Files
deepseek-harness/examples/jsonrpc-agent/tests/fixtures/subagent/subagent-sdk/child-mock-llm.ts
Tianyi Cui 3e89a73c71 test(subagent-sdk): keyless Loader-composition e2e across the SDK wire
A test-only cordis.yml under examples/jsonrpc-agent boots the headless app
through the Loader; a scripted model delegates once to the SDK backend, whose
child is a COMPLETE second harness runtime (own cordis.yml, jsonrpc serving
surface, scripted cwd-echo model, own JSONL persistence). Asserts the parent
tool result AND the child's own persisted transcript both carry the parent
session's workspace cwd; child launch resolves through the shared
example-launch resolver so src/lib modes both hold.
2026-07-27 03:59:46 +08:00

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())
}