@github/copilot-sdk 1.0.15 → 1.0.16
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 +136 -0
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +319 -8
- package/dist/cjs/generated/rpc.js +116 -2
- package/dist/cjs/host.js +61 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +27 -1
- package/dist/client.js +316 -5
- package/dist/generated/rpc.d.ts +997 -14
- package/dist/generated/rpc.js +116 -2
- package/dist/generated/session-events.d.ts +81 -1
- package/dist/host.d.ts +86 -0
- package/dist/host.js +37 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -0
- package/dist/types.d.ts +3 -0
- package/package.json +11 -10
package/dist/generated/rpc.js
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
function createServerRpc(connection) {
|
|
2
2
|
return {
|
|
3
|
+
/** @experimental */
|
|
4
|
+
environments: {
|
|
5
|
+
/**
|
|
6
|
+
* Lists GitHub Mission Control environments visible to the authenticated identity. Does not require a running host and excludes host relay credentials.
|
|
7
|
+
*
|
|
8
|
+
* @param params Optional discovery filters supported by GitHub Mission Control.
|
|
9
|
+
*
|
|
10
|
+
* @returns Environments visible to the authenticated caller and matching the supplied filters.
|
|
11
|
+
*/
|
|
12
|
+
list: async (params) => connection.sendRequest("environments.list", params),
|
|
13
|
+
/**
|
|
14
|
+
* Gets safe discovery information for a GitHub Mission Control environment without requiring a running host.
|
|
15
|
+
*
|
|
16
|
+
* @param params Identify a Mission Control environment to retrieve.
|
|
17
|
+
*
|
|
18
|
+
* @returns Safe discovery information for the requested environment.
|
|
19
|
+
*/
|
|
20
|
+
get: async (params) => connection.sendRequest("environments.get", params),
|
|
21
|
+
/**
|
|
22
|
+
* Deletes a user-managed GitHub Mission Control environment. GitHub-managed environments cannot be deleted. Does not stop a running host, which may register again.
|
|
23
|
+
*
|
|
24
|
+
* @param params Identify a user-managed Mission Control environment to delete.
|
|
25
|
+
*
|
|
26
|
+
* @returns Acknowledgement that the requested environment was deleted.
|
|
27
|
+
*/
|
|
28
|
+
delete: async (params) => connection.sendRequest("environments.delete", params)
|
|
29
|
+
},
|
|
30
|
+
/** @experimental */
|
|
31
|
+
host: {
|
|
32
|
+
/**
|
|
33
|
+
* Publishes an attached resident session for this listener's lifetime without copying it.
|
|
34
|
+
*
|
|
35
|
+
* @param params Publishes a resident session attached to the listener's owning connection.
|
|
36
|
+
*
|
|
37
|
+
* @returns The existing runtime identity and its resource on the listener.
|
|
38
|
+
*/
|
|
39
|
+
publishSession: async (params) => connection.sendRequest("host.publishSession", params),
|
|
40
|
+
/**
|
|
41
|
+
* Starts a connection-owned AHP host with explicit localServer and/or githubEnvironment transports as a supervised SDK participant.
|
|
42
|
+
*
|
|
43
|
+
* @param params Starts a supervised AHP host with at least one explicitly selected transport.
|
|
44
|
+
*
|
|
45
|
+
* @returns Listener readiness, returned only after binding and the supervised participant's SDK handshake.
|
|
46
|
+
*/
|
|
47
|
+
start: async (params) => connection.sendRequest("host.start", params),
|
|
48
|
+
/**
|
|
49
|
+
* Stops a listener owned by this SDK connection and joins its cleanup without deleting sessions.
|
|
50
|
+
*
|
|
51
|
+
* @param params Stops a connection-owned listener and joins its teardown.
|
|
52
|
+
*
|
|
53
|
+
* @returns Empty acknowledgement for a completed host lifecycle operation.
|
|
54
|
+
*/
|
|
55
|
+
dispose: async (params) => connection.sendRequest("host.dispose", params)
|
|
56
|
+
},
|
|
3
57
|
/**
|
|
4
58
|
* Checks server responsiveness and returns protocol information.
|
|
5
59
|
*
|
|
@@ -832,6 +886,45 @@ function createServerRpc(connection) {
|
|
|
832
886
|
}
|
|
833
887
|
function createInternalServerRpc(connection) {
|
|
834
888
|
return {
|
|
889
|
+
/** @experimental */
|
|
890
|
+
host: {
|
|
891
|
+
/**
|
|
892
|
+
* Requests app-owned materialization over the owning SDK participant.
|
|
893
|
+
*
|
|
894
|
+
* @param params One application-owned session handoff, requested by the supervised hosting participant.
|
|
895
|
+
*
|
|
896
|
+
* @returns The resident session the application has materialized on its own connection.
|
|
897
|
+
*/
|
|
898
|
+
createSession: async (params) => connection.sendRequest("host.createSession", params),
|
|
899
|
+
/**
|
|
900
|
+
* Releases app ownership retention after AHP detaches.
|
|
901
|
+
*
|
|
902
|
+
* @param params Ends one participation, not the application's session lifetime.
|
|
903
|
+
*
|
|
904
|
+
* @returns Empty acknowledgement for a completed host lifecycle operation.
|
|
905
|
+
*/
|
|
906
|
+
releaseSession: async (params) => connection.sendRequest("host.releaseSession", params),
|
|
907
|
+
/**
|
|
908
|
+
* Resolves current authenticated credentials and remote-control policy only for the runtime-owned Mission Control hosting participant.
|
|
909
|
+
*
|
|
910
|
+
* @returns Private credentials delivered only to a runtime-owned Mission Control hosting participant.
|
|
911
|
+
*/
|
|
912
|
+
getEnvironmentCredentials: async () => connection.sendRequest("host.getEnvironmentCredentials", {}),
|
|
913
|
+
/**
|
|
914
|
+
* Returns listener settings only to the supervised hosting participant over its SDK connection.
|
|
915
|
+
*
|
|
916
|
+
* @returns Normalized listener settings delivered only to the supervised hosting participant.
|
|
917
|
+
*/
|
|
918
|
+
getConfiguration: async () => connection.sendRequest("host.getConfiguration", {}),
|
|
919
|
+
/**
|
|
920
|
+
* Reports a supervised hosting participant's bound AHP endpoint after its SDK handshake.
|
|
921
|
+
*
|
|
922
|
+
* @param params Readiness reported by the supervised hosting participant on its own SDK connection.
|
|
923
|
+
*
|
|
924
|
+
* @returns Empty acknowledgement for a completed host lifecycle operation.
|
|
925
|
+
*/
|
|
926
|
+
ready: async (params) => connection.sendRequest("host.ready", params)
|
|
927
|
+
},
|
|
835
928
|
/**
|
|
836
929
|
* Performs the SDK server connection handshake and validates the optional connection token. Marked internal because this is JSON-RPC transport plumbing invoked automatically by an SDK client's own `connect()` wrapper, not a user-facing method. Stays internal as long as the SDK client owns the handshake; would only become public if the SDK ever exposed the raw schema surface to consumers without a connection wrapper.
|
|
837
930
|
*
|
|
@@ -953,7 +1046,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
953
1046
|
*
|
|
954
1047
|
* @returns Result of attempting to disable sandboxing for the current session.
|
|
955
1048
|
*/
|
|
956
|
-
disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params })
|
|
1049
|
+
disableForSession: async (params) => connection.sendRequest("session.sandbox.disableForSession", { sessionId, ...params }),
|
|
1050
|
+
/**
|
|
1051
|
+
* 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.
|
|
1052
|
+
*
|
|
1053
|
+
* @param params Request to accept the sandbox path grant offered on an active sandbox escalation permission prompt.
|
|
1054
|
+
*
|
|
1055
|
+
* @returns Result of accepting a sandbox path grant.
|
|
1056
|
+
*/
|
|
1057
|
+
grantPathForRequest: async (params) => connection.sendRequest("session.sandbox.grantPathForRequest", { sessionId, ...params })
|
|
957
1058
|
},
|
|
958
1059
|
/**
|
|
959
1060
|
* Aborts the current agent turn.
|
|
@@ -2161,7 +2262,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2161
2262
|
*
|
|
2162
2263
|
* @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
|
|
2163
2264
|
*/
|
|
2164
|
-
sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params })
|
|
2265
|
+
sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params }),
|
|
2266
|
+
/**
|
|
2267
|
+
* 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.
|
|
2268
|
+
*
|
|
2269
|
+
* @param params Host-managed model selection ids to withdraw from the session's BYOK registry.
|
|
2270
|
+
*
|
|
2271
|
+
* @returns What the withdrawal actually removed from the registry.
|
|
2272
|
+
*/
|
|
2273
|
+
withdraw: async (params) => connection.sendRequest("session.provider.withdraw", { sessionId, ...params })
|
|
2165
2274
|
},
|
|
2166
2275
|
/** @experimental */
|
|
2167
2276
|
options: {
|
|
@@ -3414,6 +3523,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
3414
3523
|
});
|
|
3415
3524
|
}
|
|
3416
3525
|
function registerClientGlobalApiHandlers(connection, handlers) {
|
|
3526
|
+
connection.onNotification("host.exited", async (params) => {
|
|
3527
|
+
const handler = handlers.host;
|
|
3528
|
+
if (!handler) return;
|
|
3529
|
+
await handler.exited(params);
|
|
3530
|
+
});
|
|
3417
3531
|
connection.onRequest("extensionLaunchProvider.resolve", async (params) => {
|
|
3418
3532
|
const handler = handlers.extensionLaunchProvider;
|
|
3419
3533
|
if (!handler) throw new Error("No extensionLaunchProvider client-global handler registered");
|
|
@@ -930,6 +930,14 @@ export type SystemNotificationWorkflowCompletedStatus =
|
|
|
930
930
|
* Details of the permission being requested
|
|
931
931
|
*/
|
|
932
932
|
export type PermissionRequest = PermissionRequestShell | PermissionRequestWrite | PermissionRequestRead | PermissionRequestMcp | PermissionRequestUrl | PermissionRequestMemory | PermissionRequestCustomTool | PermissionRequestHook | PermissionRequestExtensionManagement | PermissionRequestWorkflow | PermissionRequestExtensionPermissionAccess | PermissionRequestExtensionEnvAccess;
|
|
933
|
+
/**
|
|
934
|
+
* Access a sandbox path grant confers
|
|
935
|
+
*/
|
|
936
|
+
export type PermissionSandboxPathGrantAccess =
|
|
937
|
+
/** Read access: the path is added to readonlyPaths. */
|
|
938
|
+
"read"
|
|
939
|
+
/** Read and write access: the path is added to readwritePaths. */
|
|
940
|
+
| "readWrite";
|
|
933
941
|
/**
|
|
934
942
|
* Advisory recommendation the runtime attaches to a permission request whose origin it can vouch for by construction. Unlike the auto-approval judge this does not depend on auto mode and does not evaluate what the tool call does; its absence simply means the runtime has no opinion and the request follows the host's normal approval flow.
|
|
935
943
|
*/
|
|
@@ -1028,7 +1036,7 @@ export type PermissionDecisionSource =
|
|
|
1028
1036
|
/**
|
|
1029
1037
|
* The result of the permission request
|
|
1030
1038
|
*/
|
|
1031
|
-
export type PermissionResult = PermissionApproved | PermissionApprovedForSession | PermissionApprovedForLocation | PermissionCancelled | PermissionDeniedByRules | PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser | PermissionDeniedInteractivelyByUser | PermissionDeniedByContentExclusionPolicy | PermissionDeniedByPermissionRequestHook;
|
|
1039
|
+
export type PermissionResult = PermissionApproved | PermissionApprovedReadOnlyForSession | PermissionApprovedForSession | PermissionApprovedForLocation | PermissionCancelled | PermissionDeniedByRules | PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser | PermissionDeniedInteractivelyByUser | PermissionDeniedByContentExclusionPolicy | PermissionDeniedByPermissionRequestHook;
|
|
1032
1040
|
/**
|
|
1033
1041
|
* The approval to add as a session-scoped rule
|
|
1034
1042
|
*/
|
|
@@ -8274,6 +8282,12 @@ export interface PermissionRequestShell {
|
|
|
8274
8282
|
* @experimental
|
|
8275
8283
|
*/
|
|
8276
8284
|
resolvedWorkingDirectory?: string;
|
|
8285
|
+
/**
|
|
8286
|
+
* Sandbox policy edit that would let the command run inside the sandbox. Only present when requestSandboxBypass is true.
|
|
8287
|
+
*
|
|
8288
|
+
* @experimental
|
|
8289
|
+
*/
|
|
8290
|
+
sandboxPathGrant?: PermissionSandboxPathGrant;
|
|
8277
8291
|
/**
|
|
8278
8292
|
* Tool call ID that triggered this permission request
|
|
8279
8293
|
*/
|
|
@@ -8318,6 +8332,25 @@ export interface PermissionRequestShellPossibleUrl {
|
|
|
8318
8332
|
*/
|
|
8319
8333
|
url: string;
|
|
8320
8334
|
}
|
|
8335
|
+
/**
|
|
8336
|
+
* A sandbox filesystem policy edit that would let a blocked operation run inside the sandbox instead of outside it. Offered only on a sandbox escalation request whose denial adding this path lifts, and only when managed policy permits the grant. A host accepts it with session.sandbox.grantPathForRequest, which adds the path to the session's sandbox policy and re-runs the operation sandboxed; a host that persists sandbox settings may also save the path there.
|
|
8337
|
+
*/
|
|
8338
|
+
/** @experimental */
|
|
8339
|
+
export interface PermissionSandboxPathGrant {
|
|
8340
|
+
access: PermissionSandboxPathGrantAccess;
|
|
8341
|
+
/**
|
|
8342
|
+
* The path the sandbox refused, present only when it differs from path. That happens when a write under a read-only folder moves the folder to the read-write paths, when a path that does not exist yet is granted through its nearest existing folder, because the OS sandbox cannot grant a path before it exists, and when either is spelled through a symlink, because a grant covers its path as written, so path is then the resolved location. Hosts should then name path in the offer, since the denial names this one.
|
|
8343
|
+
*/
|
|
8344
|
+
deniedPath?: string;
|
|
8345
|
+
/**
|
|
8346
|
+
* Absolute path to add to the sandbox filesystem policy
|
|
8347
|
+
*/
|
|
8348
|
+
path: string;
|
|
8349
|
+
/**
|
|
8350
|
+
* readonlyPaths entries the grant removes, exactly as written in the policy, because a read-only entry for the same location would otherwise keep the path read-only. A host that persists the path must remove these entries from its stored readonlyPaths too.
|
|
8351
|
+
*/
|
|
8352
|
+
removedReadonlyPaths?: string[];
|
|
8353
|
+
}
|
|
8321
8354
|
/**
|
|
8322
8355
|
* File write permission request
|
|
8323
8356
|
*/
|
|
@@ -8364,6 +8397,12 @@ export interface PermissionRequestWrite {
|
|
|
8364
8397
|
* @experimental
|
|
8365
8398
|
*/
|
|
8366
8399
|
resolvedPath?: string;
|
|
8400
|
+
/**
|
|
8401
|
+
* Sandbox policy edit that would let the write run inside the sandbox. Only present when requestSandboxBypass is true.
|
|
8402
|
+
*
|
|
8403
|
+
* @experimental
|
|
8404
|
+
*/
|
|
8405
|
+
sandboxPathGrant?: PermissionSandboxPathGrant;
|
|
8367
8406
|
/**
|
|
8368
8407
|
* Tool call ID that triggered this permission request
|
|
8369
8408
|
*/
|
|
@@ -8403,6 +8442,12 @@ export interface PermissionRequestRead {
|
|
|
8403
8442
|
* @experimental
|
|
8404
8443
|
*/
|
|
8405
8444
|
resolvedPath?: string;
|
|
8445
|
+
/**
|
|
8446
|
+
* Sandbox policy edit that would let the read run inside the sandbox. Only present when requestSandboxBypass is true.
|
|
8447
|
+
*
|
|
8448
|
+
* @experimental
|
|
8449
|
+
*/
|
|
8450
|
+
sandboxPathGrant?: PermissionSandboxPathGrant;
|
|
8406
8451
|
/**
|
|
8407
8452
|
* Tool call ID that triggered this permission request
|
|
8408
8453
|
*/
|
|
@@ -8880,6 +8925,12 @@ export interface PermissionPromptRequestCommands {
|
|
|
8880
8925
|
* True when the escalation is a permissive retry that keeps the sandbox and network policy attached while recording file and process accesses instead of blocking them.
|
|
8881
8926
|
*/
|
|
8882
8927
|
requestSandboxPermissive?: boolean;
|
|
8928
|
+
/**
|
|
8929
|
+
* Sandbox policy edit that would let the command run inside the sandbox. Only present when requestSandboxBypass is true.
|
|
8930
|
+
*
|
|
8931
|
+
* @experimental
|
|
8932
|
+
*/
|
|
8933
|
+
sandboxPathGrant?: PermissionSandboxPathGrant;
|
|
8883
8934
|
/**
|
|
8884
8935
|
* Tool call ID that triggered this permission request
|
|
8885
8936
|
*/
|
|
@@ -9150,6 +9201,12 @@ export interface PermissionPromptRequestPath {
|
|
|
9150
9201
|
* File paths that require explicit approval
|
|
9151
9202
|
*/
|
|
9152
9203
|
paths: string[];
|
|
9204
|
+
/**
|
|
9205
|
+
* Canonical directory candidates that can be granted for file-tool read access in this logical session. Present only for read path prompts.
|
|
9206
|
+
*
|
|
9207
|
+
* @experimental
|
|
9208
|
+
*/
|
|
9209
|
+
readOnlyDirectories?: string[];
|
|
9153
9210
|
/**
|
|
9154
9211
|
* Tool call ID that triggered this permission request
|
|
9155
9212
|
*/
|
|
@@ -9413,6 +9470,21 @@ export interface PermissionApproved {
|
|
|
9413
9470
|
*/
|
|
9414
9471
|
managedApprovalHandled?: boolean;
|
|
9415
9472
|
}
|
|
9473
|
+
/**
|
|
9474
|
+
* Permission response variant that approves a request and records file-tool read authority for specific directories in this logical session.
|
|
9475
|
+
*/
|
|
9476
|
+
export interface PermissionApprovedReadOnlyForSession {
|
|
9477
|
+
/**
|
|
9478
|
+
* Canonical directories covered by the session read-only grant
|
|
9479
|
+
*
|
|
9480
|
+
* @minItems 1
|
|
9481
|
+
*/
|
|
9482
|
+
directories: [string, ...string[]];
|
|
9483
|
+
/**
|
|
9484
|
+
* Approved with read-only directory authority for this session
|
|
9485
|
+
*/
|
|
9486
|
+
kind: "approved-read-only-for-session";
|
|
9487
|
+
}
|
|
9416
9488
|
/**
|
|
9417
9489
|
* Permission response variant that approves a request and remembers the provided approval for the rest of the session.
|
|
9418
9490
|
*/
|
|
@@ -12084,10 +12156,18 @@ export interface McpServerStatusChangedEvent {
|
|
|
12084
12156
|
* Payload of `session.mcp_server_status_changed` for one MCP server's status and optional failure error.
|
|
12085
12157
|
*/
|
|
12086
12158
|
export interface McpServerStatusChangedData {
|
|
12159
|
+
/**
|
|
12160
|
+
* Runtime configuration provenance for a failed connection, or unknown when unavailable. Additional string values may be introduced.
|
|
12161
|
+
*/
|
|
12162
|
+
configSource?: string;
|
|
12087
12163
|
/**
|
|
12088
12164
|
* Error message if the server entered a failed state
|
|
12089
12165
|
*/
|
|
12090
12166
|
error?: string;
|
|
12167
|
+
/**
|
|
12168
|
+
* Runtime-produced classification for the final failed connection; unclassified means no classification was supplied. Additional string values may be introduced.
|
|
12169
|
+
*/
|
|
12170
|
+
errorClassification?: string;
|
|
12091
12171
|
/**
|
|
12092
12172
|
* Name of the MCP server whose status changed
|
|
12093
12173
|
*/
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { HostExitedNotification, HostPublishSessionResult, HostLocalServerOptions, HostGitHubEnvironmentOptions } from "./generated/rpc.js";
|
|
2
|
+
import type { CopilotSession } from "./session.js";
|
|
3
|
+
import type { SessionConfig, ResumeSessionConfig } from "./types.js";
|
|
4
|
+
/** Host-selected defaults for a fresh application-owned session. @experimental */
|
|
5
|
+
export interface AhpSessionCreateRequest {
|
|
6
|
+
/** Pass these settings to createSession, adding your prompt, tools and callbacks. */
|
|
7
|
+
config: Omit<SessionConfig, "onPermissionRequest">;
|
|
8
|
+
/** Aborted when participation ends, including timeout or owner disconnection. */
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/** Host-selected settings for resuming a durable application-owned AHP session. @experimental */
|
|
12
|
+
export interface AhpSessionResumeRequest {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
/** Pass to resumeSession, adding application tools, hooks and callbacks. */
|
|
15
|
+
config: Omit<ResumeSessionConfig, "onPermissionRequest">;
|
|
16
|
+
/** Aborted when participation ends; late results are still released exactly once. */
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A listener-task exit report, or an owner disconnect that cannot acknowledge cleanup.
|
|
21
|
+
* `reason: "exited"` means the hosting task failed, not that the runtime process died.
|
|
22
|
+
* In-process hosts have no process exit code (`exitCode` is absent).
|
|
23
|
+
* @experimental
|
|
24
|
+
*/
|
|
25
|
+
export type AhpHostExit = HostExitedNotification;
|
|
26
|
+
/**
|
|
27
|
+
* Options for runtime-supervised AHP hosting. Select at least one transport.
|
|
28
|
+
* Callbacks are captured at startup;
|
|
29
|
+
* later changes to this options object do not reconfigure an existing host.
|
|
30
|
+
* @experimental
|
|
31
|
+
*/
|
|
32
|
+
export interface AhpHostOptions {
|
|
33
|
+
/** Enable a local WebSocket listener; an empty object selects loopback defaults. */
|
|
34
|
+
localServer?: HostLocalServerOptions;
|
|
35
|
+
/** Register a Mission Control environment and enable remote WPS connections. */
|
|
36
|
+
githubEnvironment?: HostGitHubEnvironmentOptions;
|
|
37
|
+
/** Called at most once when hosting ends, not on runtime process death. Local, never serialized. */
|
|
38
|
+
onExit?: (exit: AhpHostExit) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Materialize a fresh session on this client. Preserve the supplied config
|
|
41
|
+
* (including its sessionId and workingDirectory); add your own prompt and tools.
|
|
42
|
+
* The callback and all tool/hook functions stay in the application.
|
|
43
|
+
*/
|
|
44
|
+
createSession?: (request: AhpSessionCreateRequest) => Promise<CopilotSession>;
|
|
45
|
+
/**
|
|
46
|
+
* Resume a durable session previously created by an application factory.
|
|
47
|
+
* Return the original object from this client's resumeSession, or an existing
|
|
48
|
+
* attached original without reconfiguring it. Published resident sessions
|
|
49
|
+
* attach directly and never invoke this callback.
|
|
50
|
+
*/
|
|
51
|
+
resumeSession?: (request: AhpSessionResumeRequest) => Promise<CopilotSession>;
|
|
52
|
+
/**
|
|
53
|
+
* Called once per handoff with the original returned object after AHP detaches
|
|
54
|
+
* or the handoff fails. The SDK never disconnects or destroys this object.
|
|
55
|
+
*/
|
|
56
|
+
onSessionReleased?: (session: CopilotSession) => void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A connection-owned AHP listener supervised by the runtime.
|
|
60
|
+
*
|
|
61
|
+
* The runtime hosts the listener in-process, without a companion executable. Disconnecting
|
|
62
|
+
* the owning client also stops the host; reconnecting does not reclaim it.
|
|
63
|
+
* Stopping a host does not delete its underlying sessions.
|
|
64
|
+
* Its durable AHP catalog is shared by successive hosts in the runtime's
|
|
65
|
+
* effective Copilot home; a concurrent host for that catalog is rejected.
|
|
66
|
+
*
|
|
67
|
+
* @experimental
|
|
68
|
+
*/
|
|
69
|
+
export declare class AhpHost {
|
|
70
|
+
private readonly disposeHost;
|
|
71
|
+
private readonly publishHostSession;
|
|
72
|
+
readonly hostId: string;
|
|
73
|
+
/** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
|
|
74
|
+
readonly url: string | undefined;
|
|
75
|
+
/** Mission Control environment ID, when GitHub hosting is enabled. */
|
|
76
|
+
readonly environmentId: string | undefined;
|
|
77
|
+
/** Connection token, when required by the listener. Treat this value as a secret. */
|
|
78
|
+
readonly token: string | undefined;
|
|
79
|
+
/** Legacy separate host process ID. Absent for in-process listeners; use dispose() to stop. */
|
|
80
|
+
readonly pid: number | undefined;
|
|
81
|
+
/** Ask the runtime to stop the listener and await its cleanup, on every call. */
|
|
82
|
+
dispose(): Promise<void>;
|
|
83
|
+
/** Publish an existing session attached to this client, until this listener stops. */
|
|
84
|
+
publishSession(sessionId: string): Promise<HostPublishSessionResult>;
|
|
85
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
86
|
+
}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class AhpHost {
|
|
2
|
+
/** @internal */
|
|
3
|
+
constructor(info, disposeHost, publishHostSession) {
|
|
4
|
+
this.disposeHost = disposeHost;
|
|
5
|
+
this.publishHostSession = publishHostSession;
|
|
6
|
+
this.hostId = info.hostId;
|
|
7
|
+
this.url = info.url;
|
|
8
|
+
this.environmentId = info.environmentId;
|
|
9
|
+
this.token = info.token;
|
|
10
|
+
this.pid = info.pid;
|
|
11
|
+
}
|
|
12
|
+
disposeHost;
|
|
13
|
+
publishHostSession;
|
|
14
|
+
hostId;
|
|
15
|
+
/** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
|
|
16
|
+
url;
|
|
17
|
+
/** Mission Control environment ID, when GitHub hosting is enabled. */
|
|
18
|
+
environmentId;
|
|
19
|
+
/** Connection token, when required by the listener. Treat this value as a secret. */
|
|
20
|
+
token;
|
|
21
|
+
/** Legacy separate host process ID. Absent for in-process listeners; use dispose() to stop. */
|
|
22
|
+
pid;
|
|
23
|
+
/** Ask the runtime to stop the listener and await its cleanup, on every call. */
|
|
24
|
+
dispose() {
|
|
25
|
+
return this.disposeHost();
|
|
26
|
+
}
|
|
27
|
+
/** Publish an existing session attached to this client, until this listener stops. */
|
|
28
|
+
publishSession(sessionId) {
|
|
29
|
+
return this.publishHostSession(sessionId);
|
|
30
|
+
}
|
|
31
|
+
async [Symbol.asyncDispose]() {
|
|
32
|
+
await this.dispose();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
AhpHost
|
|
37
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* JSON-RPC based SDK for programmatic control of GitHub Copilot CLI
|
|
5
5
|
*/
|
|
6
6
|
export { CopilotClient } from "./client.js";
|
|
7
|
+
export type { HostLocalServerOptions, HostGitHubEnvironmentOptions } from "./generated/rpc.js";
|
|
8
|
+
export { AhpHost, type AhpHostExit, type AhpHostOptions, type AhpSessionCreateRequest, type AhpSessionResumeRequest, } from "./host.js";
|
|
7
9
|
export { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
|
|
8
10
|
export { BuiltInTools, ToolSet } from "./toolSet.js";
|
|
9
11
|
export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
@@ -11,5 +13,5 @@ export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./wo
|
|
|
11
13
|
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
12
14
|
export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
|
|
13
15
|
export type * from "./generated/session-events.js";
|
|
14
|
-
export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, InstallationConfirmationHandler, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
|
16
|
+
export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, InstallationConfirmationHandler, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
|
15
17
|
export type { JsonValue, WorkflowRunOptions, WorkflowResumeOptions, WorkflowLimitOverrides, WorkflowResumeErrorCode, SessionWorkflowApi, WorkflowAgentOptions, WorkflowContext, WorkflowDefinition, WorkflowHandle, WorkflowJsonSchema, WorkflowLimits, WorkflowMeta, WorkflowPipelineStage, WorkflowStepOptions, WorkflowRunResult, WorkflowRunStatus, WorkflowRunSummary, WorkflowListRunsOptions, WorkflowRunsPage, WorkflowRunDetail, WorkflowProgressPage, WorkflowProgressLine, WorkflowPhaseObservation, WorkflowPhaseStatus, WorkflowAgentSummary, } from "./workflow.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { CopilotClient } from "./client.js";
|
|
2
|
+
import {
|
|
3
|
+
AhpHost
|
|
4
|
+
} from "./host.js";
|
|
2
5
|
import { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
|
|
3
6
|
import { BuiltInTools, ToolSet } from "./toolSet.js";
|
|
4
7
|
import { CopilotSession } from "./session.js";
|
|
@@ -22,6 +25,7 @@ import {
|
|
|
22
25
|
SYSTEM_MESSAGE_SECTIONS
|
|
23
26
|
} from "./types.js";
|
|
24
27
|
export {
|
|
28
|
+
AhpHost,
|
|
25
29
|
BuiltInTools,
|
|
26
30
|
Canvas,
|
|
27
31
|
CanvasError,
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider
|
|
|
13
13
|
import type { ToolSet } from "./toolSet.js";
|
|
14
14
|
export type { RemoteSessionMode } from "./generated/rpc.js";
|
|
15
15
|
export type { CurrentToolMetadata } from "./generated/rpc.js";
|
|
16
|
+
export type { SandboxConfigSource } from "./generated/rpc.js";
|
|
16
17
|
export type { ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorStatus, ExtensionLaunchProfile, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, } from "./generated/rpc.js";
|
|
17
18
|
/**
|
|
18
19
|
* Arguments passed to a session's {@link GitHubTokenProvider}.
|
|
@@ -1839,6 +1840,8 @@ export type AskUserVariant = "legacy" | "elicitation";
|
|
|
1839
1840
|
* an existing one).
|
|
1840
1841
|
*/
|
|
1841
1842
|
export interface SessionConfigBase {
|
|
1843
|
+
/** Exact model IDs allowed by the host. Omission preserves runtime policy. */
|
|
1844
|
+
allowedModels?: string[];
|
|
1842
1845
|
/**
|
|
1843
1846
|
* Client name to identify the application using the SDK.
|
|
1844
1847
|
* Included in the User-Agent header for API requests.
|
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/github/copilot-sdk.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.0.
|
|
8
|
-
"copilotCliVersion": "1.0.
|
|
7
|
+
"version": "1.0.16",
|
|
8
|
+
"copilotCliVersion": "1.0.90",
|
|
9
9
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
10
10
|
"main": "./dist/cjs/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"zod": "4.3.6"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
+
"@microsoft/agent-host-protocol-v09": "npm:@microsoft/agent-host-protocol@0.9.0",
|
|
74
75
|
"@platformatic/vfs": "^0.3.0",
|
|
75
76
|
"@types/node": "^25.2.0",
|
|
76
77
|
"@types/semver": "7.8.0",
|
|
@@ -101,13 +102,13 @@
|
|
|
101
102
|
"README.md"
|
|
102
103
|
],
|
|
103
104
|
"optionalDependencies": {
|
|
104
|
-
"@github/copilot-sdk-darwin-arm64": "1.0.
|
|
105
|
-
"@github/copilot-sdk-darwin-x64": "1.0.
|
|
106
|
-
"@github/copilot-sdk-linux-arm64": "1.0.
|
|
107
|
-
"@github/copilot-sdk-linux-x64": "1.0.
|
|
108
|
-
"@github/copilot-sdk-linuxmusl-arm64": "1.0.
|
|
109
|
-
"@github/copilot-sdk-linuxmusl-x64": "1.0.
|
|
110
|
-
"@github/copilot-sdk-win32-arm64": "1.0.
|
|
111
|
-
"@github/copilot-sdk-win32-x64": "1.0.
|
|
105
|
+
"@github/copilot-sdk-darwin-arm64": "1.0.16",
|
|
106
|
+
"@github/copilot-sdk-darwin-x64": "1.0.16",
|
|
107
|
+
"@github/copilot-sdk-linux-arm64": "1.0.16",
|
|
108
|
+
"@github/copilot-sdk-linux-x64": "1.0.16",
|
|
109
|
+
"@github/copilot-sdk-linuxmusl-arm64": "1.0.16",
|
|
110
|
+
"@github/copilot-sdk-linuxmusl-x64": "1.0.16",
|
|
111
|
+
"@github/copilot-sdk-win32-arm64": "1.0.16",
|
|
112
|
+
"@github/copilot-sdk-win32-x64": "1.0.16"
|
|
112
113
|
}
|
|
113
114
|
}
|