pi-harness-runtime 0.9.22 → 0.10.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/CHANGELOG.md +49 -7
- package/README.md +51 -51
- package/footer-status.ts +84 -44
- package/harness/auto-compact.ts +1 -1
- package/harness/auto-quota-resume.ts +15 -12
- package/harness/autonomous-review.ts +88 -0
- package/harness/context-compact-orchestrator.ts +23 -23
- package/harness/context-window-manager.ts +5 -5
- package/harness/continue-prompt.ts +3 -3
- package/harness/e2e/minimax-quota-scraper.ts +10 -10
- package/harness/e2e/openai-quota-scraper.ts +442 -0
- package/harness/forked-summarizer.ts +4 -4
- package/harness/herdr-agents.ts +91 -0
- package/harness/index.ts +5 -5
- package/harness/loop-code-agent.ts +284 -0
- package/harness/loop-controller.ts +201 -0
- package/harness/loop-review-agent.ts +295 -0
- package/harness/loop-runtime.ts +21 -17
- package/harness/loop-types.ts +118 -0
- package/harness/notification-events.ts +3 -3
- package/harness/output-limit-handler.ts +1 -1
- package/harness/partial-recovery.ts +3 -3
- package/harness/session-memory.ts +5 -5
- package/index.ts +211 -80
- package/package.json +2 -2
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/a2a-adapter/src/types.ts +5 -5
- package/packages/auth/dist/minimax-browser-auth.d.ts +89 -0
- package/packages/auth/dist/minimax-browser-auth.d.ts.map +1 -0
- package/packages/auth/dist/minimax-browser-auth.js +890 -0
- package/packages/auth/dist/minimax-browser-auth.js.map +1 -0
- package/packages/auth/dist/run-minimax-auth.d.ts +19 -0
- package/packages/auth/dist/run-minimax-auth.d.ts.map +1 -0
- package/packages/auth/dist/run-minimax-auth.js +112 -0
- package/packages/auth/dist/run-minimax-auth.js.map +1 -0
- package/packages/auth/package.json +1 -1
- package/packages/auth/tsconfig.json +9 -0
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/dist/inbox.d.ts +3 -3
- package/packages/autonomous-runtime/dist/inbox.js +12 -12
- package/packages/autonomous-runtime/dist/lease.js +14 -14
- package/packages/autonomous-runtime/dist/types.js +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/autonomous-runtime/src/inbox.ts +12 -12
- package/packages/autonomous-runtime/src/lease.ts +15 -15
- package/packages/autonomous-runtime/src/types.ts +13 -13
- package/packages/autonomous-runtime/tsconfig.tsbuildinfo +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/dist/types.js +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/capability-registry/src/types.ts +5 -5
- package/packages/checkpoint/README.md +6 -6
- package/packages/checkpoint/dist/differ.js +2 -2
- package/packages/checkpoint/dist/engine.js +3 -3
- package/packages/checkpoint/dist/index.js +5 -5
- package/packages/checkpoint/dist/storage.js +3 -3
- package/packages/checkpoint/dist/types.js +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/checkpoint/src/differ.ts +2 -2
- package/packages/checkpoint/src/engine.ts +3 -3
- package/packages/checkpoint/src/index.ts +5 -5
- package/packages/checkpoint/src/storage.ts +3 -3
- package/packages/checkpoint/src/types.ts +10 -10
- package/packages/checkpoint/tsconfig.tsbuildinfo +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
- package/packages/clipboard/dist/src/clipboard.js +15 -7
- package/packages/clipboard/dist/src/clipboard.js.map +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard/src/clipboard.ts +16 -9
- package/packages/code-generation/README.md +13 -13
- package/packages/code-generation/dist/faker.js +4 -4
- package/packages/code-generation/dist/generator.js +3 -3
- package/packages/code-generation/dist/index.js +3 -3
- package/packages/code-generation/dist/templates/registry.js +1 -1
- package/packages/code-generation/dist/types.js +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-generation/src/faker.ts +5 -5
- package/packages/code-generation/src/generator.ts +4 -4
- package/packages/code-generation/src/index.ts +3 -3
- package/packages/code-generation/src/templates/registry.ts +1 -1
- package/packages/code-generation/src/types.ts +10 -10
- package/packages/code-generation/tsconfig.tsbuildinfo +1 -1
- package/packages/code-review/README.md +13 -13
- package/packages/code-review/dist/engine.js +3 -3
- package/packages/code-review/dist/index.js +3 -3
- package/packages/code-review/dist/types.js +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/code-review/src/engine.ts +3 -3
- package/packages/code-review/src/index.ts +3 -3
- package/packages/code-review/src/types.ts +10 -10
- package/packages/code-review/tsconfig.tsbuildinfo +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/context-compiler/dist/compiler.js +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-compiler/src/compiler.ts +1 -1
- package/packages/context-compiler/src/types.ts +11 -11
- package/packages/context-compiler/test/context-compiler.test.ts +11 -11
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cookie-sanitizer/README.md +27 -27
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/cost-optimizer/src/types.ts +5 -5
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/dist/analyzer.js +7 -7
- package/packages/django-plugin/package.json +1 -1
- package/packages/django-plugin/src/analyzer.ts +7 -7
- package/packages/doc-generator/package.json +1 -1
- package/packages/evaluation-engine/dist/engine.js +9 -9
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-engine/src/engine.ts +9 -9
- package/packages/evaluation-engine/src/types.ts +3 -3
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/dist/src/herdr-bus.d.ts +121 -0
- package/packages/event-bus/dist/src/herdr-bus.d.ts.map +1 -0
- package/packages/event-bus/dist/src/herdr-bus.js +322 -0
- package/packages/event-bus/dist/src/herdr-bus.js.map +1 -0
- package/packages/event-bus/dist/src/index.d.ts +2 -0
- package/packages/event-bus/dist/src/index.d.ts.map +1 -1
- package/packages/event-bus/dist/src/index.js +1 -0
- package/packages/event-bus/dist/src/index.js.map +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-bus/src/herdr-bus.ts +525 -0
- package/packages/event-bus/src/index.ts +29 -0
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/dist/replay.js +7 -7
- package/packages/experience-replay/package.json +1 -1
- package/packages/experience-replay/src/replay.ts +7 -7
- package/packages/experience-replay/src/types.ts +5 -5
- package/packages/feedback-collector/package.json +1 -1
- package/packages/framework-detector/README.md +18 -18
- package/packages/framework-detector/dist/detector.js +3 -3
- package/packages/framework-detector/dist/index.js +3 -3
- package/packages/framework-detector/dist/signatures/registry.js +24 -24
- package/packages/framework-detector/dist/types.js +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-detector/src/detector.ts +3 -3
- package/packages/framework-detector/src/index.ts +3 -3
- package/packages/framework-detector/src/signatures/registry.ts +24 -24
- package/packages/framework-detector/src/types.ts +7 -7
- package/packages/framework-detector/tsconfig.tsbuildinfo +1 -1
- package/packages/framework-plugin-sdk/README.md +23 -23
- package/packages/framework-plugin-sdk/dist/index.js +2 -2
- package/packages/framework-plugin-sdk/dist/manager.js +3 -3
- package/packages/framework-plugin-sdk/dist/types.js +2 -2
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/framework-plugin-sdk/src/index.ts +2 -2
- package/packages/framework-plugin-sdk/src/manager.ts +3 -3
- package/packages/framework-plugin-sdk/src/types.ts +10 -10
- package/packages/framework-plugin-sdk/tsconfig.tsbuildinfo +1 -1
- package/packages/frappe-plugin/dist/analyzer.js +8 -8
- package/packages/frappe-plugin/dist/types.js +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/frappe-plugin/src/analyzer.ts +8 -8
- package/packages/frappe-plugin/src/types.ts +10 -10
- package/packages/generic-web-plugin/dist/analyzer.js +5 -5
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/generic-web-plugin/src/analyzer.ts +5 -5
- package/packages/health-monitor/package.json +1 -1
- package/packages/health-monitor/src/monitor.ts +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/laravel-plugin/dist/analyzer.js +11 -11
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/laravel-plugin/src/analyzer.ts +11 -11
- package/packages/learning-engine/dist/engine.js +5 -5
- package/packages/learning-engine/dist/types.js +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/learning-engine/src/engine.ts +5 -5
- package/packages/learning-engine/src/types.ts +6 -6
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/dist/engine.js +8 -8
- package/packages/memory-engine/dist/types.js +2 -2
- package/packages/memory-engine/package.json +1 -1
- package/packages/memory-engine/src/engine.ts +8 -8
- package/packages/memory-engine/src/types.ts +9 -9
- package/packages/model-registry/package.json +1 -1
- package/packages/model-registry/src/types.ts +4 -4
- package/packages/nextjs-plugin/dist/analyzer.js +9 -9
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/nextjs-plugin/src/analyzer.ts +9 -9
- package/packages/notification/dist/notification-center.js +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/notification-center.ts +1 -1
- package/packages/observability/dist/alerts.js +2 -2
- package/packages/observability/dist/health.js +4 -4
- package/packages/observability/dist/index.js +6 -6
- package/packages/observability/dist/logger.js +7 -7
- package/packages/observability/dist/metrics.js +11 -11
- package/packages/observability/dist/tracer.js +3 -3
- package/packages/observability/dist/types.js +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/observability/src/alerts.ts +2 -2
- package/packages/observability/src/health.ts +4 -4
- package/packages/observability/src/index.ts +6 -6
- package/packages/observability/src/logger.ts +7 -7
- package/packages/observability/src/metrics.ts +11 -11
- package/packages/observability/src/tracer.ts +3 -3
- package/packages/observability/src/types.ts +7 -7
- package/packages/observability/test/observability.test.ts +4 -4
- package/packages/observability/tsconfig.tsbuildinfo +1 -1
- package/packages/performance-optimizer/dist/optimizer.js +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/performance-optimizer/src/optimizer.ts +1 -1
- package/packages/performance-optimizer/src/types.ts +4 -4
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/dist/analyzer.js +4 -4
- package/packages/project-analyzer/dist/index.js +8 -8
- package/packages/project-analyzer/dist/signals.js +3 -3
- package/packages/project-analyzer/dist/types.js +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-analyzer/src/analyzer.ts +4 -4
- package/packages/project-analyzer/src/index.ts +9 -9
- package/packages/project-analyzer/src/signals.ts +4 -4
- package/packages/project-analyzer/src/types.ts +15 -15
- package/packages/project-analyzer/test/index.test.ts +17 -17
- package/packages/project-analyzer/tsconfig.tsbuildinfo +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/dist/section-builder.js +1 -1
- package/packages/prompt-compiler/dist/types.js +3 -3
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-compiler/src/section-builder.ts +1 -1
- package/packages/prompt-compiler/src/types.ts +12 -12
- package/packages/prompt-compiler/test/prompt-compiler.test.ts +12 -12
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/dist/builder.js +1 -1
- package/packages/provider-adapter-sdk/dist/index.js +5 -5
- package/packages/provider-adapter-sdk/dist/registry.js +1 -1
- package/packages/provider-adapter-sdk/dist/tester.js +1 -1
- package/packages/provider-adapter-sdk/dist/types.js +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-adapter-sdk/src/builder.ts +1 -1
- package/packages/provider-adapter-sdk/src/index.ts +6 -6
- package/packages/provider-adapter-sdk/src/registry.ts +1 -1
- package/packages/provider-adapter-sdk/src/tester.ts +1 -1
- package/packages/provider-adapter-sdk/src/types.ts +5 -5
- package/packages/provider-adapter-sdk/tsconfig.tsbuildinfo +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-router/src/types.ts +4 -4
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/dist/deepagents-adapter.js +1 -1
- package/packages/providers/dist/provider-id.d.ts +5 -0
- package/packages/providers/dist/provider-id.d.ts.map +1 -1
- package/packages/providers/dist/provider-id.js +6 -1
- package/packages/providers/dist/provider-id.js.map +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/providers/src/deepagents-adapter.ts +1 -1
- package/packages/providers/src/provider-id.ts +6 -1
- package/packages/quota-manager/dist/tui-usage-monitor.d.ts.map +1 -1
- package/packages/quota-manager/dist/tui-usage-monitor.js +0 -6
- package/packages/quota-manager/dist/tui-usage-monitor.js.map +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/quota-manager/src/tui-usage-monitor.ts +0 -21
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/dist/analyzer.js +7 -7
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/react-vite-plugin/src/analyzer.ts +7 -7
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/dist/compiler.js +17 -17
- package/packages/requirement-compiler/dist/types.js +2 -2
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/requirement-compiler/src/compiler.ts +17 -17
- package/packages/requirement-compiler/src/types.ts +21 -21
- package/packages/requirement-compiler/test/requirement-compiler.test.ts +17 -17
- package/packages/runtime/dist/command-executor.js +1 -1
- package/packages/runtime/dist/local-runtime-agent.js +1 -1
- package/packages/runtime/dist/policy-engine.js +1 -1
- package/packages/runtime/dist/runtime-api.js +1 -1
- package/packages/runtime/dist/workspace-manager.js +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/runtime/src/command-executor.ts +1 -1
- package/packages/runtime/src/local-runtime-agent.ts +1 -1
- package/packages/runtime/src/policy-engine.ts +1 -1
- package/packages/runtime/src/runtime-api.ts +1 -1
- package/packages/runtime/src/workspace-manager.ts +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/README.md +18 -18
- package/packages/session/dist/history.js +3 -3
- package/packages/session/dist/index.js +5 -5
- package/packages/session/dist/manager.js +3 -3
- package/packages/session/dist/policy.js +2 -2
- package/packages/session/dist/store.js +2 -2
- package/packages/session/dist/types.js +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session/src/history.ts +3 -3
- package/packages/session/src/index.ts +5 -5
- package/packages/session/src/manager.ts +3 -3
- package/packages/session/src/policy.ts +4 -4
- package/packages/session/src/store.ts +3 -3
- package/packages/session/src/types.ts +10 -10
- package/packages/session/tsconfig.tsbuildinfo +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skill-registry/src/types.ts +4 -4
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/dist/compiler.js +7 -7
- package/packages/task-compiler/dist/decompose.js +11 -11
- package/packages/task-compiler/dist/file-scope.js +6 -6
- package/packages/task-compiler/dist/graph.js +6 -6
- package/packages/task-compiler/dist/index.js +2 -2
- package/packages/task-compiler/dist/types.js +5 -5
- package/packages/task-compiler/dist/validate.js +2 -2
- package/packages/task-compiler/dist/verification.js +2 -2
- package/packages/task-compiler/package.json +1 -1
- package/packages/task-compiler/src/command-policy.ts +1 -1
- package/packages/task-compiler/src/compiler.ts +7 -7
- package/packages/task-compiler/src/decompose.ts +11 -11
- package/packages/task-compiler/src/file-scope.ts +6 -6
- package/packages/task-compiler/src/graph.ts +6 -6
- package/packages/task-compiler/src/index.ts +3 -3
- package/packages/task-compiler/src/types.ts +14 -14
- package/packages/task-compiler/src/validate.ts +2 -2
- package/packages/task-compiler/src/verification.ts +2 -2
- package/packages/task-compiler/test/task-compiler.test.ts +10 -10
- package/packages/test-data-generator/README.md +13 -13
- package/packages/test-data-generator/dist/faker-adapter.js +4 -4
- package/packages/test-data-generator/dist/generator.js +3 -3
- package/packages/test-data-generator/dist/index.js +3 -3
- package/packages/test-data-generator/dist/types.js +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-data-generator/src/faker-adapter.ts +4 -4
- package/packages/test-data-generator/src/generator.ts +3 -3
- package/packages/test-data-generator/src/index.ts +3 -3
- package/packages/test-data-generator/src/types.ts +9 -9
- package/packages/test-data-generator/tsconfig.tsbuildinfo +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/types/src/agent-worker-types.ts +5 -5
- package/packages/types/src/runtime-types.ts +12 -12
- package/packages/types/tsconfig.tsbuildinfo +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/renderer.ts +7 -7
- package/skills/harness-runtime/SKILL.md +15 -15
- package/packages/dependency-analyzer/dist/analyzer.d.ts +0 -17
- package/packages/dependency-analyzer/dist/analyzer.d.ts.map +0 -1
- package/packages/dependency-analyzer/dist/analyzer.js +0 -106
- package/packages/dependency-analyzer/dist/analyzer.js.map +0 -1
- package/packages/dependency-analyzer/dist/imports.d.ts +0 -12
- package/packages/dependency-analyzer/dist/imports.d.ts.map +0 -1
- package/packages/dependency-analyzer/dist/imports.js +0 -73
- package/packages/dependency-analyzer/dist/imports.js.map +0 -1
- package/packages/dependency-analyzer/dist/index.d.ts +0 -4
- package/packages/dependency-analyzer/dist/index.d.ts.map +0 -1
- package/packages/dependency-analyzer/dist/index.js +0 -3
- package/packages/dependency-analyzer/dist/index.js.map +0 -1
- package/packages/dependency-analyzer/dist/test/analyzer.test.js +0 -37
- package/packages/dependency-analyzer/dist/types.d.ts +0 -28
- package/packages/dependency-analyzer/dist/types.d.ts.map +0 -1
- package/packages/dependency-analyzer/dist/types.js +0 -5
- package/packages/dependency-analyzer/dist/types.js.map +0 -1
- package/packages/intent-analyzer/dist/analyzer.d.ts +0 -13
- package/packages/intent-analyzer/dist/analyzer.d.ts.map +0 -1
- package/packages/intent-analyzer/dist/analyzer.js +0 -72
- package/packages/intent-analyzer/dist/analyzer.js.map +0 -1
- package/packages/intent-analyzer/dist/index.d.ts +0 -3
- package/packages/intent-analyzer/dist/index.d.ts.map +0 -1
- package/packages/intent-analyzer/dist/index.js +0 -2
- package/packages/intent-analyzer/dist/index.js.map +0 -1
- package/packages/intent-analyzer/dist/test/analyzer.test.js +0 -56
- package/packages/intent-analyzer/dist/types.d.ts +0 -26
- package/packages/intent-analyzer/dist/types.d.ts.map +0 -1
- package/packages/intent-analyzer/dist/types.js +0 -7
- package/packages/intent-analyzer/dist/types.js.map +0 -1
- package/packages/workspace-scanner/dist/detect.d.ts +0 -3
- package/packages/workspace-scanner/dist/detect.d.ts.map +0 -1
- package/packages/workspace-scanner/dist/detect.js +0 -58
- package/packages/workspace-scanner/dist/detect.js.map +0 -1
- package/packages/workspace-scanner/dist/git.d.ts +0 -7
- package/packages/workspace-scanner/dist/git.d.ts.map +0 -1
- package/packages/workspace-scanner/dist/git.js +0 -75
- package/packages/workspace-scanner/dist/git.js.map +0 -1
- package/packages/workspace-scanner/dist/index.d.ts +0 -5
- package/packages/workspace-scanner/dist/index.d.ts.map +0 -1
- package/packages/workspace-scanner/dist/index.js +0 -4
- package/packages/workspace-scanner/dist/index.js.map +0 -1
- package/packages/workspace-scanner/dist/scanner.d.ts +0 -11
- package/packages/workspace-scanner/dist/scanner.d.ts.map +0 -1
- package/packages/workspace-scanner/dist/scanner.js +0 -46
- package/packages/workspace-scanner/dist/scanner.js.map +0 -1
- package/packages/workspace-scanner/dist/test/scanner.test.js +0 -34
- package/packages/workspace-scanner/dist/types.d.ts +0 -35
- package/packages/workspace-scanner/dist/types.d.ts.map +0 -1
- package/packages/workspace-scanner/dist/types.js +0 -5
- package/packages/workspace-scanner/dist/types.js.map +0 -1
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Quota Scraper — RFC-0031+
|
|
3
|
+
*
|
|
4
|
+
* Scrapes quota data from ChatGPT Codex analytics page using Playwright.
|
|
5
|
+
* Uses cookie-based authentication to access the usage API.
|
|
6
|
+
*
|
|
7
|
+
* Target: https://chatgpt.com/backend-api/wham/usage
|
|
8
|
+
*
|
|
9
|
+
* Response shape:
|
|
10
|
+
* {
|
|
11
|
+
* "rate_limit": {
|
|
12
|
+
* "primary_window": {
|
|
13
|
+
* "used_percent": 7, // Weekly usage percentage (0-100)
|
|
14
|
+
* "limit_window_seconds": 604800, // 7-day window
|
|
15
|
+
* "reset_after_seconds": 491924, // Seconds until reset
|
|
16
|
+
* "reset_at": 1785649269 // Unix timestamp
|
|
17
|
+
* }
|
|
18
|
+
* },
|
|
19
|
+
* "credits": {
|
|
20
|
+
* "has_credits": false,
|
|
21
|
+
* "balance": "0"
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
import { homedir } from "node:os";
|
|
29
|
+
|
|
30
|
+
export interface OpenAIQuotaData {
|
|
31
|
+
provider: "openai";
|
|
32
|
+
/** Weekly used percentage (0-100) */
|
|
33
|
+
weeklyUsedPct: number;
|
|
34
|
+
/** When the weekly window resets (e.g., "5 days 16 hr") */
|
|
35
|
+
weeklyResetsAt: string;
|
|
36
|
+
/** Epoch ms when the weekly window resets — precise UTC timestamp */
|
|
37
|
+
weeklyResetsAtEpoch?: number;
|
|
38
|
+
/** Seconds until reset */
|
|
39
|
+
resetAfterSeconds?: number;
|
|
40
|
+
/** Credits balance (if available) */
|
|
41
|
+
creditBalance?: string;
|
|
42
|
+
/** Raw API response URL for diagnostics */
|
|
43
|
+
apiEndpoint?: string;
|
|
44
|
+
/** Timestamp of scrape */
|
|
45
|
+
scrapedAt: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Typed API response from /backend-api/wham/usage */
|
|
49
|
+
interface OpenAIUsageResponse {
|
|
50
|
+
route_rate_limits?: Array<{
|
|
51
|
+
rate_limit?: { limit_window_seconds?: number; used_percent?: number };
|
|
52
|
+
}>;
|
|
53
|
+
rate_limit?: {
|
|
54
|
+
primary_window?: {
|
|
55
|
+
used_percent?: number;
|
|
56
|
+
limit_window_seconds?: number;
|
|
57
|
+
reset_after_seconds?: number;
|
|
58
|
+
reset_at?: number;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
credits?: {
|
|
62
|
+
has_credits?: boolean;
|
|
63
|
+
balance?: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface OpenAIScraperConfig {
|
|
68
|
+
/** Path to Netscape-format cookie file */
|
|
69
|
+
cookieFile?: string;
|
|
70
|
+
/** Headless mode (default: true) */
|
|
71
|
+
headless?: boolean;
|
|
72
|
+
/** Timeout in ms (default: 60000) */
|
|
73
|
+
timeout?: number;
|
|
74
|
+
/** Chrome executable path (optional) */
|
|
75
|
+
chromePath?: string;
|
|
76
|
+
/** Suppress console output — for background/auto-fetch use */
|
|
77
|
+
quiet?: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const DEFAULT_COOKIE_FILE = join(homedir(), ".config", "openai-cookies.txt");
|
|
81
|
+
const USAGE_API = "https://chatgpt.com/backend-api/wham/usage";
|
|
82
|
+
const ANALYTICS_URL =
|
|
83
|
+
"https://chatgpt.com/codex/cloud/settings/analytics#usage";
|
|
84
|
+
|
|
85
|
+
interface NetscapeCookie {
|
|
86
|
+
name: string;
|
|
87
|
+
value: string;
|
|
88
|
+
domain: string;
|
|
89
|
+
path: string;
|
|
90
|
+
secure: boolean;
|
|
91
|
+
httpOnly: boolean;
|
|
92
|
+
expires?: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Load Netscape-format cookies from file
|
|
97
|
+
*/
|
|
98
|
+
function loadNetscapeCookies(path: string): NetscapeCookie[] {
|
|
99
|
+
const cookies: NetscapeCookie[] = [];
|
|
100
|
+
|
|
101
|
+
if (!existsSync(path)) {
|
|
102
|
+
return cookies;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const lines = readFileSync(path, "utf-8").split("\n");
|
|
106
|
+
for (const line of lines) {
|
|
107
|
+
if (!line || (line.startsWith("#") && !line.startsWith("#HttpOnly_"))) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let httpOnly = false;
|
|
112
|
+
let trimmed = line;
|
|
113
|
+
if (trimmed.startsWith("#HttpOnly_")) {
|
|
114
|
+
httpOnly = true;
|
|
115
|
+
trimmed = trimmed.slice("#HttpOnly_".length);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const parts = trimmed.split("\t");
|
|
119
|
+
if (parts.length < 7) continue;
|
|
120
|
+
|
|
121
|
+
const [domain, _flag, cookiePath, secure, expires, name, value] = parts;
|
|
122
|
+
cookies.push({
|
|
123
|
+
name,
|
|
124
|
+
value,
|
|
125
|
+
domain,
|
|
126
|
+
path: cookiePath || "/",
|
|
127
|
+
secure: secure.toUpperCase() === "TRUE",
|
|
128
|
+
httpOnly,
|
|
129
|
+
expires: parseInt(expires, 10) || undefined,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return cookies;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Format remaining seconds into human-readable string
|
|
138
|
+
*/
|
|
139
|
+
function formatRemainsSeconds(seconds: number): string {
|
|
140
|
+
if (seconds <= 0) return "soon";
|
|
141
|
+
|
|
142
|
+
const days = Math.floor(seconds / 86400);
|
|
143
|
+
const hr = Math.floor((seconds % 86400) / 3600);
|
|
144
|
+
const min = Math.floor((seconds % 3600) / 60);
|
|
145
|
+
|
|
146
|
+
const parts: string[] = [];
|
|
147
|
+
if (days > 0) parts.push(`${days} days`);
|
|
148
|
+
if (hr > 0) parts.push(`${hr} hr`);
|
|
149
|
+
if (min > 0 && days === 0) parts.push(`${min} min`);
|
|
150
|
+
|
|
151
|
+
return parts.join(" ") || "0 min";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* OpenAI Quota Scraper
|
|
156
|
+
*
|
|
157
|
+
* Uses Playwright to fetch quota data from ChatGPT Codex analytics.
|
|
158
|
+
*/
|
|
159
|
+
export class OpenAIQuotaScraper {
|
|
160
|
+
private readonly config: Required<OpenAIScraperConfig>;
|
|
161
|
+
|
|
162
|
+
constructor(config: OpenAIScraperConfig = {}) {
|
|
163
|
+
this.config = {
|
|
164
|
+
cookieFile: config.cookieFile ?? DEFAULT_COOKIE_FILE,
|
|
165
|
+
headless: config.headless ?? true,
|
|
166
|
+
timeout: config.timeout ?? 60000,
|
|
167
|
+
chromePath: config.chromePath ?? "",
|
|
168
|
+
quiet: config.quiet ?? false,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Set cookie file path
|
|
174
|
+
*/
|
|
175
|
+
setCookieFile(path: string): this {
|
|
176
|
+
this.config.cookieFile = path;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Enable/disable quiet mode
|
|
182
|
+
*/
|
|
183
|
+
setQuiet(quiet: boolean): this {
|
|
184
|
+
this.config.quiet = quiet;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Check if any cookie source exists
|
|
190
|
+
*/
|
|
191
|
+
hasCookieFile(): boolean {
|
|
192
|
+
return existsSync(this.config.cookieFile);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Scrape quota data using Playwright
|
|
197
|
+
*/
|
|
198
|
+
async scrape(): Promise<OpenAIQuotaData> {
|
|
199
|
+
const { chromium } = await import("playwright");
|
|
200
|
+
|
|
201
|
+
const cookies = loadNetscapeCookies(this.config.cookieFile);
|
|
202
|
+
if (cookies.length === 0) {
|
|
203
|
+
const dropHint = join(homedir(), ".pi-harness-runtime", "cookies");
|
|
204
|
+
const msg = `No OpenAI cookies found.
|
|
205
|
+
Drop your chatgpt.com cookies (Netscape or EditThisCookie JSON) into:
|
|
206
|
+
${dropHint}
|
|
207
|
+
Then run: bun run packages/cookie-sanitizer/src/sync.ts`;
|
|
208
|
+
if (!this.config.quiet) console.error(`[OpenAIQuotaScraper] ${msg}`);
|
|
209
|
+
throw new Error(msg);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Launch browser
|
|
213
|
+
if (!this.config.quiet) {
|
|
214
|
+
console.log("[OpenAIQuotaScraper] Launching browser...");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const browser = await chromium.launch({
|
|
218
|
+
executablePath: this.config.chromePath || undefined,
|
|
219
|
+
headless: this.config.headless,
|
|
220
|
+
args: ["--no-sandbox", "--disable-dev-shm-usage"],
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const context = await browser.newContext({
|
|
224
|
+
locale: "en-US",
|
|
225
|
+
viewport: { width: 1440, height: 900 },
|
|
226
|
+
userAgent:
|
|
227
|
+
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Inject cookies
|
|
231
|
+
await context.addCookies(
|
|
232
|
+
cookies.map((c) => ({
|
|
233
|
+
name: c.name,
|
|
234
|
+
value: c.value,
|
|
235
|
+
domain: c.domain,
|
|
236
|
+
path: c.path,
|
|
237
|
+
secure: c.secure,
|
|
238
|
+
httpOnly: c.httpOnly,
|
|
239
|
+
expires: c.expires,
|
|
240
|
+
})),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const page = await context.newPage();
|
|
244
|
+
|
|
245
|
+
// Capture API responses
|
|
246
|
+
let usageData: any = null;
|
|
247
|
+
|
|
248
|
+
page.on("response", async (response) => {
|
|
249
|
+
const url = response.url();
|
|
250
|
+
if (url.includes("/wham/usage")) {
|
|
251
|
+
try {
|
|
252
|
+
usageData = await response.json().catch(() => null);
|
|
253
|
+
} catch {
|
|
254
|
+
// Ignore parse errors
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
try {
|
|
260
|
+
// Navigate to analytics page
|
|
261
|
+
if (!this.config.quiet) {
|
|
262
|
+
console.log("[OpenAIQuotaScraper] Navigating to analytics page...");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
await page.goto(ANALYTICS_URL, {
|
|
266
|
+
waitUntil: "domcontentloaded",
|
|
267
|
+
timeout: this.config.timeout,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Wait for JS to render
|
|
271
|
+
await page.waitForTimeout(5000);
|
|
272
|
+
|
|
273
|
+
// Wait for network to settle
|
|
274
|
+
try {
|
|
275
|
+
await page.waitForLoadState("networkidle", { timeout: 10000 });
|
|
276
|
+
} catch {
|
|
277
|
+
// Network idle might not be achievable
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Check if redirected to login
|
|
281
|
+
const currentUrl = page.url();
|
|
282
|
+
if (currentUrl.includes("login") || currentUrl.includes("auth")) {
|
|
283
|
+
const msg =
|
|
284
|
+
"OpenAI cookies are expired or insufficient. Please re-export cookies from chatgpt.com.";
|
|
285
|
+
if (!this.config.quiet) console.error("[OpenAIQuotaScraper] " + msg);
|
|
286
|
+
throw new Error(msg);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Parse the usage data from the captured API response
|
|
290
|
+
if (!usageData) {
|
|
291
|
+
const msg = "Failed to capture usage data from API";
|
|
292
|
+
if (!this.config.quiet) console.error("[OpenAIQuotaScraper] " + msg);
|
|
293
|
+
throw new Error(msg);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Extract weekly usage from primary_window
|
|
297
|
+
const primaryWindow = usageData?.rate_limit?.primary_window;
|
|
298
|
+
const weeklyUsedPct = primaryWindow?.used_percent ?? 0;
|
|
299
|
+
const resetAfterSeconds = primaryWindow?.reset_after_seconds ?? 0;
|
|
300
|
+
const resetAtEpoch = primaryWindow?.reset_at;
|
|
301
|
+
const weeklyResetsAt = formatRemainsSeconds(resetAfterSeconds);
|
|
302
|
+
|
|
303
|
+
// Extract credits if available
|
|
304
|
+
const credits = usageData?.credits;
|
|
305
|
+
const creditBalance = credits?.has_credits ? credits.balance : undefined;
|
|
306
|
+
|
|
307
|
+
if (!this.config.quiet) {
|
|
308
|
+
console.log(
|
|
309
|
+
`[OpenAIQuotaScraper] Weekly usage: ${weeklyUsedPct}%, resets in ${weeklyResetsAt}`,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
provider: "openai",
|
|
315
|
+
weeklyUsedPct,
|
|
316
|
+
weeklyResetsAt,
|
|
317
|
+
weeklyResetsAtEpoch: resetAtEpoch ? resetAtEpoch * 1000 : undefined,
|
|
318
|
+
resetAfterSeconds,
|
|
319
|
+
creditBalance,
|
|
320
|
+
apiEndpoint: USAGE_API,
|
|
321
|
+
scrapedAt: new Date().toISOString(),
|
|
322
|
+
};
|
|
323
|
+
} finally {
|
|
324
|
+
await browser.close();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Quick scrape using direct API fetch (faster, but may fail without browser context)
|
|
330
|
+
*/
|
|
331
|
+
async scrapeDirect(): Promise<OpenAIQuotaData | null> {
|
|
332
|
+
const cookies = loadNetscapeCookies(this.config.cookieFile);
|
|
333
|
+
if (cookies.length === 0) return null;
|
|
334
|
+
|
|
335
|
+
const cookieHeader = cookies
|
|
336
|
+
.map((c) => `${c.name}=${encodeURIComponent(c.value)}`)
|
|
337
|
+
.join("; ");
|
|
338
|
+
|
|
339
|
+
try {
|
|
340
|
+
const response = await fetch(USAGE_API, {
|
|
341
|
+
headers: {
|
|
342
|
+
Cookie: cookieHeader,
|
|
343
|
+
Accept: "application/json",
|
|
344
|
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36",
|
|
345
|
+
Referer: "https://chatgpt.com/codex/cloud/settings/analytics",
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
if (!response.ok) {
|
|
350
|
+
if (!this.config.quiet) {
|
|
351
|
+
console.log(
|
|
352
|
+
`[OpenAIQuotaScraper] Direct API failed: ${response.status}`,
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const data = (await response.json()) as OpenAIUsageResponse;
|
|
359
|
+
const primaryWindow = data?.rate_limit?.primary_window;
|
|
360
|
+
const weeklyUsedPct = primaryWindow?.used_percent ?? 0;
|
|
361
|
+
const resetAfterSeconds = primaryWindow?.reset_after_seconds ?? 0;
|
|
362
|
+
const resetAtEpoch = primaryWindow?.reset_at;
|
|
363
|
+
const weeklyResetsAt = formatRemainsSeconds(resetAfterSeconds);
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
provider: "openai",
|
|
367
|
+
weeklyUsedPct,
|
|
368
|
+
weeklyResetsAt,
|
|
369
|
+
weeklyResetsAtEpoch: resetAtEpoch ? resetAtEpoch * 1000 : undefined,
|
|
370
|
+
resetAfterSeconds,
|
|
371
|
+
apiEndpoint: USAGE_API,
|
|
372
|
+
scrapedAt: new Date().toISOString(),
|
|
373
|
+
};
|
|
374
|
+
} catch (error) {
|
|
375
|
+
if (!this.config.quiet) {
|
|
376
|
+
console.warn(
|
|
377
|
+
"[OpenAIQuotaScraper] Direct API error:",
|
|
378
|
+
error instanceof Error ? error.message : String(error),
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Integration helper for index.ts
|
|
388
|
+
*/
|
|
389
|
+
export class OpenAIQuotaManager {
|
|
390
|
+
private scraper: OpenAIQuotaScraper;
|
|
391
|
+
private lastQuota?: OpenAIQuotaData;
|
|
392
|
+
private lastFetchTime = 0;
|
|
393
|
+
private readonly cacheDurationMs: number;
|
|
394
|
+
|
|
395
|
+
constructor(config: OpenAIScraperConfig & { cacheDurationMs?: number } = {}) {
|
|
396
|
+
this.scraper = new OpenAIQuotaScraper(config);
|
|
397
|
+
this.cacheDurationMs = config.cacheDurationMs ?? 5 * 60 * 1000; // 5 min default
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Get current quota (uses cache)
|
|
402
|
+
*/
|
|
403
|
+
async getQuota(forceRefresh = false): Promise<OpenAIQuotaData> {
|
|
404
|
+
const now = Date.now();
|
|
405
|
+
|
|
406
|
+
if (
|
|
407
|
+
!forceRefresh &&
|
|
408
|
+
this.lastQuota &&
|
|
409
|
+
now - this.lastFetchTime < this.cacheDurationMs
|
|
410
|
+
) {
|
|
411
|
+
return this.lastQuota;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Try direct API first (faster)
|
|
415
|
+
const directResult = await this.scraper.scrapeDirect();
|
|
416
|
+
if (directResult) {
|
|
417
|
+
this.lastQuota = directResult;
|
|
418
|
+
this.lastFetchTime = now;
|
|
419
|
+
return this.lastQuota;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Fall back to browser scrape
|
|
423
|
+
try {
|
|
424
|
+
this.lastQuota = await this.scraper.scrape();
|
|
425
|
+
this.lastFetchTime = now;
|
|
426
|
+
return this.lastQuota;
|
|
427
|
+
} catch (error) {
|
|
428
|
+
// Return cached value if available
|
|
429
|
+
if (this.lastQuota) {
|
|
430
|
+
return this.lastQuota;
|
|
431
|
+
}
|
|
432
|
+
throw error;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Check if quota is available
|
|
438
|
+
*/
|
|
439
|
+
isAvailable(): boolean {
|
|
440
|
+
return this.scraper.hasCookieFile();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
InvokeResult,
|
|
13
13
|
} from "../packages/types/src/runtime-types.js";
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// --- Types ------------------------------------------------------------------
|
|
16
16
|
|
|
17
17
|
export interface SummarizerConfig {
|
|
18
18
|
/** Model to use for summarization */
|
|
@@ -43,7 +43,7 @@ export interface InvokeOptions {
|
|
|
43
43
|
systemPrompt?: string;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// --- Default System Prompt ---------------------------------------------------
|
|
47
47
|
|
|
48
48
|
const DEFAULT_SUMMARY_SYSTEM = `You are a conversation summarizer. Your task is to create concise, accurate summaries that preserve essential context for continuing a conversation.
|
|
49
49
|
|
|
@@ -70,7 +70,7 @@ const DECISIONS_FOCUS = `Focus specifically on:
|
|
|
70
70
|
4. What constraints or requirements influenced the decisions?
|
|
71
71
|
5. Any lessons learned or trade-offs considered?`;
|
|
72
72
|
|
|
73
|
-
//
|
|
73
|
+
// --- Forked Summarizer ------------------------------------------------------
|
|
74
74
|
|
|
75
75
|
export class ForkedSummarizer {
|
|
76
76
|
private readonly config: SummarizerConfig;
|
|
@@ -283,7 +283,7 @@ Do not include verbatim tool results — summarize their outcomes instead.`;
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
//
|
|
286
|
+
// --- Convenience Factory ----------------------------------------------------
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
289
|
* Create a ForkedSummarizer with default config
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Herdr Agent Commands
|
|
3
|
+
*/
|
|
4
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import {
|
|
7
|
+
createHerdrBus,
|
|
8
|
+
getHerdrWorkspacePaths,
|
|
9
|
+
ensureHerdrWorkspace,
|
|
10
|
+
} from "../packages/event-bus/src/herdr-bus.js";
|
|
11
|
+
|
|
12
|
+
async function startReviewAgent(): Promise<void> {
|
|
13
|
+
console.log("[herdr:review] Starting review agent...");
|
|
14
|
+
const bus = createHerdrBus("review-agent");
|
|
15
|
+
ensureHerdrWorkspace();
|
|
16
|
+
bus.subscribe("code.written");
|
|
17
|
+
bus.startPolling(async (payload) => {
|
|
18
|
+
if (payload.topic === "code.written") {
|
|
19
|
+
const data = payload.data as { taskId: string; files: string[] };
|
|
20
|
+
console.log(
|
|
21
|
+
`[herdr:review] code.written: task=${data.taskId} files=${data.files.length}`,
|
|
22
|
+
);
|
|
23
|
+
for (const file of data.files ?? []) {
|
|
24
|
+
console.log(`[herdr:review] Reviewing: ${file}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
console.log(`[herdr:review] Workspace: ${bus.getWorkspace()}`);
|
|
29
|
+
await new Promise(() => {});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function startCodeAgent(): Promise<void> {
|
|
33
|
+
console.log("[herdr:code] Starting code agent...");
|
|
34
|
+
const bus = createHerdrBus("code-agent");
|
|
35
|
+
ensureHerdrWorkspace();
|
|
36
|
+
bus.subscribe("review.completed");
|
|
37
|
+
bus.startPolling(async (payload) => {
|
|
38
|
+
if (payload.topic === "review.completed") {
|
|
39
|
+
const data = payload.data as {
|
|
40
|
+
taskId: string;
|
|
41
|
+
reportFile: string;
|
|
42
|
+
status: string;
|
|
43
|
+
};
|
|
44
|
+
console.log(
|
|
45
|
+
`[herdr:code] Review done: task=${data.taskId} status=${data.status} report=${data.reportFile}`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
console.log(`[herdr:code] Workspace: ${bus.getWorkspace()}`);
|
|
50
|
+
await new Promise(() => {});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function showStatus(): void {
|
|
54
|
+
const paths = getHerdrWorkspacePaths();
|
|
55
|
+
console.log(`Workspace: ${paths.root}`);
|
|
56
|
+
const evPath = join(paths.root, "events.jsonl");
|
|
57
|
+
if (existsSync(evPath)) {
|
|
58
|
+
const lines = readFileSync(evPath, "utf-8")
|
|
59
|
+
.split("\n")
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.slice(-10);
|
|
62
|
+
console.log("Recent events:");
|
|
63
|
+
for (const line of lines) {
|
|
64
|
+
try {
|
|
65
|
+
const { topic, ts } = JSON.parse(line);
|
|
66
|
+
console.log(` ${ts} ${topic}`);
|
|
67
|
+
} catch {
|
|
68
|
+
/* skip */
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (existsSync(paths.subscriptions)) {
|
|
73
|
+
const agents = readdirSync(paths.subscriptions);
|
|
74
|
+
console.log(`Active agents: ${agents.join(", ") || "none"}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const [command] = process.argv.slice(2);
|
|
79
|
+
switch (command) {
|
|
80
|
+
case "review":
|
|
81
|
+
startReviewAgent().catch(console.error);
|
|
82
|
+
break;
|
|
83
|
+
case "code":
|
|
84
|
+
startCodeAgent().catch(console.error);
|
|
85
|
+
break;
|
|
86
|
+
case "status":
|
|
87
|
+
showStatus();
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
console.log("Usage: bun harness/herdr-agents.ts <review|code|status>");
|
|
91
|
+
}
|
package/harness/index.ts
CHANGED
|
@@ -178,7 +178,7 @@ export type { QuotaStatus, QuotaDisplayConfig } from "./e2e/quota-status.js";
|
|
|
178
178
|
// Project Detector
|
|
179
179
|
export { ProjectDetector } from "./project-detector/detector.js";
|
|
180
180
|
|
|
181
|
-
//
|
|
181
|
+
// --- RFC-0056: Performance Optimizer ----------------------------------------
|
|
182
182
|
export {
|
|
183
183
|
PerformanceOptimizer,
|
|
184
184
|
createPerformanceOptimizer,
|
|
@@ -189,7 +189,7 @@ export type {
|
|
|
189
189
|
PerformanceRecommendation,
|
|
190
190
|
} from "../packages/performance-optimizer/src/types.js";
|
|
191
191
|
|
|
192
|
-
//
|
|
192
|
+
// --- RFC-0057: Evaluation Engine -------------------------------------------
|
|
193
193
|
export {
|
|
194
194
|
EvaluationEngine,
|
|
195
195
|
createEvaluationEngine,
|
|
@@ -200,7 +200,7 @@ export type {
|
|
|
200
200
|
EvaluationFinding,
|
|
201
201
|
} from "../packages/evaluation-engine/src/types.js";
|
|
202
202
|
|
|
203
|
-
//
|
|
203
|
+
// --- RFC-0058: Learning Engine ---------------------------------------------
|
|
204
204
|
export {
|
|
205
205
|
LearningEngine,
|
|
206
206
|
createLearningEngine,
|
|
@@ -210,7 +210,7 @@ export type {
|
|
|
210
210
|
LearnedExperience,
|
|
211
211
|
} from "../packages/learning-engine/src/types.js";
|
|
212
212
|
|
|
213
|
-
//
|
|
213
|
+
// --- RFC-0059: Experience Replay ------------------------------------------
|
|
214
214
|
export {
|
|
215
215
|
ExperienceReplay,
|
|
216
216
|
createExperienceReplay,
|
|
@@ -220,7 +220,7 @@ export type {
|
|
|
220
220
|
ReplayResult,
|
|
221
221
|
} from "../packages/experience-replay/src/types.js";
|
|
222
222
|
|
|
223
|
-
//
|
|
223
|
+
// --- RFC-0060: Memory Engine -----------------------------------------------
|
|
224
224
|
export {
|
|
225
225
|
MemoryEngine,
|
|
226
226
|
createMemoryEngine,
|