pi-harness-runtime 1.1.77 → 1.1.79

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 (104) hide show
  1. package/index.ts +110 -0
  2. package/package.json +1 -1
  3. package/packages/a2a-adapter/package.json +1 -1
  4. package/packages/architecture-generator/package.json +1 -1
  5. package/packages/auth/package.json +1 -1
  6. package/packages/autonomous-refactor/package.json +1 -1
  7. package/packages/autonomous-runtime/package.json +1 -1
  8. package/packages/cache-strategy/package.json +1 -1
  9. package/packages/capability-registry/package.json +1 -1
  10. package/packages/checkpoint/package.json +1 -1
  11. package/packages/cli-plugin-sdk/package.json +1 -1
  12. package/packages/clipboard/package.json +1 -1
  13. package/packages/clipboard-plugin/package.json +1 -1
  14. package/packages/code-generation/package.json +1 -1
  15. package/packages/code-review/package.json +1 -1
  16. package/packages/codex-adapter/package.json +1 -1
  17. package/packages/config-capture/package.json +1 -1
  18. package/packages/context-compiler/package.json +1 -1
  19. package/packages/context-discovery/package.json +1 -1
  20. package/packages/context-manager/package.json +1 -1
  21. package/packages/cookie-sanitizer/package.json +1 -1
  22. package/packages/cost-optimizer/package.json +1 -1
  23. package/packages/dependency-analyzer/package.json +1 -1
  24. package/packages/django-plugin/package.json +1 -1
  25. package/packages/doc-generator/package.json +1 -1
  26. package/packages/evaluation-engine/package.json +1 -1
  27. package/packages/evaluation-runner/package.json +1 -1
  28. package/packages/event-bus/package.json +1 -1
  29. package/packages/event-store/package.json +1 -1
  30. package/packages/experience-replay/package.json +1 -1
  31. package/packages/feedback-collector/package.json +1 -1
  32. package/packages/file-copy-helper/package.json +1 -1
  33. package/packages/framework-detector/package.json +1 -1
  34. package/packages/framework-plugin-sdk/package.json +1 -1
  35. package/packages/frappe-plugin/package.json +1 -1
  36. package/packages/generic-web-plugin/package.json +1 -1
  37. package/packages/health-monitor/package.json +1 -1
  38. package/packages/intent-analyzer/package.json +1 -1
  39. package/packages/jev-judge/README.md +61 -0
  40. package/packages/jev-judge/dist/auto-continue.d.ts +92 -0
  41. package/packages/jev-judge/dist/auto-continue.d.ts.map +1 -0
  42. package/packages/jev-judge/dist/auto-continue.js +230 -0
  43. package/packages/jev-judge/dist/auto-continue.js.map +1 -0
  44. package/packages/jev-judge/dist/index.d.ts +22 -1
  45. package/packages/jev-judge/dist/index.d.ts.map +1 -1
  46. package/packages/jev-judge/dist/index.js +34 -26
  47. package/packages/jev-judge/dist/index.js.map +1 -1
  48. package/packages/jev-judge/package.json +1 -1
  49. package/packages/jev-judge/src/auto-continue.ts +317 -0
  50. package/packages/jev-judge/src/index.ts +43 -28
  51. package/packages/knowledge-graph/package.json +1 -1
  52. package/packages/knowledge-retrieval/package.json +1 -1
  53. package/packages/laravel-plugin/package.json +1 -1
  54. package/packages/learning-engine/package.json +1 -1
  55. package/packages/mcp-adapter/package.json +1 -1
  56. package/packages/memory-engine/package.json +1 -1
  57. package/packages/milestone-manager/package.json +1 -1
  58. package/packages/model-registry/package.json +1 -1
  59. package/packages/nextjs-plugin/package.json +1 -1
  60. package/packages/notification/package.json +1 -1
  61. package/packages/observability/package.json +1 -1
  62. package/packages/okf-indexer/package.json +1 -1
  63. package/packages/performance-optimizer/package.json +1 -1
  64. package/packages/privilege-broker/package.json +1 -1
  65. package/packages/project-analyzer/package.json +1 -1
  66. package/packages/project-bootstrap/package.json +1 -1
  67. package/packages/projection-engine/package.json +1 -1
  68. package/packages/prompt-compiler/package.json +1 -1
  69. package/packages/prompt-versioning/package.json +1 -1
  70. package/packages/provider-adapter-sdk/package.json +1 -1
  71. package/packages/provider-router/package.json +1 -1
  72. package/packages/provider-selector/package.json +1 -1
  73. package/packages/providers/package.json +1 -1
  74. package/packages/quota-manager/package.json +1 -1
  75. package/packages/rate-limiter/package.json +1 -1
  76. package/packages/react-vite-plugin/package.json +1 -1
  77. package/packages/release-manager/package.json +1 -1
  78. package/packages/requirement-compiler/package.json +1 -1
  79. package/packages/runtime/package.json +1 -1
  80. package/packages/scheduler/package.json +1 -1
  81. package/packages/scheduler-adapter/package.json +1 -1
  82. package/packages/session/package.json +1 -1
  83. package/packages/session-api/package.json +1 -1
  84. package/packages/session-export/package.json +1 -1
  85. package/packages/shared-context/package.json +1 -1
  86. package/packages/skill-mcp-client/package.json +1 -1
  87. package/packages/skill-registry/package.json +1 -1
  88. package/packages/sprint-planner/package.json +1 -1
  89. package/packages/subscription-engine/package.json +1 -1
  90. package/packages/task-compiler/package.json +1 -1
  91. package/packages/tencentdb-memory/package.json +1 -1
  92. package/packages/tencentdb-sync/package.json +1 -1
  93. package/packages/test-data-generator/package.json +1 -1
  94. package/packages/test-generator/package.json +1 -1
  95. package/packages/todo-bd-sync/package.json +1 -1
  96. package/packages/token-estimation/package.json +1 -1
  97. package/packages/token-optimizer/package.json +1 -1
  98. package/packages/trajectory/package.json +1 -1
  99. package/packages/tui/package.json +1 -1
  100. package/packages/types/package.json +1 -1
  101. package/packages/workflow-events/package.json +1 -1
  102. package/packages/workspace-scanner/package.json +1 -1
  103. package/packages/worktree/package.json +1 -1
  104. package/packages/write-review/package.json +1 -1
package/index.ts CHANGED
@@ -69,6 +69,113 @@ import {
69
69
  } from "./harness/blackboard.ts";
70
70
  import { scheduleAutoResume, cancelAutoResume } from "./harness/index.js";
71
71
 
72
+ // --- Jev Auto-Continue: Agent autonomous decision-making --------------------
73
+ // Lazy import - only loads when packages/jev-judge exists and API key available
74
+ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
75
+ try {
76
+ // Check if TYPESAFE_API_KEY is available
77
+ if (!process.env.TYPESAFE_API_KEY && !process.env.OPENROUTER_API_KEY) {
78
+ console.log("[auto-continue] No Jev API key found, skipping");
79
+ return;
80
+ }
81
+
82
+ const mod = await import("./packages/jev-judge/src/auto-continue.js");
83
+
84
+ // Track waiting state
85
+ let waitingForUserSince: Date | null = null;
86
+ let lastUserMessage: Date | null = null;
87
+
88
+ // Detect when agent asks for continuation
89
+ pi.on("message_end", async (event) => {
90
+ const msg = event.message as { role?: string; content?: string } | undefined;
91
+ if (!msg || msg.role !== "assistant") return;
92
+
93
+ const content = typeof msg.content === "string" ? msg.content : "";
94
+ const hasContinuation = /continue|proceed|next phase|next step/i.test(content);
95
+
96
+ if (hasContinuation && !waitingForUserSince) {
97
+ waitingForUserSince = new Date();
98
+ console.log("[auto-continue] Agent waiting for continuation confirmation");
99
+ }
100
+ });
101
+
102
+ // Detect user responses
103
+ pi.on("message_start", async (event) => {
104
+ const msg = event.message as { role?: string } | undefined;
105
+ if (msg?.role === "user") {
106
+ lastUserMessage = new Date();
107
+ if (waitingForUserSince) {
108
+ console.log("[auto-continue] User responded, cancelling wait");
109
+ waitingForUserSince = null;
110
+ }
111
+ }
112
+ });
113
+
114
+ // Periodic check for auto-continue decision
115
+ const AUTO_CONTINUE_INTERVAL_MS = 5 * 60 * 1000; // Check every 5 minutes
116
+ const MIN_WAIT_MINUTES = 5; // Minimum wait before auto-continue
117
+
118
+ const checkAndAutoContinue = async () => {
119
+ if (!waitingForUserSince) return;
120
+
121
+ const waitMinutes = (Date.now() - waitingForUserSince.getTime()) / 60000;
122
+ if (waitMinutes < MIN_WAIT_MINUTES) return;
123
+
124
+ console.log(`[auto-continue] Checking after ${waitMinutes.toFixed(0)} minutes wait...`);
125
+
126
+ try {
127
+ const judge = new mod.AutoContinueJudge({
128
+ apiKey: process.env.TYPESAFE_API_KEY || process.env.OPENROUTER_API_KEY!,
129
+ proceedThreshold: 0.7,
130
+ maxWaitMinutes: 30,
131
+ });
132
+
133
+ const taskState = mod.createTaskState(
134
+ [], // completed tasks
135
+ [], // remaining tasks
136
+ lastUserMessage || undefined,
137
+ new Date(Date.now() - waitMinutes * 60000),
138
+ );
139
+
140
+ const decision = await judge.decide(taskState);
141
+
142
+ console.log(
143
+ `[auto-continue] Decision: ${decision.action} (${(decision.probability * 100).toFixed(0)}% confidence)`,
144
+ );
145
+
146
+ if (decision.action === "proceed") {
147
+ // Send steer message to continue
148
+ pi.sendUserMessage(
149
+ "User is unavailable. Based on task progress and low risk, proceeding autonomously.\n" +
150
+ `Decision: ${decision.reasoning}\n` +
151
+ "Continue with remaining tasks.",
152
+ { deliverAs: "steer" },
153
+ );
154
+ waitingForUserSince = null;
155
+ } else if (decision.action === "proceed_with_caution") {
156
+ pi.sendUserMessage(
157
+ "User is unavailable. Proceeding with caution - will log each significant step.\n" +
158
+ `Risk level: ${decision.riskLevel}\n` +
159
+ "Continue with remaining tasks, reporting progress.",
160
+ { deliverAs: "steer" },
161
+ );
162
+ waitingForUserSince = null;
163
+ }
164
+ // If action is "wait", do nothing and check again later
165
+ } catch (error) {
166
+ console.error("[auto-continue] Error:", error);
167
+ }
168
+ };
169
+
170
+ // Start periodic check
171
+ setInterval(checkAndAutoContinue, AUTO_CONTINUE_INTERVAL_MS);
172
+
173
+ console.log("[auto-continue] Jev Auto-Continue initialized");
174
+ } catch {
175
+ // auto-continue not available
176
+ }
177
+ }
178
+
72
179
  // --- todo-bd-sync: Two-way sync between rpiv-todo and bd --------------------
73
180
  // Lazy import - only loads when packages/todo-bd-sync exists
74
181
  async function initTodoBdSync(pi: ExtensionAPI): Promise<void> {
@@ -375,6 +482,9 @@ export default function (pi: ExtensionAPI) {
375
482
  // --- ssh-detach-interceptor: Auto-fix bare ssh & → nohup pattern ---------
376
483
  void initSshDetachInterceptor(pi);
377
484
 
485
+ // --- jev-auto-continue: Agent autonomous decision when user unavailable -----
486
+ void initAutoContinue(pi);
487
+
378
488
  // --- loop-completions: Watch daemon completions → agent TUI todos --------
379
489
  void initLoopCompletions(pi);
380
490
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "[BETA] Codex-style /usage status + autonomous coding harness for pi. Not production ready — expect breaking changes.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/a2a-adapter",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "Google Agent-to-Agent (A2A) protocol adapter for pi-harness",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/architecture-generator",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Generate ADR and Mermaid diagrams from project analysis",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/auth",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "pi-harness-runtime — auth",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/autonomous-refactor",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "Autonomous refactoring engine",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/autonomous-runtime",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Autonomous Operations Runtime — task inbox, lease management, and worker lifecycle (RFC-0101)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/cache-strategy",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "Smart caching with TTL and invalidation strategies (RFC-0022)",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/capability-registry",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Capability Registry for pi-harness-runtime — tracks model capabilities and enables capability-based routing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/checkpoint",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Enhanced checkpoint system with incremental snapshots, diff-based storage, and recovery strategies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/cli-plugin-sdk",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "CLI Plugin SDK for pi-harness — install, list, remove, update, invoke plugins",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/clipboard",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/clipboard-plugin",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/code-generation",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Code generation pipeline for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/code-review",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Automated code review engine for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/codex-adapter",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "OpenAI Codex provider adapter for pi-harness",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/config-capture",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Auto-capture API-fetched configuration values to AGENTS.md",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/context-compiler",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Bounded context selection engine for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/context-discovery",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/context-manager",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Context Window Manager — prevents model context overflow via compaction and resume prompts (RFC-0010)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/cookie-sanitizer",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "pi-harness-runtime — cookie sanitizer (provider-quota cookie file normaliser)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/cost-optimizer",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Cost Optimizer for pi-harness-runtime — budget tracking, forecasting, and model selection optimization",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/dependency-analyzer",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/django-plugin",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Django framework analysis — models, management commands, settings",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/doc-generator",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Auto-Doc Generator — generate documentation from source code (RFC-0014)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/evaluation-engine",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Evaluation engine for pi-harness runtime (RFC-0057)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/evaluation-runner",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "Framework-agnostic evaluation framework for AI outputs (RFC-0020)",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-bus",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-store",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/experience-replay",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Experience replay for debugging and reproducibility (RFC-0059)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/feedback-collector",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "Collect and aggregate human/automated feedback (RFC-0021)",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/file-copy-helper",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Injects cp/sudo cp rule when user asks to mimic/copy files",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/framework-detector",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Framework detection system for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/framework-plugin-sdk",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Framework plugin SDK for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/frappe-plugin",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Frappe/ERPNext framework analysis — DocTypes, hooks, bench sites, site config",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/generic-web-plugin",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Generic web framework analysis — REST/GraphQL endpoints, OpenAPI, auth",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/health-monitor",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "description": "Health monitoring and auto-healing",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/intent-analyzer",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -19,6 +19,7 @@ Jev is a "System One" model - a new class of AI optimized for **structured decis
19
19
  - **E2EJudge** - E2E testing decisions (flaky detection, build blocking, retry)
20
20
  - **FlakyDetector** - Specialized flaky test detection
21
21
  - **DecisionEngine** - Threshold-based routing and actions
22
+ - **AutoContinueJudge** - Agent autonomous decision-making (continue or wait)
22
23
 
23
24
  ## Installation
24
25
 
@@ -225,6 +226,66 @@ Jev via OpenRouter:
225
226
 
226
227
  See [OpenRouter pricing](https://openrouter.ai/typesafe/jev-1.13) for details.
227
228
 
229
+ ## Auto-Continue Judge (Agent Use Case)
230
+
231
+ **Problem:** Agent completes 2/5 tasks, asks "Continue?" User asleep → agent waits indefinitely.
232
+
233
+ **Solution:** Use Jev to judge whether to auto-continue.
234
+
235
+ ```typescript
236
+ import { AutoContinueJudge, createTaskState } from "@pi-harness/jev-judge/auto-continue";
237
+ import { hasJevApiKey, createJevJudge } from "@pi-harness/jev-judge";
238
+
239
+ // Auto-detect API key from environment
240
+ const judge = new AutoContinueJudge({
241
+ apiKey: process.env.TYPESAFE_API_KEY!, // or auto-detect
242
+ proceedThreshold: 0.7, // Continue if >70% confidence
243
+ maxWaitMinutes: 30,
244
+ });
245
+
246
+ // Build task state
247
+ const taskState = createTaskState(
248
+ ["task-1", "task-2"], // completed
249
+ ["task-3", "task-4", "task-5"], // remaining
250
+ new Date(Date.now() - 30 * 60 * 1000), // last user activity 30 min ago
251
+ new Date(Date.now() - 2 * 60 * 60 * 1000) // session started 2 hours ago
252
+ );
253
+
254
+ // Get decision
255
+ const decision = await judge.decide(taskState);
256
+
257
+ if (decision.action === "proceed") {
258
+ console.log("Continuing with remaining tasks...");
259
+ // Agent proceeds autonomously
260
+ } else if (decision.action === "proceed_with_caution") {
261
+ console.log(`Proceeding with caution (${decision.riskLevel} risk)`);
262
+ // Agent proceeds but logs each step
263
+ } else {
264
+ console.log(`Waiting... (recommend ${decision.waitRecommendation} min)`);
265
+ // Agent waits or notifies
266
+ }
267
+ ```
268
+
269
+ ### Environment Variable Auto-Detection
270
+
271
+ The package automatically detects API keys from environment:
272
+
273
+ ```bash
274
+ # Option 1: TypeSafe API key (preferred)
275
+ export TYPESAFE_API_KEY="your-key-here"
276
+
277
+ # Option 2: OpenRouter API key
278
+ export OPENROUTER_API_KEY="your-key-here"
279
+ ```
280
+
281
+ ```typescript
282
+ import { hasJevApiKey, createJevJudge } from "@pi-harness/jev-judge";
283
+
284
+ if (hasJevApiKey()) {
285
+ const judge = createJevJudge(); // Auto-detects API key
286
+ }
287
+ ```
288
+
228
289
  ## Examples
229
290
 
230
291
  See `tests/` directory for example usage.
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Auto-Continue Judge - Agent decision making when user is unavailable
3
+ *
4
+ * Uses Jev to decide whether an agent should continue autonomously
5
+ * when waiting for user input that may not come.
6
+ *
7
+ * Scenario: Agent completes 2/5 tasks, asks "Continue?" User asleep.
8
+ * Jev decides: proceed, wait, or proceed with caution.
9
+ */
10
+ import type { JevJudgeConfig } from "./types.js";
11
+ /**
12
+ * Task tracking state
13
+ */
14
+ export interface TaskState {
15
+ completedTasks: string[];
16
+ remainingTasks: string[];
17
+ totalTasks: number;
18
+ waitTimeMinutes: number;
19
+ userResponded: boolean;
20
+ lastUserActivity?: Date;
21
+ sessionStartTime: Date;
22
+ }
23
+ /**
24
+ * Auto-continue decision
25
+ */
26
+ export interface AutoContinueDecision {
27
+ action: "proceed" | "wait" | "proceed_with_caution";
28
+ probability: number;
29
+ riskLevel: "minimal" | "low" | "medium" | "high" | "critical";
30
+ reasoning: string;
31
+ urgency: "critical" | "high" | "normal" | "low";
32
+ estimatedImpact: "minimal" | "moderate" | "significant" | "major";
33
+ confidence: "high" | "medium" | "low";
34
+ waitRecommendation?: number;
35
+ }
36
+ /**
37
+ * Auto-Continue Judge configuration
38
+ */
39
+ export interface AutoContinueConfig extends JevJudgeConfig {
40
+ /** Minimum probability to auto-proceed (default: 0.7) */
41
+ proceedThreshold?: number;
42
+ /** Minimum probability to proceed with caution (default: 0.5) */
43
+ cautionThreshold?: number;
44
+ /** Maximum wait time before force decision (default: 30 minutes) */
45
+ maxWaitMinutes?: number;
46
+ /** Default action if Jev fails (default: "wait") */
47
+ fallbackAction?: "proceed" | "wait" | "proceed_with_caution";
48
+ }
49
+ /**
50
+ * Auto-Continue Judge
51
+ *
52
+ * Judges whether an agent should continue autonomously when user is unavailable.
53
+ * Integrates with pi-coding-agent hooks for automatic decision making.
54
+ */
55
+ export declare class AutoContinueJudge {
56
+ private jev;
57
+ private config;
58
+ constructor(config: AutoContinueConfig);
59
+ /**
60
+ * Judge whether to continue or wait
61
+ */
62
+ decide(taskState: TaskState): Promise<AutoContinueDecision>;
63
+ /**
64
+ * Quick decision - simple yes/no to proceed
65
+ */
66
+ shouldContinue(taskState: TaskState): Promise<{
67
+ shouldContinue: boolean;
68
+ probability: number;
69
+ confidence: string;
70
+ }>;
71
+ /**
72
+ * Build state for Jev
73
+ */
74
+ private buildState;
75
+ /**
76
+ * Build decision from Jev result
77
+ */
78
+ private buildDecision;
79
+ /**
80
+ * Convert score to risk level
81
+ */
82
+ private scoreToRiskLevel;
83
+ /**
84
+ * Fallback decision when Jev fails
85
+ */
86
+ private fallbackDecision;
87
+ }
88
+ /**
89
+ * Helper: Create task state from todo list
90
+ */
91
+ export declare function createTaskState(completedTasks: string[], remainingTasks: string[], lastUserActivity?: Date, sessionStartTime?: Date): TaskState;
92
+ //# sourceMappingURL=auto-continue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-continue.d.ts","sourceRoot":"","sources":["../src/auto-continue.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,IAAI,CAAC;IACxB,gBAAgB,EAAE,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,sBAAsB,CAAC;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IAChD,eAAe,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC;IAClE,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,cAAc,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,sBAAsB,CAAC;CAC9D;AAYD;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,GAAG,CAAW;IACtB,OAAO,CAAC,MAAM,CAA+B;IAE7C,YAAY,MAAM,EAAE,kBAAkB,EAOrC;IAED;;OAEG;IACG,MAAM,CACV,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,oBAAoB,CAAC,CA6C/B;IAED;;OAEG;IACG,cAAc,CAClB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;QAAE,cAAc,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAQ/E;IAED;;OAEG;IACH,OAAO,CAAC,UAAU;IA2BlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAmErB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CA4BzB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EAAE,EACxB,gBAAgB,CAAC,EAAE,IAAI,EACvB,gBAAgB,CAAC,EAAE,IAAI,GACtB,SAAS,CAcX"}