replicas-engine 0.1.1090 → 0.1.1091

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.
@@ -217,6 +217,135 @@ var ASTER_MODEL_LABELS = {
217
217
  "gpt-oss-120b": "GPT-OSS 120B"
218
218
  };
219
219
 
220
+ // ../shared/src/routes/reviews.ts
221
+ import { z as z2 } from "zod";
222
+
223
+ // ../shared/src/github/url.ts
224
+ var GITHUB_HOST_RE = /(^|@|\/\/)github\.com[:/]/;
225
+ var GITHUB_REPO_SLUG_RE = /github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?(?:[/?#]|$)/i;
226
+ function isGitHubUrl(url) {
227
+ if (!url) return false;
228
+ return GITHUB_HOST_RE.test(url);
229
+ }
230
+ function parseRepoUrlSlug(url) {
231
+ if (!url) return null;
232
+ const match = url.match(GITHUB_REPO_SLUG_RE);
233
+ if (!match) return null;
234
+ return { owner: match[1].toLowerCase(), repo: match[2].toLowerCase() };
235
+ }
236
+
237
+ // ../shared/src/urls.ts
238
+ var DASHBOARD_PATH = "/dashboard";
239
+ var WEB_APP_PATHS = {
240
+ home: "/",
241
+ onboarding: "/onboarding",
242
+ workspaces: "/workspace",
243
+ environmentSetup: "/workspace/setup",
244
+ automations: "/automations",
245
+ environment: "/environment",
246
+ analytics: "/analytics",
247
+ review: "/review",
248
+ dashboard: DASHBOARD_PATH,
249
+ agents: `${DASHBOARD_PATH}/agents`,
250
+ integrations: `${DASHBOARD_PATH}/integrations`,
251
+ integrationsGithub: `${DASHBOARD_PATH}/integrations/github`,
252
+ integrationsGitlab: `${DASHBOARD_PATH}/integrations/gitlab`,
253
+ settings: `${DASHBOARD_PATH}/settings`,
254
+ billing: `${DASHBOARD_PATH}/billing`,
255
+ members: `${DASHBOARD_PATH}/members`,
256
+ learnings: `${DASHBOARD_PATH}/learnings`,
257
+ "audit-logs": `${DASHBOARD_PATH}/audit-logs`,
258
+ accountAgents: `${DASHBOARD_PATH}/account/agents`,
259
+ accountProfile: `${DASHBOARD_PATH}/account/profile`,
260
+ accountConnections: `${DASHBOARD_PATH}/account/connections`,
261
+ accountIntegrations: `${DASHBOARD_PATH}/account/integrations`,
262
+ accountApiKeys: `${DASHBOARD_PATH}/account/api-keys`,
263
+ accountPreferences: `${DASHBOARD_PATH}/account/preferences`,
264
+ fullscreenWorkspaces: "/workspaces"
265
+ };
266
+ var LEGACY_WEB_APP_PATHS = {
267
+ app: "/app",
268
+ home: "/home",
269
+ dashboardWorkspaces: `${DASHBOARD_PATH}/workspaces`
270
+ };
271
+ var PR_URL_REGEX = /github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/;
272
+ function parsePrUrl(url) {
273
+ const match = url.match(PR_URL_REGEX);
274
+ if (!match) return null;
275
+ const [, owner, repo, numberStr] = match;
276
+ const number = Number.parseInt(numberStr, 10);
277
+ if (!Number.isFinite(number)) return null;
278
+ return { owner, repo, number };
279
+ }
280
+ function parseCodeHostPrUrl(url) {
281
+ const github = parsePrUrl(url);
282
+ if (github) {
283
+ return {
284
+ ...github,
285
+ provider: "github",
286
+ host: "github.com",
287
+ repositoryPath: `${github.owner}/${github.repo}`,
288
+ repoUrl: `https://github.com/${github.owner}/${github.repo}`
289
+ };
290
+ }
291
+ let parsed;
292
+ try {
293
+ parsed = new URL(url);
294
+ } catch {
295
+ return null;
296
+ }
297
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
298
+ const segments = parsed.pathname.split("/").filter(Boolean);
299
+ const separatorIndex = segments.indexOf("-");
300
+ if (separatorIndex <= 0 || segments[separatorIndex + 1] !== "merge_requests") return null;
301
+ const number = Number.parseInt(segments[separatorIndex + 2] ?? "", 10);
302
+ if (!Number.isFinite(number)) return null;
303
+ const repositorySegments = decodePathSegments(segments.slice(0, separatorIndex));
304
+ const repo = repositorySegments[repositorySegments.length - 1];
305
+ const owner = repositorySegments[0];
306
+ if (!owner || !repo) return null;
307
+ const repositoryPath = repositorySegments.join("/");
308
+ return {
309
+ provider: "gitlab",
310
+ host: parsed.host.toLowerCase(),
311
+ owner,
312
+ repo,
313
+ number,
314
+ repositoryPath,
315
+ repoUrl: `${parsed.origin}/${repositoryPath}`
316
+ };
317
+ }
318
+ function decodePathSegments(segments) {
319
+ return segments.map((segment) => {
320
+ try {
321
+ return decodeURIComponent(segment);
322
+ } catch {
323
+ return segment;
324
+ }
325
+ });
326
+ }
327
+ function buildCodeHostPrUrl(repoUrl, provider2, prNumber) {
328
+ const normalizedRepoUrl = repoUrl.replace(/\.git$/, "");
329
+ if (provider2 === "gitlab") {
330
+ return `${normalizedRepoUrl}/-/merge_requests/${prNumber}`;
331
+ }
332
+ return `${normalizedRepoUrl}/pull/${prNumber}`;
333
+ }
334
+
335
+ // ../shared/src/routes/reviews.ts
336
+ var text = z2.string().trim().catch("");
337
+ var optionalText = z2.string().trim().min(1).optional().catch(void 0);
338
+ var pullRequestTourSchema = z2.object({
339
+ /** The tour chat that wrote this file, so a rerun doesn't show the previous run's tour as in progress. */
340
+ runId: optionalText,
341
+ headSha: optionalText,
342
+ status: z2.enum(["writing", "done"]).catch("writing"),
343
+ summary: text,
344
+ diagram: optionalText,
345
+ files: z2.array(z2.object({ path: text, explanation: text })).catch([]),
346
+ skip: z2.array(z2.object({ path: text, note: text })).catch([])
347
+ });
348
+
220
349
  // ../shared/src/languages.ts
221
350
  var EXT_TO_LANGUAGE = {
222
351
  ".ts": "typescript",
@@ -736,7 +865,7 @@ function paginateEngineLogContent(input) {
736
865
  }
737
866
 
738
867
  // ../shared/src/analytics/types.ts
739
- import { z as z2 } from "zod";
868
+ import { z as z3 } from "zod";
740
869
 
741
870
  // ../shared/src/external-api-host.ts
742
871
  function validateExternalApiHost(url, providerLabel) {
@@ -1169,19 +1298,19 @@ function hasAgentChatActivityFields(value) {
1169
1298
  function isAgentChatActivityRecord(value) {
1170
1299
  return hasAgentChatActivityFields(value) && typeof value.provider === "string" && isValidAgentProvider(value.provider);
1171
1300
  }
1172
- var credentialAccountSchema = z2.object({
1173
- ownerName: z2.string().optional(),
1174
- email: z2.string().optional(),
1301
+ var credentialAccountSchema = z3.object({
1302
+ ownerName: z3.string().optional(),
1303
+ email: z3.string().optional(),
1175
1304
  /** 1-based place in the owner's account pool, set only when the pool holds several accounts. */
1176
- ordinal: z2.number().int().positive().optional()
1305
+ ordinal: z3.number().int().positive().optional()
1177
1306
  });
1178
- var agentCredentialSnapshotSchema = z2.object({
1179
- method: z2.enum(CREDENTIAL_METHOD),
1180
- scope: z2.enum(CREDENTIAL_SCOPE),
1181
- revision: z2.string().optional(),
1307
+ var agentCredentialSnapshotSchema = z3.object({
1308
+ method: z3.enum(CREDENTIAL_METHOD),
1309
+ scope: z3.enum(CREDENTIAL_SCOPE),
1310
+ revision: z3.string().optional(),
1182
1311
  account: credentialAccountSchema.optional(),
1183
1312
  /** The `credentials` row, which tells apart accounts pooled under one method and scope. */
1184
- credentialId: z2.string().optional()
1313
+ credentialId: z3.string().optional()
1185
1314
  });
1186
1315
  function isSameCredential(a, b) {
1187
1316
  return a.method === b.method && a.scope === b.scope && a.credentialId === b.credentialId;
@@ -1227,14 +1356,14 @@ function coerceClaudePartialMessagePayload(payload) {
1227
1356
  const streamId = payload.streamId;
1228
1357
  if (typeof streamId !== "string" || !streamId) return null;
1229
1358
  const parentToolUseId = payload.parent_tool_use_id;
1230
- const text2 = typeof payload.text === "string" && payload.text ? payload.text : void 0;
1359
+ const text3 = typeof payload.text === "string" && payload.text ? payload.text : void 0;
1231
1360
  const thinking = typeof payload.thinking === "string" && payload.thinking ? payload.thinking : void 0;
1232
1361
  const tool = isRecord(payload.tool) && typeof payload.tool.id === "string" && typeof payload.tool.name === "string" ? typeof payload.tool.filePath === "string" ? { id: payload.tool.id, name: payload.tool.name, filePath: payload.tool.filePath } : typeof payload.tool.command === "string" ? { id: payload.tool.id, name: payload.tool.name, command: payload.tool.command } : void 0 : void 0;
1233
- if (!text2 && !thinking && !tool) return null;
1362
+ if (!text3 && !thinking && !tool) return null;
1234
1363
  return {
1235
1364
  streamId,
1236
1365
  parent_tool_use_id: typeof parentToolUseId === "string" ? parentToolUseId : null,
1237
- ...text2 ? { text: text2 } : {},
1366
+ ...text3 ? { text: text3 } : {},
1238
1367
  ...thinking ? { thinking } : {},
1239
1368
  ...tool ? { tool } : {},
1240
1369
  status: payload.status === "completed" ? "completed" : "in_progress"
@@ -1329,105 +1458,105 @@ function coerceChatGoalPayload(payload) {
1329
1458
  var CONTEXT_USAGE_EVENT_TYPE = "context-usage";
1330
1459
 
1331
1460
  // ../shared/src/engine/v1.ts
1332
- import { z as z3 } from "zod";
1461
+ import { z as z4 } from "zod";
1333
1462
  var MERGED_MESSAGE_SEPARATOR = "\n\n<!-- replicas:merged -->\n\n";
1334
1463
  var ENGINE_HEALTH_WAIT_HEADER = "X-Replicas-Health-Wait";
1335
1464
  var ENGINE_HEALTH_WAIT_QUERY_PARAM = "wait_ms";
1336
1465
  var ENGINE_HEALTH_MAX_WAIT_MS = 2e3;
1337
1466
  var ENGINE_ACTIVATE_PATH = "/lifecycle/activate";
1338
1467
  var ENGINE_SLEEP_PATH = "/lifecycle/sleep";
1339
- var updateChatDisplayNameRequestSchema = z3.object({
1340
- displayName: z3.string().trim().min(1).max(100)
1468
+ var updateChatDisplayNameRequestSchema = z4.object({
1469
+ displayName: z4.string().trim().min(1).max(100)
1341
1470
  });
1342
- var createChatRequestSchema = z3.object({
1343
- id: z3.string().uuid().optional(),
1344
- createdAt: z3.string().datetime().optional(),
1345
- provider: z3.enum(VALID_AGENT_PROVIDERS),
1346
- title: z3.string().min(1).optional(),
1347
- parentChatId: z3.string().uuid().optional(),
1348
- forkSourceChatId: z3.string().uuid().optional(),
1349
- sideChat: z3.boolean().optional(),
1350
- clientRequestId: z3.string().min(1).max(128).optional()
1471
+ var createChatRequestSchema = z4.object({
1472
+ id: z4.string().uuid().optional(),
1473
+ createdAt: z4.string().datetime().optional(),
1474
+ provider: z4.enum(VALID_AGENT_PROVIDERS),
1475
+ title: z4.string().min(1).optional(),
1476
+ parentChatId: z4.string().uuid().optional(),
1477
+ forkSourceChatId: z4.string().uuid().optional(),
1478
+ sideChat: z4.boolean().optional(),
1479
+ clientRequestId: z4.string().min(1).max(128).optional()
1351
1480
  }).refine((request) => !request.sideChat || request.forkSourceChatId !== void 0 && request.parentChatId === request.forkSourceChatId, {
1352
1481
  message: "A side chat must fork its parent chat"
1353
1482
  });
1354
- var spawnSubagentRequestSchema = z3.object({
1355
- provider: z3.enum(VALID_AGENT_PROVIDERS),
1356
- prompt: z3.string().min(1),
1357
- forkTurns: z3.string().regex(/^(all|none|[1-9]\d*)$/).refine(
1483
+ var spawnSubagentRequestSchema = z4.object({
1484
+ provider: z4.enum(VALID_AGENT_PROVIDERS),
1485
+ prompt: z4.string().min(1),
1486
+ forkTurns: z4.string().regex(/^(all|none|[1-9]\d*)$/).refine(
1358
1487
  (value) => value === "all" || value === "none" || Number.isSafeInteger(Number(value)),
1359
1488
  "Expected all, none, or a positive safe integer string"
1360
1489
  ).default("all"),
1361
- model: z3.string().min(1).optional(),
1362
- thinkingLevel: z3.enum(VALID_THINKING_LEVELS).optional(),
1363
- title: z3.string().min(1).optional()
1490
+ model: z4.string().min(1).optional(),
1491
+ thinkingLevel: z4.enum(VALID_THINKING_LEVELS).optional(),
1492
+ title: z4.string().min(1).optional()
1364
1493
  });
1365
- var messageSubagentRequestSchema = z3.object({
1366
- message: z3.string().min(1),
1367
- model: z3.string().min(1).optional(),
1368
- thinkingLevel: z3.enum(VALID_THINKING_LEVELS).optional()
1494
+ var messageSubagentRequestSchema = z4.object({
1495
+ message: z4.string().min(1),
1496
+ model: z4.string().min(1).optional(),
1497
+ thinkingLevel: z4.enum(VALID_THINKING_LEVELS).optional()
1369
1498
  });
1370
- var waitSubagentRequestSchema = z3.object({
1371
- timeoutMinutes: z3.coerce.number().positive().max(1440).optional()
1499
+ var waitSubagentRequestSchema = z4.object({
1500
+ timeoutMinutes: z4.coerce.number().positive().max(1440).optional()
1372
1501
  });
1373
- var subagentResponseSchema = z3.object({
1374
- chatId: z3.string().uuid(),
1375
- status: z3.enum(["working", "completed"]),
1376
- response: z3.string().optional(),
1377
- timedOut: z3.literal(true).optional(),
1378
- interruptedByUserMessage: z3.literal(true).optional()
1502
+ var subagentResponseSchema = z4.object({
1503
+ chatId: z4.string().uuid(),
1504
+ status: z4.enum(["working", "completed"]),
1505
+ response: z4.string().optional(),
1506
+ timedOut: z4.literal(true).optional(),
1507
+ interruptedByUserMessage: z4.literal(true).optional()
1379
1508
  });
1380
- var integrationErrorNotificationTargetSchema = z3.discriminatedUnion("type", [
1381
- z3.object({
1382
- type: z3.literal("slack"),
1383
- conversation: z3.object({
1384
- channelId: z3.string().min(1),
1385
- threadTs: z3.string().min(1)
1509
+ var integrationErrorNotificationTargetSchema = z4.discriminatedUnion("type", [
1510
+ z4.object({
1511
+ type: z4.literal("slack"),
1512
+ conversation: z4.object({
1513
+ channelId: z4.string().min(1),
1514
+ threadTs: z4.string().min(1)
1386
1515
  }).optional()
1387
1516
  }),
1388
- z3.object({ type: z3.literal("linear"), sessionId: z3.string().min(1) }),
1389
- z3.object({
1390
- type: z3.literal("code_host"),
1391
- provider: z3.enum(["github", "gitlab"]),
1392
- resource: z3.enum(["issue", "pull_request"]),
1393
- repositoryId: z3.string().min(1),
1394
- resourceNumber: z3.number().int().positive()
1517
+ z4.object({ type: z4.literal("linear"), sessionId: z4.string().min(1) }),
1518
+ z4.object({
1519
+ type: z4.literal("code_host"),
1520
+ provider: z4.enum(["github", "gitlab"]),
1521
+ resource: z4.enum(["issue", "pull_request"]),
1522
+ repositoryId: z4.string().min(1),
1523
+ resourceNumber: z4.number().int().positive()
1395
1524
  }),
1396
- z3.object({ type: z3.literal("automation"), executionId: z3.string().min(1) })
1525
+ z4.object({ type: z4.literal("automation"), executionId: z4.string().min(1) })
1397
1526
  ]);
1398
- var sendChatMessageRequestSchema = z3.object({
1399
- messageId: z3.string().min(1).optional(),
1400
- submittedAt: z3.string().datetime().optional(),
1401
- message: z3.string().min(1),
1402
- model: z3.string().optional(),
1403
- customInstructions: z3.string().optional(),
1404
- planMode: z3.boolean().optional(),
1405
- images: z3.array(z3.object({
1406
- type: z3.literal("image"),
1407
- source: z3.discriminatedUnion("type", [
1408
- z3.object({ type: z3.literal("base64"), media_type: z3.enum(IMAGE_MEDIA_TYPES), data: z3.string().min(1) }),
1409
- z3.object({ type: z3.literal("url"), url: z3.string().url() })
1527
+ var sendChatMessageRequestSchema = z4.object({
1528
+ messageId: z4.string().min(1).optional(),
1529
+ submittedAt: z4.string().datetime().optional(),
1530
+ message: z4.string().min(1),
1531
+ model: z4.string().optional(),
1532
+ customInstructions: z4.string().optional(),
1533
+ planMode: z4.boolean().optional(),
1534
+ images: z4.array(z4.object({
1535
+ type: z4.literal("image"),
1536
+ source: z4.discriminatedUnion("type", [
1537
+ z4.object({ type: z4.literal("base64"), media_type: z4.enum(IMAGE_MEDIA_TYPES), data: z4.string().min(1) }),
1538
+ z4.object({ type: z4.literal("url"), url: z4.string().url() })
1410
1539
  ])
1411
1540
  })).optional(),
1412
- canvasUploadIds: z3.array(z3.string().min(1)).optional(),
1413
- thinkingLevel: z3.enum(VALID_THINKING_LEVELS).optional(),
1414
- goalMode: z3.boolean().optional(),
1415
- fastMode: z3.boolean().optional(),
1416
- ultrafastMode: z3.boolean().optional(),
1417
- source: z3.enum(MESSAGE_SOURCES).optional(),
1418
- enableInteractiveTools: z3.boolean().optional(),
1419
- type: z3.string().min(1).optional(),
1420
- merge: z3.boolean().optional(),
1421
- idempotencyKey: z3.string().min(1).max(128).optional(),
1422
- automationId: z3.string().optional(),
1423
- environmentId: z3.string().min(1).optional(),
1424
- senderUserId: z3.string().optional(),
1425
- senderEmail: z3.string().optional(),
1426
- senderDisplayName: z3.string().optional(),
1427
- senderAvatarUrl: z3.string().optional(),
1541
+ canvasUploadIds: z4.array(z4.string().min(1)).optional(),
1542
+ thinkingLevel: z4.enum(VALID_THINKING_LEVELS).optional(),
1543
+ goalMode: z4.boolean().optional(),
1544
+ fastMode: z4.boolean().optional(),
1545
+ ultrafastMode: z4.boolean().optional(),
1546
+ source: z4.enum(MESSAGE_SOURCES).optional(),
1547
+ enableInteractiveTools: z4.boolean().optional(),
1548
+ type: z4.string().min(1).optional(),
1549
+ merge: z4.boolean().optional(),
1550
+ idempotencyKey: z4.string().min(1).max(128).optional(),
1551
+ automationId: z4.string().optional(),
1552
+ environmentId: z4.string().min(1).optional(),
1553
+ senderUserId: z4.string().optional(),
1554
+ senderEmail: z4.string().optional(),
1555
+ senderDisplayName: z4.string().optional(),
1556
+ senderAvatarUrl: z4.string().optional(),
1428
1557
  errorNotificationTarget: integrationErrorNotificationTargetSchema.optional(),
1429
- errorNotificationTargets: z3.array(integrationErrorNotificationTargetSchema).optional(),
1430
- streamSlackActivity: z3.boolean().optional()
1558
+ errorNotificationTargets: z4.array(integrationErrorNotificationTargetSchema).optional(),
1559
+ streamSlackActivity: z4.boolean().optional()
1431
1560
  }).passthrough();
1432
1561
  function isChatMessageSender(value) {
1433
1562
  return isRecord(value) && (value.messageId === void 0 || typeof value.messageId === "string") && typeof value.senderUserId === "string" && typeof value.senderEmail === "string" && typeof value.recordedAt === "string";
@@ -1683,60 +1812,60 @@ function isSubagentMcpServerName(server) {
1683
1812
  }
1684
1813
 
1685
1814
  // ../shared/src/workspace-identity.ts
1686
- import { z as z4 } from "zod";
1815
+ import { z as z5 } from "zod";
1687
1816
  var WORKSPACE_IDENTITY_AUDIENCE = "replicas:workspace";
1688
1817
  var AWS_SOURCE_IDENTITY_CLAIM = "https://aws.amazon.com/source_identity";
1689
1818
  var WORKSPACE_TOKEN_TTL_SECONDS = 15 * 60;
1690
1819
  var IDENTITY_PROXY_PORT = 17323;
1691
1820
  var IDENTITY_TOKEN_PATH = "/token";
1692
- var workspaceAudienceSchema = z4.string().min(1).max(255).regex(/^[\x21-\x7e]+$/, "Audience must be a single printable token without spaces");
1693
- var workspaceTokenRequestSchema = z4.object({
1821
+ var workspaceAudienceSchema = z5.string().min(1).max(255).regex(/^[\x21-\x7e]+$/, "Audience must be a single printable token without spaces");
1822
+ var workspaceTokenRequestSchema = z5.object({
1694
1823
  audience: workspaceAudienceSchema.optional(),
1695
- aws_source_identity: z4.boolean().optional()
1824
+ aws_source_identity: z5.boolean().optional()
1696
1825
  });
1697
- var workspaceTokenClaimsSchema = z4.object({
1698
- iss: z4.string(),
1699
- sub: z4.string(),
1700
- aud: z4.string(),
1701
- iat: z4.number().int(),
1702
- nbf: z4.number().int(),
1703
- exp: z4.number().int(),
1704
- jti: z4.string(),
1705
- organization_id: z4.string().uuid(),
1706
- workspace_id: z4.string().uuid(),
1707
- environment_id: z4.string().uuid(),
1708
- creator_id: z4.string().uuid().nullable(),
1709
- creator_email: z4.string().nullable().default(null),
1710
- [AWS_SOURCE_IDENTITY_CLAIM]: z4.string().uuid().optional()
1826
+ var workspaceTokenClaimsSchema = z5.object({
1827
+ iss: z5.string(),
1828
+ sub: z5.string(),
1829
+ aud: z5.string(),
1830
+ iat: z5.number().int(),
1831
+ nbf: z5.number().int(),
1832
+ exp: z5.number().int(),
1833
+ jti: z5.string(),
1834
+ organization_id: z5.string().uuid(),
1835
+ workspace_id: z5.string().uuid(),
1836
+ environment_id: z5.string().uuid(),
1837
+ creator_id: z5.string().uuid().nullable(),
1838
+ creator_email: z5.string().nullable().default(null),
1839
+ [AWS_SOURCE_IDENTITY_CLAIM]: z5.string().uuid().optional()
1711
1840
  }).passthrough();
1712
- var workspaceTokenResponseSchema = z4.object({
1713
- issuer: z4.string(),
1714
- audience: z4.string(),
1715
- token: z4.string(),
1716
- expires_at: z4.string()
1841
+ var workspaceTokenResponseSchema = z5.object({
1842
+ issuer: z5.string(),
1843
+ audience: z5.string(),
1844
+ token: z5.string(),
1845
+ expires_at: z5.string()
1717
1846
  });
1718
- var legacyWorkspaceTokenBundleSchema = z4.object({
1719
- version: z4.literal(1),
1720
- issuer: z4.string(),
1721
- default_audience: z4.string(),
1722
- tokens: z4.record(z4.string(), z4.object({ token: z4.string(), expires_at: z4.string() }))
1847
+ var legacyWorkspaceTokenBundleSchema = z5.object({
1848
+ version: z5.literal(1),
1849
+ issuer: z5.string(),
1850
+ default_audience: z5.string(),
1851
+ tokens: z5.record(z5.string(), z5.object({ token: z5.string(), expires_at: z5.string() }))
1723
1852
  });
1724
- var mcpWorkloadAuthSchema = z4.strictObject({
1725
- type: z4.literal("workspace_identity"),
1853
+ var mcpWorkloadAuthSchema = z5.strictObject({
1854
+ type: z5.literal("workspace_identity"),
1726
1855
  audience: workspaceAudienceSchema
1727
1856
  });
1728
- var mcpAuthSchema = z4.discriminatedUnion("type", [
1857
+ var mcpAuthSchema = z5.discriminatedUnion("type", [
1729
1858
  mcpWorkloadAuthSchema,
1730
- z4.strictObject({ type: z4.literal("oauth") })
1859
+ z5.strictObject({ type: z5.literal("oauth") })
1731
1860
  ]);
1732
- var engineMcpOAuthTokenRequestSchema = z4.object({
1733
- environment_mcp_id: z4.string().uuid(),
1734
- force_refresh: z4.boolean().optional()
1861
+ var engineMcpOAuthTokenRequestSchema = z5.object({
1862
+ environment_mcp_id: z5.string().uuid(),
1863
+ force_refresh: z5.boolean().optional()
1735
1864
  });
1736
- var engineMcpOAuthTokenResponseSchema = z4.object({
1737
- url: z4.string(),
1738
- access_token: z4.string(),
1739
- expires_at: z4.string().nullable()
1865
+ var engineMcpOAuthTokenResponseSchema = z5.object({
1866
+ url: z5.string(),
1867
+ access_token: z5.string(),
1868
+ expires_at: z5.string().nullable()
1740
1869
  });
1741
1870
 
1742
1871
  // ../shared/src/runtime-env.ts
@@ -1810,20 +1939,6 @@ function parsePosixEnvFile(content) {
1810
1939
  return result;
1811
1940
  }
1812
1941
 
1813
- // ../shared/src/github/url.ts
1814
- var GITHUB_HOST_RE = /(^|@|\/\/)github\.com[:/]/;
1815
- var GITHUB_REPO_SLUG_RE = /github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?(?:[/?#]|$)/i;
1816
- function isGitHubUrl(url) {
1817
- if (!url) return false;
1818
- return GITHUB_HOST_RE.test(url);
1819
- }
1820
- function parseRepoUrlSlug(url) {
1821
- if (!url) return null;
1822
- const match = url.match(GITHUB_REPO_SLUG_RE);
1823
- if (!match) return null;
1824
- return { owner: match[1].toLowerCase(), repo: match[2].toLowerCase() };
1825
- }
1826
-
1827
1942
  // ../shared/src/git.ts
1828
1943
  var GIT_CREDENTIAL_HELPER_FILENAME = ".git-credential-replicas";
1829
1944
  var GITHUB_CREDENTIAL_REFRESH_PATH = "/git-credentials/github/refresh";
@@ -1942,19 +2057,19 @@ function gitIdentityConfigCommands(identity, scope = "global") {
1942
2057
  }
1943
2058
 
1944
2059
  // ../shared/src/headless-agent.ts
1945
- import { z as z5 } from "zod";
1946
- var headlessAgentRequestSchema = z5.object({
1947
- mode: z5.literal("structured"),
1948
- agent: z5.custom(
2060
+ import { z as z6 } from "zod";
2061
+ var headlessAgentRequestSchema = z6.object({
2062
+ mode: z6.literal("structured"),
2063
+ agent: z6.custom(
1949
2064
  (value) => typeof value === "string" && isValidAgentProvider(value)
1950
2065
  ),
1951
- model: z5.string().min(1),
1952
- prompt: z5.string(),
1953
- workingDirectory: z5.string().min(1),
1954
- timeoutSeconds: z5.number().int().min(1).max(1800).default(300),
1955
- thinkingLevel: z5.enum(STANDARD_THINKING_LEVELS).optional(),
1956
- codexOauthTokens: z5.object({ accessToken: z5.string(), accountId: z5.string() }).optional(),
1957
- outputSchema: z5.record(z5.string(), z5.json())
2066
+ model: z6.string().min(1),
2067
+ prompt: z6.string(),
2068
+ workingDirectory: z6.string().min(1),
2069
+ timeoutSeconds: z6.number().int().min(1).max(1800).default(300),
2070
+ thinkingLevel: z6.enum(STANDARD_THINKING_LEVELS).optional(),
2071
+ codexOauthTokens: z6.object({ accessToken: z6.string(), accountId: z6.string() }).optional(),
2072
+ outputSchema: z6.record(z6.string(), z6.json())
1958
2073
  });
1959
2074
  var headlessAgentUsagePath = (outputPath) => `${outputPath}.usage`;
1960
2075
 
@@ -2016,8 +2131,8 @@ var RATE_LIMIT_PATTERNS = [
2016
2131
  ];
2017
2132
  var HTTP_429_PATTERN = /(?:^|[^0-9])429(?:$|[^0-9])/;
2018
2133
  var HTTP_CONTEXT_PATTERN = /(api error|request|response|status|http)/;
2019
- function detectAgentQuotaLimit(text2) {
2020
- const normalized = text2.toLowerCase();
2134
+ function detectAgentQuotaLimit(text3) {
2135
+ const normalized = text3.toLowerCase();
2021
2136
  if (!normalized) return null;
2022
2137
  if (OUT_OF_CREDITS_PATTERNS.some((pattern) => pattern.test(normalized))) return "out_of_credits";
2023
2138
  if (RATE_LIMIT_PATTERNS.some((pattern) => pattern.test(normalized))) return "rate_limit";
@@ -2050,12 +2165,12 @@ function describeAuthFallback(payload) {
2050
2165
  }
2051
2166
 
2052
2167
  // ../shared/src/workspace-credentials.ts
2053
- import { z as z6 } from "zod";
2168
+ import { z as z7 } from "zod";
2054
2169
  var WORKSPACE_CREDENTIAL_PROVIDERS = ["claude", "codex"];
2055
- var workspaceCredentialProviderSchema = z6.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
2170
+ var workspaceCredentialProviderSchema = z7.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
2056
2171
  var workspaceCredentialSelectionSchema = agentCredentialSnapshotSchema.omit({ revision: true, account: true, credentialId: true });
2057
2172
  var createWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend({
2058
- provider: z6.enum(VALID_AGENT_PROVIDERS)
2173
+ provider: z7.enum(VALID_AGENT_PROVIDERS)
2059
2174
  }).refine(({ provider: provider2, method }) => agentCredentialMethods(provider2).includes(method), {
2060
2175
  message: "This inference provider is not supported by this agent"
2061
2176
  });
@@ -2066,59 +2181,59 @@ var switchWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend(
2066
2181
  });
2067
2182
 
2068
2183
  // ../shared/src/chat-fork.ts
2069
- import { z as z8 } from "zod";
2184
+ import { z as z9 } from "zod";
2070
2185
 
2071
2186
  // ../shared/src/fallback-chains.ts
2072
- import { z as z7 } from "zod";
2073
- var fallbackHarnessStepSchema = z7.object({
2074
- kind: z7.literal("harness"),
2075
- provider: z7.enum(VALID_AGENT_PROVIDERS),
2076
- model: z7.string().min(1),
2077
- thinkingLevel: z7.enum(VALID_THINKING_LEVELS).optional()
2187
+ import { z as z8 } from "zod";
2188
+ var fallbackHarnessStepSchema = z8.object({
2189
+ kind: z8.literal("harness"),
2190
+ provider: z8.enum(VALID_AGENT_PROVIDERS),
2191
+ model: z8.string().min(1),
2192
+ thinkingLevel: z8.enum(VALID_THINKING_LEVELS).optional()
2078
2193
  });
2079
- var fallbackPlanStepSchema = z7.discriminatedUnion("kind", [
2080
- z7.object({
2081
- kind: z7.literal("credentials"),
2082
- methods: z7.array(z7.custom(isAuthMethod)).min(1),
2083
- models: z7.record(z7.string(), z7.string().min(1)).optional()
2194
+ var fallbackPlanStepSchema = z8.discriminatedUnion("kind", [
2195
+ z8.object({
2196
+ kind: z8.literal("credentials"),
2197
+ methods: z8.array(z8.custom(isAuthMethod)).min(1),
2198
+ models: z8.record(z8.string(), z8.string().min(1)).optional()
2084
2199
  }),
2085
2200
  fallbackHarnessStepSchema
2086
2201
  ]);
2087
- var fallbackPlanResponseSchema = z7.object({ steps: z7.array(fallbackPlanStepSchema) });
2202
+ var fallbackPlanResponseSchema = z8.object({ steps: z8.array(fallbackPlanStepSchema) });
2088
2203
 
2089
2204
  // ../shared/src/chat-fork.ts
2090
- var quotaLimitKindSchema = z8.enum(["rate_limit", "out_of_credits"]);
2091
- var chatForkInfoSchema = z8.object({
2092
- source: z8.object({
2093
- chatId: z8.string().min(1),
2094
- provider: z8.enum(VALID_AGENT_PROVIDERS),
2095
- title: z8.string()
2205
+ var quotaLimitKindSchema = z9.enum(["rate_limit", "out_of_credits"]);
2206
+ var chatForkInfoSchema = z9.object({
2207
+ source: z9.object({
2208
+ chatId: z9.string().min(1),
2209
+ provider: z9.enum(VALID_AGENT_PROVIDERS),
2210
+ title: z9.string()
2096
2211
  }),
2097
- trigger: z8.enum(["manual", "auto", "side"]),
2212
+ trigger: z9.enum(["manual", "auto", "side"]),
2098
2213
  reason: quotaLimitKindSchema.optional(),
2099
- state: z8.enum(["preparing", "ready", "failed"]),
2100
- error: z8.string().optional(),
2101
- startedAt: z8.string(),
2102
- completedAt: z8.string().optional()
2214
+ state: z9.enum(["preparing", "ready", "failed"]),
2215
+ error: z9.string().optional(),
2216
+ startedAt: z9.string(),
2217
+ completedAt: z9.string().optional()
2103
2218
  });
2104
2219
  function coerceChatForkInfo(value) {
2105
2220
  const parsed = chatForkInfoSchema.safeParse(value);
2106
2221
  return parsed.success ? parsed.data : null;
2107
2222
  }
2108
- var forkChatRequestSchema = z8.object({
2109
- provider: z8.enum(VALID_AGENT_PROVIDERS),
2110
- model: z8.string().min(1).optional(),
2111
- thinkingLevel: z8.enum(VALID_THINKING_LEVELS).optional(),
2112
- title: z8.string().min(1).max(200).optional(),
2113
- message: z8.string().trim().optional(),
2114
- id: z8.string().uuid().optional(),
2115
- clientRequestId: z8.string().min(1).max(128).optional(),
2116
- enableInteractiveTools: z8.boolean().optional(),
2223
+ var forkChatRequestSchema = z9.object({
2224
+ provider: z9.enum(VALID_AGENT_PROVIDERS),
2225
+ model: z9.string().min(1).optional(),
2226
+ thinkingLevel: z9.enum(VALID_THINKING_LEVELS).optional(),
2227
+ title: z9.string().min(1).max(200).optional(),
2228
+ message: z9.string().trim().optional(),
2229
+ id: z9.string().uuid().optional(),
2230
+ clientRequestId: z9.string().min(1).max(128).optional(),
2231
+ enableInteractiveTools: z9.boolean().optional(),
2117
2232
  // Server-injected by the monolith from the authenticated request; never trusted from clients.
2118
- senderUserId: z8.string().optional(),
2119
- senderEmail: z8.string().optional(),
2120
- senderDisplayName: z8.string().optional(),
2121
- senderAvatarUrl: z8.string().optional()
2233
+ senderUserId: z9.string().optional(),
2234
+ senderEmail: z9.string().optional(),
2235
+ senderDisplayName: z9.string().optional(),
2236
+ senderAvatarUrl: z9.string().optional()
2122
2237
  });
2123
2238
  function describeQuotaLimit(reason) {
2124
2239
  return reason === "out_of_credits" ? "ran out of credits" : "hit its usage limit";
@@ -2127,10 +2242,10 @@ function describeChatForkReason(reason, provider2) {
2127
2242
  return reason ? `${getProviderDisplayName(provider2)} ${describeQuotaLimit(reason)}` : null;
2128
2243
  }
2129
2244
  var AGENT_QUOTA_EXHAUSTED_EVENT_TYPE = "agent-quota-exhausted";
2130
- var agentQuotaExhaustedPayloadSchema = z8.object({
2131
- provider: z8.enum(VALID_AGENT_PROVIDERS),
2245
+ var agentQuotaExhaustedPayloadSchema = z9.object({
2246
+ provider: z9.enum(VALID_AGENT_PROVIDERS),
2132
2247
  reason: quotaLimitKindSchema,
2133
- detail: z8.string().optional(),
2248
+ detail: z9.string().optional(),
2134
2249
  forkTo: fallbackHarnessStepSchema.optional()
2135
2250
  });
2136
2251
  function defaultForkChatTitle(source, provider2) {
@@ -2138,10 +2253,10 @@ function defaultForkChatTitle(source, provider2) {
2138
2253
  }
2139
2254
 
2140
2255
  // ../shared/src/credential-pool.ts
2141
- import { z as z9 } from "zod";
2256
+ import { z as z10 } from "zod";
2142
2257
  var MAX_CREDENTIAL_POOL_ACCOUNTS = 10;
2143
- var reorderCredentialPoolSchema = z9.object({
2144
- credential_ids: z9.array(z9.string().uuid()).min(1).max(MAX_CREDENTIAL_POOL_ACCOUNTS)
2258
+ var reorderCredentialPoolSchema = z10.object({
2259
+ credential_ids: z10.array(z10.string().uuid()).min(1).max(MAX_CREDENTIAL_POOL_ACCOUNTS)
2145
2260
  });
2146
2261
 
2147
2262
  // ../shared/src/display-message/types.ts
@@ -2277,8 +2392,8 @@ function indexOrEnd(src, search, from) {
2277
2392
  const index = src.indexOf(search, from);
2278
2393
  return index < 0 ? src.length : index;
2279
2394
  }
2280
- function decodeAnsiC(text2) {
2281
- return text2.replace(/\\(x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{1,4}|[0-7]{1,3}|[\s\S])/g, (_match, escape) => {
2395
+ function decodeAnsiC(text3) {
2396
+ return text3.replace(/\\(x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{1,4}|[0-7]{1,3}|[\s\S])/g, (_match, escape) => {
2282
2397
  if (escape[0] === "x" || escape[0] === "u") return String.fromCharCode(parseInt(escape.slice(1), 16));
2283
2398
  if (/^[0-7]/.test(escape)) return String.fromCharCode(parseInt(escape, 8));
2284
2399
  return ANSI_C_ESCAPES[escape] ?? escape;
@@ -2295,8 +2410,8 @@ function staticOutput(argv, stdin) {
2295
2410
  if (flags.includes("n")) newline = false;
2296
2411
  if (flags.includes("e")) escapes = true;
2297
2412
  }
2298
- const text2 = args.join(" ");
2299
- return (escapes ? decodeAnsiC(text2) : text2) + (newline ? "\n" : "");
2413
+ const text3 = args.join(" ");
2414
+ return (escapes ? decodeAnsiC(text3) : text3) + (newline ? "\n" : "");
2300
2415
  }
2301
2416
  if (name === "printf" && args.length > 0) {
2302
2417
  const format = decodeAnsiC(args[0]);
@@ -2456,8 +2571,8 @@ function parseUntil(scope, start, closeParen) {
2456
2571
  let quoted = false;
2457
2572
  let redirect = null;
2458
2573
  let parens = 0;
2459
- const append = (text2, isQuoted = false) => {
2460
- word = (word ?? "") + text2;
2574
+ const append = (text3, isQuoted = false) => {
2575
+ word = (word ?? "") + text3;
2461
2576
  quoted ||= isQuoted;
2462
2577
  };
2463
2578
  const endWord = () => {
@@ -2653,10 +2768,10 @@ function planItemsFromMessage(message2) {
2653
2768
  if (!todos) return null;
2654
2769
  return todos.flatMap((todo) => {
2655
2770
  if (!todo || typeof todo !== "object") return [];
2656
- const text2 = "content" in todo && typeof todo.content === "string" ? todo.content : "text" in todo && typeof todo.text === "string" ? todo.text : null;
2771
+ const text3 = "content" in todo && typeof todo.content === "string" ? todo.content : "text" in todo && typeof todo.text === "string" ? todo.text : null;
2657
2772
  const status = "status" in todo ? todo.status : null;
2658
- if (!text2) return [];
2659
- return [{ text: text2, status: status === "completed" || status === "in_progress" ? status : "pending" }];
2773
+ if (!text3) return [];
2774
+ return [{ text: text3, status: status === "completed" || status === "in_progress" ? status : "pending" }];
2660
2775
  });
2661
2776
  }
2662
2777
  function getDisplayMessageStatus(message2) {
@@ -2960,110 +3075,13 @@ function subagentChatId(message2) {
2960
3075
  }
2961
3076
 
2962
3077
  // ../shared/src/multitask-events.ts
2963
- import { z as z15 } from "zod";
2964
-
2965
- // ../shared/src/urls.ts
2966
- var DASHBOARD_PATH = "/dashboard";
2967
- var WEB_APP_PATHS = {
2968
- home: "/",
2969
- onboarding: "/onboarding",
2970
- workspaces: "/workspace",
2971
- environmentSetup: "/workspace/setup",
2972
- automations: "/automations",
2973
- environment: "/environment",
2974
- analytics: "/analytics",
2975
- dashboard: DASHBOARD_PATH,
2976
- agents: `${DASHBOARD_PATH}/agents`,
2977
- integrations: `${DASHBOARD_PATH}/integrations`,
2978
- integrationsGithub: `${DASHBOARD_PATH}/integrations/github`,
2979
- integrationsGitlab: `${DASHBOARD_PATH}/integrations/gitlab`,
2980
- settings: `${DASHBOARD_PATH}/settings`,
2981
- billing: `${DASHBOARD_PATH}/billing`,
2982
- members: `${DASHBOARD_PATH}/members`,
2983
- learnings: `${DASHBOARD_PATH}/learnings`,
2984
- "audit-logs": `${DASHBOARD_PATH}/audit-logs`,
2985
- accountAgents: `${DASHBOARD_PATH}/account/agents`,
2986
- accountProfile: `${DASHBOARD_PATH}/account/profile`,
2987
- accountConnections: `${DASHBOARD_PATH}/account/connections`,
2988
- accountIntegrations: `${DASHBOARD_PATH}/account/integrations`,
2989
- accountApiKeys: `${DASHBOARD_PATH}/account/api-keys`,
2990
- accountPreferences: `${DASHBOARD_PATH}/account/preferences`,
2991
- fullscreenWorkspaces: "/workspaces"
2992
- };
2993
- var LEGACY_WEB_APP_PATHS = {
2994
- app: "/app",
2995
- home: "/home",
2996
- dashboardWorkspaces: `${DASHBOARD_PATH}/workspaces`
2997
- };
2998
- var PR_URL_REGEX = /github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/;
2999
- function parsePrUrl(url) {
3000
- const match = url.match(PR_URL_REGEX);
3001
- if (!match) return null;
3002
- const [, owner, repo, numberStr] = match;
3003
- const number = Number.parseInt(numberStr, 10);
3004
- if (!Number.isFinite(number)) return null;
3005
- return { owner, repo, number };
3006
- }
3007
- function parseCodeHostPrUrl(url) {
3008
- const github = parsePrUrl(url);
3009
- if (github) {
3010
- return {
3011
- ...github,
3012
- provider: "github",
3013
- host: "github.com",
3014
- repositoryPath: `${github.owner}/${github.repo}`,
3015
- repoUrl: `https://github.com/${github.owner}/${github.repo}`
3016
- };
3017
- }
3018
- let parsed;
3019
- try {
3020
- parsed = new URL(url);
3021
- } catch {
3022
- return null;
3023
- }
3024
- if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
3025
- const segments = parsed.pathname.split("/").filter(Boolean);
3026
- const separatorIndex = segments.indexOf("-");
3027
- if (separatorIndex <= 0 || segments[separatorIndex + 1] !== "merge_requests") return null;
3028
- const number = Number.parseInt(segments[separatorIndex + 2] ?? "", 10);
3029
- if (!Number.isFinite(number)) return null;
3030
- const repositorySegments = decodePathSegments(segments.slice(0, separatorIndex));
3031
- const repo = repositorySegments[repositorySegments.length - 1];
3032
- const owner = repositorySegments[0];
3033
- if (!owner || !repo) return null;
3034
- const repositoryPath = repositorySegments.join("/");
3035
- return {
3036
- provider: "gitlab",
3037
- host: parsed.host.toLowerCase(),
3038
- owner,
3039
- repo,
3040
- number,
3041
- repositoryPath,
3042
- repoUrl: `${parsed.origin}/${repositoryPath}`
3043
- };
3044
- }
3045
- function decodePathSegments(segments) {
3046
- return segments.map((segment) => {
3047
- try {
3048
- return decodeURIComponent(segment);
3049
- } catch {
3050
- return segment;
3051
- }
3052
- });
3053
- }
3054
- function buildCodeHostPrUrl(repoUrl, provider2, prNumber) {
3055
- const normalizedRepoUrl = repoUrl.replace(/\.git$/, "");
3056
- if (provider2 === "gitlab") {
3057
- return `${normalizedRepoUrl}/-/merge_requests/${prNumber}`;
3058
- }
3059
- return `${normalizedRepoUrl}/pull/${prNumber}`;
3060
- }
3078
+ import { z as z16 } from "zod";
3061
3079
 
3062
3080
  // ../shared/src/replicas-mcp.ts
3063
- import { z as z14 } from "zod";
3081
+ import { z as z15 } from "zod";
3064
3082
 
3065
3083
  // ../shared/src/automations/trigger-schemas.ts
3066
- import { z as z10 } from "zod";
3084
+ import { z as z11 } from "zod";
3067
3085
 
3068
3086
  // ../shared/src/uuid.ts
3069
3087
  function createUuidFromHex(value) {
@@ -3080,47 +3098,47 @@ function getReviewerLoginsError(event, logins) {
3080
3098
  if (isReviewRequested === !!logins?.some((login) => login.trim().replace(/^@+/, ""))) return null;
3081
3099
  return isReviewRequested ? "The PR review requested trigger needs at least one GitHub username" : "Requested reviewers only apply to the PR review requested trigger";
3082
3100
  }
3083
- var repositoryTriggerConfigSchema = z10.object({
3084
- event: z10.string(),
3085
- repository_ids: z10.array(z10.string().regex(UUID_RE, "must be a repository id")).optional(),
3086
- group_pr_events: z10.boolean().optional(),
3087
- excluded_actors: z10.array(z10.string()).optional(),
3088
- reviewer_logins: z10.array(z10.string()).optional()
3101
+ var repositoryTriggerConfigSchema = z11.object({
3102
+ event: z11.string(),
3103
+ repository_ids: z11.array(z11.string().regex(UUID_RE, "must be a repository id")).optional(),
3104
+ group_pr_events: z11.boolean().optional(),
3105
+ excluded_actors: z11.array(z11.string()).optional(),
3106
+ reviewer_logins: z11.array(z11.string()).optional()
3089
3107
  });
3090
- var cronTriggerSchema = z10.object({ type: z10.literal("cron"), config: z10.object({ schedule: z10.string(), timezone: z10.string().optional() }) });
3091
- var githubTriggerSchema = z10.object({
3092
- type: z10.literal("github"),
3108
+ var cronTriggerSchema = z11.object({ type: z11.literal("cron"), config: z11.object({ schedule: z11.string(), timezone: z11.string().optional() }) });
3109
+ var githubTriggerSchema = z11.object({
3110
+ type: z11.literal("github"),
3093
3111
  config: repositoryTriggerConfigSchema.superRefine((config, ctx) => {
3094
3112
  const message2 = getReviewerLoginsError(config.event, config.reviewer_logins);
3095
3113
  if (message2) ctx.addIssue({ code: "custom", message: message2, path: ["reviewer_logins"] });
3096
3114
  })
3097
3115
  });
3098
- var gitlabTriggerSchema = z10.object({ type: z10.literal("gitlab"), config: repositoryTriggerConfigSchema });
3099
- var automationTriggerSchema = z10.discriminatedUnion("type", [
3116
+ var gitlabTriggerSchema = z11.object({ type: z11.literal("gitlab"), config: repositoryTriggerConfigSchema });
3117
+ var automationTriggerSchema = z11.discriminatedUnion("type", [
3100
3118
  cronTriggerSchema,
3101
3119
  githubTriggerSchema,
3102
3120
  gitlabTriggerSchema,
3103
- z10.object({ type: z10.literal("slack"), config: z10.object({ event: z10.string(), channel_ids: z10.array(z10.string()).optional(), group_thread_replies: z10.boolean().optional() }) }),
3104
- z10.object({ type: z10.literal("sentry"), config: z10.object({ event: z10.string(), project_slugs: z10.array(z10.string()).optional(), min_level: z10.string().optional() }) }),
3105
- z10.object({ type: z10.literal("custom"), config: z10.object({}) })
3121
+ z11.object({ type: z11.literal("slack"), config: z11.object({ event: z11.string(), channel_ids: z11.array(z11.string()).optional(), group_thread_replies: z11.boolean().optional() }) }),
3122
+ z11.object({ type: z11.literal("sentry"), config: z11.object({ event: z11.string(), project_slugs: z11.array(z11.string()).optional(), min_level: z11.string().optional() }) }),
3123
+ z11.object({ type: z11.literal("custom"), config: z11.object({}) })
3106
3124
  ]);
3107
3125
 
3108
3126
  // ../shared/src/routes/environment.ts
3109
- import { z as z11 } from "zod";
3127
+ import { z as z12 } from "zod";
3110
3128
  var ENVIRONMENT_MCP_TRANSPORTS = ["stdio", "http", "sse"];
3111
- var stringMap = z11.record(z11.string(), z11.string());
3112
- var createEnvironmentMcpRequestSchema = z11.object({
3113
- name: z11.string(),
3114
- transport: z11.enum(ENVIRONMENT_MCP_TRANSPORTS),
3115
- config: z11.union([
3116
- z11.object({ command: z11.string().min(1), args: z11.array(z11.string()).optional(), env: stringMap.optional() }),
3117
- z11.object({ url: z11.url(), headers: stringMap.optional(), auth: mcpAuthSchema.optional() })
3129
+ var stringMap = z12.record(z12.string(), z12.string());
3130
+ var createEnvironmentMcpRequestSchema = z12.object({
3131
+ name: z12.string(),
3132
+ transport: z12.enum(ENVIRONMENT_MCP_TRANSPORTS),
3133
+ config: z12.union([
3134
+ z12.object({ command: z12.string().min(1), args: z12.array(z12.string()).optional(), env: stringMap.optional() }),
3135
+ z12.object({ url: z12.url(), headers: stringMap.optional(), auth: mcpAuthSchema.optional() })
3118
3136
  ]).describe("stdio: `{ command, args, env }`. http/sse: `{ url, headers }`.")
3119
3137
  });
3120
3138
  var updateEnvironmentMcpRequestSchema = createEnvironmentMcpRequestSchema.partial();
3121
3139
 
3122
3140
  // ../shared/src/routes/workspaces.ts
3123
- import { z as z13 } from "zod";
3141
+ import { z as z14 } from "zod";
3124
3142
 
3125
3143
  // ../shared/src/default-skills/replicas-agent/abilities/computer.ts
3126
3144
  var SECTION = `### Computer use (Linux desktop control)
@@ -3392,7 +3410,7 @@ var DOCKER_ABILITY = {
3392
3410
  };
3393
3411
 
3394
3412
  // ../shared/src/routes/environment-setups.ts
3395
- import { z as z12 } from "zod";
3413
+ import { z as z13 } from "zod";
3396
3414
  var ENVIRONMENT_SETUP_STEPS = [
3397
3415
  { key: "understand", label: "Understand the codebase" },
3398
3416
  { key: "install", label: "Install dependencies and run the app" },
@@ -3426,17 +3444,17 @@ var ENVIRONMENT_SETUP_LIMITS = {
3426
3444
  };
3427
3445
  var ENVIRONMENT_SETUP_VARIABLE_WAIT = { defaultMs: 5 * 6e4, maxMs: 15 * 6e4, pollMs: 5e3 };
3428
3446
  var VARIABLE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
3429
- var text = (max) => max === void 0 ? z12.string().trim() : z12.string().trim().max(max);
3430
- var requiredText = (max) => text(max).min(1, "must not be empty");
3431
- var optionalText = (max) => text(max).nullish().transform((value) => value || null);
3432
- var clearableText = (max) => text(max).nullish().transform((value) => value === void 0 ? void 0 : value || null);
3433
- var list = (item, max) => max === void 0 ? z12.array(item) : z12.array(item).max(max);
3447
+ var text2 = (max) => max === void 0 ? z13.string().trim() : z13.string().trim().max(max);
3448
+ var requiredText = (max) => text2(max).min(1, "must not be empty");
3449
+ var optionalText2 = (max) => text2(max).nullish().transform((value) => value || null);
3450
+ var clearableText = (max) => text2(max).nullish().transform((value) => value === void 0 ? void 0 : value || null);
3451
+ var list = (item, max) => max === void 0 ? z13.array(item) : z13.array(item).max(max);
3434
3452
  var ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES = ["cron", "github", "gitlab"];
3435
3453
  function isEnvironmentSetupAuthoredTriggerType(type) {
3436
3454
  return ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES.some((authored) => authored === type);
3437
3455
  }
3438
- var proposalTriggerSchema = z12.discriminatedUnion("type", [cronTriggerSchema, githubTriggerSchema, gitlabTriggerSchema]);
3439
- var existingTriggerSchema = z12.custom(
3456
+ var proposalTriggerSchema = z13.discriminatedUnion("type", [cronTriggerSchema, githubTriggerSchema, gitlabTriggerSchema]);
3457
+ var existingTriggerSchema = z13.custom(
3440
3458
  (value) => isRecord(value) && typeof value.type === "string" && isRecord(value.config),
3441
3459
  "must be an automation trigger"
3442
3460
  );
@@ -3444,22 +3462,22 @@ var carriedTriggerSchema = existingTriggerSchema.refine(
3444
3462
  (trigger) => !isEnvironmentSetupAuthoredTriggerType(trigger.type)
3445
3463
  );
3446
3464
  function automationSchema(limits) {
3447
- const authored = z12.object({
3448
- name: text(limits.nameChars),
3449
- description: text(limits.descriptionChars),
3450
- prompt: text(limits.automationPromptChars),
3465
+ const authored = z13.object({
3466
+ name: text2(limits.nameChars),
3467
+ description: text2(limits.descriptionChars),
3468
+ prompt: text2(limits.automationPromptChars),
3451
3469
  triggers: list(proposalTriggerSchema, limits.automationTriggers)
3452
3470
  });
3453
- const updated = authored.extend({ triggers: list(z12.union([proposalTriggerSchema, carriedTriggerSchema]), limits.automationTriggers) });
3454
- return z12.object({
3471
+ const updated = authored.extend({ triggers: list(z13.union([proposalTriggerSchema, carriedTriggerSchema]), limits.automationTriggers) });
3472
+ return z13.object({
3455
3473
  key: requiredText(limits.automationKeyChars),
3456
- action: z12.enum(ENVIRONMENT_SETUP_AUTOMATION_ACTIONS).default("create"),
3457
- automation_id: z12.string().regex(UUID_RE, "must be an automation id").nullable().default(null),
3458
- name: text().default(""),
3459
- description: optionalText().transform((value) => value ?? ""),
3460
- prompt: text().default(""),
3474
+ action: z13.enum(ENVIRONMENT_SETUP_AUTOMATION_ACTIONS).default("create"),
3475
+ automation_id: z13.string().regex(UUID_RE, "must be an automation id").nullable().default(null),
3476
+ name: text2().default(""),
3477
+ description: optionalText2().transform((value) => value ?? ""),
3478
+ prompt: text2().default(""),
3461
3479
  triggers: list(existingTriggerSchema).default([]),
3462
- note: optionalText(limits.automationNoteChars)
3480
+ note: optionalText2(limits.automationNoteChars)
3463
3481
  }).superRefine((automation, ctx) => {
3464
3482
  if (automation.action === "create" && automation.automation_id) {
3465
3483
  ctx.addIssue({ code: "custom", path: ["automation_id"], message: "belongs on an update, keep, or disable entry" });
@@ -3477,7 +3495,7 @@ function automationSchema(limits) {
3477
3495
  const content = (automation.action === "update" ? updated : authored).safeParse(automation);
3478
3496
  if (content.success) return { ...automation, ...content.data };
3479
3497
  for (const issue of content.error.issues) ctx.addIssue({ ...issue, code: "custom" });
3480
- return z12.NEVER;
3498
+ return z13.NEVER;
3481
3499
  });
3482
3500
  }
3483
3501
  function automationListSchema(limits) {
@@ -3495,8 +3513,8 @@ function automationListSchema(limits) {
3495
3513
  });
3496
3514
  }
3497
3515
  function environmentSchema(limits) {
3498
- return z12.object({
3499
- name: optionalText(limits.nameChars).transform((value) => value ?? void 0),
3516
+ return z13.object({
3517
+ name: optionalText2(limits.nameChars).transform((value) => value ?? void 0),
3500
3518
  description: clearableText(limits.descriptionChars),
3501
3519
  system_prompt: clearableText(limits.systemPromptChars),
3502
3520
  start_hook: clearableText(limits.hookChars),
@@ -3504,26 +3522,26 @@ function environmentSchema(limits) {
3504
3522
  });
3505
3523
  }
3506
3524
  function variableSchema(limits, requiredDefault) {
3507
- return z12.object({
3508
- key: z12.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name").max(limits.variableKeyChars ?? Number.POSITIVE_INFINITY),
3509
- description: optionalText(limits.variableDescriptionChars).transform((value) => value ?? ""),
3510
- required: z12.boolean().default(requiredDefault)
3525
+ return z13.object({
3526
+ key: z13.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name").max(limits.variableKeyChars ?? Number.POSITIVE_INFINITY),
3527
+ description: optionalText2(limits.variableDescriptionChars).transform((value) => value ?? ""),
3528
+ required: z13.boolean().default(requiredDefault)
3511
3529
  });
3512
3530
  }
3513
3531
  function proposalSchema(limits) {
3514
- return z12.object({
3532
+ return z13.object({
3515
3533
  summary: requiredText(limits.summaryChars),
3516
- stack: list(text(), limits.stackItems).default([]).transform((items) => items.filter(Boolean)),
3534
+ stack: list(text2(), limits.stackItems).default([]).transform((items) => items.filter(Boolean)),
3517
3535
  environment: environmentSchema(limits),
3518
3536
  variables: list(variableSchema(limits, false), limits.variables).default([]),
3519
3537
  automations: automationListSchema(limits),
3520
- verification: list(z12.object({
3538
+ verification: list(z13.object({
3521
3539
  label: requiredText(limits.nameChars),
3522
- status: z12.enum(ENVIRONMENT_SETUP_VERIFICATION_STATUSES),
3523
- detail: optionalText(limits.verificationDetailChars).transform((value) => value ?? void 0)
3540
+ status: z13.enum(ENVIRONMENT_SETUP_VERIFICATION_STATUSES),
3541
+ detail: optionalText2(limits.verificationDetailChars).transform((value) => value ?? void 0)
3524
3542
  }), limits.verificationItems).default([]),
3525
- media: list(z12.object({
3526
- media_id: z12.string().regex(UUID_RE, "must be a media id"),
3543
+ media: list(z13.object({
3544
+ media_id: z13.string().regex(UUID_RE, "must be a media id"),
3527
3545
  title: requiredText(limits.nameChars)
3528
3546
  }), limits.mediaItems).default([])
3529
3547
  });
@@ -3531,35 +3549,35 @@ function proposalSchema(limits) {
3531
3549
  var environmentSetupProposalSchema = proposalSchema({});
3532
3550
  var environmentSetupProposalSubmissionSchema = proposalSchema(ENVIRONMENT_SETUP_LIMITS);
3533
3551
  var environmentSetupVariableRequestSchema = variableSchema({}, false).extend({
3534
- status: z12.enum(["pending", "provided", "skipped"]),
3535
- requested_at: z12.string(),
3536
- resolved_at: z12.string().nullable().default(null)
3552
+ status: z13.enum(["pending", "provided", "skipped"]),
3553
+ requested_at: z13.string(),
3554
+ resolved_at: z13.string().nullable().default(null)
3537
3555
  });
3538
- var environmentSetupRunStateSchema = z12.object({
3539
- status: z12.enum(ENVIRONMENT_SETUP_RUN_STATUSES),
3540
- steps: z12.partialRecord(z12.enum(ENVIRONMENT_SETUP_STEPS.map((step) => step.key)), z12.enum(ENVIRONMENT_SETUP_STEP_STATUSES)).default({}),
3556
+ var environmentSetupRunStateSchema = z13.object({
3557
+ status: z13.enum(ENVIRONMENT_SETUP_RUN_STATUSES),
3558
+ steps: z13.partialRecord(z13.enum(ENVIRONMENT_SETUP_STEPS.map((step) => step.key)), z13.enum(ENVIRONMENT_SETUP_STEP_STATUSES)).default({}),
3541
3559
  proposal: environmentSetupProposalSchema.nullable().default(null),
3542
- applied: z12.object({
3543
- applied_at: z12.string(),
3544
- automation_ids: z12.array(z12.string())
3560
+ applied: z13.object({
3561
+ applied_at: z13.string(),
3562
+ automation_ids: z13.array(z13.string())
3545
3563
  }).nullable().default(null),
3546
- variable_requests: z12.array(environmentSetupVariableRequestSchema).default([])
3564
+ variable_requests: z13.array(environmentSetupVariableRequestSchema).default([])
3547
3565
  });
3548
- var applyEnvironmentSetupRequestSchema = z12.object({
3566
+ var applyEnvironmentSetupRequestSchema = z13.object({
3549
3567
  environment: environmentSchema(ENVIRONMENT_SETUP_LIMITS).extend({ name: requiredText(ENVIRONMENT_SETUP_LIMITS.nameChars) }),
3550
- variables: list(z12.object({ key: z12.string().regex(VARIABLE_KEY_RE), value: z12.string() }), ENVIRONMENT_SETUP_LIMITS.variables).default([]).refine((variables) => new Set(variables.map((variable) => variable.key)).size === variables.length, "must have unique keys").transform((variables) => variables.filter((variable) => variable.value.length > 0)),
3568
+ variables: list(z13.object({ key: z13.string().regex(VARIABLE_KEY_RE), value: z13.string() }), ENVIRONMENT_SETUP_LIMITS.variables).default([]).refine((variables) => new Set(variables.map((variable) => variable.key)).size === variables.length, "must have unique keys").transform((variables) => variables.filter((variable) => variable.value.length > 0)),
3551
3569
  automations: automationListSchema(ENVIRONMENT_SETUP_LIMITS)
3552
3570
  });
3553
- var requestEnvironmentSetupVariablesSchema = z12.object({
3571
+ var requestEnvironmentSetupVariablesSchema = z13.object({
3554
3572
  variables: list(variableSchema(ENVIRONMENT_SETUP_LIMITS, true), ENVIRONMENT_SETUP_LIMITS.variables).min(1, "must not be empty")
3555
3573
  }).superRefine(({ variables }, ctx) => {
3556
3574
  if (new Set(variables.map((variable) => variable.key)).size !== variables.length) {
3557
3575
  ctx.addIssue({ code: "custom", path: ["variables"], message: "must have unique keys" });
3558
3576
  }
3559
3577
  });
3560
- var respondEnvironmentSetupVariablesSchema = z12.object({
3561
- values: z12.record(z12.string().regex(VARIABLE_KEY_RE), z12.string()).default({}),
3562
- skipped: z12.array(z12.string().regex(VARIABLE_KEY_RE)).default([])
3578
+ var respondEnvironmentSetupVariablesSchema = z13.object({
3579
+ values: z13.record(z13.string().regex(VARIABLE_KEY_RE), z13.string()).default({}),
3580
+ skipped: z13.array(z13.string().regex(VARIABLE_KEY_RE)).default([])
3563
3581
  });
3564
3582
 
3565
3583
  // ../shared/src/default-skills/replicas-agent/abilities/environment-setup.ts
@@ -5297,16 +5315,16 @@ var DEFAULT_WORKSPACE_FILTERS = {
5297
5315
  activity: "any"
5298
5316
  };
5299
5317
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
5300
- var workspaceExecRequestSchema = z13.object({
5301
- command: z13.string().regex(/\S/, "command is required"),
5302
- timeout_seconds: z13.number().int().min(1).max(50).optional().describe("Default: 30")
5318
+ var workspaceExecRequestSchema = z14.object({
5319
+ command: z14.string().regex(/\S/, "command is required"),
5320
+ timeout_seconds: z14.number().int().min(1).max(50).optional().describe("Default: 30")
5303
5321
  });
5304
- var terminalRtcCandidateSchema = z13.object({ type: z13.literal("rtc-candidate"), candidate: z13.string(), mid: z13.string() });
5305
- var terminalSocketServerMessageSchema = z13.discriminatedUnion("type", [
5306
- z13.object({ type: z13.literal("output"), data: z13.string() }),
5307
- z13.object({ type: z13.literal("rtc-answer"), sdp: z13.string() }),
5322
+ var terminalRtcCandidateSchema = z14.object({ type: z14.literal("rtc-candidate"), candidate: z14.string(), mid: z14.string() });
5323
+ var terminalSocketServerMessageSchema = z14.discriminatedUnion("type", [
5324
+ z14.object({ type: z14.literal("output"), data: z14.string() }),
5325
+ z14.object({ type: z14.literal("rtc-answer"), sdp: z14.string() }),
5308
5326
  terminalRtcCandidateSchema,
5309
- z13.object({ type: z13.literal("rtc-switch") })
5327
+ z14.object({ type: z14.literal("rtc-switch") })
5310
5328
  ]);
5311
5329
  var TERMINAL_RTC_ICE_SERVER = "stun:stun.l.google.com:19302";
5312
5330
 
@@ -5331,41 +5349,41 @@ var REPLICAS_MCP_TOOLS = {
5331
5349
  archiveSubagent: "archive_subagent",
5332
5350
  waitForSubagents: "wait_for_subagents"
5333
5351
  };
5334
- var automationToolInputSchema = z14.object({
5335
- name: z14.string().describe("Short automation name."),
5336
- prompt: z14.string().describe("Prompt each automation run starts with."),
5337
- environment_id: z14.string().describe(`Environment id from \`${REPLICAS_MCP_TOOLS.listEnvironments}\`.`),
5338
- triggers: z14.array(automationTriggerSchema).min(1).describe(
5352
+ var automationToolInputSchema = z15.object({
5353
+ name: z15.string().describe("Short automation name."),
5354
+ prompt: z15.string().describe("Prompt each automation run starts with."),
5355
+ environment_id: z15.string().describe(`Environment id from \`${REPLICAS_MCP_TOOLS.listEnvironments}\`.`),
5356
+ triggers: z15.array(automationTriggerSchema).min(1).describe(
5339
5357
  '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>"] } }`.'
5340
5358
  ),
5341
- description: z14.string().optional().describe("One-line summary shown in the dashboard."),
5342
- plan_mode: z14.boolean().optional(),
5343
- goal_mode: z14.boolean().optional(),
5344
- fast_mode: z14.boolean().optional()
5359
+ description: z15.string().optional().describe("One-line summary shown in the dashboard."),
5360
+ plan_mode: z15.boolean().optional(),
5361
+ goal_mode: z15.boolean().optional(),
5362
+ fast_mode: z15.boolean().optional()
5345
5363
  });
5346
5364
  var automationCreateToolInputSchema = automationToolInputSchema.extend({
5347
- scope: z14.enum(["org", "user"]).optional().describe("`org` (default) or `user` for a personal automation, which needs a personal API key.")
5365
+ scope: z15.enum(["org", "user"]).optional().describe("`org` (default) or `user` for a personal automation, which needs a personal API key.")
5348
5366
  });
5349
5367
  var automationUpdateToolInputSchema = automationToolInputSchema.partial().extend({
5350
- automation_id: z14.string().describe("Automation ID"),
5351
- enabled: z14.boolean().optional(),
5352
- agent_provider: z14.enum(AGENT).nullable().optional(),
5353
- model: z14.string().nullable().optional(),
5354
- thinking_level: z14.enum(VALID_THINKING_LEVELS).nullable().optional(),
5355
- workspace_lifecycle_policy: z14.enum(VALID_LIFECYCLE_POLICIES).optional(),
5356
- workspace_size: z14.enum(WORKSPACE_SIZES).optional()
5368
+ automation_id: z15.string().describe("Automation ID"),
5369
+ enabled: z15.boolean().optional(),
5370
+ agent_provider: z15.enum(AGENT).nullable().optional(),
5371
+ model: z15.string().nullable().optional(),
5372
+ thinking_level: z15.enum(VALID_THINKING_LEVELS).nullable().optional(),
5373
+ workspace_lifecycle_policy: z15.enum(VALID_LIFECYCLE_POLICIES).optional(),
5374
+ workspace_size: z15.enum(WORKSPACE_SIZES).optional()
5357
5375
  });
5358
- var chatPath = { id: z14.string().describe("Workspace ID"), chat_id: z14.string().describe("Chat ID") };
5376
+ var chatPath = { id: z15.string().describe("Workspace ID"), chat_id: z15.string().describe("Chat ID") };
5359
5377
  var { provider, model, thinkingLevel, title, message } = forkChatRequestSchema.shape;
5360
- var createChatToolInputSchema = z14.object({ id: chatPath.id, provider, title: createChatRequestSchema.shape.title });
5361
- var forkChatToolInputSchema = z14.object({ ...chatPath, provider, model, thinking_level: thinkingLevel, title, message });
5362
- var renameChatToolInputSchema = z14.object({ ...chatPath, display_name: updateChatDisplayNameRequestSchema.shape.displayName });
5363
- var runCommandToolInputSchema = z14.object({ id: chatPath.id, ...workspaceExecRequestSchema.shape });
5364
- var environmentMcpPath = { environment_id: z14.string().describe("Environment ID") };
5365
- var createEnvironmentMcpToolInputSchema = z14.object({ ...environmentMcpPath, ...createEnvironmentMcpRequestSchema.shape });
5366
- var updateEnvironmentMcpToolInputSchema = z14.object({
5378
+ var createChatToolInputSchema = z15.object({ id: chatPath.id, provider, title: createChatRequestSchema.shape.title });
5379
+ var forkChatToolInputSchema = z15.object({ ...chatPath, provider, model, thinking_level: thinkingLevel, title, message });
5380
+ var renameChatToolInputSchema = z15.object({ ...chatPath, display_name: updateChatDisplayNameRequestSchema.shape.displayName });
5381
+ var runCommandToolInputSchema = z15.object({ id: chatPath.id, ...workspaceExecRequestSchema.shape });
5382
+ var environmentMcpPath = { environment_id: z15.string().describe("Environment ID") };
5383
+ var createEnvironmentMcpToolInputSchema = z15.object({ ...environmentMcpPath, ...createEnvironmentMcpRequestSchema.shape });
5384
+ var updateEnvironmentMcpToolInputSchema = z15.object({
5367
5385
  ...environmentMcpPath,
5368
- mcp_id: z14.string().describe("MCP ID"),
5386
+ mcp_id: z15.string().describe("MCP ID"),
5369
5387
  ...updateEnvironmentMcpRequestSchema.shape
5370
5388
  });
5371
5389
 
@@ -5431,12 +5449,12 @@ function wrapInTag(content, tag) {
5431
5449
  ${content}
5432
5450
  </${tag}>`;
5433
5451
  }
5434
- function removeTag(text2, tag) {
5452
+ function removeTag(text3, tag) {
5435
5453
  const regex = new RegExp(`<${tag}>[\\s\\S]*?</${tag}>`, "g");
5436
- return text2.replace(regex, "").trim();
5454
+ return text3.replace(regex, "").trim();
5437
5455
  }
5438
- function removeReplicasInstructions(text2) {
5439
- return removeTag(text2, REPLICAS_INSTRUCTIONS_TAG);
5456
+ function removeReplicasInstructions(text3) {
5457
+ return removeTag(text3, REPLICAS_INSTRUCTIONS_TAG);
5440
5458
  }
5441
5459
  var MULTITASK_INSTRUCTIONS_BLOCK = new RegExp(`\\s*<${MULTITASK_INSTRUCTIONS_TAG}>\\n([\\s\\S]*?)\\n</${MULTITASK_INSTRUCTIONS_TAG}>`);
5442
5460
  function splitMultitaskInstructions(customInstructions) {
@@ -5450,23 +5468,23 @@ function splitMultitaskInstructions(customInstructions) {
5450
5468
  // ../shared/src/multitask-events.ts
5451
5469
  var MULTITASK_EVENT_KINDS = ["finished", "ready", "needs_attention", "merged", "closed", "archived"];
5452
5470
  var MULTITASK_EVENT_TYPE = "multitask-event";
5453
- var multitaskEventSchema = z15.object({
5454
- id: z15.string(),
5455
- at: z15.string(),
5456
- kind: z15.enum(MULTITASK_EVENT_KINDS),
5457
- agentId: z15.string(),
5458
- agentName: z15.string(),
5459
- summary: z15.string(),
5460
- detail: z15.string().optional(),
5471
+ var multitaskEventSchema = z16.object({
5472
+ id: z16.string(),
5473
+ at: z16.string(),
5474
+ kind: z16.enum(MULTITASK_EVENT_KINDS),
5475
+ agentId: z16.string(),
5476
+ agentName: z16.string(),
5477
+ summary: z16.string(),
5478
+ detail: z16.string().optional(),
5461
5479
  // Already shown as a row when it happened, so the delivered message does not show it again.
5462
- noticed: z15.boolean().optional()
5480
+ noticed: z16.boolean().optional()
5463
5481
  });
5464
5482
  var TAG = "multitask_event";
5465
5483
  var BLOCK = new RegExp(`<${TAG}((?:\\s+\\w+="[^"]*")*)>\\n?([\\s\\S]*?)\\n?</${TAG}>`, "g");
5466
5484
  var ATTRIBUTE = /(\w+)="([^"]*)"/g;
5467
5485
  var unescapeAttribute = (value) => value.replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
5468
- function extractMultitaskEvents(text2) {
5469
- return [...text2.matchAll(BLOCK)].flatMap((match) => {
5486
+ function extractMultitaskEvents(text3) {
5487
+ return [...text3.matchAll(BLOCK)].flatMap((match) => {
5470
5488
  const attributes = Object.fromEntries([...match[1].matchAll(ATTRIBUTE)].map(([, key, value]) => [key, unescapeAttribute(value)]));
5471
5489
  const kind = MULTITASK_EVENT_KINDS.find((candidate) => candidate === attributes.kind);
5472
5490
  if (!kind || !attributes.id || !attributes.agent_id) return [];
@@ -5484,13 +5502,13 @@ function extractMultitaskEvents(text2) {
5484
5502
  }];
5485
5503
  });
5486
5504
  }
5487
- function parseMultitaskEvents(text2) {
5488
- const events = extractMultitaskEvents(text2);
5489
- return events.length > 0 && text2.replace(BLOCK, "").replaceAll(MERGED_MESSAGE_SEPARATOR.trim(), "").trim() === "" ? events : null;
5505
+ function parseMultitaskEvents(text3) {
5506
+ const events = extractMultitaskEvents(text3);
5507
+ return events.length > 0 && text3.replace(BLOCK, "").replaceAll(MERGED_MESSAGE_SEPARATOR.trim(), "").trim() === "" ? events : null;
5490
5508
  }
5491
5509
 
5492
5510
  // ../shared/src/learned-skills.ts
5493
- import { z as z16 } from "zod";
5511
+ import { z as z17 } from "zod";
5494
5512
 
5495
5513
  // ../shared/src/frontmatter.ts
5496
5514
  import { parse as parseYaml } from "yaml";
@@ -5513,20 +5531,20 @@ function parseFrontmatter(content) {
5513
5531
  var LEARNED_SKILLS_ROOT = `${SANDBOX_PATHS.REPLICAS_DIR}/learned-skills`;
5514
5532
  var LEARNED_SKILLS_MANIFEST_PATH = `${LEARNED_SKILLS_ROOT}/manifest.json`;
5515
5533
  var LEARNED_SKILL_DIR_PREFIX = "replicas-learned__";
5516
- var learnedSkillsManifestSchema = z16.object({
5517
- skills: z16.array(z16.object({ name: z16.string(), sha256: z16.string() }))
5534
+ var learnedSkillsManifestSchema = z17.object({
5535
+ skills: z17.array(z17.object({ name: z17.string(), sha256: z17.string() }))
5518
5536
  });
5519
- var dreamVerdictChecksSchema = z16.object({
5520
- repeatable: z16.boolean(),
5521
- realInstruction: z16.boolean(),
5522
- noContradiction: z16.boolean(),
5523
- formatExact: z16.boolean(),
5524
- humanOnly: z16.boolean(),
5525
- actionable: z16.boolean(),
5526
- durable: z16.boolean()
5537
+ var dreamVerdictChecksSchema = z17.object({
5538
+ repeatable: z17.boolean(),
5539
+ realInstruction: z17.boolean(),
5540
+ noContradiction: z17.boolean(),
5541
+ formatExact: z17.boolean(),
5542
+ humanOnly: z17.boolean(),
5543
+ actionable: z17.boolean(),
5544
+ durable: z17.boolean()
5527
5545
  });
5528
5546
  var DREAM_VERDICT_CHECKS = dreamVerdictChecksSchema.keyof().options;
5529
- var dreamVerdictSchema = dreamVerdictChecksSchema.extend({ approve: z16.boolean(), reason: z16.string() });
5547
+ var dreamVerdictSchema = dreamVerdictChecksSchema.extend({ approve: z17.boolean(), reason: z17.string() });
5530
5548
  var learnedSkillFormatInstruction = (speaker) => `Write a SKILL.md whose frontmatter has a kebab-case \`name\` and a short \`description\` that starts with "Use when" and names the situations it applies to; the body records only what ${speaker} actually said, restated as a direct instruction, usually one to three lines. Every line of a learning is loaded into future sessions, so leave out anything an agent could infer on its own: no headings, explanations, rules, or examples unless ${speaker} stated those specifics themselves. For "from now on, use Conventional Commits", the body is just "Use Conventional Commits for every commit message and PR title."`;
5531
5549
 
5532
5550
  // ../shared/src/user-message-matching.ts
@@ -5774,9 +5792,9 @@ function describeToolCall(message2, base) {
5774
5792
  var ATTACHMENT_PLACEHOLDER_REGEX = /^\[\d+ (?:(?:images?|files?)(?: and \d+ files?)? attached|(?:image )?attachments?)\]$/;
5775
5793
  var WALKTHROUGH_NOTE_REGEX = /(?:^|\n\n)<replicas_walkthrough path="([^"\n]+)" duration_seconds="(\d+)" audio="(true|false)">\n[^<]*\n<\/replicas_walkthrough>$/;
5776
5794
  var TRUNCATED_WALKTHROUGH_NOTE_REGEX = /(?:^|\n\n)<replicas_walkthrough path="([^"\n]*)(?:" duration_seconds="(\d*))?(?:" audio="(true)?)?[^<]*(?:<\/?[a-z_]*)?$/;
5777
- function stripAttachmentNote(text2) {
5778
- const match = text2.match(/(?:^|\n\n)<replicas_attachments>\nUploaded files are available at:((?:\n- .*)*)(?:\n<\/?[a-z_]*>?)?$/) ?? text2.match(/(?:^|\n\n)Uploaded files are available at:((?:\n- .*)*)$/);
5779
- let content = match ? text2.replace(match[0], "").trim() : text2;
5795
+ function stripAttachmentNote(text3) {
5796
+ const match = text3.match(/(?:^|\n\n)<replicas_attachments>\nUploaded files are available at:((?:\n- .*)*)(?:\n<\/?[a-z_]*>?)?$/) ?? text3.match(/(?:^|\n\n)Uploaded files are available at:((?:\n- .*)*)$/);
5797
+ let content = match ? text3.replace(match[0], "").trim() : text3;
5780
5798
  const walkthroughs = [];
5781
5799
  const truncated = WALKTHROUGH_NOTE_REGEX.test(content) ? null : content.match(TRUNCATED_WALKTHROUGH_NOTE_REGEX);
5782
5800
  if (truncated) {
@@ -5835,7 +5853,7 @@ function messagesForCodexTurn(turn) {
5835
5853
  return [{
5836
5854
  type: "reasoning",
5837
5855
  id: turn.id,
5838
- text: reasoning.map(({ text: text2 }) => text2.trim()).join("\n\n"),
5856
+ text: reasoning.map(({ text: text3 }) => text3.trim()).join("\n\n"),
5839
5857
  timestamp: reasoning[0].timestamp,
5840
5858
  status: reasoning.at(-1)?.status ?? "completed"
5841
5859
  }];
@@ -6312,8 +6330,8 @@ function getCursorAssistantText(event) {
6312
6330
  return getTextContent(message2?.content);
6313
6331
  }
6314
6332
  function getCursorThinkingText(event) {
6315
- const text2 = event.payload.text;
6316
- if (typeof text2 === "string") return text2;
6333
+ const text3 = event.payload.text;
6334
+ if (typeof text3 === "string") return text3;
6317
6335
  const message2 = isRecord(event.payload.message) ? event.payload.message : null;
6318
6336
  return typeof message2?.text === "string" ? message2.text : "";
6319
6337
  }
@@ -6364,8 +6382,8 @@ function parseCursorEvents(events) {
6364
6382
  continue;
6365
6383
  }
6366
6384
  if (event.type === "cursor-assistant") {
6367
- const text2 = getCursorAssistantText(event);
6368
- if (text2) {
6385
+ const text3 = getCursorAssistantText(event);
6386
+ if (text3) {
6369
6387
  const runId = cursorRunId(event);
6370
6388
  if (!activeAssistant || activeAssistant.runId !== runId) {
6371
6389
  const segment = runAssistantSegments.get(runId) ?? 0;
@@ -6384,15 +6402,15 @@ function parseCursorEvents(events) {
6384
6402
  if (message2?.type === "agent") {
6385
6403
  messages[activeAssistant.index] = {
6386
6404
  ...message2,
6387
- content: `${message2.content}${text2}`
6405
+ content: `${message2.content}${text3}`
6388
6406
  };
6389
6407
  }
6390
6408
  }
6391
6409
  continue;
6392
6410
  }
6393
6411
  if (event.type === "cursor-thinking") {
6394
- const text2 = getCursorThinkingText(event);
6395
- if (text2.trim()) {
6412
+ const text3 = getCursorThinkingText(event);
6413
+ if (text3.trim()) {
6396
6414
  const runId = cursorRunId(event);
6397
6415
  if (!activeThinking || activeThinking.runId !== runId) {
6398
6416
  const segment = runThinkingSegments.get(runId) ?? 0;
@@ -6412,7 +6430,7 @@ function parseCursorEvents(events) {
6412
6430
  if (message2?.type === "reasoning") {
6413
6431
  messages[activeThinking.index] = {
6414
6432
  ...message2,
6415
- content: `${message2.content}${text2}`,
6433
+ content: `${message2.content}${text3}`,
6416
6434
  status: "in_progress"
6417
6435
  };
6418
6436
  }
@@ -6444,12 +6462,12 @@ function parseCursorEvents(events) {
6444
6462
  }
6445
6463
  if (event.type === "cursor-task") {
6446
6464
  activeAssistant = null;
6447
- const text2 = event.payload.text;
6448
- if (typeof text2 === "string" && text2.trim()) {
6465
+ const text3 = event.payload.text;
6466
+ if (typeof text3 === "string" && text3.trim()) {
6449
6467
  messages.push({
6450
6468
  id: `cursor-task-${event.timestamp}-${messages.length}`,
6451
6469
  type: "agent",
6452
- content: text2,
6470
+ content: text3,
6453
6471
  timestamp: event.timestamp
6454
6472
  });
6455
6473
  }
@@ -6535,8 +6553,8 @@ function extractErrorText(error) {
6535
6553
  collect(error);
6536
6554
  return parts.filter(Boolean).join("\n");
6537
6555
  }
6538
- function isTransientErrorText(text2, options = {}) {
6539
- const normalized = text2.toLowerCase();
6556
+ function isTransientErrorText(text3, options = {}) {
6557
+ const normalized = text3.toLowerCase();
6540
6558
  if (!normalized) return false;
6541
6559
  if (TRANSIENT_NETWORK_ERROR_PATTERNS.some((pattern) => pattern.test(normalized))) return true;
6542
6560
  if (options.includeRateLimit && /rate limit/.test(normalized)) return true;
@@ -6659,24 +6677,24 @@ function parseOpencodeEvents(events) {
6659
6677
  const time = isRecord(part.time) ? part.time : null;
6660
6678
  const timestamp = timestampFromMs(time?.start, event.timestamp);
6661
6679
  if (part.type === "text") {
6662
- const text2 = typeof part.text === "string" ? part.text : "";
6663
- if (text2.trim()) {
6680
+ const text3 = typeof part.text === "string" ? part.text : "";
6681
+ if (text3.trim()) {
6664
6682
  upsertDisplayMessage(messages, {
6665
6683
  id,
6666
6684
  type: "agent",
6667
- content: text2,
6685
+ content: text3,
6668
6686
  timestamp
6669
6687
  });
6670
6688
  }
6671
6689
  continue;
6672
6690
  }
6673
6691
  if (part.type === "reasoning") {
6674
- const text2 = typeof part.text === "string" ? part.text : "";
6675
- if (text2.trim()) {
6692
+ const text3 = typeof part.text === "string" ? part.text : "";
6693
+ if (text3.trim()) {
6676
6694
  upsertDisplayMessage(messages, {
6677
6695
  id,
6678
6696
  type: "reasoning",
6679
- content: text2,
6697
+ content: text3,
6680
6698
  status: time?.end ? "completed" : "in_progress",
6681
6699
  timestamp
6682
6700
  });
@@ -6844,7 +6862,7 @@ function assistantErrorMessage(value) {
6844
6862
  }
6845
6863
  function parsePiEvents(events) {
6846
6864
  const messages = [];
6847
- const text2 = /* @__PURE__ */ new Map();
6865
+ const text3 = /* @__PURE__ */ new Map();
6848
6866
  const thinking = /* @__PURE__ */ new Map();
6849
6867
  let activeMessageId = "assistant";
6850
6868
  for (const event of events) {
@@ -6875,9 +6893,9 @@ function parsePiEvents(events) {
6875
6893
  if (event.type === "pi-message_update") {
6876
6894
  const payload = nestedPayload(event);
6877
6895
  const id = typeof payload.id === "string" ? payload.id : activeMessageId;
6878
- if (payload.type === "text_delta" && typeof payload.delta === "string") text2.set(id, `${text2.get(id) ?? ""}${payload.delta}`);
6896
+ if (payload.type === "text_delta" && typeof payload.delta === "string") text3.set(id, `${text3.get(id) ?? ""}${payload.delta}`);
6879
6897
  if (payload.type === "thinking_delta" && typeof payload.delta === "string") thinking.set(id, `${thinking.get(id) ?? ""}${payload.delta}`);
6880
- const textContent = text2.get(id);
6898
+ const textContent = text3.get(id);
6881
6899
  const thinkingContent = thinking.get(id);
6882
6900
  if (textContent !== void 0) upsertDisplayMessage(messages, { id: `pi-${id}`, type: "agent", content: textContent, timestamp: event.timestamp });
6883
6901
  if (thinkingContent !== void 0) upsertDisplayMessage(messages, { id: `pi-thinking-${id}`, type: "reasoning", content: thinkingContent, status: "in_progress", timestamp: event.timestamp });
@@ -7896,7 +7914,7 @@ var SECRET_PATTERNS = [
7896
7914
  /\b[A-Z][A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD)\s*=\s*[^\s]{12,}/g
7897
7915
  ];
7898
7916
  function redactSecrets(value) {
7899
- return SECRET_PATTERNS.reduce((text2, pattern) => text2.replace(pattern, "[REDACTED]"), value);
7917
+ return SECRET_PATTERNS.reduce((text3, pattern) => text3.replace(pattern, "[REDACTED]"), value);
7900
7918
  }
7901
7919
 
7902
7920
  // ../shared/src/transcript-canonicalize.ts
@@ -8441,24 +8459,24 @@ function clampWarmHookTimeoutMs(timeoutMs) {
8441
8459
  }
8442
8460
  return Math.min(timeoutMs, MAX_WARM_HOOK_TIMEOUT_MS);
8443
8461
  }
8444
- function buildOutputPreview(text2, {
8462
+ function buildOutputPreview(text3, {
8445
8463
  maxChars = DEFAULT_HOOK_OUTPUT_PREVIEW_CHARS,
8446
8464
  truncateFrom = "head",
8447
8465
  marker = "\n...[truncated \u2014 download the full log to see the rest]"
8448
8466
  } = {}) {
8449
- if (text2.length <= maxChars) {
8450
- return { output: text2, outputTruncated: false, outputTotalChars: text2.length };
8467
+ if (text3.length <= maxChars) {
8468
+ return { output: text3, outputTruncated: false, outputTotalChars: text3.length };
8451
8469
  }
8452
8470
  const previewChars = Math.max(0, maxChars - marker.length);
8453
- const output = previewChars === 0 ? marker.slice(0, maxChars) : truncateFrom === "tail" ? `${marker}${text2.slice(-previewChars)}` : `${text2.slice(0, previewChars)}${marker}`;
8471
+ const output = previewChars === 0 ? marker.slice(0, maxChars) : truncateFrom === "tail" ? `${marker}${text3.slice(-previewChars)}` : `${text3.slice(0, previewChars)}${marker}`;
8454
8472
  return {
8455
8473
  output,
8456
8474
  outputTruncated: true,
8457
- outputTotalChars: text2.length
8475
+ outputTotalChars: text3.length
8458
8476
  };
8459
8477
  }
8460
- function buildHookOutputPreview(text2, maxChars = DEFAULT_HOOK_OUTPUT_PREVIEW_CHARS) {
8461
- return buildOutputPreview(text2, { maxChars });
8478
+ function buildHookOutputPreview(text3, maxChars = DEFAULT_HOOK_OUTPUT_PREVIEW_CHARS) {
8479
+ return buildOutputPreview(text3, { maxChars });
8462
8480
  }
8463
8481
  function parseWarmHookConfig(value, filename = "replicas.json") {
8464
8482
  if (typeof value === "string") {
@@ -8549,14 +8567,14 @@ var AUTHENTICATION_ERROR_PATTERNS = [
8549
8567
  /authentication error/,
8550
8568
  /invalid api key/
8551
8569
  ];
8552
- function isAuthenticationErrorText(text2, extraPatterns = []) {
8553
- const normalized = text2.toLowerCase();
8570
+ function isAuthenticationErrorText(text3, extraPatterns = []) {
8571
+ const normalized = text3.toLowerCase();
8554
8572
  return AUTHENTICATION_ERROR_PATTERNS.some((pattern) => pattern.test(normalized)) || extraPatterns.some((pattern) => pattern.test(normalized));
8555
8573
  }
8556
8574
 
8557
8575
  // ../shared/src/claude-auth.ts
8558
- function isClaudeAuthErrorText(text2) {
8559
- const lower = text2.toLowerCase();
8576
+ function isClaudeAuthErrorText(text3) {
8577
+ const lower = text3.toLowerCase();
8560
8578
  return lower.includes("failed to authenticate") || lower.includes("authentication_error") || lower.includes("authentication_failed") || lower.includes("authentication failed") || lower.includes("invalid authentication credentials") || lower.includes("not logged in") || lower.includes("please run /login") || lower.includes("401") && lower.includes("authentic");
8561
8579
  }
8562
8580
 
@@ -8749,7 +8767,7 @@ var CLAUDE_AUTH_ENV_KEYS_BY_METHOD = {
8749
8767
  };
8750
8768
 
8751
8769
  // ../shared/src/routes/command-protection.ts
8752
- import { z as z17 } from "zod";
8770
+ import { z as z18 } from "zod";
8753
8771
 
8754
8772
  // ../shared/src/git-invocations.ts
8755
8773
  var COMMIT_VALUE_OPTIONS = /* @__PURE__ */ new Set(["message", "file", "trailer", "reuse-message", "reedit-message", "fixup", "squash", "template", "author", "date", "cleanup", "pathspec-from-file"]);
@@ -8840,27 +8858,27 @@ function findCheckoutTarget(args) {
8840
8858
  }
8841
8859
 
8842
8860
  // ../shared/src/routes/command-protection.ts
8843
- var commandProtectionRepoStateSchema = z17.object({
8844
- branch: z17.string().nullable(),
8845
- defaultBranch: z17.string().nullable(),
8846
- pushBranch: z17.string().nullable(),
8847
- pushConfig: z17.string().nullable(),
8848
- headMessage: z17.string().nullable(),
8849
- mergeInProgress: z17.boolean().optional()
8861
+ var commandProtectionRepoStateSchema = z18.object({
8862
+ branch: z18.string().nullable(),
8863
+ defaultBranch: z18.string().nullable(),
8864
+ pushBranch: z18.string().nullable(),
8865
+ pushConfig: z18.string().nullable(),
8866
+ headMessage: z18.string().nullable(),
8867
+ mergeInProgress: z18.boolean().optional()
8850
8868
  });
8851
- var commandProtectionEvaluateRequestSchema = z17.object({
8852
- provider: z17.enum(["claude", "codex", "cursor", "opencode", "pi"]),
8853
- source: z17.enum(["claude_pre_tool_use", "codex_approval_request", "cursor_pre_tool_use", "opencode_pre_tool_use", "pi_tool_call"]),
8854
- toolName: z17.string(),
8855
- toolInput: z17.unknown(),
8856
- command: z17.string().nullish(),
8857
- cwd: z17.string().nullish(),
8858
- toolUseId: z17.string().nullish(),
8869
+ var commandProtectionEvaluateRequestSchema = z18.object({
8870
+ provider: z18.enum(["claude", "codex", "cursor", "opencode", "pi"]),
8871
+ source: z18.enum(["claude_pre_tool_use", "codex_approval_request", "cursor_pre_tool_use", "opencode_pre_tool_use", "pi_tool_call"]),
8872
+ toolName: z18.string(),
8873
+ toolInput: z18.unknown(),
8874
+ command: z18.string().nullish(),
8875
+ cwd: z18.string().nullish(),
8876
+ toolUseId: z18.string().nullish(),
8859
8877
  // Read by the engine before the command runs, keyed by absolute path, so the
8860
8878
  // policy can see branches and commit messages the command text only references.
8861
- gitContext: z17.object({
8862
- repos: z17.record(z17.string(), commandProtectionRepoStateSchema),
8863
- messageFiles: z17.record(z17.string(), z17.string())
8879
+ gitContext: z18.object({
8880
+ repos: z18.record(z18.string(), commandProtectionRepoStateSchema),
8881
+ messageFiles: z18.record(z18.string(), z18.string())
8864
8882
  }).optional()
8865
8883
  });
8866
8884
  var COMMAND_PROTECTION_COMMAND_KEYS = ["command", "cmd", "script", "query", "endpoint", "path", "url", "mutation"];
@@ -8873,8 +8891,8 @@ function stringifyCommandProtectionInput(value) {
8873
8891
  return String(value);
8874
8892
  }
8875
8893
  }
8876
- function normalizeCommandProtectionText(text2) {
8877
- return text2.replace(/\\\n/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
8894
+ function normalizeCommandProtectionText(text3) {
8895
+ return text3.replace(/\\\n/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
8878
8896
  }
8879
8897
  function extractCommandProtectionCommandText(request, options = {}) {
8880
8898
  if (request.command && request.command.trim()) return request.command;
@@ -8998,7 +9016,7 @@ function isPrMergeCommand(argv) {
8998
9016
  const method = /(?:^|\s)(?:-X\s*|--method[\s=])(\w+)/i.exec(args.join(" "))?.[1];
8999
9017
  return words[0] === "api" && method?.toUpperCase() === "PUT" && words.some((word) => /\/(?:pulls|merge_requests)\/[^/]+\/merge$/.test(word));
9000
9018
  }
9001
- var matchingChecks = (checks, text2) => checks.flatMap(([name, pattern]) => pattern.test(text2) ? [name] : []);
9019
+ var matchingChecks = (checks, text3) => checks.flatMap(([name, pattern]) => pattern.test(text3) ? [name] : []);
9002
9020
  function executedText(commands, keepWord = () => true) {
9003
9021
  return commands.filter(({ argv, wrapper, truncated }) => (!wrapper || truncated) && argv[0].split("/").pop() !== "git").map(({ argv, stdin }) => normalizeCommandProtectionText([...argv.filter(keepWord), stdin ?? ""].join(" ").replaceAll(SHELL_OPAQUE, " "))).join("\n");
9004
9022
  }
@@ -9057,102 +9075,102 @@ function shouldRefreshPullRequests(toolName, toolInput) {
9057
9075
  }
9058
9076
 
9059
9077
  // ../shared/src/routes/linear.ts
9060
- import { z as z18 } from "zod";
9061
- var linearSessionMetadataSchema = z18.object({
9062
- via_mothership: z18.boolean().optional(),
9063
- issue_id: z18.string(),
9064
- issue_identifier: z18.string(),
9065
- issue_title: z18.string(),
9066
- issue_description: z18.string(),
9067
- issue_url: z18.string(),
9068
- comment_id: z18.string(),
9069
- comment_body: z18.string(),
9070
- triggered_by_id: z18.string().optional(),
9071
- triggered_by_name: z18.string().optional(),
9072
- triggered_by_email: z18.string().optional(),
9073
- linear_workspace_id: z18.string().optional(),
9074
- creator_id: z18.string().optional(),
9075
- creator_name: z18.string().optional(),
9076
- creator_email: z18.string().optional(),
9077
- assignee_id: z18.string().optional(),
9078
- assignee_name: z18.string().optional(),
9079
- assignee_email: z18.string().optional(),
9080
- issue_state: z18.string().optional(),
9081
- parent_issue: z18.object({
9082
- id: z18.string(),
9083
- identifier: z18.string(),
9084
- title: z18.string(),
9085
- description: z18.string().nullable()
9078
+ import { z as z19 } from "zod";
9079
+ var linearSessionMetadataSchema = z19.object({
9080
+ via_mothership: z19.boolean().optional(),
9081
+ issue_id: z19.string(),
9082
+ issue_identifier: z19.string(),
9083
+ issue_title: z19.string(),
9084
+ issue_description: z19.string(),
9085
+ issue_url: z19.string(),
9086
+ comment_id: z19.string(),
9087
+ comment_body: z19.string(),
9088
+ triggered_by_id: z19.string().optional(),
9089
+ triggered_by_name: z19.string().optional(),
9090
+ triggered_by_email: z19.string().optional(),
9091
+ linear_workspace_id: z19.string().optional(),
9092
+ creator_id: z19.string().optional(),
9093
+ creator_name: z19.string().optional(),
9094
+ creator_email: z19.string().optional(),
9095
+ assignee_id: z19.string().optional(),
9096
+ assignee_name: z19.string().optional(),
9097
+ assignee_email: z19.string().optional(),
9098
+ issue_state: z19.string().optional(),
9099
+ parent_issue: z19.object({
9100
+ id: z19.string(),
9101
+ identifier: z19.string(),
9102
+ title: z19.string(),
9103
+ description: z19.string().nullable()
9086
9104
  }).optional(),
9087
- workspace: z18.object({
9088
- id: z18.string(),
9089
- coding_agent: z18.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
9090
- task_description: z18.string(),
9091
- created_at: z18.string()
9105
+ workspace: z19.object({
9106
+ id: z19.string(),
9107
+ coding_agent: z19.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
9108
+ task_description: z19.string(),
9109
+ created_at: z19.string()
9092
9110
  }).optional()
9093
9111
  });
9094
9112
 
9095
9113
  // ../shared/src/routes/mothership.ts
9096
- import { z as z19 } from "zod";
9114
+ import { z as z20 } from "zod";
9097
9115
  var MOTHERSHIP_LINEAR_ACTIONS = ["ask", "start"];
9098
- var mothershipLinearSessionIntentRequestSchema = z19.object({
9099
- comment_id: z19.string().trim().min(1).describe("Id of the Linear comment the session will be created on."),
9100
- action: z19.enum(MOTHERSHIP_LINEAR_ACTIONS).describe("`ask` when the comment is a clarifying question, `start` when it is the complete task prompt.")
9116
+ var mothershipLinearSessionIntentRequestSchema = z20.object({
9117
+ comment_id: z20.string().trim().min(1).describe("Id of the Linear comment the session will be created on."),
9118
+ action: z20.enum(MOTHERSHIP_LINEAR_ACTIONS).describe("`ask` when the comment is a clarifying question, `start` when it is the complete task prompt.")
9101
9119
  });
9102
- var mothershipLinearStartRequestSchema = z19.object({
9103
- issue_id: z19.string().describe("Linear issue id from the envelope's `issue_id`."),
9104
- agent_session_id: z19.string().describe("Existing Linear agent session id from the envelope's `agent_session_id`."),
9105
- prompt: z19.string().trim().min(1).describe("Complete task prompt for the coding workspace.")
9120
+ var mothershipLinearStartRequestSchema = z20.object({
9121
+ issue_id: z20.string().describe("Linear issue id from the envelope's `issue_id`."),
9122
+ agent_session_id: z20.string().describe("Existing Linear agent session id from the envelope's `agent_session_id`."),
9123
+ prompt: z20.string().trim().min(1).describe("Complete task prompt for the coding workspace.")
9106
9124
  });
9107
- var slackChannelIdSchema = z19.string().describe("Slack channel id from the envelope's `channel_id`.");
9108
- var slackThreadTsSchema = z19.string().describe("Slack thread timestamp from the envelope's `thread_ts`.");
9109
- var mothershipSlackSpawnRequestSchema = z19.object({
9125
+ var slackChannelIdSchema = z20.string().describe("Slack channel id from the envelope's `channel_id`.");
9126
+ var slackThreadTsSchema = z20.string().describe("Slack thread timestamp from the envelope's `thread_ts`.");
9127
+ var mothershipSlackSpawnRequestSchema = z20.object({
9110
9128
  channel_id: slackChannelIdSchema,
9111
9129
  thread_ts: slackThreadTsSchema,
9112
- message_ts: z19.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."),
9113
- user_id: z19.string().describe("Slack user id of that message's author (the envelope's `user_id`). The workspace is attributed to them."),
9114
- prompt: z19.string().describe("Complete task for the new workspace, written so it stands on its own."),
9115
- environment_id: z19.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.`)
9130
+ message_ts: z20.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."),
9131
+ user_id: z20.string().describe("Slack user id of that message's author (the envelope's `user_id`). The workspace is attributed to them."),
9132
+ prompt: z20.string().describe("Complete task for the new workspace, written so it stands on its own."),
9133
+ environment_id: z20.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.`)
9116
9134
  });
9117
- var mothershipSlackRelayRequestSchema = z19.object({
9135
+ var mothershipSlackRelayRequestSchema = z20.object({
9118
9136
  channel_id: slackChannelIdSchema,
9119
9137
  thread_ts: slackThreadTsSchema,
9120
- message: z19.string().describe("The follow-up to deliver, combining every fresh message that belongs to this update."),
9121
- user_id: z19.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. Required with `workspace_id`."),
9122
- queue: z19.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."),
9123
- workspace_id: z19.string().optional().describe(`Existing workspace id, from \`${REPLICAS_MCP_TOOLS.listWorkspaces}\` or a workspace link in the thread, to bind a thread without a workspace to before relaying. The author must be able to see it. Omit to relay into the thread's own workspace.`),
9124
- message_ts: z19.string().optional().describe("Timestamp of the Slack message that led to this relay (the envelope's `message_ts`). Required with `workspace_id`; the server verifies this message and its author.")
9138
+ message: z20.string().describe("The follow-up to deliver, combining every fresh message that belongs to this update."),
9139
+ user_id: z20.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. Required with `workspace_id`."),
9140
+ queue: z20.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."),
9141
+ workspace_id: z20.string().optional().describe(`Existing workspace id, from \`${REPLICAS_MCP_TOOLS.listWorkspaces}\` or a workspace link in the thread, to bind a thread without a workspace to before relaying. The author must be able to see it. Omit to relay into the thread's own workspace.`),
9142
+ message_ts: z20.string().optional().describe("Timestamp of the Slack message that led to this relay (the envelope's `message_ts`). Required with `workspace_id`; the server verifies this message and its author.")
9125
9143
  });
9126
- var mothershipListWorkspacesRequestSchema = z19.object({
9144
+ var mothershipListWorkspacesRequestSchema = z20.object({
9127
9145
  channel_id: slackChannelIdSchema,
9128
9146
  thread_ts: slackThreadTsSchema,
9129
- message_ts: z19.string().describe("The envelope's `message_ts`. The server verifies this message and its author."),
9130
- user_id: z19.string().describe("Slack user id of that message's author (the envelope's `user_id`). Only workspaces they can see are listed."),
9131
- query: z19.string().trim().min(1).optional().describe("Case-insensitive text to match against workspace names and pull request URLs.")
9147
+ message_ts: z20.string().describe("The envelope's `message_ts`. The server verifies this message and its author."),
9148
+ user_id: z20.string().describe("Slack user id of that message's author (the envelope's `user_id`). Only workspaces they can see are listed."),
9149
+ query: z20.string().trim().min(1).optional().describe("Case-insensitive text to match against workspace names and pull request URLs.")
9132
9150
  });
9133
- var mothershipSlackConfirmationSchema = z19.object({
9134
- confirmation_channel_id: z19.string().describe("`channel_id` from the envelope of the Slack message that asked for or accepted this."),
9135
- confirmation_thread_ts: z19.string().describe("`thread_ts` from that message's envelope."),
9136
- confirmation_message_ts: z19.string().describe("`message_ts` from that message's envelope."),
9137
- confirmation_user_id: z19.string().describe("`user_id` from that message's envelope.")
9151
+ var mothershipSlackConfirmationSchema = z20.object({
9152
+ confirmation_channel_id: z20.string().describe("`channel_id` from the envelope of the Slack message that asked for or accepted this."),
9153
+ confirmation_thread_ts: z20.string().describe("`thread_ts` from that message's envelope."),
9154
+ confirmation_message_ts: z20.string().describe("`message_ts` from that message's envelope."),
9155
+ confirmation_user_id: z20.string().describe("`user_id` from that message's envelope.")
9138
9156
  });
9139
9157
  var mothershipAutomationToolInputSchema = automationToolInputSchema.extend(mothershipSlackConfirmationSchema.shape);
9140
9158
  var mothershipSaveChannelPresetToolInputSchema = mothershipSlackConfirmationSchema.extend({
9141
- preset_id: z19.string().optional().describe(`Id of the preset to update, from \`${REPLICAS_MCP_TOOLS.listChannelSettings}\`. Omit to create a new preset.`),
9142
- name: z19.string().trim().min(1).max(MOTHERSHIP_PRESET_NAME_MAX_LENGTH).optional().describe("Preset name. Required when creating."),
9143
- description: z19.string().optional().describe("One-line summary shown in settings."),
9144
- icon: z19.enum(MOTHERSHIP_PRESET_ICONS).optional(),
9145
- instructions: z19.string().optional().describe("Complete preset instructions; replaces the existing text. Required when creating.")
9159
+ preset_id: z20.string().optional().describe(`Id of the preset to update, from \`${REPLICAS_MCP_TOOLS.listChannelSettings}\`. Omit to create a new preset.`),
9160
+ name: z20.string().trim().min(1).max(MOTHERSHIP_PRESET_NAME_MAX_LENGTH).optional().describe("Preset name. Required when creating."),
9161
+ description: z20.string().optional().describe("One-line summary shown in settings."),
9162
+ icon: z20.enum(MOTHERSHIP_PRESET_ICONS).optional(),
9163
+ instructions: z20.string().optional().describe("Complete preset instructions; replaces the existing text. Required when creating.")
9146
9164
  });
9147
9165
  var mothershipUpdateChannelSettingsToolInputSchema = mothershipSlackConfirmationSchema.extend({
9148
- source: z19.enum(MOTHERSHIP_SOURCE_TYPES).optional().describe("Defaults to `slack`."),
9149
- external_id: z19.string().describe("Slack channel id or Linear team id."),
9150
- monitored: z19.boolean().optional().describe("`false` stops Mothership from handling the source: it excludes a Slack channel or stops monitoring a Linear team. `true` resumes a Slack channel or starts monitoring a Linear team, and only an organization admin can ask for that. Omit to keep it."),
9151
- preset_id: z19.string().nullable().optional().describe("Preset to assign; `null` removes the preset. Omit to keep it."),
9152
- instructions: z19.string().nullable().optional().describe("Complete channel-specific instructions, applied after the preset; replaces the existing text. `null` clears them. Omit to keep them.")
9166
+ source: z20.enum(MOTHERSHIP_SOURCE_TYPES).optional().describe("Defaults to `slack`."),
9167
+ external_id: z20.string().describe("Slack channel id or Linear team id."),
9168
+ monitored: z20.boolean().optional().describe("`false` stops Mothership from handling the source: it excludes a Slack channel or stops monitoring a Linear team. `true` resumes a Slack channel or starts monitoring a Linear team, and only an organization admin can ask for that. Omit to keep it."),
9169
+ preset_id: z20.string().nullable().optional().describe("Preset to assign; `null` removes the preset. Omit to keep it."),
9170
+ instructions: z20.string().nullable().optional().describe("Complete channel-specific instructions, applied after the preset; replaces the existing text. `null` clears them. Omit to keep them.")
9153
9171
  });
9154
9172
  var mothershipDeleteChannelPresetToolInputSchema = mothershipSlackConfirmationSchema.extend({
9155
- preset_id: z19.string().describe(`Id of the preset to delete, from \`${REPLICAS_MCP_TOOLS.listChannelSettings}\`.`)
9173
+ preset_id: z20.string().describe(`Id of the preset to delete, from \`${REPLICAS_MCP_TOOLS.listChannelSettings}\`.`)
9156
9174
  });
9157
9175
 
9158
9176
  // ../shared/src/routes/plugin-catalog.ts
@@ -9501,50 +9519,69 @@ var workspaceMarkedUnreadClientStateKey = orgUserClientStateKey(WORKSPACE_MARKED
9501
9519
  var promptHistoryClientStateKey = orgUserClientStateKey(PROMPT_HISTORY_CLIENT_STATE_KEY_PREFIX);
9502
9520
 
9503
9521
  // ../shared/src/routes/workspace-events.ts
9504
- import { z as z20 } from "zod";
9505
- var workspaceChangedEventSchema = z20.discriminatedUnion("type", [
9506
- z20.object({
9507
- type: z20.literal("workspace.changed"),
9508
- workspaceId: z20.string(),
9509
- workspace: z20.object({ status: z20.enum(WORKSPACE_STATUSES), last_activity_at: z20.string().nullable() }).optional(),
9510
- completion: z20.object({
9511
- workspaceName: z20.string(),
9512
- completedAt: z20.string(),
9513
- processing: z20.boolean().optional()
9522
+ import { z as z21 } from "zod";
9523
+ var workspaceChangedEventSchema = z21.discriminatedUnion("type", [
9524
+ z21.object({
9525
+ type: z21.literal("workspace.changed"),
9526
+ workspaceId: z21.string(),
9527
+ workspace: z21.object({ status: z21.enum(WORKSPACE_STATUSES), last_activity_at: z21.string().nullable() }).optional(),
9528
+ completion: z21.object({
9529
+ workspaceName: z21.string(),
9530
+ completedAt: z21.string(),
9531
+ processing: z21.boolean().optional()
9514
9532
  }).optional(),
9515
- ts: z20.string()
9533
+ ts: z21.string()
9516
9534
  }),
9517
- z20.object({
9518
- type: z20.literal("workspace.chat.changed"),
9519
- workspaceId: z20.string(),
9520
- chatId: z20.string(),
9521
- ts: z20.string()
9535
+ z21.object({
9536
+ type: z21.literal("workspace.chat.changed"),
9537
+ workspaceId: z21.string(),
9538
+ chatId: z21.string(),
9539
+ ts: z21.string()
9522
9540
  }),
9523
- z20.object({ type: z20.literal("presence.changed"), ts: z20.string() }),
9524
- z20.object({
9525
- type: z20.literal("mobile-testing.changed"),
9526
- workspaceId: z20.string(),
9527
- ts: z20.string()
9541
+ z21.object({ type: z21.literal("presence.changed"), ts: z21.string() }),
9542
+ z21.object({
9543
+ type: z21.literal("mobile-testing.changed"),
9544
+ workspaceId: z21.string(),
9545
+ ts: z21.string()
9528
9546
  })
9529
9547
  ]);
9530
9548
 
9531
9549
  // ../shared/src/routes/presence.ts
9532
- import { z as z21 } from "zod";
9533
- var presenceStatusSchema = z21.enum(["online", "typing"]);
9534
- var presenceLocationSchema = z21.object({
9535
- workspaceId: z21.string().optional()
9550
+ import { z as z22 } from "zod";
9551
+ var presenceStatusSchema = z22.enum(["online", "typing"]);
9552
+ var presenceLocationSchema = z22.object({
9553
+ workspaceId: z22.string().optional()
9536
9554
  });
9537
- var presenceEntrySchema = z21.object({
9538
- userId: z21.string(),
9555
+ var presenceEntrySchema = z22.object({
9556
+ userId: z22.string(),
9539
9557
  status: presenceStatusSchema,
9540
9558
  location: presenceLocationSchema,
9541
- ts: z21.string()
9559
+ ts: z22.string()
9542
9560
  });
9543
- var updatePresenceRequestSchema = z21.object({
9561
+ var updatePresenceRequestSchema = z22.object({
9544
9562
  status: presenceStatusSchema,
9545
9563
  location: presenceLocationSchema.optional()
9546
9564
  });
9547
9565
 
9566
+ // ../shared/src/routes/review-messages.ts
9567
+ import { z as z23 } from "zod";
9568
+ var sendPullRequestReviewMessageRequestSchema = z23.object({
9569
+ ...sendChatMessageRequestSchema.pick({
9570
+ message: true,
9571
+ messageId: true,
9572
+ submittedAt: true,
9573
+ model: true,
9574
+ images: true,
9575
+ canvasUploadIds: true,
9576
+ thinkingLevel: true,
9577
+ fastMode: true,
9578
+ ultrafastMode: true
9579
+ }).shape,
9580
+ /** Starts a new chat instead of continuing the PR's review chat. The provider only applies to a new chat. */
9581
+ newChat: z23.boolean().optional(),
9582
+ provider: z23.enum(VALID_AGENT_PROVIDERS).optional()
9583
+ });
9584
+
9548
9585
  // ../shared/src/audit-log.ts
9549
9586
  var AUDIT_LOG_ACTION = {
9550
9587
  CREATE: "create",
@@ -9912,6 +9949,10 @@ export {
9912
9949
  OPENCODE_GO_BASE_URL,
9913
9950
  DEFAULT_OPENCODE_GO_MODEL,
9914
9951
  fetchOpenCodeGoCatalog,
9952
+ isGitHubUrl,
9953
+ parseCodeHostPrUrl,
9954
+ decodePathSegments,
9955
+ buildCodeHostPrUrl,
9915
9956
  detectLanguageByPath,
9916
9957
  isDefaultChat,
9917
9958
  CLAUDE_OPUS_4_8_BEDROCK_MODEL,
@@ -9999,10 +10040,6 @@ export {
9999
10040
  SUBAGENT_MCP_TOOLS,
10000
10041
  SUBAGENT_MCP_TOOL_NAMES,
10001
10042
  parseMcpToolName,
10002
- isGitHubUrl,
10003
- parseCodeHostPrUrl,
10004
- decodePathSegments,
10005
- buildCodeHostPrUrl,
10006
10043
  createUuidFromHex,
10007
10044
  WORKSPACE_IDENTITY_AUDIENCE,
10008
10045
  AWS_SOURCE_IDENTITY_CLAIM,