skillhub/plugins/dsh/test/recovery-remote.test.ts
XiaoSeS 3560679793
Some checks failed
Deploy Docs / build (push) Has been cancelled
Security / Dependency Review (push) Has been cancelled
Security / CodeQL (java-kotlin) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(dsh): add native SkillHub plugin for DeepSeek Harness (#956)
Add the native SkillHub plugin for DeepSeek Harness with a scoped skill center, conversation search/install tools, exact-version installation and protected lifecycle management. Prepare the independently versioned 0.1.0 npm candidate with an empty default Registry and documented compatibility limits.

Keep formal specifications and executable regression tests; remove archived development screenshots and runtime reports from the final tree. Review fixes cover independent scopes, installed references, pre-staging recovery and idempotent discovery.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-16 19:22:26 +08:00

46 lines
2.2 KiB
TypeScript

import { expect, test } from 'bun:test';
import { randomUUID } from 'node:crypto';
import SkillHubService from '@astron-team/skillhub-dsh';
test('recovery Remote binds host and owner, rejects raw extra fields and never creates missing operations', async () => {
const input = { operationId: randomUUID(), hostInstanceId: randomUUID() };
let owner = 'session';
let recovered = 0;
let kind = 'uninstall';
let fail = false;
const context = {
ctx: { invocation: { request: { args: { agentId: 'session', input: input as object } } },
get: () => ({ get: () => ({ session: { id: 'session' } }) }) },
localRuntime: {
getStatus: () => ({ state: 'ready', hostInstanceId: input.hostInstanceId }),
getOperation: async (id: string, session: string) => id === input.operationId && session === owner
? { operationId: id, kind, phase: recovered ? 'failed' : 'recovery-required', recovery: recovered ? 'restored' : 'pending' } : undefined,
},
getOperation: SkillHubService.prototype.getOperation,
recoverInstallationOperation: async (session: string, id: string) => {
expect(session).toBe(owner);
expect(id).toBe(input.operationId);
if (fail) throw new Error('/private/host/path');
recovered++;
},
};
const call = (wire: object = input) => {
context.ctx.invocation.request.args.input = wire;
return Reflect.apply(SkillHubService.prototype.recoverOperation, context, [input]);
};
await expect(call({ ...input, path: '/arbitrary' })).rejects.toThrow('Invalid recovery request');
await expect(call({ ...input, hostInstanceId: randomUUID() })).rejects.toThrow('Host identity changed');
expect(await call({ ...input, operationId: randomUUID() })).toBeNull();
owner = 'another-session';
expect(await call()).toBeNull();
owner = 'session';
kind = 'unsupported';
await expect(call()).rejects.toThrow('unavailable for this operation kind');
expect(recovered).toBe(0);
kind = 'uninstall';
fail = true;
await expect(call()).rejects.toThrow('Recovery could not be confirmed');
fail = false;
expect(await call()).toMatchObject({ operationId: input.operationId, recovery: 'restored' });
expect(await call()).toMatchObject({ operationId: input.operationId, recovery: 'restored' });
});