@miller-tech/uap 1.0.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/LICENSE +21 -0
- package/README.md +888 -0
- package/dist/analyzers/index.d.ts +3 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +684 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/benchmarks/agents/naive-agent.d.ts +60 -0
- package/dist/benchmarks/agents/naive-agent.d.ts.map +1 -0
- package/dist/benchmarks/agents/naive-agent.js +144 -0
- package/dist/benchmarks/agents/naive-agent.js.map +1 -0
- package/dist/benchmarks/agents/uap-agent.d.ts +167 -0
- package/dist/benchmarks/agents/uap-agent.d.ts.map +1 -0
- package/dist/benchmarks/agents/uap-agent.js +437 -0
- package/dist/benchmarks/agents/uap-agent.js.map +1 -0
- package/dist/benchmarks/benchmark.d.ts +328 -0
- package/dist/benchmarks/benchmark.d.ts.map +1 -0
- package/dist/benchmarks/benchmark.js +112 -0
- package/dist/benchmarks/benchmark.js.map +1 -0
- package/dist/benchmarks/execution-verifier.d.ts +41 -0
- package/dist/benchmarks/execution-verifier.d.ts.map +1 -0
- package/dist/benchmarks/execution-verifier.js +340 -0
- package/dist/benchmarks/execution-verifier.js.map +1 -0
- package/dist/benchmarks/hierarchical-prompting.d.ts +37 -0
- package/dist/benchmarks/hierarchical-prompting.d.ts.map +1 -0
- package/dist/benchmarks/hierarchical-prompting.js +246 -0
- package/dist/benchmarks/hierarchical-prompting.js.map +1 -0
- package/dist/benchmarks/improved-benchmark.d.ts +89 -0
- package/dist/benchmarks/improved-benchmark.d.ts.map +1 -0
- package/dist/benchmarks/improved-benchmark.js +585 -0
- package/dist/benchmarks/improved-benchmark.js.map +1 -0
- package/dist/benchmarks/index.d.ts +11 -0
- package/dist/benchmarks/index.d.ts.map +1 -0
- package/dist/benchmarks/index.js +11 -0
- package/dist/benchmarks/index.js.map +1 -0
- package/dist/benchmarks/model-integration.d.ts +111 -0
- package/dist/benchmarks/model-integration.d.ts.map +1 -0
- package/dist/benchmarks/model-integration.js +904 -0
- package/dist/benchmarks/model-integration.js.map +1 -0
- package/dist/benchmarks/multi-turn-agent.d.ts +44 -0
- package/dist/benchmarks/multi-turn-agent.d.ts.map +1 -0
- package/dist/benchmarks/multi-turn-agent.js +254 -0
- package/dist/benchmarks/multi-turn-agent.js.map +1 -0
- package/dist/benchmarks/multi-turn-loop.d.ts +57 -0
- package/dist/benchmarks/multi-turn-loop.d.ts.map +1 -0
- package/dist/benchmarks/multi-turn-loop.js +167 -0
- package/dist/benchmarks/multi-turn-loop.js.map +1 -0
- package/dist/benchmarks/tasks.d.ts +19 -0
- package/dist/benchmarks/tasks.d.ts.map +1 -0
- package/dist/benchmarks/tasks.js +435 -0
- package/dist/benchmarks/tasks.js.map +1 -0
- package/dist/bin/cli.d.ts +3 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +546 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/llama-server-optimize.d.ts +18 -0
- package/dist/bin/llama-server-optimize.d.ts.map +1 -0
- package/dist/bin/llama-server-optimize.js +708 -0
- package/dist/bin/llama-server-optimize.js.map +1 -0
- package/dist/bin/policy.d.ts +3 -0
- package/dist/bin/policy.d.ts.map +1 -0
- package/dist/bin/policy.js +143 -0
- package/dist/bin/policy.js.map +1 -0
- package/dist/bin/tool-calls.d.ts +3 -0
- package/dist/bin/tool-calls.d.ts.map +1 -0
- package/dist/bin/tool-calls.js +4 -0
- package/dist/bin/tool-calls.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/web-browser.d.ts +30 -0
- package/dist/browser/web-browser.d.ts.map +1 -0
- package/dist/browser/web-browser.js +93 -0
- package/dist/browser/web-browser.js.map +1 -0
- package/dist/cli/agent.d.ts +20 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +474 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/analyze.d.ts +7 -0
- package/dist/cli/analyze.d.ts.map +1 -0
- package/dist/cli/analyze.js +103 -0
- package/dist/cli/analyze.js.map +1 -0
- package/dist/cli/completion-gates.d.ts +51 -0
- package/dist/cli/completion-gates.d.ts.map +1 -0
- package/dist/cli/completion-gates.js +201 -0
- package/dist/cli/completion-gates.js.map +1 -0
- package/dist/cli/compliance.d.ts +8 -0
- package/dist/cli/compliance.d.ts.map +1 -0
- package/dist/cli/compliance.js +509 -0
- package/dist/cli/compliance.js.map +1 -0
- package/dist/cli/coord.d.ts +7 -0
- package/dist/cli/coord.d.ts.map +1 -0
- package/dist/cli/coord.js +138 -0
- package/dist/cli/coord.js.map +1 -0
- package/dist/cli/dashboard.d.ts +21 -0
- package/dist/cli/dashboard.d.ts.map +1 -0
- package/dist/cli/dashboard.js +1508 -0
- package/dist/cli/dashboard.js.map +1 -0
- package/dist/cli/deploy.d.ts +19 -0
- package/dist/cli/deploy.d.ts.map +1 -0
- package/dist/cli/deploy.js +387 -0
- package/dist/cli/deploy.js.map +1 -0
- package/dist/cli/droids.d.ts +9 -0
- package/dist/cli/droids.d.ts.map +1 -0
- package/dist/cli/droids.js +227 -0
- package/dist/cli/droids.js.map +1 -0
- package/dist/cli/generate.d.ts +17 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +432 -0
- package/dist/cli/generate.js.map +1 -0
- package/dist/cli/hooks.d.ts +9 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +464 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/init.d.ts +12 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +364 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/mcp-router.d.ts +16 -0
- package/dist/cli/mcp-router.d.ts.map +1 -0
- package/dist/cli/mcp-router.js +143 -0
- package/dist/cli/mcp-router.js.map +1 -0
- package/dist/cli/memory.d.ts +24 -0
- package/dist/cli/memory.d.ts.map +1 -0
- package/dist/cli/memory.js +885 -0
- package/dist/cli/memory.js.map +1 -0
- package/dist/cli/model.d.ts +15 -0
- package/dist/cli/model.d.ts.map +1 -0
- package/dist/cli/model.js +290 -0
- package/dist/cli/model.js.map +1 -0
- package/dist/cli/patterns.d.ts +26 -0
- package/dist/cli/patterns.d.ts.map +1 -0
- package/dist/cli/patterns.js +862 -0
- package/dist/cli/patterns.js.map +1 -0
- package/dist/cli/rtk-validation.d.ts +9 -0
- package/dist/cli/rtk-validation.d.ts.map +1 -0
- package/dist/cli/rtk-validation.js +9 -0
- package/dist/cli/rtk-validation.js.map +1 -0
- package/dist/cli/rtk.d.ts +34 -0
- package/dist/cli/rtk.d.ts.map +1 -0
- package/dist/cli/rtk.js +401 -0
- package/dist/cli/rtk.js.map +1 -0
- package/dist/cli/schema-diff.d.ts +7 -0
- package/dist/cli/schema-diff.d.ts.map +1 -0
- package/dist/cli/schema-diff.js +11 -0
- package/dist/cli/schema-diff.js.map +1 -0
- package/dist/cli/setup-mcp-router.d.ts +8 -0
- package/dist/cli/setup-mcp-router.d.ts.map +1 -0
- package/dist/cli/setup-mcp-router.js +163 -0
- package/dist/cli/setup-mcp-router.js.map +1 -0
- package/dist/cli/setup-wizard.d.ts +2 -0
- package/dist/cli/setup-wizard.d.ts.map +1 -0
- package/dist/cli/setup-wizard.js +806 -0
- package/dist/cli/setup-wizard.js.map +1 -0
- package/dist/cli/setup.d.ts +15 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +154 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/sync.d.ts +8 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +395 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/cli/task.d.ts +33 -0
- package/dist/cli/task.d.ts.map +1 -0
- package/dist/cli/task.js +672 -0
- package/dist/cli/task.js.map +1 -0
- package/dist/cli/tool-calls.d.ts +20 -0
- package/dist/cli/tool-calls.d.ts.map +1 -0
- package/dist/cli/tool-calls.js +605 -0
- package/dist/cli/tool-calls.js.map +1 -0
- package/dist/cli/uap.d.ts +10 -0
- package/dist/cli/uap.d.ts.map +1 -0
- package/dist/cli/uap.js +398 -0
- package/dist/cli/uap.js.map +1 -0
- package/dist/cli/update.d.ts +10 -0
- package/dist/cli/update.d.ts.map +1 -0
- package/dist/cli/update.js +300 -0
- package/dist/cli/update.js.map +1 -0
- package/dist/cli/visualize.d.ts +77 -0
- package/dist/cli/visualize.d.ts.map +1 -0
- package/dist/cli/visualize.js +287 -0
- package/dist/cli/visualize.js.map +1 -0
- package/dist/cli/worktree.d.ts +9 -0
- package/dist/cli/worktree.d.ts.map +1 -0
- package/dist/cli/worktree.js +213 -0
- package/dist/cli/worktree.js.map +1 -0
- package/dist/coordination/adaptive-patterns.d.ts +65 -0
- package/dist/coordination/adaptive-patterns.d.ts.map +1 -0
- package/dist/coordination/adaptive-patterns.js +108 -0
- package/dist/coordination/adaptive-patterns.js.map +1 -0
- package/dist/coordination/auto-agent.d.ts +82 -0
- package/dist/coordination/auto-agent.d.ts.map +1 -0
- package/dist/coordination/auto-agent.js +145 -0
- package/dist/coordination/auto-agent.js.map +1 -0
- package/dist/coordination/capability-router.d.ts +79 -0
- package/dist/coordination/capability-router.d.ts.map +1 -0
- package/dist/coordination/capability-router.js +334 -0
- package/dist/coordination/capability-router.js.map +1 -0
- package/dist/coordination/database.d.ts +13 -0
- package/dist/coordination/database.d.ts.map +1 -0
- package/dist/coordination/database.js +136 -0
- package/dist/coordination/database.js.map +1 -0
- package/dist/coordination/deploy-batcher.d.ts +122 -0
- package/dist/coordination/deploy-batcher.d.ts.map +1 -0
- package/dist/coordination/deploy-batcher.js +718 -0
- package/dist/coordination/deploy-batcher.js.map +1 -0
- package/dist/coordination/droid-validator.d.ts +59 -0
- package/dist/coordination/droid-validator.d.ts.map +1 -0
- package/dist/coordination/droid-validator.js +142 -0
- package/dist/coordination/droid-validator.js.map +1 -0
- package/dist/coordination/index.d.ts +10 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +10 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/pattern-router.d.ts +50 -0
- package/dist/coordination/pattern-router.d.ts.map +1 -0
- package/dist/coordination/pattern-router.js +118 -0
- package/dist/coordination/pattern-router.js.map +1 -0
- package/dist/coordination/service.d.ts +81 -0
- package/dist/coordination/service.d.ts.map +1 -0
- package/dist/coordination/service.js +619 -0
- package/dist/coordination/service.js.map +1 -0
- package/dist/coordination/worktree-enforcer.d.ts +22 -0
- package/dist/coordination/worktree-enforcer.d.ts.map +1 -0
- package/dist/coordination/worktree-enforcer.js +71 -0
- package/dist/coordination/worktree-enforcer.js.map +1 -0
- package/dist/generators/claude-md.d.ts +3 -0
- package/dist/generators/claude-md.d.ts.map +1 -0
- package/dist/generators/claude-md.js +1020 -0
- package/dist/generators/claude-md.js.map +1 -0
- package/dist/generators/template-loader.d.ts +105 -0
- package/dist/generators/template-loader.d.ts.map +1 -0
- package/dist/generators/template-loader.js +291 -0
- package/dist/generators/template-loader.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-router/config/parser.d.ts +9 -0
- package/dist/mcp-router/config/parser.d.ts.map +1 -0
- package/dist/mcp-router/config/parser.js +174 -0
- package/dist/mcp-router/config/parser.js.map +1 -0
- package/dist/mcp-router/executor/client.d.ts +31 -0
- package/dist/mcp-router/executor/client.d.ts.map +1 -0
- package/dist/mcp-router/executor/client.js +189 -0
- package/dist/mcp-router/executor/client.js.map +1 -0
- package/dist/mcp-router/index.d.ts +22 -0
- package/dist/mcp-router/index.d.ts.map +1 -0
- package/dist/mcp-router/index.js +18 -0
- package/dist/mcp-router/index.js.map +1 -0
- package/dist/mcp-router/output-compressor.d.ts +26 -0
- package/dist/mcp-router/output-compressor.d.ts.map +1 -0
- package/dist/mcp-router/output-compressor.js +236 -0
- package/dist/mcp-router/output-compressor.js.map +1 -0
- package/dist/mcp-router/search/fuzzy.d.ts +26 -0
- package/dist/mcp-router/search/fuzzy.d.ts.map +1 -0
- package/dist/mcp-router/search/fuzzy.js +94 -0
- package/dist/mcp-router/search/fuzzy.js.map +1 -0
- package/dist/mcp-router/server.d.ts +50 -0
- package/dist/mcp-router/server.d.ts.map +1 -0
- package/dist/mcp-router/server.js +229 -0
- package/dist/mcp-router/server.js.map +1 -0
- package/dist/mcp-router/session-stats.d.ts +37 -0
- package/dist/mcp-router/session-stats.d.ts.map +1 -0
- package/dist/mcp-router/session-stats.js +56 -0
- package/dist/mcp-router/session-stats.js.map +1 -0
- package/dist/mcp-router/tools/discover.d.ts +37 -0
- package/dist/mcp-router/tools/discover.d.ts.map +1 -0
- package/dist/mcp-router/tools/discover.js +65 -0
- package/dist/mcp-router/tools/discover.js.map +1 -0
- package/dist/mcp-router/tools/execute.d.ts +43 -0
- package/dist/mcp-router/tools/execute.d.ts.map +1 -0
- package/dist/mcp-router/tools/execute.js +144 -0
- package/dist/mcp-router/tools/execute.js.map +1 -0
- package/dist/mcp-router/types.d.ts +62 -0
- package/dist/mcp-router/types.d.ts.map +1 -0
- package/dist/mcp-router/types.js +6 -0
- package/dist/mcp-router/types.js.map +1 -0
- package/dist/memory/adaptive-context.d.ts +149 -0
- package/dist/memory/adaptive-context.d.ts.map +1 -0
- package/dist/memory/adaptive-context.js +1095 -0
- package/dist/memory/adaptive-context.js.map +1 -0
- package/dist/memory/agent-scoped-memory.d.ts +67 -0
- package/dist/memory/agent-scoped-memory.d.ts.map +1 -0
- package/dist/memory/agent-scoped-memory.js +126 -0
- package/dist/memory/agent-scoped-memory.js.map +1 -0
- package/dist/memory/ambiguity-detector.d.ts +54 -0
- package/dist/memory/ambiguity-detector.d.ts.map +1 -0
- package/dist/memory/ambiguity-detector.js +401 -0
- package/dist/memory/ambiguity-detector.js.map +1 -0
- package/dist/memory/backends/base.d.ts +18 -0
- package/dist/memory/backends/base.d.ts.map +1 -0
- package/dist/memory/backends/base.js +2 -0
- package/dist/memory/backends/base.js.map +1 -0
- package/dist/memory/backends/factory.d.ts +4 -0
- package/dist/memory/backends/factory.d.ts.map +1 -0
- package/dist/memory/backends/factory.js +53 -0
- package/dist/memory/backends/factory.js.map +1 -0
- package/dist/memory/backends/github.d.ts +27 -0
- package/dist/memory/backends/github.d.ts.map +1 -0
- package/dist/memory/backends/github.js +134 -0
- package/dist/memory/backends/github.js.map +1 -0
- package/dist/memory/backends/qdrant-cloud.d.ts +32 -0
- package/dist/memory/backends/qdrant-cloud.d.ts.map +1 -0
- package/dist/memory/backends/qdrant-cloud.js +167 -0
- package/dist/memory/backends/qdrant-cloud.js.map +1 -0
- package/dist/memory/context-compressor.d.ts +116 -0
- package/dist/memory/context-compressor.d.ts.map +1 -0
- package/dist/memory/context-compressor.js +430 -0
- package/dist/memory/context-compressor.js.map +1 -0
- package/dist/memory/context-pruner.d.ts +55 -0
- package/dist/memory/context-pruner.d.ts.map +1 -0
- package/dist/memory/context-pruner.js +85 -0
- package/dist/memory/context-pruner.js.map +1 -0
- package/dist/memory/correction-propagator.d.ts +44 -0
- package/dist/memory/correction-propagator.d.ts.map +1 -0
- package/dist/memory/correction-propagator.js +156 -0
- package/dist/memory/correction-propagator.js.map +1 -0
- package/dist/memory/daily-log.d.ts +67 -0
- package/dist/memory/daily-log.d.ts.map +1 -0
- package/dist/memory/daily-log.js +143 -0
- package/dist/memory/daily-log.js.map +1 -0
- package/dist/memory/dynamic-retrieval.d.ts +112 -0
- package/dist/memory/dynamic-retrieval.d.ts.map +1 -0
- package/dist/memory/dynamic-retrieval.js +908 -0
- package/dist/memory/dynamic-retrieval.js.map +1 -0
- package/dist/memory/embeddings.d.ts +172 -0
- package/dist/memory/embeddings.d.ts.map +1 -0
- package/dist/memory/embeddings.js +780 -0
- package/dist/memory/embeddings.js.map +1 -0
- package/dist/memory/generic-uap-patterns.d.ts +7 -0
- package/dist/memory/generic-uap-patterns.d.ts.map +1 -0
- package/dist/memory/generic-uap-patterns.js +43 -0
- package/dist/memory/generic-uap-patterns.js.map +1 -0
- package/dist/memory/hierarchical-memory.d.ts +141 -0
- package/dist/memory/hierarchical-memory.d.ts.map +1 -0
- package/dist/memory/hierarchical-memory.js +485 -0
- package/dist/memory/hierarchical-memory.js.map +1 -0
- package/dist/memory/knowledge-graph.d.ts +98 -0
- package/dist/memory/knowledge-graph.d.ts.map +1 -0
- package/dist/memory/knowledge-graph.js +275 -0
- package/dist/memory/knowledge-graph.js.map +1 -0
- package/dist/memory/memory-consolidator.d.ts +124 -0
- package/dist/memory/memory-consolidator.d.ts.map +1 -0
- package/dist/memory/memory-consolidator.js +514 -0
- package/dist/memory/memory-consolidator.js.map +1 -0
- package/dist/memory/memory-maintenance.d.ts +39 -0
- package/dist/memory/memory-maintenance.d.ts.map +1 -0
- package/dist/memory/memory-maintenance.js +336 -0
- package/dist/memory/memory-maintenance.js.map +1 -0
- package/dist/memory/model-router.d.ts +105 -0
- package/dist/memory/model-router.d.ts.map +1 -0
- package/dist/memory/model-router.js +474 -0
- package/dist/memory/model-router.js.map +1 -0
- package/dist/memory/multi-view-memory.d.ts +134 -0
- package/dist/memory/multi-view-memory.d.ts.map +1 -0
- package/dist/memory/multi-view-memory.js +430 -0
- package/dist/memory/multi-view-memory.js.map +1 -0
- package/dist/memory/predictive-memory.d.ts +79 -0
- package/dist/memory/predictive-memory.d.ts.map +1 -0
- package/dist/memory/predictive-memory.js +294 -0
- package/dist/memory/predictive-memory.js.map +1 -0
- package/dist/memory/prepopulate.d.ts +76 -0
- package/dist/memory/prepopulate.d.ts.map +1 -0
- package/dist/memory/prepopulate.js +832 -0
- package/dist/memory/prepopulate.js.map +1 -0
- package/dist/memory/semantic-compression.d.ts +77 -0
- package/dist/memory/semantic-compression.d.ts.map +1 -0
- package/dist/memory/semantic-compression.js +359 -0
- package/dist/memory/semantic-compression.js.map +1 -0
- package/dist/memory/serverless-qdrant.d.ts +102 -0
- package/dist/memory/serverless-qdrant.d.ts.map +1 -0
- package/dist/memory/serverless-qdrant.js +369 -0
- package/dist/memory/serverless-qdrant.js.map +1 -0
- package/dist/memory/short-term/factory.d.ts +26 -0
- package/dist/memory/short-term/factory.d.ts.map +1 -0
- package/dist/memory/short-term/factory.js +28 -0
- package/dist/memory/short-term/factory.js.map +1 -0
- package/dist/memory/short-term/indexeddb.d.ts +25 -0
- package/dist/memory/short-term/indexeddb.d.ts.map +1 -0
- package/dist/memory/short-term/indexeddb.js +64 -0
- package/dist/memory/short-term/indexeddb.js.map +1 -0
- package/dist/memory/short-term/schema.d.ts +6 -0
- package/dist/memory/short-term/schema.d.ts.map +1 -0
- package/dist/memory/short-term/schema.js +141 -0
- package/dist/memory/short-term/schema.js.map +1 -0
- package/dist/memory/short-term/sqlite.d.ts +64 -0
- package/dist/memory/short-term/sqlite.d.ts.map +1 -0
- package/dist/memory/short-term/sqlite.js +274 -0
- package/dist/memory/short-term/sqlite.js.map +1 -0
- package/dist/memory/speculative-cache.d.ts +111 -0
- package/dist/memory/speculative-cache.d.ts.map +1 -0
- package/dist/memory/speculative-cache.js +457 -0
- package/dist/memory/speculative-cache.js.map +1 -0
- package/dist/memory/task-classifier.d.ts +40 -0
- package/dist/memory/task-classifier.d.ts.map +1 -0
- package/dist/memory/task-classifier.js +342 -0
- package/dist/memory/task-classifier.js.map +1 -0
- package/dist/memory/terminal-bench-knowledge.d.ts +48 -0
- package/dist/memory/terminal-bench-knowledge.d.ts.map +1 -0
- package/dist/memory/terminal-bench-knowledge.js +622 -0
- package/dist/memory/terminal-bench-knowledge.js.map +1 -0
- package/dist/memory/write-gate.d.ts +39 -0
- package/dist/memory/write-gate.d.ts.map +1 -0
- package/dist/memory/write-gate.js +190 -0
- package/dist/memory/write-gate.js.map +1 -0
- package/dist/models/api-client.d.ts +46 -0
- package/dist/models/api-client.d.ts.map +1 -0
- package/dist/models/api-client.js +182 -0
- package/dist/models/api-client.js.map +1 -0
- package/dist/models/execution-profiles.d.ts +64 -0
- package/dist/models/execution-profiles.d.ts.map +1 -0
- package/dist/models/execution-profiles.js +403 -0
- package/dist/models/execution-profiles.js.map +1 -0
- package/dist/models/executor.d.ts +130 -0
- package/dist/models/executor.d.ts.map +1 -0
- package/dist/models/executor.js +382 -0
- package/dist/models/executor.js.map +1 -0
- package/dist/models/index.d.ts +19 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +23 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/plan-validator.d.ts +37 -0
- package/dist/models/plan-validator.d.ts.map +1 -0
- package/dist/models/plan-validator.js +179 -0
- package/dist/models/plan-validator.js.map +1 -0
- package/dist/models/planner.d.ts +73 -0
- package/dist/models/planner.d.ts.map +1 -0
- package/dist/models/planner.js +375 -0
- package/dist/models/planner.js.map +1 -0
- package/dist/models/router.d.ts +96 -0
- package/dist/models/router.d.ts.map +1 -0
- package/dist/models/router.js +523 -0
- package/dist/models/router.js.map +1 -0
- package/dist/models/types.d.ts +370 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +232 -0
- package/dist/models/types.js.map +1 -0
- package/dist/models/unified-router.d.ts +152 -0
- package/dist/models/unified-router.d.ts.map +1 -0
- package/dist/models/unified-router.js +313 -0
- package/dist/models/unified-router.js.map +1 -0
- package/dist/policies/convert-policy-to-claude.d.ts +3 -0
- package/dist/policies/convert-policy-to-claude.d.ts.map +1 -0
- package/dist/policies/convert-policy-to-claude.js +87 -0
- package/dist/policies/convert-policy-to-claude.js.map +1 -0
- package/dist/policies/database-manager.d.ts +27 -0
- package/dist/policies/database-manager.d.ts.map +1 -0
- package/dist/policies/database-manager.js +198 -0
- package/dist/policies/database-manager.js.map +1 -0
- package/dist/policies/enforced-tool-router.d.ts +53 -0
- package/dist/policies/enforced-tool-router.d.ts.map +1 -0
- package/dist/policies/enforced-tool-router.js +80 -0
- package/dist/policies/enforced-tool-router.js.map +1 -0
- package/dist/policies/index.d.ts +10 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +8 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/policy-gate.d.ts +59 -0
- package/dist/policies/policy-gate.d.ts.map +1 -0
- package/dist/policies/policy-gate.js +171 -0
- package/dist/policies/policy-gate.js.map +1 -0
- package/dist/policies/policy-memory.d.ts +18 -0
- package/dist/policies/policy-memory.d.ts.map +1 -0
- package/dist/policies/policy-memory.js +126 -0
- package/dist/policies/policy-memory.js.map +1 -0
- package/dist/policies/policy-tools.d.ts +11 -0
- package/dist/policies/policy-tools.d.ts.map +1 -0
- package/dist/policies/policy-tools.js +66 -0
- package/dist/policies/policy-tools.js.map +1 -0
- package/dist/policies/schemas/policy.d.ts +69 -0
- package/dist/policies/schemas/policy.d.ts.map +1 -0
- package/dist/policies/schemas/policy.js +31 -0
- package/dist/policies/schemas/policy.js.map +1 -0
- package/dist/tasks/coordination.d.ts +83 -0
- package/dist/tasks/coordination.d.ts.map +1 -0
- package/dist/tasks/coordination.js +291 -0
- package/dist/tasks/coordination.js.map +1 -0
- package/dist/tasks/database.d.ts +19 -0
- package/dist/tasks/database.d.ts.map +1 -0
- package/dist/tasks/database.js +149 -0
- package/dist/tasks/database.js.map +1 -0
- package/dist/tasks/decoder-gate.d.ts +64 -0
- package/dist/tasks/decoder-gate.d.ts.map +1 -0
- package/dist/tasks/decoder-gate.js +268 -0
- package/dist/tasks/decoder-gate.js.map +1 -0
- package/dist/tasks/index.d.ts +6 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +6 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/service.d.ts +40 -0
- package/dist/tasks/service.d.ts.map +1 -0
- package/dist/tasks/service.js +671 -0
- package/dist/tasks/service.js.map +1 -0
- package/dist/tasks/types.d.ts +238 -0
- package/dist/tasks/types.d.ts.map +1 -0
- package/dist/tasks/types.js +74 -0
- package/dist/tasks/types.js.map +1 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/session-telemetry.d.ts +56 -0
- package/dist/telemetry/session-telemetry.d.ts.map +1 -0
- package/dist/telemetry/session-telemetry.js +807 -0
- package/dist/telemetry/session-telemetry.js.map +1 -0
- package/dist/types/analysis.d.ts +82 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +2 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/config.d.ts +3324 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +418 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/coordination.d.ts +240 -0
- package/dist/types/coordination.d.ts.map +1 -0
- package/dist/types/coordination.js +43 -0
- package/dist/types/coordination.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/uap-droids-strict.d.ts +59 -0
- package/dist/uap-droids-strict.d.ts.map +1 -0
- package/dist/uap-droids-strict.js +200 -0
- package/dist/uap-droids-strict.js.map +1 -0
- package/dist/utils/config-manager.d.ts +30 -0
- package/dist/utils/config-manager.d.ts.map +1 -0
- package/dist/utils/config-manager.js +41 -0
- package/dist/utils/config-manager.js.map +1 -0
- package/dist/utils/fetch-with-retry.d.ts +5 -0
- package/dist/utils/fetch-with-retry.d.ts.map +1 -0
- package/dist/utils/fetch-with-retry.js +61 -0
- package/dist/utils/fetch-with-retry.js.map +1 -0
- package/dist/utils/merge-claude-md.d.ts +28 -0
- package/dist/utils/merge-claude-md.d.ts.map +1 -0
- package/dist/utils/merge-claude-md.js +342 -0
- package/dist/utils/merge-claude-md.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +58 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +100 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/string-similarity.d.ts +37 -0
- package/dist/utils/string-similarity.d.ts.map +1 -0
- package/dist/utils/string-similarity.js +114 -0
- package/dist/utils/string-similarity.js.map +1 -0
- package/dist/utils/validate-json.d.ts +51 -0
- package/dist/utils/validate-json.d.ts.map +1 -0
- package/dist/utils/validate-json.js +94 -0
- package/dist/utils/validate-json.js.map +1 -0
- package/docs/INDEX.md +66 -0
- package/docs/architecture/MULTI_MODEL.md +224 -0
- package/docs/architecture/SYSTEM_ANALYSIS.md +1117 -0
- package/docs/architecture/UAP_COMPLIANCE.md +217 -0
- package/docs/architecture/UAP_PROTOCOL.md +339 -0
- package/docs/architecture/UAP_STRICT_DROIDS.md +172 -0
- package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +260 -0
- package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +668 -0
- package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +209 -0
- package/docs/archive/NPM-PUBLISH-V0.9.1.md +240 -0
- package/docs/archive/OPTIMIZATION_OPTIONS.md +334 -0
- package/docs/archive/SETUP_IMPROVEMENTS.md +213 -0
- package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +270 -0
- package/docs/archive/UAP_V103_PATTERN_DESIGN.md +315 -0
- package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +223 -0
- package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +77 -0
- package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +109 -0
- package/docs/benchmarks/ACCURACY_ANALYSIS.md +471 -0
- package/docs/benchmarks/TOKEN_OPTIMIZATION.md +572 -0
- package/docs/benchmarks/VALIDATION_PLAN.md +568 -0
- package/docs/benchmarks/VALIDATION_RESULTS.md +161 -0
- package/docs/deployment/DEPLOYMENT.md +895 -0
- package/docs/deployment/DEPLOYMENT_STRATEGIES.md +518 -0
- package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +856 -0
- package/docs/deployment/DEPLOY_BATCHING.md +273 -0
- package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +420 -0
- package/docs/deployment/QWEN35_LLAMA_CPP.md +265 -0
- package/docs/getting-started/INTEGRATION.md +449 -0
- package/docs/getting-started/OVERVIEW.md +344 -0
- package/docs/getting-started/SETUP.md +203 -0
- package/docs/integrations/MCP_ROUTER_SETUP.md +445 -0
- package/docs/integrations/RTK_INTEGRATION.md +468 -0
- package/docs/operations/TROUBLESHOOTING.md +660 -0
- package/docs/reference/API_REFERENCE.md +903 -0
- package/docs/reference/FEATURES.md +472 -0
- package/docs/reference/HARNESS-MATRIX.md +318 -0
- package/docs/reference/UAP_CLI_REFERENCE.md +600 -0
- package/docs/research/BEHAVIORAL_PATTERNS.md +228 -0
- package/docs/research/DOMAIN_STRATEGIES.md +316 -0
- package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +812 -0
- package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +436 -0
- package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +209 -0
- package/docs/research/PERFORMANCE_TEST_PLAN.md +383 -0
- package/docs/research/TERMINAL_BENCH_LEARNINGS.md +217 -0
- package/package.json +113 -0
- package/scripts/README.md +161 -0
- package/templates/CLAUDE.template.md +10 -0
- package/templates/CLAUDE_ARCHITECTURE.template.md +103 -0
- package/templates/CLAUDE_CODING.template.md +127 -0
- package/templates/CLAUDE_DROIDS.template.md +109 -0
- package/templates/CLAUDE_MEMORY.template.md +131 -0
- package/templates/CLAUDE_WORKFLOWS.template.md +139 -0
- package/templates/PROJECT.template.md +209 -0
- package/templates/SCHEMA.md +57 -0
- package/templates/archive/CLAUDE.template.root-v6.md +534 -0
- package/templates/archive/CLAUDE.template.v6.md +534 -0
- package/templates/hooks/forgecode/pre-compact.sh +68 -0
- package/templates/hooks/forgecode/session-start.sh +169 -0
- package/templates/hooks/forgecode.plugin.sh +128 -0
- package/templates/hooks/pre-compact.sh +74 -0
- package/templates/hooks/session-start.sh +366 -0
- package/tools/agents/README.md +224 -0
- package/tools/agents/UAP/README.md +386 -0
- package/tools/agents/UAP/__init__.py +9 -0
- package/tools/agents/UAP/cli.py +901 -0
- package/tools/agents/UAP/compliance_verify.sh +108 -0
- package/tools/agents/UAP/full_verification.sh +126 -0
- package/tools/agents/UAP/version.py +32 -0
- package/tools/agents/benchmarks/benchmark_memory_systems.py +730 -0
- package/tools/agents/benchmarks/results/benchmark_20260106_064817.json +170 -0
- package/tools/agents/benchmarks/results/benchmark_20260106_064817.md +51 -0
- package/tools/agents/config/chat_template.jinja +77 -0
- package/tools/agents/config/tool-call-schema.json +19 -0
- package/tools/agents/config/tool-call.gbnf +58 -0
- package/tools/agents/docker/Dockerfile.python +52 -0
- package/tools/agents/docker/Dockerfile.ubuntu +55 -0
- package/tools/agents/docker-compose.qdrant.yml +24 -0
- package/tools/agents/install-opencode-local.sh.j2 +135 -0
- package/tools/agents/migrations/apply.py +256 -0
- package/tools/agents/opencode_uap_agent.py +1505 -0
- package/tools/agents/plugin/README.md +91 -0
- package/tools/agents/plugin/index.ts +46 -0
- package/tools/agents/plugin/pre-compact.sh +68 -0
- package/tools/agents/plugin/session-start.sh +175 -0
- package/tools/agents/plugin/uap-commands.ts +45 -0
- package/tools/agents/plugin/uap-droids.ts +54 -0
- package/tools/agents/plugin/uap-patterns.ts +54 -0
- package/tools/agents/plugin/uap-skills.ts +52 -0
- package/tools/agents/plugins/uap-enforce.ts +314 -0
- package/tools/agents/scripts/__pycache__/tool_call_wrapper.cpython-313.pyc +0 -0
- package/tools/agents/scripts/chat_template_verifier.py +343 -0
- package/tools/agents/scripts/fix-qwen-template.js +38 -0
- package/tools/agents/scripts/fix_qwen_chat_template.py +316 -0
- package/tools/agents/scripts/generate_lora_training_data.py +412 -0
- package/tools/agents/scripts/init_qdrant.py +151 -0
- package/tools/agents/scripts/memory_migration.py +560 -0
- package/tools/agents/scripts/migrate_memory_to_qdrant.py +110 -0
- package/tools/agents/scripts/prepare_lora.sh +512 -0
- package/tools/agents/scripts/query_memory.py +200 -0
- package/tools/agents/scripts/qwen-tool-call-test.js +38 -0
- package/tools/agents/scripts/qwen-tool-call-wrapper.js +38 -0
- package/tools/agents/scripts/qwen_tool_call_test.py +464 -0
- package/tools/agents/scripts/qwen_tool_call_wrapper.py +686 -0
- package/tools/agents/scripts/start-services.sh +96 -0
- package/tools/agents/scripts/tool-choice-proxy.cjs +296 -0
- package/tools/agents/scripts/tool_call_test.py +656 -0
- package/tools/agents/scripts/tool_call_wrapper.py +799 -0
- package/tools/agents/tests/test_uap_compliance.py +257 -0
- package/tools/agents/uap_agent.py +122 -0
- package/tools/agents/uap_agent_install.sh +12 -0
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, cpSync } from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
// ─── ANSI Colors ───
|
|
4
|
+
const RESET = '\x1b[0m';
|
|
5
|
+
const BOLD = '\x1b[1m';
|
|
6
|
+
const DIM = '\x1b[2m';
|
|
7
|
+
const ITALIC = '\x1b[3m';
|
|
8
|
+
const CYAN = '\x1b[36m';
|
|
9
|
+
const GREEN = '\x1b[32m';
|
|
10
|
+
const YELLOW = '\x1b[33m';
|
|
11
|
+
const MAGENTA = '\x1b[35m';
|
|
12
|
+
const BLUE = '\x1b[34m';
|
|
13
|
+
const RED = '\x1b[31m';
|
|
14
|
+
const WHITE = '\x1b[37m';
|
|
15
|
+
const BG_BLUE = '\x1b[44m';
|
|
16
|
+
const BG_GREEN = '\x1b[42m';
|
|
17
|
+
const BG_CYAN = '\x1b[46m';
|
|
18
|
+
// BG_YELLOW reserved for deploy warnings
|
|
19
|
+
// ─── Box Drawing ───
|
|
20
|
+
const BOX = {
|
|
21
|
+
tl: '╭',
|
|
22
|
+
tr: '╮',
|
|
23
|
+
bl: '╰',
|
|
24
|
+
br: '╯',
|
|
25
|
+
h: '─',
|
|
26
|
+
v: '│',
|
|
27
|
+
t: '┬',
|
|
28
|
+
b: '┴',
|
|
29
|
+
cross: '┼',
|
|
30
|
+
lj: '├',
|
|
31
|
+
rj: '┤',
|
|
32
|
+
};
|
|
33
|
+
const TREE = { pipe: '│', branch: '├', last: '└', dash: '──' };
|
|
34
|
+
let _stats = null;
|
|
35
|
+
function getStats() {
|
|
36
|
+
if (!_stats) {
|
|
37
|
+
_stats = {
|
|
38
|
+
sessionId: Math.random().toString(36).substring(2, 8),
|
|
39
|
+
startTime: Date.now(),
|
|
40
|
+
tokensUsed: 0,
|
|
41
|
+
tokensSaved: 0,
|
|
42
|
+
memoryHits: 0,
|
|
43
|
+
memoryMisses: 0,
|
|
44
|
+
toolCalls: 0,
|
|
45
|
+
policyChecks: 0,
|
|
46
|
+
policyBlocks: 0,
|
|
47
|
+
filesBackedUp: 0,
|
|
48
|
+
stepsCompleted: 0,
|
|
49
|
+
stepsTotal: 0,
|
|
50
|
+
currentStep: '',
|
|
51
|
+
errors: 0,
|
|
52
|
+
agents: new Map(),
|
|
53
|
+
tasks: new Map(),
|
|
54
|
+
skills: new Map(),
|
|
55
|
+
patterns: new Map(),
|
|
56
|
+
rootTaskIds: [],
|
|
57
|
+
deploys: new Map(),
|
|
58
|
+
costs: [],
|
|
59
|
+
totalCostUsd: 0,
|
|
60
|
+
estimatedCostWithoutUap: 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return _stats;
|
|
64
|
+
}
|
|
65
|
+
// ─── Formatting Helpers ───
|
|
66
|
+
function elapsed() {
|
|
67
|
+
const ms = Date.now() - getStats().startTime;
|
|
68
|
+
if (ms < 1000)
|
|
69
|
+
return `${ms}ms`;
|
|
70
|
+
if (ms < 60000)
|
|
71
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
72
|
+
const mins = Math.floor(ms / 60000);
|
|
73
|
+
const secs = Math.floor((ms % 60000) / 1000);
|
|
74
|
+
return `${mins}m ${secs}s`;
|
|
75
|
+
}
|
|
76
|
+
function elapsedSince(ts) {
|
|
77
|
+
const ms = Date.now() - ts;
|
|
78
|
+
if (ms < 1000)
|
|
79
|
+
return `${ms}ms`;
|
|
80
|
+
if (ms < 60000)
|
|
81
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
82
|
+
const mins = Math.floor(ms / 60000);
|
|
83
|
+
const secs = Math.floor((ms % 60000) / 1000);
|
|
84
|
+
return `${mins}m ${secs}s`;
|
|
85
|
+
}
|
|
86
|
+
function eta() {
|
|
87
|
+
const s = getStats();
|
|
88
|
+
if (s.stepsCompleted === 0 || s.stepsTotal === 0)
|
|
89
|
+
return '?';
|
|
90
|
+
const msPerStep = (Date.now() - s.startTime) / s.stepsCompleted;
|
|
91
|
+
const remaining = (s.stepsTotal - s.stepsCompleted) * msPerStep;
|
|
92
|
+
if (remaining < 1000)
|
|
93
|
+
return '<1s';
|
|
94
|
+
if (remaining < 60000)
|
|
95
|
+
return `~${Math.ceil(remaining / 1000)}s`;
|
|
96
|
+
return `~${Math.ceil(remaining / 60000)}m`;
|
|
97
|
+
}
|
|
98
|
+
function progressBar(current, total, width = 20) {
|
|
99
|
+
if (total === 0)
|
|
100
|
+
return `[${'░'.repeat(width)}]`;
|
|
101
|
+
const filled = Math.round((current / total) * width);
|
|
102
|
+
const empty = width - filled;
|
|
103
|
+
const pct = Math.round((current / total) * 100);
|
|
104
|
+
return `[${GREEN}${'█'.repeat(filled)}${DIM}${'░'.repeat(empty)}${RESET}] ${pct}%`;
|
|
105
|
+
}
|
|
106
|
+
function formatTokens(n) {
|
|
107
|
+
if (n < 1000)
|
|
108
|
+
return `${n}`;
|
|
109
|
+
if (n < 1000000)
|
|
110
|
+
return `${(n / 1000).toFixed(1)}K`;
|
|
111
|
+
return `${(n / 1000000).toFixed(2)}M`;
|
|
112
|
+
}
|
|
113
|
+
function boxLine(content, width = 60) {
|
|
114
|
+
const stripped = content.replace(/\x1b\[[0-9;]*m/g, '');
|
|
115
|
+
const pad = Math.max(0, width - stripped.length - 2);
|
|
116
|
+
return `${BOX.v} ${content}${' '.repeat(pad)}${BOX.v}`;
|
|
117
|
+
}
|
|
118
|
+
function statusIcon(status) {
|
|
119
|
+
switch (status) {
|
|
120
|
+
case 'idle':
|
|
121
|
+
return `${DIM}○${RESET}`;
|
|
122
|
+
case 'working':
|
|
123
|
+
case 'in_progress':
|
|
124
|
+
return `${YELLOW}◉${RESET}`;
|
|
125
|
+
case 'done':
|
|
126
|
+
return `${GREEN}●${RESET}`;
|
|
127
|
+
case 'error':
|
|
128
|
+
case 'failed':
|
|
129
|
+
return `${RED}✗${RESET}`;
|
|
130
|
+
case 'blocked':
|
|
131
|
+
return `${RED}◎${RESET}`;
|
|
132
|
+
case 'pending':
|
|
133
|
+
return `${DIM}○${RESET}`;
|
|
134
|
+
default:
|
|
135
|
+
return `${DIM}?${RESET}`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function truncate(s, max) {
|
|
139
|
+
return s.length > max ? s.substring(0, max - 1) + '…' : s;
|
|
140
|
+
}
|
|
141
|
+
// ─── Public API: Session Lifecycle ───
|
|
142
|
+
export function banner() {
|
|
143
|
+
const w = 60;
|
|
144
|
+
const line = BOX.h.repeat(w);
|
|
145
|
+
console.log(`\n${CYAN}${BOX.tl}${line}${BOX.tr}${RESET}`);
|
|
146
|
+
console.log(boxLine(`${BOLD}${CYAN} UAP Session ${getStats().sessionId}${RESET} ${DIM}${elapsed()}${RESET}`, w));
|
|
147
|
+
console.log(`${CYAN}${BOX.bl}${line}${BOX.br}${RESET}\n`);
|
|
148
|
+
}
|
|
149
|
+
export function sessionStart(totalSteps = 0) {
|
|
150
|
+
const s = getStats();
|
|
151
|
+
s.stepsTotal = totalSteps;
|
|
152
|
+
const w = 60;
|
|
153
|
+
const line = BOX.h.repeat(w);
|
|
154
|
+
console.log(`\n${CYAN}${BOX.tl}${line}${BOX.tr}${RESET}`);
|
|
155
|
+
console.log(boxLine(`${BOLD}${WHITE}${BG_BLUE} UAP ${RESET} ${BOLD}Universal Agent Protocol${RESET} ${DIM}v1.0.0${RESET}`, w));
|
|
156
|
+
console.log(boxLine(`${DIM}Session: ${s.sessionId} Started: ${new Date().toLocaleTimeString()}${RESET}`, w));
|
|
157
|
+
console.log(`${CYAN}${BOX.bl}${line}${BOX.br}${RESET}`);
|
|
158
|
+
}
|
|
159
|
+
// ─── Public API: Agents / Droids ───
|
|
160
|
+
export function agentRegister(id, name, type, parentId) {
|
|
161
|
+
const s = getStats();
|
|
162
|
+
const agent = {
|
|
163
|
+
id,
|
|
164
|
+
name,
|
|
165
|
+
type,
|
|
166
|
+
status: 'idle',
|
|
167
|
+
task: '',
|
|
168
|
+
parentId: parentId || null,
|
|
169
|
+
startTime: Date.now(),
|
|
170
|
+
endTime: null,
|
|
171
|
+
tokensUsed: 0,
|
|
172
|
+
};
|
|
173
|
+
s.agents.set(id, agent);
|
|
174
|
+
const typeLabel = type === 'droid'
|
|
175
|
+
? `${MAGENTA}DROID${RESET}`
|
|
176
|
+
: type === 'subagent'
|
|
177
|
+
? `${BLUE}AGENT${RESET}`
|
|
178
|
+
: `${CYAN}MAIN${RESET}`;
|
|
179
|
+
const parentStr = parentId ? ` ${DIM}(parent: ${parentId})${RESET}` : '';
|
|
180
|
+
console.log(`${typeLabel} ${BOLD}${name}${RESET} registered ${DIM}[${id}]${RESET}${parentStr}`);
|
|
181
|
+
}
|
|
182
|
+
export function agentStart(id, task) {
|
|
183
|
+
const s = getStats();
|
|
184
|
+
const agent = s.agents.get(id);
|
|
185
|
+
if (!agent)
|
|
186
|
+
return;
|
|
187
|
+
agent.status = 'working';
|
|
188
|
+
agent.task = task;
|
|
189
|
+
agent.startTime = Date.now();
|
|
190
|
+
const typeLabel = agent.type === 'droid' ? `${MAGENTA}[DROID]${RESET}` : `${BLUE}[AGENT]${RESET}`;
|
|
191
|
+
console.log(`${typeLabel} ${BOLD}${agent.name}${RESET} ${YELLOW}working${RESET} on: ${truncate(task, 50)}`);
|
|
192
|
+
}
|
|
193
|
+
export function agentProgress(id, message, tokensUsed) {
|
|
194
|
+
const s = getStats();
|
|
195
|
+
const agent = s.agents.get(id);
|
|
196
|
+
if (!agent)
|
|
197
|
+
return;
|
|
198
|
+
if (tokensUsed) {
|
|
199
|
+
agent.tokensUsed += tokensUsed;
|
|
200
|
+
s.tokensUsed += tokensUsed;
|
|
201
|
+
}
|
|
202
|
+
const dur = elapsedSince(agent.startTime);
|
|
203
|
+
const typeLabel = agent.type === 'droid' ? `${MAGENTA}[DROID]${RESET}` : `${BLUE}[AGENT]${RESET}`;
|
|
204
|
+
const tokenStr = tokensUsed
|
|
205
|
+
? ` ${DIM}(+${formatTokens(tokensUsed)} tokens, ${dur})${RESET}`
|
|
206
|
+
: ` ${DIM}(${dur})${RESET}`;
|
|
207
|
+
console.log(`${typeLabel} ${agent.name}: ${message}${tokenStr}`);
|
|
208
|
+
}
|
|
209
|
+
export function agentComplete(id, result) {
|
|
210
|
+
const s = getStats();
|
|
211
|
+
const agent = s.agents.get(id);
|
|
212
|
+
if (!agent)
|
|
213
|
+
return;
|
|
214
|
+
agent.status = 'done';
|
|
215
|
+
agent.endTime = Date.now();
|
|
216
|
+
const dur = elapsedSince(agent.startTime);
|
|
217
|
+
const typeLabel = agent.type === 'droid' ? `${MAGENTA}[DROID]${RESET}` : `${BLUE}[AGENT]${RESET}`;
|
|
218
|
+
const resStr = result ? `: ${truncate(result, 50)}` : '';
|
|
219
|
+
console.log(`${typeLabel} ${agent.name} ${GREEN}done${RESET} ${DIM}(${dur}, ${formatTokens(agent.tokensUsed)} tokens)${RESET}${resStr}`);
|
|
220
|
+
}
|
|
221
|
+
export function agentError(id, error) {
|
|
222
|
+
const s = getStats();
|
|
223
|
+
const agent = s.agents.get(id);
|
|
224
|
+
if (!agent)
|
|
225
|
+
return;
|
|
226
|
+
agent.status = 'error';
|
|
227
|
+
agent.endTime = Date.now();
|
|
228
|
+
s.errors++;
|
|
229
|
+
const typeLabel = agent.type === 'droid' ? `${MAGENTA}[DROID]${RESET}` : `${BLUE}[AGENT]${RESET}`;
|
|
230
|
+
console.log(`${typeLabel} ${agent.name} ${RED}error${RESET}: ${error}`);
|
|
231
|
+
}
|
|
232
|
+
// ─── Public API: Work Graph (Tasks) ───
|
|
233
|
+
export function taskCreate(id, title, parentId) {
|
|
234
|
+
const s = getStats();
|
|
235
|
+
const depth = parentId ? (s.tasks.get(parentId)?.depth ?? 0) + 1 : 0;
|
|
236
|
+
const task = {
|
|
237
|
+
id,
|
|
238
|
+
title,
|
|
239
|
+
status: 'pending',
|
|
240
|
+
assignedTo: null,
|
|
241
|
+
children: [],
|
|
242
|
+
parentId: parentId || null,
|
|
243
|
+
startTime: null,
|
|
244
|
+
endTime: null,
|
|
245
|
+
depth,
|
|
246
|
+
};
|
|
247
|
+
s.tasks.set(id, task);
|
|
248
|
+
if (parentId) {
|
|
249
|
+
const parent = s.tasks.get(parentId);
|
|
250
|
+
if (parent)
|
|
251
|
+
parent.children.push(id);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
s.rootTaskIds.push(id);
|
|
255
|
+
}
|
|
256
|
+
const indent = ' '.repeat(depth);
|
|
257
|
+
const connector = parentId ? `${DIM}${TREE.branch}${TREE.dash}${RESET} ` : '';
|
|
258
|
+
console.log(`${CYAN}[TASK+]${RESET} ${indent}${connector}${statusIcon('pending')} ${title} ${DIM}[${id}]${RESET}`);
|
|
259
|
+
}
|
|
260
|
+
export function taskAssign(taskId, agentId) {
|
|
261
|
+
const s = getStats();
|
|
262
|
+
const task = s.tasks.get(taskId);
|
|
263
|
+
const agent = s.agents.get(agentId);
|
|
264
|
+
if (!task || !agent)
|
|
265
|
+
return;
|
|
266
|
+
task.assignedTo = agentId;
|
|
267
|
+
const typeLabel = agent.type === 'droid' ? 'droid' : 'agent';
|
|
268
|
+
console.log(`${CYAN}[TASK]${RESET} ${' '.repeat(task.depth)}${statusIcon('pending')} ${truncate(task.title, 40)} ${DIM}-> ${typeLabel}:${agent.name}${RESET}`);
|
|
269
|
+
}
|
|
270
|
+
export function taskStart(taskId) {
|
|
271
|
+
const s = getStats();
|
|
272
|
+
const task = s.tasks.get(taskId);
|
|
273
|
+
if (!task)
|
|
274
|
+
return;
|
|
275
|
+
task.status = 'in_progress';
|
|
276
|
+
task.startTime = Date.now();
|
|
277
|
+
console.log(`${YELLOW}[TASK]${RESET} ${' '.repeat(task.depth)}${statusIcon('in_progress')} ${BOLD}${truncate(task.title, 45)}${RESET} ${DIM}started${RESET}`);
|
|
278
|
+
}
|
|
279
|
+
export function taskComplete(taskId) {
|
|
280
|
+
const s = getStats();
|
|
281
|
+
const task = s.tasks.get(taskId);
|
|
282
|
+
if (!task)
|
|
283
|
+
return;
|
|
284
|
+
task.status = 'done';
|
|
285
|
+
task.endTime = Date.now();
|
|
286
|
+
const dur = task.startTime ? elapsedSince(task.startTime) : '?';
|
|
287
|
+
console.log(`${GREEN}[TASK]${RESET} ${' '.repeat(task.depth)}${statusIcon('done')} ${truncate(task.title, 45)} ${GREEN}done${RESET} ${DIM}(${dur})${RESET}`);
|
|
288
|
+
}
|
|
289
|
+
export function taskFail(taskId, reason) {
|
|
290
|
+
const s = getStats();
|
|
291
|
+
const task = s.tasks.get(taskId);
|
|
292
|
+
if (!task)
|
|
293
|
+
return;
|
|
294
|
+
task.status = 'failed';
|
|
295
|
+
task.endTime = Date.now();
|
|
296
|
+
s.errors++;
|
|
297
|
+
console.log(`${RED}[TASK]${RESET} ${' '.repeat(task.depth)}${statusIcon('failed')} ${truncate(task.title, 40)} ${RED}failed${RESET}${reason ? `: ${reason}` : ''}`);
|
|
298
|
+
}
|
|
299
|
+
export function workGraph() {
|
|
300
|
+
const s = getStats();
|
|
301
|
+
if (s.tasks.size === 0)
|
|
302
|
+
return;
|
|
303
|
+
const totalTasks = s.tasks.size;
|
|
304
|
+
const doneTasks = [...s.tasks.values()].filter((t) => t.status === 'done').length;
|
|
305
|
+
const activeTasks = [...s.tasks.values()].filter((t) => t.status === 'in_progress').length;
|
|
306
|
+
const failedTasks = [...s.tasks.values()].filter((t) => t.status === 'failed').length;
|
|
307
|
+
console.log(`\n${BOLD}${CYAN}Work Graph${RESET} ${DIM}(${doneTasks}/${totalTasks} done, ${activeTasks} active${failedTasks > 0 ? `, ${RED}${failedTasks} failed${RESET}` : ''})${RESET}`);
|
|
308
|
+
const printTask = (taskId, prefix, isLast) => {
|
|
309
|
+
const task = s.tasks.get(taskId);
|
|
310
|
+
if (!task)
|
|
311
|
+
return;
|
|
312
|
+
const connector = isLast ? TREE.last : TREE.branch;
|
|
313
|
+
const agent = task.assignedTo ? s.agents.get(task.assignedTo) : null;
|
|
314
|
+
const agentStr = agent
|
|
315
|
+
? ` ${DIM}[${agent.type === 'droid' ? MAGENTA : BLUE}${agent.name}${RESET}${DIM}]${RESET}`
|
|
316
|
+
: '';
|
|
317
|
+
const durStr = task.startTime && task.status === 'in_progress'
|
|
318
|
+
? ` ${DIM}${elapsedSince(task.startTime)}${RESET}`
|
|
319
|
+
: '';
|
|
320
|
+
console.log(`${prefix}${DIM}${connector}${TREE.dash}${RESET} ${statusIcon(task.status)} ${task.status === 'in_progress' ? BOLD : ''}${truncate(task.title, 42)}${RESET}${agentStr}${durStr}`);
|
|
321
|
+
const childPrefix = prefix + (isLast ? ' ' : `${DIM}${TREE.pipe}${RESET} `);
|
|
322
|
+
for (let i = 0; i < task.children.length; i++) {
|
|
323
|
+
printTask(task.children[i], childPrefix, i === task.children.length - 1);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
for (let i = 0; i < s.rootTaskIds.length; i++) {
|
|
327
|
+
printTask(s.rootTaskIds[i], ' ', i === s.rootTaskIds.length - 1);
|
|
328
|
+
}
|
|
329
|
+
console.log('');
|
|
330
|
+
}
|
|
331
|
+
// ─── Public API: Skills ───
|
|
332
|
+
export function skillMatch(name, source, reason) {
|
|
333
|
+
const s = getStats();
|
|
334
|
+
const skill = { name, source, active: false, matchedAt: Date.now(), reason };
|
|
335
|
+
s.skills.set(name, skill);
|
|
336
|
+
console.log(`${GREEN}[SKILL]${RESET} ${BOLD}${name}${RESET} matched ${DIM}(${source})${RESET} -- ${ITALIC}${reason}${RESET}`);
|
|
337
|
+
}
|
|
338
|
+
export function skillActivate(name) {
|
|
339
|
+
const s = getStats();
|
|
340
|
+
const skill = s.skills.get(name);
|
|
341
|
+
if (skill)
|
|
342
|
+
skill.active = true;
|
|
343
|
+
console.log(`${GREEN}[SKILL]${RESET} ${WHITE}${BG_GREEN} ACTIVE ${RESET} ${BOLD}${name}${RESET}`);
|
|
344
|
+
}
|
|
345
|
+
export function skillDeactivate(name) {
|
|
346
|
+
const s = getStats();
|
|
347
|
+
const skill = s.skills.get(name);
|
|
348
|
+
if (skill)
|
|
349
|
+
skill.active = false;
|
|
350
|
+
console.log(`${DIM}[SKILL] ${name} deactivated${RESET}`);
|
|
351
|
+
}
|
|
352
|
+
export function showSkills() {
|
|
353
|
+
const s = getStats();
|
|
354
|
+
if (s.skills.size === 0) {
|
|
355
|
+
console.log(`${DIM}[SKILL] No skills matched this session${RESET}`);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
console.log(`\n${BOLD}${GREEN}Skills${RESET} ${DIM}(${s.skills.size} matched, ${[...s.skills.values()].filter((sk) => sk.active).length} active)${RESET}`);
|
|
359
|
+
for (const [, skill] of s.skills) {
|
|
360
|
+
const icon = skill.active ? `${WHITE}${BG_GREEN} ON ${RESET}` : `${DIM}OFF${RESET}`;
|
|
361
|
+
console.log(` ${icon} ${BOLD}${skill.name}${RESET} ${DIM}(${skill.source}) ${skill.reason}${RESET}`);
|
|
362
|
+
}
|
|
363
|
+
console.log('');
|
|
364
|
+
}
|
|
365
|
+
// ─── Public API: Patterns ───
|
|
366
|
+
export function patternMatch(id, name, weight, category) {
|
|
367
|
+
const s = getStats();
|
|
368
|
+
const pattern = {
|
|
369
|
+
id,
|
|
370
|
+
name,
|
|
371
|
+
weight,
|
|
372
|
+
active: false,
|
|
373
|
+
matchedAt: Date.now(),
|
|
374
|
+
category,
|
|
375
|
+
};
|
|
376
|
+
s.patterns.set(id, pattern);
|
|
377
|
+
const weightBar = '▓'.repeat(Math.round(weight * 10)) + '░'.repeat(10 - Math.round(weight * 10));
|
|
378
|
+
console.log(`${BLUE}[PATTERN]${RESET} ${BOLD}${name}${RESET} ${DIM}(${category})${RESET} weight: ${CYAN}${weightBar}${RESET} ${(weight * 100).toFixed(0)}%`);
|
|
379
|
+
}
|
|
380
|
+
export function patternActivate(id) {
|
|
381
|
+
const s = getStats();
|
|
382
|
+
const pattern = s.patterns.get(id);
|
|
383
|
+
if (pattern)
|
|
384
|
+
pattern.active = true;
|
|
385
|
+
const name = pattern?.name || id;
|
|
386
|
+
console.log(`${BLUE}[PATTERN]${RESET} ${WHITE}${BG_CYAN} ACTIVE ${RESET} ${BOLD}${name}${RESET}`);
|
|
387
|
+
}
|
|
388
|
+
export function showPatterns() {
|
|
389
|
+
const s = getStats();
|
|
390
|
+
if (s.patterns.size === 0) {
|
|
391
|
+
console.log(`${DIM}[PATTERN] No patterns matched this session${RESET}`);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const active = [...s.patterns.values()].filter((p) => p.active);
|
|
395
|
+
const inactive = [...s.patterns.values()].filter((p) => !p.active);
|
|
396
|
+
console.log(`\n${BOLD}${BLUE}Patterns${RESET} ${DIM}(${s.patterns.size} matched, ${active.length} active)${RESET}`);
|
|
397
|
+
for (const p of active) {
|
|
398
|
+
const weightBar = '▓'.repeat(Math.round(p.weight * 10)) + '░'.repeat(10 - Math.round(p.weight * 10));
|
|
399
|
+
console.log(` ${WHITE}${BG_CYAN} ON ${RESET} ${BOLD}${p.name}${RESET} ${DIM}(${p.category})${RESET} ${CYAN}${weightBar}${RESET}`);
|
|
400
|
+
}
|
|
401
|
+
for (const p of inactive) {
|
|
402
|
+
const weightBar = '▓'.repeat(Math.round(p.weight * 10)) + '░'.repeat(10 - Math.round(p.weight * 10));
|
|
403
|
+
console.log(` ${DIM}OFF ${p.name} (${p.category}) ${weightBar}${RESET}`);
|
|
404
|
+
}
|
|
405
|
+
console.log('');
|
|
406
|
+
}
|
|
407
|
+
// ─── Public API: Deploy Windows ───
|
|
408
|
+
export function deployQueue(id, type, target, message) {
|
|
409
|
+
const s = getStats();
|
|
410
|
+
const action = {
|
|
411
|
+
id,
|
|
412
|
+
type,
|
|
413
|
+
target,
|
|
414
|
+
message,
|
|
415
|
+
status: 'queued',
|
|
416
|
+
queuedAt: Date.now(),
|
|
417
|
+
executedAt: null,
|
|
418
|
+
batchId: null,
|
|
419
|
+
};
|
|
420
|
+
s.deploys.set(id, action);
|
|
421
|
+
console.log(`${YELLOW}[DEPLOY]${RESET} ${DIM}queued${RESET} ${type} -> ${target} ${DIM}"${truncate(message, 40)}"${RESET}`);
|
|
422
|
+
}
|
|
423
|
+
export function deployBatch(actionIds, batchId) {
|
|
424
|
+
const s = getStats();
|
|
425
|
+
const batched = [];
|
|
426
|
+
for (const id of actionIds) {
|
|
427
|
+
const action = s.deploys.get(id);
|
|
428
|
+
if (action) {
|
|
429
|
+
action.status = 'batched';
|
|
430
|
+
action.batchId = batchId;
|
|
431
|
+
batched.push(action.type);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
console.log(`${YELLOW}[DEPLOY]${RESET} ${BOLD}batch ${batchId}${RESET}: ${batched.length} actions (${batched.join(', ')}) ${DIM}squashed${RESET}`);
|
|
435
|
+
}
|
|
436
|
+
export function deployExecute(batchId) {
|
|
437
|
+
const s = getStats();
|
|
438
|
+
const actions = [...s.deploys.values()].filter((a) => a.batchId === batchId);
|
|
439
|
+
for (const action of actions) {
|
|
440
|
+
action.status = 'executing';
|
|
441
|
+
}
|
|
442
|
+
console.log(`${YELLOW}[DEPLOY]${RESET} ${BOLD}executing${RESET} batch ${batchId} (${actions.length} actions)`);
|
|
443
|
+
}
|
|
444
|
+
export function deployComplete(id, success) {
|
|
445
|
+
const s = getStats();
|
|
446
|
+
const action = s.deploys.get(id);
|
|
447
|
+
if (!action)
|
|
448
|
+
return;
|
|
449
|
+
action.status = success ? 'done' : 'failed';
|
|
450
|
+
action.executedAt = Date.now();
|
|
451
|
+
const dur = elapsedSince(action.queuedAt);
|
|
452
|
+
const icon = success ? `${GREEN}done${RESET}` : `${RED}failed${RESET}`;
|
|
453
|
+
console.log(`${YELLOW}[DEPLOY]${RESET} ${action.type} -> ${action.target} ${icon} ${DIM}(${dur} from queue)${RESET}`);
|
|
454
|
+
}
|
|
455
|
+
export function showDeployWindow() {
|
|
456
|
+
const s = getStats();
|
|
457
|
+
if (s.deploys.size === 0) {
|
|
458
|
+
console.log(`${DIM}[DEPLOY] No deploy actions this session${RESET}`);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
const queued = [...s.deploys.values()].filter((a) => a.status === 'queued');
|
|
462
|
+
const batched = [...s.deploys.values()].filter((a) => a.status === 'batched');
|
|
463
|
+
const executing = [...s.deploys.values()].filter((a) => a.status === 'executing');
|
|
464
|
+
const done = [...s.deploys.values()].filter((a) => a.status === 'done');
|
|
465
|
+
const failed = [...s.deploys.values()].filter((a) => a.status === 'failed');
|
|
466
|
+
console.log(`\n${BOLD}${YELLOW}Deploy Window${RESET} ${DIM}(${s.deploys.size} total)${RESET}`);
|
|
467
|
+
if (queued.length > 0)
|
|
468
|
+
console.log(` ${DIM}○${RESET} ${queued.length} queued`);
|
|
469
|
+
if (batched.length > 0)
|
|
470
|
+
console.log(` ${YELLOW}◉${RESET} ${batched.length} batched`);
|
|
471
|
+
if (executing.length > 0)
|
|
472
|
+
console.log(` ${CYAN}▶${RESET} ${executing.length} executing`);
|
|
473
|
+
if (done.length > 0)
|
|
474
|
+
console.log(` ${GREEN}●${RESET} ${done.length} done`);
|
|
475
|
+
if (failed.length > 0)
|
|
476
|
+
console.log(` ${RED}✗${RESET} ${failed.length} failed`);
|
|
477
|
+
// Show savings from batching
|
|
478
|
+
const batchIds = new Set([...s.deploys.values()].map((a) => a.batchId).filter(Boolean));
|
|
479
|
+
if (batchIds.size > 0) {
|
|
480
|
+
const totalActions = s.deploys.size;
|
|
481
|
+
const batchCount = batchIds.size;
|
|
482
|
+
const savedOps = totalActions - batchCount;
|
|
483
|
+
if (savedOps > 0) {
|
|
484
|
+
console.log(` ${GREEN}Batching saved ${savedOps} redundant operations${RESET} (${totalActions} -> ${batchCount} batches)`);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
console.log('');
|
|
488
|
+
}
|
|
489
|
+
// ─── Public API: Cost Tracking & Savings ───
|
|
490
|
+
const MODEL_COSTS = {
|
|
491
|
+
// Cost per 1M tokens (USD)
|
|
492
|
+
'claude-opus-4': { input: 15.0, output: 75.0 },
|
|
493
|
+
'claude-sonnet-4': { input: 3.0, output: 15.0 },
|
|
494
|
+
'claude-haiku': { input: 0.25, output: 1.25 },
|
|
495
|
+
'gpt-4o': { input: 2.5, output: 10.0 },
|
|
496
|
+
'gpt-4o-mini': { input: 0.15, output: 0.6 },
|
|
497
|
+
'qwen3.5': { input: 0.0, output: 0.0 }, // local model, no API cost
|
|
498
|
+
local: { input: 0.0, output: 0.0 },
|
|
499
|
+
};
|
|
500
|
+
export function costTrack(model, inputTokens, outputTokens, operation) {
|
|
501
|
+
const s = getStats();
|
|
502
|
+
const rates = MODEL_COSTS[model] || MODEL_COSTS['claude-sonnet-4']; // default assumption
|
|
503
|
+
const costUsd = (inputTokens * rates.input + outputTokens * rates.output) / 1_000_000;
|
|
504
|
+
const entry = {
|
|
505
|
+
model,
|
|
506
|
+
inputTokens,
|
|
507
|
+
outputTokens,
|
|
508
|
+
costUsd,
|
|
509
|
+
timestamp: Date.now(),
|
|
510
|
+
operation,
|
|
511
|
+
};
|
|
512
|
+
s.costs.push(entry);
|
|
513
|
+
s.totalCostUsd += costUsd;
|
|
514
|
+
// Estimate what it would have cost without UAP optimizations (no caching, no token savings, no batching)
|
|
515
|
+
const overhead = 1.4; // typical 40% overhead without memory/pattern caching
|
|
516
|
+
s.estimatedCostWithoutUap += costUsd * overhead;
|
|
517
|
+
if (costUsd > 0.001) {
|
|
518
|
+
console.log(`${BLUE}[COST]${RESET} $${costUsd.toFixed(4)} ${DIM}(${model}: ${formatTokens(inputTokens)}in/${formatTokens(outputTokens)}out) ${operation}${RESET}`);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
export function costFromSavedTokens(savedTokens, model) {
|
|
522
|
+
const s = getStats();
|
|
523
|
+
const rates = MODEL_COSTS[model || 'claude-sonnet-4'];
|
|
524
|
+
// Assume saved tokens are roughly 70% input, 30% output
|
|
525
|
+
const savedCost = (savedTokens * 0.7 * rates.input + savedTokens * 0.3 * rates.output) / 1_000_000;
|
|
526
|
+
s.estimatedCostWithoutUap += savedCost;
|
|
527
|
+
}
|
|
528
|
+
export function showCostSummary() {
|
|
529
|
+
const s = getStats();
|
|
530
|
+
const savedUsd = s.estimatedCostWithoutUap - s.totalCostUsd;
|
|
531
|
+
const savingsPct = s.estimatedCostWithoutUap > 0 ? Math.round((savedUsd / s.estimatedCostWithoutUap) * 100) : 0;
|
|
532
|
+
console.log(`\n${BOLD}${BLUE}Cost Summary${RESET}`);
|
|
533
|
+
console.log(` Session cost: ${BOLD}$${s.totalCostUsd.toFixed(4)}${RESET}`);
|
|
534
|
+
if (s.estimatedCostWithoutUap > s.totalCostUsd) {
|
|
535
|
+
console.log(` Without UAP: ${DIM}$${s.estimatedCostWithoutUap.toFixed(4)}${RESET}`);
|
|
536
|
+
console.log(` ${GREEN}Saved: $${savedUsd.toFixed(4)} (${savingsPct}%)${RESET}`);
|
|
537
|
+
}
|
|
538
|
+
if (s.costs.length > 0) {
|
|
539
|
+
// Per-model breakdown
|
|
540
|
+
const byModel = new Map();
|
|
541
|
+
for (const c of s.costs) {
|
|
542
|
+
const existing = byModel.get(c.model) || { cost: 0, tokens: 0 };
|
|
543
|
+
existing.cost += c.costUsd;
|
|
544
|
+
existing.tokens += c.inputTokens + c.outputTokens;
|
|
545
|
+
byModel.set(c.model, existing);
|
|
546
|
+
}
|
|
547
|
+
console.log(` ${DIM}By model:${RESET}`);
|
|
548
|
+
for (const [model, data] of byModel) {
|
|
549
|
+
console.log(` ${model}: $${data.cost.toFixed(4)} (${formatTokens(data.tokens)} tokens)`);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
console.log('');
|
|
553
|
+
}
|
|
554
|
+
// ─── Public API: Memory, Tokens, Tools, Policy (existing) ───
|
|
555
|
+
export function memoryLookup(query, hits, topMatch, similarity) {
|
|
556
|
+
const s = getStats();
|
|
557
|
+
if (hits > 0) {
|
|
558
|
+
s.memoryHits += hits;
|
|
559
|
+
console.log(`${MAGENTA}[MEMORY]${RESET} ${GREEN}${hits} match${hits > 1 ? 'es' : ''}${RESET} for "${truncate(query, 40)}"`);
|
|
560
|
+
if (topMatch) {
|
|
561
|
+
const simStr = similarity ? ` ${DIM}(${(similarity * 100).toFixed(0)}% match)${RESET}` : '';
|
|
562
|
+
console.log(` ${DIM}${BOX.bl}${BOX.h}${RESET} ${truncate(topMatch, 70)}${simStr}`);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
s.memoryMisses++;
|
|
567
|
+
console.log(`${MAGENTA}[MEMORY]${RESET} ${DIM}No matches for "${truncate(query, 40)}"${RESET}`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
export function tokenUsage(used, saved, source) {
|
|
571
|
+
const s = getStats();
|
|
572
|
+
s.tokensUsed += used;
|
|
573
|
+
s.tokensSaved += saved;
|
|
574
|
+
const srcStr = source ? ` ${DIM}via ${source}${RESET}` : '';
|
|
575
|
+
if (saved > 0) {
|
|
576
|
+
console.log(`${BLUE}[TOKENS]${RESET} Used: ${formatTokens(used)} ${GREEN}Saved: ${formatTokens(saved)}${RESET}${srcStr}`);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
console.log(`${BLUE}[TOKENS]${RESET} Used: ${formatTokens(used)}${srcStr}`);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
export function toolCall(name, duration, result) {
|
|
583
|
+
const s = getStats();
|
|
584
|
+
s.toolCalls++;
|
|
585
|
+
const durStr = duration ? ` ${DIM}(${duration}ms)${RESET}` : '';
|
|
586
|
+
const resStr = result ? ` ${DIM}-> ${truncate(result, 50)}${RESET}` : '';
|
|
587
|
+
console.log(`${YELLOW}[TOOL]${RESET} ${name}${durStr}${resStr}`);
|
|
588
|
+
}
|
|
589
|
+
export function policyCheck(policyName, allowed, reason) {
|
|
590
|
+
const s = getStats();
|
|
591
|
+
s.policyChecks++;
|
|
592
|
+
if (!allowed) {
|
|
593
|
+
s.policyBlocks++;
|
|
594
|
+
console.log(`${RED}[POLICY BLOCK]${RESET} ${BOLD}${policyName}${RESET}: ${reason || 'Violation detected'}`);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
console.log(`${GREEN}[POLICY OK]${RESET} ${policyName}${reason ? ` ${DIM}(${reason})${RESET}` : ''}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
export function fileBackup(originalPath, backupPath) {
|
|
601
|
+
const s = getStats();
|
|
602
|
+
s.filesBackedUp++;
|
|
603
|
+
console.log(`${CYAN}[BACKUP]${RESET} ${originalPath} ${DIM}->${RESET} ${backupPath}`);
|
|
604
|
+
}
|
|
605
|
+
// ─── Public API: Steps ───
|
|
606
|
+
export function stepStart(stepName, stepNum) {
|
|
607
|
+
const s = getStats();
|
|
608
|
+
s.currentStep = stepName;
|
|
609
|
+
if (stepNum !== undefined) {
|
|
610
|
+
const progress = progressBar(stepNum - 1, s.stepsTotal);
|
|
611
|
+
const etaStr = s.stepsCompleted > 0 ? ` ${DIM}ETA: ${eta()}${RESET}` : '';
|
|
612
|
+
console.log(`\n${BOLD}[${stepNum}/${s.stepsTotal}]${RESET} ${stepName} ${progress}${etaStr}`);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
console.log(`\n${BOLD}[STEP]${RESET} ${stepName}`);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
export function stepComplete(_stepName) {
|
|
619
|
+
const s = getStats();
|
|
620
|
+
s.stepsCompleted++;
|
|
621
|
+
console.log(` ${GREEN}Done${RESET} ${DIM}(${elapsed()})${RESET}`);
|
|
622
|
+
}
|
|
623
|
+
export function error(message, context) {
|
|
624
|
+
const s = getStats();
|
|
625
|
+
s.errors++;
|
|
626
|
+
console.log(`${RED}[ERROR]${RESET} ${message}${context ? ` ${DIM}(${context})${RESET}` : ''}`);
|
|
627
|
+
}
|
|
628
|
+
export function warn(message) {
|
|
629
|
+
console.log(`${YELLOW}[WARN]${RESET} ${message}`);
|
|
630
|
+
}
|
|
631
|
+
export function info(message) {
|
|
632
|
+
console.log(`${CYAN}[INFO]${RESET} ${message}`);
|
|
633
|
+
}
|
|
634
|
+
// ─── Public API: Session Summary ───
|
|
635
|
+
export function sessionSummary() {
|
|
636
|
+
const s = getStats();
|
|
637
|
+
const w = 62;
|
|
638
|
+
const line = BOX.h.repeat(w);
|
|
639
|
+
const totalTokens = s.tokensUsed + s.tokensSaved;
|
|
640
|
+
const savingsPct = totalTokens > 0 ? Math.round((s.tokensSaved / totalTokens) * 100) : 0;
|
|
641
|
+
const activeAgents = [...s.agents.values()].filter((a) => a.status === 'working').length;
|
|
642
|
+
const doneAgents = [...s.agents.values()].filter((a) => a.status === 'done').length;
|
|
643
|
+
const totalAgents = s.agents.size;
|
|
644
|
+
const activeSkills = [...s.skills.values()].filter((sk) => sk.active).length;
|
|
645
|
+
const activePatterns = [...s.patterns.values()].filter((p) => p.active).length;
|
|
646
|
+
const doneTasks = [...s.tasks.values()].filter((t) => t.status === 'done').length;
|
|
647
|
+
const totalTasks = s.tasks.size;
|
|
648
|
+
console.log(`\n${CYAN}${BOX.tl}${line}${BOX.tr}${RESET}`);
|
|
649
|
+
console.log(boxLine(`${BOLD}${WHITE}${BG_GREEN} UAP SESSION SUMMARY ${RESET} ${DIM}Session ${s.sessionId}${RESET}`, w));
|
|
650
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
651
|
+
// Time & Tokens
|
|
652
|
+
console.log(boxLine(`${BOLD}Duration:${RESET} ${elapsed()}`, w));
|
|
653
|
+
console.log(boxLine(`${BOLD}Tokens Used:${RESET} ${formatTokens(s.tokensUsed)}`, w));
|
|
654
|
+
console.log(boxLine(`${BOLD}Tokens Saved:${RESET} ${GREEN}${formatTokens(s.tokensSaved)} (${savingsPct}%)${RESET}`, w));
|
|
655
|
+
// Agents
|
|
656
|
+
if (totalAgents > 0) {
|
|
657
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
658
|
+
console.log(boxLine(`${BOLD}Agents:${RESET} ${totalAgents} total (${doneAgents} done, ${activeAgents} active)`, w));
|
|
659
|
+
for (const [, agent] of s.agents) {
|
|
660
|
+
const icon = statusIcon(agent.status);
|
|
661
|
+
const typeTag = agent.type === 'droid'
|
|
662
|
+
? `${MAGENTA}D${RESET}`
|
|
663
|
+
: agent.type === 'subagent'
|
|
664
|
+
? `${BLUE}S${RESET}`
|
|
665
|
+
: `${CYAN}M${RESET}`;
|
|
666
|
+
const tokStr = agent.tokensUsed > 0 ? ` ${DIM}${formatTokens(agent.tokensUsed)}t${RESET}` : '';
|
|
667
|
+
console.log(boxLine(` ${icon} ${typeTag} ${agent.name}${tokStr}`, w));
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
// Tasks
|
|
671
|
+
if (totalTasks > 0) {
|
|
672
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
673
|
+
console.log(boxLine(`${BOLD}Tasks:${RESET} ${doneTasks}/${totalTasks} ${progressBar(doneTasks, totalTasks, 12)}`, w));
|
|
674
|
+
}
|
|
675
|
+
// Skills & Patterns
|
|
676
|
+
if (s.skills.size > 0 || s.patterns.size > 0) {
|
|
677
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
678
|
+
if (s.skills.size > 0) {
|
|
679
|
+
console.log(boxLine(`${BOLD}Skills:${RESET} ${activeSkills}/${s.skills.size} active`, w));
|
|
680
|
+
}
|
|
681
|
+
if (s.patterns.size > 0) {
|
|
682
|
+
console.log(boxLine(`${BOLD}Patterns:${RESET} ${activePatterns}/${s.patterns.size} active`, w));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
// Deploy
|
|
686
|
+
if (s.deploys.size > 0) {
|
|
687
|
+
const deployDone = [...s.deploys.values()].filter((a) => a.status === 'done').length;
|
|
688
|
+
const deployFailed = [...s.deploys.values()].filter((a) => a.status === 'failed').length;
|
|
689
|
+
const batchIds = new Set([...s.deploys.values()].map((a) => a.batchId).filter(Boolean));
|
|
690
|
+
const savedOps = s.deploys.size - batchIds.size;
|
|
691
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
692
|
+
console.log(boxLine(`${BOLD}Deploys:${RESET} ${deployDone}/${s.deploys.size} done${deployFailed > 0 ? ` ${RED}(${deployFailed} failed)${RESET}` : ''}`, w));
|
|
693
|
+
if (savedOps > 0) {
|
|
694
|
+
console.log(boxLine(`${BOLD}Batch Savings:${RESET} ${GREEN}${savedOps} ops saved${RESET} (${s.deploys.size} -> ${batchIds.size} batches)`, w));
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
// Memory, Tools, Policy
|
|
698
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
699
|
+
console.log(boxLine(`${BOLD}Memory:${RESET} ${s.memoryHits} hits / ${s.memoryMisses} misses`, w));
|
|
700
|
+
console.log(boxLine(`${BOLD}Tool Calls:${RESET} ${s.toolCalls}`, w));
|
|
701
|
+
console.log(boxLine(`${BOLD}Policy:${RESET} ${s.policyChecks} checks, ${s.policyBlocks > 0 ? RED : GREEN}${s.policyBlocks} blocks${RESET}`, w));
|
|
702
|
+
console.log(boxLine(`${BOLD}Backups:${RESET} ${s.filesBackedUp} files`, w));
|
|
703
|
+
// Cost
|
|
704
|
+
if (s.totalCostUsd > 0 || s.estimatedCostWithoutUap > 0) {
|
|
705
|
+
const savedUsd = s.estimatedCostWithoutUap - s.totalCostUsd;
|
|
706
|
+
const costSavingsPct = s.estimatedCostWithoutUap > 0 ? Math.round((savedUsd / s.estimatedCostWithoutUap) * 100) : 0;
|
|
707
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
708
|
+
console.log(boxLine(`${BOLD}Session Cost:${RESET} $${s.totalCostUsd.toFixed(4)}`, w));
|
|
709
|
+
if (savedUsd > 0) {
|
|
710
|
+
console.log(boxLine(`${BOLD}Cost Saved:${RESET} ${GREEN}$${savedUsd.toFixed(4)} (${costSavingsPct}%)${RESET}`, w));
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (s.errors > 0) {
|
|
714
|
+
console.log(boxLine(`${DIM}${BOX.h.repeat(w - 2)}${RESET}`, w));
|
|
715
|
+
console.log(boxLine(`${BOLD}Errors:${RESET} ${RED}${s.errors}${RESET}`, w));
|
|
716
|
+
}
|
|
717
|
+
console.log(`${CYAN}${BOX.bl}${line}${BOX.br}${RESET}\n`);
|
|
718
|
+
}
|
|
719
|
+
// ─── Public API: Live Dashboard (compact) ───
|
|
720
|
+
export function liveStatus() {
|
|
721
|
+
const s = getStats();
|
|
722
|
+
const activeAgents = [...s.agents.values()].filter((a) => a.status === 'working');
|
|
723
|
+
const activeTasks = [...s.tasks.values()].filter((t) => t.status === 'in_progress');
|
|
724
|
+
const activeSkillNames = [...s.skills.values()].filter((sk) => sk.active).map((sk) => sk.name);
|
|
725
|
+
const activePatternNames = [...s.patterns.values()].filter((p) => p.active).map((p) => p.name);
|
|
726
|
+
const queuedDeploys = [...s.deploys.values()].filter((a) => a.status === 'queued' || a.status === 'batched');
|
|
727
|
+
const parts = [];
|
|
728
|
+
parts.push(`${DIM}${elapsed()}${RESET}`);
|
|
729
|
+
parts.push(`${BLUE}${formatTokens(s.tokensUsed)}t${RESET}`);
|
|
730
|
+
if (s.tokensSaved > 0)
|
|
731
|
+
parts.push(`${GREEN}-${formatTokens(s.tokensSaved)}${RESET}`);
|
|
732
|
+
if (s.totalCostUsd > 0)
|
|
733
|
+
parts.push(`${DIM}$${s.totalCostUsd.toFixed(3)}${RESET}`);
|
|
734
|
+
if (activeAgents.length > 0)
|
|
735
|
+
parts.push(`${YELLOW}${activeAgents.length} agents${RESET}`);
|
|
736
|
+
if (activeTasks.length > 0)
|
|
737
|
+
parts.push(`${CYAN}${activeTasks.length} tasks${RESET}`);
|
|
738
|
+
if (queuedDeploys.length > 0)
|
|
739
|
+
parts.push(`${YELLOW}${queuedDeploys.length} deploys queued${RESET}`);
|
|
740
|
+
if (activeSkillNames.length > 0)
|
|
741
|
+
parts.push(`${GREEN}skills:${activeSkillNames.join(',')}${RESET}`);
|
|
742
|
+
if (activePatternNames.length > 0)
|
|
743
|
+
parts.push(`${BLUE}patterns:${activePatternNames.slice(0, 2).join(',')}${activePatternNames.length > 2 ? '+' + (activePatternNames.length - 2) : ''}${RESET}`);
|
|
744
|
+
console.log(`${DIM}[UAP]${RESET} ${parts.join(' | ')}`);
|
|
745
|
+
}
|
|
746
|
+
// ─── File Backup Implementation ───
|
|
747
|
+
export function backupFile(filePath, projectRoot) {
|
|
748
|
+
const root = projectRoot || process.cwd();
|
|
749
|
+
const absPath = filePath.startsWith('/') ? filePath : join(root, filePath);
|
|
750
|
+
if (!existsSync(absPath))
|
|
751
|
+
return null;
|
|
752
|
+
const today = new Date().toISOString().split('T')[0];
|
|
753
|
+
const relativePath = absPath.startsWith(root) ? absPath.substring(root.length + 1) : filePath;
|
|
754
|
+
const backupDir = join(root, '.uap-backups', today, dirname(relativePath));
|
|
755
|
+
const backupPath = join(root, '.uap-backups', today, relativePath);
|
|
756
|
+
if (existsSync(backupPath))
|
|
757
|
+
return backupPath;
|
|
758
|
+
mkdirSync(backupDir, { recursive: true });
|
|
759
|
+
cpSync(absPath, backupPath);
|
|
760
|
+
fileBackup(relativePath, `.uap-backups/${today}/${relativePath}`);
|
|
761
|
+
return backupPath;
|
|
762
|
+
}
|
|
763
|
+
export async function backupDirectory(dirPath, projectRoot) {
|
|
764
|
+
const root = projectRoot || process.cwd();
|
|
765
|
+
const absPath = dirPath.startsWith('/') ? dirPath : join(root, dirPath);
|
|
766
|
+
if (!existsSync(absPath))
|
|
767
|
+
return 0;
|
|
768
|
+
const today = new Date().toISOString().split('T')[0];
|
|
769
|
+
const relativePath = absPath.startsWith(root) ? absPath.substring(root.length + 1) : dirPath;
|
|
770
|
+
const backupDir = join(root, '.uap-backups', today, relativePath);
|
|
771
|
+
if (existsSync(backupDir))
|
|
772
|
+
return 0;
|
|
773
|
+
mkdirSync(backupDir, { recursive: true });
|
|
774
|
+
cpSync(absPath, backupDir, { recursive: true });
|
|
775
|
+
const fs = await import('node:fs');
|
|
776
|
+
let count = 0;
|
|
777
|
+
try {
|
|
778
|
+
const countFiles = (dir) => {
|
|
779
|
+
let c = 0;
|
|
780
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
781
|
+
if (entry.isFile())
|
|
782
|
+
c++;
|
|
783
|
+
else if (entry.isDirectory())
|
|
784
|
+
c += countFiles(join(dir, entry.name));
|
|
785
|
+
}
|
|
786
|
+
return c;
|
|
787
|
+
};
|
|
788
|
+
count = countFiles(backupDir);
|
|
789
|
+
}
|
|
790
|
+
catch {
|
|
791
|
+
count = 1;
|
|
792
|
+
}
|
|
793
|
+
info(`Backed up directory: ${relativePath} (${count} files)`);
|
|
794
|
+
return count;
|
|
795
|
+
}
|
|
796
|
+
// ─── Inline Policy Management ───
|
|
797
|
+
export function showActivePolicies() {
|
|
798
|
+
console.log(`\n${BOLD}${MAGENTA}Active Policies:${RESET}`);
|
|
799
|
+
console.log(` ${GREEN}[ON]${RESET} IaC State Parity ${DIM}(REQUIRED)${RESET}`);
|
|
800
|
+
console.log(` ${GREEN}[ON]${RESET} Mandatory File Backup ${DIM}(REQUIRED)${RESET}`);
|
|
801
|
+
console.log(` ${DIM}[OFF]${RESET} Image & Asset Verification ${DIM}(RECOMMENDED)${RESET}`);
|
|
802
|
+
console.log(` ${DIM}Use: uap-policy list | uap-policy check -o <operation>${RESET}\n`);
|
|
803
|
+
}
|
|
804
|
+
export function resetStats() {
|
|
805
|
+
_stats = null;
|
|
806
|
+
}
|
|
807
|
+
//# sourceMappingURL=session-telemetry.js.map
|