test(tools): migrate remaining executor smoke fixtures
This commit is contained in:
1 parent
5935b6b2cc
commit
ebd6a9cf79
4 files changed
+26
-15
No files matched your search
@@ -1268,6 +1268,7 @@ describe.skipIf(!existsSync(dshBin))('dsh BUILT bin (node lib/bin.js, no tsx)',
|
||||
['session-title', '@deepseek-ai/dsh-session-title'],
|
||||
['system-prompt', '@deepseek-ai/dsh-system-prompt'],
|
||||
['tools', '@deepseek-ai/dsh-tools'],
|
||||
['tool-executor-native', '@deepseek-ai/dsh-tool-executor-native'],
|
||||
['mcp-resources', '@deepseek-ai/dsh-mcp-resources'],
|
||||
['agent', '@deepseek-ai/dsh-agent'],
|
||||
['llm-retry', '@deepseek-ai/dsh-llm-retry'],
|
||||
|
||||
@@ -15,6 +15,7 @@ import AgentRegistry from './packages/core/agent/lib/index.js'
|
||||
import LocalFileSystem from './packages/fs/fs-local/lib/index.js'
|
||||
import SystemPrompt from './packages/core/system-prompt/lib/index.js'
|
||||
import ToolRuntime from './packages/core/tools/lib/index.js'
|
||||
import { executeToolFixture } from './packages/test-support/tool-testkit/lib/index.js'
|
||||
import { Session, SESSION_FORMAT_VERSION } from './packages/core/session/lib/index.js'
|
||||
import * as Present from './packages/deliverables/tool-present/lib/index.js'
|
||||
import { mkdtemp, rm } from 'node:fs/promises'
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
- id: tools
|
||||
name: '@deepseek-ai/dsh-tools'
|
||||
|
||||
- id: tool-executor-native
|
||||
name: '@deepseek-ai/dsh-tool-executor-native'
|
||||
|
||||
- id: subprocess
|
||||
name: '@deepseek-ai/dsh-subprocess-local'
|
||||
|
||||
|
||||
@@ -16,29 +16,31 @@ afterEach(() => {
|
||||
for (const root of temporaryRoots.splice(0)) rmSync(root, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
describe('model-driven dsh-tools generation', () => {
|
||||
it('round-trips the complete service and event structure through the runtime registry', { timeout: 30_000 }, async () => {
|
||||
describe('model-driven tool package generation', () => {
|
||||
it('round-trips the complete service and event structure through the runtime registry', { timeout: 30_000 }, async ({ onTestFinished }) => {
|
||||
const workspace = new WorkspaceAnalyzer({
|
||||
root: workspaceRoot,
|
||||
faces: ['host'],
|
||||
packages: ['@deepseek-ai/dsh-tools'],
|
||||
packages: ['@deepseek-ai/dsh-tools', '@deepseek-ai/dsh-tool-executor-ptc'],
|
||||
}).analyze()
|
||||
const host = workspace.faces.find(candidate => candidate.face === 'host')
|
||||
if (host === undefined) throw new Error('dsh-tools has no analyzed host face')
|
||||
const artifact = new FaceModelEmitter(host).emit('@deepseek-ai/dsh-tools')
|
||||
|
||||
const root = mkdtempSync(join(import.meta.dirname, '.generated-tools-'))
|
||||
temporaryRoots.push(root)
|
||||
const modulePath = join(root, 'host.mjs')
|
||||
writeFileSync(modulePath, artifact.js)
|
||||
const generated = await import(`${pathToFileURL(modulePath).href}?test=${Date.now()}`) as {
|
||||
TYPERT: TypertContribution
|
||||
}
|
||||
|
||||
const ctx = new Context()
|
||||
onTestFinished(() => ctx.fiber.dispose())
|
||||
await ctx.plugin(TypertRegistry)
|
||||
const dispose = ctx.typert.register(generated.TYPERT)
|
||||
const registry = ctx.typert
|
||||
for (const name of ['tools', 'tool-executor-ptc']) {
|
||||
const artifact = new FaceModelEmitter(host).emit(`@deepseek-ai/dsh-${name}`)
|
||||
const modulePath = join(root, `${name}.mjs`)
|
||||
writeFileSync(modulePath, artifact.js)
|
||||
const generated = await import(pathToFileURL(modulePath).href) as { TYPERT: TypertContribution }
|
||||
registry.register(generated.TYPERT)
|
||||
}
|
||||
const record = ctx.typert.getPackage('@deepseek-ai/dsh-tools', 'host')
|
||||
const executor = ctx.typert.getPackage('@deepseek-ai/dsh-tool-executor-ptc', 'host')
|
||||
expect(executor?.model.events.map(event => event.name)).toEqual(['tools/ptc-dispatch-log'])
|
||||
const service = record?.model.services.find(candidate => candidate.key === 'tools')
|
||||
expect(service).toBeDefined()
|
||||
expect({
|
||||
@@ -55,7 +57,10 @@ describe('model-driven dsh-tools generation', () => {
|
||||
methods: api?.methods.map(method => method.signature),
|
||||
}
|
||||
})())
|
||||
expect(record?.model.events.filter(event => event.name.startsWith('tools/')).map(event => ({
|
||||
const events = [...record?.model.events ?? [], ...executor?.model.events ?? []]
|
||||
.filter(event => event.name.startsWith('tools/'))
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
expect(events.map(event => ({
|
||||
name: event.name,
|
||||
mode: event.mode,
|
||||
signature: event.signature,
|
||||
@@ -70,7 +75,8 @@ describe('model-driven dsh-tools generation', () => {
|
||||
TYPE_API.find(type => type.name === 'ToolDefinition'),
|
||||
)
|
||||
|
||||
await dispose()
|
||||
expect(ctx.typert.getPackage('@deepseek-ai/dsh-tools', 'host')).toBeUndefined()
|
||||
await ctx.fiber.dispose()
|
||||
expect(registry.getPackage('@deepseek-ai/dsh-tools', 'host')).toBeUndefined()
|
||||
expect(registry.getPackage('@deepseek-ai/dsh-tool-executor-ptc', 'host')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user