@karlorz/codexhost-cli-linux-x64 0.21.0-0 → 0.22.0-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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +1 -0
  4. package/app/console-web.js +2 -1
  5. package/app/cpa-live-voice-hook.js +213 -178
  6. package/app/desktop-controller.mjs +8 -2
  7. package/app/host-runtime.mjs +96 -26
  8. package/app/overlay-voice-bootstrap.js +1 -1616
  9. package/app/plugins/antigravity/plugin.mjs +1144 -1254
  10. package/app/plugins/claude-code/plugin.mjs +389 -80
  11. package/app/plugins/codebuddy/plugin.mjs +1 -0
  12. package/app/plugins/codex-usage/plugin.mjs +1 -0
  13. package/app/plugins/copilot/plugin.mjs +1 -0
  14. package/app/plugins/cursor-cli/plugin.mjs +1 -0
  15. package/app/plugins/deepseek-harness/plugin.mjs +1 -0
  16. package/app/plugins/devin/plugin.mjs +1 -0
  17. package/app/plugins/grok/plugin.mjs +232 -217
  18. package/app/plugins/hermes/plugin.mjs +1 -0
  19. package/app/plugins/kimi-code/plugin.mjs +1 -0
  20. package/app/plugins/kiro-cli/plugin.mjs +1 -0
  21. package/app/plugins/omp/plugin.mjs +108 -22
  22. package/app/plugins/opencode/plugin.mjs +1 -0
  23. package/app/plugins/pi/plugin.mjs +119 -23
  24. package/app/plugins/qoder/plugin.mjs +1 -0
  25. package/app/plugins/qoder-cn/plugin.mjs +1 -0
  26. package/app/plugins/qwen-code/plugin.mjs +1 -0
  27. package/app/plugins/workbuddy/plugin.mjs +1 -0
  28. package/app/plugins/zcode/plugin.mjs +1 -0
  29. package/app/renderer-extension.js +799 -476
  30. package/app/voice-qualification.json +13 -13
  31. package/app/web/assets/index-CYo5zTz_.js +201 -0
  32. package/app/web/codexhost-settings.js +2 -1
  33. package/app/web/index.html +1 -1
  34. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +3 -3
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +9 -9
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +2 -2
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +1 -1
  40. package/app/web-modules/server.mjs +130 -74
  41. package/bin/codexhost +0 -0
  42. package/libexec/codexhost-shim +0 -0
  43. package/libexec/codexhost-updater +0 -0
  44. package/package.json +1 -1
  45. package/app/web/assets/index-DLXdvkWR.js +0 -201
@@ -17334,6 +17334,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17334
17334
  message: "A history continuation requires its connection epoch"
17335
17335
  }).optional()
17336
17336
  }),
17337
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17337
17338
  external_exports.strictObject({
17338
17339
  kind: external_exports.literal("configure"),
17339
17340
  ...thread,
@@ -17454,6 +17454,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17454
17454
  message: "A history continuation requires its connection epoch"
17455
17455
  }).optional()
17456
17456
  }),
17457
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17457
17458
  external_exports.strictObject({
17458
17459
  kind: external_exports.literal("configure"),
17459
17460
  ...thread,
@@ -17309,6 +17309,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17309
17309
  message: "A history continuation requires its connection epoch"
17310
17310
  }).optional()
17311
17311
  }),
17312
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17312
17313
  external_exports.strictObject({
17313
17314
  kind: external_exports.literal("configure"),
17314
17315
  ...thread,
@@ -17370,6 +17370,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17370
17370
  message: "A history continuation requires its connection epoch"
17371
17371
  }).optional()
17372
17372
  }),
17373
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17373
17374
  external_exports.strictObject({
17374
17375
  kind: external_exports.literal("configure"),
17375
17376
  ...thread,
@@ -17636,18 +17637,6 @@ function sanitizeDiagnosticTail(value) {
17636
17637
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
17637
17638
  }
17638
17639
 
17639
- // ../../harness-adapter/dist/steer.js
17640
- function unsupportedSteer(harnessLabel) {
17641
- return {
17642
- ok: false,
17643
- error: {
17644
- code: "unsupported",
17645
- message: `${harnessLabel} cannot steer an active Turn natively`,
17646
- retryable: false
17647
- }
17648
- };
17649
- }
17650
-
17651
17640
  // ../../harness-adapter/dist/usage.js
17652
17641
  var tokenFields = [
17653
17642
  "inputTokens",
@@ -19284,6 +19273,15 @@ var OmpRpcFaultError = class extends Error {
19284
19273
  this.name = "OmpRpcFaultError";
19285
19274
  }
19286
19275
  };
19276
+ var OmpRpcSteerRejectedError = class extends Error {
19277
+ };
19278
+ var OmpRpcSteerTargetEndedError = class extends OmpRpcFaultError {
19279
+ history;
19280
+ constructor(history) {
19281
+ super("protocolError", "Omp Turn ended before steer admission could be confirmed. Delivery is unknown; do not automatically resend the input");
19282
+ this.history = history;
19283
+ }
19284
+ };
19287
19285
  var OmpRpcUnsupportedCommandError = class extends Error {
19288
19286
  command;
19289
19287
  constructor(command) {
@@ -19807,6 +19805,30 @@ var OmpRpcSession = class {
19807
19805
  throw fault;
19808
19806
  }
19809
19807
  }
19808
+ async steer(message3) {
19809
+ if (!this.#child || !this.#state || this.#closed || this.#failed) {
19810
+ throw new Error("Omp RPC Session is unavailable");
19811
+ }
19812
+ if (message3.length === 0)
19813
+ throw new Error("Omp steer text must not be empty");
19814
+ const target2 = this.#activeTurn;
19815
+ let targetEnded = false;
19816
+ const response = await this.#send("steer", { message: message3 }, void 0, () => {
19817
+ targetEnded = target2 !== null && this.#activeTurn !== target2;
19818
+ });
19819
+ if (isRecord8(response.data) && response.data.disposition !== void 0 && response.data.disposition !== "queued") {
19820
+ throw new Error("Omp steer was handled without confirming same-Turn queue admission");
19821
+ }
19822
+ if (targetEnded) {
19823
+ let history;
19824
+ try {
19825
+ history = await this.getEntries();
19826
+ } finally {
19827
+ await this.close().catch(() => void 0);
19828
+ }
19829
+ throw new OmpRpcSteerTargetEndedError(history);
19830
+ }
19831
+ }
19810
19832
  async runTurn(text, onEvent) {
19811
19833
  if (!this.#child || !this.#state || this.#closed || this.#failed) {
19812
19834
  throw new Error("Omp RPC Session is unavailable");
@@ -20374,7 +20396,9 @@ var OmpRpcSession = class {
20374
20396
  pending.resolve(value);
20375
20397
  } else {
20376
20398
  const error51 = typeof value.error === "string" ? value.error : "Omp RPC command failed";
20377
- if (value.command === pending.command && error51 === `Unknown command: ${pending.command}`) {
20399
+ if (pending.command === "steer" && value.command === "steer" && value.success === false) {
20400
+ pending.reject(new OmpRpcSteerRejectedError(error51));
20401
+ } else if (value.command === pending.command && error51 === `Unknown command: ${pending.command}`) {
20378
20402
  pending.reject(new OmpRpcUnsupportedCommandError(pending.command));
20379
20403
  } else {
20380
20404
  pending.reject(new Error(error51));
@@ -20654,7 +20678,7 @@ var OmpRpcSession = class {
20654
20678
  child.stdin.write(frame, (error51) => error51 ? reject(error51) : resolve());
20655
20679
  });
20656
20680
  }
20657
- #send(type, payload, id = `codexhost-${randomUUID()}`) {
20681
+ #send(type, payload, id = `codexhost-${randomUUID()}`, onResponse) {
20658
20682
  const child = this.#child;
20659
20683
  if (!child?.stdin.writable || this.#closed || this.#failed) {
20660
20684
  return Promise.reject(new Error("Omp RPC stdin is unavailable"));
@@ -20662,7 +20686,10 @@ var OmpRpcSession = class {
20662
20686
  return new Promise((resolve, reject) => {
20663
20687
  const pending = {
20664
20688
  command: type,
20665
- resolve,
20689
+ resolve: (response) => {
20690
+ onResponse?.();
20691
+ resolve(response);
20692
+ },
20666
20693
  reject,
20667
20694
  timeout: null
20668
20695
  };
@@ -21997,7 +22024,7 @@ var OmpHarnessSession = class {
21997
22024
  this.#toolOutputLimit = options.toolOutputLimit;
21998
22025
  this.#permissionMode = options.permissionMode;
21999
22026
  this.#permissionModeId = options.permissionModeId;
22000
- this.capabilities = {
22027
+ this.capabilities = ((session) => ({
22001
22028
  configuration: {
22002
22029
  selectModel: true,
22003
22030
  selectThinkingOption: options.supportsThinkingSelection,
@@ -22005,8 +22032,11 @@ var OmpHarnessSession = class {
22005
22032
  permissionModeScope: "live"
22006
22033
  },
22007
22034
  history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
22008
- subagents: { observe: true, readTranscript: true }
22009
- };
22035
+ subagents: { observe: true, readTranscript: true },
22036
+ get steer() {
22037
+ return session.#canSteerActiveTurn();
22038
+ }
22039
+ }))(this);
22010
22040
  this.commands = {
22011
22041
  list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
22012
22042
  execute: (command) => this.#executeHarnessCommand(command)
@@ -22147,7 +22177,7 @@ var OmpHarnessSession = class {
22147
22177
  if (command.type === "turn.cancel")
22148
22178
  return this.#cancel(command);
22149
22179
  if (command.type === "turn.steer")
22150
- return unsupportedSteer("OMP");
22180
+ return this.#steer(command);
22151
22181
  if (command.type === "interaction.respond")
22152
22182
  return this.#respond(command);
22153
22183
  if (command.type === "model.select")
@@ -22217,6 +22247,9 @@ var OmpHarnessSession = class {
22217
22247
  agentMessageId: null,
22218
22248
  compactionItem: null,
22219
22249
  sawAssistantMessage: false,
22250
+ acceptedSteerCount: 0,
22251
+ acceptingSteers: true,
22252
+ pendingSteers: /* @__PURE__ */ new Set(),
22220
22253
  reasoningItem: null,
22221
22254
  tools: /* @__PURE__ */ new Map(),
22222
22255
  interactions: /* @__PURE__ */ new Map(),
@@ -22574,6 +22607,47 @@ var OmpHarnessSession = class {
22574
22607
  return { ok: false, error: normalizedError(error51, "nativeFailure") };
22575
22608
  }
22576
22609
  }
22610
+ #canSteerActiveTurn() {
22611
+ const active = this.#active;
22612
+ return Boolean(this.#phase === "open" && active && !active.cancellationRequested && active.acceptingSteers && active.tools.size > 0 && this.#transport);
22613
+ }
22614
+ async #steer(command) {
22615
+ const text = command.input.map((input) => input.text).join("\n");
22616
+ if (text.length === 0) {
22617
+ return {
22618
+ ok: false,
22619
+ error: {
22620
+ code: "invalidRequest",
22621
+ message: "Omp steer text must not be empty",
22622
+ retryable: false
22623
+ }
22624
+ };
22625
+ }
22626
+ const active = this.#active;
22627
+ const transport = this.#transport;
22628
+ if (!active || !transport || active.command.turnId !== command.turnId || !this.#canSteerActiveTurn()) {
22629
+ return { ok: false, error: invalidState("Omp Turn is not accepting native input") };
22630
+ }
22631
+ let accepted;
22632
+ try {
22633
+ accepted = transport.steer(text).then(() => {
22634
+ active.acceptedSteerCount += 1;
22635
+ });
22636
+ active.pendingSteers.add(accepted);
22637
+ await accepted;
22638
+ return { ok: true, value: { accepted: true } };
22639
+ } catch (error51) {
22640
+ if (error51 instanceof OmpRpcSteerRejectedError) {
22641
+ return { ok: false, error: invalidState(error51.message) };
22642
+ }
22643
+ if (error51 instanceof OmpRpcSteerTargetEndedError)
22644
+ active.steerFailure = error51;
22645
+ throw error51;
22646
+ } finally {
22647
+ if (accepted)
22648
+ active.pendingSteers.delete(accepted);
22649
+ }
22650
+ }
22577
22651
  async #cancel(command) {
22578
22652
  const active = this.#active;
22579
22653
  if (!active || active.command.turnId !== command.turnId) {
@@ -22684,6 +22758,9 @@ var OmpHarnessSession = class {
22684
22758
  agentMessageId: null,
22685
22759
  compactionItem: null,
22686
22760
  sawAssistantMessage: false,
22761
+ acceptedSteerCount: 0,
22762
+ acceptingSteers: false,
22763
+ pendingSteers: /* @__PURE__ */ new Set(),
22687
22764
  reasoningItem: null,
22688
22765
  tools: /* @__PURE__ */ new Map(),
22689
22766
  interactions: /* @__PURE__ */ new Map(),
@@ -23185,13 +23262,18 @@ var OmpHarnessSession = class {
23185
23262
  });
23186
23263
  }
23187
23264
  async #completedTurnIdentity(active, transport) {
23188
- const snapshot = mapOmpSnapshot(await transport.getEntries(), {
23265
+ active.acceptingSteers = false;
23266
+ await Promise.allSettled([...active.pendingSteers]);
23267
+ const history = active.steerFailure?.history ?? await transport.getEntries();
23268
+ const snapshot = mapOmpSnapshot(history, {
23189
23269
  sessionId: transport.state.sessionId,
23190
23270
  model: nativeModelForHistory(transport.state)
23191
23271
  });
23192
23272
  const created = snapshot.turns.filter((turn2) => !active.beforeNativeTurnKeys.has(turn2.nativeTurnRef.nativeTurnKey));
23193
- if (created.length !== 1) {
23194
- throw new Error(`Omp Turn persisted ${created.length} new User Entries; exactly one is required`);
23273
+ const expected = 1 + active.acceptedSteerCount;
23274
+ if (created.length !== expected) {
23275
+ const countText = expected === 1 ? "one" : `${expected}`;
23276
+ throw new Error(`Omp Turn persisted ${created.length} new User Entries; exactly ${countText} is required`);
23195
23277
  }
23196
23278
  const turn = created[0];
23197
23279
  if (!turn?.checkpoint)
@@ -23234,6 +23316,10 @@ var OmpHarnessSession = class {
23234
23316
  ...ephemeral ? { ephemeral } : {}
23235
23317
  });
23236
23318
  active.resolveCompletion();
23319
+ if (active.steerFailure) {
23320
+ this.#fault(active.steerFailure);
23321
+ return;
23322
+ }
23237
23323
  queueMicrotask(() => {
23238
23324
  if (this.#phase === "open")
23239
23325
  void this.#refreshUsage(active.command.turnId);
@@ -17513,6 +17513,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17513
17513
  message: "A history continuation requires its connection epoch"
17514
17514
  }).optional()
17515
17515
  }),
17516
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17516
17517
  external_exports.strictObject({
17517
17518
  kind: external_exports.literal("configure"),
17518
17519
  ...thread,
@@ -17370,6 +17370,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17370
17370
  message: "A history continuation requires its connection epoch"
17371
17371
  }).optional()
17372
17372
  }),
17373
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17373
17374
  external_exports.strictObject({
17374
17375
  kind: external_exports.literal("configure"),
17375
17376
  ...thread,
@@ -17628,18 +17629,6 @@ function sanitizeDiagnosticTail(value) {
17628
17629
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
17629
17630
  }
17630
17631
 
17631
- // ../../harness-adapter/dist/steer.js
17632
- function unsupportedSteer(harnessLabel) {
17633
- return {
17634
- ok: false,
17635
- error: {
17636
- code: "unsupported",
17637
- message: `${harnessLabel} cannot steer an active Turn natively`,
17638
- retryable: false
17639
- }
17640
- };
17641
- }
17642
-
17643
17632
  // ../../harness-adapter/dist/usage.js
17644
17633
  var tokenFields = [
17645
17634
  "inputTokens",
@@ -22174,6 +22163,15 @@ var PiRpcFaultError = class extends Error {
22174
22163
  this.name = "PiRpcFaultError";
22175
22164
  }
22176
22165
  };
22166
+ var PiRpcSteerRejectedError = class extends Error {
22167
+ };
22168
+ var PiRpcSteerTargetEndedError = class extends PiRpcFaultError {
22169
+ history;
22170
+ constructor(history) {
22171
+ super("protocolError", "Pi Turn ended before steer admission could be confirmed; the isolated runtime was closed. Input hook effects are unknown, so do not automatically resend the input");
22172
+ this.history = history;
22173
+ }
22174
+ };
22177
22175
  var PiRpcUnsupportedCommandError = class extends Error {
22178
22176
  command;
22179
22177
  constructor(command) {
@@ -22770,6 +22768,38 @@ var PiRpcSession = class {
22770
22768
  throw fault;
22771
22769
  }
22772
22770
  }
22771
+ async steer(message3) {
22772
+ if (!this.#child || !this.#state || this.#closed || this.#failed) {
22773
+ throw new Error("Pi RPC Session is unavailable");
22774
+ }
22775
+ if (message3.length === 0)
22776
+ throw new Error("Pi steer text must not be empty");
22777
+ const target2 = this.#activeTurn;
22778
+ if (!target2 || target2.origin !== "requested" || target2.settlement !== "pending") {
22779
+ throw new PiRpcSteerRejectedError("Pi Turn is not accepting native input");
22780
+ }
22781
+ let admitted = false;
22782
+ const response = await this.#send("steer", { message: message3 }, () => {
22783
+ admitted = this.#activeTurn === target2 && target2.settlement === "pending";
22784
+ });
22785
+ if (isRecord9(response.data) && response.data.disposition !== void 0 && response.data.disposition !== "queued") {
22786
+ throw new Error("Pi steer was handled without confirming same-Turn queue admission");
22787
+ }
22788
+ if (!admitted) {
22789
+ let history;
22790
+ try {
22791
+ history = await this.getEntries();
22792
+ } finally {
22793
+ try {
22794
+ await this.close();
22795
+ } catch (error51) {
22796
+ if (history !== void 0)
22797
+ throw error51;
22798
+ }
22799
+ }
22800
+ throw new PiRpcSteerTargetEndedError(history);
22801
+ }
22802
+ }
22773
22803
  async runTurn(text4, onEvent) {
22774
22804
  if (!this.#child || !this.#state || this.#closed || this.#failed) {
22775
22805
  throw new Error("Pi RPC Session is unavailable");
@@ -23333,7 +23363,9 @@ var PiRpcSession = class {
23333
23363
  pending.resolve(value);
23334
23364
  else {
23335
23365
  const error51 = typeof value.error === "string" ? value.error : "Pi RPC command failed";
23336
- if (value.command === pending.command && error51 === `Unknown command: ${pending.command}`) {
23366
+ if (pending.command === "steer" && value.command === "steer" && value.success === false) {
23367
+ pending.reject(new PiRpcSteerRejectedError(error51));
23368
+ } else if (value.command === pending.command && error51 === `Unknown command: ${pending.command}`) {
23337
23369
  pending.reject(new PiRpcUnsupportedCommandError(pending.command));
23338
23370
  } else {
23339
23371
  pending.reject(new Error(error51));
@@ -23607,7 +23639,7 @@ var PiRpcSession = class {
23607
23639
  child.stdin.write(frame, (error51) => error51 ? reject(error51) : resolve());
23608
23640
  });
23609
23641
  }
23610
- #send(type, payload) {
23642
+ #send(type, payload, onResponse) {
23611
23643
  const child = this.#child;
23612
23644
  if (!child?.stdin.writable || this.#closed || this.#failed) {
23613
23645
  return Promise.reject(new Error("Pi RPC stdin is unavailable"));
@@ -23616,7 +23648,10 @@ var PiRpcSession = class {
23616
23648
  return new Promise((resolve, reject) => {
23617
23649
  const pending = {
23618
23650
  command: type,
23619
- resolve,
23651
+ resolve: (response) => {
23652
+ onResponse?.();
23653
+ resolve(response);
23654
+ },
23620
23655
  reject,
23621
23656
  timeout: null
23622
23657
  };
@@ -23910,7 +23945,7 @@ var PiHarnessSession = class {
23910
23945
  this.#requestedThinkingOptionId = options.thinkingOptionId;
23911
23946
  this.#toolOutputLimit = options.toolOutputLimit;
23912
23947
  this.#isFastSupported = options.isFastSupported;
23913
- this.capabilities = {
23948
+ this.capabilities = ((session) => ({
23914
23949
  configuration: {
23915
23950
  selectModel: true,
23916
23951
  selectThinkingOption: options.supportsThinkingSelection,
@@ -23919,8 +23954,12 @@ var PiHarnessSession = class {
23919
23954
  },
23920
23955
  history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
23921
23956
  autonomousTurns: { observe: true },
23922
- subagents: { observe: true, readTranscript: true }
23923
- };
23957
+ subagents: { observe: true, readTranscript: true },
23958
+ // Root Tools provide an admission window; the transport also checks native receipt order.
23959
+ get steer() {
23960
+ return session.#canSteerActiveTurn();
23961
+ }
23962
+ }))(this);
23924
23963
  this.commands = {
23925
23964
  list: async () => ({ ok: true, value: await this.#refreshLiveCommands() }),
23926
23965
  execute: (command) => this.#executeHarnessCommand(command)
@@ -24015,8 +24054,6 @@ var PiHarnessSession = class {
24015
24054
  if (this.#phase !== "open") {
24016
24055
  return { ok: false, error: invalidState("Pi Session is not open") };
24017
24056
  }
24018
- if (command.type === "turn.steer")
24019
- return unsupportedSteer("Pi");
24020
24057
  if (command.type === "turn.cancel")
24021
24058
  return this.#cancel(command);
24022
24059
  if (command.type === "interaction.respond")
@@ -24035,6 +24072,8 @@ var PiHarnessSession = class {
24035
24072
  }
24036
24073
  };
24037
24074
  }
24075
+ if (command.type === "turn.steer")
24076
+ return this.#steer(command);
24038
24077
  if (this.#acceptingTurn || this.#active || this.#configuring || this.#transport?.isBusy) {
24039
24078
  return {
24040
24079
  ok: false,
@@ -24094,6 +24133,9 @@ var PiHarnessSession = class {
24094
24133
  agentMessageId: null,
24095
24134
  compactionItem: null,
24096
24135
  sawAssistantMessage: false,
24136
+ acceptedSteerCount: 0,
24137
+ acceptingSteers: true,
24138
+ pendingSteers: /* @__PURE__ */ new Set(),
24097
24139
  reasoningItem: null,
24098
24140
  tools: /* @__PURE__ */ new Map(),
24099
24141
  interactions: /* @__PURE__ */ new Map(),
@@ -24355,6 +24397,47 @@ var PiHarnessSession = class {
24355
24397
  this.#drainPendingAutonomousTurns(this.#transport);
24356
24398
  }
24357
24399
  }
24400
+ #canSteerActiveTurn() {
24401
+ const active = this.#active;
24402
+ return Boolean(this.#phase === "open" && active && !active.cancellationRequested && active.acceptingSteers && active.tools.size > 0 && this.#transport);
24403
+ }
24404
+ async #steer(command) {
24405
+ const text4 = command.input.map((input) => input.text).join("\n");
24406
+ if (text4.length === 0) {
24407
+ return {
24408
+ ok: false,
24409
+ error: {
24410
+ code: "invalidRequest",
24411
+ message: "Pi steer text must not be empty",
24412
+ retryable: false
24413
+ }
24414
+ };
24415
+ }
24416
+ const active = this.#active;
24417
+ const transport = this.#transport;
24418
+ if (!active || !transport || active.command.turnId !== command.turnId || !this.#canSteerActiveTurn()) {
24419
+ return { ok: false, error: invalidState("Pi Turn is not accepting native input") };
24420
+ }
24421
+ let accepted;
24422
+ try {
24423
+ accepted = transport.steer(text4).then(() => {
24424
+ active.acceptedSteerCount += 1;
24425
+ });
24426
+ active.pendingSteers.add(accepted);
24427
+ await accepted;
24428
+ return { ok: true, value: { accepted: true } };
24429
+ } catch (error51) {
24430
+ if (error51 instanceof PiRpcSteerRejectedError) {
24431
+ return { ok: false, error: invalidState(error51.message) };
24432
+ }
24433
+ if (error51 instanceof PiRpcSteerTargetEndedError)
24434
+ active.steerFailure = error51;
24435
+ throw error51;
24436
+ } finally {
24437
+ if (accepted)
24438
+ active.pendingSteers.delete(accepted);
24439
+ }
24440
+ }
24358
24441
  async #cancel(command) {
24359
24442
  const active = this.#active;
24360
24443
  if (!active || active.command.turnId !== command.turnId) {
@@ -24478,6 +24561,9 @@ var PiHarnessSession = class {
24478
24561
  agentMessageId: null,
24479
24562
  compactionItem: null,
24480
24563
  sawAssistantMessage: false,
24564
+ acceptedSteerCount: 0,
24565
+ acceptingSteers: false,
24566
+ pendingSteers: /* @__PURE__ */ new Set(),
24481
24567
  reasoningItem: null,
24482
24568
  tools: /* @__PURE__ */ new Map(),
24483
24569
  interactions: /* @__PURE__ */ new Map(),
@@ -24744,6 +24830,9 @@ var PiHarnessSession = class {
24744
24830
  agentMessageId: null,
24745
24831
  compactionItem: null,
24746
24832
  sawAssistantMessage: false,
24833
+ acceptedSteerCount: 0,
24834
+ acceptingSteers: false,
24835
+ pendingSteers: /* @__PURE__ */ new Set(),
24747
24836
  reasoningItem: null,
24748
24837
  tools: /* @__PURE__ */ new Map(),
24749
24838
  interactions: /* @__PURE__ */ new Map(),
@@ -25186,13 +25275,16 @@ var PiHarnessSession = class {
25186
25275
  }
25187
25276
  }
25188
25277
  async #completedTurnIdentity(active, transport) {
25189
- const snapshot = mapPiSnapshot(await transport.getEntries(), {
25278
+ active.acceptingSteers = false;
25279
+ await Promise.allSettled([...active.pendingSteers]);
25280
+ const snapshot = mapPiSnapshot(active.steerFailure?.history ?? await transport.getEntries(), {
25190
25281
  sessionId: transport.state.sessionId,
25191
25282
  model: nativeModelForHistory(transport.state)
25192
25283
  });
25193
25284
  const created = snapshot.turns.filter((turn2) => turn2.input.length > 0 && !active.beforeNativeTurnKeys.has(turn2.nativeTurnRef.nativeTurnKey));
25194
- if (created.length !== 1) {
25195
- throw new Error(`Pi Turn persisted ${created.length} new User Entries; exactly one is required`);
25285
+ const expected = 1 + active.acceptedSteerCount;
25286
+ if (created.length !== expected) {
25287
+ throw new Error(`Pi Turn persisted ${created.length} new User Entries; exactly ${expected} is required`);
25196
25288
  }
25197
25289
  const turn = created[0];
25198
25290
  if (!turn)
@@ -25228,6 +25320,10 @@ var PiHarnessSession = class {
25228
25320
  ...nativeTurnRef ? { nativeTurnRef } : {}
25229
25321
  });
25230
25322
  active.resolveCompletion();
25323
+ if (active.steerFailure) {
25324
+ this.#fault(active.steerFailure);
25325
+ return;
25326
+ }
25231
25327
  queueMicrotask(() => {
25232
25328
  if (this.#phase !== "open")
25233
25329
  return;
@@ -29959,6 +29959,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
29959
29959
  message: "A history continuation requires its connection epoch"
29960
29960
  }).optional()
29961
29961
  }),
29962
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
29962
29963
  external_exports.strictObject({
29963
29964
  kind: external_exports.literal("configure"),
29964
29965
  ...thread,
@@ -29556,6 +29556,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
29556
29556
  message: "A history continuation requires its connection epoch"
29557
29557
  }).optional()
29558
29558
  }),
29559
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
29559
29560
  external_exports.strictObject({
29560
29561
  kind: external_exports.literal("configure"),
29561
29562
  ...thread,
@@ -23859,6 +23859,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
23859
23859
  message: "A history continuation requires its connection epoch"
23860
23860
  }).optional()
23861
23861
  }),
23862
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
23862
23863
  external_exports.strictObject({
23863
23864
  kind: external_exports.literal("configure"),
23864
23865
  ...thread,
@@ -16973,6 +16973,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16973
16973
  message: "A history continuation requires its connection epoch"
16974
16974
  }).optional()
16975
16975
  }),
16976
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
16976
16977
  external_exports.strictObject({
16977
16978
  kind: external_exports.literal("configure"),
16978
16979
  ...thread,
@@ -17159,6 +17159,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17159
17159
  message: "A history continuation requires its connection epoch"
17160
17160
  }).optional()
17161
17161
  }),
17162
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17162
17163
  external_exports.strictObject({
17163
17164
  kind: external_exports.literal("configure"),
17164
17165
  ...thread,