ComputerUseProviderTool creates the provider-defined computer-use tool definition using the declared model-facing desktop geometry.
(provider string, declaredWidth, declaredHeight int)
| 128 | // ComputerUseProviderTool creates the provider-defined computer-use tool |
| 129 | // definition using the declared model-facing desktop geometry. |
| 130 | func ComputerUseProviderTool(provider string, declaredWidth, declaredHeight int) (fantasy.Tool, error) { |
| 131 | switch DefaultComputerUseProvider(provider) { |
| 132 | case ComputerUseProviderAnthropic: |
| 133 | // The run callback is nil because execution is handled separately |
| 134 | // by the AgentTool runner in the chatloop. We extract just the |
| 135 | // provider-defined tool definition. |
| 136 | return fantasyanthropic.NewComputerUseTool( |
| 137 | fantasyanthropic.ComputerUseToolOptions{ |
| 138 | DisplayWidthPx: int64(declaredWidth), |
| 139 | DisplayHeightPx: int64(declaredHeight), |
| 140 | ToolVersion: fantasyanthropic.ComputerUse20251124, |
| 141 | }, |
| 142 | nil, |
| 143 | ).Definition(), nil |
| 144 | case ComputerUseProviderOpenAI: |
| 145 | // OpenAI's GA computer tool schema does not accept display |
| 146 | // dimensions. The declared geometry is applied through screenshot |
| 147 | // sizing and desktop action coordinate scaling. |
| 148 | return openaicomputeruse.Tool(), nil |
| 149 | default: |
| 150 | return nil, xerrors.Errorf("unsupported computer use provider %q, supported providers: %s", provider, |
| 151 | strings.Join(SupportedComputerUseProviders(), ", ")) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | func (t *computerUseTool) ProviderOptions() fantasy.ProviderOptions { |
| 156 | return t.providerOptions |