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

Function structuredOutput

packages/agent-core/src/session/hooks/runner.ts:153–181  ·  view source on GitHub ↗
(
  stdout: string,
)

Source from the content-addressed store, hash-verified

151}
152
153function structuredOutput(
154 stdout: string,
155): { action?: 'block'; reason?: string; message?: string; structuredOutput: true } | undefined {
156 const text = stdout.trim();
157 if (text.length === 0) return undefined;
158
159 try {
160 const parsed = JSON.parse(text) as unknown;
161 const output = HookJsonOutputSchema.safeParse(parsed);
162 if (!output.success) return undefined;
163
164 const { message, hookSpecificOutput } = output.data;
165 const result = {
166 message: message ?? hookSpecificOutput?.message,
167 structuredOutput: true as const,
168 };
169 if (hookSpecificOutput?.permissionDecision !== 'deny') {
170 return result;
171 }
172 return {
173 action: 'block',
174 message: result.message,
175 reason: hookSpecificOutput.permissionDecisionReason,
176 structuredOutput: true,
177 };
178 } catch {
179 return undefined;
180 }
181}
182
183function allowResult(input: {
184 readonly message?: string;

Callers 1

resultFromExitCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected