@microsoft/copilot-sdk 0.0.0-stage → 2.0.0-preview.0

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.
Files changed (91) hide show
  1. package/README.md +2531 -2
  2. package/dist/canvas.d.ts +135 -0
  3. package/dist/canvas.js +51 -0
  4. package/dist/cjs/canvas.js +77 -0
  5. package/dist/cjs/cliVersion.js +31 -0
  6. package/dist/cjs/client.js +3941 -0
  7. package/dist/cjs/copilotRequestHandler.js +815 -0
  8. package/dist/cjs/decisions.js +139 -0
  9. package/dist/cjs/entra.js +83 -0
  10. package/dist/cjs/extension.js +79 -0
  11. package/dist/cjs/ffiRuntimeHost.js +400 -0
  12. package/dist/cjs/generated/lifecycle-diagnostics.js +16 -0
  13. package/dist/cjs/generated/rpc.js +5883 -0
  14. package/dist/cjs/generated/session-events.js +16 -0
  15. package/dist/cjs/host.js +83 -0
  16. package/dist/cjs/index.js +100 -0
  17. package/dist/cjs/installationConfirmation.js +98 -0
  18. package/dist/cjs/jsonrpcTypes.js +41 -0
  19. package/dist/cjs/localModelJson.js +103 -0
  20. package/dist/cjs/package.json +1 -0
  21. package/dist/cjs/providerConfiguration.js +39 -0
  22. package/dist/cjs/rpcCancellation.js +49 -0
  23. package/dist/cjs/runtimeArtifacts.js +255 -0
  24. package/dist/cjs/schema.js +40 -0
  25. package/dist/cjs/sdkProtocolVersion.js +33 -0
  26. package/dist/cjs/session.js +2764 -0
  27. package/dist/cjs/sessionFsProvider.js +283 -0
  28. package/dist/cjs/taskAnalyticsJson.js +47 -0
  29. package/dist/cjs/telemetry.js +35 -0
  30. package/dist/cjs/toolSet.js +107 -0
  31. package/dist/cjs/types.js +204 -0
  32. package/dist/cjs/workflow.js +278 -0
  33. package/dist/cliVersion.d.ts +2 -0
  34. package/dist/cliVersion.js +6 -0
  35. package/dist/client.d.ts +576 -0
  36. package/dist/client.js +3924 -0
  37. package/dist/copilotRequestHandler.d.ts +91 -0
  38. package/dist/copilotRequestHandler.js +787 -0
  39. package/dist/decisions.d.ts +65 -0
  40. package/dist/decisions.js +113 -0
  41. package/dist/entra.d.ts +3 -0
  42. package/dist/entra.js +59 -0
  43. package/dist/extension.d.ts +69 -0
  44. package/dist/extension.js +59 -0
  45. package/dist/ffiRuntimeHost.d.ts +44 -0
  46. package/dist/ffiRuntimeHost.js +366 -0
  47. package/dist/generated/lifecycle-diagnostics.d.ts +232 -0
  48. package/dist/generated/lifecycle-diagnostics.js +0 -0
  49. package/dist/generated/rpc.d.ts +47706 -0
  50. package/dist/generated/rpc.js +5854 -0
  51. package/dist/generated/session-events.d.ts +17349 -0
  52. package/dist/generated/session-events.js +0 -0
  53. package/dist/host.d.ts +143 -0
  54. package/dist/host.js +59 -0
  55. package/dist/index.d.ts +23 -0
  56. package/dist/index.js +74 -0
  57. package/dist/installationConfirmation.d.ts +19 -0
  58. package/dist/installationConfirmation.js +74 -0
  59. package/dist/jsonrpcTypes.d.ts +16 -0
  60. package/dist/jsonrpcTypes.js +17 -0
  61. package/dist/localModelJson.d.ts +1 -0
  62. package/dist/localModelJson.js +69 -0
  63. package/dist/providerConfiguration.d.ts +3 -0
  64. package/dist/providerConfiguration.js +15 -0
  65. package/dist/rpcCancellation.d.ts +3 -0
  66. package/dist/rpcCancellation.js +25 -0
  67. package/dist/runtimeArtifacts.d.ts +18 -0
  68. package/dist/runtimeArtifacts.js +233 -0
  69. package/dist/schema.d.ts +4 -0
  70. package/dist/schema.js +14 -0
  71. package/dist/sdkProtocolVersion.d.ts +10 -0
  72. package/dist/sdkProtocolVersion.js +8 -0
  73. package/dist/session.d.ts +524 -0
  74. package/dist/session.js +2751 -0
  75. package/dist/sessionFsProvider.d.ts +130 -0
  76. package/dist/sessionFsProvider.js +257 -0
  77. package/dist/taskAnalyticsJson.d.ts +8 -0
  78. package/dist/taskAnalyticsJson.js +12 -0
  79. package/dist/telemetry.d.ts +14 -0
  80. package/dist/telemetry.js +11 -0
  81. package/dist/toolSet.d.ts +75 -0
  82. package/dist/toolSet.js +82 -0
  83. package/dist/types.d.ts +3864 -0
  84. package/dist/types.js +169 -0
  85. package/dist/workflow.d.ts +413 -0
  86. package/dist/workflow.js +248 -0
  87. package/docs/agent-author.md +372 -0
  88. package/docs/examples.md +747 -0
  89. package/docs/extensions.md +121 -0
  90. package/docs/workflows.md +303 -0
  91. package/package.json +135 -5
File without changes
package/dist/host.d.ts ADDED
@@ -0,0 +1,143 @@
1
+ import type { HostExitedNotification, HostPublishSessionResult, HostUnpublishSessionResult, HostListSessionsResult, HostLocalServerOptions, HostGitHubEnvironmentOptions } from "./generated/rpc.js";
2
+ import type { CopilotSession } from "./session.js";
3
+ import type { SessionConfig, ResumeSessionConfig } from "./types.js";
4
+ /** Verified host admission identity, independent of inference authentication. @experimental */
5
+ export type AhpSessionAuthentication = {
6
+ mode: "github";
7
+ identity: string;
8
+ } | {
9
+ mode: "custom";
10
+ identity: string;
11
+ } | {
12
+ mode: "none";
13
+ };
14
+ /** Explicit host-wide admission policy. @experimental */
15
+ export type AhpHostAuthentication = {
16
+ mode: "github";
17
+ } | {
18
+ mode: "none";
19
+ } | {
20
+ mode: "custom";
21
+ /** Stable owner identity. Every accepted credential must match exactly. */
22
+ requireIdentity: string;
23
+ /** Receives a decrypted admission token, never used as an inference credential. */
24
+ authenticate: (request: {
25
+ token: string;
26
+ signal: AbortSignal;
27
+ }) => Promise<{
28
+ identity: string;
29
+ /** Required future RFC3339 expiration, enforced by the host. */
30
+ expiresAt: string;
31
+ } | null>;
32
+ };
33
+ /** Host-selected defaults for a fresh application-owned session. @experimental */
34
+ export interface AhpSessionCreateRequest {
35
+ /** Trusted admission context supplied by the host, not by the connecting client. */
36
+ authentication: AhpSessionAuthentication;
37
+ /** Pass these settings to createSession, adding your prompt, tools and callbacks. */
38
+ config: Omit<SessionConfig, "onPermissionRequest">;
39
+ /** Aborted when participation ends, including timeout or owner disconnection. */
40
+ signal: AbortSignal;
41
+ }
42
+ /** Host-selected settings for resuming a durable application-owned AHP session. @experimental */
43
+ export interface AhpSessionResumeRequest {
44
+ /** Trusted admission context under the application's current host policy. */
45
+ authentication: AhpSessionAuthentication;
46
+ sessionId: string;
47
+ /** Pass to resumeSession, adding application tools, hooks and callbacks. */
48
+ config: Omit<ResumeSessionConfig, "onPermissionRequest">;
49
+ /** Aborted when participation ends; late results are still released exactly once. */
50
+ signal: AbortSignal;
51
+ }
52
+ /**
53
+ * A listener-task exit report, or an owner disconnect that cannot acknowledge cleanup.
54
+ * `reason: "exited"` means the hosting task failed, not that the runtime process died.
55
+ * In-process hosts have no process exit code (`exitCode` is absent).
56
+ * @experimental
57
+ */
58
+ export type AhpHostExit = HostExitedNotification;
59
+ /**
60
+ * Options for runtime-supervised AHP hosting. Select at least one transport.
61
+ * Callbacks are captured at startup;
62
+ * later changes to this options object do not reconfigure an existing host.
63
+ * @experimental
64
+ */
65
+ export interface AhpHostOptions {
66
+ /** Required even in coding-agent client mode. Anonymous access must be explicitly selected. */
67
+ authentication: AhpHostAuthentication;
68
+ /** Stable catalog identity; must agree with githubEnvironment.computeId when both are supplied. */
69
+ computeId?: string;
70
+ /**
71
+ * Absolute directory on the runtime host to serve through AHP.
72
+ * Defaults to the runtime's configured working directory; does not change process or session working directories.
73
+ */
74
+ workspace?: string;
75
+ /** Enable a local WebSocket listener; an empty object selects loopback defaults. */
76
+ localServer?: HostLocalServerOptions;
77
+ /** Register a Mission Control environment and enable remote WPS connections; requires github authentication. */
78
+ githubEnvironment?: HostGitHubEnvironmentOptions;
79
+ /** Remote creation admission, independent of factories. Omitted means denied. */
80
+ allowCreatingNewSessions?: boolean;
81
+ /** Called at most once when hosting ends, not on runtime process death. Local, never serialized. */
82
+ onExit?: (exit: AhpHostExit) => void;
83
+ /**
84
+ * Materialize a fresh session on this client. Preserve the supplied config
85
+ * (including its sessionId and workingDirectory); add your own prompt and tools.
86
+ * The callback and all tool/hook functions stay in the application.
87
+ */
88
+ createSession?: (request: AhpSessionCreateRequest) => Promise<CopilotSession>;
89
+ /**
90
+ * Resume a durable application-owned session, including a previously published session.
91
+ * Return the original object from this client's resumeSession, or an existing
92
+ * attached original without reconfiguring it. Published resident sessions
93
+ * attach directly and never invoke this callback.
94
+ */
95
+ resumeSession?: (request: AhpSessionResumeRequest) => Promise<CopilotSession>;
96
+ /**
97
+ * Called once per handoff with the original returned object after AHP detaches
98
+ * or the handoff fails. The SDK never disconnects or destroys this object.
99
+ */
100
+ onSessionReleased?: (session: CopilotSession) => void | Promise<void>;
101
+ }
102
+ /**
103
+ * A connection-owned AHP listener supervised by the runtime.
104
+ *
105
+ * The runtime hosts the listener in-process, without a companion executable. Disconnecting
106
+ * the owning client also stops the host; reconnecting does not reclaim it.
107
+ * Stopping a host does not delete its underlying sessions.
108
+ * Its durable AHP catalog is shared by successive hosts in the runtime's
109
+ * effective Copilot home and compute identity; a concurrent host for that catalog is rejected.
110
+ *
111
+ * @experimental
112
+ */
113
+ export declare class AhpHost {
114
+ private readonly disposeHost;
115
+ private readonly publishHostSession;
116
+ private readonly listHostSessions;
117
+ private readonly unpublishHostSession;
118
+ private readonly updateCreationPolicy;
119
+ readonly hostId: string;
120
+ /** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
121
+ readonly url: string | undefined;
122
+ /** Mission Control environment ID, when GitHub hosting is enabled. */
123
+ readonly environmentId: string | undefined;
124
+ /** Connection token, when required by the listener. Treat this value as a secret. */
125
+ readonly token: string | undefined;
126
+ /** Legacy separate host process ID. Absent for in-process listeners; use dispose() to stop. */
127
+ readonly pid: number | undefined;
128
+ /** Ask the runtime to stop the listener and await its cleanup, on every call. */
129
+ dispose(): Promise<void>;
130
+ /** Change subsequent remote admissions without disconnecting clients; admitted creation may finish. */
131
+ setAllowCreatingNewSessions(allowed: boolean): Promise<void>;
132
+ /** Publish an attached application session into the durable compute-scoped host catalog. */
133
+ publishSession(sessionId: string): Promise<HostPublishSessionResult>;
134
+ /**
135
+ * Withdraw a live or dormant application publication and revoke AHP attachments.
136
+ * Preserves local history, worktrees and ongoing work; returns false when already absent.
137
+ * Rejects nonapplication publications. Does not stop the host.
138
+ */
139
+ unpublishSession(sessionId: string): Promise<HostUnpublishSessionResult>;
140
+ /** List all live and dormant catalog sessions advertised by this host. */
141
+ listSessions(): Promise<HostListSessionsResult>;
142
+ [Symbol.asyncDispose](): Promise<void>;
143
+ }
package/dist/host.js ADDED
@@ -0,0 +1,59 @@
1
+ class AhpHost {
2
+ /** @internal */
3
+ constructor(info, disposeHost, publishHostSession, listHostSessions, unpublishHostSession, updateCreationPolicy) {
4
+ this.disposeHost = disposeHost;
5
+ this.publishHostSession = publishHostSession;
6
+ this.listHostSessions = listHostSessions;
7
+ this.unpublishHostSession = unpublishHostSession;
8
+ this.updateCreationPolicy = updateCreationPolicy;
9
+ this.hostId = info.hostId;
10
+ this.url = info.url;
11
+ this.environmentId = info.environmentId;
12
+ this.token = info.token;
13
+ this.pid = info.pid;
14
+ }
15
+ disposeHost;
16
+ publishHostSession;
17
+ listHostSessions;
18
+ unpublishHostSession;
19
+ updateCreationPolicy;
20
+ hostId;
21
+ /** Local WebSocket URL. Absent when only the GitHub environment is enabled. */
22
+ url;
23
+ /** Mission Control environment ID, when GitHub hosting is enabled. */
24
+ environmentId;
25
+ /** Connection token, when required by the listener. Treat this value as a secret. */
26
+ token;
27
+ /** Legacy separate host process ID. Absent for in-process listeners; use dispose() to stop. */
28
+ pid;
29
+ /** Ask the runtime to stop the listener and await its cleanup, on every call. */
30
+ dispose() {
31
+ return this.disposeHost();
32
+ }
33
+ /** Change subsequent remote admissions without disconnecting clients; admitted creation may finish. */
34
+ setAllowCreatingNewSessions(allowed) {
35
+ return this.updateCreationPolicy(allowed);
36
+ }
37
+ /** Publish an attached application session into the durable compute-scoped host catalog. */
38
+ publishSession(sessionId) {
39
+ return this.publishHostSession(sessionId);
40
+ }
41
+ /**
42
+ * Withdraw a live or dormant application publication and revoke AHP attachments.
43
+ * Preserves local history, worktrees and ongoing work; returns false when already absent.
44
+ * Rejects nonapplication publications. Does not stop the host.
45
+ */
46
+ unpublishSession(sessionId) {
47
+ return this.unpublishHostSession(sessionId);
48
+ }
49
+ /** List all live and dormant catalog sessions advertised by this host. */
50
+ listSessions() {
51
+ return this.listHostSessions();
52
+ }
53
+ async [Symbol.asyncDispose]() {
54
+ await this.dispose();
55
+ }
56
+ }
57
+ export {
58
+ AhpHost
59
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copilot SDK - TypeScript/Node.js Client
3
+ *
4
+ * JSON-RPC based SDK for programmatic control of GitHub Copilot CLI
5
+ */
6
+ export { CopilotClient } from "./client.js";
7
+ export { parseTrajectoryJson } from "./taskAnalyticsJson.js";
8
+ export { toSavedProviderConfiguration } from "./providerConfiguration.js";
9
+ export { CopilotDecisions, decisionErrorData, decisionErrorKind, type DecisionCallOptions, type DecisionsAskResultWithNames, type YesNoOptions, type YesNoResult, } from "./decisions.js";
10
+ export type { DecisionAnswer, DecisionContext, DecisionErrorData, DecisionErrorKind, DecisionLevel, DecisionLevelProbability, DecisionModelInfo, DecisionModelLimits, DecisionOption, DecisionOptionProbability, DecisionQuestion, DecisionsAskRequest, DecisionsAskResult, DecisionUsage, DecisionViolation, } from "./generated/rpc.js";
11
+ export type { SkillInstallSourceKind, SkillInstallSourceScope, SkillRemoveSourceEntry, SkillRemoveSourceKind, SkillsInstallSourceRequest, SkillsInstallSourceResult, SkillsRemoveSourceInventory, SkillsRemoveSourceOutcome, SkillsRemoveSourceRequest, SkillsRemoveSourceResult, } from "./generated/rpc.js";
12
+ export type { CredentialContextErrorCode, CredentialContextErrorData, FetchCancelRequest, FetchCancelResult, FetchCreateResult, FetchFileErrorData, FetchFileErrorKind, FetchFileOperation, FetchHeader, FetchProxyEnv, FetchReadRequest, FetchReadResult, FetchRedirect, FetchRequestId, FetchResponseMode, FetchSendParams, FetchSendRequest, FetchSendResult, FetchTransportErrorData, FetchTransportErrorKind, } from "./generated/rpc.js";
13
+ export type { AzureMlAcquireFamilyRequest, AzureMlHardwareResult, AzureMlRegistrationKind, AzureMlRegistrationOperation, AzureMlRegistrationRequest, AzureMlRegistrationResult, ModelProviderSaveConfigurationRequest, SavedProviderConfigurationAddModelRequest, SavedProviderConfigurationAddModelResult, SavedProviderConfigurationProviderInput, SavedProviderConfigurationType, SessionProvidersModelsDiagnoseRequest, SessionProvidersModelsDiagnoseResult, LocalModelAutoRegistration, LocalModelAzureMlIdentity, LocalModelDescriptor, LocalModelJsonValue, TrajectoryJsonValue, LocalModelDiskRequirement, LocalModelDownloadProgress, LocalModelGpuRequirement, LocalModelLimits, LocalModelMachineRow, LocalModelMachineView, LocalModelNotice, LocalModelOperation, LocalModelSource, LocalModelStatus, LocalModelTimelineMessage, LocalModelsConfigureRequest, LocalModelsConfigureResult, LocalModelsEvent, LocalModelsInspectResult, LocalModelsModelIdRequest, LocalModelsModelRequest, LocalModelsRefreshRequest, LocalModelsSetupRequest, LocalModelsSnapshot, LocalModelsView, LocalModelsWatchRequest, LocalModelsWatchResult, LocalModelsPrepareRequest, LocalModelsPrepareResult, LocalModelsDeleteModelRequest, LocalModelsCancelRequest, LocalModelsDismissNoticeRequest, HostLocalServerOptions, HostGitHubEnvironmentOptions, Model, ModelGetReasoningSummariesRequest, ModelGetReasoningSummariesResult, ModelStartupAdmissionRequest, ModelStartupAdmissionResult, SandboxConfig, AutopilotOptions, LspConfigurationProblem, LspConfigurationSnapshot, LspServerSummary, LspGlobalConfigurationRequest, LspInitializeRequest, LspProbeExitStatus, LspProbeRequest, LspProbeResult, LspSetEnabledRequest, LspWarmupError, LspWarmupResult, LspListResult, LspListRequest, SessionLspListResult, SessionLspStartResult, SessionLspDiagnoseResult, SessionLspDiagnoseRequest, SessionLspSetRequest, SessionsHasEventsRequest, SessionsHasEventsResult, ShellBuildInteractiveEnvironmentRequest, ShellBuildInteractiveEnvironmentResult, } from "./generated/rpc.js";
14
+ export { AhpHost, type AhpHostExit, type AhpHostOptions, type AhpHostAuthentication, type AhpSessionAuthentication, type AhpSessionCreateRequest, type AhpSessionResumeRequest, } from "./host.js";
15
+ export { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
16
+ export { BuiltInTools, ToolSet } from "./toolSet.js";
17
+ export { CopilotSession, type AssistantMessageEvent } from "./session.js";
18
+ export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal, WORKFLOW_AGENT_OPTION_KEYS, } from "./workflow.js";
19
+ export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
20
+ export { defineTool, approveAll, createAttributedPermissionResult, createAttributedResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SessionFsWriteFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
21
+ export type * from "./generated/session-events.js";
22
+ 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, AutoModeRecoveryContext, 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, ElicitationHandlerResult, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, HostDiagnostics, HostErrorReportingStatus, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, MemoryStoreCallOptions, StoredMemory, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, FusionTier, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, NetworkAuthenticateBasicRequest, NetworkAuthenticateBasicResult, NetworkAuthenticateNegotiateRequest, NetworkConfig, NetworkResolveProxyRequest, NetworkScope, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PromptDecisionLabel, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderConfigModelProvider, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, SectionOverride, SectionOverrideAction, SectionTransformFn, ShellAuthenticationHandler, ShellAuthenticationRequest, ShellAuthenticationResponse, 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, SessionCreationHandler, ManagedSessionInfo, SessionManagementCloseRequest, SessionManagementCloseResult, SessionManagementConfigureRequest, SessionManagementCreateHostRequest, SessionManagementCreateRequest, SessionManagementCreateResult, SessionManagementListRequest, SessionManagementListResult, SessionManagementMessageRequest, SessionManagementMessageResult, SessionManagementPolicy, SessionManagementScope, SessionManagementToolOverrides, 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";
23
+ export type { JsonValue, WorkflowRunOptions, WorkflowResumeOptions, WorkflowLimitOverrides, WorkflowResumeErrorCode, SessionWorkflowApi, WorkflowAgentOptions, WorkflowContext, WorkflowDefinition, WorkflowHandle, WorkflowAgentReference, WorkflowJsonSchema, WorkflowLimits, WorkflowMeta, WorkflowPipelineStage, WorkflowStepOptions, WorkflowRunResult, WorkflowRunStatus, WorkflowRunSummary, WorkflowListRunsOptions, WorkflowRunsPage, WorkflowRunDetail, WorkflowProgressPage, WorkflowProgressLine, WorkflowPhaseObservation, WorkflowPhaseStatus, WorkflowAgentContextObservation, WorkflowAgentModelObservation, WorkflowAgentReasoningEffortObservation, WorkflowAgentSummary, } from "./workflow.js";
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ import { CopilotClient } from "./client.js";
2
+ import { parseTrajectoryJson } from "./taskAnalyticsJson.js";
3
+ import { toSavedProviderConfiguration } from "./providerConfiguration.js";
4
+ import {
5
+ CopilotDecisions,
6
+ decisionErrorData,
7
+ decisionErrorKind
8
+ } from "./decisions.js";
9
+ import {
10
+ AhpHost
11
+ } from "./host.js";
12
+ import { DisableBypassPermissionsModes, RuntimeConnection } from "./types.js";
13
+ import { BuiltInTools, ToolSet } from "./toolSet.js";
14
+ import { CopilotSession } from "./session.js";
15
+ import {
16
+ defineWorkflow,
17
+ WorkflowResumeError,
18
+ isWorkflowRunTerminal,
19
+ WORKFLOW_AGENT_OPTION_KEYS
20
+ } from "./workflow.js";
21
+ import {
22
+ Canvas,
23
+ CanvasError,
24
+ createCanvas
25
+ } from "./canvas.js";
26
+ import {
27
+ defineTool,
28
+ approveAll,
29
+ createAttributedPermissionResult,
30
+ createAttributedResult,
31
+ convertMcpCallToolResult,
32
+ createSessionFsAdapter,
33
+ CopilotRequestHandler,
34
+ CopilotWebSocketHandler,
35
+ CopilotWebSocketCloseStatus,
36
+ CopilotWebSocketForwarder,
37
+ SessionFsSqliteTransactionFailure,
38
+ SessionFsWriteFailure,
39
+ SYSTEM_MESSAGE_SECTIONS
40
+ } from "./types.js";
41
+ export {
42
+ AhpHost,
43
+ BuiltInTools,
44
+ Canvas,
45
+ CanvasError,
46
+ CopilotClient,
47
+ CopilotDecisions,
48
+ CopilotRequestHandler,
49
+ CopilotSession,
50
+ CopilotWebSocketCloseStatus,
51
+ CopilotWebSocketForwarder,
52
+ CopilotWebSocketHandler,
53
+ DisableBypassPermissionsModes,
54
+ RuntimeConnection,
55
+ SYSTEM_MESSAGE_SECTIONS,
56
+ SessionFsSqliteTransactionFailure,
57
+ SessionFsWriteFailure,
58
+ ToolSet,
59
+ WORKFLOW_AGENT_OPTION_KEYS,
60
+ WorkflowResumeError,
61
+ approveAll,
62
+ convertMcpCallToolResult,
63
+ createAttributedPermissionResult,
64
+ createAttributedResult,
65
+ createCanvas,
66
+ createSessionFsAdapter,
67
+ decisionErrorData,
68
+ decisionErrorKind,
69
+ defineTool,
70
+ defineWorkflow,
71
+ isWorkflowRunTerminal,
72
+ parseTrajectoryJson,
73
+ toSavedProviderConfiguration
74
+ };
@@ -0,0 +1,19 @@
1
+ import type { CancellationToken, MessageConnection } from "./jsonrpcTypes.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,74 @@
1
+ import { CancellationTokenSource, ResponseError } from "vscode-jsonrpc/node";
2
+ function createInstallationConfirmationAdapter(connection, handler) {
3
+ const closed = new CancellationTokenSource();
4
+ const closeSubscription = connection.onClose(() => closed.cancel());
5
+ const disposeSubscription = connection.onDispose(() => {
6
+ closed.cancel();
7
+ closed.dispose();
8
+ closeSubscription.dispose();
9
+ disposeSubscription.dispose();
10
+ });
11
+ return {
12
+ async confirm(request, token) {
13
+ if (!token) {
14
+ throw new Error("Installation confirmation request cancellation is unavailable");
15
+ }
16
+ const { confirmationId, reviewFingerprint } = request;
17
+ const combined = new CancellationTokenSource();
18
+ const subscriptions = [];
19
+ const cancelRequest = () => combined.cancel();
20
+ const cancelConnection = () => combined.cancel();
21
+ const checkCancellation = () => {
22
+ if (closed.token.isCancellationRequested) {
23
+ throw new Error("Installation confirmation connection closed");
24
+ }
25
+ if (token.isCancellationRequested) {
26
+ throw new ResponseError(-32800, "Installation confirmation request cancelled");
27
+ }
28
+ };
29
+ try {
30
+ subscriptions.push(
31
+ token.onCancellationRequested(cancelRequest),
32
+ closed.token.onCancellationRequested(cancelConnection)
33
+ );
34
+ if (token.isCancellationRequested || closed.token.isCancellationRequested) {
35
+ combined.cancel();
36
+ }
37
+ checkCancellation();
38
+ const cancelled = new Promise((_resolve, reject) => {
39
+ subscriptions.push(
40
+ token.onCancellationRequested(
41
+ () => reject(
42
+ new ResponseError(
43
+ -32800,
44
+ "Installation confirmation request cancelled"
45
+ )
46
+ )
47
+ ),
48
+ closed.token.onCancellationRequested(
49
+ () => reject(new Error("Installation confirmation connection closed"))
50
+ )
51
+ );
52
+ });
53
+ const decision = await Promise.race([
54
+ Promise.resolve().then(() => {
55
+ checkCancellation();
56
+ return handler(request, combined.token);
57
+ }),
58
+ cancelled
59
+ ]);
60
+ checkCancellation();
61
+ if (decision !== "confirm" && decision !== "decline" && decision !== "cancel") {
62
+ throw new Error("Invalid installation confirmation decision");
63
+ }
64
+ return { confirmationId, reviewFingerprint, decision };
65
+ } finally {
66
+ for (const subscription of subscriptions) subscription.dispose();
67
+ combined.dispose();
68
+ }
69
+ }
70
+ };
71
+ }
72
+ export {
73
+ createInstallationConfirmationAdapter
74
+ };
@@ -0,0 +1,16 @@
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, token?: CancellationToken): 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
+ }
15
+ /** Sends a cancellable read without retaining the caller's abort listener after completion. */
16
+ export declare function sendRequestWithSignal<R>(connection: MessageConnection, method: string, params: unknown, signal?: AbortSignal): Promise<R>;
@@ -0,0 +1,17 @@
1
+ import { CancellationTokenSource } from "vscode-jsonrpc/node";
2
+ async function sendRequestWithSignal(connection, method, params, signal) {
3
+ if (!signal) return connection.sendRequest(method, params);
4
+ signal.throwIfAborted();
5
+ const cancellation = new CancellationTokenSource();
6
+ const abort = () => cancellation.cancel();
7
+ signal.addEventListener("abort", abort, { once: true });
8
+ try {
9
+ return await connection.sendRequest(method, params, cancellation.token);
10
+ } finally {
11
+ signal.removeEventListener("abort", abort);
12
+ cancellation.dispose();
13
+ }
14
+ }
15
+ export {
16
+ sendRequestWithSignal
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
1
+ import { Message } from "vscode-jsonrpc/node";
2
+ import { parseTrajectoryJson, rawHistoryResponse } from "./taskAnalyticsJson.js";
3
+ function createLocalModelJsonCodec() {
4
+ const pending = /* @__PURE__ */ new Map();
5
+ const snapshots = /* @__PURE__ */ new Set([
6
+ "localModels.configure",
7
+ "localModels.inspect",
8
+ "localModels.watch"
9
+ ]);
10
+ const modelRequests = /* @__PURE__ */ new Set([
11
+ "localModels.prepare",
12
+ "localModels.setup",
13
+ "localModels.deleteModel"
14
+ ]);
15
+ return {
16
+ async encode(message) {
17
+ const method = Message.isRequest(message) ? message.method : void 0;
18
+ const rawHistory = method === "session.getMessages" && message.params?.[rawHistoryResponse];
19
+ const analytics = method === "taskAnalytics.classifyTrajectory";
20
+ const json = method && (snapshots.has(method) || modelRequests.has(method) || rawHistory || analytics) ? await import("lossless-json") : void 0;
21
+ const text = method && (modelRequests.has(method) || analytics) && json ? json.stringify(
22
+ message,
23
+ analytics ? (_key, value) => {
24
+ const nativeJson = JSON;
25
+ return nativeJson.isRawJSON?.(value) ? json.parse(JSON.stringify(value)) : value;
26
+ } : void 0
27
+ ) : JSON.stringify(message);
28
+ if (Message.isRequest(message) && json && (snapshots.has(message.method) || message.method === "localModels.prepare" || rawHistory)) {
29
+ pending.set(message.id, { method: message.method, json });
30
+ }
31
+ return text;
32
+ },
33
+ async decode(text) {
34
+ const message = JSON.parse(text);
35
+ if (!Message.isResponse(message)) return message;
36
+ const request = pending.get(message.id);
37
+ pending.delete(message.id);
38
+ if (!request || !("result" in message)) return message;
39
+ if (request.method === "session.getMessages") {
40
+ return await parseTrajectoryJson(text);
41
+ }
42
+ const {
43
+ method,
44
+ json: { parse, parseNumberAndBigInt }
45
+ } = request;
46
+ const precise = parse(text, void 0, (token) => {
47
+ const value = parseNumberAndBigInt(token);
48
+ return typeof value === "bigint" && Number.isSafeInteger(Number(value)) ? Number(value) : value;
49
+ });
50
+ if (method === "localModels.prepare") {
51
+ const result = message.result;
52
+ const source = precise.result;
53
+ result.metadata = source.metadata;
54
+ result.serveOptions = source.serveOptions;
55
+ } else {
56
+ const result = message.result;
57
+ const source = precise.result;
58
+ for (const [index, row] of result.state.machine.rows.entries()) {
59
+ row.descriptor.metadata = source.state.machine.rows[index].descriptor.metadata;
60
+ row.descriptor.serveOptions = source.state.machine.rows[index].descriptor.serveOptions;
61
+ }
62
+ }
63
+ return message;
64
+ }
65
+ };
66
+ }
67
+ export {
68
+ createLocalModelJsonCodec
69
+ };
@@ -0,0 +1,3 @@
1
+ import type { NamedProviderConfig, SavedProviderConfigurationProviderInput } from "./generated/rpc.js";
2
+ /** Converts a discovered provider to credential-free saved configuration. */
3
+ export declare function toSavedProviderConfiguration(provider: NamedProviderConfig): SavedProviderConfigurationProviderInput;
@@ -0,0 +1,15 @@
1
+ function toSavedProviderConfiguration(provider) {
2
+ return {
3
+ name: provider.name,
4
+ type: provider.type,
5
+ wireApi: provider.wireApi,
6
+ transport: provider.transport,
7
+ baseUrl: provider.baseUrl,
8
+ localModel: provider.localModel,
9
+ azure: provider.azure,
10
+ modelProvider: provider.modelProvider
11
+ };
12
+ }
13
+ export {
14
+ toSavedProviderConfiguration
15
+ };
@@ -0,0 +1,3 @@
1
+ import type { MessageConnection } from "./jsonrpcTypes.js";
2
+ /** Bridges a caller's abort signal to standard JSON-RPC request cancellation. */
3
+ export declare function sendCancellableRequest<R>(connection: MessageConnection, method: string, params: unknown, signal?: AbortSignal, rejectOnAbort?: boolean): Promise<R>;
@@ -0,0 +1,25 @@
1
+ import { CancellationTokenSource } from "vscode-jsonrpc/node";
2
+ async function sendCancellableRequest(connection, method, params, signal, rejectOnAbort = false) {
3
+ signal?.throwIfAborted();
4
+ if (!signal) return connection.sendRequest(method, params);
5
+ const cancellation = new CancellationTokenSource();
6
+ let rejectAbort;
7
+ const aborted = rejectOnAbort ? new Promise((_, reject) => {
8
+ rejectAbort = reject;
9
+ }) : void 0;
10
+ const abort = () => {
11
+ cancellation.cancel();
12
+ rejectAbort?.(signal.reason);
13
+ };
14
+ signal.addEventListener("abort", abort, { once: true });
15
+ try {
16
+ const request = connection.sendRequest(method, params, cancellation.token);
17
+ return await (aborted ? Promise.race([request, aborted]) : request);
18
+ } finally {
19
+ signal.removeEventListener("abort", abort);
20
+ cancellation.dispose();
21
+ }
22
+ }
23
+ export {
24
+ sendCancellableRequest
25
+ };
@@ -0,0 +1,18 @@
1
+ export interface RuntimeArtifactSources {
2
+ packageRoot: string;
3
+ platform: string;
4
+ }
5
+ export interface EnsureRuntimeBundleOptions {
6
+ cacheRoot?: string;
7
+ packageSearchPaths?: string[];
8
+ platform?: string;
9
+ }
10
+ export declare const RUNTIME_PLATFORMS: readonly ["darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", "linuxmusl-arm64", "linuxmusl-x64", "win32-arm64", "win32-x64"];
11
+ export declare function validateFile(path: string, label: string): void;
12
+ export declare function defaultRuntimeCacheRoot(platform?: NodeJS.Platform, home?: string, environment?: NodeJS.ProcessEnv): string;
13
+ export declare function materializeRuntimeBundle(sources: RuntimeArtifactSources, cacheRoot?: string, cacheKey?: string): string;
14
+ export declare function getRuntimePlatform(platform?: NodeJS.Platform, arch?: NodeJS.Architecture, musl?: boolean): string;
15
+ export declare function getRuntimeReleaseAssetName(version: string, platform: string): string;
16
+ export declare function getRuntimePackageName(platform: string): string;
17
+ export declare function resolvePackageRoot(packageName: string, searchPaths?: string[]): string | undefined;
18
+ export declare function ensureRuntimeBundle(version: string, options?: EnsureRuntimeBundleOptions): Promise<string>;