@@ -2,12 +2,7 @@ import { randomUUID } from "node:crypto";
22import { homedir } from "node:os" ;
33import path , { posix as posixPath } from "node:path" ;
44
5- import type {
6- AgentCapability ,
7- AgentInstanceConfig ,
8- ProjectLocation ,
9- PromptSegment ,
10- } from "@/shared/contracts" ;
5+ import type { AgentInstanceConfig , ProjectLocation , PromptSegment } from "@/shared/contracts" ;
116import { claudeProfileKind , parseClaudeProfileInstanceConfig } from "@/shared/contracts" ;
127import {
138 brailleSpinnerOscTitleHint ,
@@ -45,7 +40,6 @@ warnIfPluginManifestMissing("claude", CLAUDE_PLUGIN_VERSION);
4540interface ClaudeAdapterOptions {
4641 kind ?: string ;
4742 label ?: string ;
48- profileLabel ?: string ;
4943 configDir ?: string ;
5044}
5145
@@ -70,49 +64,27 @@ function profileEnvForLocation(
7064 return { CLAUDE_CONFIG_DIR : resolveTildePath ( configDir , location ) } ;
7165}
7266
73- function capabilitiesWithProfile (
74- capabilities : AgentCapability ,
75- profileLabel : string | undefined ,
76- ) : AgentCapability {
77- const label = profileLabel ?. trim ( ) ;
78- if ( ! label ) return capabilities ;
79- const subProviderId = "claude-profile" ;
80- return {
81- ...capabilities ,
82- subProviders : [
83- ...( capabilities . subProviders ?. filter ( ( entry ) => entry . id !== subProviderId ) ?? [ ] ) ,
84- { id : subProviderId , label } ,
85- ] ,
86- modelSubProvider : {
87- ...( capabilities . modelSubProvider ?? { } ) ,
88- ...Object . fromEntries ( capabilities . models . map ( ( model ) => [ model . id , subProviderId ] ) ) ,
89- } ,
90- } ;
91- }
92-
9367export function createClaudeProfileAdapter ( instance : AgentInstanceConfig ) : AgentAdapter {
9468 const cfg = parseClaudeProfileInstanceConfig ( instance . config ) ;
9569 const profileLabel = instance . displayName ?? instance . id ;
9670 return createClaudeAdapter ( {
9771 kind : claudeProfileKind ( instance . id ) ,
9872 label : `Claude ${ profileLabel } ` ,
99- profileLabel,
10073 configDir : cfg . configDir ,
10174 } ) ;
10275}
10376
10477export function createClaudeAdapter ( options : ClaudeAdapterOptions = { } ) : AgentAdapter {
10578 const kind = options . kind ?? "claude" ;
10679 const label = options . label ?? "Claude Code" ;
107- const baseCapabilities = capabilitiesWithProfile ( claudeCapabilities , options . profileLabel ) ;
10880 const profileEnv = ( location : ProjectLocation ) =>
10981 profileEnvForLocation ( options . configDir , location ) ;
11082
11183 return {
11284 kind,
11385 label,
11486 binary : "claude" ,
115- capabilities : baseCapabilities ,
87+ capabilities : claudeCapabilities ,
11688 ...( claudeDetectionSpec . update ? { update : claudeDetectionSpec . update } : { } ) ,
11789 // WSL OAuth flows try to open a browser; no-op it so the PTY doesn't hang.
11890 spawnEnv : { wsl : { BROWSER : "/bin/true" } } ,
@@ -154,7 +126,7 @@ export function createClaudeAdapter(options: ClaudeAdapterOptions = {}): AgentAd
154126 ...claudeDetectionSpec ,
155127 kind,
156128 label,
157- capabilities : baseCapabilities ,
129+ capabilities : claudeCapabilities ,
158130 statusProbe : ( probeCtx : DetectProbeCtx ) => {
159131 const env = profileEnv ( probeCtx . location ) ;
160132 return probeClaudeStatus ( probeCtx , env ? { env } : undefined ) ;
@@ -169,7 +141,7 @@ export function createClaudeAdapter(options: ClaudeAdapterOptions = {}): AgentAd
169141 ...status ,
170142 kind,
171143 label,
172- capabilities : capabilitiesWithProfile ( status . capabilities , options . profileLabel ) ,
144+ capabilities : status . capabilities ,
173145 } ;
174146 } ,
175147 buildLaunchArgv ( location , config , prompt , _sessionRef , _launchOptions ) {
0 commit comments