@github/copilot-sdk 1.0.18-preview.3 → 1.0.18-preview.5
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 +15 -2
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +5 -2
- package/dist/cjs/generated/rpc.js +49 -1
- package/dist/cjs/host.js +8 -2
- package/dist/cjs/session.js +58 -6
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +5 -2
- package/dist/generated/rpc.d.ts +539 -246
- package/dist/generated/rpc.js +49 -1
- package/dist/generated/session-events.d.ts +528 -1
- package/dist/host.d.ts +9 -4
- package/dist/host.js +8 -2
- package/dist/session.d.ts +3 -0
- package/dist/session.js +58 -6
- package/dist/types.d.ts +18 -0
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -74,6 +74,9 @@ without deleting underlying sessions. Reconnecting does not reclaim a host.
|
|
|
74
74
|
The optional `onExit` callback reports exits at most once. If the owner connection
|
|
75
75
|
is lost, it reports that loss rather than claiming that listener cleanup was
|
|
76
76
|
acknowledged.
|
|
77
|
+
Call `const { sessions } = await host.listSessions()` to read the complete catalog
|
|
78
|
+
of live and dormant sessions advertised by the host. The method returns a
|
|
79
|
+
`HostListSessionsResult` containing `sessions`, not a session array directly.
|
|
77
80
|
|
|
78
81
|
`host.pid` is absent for in-process listeners. The optional field is retained
|
|
79
82
|
for separate host process IDs returned by legacy runtimes, never the runtime PID.
|
|
@@ -104,6 +107,10 @@ The listener follows the owning client's lifetime. Call `await host.dispose()`
|
|
|
104
107
|
only when you want to stop it earlier; `await using host` also supports a shorter
|
|
105
108
|
scope. Each disposal call forwards to the runtime, which owns idempotent cleanup.
|
|
106
109
|
The AHP transport remains owned by the host.
|
|
110
|
+
Set top-level `computeId` to reuse the same durable catalog for local and Mission
|
|
111
|
+
Control hosting; it must agree with `githubEnvironment.computeId` when both are
|
|
112
|
+
supplied. Omitted local-only identities are persisted by the runtime, not generated
|
|
113
|
+
by the SDK. Published sessions remain discoverable after hosting stops.
|
|
107
114
|
|
|
108
115
|
### Application-owned sessions
|
|
109
116
|
|
|
@@ -165,8 +172,9 @@ still matches the requested identity and workspace.
|
|
|
165
172
|
Only catalog entries marked as application-owned invoke this callback.
|
|
166
173
|
If the callback is missing, restoring such an entry fails instead of falling
|
|
167
174
|
back to host-owned creation.
|
|
168
|
-
|
|
169
|
-
their current registrations.
|
|
175
|
+
Currently resident published sessions attach directly, without invoking it or replacing
|
|
176
|
+
their current registrations. Dormant published application sessions require this
|
|
177
|
+
resume callback to restore their tools and handlers. Resumed sessions follow the same original-object
|
|
170
178
|
retention, cancellation, late-result release, and `onSessionReleased` rules.
|
|
171
179
|
|
|
172
180
|
The `copilotd-hosting` library runs inside the runtime provider.
|
|
@@ -345,6 +353,11 @@ This graceful-exit timeout is separate from the shutdown RPC and post-terminatio
|
|
|
345
353
|
##### `forceStop(): Promise<void>`
|
|
346
354
|
|
|
347
355
|
Force stop the CLI server without graceful cleanup. Use when `stop()` takes too long.
|
|
356
|
+
Retained sessions are disconnected locally, and pending `sendAndWait()` calls reject
|
|
357
|
+
without waiting for `session.idle` or their response timeout.
|
|
358
|
+
Retirement releases session-owned tool, hook, auth/input, provider, workflow, canvas,
|
|
359
|
+
and transform registrations without changing caller-owned configuration. Late
|
|
360
|
+
registration and callback dispatch are rejected; callbacks already admitted may finish.
|
|
348
361
|
|
|
349
362
|
##### `createSession(config?: SessionConfig): Promise<CopilotSession>`
|
|
350
363
|
|
package/dist/cjs/cliVersion.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
|
|
|
22
22
|
COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(cliVersion_exports);
|
|
25
|
-
const COPILOT_CLI_VERSION = "1.0.94-
|
|
25
|
+
const COPILOT_CLI_VERSION = "1.0.94-5";
|
|
26
26
|
const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
package/dist/cjs/client.js
CHANGED
|
@@ -1713,7 +1713,7 @@ class CopilotClient {
|
|
|
1713
1713
|
* This connection owns the host. Disposing it or disconnecting the client
|
|
1714
1714
|
* stops the listener without deleting sessions. The host uses a separate
|
|
1715
1715
|
* SDK connection to the same runtime, not another runtime process.
|
|
1716
|
-
* Only one AHP host may own
|
|
1716
|
+
* Only one AHP host may own a compute-scoped catalog in an effective Copilot home
|
|
1717
1717
|
* at a time. Other SDK clients and sessions remain usable in that home.
|
|
1718
1718
|
* Select localServer, githubEnvironment, or both. An empty localServer
|
|
1719
1719
|
* selects 127.0.0.1 on an available port. `onExit` runs at most once; owner disconnection cannot
|
|
@@ -1731,6 +1731,7 @@ class CopilotClient {
|
|
|
1731
1731
|
const rpc = this.rpc;
|
|
1732
1732
|
const hostId = (0, import_node_crypto.randomUUID)();
|
|
1733
1733
|
const {
|
|
1734
|
+
computeId,
|
|
1734
1735
|
localServer,
|
|
1735
1736
|
githubEnvironment,
|
|
1736
1737
|
onExit,
|
|
@@ -1751,6 +1752,7 @@ class CopilotClient {
|
|
|
1751
1752
|
try {
|
|
1752
1753
|
const info = await rpc.host.start({
|
|
1753
1754
|
hostId,
|
|
1755
|
+
computeId,
|
|
1754
1756
|
localServer,
|
|
1755
1757
|
githubEnvironment,
|
|
1756
1758
|
sessionFactory: createSession ? true : void 0,
|
|
@@ -1761,7 +1763,8 @@ class CopilotClient {
|
|
|
1761
1763
|
async () => {
|
|
1762
1764
|
await rpc.host.dispose({ hostId });
|
|
1763
1765
|
},
|
|
1764
|
-
(sessionId) => rpc.host.publishSession({ hostId, sessionId })
|
|
1766
|
+
(sessionId) => rpc.host.publishSession({ hostId, sessionId }),
|
|
1767
|
+
() => rpc.host.listSessions({ hostId })
|
|
1765
1768
|
);
|
|
1766
1769
|
} catch (error) {
|
|
1767
1770
|
this.hostExitCallbacks.delete(hostId);
|
|
@@ -65,6 +65,14 @@ function createServerRpc(connection) {
|
|
|
65
65
|
* @returns The existing runtime identity and its resource on the listener.
|
|
66
66
|
*/
|
|
67
67
|
publishSession: async (params) => connection.sendRequest("host.publishSession", params),
|
|
68
|
+
/**
|
|
69
|
+
* Reads the complete advertised live and dormant session catalog of an existing host owned by this connection. Does not start hosting, subscribe to sessions, or guarantee resumability.
|
|
70
|
+
*
|
|
71
|
+
* @param params Reads a running host's catalog or the runtime's saved default catalog.
|
|
72
|
+
*
|
|
73
|
+
* @returns The complete live and dormant advertised catalog, without subscribing to sessions.
|
|
74
|
+
*/
|
|
75
|
+
listSessions: async (params) => connection.sendRequest("host.listSessions", params),
|
|
68
76
|
/**
|
|
69
77
|
* Starts a connection-owned AHP host with explicit localServer and/or githubEnvironment transports as a supervised SDK participant.
|
|
70
78
|
*
|
|
@@ -2710,6 +2718,12 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2710
2718
|
* @returns Indicates whether the external tool call result was handled successfully.
|
|
2711
2719
|
*/
|
|
2712
2720
|
handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { ...params, sessionId }),
|
|
2721
|
+
/**
|
|
2722
|
+
* Lists the external tool calls of the session and its sub-agents that are still waiting for session.tools.handlePendingToolCall.
|
|
2723
|
+
*
|
|
2724
|
+
* @returns External tool calls still waiting for a result.
|
|
2725
|
+
*/
|
|
2726
|
+
listPendingRequests: async () => connection.sendRequest("session.tools.listPendingRequests", { sessionId }),
|
|
2713
2727
|
/**
|
|
2714
2728
|
* Resolves, builds, and validates the runtime tool list for the session.
|
|
2715
2729
|
*
|
|
@@ -3399,6 +3413,27 @@ function createSessionRpc(connection, sessionId) {
|
|
|
3399
3413
|
getMetrics: async () => connection.sendRequest("session.usage.getMetrics", { sessionId })
|
|
3400
3414
|
},
|
|
3401
3415
|
/** @experimental */
|
|
3416
|
+
quota: {
|
|
3417
|
+
/**
|
|
3418
|
+
* Gets the session's current quota and account projection without making a network request.
|
|
3419
|
+
*
|
|
3420
|
+
* @returns The incumbent session-owned quota and account projection.
|
|
3421
|
+
*/
|
|
3422
|
+
get: async () => connection.sendRequest("session.quota.get", { sessionId }),
|
|
3423
|
+
/**
|
|
3424
|
+
* Refreshes the session's provider model catalog bypassing its cache, folds quota snapshots into session state, and returns the updated projection. Failures leave the last known quota intact.
|
|
3425
|
+
*
|
|
3426
|
+
* @returns The incumbent session-owned quota and account projection.
|
|
3427
|
+
*/
|
|
3428
|
+
refresh: async () => connection.sendRequest("session.quota.refresh", { sessionId }),
|
|
3429
|
+
/**
|
|
3430
|
+
* Returns and clears the session's pending quota warnings. Reading or refreshing quota does not drain warnings.
|
|
3431
|
+
*
|
|
3432
|
+
* @returns Pending warnings returned and cleared by session.quota.takeWarnings.
|
|
3433
|
+
*/
|
|
3434
|
+
takeWarnings: async () => connection.sendRequest("session.quota.takeWarnings", { sessionId })
|
|
3435
|
+
},
|
|
3436
|
+
/** @experimental */
|
|
3402
3437
|
limitPrediction: {
|
|
3403
3438
|
/**
|
|
3404
3439
|
* 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.
|
|
@@ -3585,7 +3620,11 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
3585
3620
|
*
|
|
3586
3621
|
* @returns The model identifier active on the session after the switch.
|
|
3587
3622
|
*/
|
|
3588
|
-
applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { ...params, sessionId })
|
|
3623
|
+
applyStartupOverlay: async (params) => connection.sendRequest("session.model.applyStartupOverlay", { ...params, sessionId }),
|
|
3624
|
+
/**
|
|
3625
|
+
* Clears an unchanged startup model/provider seed before default-model resolution. Never clears a resumed or user-selected model.
|
|
3626
|
+
*/
|
|
3627
|
+
clearStartupSeed: async (params) => connection.sendRequest("session.model.clearStartupSeed", { ...params, sessionId })
|
|
3589
3628
|
},
|
|
3590
3629
|
/** @experimental */
|
|
3591
3630
|
mcp: {
|
|
@@ -3752,6 +3791,15 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
3752
3791
|
process: async () => connection.sendRequest("session.queue.process", { sessionId })
|
|
3753
3792
|
},
|
|
3754
3793
|
/** @experimental */
|
|
3794
|
+
usage: {
|
|
3795
|
+
/**
|
|
3796
|
+
* Internal host-only replacement of absolute code-change totals reported by a relay host.
|
|
3797
|
+
*
|
|
3798
|
+
* @param params Internal absolute code-change totals reported by the owning host.
|
|
3799
|
+
*/
|
|
3800
|
+
setCodeChanges: async (params) => connection.sendRequest("session.usage.setCodeChanges", { ...params, sessionId })
|
|
3801
|
+
},
|
|
3802
|
+
/** @experimental */
|
|
3755
3803
|
schedule: {
|
|
3756
3804
|
/**
|
|
3757
3805
|
* Hydrates the native schedule registry from persisted session events.
|
package/dist/cjs/host.js
CHANGED
|
@@ -23,9 +23,10 @@ __export(host_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(host_exports);
|
|
24
24
|
class AhpHost {
|
|
25
25
|
/** @internal */
|
|
26
|
-
constructor(info, disposeHost, publishHostSession) {
|
|
26
|
+
constructor(info, disposeHost, publishHostSession, listHostSessions) {
|
|
27
27
|
this.disposeHost = disposeHost;
|
|
28
28
|
this.publishHostSession = publishHostSession;
|
|
29
|
+
this.listHostSessions = listHostSessions;
|
|
29
30
|
this.hostId = info.hostId;
|
|
30
31
|
this.url = info.url;
|
|
31
32
|
this.environmentId = info.environmentId;
|
|
@@ -34,6 +35,7 @@ class AhpHost {
|
|
|
34
35
|
}
|
|
35
36
|
disposeHost;
|
|
36
37
|
publishHostSession;
|
|
38
|
+
listHostSessions;
|
|
37
39
|
hostId;
|
|
38
40
|
/** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
|
|
39
41
|
url;
|
|
@@ -47,10 +49,14 @@ class AhpHost {
|
|
|
47
49
|
dispose() {
|
|
48
50
|
return this.disposeHost();
|
|
49
51
|
}
|
|
50
|
-
/** Publish an
|
|
52
|
+
/** Publish an attached application session into the durable compute-scoped host catalog. */
|
|
51
53
|
publishSession(sessionId) {
|
|
52
54
|
return this.publishHostSession(sessionId);
|
|
53
55
|
}
|
|
56
|
+
/** List all live and dormant catalog sessions advertised by this host. */
|
|
57
|
+
listSessions() {
|
|
58
|
+
return this.listHostSessions();
|
|
59
|
+
}
|
|
54
60
|
async [Symbol.asyncDispose]() {
|
|
55
61
|
await this.dispose();
|
|
56
62
|
}
|
package/dist/cjs/session.js
CHANGED
|
@@ -294,6 +294,7 @@ class CopilotSession {
|
|
|
294
294
|
_capabilities = {};
|
|
295
295
|
openCanvasInstances = [];
|
|
296
296
|
disconnected = false;
|
|
297
|
+
pendingResponseWaits = /* @__PURE__ */ new Set();
|
|
297
298
|
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
298
299
|
disconnecting = false;
|
|
299
300
|
onDisconnected;
|
|
@@ -570,6 +571,8 @@ class CopilotSession {
|
|
|
570
571
|
resolveOutcome({ kind: "error", error });
|
|
571
572
|
}
|
|
572
573
|
});
|
|
574
|
+
const fail = (error) => resolveOutcome({ kind: "error", error });
|
|
575
|
+
this.pendingResponseWaits.add(fail);
|
|
573
576
|
let timeoutId;
|
|
574
577
|
try {
|
|
575
578
|
await this.send(options);
|
|
@@ -593,6 +596,7 @@ class CopilotSession {
|
|
|
593
596
|
clearTimeout(timeoutId);
|
|
594
597
|
}
|
|
595
598
|
unsubscribe();
|
|
599
|
+
this.pendingResponseWaits.delete(fail);
|
|
596
600
|
}
|
|
597
601
|
}
|
|
598
602
|
async sendAndWaitForStructuredMessage(options, timeout) {
|
|
@@ -674,12 +678,21 @@ class CopilotSession {
|
|
|
674
678
|
this.pendingStructuredWaits.delete(fail);
|
|
675
679
|
}
|
|
676
680
|
}
|
|
681
|
+
assertConnected() {
|
|
682
|
+
if (this.disconnected) {
|
|
683
|
+
throw new Error("Session is disconnected");
|
|
684
|
+
}
|
|
685
|
+
}
|
|
677
686
|
/** @internal */
|
|
678
687
|
_markDisconnected() {
|
|
679
688
|
if (this.disconnected) {
|
|
680
689
|
return;
|
|
681
690
|
}
|
|
682
691
|
this.disconnected = true;
|
|
692
|
+
for (const fail of this.pendingResponseWaits) {
|
|
693
|
+
fail(new Error("Session disconnected while waiting for a response"));
|
|
694
|
+
}
|
|
695
|
+
this.pendingResponseWaits.clear();
|
|
683
696
|
for (const fail of this.pendingStructuredWaits) {
|
|
684
697
|
fail(new Error("Session disconnected while waiting for a structured response"));
|
|
685
698
|
}
|
|
@@ -688,16 +701,19 @@ class CopilotSession {
|
|
|
688
701
|
controller.abort();
|
|
689
702
|
}
|
|
690
703
|
this.pendingExternalTools.clear();
|
|
691
|
-
this._runOnDisconnected();
|
|
692
704
|
this.eventHandlers.clear();
|
|
693
705
|
this.typedEventHandlers.clear();
|
|
694
706
|
this.toolHandlers.clear();
|
|
695
707
|
this.permissionHandler = void 0;
|
|
708
|
+
this.mcpAuthHandler = void 0;
|
|
696
709
|
this.userInputHandler = void 0;
|
|
697
710
|
this.elicitationHandler = void 0;
|
|
698
711
|
this.exitPlanModeHandler = void 0;
|
|
699
712
|
this.autoModeSwitchHandler = void 0;
|
|
700
713
|
this.skillProvider = void 0;
|
|
714
|
+
this.hooks = void 0;
|
|
715
|
+
this.traceContextProvider = void 0;
|
|
716
|
+
this.bearerTokenProviders.clear();
|
|
701
717
|
this.commandHandlers.clear();
|
|
702
718
|
this.canvases.clear();
|
|
703
719
|
this.workflows.clear();
|
|
@@ -707,18 +723,28 @@ class CopilotSession {
|
|
|
707
723
|
}
|
|
708
724
|
}
|
|
709
725
|
this.workflowAbortControllers.clear();
|
|
710
|
-
this.transformCallbacks
|
|
726
|
+
this.transformCallbacks = void 0;
|
|
727
|
+
delete this.clientSessionApis.providerToken;
|
|
728
|
+
delete this.clientSessionApis.canvas;
|
|
729
|
+
delete this.clientSessionApis.workflow;
|
|
730
|
+
delete this.clientSessionApis.sessionFs;
|
|
731
|
+
this._runOnDisconnected();
|
|
711
732
|
}
|
|
712
733
|
/** @internal */
|
|
713
734
|
_runOnDisconnected() {
|
|
714
|
-
this.onDisconnected
|
|
735
|
+
const callback = this.onDisconnected;
|
|
715
736
|
this.onDisconnected = void 0;
|
|
737
|
+
callback?.();
|
|
716
738
|
}
|
|
717
739
|
/** @internal */
|
|
718
740
|
_setOnDisconnected(callback) {
|
|
741
|
+
this.assertConnected();
|
|
719
742
|
this.onDisconnected = callback;
|
|
720
743
|
}
|
|
721
744
|
on(eventTypeOrHandler, handler) {
|
|
745
|
+
if (this.disconnected) {
|
|
746
|
+
throw new Error("Session is disconnected");
|
|
747
|
+
}
|
|
722
748
|
if (typeof eventTypeOrHandler === "string" && handler) {
|
|
723
749
|
const eventType = eventTypeOrHandler;
|
|
724
750
|
if (!this.typedEventHandlers.has(eventType)) {
|
|
@@ -789,7 +815,8 @@ class CopilotSession {
|
|
|
789
815
|
args,
|
|
790
816
|
handler,
|
|
791
817
|
traceparent,
|
|
792
|
-
tracestate
|
|
818
|
+
tracestate,
|
|
819
|
+
event.agentId || void 0
|
|
793
820
|
);
|
|
794
821
|
}
|
|
795
822
|
} else if (event.type === "external_tool.completed") {
|
|
@@ -880,7 +907,7 @@ class CopilotSession {
|
|
|
880
907
|
* Executes a tool handler and sends the result back via RPC.
|
|
881
908
|
* @internal
|
|
882
909
|
*/
|
|
883
|
-
async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate) {
|
|
910
|
+
async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate, agentId) {
|
|
884
911
|
const controller = new AbortController();
|
|
885
912
|
if (this.disconnected || this.pendingExternalTools.has(requestId)) {
|
|
886
913
|
return;
|
|
@@ -918,7 +945,9 @@ class CopilotSession {
|
|
|
918
945
|
availableTools,
|
|
919
946
|
traceparent,
|
|
920
947
|
tracestate,
|
|
921
|
-
signal: controller.signal
|
|
948
|
+
signal: controller.signal,
|
|
949
|
+
agentId,
|
|
950
|
+
requestId
|
|
922
951
|
});
|
|
923
952
|
let result;
|
|
924
953
|
if (rawResult == null) {
|
|
@@ -1079,6 +1108,7 @@ class CopilotSession {
|
|
|
1079
1108
|
* @internal This method is typically called internally when creating a session with tools.
|
|
1080
1109
|
*/
|
|
1081
1110
|
registerTools(tools) {
|
|
1111
|
+
this.assertConnected();
|
|
1082
1112
|
this.toolHandlers.clear();
|
|
1083
1113
|
if (!tools) {
|
|
1084
1114
|
return;
|
|
@@ -1119,6 +1149,7 @@ class CopilotSession {
|
|
|
1119
1149
|
* @internal Called by the SDK when creating/resuming a session with `canvases`.
|
|
1120
1150
|
*/
|
|
1121
1151
|
registerCanvases(canvases) {
|
|
1152
|
+
this.assertConnected();
|
|
1122
1153
|
this.canvases.clear();
|
|
1123
1154
|
if (!canvases || canvases.length === 0) {
|
|
1124
1155
|
delete this.clientSessionApis.canvas;
|
|
@@ -1174,6 +1205,7 @@ class CopilotSession {
|
|
|
1174
1205
|
* @internal Called by the SDK when an extension joins a session.
|
|
1175
1206
|
*/
|
|
1176
1207
|
registerWorkflows(workflows) {
|
|
1208
|
+
this.assertConnected();
|
|
1177
1209
|
this.workflows.clear();
|
|
1178
1210
|
if (!workflows || workflows.length === 0) {
|
|
1179
1211
|
delete this.clientSessionApis.workflow;
|
|
@@ -1366,6 +1398,7 @@ class CopilotSession {
|
|
|
1366
1398
|
* @internal This method is called internally when creating/resuming a session.
|
|
1367
1399
|
*/
|
|
1368
1400
|
registerBearerTokenProviders(providers) {
|
|
1401
|
+
this.assertConnected();
|
|
1369
1402
|
this.bearerTokenProviders.clear();
|
|
1370
1403
|
if (!providers || providers.size === 0) {
|
|
1371
1404
|
delete this.clientSessionApis.providerToken;
|
|
@@ -1377,6 +1410,7 @@ class CopilotSession {
|
|
|
1377
1410
|
const self = this;
|
|
1378
1411
|
this.clientSessionApis.providerToken = {
|
|
1379
1412
|
async getToken(params) {
|
|
1413
|
+
self.assertConnected();
|
|
1380
1414
|
const callback = self.bearerTokenProviders.get(params.providerName);
|
|
1381
1415
|
if (!callback) {
|
|
1382
1416
|
throw new Error(
|
|
@@ -1398,6 +1432,7 @@ class CopilotSession {
|
|
|
1398
1432
|
* @internal This method is typically called internally when creating/resuming a session.
|
|
1399
1433
|
*/
|
|
1400
1434
|
registerCommands(commands) {
|
|
1435
|
+
this.assertConnected();
|
|
1401
1436
|
this.commandHandlers.clear();
|
|
1402
1437
|
if (!commands) {
|
|
1403
1438
|
return;
|
|
@@ -1413,6 +1448,7 @@ class CopilotSession {
|
|
|
1413
1448
|
* @internal This method is typically called internally when creating/resuming a session.
|
|
1414
1449
|
*/
|
|
1415
1450
|
registerElicitationHandler(handler) {
|
|
1451
|
+
this.assertConnected();
|
|
1416
1452
|
this.elicitationHandler = handler;
|
|
1417
1453
|
}
|
|
1418
1454
|
/**
|
|
@@ -1422,6 +1458,7 @@ class CopilotSession {
|
|
|
1422
1458
|
* @internal This method is typically called internally when creating/resuming a session.
|
|
1423
1459
|
*/
|
|
1424
1460
|
registerExitPlanModeHandler(handler) {
|
|
1461
|
+
this.assertConnected();
|
|
1425
1462
|
this.exitPlanModeHandler = handler;
|
|
1426
1463
|
}
|
|
1427
1464
|
/**
|
|
@@ -1431,6 +1468,7 @@ class CopilotSession {
|
|
|
1431
1468
|
* @internal This method is typically called internally when creating/resuming a session.
|
|
1432
1469
|
*/
|
|
1433
1470
|
registerAutoModeSwitchHandler(handler) {
|
|
1471
|
+
this.assertConnected();
|
|
1434
1472
|
this.autoModeSwitchHandler = handler;
|
|
1435
1473
|
}
|
|
1436
1474
|
/**
|
|
@@ -1469,6 +1507,7 @@ class CopilotSession {
|
|
|
1469
1507
|
* @internal
|
|
1470
1508
|
*/
|
|
1471
1509
|
async _handleExitPlanModeRequest(request) {
|
|
1510
|
+
this.assertConnected();
|
|
1472
1511
|
if (!this.exitPlanModeHandler) {
|
|
1473
1512
|
return { approved: true };
|
|
1474
1513
|
}
|
|
@@ -1479,6 +1518,7 @@ class CopilotSession {
|
|
|
1479
1518
|
* @internal
|
|
1480
1519
|
*/
|
|
1481
1520
|
async _handleAutoModeSwitchRequest(request) {
|
|
1521
|
+
this.assertConnected();
|
|
1482
1522
|
if (!this.autoModeSwitchHandler) {
|
|
1483
1523
|
return "no";
|
|
1484
1524
|
}
|
|
@@ -1590,6 +1630,7 @@ class CopilotSession {
|
|
|
1590
1630
|
* @internal This method is typically called internally when creating a session.
|
|
1591
1631
|
*/
|
|
1592
1632
|
registerPermissionHandler(handler) {
|
|
1633
|
+
this.assertConnected();
|
|
1593
1634
|
this.permissionHandler = handler;
|
|
1594
1635
|
}
|
|
1595
1636
|
/**
|
|
@@ -1602,6 +1643,7 @@ class CopilotSession {
|
|
|
1602
1643
|
* @internal This method is typically called internally when creating a session.
|
|
1603
1644
|
*/
|
|
1604
1645
|
registerUserInputHandler(handler) {
|
|
1646
|
+
this.assertConnected();
|
|
1605
1647
|
this.userInputHandler = handler;
|
|
1606
1648
|
}
|
|
1607
1649
|
/**
|
|
@@ -1611,6 +1653,7 @@ class CopilotSession {
|
|
|
1611
1653
|
* @internal This method is typically called internally when creating a session.
|
|
1612
1654
|
*/
|
|
1613
1655
|
registerSkillProvider(provider) {
|
|
1656
|
+
this.assertConnected();
|
|
1614
1657
|
this.skillProvider = provider;
|
|
1615
1658
|
}
|
|
1616
1659
|
/**
|
|
@@ -1636,6 +1679,7 @@ class CopilotSession {
|
|
|
1636
1679
|
}));
|
|
1637
1680
|
}
|
|
1638
1681
|
requireSkillProvider() {
|
|
1682
|
+
this.assertConnected();
|
|
1639
1683
|
if (!this.skillProvider) {
|
|
1640
1684
|
throw new Error(`No skill provider for session: ${this.sessionId}`);
|
|
1641
1685
|
}
|
|
@@ -1676,6 +1720,7 @@ class CopilotSession {
|
|
|
1676
1720
|
* @internal This method is typically called internally when creating a session.
|
|
1677
1721
|
*/
|
|
1678
1722
|
registerHooks(hooks) {
|
|
1723
|
+
this.assertConnected();
|
|
1679
1724
|
this.hooks = hooks;
|
|
1680
1725
|
}
|
|
1681
1726
|
/**
|
|
@@ -1685,6 +1730,7 @@ class CopilotSession {
|
|
|
1685
1730
|
* @internal This method is typically called internally when creating a session.
|
|
1686
1731
|
*/
|
|
1687
1732
|
registerTransformCallbacks(callbacks) {
|
|
1733
|
+
this.assertConnected();
|
|
1688
1734
|
this.transformCallbacks = callbacks;
|
|
1689
1735
|
}
|
|
1690
1736
|
/**
|
|
@@ -1696,6 +1742,7 @@ class CopilotSession {
|
|
|
1696
1742
|
* @internal This method is for internal use by the SDK.
|
|
1697
1743
|
*/
|
|
1698
1744
|
async _handleSystemMessageTransform(sections) {
|
|
1745
|
+
this.assertConnected();
|
|
1699
1746
|
const result = {};
|
|
1700
1747
|
for (const [sectionId, { content }] of Object.entries(sections)) {
|
|
1701
1748
|
const callback = this.transformCallbacks?.get(sectionId);
|
|
@@ -1720,6 +1767,7 @@ class CopilotSession {
|
|
|
1720
1767
|
* @internal This method is for internal use by the SDK.
|
|
1721
1768
|
*/
|
|
1722
1769
|
async _handleUserInputRequest(request) {
|
|
1770
|
+
this.assertConnected();
|
|
1723
1771
|
if (!this.userInputHandler) {
|
|
1724
1772
|
throw new Error("User input requested but no handler registered");
|
|
1725
1773
|
}
|
|
@@ -1741,6 +1789,7 @@ class CopilotSession {
|
|
|
1741
1789
|
* @internal This method is for internal use by the SDK.
|
|
1742
1790
|
*/
|
|
1743
1791
|
async _handleHooksInvoke(hookType, input) {
|
|
1792
|
+
this.assertConnected();
|
|
1744
1793
|
if (!this.hooks) {
|
|
1745
1794
|
return void 0;
|
|
1746
1795
|
}
|
|
@@ -1947,6 +1996,7 @@ class CopilotSession {
|
|
|
1947
1996
|
* replace tools while the session is idle.
|
|
1948
1997
|
*
|
|
1949
1998
|
* @param tools - The complete set of tools this client supplies
|
|
1999
|
+
* @throws Error if the session disconnects before the replacement is applied
|
|
1950
2000
|
*
|
|
1951
2001
|
* @experimental Wraps the experimental `session.tools.set` RPC and may change
|
|
1952
2002
|
* or be removed in a future release.
|
|
@@ -1963,8 +2013,10 @@ class CopilotSession {
|
|
|
1963
2013
|
* ```
|
|
1964
2014
|
*/
|
|
1965
2015
|
async setTools(tools) {
|
|
2016
|
+
this.assertConnected();
|
|
1966
2017
|
const definitions = tools.map(toToolDefinition);
|
|
1967
2018
|
const replacement = this.setToolsQueue.then(async () => {
|
|
2019
|
+
this.assertConnected();
|
|
1968
2020
|
await this.rpc.tools.set({ tools: definitions });
|
|
1969
2021
|
this.registerTools(tools);
|
|
1970
2022
|
});
|
package/dist/cliVersion.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COPILOT_CLI_VERSION = "1.0.94-
|
|
1
|
+
export declare const COPILOT_CLI_VERSION = "1.0.94-5";
|
|
2
2
|
export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
package/dist/cliVersion.js
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -254,7 +254,7 @@ export declare class CopilotClient {
|
|
|
254
254
|
* This connection owns the host. Disposing it or disconnecting the client
|
|
255
255
|
* stops the listener without deleting sessions. The host uses a separate
|
|
256
256
|
* SDK connection to the same runtime, not another runtime process.
|
|
257
|
-
* Only one AHP host may own
|
|
257
|
+
* Only one AHP host may own a compute-scoped catalog in an effective Copilot home
|
|
258
258
|
* at a time. Other SDK clients and sessions remain usable in that home.
|
|
259
259
|
* Select localServer, githubEnvironment, or both. An empty localServer
|
|
260
260
|
* selects 127.0.0.1 on an available port. `onExit` runs at most once; owner disconnection cannot
|
package/dist/client.js
CHANGED
|
@@ -1693,7 +1693,7 @@ class CopilotClient {
|
|
|
1693
1693
|
* This connection owns the host. Disposing it or disconnecting the client
|
|
1694
1694
|
* stops the listener without deleting sessions. The host uses a separate
|
|
1695
1695
|
* SDK connection to the same runtime, not another runtime process.
|
|
1696
|
-
* Only one AHP host may own
|
|
1696
|
+
* Only one AHP host may own a compute-scoped catalog in an effective Copilot home
|
|
1697
1697
|
* at a time. Other SDK clients and sessions remain usable in that home.
|
|
1698
1698
|
* Select localServer, githubEnvironment, or both. An empty localServer
|
|
1699
1699
|
* selects 127.0.0.1 on an available port. `onExit` runs at most once; owner disconnection cannot
|
|
@@ -1711,6 +1711,7 @@ class CopilotClient {
|
|
|
1711
1711
|
const rpc = this.rpc;
|
|
1712
1712
|
const hostId = randomUUID();
|
|
1713
1713
|
const {
|
|
1714
|
+
computeId,
|
|
1714
1715
|
localServer,
|
|
1715
1716
|
githubEnvironment,
|
|
1716
1717
|
onExit,
|
|
@@ -1731,6 +1732,7 @@ class CopilotClient {
|
|
|
1731
1732
|
try {
|
|
1732
1733
|
const info = await rpc.host.start({
|
|
1733
1734
|
hostId,
|
|
1735
|
+
computeId,
|
|
1734
1736
|
localServer,
|
|
1735
1737
|
githubEnvironment,
|
|
1736
1738
|
sessionFactory: createSession ? true : void 0,
|
|
@@ -1741,7 +1743,8 @@ class CopilotClient {
|
|
|
1741
1743
|
async () => {
|
|
1742
1744
|
await rpc.host.dispose({ hostId });
|
|
1743
1745
|
},
|
|
1744
|
-
(sessionId) => rpc.host.publishSession({ hostId, sessionId })
|
|
1746
|
+
(sessionId) => rpc.host.publishSession({ hostId, sessionId }),
|
|
1747
|
+
() => rpc.host.listSessions({ hostId })
|
|
1745
1748
|
);
|
|
1746
1749
|
} catch (error) {
|
|
1747
1750
|
this.hostExitCallbacks.delete(hostId);
|