Implementation:777genius Agent teams ai OpenCodeLocalProviderConnector listLocalProviders
| Knowledge Sources | |
|---|---|
| Domains | Provider_Management, Configuration |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Concrete tool for discovering and listing locally configured OpenCode provider entries from global or project-scoped config files, provided by the Agent Teams application.
Description
The OpenCodeLocalProviderConnector class implements the `RuntimeLocalProviderConnectorPort` interface for the OpenCode runtime. It reads provider configurations from the filesystem, resolves the config target based on scope (global or project), and returns a structured list of discovered providers.
Key behaviors:
- Input validation: Only 'opencode' runtime ID is supported; scope must be 'global' or 'project'; provider ID must match `PROVIDER_ID_FILTER_PATTERN`.
- Config target resolution: `readOpenCodeConfigTarget()` resolves the config file path based on scope and optional project path, with environment-aware home directory resolution.
- Config writer serialization: Config read-modify-write operations are serialized through `OpenCodeLocalProviderConfigWriter` (single-chain queue).
- Private network approval: A `JsonLocalProviderPrivateNetworkApprovalStore` tracks which private network providers the user has approved.
- Empty config handling: If no config file exists, returns an empty provider list with the resolved scope and path.
Usage
- Provider list UI: Call `listLocalProviders()` to populate the provider selection dropdown in the onboarding UI.
- Provider filtering: Pass `providerId` to get details for a single provider.
- Config modification: Use the connector's config writer to add or update provider entries.
Code Reference
Source Location
- Repository: agent-teams
- File: src/features/runtime-provider-management/main/infrastructure/OpenCodeLocalProviderConnector.ts
Signature
export class OpenCodeLocalProviderConnector implements RuntimeLocalProviderConnectorPort {
constructor(options?: OpenCodeLocalProviderConnectorOptions);
async listLocalProviders(
input: RuntimeLocalProviderListInput
): Promise<RuntimeLocalProviderListResponse>;
}
export interface RuntimeLocalProviderListInput {
runtimeId: string;
scope: 'global' | 'project';
providerId?: string;
projectPath?: string;
}
Import
import { OpenCodeLocalProviderConnector } from '@features/runtime-provider-management/main/infrastructure/OpenCodeLocalProviderConnector';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| input.runtimeId | string | Yes | Must be 'opencode' |
| input.scope | 'project' | Yes | Config scope to read |
| input.providerId | string | No | Filter to a single provider ID |
| input.projectPath | string | No | Project path (for project scope) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Promise<RuntimeLocalProviderListResponse> | Discovered providers |
| response.schemaVersion | number | Response schema version (1) |
| response.runtimeId | string | Always 'opencode' |
| response.scope | string | Resolved scope |
| response.configPath | undefined | Path to the config file |
| response.providers | LocalProvider[] | Array of discovered provider entries |
Usage Examples
Listing Global Providers
import { OpenCodeLocalProviderConnector } from '@features/runtime-provider-management/main/infrastructure/OpenCodeLocalProviderConnector';
const connector = new OpenCodeLocalProviderConnector();
const response = await connector.listLocalProviders({
runtimeId: 'opencode',
scope: 'global',
});
for (const provider of response.providers) {
console.log(`Provider: ${provider.id} (${provider.type})`);
}
Listing Project-Scoped Providers
const response = await connector.listLocalProviders({
runtimeId: 'opencode',
scope: 'project',
projectPath: '/path/to/my/project',
});
Filtering by Provider ID
const response = await connector.listLocalProviders({
runtimeId: 'opencode',
scope: 'global',
providerId: 'anthropic',
});
if (response.providers.length > 0) {
console.log('Found anthropic provider:', response.providers[0]);
}