improvement(mship): add enrichment tool, clean up dead tools (#5058)

* feat(mothership): add enrichment_run server tool for one-off lookups

Implement the Sim-side handler for the copilot enrichment_run tool: runs the
enrichment provider cascade for a single entity and returns the result inline,
surfacing the hosted-key cost as _serviceCost for per-round billing (matching
the media tools). Registered in the server-tool router.

Regenerate the copilot tool catalog/schemas to include enrichment_run.

* fix(mothership): remove leftover touch_plan tool references

touch_plan was removed from the copilot tool catalog earlier, but the Sim side
still referenced it. Regenerating the generated tool catalog (for enrichment_run)
synced it to the current contract and dropped the stale TouchPlan export, which
broke the build where router.ts still imported it.

Remove the dead touch_plan server tool and its test, drop its router
registration and WRITE_ACTIONS entry, simplify getServerToolRegistry (no more
beta-gated server tools), and clean up stale "use touch_plan" guidance strings.

* chore(mothership): trigger dev redeploy

* improvement(mothership): log billed cost on enrichment_run lookups

* fix(contracts): regenerate mship contracts

* fix(contracts): fix mship contracts
This commit is contained in:
Siddharth Ganesan
2026-06-15 10:57:29 -07:00
committed by GitHub
parent 17500432ef
commit cefb2dc239
11 changed files with 297 additions and 625 deletions
-1
View File
@@ -19,7 +19,6 @@ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const GENERATORS = [
'scripts/sync-mothership-stream-contract.ts',
'scripts/sync-tool-catalog.ts',
'scripts/sync-request-trace-contract.ts',
'scripts/sync-trace-spans-contract.ts',
'scripts/sync-trace-attributes-contract.ts',
'scripts/sync-trace-attribute-values-contract.ts',
-77
View File
@@ -1,77 +0,0 @@
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { compile } from 'json-schema-to-typescript'
import { formatGeneratedSource } from './format-generated-source'
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url))
const ROOT = resolve(SCRIPT_DIR, '..')
const DEFAULT_CONTRACT_PATH = resolve(
ROOT,
'../copilot/copilot/contracts/request-trace-v1.schema.json'
)
const OUTPUT_PATH = resolve(ROOT, 'apps/sim/lib/copilot/generated/request-trace-v1.ts')
function generateRuntimeConstants(schema: Record<string, unknown>): string {
const defs = (schema.$defs ?? schema.definitions ?? {}) as Record<string, unknown>
const lines: string[] = []
for (const [name, def] of Object.entries(defs)) {
if (!def || typeof def !== 'object') continue
const defObj = def as Record<string, unknown>
const enumValues = defObj.enum
if (!Array.isArray(enumValues) || enumValues.length === 0) continue
if (!enumValues.every((v) => typeof v === 'string')) continue
const entries = (enumValues as string[])
.map((v) => ` ${JSON.stringify(v)}: ${JSON.stringify(v)}`)
.join(',\n')
lines.push(`export const ${name} = {\n${entries},\n} as const;\n`)
}
return lines.join('\n')
}
async function main() {
const checkOnly = process.argv.includes('--check')
const inputPathArg = process.argv.find((arg) => arg.startsWith('--input='))
const inputPath = inputPathArg
? resolve(ROOT, inputPathArg.slice('--input='.length))
: DEFAULT_CONTRACT_PATH
const raw = await readFile(inputPath, 'utf8')
const schema = JSON.parse(raw)
const types = await compile(schema, 'RequestTraceV1SimReport', {
bannerComment: '// AUTO-GENERATED FILE. DO NOT EDIT.\n//',
unreachableDefinitions: true,
additionalProperties: false,
})
const constants = generateRuntimeConstants(schema)
const rendered = formatGeneratedSource(
constants ? `${types}\n${constants}\n` : types,
OUTPUT_PATH,
ROOT
)
if (checkOnly) {
const existing = await readFile(OUTPUT_PATH, 'utf8').catch(() => null)
if (existing !== rendered) {
throw new Error(
`Generated request trace contract is stale. Run: bun run trace-contracts:generate`
)
}
console.log('Request trace contract is up to date.')
return
}
await mkdir(dirname(OUTPUT_PATH), { recursive: true })
await writeFile(OUTPUT_PATH, rendered, 'utf8')
console.log(`Generated request trace types -> ${OUTPUT_PATH}`)
}
main().catch((err) => {
console.error(err)
process.exit(1)
})