MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / resultFromExitCode

Function resultFromExitCode

packages/agent-core/src/session/hooks/runner.ts:118–151  ·  view source on GitHub ↗
(exitCode: number, stdout: string, stderr: string)

Source from the content-addressed store, hash-verified

116}
117
118function resultFromExitCode(exitCode: number, stdout: string, stderr: string): HookResult {
119 if (exitCode === 2) {
120 const message = stderr.trim();
121 return {
122 action: 'block',
123 message,
124 reason: message,
125 stdout,
126 stderr,
127 exitCode,
128 };
129 }
130
131 const structured = exitCode === 0 ? structuredOutput(stdout) : undefined;
132 if (structured?.action === 'block') {
133 return {
134 action: 'block',
135 message: structured.message ?? structured.reason,
136 reason: structured.reason,
137 stdout,
138 stderr,
139 exitCode,
140 structuredOutput: structured.structuredOutput,
141 };
142 }
143
144 return allowResult({
145 message: structured?.message,
146 stdout,
147 stderr,
148 exitCode,
149 structuredOutput: structured?.structuredOutput,
150 });
151}
152
153function structuredOutput(
154 stdout: string,

Callers 1

runHookFunction · 0.85

Calls 2

structuredOutputFunction · 0.85
allowResultFunction · 0.85

Tested by

no test coverage detected