pi-harness-runtime 0.9.25 → 1.1.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 +173 -51
- package/harness/auto-compact.ts +1 -1
- 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 +5 -5
- package/harness/e2e/openai-quota-scraper.ts +13 -8
- 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 +10 -10
- 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 +139 -34
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/a2a-adapter/src/types.ts +5 -5
- package/packages/auth/package.json +1 -1
- 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/dist/src/copy-sync.d.ts +27 -0
- package/packages/clipboard/dist/src/copy-sync.d.ts.map +1 -0
- package/packages/clipboard/dist/src/copy-sync.js +170 -0
- package/packages/clipboard/dist/src/copy-sync.js.map +1 -0
- package/packages/clipboard/dist/src/gist-relay.d.ts +48 -0
- package/packages/clipboard/dist/src/gist-relay.d.ts.map +1 -0
- package/packages/clipboard/dist/src/gist-relay.js +186 -0
- package/packages/clipboard/dist/src/gist-relay.js.map +1 -0
- package/packages/clipboard/dist/src/github-login.d.ts +16 -0
- package/packages/clipboard/dist/src/github-login.d.ts.map +1 -0
- package/packages/clipboard/dist/src/github-login.js +69 -0
- package/packages/clipboard/dist/src/github-login.js.map +1 -0
- package/packages/clipboard/dist/src/index.d.ts +2 -0
- package/packages/clipboard/dist/src/index.d.ts.map +1 -1
- package/packages/clipboard/dist/src/index.js +2 -1
- package/packages/clipboard/dist/src/index.js.map +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard/src/clipboard.ts +16 -9
- package/packages/clipboard/src/copy-sync.ts +201 -0
- package/packages/clipboard/src/gist-relay.ts +240 -0
- package/packages/clipboard/src/github-login.ts +107 -0
- package/packages/clipboard/src/index.ts +2 -0
- package/packages/clipboard/test/mojibake.test.mjs +143 -0
- 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/package.json +1 -1
- package/packages/providers/src/deepagents-adapter.ts +1 -1
- package/packages/quota-manager/package.json +1 -1
- 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/todo-bd-sync/package.json +22 -0
- package/packages/todo-bd-sync/src/detector.ts +150 -0
- package/packages/todo-bd-sync/src/extension.ts +101 -0
- package/packages/todo-bd-sync/src/index.ts +401 -0
- package/packages/todo-bd-sync/src/sync.ts +322 -0
- package/packages/todo-bd-sync/src/todo-reminder.ts +418 -0
- package/packages/todo-bd-sync/src/types.ts +137 -0
- 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
|
@@ -73,7 +73,7 @@ export class HarnessNotificationEvents {
|
|
|
73
73
|
return this.center.listChannels();
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
//
|
|
76
|
+
// --- Event Emitters ------------------------------------------------
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Emit JobStarted event
|
|
@@ -173,7 +173,7 @@ export class HarnessNotificationEvents {
|
|
|
173
173
|
await this.emit("Error", { error });
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
//
|
|
176
|
+
// --- State Machine Event Listeners ---------------------------------
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* Wire up with JobStateMachine to emit events on transitions
|
|
@@ -207,7 +207,7 @@ export class HarnessNotificationEvents {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
//
|
|
210
|
+
// --- Private Methods -----------------------------------------------
|
|
211
211
|
|
|
212
212
|
private async emit(
|
|
213
213
|
event: NotificationEvent,
|
|
@@ -277,7 +277,7 @@ export class OutputLimitHandler {
|
|
|
277
277
|
return this.attempts >= this.maxAttempts;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
//
|
|
280
|
+
// --- Private Methods ------------------------------------------------
|
|
281
281
|
|
|
282
282
|
private ensureDir(): void {
|
|
283
283
|
if (!existsSync(this.rootDir)) {
|
|
@@ -70,7 +70,7 @@ export class PartialRecovery {
|
|
|
70
70
|
this.loadExistingPartials();
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
//
|
|
73
|
+
// --- Public API -----------------------------------------------------------
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Save a partial response
|
|
@@ -285,7 +285,7 @@ export class PartialRecovery {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
//
|
|
288
|
+
// --- Private Methods ------------------------------------------------
|
|
289
289
|
|
|
290
290
|
private ensureDir(): void {
|
|
291
291
|
if (!existsSync(this.rootDir)) {
|
|
@@ -517,7 +517,7 @@ export class PartialRecovery {
|
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
//
|
|
520
|
+
// --- Factory ----------------------------------------------------------------
|
|
521
521
|
|
|
522
522
|
/**
|
|
523
523
|
* Create a PartialRecovery manager for a task
|
|
@@ -11,7 +11,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
import type { CompactableMessage } from "../packages/types/src/runtime-types.js";
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// --- Types ------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
export interface SessionMemory {
|
|
17
17
|
jobId: string;
|
|
@@ -41,7 +41,7 @@ export interface TestResult {
|
|
|
41
41
|
timestamp: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// --- Session Memory Manager -------------------------------------------------
|
|
45
45
|
|
|
46
46
|
export class SessionMemoryManager {
|
|
47
47
|
private memory: SessionMemory;
|
|
@@ -66,7 +66,7 @@ export class SessionMemoryManager {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// --- Public API -----------------------------------------------------------
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Extract key facts from recent messages
|
|
@@ -362,7 +362,7 @@ export class SessionMemoryManager {
|
|
|
362
362
|
this.save();
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
//
|
|
365
|
+
// --- Private Methods --------------------------------------------------
|
|
366
366
|
|
|
367
367
|
private load(): SessionMemory | null {
|
|
368
368
|
if (!existsSync(this.memoryPath)) {
|
|
@@ -388,7 +388,7 @@ export class SessionMemoryManager {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
//
|
|
391
|
+
// --- Factory ----------------------------------------------------------------
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
394
|
* Create a SessionMemoryManager for a job
|
package/index.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* Runs directly from Bun.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { Key } from "@earendil-works/pi-tui";
|
|
16
17
|
import type {
|
|
17
18
|
CompactOptions,
|
|
18
19
|
ExtensionAPI,
|
|
@@ -39,6 +40,8 @@ import {
|
|
|
39
40
|
} from "./packages/quota-manager/src/tui-usage-monitor.ts";
|
|
40
41
|
import { QuotaManager } from "./packages/quota-manager/src/quota-manager.ts";
|
|
41
42
|
import { buildFooterStatusValue } from "./footer-status.ts";
|
|
43
|
+
import { registerGithubLoginCommand } from "./packages/clipboard/src/github-login.js";
|
|
44
|
+
import { registerCopySyncShortcut } from "./packages/clipboard/src/copy-sync.js";
|
|
42
45
|
import {
|
|
43
46
|
MAX_PROACTIVE_COMPACT_FAILURES,
|
|
44
47
|
OUTPUT_LIMIT_RESUME_PROMPT,
|
|
@@ -64,17 +67,30 @@ import {
|
|
|
64
67
|
createBlackboard,
|
|
65
68
|
} from "./harness/blackboard.ts";
|
|
66
69
|
import { scheduleAutoResume, cancelAutoResume } from "./harness/index.js";
|
|
70
|
+
|
|
71
|
+
// --- todo-bd-sync: Two-way sync between rpiv-todo and bd --------------------
|
|
72
|
+
// Lazy import - only loads when packages/todo-bd-sync exists
|
|
73
|
+
async function initTodoBdSync(pi: ExtensionAPI): Promise<void> {
|
|
74
|
+
try {
|
|
75
|
+
const mod = await import("./packages/todo-bd-sync/src/extension.js");
|
|
76
|
+
mod.registerTodoBdSync(pi, { debug: false });
|
|
77
|
+
} catch {
|
|
78
|
+
// todo-bd-sync not available
|
|
79
|
+
}
|
|
80
|
+
}
|
|
67
81
|
import { homedir } from "node:os";
|
|
68
82
|
import { appendFileSync, existsSync, mkdirSync } from "node:fs";
|
|
69
83
|
import { join } from "node:path";
|
|
70
84
|
|
|
71
|
-
//
|
|
85
|
+
// --- Debug log → file instead of TUI ---------------------------------
|
|
72
86
|
const DEBUG_LOG_DIR = join(homedir(), ".pi", "harness-logs");
|
|
73
87
|
const DEBUG_LOG_PATH = join(DEBUG_LOG_DIR, "harness-debug.log");
|
|
74
88
|
|
|
75
89
|
try {
|
|
76
90
|
if (!existsSync(DEBUG_LOG_DIR)) mkdirSync(DEBUG_LOG_DIR, { recursive: true });
|
|
77
|
-
} catch {
|
|
91
|
+
} catch {
|
|
92
|
+
/* non-fatal */
|
|
93
|
+
}
|
|
78
94
|
|
|
79
95
|
// Write harness runtime logs to file only (NOT to TUI stdout)
|
|
80
96
|
function _debugLog(...args: unknown[]): void {
|
|
@@ -82,14 +98,16 @@ function _debugLog(...args: unknown[]): void {
|
|
|
82
98
|
const line =
|
|
83
99
|
new Date().toISOString() +
|
|
84
100
|
" " +
|
|
85
|
-
args
|
|
101
|
+
args
|
|
102
|
+
.map((a) => (typeof a === "object" ? JSON.stringify(a) : String(a)))
|
|
103
|
+
.join(" ");
|
|
86
104
|
appendFileSync(DEBUG_LOG_PATH, line + "\n");
|
|
87
105
|
} catch {
|
|
88
106
|
// non-fatal
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
|
|
92
|
-
//
|
|
110
|
+
// --- Selective console override — harness DEBUG → file only --------
|
|
93
111
|
// Real errors (no [DEBUG prefix) still print to TUI so you notice problems.
|
|
94
112
|
const _origLog = console.log.bind(console);
|
|
95
113
|
const _origError = console.error.bind(console);
|
|
@@ -108,7 +126,7 @@ console.error = (...args: unknown[]) => {
|
|
|
108
126
|
}
|
|
109
127
|
};
|
|
110
128
|
|
|
111
|
-
//
|
|
129
|
+
// --- Harness Runtime State --------------------------------------------
|
|
112
130
|
const HARNESS_ROOT_DIR = join(homedir(), ".pi", "harness");
|
|
113
131
|
|
|
114
132
|
interface HarnessSession {
|
|
@@ -207,7 +225,32 @@ export default function (pi: ExtensionAPI) {
|
|
|
207
225
|
const mirrorStore = new MirrorStore();
|
|
208
226
|
ensureHarnessDir();
|
|
209
227
|
|
|
210
|
-
//
|
|
228
|
+
// --- todo-bd-sync: Initialize two-way sync with bd ---------------
|
|
229
|
+
// Start async init but don't await - runs in background
|
|
230
|
+
void initTodoBdSync(pi);
|
|
231
|
+
|
|
232
|
+
// --- Auto-Invoke rpiv-todo via System Prompt ------------------------
|
|
233
|
+
// This makes the todo overlay ALWAYS activate at session start
|
|
234
|
+
const AUTO_TODO_INVOKE_HINT = `
|
|
235
|
+
|
|
236
|
+
You have access to a todo tool that shows a persistent task overlay.
|
|
237
|
+
ALWAYS use it at the START of every session to capture user requirements as tasks.
|
|
238
|
+
When the user gives you a multi-step task:
|
|
239
|
+
1. Immediately create todo items for each step using the todo tool
|
|
240
|
+
2. Keep tasks updated - mark in_progress when working, completed when done
|
|
241
|
+
3. When a task is completed, continue to the next or ask the user
|
|
242
|
+
|
|
243
|
+
The todo overlay persists and helps track progress across your conversation.
|
|
244
|
+
`;
|
|
245
|
+
let firstAgentStart = true;
|
|
246
|
+
pi.on("before_agent_start", async (event) => {
|
|
247
|
+
if (firstAgentStart) {
|
|
248
|
+
event.systemPrompt += AUTO_TODO_INVOKE_HINT;
|
|
249
|
+
firstAgentStart = false;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// --- Auto-track every assistant message ------------------------------
|
|
211
254
|
pi.on("message_end", async (event, ctx) => {
|
|
212
255
|
if (isOutputLimitResumePromptMessage(event.message)) {
|
|
213
256
|
pendingOutputLimitResumeAfterSettled = false;
|
|
@@ -274,7 +317,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
274
317
|
}
|
|
275
318
|
});
|
|
276
319
|
|
|
277
|
-
//
|
|
320
|
+
// --- Smart quota fetch for MiniMax status ------------------------
|
|
278
321
|
const MINIMAX_REFRESH_MIN_INTERVAL_MS = 15 * 60 * 1000;
|
|
279
322
|
const MINIMAX_REFRESH_TOKEN_THRESHOLD = 200_000;
|
|
280
323
|
const MINIMAX_REFRESH_REQUEST_THRESHOLD = 12;
|
|
@@ -282,12 +325,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
282
325
|
? new MiniMaxQuotaScraper({ cookieFile: process.env.QUOTA_COOKIE_FILE })
|
|
283
326
|
: new MiniMaxQuotaScraper();
|
|
284
327
|
|
|
285
|
-
//
|
|
328
|
+
// --- Smart quota fetch for OpenAI status -------------------------
|
|
286
329
|
const OPENAI_REFRESH_MIN_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
|
|
287
|
-
const _openaiQuotaScraper = new OpenAIQuotaScraper();
|
|
330
|
+
const _openaiQuotaScraper = new OpenAIQuotaScraper({ quiet: true });
|
|
288
331
|
let lastOpenAIQuotaFetchAt = 0;
|
|
289
332
|
|
|
290
|
-
//
|
|
333
|
+
// --- Cookie sanitizer integration ------------------------------------
|
|
291
334
|
// The drop folder is the user-facing, forgiving input. The canonical
|
|
292
335
|
// cache (`~/.config/minimax-cookies.txt`) is the runtime-owned,
|
|
293
336
|
// normalized output that `MiniMaxQuotaScraper` reads. Either being
|
|
@@ -310,7 +353,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
310
353
|
|
|
311
354
|
const cookieQuotaAutoFetchAvailable = hasCookieSource();
|
|
312
355
|
|
|
313
|
-
//
|
|
356
|
+
// --- TUI quota signal plumbing (OpenAI / GLM / Anthropic / OpenRouter) --
|
|
314
357
|
// The TUIUsageMonitor parses provider quota-exhaustion messages from pi's
|
|
315
358
|
// TUI / message stream and emits signals we write to per-provider mirror
|
|
316
359
|
// entries. For providers that don't expose a continuous usage API this is
|
|
@@ -339,10 +382,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
339
382
|
}
|
|
340
383
|
});
|
|
341
384
|
|
|
385
|
+
let lastQuotaAutoFetchAt = 0;
|
|
386
|
+
|
|
342
387
|
// Live watcher — sanitises on every change in the drop folder.
|
|
343
388
|
const cookieWatcher = new CookieWatcher({
|
|
344
389
|
dropDir: cookieDropDir,
|
|
345
|
-
syncOptions: { cachePath: cookieCachePath },
|
|
390
|
+
syncOptions: { cachePath: cookieCachePath, providerHint: "minimax" },
|
|
346
391
|
onEvent: (event) => {
|
|
347
392
|
if (event.kind === "sync-error" || event.kind === "watcher-error") {
|
|
348
393
|
const msg = "message" in event ? event.message : "";
|
|
@@ -365,8 +410,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
365
410
|
}
|
|
366
411
|
},
|
|
367
412
|
});
|
|
413
|
+
|
|
368
414
|
try {
|
|
369
415
|
cookieWatcher.start();
|
|
416
|
+
// Sync existing drop-folder cookies now (ignoreInitial: true means
|
|
417
|
+
// the watcher won't do this automatically on startup).
|
|
418
|
+
cookieWatcher.triggerNow();
|
|
370
419
|
} catch (e) {
|
|
371
420
|
const msg = e instanceof Error ? e.message : String(e);
|
|
372
421
|
if (msg.includes("ENOSPC")) {
|
|
@@ -389,7 +438,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
389
438
|
let footerStatusCtx: {
|
|
390
439
|
ui: { setStatus: (key: string, value: string) => void };
|
|
391
440
|
} | null = null;
|
|
392
|
-
let lastQuotaAutoFetchAt = 0;
|
|
393
441
|
let quotaAutoFetchInFlight = false;
|
|
394
442
|
let proactiveCompactInFlight = false;
|
|
395
443
|
let lastProactiveCompactAt = 0;
|
|
@@ -399,6 +447,49 @@ export default function (pi: ExtensionAPI) {
|
|
|
399
447
|
let pendingOutputLimitResumeAfterCompact = false;
|
|
400
448
|
let pendingOutputLimitResumeAfterSettled = false;
|
|
401
449
|
|
|
450
|
+
// --- Context-usage escalating warning tiers -----------------------------
|
|
451
|
+
// Amber at 75%, red at 85%. No notify above 90% (proactive compact handles it).
|
|
452
|
+
// Per-session dedup: only notify when crossing INTO a new higher tier.
|
|
453
|
+
const TIER_WARNING = 0.75; // amber
|
|
454
|
+
const TIER_ERROR = 0.85; // red
|
|
455
|
+
let lastNotifiedTier: "none" | "warning" | "error" = "none";
|
|
456
|
+
|
|
457
|
+
function maybeNotifyContextUsage(ctx: ExtensionContext): void {
|
|
458
|
+
const usage = ctx.getContextUsage();
|
|
459
|
+
const pct = usage?.percent;
|
|
460
|
+
if (pct === null || pct === undefined) return;
|
|
461
|
+
if (pct >= 0.9) return; // proactive compact handles 90%+
|
|
462
|
+
|
|
463
|
+
const tier: "none" | "warning" | "error" =
|
|
464
|
+
pct >= TIER_ERROR ? "error" : pct >= TIER_WARNING ? "warning" : "none";
|
|
465
|
+
|
|
466
|
+
// Only notify when crossing into a strictly higher tier
|
|
467
|
+
if (tier === "none") {
|
|
468
|
+
lastNotifiedTier = "none";
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (
|
|
472
|
+
tier === "warning" &&
|
|
473
|
+
lastNotifiedTier !== "warning" &&
|
|
474
|
+
lastNotifiedTier !== "error"
|
|
475
|
+
) {
|
|
476
|
+
lastNotifiedTier = "warning";
|
|
477
|
+
ctx.ui.notify(
|
|
478
|
+
`Context at ${Math.round(pct * 100)}% — consider condensing`,
|
|
479
|
+
"info",
|
|
480
|
+
);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (tier === "error" && lastNotifiedTier !== "error") {
|
|
484
|
+
lastNotifiedTier = "error";
|
|
485
|
+
ctx.ui.notify(
|
|
486
|
+
`Context at ${Math.round(pct * 100)}% — approaching limit`,
|
|
487
|
+
"warning",
|
|
488
|
+
);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
402
493
|
function writeMirrorRecord(
|
|
403
494
|
provider: ProviderId,
|
|
404
495
|
record: Omit<import("./mirror.js").ProviderMirrorRecord, "provider">,
|
|
@@ -692,7 +783,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
692
783
|
return;
|
|
693
784
|
}
|
|
694
785
|
|
|
695
|
-
//
|
|
786
|
+
// --- /usage — show full status ---------------------------------------
|
|
696
787
|
pi.registerCommand("usage", {
|
|
697
788
|
description: "Show Codex-style usage status (local + provider mirror)",
|
|
698
789
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -710,7 +801,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
710
801
|
},
|
|
711
802
|
});
|
|
712
803
|
|
|
713
|
-
//
|
|
804
|
+
// --- /usage refresh — force auto-fetch ----------------------------
|
|
714
805
|
pi.registerCommand("usage-refresh", {
|
|
715
806
|
description: "Force refresh quota from provider console",
|
|
716
807
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -735,14 +826,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
735
826
|
},
|
|
736
827
|
});
|
|
737
828
|
|
|
738
|
-
//
|
|
829
|
+
// --- /usage today — focused view -------------------------------------
|
|
739
830
|
pi.registerCommand("usage-today", {
|
|
740
831
|
description: "Show today's usage + 5h window",
|
|
741
832
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
742
833
|
const local = aggregateWindows(tracker.all());
|
|
743
834
|
const lines = [
|
|
744
835
|
" Today's usage",
|
|
745
|
-
"
|
|
836
|
+
"-------------------------------------",
|
|
746
837
|
` Model: ${ctx.model?.id ?? "unknown"}`,
|
|
747
838
|
` Today: ${local.today.tokens} tokens · ${local.today.requests} requests · $${local.today.cost.toFixed(4)}`,
|
|
748
839
|
` This 5h: ${local.five_h.tokens} tokens · ${local.five_h.requests} requests · $${local.five_h.cost.toFixed(4)}`,
|
|
@@ -753,14 +844,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
753
844
|
},
|
|
754
845
|
});
|
|
755
846
|
|
|
756
|
-
//
|
|
847
|
+
// --- /usage week — focused view --------------------------------------
|
|
757
848
|
pi.registerCommand("usage-week", {
|
|
758
849
|
description: "Show this week's usage + lifetime totals",
|
|
759
850
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
760
851
|
const local = aggregateWindows(tracker.all());
|
|
761
852
|
const lines = [
|
|
762
853
|
" This week's usage",
|
|
763
|
-
"
|
|
854
|
+
"-------------------------------------",
|
|
764
855
|
` Model: ${ctx.model?.id ?? "unknown"}`,
|
|
765
856
|
` This week: ${local.weekly.tokens} tokens · ${local.weekly.requests} requests · $${local.weekly.cost.toFixed(4)}`,
|
|
766
857
|
` Lifetime: ${local.lifetime.tokens} tokens · ${local.lifetime.requests} requests · $${local.lifetime.cost.toFixed(4)}`,
|
|
@@ -771,7 +862,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
771
862
|
},
|
|
772
863
|
});
|
|
773
864
|
|
|
774
|
-
//
|
|
865
|
+
// --- /usage reset — clear mirror -------------------------------------
|
|
775
866
|
pi.registerCommand("usage-reset", {
|
|
776
867
|
description: "Clear the provider mirror (force re-sync next time)",
|
|
777
868
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -811,7 +902,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
811
902
|
},
|
|
812
903
|
});
|
|
813
904
|
|
|
814
|
-
//
|
|
905
|
+
// --- /github-login — Connect GitHub Gist for clipboard sync ------------
|
|
906
|
+
registerGithubLoginCommand(pi);
|
|
907
|
+
|
|
908
|
+
// --- Ctrl+Shift+C — Copy to clipboard + sync to Gist ------------
|
|
909
|
+
registerCopySyncShortcut(pi, Key);
|
|
910
|
+
|
|
911
|
+
// --- /harness start — Start a new harness job ----------------------
|
|
815
912
|
pi.registerCommand("harness-start", {
|
|
816
913
|
description: "Start a new harness job: /harness start <requirement>",
|
|
817
914
|
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -883,7 +980,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
883
980
|
},
|
|
884
981
|
});
|
|
885
982
|
|
|
886
|
-
//
|
|
983
|
+
// --- /harness status — Show harness job status ---------------------
|
|
887
984
|
pi.registerCommand("harness-status", {
|
|
888
985
|
description: "Show current harness job status",
|
|
889
986
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -904,22 +1001,22 @@ export default function (pi: ExtensionAPI) {
|
|
|
904
1001
|
const progress = currentSession.graph.getProgressSummary();
|
|
905
1002
|
const lines = [
|
|
906
1003
|
`Harness Job Status`,
|
|
907
|
-
`${"
|
|
1004
|
+
`${"-".repeat(40)}`,
|
|
908
1005
|
`Job ID: ${currentSession.jobId}`,
|
|
909
1006
|
`Status: ${summary.status}`,
|
|
910
1007
|
`Terminal: ${summary.isTerminal ? "Yes" : "No"}`,
|
|
911
1008
|
`Can Resume: ${summary.canResume ? "Yes" : "No"}`,
|
|
912
|
-
`${"
|
|
1009
|
+
`${"-".repeat(40)}`,
|
|
913
1010
|
`Tasks: ${progress.done}/${progress.total} done, ${progress.running} running, ${progress.failed} failed`,
|
|
914
1011
|
`Created: ${currentSession.createdAt}`,
|
|
915
|
-
`${"
|
|
1012
|
+
`${"-".repeat(40)}`,
|
|
916
1013
|
`Run /harness tasks for task list`,
|
|
917
1014
|
];
|
|
918
1015
|
ctx.ui.notify(lines.join("\n"), "info");
|
|
919
1016
|
},
|
|
920
1017
|
});
|
|
921
1018
|
|
|
922
|
-
//
|
|
1019
|
+
// --- /harness tasks — List all tasks -------------------------------
|
|
923
1020
|
pi.registerCommand("harness-tasks", {
|
|
924
1021
|
description: "List all tasks in the current harness job",
|
|
925
1022
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -942,7 +1039,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
942
1039
|
|
|
943
1040
|
const lines = [
|
|
944
1041
|
`Tasks for Job ${currentSession.jobId}`,
|
|
945
|
-
`${"
|
|
1042
|
+
`${"-".repeat(50)}`,
|
|
946
1043
|
];
|
|
947
1044
|
|
|
948
1045
|
for (const task of tasks) {
|
|
@@ -950,14 +1047,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
950
1047
|
lines.push(`[${task.id}] ${status} ${task.title}`);
|
|
951
1048
|
}
|
|
952
1049
|
|
|
953
|
-
lines.push(`${"
|
|
1050
|
+
lines.push(`${"-".repeat(50)}`);
|
|
954
1051
|
const ready = currentSession.graph.getReadyTasks();
|
|
955
1052
|
lines.push(`${ready.length} tasks ready to execute.`);
|
|
956
1053
|
ctx.ui.notify(lines.join("\n"), "info");
|
|
957
1054
|
},
|
|
958
1055
|
});
|
|
959
1056
|
|
|
960
|
-
//
|
|
1057
|
+
// --- /harness pause — Pause the harness job -----------------------
|
|
961
1058
|
pi.registerCommand("harness-pause", {
|
|
962
1059
|
description: "Pause the current harness job",
|
|
963
1060
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -1013,7 +1110,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1013
1110
|
},
|
|
1014
1111
|
});
|
|
1015
1112
|
|
|
1016
|
-
//
|
|
1113
|
+
// --- /harness resume — Resume the harness job -----------------------
|
|
1017
1114
|
pi.registerCommand("harness-resume", {
|
|
1018
1115
|
description: "Resume a paused harness job",
|
|
1019
1116
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -1049,7 +1146,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1049
1146
|
},
|
|
1050
1147
|
});
|
|
1051
1148
|
|
|
1052
|
-
//
|
|
1149
|
+
// --- /harness cancel — Cancel the harness job ----------------------
|
|
1053
1150
|
pi.registerCommand("harness-cancel", {
|
|
1054
1151
|
description: "Cancel the current harness job",
|
|
1055
1152
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
@@ -1086,7 +1183,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1086
1183
|
},
|
|
1087
1184
|
});
|
|
1088
1185
|
|
|
1089
|
-
//
|
|
1186
|
+
// --- Footer status (persistent badge) --------------------------------
|
|
1090
1187
|
pi.on("session_start", (_event, ctx) => {
|
|
1091
1188
|
footerStatusCtx = ctx;
|
|
1092
1189
|
refreshFooterStatus(
|
|
@@ -1110,6 +1207,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1110
1207
|
);
|
|
1111
1208
|
void maybeAutoFetchQuota(ctx.model?.id ?? null);
|
|
1112
1209
|
maybeTriggerProactiveCompact(ctx);
|
|
1210
|
+
maybeNotifyContextUsage(ctx);
|
|
1113
1211
|
});
|
|
1114
1212
|
|
|
1115
1213
|
pi.on("agent_end", () => {
|
|
@@ -1165,6 +1263,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
1165
1263
|
queueAutoResume("post-compact", "resume", "followUp");
|
|
1166
1264
|
});
|
|
1167
1265
|
|
|
1266
|
+
// --- Periodic quota refresh every 15 minutes ---
|
|
1267
|
+
// `maybeAutoFetchQuota` checks its own rate-limit (MINIMAX_REFRESH_MIN_INTERVAL_MS)
|
|
1268
|
+
// so this is safe to call frequently.
|
|
1269
|
+
setInterval(() => {
|
|
1270
|
+
void maybeAutoFetchQuota(lastActiveProvider ?? null);
|
|
1271
|
+
}, MINIMAX_REFRESH_MIN_INTERVAL_MS);
|
|
1272
|
+
|
|
1168
1273
|
function queueAutoResume(
|
|
1169
1274
|
reason: string,
|
|
1170
1275
|
content: string,
|
|
@@ -1226,9 +1331,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1226
1331
|
}
|
|
1227
1332
|
}
|
|
1228
1333
|
|
|
1229
|
-
//
|
|
1334
|
+
// ----------------------------------------------------------------------
|
|
1230
1335
|
// Helper: refresh persistent footer status with one-line summary
|
|
1231
|
-
//
|
|
1336
|
+
// ----------------------------------------------------------------------
|
|
1232
1337
|
function refreshFooterStatus(
|
|
1233
1338
|
ctx: { ui: { setStatus: (key: string, value: string) => void } },
|
|
1234
1339
|
tracker: UsageTracker,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A2A Adapter — Types (RFC-0069)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
//
|
|
5
|
+
// --- Agent Card -------------------------------------------------------------
|
|
6
6
|
|
|
7
7
|
export interface AgentCard {
|
|
8
8
|
name: string;
|
|
@@ -36,7 +36,7 @@ export interface Authentication {
|
|
|
36
36
|
credentials?: string;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
//
|
|
39
|
+
// --- Task -----------------------------------------------------------------
|
|
40
40
|
|
|
41
41
|
export type TaskStatus =
|
|
42
42
|
| "submitted"
|
|
@@ -71,7 +71,7 @@ export interface Artifact {
|
|
|
71
71
|
parts: Array<{ type: "text"; text: string }>;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// --- A2A Requests / Responses ---------------------------------------------
|
|
75
75
|
|
|
76
76
|
export type A2ARequest =
|
|
77
77
|
| {
|
|
@@ -92,7 +92,7 @@ export interface A2AResponse {
|
|
|
92
92
|
error?: { code: number; message: string };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
//
|
|
95
|
+
// --- A2A Client ---------------------------------------------------------
|
|
96
96
|
|
|
97
97
|
export interface A2AClientConfig {
|
|
98
98
|
timeout?: number;
|
|
@@ -104,7 +104,7 @@ export interface TaskHandle {
|
|
|
104
104
|
status: TaskStatus;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
//
|
|
107
|
+
// --- A2A Agent -----------------------------------------------------------
|
|
108
108
|
|
|
109
109
|
export interface A2AAgentConfig {
|
|
110
110
|
name: string;
|
|
@@ -8,9 +8,9 @@ export declare class InboxError extends Error {
|
|
|
8
8
|
* Storage layout:
|
|
9
9
|
* ```
|
|
10
10
|
* ~/.pi/harness/inbox/
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* +-- tasks.jsonl # append-only log (one JSON line per task)
|
|
12
|
+
* +-- claimed/ # active leases (one JSON file per task)
|
|
13
|
+
* +-- BACKLOG.md # human-friendly authoring surface (optional)
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* Operations are:
|