@compilr-dev/agents 0.3.25 → 0.3.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.
package/dist/agent.d.ts CHANGED
@@ -348,9 +348,9 @@ export interface AgentConfig {
348
348
  */
349
349
  checkpointOnAbort?: boolean;
350
350
  /**
351
- * Anchor manager options for critical information that survives context compaction.
351
+ * Pin manager options for critical information that survives context compaction.
352
352
  *
353
- * Anchors are pieces of information that:
353
+ * Pins are pieces of information that:
354
354
  * - Never get compacted - Survive all context management
355
355
  * - Always re-injected - Present in every LLM call
356
356
  * - Scoped - Session, persistent, or temporary
@@ -359,7 +359,7 @@ export interface AgentConfig {
359
359
  * ```typescript
360
360
  * const agent = new Agent({
361
361
  * provider,
362
- * anchors: {
362
+ * pins: {
363
363
  * maxAnchors: 20,
364
364
  * maxTokens: 2000,
365
365
  * persistPath: '~/.myapp/anchors.json',
@@ -368,6 +368,8 @@ export interface AgentConfig {
368
368
  * });
369
369
  * ```
370
370
  */
371
+ pins?: AnchorManagerOptions;
372
+ /** @deprecated Use `pins` instead */
371
373
  anchors?: AnchorManagerOptions;
372
374
  /**
373
375
  * Guardrail options for pattern-based safety checks.
@@ -865,9 +867,9 @@ export declare class Agent {
865
867
  */
866
868
  private readonly subAgents;
867
869
  /**
868
- * Anchor manager for critical information that survives context compaction
870
+ * Pin manager for critical information that survives context compaction
869
871
  */
870
- private readonly anchorManager?;
872
+ private readonly pinManager?;
871
873
  /**
872
874
  * Guardrail manager for pattern-based safety checks
873
875
  */
@@ -1029,99 +1031,72 @@ export declare class Agent {
1029
1031
  */
1030
1032
  recordUsage(model: string, provider: string, tokens: TokenUsage): void;
1031
1033
  /**
1032
- * Add an anchor (critical information that survives context compaction).
1034
+ * Add a pin (critical information that survives context compaction).
1033
1035
  *
1034
- * Anchors are injected into every LLM call and never get compacted.
1036
+ * Pins are injected into every LLM call and never get compacted.
1035
1037
  * Use them for information that must not be forgotten.
1036
1038
  *
1037
- * @param input - Anchor input
1038
- * @returns The created anchor, or undefined if anchors are not enabled
1039
+ * @param input - Pin input (uses AnchorInput type)
1040
+ * @returns The created pin, or undefined if pins are not enabled
1039
1041
  *
1040
1042
  * @example
1041
1043
  * ```typescript
1042
- * // Session anchor - lives for this session only
1043
- * agent.addAnchor({
1044
- * content: 'This session we implemented: edit tool, grep tool',
1045
- * priority: 'critical',
1046
- * scope: 'session',
1047
- * });
1048
- *
1049
- * // Safety anchor - persisted across sessions
1050
- * agent.addAnchor({
1051
- * content: 'Never delete files in /important without confirmation',
1052
- * priority: 'safety',
1053
- * scope: 'persistent',
1054
- * });
1055
- *
1056
- * // Temporary anchor - expires after 1 hour
1057
- * agent.addAnchor({
1058
- * content: 'Currently working on feature X',
1044
+ * agent.addPin({
1045
+ * content: 'Team roster: $default, $arch',
1059
1046
  * priority: 'info',
1060
- * scope: 'temporary',
1061
- * expiresAt: new Date(Date.now() + 60 * 60 * 1000),
1047
+ * scope: 'session',
1062
1048
  * });
1063
1049
  * ```
1064
1050
  */
1065
- addAnchor(input: AnchorInput): Anchor | undefined;
1051
+ addPin(input: AnchorInput): Anchor | undefined;
1066
1052
  /**
1067
- * Get an anchor by ID
1053
+ * Get a pin by ID
1068
1054
  */
1069
- getAnchor(id: string): Anchor | undefined;
1055
+ getPin(id: string): Anchor | undefined;
1070
1056
  /**
1071
- * Get all anchors, optionally filtered
1072
- *
1073
- * @param options - Query options for filtering
1074
- * @returns Array of anchors
1075
- *
1076
- * @example
1077
- * ```typescript
1078
- * // Get all anchors
1079
- * const all = agent.getAnchors();
1080
- *
1081
- * // Get only safety anchors
1082
- * const safety = agent.getAnchors({ priority: 'safety' });
1083
- *
1084
- * // Get session anchors with specific tags
1085
- * const tagged = agent.getAnchors({ scope: 'session', tags: ['files'] });
1086
- * ```
1057
+ * Get all pins, optionally filtered
1087
1058
  */
1088
- getAnchors(options?: AnchorQueryOptions): Anchor[];
1059
+ getPins(options?: AnchorQueryOptions): Anchor[];
1089
1060
  /**
1090
- * Check if an anchor exists
1061
+ * Check if a pin exists
1091
1062
  */
1092
- hasAnchor(id: string): boolean;
1063
+ hasPin(id: string): boolean;
1093
1064
  /**
1094
- * Remove an anchor by ID
1065
+ * Remove a pin by ID
1095
1066
  *
1096
- * @returns true if anchor was removed, false if not found
1067
+ * @returns true if pin was removed, false if not found
1097
1068
  */
1098
- removeAnchor(id: string): boolean;
1069
+ removePin(id: string): boolean;
1099
1070
  /**
1100
- * Clear anchors based on criteria
1101
- *
1102
- * @param options - Clear options for filtering which anchors to remove
1103
- * @returns Number of anchors removed
1104
- *
1105
- * @example
1106
- * ```typescript
1107
- * // Clear all session anchors
1108
- * agent.clearAnchors({ scope: 'session' });
1109
- *
1110
- * // Clear expired temporary anchors
1111
- * agent.clearAnchors({ expiredOnly: true });
1071
+ * Clear pins based on criteria
1112
1072
  *
1113
- * // Clear anchors with specific tags
1114
- * agent.clearAnchors({ tags: ['auto'] });
1115
- * ```
1073
+ * @param options - Clear options for filtering which pins to remove
1074
+ * @returns Number of pins removed
1116
1075
  */
1117
- clearAnchors(options?: AnchorClearOptions): number;
1076
+ clearPins(options?: AnchorClearOptions): number;
1118
1077
  /**
1119
- * Get the anchor manager (if configured)
1078
+ * Get the pin manager (if configured)
1120
1079
  */
1121
- getAnchorManager(): AnchorManager | undefined;
1080
+ getPinManager(): AnchorManager | undefined;
1122
1081
  /**
1123
- * Check if anchors are enabled
1082
+ * Check if pins are enabled
1124
1083
  */
1084
+ hasPins(): boolean;
1085
+ /** @deprecated Use addPin() instead */
1086
+ addAnchor(input: AnchorInput): Anchor | undefined;
1087
+ /** @deprecated Use getPin() instead */
1088
+ getAnchor(id: string): Anchor | undefined;
1089
+ /** @deprecated Use getPins() instead */
1090
+ getAnchors(options?: AnchorQueryOptions): Anchor[];
1091
+ /** @deprecated Use hasPin() instead */
1092
+ hasAnchor(id: string): boolean;
1093
+ /** @deprecated Use removePin() instead */
1094
+ removeAnchor(id: string): boolean;
1095
+ /** @deprecated Use clearPins() instead */
1096
+ clearAnchors(options?: AnchorClearOptions): number;
1097
+ /** @deprecated Use getPinManager() instead */
1098
+ getAnchorManager(): AnchorManager | undefined;
1099
+ /** @deprecated Use hasPins() instead */
1125
1100
  hasAnchors(): boolean;
1126
1101
  /**
1127
1102
  * Add a custom guardrail
@@ -1657,8 +1632,8 @@ export declare class Agent {
1657
1632
  * Generate a summary of messages using the LLM provider.
1658
1633
  * Used for context summarization when approaching limits.
1659
1634
  *
1660
- * If anchors are configured, the summary will prioritize keeping
1661
- * information related to anchor content (anchor-weighted summarization).
1635
+ * If pins are configured, the summary will prioritize keeping
1636
+ * information related to pinned content (pin-weighted summarization).
1662
1637
  */
1663
1638
  private generateSummary;
1664
1639
  /**
package/dist/agent.js CHANGED
@@ -69,9 +69,9 @@ export class Agent {
69
69
  */
70
70
  subAgents = new Map();
71
71
  /**
72
- * Anchor manager for critical information that survives context compaction
72
+ * Pin manager for critical information that survives context compaction
73
73
  */
74
- anchorManager;
74
+ pinManager;
75
75
  /**
76
76
  * Guardrail manager for pattern-based safety checks
77
77
  */
@@ -145,9 +145,11 @@ export class Agent {
145
145
  this.autoCheckpoint = config.autoCheckpoint ?? false;
146
146
  this.checkpointOnAbort = config.checkpointOnAbort ?? false;
147
147
  this._createdAt = new Date().toISOString();
148
- // Anchor management
149
- if (config.anchors !== undefined) {
150
- this.anchorManager = new AnchorManager(config.anchors);
148
+ // Pin management (backwards compat: accept `anchors` as alias for `pins`)
149
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
150
+ const pinConfig = config.pins ?? config.anchors;
151
+ if (pinConfig !== undefined) {
152
+ this.pinManager = new AnchorManager(pinConfig);
151
153
  }
152
154
  // Guardrail management
153
155
  if (config.guardrails !== undefined) {
@@ -427,128 +429,118 @@ export class Agent {
427
429
  this.usageTracker?.record({ model, provider, tokens });
428
430
  }
429
431
  // ==========================================================================
430
- // Anchor Management - Critical information that survives context compaction
432
+ // Pin Management - Critical information that survives context compaction
431
433
  // ==========================================================================
432
434
  /**
433
- * Add an anchor (critical information that survives context compaction).
435
+ * Add a pin (critical information that survives context compaction).
434
436
  *
435
- * Anchors are injected into every LLM call and never get compacted.
437
+ * Pins are injected into every LLM call and never get compacted.
436
438
  * Use them for information that must not be forgotten.
437
439
  *
438
- * @param input - Anchor input
439
- * @returns The created anchor, or undefined if anchors are not enabled
440
+ * @param input - Pin input (uses AnchorInput type)
441
+ * @returns The created pin, or undefined if pins are not enabled
440
442
  *
441
443
  * @example
442
444
  * ```typescript
443
- * // Session anchor - lives for this session only
444
- * agent.addAnchor({
445
- * content: 'This session we implemented: edit tool, grep tool',
446
- * priority: 'critical',
447
- * scope: 'session',
448
- * });
449
- *
450
- * // Safety anchor - persisted across sessions
451
- * agent.addAnchor({
452
- * content: 'Never delete files in /important without confirmation',
453
- * priority: 'safety',
454
- * scope: 'persistent',
455
- * });
456
- *
457
- * // Temporary anchor - expires after 1 hour
458
- * agent.addAnchor({
459
- * content: 'Currently working on feature X',
445
+ * agent.addPin({
446
+ * content: 'Team roster: $default, $arch',
460
447
  * priority: 'info',
461
- * scope: 'temporary',
462
- * expiresAt: new Date(Date.now() + 60 * 60 * 1000),
448
+ * scope: 'session',
463
449
  * });
464
450
  * ```
465
451
  */
466
- addAnchor(input) {
467
- if (!this.anchorManager)
452
+ addPin(input) {
453
+ if (!this.pinManager)
468
454
  return undefined;
469
- const anchor = this.anchorManager.add(input);
455
+ const anchor = this.pinManager.add(input);
470
456
  this.onEvent?.({ type: 'anchor_added', anchor });
471
457
  return anchor;
472
458
  }
473
459
  /**
474
- * Get an anchor by ID
460
+ * Get a pin by ID
475
461
  */
476
- getAnchor(id) {
477
- return this.anchorManager?.get(id);
462
+ getPin(id) {
463
+ return this.pinManager?.get(id);
478
464
  }
479
465
  /**
480
- * Get all anchors, optionally filtered
481
- *
482
- * @param options - Query options for filtering
483
- * @returns Array of anchors
484
- *
485
- * @example
486
- * ```typescript
487
- * // Get all anchors
488
- * const all = agent.getAnchors();
489
- *
490
- * // Get only safety anchors
491
- * const safety = agent.getAnchors({ priority: 'safety' });
492
- *
493
- * // Get session anchors with specific tags
494
- * const tagged = agent.getAnchors({ scope: 'session', tags: ['files'] });
495
- * ```
466
+ * Get all pins, optionally filtered
496
467
  */
497
- getAnchors(options) {
498
- return this.anchorManager?.getAll(options) ?? [];
468
+ getPins(options) {
469
+ return this.pinManager?.getAll(options) ?? [];
499
470
  }
500
471
  /**
501
- * Check if an anchor exists
472
+ * Check if a pin exists
502
473
  */
503
- hasAnchor(id) {
504
- return this.anchorManager?.has(id) ?? false;
474
+ hasPin(id) {
475
+ return this.pinManager?.has(id) ?? false;
505
476
  }
506
477
  /**
507
- * Remove an anchor by ID
478
+ * Remove a pin by ID
508
479
  *
509
- * @returns true if anchor was removed, false if not found
480
+ * @returns true if pin was removed, false if not found
510
481
  */
511
- removeAnchor(id) {
512
- if (!this.anchorManager)
482
+ removePin(id) {
483
+ if (!this.pinManager)
513
484
  return false;
514
- const removed = this.anchorManager.remove(id);
485
+ const removed = this.pinManager.remove(id);
515
486
  if (removed) {
516
487
  this.onEvent?.({ type: 'anchor_removed', anchorId: id });
517
488
  }
518
489
  return removed;
519
490
  }
520
491
  /**
521
- * Clear anchors based on criteria
522
- *
523
- * @param options - Clear options for filtering which anchors to remove
524
- * @returns Number of anchors removed
492
+ * Clear pins based on criteria
525
493
  *
526
- * @example
527
- * ```typescript
528
- * // Clear all session anchors
529
- * agent.clearAnchors({ scope: 'session' });
530
- *
531
- * // Clear expired temporary anchors
532
- * agent.clearAnchors({ expiredOnly: true });
533
- *
534
- * // Clear anchors with specific tags
535
- * agent.clearAnchors({ tags: ['auto'] });
536
- * ```
494
+ * @param options - Clear options for filtering which pins to remove
495
+ * @returns Number of pins removed
537
496
  */
538
- clearAnchors(options) {
539
- return this.anchorManager?.clear(options) ?? 0;
497
+ clearPins(options) {
498
+ return this.pinManager?.clear(options) ?? 0;
540
499
  }
541
500
  /**
542
- * Get the anchor manager (if configured)
501
+ * Get the pin manager (if configured)
543
502
  */
544
- getAnchorManager() {
545
- return this.anchorManager;
503
+ getPinManager() {
504
+ return this.pinManager;
546
505
  }
547
506
  /**
548
- * Check if anchors are enabled
507
+ * Check if pins are enabled
549
508
  */
509
+ hasPins() {
510
+ return this.pinManager !== undefined;
511
+ }
512
+ // --- Deprecated aliases (use pin methods instead) --------------------------
513
+ /** @deprecated Use addPin() instead */
514
+ addAnchor(input) {
515
+ return this.addPin(input);
516
+ }
517
+ /** @deprecated Use getPin() instead */
518
+ getAnchor(id) {
519
+ return this.getPin(id);
520
+ }
521
+ /** @deprecated Use getPins() instead */
522
+ getAnchors(options) {
523
+ return this.getPins(options);
524
+ }
525
+ /** @deprecated Use hasPin() instead */
526
+ hasAnchor(id) {
527
+ return this.hasPin(id);
528
+ }
529
+ /** @deprecated Use removePin() instead */
530
+ removeAnchor(id) {
531
+ return this.removePin(id);
532
+ }
533
+ /** @deprecated Use clearPins() instead */
534
+ clearAnchors(options) {
535
+ return this.clearPins(options);
536
+ }
537
+ /** @deprecated Use getPinManager() instead */
538
+ getAnchorManager() {
539
+ return this.getPinManager();
540
+ }
541
+ /** @deprecated Use hasPins() instead */
550
542
  hasAnchors() {
551
- return this.anchorManager !== undefined;
543
+ return this.hasPins();
552
544
  }
553
545
  // ==========================================================================
554
546
  // Guardrail Management - Pattern-based safety checks
@@ -1535,25 +1527,25 @@ export class Agent {
1535
1527
  // Build messages: system prompt + history + new user message
1536
1528
  let messages = [];
1537
1529
  // Add system message if present
1538
- // NOTE: Anchors are now appended to the system prompt (not a separate message)
1530
+ // NOTE: Pins are appended to the system prompt (not a separate message)
1539
1531
  // to avoid multiple system messages which can confuse Claude's role identity
1540
1532
  let systemContent = this.systemPrompt;
1541
- // Inject anchors into the system prompt (not as separate message)
1542
- if (this.anchorManager && this.anchorManager.size > 0) {
1543
- const anchorsContent = this.anchorManager.format();
1544
- if (anchorsContent) {
1545
- // Insert anchors BEFORE the role ending (if present) so role reinforcement stays at the end
1533
+ // Inject pins into the system prompt (not as separate message)
1534
+ if (this.pinManager && this.pinManager.size > 0) {
1535
+ const pinsContent = this.pinManager.format();
1536
+ if (pinsContent) {
1537
+ // Insert pins BEFORE the role ending (if present) so role reinforcement stays at the end
1546
1538
  const roleEndingMarker = '## YOUR ASSIGNED ROLE:';
1547
1539
  const roleEndingIndex = systemContent.indexOf(roleEndingMarker);
1548
1540
  if (roleEndingIndex > 0) {
1549
- // Insert anchors before the role ending
1541
+ // Insert pins before the role ending
1550
1542
  const beforeRole = systemContent.substring(0, roleEndingIndex);
1551
1543
  const roleEnding = systemContent.substring(roleEndingIndex);
1552
- systemContent = `${beforeRole}\n\n---\n\n## Active Anchors (Critical Information)\n\n${anchorsContent}\n\n---\n\n${roleEnding}`;
1544
+ systemContent = `${beforeRole}\n\n---\n\n## Pinned Context (Critical Information)\n\n${pinsContent}\n\n---\n\n${roleEnding}`;
1553
1545
  }
1554
1546
  else {
1555
- // No role ending, just append anchors
1556
- systemContent = `${systemContent}\n\n---\n\n## Active Anchors (Critical Information)\n\n${anchorsContent}`;
1547
+ // No role ending, just append pins
1548
+ systemContent = `${systemContent}\n\n---\n\n## Pinned Context (Critical Information)\n\n${pinsContent}`;
1557
1549
  }
1558
1550
  }
1559
1551
  }
@@ -2498,25 +2490,25 @@ export class Agent {
2498
2490
  * Generate a summary of messages using the LLM provider.
2499
2491
  * Used for context summarization when approaching limits.
2500
2492
  *
2501
- * If anchors are configured, the summary will prioritize keeping
2502
- * information related to anchor content (anchor-weighted summarization).
2493
+ * If pins are configured, the summary will prioritize keeping
2494
+ * information related to pinned content (pin-weighted summarization).
2503
2495
  */
2504
2496
  async generateSummary(messages) {
2505
- // Build anchor context if available (for weighted summarization)
2497
+ // Build pin context if available (for weighted summarization)
2506
2498
  let anchorContext = '';
2507
- if (this.anchorManager && this.anchorManager.size > 0) {
2508
- const anchors = this.anchorManager.getAll();
2509
- if (anchors.length > 0) {
2510
- const anchorItems = anchors.map((a) => `- [${a.priority}] ${a.content}`).join('\n');
2499
+ if (this.pinManager && this.pinManager.size > 0) {
2500
+ const pins = this.pinManager.getAll();
2501
+ if (pins.length > 0) {
2502
+ const pinItems = pins.map((a) => `- [${a.priority}] ${a.content}`).join('\n');
2511
2503
  anchorContext = `
2512
- ## PRIORITY CONTEXT (Anchors)
2504
+ ## PRIORITY CONTEXT (Pinned)
2513
2505
 
2514
- The following are critical anchors that should be preserved in context. When summarizing,
2515
- PRIORITIZE keeping information that relates to these anchors:
2506
+ The following are pinned items that should be preserved in context. When summarizing,
2507
+ PRIORITIZE keeping information that relates to these pins:
2516
2508
 
2517
- ${anchorItems}
2509
+ ${pinItems}
2518
2510
 
2519
- Ensure the summary captures any conversation details related to these anchors.
2511
+ Ensure the summary captures any conversation details related to these pinned items.
2520
2512
  `;
2521
2513
  }
2522
2514
  }
@@ -2525,7 +2517,7 @@ Ensure the summary captures any conversation details related to these anchors.
2525
2517
  2. Important context established
2526
2518
  3. Tasks completed or in progress
2527
2519
  4. Any relevant file paths or code snippets mentioned
2528
- ${anchorContext ? '5. Information related to the priority anchors listed below' : ''}
2520
+ ${anchorContext ? '5. Information related to the pinned priority items below' : ''}
2529
2521
  ${anchorContext}
2530
2522
  Keep the summary under 500 words.
2531
2523
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/agents",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "description": "Lightweight multi-LLM agent library for building CLI AI assistants",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",