@github/copilot-sdk 1.0.8 → 1.0.9-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/dist/cjs/client.js +9 -0
- package/dist/cjs/extension.js +21 -6
- package/dist/cjs/factory.js +123 -0
- package/dist/cjs/generated/rpc.js +376 -11
- package/dist/cjs/index.js +11 -2
- package/dist/cjs/session.js +598 -3
- package/dist/cjs/sessionFsProvider.js +43 -0
- package/dist/cjs/types.js +3 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +9 -0
- package/dist/extension.d.ts +11 -2
- package/dist/extension.js +22 -6
- package/dist/factory.d.ts +273 -0
- package/dist/factory.js +96 -0
- package/dist/generated/rpc.d.ts +2445 -228
- package/dist/generated/rpc.js +376 -11
- package/dist/generated/session-events.d.ts +260 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +7 -1
- package/dist/session.d.ts +21 -0
- package/dist/session.js +602 -3
- package/dist/sessionFsProvider.d.ts +38 -2
- package/dist/sessionFsProvider.js +42 -0
- package/dist/types.d.ts +95 -10
- package/dist/types.js +2 -0
- package/docs/extensions.md +1 -0
- package/docs/factories.md +240 -0
- package/docs/factory-patterns.md +194 -0
- package/package.json +2 -2
package/dist/generated/rpc.js
CHANGED
|
@@ -19,7 +19,13 @@ function createServerRpc(connection) {
|
|
|
19
19
|
*
|
|
20
20
|
* @returns List of Copilot models available to the resolved user, including capabilities and billing metadata.
|
|
21
21
|
*/
|
|
22
|
-
list: async (params) => connection.sendRequest("models.list", params)
|
|
22
|
+
list: async (params) => connection.sendRequest("models.list", params),
|
|
23
|
+
/**
|
|
24
|
+
* Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
|
|
25
|
+
*
|
|
26
|
+
* @returns The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
|
|
27
|
+
*/
|
|
28
|
+
getBuiltInCatalog: async () => connection.sendRequest("models.getBuiltInCatalog", {})
|
|
23
29
|
},
|
|
24
30
|
/** @experimental */
|
|
25
31
|
tools: {
|
|
@@ -578,6 +584,22 @@ function createInternalServerRpc(connection) {
|
|
|
578
584
|
connect: async (params) => connection.sendRequest("connect", params),
|
|
579
585
|
/** @experimental */
|
|
580
586
|
sessions: {
|
|
587
|
+
/**
|
|
588
|
+
* Reads lightweight persisted metadata for one local session without opening it.
|
|
589
|
+
*
|
|
590
|
+
* @param params Session ID whose persisted metadata should be read.
|
|
591
|
+
*
|
|
592
|
+
* @returns Persisted local session metadata when the session exists.
|
|
593
|
+
*/
|
|
594
|
+
getMetadata: async (params) => connection.sendRequest("sessions.getMetadata", params),
|
|
595
|
+
/**
|
|
596
|
+
* Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
|
|
597
|
+
*
|
|
598
|
+
* @param params Limit for non-empty local session IDs.
|
|
599
|
+
*
|
|
600
|
+
* @returns Recent local session IDs that contain user-visible history.
|
|
601
|
+
*/
|
|
602
|
+
listNonEmptySessionIds: async (params) => connection.sendRequest("sessions.listNonEmptySessionIds", params),
|
|
581
603
|
/**
|
|
582
604
|
* Computes the absolute path to a session's persisted events.jsonl file. Internal: filesystem paths are only meaningful in-process (CLI and runtime share a filesystem). Currently used by the CLI's contribution-graph feature to read historical events directly. Remote SDK consumers must not depend on this; a proper event-query API would replace it if the contribution graph ever needed to work over the wire.
|
|
583
605
|
*
|
|
@@ -594,6 +616,12 @@ function createInternalServerRpc(connection) {
|
|
|
594
616
|
* @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
|
|
595
617
|
*/
|
|
596
618
|
getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
|
|
619
|
+
/**
|
|
620
|
+
* Deletes one local session from disk after running the same lifecycle hooks as the session manager.
|
|
621
|
+
*
|
|
622
|
+
* @param params Session ID to delete from disk.
|
|
623
|
+
*/
|
|
624
|
+
delete: async (params) => connection.sendRequest("sessions.delete", params),
|
|
597
625
|
/**
|
|
598
626
|
* Gets the dynamic-context board entry count associated with a session, when available. Internal: this exists solely so CLI telemetry events (`rem_spawn_gate`, `rem_consolidation_complete`) can pair START / END board counts around the detached rem-agent spawn. "Dynamic context board" is a runtime-internal concept that is not part of the public SDK contract; the long-term plan is to relocate the telemetry emission into the runtime so this method can be deleted entirely.
|
|
599
627
|
*
|
|
@@ -657,6 +685,24 @@ function createSessionRpc(connection, sessionId) {
|
|
|
657
685
|
* @experimental
|
|
658
686
|
*/
|
|
659
687
|
abort: async (params) => connection.sendRequest("session.abort", { sessionId, ...params }),
|
|
688
|
+
/**
|
|
689
|
+
* 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.
|
|
690
|
+
*
|
|
691
|
+
* @param params Parameters for interrupting the main agent turn.
|
|
692
|
+
*
|
|
693
|
+
* @returns Result of interrupting the main agent turn.
|
|
694
|
+
*
|
|
695
|
+
* @experimental
|
|
696
|
+
*/
|
|
697
|
+
interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { sessionId, ...params }),
|
|
698
|
+
/**
|
|
699
|
+
* Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
|
|
700
|
+
*
|
|
701
|
+
* @returns The number of running background agents (task-registry agents) that were cancelled.
|
|
702
|
+
*
|
|
703
|
+
* @experimental
|
|
704
|
+
*/
|
|
705
|
+
cancelAllBackgroundAgents: async () => connection.sendRequest("session.cancelAllBackgroundAgents", { sessionId }),
|
|
660
706
|
/**
|
|
661
707
|
* Shuts down the session and persists its final state. Awaits any deferred sessionEnd hooks before resolving so user-supplied hook scripts complete before the runtime tears down.
|
|
662
708
|
*
|
|
@@ -743,6 +789,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
743
789
|
* @returns Complete current or terminal factory run envelope.
|
|
744
790
|
*/
|
|
745
791
|
run: async (params) => connection.sendRequest("session.factory.run", { sessionId, ...params }),
|
|
792
|
+
/**
|
|
793
|
+
* Resumes a factory run using its persisted name, arguments, journal, and accounting.
|
|
794
|
+
*
|
|
795
|
+
* @param params Parameters for resuming a factory run from its persisted identity.
|
|
796
|
+
*
|
|
797
|
+
* @returns Resolved persisted factory identity and resumed run envelope.
|
|
798
|
+
*/
|
|
799
|
+
resume: async (params) => connection.sendRequest("session.factory.resume", { sessionId, ...params }),
|
|
746
800
|
/**
|
|
747
801
|
* Gets the current or settled envelope for a factory run.
|
|
748
802
|
*
|
|
@@ -751,6 +805,28 @@ function createSessionRpc(connection, sessionId) {
|
|
|
751
805
|
* @returns Complete current or terminal factory run envelope.
|
|
752
806
|
*/
|
|
753
807
|
getRun: async (params) => connection.sendRequest("session.factory.getRun", { sessionId, ...params }),
|
|
808
|
+
/**
|
|
809
|
+
* Lists durable factory runs for this session in creation order.
|
|
810
|
+
*
|
|
811
|
+
* @returns Factory runs in durable creation order.
|
|
812
|
+
*/
|
|
813
|
+
listRuns: async () => connection.sendRequest("session.factory.listRuns", { sessionId }),
|
|
814
|
+
/**
|
|
815
|
+
* Gets durable and live observability detail for one factory run.
|
|
816
|
+
*
|
|
817
|
+
* @param params Parameters for retrieving a factory run.
|
|
818
|
+
*
|
|
819
|
+
* @returns Full factory run observability detail.
|
|
820
|
+
*/
|
|
821
|
+
getRunDetail: async (params) => connection.sendRequest("session.factory.getRunDetail", { sessionId, ...params }),
|
|
822
|
+
/**
|
|
823
|
+
* Pages durable progress for one factory run.
|
|
824
|
+
*
|
|
825
|
+
* @param params Parameters for paging factory progress.
|
|
826
|
+
*
|
|
827
|
+
* @returns A bidirectional page of factory progress.
|
|
828
|
+
*/
|
|
829
|
+
getRunProgress: async (params) => connection.sendRequest("session.factory.getRunProgress", { sessionId, ...params }),
|
|
754
830
|
/**
|
|
755
831
|
* Requests cancellation of a factory run and returns its run envelope.
|
|
756
832
|
*
|
|
@@ -905,6 +981,22 @@ function createSessionRpc(connection, sessionId) {
|
|
|
905
981
|
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
906
982
|
*/
|
|
907
983
|
getWorkspace: async () => connection.sendRequest("session.workspaces.getWorkspace", { sessionId }),
|
|
984
|
+
/**
|
|
985
|
+
* Updates workspace metadata for a local session and returns the refreshed workspace.
|
|
986
|
+
*
|
|
987
|
+
* @param params Workspace metadata fields to update.
|
|
988
|
+
*
|
|
989
|
+
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
990
|
+
*/
|
|
991
|
+
updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { sessionId, ...params }),
|
|
992
|
+
/**
|
|
993
|
+
* Ensures a local session workspace exists and returns it.
|
|
994
|
+
*
|
|
995
|
+
* @param params Optional session context used when creating a local workspace.
|
|
996
|
+
*
|
|
997
|
+
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
998
|
+
*/
|
|
999
|
+
ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { sessionId, ...params }),
|
|
908
1000
|
/**
|
|
909
1001
|
* Lists files stored in the session workspace files directory.
|
|
910
1002
|
*
|
|
@@ -939,6 +1031,48 @@ function createSessionRpc(connection, sessionId) {
|
|
|
939
1031
|
* @returns Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
|
|
940
1032
|
*/
|
|
941
1033
|
readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { sessionId, ...params }),
|
|
1034
|
+
/**
|
|
1035
|
+
* Adds a compaction summary checkpoint to the local session workspace.
|
|
1036
|
+
*
|
|
1037
|
+
* @param params Compaction summary checkpoint to persist.
|
|
1038
|
+
*
|
|
1039
|
+
* @returns Persisted summary metadata and refreshed workspace metadata.
|
|
1040
|
+
*/
|
|
1041
|
+
addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { sessionId, ...params }),
|
|
1042
|
+
/**
|
|
1043
|
+
* Truncates local workspace compaction summaries after a rollback.
|
|
1044
|
+
*
|
|
1045
|
+
* @param params Rollback point for local workspace summaries.
|
|
1046
|
+
*
|
|
1047
|
+
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
1048
|
+
*/
|
|
1049
|
+
truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { sessionId, ...params }),
|
|
1050
|
+
/**
|
|
1051
|
+
* Reads the autopilot objective state file from the local session workspace.
|
|
1052
|
+
*
|
|
1053
|
+
* @returns Autopilot objective file content, or null when missing.
|
|
1054
|
+
*/
|
|
1055
|
+
readAutopilotObjective: async () => connection.sendRequest("session.workspaces.readAutopilotObjective", { sessionId }),
|
|
1056
|
+
/**
|
|
1057
|
+
* Writes the autopilot objective state file in the local session workspace.
|
|
1058
|
+
*
|
|
1059
|
+
* @param params Autopilot objective file content to persist.
|
|
1060
|
+
*
|
|
1061
|
+
* @returns Result of writing the autopilot objective file.
|
|
1062
|
+
*/
|
|
1063
|
+
writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { sessionId, ...params }),
|
|
1064
|
+
/**
|
|
1065
|
+
* Deletes the autopilot objective state file from the local session workspace.
|
|
1066
|
+
*
|
|
1067
|
+
* @returns Result of deleting the autopilot objective file.
|
|
1068
|
+
*/
|
|
1069
|
+
deleteAutopilotObjective: async () => connection.sendRequest("session.workspaces.deleteAutopilotObjective", { sessionId }),
|
|
1070
|
+
/**
|
|
1071
|
+
* Checks whether the local session workspace has an autopilot objective state file.
|
|
1072
|
+
*
|
|
1073
|
+
* @returns Whether the autopilot objective file exists.
|
|
1074
|
+
*/
|
|
1075
|
+
autopilotObjectiveExists: async () => connection.sendRequest("session.workspaces.autopilotObjectiveExists", { sessionId }),
|
|
942
1076
|
/**
|
|
943
1077
|
* Saves pasted content as a UTF-8 file in the session workspace.
|
|
944
1078
|
*
|
|
@@ -948,7 +1082,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
948
1082
|
*/
|
|
949
1083
|
saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
|
|
950
1084
|
/**
|
|
951
|
-
* Computes a diff for the session workspace.
|
|
1085
|
+
* 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`.
|
|
952
1086
|
*
|
|
953
1087
|
* @param params Parameters for computing a workspace diff.
|
|
954
1088
|
*
|
|
@@ -996,11 +1130,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
996
1130
|
/** @experimental */
|
|
997
1131
|
agent: {
|
|
998
1132
|
/**
|
|
999
|
-
* Lists
|
|
1133
|
+
* Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
|
|
1134
|
+
*
|
|
1135
|
+
* @param params Controls whether built-in agents and authored prompt text are included.
|
|
1000
1136
|
*
|
|
1001
|
-
* @returns
|
|
1137
|
+
* @returns Agents available to the session.
|
|
1002
1138
|
*/
|
|
1003
|
-
list: async () => connection.sendRequest("session.agent.list", { sessionId }),
|
|
1139
|
+
list: async (params) => connection.sendRequest("session.agent.list", { sessionId, ...params }),
|
|
1004
1140
|
/**
|
|
1005
1141
|
* Gets the currently selected custom agent for the session.
|
|
1006
1142
|
*
|
|
@@ -1207,9 +1343,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1207
1343
|
*/
|
|
1208
1344
|
removeGitHub: async () => connection.sendRequest("session.mcp.removeGitHub", { sessionId }),
|
|
1209
1345
|
/**
|
|
1210
|
-
* Starts an individual MCP server on the live session from a caller-supplied
|
|
1346
|
+
* Starts an individual MCP server on the live session. Omit `config` for a config-free start-by-name of an already-configured server (reuses the server's already-registered configuration); supply `config` to start from a caller-supplied configuration. Session-scoped and ephemeral: the server is added to this session's running set only and is reaped when the session ends. Does NOT modify persistent user configuration (`mcp.config.*`), so it does not affect future sessions. The server surfaces through `session.mcp.list` and the `session.mcp_servers_loaded` / `session.mcp_server_status_changed` events like any other server.
|
|
1211
1347
|
*
|
|
1212
|
-
* @param params Server name and configuration for an individual MCP server start.
|
|
1348
|
+
* @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.
|
|
1213
1349
|
*/
|
|
1214
1350
|
startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
|
|
1215
1351
|
/**
|
|
@@ -1249,7 +1385,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1249
1385
|
*
|
|
1250
1386
|
* @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
|
|
1251
1387
|
*/
|
|
1252
|
-
login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params })
|
|
1388
|
+
login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params }),
|
|
1389
|
+
/**
|
|
1390
|
+
* Responds to a pending MCP OAuth authorization request by its request id.
|
|
1391
|
+
*
|
|
1392
|
+
* @param params Pending MCP OAuth request id to respond to.
|
|
1393
|
+
*
|
|
1394
|
+
* @returns Indicates whether the pending MCP OAuth response was accepted.
|
|
1395
|
+
*/
|
|
1396
|
+
respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
|
|
1253
1397
|
},
|
|
1254
1398
|
/** @experimental */
|
|
1255
1399
|
headers: {
|
|
@@ -1665,9 +1809,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1665
1809
|
/**
|
|
1666
1810
|
* Clears session-scoped tool permission approvals.
|
|
1667
1811
|
*
|
|
1812
|
+
* @param params Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
|
|
1813
|
+
*
|
|
1668
1814
|
* @returns Indicates whether the operation succeeded.
|
|
1669
1815
|
*/
|
|
1670
|
-
resetSessionApprovals: async () => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId }),
|
|
1816
|
+
resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId, ...params }),
|
|
1671
1817
|
/**
|
|
1672
1818
|
* Notifies the runtime that a permission prompt UI has been shown to the user.
|
|
1673
1819
|
*
|
|
@@ -1853,9 +1999,20 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1853
1999
|
recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { sessionId, ...params })
|
|
1854
2000
|
},
|
|
1855
2001
|
/** @experimental */
|
|
2002
|
+
contentExclusion: {
|
|
2003
|
+
/**
|
|
2004
|
+
* Checks local file system absolute paths within the session working directory against its content-exclusion policy. Results preserve input order. Unsupported paths/filesystems and unavailable policy evaluation return available false, and callers must treat every requested path as excluded.
|
|
2005
|
+
*
|
|
2006
|
+
* @param params Local file system absolute paths within the session working directory to check against its content-exclusion policy.
|
|
2007
|
+
*
|
|
2008
|
+
* @returns Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
|
|
2009
|
+
*/
|
|
2010
|
+
checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { sessionId, ...params })
|
|
2011
|
+
},
|
|
2012
|
+
/** @experimental */
|
|
1856
2013
|
shell: {
|
|
1857
2014
|
/**
|
|
1858
|
-
* Starts a shell command and streams output through session notifications.
|
|
2015
|
+
* 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.
|
|
1859
2016
|
*
|
|
1860
2017
|
* @param params Shell command to run, with optional working directory and timeout in milliseconds.
|
|
1861
2018
|
*
|
|
@@ -1863,7 +2020,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1863
2020
|
*/
|
|
1864
2021
|
exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
|
|
1865
2022
|
/**
|
|
1866
|
-
* Sends a signal to a shell process previously started via "shell.exec".
|
|
2023
|
+
* 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.
|
|
1867
2024
|
*
|
|
1868
2025
|
* @param params Identifier of a process previously returned by "shell.exec" and the signal to send.
|
|
1869
2026
|
*
|
|
@@ -1905,6 +2062,28 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1905
2062
|
* @returns Number of events that were removed by the truncation.
|
|
1906
2063
|
*/
|
|
1907
2064
|
truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params }),
|
|
2065
|
+
/**
|
|
2066
|
+
* 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.
|
|
2067
|
+
*
|
|
2068
|
+
* @returns Rewind points and file-change-tracking availability for the session.
|
|
2069
|
+
*/
|
|
2070
|
+
listRewindPoints: async () => connection.sendRequest("session.history.listRewindPoints", { sessionId }),
|
|
2071
|
+
/**
|
|
2072
|
+
* Previews the files that a conversation-and-files rewind would restore.
|
|
2073
|
+
*
|
|
2074
|
+
* @param params Event boundary to preview for conversation-and-files rewind.
|
|
2075
|
+
*
|
|
2076
|
+
* @returns Files and aggregate changes for a prospective rewind.
|
|
2077
|
+
*/
|
|
2078
|
+
previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { sessionId, ...params }),
|
|
2079
|
+
/**
|
|
2080
|
+
* 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.
|
|
2081
|
+
*
|
|
2082
|
+
* @param params Boundary and mode for rewinding session history.
|
|
2083
|
+
*
|
|
2084
|
+
* @returns Structured outcome of a rewind request.
|
|
2085
|
+
*/
|
|
2086
|
+
rewind: async (params) => connection.sendRequest("session.history.rewind", { sessionId, ...params }),
|
|
1908
2087
|
/**
|
|
1909
2088
|
* Cancels any in-progress background compaction on a local session.
|
|
1910
2089
|
*
|
|
@@ -1932,6 +2111,60 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1932
2111
|
* @returns Snapshot of the session's pending queued items and immediate-steering messages.
|
|
1933
2112
|
*/
|
|
1934
2113
|
pendingItems: async () => connection.sendRequest("session.queue.pendingItems", { sessionId }),
|
|
2114
|
+
/**
|
|
2115
|
+
* Moves an addressable queued item to a public visible position.
|
|
2116
|
+
*
|
|
2117
|
+
* @param params Parameters for moving a queued item by stable id.
|
|
2118
|
+
*
|
|
2119
|
+
* @returns Result of moving a queued item.
|
|
2120
|
+
*/
|
|
2121
|
+
moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { sessionId, ...params }),
|
|
2122
|
+
/**
|
|
2123
|
+
* Inserts a new queued message at a public visible position.
|
|
2124
|
+
*
|
|
2125
|
+
* @param params Parameters for inserting a queued message at a public visible position.
|
|
2126
|
+
*
|
|
2127
|
+
* @returns Result of inserting a queued message.
|
|
2128
|
+
*/
|
|
2129
|
+
insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { sessionId, ...params }),
|
|
2130
|
+
/**
|
|
2131
|
+
* Removes an addressable queued item by its stable id.
|
|
2132
|
+
*
|
|
2133
|
+
* @param params Parameters for removing a queued item by stable id.
|
|
2134
|
+
*
|
|
2135
|
+
* @returns Result of removing a queued item.
|
|
2136
|
+
*/
|
|
2137
|
+
removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { sessionId, ...params }),
|
|
2138
|
+
/**
|
|
2139
|
+
* Updates the text of an addressable single-message queue item.
|
|
2140
|
+
*
|
|
2141
|
+
* @param params Parameters for editing a single queued message.
|
|
2142
|
+
*
|
|
2143
|
+
* @returns Result of editing a queued message.
|
|
2144
|
+
*/
|
|
2145
|
+
updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
|
|
2146
|
+
/**
|
|
2147
|
+
* Duplicates an addressable queued item immediately after its source.
|
|
2148
|
+
*
|
|
2149
|
+
* @param params Parameters for duplicating a queued item.
|
|
2150
|
+
*
|
|
2151
|
+
* @returns Result of duplicating a queued item.
|
|
2152
|
+
*/
|
|
2153
|
+
duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { sessionId, ...params }),
|
|
2154
|
+
/**
|
|
2155
|
+
* Acquires or releases the queued-lane drain pause.
|
|
2156
|
+
*
|
|
2157
|
+
* @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.
|
|
2158
|
+
*/
|
|
2159
|
+
setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { sessionId, ...params }),
|
|
2160
|
+
/**
|
|
2161
|
+
* Moves an addressable queued message into the live turn's steering lane.
|
|
2162
|
+
*
|
|
2163
|
+
* @param params Parameters for steering a queued message into a live turn.
|
|
2164
|
+
*
|
|
2165
|
+
* @returns Result of trying to steer a queued message into a live turn.
|
|
2166
|
+
*/
|
|
2167
|
+
sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { sessionId, ...params }),
|
|
1935
2168
|
/**
|
|
1936
2169
|
* Removes the most recently queued user-facing item (LIFO).
|
|
1937
2170
|
*
|
|
@@ -1986,6 +2219,17 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1986
2219
|
getMetrics: async () => connection.sendRequest("session.usage.getMetrics", { sessionId })
|
|
1987
2220
|
},
|
|
1988
2221
|
/** @experimental */
|
|
2222
|
+
limitPrediction: {
|
|
2223
|
+
/**
|
|
2224
|
+
* Predicts an AI-credit session limit for the session's resolved model. Returns an unavailable result instead of falling back when the current model is unresolved auto.
|
|
2225
|
+
*
|
|
2226
|
+
* @param params Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
|
|
2227
|
+
*
|
|
2228
|
+
* @returns Prediction result. Available results include prediction details; unavailable results include an explicit reason.
|
|
2229
|
+
*/
|
|
2230
|
+
predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { sessionId, ...params })
|
|
2231
|
+
},
|
|
2232
|
+
/** @experimental */
|
|
1989
2233
|
remote: {
|
|
1990
2234
|
/**
|
|
1991
2235
|
* Enables remote session export or steering.
|
|
@@ -2046,6 +2290,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2046
2290
|
}
|
|
2047
2291
|
function createInternalSessionRpc(connection, sessionId) {
|
|
2048
2292
|
return {
|
|
2293
|
+
/**
|
|
2294
|
+
* Queues or sends an internal system notification to the session according to its passive policy.
|
|
2295
|
+
*
|
|
2296
|
+
* @param params Internal request for sending a system notification.
|
|
2297
|
+
*
|
|
2298
|
+
* @experimental
|
|
2299
|
+
*/
|
|
2300
|
+
sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { sessionId, ...params }),
|
|
2049
2301
|
/** @experimental */
|
|
2050
2302
|
mcp: {
|
|
2051
2303
|
/**
|
|
@@ -2093,6 +2345,114 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
2093
2345
|
* @returns Result of evaluating a Rust-owned settings predicate.
|
|
2094
2346
|
*/
|
|
2095
2347
|
evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { sessionId, ...params })
|
|
2348
|
+
},
|
|
2349
|
+
/** @experimental */
|
|
2350
|
+
queue: {
|
|
2351
|
+
/**
|
|
2352
|
+
* Returns the internal native queue snapshot for in-process session orchestration.
|
|
2353
|
+
*
|
|
2354
|
+
* @returns Internal snapshot of native queue state for local session orchestration.
|
|
2355
|
+
*/
|
|
2356
|
+
snapshot: async () => connection.sendRequest("session.queue.snapshot", { sessionId }),
|
|
2357
|
+
/**
|
|
2358
|
+
* Reports whether the local session has native queued work pending.
|
|
2359
|
+
*
|
|
2360
|
+
* @returns Whether the native queue has pending work.
|
|
2361
|
+
*/
|
|
2362
|
+
hasPending: async () => connection.sendRequest("session.queue.hasPending", { sessionId }),
|
|
2363
|
+
/**
|
|
2364
|
+
* Begins a native deferred-idle drain when background work has quiesced.
|
|
2365
|
+
*
|
|
2366
|
+
* @param params Inputs for starting a deferred-idle drain.
|
|
2367
|
+
*
|
|
2368
|
+
* @returns Whether a deferred-idle drain should run.
|
|
2369
|
+
*/
|
|
2370
|
+
beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { sessionId, ...params }),
|
|
2371
|
+
/**
|
|
2372
|
+
* Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
|
|
2373
|
+
*
|
|
2374
|
+
* @param params Inputs for completing a deferred-idle drain.
|
|
2375
|
+
*
|
|
2376
|
+
* @returns Action selected by the native deferred-idle drain.
|
|
2377
|
+
*/
|
|
2378
|
+
finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { sessionId, ...params }),
|
|
2379
|
+
/**
|
|
2380
|
+
* Marks session.idle as deferred by native background work state.
|
|
2381
|
+
*
|
|
2382
|
+
* @param params Inputs for marking session.idle deferred in native state.
|
|
2383
|
+
*/
|
|
2384
|
+
deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { sessionId, ...params }),
|
|
2385
|
+
/**
|
|
2386
|
+
* Consumes queued native system notifications matching an internal filter.
|
|
2387
|
+
*
|
|
2388
|
+
* @param params Internal filter for consuming queued system notifications.
|
|
2389
|
+
*
|
|
2390
|
+
* @returns Indicates whether a user-facing pending item was removed.
|
|
2391
|
+
*/
|
|
2392
|
+
consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { sessionId, ...params }),
|
|
2393
|
+
/**
|
|
2394
|
+
* Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
|
|
2395
|
+
*
|
|
2396
|
+
* @returns Result of enqueueing the resume-pending wake item.
|
|
2397
|
+
*/
|
|
2398
|
+
enqueueResumePending: async () => connection.sendRequest("session.queue.enqueueResumePending", { sessionId }),
|
|
2399
|
+
/**
|
|
2400
|
+
* Drains the native local-session work queue for in-process session orchestration.
|
|
2401
|
+
*/
|
|
2402
|
+
process: async () => connection.sendRequest("session.queue.process", { sessionId })
|
|
2403
|
+
},
|
|
2404
|
+
/** @experimental */
|
|
2405
|
+
schedule: {
|
|
2406
|
+
/**
|
|
2407
|
+
* Hydrates the native schedule registry from persisted session events.
|
|
2408
|
+
*/
|
|
2409
|
+
hydrate: async () => connection.sendRequest("session.schedule.hydrate", { sessionId }),
|
|
2410
|
+
/**
|
|
2411
|
+
* Reports whether the session has an active self-paced scheduled prompt.
|
|
2412
|
+
*
|
|
2413
|
+
* @returns Whether the session currently has an active self-paced schedule.
|
|
2414
|
+
*/
|
|
2415
|
+
hasSelfPaced: async () => connection.sendRequest("session.schedule.hasSelfPaced", { sessionId }),
|
|
2416
|
+
/**
|
|
2417
|
+
* Registers a relative-interval scheduled prompt.
|
|
2418
|
+
*
|
|
2419
|
+
* @param params Register a relative-interval scheduled prompt.
|
|
2420
|
+
*
|
|
2421
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2422
|
+
*/
|
|
2423
|
+
add: async (params) => connection.sendRequest("session.schedule.add", { sessionId, ...params }),
|
|
2424
|
+
/**
|
|
2425
|
+
* Registers a recurring cron scheduled prompt.
|
|
2426
|
+
*
|
|
2427
|
+
* @param params Register a cron scheduled prompt.
|
|
2428
|
+
*
|
|
2429
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2430
|
+
*/
|
|
2431
|
+
addCron: async (params) => connection.sendRequest("session.schedule.addCron", { sessionId, ...params }),
|
|
2432
|
+
/**
|
|
2433
|
+
* Registers an absolute-time scheduled prompt.
|
|
2434
|
+
*
|
|
2435
|
+
* @param params Register an absolute-time scheduled prompt.
|
|
2436
|
+
*
|
|
2437
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2438
|
+
*/
|
|
2439
|
+
addAt: async (params) => connection.sendRequest("session.schedule.addAt", { sessionId, ...params }),
|
|
2440
|
+
/**
|
|
2441
|
+
* Registers a self-paced scheduled prompt.
|
|
2442
|
+
*
|
|
2443
|
+
* @param params Register a self-paced scheduled prompt.
|
|
2444
|
+
*
|
|
2445
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2446
|
+
*/
|
|
2447
|
+
addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { sessionId, ...params }),
|
|
2448
|
+
/**
|
|
2449
|
+
* Re-arms an active self-paced scheduled prompt.
|
|
2450
|
+
*
|
|
2451
|
+
* @param params Re-arm a self-paced scheduled prompt.
|
|
2452
|
+
*
|
|
2453
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2454
|
+
*/
|
|
2455
|
+
rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { sessionId, ...params })
|
|
2096
2456
|
}
|
|
2097
2457
|
};
|
|
2098
2458
|
}
|
|
@@ -2167,6 +2527,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
2167
2527
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
2168
2528
|
return handler.sqliteQuery(params);
|
|
2169
2529
|
});
|
|
2530
|
+
connection.onRequest("sessionFs.sqliteTransaction", async (params) => {
|
|
2531
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
2532
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
2533
|
+
return handler.sqliteTransaction(params);
|
|
2534
|
+
});
|
|
2170
2535
|
connection.onRequest("sessionFs.sqliteExists", async (params) => {
|
|
2171
2536
|
const handler = getHandlers(params.sessionId).sessionFs;
|
|
2172
2537
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|