skillhub/plugins/dsh/test/integration/fixture-tool-execution.mjs
XiaoSeS 3a3ae6d9b8
Some checks failed
Security / Dependency Review (push) Waiting to run
Security / CodeQL (java-kotlin) (push) Waiting to run
Security / CodeQL (javascript-typescript) (push) Waiting to run
Security / CodeQL (python) (push) Waiting to run
Deploy Docs / build (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
fix(dsh): admit newer hosts without a version ceiling (#1099)
Admit DSH hosts from 0.2.0-rc.2 without an upper version ceiling while retaining capability, ownership, permission and inventory protections.

Separate tested versions from admission, cover DSH 0.2.2-rc.3, and fix clean CI smoke dependency resolution. Prepare the DSH-only 0.6.4 patch; no CLI or application release.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-11-16 15:02:04 +08:00

28 lines
1.7 KiB
JavaScript

import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
/** Execute exactly once through the selected official Host API, never retry a mutation to detect its shape. */
export async function executeFixtureTool(ctx, root, input) {
const manifest = JSON.parse(await readFile(join(root, 'node_modules/@deepseek-ai/dsh/package.json'), 'utf8'));
if (manifest.name !== '@deepseek-ai/dsh') throw new Error('Fixture Host package identity is unavailable.');
const tools = ctx.tools;
if (typeof tools?.execute !== 'function') throw new Error('Fixture tool execution service is unavailable.');
// Batch Hosts expose their schema projection and scoped executor registration.
const batchApi = typeof tools.schemas === 'function' && typeof tools.resolve === 'function'
&& typeof tools.setExecutor === 'function';
if (!batchApi) {
if (typeof tools.schemas !== 'function' || typeof tools.executionMode !== 'function') {
throw new Error('Fixture tool execution contract is unavailable.');
}
return tools.execute(input);
}
const args = JSON.stringify(input.arguments);
if (typeof args !== 'string') throw new Error('Fixture tool arguments must be JSON serializable.');
const batch = await ctx.tools.execute({
calls: [{ type: 'tool-call', id: input.callId, name: input.name, arguments: args }],
agent: input.agent, signal: input.signal, ...(input.toolSet ? { toolSet: input.toolSet } : {}),
});
if (!Array.isArray(batch?.results) || batch.results.length !== 1 || batch.results[0]?.callId !== input.callId
|| typeof batch.results[0]?.result?.isError !== 'boolean') throw new Error('Fixture tool batch did not return the exact call result.');
return batch.results[0].result;
}