@compilr-dev/sdk 0.7.32 → 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 +12 -1
- package/dist/config.d.ts +39 -0
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -314,7 +314,16 @@ class CompilrAgentImpl {
|
|
|
314
314
|
: false
|
|
315
315
|
: undefined,
|
|
316
316
|
hooks: mergedHooks,
|
|
317
|
-
|
|
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
|
@@ -245,6 +245,45 @@ export interface CompilrAgentConfig {
|
|
|
245
245
|
action: string;
|
|
246
246
|
reason?: string;
|
|
247
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';
|
|
248
287
|
/**
|
|
249
288
|
* Dynamic capability loading configuration.
|
|
250
289
|
* When enabled, tools are loaded on-demand for token efficiency.
|