6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (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 / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import rawMetadata from '@/tools/generated/tool-metadata'
|
|
import { resolveToolId } from '@/tools/tool-ids'
|
|
import type { OAuthConfig, ToolConfig } from '@/tools/types'
|
|
|
|
/**
|
|
* Serializable tool metadata, read without importing the executable registry.
|
|
*
|
|
* `@/tools/registry` is a barrel over 4,300+ tools whose `ToolConfig`s carry
|
|
* closures (`request.headers`, `transformResponse`, `directExecution`), and
|
|
* those closures drag ~4,700 modules into any graph that reaches them. Callers
|
|
* that only need to know a tool's shape — its params, its outputs, or whether it
|
|
* exists — read it from here instead, and stay off the registry entirely.
|
|
*
|
|
* The backing data is generated by `scripts/sync-tool-metadata.ts` and verified
|
|
* in CI by `bun run tool-metadata:check`. Never hand-edit it.
|
|
*
|
|
* Outputs live in `@/tools/metadata-outputs`, not here: they are the larger half
|
|
* of the data and have a single consumer, so keeping them in a separate module
|
|
* means callers that only need params don't pay for them. Callers that need
|
|
* neither should use `@/tools/tool-ids`, which is ~40x smaller again.
|
|
*
|
|
* Lookups resolve unversioned names the same way `getTool` does.
|
|
*/
|
|
export interface ToolMetadata {
|
|
id: string
|
|
name?: string
|
|
description?: string
|
|
version?: string
|
|
params: ToolConfig['params']
|
|
oauth?: OAuthConfig
|
|
}
|
|
|
|
/**
|
|
* Annotated rather than inferred: letting TypeScript infer a literal type for a
|
|
* 4 MB JSON import makes every downstream file that touches it dramatically more
|
|
* expensive to typecheck.
|
|
*/
|
|
const metadata: Record<string, ToolMetadata> = rawMetadata as Record<string, ToolMetadata>
|
|
|
|
/**
|
|
* Serializable metadata for a built-in tool, or `undefined` if unknown.
|
|
*
|
|
* `Object.hasOwn` rather than a bare lookup: `JSON.parse` yields an object with
|
|
* the normal prototype, so a tool id colliding with `constructor`, `toString` or
|
|
* `__proto__` would otherwise return an inherited function typed as tool
|
|
* metadata.
|
|
*/
|
|
export function getToolMetadata(toolId: string): ToolMetadata | undefined {
|
|
const resolved = resolveToolId(toolId)
|
|
return Object.hasOwn(metadata, resolved) ? metadata[resolved] : undefined
|
|
}
|
|
|
|
/** Declared parameters for a built-in tool, or `undefined` if unknown. */
|
|
export function getToolParams(toolId: string): ToolConfig['params'] | undefined {
|
|
return getToolMetadata(toolId)?.params
|
|
}
|