@compilr-dev/sdk 0.2.11 → 0.2.13

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/agent.js CHANGED
@@ -118,6 +118,7 @@ class CompilrAgentImpl {
118
118
  provider,
119
119
  systemPrompt,
120
120
  maxIterations: config?.maxIterations ?? 50,
121
+ toolTimeoutMs: config?.toolTimeoutMs,
121
122
  contextManager,
122
123
  autoContextManagement: contextManager !== undefined,
123
124
  hooks: config?.hooks,
package/dist/config.d.ts CHANGED
@@ -141,6 +141,8 @@ export interface CompilrAgentConfig {
141
141
  includeDefaultRules?: boolean;
142
142
  /** Guardrail configuration. Default: true */
143
143
  guardrails?: boolean | GuardrailConfig;
144
+ /** Tool execution timeout in milliseconds. 0 = no timeout. Default: 30000 (30s) */
145
+ toolTimeoutMs?: number;
144
146
  /** Lifecycle hooks */
145
147
  hooks?: HooksConfig;
146
148
  /** Context management configuration */
package/dist/index.d.ts CHANGED
@@ -56,6 +56,8 @@ export type { SystemPromptContext, BuildResult, SystemPromptModule, ModuleCondit
56
56
  export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState, WorkItemType, WorkItemStatus, WorkItemPriority, GuidedStep, DocumentType, PlanStatus, Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, PlatformContext, PlatformToolsConfig, PlatformHooks, StepCriteria, } from './platform/index.js';
57
57
  export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
58
58
  export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, } from './platform/index.js';
59
+ export { createAskUserTool, createAskUserSimpleTool, } from './tools/index.js';
60
+ export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './tools/index.js';
59
61
  export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, ProjectAnchorStore, } from './platform/index.js';
60
62
  export type { ProjectAnchorStoreConfig } from './platform/index.js';
61
63
  export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './platform/index.js';
package/dist/index.js CHANGED
@@ -117,6 +117,10 @@ shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, }
117
117
  // =============================================================================
118
118
  export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
119
119
  // =============================================================================
120
+ // User Interaction Tools (ask_user, ask_user_simple)
121
+ // =============================================================================
122
+ export { createAskUserTool, createAskUserSimpleTool, } from './tools/index.js';
123
+ // =============================================================================
120
124
  // Platform Tools (runtime — createPlatformTools factory + individual factories)
121
125
  // =============================================================================
122
126
  export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, ProjectAnchorStore, } from './platform/index.js';
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Ask User Tools — Agent tools for gathering user input
3
+ *
4
+ * Two tools:
5
+ * - ask_user: Structured multi-question batches (1-5 questions)
6
+ * - ask_user_simple: Single question with flat schema (easier for small models)
7
+ *
8
+ * Both use a factory pattern: the consumer (CLI, desktop app) provides a handler
9
+ * callback that implements the actual UI. The SDK defines the tool schemas and
10
+ * types as the single source of truth.
11
+ */
12
+ import type { Tool } from '@compilr-dev/agents';
13
+ /** A single question in an ask_user batch */
14
+ export interface AskUserQuestion {
15
+ /** Unique identifier for the question (e.g., "app_type", "target_users") */
16
+ id: string;
17
+ /** Short label for tab/step display (e.g., "App Type") — max 12 chars */
18
+ header: string;
19
+ /** The question text */
20
+ question: string;
21
+ /** Predefined options (optional — if omitted, free-text only) */
22
+ options?: string[];
23
+ /** Allow free-text input (default: true) */
24
+ allowCustom?: boolean;
25
+ /** Allow multiple selections (default: false) */
26
+ multiSelect?: boolean;
27
+ }
28
+ /** Input parameters for ask_user tool */
29
+ export interface AskUserInput {
30
+ /** 1-5 questions to ask */
31
+ questions: AskUserQuestion[];
32
+ /** Optional context shown above questions */
33
+ context?: string;
34
+ }
35
+ /** Result from ask_user tool */
36
+ export interface AskUserResult {
37
+ /** Answers keyed by question ID */
38
+ answers: Record<string, string | string[]>;
39
+ /** Question IDs that were skipped */
40
+ skipped: string[];
41
+ }
42
+ /**
43
+ * Handler callback for ask_user tool.
44
+ * The consumer provides the UI implementation.
45
+ */
46
+ export type AskUserHandler = (input: AskUserInput) => Promise<AskUserResult>;
47
+ /** Input parameters for ask_user_simple tool */
48
+ export interface AskUserSimpleInput {
49
+ /** The question text */
50
+ question: string;
51
+ /** Predefined options (optional, max 5) */
52
+ options?: string[];
53
+ /** Allow free-text input (default: true) */
54
+ allowCustom?: boolean;
55
+ }
56
+ /** Result from ask_user_simple tool */
57
+ export interface AskUserSimpleResult {
58
+ /** User's answer */
59
+ answer: string;
60
+ /** True if user skipped the question */
61
+ skipped: boolean;
62
+ }
63
+ /**
64
+ * Handler callback for ask_user_simple tool.
65
+ * The consumer provides the UI implementation.
66
+ */
67
+ export type AskUserSimpleHandler = (input: AskUserSimpleInput) => Promise<AskUserSimpleResult>;
68
+ /**
69
+ * Create an ask_user tool with a custom UI handler.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // CLI: show terminal overlay
74
+ * const askUser = createAskUserTool(async (input) => {
75
+ * const overlay = new AskUserOverlay(input);
76
+ * return await ui.showOverlay(overlay);
77
+ * });
78
+ *
79
+ * // Desktop: send IPC to renderer
80
+ * const askUser = createAskUserTool(async (input) => {
81
+ * return await sendToRenderer('ask-user', input);
82
+ * });
83
+ * ```
84
+ */
85
+ export declare function createAskUserTool(handler: AskUserHandler): Tool<AskUserInput>;
86
+ /**
87
+ * Create an ask_user_simple tool with a custom UI handler.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const askSimple = createAskUserSimpleTool(async (input) => {
92
+ * const overlay = new AskUserSimpleOverlay(input);
93
+ * return await ui.showOverlay(overlay);
94
+ * });
95
+ * ```
96
+ */
97
+ export declare function createAskUserSimpleTool(handler: AskUserSimpleHandler): Tool<AskUserSimpleInput>;
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Ask User Tools — Agent tools for gathering user input
3
+ *
4
+ * Two tools:
5
+ * - ask_user: Structured multi-question batches (1-5 questions)
6
+ * - ask_user_simple: Single question with flat schema (easier for small models)
7
+ *
8
+ * Both use a factory pattern: the consumer (CLI, desktop app) provides a handler
9
+ * callback that implements the actual UI. The SDK defines the tool schemas and
10
+ * types as the single source of truth.
11
+ */
12
+ import { defineTool } from '@compilr-dev/agents';
13
+ // =============================================================================
14
+ // Factory — ask_user
15
+ // =============================================================================
16
+ /**
17
+ * Create an ask_user tool with a custom UI handler.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // CLI: show terminal overlay
22
+ * const askUser = createAskUserTool(async (input) => {
23
+ * const overlay = new AskUserOverlay(input);
24
+ * return await ui.showOverlay(overlay);
25
+ * });
26
+ *
27
+ * // Desktop: send IPC to renderer
28
+ * const askUser = createAskUserTool(async (input) => {
29
+ * return await sendToRenderer('ask-user', input);
30
+ * });
31
+ * ```
32
+ */
33
+ export function createAskUserTool(handler) {
34
+ return defineTool({
35
+ name: 'ask_user',
36
+ description: 'Ask the user structured questions. ' +
37
+ 'Present 1-5 questions with optional predefined answers. ' +
38
+ 'Each question can have options to choose from or allow free-text input. ' +
39
+ 'Use this during design/refine phases to gather requirements efficiently.',
40
+ inputSchema: {
41
+ type: 'object',
42
+ properties: {
43
+ questions: {
44
+ type: 'array',
45
+ description: 'Questions to ask the user (1-5 questions)',
46
+ minItems: 1,
47
+ maxItems: 5,
48
+ items: {
49
+ type: 'object',
50
+ properties: {
51
+ id: {
52
+ type: 'string',
53
+ description: 'Unique identifier for the question',
54
+ },
55
+ header: {
56
+ type: 'string',
57
+ description: 'Short label for tab/step display (max 12 chars)',
58
+ },
59
+ question: {
60
+ type: 'string',
61
+ description: 'The question text',
62
+ },
63
+ options: {
64
+ type: 'array',
65
+ description: 'Predefined options (optional)',
66
+ items: { type: 'string' },
67
+ },
68
+ allowCustom: {
69
+ type: 'boolean',
70
+ description: 'Allow free-text input (default: true)',
71
+ },
72
+ multiSelect: {
73
+ type: 'boolean',
74
+ description: 'Allow multiple selections (default: false)',
75
+ },
76
+ },
77
+ required: ['id', 'header', 'question'],
78
+ },
79
+ },
80
+ context: {
81
+ type: 'string',
82
+ description: 'Optional context shown above questions',
83
+ },
84
+ },
85
+ required: ['questions'],
86
+ },
87
+ execute: async (input) => {
88
+ try {
89
+ if (input.questions.length === 0) {
90
+ return { success: false, error: 'At least one question is required' };
91
+ }
92
+ if (input.questions.length > 5) {
93
+ return { success: false, error: 'Maximum 5 questions allowed' };
94
+ }
95
+ const result = await handler(input);
96
+ return { success: true, result };
97
+ }
98
+ catch (err) {
99
+ return {
100
+ success: false,
101
+ error: `Failed to ask user: ${err instanceof Error ? err.message : String(err)}`,
102
+ };
103
+ }
104
+ },
105
+ silent: true,
106
+ });
107
+ }
108
+ // =============================================================================
109
+ // Factory — ask_user_simple
110
+ // =============================================================================
111
+ /**
112
+ * Create an ask_user_simple tool with a custom UI handler.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const askSimple = createAskUserSimpleTool(async (input) => {
117
+ * const overlay = new AskUserSimpleOverlay(input);
118
+ * return await ui.showOverlay(overlay);
119
+ * });
120
+ * ```
121
+ */
122
+ export function createAskUserSimpleTool(handler) {
123
+ return defineTool({
124
+ name: 'ask_user_simple',
125
+ description: 'Ask the user a single question. ' +
126
+ 'Provide optional predefined choices or allow free-text input. ' +
127
+ 'Use this for simple question flows — one question at a time. ' +
128
+ 'Preferred over ask_user for single questions and smaller models.',
129
+ inputSchema: {
130
+ type: 'object',
131
+ properties: {
132
+ question: {
133
+ type: 'string',
134
+ description: 'The question to ask the user',
135
+ },
136
+ options: {
137
+ type: 'array',
138
+ description: 'Predefined options for the user to choose from (max 5)',
139
+ items: { type: 'string' },
140
+ maxItems: 5,
141
+ },
142
+ allowCustom: {
143
+ type: 'boolean',
144
+ description: 'Allow free-text input in addition to options (default: true)',
145
+ },
146
+ },
147
+ required: ['question'],
148
+ },
149
+ execute: async (input) => {
150
+ try {
151
+ if (!input.question || input.question.trim().length === 0) {
152
+ return { success: false, error: 'Question text is required' };
153
+ }
154
+ if (input.options && input.options.length > 5) {
155
+ return { success: false, error: 'Maximum 5 options allowed' };
156
+ }
157
+ const result = await handler(input);
158
+ return { success: true, result };
159
+ }
160
+ catch (err) {
161
+ return {
162
+ success: false,
163
+ error: `Failed to ask user: ${err instanceof Error ? err.message : String(err)}`,
164
+ };
165
+ }
166
+ },
167
+ silent: true,
168
+ });
169
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tools — Reusable tool factories for CLI and desktop consumers.
3
+ *
4
+ * These tools require a UI handler callback from the consumer.
5
+ * The SDK defines schemas and types; consumers provide the UI.
6
+ */
7
+ export { createAskUserTool, createAskUserSimpleTool, } from './ask-user-tools.js';
8
+ export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './ask-user-tools.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tools — Reusable tool factories for CLI and desktop consumers.
3
+ *
4
+ * These tools require a UI handler callback from the consumer.
5
+ * The SDK defines schemas and types; consumers provide the UI.
6
+ */
7
+ export { createAskUserTool, createAskUserSimpleTool, } from './ask-user-tools.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",