@compilr-dev/sdk 0.24.0 → 0.24.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.d.ts CHANGED
@@ -39,7 +39,7 @@ export { AgentTeam, TeamAgent, SharedContextManager, ArtifactStore, DelegationTr
39
39
  export type { AgentTeamConfig, TeamAgentConfig, TeamAgentUpdate, AgentUpdateResult, ITeamPersistence, IArtifactStorage, ISessionRegistry, CustomAgentDefinition, AgentTemplate, AgentWorkshopData, WorkshopRoleDef, WorkshopToolProfile, WorkshopModelTier, WorkshopSkillDef, PlanSubmitInfo, PlanSubmitResult, PlanModeExitInfo, PlanModeCallbacks, ToolConfig as TeamToolConfig, ToolTier, ToolGroup, ProfileInfo, } from './team/index.js';
40
40
  export type { AgentRole, RoleMetadata, ToolProfile, MascotExpression, BackgroundSessionInfo, SerializedTeam, SerializedTeamAgent, TeamMetadata, TeamEvent, TeamEventType, TeamEventHandler, Artifact, ArtifactType as TeamArtifactType, ArtifactSummary as TeamArtifactSummary, CreateArtifactOptions, UpdateArtifactOptions, SerializedArtifact, SharedContext, SharedProjectInfo, SharedTeamInfo, TeamRosterEntry, TeamActivity, TeamActivityType, SharedDecision, TokenBudget, SerializedSharedContext, ParsedMention, ParsedInput, ResolvedMention, ResolveOptions, ResolutionSource, Delegation, DelegationStatus, DelegationResult, CompletionEvent, CreateDelegationOptions, DelegationStats, DelegationTrackerEvents, HandoffResult, HandoffToolConfig, HandoffIntent, HandoffValidationResult, DelegateResult, DelegateToolConfig, DelegateBackgroundResult, DelegateBackgroundToolConfig, ConsultInput, ConsultResult, ConsultToolConfig, NormalizedRole, SkillToolRequirement, } from './team/index.js';
41
41
  export { ROLE_METADATA, ROLE_EXPERTISE, ROLE_GROUPS, PREDEFINED_ROLE_IDS, TOOL_GROUPS, TOOL_PROFILES, PROFILE_INFO, SKILL_REQUIREMENTS, CUSTOM_MASCOTS, buildAgentWorkshopData, buildSuggestedRolesMap, PLAN_MODE_BLOCKED_TOOLS, PLAN_MODE_DENIAL_MESSAGE, PLAN_MODE_PROMPT, isToolAllowedInPlanMode, getPlanModePrompt, } from './team/index.js';
42
- export { getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate, parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap, findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, suggestOwner, suggestOwners, matchesAgentExpertise, wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, resolveAgentIdCollision, setActiveSharedContext, getActiveSharedContext, recordTeamActivity, getDefinedSkillNames, getSkillRequirements, checkSkillCompatibility, getCompatibleSkills, getAllRequiredTools, getSkillsByCategory, } from './team/index.js';
42
+ export { getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAwarenessPrompt, generateCoordinatorGuidance, generateSpecialistGuidance, createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile, assignMascot, generateCustomAgentSystemPrompt, mcpServerOf, filterMcpToolsByGrant, MCP_TOOL_PREFIX, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition, listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate, parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, buildContextMap, findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, suggestOwner, suggestOwners, matchesAgentExpertise, wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, resolveAgentIdCollision, setActiveSharedContext, getActiveSharedContext, recordTeamActivity, getDefinedSkillNames, getSkillRequirements, checkSkillCompatibility, getCompatibleSkills, getAllRequiredTools, getSkillsByCategory, } from './team/index.js';
43
43
  export { codingPreset, readOnlyPreset, resolvePreset } from './presets/index.js';
44
44
  export type { Preset } from './presets/index.js';
45
45
  export type { AnyTool } from './presets/types.js';
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ getToolsForProfile, detectProfileFromTools, isProfileReadOnly, generateToolAware
53
53
  // Tool config (extended)
54
54
  createDefaultToolConfig, validateToolConfig, getAllGroupIds, getGroupInfo, getGroupsByTier, getGroupsForProfile,
55
55
  // Custom agents
56
- assignMascot, generateCustomAgentSystemPrompt, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition,
56
+ assignMascot, generateCustomAgentSystemPrompt, mcpServerOf, filterMcpToolsByGrant, MCP_TOOL_PREFIX, getCustomAgentToolFilter, getCustomAgentProfileLabel, validateAgentId, isAgentIdTaken, createCustomAgentDefinition,
57
57
  // Agent templates
58
58
  listTemplates, getTemplate, saveTemplate, updateTemplate, deleteTemplate, createAgentFromTemplate,
59
59
  // Mention parsing
@@ -7,6 +7,7 @@
7
7
  export { AgentTeam } from './team.js';
8
8
  export type { AgentTeamConfig } from './team.js';
9
9
  export { TeamAgent, isNarrowing, lostWriteAccess } from './team-agent.js';
10
+ export { mcpServerOf, filterMcpToolsByGrant, MCP_TOOL_PREFIX } from './mcp-servers.js';
10
11
  export type { TeamAgentUpdate, AgentUpdateResult } from './team-agent.js';
11
12
  export { SharedContextManager } from './shared-context.js';
12
13
  export type { SharedContext, SharedProjectInfo, SharedTeamInfo, TeamRosterEntry, TeamActivity, TeamActivityType, SharedDecision, TokenBudget, SerializedSharedContext, } from './shared-context.js';
@@ -7,6 +7,7 @@
7
7
  // Core classes
8
8
  export { AgentTeam } from './team.js';
9
9
  export { TeamAgent, isNarrowing, lostWriteAccess } from './team-agent.js';
10
+ export { mcpServerOf, filterMcpToolsByGrant, MCP_TOOL_PREFIX } from './mcp-servers.js';
10
11
  export { SharedContextManager } from './shared-context.js';
11
12
  export { ArtifactStore } from './artifacts.js';
12
13
  export { ROLE_METADATA, ROLE_EXPERTISE, ROLE_GROUPS, PREDEFINED_ROLE_IDS } from './types.js';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Which MCP server owns a tool.
3
+ *
4
+ * `MCPManager` names every discovered tool `` `${prefix}_${server}_${tool}` `` (default prefix
5
+ * `mcp`). Recovering the server from the name is what lets a host honour a per-agent grant, and
6
+ * it is shared here because BOTH hosts need it and a second copy would eventually disagree with
7
+ * the first about which server owns `mcp_my_db_replica_list_tables`.
8
+ */
9
+ /** The prefix `MCPManager` is constructed with in both hosts. */
10
+ export declare const MCP_TOOL_PREFIX = "mcp";
11
+ /**
12
+ * The server a tool belongs to, or `null` when it cannot be told.
13
+ *
14
+ * ⚠️ DO NOT SPLIT ON `_`. Server names and tool names may both contain underscores, so
15
+ * `mcp_my_db_replica_list_tables` splits four ways and only one reading is right. Matching
16
+ * against the manager's own server list, LONGEST FIRST, is the only approach that cannot assign
17
+ * a tool to a server the user did not grant — `my_db` is a prefix of `my_db_replica`, and
18
+ * checking it first would hand the replica's tools to the wrong server.
19
+ *
20
+ * ⚠️ `null` MEANS "DO NOT GUESS", NOT "DENY". A caller should leave an unidentifiable tool
21
+ * alone: removing a capability because a name did not parse is a failure the user cannot see or
22
+ * act on, and the names come from servers we do not control.
23
+ */
24
+ export declare function mcpServerOf(toolName: string, servers: readonly string[], prefix?: string): string | null;
25
+ /**
26
+ * Filter MCP tools down to what an agent is granted.
27
+ *
28
+ * The shared half of enforcement: a host still decides WHEN to call it (at construction, where
29
+ * a tool the agent does not have cannot be called at all), but not what an absent grant means
30
+ * or how a tool maps to a server.
31
+ */
32
+ export declare function filterMcpToolsByGrant<T extends {
33
+ definition: {
34
+ name: string;
35
+ };
36
+ }>(tools: readonly T[], servers: readonly string[], grants: (server: string) => boolean, prefix?: string): T[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Which MCP server owns a tool.
3
+ *
4
+ * `MCPManager` names every discovered tool `` `${prefix}_${server}_${tool}` `` (default prefix
5
+ * `mcp`). Recovering the server from the name is what lets a host honour a per-agent grant, and
6
+ * it is shared here because BOTH hosts need it and a second copy would eventually disagree with
7
+ * the first about which server owns `mcp_my_db_replica_list_tables`.
8
+ */
9
+ /** The prefix `MCPManager` is constructed with in both hosts. */
10
+ export const MCP_TOOL_PREFIX = 'mcp';
11
+ /**
12
+ * The server a tool belongs to, or `null` when it cannot be told.
13
+ *
14
+ * ⚠️ DO NOT SPLIT ON `_`. Server names and tool names may both contain underscores, so
15
+ * `mcp_my_db_replica_list_tables` splits four ways and only one reading is right. Matching
16
+ * against the manager's own server list, LONGEST FIRST, is the only approach that cannot assign
17
+ * a tool to a server the user did not grant — `my_db` is a prefix of `my_db_replica`, and
18
+ * checking it first would hand the replica's tools to the wrong server.
19
+ *
20
+ * ⚠️ `null` MEANS "DO NOT GUESS", NOT "DENY". A caller should leave an unidentifiable tool
21
+ * alone: removing a capability because a name did not parse is a failure the user cannot see or
22
+ * act on, and the names come from servers we do not control.
23
+ */
24
+ export function mcpServerOf(toolName, servers, prefix = MCP_TOOL_PREFIX) {
25
+ const byLongest = [...servers].sort((a, b) => b.length - a.length);
26
+ for (const server of byLongest) {
27
+ if (toolName.startsWith(`${prefix}_${server}_`))
28
+ return server;
29
+ }
30
+ return null;
31
+ }
32
+ /**
33
+ * Filter MCP tools down to what an agent is granted.
34
+ *
35
+ * The shared half of enforcement: a host still decides WHEN to call it (at construction, where
36
+ * a tool the agent does not have cannot be called at all), but not what an absent grant means
37
+ * or how a tool maps to a server.
38
+ */
39
+ export function filterMcpToolsByGrant(tools, servers, grants, prefix = MCP_TOOL_PREFIX) {
40
+ return tools.filter((tool) => {
41
+ const server = mcpServerOf(tool.definition.name, servers, prefix);
42
+ return server === null || grants(server);
43
+ });
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",