MCPcopy Create free account
hub / github.com/tiann/hapi / buildThreadStartParams

Function buildThreadStartParams

cli/src/codex/utils/appServerConfig.ts:90–130  ·  view source on GitHub ↗
(args: {
    cwd: string;
    mode: EnhancedMode;
    mcpServers: McpServersConfig;
    cliOverrides?: CodexCliOverrides;
    baseInstructions?: string;
    developerInstructions?: string;
})

Source from the content-addressed store, hash-verified

88}
89
90export function buildThreadStartParams(args: {
91 cwd: string;
92 mode: EnhancedMode;
93 mcpServers: McpServersConfig;
94 cliOverrides?: CodexCliOverrides;
95 baseInstructions?: string;
96 developerInstructions?: string;
97}): ThreadStartParams {
98 const approvalPolicy = resolveApprovalPolicy(args.mode);
99 const sandbox = resolveSandbox(args.mode);
100 const allowCliOverrides = args.mode.permissionMode === 'default';
101 const cliOverrides = allowCliOverrides ? args.cliOverrides : undefined;
102 const resolvedApprovalPolicy = cliOverrides?.approvalPolicy ?? approvalPolicy;
103 const resolvedSandbox = cliOverrides?.sandbox ?? sandbox;
104
105 const config = buildMcpServerConfig(args.mcpServers);
106 const {
107 baseInstructions,
108 developerInstructions: resolvedDeveloperInstructions
109 } = resolveInstructions(args);
110 const configWithInstructions = {
111 ...config,
112 developer_instructions: resolvedDeveloperInstructions,
113 ...(args.mode.modelReasoningEffort ? { model_reasoning_effort: args.mode.modelReasoningEffort } : {})
114 };
115
116 const params: ThreadStartParams = {
117 cwd: args.cwd,
118 approvalPolicy: resolvedApprovalPolicy,
119 sandbox: resolvedSandbox,
120 baseInstructions,
121 developerInstructions: resolvedDeveloperInstructions,
122 ...(Object.keys(configWithInstructions).length > 0 ? { config: configWithInstructions } : {})
123 };
124
125 if (args.mode.model) {
126 params.model = args.mode.model;
127 }
128
129 return params;
130}
131
132export function buildTurnStartParams(args: {
133 threadId: string;

Callers 4

ensureThreadForGoalMethod · 0.90
runMainLoopMethod · 0.90

Calls 4

resolveApprovalPolicyFunction · 0.85
resolveSandboxFunction · 0.85
buildMcpServerConfigFunction · 0.85
resolveInstructionsFunction · 0.85

Tested by

no test coverage detected