pi-harness-runtime 1.1.237 → 1.1.238

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 (111) hide show
  1. package/index.ts +20 -9
  2. package/package.json +1 -1
  3. package/packages/a2a-adapter/package.json +1 -1
  4. package/packages/agent-policy/package.json +1 -1
  5. package/packages/architecture-generator/package.json +1 -1
  6. package/packages/auth/package.json +1 -1
  7. package/packages/autonomous-refactor/package.json +1 -1
  8. package/packages/autonomous-runtime/package.json +1 -1
  9. package/packages/cache-strategy/package.json +1 -1
  10. package/packages/capability-registry/package.json +1 -1
  11. package/packages/checkpoint/package.json +1 -1
  12. package/packages/cli-plugin-sdk/package.json +1 -1
  13. package/packages/clipboard/package.json +1 -1
  14. package/packages/clipboard-plugin/package.json +1 -1
  15. package/packages/code-generation/package.json +1 -1
  16. package/packages/code-review/package.json +1 -1
  17. package/packages/codex-adapter/package.json +1 -1
  18. package/packages/codex-watcher/package.json +1 -1
  19. package/packages/config-capture/package.json +1 -1
  20. package/packages/context-compiler/package.json +1 -1
  21. package/packages/context-discovery/package.json +1 -1
  22. package/packages/context-manager/package.json +1 -1
  23. package/packages/cookie-sanitizer/package.json +1 -1
  24. package/packages/cost-optimizer/package.json +1 -1
  25. package/packages/dependency-analyzer/package.json +1 -1
  26. package/packages/django-plugin/package.json +1 -1
  27. package/packages/doc-generator/package.json +1 -1
  28. package/packages/e2e-tester/package.json +1 -1
  29. package/packages/evaluation-engine/package.json +1 -1
  30. package/packages/evaluation-runner/package.json +1 -1
  31. package/packages/event-bus/package.json +1 -1
  32. package/packages/event-store/package.json +1 -1
  33. package/packages/experience-replay/package.json +1 -1
  34. package/packages/feedback-collector/package.json +1 -1
  35. package/packages/file-copy-helper/package.json +1 -1
  36. package/packages/framework-detector/package.json +1 -1
  37. package/packages/framework-plugin-sdk/package.json +1 -1
  38. package/packages/frappe-plugin/package.json +1 -1
  39. package/packages/generic-web-plugin/package.json +1 -1
  40. package/packages/health-monitor/package.json +1 -1
  41. package/packages/intent-analyzer/package.json +1 -1
  42. package/packages/jev-judge/dist/continuation-controller.d.ts +20 -0
  43. package/packages/jev-judge/dist/continuation-controller.d.ts.map +1 -1
  44. package/packages/jev-judge/dist/continuation-controller.js +57 -6
  45. package/packages/jev-judge/dist/continuation-controller.js.map +1 -1
  46. package/packages/jev-judge/dist/task-intake.d.ts +21 -1
  47. package/packages/jev-judge/dist/task-intake.d.ts.map +1 -1
  48. package/packages/jev-judge/dist/task-intake.js +28 -13
  49. package/packages/jev-judge/dist/task-intake.js.map +1 -1
  50. package/packages/jev-judge/package.json +1 -1
  51. package/packages/jev-judge/src/continuation-controller.ts +64 -6
  52. package/packages/jev-judge/src/task-intake.ts +38 -17
  53. package/packages/knowledge-graph/package.json +1 -1
  54. package/packages/knowledge-retrieval/package.json +1 -1
  55. package/packages/laravel-plugin/package.json +1 -1
  56. package/packages/learning-engine/package.json +1 -1
  57. package/packages/mcp-adapter/package.json +1 -1
  58. package/packages/memory-engine/package.json +1 -1
  59. package/packages/milestone-manager/package.json +1 -1
  60. package/packages/model-registry/package.json +1 -1
  61. package/packages/nextjs-plugin/package.json +1 -1
  62. package/packages/notification/package.json +1 -1
  63. package/packages/observability/package.json +1 -1
  64. package/packages/okf-indexer/package.json +1 -1
  65. package/packages/paperclip-integration/package.json +1 -1
  66. package/packages/performance-optimizer/package.json +1 -1
  67. package/packages/privilege-broker/package.json +1 -1
  68. package/packages/project-analyzer/package.json +1 -1
  69. package/packages/project-bootstrap/package.json +1 -1
  70. package/packages/projection-engine/package.json +1 -1
  71. package/packages/prompt-compiler/package.json +1 -1
  72. package/packages/prompt-versioning/package.json +1 -1
  73. package/packages/provider-adapter-sdk/package.json +1 -1
  74. package/packages/provider-router/package.json +1 -1
  75. package/packages/provider-selector/package.json +1 -1
  76. package/packages/providers/package.json +1 -1
  77. package/packages/qdrant-skills/package.json +1 -1
  78. package/packages/quota-manager/package.json +1 -1
  79. package/packages/rate-limiter/package.json +1 -1
  80. package/packages/react-vite-plugin/package.json +1 -1
  81. package/packages/release-manager/package.json +1 -1
  82. package/packages/requirement-compiler/package.json +1 -1
  83. package/packages/runtime/package.json +1 -1
  84. package/packages/scheduler/package.json +1 -1
  85. package/packages/scheduler-adapter/package.json +1 -1
  86. package/packages/session/package.json +1 -1
  87. package/packages/session-api/package.json +1 -1
  88. package/packages/session-export/package.json +1 -1
  89. package/packages/shared-context/package.json +1 -1
  90. package/packages/skill-mcp-client/package.json +1 -1
  91. package/packages/skill-registry/package.json +1 -1
  92. package/packages/skills/package.json +1 -1
  93. package/packages/sprint-planner/package.json +1 -1
  94. package/packages/subscription-engine/package.json +1 -1
  95. package/packages/task-compiler/package.json +1 -1
  96. package/packages/telegram/package.json +1 -1
  97. package/packages/tencentdb-memory/package.json +1 -1
  98. package/packages/tencentdb-sync/package.json +1 -1
  99. package/packages/test-data-generator/package.json +1 -1
  100. package/packages/test-generator/package.json +1 -1
  101. package/packages/todo-bd-sync/package.json +1 -1
  102. package/packages/token-estimation/package.json +1 -1
  103. package/packages/token-optimizer/package.json +1 -1
  104. package/packages/trajectory/package.json +1 -1
  105. package/packages/tui/package.json +1 -1
  106. package/packages/types/package.json +1 -1
  107. package/packages/webmcp-tester/package.json +1 -1
  108. package/packages/workflow-events/package.json +1 -1
  109. package/packages/workspace-scanner/package.json +1 -1
  110. package/packages/worktree/package.json +1 -1
  111. package/packages/write-review/package.json +1 -1
package/index.ts CHANGED
@@ -510,12 +510,20 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
510
510
 
511
511
  // Wire user messages to task intake
512
512
  pi.on("message_start", (event) => {
513
- const msg = (event as { message?: { role?: string; content?: string } }).message;
514
- if (msg?.role === "user" && taskIntakeController) {
515
- // Pause continuation when user sends message
513
+ const msgEvent = event as { message?: { role?: string; content?: string | Array<{ type?: string; text?: string }>; customType?: string } };
514
+ const msg = msgEvent.message;
515
+ if (!msg) return;
516
+
517
+ // Skip harness-generated messages (internal use)
518
+ if (msg.customType?.startsWith("harness:")) {
519
+ return;
520
+ }
521
+
522
+ if (msg.role === "user" && taskIntakeController) {
523
+ // Temporary pause for user input processing (auto-clears on next decision)
516
524
  if (todoContinuationController) {
517
- todoContinuationController.pause();
518
- logToFile("[auto-continue]", "User input received, pausing continuation");
525
+ todoContinuationController.tempPause();
526
+ logToFile("[auto-continue]", "User input received, temp pausing");
519
527
  }
520
528
 
521
529
  // Extract user message content
@@ -532,13 +540,16 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
532
540
  }
533
541
 
534
542
  // Evaluate with task intake controller (non-blocking)
535
- if (userMessage.trim().length > 10 && taskIntakeController) {
543
+ if (userMessage.trim().length > 10 && taskIntakeController && todoContinuationController) {
536
544
  const intake = taskIntakeController;
537
- intake.evaluate(userMessage).then(async (result) => {
545
+ const controller = todoContinuationController;
546
+
547
+ // Get current todos for duplicate detection
548
+ intake.evaluateWithTodos(userMessage, controller).then(async (result) => {
538
549
  if (result.actionable && result.action !== "skip") {
539
550
  logToFile("[auto-continue]", "Task intake result:", JSON.stringify(result));
540
- // Request capture if actionable
541
- await intake.requestCapture(userMessage);
551
+ // Request capture if actionable using harness custom message
552
+ await intake.requestCapture(userMessage, "harness:task-capture");
542
553
  }
543
554
  }).catch((err) => {
544
555
  logToFile("[auto-continue]", "Task intake error:", String(err));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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/agent-policy",
3
- "version": "1.1.237",
3
+ "version": "1.1.238",
4
4
  "description": "Agent policy runtime for pi-harness - enforces mandatory rule delivery and mutation gating",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/architecture-generator",
3
- "version": "1.1.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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": "@pi-harness/codex-watcher",
3
- "version": "1.1.237",
3
+ "version": "1.1.238",
4
4
  "description": "Watches Codex CLI sessions and emits visible messages for PING-PONG monitoring",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/config-capture",
3
- "version": "1.1.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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/e2e-tester",
3
- "version": "1.1.237",
3
+ "version": "1.1.238",
4
4
  "description": "WebMCP-powered E2E testing for pi-harness - natural language test scenarios",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
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.237",
3
+ "version": "1.1.238",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -26,6 +26,7 @@ export interface ContinuationState {
26
26
  lastMessageId: string | null;
27
27
  continuationQueued: boolean;
28
28
  userPaused: boolean;
29
+ explicitPause: boolean;
29
30
  lastSteerMessage: string | null;
30
31
  steerAttemptsForCurrentItem: number;
31
32
  lastItemContinued: number | null;
@@ -50,11 +51,29 @@ export declare class TodoContinuationController {
50
51
  private config;
51
52
  private todoProvider;
52
53
  private state;
54
+ private _inFlight;
53
55
  constructor(ctx: TodoContext, config?: ContinuationConfig);
54
56
  /**
55
57
  * Check if continuation is allowed (not paused, session idle)
56
58
  */
57
59
  private canContinue;
60
+ /**
61
+ * User explicitly paused - only this clears on explicit resume
62
+ */
63
+ explicitPause(): void;
64
+ /**
65
+ * Resume from explicit pause
66
+ */
67
+ resume(): void;
68
+ /**
69
+ * Temporary pause for user input processing
70
+ * Does not require explicit resume
71
+ */
72
+ tempPause(): void;
73
+ /**
74
+ * Clear continuation queue (called when work completes or starts)
75
+ */
76
+ clearQueue(): void;
58
77
  /**
59
78
  * Public method to evaluate and execute continuation
60
79
  * Called by external handlers (e.g., agent_settled)
@@ -67,6 +86,7 @@ export declare class TodoContinuationController {
67
86
  continueItem(item: TodoItem): Promise<void>;
68
87
  /**
69
88
  * Guarded dispatch - checks all conditions before sending
89
+ * Uses in-flight guard to prevent race conditions
70
90
  */
71
91
  private guardedDispatch;
72
92
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"continuation-controller.d.ts","sourceRoot":"","sources":["../src/continuation-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmBhE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,iEAAiE;IACjE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,4CAA4C;IAC5C,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qCAAqC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D;IAED;;;OAGG;YACW,eAAe;IA0D7B;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBnD;IAED;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjD;IAED;;OAEG;IACH,KAAK,IAAI,IAAI,CAIZ;IAED;;OAEG;IACH,MAAM,IAAI,IAAI,CAiBb;IAED;;OAEG;IACH,QAAQ,IAAI,IAAI,CAIf;IAED;;OAEG;IACH,QAAQ,IAAI;QAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAM7E;CACD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,WAAW,EAChB,MAAM,CAAC,EAAE,kBAAkB,GACzB,0BAA0B,CAE5B"}
@@ -33,11 +33,13 @@ export class TodoContinuationController {
33
33
  lastMessageId: null,
34
34
  continuationQueued: false,
35
35
  userPaused: false,
36
+ explicitPause: false,
36
37
  lastSteerMessage: null,
37
38
  steerAttemptsForCurrentItem: 0,
38
39
  lastItemContinued: null,
39
40
  lastEvaluationResult: null,
40
41
  };
42
+ _inFlight = false; // Guard against concurrent dispatches
41
43
  constructor(ctx, config) {
42
44
  this.ctx = ctx;
43
45
  this.todoProvider = createTodoProvider(ctx);
@@ -53,8 +55,9 @@ export class TodoContinuationController {
53
55
  * Check if continuation is allowed (not paused, session idle)
54
56
  */
55
57
  canContinue() {
56
- if (this.state.userPaused) {
57
- debugLog("TodoContinuation", "User paused, not continuing");
58
+ // Only blocked by explicit pause, not by temporary user input pause
59
+ if (this.state.explicitPause) {
60
+ debugLog("TodoContinuation", "Explicitly paused, not continuing");
58
61
  return false;
59
62
  }
60
63
  if (this.ctx.isIdle?.() === false) {
@@ -67,6 +70,41 @@ export class TodoContinuationController {
67
70
  }
68
71
  return true;
69
72
  }
73
+ /**
74
+ * User explicitly paused - only this clears on explicit resume
75
+ */
76
+ explicitPause() {
77
+ debugLog("TodoContinuation", "Explicit pause requested");
78
+ this.state.explicitPause = true;
79
+ this.state.userPaused = true;
80
+ }
81
+ /**
82
+ * Resume from explicit pause
83
+ */
84
+ resume() {
85
+ if (this.state.explicitPause) {
86
+ debugLog("TodoContinuation", "Resuming from explicit pause");
87
+ this.state.explicitPause = false;
88
+ this.state.userPaused = false;
89
+ this.clearQueue();
90
+ }
91
+ }
92
+ /**
93
+ * Temporary pause for user input processing
94
+ * Does not require explicit resume
95
+ */
96
+ tempPause() {
97
+ debugLog("TodoContinuation", "Temporary pause for user input");
98
+ this.state.userPaused = true;
99
+ }
100
+ /**
101
+ * Clear continuation queue (called when work completes or starts)
102
+ */
103
+ clearQueue() {
104
+ this.state.continuationQueued = false;
105
+ this._inFlight = false;
106
+ debugLog("TodoContinuation", "Continuation queue cleared");
107
+ }
70
108
  /**
71
109
  * Public method to evaluate and execute continuation
72
110
  * Called by external handlers (e.g., agent_settled)
@@ -175,11 +213,17 @@ export class TodoContinuationController {
175
213
  }
176
214
  /**
177
215
  * Guarded dispatch - checks all conditions before sending
216
+ * Uses in-flight guard to prevent race conditions
178
217
  */
179
218
  async guardedDispatch(itemId, message) {
180
- // 1. Check if paused by user
181
- if (this.state.userPaused) {
182
- debugLog("TodoContinuation", "Guarded dispatch: user paused, skipping");
219
+ // 0. Acquire in-flight guard to prevent concurrent dispatches
220
+ if (this._inFlight) {
221
+ debugLog("TodoContinuation", "Guarded dispatch: already in-flight, skipping");
222
+ return false;
223
+ }
224
+ // 1. Check if paused by explicit user pause
225
+ if (this.state.explicitPause) {
226
+ debugLog("TodoContinuation", "Guarded dispatch: explicitly paused, skipping");
183
227
  return false;
184
228
  }
185
229
  // 2. Check if session is still idle
@@ -192,18 +236,21 @@ export class TodoContinuationController {
192
236
  debugLog("TodoContinuation", "Guarded dispatch: already queued, skipping");
193
237
  return false;
194
238
  }
195
- // 4. Verify item still needs work (not completed)
239
+ // 4. Verify item still needs work (not completed) - acquire guard BEFORE await
240
+ this._inFlight = true;
196
241
  try {
197
242
  const snapshot = await this.todoProvider.getSnapshot();
198
243
  const item = snapshot.items.find((i) => i.id === itemId);
199
244
  if (item?.status === "completed") {
200
245
  debugLog("TodoContinuation", "Guarded dispatch: item completed, skipping");
246
+ this._inFlight = false;
201
247
  return false;
202
248
  }
203
249
  }
204
250
  catch {
205
251
  // If we can't read todos, skip dispatch
206
252
  debugLog("TodoContinuation", "Guarded dispatch: failed to read todos, skipping");
253
+ this._inFlight = false;
207
254
  return false;
208
255
  }
209
256
  // All checks passed - dispatch
@@ -211,11 +258,13 @@ export class TodoContinuationController {
211
258
  this.state.lastSteerMessage = message;
212
259
  try {
213
260
  await this.config.dispatch(message);
261
+ // Queue stays set while agent processes - cleared on agent_settled
214
262
  return true;
215
263
  }
216
264
  catch (err) {
217
265
  debugLog("TodoContinuation", "Guarded dispatch failed:", String(err));
218
266
  this.state.continuationQueued = false;
267
+ this._inFlight = false;
219
268
  return false;
220
269
  }
221
270
  }
@@ -270,11 +319,13 @@ export class TodoContinuationController {
270
319
  lastMessageId: null,
271
320
  continuationQueued: false,
272
321
  userPaused: false,
322
+ explicitPause: false,
273
323
  lastSteerMessage: null,
274
324
  steerAttemptsForCurrentItem: 0,
275
325
  lastItemContinued: null,
276
326
  lastEvaluationResult: null,
277
327
  };
328
+ this._inFlight = false;
278
329
  }
279
330
  /**
280
331
  * Cleanup on shutdown