MCPcopy Index your code
hub / github.com/callstack/agent-device / readClientConfig

Function readClientConfig

src/mcp/command-tools.ts:121–141  ·  view source on GitHub ↗
(record: Record<string, unknown>)

Source from the content-addressed store, hash-verified

119}
120
121function readClientConfig(record: Record<string, unknown>): AgentDeviceClientConfig {
122 const stateDir = record.stateDir;
123 const includeCost = record.includeCost;
124 const responseLevel = record.responseLevel;
125 const client: AgentDeviceClientConfig = {};
126 if (stateDir !== undefined && (typeof stateDir !== 'string' || stateDir.length === 0)) {
127 throw new Error('Expected stateDir to be a non-empty string.');
128 }
129 if (typeof stateDir === 'string') client.stateDir = stateDir;
130 if (includeCost !== undefined && typeof includeCost !== 'boolean') {
131 throw new Error('Expected includeCost to be a boolean.');
132 }
133 // Only set when explicitly true so the default request shape is untouched
134 // (cost rides on response.data → structuredContent only when opted in).
135 if (includeCost === true) client.cost = true;
136 // Only set when it names a known level so the default request shape is
137 // untouched (responseLevel rides on meta.responseLevel only when opted in).
138 const level = readResponseLevel(responseLevel);
139 if (level !== undefined) client.responseLevel = level;
140 return client;
141}
142
143function readResponseLevel(value: unknown): ResponseLevel | undefined {
144 if (value === undefined) return undefined;

Callers 1

readMcpToolConfigFunction · 0.85

Calls 1

readResponseLevelFunction · 0.85

Tested by

no test coverage detected