@github/copilot-sdk 1.0.13-preview.1 → 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/README.md +13 -0
- package/dist/cjs/client.js +95 -4
- package/dist/cjs/generated/rpc.js +19 -0
- package/dist/cjs/session.js +16 -1
- package/dist/client.d.ts +5 -0
- package/dist/client.js +95 -4
- package/dist/generated/rpc.d.ts +46 -9
- package/dist/generated/rpc.js +19 -0
- package/dist/generated/session-events.d.ts +1056 -237
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +1 -0
- package/dist/session.js +16 -1
- package/dist/types.d.ts +30 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./facto
|
|
|
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/session.d.ts
CHANGED
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
|
/**
|
|
@@ -2237,6 +2255,15 @@ export interface SessionConfigBase {
|
|
|
2237
2255
|
* the identity used for content exclusion, model routing, and quota checks.
|
|
2238
2256
|
*/
|
|
2239
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;
|
|
2240
2267
|
/**
|
|
2241
2268
|
* Opt-in: when true, the runtime self-fetches enterprise managed settings
|
|
2242
2269
|
* (bypass-permissions policy) at session bootstrap using the session's
|
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.
|
|
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.
|
|
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"
|