@cchistory/lite 0.4.5 → 0.6.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 +7 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +36 -25
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +2 -2
- package/apps/lite-cli/dist/bin.js.map +1 -1
- package/apps/lite-cli/dist/index.d.ts.map +1 -1
- package/apps/lite-cli/dist/index.js +151 -66
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +59 -89
- package/apps/lite-cli/dist/index.test.js.map +1 -1
- package/apps/lite-cli/dist/query.d.ts +4 -1
- package/apps/lite-cli/dist/query.d.ts.map +1 -1
- package/apps/lite-cli/dist/query.js +45 -29
- package/apps/lite-cli/dist/query.js.map +1 -1
- package/apps/lite-cli/dist/resource-errors.d.ts +3 -0
- package/apps/lite-cli/dist/resource-errors.d.ts.map +1 -0
- package/apps/lite-cli/dist/resource-errors.js +17 -0
- package/apps/lite-cli/dist/resource-errors.js.map +1 -0
- package/apps/lite-cli/dist/shell.d.ts +12 -2
- package/apps/lite-cli/dist/shell.d.ts.map +1 -1
- package/apps/lite-cli/dist/shell.js +129 -57
- package/apps/lite-cli/dist/shell.js.map +1 -1
- package/apps/lite-cli/dist/sql-query.test.d.ts +2 -0
- package/apps/lite-cli/dist/sql-query.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/sql-query.test.js +290 -0
- package/apps/lite-cli/dist/sql-query.test.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/bin.js +2 -2
- package/apps/lite-tui/dist/bin.js.map +1 -1
- package/apps/lite-tui/dist/index.d.ts.map +1 -1
- package/apps/lite-tui/dist/index.js +6 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +10 -8
- package/apps/lite-tui/dist/index.test.js.map +1 -1
- package/apps/lite-tui/dist/render.d.ts +1 -1
- package/apps/lite-tui/dist/version.d.ts +1 -1
- package/apps/lite-tui/dist/version.js +1 -1
- package/bin/cchistory-lite-tui.mjs +2 -2
- package/bin/cchistory-lite.mjs +2 -2
- package/docs/guide/for-agents.md +66 -46
- package/docs/guide/lite.md +53 -11
- package/docs/guide/queries/latest-sessions.sql +4 -0
- package/docs/guide/queries/latest-turns.sql +1 -0
- package/docs/guide/queries/list-sessions.sql +2 -0
- package/docs/guide/query.md +153 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +7 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/directory-scope.js +11 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts +5 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.js +5 -1
- package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/query.d.ts +15 -0
- package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/query.js +208 -0
- package/node_modules/@cchistory/canonical/dist/query.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.js +3 -0
- package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.test.js +61 -0
- package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +30 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js +713 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js +56 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/package.json +1 -1
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts +7 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js +36 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts +26 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js +80 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/domain/dist/index.js +5 -0
- package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
- package/node_modules/@cchistory/domain/dist/masks.d.ts +31 -0
- package/node_modules/@cchistory/domain/dist/masks.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/masks.js +342 -0
- package/node_modules/@cchistory/domain/dist/masks.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts +58 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js +2 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts +67 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.js +2 -0
- package/node_modules/@cchistory/domain/dist/query.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts +14 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js +247 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -0
- package/node_modules/@cchistory/domain/package.json +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts +30 -9
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.js +314 -143
- package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.test.js +177 -20
- package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts +12 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js +44 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js +20 -0
- package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js +92 -0
- package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +22 -22
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +53 -47
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +287 -83
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +171 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/package.json +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +81 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +31 -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 +4 -3
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +32 -13
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js +46 -45
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +76 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
- 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 +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
- package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -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 +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
- package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
- 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 +11 -9
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +428 -0
- package/node_modules/commander/index.js +1224 -0
- package/node_modules/commander/package.json +38 -0
- package/node_modules/commander/typings/index.d.ts +310 -0
- package/node_modules/discontinuous-range/.npmignore +28 -0
- package/node_modules/discontinuous-range/.travis.yml +4 -0
- package/node_modules/discontinuous-range/LICENSE +21 -0
- package/node_modules/discontinuous-range/README.md +23 -0
- package/node_modules/discontinuous-range/index.js +144 -0
- package/node_modules/discontinuous-range/package.json +27 -0
- package/node_modules/discontinuous-range/test/main-test.js +96 -0
- package/node_modules/moo/LICENSE +29 -0
- package/node_modules/moo/README.md +385 -0
- package/node_modules/moo/moo.js +645 -0
- package/node_modules/moo/package.json +29 -0
- package/node_modules/nearley/LICENSE.txt +21 -0
- package/node_modules/nearley/README.md +80 -0
- package/node_modules/nearley/bin/nearley-railroad.js +121 -0
- package/node_modules/nearley/bin/nearley-test.js +64 -0
- package/node_modules/nearley/bin/nearley-unparse.js +29 -0
- package/node_modules/nearley/bin/nearleyc.js +38 -0
- package/node_modules/nearley/builtin/cow.ne +2 -0
- package/node_modules/nearley/builtin/number.ne +51 -0
- package/node_modules/nearley/builtin/postprocessors.ne +36 -0
- package/node_modules/nearley/builtin/string.ne +26 -0
- package/node_modules/nearley/builtin/whitespace.ne +5 -0
- package/node_modules/nearley/lib/compile.js +307 -0
- package/node_modules/nearley/lib/generate.js +244 -0
- package/node_modules/nearley/lib/lint.js +28 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
- package/node_modules/nearley/lib/nearley.js +564 -0
- package/node_modules/nearley/lib/stream.js +18 -0
- package/node_modules/nearley/lib/unparse.js +139 -0
- package/node_modules/nearley/package.json +63 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
- package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.js +6484 -0
- package/node_modules/pgsql-ast-parser/index.js.map +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/package.json +69 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/readme.md +255 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
- package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
- package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
- package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
- package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
- package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
- package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
- package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
- package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
- package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
- package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
- package/node_modules/railroad-diagrams/.gitattributes +22 -0
- package/node_modules/railroad-diagrams/.npmignore +163 -0
- package/node_modules/railroad-diagrams/README.md +86 -0
- package/node_modules/railroad-diagrams/css-example.py-js +183 -0
- package/node_modules/railroad-diagrams/example.html +141 -0
- package/node_modules/railroad-diagrams/generator.html +59 -0
- package/node_modules/railroad-diagrams/package.json +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
- package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
- package/node_modules/randexp/LICENSE +19 -0
- package/node_modules/randexp/README.md +134 -0
- package/node_modules/randexp/lib/randexp.js +245 -0
- package/node_modules/randexp/package.json +48 -0
- package/node_modules/ret/LICENSE +19 -0
- package/node_modules/ret/README.md +183 -0
- package/node_modules/ret/lib/index.js +282 -0
- package/node_modules/ret/lib/positions.js +17 -0
- package/node_modules/ret/lib/sets.js +82 -0
- package/node_modules/ret/lib/types.js +10 -0
- package/node_modules/ret/lib/util.js +111 -0
- package/node_modules/ret/package.json +35 -0
- package/package.json +22 -6
- package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
- package/schemas/cchistory-lite-error-v1.schema.json +58 -8
- package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
- package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
- package/schemas/cchistory-lite-query-v3.schema.json +57 -0
- package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
- package/skills/using-cchistory-lite/SKILL.md +126 -55
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { access, realpath, stat } from "node:fs/promises";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import process from "node:process";
|
|
5
6
|
import { deriveHostId, deriveSourceInstanceId, normalizeLocalPathIdentity, } from "@cchistory/domain";
|
|
6
|
-
import { auditProjectionConsistency, buildSessionLastMessageIndex, buildDirectoryScopedProjectTreeProjection, buildFallbackProjectObservationCandidates, buildProjectDisplayList, buildSessionRelatedWorkIndex, compareTurnsByChronology, compareTurnsByRecency, computeUsageOverview, computeUsageRollup, deriveProjectLinkSnapshot, filterProjectsByDirectoryScope, filterSessionsByDirectoryScope, filterTopLevelSessions, filterTurnsByDirectoryScope, buildSessionFamilyInventory, FAMILY_IO_PREVIEW_CHARS, listDelegatedRelationsForFamilyChildren, listSessionFamilies, mergeSessionFamilyInventories, installRuntimeWarningFilter, orderSessionsByLastMessage, pathMatchesDirectoryScope, searchSessionsInMemory, searchTurnsInMemory, resolveTurnUsage, summarizeSessionUsage, } from "@cchistory/canonical";
|
|
7
|
-
import { applyMaskTemplates } from "@cchistory/source-adapters";
|
|
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";
|
|
8
|
+
import { SourceReadBudgetExceededError, applyMaskTemplates } from "@cchistory/source-adapters";
|
|
8
9
|
import { SAMPLE_RANK_CONCURRENCY, mapPool } from "./async-pool.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export {
|
|
10
|
+
import { isSelectiveLatestQuery, newQueryReadWork } from "./selective-query.js";
|
|
11
|
+
import { PreparationMetadata } from "./preparation-metadata.js";
|
|
12
|
+
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
|
+
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
|
+
import { readAvailableMemoryBytes } from "./system-memory.js";
|
|
15
|
+
export { SourceReadBudgetExceededError } from "@cchistory/source-adapters";
|
|
16
|
+
export { readAvailableMemory, readAvailableMemoryBytes } from "./system-memory.js";
|
|
13
17
|
installRuntimeWarningFilter();
|
|
14
18
|
export function maskCompactPreview(value, kind) {
|
|
15
19
|
if (!value?.trim())
|
|
@@ -32,7 +36,14 @@ export class AmbiguousReferenceError extends Error {
|
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
export class LiveHistorySnapshot {
|
|
39
|
+
selectSampleSessions(perSource, directoryScope) {
|
|
40
|
+
return selectSampleSessions(this.data, perSource, directoryScope);
|
|
41
|
+
}
|
|
42
|
+
getDirectoryScopeDiagnostics(directoryScope) {
|
|
43
|
+
return summarizeDirectoryScope(this.data.sessions, directoryScope);
|
|
44
|
+
}
|
|
35
45
|
data;
|
|
46
|
+
readIdentity = { id: randomUUID(), prepared_at: new Date().toISOString() };
|
|
36
47
|
/** Non-fatal projection diagnostics kept visible to read-only surfaces. */
|
|
37
48
|
projectionIssues;
|
|
38
49
|
sourcesById;
|
|
@@ -101,6 +112,12 @@ export class LiveHistorySnapshot {
|
|
|
101
112
|
directoryScope: options.directoryScope,
|
|
102
113
|
}));
|
|
103
114
|
}
|
|
115
|
+
executeCollectionQuery(query, options = {}) {
|
|
116
|
+
return executeCanonicalQuery(this.data, query, options.directoryScope);
|
|
117
|
+
}
|
|
118
|
+
selectCollectionTemplate(kind, limit = 20, offset = 0, options = {}) {
|
|
119
|
+
return this.executeCollectionQuery(collectionQueryTemplate(kind, limit, offset), options);
|
|
120
|
+
}
|
|
104
121
|
listResolvedSessions(options = {}) {
|
|
105
122
|
return filterSessionsByDirectoryScope(this.data.sessions, options.directoryScope);
|
|
106
123
|
}
|
|
@@ -366,6 +383,46 @@ export class LiveHistorySnapshot {
|
|
|
366
383
|
}
|
|
367
384
|
}
|
|
368
385
|
export async function scanLiteHistory(options = {}) {
|
|
386
|
+
return withPreparedScan(options, (sources, scanGuard, getPlan) => scanResolvedSources(scanGuard.guardedOptions(options), sources, scanGuard, getPlan));
|
|
387
|
+
}
|
|
388
|
+
/** Query-only selective reads never escape as a reusable full snapshot. */
|
|
389
|
+
export async function scanLiteQuery(query, options = {}) {
|
|
390
|
+
const work = newQueryReadWork();
|
|
391
|
+
options = { ...options, contextMode: "none" };
|
|
392
|
+
return withPreparedScan(options, async (sources, scanGuard, getPlan) => {
|
|
393
|
+
const guardedOptions = scanGuard.guardedOptions(options);
|
|
394
|
+
let selection;
|
|
395
|
+
for (const source of sources) {
|
|
396
|
+
const plan = await getPlan(source, options);
|
|
397
|
+
work.discoveredPrimaryFiles += plan.discoveredPrimaryFiles;
|
|
398
|
+
work.plannedPrimaryFiles += plan.readPlan.files.length;
|
|
399
|
+
work.metadataEvidenceFiles += new Set(plan.selectionEvidence.flatMap(e => [...e.files])).size;
|
|
400
|
+
}
|
|
401
|
+
if (isSelectiveLatestQuery(query) && sources.length === 1 && sources[0].platform === "codex" && !options.sample && !options.sessionRefs?.length) {
|
|
402
|
+
const source = sources[0], plan = await getPlan(source, options);
|
|
403
|
+
try {
|
|
404
|
+
selection = await prepareSelectiveGroups(plan, query, work, scanGuard, guardedOptions.readBudget);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
const { SourceFileReadPlanChangedError } = await import("@cchistory/source-adapters");
|
|
408
|
+
if (!(error instanceof SourceFileReadPlanChangedError))
|
|
409
|
+
throw error;
|
|
410
|
+
work.fallbackReason = "source_changed";
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
else
|
|
414
|
+
work.fallbackReason = query.complete ? "complete_requested" : "query_or_source_shape";
|
|
415
|
+
const snapshot = await scanResolvedSources(guardedOptions, sources, scanGuard, getPlan, work, selection);
|
|
416
|
+
const result = snapshot.executeCollectionQuery(query, { directoryScope: options.directoryScope });
|
|
417
|
+
if (selection?.stopped)
|
|
418
|
+
result.coverage = { execution: "selective", rows: "exact", diagnostics: "observed" };
|
|
419
|
+
work.retainedSessions = snapshot.data.sessions.length;
|
|
420
|
+
work.retainedTurns = snapshot.data.turns.length;
|
|
421
|
+
return { identity: snapshot.readIdentity, sourceIds: snapshot.data.sources.map(s => s.id), directoryScope: options.directoryScope,
|
|
422
|
+
result, projectionIssues: snapshot.projectionIssues, sources: snapshot.data.sources, lossAudits: snapshot.data.loss_audits, directoryScopeDiagnostics: snapshot.getDirectoryScopeDiagnostics(options.directoryScope), work };
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
async function withPreparedScan(options, run) {
|
|
369
426
|
if (options.contextMode === "matching" && resolveContextTargets(options).length === 0) {
|
|
370
427
|
throw new Error("matching context mode requires at least one context target.");
|
|
371
428
|
}
|
|
@@ -377,9 +434,31 @@ export async function scanLiteHistory(options = {}) {
|
|
|
377
434
|
throw new Error(`No selected Lite source can resolve requested session ${options.sessionRefs?.join(", ")}.`);
|
|
378
435
|
}
|
|
379
436
|
}
|
|
380
|
-
const
|
|
437
|
+
const sourceAdapters = await import("@cchistory/source-adapters");
|
|
438
|
+
const metadata = new PreparationMetadata();
|
|
439
|
+
const plans = new Map();
|
|
440
|
+
const getPlan = (source, scanOptions) => {
|
|
441
|
+
const key = JSON.stringify([source.id, scanOptions.sessionRefs ?? []]);
|
|
442
|
+
let pending = plans.get(key);
|
|
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);
|
|
456
|
+
}
|
|
457
|
+
return pending;
|
|
458
|
+
};
|
|
459
|
+
const scanGuard = await beginScanGuard(options, sources, getPlan);
|
|
381
460
|
try {
|
|
382
|
-
return await
|
|
461
|
+
return await run(sources, scanGuard, getPlan);
|
|
383
462
|
}
|
|
384
463
|
finally {
|
|
385
464
|
await scanGuard.release();
|
|
@@ -387,17 +466,18 @@ export async function scanLiteHistory(options = {}) {
|
|
|
387
466
|
}
|
|
388
467
|
/**
|
|
389
468
|
* Runs the guard layer around a scan: serialize full scans on this machine,
|
|
390
|
-
*
|
|
469
|
+
* warn when the conservative peak estimate is high, and arm the
|
|
391
470
|
* watchdog that aborts the scan if available memory collapses mid-probe. The
|
|
392
471
|
* kill-switch env is read here — the live-runtime entry — so the guard module
|
|
393
472
|
* and its tests stay explicit about behavior.
|
|
394
473
|
*/
|
|
395
|
-
async function beginScanGuard(options, sources) {
|
|
474
|
+
async function beginScanGuard(options, sources, getPlan) {
|
|
396
475
|
const request = options.scanGuard;
|
|
397
476
|
if (!request || !isScanGuardEnabled(process.env.CCHISTORY_SCAN_GUARD)) {
|
|
398
477
|
return {
|
|
399
478
|
guardedOptions: (scanOptions) => scanOptions,
|
|
400
479
|
assertHealthy: () => { },
|
|
480
|
+
assess: async () => { },
|
|
401
481
|
release: async () => { },
|
|
402
482
|
};
|
|
403
483
|
}
|
|
@@ -414,31 +494,57 @@ async function beginScanGuard(options, sources) {
|
|
|
414
494
|
}
|
|
415
495
|
lockHandle = lock.handle;
|
|
416
496
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
497
|
+
const assess = async (scanOptions) => {
|
|
498
|
+
const directoryScoped = Boolean(scanOptions.directoryScope);
|
|
499
|
+
// Planning failures must propagate before the generic estimator's best-effort walk.
|
|
500
|
+
const prepared = new Map();
|
|
501
|
+
if (!deps.walkRootBytes) {
|
|
502
|
+
for (const source of sources)
|
|
503
|
+
prepared.set(source.slot_id, await getPlan(source, scanOptions));
|
|
504
|
+
}
|
|
505
|
+
const walkRootBytes = deps.walkRootBytes ?? (async (_root, _limit, slotId) => {
|
|
506
|
+
const plan = slotId && prepared.get(slotId);
|
|
507
|
+
if (!plan)
|
|
508
|
+
throw new Error(`Scan estimate has no source for ${slotId}.`);
|
|
509
|
+
return plan.readPlan.bytes;
|
|
510
|
+
});
|
|
511
|
+
const assessment = await assessScanRisk({
|
|
512
|
+
roots: sources.map((source) => ({ path: source.base_dir, slot_id: source.slot_id })),
|
|
513
|
+
limitFiles: scanOptions.limitFiles,
|
|
514
|
+
profile: request.profile,
|
|
515
|
+
...(directoryScoped ? { directoryScoped: true } : {}),
|
|
516
|
+
}, { walkRootBytes, readAvailableBytes: deps.readAvailableBytes, readHeapBytes: deps.readHeapBytes });
|
|
517
|
+
if (assessment.status !== "ok") {
|
|
518
|
+
options.onScanGuardEvent?.({ type: "warn", assessment });
|
|
435
519
|
}
|
|
520
|
+
};
|
|
521
|
+
try {
|
|
522
|
+
await assess(options);
|
|
436
523
|
}
|
|
437
524
|
catch (error) {
|
|
438
525
|
// A refused scan must not keep siblings queued behind a lock it no longer needs.
|
|
439
526
|
await lockHandle?.release();
|
|
440
527
|
throw error;
|
|
441
528
|
}
|
|
529
|
+
const multiplier = request.profile === "full" ? FULL_SCAN_MEMORY_MULTIPLIER : LIGHT_SCAN_MEMORY_MULTIPLIER;
|
|
530
|
+
const readHeadroom = () => {
|
|
531
|
+
let available;
|
|
532
|
+
try {
|
|
533
|
+
available = (deps.readAvailableBytes ?? readAvailableMemoryBytes)();
|
|
534
|
+
}
|
|
535
|
+
catch { /* use heap */ }
|
|
536
|
+
const heap = (deps.readHeapBytes ?? readRemainingHeapBytes)();
|
|
537
|
+
return Math.max(0, Math.min(heap, available ?? heap)) * SCAN_GUARD_REFUSE_AVAILABLE_FRACTION / multiplier;
|
|
538
|
+
};
|
|
539
|
+
const readBudget = {
|
|
540
|
+
admit(bytes, unit) {
|
|
541
|
+
// Parsed temporary payloads are released between groups. Lifetime input
|
|
542
|
+
// bytes are not resident memory; price the next allocation against live headroom.
|
|
543
|
+
const allowed = Math.floor(readHeadroom());
|
|
544
|
+
if (!Number.isSafeInteger(bytes) || bytes < 0 || bytes > allowed)
|
|
545
|
+
throw new SourceReadBudgetExceededError(unit, bytes, allowed);
|
|
546
|
+
},
|
|
547
|
+
};
|
|
442
548
|
const watchdog = createScanWatchdog({
|
|
443
549
|
...deps.watchdog,
|
|
444
550
|
readAvailableBytes: deps.watchdog?.readAvailableBytes ?? deps.readAvailableBytes,
|
|
@@ -446,35 +552,62 @@ async function beginScanGuard(options, sources) {
|
|
|
446
552
|
return {
|
|
447
553
|
guardedOptions: (scanOptions) => ({
|
|
448
554
|
...scanOptions,
|
|
555
|
+
readBudget,
|
|
449
556
|
onProgress: (event) => {
|
|
450
557
|
watchdog.observeProgress(event);
|
|
451
558
|
scanOptions.onProgress?.(event);
|
|
452
559
|
},
|
|
453
560
|
}),
|
|
454
561
|
assertHealthy: () => watchdog.assertHealthy(),
|
|
562
|
+
assess,
|
|
455
563
|
release: async () => {
|
|
456
564
|
await lockHandle?.release();
|
|
457
565
|
},
|
|
458
566
|
};
|
|
459
567
|
}
|
|
460
|
-
async function scanResolvedSources(options, sources, scanGuard) {
|
|
568
|
+
async function scanResolvedSources(options, sources, scanGuard, getPlan, work, selection) {
|
|
461
569
|
const sourceAdapters = await import("@cchistory/source-adapters");
|
|
462
570
|
const contextMode = options.contextMode ?? "full";
|
|
463
571
|
const scanSources = async (scanOptions) => {
|
|
464
572
|
const nextPayloads = [];
|
|
465
573
|
let nextHost;
|
|
466
|
-
//
|
|
467
|
-
//
|
|
574
|
+
// Reuse this attempt's inventory, then scan one source at a time so raw
|
|
575
|
+
// adapter payloads can be released promptly. Each
|
|
468
576
|
// adapter explicitly declares its minimum safe projection boundary; the
|
|
469
577
|
// runtime never infers independence from a file-oriented source shape.
|
|
470
578
|
for (const source of sources) {
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
579
|
+
const plan = await getPlan(source, scanOptions);
|
|
580
|
+
let result;
|
|
581
|
+
try {
|
|
582
|
+
for (const evidence of plan.selectionEvidence)
|
|
583
|
+
await sourceAdapters.assertSourceFileReadPlanCurrent(evidence);
|
|
584
|
+
if (selection)
|
|
585
|
+
await sourceAdapters.assertSourceFileReadPlanCurrent(plan.readPlan);
|
|
586
|
+
result = plan.groups
|
|
587
|
+
? await scanLogicalSessionGroups(source, scanOptions, contextMode, sourceAdapters, plan, () => scanGuard.assess(scanOptions), work, selection)
|
|
588
|
+
: await scanSourceWithCollector(source, scanOptions, contextMode, sourceAdapters, plan.readPlan.files, plan.readPlan, plan.selectSessionFiles, work);
|
|
589
|
+
for (const evidence of plan.selectionEvidence)
|
|
590
|
+
await sourceAdapters.assertSourceFileReadPlanCurrent(evidence);
|
|
591
|
+
if (selection)
|
|
592
|
+
await sourceAdapters.assertSourceFileReadPlanCurrent(plan.readPlan);
|
|
593
|
+
}
|
|
594
|
+
catch (error) {
|
|
595
|
+
if (!(error instanceof sourceAdapters.SourceFileReadPlanChangedError))
|
|
596
|
+
throw error;
|
|
597
|
+
if (selection)
|
|
598
|
+
selection.stopped = false;
|
|
599
|
+
if (work) {
|
|
600
|
+
work.fallbackReason = "source_changed";
|
|
601
|
+
work.skippedPrimaryFiles = 0;
|
|
602
|
+
}
|
|
603
|
+
// Re-read this source without version-dependent grouping/pruning. Keep
|
|
604
|
+
// this attempt's inventory, including files excluded by stale metadata.
|
|
605
|
+
const inventory = [...new Set([...plan.readPlan.files, ...plan.selectionEvidence.flatMap(e => [...e.files])])];
|
|
606
|
+
const files = scanOptions.sample
|
|
607
|
+
? await selectSampleSourceFiles(source, inventory, scanOptions.sample.perSource, sourceAdapters) : inventory;
|
|
608
|
+
const readPlan = await sourceAdapters.createSourceFileReadPlan(source, files, scanOptions.safeMode ?? false);
|
|
609
|
+
result = await scanSourceWithCollector(source, scanOptions, contextMode, sourceAdapters, files, readPlan, false, work);
|
|
610
|
+
}
|
|
478
611
|
nextHost ??= result.host;
|
|
479
612
|
nextPayloads.push(result.payload);
|
|
480
613
|
// Watchdog backstop: breaches recorded inside adapter progress callbacks
|
|
@@ -483,7 +616,7 @@ async function scanResolvedSources(options, sources, scanGuard) {
|
|
|
483
616
|
scanGuard.assertHealthy();
|
|
484
617
|
}
|
|
485
618
|
if (!nextHost) {
|
|
486
|
-
const emptyProbe = await sourceAdapters.runSourceProbe({}, []);
|
|
619
|
+
const emptyProbe = await sourceAdapters.runSourceProbe(interpretSessionEvidence, {}, []);
|
|
487
620
|
nextHost = emptyProbe.host;
|
|
488
621
|
}
|
|
489
622
|
return { host: nextHost, payloads: nextPayloads };
|
|
@@ -494,10 +627,9 @@ async function scanResolvedSources(options, sources, scanGuard) {
|
|
|
494
627
|
return buildLiveSnapshot({ host, sources: payloads });
|
|
495
628
|
const missingChildRefs = missingDelegatedChildSessionRefs(payloads, requestedSessionRefs);
|
|
496
629
|
if (missingChildRefs.length > 0) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}));
|
|
630
|
+
const expandedOptions = { ...options, sessionRefs: [...requestedSessionRefs, ...missingChildRefs] };
|
|
631
|
+
await scanGuard.assess(expandedOptions);
|
|
632
|
+
({ host, payloads } = await scanSources(expandedOptions));
|
|
501
633
|
}
|
|
502
634
|
const combined = buildLiveSnapshot({ host, sources: payloads });
|
|
503
635
|
const resolvedSessionRefs = requestedSessionRefs.map((ref) => {
|
|
@@ -555,26 +687,99 @@ export function buildLiveSnapshot(probe) {
|
|
|
555
687
|
loss_audits: probe.sources.flatMap((payload) => payload.loss_audits),
|
|
556
688
|
}), candidates);
|
|
557
689
|
}
|
|
558
|
-
async function
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
690
|
+
async function prepareSourceScan(source, options, adapters, metadata) {
|
|
691
|
+
const adapter = adapters.listPlatformAdapters().find((entry) => entry.platform === source.platform);
|
|
692
|
+
let files;
|
|
693
|
+
let discoveredPrimaryFiles;
|
|
694
|
+
let groups;
|
|
695
|
+
const selectionEvidence = new Set();
|
|
696
|
+
if (adapter?.projectionBoundary === "logical_session") {
|
|
697
|
+
({ files, groups, discoveredPrimaryFiles } = await prepareLogicalSessionGroups(source, options, adapters, async (filePaths, includeWorkspaceMetadata) => {
|
|
698
|
+
const inspected = await metadata.inspect(source, filePaths, {
|
|
699
|
+
includeWorkspaceMetadata,
|
|
700
|
+
workspaceScan: source.platform === "codex" && options.directoryScope ? "first" : "full",
|
|
701
|
+
});
|
|
702
|
+
for (const evidence of inspected.evidence)
|
|
703
|
+
selectionEvidence.add(evidence);
|
|
704
|
+
return inspected.metadata;
|
|
705
|
+
}));
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
files = await adapters.listSourceFiles(source.platform, source.base_dir, options.limitFiles);
|
|
709
|
+
discoveredPrimaryFiles = files.length;
|
|
710
|
+
if (options.directoryScope) {
|
|
711
|
+
files = files.filter((file) => sourceFileMayBeInDirectoryScope(adapters, source, file, options.directoryScope));
|
|
712
|
+
}
|
|
713
|
+
if (options.sample)
|
|
714
|
+
files = await selectSampleSourceFiles(source, files, options.sample.perSource, adapters);
|
|
715
|
+
}
|
|
716
|
+
const selectedFiles = groups ? groups.flatMap((group) => group.files) : files;
|
|
717
|
+
const readPlan = await adapters.createSourceFileReadPlan(source, selectedFiles, options.safeMode ?? false);
|
|
718
|
+
// Some source-level identity lookups read whole JSON files. Budget all their
|
|
719
|
+
// candidates before doing that work; retain the probe's existing targeting rule.
|
|
720
|
+
const selectSessionFiles = adapter?.projectionBoundary !== "logical_session"
|
|
721
|
+
&& !options.directoryScope && !options.sample && Boolean(options.sessionRefs?.length);
|
|
722
|
+
return { discoveredPrimaryFiles, readPlan, selectionEvidence: [...selectionEvidence], selectSessionFiles, groups, fallbackFiles: groups ? files : undefined };
|
|
723
|
+
}
|
|
724
|
+
async function prepareSelectiveGroups(plan, query, work, guard, budget) {
|
|
725
|
+
if (!plan.groups?.length) {
|
|
726
|
+
work.fallbackReason = "uncertain_grouping";
|
|
727
|
+
return undefined;
|
|
728
|
+
}
|
|
729
|
+
const adapters = await import("@cchistory/source-adapters");
|
|
730
|
+
for (const evidence of plan.selectionEvidence)
|
|
731
|
+
await adapters.assertSourceFileReadPlanCurrent(evidence);
|
|
732
|
+
await adapters.assertSourceFileReadPlanCurrent(plan.readPlan);
|
|
733
|
+
const byFile = new Map();
|
|
734
|
+
for (const file of plan.readPlan.files) {
|
|
735
|
+
try {
|
|
736
|
+
budget?.admit(plan.readPlan.versions[file]?.size ?? 0, file);
|
|
737
|
+
}
|
|
738
|
+
catch (error) {
|
|
739
|
+
if (!(error instanceof SourceReadBudgetExceededError))
|
|
740
|
+
throw error;
|
|
741
|
+
work.fallbackReason = "read_budget";
|
|
742
|
+
return undefined;
|
|
743
|
+
}
|
|
744
|
+
const evidence = await adapters.inspectCodexActivityEvidence(plan.readPlan, file);
|
|
745
|
+
work.inventoryFiles++;
|
|
746
|
+
work.inventoryBytesRead += evidence.bytesRead;
|
|
747
|
+
work.inventoryRecordsDecoded += evidence.recordsDecoded;
|
|
748
|
+
byFile.set(file, evidence);
|
|
749
|
+
guard.assertHealthy();
|
|
750
|
+
if (!evidence.supported || hasSessionFamilyLinkTool(evidence.toolNames)) {
|
|
751
|
+
work.fallbackReason = evidence.reason ?? "family_link_tool";
|
|
752
|
+
return undefined;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
const groups = plan.groups.map(group => ({ group, evidence: group.files.map(file => byFile.get(file)) }));
|
|
756
|
+
if (groups.some(g => new Set(g.evidence.map(e => e.sessionId)).size !== 1)
|
|
757
|
+
|| new Set(groups.map(g => g.evidence[0]?.sessionId)).size !== groups.length) {
|
|
758
|
+
work.fallbackReason = "group_identity_mismatch";
|
|
759
|
+
return undefined;
|
|
760
|
+
}
|
|
761
|
+
const ranked = groups.map(g => ({ group: g.group, bound: g.evidence.reduce((max, e) => e.upperBound > max ? e.upperBound : max, "") }))
|
|
762
|
+
.sort((a, b) => b.bound.localeCompare(a.bound));
|
|
763
|
+
await adapters.assertSourceFileReadPlanCurrent(plan.readPlan);
|
|
764
|
+
return { groups: ranked.map(x => x.group), upperBounds: ranked.map(x => x.bound), query, stopped: false };
|
|
765
|
+
}
|
|
766
|
+
async function scanSourceWithCollector(source, options, contextMode, sourceAdapters, sourceFiles, readPlan, selectSessionFiles = false, work) {
|
|
767
|
+
if (selectSessionFiles && !options.readBudget) {
|
|
768
|
+
sourceFiles = await sourceAdapters.selectSourceSessionFiles(source, sourceFiles, options.sessionRefs);
|
|
769
|
+
}
|
|
770
|
+
const probe = await sourceAdapters.runSourceProbe(work ? evidence => { work.canonicalInterpretations++; return interpretSessionEvidence(evidence); } : interpretSessionEvidence, {
|
|
571
771
|
...buildProbeOptions(source, options),
|
|
572
|
-
|
|
772
|
+
source_file_paths: { [source.id]: sourceFiles },
|
|
773
|
+
source_file_plans: { [source.id]: readPlan },
|
|
573
774
|
}, [source]);
|
|
574
775
|
const payload = probe.sources[0];
|
|
575
776
|
if (!payload) {
|
|
576
777
|
throw new Error(`Lite source probe produced no payload for ${source.display_name}.`);
|
|
577
778
|
}
|
|
779
|
+
if (work) {
|
|
780
|
+
work.payloadFilesProcessed += sourceFiles.length;
|
|
781
|
+
work.payloadRecordsProcessed += payload.source.total_records;
|
|
782
|
+
}
|
|
578
783
|
const compacted = compactSourcePayload(payload, contextMode, resolveContextTargets(options));
|
|
579
784
|
return {
|
|
580
785
|
host: probe.host,
|
|
@@ -583,7 +788,7 @@ async function scanSourceWithCollector(source, options, contextMode, sourceAdapt
|
|
|
583
788
|
: compacted,
|
|
584
789
|
};
|
|
585
790
|
}
|
|
586
|
-
async function
|
|
791
|
+
async function prepareLogicalSessionGroups(source, options, sourceAdapters, inspectGroupFiles) {
|
|
587
792
|
const listedFiles = await sourceAdapters.listSourceFiles(source.platform, source.base_dir, options.limitFiles);
|
|
588
793
|
let files = options.directoryScope
|
|
589
794
|
? listedFiles.filter((filePath) => sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, options.directoryScope))
|
|
@@ -601,13 +806,13 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
601
806
|
files = await selectSampleSourceFiles(source, files, options.sample.perSource, sourceAdapters);
|
|
602
807
|
}
|
|
603
808
|
if (files.length === 0) {
|
|
604
|
-
return
|
|
809
|
+
return { files: [], discoveredPrimaryFiles: listedFiles.length };
|
|
605
810
|
}
|
|
606
811
|
const filesByGroup = new Map();
|
|
607
812
|
const requestedSessionRefs = options.sessionRefs?.filter((ref) => ref.trim().length > 0) ?? [];
|
|
608
813
|
const inspectedFiles = await inspectGroupFiles(files, Boolean(options.directoryScope || requestedSessionRefs.length > 0));
|
|
609
814
|
if (inspectedFiles.some((metadata) => metadata.sessionKeyState === "uncertain")) {
|
|
610
|
-
return
|
|
815
|
+
return { files, discoveredPrimaryFiles: listedFiles.length };
|
|
611
816
|
}
|
|
612
817
|
for (const [fileIndex, filePath] of files.entries()) {
|
|
613
818
|
const metadata = inspectedFiles[fileIndex];
|
|
@@ -665,8 +870,12 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
665
870
|
: undefined,
|
|
666
871
|
}));
|
|
667
872
|
if (selectedGroupFiles.length === 0) {
|
|
668
|
-
return
|
|
873
|
+
return { files: [], discoveredPrimaryFiles: listedFiles.length };
|
|
669
874
|
}
|
|
875
|
+
return { files, groups: selectedGroupFiles, discoveredPrimaryFiles: listedFiles.length };
|
|
876
|
+
}
|
|
877
|
+
async function scanLogicalSessionGroups(source, options, contextMode, sourceAdapters, plan, assessExpandedPlan, work, selection) {
|
|
878
|
+
const selectedGroupFiles = selection?.groups ?? plan.groups;
|
|
670
879
|
const blobsById = new Map();
|
|
671
880
|
const candidatesById = new Map();
|
|
672
881
|
const sessionsById = new Map();
|
|
@@ -683,10 +892,11 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
683
892
|
let requiresSourceCollector = false;
|
|
684
893
|
let forwardedSourceStart = false;
|
|
685
894
|
let host;
|
|
686
|
-
for (const group of selectedGroupFiles) {
|
|
687
|
-
const probe = await sourceAdapters.runSourceProbe({
|
|
895
|
+
for (const [groupIndex, group] of selectedGroupFiles.entries()) {
|
|
896
|
+
const probe = await sourceAdapters.runSourceProbe(work ? evidence => { work.canonicalInterpretations++; return interpretSessionEvidence(evidence); } : interpretSessionEvidence, {
|
|
688
897
|
...buildProbeOptions(source, options, group.targetSessionRefs),
|
|
689
898
|
source_file_paths: { [source.id]: group.files },
|
|
899
|
+
source_file_plans: { [source.id]: plan.readPlan },
|
|
690
900
|
on_progress: (event) => {
|
|
691
901
|
if (event.stage === "source_start") {
|
|
692
902
|
if (forwardedSourceStart)
|
|
@@ -706,6 +916,10 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
706
916
|
if (!groupPayload) {
|
|
707
917
|
throw new Error(`Lite source probe produced no payload for ${source.display_name}.`);
|
|
708
918
|
}
|
|
919
|
+
if (work) {
|
|
920
|
+
work.payloadFilesProcessed += group.files.length;
|
|
921
|
+
work.payloadRecordsProcessed += groupPayload.source.total_records;
|
|
922
|
+
}
|
|
709
923
|
totalRecords += groupPayload.source.total_records;
|
|
710
924
|
totalFragments += groupPayload.source.total_fragments;
|
|
711
925
|
totalAtoms += groupPayload.source.total_atoms;
|
|
@@ -731,9 +945,43 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
|
|
|
731
945
|
sessionRelationFragments.push(...groupPayload.fragments.filter((fragment) => fragment.fragment_kind === "session_relation"));
|
|
732
946
|
familyInventories.push(familyInventoryFromPayload(groupPayload, flattenRelatedWorkIndex(buildSessionRelatedWorkIndex(groupPayload.sessions, groupPayload.fragments))));
|
|
733
947
|
lossAudits.push(...groupPayload.loss_audits);
|
|
948
|
+
if (selection && groupPayload.loss_audits.length > 0) {
|
|
949
|
+
// Missing payloads cannot prove a latest-row cutoff even with stable metadata.
|
|
950
|
+
selection.stopped = false;
|
|
951
|
+
selection = undefined;
|
|
952
|
+
if (work)
|
|
953
|
+
work.fallbackReason = "read_loss";
|
|
954
|
+
}
|
|
955
|
+
if (selection && !requiresSourceCollector) {
|
|
956
|
+
// Unexpected cross-session relationships invalidate the narrow independence proof.
|
|
957
|
+
if (sessionRelationFragments.length || familyInventories.some(f => f.children.length > 0)) {
|
|
958
|
+
if (work)
|
|
959
|
+
work.fallbackReason = "derived_relationship";
|
|
960
|
+
selection = undefined;
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
const turns = [...turnsById.values()].sort(compareTurnsByRecency);
|
|
964
|
+
const sessions = orderSessionsByLastMessage([...sessionsById.values()], turns);
|
|
965
|
+
const current = executeCanonicalQuery({ sessions, turns, related_work: [] }, selection.query, options.directoryScope);
|
|
966
|
+
const cutoff = current.rows.at(-1)?.last_message_at;
|
|
967
|
+
const nextBound = selection.upperBounds[groupIndex + 1];
|
|
968
|
+
if (current.shown === selection.query.limit && typeof cutoff === "string" && nextBound !== undefined && nextBound < cutoff) {
|
|
969
|
+
selection.stopped = true;
|
|
970
|
+
if (work)
|
|
971
|
+
work.skippedPrimaryFiles = selectedGroupFiles.slice(groupIndex + 1).reduce((n, g) => n + g.files.length, 0);
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
734
976
|
}
|
|
735
977
|
if (requiresSourceCollector) {
|
|
736
|
-
|
|
978
|
+
plan.readPlan = await sourceAdapters.createSourceFileReadPlan(source, plan.fallbackFiles, options.safeMode ?? false);
|
|
979
|
+
await assessExpandedPlan();
|
|
980
|
+
if (selection)
|
|
981
|
+
selection.stopped = false;
|
|
982
|
+
if (work)
|
|
983
|
+
work.fallbackReason = "duplicate_identity";
|
|
984
|
+
return scanSourceWithCollector(source, options, contextMode, sourceAdapters, plan.readPlan.files, plan.readPlan, false, work);
|
|
737
985
|
}
|
|
738
986
|
if (!host) {
|
|
739
987
|
throw new Error(`Lite logical-session scan produced no host for ${source.display_name}.`);
|
|
@@ -863,88 +1111,10 @@ function sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, direc
|
|
|
863
1111
|
return true;
|
|
864
1112
|
return pathMatchesDirectoryScope(preview.workingDirectory, directoryScope);
|
|
865
1113
|
}
|
|
866
|
-
/**
|
|
867
|
-
* Files a `--dir` scan would pass to the probe. Layout/`preview` rejects match
|
|
868
|
-
* `scanSourceWithCollector`; logical-session adapters also apply the same
|
|
869
|
-
* first-cwd / group keep rule as `scanLogicalSessionGroups` so the estimate
|
|
870
|
-
* does not price files the scan would drop after inspect.
|
|
871
|
-
*/
|
|
872
|
-
async function selectDirectoryScopedProbeFiles(sourceAdapters, source, listedFiles, directoryScope) {
|
|
873
|
-
const candidates = listedFiles.filter((filePath) => sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, directoryScope));
|
|
874
|
-
const adapter = sourceAdapters.listPlatformAdapters().find((entry) => entry.platform === source.platform);
|
|
875
|
-
if (adapter?.projectionBoundary !== "logical_session" || candidates.length === 0) {
|
|
876
|
-
return candidates;
|
|
877
|
-
}
|
|
878
|
-
const inspected = await sourceAdapters.inspectSourceFilesLogicalSessionMetadata(source.platform, candidates, {
|
|
879
|
-
includeWorkspaceMetadata: true,
|
|
880
|
-
workspaceScan: source.platform === "codex" ? "first" : "full",
|
|
881
|
-
});
|
|
882
|
-
if (inspected.some((metadata) => metadata.sessionKeyState === "uncertain")) {
|
|
883
|
-
return candidates;
|
|
884
|
-
}
|
|
885
|
-
// Same merge + keep rule as scanLogicalSessionGroups: a group with
|
|
886
|
-
// conflicting known cwds becomes uncertain and is fully probed.
|
|
887
|
-
const filesByGroup = new Map();
|
|
888
|
-
for (const [fileIndex, filePath] of candidates.entries()) {
|
|
889
|
-
const metadata = inspected[fileIndex];
|
|
890
|
-
const group = filesByGroup.get(metadata.sessionKey);
|
|
891
|
-
if (group) {
|
|
892
|
-
group.files.push(filePath);
|
|
893
|
-
mergeLogicalSessionWorkingDirectory(group, metadata);
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
filesByGroup.set(metadata.sessionKey, {
|
|
897
|
-
files: [filePath],
|
|
898
|
-
workingDirectoryState: metadata.workingDirectoryState,
|
|
899
|
-
workingDirectory: metadata.workingDirectory,
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
return [...filesByGroup.values()]
|
|
903
|
-
.filter((group) => group.workingDirectoryState !== "known"
|
|
904
|
-
|| !group.workingDirectory
|
|
905
|
-
|| pathMatchesDirectoryScope(group.workingDirectory, directoryScope))
|
|
906
|
-
.flatMap((group) => group.files);
|
|
907
|
-
}
|
|
908
|
-
function mergeLogicalSessionWorkingDirectory(group, metadata) {
|
|
909
|
-
if (group.workingDirectoryState === "uncertain"
|
|
910
|
-
|| metadata.workingDirectoryState === "uncertain"
|
|
911
|
-
|| (group.workingDirectoryState === "known"
|
|
912
|
-
&& metadata.workingDirectoryState === "known"
|
|
913
|
-
&& group.workingDirectory !== metadata.workingDirectory)) {
|
|
914
|
-
group.workingDirectoryState = "uncertain";
|
|
915
|
-
group.workingDirectory = undefined;
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
if (group.workingDirectoryState === "absent" && metadata.workingDirectoryState === "known") {
|
|
919
|
-
group.workingDirectoryState = metadata.workingDirectoryState;
|
|
920
|
-
group.workingDirectory = metadata.workingDirectory;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
async function createDirectoryScopedRootWalker(sources, directoryScope) {
|
|
924
|
-
const sourceAdapters = await import("@cchistory/source-adapters");
|
|
925
|
-
const byRoot = new Map(sources.map((source) => [path.normalize(source.base_dir), source]));
|
|
926
|
-
return async (root, limitFiles) => {
|
|
927
|
-
const source = byRoot.get(path.normalize(root));
|
|
928
|
-
if (!source) {
|
|
929
|
-
throw new Error(`scan estimate has no source for ${root}`);
|
|
930
|
-
}
|
|
931
|
-
const listed = await sourceAdapters.listSourceFiles(source.platform, source.base_dir, limitFiles);
|
|
932
|
-
const files = await selectDirectoryScopedProbeFiles(sourceAdapters, source, listed, directoryScope);
|
|
933
|
-
let totalBytes = 0;
|
|
934
|
-
for (const filePath of files) {
|
|
935
|
-
try {
|
|
936
|
-
totalBytes += (await stat(filePath)).size;
|
|
937
|
-
}
|
|
938
|
-
catch {
|
|
939
|
-
// Listed then vanished: the scan would skip this file too.
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
return totalBytes;
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
1114
|
function buildProbeOptions(source, options, targetSessionRefs = options.sessionRefs) {
|
|
946
1115
|
return {
|
|
947
1116
|
source_ids: [source.id],
|
|
1117
|
+
read_budget: options.readBudget,
|
|
948
1118
|
target_session_refs: targetSessionRefs,
|
|
949
1119
|
limit_files_per_source: options.limitFiles,
|
|
950
1120
|
safe_mode: options.safeMode,
|
|
@@ -1350,4 +1520,5 @@ function normalizeJsonShapeForJsonOutputMutating(value) {
|
|
|
1350
1520
|
}
|
|
1351
1521
|
return value;
|
|
1352
1522
|
}
|
|
1523
|
+
export { compileSql, compileSqlRequest, parseSqlRequest, QueryValidationError, SQL_REQUEST_SCHEMA, SQL_RESULT_SCHEMA, MAX_SQL_BYTES, MAX_QUERY_REQUEST_BYTES } from "./sql-query.js";
|
|
1353
1524
|
//# sourceMappingURL=index.js.map
|