@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
|
@@ -47,7 +47,13 @@ function createServerRpc(connection) {
|
|
|
47
47
|
*
|
|
48
48
|
* @returns List of Copilot models available to the resolved user, including capabilities and billing metadata.
|
|
49
49
|
*/
|
|
50
|
-
list: async (params) => connection.sendRequest("models.list", params)
|
|
50
|
+
list: async (params) => connection.sendRequest("models.list", params),
|
|
51
|
+
/**
|
|
52
|
+
* Returns the running runtime's complete catalog of well-known built-in model IDs without authentication or network access.
|
|
53
|
+
*
|
|
54
|
+
* @returns The running runtime's complete catalog of well-known built-in model IDs, including supported models and additional IDs with built-in metadata.
|
|
55
|
+
*/
|
|
56
|
+
getBuiltInCatalog: async () => connection.sendRequest("models.getBuiltInCatalog", {})
|
|
51
57
|
},
|
|
52
58
|
/** @experimental */
|
|
53
59
|
tools: {
|
|
@@ -606,6 +612,22 @@ function createInternalServerRpc(connection) {
|
|
|
606
612
|
connect: async (params) => connection.sendRequest("connect", params),
|
|
607
613
|
/** @experimental */
|
|
608
614
|
sessions: {
|
|
615
|
+
/**
|
|
616
|
+
* Reads lightweight persisted metadata for one local session without opening it.
|
|
617
|
+
*
|
|
618
|
+
* @param params Session ID whose persisted metadata should be read.
|
|
619
|
+
*
|
|
620
|
+
* @returns Persisted local session metadata when the session exists.
|
|
621
|
+
*/
|
|
622
|
+
getMetadata: async (params) => connection.sendRequest("sessions.getMetadata", params),
|
|
623
|
+
/**
|
|
624
|
+
* Lists recent local session IDs that contain user-visible history, omitting housekeeping-only sessions.
|
|
625
|
+
*
|
|
626
|
+
* @param params Limit for non-empty local session IDs.
|
|
627
|
+
*
|
|
628
|
+
* @returns Recent local session IDs that contain user-visible history.
|
|
629
|
+
*/
|
|
630
|
+
listNonEmptySessionIds: async (params) => connection.sendRequest("sessions.listNonEmptySessionIds", params),
|
|
609
631
|
/**
|
|
610
632
|
* 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.
|
|
611
633
|
*
|
|
@@ -622,6 +644,12 @@ function createInternalServerRpc(connection) {
|
|
|
622
644
|
* @returns The session's persisted remote-steerable flag, or omitted when no value has been persisted.
|
|
623
645
|
*/
|
|
624
646
|
getPersistedRemoteSteerable: async (params) => connection.sendRequest("sessions.getPersistedRemoteSteerable", params),
|
|
647
|
+
/**
|
|
648
|
+
* Deletes one local session from disk after running the same lifecycle hooks as the session manager.
|
|
649
|
+
*
|
|
650
|
+
* @param params Session ID to delete from disk.
|
|
651
|
+
*/
|
|
652
|
+
delete: async (params) => connection.sendRequest("sessions.delete", params),
|
|
625
653
|
/**
|
|
626
654
|
* 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.
|
|
627
655
|
*
|
|
@@ -685,6 +713,24 @@ function createSessionRpc(connection, sessionId) {
|
|
|
685
713
|
* @experimental
|
|
686
714
|
*/
|
|
687
715
|
abort: async (params) => connection.sendRequest("session.abort", { sessionId, ...params }),
|
|
716
|
+
/**
|
|
717
|
+
* 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.
|
|
718
|
+
*
|
|
719
|
+
* @param params Parameters for interrupting the main agent turn.
|
|
720
|
+
*
|
|
721
|
+
* @returns Result of interrupting the main agent turn.
|
|
722
|
+
*
|
|
723
|
+
* @experimental
|
|
724
|
+
*/
|
|
725
|
+
interruptMainTurn: async (params) => connection.sendRequest("session.interruptMainTurn", { sessionId, ...params }),
|
|
726
|
+
/**
|
|
727
|
+
* Cancels every running background agent (task-registry subagents plus sidekick agents) without interrupting the main agent loop. Promoted attached shells are left running.
|
|
728
|
+
*
|
|
729
|
+
* @returns The number of running background agents (task-registry agents) that were cancelled.
|
|
730
|
+
*
|
|
731
|
+
* @experimental
|
|
732
|
+
*/
|
|
733
|
+
cancelAllBackgroundAgents: async () => connection.sendRequest("session.cancelAllBackgroundAgents", { sessionId }),
|
|
688
734
|
/**
|
|
689
735
|
* 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.
|
|
690
736
|
*
|
|
@@ -771,6 +817,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
771
817
|
* @returns Complete current or terminal factory run envelope.
|
|
772
818
|
*/
|
|
773
819
|
run: async (params) => connection.sendRequest("session.factory.run", { sessionId, ...params }),
|
|
820
|
+
/**
|
|
821
|
+
* Resumes a factory run using its persisted name, arguments, journal, and accounting.
|
|
822
|
+
*
|
|
823
|
+
* @param params Parameters for resuming a factory run from its persisted identity.
|
|
824
|
+
*
|
|
825
|
+
* @returns Resolved persisted factory identity and resumed run envelope.
|
|
826
|
+
*/
|
|
827
|
+
resume: async (params) => connection.sendRequest("session.factory.resume", { sessionId, ...params }),
|
|
774
828
|
/**
|
|
775
829
|
* Gets the current or settled envelope for a factory run.
|
|
776
830
|
*
|
|
@@ -779,6 +833,28 @@ function createSessionRpc(connection, sessionId) {
|
|
|
779
833
|
* @returns Complete current or terminal factory run envelope.
|
|
780
834
|
*/
|
|
781
835
|
getRun: async (params) => connection.sendRequest("session.factory.getRun", { sessionId, ...params }),
|
|
836
|
+
/**
|
|
837
|
+
* Lists durable factory runs for this session in creation order.
|
|
838
|
+
*
|
|
839
|
+
* @returns Factory runs in durable creation order.
|
|
840
|
+
*/
|
|
841
|
+
listRuns: async () => connection.sendRequest("session.factory.listRuns", { sessionId }),
|
|
842
|
+
/**
|
|
843
|
+
* Gets durable and live observability detail for one factory run.
|
|
844
|
+
*
|
|
845
|
+
* @param params Parameters for retrieving a factory run.
|
|
846
|
+
*
|
|
847
|
+
* @returns Full factory run observability detail.
|
|
848
|
+
*/
|
|
849
|
+
getRunDetail: async (params) => connection.sendRequest("session.factory.getRunDetail", { sessionId, ...params }),
|
|
850
|
+
/**
|
|
851
|
+
* Pages durable progress for one factory run.
|
|
852
|
+
*
|
|
853
|
+
* @param params Parameters for paging factory progress.
|
|
854
|
+
*
|
|
855
|
+
* @returns A bidirectional page of factory progress.
|
|
856
|
+
*/
|
|
857
|
+
getRunProgress: async (params) => connection.sendRequest("session.factory.getRunProgress", { sessionId, ...params }),
|
|
782
858
|
/**
|
|
783
859
|
* Requests cancellation of a factory run and returns its run envelope.
|
|
784
860
|
*
|
|
@@ -933,6 +1009,22 @@ function createSessionRpc(connection, sessionId) {
|
|
|
933
1009
|
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
934
1010
|
*/
|
|
935
1011
|
getWorkspace: async () => connection.sendRequest("session.workspaces.getWorkspace", { sessionId }),
|
|
1012
|
+
/**
|
|
1013
|
+
* Updates workspace metadata for a local session and returns the refreshed workspace.
|
|
1014
|
+
*
|
|
1015
|
+
* @param params Workspace metadata fields to update.
|
|
1016
|
+
*
|
|
1017
|
+
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
1018
|
+
*/
|
|
1019
|
+
updateMetadata: async (params) => connection.sendRequest("session.workspaces.updateMetadata", { sessionId, ...params }),
|
|
1020
|
+
/**
|
|
1021
|
+
* Ensures a local session workspace exists and returns it.
|
|
1022
|
+
*
|
|
1023
|
+
* @param params Optional session context used when creating a local workspace.
|
|
1024
|
+
*
|
|
1025
|
+
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
1026
|
+
*/
|
|
1027
|
+
ensure: async (params) => connection.sendRequest("session.workspaces.ensure", { sessionId, ...params }),
|
|
936
1028
|
/**
|
|
937
1029
|
* Lists files stored in the session workspace files directory.
|
|
938
1030
|
*
|
|
@@ -967,6 +1059,48 @@ function createSessionRpc(connection, sessionId) {
|
|
|
967
1059
|
* @returns Checkpoint content as a UTF-8 string, or null when the checkpoint or workspace is missing.
|
|
968
1060
|
*/
|
|
969
1061
|
readCheckpoint: async (params) => connection.sendRequest("session.workspaces.readCheckpoint", { sessionId, ...params }),
|
|
1062
|
+
/**
|
|
1063
|
+
* Adds a compaction summary checkpoint to the local session workspace.
|
|
1064
|
+
*
|
|
1065
|
+
* @param params Compaction summary checkpoint to persist.
|
|
1066
|
+
*
|
|
1067
|
+
* @returns Persisted summary metadata and refreshed workspace metadata.
|
|
1068
|
+
*/
|
|
1069
|
+
addSummary: async (params) => connection.sendRequest("session.workspaces.addSummary", { sessionId, ...params }),
|
|
1070
|
+
/**
|
|
1071
|
+
* Truncates local workspace compaction summaries after a rollback.
|
|
1072
|
+
*
|
|
1073
|
+
* @param params Rollback point for local workspace summaries.
|
|
1074
|
+
*
|
|
1075
|
+
* @returns Current workspace metadata for the session, including its absolute filesystem path when available.
|
|
1076
|
+
*/
|
|
1077
|
+
truncateSummaries: async (params) => connection.sendRequest("session.workspaces.truncateSummaries", { sessionId, ...params }),
|
|
1078
|
+
/**
|
|
1079
|
+
* Reads the autopilot objective state file from the local session workspace.
|
|
1080
|
+
*
|
|
1081
|
+
* @returns Autopilot objective file content, or null when missing.
|
|
1082
|
+
*/
|
|
1083
|
+
readAutopilotObjective: async () => connection.sendRequest("session.workspaces.readAutopilotObjective", { sessionId }),
|
|
1084
|
+
/**
|
|
1085
|
+
* Writes the autopilot objective state file in the local session workspace.
|
|
1086
|
+
*
|
|
1087
|
+
* @param params Autopilot objective file content to persist.
|
|
1088
|
+
*
|
|
1089
|
+
* @returns Result of writing the autopilot objective file.
|
|
1090
|
+
*/
|
|
1091
|
+
writeAutopilotObjective: async (params) => connection.sendRequest("session.workspaces.writeAutopilotObjective", { sessionId, ...params }),
|
|
1092
|
+
/**
|
|
1093
|
+
* Deletes the autopilot objective state file from the local session workspace.
|
|
1094
|
+
*
|
|
1095
|
+
* @returns Result of deleting the autopilot objective file.
|
|
1096
|
+
*/
|
|
1097
|
+
deleteAutopilotObjective: async () => connection.sendRequest("session.workspaces.deleteAutopilotObjective", { sessionId }),
|
|
1098
|
+
/**
|
|
1099
|
+
* Checks whether the local session workspace has an autopilot objective state file.
|
|
1100
|
+
*
|
|
1101
|
+
* @returns Whether the autopilot objective file exists.
|
|
1102
|
+
*/
|
|
1103
|
+
autopilotObjectiveExists: async () => connection.sendRequest("session.workspaces.autopilotObjectiveExists", { sessionId }),
|
|
970
1104
|
/**
|
|
971
1105
|
* Saves pasted content as a UTF-8 file in the session workspace.
|
|
972
1106
|
*
|
|
@@ -976,7 +1110,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
976
1110
|
*/
|
|
977
1111
|
saveLargePaste: async (params) => connection.sendRequest("session.workspaces.saveLargePaste", { sessionId, ...params }),
|
|
978
1112
|
/**
|
|
979
|
-
* Computes a diff for the session workspace.
|
|
1113
|
+
* 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`.
|
|
980
1114
|
*
|
|
981
1115
|
* @param params Parameters for computing a workspace diff.
|
|
982
1116
|
*
|
|
@@ -1024,11 +1158,13 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1024
1158
|
/** @experimental */
|
|
1025
1159
|
agent: {
|
|
1026
1160
|
/**
|
|
1027
|
-
* Lists
|
|
1161
|
+
* Lists agents available to the session. Defaults to custom agents only; pass includeBuiltInAgents to include the effective built-in agents.
|
|
1162
|
+
*
|
|
1163
|
+
* @param params Controls whether built-in agents and authored prompt text are included.
|
|
1028
1164
|
*
|
|
1029
|
-
* @returns
|
|
1165
|
+
* @returns Agents available to the session.
|
|
1030
1166
|
*/
|
|
1031
|
-
list: async () => connection.sendRequest("session.agent.list", { sessionId }),
|
|
1167
|
+
list: async (params) => connection.sendRequest("session.agent.list", { sessionId, ...params }),
|
|
1032
1168
|
/**
|
|
1033
1169
|
* Gets the currently selected custom agent for the session.
|
|
1034
1170
|
*
|
|
@@ -1235,9 +1371,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1235
1371
|
*/
|
|
1236
1372
|
removeGitHub: async () => connection.sendRequest("session.mcp.removeGitHub", { sessionId }),
|
|
1237
1373
|
/**
|
|
1238
|
-
* Starts an individual MCP server on the live session from a caller-supplied
|
|
1374
|
+
* 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.
|
|
1239
1375
|
*
|
|
1240
|
-
* @param params Server name and configuration for an individual MCP server start.
|
|
1376
|
+
* @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.
|
|
1241
1377
|
*/
|
|
1242
1378
|
startServer: async (params) => connection.sendRequest("session.mcp.startServer", { sessionId, ...params }),
|
|
1243
1379
|
/**
|
|
@@ -1277,7 +1413,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1277
1413
|
*
|
|
1278
1414
|
* @returns OAuth authorization URL the caller should open, or empty when cached tokens already authenticated the server.
|
|
1279
1415
|
*/
|
|
1280
|
-
login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params })
|
|
1416
|
+
login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params }),
|
|
1417
|
+
/**
|
|
1418
|
+
* Responds to a pending MCP OAuth authorization request by its request id.
|
|
1419
|
+
*
|
|
1420
|
+
* @param params Pending MCP OAuth request id to respond to.
|
|
1421
|
+
*
|
|
1422
|
+
* @returns Indicates whether the pending MCP OAuth response was accepted.
|
|
1423
|
+
*/
|
|
1424
|
+
respond: async (params) => connection.sendRequest("session.mcp.oauth.respond", { sessionId, ...params })
|
|
1281
1425
|
},
|
|
1282
1426
|
/** @experimental */
|
|
1283
1427
|
headers: {
|
|
@@ -1693,9 +1837,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1693
1837
|
/**
|
|
1694
1838
|
* Clears session-scoped tool permission approvals.
|
|
1695
1839
|
*
|
|
1840
|
+
* @param params Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
|
|
1841
|
+
*
|
|
1696
1842
|
* @returns Indicates whether the operation succeeded.
|
|
1697
1843
|
*/
|
|
1698
|
-
resetSessionApprovals: async () => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId }),
|
|
1844
|
+
resetSessionApprovals: async (params) => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId, ...params }),
|
|
1699
1845
|
/**
|
|
1700
1846
|
* Notifies the runtime that a permission prompt UI has been shown to the user.
|
|
1701
1847
|
*
|
|
@@ -1881,9 +2027,20 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1881
2027
|
recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { sessionId, ...params })
|
|
1882
2028
|
},
|
|
1883
2029
|
/** @experimental */
|
|
2030
|
+
contentExclusion: {
|
|
2031
|
+
/**
|
|
2032
|
+
* 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.
|
|
2033
|
+
*
|
|
2034
|
+
* @param params Local file system absolute paths within the session working directory to check against its content-exclusion policy.
|
|
2035
|
+
*
|
|
2036
|
+
* @returns Batch content-exclusion result. Callers must fail closed when policy evaluation is unavailable.
|
|
2037
|
+
*/
|
|
2038
|
+
checkPaths: async (params) => connection.sendRequest("session.contentExclusion.checkPaths", { sessionId, ...params })
|
|
2039
|
+
},
|
|
2040
|
+
/** @experimental */
|
|
1884
2041
|
shell: {
|
|
1885
2042
|
/**
|
|
1886
|
-
* Starts a shell command and streams output through session notifications.
|
|
2043
|
+
* 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.
|
|
1887
2044
|
*
|
|
1888
2045
|
* @param params Shell command to run, with optional working directory and timeout in milliseconds.
|
|
1889
2046
|
*
|
|
@@ -1891,7 +2048,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1891
2048
|
*/
|
|
1892
2049
|
exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
|
|
1893
2050
|
/**
|
|
1894
|
-
* Sends a signal to a shell process previously started via "shell.exec".
|
|
2051
|
+
* 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.
|
|
1895
2052
|
*
|
|
1896
2053
|
* @param params Identifier of a process previously returned by "shell.exec" and the signal to send.
|
|
1897
2054
|
*
|
|
@@ -1933,6 +2090,28 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1933
2090
|
* @returns Number of events that were removed by the truncation.
|
|
1934
2091
|
*/
|
|
1935
2092
|
truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params }),
|
|
2093
|
+
/**
|
|
2094
|
+
* 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.
|
|
2095
|
+
*
|
|
2096
|
+
* @returns Rewind points and file-change-tracking availability for the session.
|
|
2097
|
+
*/
|
|
2098
|
+
listRewindPoints: async () => connection.sendRequest("session.history.listRewindPoints", { sessionId }),
|
|
2099
|
+
/**
|
|
2100
|
+
* Previews the files that a conversation-and-files rewind would restore.
|
|
2101
|
+
*
|
|
2102
|
+
* @param params Event boundary to preview for conversation-and-files rewind.
|
|
2103
|
+
*
|
|
2104
|
+
* @returns Files and aggregate changes for a prospective rewind.
|
|
2105
|
+
*/
|
|
2106
|
+
previewRewind: async (params) => connection.sendRequest("session.history.previewRewind", { sessionId, ...params }),
|
|
2107
|
+
/**
|
|
2108
|
+
* 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.
|
|
2109
|
+
*
|
|
2110
|
+
* @param params Boundary and mode for rewinding session history.
|
|
2111
|
+
*
|
|
2112
|
+
* @returns Structured outcome of a rewind request.
|
|
2113
|
+
*/
|
|
2114
|
+
rewind: async (params) => connection.sendRequest("session.history.rewind", { sessionId, ...params }),
|
|
1936
2115
|
/**
|
|
1937
2116
|
* Cancels any in-progress background compaction on a local session.
|
|
1938
2117
|
*
|
|
@@ -1960,6 +2139,60 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1960
2139
|
* @returns Snapshot of the session's pending queued items and immediate-steering messages.
|
|
1961
2140
|
*/
|
|
1962
2141
|
pendingItems: async () => connection.sendRequest("session.queue.pendingItems", { sessionId }),
|
|
2142
|
+
/**
|
|
2143
|
+
* Moves an addressable queued item to a public visible position.
|
|
2144
|
+
*
|
|
2145
|
+
* @param params Parameters for moving a queued item by stable id.
|
|
2146
|
+
*
|
|
2147
|
+
* @returns Result of moving a queued item.
|
|
2148
|
+
*/
|
|
2149
|
+
moveItem: async (params) => connection.sendRequest("session.queue.moveItem", { sessionId, ...params }),
|
|
2150
|
+
/**
|
|
2151
|
+
* Inserts a new queued message at a public visible position.
|
|
2152
|
+
*
|
|
2153
|
+
* @param params Parameters for inserting a queued message at a public visible position.
|
|
2154
|
+
*
|
|
2155
|
+
* @returns Result of inserting a queued message.
|
|
2156
|
+
*/
|
|
2157
|
+
insertAt: async (params) => connection.sendRequest("session.queue.insertAt", { sessionId, ...params }),
|
|
2158
|
+
/**
|
|
2159
|
+
* Removes an addressable queued item by its stable id.
|
|
2160
|
+
*
|
|
2161
|
+
* @param params Parameters for removing a queued item by stable id.
|
|
2162
|
+
*
|
|
2163
|
+
* @returns Result of removing a queued item.
|
|
2164
|
+
*/
|
|
2165
|
+
removeAt: async (params) => connection.sendRequest("session.queue.removeAt", { sessionId, ...params }),
|
|
2166
|
+
/**
|
|
2167
|
+
* Updates the text of an addressable single-message queue item.
|
|
2168
|
+
*
|
|
2169
|
+
* @param params Parameters for editing a single queued message.
|
|
2170
|
+
*
|
|
2171
|
+
* @returns Result of editing a queued message.
|
|
2172
|
+
*/
|
|
2173
|
+
updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
|
|
2174
|
+
/**
|
|
2175
|
+
* Duplicates an addressable queued item immediately after its source.
|
|
2176
|
+
*
|
|
2177
|
+
* @param params Parameters for duplicating a queued item.
|
|
2178
|
+
*
|
|
2179
|
+
* @returns Result of duplicating a queued item.
|
|
2180
|
+
*/
|
|
2181
|
+
duplicateAt: async (params) => connection.sendRequest("session.queue.duplicateAt", { sessionId, ...params }),
|
|
2182
|
+
/**
|
|
2183
|
+
* Acquires or releases the queued-lane drain pause.
|
|
2184
|
+
*
|
|
2185
|
+
* @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.
|
|
2186
|
+
*/
|
|
2187
|
+
setDrainPaused: async (params) => connection.sendRequest("session.queue.setDrainPaused", { sessionId, ...params }),
|
|
2188
|
+
/**
|
|
2189
|
+
* Moves an addressable queued message into the live turn's steering lane.
|
|
2190
|
+
*
|
|
2191
|
+
* @param params Parameters for steering a queued message into a live turn.
|
|
2192
|
+
*
|
|
2193
|
+
* @returns Result of trying to steer a queued message into a live turn.
|
|
2194
|
+
*/
|
|
2195
|
+
sendNow: async (params) => connection.sendRequest("session.queue.sendNow", { sessionId, ...params }),
|
|
1963
2196
|
/**
|
|
1964
2197
|
* Removes the most recently queued user-facing item (LIFO).
|
|
1965
2198
|
*
|
|
@@ -2014,6 +2247,17 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2014
2247
|
getMetrics: async () => connection.sendRequest("session.usage.getMetrics", { sessionId })
|
|
2015
2248
|
},
|
|
2016
2249
|
/** @experimental */
|
|
2250
|
+
limitPrediction: {
|
|
2251
|
+
/**
|
|
2252
|
+
* 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.
|
|
2253
|
+
*
|
|
2254
|
+
* @param params Parameters for predicting an AI-credit session limit. Omitting `modelId` uses the session's currently selected model.
|
|
2255
|
+
*
|
|
2256
|
+
* @returns Prediction result. Available results include prediction details; unavailable results include an explicit reason.
|
|
2257
|
+
*/
|
|
2258
|
+
predict: async (params) => connection.sendRequest("session.limitPrediction.predict", { sessionId, ...params })
|
|
2259
|
+
},
|
|
2260
|
+
/** @experimental */
|
|
2017
2261
|
remote: {
|
|
2018
2262
|
/**
|
|
2019
2263
|
* Enables remote session export or steering.
|
|
@@ -2074,6 +2318,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2074
2318
|
}
|
|
2075
2319
|
function createInternalSessionRpc(connection, sessionId) {
|
|
2076
2320
|
return {
|
|
2321
|
+
/**
|
|
2322
|
+
* Queues or sends an internal system notification to the session according to its passive policy.
|
|
2323
|
+
*
|
|
2324
|
+
* @param params Internal request for sending a system notification.
|
|
2325
|
+
*
|
|
2326
|
+
* @experimental
|
|
2327
|
+
*/
|
|
2328
|
+
sendSystemNotification: async (params) => connection.sendRequest("session.sendSystemNotification", { sessionId, ...params }),
|
|
2077
2329
|
/** @experimental */
|
|
2078
2330
|
mcp: {
|
|
2079
2331
|
/**
|
|
@@ -2121,6 +2373,114 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
2121
2373
|
* @returns Result of evaluating a Rust-owned settings predicate.
|
|
2122
2374
|
*/
|
|
2123
2375
|
evaluatePredicate: async (params) => connection.sendRequest("session.settings.evaluatePredicate", { sessionId, ...params })
|
|
2376
|
+
},
|
|
2377
|
+
/** @experimental */
|
|
2378
|
+
queue: {
|
|
2379
|
+
/**
|
|
2380
|
+
* Returns the internal native queue snapshot for in-process session orchestration.
|
|
2381
|
+
*
|
|
2382
|
+
* @returns Internal snapshot of native queue state for local session orchestration.
|
|
2383
|
+
*/
|
|
2384
|
+
snapshot: async () => connection.sendRequest("session.queue.snapshot", { sessionId }),
|
|
2385
|
+
/**
|
|
2386
|
+
* Reports whether the local session has native queued work pending.
|
|
2387
|
+
*
|
|
2388
|
+
* @returns Whether the native queue has pending work.
|
|
2389
|
+
*/
|
|
2390
|
+
hasPending: async () => connection.sendRequest("session.queue.hasPending", { sessionId }),
|
|
2391
|
+
/**
|
|
2392
|
+
* Begins a native deferred-idle drain when background work has quiesced.
|
|
2393
|
+
*
|
|
2394
|
+
* @param params Inputs for starting a deferred-idle drain.
|
|
2395
|
+
*
|
|
2396
|
+
* @returns Whether a deferred-idle drain should run.
|
|
2397
|
+
*/
|
|
2398
|
+
beginDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.beginDeferredIdleDrain", { sessionId, ...params }),
|
|
2399
|
+
/**
|
|
2400
|
+
* Finishes a native deferred-idle drain and reports whether to drain queue work or emit idle.
|
|
2401
|
+
*
|
|
2402
|
+
* @param params Inputs for completing a deferred-idle drain.
|
|
2403
|
+
*
|
|
2404
|
+
* @returns Action selected by the native deferred-idle drain.
|
|
2405
|
+
*/
|
|
2406
|
+
finishDeferredIdleDrain: async (params) => connection.sendRequest("session.queue.finishDeferredIdleDrain", { sessionId, ...params }),
|
|
2407
|
+
/**
|
|
2408
|
+
* Marks session.idle as deferred by native background work state.
|
|
2409
|
+
*
|
|
2410
|
+
* @param params Inputs for marking session.idle deferred in native state.
|
|
2411
|
+
*/
|
|
2412
|
+
deferSessionIdle: async (params) => connection.sendRequest("session.queue.deferSessionIdle", { sessionId, ...params }),
|
|
2413
|
+
/**
|
|
2414
|
+
* Consumes queued native system notifications matching an internal filter.
|
|
2415
|
+
*
|
|
2416
|
+
* @param params Internal filter for consuming queued system notifications.
|
|
2417
|
+
*
|
|
2418
|
+
* @returns Indicates whether a user-facing pending item was removed.
|
|
2419
|
+
*/
|
|
2420
|
+
consumeSystemNotifications: async (params) => connection.sendRequest("session.queue.consumeSystemNotifications", { sessionId, ...params }),
|
|
2421
|
+
/**
|
|
2422
|
+
* Enqueues the internal resume-pending wake item when orphan handling needs a follow-up turn.
|
|
2423
|
+
*
|
|
2424
|
+
* @returns Result of enqueueing the resume-pending wake item.
|
|
2425
|
+
*/
|
|
2426
|
+
enqueueResumePending: async () => connection.sendRequest("session.queue.enqueueResumePending", { sessionId }),
|
|
2427
|
+
/**
|
|
2428
|
+
* Drains the native local-session work queue for in-process session orchestration.
|
|
2429
|
+
*/
|
|
2430
|
+
process: async () => connection.sendRequest("session.queue.process", { sessionId })
|
|
2431
|
+
},
|
|
2432
|
+
/** @experimental */
|
|
2433
|
+
schedule: {
|
|
2434
|
+
/**
|
|
2435
|
+
* Hydrates the native schedule registry from persisted session events.
|
|
2436
|
+
*/
|
|
2437
|
+
hydrate: async () => connection.sendRequest("session.schedule.hydrate", { sessionId }),
|
|
2438
|
+
/**
|
|
2439
|
+
* Reports whether the session has an active self-paced scheduled prompt.
|
|
2440
|
+
*
|
|
2441
|
+
* @returns Whether the session currently has an active self-paced schedule.
|
|
2442
|
+
*/
|
|
2443
|
+
hasSelfPaced: async () => connection.sendRequest("session.schedule.hasSelfPaced", { sessionId }),
|
|
2444
|
+
/**
|
|
2445
|
+
* Registers a relative-interval scheduled prompt.
|
|
2446
|
+
*
|
|
2447
|
+
* @param params Register a relative-interval scheduled prompt.
|
|
2448
|
+
*
|
|
2449
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2450
|
+
*/
|
|
2451
|
+
add: async (params) => connection.sendRequest("session.schedule.add", { sessionId, ...params }),
|
|
2452
|
+
/**
|
|
2453
|
+
* Registers a recurring cron scheduled prompt.
|
|
2454
|
+
*
|
|
2455
|
+
* @param params Register a cron scheduled prompt.
|
|
2456
|
+
*
|
|
2457
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2458
|
+
*/
|
|
2459
|
+
addCron: async (params) => connection.sendRequest("session.schedule.addCron", { sessionId, ...params }),
|
|
2460
|
+
/**
|
|
2461
|
+
* Registers an absolute-time scheduled prompt.
|
|
2462
|
+
*
|
|
2463
|
+
* @param params Register an absolute-time scheduled prompt.
|
|
2464
|
+
*
|
|
2465
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2466
|
+
*/
|
|
2467
|
+
addAt: async (params) => connection.sendRequest("session.schedule.addAt", { sessionId, ...params }),
|
|
2468
|
+
/**
|
|
2469
|
+
* Registers a self-paced scheduled prompt.
|
|
2470
|
+
*
|
|
2471
|
+
* @param params Register a self-paced scheduled prompt.
|
|
2472
|
+
*
|
|
2473
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2474
|
+
*/
|
|
2475
|
+
addSelfPaced: async (params) => connection.sendRequest("session.schedule.addSelfPaced", { sessionId, ...params }),
|
|
2476
|
+
/**
|
|
2477
|
+
* Re-arms an active self-paced scheduled prompt.
|
|
2478
|
+
*
|
|
2479
|
+
* @param params Re-arm a self-paced scheduled prompt.
|
|
2480
|
+
*
|
|
2481
|
+
* @returns Result of registering or re-arming a scheduled prompt.
|
|
2482
|
+
*/
|
|
2483
|
+
rearmSelfPaced: async (params) => connection.sendRequest("session.schedule.rearmSelfPaced", { sessionId, ...params })
|
|
2124
2484
|
}
|
|
2125
2485
|
};
|
|
2126
2486
|
}
|
|
@@ -2195,6 +2555,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
2195
2555
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
2196
2556
|
return handler.sqliteQuery(params);
|
|
2197
2557
|
});
|
|
2558
|
+
connection.onRequest("sessionFs.sqliteTransaction", async (params) => {
|
|
2559
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
2560
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
2561
|
+
return handler.sqliteTransaction(params);
|
|
2562
|
+
});
|
|
2198
2563
|
connection.onRequest("sessionFs.sqliteExists", async (params) => {
|
|
2199
2564
|
const handler = getHandlers(params.sessionId).sessionFs;
|
|
2200
2565
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
package/dist/cjs/index.js
CHANGED
|
@@ -27,20 +27,25 @@ __export(index_exports, {
|
|
|
27
27
|
CopilotWebSocketCloseStatus: () => import_types2.CopilotWebSocketCloseStatus,
|
|
28
28
|
CopilotWebSocketForwarder: () => import_types2.CopilotWebSocketForwarder,
|
|
29
29
|
CopilotWebSocketHandler: () => import_types2.CopilotWebSocketHandler,
|
|
30
|
+
FactoryResumeError: () => import_factory.FactoryResumeError,
|
|
30
31
|
RuntimeConnection: () => import_types.RuntimeConnection,
|
|
31
32
|
SYSTEM_MESSAGE_SECTIONS: () => import_types2.SYSTEM_MESSAGE_SECTIONS,
|
|
33
|
+
SessionFsSqliteTransactionFailure: () => import_types2.SessionFsSqliteTransactionFailure,
|
|
32
34
|
ToolSet: () => import_toolSet.ToolSet,
|
|
33
35
|
approveAll: () => import_types2.approveAll,
|
|
34
36
|
convertMcpCallToolResult: () => import_types2.convertMcpCallToolResult,
|
|
35
37
|
createCanvas: () => import_canvas.createCanvas,
|
|
36
38
|
createSessionFsAdapter: () => import_types2.createSessionFsAdapter,
|
|
37
|
-
|
|
39
|
+
defineFactory: () => import_factory.defineFactory,
|
|
40
|
+
defineTool: () => import_types2.defineTool,
|
|
41
|
+
isFactoryRunTerminal: () => import_factory.isFactoryRunTerminal
|
|
38
42
|
});
|
|
39
43
|
module.exports = __toCommonJS(index_exports);
|
|
40
44
|
var import_client = require("./client.js");
|
|
41
45
|
var import_types = require("./types.js");
|
|
42
46
|
var import_toolSet = require("./toolSet.js");
|
|
43
47
|
var import_session = require("./session.js");
|
|
48
|
+
var import_factory = require("./factory.js");
|
|
44
49
|
var import_canvas = require("./canvas.js");
|
|
45
50
|
var import_types2 = require("./types.js");
|
|
46
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -54,12 +59,16 @@ var import_types2 = require("./types.js");
|
|
|
54
59
|
CopilotWebSocketCloseStatus,
|
|
55
60
|
CopilotWebSocketForwarder,
|
|
56
61
|
CopilotWebSocketHandler,
|
|
62
|
+
FactoryResumeError,
|
|
57
63
|
RuntimeConnection,
|
|
58
64
|
SYSTEM_MESSAGE_SECTIONS,
|
|
65
|
+
SessionFsSqliteTransactionFailure,
|
|
59
66
|
ToolSet,
|
|
60
67
|
approveAll,
|
|
61
68
|
convertMcpCallToolResult,
|
|
62
69
|
createCanvas,
|
|
63
70
|
createSessionFsAdapter,
|
|
64
|
-
|
|
71
|
+
defineFactory,
|
|
72
|
+
defineTool,
|
|
73
|
+
isFactoryRunTerminal
|
|
65
74
|
});
|