fix(team): speed up provider runtime preflight
This commit is contained in:
parent
a76d0cb2ed
commit
0cbba46083
2 changed files with 52 additions and 4 deletions
|
|
@ -1392,6 +1392,8 @@ interface RuntimeStatusCommandResponse {
|
|||
}
|
||||
|
||||
interface AuthStatusCommandResponse {
|
||||
provider?: string;
|
||||
status?: Partial<CliProviderStatus>;
|
||||
loggedIn?: boolean;
|
||||
authMethod?: string | null;
|
||||
providers?: Record<string, Partial<CliProviderStatus>>;
|
||||
|
|
@ -4410,7 +4412,7 @@ export class TeamProvisioningService {
|
|||
{
|
||||
cwd: params.cwd,
|
||||
env: params.env,
|
||||
timeout: 8_000,
|
||||
timeout: PROVIDER_RUNTIME_STATUS_TIMEOUT_MS,
|
||||
}
|
||||
)
|
||||
: null;
|
||||
|
|
@ -36614,7 +36616,10 @@ export class TeamProvisioningService {
|
|||
authenticated: boolean | null;
|
||||
providerStatus: Partial<CliProviderStatus> | null;
|
||||
} {
|
||||
const providerStatus = parsed.providers?.[providerId] ?? null;
|
||||
const providerStatus =
|
||||
parsed.providers?.[providerId] ??
|
||||
(parsed.provider === providerId || !parsed.provider ? parsed.status : null) ??
|
||||
null;
|
||||
if (typeof providerStatus?.authenticated === 'boolean') {
|
||||
return {
|
||||
authenticated: providerStatus.authenticated,
|
||||
|
|
@ -36656,13 +36661,14 @@ export class TeamProvisioningService {
|
|||
'runtime',
|
||||
'status',
|
||||
'--json',
|
||||
'--summary',
|
||||
'--provider',
|
||||
providerId,
|
||||
]),
|
||||
{
|
||||
cwd,
|
||||
env,
|
||||
timeout: 8_000,
|
||||
timeout: PROVIDER_RUNTIME_STATUS_TIMEOUT_MS,
|
||||
}
|
||||
);
|
||||
const parsed = extractJsonObjectFromCli<RuntimeStatusCommandResponse>(runtimeStatus.stdout);
|
||||
|
|
|
|||
|
|
@ -2288,7 +2288,7 @@ describe('TeamProvisioningService prepare/auth behavior', () => {
|
|||
expect(result.ready).toBe(true);
|
||||
expect(execCliMock).toHaveBeenCalledWith(
|
||||
'/fake/claude',
|
||||
['runtime', 'status', '--json', '--provider', 'codex'],
|
||||
['runtime', 'status', '--json', '--summary', '--provider', 'codex'],
|
||||
expect.objectContaining({ cwd: tempRoot })
|
||||
);
|
||||
expect(spawnProbe).toHaveBeenCalledTimes(1);
|
||||
|
|
@ -2332,6 +2332,7 @@ describe('TeamProvisioningService prepare/auth behavior', () => {
|
|||
'runtime',
|
||||
'status',
|
||||
'--json',
|
||||
'--summary',
|
||||
'--provider',
|
||||
'codex',
|
||||
],
|
||||
|
|
@ -2339,6 +2340,47 @@ describe('TeamProvisioningService prepare/auth behavior', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('accepts provider-specific auth status fallback payloads', async () => {
|
||||
execCliMock.mockImplementation(async (_binaryPath: string | null, args: string[]) => {
|
||||
if (args.includes('runtime')) {
|
||||
throw new Error(
|
||||
'Timeout running: orchestrator-cli runtime status --json --summary --provider anthropic'
|
||||
);
|
||||
}
|
||||
if (args.includes('auth')) {
|
||||
return {
|
||||
stdout: JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
provider: 'anthropic',
|
||||
status: {
|
||||
supported: true,
|
||||
authenticated: true,
|
||||
capabilities: { teamLaunch: true, oneShot: true },
|
||||
},
|
||||
}),
|
||||
stderr: '',
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
return { stdout: '', stderr: '', exitCode: 0 };
|
||||
});
|
||||
|
||||
const svc = new TeamProvisioningService();
|
||||
const result = await (svc as any).probeProviderRuntimeControlPlane({
|
||||
claudePath: '/fake/claude',
|
||||
cwd: tempRoot,
|
||||
env: {
|
||||
PATH: '/usr/bin',
|
||||
SHELL: '/bin/zsh',
|
||||
},
|
||||
providerId: 'anthropic',
|
||||
providerArgs: [],
|
||||
});
|
||||
|
||||
expect(result.warning).toContain('runtime status was unavailable, but auth status passed');
|
||||
expect(result.warning).not.toContain('auth status did not report Anthropic authentication');
|
||||
});
|
||||
|
||||
it('falls back from runtime status timeout to auth status and still checks selected models', async () => {
|
||||
execCliMock.mockImplementation(async (_binaryPath: string | null, args: string[]) => {
|
||||
if (args[0] === 'runtime' && args[1] === 'status') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue