@github/copilot-sdk 1.0.28 → 1.0.29-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@
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, ModelGetReasoningSummariesRequest, ModelGetReasoningSummariesResult, SandboxConfig, AutopilotOptions, } from "./generated/rpc.js";
7
+ export type { HostLocalServerOptions, HostGitHubEnvironmentOptions, Model, ModelGetReasoningSummariesRequest, ModelGetReasoningSummariesResult, SandboxConfig, AutopilotOptions, } from "./generated/rpc.js";
8
8
  export { AhpHost, type AhpHostExit, type AhpHostOptions, type AhpHostAuthentication, type AhpSessionAuthentication, type AhpSessionCreateRequest, type AhpSessionResumeRequest, } from "./host.js";
9
9
  export { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
10
10
  export { BuiltInTools, ToolSet } from "./toolSet.js";
@@ -13,5 +13,5 @@ export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./wo
13
13
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
14
14
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SessionFsWriteFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
15
15
  export type * from "./generated/session-events.js";
16
- export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, SubagentStartHandler, SubagentStartHookInput, SubagentStartHookOutput, SubagentStopHandler, SubagentStopHookInput, SubagentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, EntraAuthConfig, 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, ProviderConfigModelProvider, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, WorkingDirectoryTrust, 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, SkillProvider, SkillProviderCallOptions, SkillProviderDescriptor, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolNamespace, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, ImageGenerationConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
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";
16
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, SubagentStartHandler, SubagentStartHookInput, SubagentStartHookOutput, SubagentStopHandler, SubagentStopHookInput, SubagentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, EntraAuthConfig, EntraAuthOptions, EntraTokenProvider, EntraTokenProviderArgs, EntraTokenProviderResult, 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, KerberosAuthAcquireRequest, KerberosAuthConfig, KerberosAuthMode, KerberosAuthScope, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, HostDiagnostics, HostErrorReportingStatus, 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, ProviderConfigModelProvider, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, WorkingDirectoryTrust, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsByteRange, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, SkillProvider, SkillProviderCallOptions, SkillProviderDescriptor, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolNamespace, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, ImageGenerationConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
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, WorkflowAgentContextObservation, WorkflowAgentModelObservation, WorkflowAgentReasoningEffortObservation, WorkflowAgentSummary, } from "./workflow.js";
@@ -1,4 +1,4 @@
1
- import { type CancellationToken, type MessageConnection } from "vscode-jsonrpc/node.js";
1
+ import type { CancellationToken, MessageConnection } from "./jsonrpcTypes.js";
2
2
  import type { InstallationConfirmationRequest, InstallationDecision, InstallationsConfirmResult } from "./generated/rpc.js";
3
3
  /** The `installations.confirm` receiver, invoked with the transport's request cancellation. */
4
4
  export interface InstallationConfirmationReceiver {
@@ -1,7 +1,4 @@
1
- import {
2
- CancellationTokenSource,
3
- ResponseError
4
- } from "vscode-jsonrpc/node.js";
1
+ import { CancellationTokenSource, ResponseError } from "vscode-jsonrpc/node";
5
2
  function createInstallationConfirmationAdapter(connection, handler) {
6
3
  const closed = new CancellationTokenSource();
7
4
  const closeSubscription = connection.onClose(() => closed.cancel());
@@ -0,0 +1,14 @@
1
+ export interface Disposable {
2
+ dispose(): void;
3
+ }
4
+ export interface CancellationToken {
5
+ readonly isCancellationRequested: boolean;
6
+ readonly onCancellationRequested: <T>(listener: (event: T) => unknown, thisArgs?: unknown, disposables?: Disposable[]) => Disposable;
7
+ }
8
+ export interface MessageConnection {
9
+ sendRequest<R>(method: string, params?: unknown): Promise<R>;
10
+ onRequest<P, R>(method: string, handler: (params: P, token: CancellationToken) => R | Promise<R>): Disposable;
11
+ onNotification<P>(method: string, handler: (params: P) => void | Promise<void>): Disposable;
12
+ onClose(listener: () => void): Disposable;
13
+ onDispose(listener: () => void): Disposable;
14
+ }
File without changes
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The SDK protocol version.
3
- * This must match the version expected by the copilot-agent-runtime server.
3
+ * This must match the version expected by the Copilot runtime server.
4
4
  */
5
5
  export declare const SDK_PROTOCOL_VERSION = 3;
6
6
  /**
package/dist/session.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  ConnectionError,
5
5
  ErrorCodes,
6
6
  ResponseError
7
- } from "vscode-jsonrpc/node.js";
7
+ } from "vscode-jsonrpc/node";
8
8
  import { createInternalSessionRpc, createSessionRpc } from "./generated/rpc.js";
9
9
  import { CanvasError } from "./canvas.js";
10
10
  import { getTraceContext } from "./telemetry.js";
@@ -245,6 +245,15 @@ function isWorkflowAbortError(error) {
245
245
  function isWorkflowFatalError(error) {
246
246
  return isWorkflowAbortError(error) || error instanceof ResponseError || error instanceof ConnectionError;
247
247
  }
248
+ const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
249
+ function setLongTimeout(callback, delayMs) {
250
+ let timer;
251
+ const arm = (remainingMs) => {
252
+ timer = remainingMs > MAX_TIMER_DELAY_MS ? setTimeout(() => arm(remainingMs - MAX_TIMER_DELAY_MS), MAX_TIMER_DELAY_MS) : setTimeout(callback, remainingMs);
253
+ };
254
+ arm(delayMs);
255
+ return () => clearTimeout(timer);
256
+ }
248
257
  const TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
249
258
  class CopilotSession {
250
259
  /**
@@ -655,11 +664,11 @@ class CopilotSession {
655
664
  else resolveOutcome({ kind: "error", error });
656
665
  };
657
666
  this.pendingResponseWaits.add(fail);
658
- let timeoutId;
667
+ let cancelTimeout;
659
668
  let waiting = true;
660
669
  try {
661
670
  const timeoutPromise = new Promise((_, reject) => {
662
- timeoutId = setTimeout(
671
+ cancelTimeout = setLongTimeout(
663
672
  () => reject(
664
673
  new Error(
665
674
  `Timeout after ${effectiveTimeout}ms waiting for response completion`
@@ -687,9 +696,7 @@ class CopilotSession {
687
696
  return outcome.message;
688
697
  } finally {
689
698
  waiting = false;
690
- if (timeoutId !== void 0) {
691
- clearTimeout(timeoutId);
692
- }
699
+ cancelTimeout?.();
693
700
  unsubscribe();
694
701
  buffered.length = 0;
695
702
  this.pendingResponseWaits.delete(fail);
@@ -723,7 +730,7 @@ class CopilotSession {
723
730
  fail = reject;
724
731
  });
725
732
  this.pendingResponseWaits.add(fail);
726
- const timer = setTimeout(
733
+ const cancelTimeout = setLongTimeout(
727
734
  () => fail(new Error(`Timeout after ${timeout}ms waiting for session.idle`)),
728
735
  timeout
729
736
  );
@@ -762,7 +769,7 @@ class CopilotSession {
762
769
  try {
763
770
  return await Promise.race([operation(), stopped]);
764
771
  } finally {
765
- clearTimeout(timer);
772
+ cancelTimeout();
766
773
  unsubscribe();
767
774
  this.pendingResponseWaits.delete(fail);
768
775
  resolveDispatched();
@@ -820,7 +827,7 @@ class CopilotSession {
820
827
  });
821
828
  this.pendingStructuredWaits.add(fail);
822
829
  let waiting = true;
823
- const timer = setTimeout(
830
+ const cancelTimeout = setLongTimeout(
824
831
  () => fail(new Error(`Timeout after ${timeout}ms waiting for the structured response`)),
825
832
  timeout
826
833
  );
@@ -847,7 +854,7 @@ class CopilotSession {
847
854
  return outcome.message;
848
855
  } finally {
849
856
  waiting = false;
850
- clearTimeout(timer);
857
+ cancelTimeout();
851
858
  buffered.length = 0;
852
859
  unsubscribe();
853
860
  this.pendingStructuredWaits.delete(fail);
@@ -1004,12 +1011,23 @@ class CopilotSession {
1004
1011
  }
1005
1012
  }
1006
1013
  } else if (event.type === "permission.requested") {
1007
- const { requestId, permissionRequest, promptRequest, resolvedByHook } = event.data;
1014
+ const {
1015
+ requestId,
1016
+ permissionRequest,
1017
+ promptRequest,
1018
+ assistedApprovalAssessment,
1019
+ resolvedByHook
1020
+ } = event.data;
1008
1021
  if (resolvedByHook) {
1009
1022
  return;
1010
1023
  }
1011
1024
  if (this.permissionHandler) {
1012
- void this._executePermissionAndRespond(requestId, permissionRequest, promptRequest);
1025
+ void this._executePermissionAndRespond(
1026
+ requestId,
1027
+ permissionRequest,
1028
+ promptRequest,
1029
+ assistedApprovalAssessment
1030
+ );
1013
1031
  }
1014
1032
  } else if (event.type === "mcp.oauth_required") {
1015
1033
  const data = event.data;
@@ -1028,15 +1046,7 @@ class CopilotSession {
1028
1046
  void this._executeCommandAndRespond(requestId, commandName, command, args);
1029
1047
  } else if (event.type === "elicitation.requested") {
1030
1048
  if (this.elicitationHandler) {
1031
- const {
1032
- message,
1033
- requestedSchema,
1034
- mode,
1035
- elicitationSource,
1036
- elicitationSourceDisplayName,
1037
- url,
1038
- requestId
1039
- } = event.data;
1049
+ const { message, requestedSchema, mode, elicitationSource, url, requestId } = event.data;
1040
1050
  void this._handleElicitationRequest(
1041
1051
  {
1042
1052
  sessionId: this.sessionId,
@@ -1044,14 +1054,17 @@ class CopilotSession {
1044
1054
  requestedSchema,
1045
1055
  mode,
1046
1056
  elicitationSource,
1047
- elicitationSourceDisplayName,
1048
1057
  url
1049
1058
  },
1050
1059
  requestId
1051
1060
  );
1052
1061
  }
1053
1062
  } else if (event.type === "capabilities.changed") {
1054
- this._capabilities = { ...this._capabilities, ...event.data };
1063
+ const { ui, ...changed } = event.data;
1064
+ this._capabilities = { ...this._capabilities, ...changed };
1065
+ if (ui) {
1066
+ this._capabilities.ui = { ...this._capabilities.ui, ...ui };
1067
+ }
1055
1068
  } else if (event.type === "session.canvas.opened") {
1056
1069
  this.upsertOpenCanvasFromEvent(event.data);
1057
1070
  } else if (event.type === "session.canvas.closed") {
@@ -1177,12 +1190,13 @@ class CopilotSession {
1177
1190
  * Executes a permission handler and sends the result back via RPC.
1178
1191
  * @internal
1179
1192
  */
1180
- async _executePermissionAndRespond(requestId, permissionRequest, promptRequest) {
1193
+ async _executePermissionAndRespond(requestId, permissionRequest, promptRequest, assistedApprovalAssessment) {
1181
1194
  try {
1182
1195
  const invocation = {
1183
1196
  sessionId: this.sessionId,
1184
1197
  managedSettingsEnabled: this.managedSettingsEnabled,
1185
- ...promptRequest === void 0 ? {} : { promptRequest }
1198
+ ...promptRequest === void 0 ? {} : { promptRequest },
1199
+ ...assistedApprovalAssessment === void 0 ? {} : { assistedApprovalAssessment }
1186
1200
  };
1187
1201
  const handlerResult = await this.permissionHandler(permissionRequest, invocation);
1188
1202
  const isAttributed = isAttributedPermissionResult(handlerResult);
@@ -6,6 +6,13 @@ export type { SessionFsSqliteQueryType, SessionFsSqliteTransactionErrorClass };
6
6
  * `error` field, since providers signal errors by throwing.
7
7
  */
8
8
  export type SessionFsFileInfo = Omit<SessionFsStatResult, "error">;
9
+ /** Raw bytes and the authoritative total file byte length captured by the same read. */
10
+ export interface SessionFsByteRange {
11
+ /** Requested bytes; boundaries may split UTF-8 characters. */
12
+ content: Uint8Array;
13
+ /** Total file byte length, independent of the requested range. */
14
+ byteLength: number;
15
+ }
9
16
  /**
10
17
  * Result of a SQLite query execution via {@link SessionFsSqliteProvider.query}.
11
18
  * Same shape as the generated {@link GeneratedSqliteQueryResult} but without the
@@ -84,6 +91,14 @@ export interface SessionFsProvider {
84
91
  readFile(path: string): Promise<string>;
85
92
  /** Read exact file bytes. Required when capabilities.binary is enabled. */
86
93
  readFileBytes?(path: string): Promise<Uint8Array>;
94
+ /**
95
+ * Reads raw bytes starting at a non-negative safe integer byte offset.
96
+ * Omit length to read through EOF; zero returns only byte length.
97
+ * At or beyond EOF, content is empty. Advertise capabilities.readFileRange
98
+ * only when every provider implements bounded reads without full-file downloads.
99
+ * This capability is independent of binary reads and writes.
100
+ */
101
+ readFileRange?(path: string, offset: number, length?: number): Promise<SessionFsByteRange>;
87
102
  /** Write exact file bytes. Required when capabilities.binary is enabled. */
88
103
  writeFileBytes?(path: string, content: Uint8Array, mode?: number): Promise<void>;
89
104
  /** Writes content to a file, creating parent directories if needed. Throw {@link SessionFsWriteFailure} if a failed write changed the target. */
@@ -26,6 +26,34 @@ function normalizeSqliteParams(params) {
26
26
  }
27
27
  function createSessionFsAdapter(provider) {
28
28
  return {
29
+ readFileRange: async ({ path, offset, length }) => {
30
+ try {
31
+ if (!Number.isSafeInteger(offset) || offset < 0 || length !== void 0 && (!Number.isSafeInteger(length) || length < 0)) {
32
+ throw new RangeError(
33
+ "SessionFs byte offset and length must be non-negative safe integers"
34
+ );
35
+ }
36
+ if (!provider.readFileRange) {
37
+ throw new Error(
38
+ "Byte-range reads are not supported by this SessionFs provider"
39
+ );
40
+ }
41
+ const result = await provider.readFileRange(path, offset, length);
42
+ if (!Number.isSafeInteger(result.byteLength) || result.byteLength < 0) {
43
+ throw new Error("SessionFs byte length must be a non-negative safe integer");
44
+ }
45
+ const available = Math.max(0, result.byteLength - offset);
46
+ if (result.content.byteLength !== Math.min(length ?? available, available)) {
47
+ throw new Error("SessionFs returned an incorrect byte range length");
48
+ }
49
+ return {
50
+ content: Buffer.from(result.content).toString("base64"),
51
+ byteLength: result.byteLength
52
+ };
53
+ } catch (err) {
54
+ return { content: "", byteLength: 0, error: toSessionFsError(err) };
55
+ }
56
+ },
29
57
  readFile: async ({ path }) => {
30
58
  try {
31
59
  const content = await provider.readFile(path);
package/dist/types.d.ts CHANGED
@@ -6,16 +6,17 @@ import type { SessionFsProvider } from "./sessionFsProvider.js";
6
6
  import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
7
7
  import type { InstallationConfirmationHandler } from "./installationConfirmation.js";
8
8
  export type { InstallationConfirmationHandler } from "./installationConfirmation.js";
9
- import type { AgentModelPolicy, AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
9
+ import type { AgentModelPolicy, AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, ModelProviderRef, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
10
10
  import type { CopilotSession } from "./session.js";
11
11
  import type { JsonValue } from "./workflow.js";
12
- import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, AutopilotOptions, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, ProtocolExternalToolNamespace, CurrentToolMetadata, SandboxConfig } from "./generated/rpc.js";
12
+ import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, AutopilotOptions, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, HostDiagnostics, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, ProtocolExternalToolNamespace, CurrentToolMetadata, KerberosAuthAcquireRequest, KerberosAuthMode, KerberosAuthScope, SandboxConfig } from "./generated/rpc.js";
13
13
  import type { ToolSet } from "./toolSet.js";
14
+ export type { KerberosAuthAcquireRequest, KerberosAuthMode, KerberosAuthScope, } from "./generated/rpc.js";
14
15
  export type { RemoteSessionMode } from "./generated/rpc.js";
15
16
  export type { AutopilotOptions } from "./generated/rpc.js";
16
17
  export type { CurrentToolMetadata } from "./generated/rpc.js";
17
18
  export type { SandboxConfig, SandboxConfigSource } from "./generated/rpc.js";
18
- export type { AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, ExtensionLaunchProfile, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, } from "./generated/rpc.js";
19
+ export type { AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, ExtensionLaunchProfile, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, HostDiagnostics, HostErrorReportingStatus, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, } from "./generated/rpc.js";
19
20
  /**
20
21
  * Arguments passed to a session's {@link GitHubTokenProvider}.
21
22
  *
@@ -43,6 +44,7 @@ export type { CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus
43
44
  export type { SessionFsProvider } from "./sessionFsProvider.js";
44
45
  export { createSessionFsAdapter } from "./sessionFsProvider.js";
45
46
  export type { SessionFsFileInfo } from "./sessionFsProvider.js";
47
+ export type { SessionFsByteRange } from "./sessionFsProvider.js";
46
48
  export type { SessionFsSqliteQueryResult } from "./sessionFsProvider.js";
47
49
  export type { SessionFsSqliteQueryType } from "./sessionFsProvider.js";
48
50
  export type { SessionFsSqliteProvider } from "./sessionFsProvider.js";
@@ -91,7 +93,7 @@ export interface TelemetryConfig {
91
93
  exporterType?: string;
92
94
  /** Instrumentation scope name. Sets COPILOT_OTEL_SOURCE_NAME. */
93
95
  sourceName?: string;
94
- /** Whether to capture message content (prompts, responses). Sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT. */
96
+ /** Whether to capture span content. Sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT and its legacy boolean alias. */
95
97
  captureContent?: boolean;
96
98
  }
97
99
  /**
@@ -150,7 +152,6 @@ export interface InProcessRuntimeConnection {
150
152
  * Required for OneAuth interactive authentication on macOS. This general-purpose
151
153
  * scheduler may also be used for other runtime-owned native UI operations.
152
154
  * Temporary OneAuth workaround; this API may be removed if no longer needed.
153
- * See https://github.com/github/copilot-agent-runtime/issues/27032.
154
155
  * @experimental
155
156
  */
156
157
  readonly runOnUiThread?: (action: () => void) => void | Promise<void>;
@@ -265,14 +266,31 @@ export interface CopilotClientInfo {
265
266
  */
266
267
  integrationVersion?: string;
267
268
  }
268
- export type EntraAuthConfig = import("./generated/rpc.js").EntraAuthConfig;
269
+ /** Host application's Microsoft Entra registration. @experimental */
270
+ export type EntraAuthConfig = Pick<import("./generated/rpc.js").EntraAuthConfig, "clientId" | "matsAppName">;
271
+ /** Host-owned Entra identity or resource acquisition. @experimental */
272
+ export type EntraTokenProviderArgs = import("./generated/rpc.js").EntraTokenAcquireRequest;
273
+ /** Response matching the requested acquisition kind and pinned account. @experimental */
274
+ export type EntraTokenProviderResult = import("./generated/rpc.js").EntraTokenAcquireResult;
275
+ /**
276
+ * Selects/revalidates an identity or acquires its resource token. Renewal must be
277
+ * silent and account-pinned. Cancellation and unavailability never open runtime sign-in.
278
+ * The cancellation token fires when the request or original connection ends.
279
+ * @experimental
280
+ */
281
+ export type EntraTokenProvider = (request: EntraTokenProviderArgs, cancellation: import("./jsonrpcTypes.js").CancellationToken) => EntraTokenProviderResult | Promise<EntraTokenProviderResult>;
282
+ /** Entra application and optional host-owned acquisition. @experimental */
283
+ export interface EntraAuthOptions extends EntraAuthConfig {
284
+ /** Host-owned acquisition; omission retains built-in runtime authentication. @experimental */
285
+ tokenProvider?: EntraTokenProvider;
286
+ }
269
287
  export interface CopilotClientOptions {
270
288
  /**
271
289
  * Host application's Microsoft Entra registration, shared by its sessions.
272
290
  * Required for built-in Entra sign-in and token renewal; other authentication methods remain available.
273
291
  * @experimental
274
292
  */
275
- entra?: EntraAuthConfig;
293
+ entra?: EntraAuthOptions;
276
294
  /**
277
295
  * How to connect to the Copilot runtime. When omitted, defaults to
278
296
  * {@link RuntimeConnection.forStdio} with the bundled runtime.
@@ -317,6 +335,10 @@ export interface CopilotClientOptions {
317
335
  * @experimental
318
336
  */
319
337
  extensionLaunchProvider?: ExtensionLaunchProvider;
338
+ /**
339
+ * Supplies Kerberos credentials from the SDK host. Registered before sessions start.
340
+ */
341
+ kerberosAuth?: KerberosAuthConfig;
320
342
  /**
321
343
  * Connection-global human review for experimental installation operations.
322
344
  * Does not register or enable installation capabilities on the runtime.
@@ -341,7 +363,8 @@ export interface CopilotClientOptions {
341
363
  /**
342
364
  * Whether to use the logged-in user for authentication.
343
365
  * When true, the runtime will attempt to use stored OAuth tokens or gh CLI auth.
344
- * When false, only explicit tokens (gitHubToken or environment variables) are used.
366
+ * When false, only explicit tokens such as gitHubToken are used; environment variable
367
+ * tokens (COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN) are ignored.
345
368
  * @default true (but defaults to false when gitHubToken is provided)
346
369
  */
347
370
  useLoggedInUser?: boolean;
@@ -444,6 +467,26 @@ export interface CopilotClientOptions {
444
467
  }
445
468
  /** Resolves launch profiles for extension entrypoints discovered by the runtime. */
446
469
  export type ExtensionLaunchProvider = GeneratedExtensionLaunchProvider;
470
+ /** Supplies Kerberos credentials from the SDK host for a requested service principal. */
471
+ export interface KerberosAuthConfig {
472
+ /** `fallback` uses the callback only when native lookup fails; `always` never attempts native lookup. */
473
+ mode: KerberosAuthMode;
474
+ /**
475
+ * `connection` (the default) authenticates only requests made for sessions this client creates or resumes;
476
+ * `runtime` also authenticates the runtime's shared background traffic. Only one connection at a time can
477
+ * hold `runtime` scope, so startup fails if another client holds it. The registration ends when the
478
+ * connection closes.
479
+ */
480
+ scope?: KerberosAuthScope;
481
+ /**
482
+ * Returns a fresh, single-use base64 SPNEGO token without the `Negotiate ` prefix, or `undefined` when unavailable.
483
+ * The SPN uses the platform-independent `service/host[@REALM]` form; validate it before issuing credentials.
484
+ * `signal` aborts when the runtime stops waiting: it cancels the request (for example when its wait times
485
+ * out) or the connection closes. The SDK then stops awaiting the callback and ignores any later result,
486
+ * so pass `signal` to credential lookups that support cancellation.
487
+ */
488
+ callback: (request: KerberosAuthAcquireRequest, signal: AbortSignal) => Promise<string | undefined>;
489
+ }
447
490
  /**
448
491
  * Configuration for creating a session
449
492
  */
@@ -854,7 +897,7 @@ export interface ElicitationResult {
854
897
  /** User action: "accept" (submitted), "decline" (rejected), or "cancel" (dismissed). */
855
898
  action: "accept" | "decline" | "cancel";
856
899
  /** Form values submitted by the user (present when action is "accept"). */
857
- content?: Record<string, ElicitationFieldValue>;
900
+ content?: Record<string, ElicitationFieldValue | undefined>;
858
901
  }
859
902
  /**
860
903
  * Parameters for a raw elicitation request.
@@ -880,8 +923,6 @@ export interface ElicitationContext {
880
923
  mode?: "form" | "url";
881
924
  /** The source that initiated the request (e.g. MCP server name). */
882
925
  elicitationSource?: string;
883
- /** Trusted display label of a Connector-owned MCP server that initiated the request, such as "Work IQ". */
884
- elicitationSourceDisplayName?: string;
885
926
  /** URL to open in the user's browser (url mode only). */
886
927
  url?: string;
887
928
  }
@@ -1098,6 +1139,16 @@ export declare function createAttributedPermissionResult(result: PermissionReque
1098
1139
  export interface PermissionHandlerInvocation {
1099
1140
  sessionId: string;
1100
1141
  managedSettingsEnabled?: boolean;
1142
+ /**
1143
+ * Canonical runtime-owned Assisted Permissions assessment.
1144
+ *
1145
+ * This explains the assisted review only; `permission.completed` remains
1146
+ * authoritative for the final permission result. It is absent with older
1147
+ * runtimes and legacy direct permission callbacks.
1148
+ *
1149
+ * @experimental
1150
+ */
1151
+ assistedApprovalAssessment?: PermissionRequestedData["assistedApprovalAssessment"];
1101
1152
  /**
1102
1153
  * Derived user-facing prompt context when supplied by the runtime.
1103
1154
  *
@@ -1210,9 +1261,13 @@ export interface BaseHookInput {
1210
1261
  agentType?: string;
1211
1262
  /** Immediate parent actor ID, when available. */
1212
1263
  parentAgentId?: string;
1264
+ /** W3C trace context for the runtime span associated with this hook, when available. */
1265
+ traceparent?: string;
1266
+ /** W3C vendor trace state associated with traceparent, when available. */
1267
+ tracestate?: string;
1213
1268
  /** The runtime session ID associated with the hook. Child tool hooks use
1214
1269
  * the child session ID; sub-agent lifecycle hooks use the parent session ID,
1215
- * matching `invocation.sessionId`. */
1270
+ * which can differ from `invocation.sessionId`. */
1216
1271
  sessionId: string;
1217
1272
  /** Time at which the hook event was emitted by the runtime. */
1218
1273
  timestamp: Date;
@@ -1222,6 +1277,8 @@ export interface BaseHookInput {
1222
1277
  * Input for pre-tool-use hook
1223
1278
  */
1224
1279
  export interface PreToolUseHookInput extends BaseHookInput {
1280
+ /** Existing tool-call ID; correlate using (sessionId, toolCallId). Absent on older runtimes. */
1281
+ toolCallId?: string;
1225
1282
  toolName: string;
1226
1283
  toolArgs: unknown;
1227
1284
  }
@@ -1273,6 +1330,8 @@ export type PreMcpToolCallHandler = (input: PreMcpToolCallHookInput, invocation:
1273
1330
  * Input for post-tool-use hook
1274
1331
  */
1275
1332
  export interface PostToolUseHookInput extends BaseHookInput {
1333
+ /** Existing tool-call ID; correlate using (sessionId, toolCallId). Absent on older runtimes. */
1334
+ toolCallId?: string;
1276
1335
  toolName: string;
1277
1336
  toolArgs: unknown;
1278
1337
  toolResult: ToolResultObject;
@@ -1300,6 +1359,8 @@ export type PostToolUseHandler = (input: PostToolUseHookInput, invocation: {
1300
1359
  * stringified failure message extracted from the tool's result, is provided.
1301
1360
  */
1302
1361
  export interface PostToolUseFailureHookInput extends BaseHookInput {
1362
+ /** Existing tool-call ID; correlate using (sessionId, toolCallId). Absent on older runtimes. */
1363
+ toolCallId?: string;
1303
1364
  toolName: string;
1304
1365
  toolArgs: unknown;
1305
1366
  /**
@@ -2312,10 +2373,10 @@ export interface SessionConfigBase {
2312
2373
  models?: ProviderModelConfig[];
2313
2374
  /**
2314
2375
  * Enables or disables internal session telemetry for this session.
2315
- * When `false`, disables session telemetry. When omitted (the default) or `true`,
2316
- * telemetry is enabled for GitHub-authenticated sessions.
2317
- * When a custom {@link provider} (BYOK) is configured, session telemetry is always
2318
- * disabled regardless of this setting.
2376
+ * `false` disables it; `true` enables it for eligible GitHub-authenticated sessions,
2377
+ * including custom {@link provider} (BYOK) sessions. Omission preserves a resident
2378
+ * session's choice; otherwise defaults to enabled. Host and account policies still
2379
+ * determine whether telemetry can be uploaded.
2319
2380
  * This is independent of the OpenTelemetry configuration in {@link CopilotClientOptions.telemetry}.
2320
2381
  */
2321
2382
  enableSessionTelemetry?: boolean;
@@ -2365,7 +2426,7 @@ export interface SessionConfigBase {
2365
2426
  customAgentsLocalOnly?: boolean;
2366
2427
  /**
2367
2428
  * When true, the runtime instructs the agent to include a `Co-authored-by`
2368
- * trailer in commit messages it composes.
2429
+ * trailer in commit messages it composes. Subagents inherit this setting.
2369
2430
  *
2370
2431
  * Defaults to `true`. Under {@link CopilotClientOptions.mode} = `"empty"`,
2371
2432
  * defaults to `false`; apps can pass `true` here to opt back in.
@@ -2822,10 +2883,10 @@ export interface ResumeSessionConfig extends SessionConfigBase {
2822
2883
  * runtime treats pending work as interrupted on resume. Completed tool results
2823
2884
  * already durably recorded by the runtime are preserved.
2824
2885
  *
2825
- * For permission requests, the runtime re-emits `permission.requested` so the
2826
- * registered `onPermissionRequest` handler can re-prompt; for external tool calls,
2827
- * the consumer is expected to supply the result via the corresponding low-level
2828
- * RPC method.
2886
+ * When true, pending permission requests and external tool calls wait for
2887
+ * caller-supplied results via the corresponding low-level RPC methods. Resuming
2888
+ * does not re-emit restored permission requests or re-invoke permission handlers
2889
+ * or already-dispatched external tool callbacks.
2829
2890
  * @default false
2830
2891
  */
2831
2892
  continuePendingWork?: boolean;
@@ -2913,7 +2974,9 @@ export interface ProviderConfig {
2913
2974
  transport?: "http" | "websockets";
2914
2975
  /**
2915
2976
  * Product serving the model, such as "ollama" or "lm_studio", reported in
2916
- * telemetry as `model_provider`. Only affects telemetry.
2977
+ * telemetry as `model_provider`. "azure_openai" also omits explicit
2978
+ * prompt-cache breakpoints, which limit cross-turn cache reuse on Azure; set
2979
+ * it for a proxy or custom domain in front of Azure OpenAI.
2917
2980
  */
2918
2981
  modelProvider?: ProviderConfigModelProvider;
2919
2982
  /**
@@ -3017,7 +3080,9 @@ export interface NamedProviderConfig {
3017
3080
  wireApi?: "completions" | "responses";
3018
3081
  /**
3019
3082
  * Product serving this provider's models, such as "ollama" or "lm_studio",
3020
- * reported in telemetry as `model_provider`. Only affects telemetry.
3083
+ * reported in telemetry as `model_provider`. "azure_openai" also omits
3084
+ * explicit prompt-cache breakpoints, which limit cross-turn cache reuse on
3085
+ * Azure; set it for a proxy or custom domain in front of Azure OpenAI.
3021
3086
  */
3022
3087
  modelProvider?: ProviderConfigModelProvider;
3023
3088
  /**
@@ -3267,6 +3332,8 @@ export interface SessionFsConfig {
3267
3332
  * @default false
3268
3333
  */
3269
3334
  binary?: boolean;
3335
+ /** Whether every session provider supports bounded byte-range reads, independently of binary support. */
3336
+ readFileRange?: boolean;
3270
3337
  };
3271
3338
  }
3272
3339
  /**
@@ -3302,6 +3369,8 @@ export interface GetStatusResponse {
3302
3369
  version: string;
3303
3370
  /** Protocol version for SDK compatibility */
3304
3371
  protocolVersion: number;
3372
+ /** Host diagnostics, when supplied by the runtime. */
3373
+ hostDiagnostics?: HostDiagnostics;
3305
3374
  }
3306
3375
  /**
3307
3376
  * Response from auth.getStatus
@@ -3368,6 +3437,8 @@ export interface ModelInfo {
3368
3437
  id: string;
3369
3438
  /** Display name */
3370
3439
  name: string;
3440
+ /** Native serving provider, when attributed by the runtime. Absent for configured BYOK models. */
3441
+ provider?: ModelProviderRef;
3371
3442
  /** Model capabilities and limits */
3372
3443
  capabilities: ModelCapabilities;
3373
3444
  /** Policy state */
@@ -6,7 +6,7 @@ export type { WorkflowRunResult };
6
6
  export type JsonValue = null | boolean | number | string | JsonValue[] | {
7
7
  [key: string]: JsonValue;
8
8
  };
9
- export type { WorkflowAgentSummary, WorkflowPhaseStatus, WorkflowPhaseObservation, WorkflowProgressLine, WorkflowProgressPage, WorkflowRunDetail, WorkflowRunStatus, WorkflowRunSummary, } from "./generated/rpc.js";
9
+ export type { WorkflowAgentContextObservation, WorkflowAgentModelObservation, WorkflowAgentReasoningEffortObservation, WorkflowAgentSummary, WorkflowPhaseStatus, WorkflowPhaseObservation, WorkflowProgressLine, WorkflowProgressPage, WorkflowRunDetail, WorkflowRunStatus, WorkflowRunSummary, } from "./generated/rpc.js";
10
10
  /**
11
11
  * Options for paging durable workflow runs.
12
12
  *
@@ -19,8 +19,8 @@ For user-scoped extensions (persist across all repos), add `location: "user"`.
19
19
 
20
20
  Modify the generated `extension.mjs` using `edit` or `create` tools. The file must:
21
21
 
22
- - Be named `extension.mjs` (only `.mjs` is supported)
23
- - Use ES module syntax (`import`/`export`)
22
+ - Be named `extension.mjs`, `extension.cjs` or `extension.js` (the scaffold creates `extension.mjs`)
23
+ - Use ES module syntax (`import`/`export`) in `.mjs` files, or CommonJS (`require`) in `.cjs` files
24
24
  - Call `joinSession({ ... })`
25
25
 
26
26
  ### Step 3: Reload extensions
@@ -53,7 +53,7 @@ Discovery rules:
53
53
  - The CLI scans `.github/extensions/` relative to the git root
54
54
  - It also scans the user's copilot config extensions directory
55
55
  - Only immediate subdirectories are checked (not recursive)
56
- - Each subdirectory must contain a file named `extension.mjs`
56
+ - Each subdirectory must contain a file named `extension.mjs`, `extension.cjs` or `extension.js`
57
57
  - Project extensions shadow user extensions on name collision
58
58
 
59
59
  ---
@@ -320,5 +320,5 @@ Low-level typed RPC access to all session APIs (model, mode, plan, workspace, et
320
320
  - **Tool name collisions are fatal.** If two extensions register the same tool name, the second extension fails to initialize.
321
321
  - **Don't call `session.send()` synchronously from `onUserPromptSubmitted`.** Use `setTimeout(() => session.send(...), 0)` to avoid infinite loops.
322
322
  - **Extensions are reloaded on `/clear`.** Any in-memory state is lost between sessions.
323
- - **Only `.mjs` is supported.** TypeScript (`.ts`) is not yet supported.
323
+ - **The entry file must be `.mjs`, `.cjs` or `.js`.** TypeScript (`.ts`) is not yet supported.
324
324
  - **The handler's return value is the tool result.** Returning `undefined` sends an empty success. Throwing sends a failure with the error message.