@github/copilot-sdk 1.0.13-preview.0 → 1.0.13-preview.2

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,12 +4,12 @@
4
4
  * JSON-RPC based SDK for programmatic control of GitHub Copilot CLI
5
5
  */
6
6
  export { CopilotClient } from "./client.js";
7
- export { RuntimeConnection } from "./types.js";
7
+ export { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
8
8
  export { BuiltInTools, ToolSet } from "./toolSet.js";
9
9
  export { CopilotSession, type AssistantMessageEvent } from "./session.js";
10
10
  export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./factory.js";
11
11
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
12
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
13
  export type * from "./generated/session-events.js";
14
- export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
14
+ export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
15
  export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CopilotClient } from "./client.js";
2
- import { RuntimeConnection } from "./types.js";
2
+ import { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
3
3
  import { BuiltInTools, ToolSet } from "./toolSet.js";
4
4
  import { CopilotSession } from "./session.js";
5
5
  import { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./factory.js";
@@ -31,6 +31,7 @@ export {
31
31
  CopilotWebSocketCloseStatus,
32
32
  CopilotWebSocketForwarder,
33
33
  CopilotWebSocketHandler,
34
+ DisableBypassPermissionsModes,
34
35
  FactoryResumeError,
35
36
  RuntimeConnection,
36
37
  SYSTEM_MESSAGE_SECTIONS,
package/dist/session.d.ts CHANGED
@@ -62,6 +62,7 @@ export declare class CopilotSession {
62
62
  private _capabilities;
63
63
  private openCanvasInstances;
64
64
  private disconnected;
65
+ private onDisconnected?;
65
66
  /**
66
67
  * Friendly factory API for running registered factories by name or handle.
67
68
  *
package/dist/session.js CHANGED
@@ -223,6 +223,7 @@ class CopilotSession {
223
223
  this.traceContextProvider = traceContextProvider;
224
224
  this.mcpAuthHandler = options?.mcpAuthHandler;
225
225
  this.managedSettingsEnabled = options?.managedSettingsEnabled === true;
226
+ this.onDisconnected = options?.onDisconnected;
226
227
  }
227
228
  sessionId;
228
229
  connection;
@@ -249,6 +250,7 @@ class CopilotSession {
249
250
  _capabilities = {};
250
251
  openCanvasInstances = [];
251
252
  disconnected = false;
253
+ onDisconnected;
252
254
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
253
255
  clientSessionApis = {};
254
256
  /**
@@ -457,7 +459,7 @@ class CopilotSession {
457
459
  const unsubscribe = this.on((event) => {
458
460
  if (event.type === "assistant.message") {
459
461
  lastAssistantMessage = event;
460
- } else if (event.type === "session.idle") {
462
+ } else if (event.type === "session.idle" && event.data.mode !== "autopilot") {
461
463
  resolveOutcome({ kind: "idle" });
462
464
  } else if (event.type === "session.error") {
463
465
  const error = new Error(event.data.message);
@@ -492,7 +494,11 @@ class CopilotSession {
492
494
  }
493
495
  /** @internal */
494
496
  _markDisconnected() {
497
+ if (this.disconnected) {
498
+ return;
499
+ }
495
500
  this.disconnected = true;
501
+ this._runOnDisconnected();
496
502
  this.eventHandlers.clear();
497
503
  this.typedEventHandlers.clear();
498
504
  this.toolHandlers.clear();
@@ -512,6 +518,15 @@ class CopilotSession {
512
518
  this.factoryAbortControllers.clear();
513
519
  this.transformCallbacks?.clear();
514
520
  }
521
+ /** @internal */
522
+ _runOnDisconnected() {
523
+ this.onDisconnected?.();
524
+ this.onDisconnected = void 0;
525
+ }
526
+ /** @internal */
527
+ _setOnDisconnected(callback) {
528
+ this.onDisconnected = callback;
529
+ }
515
530
  on(eventTypeOrHandler, handler) {
516
531
  if (typeof eventTypeOrHandler === "string" && handler) {
517
532
  const eventType = eventTypeOrHandler;
package/dist/types.d.ts CHANGED
@@ -7,11 +7,29 @@ import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
7
7
  import type { PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
8
8
  import type { CopilotSession } from "./session.js";
9
9
  import type { FactoryJsonSchema, JsonValue } from "./factory.js";
10
- import type { GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
10
+ import type { GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
11
11
  import type { ToolSet } from "./toolSet.js";
12
12
  export type { RemoteSessionMode } from "./generated/rpc.js";
13
13
  export type { CurrentToolMetadata } from "./generated/rpc.js";
14
- export type { GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
14
+ export type { GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
15
+ /**
16
+ * Arguments passed to a session's {@link GitHubTokenProvider}.
17
+ *
18
+ * The callback registration identifier is intentionally kept inside the SDK.
19
+ */
20
+ export type GitHubTokenProviderArgs = Pick<GitHubTokenAcquireRequest, "host" | "sessionId" | "reason">;
21
+ /** Tagged token or cancellation returned by a {@link GitHubTokenProvider}. */
22
+ export type GitHubTokenProviderResult = GitHubTokenAcquireResult;
23
+ /**
24
+ * Acquires a GitHub token for one session.
25
+ *
26
+ * A token result must include `expiresIn`: the positive number of seconds of
27
+ * remaining lifetime when the callback completes. Production GitHub tokens
28
+ * typically last eight hours. Initial cancellation, callback errors, and
29
+ * invalid token responses reject session creation or resume instead of falling
30
+ * back to ambient authentication.
31
+ */
32
+ export type GitHubTokenProvider = (args: GitHubTokenProviderArgs) => GitHubTokenProviderResult | Promise<GitHubTokenProviderResult>;
15
33
  export type { ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, } from "./generated/rpc.js";
16
34
  export type SessionEvent = Exclude<GeneratedSessionEvent, {
17
35
  type: "permission.requested";
@@ -27,7 +45,7 @@ export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
27
45
  export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
28
46
  export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
29
47
  export type { LlmInferenceHeaders } from "./generated/rpc.js";
30
- export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, } from "./generated/rpc.js";
48
+ export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
31
49
  export type { CopilotRequestContext } from "./copilotRequestHandler.js";
32
50
  export { CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, } from "./copilotRequestHandler.js";
33
51
  /**
@@ -1751,6 +1769,13 @@ export interface GitHubMcpToolConfig {
1751
1769
  enableInsidersMode?: boolean;
1752
1770
  disableFormDeferral?: boolean;
1753
1771
  }
1772
+ /** Well-known managed bypass-permissions policies. */
1773
+ export declare const DisableBypassPermissionsModes: {
1774
+ /** Turn off bypass-permissions mode entirely. */
1775
+ readonly Disable: "disable";
1776
+ /** Permit automatic bypass but block full allow-all. */
1777
+ readonly AllowAutoOnly: "allow-auto-only";
1778
+ };
1754
1779
  /**
1755
1780
  * Permissions-only managed policy injected by the host via
1756
1781
  * {@link SessionConfigBase.managedSettings}.
@@ -1761,11 +1786,11 @@ export interface GitHubMcpToolConfig {
1761
1786
  */
1762
1787
  export interface ManagedSettingsPermissions {
1763
1788
  /**
1764
- * When set to `"disable"`, bypass-permissions ("yolo") mode is turned off
1765
- * for the session. This is deny-wins: it cannot be re-enabled by any other
1766
- * layer.
1789
+ * Restricts bypass-permissions mode for the session. See
1790
+ * {@link DisableBypassPermissionsModes} for well-known values. Unknown
1791
+ * values are forwarded so newer runtime policies fail closed.
1767
1792
  */
1768
- disableBypassPermissionsMode?: "disable";
1793
+ disableBypassPermissionsMode?: string;
1769
1794
  /** Operations that must always be denied. Unioned across managed layers. */
1770
1795
  deny?: string[];
1771
1796
  /**
@@ -1944,6 +1969,12 @@ export interface SessionConfigBase {
1944
1969
  * a custom agent with the same name is configured.
1945
1970
  */
1946
1971
  excludedBuiltinAgents?: string[];
1972
+ /**
1973
+ * Built-in skill names to include in the session. In `mode: "empty"`,
1974
+ * omitting this option excludes all runtime-bundled skills; specifying names
1975
+ * opts those built-ins back in. Skills from other sources remain eligible.
1976
+ */
1977
+ includedBuiltinSkills?: string[];
1947
1978
  /**
1948
1979
  * Custom provider configuration (BYOK - Bring Your Own Key).
1949
1980
  * When specified, uses the provided API endpoint instead of the Copilot API.
@@ -2224,6 +2255,15 @@ export interface SessionConfigBase {
2224
2255
  * the identity used for content exclusion, model routing, and quota checks.
2225
2256
  */
2226
2257
  gitHubToken?: string;
2258
+ /**
2259
+ * Acquires short-lived GitHub credentials for this session on demand.
2260
+ *
2261
+ * Mutually exclusive with {@link SessionConfigBase.gitHubToken}. The
2262
+ * callback receives the effective GitHub host, the session ID when known,
2263
+ * and whether this is the initial acquisition or a refresh. Its opaque
2264
+ * registration ID remains internal to the SDK.
2265
+ */
2266
+ gitHubTokenProvider?: GitHubTokenProvider;
2227
2267
  /**
2228
2268
  * Opt-in: when true, the runtime self-fetches enterprise managed settings
2229
2269
  * (bypass-permissions policy) at session bootstrap using the session's
@@ -2240,8 +2280,8 @@ export interface SessionConfigBase {
2240
2280
  * with the same managed-permission parser it uses for fetched policy and
2241
2281
  * composes it restrictively with any self-fetched (server) and
2242
2282
  * device-managed (MDM) layers: `deny`/`ask` rules are unioned, every
2243
- * declared `allow` list must admit an operation, and
2244
- * `disableBypassPermissionsMode: "disable"` is deny-wins.
2283
+ * declared `allow` list must admit an operation, and bypass-mode
2284
+ * restrictions are composed fail-closed.
2245
2285
  *
2246
2286
  * This is startup-only. It is **not** persisted: it must be re-supplied on
2247
2287
  * {@link CopilotClient.resumeSession | resume}, where it replaces the prior
package/dist/types.js CHANGED
@@ -134,11 +134,18 @@ const approveAll = (request, invocation) => {
134
134
  const defaultJoinSessionPermissionHandler = () => ({
135
135
  kind: "no-result"
136
136
  });
137
+ const DisableBypassPermissionsModes = {
138
+ /** Turn off bypass-permissions mode entirely. */
139
+ Disable: "disable",
140
+ /** Permit automatic bypass but block full allow-all. */
141
+ AllowAutoOnly: "allow-auto-only"
142
+ };
137
143
  export {
138
144
  CopilotRequestHandler,
139
145
  CopilotWebSocketCloseStatus,
140
146
  CopilotWebSocketForwarder,
141
147
  CopilotWebSocketHandler,
148
+ DisableBypassPermissionsModes,
142
149
  RuntimeConnection,
143
150
  SYSTEM_MESSAGE_SECTIONS,
144
151
  SessionFsSqliteTransactionFailure,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.13-preview.0",
7
+ "version": "1.0.13-preview.2",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.81-6",
59
+ "@github/copilot": "^1.0.82-0",
60
60
  "koffi": "^3.1.0",
61
61
  "vscode-jsonrpc": "^8.2.1",
62
62
  "zod": "^4.3.6"