replicas-engine 0.1.1036 → 0.1.1038

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.
@@ -10,6 +10,31 @@ function isNonEmptyString(value) {
10
10
  return typeof value === "string" && value.trim().length > 0;
11
11
  }
12
12
 
13
+ // ../shared/src/async.ts
14
+ var TIMEOUT = /* @__PURE__ */ Symbol("timeout");
15
+ async function raceWithTimeout(promise, ms) {
16
+ let timer;
17
+ try {
18
+ return await Promise.race([
19
+ promise,
20
+ new Promise((resolve) => {
21
+ timer = setTimeout(() => resolve(TIMEOUT), ms);
22
+ })
23
+ ]);
24
+ } finally {
25
+ clearTimeout(timer);
26
+ promise.catch(() => {
27
+ });
28
+ }
29
+ }
30
+ async function withTimeout(promise, ms, message2) {
31
+ const result = await raceWithTimeout(promise, ms);
32
+ if (result === TIMEOUT) {
33
+ throw new Error(message2);
34
+ }
35
+ return result;
36
+ }
37
+
13
38
  // ../shared/src/result.ts
14
39
  function createSuccessResult(data) {
15
40
  return { ok: true, data };
@@ -78,6 +103,14 @@ function getProviderDisplayName(provider2, variant = "short") {
78
103
  }
79
104
  }
80
105
 
106
+ // ../shared/src/api-casing.ts
107
+ var toCamel = (key) => key.replace(/_([a-z0-9])/g, (_, char) => char.toUpperCase());
108
+ function withCamelCaseKeys(body) {
109
+ if (!isRecord(body)) return body;
110
+ const aliases = Object.entries(body).filter(([key]) => key.includes("_") && !(toCamel(key) in body));
111
+ return aliases.length ? { ...body, ...Object.fromEntries(aliases.map(([key, entry]) => [toCamel(key), entry])) } : body;
112
+ }
113
+
81
114
  // ../shared/src/aster.ts
82
115
  var ASTER_PROVIDER = "aster";
83
116
  var ASTER_BASE_URL = "https://api.asterlab.ai/v1";
@@ -969,7 +1002,7 @@ var PLANS = {
969
1002
  "Higher API rate limits",
970
1003
  "Mobile app",
971
1004
  "Access to a static egress IP",
972
- "Auto-upgraded sandbox resources (4 vCPU, 32 GB disk, 16 GB memory)",
1005
+ "Auto-upgraded to Large workspaces (4 vCPU, 16 GB memory)",
973
1006
  "Shared Slack support channel"
974
1007
  ]
975
1008
  },
@@ -1246,6 +1279,7 @@ var sendChatMessageRequestSchema = z3.object({
1246
1279
  thinkingLevel: z3.enum(VALID_THINKING_LEVELS).optional(),
1247
1280
  goalMode: z3.boolean().optional(),
1248
1281
  fastMode: z3.boolean().optional(),
1282
+ ultrafastMode: z3.boolean().optional(),
1249
1283
  source: z3.enum(MESSAGE_SOURCES).optional(),
1250
1284
  enableInteractiveTools: z3.boolean().optional(),
1251
1285
  type: z3.string().min(1).optional(),
@@ -1462,7 +1496,8 @@ function parseChatHistoryCursor(value) {
1462
1496
  function createChatHistoryCursor(cursor, mode = "range") {
1463
1497
  return cursor.events === null && cursor.turns === null ? null : JSON.stringify({ mode, ...cursor });
1464
1498
  }
1465
- function chatHistoryPageParamsFromQuery(query) {
1499
+ function chatHistoryPageParamsFromQuery(rawQuery) {
1500
+ const query = withCamelCaseKeys(rawQuery);
1466
1501
  const parse = (value) => {
1467
1502
  if (value === void 0) return void 0;
1468
1503
  const parsed = Number.parseInt(value, 10);
@@ -1472,7 +1507,8 @@ function chatHistoryPageParamsFromQuery(query) {
1472
1507
  limit: parse(query.limit),
1473
1508
  beforeEvent: parse(query.beforeEvent),
1474
1509
  beforeTurn: parse(query.beforeTurn),
1475
- beforeCursor: query.beforeCursor || void 0
1510
+ beforeCursor: query.beforeCursor || void 0,
1511
+ afterCursor: query.afterCursor || void 0
1476
1512
  };
1477
1513
  }
1478
1514
  function getChatHistoryPageWindow(totalItems, limit, before) {
@@ -1832,31 +1868,6 @@ function safeJsonParse(str, fallback) {
1832
1868
  }
1833
1869
  }
1834
1870
 
1835
- // ../shared/src/async.ts
1836
- var TIMEOUT = /* @__PURE__ */ Symbol("timeout");
1837
- async function raceWithTimeout(promise, ms) {
1838
- let timer;
1839
- try {
1840
- return await Promise.race([
1841
- promise,
1842
- new Promise((resolve) => {
1843
- timer = setTimeout(() => resolve(TIMEOUT), ms);
1844
- })
1845
- ]);
1846
- } finally {
1847
- clearTimeout(timer);
1848
- promise.catch(() => {
1849
- });
1850
- }
1851
- }
1852
- async function withTimeout(promise, ms, message2) {
1853
- const result = await raceWithTimeout(promise, ms);
1854
- if (result === TIMEOUT) {
1855
- throw new Error(message2);
1856
- }
1857
- return result;
1858
- }
1859
-
1860
1871
  // ../shared/src/agent-quota.ts
1861
1872
  var OUT_OF_CREDITS_PATTERNS = [
1862
1873
  /credit balance is too low/,
@@ -2860,7 +2871,7 @@ var SANDBOX_PATHS = {
2860
2871
  REPLICAS_CANVAS_DIR: "/home/user/.replicas/canvas",
2861
2872
  REPLICAS_RUNTIME_ENV_FILE: "/home/user/.replicas/runtime-env.sh"
2862
2873
  };
2863
- var WORKSPACE_SIZES = ["small", "large"];
2874
+ var WORKSPACE_SIZES = ["small", "large", "ultra"];
2864
2875
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
2865
2876
 
2866
2877
  // ../shared/src/learned-skills.ts
@@ -3946,7 +3957,7 @@ Create tickets, fetch issues, update state, add comments, and search through \`r
3946
3957
 
3947
3958
  Use this when:
3948
3959
  - You need to create a Linear ticket or issue
3949
- - You encounter a Linear issue link and need to understand the task
3960
+ - You encounter a linear.app issue link and need to understand the task
3950
3961
  - You need to update an issue's state or add a comment
3951
3962
  - You need to search Linear issues
3952
3963
  - A Linear request failed with an authentication error`;
@@ -4004,6 +4015,8 @@ const issue = await replicas.linear.graphql({
4004
4015
  });
4005
4016
  \`\`\`
4006
4017
 
4018
+ For a link such as \`https://linear.app/acme/issue/ENG-123/fix-login\`, the identifier is the path segment after \`/issue/\` (\`ENG-123\`).
4019
+
4007
4020
  ## Update and comment in one script
4008
4021
 
4009
4022
  \`\`\`ts
@@ -4040,7 +4053,7 @@ For screenshots, recordings, diagrams, or other media, read \`references/MEDIA.m
4040
4053
  var LINEAR_ABILITY = {
4041
4054
  label: "Linear",
4042
4055
  description: "Create tickets, fetch issues, comment, and update state through @replicas/sdk.",
4043
- bullet: "- Interacting with Linear (creating tickets, fetching issues, updating state, commenting, or troubleshooting authentication): use replicas.linear.graphql from @replicas/sdk, which refreshes tokens automatically and needs no Linear MCP server. Read references/LINEAR.md before treating a rejected workspace token as a disconnected integration.",
4056
+ bullet: "- Interacting with Linear (creating tickets, fetching issues including any linear.app link the user shares, updating state, commenting, or troubleshooting authentication): use replicas.linear.graphql from @replicas/sdk, which refreshes tokens automatically and needs no Linear MCP server. Read references/LINEAR.md before treating a rejected workspace token as a disconnected integration.",
4044
4057
  section: SECTION6,
4045
4058
  referenceFile: { name: "LINEAR.md", content: REFERENCE6 }
4046
4059
  };
@@ -4964,6 +4977,7 @@ Read issues and project data through the workspace-scoped TypeScript SDK.
4964
4977
  **Reference:** \`references/SENTRY.md\`
4965
4978
 
4966
4979
  Use this when:
4980
+ - A user shares a sentry.io link
4967
4981
  - You need to inspect Sentry projects or issues
4968
4982
  - A user asks for error-monitoring context outside a webhook-triggered task`;
4969
4983
  var REFERENCE11 = `# Sentry Integration
@@ -4978,12 +4992,23 @@ import { replicas } from '@replicas/sdk';
4978
4992
  const issues = await replicas.sentry.request('/organizations/acme/issues/?query=is:unresolved');
4979
4993
  \`\`\`
4980
4994
 
4995
+ ## Read a pasted issue link
4996
+
4997
+ Map the link to API paths instead of fetching the page. For \`https://acme.sentry.io/issues/4512345678/?project=123\` or \`https://sentry.io/organizations/acme/issues/4512345678/\`, the organization slug is \`acme\` and the issue ID is \`4512345678\`:
4998
+
4999
+ \`\`\`ts
5000
+ const issue = await replicas.sentry.request('/organizations/acme/issues/4512345678/');
5001
+ const latest = await replicas.sentry.request('/organizations/acme/issues/4512345678/events/latest/');
5002
+ \`\`\`
5003
+
5004
+ A link ending in \`/events/<eventId>/\` names a specific event: \`/organizations/acme/issues/4512345678/events/<eventId>/\`. Resolve a short ID such as \`BACKEND-1A2\` with \`/organizations/acme/shortids/BACKEND-1A2/\`. The event's \`entries\` hold the stack trace and breadcrumbs.
5005
+
4981
5006
  Pass only a relative Sentry API path. The Replicas gateway selects the connected organization credential and rejects writes, absolute URLs, oversized responses, and long-running requests.
4982
5007
  `;
4983
5008
  var SENTRY_ABILITY = {
4984
5009
  label: "Sentry",
4985
5010
  description: "Read Sentry projects and issues through @replicas/sdk.",
4986
- bullet: "- Interacting with Sentry (reading projects, issues, and error context)",
5011
+ bullet: "- Interacting with Sentry (reading projects, issues, and error context, including any sentry.io link the user shares): use replicas.sentry.request from @replicas/sdk. Read references/SENTRY.md to turn an issue link into API paths.",
4987
5012
  section: SECTION11,
4988
5013
  referenceFile: { name: "SENTRY.md", content: REFERENCE11 }
4989
5014
  };
@@ -5234,8 +5259,8 @@ var automationUpdateToolInputSchema = automationToolInputSchema.partial().extend
5234
5259
  var chatPath = { id: z15.string().describe("Workspace ID"), chat_id: z15.string().describe("Chat ID") };
5235
5260
  var { provider, model, thinkingLevel, title, message } = forkChatRequestSchema.shape;
5236
5261
  var createChatToolInputSchema = z15.object({ id: chatPath.id, provider, title: createChatRequestSchema.shape.title });
5237
- var forkChatToolInputSchema = z15.object({ ...chatPath, provider, model, thinkingLevel, title, message });
5238
- var renameChatToolInputSchema = z15.object({ ...chatPath, ...updateChatDisplayNameRequestSchema.shape });
5262
+ var forkChatToolInputSchema = z15.object({ ...chatPath, provider, model, thinking_level: thinkingLevel, title, message });
5263
+ var renameChatToolInputSchema = z15.object({ ...chatPath, display_name: updateChatDisplayNameRequestSchema.shape.displayName });
5239
5264
  var runCommandToolInputSchema = z15.object({ id: chatPath.id, ...workspaceExecRequestSchema.shape });
5240
5265
  var environmentMcpPath = { environment_id: z15.string().describe("Environment ID") };
5241
5266
  var createEnvironmentMcpToolInputSchema = z15.object({ ...environmentMcpPath, ...createEnvironmentMcpRequestSchema.shape });
@@ -9527,6 +9552,26 @@ async function readJsonlPage(args) {
9527
9552
  before: before > 0 ? String(before) : null
9528
9553
  };
9529
9554
  }
9555
+ var MAX_APPENDED_BYTES = 4 * 1024 * 1024;
9556
+ async function readJsonlAppended(args) {
9557
+ const start = /^(0|[1-9]\d*)$/.test(args.after) ? Number(args.after) : Number.NaN;
9558
+ if (!Number.isSafeInteger(start) || start > args.size || args.size - start > MAX_APPENDED_BYTES) return null;
9559
+ if (start === args.size) return { items: [], after: args.after };
9560
+ const from = Math.max(0, start - 1);
9561
+ const bytes = await readExactRange(args.readRange, from, args.size, "Incomplete JSONL append read");
9562
+ if (start > 0 && bytes[0] !== 10) return null;
9563
+ const items = [];
9564
+ let lineStart = start - from;
9565
+ for (let lineEnd = bytes.indexOf(10, lineStart); lineEnd !== -1; lineEnd = bytes.indexOf(10, lineStart)) {
9566
+ try {
9567
+ const item = args.parse(JSON.parse(decoder.decode(bytes.subarray(lineStart, lineEnd))));
9568
+ if (item !== void 0) items.push(item);
9569
+ } catch {
9570
+ }
9571
+ lineStart = lineEnd + 1;
9572
+ }
9573
+ return { items, after: String(from + lineStart) };
9574
+ }
9530
9575
  function parseChatTranscriptHistoryIndex(value) {
9531
9576
  if (!isRecord(value) || value.version !== 2 || !isNonNegativeInteger(value.sourceSize)) return void 0;
9532
9577
  const removedMessageIds = Array.isArray(value.removedMessageIds) ? value.removedMessageIds.filter((id) => typeof id === "string") : [];
@@ -9894,6 +9939,7 @@ export {
9894
9939
  searchRepoFileIndex,
9895
9940
  isExcludedRepoFilePath,
9896
9941
  readJsonlPage,
9942
+ readJsonlAppended,
9897
9943
  normalizeChatTranscriptMetadata,
9898
9944
  parseChatTranscriptArtifact,
9899
9945
  readSseStream,
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-OPJ5KAGY.js";
8
+ } from "./chunk-MALHGZWB.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  execFileAsync
6
- } from "./chunk-KVJYQOUT.js";
6
+ } from "./chunk-XOSNMSSU.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-OPJ5KAGY.js";
9
+ } from "./chunk-MALHGZWB.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -233,14 +233,14 @@ var DEFAULT_CODEX_ARGS = [
233
233
  "-c",
234
234
  "memories.generate_memories=false"
235
235
  ];
236
- var MIN_CODEX_CLI_VERSION = "0.159.2";
236
+ var MIN_CODEX_CLI_VERSION = "0.162.1";
237
237
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
238
238
  var codexCliVersionEnsured = null;
239
239
  function getCodexModelProvider(method) {
240
240
  if (method === "foundry") return "azure";
241
241
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
242
242
  }
243
- var ENGINE_PACKAGE_VERSION = "0.1.1036";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1038";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-OPJ5KAGY.js";
6
+ } from "./chunk-MALHGZWB.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-W6NY5P76.js";
7
- import "./chunk-2RHUTB67.js";
8
- import "./chunk-KVJYQOUT.js";
6
+ } from "./chunk-5PNGQGYW.js";
7
+ import "./chunk-5TYR5GFS.js";
8
+ import "./chunk-XOSNMSSU.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-OPJ5KAGY.js";
12
+ import "./chunk-MALHGZWB.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -7,12 +7,12 @@ import {
7
7
  import {
8
8
  AppServerProcess,
9
9
  buildCodexAgentEnv
10
- } from "./chunk-AP442WDC.js";
11
- import "./chunk-KVJYQOUT.js";
10
+ } from "./chunk-SHHV4JCC.js";
11
+ import "./chunk-XOSNMSSU.js";
12
12
  import {
13
13
  AGENT,
14
14
  headlessAgentRequestSchema
15
- } from "./chunk-OPJ5KAGY.js";
15
+ } from "./chunk-MALHGZWB.js";
16
16
  import "./chunk-VEQXQN22.js";
17
17
 
18
18
  // src/headless-agent.ts