Files
openclaw/extensions/copilot/doctor-contract-api.ts
Ramrajprabu f3cfd752d3 feat(copilot): add GitHub Copilot agent runtime
Adds the opt-in bundled GitHub Copilot agent runtime, pinned SDK install path, docs/inventory, SDK/tool/sandbox/auth wiring, and replay/tool-safety fixes.

Verification:
- Local: git diff --check; fnm exec --using 24.15.0 pnpm tsgo:extensions; fnm exec --using 24.15.0 pnpm check:test-types; fnm exec --using 24.15.0 pnpm build.
- Autoreview local: clean for the replay-safety fix; branch autoreview engine returned empty output twice, so local autoreview plus local/Crabbox/CI proof was used.
- Crabbox focused Copilot: run_2c0db9f48a4a, 19 files / 485 tests passed.
- Crabbox additional boundary shard: run_26a246a1aa24, prompt snapshots and plugin SDK boundary/export checks passed.
- Crabbox live Copilot: run_d128e4048b4e, real gpt-4.1 turn with live_echo phase-1-green and clean session-file check.
- GitHub checks: green on head 7cc8657e0d, including Dependency Guard after exact-head approval.

Co-authored-by: Ramraj Balasubramanian <ramrajba@microsoft.com>
2026-05-29 05:15:22 +01:00

64 lines
2.3 KiB
TypeScript
Executable File

/**
* Doctor contract for the copilot extension.
*
* Mirrors {@link ../codex/doctor-contract-api.ts} so `openclaw doctor`
* can:
* - Reason about which session-state belongs to this extension
* (sessionRouteStateOwners) for cleanup of stale state across
* runtime swaps.
* - Detect retired config fields and migrate them
* (legacyConfigRules + normalizeCompatibilityConfig). No retired
* fields exist for copilot yet; the array is empty by design
* and normalizeCompatibilityConfig is a structural no-op so
* future retirements have a stable in-tree home.
*
* The deeper runtime probes (copilot CLI version, copilot auth,
* copilotHome writability) live in {@link ./src/doctor-probes.ts}
* because they have side effects (subprocess spawn, fs touch) and
* need to be invoked imperatively, not declaratively, from the
* doctor command. They are exported separately so callers can opt
* in. Auto-discovery of doctor-contract-api.ts at the plugin root
* keeps this file purely declarative.
*/
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import type { DoctorSessionRouteStateOwner } from "openclaw/plugin-sdk/runtime-doctor";
type LegacyConfigRule = {
path: string[];
message: string;
match: (value: unknown) => boolean;
};
export const legacyConfigRules: LegacyConfigRule[] = [];
export function normalizeCompatibilityConfig({ cfg }: { cfg: OpenClawConfig }): {
config: OpenClawConfig;
changes: string[];
} {
return { config: cfg, changes: [] };
}
/**
* Session-state ownership claim for the copilot agent runtime.
*
* - id / label: Identify the extension in doctor output.
* - providerIds: The subscription Copilot providers (kept in sync
* with `SUPPORTED_PROVIDERS` in attempt.ts).
* - runtimeIds: Our harness id (matches harness.ts `id` field).
* - cliSessionKeys: Session keys this harness writes; doctor uses
* this when pruning stale CLI session state.
* - authProfilePrefixes: Conventional prefix for any auth profile
* created/consumed by this extension.
*/
export const sessionRouteStateOwners: DoctorSessionRouteStateOwner[] = [
{
id: "copilot",
label: "GitHub Copilot agent runtime",
providerIds: ["github-copilot"],
runtimeIds: ["copilot"],
cliSessionKeys: ["copilot"],
authProfilePrefixes: ["github-copilot:"],
},
];