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

Function buildCliArgs

cli/src/runner/run.ts:1089–1131  ·  view source on GitHub ↗
(
  agent: string,
  options: SpawnSessionOptions,
  yolo?: boolean
)

Source from the content-addressed store, hash-verified

1087}
1088
1089export function buildCliArgs(
1090 agent: string,
1091 options: SpawnSessionOptions,
1092 yolo?: boolean
1093): string[] {
1094 const agentCommand = agent === 'codex'
1095 ? 'codex'
1096 : agent === 'cursor'
1097 ? 'cursor'
1098 : agent === 'gemini'
1099 ? 'gemini'
1100 : agent === 'kimi'
1101 ? 'kimi'
1102 : agent === 'opencode'
1103 ? 'opencode'
1104 : 'claude';
1105 const args = [agentCommand];
1106 if (options.resumeSessionId) {
1107 if (agent === 'codex') {
1108 args.push('resume', options.resumeSessionId);
1109 } else if (agent === 'cursor') {
1110 args.push('--resume', options.resumeSessionId);
1111 } else {
1112 args.push('--resume', options.resumeSessionId);
1113 }
1114 }
1115 args.push('--hapi-starting-mode', 'remote', '--started-by', 'runner');
1116 if (options.model) {
1117 args.push('--model', options.model);
1118 }
1119 if (options.effort && agent === 'claude') {
1120 args.push('--effort', options.effort);
1121 }
1122 if (options.modelReasoningEffort && (agent === 'codex' || agent === 'opencode')) {
1123 args.push('--model-reasoning-effort', options.modelReasoningEffort);
1124 }
1125 if (options.permissionMode && (PERMISSION_MODES as readonly string[]).includes(options.permissionMode)) {
1126 args.push('--permission-mode', options.permissionMode);
1127 } else if (yolo) {
1128 args.push('--yolo');
1129 }
1130 return args;
1131}

Callers 2

spawnSessionFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected