Skip to content

AgentConfigService

katanakit-js / AgentConfigService

Defined in: core/services/agentconfig.service.ts:77

AgentConfigService — Singleton facade for per-agent configuration emission.

Applies the Singleton pattern (one shared instance via AgentConfigService.getInstance) and the Facade pattern: unknown agents and invalid input resolve to { data, error, ok }, nothing throws.

The emitters mirror the two boxes every agent-setup UI shows: auto configuration (AgentConfigFile — the file the tool reads) and manual connection (AgentConfigManualEntry — the env names and endpoint to paste by hand). Secret masking is policy, not presentation: emitted values are masked unless the caller passes reveal: true, so a preview can be logged or pasted into a chat without leaking anything.

import { useEmitAgentConfig } from "katanakit-js";
const result = useEmitAgentConfig("opencode", {
provider: "openai",
secret: "sk-…",
mcpServers: [],
});
if (result.ok) console.log(result.data.files[0].content);
useAgentDefinitions(): AgentDefinition[];

Defined in: core/services/agentconfig.service.ts:96

Lists the supported agents.

AgentDefinition[]

The agent registry.


useEmitAgentConfig(agentId, input): SafeResult<AgentConfigOutput>;

Defined in: core/services/agentconfig.service.ts:118

Emits the auto-configuration file and the manual connection entries for one agent.

Parameter Type Description
agentId string The agent to configure.
input AgentConfigInput Provider, secret, optional env var name, base URL and MCP servers.

SafeResult<AgentConfigOutput>

{ data, error, ok } — error.status = 404 for unknown agents.


useFindAgent(agentId): AgentDefinition | undefined;

Defined in: core/services/agentconfig.service.ts:106

Finds an agent definition by id.

Parameter Type Description
agentId string The agent id, e.g. opencode.

AgentDefinition | undefined

The definition, or undefined.


static getInstance(): AgentConfigService;

Defined in: core/services/agentconfig.service.ts:84

Returns the shared instance (Singleton).

AgentConfigService