* Settle one resolved Maka tool call. Tool/business failures resolve with a * provider-facing error output; durable runtime commit failures still reject.
(call: ResolvedMakaToolCall)
| 692 | * provider-facing error output; durable runtime commit failures still reject. |
| 693 | */ |
| 694 | async settleToolCall(call: ResolvedMakaToolCall): Promise<ToolSettlement> { |
| 695 | const settlement = await this.settleToolCallRaw(call); |
| 696 | const modelOutput = settlement.providerError |
| 697 | ? call.tool.providerTool?.kind === 'openai-apply-patch' |
| 698 | ? { |
| 699 | type: 'json' as const, |
| 700 | value: { status: 'failed' as const, output: settlement.providerError }, |
| 701 | } |
| 702 | : { type: 'error-text' as const, value: new Error(settlement.providerError).toString() } |
| 703 | : call.tool.toModelOutput |
| 704 | ? await call.tool.toModelOutput({ |
| 705 | toolCallId: call.toolCallId, |
| 706 | input: call.input, |
| 707 | output: settlement.result, |
| 708 | }) |
| 709 | : this.input.materializeDefaultToolResultOutput |
| 710 | ? await this.input.materializeDefaultToolResultOutput({ |
| 711 | toolCallId: call.toolCallId, |
| 712 | output: settlement.result, |
| 713 | }) |
| 714 | : typeof settlement.result === 'string' |
| 715 | ? { type: 'text' as const, value: settlement.result } |
| 716 | : { type: 'json' as const, value: jsonValue(settlement.result) }; |
| 717 | return { result: settlement.result, modelOutput }; |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * Settle a tool without producing provider-visible output. Runtime-owned |