@github/copilot-sdk 1.0.15-preview.3 → 1.0.15-preview.4
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 +44 -0
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +18 -6
- package/dist/cjs/extension.js +1 -12
- package/dist/cjs/generated/rpc.js +262 -173
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/installationConfirmation.js +98 -0
- package/dist/cjs/session.js +14 -524
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +20 -6
- package/dist/extension.d.ts +10 -24
- package/dist/extension.js +1 -13
- package/dist/generated/rpc.d.ts +5960 -4645
- package/dist/generated/rpc.js +262 -173
- package/dist/generated/session-events.d.ts +197 -118
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -4
- package/dist/installationConfirmation.d.ts +19 -0
- package/dist/installationConfirmation.js +77 -0
- package/dist/session.d.ts +2 -25
- package/dist/session.js +14 -529
- package/dist/types.d.ts +10 -65
- package/dist/workflow.d.ts +5 -2
- package/docs/extensions.md +0 -1
- package/docs/workflows.md +2 -4
- package/package.json +10 -10
- package/dist/cjs/factory.js +0 -134
- package/dist/factory.d.ts +0 -327
- package/dist/factory.js +0 -106
- package/docs/factories.md +0 -296
- package/docs/factory-patterns.md +0 -194
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,9 @@ export { CopilotClient } from "./client.js";
|
|
|
7
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
|
-
export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./factory.js";
|
|
11
10
|
export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./workflow.js";
|
|
12
11
|
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
13
12
|
export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
|
|
14
13
|
export type * from "./generated/session-events.js";
|
|
15
|
-
export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, 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,
|
|
16
|
-
export type {
|
|
17
|
-
export type { 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";
|
|
14
|
+
export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, 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, 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
|
+
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";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { CopilotClient } from "./client.js";
|
|
|
2
2
|
import { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
|
|
3
3
|
import { BuiltInTools, ToolSet } from "./toolSet.js";
|
|
4
4
|
import { CopilotSession } from "./session.js";
|
|
5
|
-
import { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./factory.js";
|
|
6
5
|
import { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./workflow.js";
|
|
7
6
|
import {
|
|
8
7
|
Canvas,
|
|
@@ -33,7 +32,6 @@ export {
|
|
|
33
32
|
CopilotWebSocketForwarder,
|
|
34
33
|
CopilotWebSocketHandler,
|
|
35
34
|
DisableBypassPermissionsModes,
|
|
36
|
-
FactoryResumeError,
|
|
37
35
|
RuntimeConnection,
|
|
38
36
|
SYSTEM_MESSAGE_SECTIONS,
|
|
39
37
|
SessionFsSqliteTransactionFailure,
|
|
@@ -44,9 +42,7 @@ export {
|
|
|
44
42
|
createAttributedPermissionResult,
|
|
45
43
|
createCanvas,
|
|
46
44
|
createSessionFsAdapter,
|
|
47
|
-
defineFactory,
|
|
48
45
|
defineTool,
|
|
49
46
|
defineWorkflow,
|
|
50
|
-
isFactoryRunTerminal,
|
|
51
47
|
isWorkflowRunTerminal
|
|
52
48
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type CancellationToken, type MessageConnection } from "vscode-jsonrpc/node.js";
|
|
2
|
+
import type { InstallationConfirmationRequest, InstallationDecision, InstallationsConfirmResult } from "./generated/rpc.js";
|
|
3
|
+
/** The `installations.confirm` receiver, invoked with the transport's request cancellation. */
|
|
4
|
+
export interface InstallationConfirmationReceiver {
|
|
5
|
+
confirm(request: InstallationConfirmationRequest, token: CancellationToken): Promise<InstallationsConfirmResult>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Collects an explicit human decision for the complete runtime review.
|
|
9
|
+
* Match operationId and policySessionId to the exact action registered by the host
|
|
10
|
+
* before displaying it. Refuse unknown actions or incomplete reviews; never infer
|
|
11
|
+
* authority from the current session or a global pending slot.
|
|
12
|
+
*
|
|
13
|
+
* The SDK echoes the original challenge and fingerprint. Separately spawned UI
|
|
14
|
+
* work must observe the token to retire itself when the request or connection ends.
|
|
15
|
+
* Registering this callback does not enable installation capabilities.
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
export type InstallationConfirmationHandler = (request: InstallationConfirmationRequest, token: CancellationToken) => InstallationDecision | Promise<InstallationDecision>;
|
|
19
|
+
export declare function createInstallationConfirmationAdapter(connection: MessageConnection, handler: InstallationConfirmationHandler): InstallationConfirmationReceiver;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CancellationTokenSource,
|
|
3
|
+
ResponseError
|
|
4
|
+
} from "vscode-jsonrpc/node.js";
|
|
5
|
+
function createInstallationConfirmationAdapter(connection, handler) {
|
|
6
|
+
const closed = new CancellationTokenSource();
|
|
7
|
+
const closeSubscription = connection.onClose(() => closed.cancel());
|
|
8
|
+
const disposeSubscription = connection.onDispose(() => {
|
|
9
|
+
closed.cancel();
|
|
10
|
+
closed.dispose();
|
|
11
|
+
closeSubscription.dispose();
|
|
12
|
+
disposeSubscription.dispose();
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
async confirm(request, token) {
|
|
16
|
+
if (!token) {
|
|
17
|
+
throw new Error("Installation confirmation request cancellation is unavailable");
|
|
18
|
+
}
|
|
19
|
+
const { confirmationId, reviewFingerprint } = request;
|
|
20
|
+
const combined = new CancellationTokenSource();
|
|
21
|
+
const subscriptions = [];
|
|
22
|
+
const cancelRequest = () => combined.cancel();
|
|
23
|
+
const cancelConnection = () => combined.cancel();
|
|
24
|
+
const checkCancellation = () => {
|
|
25
|
+
if (closed.token.isCancellationRequested) {
|
|
26
|
+
throw new Error("Installation confirmation connection closed");
|
|
27
|
+
}
|
|
28
|
+
if (token.isCancellationRequested) {
|
|
29
|
+
throw new ResponseError(-32800, "Installation confirmation request cancelled");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
subscriptions.push(
|
|
34
|
+
token.onCancellationRequested(cancelRequest),
|
|
35
|
+
closed.token.onCancellationRequested(cancelConnection)
|
|
36
|
+
);
|
|
37
|
+
if (token.isCancellationRequested || closed.token.isCancellationRequested) {
|
|
38
|
+
combined.cancel();
|
|
39
|
+
}
|
|
40
|
+
checkCancellation();
|
|
41
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
42
|
+
subscriptions.push(
|
|
43
|
+
token.onCancellationRequested(
|
|
44
|
+
() => reject(
|
|
45
|
+
new ResponseError(
|
|
46
|
+
-32800,
|
|
47
|
+
"Installation confirmation request cancelled"
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
),
|
|
51
|
+
closed.token.onCancellationRequested(
|
|
52
|
+
() => reject(new Error("Installation confirmation connection closed"))
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
const decision = await Promise.race([
|
|
57
|
+
Promise.resolve().then(() => {
|
|
58
|
+
checkCancellation();
|
|
59
|
+
return handler(request, combined.token);
|
|
60
|
+
}),
|
|
61
|
+
cancelled
|
|
62
|
+
]);
|
|
63
|
+
checkCancellation();
|
|
64
|
+
if (decision !== "confirm" && decision !== "decline" && decision !== "cancel") {
|
|
65
|
+
throw new Error("Invalid installation confirmation decision");
|
|
66
|
+
}
|
|
67
|
+
return { confirmationId, reviewFingerprint, decision };
|
|
68
|
+
} finally {
|
|
69
|
+
for (const subscription of subscriptions) subscription.dispose();
|
|
70
|
+
combined.dispose();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
createInstallationConfirmationAdapter
|
|
77
|
+
};
|
package/dist/session.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { createSessionRpc } from "./generated/rpc.js";
|
|
|
2
2
|
import type { ModelSwitchAutoTierResult } from "./generated/rpc.js";
|
|
3
3
|
import type { OpenCanvasInstance } from "./generated/rpc.js";
|
|
4
4
|
import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
|
|
5
|
-
import { type SessionFactoryApi } from "./factory.js";
|
|
6
5
|
import { type SessionWorkflowApi } from "./workflow.js";
|
|
7
6
|
/** Assistant message event - the final response from the assistant. */
|
|
8
7
|
export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
@@ -49,8 +48,6 @@ export declare class CopilotSession {
|
|
|
49
48
|
private canvases;
|
|
50
49
|
private bearerTokenProviders;
|
|
51
50
|
private commandHandlers;
|
|
52
|
-
private factories;
|
|
53
|
-
private factoryAbortControllers;
|
|
54
51
|
private workflows;
|
|
55
52
|
private workflowAbortControllers;
|
|
56
53
|
private permissionHandler?;
|
|
@@ -72,32 +69,12 @@ export declare class CopilotSession {
|
|
|
72
69
|
private disconnecting;
|
|
73
70
|
private onDisconnected?;
|
|
74
71
|
/**
|
|
75
|
-
* Friendly
|
|
72
|
+
* Friendly workflow API for running registered workflows by name or handle.
|
|
76
73
|
*
|
|
77
|
-
* @experimental Part of the experimental
|
|
74
|
+
* @experimental Part of the experimental Dynamic Workflows surface and may
|
|
78
75
|
* change or be removed in future SDK or CLI releases.
|
|
79
76
|
*/
|
|
80
|
-
readonly factory: SessionFactoryApi;
|
|
81
77
|
readonly workflow: SessionWorkflowApi;
|
|
82
|
-
/**
|
|
83
|
-
* Resolve a start/resume envelope into the terminal envelope callers expect.
|
|
84
|
-
*
|
|
85
|
-
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
86
|
-
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
87
|
-
* on the run's terminal state.
|
|
88
|
-
*/
|
|
89
|
-
private settleFactoryRun;
|
|
90
|
-
/**
|
|
91
|
-
* Resolve when a factory run reaches a terminal status.
|
|
92
|
-
*
|
|
93
|
-
* The subscription is installed *before* the first read so a transition
|
|
94
|
-
* landing between the two cannot be missed, and re-reads are serialized so
|
|
95
|
-
* overlapping invalidation events cannot interleave — the run's revision
|
|
96
|
-
* advances once per operation, so a burst of events is common and must
|
|
97
|
-
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
98
|
-
* dropped invalidation from leaving the wait pending forever.
|
|
99
|
-
*/
|
|
100
|
-
private waitForFactoryRun;
|
|
101
78
|
private settleWorkflowRun;
|
|
102
79
|
/**
|
|
103
80
|
* Resolve when a workflow run reaches a terminal status.
|