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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1078,7 +1078,7 @@ function createSessionRpc(connection, sessionId) {
1078
1078
  *
1079
1079
  * @experimental
1080
1080
  */
1081
- send: async (params) => connection.sendRequest("session.send", { sessionId, ...params }),
1081
+ send: async (params) => connection.sendRequest("session.send", { ...params, sessionId }),
1082
1082
  /**
1083
1083
  * 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
1084
  *
@@ -1088,7 +1088,7 @@ function createSessionRpc(connection, sessionId) {
1088
1088
  *
1089
1089
  * @experimental
1090
1090
  */
1091
- sendMessages: async (params) => connection.sendRequest("session.sendMessages", { sessionId, ...params }),
1091
+ sendMessages: async (params) => connection.sendRequest("session.sendMessages", { ...params, sessionId }),
1092
1092
  /** @experimental */
1093
1093
  sandbox: {
1094
1094
  /**
@@ -1104,7 +1104,7 @@ function createSessionRpc(connection, sessionId) {
1104
1104
  *
1105
1105
  * @returns Result of attempting to disable sandboxing for the current session.
1106
1106
  */
1107
- disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params }),
1107
+ disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { ...params, sessionId }),
1108
1108
  /**
1109
1109
  * 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
1110
  *
@@ -1112,7 +1112,7 @@ function createSessionRpc(connection, sessionId) {
1112
1112
  *
1113
1113
  * @returns Result of accepting a sandbox path grant.
1114
1114
  */
1115
- grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { sessionId, ...params })
1115
+ grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { ...params, sessionId })
1116
1116
  },
1117
1117
  /**
1118
1118
  * Aborts the current agent turn.
@@ -1123,7 +1123,7 @@ function createSessionRpc(connection, sessionId) {
1123
1123
  *
1124
1124
  * @experimental
1125
1125
  */
1126
- abort: async (params) => connection.sendRequest("session.abort", { sessionId, ...params }),
1126
+ abort: async (params) => connection.sendRequest("session.abort", { ...params, sessionId }),
1127
1127
  /**
1128
1128
  * 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
1129
  *
@@ -1133,7 +1133,7 @@ function createSessionRpc(connection, sessionId) {
1133
1133
  *
1134
1134
  * @experimental
1135
1135
  */
1136
- interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { sessionId, ...params }),
1136
+ interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { ...params, sessionId }),
1137
1137
  /**
1138
1138
  * Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
1139
1139
  *
@@ -1149,7 +1149,7 @@ function createSessionRpc(connection, sessionId) {
1149
1149
  *
1150
1150
  * @experimental
1151
1151
  */
1152
- shutdown: async (params) => connection.sendRequest("session.shutdown", { sessionId, ...params }),
1152
+ shutdown: async (params) => connection.sendRequest("session.shutdown", { ...params, sessionId }),
1153
1153
  /** @experimental */
1154
1154
  gitHubAuth: {
1155
1155
  /**
@@ -1165,7 +1165,7 @@ function createSessionRpc(connection, sessionId) {
1165
1165
  *
1166
1166
  * @returns Indicates whether the credential update succeeded.
1167
1167
  */
1168
- setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { sessionId, ...params })
1168
+ setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { ...params, sessionId })
1169
1169
  },
1170
1170
  /** @experimental */
1171
1171
  accounts: {
@@ -1176,7 +1176,7 @@ function createSessionRpc(connection, sessionId) {
1176
1176
  *
1177
1177
  * @returns The enumerated collection, keyed by the same selector as the query.
1178
1178
  */
1179
- enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { sessionId, ...params }),
1179
+ enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { ...params, sessionId }),
1180
1180
  /**
1181
1181
  * Read one typed accounts datum: the active account, a neutral status summary, or the last authentication errors.
1182
1182
  *
@@ -1184,7 +1184,7 @@ function createSessionRpc(connection, sessionId) {
1184
1184
  *
1185
1185
  * @returns The read result, keyed by the same selector as the query.
1186
1186
  */
1187
- get: async (params) => connection.sendRequest("session.accounts.get", { sessionId, ...params }),
1187
+ get: async (params) => connection.sendRequest("session.accounts.get", { ...params, sessionId }),
1188
1188
  /**
1189
1189
  * Apply one non-interactive accounts mutation: switch the active account, log an account out, or set credentials from a token.
1190
1190
  *
@@ -1192,7 +1192,7 @@ function createSessionRpc(connection, sessionId) {
1192
1192
  *
1193
1193
  * @returns Result of a non-interactive accounts mutation.
1194
1194
  */
1195
- set: async (params) => connection.sendRequest("session.accounts.set", { sessionId, ...params }),
1195
+ set: async (params) => connection.sendRequest("session.accounts.set", { ...params, sessionId }),
1196
1196
  /** @experimental */
1197
1197
  login: {
1198
1198
  /**
@@ -1202,7 +1202,7 @@ function createSessionRpc(connection, sessionId) {
1202
1202
  *
1203
1203
  * @returns A started login flow: its opaque id and first step.
1204
1204
  */
1205
- begin: async (params) => connection.sendRequest("session.accounts.login.begin", { sessionId, ...params }),
1205
+ begin: async (params) => connection.sendRequest("session.accounts.login.begin", { ...params, sessionId }),
1206
1206
  /**
1207
1207
  * Advance an in-flight login flow, optionally fulfilling an input-required step, and return the next step.
1208
1208
  *
@@ -1210,13 +1210,13 @@ function createSessionRpc(connection, sessionId) {
1210
1210
  *
1211
1211
  * @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
1212
  */
1213
- advance: async (params) => connection.sendRequest("session.accounts.login.advance", { sessionId, ...params }),
1213
+ advance: async (params) => connection.sendRequest("session.accounts.login.advance", { ...params, sessionId }),
1214
1214
  /**
1215
1215
  * Cancel an in-flight login flow and release its resources.
1216
1216
  *
1217
1217
  * @param params Cancel an in-flight login flow.
1218
1218
  */
1219
- cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { sessionId, ...params })
1219
+ cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { ...params, sessionId })
1220
1220
  }
1221
1221
  },
1222
1222
  /** @experimental */
@@ -1228,7 +1228,7 @@ function createSessionRpc(connection, sessionId) {
1228
1228
  *
1229
1229
  * @returns Result of collecting a session debug bundle.
1230
1230
  */
1231
- collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
1231
+ collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { ...params, sessionId })
1232
1232
  },
1233
1233
  /** @experimental */
1234
1234
  canvas: {
@@ -1251,13 +1251,13 @@ function createSessionRpc(connection, sessionId) {
1251
1251
  *
1252
1252
  * @returns Open canvas instance snapshot.
1253
1253
  */
1254
- open: async (params) => connection.sendRequest("session.canvas.open", { sessionId, ...params }),
1254
+ open: async (params) => connection.sendRequest("session.canvas.open", { ...params, sessionId }),
1255
1255
  /**
1256
1256
  * Closes an open canvas instance.
1257
1257
  *
1258
1258
  * @param params Canvas close parameters.
1259
1259
  */
1260
- close: async (params) => connection.sendRequest("session.canvas.close", { sessionId, ...params }),
1260
+ close: async (params) => connection.sendRequest("session.canvas.close", { ...params, sessionId }),
1261
1261
  /** @experimental */
1262
1262
  action: {
1263
1263
  /**
@@ -1267,7 +1267,7 @@ function createSessionRpc(connection, sessionId) {
1267
1267
  *
1268
1268
  * @returns Canvas action invocation result.
1269
1269
  */
1270
- invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { sessionId, ...params })
1270
+ invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { ...params, sessionId })
1271
1271
  }
1272
1272
  },
1273
1273
  /** @experimental */
@@ -1279,7 +1279,7 @@ function createSessionRpc(connection, sessionId) {
1279
1279
  *
1280
1280
  * @returns Complete current or terminal workflow run envelope.
1281
1281
  */
1282
- run: async (params) => connection.sendRequest("session.workflow.run", { sessionId, ...params }),
1282
+ run: async (params) => connection.sendRequest("session.workflow.run", { ...params, sessionId }),
1283
1283
  /**
1284
1284
  * Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
1285
1285
  *
@@ -1287,7 +1287,7 @@ function createSessionRpc(connection, sessionId) {
1287
1287
  *
1288
1288
  * @returns Resolved persisted workflow identity and resumed run envelope.
1289
1289
  */
1290
- resume: async (params) => connection.sendRequest("session.workflow.resume", { sessionId, ...params }),
1290
+ resume: async (params) => connection.sendRequest("session.workflow.resume", { ...params, sessionId }),
1291
1291
  /**
1292
1292
  * Gets the current or settled envelope for a dynamic workflow run.
1293
1293
  *
@@ -1295,7 +1295,7 @@ function createSessionRpc(connection, sessionId) {
1295
1295
  *
1296
1296
  * @returns Complete current or terminal workflow run envelope.
1297
1297
  */
1298
- getRun: async (params) => connection.sendRequest("session.workflow.getRun", { sessionId, ...params }),
1298
+ getRun: async (params) => connection.sendRequest("session.workflow.getRun", { ...params, sessionId }),
1299
1299
  /**
1300
1300
  * Lists durable dynamic workflow runs for this session in creation order.
1301
1301
  *
@@ -1303,7 +1303,7 @@ function createSessionRpc(connection, sessionId) {
1303
1303
  *
1304
1304
  * @returns A page of workflow runs in durable creation order.
1305
1305
  */
1306
- listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { sessionId, ...params }),
1306
+ listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { ...params, sessionId }),
1307
1307
  /**
1308
1308
  * Gets durable and live observability detail for one dynamic workflow run.
1309
1309
  *
@@ -1311,7 +1311,7 @@ function createSessionRpc(connection, sessionId) {
1311
1311
  *
1312
1312
  * @returns Full workflow run observability detail.
1313
1313
  */
1314
- getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { sessionId, ...params }),
1314
+ getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { ...params, sessionId }),
1315
1315
  /**
1316
1316
  * Pages durable progress for one dynamic workflow run.
1317
1317
  *
@@ -1319,7 +1319,7 @@ function createSessionRpc(connection, sessionId) {
1319
1319
  *
1320
1320
  * @returns A bidirectional page of workflow progress.
1321
1321
  */
1322
- getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { sessionId, ...params }),
1322
+ getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { ...params, sessionId }),
1323
1323
  /**
1324
1324
  * Requests cancellation of a dynamic workflow run and returns its run envelope.
1325
1325
  *
@@ -1327,7 +1327,7 @@ function createSessionRpc(connection, sessionId) {
1327
1327
  *
1328
1328
  * @returns Complete current or terminal workflow run envelope.
1329
1329
  */
1330
- cancel: async (params) => connection.sendRequest("session.workflow.cancel", { sessionId, ...params }),
1330
+ cancel: async (params) => connection.sendRequest("session.workflow.cancel", { ...params, sessionId }),
1331
1331
  /**
1332
1332
  * Pauses a running dynamic workflow and returns its settled run envelope.
1333
1333
  *
@@ -1335,7 +1335,7 @@ function createSessionRpc(connection, sessionId) {
1335
1335
  *
1336
1336
  * @returns Complete current or terminal workflow run envelope.
1337
1337
  */
1338
- pause: async (params) => connection.sendRequest("session.workflow.pause", { sessionId, ...params }),
1338
+ pause: async (params) => connection.sendRequest("session.workflow.pause", { ...params, sessionId }),
1339
1339
  /**
1340
1340
  * Records a batch of ordered dynamic workflow progress lines.
1341
1341
  *
@@ -1343,7 +1343,7 @@ function createSessionRpc(connection, sessionId) {
1343
1343
  *
1344
1344
  * @returns Acknowledgement that a workflow request was accepted.
1345
1345
  */
1346
- log: async (params) => connection.sendRequest("session.workflow.log", { sessionId, ...params }),
1346
+ log: async (params) => connection.sendRequest("session.workflow.log", { ...params, sessionId }),
1347
1347
  /**
1348
1348
  * Runs one dynamic-workflow-scoped subagent and returns its result.
1349
1349
  *
@@ -1351,7 +1351,7 @@ function createSessionRpc(connection, sessionId) {
1351
1351
  *
1352
1352
  * @returns Result of one workflow-scoped subagent call.
1353
1353
  */
1354
- agent: async (params) => connection.sendRequest("session.workflow.agent", { sessionId, ...params }),
1354
+ agent: async (params) => connection.sendRequest("session.workflow.agent", { ...params, sessionId }),
1355
1355
  /** @experimental */
1356
1356
  journal: {
1357
1357
  /**
@@ -1361,7 +1361,7 @@ function createSessionRpc(connection, sessionId) {
1361
1361
  *
1362
1362
  * @returns Result of reading a workflow journal entry.
1363
1363
  */
1364
- get: async (params) => connection.sendRequest("session.workflow.journal.get", { sessionId, ...params }),
1364
+ get: async (params) => connection.sendRequest("session.workflow.journal.get", { ...params, sessionId }),
1365
1365
  /**
1366
1366
  * Stores a memoized dynamic workflow journal entry.
1367
1367
  *
@@ -1369,7 +1369,7 @@ function createSessionRpc(connection, sessionId) {
1369
1369
  *
1370
1370
  * @returns Acknowledgement that a workflow request was accepted.
1371
1371
  */
1372
- put: async (params) => connection.sendRequest("session.workflow.journal.put", { sessionId, ...params })
1372
+ put: async (params) => connection.sendRequest("session.workflow.journal.put", { ...params, sessionId })
1373
1373
  }
1374
1374
  },
1375
1375
  /** @experimental */
@@ -1387,7 +1387,7 @@ function createSessionRpc(connection, sessionId) {
1387
1387
  *
1388
1388
  * @returns The model identifier active on the session after the switch.
1389
1389
  */
1390
- switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params }),
1390
+ switchTo: async (params) => connection.sendRequest("session.model.switchTo", { ...params, sessionId }),
1391
1391
  /**
1392
1392
  * 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
1393
  *
@@ -1395,7 +1395,7 @@ function createSessionRpc(connection, sessionId) {
1395
1395
  *
1396
1396
  * @returns Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
1397
1397
  */
1398
- switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { sessionId, ...params }),
1398
+ switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { ...params, sessionId }),
1399
1399
  /**
1400
1400
  * Replaces or clears the host-supplied model allowlist for a running session.
1401
1401
  *
@@ -1403,7 +1403,7 @@ function createSessionRpc(connection, sessionId) {
1403
1403
  *
1404
1404
  * @returns The applied host allowlist and effective session model policy after intersection.
1405
1405
  */
1406
- setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { sessionId, ...params }),
1406
+ setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { ...params, sessionId }),
1407
1407
  /**
1408
1408
  * Updates the session's reasoning effort without changing the selected model.
1409
1409
  *
@@ -1411,7 +1411,7 @@ function createSessionRpc(connection, sessionId) {
1411
1411
  *
1412
1412
  * @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
1413
  */
1414
- setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params }),
1414
+ setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { ...params, sessionId }),
1415
1415
  /**
1416
1416
  * 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
1417
  *
@@ -1419,7 +1419,7 @@ function createSessionRpc(connection, sessionId) {
1419
1419
  *
1420
1420
  * @returns The list of models available to this session.
1421
1421
  */
1422
- list: async (params) => connection.sendRequest("session.model.list", { sessionId, ...params })
1422
+ list: async (params) => connection.sendRequest("session.model.list", { ...params, sessionId })
1423
1423
  },
1424
1424
  /** @experimental */
1425
1425
  mode: {
@@ -1436,7 +1436,7 @@ function createSessionRpc(connection, sessionId) {
1436
1436
  *
1437
1437
  * @returns Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
1438
1438
  */
1439
- set: async (params) => connection.sendRequest("session.mode.set", { sessionId, ...params })
1439
+ set: async (params) => connection.sendRequest("session.mode.set", { ...params, sessionId })
1440
1440
  },
1441
1441
  /** @experimental */
1442
1442
  name: {
@@ -1451,7 +1451,7 @@ function createSessionRpc(connection, sessionId) {
1451
1451
  *
1452
1452
  * @param params New friendly name to apply to the session.
1453
1453
  */
1454
- set: async (params) => connection.sendRequest("session.name.set", { sessionId, ...params }),
1454
+ set: async (params) => connection.sendRequest("session.name.set", { ...params, sessionId }),
1455
1455
  /**
1456
1456
  * Persists an auto-generated session summary as the session's name when no user-set name exists.
1457
1457
  *
@@ -1459,7 +1459,7 @@ function createSessionRpc(connection, sessionId) {
1459
1459
  *
1460
1460
  * @returns Indicates whether the auto-generated summary was applied as the session's name.
1461
1461
  */
1462
- setAuto: async (params) => connection.sendRequest("session.name.setAuto", { sessionId, ...params })
1462
+ setAuto: async (params) => connection.sendRequest("session.name.setAuto", { ...params, sessionId })
1463
1463
  },
1464
1464
  /** @experimental */
1465
1465
  plan: {
@@ -1474,7 +1474,7 @@ function createSessionRpc(connection, sessionId) {
1474
1474
  *
1475
1475
  * @param params Replacement contents to write to the session plan file.
1476
1476
  */
1477
- update: async (params) => connection.sendRequest("session.plan.update", { sessionId, ...params }),
1477
+ update: async (params) => connection.sendRequest("session.plan.update", { ...params, sessionId }),
1478
1478
  /**
1479
1479
  * Deletes the session plan file from the workspace.
1480
1480
  */
@@ -1507,7 +1507,7 @@ function createSessionRpc(connection, sessionId) {
1507
1507
  *
1508
1508
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1509
1509
  */
1510
- updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { sessionId, ...params }),
1510
+ updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { ...params, sessionId }),
1511
1511
  /**
1512
1512
  * Ensures a local session workspace exists and returns it.
1513
1513
  *
@@ -1515,7 +1515,7 @@ function createSessionRpc(connection, sessionId) {
1515
1515
  *
1516
1516
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1517
1517
  */
1518
- ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { sessionId, ...params }),
1518
+ ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { ...params, sessionId }),
1519
1519
  /**
1520
1520
  * Lists files stored in the session workspace files directory.
1521
1521
  *
@@ -1529,13 +1529,13 @@ function createSessionRpc(connection, sessionId) {
1529
1529
  *
1530
1530
  * @returns Contents of the requested workspace file as a UTF-8 string.
1531
1531
  */
1532
- readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { sessionId, ...params }),
1532
+ readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { ...params, sessionId }),
1533
1533
  /**
1534
1534
  * Creates or overwrites a file in the session workspace files directory.
1535
1535
  *
1536
1536
  * @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
1537
1537
  */
1538
- createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
1538
+ createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { ...params, sessionId }),
1539
1539
  /**
1540
1540
  * Returns metadata for a file or directory in the session workspace files directory.
1541
1541
  *
@@ -1543,25 +1543,25 @@ function createSessionRpc(connection, sessionId) {
1543
1543
  *
1544
1544
  * @returns Filesystem metadata for a path in the session workspace files directory.
1545
1545
  */
1546
- statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
1546
+ statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { ...params, sessionId }),
1547
1547
  /**
1548
1548
  * Creates a directory in the session workspace files directory.
1549
1549
  *
1550
1550
  * @param params Directory to create within the session workspace files directory.
1551
1551
  */
1552
- createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
1552
+ createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { ...params, sessionId }),
1553
1553
  /**
1554
1554
  * Removes a file or directory from the session workspace files directory.
1555
1555
  *
1556
1556
  * @param params File or directory to remove from the session workspace files directory.
1557
1557
  */
1558
- removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
1558
+ removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { ...params, sessionId }),
1559
1559
  /**
1560
1560
  * Renames a file or directory within the session workspace files directory.
1561
1561
  *
1562
1562
  * @param params Source and destination paths for a rename within the session workspace files directory.
1563
1563
  */
1564
- renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
1564
+ renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { ...params, sessionId }),
1565
1565
  /**
1566
1566
  * Lists workspace checkpoints in chronological order.
1567
1567
  *
@@ -1575,7 +1575,7 @@ function createSessionRpc(connection, sessionId) {
1575
1575
  *
1576
1576
  * @returns Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
1577
1577
  */
1578
- readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { sessionId, ...params }),
1578
+ readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { ...params, sessionId }),
1579
1579
  /**
1580
1580
  * Adds a compaction summary checkpoint to the local session workspace.
1581
1581
  *
@@ -1583,7 +1583,7 @@ function createSessionRpc(connection, sessionId) {
1583
1583
  *
1584
1584
  * @returns Persisted summary metadata and refreshed workspace metadata.
1585
1585
  */
1586
- addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { sessionId, ...params }),
1586
+ addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { ...params, sessionId }),
1587
1587
  /**
1588
1588
  * Truncates local workspace compaction summaries after a rollback.
1589
1589
  *
@@ -1591,7 +1591,7 @@ function createSessionRpc(connection, sessionId) {
1591
1591
  *
1592
1592
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1593
1593
  */
1594
- truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { sessionId, ...params }),
1594
+ truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { ...params, sessionId }),
1595
1595
  /**
1596
1596
  * Reads the autopilot objective state file from the local session workspace.
1597
1597
  *
@@ -1605,7 +1605,7 @@ function createSessionRpc(connection, sessionId) {
1605
1605
  *
1606
1606
  * @returns Result of writing the autopilot objective file.
1607
1607
  */
1608
- writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { sessionId, ...params }),
1608
+ writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { ...params, sessionId }),
1609
1609
  /**
1610
1610
  * Deletes the autopilot objective state file from the local session workspace.
1611
1611
  *
@@ -1625,7 +1625,7 @@ function createSessionRpc(connection, sessionId) {
1625
1625
  *
1626
1626
  * @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
1627
1627
  */
1628
- saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
1628
+ saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { ...params, sessionId }),
1629
1629
  /**
1630
1630
  * 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
1631
  *
@@ -1633,7 +1633,7 @@ function createSessionRpc(connection, sessionId) {
1633
1633
  *
1634
1634
  * @returns Workspace diff result for the requested mode.
1635
1635
  */
1636
- diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
1636
+ diff: async (params) => connection.sendRequest("session.workspaces.diff", { ...params, sessionId })
1637
1637
  },
1638
1638
  /** @experimental */
1639
1639
  autopilotObjective: {
@@ -1659,7 +1659,7 @@ function createSessionRpc(connection, sessionId) {
1659
1659
  *
1660
1660
  * @returns Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
1661
1661
  */
1662
- request: async (params) => connection.sendRequest("session.completions.request", { sessionId, ...params })
1662
+ request: async (params) => connection.sendRequest("session.completions.request", { ...params, sessionId })
1663
1663
  },
1664
1664
  /** @experimental */
1665
1665
  instructions: {
@@ -1692,7 +1692,7 @@ function createSessionRpc(connection, sessionId) {
1692
1692
  *
1693
1693
  * @returns Indicates whether fleet mode was successfully activated.
1694
1694
  */
1695
- start: async (params) => connection.sendRequest("session.fleet.start", { sessionId, ...params })
1695
+ start: async (params) => connection.sendRequest("session.fleet.start", { ...params, sessionId })
1696
1696
  },
1697
1697
  /** @experimental */
1698
1698
  agent: {
@@ -1703,13 +1703,13 @@ function createSessionRpc(connection, sessionId) {
1703
1703
  *
1704
1704
  * @returns Agents available to the session.
1705
1705
  */
1706
- list: async (params) => connection.sendRequest("session.agent.list", { sessionId, ...params }),
1706
+ list: async (params) => connection.sendRequest("session.agent.list", { ...params, sessionId }),
1707
1707
  /**
1708
1708
  * 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
1709
  *
1710
1710
  * @param params An in-memory authored prompt override for an available agent.
1711
1711
  */
1712
- setPrompt: async (params) => connection.sendRequest("session.agent.setPrompt", { sessionId, ...params }),
1712
+ setPrompt: async (params) => connection.sendRequest("session.agent.setPrompt", { ...params, sessionId }),
1713
1713
  /**
1714
1714
  * Gets the currently selected custom agent for the session.
1715
1715
  *
@@ -1723,7 +1723,7 @@ function createSessionRpc(connection, sessionId) {
1723
1723
  *
1724
1724
  * @returns The newly selected custom agent.
1725
1725
  */
1726
- select: async (params) => connection.sendRequest("session.agent.select", { sessionId, ...params }),
1726
+ select: async (params) => connection.sendRequest("session.agent.select", { ...params, sessionId }),
1727
1727
  /**
1728
1728
  * Clears the selected custom agent and returns the session to the default agent.
1729
1729
  */
@@ -1744,7 +1744,7 @@ function createSessionRpc(connection, sessionId) {
1744
1744
  *
1745
1745
  * @returns Identifier assigned to the newly started background agent task.
1746
1746
  */
1747
- startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { sessionId, ...params }),
1747
+ startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { ...params, sessionId }),
1748
1748
  /**
1749
1749
  * Lists background tasks tracked by the session.
1750
1750
  *
@@ -1758,7 +1758,7 @@ function createSessionRpc(connection, sessionId) {
1758
1758
  *
1759
1759
  * @returns Result of registering or reclaiming a client-owned task.
1760
1760
  */
1761
- register: async (params) => connection.sendRequest("session.tasks.register", { sessionId, ...params }),
1761
+ register: async (params) => connection.sendRequest("session.tasks.register", { ...params, sessionId }),
1762
1762
  /**
1763
1763
  * Publishes generic progress or a terminal outcome for a client-owned task.
1764
1764
  *
@@ -1766,7 +1766,7 @@ function createSessionRpc(connection, sessionId) {
1766
1766
  *
1767
1767
  * @returns Result of publishing a client-owned task update.
1768
1768
  */
1769
- update: async (params) => connection.sendRequest("session.tasks.update", { sessionId, ...params }),
1769
+ update: async (params) => connection.sendRequest("session.tasks.update", { ...params, sessionId }),
1770
1770
  /**
1771
1771
  * Refreshes metadata for any detached background shells the runtime knows about.
1772
1772
  *
@@ -1786,7 +1786,7 @@ function createSessionRpc(connection, sessionId) {
1786
1786
  *
1787
1787
  * @returns Progress information for the task, or null when no task with that ID is tracked.
1788
1788
  */
1789
- getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { sessionId, ...params }),
1789
+ getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { ...params, sessionId }),
1790
1790
  /**
1791
1791
  * Returns the first sync-waiting task that can currently be promoted to background mode.
1792
1792
  *
@@ -1800,7 +1800,7 @@ function createSessionRpc(connection, sessionId) {
1800
1800
  *
1801
1801
  * @returns Indicates whether the task was successfully promoted to background mode.
1802
1802
  */
1803
- promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
1803
+ promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { ...params, sessionId }),
1804
1804
  /**
1805
1805
  * Atomically promotes the first promotable sync-waiting task to background mode and returns it.
1806
1806
  *
@@ -1814,7 +1814,7 @@ function createSessionRpc(connection, sessionId) {
1814
1814
  *
1815
1815
  * @returns Indicates whether the background task was successfully cancelled.
1816
1816
  */
1817
- cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
1817
+ cancel: async (params) => connection.sendRequest("session.tasks.cancel", { ...params, sessionId }),
1818
1818
  /**
1819
1819
  * Removes a completed or cancelled background task from tracking.
1820
1820
  *
@@ -1822,7 +1822,7 @@ function createSessionRpc(connection, sessionId) {
1822
1822
  *
1823
1823
  * @returns Indicates whether the task was removed. False when the task does not exist or is still running/idle.
1824
1824
  */
1825
- remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params }),
1825
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { ...params, sessionId }),
1826
1826
  /**
1827
1827
  * Sends a message to a background agent task.
1828
1828
  *
@@ -1830,7 +1830,7 @@ function createSessionRpc(connection, sessionId) {
1830
1830
  *
1831
1831
  * @returns Indicates whether the message was delivered, with an error message when delivery failed.
1832
1832
  */
1833
- sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { sessionId, ...params })
1833
+ sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { ...params, sessionId })
1834
1834
  },
1835
1835
  /** @experimental */
1836
1836
  skills: {
@@ -1851,13 +1851,13 @@ function createSessionRpc(connection, sessionId) {
1851
1851
  *
1852
1852
  * @param params Name of the skill to enable for the session.
1853
1853
  */
1854
- enable: async (params) => connection.sendRequest("session.skills.enable", { sessionId, ...params }),
1854
+ enable: async (params) => connection.sendRequest("session.skills.enable", { ...params, sessionId }),
1855
1855
  /**
1856
1856
  * Disables a skill for the session.
1857
1857
  *
1858
1858
  * @param params Name of the skill to disable for the session.
1859
1859
  */
1860
- disable: async (params) => connection.sendRequest("session.skills.disable", { sessionId, ...params }),
1860
+ disable: async (params) => connection.sendRequest("session.skills.disable", { ...params, sessionId }),
1861
1861
  /**
1862
1862
  * Reloads skill definitions for the session.
1863
1863
  *
@@ -1884,19 +1884,19 @@ function createSessionRpc(connection, sessionId) {
1884
1884
  *
1885
1885
  * @returns Tools exposed by the connected MCP server. Throws when the server is not connected.
1886
1886
  */
1887
- listTools: async (params) => connection.sendRequest("session.mcp.listTools", { sessionId, ...params }),
1887
+ listTools: async (params) => connection.sendRequest("session.mcp.listTools", { ...params, sessionId }),
1888
1888
  /**
1889
1889
  * Enables an MCP server for the session.
1890
1890
  *
1891
1891
  * @param params Name of the MCP server to enable for the session.
1892
1892
  */
1893
- enable: async (params) => connection.sendRequest("session.mcp.enable", { sessionId, ...params }),
1893
+ enable: async (params) => connection.sendRequest("session.mcp.enable", { ...params, sessionId }),
1894
1894
  /**
1895
1895
  * Disables an MCP server for the session.
1896
1896
  *
1897
1897
  * @param params Name of the MCP server to disable for the session.
1898
1898
  */
1899
- disable: async (params) => connection.sendRequest("session.mcp.disable", { sessionId, ...params }),
1899
+ disable: async (params) => connection.sendRequest("session.mcp.disable", { ...params, sessionId }),
1900
1900
  /**
1901
1901
  * Reloads MCP server connections for the session.
1902
1902
  */
@@ -1914,7 +1914,7 @@ function createSessionRpc(connection, sessionId) {
1914
1914
  *
1915
1915
  * @returns Outcome of an MCP sampling execution: success result, failure error, or cancellation.
1916
1916
  */
1917
- executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { sessionId, ...params }),
1917
+ executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { ...params, sessionId }),
1918
1918
  /**
1919
1919
  * Cancels an in-flight MCP sampling execution by request ID.
1920
1920
  *
@@ -1922,7 +1922,7 @@ function createSessionRpc(connection, sessionId) {
1922
1922
  *
1923
1923
  * @returns Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
1924
1924
  */
1925
- cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { sessionId, ...params }),
1925
+ cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { ...params, sessionId }),
1926
1926
  /**
1927
1927
  * Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
1928
1928
  *
@@ -1930,7 +1930,7 @@ function createSessionRpc(connection, sessionId) {
1930
1930
  *
1931
1931
  * @returns Env-value mode recorded on the session after the update.
1932
1932
  */
1933
- setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { sessionId, ...params }),
1933
+ setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { ...params, sessionId }),
1934
1934
  /**
1935
1935
  * Removes the auto-managed `github` MCP server when present.
1936
1936
  *
@@ -1942,19 +1942,19 @@ function createSessionRpc(connection, sessionId) {
1942
1942
  *
1943
1943
  * @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
1944
  */
1945
- startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
1945
+ startServer: async (params) => connection.sendRequest("session.mcp.startServer", { ...params, sessionId }),
1946
1946
  /**
1947
1947
  * 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
1948
  *
1949
1949
  * @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
1950
  */
1951
- restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { sessionId, ...params }),
1951
+ restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { ...params, sessionId }),
1952
1952
  /**
1953
1953
  * Stops an individual MCP server on the session's host.
1954
1954
  *
1955
1955
  * @param params Server name for an individual MCP server stop.
1956
1956
  */
1957
- stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { sessionId, ...params }),
1957
+ stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { ...params, sessionId }),
1958
1958
  /**
1959
1959
  * Checks whether a named MCP server is currently running on the session's host.
1960
1960
  *
@@ -1962,7 +1962,7 @@ function createSessionRpc(connection, sessionId) {
1962
1962
  *
1963
1963
  * @returns Whether the named MCP server is running.
1964
1964
  */
1965
- isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { sessionId, ...params }),
1965
+ isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { ...params, sessionId }),
1966
1966
  /** @experimental */
1967
1967
  oauth: {
1968
1968
  /**
@@ -1972,13 +1972,13 @@ function createSessionRpc(connection, sessionId) {
1972
1972
  *
1973
1973
  * @returns Indicates whether the pending MCP OAuth response was accepted.
1974
1974
  */
1975
- handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { sessionId, ...params }),
1975
+ handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { ...params, sessionId }),
1976
1976
  /**
1977
1977
  * Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
1978
1978
  *
1979
1979
  * @param params Identifies the MCP server whose persisted OAuth credentials were updated.
1980
1980
  */
1981
- authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { sessionId, ...params }),
1981
+ authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { ...params, sessionId }),
1982
1982
  /**
1983
1983
  * 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
1984
  *
@@ -1986,15 +1986,21 @@ function createSessionRpc(connection, sessionId) {
1986
1986
  *
1987
1987
  * @returns An inert runtime-issued login handle. Preparation alone performs no activation or OAuth work.
1988
1988
  */
1989
- prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { sessionId, ...params }),
1989
+ prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { ...params, sessionId }),
1990
1990
  /**
1991
1991
  * 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
1992
  *
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.
1993
+ * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback handling, and static OAuth client selection.
1994
1994
  *
1995
1995
  * @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
1996
1996
  */
1997
- login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params }),
1997
+ login: async (params) => connection.sendRequest("session.mcp.oauth.login", { ...params, sessionId }),
1998
+ /**
1999
+ * Completes a runtime-managed MCP OAuth login after the authorization server redirects to a host-managed callback URL.
2000
+ *
2001
+ * @param params Host-delivered callback for a runtime-managed MCP OAuth login.
2002
+ */
2003
+ complete: async (params) => connection.sendRequest("session.mcp.oauth.complete", { ...params, sessionId }),
1998
2004
  /**
1999
2005
  * 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
2006
  *
@@ -2002,7 +2008,7 @@ function createSessionRpc(connection, sessionId) {
2002
2008
  *
2003
2009
  * @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
2010
  */
2005
- probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { sessionId, ...params }),
2011
+ probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { ...params, sessionId }),
2006
2012
  /**
2007
2013
  * Cancels the exact owned OAuth login issued to this original session requester, without clearing shared credentials.
2008
2014
  *
@@ -2010,7 +2016,7 @@ function createSessionRpc(connection, sessionId) {
2010
2016
  *
2011
2017
  * @returns Honest terminal cancellation result; persistence or recovery failures remain RPC errors.
2012
2018
  */
2013
- cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { sessionId, ...params }),
2019
+ cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { ...params, sessionId }),
2014
2020
  /**
2015
2021
  * Responds to a pending MCP OAuth authorization request by its request id.
2016
2022
  *
@@ -2018,7 +2024,7 @@ function createSessionRpc(connection, sessionId) {
2018
2024
  *
2019
2025
  * @returns Indicates whether the pending MCP OAuth response was accepted.
2020
2026
  */
2021
- respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
2027
+ respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { ...params, sessionId })
2022
2028
  },
2023
2029
  /** @experimental */
2024
2030
  headers: {
@@ -2029,7 +2035,7 @@ function createSessionRpc(connection, sessionId) {
2029
2035
  *
2030
2036
  * @returns Indicates whether the pending MCP headers refresh response was accepted.
2031
2037
  */
2032
- handlePendingHeadersRefreshRequest: async (params) => connection.sendRequest("session.mcp.headers.handlePendingHeadersRefreshRequest", { sessionId, ...params })
2038
+ handlePendingHeadersRefreshRequest: async (params) => connection.sendRequest("session.mcp.headers.handlePendingHeadersRefreshRequest", { ...params, sessionId })
2033
2039
  },
2034
2040
  /** @experimental */
2035
2041
  apps: {
@@ -2040,7 +2046,7 @@ function createSessionRpc(connection, sessionId) {
2040
2046
  *
2041
2047
  * @returns Resource contents returned by the MCP server.
2042
2048
  */
2043
- readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { sessionId, ...params }),
2049
+ readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { ...params, sessionId }),
2044
2050
  /**
2045
2051
  * 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
2052
  *
@@ -2048,7 +2054,7 @@ function createSessionRpc(connection, sessionId) {
2048
2054
  *
2049
2055
  * @returns App-callable tools from the named MCP server.
2050
2056
  */
2051
- listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { sessionId, ...params }),
2057
+ listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { ...params, sessionId }),
2052
2058
  /**
2053
2059
  * 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
2060
  *
@@ -2056,13 +2062,13 @@ function createSessionRpc(connection, sessionId) {
2056
2062
  *
2057
2063
  * @returns Standard MCP CallToolResult
2058
2064
  */
2059
- callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { sessionId, ...params }),
2065
+ callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { ...params, sessionId }),
2060
2066
  /**
2061
2067
  * 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
2068
  *
2063
2069
  * @param params Host context to advertise to MCP App guests.
2064
2070
  */
2065
- setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { sessionId, ...params }),
2071
+ setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { ...params, sessionId }),
2066
2072
  /**
2067
2073
  * Read the current host context advertised to MCP App guests.
2068
2074
  *
@@ -2076,7 +2082,7 @@ function createSessionRpc(connection, sessionId) {
2076
2082
  *
2077
2083
  * @returns Diagnostic snapshot of MCP Apps wiring for the named server.
2078
2084
  */
2079
- diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { sessionId, ...params })
2085
+ diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { ...params, sessionId })
2080
2086
  },
2081
2087
  /** @experimental */
2082
2088
  resources: {
@@ -2087,7 +2093,7 @@ function createSessionRpc(connection, sessionId) {
2087
2093
  *
2088
2094
  * @returns Resource contents returned by the MCP server.
2089
2095
  */
2090
- read: async (params) => connection.sendRequest("session.mcp.resources.read", { sessionId, ...params }),
2096
+ read: async (params) => connection.sendRequest("session.mcp.resources.read", { ...params, sessionId }),
2091
2097
  /**
2092
2098
  * 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
2099
  *
@@ -2095,7 +2101,7 @@ function createSessionRpc(connection, sessionId) {
2095
2101
  *
2096
2102
  * @returns One page of resources advertised by the named MCP server.
2097
2103
  */
2098
- list: async (params) => connection.sendRequest("session.mcp.resources.list", { sessionId, ...params }),
2104
+ list: async (params) => connection.sendRequest("session.mcp.resources.list", { ...params, sessionId }),
2099
2105
  /**
2100
2106
  * 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
2107
  *
@@ -2103,7 +2109,26 @@ function createSessionRpc(connection, sessionId) {
2103
2109
  *
2104
2110
  * @returns One page of resource templates advertised by the named MCP server.
2105
2111
  */
2106
- listTemplates: async (params) => connection.sendRequest("session.mcp.resources.listTemplates", { sessionId, ...params })
2112
+ listTemplates: async (params) => connection.sendRequest("session.mcp.resources.listTemplates", { ...params, sessionId })
2113
+ },
2114
+ /** @experimental */
2115
+ prompts: {
2116
+ /**
2117
+ * Enumerate one page of prompts a connected MCP server exposes (proxies MCP `prompts/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
2118
+ *
2119
+ * @param params MCP server whose prompts to enumerate.
2120
+ *
2121
+ * @returns One page of prompts advertised by the named MCP server.
2122
+ */
2123
+ list: async (params) => connection.sendRequest("session.mcp.prompts.list", { ...params, sessionId }),
2124
+ /**
2125
+ * 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.
2126
+ *
2127
+ * @param params MCP server, prompt name, and optional string-valued arguments.
2128
+ *
2129
+ * @returns Prompt messages returned by the MCP server without sending them to the model.
2130
+ */
2131
+ get: async (params) => connection.sendRequest("session.mcp.prompts.get", { ...params, sessionId })
2107
2132
  }
2108
2133
  },
2109
2134
  /** @experimental */
@@ -2115,7 +2140,7 @@ function createSessionRpc(connection, sessionId) {
2115
2140
  *
2116
2141
  * @returns Per-source session diagnostics configuration.
2117
2142
  */
2118
- configure: async (params) => connection.sendRequest("session.diagnostics.configure", { sessionId, ...params }),
2143
+ configure: async (params) => connection.sendRequest("session.diagnostics.configure", { ...params, sessionId }),
2119
2144
  /**
2120
2145
  * 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
2146
  *
@@ -2123,7 +2148,7 @@ function createSessionRpc(connection, sessionId) {
2123
2148
  *
2124
2149
  * @returns One cursor-addressed page of retained session diagnostics.
2125
2150
  */
2126
- read: async (params) => connection.sendRequest("session.diagnostics.read", { sessionId, ...params })
2151
+ read: async (params) => connection.sendRequest("session.diagnostics.read", { ...params, sessionId })
2127
2152
  },
2128
2153
  /** @experimental */
2129
2154
  connectors: {
@@ -2152,7 +2177,7 @@ function createSessionRpc(connection, sessionId) {
2152
2177
  *
2153
2178
  * @returns Validated Connector catalog snapshot cached by the session.
2154
2179
  */
2155
- list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
2180
+ list: async (params) => connection.sendRequest("session.connectors.list", { ...params, sessionId }),
2156
2181
  /**
2157
2182
  * Refreshes and validates the Connector catalog for the pinned opaque account selection.
2158
2183
  *
@@ -2160,7 +2185,7 @@ function createSessionRpc(connection, sessionId) {
2160
2185
  *
2161
2186
  * @returns Validated Connector catalog snapshot cached by the session.
2162
2187
  */
2163
- refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
2188
+ refresh: async (params) => connection.sendRequest("session.connectors.refresh", { ...params, sessionId }),
2164
2189
  /**
2165
2190
  * 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
2191
  *
@@ -2168,7 +2193,7 @@ function createSessionRpc(connection, sessionId) {
2168
2193
  *
2169
2194
  * @returns Typed result of initiating or continuing a Connector connection.
2170
2195
  */
2171
- connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
2196
+ connect: async (params) => connection.sendRequest("session.connectors.connect", { ...params, sessionId }),
2172
2197
  /**
2173
2198
  * Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
2174
2199
  *
@@ -2176,7 +2201,7 @@ function createSessionRpc(connection, sessionId) {
2176
2201
  *
2177
2202
  * @returns Typed result of initiating or continuing a Connector connection.
2178
2203
  */
2179
- reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
2204
+ reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { ...params, sessionId }),
2180
2205
  /**
2181
2206
  * Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
2182
2207
  *
@@ -2184,7 +2209,7 @@ function createSessionRpc(connection, sessionId) {
2184
2209
  *
2185
2210
  * @returns Typed result of initiating or continuing a Connector connection.
2186
2211
  */
2187
- continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
2212
+ continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { ...params, sessionId }),
2188
2213
  /**
2189
2214
  * Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
2190
2215
  *
@@ -2192,7 +2217,7 @@ function createSessionRpc(connection, sessionId) {
2192
2217
  *
2193
2218
  * @returns Authoritative result after disconnect and MCP reconciliation.
2194
2219
  */
2195
- disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
2220
+ disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { ...params, sessionId }),
2196
2221
  /**
2197
2222
  * Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
2198
2223
  *
@@ -2200,7 +2225,7 @@ function createSessionRpc(connection, sessionId) {
2200
2225
  *
2201
2226
  * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
2202
2227
  */
2203
- reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
2228
+ reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { ...params, sessionId })
2204
2229
  },
2205
2230
  /** @experimental */
2206
2231
  managedSettings: {
@@ -2226,13 +2251,13 @@ function createSessionRpc(connection, sessionId) {
2226
2251
  *
2227
2252
  * @returns Result of installing a plugin.
2228
2253
  */
2229
- install: async (params) => connection.sendRequest("session.plugins.install", { sessionId, ...params }),
2254
+ install: async (params) => connection.sendRequest("session.plugins.install", { ...params, sessionId }),
2230
2255
  /**
2231
2256
  * Uninstalls a plugin when permitted by the live session's retained managed policy.
2232
2257
  *
2233
2258
  * @param params Name (or spec) of the plugin to uninstall.
2234
2259
  */
2235
- uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { sessionId, ...params }),
2260
+ uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { ...params, sessionId }),
2236
2261
  /**
2237
2262
  * Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
2238
2263
  *
@@ -2240,19 +2265,19 @@ function createSessionRpc(connection, sessionId) {
2240
2265
  *
2241
2266
  * @returns Result of updating a single plugin.
2242
2267
  */
2243
- update: async (params) => connection.sendRequest("session.plugins.update", { sessionId, ...params }),
2268
+ update: async (params) => connection.sendRequest("session.plugins.update", { ...params, sessionId }),
2244
2269
  /**
2245
2270
  * Enables installed plugins when permitted by the live session's retained managed policy.
2246
2271
  *
2247
2272
  * @param params Plugin names (or specs) to enable in the session's authoritative working directory.
2248
2273
  */
2249
- enable: async (params) => connection.sendRequest("session.plugins.enable", { sessionId, ...params }),
2274
+ enable: async (params) => connection.sendRequest("session.plugins.enable", { ...params, sessionId }),
2250
2275
  /**
2251
2276
  * Disables installed plugins when permitted by the live session's retained managed policy.
2252
2277
  *
2253
2278
  * @param params Plugin names (or specs) to disable in the session's authoritative working directory.
2254
2279
  */
2255
- disable: async (params) => connection.sendRequest("session.plugins.disable", { sessionId, ...params }),
2280
+ disable: async (params) => connection.sendRequest("session.plugins.disable", { ...params, sessionId }),
2256
2281
  /** @experimental */
2257
2282
  marketplaces: {
2258
2283
  /**
@@ -2268,7 +2293,7 @@ function createSessionRpc(connection, sessionId) {
2268
2293
  *
2269
2294
  * @returns Result of registering a new marketplace.
2270
2295
  */
2271
- add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { sessionId, ...params }),
2296
+ add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { ...params, sessionId }),
2272
2297
  /**
2273
2298
  * Removes a marketplace when permitted by the live session's retained managed policy.
2274
2299
  *
@@ -2276,7 +2301,7 @@ function createSessionRpc(connection, sessionId) {
2276
2301
  *
2277
2302
  * @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
2278
2303
  */
2279
- remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { sessionId, ...params }),
2304
+ remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { ...params, sessionId }),
2280
2305
  /**
2281
2306
  * Browses a marketplace resolved through the live session's working directory and retained managed policy.
2282
2307
  *
@@ -2284,7 +2309,7 @@ function createSessionRpc(connection, sessionId) {
2284
2309
  *
2285
2310
  * @returns Plugins advertised by the marketplace.
2286
2311
  */
2287
- browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { sessionId, ...params }),
2312
+ browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { ...params, sessionId }),
2288
2313
  /**
2289
2314
  * Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
2290
2315
  *
@@ -2292,14 +2317,14 @@ function createSessionRpc(connection, sessionId) {
2292
2317
  *
2293
2318
  * @returns Result of refreshing one or more marketplace catalogs.
2294
2319
  */
2295
- refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { sessionId, ...params })
2320
+ refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { ...params, sessionId })
2296
2321
  },
2297
2322
  /**
2298
2323
  * 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
2324
  *
2300
2325
  * @param params Optional flags controlling which side effects the reload performs.
2301
2326
  */
2302
- reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
2327
+ reload: async (params) => connection.sendRequest("session.plugins.reload", { ...params, sessionId })
2303
2328
  },
2304
2329
  /** @experimental */
2305
2330
  provider: {
@@ -2310,7 +2335,7 @@ function createSessionRpc(connection, sessionId) {
2310
2335
  *
2311
2336
  * @returns A snapshot of the provider endpoint the session is currently configured to talk to.
2312
2337
  */
2313
- getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
2338
+ getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { ...params, sessionId }),
2314
2339
  /**
2315
2340
  * 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
2341
  *
@@ -2318,7 +2343,7 @@ function createSessionRpc(connection, sessionId) {
2318
2343
  *
2319
2344
  * @returns The selectable model entries synthesized for the models added by this call.
2320
2345
  */
2321
- add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
2346
+ add: async (params) => connection.sendRequest("session.provider.add", { ...params, sessionId }),
2322
2347
  /**
2323
2348
  * 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
2349
  *
@@ -2326,7 +2351,7 @@ function createSessionRpc(connection, sessionId) {
2326
2351
  *
2327
2352
  * @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
2328
2353
  */
2329
- sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params }),
2354
+ sync: async (params) => connection.sendRequest("session.provider.sync", { ...params, sessionId }),
2330
2355
  /**
2331
2356
  * 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
2357
  *
@@ -2334,7 +2359,7 @@ function createSessionRpc(connection, sessionId) {
2334
2359
  *
2335
2360
  * @returns What the withdrawal actually removed from the registry.
2336
2361
  */
2337
- withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { sessionId, ...params })
2362
+ withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { ...params, sessionId })
2338
2363
  },
2339
2364
  /** @experimental */
2340
2365
  options: {
@@ -2345,7 +2370,7 @@ function createSessionRpc(connection, sessionId) {
2345
2370
  *
2346
2371
  * @returns Indicates whether the session options patch was applied successfully.
2347
2372
  */
2348
- update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
2373
+ update: async (params) => connection.sendRequest("session.options.update", { ...params, sessionId })
2349
2374
  },
2350
2375
  /** @experimental */
2351
2376
  lsp: {
@@ -2354,7 +2379,7 @@ function createSessionRpc(connection, sessionId) {
2354
2379
  *
2355
2380
  * @param params Parameters for (re)loading the merged LSP configuration set.
2356
2381
  */
2357
- initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
2382
+ initialize: async (params) => connection.sendRequest("session.lsp.initialize", { ...params, sessionId })
2358
2383
  },
2359
2384
  /** @experimental */
2360
2385
  extensions: {
@@ -2369,13 +2394,13 @@ function createSessionRpc(connection, sessionId) {
2369
2394
  *
2370
2395
  * @param params Source-qualified extension identifier to enable for the session.
2371
2396
  */
2372
- enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
2397
+ enable: async (params) => connection.sendRequest("session.extensions.enable", { ...params, sessionId }),
2373
2398
  /**
2374
2399
  * Disables an extension for the session.
2375
2400
  *
2376
2401
  * @param params Source-qualified extension identifier to disable for the session.
2377
2402
  */
2378
- disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
2403
+ disable: async (params) => connection.sendRequest("session.extensions.disable", { ...params, sessionId }),
2379
2404
  /**
2380
2405
  * Reloads extension definitions and processes for the session.
2381
2406
  */
@@ -2385,7 +2410,7 @@ function createSessionRpc(connection, sessionId) {
2385
2410
  *
2386
2411
  * @param params Parameters for session.extensions.sendAttachmentsToMessage.
2387
2412
  */
2388
- sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { sessionId, ...params })
2413
+ sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { ...params, sessionId })
2389
2414
  },
2390
2415
  /** @experimental */
2391
2416
  tools: {
@@ -2396,7 +2421,7 @@ function createSessionRpc(connection, sessionId) {
2396
2421
  *
2397
2422
  * @returns Canonical result returned by a session tool.
2398
2423
  */
2399
- execute: async (params) => connection.sendRequest("session.tools.execute", { sessionId, ...params }),
2424
+ execute: async (params) => connection.sendRequest("session.tools.execute", { ...params, sessionId }),
2400
2425
  /**
2401
2426
  * Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
2402
2427
  *
@@ -2404,7 +2429,7 @@ function createSessionRpc(connection, sessionId) {
2404
2429
  *
2405
2430
  * @returns Rust-owned built-in tool descriptors for the session.
2406
2431
  */
2407
- getBuiltinDescriptors: async (params) => connection.sendRequest("session.tools.getBuiltinDescriptors", { sessionId, ...params }),
2432
+ getBuiltinDescriptors: async (params) => connection.sendRequest("session.tools.getBuiltinDescriptors", { ...params, sessionId }),
2408
2433
  /**
2409
2434
  * Projects a completed task_complete tool call into its label-safe session event payload.
2410
2435
  *
@@ -2412,7 +2437,7 @@ function createSessionRpc(connection, sessionId) {
2412
2437
  *
2413
2438
  * @returns Task completion notification with summary from the agent
2414
2439
  */
2415
- taskCompleteEventData: async (params) => connection.sendRequest("session.tools.taskCompleteEventData", { sessionId, ...params }),
2440
+ taskCompleteEventData: async (params) => connection.sendRequest("session.tools.taskCompleteEventData", { ...params, sessionId }),
2416
2441
  /**
2417
2442
  * Provides the result for a pending external tool call.
2418
2443
  *
@@ -2420,7 +2445,7 @@ function createSessionRpc(connection, sessionId) {
2420
2445
  *
2421
2446
  * @returns Indicates whether the external tool call result was handled successfully.
2422
2447
  */
2423
- handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params }),
2448
+ handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { ...params, sessionId }),
2424
2449
  /**
2425
2450
  * Resolves, builds, and validates the runtime tool list for the session.
2426
2451
  *
@@ -2440,7 +2465,7 @@ function createSessionRpc(connection, sessionId) {
2440
2465
  *
2441
2466
  * @returns Empty result after replacing the calling connection's externally implemented tools.
2442
2467
  */
2443
- set: async (params) => connection.sendRequest("session.tools.set", { sessionId, ...params }),
2468
+ set: async (params) => connection.sendRequest("session.tools.set", { ...params, sessionId }),
2444
2469
  /**
2445
2470
  * 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
2471
  *
@@ -2448,7 +2473,7 @@ function createSessionRpc(connection, sessionId) {
2448
2473
  *
2449
2474
  * @returns Empty result after applying subagent settings
2450
2475
  */
2451
- updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { sessionId, ...params })
2476
+ updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { ...params, sessionId })
2452
2477
  },
2453
2478
  /** @experimental */
2454
2479
  commands: {
@@ -2459,7 +2484,7 @@ function createSessionRpc(connection, sessionId) {
2459
2484
  *
2460
2485
  * @returns Slash commands available in the session, after applying any include/exclude filters.
2461
2486
  */
2462
- list: async (params) => connection.sendRequest("session.commands.list", { sessionId, ...params }),
2487
+ list: async (params) => connection.sendRequest("session.commands.list", { ...params, sessionId }),
2463
2488
  /**
2464
2489
  * Invokes a slash command in the session.
2465
2490
  *
@@ -2467,7 +2492,7 @@ function createSessionRpc(connection, sessionId) {
2467
2492
  *
2468
2493
  * @returns Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
2469
2494
  */
2470
- invoke: async (params) => connection.sendRequest("session.commands.invoke", { sessionId, ...params }),
2495
+ invoke: async (params) => connection.sendRequest("session.commands.invoke", { ...params, sessionId }),
2471
2496
  /**
2472
2497
  * Reports completion of a pending client-handled slash command.
2473
2498
  *
@@ -2475,7 +2500,7 @@ function createSessionRpc(connection, sessionId) {
2475
2500
  *
2476
2501
  * @returns Indicates whether the pending client-handled command was completed successfully.
2477
2502
  */
2478
- handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params }),
2503
+ handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { ...params, sessionId }),
2479
2504
  /**
2480
2505
  * Executes a slash command synchronously and returns any error.
2481
2506
  *
@@ -2483,7 +2508,7 @@ function createSessionRpc(connection, sessionId) {
2483
2508
  *
2484
2509
  * @returns Error message produced while executing the command, if any.
2485
2510
  */
2486
- execute: async (params) => connection.sendRequest("session.commands.execute", { sessionId, ...params }),
2511
+ execute: async (params) => connection.sendRequest("session.commands.execute", { ...params, sessionId }),
2487
2512
  /**
2488
2513
  * Enqueues a slash command for FIFO processing on the local session.
2489
2514
  *
@@ -2491,7 +2516,7 @@ function createSessionRpc(connection, sessionId) {
2491
2516
  *
2492
2517
  * @returns Indicates whether the command was accepted into the local execution queue.
2493
2518
  */
2494
- enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { sessionId, ...params }),
2519
+ enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { ...params, sessionId }),
2495
2520
  /**
2496
2521
  * Reports whether the host actually executed a queued command and whether to continue processing.
2497
2522
  *
@@ -2499,7 +2524,7 @@ function createSessionRpc(connection, sessionId) {
2499
2524
  *
2500
2525
  * @returns Indicates whether the queued-command response was matched to a pending request.
2501
2526
  */
2502
- respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { sessionId, ...params })
2527
+ respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { ...params, sessionId })
2503
2528
  },
2504
2529
  /** @experimental */
2505
2530
  telemetry: {
@@ -2514,7 +2539,7 @@ function createSessionRpc(connection, sessionId) {
2514
2539
  *
2515
2540
  * @param params Feature override key/value pairs to attach to subsequent telemetry events from this session.
2516
2541
  */
2517
- setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { sessionId, ...params })
2542
+ setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { ...params, sessionId })
2518
2543
  },
2519
2544
  /** @experimental */
2520
2545
  ui: {
@@ -2525,7 +2550,7 @@ function createSessionRpc(connection, sessionId) {
2525
2550
  *
2526
2551
  * @returns Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
2527
2552
  */
2528
- ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { sessionId, ...params }),
2553
+ ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { ...params, sessionId }),
2529
2554
  /**
2530
2555
  * Requests structured input from a UI-capable client.
2531
2556
  *
@@ -2533,7 +2558,7 @@ function createSessionRpc(connection, sessionId) {
2533
2558
  *
2534
2559
  * @returns The elicitation response (accept with form values, decline, or cancel)
2535
2560
  */
2536
- elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
2561
+ elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { ...params, sessionId }),
2537
2562
  /**
2538
2563
  * Provides the user response for a pending elicitation request.
2539
2564
  *
@@ -2541,7 +2566,7 @@ function createSessionRpc(connection, sessionId) {
2541
2566
  *
2542
2567
  * @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
2543
2568
  */
2544
- handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params }),
2569
+ handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { ...params, sessionId }),
2545
2570
  /**
2546
2571
  * Resolves a pending `user_input.requested` event with the user's response.
2547
2572
  *
@@ -2549,7 +2574,7 @@ function createSessionRpc(connection, sessionId) {
2549
2574
  *
2550
2575
  * @returns Indicates whether the pending UI request was resolved by this call.
2551
2576
  */
2552
- handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { sessionId, ...params }),
2577
+ handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { ...params, sessionId }),
2553
2578
  /**
2554
2579
  * Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
2555
2580
  *
@@ -2557,7 +2582,7 @@ function createSessionRpc(connection, sessionId) {
2557
2582
  *
2558
2583
  * @returns Indicates whether the pending UI request was resolved by this call.
2559
2584
  */
2560
- handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { sessionId, ...params }),
2585
+ handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { ...params, sessionId }),
2561
2586
  /**
2562
2587
  * Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
2563
2588
  *
@@ -2565,7 +2590,7 @@ function createSessionRpc(connection, sessionId) {
2565
2590
  *
2566
2591
  * @returns Indicates whether the pending UI request was resolved by this call.
2567
2592
  */
2568
- handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { sessionId, ...params }),
2593
+ handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { ...params, sessionId }),
2569
2594
  /**
2570
2595
  * Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
2571
2596
  *
@@ -2573,7 +2598,7 @@ function createSessionRpc(connection, sessionId) {
2573
2598
  *
2574
2599
  * @returns Indicates whether the pending UI request was resolved by this call.
2575
2600
  */
2576
- handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { sessionId, ...params }),
2601
+ handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { ...params, sessionId }),
2577
2602
  /**
2578
2603
  * Resolves a pending `exit_plan_mode.requested` event with the user's response.
2579
2604
  *
@@ -2581,7 +2606,7 @@ function createSessionRpc(connection, sessionId) {
2581
2606
  *
2582
2607
  * @returns Indicates whether the pending UI request was resolved by this call.
2583
2608
  */
2584
- handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { sessionId, ...params }),
2609
+ handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { ...params, sessionId }),
2585
2610
  /**
2586
2611
  * Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
2587
2612
  *
@@ -2595,7 +2620,7 @@ function createSessionRpc(connection, sessionId) {
2595
2620
  *
2596
2621
  * @returns Indicates whether the handle was active and the registration count was decremented.
2597
2622
  */
2598
- unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { sessionId, ...params })
2623
+ unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { ...params, sessionId })
2599
2624
  },
2600
2625
  /** @experimental */
2601
2626
  permissions: {
@@ -2606,7 +2631,7 @@ function createSessionRpc(connection, sessionId) {
2606
2631
  *
2607
2632
  * @returns Indicates whether the operation succeeded.
2608
2633
  */
2609
- configure: async (params) => connection.sendRequest("session.permissions.configure", { sessionId, ...params }),
2634
+ configure: async (params) => connection.sendRequest("session.permissions.configure", { ...params, sessionId }),
2610
2635
  /**
2611
2636
  * Provides a decision for a pending tool permission request.
2612
2637
  *
@@ -2614,7 +2639,7 @@ function createSessionRpc(connection, sessionId) {
2614
2639
  *
2615
2640
  * @returns Indicates whether the permission decision was applied; false when the request was already resolved.
2616
2641
  */
2617
- handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params }),
2642
+ handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { ...params, sessionId }),
2618
2643
  /**
2619
2644
  * Reconstructs the set of pending tool permission requests from the session's event history.
2620
2645
  *
@@ -2628,7 +2653,7 @@ function createSessionRpc(connection, sessionId) {
2628
2653
  *
2629
2654
  * @returns Indicates whether the operation succeeded.
2630
2655
  */
2631
- setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { sessionId, ...params }),
2656
+ setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { ...params, sessionId }),
2632
2657
  /**
2633
2658
  * 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
2659
  *
@@ -2636,7 +2661,7 @@ function createSessionRpc(connection, sessionId) {
2636
2661
  *
2637
2662
  * @returns Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
2638
2663
  */
2639
- setMode: async (params) => connection.sendRequest("session.permissions.setMode", { sessionId, ...params }),
2664
+ setMode: async (params) => connection.sendRequest("session.permissions.setMode", { ...params, sessionId }),
2640
2665
  /**
2641
2666
  * Returns the current permission mode for the session.
2642
2667
  *
@@ -2650,7 +2675,7 @@ function createSessionRpc(connection, sessionId) {
2650
2675
  *
2651
2676
  * @returns Indicates whether the operation succeeded.
2652
2677
  */
2653
- modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { sessionId, ...params }),
2678
+ modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { ...params, sessionId }),
2654
2679
  /**
2655
2680
  * Sets whether the client wants permission prompts bridged into session events.
2656
2681
  *
@@ -2658,7 +2683,7 @@ function createSessionRpc(connection, sessionId) {
2658
2683
  *
2659
2684
  * @returns Indicates whether the operation succeeded.
2660
2685
  */
2661
- setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
2686
+ setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { ...params, sessionId }),
2662
2687
  /**
2663
2688
  * Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
2664
2689
  *
@@ -2666,7 +2691,7 @@ function createSessionRpc(connection, sessionId) {
2666
2691
  *
2667
2692
  * @returns Indicates whether the operation succeeded.
2668
2693
  */
2669
- resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId, ...params }),
2694
+ resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { ...params, sessionId }),
2670
2695
  /**
2671
2696
  * Notifies the runtime that a permission prompt UI has been shown to the user.
2672
2697
  *
@@ -2674,7 +2699,7 @@ function createSessionRpc(connection, sessionId) {
2674
2699
  *
2675
2700
  * @returns Indicates whether the operation succeeded.
2676
2701
  */
2677
- notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { sessionId, ...params }),
2702
+ notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { ...params, sessionId }),
2678
2703
  /** @experimental */
2679
2704
  paths: {
2680
2705
  /**
@@ -2690,7 +2715,7 @@ function createSessionRpc(connection, sessionId) {
2690
2715
  *
2691
2716
  * @returns Indicates whether the operation succeeded.
2692
2717
  */
2693
- add: async (params) => connection.sendRequest("session.permissions.paths.add", { sessionId, ...params }),
2718
+ add: async (params) => connection.sendRequest("session.permissions.paths.add", { ...params, sessionId }),
2694
2719
  /**
2695
2720
  * Updates the session's primary working directory used by the permission policy.
2696
2721
  *
@@ -2698,7 +2723,7 @@ function createSessionRpc(connection, sessionId) {
2698
2723
  *
2699
2724
  * @returns Indicates whether the operation succeeded.
2700
2725
  */
2701
- updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { sessionId, ...params }),
2726
+ updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { ...params, sessionId }),
2702
2727
  /**
2703
2728
  * Reports whether a path falls within any of the session's allowed directories.
2704
2729
  *
@@ -2706,7 +2731,7 @@ function createSessionRpc(connection, sessionId) {
2706
2731
  *
2707
2732
  * @returns Indicates whether the supplied path is within the session's allowed directories.
2708
2733
  */
2709
- isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { sessionId, ...params }),
2734
+ isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { ...params, sessionId }),
2710
2735
  /**
2711
2736
  * Reports whether a path falls within the session's workspace (primary) directory.
2712
2737
  *
@@ -2714,7 +2739,7 @@ function createSessionRpc(connection, sessionId) {
2714
2739
  *
2715
2740
  * @returns Indicates whether the supplied path is within the session's workspace directory.
2716
2741
  */
2717
- isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { sessionId, ...params })
2742
+ isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { ...params, sessionId })
2718
2743
  },
2719
2744
  /** @experimental */
2720
2745
  locations: {
@@ -2725,7 +2750,7 @@ function createSessionRpc(connection, sessionId) {
2725
2750
  *
2726
2751
  * @returns Resolved location-permissions key and type.
2727
2752
  */
2728
- resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { sessionId, ...params }),
2753
+ resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { ...params, sessionId }),
2729
2754
  /**
2730
2755
  * Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
2731
2756
  *
@@ -2733,7 +2758,7 @@ function createSessionRpc(connection, sessionId) {
2733
2758
  *
2734
2759
  * @returns Summary of persisted location permissions applied to the session.
2735
2760
  */
2736
- apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { sessionId, ...params }),
2761
+ apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { ...params, sessionId }),
2737
2762
  /**
2738
2763
  * Persists a tool approval for a permission location and applies its rules to this session's live permission service.
2739
2764
  *
@@ -2741,7 +2766,7 @@ function createSessionRpc(connection, sessionId) {
2741
2766
  *
2742
2767
  * @returns Indicates whether the operation succeeded.
2743
2768
  */
2744
- addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { sessionId, ...params })
2769
+ addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { ...params, sessionId })
2745
2770
  },
2746
2771
  /** @experimental */
2747
2772
  folderTrust: {
@@ -2752,7 +2777,7 @@ function createSessionRpc(connection, sessionId) {
2752
2777
  *
2753
2778
  * @returns Folder trust check result.
2754
2779
  */
2755
- isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { sessionId, ...params }),
2780
+ isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { ...params, sessionId }),
2756
2781
  /**
2757
2782
  * Adds a folder to the user's trusted folders list.
2758
2783
  *
@@ -2760,7 +2785,7 @@ function createSessionRpc(connection, sessionId) {
2760
2785
  *
2761
2786
  * @returns Indicates whether the operation succeeded.
2762
2787
  */
2763
- addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { sessionId, ...params })
2788
+ addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { ...params, sessionId })
2764
2789
  },
2765
2790
  /** @experimental */
2766
2791
  urls: {
@@ -2771,7 +2796,7 @@ function createSessionRpc(connection, sessionId) {
2771
2796
  *
2772
2797
  * @returns Indicates whether the operation succeeded.
2773
2798
  */
2774
- setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { sessionId, ...params })
2799
+ setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { ...params, sessionId })
2775
2800
  }
2776
2801
  },
2777
2802
  /**
@@ -2783,7 +2808,7 @@ function createSessionRpc(connection, sessionId) {
2783
2808
  *
2784
2809
  * @experimental
2785
2810
  */
2786
- log: async (params) => connection.sendRequest("session.log", { sessionId, ...params }),
2811
+ log: async (params) => connection.sendRequest("session.log", { ...params, sessionId }),
2787
2812
  /** @experimental */
2788
2813
  metadata: {
2789
2814
  /**
@@ -2805,7 +2830,7 @@ function createSessionRpc(connection, sessionId) {
2805
2830
  *
2806
2831
  * @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
2832
  */
2808
- updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { sessionId, ...params }),
2833
+ updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { ...params, sessionId }),
2809
2834
  /**
2810
2835
  * Reports whether the local session is currently processing user/agent messages.
2811
2836
  *
@@ -2825,7 +2850,7 @@ function createSessionRpc(connection, sessionId) {
2825
2850
  *
2826
2851
  * @returns Token breakdown for the session's current context window, or null if uninitialized.
2827
2852
  */
2828
- contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { sessionId, ...params }),
2853
+ contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { ...params, sessionId }),
2829
2854
  /**
2830
2855
  * 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
2856
  *
@@ -2839,7 +2864,7 @@ function createSessionRpc(connection, sessionId) {
2839
2864
  *
2840
2865
  * @returns The heaviest individual messages in the session's context window, most-expensive first.
2841
2866
  */
2842
- getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { sessionId, ...params }),
2867
+ getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { ...params, sessionId }),
2843
2868
  /**
2844
2869
  * 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
2870
  *
@@ -2847,7 +2872,7 @@ function createSessionRpc(connection, sessionId) {
2847
2872
  *
2848
2873
  * @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
2874
  */
2850
- recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
2875
+ recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { ...params, sessionId }),
2851
2876
  /**
2852
2877
  * 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
2878
  *
@@ -2855,7 +2880,7 @@ function createSessionRpc(connection, sessionId) {
2855
2880
  *
2856
2881
  * @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
2882
  */
2858
- setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { sessionId, ...params }),
2883
+ setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { ...params, sessionId }),
2859
2884
  /**
2860
2885
  * Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
2861
2886
  *
@@ -2863,7 +2888,7 @@ function createSessionRpc(connection, sessionId) {
2863
2888
  *
2864
2889
  * @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
2890
  */
2866
- recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { sessionId, ...params })
2891
+ recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { ...params, sessionId })
2867
2892
  },
2868
2893
  /** @experimental */
2869
2894
  contentExclusion: {
@@ -2874,18 +2899,18 @@ function createSessionRpc(connection, sessionId) {
2874
2899
  *
2875
2900
  * @returns Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
2876
2901
  */
2877
- checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { sessionId, ...params })
2902
+ checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { ...params, sessionId })
2878
2903
  },
2879
2904
  /** @experimental */
2880
2905
  shell: {
2881
2906
  /**
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.
2907
+ * 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
2908
  *
2884
- * @param params Shell command to run, with optional working directory and timeout in milliseconds.
2909
+ * @param params Shell command to run, with optional working directory and timeout in milliseconds. Spawn failures return an RPC error.
2885
2910
  *
2886
- * @returns Identifier of the spawned process, used to correlate streamed output and exit notifications.
2911
+ * @returns Identifier of the spawned shell process, usable with shell.kill while the process is running.
2887
2912
  */
2888
- exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
2913
+ exec: async (params) => connection.sendRequest("session.shell.exec", { ...params, sessionId }),
2889
2914
  /**
2890
2915
  * 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
2916
  *
@@ -2893,7 +2918,7 @@ function createSessionRpc(connection, sessionId) {
2893
2918
  *
2894
2919
  * @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
2895
2920
  */
2896
- kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params }),
2921
+ kill: async (params) => connection.sendRequest("session.shell.kill", { ...params, sessionId }),
2897
2922
  /**
2898
2923
  * Executes a user-requested shell command through the session runtime.
2899
2924
  *
@@ -2901,7 +2926,7 @@ function createSessionRpc(connection, sessionId) {
2901
2926
  *
2902
2927
  * @returns Result of a user-requested shell command.
2903
2928
  */
2904
- executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { sessionId, ...params }),
2929
+ executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { ...params, sessionId }),
2905
2930
  /**
2906
2931
  * Cancels a user-requested shell command by request ID.
2907
2932
  *
@@ -2909,7 +2934,7 @@ function createSessionRpc(connection, sessionId) {
2909
2934
  *
2910
2935
  * @returns Cancellation result for a user-requested shell command.
2911
2936
  */
2912
- cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { sessionId, ...params })
2937
+ cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { ...params, sessionId })
2913
2938
  },
2914
2939
  /** @experimental */
2915
2940
  history: {
@@ -2920,7 +2945,7 @@ function createSessionRpc(connection, sessionId) {
2920
2945
  *
2921
2946
  * @returns Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
2922
2947
  */
2923
- compact: async (params) => connection.sendRequest("session.history.compact", { sessionId, ...params }),
2948
+ compact: async (params) => connection.sendRequest("session.history.compact", { ...params, sessionId }),
2924
2949
  /**
2925
2950
  * Truncates persisted session history to a specific event.
2926
2951
  *
@@ -2928,7 +2953,7 @@ function createSessionRpc(connection, sessionId) {
2928
2953
  *
2929
2954
  * @returns Number of events that were removed by the truncation.
2930
2955
  */
2931
- truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params }),
2956
+ truncate: async (params) => connection.sendRequest("session.history.truncate", { ...params, sessionId }),
2932
2957
  /**
2933
2958
  * 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
2959
  *
@@ -2942,7 +2967,7 @@ function createSessionRpc(connection, sessionId) {
2942
2967
  *
2943
2968
  * @returns Files and aggregate changes for a prospective rewind.
2944
2969
  */
2945
- previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { sessionId, ...params }),
2970
+ previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { ...params, sessionId }),
2946
2971
  /**
2947
2972
  * 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
2973
  *
@@ -2950,7 +2975,7 @@ function createSessionRpc(connection, sessionId) {
2950
2975
  *
2951
2976
  * @returns Structured outcome of a rewind request.
2952
2977
  */
2953
- rewind: async (params) => connection.sendRequest("session.history.rewind", { sessionId, ...params }),
2978
+ rewind: async (params) => connection.sendRequest("session.history.rewind", { ...params, sessionId }),
2954
2979
  /**
2955
2980
  * Cancels any in-progress background compaction on a local session.
2956
2981
  *
@@ -2976,7 +3001,7 @@ function createSessionRpc(connection, sessionId) {
2976
3001
  *
2977
3002
  * @returns What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
2978
3003
  */
2979
- clearContext: async (params) => connection.sendRequest("session.history.clearContext", { sessionId, ...params })
3004
+ clearContext: async (params) => connection.sendRequest("session.history.clearContext", { ...params, sessionId })
2980
3005
  },
2981
3006
  /** @experimental */
2982
3007
  queue: {
@@ -2993,7 +3018,7 @@ function createSessionRpc(connection, sessionId) {
2993
3018
  *
2994
3019
  * @returns Result of moving a queued item.
2995
3020
  */
2996
- moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { sessionId, ...params }),
3021
+ moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { ...params, sessionId }),
2997
3022
  /**
2998
3023
  * Inserts a new queued message at a public visible position.
2999
3024
  *
@@ -3001,7 +3026,7 @@ function createSessionRpc(connection, sessionId) {
3001
3026
  *
3002
3027
  * @returns Result of inserting a queued message.
3003
3028
  */
3004
- insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { sessionId, ...params }),
3029
+ insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { ...params, sessionId }),
3005
3030
  /**
3006
3031
  * Removes an addressable queued item by its stable id.
3007
3032
  *
@@ -3009,7 +3034,7 @@ function createSessionRpc(connection, sessionId) {
3009
3034
  *
3010
3035
  * @returns Result of removing a queued item.
3011
3036
  */
3012
- removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { sessionId, ...params }),
3037
+ removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { ...params, sessionId }),
3013
3038
  /**
3014
3039
  * Updates the text of an addressable single-message queue item.
3015
3040
  *
@@ -3017,7 +3042,7 @@ function createSessionRpc(connection, sessionId) {
3017
3042
  *
3018
3043
  * @returns Result of editing a queued message.
3019
3044
  */
3020
- updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
3045
+ updateText: async (params) => connection.sendRequest("session.queue.updateText", { ...params, sessionId }),
3021
3046
  /**
3022
3047
  * 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
3048
  *
@@ -3025,7 +3050,7 @@ function createSessionRpc(connection, sessionId) {
3025
3050
  *
3026
3051
  * @returns Result of withdrawing a user message.
3027
3052
  */
3028
- withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
3053
+ withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { ...params, sessionId }),
3029
3054
  /**
3030
3055
  * Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
3031
3056
  *
@@ -3033,7 +3058,7 @@ function createSessionRpc(connection, sessionId) {
3033
3058
  *
3034
3059
  * @returns Result of editing a queued message.
3035
3060
  */
3036
- appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { sessionId, ...params }),
3061
+ appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { ...params, sessionId }),
3037
3062
  /**
3038
3063
  * Duplicates an addressable queued item immediately after its source.
3039
3064
  *
@@ -3041,13 +3066,13 @@ function createSessionRpc(connection, sessionId) {
3041
3066
  *
3042
3067
  * @returns Result of duplicating a queued item.
3043
3068
  */
3044
- duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { sessionId, ...params }),
3069
+ duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { ...params, sessionId }),
3045
3070
  /**
3046
3071
  * Acquires or releases the queued-lane drain pause.
3047
3072
  *
3048
3073
  * @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
3074
  */
3050
- setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { sessionId, ...params }),
3075
+ setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { ...params, sessionId }),
3051
3076
  /**
3052
3077
  * Moves an addressable queued message into the live turn's steering lane.
3053
3078
  *
@@ -3055,7 +3080,7 @@ function createSessionRpc(connection, sessionId) {
3055
3080
  *
3056
3081
  * @returns Result of trying to steer a queued message into a live turn.
3057
3082
  */
3058
- sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { sessionId, ...params }),
3083
+ sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { ...params, sessionId }),
3059
3084
  /**
3060
3085
  * Removes the most recently queued user-facing item (LIFO).
3061
3086
  *
@@ -3076,7 +3101,7 @@ function createSessionRpc(connection, sessionId) {
3076
3101
  *
3077
3102
  * @returns Batch of session events returned by a read, with cursor and continuation metadata.
3078
3103
  */
3079
- read: async (params) => connection.sendRequest("session.eventLog.read", { sessionId, ...params }),
3104
+ read: async (params) => connection.sendRequest("session.eventLog.read", { ...params, sessionId }),
3080
3105
  /**
3081
3106
  * Returns a snapshot of the current tail cursor without consuming events.
3082
3107
  *
@@ -3090,7 +3115,7 @@ function createSessionRpc(connection, sessionId) {
3090
3115
  *
3091
3116
  * @returns Opaque handle representing an event-type interest registration.
3092
3117
  */
3093
- registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { sessionId, ...params }),
3118
+ registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { ...params, sessionId }),
3094
3119
  /**
3095
3120
  * Releases a consumer's previously-registered interest in an event type.
3096
3121
  *
@@ -3098,7 +3123,7 @@ function createSessionRpc(connection, sessionId) {
3098
3123
  *
3099
3124
  * @returns Indicates whether the operation succeeded.
3100
3125
  */
3101
- releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { sessionId, ...params })
3126
+ releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { ...params, sessionId })
3102
3127
  },
3103
3128
  /** @experimental */
3104
3129
  usage: {
@@ -3118,7 +3143,7 @@ function createSessionRpc(connection, sessionId) {
3118
3143
  *
3119
3144
  * @returns Prediction result. Available results include prediction details; unavailable results include an explicit reason.
3120
3145
  */
3121
- predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { sessionId, ...params })
3146
+ predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { ...params, sessionId })
3122
3147
  },
3123
3148
  /** @experimental */
3124
3149
  remote: {
@@ -3129,7 +3154,7 @@ function createSessionRpc(connection, sessionId) {
3129
3154
  *
3130
3155
  * @returns GitHub URL for the session and a flag indicating whether remote steering is enabled.
3131
3156
  */
3132
- enable: async (params) => connection.sendRequest("session.remote.enable", { sessionId, ...params }),
3157
+ enable: async (params) => connection.sendRequest("session.remote.enable", { ...params, sessionId }),
3133
3158
  /**
3134
3159
  * Disables remote session export and steering.
3135
3160
  */
@@ -3141,7 +3166,7 @@ function createSessionRpc(connection, sessionId) {
3141
3166
  *
3142
3167
  * @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
3168
  */
3144
- notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
3169
+ notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { ...params, sessionId })
3145
3170
  },
3146
3171
  /** @experimental */
3147
3172
  visibility: {
@@ -3158,7 +3183,7 @@ function createSessionRpc(connection, sessionId) {
3158
3183
  *
3159
3184
  * @returns Effective sharing status and shareable GitHub URL after updating session visibility.
3160
3185
  */
3161
- set: async (params) => connection.sendRequest("session.visibility.set", { sessionId, ...params })
3186
+ set: async (params) => connection.sendRequest("session.visibility.set", { ...params, sessionId })
3162
3187
  },
3163
3188
  /** @experimental */
3164
3189
  schedule: {
@@ -3175,7 +3200,7 @@ function createSessionRpc(connection, sessionId) {
3175
3200
  *
3176
3201
  * @returns Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
3177
3202
  */
3178
- stop: async (params) => connection.sendRequest("session.schedule.stop", { sessionId, ...params })
3203
+ stop: async (params) => connection.sendRequest("session.schedule.stop", { ...params, sessionId })
3179
3204
  }
3180
3205
  };
3181
3206
  }
@@ -3188,7 +3213,7 @@ function createInternalSessionRpc(connection, sessionId) {
3188
3213
  *
3189
3214
  * @experimental
3190
3215
  */
3191
- sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { sessionId, ...params }),
3216
+ sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { ...params, sessionId }),
3192
3217
  /** @experimental */
3193
3218
  gitHubAuth: {
3194
3219
  /**
@@ -3216,13 +3241,13 @@ function createInternalSessionRpc(connection, sessionId) {
3216
3241
  *
3217
3242
  * @returns Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
3218
3243
  */
3219
- login: async (params) => connection.sendRequest("session.gitHubAuth.login", { sessionId, ...params }),
3244
+ login: async (params) => connection.sendRequest("session.gitHubAuth.login", { ...params, sessionId }),
3220
3245
  /**
3221
3246
  * Switches the session to another available authentication.
3222
3247
  *
3223
3248
  * @param params Parameters for switching the session's active authentication.
3224
3249
  */
3225
- switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { sessionId, ...params }),
3250
+ switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { ...params, sessionId }),
3226
3251
  /**
3227
3252
  * Logs out the session's current GitHub authentication.
3228
3253
  *
@@ -3236,7 +3261,7 @@ function createInternalSessionRpc(connection, sessionId) {
3236
3261
  *
3237
3262
  * @returns Whether the requested authentication was logged out.
3238
3263
  */
3239
- logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { sessionId, ...params }),
3264
+ logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { ...params, sessionId }),
3240
3265
  /**
3241
3266
  * Gets validation errors from the most recent authentication attempt.
3242
3267
  *
@@ -3253,13 +3278,13 @@ function createInternalSessionRpc(connection, sessionId) {
3253
3278
  *
3254
3279
  * @param params Internal canvas provider registration parameters.
3255
3280
  */
3256
- register: async (params) => connection.sendRequest("session.canvas.provider.register", { sessionId, ...params }),
3281
+ register: async (params) => connection.sendRequest("session.canvas.provider.register", { ...params, sessionId }),
3257
3282
  /**
3258
3283
  * Unregisters an internal canvas provider connection.
3259
3284
  *
3260
3285
  * @param params Internal canvas provider unregistration parameters.
3261
3286
  */
3262
- unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { sessionId, ...params })
3287
+ unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { ...params, sessionId })
3263
3288
  }
3264
3289
  },
3265
3290
  /** @experimental */
@@ -3271,7 +3296,7 @@ function createInternalSessionRpc(connection, sessionId) {
3271
3296
  *
3272
3297
  * @returns Complete current or terminal workflow run envelope.
3273
3298
  */
3274
- runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { sessionId, ...params }),
3299
+ runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { ...params, sessionId }),
3275
3300
  /**
3276
3301
  * Internal tool-originated dynamic workflow resume.
3277
3302
  *
@@ -3279,13 +3304,13 @@ function createInternalSessionRpc(connection, sessionId) {
3279
3304
  *
3280
3305
  * @returns Resolved persisted workflow identity and resumed run envelope.
3281
3306
  */
3282
- resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { sessionId, ...params }),
3307
+ resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { ...params, sessionId }),
3283
3308
  /**
3284
3309
  * Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
3285
3310
  *
3286
3311
  * @param params Parameters for an owned durable pause checkpoint.
3287
3312
  */
3288
- pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { sessionId, ...params })
3313
+ pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { ...params, sessionId })
3289
3314
  },
3290
3315
  /** @experimental */
3291
3316
  model: {
@@ -3296,7 +3321,7 @@ function createInternalSessionRpc(connection, sessionId) {
3296
3321
  *
3297
3322
  * @returns The model identifier active on the session after the switch.
3298
3323
  */
3299
- applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { sessionId, ...params })
3324
+ applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { ...params, sessionId })
3300
3325
  },
3301
3326
  /** @experimental */
3302
3327
  mcp: {
@@ -3307,7 +3332,7 @@ function createInternalSessionRpc(connection, sessionId) {
3307
3332
  *
3308
3333
  * @returns MCP server startup filtering result.
3309
3334
  */
3310
- reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { sessionId, ...params }),
3335
+ reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { ...params, sessionId }),
3311
3336
  /**
3312
3337
  * Configures the built-in GitHub MCP server for the session's current auth context.
3313
3338
  *
@@ -3315,19 +3340,19 @@ function createInternalSessionRpc(connection, sessionId) {
3315
3340
  *
3316
3341
  * @returns Result of configuring GitHub MCP.
3317
3342
  */
3318
- configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { sessionId, ...params }),
3343
+ configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { ...params, sessionId }),
3319
3344
  /**
3320
3345
  * 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
3346
  *
3322
3347
  * @param params Registration parameters for an external MCP client.
3323
3348
  */
3324
- registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { sessionId, ...params }),
3349
+ registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { ...params, sessionId }),
3325
3350
  /**
3326
3351
  * 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
3352
  *
3328
3353
  * @param params Server name identifying the external client to remove.
3329
3354
  */
3330
- unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
3355
+ unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { ...params, sessionId })
3331
3356
  },
3332
3357
  /** @experimental */
3333
3358
  connectors: {
@@ -3338,7 +3363,7 @@ function createInternalSessionRpc(connection, sessionId) {
3338
3363
  *
3339
3364
  * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
3340
3365
  */
3341
- reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
3366
+ reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { ...params, sessionId }),
3342
3367
  /**
3343
3368
  * Removes the runtime-owned Connector MCP projection without changing service-side connections.
3344
3369
  *
@@ -3355,7 +3380,7 @@ function createInternalSessionRpc(connection, sessionId) {
3355
3380
  *
3356
3381
  * @returns Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
3357
3382
  */
3358
- finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { sessionId, ...params })
3383
+ finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { ...params, sessionId })
3359
3384
  },
3360
3385
  /** @experimental */
3361
3386
  settings: {
@@ -3372,7 +3397,7 @@ function createInternalSessionRpc(connection, sessionId) {
3372
3397
  *
3373
3398
  * @returns Result of evaluating a Rust-owned settings predicate.
3374
3399
  */
3375
- evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { sessionId, ...params })
3400
+ evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { ...params, sessionId })
3376
3401
  },
3377
3402
  /** @experimental */
3378
3403
  queue: {
@@ -3395,7 +3420,7 @@ function createInternalSessionRpc(connection, sessionId) {
3395
3420
  *
3396
3421
  * @returns Whether a deferred-idle drain should run.
3397
3422
  */
3398
- beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { sessionId, ...params }),
3423
+ beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { ...params, sessionId }),
3399
3424
  /**
3400
3425
  * Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
3401
3426
  *
@@ -3403,13 +3428,13 @@ function createInternalSessionRpc(connection, sessionId) {
3403
3428
  *
3404
3429
  * @returns Action selected by the native deferred-idle drain.
3405
3430
  */
3406
- finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { sessionId, ...params }),
3431
+ finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { ...params, sessionId }),
3407
3432
  /**
3408
3433
  * Marks session.idle as deferred by native background work state.
3409
3434
  *
3410
3435
  * @param params Inputs for marking session.idle deferred in native state.
3411
3436
  */
3412
- deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { sessionId, ...params }),
3437
+ deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { ...params, sessionId }),
3413
3438
  /**
3414
3439
  * Consumes queued native system notifications matching an internal filter.
3415
3440
  *
@@ -3417,7 +3442,7 @@ function createInternalSessionRpc(connection, sessionId) {
3417
3442
  *
3418
3443
  * @returns Indicates whether a user-facing pending item was removed.
3419
3444
  */
3420
- consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { sessionId, ...params }),
3445
+ consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { ...params, sessionId }),
3421
3446
  /**
3422
3447
  * Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
3423
3448
  *
@@ -3448,7 +3473,7 @@ function createInternalSessionRpc(connection, sessionId) {
3448
3473
  *
3449
3474
  * @returns Result of registering or re-arming a scheduled prompt.
3450
3475
  */
3451
- add: async (params) => connection.sendRequest("session.schedule.add", { sessionId, ...params }),
3476
+ add: async (params) => connection.sendRequest("session.schedule.add", { ...params, sessionId }),
3452
3477
  /**
3453
3478
  * Registers a recurring cron scheduled prompt.
3454
3479
  *
@@ -3456,7 +3481,7 @@ function createInternalSessionRpc(connection, sessionId) {
3456
3481
  *
3457
3482
  * @returns Result of registering or re-arming a scheduled prompt.
3458
3483
  */
3459
- addCron: async (params) => connection.sendRequest("session.schedule.addCron", { sessionId, ...params }),
3484
+ addCron: async (params) => connection.sendRequest("session.schedule.addCron", { ...params, sessionId }),
3460
3485
  /**
3461
3486
  * Registers an absolute-time scheduled prompt.
3462
3487
  *
@@ -3464,7 +3489,7 @@ function createInternalSessionRpc(connection, sessionId) {
3464
3489
  *
3465
3490
  * @returns Result of registering or re-arming a scheduled prompt.
3466
3491
  */
3467
- addAt: async (params) => connection.sendRequest("session.schedule.addAt", { sessionId, ...params }),
3492
+ addAt: async (params) => connection.sendRequest("session.schedule.addAt", { ...params, sessionId }),
3468
3493
  /**
3469
3494
  * Registers a self-paced scheduled prompt.
3470
3495
  *
@@ -3472,7 +3497,7 @@ function createInternalSessionRpc(connection, sessionId) {
3472
3497
  *
3473
3498
  * @returns Result of registering or re-arming a scheduled prompt.
3474
3499
  */
3475
- addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { sessionId, ...params }),
3500
+ addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { ...params, sessionId }),
3476
3501
  /**
3477
3502
  * Re-arms an active self-paced scheduled prompt.
3478
3503
  *
@@ -3480,7 +3505,7 @@ function createInternalSessionRpc(connection, sessionId) {
3480
3505
  *
3481
3506
  * @returns Result of registering or re-arming a scheduled prompt.
3482
3507
  */
3483
- rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { sessionId, ...params })
3508
+ rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { ...params, sessionId })
3484
3509
  }
3485
3510
  };
3486
3511
  }