( cfg: MagicContextConfig, hist: PiHistorianOptions | undefined, auto: PiAutoSearchHandlerOptions, )
| 661 | // cwd is pre-seeded with the already-loaded boot config. |
| 662 | const contextOptionsByDir = new Map<string, PiContextHandlerOptions>(); |
| 663 | const buildContextOptions = ( |
| 664 | cfg: MagicContextConfig, |
| 665 | hist: PiHistorianOptions | undefined, |
| 666 | auto: PiAutoSearchHandlerOptions, |
| 667 | ): PiContextHandlerOptions => ({ |
| 668 | db: database, |
| 669 | ctxReduceEnabled: cfg.ctx_reduce_enabled, |
| 670 | smartDrops: cfg.smart_drops === true, |
| 671 | protectedTags: cfg.protected_tags ?? 20, |
| 672 | heuristics: { |
| 673 | caveman: |
| 674 | cfg.ctx_reduce_enabled === false && cfg.caveman_text_compression |
| 675 | ? { |
| 676 | enabled: cfg.caveman_text_compression.enabled, |
| 677 | minChars: cfg.caveman_text_compression.min_chars, |
| 678 | } |
| 679 | : undefined, |
| 680 | clearReasoningAge: cfg.clear_reasoning_age, |
| 681 | }, |
| 682 | injection: { |
| 683 | memoryEnabled: cfg.memory.enabled, |
| 684 | injectDocs: cfg.dreamer?.inject_docs !== false, |
| 685 | injectionBudgetTokens: cfg.memory.injection_budget_tokens, |
| 686 | temporalAwareness: cfg.temporal_awareness === true, |
| 687 | }, |
| 688 | scheduler: { |
| 689 | executeThresholdPercentage: cfg.execute_threshold_percentage, |
| 690 | executeThresholdTokens: cfg.execute_threshold_tokens, |
| 691 | }, |
| 692 | historian: hist, |
| 693 | language: cfg.language, |
| 694 | autoSearch: auto, |
| 695 | resolveForProject: resolveContextOptionsForProject, |
| 696 | maybeAutoEmbedSession: (sessionId, dir, identity) => { |
| 697 | maybeAutoEmbedPiSession( |
| 698 | { |
| 699 | db: database, |
| 700 | projectDir: dir, |
| 701 | projectIdentity: identity, |
| 702 | memoryEnabled: cfg.memory.enabled, |
| 703 | }, |
| 704 | sessionId, |
| 705 | dir, |
| 706 | identity, |
| 707 | (text) => { |
| 708 | pi.sendMessage( |
| 709 | { |
| 710 | customType: "ctx-status", |
| 711 | content: text, |
| 712 | display: true, |
| 713 | } as never, |
| 714 | { triggerTurn: false }, |
| 715 | ); |
| 716 | }, |
| 717 | ); |
| 718 | }, |
| 719 | }); |
| 720 | function resolveContextOptionsForProject( |
no test coverage detected