@moxt-ai/mobius 0.0.441 → 0.0.443

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 (92) hide show
  1. package/dist/{chunk-H5UFPY6F.js → chunk-7V5JOCWD.js} +2 -2
  2. package/dist/{chunk-H5UFPY6F.js.map → chunk-7V5JOCWD.js.map} +1 -1
  3. package/dist/{chunk-WFQZ4ALO.js → chunk-NFQ5D3AF.js} +590 -50
  4. package/dist/{chunk-WFQZ4ALO.js.map → chunk-NFQ5D3AF.js.map} +4 -4
  5. package/dist/{cli-A2WWY7SU.js → cli-K5WNORRA.js} +3 -3
  6. package/dist/cli.js +2 -2
  7. package/dist/engine/acp/adapter/agent-initialization.d.ts +1 -0
  8. package/dist/engine/acp/adapter/agent-initialization.d.ts.map +1 -1
  9. package/dist/engine/acp/adapter/claude/adapter.d.ts +1 -0
  10. package/dist/engine/acp/adapter/claude/adapter.d.ts.map +1 -1
  11. package/dist/engine/acp/adapter/claude/adapter.js +15 -3
  12. package/dist/engine/acp/adapter/claude/adapter.js.map +1 -1
  13. package/dist/engine/acp/adapter/claude/agent-connection.d.ts.map +1 -1
  14. package/dist/engine/acp/adapter/claude/agent-connection.js +1 -0
  15. package/dist/engine/acp/adapter/claude/agent-connection.js.map +1 -1
  16. package/dist/engine/acp/adapter/codex/adapter.d.ts +1 -0
  17. package/dist/engine/acp/adapter/codex/adapter.d.ts.map +1 -1
  18. package/dist/engine/acp/adapter/codex/agent-connection.d.ts.map +1 -1
  19. package/dist/engine/acp/adapter/codex/agent-connection.js +1 -0
  20. package/dist/engine/acp/adapter/codex/agent-connection.js.map +1 -1
  21. package/dist/engine/acp/adapter/execution-connections.d.ts.map +1 -1
  22. package/dist/engine/acp/adapter/execution-connections.js +9 -2
  23. package/dist/engine/acp/adapter/execution-connections.js.map +1 -1
  24. package/dist/engine/acp/adapter/pi/adapter.d.ts +1 -0
  25. package/dist/engine/acp/adapter/pi/adapter.d.ts.map +1 -1
  26. package/dist/engine/acp/adapter/session-events.d.ts +4 -1
  27. package/dist/engine/acp/adapter/session-events.d.ts.map +1 -1
  28. package/dist/engine/acp/adapter/session-events.js +5 -0
  29. package/dist/engine/acp/adapter/session-events.js.map +1 -1
  30. package/dist/engine/acp/agent/in-process-endpoint.d.ts +25 -0
  31. package/dist/engine/acp/agent/in-process-endpoint.d.ts.map +1 -1
  32. package/dist/engine/acp/connection/agent-connection.d.ts +2 -1
  33. package/dist/engine/acp/connection/agent-connection.d.ts.map +1 -1
  34. package/dist/engine/acp/harness/claude/endpoint.d.ts.map +1 -1
  35. package/dist/engine/acp/harness/claude/endpoint.js +1 -0
  36. package/dist/engine/acp/harness/claude/endpoint.js.map +1 -1
  37. package/dist/engine/acp/harness/codex/agent.d.ts.map +1 -1
  38. package/dist/engine/acp/harness/codex/agent.js +46 -2
  39. package/dist/engine/acp/harness/codex/agent.js.map +1 -1
  40. package/dist/engine/acp/harness/codex/app-server-client.d.ts +5 -2
  41. package/dist/engine/acp/harness/codex/app-server-client.d.ts.map +1 -1
  42. package/dist/engine/acp/harness/codex/app-server-client.js +6 -2
  43. package/dist/engine/acp/harness/codex/app-server-client.js.map +1 -1
  44. package/dist/engine/acp/harness/codex/app-server-protocol.d.ts +11 -0
  45. package/dist/engine/acp/harness/codex/app-server-protocol.d.ts.map +1 -1
  46. package/dist/engine/acp/harness/codex/app-server-protocol.js +11 -0
  47. package/dist/engine/acp/harness/codex/app-server-protocol.js.map +1 -1
  48. package/dist/engine/acp/harness/codex/owned-agent.d.ts +5 -2
  49. package/dist/engine/acp/harness/codex/owned-agent.d.ts.map +1 -1
  50. package/dist/engine/acp/harness/codex/owned-agent.js +79 -2
  51. package/dist/engine/acp/harness/codex/owned-agent.js.map +1 -1
  52. package/dist/engine/acp/harness/codex/session-agent.d.ts +3 -1
  53. package/dist/engine/acp/harness/codex/session-agent.d.ts.map +1 -1
  54. package/dist/engine/acp/native-history/preview-contract.d.ts +4 -0
  55. package/dist/engine/acp/native-history/preview-contract.d.ts.map +1 -1
  56. package/dist/engine/acp/protocol/session-capabilities.d.ts.map +1 -1
  57. package/dist/engine/acp/protocol/session-capabilities.js +11 -2
  58. package/dist/engine/acp/protocol/session-capabilities.js.map +1 -1
  59. package/dist/engine/runtime/command/registry/index.d.ts.map +1 -1
  60. package/dist/engine/runtime/command/registry/index.js +2 -0
  61. package/dist/engine/runtime/command/registry/index.js.map +1 -1
  62. package/dist/engine/runtime/command/registry/prompt-suggestion.d.ts +4 -0
  63. package/dist/engine/runtime/command/registry/prompt-suggestion.d.ts.map +1 -0
  64. package/dist/engine/runtime/command/registry/prompt-suggestion.js +19 -0
  65. package/dist/engine/runtime/command/registry/prompt-suggestion.js.map +1 -0
  66. package/dist/engine/runtime/command/registry/runtime.d.ts.map +1 -1
  67. package/dist/engine/runtime/command/registry/runtime.js +1 -0
  68. package/dist/engine/runtime/command/registry/runtime.js.map +1 -1
  69. package/dist/engine/runtime/command/registry/session.d.ts.map +1 -1
  70. package/dist/engine/runtime/command/registry/session.js +3 -0
  71. package/dist/engine/runtime/command/registry/session.js.map +1 -1
  72. package/dist/engine/session/api/session-api.d.ts +2 -0
  73. package/dist/engine/session/api/session-api.d.ts.map +1 -1
  74. package/dist/engine/session/api/session-api.js.map +1 -1
  75. package/dist/engine/session/live/agent-session.d.ts +2 -1
  76. package/dist/engine/session/live/agent-session.d.ts.map +1 -1
  77. package/dist/engine/session/live/agent-session.js +18 -6
  78. package/dist/engine/session/live/agent-session.js.map +1 -1
  79. package/dist/engine/session/manager/session-manager.d.ts +3 -0
  80. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  81. package/dist/engine/session/manager/session-manager.js +9 -4
  82. package/dist/engine/session/manager/session-manager.js.map +1 -1
  83. package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
  84. package/dist/engine/session/prompt/execute-prompt.js +15 -0
  85. package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
  86. package/dist/engine/session/prompt/prompt-suggestions.d.ts +38 -0
  87. package/dist/engine/session/prompt/prompt-suggestions.d.ts.map +1 -0
  88. package/dist/engine/session/prompt/prompt-suggestions.js +202 -0
  89. package/dist/engine/session/prompt/prompt-suggestions.js.map +1 -0
  90. package/dist/engine.js +2 -2
  91. package/package.json +2 -2
  92. /package/dist/{cli-A2WWY7SU.js.map → cli-K5WNORRA.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-H5UFPY6F.js";
6
+ } from "./chunk-7V5JOCWD.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -19995,8 +19995,10 @@ function decodeRuntimePongEvent(encoded) {
19995
19995
  const value = parseJson(encoded);
19996
19996
  assertKind(value, RUNTIME_PONG_KIND);
19997
19997
  const scopedFileRead = Reflect.get(value, "scopedFileRead");
19998
+ const promptSuggestions = Reflect.get(value, "promptSuggestions");
19998
19999
  return {
19999
20000
  kind: RUNTIME_PONG_KIND,
20001
+ ...typeof promptSuggestions === "boolean" ? { promptSuggestions } : {},
20000
20002
  requestId: readIdentifier(value, "requestId"),
20001
20003
  ...typeof scopedFileRead === "boolean" ? { scopedFileRead } : {}
20002
20004
  };
@@ -20111,6 +20113,8 @@ var sessionCapabilitiesSchema = external_exports.object({
20111
20113
  listSessions: external_exports.boolean(),
20112
20114
  loadSession: external_exports.boolean(),
20113
20115
  promptQueueing: external_exports.boolean().default(false),
20116
+ /** The Agent can predict the member's next prompt after a Turn that asked for one. */
20117
+ promptSuggestions: external_exports.boolean().default(false),
20114
20118
  renameSession: external_exports.boolean().default(false),
20115
20119
  resumeSession: external_exports.boolean(),
20116
20120
  steering: external_exports.boolean().default(false),
@@ -21211,6 +21215,11 @@ var sessionPrepareCommandSchema = external_exports.object({
21211
21215
  kind: external_exports.literal(SESSION_PREPARE_KIND),
21212
21216
  requestId: identifierStringSchema,
21213
21217
  sessionState: external_exports.literal("provisioned").optional(),
21218
+ /**
21219
+ * Whether the member wants the Agent to predict their next prompt in this Session. An Agent that decides this
21220
+ * when it opens the Session applies it the next time it does; omitted leaves the Session's choice unchanged.
21221
+ */
21222
+ suggestNextPrompt: external_exports.boolean().optional(),
21214
21223
  /** Marks an inspection-only Session preparation. */
21215
21224
  transient: external_exports.boolean().optional()
21216
21225
  }).superRefine((command, context) => {
@@ -21404,9 +21413,17 @@ function decodeSessionPromptCommand(encoded) {
21404
21413
  prompt,
21405
21414
  ...hasSessionConfigurations ? { sessionConfigurations } : {},
21406
21415
  sessionId: readIdentifier(value, "sessionId"),
21416
+ ...readSuggestNextPrompt(value) ? { suggestNextPrompt: true } : {},
21407
21417
  targetCommandId
21408
21418
  };
21409
21419
  }
21420
+ function readSuggestNextPrompt(value) {
21421
+ const field = value["suggestNextPrompt"];
21422
+ if (field === void 0 || typeof field === "boolean") {
21423
+ return field === true;
21424
+ }
21425
+ throw new ProtocolMessageError("Invalid value field: suggestNextPrompt");
21426
+ }
21410
21427
  function readHistoryPolicy(value) {
21411
21428
  const field = value["historyPolicy"];
21412
21429
  if (field === SessionHistoryPolicy.Eager || field === SessionHistoryPolicy.ExecutionOnly) {
@@ -21696,6 +21713,66 @@ var encodeSessionHistoryPageLoaded = (value) => JSON.stringify(sessionHistoryPag
21696
21713
  var encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
21697
21714
  var encodeSessionPreviewHistoryPageLoaded = (value) => JSON.stringify(sessionPreviewHistoryPageLoadedSchema.parse(value));
21698
21715
 
21716
+ // ../mobius-sdk/src/protocol/session/prompt/suggestion.ts
21717
+ var SESSION_PROMPT_SUGGESTION_READ_KIND = "session.prompt-suggestion.read";
21718
+ var SESSION_PROMPT_SUGGESTION_READ_RESULT_KIND = "session.prompt-suggestion.read.result";
21719
+ var PROMPT_SUGGESTION_MAX_LENGTH = 500;
21720
+ var PromptSuggestionUnavailableReason = Object.freeze({
21721
+ /** The Turn did not ask for a suggestion. */
21722
+ NotRequested: "not_requested",
21723
+ /** The Session's Agent, its version, or its connection cannot predict the next prompt. */
21724
+ Unsupported: "unsupported",
21725
+ /** The Turn failed or was cancelled, so nothing follows it. */
21726
+ TurnNotCompleted: "turn_not_completed",
21727
+ /** The Agent decided there was no clear next prompt. */
21728
+ NoSuggestion: "no_suggestion",
21729
+ /** The Agent could not produce a suggestion. */
21730
+ Failed: "failed",
21731
+ /** No suggestion arrived in time. */
21732
+ TimedOut: "timed_out",
21733
+ /** A later prompt started in the Session, so the suggestion no longer follows the latest Turn. */
21734
+ Superseded: "superseded",
21735
+ /** The Runtime holds nothing for this Turn, for example after a restart or once the suggestion expired. */
21736
+ UnknownTurn: "unknown_turn"
21737
+ });
21738
+ var unavailableReasonSchema = external_exports.enum([
21739
+ PromptSuggestionUnavailableReason.NotRequested,
21740
+ PromptSuggestionUnavailableReason.Unsupported,
21741
+ PromptSuggestionUnavailableReason.TurnNotCompleted,
21742
+ PromptSuggestionUnavailableReason.NoSuggestion,
21743
+ PromptSuggestionUnavailableReason.Failed,
21744
+ PromptSuggestionUnavailableReason.TimedOut,
21745
+ PromptSuggestionUnavailableReason.Superseded,
21746
+ PromptSuggestionUnavailableReason.UnknownTurn
21747
+ ]);
21748
+ var promptSuggestionSchema = external_exports.discriminatedUnion("state", [
21749
+ external_exports.object({ state: external_exports.literal("pending") }).readonly(),
21750
+ external_exports.object({ state: external_exports.literal("ready"), text: external_exports.string().min(1).max(PROMPT_SUGGESTION_MAX_LENGTH) }).readonly(),
21751
+ external_exports.object({
21752
+ // A reason a newer Runtime adds reads as absent; the suggestion stays unavailable either way.
21753
+ reason: unavailableReasonSchema.optional().catch(void 0),
21754
+ state: external_exports.literal("unavailable")
21755
+ }).readonly()
21756
+ ]);
21757
+ var sessionPromptSuggestionReadCommandSchema = external_exports.object({
21758
+ kind: external_exports.literal(SESSION_PROMPT_SUGGESTION_READ_KIND),
21759
+ requestId: identifierStringSchema,
21760
+ sessionId: identifierStringSchema,
21761
+ // Not named `commandId`: the Relay routes a request carrying one as the command it names.
21762
+ turnId: identifierStringSchema
21763
+ }).readonly();
21764
+ var sessionPromptSuggestionReadResultSchema = external_exports.object({
21765
+ kind: external_exports.literal(SESSION_PROMPT_SUGGESTION_READ_RESULT_KIND),
21766
+ requestId: identifierStringSchema,
21767
+ sessionId: identifierStringSchema,
21768
+ suggestion: promptSuggestionSchema,
21769
+ turnId: identifierStringSchema
21770
+ }).readonly();
21771
+ var decodeSessionPromptSuggestionReadCommand = (encoded) => decodeZodMessage(encoded, sessionPromptSuggestionReadCommandSchema);
21772
+ var encodeSessionPromptSuggestionReadCommand = (message) => encodeZodMessage(message, sessionPromptSuggestionReadCommandSchema);
21773
+ var decodeSessionPromptSuggestionReadResult = (encoded) => decodeZodMessage(encoded, sessionPromptSuggestionReadResultSchema);
21774
+ var encodeSessionPromptSuggestionReadResult = (message) => encodeZodMessage(message, sessionPromptSuggestionReadResultSchema);
21775
+
21699
21776
  // ../mobius-sdk/src/protocol/session/prompt/usage.ts
21700
21777
  var TOKEN_COUNT = external_exports.number().int().nonnegative();
21701
21778
  function normalizeQuotaTokenCount(value) {
@@ -21895,6 +21972,11 @@ var serviceToDaemonSignatures = {
21895
21972
  encodeSessionConfigReadCommand,
21896
21973
  decodeSessionConfigReadCommand
21897
21974
  ),
21975
+ [SESSION_PROMPT_SUGGESTION_READ_KIND]: defineMessageSignature(
21976
+ SESSION_PROMPT_SUGGESTION_READ_KIND,
21977
+ encodeSessionPromptSuggestionReadCommand,
21978
+ decodeSessionPromptSuggestionReadCommand
21979
+ ),
21898
21980
  [SESSION_RENAME_KIND]: defineMessageSignature(
21899
21981
  SESSION_RENAME_KIND,
21900
21982
  encodeSessionRenameCommand,
@@ -21975,6 +22057,11 @@ var daemonToServiceSignatures = {
21975
22057
  encodeSessionConfigReadResult,
21976
22058
  decodeSessionConfigReadResult
21977
22059
  ),
22060
+ [SESSION_PROMPT_SUGGESTION_READ_RESULT_KIND]: defineMessageSignature(
22061
+ SESSION_PROMPT_SUGGESTION_READ_RESULT_KIND,
22062
+ encodeSessionPromptSuggestionReadResult,
22063
+ decodeSessionPromptSuggestionReadResult
22064
+ ),
21978
22065
  [SESSION_RENAMED_KIND]: defineMessageSignature(
21979
22066
  SESSION_RENAMED_KIND,
21980
22067
  encodeSessionRenamedEvent,
@@ -66519,6 +66606,18 @@ function disarmForceCancel(session) {
66519
66606
  session.forceCancelTimer = void 0;
66520
66607
  }
66521
66608
  }
66609
+ function isPromptSuggestionsRequested(meta3) {
66610
+ const request = isRecord7(meta3) ? meta3["promptSuggestions"] : void 0;
66611
+ return isRecord7(request) && request["enabled"] === true;
66612
+ }
66613
+ function promptSuggestionTurn(meta3) {
66614
+ const request = isRecord7(meta3) ? meta3["promptSuggestions"] : void 0;
66615
+ const turnId = isRecord7(request) ? request["turnId"] : void 0;
66616
+ return typeof turnId === "string" && turnId.length > 0 ? turnId : void 0;
66617
+ }
66618
+ function isRecord7(value) {
66619
+ return typeof value === "object" && value !== null && !Array.isArray(value);
66620
+ }
66522
66621
  function computeSessionFingerprint(params) {
66523
66622
  const servers = [...params.mcpServers ?? []].sort((a, b2) => a.name.localeCompare(b2.name));
66524
66623
  return JSON.stringify({ cwd: params.cwd, mcpServers: servers });
@@ -66814,6 +66913,7 @@ async function waitForMcpAuthentication(sessions, sessionId, query, serverName,
66814
66913
  var ClaudeAcpAgent = class {
66815
66914
  spawnClaudeCodeProcess;
66816
66915
  onBackgroundActivity;
66916
+ onPromptSuggestion;
66817
66917
  pendingSubmissions = /* @__PURE__ */ new Map();
66818
66918
  sessions;
66819
66919
  client;
@@ -66841,9 +66941,10 @@ var ClaudeAcpAgent = class {
66841
66941
  * return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
66842
66942
  * tests can shrink it. */
66843
66943
  forceCancelGraceMs = DEFAULT_FORCE_CANCEL_GRACE_MS;
66844
- constructor(client2, logger, environment = process.env, spawnClaudeCodeProcess, onBackgroundActivity) {
66944
+ constructor(client2, logger, environment = process.env, spawnClaudeCodeProcess, onBackgroundActivity, onPromptSuggestion) {
66845
66945
  this.spawnClaudeCodeProcess = spawnClaudeCodeProcess;
66846
66946
  this.onBackgroundActivity = onBackgroundActivity;
66947
+ this.onPromptSuggestion = onPromptSuggestion;
66847
66948
  this.sessions = {};
66848
66949
  this.client = client2;
66849
66950
  this.logger = logger ?? console;
@@ -67024,6 +67125,11 @@ var ClaudeAcpAgent = class {
67024
67125
  // so clients know they may inject a follow-up into a running turn, and the
67025
67126
  // `_session/rename` request so clients know they may retitle a session.
67026
67127
  _meta: {
67128
+ // A client asks for suggestions with `_meta.promptSuggestions.enabled` when it opens a session,
67129
+ // and per prompt with `_meta.promptSuggestions.turnId`; see `createSession` and `prompt_suggestion`.
67130
+ promptSuggestions: {
67131
+ supported: true
67132
+ },
67027
67133
  renameSession: {
67028
67134
  supported: true
67029
67135
  },
@@ -67285,11 +67391,16 @@ var ClaudeAcpAgent = class {
67285
67391
  const firstText = params.prompt[0]?.type === "text" ? params.prompt[0].text : "";
67286
67392
  const isLocalOnlyCommand = firstText.startsWith("/") && LOCAL_ONLY_COMMANDS.has(firstText.split(" ", 1)[0]);
67287
67393
  session.titles.onPrompt(params.prompt);
67394
+ const promptSuggestionTurnId = promptSuggestionTurn(params._meta);
67395
+ if (promptSuggestionTurnId !== void 0 && !session.promptSuggestions) {
67396
+ this.onPromptSuggestion?.({ outcome: { kind: "unsupported" }, turnId: promptSuggestionTurnId });
67397
+ }
67288
67398
  const turn = {
67289
67399
  promptUuid,
67290
67400
  inputQueuedAt: performance.now(),
67291
67401
  isLocalOnlyCommand,
67292
67402
  settled: false,
67403
+ ...promptSuggestionTurnId !== void 0 && session.promptSuggestions ? { promptSuggestionTurnId } : {},
67293
67404
  resolve: () => {
67294
67405
  },
67295
67406
  reject: () => {
@@ -67557,6 +67668,7 @@ var ClaudeAcpAgent = class {
67557
67668
  const activateTurn = (turn) => {
67558
67669
  session.activeTurn = turn;
67559
67670
  session.cancelled = false;
67671
+ session.promptSuggestionSource = null;
67560
67672
  session.pendingOrphanResults = 0;
67561
67673
  session.orphanCommands?.clear();
67562
67674
  disarmResultWatchdog();
@@ -68220,6 +68332,7 @@ ${message.api_refusal_explanation}` : "";
68220
68332
  break;
68221
68333
  case "result": {
68222
68334
  disarmResultWatchdog();
68335
+ session.promptSuggestionSource = null;
68223
68336
  const isAutonomousResult = message.origin != null && AUTONOMOUS_RESULT_ORIGINS.has(message.origin.kind) && (message.user_message_uuid === void 0 || findUnsettledTurn(message.user_message_uuid) === void 0);
68224
68337
  const pendingExitPlanModeInterruption = session.pendingExitPlanModeInterruption;
68225
68338
  const pendingExitPlanContextReset = session.pendingExitPlanContextReset;
@@ -68391,7 +68504,11 @@ ${message.api_refusal_explanation}` : "";
68391
68504
  });
68392
68505
  }
68393
68506
  if (!session.cancelled) {
68507
+ const settling = session.activeTurn;
68394
68508
  settleOrDefer(turnOutcome(session, stopReason));
68509
+ if (settling?.settled === true && stopReason === "end_turn" && !settling.isLocalOnlyCommand && settling.promptSuggestionTurnId !== void 0) {
68510
+ session.promptSuggestionSource = settling.promptSuggestionTurnId;
68511
+ }
68395
68512
  }
68396
68513
  } finally {
68397
68514
  if (message.origin?.kind === "task-notification") {
@@ -68704,9 +68821,20 @@ ${message.api_refusal_explanation}` : "";
68704
68821
  session.titles.reset();
68705
68822
  break;
68706
68823
  }
68824
+ case "prompt_suggestion": {
68825
+ const turnId = session.promptSuggestionSource;
68826
+ session.promptSuggestionSource = null;
68827
+ if (turnId !== null) {
68828
+ const text2 = message.suggestion.trim();
68829
+ this.onPromptSuggestion?.({
68830
+ outcome: text2.length === 0 ? { kind: "none" } : { kind: "suggested", text: text2 },
68831
+ turnId
68832
+ });
68833
+ }
68834
+ break;
68835
+ }
68707
68836
  case "tool_use_summary":
68708
68837
  case "auth_status":
68709
- case "prompt_suggestion":
68710
68838
  break;
68711
68839
  default:
68712
68840
  unreachable(message, this.logger);
@@ -69695,6 +69823,7 @@ ${message.api_refusal_explanation}` : "";
69695
69823
  };
69696
69824
  const providerCacheKey = providerCacheKeyFor(env);
69697
69825
  this.logger.log(`[session/query] sessionId=${sessionId} resume=${creationOpts?.resume ?? "none"} apiType=${resolvedProvider?.apiType ?? "native"} baseUrl=${resolvedProvider?.baseUrl ?? "native"}`);
69826
+ const promptSuggestions = isPromptSuggestionsRequested(params._meta) && resolvedProvider === null;
69698
69827
  const options = {
69699
69828
  systemPrompt,
69700
69829
  settingSources: ["user", "project", "local"],
@@ -69705,6 +69834,7 @@ ${message.api_refusal_explanation}` : "";
69705
69834
  // Override certain fields that must be controlled by ACP
69706
69835
  cwd: params.cwd,
69707
69836
  includePartialMessages: true,
69837
+ ...promptSuggestions ? { promptSuggestions: true } : {},
69708
69838
  forwardSubagentText,
69709
69839
  mcpServers: { ...userProvidedOptions?.mcpServers || {}, ...mcpServers },
69710
69840
  // If we want bypassPermissions to be an option, we have to allow it here.
@@ -69933,7 +70063,9 @@ ${message.api_refusal_explanation}` : "";
69933
70063
  emittedToolCalls: /* @__PURE__ */ new Set(),
69934
70064
  liveBackgroundTasks: /* @__PURE__ */ new Map(),
69935
70065
  emittedAssistantText: false,
69936
- idleBoundary: { kind: "unaccounted" }
70066
+ idleBoundary: { kind: "unaccounted" },
70067
+ promptSuggestions,
70068
+ promptSuggestionSource: null
69937
70069
  };
69938
70070
  return {
69939
70071
  sessionId,
@@ -71162,7 +71294,7 @@ async function runPromptWithCancellation(agent2, params, signal) {
71162
71294
  function createClaudeAcpApp(options = {}) {
71163
71295
  let agent2 = null;
71164
71296
  const app = agent({ name: "claude-code-acp" }).onConnect((connection) => {
71165
- agent2 = new ClaudeAcpAgent(new ClientConnection(connection.client, options.onSessionUpdate), options.logger, options.environment, options.spawnClaudeCodeProcess, options.onBackgroundActivity);
71297
+ agent2 = new ClaudeAcpAgent(new ClientConnection(connection.client, options.onSessionUpdate), options.logger, options.environment, options.spawnClaudeCodeProcess, options.onBackgroundActivity, options.onPromptSuggestion);
71166
71298
  options.onConnect?.(connection);
71167
71299
  }).onRequest(methods.agent.initialize, (ctx) => requiredAgent(agent2).initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => requiredAgent(agent2).newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => requiredAgent(agent2).loadSession(ctx.params, ctx.signal)).onRequest(methods.agent.session.fork, (ctx) => requiredAgent(agent2).unstable_forkSession(ctx.params, ctx.signal)).onRequest(methods.agent.session.list, (ctx) => requiredAgent(agent2).listSessions(ctx.params, ctx.signal)).onRequest(methods.agent.session.delete, (ctx) => requiredAgent(agent2).deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => requiredAgent(agent2).resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => requiredAgent(agent2).closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => requiredAgent(agent2).setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => requiredAgent(agent2).setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => requiredAgent(agent2).authenticate(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => requiredAgent(agent2).unstable_listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => requiredAgent(agent2).unstable_setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => requiredAgent(agent2).unstable_disableProvider(ctx.params)).onRequest(methods.agent.logout, (ctx) => requiredAgent(agent2).logout(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => runPromptWithCancellation(requiredAgent(agent2), ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => requiredAgent(agent2).cancel(ctx.params)).onRequest(STEER_METHOD, { parse: parseSteerRequest }, (ctx) => requiredAgent(agent2).steer(ctx.params)).onRequest(RENAME_METHOD, { parse: parseRenameRequest }, (ctx) => requiredAgent(agent2).renameSession(ctx.params)).onRequest(REVISION_METHOD, { parse: parseRevisionRequest }, (ctx) => requiredAgent(agent2).readSessionRevision(ctx.params, ctx.signal)).onRequest(GOAL_CONTROL_METHOD, { parse: parseGoalRequest }, (ctx) => requiredAgent(agent2).goal(ctx.params));
71168
71300
  return { agent: () => agent2, app };
@@ -71298,6 +71430,7 @@ var ClaudeAcpEndpoint = class {
71298
71430
  }),
71299
71431
  onSessionUpdate: options.onSessionUpdate,
71300
71432
  onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity),
71433
+ onPromptSuggestion: (report) => options.onPromptSuggestion?.(report),
71301
71434
  onConnect: (connection) => {
71302
71435
  this.#connection = connection;
71303
71436
  }
@@ -71334,7 +71467,8 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
71334
71467
  onSessionUpdate: async (notification) => {
71335
71468
  await options.client.onUpdate(notification);
71336
71469
  },
71337
- onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
71470
+ onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity),
71471
+ onPromptSuggestion: (report) => options.onPromptSuggestion?.(report)
71338
71472
  });
71339
71473
  super(endpoint, options.client);
71340
71474
  }
@@ -72290,6 +72424,14 @@ var turnSchema = external_exports.object({
72290
72424
  status: turnStatusSchema
72291
72425
  });
72292
72426
  var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
72427
+ var threadSampleResponseSchema = external_exports.object({ text: external_exports.string().nullable() });
72428
+ var hooksListResponseSchema = external_exports.object({
72429
+ data: external_exports.array(
72430
+ external_exports.object({
72431
+ hooks: external_exports.array(external_exports.object({ enabled: external_exports.boolean(), eventName: boundedText(256) })).max(1e4)
72432
+ })
72433
+ ).max(1e3)
72434
+ });
72293
72435
  var threadNotificationSchema = external_exports.object({ threadId: boundedText(256).min(1) });
72294
72436
  var turnNotificationSchema = external_exports.object({
72295
72437
  thread: external_exports.object({ id: boundedText(256) }).nullish(),
@@ -72597,8 +72739,11 @@ var CodexAppServerClient = class {
72597
72739
  }
72598
72740
  this.#runHandler(this.#handlers.onNotification(message.method, message.params));
72599
72741
  };
72600
- /** Sends a request and waits for its response, bounded by the caller's cancellation signal. */
72601
- request = async (method, params, signal) => {
72742
+ /**
72743
+ * Sends a request and waits for its response, bounded by the caller's cancellation signal. Abandoning a request
72744
+ * only stops waiting for it; `onAbandoned` receives its id for a method the app-server can be told to stop.
72745
+ */
72746
+ request = async (method, params, signal, onAbandoned) => {
72602
72747
  signal.throwIfAborted();
72603
72748
  this.#requireOpen();
72604
72749
  const id = this.#nextRequestId;
@@ -72608,6 +72753,7 @@ var CodexAppServerClient = class {
72608
72753
  const abort = () => {
72609
72754
  if (this.#pending.delete(id)) {
72610
72755
  completion.reject(signal.reason ?? new Error("Codex app-server request was cancelled"));
72756
+ onAbandoned?.(id);
72611
72757
  }
72612
72758
  };
72613
72759
  signal.addEventListener("abort", abort, { once: true });
@@ -72964,6 +73110,17 @@ var APPROVAL_REASON_CHARACTER_LIMIT = 500;
72964
73110
  var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
72965
73111
  var COMPACT_TIMEOUT_MILLISECONDS = 36e5;
72966
73112
  var COMPACT_ITEM_WAIT_MILLISECONDS = 6e5;
73113
+ var NEXT_PROMPT_INSTRUCTION = "Predict the next message the user will send in this conversation. Reply with only that message, written in the user's own voice as they would type it, in one short sentence. Do not use tools. If there is no clear next step, reply with nothing.";
73114
+ var HOOK_EVENTS_A_SAMPLE_SKIPS = /* @__PURE__ */ new Set([
73115
+ "permissionRequest",
73116
+ "postToolUse",
73117
+ "preToolUse",
73118
+ "stop",
73119
+ "subagentStart",
73120
+ "subagentStop"
73121
+ ]);
73122
+ var SAMPLE_TIMEOUT_MILLISECONDS = 25e3;
73123
+ var SAMPLE_CANCEL_TIMEOUT_MILLISECONDS = 5e3;
72967
73124
  var THREAD_NOTIFICATIONS = /* @__PURE__ */ new Set([
72968
73125
  "item/agentMessage/delta",
72969
73126
  "item/completed",
@@ -73106,6 +73263,8 @@ var CodexOwnedAcpAgent = class {
73106
73263
  // compaction, so the compact error path does not report a second terminal
73107
73264
  // update for the same failure.
73108
73265
  #turnSettledCompaction = false;
73266
+ /** The next-prompt sample running for the latest completed turn; a later turn or closing cancels it. */
73267
+ #sampling = null;
73109
73268
  constructor(context) {
73110
73269
  this.#context = context;
73111
73270
  this.#appServer = context.client;
@@ -73113,6 +73272,7 @@ var CodexOwnedAcpAgent = class {
73113
73272
  }
73114
73273
  nativeTurnId = () => this.#nativeTurnId;
73115
73274
  onTerminated = (termination) => {
73275
+ this.#cancelSampling();
73116
73276
  if (this.#turn !== null) {
73117
73277
  this.#turn.steeringContent.clear();
73118
73278
  }
@@ -73120,6 +73280,7 @@ var CodexOwnedAcpAgent = class {
73120
73280
  this.#settleCompaction("cancelled");
73121
73281
  };
73122
73282
  close = async () => {
73283
+ this.#cancelSampling();
73123
73284
  if (this.#turn !== null) {
73124
73285
  this.#turn.steeringContent.clear();
73125
73286
  }
@@ -73170,6 +73331,7 @@ var CodexOwnedAcpAgent = class {
73170
73331
  if (this.#turn !== null) {
73171
73332
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
73172
73333
  }
73334
+ this.#cancelSampling();
73173
73335
  if (this.#openCompaction !== null) {
73174
73336
  throw new AcpExecutionError(
73175
73337
  "Another compaction is already running in this conversation",
@@ -73581,11 +73743,12 @@ var CodexOwnedAcpAgent = class {
73581
73743
  const content = response.action === "accept" ? Reflect.get(response, "content") ?? null : null;
73582
73744
  this.#appServer.respond(request.id, { action: response.action, content });
73583
73745
  };
73584
- prompt = async (input2, signal, content) => {
73746
+ prompt = async (input2, signal, content, promptSuggestionTurnId) => {
73585
73747
  signal.throwIfAborted();
73586
73748
  if (this.#turn !== null) {
73587
73749
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
73588
73750
  }
73751
+ this.#cancelSampling();
73589
73752
  const completion = Promise.withResolvers();
73590
73753
  void completion.promise.catch(() => {
73591
73754
  });
@@ -73627,6 +73790,9 @@ var CodexOwnedAcpAgent = class {
73627
73790
  }
73628
73791
  try {
73629
73792
  const result = await completion.promise;
73793
+ if (promptSuggestionTurnId !== void 0 && result.stopReason === "end_turn") {
73794
+ this.#sampleNextPrompt(promptSuggestionTurnId, turn.turn.id);
73795
+ }
73630
73796
  return turn.input.kind === "identified" ? await promptResultWithMessageId2(Promise.resolve(result), turn.input.messageId) : result;
73631
73797
  } catch (cause) {
73632
73798
  if (turn.input.kind === "identified" && !signal.aborted) {
@@ -73710,6 +73876,65 @@ var CodexOwnedAcpAgent = class {
73710
73876
  this.#turnSettledCompaction = this.#settleCompaction("cancelled") !== null;
73711
73877
  turn.completion.resolve({ stopReason: "cancelled" });
73712
73878
  };
73879
+ #cancelSampling = () => {
73880
+ this.#sampling?.abort();
73881
+ this.#sampling = null;
73882
+ };
73883
+ /**
73884
+ * Predicts the member's next prompt from the thread as it stands after `sourceTurnId`, without blocking the turn
73885
+ * that just completed. Only the latest turn's sample reports: a later turn or closing cancels it, and the
73886
+ * app-server is told to stop.
73887
+ */
73888
+ #sampleNextPrompt = (turnId, sourceTurnId) => {
73889
+ this.#cancelSampling();
73890
+ const sampling = new AbortController();
73891
+ this.#sampling = sampling;
73892
+ const signal = AbortSignal.any([sampling.signal, AbortSignal.timeout(SAMPLE_TIMEOUT_MILLISECONDS)]);
73893
+ const sample = async () => {
73894
+ if (sourceTurnId.length === 0) {
73895
+ return { kind: "failed" };
73896
+ }
73897
+ try {
73898
+ const configured = hooksListResponseSchema.parse(
73899
+ await this.#appServer.request("hooks/list", { cwds: [this.#context.cwd()] }, signal)
73900
+ );
73901
+ if (configured.data.some(
73902
+ (entry) => entry.hooks.some((hook) => hook.enabled && !HOOK_EVENTS_A_SAMPLE_SKIPS.has(hook.eventName))
73903
+ )) {
73904
+ return { kind: "unsupported" };
73905
+ }
73906
+ const response = threadSampleResponseSchema.parse(
73907
+ await this.#appServer.request(
73908
+ "thread/sample",
73909
+ {
73910
+ effort: "low",
73911
+ expectedTurnId: sourceTurnId,
73912
+ prompt: NEXT_PROMPT_INSTRUCTION,
73913
+ threadId: this.#context.threadId()
73914
+ },
73915
+ signal,
73916
+ (requestId) => {
73917
+ void this.#appServer.request(
73918
+ "thread/sample/cancel",
73919
+ { requestId },
73920
+ AbortSignal.timeout(SAMPLE_CANCEL_TIMEOUT_MILLISECONDS)
73921
+ ).catch(() => void 0);
73922
+ }
73923
+ )
73924
+ );
73925
+ const text2 = response.text?.trim() ?? "";
73926
+ return text2.length === 0 ? { kind: "none" } : { kind: "suggested", text: text2 };
73927
+ } catch {
73928
+ return { kind: "failed" };
73929
+ }
73930
+ };
73931
+ void sample().then((outcome) => {
73932
+ if (this.#sampling === sampling) {
73933
+ this.#sampling = null;
73934
+ this.#context.onPromptSuggestion?.({ outcome, turnId });
73935
+ }
73936
+ });
73937
+ };
73713
73938
  #completeTurn = async (turn) => {
73714
73939
  const active = this.#turn;
73715
73940
  if (active === null || active.turn.id !== turn.id) {
@@ -74821,6 +75046,7 @@ var CodexSettings = class {
74821
75046
  import { randomUUID as randomUUID9 } from "node:crypto";
74822
75047
  var APPROVAL_TIMEOUT_MILLISECONDS3 = 36e5;
74823
75048
  var CODEX_AGENT_VERSION = "0.154.0";
75049
+ var SAMPLING_PROBE_TIMEOUT_MILLISECONDS = 1e4;
74824
75050
  var SESSION_LIST_TIMEOUT_MILLISECONDS2 = 3e4;
74825
75051
  function promptInput(prompt) {
74826
75052
  const input2 = [];
@@ -74851,6 +75077,11 @@ function promptInput(prompt) {
74851
75077
  function isCompactCommand(prompt) {
74852
75078
  return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim().toLowerCase() === "/compact";
74853
75079
  }
75080
+ function promptSuggestionTurn2(meta3) {
75081
+ const request = typeof meta3 === "object" && meta3 !== null ? Reflect.get(meta3, "promptSuggestions") : void 0;
75082
+ const turnId = typeof request === "object" && request !== null ? Reflect.get(request, "turnId") : void 0;
75083
+ return typeof turnId === "string" && turnId.length > 0 ? turnId : void 0;
75084
+ }
74854
75085
  var CodexAcpAgent = class {
74855
75086
  #app;
74856
75087
  #appServer;
@@ -74861,12 +75092,17 @@ var CodexAcpAgent = class {
74861
75092
  #onSessionUpdate;
74862
75093
  #onBackgroundActivity;
74863
75094
  #onPromptDelegation;
75095
+ #onPromptSuggestion;
75096
+ /** Whether this app-server serves `thread/sample`, which predicts the member's next prompt. */
75097
+ #promptSampling = false;
74864
75098
  #nativeSessionId = "";
75099
+ #threadCwd = "";
74865
75100
  #sessionAgent;
74866
75101
  constructor(options) {
74867
75102
  this.#onSessionUpdate = options.onSessionUpdate;
74868
75103
  this.#onBackgroundActivity = options.onBackgroundActivity;
74869
75104
  this.#onPromptDelegation = options.onPromptDelegation;
75105
+ this.#onPromptSuggestion = options.onPromptSuggestion;
74870
75106
  this.#appServer = new CodexAppServerClient({
74871
75107
  command: options.command,
74872
75108
  cwd: options.cwd,
@@ -74885,6 +75121,7 @@ var CodexAcpAgent = class {
74885
75121
  client: this.#appServer,
74886
75122
  settings: this.#settings,
74887
75123
  threadId: () => this.#nativeSessionId,
75124
+ cwd: () => this.#threadCwd,
74888
75125
  connection: () => this.#connection,
74889
75126
  emit: this.#emit,
74890
75127
  onBackgroundActivity: (activity) => {
@@ -74892,6 +75129,11 @@ var CodexAcpAgent = class {
74892
75129
  this.#onBackgroundActivity?.(activity);
74893
75130
  }
74894
75131
  },
75132
+ onPromptSuggestion: (report) => {
75133
+ if (this.#closePromise === null) {
75134
+ this.#onPromptSuggestion?.(report);
75135
+ }
75136
+ },
74895
75137
  close: this.close
74896
75138
  });
74897
75139
  this.terminated = this.#appServer.terminated;
@@ -74906,7 +75148,7 @@ var CodexAcpAgent = class {
74906
75148
  this.#app = agent({ name: "mobius-codex" }).onConnect((connection) => {
74907
75149
  this.#connection = connection;
74908
75150
  }).onRequest(methods.agent.initialize, async () => ({
74909
- _meta: { steering: { supported: true } },
75151
+ _meta: { promptSuggestions: { supported: this.#promptSampling }, steering: { supported: true } },
74910
75152
  agentCapabilities: {
74911
75153
  loadSession: true,
74912
75154
  promptCapabilities: { embeddedContext: true, image: true },
@@ -74924,6 +75166,7 @@ var CodexAcpAgent = class {
74924
75166
  )
74925
75167
  );
74926
75168
  this.#nativeSessionId = created.thread.id;
75169
+ this.#threadCwd = context.params.cwd;
74927
75170
  this.#settings.selectNewThread(created);
74928
75171
  await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
74929
75172
  this.#advertiseCompactCommand();
@@ -74957,6 +75200,7 @@ var CodexAcpAgent = class {
74957
75200
  )
74958
75201
  );
74959
75202
  this.#nativeSessionId = forked.thread.id;
75203
+ this.#threadCwd = context.params.cwd;
74960
75204
  this.#settings.selectRestoredThread(forked);
74961
75205
  await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
74962
75206
  this.#advertiseCompactCommand();
@@ -74969,6 +75213,11 @@ var CodexAcpAgent = class {
74969
75213
  configOptions: this.#settings.configOptions()
74970
75214
  };
74971
75215
  }).onRequest(methods.agent.session.prompt, async (context) => {
75216
+ const promptSuggestionTurnId = promptSuggestionTurn2(context.params._meta);
75217
+ const samples = this.#promptSampling && this.#sessionAgent.runsTurns && !isCompactCommand(context.params.prompt);
75218
+ if (promptSuggestionTurnId !== void 0 && !samples) {
75219
+ this.#onPromptSuggestion?.({ outcome: { kind: "unsupported" }, turnId: promptSuggestionTurnId });
75220
+ }
74972
75221
  if (isCompactCommand(context.params.prompt)) {
74973
75222
  const messageId = randomUUID9();
74974
75223
  for (const content of context.params.prompt) {
@@ -74979,7 +75228,8 @@ var CodexAcpAgent = class {
74979
75228
  return await this.#sessionAgent.prompt(
74980
75229
  promptInput(context.params.prompt),
74981
75230
  context.signal,
74982
- context.params.prompt
75231
+ context.params.prompt,
75232
+ samples ? promptSuggestionTurnId : void 0
74983
75233
  );
74984
75234
  }).onRequest(
74985
75235
  "_session/steering",
@@ -75021,6 +75271,24 @@ var CodexAcpAgent = class {
75021
75271
  initialize = async (signal) => {
75022
75272
  await this.#appServer.initialize(signal);
75023
75273
  await this.#settings.loadModels(signal);
75274
+ this.#promptSampling = await this.#probePromptSampling(signal);
75275
+ };
75276
+ /**
75277
+ * Asks the app-server itself whether it serves `thread/sample`: cancelling a sample that does not exist succeeds
75278
+ * there and fails as an unknown method on a release without sampling.
75279
+ */
75280
+ #probePromptSampling = async (signal) => {
75281
+ try {
75282
+ await this.#appServer.request(
75283
+ "thread/sample/cancel",
75284
+ { requestId: `mobius-sampling-probe-${randomUUID9()}` },
75285
+ AbortSignal.any([signal, AbortSignal.timeout(SAMPLING_PROBE_TIMEOUT_MILLISECONDS)])
75286
+ );
75287
+ return true;
75288
+ } catch {
75289
+ signal.throwIfAborted();
75290
+ return false;
75291
+ }
75024
75292
  };
75025
75293
  /**
75026
75294
  * Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
@@ -75092,11 +75360,13 @@ var CodexAcpAgent = class {
75092
75360
  return;
75093
75361
  }
75094
75362
  this.#nativeSessionId = resumed.thread.id;
75363
+ this.#threadCwd = cwd;
75095
75364
  this.#settings.selectRestoredThread(resumed);
75096
75365
  await this.#settings.probeCollaborationMode(this.#nativeSessionId, signal);
75097
75366
  };
75098
75367
  /** What the session response tells Mobius about the session behavior selected while opening it. */
75099
75368
  #sessionMeta = () => ({
75369
+ promptSuggestions: { supported: this.#promptSampling && this.#sessionAgent.runsTurns },
75100
75370
  steering: { supported: this.#sessionAgent.steeringSupported },
75101
75371
  codex: { runsTurns: this.#sessionAgent.runsTurns }
75102
75372
  });
@@ -75145,7 +75415,8 @@ var CodexAgentConnection = class extends EndpointAgentConnection {
75145
75415
  environment: options.environment,
75146
75416
  onSessionUpdate: options.client.onUpdate,
75147
75417
  onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity),
75148
- onPromptDelegation: async (stage) => await options.onPromptDelegation?.(stage)
75418
+ onPromptDelegation: async (stage) => await options.onPromptDelegation?.(stage),
75419
+ onPromptSuggestion: (report) => options.onPromptSuggestion?.(report)
75149
75420
  });
75150
75421
  super(endpoint, options.client);
75151
75422
  }
@@ -79397,12 +79668,12 @@ var LocalAgentInventory = class {
79397
79668
  constructor(results) {
79398
79669
  const discoveries = results.map((result) => result.discovery);
79399
79670
  const available = [];
79400
- const unavailable = [];
79671
+ const unavailable2 = [];
79401
79672
  for (const discovery of discoveries) {
79402
79673
  if (discovery instanceof AvailableAgent) {
79403
79674
  available.push(discovery);
79404
79675
  } else if (discovery instanceof UnavailableAgent) {
79405
- unavailable.push(discovery);
79676
+ unavailable2.push(discovery);
79406
79677
  } else {
79407
79678
  throw new Error("Unsupported Agent discovery outcome");
79408
79679
  }
@@ -79410,7 +79681,7 @@ var LocalAgentInventory = class {
79410
79681
  this.available = Object.freeze(available);
79411
79682
  this.discoveries = Object.freeze([...discoveries]);
79412
79683
  this.results = Object.freeze([...results]);
79413
- this.unavailable = Object.freeze(unavailable);
79684
+ this.unavailable = Object.freeze(unavailable2);
79414
79685
  }
79415
79686
  detectionMillisecondsFor = (discovery) => {
79416
79687
  for (const result of this.results) {
@@ -79457,6 +79728,7 @@ function unsupportedSessionCapabilities() {
79457
79728
  listSessions: false,
79458
79729
  loadSession: false,
79459
79730
  promptQueueing: false,
79731
+ promptSuggestions: false,
79460
79732
  renameSession: false,
79461
79733
  resumeSession: false,
79462
79734
  steering: false,
@@ -79477,6 +79749,7 @@ function normalizeAcpCapabilities(initialized) {
79477
79749
  listSessions: session?.list != null,
79478
79750
  loadSession: capabilities.loadSession === true,
79479
79751
  promptQueueing: hasTrueChildField(capabilities._meta, "claudeCode", "promptQueueing"),
79752
+ promptSuggestions: hasTrueChildField(initialized._meta, "promptSuggestions", "supported"),
79480
79753
  renameSession: hasTrueChildField(initialized._meta, "renameSession", "supported"),
79481
79754
  resumeSession: session?.resume != null,
79482
79755
  steering: hasTrueChildField(initialized._meta, "steering", "supported"),
@@ -79488,10 +79761,17 @@ function restrictAcpSessionCapabilities(capabilities, response) {
79488
79761
  return capabilities;
79489
79762
  }
79490
79763
  const steering = response["_meta"]["steering"];
79491
- if (!isRecord5(steering) || steering["supported"] !== false) {
79764
+ const promptSuggestions = response["_meta"]["promptSuggestions"];
79765
+ const steeringWithdrawn = isRecord5(steering) && steering["supported"] === false;
79766
+ const promptSuggestionsWithdrawn = isRecord5(promptSuggestions) && promptSuggestions["supported"] === false;
79767
+ if (!steeringWithdrawn && !promptSuggestionsWithdrawn) {
79492
79768
  return capabilities;
79493
79769
  }
79494
- return Object.freeze({ ...capabilities, steering: false });
79770
+ return Object.freeze({
79771
+ ...capabilities,
79772
+ ...steeringWithdrawn ? { steering: false } : {},
79773
+ ...promptSuggestionsWithdrawn ? { promptSuggestions: false } : {}
79774
+ });
79495
79775
  }
79496
79776
 
79497
79777
  // src/engine/acp/agent/agent-definition.ts
@@ -80059,7 +80339,7 @@ var SessionConfigProtocolError = class extends Error {
80059
80339
  this.name = "SessionConfigProtocolError";
80060
80340
  }
80061
80341
  };
80062
- function isRecord7(value) {
80342
+ function isRecord8(value) {
80063
80343
  return typeof value === "object" && value !== null && !Array.isArray(value);
80064
80344
  }
80065
80345
  function readString3(value, fallback = "") {
@@ -80090,7 +80370,7 @@ function normalizeConfigValues(value) {
80090
80370
  }
80091
80371
  const normalized = [];
80092
80372
  for (const entry of value) {
80093
- if (!isRecord7(entry)) {
80373
+ if (!isRecord8(entry)) {
80094
80374
  continue;
80095
80375
  }
80096
80376
  const groupedOptions = entry["options"];
@@ -80098,7 +80378,7 @@ function normalizeConfigValues(value) {
80098
80378
  const groupId = readString3(entry["group"]);
80099
80379
  const groupName = readString3(entry["name"]);
80100
80380
  for (const groupedOption of groupedOptions) {
80101
- if (isRecord7(groupedOption)) {
80381
+ if (isRecord8(groupedOption)) {
80102
80382
  const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
80103
80383
  if (normalizedValue !== void 0) {
80104
80384
  normalized.push(normalizedValue);
@@ -80123,7 +80403,7 @@ function normalizeConfigOptions(value, modes) {
80123
80403
  const normalized = [];
80124
80404
  if (Array.isArray(value)) {
80125
80405
  for (const option of value) {
80126
- if (!isRecord7(option)) {
80406
+ if (!isRecord8(option)) {
80127
80407
  continue;
80128
80408
  }
80129
80409
  const id = truncate3(readString3(option["id"]), 128);
@@ -80163,12 +80443,12 @@ function normalizeConfigOptions(value, modes) {
80163
80443
  }
80164
80444
  }
80165
80445
  }
80166
- if (isRecord7(modes)) {
80446
+ if (isRecord8(modes)) {
80167
80447
  const values = [];
80168
80448
  const availableModes = modes["availableModes"];
80169
80449
  if (Array.isArray(availableModes)) {
80170
80450
  for (const mode of availableModes) {
80171
- if (!isRecord7(mode)) {
80451
+ if (!isRecord8(mode)) {
80172
80452
  continue;
80173
80453
  }
80174
80454
  const id = truncate3(readString3(mode["id"]), 500);
@@ -80201,7 +80481,7 @@ function normalizeConfigOptions(value, modes) {
80201
80481
  return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
80202
80482
  }
80203
80483
  function normalizeStandardLifecycle(response) {
80204
- const lifecycle = isRecord7(response) ? response : {};
80484
+ const lifecycle = isRecord8(response) ? response : {};
80205
80485
  return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
80206
80486
  }
80207
80487
  function replaceStandardConfigOptions(current, value) {
@@ -80243,7 +80523,7 @@ var StandardSessionConfigProtocol = class {
80243
80523
  "ACP agent exited while changing session configuration",
80244
80524
  change.signal
80245
80525
  );
80246
- if (!isRecord7(response) || !Array.isArray(response["configOptions"])) {
80526
+ if (!isRecord8(response) || !Array.isArray(response["configOptions"])) {
80247
80527
  throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
80248
80528
  }
80249
80529
  return replaceStandardConfigOptions(current, response["configOptions"]);
@@ -80596,6 +80876,11 @@ var AdapterSessionConnection = class {
80596
80876
  if (!this.#lifetime.signal.aborted) {
80597
80877
  await options.onPromptDelegation?.(stage);
80598
80878
  }
80879
+ },
80880
+ onPromptSuggestion: (report) => {
80881
+ if (!this.#lifetime.signal.aborted) {
80882
+ options.onPromptSuggestion?.(report);
80883
+ }
80599
80884
  }
80600
80885
  });
80601
80886
  }
@@ -80778,6 +81063,7 @@ var AcpExecutionConnections = class {
80778
81063
  onEvent: (event) => params.onSessionEvent(connection.events.sessionId(), event),
80779
81064
  ...params.onBackgroundActivity === void 0 ? {} : { onBackgroundActivity: params.onBackgroundActivity },
80780
81065
  ...params.onPromptDelegation === void 0 ? {} : { onPromptDelegation: params.onPromptDelegation },
81066
+ ...params.onPromptSuggestion === void 0 ? {} : { onPromptSuggestion: params.onPromptSuggestion },
80781
81067
  interactions: params.interactions
80782
81068
  },
80783
81069
  this.#externalizer,
@@ -80897,14 +81183,23 @@ var AcpExecutionConnections = class {
80897
81183
  }
80898
81184
  signal.throwIfAborted();
80899
81185
  };
80900
- prompt = async ({ content, signal, ...target }) => {
81186
+ prompt = async ({
81187
+ content,
81188
+ promptSuggestionTurnId,
81189
+ signal,
81190
+ ...target
81191
+ }) => {
80901
81192
  signal.throwIfAborted();
80902
81193
  const { connection } = this.#resolve(target);
80903
81194
  const prompt = buildPromptContent(content, connection.snapshot().capabilities);
80904
81195
  const response = await connection.race(
80905
81196
  connection.connection.agent.request(
80906
81197
  methods.agent.session.prompt,
80907
- { prompt, sessionId: target.nativeSessionId },
81198
+ {
81199
+ prompt,
81200
+ sessionId: target.nativeSessionId,
81201
+ ...promptSuggestionTurnId === void 0 ? {} : { _meta: { promptSuggestions: { turnId: promptSuggestionTurnId } } }
81202
+ },
80908
81203
  { cancellationSignal: signal }
80909
81204
  ),
80910
81205
  "ACP agent exited during a prompt",
@@ -81390,6 +81685,12 @@ var AgentQueryProcesses = class {
81390
81685
  };
81391
81686
 
81392
81687
  // src/engine/acp/adapter/claude/adapter.ts
81688
+ function openingRequest(params, execution) {
81689
+ return {
81690
+ ...sessionWorkspace(params.scope),
81691
+ ...params.suggestNextPrompt === true && execution.connection.snapshot().capabilities.promptSuggestions ? { _meta: { promptSuggestions: { enabled: true } } } : {}
81692
+ };
81693
+ }
81393
81694
  var ClaudeAdapter = class {
81394
81695
  #queryProcesses;
81395
81696
  #connector;
@@ -81404,7 +81705,7 @@ var ClaudeAdapter = class {
81404
81705
  createSession = (params) => this.#executionConnections.withConnection(params, async (execution, signal) => {
81405
81706
  const { connection } = execution;
81406
81707
  const response = await connection.race(
81407
- connection.connection.agent.request(methods.agent.session.new, sessionWorkspace(params.scope), {
81708
+ connection.connection.agent.request(methods.agent.session.new, openingRequest(params, execution), {
81408
81709
  cancellationSignal: signal
81409
81710
  }),
81410
81711
  "ACP agent exited while starting a session",
@@ -81421,7 +81722,7 @@ var ClaudeAdapter = class {
81421
81722
  const response = await connection.race(
81422
81723
  connection.connection.agent.request(
81423
81724
  methods.agent.session.resume,
81424
- { ...sessionWorkspace(params.scope), sessionId: nativeSessionId },
81725
+ { ...openingRequest(params, execution), sessionId: nativeSessionId },
81425
81726
  { cancellationSignal: signal }
81426
81727
  ),
81427
81728
  "ACP agent exited while resuming a session",
@@ -81436,7 +81737,7 @@ var ClaudeAdapter = class {
81436
81737
  const response = await connection.race(
81437
81738
  connection.connection.agent.request(
81438
81739
  methods.agent.session.load,
81439
- { ...sessionWorkspace(params.scope), sessionId: nativeSessionId },
81740
+ { ...openingRequest(params, execution), sessionId: nativeSessionId },
81440
81741
  { cancellationSignal: signal }
81441
81742
  ),
81442
81743
  "ACP agent exited while loading a session",
@@ -81784,7 +82085,7 @@ var toolImageSchema = external_exports.union([
81784
82085
  file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
81785
82086
  }).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
81786
82087
  ]);
81787
- function isRecord8(value) {
82088
+ function isRecord9(value) {
81788
82089
  return typeof value === "object" && value !== null && !Array.isArray(value);
81789
82090
  }
81790
82091
  var AcpContentExternalizer = class {
@@ -81836,8 +82137,8 @@ var AcpContentExternalizer = class {
81836
82137
  };
81837
82138
  } catch {
81838
82139
  signal.throwIfAborted();
81839
- const unavailable = { type: "text", text: "[Image unavailable]" };
81840
- return { agent: unavailable, event: unavailable };
82140
+ const unavailable2 = { type: "text", text: "[Image unavailable]" };
82141
+ return { agent: unavailable2, event: unavailable2 };
81841
82142
  }
81842
82143
  }
81843
82144
  case "audio": {
@@ -81902,13 +82203,13 @@ var AcpContentExternalizer = class {
81902
82203
  }
81903
82204
  return result2;
81904
82205
  }
81905
- if (!isRecord8(value)) {
82206
+ if (!isRecord9(value)) {
81906
82207
  return value;
81907
82208
  }
81908
82209
  const image = toolImageSchema.safeParse(value);
81909
82210
  if (image.success && image.data.data.length > 0) {
81910
82211
  const prepared = await this.#content(sessionId, image.data, signal);
81911
- if (isRecord8(prepared.event) && typeof prepared.event["imageKey"] === "string") {
82212
+ if (isRecord9(prepared.event) && typeof prepared.event["imageKey"] === "string") {
81912
82213
  images.set(prepared.event["imageKey"], prepared);
81913
82214
  } else {
81914
82215
  images.set(`unavailable:${images.size}`, prepared);
@@ -81939,7 +82240,7 @@ var AcpContentExternalizer = class {
81939
82240
  const prepared = await this.#content(sessionId, content, signal);
81940
82241
  agentContent.push({ ...item, content: prepared.agent });
81941
82242
  eventContent.push({ ...item, content: prepared.event });
81942
- if (isRecord8(prepared.event) && typeof prepared.event["imageKey"] === "string") {
82243
+ if (isRecord9(prepared.event) && typeof prepared.event["imageKey"] === "string") {
81943
82244
  images.delete(prepared.event["imageKey"]);
81944
82245
  }
81945
82246
  }
@@ -82371,7 +82672,7 @@ var AgentCatalogPublishError = class extends Error {
82371
82672
  this.name = "AgentCatalogPublishError";
82372
82673
  }
82373
82674
  };
82374
- function isRecord9(value) {
82675
+ function isRecord10(value) {
82375
82676
  return typeof value === "object" && value !== null && !Array.isArray(value);
82376
82677
  }
82377
82678
  function isSafeRelayErrorMessage(value) {
@@ -82384,7 +82685,7 @@ async function rejectedCatalogError(response) {
82384
82685
  } catch {
82385
82686
  return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
82386
82687
  }
82387
- if (!isRecord9(value) || !isRecord9(value["error"])) {
82688
+ if (!isRecord10(value) || !isRecord10(value["error"])) {
82388
82689
  return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
82389
82690
  }
82390
82691
  const code = value["error"]["code"];
@@ -89419,6 +89720,194 @@ var SessionInteractions = class {
89419
89720
  };
89420
89721
  };
89421
89722
 
89723
+ // src/engine/session/prompt/prompt-suggestions.ts
89724
+ var PROMPT_SUGGESTION_DEADLINE_MILLISECONDS = 3e4;
89725
+ var PROMPT_SUGGESTION_RETENTION_MILLISECONDS = 30 * 6e4;
89726
+ var MAX_SUPERSEDED_TURNS = 8;
89727
+ var promptSuggestionsDisabled = Object.freeze({
89728
+ wanted: () => false,
89729
+ report: () => {
89730
+ }
89731
+ });
89732
+ function unavailable(reason) {
89733
+ return { reason, state: "unavailable" };
89734
+ }
89735
+ function suggestion(outcome) {
89736
+ switch (outcome.kind) {
89737
+ case "suggested": {
89738
+ const text2 = outcome.text.trim();
89739
+ return text2.length === 0 || text2.length > PROMPT_SUGGESTION_MAX_LENGTH ? unavailable(PromptSuggestionUnavailableReason.NoSuggestion) : { state: "ready", text: text2 };
89740
+ }
89741
+ case "none":
89742
+ return unavailable(PromptSuggestionUnavailableReason.NoSuggestion);
89743
+ case "unsupported":
89744
+ return unavailable(PromptSuggestionUnavailableReason.Unsupported);
89745
+ case "failed":
89746
+ return unavailable(PromptSuggestionUnavailableReason.Failed);
89747
+ default: {
89748
+ const unreachable2 = outcome;
89749
+ return unreachable2;
89750
+ }
89751
+ }
89752
+ }
89753
+ var PromptSuggestions = class {
89754
+ #closed = false;
89755
+ #sessions = /* @__PURE__ */ new Map();
89756
+ #timer;
89757
+ constructor(timer) {
89758
+ this.#timer = timer;
89759
+ }
89760
+ /** Records whether the member wants suggestions; an Agent that fixes this per conversation applies it on opening. */
89761
+ want = (sessionId, wanted) => {
89762
+ if (this.#closed) {
89763
+ return;
89764
+ }
89765
+ const session = this.#session(sessionId);
89766
+ session.wanted = wanted;
89767
+ this.#retain(sessionId, session);
89768
+ };
89769
+ wanted = (sessionId) => this.#sessions.get(sessionId)?.wanted === true;
89770
+ /** A Turn starts running in the Session; the suggestion for any earlier Turn no longer follows the latest Turn. */
89771
+ begin = (sessionId, turnId, request) => {
89772
+ if (this.#closed) {
89773
+ return;
89774
+ }
89775
+ const session = this.#session(sessionId);
89776
+ const previous = session.latest;
89777
+ if (previous !== null && previous.turnId !== turnId) {
89778
+ if (previous.state.kind === "awaiting") {
89779
+ previous.state.deadline.cancel();
89780
+ }
89781
+ session.superseded.push(previous.turnId);
89782
+ session.superseded.splice(0, Math.max(0, session.superseded.length - MAX_SUPERSEDED_TURNS));
89783
+ }
89784
+ session.latest = {
89785
+ state: request === "requested" ? { kind: "running", early: null } : {
89786
+ kind: "settled",
89787
+ suggestion: unavailable(
89788
+ request === "unsupported" ? PromptSuggestionUnavailableReason.Unsupported : PromptSuggestionUnavailableReason.NotRequested
89789
+ )
89790
+ },
89791
+ turnId
89792
+ };
89793
+ this.#retain(sessionId, session);
89794
+ };
89795
+ /** The Turn ended. Only a Turn the Agent finished normally is followed by a suggestion. */
89796
+ finish = (sessionId, turnId, stopReason) => {
89797
+ const session = this.#sessions.get(sessionId);
89798
+ const turn = this.#latest(sessionId, turnId);
89799
+ if (session === void 0 || turn === void 0 || turn.state.kind !== "running") {
89800
+ return;
89801
+ }
89802
+ if (stopReason !== "end_turn") {
89803
+ turn.state = {
89804
+ kind: "settled",
89805
+ suggestion: unavailable(PromptSuggestionUnavailableReason.TurnNotCompleted)
89806
+ };
89807
+ } else if (turn.state.early !== null) {
89808
+ turn.state = { kind: "settled", suggestion: suggestion(turn.state.early) };
89809
+ } else {
89810
+ const deadline = this.#timer.schedule(() => {
89811
+ if (turn.state.kind === "awaiting") {
89812
+ turn.state = {
89813
+ kind: "settled",
89814
+ suggestion: unavailable(PromptSuggestionUnavailableReason.TimedOut)
89815
+ };
89816
+ }
89817
+ }, PROMPT_SUGGESTION_DEADLINE_MILLISECONDS);
89818
+ turn.state = { kind: "awaiting", deadline };
89819
+ }
89820
+ this.#retain(sessionId, session);
89821
+ };
89822
+ /** The Agent's suggestion for a Turn. A report for an earlier Turn, or one past its deadline, is dropped. */
89823
+ report = (sessionId, turnId, outcome) => {
89824
+ const session = this.#sessions.get(sessionId);
89825
+ const turn = this.#latest(sessionId, turnId);
89826
+ if (session === void 0 || turn === void 0) {
89827
+ return;
89828
+ }
89829
+ switch (turn.state.kind) {
89830
+ case "running":
89831
+ if (turn.state.early === null) {
89832
+ turn.state = { kind: "running", early: outcome };
89833
+ }
89834
+ return;
89835
+ case "awaiting":
89836
+ turn.state.deadline.cancel();
89837
+ turn.state = { kind: "settled", suggestion: suggestion(outcome) };
89838
+ this.#retain(sessionId, session);
89839
+ return;
89840
+ case "settled":
89841
+ return;
89842
+ default: {
89843
+ const unreachable2 = turn.state;
89844
+ throw new Error("Unexpected prompt suggestion state", { cause: unreachable2 });
89845
+ }
89846
+ }
89847
+ };
89848
+ read = (sessionId, turnId) => {
89849
+ const turn = this.#latest(sessionId, turnId);
89850
+ if (turn === void 0) {
89851
+ return unavailable(
89852
+ this.#sessions.get(sessionId)?.superseded.includes(turnId) === true ? PromptSuggestionUnavailableReason.Superseded : PromptSuggestionUnavailableReason.UnknownTurn
89853
+ );
89854
+ }
89855
+ switch (turn.state.kind) {
89856
+ case "running":
89857
+ case "awaiting":
89858
+ return { state: "pending" };
89859
+ case "settled":
89860
+ return turn.state.suggestion;
89861
+ default: {
89862
+ const unreachable2 = turn.state;
89863
+ return unreachable2;
89864
+ }
89865
+ }
89866
+ };
89867
+ /** Forgets every Session and stops their deadlines, so a stopping Runtime has no timer left to wait for. */
89868
+ close = () => {
89869
+ this.#closed = true;
89870
+ for (const session of this.#sessions.values()) {
89871
+ session.retention?.cancel();
89872
+ if (session.latest?.state.kind === "awaiting") {
89873
+ session.latest.state.deadline.cancel();
89874
+ }
89875
+ }
89876
+ this.#sessions.clear();
89877
+ };
89878
+ /** The Session's latest Turn when it is `turnId`. */
89879
+ #latest = (sessionId, turnId) => {
89880
+ const latest = this.#sessions.get(sessionId)?.latest;
89881
+ return latest?.turnId === turnId ? latest : void 0;
89882
+ };
89883
+ #session = (sessionId) => {
89884
+ const existing = this.#sessions.get(sessionId);
89885
+ if (existing !== void 0) {
89886
+ return existing;
89887
+ }
89888
+ const session = { latest: null, retention: null, superseded: [], wanted: false };
89889
+ this.#sessions.set(sessionId, session);
89890
+ return session;
89891
+ };
89892
+ /** Forgets the Session once it has been idle for the retention period. A running Turn keeps it however long. */
89893
+ #retain = (sessionId, session) => {
89894
+ session.retention?.cancel();
89895
+ session.retention = null;
89896
+ if (session.latest?.state.kind === "running") {
89897
+ return;
89898
+ }
89899
+ session.retention = this.#timer.schedule(() => {
89900
+ if (this.#sessions.get(sessionId) !== session) {
89901
+ return;
89902
+ }
89903
+ if (session.latest?.state.kind === "awaiting") {
89904
+ session.latest.state.deadline.cancel();
89905
+ }
89906
+ this.#sessions.delete(sessionId);
89907
+ }, PROMPT_SUGGESTION_RETENTION_MILLISECONDS);
89908
+ };
89909
+ };
89910
+
89422
89911
  // src/engine/session/settings/configuration-dependencies.ts
89423
89912
  function isModelOption(option) {
89424
89913
  return option.id === "model" || option.category === "model";
@@ -89772,6 +90261,7 @@ var AgentSession = class _AgentSession {
89772
90261
  #mobiusSessionId;
89773
90262
  #metrics;
89774
90263
  #store;
90264
+ #promptSuggestions;
89775
90265
  #agentName = "";
89776
90266
  #agentVersion = "";
89777
90267
  #capabilities = unsupportedSessionCapabilities();
@@ -89787,8 +90277,9 @@ var AgentSession = class _AgentSession {
89787
90277
  #restored = false;
89788
90278
  #sessionTitle = null;
89789
90279
  #sessionUpdatedAt = "";
89790
- constructor(agent2, cwd, additionalDirectories, mobiusSessionId, getObserver, agentCommand, store, metrics, adapter, externalize) {
90280
+ constructor(agent2, cwd, additionalDirectories, mobiusSessionId, getObserver, agentCommand, store, metrics, adapter, externalize, promptSuggestions) {
89791
90281
  this.#agentCommand = () => agentCommand(this.#mobiusSessionId);
90282
+ this.#promptSuggestions = promptSuggestions;
89792
90283
  this.#additionalDirectories = [...additionalDirectories];
89793
90284
  this.#adapter = adapter;
89794
90285
  this.#agentId = agent2.id;
@@ -89840,6 +90331,9 @@ var AgentSession = class _AgentSession {
89840
90331
  });
89841
90332
  }
89842
90333
  },
90334
+ onPromptSuggestion: (report) => {
90335
+ this.#promptSuggestions.report(this.#mobiusSessionId, report.turnId, report.outcome);
90336
+ },
89843
90337
  interactions: {
89844
90338
  onPermission: this.#interactions.onPermission,
89845
90339
  onElicitation: this.#interactions.onElicitation,
@@ -89847,7 +90341,7 @@ var AgentSession = class _AgentSession {
89847
90341
  }
89848
90342
  };
89849
90343
  }
89850
- static async #start(options, getObserver, agentCommand, store, initialize, metrics, adapter) {
90344
+ static async #start(options, getObserver, agentCommand, store, initialize, metrics, adapter, promptSuggestions) {
89851
90345
  for (let attempt = 1; attempt <= 2; attempt += 1) {
89852
90346
  await metrics.measure(
89853
90347
  "executable-validation",
@@ -89865,7 +90359,8 @@ var AgentSession = class _AgentSession {
89865
90359
  store,
89866
90360
  metrics,
89867
90361
  adapter,
89868
- options.externalizeSessionUpdate
90362
+ options.externalizeSessionUpdate,
90363
+ promptSuggestions
89869
90364
  )
89870
90365
  );
89871
90366
  try {
@@ -89888,7 +90383,7 @@ var AgentSession = class _AgentSession {
89888
90383
  }
89889
90384
  throw new AcpExecutionError("ACP agent initialization failed");
89890
90385
  }
89891
- static start = async (options, recovery, getObserver, agentCommand, store, metrics, adapter, capabilities = unsupportedSessionCapabilities()) => await _AgentSession.#start(
90386
+ static start = async (options, recovery, getObserver, agentCommand, store, metrics, adapter, capabilities = unsupportedSessionCapabilities(), promptSuggestions = promptSuggestionsDisabled) => await _AgentSession.#start(
89892
90387
  options,
89893
90388
  getObserver,
89894
90389
  agentCommand,
@@ -89898,7 +90393,8 @@ var AgentSession = class _AgentSession {
89898
90393
  await runtime.initialize(options.signal, recovery);
89899
90394
  },
89900
90395
  metrics,
89901
- adapter
90396
+ adapter,
90397
+ promptSuggestions
89902
90398
  );
89903
90399
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
89904
90400
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
@@ -90248,7 +90744,12 @@ var AgentSession = class _AgentSession {
90248
90744
  try {
90249
90745
  const result = await this.#writeNativeHistory(async () => {
90250
90746
  try {
90251
- return await this.#adapter.prompt({ ...this.#target(), content: options, signal: options.signal });
90747
+ return await this.#adapter.prompt({
90748
+ ...this.#target(),
90749
+ content: options,
90750
+ ...options.suggestNextPrompt === true ? { promptSuggestionTurnId: options.commandId } : {},
90751
+ signal: options.signal
90752
+ });
90252
90753
  } finally {
90253
90754
  this.#delegableCommandId = null;
90254
90755
  }
@@ -90486,7 +90987,8 @@ var AgentSession = class _AgentSession {
90486
90987
  #sessionParams = (signal) => ({
90487
90988
  ...this.#subscriber,
90488
90989
  scope: this.#scope,
90489
- signal
90990
+ signal,
90991
+ suggestNextPrompt: this.#promptSuggestions.wanted(this.#mobiusSessionId)
90490
90992
  });
90491
90993
  createSession = (signal) => this.#adapter.createSession(this.#sessionParams(signal));
90492
90994
  openSession = (signal) => this.#adapter.openSession({ ...this.#sessionParams(signal), nativeSessionId: this.nativeSessionId() });
@@ -90636,6 +91138,8 @@ var SessionManager2 = class {
90636
91138
  #onSessionClosed;
90637
91139
  #timer;
90638
91140
  #observer;
91141
+ /** Each Session's next-prompt suggestions. They outlive the Session's Agent process. */
91142
+ promptSuggestions;
90639
91143
  constructor({
90640
91144
  observer,
90641
91145
  store,
@@ -90658,6 +91162,7 @@ var SessionManager2 = class {
90658
91162
  );
90659
91163
  this.#onSessionClosed = onSessionClosed;
90660
91164
  this.#timer = timer;
91165
+ this.promptSuggestions = new PromptSuggestions(timer);
90661
91166
  }
90662
91167
  recordLifecycleEvent = async (sessionId, event) => {
90663
91168
  const runtime = this.#executionProcesses.get(sessionId);
@@ -90747,7 +91252,8 @@ var SessionManager2 = class {
90747
91252
  this.#store,
90748
91253
  metrics,
90749
91254
  options.adapter,
90750
- capabilities
91255
+ capabilities,
91256
+ this.promptSuggestions
90751
91257
  )
90752
91258
  );
90753
91259
  });
@@ -90770,7 +91276,8 @@ var SessionManager2 = class {
90770
91276
  this.#store,
90771
91277
  metrics,
90772
91278
  options.adapter,
90773
- capabilities
91279
+ capabilities,
91280
+ this.promptSuggestions
90774
91281
  )
90775
91282
  );
90776
91283
  });
@@ -90790,7 +91297,8 @@ var SessionManager2 = class {
90790
91297
  this.#store,
90791
91298
  unmeasuredOperationMetrics,
90792
91299
  options.adapter,
90793
- capabilities
91300
+ capabilities,
91301
+ this.promptSuggestions
90794
91302
  )
90795
91303
  );
90796
91304
  try {
@@ -90846,7 +91354,8 @@ var SessionManager2 = class {
90846
91354
  this.#store,
90847
91355
  unmeasuredOperationMetrics,
90848
91356
  options.adapter,
90849
- capabilities
91357
+ capabilities,
91358
+ this.promptSuggestions
90850
91359
  )
90851
91360
  );
90852
91361
  });
@@ -91270,6 +91779,7 @@ var SessionManager2 = class {
91270
91779
  await waitForSharedOperation(completion, options.signal);
91271
91780
  });
91272
91781
  close = async () => {
91782
+ this.promptSuggestions.close();
91273
91783
  const retiring = this.#processes.stopIdleReclamation();
91274
91784
  await this.#operations.close(async () => {
91275
91785
  await retiring;
@@ -95233,6 +95743,9 @@ async function executePrompt({
95233
95743
  signal,
95234
95744
  recovery
95235
95745
  };
95746
+ if (availability.disposition !== SessionPromptDisposition.Steer) {
95747
+ sessions.promptSuggestions.want(command.sessionId, command.suggestNextPrompt === true);
95748
+ }
95236
95749
  let prepared = await sessions.prepareExecutionSession(preparation);
95237
95750
  if (command.sessionConfigurations !== void 0 && availability.disposition !== SessionPromptDisposition.Steer) {
95238
95751
  await applyCompleteSessionConfiguration(
@@ -95284,6 +95797,8 @@ async function executePrompt({
95284
95797
  });
95285
95798
  stopReason = "steered";
95286
95799
  } else {
95800
+ const suggestion2 = command.suggestNextPrompt !== true ? "not-requested" : prepared.capabilities.promptSuggestions ? "requested" : "unsupported";
95801
+ sessions.promptSuggestions.begin(command.sessionId, command.commandId, suggestion2);
95287
95802
  const result = await sessions.runPrompt({
95288
95803
  adapter,
95289
95804
  cancellationRequested,
@@ -95299,13 +95814,16 @@ async function executePrompt({
95299
95814
  resources: attachments.resources,
95300
95815
  sessionId: command.sessionId,
95301
95816
  signal,
95817
+ ...suggestion2 === "requested" ? { suggestNextPrompt: true } : {},
95302
95818
  targetCommandId: command.targetCommandId,
95303
95819
  recovery
95304
95820
  });
95305
95821
  stopReason = result.stopReason;
95822
+ sessions.promptSuggestions.finish(command.sessionId, command.commandId, stopReason);
95306
95823
  }
95307
95824
  await eventProjection.completed(command.sessionId, command.commandId, stopReason);
95308
95825
  } catch (error62) {
95826
+ sessions.promptSuggestions.finish(command.sessionId, command.commandId, null);
95309
95827
  if (signal.aborted && cancellationRequested()) {
95310
95828
  await eventProjection.completed(command.sessionId, command.commandId, "cancelled");
95311
95829
  return;
@@ -95423,6 +95941,23 @@ var sessionPromptCommand = {
95423
95941
  }
95424
95942
  };
95425
95943
 
95944
+ // src/engine/runtime/command/registry/prompt-suggestion.ts
95945
+ var sessionPromptSuggestionReadCommand = {
95946
+ kind: SESSION_PROMPT_SUGGESTION_READ_KIND,
95947
+ handle: (context, message) => {
95948
+ if (message.kind !== SESSION_PROMPT_SUGGESTION_READ_KIND) {
95949
+ throw new Error("Command kind mismatch");
95950
+ }
95951
+ send(context.socket, {
95952
+ kind: SESSION_PROMPT_SUGGESTION_READ_RESULT_KIND,
95953
+ requestId: message.requestId,
95954
+ sessionId: message.sessionId,
95955
+ suggestion: context.sessions.promptSuggestions.read(message.sessionId, message.turnId),
95956
+ turnId: message.turnId
95957
+ });
95958
+ }
95959
+ };
95960
+
95426
95961
  // src/engine/runtime/observability/environment-diagnostics.ts
95427
95962
  import { release } from "node:os";
95428
95963
  function version2(value) {
@@ -95525,6 +96060,7 @@ var runtimePingCommand = {
95525
96060
  }
95526
96061
  send(socket, {
95527
96062
  kind: RUNTIME_PONG_KIND,
96063
+ promptSuggestions: true,
95528
96064
  requestId: message.requestId,
95529
96065
  scopedFileRead: supportsScopedLocalFileRead()
95530
96066
  });
@@ -95545,6 +96081,9 @@ async function prepareSession(command, recovery, closed, config2, resolveAgent,
95545
96081
  )
95546
96082
  );
95547
96083
  const resolvedAgent = await resolveAgent(command.agentId, signal, command.sessionId);
96084
+ if (command.suggestNextPrompt !== void 0 && command.transient !== true) {
96085
+ sessions.promptSuggestions.want(command.sessionId, command.suggestNextPrompt);
96086
+ }
95548
96087
  const preparation = {
95549
96088
  additionalDirectories: resolved.additionalDirectories,
95550
96089
  ...resolvedAgent,
@@ -95934,6 +96473,7 @@ function createCommandRegistry(context) {
95934
96473
  sessionPrepareCommand,
95935
96474
  sessionConfigureCommand,
95936
96475
  sessionConfigReadCommand,
96476
+ sessionPromptSuggestionReadCommand,
95937
96477
  sessionRenameCommand,
95938
96478
  sessionRestoreCommand,
95939
96479
  permissionRespondCommand,
@@ -97096,4 +97636,4 @@ export {
97096
97636
  * MIT Licensed
97097
97637
  *)
97098
97638
  */
97099
- //# sourceMappingURL=chunk-WFQZ4ALO.js.map
97639
+ //# sourceMappingURL=chunk-NFQ5D3AF.js.map