replicas-engine 0.1.1035 → 0.1.1036

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.
@@ -5,12 +5,12 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-ST4ODIF2.js";
9
- import "./chunk-WRAVQEOB.js";
10
- import "./chunk-F52XMCMW.js";
11
- import "./chunk-SEYXPQY7.js";
8
+ } from "./chunk-EDNMHUVD.js";
9
+ import "./chunk-2RHUTB67.js";
10
+ import "./chunk-AP442WDC.js";
11
+ import "./chunk-KVJYQOUT.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-MD2DJUY2.js";
13
+ import "./chunk-OPJ5KAGY.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
  export {
16
16
  getCodexAspHost,
@@ -14,7 +14,7 @@ import {
14
14
  isValidAgentProvider,
15
15
  parsePosixEnvFile,
16
16
  readReplicasRuntimeEnv
17
- } from "./chunk-MD2DJUY2.js";
17
+ } from "./chunk-OPJ5KAGY.js";
18
18
 
19
19
  // src/runtime-env-loader.ts
20
20
  import { readFileSync } from "fs";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-MD2DJUY2.js";
8
+ } from "./chunk-OPJ5KAGY.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-SEYXPQY7.js";
6
+ } from "./chunk-KVJYQOUT.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-MD2DJUY2.js";
9
+ } from "./chunk-OPJ5KAGY.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -240,7 +240,7 @@ 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.1035";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1036";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -5,15 +5,15 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-WRAVQEOB.js";
8
+ } from "./chunk-2RHUTB67.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-F52XMCMW.js";
12
+ } from "./chunk-AP442WDC.js";
13
13
  import {
14
14
  SUBPROCESS_MAX_BUFFER,
15
15
  execFileAsync
16
- } from "./chunk-SEYXPQY7.js";
16
+ } from "./chunk-KVJYQOUT.js";
17
17
  import {
18
18
  isRecord
19
19
  } from "./chunk-UZSNFLDQ.js";
@@ -28,7 +28,7 @@ import {
28
28
  listOpenAICompatibleModels,
29
29
  readOllamaAuthEnv,
30
30
  resolveOpenAICompatibleModelsUrl
31
- } from "./chunk-MD2DJUY2.js";
31
+ } from "./chunk-OPJ5KAGY.js";
32
32
 
33
33
  // src/managers/codex-token-manager.ts
34
34
  import { promises as fs } from "fs";
@@ -264,7 +264,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
264
264
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
265
265
  await this.applyCredentialsResponse(data);
266
266
  setAgentCredentialSnapshot("codex", data);
267
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-CRMYVVBY.js");
267
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-4JQWKA47.js");
268
268
  await restartCodexAspHostIfRunning2();
269
269
  });
270
270
  await this.start(true);
@@ -285,7 +285,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
285
285
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
286
286
  await this.applyCredentialsResponse(data);
287
287
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
288
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-CRMYVVBY.js");
288
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-4JQWKA47.js");
289
289
  await restartCodexAspHostIfRunning2();
290
290
  }
291
291
  setAgentCredentialSnapshot("codex", data);
@@ -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-MD2DJUY2.js";
6
+ } from "./chunk-OPJ5KAGY.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -9476,36 +9476,46 @@ async function readJsonlPage(args) {
9476
9476
  throw new RangeError("Invalid JSONL page");
9477
9477
  }
9478
9478
  let startByte = endByte;
9479
- let bytes = new Uint8Array();
9480
- let items = [];
9481
- while (startByte > 0 && items.length < args.limit && (endByte - startByte < MAX_SOURCE_PAGE_BYTES || !bytes.subarray(0, -1).includes(10))) {
9482
- const nextStartByte = Math.max(0, startByte - SOURCE_RANGE_BYTES);
9479
+ let head = new Uint8Array();
9480
+ let headTerminated = false;
9481
+ let lineBreaks = 0;
9482
+ let endsWithLineBreak = false;
9483
+ const pages = [];
9484
+ let itemCount = 0;
9485
+ while (startByte > 0 && itemCount < args.limit && (endByte - startByte < MAX_SOURCE_PAGE_BYTES || lineBreaks - (endsWithLineBreak ? 1 : 0) === 0)) {
9486
+ const read = endByte - startByte;
9487
+ const nextStartByte = Math.max(0, startByte - (read < MAX_SOURCE_PAGE_BYTES ? Math.min(Math.max(SOURCE_RANGE_BYTES, read), MAX_SOURCE_PAGE_BYTES - read) : SOURCE_RANGE_BYTES));
9483
9488
  const chunk = await readExactRange(
9484
9489
  args.readRange,
9485
9490
  nextStartByte,
9486
9491
  startByte,
9487
9492
  "Incomplete JSONL page read"
9488
9493
  );
9489
- const combined = new Uint8Array(chunk.length + bytes.length);
9490
- combined.set(chunk);
9491
- combined.set(bytes, chunk.length);
9492
- bytes = combined;
9494
+ if (startByte === endByte) endsWithLineBreak = chunk[chunk.length - 1] === 10;
9495
+ for (let index = chunk.indexOf(10); index !== -1; index = chunk.indexOf(10, index + 1)) lineBreaks++;
9496
+ const bytes = new Uint8Array(chunk.length + head.length + (headTerminated ? 1 : 0));
9497
+ bytes.set(chunk);
9498
+ bytes.set(head, chunk.length);
9499
+ if (headTerminated) bytes[bytes.length - 1] = 10;
9493
9500
  startByte = nextStartByte;
9494
- items = [];
9495
- let lineStart = 0;
9496
- for (let lineEnd = bytes.indexOf(10); lineEnd !== -1; lineEnd = bytes.indexOf(10, lineStart)) {
9497
- if (!(startByte > 0 && lineStart === 0)) {
9498
- try {
9499
- const item = args.parse(JSON.parse(decoder.decode(bytes.subarray(lineStart, lineEnd))));
9500
- if (item !== void 0) items.push({ item, startByte: startByte + lineStart });
9501
- } catch {
9502
- }
9501
+ const firstLineEnd = bytes.indexOf(10);
9502
+ const page = [];
9503
+ let lineStart = startByte > 0 ? firstLineEnd + 1 : 0;
9504
+ for (let lineEnd = bytes.indexOf(10, lineStart); lineEnd !== -1; lineEnd = bytes.indexOf(10, lineStart)) {
9505
+ try {
9506
+ const item = args.parse(JSON.parse(decoder.decode(bytes.subarray(lineStart, lineEnd))));
9507
+ if (item !== void 0) page.push({ item, startByte: startByte + lineStart });
9508
+ } catch {
9503
9509
  }
9504
9510
  lineStart = lineEnd + 1;
9505
9511
  }
9512
+ head = firstLineEnd === -1 ? bytes : bytes.subarray(0, startByte > 0 ? firstLineEnd : 0);
9513
+ headTerminated = firstLineEnd !== -1;
9514
+ pages.push(page);
9515
+ itemCount += page.length;
9506
9516
  }
9507
- const selected = items.slice(-args.limit);
9508
- const firstCompleteLine = bytes.indexOf(10) + 1;
9517
+ const selected = pages.reverse().flat().slice(-args.limit);
9518
+ const firstCompleteLine = headTerminated ? head.length + 1 : 0;
9509
9519
  let before = 0;
9510
9520
  if (selected.length === args.limit) before = selected[0].startByte;
9511
9521
  else if (startByte > 0) {
@@ -3,18 +3,18 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-WRAVQEOB.js";
6
+ } from "./chunk-2RHUTB67.js";
7
7
  import {
8
8
  SUBPROCESS_MAX_BUFFER,
9
9
  execFileAsync
10
- } from "./chunk-SEYXPQY7.js";
10
+ } from "./chunk-KVJYQOUT.js";
11
11
  import {
12
12
  extractCommandProtectionCommandText,
13
13
  findCommandProtectionGitLookups,
14
14
  findGitCommitSignals,
15
15
  findPrMergeSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-MD2DJUY2.js";
17
+ } from "./chunk-OPJ5KAGY.js";
18
18
 
19
19
  // src/services/command-protection-service.ts
20
20
  import { readFile, stat } from "fs/promises";
@@ -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-SXWQC3OB.js";
7
- import "./chunk-WRAVQEOB.js";
8
- import "./chunk-SEYXPQY7.js";
6
+ } from "./chunk-W6NY5P76.js";
7
+ import "./chunk-2RHUTB67.js";
8
+ import "./chunk-KVJYQOUT.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-MD2DJUY2.js";
12
+ import "./chunk-OPJ5KAGY.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-F52XMCMW.js";
11
- import "./chunk-SEYXPQY7.js";
10
+ } from "./chunk-AP442WDC.js";
11
+ import "./chunk-KVJYQOUT.js";
12
12
  import {
13
13
  AGENT,
14
14
  headlessAgentRequestSchema
15
- } from "./chunk-MD2DJUY2.js";
15
+ } from "./chunk-OPJ5KAGY.js";
16
16
  import "./chunk-VEQXQN22.js";
17
17
 
18
18
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  reportCommandProtectionBlock,
33
33
  resolveDiffBase,
34
34
  runGitCommand
35
- } from "./chunk-SXWQC3OB.js";
35
+ } from "./chunk-W6NY5P76.js";
36
36
  import {
37
37
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
38
38
  AGENT_MESSAGE_DELTA_METHOD,
@@ -57,7 +57,7 @@ import {
57
57
  } from "./chunk-P73LGPQO.js";
58
58
  import {
59
59
  publishedPullRequestUrls
60
- } from "./chunk-X6SC3YRN.js";
60
+ } from "./chunk-3OBN7KPB.js";
61
61
  import {
62
62
  BaseRefreshManager,
63
63
  CodexAspAuthMethodChangedError,
@@ -71,7 +71,7 @@ import {
71
71
  refreshDelayMs,
72
72
  restartCodexAspHost,
73
73
  routineRefreshRequest
74
- } from "./chunk-ST4ODIF2.js";
74
+ } from "./chunk-EDNMHUVD.js";
75
75
  import {
76
76
  ENGINE_ENV,
77
77
  monolithRequest,
@@ -79,16 +79,16 @@ import {
79
79
  readRuntimeEnvFile,
80
80
  reloadEngineEnv,
81
81
  setAgentCredentialSnapshot
82
- } from "./chunk-WRAVQEOB.js";
82
+ } from "./chunk-2RHUTB67.js";
83
83
  import {
84
84
  AspClient,
85
85
  getCodexModelProvider
86
- } from "./chunk-F52XMCMW.js";
86
+ } from "./chunk-AP442WDC.js";
87
87
  import {
88
88
  SUBPROCESS_MAX_BUFFER,
89
89
  execAsync,
90
90
  execFileAsync
91
- } from "./chunk-SEYXPQY7.js";
91
+ } from "./chunk-KVJYQOUT.js";
92
92
  import {
93
93
  isRecord as isRecord2
94
94
  } from "./chunk-UZSNFLDQ.js";
@@ -322,7 +322,7 @@ import {
322
322
  workspaceTokenRequestSchema,
323
323
  workspaceTokenResponseSchema,
324
324
  wrapInTag
325
- } from "./chunk-MD2DJUY2.js";
325
+ } from "./chunk-OPJ5KAGY.js";
326
326
  import {
327
327
  cloneMcpConfig,
328
328
  ensureCompatibilityImports,
@@ -60644,6 +60644,7 @@ async function buildForkHandoff(input) {
60644
60644
  // src/services/chat/slack-activity-stream.ts
60645
60645
  var FLUSH_INTERVAL_MS = 3e3;
60646
60646
  var MAX_ACTIVITY_LENGTH = 100;
60647
+ var MAX_THOUGHT_LENGTH = 500;
60647
60648
  var MAX_CODE_LENGTH = 40;
60648
60649
  var MAX_DONE_ATTEMPTS = 3;
60649
60650
  var GENERIC_STEPS = {
@@ -60665,11 +60666,11 @@ var code = (text) => {
60665
60666
  };
60666
60667
  var basename4 = (path7) => path7.split("/").pop() || path7;
60667
60668
  function describeActivity(message, idle) {
60669
+ if (planItemsFromMessage(message) || message.type === "tool_call" && message.inputRequest) return null;
60668
60670
  if (message.type === "agent" || message.type === "reasoning" && !isCompaction(message)) {
60669
- const heading = message.type === "reasoning" ? [...message.content.matchAll(/^\*\*(.+?)\*\*$/gm)].at(-1)?.[1] : void 0;
60670
- return { thought: clean(heading ?? "") || "Thinking" };
60671
+ const thought = message.content.replace(/\*\*/g, "").replace(/\s+/g, " ").trim();
60672
+ return thought ? { thought: thought.length > MAX_THOUGHT_LENGTH ? `\u2026${thought.slice(1 - MAX_THOUGHT_LENGTH)}` : thought } : null;
60671
60673
  }
60672
- if (planItemsFromMessage(message) || message.type === "tool_call" && message.inputRequest) return null;
60673
60674
  const steps = describeMessageSteps(message);
60674
60675
  const step = steps.at(-1);
60675
60676
  if (!step) return null;
@@ -60699,9 +60700,6 @@ var SlackActivityStream = class {
60699
60700
  stopped = false;
60700
60701
  queued = false;
60701
60702
  noteEvent(event) {
60702
- if (event.type === CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE) return;
60703
- const partialType = event.type === CODEX_ITEM_PARTIAL_EVENT_TYPE ? codexItemFromEvent(event)?.item.type : void 0;
60704
- if (partialType === "agentMessage" || partialType === "reasoning") return;
60705
60703
  const streamId = getEventStreamId(event);
60706
60704
  const index = streamId ? this.events.findLastIndex((previous) => getEventStreamId(previous) === streamId) : -1;
60707
60705
  if (index >= 0) this.events[index] = event;
@@ -60734,7 +60732,9 @@ var SlackActivityStream = class {
60734
60732
  if (idle && this.settled) return true;
60735
60733
  this.settled = idle;
60736
60734
  this.dirty = false;
60737
- activity = parseDisplayMessages(this.events, this.provider).map((message) => describeActivity(message, idle)).findLast(Boolean) ?? null;
60735
+ const latestReasoning = this.provider === "codex" ? this.events.findLast((event2) => codexItemFromEvent(event2)?.item.type === "reasoning") : void 0;
60736
+ const events = latestReasoning ? this.events.filter((event2) => event2 === latestReasoning || codexItemFromEvent(event2)?.item.type !== "reasoning") : this.events;
60737
+ activity = parseDisplayMessages(events, this.provider).map((message) => describeActivity(message, idle)).findLast(Boolean) ?? null;
60738
60738
  if (!activity || JSON.stringify(activity) === this.sent) return true;
60739
60739
  }
60740
60740
  this.attempted = true;
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-X6SC3YRN.js";
6
+ } from "./chunk-3OBN7KPB.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-MD2DJUY2.js";
12
+ } from "./chunk-OPJ5KAGY.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -9,7 +9,7 @@ import {
9
9
  spawnSubagentRequestSchema,
10
10
  subagentResponseSchema,
11
11
  waitSubagentRequestSchema
12
- } from "./chunk-MD2DJUY2.js";
12
+ } from "./chunk-OPJ5KAGY.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1035",
3
+ "version": "0.1.1036",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",