Skip to content

[python] copilot.generated exposed as part of the public API #2048

Description

@brettcannon

https://github.com/github/copilot-sdk/blob/main/python/copilot/generated/__init__.py Makes it clear that the copilot.generated subpackage is not meant to be public:

This package is not part of the public API. Import from `copilot` (session-event

But the subpackage doesn't start with an underscore to signify it's an implementation detail: copilot._generated.

As well, https://github.com/github/copilot-sdk/blob/main/python/copilot/rpc.py and https://github.com/github/copilot-sdk/blob/main/python/copilot/session_events.py which are meant to act as the public API potentially over-expose things. While copilot.rpc does export something explicitly:

from .generated.rpc import (
SessionFsReaddirWithTypesEntryType as SessionFSReaddirWithTypesEntryType, # noqa: F401

... both files also do an import * followed by an import of __all__ from the generated code which lists everything contained in the generated code. E.g.:

from .generated.session_events import * # noqa: F401, F403
from .generated.session_events import __all__ # noqa: F401

exposes 330 symbols in the module:

__all__ = [
"AbortData",
"AbortReason",
"AssistantIdleData",
"AssistantIntentData",
"AssistantMessageData",
"AssistantMessageDeltaData",
"AssistantMessageServerTools",
"AssistantMessageStartData",
"AssistantMessageToolRequest",
"AssistantMessageToolRequestType",
"AssistantReasoningData",
"AssistantReasoningDeltaData",
"AssistantServerToolProgressData",
"AssistantStreamingDeltaData",
"AssistantToolCallDeltaData",
"AssistantTurnEndData",
"AssistantTurnRetryData",
"AssistantTurnStartData",
"AssistantUsageApiEndpoint",
"AssistantUsageCopilotUsage",
"AssistantUsageCopilotUsageTokenDetail",
"AssistantUsageData",
"Attachment",
"AttachmentBlob",
"AttachmentDirectory",
"AttachmentExtensionContext",
"AttachmentFile",
"AttachmentFileLineRange",
"AttachmentGitHubActionsJob",
"AttachmentGitHubCommit",
"AttachmentGitHubFile",
"AttachmentGitHubFileDiff",
"AttachmentGitHubFileDiffSide",
"AttachmentGitHubReference",
"AttachmentGitHubReferenceType",
"AttachmentGitHubRelease",
"AttachmentGitHubRepository",
"AttachmentGitHubSnippet",
"AttachmentGitHubTreeComparison",
"AttachmentGitHubTreeComparisonSide",
"AttachmentGitHubUrl",
"AttachmentSelection",
"AttachmentSelectionDetails",
"AttachmentSelectionDetailsEnd",
"AttachmentSelectionDetailsStart",
"AutoApprovalRecommendation",
"AutoModeResolvedReasoningBucket",
"AutoModeSwitchCompletedData",
"AutoModeSwitchRequestedData",
"AutoModeSwitchResponse",
"AutopilotObjectiveChangedOperation",
"AutopilotObjectiveChangedStatus",
"BinaryAssetReference",
"BinaryAssetReferenceType",
"BinaryAssetType",
"CanvasRegistryChangedCanvas",
"CanvasRegistryChangedCanvasAction",
"CapabilitiesChangedData",
"CapabilitiesChangedUI",
"CitableSource",
"CitationLocation",
"CitationLocationBlock",
"CitationLocationChar",
"CitationLocationPage",
"CitationProvider",
"CitationReference",
"CitationSource",
"CitationSpan",
"Citations",
"CommandCompletedData",
"CommandExecuteData",
"CommandQueuedData",
"CommandsChangedCommand",
"CommandsChangedData",
"CompactionCompleteCompactionTokensUsed",
"CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail",
"ContextTier",
"CustomAgentsUpdatedAgent",
"Data",
"ElicitationCompletedAction",
"ElicitationCompletedData",
"ElicitationRequestedData",
"ElicitationRequestedMode",
"ElicitationRequestedSchema",
"EmbeddedBlobResourceContents",
"EmbeddedTextResourceContents",
"ExitPlanModeAction",
"ExitPlanModeCompletedData",
"ExitPlanModeRequestedData",
"ExtensionsLoadedExtension",
"ExtensionsLoadedExtensionSource",
"ExtensionsLoadedExtensionStatus",
"ExternalToolCompletedData",
"ExternalToolRequestedData",
"GitHubRepoRef",
"HandoffRepository",
"HandoffSourceType",
"HeaderEntry",
"HookEndData",
"HookEndError",
"HookProgressData",
"HookStartData",
"ManagedSettingsEnforcedAction",
"ManagedSettingsEnforcedEscalation",
"ManagedSettingsResolvedSource",
"McpAppToolCallCompleteData",
"McpAppToolCallCompleteError",
"McpAppToolCallCompleteToolMeta",
"McpAppToolCallCompleteToolMetaUI",
"McpHeadersRefreshCompletedData",
"McpHeadersRefreshCompletedOutcome",
"McpHeadersRefreshRequiredData",
"McpHeadersRefreshRequiredReason",
"McpOauthCompletedData",
"McpOauthCompletionOutcome",
"McpOauthHttpResponse",
"McpOauthRequestReason",
"McpOauthRequiredData",
"McpOauthRequiredStaticClientConfig",
"McpOauthWWWAuthenticateParams",
"McpPromptsListChangedData",
"McpResourcesListChangedData",
"McpServerSource",
"McpServerStatus",
"McpServerTransport",
"McpServersLoadedServer",
"McpToolsListChangedData",
"ModelCallFailureBadRequestKind",
"ModelCallFailureData",
"ModelCallFailureKind",
"ModelCallFailureRequestFingerprint",
"ModelCallFailureSource",
"ModelCallFailureTransport",
"ModelCallStartData",
"OmittedBinaryOmittedReason",
"OmittedBinaryResult",
"OmittedBinaryType",
"PendingMessagesModifiedData",
"PermissionAllowAllMode",
"PermissionApproved",
"PermissionApprovedForLocation",
"PermissionApprovedForSession",
"PermissionAutoApproval",
"PermissionCancelled",
"PermissionCompletedData",
"PermissionDeniedByContentExclusionPolicy",
"PermissionDeniedByPermissionRequestHook",
"PermissionDeniedByRules",
"PermissionDeniedInteractivelyByUser",
"PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser",
"PermissionPromptRequest",
"PermissionPromptRequestCommands",
"PermissionPromptRequestCustomTool",
"PermissionPromptRequestExtensionManagement",
"PermissionPromptRequestExtensionPermissionAccess",
"PermissionPromptRequestHook",
"PermissionPromptRequestMcp",
"PermissionPromptRequestMemory",
"PermissionPromptRequestPath",
"PermissionPromptRequestPathAccessKind",
"PermissionPromptRequestRead",
"PermissionPromptRequestUrl",
"PermissionPromptRequestWrite",
"PermissionRequest",
"PermissionRequestCustomTool",
"PermissionRequestExtensionManagement",
"PermissionRequestExtensionPermissionAccess",
"PermissionRequestHook",
"PermissionRequestMcp",
"PermissionRequestMemory",
"PermissionRequestMemoryAction",
"PermissionRequestMemoryDirection",
"PermissionRequestRead",
"PermissionRequestShell",
"PermissionRequestShellCommand",
"PermissionRequestShellPossibleUrl",
"PermissionRequestUrl",
"PermissionRequestWrite",
"PermissionRequestedData",
"PermissionResult",
"PermissionRule",
"PersistedBinaryImage",
"PersistedBinaryImageType",
"PersistedBinaryResult",
"PlanChangedOperation",
"RawSessionEventData",
"ReasoningSummary",
"SamplingCompletedData",
"SamplingRequestedData",
"SessionAutoModeResolvedData",
"SessionAutopilotObjectiveChangedData",
"SessionBackgroundTasksChangedData",
"SessionBinaryAssetData",
"SessionCanvasClosedData",
"SessionCanvasOpenedData",
"SessionCanvasRecordedData",
"SessionCanvasRegistryChangedData",
"SessionCanvasRemovedData",
"SessionCanvasUnavailableData",
"SessionCompactionCompleteData",
"SessionCompactionStartData",
"SessionContextChangedData",
"SessionCustomAgentsUpdatedData",
"SessionCustomNotificationData",
"SessionErrorData",
"SessionEvent",
"SessionEventData",
"SessionEventType",
"SessionExtensionsAttachmentsPushedData",
"SessionExtensionsLoadedData",
"SessionHandoffData",
"SessionIdleData",
"SessionInfoData",
"SessionLimitsConfig",
"SessionLimitsExhaustedCompletedData",
"SessionLimitsExhaustedRequestedData",
"SessionLimitsExhaustedResponse",
"SessionLimitsExhaustedResponseAction",
"SessionManagedSettingsEnforcedData",
"SessionManagedSettingsResolvedData",
"SessionMcpServerStatusChangedData",
"SessionMcpServersLoadedData",
"SessionMode",
"SessionModeChangedData",
"SessionModelChangeData",
"SessionPermissionsChangedData",
"SessionPlanChangedData",
"SessionRemoteSteerableChangedData",
"SessionResumeData",
"SessionScheduleCancelledData",
"SessionScheduleCreatedData",
"SessionScheduleRearmedData",
"SessionSessionLimitsChangedData",
"SessionShutdownData",
"SessionSkillsLoadedData",
"SessionSnapshotRewindData",
"SessionStartData",
"SessionTaskCompleteData",
"SessionTitleChangedData",
"SessionTodosChangedData",
"SessionToolsUpdatedData",
"SessionTruncationData",
"SessionUsageCheckpointData",
"SessionUsageInfoData",
"SessionWarningData",
"SessionWorkspaceFileChangedData",
"ShutdownCodeChanges",
"ShutdownModelMetric",
"ShutdownModelMetricRequests",
"ShutdownModelMetricTokenDetail",
"ShutdownModelMetricUsage",
"ShutdownTokenDetail",
"ShutdownType",
"SkillInvokedData",
"SkillInvokedTrigger",
"SkillSource",
"SkillsLoadedSkill",
"SubagentCompletedData",
"SubagentDeselectedData",
"SubagentFailedData",
"SubagentSelectedData",
"SubagentStartedData",
"SystemMessageData",
"SystemMessageMetadata",
"SystemMessageRole",
"SystemNotification",
"SystemNotificationAgentCompleted",
"SystemNotificationAgentCompletedStatus",
"SystemNotificationAgentIdle",
"SystemNotificationData",
"SystemNotificationInstructionDiscovered",
"SystemNotificationNewInboxMessage",
"SystemNotificationShellCompleted",
"SystemNotificationShellDetachedCompleted",
"ToolExecutionCompleteContent",
"ToolExecutionCompleteContentAudio",
"ToolExecutionCompleteContentImage",
"ToolExecutionCompleteContentResource",
"ToolExecutionCompleteContentResourceDetails",
"ToolExecutionCompleteContentResourceLink",
"ToolExecutionCompleteContentResourceLinkIcon",
"ToolExecutionCompleteContentResourceLinkIconTheme",
"ToolExecutionCompleteContentShellExit",
"ToolExecutionCompleteContentTerminal",
"ToolExecutionCompleteContentText",
"ToolExecutionCompleteData",
"ToolExecutionCompleteError",
"ToolExecutionCompleteResult",
"ToolExecutionCompleteToolDescription",
"ToolExecutionCompleteToolDescriptionMeta",
"ToolExecutionCompleteToolDescriptionMetaUI",
"ToolExecutionCompleteToolDescriptionMetaUIVisibility",
"ToolExecutionCompleteUIResource",
"ToolExecutionCompleteUIResourceMeta",
"ToolExecutionCompleteUIResourceMetaUI",
"ToolExecutionCompleteUIResourceMetaUICsp",
"ToolExecutionCompleteUIResourceMetaUIPermissions",
"ToolExecutionCompleteUIResourceMetaUIPermissionsCamera",
"ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite",
"ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation",
"ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone",
"ToolExecutionPartialResultData",
"ToolExecutionProgressData",
"ToolExecutionStartData",
"ToolExecutionStartShellToolInfo",
"ToolExecutionStartToolDescription",
"ToolExecutionStartToolDescriptionMeta",
"ToolExecutionStartToolDescriptionMetaUI",
"ToolExecutionStartToolDescriptionMetaUIVisibility",
"ToolSearchActivatedData",
"ToolUserRequestedData",
"UserInputCompletedData",
"UserInputRequestedData",
"UserMessageAgentMode",
"UserMessageData",
"UserMessageDelivery",
"UserToolSessionApproval",
"UserToolSessionApprovalCommands",
"UserToolSessionApprovalCustomTool",
"UserToolSessionApprovalExtensionManagement",
"UserToolSessionApprovalExtensionPermissionAccess",
"UserToolSessionApprovalMcp",
"UserToolSessionApprovalMemory",
"UserToolSessionApprovalRead",
"UserToolSessionApprovalWrite",
"Verbosity",
"WorkingDirectoryContext",
"WorkingDirectoryContextHostType",
"WorkspaceFileChangedOperation",
"session_event_from_dict",
"session_event_to_dict",
]

I'm not sure if all 330 symbols are meant to be exposed, but at least copilot.generated should be made private by renaming it to copilot._generated. If all of those symbols are meant to be exposed then that one-liner in copilot.rpc might as well be removed. If they are not meant to be exposed then the import __all__ and import * should go and you can explicitly set __all__ in the exporting modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions