Skip to content

Commit f6c6c34

Browse files
committed
fix(tailscale): fix transformResponse signatures and block output types
1 parent 1457d85 commit f6c6c34

6 files changed

Lines changed: 52 additions & 56 deletions

File tree

apps/sim/blocks/blocks/tailscale.ts

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -298,45 +298,44 @@ export const TailscaleBlock: BlockConfig = {
298298
},
299299

300300
outputs: {
301-
response: {
302-
type: {
303-
devices: 'json',
304-
count: 'number',
305-
id: 'string',
306-
name: 'string',
307-
hostname: 'string',
308-
user: 'string',
309-
os: 'string',
310-
clientVersion: 'string',
311-
addresses: 'json',
312-
tags: 'json',
313-
authorized: 'boolean',
314-
blocksIncomingConnections: 'boolean',
315-
lastSeen: 'string',
316-
created: 'string',
317-
enabledRoutes: 'json',
318-
advertisedRoutes: 'json',
319-
isExternal: 'boolean',
320-
updateAvailable: 'boolean',
321-
machineKey: 'string',
322-
nodeKey: 'string',
323-
success: 'boolean',
324-
deviceId: 'string',
325-
keyExpiryDisabled: 'boolean',
326-
dns: 'json',
327-
magicDNS: 'boolean',
328-
searchPaths: 'json',
329-
users: 'json',
330-
keys: 'json',
331-
key: 'string',
332-
keyId: 'string',
333-
description: 'string',
334-
expires: 'string',
335-
revoked: 'string',
336-
capabilities: 'json',
337-
acl: 'string',
338-
etag: 'string',
339-
},
301+
devices: { type: 'json', description: 'List of devices in the tailnet' },
302+
count: { type: 'number', description: 'Total count of items returned' },
303+
id: { type: 'string', description: 'Device or auth key ID' },
304+
name: { type: 'string', description: 'Device name' },
305+
hostname: { type: 'string', description: 'Device hostname' },
306+
user: { type: 'string', description: 'Associated user' },
307+
os: { type: 'string', description: 'Operating system' },
308+
clientVersion: { type: 'string', description: 'Tailscale client version' },
309+
addresses: { type: 'json', description: 'Tailscale IP addresses' },
310+
tags: { type: 'json', description: 'Device or auth key tags' },
311+
authorized: { type: 'boolean', description: 'Whether the device is authorized' },
312+
blocksIncomingConnections: {
313+
type: 'boolean',
314+
description: 'Whether the device blocks incoming connections',
340315
},
316+
lastSeen: { type: 'string', description: 'Last seen timestamp' },
317+
created: { type: 'string', description: 'Creation timestamp' },
318+
enabledRoutes: { type: 'json', description: 'Enabled subnet routes' },
319+
advertisedRoutes: { type: 'json', description: 'Advertised subnet routes' },
320+
isExternal: { type: 'boolean', description: 'Whether the device is external' },
321+
updateAvailable: { type: 'boolean', description: 'Whether an update is available' },
322+
machineKey: { type: 'string', description: 'Machine key' },
323+
nodeKey: { type: 'string', description: 'Node key' },
324+
success: { type: 'boolean', description: 'Whether the operation succeeded' },
325+
deviceId: { type: 'string', description: 'Device ID' },
326+
keyExpiryDisabled: { type: 'boolean', description: 'Whether key expiry is disabled' },
327+
dns: { type: 'json', description: 'DNS nameserver addresses' },
328+
magicDNS: { type: 'boolean', description: 'Whether MagicDNS is enabled' },
329+
searchPaths: { type: 'json', description: 'DNS search paths' },
330+
users: { type: 'json', description: 'List of users in the tailnet' },
331+
keys: { type: 'json', description: 'List of auth keys' },
332+
key: { type: 'string', description: 'Auth key value (only at creation)' },
333+
keyId: { type: 'string', description: 'Auth key ID' },
334+
description: { type: 'string', description: 'Auth key description' },
335+
expires: { type: 'string', description: 'Expiration timestamp' },
336+
revoked: { type: 'string', description: 'Revocation timestamp' },
337+
capabilities: { type: 'json', description: 'Auth key capabilities' },
338+
acl: { type: 'string', description: 'ACL policy as JSON string' },
339+
etag: { type: 'string', description: 'ACL ETag for conditional updates' },
341340
},
342341
}

apps/sim/tools/tailscale/authorize_device.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export const tailscaleAuthorizeDeviceTool: ToolConfig<
5050
}),
5151
},
5252

53-
transformResponse: async (response, _ctx, params) => {
54-
const typedParams = params as { deviceId?: string; authorized?: boolean }
53+
transformResponse: async (response: Response, params?: TailscaleAuthorizeDeviceParams) => {
5554
if (!response.ok) {
5655
const data = await response.json().catch(() => ({}))
5756
return {
@@ -65,8 +64,8 @@ export const tailscaleAuthorizeDeviceTool: ToolConfig<
6564
success: true,
6665
output: {
6766
success: true,
68-
deviceId: typedParams?.deviceId ?? '',
69-
authorized: typedParams?.authorized ?? true,
67+
deviceId: params?.deviceId ?? '',
68+
authorized: params?.authorized ?? true,
7069
},
7170
}
7271
},

apps/sim/tools/tailscale/delete_auth_key.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const tailscaleDeleteAuthKeyTool: ToolConfig<
5252
}),
5353
},
5454

55-
transformResponse: async (response, _ctx, params) => {
55+
transformResponse: async (response: Response, params?: TailscaleDeleteAuthKeyParams) => {
5656
if (!response.ok) {
5757
const data = await response.json().catch(() => ({}))
5858
return {
@@ -66,7 +66,7 @@ export const tailscaleDeleteAuthKeyTool: ToolConfig<
6666
success: true,
6767
output: {
6868
success: true,
69-
keyId: (params as TailscaleDeleteAuthKeyParams)?.keyId ?? '',
69+
keyId: params?.keyId ?? '',
7070
},
7171
}
7272
},

apps/sim/tools/tailscale/delete_device.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const tailscaleDeleteDeviceTool: ToolConfig<
4040
}),
4141
},
4242

43-
transformResponse: async (response, _ctx, params) => {
43+
transformResponse: async (response: Response, params?: TailscaleDeviceParams) => {
4444
if (!response.ok) {
4545
const data = await response.json().catch(() => ({}))
4646
return {
@@ -54,7 +54,7 @@ export const tailscaleDeleteDeviceTool: ToolConfig<
5454
success: true,
5555
output: {
5656
success: true,
57-
deviceId: (params as { deviceId?: string })?.deviceId ?? '',
57+
deviceId: params?.deviceId ?? '',
5858
},
5959
}
6060
},

apps/sim/tools/tailscale/set_device_tags.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export const tailscaleSetDeviceTagsTool: ToolConfig<
5353
}),
5454
},
5555

56-
transformResponse: async (response, _ctx, params) => {
57-
const typedParams = params as { deviceId?: string; tags?: string }
56+
transformResponse: async (response: Response, params?: TailscaleSetDeviceTagsParams) => {
5857
if (!response.ok) {
5958
const data = await response.json().catch(() => ({}))
6059
return {
@@ -64,8 +63,8 @@ export const tailscaleSetDeviceTagsTool: ToolConfig<
6463
}
6564
}
6665

67-
const tags = typedParams?.tags
68-
? typedParams.tags
66+
const tags = params?.tags
67+
? params.tags
6968
.split(',')
7069
.map((t) => t.trim())
7170
.filter(Boolean)
@@ -75,7 +74,7 @@ export const tailscaleSetDeviceTagsTool: ToolConfig<
7574
success: true,
7675
output: {
7776
success: true,
78-
deviceId: typedParams?.deviceId ?? '',
77+
deviceId: params?.deviceId ?? '',
7978
tags,
8079
},
8180
}

apps/sim/tools/tailscale/update_device_key.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export const tailscaleUpdateDeviceKeyTool: ToolConfig<
5050
}),
5151
},
5252

53-
transformResponse: async (response, _ctx, params) => {
54-
const typedParams = params as { deviceId?: string; keyExpiryDisabled?: boolean }
53+
transformResponse: async (response: Response, params?: TailscaleUpdateDeviceKeyParams) => {
5554
if (!response.ok) {
5655
const data = await response.json().catch(() => ({}))
5756
return {
@@ -65,8 +64,8 @@ export const tailscaleUpdateDeviceKeyTool: ToolConfig<
6564
success: true,
6665
output: {
6766
success: true,
68-
deviceId: typedParams?.deviceId ?? '',
69-
keyExpiryDisabled: typedParams?.keyExpiryDisabled ?? true,
67+
deviceId: params?.deviceId ?? '',
68+
keyExpiryDisabled: params?.keyExpiryDisabled ?? true,
7069
},
7170
}
7271
},

0 commit comments

Comments
 (0)