@exulu/backend 5.2.0 → 5.3.0
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/{chunk-ASF74XFZ.js → chunk-PU3LGCBR.js} +17 -2
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-MFLZQONB.js → convert-exulu-tools-to-ai-sdk-tools-77FLVHEA.js} +1 -1
- package/dist/index.cjs +52 -25
- package/dist/index.js +31 -19
- package/ee/invoke-skills/create-sandbox.ts +18 -1
- package/ee/python/requirements.txt +3 -0
- package/ee/workers.ts +13 -0
- package/package.json +1 -1
|
@@ -1723,7 +1723,7 @@ var ExuluTool = class _ExuluTool {
|
|
|
1723
1723
|
if (!agent) {
|
|
1724
1724
|
throw new Error("Agent not found.");
|
|
1725
1725
|
}
|
|
1726
|
-
const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-
|
|
1726
|
+
const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-77FLVHEA.js");
|
|
1727
1727
|
const tools = await convertExuluToolsToAiSdkTools2(
|
|
1728
1728
|
[this],
|
|
1729
1729
|
[],
|
|
@@ -13098,6 +13098,16 @@ var getAllExuluVariables = async () => {
|
|
|
13098
13098
|
return { granted, withheldNames: deriveWithheldNames(rows, granted) };
|
|
13099
13099
|
};
|
|
13100
13100
|
var execAsync2 = promisify2(exec2);
|
|
13101
|
+
var backendSecretFiles = () => {
|
|
13102
|
+
const cwd = process.cwd();
|
|
13103
|
+
const names = [".env", ".env.local", ".env.production", ".env.production.local"];
|
|
13104
|
+
const paths = /* @__PURE__ */ new Set();
|
|
13105
|
+
for (const name of names) {
|
|
13106
|
+
paths.add(join2(cwd, name));
|
|
13107
|
+
paths.add(join2("/app", name));
|
|
13108
|
+
}
|
|
13109
|
+
return [...paths];
|
|
13110
|
+
};
|
|
13101
13111
|
var EXEC_MAX_BUFFER = 32 * 1024 * 1024;
|
|
13102
13112
|
var litellmSecretNamesCache;
|
|
13103
13113
|
var litellmConfigSecretNames = () => {
|
|
@@ -13354,7 +13364,12 @@ Probe error: ${probe.reason ?? "(no detail)"}`
|
|
|
13354
13364
|
// todo
|
|
13355
13365
|
},
|
|
13356
13366
|
filesystem: {
|
|
13357
|
-
|
|
13367
|
+
// The backend's own dotenv file sits under the process cwd (and
|
|
13368
|
+
// /app in the shipped image); a bash command could otherwise
|
|
13369
|
+
// `cat` the database password out of it (seen in an ALGI session
|
|
13370
|
+
// 2026-10-07). Deny it explicitly — the rest of the tree stays
|
|
13371
|
+
// readable for node_modules / skill assets.
|
|
13372
|
+
denyRead: ["~", ...backendSecretFiles()],
|
|
13358
13373
|
allowRead: [
|
|
13359
13374
|
sessionDir,
|
|
13360
13375
|
// Allow Node to read globally-installed packages from inside
|
package/dist/index.cjs
CHANGED
|
@@ -11589,7 +11589,12 @@ Probe error: ${probe.reason ?? "(no detail)"}`
|
|
|
11589
11589
|
// todo
|
|
11590
11590
|
},
|
|
11591
11591
|
filesystem: {
|
|
11592
|
-
|
|
11592
|
+
// The backend's own dotenv file sits under the process cwd (and
|
|
11593
|
+
// /app in the shipped image); a bash command could otherwise
|
|
11594
|
+
// `cat` the database password out of it (seen in an ALGI session
|
|
11595
|
+
// 2026-10-07). Deny it explicitly — the rest of the tree stays
|
|
11596
|
+
// readable for node_modules / skill assets.
|
|
11597
|
+
denyRead: ["~", ...backendSecretFiles()],
|
|
11593
11598
|
allowRead: [
|
|
11594
11599
|
sessionDir,
|
|
11595
11600
|
// Allow Node to read globally-installed packages from inside
|
|
@@ -11912,7 +11917,7 @@ ${lines.join("\n")}`;
|
|
|
11912
11917
|
sandboxCache.set(sessionId, { handle, installedSkills });
|
|
11913
11918
|
return handle;
|
|
11914
11919
|
}
|
|
11915
|
-
var import_sandbox_runtime, import_promises2, import_node_fs6, import_node_path5, import_node_child_process4, import_node_util3, import_bash_tool, import_ai2, import_zod6, import_crypto_js3, getAllExuluVariables, execAsync3, EXEC_MAX_BUFFER, litellmSecretNamesCache, litellmConfigSecretNames, sandboxProbePromise, SANDBOX_FALLBACK_INSTRUCTIONS, degradedModeLogged, sandboxCache;
|
|
11920
|
+
var import_sandbox_runtime, import_promises2, import_node_fs6, import_node_path5, import_node_child_process4, import_node_util3, import_bash_tool, import_ai2, import_zod6, import_crypto_js3, getAllExuluVariables, execAsync3, backendSecretFiles, EXEC_MAX_BUFFER, litellmSecretNamesCache, litellmConfigSecretNames, sandboxProbePromise, SANDBOX_FALLBACK_INSTRUCTIONS, degradedModeLogged, sandboxCache;
|
|
11916
11921
|
var init_create_sandbox = __esm({
|
|
11917
11922
|
"ee/invoke-skills/create-sandbox.ts"() {
|
|
11918
11923
|
"use strict";
|
|
@@ -11961,6 +11966,16 @@ var init_create_sandbox = __esm({
|
|
|
11961
11966
|
return { granted, withheldNames: deriveWithheldNames(rows, granted) };
|
|
11962
11967
|
};
|
|
11963
11968
|
execAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.exec);
|
|
11969
|
+
backendSecretFiles = () => {
|
|
11970
|
+
const cwd = process.cwd();
|
|
11971
|
+
const names = [".env", ".env.local", ".env.production", ".env.production.local"];
|
|
11972
|
+
const paths = /* @__PURE__ */ new Set();
|
|
11973
|
+
for (const name of names) {
|
|
11974
|
+
paths.add((0, import_node_path5.join)(cwd, name));
|
|
11975
|
+
paths.add((0, import_node_path5.join)("/app", name));
|
|
11976
|
+
}
|
|
11977
|
+
return [...paths];
|
|
11978
|
+
};
|
|
11964
11979
|
EXEC_MAX_BUFFER = 32 * 1024 * 1024;
|
|
11965
11980
|
litellmConfigSecretNames = () => {
|
|
11966
11981
|
if (litellmSecretNamesCache === void 0) {
|
|
@@ -21448,6 +21463,27 @@ init_storage();
|
|
|
21448
21463
|
init_context();
|
|
21449
21464
|
init_hydrate_embedders();
|
|
21450
21465
|
init_resolve_model();
|
|
21466
|
+
|
|
21467
|
+
// src/exulu/resolve-context-window.ts
|
|
21468
|
+
init_cjs_shims();
|
|
21469
|
+
init_catalog();
|
|
21470
|
+
init_context_budget();
|
|
21471
|
+
var resolveContextWindow = async ({
|
|
21472
|
+
modelId
|
|
21473
|
+
}) => {
|
|
21474
|
+
if (process.env.EXULU_USE_LITELLM !== "true") {
|
|
21475
|
+
throw new Error("Litellm not configured.");
|
|
21476
|
+
}
|
|
21477
|
+
const entry = await findLiteLLMModel(modelId);
|
|
21478
|
+
const fromCatalog = entry?.max_input_tokens ?? entry?.max_tokens;
|
|
21479
|
+
if (fromCatalog != null && fromCatalog > 0) return fromCatalog;
|
|
21480
|
+
console.warn(
|
|
21481
|
+
`[EXULU] Unknown context window for model "${modelId}" \u2014 assuming ${DEFAULT_CONTEXT_WINDOW}. Check the LiteLLM catalog / provider template metadata.`
|
|
21482
|
+
);
|
|
21483
|
+
return DEFAULT_CONTEXT_WINDOW;
|
|
21484
|
+
};
|
|
21485
|
+
|
|
21486
|
+
// ee/workers.ts
|
|
21451
21487
|
init_client();
|
|
21452
21488
|
init_prune_job_results();
|
|
21453
21489
|
var import_api = require("@opentelemetry/api");
|
|
@@ -21737,7 +21773,12 @@ var workflowRunLabel = (workflowId) => `workflow-run-${workflowId}`;
|
|
|
21737
21773
|
var baseTriggerMetadata = (email) => ({
|
|
21738
21774
|
from: email.from.address,
|
|
21739
21775
|
subject: email.subject,
|
|
21740
|
-
message_id: email.messageId
|
|
21776
|
+
message_id: email.messageId,
|
|
21777
|
+
attachments: email.attachments.map((attachment) => ({
|
|
21778
|
+
filename: attachment.filename,
|
|
21779
|
+
content_type: attachment.contentType,
|
|
21780
|
+
size: attachment.content?.length ?? 0
|
|
21781
|
+
}))
|
|
21741
21782
|
});
|
|
21742
21783
|
var resolveTriggerBySecret = async (db2, secret) => db2.from("workflow_triggers").where({ secret }).first();
|
|
21743
21784
|
var resolveTriggerById = async (db2, triggerId) => db2.from("workflow_triggers").where({ id: triggerId }).first();
|
|
@@ -23099,6 +23140,12 @@ var processUiMessagesFlow = async ({
|
|
|
23099
23140
|
routine
|
|
23100
23141
|
});
|
|
23101
23142
|
const resolvedLanguageModel = resolved.languageModel;
|
|
23143
|
+
let contextWindow;
|
|
23144
|
+
try {
|
|
23145
|
+
contextWindow = await resolveContextWindow({ modelId: resolved.model.id });
|
|
23146
|
+
} catch (err2) {
|
|
23147
|
+
console.warn(`[EXULU] Could not resolve the context window for routine model "${resolved.model.id}"; using the default.`, err2);
|
|
23148
|
+
}
|
|
23102
23149
|
const messagesWithoutPlaceholder = inputMessages.filter(
|
|
23103
23150
|
(message) => message.metadata?.type !== "placeholder"
|
|
23104
23151
|
);
|
|
@@ -23162,7 +23209,8 @@ var processUiMessagesFlow = async ({
|
|
|
23162
23209
|
allExuluTools: tools,
|
|
23163
23210
|
languageModel: resolvedLanguageModel,
|
|
23164
23211
|
toolConfigs: agent.tools,
|
|
23165
|
-
exuluConfig: config
|
|
23212
|
+
exuluConfig: config,
|
|
23213
|
+
contextWindow
|
|
23166
23214
|
});
|
|
23167
23215
|
console.log("[EXULU] consuming stream for agent.");
|
|
23168
23216
|
const stream = result.stream.toUIMessageStream({
|
|
@@ -29134,27 +29182,6 @@ ${SUGGESTIONS_SYSTEM_PROMPT}` : SUGGESTIONS_SYSTEM_PROMPT;
|
|
|
29134
29182
|
// src/exulu/routes.ts
|
|
29135
29183
|
init_resolve_model();
|
|
29136
29184
|
init_supervisor();
|
|
29137
|
-
|
|
29138
|
-
// src/exulu/resolve-context-window.ts
|
|
29139
|
-
init_cjs_shims();
|
|
29140
|
-
init_catalog();
|
|
29141
|
-
init_context_budget();
|
|
29142
|
-
var resolveContextWindow = async ({
|
|
29143
|
-
modelId
|
|
29144
|
-
}) => {
|
|
29145
|
-
if (process.env.EXULU_USE_LITELLM !== "true") {
|
|
29146
|
-
throw new Error("Litellm not configured.");
|
|
29147
|
-
}
|
|
29148
|
-
const entry = await findLiteLLMModel(modelId);
|
|
29149
|
-
const fromCatalog = entry?.max_input_tokens ?? entry?.max_tokens;
|
|
29150
|
-
if (fromCatalog != null && fromCatalog > 0) return fromCatalog;
|
|
29151
|
-
console.warn(
|
|
29152
|
-
`[EXULU] Unknown context window for model "${modelId}" \u2014 assuming ${DEFAULT_CONTEXT_WINDOW}. Check the LiteLLM catalog / provider template metadata.`
|
|
29153
|
-
);
|
|
29154
|
-
return DEFAULT_CONTEXT_WINDOW;
|
|
29155
|
-
};
|
|
29156
|
-
|
|
29157
|
-
// src/exulu/routes.ts
|
|
29158
29185
|
init_context_budget();
|
|
29159
29186
|
|
|
29160
29187
|
// src/exulu/compact-session.ts
|
package/dist/index.js
CHANGED
|
@@ -193,7 +193,7 @@ import {
|
|
|
193
193
|
willEmbedOnQueue,
|
|
194
194
|
withRetry,
|
|
195
195
|
workflowTemplatesSchema
|
|
196
|
-
} from "./chunk-
|
|
196
|
+
} from "./chunk-PU3LGCBR.js";
|
|
197
197
|
import {
|
|
198
198
|
LiteLLMAdminError,
|
|
199
199
|
findLiteLLMModel,
|
|
@@ -4885,6 +4885,22 @@ var getEnabledTools = async (agent, allExuluTools, allContexts, disabledTools =
|
|
|
4885
4885
|
return enabledTools;
|
|
4886
4886
|
};
|
|
4887
4887
|
|
|
4888
|
+
// src/exulu/resolve-context-window.ts
|
|
4889
|
+
var resolveContextWindow = async ({
|
|
4890
|
+
modelId
|
|
4891
|
+
}) => {
|
|
4892
|
+
if (process.env.EXULU_USE_LITELLM !== "true") {
|
|
4893
|
+
throw new Error("Litellm not configured.");
|
|
4894
|
+
}
|
|
4895
|
+
const entry = await findLiteLLMModel(modelId);
|
|
4896
|
+
const fromCatalog = entry?.max_input_tokens ?? entry?.max_tokens;
|
|
4897
|
+
if (fromCatalog != null && fromCatalog > 0) return fromCatalog;
|
|
4898
|
+
console.warn(
|
|
4899
|
+
`[EXULU] Unknown context window for model "${modelId}" \u2014 assuming ${DEFAULT_CONTEXT_WINDOW}. Check the LiteLLM catalog / provider template metadata.`
|
|
4900
|
+
);
|
|
4901
|
+
return DEFAULT_CONTEXT_WINDOW;
|
|
4902
|
+
};
|
|
4903
|
+
|
|
4888
4904
|
// ee/workers.ts
|
|
4889
4905
|
import "@opentelemetry/api";
|
|
4890
4906
|
import { v4 as uuidv42 } from "uuid";
|
|
@@ -5158,7 +5174,12 @@ var workflowRunLabel = (workflowId) => `workflow-run-${workflowId}`;
|
|
|
5158
5174
|
var baseTriggerMetadata = (email) => ({
|
|
5159
5175
|
from: email.from.address,
|
|
5160
5176
|
subject: email.subject,
|
|
5161
|
-
message_id: email.messageId
|
|
5177
|
+
message_id: email.messageId,
|
|
5178
|
+
attachments: email.attachments.map((attachment) => ({
|
|
5179
|
+
filename: attachment.filename,
|
|
5180
|
+
content_type: attachment.contentType,
|
|
5181
|
+
size: attachment.content?.length ?? 0
|
|
5182
|
+
}))
|
|
5162
5183
|
});
|
|
5163
5184
|
var resolveTriggerBySecret = async (db, secret) => db.from("workflow_triggers").where({ secret }).first();
|
|
5164
5185
|
var resolveTriggerById = async (db, triggerId) => db.from("workflow_triggers").where({ id: triggerId }).first();
|
|
@@ -6515,6 +6536,12 @@ var processUiMessagesFlow = async ({
|
|
|
6515
6536
|
routine
|
|
6516
6537
|
});
|
|
6517
6538
|
const resolvedLanguageModel = resolved.languageModel;
|
|
6539
|
+
let contextWindow;
|
|
6540
|
+
try {
|
|
6541
|
+
contextWindow = await resolveContextWindow({ modelId: resolved.model.id });
|
|
6542
|
+
} catch (err) {
|
|
6543
|
+
console.warn(`[EXULU] Could not resolve the context window for routine model "${resolved.model.id}"; using the default.`, err);
|
|
6544
|
+
}
|
|
6518
6545
|
const messagesWithoutPlaceholder = inputMessages.filter(
|
|
6519
6546
|
(message) => message.metadata?.type !== "placeholder"
|
|
6520
6547
|
);
|
|
@@ -6578,7 +6605,8 @@ var processUiMessagesFlow = async ({
|
|
|
6578
6605
|
allExuluTools: tools,
|
|
6579
6606
|
languageModel: resolvedLanguageModel,
|
|
6580
6607
|
toolConfigs: agent.tools,
|
|
6581
|
-
exuluConfig: config
|
|
6608
|
+
exuluConfig: config,
|
|
6609
|
+
contextWindow
|
|
6582
6610
|
});
|
|
6583
6611
|
console.log("[EXULU] consuming stream for agent.");
|
|
6584
6612
|
const stream = result.stream.toUIMessageStream({
|
|
@@ -12453,22 +12481,6 @@ ${SUGGESTIONS_SYSTEM_PROMPT}` : SUGGESTIONS_SYSTEM_PROMPT;
|
|
|
12453
12481
|
};
|
|
12454
12482
|
};
|
|
12455
12483
|
|
|
12456
|
-
// src/exulu/resolve-context-window.ts
|
|
12457
|
-
var resolveContextWindow = async ({
|
|
12458
|
-
modelId
|
|
12459
|
-
}) => {
|
|
12460
|
-
if (process.env.EXULU_USE_LITELLM !== "true") {
|
|
12461
|
-
throw new Error("Litellm not configured.");
|
|
12462
|
-
}
|
|
12463
|
-
const entry = await findLiteLLMModel(modelId);
|
|
12464
|
-
const fromCatalog = entry?.max_input_tokens ?? entry?.max_tokens;
|
|
12465
|
-
if (fromCatalog != null && fromCatalog > 0) return fromCatalog;
|
|
12466
|
-
console.warn(
|
|
12467
|
-
`[EXULU] Unknown context window for model "${modelId}" \u2014 assuming ${DEFAULT_CONTEXT_WINDOW}. Check the LiteLLM catalog / provider template metadata.`
|
|
12468
|
-
);
|
|
12469
|
-
return DEFAULT_CONTEXT_WINDOW;
|
|
12470
|
-
};
|
|
12471
|
-
|
|
12472
12484
|
// src/exulu/compact-session.ts
|
|
12473
12485
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
12474
12486
|
import { generateText as generateText6, validateUIMessages as validateUIMessages2 } from "ai";
|
|
@@ -78,6 +78,18 @@ const getAllExuluVariables = async (): Promise<{
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const execAsync = promisify(exec);
|
|
81
|
+
|
|
82
|
+
/** Dotenv files of the running backend that a sandboxed command must not read. */
|
|
83
|
+
export const backendSecretFiles = (): string[] => {
|
|
84
|
+
const cwd = process.cwd();
|
|
85
|
+
const names = ['.env', '.env.local', '.env.production', '.env.production.local'];
|
|
86
|
+
const paths = new Set<string>();
|
|
87
|
+
for (const name of names) {
|
|
88
|
+
paths.add(join(cwd, name));
|
|
89
|
+
paths.add(join('/app', name));
|
|
90
|
+
}
|
|
91
|
+
return [...paths];
|
|
92
|
+
};
|
|
81
93
|
// Sandbox commands can be very long (long deny lists) — bump default buffer.
|
|
82
94
|
const EXEC_MAX_BUFFER = 32 * 1024 * 1024;
|
|
83
95
|
|
|
@@ -595,7 +607,12 @@ export async function createSessionSandbox(
|
|
|
595
607
|
deniedDomains: [], // todo
|
|
596
608
|
},
|
|
597
609
|
filesystem: {
|
|
598
|
-
|
|
610
|
+
// The backend's own dotenv file sits under the process cwd (and
|
|
611
|
+
// /app in the shipped image); a bash command could otherwise
|
|
612
|
+
// `cat` the database password out of it (seen in an ALGI session
|
|
613
|
+
// 2026-10-07). Deny it explicitly — the rest of the tree stays
|
|
614
|
+
// readable for node_modules / skill assets.
|
|
615
|
+
denyRead: ['~', ...backendSecretFiles()],
|
|
599
616
|
allowRead: [
|
|
600
617
|
sessionDir,
|
|
601
618
|
// Allow Node to read globally-installed packages from inside
|
|
@@ -67,3 +67,6 @@ google-cloud-aiplatform>=1.38
|
|
|
67
67
|
python-docx>=1.1
|
|
68
68
|
python-pptx>=1.0
|
|
69
69
|
openpyxl>=3.1
|
|
70
|
+
# Legacy .xls (BIFF) workbooks: pandas.read_excel / xlrd — parse_document converts them via
|
|
71
|
+
# LibreOffice, but skill scripts that open the file themselves need this (ALGI feedback 2026-09-17).
|
|
72
|
+
xlrd>=2.0
|
package/ee/workers.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { refreshContextEmbeddersIfStale } from "@SRC/exulu/hydrate-embedders";
|
|
|
14
14
|
import type { ExuluEval } from "@SRC/exulu/evals.ts";
|
|
15
15
|
import type { ExuluTool } from "@SRC/exulu/tool.ts";
|
|
16
16
|
import { resolveModel } from "@SRC/exulu/resolve-model.ts";
|
|
17
|
+
import { resolveContextWindow } from "@SRC/exulu/resolve-context-window.ts";
|
|
17
18
|
import { postgresClient } from "@SRC/postgres/client";
|
|
18
19
|
import type { BullMqJobData } from "@EE/queues/decorator.ts";
|
|
19
20
|
import { maybePruneJobResults } from "@EE/queues/prune-job-results.ts";
|
|
@@ -1600,6 +1601,17 @@ export const processUiMessagesFlow = async ({
|
|
|
1600
1601
|
|
|
1601
1602
|
const resolvedLanguageModel = resolved.languageModel;
|
|
1602
1603
|
|
|
1604
|
+
// Routine runs used to omit the context window, so generateStream fell back
|
|
1605
|
+
// to the 128k default and a Gemini run with ~500k tokens of tool results was
|
|
1606
|
+
// rejected with CONTEXT_COMPACTION_REQUIRED ("of 102,400 usable tokens")
|
|
1607
|
+
// although the model takes 1M. Resolve it like the chat route does.
|
|
1608
|
+
let contextWindow: number | undefined;
|
|
1609
|
+
try {
|
|
1610
|
+
contextWindow = await resolveContextWindow({ modelId: resolved.model.id });
|
|
1611
|
+
} catch (err) {
|
|
1612
|
+
console.warn(`[EXULU] Could not resolve the context window for routine model "${resolved.model.id}"; using the default.`, err);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1603
1615
|
// Remove placeholder agent response before sending
|
|
1604
1616
|
const messagesWithoutPlaceholder = inputMessages.filter(
|
|
1605
1617
|
(message) => (message.metadata as any)?.type !== "placeholder",
|
|
@@ -1712,6 +1724,7 @@ export const processUiMessagesFlow = async ({
|
|
|
1712
1724
|
languageModel: resolvedLanguageModel,
|
|
1713
1725
|
toolConfigs: agent.tools,
|
|
1714
1726
|
exuluConfig: config,
|
|
1727
|
+
contextWindow,
|
|
1715
1728
|
});
|
|
1716
1729
|
|
|
1717
1730
|
console.log("[EXULU] consuming stream for agent.");
|