@compilr-dev/sdk 0.7.31 → 0.8.0

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
@@ -314,7 +314,16 @@ class CompilrAgentImpl {
314
314
  : false
315
315
  : undefined,
316
316
  hooks: mergedHooks,
317
- pins: {},
317
+ enableFileTracking: config?.enableFileTracking ?? true,
318
+ pins: config?.pins
319
+ ? {
320
+ maxAnchors: config.pins.maxAnchors ?? 50,
321
+ maxTokens: config.pins.maxTokens ?? 4000,
322
+ includeDefaults: config.pins.includeDefaults ?? true,
323
+ }
324
+ : {},
325
+ onIterationLimitReached: config?.onIterationLimitReached,
326
+ iterationLimitBehavior: config?.iterationLimitBehavior,
318
327
  permissions: {
319
328
  defaultLevel: permissionsConfig.defaultLevel,
320
329
  onPermissionRequest: permissionsConfig.onPermissionRequest,
@@ -334,6 +343,8 @@ class CompilrAgentImpl {
334
343
  this.totalUsage.outputTokens += event.tokens.outputTokens;
335
344
  this.totalUsage.totalTokens += event.tokens.inputTokens + event.tokens.outputTokens;
336
345
  }
346
+ // Forward to user-provided onEvent callback
347
+ config?.onEvent?.(event);
337
348
  // Forward ALL events to external listener (if set via run/stream)
338
349
  this.externalEventListener?.(event);
339
350
  },
package/dist/config.d.ts CHANGED
@@ -223,6 +223,8 @@ export interface CompilrAgentConfig {
223
223
  * Default: true when a PermissionCallback is provided, false otherwise.
224
224
  */
225
225
  includeDefaultRules?: boolean;
226
+ /** Logger instance for structured logging. When omitted, logging is disabled. */
227
+ logger?: import('@compilr-dev/logger').Logger;
226
228
  /** Guardrail configuration. Default: true */
227
229
  guardrails?: boolean | GuardrailConfig;
228
230
  /** Tool execution timeout in milliseconds. 0 = no timeout. Default: 30000 (30s) */
@@ -243,6 +245,45 @@ export interface CompilrAgentConfig {
243
245
  action: string;
244
246
  reason?: string;
245
247
  }) => void;
248
+ /**
249
+ * Event handler for monitoring agent execution.
250
+ * Called alongside the SDK's internal usage tracking — both run on every event.
251
+ */
252
+ onEvent?: (event: AgentEvent) => void;
253
+ /**
254
+ * Enable file access tracking for context restoration hints.
255
+ * When enabled, the agent tracks which files were read, referenced, and modified.
256
+ * After context compaction, hints are injected to help the LLM understand
257
+ * what files it previously accessed.
258
+ * Default: true when contextManager is created (i.e., almost always).
259
+ */
260
+ enableFileTracking?: boolean;
261
+ /**
262
+ * Pin/anchor configuration. Controls the AnchorManager for critical information
263
+ * that survives context compaction.
264
+ */
265
+ pins?: {
266
+ /** Maximum number of pins. Default: 50 */
267
+ maxAnchors?: number;
268
+ /** Maximum total tokens for pins. Default: 4000 */
269
+ maxTokens?: number;
270
+ /** Include built-in safety pins. Default: true */
271
+ includeDefaults?: boolean;
272
+ };
273
+ /**
274
+ * Callback invoked when the agent reaches its iteration limit.
275
+ * Return a positive number to extend by that many iterations, or false to stop.
276
+ */
277
+ onIterationLimitReached?: (context: {
278
+ iteration: number;
279
+ maxIterations: number;
280
+ toolCallCount: number;
281
+ }) => Promise<number | false>;
282
+ /**
283
+ * Behavior when max iterations is reached and no onIterationLimitReached callback
284
+ * is provided. Default: 'error'.
285
+ */
286
+ iterationLimitBehavior?: 'error' | 'summarize' | 'continue';
246
287
  /**
247
288
  * Dynamic capability loading configuration.
248
289
  * When enabled, tools are loaded on-demand for token efficiency.
package/dist/index.d.ts CHANGED
@@ -77,3 +77,5 @@ export { generateProject, isGitConfigured, generateCompilrMd, generateConfigJson
77
77
  export type { TechStack, CodingStandards, GeneratorRepoPattern, ProjectConfig, GenerationResult, CompilrConfig, DetectedProject, GitInfo, ImportProjectConfig, } from './project-generator/index.js';
78
78
  export { readFileTool, writeFileTool, createBashTool, bashTool, bashOutputTool, killShellTool, grepTool, globTool, editTool, todoWriteTool, todoReadTool, createTodoTools, TodoStore, webFetchTool, suggestTool, } from '@compilr-dev/agents';
79
79
  export { gitStatusTool, gitDiffTool, gitLogTool, gitCommitTool, gitBranchTool, gitStashTool, gitBlameTool, gitFileHistoryTool, detectProjectTool, findProjectRootTool, runTestsTool, runLintTool, runBuildTool, runFormatTool, findDefinitionTool, findReferencesTool, findTodosTool, checkOutdatedTool, findVulnerabilitiesTool, analyzeTestCoverageTool, getFileStructureTool, getComplexityTool, allCodingTools, unifiedTools, } from '@compilr-dev/agents-coding';
80
+ export { createLogger, createSilentLogger } from '@compilr-dev/logger';
81
+ export type { Logger, LoggerOptions, LogLevel } from '@compilr-dev/logger';
package/dist/index.js CHANGED
@@ -221,3 +221,7 @@ analyzeTestCoverageTool,
221
221
  getFileStructureTool, getComplexityTool,
222
222
  // Bulk exports
223
223
  allCodingTools, unifiedTools, } from '@compilr-dev/agents-coding';
224
+ // =============================================================================
225
+ // Logger (re-export for consumers)
226
+ // =============================================================================
227
+ export { createLogger, createSilentLogger } from '@compilr-dev/logger';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.7.31",
3
+ "version": "0.8.0",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -54,6 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@compilr-dev/agents": "^0.5.1",
57
+ "@compilr-dev/logger": "^0.1.0",
57
58
  "ajv": "^6.14.0"
58
59
  },
59
60
  "peerDependencies": {