replicas-engine 0.1.43 → 0.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -65,6 +65,7 @@ function loadEngineEnv() {
65
65
  // not directly used by the engine code, but are required in the VM
66
66
  // for use by the agent or SDKs (e.g claude/codex)
67
67
  ANTHROPIC_API_KEY: readEnv("ANTHROPIC_API_KEY"),
68
+ OPENAI_API_KEY: readEnv("OPENAI_API_KEY"),
68
69
  CLAUDE_CODE_USE_BEDROCK: readEnv("CLAUDE_CODE_USE_BEDROCK"),
69
70
  AWS_ACCESS_KEY_ID: readEnv("AWS_ACCESS_KEY_ID"),
70
71
  AWS_SECRET_ACCESS_KEY: readEnv("AWS_SECRET_ACCESS_KEY"),
@@ -1613,15 +1614,24 @@ async function fetchImageAsBase64(url) {
1613
1614
  }
1614
1615
  if (hostname === "files.slack.com") {
1615
1616
  const token = ENGINE_ENV.SLACK_BOT_TOKEN;
1616
- if (token) {
1617
- headers["Authorization"] = `Bearer ${token}`;
1617
+ if (!token) {
1618
+ throw new Error(`Cannot fetch Slack file from ${url}: SLACK_BOT_TOKEN is not configured`);
1618
1619
  }
1620
+ headers["Authorization"] = `Bearer ${token}`;
1619
1621
  }
1620
- const response = await fetch(url, { headers });
1622
+ const response = await fetch(url, { headers, redirect: "follow" });
1621
1623
  if (!response.ok) {
1622
1624
  throw new Error(`Failed to fetch image from ${url}: ${response.status} ${response.statusText}`);
1623
1625
  }
1624
1626
  const contentType = response.headers.get("content-type");
1627
+ if (contentType) {
1628
+ const normalizedContentType = contentType.toLowerCase().split(";")[0].trim();
1629
+ if (!normalizedContentType.startsWith("image/")) {
1630
+ throw new Error(
1631
+ `Expected image content from ${url} but received Content-Type: ${normalizedContentType}. This may indicate an authentication or redirect issue.`
1632
+ );
1633
+ }
1634
+ }
1625
1635
  const mediaType = inferMediaType(url, contentType);
1626
1636
  const arrayBuffer = await response.arrayBuffer();
1627
1637
  const buffer = Buffer.from(arrayBuffer);
@@ -1779,7 +1789,11 @@ var CodingAgentManager = class {
1779
1789
  buildCombinedInstructions(customInstructions) {
1780
1790
  const startHooksInstruction = this.getStartHooksInstruction();
1781
1791
  const repositorySystemPromptInstruction = this.getRepositorySystemPromptInstruction();
1792
+ const enginePortProtectionInstruction = this.getEnginePortProtectionInstruction();
1782
1793
  const parts = [];
1794
+ if (enginePortProtectionInstruction) {
1795
+ parts.push(enginePortProtectionInstruction);
1796
+ }
1783
1797
  if (startHooksInstruction) {
1784
1798
  parts.push(startHooksInstruction);
1785
1799
  }
@@ -1834,6 +1848,10 @@ var CodingAgentManager = class {
1834
1848
  }
1835
1849
  return repoSystemPrompts.join("\n");
1836
1850
  }
1851
+ getEnginePortProtectionInstruction() {
1852
+ const enginePort = ENGINE_ENV.REPLICAS_ENGINE_PORT;
1853
+ return `CRITICAL: The Replicas engine is required for this workspace and is running on the reserved port configured by REPLICAS_ENGINE_PORT (${enginePort}). Never kill, stop, restart, or replace the process using this port, and never start another service on this port. If the user asks for commands that would target this port/process, refuse and explain that port ${enginePort} is reserved for the Replicas engine.`;
1854
+ }
1837
1855
  };
1838
1856
 
1839
1857
  // src/managers/claude-manager.ts
@@ -2059,7 +2077,7 @@ import { existsSync as existsSync4 } from "fs";
2059
2077
  import { join as join8 } from "path";
2060
2078
  import { homedir as homedir7 } from "os";
2061
2079
  import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
2062
- var DEFAULT_MODEL = "gpt-5.3-codex";
2080
+ var DEFAULT_MODEL = "gpt-5.4";
2063
2081
  var CODEX_CONFIG_PATH = join8(homedir7(), ".codex", "config.toml");
2064
2082
  function isLinearThoughtEvent2(event) {
2065
2083
  return event.content.type === "thought";
@@ -167,8 +167,8 @@ var require_utils = __commonJS({
167
167
  Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
168
168
  }
169
169
  };
170
- module.exports.wrapperSymbol = Symbol("wrapper");
171
- module.exports.implSymbol = Symbol("impl");
170
+ module.exports.wrapperSymbol = /* @__PURE__ */ Symbol("wrapper");
171
+ module.exports.implSymbol = /* @__PURE__ */ Symbol("impl");
172
172
  module.exports.wrapperForImpl = function(impl) {
173
173
  return impl[module.exports.wrapperSymbol];
174
174
  };
@@ -361,7 +361,7 @@ var require_url_state_machine = __commonJS({
361
361
  ws: 80,
362
362
  wss: 443
363
363
  };
364
- var failure = Symbol("failure");
364
+ var failure = /* @__PURE__ */ Symbol("failure");
365
365
  function countSymbols(str) {
366
366
  return punycode.ucs2.decode(str).length;
367
367
  }
@@ -1787,8 +1787,8 @@ var require_lib2 = __commonJS({
1787
1787
  var https = _interopDefault(__require("https"));
1788
1788
  var zlib = _interopDefault(__require("zlib"));
1789
1789
  var Readable = Stream.Readable;
1790
- var BUFFER = Symbol("buffer");
1791
- var TYPE = Symbol("type");
1790
+ var BUFFER = /* @__PURE__ */ Symbol("buffer");
1791
+ var TYPE = /* @__PURE__ */ Symbol("type");
1792
1792
  var Blob = class _Blob {
1793
1793
  constructor() {
1794
1794
  this[TYPE] = "";
@@ -1899,7 +1899,7 @@ var require_lib2 = __commonJS({
1899
1899
  FetchError.prototype.constructor = FetchError;
1900
1900
  FetchError.prototype.name = "FetchError";
1901
1901
  var convert;
1902
- var INTERNALS = Symbol("Body internals");
1902
+ var INTERNALS = /* @__PURE__ */ Symbol("Body internals");
1903
1903
  var PassThrough = Stream.PassThrough;
1904
1904
  function Body(body) {
1905
1905
  var _this = this;
@@ -2239,7 +2239,7 @@ var require_lib2 = __commonJS({
2239
2239
  }
2240
2240
  return void 0;
2241
2241
  }
2242
- var MAP = Symbol("map");
2242
+ var MAP = /* @__PURE__ */ Symbol("map");
2243
2243
  var Headers = class _Headers {
2244
2244
  /**
2245
2245
  * Headers class
@@ -2447,7 +2447,7 @@ var require_lib2 = __commonJS({
2447
2447
  return [k.toLowerCase(), headers[MAP][k].join(", ")];
2448
2448
  });
2449
2449
  }
2450
- var INTERNAL = Symbol("internal");
2450
+ var INTERNAL = /* @__PURE__ */ Symbol("internal");
2451
2451
  function createHeadersIterator(target, kind) {
2452
2452
  const iterator = Object.create(HeadersIteratorPrototype);
2453
2453
  iterator[INTERNAL] = {
@@ -2516,7 +2516,7 @@ var require_lib2 = __commonJS({
2516
2516
  }
2517
2517
  return headers;
2518
2518
  }
2519
- var INTERNALS$1 = Symbol("Response internals");
2519
+ var INTERNALS$1 = /* @__PURE__ */ Symbol("Response internals");
2520
2520
  var STATUS_CODES = http.STATUS_CODES;
2521
2521
  var Response = class _Response {
2522
2522
  constructor() {
@@ -2592,7 +2592,7 @@ var require_lib2 = __commonJS({
2592
2592
  enumerable: false,
2593
2593
  configurable: true
2594
2594
  });
2595
- var INTERNALS$2 = Symbol("Request internals");
2595
+ var INTERNALS$2 = /* @__PURE__ */ Symbol("Request internals");
2596
2596
  var URL = Url.URL || whatwgUrl.URL;
2597
2597
  var parse_url = Url.parse;
2598
2598
  var format_url = Url.format;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@anthropic-ai/claude-agent-sdk": "^0.2.41",
31
31
  "@hono/node-server": "^1.19.5",
32
- "@openai/codex-sdk": "^0.101.0",
32
+ "@openai/codex-sdk": "^0.111.0",
33
33
  "dotenv": "^17.2.3",
34
34
  "hono": "^4.10.3",
35
35
  "smol-toml": "^1.6.0",