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
217 lines
6.5 KiB
TypeScript
217 lines
6.5 KiB
TypeScript
import {
|
|
PARENT_OWNER_OUTPUT_PROPERTIES,
|
|
PARENT_REPO_OUTPUT_PROPERTIES,
|
|
SOURCE_REPO_OUTPUT_PROPERTIES,
|
|
USER_FULL_OUTPUT_PROPERTIES,
|
|
} from '@/tools/github/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
interface ForkRepoParams {
|
|
owner: string
|
|
repo: string
|
|
organization?: string
|
|
name?: string
|
|
default_branch_only?: boolean
|
|
apiKey: string
|
|
}
|
|
|
|
interface ForkRepoResponse {
|
|
success: boolean
|
|
output: {
|
|
content: string
|
|
metadata: {
|
|
id: number
|
|
full_name: string
|
|
html_url: string
|
|
clone_url: string
|
|
ssh_url: string
|
|
default_branch: string
|
|
fork: boolean
|
|
parent: { full_name: string; html_url: string }
|
|
owner: { login: string }
|
|
created_at: string
|
|
}
|
|
}
|
|
}
|
|
|
|
export const forkRepoTool: ToolConfig<ForkRepoParams, ForkRepoResponse> = {
|
|
id: 'github_fork_repo',
|
|
name: 'GitHub Fork Repository',
|
|
description: 'Fork a repository to your account or an organization',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
owner: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Repository owner to fork from',
|
|
},
|
|
repo: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Repository name to fork',
|
|
},
|
|
organization: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Organization to fork into (omit to fork to your account)',
|
|
},
|
|
name: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Custom name for the forked repository',
|
|
},
|
|
default_branch_only: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Only fork the default branch (default: false)',
|
|
default: false,
|
|
},
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'GitHub API token',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => `https://api.github.com/repos/${params.owner}/${params.repo}/forks`,
|
|
method: 'POST',
|
|
headers: (params) => ({
|
|
Accept: 'application/vnd.github.v3+json',
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
'Content-Type': 'application/json',
|
|
'X-GitHub-Api-Version': '2022-11-28',
|
|
}),
|
|
body: (params) => {
|
|
const body: Record<string, any> = {}
|
|
if (params.organization) body.organization = params.organization
|
|
if (params.name) body.name = params.name
|
|
if (params.default_branch_only !== undefined)
|
|
body.default_branch_only = params.default_branch_only
|
|
return body
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response) => {
|
|
const data = await response.json()
|
|
|
|
const content = `Forked repository: ${data.html_url}
|
|
Forked from: ${data.parent?.full_name ?? 'unknown'}
|
|
Clone URL: ${data.clone_url}
|
|
Default branch: ${data.default_branch}`
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
content,
|
|
metadata: {
|
|
id: data.id,
|
|
full_name: data.full_name,
|
|
html_url: data.html_url,
|
|
clone_url: data.clone_url,
|
|
ssh_url: data.ssh_url,
|
|
default_branch: data.default_branch,
|
|
fork: data.fork,
|
|
parent: {
|
|
full_name: data.parent?.full_name ?? '',
|
|
html_url: data.parent?.html_url ?? '',
|
|
},
|
|
owner: { login: data.owner?.login ?? 'unknown' },
|
|
created_at: data.created_at,
|
|
},
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
content: { type: 'string', description: 'Human-readable result' },
|
|
metadata: {
|
|
type: 'object',
|
|
description: 'Forked repository metadata',
|
|
properties: {
|
|
id: { type: 'number', description: 'Repository ID' },
|
|
full_name: { type: 'string', description: 'Full name (owner/repo)' },
|
|
html_url: { type: 'string', description: 'Web URL' },
|
|
clone_url: { type: 'string', description: 'HTTPS clone URL' },
|
|
ssh_url: { type: 'string', description: 'SSH clone URL' },
|
|
default_branch: { type: 'string', description: 'Default branch' },
|
|
fork: { type: 'boolean', description: 'Is a fork' },
|
|
parent: { type: 'object', description: 'Parent repository' },
|
|
owner: { type: 'object', description: 'Owner info' },
|
|
created_at: { type: 'string', description: 'Creation date' },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
export const forkRepoV2Tool: ToolConfig<ForkRepoParams, any> = {
|
|
id: 'github_fork_repo_v2',
|
|
name: forkRepoTool.name,
|
|
description: forkRepoTool.description,
|
|
version: '2.0.0',
|
|
params: forkRepoTool.params,
|
|
request: forkRepoTool.request,
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
return {
|
|
success: true,
|
|
output: {
|
|
...data,
|
|
parent: data.parent ?? null,
|
|
source: data.source ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
id: { type: 'number', description: 'Repository ID' },
|
|
node_id: { type: 'string', description: 'GraphQL node ID' },
|
|
name: { type: 'string', description: 'Repository name' },
|
|
full_name: { type: 'string', description: 'Full name (owner/repo)' },
|
|
private: { type: 'boolean', description: 'Whether repository is private' },
|
|
description: { type: 'string', description: 'Repository description', optional: true },
|
|
html_url: { type: 'string', description: 'GitHub web URL' },
|
|
url: { type: 'string', description: 'API URL' },
|
|
clone_url: { type: 'string', description: 'HTTPS clone URL' },
|
|
ssh_url: { type: 'string', description: 'SSH clone URL' },
|
|
git_url: { type: 'string', description: 'Git protocol URL' },
|
|
default_branch: { type: 'string', description: 'Default branch name' },
|
|
fork: { type: 'boolean', description: 'Whether this is a fork' },
|
|
created_at: { type: 'string', description: 'Creation timestamp' },
|
|
updated_at: { type: 'string', description: 'Last update timestamp' },
|
|
pushed_at: { type: 'string', description: 'Last push timestamp', optional: true },
|
|
owner: {
|
|
type: 'object',
|
|
description: 'Fork owner',
|
|
properties: USER_FULL_OUTPUT_PROPERTIES,
|
|
},
|
|
parent: {
|
|
type: 'object',
|
|
description: 'Parent repository (source of the fork)',
|
|
optional: true,
|
|
properties: {
|
|
...PARENT_REPO_OUTPUT_PROPERTIES,
|
|
owner: {
|
|
type: 'object',
|
|
description: 'Parent owner',
|
|
properties: PARENT_OWNER_OUTPUT_PROPERTIES,
|
|
},
|
|
},
|
|
},
|
|
source: {
|
|
type: 'object',
|
|
description: 'Source repository (ultimate origin)',
|
|
optional: true,
|
|
properties: SOURCE_REPO_OUTPUT_PROPERTIES,
|
|
},
|
|
},
|
|
}
|