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

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.
@@ -1050,7 +1050,7 @@ function createSessionRpc(connection, sessionId) {
1050
1050
  *
1051
1051
  * @experimental
1052
1052
  */
1053
- send: async (params) => connection.sendRequest("session.send", { sessionId, ...params }),
1053
+ send: async (params) => connection.sendRequest("session.send", { ...params, sessionId }),
1054
1054
  /**
1055
1055
  * 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.
1056
1056
  *
@@ -1060,7 +1060,7 @@ function createSessionRpc(connection, sessionId) {
1060
1060
  *
1061
1061
  * @experimental
1062
1062
  */
1063
- sendMessages: async (params) => connection.sendRequest("session.sendMessages", { sessionId, ...params }),
1063
+ sendMessages: async (params) => connection.sendRequest("session.sendMessages", { ...params, sessionId }),
1064
1064
  /** @experimental */
1065
1065
  sandbox: {
1066
1066
  /**
@@ -1076,7 +1076,7 @@ function createSessionRpc(connection, sessionId) {
1076
1076
  *
1077
1077
  * @returns Result of attempting to disable sandboxing for the current session.
1078
1078
  */
1079
- disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params }),
1079
+ disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { ...params, sessionId }),
1080
1080
  /**
1081
1081
  * 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.
1082
1082
  *
@@ -1084,7 +1084,7 @@ function createSessionRpc(connection, sessionId) {
1084
1084
  *
1085
1085
  * @returns Result of accepting a sandbox path grant.
1086
1086
  */
1087
- grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { sessionId, ...params })
1087
+ grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { ...params, sessionId })
1088
1088
  },
1089
1089
  /**
1090
1090
  * Aborts the current agent turn.
@@ -1095,7 +1095,7 @@ function createSessionRpc(connection, sessionId) {
1095
1095
  *
1096
1096
  * @experimental
1097
1097
  */
1098
- abort: async (params) => connection.sendRequest("session.abort", { sessionId, ...params }),
1098
+ abort: async (params) => connection.sendRequest("session.abort", { ...params, sessionId }),
1099
1099
  /**
1100
1100
  * 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.
1101
1101
  *
@@ -1105,7 +1105,7 @@ function createSessionRpc(connection, sessionId) {
1105
1105
  *
1106
1106
  * @experimental
1107
1107
  */
1108
- interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { sessionId, ...params }),
1108
+ interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { ...params, sessionId }),
1109
1109
  /**
1110
1110
  * Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
1111
1111
  *
@@ -1121,7 +1121,7 @@ function createSessionRpc(connection, sessionId) {
1121
1121
  *
1122
1122
  * @experimental
1123
1123
  */
1124
- shutdown: async (params) => connection.sendRequest("session.shutdown", { sessionId, ...params }),
1124
+ shutdown: async (params) => connection.sendRequest("session.shutdown", { ...params, sessionId }),
1125
1125
  /** @experimental */
1126
1126
  gitHubAuth: {
1127
1127
  /**
@@ -1137,7 +1137,7 @@ function createSessionRpc(connection, sessionId) {
1137
1137
  *
1138
1138
  * @returns Indicates whether the credential update succeeded.
1139
1139
  */
1140
- setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { sessionId, ...params })
1140
+ setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { ...params, sessionId })
1141
1141
  },
1142
1142
  /** @experimental */
1143
1143
  accounts: {
@@ -1148,7 +1148,7 @@ function createSessionRpc(connection, sessionId) {
1148
1148
  *
1149
1149
  * @returns The enumerated collection, keyed by the same selector as the query.
1150
1150
  */
1151
- enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { sessionId, ...params }),
1151
+ enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { ...params, sessionId }),
1152
1152
  /**
1153
1153
  * Read one typed accounts datum: the active account, a neutral status summary, or the last authentication errors.
1154
1154
  *
@@ -1156,7 +1156,7 @@ function createSessionRpc(connection, sessionId) {
1156
1156
  *
1157
1157
  * @returns The read result, keyed by the same selector as the query.
1158
1158
  */
1159
- get: async (params) => connection.sendRequest("session.accounts.get", { sessionId, ...params }),
1159
+ get: async (params) => connection.sendRequest("session.accounts.get", { ...params, sessionId }),
1160
1160
  /**
1161
1161
  * Apply one non-interactive accounts mutation: switch the active account, log an account out, or set credentials from a token.
1162
1162
  *
@@ -1164,7 +1164,7 @@ function createSessionRpc(connection, sessionId) {
1164
1164
  *
1165
1165
  * @returns Result of a non-interactive accounts mutation.
1166
1166
  */
1167
- set: async (params) => connection.sendRequest("session.accounts.set", { sessionId, ...params }),
1167
+ set: async (params) => connection.sendRequest("session.accounts.set", { ...params, sessionId }),
1168
1168
  /** @experimental */
1169
1169
  login: {
1170
1170
  /**
@@ -1174,7 +1174,7 @@ function createSessionRpc(connection, sessionId) {
1174
1174
  *
1175
1175
  * @returns A started login flow: its opaque id and first step.
1176
1176
  */
1177
- begin: async (params) => connection.sendRequest("session.accounts.login.begin", { sessionId, ...params }),
1177
+ begin: async (params) => connection.sendRequest("session.accounts.login.begin", { ...params, sessionId }),
1178
1178
  /**
1179
1179
  * Advance an in-flight login flow, optionally fulfilling an input-required step, and return the next step.
1180
1180
  *
@@ -1182,13 +1182,13 @@ function createSessionRpc(connection, sessionId) {
1182
1182
  *
1183
1183
  * @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).
1184
1184
  */
1185
- advance: async (params) => connection.sendRequest("session.accounts.login.advance", { sessionId, ...params }),
1185
+ advance: async (params) => connection.sendRequest("session.accounts.login.advance", { ...params, sessionId }),
1186
1186
  /**
1187
1187
  * Cancel an in-flight login flow and release its resources.
1188
1188
  *
1189
1189
  * @param params Cancel an in-flight login flow.
1190
1190
  */
1191
- cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { sessionId, ...params })
1191
+ cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { ...params, sessionId })
1192
1192
  }
1193
1193
  },
1194
1194
  /** @experimental */
@@ -1200,7 +1200,7 @@ function createSessionRpc(connection, sessionId) {
1200
1200
  *
1201
1201
  * @returns Result of collecting a session debug bundle.
1202
1202
  */
1203
- collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
1203
+ collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { ...params, sessionId })
1204
1204
  },
1205
1205
  /** @experimental */
1206
1206
  canvas: {
@@ -1223,13 +1223,13 @@ function createSessionRpc(connection, sessionId) {
1223
1223
  *
1224
1224
  * @returns Open canvas instance snapshot.
1225
1225
  */
1226
- open: async (params) => connection.sendRequest("session.canvas.open", { sessionId, ...params }),
1226
+ open: async (params) => connection.sendRequest("session.canvas.open", { ...params, sessionId }),
1227
1227
  /**
1228
1228
  * Closes an open canvas instance.
1229
1229
  *
1230
1230
  * @param params Canvas close parameters.
1231
1231
  */
1232
- close: async (params) => connection.sendRequest("session.canvas.close", { sessionId, ...params }),
1232
+ close: async (params) => connection.sendRequest("session.canvas.close", { ...params, sessionId }),
1233
1233
  /** @experimental */
1234
1234
  action: {
1235
1235
  /**
@@ -1239,7 +1239,7 @@ function createSessionRpc(connection, sessionId) {
1239
1239
  *
1240
1240
  * @returns Canvas action invocation result.
1241
1241
  */
1242
- invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { sessionId, ...params })
1242
+ invoke: async (params) => connection.sendRequest("session.canvas.action.invoke", { ...params, sessionId })
1243
1243
  }
1244
1244
  },
1245
1245
  /** @experimental */
@@ -1251,7 +1251,7 @@ function createSessionRpc(connection, sessionId) {
1251
1251
  *
1252
1252
  * @returns Complete current or terminal workflow run envelope.
1253
1253
  */
1254
- run: async (params) => connection.sendRequest("session.workflow.run", { sessionId, ...params }),
1254
+ run: async (params) => connection.sendRequest("session.workflow.run", { ...params, sessionId }),
1255
1255
  /**
1256
1256
  * Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
1257
1257
  *
@@ -1259,7 +1259,7 @@ function createSessionRpc(connection, sessionId) {
1259
1259
  *
1260
1260
  * @returns Resolved persisted workflow identity and resumed run envelope.
1261
1261
  */
1262
- resume: async (params) => connection.sendRequest("session.workflow.resume", { sessionId, ...params }),
1262
+ resume: async (params) => connection.sendRequest("session.workflow.resume", { ...params, sessionId }),
1263
1263
  /**
1264
1264
  * Gets the current or settled envelope for a dynamic workflow run.
1265
1265
  *
@@ -1267,7 +1267,7 @@ function createSessionRpc(connection, sessionId) {
1267
1267
  *
1268
1268
  * @returns Complete current or terminal workflow run envelope.
1269
1269
  */
1270
- getRun: async (params) => connection.sendRequest("session.workflow.getRun", { sessionId, ...params }),
1270
+ getRun: async (params) => connection.sendRequest("session.workflow.getRun", { ...params, sessionId }),
1271
1271
  /**
1272
1272
  * Lists durable dynamic workflow runs for this session in creation order.
1273
1273
  *
@@ -1275,7 +1275,7 @@ function createSessionRpc(connection, sessionId) {
1275
1275
  *
1276
1276
  * @returns A page of workflow runs in durable creation order.
1277
1277
  */
1278
- listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { sessionId, ...params }),
1278
+ listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { ...params, sessionId }),
1279
1279
  /**
1280
1280
  * Gets durable and live observability detail for one dynamic workflow run.
1281
1281
  *
@@ -1283,7 +1283,7 @@ function createSessionRpc(connection, sessionId) {
1283
1283
  *
1284
1284
  * @returns Full workflow run observability detail.
1285
1285
  */
1286
- getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { sessionId, ...params }),
1286
+ getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { ...params, sessionId }),
1287
1287
  /**
1288
1288
  * Pages durable progress for one dynamic workflow run.
1289
1289
  *
@@ -1291,7 +1291,7 @@ function createSessionRpc(connection, sessionId) {
1291
1291
  *
1292
1292
  * @returns A bidirectional page of workflow progress.
1293
1293
  */
1294
- getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { sessionId, ...params }),
1294
+ getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { ...params, sessionId }),
1295
1295
  /**
1296
1296
  * Requests cancellation of a dynamic workflow run and returns its run envelope.
1297
1297
  *
@@ -1299,7 +1299,7 @@ function createSessionRpc(connection, sessionId) {
1299
1299
  *
1300
1300
  * @returns Complete current or terminal workflow run envelope.
1301
1301
  */
1302
- cancel: async (params) => connection.sendRequest("session.workflow.cancel", { sessionId, ...params }),
1302
+ cancel: async (params) => connection.sendRequest("session.workflow.cancel", { ...params, sessionId }),
1303
1303
  /**
1304
1304
  * Pauses a running dynamic workflow and returns its settled run envelope.
1305
1305
  *
@@ -1307,7 +1307,7 @@ function createSessionRpc(connection, sessionId) {
1307
1307
  *
1308
1308
  * @returns Complete current or terminal workflow run envelope.
1309
1309
  */
1310
- pause: async (params) => connection.sendRequest("session.workflow.pause", { sessionId, ...params }),
1310
+ pause: async (params) => connection.sendRequest("session.workflow.pause", { ...params, sessionId }),
1311
1311
  /**
1312
1312
  * Records a batch of ordered dynamic workflow progress lines.
1313
1313
  *
@@ -1315,7 +1315,7 @@ function createSessionRpc(connection, sessionId) {
1315
1315
  *
1316
1316
  * @returns Acknowledgement that a workflow request was accepted.
1317
1317
  */
1318
- log: async (params) => connection.sendRequest("session.workflow.log", { sessionId, ...params }),
1318
+ log: async (params) => connection.sendRequest("session.workflow.log", { ...params, sessionId }),
1319
1319
  /**
1320
1320
  * Runs one dynamic-workflow-scoped subagent and returns its result.
1321
1321
  *
@@ -1323,7 +1323,7 @@ function createSessionRpc(connection, sessionId) {
1323
1323
  *
1324
1324
  * @returns Result of one workflow-scoped subagent call.
1325
1325
  */
1326
- agent: async (params) => connection.sendRequest("session.workflow.agent", { sessionId, ...params }),
1326
+ agent: async (params) => connection.sendRequest("session.workflow.agent", { ...params, sessionId }),
1327
1327
  /** @experimental */
1328
1328
  journal: {
1329
1329
  /**
@@ -1333,7 +1333,7 @@ function createSessionRpc(connection, sessionId) {
1333
1333
  *
1334
1334
  * @returns Result of reading a workflow journal entry.
1335
1335
  */
1336
- get: async (params) => connection.sendRequest("session.workflow.journal.get", { sessionId, ...params }),
1336
+ get: async (params) => connection.sendRequest("session.workflow.journal.get", { ...params, sessionId }),
1337
1337
  /**
1338
1338
  * Stores a memoized dynamic workflow journal entry.
1339
1339
  *
@@ -1341,7 +1341,7 @@ function createSessionRpc(connection, sessionId) {
1341
1341
  *
1342
1342
  * @returns Acknowledgement that a workflow request was accepted.
1343
1343
  */
1344
- put: async (params) => connection.sendRequest("session.workflow.journal.put", { sessionId, ...params })
1344
+ put: async (params) => connection.sendRequest("session.workflow.journal.put", { ...params, sessionId })
1345
1345
  }
1346
1346
  },
1347
1347
  /** @experimental */
@@ -1359,7 +1359,7 @@ function createSessionRpc(connection, sessionId) {
1359
1359
  *
1360
1360
  * @returns The model identifier active on the session after the switch.
1361
1361
  */
1362
- switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params }),
1362
+ switchTo: async (params) => connection.sendRequest("session.model.switchTo", { ...params, sessionId }),
1363
1363
  /**
1364
1364
  * 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`.
1365
1365
  *
@@ -1367,7 +1367,7 @@ function createSessionRpc(connection, sessionId) {
1367
1367
  *
1368
1368
  * @returns Immediate acknowledgement and Auto preference snapshot after a switch request. This result never implies that a pending preference committed.
1369
1369
  */
1370
- switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { sessionId, ...params }),
1370
+ switchAutoTier: async (params) => connection.sendRequest("session.model.switchAutoTier", { ...params, sessionId }),
1371
1371
  /**
1372
1372
  * Replaces or clears the host-supplied model allowlist for a running session.
1373
1373
  *
@@ -1375,7 +1375,7 @@ function createSessionRpc(connection, sessionId) {
1375
1375
  *
1376
1376
  * @returns The applied host allowlist and effective session model policy after intersection.
1377
1377
  */
1378
- setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { sessionId, ...params }),
1378
+ setAllowedModels: async (params) => connection.sendRequest("session.model.setAllowedModels", { ...params, sessionId }),
1379
1379
  /**
1380
1380
  * Updates the session's reasoning effort without changing the selected model.
1381
1381
  *
@@ -1383,7 +1383,7 @@ function createSessionRpc(connection, sessionId) {
1383
1383
  *
1384
1384
  * @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.
1385
1385
  */
1386
- setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { sessionId, ...params }),
1386
+ setReasoningEffort: async (params) => connection.sendRequest("session.model.setReasoningEffort", { ...params, sessionId }),
1387
1387
  /**
1388
1388
  * 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.
1389
1389
  *
@@ -1391,7 +1391,7 @@ function createSessionRpc(connection, sessionId) {
1391
1391
  *
1392
1392
  * @returns The list of models available to this session.
1393
1393
  */
1394
- list: async (params) => connection.sendRequest("session.model.list", { sessionId, ...params })
1394
+ list: async (params) => connection.sendRequest("session.model.list", { ...params, sessionId })
1395
1395
  },
1396
1396
  /** @experimental */
1397
1397
  mode: {
@@ -1408,7 +1408,7 @@ function createSessionRpc(connection, sessionId) {
1408
1408
  *
1409
1409
  * @returns Outcome of a session mode change, including any model switch it triggered and follow-up the host must perform.
1410
1410
  */
1411
- set: async (params) => connection.sendRequest("session.mode.set", { sessionId, ...params })
1411
+ set: async (params) => connection.sendRequest("session.mode.set", { ...params, sessionId })
1412
1412
  },
1413
1413
  /** @experimental */
1414
1414
  name: {
@@ -1423,7 +1423,7 @@ function createSessionRpc(connection, sessionId) {
1423
1423
  *
1424
1424
  * @param params New friendly name to apply to the session.
1425
1425
  */
1426
- set: async (params) => connection.sendRequest("session.name.set", { sessionId, ...params }),
1426
+ set: async (params) => connection.sendRequest("session.name.set", { ...params, sessionId }),
1427
1427
  /**
1428
1428
  * Persists an auto-generated session summary as the session's name when no user-set name exists.
1429
1429
  *
@@ -1431,7 +1431,7 @@ function createSessionRpc(connection, sessionId) {
1431
1431
  *
1432
1432
  * @returns Indicates whether the auto-generated summary was applied as the session's name.
1433
1433
  */
1434
- setAuto: async (params) => connection.sendRequest("session.name.setAuto", { sessionId, ...params })
1434
+ setAuto: async (params) => connection.sendRequest("session.name.setAuto", { ...params, sessionId })
1435
1435
  },
1436
1436
  /** @experimental */
1437
1437
  plan: {
@@ -1446,7 +1446,7 @@ function createSessionRpc(connection, sessionId) {
1446
1446
  *
1447
1447
  * @param params Replacement contents to write to the session plan file.
1448
1448
  */
1449
- update: async (params) => connection.sendRequest("session.plan.update", { sessionId, ...params }),
1449
+ update: async (params) => connection.sendRequest("session.plan.update", { ...params, sessionId }),
1450
1450
  /**
1451
1451
  * Deletes the session plan file from the workspace.
1452
1452
  */
@@ -1479,7 +1479,7 @@ function createSessionRpc(connection, sessionId) {
1479
1479
  *
1480
1480
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1481
1481
  */
1482
- updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { sessionId, ...params }),
1482
+ updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { ...params, sessionId }),
1483
1483
  /**
1484
1484
  * Ensures a local session workspace exists and returns it.
1485
1485
  *
@@ -1487,7 +1487,7 @@ function createSessionRpc(connection, sessionId) {
1487
1487
  *
1488
1488
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1489
1489
  */
1490
- ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { sessionId, ...params }),
1490
+ ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { ...params, sessionId }),
1491
1491
  /**
1492
1492
  * Lists files stored in the session workspace files directory.
1493
1493
  *
@@ -1501,13 +1501,13 @@ function createSessionRpc(connection, sessionId) {
1501
1501
  *
1502
1502
  * @returns Contents of the requested workspace file as a UTF-8 string.
1503
1503
  */
1504
- readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { sessionId, ...params }),
1504
+ readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { ...params, sessionId }),
1505
1505
  /**
1506
1506
  * Creates or overwrites a file in the session workspace files directory.
1507
1507
  *
1508
1508
  * @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
1509
1509
  */
1510
- createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
1510
+ createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { ...params, sessionId }),
1511
1511
  /**
1512
1512
  * Returns metadata for a file or directory in the session workspace files directory.
1513
1513
  *
@@ -1515,25 +1515,25 @@ function createSessionRpc(connection, sessionId) {
1515
1515
  *
1516
1516
  * @returns Filesystem metadata for a path in the session workspace files directory.
1517
1517
  */
1518
- statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
1518
+ statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { ...params, sessionId }),
1519
1519
  /**
1520
1520
  * Creates a directory in the session workspace files directory.
1521
1521
  *
1522
1522
  * @param params Directory to create within the session workspace files directory.
1523
1523
  */
1524
- createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
1524
+ createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { ...params, sessionId }),
1525
1525
  /**
1526
1526
  * Removes a file or directory from the session workspace files directory.
1527
1527
  *
1528
1528
  * @param params File or directory to remove from the session workspace files directory.
1529
1529
  */
1530
- removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
1530
+ removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { ...params, sessionId }),
1531
1531
  /**
1532
1532
  * Renames a file or directory within the session workspace files directory.
1533
1533
  *
1534
1534
  * @param params Source and destination paths for a rename within the session workspace files directory.
1535
1535
  */
1536
- renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
1536
+ renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { ...params, sessionId }),
1537
1537
  /**
1538
1538
  * Lists workspace checkpoints in chronological order.
1539
1539
  *
@@ -1547,7 +1547,7 @@ function createSessionRpc(connection, sessionId) {
1547
1547
  *
1548
1548
  * @returns Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
1549
1549
  */
1550
- readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { sessionId, ...params }),
1550
+ readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { ...params, sessionId }),
1551
1551
  /**
1552
1552
  * Adds a compaction summary checkpoint to the local session workspace.
1553
1553
  *
@@ -1555,7 +1555,7 @@ function createSessionRpc(connection, sessionId) {
1555
1555
  *
1556
1556
  * @returns Persisted summary metadata and refreshed workspace metadata.
1557
1557
  */
1558
- addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { sessionId, ...params }),
1558
+ addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { ...params, sessionId }),
1559
1559
  /**
1560
1560
  * Truncates local workspace compaction summaries after a rollback.
1561
1561
  *
@@ -1563,7 +1563,7 @@ function createSessionRpc(connection, sessionId) {
1563
1563
  *
1564
1564
  * @returns Current workspace metadata for the session, including its absolute filesystem path when available.
1565
1565
  */
1566
- truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { sessionId, ...params }),
1566
+ truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { ...params, sessionId }),
1567
1567
  /**
1568
1568
  * Reads the autopilot objective state file from the local session workspace.
1569
1569
  *
@@ -1577,7 +1577,7 @@ function createSessionRpc(connection, sessionId) {
1577
1577
  *
1578
1578
  * @returns Result of writing the autopilot objective file.
1579
1579
  */
1580
- writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { sessionId, ...params }),
1580
+ writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { ...params, sessionId }),
1581
1581
  /**
1582
1582
  * Deletes the autopilot objective state file from the local session workspace.
1583
1583
  *
@@ -1597,7 +1597,7 @@ function createSessionRpc(connection, sessionId) {
1597
1597
  *
1598
1598
  * @returns Descriptor for the saved paste file, or null when the workspace is unavailable.
1599
1599
  */
1600
- saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
1600
+ saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { ...params, sessionId }),
1601
1601
  /**
1602
1602
  * 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`.
1603
1603
  *
@@ -1605,7 +1605,7 @@ function createSessionRpc(connection, sessionId) {
1605
1605
  *
1606
1606
  * @returns Workspace diff result for the requested mode.
1607
1607
  */
1608
- diff: async (params) => connection.sendRequest("session.workspaces.diff", { sessionId, ...params })
1608
+ diff: async (params) => connection.sendRequest("session.workspaces.diff", { ...params, sessionId })
1609
1609
  },
1610
1610
  /** @experimental */
1611
1611
  autopilotObjective: {
@@ -1631,7 +1631,7 @@ function createSessionRpc(connection, sessionId) {
1631
1631
  *
1632
1632
  * @returns Host-driven completion items for the current composer input. Empty when the host returns no items or does not support completions.
1633
1633
  */
1634
- request: async (params) => connection.sendRequest("session.completions.request", { sessionId, ...params })
1634
+ request: async (params) => connection.sendRequest("session.completions.request", { ...params, sessionId })
1635
1635
  },
1636
1636
  /** @experimental */
1637
1637
  instructions: {
@@ -1664,7 +1664,7 @@ function createSessionRpc(connection, sessionId) {
1664
1664
  *
1665
1665
  * @returns Indicates whether fleet mode was successfully activated.
1666
1666
  */
1667
- start: async (params) => connection.sendRequest("session.fleet.start", { sessionId, ...params })
1667
+ start: async (params) => connection.sendRequest("session.fleet.start", { ...params, sessionId })
1668
1668
  },
1669
1669
  /** @experimental */
1670
1670
  agent: {
@@ -1675,13 +1675,13 @@ function createSessionRpc(connection, sessionId) {
1675
1675
  *
1676
1676
  * @returns Agents available to the session.
1677
1677
  */
1678
- list: async (params) => connection.sendRequest("session.agent.list", { sessionId, ...params }),
1678
+ list: async (params) => connection.sendRequest("session.agent.list", { ...params, sessionId }),
1679
1679
  /**
1680
1680
  * 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.
1681
1681
  *
1682
1682
  * @param params An in-memory authored prompt override for an available agent.
1683
1683
  */
1684
- setPrompt: async (params) => connection.sendRequest("session.agent.setPrompt", { sessionId, ...params }),
1684
+ setPrompt: async (params) => connection.sendRequest("session.agent.setPrompt", { ...params, sessionId }),
1685
1685
  /**
1686
1686
  * Gets the currently selected custom agent for the session.
1687
1687
  *
@@ -1695,7 +1695,7 @@ function createSessionRpc(connection, sessionId) {
1695
1695
  *
1696
1696
  * @returns The newly selected custom agent.
1697
1697
  */
1698
- select: async (params) => connection.sendRequest("session.agent.select", { sessionId, ...params }),
1698
+ select: async (params) => connection.sendRequest("session.agent.select", { ...params, sessionId }),
1699
1699
  /**
1700
1700
  * Clears the selected custom agent and returns the session to the default agent.
1701
1701
  */
@@ -1716,7 +1716,7 @@ function createSessionRpc(connection, sessionId) {
1716
1716
  *
1717
1717
  * @returns Identifier assigned to the newly started background agent task.
1718
1718
  */
1719
- startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { sessionId, ...params }),
1719
+ startAgent: async (params) => connection.sendRequest("session.tasks.startAgent", { ...params, sessionId }),
1720
1720
  /**
1721
1721
  * Lists background tasks tracked by the session.
1722
1722
  *
@@ -1730,7 +1730,7 @@ function createSessionRpc(connection, sessionId) {
1730
1730
  *
1731
1731
  * @returns Result of registering or reclaiming a client-owned task.
1732
1732
  */
1733
- register: async (params) => connection.sendRequest("session.tasks.register", { sessionId, ...params }),
1733
+ register: async (params) => connection.sendRequest("session.tasks.register", { ...params, sessionId }),
1734
1734
  /**
1735
1735
  * Publishes generic progress or a terminal outcome for a client-owned task.
1736
1736
  *
@@ -1738,7 +1738,7 @@ function createSessionRpc(connection, sessionId) {
1738
1738
  *
1739
1739
  * @returns Result of publishing a client-owned task update.
1740
1740
  */
1741
- update: async (params) => connection.sendRequest("session.tasks.update", { sessionId, ...params }),
1741
+ update: async (params) => connection.sendRequest("session.tasks.update", { ...params, sessionId }),
1742
1742
  /**
1743
1743
  * Refreshes metadata for any detached background shells the runtime knows about.
1744
1744
  *
@@ -1758,7 +1758,7 @@ function createSessionRpc(connection, sessionId) {
1758
1758
  *
1759
1759
  * @returns Progress information for the task, or null when no task with that ID is tracked.
1760
1760
  */
1761
- getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { sessionId, ...params }),
1761
+ getProgress: async (params) => connection.sendRequest("session.tasks.getProgress", { ...params, sessionId }),
1762
1762
  /**
1763
1763
  * Returns the first sync-waiting task that can currently be promoted to background mode.
1764
1764
  *
@@ -1772,7 +1772,7 @@ function createSessionRpc(connection, sessionId) {
1772
1772
  *
1773
1773
  * @returns Indicates whether the task was successfully promoted to background mode.
1774
1774
  */
1775
- promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { sessionId, ...params }),
1775
+ promoteToBackground: async (params) => connection.sendRequest("session.tasks.promoteToBackground", { ...params, sessionId }),
1776
1776
  /**
1777
1777
  * Atomically promotes the first promotable sync-waiting task to background mode and returns it.
1778
1778
  *
@@ -1786,7 +1786,7 @@ function createSessionRpc(connection, sessionId) {
1786
1786
  *
1787
1787
  * @returns Indicates whether the background task was successfully cancelled.
1788
1788
  */
1789
- cancel: async (params) => connection.sendRequest("session.tasks.cancel", { sessionId, ...params }),
1789
+ cancel: async (params) => connection.sendRequest("session.tasks.cancel", { ...params, sessionId }),
1790
1790
  /**
1791
1791
  * Removes a completed or cancelled background task from tracking.
1792
1792
  *
@@ -1794,7 +1794,7 @@ function createSessionRpc(connection, sessionId) {
1794
1794
  *
1795
1795
  * @returns Indicates whether the task was removed. False when the task does not exist or is still running/idle.
1796
1796
  */
1797
- remove: async (params) => connection.sendRequest("session.tasks.remove", { sessionId, ...params }),
1797
+ remove: async (params) => connection.sendRequest("session.tasks.remove", { ...params, sessionId }),
1798
1798
  /**
1799
1799
  * Sends a message to a background agent task.
1800
1800
  *
@@ -1802,7 +1802,7 @@ function createSessionRpc(connection, sessionId) {
1802
1802
  *
1803
1803
  * @returns Indicates whether the message was delivered, with an error message when delivery failed.
1804
1804
  */
1805
- sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { sessionId, ...params })
1805
+ sendMessage: async (params) => connection.sendRequest("session.tasks.sendMessage", { ...params, sessionId })
1806
1806
  },
1807
1807
  /** @experimental */
1808
1808
  skills: {
@@ -1823,13 +1823,13 @@ function createSessionRpc(connection, sessionId) {
1823
1823
  *
1824
1824
  * @param params Name of the skill to enable for the session.
1825
1825
  */
1826
- enable: async (params) => connection.sendRequest("session.skills.enable", { sessionId, ...params }),
1826
+ enable: async (params) => connection.sendRequest("session.skills.enable", { ...params, sessionId }),
1827
1827
  /**
1828
1828
  * Disables a skill for the session.
1829
1829
  *
1830
1830
  * @param params Name of the skill to disable for the session.
1831
1831
  */
1832
- disable: async (params) => connection.sendRequest("session.skills.disable", { sessionId, ...params }),
1832
+ disable: async (params) => connection.sendRequest("session.skills.disable", { ...params, sessionId }),
1833
1833
  /**
1834
1834
  * Reloads skill definitions for the session.
1835
1835
  *
@@ -1856,19 +1856,19 @@ function createSessionRpc(connection, sessionId) {
1856
1856
  *
1857
1857
  * @returns Tools exposed by the connected MCP server. Throws when the server is not connected.
1858
1858
  */
1859
- listTools: async (params) => connection.sendRequest("session.mcp.listTools", { sessionId, ...params }),
1859
+ listTools: async (params) => connection.sendRequest("session.mcp.listTools", { ...params, sessionId }),
1860
1860
  /**
1861
1861
  * Enables an MCP server for the session.
1862
1862
  *
1863
1863
  * @param params Name of the MCP server to enable for the session.
1864
1864
  */
1865
- enable: async (params) => connection.sendRequest("session.mcp.enable", { sessionId, ...params }),
1865
+ enable: async (params) => connection.sendRequest("session.mcp.enable", { ...params, sessionId }),
1866
1866
  /**
1867
1867
  * Disables an MCP server for the session.
1868
1868
  *
1869
1869
  * @param params Name of the MCP server to disable for the session.
1870
1870
  */
1871
- disable: async (params) => connection.sendRequest("session.mcp.disable", { sessionId, ...params }),
1871
+ disable: async (params) => connection.sendRequest("session.mcp.disable", { ...params, sessionId }),
1872
1872
  /**
1873
1873
  * Reloads MCP server connections for the session.
1874
1874
  */
@@ -1886,7 +1886,7 @@ function createSessionRpc(connection, sessionId) {
1886
1886
  *
1887
1887
  * @returns Outcome of an MCP sampling execution: success result, failure error, or cancellation.
1888
1888
  */
1889
- executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { sessionId, ...params }),
1889
+ executeSampling: async (params) => connection.sendRequest("session.mcp.executeSampling", { ...params, sessionId }),
1890
1890
  /**
1891
1891
  * Cancels an in-flight MCP sampling execution by request ID.
1892
1892
  *
@@ -1894,7 +1894,7 @@ function createSessionRpc(connection, sessionId) {
1894
1894
  *
1895
1895
  * @returns Indicates whether an in-flight sampling execution with the given requestId was found and cancelled.
1896
1896
  */
1897
- cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { sessionId, ...params }),
1897
+ cancelSamplingExecution: async (params) => connection.sendRequest("session.mcp.cancelSamplingExecution", { ...params, sessionId }),
1898
1898
  /**
1899
1899
  * Sets how environment-variable values supplied to MCP servers are resolved (direct or indirect).
1900
1900
  *
@@ -1902,7 +1902,7 @@ function createSessionRpc(connection, sessionId) {
1902
1902
  *
1903
1903
  * @returns Env-value mode recorded on the session after the update.
1904
1904
  */
1905
- setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { sessionId, ...params }),
1905
+ setEnvValueMode: async (params) => connection.sendRequest("session.mcp.setEnvValueMode", { ...params, sessionId }),
1906
1906
  /**
1907
1907
  * Removes the auto-managed `github` MCP server when present.
1908
1908
  *
@@ -1914,19 +1914,19 @@ function createSessionRpc(connection, sessionId) {
1914
1914
  *
1915
1915
  * @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.
1916
1916
  */
1917
- startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
1917
+ startServer: async (params) => connection.sendRequest("session.mcp.startServer", { ...params, sessionId }),
1918
1918
  /**
1919
1919
  * 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.*`).
1920
1920
  *
1921
1921
  * @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.
1922
1922
  */
1923
- restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { sessionId, ...params }),
1923
+ restartServer: async (params) => connection.sendRequest("session.mcp.restartServer", { ...params, sessionId }),
1924
1924
  /**
1925
1925
  * Stops an individual MCP server on the session's host.
1926
1926
  *
1927
1927
  * @param params Server name for an individual MCP server stop.
1928
1928
  */
1929
- stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { sessionId, ...params }),
1929
+ stopServer: async (params) => connection.sendRequest("session.mcp.stopServer", { ...params, sessionId }),
1930
1930
  /**
1931
1931
  * Checks whether a named MCP server is currently running on the session's host.
1932
1932
  *
@@ -1934,7 +1934,7 @@ function createSessionRpc(connection, sessionId) {
1934
1934
  *
1935
1935
  * @returns Whether the named MCP server is running.
1936
1936
  */
1937
- isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { sessionId, ...params }),
1937
+ isServerRunning: async (params) => connection.sendRequest("session.mcp.isServerRunning", { ...params, sessionId }),
1938
1938
  /** @experimental */
1939
1939
  oauth: {
1940
1940
  /**
@@ -1944,13 +1944,13 @@ function createSessionRpc(connection, sessionId) {
1944
1944
  *
1945
1945
  * @returns Indicates whether the pending MCP OAuth response was accepted.
1946
1946
  */
1947
- handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { sessionId, ...params }),
1947
+ handlePendingRequest: async (params) => connection.sendRequest("session.mcp.oauth.handlePendingRequest", { ...params, sessionId }),
1948
1948
  /**
1949
1949
  * Notifies the session that MCP OAuth authentication succeeded and updated credentials were persisted, so cached tool definitions can be refreshed.
1950
1950
  *
1951
1951
  * @param params Identifies the MCP server whose persisted OAuth credentials were updated.
1952
1952
  */
1953
- authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { sessionId, ...params }),
1953
+ authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { ...params, sessionId }),
1954
1954
  /**
1955
1955
  * 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.
1956
1956
  *
@@ -1958,15 +1958,21 @@ function createSessionRpc(connection, sessionId) {
1958
1958
  *
1959
1959
  * @returns An inert runtime-issued login handle. Preparation alone performs no activation or OAuth work.
1960
1960
  */
1961
- prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { sessionId, ...params }),
1961
+ prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { ...params, sessionId }),
1962
1962
  /**
1963
1963
  * 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.
1964
1964
  *
1965
- * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
1965
+ * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback handling, and static OAuth client selection.
1966
1966
  *
1967
1967
  * @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
1968
1968
  */
1969
- login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params }),
1969
+ login: async (params) => connection.sendRequest("session.mcp.oauth.login", { ...params, sessionId }),
1970
+ /**
1971
+ * Completes a runtime-managed MCP OAuth login after the authorization server redirects to a host-managed callback URL.
1972
+ *
1973
+ * @param params Host-delivered callback for a runtime-managed MCP OAuth login.
1974
+ */
1975
+ complete: async (params) => connection.sendRequest("session.mcp.oauth.complete", { ...params, sessionId }),
1970
1976
  /**
1971
1977
  * 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.
1972
1978
  *
@@ -1974,7 +1980,7 @@ function createSessionRpc(connection, sessionId) {
1974
1980
  *
1975
1981
  * @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.
1976
1982
  */
1977
- probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { sessionId, ...params }),
1983
+ probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { ...params, sessionId }),
1978
1984
  /**
1979
1985
  * Cancels the exact owned OAuth login issued to this original session requester, without clearing shared credentials.
1980
1986
  *
@@ -1982,7 +1988,7 @@ function createSessionRpc(connection, sessionId) {
1982
1988
  *
1983
1989
  * @returns Honest terminal cancellation result; persistence or recovery failures remain RPC errors.
1984
1990
  */
1985
- cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { sessionId, ...params }),
1991
+ cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { ...params, sessionId }),
1986
1992
  /**
1987
1993
  * Responds to a pending MCP OAuth authorization request by its request id.
1988
1994
  *
@@ -1990,7 +1996,7 @@ function createSessionRpc(connection, sessionId) {
1990
1996
  *
1991
1997
  * @returns Indicates whether the pending MCP OAuth response was accepted.
1992
1998
  */
1993
- respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
1999
+ respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { ...params, sessionId })
1994
2000
  },
1995
2001
  /** @experimental */
1996
2002
  headers: {
@@ -2001,7 +2007,7 @@ function createSessionRpc(connection, sessionId) {
2001
2007
  *
2002
2008
  * @returns Indicates whether the pending MCP headers refresh response was accepted.
2003
2009
  */
2004
- handlePendingHeadersRefreshRequest: async (params) => connection.sendRequest("session.mcp.headers.handlePendingHeadersRefreshRequest", { sessionId, ...params })
2010
+ handlePendingHeadersRefreshRequest: async (params) => connection.sendRequest("session.mcp.headers.handlePendingHeadersRefreshRequest", { ...params, sessionId })
2005
2011
  },
2006
2012
  /** @experimental */
2007
2013
  apps: {
@@ -2012,7 +2018,7 @@ function createSessionRpc(connection, sessionId) {
2012
2018
  *
2013
2019
  * @returns Resource contents returned by the MCP server.
2014
2020
  */
2015
- readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { sessionId, ...params }),
2021
+ readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { ...params, sessionId }),
2016
2022
  /**
2017
2023
  * 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"`.
2018
2024
  *
@@ -2020,7 +2026,7 @@ function createSessionRpc(connection, sessionId) {
2020
2026
  *
2021
2027
  * @returns App-callable tools from the named MCP server.
2022
2028
  */
2023
- listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { sessionId, ...params }),
2029
+ listTools: async (params) => connection.sendRequest("session.mcp.apps.listTools", { ...params, sessionId }),
2024
2030
  /**
2025
2031
  * 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`.
2026
2032
  *
@@ -2028,13 +2034,13 @@ function createSessionRpc(connection, sessionId) {
2028
2034
  *
2029
2035
  * @returns Standard MCP CallToolResult
2030
2036
  */
2031
- callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { sessionId, ...params }),
2037
+ callTool: async (params) => connection.sendRequest("session.mcp.apps.callTool", { ...params, sessionId }),
2032
2038
  /**
2033
2039
  * 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.
2034
2040
  *
2035
2041
  * @param params Host context to advertise to MCP App guests.
2036
2042
  */
2037
- setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { sessionId, ...params }),
2043
+ setHostContext: async (params) => connection.sendRequest("session.mcp.apps.setHostContext", { ...params, sessionId }),
2038
2044
  /**
2039
2045
  * Read the current host context advertised to MCP App guests.
2040
2046
  *
@@ -2048,7 +2054,7 @@ function createSessionRpc(connection, sessionId) {
2048
2054
  *
2049
2055
  * @returns Diagnostic snapshot of MCP Apps wiring for the named server.
2050
2056
  */
2051
- diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { sessionId, ...params })
2057
+ diagnose: async (params) => connection.sendRequest("session.mcp.apps.diagnose", { ...params, sessionId })
2052
2058
  },
2053
2059
  /** @experimental */
2054
2060
  resources: {
@@ -2059,7 +2065,7 @@ function createSessionRpc(connection, sessionId) {
2059
2065
  *
2060
2066
  * @returns Resource contents returned by the MCP server.
2061
2067
  */
2062
- read: async (params) => connection.sendRequest("session.mcp.resources.read", { sessionId, ...params }),
2068
+ read: async (params) => connection.sendRequest("session.mcp.resources.read", { ...params, sessionId }),
2063
2069
  /**
2064
2070
  * Enumerate one page of resources a connected MCP server exposes (proxies MCP `resources/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
2065
2071
  *
@@ -2067,7 +2073,7 @@ function createSessionRpc(connection, sessionId) {
2067
2073
  *
2068
2074
  * @returns One page of resources advertised by the named MCP server.
2069
2075
  */
2070
- list: async (params) => connection.sendRequest("session.mcp.resources.list", { sessionId, ...params }),
2076
+ list: async (params) => connection.sendRequest("session.mcp.resources.list", { ...params, sessionId }),
2071
2077
  /**
2072
2078
  * 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`.
2073
2079
  *
@@ -2075,7 +2081,26 @@ function createSessionRpc(connection, sessionId) {
2075
2081
  *
2076
2082
  * @returns One page of resource templates advertised by the named MCP server.
2077
2083
  */
2078
- listTemplates: async (params) => connection.sendRequest("session.mcp.resources.listTemplates", { sessionId, ...params })
2084
+ listTemplates: async (params) => connection.sendRequest("session.mcp.resources.listTemplates", { ...params, sessionId })
2085
+ },
2086
+ /** @experimental */
2087
+ prompts: {
2088
+ /**
2089
+ * Enumerate one page of prompts a connected MCP server exposes (proxies MCP `prompts/list`). Pass `cursor` to continue from a prior result's `nextCursor`.
2090
+ *
2091
+ * @param params MCP server whose prompts to enumerate.
2092
+ *
2093
+ * @returns One page of prompts advertised by the named MCP server.
2094
+ */
2095
+ list: async (params) => connection.sendRequest("session.mcp.prompts.list", { ...params, sessionId }),
2096
+ /**
2097
+ * 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.
2098
+ *
2099
+ * @param params MCP server, prompt name, and optional string-valued arguments.
2100
+ *
2101
+ * @returns Prompt messages returned by the MCP server without sending them to the model.
2102
+ */
2103
+ get: async (params) => connection.sendRequest("session.mcp.prompts.get", { ...params, sessionId })
2079
2104
  }
2080
2105
  },
2081
2106
  /** @experimental */
@@ -2087,7 +2112,7 @@ function createSessionRpc(connection, sessionId) {
2087
2112
  *
2088
2113
  * @returns Per-source session diagnostics configuration.
2089
2114
  */
2090
- configure: async (params) => connection.sendRequest("session.diagnostics.configure", { sessionId, ...params }),
2115
+ configure: async (params) => connection.sendRequest("session.diagnostics.configure", { ...params, sessionId }),
2091
2116
  /**
2092
2117
  * 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.
2093
2118
  *
@@ -2095,7 +2120,7 @@ function createSessionRpc(connection, sessionId) {
2095
2120
  *
2096
2121
  * @returns One cursor-addressed page of retained session diagnostics.
2097
2122
  */
2098
- read: async (params) => connection.sendRequest("session.diagnostics.read", { sessionId, ...params })
2123
+ read: async (params) => connection.sendRequest("session.diagnostics.read", { ...params, sessionId })
2099
2124
  },
2100
2125
  /** @experimental */
2101
2126
  connectors: {
@@ -2124,7 +2149,7 @@ function createSessionRpc(connection, sessionId) {
2124
2149
  *
2125
2150
  * @returns Validated Connector catalog snapshot cached by the session.
2126
2151
  */
2127
- list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
2152
+ list: async (params) => connection.sendRequest("session.connectors.list", { ...params, sessionId }),
2128
2153
  /**
2129
2154
  * Refreshes and validates the Connector catalog for the pinned opaque account selection.
2130
2155
  *
@@ -2132,7 +2157,7 @@ function createSessionRpc(connection, sessionId) {
2132
2157
  *
2133
2158
  * @returns Validated Connector catalog snapshot cached by the session.
2134
2159
  */
2135
- refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
2160
+ refresh: async (params) => connection.sendRequest("session.connectors.refresh", { ...params, sessionId }),
2136
2161
  /**
2137
2162
  * 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.
2138
2163
  *
@@ -2140,7 +2165,7 @@ function createSessionRpc(connection, sessionId) {
2140
2165
  *
2141
2166
  * @returns Typed result of initiating or continuing a Connector connection.
2142
2167
  */
2143
- connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
2168
+ connect: async (params) => connection.sendRequest("session.connectors.connect", { ...params, sessionId }),
2144
2169
  /**
2145
2170
  * Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
2146
2171
  *
@@ -2148,7 +2173,7 @@ function createSessionRpc(connection, sessionId) {
2148
2173
  *
2149
2174
  * @returns Typed result of initiating or continuing a Connector connection.
2150
2175
  */
2151
- reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
2176
+ reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { ...params, sessionId }),
2152
2177
  /**
2153
2178
  * Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
2154
2179
  *
@@ -2156,7 +2181,7 @@ function createSessionRpc(connection, sessionId) {
2156
2181
  *
2157
2182
  * @returns Typed result of initiating or continuing a Connector connection.
2158
2183
  */
2159
- continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
2184
+ continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { ...params, sessionId }),
2160
2185
  /**
2161
2186
  * Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
2162
2187
  *
@@ -2164,7 +2189,7 @@ function createSessionRpc(connection, sessionId) {
2164
2189
  *
2165
2190
  * @returns Authoritative result after disconnect and MCP reconciliation.
2166
2191
  */
2167
- disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
2192
+ disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { ...params, sessionId }),
2168
2193
  /**
2169
2194
  * Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
2170
2195
  *
@@ -2172,7 +2197,7 @@ function createSessionRpc(connection, sessionId) {
2172
2197
  *
2173
2198
  * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
2174
2199
  */
2175
- reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
2200
+ reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { ...params, sessionId })
2176
2201
  },
2177
2202
  /** @experimental */
2178
2203
  managedSettings: {
@@ -2198,13 +2223,13 @@ function createSessionRpc(connection, sessionId) {
2198
2223
  *
2199
2224
  * @returns Result of installing a plugin.
2200
2225
  */
2201
- install: async (params) => connection.sendRequest("session.plugins.install", { sessionId, ...params }),
2226
+ install: async (params) => connection.sendRequest("session.plugins.install", { ...params, sessionId }),
2202
2227
  /**
2203
2228
  * Uninstalls a plugin when permitted by the live session's retained managed policy.
2204
2229
  *
2205
2230
  * @param params Name (or spec) of the plugin to uninstall.
2206
2231
  */
2207
- uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { sessionId, ...params }),
2232
+ uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { ...params, sessionId }),
2208
2233
  /**
2209
2234
  * Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
2210
2235
  *
@@ -2212,19 +2237,19 @@ function createSessionRpc(connection, sessionId) {
2212
2237
  *
2213
2238
  * @returns Result of updating a single plugin.
2214
2239
  */
2215
- update: async (params) => connection.sendRequest("session.plugins.update", { sessionId, ...params }),
2240
+ update: async (params) => connection.sendRequest("session.plugins.update", { ...params, sessionId }),
2216
2241
  /**
2217
2242
  * Enables installed plugins when permitted by the live session's retained managed policy.
2218
2243
  *
2219
2244
  * @param params Plugin names (or specs) to enable in the session's authoritative working directory.
2220
2245
  */
2221
- enable: async (params) => connection.sendRequest("session.plugins.enable", { sessionId, ...params }),
2246
+ enable: async (params) => connection.sendRequest("session.plugins.enable", { ...params, sessionId }),
2222
2247
  /**
2223
2248
  * Disables installed plugins when permitted by the live session's retained managed policy.
2224
2249
  *
2225
2250
  * @param params Plugin names (or specs) to disable in the session's authoritative working directory.
2226
2251
  */
2227
- disable: async (params) => connection.sendRequest("session.plugins.disable", { sessionId, ...params }),
2252
+ disable: async (params) => connection.sendRequest("session.plugins.disable", { ...params, sessionId }),
2228
2253
  /** @experimental */
2229
2254
  marketplaces: {
2230
2255
  /**
@@ -2240,7 +2265,7 @@ function createSessionRpc(connection, sessionId) {
2240
2265
  *
2241
2266
  * @returns Result of registering a new marketplace.
2242
2267
  */
2243
- add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { sessionId, ...params }),
2268
+ add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { ...params, sessionId }),
2244
2269
  /**
2245
2270
  * Removes a marketplace when permitted by the live session's retained managed policy.
2246
2271
  *
@@ -2248,7 +2273,7 @@ function createSessionRpc(connection, sessionId) {
2248
2273
  *
2249
2274
  * @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
2250
2275
  */
2251
- remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { sessionId, ...params }),
2276
+ remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { ...params, sessionId }),
2252
2277
  /**
2253
2278
  * Browses a marketplace resolved through the live session's working directory and retained managed policy.
2254
2279
  *
@@ -2256,7 +2281,7 @@ function createSessionRpc(connection, sessionId) {
2256
2281
  *
2257
2282
  * @returns Plugins advertised by the marketplace.
2258
2283
  */
2259
- browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { sessionId, ...params }),
2284
+ browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { ...params, sessionId }),
2260
2285
  /**
2261
2286
  * Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
2262
2287
  *
@@ -2264,14 +2289,14 @@ function createSessionRpc(connection, sessionId) {
2264
2289
  *
2265
2290
  * @returns Result of refreshing one or more marketplace catalogs.
2266
2291
  */
2267
- refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { sessionId, ...params })
2292
+ refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { ...params, sessionId })
2268
2293
  },
2269
2294
  /**
2270
2295
  * 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.
2271
2296
  *
2272
2297
  * @param params Optional flags controlling which side effects the reload performs.
2273
2298
  */
2274
- reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
2299
+ reload: async (params) => connection.sendRequest("session.plugins.reload", { ...params, sessionId })
2275
2300
  },
2276
2301
  /** @experimental */
2277
2302
  provider: {
@@ -2282,7 +2307,7 @@ function createSessionRpc(connection, sessionId) {
2282
2307
  *
2283
2308
  * @returns A snapshot of the provider endpoint the session is currently configured to talk to.
2284
2309
  */
2285
- getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
2310
+ getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { ...params, sessionId }),
2286
2311
  /**
2287
2312
  * 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.
2288
2313
  *
@@ -2290,7 +2315,7 @@ function createSessionRpc(connection, sessionId) {
2290
2315
  *
2291
2316
  * @returns The selectable model entries synthesized for the models added by this call.
2292
2317
  */
2293
- add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
2318
+ add: async (params) => connection.sendRequest("session.provider.add", { ...params, sessionId }),
2294
2319
  /**
2295
2320
  * 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.
2296
2321
  *
@@ -2298,7 +2323,7 @@ function createSessionRpc(connection, sessionId) {
2298
2323
  *
2299
2324
  * @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
2300
2325
  */
2301
- sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params }),
2326
+ sync: async (params) => connection.sendRequest("session.provider.sync", { ...params, sessionId }),
2302
2327
  /**
2303
2328
  * 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.
2304
2329
  *
@@ -2306,7 +2331,7 @@ function createSessionRpc(connection, sessionId) {
2306
2331
  *
2307
2332
  * @returns What the withdrawal actually removed from the registry.
2308
2333
  */
2309
- withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { sessionId, ...params })
2334
+ withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { ...params, sessionId })
2310
2335
  },
2311
2336
  /** @experimental */
2312
2337
  options: {
@@ -2317,7 +2342,7 @@ function createSessionRpc(connection, sessionId) {
2317
2342
  *
2318
2343
  * @returns Indicates whether the session options patch was applied successfully.
2319
2344
  */
2320
- update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
2345
+ update: async (params) => connection.sendRequest("session.options.update", { ...params, sessionId })
2321
2346
  },
2322
2347
  /** @experimental */
2323
2348
  lsp: {
@@ -2326,7 +2351,7 @@ function createSessionRpc(connection, sessionId) {
2326
2351
  *
2327
2352
  * @param params Parameters for (re)loading the merged LSP configuration set.
2328
2353
  */
2329
- initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
2354
+ initialize: async (params) => connection.sendRequest("session.lsp.initialize", { ...params, sessionId })
2330
2355
  },
2331
2356
  /** @experimental */
2332
2357
  extensions: {
@@ -2341,13 +2366,13 @@ function createSessionRpc(connection, sessionId) {
2341
2366
  *
2342
2367
  * @param params Source-qualified extension identifier to enable for the session.
2343
2368
  */
2344
- enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
2369
+ enable: async (params) => connection.sendRequest("session.extensions.enable", { ...params, sessionId }),
2345
2370
  /**
2346
2371
  * Disables an extension for the session.
2347
2372
  *
2348
2373
  * @param params Source-qualified extension identifier to disable for the session.
2349
2374
  */
2350
- disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
2375
+ disable: async (params) => connection.sendRequest("session.extensions.disable", { ...params, sessionId }),
2351
2376
  /**
2352
2377
  * Reloads extension definitions and processes for the session.
2353
2378
  */
@@ -2357,7 +2382,7 @@ function createSessionRpc(connection, sessionId) {
2357
2382
  *
2358
2383
  * @param params Parameters for session.extensions.sendAttachmentsToMessage.
2359
2384
  */
2360
- sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { sessionId, ...params })
2385
+ sendAttachmentsToMessage: async (params) => connection.sendRequest("session.extensions.sendAttachmentsToMessage", { ...params, sessionId })
2361
2386
  },
2362
2387
  /** @experimental */
2363
2388
  tools: {
@@ -2368,7 +2393,7 @@ function createSessionRpc(connection, sessionId) {
2368
2393
  *
2369
2394
  * @returns Canonical result returned by a session tool.
2370
2395
  */
2371
- execute: async (params) => connection.sendRequest("session.tools.execute", { sessionId, ...params }),
2396
+ execute: async (params) => connection.sendRequest("session.tools.execute", { ...params, sessionId }),
2372
2397
  /**
2373
2398
  * Returns the Rust-owned built-in tool descriptors used to construct the session's offered tool set.
2374
2399
  *
@@ -2376,7 +2401,7 @@ function createSessionRpc(connection, sessionId) {
2376
2401
  *
2377
2402
  * @returns Rust-owned built-in tool descriptors for the session.
2378
2403
  */
2379
- getBuiltinDescriptors: async (params) => connection.sendRequest("session.tools.getBuiltinDescriptors", { sessionId, ...params }),
2404
+ getBuiltinDescriptors: async (params) => connection.sendRequest("session.tools.getBuiltinDescriptors", { ...params, sessionId }),
2380
2405
  /**
2381
2406
  * Projects a completed task_complete tool call into its label-safe session event payload.
2382
2407
  *
@@ -2384,7 +2409,7 @@ function createSessionRpc(connection, sessionId) {
2384
2409
  *
2385
2410
  * @returns Task completion notification with summary from the agent
2386
2411
  */
2387
- taskCompleteEventData: async (params) => connection.sendRequest("session.tools.taskCompleteEventData", { sessionId, ...params }),
2412
+ taskCompleteEventData: async (params) => connection.sendRequest("session.tools.taskCompleteEventData", { ...params, sessionId }),
2388
2413
  /**
2389
2414
  * Provides the result for a pending external tool call.
2390
2415
  *
@@ -2392,7 +2417,7 @@ function createSessionRpc(connection, sessionId) {
2392
2417
  *
2393
2418
  * @returns Indicates whether the external tool call result was handled successfully.
2394
2419
  */
2395
- handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params }),
2420
+ handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { ...params, sessionId }),
2396
2421
  /**
2397
2422
  * Resolves, builds, and validates the runtime tool list for the session.
2398
2423
  *
@@ -2412,7 +2437,7 @@ function createSessionRpc(connection, sessionId) {
2412
2437
  *
2413
2438
  * @returns Empty result after replacing the calling connection's externally implemented tools.
2414
2439
  */
2415
- set: async (params) => connection.sendRequest("session.tools.set", { sessionId, ...params }),
2440
+ set: async (params) => connection.sendRequest("session.tools.set", { ...params, sessionId }),
2416
2441
  /**
2417
2442
  * 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.
2418
2443
  *
@@ -2420,7 +2445,7 @@ function createSessionRpc(connection, sessionId) {
2420
2445
  *
2421
2446
  * @returns Empty result after applying subagent settings
2422
2447
  */
2423
- updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { sessionId, ...params })
2448
+ updateSubagentSettings: async (params) => connection.sendRequest("session.tools.updateSubagentSettings", { ...params, sessionId })
2424
2449
  },
2425
2450
  /** @experimental */
2426
2451
  commands: {
@@ -2431,7 +2456,7 @@ function createSessionRpc(connection, sessionId) {
2431
2456
  *
2432
2457
  * @returns Slash commands available in the session, after applying any include/exclude filters.
2433
2458
  */
2434
- list: async (params) => connection.sendRequest("session.commands.list", { sessionId, ...params }),
2459
+ list: async (params) => connection.sendRequest("session.commands.list", { ...params, sessionId }),
2435
2460
  /**
2436
2461
  * Invokes a slash command in the session.
2437
2462
  *
@@ -2439,7 +2464,7 @@ function createSessionRpc(connection, sessionId) {
2439
2464
  *
2440
2465
  * @returns Result of invoking the slash command (text output, prompt to send to the agent, completion, or subcommand selection).
2441
2466
  */
2442
- invoke: async (params) => connection.sendRequest("session.commands.invoke", { sessionId, ...params }),
2467
+ invoke: async (params) => connection.sendRequest("session.commands.invoke", { ...params, sessionId }),
2443
2468
  /**
2444
2469
  * Reports completion of a pending client-handled slash command.
2445
2470
  *
@@ -2447,7 +2472,7 @@ function createSessionRpc(connection, sessionId) {
2447
2472
  *
2448
2473
  * @returns Indicates whether the pending client-handled command was completed successfully.
2449
2474
  */
2450
- handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params }),
2475
+ handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { ...params, sessionId }),
2451
2476
  /**
2452
2477
  * Executes a slash command synchronously and returns any error.
2453
2478
  *
@@ -2455,7 +2480,7 @@ function createSessionRpc(connection, sessionId) {
2455
2480
  *
2456
2481
  * @returns Error message produced while executing the command, if any.
2457
2482
  */
2458
- execute: async (params) => connection.sendRequest("session.commands.execute", { sessionId, ...params }),
2483
+ execute: async (params) => connection.sendRequest("session.commands.execute", { ...params, sessionId }),
2459
2484
  /**
2460
2485
  * Enqueues a slash command for FIFO processing on the local session.
2461
2486
  *
@@ -2463,7 +2488,7 @@ function createSessionRpc(connection, sessionId) {
2463
2488
  *
2464
2489
  * @returns Indicates whether the command was accepted into the local execution queue.
2465
2490
  */
2466
- enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { sessionId, ...params }),
2491
+ enqueue: async (params) => connection.sendRequest("session.commands.enqueue", { ...params, sessionId }),
2467
2492
  /**
2468
2493
  * Reports whether the host actually executed a queued command and whether to continue processing.
2469
2494
  *
@@ -2471,7 +2496,7 @@ function createSessionRpc(connection, sessionId) {
2471
2496
  *
2472
2497
  * @returns Indicates whether the queued-command response was matched to a pending request.
2473
2498
  */
2474
- respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { sessionId, ...params })
2499
+ respondToQueuedCommand: async (params) => connection.sendRequest("session.commands.respondToQueuedCommand", { ...params, sessionId })
2475
2500
  },
2476
2501
  /** @experimental */
2477
2502
  telemetry: {
@@ -2486,7 +2511,7 @@ function createSessionRpc(connection, sessionId) {
2486
2511
  *
2487
2512
  * @param params Feature override key/value pairs to attach to subsequent telemetry events from this session.
2488
2513
  */
2489
- setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { sessionId, ...params })
2514
+ setFeatureOverrides: async (params) => connection.sendRequest("session.telemetry.setFeatureOverrides", { ...params, sessionId })
2490
2515
  },
2491
2516
  /** @experimental */
2492
2517
  ui: {
@@ -2497,7 +2522,7 @@ function createSessionRpc(connection, sessionId) {
2497
2522
  *
2498
2523
  * @returns Completed transient query. Ordered chunks and the terminal outcome are also delivered through `ui.ephemeral_query` session events while it runs.
2499
2524
  */
2500
- ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { sessionId, ...params }),
2525
+ ephemeralQuery: async (params) => connection.sendRequest("session.ui.ephemeralQuery", { ...params, sessionId }),
2501
2526
  /**
2502
2527
  * Requests structured input from a UI-capable client.
2503
2528
  *
@@ -2505,7 +2530,7 @@ function createSessionRpc(connection, sessionId) {
2505
2530
  *
2506
2531
  * @returns The elicitation response (accept with form values, decline, or cancel)
2507
2532
  */
2508
- elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
2533
+ elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { ...params, sessionId }),
2509
2534
  /**
2510
2535
  * Provides the user response for a pending elicitation request.
2511
2536
  *
@@ -2513,7 +2538,7 @@ function createSessionRpc(connection, sessionId) {
2513
2538
  *
2514
2539
  * @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
2515
2540
  */
2516
- handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params }),
2541
+ handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { ...params, sessionId }),
2517
2542
  /**
2518
2543
  * Resolves a pending `user_input.requested` event with the user's response.
2519
2544
  *
@@ -2521,7 +2546,7 @@ function createSessionRpc(connection, sessionId) {
2521
2546
  *
2522
2547
  * @returns Indicates whether the pending UI request was resolved by this call.
2523
2548
  */
2524
- handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { sessionId, ...params }),
2549
+ handlePendingUserInput: async (params) => connection.sendRequest("session.ui.handlePendingUserInput", { ...params, sessionId }),
2525
2550
  /**
2526
2551
  * Resolves a pending `sampling.requested` event with a sampling result, or rejects it.
2527
2552
  *
@@ -2529,7 +2554,7 @@ function createSessionRpc(connection, sessionId) {
2529
2554
  *
2530
2555
  * @returns Indicates whether the pending UI request was resolved by this call.
2531
2556
  */
2532
- handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { sessionId, ...params }),
2557
+ handlePendingSampling: async (params) => connection.sendRequest("session.ui.handlePendingSampling", { ...params, sessionId }),
2533
2558
  /**
2534
2559
  * Resolves a pending `auto_mode_switch.requested` event with the user's accept/decline decision.
2535
2560
  *
@@ -2537,7 +2562,7 @@ function createSessionRpc(connection, sessionId) {
2537
2562
  *
2538
2563
  * @returns Indicates whether the pending UI request was resolved by this call.
2539
2564
  */
2540
- handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { sessionId, ...params }),
2565
+ handlePendingAutoModeSwitch: async (params) => connection.sendRequest("session.ui.handlePendingAutoModeSwitch", { ...params, sessionId }),
2541
2566
  /**
2542
2567
  * Resolves a pending `session_limits_exhausted.requested` event with the user's selected limit action.
2543
2568
  *
@@ -2545,7 +2570,7 @@ function createSessionRpc(connection, sessionId) {
2545
2570
  *
2546
2571
  * @returns Indicates whether the pending UI request was resolved by this call.
2547
2572
  */
2548
- handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { sessionId, ...params }),
2573
+ handlePendingSessionLimitsExhausted: async (params) => connection.sendRequest("session.ui.handlePendingSessionLimitsExhausted", { ...params, sessionId }),
2549
2574
  /**
2550
2575
  * Resolves a pending `exit_plan_mode.requested` event with the user's response.
2551
2576
  *
@@ -2553,7 +2578,7 @@ function createSessionRpc(connection, sessionId) {
2553
2578
  *
2554
2579
  * @returns Indicates whether the pending UI request was resolved by this call.
2555
2580
  */
2556
- handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { sessionId, ...params }),
2581
+ handlePendingExitPlanMode: async (params) => connection.sendRequest("session.ui.handlePendingExitPlanMode", { ...params, sessionId }),
2557
2582
  /**
2558
2583
  * Registers an in-process handler for auto-mode-switch requests so the server bridge skips dispatch.
2559
2584
  *
@@ -2567,7 +2592,7 @@ function createSessionRpc(connection, sessionId) {
2567
2592
  *
2568
2593
  * @returns Indicates whether the handle was active and the registration count was decremented.
2569
2594
  */
2570
- unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { sessionId, ...params })
2595
+ unregisterDirectAutoModeSwitchHandler: async (params) => connection.sendRequest("session.ui.unregisterDirectAutoModeSwitchHandler", { ...params, sessionId })
2571
2596
  },
2572
2597
  /** @experimental */
2573
2598
  permissions: {
@@ -2578,7 +2603,7 @@ function createSessionRpc(connection, sessionId) {
2578
2603
  *
2579
2604
  * @returns Indicates whether the operation succeeded.
2580
2605
  */
2581
- configure: async (params) => connection.sendRequest("session.permissions.configure", { sessionId, ...params }),
2606
+ configure: async (params) => connection.sendRequest("session.permissions.configure", { ...params, sessionId }),
2582
2607
  /**
2583
2608
  * Provides a decision for a pending tool permission request.
2584
2609
  *
@@ -2586,7 +2611,7 @@ function createSessionRpc(connection, sessionId) {
2586
2611
  *
2587
2612
  * @returns Indicates whether the permission decision was applied; false when the request was already resolved.
2588
2613
  */
2589
- handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params }),
2614
+ handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { ...params, sessionId }),
2590
2615
  /**
2591
2616
  * Reconstructs the set of pending tool permission requests from the session's event history.
2592
2617
  *
@@ -2600,7 +2625,7 @@ function createSessionRpc(connection, sessionId) {
2600
2625
  *
2601
2626
  * @returns Indicates whether the operation succeeded.
2602
2627
  */
2603
- setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { sessionId, ...params }),
2628
+ setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { ...params, sessionId }),
2604
2629
  /**
2605
2630
  * 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.
2606
2631
  *
@@ -2608,7 +2633,7 @@ function createSessionRpc(connection, sessionId) {
2608
2633
  *
2609
2634
  * @returns Indicates whether the requested permission mode was applied and reports the authoritative post-mutation mode.
2610
2635
  */
2611
- setMode: async (params) => connection.sendRequest("session.permissions.setMode", { sessionId, ...params }),
2636
+ setMode: async (params) => connection.sendRequest("session.permissions.setMode", { ...params, sessionId }),
2612
2637
  /**
2613
2638
  * Returns the current permission mode for the session.
2614
2639
  *
@@ -2622,7 +2647,7 @@ function createSessionRpc(connection, sessionId) {
2622
2647
  *
2623
2648
  * @returns Indicates whether the operation succeeded.
2624
2649
  */
2625
- modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { sessionId, ...params }),
2650
+ modifyRules: async (params) => connection.sendRequest("session.permissions.modifyRules", { ...params, sessionId }),
2626
2651
  /**
2627
2652
  * Sets whether the client wants permission prompts bridged into session events.
2628
2653
  *
@@ -2630,7 +2655,7 @@ function createSessionRpc(connection, sessionId) {
2630
2655
  *
2631
2656
  * @returns Indicates whether the operation succeeded.
2632
2657
  */
2633
- setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
2658
+ setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { ...params, sessionId }),
2634
2659
  /**
2635
2660
  * Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
2636
2661
  *
@@ -2638,7 +2663,7 @@ function createSessionRpc(connection, sessionId) {
2638
2663
  *
2639
2664
  * @returns Indicates whether the operation succeeded.
2640
2665
  */
2641
- resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId, ...params }),
2666
+ resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { ...params, sessionId }),
2642
2667
  /**
2643
2668
  * Notifies the runtime that a permission prompt UI has been shown to the user.
2644
2669
  *
@@ -2646,7 +2671,7 @@ function createSessionRpc(connection, sessionId) {
2646
2671
  *
2647
2672
  * @returns Indicates whether the operation succeeded.
2648
2673
  */
2649
- notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { sessionId, ...params }),
2674
+ notifyPromptShown: async (params) => connection.sendRequest("session.permissions.notifyPromptShown", { ...params, sessionId }),
2650
2675
  /** @experimental */
2651
2676
  paths: {
2652
2677
  /**
@@ -2662,7 +2687,7 @@ function createSessionRpc(connection, sessionId) {
2662
2687
  *
2663
2688
  * @returns Indicates whether the operation succeeded.
2664
2689
  */
2665
- add: async (params) => connection.sendRequest("session.permissions.paths.add", { sessionId, ...params }),
2690
+ add: async (params) => connection.sendRequest("session.permissions.paths.add", { ...params, sessionId }),
2666
2691
  /**
2667
2692
  * Updates the session's primary working directory used by the permission policy.
2668
2693
  *
@@ -2670,7 +2695,7 @@ function createSessionRpc(connection, sessionId) {
2670
2695
  *
2671
2696
  * @returns Indicates whether the operation succeeded.
2672
2697
  */
2673
- updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { sessionId, ...params }),
2698
+ updatePrimary: async (params) => connection.sendRequest("session.permissions.paths.updatePrimary", { ...params, sessionId }),
2674
2699
  /**
2675
2700
  * Reports whether a path falls within any of the session's allowed directories.
2676
2701
  *
@@ -2678,7 +2703,7 @@ function createSessionRpc(connection, sessionId) {
2678
2703
  *
2679
2704
  * @returns Indicates whether the supplied path is within the session's allowed directories.
2680
2705
  */
2681
- isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { sessionId, ...params }),
2706
+ isPathWithinAllowedDirectories: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinAllowedDirectories", { ...params, sessionId }),
2682
2707
  /**
2683
2708
  * Reports whether a path falls within the session's workspace (primary) directory.
2684
2709
  *
@@ -2686,7 +2711,7 @@ function createSessionRpc(connection, sessionId) {
2686
2711
  *
2687
2712
  * @returns Indicates whether the supplied path is within the session's workspace directory.
2688
2713
  */
2689
- isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { sessionId, ...params })
2714
+ isPathWithinWorkspace: async (params) => connection.sendRequest("session.permissions.paths.isPathWithinWorkspace", { ...params, sessionId })
2690
2715
  },
2691
2716
  /** @experimental */
2692
2717
  locations: {
@@ -2697,7 +2722,7 @@ function createSessionRpc(connection, sessionId) {
2697
2722
  *
2698
2723
  * @returns Resolved location-permissions key and type.
2699
2724
  */
2700
- resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { sessionId, ...params }),
2725
+ resolve: async (params) => connection.sendRequest("session.permissions.locations.resolve", { ...params, sessionId }),
2701
2726
  /**
2702
2727
  * Applies persisted location-scoped tool approvals and allowed directories for a working directory to this session's permission service.
2703
2728
  *
@@ -2705,7 +2730,7 @@ function createSessionRpc(connection, sessionId) {
2705
2730
  *
2706
2731
  * @returns Summary of persisted location permissions applied to the session.
2707
2732
  */
2708
- apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { sessionId, ...params }),
2733
+ apply: async (params) => connection.sendRequest("session.permissions.locations.apply", { ...params, sessionId }),
2709
2734
  /**
2710
2735
  * Persists a tool approval for a permission location and applies its rules to this session's live permission service.
2711
2736
  *
@@ -2713,7 +2738,7 @@ function createSessionRpc(connection, sessionId) {
2713
2738
  *
2714
2739
  * @returns Indicates whether the operation succeeded.
2715
2740
  */
2716
- addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { sessionId, ...params })
2741
+ addToolApproval: async (params) => connection.sendRequest("session.permissions.locations.addToolApproval", { ...params, sessionId })
2717
2742
  },
2718
2743
  /** @experimental */
2719
2744
  folderTrust: {
@@ -2724,7 +2749,7 @@ function createSessionRpc(connection, sessionId) {
2724
2749
  *
2725
2750
  * @returns Folder trust check result.
2726
2751
  */
2727
- isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { sessionId, ...params }),
2752
+ isTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.isTrusted", { ...params, sessionId }),
2728
2753
  /**
2729
2754
  * Adds a folder to the user's trusted folders list.
2730
2755
  *
@@ -2732,7 +2757,7 @@ function createSessionRpc(connection, sessionId) {
2732
2757
  *
2733
2758
  * @returns Indicates whether the operation succeeded.
2734
2759
  */
2735
- addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { sessionId, ...params })
2760
+ addTrusted: async (params) => connection.sendRequest("session.permissions.folderTrust.addTrusted", { ...params, sessionId })
2736
2761
  },
2737
2762
  /** @experimental */
2738
2763
  urls: {
@@ -2743,7 +2768,7 @@ function createSessionRpc(connection, sessionId) {
2743
2768
  *
2744
2769
  * @returns Indicates whether the operation succeeded.
2745
2770
  */
2746
- setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { sessionId, ...params })
2771
+ setUnrestrictedMode: async (params) => connection.sendRequest("session.permissions.urls.setUnrestrictedMode", { ...params, sessionId })
2747
2772
  }
2748
2773
  },
2749
2774
  /**
@@ -2755,7 +2780,7 @@ function createSessionRpc(connection, sessionId) {
2755
2780
  *
2756
2781
  * @experimental
2757
2782
  */
2758
- log: async (params) => connection.sendRequest("session.log", { sessionId, ...params }),
2783
+ log: async (params) => connection.sendRequest("session.log", { ...params, sessionId }),
2759
2784
  /** @experimental */
2760
2785
  metadata: {
2761
2786
  /**
@@ -2777,7 +2802,7 @@ function createSessionRpc(connection, sessionId) {
2777
2802
  *
2778
2803
  * @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.
2779
2804
  */
2780
- updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { sessionId, ...params }),
2805
+ updateClientMetadata: async (params) => connection.sendRequest("session.metadata.updateClientMetadata", { ...params, sessionId }),
2781
2806
  /**
2782
2807
  * Reports whether the local session is currently processing user/agent messages.
2783
2808
  *
@@ -2797,7 +2822,7 @@ function createSessionRpc(connection, sessionId) {
2797
2822
  *
2798
2823
  * @returns Token breakdown for the session's current context window, or null if uninitialized.
2799
2824
  */
2800
- contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { sessionId, ...params }),
2825
+ contextInfo: async (params) => connection.sendRequest("session.metadata.contextInfo", { ...params, sessionId }),
2801
2826
  /**
2802
2827
  * 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.
2803
2828
  *
@@ -2811,7 +2836,7 @@ function createSessionRpc(connection, sessionId) {
2811
2836
  *
2812
2837
  * @returns The heaviest individual messages in the session's context window, most-expensive first.
2813
2838
  */
2814
- getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { sessionId, ...params }),
2839
+ getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { ...params, sessionId }),
2815
2840
  /**
2816
2841
  * 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.
2817
2842
  *
@@ -2819,7 +2844,7 @@ function createSessionRpc(connection, sessionId) {
2819
2844
  *
2820
2845
  * @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.
2821
2846
  */
2822
- recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
2847
+ recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { ...params, sessionId }),
2823
2848
  /**
2824
2849
  * 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.
2825
2850
  *
@@ -2827,7 +2852,7 @@ function createSessionRpc(connection, sessionId) {
2827
2852
  *
2828
2853
  * @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.
2829
2854
  */
2830
- setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { sessionId, ...params }),
2855
+ setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { ...params, sessionId }),
2831
2856
  /**
2832
2857
  * Re-tokenizes the session's existing messages against a model and returns aggregate token totals.
2833
2858
  *
@@ -2835,7 +2860,7 @@ function createSessionRpc(connection, sessionId) {
2835
2860
  *
2836
2861
  * @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.
2837
2862
  */
2838
- recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { sessionId, ...params })
2863
+ recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { ...params, sessionId })
2839
2864
  },
2840
2865
  /** @experimental */
2841
2866
  contentExclusion: {
@@ -2846,18 +2871,18 @@ function createSessionRpc(connection, sessionId) {
2846
2871
  *
2847
2872
  * @returns Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
2848
2873
  */
2849
- checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { sessionId, ...params })
2874
+ checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { ...params, sessionId })
2850
2875
  },
2851
2876
  /** @experimental */
2852
2877
  shell: {
2853
2878
  /**
2854
- * 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.
2879
+ * 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.
2855
2880
  *
2856
- * @param params Shell command to run, with optional working directory and timeout in milliseconds.
2881
+ * @param params Shell command to run, with optional working directory and timeout in milliseconds. Spawn failures return an RPC error.
2857
2882
  *
2858
- * @returns Identifier of the spawned process, used to correlate streamed output and exit notifications.
2883
+ * @returns Identifier of the spawned shell process, usable with shell.kill while the process is running.
2859
2884
  */
2860
- exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
2885
+ exec: async (params) => connection.sendRequest("session.shell.exec", { ...params, sessionId }),
2861
2886
  /**
2862
2887
  * 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.
2863
2888
  *
@@ -2865,7 +2890,7 @@ function createSessionRpc(connection, sessionId) {
2865
2890
  *
2866
2891
  * @returns Indicates whether the signal was delivered; false if the process was unknown or already exited.
2867
2892
  */
2868
- kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params }),
2893
+ kill: async (params) => connection.sendRequest("session.shell.kill", { ...params, sessionId }),
2869
2894
  /**
2870
2895
  * Executes a user-requested shell command through the session runtime.
2871
2896
  *
@@ -2873,7 +2898,7 @@ function createSessionRpc(connection, sessionId) {
2873
2898
  *
2874
2899
  * @returns Result of a user-requested shell command.
2875
2900
  */
2876
- executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { sessionId, ...params }),
2901
+ executeUserRequested: async (params) => connection.sendRequest("session.shell.executeUserRequested", { ...params, sessionId }),
2877
2902
  /**
2878
2903
  * Cancels a user-requested shell command by request ID.
2879
2904
  *
@@ -2881,7 +2906,7 @@ function createSessionRpc(connection, sessionId) {
2881
2906
  *
2882
2907
  * @returns Cancellation result for a user-requested shell command.
2883
2908
  */
2884
- cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { sessionId, ...params })
2909
+ cancelUserRequested: async (params) => connection.sendRequest("session.shell.cancelUserRequested", { ...params, sessionId })
2885
2910
  },
2886
2911
  /** @experimental */
2887
2912
  history: {
@@ -2892,7 +2917,7 @@ function createSessionRpc(connection, sessionId) {
2892
2917
  *
2893
2918
  * @returns Compaction outcome with the number of tokens and messages removed, summary text, and the resulting context window breakdown.
2894
2919
  */
2895
- compact: async (params) => connection.sendRequest("session.history.compact", { sessionId, ...params }),
2920
+ compact: async (params) => connection.sendRequest("session.history.compact", { ...params, sessionId }),
2896
2921
  /**
2897
2922
  * Truncates persisted session history to a specific event.
2898
2923
  *
@@ -2900,7 +2925,7 @@ function createSessionRpc(connection, sessionId) {
2900
2925
  *
2901
2926
  * @returns Number of events that were removed by the truncation.
2902
2927
  */
2903
- truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params }),
2928
+ truncate: async (params) => connection.sendRequest("session.history.truncate", { ...params, sessionId }),
2904
2929
  /**
2905
2930
  * 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.
2906
2931
  *
@@ -2914,7 +2939,7 @@ function createSessionRpc(connection, sessionId) {
2914
2939
  *
2915
2940
  * @returns Files and aggregate changes for a prospective rewind.
2916
2941
  */
2917
- previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { sessionId, ...params }),
2942
+ previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { ...params, sessionId }),
2918
2943
  /**
2919
2944
  * 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.
2920
2945
  *
@@ -2922,7 +2947,7 @@ function createSessionRpc(connection, sessionId) {
2922
2947
  *
2923
2948
  * @returns Structured outcome of a rewind request.
2924
2949
  */
2925
- rewind: async (params) => connection.sendRequest("session.history.rewind", { sessionId, ...params }),
2950
+ rewind: async (params) => connection.sendRequest("session.history.rewind", { ...params, sessionId }),
2926
2951
  /**
2927
2952
  * Cancels any in-progress background compaction on a local session.
2928
2953
  *
@@ -2948,7 +2973,7 @@ function createSessionRpc(connection, sessionId) {
2948
2973
  *
2949
2974
  * @returns What a successful clear removed. A clear that could not be applied rejects instead of reporting a count.
2950
2975
  */
2951
- clearContext: async (params) => connection.sendRequest("session.history.clearContext", { sessionId, ...params })
2976
+ clearContext: async (params) => connection.sendRequest("session.history.clearContext", { ...params, sessionId })
2952
2977
  },
2953
2978
  /** @experimental */
2954
2979
  queue: {
@@ -2965,7 +2990,7 @@ function createSessionRpc(connection, sessionId) {
2965
2990
  *
2966
2991
  * @returns Result of moving a queued item.
2967
2992
  */
2968
- moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { sessionId, ...params }),
2993
+ moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { ...params, sessionId }),
2969
2994
  /**
2970
2995
  * Inserts a new queued message at a public visible position.
2971
2996
  *
@@ -2973,7 +2998,7 @@ function createSessionRpc(connection, sessionId) {
2973
2998
  *
2974
2999
  * @returns Result of inserting a queued message.
2975
3000
  */
2976
- insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { sessionId, ...params }),
3001
+ insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { ...params, sessionId }),
2977
3002
  /**
2978
3003
  * Removes an addressable queued item by its stable id.
2979
3004
  *
@@ -2981,7 +3006,7 @@ function createSessionRpc(connection, sessionId) {
2981
3006
  *
2982
3007
  * @returns Result of removing a queued item.
2983
3008
  */
2984
- removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { sessionId, ...params }),
3009
+ removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { ...params, sessionId }),
2985
3010
  /**
2986
3011
  * Updates the text of an addressable single-message queue item.
2987
3012
  *
@@ -2989,7 +3014,7 @@ function createSessionRpc(connection, sessionId) {
2989
3014
  *
2990
3015
  * @returns Result of editing a queued message.
2991
3016
  */
2992
- updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
3017
+ updateText: async (params) => connection.sendRequest("session.queue.updateText", { ...params, sessionId }),
2993
3018
  /**
2994
3019
  * 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.
2995
3020
  *
@@ -2997,7 +3022,7 @@ function createSessionRpc(connection, sessionId) {
2997
3022
  *
2998
3023
  * @returns Result of withdrawing a user message.
2999
3024
  */
3000
- withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
3025
+ withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { ...params, sessionId }),
3001
3026
  /**
3002
3027
  * Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
3003
3028
  *
@@ -3005,7 +3030,7 @@ function createSessionRpc(connection, sessionId) {
3005
3030
  *
3006
3031
  * @returns Result of editing a queued message.
3007
3032
  */
3008
- appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { sessionId, ...params }),
3033
+ appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { ...params, sessionId }),
3009
3034
  /**
3010
3035
  * Duplicates an addressable queued item immediately after its source.
3011
3036
  *
@@ -3013,13 +3038,13 @@ function createSessionRpc(connection, sessionId) {
3013
3038
  *
3014
3039
  * @returns Result of duplicating a queued item.
3015
3040
  */
3016
- duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { sessionId, ...params }),
3041
+ duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { ...params, sessionId }),
3017
3042
  /**
3018
3043
  * Acquires or releases the queued-lane drain pause.
3019
3044
  *
3020
3045
  * @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.
3021
3046
  */
3022
- setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { sessionId, ...params }),
3047
+ setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { ...params, sessionId }),
3023
3048
  /**
3024
3049
  * Moves an addressable queued message into the live turn's steering lane.
3025
3050
  *
@@ -3027,7 +3052,7 @@ function createSessionRpc(connection, sessionId) {
3027
3052
  *
3028
3053
  * @returns Result of trying to steer a queued message into a live turn.
3029
3054
  */
3030
- sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { sessionId, ...params }),
3055
+ sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { ...params, sessionId }),
3031
3056
  /**
3032
3057
  * Removes the most recently queued user-facing item (LIFO).
3033
3058
  *
@@ -3048,7 +3073,7 @@ function createSessionRpc(connection, sessionId) {
3048
3073
  *
3049
3074
  * @returns Batch of session events returned by a read, with cursor and continuation metadata.
3050
3075
  */
3051
- read: async (params) => connection.sendRequest("session.eventLog.read", { sessionId, ...params }),
3076
+ read: async (params) => connection.sendRequest("session.eventLog.read", { ...params, sessionId }),
3052
3077
  /**
3053
3078
  * Returns a snapshot of the current tail cursor without consuming events.
3054
3079
  *
@@ -3062,7 +3087,7 @@ function createSessionRpc(connection, sessionId) {
3062
3087
  *
3063
3088
  * @returns Opaque handle representing an event-type interest registration.
3064
3089
  */
3065
- registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { sessionId, ...params }),
3090
+ registerInterest: async (params) => connection.sendRequest("session.eventLog.registerInterest", { ...params, sessionId }),
3066
3091
  /**
3067
3092
  * Releases a consumer's previously-registered interest in an event type.
3068
3093
  *
@@ -3070,7 +3095,7 @@ function createSessionRpc(connection, sessionId) {
3070
3095
  *
3071
3096
  * @returns Indicates whether the operation succeeded.
3072
3097
  */
3073
- releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { sessionId, ...params })
3098
+ releaseInterest: async (params) => connection.sendRequest("session.eventLog.releaseInterest", { ...params, sessionId })
3074
3099
  },
3075
3100
  /** @experimental */
3076
3101
  usage: {
@@ -3090,7 +3115,7 @@ function createSessionRpc(connection, sessionId) {
3090
3115
  *
3091
3116
  * @returns Prediction result. Available results include prediction details; unavailable results include an explicit reason.
3092
3117
  */
3093
- predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { sessionId, ...params })
3118
+ predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { ...params, sessionId })
3094
3119
  },
3095
3120
  /** @experimental */
3096
3121
  remote: {
@@ -3101,7 +3126,7 @@ function createSessionRpc(connection, sessionId) {
3101
3126
  *
3102
3127
  * @returns GitHub URL for the session and a flag indicating whether remote steering is enabled.
3103
3128
  */
3104
- enable: async (params) => connection.sendRequest("session.remote.enable", { sessionId, ...params }),
3129
+ enable: async (params) => connection.sendRequest("session.remote.enable", { ...params, sessionId }),
3105
3130
  /**
3106
3131
  * Disables remote session export and steering.
3107
3132
  */
@@ -3113,7 +3138,7 @@ function createSessionRpc(connection, sessionId) {
3113
3138
  *
3114
3139
  * @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.
3115
3140
  */
3116
- notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { sessionId, ...params })
3141
+ notifySteerableChanged: async (params) => connection.sendRequest("session.remote.notifySteerableChanged", { ...params, sessionId })
3117
3142
  },
3118
3143
  /** @experimental */
3119
3144
  visibility: {
@@ -3130,7 +3155,7 @@ function createSessionRpc(connection, sessionId) {
3130
3155
  *
3131
3156
  * @returns Effective sharing status and shareable GitHub URL after updating session visibility.
3132
3157
  */
3133
- set: async (params) => connection.sendRequest("session.visibility.set", { sessionId, ...params })
3158
+ set: async (params) => connection.sendRequest("session.visibility.set", { ...params, sessionId })
3134
3159
  },
3135
3160
  /** @experimental */
3136
3161
  schedule: {
@@ -3147,7 +3172,7 @@ function createSessionRpc(connection, sessionId) {
3147
3172
  *
3148
3173
  * @returns Remove a scheduled prompt by id. The result entry is omitted if the id was unknown.
3149
3174
  */
3150
- stop: async (params) => connection.sendRequest("session.schedule.stop", { sessionId, ...params })
3175
+ stop: async (params) => connection.sendRequest("session.schedule.stop", { ...params, sessionId })
3151
3176
  }
3152
3177
  };
3153
3178
  }
@@ -3160,7 +3185,7 @@ function createInternalSessionRpc(connection, sessionId) {
3160
3185
  *
3161
3186
  * @experimental
3162
3187
  */
3163
- sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { sessionId, ...params }),
3188
+ sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { ...params, sessionId }),
3164
3189
  /** @experimental */
3165
3190
  gitHubAuth: {
3166
3191
  /**
@@ -3188,13 +3213,13 @@ function createInternalSessionRpc(connection, sessionId) {
3188
3213
  *
3189
3214
  * @returns Authentication credentials accepted only at native protocol ingress. Runtime outputs use credential-free `AuthIdentity` metadata.
3190
3215
  */
3191
- login: async (params) => connection.sendRequest("session.gitHubAuth.login", { sessionId, ...params }),
3216
+ login: async (params) => connection.sendRequest("session.gitHubAuth.login", { ...params, sessionId }),
3192
3217
  /**
3193
3218
  * Switches the session to another available authentication.
3194
3219
  *
3195
3220
  * @param params Parameters for switching the session's active authentication.
3196
3221
  */
3197
- switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { sessionId, ...params }),
3222
+ switchToAuth: async (params) => connection.sendRequest("session.gitHubAuth.switchToAuth", { ...params, sessionId }),
3198
3223
  /**
3199
3224
  * Logs out the session's current GitHub authentication.
3200
3225
  *
@@ -3208,7 +3233,7 @@ function createInternalSessionRpc(connection, sessionId) {
3208
3233
  *
3209
3234
  * @returns Whether the requested authentication was logged out.
3210
3235
  */
3211
- logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { sessionId, ...params }),
3236
+ logoutUser: async (params) => connection.sendRequest("session.gitHubAuth.logoutUser", { ...params, sessionId }),
3212
3237
  /**
3213
3238
  * Gets validation errors from the most recent authentication attempt.
3214
3239
  *
@@ -3225,13 +3250,13 @@ function createInternalSessionRpc(connection, sessionId) {
3225
3250
  *
3226
3251
  * @param params Internal canvas provider registration parameters.
3227
3252
  */
3228
- register: async (params) => connection.sendRequest("session.canvas.provider.register", { sessionId, ...params }),
3253
+ register: async (params) => connection.sendRequest("session.canvas.provider.register", { ...params, sessionId }),
3229
3254
  /**
3230
3255
  * Unregisters an internal canvas provider connection.
3231
3256
  *
3232
3257
  * @param params Internal canvas provider unregistration parameters.
3233
3258
  */
3234
- unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { sessionId, ...params })
3259
+ unregister: async (params) => connection.sendRequest("session.canvas.provider.unregister", { ...params, sessionId })
3235
3260
  }
3236
3261
  },
3237
3262
  /** @experimental */
@@ -3243,7 +3268,7 @@ function createInternalSessionRpc(connection, sessionId) {
3243
3268
  *
3244
3269
  * @returns Complete current or terminal workflow run envelope.
3245
3270
  */
3246
- runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { sessionId, ...params }),
3271
+ runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { ...params, sessionId }),
3247
3272
  /**
3248
3273
  * Internal tool-originated dynamic workflow resume.
3249
3274
  *
@@ -3251,13 +3276,13 @@ function createInternalSessionRpc(connection, sessionId) {
3251
3276
  *
3252
3277
  * @returns Resolved persisted workflow identity and resumed run envelope.
3253
3278
  */
3254
- resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { sessionId, ...params }),
3279
+ resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { ...params, sessionId }),
3255
3280
  /**
3256
3281
  * Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
3257
3282
  *
3258
3283
  * @param params Parameters for an owned durable pause checkpoint.
3259
3284
  */
3260
- pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { sessionId, ...params })
3285
+ pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { ...params, sessionId })
3261
3286
  },
3262
3287
  /** @experimental */
3263
3288
  model: {
@@ -3268,7 +3293,7 @@ function createInternalSessionRpc(connection, sessionId) {
3268
3293
  *
3269
3294
  * @returns The model identifier active on the session after the switch.
3270
3295
  */
3271
- applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { sessionId, ...params })
3296
+ applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { ...params, sessionId })
3272
3297
  },
3273
3298
  /** @experimental */
3274
3299
  mcp: {
@@ -3279,7 +3304,7 @@ function createInternalSessionRpc(connection, sessionId) {
3279
3304
  *
3280
3305
  * @returns MCP server startup filtering result.
3281
3306
  */
3282
- reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { sessionId, ...params }),
3307
+ reloadWithConfig: async (params) => connection.sendRequest("session.mcp.reloadWithConfig", { ...params, sessionId }),
3283
3308
  /**
3284
3309
  * Configures the built-in GitHub MCP server for the session's current auth context.
3285
3310
  *
@@ -3287,19 +3312,19 @@ function createInternalSessionRpc(connection, sessionId) {
3287
3312
  *
3288
3313
  * @returns Result of configuring GitHub MCP.
3289
3314
  */
3290
- configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { sessionId, ...params }),
3315
+ configureGitHub: async (params) => connection.sendRequest("session.mcp.configureGitHub", { ...params, sessionId }),
3291
3316
  /**
3292
3317
  * 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.
3293
3318
  *
3294
3319
  * @param params Registration parameters for an external MCP client.
3295
3320
  */
3296
- registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { sessionId, ...params }),
3321
+ registerExternalClient: async (params) => connection.sendRequest("session.mcp.registerExternalClient", { ...params, sessionId }),
3297
3322
  /**
3298
3323
  * 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.
3299
3324
  *
3300
3325
  * @param params Server name identifying the external client to remove.
3301
3326
  */
3302
- unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
3327
+ unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { ...params, sessionId })
3303
3328
  },
3304
3329
  /** @experimental */
3305
3330
  connectors: {
@@ -3310,7 +3335,7 @@ function createInternalSessionRpc(connection, sessionId) {
3310
3335
  *
3311
3336
  * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
3312
3337
  */
3313
- reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
3338
+ reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { ...params, sessionId }),
3314
3339
  /**
3315
3340
  * Removes the runtime-owned Connector MCP projection without changing service-side connections.
3316
3341
  *
@@ -3327,7 +3352,7 @@ function createInternalSessionRpc(connection, sessionId) {
3327
3352
  *
3328
3353
  * @returns Whether finalizing the invocation effect succeeded, and the failure reason when it did not.
3329
3354
  */
3330
- finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { sessionId, ...params })
3355
+ finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { ...params, sessionId })
3331
3356
  },
3332
3357
  /** @experimental */
3333
3358
  settings: {
@@ -3344,7 +3369,7 @@ function createInternalSessionRpc(connection, sessionId) {
3344
3369
  *
3345
3370
  * @returns Result of evaluating a Rust-owned settings predicate.
3346
3371
  */
3347
- evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { sessionId, ...params })
3372
+ evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { ...params, sessionId })
3348
3373
  },
3349
3374
  /** @experimental */
3350
3375
  queue: {
@@ -3367,7 +3392,7 @@ function createInternalSessionRpc(connection, sessionId) {
3367
3392
  *
3368
3393
  * @returns Whether a deferred-idle drain should run.
3369
3394
  */
3370
- beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { sessionId, ...params }),
3395
+ beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { ...params, sessionId }),
3371
3396
  /**
3372
3397
  * Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
3373
3398
  *
@@ -3375,13 +3400,13 @@ function createInternalSessionRpc(connection, sessionId) {
3375
3400
  *
3376
3401
  * @returns Action selected by the native deferred-idle drain.
3377
3402
  */
3378
- finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { sessionId, ...params }),
3403
+ finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { ...params, sessionId }),
3379
3404
  /**
3380
3405
  * Marks session.idle as deferred by native background work state.
3381
3406
  *
3382
3407
  * @param params Inputs for marking session.idle deferred in native state.
3383
3408
  */
3384
- deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { sessionId, ...params }),
3409
+ deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { ...params, sessionId }),
3385
3410
  /**
3386
3411
  * Consumes queued native system notifications matching an internal filter.
3387
3412
  *
@@ -3389,7 +3414,7 @@ function createInternalSessionRpc(connection, sessionId) {
3389
3414
  *
3390
3415
  * @returns Indicates whether a user-facing pending item was removed.
3391
3416
  */
3392
- consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { sessionId, ...params }),
3417
+ consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { ...params, sessionId }),
3393
3418
  /**
3394
3419
  * Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
3395
3420
  *
@@ -3420,7 +3445,7 @@ function createInternalSessionRpc(connection, sessionId) {
3420
3445
  *
3421
3446
  * @returns Result of registering or re-arming a scheduled prompt.
3422
3447
  */
3423
- add: async (params) => connection.sendRequest("session.schedule.add", { sessionId, ...params }),
3448
+ add: async (params) => connection.sendRequest("session.schedule.add", { ...params, sessionId }),
3424
3449
  /**
3425
3450
  * Registers a recurring cron scheduled prompt.
3426
3451
  *
@@ -3428,7 +3453,7 @@ function createInternalSessionRpc(connection, sessionId) {
3428
3453
  *
3429
3454
  * @returns Result of registering or re-arming a scheduled prompt.
3430
3455
  */
3431
- addCron: async (params) => connection.sendRequest("session.schedule.addCron", { sessionId, ...params }),
3456
+ addCron: async (params) => connection.sendRequest("session.schedule.addCron", { ...params, sessionId }),
3432
3457
  /**
3433
3458
  * Registers an absolute-time scheduled prompt.
3434
3459
  *
@@ -3436,7 +3461,7 @@ function createInternalSessionRpc(connection, sessionId) {
3436
3461
  *
3437
3462
  * @returns Result of registering or re-arming a scheduled prompt.
3438
3463
  */
3439
- addAt: async (params) => connection.sendRequest("session.schedule.addAt", { sessionId, ...params }),
3464
+ addAt: async (params) => connection.sendRequest("session.schedule.addAt", { ...params, sessionId }),
3440
3465
  /**
3441
3466
  * Registers a self-paced scheduled prompt.
3442
3467
  *
@@ -3444,7 +3469,7 @@ function createInternalSessionRpc(connection, sessionId) {
3444
3469
  *
3445
3470
  * @returns Result of registering or re-arming a scheduled prompt.
3446
3471
  */
3447
- addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { sessionId, ...params }),
3472
+ addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { ...params, sessionId }),
3448
3473
  /**
3449
3474
  * Re-arms an active self-paced scheduled prompt.
3450
3475
  *
@@ -3452,7 +3477,7 @@ function createInternalSessionRpc(connection, sessionId) {
3452
3477
  *
3453
3478
  * @returns Result of registering or re-arming a scheduled prompt.
3454
3479
  */
3455
- rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { sessionId, ...params })
3480
+ rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { ...params, sessionId })
3456
3481
  }
3457
3482
  };
3458
3483
  }