@winspan/claude-forge 8.54.4 → 9.12.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/DEVELOPMENT.md +723 -46
- package/README.md +166 -21
- package/dist/catalogs/agents.json +67 -0
- package/dist/catalogs/skills.json +306 -0
- package/dist/claudemd/claudemd-generator.d.ts +45 -45
- package/dist/claudemd/claudemd-generator.d.ts.map +1 -1
- package/dist/claudemd/claudemd-generator.js +128 -449
- package/dist/claudemd/claudemd-generator.js.map +1 -1
- package/dist/claudemd/index.d.ts +14 -4
- package/dist/claudemd/index.d.ts.map +1 -1
- package/dist/claudemd/index.js +15 -4
- package/dist/claudemd/index.js.map +1 -1
- package/dist/claudemd/resume-manager.d.ts.map +1 -1
- package/dist/claudemd/resume-manager.js +37 -9
- package/dist/claudemd/resume-manager.js.map +1 -1
- package/dist/claudemd/templates/swarm-protocol.md +35 -186
- package/dist/claudemd/violations-manager.d.ts +40 -0
- package/dist/claudemd/violations-manager.d.ts.map +1 -0
- package/dist/claudemd/violations-manager.js +106 -0
- package/dist/claudemd/violations-manager.js.map +1 -0
- package/dist/cli/commands/admin.d.ts +15 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +177 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +169 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +690 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/agents.d.ts +18 -0
- package/dist/cli/commands/agents.d.ts.map +1 -0
- package/dist/cli/commands/agents.js +160 -0
- package/dist/cli/commands/agents.js.map +1 -0
- package/dist/cli/commands/bypass.d.ts +18 -0
- package/dist/cli/commands/bypass.d.ts.map +1 -0
- package/dist/cli/commands/bypass.js +87 -0
- package/dist/cli/commands/bypass.js.map +1 -0
- package/dist/cli/commands/claudemd.d.ts +60 -0
- package/dist/cli/commands/claudemd.d.ts.map +1 -1
- package/dist/cli/commands/claudemd.js +174 -37
- package/dist/cli/commands/claudemd.js.map +1 -1
- package/dist/cli/commands/codegraph.d.ts +17 -0
- package/dist/cli/commands/codegraph.d.ts.map +1 -0
- package/dist/cli/commands/codegraph.js +263 -0
- package/dist/cli/commands/codegraph.js.map +1 -0
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/config.js +94 -1
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/daemon.d.ts +39 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -1
- package/dist/cli/commands/daemon.js +167 -20
- package/dist/cli/commands/daemon.js.map +1 -1
- package/dist/cli/commands/decisions.d.ts +129 -0
- package/dist/cli/commands/decisions.d.ts.map +1 -0
- package/dist/cli/commands/decisions.js +706 -0
- package/dist/cli/commands/decisions.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +29 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +124 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/entropy.d.ts +35 -0
- package/dist/cli/commands/entropy.d.ts.map +1 -0
- package/dist/cli/commands/entropy.js +121 -0
- package/dist/cli/commands/entropy.js.map +1 -0
- package/dist/cli/commands/executions.d.ts +1 -0
- package/dist/cli/commands/executions.d.ts.map +1 -1
- package/dist/cli/commands/executions.js +12 -2
- package/dist/cli/commands/executions.js.map +1 -1
- package/dist/cli/commands/fix.d.ts +31 -0
- package/dist/cli/commands/fix.d.ts.map +1 -0
- package/dist/cli/commands/fix.js +108 -0
- package/dist/cli/commands/fix.js.map +1 -0
- package/dist/cli/commands/governance.d.ts +21 -0
- package/dist/cli/commands/governance.d.ts.map +1 -0
- package/dist/cli/commands/governance.js +60 -0
- package/dist/cli/commands/governance.js.map +1 -0
- package/dist/cli/commands/init.d.ts +27 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +158 -146
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/insights-goal-check.d.ts +54 -0
- package/dist/cli/commands/insights-goal-check.d.ts.map +1 -0
- package/dist/cli/commands/insights-goal-check.js +318 -0
- package/dist/cli/commands/insights-goal-check.js.map +1 -0
- package/dist/cli/commands/insights.d.ts +15 -0
- package/dist/cli/commands/insights.d.ts.map +1 -0
- package/dist/cli/commands/insights.js +127 -0
- package/dist/cli/commands/insights.js.map +1 -0
- package/dist/cli/commands/knowledge.d.ts +117 -0
- package/dist/cli/commands/knowledge.d.ts.map +1 -0
- package/dist/cli/commands/knowledge.js +1070 -0
- package/dist/cli/commands/knowledge.js.map +1 -0
- package/dist/cli/commands/loop.d.ts +95 -0
- package/dist/cli/commands/loop.d.ts.map +1 -0
- package/dist/cli/commands/loop.js +408 -0
- package/dist/cli/commands/loop.js.map +1 -0
- package/dist/cli/commands/maintenance.d.ts +33 -0
- package/dist/cli/commands/maintenance.d.ts.map +1 -0
- package/dist/cli/commands/maintenance.js +75 -0
- package/dist/cli/commands/maintenance.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +22 -11
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +93 -5
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/menu.d.ts.map +1 -1
- package/dist/cli/commands/menu.js +10 -184
- package/dist/cli/commands/menu.js.map +1 -1
- package/dist/cli/commands/project.d.ts +98 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +382 -0
- package/dist/cli/commands/project.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +131 -0
- package/dist/cli/commands/skills.d.ts.map +1 -1
- package/dist/cli/commands/skills.js +404 -118
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +40 -0
- package/dist/cli/commands/spec.d.ts.map +1 -0
- package/dist/cli/commands/spec.js +49 -0
- package/dist/cli/commands/spec.js.map +1 -0
- package/dist/cli/commands/stats.d.ts.map +1 -1
- package/dist/cli/commands/stats.js +11 -3
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +17 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/trace.d.ts.map +1 -1
- package/dist/cli/commands/trace.js +4 -9
- package/dist/cli/commands/trace.js.map +1 -1
- package/dist/cli/commands/violations.d.ts +14 -0
- package/dist/cli/commands/violations.d.ts.map +1 -0
- package/dist/cli/commands/violations.js +43 -0
- package/dist/cli/commands/violations.js.map +1 -0
- package/dist/cli/index.js +34 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/hook-manager.d.ts +1 -1
- package/dist/cli/init/hook-manager.d.ts.map +1 -1
- package/dist/cli/init/hook-manager.js +6 -0
- package/dist/cli/init/hook-manager.js.map +1 -1
- package/dist/cli/utils/resolve-session.d.ts +32 -0
- package/dist/cli/utils/resolve-session.d.ts.map +1 -0
- package/dist/cli/utils/resolve-session.js +39 -0
- package/dist/cli/utils/resolve-session.js.map +1 -0
- package/dist/core/config.d.ts +4 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +11 -23
- package/dist/core/config.js.map +1 -1
- package/dist/core/constants.d.ts +51 -13
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +63 -13
- package/dist/core/constants.js.map +1 -1
- package/dist/core/diagnostics/checks.d.ts +151 -0
- package/dist/core/diagnostics/checks.d.ts.map +1 -0
- package/dist/core/diagnostics/checks.js +766 -0
- package/dist/core/diagnostics/checks.js.map +1 -0
- package/dist/core/diagnostics/daemon-status.d.ts +77 -0
- package/dist/core/diagnostics/daemon-status.d.ts.map +1 -0
- package/dist/core/diagnostics/daemon-status.js +113 -0
- package/dist/core/diagnostics/daemon-status.js.map +1 -0
- package/dist/core/diagnostics/entropy-checks.d.ts +83 -0
- package/dist/core/diagnostics/entropy-checks.d.ts.map +1 -0
- package/dist/core/diagnostics/entropy-checks.js +400 -0
- package/dist/core/diagnostics/entropy-checks.js.map +1 -0
- package/dist/core/diagnostics/fix-runner.d.ts +54 -0
- package/dist/core/diagnostics/fix-runner.d.ts.map +1 -0
- package/dist/core/diagnostics/fix-runner.js +90 -0
- package/dist/core/diagnostics/fix-runner.js.map +1 -0
- package/dist/core/diagnostics/heartbeat-reader.d.ts +28 -0
- package/dist/core/diagnostics/heartbeat-reader.d.ts.map +1 -0
- package/dist/core/diagnostics/heartbeat-reader.js +50 -0
- package/dist/core/diagnostics/heartbeat-reader.js.map +1 -0
- package/dist/core/diagnostics/knip-runner.d.ts +49 -0
- package/dist/core/diagnostics/knip-runner.d.ts.map +1 -0
- package/dist/core/diagnostics/knip-runner.js +100 -0
- package/dist/core/diagnostics/knip-runner.js.map +1 -0
- package/dist/core/diagnostics/markers.d.ts +96 -0
- package/dist/core/diagnostics/markers.d.ts.map +1 -0
- package/dist/core/diagnostics/markers.js +153 -0
- package/dist/core/diagnostics/markers.js.map +1 -0
- package/dist/core/event-fields.d.ts +27 -0
- package/dist/core/event-fields.d.ts.map +1 -1
- package/dist/core/event-fields.js +43 -0
- package/dist/core/event-fields.js.map +1 -1
- package/dist/core/governance/global-inject.d.ts +90 -0
- package/dist/core/governance/global-inject.d.ts.map +1 -0
- package/dist/core/governance/global-inject.js +184 -0
- package/dist/core/governance/global-inject.js.map +1 -0
- package/dist/core/insights/agent-anchor-guard.d.ts +77 -0
- package/dist/core/insights/agent-anchor-guard.d.ts.map +1 -0
- package/dist/core/insights/agent-anchor-guard.js +119 -0
- package/dist/core/insights/agent-anchor-guard.js.map +1 -0
- package/dist/core/insights/agent-distill-context.d.ts +55 -0
- package/dist/core/insights/agent-distill-context.d.ts.map +1 -0
- package/dist/core/insights/agent-distill-context.js +146 -0
- package/dist/core/insights/agent-distill-context.js.map +1 -0
- package/dist/core/insights/agent-distill-spawn.d.ts +56 -0
- package/dist/core/insights/agent-distill-spawn.d.ts.map +1 -0
- package/dist/core/insights/agent-distill-spawn.js +179 -0
- package/dist/core/insights/agent-distill-spawn.js.map +1 -0
- package/dist/core/insights/agent-drift.d.ts +66 -0
- package/dist/core/insights/agent-drift.d.ts.map +1 -0
- package/dist/core/insights/agent-drift.js +109 -0
- package/dist/core/insights/agent-drift.js.map +1 -0
- package/dist/core/insights/agent-evolution-sources.d.ts +21 -0
- package/dist/core/insights/agent-evolution-sources.d.ts.map +1 -0
- package/dist/core/insights/agent-evolution-sources.js +36 -0
- package/dist/core/insights/agent-evolution-sources.js.map +1 -0
- package/dist/core/insights/agent-health.d.ts +142 -0
- package/dist/core/insights/agent-health.d.ts.map +1 -0
- package/dist/core/insights/agent-health.js +296 -0
- package/dist/core/insights/agent-health.js.map +1 -0
- package/dist/core/insights/agent-patch-apply.d.ts +45 -0
- package/dist/core/insights/agent-patch-apply.d.ts.map +1 -0
- package/dist/core/insights/agent-patch-apply.js +165 -0
- package/dist/core/insights/agent-patch-apply.js.map +1 -0
- package/dist/core/insights/agent-suggest.d.ts +128 -0
- package/dist/core/insights/agent-suggest.d.ts.map +1 -0
- package/dist/core/insights/agent-suggest.js +284 -0
- package/dist/core/insights/agent-suggest.js.map +1 -0
- package/dist/core/insights/coverage-tiers.d.ts +46 -0
- package/dist/core/insights/coverage-tiers.d.ts.map +1 -0
- package/dist/core/insights/coverage-tiers.js +95 -0
- package/dist/core/insights/coverage-tiers.js.map +1 -0
- package/dist/core/insights/experience-extractor.d.ts +60 -0
- package/dist/core/insights/experience-extractor.d.ts.map +1 -0
- package/dist/core/insights/experience-extractor.js +319 -0
- package/dist/core/insights/experience-extractor.js.map +1 -0
- package/dist/core/insights/violation-reporter.d.ts +149 -0
- package/dist/core/insights/violation-reporter.d.ts.map +1 -0
- package/dist/core/insights/violation-reporter.js +391 -0
- package/dist/core/insights/violation-reporter.js.map +1 -0
- package/dist/core/loop/loop-engine.d.ts +140 -0
- package/dist/core/loop/loop-engine.d.ts.map +1 -0
- package/dist/core/loop/loop-engine.js +266 -0
- package/dist/core/loop/loop-engine.js.map +1 -0
- package/dist/core/queue/index.d.ts +16 -3
- package/dist/core/queue/index.d.ts.map +1 -1
- package/dist/core/queue/index.js +16 -4
- package/dist/core/queue/index.js.map +1 -1
- package/dist/core/storage/base.d.ts +317 -0
- package/dist/core/storage/base.d.ts.map +1 -1
- package/dist/core/storage/base.js +1093 -0
- package/dist/core/storage/base.js.map +1 -1
- package/dist/core/storage/codec/tool-input-codec.d.ts +93 -0
- package/dist/core/storage/codec/tool-input-codec.d.ts.map +1 -0
- package/dist/core/storage/codec/tool-input-codec.js +159 -0
- package/dist/core/storage/codec/tool-input-codec.js.map +1 -0
- package/dist/core/storage/codegraph-types.d.ts +79 -0
- package/dist/core/storage/codegraph-types.d.ts.map +1 -0
- package/dist/core/storage/codegraph-types.js +14 -0
- package/dist/core/storage/codegraph-types.js.map +1 -0
- package/dist/core/storage/codegraph.d.ts +186 -0
- package/dist/core/storage/codegraph.d.ts.map +1 -0
- package/dist/core/storage/codegraph.js +452 -0
- package/dist/core/storage/codegraph.js.map +1 -0
- package/dist/core/storage/decisions.d.ts +387 -0
- package/dist/core/storage/decisions.d.ts.map +1 -0
- package/dist/core/storage/decisions.js +534 -0
- package/dist/core/storage/decisions.js.map +1 -0
- package/dist/core/storage/events.d.ts +239 -8
- package/dist/core/storage/events.d.ts.map +1 -1
- package/dist/core/storage/events.js +705 -39
- package/dist/core/storage/events.js.map +1 -1
- package/dist/core/storage/feedback.d.ts +111 -0
- package/dist/core/storage/feedback.d.ts.map +1 -0
- package/dist/core/storage/feedback.js +186 -0
- package/dist/core/storage/feedback.js.map +1 -0
- package/dist/core/storage/forge-config.d.ts +40 -0
- package/dist/core/storage/forge-config.d.ts.map +1 -0
- package/dist/core/storage/forge-config.js +65 -0
- package/dist/core/storage/forge-config.js.map +1 -0
- package/dist/core/storage/injections.d.ts +68 -0
- package/dist/core/storage/injections.d.ts.map +1 -1
- package/dist/core/storage/injections.js +131 -5
- package/dist/core/storage/injections.js.map +1 -1
- package/dist/core/storage/knowledge.d.ts +332 -0
- package/dist/core/storage/knowledge.d.ts.map +1 -0
- package/dist/core/storage/knowledge.js +589 -0
- package/dist/core/storage/knowledge.js.map +1 -0
- package/dist/core/storage/maintenance.d.ts +36 -9
- package/dist/core/storage/maintenance.d.ts.map +1 -1
- package/dist/core/storage/maintenance.js +56 -24
- package/dist/core/storage/maintenance.js.map +1 -1
- package/dist/core/storage/pipeline-rollup.d.ts +111 -0
- package/dist/core/storage/pipeline-rollup.d.ts.map +1 -0
- package/dist/core/storage/pipeline-rollup.js +432 -0
- package/dist/core/storage/pipeline-rollup.js.map +1 -0
- package/dist/core/storage/routing.d.ts +50 -3
- package/dist/core/storage/routing.d.ts.map +1 -1
- package/dist/core/storage/routing.js +131 -10
- package/dist/core/storage/routing.js.map +1 -1
- package/dist/core/storage/rows.d.ts +31 -8
- package/dist/core/storage/rows.d.ts.map +1 -1
- package/dist/core/storage/schema.sql +367 -23
- package/dist/core/storage/sessions.d.ts +136 -0
- package/dist/core/storage/sessions.d.ts.map +1 -1
- package/dist/core/storage/sessions.js +352 -15
- package/dist/core/storage/sessions.js.map +1 -1
- package/dist/core/storage/skills.d.ts +160 -0
- package/dist/core/storage/skills.d.ts.map +1 -1
- package/dist/core/storage/skills.js +368 -7
- package/dist/core/storage/skills.js.map +1 -1
- package/dist/core/storage/sqlite.d.ts +309 -20
- package/dist/core/storage/sqlite.d.ts.map +1 -1
- package/dist/core/storage/sqlite.js +523 -16
- package/dist/core/storage/sqlite.js.map +1 -1
- package/dist/core/storage/tasks.d.ts +744 -2
- package/dist/core/storage/tasks.d.ts.map +1 -1
- package/dist/core/storage/tasks.js +1691 -17
- package/dist/core/storage/tasks.js.map +1 -1
- package/dist/core/storage/tool-intercepts.d.ts +69 -0
- package/dist/core/storage/tool-intercepts.d.ts.map +1 -0
- package/dist/core/storage/tool-intercepts.js +116 -0
- package/dist/core/storage/tool-intercepts.js.map +1 -0
- package/dist/core/types.d.ts +136 -18
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/utils/backup.d.ts +81 -0
- package/dist/core/utils/backup.d.ts.map +1 -0
- package/dist/core/utils/backup.js +98 -0
- package/dist/core/utils/backup.js.map +1 -0
- package/dist/core/utils/binary-paths.d.ts +124 -0
- package/dist/core/utils/binary-paths.d.ts.map +1 -0
- package/dist/core/utils/binary-paths.js +218 -0
- package/dist/core/utils/binary-paths.js.map +1 -0
- package/dist/core/utils/bypass-token.d.ts +75 -0
- package/dist/core/utils/bypass-token.d.ts.map +1 -0
- package/dist/core/utils/bypass-token.js +133 -0
- package/dist/core/utils/bypass-token.js.map +1 -0
- package/dist/core/utils/cc-builtin-agents.d.ts +3 -0
- package/dist/core/utils/cc-builtin-agents.d.ts.map +1 -0
- package/dist/core/utils/cc-builtin-agents.js +29 -0
- package/dist/core/utils/cc-builtin-agents.js.map +1 -0
- package/dist/core/utils/claude-cli-resolver.d.ts +26 -0
- package/dist/core/utils/claude-cli-resolver.d.ts.map +1 -0
- package/dist/core/utils/claude-cli-resolver.js +115 -0
- package/dist/core/utils/claude-cli-resolver.js.map +1 -0
- package/dist/core/utils/claude-cli-spawn.d.ts +106 -0
- package/dist/core/utils/claude-cli-spawn.d.ts.map +1 -0
- package/dist/core/utils/claude-cli-spawn.js +219 -0
- package/dist/core/utils/claude-cli-spawn.js.map +1 -0
- package/dist/core/utils/forge-resume-block.d.ts.map +1 -1
- package/dist/core/utils/forge-resume-block.js +3 -2
- package/dist/core/utils/forge-resume-block.js.map +1 -1
- package/dist/core/utils/logger.d.ts +15 -3
- package/dist/core/utils/logger.d.ts.map +1 -1
- package/dist/core/utils/logger.js +20 -2
- package/dist/core/utils/logger.js.map +1 -1
- package/dist/core/utils/noise-prompt.d.ts +97 -0
- package/dist/core/utils/noise-prompt.d.ts.map +1 -0
- package/dist/core/utils/noise-prompt.js +127 -0
- package/dist/core/utils/noise-prompt.js.map +1 -0
- package/dist/core/utils/path.d.ts +0 -4
- package/dist/core/utils/path.d.ts.map +1 -1
- package/dist/core/utils/path.js +0 -7
- package/dist/core/utils/path.js.map +1 -1
- package/dist/core/utils/time.d.ts +67 -0
- package/dist/core/utils/time.d.ts.map +1 -1
- package/dist/core/utils/time.js +147 -0
- package/dist/core/utils/time.js.map +1 -1
- package/dist/daemon/agent-sync.d.ts +24 -0
- package/dist/daemon/agent-sync.d.ts.map +1 -0
- package/dist/daemon/agent-sync.js +114 -0
- package/dist/daemon/agent-sync.js.map +1 -0
- package/dist/daemon/config-store.d.ts +55 -0
- package/dist/daemon/config-store.d.ts.map +1 -0
- package/dist/daemon/config-store.js +146 -0
- package/dist/daemon/config-store.js.map +1 -0
- package/dist/daemon/event-parser.d.ts +22 -0
- package/dist/daemon/event-parser.d.ts.map +1 -1
- package/dist/daemon/event-parser.js +54 -3
- package/dist/daemon/event-parser.js.map +1 -1
- package/dist/daemon/handlers/history-exporter.d.ts.map +1 -1
- package/dist/daemon/handlers/history-exporter.js +9 -8
- package/dist/daemon/handlers/history-exporter.js.map +1 -1
- package/dist/daemon/handlers/post-tool-use.d.ts +66 -4
- package/dist/daemon/handlers/post-tool-use.d.ts.map +1 -1
- package/dist/daemon/handlers/post-tool-use.js +221 -8
- package/dist/daemon/handlers/post-tool-use.js.map +1 -1
- package/dist/daemon/handlers/pre-tool-use.d.ts +181 -0
- package/dist/daemon/handlers/pre-tool-use.d.ts.map +1 -0
- package/dist/daemon/handlers/pre-tool-use.js +618 -0
- package/dist/daemon/handlers/pre-tool-use.js.map +1 -0
- package/dist/daemon/handlers/stop.d.ts +55 -7
- package/dist/daemon/handlers/stop.d.ts.map +1 -1
- package/dist/daemon/handlers/stop.js +245 -8
- package/dist/daemon/handlers/stop.js.map +1 -1
- package/dist/daemon/handlers/user-prompt.d.ts +51 -14
- package/dist/daemon/handlers/user-prompt.d.ts.map +1 -1
- package/dist/daemon/handlers/user-prompt.js +223 -95
- package/dist/daemon/handlers/user-prompt.js.map +1 -1
- package/dist/daemon/handlers/violation-content-backfill.d.ts +76 -0
- package/dist/daemon/handlers/violation-content-backfill.d.ts.map +1 -0
- package/dist/daemon/handlers/violation-content-backfill.js +167 -0
- package/dist/daemon/handlers/violation-content-backfill.js.map +1 -0
- package/dist/daemon/hook-sync.d.ts.map +1 -1
- package/dist/daemon/hook-sync.js +2 -1
- package/dist/daemon/hook-sync.js.map +1 -1
- package/dist/daemon/index.d.ts +19 -0
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +439 -86
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/lifecycle.d.ts +48 -1
- package/dist/daemon/lifecycle.d.ts.map +1 -1
- package/dist/daemon/lifecycle.js +98 -2
- package/dist/daemon/lifecycle.js.map +1 -1
- package/dist/daemon/router.d.ts +4 -1
- package/dist/daemon/router.d.ts.map +1 -1
- package/dist/daemon/router.js +4 -2
- package/dist/daemon/router.js.map +1 -1
- package/dist/daemon/rules/defaults.d.ts +20 -0
- package/dist/daemon/rules/defaults.d.ts.map +1 -0
- package/dist/daemon/rules/defaults.js +779 -0
- package/dist/daemon/rules/defaults.js.map +1 -0
- package/dist/daemon/rules/registry.d.ts +47 -0
- package/dist/daemon/rules/registry.d.ts.map +1 -0
- package/dist/daemon/rules/registry.js +84 -0
- package/dist/daemon/rules/registry.js.map +1 -0
- package/dist/daemon/rules/types.d.ts +176 -0
- package/dist/daemon/rules/types.d.ts.map +1 -0
- package/dist/daemon/rules/types.js +15 -0
- package/dist/daemon/rules/types.js.map +1 -0
- package/dist/daemon/rules/whitelist.d.ts +101 -0
- package/dist/daemon/rules/whitelist.d.ts.map +1 -0
- package/dist/daemon/rules/whitelist.js +210 -0
- package/dist/daemon/rules/whitelist.js.map +1 -0
- package/dist/daemon/rules/workflow-defaults.d.ts +52 -0
- package/dist/daemon/rules/workflow-defaults.d.ts.map +1 -0
- package/dist/daemon/rules/workflow-defaults.js +521 -0
- package/dist/daemon/rules/workflow-defaults.js.map +1 -0
- package/dist/daemon/server.d.ts +11 -1
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +7 -1
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/services/codegraph-sync.d.ts +94 -0
- package/dist/daemon/services/codegraph-sync.d.ts.map +1 -0
- package/dist/daemon/services/codegraph-sync.js +159 -0
- package/dist/daemon/services/codegraph-sync.js.map +1 -0
- package/dist/daemon/services/context-injector.d.ts +34 -0
- package/dist/daemon/services/context-injector.d.ts.map +1 -0
- package/dist/daemon/services/context-injector.js +61 -0
- package/dist/daemon/services/context-injector.js.map +1 -0
- package/dist/daemon/services/decision-hint.d.ts +240 -0
- package/dist/daemon/services/decision-hint.d.ts.map +1 -0
- package/dist/daemon/services/decision-hint.js +562 -0
- package/dist/daemon/services/decision-hint.js.map +1 -0
- package/dist/daemon/services/event-ttl-sweep.d.ts +86 -0
- package/dist/daemon/services/event-ttl-sweep.d.ts.map +1 -0
- package/dist/daemon/services/event-ttl-sweep.js +124 -0
- package/dist/daemon/services/event-ttl-sweep.js.map +1 -0
- package/dist/daemon/services/feedback-aggregator.d.ts +167 -0
- package/dist/daemon/services/feedback-aggregator.d.ts.map +1 -0
- package/dist/daemon/services/feedback-aggregator.js +415 -0
- package/dist/daemon/services/feedback-aggregator.js.map +1 -0
- package/dist/daemon/services/heartbeat-writer.d.ts +46 -0
- package/dist/daemon/services/heartbeat-writer.d.ts.map +1 -0
- package/dist/daemon/services/heartbeat-writer.js +82 -0
- package/dist/daemon/services/heartbeat-writer.js.map +1 -0
- package/dist/daemon/services/idle-session-sweeper.d.ts +61 -0
- package/dist/daemon/services/idle-session-sweeper.d.ts.map +1 -0
- package/dist/daemon/services/idle-session-sweeper.js +94 -0
- package/dist/daemon/services/idle-session-sweeper.js.map +1 -0
- package/dist/daemon/services/idle-task-budget.d.ts +50 -0
- package/dist/daemon/services/idle-task-budget.d.ts.map +1 -0
- package/dist/daemon/services/idle-task-budget.js +72 -0
- package/dist/daemon/services/idle-task-budget.js.map +1 -0
- package/dist/daemon/services/intercept-revive.d.ts +60 -0
- package/dist/daemon/services/intercept-revive.d.ts.map +1 -0
- package/dist/daemon/services/intercept-revive.js +86 -0
- package/dist/daemon/services/intercept-revive.js.map +1 -0
- package/dist/daemon/services/intercept-rollback-guard.d.ts +105 -0
- package/dist/daemon/services/intercept-rollback-guard.d.ts.map +1 -0
- package/dist/daemon/services/intercept-rollback-guard.js +152 -0
- package/dist/daemon/services/intercept-rollback-guard.js.map +1 -0
- package/dist/daemon/services/intercept-timeout-sweeper.d.ts +58 -0
- package/dist/daemon/services/intercept-timeout-sweeper.d.ts.map +1 -0
- package/dist/daemon/services/intercept-timeout-sweeper.js +83 -0
- package/dist/daemon/services/intercept-timeout-sweeper.js.map +1 -0
- package/dist/daemon/services/kb-injector.d.ts +57 -0
- package/dist/daemon/services/kb-injector.d.ts.map +1 -0
- package/dist/daemon/services/kb-injector.js +148 -0
- package/dist/daemon/services/kb-injector.js.map +1 -0
- package/dist/daemon/services/kb-rebuild-scheduler.d.ts +95 -0
- package/dist/daemon/services/kb-rebuild-scheduler.d.ts.map +1 -0
- package/dist/daemon/services/kb-rebuild-scheduler.js +149 -0
- package/dist/daemon/services/kb-rebuild-scheduler.js.map +1 -0
- package/dist/daemon/services/loop-hint.d.ts +139 -0
- package/dist/daemon/services/loop-hint.d.ts.map +1 -0
- package/dist/daemon/services/loop-hint.js +272 -0
- package/dist/daemon/services/loop-hint.js.map +1 -0
- package/dist/daemon/services/outcome-classification-service.d.ts +49 -0
- package/dist/daemon/services/outcome-classification-service.d.ts.map +1 -0
- package/dist/daemon/services/outcome-classification-service.js +214 -0
- package/dist/daemon/services/outcome-classification-service.js.map +1 -0
- package/dist/daemon/services/outcome-classifier.d.ts +136 -0
- package/dist/daemon/services/outcome-classifier.d.ts.map +1 -0
- package/dist/daemon/services/outcome-classifier.js +178 -0
- package/dist/daemon/services/outcome-classifier.js.map +1 -0
- package/dist/daemon/services/outcome-nudge.d.ts +107 -0
- package/dist/daemon/services/outcome-nudge.d.ts.map +1 -0
- package/dist/daemon/services/outcome-nudge.js +242 -0
- package/dist/daemon/services/outcome-nudge.js.map +1 -0
- package/dist/daemon/services/spec-approval.d.ts +127 -0
- package/dist/daemon/services/spec-approval.d.ts.map +1 -0
- package/dist/daemon/services/spec-approval.js +216 -0
- package/dist/daemon/services/spec-approval.js.map +1 -0
- package/dist/daemon/services/spec-gate.d.ts +54 -0
- package/dist/daemon/services/spec-gate.d.ts.map +1 -0
- package/dist/daemon/services/spec-gate.js +113 -0
- package/dist/daemon/services/spec-gate.js.map +1 -0
- package/dist/daemon/services/task-boundary-classifier.d.ts +78 -0
- package/dist/daemon/services/task-boundary-classifier.d.ts.map +1 -0
- package/dist/daemon/services/task-boundary-classifier.js +202 -0
- package/dist/daemon/services/task-boundary-classifier.js.map +1 -0
- package/dist/daemon/services/task-segmenter.d.ts +230 -1
- package/dist/daemon/services/task-segmenter.d.ts.map +1 -1
- package/dist/daemon/services/task-segmenter.js +527 -17
- package/dist/daemon/services/task-segmenter.js.map +1 -1
- package/dist/daemon/skill-sync.d.ts +7 -2
- package/dist/daemon/skill-sync.d.ts.map +1 -1
- package/dist/daemon/skill-sync.js +114 -9
- package/dist/daemon/skill-sync.js.map +1 -1
- package/dist/daemon/startup/maintenance-schedulers.d.ts +68 -0
- package/dist/daemon/startup/maintenance-schedulers.d.ts.map +1 -0
- package/dist/daemon/startup/maintenance-schedulers.js +294 -0
- package/dist/daemon/startup/maintenance-schedulers.js.map +1 -0
- package/dist/daemon/templates/agents/agent-retro-distiller.md +106 -0
- package/dist/daemon/templates/agents/claudemd-writer.md +102 -0
- package/dist/daemon/templates/agents/coder.md +262 -0
- package/dist/daemon/templates/agents/decision-maker.md +546 -0
- package/dist/daemon/templates/agents/doc-reviewer.md +118 -0
- package/dist/daemon/templates/agents/harness-debug-full.md +196 -0
- package/dist/daemon/templates/agents/knowledge-builder.md +120 -0
- package/dist/daemon/templates/agents/patch-applier.md +145 -0
- package/dist/daemon/templates/agents/planner.md +217 -0
- package/dist/daemon/templates/agents/safety-net-implementer.md +278 -0
- package/dist/daemon/templates/agents/skill-distiller.md +114 -0
- package/dist/daemon/templates/agents/task-boundary-classifier.md +65 -0
- package/dist/daemon/templates/agents/verify-agent.md +259 -0
- package/dist/daemon/utils/inject-block.d.ts +39 -0
- package/dist/daemon/utils/inject-block.d.ts.map +1 -0
- package/dist/daemon/utils/inject-block.js +25 -0
- package/dist/daemon/utils/inject-block.js.map +1 -0
- package/dist/hooks/hook-lib.sh +8 -0
- package/dist/hooks/notification.sh +19 -8
- package/dist/hooks/post-tool-use.sh +41 -23
- package/dist/hooks/pre-tool-use.sh +54 -23
- package/dist/hooks/session-start.sh +68 -0
- package/dist/hooks/stop.sh +31 -11
- package/dist/hooks/user-prompt-submit.sh +37 -21
- package/dist/knowledge/adapters/go-adapter.d.ts +65 -0
- package/dist/knowledge/adapters/go-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/go-adapter.js +294 -0
- package/dist/knowledge/adapters/go-adapter.js.map +1 -0
- package/dist/knowledge/adapters/index.d.ts +41 -0
- package/dist/knowledge/adapters/index.d.ts.map +1 -0
- package/dist/knowledge/adapters/index.js +71 -0
- package/dist/knowledge/adapters/index.js.map +1 -0
- package/dist/knowledge/adapters/java-adapter.d.ts +66 -0
- package/dist/knowledge/adapters/java-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/java-adapter.js +260 -0
- package/dist/knowledge/adapters/java-adapter.js.map +1 -0
- package/dist/knowledge/adapters/js-vue-adapter.d.ts +56 -0
- package/dist/knowledge/adapters/js-vue-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/js-vue-adapter.js +203 -0
- package/dist/knowledge/adapters/js-vue-adapter.js.map +1 -0
- package/dist/knowledge/adapters/kotlin-adapter.d.ts +55 -0
- package/dist/knowledge/adapters/kotlin-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/kotlin-adapter.js +209 -0
- package/dist/knowledge/adapters/kotlin-adapter.js.map +1 -0
- package/dist/knowledge/adapters/monorepo-adapter.d.ts +77 -0
- package/dist/knowledge/adapters/monorepo-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/monorepo-adapter.js +170 -0
- package/dist/knowledge/adapters/monorepo-adapter.js.map +1 -0
- package/dist/knowledge/adapters/python-adapter.d.ts +89 -0
- package/dist/knowledge/adapters/python-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/python-adapter.js +358 -0
- package/dist/knowledge/adapters/python-adapter.js.map +1 -0
- package/dist/knowledge/adapters/rust-adapter.d.ts +73 -0
- package/dist/knowledge/adapters/rust-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/rust-adapter.js +329 -0
- package/dist/knowledge/adapters/rust-adapter.js.map +1 -0
- package/dist/knowledge/adapters/types.d.ts +99 -0
- package/dist/knowledge/adapters/types.d.ts.map +1 -0
- package/dist/knowledge/adapters/types.js +17 -0
- package/dist/knowledge/adapters/types.js.map +1 -0
- package/dist/knowledge/adapters/typescript-adapter.d.ts +57 -0
- package/dist/knowledge/adapters/typescript-adapter.d.ts.map +1 -0
- package/dist/knowledge/adapters/typescript-adapter.js +171 -0
- package/dist/knowledge/adapters/typescript-adapter.js.map +1 -0
- package/dist/knowledge/audit-applier.d.ts +70 -0
- package/dist/knowledge/audit-applier.d.ts.map +1 -0
- package/dist/knowledge/audit-applier.js +251 -0
- package/dist/knowledge/audit-applier.js.map +1 -0
- package/dist/knowledge/builder.d.ts +261 -0
- package/dist/knowledge/builder.d.ts.map +1 -0
- package/dist/knowledge/builder.js +966 -0
- package/dist/knowledge/builder.js.map +1 -0
- package/dist/knowledge/cli-provider.d.ts +151 -0
- package/dist/knowledge/cli-provider.d.ts.map +1 -0
- package/dist/knowledge/cli-provider.js +313 -0
- package/dist/knowledge/cli-provider.js.map +1 -0
- package/dist/knowledge/constants.d.ts +78 -0
- package/dist/knowledge/constants.d.ts.map +1 -0
- package/dist/knowledge/constants.js +98 -0
- package/dist/knowledge/constants.js.map +1 -0
- package/dist/knowledge/cross-module.d.ts +139 -0
- package/dist/knowledge/cross-module.d.ts.map +1 -0
- package/dist/knowledge/cross-module.js +370 -0
- package/dist/knowledge/cross-module.js.map +1 -0
- package/dist/knowledge/git-hooks.d.ts +67 -0
- package/dist/knowledge/git-hooks.d.ts.map +1 -0
- package/dist/knowledge/git-hooks.js +258 -0
- package/dist/knowledge/git-hooks.js.map +1 -0
- package/dist/knowledge/graph/edge-extractor.d.ts +45 -0
- package/dist/knowledge/graph/edge-extractor.d.ts.map +1 -0
- package/dist/knowledge/graph/edge-extractor.js +242 -0
- package/dist/knowledge/graph/edge-extractor.js.map +1 -0
- package/dist/knowledge/graph/impact.d.ts +73 -0
- package/dist/knowledge/graph/impact.d.ts.map +1 -0
- package/dist/knowledge/graph/impact.js +94 -0
- package/dist/knowledge/graph/impact.js.map +1 -0
- package/dist/knowledge/graph/types.d.ts +22 -0
- package/dist/knowledge/graph/types.d.ts.map +1 -0
- package/dist/knowledge/graph/types.js +13 -0
- package/dist/knowledge/graph/types.js.map +1 -0
- package/dist/knowledge/module-hash.d.ts +88 -0
- package/dist/knowledge/module-hash.d.ts.map +1 -0
- package/dist/knowledge/module-hash.js +162 -0
- package/dist/knowledge/module-hash.js.map +1 -0
- package/dist/knowledge/project-detector.d.ts +101 -0
- package/dist/knowledge/project-detector.d.ts.map +1 -0
- package/dist/knowledge/project-detector.js +223 -0
- package/dist/knowledge/project-detector.js.map +1 -0
- package/dist/knowledge/prompt.d.ts +237 -0
- package/dist/knowledge/prompt.d.ts.map +1 -0
- package/dist/knowledge/prompt.js +416 -0
- package/dist/knowledge/prompt.js.map +1 -0
- package/dist/knowledge/query.d.ts +118 -0
- package/dist/knowledge/query.d.ts.map +1 -0
- package/dist/knowledge/query.js +438 -0
- package/dist/knowledge/query.js.map +1 -0
- package/dist/knowledge/repo-map.d.ts +97 -0
- package/dist/knowledge/repo-map.d.ts.map +1 -0
- package/dist/knowledge/repo-map.js +447 -0
- package/dist/knowledge/repo-map.js.map +1 -0
- package/dist/knowledge/tools/index.d.ts +14 -0
- package/dist/knowledge/tools/index.d.ts.map +1 -0
- package/dist/knowledge/tools/index.js +11 -0
- package/dist/knowledge/tools/index.js.map +1 -0
- package/dist/knowledge/tools/knowledge-get-page.d.ts +46 -0
- package/dist/knowledge/tools/knowledge-get-page.d.ts.map +1 -0
- package/dist/knowledge/tools/knowledge-get-page.js +101 -0
- package/dist/knowledge/tools/knowledge-get-page.js.map +1 -0
- package/dist/knowledge/tools/knowledge-query.d.ts +77 -0
- package/dist/knowledge/tools/knowledge-query.d.ts.map +1 -0
- package/dist/knowledge/tools/knowledge-query.js +104 -0
- package/dist/knowledge/tools/knowledge-query.js.map +1 -0
- package/dist/knowledge/tools/repo-map-lookup.d.ts +45 -0
- package/dist/knowledge/tools/repo-map-lookup.d.ts.map +1 -0
- package/dist/knowledge/tools/repo-map-lookup.js +82 -0
- package/dist/knowledge/tools/repo-map-lookup.js.map +1 -0
- package/dist/knowledge/types.d.ts +269 -0
- package/dist/knowledge/types.d.ts.map +1 -0
- package/dist/knowledge/types.js +10 -0
- package/dist/knowledge/types.js.map +1 -0
- package/dist/knowledge/validator.d.ts +90 -0
- package/dist/knowledge/validator.d.ts.map +1 -0
- package/dist/knowledge/validator.js +355 -0
- package/dist/knowledge/validator.js.map +1 -0
- package/dist/mcp/server.d.ts +64 -8
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +448 -12
- package/dist/mcp/server.js.map +1 -1
- package/dist/skills/builtin-skills.d.ts +35 -0
- package/dist/skills/builtin-skills.d.ts.map +1 -0
- package/dist/skills/builtin-skills.js +68 -0
- package/dist/skills/builtin-skills.js.map +1 -0
- package/dist/skills/distill/attribution.d.ts +59 -0
- package/dist/skills/distill/attribution.d.ts.map +1 -0
- package/dist/skills/distill/attribution.js +101 -0
- package/dist/skills/distill/attribution.js.map +1 -0
- package/dist/skills/distill/distiller.d.ts +161 -0
- package/dist/skills/distill/distiller.d.ts.map +1 -0
- package/dist/skills/distill/distiller.js +461 -0
- package/dist/skills/distill/distiller.js.map +1 -0
- package/dist/skills/distill/index.d.ts +223 -0
- package/dist/skills/distill/index.d.ts.map +1 -0
- package/dist/skills/distill/index.js +466 -0
- package/dist/skills/distill/index.js.map +1 -0
- package/dist/skills/distill/project-anchor-guard.d.ts +116 -0
- package/dist/skills/distill/project-anchor-guard.d.ts.map +1 -0
- package/dist/skills/distill/project-anchor-guard.js +334 -0
- package/dist/skills/distill/project-anchor-guard.js.map +1 -0
- package/dist/skills/distill/topic-deduper.d.ts +77 -0
- package/dist/skills/distill/topic-deduper.d.ts.map +1 -0
- package/dist/skills/distill/topic-deduper.js +119 -0
- package/dist/skills/distill/topic-deduper.js.map +1 -0
- package/dist/skills/distill/upstream-fetcher.d.ts +71 -0
- package/dist/skills/distill/upstream-fetcher.d.ts.map +1 -0
- package/dist/skills/distill/upstream-fetcher.js +202 -0
- package/dist/skills/distill/upstream-fetcher.js.map +1 -0
- package/dist/skills/distilled/distilled-api-design.md +495 -0
- package/dist/skills/distilled/distilled-architecture-decision.md +173 -0
- package/dist/skills/distilled/distilled-brainstorming.md +79 -0
- package/dist/skills/distilled/distilled-brand-guidelines.md +86 -0
- package/dist/skills/distilled/distilled-canvas-design.md +128 -0
- package/dist/skills/distilled/distilled-claude-api.md +185 -0
- package/dist/skills/distilled/distilled-creator.md +181 -0
- package/dist/skills/distilled/distilled-db-schema-design.md +245 -0
- package/dist/skills/distilled/distilled-dispatching-parallel-agents.md +136 -0
- package/dist/skills/distilled/distilled-doc-coauthoring.md +144 -0
- package/dist/skills/distilled/distilled-docx.md +231 -0
- package/dist/skills/distilled/distilled-executing-plans.md +148 -0
- package/dist/skills/distilled/distilled-finishing-a-development-branch.md +213 -0
- package/dist/skills/distilled/distilled-frontend-design.md +118 -0
- package/dist/skills/distilled/distilled-harness-engineering.md +242 -0
- package/dist/skills/distilled/distilled-karpathy-guidelines.md +104 -0
- package/dist/skills/distilled/distilled-performance-optimization.md +175 -0
- package/dist/skills/distilled/distilled-receiving-code-review.md +185 -0
- package/dist/skills/distilled/distilled-spec-driven-design.md +193 -0
- package/dist/skills/distilled/distilled-subagent-driven-development.md +124 -0
- package/dist/skills/distilled/distilled-systematic-debugging.md +154 -0
- package/dist/skills/distilled/distilled-test-driven-development.md +432 -0
- package/dist/skills/distilled/distilled-using-superpowers.md +134 -0
- package/dist/skills/distilled/distilled-verification-before-completion.md +213 -0
- package/dist/skills/distilled/distilled-writing-skills.md +175 -0
- package/dist/skills/registry.d.ts +55 -51
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +82 -196
- package/dist/skills/registry.js.map +1 -1
- package/dist/skills/tools/pipeline-suggest.js +14 -14
- package/dist/skills/tools/pipeline-suggest.js.map +1 -1
- package/dist/skills/tools/skill-invoke.d.ts +3 -2
- package/dist/skills/tools/skill-invoke.d.ts.map +1 -1
- package/dist/skills/tools/skill-invoke.js +4 -2
- package/dist/skills/tools/skill-invoke.js.map +1 -1
- package/dist/web/analytics/anti-pattern-detector.d.ts.map +1 -1
- package/dist/web/analytics/anti-pattern-detector.js +6 -1
- package/dist/web/analytics/anti-pattern-detector.js.map +1 -1
- package/dist/web/analytics/drift-detector.d.ts +6 -0
- package/dist/web/analytics/drift-detector.d.ts.map +1 -1
- package/dist/web/analytics/drift-detector.js +15 -8
- package/dist/web/analytics/drift-detector.js.map +1 -1
- package/dist/web/analytics/weekly-report.d.ts +13 -0
- package/dist/web/analytics/weekly-report.d.ts.map +1 -1
- package/dist/web/analytics/weekly-report.js +17 -3
- package/dist/web/analytics/weekly-report.js.map +1 -1
- package/dist/web/routes/_helpers.d.ts +31 -0
- package/dist/web/routes/_helpers.d.ts.map +1 -1
- package/dist/web/routes/_helpers.js +33 -0
- package/dist/web/routes/_helpers.js.map +1 -1
- package/dist/web/routes/agent-content.d.ts +30 -0
- package/dist/web/routes/agent-content.d.ts.map +1 -0
- package/dist/web/routes/agent-content.js +139 -0
- package/dist/web/routes/agent-content.js.map +1 -0
- package/dist/web/routes/agent-distill.d.ts +49 -0
- package/dist/web/routes/agent-distill.d.ts.map +1 -0
- package/dist/web/routes/agent-distill.js +526 -0
- package/dist/web/routes/agent-distill.js.map +1 -0
- package/dist/web/routes/config.d.ts +56 -0
- package/dist/web/routes/config.d.ts.map +1 -0
- package/dist/web/routes/config.js +243 -0
- package/dist/web/routes/config.js.map +1 -0
- package/dist/web/routes/decisions.d.ts +15 -0
- package/dist/web/routes/decisions.d.ts.map +1 -0
- package/dist/web/routes/decisions.js +181 -0
- package/dist/web/routes/decisions.js.map +1 -0
- package/dist/web/routes/diagnostics.d.ts +61 -0
- package/dist/web/routes/diagnostics.d.ts.map +1 -0
- package/dist/web/routes/diagnostics.js +203 -0
- package/dist/web/routes/diagnostics.js.map +1 -0
- package/dist/web/routes/error-handler.d.ts +0 -4
- package/dist/web/routes/error-handler.d.ts.map +1 -1
- package/dist/web/routes/error-handler.js +0 -8
- package/dist/web/routes/error-handler.js.map +1 -1
- package/dist/web/routes/events.d.ts.map +1 -1
- package/dist/web/routes/events.js +26 -1
- package/dist/web/routes/events.js.map +1 -1
- package/dist/web/routes/health.d.ts +33 -0
- package/dist/web/routes/health.d.ts.map +1 -0
- package/dist/web/routes/health.js +37 -0
- package/dist/web/routes/health.js.map +1 -0
- package/dist/web/routes/insights.d.ts +0 -5
- package/dist/web/routes/insights.d.ts.map +1 -1
- package/dist/web/routes/insights.js +0 -0
- package/dist/web/routes/insights.js.map +1 -1
- package/dist/web/routes/knowledge.d.ts +57 -0
- package/dist/web/routes/knowledge.d.ts.map +1 -0
- package/dist/web/routes/knowledge.js +772 -0
- package/dist/web/routes/knowledge.js.map +1 -0
- package/dist/web/routes/patch.d.ts +60 -1
- package/dist/web/routes/patch.d.ts.map +1 -1
- package/dist/web/routes/patch.js +170 -64
- package/dist/web/routes/patch.js.map +1 -1
- package/dist/web/routes/pipeline.d.ts +28 -0
- package/dist/web/routes/pipeline.d.ts.map +1 -0
- package/dist/web/routes/pipeline.js +145 -0
- package/dist/web/routes/pipeline.js.map +1 -0
- package/dist/web/routes/rules.d.ts.map +1 -1
- package/dist/web/routes/rules.js +26 -7
- package/dist/web/routes/rules.js.map +1 -1
- package/dist/web/routes/sessions.d.ts.map +1 -1
- package/dist/web/routes/sessions.js +17 -8
- package/dist/web/routes/sessions.js.map +1 -1
- package/dist/web/routes/skill-content.d.ts +30 -0
- package/dist/web/routes/skill-content.d.ts.map +1 -0
- package/dist/web/routes/skill-content.js +117 -0
- package/dist/web/routes/skill-content.js.map +1 -0
- package/dist/web/routes/skill-stats.d.ts.map +1 -1
- package/dist/web/routes/skill-stats.js +153 -16
- package/dist/web/routes/skill-stats.js.map +1 -1
- package/dist/web/routes/skills-distill.d.ts +29 -0
- package/dist/web/routes/skills-distill.d.ts.map +1 -0
- package/dist/web/routes/skills-distill.js +552 -0
- package/dist/web/routes/skills-distill.js.map +1 -0
- package/dist/web/routes/skills.js +7 -7
- package/dist/web/routes/skills.js.map +1 -1
- package/dist/web/routes/stats.d.ts.map +1 -1
- package/dist/web/routes/stats.js +2 -1
- package/dist/web/routes/stats.js.map +1 -1
- package/dist/web/routes/task-timeline.d.ts +178 -0
- package/dist/web/routes/task-timeline.d.ts.map +1 -0
- package/dist/web/routes/task-timeline.js +530 -0
- package/dist/web/routes/task-timeline.js.map +1 -0
- package/dist/web/routes/tasks.d.ts.map +1 -1
- package/dist/web/routes/tasks.js +377 -8
- package/dist/web/routes/tasks.js.map +1 -1
- package/dist/web/routes/trace.d.ts.map +1 -1
- package/dist/web/routes/trace.js +3 -2
- package/dist/web/routes/trace.js.map +1 -1
- package/dist/web/routes/types.d.ts +0 -4
- package/dist/web/routes/types.d.ts.map +1 -1
- package/dist/web/routes/types.js +1 -1
- package/dist/web/routes/types.js.map +1 -1
- package/dist/web/routes/violations.d.ts +14 -0
- package/dist/web/routes/violations.d.ts.map +1 -0
- package/dist/web/routes/violations.js +112 -0
- package/dist/web/routes/violations.js.map +1 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +99 -19
- package/dist/web/server.js.map +1 -1
- package/dist/web/services/agent-distill-manager.d.ts +122 -0
- package/dist/web/services/agent-distill-manager.d.ts.map +1 -0
- package/dist/web/services/agent-distill-manager.js +397 -0
- package/dist/web/services/agent-distill-manager.js.map +1 -0
- package/dist/web/services/build-manager.d.ts +72 -0
- package/dist/web/services/build-manager.d.ts.map +1 -0
- package/dist/web/services/build-manager.js +189 -0
- package/dist/web/services/build-manager.js.map +1 -0
- package/dist/web/services/distill-manager.d.ts +172 -0
- package/dist/web/services/distill-manager.d.ts.map +1 -0
- package/dist/web/services/distill-manager.js +411 -0
- package/dist/web/services/distill-manager.js.map +1 -0
- package/dist/web/static/assets/AgentDetailPage-DlUeA1sX.js +2 -0
- package/dist/web/static/assets/AgentDetailPage-DlUeA1sX.js.map +1 -0
- package/dist/web/static/assets/AgentDistillRunPage-Cybo4bii.js +3 -0
- package/dist/web/static/assets/AgentDistillRunPage-Cybo4bii.js.map +1 -0
- package/dist/web/static/assets/AgentsPage-Qd9FExLG.js +2 -0
- package/dist/web/static/assets/AgentsPage-Qd9FExLG.js.map +1 -0
- package/dist/web/static/assets/DaemonHealthPage-DTSVqtrI.js +2 -0
- package/dist/web/static/assets/DaemonHealthPage-DTSVqtrI.js.map +1 -0
- package/dist/web/static/assets/DecisionDetailPage-b4BA8dhc.js +2 -0
- package/dist/web/static/assets/DecisionDetailPage-b4BA8dhc.js.map +1 -0
- package/dist/web/static/assets/DecisionsPage-a3NRo_T7.js +2 -0
- package/dist/web/static/assets/DecisionsPage-a3NRo_T7.js.map +1 -0
- package/dist/web/static/assets/DiagnosticsPage-DIVdiIQG.js +2 -0
- package/dist/web/static/assets/DiagnosticsPage-DIVdiIQG.js.map +1 -0
- package/dist/web/static/assets/DistillDetailPage-U6a3l2iP.js +4 -0
- package/dist/web/static/assets/DistillDetailPage-U6a3l2iP.js.map +1 -0
- package/dist/web/static/assets/DistillPage-O7BHtRN8.js +2 -0
- package/dist/web/static/assets/DistillPage-O7BHtRN8.js.map +1 -0
- package/dist/web/static/assets/DistillRunPage-D1JuRWWr.js +2 -0
- package/dist/web/static/assets/DistillRunPage-D1JuRWWr.js.map +1 -0
- package/dist/web/static/assets/GlobalScopeHint-Q3wTJx3F.js +2 -0
- package/dist/web/static/assets/GlobalScopeHint-Q3wTJx3F.js.map +1 -0
- package/dist/web/static/assets/IssueDetailPage-BDfrtk2C.js +2 -0
- package/dist/web/static/assets/IssueDetailPage-BDfrtk2C.js.map +1 -0
- package/dist/web/static/assets/IssuesPage-SKmhlCrw.js +2 -0
- package/dist/web/static/assets/IssuesPage-SKmhlCrw.js.map +1 -0
- package/dist/web/static/assets/KbDetailPage-Yna86Na8.js +2 -0
- package/dist/web/static/assets/KbDetailPage-Yna86Na8.js.map +1 -0
- package/dist/web/static/assets/KbHitsPage-Cljl7H9p.js +2 -0
- package/dist/web/static/assets/KbHitsPage-Cljl7H9p.js.map +1 -0
- package/dist/web/static/assets/MarkdownRenderer-DlDQNihj.js +3 -0
- package/dist/web/static/assets/MarkdownRenderer-DlDQNihj.js.map +1 -0
- package/dist/web/static/assets/NotFound-LMzbP51V.js +2 -0
- package/dist/web/static/assets/NotFound-LMzbP51V.js.map +1 -0
- package/dist/web/static/assets/SettingsPage-DzoK4PKg.js +2 -0
- package/dist/web/static/assets/SettingsPage-DzoK4PKg.js.map +1 -0
- package/dist/web/static/assets/SkillDetailPage-BuBJJ_NX.js +2 -0
- package/dist/web/static/assets/SkillDetailPage-BuBJJ_NX.js.map +1 -0
- package/dist/web/static/assets/SkillsPage-aojkJpBc.js +2 -0
- package/dist/web/static/assets/SkillsPage-aojkJpBc.js.map +1 -0
- package/dist/web/static/assets/TaskDetailPage-1ckxnGhw.js +4 -0
- package/dist/web/static/assets/TaskDetailPage-1ckxnGhw.js.map +1 -0
- package/dist/web/static/assets/TasksHubPage-C2PLh3eg.js +6 -0
- package/dist/web/static/assets/TasksHubPage-C2PLh3eg.js.map +1 -0
- package/dist/web/static/assets/WorkplacePage-DHrp5VxS.js +2 -0
- package/dist/web/static/assets/WorkplacePage-DHrp5VxS.js.map +1 -0
- package/dist/web/static/assets/arco-DFQA6dO_.css +1 -0
- package/dist/web/static/assets/arco-DV6xCLhr.js +14 -0
- package/dist/web/static/assets/arco-DV6xCLhr.js.map +1 -0
- package/dist/web/static/assets/charts-BSV4cyC4.js +37 -0
- package/dist/web/static/assets/charts-BSV4cyC4.js.map +1 -0
- package/dist/web/static/assets/date-fns-sbWH3_uq.js +2 -0
- package/dist/web/static/assets/date-fns-sbWH3_uq.js.map +1 -0
- package/dist/web/static/assets/index-B_v_MKlb.css +1 -0
- package/dist/web/static/assets/index-DileOOE4.js +4 -0
- package/dist/web/static/assets/index-DileOOE4.js.map +1 -0
- package/dist/web/static/assets/lucide-CnlPQoG8.js +72 -0
- package/dist/web/static/assets/lucide-CnlPQoG8.js.map +1 -0
- package/dist/web/static/assets/markdown-CA7ePUts.js +30 -0
- package/dist/web/static/assets/markdown-CA7ePUts.js.map +1 -0
- package/dist/web/static/assets/outcome-BKGy9azt.js +2 -0
- package/dist/web/static/assets/outcome-BKGy9azt.js.map +1 -0
- package/dist/web/static/assets/query-CgCOpYWf.js +2 -0
- package/dist/web/static/assets/{query-C99w429o.js.map → query-CgCOpYWf.js.map} +1 -1
- package/dist/web/static/assets/{react-router-r79dBVy4.js → react-router-Cxmg8RuL.js} +3 -3
- package/dist/web/static/assets/{react-router-r79dBVy4.js.map → react-router-Cxmg8RuL.js.map} +1 -1
- package/dist/web/static/assets/react-vendor-tkvCrao7.js +57 -0
- package/dist/web/static/assets/react-vendor-tkvCrao7.js.map +1 -0
- package/dist/web/static/assets/syntax-highlighter-BDYycNja.js +6 -0
- package/dist/web/static/assets/syntax-highlighter-BDYycNja.js.map +1 -0
- package/dist/web/static/assets/useAgentStats-B-uTgqBd.js +2 -0
- package/dist/web/static/assets/useAgentStats-B-uTgqBd.js.map +1 -0
- package/dist/web/static/assets/useDecisions-D-G2Ft5T.js +2 -0
- package/dist/web/static/assets/useDecisions-D-G2Ft5T.js.map +1 -0
- package/dist/web/static/assets/useDistill-21dZkXlT.js +3 -0
- package/dist/web/static/assets/useDistill-21dZkXlT.js.map +1 -0
- package/dist/web/static/assets/useEffectiveProject-DQiyX54y.js +2 -0
- package/dist/web/static/assets/useEffectiveProject-DQiyX54y.js.map +1 -0
- package/dist/web/static/assets/useIssuesFeed-CFiyQkAL.js +2 -0
- package/dist/web/static/assets/useIssuesFeed-CFiyQkAL.js.map +1 -0
- package/dist/web/static/assets/useKbHits-xKXWgqh9.js +2 -0
- package/dist/web/static/assets/useKbHits-xKXWgqh9.js.map +1 -0
- package/dist/web/static/assets/useSkillStats-B5hbIwdf.js +2 -0
- package/dist/web/static/assets/useSkillStats-B5hbIwdf.js.map +1 -0
- package/dist/web/static/assets/vendor-DS-q4Eyc.js +36 -0
- package/dist/web/static/assets/vendor-DS-q4Eyc.js.map +1 -0
- package/dist/web/static/index.html +12 -8
- package/package.json +18 -5
- package/dist/core/ai/provider.d.ts +0 -63
- package/dist/core/ai/provider.d.ts.map +0 -1
- package/dist/core/ai/provider.js +0 -241
- package/dist/core/ai/provider.js.map +0 -1
- package/dist/core/ai/types.d.ts +0 -43
- package/dist/core/ai/types.d.ts.map +0 -1
- package/dist/core/ai/types.js +0 -5
- package/dist/core/ai/types.js.map +0 -1
- package/dist/core/storage/token-usage.d.ts +0 -36
- package/dist/core/storage/token-usage.d.ts.map +0 -1
- package/dist/core/storage/token-usage.js +0 -59
- package/dist/core/storage/token-usage.js.map +0 -1
- package/dist/core/utils/token-tracker.d.ts +0 -39
- package/dist/core/utils/token-tracker.d.ts.map +0 -1
- package/dist/core/utils/token-tracker.js +0 -69
- package/dist/core/utils/token-tracker.js.map +0 -1
- package/dist/skills/index.d.ts +0 -3
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js +0 -3
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/matcher.d.ts +0 -26
- package/dist/skills/matcher.d.ts.map +0 -1
- package/dist/skills/matcher.js +0 -113
- package/dist/skills/matcher.js.map +0 -1
- package/dist/skills/official/code-simplifier.md +0 -52
- package/dist/skills/official/find-skills.md +0 -142
- package/dist/skills/official/official-api-design.md +0 -30
- package/dist/skills/official/official-architecture-decision.md +0 -41
- package/dist/skills/official/official-bmad.md +0 -118
- package/dist/skills/official/official-db-schema-design.md +0 -34
- package/dist/skills/official/official-debug.md +0 -25
- package/dist/skills/official/official-doc-driven.md +0 -31
- package/dist/skills/official/official-harness-engineering.md +0 -108
- package/dist/skills/official/official-openspec.md +0 -89
- package/dist/skills/official/official-performance-optimization.md +0 -30
- package/dist/skills/official/official-pr-review.md +0 -35
- package/dist/skills/official/official-release-checklist.md +0 -30
- package/dist/skills/official/official-security-hardening.md +0 -32
- package/dist/skills/official/official-spec-driven-design.md +0 -31
- package/dist/skills/official/planning-with-files.md +0 -241
- package/dist/skills/official/ui-ux-pro-max.md +0 -105
- package/dist/skills/official/webapp-testing.md +0 -96
- package/dist/skills/official-skills.d.ts +0 -26
- package/dist/skills/official-skills.d.ts.map +0 -1
- package/dist/skills/official-skills.js +0 -74
- package/dist/skills/official-skills.js.map +0 -1
- package/dist/skills/semantic-matcher.d.ts +0 -60
- package/dist/skills/semantic-matcher.d.ts.map +0 -1
- package/dist/skills/semantic-matcher.js +0 -192
- package/dist/skills/semantic-matcher.js.map +0 -1
- package/dist/skills/upgrade-engine.d.ts +0 -93
- package/dist/skills/upgrade-engine.d.ts.map +0 -1
- package/dist/skills/upgrade-engine.js +0 -447
- package/dist/skills/upgrade-engine.js.map +0 -1
- package/dist/skills/upgrade-prompt.d.ts +0 -20
- package/dist/skills/upgrade-prompt.d.ts.map +0 -1
- package/dist/skills/upgrade-prompt.js +0 -75
- package/dist/skills/upgrade-prompt.js.map +0 -1
- package/dist/web/routes/ai.d.ts +0 -10
- package/dist/web/routes/ai.d.ts.map +0 -1
- package/dist/web/routes/ai.js +0 -186
- package/dist/web/routes/ai.js.map +0 -1
- package/dist/web/routes/token-usage.d.ts +0 -7
- package/dist/web/routes/token-usage.d.ts.map +0 -1
- package/dist/web/routes/token-usage.js +0 -18
- package/dist/web/routes/token-usage.js.map +0 -1
- package/dist/web/ssrf-guard.d.ts +0 -35
- package/dist/web/ssrf-guard.d.ts.map +0 -1
- package/dist/web/ssrf-guard.js +0 -93
- package/dist/web/ssrf-guard.js.map +0 -1
- package/dist/web/static/assets/AIConfig-CdDWzJyO.js +0 -2
- package/dist/web/static/assets/AIConfig-CdDWzJyO.js.map +0 -1
- package/dist/web/static/assets/Dashboard-CoEmmIDt.js +0 -2
- package/dist/web/static/assets/Dashboard-CoEmmIDt.js.map +0 -1
- package/dist/web/static/assets/Drawer-DdRTzlLB.js +0 -2
- package/dist/web/static/assets/Drawer-DdRTzlLB.js.map +0 -1
- package/dist/web/static/assets/Events-DrIq1SUS.js +0 -2
- package/dist/web/static/assets/Events-DrIq1SUS.js.map +0 -1
- package/dist/web/static/assets/Reports-DFBM3MDK.js +0 -2
- package/dist/web/static/assets/Reports-DFBM3MDK.js.map +0 -1
- package/dist/web/static/assets/SearchInput-qCj_jAcf.js +0 -2
- package/dist/web/static/assets/SearchInput-qCj_jAcf.js.map +0 -1
- package/dist/web/static/assets/SessionDetail-CCzwdoT7.js +0 -2
- package/dist/web/static/assets/SessionDetail-CCzwdoT7.js.map +0 -1
- package/dist/web/static/assets/Sessions-FfLYkAw9.js +0 -2
- package/dist/web/static/assets/Sessions-FfLYkAw9.js.map +0 -1
- package/dist/web/static/assets/Skills-C8Gvs3Qa.js +0 -2
- package/dist/web/static/assets/Skills-C8Gvs3Qa.js.map +0 -1
- package/dist/web/static/assets/TaskDetail-BS8pYhaR.js +0 -2
- package/dist/web/static/assets/TaskDetail-BS8pYhaR.js.map +0 -1
- package/dist/web/static/assets/Tasks-CyuhizG8.js +0 -2
- package/dist/web/static/assets/Tasks-CyuhizG8.js.map +0 -1
- package/dist/web/static/assets/charts-CLrM0_uM.js +0 -37
- package/dist/web/static/assets/charts-CLrM0_uM.js.map +0 -1
- package/dist/web/static/assets/date-fns-CZ_bHujz.js +0 -2
- package/dist/web/static/assets/date-fns-CZ_bHujz.js.map +0 -1
- package/dist/web/static/assets/export-L_VBD2p1.js +0 -4
- package/dist/web/static/assets/export-L_VBD2p1.js.map +0 -1
- package/dist/web/static/assets/index-CBX47X8l.js +0 -3
- package/dist/web/static/assets/index-CBX47X8l.js.map +0 -1
- package/dist/web/static/assets/index-DjIoMdoR.css +0 -1
- package/dist/web/static/assets/lucide-Bs_edTLa.js +0 -232
- package/dist/web/static/assets/lucide-Bs_edTLa.js.map +0 -1
- package/dist/web/static/assets/query-C99w429o.js +0 -2
- package/dist/web/static/assets/react-vendor-CSp-GLFF.js +0 -49
- package/dist/web/static/assets/react-vendor-CSp-GLFF.js.map +0 -1
- package/dist/web/static/assets/syntax-highlighter-44FakypI.js +0 -9
- package/dist/web/static/assets/syntax-highlighter-44FakypI.js.map +0 -1
- package/dist/web/static/assets/time-Bxuk0M-C.js +0 -2
- package/dist/web/static/assets/time-Bxuk0M-C.js.map +0 -1
- package/dist/web/static/assets/vendor-CMMjVdZs.js +0 -64
- package/dist/web/static/assets/vendor-CMMjVdZs.js.map +0 -1
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { randomUUID } from 'node:crypto';
|
|
12
12
|
import { z } from 'zod';
|
|
13
|
+
import { extractSpawnFields } from '../event-fields.js';
|
|
13
14
|
import { logger } from '../utils/logger.js';
|
|
15
|
+
import { encodeToolInput, decodeToolInput, encodeToolOutput, decodeToolOutput, } from './codec/tool-input-codec.js';
|
|
16
|
+
/**
|
|
17
|
+
* Per-row cap on backfilled `ai_response` text (spec 1446). Mirrors the
|
|
18
|
+
* event-parser MAX_PROMPT_CHARS magnitude (100 K chars) so a pathological
|
|
19
|
+
* violation window can't write a multi-MB string into one row.
|
|
20
|
+
*/
|
|
21
|
+
export const MAX_AI_RESPONSE_CHARS = 100 * 1024;
|
|
14
22
|
// Zod schema for runtime validation
|
|
15
23
|
const ForgeEventSchema = z.object({
|
|
16
24
|
event_id: z.string().uuid().optional(),
|
|
@@ -30,6 +38,10 @@ const ForgeEventSchema = z.object({
|
|
|
30
38
|
user_prompt: z.string().optional(),
|
|
31
39
|
ai_response: z.string().optional(),
|
|
32
40
|
});
|
|
41
|
+
// `tool_input` and `tool_output` are validated as permissive unions: legacy
|
|
42
|
+
// rows hold plain JSON text; new rows may hold either UTF-8 bytes (tiny-input
|
|
43
|
+
// skip) or gzip Buffer bytes. Zod can't usefully introspect binary, so we
|
|
44
|
+
// accept any Buffer/Uint8Array via `z.any()` and let the codec parse it.
|
|
33
45
|
const DatabaseRowSchema = z.object({
|
|
34
46
|
event_id: z.string(),
|
|
35
47
|
session_id: z.string(),
|
|
@@ -37,17 +49,39 @@ const DatabaseRowSchema = z.object({
|
|
|
37
49
|
timestamp: z.string(),
|
|
38
50
|
hook_type: z.string(),
|
|
39
51
|
tool_name: z.union([z.string(), z.null()]),
|
|
40
|
-
tool_input: z.union([z.string(), z.null()]),
|
|
41
|
-
tool_output
|
|
52
|
+
tool_input: z.union([z.string(), z.null(), z.any()]),
|
|
53
|
+
// tool_output is now codec-encoded for new rows (2026-05-26 perf PR).
|
|
54
|
+
// Legacy rows remain plain JSON text — magic-byte sniff handles both.
|
|
55
|
+
tool_output: z.union([z.string(), z.null(), z.any()]),
|
|
42
56
|
user_prompt: z.union([z.string(), z.null()]),
|
|
43
57
|
ai_response: z.union([z.string(), z.null()]),
|
|
44
58
|
});
|
|
59
|
+
// TODO (storage-perf follow-up, 2026-05-26): the remaining un-cached
|
|
60
|
+
// `this.db.prepare(...)` callsites in EventOperations are listed here so a
|
|
61
|
+
// future sweep can promote them to constructor-time Statement fields.
|
|
62
|
+
// Hot-path (writeEvent) is already cached below.
|
|
63
|
+
//
|
|
64
|
+
// - queryEvents (line ~167) — variable WHERE, harder to cache
|
|
65
|
+
// - queryEventsTimeline (line ~221)
|
|
66
|
+
// - countEvents (lines ~262, ~284) — variable WHERE
|
|
67
|
+
// - searchEvents (multiple)
|
|
68
|
+
// - all aggregate*/queryDistinct* analytics queries (~lines 480-635)
|
|
69
|
+
// - expireToolInputBatch / deleteEventsByCutoff (TTL sweep)
|
|
70
|
+
//
|
|
71
|
+
// Cached now: writeEvent INSERT (hottest — fires per event/day).
|
|
45
72
|
export class EventOperations {
|
|
46
73
|
db;
|
|
47
74
|
emitter;
|
|
75
|
+
writeEventStmt;
|
|
48
76
|
constructor(db, emitter) {
|
|
49
77
|
this.db = db;
|
|
50
78
|
this.emitter = emitter;
|
|
79
|
+
this.writeEventStmt = db.prepare(`
|
|
80
|
+
INSERT INTO events (event_id, session_id, project_path, timestamp, hook_type,
|
|
81
|
+
tool_name, tool_input, tool_output, user_prompt, ai_response,
|
|
82
|
+
decision_id, subagent_type, distilled)
|
|
83
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)
|
|
84
|
+
`);
|
|
51
85
|
}
|
|
52
86
|
writeEvent(event) {
|
|
53
87
|
// Runtime validation
|
|
@@ -59,13 +93,21 @@ export class EventOperations {
|
|
|
59
93
|
throw new Error(`Invalid event data: ${err instanceof Error ? err.message : String(err)}`);
|
|
60
94
|
}
|
|
61
95
|
const eventId = event.event_id || randomUUID();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
// decision c425f26f (spec 1544 § 1.2): extract decision_id + subagent_type
|
|
97
|
+
// into PLAINTEXT columns for Task/Agent spawn rows. CRITICAL: we read the
|
|
98
|
+
// STILL-DECODED `event.tool_input` (a JS object) HERE — BEFORE the codec
|
|
99
|
+
// encodes/gzip-compresses it below — and write the extracted strings as
|
|
100
|
+
// plain TEXT. These two columns NEVER flow through encodeToolInput / gzip
|
|
101
|
+
// (gzip one-way-door landmine). Non-spawn rows → both NULL.
|
|
102
|
+
const { decisionId, subagentType } = extractSpawnFields(event.tool_name, event.tool_input);
|
|
67
103
|
try {
|
|
68
|
-
|
|
104
|
+
// tool_input + tool_output flow through the gzip codec (encodeToolInput
|
|
105
|
+
// / encodeToolOutput). The codec returns null for null/undefined, a
|
|
106
|
+
// plain UTF-8 Buffer for payloads under TINY_INPUT_BYTES, and gzipped
|
|
107
|
+
// Buffer otherwise. better-sqlite3 binds Buffer as binary; SQLite
|
|
108
|
+
// stores it verbatim in the TEXT column. Read path uses
|
|
109
|
+
// decodeToolInput / decodeToolOutput (rowToEvent).
|
|
110
|
+
this.writeEventStmt.run(eventId, event.session_id, event.project_path, event.timestamp, event.hook_type, event.tool_name ?? null, encodeToolInput(event.tool_input), encodeToolOutput(event.tool_output), event.user_prompt ?? null, event.ai_response ?? null, decisionId, subagentType);
|
|
69
111
|
}
|
|
70
112
|
catch (err) {
|
|
71
113
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -88,6 +130,49 @@ export class EventOperations {
|
|
|
88
130
|
}
|
|
89
131
|
this.emitter.emit('event', { ...event, event_id: eventId });
|
|
90
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Backfill the `ai_response` column for one event row with PLAIN TEXT
|
|
135
|
+
* (spec 1446 / decision 0df5271f).
|
|
136
|
+
*
|
|
137
|
+
* CRITICAL: `ai_response` is a plain-text TEXT column and MUST NOT flow
|
|
138
|
+
* through the gzip codec (encodeToolOutput) — gzip-stored content is silently
|
|
139
|
+
* invisible to SQL LIKE / raw reads (project gzip landmine). We write the
|
|
140
|
+
* string verbatim so `getEventById(id).ai_response` reads back identically and
|
|
141
|
+
* `searchEvents`' LIKE on ai_response keeps working.
|
|
142
|
+
*
|
|
143
|
+
* Idempotent: re-callable, overwrites. Truncated to MAX_AI_RESPONSE_CHARS to
|
|
144
|
+
* bound a single row's size.
|
|
145
|
+
*/
|
|
146
|
+
updateEventAiResponse(eventId, text) {
|
|
147
|
+
if (!eventId)
|
|
148
|
+
return;
|
|
149
|
+
const truncated = text.length > MAX_AI_RESPONSE_CHARS
|
|
150
|
+
? text.slice(0, MAX_AI_RESPONSE_CHARS)
|
|
151
|
+
: text;
|
|
152
|
+
this.db
|
|
153
|
+
.prepare('UPDATE events SET ai_response = ? WHERE event_id = ?')
|
|
154
|
+
.run(truncated, eventId);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Inline-edit events (PostToolUse Edit/Write/NotebookEdit) for one session
|
|
158
|
+
* within an inclusive ISO time window, ascending by timestamp (spec 1446).
|
|
159
|
+
*
|
|
160
|
+
* Reads only tool_name / timestamp (plain columns) so it never touches the
|
|
161
|
+
* gzip tool_input blob. Used by the Stop handler to locate the earliest
|
|
162
|
+
* inline-edit row of a violation window to backfill its ai_response.
|
|
163
|
+
*/
|
|
164
|
+
queryInlineEditEvents(opts) {
|
|
165
|
+
const rows = this.db
|
|
166
|
+
.prepare(`SELECT * FROM events
|
|
167
|
+
WHERE session_id = ?
|
|
168
|
+
AND hook_type = 'PostToolUse'
|
|
169
|
+
AND tool_name IN ('Edit', 'Write', 'NotebookEdit')
|
|
170
|
+
AND timestamp >= ?
|
|
171
|
+
AND timestamp <= ?
|
|
172
|
+
ORDER BY timestamp ASC`)
|
|
173
|
+
.all(opts.session_id, opts.since_iso, opts.until_iso);
|
|
174
|
+
return rows.map((row) => this.rowToEvent(row));
|
|
175
|
+
}
|
|
91
176
|
queryEvents(filter) {
|
|
92
177
|
const conditions = [];
|
|
93
178
|
const params = [];
|
|
@@ -103,6 +188,10 @@ export class EventOperations {
|
|
|
103
188
|
conditions.push('hook_type = ?');
|
|
104
189
|
params.push(filter.hook_type);
|
|
105
190
|
}
|
|
191
|
+
if (filter.since !== undefined) {
|
|
192
|
+
conditions.push('timestamp >= ?');
|
|
193
|
+
params.push(filter.since);
|
|
194
|
+
}
|
|
106
195
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
107
196
|
const limit = filter.limit ?? 1000;
|
|
108
197
|
const offset = filter.offset ?? 0;
|
|
@@ -111,6 +200,79 @@ export class EventOperations {
|
|
|
111
200
|
const rows = this.db.prepare(sql).all(...params);
|
|
112
201
|
return rows.map((row) => this.rowToEvent(row));
|
|
113
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Fetch a single event by its primary key (`event_id`), or null when absent.
|
|
205
|
+
*
|
|
206
|
+
* Unlike {@link queryEvents}, this does a point lookup (`WHERE event_id = ?`)
|
|
207
|
+
* so it never depends on a `limit` window — the pipeline drawer's
|
|
208
|
+
* `?event_id=<id>` branch needs to locate an arbitrarily-old prompt that may
|
|
209
|
+
* be far beyond the most-recent-N set the default rollup scans.
|
|
210
|
+
*/
|
|
211
|
+
getEventById(eventId) {
|
|
212
|
+
if (!eventId)
|
|
213
|
+
return null;
|
|
214
|
+
const row = this.db
|
|
215
|
+
.prepare('SELECT * FROM events WHERE event_id = ? LIMIT 1')
|
|
216
|
+
.get(eventId);
|
|
217
|
+
return row ? this.rowToEvent(row) : null;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Slim variant of queryEvents used by `/api/insights/timeline` (audit F5).
|
|
221
|
+
*
|
|
222
|
+
* Drops `tool_output` and `ai_response` from the SELECT — those columns
|
|
223
|
+
* dominate row size on tool-heavy sessions (PostToolUse rows can carry
|
|
224
|
+
* MB-scale JSON each), so omitting them cuts both transport bytes and the
|
|
225
|
+
* per-row JSON.parse cost handled inside this method.
|
|
226
|
+
*
|
|
227
|
+
* Adds an optional `before_ts` cursor (exclusive, `timestamp < ?`) for
|
|
228
|
+
* descending pagination — keeps the existing `limit` semantics and is
|
|
229
|
+
* additive so callers that don't pass it behave exactly like before.
|
|
230
|
+
*
|
|
231
|
+
* NOT a generic queryEvents overload: dropping output columns would
|
|
232
|
+
* silently break any caller that relies on `tool_output` / `ai_response`.
|
|
233
|
+
*/
|
|
234
|
+
queryEventsTimeline(filter) {
|
|
235
|
+
const conditions = ['session_id = ?'];
|
|
236
|
+
const params = [filter.session_id];
|
|
237
|
+
if (filter.hook_type) {
|
|
238
|
+
conditions.push('hook_type = ?');
|
|
239
|
+
params.push(filter.hook_type);
|
|
240
|
+
}
|
|
241
|
+
if (filter.before_ts) {
|
|
242
|
+
conditions.push('timestamp < ?');
|
|
243
|
+
params.push(filter.before_ts);
|
|
244
|
+
}
|
|
245
|
+
const limit = Math.min(Math.max(filter.limit ?? 500, 1), 2000);
|
|
246
|
+
const sql = `SELECT event_id, session_id, project_path, timestamp, hook_type,
|
|
247
|
+
tool_name, tool_input, user_prompt
|
|
248
|
+
FROM events
|
|
249
|
+
WHERE ${conditions.join(' AND ')}
|
|
250
|
+
ORDER BY timestamp DESC
|
|
251
|
+
LIMIT ?`;
|
|
252
|
+
params.push(limit);
|
|
253
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
254
|
+
return rows.map((row) => {
|
|
255
|
+
let toolInput;
|
|
256
|
+
if (row.tool_input) {
|
|
257
|
+
try {
|
|
258
|
+
toolInput = decodeToolInput(row.tool_input);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
toolInput = undefined;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
event_id: row.event_id,
|
|
266
|
+
session_id: row.session_id,
|
|
267
|
+
project_path: row.project_path,
|
|
268
|
+
timestamp: row.timestamp,
|
|
269
|
+
hook_type: row.hook_type,
|
|
270
|
+
tool_name: row.tool_name ?? undefined,
|
|
271
|
+
tool_input: toolInput,
|
|
272
|
+
user_prompt: row.user_prompt ?? undefined,
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
}
|
|
114
276
|
countEvents(filter) {
|
|
115
277
|
if (!filter || (!filter.session_id && !filter.project_path && !filter.hook_type)) {
|
|
116
278
|
const result = this.db.prepare('SELECT COUNT(*) as count FROM events').get();
|
|
@@ -140,8 +302,23 @@ export class EventOperations {
|
|
|
140
302
|
* Reduces data transfer by filtering events before sending to client.
|
|
141
303
|
*/
|
|
142
304
|
searchEvents(filter) {
|
|
143
|
-
const conditions = [
|
|
144
|
-
const params = [
|
|
305
|
+
const conditions = [];
|
|
306
|
+
const params = [];
|
|
307
|
+
if (filter.session_id) {
|
|
308
|
+
conditions.push('session_id = ?');
|
|
309
|
+
params.push(filter.session_id);
|
|
310
|
+
}
|
|
311
|
+
// gzip codec: `tool_input` is gzip bytes for new rows so a raw LIKE on
|
|
312
|
+
// it can never match. Strategy:
|
|
313
|
+
// 1) SQL pre-filter: LIKE on `user_prompt` / `ai_response` / `tool_input`
|
|
314
|
+
// gets the plain-text hits (covers legacy 42k rows + the two plain
|
|
315
|
+
// columns on all rows).
|
|
316
|
+
// 2) When `filter.query` is set, also fetch rows that DIDN'T match the
|
|
317
|
+
// LIKE but have a gzipped `tool_input`, decode them in JS, and union
|
|
318
|
+
// in the ones whose decoded content matches. Bounded by `limit` so
|
|
319
|
+
// we don't decompress an arbitrary scan.
|
|
320
|
+
// The two-phase union preserves the pre-codec behaviour exactly (callers
|
|
321
|
+
// get the same set of events back).
|
|
145
322
|
if (filter.query) {
|
|
146
323
|
conditions.push('(user_prompt LIKE ? OR ai_response LIKE ? OR tool_input LIKE ?)');
|
|
147
324
|
const pattern = `%${filter.query}%`;
|
|
@@ -157,10 +334,68 @@ export class EventOperations {
|
|
|
157
334
|
}
|
|
158
335
|
const limit = filter.limit ?? 100;
|
|
159
336
|
const offset = filter.offset ?? 0;
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
337
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
338
|
+
const sql = `SELECT * FROM events ${where} ORDER BY timestamp DESC LIMIT ? OFFSET ?`;
|
|
339
|
+
const sqlParams = [...params, limit, offset];
|
|
340
|
+
const rows = this.db.prepare(sql).all(...sqlParams);
|
|
341
|
+
const sqlMatches = rows.map((row) => this.rowToEvent(row));
|
|
342
|
+
// Phase 2: when query is set, look for gzipped-row tool_input matches that
|
|
343
|
+
// SQL LIKE necessarily missed. Scope: same session/tool/hook filters as
|
|
344
|
+
// the SQL above, but restricted to rows where tool_input is gzipped (i.e.
|
|
345
|
+
// length > 0 AND it didn't match the LIKE). We bound the scan by `limit`.
|
|
346
|
+
if (filter.query) {
|
|
347
|
+
const codecConditions = ['tool_input IS NOT NULL'];
|
|
348
|
+
const codecParams = [];
|
|
349
|
+
if (filter.session_id) {
|
|
350
|
+
codecConditions.push('session_id = ?');
|
|
351
|
+
codecParams.push(filter.session_id);
|
|
352
|
+
}
|
|
353
|
+
if (filter.tool_name) {
|
|
354
|
+
codecConditions.push('tool_name = ?');
|
|
355
|
+
codecParams.push(filter.tool_name);
|
|
356
|
+
}
|
|
357
|
+
if (filter.hook_type) {
|
|
358
|
+
codecConditions.push('hook_type = ?');
|
|
359
|
+
codecParams.push(filter.hook_type);
|
|
360
|
+
}
|
|
361
|
+
// Skip rows that already matched SQL LIKE — they're already in sqlMatches.
|
|
362
|
+
// Cheaper to scan a slightly bigger candidate set and de-dup by event_id.
|
|
363
|
+
const scanLimit = Math.min(limit * 5, 2000);
|
|
364
|
+
const codecSql = `SELECT * FROM events WHERE ${codecConditions.join(' AND ')} ORDER BY timestamp DESC LIMIT ?`;
|
|
365
|
+
const candidateRows = this.db
|
|
366
|
+
.prepare(codecSql)
|
|
367
|
+
.all(...codecParams, scanLimit);
|
|
368
|
+
const queryLower = filter.query.toLowerCase();
|
|
369
|
+
const seenIds = new Set(sqlMatches.map(e => e.event_id));
|
|
370
|
+
const extraMatches = [];
|
|
371
|
+
for (const raw of candidateRows) {
|
|
372
|
+
const id = String(raw.event_id);
|
|
373
|
+
if (seenIds.has(id))
|
|
374
|
+
continue;
|
|
375
|
+
// Only inspect gzipped rows — plain rows already had a chance via LIKE.
|
|
376
|
+
const ti = raw.tool_input;
|
|
377
|
+
const isBinary = Buffer.isBuffer(ti) || ArrayBuffer.isView(ti);
|
|
378
|
+
if (!isBinary)
|
|
379
|
+
continue;
|
|
380
|
+
try {
|
|
381
|
+
const decoded = decodeToolInput(ti);
|
|
382
|
+
const haystack = JSON.stringify(decoded ?? '').toLowerCase();
|
|
383
|
+
if (haystack.includes(queryLower)) {
|
|
384
|
+
extraMatches.push(this.rowToEvent(raw));
|
|
385
|
+
seenIds.add(id);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
// Skip malformed gzip rows silently — they're already broken.
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (extraMatches.length === 0)
|
|
393
|
+
return sqlMatches;
|
|
394
|
+
const combined = [...sqlMatches, ...extraMatches];
|
|
395
|
+
combined.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
|
|
396
|
+
return combined.slice(0, limit);
|
|
397
|
+
}
|
|
398
|
+
return sqlMatches;
|
|
164
399
|
}
|
|
165
400
|
// ── H2: 聚合 / 计数方法(消除 routes / handlers / analytics 越权 SQL)─────
|
|
166
401
|
/** Total event row count. */
|
|
@@ -211,12 +446,290 @@ export class EventOperations {
|
|
|
211
446
|
return this.db.prepare(`SELECT hook_type, COUNT(*) as count FROM events
|
|
212
447
|
WHERE session_id = ? GROUP BY hook_type`).all(session_id);
|
|
213
448
|
}
|
|
214
|
-
/**
|
|
449
|
+
/**
|
|
450
|
+
* Agent/Task subagent_type distribution for a single session.
|
|
451
|
+
*
|
|
452
|
+
* Was a single SQL with `json_extract(tool_input, '$.subagent_type')` —
|
|
453
|
+
* incompatible with the gzip codec. Refactored to: SELECT raw tool_input
|
|
454
|
+
* for matching events, JS-decode each row via the codec, bucket in JS.
|
|
455
|
+
* Per-session scan is tiny (≤ a few hundred Task/Agent rows in practice).
|
|
456
|
+
*/
|
|
215
457
|
aggregateAgentTypeBySession(session_id) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
458
|
+
const rows = this.db.prepare(`SELECT tool_input FROM events
|
|
459
|
+
WHERE session_id = ? AND tool_name IN ('Agent', 'Task') AND tool_input IS NOT NULL`).all(session_id);
|
|
460
|
+
const counts = new Map();
|
|
461
|
+
for (const row of rows) {
|
|
462
|
+
let agentType = null;
|
|
463
|
+
try {
|
|
464
|
+
const decoded = decodeToolInput(row.tool_input);
|
|
465
|
+
if (decoded && typeof decoded === 'object' && !Array.isArray(decoded)) {
|
|
466
|
+
const v = decoded.subagent_type;
|
|
467
|
+
agentType = typeof v === 'string' ? v : null;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
// Malformed row — count under null bucket (matches SQL's NULL semantics).
|
|
472
|
+
}
|
|
473
|
+
counts.set(agentType, (counts.get(agentType) ?? 0) + 1);
|
|
474
|
+
}
|
|
475
|
+
return Array.from(counts.entries()).map(([agent_type, count]) => ({ agent_type, count }));
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Cross-task agent-delegation aggregation, grouped by subagent_type
|
|
479
|
+
* (Arco Phase 2d — Agent 委托 list/detail, decision 29688066).
|
|
480
|
+
*
|
|
481
|
+
* Pairs Pre/Post `Task`/`Agent` tool events within [since, until) per
|
|
482
|
+
* session (same one-post-per-pre consumption rule the task-timeline route
|
|
483
|
+
* uses) to derive each delegation's duration. Then LEFT JOINs the *task*
|
|
484
|
+
* that the spawn fell inside (same session, spawn timestamp ∈ [task.start,
|
|
485
|
+
* task.end]) to attribute an outcome (success / partial / failed / other /
|
|
486
|
+
* unrated) per spawn. Aggregates per subagent_type:
|
|
487
|
+
* - delegations : paired spawn count (one per Pre)
|
|
488
|
+
* - success/partial/failed : containing-task outcome buckets
|
|
489
|
+
* - unrated : spawns whose task has no outcome (active / null)
|
|
490
|
+
* - avg_duration_ms : mean of paired (or task_end-fallback) durations
|
|
491
|
+
* - last_ts : most-recent spawn epoch-ms
|
|
492
|
+
* - recent[] : newest `recentLimit` spawns (task_id / title /
|
|
493
|
+
* outcome / duration_ms / ts / session_id)
|
|
494
|
+
*
|
|
495
|
+
* gzip note: `subagent_type` lives in the gzip `tool_input` blob, so we
|
|
496
|
+
* decode each Task/Agent row in JS (same as aggregateAgentTypeBySession).
|
|
497
|
+
* Window-scoped + Task/Agent-only keeps the scan small.
|
|
498
|
+
*/
|
|
499
|
+
aggregateAgentSpawns(opts) {
|
|
500
|
+
const recentLimit = opts.recentLimit ?? 5;
|
|
501
|
+
const conditions = ["timestamp >= ?", "tool_name IN ('Task','Agent')"];
|
|
502
|
+
const params = [opts.since];
|
|
503
|
+
if (opts.until !== undefined) {
|
|
504
|
+
conditions.push('timestamp < ?');
|
|
505
|
+
params.push(opts.until);
|
|
506
|
+
}
|
|
507
|
+
// Additive project filter (decision dd79010a): scope the spawn scan to one
|
|
508
|
+
// project's events. Omit (or '') → all projects (legacy back-compat with
|
|
509
|
+
// cf agent retro / callers that never pass it). events.project_path is a
|
|
510
|
+
// plaintext TEXT column (NOT gzip), so a direct equality predicate is safe.
|
|
511
|
+
if (opts.projectPath) {
|
|
512
|
+
conditions.push('project_path = ?');
|
|
513
|
+
params.push(opts.projectPath);
|
|
514
|
+
}
|
|
515
|
+
const rows = this.db.prepare(`SELECT event_id, session_id, timestamp, hook_type, tool_input
|
|
516
|
+
FROM events
|
|
517
|
+
WHERE ${conditions.join(' AND ')}
|
|
518
|
+
ORDER BY timestamp ASC`).all(...params);
|
|
519
|
+
const spawns = [];
|
|
520
|
+
// Pre/Post pairing per session (mirror task-timeline's consume-as-paired).
|
|
521
|
+
const bySession = new Map();
|
|
522
|
+
for (const r of rows) {
|
|
523
|
+
const arr = bySession.get(r.session_id) ?? [];
|
|
524
|
+
arr.push(r);
|
|
525
|
+
bySession.set(r.session_id, arr);
|
|
526
|
+
}
|
|
527
|
+
const decodeAgent = (ti) => {
|
|
528
|
+
try {
|
|
529
|
+
const decoded = decodeToolInput(ti);
|
|
530
|
+
if (decoded && typeof decoded === 'object' && !Array.isArray(decoded)) {
|
|
531
|
+
const v = decoded.subagent_type;
|
|
532
|
+
return typeof v === 'string' && v.length > 0 ? v : null;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch {
|
|
536
|
+
/* malformed — skip */
|
|
537
|
+
}
|
|
538
|
+
return null;
|
|
539
|
+
};
|
|
540
|
+
for (const sessionRows of bySession.values()) {
|
|
541
|
+
const pres = sessionRows.filter((e) => e.hook_type === 'PreToolUse');
|
|
542
|
+
const posts = sessionRows.filter((e) => e.hook_type === 'PostToolUse');
|
|
543
|
+
const consumed = new Set();
|
|
544
|
+
for (const pre of pres) {
|
|
545
|
+
const agent = decodeAgent(pre.tool_input);
|
|
546
|
+
if (!agent)
|
|
547
|
+
continue; // built-in calls without subagent_type → skip
|
|
548
|
+
const preMs = new Date(pre.timestamp).getTime();
|
|
549
|
+
const post = posts.find((p) => {
|
|
550
|
+
const key = p.event_id ?? p.timestamp;
|
|
551
|
+
if (consumed.has(key))
|
|
552
|
+
return false;
|
|
553
|
+
if (new Date(p.timestamp).getTime() < preMs)
|
|
554
|
+
return false;
|
|
555
|
+
const pAgent = decodeAgent(p.tool_input);
|
|
556
|
+
return pAgent === null || pAgent === agent;
|
|
557
|
+
});
|
|
558
|
+
let durationMs = null;
|
|
559
|
+
if (post) {
|
|
560
|
+
consumed.add(post.event_id ?? post.timestamp);
|
|
561
|
+
durationMs = new Date(post.timestamp).getTime() - preMs;
|
|
562
|
+
if (durationMs < 0)
|
|
563
|
+
durationMs = null;
|
|
564
|
+
}
|
|
565
|
+
spawns.push({ agent, session_id: pre.session_id, ts: preMs, duration_ms: durationMs });
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (spawns.length === 0)
|
|
569
|
+
return [];
|
|
570
|
+
// Attribute each spawn to the containing task (same session, ts in window).
|
|
571
|
+
// Load candidate tasks once per touched session.
|
|
572
|
+
const taskStmt = this.db.prepare(`SELECT id, title, start_time, end_time, outcome
|
|
573
|
+
FROM tasks WHERE session_id = ? ORDER BY start_time ASC`);
|
|
574
|
+
const tasksBySession = new Map();
|
|
575
|
+
const taskFor = (sessionId, ts) => {
|
|
576
|
+
let cand = tasksBySession.get(sessionId);
|
|
577
|
+
if (!cand) {
|
|
578
|
+
const trows = taskStmt.all(sessionId);
|
|
579
|
+
cand = trows.map((t) => ({
|
|
580
|
+
id: t.id,
|
|
581
|
+
title: t.title,
|
|
582
|
+
startMs: new Date(t.start_time).getTime(),
|
|
583
|
+
endMs: t.end_time ? new Date(t.end_time).getTime() : null,
|
|
584
|
+
outcome: t.outcome,
|
|
585
|
+
}));
|
|
586
|
+
tasksBySession.set(sessionId, cand);
|
|
587
|
+
}
|
|
588
|
+
// newest task whose [start, end] (open-ended end → now) contains ts
|
|
589
|
+
let best = null;
|
|
590
|
+
for (const t of cand) {
|
|
591
|
+
if (ts < t.startMs)
|
|
592
|
+
continue;
|
|
593
|
+
if (t.endMs !== null && ts > t.endMs)
|
|
594
|
+
continue;
|
|
595
|
+
if (!best || t.startMs > best.startMs)
|
|
596
|
+
best = t;
|
|
597
|
+
}
|
|
598
|
+
return best;
|
|
599
|
+
};
|
|
600
|
+
const buckets = new Map();
|
|
601
|
+
for (const s of spawns) {
|
|
602
|
+
let b = buckets.get(s.agent);
|
|
603
|
+
if (!b) {
|
|
604
|
+
b = { agent: s.agent, delegations: 0, success: 0, partial: 0, failed: 0, unrated: 0, durSum: 0, durCount: 0, last_ts: 0, recent: [] };
|
|
605
|
+
buckets.set(s.agent, b);
|
|
606
|
+
}
|
|
607
|
+
b.delegations++;
|
|
608
|
+
const task = taskFor(s.session_id, s.ts);
|
|
609
|
+
const outcome = task?.outcome ?? null;
|
|
610
|
+
if (outcome === 'success')
|
|
611
|
+
b.success++;
|
|
612
|
+
else if (outcome === 'partial')
|
|
613
|
+
b.partial++;
|
|
614
|
+
else if (outcome === 'failed')
|
|
615
|
+
b.failed++;
|
|
616
|
+
else
|
|
617
|
+
b.unrated++;
|
|
618
|
+
if (s.duration_ms !== null) {
|
|
619
|
+
b.durSum += s.duration_ms;
|
|
620
|
+
b.durCount++;
|
|
621
|
+
}
|
|
622
|
+
if (s.ts > b.last_ts)
|
|
623
|
+
b.last_ts = s.ts;
|
|
624
|
+
b.recent.push({ task_id: task?.id ?? null, title: task?.title ?? null, outcome, duration_ms: s.duration_ms, ts: s.ts, session_id: s.session_id });
|
|
625
|
+
}
|
|
626
|
+
return Array.from(buckets.values())
|
|
627
|
+
.map((b) => ({
|
|
628
|
+
agent: b.agent,
|
|
629
|
+
delegations: b.delegations,
|
|
630
|
+
success: b.success,
|
|
631
|
+
partial: b.partial,
|
|
632
|
+
failed: b.failed,
|
|
633
|
+
unrated: b.unrated,
|
|
634
|
+
avg_duration_ms: b.durCount > 0 ? Math.round(b.durSum / b.durCount) : null,
|
|
635
|
+
last_ts: b.last_ts,
|
|
636
|
+
recent: b.recent.sort((a, c) => c.ts - a.ts).slice(0, recentLimit),
|
|
637
|
+
}))
|
|
638
|
+
.sort((a, b) => b.delegations - a.delegations || a.agent.localeCompare(b.agent));
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Cross-task workflow spawn aggregation, grouped by decision_id (decision
|
|
642
|
+
* c425f26f, spec 1544 § 1.4).
|
|
643
|
+
*
|
|
644
|
+
* Returns every Task/Agent spawn event (both Pre and Post hooks) that carries
|
|
645
|
+
* the given `decision_id` in its PLAINTEXT `decision_id` column — across ALL
|
|
646
|
+
* tasks that share that decision (the whole logical workflow), ordered by
|
|
647
|
+
* timestamp ASC. This is the read primitive the timeline route uses to refill
|
|
648
|
+
* the implement/verify segments that the single-task window misses when a
|
|
649
|
+
* workflow is fragmented across per-prompt tasks.
|
|
650
|
+
*
|
|
651
|
+
* Key design points (spec § 1.4 / R5):
|
|
652
|
+
* - Filters STRICTLY on the spawn row's own `decision_id` column — NEVER
|
|
653
|
+
* groups by whole task — so a task that mixes two decision_ids does not
|
|
654
|
+
* cross-contaminate (R5).
|
|
655
|
+
* - `subagent_type` is read from the new PLAINTEXT column (no gzip decode).
|
|
656
|
+
* - `task_id` is attributed via LEFT JOIN task_events (precise, user
|
|
657
|
+
* ruling #2): the task each spawn event was linked into. NULL when the
|
|
658
|
+
* spawn was never linked to a task.
|
|
659
|
+
* - `task_count` = distinct non-null task_ids = the "跨 N 轮工作流" N.
|
|
660
|
+
*
|
|
661
|
+
* gzip note: reads only plaintext columns + the `prompt`/`tool_output` via the
|
|
662
|
+
* codec for previews. Walks O(10) spawns per workflow — well under the <200ms
|
|
663
|
+
* timeline budget; the idx_events_decision_spawn covering index serves the WHERE.
|
|
664
|
+
*/
|
|
665
|
+
queryWorkflowSpawnsByDecisionId(decisionId) {
|
|
666
|
+
if (!decisionId)
|
|
667
|
+
return { spawns: [], task_count: 0 };
|
|
668
|
+
const rows = this.db.prepare(`SELECT e.event_id, e.session_id, e.timestamp, e.hook_type, e.subagent_type,
|
|
669
|
+
e.tool_input, e.tool_output, te.task_id AS task_id
|
|
670
|
+
FROM events e
|
|
671
|
+
LEFT JOIN task_events te ON te.event_id = e.event_id
|
|
672
|
+
WHERE e.decision_id = ?
|
|
673
|
+
AND e.tool_name IN ('Task','Agent')
|
|
674
|
+
AND e.hook_type IN ('PreToolUse','PostToolUse')
|
|
675
|
+
ORDER BY e.timestamp ASC`).all(decisionId);
|
|
676
|
+
const taskIds = new Set();
|
|
677
|
+
const spawns = rows.map((row) => {
|
|
678
|
+
if (row.task_id)
|
|
679
|
+
taskIds.add(row.task_id);
|
|
680
|
+
let toolInput;
|
|
681
|
+
if (row.tool_input) {
|
|
682
|
+
try {
|
|
683
|
+
toolInput = decodeToolInput(row.tool_input);
|
|
684
|
+
}
|
|
685
|
+
catch {
|
|
686
|
+
toolInput = undefined;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
let toolOutput;
|
|
690
|
+
if (row.tool_output) {
|
|
691
|
+
try {
|
|
692
|
+
toolOutput = decodeToolOutput(row.tool_output);
|
|
693
|
+
}
|
|
694
|
+
catch {
|
|
695
|
+
toolOutput = undefined;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
event_id: row.event_id,
|
|
700
|
+
session_id: row.session_id,
|
|
701
|
+
task_id: row.task_id ?? null,
|
|
702
|
+
timestamp: row.timestamp,
|
|
703
|
+
hook_type: row.hook_type,
|
|
704
|
+
subagent_type: row.subagent_type,
|
|
705
|
+
tool_input: toolInput,
|
|
706
|
+
tool_output: toolOutput,
|
|
707
|
+
};
|
|
708
|
+
});
|
|
709
|
+
return { spawns, task_count: taskIds.size };
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Resolve the decision_id that a single task belongs to (decision c425f26f,
|
|
713
|
+
* spec 1544 § 1.5). Reads the PLAINTEXT `decision_id` column off the task's
|
|
714
|
+
* own spawn rows (linked via task_events) — no gzip decode. Returns the most
|
|
715
|
+
* common non-null decision_id among the task's spawns (a task occasionally
|
|
716
|
+
* mixes two decision_ids — R5 — so we pick the dominant one as the task's
|
|
717
|
+
* "home" workflow; the aggregation query itself still filters strictly per
|
|
718
|
+
* spawn row, so a minority decision_id is not lost). NULL when the task has no
|
|
719
|
+
* spawn carrying a decision_id (e.g. the magic comment was omitted).
|
|
720
|
+
*/
|
|
721
|
+
queryTaskDecisionId(taskId) {
|
|
722
|
+
const rows = this.db.prepare(`SELECT e.decision_id AS decision_id, COUNT(*) AS n
|
|
723
|
+
FROM events e
|
|
724
|
+
JOIN task_events te ON te.event_id = e.event_id
|
|
725
|
+
WHERE te.task_id = ?
|
|
726
|
+
AND e.tool_name IN ('Task','Agent')
|
|
727
|
+
AND e.hook_type = 'PreToolUse'
|
|
728
|
+
AND e.decision_id IS NOT NULL
|
|
729
|
+
GROUP BY e.decision_id
|
|
730
|
+
ORDER BY n DESC, e.decision_id ASC
|
|
731
|
+
LIMIT 1`).get(taskId);
|
|
732
|
+
return rows?.decision_id ?? null;
|
|
220
733
|
}
|
|
221
734
|
/** Tool usage distribution for a single session (non-null tool_name only). */
|
|
222
735
|
aggregateToolUsageBySession(session_id) {
|
|
@@ -256,34 +769,76 @@ export class EventOperations {
|
|
|
256
769
|
AND project_path IS NOT NULL AND project_path != ''`).all(opts.since, opts.until);
|
|
257
770
|
return rows.map(r => r.project_path);
|
|
258
771
|
}
|
|
772
|
+
/**
|
|
773
|
+
* Outcome classifier (spec 1100 v2): count a SESSION's Edit/Write intent
|
|
774
|
+
* events. Reads only `tool_name` (never the gzip `tool_input`), so it is
|
|
775
|
+
* always correct. Drives the session-level `edit_intent_count` signal
|
|
776
|
+
* (>0 → success, ==0 → answered). PreToolUse only, so a single logical edit
|
|
777
|
+
* (Pre+Post) counts once.
|
|
778
|
+
*/
|
|
779
|
+
countEditIntentEventsBySession(sessionId) {
|
|
780
|
+
const row = this.db.prepare(`SELECT COUNT(*) AS n FROM events
|
|
781
|
+
WHERE session_id = ?
|
|
782
|
+
AND hook_type = 'PreToolUse'
|
|
783
|
+
AND tool_name IN ('Edit', 'Write', 'MultiEdit', 'NotebookEdit')`).get(sessionId);
|
|
784
|
+
return row?.n ?? 0;
|
|
785
|
+
}
|
|
259
786
|
/**
|
|
260
787
|
* PostToolUse failure rate within [since, until).
|
|
261
788
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
789
|
+
* Was three SQL `LIKE` branches on `tool_output` — incompatible with the gzip
|
|
790
|
+
* codec: any tool_output >= TINY_INPUT_BYTES is stored as gzip bytes, so the
|
|
791
|
+
* LIKE could never match and failures buried in large (stack-trace) outputs
|
|
792
|
+
* were silently dropped, deflating the weekly-report failure rate. Refactored
|
|
793
|
+
* to "decode at read time": SELECT raw tool_output for the PostToolUse rows,
|
|
794
|
+
* `decodeToolOutput` each via the codec (transparently handles gzip Buffer,
|
|
795
|
+
* tiny-UTF-8 Buffer, and legacy plain text — `JSON.parse` fallback covers
|
|
796
|
+
* pre-codec plain rows), then apply the same three-marker heuristic in JS.
|
|
797
|
+
* Same pattern as `aggregateAgentTypeBySession` (:483).
|
|
798
|
+
*
|
|
799
|
+
* Failure markers (semantically equivalent to the original LIKE branches):
|
|
800
|
+
* - top-level `error` key present (was `'%"error"%'`)
|
|
801
|
+
* - `is_error === true` (was `'%"is_error":true%'`)
|
|
802
|
+
* - `isError === true` (was `'%"isError":true%'`)
|
|
803
|
+
*
|
|
804
|
+
* Non-hot path (weekly-report generation, user-triggered), so the per-row
|
|
805
|
+
* decode cost is acceptable.
|
|
267
806
|
*/
|
|
268
807
|
aggregateToolFailureRate(opts) {
|
|
269
|
-
const
|
|
808
|
+
const rows = this.db.prepare(`SELECT tool_output FROM events
|
|
270
809
|
WHERE timestamp >= ? AND timestamp < ?
|
|
271
|
-
AND hook_type = 'PostToolUse'`).
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
810
|
+
AND hook_type = 'PostToolUse'`).all(opts.since, opts.until);
|
|
811
|
+
let failed = 0;
|
|
812
|
+
for (const row of rows) {
|
|
813
|
+
if (row.tool_output === null || row.tool_output === undefined)
|
|
814
|
+
continue;
|
|
815
|
+
let decoded;
|
|
816
|
+
try {
|
|
817
|
+
decoded = decodeToolOutput(row.tool_output);
|
|
818
|
+
}
|
|
819
|
+
catch {
|
|
820
|
+
// Undecodable row — can't inspect; treat as non-failure. Matches the
|
|
821
|
+
// old LIKE behaviour where a malformed gzip row never matched.
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
if (isFailureToolOutput(decoded))
|
|
825
|
+
failed++;
|
|
826
|
+
}
|
|
279
827
|
return {
|
|
280
|
-
post_total:
|
|
281
|
-
failed
|
|
828
|
+
post_total: rows.length,
|
|
829
|
+
failed,
|
|
282
830
|
};
|
|
283
831
|
}
|
|
284
832
|
/**
|
|
285
833
|
* Raw tool_input JSON strings for file-edit tools within [since, until).
|
|
286
|
-
*
|
|
834
|
+
*
|
|
835
|
+
* gzip codec note: the on-disk column is now binary for new rows. To
|
|
836
|
+
* preserve the existing caller contract (caller does `JSON.parse(row.tool_input)`),
|
|
837
|
+
* we decode each row via the codec inside this method and re-stringify back
|
|
838
|
+
* to JSON text on the way out. Net: callers see the same `Array<{tool_input: string}>`
|
|
839
|
+
* shape as before. Bytes-per-row pays the gzip → JSON.stringify cost but
|
|
840
|
+
* the row counts here are small (weekly anti-pattern-detector ≈ a few thousand).
|
|
841
|
+
*
|
|
287
842
|
* Internal IN-list expansion of `tool_names`.
|
|
288
843
|
*/
|
|
289
844
|
queryFileEditInputs(opts) {
|
|
@@ -295,7 +850,81 @@ export class EventOperations {
|
|
|
295
850
|
AND hook_type = 'PreToolUse'
|
|
296
851
|
AND tool_name IN (${placeholders})
|
|
297
852
|
AND tool_input IS NOT NULL`;
|
|
298
|
-
|
|
853
|
+
const rawRows = this.db.prepare(sql).all(opts.since, opts.until, ...opts.tool_names);
|
|
854
|
+
const out = [];
|
|
855
|
+
for (const raw of rawRows) {
|
|
856
|
+
try {
|
|
857
|
+
const decoded = decodeToolInput(raw.tool_input);
|
|
858
|
+
// Caller expects a string; re-stringify so JSON.parse on their side works.
|
|
859
|
+
out.push({ tool_input: JSON.stringify(decoded ?? null) });
|
|
860
|
+
}
|
|
861
|
+
catch {
|
|
862
|
+
// Skip malformed rows — caller already has a try/catch.
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return out;
|
|
866
|
+
}
|
|
867
|
+
// ── TTL sweep operations (Phase: db-size optimization) ─────────────────
|
|
868
|
+
//
|
|
869
|
+
// Two-tier expiry policy for events:
|
|
870
|
+
// - warm TTL: rows older than this get `tool_input = NULL` (frees the
|
|
871
|
+
// dominant column without dropping the row, so analytics/queries
|
|
872
|
+
// still see hook_type/tool_name/timestamps).
|
|
873
|
+
// - cold TTL: rows older than this are DELETEd outright (and orphan
|
|
874
|
+
// task_events rows pruned, mirroring `cleanOldData`).
|
|
875
|
+
//
|
|
876
|
+
// Caller is the daemon's event-ttl-sweep service. Both operations are
|
|
877
|
+
// capped to keep the SQLite writer lock short — if a pass hits the cap,
|
|
878
|
+
// the daemon logs and waits for the next sweep tick (default 6h).
|
|
879
|
+
/**
|
|
880
|
+
* NULL out `tool_input` for events older than `cutoffIso` in batches.
|
|
881
|
+
*
|
|
882
|
+
* Only touches rows where `tool_input IS NOT NULL` so repeat-runs are
|
|
883
|
+
* idempotent. Returns the row count that was updated this pass.
|
|
884
|
+
*
|
|
885
|
+
* `maxRows` bounds the SQL UPDATE via a LIMIT-style sub-SELECT — SQLite
|
|
886
|
+
* doesn't support `UPDATE ... LIMIT` without compile-time flag, so we
|
|
887
|
+
* use `WHERE event_id IN (SELECT event_id FROM events WHERE ... LIMIT ?)`.
|
|
888
|
+
*/
|
|
889
|
+
expireToolInputBatch(cutoffIso, maxRows) {
|
|
890
|
+
const result = this.db
|
|
891
|
+
.prepare(`UPDATE events SET tool_input = NULL
|
|
892
|
+
WHERE event_id IN (
|
|
893
|
+
SELECT event_id FROM events
|
|
894
|
+
WHERE timestamp < ? AND tool_input IS NOT NULL
|
|
895
|
+
LIMIT ?
|
|
896
|
+
)`)
|
|
897
|
+
.run(cutoffIso, maxRows);
|
|
898
|
+
return result.changes;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* DELETE events older than `cutoffIso`, plus orphan task_events rows, in
|
|
902
|
+
* one transaction. Returns counters per table for logging.
|
|
903
|
+
*
|
|
904
|
+
* `maxRows` caps the events delete to keep writer lock short. task_events
|
|
905
|
+
* pruning is bounded by the events delete via the IN-subquery.
|
|
906
|
+
*/
|
|
907
|
+
deleteEventsByCutoff(cutoffIso, maxRows) {
|
|
908
|
+
// Run in a transaction so the orphan-pruning matches the same set of
|
|
909
|
+
// event_ids the events DELETE removed. We capture the doomed ids first
|
|
910
|
+
// to keep task_events bound to that exact set.
|
|
911
|
+
const tx = this.db.transaction(() => {
|
|
912
|
+
const doomed = this.db
|
|
913
|
+
.prepare(`SELECT event_id FROM events WHERE timestamp < ? LIMIT ?`)
|
|
914
|
+
.all(cutoffIso, maxRows);
|
|
915
|
+
if (doomed.length === 0)
|
|
916
|
+
return { events: 0, taskEvents: 0 };
|
|
917
|
+
const placeholders = doomed.map(() => '?').join(',');
|
|
918
|
+
const ids = doomed.map(d => d.event_id);
|
|
919
|
+
const teResult = this.db
|
|
920
|
+
.prepare(`DELETE FROM task_events WHERE event_id IN (${placeholders})`)
|
|
921
|
+
.run(...ids);
|
|
922
|
+
const evResult = this.db
|
|
923
|
+
.prepare(`DELETE FROM events WHERE event_id IN (${placeholders})`)
|
|
924
|
+
.run(...ids);
|
|
925
|
+
return { events: evResult.changes, taskEvents: teResult.changes };
|
|
926
|
+
});
|
|
927
|
+
return tx();
|
|
299
928
|
}
|
|
300
929
|
/** Full events in [since, until?), ascending by timestamp (used by anti-pattern-detector). */
|
|
301
930
|
queryEventsByTimeRange(opts) {
|
|
@@ -313,6 +942,13 @@ export class EventOperations {
|
|
|
313
942
|
// Runtime validation of database row
|
|
314
943
|
try {
|
|
315
944
|
const validatedRow = DatabaseRowSchema.parse(row);
|
|
945
|
+
// tool_input + tool_output flow through the codec: handles gzip Buffer
|
|
946
|
+
// (new large rows), plain UTF-8 Buffer (new tiny rows), and plain JSON
|
|
947
|
+
// text (legacy rows). decodeTool* returns undefined for null/empty,
|
|
948
|
+
// throws on malformed payloads — caught by the outer try/catch which
|
|
949
|
+
// returns a defaulted ForgeEvent.
|
|
950
|
+
const toolInput = decodeToolInput(validatedRow.tool_input);
|
|
951
|
+
const toolOutput = decodeToolOutput(validatedRow.tool_output);
|
|
316
952
|
return {
|
|
317
953
|
event_id: validatedRow.event_id,
|
|
318
954
|
session_id: validatedRow.session_id,
|
|
@@ -320,8 +956,8 @@ export class EventOperations {
|
|
|
320
956
|
timestamp: validatedRow.timestamp,
|
|
321
957
|
hook_type: validatedRow.hook_type,
|
|
322
958
|
tool_name: validatedRow.tool_name || undefined,
|
|
323
|
-
tool_input:
|
|
324
|
-
tool_output:
|
|
959
|
+
tool_input: toolInput,
|
|
960
|
+
tool_output: toolOutput,
|
|
325
961
|
user_prompt: validatedRow.user_prompt || undefined,
|
|
326
962
|
ai_response: validatedRow.ai_response || undefined,
|
|
327
963
|
};
|
|
@@ -344,4 +980,34 @@ export class EventOperations {
|
|
|
344
980
|
}
|
|
345
981
|
}
|
|
346
982
|
}
|
|
983
|
+
/**
|
|
984
|
+
* Decide whether a decoded tool_output represents a tool failure, for
|
|
985
|
+
* `aggregateToolFailureRate`. Semantically equivalent to the three SQL `LIKE`
|
|
986
|
+
* branches the aggregator used before the gzip-codec migration:
|
|
987
|
+
*
|
|
988
|
+
* - '%"error"%' → a JSON `"error"` key appears anywhere
|
|
989
|
+
* - '%"is_error":true%' → a `"is_error":true` pair appears anywhere
|
|
990
|
+
* - '%"isError":true%' → a `"isError":true` pair appears anywhere
|
|
991
|
+
*
|
|
992
|
+
* The original LIKE matched substrings of the stored JSON *text* (and matched
|
|
993
|
+
* nested keys, not just top-level). To preserve that breadth exactly we
|
|
994
|
+
* re-stringify the decoded value and test the same substrings — JSON.stringify
|
|
995
|
+
* emits the canonical `"key":value` form the LIKE patterns assumed.
|
|
996
|
+
*/
|
|
997
|
+
function isFailureToolOutput(decoded) {
|
|
998
|
+
if (decoded === null || decoded === undefined)
|
|
999
|
+
return false;
|
|
1000
|
+
let json;
|
|
1001
|
+
try {
|
|
1002
|
+
json = typeof decoded === 'string' ? decoded : JSON.stringify(decoded);
|
|
1003
|
+
}
|
|
1004
|
+
catch {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (json === undefined)
|
|
1008
|
+
return false;
|
|
1009
|
+
return (json.includes('"error"') ||
|
|
1010
|
+
json.includes('"is_error":true') ||
|
|
1011
|
+
json.includes('"isError":true'));
|
|
1012
|
+
}
|
|
347
1013
|
//# sourceMappingURL=events.js.map
|