@compilr-dev/sdk 0.1.23 → 0.1.25

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.
@@ -39,7 +39,7 @@ export type CapabilityTier = 'upfront' | 'loadable' | 'forbidden';
39
39
  export interface LoadedCapability {
40
40
  packId: string;
41
41
  loadedAt: number;
42
- trigger: 'upfront' | 'slash-command' | 'agent-self' | 'auto-detect';
42
+ trigger: 'upfront' | 'slash-command' | 'agent-self' | 'auto-detect' | 'auto-load';
43
43
  }
44
44
  /**
45
45
  * Catalog entry shown in the agent's system prompt for self-loading.
package/dist/index.d.ts CHANGED
@@ -44,7 +44,7 @@ export { DEFAULT_MODELS, getContextWindow, DEFAULT_CONTEXT_WINDOW } from './mode
44
44
  export { type ModelTier, type TierInfo, type ProviderModelMap, MODEL_TIERS, TIER_INFO, isValidTier, type ThinkingFormat, type ModelStatus, type ModelInfo, MODEL_REGISTRY, getModelsForProvider, getModelsSortedForDisplay, getModelInfo, isKnownModel, isModelSupported, getThinkingFormat, getStatusIndicator, getStatusLabel, getDefaultModelForTier, areThinkingFormatsCompatible, shouldClearHistoryOnModelChange, getModelContextWindow, getModelDisplayName, getModelDescription, getModelForTier, getTierMappings, getTierDisplayName, getShortModelName, getDefaultTierMappings, type ProviderMetadata, type OthersProviderModel, PROVIDER_METADATA, TOGETHER_MODELS, GROQ_MODELS, FIREWORKS_MODELS, PERPLEXITY_MODELS, OPENROUTER_MODELS, getModelsForOthersProvider, getOthersProviders, getProviderMetadata, isOthersProvider, } from './models/index.js';
45
45
  export { assembleTools, deduplicateTools } from './tools.js';
46
46
  export { MetaToolsRegistry, createMetaTools, META_TOOLS_SYSTEM_PROMPT_PREFIX, } from './meta-tools/index.js';
47
- export type { MetaToolStats, MetaTools } from './meta-tools/index.js';
47
+ export type { MetaToolStats, MetaTools, FallbackOptions } from './meta-tools/index.js';
48
48
  export { CapabilityManager, CAPABILITY_PACKS, FORBIDDEN_PACK_SUGGESTIONS, getPackCount, getAllPackIds, createLoadCapabilityTool, generateCapabilityCatalog, } from './capabilities/index.js';
49
49
  export type { CapabilityPack, CapabilityTier, LoadedCapability, CapabilityCatalogEntry, CapabilityLoadResult, CapabilityManagerConfig, } from './capabilities/index.js';
50
50
  export { SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats, ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './system-prompt/index.js';
@@ -13,4 +13,4 @@
13
13
  * // Use metaTools.createFallback() for transparent routing
14
14
  * ```
15
15
  */
16
- export { MetaToolsRegistry, createMetaTools, META_TOOLS_SYSTEM_PROMPT_PREFIX, type MetaToolStats, type MetaTools, } from './registry.js';
16
+ export { MetaToolsRegistry, createMetaTools, META_TOOLS_SYSTEM_PROMPT_PREFIX, type MetaToolStats, type MetaTools, type FallbackOptions, } from './registry.js';
@@ -21,6 +21,14 @@ export interface MetaToolStats {
21
21
  /** Estimated token savings vs declaring all tools directly */
22
22
  estimatedTokenSavings: number;
23
23
  }
24
+ /**
25
+ * Options for the fallback handler created by createFallback().
26
+ */
27
+ export interface FallbackOptions {
28
+ /** Called when a tool exists in the registry but is blocked by the filter.
29
+ * Return true if the filter was updated and the tool should be retried. */
30
+ onFilteredTool?: (toolName: string) => boolean;
31
+ }
24
32
  /**
25
33
  * The set of meta-tools and fallback handler returned by createMetaTools().
26
34
  */
@@ -32,7 +40,7 @@ export interface MetaTools {
32
40
  /** Executes any registered tool by name */
33
41
  useToolTool: Tool;
34
42
  /** Creates a fallback handler for transparent tool routing */
35
- createFallback: () => (name: string, input: Record<string, unknown>) => Promise<ToolExecutionResult | null>;
43
+ createFallback: (options?: FallbackOptions) => (name: string, input: Record<string, unknown>) => Promise<ToolExecutionResult | null>;
36
44
  }
37
45
  export declare class MetaToolsRegistry {
38
46
  private readonly toolRegistry;
@@ -89,6 +97,7 @@ export declare class MetaToolsRegistry {
89
97
  }
90
98
  /**
91
99
  * Create the three meta-tools + fallback handler, all bound to a registry instance.
100
+ * Pass FallbackOptions to enable auto-loading in both use_tool and createFallback paths.
92
101
  */
93
- export declare function createMetaTools(registry: MetaToolsRegistry): MetaTools;
102
+ export declare function createMetaTools(registry: MetaToolsRegistry, options?: FallbackOptions): MetaTools;
94
103
  export declare const META_TOOLS_SYSTEM_PROMPT_PREFIX = "\n## Tool Index (Specialized Tools)\n\nThese tools are called **exactly like direct tools** \u2014 just use the tool name with parameters. No special syntax or wrapper needed. The system routes them automatically.\n\n**IMPORTANT \u2014 These are CLI system tools, NOT your project's backend. Never use localhost/curl to access them.**\n\n**Parameter Rules:**\n- For **zero-parameter calls**: call the tool directly (e.g., `workitem_query()`, `git_status()`).\n- For **calls WITH parameters**: you MUST call `get_tool_info(\"tool_name\")` first to get parameter details. The signatures below are summaries only \u2014 do NOT guess parameter structure from them.\n- After a failed tool call, always call `get_tool_info()` before retrying.\n\n";
@@ -143,8 +143,9 @@ export class MetaToolsRegistry {
143
143
  // =============================================================================
144
144
  /**
145
145
  * Create the three meta-tools + fallback handler, all bound to a registry instance.
146
+ * Pass FallbackOptions to enable auto-loading in both use_tool and createFallback paths.
146
147
  */
147
- export function createMetaTools(registry) {
148
+ export function createMetaTools(registry, options) {
148
149
  // -------------------------------------------------------------------------
149
150
  // list_tools
150
151
  // -------------------------------------------------------------------------
@@ -240,13 +241,16 @@ export function createMetaTools(registry) {
240
241
  execute: async ({ tool_name, args }) => {
241
242
  // 0. Check tool filter
242
243
  if (!registry.isToolAllowed(tool_name)) {
243
- const filter = registry.getFilter();
244
- const allowedTools = filter
245
- ? Array.from(filter).filter((t) => registry.getTool(t) !== undefined)
246
- : [];
247
- return createErrorResult(`Tool '${tool_name}' is not available for this agent. ` +
248
- `Your available meta-registry tools: ${allowedTools.slice(0, 10).join(', ')}${allowedTools.length > 10 ? '...' : ''} ` +
249
- `Call list_tools() to see all available tools.`);
244
+ // Give consumer a chance to load the capability and update the filter
245
+ if (!(options?.onFilteredTool?.(tool_name) && registry.isToolAllowed(tool_name))) {
246
+ const filter = registry.getFilter();
247
+ const allowedTools = filter
248
+ ? Array.from(filter).filter((t) => registry.getTool(t) !== undefined)
249
+ : [];
250
+ return createErrorResult(`Tool '${tool_name}' is not available for this agent. ` +
251
+ `Your available meta-registry tools: ${allowedTools.slice(0, 10).join(', ')}${allowedTools.length > 10 ? '...' : ''} ` +
252
+ `Call list_tools() to see all available tools.`);
253
+ }
250
254
  }
251
255
  // 1. Find the tool
252
256
  const tool = registry.getTool(tool_name);
@@ -293,7 +297,7 @@ export function createMetaTools(registry) {
293
297
  // -------------------------------------------------------------------------
294
298
  // Fallback handler factory
295
299
  // -------------------------------------------------------------------------
296
- function createFallback() {
300
+ function createFallback(options) {
297
301
  return async (name, input) => {
298
302
  // Check if tool exists in registry
299
303
  const tool = registry.getTool(name);
@@ -302,12 +306,18 @@ export function createMetaTools(registry) {
302
306
  }
303
307
  // Check tool filter
304
308
  if (!registry.isToolAllowed(name)) {
305
- const filter = registry.getFilter();
306
- const allowedTools = filter
307
- ? Array.from(filter).filter((t) => registry.getTool(t) !== undefined)
308
- : [];
309
- return createErrorResult(`Tool '${name}' is not available for this agent. ` +
310
- `Available tools: ${allowedTools.slice(0, 10).join(', ')}${allowedTools.length > 10 ? '...' : ''}`);
309
+ // Give consumer a chance to load the capability and update the filter
310
+ if (options?.onFilteredTool?.(name) && registry.isToolAllowed(name)) {
311
+ // Filter updated fall through to execute
312
+ }
313
+ else {
314
+ const filter = registry.getFilter();
315
+ const allowedTools = filter
316
+ ? Array.from(filter).filter((t) => registry.getTool(t) !== undefined)
317
+ : [];
318
+ return createErrorResult(`Tool '${name}' is not available for this agent. ` +
319
+ `Available tools: ${allowedTools.slice(0, 10).join(', ')}${allowedTools.length > 10 ? '...' : ''}`);
320
+ }
311
321
  }
312
322
  // Coerce arguments before validation (handles LLM mistakes without guided decoding)
313
323
  const toolSchema = tool.definition.inputSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",