chatroom-cli 1.75.0 → 1.77.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/dist/index.js CHANGED
@@ -76767,7 +76767,8 @@ var init_participant = __esm(() => {
76767
76767
  "task.inProgress",
76768
76768
  "task.completed",
76769
76769
  "agent.requestStop",
76770
- "agent.awaitingHandoff"
76770
+ "agent.awaitingHandoff",
76771
+ "agent.enhancing"
76771
76772
  ]);
76772
76773
  });
76773
76774
 
@@ -77365,6 +77366,38 @@ var init_builder_to_planner = __esm(() => {
77365
77366
  init_role_guidance_disclosure();
77366
77367
  });
77367
77368
 
77369
+ // ../../services/backend/prompts/teams/duo/handoff-templates/enhancer-to-planner.ts
77370
+ function getEnhancerToPlannerHandoffTemplate() {
77371
+ return `${getHandoffRecipientVisibilityCallout("planner")}
77372
+
77373
+ ${getHandoffReportTemplateIntro("Planning Feedback (Enhancer → Planner)")}
77374
+
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.
77376
+
77377
+ \`\`\`markdown
77378
+ ## Summary
77379
+ <one paragraph: overall assessment of the planner's check-in — strengths and the main gaps to address>
77380
+
77381
+ ## User intent assessment
77382
+ <mistakes or misreadings in what the user may want; clarify the correct interpretation>
77383
+
77384
+ ## Knowledge gaps
77385
+ <facts, context, or research the planner is missing or has not surfaced>
77386
+
77387
+ ## Reasoning & logic
77388
+ <logical errors, weak inference chains, contradictions, or unsupported conclusions>
77389
+
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>
77392
+
77393
+ ## Recommended next steps
77394
+ <concrete actions for the planner: what to research, revise, validate, or decide before proceeding>
77395
+ \`\`\`
77396
+
77397
+ Return only the feedback markdown — no preamble. Follow this structure; omit sections that truly do not apply.`;
77398
+ }
77399
+ var init_enhancer_to_planner = () => {};
77400
+
77368
77401
  // ../../services/backend/prompts/teams/duo/handoff-templates/planner-to-builder.ts
77369
77402
  function getPlannerToBuilderHandoffTemplate(nativeIntegration = false) {
77370
77403
  const sessionManagement = nativeIntegration ? `\`compact\` runs in-session context compaction via the SDK runtime. \`new_session\` starts a completely new session within the same process (not compaction). \`none\` continues the prior session. Tasks continue via injection.` : `\`compact\` is NOT supported — use \`none\` or \`new_session\`. \`new_session\` requires a hard restart (daemon stops agent, cold-starts, agent rejoins via \`get-next-task\`). \`none\` resumes prior session (\`wantResume=true\`).`;
@@ -77449,6 +77482,41 @@ Keep one slice ≈ one focused review surface. Delegate slices incrementally —
77449
77482
  }
77450
77483
  var init_planner_to_builder = () => {};
77451
77484
 
77485
+ // ../../services/backend/prompts/teams/duo/handoff-templates/planner-to-enhancer.ts
77486
+ function getPlannerToEnhancerHandoffTemplate() {
77487
+ return `${getHandoffRecipientVisibilityCallout("enhancer")}
77488
+
77489
+ **Mandatory Planning Check-in (Planner → Enhancer)** — paste into the handoff message. **Do not skip this check-in** when the enhancer is enabled.
77490
+
77491
+ The enhancer has **no session context** — only this message. Use the three XML sections below **exactly** — they delimit what the enhancer will review.
77492
+
77493
+ \`\`\`markdown
77494
+ <user-message>
77495
+ <verbatim or faithful quote of the user's request — include constraints, priorities, and classification context if relevant>
77496
+ </user-message>
77497
+
77498
+ <grounding>
77499
+ <fully detailed research the enhancer cannot see from your session — be exhaustive>
77500
+
77501
+ Include:
77502
+ - **Existing code examples** — relevant snippets, patterns, and conventions already in the codebase
77503
+ - **File references** — paths to every file you investigated or plan to change
77504
+ - **Technology choices** — libraries, frameworks, APIs, and why they apply here
77505
+ - **Observations** — what you learned, edge cases, risks, and open questions from investigation
77506
+ ${getFileReferenceGuidanceComment()}
77507
+ </grounding>
77508
+
77509
+ <builder-handoff>
77510
+ <your complete, filled-in Delegation Brief for builder review — every section with real content, not placeholders>
77511
+
77512
+ Follow the **Handoff to \`builder\`** template structure (Summary, Goal, Files to implement, Requirements, etc.). The enhancer critiques this draft before you delegate.
77513
+ </builder-handoff>
77514
+ \`\`\`
77515
+
77516
+ 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.`;
77517
+ }
77518
+ var init_planner_to_enhancer = () => {};
77519
+
77452
77520
  // ../../services/backend/prompts/cli/context/read.ts
77453
77521
  function contextReadCommand(params = {}) {
77454
77522
  const prefix = params.cliEnvPrefix ?? "";
@@ -77540,8 +77608,11 @@ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
77540
77608
 
77541
77609
  ${getUnresolvedDecisionsSectionBlock()}
77542
77610
 
77543
- ## Notes / Next steps
77544
- <anything the user should know, follow-ups, or open questions>
77611
+ ## Notes
77612
+ <anything the user should know — context, caveats, or observations not covered above. Omit if none.>
77613
+
77614
+ ## Next steps
77615
+ <follow-up actions for the user or team. Omit if none.>
77545
77616
  \`\`\``;
77546
77617
  }
77547
77618
  var init_planner_to_user = __esm(() => {
@@ -77558,10 +77629,14 @@ function getDuoHandoffTemplate(query) {
77558
77629
  var DUO_HANDOFF_TEMPLATES;
77559
77630
  var init_handoff_templates = __esm(() => {
77560
77631
  init_builder_to_planner();
77632
+ init_enhancer_to_planner();
77561
77633
  init_planner_to_builder();
77634
+ init_planner_to_enhancer();
77562
77635
  init_planner_to_user();
77563
77636
  DUO_HANDOFF_TEMPLATES = {
77564
77637
  "planner:builder": (query) => getPlannerToBuilderHandoffTemplate(query.nativeIntegration),
77638
+ "planner:enhancer": () => getPlannerToEnhancerHandoffTemplate(),
77639
+ "enhancer:planner": () => getEnhancerToPlannerHandoffTemplate(),
77565
77640
  "planner:user": (query) => getPlannerToUserReportTemplate({
77566
77641
  chatroomId: query.chatroomId,
77567
77642
  role: query.role,
@@ -77638,8 +77713,11 @@ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
77638
77713
 
77639
77714
  ${getUnresolvedDecisionsSectionBlock()}
77640
77715
 
77641
- ## Notes / Next steps
77642
- <anything the user should know, follow-ups, or open questions>
77716
+ ## Notes
77717
+ <anything the user should know — context, caveats, or observations not covered above. Omit if none.>
77718
+
77719
+ ## Next steps
77720
+ <follow-up actions for the user or team. Omit if none.>
77643
77721
  \`\`\``;
77644
77722
  }
77645
77723
  var init_solo_to_user = __esm(() => {
@@ -80380,11 +80458,33 @@ function composeSystemPrompt2(input) {
80380
80458
  });
80381
80459
  return composeSections(buildInitPromptSections(input, selectorCtx));
80382
80460
  }
80461
+ function isEnhancerCheckInQueuedHandoff(params) {
80462
+ return params.enhancerCheckInQueued === true && params.role.toLowerCase() === "planner" && params.nextRole.toLowerCase() === "enhancer";
80463
+ }
80464
+ function getEnhancerCheckInQueuedConfirmationLines() {
80465
+ return [
80466
+ "✅ Planning check-in queued for handoff enhancer",
80467
+ "",
80468
+ "Your check-in was sent to the handoff enhancer (async). You will receive planning feedback back as a planner task when review completes.",
80469
+ "**Run get-next-task now and end your turn** — do not wait for feedback, poll, or re-submit the handoff."
80470
+ ];
80471
+ }
80383
80472
  function generateHandoffOutput(params) {
80384
- const { role, nextRole, chatroomId, convexUrl, supportsNativeIntegration } = params;
80473
+ const {
80474
+ role,
80475
+ nextRole,
80476
+ chatroomId,
80477
+ convexUrl,
80478
+ supportsNativeIntegration,
80479
+ enhancerCheckInQueued
80480
+ } = params;
80385
80481
  const cliEnvPrefix = getCliEnvPrefix(convexUrl);
80386
80482
  const lines = [];
80387
- lines.push(`✅ Chatroom task completed and handed off to ${nextRole}`);
80483
+ if (isEnhancerCheckInQueuedHandoff({ role, nextRole, enhancerCheckInQueued })) {
80484
+ lines.push(...getEnhancerCheckInQueuedConfirmationLines());
80485
+ } else {
80486
+ lines.push(`✅ Chatroom task completed and handed off to ${nextRole}`);
80487
+ }
80388
80488
  if (supportsNativeIntegration) {
80389
80489
  lines.push(getNativeHandoffTurnEndGuidance(nextRole));
80390
80490
  } else {
@@ -103343,7 +103443,6 @@ class BufferedJournalFactory {
103343
103443
  return;
103344
103444
  flushInProgress = true;
103345
103445
  const batch = buffer.splice(0);
103346
- console.log(`[journal] Flushing ${batch.length} chunks for session ${harnessSessionId}`);
103347
103446
  outputRepository.appendChunks(harnessSessionId, batch).catch((err) => {
103348
103447
  buffer.unshift(...batch);
103349
103448
  logger.warn(`[journal] Flush FAILED for ${harnessSessionId}: ${err instanceof Error ? err.message : String(err)}`);
@@ -103362,7 +103461,6 @@ class BufferedJournalFactory {
103362
103461
  messageId: chunk2.messageId,
103363
103462
  partType: chunk2.partType
103364
103463
  });
103365
- logger.log?.(`[journal] chunk recorded session=${harnessSessionId} messageId=${chunk2.messageId ?? "-"} partType=${chunk2.partType ?? "text"} bytes=${chunk2.content.length}`);
103366
103464
  },
103367
103465
  async flush() {
103368
103466
  await waitForInProgress();
@@ -103788,6 +103886,19 @@ var init_start_subscriptions2 = __esm(() => {
103788
103886
  // src/commands/machine/daemon-start/enhancer/constants.ts
103789
103887
  var ENHANCER_AGENT_ROLE = "enhancer";
103790
103888
 
103889
+ // src/commands/machine/daemon-start/enhancer/enhancer-log.ts
103890
+ function formatEnhancerLogLine(message) {
103891
+ const trimmed = message.trimEnd();
103892
+ if (trimmed.startsWith(ENHANCER_LOG_PREFIX))
103893
+ return trimmed;
103894
+ return `${ENHANCER_LOG_PREFIX} ${trimmed}`;
103895
+ }
103896
+ function writeEnhancerLog(message) {
103897
+ process.stdout.write(`${formatEnhancerLogLine(message)}
103898
+ `);
103899
+ }
103900
+ var ENHANCER_LOG_PREFIX = "[enhancer]";
103901
+
103791
103902
  // src/commands/machine/daemon-start/enhancer/job-subscriber.ts
103792
103903
  function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, wsClient2, agentServices) {
103793
103904
  const inFlight = new Set;
@@ -103809,12 +103920,14 @@ function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, w
103809
103920
  if (!claim.claimed)
103810
103921
  return;
103811
103922
  claimed = true;
103923
+ writeEnhancerLog(`claimed job=${job.jobId} chatroom=${job.chatroomId}`);
103812
103924
  const payload = await backend2.query(api.daemon.enhancer.index.getSpawnPayload, {
103813
103925
  sessionId,
103814
103926
  jobId: job.jobId
103815
103927
  });
103816
103928
  chatroomId = payload.chatroomId;
103817
103929
  jobId = payload.jobId;
103930
+ writeEnhancerLog(`spawning harness=${payload.agentHarness} model=${payload.model} job=${payload.jobId}`);
103818
103931
  const service3 = agentServices.get(payload.agentHarness);
103819
103932
  if (!service3) {
103820
103933
  await backend2.mutation(api.web.enhancer.index.recordAttemptFailure, {
@@ -103838,8 +103951,11 @@ function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, w
103838
103951
  resolvedConvexUrl: convexUrl
103839
103952
  });
103840
103953
  spawnResult.onLogLine?.((line) => {
103841
- process.stdout.write(`${line}
103842
- `);
103954
+ writeEnhancerLog(line);
103955
+ });
103956
+ spawnResult.onAssistantText?.((text) => {
103957
+ if (text)
103958
+ writeEnhancerLog(`text] ${text}`);
103843
103959
  });
103844
103960
  await new Promise((resolve4) => {
103845
103961
  spawnResult.onExit(() => resolve4());
@@ -103849,6 +103965,9 @@ function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, w
103849
103965
  chatroomId: payload.chatroomId,
103850
103966
  jobId: payload.jobId
103851
103967
  });
103968
+ if (status3?.status === "complete") {
103969
+ writeEnhancerLog(`completed job=${payload.jobId}`);
103970
+ }
103852
103971
  if (status3?.status === "running") {
103853
103972
  await backend2.mutation(api.web.enhancer.index.recordAttemptFailure, {
103854
103973
  sessionId,
@@ -103858,7 +103977,7 @@ function startEnhancerJobSubscriber(sessionId, machineId, convexUrl, backend2, w
103858
103977
  });
103859
103978
  }
103860
103979
  } catch (err) {
103861
- console.warn("[enhancer] spawn error:", err instanceof Error ? err.message : String(err));
103980
+ writeEnhancerLog(`error: ${err instanceof Error ? err.message : String(err)}`);
103862
103981
  if (claimed) {
103863
103982
  await backend2.mutation(api.web.enhancer.index.recordAttemptFailure, {
103864
103983
  sessionId,
@@ -115642,7 +115761,7 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
115642
115761
  console.error("❌ Message is empty");
115643
115762
  process.exit(1);
115644
115763
  }
115645
- const shouldEnhance = options.role.toLowerCase() === "planner" && options.nextRole.toLowerCase() === "builder";
115764
+ const shouldEnhance = options.role.toLowerCase() === "planner" && options.nextRole.toLowerCase() === "enhancer";
115646
115765
  if (shouldEnhance) {
115647
115766
  const { api: api3 } = await Promise.resolve().then(() => (init_api3(), exports_api));
115648
115767
  const { getConvexClient: getConvexClient2 } = await Promise.resolve().then(() => (init_client2(), exports_client));
@@ -115670,7 +115789,8 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
115670
115789
  role: options.role,
115671
115790
  nextRole: options.nextRole,
115672
115791
  chatroomId: options.chatroomId,
115673
- convexUrl
115792
+ convexUrl,
115793
+ enhancerCheckInQueued: true
115674
115794
  }));
115675
115795
  return;
115676
115796
  }
@@ -115678,7 +115798,7 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
115678
115798
  const error51 = err;
115679
115799
  if (error51?.data?.code !== "ENHANCER_NOT_ENABLED") {
115680
115800
  console.error(`
115681
- ❌ ERROR: Enhancer interception failed`);
115801
+ ❌ ERROR: Enhancer check-in failed`);
115682
115802
  console.error(`
115683
115803
  ${error51?.data?.message ?? err.message}`);
115684
115804
  process.exit(1);
@@ -116027,4 +116147,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
116027
116147
  });
116028
116148
  program2.parse();
116029
116149
 
116030
- //# debugId=84E53044E3B850A464756E2164756E21
116150
+ //# debugId=94A8E14D18276BBD64756E2164756E21