d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
204 lines
6.0 KiB
TypeScript
204 lines
6.0 KiB
TypeScript
import type { GetLatestReleaseParams, ReleaseResponse } from '@/tools/github/types'
|
|
import {
|
|
RELEASE_ASSET_OUTPUT_PROPERTIES,
|
|
RELEASE_OUTPUT_PROPERTIES,
|
|
USER_OUTPUT,
|
|
} from '@/tools/github/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const getLatestReleaseTool: ToolConfig<GetLatestReleaseParams, ReleaseResponse> = {
|
|
id: 'github_get_latest_release',
|
|
name: 'GitHub Get Latest Release',
|
|
description:
|
|
'Get the latest published, non-draft, non-prerelease release for a GitHub repository. Returns release metadata including assets and download URLs.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
owner: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Repository owner (user or organization)',
|
|
},
|
|
repo: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Repository name',
|
|
},
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'GitHub Personal Access Token',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => `https://api.github.com/repos/${params.owner}/${params.repo}/releases/latest`,
|
|
method: 'GET',
|
|
headers: (params) => ({
|
|
Accept: 'application/vnd.github+json',
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
'X-GitHub-Api-Version': '2022-11-28',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response) => {
|
|
if (!response.ok) {
|
|
const error = await response.json().catch(() => ({}))
|
|
return {
|
|
success: false,
|
|
error: error.message || `Failed to get latest release (HTTP ${response.status})`,
|
|
output: {
|
|
content: '',
|
|
metadata: {
|
|
id: 0,
|
|
tag_name: '',
|
|
name: '',
|
|
html_url: '',
|
|
tarball_url: '',
|
|
zipball_url: '',
|
|
draft: false,
|
|
prerelease: false,
|
|
created_at: '',
|
|
published_at: '',
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
const data = await response.json()
|
|
|
|
const assetsInfo =
|
|
data.assets && data.assets.length > 0
|
|
? `\n\nAssets (${data.assets.length}):\n${data.assets.map((asset: any) => `- ${asset.name} (${asset.size} bytes, downloaded ${asset.download_count} times)`).join('\n')}`
|
|
: '\n\nNo assets attached'
|
|
|
|
const content = `Latest release: "${data.name || data.tag_name}"
|
|
Tag: ${data.tag_name}
|
|
Author: ${data.author?.login || 'Unknown'}
|
|
Created: ${data.created_at}
|
|
${data.published_at ? `Published: ${data.published_at}` : 'Not yet published'}
|
|
URL: ${data.html_url}
|
|
|
|
Description:
|
|
${data.body || 'No description provided'}
|
|
|
|
Download URLs:
|
|
- Tarball: ${data.tarball_url}
|
|
- Zipball: ${data.zipball_url}${assetsInfo}`
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
content,
|
|
metadata: {
|
|
id: data.id,
|
|
tag_name: data.tag_name,
|
|
name: data.name || data.tag_name,
|
|
html_url: data.html_url,
|
|
tarball_url: data.tarball_url,
|
|
zipball_url: data.zipball_url,
|
|
draft: data.draft,
|
|
prerelease: data.prerelease,
|
|
created_at: data.created_at,
|
|
published_at: data.published_at,
|
|
},
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
content: { type: 'string', description: 'Human-readable release details' },
|
|
metadata: {
|
|
type: 'object',
|
|
description: 'Release metadata including download URLs',
|
|
properties: {
|
|
id: { type: 'number', description: 'Release ID' },
|
|
tag_name: { type: 'string', description: 'Git tag name' },
|
|
name: { type: 'string', description: 'Release name' },
|
|
html_url: { type: 'string', description: 'GitHub web URL for the release' },
|
|
tarball_url: { type: 'string', description: 'URL to download release as tarball' },
|
|
zipball_url: { type: 'string', description: 'URL to download release as zipball' },
|
|
draft: { type: 'boolean', description: 'Whether this is a draft release' },
|
|
prerelease: { type: 'boolean', description: 'Whether this is a prerelease' },
|
|
created_at: { type: 'string', description: 'Creation timestamp' },
|
|
published_at: { type: 'string', description: 'Publication timestamp' },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
export const getLatestReleaseV2Tool: ToolConfig<GetLatestReleaseParams, any> = {
|
|
id: 'github_get_latest_release_v2',
|
|
name: getLatestReleaseTool.name,
|
|
description: getLatestReleaseTool.description,
|
|
version: '2.0.0',
|
|
params: getLatestReleaseTool.params,
|
|
request: getLatestReleaseTool.request,
|
|
|
|
transformResponse: async (response: Response) => {
|
|
if (!response.ok) {
|
|
const error = await response.json().catch(() => ({}))
|
|
return {
|
|
success: false,
|
|
error: error.message || `Failed to get latest release (HTTP ${response.status})`,
|
|
output: {
|
|
id: 0,
|
|
tag_name: '',
|
|
name: '',
|
|
body: null,
|
|
html_url: '',
|
|
tarball_url: '',
|
|
zipball_url: '',
|
|
draft: false,
|
|
prerelease: false,
|
|
author: null,
|
|
assets: [],
|
|
created_at: '',
|
|
published_at: null,
|
|
target_commitish: '',
|
|
},
|
|
}
|
|
}
|
|
|
|
const data = await response.json()
|
|
return {
|
|
success: true,
|
|
output: {
|
|
id: data.id,
|
|
tag_name: data.tag_name,
|
|
name: data.name,
|
|
body: data.body ?? null,
|
|
html_url: data.html_url,
|
|
tarball_url: data.tarball_url,
|
|
zipball_url: data.zipball_url,
|
|
draft: data.draft,
|
|
prerelease: data.prerelease,
|
|
author: data.author,
|
|
assets: data.assets,
|
|
created_at: data.created_at,
|
|
published_at: data.published_at ?? null,
|
|
target_commitish: data.target_commitish,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
...RELEASE_OUTPUT_PROPERTIES,
|
|
author: USER_OUTPUT,
|
|
assets: {
|
|
type: 'array',
|
|
description: 'Release assets',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
...RELEASE_ASSET_OUTPUT_PROPERTIES,
|
|
uploader: USER_OUTPUT,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|