chatroom-cli 1.77.4 → 1.78.1

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/dist/index.js CHANGED
@@ -77263,14 +77263,21 @@ function getFileReferenceProofOfCompletionExample() {
77263
77263
  }
77264
77264
 
77265
77265
  // ../../services/backend/prompts/utils/handoff-quality-principles.ts
77266
- function getHandoffQualityPrinciplesCommentBlock() {
77267
- const bullets = HANDOFF_QUALITY_PRINCIPLES.map((p) => `- ${p.name}: ${p.description}`).join(`
77268
- `);
77269
- return `<!-- Demonstrate adherence to:
77270
- ${bullets}
77271
- -->`;
77266
+ function getHandoffQualityPrinciplesTemplateBlock() {
77267
+ const lines = HANDOFF_QUALITY_PRINCIPLES.flatMap((p) => [
77268
+ `- **${p.name}:** <how this work demonstrates ${p.name.toLowerCase()}, or Not Applicable>`,
77269
+ `<!-- ${p.name}: ${p.description} -->`,
77270
+ ""
77271
+ ]);
77272
+ return lines.join(`
77273
+ `).trimEnd();
77272
77274
  }
77273
- var HANDOFF_QUALITY_PRINCIPLES, PROOF_OF_PRINCIPLES_HEADING_H2 = "## Proof of Principles", PROOF_OF_PRINCIPLES_HEADING_H3 = "### Proof of Principles";
77275
+ function getHandoffQualityPrinciplesSectionBlock() {
77276
+ return `${PROOF_OF_PRINCIPLES_HEADING_H2}
77277
+ ${PROOF_OF_PRINCIPLES_MANDATORY_COMMENT}
77278
+ ${getHandoffQualityPrinciplesTemplateBlock()}`;
77279
+ }
77280
+ var HANDOFF_QUALITY_PRINCIPLES, PROOF_OF_PRINCIPLES_HEADING_H2 = "## Proof of Principles", PROOF_OF_PRINCIPLES_MANDATORY_COMMENT = '<!-- REQUIRED: Complete every principle below. Write an explanation or "Not Applicable" for each — do not omit this section or skip any principle bullet. -->';
77274
77281
  var init_handoff_quality_principles = __esm(() => {
77275
77282
  HANDOFF_QUALITY_PRINCIPLES = [
77276
77283
  {
@@ -77302,7 +77309,7 @@ var init_handoff_quality_principles = __esm(() => {
77302
77309
 
77303
77310
  // ../../services/backend/prompts/utils/handoff-section-guidance.ts
77304
77311
  function getHandoffReportTemplateIntro(templateLabel) {
77305
- return `**${templateLabel}** — include every section that applies to this handoff. **Omit sections that do not apply** do not write \`Not Applicable\` as filler:`;
77312
+ return `**${templateLabel}** — complete every section below. Do not omit sections, principles, or XML wrappers:`;
77306
77313
  }
77307
77314
  function getDelegationBriefIntro() {
77308
77315
  return `**Delegation Brief (Planner → Builder)** — paste into the handoff message. Include every field that applies. **Omit fields that do not apply** — do not write \`Not Applicable\` as filler.`;
@@ -77342,9 +77349,7 @@ ${getHandoffReportTemplateIntro("Handoff Template (Builder → Planner)")}
77342
77349
  - [ ] I confirm that I have seen this template at the start of this task, before implementing or modifying any code
77343
77350
  ${getRoleGuidanceDisclosureBlock(roleGuidanceContext)}
77344
77351
 
77345
- ${PROOF_OF_PRINCIPLES_HEADING_H2}
77346
- ${getHandoffQualityPrinciplesCommentBlock()}
77347
- <how this work follows the principles above — localized changes, readable structure, correctness provable from source then tests>
77352
+ ${getHandoffQualityPrinciplesSectionBlock()}
77348
77353
 
77349
77354
  ## Proof of Completion
77350
77355
  ${getDelegationBriefDisclosureBlock()}
@@ -77355,10 +77360,12 @@ ${getFileReferenceProofOfCompletionExample()}
77355
77360
  ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
77356
77361
 
77357
77362
  ## Blockers / questions
77358
- <anything needing planner decision. Omit if none.>
77363
+ <!-- REQUIRED. List blockers, or write "Not Applicable". Do not omit this section. -->
77364
+ <anything needing planner decision>
77359
77365
 
77360
77366
  ## Notes for review
77361
- <specific areas for planner to check. Omit if none.>
77367
+ <!-- REQUIRED. List review notes, or write "Not Applicable". Do not omit this section. -->
77368
+ <specific areas for planner to check>
77362
77369
  \`\`\``;
77363
77370
  }
77364
77371
  var init_builder_to_planner = __esm(() => {
@@ -77372,26 +77379,29 @@ function getEnhancerToPlannerHandoffTemplate() {
77372
77379
 
77373
77380
  ${getHandoffReportTemplateIntro("Planning Feedback (Enhancer → Planner)")}
77374
77381
 
77375
- The planner sent you three XML sections: \`<user-message>\`, \`<grounding>\`, and a draft \`<builder-handoff>\`. Your job is **critical review** of all three tighten their thinking toward a high-quality eventual handoff to the user. Do not explore the codebase or invent new scope.
77382
+ The planner sent you three XML sections. Your job is **advisory adversarial review** — raise risks, challenge assumptions, and help the planner align with user intent. **Do not prescribe file-level changes or rewrite their builder brief.** The planner makes the final call.
77376
77383
 
77377
77384
  \`\`\`markdown
77378
77385
  ## Summary
77379
- <one paragraph: overall assessment of the planner's check-in strengths and the main gaps to address>
77386
+ <one paragraph: overall assessment strengths, main risks, and whether the approach is sound>
77387
+
77388
+ ## User intent alignment
77389
+ <does the planner's reading of the user request match what was asked? misreadings or missing constraints?>
77380
77390
 
77381
- ## User intent assessment
77382
- <mistakes or misreadings in what the user may want; clarify the correct interpretation>
77391
+ ## Risks &amp; failure modes
77392
+ <what could go wrong if they proceed as planned? common pitfalls for this kind of work?>
77383
77393
 
77384
77394
  ## Knowledge gaps
77385
- <facts, context, or research the planner is missing or has not surfaced>
77395
+ <facts, context, or research the planner should verify advisory questions, not answers from codebase>
77386
77396
 
77387
- ## Reasoning & logic
77388
- <logical errors, weak inference chains, contradictions, or unsupported conclusions>
77397
+ ## Reasoning review
77398
+ <logical errors, weak inference, contradictions challenge assumptions>
77389
77399
 
77390
- ## Alignment with user handoff
77391
- <how to tighten the research and conclusions so the eventual planner→user report will be accurate, complete, and well-justified>
77400
+ ## Questions for the planner
77401
+ <specific questions they should answer before delegating not instructions disguised as questions>
77392
77402
 
77393
- ## Recommended next steps
77394
- <concrete actions for the planner: what to research, revise, validate, or decide before proceeding>
77403
+ ## Alignment with eventual user handoff
77404
+ <will this approach produce a credible planner→user report? what's missing for user-facing completeness?>
77395
77405
  \`\`\`
77396
77406
 
77397
77407
  Return only the feedback markdown — no preamble. Follow this structure; omit sections that truly do not apply.`;
@@ -77510,11 +77520,11 @@ ${getFileReferenceGuidanceComment()}
77510
77520
  <builder-handoff>
77511
77521
  <your complete, filled-in Delegation Brief for builder review — every section with real content, not placeholders>
77512
77522
 
77513
- Follow the **Handoff to \`builder\`** template structure (Summary, Goal, Files to implement, Requirements, etc.). The enhancer critiques this draft before you delegate.
77523
+ Follow the **Handoff to \`builder\`** template structure (Summary, Goal, approach, Requirements, etc.). The enhancer reviews **approach and scope** not line-by-line file edits. Keep file references for context, but expect advisory feedback on risks and gaps, not a rewritten brief.
77514
77524
  </builder-handoff>
77515
77525
  \`\`\`
77516
77526
 
77517
- After the enhancer returns feedback, you will receive it as a new planner task. Revise grounding and the builder handoff as needed, then proceed to \`builder\` or \`user\` as appropriate.`;
77527
+ After the enhancer returns **advisory** feedback, you make the **final call** incorporate valid critiques, ignore what doesn't apply, then proceed to \`builder\` or \`user\`. Do not re-check with the enhancer for this slice; one round only.`;
77518
77528
  }
77519
77529
  var init_planner_to_enhancer = () => {};
77520
77530
 
@@ -77541,84 +77551,113 @@ var init_context_disclosure = () => {};
77541
77551
  // ../../services/backend/prompts/utils/unresolved-decisions.ts
77542
77552
  function getUnresolvedDecisionsSectionBlock() {
77543
77553
  return `## Unresolved Decisions
77544
- <!-- Decisions that need user input before work can proceed. Omit this section when there are no open decisions. -->
77554
+ <!-- REQUIRED. List open decisions needing user input, or write "Not Applicable" if none. Do not omit this section. -->
77545
77555
  - <decision or question — options considered, recommendation if any>
77546
77556
  <Carry forward decisions still open from earlier handoffs in this chatroom. Remove items the user has resolved. Do not decide on the user's behalf unless they explicitly asked you to.>`;
77547
77557
  }
77548
77558
 
77549
- // ../../services/backend/prompts/teams/duo/handoff-templates/planner-to-user.ts
77550
- function getPlannerToUserReportTemplate(roleGuidanceContext) {
77551
- return `${getHandoffRecipientVisibilityCallout("user")}
77552
-
77553
- ${getHandoffReportTemplateIntro("Report Template (Planner → User)")}
77554
-
77555
- \`\`\`markdown
77559
+ // ../../services/backend/prompts/utils/handoff-report-template-body.ts
77560
+ function getHandoffReportTemplateBody(roleGuidanceContext) {
77561
+ return `<handoff-overview>
77556
77562
  ## Summary
77557
77563
  <what was accomplished, in plain terms — no references to prior messages>
77558
77564
 
77565
+ ## What changed
77566
+ <high-level view of what changed since the user's message>
77567
+ </handoff-overview>
77568
+
77569
+ <!-- UI collapses proofs, direction, and notes by default; overview and action required are expanded -->
77570
+
77571
+ <handoff-proofs>
77559
77572
  ## Template Disclosure Confirmation
77560
77573
  - [ ] I confirm that I have seen this template at the start of any planning, before working on or delegating any task to the team
77561
77574
  ${getRoleGuidanceDisclosureBlock(roleGuidanceContext)}
77562
77575
 
77563
77576
  ## Proof of Planning
77564
- <!-- Demonstrate the goal was decomposed into actionable steps with clear outcomes before implementation. -->
77577
+ <!-- REQUIRED. List planning steps, or write "Not Applicable" for trivial single-step tasks. Do not omit this section. -->
77565
77578
  - <step 1: concrete artifact or outcome>
77566
77579
  - <step 2: concrete artifact or outcome>
77567
- <Omit for trivial single-step tasks.>
77568
-
77569
- ## What changed
77570
- <high-level view of what changed since the user's message before the detailed proofs below>
77571
77580
 
77572
- ${PROOF_OF_PRINCIPLES_HEADING_H3}
77573
- ${getHandoffQualityPrinciplesCommentBlock()}
77574
- <how this work follows the principles above — localized changes, readable structure, correctness provable from source then tests>
77581
+ ${getHandoffQualityPrinciplesSectionBlock()}
77575
77582
 
77576
- ### Proof of Completion
77583
+ ## Proof of Completion
77577
77584
  ${getContextReadDisclosureBlock(roleGuidanceContext)}
77578
77585
  ${getFileReferenceProofOfCompletionExample()}
77579
77586
  <evidence the goal was met — list every file you (or the builder) modified>
77580
77587
 
77581
77588
  ## Backlog Tasks Implemented
77589
+ <!-- REQUIRED. List backlog items addressed, or write "Not Applicable" if none were in scope. Do not omit this section. -->
77582
77590
  - \`backlog-item-id\` — <backlog item title/summary and how this work addresses it>
77583
- <Omit if no backlog items were in scope.>
77584
77591
 
77585
77592
  ## Backlog Pending User Review Confirmation
77593
+ <!-- REQUIRED. Complete the attestation, or write "Not Applicable" if no backlog items apply. Do not omit this section. -->
77586
77594
  - [ ] I confirm that every backlog item implemented in this work has been moved to \`pending_user_review\` via \`chatroom backlog mark-for-review\` after the feature was verified end-to-end and a PR was raised for user review
77587
77595
  - PR URL(s): <link to PR(s)>
77588
- <Omit this section if no backlog items apply.>
77596
+
77597
+ ## Code Change Verification
77598
+ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
77599
+ </handoff-proofs>
77600
+
77601
+ <handoff-direction>
77602
+ ## What exists today
77603
+ <!-- REQUIRED. Describe current state after this work, or write "Not Applicable". Do not omit this section. -->
77604
+ <current state after this work — what the user can now do, what is in place, how the system behaves>
77589
77605
 
77590
77606
  ## Key Technical Decisions
77607
+ <!-- REQUIRED. List decisions, or write "Not Applicable". Do not omit this section. -->
77591
77608
  - <schema design, modules, interfaces, domain entities — what you chose and why>
77592
77609
 
77593
77610
  ## Key Tradeoffs
77611
+ <!-- REQUIRED. List tradeoffs, or write "Not Applicable". Do not omit this section. -->
77594
77612
  - <what was weighed against what, and why you chose this path>
77595
77613
 
77596
- ## Tech Debt Observed
77597
- - <issues noticed but intentionally left out of scope of this change>
77598
-
77599
77614
  ## System Design
77600
- <include a mermaid diagram when the change has non-trivial structure; omit for trivial changes>
77615
+ <!-- REQUIRED. Include a mermaid diagram when the change has non-trivial structure, or write "Not Applicable". Do not omit this section. -->
77601
77616
 
77602
77617
  \`\`\`mermaid
77603
77618
  flowchart TD
77604
77619
  A[Component] --> B[Component]
77605
77620
  \`\`\`
77621
+ </handoff-direction>
77606
77622
 
77607
- ## Code Change Verification
77608
- ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
77623
+ <handoff-notes>
77624
+ ## Notes
77625
+ <!-- REQUIRED. Write notes, or "Not Applicable" if none. Do not omit this section. -->
77626
+ <anything the user should know — context, caveats, or observations not covered above>
77627
+ </handoff-notes>
77628
+
77629
+ <handoff-action>
77630
+ ## Tech Debt Observed
77631
+ <!-- REQUIRED. List tech debt, or write "Not Applicable". Do not omit this section. -->
77632
+ - <issues noticed but intentionally left out of scope of this change>
77609
77633
 
77610
77634
  ${getUnresolvedDecisionsSectionBlock()}
77611
77635
 
77612
- ## Notes
77613
- <anything the user should know context, caveats, or observations not covered above. Omit if none.>
77614
- \`\`\``;
77636
+ ## Manual steps
77637
+ <!-- REQUIRED. List manual steps outside the system, or write "Not Applicable". Do not omit this section. -->
77638
+ <steps the user must take outside the system — deploy, configure credentials, run commands, verify in production, etc.>
77639
+ </handoff-action>`;
77615
77640
  }
77616
- var init_planner_to_user = __esm(() => {
77641
+ var init_handoff_report_template_body = __esm(() => {
77617
77642
  init_context_disclosure();
77618
77643
  init_handoff_quality_principles();
77619
77644
  init_role_guidance_disclosure();
77620
77645
  });
77621
77646
 
77647
+ // ../../services/backend/prompts/teams/duo/handoff-templates/planner-to-user.ts
77648
+ function getPlannerToUserReportTemplate(roleGuidanceContext) {
77649
+ return `${getHandoffRecipientVisibilityCallout("user")}
77650
+
77651
+ ${getHandoffReportTemplateIntro("Report Template (Planner → User)")}
77652
+
77653
+ \`\`\`markdown
77654
+ ${getHandoffReportTemplateBody(roleGuidanceContext)}
77655
+ \`\`\``;
77656
+ }
77657
+ var init_planner_to_user = __esm(() => {
77658
+ init_handoff_report_template_body();
77659
+ });
77660
+
77622
77661
  // ../../services/backend/prompts/teams/duo/handoff-templates/index.ts
77623
77662
  function getDuoHandoffTemplate(query) {
77624
77663
  const getter = DUO_HANDOFF_TEMPLATES[`${query.fromRole.toLowerCase()}:${query.toRole.toLowerCase()}`];
@@ -77655,70 +77694,11 @@ function getSoloToUserReportTemplate(roleGuidanceContext) {
77655
77694
  ${getHandoffReportTemplateIntro("Report Template (Solo → User)")}
77656
77695
 
77657
77696
  \`\`\`markdown
77658
- ## Summary
77659
- <what was accomplished, in plain terms — no references to prior messages>
77660
-
77661
- ## Template Disclosure Confirmation
77662
- - [ ] I confirm that I have seen this template at the start of any planning, before implementing any code for this task
77663
- ${getRoleGuidanceDisclosureBlock(roleGuidanceContext)}
77664
-
77665
- ## Proof of Planning
77666
- <!-- Demonstrate the goal was decomposed into actionable steps with clear outcomes before implementation. -->
77667
- - <step 1: concrete artifact or outcome>
77668
- - <step 2: concrete artifact or outcome>
77669
- <Omit for trivial single-step tasks.>
77670
-
77671
- ## What changed
77672
- <high-level view of what changed since the user's message before the detailed proofs below>
77673
-
77674
- ${PROOF_OF_PRINCIPLES_HEADING_H3}
77675
- ${getHandoffQualityPrinciplesCommentBlock()}
77676
- <how this work follows the principles above — localized changes, readable structure, correctness provable from source then tests>
77677
-
77678
- ### Proof of Completion
77679
- ${getContextReadDisclosureBlock(roleGuidanceContext)}
77680
- ${getFileReferenceProofOfCompletionExample()}
77681
- <evidence the goal was met — list every file you modified>
77682
-
77683
- ## Backlog Tasks Implemented
77684
- - \`backlog-item-id\` — <backlog item title/summary and how this work addresses it>
77685
- <Omit if no backlog items were in scope.>
77686
-
77687
- ## Backlog Pending User Review Confirmation
77688
- - [ ] I confirm that every backlog item implemented in this work has been moved to \`pending_user_review\` via \`chatroom backlog mark-for-review\` after the feature was verified end-to-end and a PR was raised for user review
77689
- - PR URL(s): <link to PR(s)>
77690
- <Omit this section if no backlog items apply.>
77691
-
77692
- ## Key Technical Decisions
77693
- - <schema design, modules, interfaces, domain entities — what you chose and why>
77694
-
77695
- ## Key Tradeoffs
77696
- - <what was weighed against what, and why you chose this path>
77697
-
77698
- ## Tech Debt Observed
77699
- - <issues noticed but intentionally left out of scope of this change>
77700
-
77701
- ## System Design
77702
- <include a mermaid diagram when the change has non-trivial structure; omit for trivial changes>
77703
-
77704
- \`\`\`mermaid
77705
- flowchart TD
77706
- A[Component] --> B[Component]
77707
- \`\`\`
77708
-
77709
- ## Code Change Verification
77710
- ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
77711
-
77712
- ${getUnresolvedDecisionsSectionBlock()}
77713
-
77714
- ## Notes
77715
- <anything the user should know — context, caveats, or observations not covered above. Omit if none.>
77697
+ ${getHandoffReportTemplateBody(roleGuidanceContext)}
77716
77698
  \`\`\``;
77717
77699
  }
77718
77700
  var init_solo_to_user = __esm(() => {
77719
- init_context_disclosure();
77720
- init_handoff_quality_principles();
77721
- init_role_guidance_disclosure();
77701
+ init_handoff_report_template_body();
77722
77702
  });
77723
77703
 
77724
77704
  // ../../services/backend/prompts/teams/solo/handoff-templates/index.ts
@@ -99304,6 +99284,30 @@ var init_assigned_task_snapshot_store = __esm(() => {
99304
99284
  rows = [];
99305
99285
  });
99306
99286
 
99287
+ // src/commands/machine/daemon-start/restart-orchestrator-in-flight.ts
99288
+ function roleKey2(chatroomId, role) {
99289
+ return `${chatroomId}:${role.toLowerCase()}`;
99290
+ }
99291
+ function markRestartOrchestratorInFlight(chatroomId, role, correlationId) {
99292
+ inFlight.set(roleKey2(chatroomId, role), correlationId);
99293
+ }
99294
+ function clearRestartOrchestratorInFlight(chatroomId, role, correlationId) {
99295
+ const key = roleKey2(chatroomId, role);
99296
+ if (correlationId !== undefined && inFlight.get(key) !== correlationId)
99297
+ return;
99298
+ inFlight.delete(key);
99299
+ }
99300
+ function isRestartOrchestratorInFlight(chatroomId, role) {
99301
+ return inFlight.has(roleKey2(chatroomId, role));
99302
+ }
99303
+ function filterSnapshotsExcludingRestartInFlight(snapshots) {
99304
+ return snapshots.filter((row) => !isRestartOrchestratorInFlight(row.chatroomId, row.agentConfig.role));
99305
+ }
99306
+ var inFlight;
99307
+ var init_restart_orchestrator_in_flight = __esm(() => {
99308
+ inFlight = new Map;
99309
+ });
99310
+
99307
99311
  // src/commands/machine/daemon-start/native-task-delivery-coordinator.ts
99308
99312
  class NativeTaskDeliveryCoordinator {
99309
99313
  onSessionLost(params) {
@@ -99316,6 +99320,8 @@ class NativeTaskDeliveryCoordinator {
99316
99320
  getRoleDeliveryState().resetDeliveryState(chatroomId, role);
99317
99321
  }
99318
99322
  tryInjectNextForRole(chatroomId, role) {
99323
+ if (isRestartOrchestratorInFlight(chatroomId, role))
99324
+ return;
99319
99325
  const session2 = getNativeDeliverySession();
99320
99326
  if (!session2)
99321
99327
  return;
@@ -99335,7 +99341,10 @@ class NativeTaskDeliveryCoordinator {
99335
99341
  });
99336
99342
  }
99337
99343
  reconcileAssignedTasks(params) {
99338
- const { tasks, runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId } = params;
99344
+ const tasks = filterSnapshotsExcludingRestartInFlight(params.tasks);
99345
+ if (tasks.length === 0)
99346
+ return;
99347
+ const { runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId } = params;
99339
99348
  const deliveryState = getRoleDeliveryState();
99340
99349
  const ledger = getNativeDeliveryLedger();
99341
99350
  const pendingFirst = [...tasks].sort((a, b) => {
@@ -99424,6 +99433,8 @@ function resetRoleDeliveryState(chatroomId, role) {
99424
99433
  getRoleDeliveryState().resetDeliveryState(chatroomId, role);
99425
99434
  }
99426
99435
  function notifyNativeTurnIdle(params) {
99436
+ if (isRestartOrchestratorInFlight(params.chatroomId, params.role))
99437
+ return;
99427
99438
  logNativeDeliveryPrimary(params.role, params.chatroomId);
99428
99439
  getNativeTaskDeliveryCoordinator().tryInjectNextForRole(params.chatroomId, params.role);
99429
99440
  }
@@ -99436,6 +99447,7 @@ var init_native_task_delivery_coordinator = __esm(() => {
99436
99447
  init_api3();
99437
99448
  init_assigned_task_snapshot_store();
99438
99449
  init_convex_error();
99450
+ init_restart_orchestrator_in_flight();
99439
99451
  });
99440
99452
 
99441
99453
  // src/commands/machine/daemon-start/restart-orchestrator.ts
@@ -99458,14 +99470,6 @@ async function waitForHarnessSessionId(deps, event, pid) {
99458
99470
  if (initial?.harnessSessionId) {
99459
99471
  return initial.harnessSessionId;
99460
99472
  }
99461
- await deps.session.backend.mutation(api.machines.emitHarnessSessionAwaiting, {
99462
- sessionId: deps.session.sessionId,
99463
- machineId: deps.session.machineId,
99464
- chatroomId: event.chatroomId,
99465
- role: event.role,
99466
- pid,
99467
- timeoutMs: HARNESS_SESSION_READY_TIMEOUT_MS
99468
- });
99469
99473
  const deadline = Date.now() + HARNESS_SESSION_READY_TIMEOUT_MS;
99470
99474
  while (Date.now() < deadline) {
99471
99475
  const slot = deps.agentMgr.getSlot(event.chatroomId, event.role);
@@ -99474,14 +99478,6 @@ async function waitForHarnessSessionId(deps, event, pid) {
99474
99478
  }
99475
99479
  await sleep5(100);
99476
99480
  }
99477
- await deps.session.backend.mutation(api.machines.emitHarnessSessionTimeout, {
99478
- sessionId: deps.session.sessionId,
99479
- machineId: deps.session.machineId,
99480
- chatroomId: event.chatroomId,
99481
- role: event.role,
99482
- pid,
99483
- timeoutMs: HARNESS_SESSION_READY_TIMEOUT_MS
99484
- });
99485
99481
  await deps.agentMgr.stop({
99486
99482
  chatroomId: event.chatroomId,
99487
99483
  role: event.role,
@@ -99576,15 +99572,14 @@ async function deliverPendingTasks(deps, event) {
99576
99572
  }
99577
99573
  async function runRestartOrchestrator(deps, event) {
99578
99574
  const { chatroomId, role } = event;
99575
+ markRestartOrchestratorInFlight(chatroomId, role, event.correlationId);
99579
99576
  try {
99580
- await emitPhase(deps, event, "reset");
99581
99577
  resetRoleDeliveryState(chatroomId, role);
99582
99578
  await deps.agentMgr.stop({
99583
99579
  chatroomId,
99584
99580
  role,
99585
99581
  reason: "user.restart"
99586
99582
  });
99587
- await emitPhase(deps, event, "spawn");
99588
99583
  const spawnResult = await exports_Effect.runPromise(deps.agentMgr.ensureRunning({
99589
99584
  chatroomId,
99590
99585
  role,
@@ -99598,23 +99593,12 @@ async function runRestartOrchestrator(deps, event) {
99598
99593
  await emitPhase(deps, event, "failed", spawnResult.error ?? "spawn failed");
99599
99594
  return;
99600
99595
  }
99601
- await emitPhase(deps, event, "await_session");
99602
99596
  const harnessSessionId = await waitForHarnessSessionId(deps, event, spawnResult.pid);
99603
99597
  if (!harnessSessionId) {
99604
99598
  await emitPhase(deps, event, "failed", "harnessSessionId timeout");
99605
99599
  return;
99606
99600
  }
99607
- await deps.session.backend.mutation(api.machines.emitHarnessSessionReady, {
99608
- sessionId: deps.session.sessionId,
99609
- machineId: deps.session.machineId,
99610
- chatroomId,
99611
- role,
99612
- harnessSessionId,
99613
- pid: spawnResult.pid
99614
- });
99615
99601
  await forceNativeWaiting(deps, event);
99616
- await emitPhase(deps, event, "ready");
99617
- await emitPhase(deps, event, "deliver");
99618
99602
  const deliveredTaskIds = await deliverPendingTasks(deps, event);
99619
99603
  await deps.session.backend.mutation(api.machines.emitRestartCompleted, {
99620
99604
  sessionId: deps.session.sessionId,
@@ -99624,10 +99608,11 @@ async function runRestartOrchestrator(deps, event) {
99624
99608
  correlationId: event.correlationId,
99625
99609
  deliveredTaskIds
99626
99610
  });
99627
- await emitPhase(deps, event, "completed");
99628
99611
  } catch (err) {
99629
99612
  console.warn(`[RestartOrchestrator] failed for ${role}@${chatroomId}: ${getErrorMessage(err)}`);
99630
99613
  await emitPhase(deps, event, "failed", getErrorMessage(err));
99614
+ } finally {
99615
+ clearRestartOrchestratorInFlight(chatroomId, role, event.correlationId);
99631
99616
  }
99632
99617
  }
99633
99618
  var init_restart_orchestrator = __esm(() => {
@@ -99641,6 +99626,7 @@ var init_restart_orchestrator = __esm(() => {
99641
99626
  init_native_task_injector();
99642
99627
  init_api3();
99643
99628
  init_convex_error();
99629
+ init_restart_orchestrator_in_flight();
99644
99630
  });
99645
99631
 
99646
99632
  // src/events/daemon/agent/on-request-restart-agent.ts
@@ -100762,6 +100748,17 @@ async function openFinder(workingDir) {
100762
100748
  execFireAndForget(`${cmd} ${escapeShellArg(workingDir)}`, "open-finder");
100763
100749
  return { success: true };
100764
100750
  }
100751
+ async function openCursor(workingDir) {
100752
+ const available = await isCliAvailable("cursor");
100753
+ if (!available) {
100754
+ return {
100755
+ success: false,
100756
+ error: "Cursor CLI (cursor) not found. Install via: Cursor → Cmd+Shift+P → 'Shell Command: Install cursor in PATH'"
100757
+ };
100758
+ }
100759
+ execFireAndForget(`cursor ${escapeShellArg(workingDir)}`, "open-cursor");
100760
+ return { success: true };
100761
+ }
100765
100762
  async function openGithubDesktop(workingDir) {
100766
100763
  const available = await isCliAvailable("github");
100767
100764
  if (!available) {
@@ -100836,6 +100833,7 @@ var init_execute_local_action = __esm(() => {
100836
100833
  actionHandlers = {
100837
100834
  "open-vscode": openVscode,
100838
100835
  "open-finder": openFinder,
100836
+ "open-cursor": openCursor,
100839
100837
  "open-github-desktop": openGithubDesktop,
100840
100838
  "git-discard-file": gitDiscardFileAction,
100841
100839
  "git-discard-all": gitDiscardAllAction,
@@ -103256,7 +103254,7 @@ var init_open_pending_session = __esm(() => {
103256
103254
 
103257
103255
  // src/commands/machine/daemon-start/direct-harness/session-subscriber.ts
103258
103256
  function startSessionSubscriber(daemonSession, wsClient2, deps) {
103259
- const inFlight = new Set;
103257
+ const inFlight2 = new Set;
103260
103258
  const unsub = wsClient2.onUpdate(api.daemon.directHarness.sessions.listPendingSessionsForMachine, {
103261
103259
  sessionId: daemonSession.sessionId,
103262
103260
  machineId: daemonSession.machineId
@@ -103265,9 +103263,9 @@ function startSessionSubscriber(daemonSession, wsClient2, deps) {
103265
103263
  return;
103266
103264
  for (const session2 of pendingSessions) {
103267
103265
  const rowId = session2._id;
103268
- if (inFlight.has(rowId))
103266
+ if (inFlight2.has(rowId))
103269
103267
  continue;
103270
- inFlight.add(rowId);
103268
+ inFlight2.add(rowId);
103271
103269
  (async () => {
103272
103270
  const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
103273
103271
  const agent = session2.opencode?.lastUsedConfig?.agent ?? "build";
@@ -103278,7 +103276,7 @@ function startSessionSubscriber(daemonSession, wsClient2, deps) {
103278
103276
  harnessName,
103279
103277
  lastUsedConfig: { agent, ...model ? { model } : {} }
103280
103278
  }, { logPrefix: "[direct-harness]", handleProviderIdEvents: true });
103281
- })().finally(() => inFlight.delete(rowId));
103279
+ })().finally(() => inFlight2.delete(rowId));
103282
103280
  }
103283
103281
  }, (err) => {
103284
103282
  console.warn("[direct-harness] Session subscription error:", err instanceof Error ? err.message : String(err));
@@ -103813,21 +103811,21 @@ var init_prompt_subscriber2 = __esm(() => {
103813
103811
 
103814
103812
  // src/commands/machine/daemon-start/agentic-query/session-subscriber.ts
103815
103813
  function startSessionSubscriber2(daemonSession, wsClient2, deps) {
103816
- const inFlight = new Set;
103814
+ const inFlight2 = new Set;
103817
103815
  const unsub = wsClient2.onUpdate(api.daemon.agenticQuery.runs.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId }, (pendingSessions) => {
103818
103816
  if (!pendingSessions || pendingSessions.length === 0)
103819
103817
  return;
103820
103818
  for (const session2 of pendingSessions) {
103821
103819
  const rowId = session2.runId;
103822
- if (inFlight.has(rowId))
103820
+ if (inFlight2.has(rowId))
103823
103821
  continue;
103824
- inFlight.add(rowId);
103822
+ inFlight2.add(rowId);
103825
103823
  openPendingHarnessSession(daemonSession, deps, {
103826
103824
  rowId: session2.runId,
103827
103825
  workspaceId: session2.workspaceId,
103828
103826
  harnessName: session2.harnessName,
103829
103827
  lastUsedConfig: session2.lastUsedConfig
103830
- }, { logPrefix: "[agentic-query]", handleProviderIdEvents: false }).finally(() => inFlight.delete(rowId));
103828
+ }, { logPrefix: "[agentic-query]", handleProviderIdEvents: false }).finally(() => inFlight2.delete(rowId));
103831
103829
  }
103832
103830
  }, (err) => {
103833
103831
  console.warn("[agentic-query] Session subscription error:", err instanceof Error ? err.message : String(err));
@@ -104120,12 +104118,12 @@ var init_wait_for_enhancer_job = __esm(() => {
104120
104118
 
104121
104119
  // src/commands/machine/daemon-start/enhancer/job-subscriber.ts
104122
104120
  function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, wsClient2, agentServices) {
104123
- const inFlight = new Set;
104121
+ const inFlight2 = new Set;
104124
104122
  const unsub = wsClient2.onUpdate(api.daemon.enhancer.index.pendingForMachine, { sessionId, machineId }, (jobs) => {
104125
104123
  for (const job of jobs ?? []) {
104126
- if (inFlight.has(job.jobId))
104124
+ if (inFlight2.has(job.jobId))
104127
104125
  continue;
104128
- inFlight.add(job.jobId);
104126
+ inFlight2.add(job.jobId);
104129
104127
  (async () => {
104130
104128
  let claimed = false;
104131
104129
  let chatroomId = job.chatroomId;
@@ -104213,7 +104211,7 @@ function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, w
104213
104211
  });
104214
104212
  }
104215
104213
  } finally {
104216
- inFlight.delete(job.jobId);
104214
+ inFlight2.delete(job.jobId);
104217
104215
  if (spawnResult && service3) {
104218
104216
  try {
104219
104217
  await service3.stop(spawnResult.pid);
@@ -114533,6 +114531,8 @@ async function nudgeStuckTasks(tasks, now, cooldown, runtime4, effectContext2, a
114533
114531
  }
114534
114532
  async function reviveNativeTasks(tasks, localHealth, now, cooldown, runtime4, effectContext2, agentMgr, sessionDeps, machineId) {
114535
114533
  for (const row of listNativeTasksNeedingRevive(tasks, localHealth, now, cooldown)) {
114534
+ if (isRestartOrchestratorInFlight(row.chatroomId, row.agentConfig.role))
114535
+ continue;
114536
114536
  await clearStuckStoppingSlotIfNeeded(agentMgr, row.chatroomId, row.agentConfig.role);
114537
114537
  const full = await fetchTaskForAction(sessionDeps, machineId, row);
114538
114538
  if (!full)
@@ -114541,6 +114541,7 @@ async function reviveNativeTasks(tasks, localHealth, now, cooldown, runtime4, ef
114541
114541
  }
114542
114542
  }
114543
114543
  async function processTasksUpdate(tasks, runtime4, effectContext2, cooldown, agentMgr, sessionDeps, machineId, _pass) {
114544
+ tasks = filterSnapshotsExcludingRestartInFlight(tasks);
114544
114545
  if (tasks.length === 0)
114545
114546
  return;
114546
114547
  const now = Date.now();
@@ -114577,7 +114578,7 @@ function runLocalStoreReconcilePass(params) {
114577
114578
  const { stopped, monitorPassInFlight, agentMgr, runtime: runtime4, effectContext: effectContext2, sessionDeps, machineId } = params;
114578
114579
  if (stopped || monitorPassInFlight)
114579
114580
  return;
114580
- const deliverable = listDeliverablePendingFromStore(agentMgr);
114581
+ const deliverable = filterSnapshotsExcludingRestartInFlight(listDeliverablePendingFromStore(agentMgr));
114581
114582
  if (deliverable.length === 0)
114582
114583
  return;
114583
114584
  const first = deliverable[0];
@@ -114720,6 +114721,7 @@ var init_task_monitor = __esm(() => {
114720
114721
  init_esm();
114721
114722
  init_daemon_services();
114722
114723
  init_native_ready_invariant();
114724
+ init_restart_orchestrator_in_flight();
114723
114725
  init_native_task_delivery_coordinator();
114724
114726
  init_native_task_injector_logic();
114725
114727
  init_task_monitor_logic();
@@ -116379,4 +116381,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
116379
116381
  });
116380
116382
  program2.parse();
116381
116383
 
116382
- //# debugId=550B12123AE171BD64756E2164756E21
116384
+ //# debugId=F542CAE8E215492E64756E2164756E21