@compilr-dev/sdk 0.1.24 → 0.1.26

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.
@@ -97,6 +97,7 @@ export declare class MetaToolsRegistry {
97
97
  }
98
98
  /**
99
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.
100
101
  */
101
- export declare function createMetaTools(registry: MetaToolsRegistry): MetaTools;
102
+ export declare function createMetaTools(registry: MetaToolsRegistry, options?: FallbackOptions): MetaTools;
102
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);
@@ -22,8 +22,12 @@ export interface SystemPromptContext {
22
22
  enableMetaTools?: boolean;
23
23
  /** Does the agent have a role-specific identity? (team agents) */
24
24
  hasRoleIdentity?: boolean;
25
- /** Active project name (for explicit identification) */
25
+ /** Active project display name (human-readable, e.g. "Hr Manager") */
26
26
  projectName?: string;
27
+ /** Active project slug (unique identifier, e.g. "hr-manager") */
28
+ projectSlug?: string;
29
+ /** Active project ID (numeric database identifier) */
30
+ projectId?: number;
27
31
  /** Project context from COMPILR.md (appended at end) */
28
32
  projectContext?: string;
29
33
  /** Guided mode context (appended at end) */
@@ -79,6 +83,10 @@ export declare class SystemPromptBuilder {
79
83
  * Build the system prompt based on current context
80
84
  */
81
85
  build(): BuildResult;
86
+ /**
87
+ * Build project metadata lines (name, slug, ID) for the system prompt.
88
+ */
89
+ private buildProjectMeta;
82
90
  /**
83
91
  * Build and return just the prompt string
84
92
  */
@@ -168,10 +168,12 @@ export class SystemPromptBuilder {
168
168
  const projectHeader = this.context.projectName
169
169
  ? `## Project Context (${this.context.projectName})`
170
170
  : '## Project Context';
171
- prompt += `\n\n---\n\n${projectHeader}\n\nThe following is project-specific context loaded from COMPILR.md:\n\n${this.context.projectContext}`;
171
+ const projectMeta = this.buildProjectMeta();
172
+ prompt += `\n\n---\n\n${projectHeader}${projectMeta}\n\nThe following is project-specific context loaded from COMPILR.md:\n\n${this.context.projectContext}`;
172
173
  }
173
174
  else if (this.context.projectName) {
174
- prompt += `\n\n---\n\n## Active Project\n\nThe current project is: **${this.context.projectName}**`;
175
+ const projectMeta = this.buildProjectMeta();
176
+ prompt += `\n\n---\n\n## Active Project${projectMeta}`;
175
177
  }
176
178
  // Append guided mode context if provided
177
179
  if (this.context.guidedModeContext) {
@@ -196,6 +198,22 @@ export class SystemPromptBuilder {
196
198
  estimatedTokens: baseTokens + appendedTokens,
197
199
  };
198
200
  }
201
+ /**
202
+ * Build project metadata lines (name, slug, ID) for the system prompt.
203
+ */
204
+ buildProjectMeta() {
205
+ const lines = [];
206
+ if (this.context.projectName) {
207
+ lines.push(`- **Name:** ${this.context.projectName}`);
208
+ }
209
+ if (this.context.projectSlug) {
210
+ lines.push(`- **Slug:** \`${this.context.projectSlug}\` (unique identifier — use this for tool lookups)`);
211
+ }
212
+ if (this.context.projectId !== undefined) {
213
+ lines.push(`- **ID:** ${String(this.context.projectId)}`);
214
+ }
215
+ return lines.length > 0 ? '\n\n' + lines.join('\n') : '';
216
+ }
199
217
  /**
200
218
  * Build and return just the prompt string
201
219
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",