Skip to content

Commit a29717e

Browse files
TheodoreSpeaksTheodore Li
andauthored
fix(remove-speed-hosted-key) Remove maps speed limit hosted key, it's deprecated (#3521)
Co-authored-by: Theodore Li <theo@sim.ai>
1 parent f161c26 commit a29717e

File tree

3 files changed

+51
-15
lines changed

3 files changed

+51
-15
lines changed

.cursor/skills/add-hosted-key/SKILL.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,45 @@ In the block config (`blocks/blocks/{service}.ts`), add `hideWhenHosted: true` t
194194

195195
The visibility is controlled by `isSubBlockHiddenByHostedKey()` in `lib/workflows/subblocks/visibility.ts`, which checks the `isHosted` feature flag.
196196

197+
### Excluding Specific Operations from Hosted Key Support
198+
199+
When a block has multiple operations but some operations should **not** use a hosted key (e.g., the underlying API is deprecated, unsupported, or too expensive), use the **duplicate apiKey subblock** pattern. This is the same pattern Exa uses for its `research` operation:
200+
201+
1. **Remove the `hosting` config** from the tool definition for that operation — it must not have a `hosting` object at all.
202+
2. **Duplicate the `apiKey` subblock** in the block config with opposing conditions:
203+
204+
```typescript
205+
// API Key — hidden when hosted for operations with hosted key support
206+
{
207+
id: 'apiKey',
208+
title: 'API Key',
209+
type: 'short-input',
210+
placeholder: 'Enter your API key',
211+
password: true,
212+
required: true,
213+
hideWhenHosted: true,
214+
condition: { field: 'operation', value: 'unsupported_op', not: true },
215+
},
216+
// API Key — always visible for unsupported_op (no hosted key support)
217+
{
218+
id: 'apiKey',
219+
title: 'API Key',
220+
type: 'short-input',
221+
placeholder: 'Enter your API key',
222+
password: true,
223+
required: true,
224+
condition: { field: 'operation', value: 'unsupported_op' },
225+
},
226+
```
227+
228+
Both subblocks share the same `id: 'apiKey'`, so the same value flows to the tool. The conditions ensure only one is visible at a time. The first has `hideWhenHosted: true` and shows for all hosted operations; the second has no `hideWhenHosted` and shows only for the excluded operation — meaning users must always provide their own key for that operation.
229+
230+
To exclude multiple operations, use an array: `{ field: 'operation', value: ['op_a', 'op_b'] }`.
231+
232+
**Reference implementations:**
233+
- **Exa** (`blocks/blocks/exa.ts`): `research` operation excluded from hosting — lines 309-329
234+
- **Google Maps** (`blocks/blocks/google_maps.ts`): `speed_limits` operation excluded from hosting (deprecated Roads API)
235+
197236
## Step 5: Add to the BYOK Settings UI
198237

199238
Add an entry to the `PROVIDERS` array in the BYOK settings component so users can bring their own key. You need the service icon from `components/icons.tsx`:

apps/sim/blocks/blocks/google_maps.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const GoogleMapsBlock: BlockConfig = {
3636
value: () => 'geocode',
3737
},
3838

39-
// API Key
39+
// API Key — hidden when hosted for operations with hosted key support
4040
{
4141
id: 'apiKey',
4242
title: 'API Key',
@@ -45,6 +45,17 @@ export const GoogleMapsBlock: BlockConfig = {
4545
placeholder: 'Enter your Google Maps API key',
4646
required: true,
4747
hideWhenHosted: true,
48+
condition: { field: 'operation', value: 'speed_limits', not: true },
49+
},
50+
// API Key — always visible for Speed Limits (deprecated API, no hosted key support)
51+
{
52+
id: 'apiKey',
53+
title: 'API Key',
54+
type: 'short-input',
55+
password: true,
56+
placeholder: 'Enter your Google Maps API key',
57+
required: true,
58+
condition: { field: 'operation', value: 'speed_limits' },
4859
},
4960

5061
// ========== Geocode ==========

apps/sim/tools/google_maps/speed_limits.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ export const googleMapsSpeedLimitsTool: ToolConfig<
3434
},
3535
},
3636

37-
hosting: {
38-
envKeyPrefix: 'GOOGLE_CLOUD_API_KEY',
39-
apiKeyParam: 'apiKey',
40-
byokProviderId: 'google_cloud',
41-
pricing: {
42-
type: 'per_request',
43-
cost: 0.02,
44-
},
45-
rateLimit: {
46-
mode: 'per_request',
47-
requestsPerMinute: 60,
48-
},
49-
},
50-
5137
request: {
5238
url: (params) => {
5339
const hasPath = params.path && params.path.trim().length > 0

0 commit comments

Comments
 (0)