The group's convention is package suffix == provider default (subagent-acp/'acp', subagent-spawn/'spawn', subagent-fork/'fork'), and the provider default became dsh-sdk in the last review round — so the package follows: @deepseek-ai/dsh-subagent-dsh-sdk at packages/subagent/subagent-dsh-sdk, plugin name subagent-dsh-sdk, diagnostics prefixed subagent-dsh-sdk:. The dsh echo has precedent (dsh-llm-deepseek). Directory, fixture path, knip/tsconfig/examples registrations, catalogs, READMEs (en+zh), and the Agent Note follow; the sdk-client dispose ladder moves to its own module (src/dispose.ts) with the deterministic FakeChild tier tests restored alongside it.
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import type { Context } from 'cordis'
|
|
import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
|
|
import { LlmAdapter } from '@deepseek-ai/dsh-llm'
|
|
|
|
/**
|
|
* Scripted model for the CHILD runtime: answers every request with its own
|
|
* process cwd, so the driving e2e can prove the parent session's workspace
|
|
* reached the child process across the SDK wire. `options` carries the
|
|
* request; the reply depends only on process state.
|
|
*/
|
|
class CwdEchoAdapter extends LlmAdapter {
|
|
async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
|
|
void options
|
|
const reply = `child cwd: ${process.cwd()}`
|
|
yield { type: 'block-start', index: 0, blockType: 'text' }
|
|
yield { type: 'text-delta', index: 0, text: reply }
|
|
yield { type: 'block-end', index: 0, block: { type: 'text', text: reply } }
|
|
yield { type: 'usage', usage: { inputTokens: 3, outputTokens: reply.length } }
|
|
yield { type: 'finish', reason: { kind: 'stop' } }
|
|
}
|
|
}
|
|
|
|
export const name = 'child-mock-llm'
|
|
export const inject = ['llm']
|
|
|
|
/**
|
|
* Register the cwd-echo adapter under the `mock` provider.
|
|
* @param ctx - the plugin context supplying `ctx.llm`.
|
|
*/
|
|
export function apply(ctx: Context): void {
|
|
ctx.llm.registerAdapter(['mock'], new CwdEchoAdapter())
|
|
}
|