@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,684 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { applyMaskTemplates, LITERAL_PROMPT_MASK_TEMPLATE_IDS } from "../masks.js";
|
|
4
|
-
import { stableId, asString, nowIso, truncate, isObject, mergeTokenUsageMetrics, sha1, normalizeGitRemote, normalizeWorkspacePath, findLastConversationActivityAtom, isUserTurnAtom, extractTokenUsageFromPayload, extractTokenCountFromPayload, extractStopReasonFromPayload, buildStageRunId, RULE_VERSION, normalizePathSeparators, } from "./utils.js";
|
|
1
|
+
import { stableId, asString } from "@cchistory/domain";
|
|
2
|
+
import { buildStageRunId } from "./source-identity.js";
|
|
5
3
|
import { resolveSourceFormatProfile } from "./discovery.js";
|
|
6
4
|
import { getAskUserProfile } from "./ask-user-registry.js";
|
|
7
|
-
export function buildProjectObservationCandidates(draft, atoms, gitProjectEvidence) {
|
|
8
|
-
const workspaceSignals = new Map();
|
|
9
|
-
for (const atom of atoms) {
|
|
10
|
-
if (atom.content_kind !== "meta_signal") {
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
if (atom.payload.signal_kind !== "workspace_signal") {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
const workspacePath = asString(atom.payload.path);
|
|
17
|
-
if (!workspacePath) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const workspacePathNormalized = normalizeWorkspacePath(workspacePath) ?? workspacePath;
|
|
21
|
-
workspaceSignals.set(workspacePathNormalized, atom);
|
|
22
|
-
}
|
|
23
|
-
const workspaceCandidates = [...workspaceSignals.values()].map((atom) => {
|
|
24
|
-
const sourceBackedRepoRoot = normalizeWorkspacePath(asString(atom.payload.repo_root) ?? "");
|
|
25
|
-
const sourceBackedRepoRemote = normalizeGitRemote(asString(atom.payload.repo_remote));
|
|
26
|
-
const observedRepoRoot = sourceBackedRepoRoot ?? gitProjectEvidence?.repoRoot;
|
|
27
|
-
const observedRepoRemote = sourceBackedRepoRemote;
|
|
28
|
-
const observedRepoFingerprint = sourceBackedRepoRemote
|
|
29
|
-
? sha1(Buffer.from(`repo-remote:${sourceBackedRepoRemote}`))
|
|
30
|
-
: undefined;
|
|
31
|
-
const debugSummary = sourceBackedRepoRemote
|
|
32
|
-
? "workspace signal with source-backed repository evidence"
|
|
33
|
-
: sourceBackedRepoRoot
|
|
34
|
-
? "workspace signal with source-backed repository root"
|
|
35
|
-
: observedRepoRoot
|
|
36
|
-
? "workspace signal with git-backed repository root"
|
|
37
|
-
: "workspace signal without git repository evidence";
|
|
38
|
-
return {
|
|
39
|
-
id: stableId("candidate", "project_observation", draft.source_id, draft.id, normalizeWorkspacePath(asString(atom.payload.path) ?? "") ?? String(atom.payload.path)),
|
|
40
|
-
source_id: draft.source_id,
|
|
41
|
-
session_ref: draft.id,
|
|
42
|
-
candidate_kind: "project_observation",
|
|
43
|
-
input_atom_refs: [atom.id],
|
|
44
|
-
started_at: atom.time_key,
|
|
45
|
-
ended_at: atom.time_key,
|
|
46
|
-
rule_version: RULE_VERSION,
|
|
47
|
-
evidence: {
|
|
48
|
-
workspace_path: atom.payload.path,
|
|
49
|
-
workspace_path_normalized: normalizeWorkspacePath(asString(atom.payload.path) ?? ""),
|
|
50
|
-
repo_root: observedRepoRoot,
|
|
51
|
-
repo_remote: observedRepoRemote,
|
|
52
|
-
repo_fingerprint: observedRepoFingerprint,
|
|
53
|
-
source_native_project_ref: draft.source_native_project_ref,
|
|
54
|
-
confidence: 0.5,
|
|
55
|
-
reason: "workspace_signal_detected",
|
|
56
|
-
debug_summary: debugSummary,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
if (workspaceCandidates.length > 0) {
|
|
61
|
-
return workspaceCandidates;
|
|
62
|
-
}
|
|
63
|
-
if (!draft.source_native_project_ref) {
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
const seedAtom = atoms[0];
|
|
67
|
-
const observedAt = seedAtom?.time_key ?? draft.updated_at ?? draft.created_at ?? nowIso();
|
|
68
|
-
return [
|
|
69
|
-
{
|
|
70
|
-
id: stableId("candidate", "project_observation", draft.source_id, draft.id, draft.source_native_project_ref),
|
|
71
|
-
source_id: draft.source_id,
|
|
72
|
-
session_ref: draft.id,
|
|
73
|
-
candidate_kind: "project_observation",
|
|
74
|
-
input_atom_refs: seedAtom ? [seedAtom.id] : [],
|
|
75
|
-
started_at: observedAt,
|
|
76
|
-
ended_at: observedAt,
|
|
77
|
-
rule_version: RULE_VERSION,
|
|
78
|
-
evidence: {
|
|
79
|
-
source_native_project_ref: draft.source_native_project_ref,
|
|
80
|
-
confidence: 0.35,
|
|
81
|
-
reason: "source_native_project_detected",
|
|
82
|
-
debug_summary: "source-native project reference without explicit workspace signal",
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
export function buildSubmissionGroups(draft, atoms, edges) {
|
|
88
|
-
const groups = [];
|
|
89
|
-
let currentGroupAtomIds = [];
|
|
90
|
-
let currentStartedAt;
|
|
91
|
-
let currentEndedAt;
|
|
92
|
-
let lastUserAtomId;
|
|
93
|
-
let assistantSeenAfterGroupStart = false;
|
|
94
|
-
let groupIndex = 0;
|
|
95
|
-
const commitGroup = () => {
|
|
96
|
-
if (currentGroupAtomIds.length === 0 || !currentStartedAt || !currentEndedAt) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
groups.push({
|
|
100
|
-
id: stableId("candidate", "submission_group", draft.source_id, draft.id, String(groupIndex)),
|
|
101
|
-
source_id: draft.source_id,
|
|
102
|
-
session_ref: draft.id,
|
|
103
|
-
candidate_kind: "submission_group",
|
|
104
|
-
input_atom_refs: [...currentGroupAtomIds],
|
|
105
|
-
started_at: currentStartedAt,
|
|
106
|
-
ended_at: currentEndedAt,
|
|
107
|
-
rule_version: RULE_VERSION,
|
|
108
|
-
evidence: {
|
|
109
|
-
group_index: groupIndex,
|
|
110
|
-
assistant_seen_after_group_start: assistantSeenAfterGroupStart,
|
|
111
|
-
boundary_reason: assistantSeenAfterGroupStart
|
|
112
|
-
? "assistant reply observed after the current user submission"
|
|
113
|
-
: "consecutive user-authored or injected fragments continued the same submission",
|
|
114
|
-
debug_atom_refs: [...currentGroupAtomIds],
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
groupIndex += 1;
|
|
118
|
-
currentGroupAtomIds = [];
|
|
119
|
-
currentStartedAt = undefined;
|
|
120
|
-
currentEndedAt = undefined;
|
|
121
|
-
lastUserAtomId = undefined;
|
|
122
|
-
assistantSeenAfterGroupStart = false;
|
|
123
|
-
};
|
|
124
|
-
for (const atom of atoms) {
|
|
125
|
-
if (atom.actor_kind === "assistant" && atom.content_kind === "text" && atom.display_policy !== "hide") {
|
|
126
|
-
assistantSeenAfterGroupStart = currentGroupAtomIds.length > 0 || assistantSeenAfterGroupStart;
|
|
127
|
-
}
|
|
128
|
-
if (!isUserTurnAtom(atom)) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
const antigravityStartsFreshGroup = draft.source_platform === "antigravity" && atom.origin_kind === "user_authored" && currentGroupAtomIds.length > 0;
|
|
132
|
-
const continuesCurrentGroup = currentGroupAtomIds.length > 0 &&
|
|
133
|
-
!antigravityStartsFreshGroup &&
|
|
134
|
-
(!assistantSeenAfterGroupStart || atom.origin_kind === "injected_user_shaped");
|
|
135
|
-
if (!continuesCurrentGroup) {
|
|
136
|
-
commitGroup();
|
|
137
|
-
}
|
|
138
|
-
if (!currentStartedAt) {
|
|
139
|
-
currentStartedAt = atom.time_key;
|
|
140
|
-
}
|
|
141
|
-
currentEndedAt = atom.time_key;
|
|
142
|
-
currentGroupAtomIds.push(atom.id);
|
|
143
|
-
if (lastUserAtomId) {
|
|
144
|
-
edges.push({
|
|
145
|
-
id: stableId("edge", draft.source_id, draft.id, atom.id, lastUserAtomId, "same_submission"),
|
|
146
|
-
source_id: draft.source_id,
|
|
147
|
-
session_ref: draft.id,
|
|
148
|
-
from_atom_id: atom.id,
|
|
149
|
-
to_atom_id: lastUserAtomId,
|
|
150
|
-
edge_kind: "same_submission",
|
|
151
|
-
});
|
|
152
|
-
if (continuesCurrentGroup) {
|
|
153
|
-
edges.push({
|
|
154
|
-
id: stableId("edge", draft.source_id, draft.id, atom.id, lastUserAtomId, "continuation_of"),
|
|
155
|
-
source_id: draft.source_id,
|
|
156
|
-
session_ref: draft.id,
|
|
157
|
-
from_atom_id: atom.id,
|
|
158
|
-
to_atom_id: lastUserAtomId,
|
|
159
|
-
edge_kind: "continuation_of",
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
lastUserAtomId = atom.id;
|
|
164
|
-
}
|
|
165
|
-
commitGroup();
|
|
166
|
-
return { groups, edges };
|
|
167
|
-
}
|
|
168
|
-
export function buildTurnsAndContext(draft, fragments, records, blobs, atoms, submissionGroups, edges) {
|
|
169
|
-
const turnCandidates = [];
|
|
170
|
-
const contextCandidates = [];
|
|
171
|
-
const turns = [];
|
|
172
|
-
const contexts = [];
|
|
173
|
-
const fragmentById = new Map(fragments.map((fragment) => [fragment.id, fragment]));
|
|
174
|
-
const recordById = new Map(records.map((record) => [record.id, record]));
|
|
175
|
-
const blobById = new Map(blobs.map((blob) => [blob.id, blob]));
|
|
176
|
-
const atomById = new Map();
|
|
177
|
-
const atomIndexById = new Map();
|
|
178
|
-
for (const [index, atom] of atoms.entries()) {
|
|
179
|
-
atomById.set(atom.id, atom);
|
|
180
|
-
atomIndexById.set(atom.id, index);
|
|
181
|
-
}
|
|
182
|
-
const edgeIndex = buildTurnContextEdgeIndex(edges);
|
|
183
|
-
for (const [index, group] of submissionGroups.entries()) {
|
|
184
|
-
const firstAtomId = group.input_atom_refs[0];
|
|
185
|
-
if (!firstAtomId) {
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const atomIndex = atomIndexById.get(firstAtomId) ?? -1;
|
|
189
|
-
const nextGroup = submissionGroups[index + 1];
|
|
190
|
-
const nextStartAtomId = nextGroup?.input_atom_refs[0];
|
|
191
|
-
const nextIndex = nextStartAtomId ? atomIndexById.get(nextStartAtomId) : undefined;
|
|
192
|
-
const currentGroupAtomSet = new Set(group.input_atom_refs);
|
|
193
|
-
const turnId = stableId("turn", draft.source_id, draft.id, String(index));
|
|
194
|
-
const contextAtoms = [];
|
|
195
|
-
const contextAtomIds = new Set();
|
|
196
|
-
const contextEndIndex = nextIndex === undefined || nextIndex < 0 ? atoms.length : nextIndex;
|
|
197
|
-
if (atomIndex >= 0) {
|
|
198
|
-
for (let atomIndexValue = atomIndex + 1; atomIndexValue < contextEndIndex; atomIndexValue += 1) {
|
|
199
|
-
const atom = atoms[atomIndexValue];
|
|
200
|
-
if (!atom || currentGroupAtomSet.has(atom.id)) {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
contextAtoms.push(atom);
|
|
204
|
-
contextAtomIds.add(atom.id);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const groupAtoms = [];
|
|
208
|
-
for (const atomId of group.input_atom_refs) {
|
|
209
|
-
const atom = atomById.get(atomId);
|
|
210
|
-
if (atom) {
|
|
211
|
-
groupAtoms.push(atom);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const turnCandidateId = stableId("candidate", "turn", draft.source_id, draft.id, String(index));
|
|
215
|
-
const contextCandidateId = stableId("candidate", "context", draft.source_id, draft.id, String(index));
|
|
216
|
-
const userMessages = groupAtoms
|
|
217
|
-
.filter((atom) => atom.content_kind === "text" && (atom.origin_kind === "user_authored" || atom.origin_kind === "injected_user_shaped"))
|
|
218
|
-
.map((atom, userIndex) => {
|
|
219
|
-
const rawText = asString(atom.payload.text) ?? "";
|
|
220
|
-
const isInjected = atom.origin_kind === "injected_user_shaped";
|
|
221
|
-
const masked = applyMaskTemplates(rawText, "user_message", {
|
|
222
|
-
injected: isInjected,
|
|
223
|
-
exclude_template_ids: draft.source_platform === "antigravity" && !isInjected ? LITERAL_PROMPT_MASK_TEMPLATE_IDS : undefined,
|
|
224
|
-
});
|
|
225
|
-
return {
|
|
226
|
-
id: stableId("user-message", draft.source_id, draft.id, atom.id),
|
|
227
|
-
raw_text: rawText,
|
|
228
|
-
sequence: userIndex,
|
|
229
|
-
is_injected: isInjected,
|
|
230
|
-
created_at: atom.time_key,
|
|
231
|
-
atom_refs: [atom.id],
|
|
232
|
-
canonical_text: masked.canonical_text,
|
|
233
|
-
display_segments: masked.display_segments,
|
|
234
|
-
};
|
|
235
|
-
});
|
|
236
|
-
const rawText = userMessages.map((message) => message.raw_text).join("\n\n");
|
|
237
|
-
const displaySegments = joinDisplaySegments(userMessages.map((message) => message.display_segments ?? [{ type: message.is_injected ? "injected" : "text", content: message.raw_text }]));
|
|
238
|
-
const canonicalText = userMessages
|
|
239
|
-
.map((message) => message.canonical_text ?? "")
|
|
240
|
-
.filter((value) => value.length > 0)
|
|
241
|
-
.join("\n\n");
|
|
242
|
-
const contextProjection = buildTurnContext(turnId, draft, groupAtoms, contextAtoms, fragmentById, edges, {
|
|
243
|
-
atomById,
|
|
244
|
-
contextAtomIds,
|
|
245
|
-
edgeIndex,
|
|
246
|
-
});
|
|
247
|
-
const hasAuthoredUserInput = userMessages.some((message) => !message.is_injected);
|
|
248
|
-
if (!hasAuthoredUserInput) {
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
const lastActivityAtom = findLastConversationActivityAtom(contextAtoms) ?? findLastConversationActivityAtom(groupAtoms);
|
|
252
|
-
const lastActivityAt = lastActivityAtom?.time_key ?? group.ended_at;
|
|
253
|
-
turnCandidates.push({
|
|
254
|
-
id: turnCandidateId,
|
|
255
|
-
source_id: draft.source_id,
|
|
256
|
-
session_ref: draft.id,
|
|
257
|
-
candidate_kind: "turn",
|
|
258
|
-
input_atom_refs: groupAtoms.map((atom) => atom.id),
|
|
259
|
-
started_at: group.started_at,
|
|
260
|
-
ended_at: lastActivityAt,
|
|
261
|
-
rule_version: RULE_VERSION,
|
|
262
|
-
evidence: {
|
|
263
|
-
submission_group_id: group.id,
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
contextCandidates.push({
|
|
267
|
-
id: contextCandidateId,
|
|
268
|
-
source_id: draft.source_id,
|
|
269
|
-
session_ref: draft.id,
|
|
270
|
-
candidate_kind: "context_span",
|
|
271
|
-
input_atom_refs: contextAtoms.map((atom) => atom.id),
|
|
272
|
-
started_at: group.started_at,
|
|
273
|
-
ended_at: lastActivityAt,
|
|
274
|
-
rule_version: RULE_VERSION,
|
|
275
|
-
evidence: {
|
|
276
|
-
turn_candidate_id: turnCandidateId,
|
|
277
|
-
},
|
|
278
|
-
});
|
|
279
|
-
const allFragmentIds = new Set();
|
|
280
|
-
const allRecordIds = new Set();
|
|
281
|
-
const allBlobIds = new Set();
|
|
282
|
-
for (const atom of [...groupAtoms, ...contextAtoms]) {
|
|
283
|
-
for (const fragmentId of atom.fragment_refs) {
|
|
284
|
-
allFragmentIds.add(fragmentId);
|
|
285
|
-
const recordId = fragmentById.get(fragmentId)?.record_id;
|
|
286
|
-
if (recordId) {
|
|
287
|
-
allRecordIds.add(recordId);
|
|
288
|
-
const blobId = recordById.get(recordId)?.blob_id;
|
|
289
|
-
if (blobId && blobById.get(blobId)) {
|
|
290
|
-
allBlobIds.add(blobId);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
const contextTokenUsage = summarizeAssistantReplyUsage(contextProjection.assistant_replies);
|
|
296
|
-
const hasNoAssistantReply = contextProjection.assistant_replies.length === 0;
|
|
297
|
-
turns.push({
|
|
298
|
-
id: turnId,
|
|
299
|
-
revision_id: `${turnId}:r1`,
|
|
300
|
-
turn_id: turnId,
|
|
301
|
-
turn_revision_id: `${turnId}:r1`,
|
|
302
|
-
user_messages: userMessages,
|
|
303
|
-
raw_text: rawText,
|
|
304
|
-
canonical_text: canonicalText || extractCanonicalFallback(displaySegments),
|
|
305
|
-
display_segments: displaySegments,
|
|
306
|
-
created_at: group.started_at,
|
|
307
|
-
submission_started_at: group.started_at,
|
|
308
|
-
last_context_activity_at: lastActivityAt,
|
|
309
|
-
session_id: draft.id,
|
|
310
|
-
source_id: draft.source_id,
|
|
311
|
-
link_state: "unlinked",
|
|
312
|
-
sync_axis: "current",
|
|
313
|
-
value_axis: "active",
|
|
314
|
-
retention_axis: "keep_raw_and_derived",
|
|
315
|
-
context_ref: contextCandidateId,
|
|
316
|
-
context_summary: {
|
|
317
|
-
assistant_reply_count: contextProjection.assistant_replies.length,
|
|
318
|
-
tool_call_count: contextProjection.tool_calls.length,
|
|
319
|
-
token_usage: contextTokenUsage,
|
|
320
|
-
total_tokens: contextTokenUsage?.total_tokens,
|
|
321
|
-
primary_model: summarizeAssistantReplyPrimaryModel(contextProjection.assistant_replies) ?? draft.model,
|
|
322
|
-
has_errors: contextProjection.assistant_replies.some((reply) => reply.stop_reason === "error"),
|
|
323
|
-
zero_token_reason: hasNoAssistantReply ? "no_assistant_reply" : undefined,
|
|
324
|
-
},
|
|
325
|
-
lineage: {
|
|
326
|
-
atom_refs: [...groupAtoms.map((atom) => atom.id), ...contextAtoms.map((atom) => atom.id)],
|
|
327
|
-
candidate_refs: [turnCandidateId, contextCandidateId],
|
|
328
|
-
fragment_refs: Array.from(allFragmentIds),
|
|
329
|
-
record_refs: Array.from(allRecordIds),
|
|
330
|
-
blob_refs: Array.from(allBlobIds),
|
|
331
|
-
},
|
|
332
|
-
path_text: buildTurnPathText(draft, contextProjection, groupAtoms, contextAtoms),
|
|
333
|
-
});
|
|
334
|
-
contexts.push(contextProjection);
|
|
335
|
-
}
|
|
336
|
-
const session = {
|
|
337
|
-
id: draft.id,
|
|
338
|
-
source_id: draft.source_id,
|
|
339
|
-
host_id: draft.host_id,
|
|
340
|
-
source_platform: draft.source_platform,
|
|
341
|
-
title: draft.title,
|
|
342
|
-
canonical_title: draft.canonical_title ?? canonicalizeSessionTitle(draft.title),
|
|
343
|
-
created_at: draft.created_at ?? atoms[0]?.time_key ?? nowIso(),
|
|
344
|
-
updated_at: draft.updated_at ?? atoms.at(-1)?.time_key ?? nowIso(),
|
|
345
|
-
model: draft.model,
|
|
346
|
-
working_directory: draft.working_directory,
|
|
347
|
-
source_native_project_ref: draft.source_native_project_ref,
|
|
348
|
-
source_session_id: draft.source_session_id,
|
|
349
|
-
resume_command: draft.resume_command,
|
|
350
|
-
resume_working_directory: draft.resume_working_directory,
|
|
351
|
-
resume_command_confidence: draft.resume_command_confidence,
|
|
352
|
-
turn_count: turns.length,
|
|
353
|
-
sync_axis: "current",
|
|
354
|
-
};
|
|
355
|
-
return { session, turnCandidates, contextCandidates, turns, contexts };
|
|
356
|
-
}
|
|
357
|
-
function canonicalizeSessionTitle(title) {
|
|
358
|
-
if (!title)
|
|
359
|
-
return undefined;
|
|
360
|
-
return applyMaskTemplates(title, "user_message").canonical_text || undefined;
|
|
361
|
-
}
|
|
362
|
-
function buildTurnContextEdgeIndex(edges) {
|
|
363
|
-
const spawnedFromAtomIdByToolAtomId = new Map();
|
|
364
|
-
const toolResultAtomIdByToolAtomId = new Map();
|
|
365
|
-
for (const edge of edges) {
|
|
366
|
-
if (edge.edge_kind === "spawned_from" && !spawnedFromAtomIdByToolAtomId.has(edge.from_atom_id)) {
|
|
367
|
-
spawnedFromAtomIdByToolAtomId.set(edge.from_atom_id, edge.to_atom_id);
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (edge.edge_kind === "tool_result_for" && !toolResultAtomIdByToolAtomId.has(edge.to_atom_id)) {
|
|
371
|
-
toolResultAtomIdByToolAtomId.set(edge.to_atom_id, edge.from_atom_id);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
return {
|
|
375
|
-
spawnedFromAtomIdByToolAtomId,
|
|
376
|
-
toolResultAtomIdByToolAtomId,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
export function buildTurnContext(turnId, draft, groupAtoms, contextAtoms, fragmentById, edges, buildIndex) {
|
|
380
|
-
const assistantReplies = [];
|
|
381
|
-
const systemMessages = [];
|
|
382
|
-
const toolCalls = [];
|
|
383
|
-
const rawEventRefs = new Set();
|
|
384
|
-
const replyIdByAtomId = new Map();
|
|
385
|
-
const toolCallIdsByReplyId = new Map();
|
|
386
|
-
let toolSequence = 0;
|
|
387
|
-
let activeModel = draft.model;
|
|
388
|
-
const contextIndex = buildIndex ??
|
|
389
|
-
{
|
|
390
|
-
atomById: new Map(contextAtoms.map((atom) => [atom.id, atom])),
|
|
391
|
-
contextAtomIds: new Set(contextAtoms.map((atom) => atom.id)),
|
|
392
|
-
edgeIndex: buildTurnContextEdgeIndex(edges),
|
|
393
|
-
};
|
|
394
|
-
for (const atom of groupAtoms) {
|
|
395
|
-
for (const fragmentId of atom.fragment_refs) {
|
|
396
|
-
const recordId = fragmentById.get(fragmentId)?.record_id;
|
|
397
|
-
if (recordId) {
|
|
398
|
-
rawEventRefs.add(recordId);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const signalsByReply = new Map();
|
|
403
|
-
// Maps Claude message.id → index of the assistant reply that contains that
|
|
404
|
-
// message's text. Used to attribute token_usage_signal atoms to the correct
|
|
405
|
-
// reply even when the signal atom arrives in the stream before the text atom
|
|
406
|
-
// (which happens because the signal is emitted from the first non-text chunk
|
|
407
|
-
// of a multi-block message, and that chunk precedes the text chunk in JSONL).
|
|
408
|
-
const replyIndexByMessageId = new Map();
|
|
409
|
-
// Signals whose message.id has not yet been seen on a text reply. These are
|
|
410
|
-
// real billed API calls — either they arrive before their own text reply
|
|
411
|
-
// (queued until the reply shows up), or they belong to a tool-only / thinking-
|
|
412
|
-
// only message that has no text reply at all (orphan; attributed to the next
|
|
413
|
-
// reply in the session so their tokens are not silently dropped).
|
|
414
|
-
const pendingSignals = [];
|
|
415
|
-
let currentReplyIndex = -1;
|
|
416
|
-
for (const atom of contextAtoms) {
|
|
417
|
-
for (const fragmentId of atom.fragment_refs) {
|
|
418
|
-
const recordId = fragmentById.get(fragmentId)?.record_id;
|
|
419
|
-
if (recordId) {
|
|
420
|
-
rawEventRefs.add(recordId);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
for (const atom of contextAtoms) {
|
|
425
|
-
if (atom.content_kind === "meta_signal" && atom.payload.signal_kind === "model_signal") {
|
|
426
|
-
const signalModel = asString(atom.payload.model);
|
|
427
|
-
if (signalModel) {
|
|
428
|
-
activeModel = signalModel;
|
|
429
|
-
}
|
|
430
|
-
continue;
|
|
431
|
-
}
|
|
432
|
-
if (atom.actor_kind === "system" && atom.content_kind === "text" && atom.display_policy !== "hide") {
|
|
433
|
-
const content = asString(atom.payload.text) ?? "";
|
|
434
|
-
const masked = applyMaskTemplates(content, "system_message");
|
|
435
|
-
systemMessages.push({
|
|
436
|
-
id: stableId("system-message", draft.source_id, draft.id, atom.id),
|
|
437
|
-
content,
|
|
438
|
-
display_segments: masked.display_segments,
|
|
439
|
-
position: "interleaved",
|
|
440
|
-
sequence: systemMessages.length,
|
|
441
|
-
created_at: atom.time_key,
|
|
442
|
-
});
|
|
443
|
-
continue;
|
|
444
|
-
}
|
|
445
|
-
if (atom.actor_kind === "assistant" && atom.content_kind === "text" && atom.display_policy !== "hide") {
|
|
446
|
-
const replyId = stableId("assistant-reply", draft.source_id, draft.id, atom.id);
|
|
447
|
-
replyIdByAtomId.set(atom.id, replyId);
|
|
448
|
-
const content = asString(atom.payload.text) ?? "";
|
|
449
|
-
const masked = applyMaskTemplates(content, "assistant_reply");
|
|
450
|
-
const tokenUsage = extractTokenUsageFromPayload(atom.payload);
|
|
451
|
-
const replyModel = asString(atom.payload.model) ??
|
|
452
|
-
tokenUsage?.model ??
|
|
453
|
-
activeModel ??
|
|
454
|
-
draft.model ??
|
|
455
|
-
"unknown";
|
|
456
|
-
const reply = {
|
|
457
|
-
id: replyId,
|
|
458
|
-
content,
|
|
459
|
-
canonical_text: masked.canonical_text,
|
|
460
|
-
display_segments: masked.display_segments,
|
|
461
|
-
content_preview: truncate(masked.canonical_text || content, 140),
|
|
462
|
-
token_usage: tokenUsage,
|
|
463
|
-
token_count: extractTokenCountFromPayload(atom.payload) ?? tokenUsage?.total_tokens,
|
|
464
|
-
model: replyModel,
|
|
465
|
-
created_at: atom.time_key,
|
|
466
|
-
tool_call_ids: [],
|
|
467
|
-
stop_reason: extractStopReasonFromPayload(atom.payload),
|
|
468
|
-
};
|
|
469
|
-
assistantReplies.push(reply);
|
|
470
|
-
currentReplyIndex = assistantReplies.length - 1;
|
|
471
|
-
if (replyModel !== "unknown") {
|
|
472
|
-
activeModel = replyModel;
|
|
473
|
-
}
|
|
474
|
-
const replyMessageId = asString(atom.payload.message_id);
|
|
475
|
-
if (replyMessageId) {
|
|
476
|
-
replyIndexByMessageId.set(replyMessageId, currentReplyIndex);
|
|
477
|
-
}
|
|
478
|
-
// Flush any signals that arrived earlier in the session without a
|
|
479
|
-
// matching text reply — either their own reply (now created) or as
|
|
480
|
-
// orphans attributed to this turn.
|
|
481
|
-
if (pendingSignals.length > 0) {
|
|
482
|
-
const signals = signalsByReply.get(currentReplyIndex) ?? [];
|
|
483
|
-
for (const pending of pendingSignals) {
|
|
484
|
-
signals.push(pending);
|
|
485
|
-
}
|
|
486
|
-
signalsByReply.set(currentReplyIndex, signals);
|
|
487
|
-
pendingSignals.length = 0;
|
|
488
|
-
}
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
if (atom.content_kind === "meta_signal" &&
|
|
492
|
-
atom.payload.signal_kind === "token_usage_signal") {
|
|
493
|
-
const signalMessageId = asString(atom.payload.message_id);
|
|
494
|
-
const matchedReplyIndex = signalMessageId !== undefined ? replyIndexByMessageId.get(signalMessageId) : undefined;
|
|
495
|
-
if (signalMessageId !== undefined && matchedReplyIndex === undefined) {
|
|
496
|
-
// Signal's message.id has no text reply yet (and may never have one).
|
|
497
|
-
// Queue rather than mis-attribute to the most recent reply.
|
|
498
|
-
pendingSignals.push(atom);
|
|
499
|
-
}
|
|
500
|
-
else {
|
|
501
|
-
const targetReplyIndex = matchedReplyIndex ?? currentReplyIndex;
|
|
502
|
-
if (targetReplyIndex >= 0) {
|
|
503
|
-
let signals = signalsByReply.get(targetReplyIndex);
|
|
504
|
-
if (!signals) {
|
|
505
|
-
signals = [];
|
|
506
|
-
signalsByReply.set(targetReplyIndex, signals);
|
|
507
|
-
}
|
|
508
|
-
signals.push(atom);
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
pendingSignals.push(atom);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
// Trailing orphans: signals whose message.id has no text reply anywhere in
|
|
517
|
-
// the session (tool-only / thinking-only API calls). Attribute them to the
|
|
518
|
-
// last assistant reply so their billing is not silently dropped. If the
|
|
519
|
-
// session has no text reply at all, there is nowhere to anchor the cost and
|
|
520
|
-
// the tokens are dropped — logged as a known limitation.
|
|
521
|
-
if (pendingSignals.length > 0 && assistantReplies.length > 0) {
|
|
522
|
-
const lastReplyIndex = assistantReplies.length - 1;
|
|
523
|
-
const signals = signalsByReply.get(lastReplyIndex) ?? [];
|
|
524
|
-
for (const pending of pendingSignals) {
|
|
525
|
-
signals.push(pending);
|
|
526
|
-
}
|
|
527
|
-
signalsByReply.set(lastReplyIndex, signals);
|
|
528
|
-
pendingSignals.length = 0;
|
|
529
|
-
}
|
|
530
|
-
// Apply token_usage_signal atoms to the most recent preceding assistant reply.
|
|
531
|
-
// Each signal is associated with the reply that precedes it in the atom sequence.
|
|
532
|
-
if (assistantReplies.length > 0 && signalsByReply.size > 0) {
|
|
533
|
-
for (const [replyIndex, signals] of signalsByReply.entries()) {
|
|
534
|
-
const reply = assistantReplies[replyIndex];
|
|
535
|
-
if (!reply || signals.length === 0) {
|
|
536
|
-
continue;
|
|
537
|
-
}
|
|
538
|
-
// Check if signals carry delta_token_usage (cumulative mode)
|
|
539
|
-
const hasDeltas = signals.some((s) => isObject(s.payload.delta_token_usage));
|
|
540
|
-
// Codex's `last_token_usage` (without `total_token_usage`) is a cumulative
|
|
541
|
-
// checkpoint within the turn — the last signal already subsumes earlier
|
|
542
|
-
// ones. Claude Code's per-message.id signals are independent API calls
|
|
543
|
-
// that must be summed. We tell them apart by Codex's `source_event_type`.
|
|
544
|
-
const isCodexCumulativeWithinTurn = signals.every((s) => s.payload.source_event_type === "token_count");
|
|
545
|
-
let resolvedUsage;
|
|
546
|
-
if (hasDeltas) {
|
|
547
|
-
// Codex cumulative mode: each signal carries a delta since the prior
|
|
548
|
-
// checkpoint. Sum deltas to recover the total increment for this reply.
|
|
549
|
-
for (const signal of signals) {
|
|
550
|
-
const delta = extractTokenUsageFromPayload(isObject(signal.payload.delta_token_usage) ? { token_usage: signal.payload.delta_token_usage } : {});
|
|
551
|
-
resolvedUsage = mergeTokenUsageMetrics(resolvedUsage, delta);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
else if (isCodexCumulativeWithinTurn) {
|
|
555
|
-
// Codex without total_token_usage: last_token_usage is cumulative
|
|
556
|
-
// within the turn, so the final checkpoint is the turn total.
|
|
557
|
-
const lastSignal = signals.at(-1);
|
|
558
|
-
resolvedUsage = extractTokenUsageFromPayload(lastSignal.payload);
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
// Claude Code mode: each signal is one API call's standalone usage
|
|
562
|
-
// (after upstream dedup by message.id). A turn can chain several API
|
|
563
|
-
// calls behind one text reply (text + tool_use loop + ...), and every
|
|
564
|
-
// call's tokens must be summed — taking only the last signal silently
|
|
565
|
-
// drops every preceding call's billing.
|
|
566
|
-
for (const signal of signals) {
|
|
567
|
-
const u = extractTokenUsageFromPayload(signal.payload);
|
|
568
|
-
resolvedUsage = mergeTokenUsageMetrics(resolvedUsage, u);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
if (resolvedUsage) {
|
|
572
|
-
reply.token_usage = resolvedUsage;
|
|
573
|
-
reply.token_count = resolvedUsage.total_tokens ?? reply.token_count;
|
|
574
|
-
if (resolvedUsage.model && reply.model === "unknown") {
|
|
575
|
-
reply.model = resolvedUsage.model;
|
|
576
|
-
}
|
|
577
|
-
if (!reply.stop_reason) {
|
|
578
|
-
const lastSignal = signals.at(-1);
|
|
579
|
-
reply.stop_reason = extractStopReasonFromPayload(lastSignal.payload);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
const lastAssistantReplyId = () => assistantReplies.at(-1)?.id ?? stableId("assistant-reply", draft.id, "synthetic");
|
|
585
|
-
for (const atom of contextAtoms) {
|
|
586
|
-
if (atom.content_kind !== "tool_call" || atom.display_policy === "hide") {
|
|
587
|
-
continue;
|
|
588
|
-
}
|
|
589
|
-
const spawnedFromAtomId = contextIndex.edgeIndex.spawnedFromAtomIdByToolAtomId.get(atom.id);
|
|
590
|
-
const replyId = spawnedFromAtomId ? replyIdByAtomId.get(spawnedFromAtomId) ?? lastAssistantReplyId() : lastAssistantReplyId();
|
|
591
|
-
const inputJson = JSON.stringify(atom.payload.input ?? {});
|
|
592
|
-
const maskedInput = applyMaskTemplates(inputJson, "tool_input");
|
|
593
|
-
const toolCall = {
|
|
594
|
-
id: stableId("tool-call", draft.source_id, draft.id, atom.id),
|
|
595
|
-
tool_name: asString(atom.payload.tool_name) ?? "tool_call",
|
|
596
|
-
input: isObject(atom.payload.input) ? atom.payload.input : {},
|
|
597
|
-
input_summary: truncate(maskedInput.canonical_text || inputJson, 140),
|
|
598
|
-
input_display_segments: maskedInput.display_segments,
|
|
599
|
-
status: "success",
|
|
600
|
-
reply_id: replyId,
|
|
601
|
-
sequence: toolSequence++,
|
|
602
|
-
created_at: atom.time_key,
|
|
603
|
-
};
|
|
604
|
-
const resultAtomId = contextIndex.edgeIndex.toolResultAtomIdByToolAtomId.get(atom.id);
|
|
605
|
-
const resultAtom = resultAtomId && contextIndex.contextAtomIds.has(resultAtomId)
|
|
606
|
-
? contextIndex.atomById.get(resultAtomId)
|
|
607
|
-
: undefined;
|
|
608
|
-
if (resultAtom) {
|
|
609
|
-
const output = asString(resultAtom.payload.output) ?? "";
|
|
610
|
-
const maskedOutput = applyMaskTemplates(output, "tool_output");
|
|
611
|
-
toolCall.output = output;
|
|
612
|
-
toolCall.output_preview = truncate(maskedOutput.canonical_text || output, 140);
|
|
613
|
-
toolCall.output_display_segments = maskedOutput.display_segments;
|
|
614
|
-
}
|
|
615
|
-
toolCalls.push(toolCall);
|
|
616
|
-
let replyToolCallIds = toolCallIdsByReplyId.get(replyId);
|
|
617
|
-
if (!replyToolCallIds) {
|
|
618
|
-
replyToolCallIds = [];
|
|
619
|
-
toolCallIdsByReplyId.set(replyId, replyToolCallIds);
|
|
620
|
-
}
|
|
621
|
-
replyToolCallIds.push(toolCall.id);
|
|
622
|
-
}
|
|
623
|
-
for (const reply of assistantReplies) {
|
|
624
|
-
reply.tool_call_ids = toolCallIdsByReplyId.get(reply.id) ?? [];
|
|
625
|
-
}
|
|
626
|
-
return {
|
|
627
|
-
turn_id: turnId,
|
|
628
|
-
system_messages: systemMessages,
|
|
629
|
-
assistant_replies: assistantReplies,
|
|
630
|
-
tool_calls: toolCalls,
|
|
631
|
-
raw_event_refs: Array.from(rawEventRefs),
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
function buildTurnPathText(draft, contextProjection, groupAtoms, contextAtoms) {
|
|
635
|
-
const parts = new Set();
|
|
636
|
-
addPathText(parts, draft.working_directory);
|
|
637
|
-
addPathText(parts, draft.source_native_project_ref);
|
|
638
|
-
addPathText(parts, draft.resume_working_directory);
|
|
639
|
-
addPathText(parts, draft.source_native_project_ref ? path.basename(draft.source_native_project_ref) : undefined);
|
|
640
|
-
for (const atom of [...groupAtoms, ...contextAtoms]) {
|
|
641
|
-
const payload = atom.payload;
|
|
642
|
-
addPathText(parts, asString(payload.path));
|
|
643
|
-
addPathText(parts, asString(payload.workspace_path));
|
|
644
|
-
addPathText(parts, asString(payload.repo_root));
|
|
645
|
-
addPathText(parts, asString(payload.source_native_project_ref));
|
|
646
|
-
}
|
|
647
|
-
for (const reply of contextProjection.assistant_replies) {
|
|
648
|
-
for (const segment of reply.display_segments ?? []) {
|
|
649
|
-
if (segment.type === "reference") {
|
|
650
|
-
addPathText(parts, segment.content);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
return [...parts].join(" ").trim() || undefined;
|
|
655
|
-
}
|
|
656
|
-
function addPathText(target, value) {
|
|
657
|
-
if (!value) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
const normalized = normalizePathSeparators(value).trim();
|
|
661
|
-
if (!normalized) {
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
target.add(normalized);
|
|
665
|
-
const basename = normalized.split("/").filter(Boolean).at(-1);
|
|
666
|
-
if (basename) {
|
|
667
|
-
target.add(basename);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
export function summarizeAssistantReplyUsage(replies) {
|
|
671
|
-
let total;
|
|
672
|
-
for (const reply of replies) {
|
|
673
|
-
if (reply.token_usage) {
|
|
674
|
-
total = mergeTokenUsageMetrics(total, reply.token_usage);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
return total;
|
|
678
|
-
}
|
|
679
|
-
export function summarizeAssistantReplyPrimaryModel(replies) {
|
|
680
|
-
return replies.find((reply) => reply.model)?.model;
|
|
681
|
-
}
|
|
682
5
|
export function buildStageRuns(sourceId, sourcePlatform, startedAt, finishedAt, counts, lossAudits) {
|
|
683
6
|
const sourceDefinition = {
|
|
684
7
|
id: sourceId,
|
|
@@ -792,22 +115,6 @@ export function countLossAuditsByStage(lossAudits) {
|
|
|
792
115
|
}
|
|
793
116
|
return counts;
|
|
794
117
|
}
|
|
795
|
-
export function extractCanonicalFallback(segments) {
|
|
796
|
-
return segments
|
|
797
|
-
.map((segment) => {
|
|
798
|
-
if (segment.type === "masked") {
|
|
799
|
-
return `[${segment.mask_label ?? "Masked"}]`;
|
|
800
|
-
}
|
|
801
|
-
if (segment.type === "injected") {
|
|
802
|
-
return "";
|
|
803
|
-
}
|
|
804
|
-
return segment.content;
|
|
805
|
-
})
|
|
806
|
-
.join("")
|
|
807
|
-
.replace(/[ \t]+\n/g, "\n")
|
|
808
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
809
|
-
.trim();
|
|
810
|
-
}
|
|
811
118
|
export function buildAskUserQuestionTurns(draft, atoms, edges) {
|
|
812
119
|
const profile = getAskUserProfile(draft.source_platform);
|
|
813
120
|
if (!profile) {
|