MCPcopy Create free account
hub / github.com/ConsortiumAI/Consortium / query

Function query

packages/consortium-cli/src/claude/sdk/query.ts:186–326  ·  view source on GitHub ↗
(config: {
    prompt: QueryPrompt
    options?: QueryOptions
})

Source from the content-addressed store, hash-verified

184}
185
186export function query(config: {
187 prompt: QueryPrompt
188 options?: QueryOptions
189}): Query {
190 const {
191 prompt,
192 options: {
193 allowedTools = [],
194 appendSystemPrompt,
195 customSystemPrompt,
196 cwd,
197 disallowedTools = [],
198 executable = 'node',
199 executableArgs = [],
200 maxTurns,
201 mcpServers,
202 pathToClaudeCodeExecutable = getDefaultClaudeCodePath(),
203 permissionMode = 'default',
204 continue: continueConversation,
205 resume,
206 model,
207 fallbackModel,
208 strictMcpConfig,
209 canCallTool,
210 settingsPath
211 } = {}
212 } = config
213
214 if (!process.env.CLAUDE_CODE_ENTRYPOINT) {
215 process.env.CLAUDE_CODE_ENTRYPOINT = 'consortium-relay'
216 }
217
218 const args = ['--output-format', 'stream-json', '--verbose']
219
220 if (customSystemPrompt) args.push('--system-prompt', customSystemPrompt)
221 if (appendSystemPrompt) args.push('--append-system-prompt', appendSystemPrompt)
222 if (maxTurns) args.push('--max-turns', maxTurns.toString())
223 if (model) args.push('--model', model)
224 if (canCallTool) {
225 if (typeof prompt === 'string') {
226 throw new Error('canCallTool callback requires --input-format stream-json')
227 }
228 args.push('--permission-prompt-tool', 'stdio')
229 }
230 if (continueConversation) args.push('--continue')
231 if (resume) args.push('--resume', resume)
232 if (allowedTools.length > 0) args.push('--allowedTools', allowedTools.join(','))
233 if (disallowedTools.length > 0) args.push('--disallowedTools', disallowedTools.join(','))
234 if (mcpServers && Object.keys(mcpServers).length > 0) {
235 args.push('--mcp-config', JSON.stringify({ mcpServers }))
236 }
237 if (strictMcpConfig) args.push('--strict-mcp-config')
238 if (permissionMode) args.push('--permission-mode', permissionMode)
239 if (settingsPath) args.push('--settings', settingsPath)
240 if (fallbackModel) {
241 if (model && fallbackModel === model) {
242 throw new Error('Fallback model cannot be the same as the main model.')
243 }

Callers 1

claudeRemoteFunction · 0.90

Calls 9

setErrorMethod · 0.95
getDefaultClaudeCodePathFunction · 0.90
getCleanEnvFunction · 0.90
logDebugFunction · 0.90
streamToStdinFunction · 0.90
endMethod · 0.80
errorMethod · 0.80
cleanupFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected