@ethosagent/core 0.4.1 → 0.4.2

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 CHANGED
@@ -321,6 +321,7 @@ function defaultAlwaysDeny() {
321
321
  import { readFileSync } from "fs";
322
322
  var ENV_TO_REF = {
323
323
  ANTHROPIC_API_KEY: "providers/anthropic/apiKey",
324
+ AZURE_API_KEY: "providers/azure/apiKey",
324
325
  OPENAI_API_KEY: "providers/openai/apiKey",
325
326
  OPENROUTER_API_KEY: "providers/openrouter/apiKey",
326
327
  GEMINI_API_KEY: "providers/gemini/apiKey",
@@ -1582,6 +1583,7 @@ function validateRegistration(tool, personality) {
1582
1583
 
1583
1584
  // src/tool-registry.ts
1584
1585
  function needsBackends(caps) {
1586
+ if (!caps) return false;
1585
1587
  return !!(caps.network || caps.secrets || caps.storage || caps.fs_reach || caps.process || caps.attachments);
1586
1588
  }
1587
1589
  function mcpServerName(toolName) {
@@ -2038,7 +2040,8 @@ var AgentLoop = class {
2038
2040
  const allowedPlugins = personality.plugins ?? [];
2039
2041
  const mcpServers = this.mcpPolicy?.servers;
2040
2042
  const allowedMcpTools = mcpServers ? Object.fromEntries(
2041
- Object.entries(mcpServers).filter(([, v]) => v.tools !== void 0).map(([k, v]) => {
2043
+ Object.entries(mcpServers).filter(([, v]) => v.tools !== void 0 || v.enabled === false).map(([k, v]) => {
2044
+ if (v.enabled === false) return [k, []];
2042
2045
  const tools = v.tools;
2043
2046
  return [k, tools ?? []];
2044
2047
  })
@@ -2600,6 +2603,30 @@ ${rendered.slice(-MEMORY_MAX_CHARS)}`;
2600
2603
  continue;
2601
2604
  }
2602
2605
  const effectiveArgs = beforeResult.args ?? tc.args;
2606
+ const enabledError = checkMcpEnabled(this.mcpPolicy, tc.toolName);
2607
+ if (enabledError) {
2608
+ this.observability?.recordSafetyBlock({
2609
+ traceId,
2610
+ code: "tool_blocked",
2611
+ cause: enabledError
2612
+ });
2613
+ observe({ type: "tool_end", toolName: tc.toolName, ok: false });
2614
+ yield {
2615
+ type: "tool_end",
2616
+ toolCallId: tc.toolCallId,
2617
+ toolName: tc.toolName,
2618
+ ok: false,
2619
+ durationMs: 0,
2620
+ result: enabledError
2621
+ };
2622
+ prepped.push({
2623
+ toolCallId: tc.toolCallId,
2624
+ name: tc.toolName,
2625
+ args: effectiveArgs,
2626
+ rejected: enabledError
2627
+ });
2628
+ continue;
2629
+ }
2603
2630
  const rejectError = checkMcpRejectArgs(this.mcpPolicy, tc.toolName, effectiveArgs);
2604
2631
  if (rejectError) {
2605
2632
  this.observability?.recordSafetyBlock({
@@ -3152,6 +3179,18 @@ function checkMcpRejectArgs(mcpPolicy, toolName, args) {
3152
3179
  }
3153
3180
  return void 0;
3154
3181
  }
3182
+ function checkMcpEnabled(mcpPolicy, toolName) {
3183
+ const servers = mcpPolicy?.servers;
3184
+ if (!servers || !toolName.startsWith("mcp__")) return void 0;
3185
+ const firstSep = toolName.indexOf("__");
3186
+ const secondSep = toolName.indexOf("__", firstSep + 2);
3187
+ if (secondSep === -1) return void 0;
3188
+ const server = toolName.slice(firstSep + 2, secondSep);
3189
+ if (servers[server]?.enabled === false) {
3190
+ return `MCP policy: server '${server}' is disabled for this personality`;
3191
+ }
3192
+ return void 0;
3193
+ }
3155
3194
  function describeSource(toolName, args) {
3156
3195
  if (!args || typeof args !== "object") return void 0;
3157
3196
  const a = args;