@caupulican/pi-adaptative 0.80.86 → 0.80.88
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/CHANGELOG.md +149 -0
- package/dist/core/agent-session.d.ts +377 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1791 -41
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +4 -0
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -0
- package/dist/core/autonomy/approval-gate.js +27 -0
- package/dist/core/autonomy/approval-gate.js.map +1 -0
- package/dist/core/autonomy/bounded-completion.d.ts +27 -0
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -0
- package/dist/core/autonomy/bounded-completion.js +44 -0
- package/dist/core/autonomy/bounded-completion.js.map +1 -0
- package/dist/core/autonomy/contracts.d.ts +129 -0
- package/dist/core/autonomy/contracts.d.ts.map +1 -0
- package/dist/core/autonomy/contracts.js +2 -0
- package/dist/core/autonomy/contracts.js.map +1 -0
- package/dist/core/autonomy/gates.d.ts +15 -0
- package/dist/core/autonomy/gates.d.ts.map +1 -0
- package/dist/core/autonomy/gates.js +205 -0
- package/dist/core/autonomy/gates.js.map +1 -0
- package/dist/core/autonomy/lane-tracker.d.ts +48 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -0
- package/dist/core/autonomy/lane-tracker.js +125 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -0
- package/dist/core/autonomy/path-scope.d.ts +9 -0
- package/dist/core/autonomy/path-scope.d.ts.map +1 -0
- package/dist/core/autonomy/path-scope.js +122 -0
- package/dist/core/autonomy/path-scope.js.map +1 -0
- package/dist/core/autonomy/risk-assessment.d.ts +3 -0
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -0
- package/dist/core/autonomy/risk-assessment.js +122 -0
- package/dist/core/autonomy/risk-assessment.js.map +1 -0
- package/dist/core/autonomy/session-lane-record.d.ts +10 -0
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -0
- package/dist/core/autonomy/session-lane-record.js +36 -0
- package/dist/core/autonomy/session-lane-record.js.map +1 -0
- package/dist/core/autonomy/status.d.ts +40 -0
- package/dist/core/autonomy/status.d.ts.map +1 -0
- package/dist/core/autonomy/status.js +107 -0
- package/dist/core/autonomy/status.js.map +1 -0
- package/dist/core/autonomy/subagent-prompt.d.ts +21 -0
- package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -0
- package/dist/core/autonomy/subagent-prompt.js +28 -0
- package/dist/core/autonomy/subagent-prompt.js.map +1 -0
- package/dist/core/autonomy/telemetry-events.d.ts +18 -0
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -0
- package/dist/core/autonomy/telemetry-events.js +60 -0
- package/dist/core/autonomy/telemetry-events.js.map +1 -0
- package/dist/core/context/artifact-retrieval.d.ts +49 -0
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -0
- package/dist/core/context/artifact-retrieval.js +49 -0
- package/dist/core/context/artifact-retrieval.js.map +1 -0
- package/dist/core/context/context-artifacts.d.ts +94 -0
- package/dist/core/context/context-artifacts.d.ts.map +1 -0
- package/dist/core/context/context-artifacts.js +307 -0
- package/dist/core/context/context-artifacts.js.map +1 -0
- package/dist/core/context/context-audit.d.ts +66 -0
- package/dist/core/context/context-audit.d.ts.map +1 -0
- package/dist/core/context/context-audit.js +173 -0
- package/dist/core/context/context-audit.js.map +1 -0
- package/dist/core/context/context-item.d.ts +117 -0
- package/dist/core/context/context-item.d.ts.map +1 -0
- package/dist/core/context/context-item.js +36 -0
- package/dist/core/context/context-item.js.map +1 -0
- package/dist/core/context/context-prompt-enforcement.d.ts +73 -0
- package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -0
- package/dist/core/context/context-prompt-enforcement.js +153 -0
- package/dist/core/context/context-prompt-enforcement.js.map +1 -0
- package/dist/core/context/context-prompt-policy.d.ts +90 -0
- package/dist/core/context/context-prompt-policy.d.ts.map +1 -0
- package/dist/core/context/context-prompt-policy.js +73 -0
- package/dist/core/context/context-prompt-policy.js.map +1 -0
- package/dist/core/context/context-retention.d.ts +36 -0
- package/dist/core/context/context-retention.d.ts.map +1 -0
- package/dist/core/context/context-retention.js +108 -0
- package/dist/core/context/context-retention.js.map +1 -0
- package/dist/core/context/context-store.d.ts +37 -0
- package/dist/core/context/context-store.d.ts.map +1 -0
- package/dist/core/context/context-store.js +45 -0
- package/dist/core/context/context-store.js.map +1 -0
- package/dist/core/context/memory-diagnostics.d.ts +50 -0
- package/dist/core/context/memory-diagnostics.d.ts.map +1 -0
- package/dist/core/context/memory-diagnostics.js +43 -0
- package/dist/core/context/memory-diagnostics.js.map +1 -0
- package/dist/core/context/memory-index-store.d.ts +28 -0
- package/dist/core/context/memory-index-store.d.ts.map +1 -0
- package/dist/core/context/memory-index-store.js +38 -0
- package/dist/core/context/memory-index-store.js.map +1 -0
- package/dist/core/context/memory-prompt-block.d.ts +34 -0
- package/dist/core/context/memory-prompt-block.d.ts.map +1 -0
- package/dist/core/context/memory-prompt-block.js +58 -0
- package/dist/core/context/memory-prompt-block.js.map +1 -0
- package/dist/core/context/memory-provider-contract.d.ts +114 -0
- package/dist/core/context/memory-provider-contract.d.ts.map +1 -0
- package/dist/core/context/memory-provider-contract.js +121 -0
- package/dist/core/context/memory-provider-contract.js.map +1 -0
- package/dist/core/context/memory-retrieval.d.ts +27 -0
- package/dist/core/context/memory-retrieval.d.ts.map +1 -0
- package/dist/core/context/memory-retrieval.js +91 -0
- package/dist/core/context/memory-retrieval.js.map +1 -0
- package/dist/core/context/okf-memory-provider.d.ts +26 -0
- package/dist/core/context/okf-memory-provider.d.ts.map +1 -0
- package/dist/core/context/okf-memory-provider.js +154 -0
- package/dist/core/context/okf-memory-provider.js.map +1 -0
- package/dist/core/context/okf-memory.d.ts +42 -0
- package/dist/core/context/okf-memory.d.ts.map +1 -0
- package/dist/core/context/okf-memory.js +175 -0
- package/dist/core/context/okf-memory.js.map +1 -0
- package/dist/core/context/policy-engine.d.ts +66 -0
- package/dist/core/context/policy-engine.d.ts.map +1 -0
- package/dist/core/context/policy-engine.js +171 -0
- package/dist/core/context/policy-engine.js.map +1 -0
- package/dist/core/context/policy-types.d.ts +102 -0
- package/dist/core/context/policy-types.d.ts.map +1 -0
- package/dist/core/context/policy-types.js +7 -0
- package/dist/core/context/policy-types.js.map +1 -0
- package/dist/core/context/sqlite-runtime-index.d.ts +19 -0
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -0
- package/dist/core/context/sqlite-runtime-index.js +344 -0
- package/dist/core/context/sqlite-runtime-index.js.map +1 -0
- package/dist/core/context/storage-authority.d.ts +20 -0
- package/dist/core/context/storage-authority.d.ts.map +1 -0
- package/dist/core/context/storage-authority.js +51 -0
- package/dist/core/context/storage-authority.js.map +1 -0
- package/dist/core/context/tool-output-packer.d.ts +75 -0
- package/dist/core/context/tool-output-packer.d.ts.map +1 -0
- package/dist/core/context/tool-output-packer.js +77 -0
- package/dist/core/context/tool-output-packer.js.map +1 -0
- package/dist/core/cost/session-usage.d.ts +20 -0
- package/dist/core/cost/session-usage.d.ts.map +1 -0
- package/dist/core/cost/session-usage.js +164 -0
- package/dist/core/cost/session-usage.js.map +1 -0
- package/dist/core/delegation/session-worker-result.d.ts +10 -0
- package/dist/core/delegation/session-worker-result.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-result.js +36 -0
- package/dist/core/delegation/session-worker-result.js.map +1 -0
- package/dist/core/delegation/worker-result.d.ts +9 -0
- package/dist/core/delegation/worker-result.d.ts.map +1 -0
- package/dist/core/delegation/worker-result.js +152 -0
- package/dist/core/delegation/worker-result.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +58 -0
- package/dist/core/delegation/worker-runner.d.ts.map +1 -0
- package/dist/core/delegation/worker-runner.js +188 -0
- package/dist/core/delegation/worker-runner.js.map +1 -0
- package/dist/core/extensions/builtin.d.ts +5 -1
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +23 -1
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +5 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +13 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts +22 -0
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-continuation-controller.js +88 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts +10 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -0
- package/dist/core/goals/goal-continuation-defaults.js +10 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -0
- package/dist/core/goals/goal-continuation-prompt.d.ts +18 -0
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -0
- package/dist/core/goals/goal-continuation-prompt.js +141 -0
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +19 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.js +23 -0
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +87 -0
- package/dist/core/goals/goal-state.d.ts.map +1 -0
- package/dist/core/goals/goal-state.js +259 -0
- package/dist/core/goals/goal-state.js.map +1 -0
- package/dist/core/goals/goal-tool-core.d.ts +66 -0
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -0
- package/dist/core/goals/goal-tool-core.js +146 -0
- package/dist/core/goals/goal-tool-core.js.map +1 -0
- package/dist/core/goals/session-goal-state.d.ts +10 -0
- package/dist/core/goals/session-goal-state.d.ts.map +1 -0
- package/dist/core/goals/session-goal-state.js +35 -0
- package/dist/core/goals/session-goal-state.js.map +1 -0
- package/dist/core/learning/learning-audit.d.ts +45 -0
- package/dist/core/learning/learning-audit.d.ts.map +1 -0
- package/dist/core/learning/learning-audit.js +139 -0
- package/dist/core/learning/learning-audit.js.map +1 -0
- package/dist/core/learning/learning-gate.d.ts +29 -0
- package/dist/core/learning/learning-gate.d.ts.map +1 -0
- package/dist/core/learning/learning-gate.js +150 -0
- package/dist/core/learning/learning-gate.js.map +1 -0
- package/dist/core/learning/session-learning-decision.d.ts +10 -0
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -0
- package/dist/core/learning/session-learning-decision.js +36 -0
- package/dist/core/learning/session-learning-decision.js.map +1 -0
- package/dist/core/model-capability.d.ts +41 -0
- package/dist/core/model-capability.d.ts.map +1 -0
- package/dist/core/model-capability.js +101 -0
- package/dist/core/model-capability.js.map +1 -0
- package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
- package/dist/core/model-router/config-diagnostics.js +1 -0
- package/dist/core/model-router/config-diagnostics.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +2 -0
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +154 -9
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router/route-judge.d.ts +54 -0
- package/dist/core/model-router/route-judge.d.ts.map +1 -0
- package/dist/core/model-router/route-judge.js +128 -0
- package/dist/core/model-router/route-judge.js.map +1 -0
- package/dist/core/model-router/status.d.ts +4 -1
- package/dist/core/model-router/status.d.ts.map +1 -1
- package/dist/core/model-router/status.js +30 -6
- package/dist/core/model-router/status.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts +4 -6
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +1 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +40 -0
- package/dist/core/models/fitness-store.d.ts.map +1 -0
- package/dist/core/models/fitness-store.js +61 -0
- package/dist/core/models/fitness-store.js.map +1 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +1 -1
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +2 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +12 -4
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/research/automata-provider.d.ts +5 -0
- package/dist/core/research/automata-provider.d.ts.map +1 -0
- package/dist/core/research/automata-provider.js +15 -0
- package/dist/core/research/automata-provider.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts +10 -0
- package/dist/core/research/evidence-bundle.d.ts.map +1 -0
- package/dist/core/research/evidence-bundle.js +116 -0
- package/dist/core/research/evidence-bundle.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +79 -0
- package/dist/core/research/model-fitness.d.ts.map +1 -0
- package/dist/core/research/model-fitness.js +257 -0
- package/dist/core/research/model-fitness.js.map +1 -0
- package/dist/core/research/research-gate.d.ts +11 -0
- package/dist/core/research/research-gate.d.ts.map +1 -0
- package/dist/core/research/research-gate.js +82 -0
- package/dist/core/research/research-gate.js.map +1 -0
- package/dist/core/research/research-runner.d.ts +59 -0
- package/dist/core/research/research-runner.d.ts.map +1 -0
- package/dist/core/research/research-runner.js +155 -0
- package/dist/core/research/research-runner.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +11 -0
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -0
- package/dist/core/research/session-evidence-bundle.js +55 -0
- package/dist/core/research/session-evidence-bundle.js.map +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +4 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +147 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +285 -9
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +4 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +18 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/toolkit/script-registry.d.ts +34 -0
- package/dist/core/toolkit/script-registry.d.ts.map +1 -0
- package/dist/core/toolkit/script-registry.js +71 -0
- package/dist/core/toolkit/script-registry.js.map +1 -0
- package/dist/core/toolkit/script-runner.d.ts +28 -0
- package/dist/core/toolkit/script-runner.d.ts.map +1 -0
- package/dist/core/toolkit/script-runner.js +48 -0
- package/dist/core/toolkit/script-runner.js.map +1 -0
- package/dist/core/tools/artifact-retrieve.d.ts +23 -0
- package/dist/core/tools/artifact-retrieve.d.ts.map +1 -0
- package/dist/core/tools/artifact-retrieve.js +110 -0
- package/dist/core/tools/artifact-retrieve.js.map +1 -0
- package/dist/core/tools/delegate.d.ts +32 -0
- package/dist/core/tools/delegate.d.ts.map +1 -0
- package/dist/core/tools/delegate.js +60 -0
- package/dist/core/tools/delegate.js.map +1 -0
- package/dist/core/tools/fff-search-backend.d.ts +103 -0
- package/dist/core/tools/fff-search-backend.d.ts.map +1 -0
- package/dist/core/tools/fff-search-backend.js +151 -0
- package/dist/core/tools/fff-search-backend.js.map +1 -0
- package/dist/core/tools/find.d.ts +21 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +183 -10
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/goal.d.ts +35 -0
- package/dist/core/tools/goal.d.ts.map +1 -0
- package/dist/core/tools/goal.js +122 -0
- package/dist/core/tools/goal.js.map +1 -0
- package/dist/core/tools/grep.d.ts +21 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +272 -27
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +9 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +30 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -0
- package/dist/core/tools/model-fitness.js +38 -0
- package/dist/core/tools/model-fitness.js.map +1 -0
- package/dist/core/tools/run-toolkit-script.d.ts +24 -0
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -0
- package/dist/core/tools/run-toolkit-script.js +103 -0
- package/dist/core/tools/run-toolkit-script.js.map +1 -0
- package/dist/core/tools/search-router.d.ts +75 -0
- package/dist/core/tools/search-router.d.ts.map +1 -0
- package/dist/core/tools/search-router.js +85 -0
- package/dist/core/tools/search-router.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +18 -16
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +13 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +471 -11
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +217 -39
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +2 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +154 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +368 -12
- package/package.json +5 -4
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search backend router.
|
|
3
|
+
*
|
|
4
|
+
* The agent sees one stable tool interface (`find`, `grep`). Internally each tool
|
|
5
|
+
* can be served by more than one backend:
|
|
6
|
+
*
|
|
7
|
+
* - `fff`: the resident FFF index (in-process, ranked top-N, fuzzy file search),
|
|
8
|
+
* - `fallback`: the fd/rg subprocess path (exhaustive, forced ignore-case,
|
|
9
|
+
* fd/rg-native hierarchical `.gitignore` semantics).
|
|
10
|
+
*
|
|
11
|
+
* This module is the single, pure, auditable place that decides which backend a
|
|
12
|
+
* given call should use, based on the filters the agent supplied plus a few
|
|
13
|
+
* environment facts. It does no IO; callers gather facts and pass them in.
|
|
14
|
+
*
|
|
15
|
+
* Why route at all (measured, warm cache, synthetic corpora 8k-20k files):
|
|
16
|
+
*
|
|
17
|
+
* find, default limit 1000 : FFF 110-163ms vs fd 27-29ms -> fd wins
|
|
18
|
+
* find, small limit 50 : FFF 34-92ms vs fd 21-23ms -> fd wins
|
|
19
|
+
* grep, default limit 100 : FFF 46-92ms vs rg 26-27ms -> rg wins
|
|
20
|
+
* raw glob pageSize 20 : 5.6ms (12k files) -> FFF strong
|
|
21
|
+
* raw glob pageSize 20000: 778ms (12k files) -> FFF collapses
|
|
22
|
+
* raw fuzzy pageSize 20 : 7.5ms (fd cannot do fuzzy) -> FFF only
|
|
23
|
+
*
|
|
24
|
+
* The dominant factor is the requested result count: FFF is a ranked top-N engine
|
|
25
|
+
* and must score/sort the whole corpus when asked for a large page, which is its
|
|
26
|
+
* worst case and fd/rg's amortized best case. So the router keeps small top-N and
|
|
27
|
+
* fuzzy queries on FFF and sends exhaustive/forced-ignore-case/gitignore-tree
|
|
28
|
+
* queries to fd/rg. Thresholds are configurable so they can be retuned per
|
|
29
|
+
* environment with the benchmark suite instead of being hardcoded guesses.
|
|
30
|
+
*/
|
|
31
|
+
export const DEFAULT_SEARCH_ROUTER_THRESHOLDS = {
|
|
32
|
+
findMaxFffLimit: 20,
|
|
33
|
+
grepMaxFffLimit: 20,
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Pure routing decision. Fail-closed toward the fallback: any missing capability
|
|
37
|
+
* or unsupported filter routes to fd/rg, never silently to a backend that cannot
|
|
38
|
+
* honor the request. Order matters — the earliest matching guard wins so the
|
|
39
|
+
* reason code reflects the most fundamental reason FFF was rejected.
|
|
40
|
+
*/
|
|
41
|
+
export function routeSearchBackend(request, thresholds = DEFAULT_SEARCH_ROUTER_THRESHOLDS) {
|
|
42
|
+
if (!request.pathResolvable) {
|
|
43
|
+
return { backend: "fallback", reason: "path_unresolved" };
|
|
44
|
+
}
|
|
45
|
+
if (request.ignoreCase) {
|
|
46
|
+
// FFF exposes smart-case/case-sensitive modes but no forced ignore-case
|
|
47
|
+
// equivalent to `fd --ignore-case` / `rg --ignore-case`.
|
|
48
|
+
return { backend: "fallback", reason: "forced_ignore_case" };
|
|
49
|
+
}
|
|
50
|
+
const maxFff = request.tool === "find" ? thresholds.findMaxFffLimit : thresholds.grepMaxFffLimit;
|
|
51
|
+
if (request.tool === "find" && !request.glob) {
|
|
52
|
+
// Fuzzy ranked file search: the fd fallback cannot honor this filter at all,
|
|
53
|
+
// so FFF is the only backend that satisfies it. Still bounded so a pathological
|
|
54
|
+
// huge pull degrades to a normal exhaustive listing instead of scoring the
|
|
55
|
+
// entire corpus.
|
|
56
|
+
if (request.limit > maxFff)
|
|
57
|
+
return { backend: "fallback", reason: "exhaustive_limit" };
|
|
58
|
+
if (request.gitignoreInTree)
|
|
59
|
+
return { backend: "fallback", reason: "gitignore_semantics" };
|
|
60
|
+
if (!request.finderAvailable)
|
|
61
|
+
return { backend: "fallback", reason: "fff_unavailable" };
|
|
62
|
+
return { backend: "fff", reason: "fff_fuzzy_file_search" };
|
|
63
|
+
}
|
|
64
|
+
if (request.limit > maxFff) {
|
|
65
|
+
return { backend: "fallback", reason: "exhaustive_limit" };
|
|
66
|
+
}
|
|
67
|
+
if (request.gitignoreInTree) {
|
|
68
|
+
// FFF's `.gitignore` handling diverges from fd/rg's hierarchical, per-subtree
|
|
69
|
+
// semantics (see regression #3303), so defer to fd/rg when one is present.
|
|
70
|
+
return { backend: "fallback", reason: "gitignore_semantics" };
|
|
71
|
+
}
|
|
72
|
+
if (!request.finderAvailable) {
|
|
73
|
+
return { backend: "fallback", reason: "fff_unavailable" };
|
|
74
|
+
}
|
|
75
|
+
return { backend: "fff", reason: "fff_topn" };
|
|
76
|
+
}
|
|
77
|
+
/** Build a router bound to a fixed threshold set. */
|
|
78
|
+
export function createSearchRouter(thresholds = DEFAULT_SEARCH_ROUTER_THRESHOLDS) {
|
|
79
|
+
return {
|
|
80
|
+
route: (request) => routeSearchBackend(request, thresholds),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Default router used by the built-in `find`/`grep` tools when none is injected. */
|
|
84
|
+
export const defaultSearchRouter = createSearchRouter();
|
|
85
|
+
//# sourceMappingURL=search-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-router.js","sourceRoot":"","sources":["../../../src/core/tools/search-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA4CH,MAAM,CAAC,MAAM,gCAAgC,GAA2B;IACvE,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,EAAE;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,OAA2B,EAC3B,UAAU,GAA2B,gCAAgC,EAC/C;IACtB,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC3D,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,wEAAwE;QACxE,yDAAyD;QACzD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC9D,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC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AAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC;KAC3D,CAAC;AAAA,CACF;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,mBAAmB,GAAiB,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Search backend router.\n *\n * The agent sees one stable tool interface (`find`, `grep`). Internally each tool\n * can be served by more than one backend:\n *\n * - `fff`: the resident FFF index (in-process, ranked top-N, fuzzy file search),\n * - `fallback`: the fd/rg subprocess path (exhaustive, forced ignore-case,\n * fd/rg-native hierarchical `.gitignore` semantics).\n *\n * This module is the single, pure, auditable place that decides which backend a\n * given call should use, based on the filters the agent supplied plus a few\n * environment facts. It does no IO; callers gather facts and pass them in.\n *\n * Why route at all (measured, warm cache, synthetic corpora 8k-20k files):\n *\n * find, default limit 1000 : FFF 110-163ms vs fd 27-29ms -> fd wins\n * find, small limit 50 : FFF 34-92ms vs fd 21-23ms -> fd wins\n * grep, default limit 100 : FFF 46-92ms vs rg 26-27ms -> rg wins\n * raw glob pageSize 20 : 5.6ms (12k files) -> FFF strong\n * raw glob pageSize 20000: 778ms (12k files) -> FFF collapses\n * raw fuzzy pageSize 20 : 7.5ms (fd cannot do fuzzy) -> FFF only\n *\n * The dominant factor is the requested result count: FFF is a ranked top-N engine\n * and must score/sort the whole corpus when asked for a large page, which is its\n * worst case and fd/rg's amortized best case. So the router keeps small top-N and\n * fuzzy queries on FFF and sends exhaustive/forced-ignore-case/gitignore-tree\n * queries to fd/rg. Thresholds are configurable so they can be retuned per\n * environment with the benchmark suite instead of being hardcoded guesses.\n */\n\nexport type SearchBackend = \"fff\" | \"fallback\";\n\nexport type SearchToolKind = \"find\" | \"grep\";\n\nexport type SearchRouteReason =\n\t| \"fff_unavailable\"\n\t| \"path_unresolved\"\n\t| \"forced_ignore_case\"\n\t| \"gitignore_semantics\"\n\t| \"exhaustive_limit\"\n\t| \"fff_fuzzy_file_search\"\n\t| \"fff_topn\";\n\nexport interface SearchRouteRequest {\n\t/** Which built-in tool is routing. */\n\ttool: SearchToolKind;\n\t/** Filter: the request targets glob-style matching (find) rather than fuzzy file search. */\n\tglob: boolean;\n\t/** Filter: forced case-insensitive matching was requested. */\n\tignoreCase: boolean;\n\t/** Filter: maximum number of results the caller will keep. */\n\tlimit: number;\n\t/** Env fact: an FFF resident finder is usable for this cwd. */\n\tfinderAvailable: boolean;\n\t/** Env fact: the search path is inside the indexed cwd and exists. */\n\tpathResolvable: boolean;\n\t/** Env fact: a `.gitignore` exists under the search path. */\n\tgitignoreInTree: boolean;\n}\n\nexport interface SearchRouteDecision {\n\tbackend: SearchBackend;\n\treason: SearchRouteReason;\n}\n\nexport interface SearchRouterThresholds {\n\t/** Result limit at or below which `find` prefers the FFF top-N/fuzzy path. */\n\tfindMaxFffLimit: number;\n\t/** Result limit at or below which `grep` prefers the FFF top-N path. */\n\tgrepMaxFffLimit: number;\n}\n\nexport const DEFAULT_SEARCH_ROUTER_THRESHOLDS: SearchRouterThresholds = {\n\tfindMaxFffLimit: 20,\n\tgrepMaxFffLimit: 20,\n};\n\n/**\n * Pure routing decision. Fail-closed toward the fallback: any missing capability\n * or unsupported filter routes to fd/rg, never silently to a backend that cannot\n * honor the request. Order matters — the earliest matching guard wins so the\n * reason code reflects the most fundamental reason FFF was rejected.\n */\nexport function routeSearchBackend(\n\trequest: SearchRouteRequest,\n\tthresholds: SearchRouterThresholds = DEFAULT_SEARCH_ROUTER_THRESHOLDS,\n): SearchRouteDecision {\n\tif (!request.pathResolvable) {\n\t\treturn { backend: \"fallback\", reason: \"path_unresolved\" };\n\t}\n\tif (request.ignoreCase) {\n\t\t// FFF exposes smart-case/case-sensitive modes but no forced ignore-case\n\t\t// equivalent to `fd --ignore-case` / `rg --ignore-case`.\n\t\treturn { backend: \"fallback\", reason: \"forced_ignore_case\" };\n\t}\n\n\tconst maxFff = request.tool === \"find\" ? thresholds.findMaxFffLimit : thresholds.grepMaxFffLimit;\n\n\tif (request.tool === \"find\" && !request.glob) {\n\t\t// Fuzzy ranked file search: the fd fallback cannot honor this filter at all,\n\t\t// so FFF is the only backend that satisfies it. Still bounded so a pathological\n\t\t// huge pull degrades to a normal exhaustive listing instead of scoring the\n\t\t// entire corpus.\n\t\tif (request.limit > maxFff) return { backend: \"fallback\", reason: \"exhaustive_limit\" };\n\t\tif (request.gitignoreInTree) return { backend: \"fallback\", reason: \"gitignore_semantics\" };\n\t\tif (!request.finderAvailable) return { backend: \"fallback\", reason: \"fff_unavailable\" };\n\t\treturn { backend: \"fff\", reason: \"fff_fuzzy_file_search\" };\n\t}\n\n\tif (request.limit > maxFff) {\n\t\treturn { backend: \"fallback\", reason: \"exhaustive_limit\" };\n\t}\n\tif (request.gitignoreInTree) {\n\t\t// FFF's `.gitignore` handling diverges from fd/rg's hierarchical, per-subtree\n\t\t// semantics (see regression #3303), so defer to fd/rg when one is present.\n\t\treturn { backend: \"fallback\", reason: \"gitignore_semantics\" };\n\t}\n\tif (!request.finderAvailable) {\n\t\treturn { backend: \"fallback\", reason: \"fff_unavailable\" };\n\t}\n\n\treturn { backend: \"fff\", reason: \"fff_topn\" };\n}\n\nexport interface SearchRouter {\n\troute(request: SearchRouteRequest): SearchRouteDecision;\n}\n\n/** Build a router bound to a fixed threshold set. */\nexport function createSearchRouter(\n\tthresholds: SearchRouterThresholds = DEFAULT_SEARCH_ROUTER_THRESHOLDS,\n): SearchRouter {\n\treturn {\n\t\troute: (request) => routeSearchBackend(request, thresholds),\n\t};\n}\n\n/** Default router used by the built-in `find`/`grep` tools when none is injected. */\nexport const defaultSearchRouter: SearchRouter = createSearchRouter();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,oBAAoB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAqFxF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYhF;AAoBD,qBAAa,eAAgB,YAAW,SAAS;IAChD,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,aAAa,CAAC,CAAsB;IAE5C,YAAY,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,0BAA0B,EAGxE;IAED,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAGtC;IAED,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5C;IAED;;OAEG;IACH,UAAU,IAAI,IAAI,CAEjB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CAEd;IAED,OAAO,CAAC,gBAAgB;IAsDxB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA2J9B;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@caupulican/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\nfunction stripAnsi(text: string): string {\n\treturn text.replace(/\\u001b\\[[0-?]*[ -/]*[@-~]/g, \"\");\n}\n\nfunction normalizeLearningPhase(phase: string): string {\n\tconst normalized = phase\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_-]+/g, \"\")\n\t\t.trim();\n\tif (!normalized) return \"active\";\n\tif (normalized === \"starting\") return \"start\";\n\tif (normalized === \"mapping\") return \"map\";\n\tif (normalized === \"scanning\") return \"scan\";\n\tif (normalized === \"auditing\") return \"audit\";\n\tif (normalized === \"learning\") return \"run\";\n\tif (normalized === \"pruning\") return \"prune\";\n\treturn normalized.slice(0, 16);\n}\n\nfunction formatExtensionStatuses(statuses: ReadonlyMap<string, string>): string[] {\n\tconst regularStatuses: string[] = [];\n\tconst learningPhases = new Set<string>();\n\tlet sawLearningStatus = false;\n\n\tfor (const [key, rawText] of Array.from(statuses.entries()).sort(([a], [b]) => a.localeCompare(b))) {\n\t\tconst text = sanitizeStatusText(rawText);\n\t\tconst plain = stripAnsi(text).trim();\n\t\tconst plainLower = plain.toLowerCase();\n\t\tlet phase: string | undefined;\n\n\t\tif (plainLower.startsWith(\"(learning)\")) {\n\t\t\tphase = plain.slice(\"(learning)\".length).trim();\n\t\t} else if (plainLower === \"learning\") {\n\t\t\tphase = \"active\";\n\t\t} else if (/^learn(?:ing)?\\s*[: ]/.test(plainLower)) {\n\t\t\tphase = plain.replace(/^learn(?:ing)?\\s*[: ]/i, \"\").trim();\n\t\t}\n\n\t\tif (phase !== undefined) {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(normalizeLearningPhase(phase));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (key === \"auto-learn\" || key === \"continuous-learning\") {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(\"active\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tregularStatuses.push(text);\n\t}\n\n\tif (!sawLearningStatus) return regularStatuses;\n\tconst phases = Array.from(learningPhases).filter((phase) => phase !== \"active\");\n\tconst phaseText = phases.length > 0 ? phases.join(\"/\") : \"active\";\n\treturn [theme.fg(\"warning\", \"learn\") + theme.fg(\"dim\", `:${phaseText}`), ...regularStatuses];\n}\n\n/**\n * Format token counts for compact footer display.\n */\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\ntype FooterUsageSnapshot = {\n\tentryCount: number;\n\tmessageCount: number;\n\ttotalInput: number;\n\ttotalOutput: number;\n\ttotalCacheRead: number;\n\ttotalCacheWrite: number;\n\ttotalCost: number;\n\t/** Rolled-up cost of spawned/subagent sessions (Cost Aggregation). 0 when none. */\n\ttotalSpawnedCost: number;\n\tdailyTotalCost: number;\n\tcontextUsage: ReturnType<AgentSession[\"getContextUsage\"]>;\n};\n\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate usageSnapshot?: FooterUsageSnapshot;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * Invalidate cached footer stats when session state changes.\n\t */\n\tinvalidate(): void {\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\tprivate getUsageSnapshot(messageCount: number): FooterUsageSnapshot {\n\t\tconst sessionManager = this.session.sessionManager as AgentSession[\"sessionManager\"] & {\n\t\t\tgetEntryCount?: () => number;\n\t\t};\n\t\tconst entryCount = sessionManager.getEntryCount?.() ?? sessionManager.getEntries().length;\n\t\tconst cached = this.usageSnapshot;\n\t\tif (cached && cached.entryCount === entryCount && cached.messageCount === messageCount) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries in one batched pass.\n\t\t// This avoids per-frame defensive array allocation when only the TUI redraws.\n\t\tlet totalInput = 0;\n\t\tlet totalOutput = 0;\n\t\tlet totalCacheRead = 0;\n\t\tlet totalCacheWrite = 0;\n\t\tlet totalCost = 0;\n\n\t\tconst entries = this.session.sessionManager.getEntries();\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst entry = entries[i];\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = entry.message.usage;\n\t\t\tif (!usage) continue;\n\t\t\ttotalInput += usage.input;\n\t\t\ttotalOutput += usage.output;\n\t\t\ttotalCacheRead += usage.cacheRead;\n\t\t\ttotalCacheWrite += usage.cacheWrite;\n\t\t\ttotalCost += usage.cost.total;\n\t\t}\n\n\t\t// Roll up spawned/subagent cost (Cost Aggregation, Model A). Derived from the same\n\t\t// session entries, so the {entryCount} cache key above busts when new reports land.\n\t\tconst totalSpawnedCost = this.session.getSpawnedUsage().cost;\n\t\tconst dailyTotalCost = this.session.getDailyUsageTotals?.().totalCost ?? 0;\n\n\t\tconst snapshot: FooterUsageSnapshot = {\n\t\t\tentryCount,\n\t\t\tmessageCount,\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\t\tcontextUsage: this.session.getContextUsage(),\n\t\t};\n\t\tthis.usageSnapshot = snapshot;\n\t\treturn snapshot;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.session.state;\n\t\tconst usageSnapshot = this.getUsageSnapshot(state.messages?.length ?? 0);\n\t\tconst {\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\tcontextUsage,\n\t\t} = usageSnapshot;\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.session.sessionManager.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.session.sessionManager.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (totalInput) statsParts.push(`↑${formatTokens(totalInput)}`);\n\t\tif (totalOutput) statsParts.push(`↓${formatTokens(totalOutput)}`);\n\t\tif (totalCacheRead) statsParts.push(`R${formatTokens(totalCacheRead)}`);\n\t\tif (totalCacheWrite) statsParts.push(`W${formatTokens(totalCacheWrite)}`);\n\n\t\t// Show cost with \"(sub)\" indicator if using OAuth subscription\n\t\tconst usingSubscription = state.model ? this.session.modelRegistry.isUsingOAuth(state.model) : false;\n\t\tif (totalCost || totalSpawnedCost || usingSubscription) {\n\t\t\t// Main cost, then the spawned/subagent roll-up: `$0.842 (sub) (+$0.310 sub)`.\n\t\t\tlet costStr = `$${totalCost.toFixed(3)}${usingSubscription ? \" (sub)\" : \"\"}`;\n\t\t\tif (totalSpawnedCost) {\n\t\t\t\tcostStr += ` (+$${totalSpawnedCost.toFixed(3)} sub)`;\n\t\t\t}\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\t\tif (dailyTotalCost) {\n\t\t\tstatsParts.push(`day:$${dailyTotalCost.toFixed(3)}`);\n\t\t}\n\n\t\t// Proactive cost-guard warning (#34): when the projected per-turn cost crosses the ceiling,\n\t\t// surface a visible notice so an expensive turn never sneaks by. Warn-only — no silent action.\n\t\tconst costGuard = this.session.getLastCostGuardDecision?.();\n\t\tif (costGuard?.over) {\n\t\t\tstatsParts.push(theme.fg(\"warning\", `⚠$${costGuard.estUsd.toFixed(2)}/turn`));\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst autoIndicator = this.autoCompactEnabled ? \" (auto)\" : \"\";\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}${autoIndicator}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model display name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.name || state.model?.id || \"no-model\";\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\" ? `${modelName} • thinking off` : `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add extension statuses on a single line. Learning-related statuses are\n\t\t// folded into one compact chip so independent learning systems do not render\n\t\t// brittle duplicates like \"(learning) (learning) auto\".\n\t\tconst extensionStatuses = this.footerData.getExtensionStatuses();\n\t\tif (extensionStatuses.size > 0) {\n\t\t\tconst statusLine = formatExtensionStatuses(extensionStatuses).join(\" \");\n\t\t\tif (statusLine) {\n\t\t\t\t// Truncate to terminal width with dim ellipsis for consistency with footer style\n\t\t\t\tlines.push(truncateToWidth(statusLine, width, theme.fg(\"dim\", \"...\")));\n\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,oBAAoB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAqFxF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYhF;AAoBD,qBAAa,eAAgB,YAAW,SAAS;IAChD,OAAO,CAAC,kBAAkB,CAAQ;IAClC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,aAAa,CAAC,CAAsB;IAE5C,YAAY,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,0BAA0B,EAGxE;IAED,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAGtC;IAED,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5C;IAED;;OAEG;IACH,UAAU,IAAI,IAAI,CAEjB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CAEd;IAED,OAAO,CAAC,gBAAgB;IAsDxB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA8J9B;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@caupulican/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\nfunction stripAnsi(text: string): string {\n\treturn text.replace(/\\u001b\\[[0-?]*[ -/]*[@-~]/g, \"\");\n}\n\nfunction normalizeLearningPhase(phase: string): string {\n\tconst normalized = phase\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_-]+/g, \"\")\n\t\t.trim();\n\tif (!normalized) return \"active\";\n\tif (normalized === \"starting\") return \"start\";\n\tif (normalized === \"mapping\") return \"map\";\n\tif (normalized === \"scanning\") return \"scan\";\n\tif (normalized === \"auditing\") return \"audit\";\n\tif (normalized === \"learning\") return \"run\";\n\tif (normalized === \"pruning\") return \"prune\";\n\treturn normalized.slice(0, 16);\n}\n\nfunction formatExtensionStatuses(statuses: ReadonlyMap<string, string>): string[] {\n\tconst regularStatuses: string[] = [];\n\tconst learningPhases = new Set<string>();\n\tlet sawLearningStatus = false;\n\n\tfor (const [key, rawText] of Array.from(statuses.entries()).sort(([a], [b]) => a.localeCompare(b))) {\n\t\tconst text = sanitizeStatusText(rawText);\n\t\tconst plain = stripAnsi(text).trim();\n\t\tconst plainLower = plain.toLowerCase();\n\t\tlet phase: string | undefined;\n\n\t\tif (plainLower.startsWith(\"(learning)\")) {\n\t\t\tphase = plain.slice(\"(learning)\".length).trim();\n\t\t} else if (plainLower === \"learning\") {\n\t\t\tphase = \"active\";\n\t\t} else if (/^learn(?:ing)?\\s*[: ]/.test(plainLower)) {\n\t\t\tphase = plain.replace(/^learn(?:ing)?\\s*[: ]/i, \"\").trim();\n\t\t}\n\n\t\tif (phase !== undefined) {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(normalizeLearningPhase(phase));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (key === \"auto-learn\" || key === \"continuous-learning\") {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(\"active\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tregularStatuses.push(text);\n\t}\n\n\tif (!sawLearningStatus) return regularStatuses;\n\tconst phases = Array.from(learningPhases).filter((phase) => phase !== \"active\");\n\tconst phaseText = phases.length > 0 ? phases.join(\"/\") : \"active\";\n\treturn [theme.fg(\"warning\", \"learn\") + theme.fg(\"dim\", `:${phaseText}`), ...regularStatuses];\n}\n\n/**\n * Format token counts for compact footer display.\n */\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\ntype FooterUsageSnapshot = {\n\tentryCount: number;\n\tmessageCount: number;\n\ttotalInput: number;\n\ttotalOutput: number;\n\ttotalCacheRead: number;\n\ttotalCacheWrite: number;\n\ttotalCost: number;\n\t/** Rolled-up cost of spawned/subagent sessions (Cost Aggregation). 0 when none. */\n\ttotalSpawnedCost: number;\n\tdailyTotalCost: number;\n\tcontextUsage: ReturnType<AgentSession[\"getContextUsage\"]>;\n};\n\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate usageSnapshot?: FooterUsageSnapshot;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * Invalidate cached footer stats when session state changes.\n\t */\n\tinvalidate(): void {\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\tprivate getUsageSnapshot(messageCount: number): FooterUsageSnapshot {\n\t\tconst sessionManager = this.session.sessionManager as AgentSession[\"sessionManager\"] & {\n\t\t\tgetEntryCount?: () => number;\n\t\t};\n\t\tconst entryCount = sessionManager.getEntryCount?.() ?? sessionManager.getEntries().length;\n\t\tconst cached = this.usageSnapshot;\n\t\tif (cached && cached.entryCount === entryCount && cached.messageCount === messageCount) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries in one batched pass.\n\t\t// This avoids per-frame defensive array allocation when only the TUI redraws.\n\t\tlet totalInput = 0;\n\t\tlet totalOutput = 0;\n\t\tlet totalCacheRead = 0;\n\t\tlet totalCacheWrite = 0;\n\t\tlet totalCost = 0;\n\n\t\tconst entries = this.session.sessionManager.getEntries();\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst entry = entries[i];\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = entry.message.usage;\n\t\t\tif (!usage) continue;\n\t\t\ttotalInput += usage.input;\n\t\t\ttotalOutput += usage.output;\n\t\t\ttotalCacheRead += usage.cacheRead;\n\t\t\ttotalCacheWrite += usage.cacheWrite;\n\t\t\ttotalCost += usage.cost.total;\n\t\t}\n\n\t\t// Roll up spawned/subagent cost (Cost Aggregation, Model A). Derived from the same\n\t\t// session entries, so the {entryCount} cache key above busts when new reports land.\n\t\tconst totalSpawnedCost = this.session.getSpawnedUsage().cost;\n\t\tconst dailyTotalCost = this.session.getDailyUsageTotals?.().totalCost ?? 0;\n\n\t\tconst snapshot: FooterUsageSnapshot = {\n\t\t\tentryCount,\n\t\t\tmessageCount,\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\t\tcontextUsage: this.session.getContextUsage(),\n\t\t};\n\t\tthis.usageSnapshot = snapshot;\n\t\treturn snapshot;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.session.state;\n\t\tconst usageSnapshot = this.getUsageSnapshot(state.messages?.length ?? 0);\n\t\tconst {\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\tcontextUsage,\n\t\t} = usageSnapshot;\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.session.sessionManager.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.session.sessionManager.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (totalInput) statsParts.push(`↑${formatTokens(totalInput)}`);\n\t\tif (totalOutput) statsParts.push(`↓${formatTokens(totalOutput)}`);\n\t\tif (totalCacheRead) statsParts.push(`R${formatTokens(totalCacheRead)}`);\n\t\tif (totalCacheWrite) statsParts.push(`W${formatTokens(totalCacheWrite)}`);\n\n\t\t// Show cost with \"(sub)\" indicator if using OAuth subscription\n\t\tconst usingSubscription = state.model ? this.session.modelRegistry.isUsingOAuth(state.model) : false;\n\t\tconst grandTotalCost = totalCost + totalSpawnedCost;\n\t\tif (grandTotalCost || usingSubscription) {\n\t\t\tconst costStr = `$${grandTotalCost.toFixed(3)}${usingSubscription ? \" (sub)\" : \"\"}`;\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\t\tif (dailyTotalCost) {\n\t\t\tstatsParts.push(`day:$${dailyTotalCost.toFixed(3)}`);\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst autoIndicator = this.autoCompactEnabled ? \" (auto)\" : \"\";\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}${autoIndicator}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model display name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.name || state.model?.id || \"no-model\";\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\" ? `${modelName} • thinking off` : `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add extension statuses on a single line. Learning-related statuses are\n\t\t// folded into one compact chip so independent learning systems do not render\n\t\t// brittle duplicates like \"(learning) (learning) auto\".\n\t\tconst extensionStatuses = this.footerData.getExtensionStatuses();\n\t\tconst autonomyStatus = this.footerData.getAutonomyStatus();\n\n\t\tconst statusParts: string[] = [];\n\t\tif (autonomyStatus) {\n\t\t\tconst sanitizedAutonomyStatus = sanitizeStatusText(autonomyStatus);\n\t\t\tif (sanitizedAutonomyStatus) {\n\t\t\t\tstatusParts.push(sanitizedAutonomyStatus);\n\t\t\t}\n\t\t}\n\t\tif (extensionStatuses.size > 0) {\n\t\t\tconst extLine = formatExtensionStatuses(extensionStatuses).join(\" \");\n\t\t\tif (extLine) {\n\t\t\t\tstatusParts.push(extLine);\n\t\t\t}\n\t\t}\n\n\t\tif (statusParts.length > 0) {\n\t\t\tconst statusLine = statusParts.join(\" \");\n\t\t\tlines.push(truncateToWidth(statusLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
@@ -207,23 +207,14 @@ export class FooterComponent {
|
|
|
207
207
|
statsParts.push(`W${formatTokens(totalCacheWrite)}`);
|
|
208
208
|
// Show cost with "(sub)" indicator if using OAuth subscription
|
|
209
209
|
const usingSubscription = state.model ? this.session.modelRegistry.isUsingOAuth(state.model) : false;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (totalSpawnedCost) {
|
|
214
|
-
costStr += ` (+$${totalSpawnedCost.toFixed(3)} sub)`;
|
|
215
|
-
}
|
|
210
|
+
const grandTotalCost = totalCost + totalSpawnedCost;
|
|
211
|
+
if (grandTotalCost || usingSubscription) {
|
|
212
|
+
const costStr = `$${grandTotalCost.toFixed(3)}${usingSubscription ? " (sub)" : ""}`;
|
|
216
213
|
statsParts.push(costStr);
|
|
217
214
|
}
|
|
218
215
|
if (dailyTotalCost) {
|
|
219
216
|
statsParts.push(`day:$${dailyTotalCost.toFixed(3)}`);
|
|
220
217
|
}
|
|
221
|
-
// Proactive cost-guard warning (#34): when the projected per-turn cost crosses the ceiling,
|
|
222
|
-
// surface a visible notice so an expensive turn never sneaks by. Warn-only — no silent action.
|
|
223
|
-
const costGuard = this.session.getLastCostGuardDecision?.();
|
|
224
|
-
if (costGuard?.over) {
|
|
225
|
-
statsParts.push(theme.fg("warning", `⚠$${costGuard.estUsd.toFixed(2)}/turn`));
|
|
226
|
-
}
|
|
227
218
|
// Colorize context percentage based on usage
|
|
228
219
|
let contextPercentStr;
|
|
229
220
|
const autoIndicator = this.autoCompactEnabled ? " (auto)" : "";
|
|
@@ -301,13 +292,24 @@ export class FooterComponent {
|
|
|
301
292
|
// folded into one compact chip so independent learning systems do not render
|
|
302
293
|
// brittle duplicates like "(learning) (learning) auto".
|
|
303
294
|
const extensionStatuses = this.footerData.getExtensionStatuses();
|
|
295
|
+
const autonomyStatus = this.footerData.getAutonomyStatus();
|
|
296
|
+
const statusParts = [];
|
|
297
|
+
if (autonomyStatus) {
|
|
298
|
+
const sanitizedAutonomyStatus = sanitizeStatusText(autonomyStatus);
|
|
299
|
+
if (sanitizedAutonomyStatus) {
|
|
300
|
+
statusParts.push(sanitizedAutonomyStatus);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
304
303
|
if (extensionStatuses.size > 0) {
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
lines.push(truncateToWidth(statusLine, width, theme.fg("dim", "...")));
|
|
304
|
+
const extLine = formatExtensionStatuses(extensionStatuses).join(" ");
|
|
305
|
+
if (extLine) {
|
|
306
|
+
statusParts.push(extLine);
|
|
309
307
|
}
|
|
310
308
|
}
|
|
309
|
+
if (statusParts.length > 0) {
|
|
310
|
+
const statusLine = statusParts.join(" ");
|
|
311
|
+
lines.push(truncateToWidth(statusLine, width, theme.fg("dim", "...")));
|
|
312
|
+
}
|
|
311
313
|
return lines;
|
|
312
314
|
}
|
|
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AC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB;QAC3E,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAEhD,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACrF,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC;QAErD,yEAAyE;QACzE,6EAA6E;QAC7E,wDAAwD;QACxD,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC;QACjE,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACxE,IAAI,UAAU,EAAE,CAAC;gBAChB,iFAAiF;gBACjF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACxE,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@caupulican/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\nfunction stripAnsi(text: string): string {\n\treturn text.replace(/\\u001b\\[[0-?]*[ -/]*[@-~]/g, \"\");\n}\n\nfunction normalizeLearningPhase(phase: string): string {\n\tconst normalized = phase\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_-]+/g, \"\")\n\t\t.trim();\n\tif (!normalized) return \"active\";\n\tif (normalized === \"starting\") return \"start\";\n\tif (normalized === \"mapping\") return \"map\";\n\tif (normalized === \"scanning\") return \"scan\";\n\tif (normalized === \"auditing\") return \"audit\";\n\tif (normalized === \"learning\") return \"run\";\n\tif (normalized === \"pruning\") return \"prune\";\n\treturn normalized.slice(0, 16);\n}\n\nfunction formatExtensionStatuses(statuses: ReadonlyMap<string, string>): string[] {\n\tconst regularStatuses: string[] = [];\n\tconst learningPhases = new Set<string>();\n\tlet sawLearningStatus = false;\n\n\tfor (const [key, rawText] of Array.from(statuses.entries()).sort(([a], [b]) => a.localeCompare(b))) {\n\t\tconst text = sanitizeStatusText(rawText);\n\t\tconst plain = stripAnsi(text).trim();\n\t\tconst plainLower = plain.toLowerCase();\n\t\tlet phase: string | undefined;\n\n\t\tif (plainLower.startsWith(\"(learning)\")) {\n\t\t\tphase = plain.slice(\"(learning)\".length).trim();\n\t\t} else if (plainLower === \"learning\") {\n\t\t\tphase = \"active\";\n\t\t} else if (/^learn(?:ing)?\\s*[: ]/.test(plainLower)) {\n\t\t\tphase = plain.replace(/^learn(?:ing)?\\s*[: ]/i, \"\").trim();\n\t\t}\n\n\t\tif (phase !== undefined) {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(normalizeLearningPhase(phase));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (key === \"auto-learn\" || key === \"continuous-learning\") {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(\"active\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tregularStatuses.push(text);\n\t}\n\n\tif (!sawLearningStatus) return regularStatuses;\n\tconst phases = Array.from(learningPhases).filter((phase) => phase !== \"active\");\n\tconst phaseText = phases.length > 0 ? phases.join(\"/\") : \"active\";\n\treturn [theme.fg(\"warning\", \"learn\") + theme.fg(\"dim\", `:${phaseText}`), ...regularStatuses];\n}\n\n/**\n * Format token counts for compact footer display.\n */\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\ntype FooterUsageSnapshot = {\n\tentryCount: number;\n\tmessageCount: number;\n\ttotalInput: number;\n\ttotalOutput: number;\n\ttotalCacheRead: number;\n\ttotalCacheWrite: number;\n\ttotalCost: number;\n\t/** Rolled-up cost of spawned/subagent sessions (Cost Aggregation). 0 when none. */\n\ttotalSpawnedCost: number;\n\tdailyTotalCost: number;\n\tcontextUsage: ReturnType<AgentSession[\"getContextUsage\"]>;\n};\n\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate usageSnapshot?: FooterUsageSnapshot;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * Invalidate cached footer stats when session state changes.\n\t */\n\tinvalidate(): void {\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\tprivate getUsageSnapshot(messageCount: number): FooterUsageSnapshot {\n\t\tconst sessionManager = this.session.sessionManager as AgentSession[\"sessionManager\"] & {\n\t\t\tgetEntryCount?: () => number;\n\t\t};\n\t\tconst entryCount = sessionManager.getEntryCount?.() ?? sessionManager.getEntries().length;\n\t\tconst cached = this.usageSnapshot;\n\t\tif (cached && cached.entryCount === entryCount && cached.messageCount === messageCount) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries in one batched pass.\n\t\t// This avoids per-frame defensive array allocation when only the TUI redraws.\n\t\tlet totalInput = 0;\n\t\tlet totalOutput = 0;\n\t\tlet totalCacheRead = 0;\n\t\tlet totalCacheWrite = 0;\n\t\tlet totalCost = 0;\n\n\t\tconst entries = this.session.sessionManager.getEntries();\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst entry = entries[i];\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = entry.message.usage;\n\t\t\tif (!usage) continue;\n\t\t\ttotalInput += usage.input;\n\t\t\ttotalOutput += usage.output;\n\t\t\ttotalCacheRead += usage.cacheRead;\n\t\t\ttotalCacheWrite += usage.cacheWrite;\n\t\t\ttotalCost += usage.cost.total;\n\t\t}\n\n\t\t// Roll up spawned/subagent cost (Cost Aggregation, Model A). Derived from the same\n\t\t// session entries, so the {entryCount} cache key above busts when new reports land.\n\t\tconst totalSpawnedCost = this.session.getSpawnedUsage().cost;\n\t\tconst dailyTotalCost = this.session.getDailyUsageTotals?.().totalCost ?? 0;\n\n\t\tconst snapshot: FooterUsageSnapshot = {\n\t\t\tentryCount,\n\t\t\tmessageCount,\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\t\tcontextUsage: this.session.getContextUsage(),\n\t\t};\n\t\tthis.usageSnapshot = snapshot;\n\t\treturn snapshot;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.session.state;\n\t\tconst usageSnapshot = this.getUsageSnapshot(state.messages?.length ?? 0);\n\t\tconst {\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\tcontextUsage,\n\t\t} = usageSnapshot;\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.session.sessionManager.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.session.sessionManager.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (totalInput) statsParts.push(`↑${formatTokens(totalInput)}`);\n\t\tif (totalOutput) statsParts.push(`↓${formatTokens(totalOutput)}`);\n\t\tif (totalCacheRead) statsParts.push(`R${formatTokens(totalCacheRead)}`);\n\t\tif (totalCacheWrite) statsParts.push(`W${formatTokens(totalCacheWrite)}`);\n\n\t\t// Show cost with \"(sub)\" indicator if using OAuth subscription\n\t\tconst usingSubscription = state.model ? this.session.modelRegistry.isUsingOAuth(state.model) : false;\n\t\tif (totalCost || totalSpawnedCost || usingSubscription) {\n\t\t\t// Main cost, then the spawned/subagent roll-up: `$0.842 (sub) (+$0.310 sub)`.\n\t\t\tlet costStr = `$${totalCost.toFixed(3)}${usingSubscription ? \" (sub)\" : \"\"}`;\n\t\t\tif (totalSpawnedCost) {\n\t\t\t\tcostStr += ` (+$${totalSpawnedCost.toFixed(3)} sub)`;\n\t\t\t}\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\t\tif (dailyTotalCost) {\n\t\t\tstatsParts.push(`day:$${dailyTotalCost.toFixed(3)}`);\n\t\t}\n\n\t\t// Proactive cost-guard warning (#34): when the projected per-turn cost crosses the ceiling,\n\t\t// surface a visible notice so an expensive turn never sneaks by. Warn-only — no silent action.\n\t\tconst costGuard = this.session.getLastCostGuardDecision?.();\n\t\tif (costGuard?.over) {\n\t\t\tstatsParts.push(theme.fg(\"warning\", `⚠$${costGuard.estUsd.toFixed(2)}/turn`));\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst autoIndicator = this.autoCompactEnabled ? \" (auto)\" : \"\";\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}${autoIndicator}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model display name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.name || state.model?.id || \"no-model\";\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\" ? `${modelName} • thinking off` : `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add extension statuses on a single line. Learning-related statuses are\n\t\t// folded into one compact chip so independent learning systems do not render\n\t\t// brittle duplicates like \"(learning) (learning) auto\".\n\t\tconst extensionStatuses = this.footerData.getExtensionStatuses();\n\t\tif (extensionStatuses.size > 0) {\n\t\t\tconst statusLine = formatExtensionStatuses(extensionStatuses).join(\" \");\n\t\t\tif (statusLine) {\n\t\t\t\t// Truncate to terminal width with dim ellipsis for consistency with footer style\n\t\t\t\tlines.push(truncateToWidth(statusLine, width, theme.fg(\"dim\", \"...\")));\n\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../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C7E,wDAAwD;QACxD,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC;QACjE,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAE3D,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,IAAI,cAAc,EAAE,CAAC;YACpB,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;YACnE,IAAI,uBAAuB,EAAE,CAAC;gBAC7B,WAAW,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;QACD,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrE,IAAI,OAAO,EAAE,CAAC;gBACb,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACF,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { type Component, truncateToWidth, visibleWidth } from \"@caupulican/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.ts\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { theme } from \"../theme/theme.ts\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\nfunction stripAnsi(text: string): string {\n\treturn text.replace(/\\u001b\\[[0-?]*[ -/]*[@-~]/g, \"\");\n}\n\nfunction normalizeLearningPhase(phase: string): string {\n\tconst normalized = phase\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_-]+/g, \"\")\n\t\t.trim();\n\tif (!normalized) return \"active\";\n\tif (normalized === \"starting\") return \"start\";\n\tif (normalized === \"mapping\") return \"map\";\n\tif (normalized === \"scanning\") return \"scan\";\n\tif (normalized === \"auditing\") return \"audit\";\n\tif (normalized === \"learning\") return \"run\";\n\tif (normalized === \"pruning\") return \"prune\";\n\treturn normalized.slice(0, 16);\n}\n\nfunction formatExtensionStatuses(statuses: ReadonlyMap<string, string>): string[] {\n\tconst regularStatuses: string[] = [];\n\tconst learningPhases = new Set<string>();\n\tlet sawLearningStatus = false;\n\n\tfor (const [key, rawText] of Array.from(statuses.entries()).sort(([a], [b]) => a.localeCompare(b))) {\n\t\tconst text = sanitizeStatusText(rawText);\n\t\tconst plain = stripAnsi(text).trim();\n\t\tconst plainLower = plain.toLowerCase();\n\t\tlet phase: string | undefined;\n\n\t\tif (plainLower.startsWith(\"(learning)\")) {\n\t\t\tphase = plain.slice(\"(learning)\".length).trim();\n\t\t} else if (plainLower === \"learning\") {\n\t\t\tphase = \"active\";\n\t\t} else if (/^learn(?:ing)?\\s*[: ]/.test(plainLower)) {\n\t\t\tphase = plain.replace(/^learn(?:ing)?\\s*[: ]/i, \"\").trim();\n\t\t}\n\n\t\tif (phase !== undefined) {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(normalizeLearningPhase(phase));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (key === \"auto-learn\" || key === \"continuous-learning\") {\n\t\t\tsawLearningStatus = true;\n\t\t\tlearningPhases.add(\"active\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tregularStatuses.push(text);\n\t}\n\n\tif (!sawLearningStatus) return regularStatuses;\n\tconst phases = Array.from(learningPhases).filter((phase) => phase !== \"active\");\n\tconst phaseText = phases.length > 0 ? phases.join(\"/\") : \"active\";\n\treturn [theme.fg(\"warning\", \"learn\") + theme.fg(\"dim\", `:${phaseText}`), ...regularStatuses];\n}\n\n/**\n * Format token counts for compact footer display.\n */\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\nexport function formatCwdForFooter(cwd: string, home: string | undefined): string {\n\tif (!home) return cwd;\n\n\tconst resolvedCwd = resolve(cwd);\n\tconst resolvedHome = resolve(home);\n\tconst relativeToHome = relative(resolvedHome, resolvedCwd);\n\tconst isInsideHome =\n\t\trelativeToHome === \"\" ||\n\t\t(relativeToHome !== \"..\" && !relativeToHome.startsWith(`..${sep}`) && !isAbsolute(relativeToHome));\n\n\tif (!isInsideHome) return cwd;\n\treturn relativeToHome === \"\" ? \"~\" : `~${sep}${relativeToHome}`;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\ntype FooterUsageSnapshot = {\n\tentryCount: number;\n\tmessageCount: number;\n\ttotalInput: number;\n\ttotalOutput: number;\n\ttotalCacheRead: number;\n\ttotalCacheWrite: number;\n\ttotalCost: number;\n\t/** Rolled-up cost of spawned/subagent sessions (Cost Aggregation). 0 when none. */\n\ttotalSpawnedCost: number;\n\tdailyTotalCost: number;\n\tcontextUsage: ReturnType<AgentSession[\"getContextUsage\"]>;\n};\n\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\tprivate session: AgentSession;\n\tprivate footerData: ReadonlyFooterDataProvider;\n\tprivate usageSnapshot?: FooterUsageSnapshot;\n\n\tconstructor(session: AgentSession, footerData: ReadonlyFooterDataProvider) {\n\t\tthis.session = session;\n\t\tthis.footerData = footerData;\n\t}\n\n\tsetSession(session: AgentSession): void {\n\t\tthis.session = session;\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * Invalidate cached footer stats when session state changes.\n\t */\n\tinvalidate(): void {\n\t\tthis.usageSnapshot = undefined;\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\tprivate getUsageSnapshot(messageCount: number): FooterUsageSnapshot {\n\t\tconst sessionManager = this.session.sessionManager as AgentSession[\"sessionManager\"] & {\n\t\t\tgetEntryCount?: () => number;\n\t\t};\n\t\tconst entryCount = sessionManager.getEntryCount?.() ?? sessionManager.getEntries().length;\n\t\tconst cached = this.usageSnapshot;\n\t\tif (cached && cached.entryCount === entryCount && cached.messageCount === messageCount) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Calculate cumulative usage from ALL session entries in one batched pass.\n\t\t// This avoids per-frame defensive array allocation when only the TUI redraws.\n\t\tlet totalInput = 0;\n\t\tlet totalOutput = 0;\n\t\tlet totalCacheRead = 0;\n\t\tlet totalCacheWrite = 0;\n\t\tlet totalCost = 0;\n\n\t\tconst entries = this.session.sessionManager.getEntries();\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst entry = entries[i];\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = entry.message.usage;\n\t\t\tif (!usage) continue;\n\t\t\ttotalInput += usage.input;\n\t\t\ttotalOutput += usage.output;\n\t\t\ttotalCacheRead += usage.cacheRead;\n\t\t\ttotalCacheWrite += usage.cacheWrite;\n\t\t\ttotalCost += usage.cost.total;\n\t\t}\n\n\t\t// Roll up spawned/subagent cost (Cost Aggregation, Model A). Derived from the same\n\t\t// session entries, so the {entryCount} cache key above busts when new reports land.\n\t\tconst totalSpawnedCost = this.session.getSpawnedUsage().cost;\n\t\tconst dailyTotalCost = this.session.getDailyUsageTotals?.().totalCost ?? 0;\n\n\t\tconst snapshot: FooterUsageSnapshot = {\n\t\t\tentryCount,\n\t\t\tmessageCount,\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\t\tcontextUsage: this.session.getContextUsage(),\n\t\t};\n\t\tthis.usageSnapshot = snapshot;\n\t\treturn snapshot;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.session.state;\n\t\tconst usageSnapshot = this.getUsageSnapshot(state.messages?.length ?? 0);\n\t\tconst {\n\t\t\ttotalInput,\n\t\t\ttotalOutput,\n\t\t\ttotalCacheRead,\n\t\t\ttotalCacheWrite,\n\t\t\ttotalCost,\n\t\t\ttotalSpawnedCost,\n\t\t\tdailyTotalCost,\n\t\t\tcontextUsage,\n\t\t} = usageSnapshot;\n\t\tconst contextWindow = contextUsage?.contextWindow ?? state.model?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = formatCwdForFooter(this.session.sessionManager.getCwd(), process.env.HOME || process.env.USERPROFILE);\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.session.sessionManager.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line\n\t\tconst statsParts = [];\n\t\tif (totalInput) statsParts.push(`↑${formatTokens(totalInput)}`);\n\t\tif (totalOutput) statsParts.push(`↓${formatTokens(totalOutput)}`);\n\t\tif (totalCacheRead) statsParts.push(`R${formatTokens(totalCacheRead)}`);\n\t\tif (totalCacheWrite) statsParts.push(`W${formatTokens(totalCacheWrite)}`);\n\n\t\t// Show cost with \"(sub)\" indicator if using OAuth subscription\n\t\tconst usingSubscription = state.model ? this.session.modelRegistry.isUsingOAuth(state.model) : false;\n\t\tconst grandTotalCost = totalCost + totalSpawnedCost;\n\t\tif (grandTotalCost || usingSubscription) {\n\t\t\tconst costStr = `$${grandTotalCost.toFixed(3)}${usingSubscription ? \" (sub)\" : \"\"}`;\n\t\t\tstatsParts.push(costStr);\n\t\t}\n\t\tif (dailyTotalCost) {\n\t\t\tstatsParts.push(`day:$${dailyTotalCost.toFixed(3)}`);\n\t\t}\n\n\t\t// Colorize context percentage based on usage\n\t\tlet contextPercentStr: string;\n\t\tconst autoIndicator = this.autoCompactEnabled ? \" (auto)\" : \"\";\n\t\tconst contextPercentDisplay =\n\t\t\tcontextPercent === \"?\"\n\t\t\t\t? `?/${formatTokens(contextWindow)}${autoIndicator}`\n\t\t\t\t: `${contextPercent}%/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tif (contextPercentValue > 90) {\n\t\t\tcontextPercentStr = theme.fg(\"error\", contextPercentDisplay);\n\t\t} else if (contextPercentValue > 70) {\n\t\t\tcontextPercentStr = theme.fg(\"warning\", contextPercentDisplay);\n\t\t} else {\n\t\t\tcontextPercentStr = contextPercentDisplay;\n\t\t}\n\t\tstatsParts.push(contextPercentStr);\n\n\t\tlet statsLeft = statsParts.join(\" \");\n\n\t\t// Add model display name on the right side, plus thinking level if model supports it\n\t\tconst modelName = state.model?.name || state.model?.id || \"no-model\";\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (state.model?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\" ? `${modelName} • thinking off` : `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && state.model) {\n\t\t\trightSide = `(${state.model!.provider}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\tconst pwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\t// Add extension statuses on a single line. Learning-related statuses are\n\t\t// folded into one compact chip so independent learning systems do not render\n\t\t// brittle duplicates like \"(learning) (learning) auto\".\n\t\tconst extensionStatuses = this.footerData.getExtensionStatuses();\n\t\tconst autonomyStatus = this.footerData.getAutonomyStatus();\n\n\t\tconst statusParts: string[] = [];\n\t\tif (autonomyStatus) {\n\t\t\tconst sanitizedAutonomyStatus = sanitizeStatusText(autonomyStatus);\n\t\t\tif (sanitizedAutonomyStatus) {\n\t\t\t\tstatusParts.push(sanitizedAutonomyStatus);\n\t\t\t}\n\t\t}\n\t\tif (extensionStatuses.size > 0) {\n\t\t\tconst extLine = formatExtensionStatuses(extensionStatuses).join(\" \");\n\t\t\tif (extLine) {\n\t\t\t\tstatusParts.push(extLine);\n\t\t\t}\n\t\t}\n\n\t\tif (statusParts.length > 0) {\n\t\t\tconst statusLine = statusParts.join(\" \");\n\t\t\tlines.push(truncateToWidth(statusLine, width, theme.fg(\"dim\", \"...\")));\n\t\t}\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ThinkingLevel } from "@caupulican/pi-agent-core";
|
|
2
2
|
import type { Transport } from "@caupulican/pi-ai";
|
|
3
3
|
import { Container, type SelectItem, SelectList, SettingsList } from "@caupulican/pi-tui";
|
|
4
|
-
import type { AutoLearnSettings, AutonomySettings, ModelRouterSettings, SelfModificationSettings, SettingsScope, WarningSettings } from "../../../core/settings-manager.ts";
|
|
4
|
+
import type { AutoLearnSettings, AutonomySettings, ContextPromptEnforcementSettings, MemoryRetrievalSettings, ModelRouterSettings, ResearchLaneSettings, SelfModificationSettings, SettingsScope, WarningSettings, WorkerDelegationSettings } from "../../../core/settings-manager.ts";
|
|
5
5
|
export interface SettingsConfig {
|
|
6
6
|
autoCompact: boolean;
|
|
7
7
|
showImages: boolean;
|
|
@@ -37,10 +37,18 @@ export interface SettingsConfig {
|
|
|
37
37
|
selfModificationScope?: SettingsScope;
|
|
38
38
|
autonomy: AutonomySettings;
|
|
39
39
|
autonomyScope?: SettingsScope;
|
|
40
|
+
researchLane: ResearchLaneSettings;
|
|
41
|
+
researchLaneScope?: SettingsScope;
|
|
42
|
+
workerDelegation: WorkerDelegationSettings;
|
|
43
|
+
workerDelegationScope?: SettingsScope;
|
|
40
44
|
modelRouter: ModelRouterSettings;
|
|
41
45
|
modelRouterScope?: SettingsScope;
|
|
42
46
|
autoLearn: AutoLearnSettings;
|
|
43
47
|
autoLearnScope?: SettingsScope;
|
|
48
|
+
contextPolicyEnforcement: ContextPromptEnforcementSettings;
|
|
49
|
+
contextPolicyEnforcementScope?: SettingsScope;
|
|
50
|
+
contextMemoryRetrieval: MemoryRetrievalSettings;
|
|
51
|
+
contextMemoryRetrievalScope?: SettingsScope;
|
|
44
52
|
currentModelPattern?: string;
|
|
45
53
|
autoLearnModelOptions?: SelectItem[];
|
|
46
54
|
activeProfileName?: string;
|
|
@@ -76,8 +84,12 @@ export interface SettingsCallbacks {
|
|
|
76
84
|
onWarningsChange: (warnings: WarningSettings) => void;
|
|
77
85
|
onSelfModificationChange: (settings: SelfModificationSettings, scope: SettingsScope) => void;
|
|
78
86
|
onAutonomyChange: (settings: AutonomySettings, scope: SettingsScope) => void;
|
|
87
|
+
onResearchLaneChange: (settings: ResearchLaneSettings, scope: SettingsScope) => void;
|
|
88
|
+
onWorkerDelegationChange: (settings: WorkerDelegationSettings, scope: SettingsScope) => void;
|
|
79
89
|
onModelRouterChange: (settings: ModelRouterSettings, scope: SettingsScope) => void;
|
|
80
90
|
onAutoLearnChange: (settings: AutoLearnSettings, scope: SettingsScope) => void;
|
|
91
|
+
onContextPolicyEnforcementChange: (settings: ContextPromptEnforcementSettings, scope: SettingsScope) => void;
|
|
92
|
+
onContextMemoryRetrievalChange: (settings: MemoryRetrievalSettings, scope: SettingsScope) => void;
|
|
81
93
|
onResourcesHubAction?: (action: string) => void;
|
|
82
94
|
onCancel: () => void;
|
|
83
95
|
}
|