Files
WeHub Mirror 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
WeHub snapshot of cb28d14c6f2c081de7a0d8729a8c816c9adef67a
2026-08-10 11:17:50 +08:00

117 lines
4.4 KiB
TypeScript

/**
* @vitest-environment node
*/
import { describe, expect, it } from 'vitest'
import { getToolMetadata, getToolParams } from '@/tools/metadata'
import { getToolOutputsMetadata } from '@/tools/metadata-outputs'
import { getToolIds, hasToolId, resolveToolId } from '@/tools/tool-ids'
/**
* Guards the properties the generated artifacts are relied on for. The
* `tool-metadata:check` script guards that they are in sync with the registry;
* these guard that what they contain is usable.
*/
describe('generated tool metadata', () => {
it('covers the whole registry', () => {
expect(getToolIds().length).toBeGreaterThan(4000)
})
it('resolves a known tool with its params', () => {
const gmail = getToolMetadata('gmail_send')
expect(gmail?.id).toBe('gmail_send')
expect(Object.keys(gmail?.params ?? {})).toContain('to')
})
it('reports unknown tools as absent without throwing', () => {
expect(hasToolId('definitely_not_a_tool')).toBe(false)
expect(getToolMetadata('definitely_not_a_tool')).toBeUndefined()
expect(getToolParams('definitely_not_a_tool')).toBeUndefined()
expect(getToolOutputsMetadata('definitely_not_a_tool')).toBeUndefined()
})
it('resolves declared outputs for a known tool', () => {
expect(getToolOutputsMetadata('gmail_send')).toBeDefined()
})
/**
* `JSON.parse` yields an object with the normal prototype, so a bare bracket
* lookup returns inherited members — `getToolMetadata('constructor')` handed
* back a function typed as tool metadata.
*/
it.each(['constructor', 'toString', 'valueOf', 'hasOwnProperty', '__proto__'])(
'treats inherited key %s as an unknown tool',
(key) => {
expect(getToolMetadata(key)).toBeUndefined()
expect(getToolParams(key)).toBeUndefined()
expect(getToolOutputsMetadata(key)).toBeUndefined()
expect(hasToolId(key)).toBe(false)
}
)
/**
* `getTool` resolves an unversioned name onto the newest version, and callers
* migrated off it depend on that. A plain key lookup would silently report
* versioned tools as missing.
*/
describe('version resolution', () => {
/**
* Only a versioned id whose base name is *not* itself registered exercises
* resolution — where both exist, the base name resolves to itself.
*/
const versionedId = getToolIds().find(
(id) => /_v[2-9]\d*$/.test(id) && !getToolIds().includes(id.replace(/_v\d+$/, ''))
)
it('has at least one versioned tool to exercise', () => {
expect(versionedId).toBeDefined()
})
it('maps an unversioned name onto the newest version', () => {
const baseName = (versionedId as string).replace(/_v\d+$/, '')
expect(getToolIds()).not.toContain(baseName)
expect(resolveToolId(baseName)).toBe(versionedId)
expect(hasToolId(baseName)).toBe(true)
expect(getToolMetadata(baseName)?.id).toBe(getToolMetadata(versionedId as string)?.id)
expect(getToolOutputsMetadata(baseName)).toEqual(
getToolOutputsMetadata(versionedId as string)
)
})
it('returns an unknown name unchanged', () => {
expect(resolveToolId('definitely_not_a_tool')).toBe('definitely_not_a_tool')
})
})
/**
* The registry contains a null param entry (`stt_deepgram_v2`), which crashes
* any consumer that iterates params unguarded. The generator strips those, so
* consumers may iterate freely.
*/
it('contains no null param entries', () => {
for (const id of getToolIds()) {
for (const [paramId, config] of Object.entries(getToolParams(id) ?? {})) {
expect(config, `${id}.${paramId} is empty`).not.toBeNull()
expect(config, `${id}.${paramId} is empty`).toBeDefined()
}
}
})
/**
* The whole point of the artifacts: they carry no executable config, so
* importing them cannot pull the tool implementations into a module graph.
*/
it('contains no function values', () => {
for (const id of getToolIds()) {
const metadata = getToolMetadata(id)
for (const [key, value] of Object.entries(metadata ?? {})) {
expect(typeof value, `${id}.${key} is a function`).not.toBe('function')
}
for (const [paramId, config] of Object.entries(metadata?.params ?? {})) {
for (const [key, value] of Object.entries(config ?? {})) {
expect(typeof value, `${id}.params.${paramId}.${key} is a function`).not.toBe('function')
}
}
}
})
})