-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add GitHub Copilot as a built-in provider #3076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
155 commits
Select commit
Hold shift + click to select a range
f00b461
Add Copilot SDK support
zortos293 743aa71
Include copilot in provider registry test
zortos293 8a0431f
Guard Copilot session bootstrap callbacks
zortos293 d93faeb
Refactor Copilot adapter to use Effect deferreds
zortos293 a2f94a0
Use copilot icon in model picker
zortos293 28be1d0
Reuse Copilot git text clients
zortos293 b6de891
Delete apps/web/src/components/chat/providerIconUtils.test.ts
zortos293 3cb707b
Render Copilot task completion as assistant text
zortos293 6892fcd
Complete Copilot send failure lifecycle
zortos293 ed4c30d
Fix Copilot rebase fallout
zortos293 cbe235f
Remove unused Copilot provider service
zortos293 ab72e4c
Handle empty Copilot tool progress messages
zortos293 10bf620
Emit Copilot fallback message for tool-only turns
zortos293 7eca7d6
Fix Copilot integration after main rebase
huxcrux 470b28a
Handle invalid Copilot CLI paths safely
huxcrux 7ff1527
Refine Copilot provider auth labels
huxcrux 8059cac
Preserve Copilot auth status labels
huxcrux 2bb4d2a
Adapt Copilot changes to latest main
huxcrux 666793b
Fix Copilot CLI launch in desktop
huxcrux 468794d
Update Copilot SDK runtime integration
huxcrux a916228
Add Copilot context window selection
huxcrux 735711c
Label Copilot none reasoning effort
huxcrux 038d5a0
Refresh Copilot provider timestamps
huxcrux 4df2947
Clear Copilot permission bindings on reply
huxcrux 6d69312
Drain Copilot events before teardown
huxcrux aad7c03
Clean up Copilot regression tests
huxcrux 79bc3f0
Add Copilot max reasoning effort
huxcrux b5161da
Align Copilot command tool rendering
huxcrux a0fb1a6
fix(web): stabilize context window snapshots
huxcrux 9baa0c1
Handle stale Copilot resume cursors
huxcrux 806d96e
Emit Copilot file-change turn diffs
huxcrux 44037e0
Skip Copilot first-turn text generation
huxcrux 227c0d8
Propagate thread metadata shell updates
huxcrux fc87f9d
Warn on Copilot mode sync failures
huxcrux 2a013d9
Fix Copilot approval resolution
huxcrux 5e55227
Ensure Copilot task completions snapshot diffs
huxcrux 5d50003
Fix first-turn title generation draining
huxcrux 130f82b
Align Copilot provider format
huxcrux 836bb3d
Wire Copilot tasks into task list
huxcrux 00b4934
Handle missing Copilot background task list
huxcrux 8d7d7f5
Fix Copilot diff markers
huxcrux 129f9b6
Filter Copilot command-only completion fallback
huxcrux 1816021
Filter Copilot task-agent completion fallback
huxcrux feab8d2
Filter Copilot task-completed generic fallback
huxcrux aada078
Stop emitting empty Copilot diffs
huxcrux 9bd32b7
Normalize Copilot user input answers
huxcrux dfe699b
Stream Copilot fallback assistant text
huxcrux 55a21a4
Add Copilot provider refs
huxcrux d0ac4cc
Share provider tool classification
huxcrux fa6b682
Normalize provider plan updates
huxcrux 60d8c5c
Project provider reasoning deltas
huxcrux f72bc79
Project provider tool output deltas
huxcrux 3b12f67
Guard duplicate Copilot completions
huxcrux d01f19d
Fix queued Copilot turn idle handling
huxcrux 768dcf8
Suppress Copilot generic completion fallbacks
huxcrux d420756
Trigger Copilot diff checkpoints for tool completions
huxcrux 5917005
Make checkpoint revert rollback-safe
huxcrux 61905f7
Restore Copilot first-turn branch naming
huxcrux 9ac833d
Filter empty Copilot diff turns
huxcrux 53b6df8
Ignore Copilot shell completion lines in diffs
huxcrux 6452283
Fix Copilot session error turn completion
huxcrux e2aab96
Fix Copilot adapter formatting
huxcrux d2cb1b0
Fix web search approval classification
huxcrux 4e87af8
Fix checkpoint revert rollback ordering
huxcrux 3616cb7
Fix file-read tool name classification
huxcrux a801f47
Invalidate workspace cache on rollback recovery failure
huxcrux e9bd573
Fix Copilot provider permission handling
huxcrux 45e8882
Fix Copilot runtime after rebase
huxcrux 228c905
Fix Copilot review issues
huxcrux 285910c
Fix Copilot test vitest imports
huxcrux 5e061d6
Fix Copilot mock test imports
huxcrux ba2414e
fix copilot settings patch trimming
huxcrux 47015f1
Use active turn IDs for Copilot diffs
huxcrux f32d65d
Tighten composer prompt effort descriptors
huxcrux e34a588
Handle provider completions without turn ids
huxcrux 3b47f19
Normalize Copilot tool lifecycle classification
huxcrux 5ff2184
Render Copilot task completion as assistant text
huxcrux 5b15ff8
Fix Copilot adapter test formatting
huxcrux 0c0ae9b
Refactor Copilot provider cleanup helpers
huxcrux 90f20ab
Mark Copilot provider early access
huxcrux 6397708
Clean up Copilot adapter internals
huxcrux eae8db7
Fix provider review issues
huxcrux c5d911c
Fix CI review follow-ups
huxcrux 7626c62
Fix unscoped provider turn completion
huxcrux 9f0d5cd
Fix Copilot task and abort event handling
huxcrux c169d87
fix: align copilot branch with latest main
huxcrux 1a1cc8a
fix: match mobile title seed truncation
huxcrux 4706da2
fix: address copilot review feedback
huxcrux dfdc13d
fix: address copilot follow-up review
huxcrux 543123b
fix: address copilot review follow-ups
huxcrux 00c5f1f
fix: structure copilot cli resolution errors
huxcrux 44c11a7
fix: address copilot runtime review comments
huxcrux a9aa6f4
fix: align copilot binary path resolution
huxcrux 718c6ba
Add Copilot text generation context tier
huxcrux 229b438
Skip Copilot first-turn title generation
huxcrux 8fb57e2
Move Copilot title fallback into provider
huxcrux 1f207c2
Fix Copilot follow-up turn completion
huxcrux 30c866a
Address Copilot provider review comments
huxcrux 3efc417
Fix Copilot text generation formatting
huxcrux f6fcc44
refine copilot lifecycle and remove stale awareness fallback
huxcrux 56d5b3c
Harden provider runtime lifecycle handling
huxcrux d3238af
Fix review feedback on turn completion guards
huxcrux fd17f3f
Fix Copilot probe error message and flaky idle test
huxcrux 618f59c
Unwrap Copilot probe wrapper errors for status
huxcrux 80d2638
fix leftover merge markers in agent awareness test
huxcrux 3e96238
Fix 8 code review issues on Copilot provider PR
huxcrux ed98701
fix(copilot): fail startupDeferred on client init error and guard sha…
huxcrux c370fe2
fix(copilot): fix backgroundTasks RPC property name and contextTier f…
huxcrux 169fea4
Fix Copilot background task listing
huxcrux d194218
Address Copilot Effect review comments
huxcrux 7cc94f6
Fix Copilot text generation formatting
huxcrux 903b8c2
Fix Copilot test Effect imports
huxcrux 46e2966
Fix Copilot review findings
huxcrux 8770677
fix: stabilize Copilot tool activity IDs
huxcrux 5f3f6b5
fix(server): preserve active Copilot turn on queued send failure
huxcrux ddb15d6
fix(copilot): activate queued turns when SDK starts
huxcrux 02a7988
fix(copilot): support conversation rollback
huxcrux 30fa713
fix(copilot): require mode sync before sending
huxcrux b3a00d5
fix(server): run first-turn metadata jobs concurrently
huxcrux b4977c4
perf(server): stop persisting streamed tool deltas
huxcrux c70d274
fix(copilot): separate call usage from context usage
huxcrux 72aacff
fix(server): align bundled Copilot CLI version
huxcrux 6516424
test(copilot): type mocked send responses
huxcrux ad70a3e
fix(copilot): coalesce text client startup
huxcrux 5f06820
refactor(copilot): remove unused delta emissions
huxcrux 436312f
refactor(copilot): keep client-seeded thread titles
huxcrux 8d4ebc0
fix(server): address Copilot review feedback
huxcrux a66e39e
test(server): synchronize provider settings watcher
huxcrux 40cfe7d
fix(server): harden copilot rollback and settings watching
huxcrux b0631f9
fix(copilot): serialize rollback history mutations
huxcrux b9ef000
fix(copilot): harden rollback shutdown ordering
huxcrux 040030b
fix(copilot): serialize session replacement teardown
huxcrux 79f94eb
fix(copilot): serialize per-thread session lifecycle
huxcrux 4740f2f
fix(copilot): coalesce concurrent session stops
huxcrux ba8d61a
fix(copilot): stop the current serialized session
huxcrux 29ab19d
test(cursor): wait for ACP request log writes
huxcrux c612c3f
fix(copilot): harden provider lifecycle
huxcrux b41a327
fix(copilot): complete failed tool turns
huxcrux 2c07a93
fix(providers): recover stale instance selections
huxcrux c11a469
fix(copilot): reduce work log noise
huxcrux 651ff66
chore(copilot): update CLI and SDK packages
huxcrux 7f59363
fix(copilot): address review follow-ups
huxcrux b6deabf
fix(copilot): debounce successful tool completion
huxcrux b1b11e8
fix(copilot): preserve rejected turn completion
huxcrux 17d1aa0
feat(copilot): generate summarized thread titles
huxcrux a5a227c
feat(plans): render status-aware task lists
huxcrux d2c918d
fix(plans): prioritize named task sections
huxcrux c360618
fix(plans): isolate task list groups
huxcrux 5a68ce8
fix(plans): consolidate task section fragments
huxcrux 9c63d2a
fix(copilot): preserve custom thread titles
huxcrux eb7b4fb
refactor(copilot): narrow provider integration scope
huxcrux dbe1f34
fix(server): subscribe before watching provider settings
huxcrux 3dffaee
fix(server): replay latest settings snapshot
huxcrux c6d8898
fix(copilot): address lifecycle review findings
huxcrux 5e461d8
fix(copilot): structure client stop failures
huxcrux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| /** | ||
| * CopilotDriver — `ProviderDriver` for the GitHub Copilot SDK runtime. | ||
| * | ||
| * Mirrors the other provider drivers: a plain value whose `create()` returns | ||
| * one `ProviderInstance` bundling `snapshot` / `adapter` / `textGeneration` | ||
| * closures captured over the per-instance `CopilotSettings`. | ||
| * | ||
| * Each instance owns an isolated Copilot home directory under server state and | ||
| * a per-instance SDK client, so sessions and persisted cursors do not leak | ||
| * across configured Copilot providers. | ||
| * | ||
| * @module provider/Drivers/CopilotDriver | ||
| */ | ||
| import { CopilotSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts"; | ||
| import { HostProcessPlatform } from "@t3tools/shared/hostProcess"; | ||
| import type * as Context from "effect/Context"; | ||
| import * as Duration from "effect/Duration"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Path from "effect/Path"; | ||
| import * as Schema from "effect/Schema"; | ||
| import * as Stream from "effect/Stream"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
|
|
||
| import { makeCopilotTextGeneration } from "../../textGeneration/CopilotTextGeneration.ts"; | ||
| import { ServerConfig } from "../../config.ts"; | ||
| import { ProviderDriverError } from "../Errors.ts"; | ||
| import { makeCopilotAdapter } from "../Layers/CopilotAdapter.ts"; | ||
| import { | ||
| checkCopilotProviderStatus, | ||
| makePendingCopilotProvider, | ||
| } from "../Layers/CopilotProvider.ts"; | ||
| import { ProviderEventLoggers } from "../Layers/ProviderEventLoggers.ts"; | ||
| import { makeManagedServerProvider } from "../makeManagedServerProvider.ts"; | ||
| import { | ||
| defaultProviderContinuationIdentity, | ||
| type ProviderDriver, | ||
| type ProviderInstance, | ||
| } from "../ProviderDriver.ts"; | ||
| import type { ServerProviderDraft } from "../providerSnapshot.ts"; | ||
| import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts"; | ||
| import { makeManualOnlyProviderMaintenanceCapabilities } from "../providerMaintenance.ts"; | ||
|
|
||
| const DRIVER_KIND = ProviderDriverKind.make("copilot"); | ||
| const SNAPSHOT_REFRESH_INTERVAL = Duration.hours(1); | ||
| const decodeCopilotSettings = Schema.decodeSync(CopilotSettings); | ||
|
|
||
| export type CopilotDriverEnv = | ||
| | FileSystem.FileSystem | ||
| | Path.Path | ||
| | Context.Service.Identifier<typeof HostProcessPlatform> | ||
| | ProviderEventLoggers | ||
| | ServerConfig; | ||
|
|
||
| const withInstanceIdentity = | ||
| (input: { | ||
| readonly instanceId: ProviderInstance["instanceId"]; | ||
| readonly displayName: string | undefined; | ||
| readonly accentColor: string | undefined; | ||
| readonly continuationGroupKey: string; | ||
| }) => | ||
| (snapshot: ServerProviderDraft): ServerProvider => ({ | ||
| ...snapshot, | ||
| instanceId: input.instanceId, | ||
| driver: DRIVER_KIND, | ||
| ...(input.displayName ? { displayName: input.displayName } : {}), | ||
| ...(input.accentColor ? { accentColor: input.accentColor } : {}), | ||
| continuation: { groupKey: input.continuationGroupKey }, | ||
| }); | ||
|
|
||
| export const CopilotDriver: ProviderDriver<CopilotSettings, CopilotDriverEnv> = { | ||
| driverKind: DRIVER_KIND, | ||
| metadata: { | ||
| displayName: "GitHub Copilot", | ||
| supportsMultipleInstances: true, | ||
| }, | ||
| configSchema: CopilotSettings, | ||
| defaultConfig: (): CopilotSettings => decodeCopilotSettings({}), | ||
| create: ({ instanceId, displayName, accentColor, environment, enabled, config }) => | ||
| Effect.gen(function* () { | ||
| const serverConfig = yield* ServerConfig; | ||
| const eventLoggers = yield* ProviderEventLoggers; | ||
| const fileSystem = yield* FileSystem.FileSystem; | ||
| const path = yield* Path.Path; | ||
| const processEnv = mergeProviderInstanceEnvironment(environment); | ||
| const effectiveConfig = { ...config, enabled } satisfies CopilotSettings; | ||
| const baseDirectory = path.join(serverConfig.stateDir, "providers", "copilot", instanceId); | ||
| const continuationIdentity = defaultProviderContinuationIdentity({ | ||
| driverKind: DRIVER_KIND, | ||
| instanceId, | ||
| }); | ||
| const stampIdentity = withInstanceIdentity({ | ||
| instanceId, | ||
| displayName, | ||
| accentColor, | ||
| continuationGroupKey: continuationIdentity.continuationKey, | ||
| }); | ||
| const maintenanceCapabilities = makeManualOnlyProviderMaintenanceCapabilities({ | ||
| provider: DRIVER_KIND, | ||
| packageName: "@github/copilot", | ||
| }); | ||
| yield* fileSystem.makeDirectory(baseDirectory, { recursive: true }).pipe( | ||
| Effect.mapError( | ||
| (cause) => | ||
| new ProviderDriverError({ | ||
| driver: DRIVER_KIND, | ||
| instanceId, | ||
| detail: `Failed to prepare Copilot home: ${cause.message ?? String(cause)}`, | ||
| cause, | ||
| }), | ||
| ), | ||
| ); | ||
|
|
||
| const adapter = yield* makeCopilotAdapter(effectiveConfig, { | ||
| instanceId, | ||
| baseDirectory, | ||
| environment: processEnv, | ||
| ...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}), | ||
| }); | ||
| const textGeneration = yield* makeCopilotTextGeneration(effectiveConfig, processEnv, { | ||
| baseDirectory, | ||
| }); | ||
|
|
||
| const snapshot = yield* makeManagedServerProvider<CopilotSettings>({ | ||
| maintenanceCapabilities, | ||
| getSettings: Effect.succeed(effectiveConfig), | ||
| streamSettings: Stream.never, | ||
| haveSettingsChanged: () => false, | ||
| initialSnapshot: (settings) => | ||
| Effect.succeed(stampIdentity(makePendingCopilotProvider(settings))), | ||
| checkProvider: checkCopilotProviderStatus({ | ||
| settings: effectiveConfig, | ||
| cwd: serverConfig.cwd, | ||
| baseDirectory, | ||
| environment: processEnv, | ||
| }).pipe(Effect.map(stampIdentity)), | ||
| refreshInterval: SNAPSHOT_REFRESH_INTERVAL, | ||
| }).pipe( | ||
| Effect.mapError( | ||
| (cause) => | ||
| new ProviderDriverError({ | ||
| driver: DRIVER_KIND, | ||
| instanceId, | ||
| detail: `Failed to build Copilot snapshot: ${cause.message ?? String(cause)}`, | ||
| cause, | ||
| }), | ||
| ), | ||
| ); | ||
|
|
||
| return { | ||
| instanceId, | ||
| driverKind: DRIVER_KIND, | ||
| continuationIdentity, | ||
| displayName, | ||
| accentColor, | ||
| enabled, | ||
| snapshot, | ||
| adapter, | ||
| textGeneration, | ||
| } satisfies ProviderInstance; | ||
| }), | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.