pi-harness-runtime 1.1.166 → 1.1.167

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.
Files changed (118) hide show
  1. package/AGENTS.md +272 -0
  2. package/CLAUDE.md +77 -0
  3. package/SECURITY.md +21 -0
  4. package/TODO-todo-bd-sync.md +124 -0
  5. package/auto-resume-fix-prompt.md +189 -0
  6. package/harness/reports/PROJECT_STATE.md +342 -0
  7. package/harness/reports/PROVIDER_USAGE_RESEARCH.md +115 -0
  8. package/harness/reports/SESSION_STATUS.md +107 -0
  9. package/harness/skills-plan/2026-07-12-herdr-moo-skills-adaptation-plan.md +278 -0
  10. package/harness/skills-plan/2026-07-12-minimax-prompt-step1-sync.md +345 -0
  11. package/harness/skills-plan/2026-07-12-public-skill-export-and-sync-design.md +504 -0
  12. package/harness/skills-plan/ACTION-PLAN.md +108 -0
  13. package/package.json +3 -1
  14. package/packages/a2a-adapter/package.json +1 -1
  15. package/packages/agent-policy/dist/extension.d.ts +2 -1
  16. package/packages/agent-policy/dist/extension.d.ts.map +1 -1
  17. package/packages/agent-policy/dist/extension.js +8 -3
  18. package/packages/agent-policy/dist/extension.js.map +1 -1
  19. package/packages/agent-policy/dist/policy-loader.d.ts.map +1 -1
  20. package/packages/agent-policy/dist/policy-loader.js +14 -2
  21. package/packages/agent-policy/dist/policy-loader.js.map +1 -1
  22. package/packages/agent-policy/package.json +1 -1
  23. package/packages/agent-policy/src/extension.ts +9 -3
  24. package/packages/agent-policy/src/policy-loader.ts +16 -2
  25. package/packages/architecture-generator/package.json +1 -1
  26. package/packages/auth/package.json +1 -1
  27. package/packages/autonomous-refactor/package.json +1 -1
  28. package/packages/autonomous-runtime/package.json +1 -1
  29. package/packages/cache-strategy/package.json +1 -1
  30. package/packages/capability-registry/package.json +1 -1
  31. package/packages/checkpoint/package.json +1 -1
  32. package/packages/cli-plugin-sdk/package.json +1 -1
  33. package/packages/clipboard/package.json +1 -1
  34. package/packages/clipboard-plugin/package.json +1 -1
  35. package/packages/code-generation/package.json +1 -1
  36. package/packages/code-review/package.json +1 -1
  37. package/packages/codex-adapter/package.json +1 -1
  38. package/packages/codex-watcher/package.json +1 -1
  39. package/packages/config-capture/package.json +1 -1
  40. package/packages/context-compiler/package.json +1 -1
  41. package/packages/context-discovery/package.json +1 -1
  42. package/packages/context-manager/package.json +1 -1
  43. package/packages/cookie-sanitizer/package.json +1 -1
  44. package/packages/cost-optimizer/package.json +1 -1
  45. package/packages/dependency-analyzer/package.json +1 -1
  46. package/packages/django-plugin/package.json +1 -1
  47. package/packages/doc-generator/package.json +1 -1
  48. package/packages/evaluation-engine/package.json +1 -1
  49. package/packages/evaluation-runner/package.json +1 -1
  50. package/packages/event-bus/package.json +1 -1
  51. package/packages/event-store/package.json +1 -1
  52. package/packages/experience-replay/package.json +1 -1
  53. package/packages/feedback-collector/package.json +1 -1
  54. package/packages/file-copy-helper/package.json +1 -1
  55. package/packages/framework-detector/package.json +1 -1
  56. package/packages/framework-plugin-sdk/package.json +1 -1
  57. package/packages/frappe-plugin/package.json +1 -1
  58. package/packages/generic-web-plugin/package.json +1 -1
  59. package/packages/health-monitor/package.json +1 -1
  60. package/packages/intent-analyzer/package.json +1 -1
  61. package/packages/jev-judge/package.json +1 -1
  62. package/packages/knowledge-graph/package.json +1 -1
  63. package/packages/knowledge-retrieval/package.json +1 -1
  64. package/packages/laravel-plugin/package.json +1 -1
  65. package/packages/learning-engine/package.json +1 -1
  66. package/packages/mcp-adapter/package.json +1 -1
  67. package/packages/memory-engine/package.json +1 -1
  68. package/packages/milestone-manager/package.json +1 -1
  69. package/packages/model-registry/package.json +1 -1
  70. package/packages/nextjs-plugin/package.json +1 -1
  71. package/packages/notification/package.json +1 -1
  72. package/packages/observability/package.json +1 -1
  73. package/packages/okf-indexer/package.json +1 -1
  74. package/packages/paperclip-integration/package.json +1 -1
  75. package/packages/performance-optimizer/package.json +1 -1
  76. package/packages/privilege-broker/package.json +1 -1
  77. package/packages/project-analyzer/package.json +1 -1
  78. package/packages/project-bootstrap/package.json +1 -1
  79. package/packages/projection-engine/package.json +1 -1
  80. package/packages/prompt-compiler/package.json +1 -1
  81. package/packages/prompt-versioning/package.json +1 -1
  82. package/packages/provider-adapter-sdk/package.json +1 -1
  83. package/packages/provider-router/package.json +1 -1
  84. package/packages/provider-selector/package.json +1 -1
  85. package/packages/providers/package.json +1 -1
  86. package/packages/qdrant-skills/package.json +1 -1
  87. package/packages/quota-manager/package.json +1 -1
  88. package/packages/rate-limiter/package.json +1 -1
  89. package/packages/react-vite-plugin/package.json +1 -1
  90. package/packages/release-manager/package.json +1 -1
  91. package/packages/requirement-compiler/package.json +1 -1
  92. package/packages/runtime/package.json +1 -1
  93. package/packages/scheduler/package.json +1 -1
  94. package/packages/scheduler-adapter/package.json +1 -1
  95. package/packages/session/package.json +1 -1
  96. package/packages/session-api/package.json +1 -1
  97. package/packages/session-export/package.json +1 -1
  98. package/packages/shared-context/package.json +1 -1
  99. package/packages/skill-mcp-client/package.json +1 -1
  100. package/packages/skill-registry/package.json +1 -1
  101. package/packages/skills/package.json +1 -1
  102. package/packages/sprint-planner/package.json +1 -1
  103. package/packages/subscription-engine/package.json +1 -1
  104. package/packages/task-compiler/package.json +1 -1
  105. package/packages/tencentdb-memory/package.json +1 -1
  106. package/packages/tencentdb-sync/package.json +1 -1
  107. package/packages/test-data-generator/package.json +1 -1
  108. package/packages/test-generator/package.json +1 -1
  109. package/packages/todo-bd-sync/package.json +1 -1
  110. package/packages/token-estimation/package.json +1 -1
  111. package/packages/token-optimizer/package.json +1 -1
  112. package/packages/trajectory/package.json +1 -1
  113. package/packages/tui/package.json +1 -1
  114. package/packages/types/package.json +1 -1
  115. package/packages/workflow-events/package.json +1 -1
  116. package/packages/workspace-scanner/package.json +1 -1
  117. package/packages/worktree/package.json +1 -1
  118. package/packages/write-review/package.json +1 -1
@@ -0,0 +1,342 @@
1
+ # Pi Harness Runtime - Project State Report
2
+
3
+ **Generated:** 2026-07-06
4
+ **Last Updated:** 2026-07-06
5
+
6
+ ---
7
+
8
+ ## Project Overview
9
+
10
+ Pi Harness Runtime is a local-first, provider-agnostic AI coding harness for pi.dev. It provides:
11
+
12
+ - Quota tracking and management
13
+ - Multi-provider support (MiniMax, OpenRouter, etc.)
14
+ - Job state machine with checkpoint/resume
15
+ - Task graph with dependency management
16
+ - Auto-compaction and continuation on output token limits
17
+ - Mobile notifications via Telegram/Ntfy/Webhook
18
+
19
+ ---
20
+
21
+ ## Directory Structure
22
+
23
+ ```
24
+ pi-harness-runtime/
25
+ +-- index.ts # Main CLI extension entry point
26
+ +-- cli.ts # CLI commands
27
+ +-- mirror.ts # Provider mirror store
28
+ +-- renderer.ts # Status rendering
29
+ +-- tracker.ts # Usage tracking
30
+ +-- sync-form.ts # Manual sync form
31
+ +-- windows.ts # Windows aggregation
32
+ +-- harness/ # Core harness modules
33
+ | +-- agent-handoff.ts # Agent handoff protocol
34
+ | +-- auto-compact.ts # RFC-0019: Auto Compact
35
+ | +-- blackboard.ts # Shared blackboard
36
+ | +-- context-window-manager.ts
37
+ | +-- job-state-machine.ts # Job state machine
38
+ | +-- loop-runtime.ts # RFC-0001: Main loop
39
+ | +-- master-planner.ts # Task planning
40
+ | +-- notification-events.ts # RFC-0022: Notification events
41
+ | +-- output-limit-handler.ts # RFC-0020: Output limit
42
+ | +-- partial-recovery.ts # RFC-0021: Partial recovery
43
+ | +-- repair-engine.ts # Repair/retry logic
44
+ | +-- task-graph.ts # Task dependency graph
45
+ | +-- e2e/ # E2E test engine
46
+ | +-- project-detector/ # Project type detection
47
+ +-- packages/
48
+ | +-- auth/ # Authentication
49
+ | +-- checkpoint/ # Checkpoint manager
50
+ | +-- notification/ # RFC-0022: Notification center
51
+ | | +-- notification-center.ts
52
+ | | +-- types.ts
53
+ | | +-- base-adapter.ts
54
+ | | +-- adapters/
55
+ | | +-- telegram-adapter.ts
56
+ | | +-- ntfy-adapter.ts
57
+ | | +-- email-adapter.ts
58
+ | | +-- webhook-adapter.ts
59
+ | +-- provider-router/ # Provider routing
60
+ | +-- providers/ # Provider adapters
61
+ | +-- quota-manager/ # Quota tracking
62
+ | +-- runtime/ # Runtime components (NEW)
63
+ | +-- scheduler/ # Job scheduling
64
+ | +-- shared-context/ # Shared context
65
+ | +-- tui/ # Terminal UI
66
+ | +-- types/ # Type definitions
67
+ | +-- worktree/ # Git worktree management
68
+ +-- RFC/ # RFC documents (0028 total)
69
+ +-- IMPLEMENTATION/ # Implementation tracking
70
+ | +-- RFC-XXXX/ # Per-RFC implementation tracking
71
+ | +-- AI_BRIEF.md
72
+ | +-- TASKS.md
73
+ | +-- ACCEPTANCE_CRITERIA.md
74
+ +-- schemas/ # JSON schemas
75
+ +-- profiles/ # Provider profiles
76
+ +-- test/ # Tests
77
+ ```
78
+
79
+ ---
80
+
81
+ ## RFC Status
82
+
83
+ ### Completed Implementations
84
+
85
+ | RFC | Name | Status | File(s) |
86
+ | ----- | ------ | -------- | --------- |
87
+ | 0001 | Loop Runtime | ✅ Implemented | `harness/loop-runtime.ts` |
88
+ | 0002 | Provider Adapter | ✅ Implemented | `packages/providers/adapters.ts` |
89
+ | 0003 | Quota Manager | ✅ Implemented | `packages/quota-manager/` |
90
+ | 0004 | Playwright Adapter | ✅ Implemented | `packages/providers/` |
91
+ | 0005 | Git Worktree | ✅ Implemented | `packages/worktree/` |
92
+ | 0006 | Checkpoint Manager | ✅ Implemented | `packages/checkpoint/` |
93
+ | 0007 | Scheduler | ✅ Implemented | `packages/scheduler/` |
94
+ | 0008 | Provider Router | ✅ Implemented | `packages/provider-router/` |
95
+ | 0009 | Shared Context | ✅ Implemented | `packages/shared-context/` |
96
+ | 0010 | Context Window Manager | ✅ Implemented | `harness/context-window-manager.ts` |
97
+ | 0011 | Shared Blackboard | ✅ Implemented | `harness/blackboard.ts` |
98
+ | 0012 | Agent Handoff Protocol | ✅ Implemented | `harness/agent-handoff.ts` |
99
+ | 0013 | E2E Test Engine | ✅ Implemented | `harness/e2e/` |
100
+ | 0014 | Project Detector | ✅ Implemented | `harness/project-detector/` |
101
+ | 0015 | Job State Machine | ✅ Implemented | `harness/job-state-machine.ts` |
102
+ | 0016 | Task Graph | ✅ Implemented | `harness/task-graph.ts` |
103
+ | 0017 | Master Planner | ✅ Implemented | `harness/master-planner.ts` |
104
+ | 0018 | Repair Engine | ✅ Implemented | `harness/repair-engine.ts` |
105
+ | 0019 | Auto Compact and Continue | ✅ Implemented | `harness/auto-compact.ts` |
106
+ | 0020 | Output Token Limit Handler | ✅ Implemented | `harness/output-limit-handler.ts` |
107
+ | 0021 | Partial Response Recovery | ✅ Implemented | `harness/partial-recovery.ts` |
108
+ | 0022 | Notification Center | ✅ Implemented | `packages/notification/` |
109
+ | 0023 | Local Browser Agent | 🔲 Stub Only | - |
110
+
111
+ ### Stubs (Need Implementation)
112
+
113
+ | RFC | Name | Status |
114
+ | ----- | ------ | -------- |
115
+ | 0024 | Local Runtime Agent | ✅ Implemented - `packages/runtime/local-runtime-agent.ts` |
116
+ | 0025 | Command Executor | ✅ Implemented - `packages/runtime/command-executor.ts` |
117
+ | 0026 | Workspace Manager | ✅ Implemented - `packages/runtime/workspace-manager.ts` |
118
+ | 0027 | Runtime API | ✅ Implemented - `packages/runtime/runtime-api.ts` |
119
+ | 0028 | Policy Engine | ✅ Implemented - `packages/runtime/policy-engine.ts` |
120
+
121
+ ---
122
+
123
+ ## Key Implementation Patterns
124
+
125
+ ### 1. RFC Document Structure
126
+
127
+ Each RFC in `/RFC/` follows this format:
128
+
129
+ ```markdown
130
+ # RFC-XXXX - Title
131
+
132
+ ## Purpose
133
+ ## Motivation
134
+ ## Goals
135
+ ## Artifact Layout (file structure)
136
+ ## Runtime Flow (state diagram)
137
+ ## Acceptance Criteria
138
+ ```
139
+
140
+ ### 2. Implementation Tracking
141
+
142
+ Each RFC in `/IMPLEMENTATION/RFC-XXXX/` contains:
143
+
144
+ - `AI_BRIEF.md` - Brief description of what to implement
145
+ - `TASKS.md` - Task list (Read RFC, Implement, Test)
146
+ - `ACCEPTANCE_CRITERIA.md` - Success criteria
147
+
148
+ ### 3. Class Naming Convention
149
+
150
+ - **Core Engine:** `[Name]Engine` or `[Name]Manager`
151
+ - Example: `AutoCompactEngine`, `JobStateMachine`, `TaskGraphManager`
152
+ - **Runtime:** `[Name]Runtime`
153
+ - Example: `LoopRuntime`, `LocalRuntimeAgent`
154
+ - **Adapter:** `[Name]Adapter` extends `BaseChannelAdapter`
155
+ - Example: `TelegramAdapter`, `NtfyAdapter`
156
+ - **Handler:** `[Name]Handler`
157
+ - Example: `OutputLimitHandler`, `PartialRecovery`
158
+
159
+ ### 4. TypeScript Conventions
160
+
161
+ - Uses ESM (`import/export`)
162
+ - JSDoc comments for documentation
163
+ - Interfaces for public APIs, types for unions
164
+ - Error handling with typed errors
165
+ - Async/await pattern for I/O
166
+
167
+ ### 5. File Paths
168
+
169
+ - Harness modules: `harness/[module-name].ts`
170
+ - Package modules: `packages/[name]/[module-name].ts`
171
+ - Adapters: `packages/notification/adapters/[name]-adapter.ts`
172
+
173
+ ---
174
+
175
+ ## Configuration
176
+
177
+ ### Environment Variables
178
+
179
+ ```
180
+ # Provider
181
+ MINIMAX_API_KEY=
182
+ OPENROUTER_API_KEY=
183
+
184
+ # Notification
185
+ TELEGRAM_BOT_TOKEN=
186
+ TELEGRAM_CHAT_ID=
187
+ NTFY_TOPIC=
188
+ NTFY_SERVER=https://ntfy.sh
189
+ NTFY_TOKEN=
190
+ NOTIFICATION_WEBHOOK_URL=
191
+ NOTIFICATION_WEBHOOK_METHOD=POST
192
+
193
+ # Paths
194
+ PI_USAGE_DIR=~/.pi/usage-status
195
+ PI_HARNESS_DIR=~/.pi/harness
196
+ ```
197
+
198
+ ### Runtime Storage
199
+
200
+ - **Usage tracking:** `~/.pi/usage-status/`
201
+ - **Harness state:** `~/.pi/harness/[jobId]/`
202
+ - `checkpoint.json` - Job checkpoint
203
+ - `context/` - Compaction artifacts
204
+ - `partial/` - Partial responses
205
+ - `events.jsonl` - Event log
206
+
207
+ ---
208
+
209
+ ## Event Types (RFC-0022)
210
+
211
+ ```typescript
212
+ type NotificationEvent =
213
+ | "JobStarted"
214
+ | "TaskCompleted"
215
+ | "TaskFailed"
216
+ | "QuotaPaused"
217
+ | "ResumeScheduled"
218
+ | "ContextCompacted"
219
+ | "OutputLimitContinued"
220
+ | "E2EFailed"
221
+ | "HumanReviewNeeded"
222
+ | "ReadyForClient"
223
+ | "JobCancelled"
224
+ | "Error";
225
+ ```
226
+
227
+ ---
228
+
229
+ ## State Machine States
230
+
231
+ ```
232
+ pending -> planning -> running <-> repairing <-> testing <-> reviewing
233
+ | | | | |
234
+ v v v v v
235
+ cancelled paused waiting_human paused_quota ready_for_client
236
+ ```
237
+
238
+ ---
239
+
240
+ ## ✅ IMPLEMENTED: RFCs 0024-0028
241
+
242
+ ### RFC-0024: Local Runtime Agent ✅
243
+
244
+ **File:** `packages/runtime/local-runtime-agent.ts`
245
+
246
+ - HTTP server for quota checking
247
+ - Coordinates with Local Browser Agent (RFC-0023)
248
+ - Security: redact sensitive data, localhost binding
249
+
250
+ ### RFC-0025: Command Executor ✅
251
+
252
+ **File:** `packages/runtime/command-executor.ts`
253
+
254
+ - Safe shell command execution
255
+ - Timeout, output capture
256
+ - Security policies with allowlist/denylist
257
+
258
+ ### RFC-0026: Workspace Manager ✅
259
+
260
+ **File:** `packages/runtime/workspace-manager.ts`
261
+
262
+ - Workspace directory management
263
+ - Worktree lifecycle
264
+ - Automatic cleanup policies
265
+
266
+ ### RFC-0027: Runtime API ✅
267
+
268
+ **File:** `packages/runtime/runtime-api.ts`
269
+
270
+ - HTTP/RPC API for runtime control
271
+ - Job management endpoints
272
+ - WebSocket support for real-time events
273
+
274
+ ### RFC-0028: Policy Engine ✅
275
+
276
+ **File:** `packages/runtime/policy-engine.ts`
277
+
278
+ - Command execution policies
279
+ - Network access policies
280
+ - Rate limiting & audit logging
281
+
282
+ ---
283
+
284
+ ## Provider Usage Data
285
+
286
+ See: `harness/reports/PROVIDER_USAGE_RESEARCH.md`
287
+
288
+ | Provider | Method | Status |
289
+ | ---------- | -------- | -------- |
290
+ | MiniMax | Browser scraping | 🔄 Testing |
291
+ | OpenAI (GPT) | TUI parsing | ✅ Implemented |
292
+ | GLM (Zhipu) | TUI parsing | ✅ Implemented |
293
+
294
+ ### Unified Approach
295
+
296
+ All providers use TUI message parsing (except MiniMax which needs browser).
297
+ No API keys needed - hooks into pi's error/status messages.
298
+
299
+ ---
300
+
301
+ ## Dependencies
302
+
303
+ ```json
304
+ {
305
+ "dependencies": {
306
+ "node:fs": "built-in",
307
+ "node:path": "built-in",
308
+ "node:os": "built-in",
309
+ "node:http": "built-in",
310
+ "node:events": "built-in",
311
+ "ws": "WebSocket support"
312
+ }
313
+ }
314
+ ```
315
+
316
+ ---
317
+
318
+ ## Testing
319
+
320
+ Test files located in `/test/`:
321
+
322
+ - Unit tests for core modules
323
+ - Integration tests for state machine
324
+ - E2E test engine in `harness/e2e/`
325
+
326
+ ---
327
+
328
+ ## Next Steps
329
+
330
+ 1. ~~Complete RFC-0024~~ - Local Runtime Agent ✅
331
+ 2. ~~Implement RFC-0025~~ - Command Executor ✅
332
+ 3. ~~Implement RFC-0026~~ - Workspace Manager ✅
333
+ 4. ~~Implement RFC-0027~~ - Runtime API ✅
334
+ 5. ~~Implement RFC-0028~~ - Policy Engine ✅
335
+ 6. ~~Update index.ts~~ - Package exports ✅
336
+
337
+ ### New Priority Items
338
+
339
+ 1. **Implement OpenAI billing API** usage fetcher
340
+ 2. **Research GLM** usage API
341
+ 3. Debug MiniMax browser scraping
342
+ 4. Add acceptance tests for RFC-0024-0028
@@ -0,0 +1,115 @@
1
+ # Provider Usage API Research
2
+
3
+ **Date:** 2026-07-06
4
+ **Updated:** Unified TUI Integration
5
+
6
+ ---
7
+
8
+ ## Summary: Unified TUI Message Parsing
9
+
10
+ All providers (except MiniMax) report quota exhaustion via TUI in pi.dev. No API keys needed!
11
+
12
+ | Provider | Method | File | Status |
13
+ | ---------- | -------- | ------ | -------- |
14
+ | OpenAI (GPT) | TUI message | `tui-usage-monitor.ts` | ✅ |
15
+ | GLM (Zhipu) | TUI message | `tui-usage-monitor.ts` | ✅ |
16
+ | Anthropic (Claude) | TUI message | `tui-usage-monitor.ts` | ✅ |
17
+ | OpenRouter | TUI message | `tui-usage-monitor.ts` | ✅ |
18
+ | MiniMax | Browser scraping | `minimax-browser-auth.ts` | 🔄 |
19
+
20
+ ---
21
+
22
+ ## Architecture
23
+
24
+ ### Unified TUI Usage Monitor
25
+
26
+ **File:** `packages/quota-manager/tui-usage-monitor.ts`
27
+
28
+ The `TUIUsageMonitor` handles all TUI-based providers:
29
+
30
+ - Detects provider from message content
31
+ - Parses reset time and limit type
32
+ - Records to QuotaManager automatically
33
+
34
+ ### Integration
35
+
36
+ ```typescript
37
+ import { QuotaManager, TUIUsageMonitor } from "@pi-harness/quota-manager";
38
+
39
+ const quotaManager = new QuotaManager();
40
+
41
+ const monitor = new TUIUsageMonitor({
42
+ quotaManager,
43
+ debug: true,
44
+ });
45
+
46
+ // Hook into pi
47
+ pi.on("error", (event) => monitor.processMessage(event.message));
48
+ pi.on("message", (event) => monitor.processMessage(event.message));
49
+
50
+ // Check availability
51
+ if (!quotaManager.isAvailable("openai")) {
52
+ const waitTime = quotaManager.getWaitTime("openai");
53
+ console.log(`Waiting ${waitTime}ms for OpenAI`);
54
+ }
55
+ ```
56
+
57
+ ### Detected Patterns
58
+
59
+ | Provider | Patterns |
60
+ | ---------- | ---------- |
61
+ | OpenAI | `OpenAI`, `GPT`, `insufficient_quota`, `429` |
62
+ | GLM | `GLM`, `Zhipu`, `tokens exhausted` |
63
+ | Anthropic | `Claude`, `Anthropic`, `rate_limit_error` |
64
+ | OpenRouter | `OpenRouter`, `quota exhausted` |
65
+
66
+ ---
67
+
68
+ ## MiniMax (Separate)
69
+
70
+ **File:** `packages/auth/src/minimax-browser-auth.ts`
71
+
72
+ MiniMax requires browser scraping because it doesn't expose usage via TUI.
73
+
74
+ **Solution:** Local Browser Agent (RFC-0023 + RFC-0024)
75
+
76
+ ---
77
+
78
+ ## Files Created/Updated
79
+
80
+ ```
81
+ packages/
82
+ +-- quota-manager/
83
+ | +-- quota-manager.ts # Core quota tracking
84
+ | +-- tui-usage-monitor.ts # ✅ NEW - Unified TUI parser
85
+ | +-- index.ts # ✅ NEW - Exports
86
+ | +-- examples/
87
+ | +-- tui-usage-integration.ts # ✅ NEW - Example
88
+ +-- providers/
89
+ | +-- openai-usage.ts # Legacy (can be removed)
90
+ | +-- glm-usage.ts # Legacy (can be removed)
91
+ packages/
92
+ +-- types/src/
93
+ +-- runtime-types.ts # Updated QuotaSignal.source
94
+ ```
95
+
96
+ ---
97
+
98
+ ## TODO
99
+
100
+ ### ✅ Completed
101
+
102
+ 1. [x] TUIUsageMonitor - unified parser
103
+ 2. [x] QuotaManager integration
104
+ 3. [x] Multi-provider support
105
+
106
+ ### 🔄 In Progress
107
+
108
+ 4. [ ] Test with actual pi TUI messages
109
+ 2. [ ] Add to pi extension
110
+
111
+ ### 📋 MiniMax
112
+
113
+ - Browser scraping exists but not 100%
114
+ - Needs Local Browser Agent (RFC-0023)
115
+ - Not blocking TUI providers
@@ -0,0 +1,107 @@
1
+ # Session Status Report
2
+
3
+ **Date:** 2026-07-06
4
+ **Session:** Implementation Day
5
+
6
+ ---
7
+
8
+ ## ✅ Completed Implementations (RFC-0024 to RFC-0028)
9
+
10
+ ### Files Created
11
+
12
+ | File | RFC | Description |
13
+ | ------ | ----- | ------------- |
14
+ | `packages/runtime/local-runtime-agent.ts` | 0024 | HTTP server for local browser agent coordination |
15
+ | `packages/runtime/command-executor.ts` | 0025 | Safe shell command execution |
16
+ | `packages/runtime/workspace-manager.ts` | 0026 | Workspace lifecycle management |
17
+ | `packages/runtime/runtime-api.ts` | 0027 | HTTP/RPC API for job control |
18
+ | `packages/runtime/policy-engine.ts` | 0028 | Policy enforcement with rate limiting |
19
+ | `packages/runtime/index.ts` | - | Package exports |
20
+ | `packages/providers/openai-usage.ts` | - | OpenAI billing API fetcher |
21
+ | `packages/providers/glm-usage.ts` | - | GLM TUI message parser |
22
+ | `packages/providers/index.ts` | - | Providers package exports |
23
+ | `harness/reports/PROJECT_STATE.md` | - | Project documentation |
24
+ | `harness/reports/SESSION_STATUS.md` | - | Session todo list |
25
+ | `harness/reports/PROVIDER_USAGE_RESEARCH.md` | - | Provider research |
26
+
27
+ ### Dependencies Added
28
+
29
+ - `@types/ws` - WebSocket support
30
+
31
+ ---
32
+
33
+ ## 🔬 In Progress: Provider Usage Data
34
+
35
+ ### MiniMax (Testing in Progress)
36
+
37
+ - **Status:** Browser scraping via Playwright
38
+ - **URL:** `https://platform.minimax.io/console/usage`
39
+ - **File:** `packages/auth/src/minimax-browser-auth.ts`
40
+ - **Issue:** Not 100% success rate yet
41
+ - **Need:** Local Browser Agent to handle human login
42
+
43
+ ### GPT (OpenAI) - ✅ IMPLEMENTED
44
+
45
+ - **File:** `packages/providers/openai-usage.ts`
46
+ - **Method:** TUI message parsing (no API key needed)
47
+ - **Patterns:** Context window, quota exhausted, rate limit, reset time
48
+
49
+ ### GLM (Zhipu AI) - ✅ IMPLEMENTED
50
+
51
+ - **File:** `packages/providers/glm-usage.ts`
52
+ - **Method:** TUI message parsing (no API key needed)
53
+ - **Patterns:** Context window, tokens exhausted, rate limit, reset time
54
+
55
+ ---
56
+
57
+ ## 📋 TODO List
58
+
59
+ ### High Priority
60
+
61
+ 1. [x] Explore GPT/OpenAI usage API - ✅ Implemented
62
+ 2. [x] Explore GLM/Zhipu AI usage API - ✅ Implemented (TUI parsing)
63
+ 3. [x] Integrate usage data into QuotaManager - ✅ Done
64
+ 4. [ ] Add to pi extension
65
+ 5. [ ] Complete Local Browser Agent (RFC-0023 stub)
66
+
67
+ ### Medium Priority
68
+
69
+ 1. [ ] Add acceptance tests for RFC-0024-0028
70
+ 2. [ ] Integrate new runtime components into main index.ts
71
+ 3. [ ] Test CommandExecutor with actual commands
72
+
73
+ ### Low Priority
74
+
75
+ 1. [ ] Write RFC stubs for any new components needed
76
+ 2. [ ] Performance testing
77
+
78
+ ---
79
+
80
+ ## 🔍 Research Notes
81
+
82
+ ### MiniMax
83
+
84
+ - Requires browser login (authenticated session)
85
+ - Cannot be scraped via server-side fetch
86
+ - Solution: Local Browser Agent (RFC-0023 + RFC-0024)
87
+
88
+ ### GPT (OpenAI)
89
+
90
+ - API key based authentication ✅
91
+ - Usage endpoint: `https://api.openai.com/v1/billing/usage` ✅
92
+ - Implementation: `packages/providers/openai-usage.ts` ✅
93
+
94
+ ### GLM (Zhipu AI)
95
+
96
+ - Reports quota via TUI in pi.dev ✅
97
+ - Implementation: `packages/providers/glm-usage.ts` ✅
98
+ - Hooks into error/status messages, extracts reset time
99
+
100
+ ---
101
+
102
+ ## Next Actions
103
+
104
+ 1. [x] ~~Check existing adapters~~ - Done
105
+ 2. [x] ~~Test OpenAI usage API~~ - Implemented, need to test
106
+ 3. [ ] Update QuotaManager to integrate all providers
107
+ 4. [ ] Test integration with pi extension