elsium-ai 0.4.0 → 0.4.1
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/index.js +31 -6
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -974,6 +974,9 @@ function createShutdownManager(config) {
|
|
|
974
974
|
// ../gateway/src/provider.ts
|
|
975
975
|
var providerRegistry = new Map;
|
|
976
976
|
var metadataRegistry = new Map;
|
|
977
|
+
function registerProvider(name, factory) {
|
|
978
|
+
providerRegistry.set(name, factory);
|
|
979
|
+
}
|
|
977
980
|
function getProviderFactory(name) {
|
|
978
981
|
return providerRegistry.get(name);
|
|
979
982
|
}
|
|
@@ -2365,6 +2368,7 @@ registerProviderMetadata("google", {
|
|
|
2365
2368
|
});
|
|
2366
2369
|
function registerProviderFactory(name, factory) {
|
|
2367
2370
|
PROVIDER_FACTORIES[name] = factory;
|
|
2371
|
+
registerProvider(name, factory);
|
|
2368
2372
|
}
|
|
2369
2373
|
function validateGatewayConfig(config) {
|
|
2370
2374
|
const factory = PROVIDER_FACTORIES[config.provider] ?? getProviderFactory(config.provider);
|
|
@@ -2732,6 +2736,7 @@ function redactPatterns(text, patterns) {
|
|
|
2732
2736
|
let redacted = text;
|
|
2733
2737
|
for (const { pattern, detail, replacement } of patterns) {
|
|
2734
2738
|
const regex = new RegExp(pattern.source, pattern.flags);
|
|
2739
|
+
regex.lastIndex = 0;
|
|
2735
2740
|
const result = redacted.replace(regex, replacement);
|
|
2736
2741
|
if (result !== redacted) {
|
|
2737
2742
|
found.push({ type: "secret_detected", detail, severity: "medium" });
|
|
@@ -2763,7 +2768,8 @@ function redactSecrets(text, piiTypes) {
|
|
|
2763
2768
|
}
|
|
2764
2769
|
function checkBlockedPatterns(text, patterns) {
|
|
2765
2770
|
const violations = [];
|
|
2766
|
-
for (const
|
|
2771
|
+
for (const raw of patterns) {
|
|
2772
|
+
const pattern = typeof raw === "string" ? new RegExp(raw, "i") : raw;
|
|
2767
2773
|
pattern.lastIndex = 0;
|
|
2768
2774
|
if (pattern.test(text)) {
|
|
2769
2775
|
violations.push({
|
|
@@ -3413,7 +3419,11 @@ function createProviderMesh(config) {
|
|
|
3413
3419
|
}
|
|
3414
3420
|
// ../tools/src/define.ts
|
|
3415
3421
|
function defineTool(config) {
|
|
3416
|
-
const
|
|
3422
|
+
const input = config.input ?? config.parameters;
|
|
3423
|
+
if (!input) {
|
|
3424
|
+
throw ElsiumError.validation(`Tool "${config.name}" requires an input schema (use "input" or "parameters" key)`);
|
|
3425
|
+
}
|
|
3426
|
+
const { name, description, output, handler, timeoutMs = 30000 } = config;
|
|
3417
3427
|
return {
|
|
3418
3428
|
name,
|
|
3419
3429
|
description,
|
|
@@ -8652,7 +8662,22 @@ async function safeHook2(fn) {
|
|
|
8652
8662
|
await fn();
|
|
8653
8663
|
} catch (_) {}
|
|
8654
8664
|
}
|
|
8665
|
+
function resolveDependencies(config, deps) {
|
|
8666
|
+
if (deps)
|
|
8667
|
+
return deps;
|
|
8668
|
+
if (!config.provider || !config.apiKey) {
|
|
8669
|
+
throw ElsiumError.validation("Either provide AgentDependencies as second argument, or set provider and apiKey in config");
|
|
8670
|
+
}
|
|
8671
|
+
const gw = gateway({
|
|
8672
|
+
provider: config.provider,
|
|
8673
|
+
apiKey: config.apiKey,
|
|
8674
|
+
baseUrl: config.baseUrl,
|
|
8675
|
+
model: config.model
|
|
8676
|
+
});
|
|
8677
|
+
return { complete: (req) => gw.complete(req) };
|
|
8678
|
+
}
|
|
8655
8679
|
function defineAgent(config, deps) {
|
|
8680
|
+
const resolvedDeps = resolveDependencies(config, deps);
|
|
8656
8681
|
const memory = createMemory(config.memory ?? { strategy: "sliding-window", maxMessages: 50 });
|
|
8657
8682
|
const toolMap = new Map((config.tools ?? []).map((t) => [t.name, t]));
|
|
8658
8683
|
const guardrails = {
|
|
@@ -8663,7 +8688,7 @@ function defineAgent(config, deps) {
|
|
|
8663
8688
|
semantic: config.guardrails?.semantic,
|
|
8664
8689
|
security: config.guardrails?.security
|
|
8665
8690
|
};
|
|
8666
|
-
const semanticValidator = guardrails.semantic ? createSemanticValidator(guardrails.semantic,
|
|
8691
|
+
const semanticValidator = guardrails.semantic ? createSemanticValidator(guardrails.semantic, resolvedDeps.complete) : null;
|
|
8667
8692
|
const agentSecurity = guardrails.security ? createAgentSecurity(guardrails.security) : null;
|
|
8668
8693
|
const approvalGate = config.guardrails?.approval ? createApprovalGate(config.guardrails.approval) : null;
|
|
8669
8694
|
const confidenceScorer = config.confidence ? createConfidenceScorer(typeof config.confidence === "boolean" ? {} : config.confidence) : null;
|
|
@@ -8805,7 +8830,7 @@ function defineAgent(config, deps) {
|
|
|
8805
8830
|
checkAborted(options);
|
|
8806
8831
|
checkBudget(totalInputTokens, totalOutputTokens);
|
|
8807
8832
|
const request = buildCompletionRequest2(conversationMessages);
|
|
8808
|
-
const response = await
|
|
8833
|
+
const response = await resolvedDeps.complete(request);
|
|
8809
8834
|
totalInputTokens += response.usage.inputTokens;
|
|
8810
8835
|
totalOutputTokens += response.usage.outputTokens;
|
|
8811
8836
|
totalCost += response.cost.totalCost;
|
|
@@ -8884,7 +8909,7 @@ function defineAgent(config, deps) {
|
|
|
8884
8909
|
async run(input, options = {}) {
|
|
8885
8910
|
validateInputText(input);
|
|
8886
8911
|
if (config.states && config.initialState) {
|
|
8887
|
-
return executeStateMachine(config, { states: config.states, initialState: config.initialState },
|
|
8912
|
+
return executeStateMachine(config, { states: config.states, initialState: config.initialState }, resolvedDeps, input, options);
|
|
8888
8913
|
}
|
|
8889
8914
|
const userMessage = { role: "user", content: input };
|
|
8890
8915
|
return executeLoop([userMessage], options);
|
|
@@ -8898,7 +8923,7 @@ function defineAgent(config, deps) {
|
|
|
8898
8923
|
if (config.states && config.initialState) {
|
|
8899
8924
|
const inputText = messages.filter((m) => m.role === "user").map((m) => extractText(m.content)).join(`
|
|
8900
8925
|
`);
|
|
8901
|
-
return executeStateMachine(config, { states: config.states, initialState: config.initialState },
|
|
8926
|
+
return executeStateMachine(config, { states: config.states, initialState: config.initialState }, resolvedDeps, inputText || "", options);
|
|
8902
8927
|
}
|
|
8903
8928
|
return executeLoop(messages, options);
|
|
8904
8929
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elsium-ai",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "ElsiumAI — A high-performance, TypeScript-first AI framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Utrera <ebutrera9103@gmail.com>",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"build": "bun build ./src/index.ts --outdir ./dist --target node && bun x tsc -p tsconfig.build.json --emitDeclarationOnly"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@elsium-ai/core": "^0.4.
|
|
29
|
-
"@elsium-ai/gateway": "^0.4.
|
|
30
|
-
"@elsium-ai/agents": "^0.4.
|
|
31
|
-
"@elsium-ai/tools": "^0.4.
|
|
32
|
-
"@elsium-ai/rag": "^0.4.
|
|
33
|
-
"@elsium-ai/workflows": "^0.4.
|
|
34
|
-
"@elsium-ai/observe": "^0.4.
|
|
35
|
-
"@elsium-ai/app": "^0.4.
|
|
36
|
-
"@elsium-ai/testing": "^0.4.
|
|
37
|
-
"@elsium-ai/mcp": "^0.4.
|
|
38
|
-
"@elsium-ai/client": "^0.4.
|
|
28
|
+
"@elsium-ai/core": "^0.4.1",
|
|
29
|
+
"@elsium-ai/gateway": "^0.4.1",
|
|
30
|
+
"@elsium-ai/agents": "^0.4.1",
|
|
31
|
+
"@elsium-ai/tools": "^0.4.1",
|
|
32
|
+
"@elsium-ai/rag": "^0.4.1",
|
|
33
|
+
"@elsium-ai/workflows": "^0.4.1",
|
|
34
|
+
"@elsium-ai/observe": "^0.4.1",
|
|
35
|
+
"@elsium-ai/app": "^0.4.1",
|
|
36
|
+
"@elsium-ai/testing": "^0.4.1",
|
|
37
|
+
"@elsium-ai/mcp": "^0.4.1",
|
|
38
|
+
"@elsium-ai/client": "^0.4.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^5.7.0"
|