@cchistory/lite 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +1 -1
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +41 -9
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/agent-journeys.test.d.ts +2 -0
- package/apps/lite-cli/dist/agent-journeys.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/agent-journeys.test.js +403 -0
- package/apps/lite-cli/dist/agent-journeys.test.js.map +1 -0
- package/apps/lite-cli/dist/index.d.ts.map +1 -1
- package/apps/lite-cli/dist/index.js +137 -60
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +48 -5
- package/apps/lite-cli/dist/index.test.js.map +1 -1
- package/apps/lite-cli/dist/json-v2.d.ts.map +1 -1
- package/apps/lite-cli/dist/json-v2.js +8 -1
- package/apps/lite-cli/dist/json-v2.js.map +1 -1
- package/apps/lite-cli/dist/query.d.ts +15 -2
- package/apps/lite-cli/dist/query.d.ts.map +1 -1
- package/apps/lite-cli/dist/query.js +79 -4
- package/apps/lite-cli/dist/query.js.map +1 -1
- package/apps/lite-cli/dist/shell.d.ts +2 -1
- package/apps/lite-cli/dist/shell.d.ts.map +1 -1
- package/apps/lite-cli/dist/shell.js +20 -16
- package/apps/lite-cli/dist/shell.js.map +1 -1
- package/apps/lite-cli/dist/stats-command.d.ts +52 -0
- package/apps/lite-cli/dist/stats-command.d.ts.map +1 -0
- package/apps/lite-cli/dist/stats-command.js +322 -0
- package/apps/lite-cli/dist/stats-command.js.map +1 -0
- package/apps/lite-cli/dist/stats-command.test.d.ts +2 -0
- package/apps/lite-cli/dist/stats-command.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/stats-command.test.js +154 -0
- package/apps/lite-cli/dist/stats-command.test.js.map +1 -0
- package/apps/lite-cli/dist/stats-render.d.ts +21 -0
- package/apps/lite-cli/dist/stats-render.d.ts.map +1 -0
- package/apps/lite-cli/dist/stats-render.js +207 -0
- package/apps/lite-cli/dist/stats-render.js.map +1 -0
- package/apps/lite-cli/dist/version.d.ts +1 -1
- package/apps/lite-cli/dist/version.js +1 -1
- package/apps/lite-tui/dist/index.d.ts.map +1 -1
- package/apps/lite-tui/dist/index.js +75 -4
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/input.d.ts.map +1 -1
- package/apps/lite-tui/dist/input.js +124 -3
- package/apps/lite-tui/dist/input.js.map +1 -1
- package/apps/lite-tui/dist/model.d.ts +29 -4
- package/apps/lite-tui/dist/model.d.ts.map +1 -1
- package/apps/lite-tui/dist/model.js +91 -8
- package/apps/lite-tui/dist/model.js.map +1 -1
- package/apps/lite-tui/dist/render.d.ts +1 -1
- package/apps/lite-tui/dist/render.d.ts.map +1 -1
- package/apps/lite-tui/dist/render.js +21 -51
- package/apps/lite-tui/dist/render.js.map +1 -1
- package/apps/lite-tui/dist/state.d.ts +3 -1
- package/apps/lite-tui/dist/state.d.ts.map +1 -1
- package/apps/lite-tui/dist/state.js +31 -13
- package/apps/lite-tui/dist/state.js.map +1 -1
- package/apps/lite-tui/dist/state.test.js +118 -0
- package/apps/lite-tui/dist/state.test.js.map +1 -1
- package/apps/lite-tui/dist/stats-dashboard.test.d.ts +2 -0
- package/apps/lite-tui/dist/stats-dashboard.test.d.ts.map +1 -0
- package/apps/lite-tui/dist/stats-dashboard.test.js +191 -0
- package/apps/lite-tui/dist/stats-dashboard.test.js.map +1 -0
- package/apps/lite-tui/dist/stats-query.d.ts +11 -0
- package/apps/lite-tui/dist/stats-query.d.ts.map +1 -0
- package/apps/lite-tui/dist/stats-query.js +104 -0
- package/apps/lite-tui/dist/stats-query.js.map +1 -0
- package/apps/lite-tui/dist/stats-render.d.ts +9 -0
- package/apps/lite-tui/dist/stats-render.d.ts.map +1 -0
- package/apps/lite-tui/dist/stats-render.js +311 -0
- package/apps/lite-tui/dist/stats-render.js.map +1 -0
- package/apps/lite-tui/dist/stats-state.d.ts +121 -0
- package/apps/lite-tui/dist/stats-state.d.ts.map +1 -0
- package/apps/lite-tui/dist/stats-state.js +335 -0
- package/apps/lite-tui/dist/stats-state.js.map +1 -0
- package/apps/lite-tui/dist/version.d.ts +1 -1
- package/apps/lite-tui/dist/version.js +1 -1
- package/docs/guide/agent-evidence.md +154 -0
- package/docs/guide/for-agents.md +29 -10
- package/docs/guide/lite.md +31 -4
- package/docs/guide/pricing.example.json +38 -0
- package/docs/guide/query.md +10 -1
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.d.ts +85 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.js +191 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.js +105 -0
- package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/index.d.ts +9 -2
- package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.js +9 -2
- package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.test.js +62 -1
- package/node_modules/@cchistory/canonical/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.d.ts +11 -0
- package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.js +96 -0
- package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts +4 -3
- package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/projection-audit.js +34 -0
- package/node_modules/@cchistory/canonical/dist/projection-audit.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/query.js +1 -1
- package/node_modules/@cchistory/canonical/dist/query.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/read-order.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/read-order.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/read-order.js +10 -0
- package/node_modules/@cchistory/canonical/dist/read-order.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/read-status.d.ts +11 -0
- package/node_modules/@cchistory/canonical/dist/read-status.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/read-status.js +14 -0
- package/node_modules/@cchistory/canonical/dist/read-status.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.js +3 -3
- package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +7 -3
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js +40 -14
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/usage-breakdown.d.ts +37 -0
- package/node_modules/@cchistory/canonical/dist/usage-breakdown.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-breakdown.js +274 -0
- package/node_modules/@cchistory/canonical/dist/usage-breakdown.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing-config.d.ts +11 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing-config.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing-config.js +297 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing-config.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.d.ts +28 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.js +267 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.test.js +365 -0
- package/node_modules/@cchistory/canonical/dist/usage-pricing.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-time.d.ts +53 -0
- package/node_modules/@cchistory/canonical/dist/usage-time.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage-time.js +323 -0
- package/node_modules/@cchistory/canonical/dist/usage-time.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/usage.d.ts +46 -31
- package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/usage.js +187 -96
- package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -1
- package/node_modules/@cchistory/canonical/package.json +1 -1
- package/node_modules/@cchistory/domain/dist/conversation-evidence.d.ts +24 -0
- package/node_modules/@cchistory/domain/dist/conversation-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/conversation-evidence.js +2 -0
- package/node_modules/@cchistory/domain/dist/conversation-evidence.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts +27 -2
- package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/domain/dist/index.js +1 -0
- package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
- package/node_modules/@cchistory/domain/dist/usage-pricing.d.ts +145 -0
- package/node_modules/@cchistory/domain/dist/usage-pricing.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/usage-pricing.js +7 -0
- package/node_modules/@cchistory/domain/dist/usage-pricing.js.map +1 -0
- package/node_modules/@cchistory/domain/package.json +1 -1
- package/node_modules/@cchistory/live-runtime/dist/antigravity.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/antigravity.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/antigravity.test.js +104 -0
- package/node_modules/@cchistory/live-runtime/dist/antigravity.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.d.ts +15 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.js +44 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.js +45 -0
- package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/diagnostics.d.ts +7 -0
- package/node_modules/@cchistory/live-runtime/dist/diagnostics.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/diagnostics.js +2 -0
- package/node_modules/@cchistory/live-runtime/dist/diagnostics.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.js +211 -0
- package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/history-reader.d.ts +24 -0
- package/node_modules/@cchistory/live-runtime/dist/history-reader.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/history-reader.js +155 -0
- package/node_modules/@cchistory/live-runtime/dist/history-reader.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts +102 -5
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.js +245 -58
- package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.test.js +43 -2
- package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +2 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/package.json +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/atomizer.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/atomizer.js +10 -0
- package/node_modules/@cchistory/source-adapters/dist/core/atomizer.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +7 -0
- package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.d.ts +12 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.js +32 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.js +21 -0
- package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.js +16 -2
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts +3 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js +56 -38
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +46 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +15 -4
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +181 -65
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js +223 -61
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +4 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +4 -2
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +58 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +6 -2
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +16 -5
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +5 -2
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/user-text.d.ts +9 -7
- package/node_modules/@cchistory/source-adapters/dist/core/user-text.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/user-text.js +34 -8
- package/node_modules/@cchistory/source-adapters/dist/core/user-text.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/utils.test.js +11 -0
- package/node_modules/@cchistory/source-adapters/dist/core/utils.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +3 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.js +3 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +49 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.d.ts +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.js +2 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.js +105 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.d.ts +8 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.js +227 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.js +22 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.js +145 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.d.ts +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.js +14 -5
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.d.ts +27 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.js +262 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.js +101 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.d.ts +17 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.js +145 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.js +423 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js +2 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/types.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/types.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +48 -29
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/package.json +1 -1
- package/package.json +5 -5
- package/schemas/cchistory-lite-agent-v1.schema.json +8 -5
- package/schemas/cchistory-lite-canonical-v1.schema.json +82 -0
- package/schemas/cchistory-lite-diagnostic-v1.schema.json +27 -0
- package/schemas/cchistory-lite-query-result-v2.schema.json +232 -4
- package/schemas/cchistory-lite-query-result-v3.schema.json +45 -1
- package/schemas/cchistory-lite-query-v2.schema.json +150 -8
- package/schemas/cchistory-lite-v2.schema.json +82 -0
- package/skills/using-cchistory-lite/SKILL.md +86 -128
|
@@ -4,11 +4,12 @@ import os from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { deriveHostId, deriveSourceInstanceId, normalizeLocalPathIdentity, } from "@cchistory/domain";
|
|
7
|
-
import { executeCanonicalQuery, collectionQueryTemplate, hasSessionFamilyLinkTool, auditProjectionConsistency, interpretSessionEvidence, buildSessionLastMessageIndex, buildDirectoryScopedProjectTreeProjection, buildFallbackProjectObservationCandidates, buildProjectDisplayList, buildSessionRelatedWorkIndex, compareTurnsByChronology, compareTurnsByRecency, computeUsageOverview, computeUsageRollup, deriveProjectLinkSnapshot, filterProjectsByDirectoryScope, selectSampleSessions, summarizeDirectoryScope, filterSessionsByDirectoryScope, filterTopLevelSessions, filterTurnsByDirectoryScope, buildSessionFamilyInventory, FAMILY_IO_PREVIEW_CHARS, listDelegatedRelationsForFamilyChildren, listSessionFamilies, mergeSessionFamilyInventories, installRuntimeWarningFilter, orderSessionsByLastMessage, pathMatchesDirectoryScope, searchSessionsInMemory, searchTurnsInMemory, resolveTurnUsage, summarizeSessionUsage, } from "@cchistory/canonical";
|
|
7
|
+
import { buildConversationEvidence, prepareConversationEvidence, searchConversationEvidence, summarizeReadStatus, executeCanonicalQuery, collectionQueryTemplate, hasSessionFamilyLinkTool, auditProjectionConsistency, interpretSessionEvidence, buildSessionLastMessageIndex, buildDirectoryScopedProjectTreeProjection, buildFallbackProjectObservationCandidates, buildProjectDisplayList, buildSessionRelatedWorkIndex, compareTurnsByChronology, compareTurnsByRecency, computeUsageBreakdown, computeUsageMatrix, computeUsageOverview, computeUsageRollup, deriveProjectLinkSnapshot, extractUnfilteredUsageRows, filterProjectsByDirectoryScope, selectSampleSessions, summarizeDirectoryScope, filterSessionsByDirectoryScope, filterTopLevelSessions, filterTurnsByDirectoryScope, buildSessionFamilyInventory, FAMILY_IO_PREVIEW_CHARS, listDelegatedRelationsForFamilyChildren, listSessionFamilies, mergeSessionFamilyInventories, installRuntimeWarningFilter, orderSessionsByLastMessage, pathMatchesDirectoryScope, resolveLatestTurnActivityAt, resolveUsageTimezone, searchSessionsInMemory, searchTurnsInMemory, resolveTurnUsage, summarizeSessionUsage, } from "@cchistory/canonical";
|
|
8
8
|
import { SourceReadBudgetExceededError, applyMaskTemplates } from "@cchistory/source-adapters";
|
|
9
9
|
import { SAMPLE_RANK_CONCURRENCY, mapPool } from "./async-pool.js";
|
|
10
10
|
import { isSelectiveLatestQuery, newQueryReadWork } from "./selective-query.js";
|
|
11
11
|
import { PreparationMetadata } from "./preparation-metadata.js";
|
|
12
|
+
import { BoundedCache } from "./bounded-cache.js";
|
|
12
13
|
import { readRemainingHeapBytes, LIGHT_SCAN_MEMORY_MULTIPLIER, FULL_SCAN_MEMORY_MULTIPLIER, SCAN_GUARD_REFUSE_AVAILABLE_FRACTION, acquireScanLock, assessScanRisk, createScanWatchdog, isScanGuardEnabled, ScanGuardRefusedError, } from "./scan-guard.js";
|
|
13
14
|
export { acquireScanLock, assessScanRisk, createScanWatchdog, defaultScanLockPath, formatScanGuardBytes, formatScanGuardWarning, FULL_SCAN_MEMORY_MULTIPLIER, isScanGuardEnabled, LIGHT_SCAN_MEMORY_MULTIPLIER, SCAN_GUARD_REFUSE_AVAILABLE_FRACTION, SCAN_GUARD_WARN_AVAILABLE_FRACTION, SCAN_WATCHDOG_MAX_RESERVE_BYTES, SCAN_LOCK_WAIT_MS, SCAN_WATCHDOG_AVAILABLE_RESERVE_FRACTION, ScanGuardAbortedError, ScanGuardRefusedError, } from "./scan-guard.js";
|
|
14
15
|
import { readAvailableMemoryBytes } from "./system-memory.js";
|
|
@@ -35,7 +36,15 @@ export class AmbiguousReferenceError extends Error {
|
|
|
35
36
|
this.candidateIds = [...candidateIds];
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
/** An exact session scan could not resolve one of its requested targets. */
|
|
40
|
+
export class SessionReferenceNotFoundError extends Error {
|
|
41
|
+
constructor(message) {
|
|
42
|
+
super(message);
|
|
43
|
+
this.name = "SessionReferenceNotFoundError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
38
46
|
export class LiveHistorySnapshot {
|
|
47
|
+
limitedScan;
|
|
39
48
|
selectSampleSessions(perSource, directoryScope) {
|
|
40
49
|
return selectSampleSessions(this.data, perSource, directoryScope);
|
|
41
50
|
}
|
|
@@ -44,6 +53,7 @@ export class LiveHistorySnapshot {
|
|
|
44
53
|
}
|
|
45
54
|
data;
|
|
46
55
|
readIdentity = { id: randomUUID(), prepared_at: new Date().toISOString() };
|
|
56
|
+
searchNowMs = Date.parse(this.readIdentity.prepared_at);
|
|
47
57
|
/** Non-fatal projection diagnostics kept visible to read-only surfaces. */
|
|
48
58
|
projectionIssues;
|
|
49
59
|
sourcesById;
|
|
@@ -62,9 +72,12 @@ export class LiveHistorySnapshot {
|
|
|
62
72
|
// memoized for the lifetime of the instance (a refresh builds a new one).
|
|
63
73
|
turnsBySessionId;
|
|
64
74
|
turnsByProjectId;
|
|
65
|
-
searchRankCache;
|
|
66
|
-
sessionSearchRankCache;
|
|
67
|
-
|
|
75
|
+
searchRankCache = new BoundedCache(32, 20_000, (rows, key) => rows.reduce((total, row) => total + 1 + row.highlights.length * 2, Math.ceil(key.length / 128)));
|
|
76
|
+
sessionSearchRankCache = new BoundedCache(32, 20_000, (rows, key) => rows.reduce((total, row) => total + 1 + row.highlights.length * 2, Math.ceil(key.length / 128)));
|
|
77
|
+
evidencePages = new BoundedCache(32, 100_000, (entry, key) => entry.messageCount + Math.ceil(key.length / 128));
|
|
78
|
+
usageBaseRowsCache = new BoundedCache(8, 50_000, (rows, key) => rows.length + Math.ceil(key.length / 128));
|
|
79
|
+
constructor(data, searchCandidates = [], limitedScan = false) {
|
|
80
|
+
this.limitedScan = limitedScan;
|
|
68
81
|
this.data = {
|
|
69
82
|
...data,
|
|
70
83
|
related_work: data.related_work ?? [],
|
|
@@ -101,6 +114,48 @@ export class LiveHistorySnapshot {
|
|
|
101
114
|
this.childrenByParentId.set(child.parent_session_ref, siblings);
|
|
102
115
|
}
|
|
103
116
|
}
|
|
117
|
+
getReadStatus(directoryScope, diagnostics = "complete") {
|
|
118
|
+
return summarizeReadStatus({ sources: this.data.sources, lossAudits: this.data.loss_audits,
|
|
119
|
+
projectionIssueCount: this.projectionIssues.length,
|
|
120
|
+
unknownDirectorySessions: this.getDirectoryScopeDiagnostics(directoryScope)?.unknown_directory_sessions,
|
|
121
|
+
limitedScan: this.limitedScan, observedDiagnostics: diagnostics === "observed" });
|
|
122
|
+
}
|
|
123
|
+
getCacheStats() {
|
|
124
|
+
const state = (cache) => ({ entries: cache.size, retained_units: cache.weight });
|
|
125
|
+
return { search: state(this.searchRankCache), session_search: state(this.sessionSearchRankCache),
|
|
126
|
+
evidence_pages: state(this.evidencePages) };
|
|
127
|
+
}
|
|
128
|
+
readEvidence(target, options = {}, directoryScope) {
|
|
129
|
+
const session = target.kind === "session" ? this.getSession(target.ref) : undefined;
|
|
130
|
+
const turn = target.kind === "turn" ? this.getTurn(target.ref) : undefined;
|
|
131
|
+
if (!(session || turn))
|
|
132
|
+
return undefined;
|
|
133
|
+
const allowed = new Set(this.listResolvedSessions({ directoryScope }).map(s => s.id));
|
|
134
|
+
if (!allowed.has(session?.id ?? turn.session_id))
|
|
135
|
+
return undefined;
|
|
136
|
+
const turns = session ? this.listSessionTurns(session.id) : [turn];
|
|
137
|
+
if (!this.data.conversation_evidence && turns.some(t => t.context_summary.assistant_reply_count > 0 && !this.getTurnContext(t.id))) {
|
|
138
|
+
throw new Error("Conversation detail is not loaded for this read.");
|
|
139
|
+
}
|
|
140
|
+
const selector = JSON.stringify([target.kind, session?.id ?? turn.id, directoryScope ?? null]);
|
|
141
|
+
let pages = this.evidencePages.get(selector);
|
|
142
|
+
if (!pages) {
|
|
143
|
+
const ids = new Set(turns.map(t => t.id));
|
|
144
|
+
const messages = this.data.conversation_evidence?.filter(m => session ? m.session_id === session.id : m.turn_id !== null && ids.has(m.turn_id))
|
|
145
|
+
?? buildConversationEvidence(turns, this.data.contexts);
|
|
146
|
+
pages = prepareConversationEvidence(messages, selector);
|
|
147
|
+
this.evidencePages.set(selector, pages);
|
|
148
|
+
}
|
|
149
|
+
return { target: { kind: target.kind, id: session?.id ?? turn.id },
|
|
150
|
+
...pages.read(options) };
|
|
151
|
+
}
|
|
152
|
+
searchConversation(options) {
|
|
153
|
+
if (!this.data.conversation_evidence)
|
|
154
|
+
throw new Error("Conversation search evidence is not loaded.");
|
|
155
|
+
return searchConversationEvidence({ ...options, messages: this.data.conversation_evidence,
|
|
156
|
+
sessions: this.data.sessions, related_work: this.data.related_work,
|
|
157
|
+
projectTurnIds: options.projectId ? new Set(this.listProjectTurns(options.projectId).map(t => t.id)) : undefined });
|
|
158
|
+
}
|
|
104
159
|
listSources() {
|
|
105
160
|
return [...this.data.sources];
|
|
106
161
|
}
|
|
@@ -131,6 +186,9 @@ export class LiveHistorySnapshot {
|
|
|
131
186
|
const session = this.getSession(sessionRef);
|
|
132
187
|
return session ? this.lastMessageAtBySessionId.get(session.id) ?? session.updated_at : undefined;
|
|
133
188
|
}
|
|
189
|
+
getLatestTurnActivityAt(turns) {
|
|
190
|
+
return resolveLatestTurnActivityAt(turns);
|
|
191
|
+
}
|
|
134
192
|
getProjectsTreeProjection(options = {}) {
|
|
135
193
|
return buildDirectoryScopedProjectTreeProjection({
|
|
136
194
|
projects: this.listProjects(),
|
|
@@ -261,7 +319,7 @@ export class LiveHistorySnapshot {
|
|
|
261
319
|
}
|
|
262
320
|
getSessionUsage(sessionRef) {
|
|
263
321
|
const session = this.getSession(sessionRef);
|
|
264
|
-
return session ? summarizeSessionUsage(this.sessionTurnBuckets().get(session.id) ?? []) : undefined;
|
|
322
|
+
return session ? summarizeSessionUsage(this.sessionTurnBuckets().get(session.id) ?? [], session) : undefined;
|
|
265
323
|
}
|
|
266
324
|
listProjectTurns(projectRef, options = {}) {
|
|
267
325
|
const project = this.getProject(projectRef);
|
|
@@ -284,7 +342,6 @@ export class LiveHistorySnapshot {
|
|
|
284
342
|
options.sourceIds ?? null,
|
|
285
343
|
options.directoryScope ?? null,
|
|
286
344
|
]);
|
|
287
|
-
this.searchRankCache ??= new Map();
|
|
288
345
|
let ranked = this.searchRankCache.get(cacheKey);
|
|
289
346
|
if (!ranked) {
|
|
290
347
|
ranked = searchTurnsInMemory({
|
|
@@ -292,6 +349,7 @@ export class LiveHistorySnapshot {
|
|
|
292
349
|
sessions: this.data.sessions,
|
|
293
350
|
projects: this.data.projects,
|
|
294
351
|
candidates: this.searchCandidates,
|
|
352
|
+
now_ms: this.searchNowMs,
|
|
295
353
|
query: options.query,
|
|
296
354
|
project_id: options.projectId,
|
|
297
355
|
source_ids: options.sourceIds,
|
|
@@ -311,7 +369,6 @@ export class LiveHistorySnapshot {
|
|
|
311
369
|
options.sourceIds ?? null,
|
|
312
370
|
options.directoryScope ?? null,
|
|
313
371
|
]);
|
|
314
|
-
this.sessionSearchRankCache ??= new Map();
|
|
315
372
|
let ranked = this.sessionSearchRankCache.get(cacheKey);
|
|
316
373
|
if (!ranked) {
|
|
317
374
|
ranked = searchSessionsInMemory({
|
|
@@ -319,6 +376,7 @@ export class LiveHistorySnapshot {
|
|
|
319
376
|
sessions: filterSessionsByDirectoryScope(this.data.sessions, options.directoryScope),
|
|
320
377
|
projects: this.data.projects,
|
|
321
378
|
candidates: this.searchCandidates,
|
|
379
|
+
now_ms: this.searchNowMs,
|
|
322
380
|
related_work: this.data.related_work,
|
|
323
381
|
query: options.query,
|
|
324
382
|
project_id: options.projectId,
|
|
@@ -381,15 +439,70 @@ export class LiveHistorySnapshot {
|
|
|
381
439
|
listProjects: () => this.data.projects,
|
|
382
440
|
});
|
|
383
441
|
}
|
|
442
|
+
getCachedUsageBaseRows(filters = {}) {
|
|
443
|
+
const timeZone = resolveUsageTimezone(filters.timezone ?? filters.pricing?.timezone);
|
|
444
|
+
const weekMode = filters.week_mode ?? filters.pricing?.quota?.week_mode ?? "rolling_7d";
|
|
445
|
+
const weekStartDay = filters.week_start_day ?? filters.pricing?.quota?.week_start_day;
|
|
446
|
+
const weekResetHour = filters.week_reset_hour ?? filters.pricing?.quota?.week_reset_hour;
|
|
447
|
+
const nowMs = filters.now_ms ?? Date.now();
|
|
448
|
+
const rollingBucket = weekMode === "rolling_7d"
|
|
449
|
+
? String(filters.now_ms ?? Math.floor(nowMs / 60_000))
|
|
450
|
+
: "";
|
|
451
|
+
const cacheKey = `${timeZone}|${weekMode}|${weekStartDay ?? ""}|${weekResetHour ?? ""}|${rollingBucket}`;
|
|
452
|
+
const cached = this.usageBaseRowsCache.get(cacheKey);
|
|
453
|
+
if (cached)
|
|
454
|
+
return cached;
|
|
455
|
+
const extracted = extractUnfilteredUsageRows({
|
|
456
|
+
listResolvedTurns: () => this.data.turns,
|
|
457
|
+
listResolvedSessions: () => this.data.sessions,
|
|
458
|
+
listSources: () => this.data.sources,
|
|
459
|
+
listProjects: () => this.data.projects,
|
|
460
|
+
}, {
|
|
461
|
+
timezone: timeZone,
|
|
462
|
+
week_mode: weekMode,
|
|
463
|
+
week_start_day: weekStartDay,
|
|
464
|
+
week_reset_hour: weekResetHour,
|
|
465
|
+
now_ms: nowMs,
|
|
466
|
+
pricing: filters.pricing,
|
|
467
|
+
});
|
|
468
|
+
this.usageBaseRowsCache.set(cacheKey, extracted);
|
|
469
|
+
return extracted;
|
|
470
|
+
}
|
|
471
|
+
getUsageMatrix(dimensions, filters = {}, sortBy = "adjusted_cost") {
|
|
472
|
+
return computeUsageMatrix({
|
|
473
|
+
dimensions,
|
|
474
|
+
filters,
|
|
475
|
+
sortBy,
|
|
476
|
+
listResolvedTurns: () => this.data.turns,
|
|
477
|
+
listResolvedSessions: () => this.data.sessions,
|
|
478
|
+
listSources: () => this.data.sources,
|
|
479
|
+
listProjects: () => this.data.projects,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
getUsageBreakdown(options = {}) {
|
|
483
|
+
const filters = options.filters ?? {};
|
|
484
|
+
return computeUsageBreakdown({
|
|
485
|
+
filters,
|
|
486
|
+
time_dimension: options.time_dimension,
|
|
487
|
+
matrix_dimensions: options.matrix_dimensions,
|
|
488
|
+
sort_by: options.sort_by,
|
|
489
|
+
cached_base_rows: this.getCachedUsageBaseRows(filters),
|
|
490
|
+
listResolvedTurns: () => this.data.turns,
|
|
491
|
+
listResolvedSessions: () => this.data.sessions,
|
|
492
|
+
listSources: () => this.data.sources,
|
|
493
|
+
listProjects: () => this.data.projects,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
384
496
|
}
|
|
385
497
|
export async function scanLiteHistory(options = {}) {
|
|
386
|
-
return withPreparedScan(options, (sources, scanGuard, getPlan) => scanResolvedSources(scanGuard.guardedOptions(
|
|
498
|
+
return withPreparedScan(options, (sources, scanGuard, getPlan, tracedOptions) => scanResolvedSources(scanGuard.guardedOptions(tracedOptions), sources, scanGuard, getPlan));
|
|
387
499
|
}
|
|
388
500
|
/** Query-only selective reads never escape as a reusable full snapshot. */
|
|
389
501
|
export async function scanLiteQuery(query, options = {}) {
|
|
390
502
|
const work = newQueryReadWork();
|
|
391
503
|
options = { ...options, contextMode: "none" };
|
|
392
|
-
return withPreparedScan(options, async (sources, scanGuard, getPlan) => {
|
|
504
|
+
return withPreparedScan(options, async (sources, scanGuard, getPlan, tracedOptions) => {
|
|
505
|
+
options = tracedOptions;
|
|
393
506
|
const guardedOptions = scanGuard.guardedOptions(options);
|
|
394
507
|
let selection;
|
|
395
508
|
for (const source of sources) {
|
|
@@ -418,50 +531,87 @@ export async function scanLiteQuery(query, options = {}) {
|
|
|
418
531
|
result.coverage = { execution: "selective", rows: "exact", diagnostics: "observed" };
|
|
419
532
|
work.retainedSessions = snapshot.data.sessions.length;
|
|
420
533
|
work.retainedTurns = snapshot.data.turns.length;
|
|
421
|
-
return { identity: snapshot.readIdentity, sourceIds: snapshot.data.sources.map(s => s.id), directoryScope: options.directoryScope,
|
|
534
|
+
return { identity: snapshot.readIdentity, readStatus: snapshot.getReadStatus(options.directoryScope, result.coverage.diagnostics), sourceIds: snapshot.data.sources.map(s => s.id), directoryScope: options.directoryScope,
|
|
422
535
|
result, projectionIssues: snapshot.projectionIssues, sources: snapshot.data.sources, lossAudits: snapshot.data.loss_audits, directoryScopeDiagnostics: snapshot.getDirectoryScopeDiagnostics(options.directoryScope), work };
|
|
423
536
|
});
|
|
424
537
|
}
|
|
425
538
|
async function withPreparedScan(options, run) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
539
|
+
const sink = options.onDiagnostic;
|
|
540
|
+
const attemptId = sink ? randomUUID() : undefined;
|
|
541
|
+
const startedAt = performance.now();
|
|
542
|
+
if (sink) {
|
|
543
|
+
const progress = options.onProgress;
|
|
544
|
+
const report = event => {
|
|
545
|
+
const memory = process.memoryUsage();
|
|
546
|
+
sink({ ...event, attempt_id: attemptId, elapsed_ms: performance.now() - startedAt,
|
|
547
|
+
heap_used_bytes: memory.heapUsed, rss_bytes: memory.rss,
|
|
548
|
+
process_peak_rss_bytes: process.resourceUsage().maxRSS * 1024 });
|
|
549
|
+
};
|
|
550
|
+
options = { ...options, onDiagnostic: report, onProgress: event => {
|
|
551
|
+
report({ kind: "progress", stage: event.stage, source_id: event.source_id, slot_id: event.slot_id,
|
|
552
|
+
file_index: event.file_index, file_count: event.file_count, size_bytes: event.size_bytes,
|
|
553
|
+
count: event.count, count_unit: event.count_unit,
|
|
554
|
+
stage_elapsed_ms: event.elapsed_ms === undefined ? undefined : Math.max(0, event.elapsed_ms) });
|
|
555
|
+
progress?.(event);
|
|
556
|
+
} };
|
|
557
|
+
report({ kind: "read_start", directory: options.directoryScope ?? null, source_refs: options.sourceRefs ?? [],
|
|
558
|
+
context_mode: options.contextMode ?? "full", conversation: options.retainConversationEvidence ?? false });
|
|
559
|
+
}
|
|
560
|
+
let scanGuard;
|
|
561
|
+
try {
|
|
562
|
+
if (options.contextMode === "matching" && resolveContextTargets(options).length === 0) {
|
|
563
|
+
throw new Error("matching context mode requires at least one context target.");
|
|
435
564
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (!pending) {
|
|
444
|
-
pending = prepareSourceScan(source, scanOptions, sourceAdapters, metadata).catch(async (error) => {
|
|
445
|
-
if (!(error instanceof sourceAdapters.SourceFileReadPlanChangedError))
|
|
446
|
-
throw error;
|
|
447
|
-
// Live metadata is an optimization, not a prerequisite for reading history.
|
|
448
|
-
const files = await sourceAdapters.listSourceFiles(source.platform, source.base_dir, scanOptions.limitFiles);
|
|
449
|
-
const selected = scanOptions.sample
|
|
450
|
-
? await selectSampleSourceFiles(source, files, scanOptions.sample.perSource, sourceAdapters) : files;
|
|
451
|
-
return { discoveredPrimaryFiles: files.length,
|
|
452
|
-
readPlan: await sourceAdapters.createSourceFileReadPlan(source, selected, scanOptions.safeMode ?? false),
|
|
453
|
-
selectionEvidence: [] };
|
|
454
|
-
});
|
|
455
|
-
plans.set(key, pending);
|
|
565
|
+
let sources = await resolveLiteSources(options);
|
|
566
|
+
const exactPlatforms = exactCanonicalSessionPlatforms(options.sessionRefs ?? []);
|
|
567
|
+
if (exactPlatforms.size > 0) {
|
|
568
|
+
sources = sources.filter((source) => exactPlatforms.has(source.platform));
|
|
569
|
+
if (sources.length === 0) {
|
|
570
|
+
throw new SessionReferenceNotFoundError(`No selected Lite source can resolve requested session ${options.sessionRefs?.join(", ")}.`);
|
|
571
|
+
}
|
|
456
572
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
573
|
+
const sourceAdapters = await import("@cchistory/source-adapters");
|
|
574
|
+
const metadata = new PreparationMetadata();
|
|
575
|
+
const plans = new Map();
|
|
576
|
+
const getPlan = (source, scanOptions) => {
|
|
577
|
+
const key = JSON.stringify([source.id, scanOptions.sessionRefs ?? []]);
|
|
578
|
+
let pending = plans.get(key);
|
|
579
|
+
if (!pending) {
|
|
580
|
+
pending = prepareSourceScan(source, scanOptions, sourceAdapters, metadata).catch(async (error) => {
|
|
581
|
+
if (!(error instanceof sourceAdapters.SourceFileReadPlanChangedError))
|
|
582
|
+
throw error;
|
|
583
|
+
// Live metadata is an optimization, not a prerequisite for reading history.
|
|
584
|
+
const files = await sourceAdapters.listSourceFiles(source.platform, source.base_dir, scanOptions.limitFiles);
|
|
585
|
+
const selected = scanOptions.sample
|
|
586
|
+
? await selectSampleSourceFiles(source, files, scanOptions.sample.perSource, sourceAdapters) : files;
|
|
587
|
+
return { discoveredPrimaryFiles: files.length,
|
|
588
|
+
readPlan: await sourceAdapters.createSourceFileReadPlan(source, selected, scanOptions.safeMode ?? false),
|
|
589
|
+
selectionEvidence: [] };
|
|
590
|
+
});
|
|
591
|
+
plans.set(key, pending);
|
|
592
|
+
}
|
|
593
|
+
return pending;
|
|
594
|
+
};
|
|
595
|
+
scanGuard = await beginScanGuard(options, sources, getPlan);
|
|
596
|
+
const result = await run(sources, scanGuard, getPlan, options);
|
|
597
|
+
if (result instanceof LiveHistorySnapshot) {
|
|
598
|
+
options.onDiagnostic?.({ kind: "read_done", read_id: result.readIdentity.id,
|
|
599
|
+
sessions: result.data.sessions.length, turns: result.data.turns.length,
|
|
600
|
+
read_status: result.getReadStatus(options.directoryScope) });
|
|
601
|
+
}
|
|
602
|
+
else if (result && typeof result === "object" && "work" in result) {
|
|
603
|
+
const read = result;
|
|
604
|
+
options.onDiagnostic?.({ kind: "query_work", ...read.work });
|
|
605
|
+
options.onDiagnostic?.({ kind: "read_done", read_id: read.identity.id, read_status: read.readStatus });
|
|
606
|
+
}
|
|
607
|
+
return result;
|
|
608
|
+
}
|
|
609
|
+
catch (error) {
|
|
610
|
+
options.onDiagnostic?.({ kind: "read_error", error_class: error instanceof Error ? error.name : "unknown" });
|
|
611
|
+
throw error;
|
|
462
612
|
}
|
|
463
613
|
finally {
|
|
464
|
-
await scanGuard
|
|
614
|
+
await scanGuard?.release();
|
|
465
615
|
}
|
|
466
616
|
}
|
|
467
617
|
/**
|
|
@@ -534,14 +684,25 @@ async function beginScanGuard(options, sources, getPlan) {
|
|
|
534
684
|
}
|
|
535
685
|
catch { /* use heap */ }
|
|
536
686
|
const heap = (deps.readHeapBytes ?? readRemainingHeapBytes)();
|
|
537
|
-
return Math.max(0, Math.min(heap, available ?? heap)) * SCAN_GUARD_REFUSE_AVAILABLE_FRACTION / multiplier;
|
|
687
|
+
return { heap, available, bytes: Math.max(0, Math.min(heap, available ?? heap)) * SCAN_GUARD_REFUSE_AVAILABLE_FRACTION / multiplier };
|
|
538
688
|
};
|
|
689
|
+
let largestAdmittedUnit = -1;
|
|
539
690
|
const readBudget = {
|
|
691
|
+
maximumUnitBytes: () => Math.floor(readHeadroom().bytes),
|
|
540
692
|
admit(bytes, unit) {
|
|
541
693
|
// Parsed temporary payloads are released between groups. Lifetime input
|
|
542
694
|
// bytes are not resident memory; price the next allocation against live headroom.
|
|
543
|
-
const
|
|
544
|
-
|
|
695
|
+
const headroom = readHeadroom();
|
|
696
|
+
const allowed = Math.floor(headroom.bytes);
|
|
697
|
+
const refused = !Number.isSafeInteger(bytes) || bytes < 0 || bytes > allowed;
|
|
698
|
+
if (refused || bytes > largestAdmittedUnit) {
|
|
699
|
+
options.onDiagnostic?.({ kind: "budget", decision: refused ? "refused" : "admitted", unit,
|
|
700
|
+
requested_bytes: bytes, allowed_native_bytes: allowed, profile: request.profile,
|
|
701
|
+
heap_available_bytes: headroom.heap, system_available_bytes: headroom.available ?? null });
|
|
702
|
+
if (!refused)
|
|
703
|
+
largestAdmittedUnit = bytes;
|
|
704
|
+
}
|
|
705
|
+
if (refused)
|
|
545
706
|
throw new SourceReadBudgetExceededError(unit, bytes, allowed);
|
|
546
707
|
},
|
|
547
708
|
};
|
|
@@ -623,27 +784,28 @@ async function scanResolvedSources(options, sources, scanGuard, getPlan, work, s
|
|
|
623
784
|
};
|
|
624
785
|
let { host, payloads } = await scanSources(options);
|
|
625
786
|
const requestedSessionRefs = options.sessionRefs?.filter((ref) => ref.trim().length > 0) ?? [];
|
|
787
|
+
const limitedScan = options.sample !== undefined || options.limitFiles !== undefined;
|
|
626
788
|
if (requestedSessionRefs.length === 0)
|
|
627
|
-
return buildLiveSnapshot({ host, sources: payloads });
|
|
789
|
+
return buildLiveSnapshot({ host, sources: payloads }, limitedScan);
|
|
628
790
|
const missingChildRefs = missingDelegatedChildSessionRefs(payloads, requestedSessionRefs);
|
|
629
791
|
if (missingChildRefs.length > 0) {
|
|
630
792
|
const expandedOptions = { ...options, sessionRefs: [...requestedSessionRefs, ...missingChildRefs] };
|
|
631
793
|
await scanGuard.assess(expandedOptions);
|
|
632
794
|
({ host, payloads } = await scanSources(expandedOptions));
|
|
633
795
|
}
|
|
634
|
-
const combined = buildLiveSnapshot({ host, sources: payloads });
|
|
796
|
+
const combined = buildLiveSnapshot({ host, sources: payloads }, limitedScan);
|
|
635
797
|
const resolvedSessionRefs = requestedSessionRefs.map((ref) => {
|
|
636
798
|
const session = combined.getSession(ref);
|
|
637
799
|
if (!session)
|
|
638
|
-
throw new
|
|
800
|
+
throw new SessionReferenceNotFoundError(`Lite scan did not find requested session ${ref}.`);
|
|
639
801
|
return session.id;
|
|
640
802
|
});
|
|
641
803
|
return buildLiveSnapshot({
|
|
642
804
|
host,
|
|
643
805
|
sources: payloads.map((payload) => filterLiveSourcePayloadBySessions(payload, resolvedSessionRefs)),
|
|
644
|
-
});
|
|
806
|
+
}, limitedScan);
|
|
645
807
|
}
|
|
646
|
-
export function buildLiveSnapshot(probe) {
|
|
808
|
+
export function buildLiveSnapshot(probe, limitedScan = false) {
|
|
647
809
|
const sources = probe.sources.map((payload) => payload.source);
|
|
648
810
|
const turns = probe.sources
|
|
649
811
|
.flatMap((payload) => payload.turns)
|
|
@@ -685,7 +847,9 @@ export function buildLiveSnapshot(probe) {
|
|
|
685
847
|
contexts: probe.sources.flatMap((payload) => payload.contexts),
|
|
686
848
|
ask_user_question_turns: probe.sources.flatMap((payload) => payload.ask_user_question_turns),
|
|
687
849
|
loss_audits: probe.sources.flatMap((payload) => payload.loss_audits),
|
|
688
|
-
|
|
850
|
+
...(probe.sources.some(p => p.conversation_evidence !== undefined)
|
|
851
|
+
? { conversation_evidence: probe.sources.flatMap(p => p.conversation_evidence ?? []) } : {}),
|
|
852
|
+
}), candidates, limitedScan);
|
|
689
853
|
}
|
|
690
854
|
async function prepareSourceScan(source, options, adapters, metadata) {
|
|
691
855
|
const adapter = adapters.listPlatformAdapters().find((entry) => entry.platform === source.platform);
|
|
@@ -767,7 +931,11 @@ async function scanSourceWithCollector(source, options, contextMode, sourceAdapt
|
|
|
767
931
|
if (selectSessionFiles && !options.readBudget) {
|
|
768
932
|
sourceFiles = await sourceAdapters.selectSourceSessionFiles(source, sourceFiles, options.sessionRefs);
|
|
769
933
|
}
|
|
770
|
-
const probe = await sourceAdapters.runSourceProbe(
|
|
934
|
+
const probe = await sourceAdapters.runSourceProbe(evidence => {
|
|
935
|
+
if (work)
|
|
936
|
+
work.canonicalInterpretations++;
|
|
937
|
+
return interpretSessionEvidence(evidence, { formatContextBodies: contextMode !== "none" });
|
|
938
|
+
}, {
|
|
771
939
|
...buildProbeOptions(source, options),
|
|
772
940
|
source_file_paths: { [source.id]: sourceFiles },
|
|
773
941
|
source_file_plans: { [source.id]: readPlan },
|
|
@@ -780,7 +948,7 @@ async function scanSourceWithCollector(source, options, contextMode, sourceAdapt
|
|
|
780
948
|
work.payloadFilesProcessed += sourceFiles.length;
|
|
781
949
|
work.payloadRecordsProcessed += payload.source.total_records;
|
|
782
950
|
}
|
|
783
|
-
const compacted = compactSourcePayload(payload, contextMode, resolveContextTargets(options));
|
|
951
|
+
const compacted = compactSourcePayload(payload, contextMode, resolveContextTargets(options), options.retainConversationEvidence);
|
|
784
952
|
return {
|
|
785
953
|
host: probe.host,
|
|
786
954
|
payload: options.sessionRefs?.length
|
|
@@ -881,6 +1049,7 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
881
1049
|
const sessionsById = new Map();
|
|
882
1050
|
const turnsById = new Map();
|
|
883
1051
|
const contextsByTurnId = new Map();
|
|
1052
|
+
const evidenceBySessionId = new Map();
|
|
884
1053
|
const askTurnsById = new Map();
|
|
885
1054
|
const sessionRelationFragments = [];
|
|
886
1055
|
const familyInventories = [];
|
|
@@ -893,7 +1062,11 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
893
1062
|
let forwardedSourceStart = false;
|
|
894
1063
|
let host;
|
|
895
1064
|
for (const [groupIndex, group] of selectedGroupFiles.entries()) {
|
|
896
|
-
const probe = await sourceAdapters.runSourceProbe(
|
|
1065
|
+
const probe = await sourceAdapters.runSourceProbe(evidence => {
|
|
1066
|
+
if (work)
|
|
1067
|
+
work.canonicalInterpretations++;
|
|
1068
|
+
return interpretSessionEvidence(evidence, { formatContextBodies: contextMode !== "none" });
|
|
1069
|
+
}, {
|
|
897
1070
|
...buildProbeOptions(source, options, group.targetSessionRefs),
|
|
898
1071
|
source_file_paths: { [source.id]: group.files },
|
|
899
1072
|
source_file_plans: { [source.id]: plan.readPlan },
|
|
@@ -940,6 +1113,13 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
940
1113
|
for (const context of selectPayloadContexts(groupPayload, contextMode, resolveContextTargets(options))) {
|
|
941
1114
|
contextsByTurnId.set(context.turn_id, context);
|
|
942
1115
|
}
|
|
1116
|
+
if (options.retainConversationEvidence) {
|
|
1117
|
+
const evidence = buildConversationEvidence(groupPayload.turns, groupPayload.contexts, groupPayload.atoms, groupPayload.sessions);
|
|
1118
|
+
for (const session of groupPayload.sessions)
|
|
1119
|
+
evidenceBySessionId.set(session.id, []);
|
|
1120
|
+
for (const message of evidence)
|
|
1121
|
+
evidenceBySessionId.get(message.session_id).push(message);
|
|
1122
|
+
}
|
|
943
1123
|
for (const askTurn of groupPayload.ask_user_question_turns)
|
|
944
1124
|
askTurnsById.set(askTurn.id, askTurn);
|
|
945
1125
|
sessionRelationFragments.push(...groupPayload.fragments.filter((fragment) => fragment.fragment_kind === "session_relation"));
|
|
@@ -1025,6 +1205,7 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
1025
1205
|
delegated_children: family.children,
|
|
1026
1206
|
turns,
|
|
1027
1207
|
contexts: [...contextsByTurnId.values()],
|
|
1208
|
+
...(options.retainConversationEvidence ? { conversation_evidence: [...evidenceBySessionId.values()].flat() } : {}),
|
|
1028
1209
|
ask_user_question_turns: [...askTurnsById.values()],
|
|
1029
1210
|
loss_audits: lossAudits,
|
|
1030
1211
|
},
|
|
@@ -1114,6 +1295,7 @@ function sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, direc
|
|
|
1114
1295
|
function buildProbeOptions(source, options, targetSessionRefs = options.sessionRefs) {
|
|
1115
1296
|
return {
|
|
1116
1297
|
source_ids: [source.id],
|
|
1298
|
+
retain_raw_records: false,
|
|
1117
1299
|
read_budget: options.readBudget,
|
|
1118
1300
|
target_session_refs: targetSessionRefs,
|
|
1119
1301
|
limit_files_per_source: options.limitFiles,
|
|
@@ -1121,7 +1303,7 @@ function buildProbeOptions(source, options, targetSessionRefs = options.sessionR
|
|
|
1121
1303
|
on_progress: options.onProgress,
|
|
1122
1304
|
};
|
|
1123
1305
|
}
|
|
1124
|
-
function compactSourcePayload(payload, contextMode, contextTargets = []) {
|
|
1306
|
+
function compactSourcePayload(payload, contextMode, contextTargets = [], retainConversationEvidence = false) {
|
|
1125
1307
|
const relatedWork = flattenRelatedWorkIndex(buildSessionRelatedWorkIndex(payload.sessions, payload.fragments));
|
|
1126
1308
|
const family = familyInventoryFromPayload(payload, relatedWork);
|
|
1127
1309
|
return {
|
|
@@ -1134,6 +1316,7 @@ function compactSourcePayload(payload, contextMode, contextTargets = []) {
|
|
|
1134
1316
|
delegated_children: family.children,
|
|
1135
1317
|
turns: payload.turns,
|
|
1136
1318
|
contexts: selectPayloadContexts(payload, contextMode, contextTargets),
|
|
1319
|
+
...(retainConversationEvidence ? { conversation_evidence: buildConversationEvidence(payload.turns, payload.contexts, payload.atoms, payload.sessions) } : {}),
|
|
1137
1320
|
ask_user_question_turns: payload.ask_user_question_turns,
|
|
1138
1321
|
loss_audits: payload.loss_audits,
|
|
1139
1322
|
};
|
|
@@ -1246,6 +1429,7 @@ function filterLiveSourcePayloadBySessions(payload, sessionRefs) {
|
|
|
1246
1429
|
turns,
|
|
1247
1430
|
candidates: payload.candidates.filter((candidate) => sessionIds.has(candidate.session_ref)),
|
|
1248
1431
|
contexts: payload.contexts.filter((context) => turnIds.has(context.turn_id)),
|
|
1432
|
+
...(payload.conversation_evidence ? { conversation_evidence: payload.conversation_evidence.filter(m => sessionIds.has(m.session_id)) } : {}),
|
|
1249
1433
|
ask_user_question_turns: payload.ask_user_question_turns.filter((turn) => sessionIds.has(turn.session_id)),
|
|
1250
1434
|
related_work: relatedWork,
|
|
1251
1435
|
session_contributions: payload.session_contributions?.filter((entry) => familySessionIds.has(entry.session_ref)),
|
|
@@ -1521,4 +1705,7 @@ function normalizeJsonShapeForJsonOutputMutating(value) {
|
|
|
1521
1705
|
return value;
|
|
1522
1706
|
}
|
|
1523
1707
|
export { compileSql, compileSqlRequest, parseSqlRequest, QueryValidationError, SQL_REQUEST_SCHEMA, SQL_RESULT_SCHEMA, MAX_SQL_BYTES, MAX_QUERY_REQUEST_BYTES } from "./sql-query.js";
|
|
1708
|
+
export { BoundedCache } from "./bounded-cache.js";
|
|
1709
|
+
export { LiveHistoryReader } from "./history-reader.js";
|
|
1710
|
+
export { EvidenceCursorError, validateEvidenceBudget, DEFAULT_EVIDENCE_CHARS, MAX_EVIDENCE_CHARS, UNASSIGNED_PROJECT_KEY, BUILTIN_MODEL_PRICING_CATALOG, DEFAULT_MODEL_ALIASES, MODEL_PRICING_CATALOG_SNAPSHOT_DATE, buildPricingConfigTemplate, mergeUsagePricingConfigs, parseUsagePricingInput, resolveEffectiveQuotaLimitUsd, resolveModelPricing, normalizeMultipliers, parseDateEnd, parseDateOrRelativeStart, resolveTimeWindowBounds, resolveUsageTimezone, resolveWeekBucket, } from "@cchistory/canonical";
|
|
1524
1711
|
//# sourceMappingURL=index.js.map
|