replicas-engine 0.1.43 → 0.1.44
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 +13 -3
- package/package.json +1 -1
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
|
-
|
|
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);
|