@aiwayds/dsh-opentui 0.29.0 → 0.29.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/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.29.1] - 2026-11-26
9
+
10
+ ### Fixed
11
+
12
+ - **`session.steer` now sends a real bridge request and surfaces a typed
13
+ rejection.**
14
+ - **Failed, aborted and stopped turns no longer falsely mark a steer
15
+ `Delivered` or keep pumping the queue.**
16
+ - **Late errors from an old turn no longer contaminate the next turn.**
17
+ - **The queue pump no longer steals the scrollback.**
18
+
19
+ ### Changed
20
+
21
+ - **The 0.29 E2E suite was expanded to 17 scenarios, and the `NOT RUN` / live
22
+ contract was corrected.**
23
+
24
+ ### Known Risks
25
+
26
+ - **An unconsumed steer may remain in the host inbox after an abort or turn
27
+ error and be consumed on the next turn.** This is accepted: the host has no
28
+ removal API, so the UI keeps the steer `Injected` and never marks it
29
+ `Delivered` across turns.
30
+ - **The full-package typecheck still reports 58 pre-existing `tui-base` errors
31
+ from 0.29.0.** The entry typecheck passes.
32
+
8
33
  ## [0.29.0] - 2026-11-26
9
34
 
10
35
  ### Added
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@aiwayds/dsh-opentui-bridge",
3
3
  "version": "0.1.0",
4
- "sha256": "fcc1af91c7a63794bba58f110b396dafbba8e9885023ca4e6118997ccc1acad3"
4
+ "sha256": "2e6f512fe4b83f9691262845ab1ce5038556592aa7c1e118bf159ea7e4aafd8d"
5
5
  }
@@ -3108,103 +3108,110 @@ var ledger_default = {
3108
3108
  },
3109
3109
  wired_protocol: {
3110
3110
  mark: "bridge-protocol (ADR-0010)",
3111
- count: 14,
3111
+ count: 15,
3112
3112
  methods: [
3113
3113
  {
3114
3114
  method: "bridge.ping",
3115
3115
  kind: "meta",
3116
- source_line: 5682,
3116
+ source_line: 5747,
3117
3117
  capir_id: null,
3118
3118
  note: "protocol version negotiation (no host call)"
3119
3119
  },
3120
3120
  {
3121
3121
  method: "bridge.hello",
3122
3122
  kind: "meta",
3123
- source_line: 5691,
3123
+ source_line: 5756,
3124
3124
  capir_id: null,
3125
3125
  note: "protocol version negotiation (no host call)"
3126
3126
  },
3127
3127
  {
3128
3128
  method: "session.prune.plan",
3129
3129
  kind: "business",
3130
- source_line: 5725,
3130
+ source_line: 5790,
3131
3131
  capir_id: null,
3132
3132
  note: "retention P1 read-only dry run: session.list drain + sessionPersistence.stat locations + read-only path gates; no CapIR id, no host write, no deletion"
3133
3133
  },
3134
3134
  {
3135
3135
  method: "session.prune.apply",
3136
3136
  kind: "business",
3137
- source_line: 5731,
3137
+ source_line: 5796,
3138
3138
  capir_id: null,
3139
3139
  note: "retention P2 host-recomputed trash apply: fingerprint/max-age/config checks + host-side apply lock + rename-to-trash with rollback/journal; client entries/policy rejected; no CapIR id"
3140
3140
  },
3141
3141
  {
3142
3142
  method: "session.prune.purge",
3143
3143
  kind: "business",
3144
- source_line: 5737,
3144
+ source_line: 5802,
3145
3145
  capir_id: null,
3146
3146
  note: "retention P3 trash-only deletion: server-issued single-use HMAC token + host re-validation of trash realpath/header/manifest/residence + full gate re-probe (live agent, live path, flock) + recursive delete with per-entry failure and crash manifest; client path/policy rejected; no CapIR id"
3147
3147
  },
3148
3148
  {
3149
3149
  method: "session.prune.restore",
3150
3150
  kind: "business",
3151
- source_line: 5743,
3151
+ source_line: 5808,
3152
3152
  capir_id: null,
3153
3153
  note: "retention B4/C7 trash restore by entry id: read-only list of {id,movedAt,size?} (no path) + host re-validation of trash realpath/manifest/artifact header.id/live roster/live destination containment + refuse-if-exists + read-only flock probe + reverse rename; client path/policy rejected; no CapIR id"
3154
3154
  },
3155
3155
  {
3156
3156
  method: "subagents.interrupt",
3157
3157
  kind: "business",
3158
- source_line: 5810,
3158
+ source_line: 5875,
3159
3159
  capir_id: null,
3160
3160
  note: "L1 0.23.1 added; subagent authorization gate (binding ownership) + index reconcile + per-child cancel"
3161
3161
  },
3162
3162
  {
3163
3163
  method: "subagents.stopChildren",
3164
3164
  kind: "business",
3165
- source_line: 5814,
3165
+ source_line: 5879,
3166
3166
  capir_id: null,
3167
3167
  note: "L1 0.23.1 added; subagent authorization gate (binding ownership) + index reconcile + per-child cancel"
3168
3168
  },
3169
3169
  {
3170
3170
  method: "session.open",
3171
3171
  kind: "business",
3172
- source_line: 5818,
3172
+ source_line: 5883,
3173
3173
  capir_id: null,
3174
3174
  note: "binding orchestration (agents.create/resume + push relay/grants); multi-step, stateful"
3175
3175
  },
3176
3176
  {
3177
3177
  method: "session.send",
3178
3178
  kind: "business",
3179
- source_line: 5822,
3179
+ source_line: 5887,
3180
3180
  capir_id: null,
3181
3181
  note: "single in-flight turn state machine + streaming turn"
3182
3182
  },
3183
+ {
3184
+ method: "session.steer",
3185
+ kind: "business",
3186
+ source_line: 5891,
3187
+ capir_id: null,
3188
+ note: "029 A: bridge-owned steer into the running turn; accepts only a live non-aborting turn with agent.status==='running', calls agent.steer(createBridgeUserMessage(text)) directly, no turn id / inFlightTurnId / turn.start, no followup downgrade; typed STEER_IDLE / STEER_ENDED / STEER_ABORTING rejections never reach the host"
3189
+ },
3183
3190
  {
3184
3191
  method: "session.close",
3185
3192
  kind: "business",
3186
- source_line: 5826,
3193
+ source_line: 5895,
3187
3194
  capir_id: null,
3188
3195
  note: "binding dispose"
3189
3196
  },
3190
3197
  {
3191
3198
  method: "turn.abort",
3192
3199
  kind: "business",
3193
- source_line: 5830,
3200
+ source_line: 5899,
3194
3201
  capir_id: null,
3195
3202
  note: "turn state machine + terminalTurnIds FIFO idempotency + fire-and-forget agent.cancel"
3196
3203
  },
3197
3204
  {
3198
3205
  method: "ask.response",
3199
3206
  kind: "business",
3200
- source_line: 5834,
3207
+ source_line: 5903,
3201
3208
  capir_id: null,
3202
3209
  note: "bridge-internal AskRegistry settlement (no host call)"
3203
3210
  },
3204
3211
  {
3205
3212
  method: "journal.replay",
3206
3213
  kind: "business",
3207
- source_line: 5838,
3214
+ source_line: 5907,
3208
3215
  capir_id: null,
3209
3216
  note: "I-class persistence read (persistence.open(id,'read')); no same-name CapIR id"
3210
3217
  }
@@ -9621,7 +9628,7 @@ function getAskRegistry(ctx) {
9621
9628
  var PROTOCOL_VERSION = 1;
9622
9629
  var STDIO_SWITCH = "DSH_OPENTUI_BRIDGE_STDIO";
9623
9630
  var CAP_SMOKE_SWITCH = "DSH_OPENTUI_CAP_SMOKE";
9624
- var BRIDGE_CAPABILITIES = ["subagents.interrupt", "subagents.stopChildren"];
9631
+ var BRIDGE_CAPABILITIES = ["subagents.interrupt", "subagents.stopChildren", "session.steer"];
9625
9632
  var TERMINAL_TURN_ID_LIMIT = 64;
9626
9633
  function findPackageVersion(entryFile, wantedName) {
9627
9634
  try {
@@ -10087,7 +10094,7 @@ function apply(ctx, config) {
10087
10094
  catalog: "@deepseek-ai/dsh-api-session-controller#session/modelCatalog",
10088
10095
  select: "@deepseek-ai/dsh-api-session-controller#session/selectModel",
10089
10096
  initDefault: "@deepseek-ai/dsh-api-session-controller#session/initializeDefaultModel",
10090
- unwired: "@deepseek-ai/dsh-api-session-controller#session/create"
10097
+ unwired: "@deepseek-ai/dsh-api-session-controller#session/control"
10091
10098
  };
10092
10099
  const invoke = createCapInvoke(ctx);
10093
10100
  const probe = async (id, params) => {
@@ -11608,6 +11615,47 @@ function apply(ctx, config) {
11608
11615
  replyError(req.id, "INTERNAL", err instanceof Error ? err.message : String(err));
11609
11616
  }
11610
11617
  }
11618
+ async function handleSteer(req) {
11619
+ if (binding === undefined) {
11620
+ replyError(req.id, "SESSION_NOT_OPEN", "no open session; call session.open first");
11621
+ return;
11622
+ }
11623
+ const text = req.params.text;
11624
+ if (typeof text !== "string" || text.trim() === "") {
11625
+ replyError(req.id, "BAD_PARAMS", "session.steer requires a non-empty text string");
11626
+ return;
11627
+ }
11628
+ const state = activeTurn;
11629
+ const turnId = inFlightTurnId;
11630
+ const lastTerminalTurnId = [...terminalTurnIds].at(-1);
11631
+ if (turnId === undefined || state === undefined || state.ended || turnId !== state.turnId) {
11632
+ const ended = state !== undefined && state.ended || terminalTurnIds.size > 0;
11633
+ replyError(req.id, ended ? "STEER_ENDED" : "STEER_IDLE", ended ? "the turn has already ended; no running turn to steer" : "no turn in flight; steer requires a running turn", { turnId: turnId ?? lastTerminalTurnId ?? null });
11634
+ return;
11635
+ }
11636
+ if (state.abortRequested) {
11637
+ replyError(req.id, "STEER_ABORTING", "the in-flight turn is aborting; steer refused", { turnId });
11638
+ return;
11639
+ }
11640
+ const agent = binding.handle.agent;
11641
+ if (agent.status !== "running") {
11642
+ replyError(req.id, "STEER_IDLE", "agent is not running; steer refused", { turnId });
11643
+ return;
11644
+ }
11645
+ if (typeof agent.steer !== "function") {
11646
+ replyError(req.id, "UNSUPPORTED", "open agent has no steer() seam", { capability: "session.steer" });
11647
+ return;
11648
+ }
11649
+ const message = createBridgeUserMessage(text);
11650
+ try {
11651
+ agent.steer(message);
11652
+ logger.info("[dsh-opentui-bridge] session.steer ok turnId=%s messageId=%s", turnId, message.id);
11653
+ replyOk(req.id, { accepted: true, turnId, messageId: message.id });
11654
+ } catch (err) {
11655
+ logger.error("[dsh-opentui-bridge] session.steer failed: %s", err);
11656
+ replyError(req.id, "INTERNAL", err instanceof Error ? err.message : String(err));
11657
+ }
11658
+ }
11611
11659
  async function handleClose(req) {
11612
11660
  if (binding === undefined) {
11613
11661
  replyError(req.id, "SESSION_NOT_OPEN", "no open session");
@@ -12443,6 +12491,10 @@ function apply(ctx, config) {
12443
12491
  await handleSend(req);
12444
12492
  return;
12445
12493
  }
12494
+ if (req.method === "session.steer") {
12495
+ await handleSteer(req);
12496
+ return;
12497
+ }
12446
12498
  if (req.method === "session.close") {
12447
12499
  await handleClose(req);
12448
12500
  return;
@@ -3587,6 +3587,56 @@ var init_terminal_size = __esm(() => {
3587
3587
  });
3588
3588
 
3589
3589
  // ../tui-base/src/routes/session/composer-state.ts
3590
+ function isAbortTurnCode(code) {
3591
+ return code === "ABORTED" || code === "USER_ABORT" || code === "SESSION_CLOSED" || code === "FORKED" || code === "INTERRUPTED" || code === "TURN_ABORT_NOOP";
3592
+ }
3593
+
3594
+ class TurnOutcomeTracker {
3595
+ activeTurnId;
3596
+ outcome;
3597
+ beginTurn() {
3598
+ this.activeTurnId = undefined;
3599
+ this.outcome = undefined;
3600
+ }
3601
+ onEvent(event) {
3602
+ const details = event?.details ?? {};
3603
+ if (event?.type === "session.updated" && details.turn === "starting") {
3604
+ const id = details.turnId;
3605
+ if (typeof id === "string" && id !== "")
3606
+ this.activeTurnId = id;
3607
+ return;
3608
+ }
3609
+ if (this.activeTurnId === undefined)
3610
+ return;
3611
+ if (event?.type === "session.error") {
3612
+ if (details.turnId !== this.activeTurnId)
3613
+ return;
3614
+ const code = typeof details.code === "string" ? details.code : "INTERNAL";
3615
+ this.outcome = isAbortTurnCode(code) ? "aborted" : "failed";
3616
+ return;
3617
+ }
3618
+ if (event?.type === "bridge.turn.terminal") {
3619
+ if (details.turnId !== this.activeTurnId)
3620
+ return;
3621
+ if (details.terminalType === "turn/error") {
3622
+ const reason = details.reason ?? {};
3623
+ const code = typeof reason.code === "string" ? reason.code : "INTERNAL";
3624
+ this.outcome = isAbortTurnCode(code) ? "aborted" : "failed";
3625
+ }
3626
+ return;
3627
+ }
3628
+ if (event?.type === "bridge.turn.interrupted" && details.turnId === this.activeTurnId) {
3629
+ this.outcome = "aborted";
3630
+ }
3631
+ }
3632
+ isFailed() {
3633
+ return this.outcome === "failed";
3634
+ }
3635
+ isAborted() {
3636
+ return this.outcome === "aborted";
3637
+ }
3638
+ }
3639
+
3590
3640
  class ComposerHistory {
3591
3641
  entries = [];
3592
3642
  index = null;
@@ -3637,11 +3687,13 @@ class ComposerController {
3637
3687
  history;
3638
3688
  send;
3639
3689
  steer;
3690
+ onSteerRejected;
3640
3691
  onBusyChange;
3641
3692
  chooseDelivery;
3642
3693
  onPendingChange;
3643
3694
  onQueuePaused;
3644
3695
  isTurnAborted;
3696
+ isTurnFailed;
3645
3697
  disabled;
3646
3698
  busyState = false;
3647
3699
  pendingTurn;
@@ -3649,14 +3701,18 @@ class ComposerController {
3649
3701
  pendingRows = [];
3650
3702
  deliverySeq = 0;
3651
3703
  deliveryEpoch = 0;
3704
+ turnGeneration = 0;
3705
+ steerTurnById = new Map;
3652
3706
  constructor(options) {
3653
3707
  this.send = options.send;
3654
3708
  this.steer = options.steer;
3709
+ this.onSteerRejected = options.onSteerRejected;
3655
3710
  this.onBusyChange = options.onBusyChange;
3656
3711
  this.chooseDelivery = options.chooseDelivery;
3657
3712
  this.onPendingChange = options.onPendingChange;
3658
3713
  this.onQueuePaused = options.onQueuePaused;
3659
3714
  this.isTurnAborted = options.isTurnAborted;
3715
+ this.isTurnFailed = options.isTurnFailed;
3660
3716
  this.disabled = options.disabled;
3661
3717
  this.history = options.history ?? new ComposerHistory;
3662
3718
  }
@@ -3695,22 +3751,26 @@ class ComposerController {
3695
3751
  return "cancelled";
3696
3752
  if (delivery === undefined)
3697
3753
  return "cancelled";
3698
- this.history.append(prompt);
3699
3754
  if (!this.busyState) {
3700
- this.startTurn(prompt);
3755
+ this.history.append(prompt);
3756
+ this.startTurn(prompt, "queue");
3701
3757
  return "sent";
3702
3758
  }
3703
3759
  if (delivery === "queue") {
3760
+ this.history.append(prompt);
3704
3761
  this.enqueue(prompt);
3705
3762
  return "queued";
3706
3763
  }
3707
- this.injectSteer(prompt);
3764
+ if (!await this.injectSteer(prompt))
3765
+ return "cancelled";
3766
+ this.history.append(prompt);
3708
3767
  return "steered";
3709
3768
  }
3710
3769
  resetDeliveries() {
3711
3770
  this.deliveryEpoch += 1;
3712
3771
  this.queueItems = [];
3713
3772
  this.pendingRows = [];
3773
+ this.steerTurnById.clear();
3714
3774
  this.emitPending();
3715
3775
  }
3716
3776
  flushQueue() {
@@ -3736,18 +3796,21 @@ class ComposerController {
3736
3796
  emitPending() {
3737
3797
  this.onPendingChange?.(this.pendingRows);
3738
3798
  }
3739
- startTurn(prompt) {
3799
+ startTurn(prompt, source = "user") {
3800
+ const generation = ++this.turnGeneration;
3740
3801
  this.setBusy(true);
3741
- let failed = false;
3742
- const turn = (async () => this.send(prompt))().then(() => {
3802
+ let sendRejected = false;
3803
+ const turn = (async () => this.send(prompt, source))().then(() => {
3743
3804
  return;
3744
3805
  }, () => {
3745
- failed = true;
3806
+ sendRejected = true;
3746
3807
  });
3747
3808
  this.pendingTurn = turn.finally(() => {
3748
3809
  this.pendingTurn = undefined;
3810
+ const failed = sendRejected || (this.isTurnFailed?.() ?? false);
3749
3811
  const aborted = !failed && (this.isTurnAborted?.() ?? false);
3750
- this.markSteerDelivered();
3812
+ if (!failed && !aborted)
3813
+ this.markSteerDelivered(generation);
3751
3814
  if (failed || aborted) {
3752
3815
  this.setBusy(false);
3753
3816
  if (this.queueItems.length > 0) {
@@ -3762,7 +3825,7 @@ class ComposerController {
3762
3825
  return;
3763
3826
  }
3764
3827
  this.dropQueueRow(next.id);
3765
- this.startTurn(next.text);
3828
+ this.startTurn(next.text, "queue");
3766
3829
  });
3767
3830
  }
3768
3831
  enqueue(prompt) {
@@ -3774,16 +3837,33 @@ class ComposerController {
3774
3837
  ];
3775
3838
  this.emitPending();
3776
3839
  }
3777
- injectSteer(prompt) {
3840
+ async injectSteer(prompt) {
3841
+ const epoch = this.deliveryEpoch;
3842
+ const generation = this.turnGeneration;
3843
+ let result;
3844
+ try {
3845
+ const awaited = await this.steer(prompt);
3846
+ result = awaited !== null && typeof awaited === "object" && typeof awaited.accepted === "boolean" ? awaited : { accepted: false, reason: "INVALID_STEER_RESULT" };
3847
+ } catch (err) {
3848
+ result = { accepted: false, reason: err instanceof Error ? err.message : String(err) };
3849
+ }
3850
+ if (epoch !== this.deliveryEpoch)
3851
+ return false;
3852
+ if (!result.accepted) {
3853
+ this.onSteerRejected?.({ text: prompt, reason: result.reason });
3854
+ return false;
3855
+ }
3778
3856
  const id = ++this.deliverySeq;
3857
+ this.steerTurnById.set(id, generation);
3779
3858
  this.pendingRows = [...this.pendingRows, { id, kind: "steer", state: "injected", text: prompt }];
3780
3859
  this.emitPending();
3781
- this.steer(prompt);
3860
+ return true;
3782
3861
  }
3783
- markSteerDelivered() {
3784
- if (!this.pendingRows.some((row) => row.kind === "steer" && row.state === "injected"))
3862
+ markSteerDelivered(generation) {
3863
+ const isMine = (row) => row.kind === "steer" && row.state === "injected" && this.steerTurnById.get(row.id) === generation;
3864
+ if (!this.pendingRows.some(isMine))
3785
3865
  return;
3786
- this.pendingRows = this.pendingRows.map((row) => row.kind === "steer" && row.state === "injected" ? { ...row, state: "delivered" } : row);
3866
+ this.pendingRows = this.pendingRows.map((row) => isMine(row) ? { ...row, state: "delivered" } : row);
3787
3867
  this.emitPending();
3788
3868
  }
3789
3869
  dropQueueRow(id) {
@@ -32458,13 +32538,27 @@ function SessionComposer(props) {
32458
32538
  onCleanup(props.seam.onSubagentViews(() => {}));
32459
32539
  }
32460
32540
  const controller = new ComposerController({
32461
- send: (text) => props.send(text),
32541
+ send: (text, source) => props.send(text, source),
32462
32542
  steer: (text) => props.seam.steer(text),
32543
+ onSteerRejected: ({
32544
+ text
32545
+ }) => {
32546
+ if (disposed || textarea === undefined || textarea.isDestroyed)
32547
+ return;
32548
+ const current = textarea.plainText;
32549
+ if (current !== "" && current !== text)
32550
+ return;
32551
+ if (current !== text) {
32552
+ textarea.setText(text);
32553
+ traceSet("failure-refill", text);
32554
+ }
32555
+ },
32463
32556
  history: props.history,
32464
32557
  chooseDelivery: props.chooseDelivery,
32465
32558
  onPendingChange: props.onPendingChange,
32466
32559
  onQueuePaused: props.onQueuePaused,
32467
32560
  isTurnAborted: props.isTurnAborted,
32561
+ isTurnFailed: props.isTurnFailed,
32468
32562
  disabled: props.disabled,
32469
32563
  onBusyChange: (value) => {
32470
32564
  if (disposed)
@@ -55554,7 +55648,7 @@ var init_subagents_viewer = __esm(() => {
55554
55648
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
55555
55649
  function resolveVersion() {
55556
55650
  try {
55557
- return "0.29.0";
55651
+ return "0.29.1";
55558
55652
  } catch {
55559
55653
  return "dev";
55560
55654
  }
@@ -61768,7 +61862,7 @@ class BridgeSessionSeam {
61768
61862
  this.#currentSessionId = undefined;
61769
61863
  this.#resetModelRoute();
61770
61864
  this.#pendingOpen = { mode: "new" };
61771
- this.#settleSuspendedTurn();
61865
+ this.#settleSuspendedTurn({ code: "SESSION_CLOSED", reason: "session changed" });
61772
61866
  this.#deadInFlight = undefined;
61773
61867
  this.#inFlightPartial = "";
61774
61868
  }
@@ -61912,7 +62006,7 @@ class BridgeSessionSeam {
61912
62006
  source: "journal"
61913
62007
  }
61914
62008
  });
61915
- this.#settleSuspendedTurn();
62009
+ this.#settleSuspendedTurn({ terminalEmitted: true });
61916
62010
  } else {
61917
62011
  emit({
61918
62012
  type: "bridge.turn.interrupted",
@@ -61926,7 +62020,7 @@ class BridgeSessionSeam {
61926
62020
  source: "local"
61927
62021
  }
61928
62022
  });
61929
- this.#settleSuspendedTurn();
62023
+ this.#settleSuspendedTurn({ terminalEmitted: true });
61930
62024
  }
61931
62025
  }
61932
62026
  await new Promise((resolve) => setTimeout(resolve, 0));
@@ -62992,9 +63086,23 @@ class BridgeSessionSeam {
62992
63086
  const fallback = await this.#defaultModelRoute();
62993
63087
  return fallback !== undefined ? { providerID: fallback.providerID, modelID: fallback.modelID } : undefined;
62994
63088
  }
62995
- #settleSuspendedTurn() {
63089
+ #settleSuspendedTurn(options) {
62996
63090
  const done = this.#turnDone;
62997
63091
  const endedTurnId = this.#inFlightTurnId;
63092
+ if (!(options?.terminalEmitted ?? false) && done !== undefined) {
63093
+ this.#emitEvent({
63094
+ type: "bridge.turn.interrupted",
63095
+ details: {
63096
+ sessionID: this.#currentSessionId ?? "",
63097
+ turnId: endedTurnId,
63098
+ partial: this.#inFlightPartial,
63099
+ reason: options?.reason ?? "turn interrupted before a terminal event",
63100
+ code: options?.code ?? "INTERRUPTED",
63101
+ seq: null,
63102
+ source: "local"
63103
+ }
63104
+ });
63105
+ }
62998
63106
  this.#turnDone = undefined;
62999
63107
  this.#activeCallbacks = undefined;
63000
63108
  this.#inFlightTurnId = undefined;
@@ -63167,8 +63275,29 @@ class BridgeSessionSeam {
63167
63275
  async renameSession(_title) {
63168
63276
  return unsupported("renameSession");
63169
63277
  }
63170
- steer(_text) {
63171
- this.#degrade("steer", "no session.steer frame; steer is a no-op");
63278
+ async steer(text) {
63279
+ if (!this.hasBridgeCapability("session.steer")) {
63280
+ return { accepted: false, reason: "UNSUPPORTED" };
63281
+ }
63282
+ let reply;
63283
+ try {
63284
+ reply = await this.#transport.request("session.steer", { text });
63285
+ } catch (err) {
63286
+ if (err instanceof BridgeProtocolError && STEER_REJECTION_CODES.has(err.code)) {
63287
+ const detail = asRecord12(err.detail);
63288
+ return {
63289
+ accepted: false,
63290
+ reason: err.code,
63291
+ ...typeof detail.turnId === "string" ? { turnId: detail.turnId } : {}
63292
+ };
63293
+ }
63294
+ throw err;
63295
+ }
63296
+ const result = asRecord12(reply);
63297
+ if (result.accepted !== true || typeof result.turnId !== "string") {
63298
+ throw new BridgeProtocolError("INTERNAL", "session.steer reply has no accepted:true turnId");
63299
+ }
63300
+ return { accepted: true, turnId: result.turnId };
63172
63301
  }
63173
63302
  registerAskProvider(onAsk) {
63174
63303
  this.#askProvider = onAsk;
@@ -63596,7 +63725,7 @@ class BridgeSessionSeam {
63596
63725
  }
63597
63726
  }
63598
63727
  }
63599
- var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `${method}: write requires a confirmed TUI modal token`), BridgeProtocolError, ACCOUNT_STATUSES, ACCOUNT_PHASES, ROUTE_ROW_TYPES, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CHILD_TRANSCRIPT_MAX_LINES = 500, CHILD_TRANSCRIPT_MAX_BYTES, childTextEncoder, childStrictTextDecoder, CHILD_TRANSCRIPT_LINE_BUDGET, CHILD_TRANSCRIPT_TRUNCATION_MARKER = "\u2026", CHILD_TRANSCRIPT_TRUNCATION_MARKER_BYTES, CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
63728
+ var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `${method}: write requires a confirmed TUI modal token`), BridgeProtocolError, ACCOUNT_STATUSES, ACCOUNT_PHASES, STEER_REJECTION_CODES, ROUTE_ROW_TYPES, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CHILD_TRANSCRIPT_MAX_LINES = 500, CHILD_TRANSCRIPT_MAX_BYTES, childTextEncoder, childStrictTextDecoder, CHILD_TRANSCRIPT_LINE_BUDGET, CHILD_TRANSCRIPT_TRUNCATION_MARKER = "\u2026", CHILD_TRANSCRIPT_TRUNCATION_MARKER_BYTES, CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
63600
63729
  var init_bridge_session_seam = __esm(() => {
63601
63730
  init_remote_session_ops();
63602
63731
  init_journal_projection();
@@ -63631,6 +63760,14 @@ var init_bridge_session_seam = __esm(() => {
63631
63760
  "expired",
63632
63761
  "failed"
63633
63762
  ]);
63763
+ STEER_REJECTION_CODES = new Set([
63764
+ "STEER_IDLE",
63765
+ "STEER_ENDED",
63766
+ "STEER_ABORTING",
63767
+ "SESSION_NOT_OPEN",
63768
+ "BAD_PARAMS",
63769
+ "UNSUPPORTED"
63770
+ ]);
63634
63771
  ROUTE_ROW_TYPES = new Set(["model/selection", "request/header", "request/context"]);
63635
63772
  CHILD_TRANSCRIPT_MAX_BYTES = 64 * 1024;
63636
63773
  childTextEncoder = new TextEncoder;
@@ -63934,7 +64071,9 @@ function V2SessionPageBody(props) {
63934
64071
  "bridge.recovery.locked",
63935
64072
  "bridge.recovery.failed"
63936
64073
  ]);
64074
+ const turnTracker = new TurnOutcomeTracker;
63937
64075
  onCleanup(seam.onSessionEvent?.((event) => {
64076
+ turnTracker.onEvent(event);
63938
64077
  if (!recoveryEvents.has(event?.type))
63939
64078
  return;
63940
64079
  recovery.handleEvent(event);
@@ -64016,11 +64155,14 @@ function V2SessionPageBody(props) {
64016
64155
  const [lastRequest, setLastRequest] = createSignal();
64017
64156
  const [composerPending, setComposerPending] = createSignal([]);
64018
64157
  let turnAborted = false;
64019
- const send = (text) => {
64158
+ const send = (text, source) => {
64020
64159
  turnAborted = false;
64160
+ turnTracker.beginTurn();
64021
64161
  setTurnBusy(true);
64022
64162
  setLastRequest(text);
64023
- transcriptScroll?.scrollTo(Infinity);
64163
+ if (source !== "queue") {
64164
+ transcriptScroll?.scrollTo(Infinity);
64165
+ }
64024
64166
  const done = projection.send(text);
64025
64167
  done.finally(() => setTurnBusy(false));
64026
64168
  return done;
@@ -64527,7 +64669,8 @@ function V2SessionPageBody(props) {
64527
64669
  chooseDelivery: (text) => openDeliveryChoice(dialog, text),
64528
64670
  onPendingChange: (rows) => setComposerPending(rows),
64529
64671
  onQueuePaused: (info) => showNotice(`\u961F\u5217\u5DF2\u4FDD\u7559 ${info.remaining} \u6761:\u672C\u56DE\u5408${info.reason === "failed" ? "\u5931\u8D25" : "\u5DF2\u4E2D\u6B62"},\u4E0B\u56DE\u5408\u7ED3\u675F\u540E\u7EE7\u7EED\u53D1\u9001`, 8000),
64530
- isTurnAborted: () => turnAborted,
64672
+ isTurnAborted: () => turnAborted || turnTracker.isAborted(),
64673
+ isTurnFailed: () => turnTracker.isFailed(),
64531
64674
  slashKeyFilter: slash.slashKeyFilter,
64532
64675
  slashSync: (buffer) => slash.controller.sync(buffer, slash.commands),
64533
64676
  interceptSubmit: slash.interceptSubmit,
@@ -65164,5 +65307,5 @@ if (import.meta.main) {
65164
65307
  main();
65165
65308
  }
65166
65309
 
65167
- //# debugId=2A5F7C9D91CE94DC64756E2164756E21
65310
+ //# debugId=39BBC5E19A7B4E5264756E2164756E21
65168
65311
  //# sourceMappingURL=index.js.map