@compilr-dev/sdk 0.1.22 → 0.1.24

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;
@@ -293,7 +293,7 @@ export function createMetaTools(registry) {
293
293
  // -------------------------------------------------------------------------
294
294
  // Fallback handler factory
295
295
  // -------------------------------------------------------------------------
296
- function createFallback() {
296
+ function createFallback(options) {
297
297
  return async (name, input) => {
298
298
  // Check if tool exists in registry
299
299
  const tool = registry.getTool(name);
@@ -302,12 +302,18 @@ export function createMetaTools(registry) {
302
302
  }
303
303
  // Check tool filter
304
304
  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 ? '...' : ''}`);
305
+ // Give consumer a chance to load the capability and update the filter
306
+ if (options?.onFilteredTool?.(name) && registry.isToolAllowed(name)) {
307
+ // Filter updated fall through to execute
308
+ }
309
+ else {
310
+ const filter = registry.getFilter();
311
+ const allowedTools = filter
312
+ ? Array.from(filter).filter((t) => registry.getTool(t) !== undefined)
313
+ : [];
314
+ return createErrorResult(`Tool '${name}' is not available for this agent. ` +
315
+ `Available tools: ${allowedTools.slice(0, 10).join(', ')}${allowedTools.length > 10 ? '...' : ''}`);
316
+ }
311
317
  }
312
318
  // Coerce arguments before validation (handles LLM mistakes without guided decoding)
313
319
  const toolSchema = tool.definition.inputSchema;
@@ -7,6 +7,15 @@
7
7
  * Ported from CLI's src/tools/document-db.ts.
8
8
  */
9
9
  import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev/agents';
10
+ /** All valid document types — keep in sync with DocumentType. */
11
+ const DOC_TYPE_ENUM = [
12
+ 'prd',
13
+ 'architecture',
14
+ 'design',
15
+ 'notes',
16
+ 'plan',
17
+ 'app-model',
18
+ ];
10
19
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11
20
  export function createDocumentTools(config) {
12
21
  const { context: ctx } = config;
@@ -21,7 +30,7 @@ export function createDocumentTools(config) {
21
30
  properties: {
22
31
  doc_type: {
23
32
  type: 'string',
24
- enum: ['prd', 'architecture', 'design', 'notes'],
33
+ enum: DOC_TYPE_ENUM,
25
34
  description: 'Document type',
26
35
  },
27
36
  title: {
@@ -80,7 +89,7 @@ export function createDocumentTools(config) {
80
89
  properties: {
81
90
  doc_type: {
82
91
  type: 'string',
83
- enum: ['prd', 'architecture', 'design', 'notes'],
92
+ enum: DOC_TYPE_ENUM,
84
93
  description: 'Document type to retrieve',
85
94
  },
86
95
  project_id: {
@@ -174,7 +183,7 @@ export function createDocumentTools(config) {
174
183
  properties: {
175
184
  doc_type: {
176
185
  type: 'string',
177
- enum: ['prd', 'architecture', 'design', 'notes'],
186
+ enum: DOC_TYPE_ENUM,
178
187
  description: 'Document type to delete',
179
188
  },
180
189
  project_id: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",