@evident-ai/cli 3.1.1-dev.be525f8 → 3.1.1-dev.bedbd30

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
@@ -3317,6 +3317,8 @@ var ChannelDriver = class _ChannelDriver {
3317
3317
  stuckReported: false,
3318
3318
  lastAliveAt: 0,
3319
3319
  aliveInFlight: false,
3320
+ titleSynced: false,
3321
+ titleSyncInFlight: false,
3320
3322
  awaitingHumanLatched: false,
3321
3323
  pausedOnQuestion: false,
3322
3324
  pausedOnPermission: false,
@@ -3390,6 +3392,8 @@ var ChannelDriver = class _ChannelDriver {
3390
3392
  // with no extra `re_adopted` signal needed (folds old WI-6).
3391
3393
  lastAliveAt: 0,
3392
3394
  aliveInFlight: false,
3395
+ titleSynced: false,
3396
+ titleSyncInFlight: false,
3393
3397
  awaitingHumanLatched: false,
3394
3398
  pausedOnQuestion: false,
3395
3399
  pausedOnPermission: false,
@@ -3687,6 +3691,18 @@ var ChannelDriver = class _ChannelDriver {
3687
3691
  inFlight.aliveInFlight = false;
3688
3692
  if (ok) inFlight.lastAliveAt = this.now();
3689
3693
  });
3694
+ if (!inFlight.titleSynced && !inFlight.titleSyncInFlight) {
3695
+ inFlight.titleSyncInFlight = true;
3696
+ void this.resolveSessionTitle(sessionId, conv.id).then(async (title) => {
3697
+ if (!title) {
3698
+ inFlight.titleSyncInFlight = false;
3699
+ return;
3700
+ }
3701
+ const ok = await this.patchConversationTitle(conv.id, title);
3702
+ inFlight.titleSyncInFlight = false;
3703
+ if (ok) inFlight.titleSynced = true;
3704
+ });
3705
+ }
3690
3706
  }
3691
3707
  if (awaitingHuman) {
3692
3708
  if (!inFlight.awaitingHumanLatched) {
@@ -4387,6 +4403,54 @@ var ChannelDriver = class _ChannelDriver {
4387
4403
  }
4388
4404
  return null;
4389
4405
  }
4406
+ /**
4407
+ * Best-effort mid-turn title sync (#711 follow-up): PATCH a resolved OpenCode
4408
+ * session title onto the conversation via the PLAIN conversation-update
4409
+ * endpoint (`PATCH /runners/:agentId/conversations/:conversationId`) — NOT the
4410
+ * message-status endpoint `markProcessing`/`markDone` use. Deliberately a
4411
+ * separate, lighter call: it carries no `status`, so it cannot re-trigger the
4412
+ * `processing`/`done` transition side effects (Slack notices, activity-log
4413
+ * rows, delivery jobs) those PATCHes gate on `transitioned` — this call only
4414
+ * ever touches `conversations.title`. That route (`routes/conversations.ts`)
4415
+ * skips a title write matching the stored value, so a redundant call with the
4416
+ * same title is a real no-op — it does not bump `updated_at`, which the
4417
+ * conversation list sorts and paginates on. (Note this is a DIFFERENT guard
4418
+ * from `threads.ts`'s "non-empty AND changed" one, which only covers the
4419
+ * message-status PATCH; the non-empty half is enforced here instead, by
4420
+ * `resolveSessionTitle` never returning an empty/placeholder title.)
4421
+ *
4422
+ * Telemetry-only / never blocks the caller, mirroring `postSignal`: a failure
4423
+ * is logged and the title is simply retried on the next heartbeat tick (the
4424
+ * caller only latches `titleSynced` on `true`).
4425
+ */
4426
+ async patchConversationTitle(conversationId, title) {
4427
+ try {
4428
+ const res = await this.fetchImpl(
4429
+ `${this.apiUrl}/runners/${this.agentId}/conversations/${conversationId}`,
4430
+ {
4431
+ method: "PATCH",
4432
+ headers: { Authorization: this.getAuthHeader(), "Content-Type": "application/json" },
4433
+ body: JSON.stringify({ title })
4434
+ }
4435
+ );
4436
+ if (!res.ok) {
4437
+ this.log({
4438
+ level: "debug",
4439
+ message: `Mid-turn title sync PATCH for conversation ${conversationId.slice(0, 8)} returned HTTP ${res.status} (best-effort, will retry next heartbeat)`,
4440
+ conversation_id: conversationId
4441
+ });
4442
+ return false;
4443
+ }
4444
+ return true;
4445
+ } catch (err) {
4446
+ this.log({
4447
+ level: "debug",
4448
+ message: `Best-effort mid-turn title sync PATCH failed for conversation ${conversationId.slice(0, 8)} (will retry next heartbeat): ${err instanceof Error ? err.message : String(err)}`,
4449
+ conversation_id: conversationId
4450
+ });
4451
+ return false;
4452
+ }
4453
+ }
4390
4454
  /**
4391
4455
  * DEFENSIVE cross-check for the restart-recovery path (WI-2): is any descendant
4392
4456
  * (`task` sub-agent) session under `rootSessionId` still genuinely doing work?