@github/copilot-sdk 1.0.17-preview.0 → 1.0.17-preview.10

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.
@@ -127,7 +127,48 @@ function createServerRpc(connection) {
127
127
  *
128
128
  * @returns Whether the host running this runtime can run the command sandbox. The runtime checks `supported` once per process. A capability answer can change while the process runs, for example after the user installs a missing package.
129
129
  */
130
- getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {})
130
+ getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {}),
131
+ /** @experimental */
132
+ proxyCa: {
133
+ /**
134
+ * Reports whether the persistent certificate authority of the sandbox credential proxy exists, whether OS trust includes it, and whether it must be rotated. Changes nothing.
135
+ *
136
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
137
+ *
138
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
139
+ */
140
+ getStatus: async (params) => connection.sendRequest("sandbox.proxyCa.getStatus", params),
141
+ /**
142
+ * Creates the persistent certificate authority of the sandbox credential proxy if none is stored, without changing OS trust, and returns the path of its public certificate. Keeps an existing certificate authority, even one that must be rotated. Fails where OS trust is unsupported. Trust it with sandbox.proxyCa.trust: the CLI trusts only the hosts in the saved user settings, so it refuses a certificate authority that also covers hosts from sandboxConfig.
143
+ *
144
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
145
+ *
146
+ * @returns Result of creating the persistent certificate authority of the sandbox credential proxy.
147
+ */
148
+ create: async (params) => connection.sendRequest("sandbox.proxyCa.create", params),
149
+ /**
150
+ * Replaces the persistent certificate authority of the sandbox credential proxy with a new one for the current credential hosts. If OS trust included the old one, removes it and trusts the new one, which can show an OS authentication prompt. Running sandboxed tools keep the old certificate authority until they restart.
151
+ *
152
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
153
+ *
154
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
155
+ */
156
+ rotate: async (params) => connection.sendRequest("sandbox.proxyCa.rotate", params),
157
+ /**
158
+ * Adds the persistent certificate authority of the sandbox credential proxy to OS trust, so sandboxed clients that read only OS trust accept the proxy. Call create first. Refuses a certificate authority that is not constrained to the current credential hosts. Can show an OS authentication prompt.
159
+ *
160
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
161
+ *
162
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
163
+ */
164
+ trust: async (params) => connection.sendRequest("sandbox.proxyCa.trust", params),
165
+ /**
166
+ * Removes the persistent certificate authority of the sandbox credential proxy from OS trust. Keeps the stored certificate authority. Can show an OS authentication prompt. Sandboxed clients that read only OS trust then reject the proxy; clients that read the per-process certificate bundle continue to work.
167
+ *
168
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
169
+ */
170
+ remove: async () => connection.sendRequest("sandbox.proxyCa.remove", {})
171
+ }
131
172
  },
132
173
  /** @experimental */
133
174
  tools: {
@@ -625,21 +666,15 @@ function createServerRpc(connection) {
625
666
  /** @experimental */
626
667
  settings: {
627
668
  /**
628
- * Drops this runtime process's in-memory user settings cache so the next settings read observes disk.
629
- */
630
- reload: async () => connection.sendRequest("user.settings.reload", {}),
631
- /**
632
- * Lists every known user setting (settings.json overlaid with the legacy config.json, config.json wins), each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
669
+ * Lists every known user setting from settings.json, each with its effective value, its default, and whether it is at the default — so settings the user has never set still appear with their default value. Does not include repository- or enterprise-managed overrides that the runtime layers on top at session time.
633
670
  *
634
- * @returns Per-key metadata for every known user setting (settings.json overlaid with the legacy config.json, config.json wins), including settings left at their default. Excludes repository- and enterprise-managed overrides.
671
+ * @returns Per-key metadata for every known user setting in settings.json, including settings left at their default. Excludes repository- and enterprise-managed overrides.
635
672
  */
636
673
  get: async () => connection.sendRequest("user.settings.get", {}),
637
674
  /**
638
- * Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed. Returns the keys whose new value is shadowed by a legacy config.json entry (config.json wins on read), which the runtime leaves in place — such writes do not take effect until the legacy value is removed.
675
+ * Writes one or more user settings to settings.json, replacing each provided top-level key. A key whose value is null is removed.
639
676
  *
640
677
  * @param params Partial user settings to write to settings.json. Each top-level key is written individually, replacing the existing value; a key whose value is null is removed.
641
- *
642
- * @returns Outcome of writing user settings.
643
678
  */
644
679
  set: async (params) => connection.sendRequest("user.settings.set", params)
645
680
  }
@@ -939,6 +974,37 @@ function createServerRpc(connection) {
939
974
  * @returns Outcome of an agentRegistry.spawn call.
940
975
  */
941
976
  spawn: async (params) => connection.sendRequest("agentRegistry.spawn", params)
977
+ },
978
+ /** @experimental */
979
+ connectors: {
980
+ /**
981
+ * Returns feature availability.
982
+ *
983
+ * @returns Feature availability.
984
+ */
985
+ getCapabilities: async () => connection.sendRequest("connectors.getCapabilities", {}),
986
+ /**
987
+ * Returns eligible accounts.
988
+ *
989
+ * @returns Eligible accounts.
990
+ */
991
+ getAccounts: async () => connection.sendRequest("connectors.getAccounts", {}),
992
+ /**
993
+ * Lists entries for the selected account.
994
+ *
995
+ * @param params Selected account.
996
+ *
997
+ * @returns Entries for the selected account.
998
+ */
999
+ list: async (params) => connection.sendRequest("connectors.list", params),
1000
+ /**
1001
+ * Refreshes entries for the selected account.
1002
+ *
1003
+ * @param params Selected account.
1004
+ *
1005
+ * @returns Entries for the selected account.
1006
+ */
1007
+ refresh: async (params) => connection.sendRequest("connectors.refresh", params)
942
1008
  }
943
1009
  };
944
1010
  }
@@ -994,6 +1060,133 @@ function createInternalServerRpc(connection) {
994
1060
  */
995
1061
  connect: async (params) => connection.sendRequest("connect", params),
996
1062
  /** @experimental */
1063
+ agents: {
1064
+ /**
1065
+ * Lists the agents this runtime ships, by name. A consumer separating shipped agents from ones the user or a plugin authored should compare against these names rather than against `AgentInfo.source`: an authored agent may carry the `builtin` source while not being one of these, and the runtime treats the two as separate questions. `disableableNames` is the subset a user may turn off, which a client needs to decide whether to offer a toggle. `yamlBasedNames` is the subset backed by a shipped YAML definition, which a client needs before asking the runtime to load one.
1066
+ *
1067
+ * @returns The agents this runtime ships, named so a consumer can tell them apart from authored ones.
1068
+ */
1069
+ getBuiltins: async () => connection.sendRequest("agents.getBuiltins", {}),
1070
+ /**
1071
+ * Lists the shipped agents a client should offer right now, filtered by the feature flags it passes. `getBuiltins` names every agent the runtime knows about; some of those are gated, so a client rendering a picker wants this narrower list together with the description to show beside each name.
1072
+ *
1073
+ * @param params The feature flags to evaluate shipped agents against.
1074
+ *
1075
+ * @returns The shipped agents available under the requested flags.
1076
+ */
1077
+ getAvailableBuiltins: async (params) => connection.sendRequest("agents.getAvailableBuiltins", params),
1078
+ /**
1079
+ * Loads one shipped agent's YAML definition, for a client that needs what the agent declares rather than only its name. `getBuiltins` reports which names have a definition to load: a name outside its `yamlBasedNames` is special-cased in code and has none. The definition crosses as its own JSON rather than as contract-typed fields, because the runtime parses it with the agent schema's tolerant shape and re-typing it here would drop the keys that shape accepts and this one does not. The projected `__nativeCustomAgent` view the runtime derives is included, so a caller reading the declared model and a caller rendering the agent see the same definition.
1080
+ *
1081
+ * @param params The shipped agent whose definition to load.
1082
+ *
1083
+ * @returns One shipped agent's definition.
1084
+ */
1085
+ getBuiltinDefinition: async (params) => connection.sendRequest("agents.getBuiltinDefinition", params),
1086
+ /**
1087
+ * Projects one shipped agent the way a picker lists it, reading only the metadata at the head of the definition file and stopping before the prompt body. `getBuiltinDefinition` answers the whole definition instead, so a client listing every shipped agent should prefer this one: the cost of a listing grows with the number of agents, and the prompt body is the part a listing never shows. The two also differ in shape. This returns the projected custom agent on its own, whereas `getBuiltinDefinition` returns the authored definition with that projection nested under `__nativeCustomAgent`.
1088
+ *
1089
+ * @param params The shipped agent whose listing entry to load.
1090
+ *
1091
+ * @returns One shipped agent, projected for a listing.
1092
+ */
1093
+ getBuiltinListingDefinition: async (params) => connection.sendRequest("agents.getBuiltinListingDefinition", params),
1094
+ /**
1095
+ * Resolves the model a custom agent asks for against the models actually available, and answers both the model to switch to and the warning a user should see when the agent's preference cannot be met. A custom agent may name several acceptable models in preference order, so the decision is a match rather than a lookup, and an agent whose preference is unavailable is a normal outcome that produces a warning rather than an error. A host must call this rather than pick the first available name itself, because the preference order and the wording of the warning are what keep one installation's agent selection the same as another's.
1096
+ *
1097
+ * @param params The models a custom agent asks for, and the models actually available.
1098
+ *
1099
+ * @returns The model to switch to, and the warning to show when the agent's preference could not be met.
1100
+ */
1101
+ customAgentInitialModelDecision: async (params) => connection.sendRequest("agents.customAgentInitialModelDecision", params)
1102
+ },
1103
+ /** @experimental */
1104
+ globalState: {
1105
+ /**
1106
+ * Reads the host's machine-wide state: which plugins are installed and the one-off flags and timestamps that record what the user has already been shown or migrated. This is the state that outlives a single session and a single workspace, so a host reads it to decide whether to run a first-launch step, offer an onboarding prompt, or skip one it has already completed. The stored credentials are deliberately not part of this result; a caller that needs an authenticated identity asks the account methods for it instead. Reading is non-destructive and every field is optional, because a fresh install has recorded nothing yet.
1107
+ *
1108
+ * @returns The host's machine-wide state. Every field is optional because a fresh install has recorded nothing yet, so a reader must treat an absent field as `not yet`, never as a negative answer. Stored credentials are deliberately absent from this shape.
1109
+ */
1110
+ load: async () => connection.sendRequest("globalState.load", {}),
1111
+ /**
1112
+ * Reads the host's machine-wide state exactly as `globalState.load` does, but from a caller-supplied configuration directory instead of the one the server resolved for itself. Use this when a consumer scopes a session to its own Copilot home — the SDK's per-session `configDir` override — so the state read matches the directory that session actually uses. An absent or empty `configDir` resolves the server's own home, making this identical to `globalState.load`. The stored credentials are omitted here for the same reason they are omitted from `globalState.load`: a caller that needs an authenticated identity asks the account methods instead, so pointing this at another directory cannot be used to read the credentials kept in it.
1113
+ *
1114
+ * @param params Selects the configuration directory whose machine-wide state to read.
1115
+ *
1116
+ * @returns The host's machine-wide state. Every field is optional because a fresh install has recorded nothing yet, so a reader must treat an absent field as `not yet`, never as a negative answer. Stored credentials are deliberately absent from this shape.
1117
+ */
1118
+ loadForConfigDir: async (params) => connection.sendRequest("globalState.loadForConfigDir", params),
1119
+ /**
1120
+ * Records one top-level key in the host's machine-wide state, the counterpart to `globalState.load`. A host calls this to remember that it has shown an onboarding step, asked a one-off question, or completed a migration, so the next run can skip it. Only the named key is replaced and the rest of the document is preserved, which lets two writers record different flags without overwriting each other; passing no value removes the key instead. Only the keys a host records itself are writable: `appInstallNudgeResponded`, `appTipShown`, `askedSetupTerminals`, `autoFeedbackLastPromptedAt`, `firstLaunchAt`, `recentModelIds`, `sandboxCredentialProxyCaDeclined` and `sandboxOnboardingShown`. Every other key is refused, including `installedPlugins`, the stored credentials, `trustedFolders`, the staff flags and the signed-in accounts. Plugin enablement must use the plugin APIs, which apply repository and managed-policy checks.
1121
+ *
1122
+ * @param params A single top-level key to record in the host's machine-wide state. The write replaces only that key and leaves the rest of the document untouched, so two writers recording different one-off flags do not overwrite each other. The stored credential keys cannot be written through this method.
1123
+ */
1124
+ writeKey: async (params) => connection.sendRequest("globalState.writeKey", params)
1125
+ },
1126
+ /** @experimental */
1127
+ gitHubRepository: {
1128
+ /**
1129
+ * Resolves the GitHub repository that owns a working-tree path by reading the selected git remote configured for it, preferring `origin`. Returns a null `repository` when the path is inside a git working tree but that selected remote does not resolve to a GitHub host. Fails when the path is not inside a git working tree at all, so a caller can tell 'not a repository' apart from 'a repository with no GitHub remote'.
1130
+ *
1131
+ * @param params Working-tree path whose owning GitHub repository should be resolved.
1132
+ *
1133
+ * @returns The GitHub repository that owns the requested path, when the selected remote (`origin`, else the first) is on a GitHub host.
1134
+ */
1135
+ atPath: async (params) => connection.sendRequest("gitHubRepository.atPath", params)
1136
+ },
1137
+ /** @experimental */
1138
+ gitHubOwners: {
1139
+ /**
1140
+ * Registers a cancellable owner listing and returns its request id. Separate from `gitHubOwners.list` so the id exists before the listing starts: a caller that abandons the listing the moment it begins would otherwise have nothing to name in `gitHubOwners.cancel`. The id serves one listing only. Long-abandoned unused ids can be released by later allocations.
1141
+ *
1142
+ * @returns A freshly registered request id. Registering it before the listing starts is what lets a cancel that races the request still find the owner listing slot. The id serves one listing only. Long-abandoned unused ids can be released by later allocations.
1143
+ */
1144
+ nextRequestId: async () => connection.sendRequest("gitHubOwners.nextRequestId", {}),
1145
+ /**
1146
+ * Lists the logins the authenticated user may act as — their own account first, then the organizations they belong to — by asking the GitHub API under the supplied credential. No credential travels in the request: `authInfo` selects one the runtime already holds, and the runtime resolves the token and the GitHub host from it. A failure the caller should render arrives as `message`; one it should raise arrives as `throwError`.
1147
+ *
1148
+ * @param params Credential to list owners under, and the request id that makes the listing cancellable.
1149
+ *
1150
+ * @returns Outcome of an owner listing. Exactly one of `owners` and `message` is present, except that `throwError` reports a failure the caller is expected to raise rather than render.
1151
+ */
1152
+ list: async (params) => connection.sendRequest("gitHubOwners.list", params),
1153
+ /**
1154
+ * Abandons an owner listing started with the given request id. Answers `canceled: true` while a listing with that id is running. Answers `canceled: false` when the id was never registered, was registered but not used, was released after being abandoned, or its listing has ended. Canceling an unused id releases it, and a later `list` with that id is refused. The cancel acts only on owner listings and never reaches another request of the host.
1155
+ *
1156
+ * @param params The owner listing to abandon.
1157
+ *
1158
+ * @returns Whether the id named a running owner listing.
1159
+ */
1160
+ cancel: async (params) => connection.sendRequest("gitHubOwners.cancel", params)
1161
+ },
1162
+ /** @experimental */
1163
+ git: {
1164
+ /**
1165
+ * Reads the remote that the branch checked out in a working tree tracks, as `branch.<name>.remote` configures it. Reports `origin` rather than failing whenever there is no tracking configuration to read — on a detached HEAD, on a branch with no upstream, or when git itself fails — because a caller asking which remote to talk to needs an answer it can act on, not an error. Marked internal because it exists to carry a CLI call site off the napi boundary onto the SDK contract; it is migration plumbing, not a surface consumers are meant to depend on.
1166
+ *
1167
+ * @param params Working-tree path a git query applies to.
1168
+ *
1169
+ * @returns The remote the checked-out branch tracks.
1170
+ */
1171
+ currentBranchRemote: async (params) => connection.sendRequest("git.currentBranchRemote", params),
1172
+ /**
1173
+ * Collects the repository context of a working directory in one call: working tree root, repository identifier and host, current branch, and the HEAD and base commits. Every repository field is omitted when the path is not inside a git working tree, and the requested path is echoed back as `cwd`. The answer is the same `SessionWorkingDirectoryContext` that `session.metadata.recordContextChange` accepts, so a caller polling for a context change can forward the result unchanged. Marked internal because it exists to carry a CLI call site off the napi boundary onto the SDK contract; it is migration plumbing, not a surface consumers are meant to depend on. It can become public once an SDK consumer needs to derive session context from a directory itself.
1174
+ *
1175
+ * @param params Working-tree path a git query applies to.
1176
+ *
1177
+ * @returns Updated working directory and git context. Emitted as the new payload of `session.context_changed`.
1178
+ */
1179
+ workingDirectoryContext: async (params) => connection.sendRequest("git.workingDirectoryContext", params),
1180
+ /**
1181
+ * Lists the GitHub repositories a working tree's remotes point at, one entry per distinct repository, so a caller can resolve a base and head repository without parsing remote URLs itself. When several remotes name the same repository, only the first is listed, and the entry keeps that remote name. Remotes pointing at no GitHub host are left out, so an empty list means the tree reaches GitHub through no remote. Failing to read the remotes is reported as an error rather than as an empty list, because the two mean different things to a caller. Marked internal because it exists to carry a CLI call site off the napi boundary onto the SDK contract; it is migration plumbing, not a surface consumers are meant to depend on.
1182
+ *
1183
+ * @param params Git working tree whose GitHub remotes should be listed.
1184
+ *
1185
+ * @returns The GitHub repositories a working tree's remotes point at.
1186
+ */
1187
+ reposFromRemotes: async (params) => connection.sendRequest("git.reposFromRemotes", params)
1188
+ },
1189
+ /** @experimental */
997
1190
  sessions: {
998
1191
  /**
999
1192
  * Reads lightweight persisted metadata for one local session without opening it.
@@ -1033,6 +1226,30 @@ function createInternalServerRpc(connection) {
1033
1226
  * @param params Session ID to delete from disk.
1034
1227
  */
1035
1228
  delete: async (params) => connection.sendRequest("sessions.delete", params),
1229
+ /**
1230
+ * Creates the workspace record for a session that has not been opened yet. A host that hands a session off to another application — writing the record and then launching that application against the session ID — needs the record on disk before any session exists to carry it, which the session-scoped workspace methods cannot do. Replaces any existing record and resets the checkpoint index. When writing to the local filesystem, a stored `fork_count` survives on disk. Returns the record it built, so a surviving stored `fork_count` can differ from the answer.
1231
+ *
1232
+ * @param params Identity, state location and starting context for a workspace record.
1233
+ *
1234
+ * @returns The workspace record that was written.
1235
+ */
1236
+ createWorkspace: async (params) => connection.sendRequest("sessions.createWorkspace", params),
1237
+ /**
1238
+ * Reads a session's workspace record straight from disk, without opening the session. Resuming by session ID has to know where the session lives before it can connect, so the lookup cannot come from the session-scoped workspace methods, which resolve their location from a live session's context. Returns no record when the file is absent.
1239
+ *
1240
+ * @param params Where the session's state lives, as a root directory and the session ID under it.
1241
+ *
1242
+ * @returns The workspace record on disk, omitted when the session has none.
1243
+ */
1244
+ loadWorkspace: async (params) => connection.sendRequest("sessions.loadWorkspace", params),
1245
+ /**
1246
+ * Merges fields into a session's workspace record on disk, creating the record when it is absent. The counterpart to `sessions.loadWorkspace`, for the same before-the-session-exists case. It preserves stored workspace-schema fields the request does not supply, does not preserve stored keys outside the workspace schema, and never replaces a stored `fork_count`.
1247
+ *
1248
+ * @param params Where the session's state lives, plus workspace-schema fields to merge into its workspace record. Stored keys outside the schema are not preserved, and a stored `fork_count` is never replaced.
1249
+ *
1250
+ * @returns The merge completed. The record carries the supplied workspace-schema fields, but a stored `fork_count` stays.
1251
+ */
1252
+ updateWorkspaceFields: async (params) => connection.sendRequest("sessions.updateWorkspaceFields", params),
1036
1253
  /**
1037
1254
  * Gets the dynamic-context board entry count associated with a session, when available. Internal: this exists solely so CLI telemetry events (`rem_spawn_gate`, `rem_consolidation_complete`) can pair START / END board counts around the detached rem-agent spawn. "Dynamic context board" is a runtime-internal concept that is not part of the public SDK contract; the long-term plan is to relocate the telemetry emission into the runtime so this method can be deleted entirely.
1038
1255
  *
@@ -1047,22 +1264,55 @@ function createInternalServerRpc(connection) {
1047
1264
  * @param params Params to attach or detach an in-process ExtensionController delegate.
1048
1265
  */
1049
1266
  configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
1050
- },
1051
- /** @experimental */
1052
- accounts: {
1053
- /**
1054
- * Acquire a Microsoft Entra access token through the runtime's OneAuth broker. Account-scoped because it uses the same native broker as the account stack: a trusted host application mints a scoped Entra token for its own use, most notably to authenticate to a remote MCP server whose authorization server is Entra ID (in place of the generic browser-OAuth flow).
1055
- *
1056
- * @param params OneAuth token request supplied by a trusted host application.
1057
- *
1058
- * @returns Result of a OneAuth token acquisition.
1059
- */
1060
- acquireEntraToken: async (params) => connection.sendRequest("accounts.acquireEntraToken", params)
1061
1267
  }
1062
1268
  };
1063
1269
  }
1064
1270
  function createSessionRpc(connection, sessionId) {
1065
1271
  return {
1272
+ /** @experimental */
1273
+ providers: {
1274
+ /**
1275
+ * Returns adapter definitions and supported operations in this session's effective provider catalog, without running discovery. Does not list provider instances or select inference models.
1276
+ *
1277
+ * @returns Normalized model-provider adapter definitions available to the session, not discovered instances.
1278
+ */
1279
+ getCatalog: async () => connection.sendRequest("session.providers.getCatalog", { sessionId }),
1280
+ /**
1281
+ * Discovers reachable instances using an adapter from this session's effective provider catalog and provider-specific discovery input.
1282
+ *
1283
+ * @param params Provider discovery parameters.
1284
+ *
1285
+ * @returns Provider instances found by a discovery operation.
1286
+ */
1287
+ discover: async (params) => connection.sendRequest("session.providers.discover", { ...params, sessionId }),
1288
+ /**
1289
+ * Gets current health and version information for a discovered model-provider instance.
1290
+ *
1291
+ * @param params Provider status request parameters.
1292
+ *
1293
+ * @returns Current health information for a provider instance.
1294
+ */
1295
+ getStatus: async (params) => connection.sendRequest("session.providers.getStatus", { ...params, sessionId }),
1296
+ /** @experimental */
1297
+ models: {
1298
+ /**
1299
+ * Lists models installed or otherwise available from a discovered model-provider instance.
1300
+ *
1301
+ * @param params Provider model inventory request parameters.
1302
+ *
1303
+ * @returns Models offered for agent conversations by one provider instance. Adapters exclude known-incompatible models, but retain candidates with unknown capabilities. Listing does not guarantee compatibility.
1304
+ */
1305
+ list: async (params) => connection.sendRequest("session.providers.models.list", { ...params, sessionId }),
1306
+ /**
1307
+ * Translates a discovered model into the provider and model configuration needed to use it, and reports whether each is already registered in this session. Prepares only: it registers nothing, writes nothing, and performs no provider requests.
1308
+ *
1309
+ * @param params A discovered instance and one of its models to translate into provider configuration. Pass back the instance and model as returned by `session.providers.discover` and `session.providers.models.list`.
1310
+ *
1311
+ * @returns Provider configuration prepared from a discovered model. Preparing a plan changes nothing: it neither registers the model with the session nor writes durable configuration. To apply it, pass `provider` and `model` to `session.provider.add`, omitting whichever the dispositions report as already configured.
1312
+ */
1313
+ prepareConfiguration: async (params) => connection.sendRequest("session.providers.models.prepareConfiguration", { ...params, sessionId })
1314
+ }
1315
+ },
1066
1316
  /**
1067
1317
  * Suspends the session while preserving persisted state for later resume.
1068
1318
  *
@@ -1078,7 +1328,7 @@ function createSessionRpc(connection, sessionId) {
1078
1328
  *
1079
1329
  * @experimental
1080
1330
  */
1081
- send: async (params) => connection.sendRequest("session.send", { sessionId, ...params }),
1331
+ send: async (params) => connection.sendRequest("session.send", { ...params, sessionId }),
1082
1332
  /**
1083
1333
  * Sends zero or more user messages to the session in a single turn and returns their message IDs. All provided messages are appended to the conversation in order, then exactly one agent turn runs over the resulting history. When the list is empty, one turn runs over the existing history with no new user message. Remote-backed (Mission Control) sessions do not support this method and will return an error.
1084
1334
  *
@@ -1088,7 +1338,7 @@ function createSessionRpc(connection, sessionId) {
1088
1338
  *
1089
1339
  * @experimental
1090
1340
  */
1091
- sendMessages: async (params) => connection.sendRequest("session.sendMessages", { sessionId, ...params }),
1341
+ sendMessages: async (params) => connection.sendRequest("session.sendMessages", { ...params, sessionId }),
1092
1342
  /** @experimental */
1093
1343
  sandbox: {
1094
1344
  /**
@@ -1104,7 +1354,7 @@ function createSessionRpc(connection, sessionId) {
1104
1354
  *
1105
1355
  * @returns Result of attempting to disable sandboxing for the current session.
1106
1356
  */
1107
- disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params }),
1357
+ disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { ...params, sessionId }),
1108
1358
  /**
1109
1359
  * Adds the path offered by a pending sandbox escalation permission request's sandboxPathGrant to the session's sandbox policy and approves the request, so the blocked operation re-runs inside the sandbox rather than outside it. The request is rejected unless the exact request is still pending, carries a sandboxPathGrant, and the grant still takes effect under the current managed policy. Does not persist the path; hosts that store sandbox settings save it themselves.
1110
1360
  *
@@ -1112,7 +1362,7 @@ function createSessionRpc(connection, sessionId) {
1112
1362
  *
1113
1363
  * @returns Result of accepting a sandbox path grant.
1114
1364
  */
1115
- grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { sessionId, ...params })
1365
+ grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { ...params, sessionId })
1116
1366
  },
1117
1367
  /**
1118
1368
  * Aborts the current agent turn.
@@ -1123,7 +1373,7 @@ function createSessionRpc(connection, sessionId) {
1123
1373
  *
1124
1374
  * @experimental
1125
1375
  */
1126
- abort: async (params) => connection.sendRequest("session.abort", { sessionId, ...params }),
1376
+ abort: async (params) => connection.sendRequest("session.abort", { ...params, sessionId }),
1127
1377
  /**
1128
1378
  * Interrupts the current main agent turn while leaving running background work (subagents, sidekicks, and promoted attached shells) alive. No-op when the main loop is not processing.
1129
1379
  *
@@ -1133,7 +1383,7 @@ function createSessionRpc(connection, sessionId) {
1133
1383
  *
1134
1384
  * @experimental
1135
1385
  */
1136
- interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { sessionId, ...params }),
1386
+ interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { ...params, sessionId }),
1137
1387
  /**
1138
1388
  * Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
1139
1389
  *
@@ -1149,7 +1399,7 @@ function createSessionRpc(connection, sessionId) {
1149
1399
  *
1150
1400
  * @experimental
1151
1401
  */
1152
- shutdown: async (params) => connection.sendRequest("session.shutdown", { sessionId, ...params }),
1402
+ shutdown: async (params) => connection.sendRequest("session.shutdown", { ...params, sessionId }),
1153
1403
  /** @experimental */
1154
1404
  gitHubAuth: {
1155
1405
  /**
@@ -1165,7 +1415,7 @@ function createSessionRpc(connection, sessionId) {
1165
1415
  *
1166
1416
  * @returns Indicates whether the credential update succeeded.
1167
1417
  */
1168
- setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { sessionId, ...params })
1418
+ setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { ...params, sessionId })
1169
1419
  },
1170
1420
  /** @experimental */
1171
1421
  accounts: {
@@ -1176,7 +1426,7 @@ function createSessionRpc(connection, sessionId) {
1176
1426
  *
1177
1427
  * @returns The enumerated collection, keyed by the same selector as the query.
1178
1428
  */
1179
- enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { sessionId, ...params }),
1429
+ enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { ...params, sessionId }),
1180
1430
  /**
1181
1431
  * Read one typed accounts datum: the active account, a neutral status summary, or the last authentication errors.
1182
1432
  *
@@ -1184,7 +1434,7 @@ function createSessionRpc(connection, sessionId) {
1184
1434
  *
1185
1435
  * @returns The read result, keyed by the same selector as the query.
1186
1436
  */
1187
- get: async (params) => connection.sendRequest("session.accounts.get", { sessionId, ...params }),
1437
+ get: async (params) => connection.sendRequest("session.accounts.get", { ...params, sessionId }),
1188
1438
  /**
1189
1439
  * Apply one non-interactive accounts mutation: switch the active account, log an account out, or set credentials from a token.
1190
1440
  *
@@ -1192,7 +1442,7 @@ function createSessionRpc(connection, sessionId) {
1192
1442
  *
1193
1443
  * @returns Result of a non-interactive accounts mutation.
1194
1444
  */
1195
- set: async (params) => connection.sendRequest("session.accounts.set", { sessionId, ...params }),
1445
+ set: async (params) => connection.sendRequest("session.accounts.set", { ...params, sessionId }),
1196
1446
  /** @experimental */
1197
1447
  login: {
1198
1448
  /**
@@ -1202,7 +1452,7 @@ function createSessionRpc(connection, sessionId) {
1202
1452
  *
1203
1453
  * @returns A started login flow: its opaque id and first step.
1204
1454
  */
1205
- begin: async (params) => connection.sendRequest("session.accounts.login.begin", { sessionId, ...params }),
1455
+ begin: async (params) => connection.sendRequest("session.accounts.login.begin", { ...params, sessionId }),
1206
1456
  /**
1207
1457
  * Advance an in-flight login flow, optionally fulfilling an input-required step, and return the next step.
1208
1458
  *
@@ -1210,13 +1460,13 @@ function createSessionRpc(connection, sessionId) {
1210
1460
  *
1211
1461
  * @returns One step in an interactive login flow. The consumer acts on the step and calls advance to proceed. Browser-open is encoded as two distinct steps by design: `open-url` is CONSUMER-driven (the provider surfaces the authorize URL and the consumer opens it — github.com/GHEC web), while `needs-interaction` is PROVIDER-driven (the provider opens the browser or broker UI itself and does not surface a URL — Entra).
1212
1462
  */
1213
- advance: async (params) => connection.sendRequest("session.accounts.login.advance", { sessionId, ...params }),
1463
+ advance: async (params) => connection.sendRequest("session.accounts.login.advance", { ...params, sessionId }),
1214
1464
  /**
1215
1465
  * Cancel an in-flight login flow and release its resources.
1216
1466
  *
1217
1467
  * @param params Cancel an in-flight login flow.
1218
1468
  */
1219
- cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { sessionId, ...params })
1469
+ cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { ...params, sessionId })
1220
1470
  }
1221
1471
  },
1222
1472
  /** @experimental */
@@ -1228,7 +1478,7 @@ function createSessionRpc(connection, sessionId) {
1228
1478
  *
1229
1479
  * @returns Result of collecting a session debug bundle.
1230
1480
  */
1231
- collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
1481
+ collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { ...params, sessionId })
1232
1482
  },
1233
1483
  /** @experimental */
1234
1484
  canvas: {
@@ -1251,13 +1501,13 @@ function createSessionRpc(connection, sessionId) {
1251
1501
  *
1252
1502
  * @returns Open canvas instance snapshot.
1253
1503
  */
1254
- open: async (params) => connection.sendRequest("session.canvas.open", { sessionId, ...params }),
1504
+ open: async (params) => connection.sendRequest("session.canvas.open", { ...params, sessionId }),
1255
1505
  /**
1256
1506
  * Closes an open canvas instance.
1257
1507
  *
1258
1508
  * @param params Canvas close parameters.
1259
1509
  */
1260
- close: async (params) => connection.sendRequest("session.canvas.close", { sessionId, ...params }),
1510
+ close: async (params) => connection.sendRequest("session.canvas.close", { ...params, sessionId }),
1261
1511
  /** @experimental */
1262
1512
  action: {
1263
1513
  /**
@@ -1267,7 +1517,7 @@ function createSessionRpc(connection, sessionId) {
1267
1517
  *
1268
1518
  * @returns Canvas action invocation result.
1269
1519
  */
1270
- invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { sessionId, ...params })
1520
+ invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { ...params, sessionId })
1271
1521
  }
1272
1522
  },
1273
1523
  /** @experimental */
@@ -1279,7 +1529,7 @@ function createSessionRpc(connection, sessionId) {
1279
1529
  *
1280
1530
  * @returns Complete current or terminal workflow run envelope.
1281
1531
  */
1282
- run: async (params) => connection.sendRequest("session.workflow.run", { sessionId, ...params }),
1532
+ run: async (params) => connection.sendRequest("session.workflow.run", { ...params, sessionId }),
1283
1533
  /**
1284
1534
  * Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
1285
1535
  *
@@ -1287,7 +1537,7 @@ function createSessionRpc(connection, sessionId) {
1287
1537
  *
1288
1538
  * @returns Resolved persisted workflow identity and resumed run envelope.
1289
1539
  */
1290
- resume: async (params) => connection.sendRequest("session.workflow.resume", { sessionId, ...params }),
1540
+ resume: async (params) => connection.sendRequest("session.workflow.resume", { ...params, sessionId }),
1291
1541
  /**
1292
1542
  * Gets the current or settled envelope for a dynamic workflow run.
1293
1543
  *
@@ -1295,7 +1545,7 @@ function createSessionRpc(connection, sessionId) {
1295
1545
  *
1296
1546
  * @returns Complete current or terminal workflow run envelope.
1297
1547
  */
1298
- getRun: async (params) => connection.sendRequest("session.workflow.getRun", { sessionId, ...params }),
1548
+ getRun: async (params) => connection.sendRequest("session.workflow.getRun", { ...params, sessionId }),
1299
1549
  /**
1300
1550
  * Lists durable dynamic workflow runs for this session in creation order.
1301
1551
  *
@@ -1303,7 +1553,7 @@ function createSessionRpc(connection, sessionId) {
1303
1553
  *
1304
1554
  * @returns A page of workflow runs in durable creation order.
1305
1555
  */
1306
- listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { sessionId, ...params }),
1556
+ listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { ...params, sessionId }),
1307
1557
  /**
1308
1558
  * Gets durable and live observability detail for one dynamic workflow run.
1309
1559
  *
@@ -1311,7 +1561,7 @@ function createSessionRpc(connection, sessionId) {
1311
1561
  *
1312
1562
  * @returns Full workflow run observability detail.
1313
1563
  */
1314
- getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { sessionId, ...params }),
1564
+ getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { ...params, sessionId }),
1315
1565
  /**
1316
1566
  * Pages durable progress for one dynamic workflow run.
1317
1567
  *
@@ -1319,7 +1569,7 @@ function createSessionRpc(connection, sessionId) {
1319
1569
  *
1320
1570
  * @returns A bidirectional page of workflow progress.
1321
1571
  */
1322
- getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { sessionId, ...params }),
1572
+ getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { ...params, sessionId }),
1323
1573
  /**
1324
1574
  * Requests cancellation of a dynamic workflow run and returns its run envelope.
1325
1575
  *
@@ -1327,7 +1577,7 @@ function createSessionRpc(connection, sessionId) {
1327
1577
  *
1328
1578
  * @returns Complete current or terminal workflow run envelope.
1329
1579
  */
1330
- cancel: async (params) => connection.sendRequest("session.workflow.cancel", { sessionId, ...params }),
1580
+ cancel: async (params) => connection.sendRequest("session.workflow.cancel", { ...params, sessionId }),
1331
1581
  /**
1332
1582
  * Pauses a running dynamic workflow and returns its settled run envelope.
1333
1583
  *
@@ -1335,7 +1585,7 @@ function createSessionRpc(connection, sessionId) {
1335
1585
  *
1336
1586
  * @returns Complete current or terminal workflow run envelope.
1337
1587
  */
1338
- pause: async (params) => connection.sendRequest("session.workflow.pause", { sessionId, ...params }),
1588
+ pause: async (params) => connection.sendRequest("session.workflow.pause", { ...params, sessionId }),
1339
1589
  /**
1340
1590
  * Records a batch of ordered dynamic workflow progress lines.
1341
1591
  *
@@ -1343,7 +1593,7 @@ function createSessionRpc(connection, sessionId) {
1343
1593
  *
1344
1594
  * @returns Acknowledgement that a workflow request was accepted.
1345
1595
  */
1346
- log: async (params) => connection.sendRequest("session.workflow.log", { sessionId, ...params }),
1596
+ log: async (params) => connection.sendRequest("session.workflow.log", { ...params, sessionId }),
1347
1597
  /**
1348
1598
  * Runs one dynamic-workflow-scoped subagent and returns its result.
1349
1599
  *
@@ -1351,7 +1601,7 @@ function createSessionRpc(connection, sessionId) {
1351
1601
  *
1352
1602
  * @returns Result of one workflow-scoped subagent call.
1353
1603
  */
1354
- agent: async (params) => connection.sendRequest("session.workflow.agent", { sessionId, ...params }),
1604
+ agent: async (params) => connection.sendRequest("session.workflow.agent", { ...params, sessionId }),
1355
1605
  /** @experimental */
1356
1606
  journal: {
1357
1607
  /**
@@ -1361,7 +1611,7 @@ function createSessionRpc(connection, sessionId) {
1361
1611
  *
1362
1612
  * @returns Result of reading a workflow journal entry.
1363
1613
  */
1364
- get: async (params) => connection.sendRequest("session.workflow.journal.get", { sessionId, ...params }),
1614
+ get: async (params) => connection.sendRequest("session.workflow.journal.get", { ...params, sessionId }),
1365
1615
  /**
1366
1616
  * Stores a memoized dynamic workflow journal entry.
1367
1617
  *
@@ -1369,7 +1619,7 @@ function createSessionRpc(connection, sessionId) {
1369
1619
  *
1370
1620
  * @returns Acknowledgement that a workflow request was accepted.
1371
1621
  */
1372
- put: async (params) => connection.sendRequest("session.workflow.journal.put", { sessionId, ...params })
1622
+ put: async (params) => connection.sendRequest("session.workflow.journal.put", { ...params, sessionId })
1373
1623
  }
1374
1624
  },
1375
1625
  /** @experimental */
@@ -1387,7 +1637,7 @@ function createSessionRpc(connection, sessionId) {
1387
1637
  *
1388
1638
  * @returns The model identifier active on the session after the switch.
1389
1639
  */
1390
- switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params }),
1640
+ switchTo: async (params) => connection.sendRequest("session.model.switchTo", { ...params, sessionId }),
1391
1641
  /**
1392
1642
  * Requests an Auto preference change without changing the session's selected model. The latest unclaimed request wins; the runtime commits it only after a later prompt using the `auto` model mints a usable model and token pair. A `pending` response confirms that the request was accepted, not that it committed. Observe eventual success through `session.model_change`, failure through the ephemeral `session.auto_tier_switch_failed` event, or current unclaimed state through `session.model.getCurrent`.
1393
1643
  *
@@ -1395,7 +1645,7 @@ function createSessionRpc(connection, sessionId) {
1395
1645
  *
1396
1646
  * @returns Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
1397
1647
  */
1398
- switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { sessionId, ...params }),
1648
+ switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { ...params, sessionId }),
1399
1649
  /**
1400
1650
  * Replaces or clears the host-supplied model allowlist for a running session.
1401
1651
  *
@@ -1403,7 +1653,7 @@ function createSessionRpc(connection, sessionId) {
1403
1653
  *
1404
1654
  * @returns The applied host allowlist and effective session model policy after intersection.
1405
1655
  */
1406
- setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { sessionId, ...params }),
1656
+ setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { ...params, sessionId }),
1407
1657
  /**
1408
1658
  * Updates the session's reasoning effort without changing the selected model.
1409
1659
  *
@@ -1411,7 +1661,7 @@ function createSessionRpc(connection, sessionId) {
1411
1661
  *
1412
1662
  * @returns Update the session's reasoning effort without changing the selected model. Use `switchTo` instead when you also need to change the model. The runtime stores the effort on the session and applies it to subsequent turns.
1413
1663
  */
1414
- setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params }),
1664
+ setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { ...params, sessionId }),
1415
1665
  /**
1416
1666
  * Lists models available to this session using its own auth and integration context. Connected hosts (CLI TUI, GitHub App) should call this through the session client so remote sessions return the remote CLI's available models rather than the caller's.
1417
1667
  *
@@ -1419,7 +1669,7 @@ function createSessionRpc(connection, sessionId) {
1419
1669
  *
1420
1670
  * @returns The list of models available to this session.
1421
1671
  */
1422
- list: async (params) => connection.sendRequest("session.model.list", { sessionId, ...params })
1672
+ list: async (params) => connection.sendRequest("session.model.list", { ...params, sessionId })
1423
1673
  },
1424
1674
  /** @experimental */
1425
1675
  mode: {
@@ -1436,7 +1686,7 @@ function createSessionRpc(connection, sessionId) {
1436
1686
  *
1437
1687
  * @returns Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
1438
1688
  */
1439
- set: async (params) => connection.sendRequest("session.mode.set", { sessionId, ...params })
1689
+ set: async (params) => connection.sendRequest("session.mode.set", { ...params, sessionId })
1440
1690
  },
1441
1691
  /** @experimental */
1442
1692
  name: {
@@ -1451,7 +1701,7 @@ function createSessionRpc(connection, sessionId) {
1451
1701
  *
1452
1702
  * @param params New friendly name to apply to the session.
1453
1703
  */
1454
- set: async (params) => connection.sendRequest("session.name.set", { sessionId, ...params }),
1704
+ set: async (params) => connection.sendRequest("session.name.set", { ...params, sessionId }),
1455
1705
  /**
1456
1706
  * Persists an auto-generated session summary as the session's name when no user-set name exists.
1457
1707
  *
@@ -1459,7 +1709,7 @@ function createSessionRpc(connection, sessionId) {
1459
1709
  *
1460
1710
  * @returns Indicates whether the auto-generated summary was applied as the session's name.
1461
1711
  */
1462
- setAuto: async (params) => connection.sendRequest("session.name.setAuto", { sessionId, ...params })
1712
+ setAuto: async (params) => connection.sendRequest("session.name.setAuto", { ...params, sessionId })
1463
1713
  },
1464
1714
  /** @experimental */
1465
1715
  plan: {
@@ -1474,7 +1724,7 @@ function createSessionRpc(connection, sessionId) {
1474
1724
  *
1475
1725
  * @param params Replacement contents to write to the session plan file.
1476
1726
  */
1477
- update: async (params) => connection.sendRequest("session.plan.update", { sessionId, ...params }),
1727
+ update: async (params) => connection.sendRequest("session.plan.update", { ...params, sessionId }),
1478
1728
  /**
1479
1729
  * Deletes the session plan file from the workspace.
1480
1730
  */
@@ -1507,7 +1757,7 @@ function createSessionRpc(connection, sessionId) {
1507
1757
  *
1508
1758
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1509
1759
  */
1510
- updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { sessionId, ...params }),
1760
+ updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { ...params, sessionId }),
1511
1761
  /**
1512
1762
  * Ensures a local session workspace exists and returns it.
1513
1763
  *
@@ -1515,7 +1765,7 @@ function createSessionRpc(connection, sessionId) {
1515
1765
  *
1516
1766
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1517
1767
  */
1518
- ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { sessionId, ...params }),
1768
+ ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { ...params, sessionId }),
1519
1769
  /**
1520
1770
  * Lists files stored in the session workspace files directory.
1521
1771
  *
@@ -1529,13 +1779,13 @@ function createSessionRpc(connection, sessionId) {
1529
1779
  *
1530
1780
  * @returns Contents of the requested workspace file as a UTF-8 string.
1531
1781
  */
1532
- readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { sessionId, ...params }),
1782
+ readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { ...params, sessionId }),
1533
1783
  /**
1534
1784
  * Creates or overwrites a file in the session workspace files directory.
1535
1785
  *
1536
1786
  * @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
1537
1787
  */
1538
- createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
1788
+ createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { ...params, sessionId }),
1539
1789
  /**
1540
1790
  * Returns metadata for a file or directory in the session workspace files directory.
1541
1791
  *
@@ -1543,25 +1793,25 @@ function createSessionRpc(connection, sessionId) {
1543
1793
  *
1544
1794
  * @returns Filesystem metadata for a path in the session workspace files directory.
1545
1795
  */
1546
- statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
1796
+ statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { ...params, sessionId }),
1547
1797
  /**
1548
1798
  * Creates a directory in the session workspace files directory.
1549
1799
  *
1550
1800
  * @param params Directory to create within the session workspace files directory.
1551
1801
  */
1552
- createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
1802
+ createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { ...params, sessionId }),
1553
1803
  /**
1554
1804
  * Removes a file or directory from the session workspace files directory.
1555
1805
  *
1556
1806
  * @param params File or directory to remove from the session workspace files directory.
1557
1807
  */
1558
- removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
1808
+ removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { ...params, sessionId }),
1559
1809
  /**
1560
1810
  * Renames a file or directory within the session workspace files directory.
1561
1811
  *
1562
1812
  * @param params Source and destination paths for a rename within the session workspace files directory.
1563
1813
  */
1564
- renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
1814
+ renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { ...params, sessionId }),
1565
1815
  /**
1566
1816
  * Lists workspace checkpoints in chronological order.
1567
1817
  *
@@ -1575,7 +1825,7 @@ function createSessionRpc(connection, sessionId) {
1575
1825
  *
1576
1826
  * @returns Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
1577
1827
  */
1578
- readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { sessionId, ...params }),
1828
+ readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { ...params, sessionId }),
1579
1829
  /**
1580
1830
  * Adds a compaction summary checkpoint to the local session workspace.
1581
1831
  *
@@ -1583,7 +1833,7 @@ function createSessionRpc(connection, sessionId) {
1583
1833
  *
1584
1834
  * @returns Persisted summary metadata and refreshed workspace metadata.
1585
1835
  */
1586
- addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { sessionId, ...params }),
1836
+ addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { ...params, sessionId }),
1587
1837
  /**
1588
1838
  * Truncates local workspace compaction summaries after a rollback.
1589
1839
  *
@@ -1591,7 +1841,7 @@ function createSessionRpc(connection, sessionId) {
1591
1841
  *
1592
1842
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1593
1843
  */
1594
- truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { sessionId, ...params }),
1844
+ truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { ...params, sessionId }),
1595
1845
  /**
1596
1846
  * Reads the autopilot objective state file from the local session workspace.
1597
1847
  *
@@ -1605,7 +1855,7 @@ function createSessionRpc(connection, sessionId) {
1605
1855
  *
1606
1856
  * @returns Result of writing the autopilot objective file.
1607
1857
  */
1608
- writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { sessionId, ...params }),
1858
+ writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { ...params, sessionId }),
1609
1859
  /**
1610
1860
  * Deletes the autopilot objective state file from the local session workspace.
1611
1861
  *
@@ -1625,7 +1875,7 @@ function createSessionRpc(connection, sessionId) {
1625
1875
  *
1626
1876
  * @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
1627
1877
  */
1628
- saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
1878
+ saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { ...params, sessionId }),
1629
1879
  /**
1630
1880
  * Computes a diff for the session workspace. Never rejects for a busy session: a `session`-mode diff that cannot read the session's file-change captures falls back to an unstaged git diff with `isFallback: true` and reports why in `unavailableReason`.
1631
1881
  *
@@ -1633,7 +1883,7 @@ function createSessionRpc(connection, sessionId) {
1633
1883
  *
1634
1884
  * @returns Workspace diff result for the requested mode.
1635
1885
  */
1636
- diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
1886
+ diff: async (params) => connection.sendRequest("session.workspaces.diff", { ...params, sessionId })
1637
1887
  },
1638
1888
  /** @experimental */
1639
1889
  autopilotObjective: {
@@ -1659,7 +1909,7 @@ function createSessionRpc(connection, sessionId) {
1659
1909
  *
1660
1910
  * @returns Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
1661
1911
  */
1662
- request: async (params) => connection.sendRequest("session.completions.request", { sessionId, ...params })
1912
+ request: async (params) => connection.sendRequest("session.completions.request", { ...params, sessionId })
1663
1913
  },
1664
1914
  /** @experimental */
1665
1915
  instructions: {
@@ -1670,16 +1920,18 @@ function createSessionRpc(connection, sessionId) {
1670
1920
  */
1671
1921
  getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId }),
1672
1922
  /**
1673
- * Invalidates cached custom-instruction discovery so subsequent turns and source reads observe instruction files currently on disk.
1923
+ * For local sessions, invalidates instruction discovery and the model-facing prompt, then returns freshly discovered sources. The updated prompt takes effect on the next turn. Remote sessions must reload on their agent host instead.
1924
+ *
1925
+ * @returns Instruction sources loaded for the session, in merge order.
1674
1926
  */
1675
1927
  reload: async () => connection.sendRequest("session.instructions.reload", { sessionId })
1676
1928
  },
1677
1929
  /** @experimental */
1678
1930
  customizations: {
1679
1931
  /**
1680
- * Reloads all repository and user customizations for the active session: instructions, plugins and their MCP servers and hooks, custom agents, extensions, and skills. Returns diagnostics from the final skill reload.
1932
+ * For local sessions, reconciles repository context and discovered instructions, plugins, skills, agents, hooks, MCP servers, and extensions after files appear or change under the working directory. Independent component failures are returned in outcomes and errors; a rejected call can have partially applied earlier steps. Remote sessions must reload on their agent host instead. The model-facing context is rebuilt on the next turn.
1681
1933
  *
1682
- * @returns Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
1934
+ * @returns Results of reloading discovered session customizations. Inspect outcomes for reloaded, skipped, or failed subsystems; a rejection may follow partial mutation. Changes to the model-facing prompt and tools apply on the next turn.
1683
1935
  */
1684
1936
  reload: async () => connection.sendRequest("session.customizations.reload", { sessionId })
1685
1937
  },
@@ -1692,7 +1944,7 @@ function createSessionRpc(connection, sessionId) {
1692
1944
  *
1693
1945
  * @returns Indicates whether fleet mode was successfully activated.
1694
1946
  */
1695
- start: async (params) => connection.sendRequest("session.fleet.start", { sessionId, ...params })
1947
+ start: async (params) => connection.sendRequest("session.fleet.start", { ...params, sessionId })
1696
1948
  },
1697
1949
  /** @experimental */
1698
1950
  agent: {
@@ -1703,13 +1955,13 @@ function createSessionRpc(connection, sessionId) {
1703
1955
  *
1704
1956
  * @returns Agents available to the session.
1705
1957
  */
1706
- list: async (params) => connection.sendRequest("session.agent.list", { sessionId, ...params }),
1958
+ list: async (params) => connection.sendRequest("session.agent.list", { ...params, sessionId }),
1707
1959
  /**
1708
1960
  * Sets an in-memory authored prompt override for an available agent. For built-in agents, this replaces only the static base prompt while preserving runtime-owned dynamic prompt composition and behavior. The special `general-purpose` agent is not overrideable. Overrides are not persisted; resumed and forked sessions start without them, so the host must re-apply them.
1709
1961
  *
1710
1962
  * @param params An in-memory authored prompt override for an available agent.
1711
1963
  */
1712
- setPrompt: async (params) => connection.sendRequest("session.agent.setPrompt", { sessionId, ...params }),
1964
+ setPrompt: async (params) => connection.sendRequest("session.agent.setPrompt", { ...params, sessionId }),
1713
1965
  /**
1714
1966
  * Gets the currently selected custom agent for the session.
1715
1967
  *
@@ -1723,7 +1975,7 @@ function createSessionRpc(connection, sessionId) {
1723
1975
  *
1724
1976
  * @returns The newly selected custom agent.
1725
1977
  */
1726
- select: async (params) => connection.sendRequest("session.agent.select", { sessionId, ...params }),
1978
+ select: async (params) => connection.sendRequest("session.agent.select", { ...params, sessionId }),
1727
1979
  /**
1728
1980
  * Clears the selected custom agent and returns the session to the default agent.
1729
1981
  */
@@ -1744,7 +1996,7 @@ function createSessionRpc(connection, sessionId) {
1744
1996
  *
1745
1997
  * @returns Identifier assigned to the newly started background agent task.
1746
1998
  */
1747
- startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { sessionId, ...params }),
1999
+ startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { ...params, sessionId }),
1748
2000
  /**
1749
2001
  * Lists background tasks tracked by the session.
1750
2002
  *
@@ -1758,7 +2010,7 @@ function createSessionRpc(connection, sessionId) {
1758
2010
  *
1759
2011
  * @returns Result of registering or reclaiming a client-owned task.
1760
2012
  */
1761
- register: async (params) => connection.sendRequest("session.tasks.register", { sessionId, ...params }),
2013
+ register: async (params) => connection.sendRequest("session.tasks.register", { ...params, sessionId }),
1762
2014
  /**
1763
2015
  * Publishes generic progress or a terminal outcome for a client-owned task.
1764
2016
  *
@@ -1766,7 +2018,7 @@ function createSessionRpc(connection, sessionId) {
1766
2018
  *
1767
2019
  * @returns Result of publishing a client-owned task update.
1768
2020
  */
1769
- update: async (params) => connection.sendRequest("session.tasks.update", { sessionId, ...params }),
2021
+ update: async (params) => connection.sendRequest("session.tasks.update", { ...params, sessionId }),
1770
2022
  /**
1771
2023
  * Refreshes metadata for any detached background shells the runtime knows about.
1772
2024
  *
@@ -1786,7 +2038,7 @@ function createSessionRpc(connection, sessionId) {
1786
2038
  *
1787
2039
  * @returns Progress information for the task, or null when no task with that ID is tracked.
1788
2040
  */
1789
- getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { sessionId, ...params }),
2041
+ getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { ...params, sessionId }),
1790
2042
  /**
1791
2043
  * Returns the first sync-waiting task that can currently be promoted to background mode.
1792
2044
  *
@@ -1800,7 +2052,7 @@ function createSessionRpc(connection, sessionId) {
1800
2052
  *
1801
2053
  * @returns Indicates whether the task was successfully promoted to background mode.
1802
2054
  */
1803
- promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
2055
+ promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { ...params, sessionId }),
1804
2056
  /**
1805
2057
  * Atomically promotes the first promotable sync-waiting task to background mode and returns it.
1806
2058
  *
@@ -1814,7 +2066,7 @@ function createSessionRpc(connection, sessionId) {
1814
2066
  *
1815
2067
  * @returns Indicates whether the background task was successfully cancelled.
1816
2068
  */
1817
- cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
2069
+ cancel: async (params) => connection.sendRequest("session.tasks.cancel", { ...params, sessionId }),
1818
2070
  /**
1819
2071
  * Removes a completed or cancelled background task from tracking.
1820
2072
  *
@@ -1822,7 +2074,7 @@ function createSessionRpc(connection, sessionId) {
1822
2074
  *
1823
2075
  * @returns Indicates whether the task was removed. False when the task does not exist or is still running/idle.
1824
2076
  */
1825
- remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params }),
2077
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { ...params, sessionId }),
1826
2078
  /**
1827
2079
  * Sends a message to a background agent task.
1828
2080
  *
@@ -1830,7 +2082,7 @@ function createSessionRpc(connection, sessionId) {
1830
2082
  *
1831
2083
  * @returns Indicates whether the message was delivered, with an error message when delivery failed.
1832
2084
  */
1833
- sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { sessionId, ...params })
2085
+ sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { ...params, sessionId })
1834
2086
  },
1835
2087
  /** @experimental */
1836
2088
  skills: {
@@ -1851,13 +2103,13 @@ function createSessionRpc(connection, sessionId) {
1851
2103
  *
1852
2104
  * @param params Name of the skill to enable for the session.
1853
2105
  */
1854
- enable: async (params) => connection.sendRequest("session.skills.enable", { sessionId, ...params }),
2106
+ enable: async (params) => connection.sendRequest("session.skills.enable", { ...params, sessionId }),
1855
2107
  /**
1856
2108
  * Disables a skill for the session.
1857
2109
  *
1858
2110
  * @param params Name of the skill to disable for the session.
1859
2111
  */
1860
- disable: async (params) => connection.sendRequest("session.skills.disable", { sessionId, ...params }),
2112
+ disable: async (params) => connection.sendRequest("session.skills.disable", { ...params, sessionId }),
1861
2113
  /**
1862
2114
  * Reloads skill definitions for the session.
1863
2115
  *
@@ -1872,11 +2124,17 @@ function createSessionRpc(connection, sessionId) {
1872
2124
  /** @experimental */
1873
2125
  mcp: {
1874
2126
  /**
1875
- * Lists MCP servers configured for the session, their connection status, and host-level state. The host-level state (disabled/filtered servers, failed/needs-auth/pending connections, mcp3p policy, full config) is empty/zero when no MCP host has been initialized for the session.
2127
+ * Lists materialized MCP servers and their connection status. Cache misses may start and wait for MCP servers.
1876
2128
  *
1877
2129
  * @returns MCP servers configured for the session, with their connection status and host-level state.
1878
2130
  */
1879
2131
  list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
2132
+ /**
2133
+ * Lists effective MCP configuration without starting, restarting, authenticating, or waiting for servers. An optional live observation is from an already materialized matching server; this is not a readiness guarantee.
2134
+ *
2135
+ * @returns Effective MCP configuration with optional live observations from matching already materialized servers.
2136
+ */
2137
+ listConfigured: async () => connection.sendRequest("session.mcp.listConfigured", { sessionId }),
1880
2138
  /**
1881
2139
  * Lists the tools exposed by a connected MCP server on this session's host. This performs a live `tools/list` request. Tool UI metadata is returned independently of whether MCP Apps rendering is enabled for the session.
1882
2140
  *
@@ -1884,19 +2142,19 @@ function createSessionRpc(connection, sessionId) {
1884
2142
  *
1885
2143
  * @returns Tools exposed by the connected MCP server. Throws when the server is not connected.
1886
2144
  */
1887
- listTools: async (params) => connection.sendRequest("session.mcp.listTools", { sessionId, ...params }),
2145
+ listTools: async (params) => connection.sendRequest("session.mcp.listTools", { ...params, sessionId }),
1888
2146
  /**
1889
2147
  * Enables an MCP server for the session.
1890
2148
  *
1891
2149
  * @param params Name of the MCP server to enable for the session.
1892
2150
  */
1893
- enable: async (params) => connection.sendRequest("session.mcp.enable", { sessionId, ...params }),
2151
+ enable: async (params) => connection.sendRequest("session.mcp.enable", { ...params, sessionId }),
1894
2152
  /**
1895
2153
  * Disables an MCP server for the session.
1896
2154
  *
1897
2155
  * @param params Name of the MCP server to disable for the session.
1898
2156
  */
1899
- disable: async (params) => connection.sendRequest("session.mcp.disable", { sessionId, ...params }),
2157
+ disable: async (params) => connection.sendRequest("session.mcp.disable", { ...params, sessionId }),
1900
2158
  /**
1901
2159
  * Reloads MCP server connections for the session.
1902
2160
  */
@@ -1914,7 +2172,7 @@ function createSessionRpc(connection, sessionId) {
1914
2172
  *
1915
2173
  * @returns Outcome of an MCP sampling execution: success result, failure error, or cancellation.
1916
2174
  */
1917
- executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { sessionId, ...params }),
2175
+ executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { ...params, sessionId }),
1918
2176
  /**
1919
2177
  * Cancels an in-flight MCP sampling execution by request ID.
1920
2178
  *
@@ -1922,7 +2180,7 @@ function createSessionRpc(connection, sessionId) {
1922
2180
  *
1923
2181
  * @returns Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
1924
2182
  */
1925
- cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { sessionId, ...params }),
2183
+ cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { ...params, sessionId }),
1926
2184
  /**
1927
2185
  * Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
1928
2186
  *
@@ -1930,7 +2188,7 @@ function createSessionRpc(connection, sessionId) {
1930
2188
  *
1931
2189
  * @returns Env-value mode recorded on the session after the update.
1932
2190
  */
1933
- setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { sessionId, ...params }),
2191
+ setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { ...params, sessionId }),
1934
2192
  /**
1935
2193
  * Removes the auto-managed `github` MCP server when present.
1936
2194
  *
@@ -1942,19 +2200,19 @@ function createSessionRpc(connection, sessionId) {
1942
2200
  *
1943
2201
  * @param params Server name and optional configuration for an individual MCP server start. Omit `config` for a config-free start-by-name of an already-configured server.
1944
2202
  */
1945
- startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
2203
+ startServer: async (params) => connection.sendRequest("session.mcp.startServer", { ...params, sessionId }),
1946
2204
  /**
1947
2205
  * Restarts an individual MCP server on the live session (stops then starts). Omit `config` for a config-free restart-by-name of an already-configured server; supply `config` to restart with a replacement configuration. Session-scoped and ephemeral: does NOT modify persistent user configuration (`mcp.config.*`).
1948
2206
  *
1949
2207
  * @param params Server name and optional replacement configuration for an individual MCP server restart. Omit `config` for a config-free restart-by-name of an already-configured server.
1950
2208
  */
1951
- restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { sessionId, ...params }),
2209
+ restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { ...params, sessionId }),
1952
2210
  /**
1953
2211
  * Stops an individual MCP server on the session's host.
1954
2212
  *
1955
2213
  * @param params Server name for an individual MCP server stop.
1956
2214
  */
1957
- stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { sessionId, ...params }),
2215
+ stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { ...params, sessionId }),
1958
2216
  /**
1959
2217
  * Checks whether a named MCP server is currently running on the session's host.
1960
2218
  *
@@ -1962,7 +2220,7 @@ function createSessionRpc(connection, sessionId) {
1962
2220
  *
1963
2221
  * @returns Whether the named MCP server is running.
1964
2222
  */
1965
- isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { sessionId, ...params }),
2223
+ isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { ...params, sessionId }),
1966
2224
  /** @experimental */
1967
2225
  oauth: {
1968
2226
  /**
@@ -1972,13 +2230,13 @@ function createSessionRpc(connection, sessionId) {
1972
2230
  *
1973
2231
  * @returns Indicates whether the pending MCP OAuth response was accepted.
1974
2232
  */
1975
- handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { sessionId, ...params }),
2233
+ handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { ...params, sessionId }),
1976
2234
  /**
1977
2235
  * Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
1978
2236
  *
1979
2237
  * @param params Identifies the MCP server whose persisted OAuth credentials were updated.
1980
2238
  */
1981
- authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { sessionId, ...params }),
2239
+ authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { ...params, sessionId }),
1982
2240
  /**
1983
2241
  * Prepares an inert, expiring owned OAuth login bound to the original session requester and exact installation. Does not activate, connect, read credentials or open a browser.
1984
2242
  *
@@ -1986,15 +2244,21 @@ function createSessionRpc(connection, sessionId) {
1986
2244
  *
1987
2245
  * @returns An inert runtime-issued login handle. Preparation alone performs no activation or OAuth work.
1988
2246
  */
1989
- prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { sessionId, ...params }),
2247
+ prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { ...params, sessionId }),
1990
2248
  /**
1991
2249
  * Starts OAuth authentication for a remote MCP server. Owned servers require the original one-use prepareLogin handle and exact installation ID; manual servers retain the existing direct login behaviour.
1992
2250
  *
1993
- * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
2251
+ * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback handling, and static OAuth client selection.
1994
2252
  *
1995
2253
  * @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
1996
2254
  */
1997
- login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params }),
2255
+ login: async (params) => connection.sendRequest("session.mcp.oauth.login", { ...params, sessionId }),
2256
+ /**
2257
+ * Completes a runtime-managed MCP OAuth login after the authorization server redirects to a host-managed callback URL.
2258
+ *
2259
+ * @param params Host-delivered callback for a runtime-managed MCP OAuth login.
2260
+ */
2261
+ complete: async (params) => connection.sendRequest("session.mcp.oauth.complete", { ...params, sessionId }),
1998
2262
  /**
1999
2263
  * Passively probes a configured remote MCP server to classify whether OAuth is required or a cached/override token is accepted. Does not start OAuth, emit pending OAuth requests, or mutate MCP connection state.
2000
2264
  *
@@ -2002,7 +2266,7 @@ function createSessionRpc(connection, sessionId) {
2002
2266
  *
2003
2267
  * @returns Passive MCP OAuth probe result. `authenticated` means the server accepted the probe request while an OAuth-origin access token was attached; it does not prove the server required or independently validated that token. The probe does not make a second unauthenticated request. Failed is an expected probe-domain outcome; JSON-RPC errors are reserved for API-call failures.
2004
2268
  */
2005
- probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { sessionId, ...params }),
2269
+ probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { ...params, sessionId }),
2006
2270
  /**
2007
2271
  * Cancels the exact owned OAuth login issued to this original session requester, without clearing shared credentials.
2008
2272
  *
@@ -2010,7 +2274,7 @@ function createSessionRpc(connection, sessionId) {
2010
2274
  *
2011
2275
  * @returns Honest terminal cancellation result; persistence or recovery failures remain RPC errors.
2012
2276
  */
2013
- cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { sessionId, ...params }),
2277
+ cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { ...params, sessionId }),
2014
2278
  /**
2015
2279
  * Responds to a pending MCP OAuth authorization request by its request id.
2016
2280
  *
@@ -2018,7 +2282,7 @@ function createSessionRpc(connection, sessionId) {
2018
2282
  *
2019
2283
  * @returns Indicates whether the pending MCP OAuth response was accepted.
2020
2284
  */
2021
- respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
2285
+ respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { ...params, sessionId })
2022
2286
  },
2023
2287
  /** @experimental */
2024
2288
  headers: {
@@ -2029,7 +2293,7 @@ function createSessionRpc(connection, sessionId) {
2029
2293
  *
2030
2294
  * @returns Indicates whether the pending MCP headers refresh response was accepted.
2031
2295
  */
2032
- handlePendingHeadersRefreshRequest: async (params) => connection.sendRequest("session.mcp.headers.handlePendingHeadersRefreshRequest", { sessionId, ...params })
2296
+ handlePendingHeadersRefreshRequest: async (params) => connection.sendRequest("session.mcp.headers.handlePendingHeadersRefreshRequest", { ...params, sessionId })
2033
2297
  },
2034
2298
  /** @experimental */
2035
2299
  apps: {
@@ -2040,7 +2304,7 @@ function createSessionRpc(connection, sessionId) {
2040
2304
  *
2041
2305
  * @returns Resource contents returned by the MCP server.
2042
2306
  */
2043
- readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { sessionId, ...params }),
2307
+ readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { ...params, sessionId }),
2044
2308
  /**
2045
2309
  * List tools that an MCP App view is allowed to call (SEP-1865 visibility filter). Returns tools whose `_meta.ui.visibility` is unset (default `["model","app"]`) or includes `"app"`.
2046
2310
  *
@@ -2048,7 +2312,7 @@ function createSessionRpc(connection, sessionId) {
2048
2312
  *
2049
2313
  * @returns App-callable tools from the named MCP server.
2050
2314
  */
2051
- listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { sessionId, ...params }),
2315
+ listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { ...params, sessionId }),
2052
2316
  /**
2053
2317
  * Call an MCP tool from an MCP App view (SEP-1865). Enforces the visibility check that prevents an app iframe from invoking model-only tools. Returns the standard MCP `CallToolResult`.
2054
2318
  *
@@ -2056,13 +2320,13 @@ function createSessionRpc(connection, sessionId) {
2056
2320
  *
2057
2321
  * @returns Standard MCP CallToolResult
2058
2322
  */
2059
- callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { sessionId, ...params }),
2323
+ callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { ...params, sessionId }),
2060
2324
  /**
2061
2325
  * Replace the host context returned to MCP App guests on `ui/initialize`. Hosts use this to advertise theme, locale, or other metadata to the guest UI.
2062
2326
  *
2063
2327
  * @param params Host context to advertise to MCP App guests.
2064
2328
  */
2065
- setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { sessionId, ...params }),
2329
+ setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { ...params, sessionId }),
2066
2330
  /**
2067
2331
  * Read the current host context advertised to MCP App guests.
2068
2332
  *
@@ -2076,7 +2340,7 @@ function createSessionRpc(connection, sessionId) {
2076
2340
  *
2077
2341
  * @returns Diagnostic snapshot of MCP Apps wiring for the named server.
2078
2342
  */
2079
- diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { sessionId, ...params })
2343
+ diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { ...params, sessionId })
2080
2344
  },
2081
2345
  /** @experimental */
2082
2346
  resources: {
@@ -2087,7 +2351,7 @@ function createSessionRpc(connection, sessionId) {
2087
2351
  *
2088
2352
  * @returns Resource contents returned by the MCP server.
2089
2353
  */
2090
- read: async (params) => connection.sendRequest("session.mcp.resources.read", { sessionId, ...params }),
2354
+ read: async (params) => connection.sendRequest("session.mcp.resources.read", { ...params, sessionId }),
2091
2355
  /**
2092
2356
  * Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
2093
2357
  *
@@ -2095,7 +2359,7 @@ function createSessionRpc(connection, sessionId) {
2095
2359
  *
2096
2360
  * @returns One page of resources advertised by the named MCP server.
2097
2361
  */
2098
- list: async (params) => connection.sendRequest("session.mcp.resources.list", { sessionId, ...params }),
2362
+ list: async (params) => connection.sendRequest("session.mcp.resources.list", { ...params, sessionId }),
2099
2363
  /**
2100
2364
  * Enumerate one page of resource templates a connected MCP server exposes (proxies MCP `resources/templates/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
2101
2365
  *
@@ -2103,7 +2367,26 @@ function createSessionRpc(connection, sessionId) {
2103
2367
  *
2104
2368
  * @returns One page of resource templates advertised by the named MCP server.
2105
2369
  */
2106
- listTemplates: async (params) => connection.sendRequest("session.mcp.resources.listTemplates", { sessionId, ...params })
2370
+ listTemplates: async (params) => connection.sendRequest("session.mcp.resources.listTemplates", { ...params, sessionId })
2371
+ },
2372
+ /** @experimental */
2373
+ prompts: {
2374
+ /**
2375
+ * Enumerate one page of prompts a connected MCP server exposes (proxies MCP `prompts/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
2376
+ *
2377
+ * @param params MCP server whose prompts to enumerate.
2378
+ *
2379
+ * @returns One page of prompts advertised by the named MCP server.
2380
+ */
2381
+ list: async (params) => connection.sendRequest("session.mcp.prompts.list", { ...params, sessionId }),
2382
+ /**
2383
+ * Get a prompt's messages from a connected MCP server (proxies MCP `prompts/get`). Content is preserved as opaque JSON. Does not send messages to the model, execute tools, or fetch referenced resources.
2384
+ *
2385
+ * @param params MCP server, prompt name, and optional string-valued arguments.
2386
+ *
2387
+ * @returns Prompt messages returned by the MCP server without sending them to the model.
2388
+ */
2389
+ get: async (params) => connection.sendRequest("session.mcp.prompts.get", { ...params, sessionId })
2107
2390
  }
2108
2391
  },
2109
2392
  /** @experimental */
@@ -2115,7 +2398,7 @@ function createSessionRpc(connection, sessionId) {
2115
2398
  *
2116
2399
  * @returns Per-source session diagnostics configuration.
2117
2400
  */
2118
- configure: async (params) => connection.sendRequest("session.diagnostics.configure", { sessionId, ...params }),
2401
+ configure: async (params) => connection.sendRequest("session.diagnostics.configure", { ...params, sessionId }),
2119
2402
  /**
2120
2403
  * Reads a bounded batch of retained session diagnostics for the selected sources. Records are never consumed and each reader advances independently through its opaque cursor.
2121
2404
  *
@@ -2123,7 +2406,7 @@ function createSessionRpc(connection, sessionId) {
2123
2406
  *
2124
2407
  * @returns One cursor-addressed page of retained session diagnostics.
2125
2408
  */
2126
- read: async (params) => connection.sendRequest("session.diagnostics.read", { sessionId, ...params })
2409
+ read: async (params) => connection.sendRequest("session.diagnostics.read", { ...params, sessionId })
2127
2410
  },
2128
2411
  /** @experimental */
2129
2412
  connectors: {
@@ -2152,7 +2435,7 @@ function createSessionRpc(connection, sessionId) {
2152
2435
  *
2153
2436
  * @returns Validated Connector catalog snapshot cached by the session.
2154
2437
  */
2155
- list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
2438
+ list: async (params) => connection.sendRequest("session.connectors.list", { ...params, sessionId }),
2156
2439
  /**
2157
2440
  * Refreshes and validates the Connector catalog for the pinned opaque account selection.
2158
2441
  *
@@ -2160,7 +2443,7 @@ function createSessionRpc(connection, sessionId) {
2160
2443
  *
2161
2444
  * @returns Validated Connector catalog snapshot cached by the session.
2162
2445
  */
2163
- refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
2446
+ refresh: async (params) => connection.sendRequest("session.connectors.refresh", { ...params, sessionId }),
2164
2447
  /**
2165
2448
  * Initiates an idempotent Connector connection request without opening a browser. Returns connected when the service is immediately authoritative, consent_required with a validated URL, or pending with an opaque continuation ID.
2166
2449
  *
@@ -2168,7 +2451,7 @@ function createSessionRpc(connection, sessionId) {
2168
2451
  *
2169
2452
  * @returns Typed result of initiating or continuing a Connector connection.
2170
2453
  */
2171
- connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
2454
+ connect: async (params) => connection.sendRequest("session.connectors.connect", { ...params, sessionId }),
2172
2455
  /**
2173
2456
  * Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
2174
2457
  *
@@ -2176,7 +2459,7 @@ function createSessionRpc(connection, sessionId) {
2176
2459
  *
2177
2460
  * @returns Typed result of initiating or continuing a Connector connection.
2178
2461
  */
2179
- reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
2462
+ reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { ...params, sessionId }),
2180
2463
  /**
2181
2464
  * Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
2182
2465
  *
@@ -2184,7 +2467,7 @@ function createSessionRpc(connection, sessionId) {
2184
2467
  *
2185
2468
  * @returns Typed result of initiating or continuing a Connector connection.
2186
2469
  */
2187
- continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
2470
+ continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { ...params, sessionId }),
2188
2471
  /**
2189
2472
  * Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
2190
2473
  *
@@ -2192,7 +2475,7 @@ function createSessionRpc(connection, sessionId) {
2192
2475
  *
2193
2476
  * @returns Authoritative result after disconnect and MCP reconciliation.
2194
2477
  */
2195
- disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
2478
+ disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { ...params, sessionId }),
2196
2479
  /**
2197
2480
  * Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
2198
2481
  *
@@ -2200,7 +2483,7 @@ function createSessionRpc(connection, sessionId) {
2200
2483
  *
2201
2484
  * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
2202
2485
  */
2203
- reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
2486
+ reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { ...params, sessionId })
2204
2487
  },
2205
2488
  /** @experimental */
2206
2489
  managedSettings: {
@@ -2226,13 +2509,13 @@ function createSessionRpc(connection, sessionId) {
2226
2509
  *
2227
2510
  * @returns Result of installing a plugin.
2228
2511
  */
2229
- install: async (params) => connection.sendRequest("session.plugins.install", { sessionId, ...params }),
2512
+ install: async (params) => connection.sendRequest("session.plugins.install", { ...params, sessionId }),
2230
2513
  /**
2231
2514
  * Uninstalls a plugin when permitted by the live session's retained managed policy.
2232
2515
  *
2233
2516
  * @param params Name (or spec) of the plugin to uninstall.
2234
2517
  */
2235
- uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { sessionId, ...params }),
2518
+ uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { ...params, sessionId }),
2236
2519
  /**
2237
2520
  * Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
2238
2521
  *
@@ -2240,19 +2523,19 @@ function createSessionRpc(connection, sessionId) {
2240
2523
  *
2241
2524
  * @returns Result of updating a single plugin.
2242
2525
  */
2243
- update: async (params) => connection.sendRequest("session.plugins.update", { sessionId, ...params }),
2526
+ update: async (params) => connection.sendRequest("session.plugins.update", { ...params, sessionId }),
2244
2527
  /**
2245
2528
  * Enables installed plugins when permitted by the live session's retained managed policy.
2246
2529
  *
2247
2530
  * @param params Plugin names (or specs) to enable in the session's authoritative working directory.
2248
2531
  */
2249
- enable: async (params) => connection.sendRequest("session.plugins.enable", { sessionId, ...params }),
2532
+ enable: async (params) => connection.sendRequest("session.plugins.enable", { ...params, sessionId }),
2250
2533
  /**
2251
2534
  * Disables installed plugins when permitted by the live session's retained managed policy.
2252
2535
  *
2253
2536
  * @param params Plugin names (or specs) to disable in the session's authoritative working directory.
2254
2537
  */
2255
- disable: async (params) => connection.sendRequest("session.plugins.disable", { sessionId, ...params }),
2538
+ disable: async (params) => connection.sendRequest("session.plugins.disable", { ...params, sessionId }),
2256
2539
  /** @experimental */
2257
2540
  marketplaces: {
2258
2541
  /**
@@ -2268,7 +2551,7 @@ function createSessionRpc(connection, sessionId) {
2268
2551
  *
2269
2552
  * @returns Result of registering a new marketplace.
2270
2553
  */
2271
- add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { sessionId, ...params }),
2554
+ add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { ...params, sessionId }),
2272
2555
  /**
2273
2556
  * Removes a marketplace when permitted by the live session's retained managed policy.
2274
2557
  *
@@ -2276,7 +2559,7 @@ function createSessionRpc(connection, sessionId) {
2276
2559
  *
2277
2560
  * @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
2278
2561
  */
2279
- remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { sessionId, ...params }),
2562
+ remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { ...params, sessionId }),
2280
2563
  /**
2281
2564
  * Browses a marketplace resolved through the live session's working directory and retained managed policy.
2282
2565
  *
@@ -2284,7 +2567,7 @@ function createSessionRpc(connection, sessionId) {
2284
2567
  *
2285
2568
  * @returns Plugins advertised by the marketplace.
2286
2569
  */
2287
- browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { sessionId, ...params }),
2570
+ browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { ...params, sessionId }),
2288
2571
  /**
2289
2572
  * Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
2290
2573
  *
@@ -2292,14 +2575,14 @@ function createSessionRpc(connection, sessionId) {
2292
2575
  *
2293
2576
  * @returns Result of refreshing one or more marketplace catalogs.
2294
2577
  */
2295
- refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { sessionId, ...params })
2578
+ refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { ...params, sessionId })
2296
2579
  },
2297
2580
  /**
2298
2581
  * Reloads the session's plugin set, refreshing MCP servers, custom agents, hooks, and skills cache so SDK-driven changes via `server.plugins.*` take effect immediately.
2299
2582
  *
2300
2583
  * @param params Optional flags controlling which side effects the reload performs.
2301
2584
  */
2302
- reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
2585
+ reload: async (params) => connection.sendRequest("session.plugins.reload", { ...params, sessionId })
2303
2586
  },
2304
2587
  /** @experimental */
2305
2588
  provider: {
@@ -2310,7 +2593,7 @@ function createSessionRpc(connection, sessionId) {
2310
2593
  *
2311
2594
  * @returns A snapshot of the provider endpoint the session is currently configured to talk to.
2312
2595
  */
2313
- getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
2596
+ getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { ...params, sessionId }),
2314
2597
  /**
2315
2598
  * Adds BYOK providers and/or models to the session's registry at runtime, extending the additive registry built from the session's `providers`/`models` options. Both fields are optional, so a call may add providers only, models only, or both. Within a single call providers are registered before models, so a model may reference a provider added in the same call; across calls a model may reference any provider already registered (from session creation or a prior add). A model whose referenced provider is not registered by the end of the call is rejected. Newly added models become selectable via `model.list` / `model.switchTo` and are inherited by sub-agents spawned afterwards.
2316
2599
  *
@@ -2318,7 +2601,7 @@ function createSessionRpc(connection, sessionId) {
2318
2601
  *
2319
2602
  * @returns The selectable model entries synthesized for the models added by this call.
2320
2603
  */
2321
- add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
2604
+ add: async (params) => connection.sendRequest("session.provider.add", { ...params, sessionId }),
2322
2605
  /**
2323
2606
  * Atomically updates the session's BYOK provider and model registry by applying the supplied snapshot, replacing existing entries, updating models, or removing entries absent from the snapshot.
2324
2607
  *
@@ -2326,7 +2609,7 @@ function createSessionRpc(connection, sessionId) {
2326
2609
  *
2327
2610
  * @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
2328
2611
  */
2329
- sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params }),
2612
+ sync: async (params) => connection.sendRequest("session.provider.sync", { ...params, sessionId }),
2330
2613
  /**
2331
2614
  * Withdraws named host-managed models from the session's BYOK registry, leaving every other entry untouched. The scoped counterpart to `provider.sync`: a snapshot can only describe entries the caller knows about, so using it to remove one model silently withdraws rows registered by another source, such as a plugin calling `provider.add` at runtime. Naming what to remove leaves unrelated entries alone. Selection ids that are not registered are ignored, so withdrawal is idempotent. A provider is removed only when one of the withdrawn models was the last entry referencing it; a provider that simply has no models, which is the normal state while its rows are supplied by catalog discovery, is left in place.
2332
2615
  *
@@ -2334,7 +2617,7 @@ function createSessionRpc(connection, sessionId) {
2334
2617
  *
2335
2618
  * @returns What the withdrawal actually removed from the registry.
2336
2619
  */
2337
- withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { sessionId, ...params })
2620
+ withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { ...params, sessionId })
2338
2621
  },
2339
2622
  /** @experimental */
2340
2623
  options: {
@@ -2345,7 +2628,7 @@ function createSessionRpc(connection, sessionId) {
2345
2628
  *
2346
2629
  * @returns Indicates whether the session options patch was applied successfully.
2347
2630
  */
2348
- update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
2631
+ update: async (params) => connection.sendRequest("session.options.update", { ...params, sessionId })
2349
2632
  },
2350
2633
  /** @experimental */
2351
2634
  lsp: {
@@ -2354,7 +2637,7 @@ function createSessionRpc(connection, sessionId) {
2354
2637
  *
2355
2638
  * @param params Parameters for (re)loading the merged LSP configuration set.
2356
2639
  */
2357
- initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
2640
+ initialize: async (params) => connection.sendRequest("session.lsp.initialize", { ...params, sessionId })
2358
2641
  },
2359
2642
  /** @experimental */
2360
2643
  extensions: {
@@ -2369,13 +2652,13 @@ function createSessionRpc(connection, sessionId) {
2369
2652
  *
2370
2653
  * @param params Source-qualified extension identifier to enable for the session.
2371
2654
  */
2372
- enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
2655
+ enable: async (params) => connection.sendRequest("session.extensions.enable", { ...params, sessionId }),
2373
2656
  /**
2374
2657
  * Disables an extension for the session.
2375
2658
  *
2376
2659
  * @param params Source-qualified extension identifier to disable for the session.
2377
2660
  */
2378
- disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
2661
+ disable: async (params) => connection.sendRequest("session.extensions.disable", { ...params, sessionId }),
2379
2662
  /**
2380
2663
  * Reloads extension definitions and processes for the session.
2381
2664
  */
@@ -2385,7 +2668,7 @@ function createSessionRpc(connection, sessionId) {
2385
2668
  *
2386
2669
  * @param params Parameters for session.extensions.sendAttachmentsToMessage.
2387
2670
  */
2388
- sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { sessionId, ...params })
2671
+ sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { ...params, sessionId })
2389
2672
  },
2390
2673
  /** @experimental */
2391
2674
  tools: {
@@ -2396,7 +2679,7 @@ function createSessionRpc(connection, sessionId) {
2396
2679
  *
2397
2680
  * @returns Canonical result returned by a session tool.
2398
2681
  */
2399
- execute: async (params) => connection.sendRequest("session.tools.execute", { sessionId, ...params }),
2682
+ execute: async (params) => connection.sendRequest("session.tools.execute", { ...params, sessionId }),
2400
2683
  /**
2401
2684
  * Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
2402
2685
  *
@@ -2404,7 +2687,7 @@ function createSessionRpc(connection, sessionId) {
2404
2687
  *
2405
2688
  * @returns Rust-owned built-in tool descriptors for the session.
2406
2689
  */
2407
- getBuiltinDescriptors: async (params) => connection.sendRequest("session.tools.getBuiltinDescriptors", { sessionId, ...params }),
2690
+ getBuiltinDescriptors: async (params) => connection.sendRequest("session.tools.getBuiltinDescriptors", { ...params, sessionId }),
2408
2691
  /**
2409
2692
  * Projects a completed task_complete tool call into its label-safe session event payload.
2410
2693
  *
@@ -2412,7 +2695,7 @@ function createSessionRpc(connection, sessionId) {
2412
2695
  *
2413
2696
  * @returns Task completion notification with summary from the agent
2414
2697
  */
2415
- taskCompleteEventData: async (params) => connection.sendRequest("session.tools.taskCompleteEventData", { sessionId, ...params }),
2698
+ taskCompleteEventData: async (params) => connection.sendRequest("session.tools.taskCompleteEventData", { ...params, sessionId }),
2416
2699
  /**
2417
2700
  * Provides the result for a pending external tool call.
2418
2701
  *
@@ -2420,7 +2703,7 @@ function createSessionRpc(connection, sessionId) {
2420
2703
  *
2421
2704
  * @returns Indicates whether the external tool call result was handled successfully.
2422
2705
  */
2423
- handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params }),
2706
+ handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { ...params, sessionId }),
2424
2707
  /**
2425
2708
  * Resolves, builds, and validates the runtime tool list for the session.
2426
2709
  *
@@ -2440,7 +2723,7 @@ function createSessionRpc(connection, sessionId) {
2440
2723
  *
2441
2724
  * @returns Empty result after replacing the calling connection's externally implemented tools.
2442
2725
  */
2443
- set: async (params) => connection.sendRequest("session.tools.set", { sessionId, ...params }),
2726
+ set: async (params) => connection.sendRequest("session.tools.set", { ...params, sessionId }),
2444
2727
  /**
2445
2728
  * Sets the current session's live subagent settings override, which takes precedence over persisted user settings until cleared. Persisted user settings remain the source of truth for future sessions.
2446
2729
  *
@@ -2448,7 +2731,7 @@ function createSessionRpc(connection, sessionId) {
2448
2731
  *
2449
2732
  * @returns Empty result after applying subagent settings
2450
2733
  */
2451
- updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { sessionId, ...params })
2734
+ updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { ...params, sessionId })
2452
2735
  },
2453
2736
  /** @experimental */
2454
2737
  commands: {
@@ -2459,7 +2742,7 @@ function createSessionRpc(connection, sessionId) {
2459
2742
  *
2460
2743
  * @returns Slash commands available in the session, after applying any include/exclude filters.
2461
2744
  */
2462
- list: async (params) => connection.sendRequest("session.commands.list", { sessionId, ...params }),
2745
+ list: async (params) => connection.sendRequest("session.commands.list", { ...params, sessionId }),
2463
2746
  /**
2464
2747
  * Invokes a slash command in the session.
2465
2748
  *
@@ -2467,7 +2750,7 @@ function createSessionRpc(connection, sessionId) {
2467
2750
  *
2468
2751
  * @returns Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
2469
2752
  */
2470
- invoke: async (params) => connection.sendRequest("session.commands.invoke", { sessionId, ...params }),
2753
+ invoke: async (params) => connection.sendRequest("session.commands.invoke", { ...params, sessionId }),
2471
2754
  /**
2472
2755
  * Reports completion of a pending client-handled slash command.
2473
2756
  *
@@ -2475,7 +2758,7 @@ function createSessionRpc(connection, sessionId) {
2475
2758
  *
2476
2759
  * @returns Indicates whether the pending client-handled command was completed successfully.
2477
2760
  */
2478
- handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params }),
2761
+ handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { ...params, sessionId }),
2479
2762
  /**
2480
2763
  * Executes a slash command synchronously and returns any error.
2481
2764
  *
@@ -2483,7 +2766,7 @@ function createSessionRpc(connection, sessionId) {
2483
2766
  *
2484
2767
  * @returns Error message produced while executing the command, if any.
2485
2768
  */
2486
- execute: async (params) => connection.sendRequest("session.commands.execute", { sessionId, ...params }),
2769
+ execute: async (params) => connection.sendRequest("session.commands.execute", { ...params, sessionId }),
2487
2770
  /**
2488
2771
  * Enqueues a slash command for FIFO processing on the local session.
2489
2772
  *
@@ -2491,7 +2774,7 @@ function createSessionRpc(connection, sessionId) {
2491
2774
  *
2492
2775
  * @returns Indicates whether the command was accepted into the local execution queue.
2493
2776
  */
2494
- enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { sessionId, ...params }),
2777
+ enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { ...params, sessionId }),
2495
2778
  /**
2496
2779
  * Reports whether the host actually executed a queued command and whether to continue processing.
2497
2780
  *
@@ -2499,7 +2782,7 @@ function createSessionRpc(connection, sessionId) {
2499
2782
  *
2500
2783
  * @returns Indicates whether the queued-command response was matched to a pending request.
2501
2784
  */
2502
- respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { sessionId, ...params })
2785
+ respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { ...params, sessionId })
2503
2786
  },
2504
2787
  /** @experimental */
2505
2788
  telemetry: {
@@ -2514,7 +2797,7 @@ function createSessionRpc(connection, sessionId) {
2514
2797
  *
2515
2798
  * @param params Feature override key/value pairs to attach to subsequent telemetry events from this session.
2516
2799
  */
2517
- setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { sessionId, ...params })
2800
+ setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { ...params, sessionId })
2518
2801
  },
2519
2802
  /** @experimental */
2520
2803
  ui: {
@@ -2525,7 +2808,7 @@ function createSessionRpc(connection, sessionId) {
2525
2808
  *
2526
2809
  * @returns Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
2527
2810
  */
2528
- ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { sessionId, ...params }),
2811
+ ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { ...params, sessionId }),
2529
2812
  /**
2530
2813
  * Requests structured input from a UI-capable client.
2531
2814
  *
@@ -2533,7 +2816,7 @@ function createSessionRpc(connection, sessionId) {
2533
2816
  *
2534
2817
  * @returns The elicitation response (accept with form values, decline, or cancel)
2535
2818
  */
2536
- elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
2819
+ elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { ...params, sessionId }),
2537
2820
  /**
2538
2821
  * Provides the user response for a pending elicitation request.
2539
2822
  *
@@ -2541,7 +2824,7 @@ function createSessionRpc(connection, sessionId) {
2541
2824
  *
2542
2825
  * @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
2543
2826
  */
2544
- handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params }),
2827
+ handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { ...params, sessionId }),
2545
2828
  /**
2546
2829
  * Resolves a pending `user_input.requested` event with the user's response.
2547
2830
  *
@@ -2549,7 +2832,7 @@ function createSessionRpc(connection, sessionId) {
2549
2832
  *
2550
2833
  * @returns Indicates whether the pending UI request was resolved by this call.
2551
2834
  */
2552
- handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { sessionId, ...params }),
2835
+ handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { ...params, sessionId }),
2553
2836
  /**
2554
2837
  * Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
2555
2838
  *
@@ -2557,7 +2840,7 @@ function createSessionRpc(connection, sessionId) {
2557
2840
  *
2558
2841
  * @returns Indicates whether the pending UI request was resolved by this call.
2559
2842
  */
2560
- handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { sessionId, ...params }),
2843
+ handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { ...params, sessionId }),
2561
2844
  /**
2562
2845
  * Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
2563
2846
  *
@@ -2565,7 +2848,7 @@ function createSessionRpc(connection, sessionId) {
2565
2848
  *
2566
2849
  * @returns Indicates whether the pending UI request was resolved by this call.
2567
2850
  */
2568
- handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { sessionId, ...params }),
2851
+ handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { ...params, sessionId }),
2569
2852
  /**
2570
2853
  * Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
2571
2854
  *
@@ -2573,7 +2856,7 @@ function createSessionRpc(connection, sessionId) {
2573
2856
  *
2574
2857
  * @returns Indicates whether the pending UI request was resolved by this call.
2575
2858
  */
2576
- handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { sessionId, ...params }),
2859
+ handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { ...params, sessionId }),
2577
2860
  /**
2578
2861
  * Resolves a pending `exit_plan_mode.requested` event with the user's response.
2579
2862
  *
@@ -2581,7 +2864,7 @@ function createSessionRpc(connection, sessionId) {
2581
2864
  *
2582
2865
  * @returns Indicates whether the pending UI request was resolved by this call.
2583
2866
  */
2584
- handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { sessionId, ...params }),
2867
+ handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { ...params, sessionId }),
2585
2868
  /**
2586
2869
  * Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
2587
2870
  *
@@ -2595,7 +2878,7 @@ function createSessionRpc(connection, sessionId) {
2595
2878
  *
2596
2879
  * @returns Indicates whether the handle was active and the registration count was decremented.
2597
2880
  */
2598
- unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { sessionId, ...params })
2881
+ unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { ...params, sessionId })
2599
2882
  },
2600
2883
  /** @experimental */
2601
2884
  permissions: {
@@ -2606,7 +2889,7 @@ function createSessionRpc(connection, sessionId) {
2606
2889
  *
2607
2890
  * @returns Indicates whether the operation succeeded.
2608
2891
  */
2609
- configure: async (params) => connection.sendRequest("session.permissions.configure", { sessionId, ...params }),
2892
+ configure: async (params) => connection.sendRequest("session.permissions.configure", { ...params, sessionId }),
2610
2893
  /**
2611
2894
  * Provides a decision for a pending tool permission request.
2612
2895
  *
@@ -2614,7 +2897,7 @@ function createSessionRpc(connection, sessionId) {
2614
2897
  *
2615
2898
  * @returns Indicates whether the permission decision was applied; false when the request was already resolved.
2616
2899
  */
2617
- handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params }),
2900
+ handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { ...params, sessionId }),
2618
2901
  /**
2619
2902
  * Reconstructs the set of pending tool permission requests from the session's event history.
2620
2903
  *
@@ -2628,7 +2911,7 @@ function createSessionRpc(connection, sessionId) {
2628
2911
  *
2629
2912
  * @returns Indicates whether the operation succeeded.
2630
2913
  */
2631
- setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { sessionId, ...params }),
2914
+ setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { ...params, sessionId }),
2632
2915
  /**
2633
2916
  * Sets the permission mode for the session. `manual` follows the normal approval flow, `assisted` attaches LLM safety recommendations, and `allow-all` automatically approves permission requests. The result returns the authoritative post-mutation mode so callers can update local state without racing the `session.permissions_changed` notification.
2634
2917
  *
@@ -2636,7 +2919,7 @@ function createSessionRpc(connection, sessionId) {
2636
2919
  *
2637
2920
  * @returns Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
2638
2921
  */
2639
- setMode: async (params) => connection.sendRequest("session.permissions.setMode", { sessionId, ...params }),
2922
+ setMode: async (params) => connection.sendRequest("session.permissions.setMode", { ...params, sessionId }),
2640
2923
  /**
2641
2924
  * Returns the current permission mode for the session.
2642
2925
  *
@@ -2650,7 +2933,7 @@ function createSessionRpc(connection, sessionId) {
2650
2933
  *
2651
2934
  * @returns Indicates whether the operation succeeded.
2652
2935
  */
2653
- modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { sessionId, ...params }),
2936
+ modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { ...params, sessionId }),
2654
2937
  /**
2655
2938
  * Sets whether the client wants permission prompts bridged into session events.
2656
2939
  *
@@ -2658,7 +2941,7 @@ function createSessionRpc(connection, sessionId) {
2658
2941
  *
2659
2942
  * @returns Indicates whether the operation succeeded.
2660
2943
  */
2661
- setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
2944
+ setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { ...params, sessionId }),
2662
2945
  /**
2663
2946
  * Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
2664
2947
  *
@@ -2666,7 +2949,7 @@ function createSessionRpc(connection, sessionId) {
2666
2949
  *
2667
2950
  * @returns Indicates whether the operation succeeded.
2668
2951
  */
2669
- resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId, ...params }),
2952
+ resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { ...params, sessionId }),
2670
2953
  /**
2671
2954
  * Notifies the runtime that a permission prompt UI has been shown to the user.
2672
2955
  *
@@ -2674,7 +2957,7 @@ function createSessionRpc(connection, sessionId) {
2674
2957
  *
2675
2958
  * @returns Indicates whether the operation succeeded.
2676
2959
  */
2677
- notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { sessionId, ...params }),
2960
+ notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { ...params, sessionId }),
2678
2961
  /** @experimental */
2679
2962
  paths: {
2680
2963
  /**
@@ -2690,7 +2973,7 @@ function createSessionRpc(connection, sessionId) {
2690
2973
  *
2691
2974
  * @returns Indicates whether the operation succeeded.
2692
2975
  */
2693
- add: async (params) => connection.sendRequest("session.permissions.paths.add", { sessionId, ...params }),
2976
+ add: async (params) => connection.sendRequest("session.permissions.paths.add", { ...params, sessionId }),
2694
2977
  /**
2695
2978
  * Updates the session's primary working directory used by the permission policy.
2696
2979
  *
@@ -2698,7 +2981,7 @@ function createSessionRpc(connection, sessionId) {
2698
2981
  *
2699
2982
  * @returns Indicates whether the operation succeeded.
2700
2983
  */
2701
- updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { sessionId, ...params }),
2984
+ updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { ...params, sessionId }),
2702
2985
  /**
2703
2986
  * Reports whether a path falls within any of the session's allowed directories.
2704
2987
  *
@@ -2706,7 +2989,7 @@ function createSessionRpc(connection, sessionId) {
2706
2989
  *
2707
2990
  * @returns Indicates whether the supplied path is within the session's allowed directories.
2708
2991
  */
2709
- isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { sessionId, ...params }),
2992
+ isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { ...params, sessionId }),
2710
2993
  /**
2711
2994
  * Reports whether a path falls within the session's workspace (primary) directory.
2712
2995
  *
@@ -2714,7 +2997,7 @@ function createSessionRpc(connection, sessionId) {
2714
2997
  *
2715
2998
  * @returns Indicates whether the supplied path is within the session's workspace directory.
2716
2999
  */
2717
- isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { sessionId, ...params })
3000
+ isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { ...params, sessionId })
2718
3001
  },
2719
3002
  /** @experimental */
2720
3003
  locations: {
@@ -2725,7 +3008,7 @@ function createSessionRpc(connection, sessionId) {
2725
3008
  *
2726
3009
  * @returns Resolved location-permissions key and type.
2727
3010
  */
2728
- resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { sessionId, ...params }),
3011
+ resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { ...params, sessionId }),
2729
3012
  /**
2730
3013
  * Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
2731
3014
  *
@@ -2733,7 +3016,7 @@ function createSessionRpc(connection, sessionId) {
2733
3016
  *
2734
3017
  * @returns Summary of persisted location permissions applied to the session.
2735
3018
  */
2736
- apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { sessionId, ...params }),
3019
+ apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { ...params, sessionId }),
2737
3020
  /**
2738
3021
  * Persists a tool approval for a permission location and applies its rules to this session's live permission service.
2739
3022
  *
@@ -2741,7 +3024,7 @@ function createSessionRpc(connection, sessionId) {
2741
3024
  *
2742
3025
  * @returns Indicates whether the operation succeeded.
2743
3026
  */
2744
- addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { sessionId, ...params })
3027
+ addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { ...params, sessionId })
2745
3028
  },
2746
3029
  /** @experimental */
2747
3030
  folderTrust: {
@@ -2752,7 +3035,7 @@ function createSessionRpc(connection, sessionId) {
2752
3035
  *
2753
3036
  * @returns Folder trust check result.
2754
3037
  */
2755
- isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { sessionId, ...params }),
3038
+ isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { ...params, sessionId }),
2756
3039
  /**
2757
3040
  * Adds a folder to the user's trusted folders list.
2758
3041
  *
@@ -2760,7 +3043,7 @@ function createSessionRpc(connection, sessionId) {
2760
3043
  *
2761
3044
  * @returns Indicates whether the operation succeeded.
2762
3045
  */
2763
- addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { sessionId, ...params })
3046
+ addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { ...params, sessionId })
2764
3047
  },
2765
3048
  /** @experimental */
2766
3049
  urls: {
@@ -2771,7 +3054,7 @@ function createSessionRpc(connection, sessionId) {
2771
3054
  *
2772
3055
  * @returns Indicates whether the operation succeeded.
2773
3056
  */
2774
- setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { sessionId, ...params })
3057
+ setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { ...params, sessionId })
2775
3058
  }
2776
3059
  },
2777
3060
  /**
@@ -2783,7 +3066,7 @@ function createSessionRpc(connection, sessionId) {
2783
3066
  *
2784
3067
  * @experimental
2785
3068
  */
2786
- log: async (params) => connection.sendRequest("session.log", { sessionId, ...params }),
3069
+ log: async (params) => connection.sendRequest("session.log", { ...params, sessionId }),
2787
3070
  /** @experimental */
2788
3071
  metadata: {
2789
3072
  /**
@@ -2805,7 +3088,7 @@ function createSessionRpc(connection, sessionId) {
2805
3088
  *
2806
3089
  * @returns Client-owned, case-sensitive string metadata persisted with a local session. Clients should namespace keys by owner. Keys must be non-empty and at most 256 UTF-8 bytes; keys under `copilot/` and `github/` are reserved. Values may contain at most 16 KiB of UTF-8 data. A bag may contain at most 128 entries and its serialized sidecar may contain at most 64 KiB. The runtime stores but never interprets these values.
2807
3090
  */
2808
- updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { sessionId, ...params }),
3091
+ updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { ...params, sessionId }),
2809
3092
  /**
2810
3093
  * Reports whether the local session is currently processing user/agent messages.
2811
3094
  *
@@ -2825,7 +3108,7 @@ function createSessionRpc(connection, sessionId) {
2825
3108
  *
2826
3109
  * @returns Token breakdown for the session's current context window, or null if uninitialized.
2827
3110
  */
2828
- contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { sessionId, ...params }),
3111
+ contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { ...params, sessionId }),
2829
3112
  /**
2830
3113
  * Returns the experimental per-source attribution breakdown of the session's current context window as a flat list of entries (skills, subagents, MCP servers, built-in tools, plugin rollups, system/tool-definition costs, with nesting via parentId), plus the successful compaction count. The heaviest individual messages are available separately via `metadata.getContextHeaviestMessages`. Returns null until the session has initialized its system prompt and tool metadata.
2831
3114
  *
@@ -2839,7 +3122,7 @@ function createSessionRpc(connection, sessionId) {
2839
3122
  *
2840
3123
  * @returns The heaviest individual messages in the session's context window, most-expensive first.
2841
3124
  */
2842
- getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { sessionId, ...params }),
3125
+ getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { ...params, sessionId }),
2843
3126
  /**
2844
3127
  * Records a working-directory/git context change and emits a `session.context_changed` event. For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event): a local session's working directory is authoritative and is moved via `metadata.setWorkingDirectory` (or an SDK `session.resume` that supplies a `workingDirectory`), not by this method.
2845
3128
  *
@@ -2847,7 +3130,7 @@ function createSessionRpc(connection, sessionId) {
2847
3130
  *
2848
3131
  * @returns Notify the session that its working directory context has changed. Emits a `session.context_changed` event so consumers (telemetry, OTel tracker, ACP, the timeline UI) can react. Use this when the host has detected a cwd/branch/repo change outside the session's normal lifecycle (e.g., after a shell command in interactive mode). For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event); move a local session's working directory via `metadata.setWorkingDirectory` instead.
2849
3132
  */
2850
- recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
3133
+ recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { ...params, sessionId }),
2851
3134
  /**
2852
3135
  * Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
2853
3136
  *
@@ -2855,7 +3138,7 @@ function createSessionRpc(connection, sessionId) {
2855
3138
  *
2856
3139
  * @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
2857
3140
  */
2858
- setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { sessionId, ...params }),
3141
+ setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { ...params, sessionId }),
2859
3142
  /**
2860
3143
  * Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
2861
3144
  *
@@ -2863,7 +3146,7 @@ function createSessionRpc(connection, sessionId) {
2863
3146
  *
2864
3147
  * @returns Re-tokenize the session's existing messages against `modelId` and return the token totals. Useful for hosts that want an initial estimate of context usage on session resume, before the next agent turn fires `session.context_info_changed` events. Returns zeros for an empty session.
2865
3148
  */
2866
- recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { sessionId, ...params })
3149
+ recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { ...params, sessionId })
2867
3150
  },
2868
3151
  /** @experimental */
2869
3152
  contentExclusion: {
@@ -2874,18 +3157,18 @@ function createSessionRpc(connection, sessionId) {
2874
3157
  *
2875
3158
  * @returns Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
2876
3159
  */
2877
- checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { sessionId, ...params })
3160
+ checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { ...params, sessionId })
2878
3161
  },
2879
3162
  /** @experimental */
2880
3163
  shell: {
2881
3164
  /**
2882
- * Starts a shell command and streams output through session notifications. The command runs as the leader of its own process group (POSIX) or in a dedicated job object (Windows), so a forced termination — via "shell.kill", the request timeout, or session disposal — signals that whole group/job rather than only the direct child. Two gaps are worth planning for: a command that exits on its own does not trigger that teardown, and on POSIX a descendant that moves itself into a new session or process group (for example via "setsid") leaves the signalled group, so either can leave a background process running.
3165
+ * Starts a shell command, returning an RPC error if it cannot be spawned. The command runs as the leader of its own process group (POSIX) or in a dedicated job object (Windows), so a forced termination — via "shell.kill", the request timeout, or session disposal — signals that whole group/job rather than only the direct child. Two gaps are worth planning for: a command that exits on its own does not trigger that teardown, and on POSIX a descendant that moves itself into a new session or process group (for example via "setsid") leaves the signalled group, so either can leave a background process running.
2883
3166
  *
2884
- * @param params Shell command to run, with optional working directory and timeout in milliseconds.
3167
+ * @param params Shell command to run, with optional working directory and timeout in milliseconds. Spawn failures return an RPC error.
2885
3168
  *
2886
- * @returns Identifier of the spawned process, used to correlate streamed output and exit notifications.
3169
+ * @returns Identifier of the spawned shell process, usable with shell.kill while the process is running.
2887
3170
  */
2888
- exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
3171
+ exec: async (params) => connection.sendRequest("session.shell.exec", { ...params, sessionId }),
2889
3172
  /**
2890
3173
  * Sends a signal to a shell process previously started via "shell.exec". The signal targets the command's whole process group (POSIX) or job object (Windows), so descendants still in that group are signalled too, not just the direct child. On POSIX a descendant that moved itself into a new session or process group (for example via "setsid") is no longer in the signalled group and survives.
2891
3174
  *
@@ -2893,7 +3176,7 @@ function createSessionRpc(connection, sessionId) {
2893
3176
  *
2894
3177
  * @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
2895
3178
  */
2896
- kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params }),
3179
+ kill: async (params) => connection.sendRequest("session.shell.kill", { ...params, sessionId }),
2897
3180
  /**
2898
3181
  * Executes a user-requested shell command through the session runtime.
2899
3182
  *
@@ -2901,7 +3184,7 @@ function createSessionRpc(connection, sessionId) {
2901
3184
  *
2902
3185
  * @returns Result of a user-requested shell command.
2903
3186
  */
2904
- executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { sessionId, ...params }),
3187
+ executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { ...params, sessionId }),
2905
3188
  /**
2906
3189
  * Cancels a user-requested shell command by request ID.
2907
3190
  *
@@ -2909,7 +3192,7 @@ function createSessionRpc(connection, sessionId) {
2909
3192
  *
2910
3193
  * @returns Cancellation result for a user-requested shell command.
2911
3194
  */
2912
- cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { sessionId, ...params })
3195
+ cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { ...params, sessionId })
2913
3196
  },
2914
3197
  /** @experimental */
2915
3198
  history: {
@@ -2920,7 +3203,7 @@ function createSessionRpc(connection, sessionId) {
2920
3203
  *
2921
3204
  * @returns Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
2922
3205
  */
2923
- compact: async (params) => connection.sendRequest("session.history.compact", { sessionId, ...params }),
3206
+ compact: async (params) => connection.sendRequest("session.history.compact", { ...params, sessionId }),
2924
3207
  /**
2925
3208
  * Truncates persisted session history to a specific event.
2926
3209
  *
@@ -2928,7 +3211,7 @@ function createSessionRpc(connection, sessionId) {
2928
3211
  *
2929
3212
  * @returns Number of events that were removed by the truncation.
2930
3213
  */
2931
- truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params }),
3214
+ truncate: async (params) => connection.sendRequest("session.history.truncate", { ...params, sessionId }),
2932
3215
  /**
2933
3216
  * Lists the user turns that the session can rewind to. Never rejects for a busy session: rewind reads need the session's file-change captures to be settled, so a session that still holds active work answers with `unavailableReason: "session-busy"` and no points, which the caller can retry.
2934
3217
  *
@@ -2942,7 +3225,7 @@ function createSessionRpc(connection, sessionId) {
2942
3225
  *
2943
3226
  * @returns Files and aggregate changes for a prospective rewind.
2944
3227
  */
2945
- previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { sessionId, ...params }),
3228
+ previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { ...params, sessionId }),
2946
3229
  /**
2947
3230
  * Rewinds the session conversation, optionally restoring files changed by the discarded turns. Not crash-atomic: file restore and conversation truncation are separate stores, applied in that order, so a process crash between them can leave the workspace rewound while the conversation still contains the discarded turns. There is no recovery journal; re-running the same rewind is the recovery path for a crash before truncation lands, since file restore is idempotent (already-restored files are reported as skipped) and truncation is re-derived from the still-retained boundary event. After truncation lands that boundary no longer exists, so the same request is rejected; the only stage that can still be outstanding is snapshot pruning, whose failure leaves orphan snapshots the capture store tolerates. The reverse inconsistency cannot occur, because truncation is never applied before file restore succeeds.
2948
3231
  *
@@ -2950,7 +3233,7 @@ function createSessionRpc(connection, sessionId) {
2950
3233
  *
2951
3234
  * @returns Structured outcome of a rewind request.
2952
3235
  */
2953
- rewind: async (params) => connection.sendRequest("session.history.rewind", { sessionId, ...params }),
3236
+ rewind: async (params) => connection.sendRequest("session.history.rewind", { ...params, sessionId }),
2954
3237
  /**
2955
3238
  * Cancels any in-progress background compaction on a local session.
2956
3239
  *
@@ -2976,7 +3259,7 @@ function createSessionRpc(connection, sessionId) {
2976
3259
  *
2977
3260
  * @returns What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
2978
3261
  */
2979
- clearContext: async (params) => connection.sendRequest("session.history.clearContext", { sessionId, ...params })
3262
+ clearContext: async (params) => connection.sendRequest("session.history.clearContext", { ...params, sessionId })
2980
3263
  },
2981
3264
  /** @experimental */
2982
3265
  queue: {
@@ -2993,7 +3276,7 @@ function createSessionRpc(connection, sessionId) {
2993
3276
  *
2994
3277
  * @returns Result of moving a queued item.
2995
3278
  */
2996
- moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { sessionId, ...params }),
3279
+ moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { ...params, sessionId }),
2997
3280
  /**
2998
3281
  * Inserts a new queued message at a public visible position.
2999
3282
  *
@@ -3001,7 +3284,7 @@ function createSessionRpc(connection, sessionId) {
3001
3284
  *
3002
3285
  * @returns Result of inserting a queued message.
3003
3286
  */
3004
- insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { sessionId, ...params }),
3287
+ insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { ...params, sessionId }),
3005
3288
  /**
3006
3289
  * Removes an addressable queued item by its stable id.
3007
3290
  *
@@ -3009,7 +3292,7 @@ function createSessionRpc(connection, sessionId) {
3009
3292
  *
3010
3293
  * @returns Result of removing a queued item.
3011
3294
  */
3012
- removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { sessionId, ...params }),
3295
+ removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { ...params, sessionId }),
3013
3296
  /**
3014
3297
  * Updates the text of an addressable single-message queue item.
3015
3298
  *
@@ -3017,7 +3300,7 @@ function createSessionRpc(connection, sessionId) {
3017
3300
  *
3018
3301
  * @returns Result of editing a queued message.
3019
3302
  */
3020
- updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
3303
+ updateText: async (params) => connection.sendRequest("session.queue.updateText", { ...params, sessionId }),
3021
3304
  /**
3022
3305
  * Atomically withdraws an unchanged user message of a local session: from the queued or steering lane while unconsumed, or from the running turn it started while the model has not answered it and nothing the user sent after it is pending. Withdrawing from the running turn interrupts that turn and removes its events from history. A client retaining the original draft may restore it only when removed is true.
3023
3306
  *
@@ -3025,7 +3308,7 @@ function createSessionRpc(connection, sessionId) {
3025
3308
  *
3026
3309
  * @returns Result of withdrawing a user message.
3027
3310
  */
3028
- withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
3311
+ withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { ...params, sessionId }),
3029
3312
  /**
3030
3313
  * Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
3031
3314
  *
@@ -3033,7 +3316,7 @@ function createSessionRpc(connection, sessionId) {
3033
3316
  *
3034
3317
  * @returns Result of editing a queued message.
3035
3318
  */
3036
- appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { sessionId, ...params }),
3319
+ appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { ...params, sessionId }),
3037
3320
  /**
3038
3321
  * Duplicates an addressable queued item immediately after its source.
3039
3322
  *
@@ -3041,13 +3324,13 @@ function createSessionRpc(connection, sessionId) {
3041
3324
  *
3042
3325
  * @returns Result of duplicating a queued item.
3043
3326
  */
3044
- duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { sessionId, ...params }),
3327
+ duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { ...params, sessionId }),
3045
3328
  /**
3046
3329
  * Acquires or releases the queued-lane drain pause.
3047
3330
  *
3048
3331
  * @param params Parameters for acquiring or releasing the queued-lane drain pause. Acquisition is exclusive and non-idempotent: `paused: true` against an already-paused session fails with `queue_already_paused`. The pause is never released automatically — it is not tied to the caller's lifetime, so a client that exits without sending `paused: false` leaves the lane frozen. Release is unowned: `paused: false` clears the pause for any caller, including one that never acquired it.
3049
3332
  */
3050
- setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { sessionId, ...params }),
3333
+ setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { ...params, sessionId }),
3051
3334
  /**
3052
3335
  * Moves an addressable queued message into the live turn's steering lane.
3053
3336
  *
@@ -3055,7 +3338,7 @@ function createSessionRpc(connection, sessionId) {
3055
3338
  *
3056
3339
  * @returns Result of trying to steer a queued message into a live turn.
3057
3340
  */
3058
- sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { sessionId, ...params }),
3341
+ sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { ...params, sessionId }),
3059
3342
  /**
3060
3343
  * Removes the most recently queued user-facing item (LIFO).
3061
3344
  *
@@ -3076,7 +3359,7 @@ function createSessionRpc(connection, sessionId) {
3076
3359
  *
3077
3360
  * @returns Batch of session events returned by a read, with cursor and continuation metadata.
3078
3361
  */
3079
- read: async (params) => connection.sendRequest("session.eventLog.read", { sessionId, ...params }),
3362
+ read: async (params) => connection.sendRequest("session.eventLog.read", { ...params, sessionId }),
3080
3363
  /**
3081
3364
  * Returns a snapshot of the current tail cursor without consuming events.
3082
3365
  *
@@ -3090,7 +3373,7 @@ function createSessionRpc(connection, sessionId) {
3090
3373
  *
3091
3374
  * @returns Opaque handle representing an event-type interest registration.
3092
3375
  */
3093
- registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { sessionId, ...params }),
3376
+ registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { ...params, sessionId }),
3094
3377
  /**
3095
3378
  * Releases a consumer's previously-registered interest in an event type.
3096
3379
  *
@@ -3098,7 +3381,7 @@ function createSessionRpc(connection, sessionId) {
3098
3381
  *
3099
3382
  * @returns Indicates whether the operation succeeded.
3100
3383
  */
3101
- releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { sessionId, ...params })
3384
+ releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { ...params, sessionId })
3102
3385
  },
3103
3386
  /** @experimental */
3104
3387
  usage: {
@@ -3118,7 +3401,7 @@ function createSessionRpc(connection, sessionId) {
3118
3401
  *
3119
3402
  * @returns Prediction result. Available results include prediction details; unavailable results include an explicit reason.
3120
3403
  */
3121
- predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { sessionId, ...params })
3404
+ predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { ...params, sessionId })
3122
3405
  },
3123
3406
  /** @experimental */
3124
3407
  remote: {
@@ -3129,7 +3412,7 @@ function createSessionRpc(connection, sessionId) {
3129
3412
  *
3130
3413
  * @returns GitHub URL for the session and a flag indicating whether remote steering is enabled.
3131
3414
  */
3132
- enable: async (params) => connection.sendRequest("session.remote.enable", { sessionId, ...params }),
3415
+ enable: async (params) => connection.sendRequest("session.remote.enable", { ...params, sessionId }),
3133
3416
  /**
3134
3417
  * Disables remote session export and steering.
3135
3418
  */
@@ -3141,7 +3424,7 @@ function createSessionRpc(connection, sessionId) {
3141
3424
  *
3142
3425
  * @returns Persist a steerability change as a `session.remote_steerable_changed` event. Used by the host (CLI / SDK consumer) when it has just finished enabling or disabling steering on a remote exporter that the runtime does not directly own.
3143
3426
  */
3144
- notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
3427
+ notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { ...params, sessionId })
3145
3428
  },
3146
3429
  /** @experimental */
3147
3430
  visibility: {
@@ -3158,7 +3441,7 @@ function createSessionRpc(connection, sessionId) {
3158
3441
  *
3159
3442
  * @returns Effective sharing status and shareable GitHub URL after updating session visibility.
3160
3443
  */
3161
- set: async (params) => connection.sendRequest("session.visibility.set", { sessionId, ...params })
3444
+ set: async (params) => connection.sendRequest("session.visibility.set", { ...params, sessionId })
3162
3445
  },
3163
3446
  /** @experimental */
3164
3447
  schedule: {
@@ -3175,7 +3458,7 @@ function createSessionRpc(connection, sessionId) {
3175
3458
  *
3176
3459
  * @returns Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
3177
3460
  */
3178
- stop: async (params) => connection.sendRequest("session.schedule.stop", { sessionId, ...params })
3461
+ stop: async (params) => connection.sendRequest("session.schedule.stop", { ...params, sessionId })
3179
3462
  }
3180
3463
  };
3181
3464
  }
@@ -3188,7 +3471,7 @@ function createInternalSessionRpc(connection, sessionId) {
3188
3471
  *
3189
3472
  * @experimental
3190
3473
  */
3191
- sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { sessionId, ...params }),
3474
+ sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { ...params, sessionId }),
3192
3475
  /** @experimental */
3193
3476
  gitHubAuth: {
3194
3477
  /**
@@ -3216,13 +3499,13 @@ function createInternalSessionRpc(connection, sessionId) {
3216
3499
  *
3217
3500
  * @returns Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
3218
3501
  */
3219
- login: async (params) => connection.sendRequest("session.gitHubAuth.login", { sessionId, ...params }),
3502
+ login: async (params) => connection.sendRequest("session.gitHubAuth.login", { ...params, sessionId }),
3220
3503
  /**
3221
3504
  * Switches the session to another available authentication.
3222
3505
  *
3223
3506
  * @param params Parameters for switching the session's active authentication.
3224
3507
  */
3225
- switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { sessionId, ...params }),
3508
+ switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { ...params, sessionId }),
3226
3509
  /**
3227
3510
  * Logs out the session's current GitHub authentication.
3228
3511
  *
@@ -3236,7 +3519,7 @@ function createInternalSessionRpc(connection, sessionId) {
3236
3519
  *
3237
3520
  * @returns Whether the requested authentication was logged out.
3238
3521
  */
3239
- logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { sessionId, ...params }),
3522
+ logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { ...params, sessionId }),
3240
3523
  /**
3241
3524
  * Gets validation errors from the most recent authentication attempt.
3242
3525
  *
@@ -3253,13 +3536,13 @@ function createInternalSessionRpc(connection, sessionId) {
3253
3536
  *
3254
3537
  * @param params Internal canvas provider registration parameters.
3255
3538
  */
3256
- register: async (params) => connection.sendRequest("session.canvas.provider.register", { sessionId, ...params }),
3539
+ register: async (params) => connection.sendRequest("session.canvas.provider.register", { ...params, sessionId }),
3257
3540
  /**
3258
3541
  * Unregisters an internal canvas provider connection.
3259
3542
  *
3260
3543
  * @param params Internal canvas provider unregistration parameters.
3261
3544
  */
3262
- unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { sessionId, ...params })
3545
+ unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { ...params, sessionId })
3263
3546
  }
3264
3547
  },
3265
3548
  /** @experimental */
@@ -3271,7 +3554,7 @@ function createInternalSessionRpc(connection, sessionId) {
3271
3554
  *
3272
3555
  * @returns Complete current or terminal workflow run envelope.
3273
3556
  */
3274
- runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { sessionId, ...params }),
3557
+ runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { ...params, sessionId }),
3275
3558
  /**
3276
3559
  * Internal tool-originated dynamic workflow resume.
3277
3560
  *
@@ -3279,13 +3562,13 @@ function createInternalSessionRpc(connection, sessionId) {
3279
3562
  *
3280
3563
  * @returns Resolved persisted workflow identity and resumed run envelope.
3281
3564
  */
3282
- resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { sessionId, ...params }),
3565
+ resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { ...params, sessionId }),
3283
3566
  /**
3284
3567
  * Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
3285
3568
  *
3286
3569
  * @param params Parameters for an owned durable pause checkpoint.
3287
3570
  */
3288
- pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { sessionId, ...params })
3571
+ pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { ...params, sessionId })
3289
3572
  },
3290
3573
  /** @experimental */
3291
3574
  model: {
@@ -3296,10 +3579,16 @@ function createInternalSessionRpc(connection, sessionId) {
3296
3579
  *
3297
3580
  * @returns The model identifier active on the session after the switch.
3298
3581
  */
3299
- applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { sessionId, ...params })
3582
+ applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { ...params, sessionId })
3300
3583
  },
3301
3584
  /** @experimental */
3302
3585
  mcp: {
3586
+ /**
3587
+ * Records the IDE the host is connected to, so the agent's system prompt can name it and its workspace folder. Null or an omitted `ide` clears the recorded value, which is how a host reports that it is disconnected; there is no separate clear method. Both `ideName` and `workspaceFolder` are required together, because half a state cannot be attributed to a project.
3588
+ *
3589
+ * @param params Records which IDE the host is connected to, or clears it.
3590
+ */
3591
+ setConnectedIdeInfo: async (params) => connection.sendRequest("session.mcp.setConnectedIdeInfo", { ...params, sessionId }),
3303
3592
  /**
3304
3593
  * Reloads MCP server connections for the session with an explicit host-provided configuration.
3305
3594
  *
@@ -3307,7 +3596,7 @@ function createInternalSessionRpc(connection, sessionId) {
3307
3596
  *
3308
3597
  * @returns MCP server startup filtering result.
3309
3598
  */
3310
- reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { sessionId, ...params }),
3599
+ reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { ...params, sessionId }),
3311
3600
  /**
3312
3601
  * Configures the built-in GitHub MCP server for the session's current auth context.
3313
3602
  *
@@ -3315,19 +3604,19 @@ function createInternalSessionRpc(connection, sessionId) {
3315
3604
  *
3316
3605
  * @returns Result of configuring GitHub MCP.
3317
3606
  */
3318
- configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { sessionId, ...params }),
3607
+ configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { ...params, sessionId }),
3319
3608
  /**
3320
3609
  * Registers a pre-connected external MCP client (e.g. IDE) on the session's host. The caller retains lifecycle ownership of the client and transport. Marked internal because the `client` and `transport` arguments are in-process MCP SDK instances that cannot be serialized across the JSON-RPC boundary; once the CLI moves on top of the SDK, external clients will be expressed as transport configs the runtime can construct itself.
3321
3610
  *
3322
3611
  * @param params Registration parameters for an external MCP client.
3323
3612
  */
3324
- registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { sessionId, ...params }),
3613
+ registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { ...params, sessionId }),
3325
3614
  /**
3326
3615
  * Unregisters a previously registered external MCP client by server name. Marked internal as the paired companion of `registerExternalClient`: only in-process callers that registered a client this way can meaningfully unregister it. Disappears alongside `registerExternalClient`: once external clients are described to the runtime as config rather than handed in as instances, lifecycle (including deregistration) is owned entirely by the runtime.
3327
3616
  *
3328
3617
  * @param params Server name identifying the external client to remove.
3329
3618
  */
3330
- unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
3619
+ unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { ...params, sessionId })
3331
3620
  },
3332
3621
  /** @experimental */
3333
3622
  connectors: {
@@ -3338,7 +3627,7 @@ function createInternalSessionRpc(connection, sessionId) {
3338
3627
  *
3339
3628
  * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
3340
3629
  */
3341
- reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
3630
+ reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { ...params, sessionId }),
3342
3631
  /**
3343
3632
  * Removes the runtime-owned Connector MCP projection without changing service-side connections.
3344
3633
  *
@@ -3355,7 +3644,34 @@ function createInternalSessionRpc(connection, sessionId) {
3355
3644
  *
3356
3645
  * @returns Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
3357
3646
  */
3358
- finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { sessionId, ...params })
3647
+ finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { ...params, sessionId })
3648
+ },
3649
+ /** @experimental */
3650
+ ui: {
3651
+ /**
3652
+ * Resolves a pending elicitation request after direct interaction in the trusted in-process client. Only an accepted response to the built-in ask_user tool can become trusted human evidence.
3653
+ *
3654
+ * @param params Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
3655
+ *
3656
+ * @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
3657
+ */
3658
+ handleHumanAskUser: async (params) => connection.sendRequest("session.ui.handleHumanAskUser", { ...params, sessionId }),
3659
+ /**
3660
+ * Resolves a pending `user_input.requested` event after direct interaction in the trusted in-process client.
3661
+ *
3662
+ * @param params Request ID of a pending `user_input.requested` event and the user's response.
3663
+ *
3664
+ * @returns Indicates whether the pending UI request was resolved by this call.
3665
+ */
3666
+ handleHumanUserInput: async (params) => connection.sendRequest("session.ui.handleHumanUserInput", { ...params, sessionId }),
3667
+ /**
3668
+ * Resolves a pending `exit_plan_mode.requested` event after direct interaction in the trusted in-process client.
3669
+ *
3670
+ * @param params Request ID of a pending `exit_plan_mode.requested` event and the user's response.
3671
+ *
3672
+ * @returns Indicates whether the pending UI request was resolved by this call.
3673
+ */
3674
+ handleHumanExitPlanMode: async (params) => connection.sendRequest("session.ui.handleHumanExitPlanMode", { ...params, sessionId })
3359
3675
  },
3360
3676
  /** @experimental */
3361
3677
  settings: {
@@ -3372,7 +3688,7 @@ function createInternalSessionRpc(connection, sessionId) {
3372
3688
  *
3373
3689
  * @returns Result of evaluating a Rust-owned settings predicate.
3374
3690
  */
3375
- evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { sessionId, ...params })
3691
+ evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { ...params, sessionId })
3376
3692
  },
3377
3693
  /** @experimental */
3378
3694
  queue: {
@@ -3395,7 +3711,7 @@ function createInternalSessionRpc(connection, sessionId) {
3395
3711
  *
3396
3712
  * @returns Whether a deferred-idle drain should run.
3397
3713
  */
3398
- beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { sessionId, ...params }),
3714
+ beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { ...params, sessionId }),
3399
3715
  /**
3400
3716
  * Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
3401
3717
  *
@@ -3403,13 +3719,13 @@ function createInternalSessionRpc(connection, sessionId) {
3403
3719
  *
3404
3720
  * @returns Action selected by the native deferred-idle drain.
3405
3721
  */
3406
- finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { sessionId, ...params }),
3722
+ finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { ...params, sessionId }),
3407
3723
  /**
3408
3724
  * Marks session.idle as deferred by native background work state.
3409
3725
  *
3410
3726
  * @param params Inputs for marking session.idle deferred in native state.
3411
3727
  */
3412
- deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { sessionId, ...params }),
3728
+ deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { ...params, sessionId }),
3413
3729
  /**
3414
3730
  * Consumes queued native system notifications matching an internal filter.
3415
3731
  *
@@ -3417,7 +3733,7 @@ function createInternalSessionRpc(connection, sessionId) {
3417
3733
  *
3418
3734
  * @returns Indicates whether a user-facing pending item was removed.
3419
3735
  */
3420
- consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { sessionId, ...params }),
3736
+ consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { ...params, sessionId }),
3421
3737
  /**
3422
3738
  * Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
3423
3739
  *
@@ -3448,7 +3764,7 @@ function createInternalSessionRpc(connection, sessionId) {
3448
3764
  *
3449
3765
  * @returns Result of registering or re-arming a scheduled prompt.
3450
3766
  */
3451
- add: async (params) => connection.sendRequest("session.schedule.add", { sessionId, ...params }),
3767
+ add: async (params) => connection.sendRequest("session.schedule.add", { ...params, sessionId }),
3452
3768
  /**
3453
3769
  * Registers a recurring cron scheduled prompt.
3454
3770
  *
@@ -3456,7 +3772,7 @@ function createInternalSessionRpc(connection, sessionId) {
3456
3772
  *
3457
3773
  * @returns Result of registering or re-arming a scheduled prompt.
3458
3774
  */
3459
- addCron: async (params) => connection.sendRequest("session.schedule.addCron", { sessionId, ...params }),
3775
+ addCron: async (params) => connection.sendRequest("session.schedule.addCron", { ...params, sessionId }),
3460
3776
  /**
3461
3777
  * Registers an absolute-time scheduled prompt.
3462
3778
  *
@@ -3464,7 +3780,7 @@ function createInternalSessionRpc(connection, sessionId) {
3464
3780
  *
3465
3781
  * @returns Result of registering or re-arming a scheduled prompt.
3466
3782
  */
3467
- addAt: async (params) => connection.sendRequest("session.schedule.addAt", { sessionId, ...params }),
3783
+ addAt: async (params) => connection.sendRequest("session.schedule.addAt", { ...params, sessionId }),
3468
3784
  /**
3469
3785
  * Registers a self-paced scheduled prompt.
3470
3786
  *
@@ -3472,7 +3788,7 @@ function createInternalSessionRpc(connection, sessionId) {
3472
3788
  *
3473
3789
  * @returns Result of registering or re-arming a scheduled prompt.
3474
3790
  */
3475
- addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { sessionId, ...params }),
3791
+ addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { ...params, sessionId }),
3476
3792
  /**
3477
3793
  * Re-arms an active self-paced scheduled prompt.
3478
3794
  *
@@ -3480,7 +3796,7 @@ function createInternalSessionRpc(connection, sessionId) {
3480
3796
  *
3481
3797
  * @returns Result of registering or re-arming a scheduled prompt.
3482
3798
  */
3483
- rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { sessionId, ...params })
3799
+ rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { ...params, sessionId })
3484
3800
  }
3485
3801
  };
3486
3802
  }
@@ -3510,11 +3826,21 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
3510
3826
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
3511
3827
  return handler.readFile(params);
3512
3828
  });
3829
+ connection.onRequest("sessionFs.readFileBytes", async (params) => {
3830
+ const handler = getHandlers(params.sessionId).sessionFs;
3831
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
3832
+ return handler.readFileBytes(params);
3833
+ });
3513
3834
  connection.onRequest("sessionFs.writeFile", async (params) => {
3514
3835
  const handler = getHandlers(params.sessionId).sessionFs;
3515
3836
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
3516
3837
  return handler.writeFile(params);
3517
3838
  });
3839
+ connection.onRequest("sessionFs.writeFileBytes", async (params) => {
3840
+ const handler = getHandlers(params.sessionId).sessionFs;
3841
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
3842
+ return handler.writeFileBytes(params);
3843
+ });
3518
3844
  connection.onRequest("sessionFs.appendFile", async (params) => {
3519
3845
  const handler = getHandlers(params.sessionId).sessionFs;
3520
3846
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);