@github/copilot-sdk 0.1.33-preview.1 → 0.1.33-preview.3

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.
@@ -0,0 +1,581 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var session_exports = {};
20
+ __export(session_exports, {
21
+ CopilotSession: () => CopilotSession,
22
+ NO_RESULT_PERMISSION_V2_ERROR: () => NO_RESULT_PERMISSION_V2_ERROR
23
+ });
24
+ module.exports = __toCommonJS(session_exports);
25
+ var import_node = require("vscode-jsonrpc/node.js");
26
+ var import_rpc = require("./generated/rpc.js");
27
+ var import_telemetry = require("./telemetry.js");
28
+ const NO_RESULT_PERMISSION_V2_ERROR = "Permission handlers cannot return 'no-result' when connected to a protocol v2 server.";
29
+ class CopilotSession {
30
+ /**
31
+ * Creates a new CopilotSession instance.
32
+ *
33
+ * @param sessionId - The unique identifier for this session
34
+ * @param connection - The JSON-RPC message connection to the Copilot CLI
35
+ * @param workspacePath - Path to the session workspace directory (when infinite sessions enabled)
36
+ * @param traceContextProvider - Optional callback to get W3C Trace Context for outbound RPCs
37
+ * @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
38
+ */
39
+ constructor(sessionId, connection, _workspacePath, traceContextProvider) {
40
+ this.sessionId = sessionId;
41
+ this.connection = connection;
42
+ this._workspacePath = _workspacePath;
43
+ this.traceContextProvider = traceContextProvider;
44
+ }
45
+ eventHandlers = /* @__PURE__ */ new Set();
46
+ typedEventHandlers = /* @__PURE__ */ new Map();
47
+ toolHandlers = /* @__PURE__ */ new Map();
48
+ permissionHandler;
49
+ userInputHandler;
50
+ hooks;
51
+ _rpc = null;
52
+ traceContextProvider;
53
+ /**
54
+ * Typed session-scoped RPC methods.
55
+ */
56
+ get rpc() {
57
+ if (!this._rpc) {
58
+ this._rpc = (0, import_rpc.createSessionRpc)(this.connection, this.sessionId);
59
+ }
60
+ return this._rpc;
61
+ }
62
+ /**
63
+ * Path to the session workspace directory when infinite sessions are enabled.
64
+ * Contains checkpoints/, plan.md, and files/ subdirectories.
65
+ * Undefined if infinite sessions are disabled.
66
+ */
67
+ get workspacePath() {
68
+ return this._workspacePath;
69
+ }
70
+ /**
71
+ * Sends a message to this session and waits for the response.
72
+ *
73
+ * The message is processed asynchronously. Subscribe to events via {@link on}
74
+ * to receive streaming responses and other session events.
75
+ *
76
+ * @param options - The message options including the prompt and optional attachments
77
+ * @returns A promise that resolves with the message ID of the response
78
+ * @throws Error if the session has been disconnected or the connection fails
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const messageId = await session.send({
83
+ * prompt: "Explain this code",
84
+ * attachments: [{ type: "file", path: "./src/index.ts" }]
85
+ * });
86
+ * ```
87
+ */
88
+ async send(options) {
89
+ const response = await this.connection.sendRequest("session.send", {
90
+ ...await (0, import_telemetry.getTraceContext)(this.traceContextProvider),
91
+ sessionId: this.sessionId,
92
+ prompt: options.prompt,
93
+ attachments: options.attachments,
94
+ mode: options.mode
95
+ });
96
+ return response.messageId;
97
+ }
98
+ /**
99
+ * Sends a message to this session and waits until the session becomes idle.
100
+ *
101
+ * This is a convenience method that combines {@link send} with waiting for
102
+ * the `session.idle` event. Use this when you want to block until the
103
+ * assistant has finished processing the message.
104
+ *
105
+ * Events are still delivered to handlers registered via {@link on} while waiting.
106
+ *
107
+ * @param options - The message options including the prompt and optional attachments
108
+ * @param timeout - Timeout in milliseconds (default: 60000). Controls how long to wait; does not abort in-flight agent work.
109
+ * @returns A promise that resolves with the final assistant message when the session becomes idle,
110
+ * or undefined if no assistant message was received
111
+ * @throws Error if the timeout is reached before the session becomes idle
112
+ * @throws Error if the session has been disconnected or the connection fails
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * // Send and wait for completion with default 60s timeout
117
+ * const response = await session.sendAndWait({ prompt: "What is 2+2?" });
118
+ * console.log(response?.data.content); // "4"
119
+ * ```
120
+ */
121
+ async sendAndWait(options, timeout) {
122
+ const effectiveTimeout = timeout ?? 6e4;
123
+ let resolveIdle;
124
+ let rejectWithError;
125
+ const idlePromise = new Promise((resolve, reject) => {
126
+ resolveIdle = resolve;
127
+ rejectWithError = reject;
128
+ });
129
+ let lastAssistantMessage;
130
+ const unsubscribe = this.on((event) => {
131
+ if (event.type === "assistant.message") {
132
+ lastAssistantMessage = event;
133
+ } else if (event.type === "session.idle") {
134
+ resolveIdle();
135
+ } else if (event.type === "session.error") {
136
+ const error = new Error(event.data.message);
137
+ error.stack = event.data.stack;
138
+ rejectWithError(error);
139
+ }
140
+ });
141
+ let timeoutId;
142
+ try {
143
+ await this.send(options);
144
+ const timeoutPromise = new Promise((_, reject) => {
145
+ timeoutId = setTimeout(
146
+ () => reject(
147
+ new Error(
148
+ `Timeout after ${effectiveTimeout}ms waiting for session.idle`
149
+ )
150
+ ),
151
+ effectiveTimeout
152
+ );
153
+ });
154
+ await Promise.race([idlePromise, timeoutPromise]);
155
+ return lastAssistantMessage;
156
+ } finally {
157
+ if (timeoutId !== void 0) {
158
+ clearTimeout(timeoutId);
159
+ }
160
+ unsubscribe();
161
+ }
162
+ }
163
+ on(eventTypeOrHandler, handler) {
164
+ if (typeof eventTypeOrHandler === "string" && handler) {
165
+ const eventType = eventTypeOrHandler;
166
+ if (!this.typedEventHandlers.has(eventType)) {
167
+ this.typedEventHandlers.set(eventType, /* @__PURE__ */ new Set());
168
+ }
169
+ const storedHandler = handler;
170
+ this.typedEventHandlers.get(eventType).add(storedHandler);
171
+ return () => {
172
+ const handlers = this.typedEventHandlers.get(eventType);
173
+ if (handlers) {
174
+ handlers.delete(storedHandler);
175
+ }
176
+ };
177
+ }
178
+ const wildcardHandler = eventTypeOrHandler;
179
+ this.eventHandlers.add(wildcardHandler);
180
+ return () => {
181
+ this.eventHandlers.delete(wildcardHandler);
182
+ };
183
+ }
184
+ /**
185
+ * Dispatches an event to all registered handlers.
186
+ * Also handles broadcast request events internally (external tool calls, permissions).
187
+ *
188
+ * @param event - The session event to dispatch
189
+ * @internal This method is for internal use by the SDK.
190
+ */
191
+ _dispatchEvent(event) {
192
+ this._handleBroadcastEvent(event);
193
+ const typedHandlers = this.typedEventHandlers.get(event.type);
194
+ if (typedHandlers) {
195
+ for (const handler of typedHandlers) {
196
+ try {
197
+ handler(event);
198
+ } catch (_error) {
199
+ }
200
+ }
201
+ }
202
+ for (const handler of this.eventHandlers) {
203
+ try {
204
+ handler(event);
205
+ } catch (_error) {
206
+ }
207
+ }
208
+ }
209
+ /**
210
+ * Handles broadcast request events by executing local handlers and responding via RPC.
211
+ * Handlers are dispatched as fire-and-forget — rejections propagate as unhandled promise
212
+ * rejections, consistent with standard EventEmitter / event handler semantics.
213
+ * @internal
214
+ */
215
+ _handleBroadcastEvent(event) {
216
+ if (event.type === "external_tool.requested") {
217
+ const { requestId, toolName } = event.data;
218
+ const args = event.data.arguments;
219
+ const toolCallId = event.data.toolCallId;
220
+ const traceparent = event.data.traceparent;
221
+ const tracestate = event.data.tracestate;
222
+ const handler = this.toolHandlers.get(toolName);
223
+ if (handler) {
224
+ void this._executeToolAndRespond(
225
+ requestId,
226
+ toolName,
227
+ toolCallId,
228
+ args,
229
+ handler,
230
+ traceparent,
231
+ tracestate
232
+ );
233
+ }
234
+ } else if (event.type === "permission.requested") {
235
+ const { requestId, permissionRequest } = event.data;
236
+ if (this.permissionHandler) {
237
+ void this._executePermissionAndRespond(requestId, permissionRequest);
238
+ }
239
+ }
240
+ }
241
+ /**
242
+ * Executes a tool handler and sends the result back via RPC.
243
+ * @internal
244
+ */
245
+ async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate) {
246
+ try {
247
+ const rawResult = await handler(args, {
248
+ sessionId: this.sessionId,
249
+ toolCallId,
250
+ toolName,
251
+ arguments: args,
252
+ traceparent,
253
+ tracestate
254
+ });
255
+ let result;
256
+ if (rawResult == null) {
257
+ result = "";
258
+ } else if (typeof rawResult === "string") {
259
+ result = rawResult;
260
+ } else {
261
+ result = JSON.stringify(rawResult);
262
+ }
263
+ await this.rpc.tools.handlePendingToolCall({ requestId, result });
264
+ } catch (error) {
265
+ const message = error instanceof Error ? error.message : String(error);
266
+ try {
267
+ await this.rpc.tools.handlePendingToolCall({ requestId, error: message });
268
+ } catch (rpcError) {
269
+ if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
270
+ throw rpcError;
271
+ }
272
+ }
273
+ }
274
+ }
275
+ /**
276
+ * Executes a permission handler and sends the result back via RPC.
277
+ * @internal
278
+ */
279
+ async _executePermissionAndRespond(requestId, permissionRequest) {
280
+ try {
281
+ const result = await this.permissionHandler(permissionRequest, {
282
+ sessionId: this.sessionId
283
+ });
284
+ if (result.kind === "no-result") {
285
+ return;
286
+ }
287
+ await this.rpc.permissions.handlePendingPermissionRequest({ requestId, result });
288
+ } catch (_error) {
289
+ try {
290
+ await this.rpc.permissions.handlePendingPermissionRequest({
291
+ requestId,
292
+ result: {
293
+ kind: "denied-no-approval-rule-and-could-not-request-from-user"
294
+ }
295
+ });
296
+ } catch (rpcError) {
297
+ if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
298
+ throw rpcError;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ /**
304
+ * Registers custom tool handlers for this session.
305
+ *
306
+ * Tools allow the assistant to execute custom functions. When the assistant
307
+ * invokes a tool, the corresponding handler is called with the tool arguments.
308
+ *
309
+ * @param tools - An array of tool definitions with their handlers, or undefined to clear all tools
310
+ * @internal This method is typically called internally when creating a session with tools.
311
+ */
312
+ registerTools(tools) {
313
+ this.toolHandlers.clear();
314
+ if (!tools) {
315
+ return;
316
+ }
317
+ for (const tool of tools) {
318
+ this.toolHandlers.set(tool.name, tool.handler);
319
+ }
320
+ }
321
+ /**
322
+ * Retrieves a registered tool handler by name.
323
+ *
324
+ * @param name - The name of the tool to retrieve
325
+ * @returns The tool handler if found, or undefined
326
+ * @internal This method is for internal use by the SDK.
327
+ */
328
+ getToolHandler(name) {
329
+ return this.toolHandlers.get(name);
330
+ }
331
+ /**
332
+ * Registers a handler for permission requests.
333
+ *
334
+ * When the assistant needs permission to perform certain actions (e.g., file operations),
335
+ * this handler is called to approve or deny the request.
336
+ *
337
+ * @param handler - The permission handler function, or undefined to remove the handler
338
+ * @internal This method is typically called internally when creating a session.
339
+ */
340
+ registerPermissionHandler(handler) {
341
+ this.permissionHandler = handler;
342
+ }
343
+ /**
344
+ * Registers a user input handler for ask_user requests.
345
+ *
346
+ * When the agent needs input from the user (via ask_user tool),
347
+ * this handler is called to provide the response.
348
+ *
349
+ * @param handler - The user input handler function, or undefined to remove the handler
350
+ * @internal This method is typically called internally when creating a session.
351
+ */
352
+ registerUserInputHandler(handler) {
353
+ this.userInputHandler = handler;
354
+ }
355
+ /**
356
+ * Registers hook handlers for session lifecycle events.
357
+ *
358
+ * Hooks allow custom logic to be executed at various points during
359
+ * the session lifecycle (before/after tool use, session start/end, etc.).
360
+ *
361
+ * @param hooks - The hook handlers object, or undefined to remove all hooks
362
+ * @internal This method is typically called internally when creating a session.
363
+ */
364
+ registerHooks(hooks) {
365
+ this.hooks = hooks;
366
+ }
367
+ /**
368
+ * Handles a permission request in the v2 protocol format (synchronous RPC).
369
+ * Used as a back-compat adapter when connected to a v2 server.
370
+ *
371
+ * @param request - The permission request data from the CLI
372
+ * @returns A promise that resolves with the permission decision
373
+ * @internal This method is for internal use by the SDK.
374
+ */
375
+ async _handlePermissionRequestV2(request) {
376
+ if (!this.permissionHandler) {
377
+ return { kind: "denied-no-approval-rule-and-could-not-request-from-user" };
378
+ }
379
+ try {
380
+ const result = await this.permissionHandler(request, {
381
+ sessionId: this.sessionId
382
+ });
383
+ if (result.kind === "no-result") {
384
+ throw new Error(NO_RESULT_PERMISSION_V2_ERROR);
385
+ }
386
+ return result;
387
+ } catch (error) {
388
+ if (error instanceof Error && error.message === NO_RESULT_PERMISSION_V2_ERROR) {
389
+ throw error;
390
+ }
391
+ return { kind: "denied-no-approval-rule-and-could-not-request-from-user" };
392
+ }
393
+ }
394
+ /**
395
+ * Handles a user input request from the Copilot CLI.
396
+ *
397
+ * @param request - The user input request data from the CLI
398
+ * @returns A promise that resolves with the user's response
399
+ * @internal This method is for internal use by the SDK.
400
+ */
401
+ async _handleUserInputRequest(request) {
402
+ if (!this.userInputHandler) {
403
+ throw new Error("User input requested but no handler registered");
404
+ }
405
+ try {
406
+ const result = await this.userInputHandler(request, {
407
+ sessionId: this.sessionId
408
+ });
409
+ return result;
410
+ } catch (error) {
411
+ throw error;
412
+ }
413
+ }
414
+ /**
415
+ * Handles a hooks invocation from the Copilot CLI.
416
+ *
417
+ * @param hookType - The type of hook being invoked
418
+ * @param input - The input data for the hook
419
+ * @returns A promise that resolves with the hook output, or undefined
420
+ * @internal This method is for internal use by the SDK.
421
+ */
422
+ async _handleHooksInvoke(hookType, input) {
423
+ if (!this.hooks) {
424
+ return void 0;
425
+ }
426
+ const handlerMap = {
427
+ preToolUse: this.hooks.onPreToolUse,
428
+ postToolUse: this.hooks.onPostToolUse,
429
+ userPromptSubmitted: this.hooks.onUserPromptSubmitted,
430
+ sessionStart: this.hooks.onSessionStart,
431
+ sessionEnd: this.hooks.onSessionEnd,
432
+ errorOccurred: this.hooks.onErrorOccurred
433
+ };
434
+ const handler = handlerMap[hookType];
435
+ if (!handler) {
436
+ return void 0;
437
+ }
438
+ try {
439
+ const result = await handler(input, { sessionId: this.sessionId });
440
+ return result;
441
+ } catch (_error) {
442
+ return void 0;
443
+ }
444
+ }
445
+ /**
446
+ * Retrieves all events and messages from this session's history.
447
+ *
448
+ * This returns the complete conversation history including user messages,
449
+ * assistant responses, tool executions, and other session events.
450
+ *
451
+ * @returns A promise that resolves with an array of all session events
452
+ * @throws Error if the session has been disconnected or the connection fails
453
+ *
454
+ * @example
455
+ * ```typescript
456
+ * const events = await session.getMessages();
457
+ * for (const event of events) {
458
+ * if (event.type === "assistant.message") {
459
+ * console.log("Assistant:", event.data.content);
460
+ * }
461
+ * }
462
+ * ```
463
+ */
464
+ async getMessages() {
465
+ const response = await this.connection.sendRequest("session.getMessages", {
466
+ sessionId: this.sessionId
467
+ });
468
+ return response.events;
469
+ }
470
+ /**
471
+ * Disconnects this session and releases all in-memory resources (event handlers,
472
+ * tool handlers, permission handlers).
473
+ *
474
+ * Session state on disk (conversation history, planning state, artifacts) is
475
+ * preserved, so the conversation can be resumed later by calling
476
+ * {@link CopilotClient.resumeSession} with the session ID. To permanently
477
+ * remove all session data including files on disk, use
478
+ * {@link CopilotClient.deleteSession} instead.
479
+ *
480
+ * After calling this method, the session object can no longer be used.
481
+ *
482
+ * @returns A promise that resolves when the session is disconnected
483
+ * @throws Error if the connection fails
484
+ *
485
+ * @example
486
+ * ```typescript
487
+ * // Clean up when done — session can still be resumed later
488
+ * await session.disconnect();
489
+ * ```
490
+ */
491
+ async disconnect() {
492
+ await this.connection.sendRequest("session.destroy", {
493
+ sessionId: this.sessionId
494
+ });
495
+ this.eventHandlers.clear();
496
+ this.typedEventHandlers.clear();
497
+ this.toolHandlers.clear();
498
+ this.permissionHandler = void 0;
499
+ }
500
+ /**
501
+ * @deprecated Use {@link disconnect} instead. This method will be removed in a future release.
502
+ *
503
+ * Disconnects this session and releases all in-memory resources.
504
+ * Session data on disk is preserved for later resumption.
505
+ *
506
+ * @returns A promise that resolves when the session is disconnected
507
+ * @throws Error if the connection fails
508
+ */
509
+ async destroy() {
510
+ return this.disconnect();
511
+ }
512
+ /** Enables `await using session = ...` syntax for automatic cleanup. */
513
+ async [Symbol.asyncDispose]() {
514
+ return this.disconnect();
515
+ }
516
+ /**
517
+ * Aborts the currently processing message in this session.
518
+ *
519
+ * Use this to cancel a long-running request. The session remains valid
520
+ * and can continue to be used for new messages.
521
+ *
522
+ * @returns A promise that resolves when the abort request is acknowledged
523
+ * @throws Error if the session has been disconnected or the connection fails
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * // Start a long-running request
528
+ * const messagePromise = session.send({ prompt: "Write a very long story..." });
529
+ *
530
+ * // Abort after 5 seconds
531
+ * setTimeout(async () => {
532
+ * await session.abort();
533
+ * }, 5000);
534
+ * ```
535
+ */
536
+ async abort() {
537
+ await this.connection.sendRequest("session.abort", {
538
+ sessionId: this.sessionId
539
+ });
540
+ }
541
+ /**
542
+ * Change the model for this session.
543
+ * The new model takes effect for the next message. Conversation history is preserved.
544
+ *
545
+ * @param model - Model ID to switch to
546
+ * @param options - Optional settings for the new model
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * await session.setModel("gpt-4.1");
551
+ * await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
552
+ * ```
553
+ */
554
+ async setModel(model, options) {
555
+ await this.rpc.model.switchTo({ modelId: model, ...options });
556
+ }
557
+ /**
558
+ * Log a message to the session timeline.
559
+ * The message appears in the session event stream and is visible to SDK consumers
560
+ * and (for non-ephemeral messages) persisted to the session event log on disk.
561
+ *
562
+ * @param message - Human-readable message text
563
+ * @param options - Optional log level and ephemeral flag
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * await session.log("Processing started");
568
+ * await session.log("Disk usage high", { level: "warning" });
569
+ * await session.log("Connection failed", { level: "error" });
570
+ * await session.log("Debug info", { ephemeral: true });
571
+ * ```
572
+ */
573
+ async log(message, options) {
574
+ await this.rpc.log({ message, ...options });
575
+ }
576
+ }
577
+ // Annotate the CommonJS export names for ESM import in node:
578
+ 0 && (module.exports = {
579
+ CopilotSession,
580
+ NO_RESULT_PERMISSION_V2_ERROR
581
+ });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var telemetry_exports = {};
20
+ __export(telemetry_exports, {
21
+ getTraceContext: () => getTraceContext
22
+ });
23
+ module.exports = __toCommonJS(telemetry_exports);
24
+ async function getTraceContext(provider) {
25
+ if (!provider) return {};
26
+ try {
27
+ return await provider() ?? {};
28
+ } catch {
29
+ return {};
30
+ }
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ getTraceContext
35
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ approveAll: () => approveAll,
22
+ defineTool: () => defineTool
23
+ });
24
+ module.exports = __toCommonJS(types_exports);
25
+ function defineTool(name, config) {
26
+ return { name, ...config };
27
+ }
28
+ const approveAll = () => ({ kind: "approved" });
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ approveAll,
32
+ defineTool
33
+ });
package/dist/client.d.ts CHANGED
@@ -47,6 +47,7 @@ export declare class CopilotClient {
47
47
  private isExternalServer;
48
48
  private forceStopping;
49
49
  private onListModels?;
50
+ private onGetTraceContext?;
50
51
  private modelsCache;
51
52
  private modelsCacheLock;
52
53
  private sessionLifecycleHandlers;