test(apiproxy): register question callers
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { Context } from 'cordis'
|
import { Context } from 'cordis'
|
||||||
import type { Agent } from '@deepseek-ai/dsh-agent'
|
import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
|
||||||
import SessionStore from '@deepseek-ai/dsh-session'
|
import SessionStore from '@deepseek-ai/dsh-session'
|
||||||
import UserInteractionService from '@deepseek-ai/dsh-user-interaction'
|
import UserInteractionService from '@deepseek-ai/dsh-user-interaction'
|
||||||
import type { ApiProxy, MuxFrame, RpcRequest } from '@deepseek-ai/dsh-host-apiproxy/api'
|
import type { ApiProxy, MuxFrame, RpcRequest } from '@deepseek-ai/dsh-host-apiproxy/api'
|
||||||
@@ -10,6 +10,7 @@ import { createApiProxy } from '../src/api-proxy.ts'
|
|||||||
async function harness(): Promise<{ ctx: Context; api: ApiProxy }> {
|
async function harness(): Promise<{ ctx: Context; api: ApiProxy }> {
|
||||||
const ctx = new Context()
|
const ctx = new Context()
|
||||||
await ctx.plugin(SessionStore)
|
await ctx.plugin(SessionStore)
|
||||||
|
await ctx.plugin(AgentRegistry)
|
||||||
await ctx.plugin(UserInteractionService)
|
await ctx.plugin(UserInteractionService)
|
||||||
return {
|
return {
|
||||||
ctx,
|
ctx,
|
||||||
@@ -17,8 +18,11 @@ async function harness(): Promise<{ ctx: Context; api: ApiProxy }> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function agent(id: string): Agent {
|
function agent(ctx: Context): Agent {
|
||||||
return { id } as unknown as Agent
|
const session = ctx.sessions.create()
|
||||||
|
const value = { id: session.id, session, status: 'idle', ctx } as Agent
|
||||||
|
ctx.agents.register(value)
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
function openMux(api: ApiProxy, abort: AbortController): {
|
function openMux(api: ApiProxy, abort: AbortController): {
|
||||||
@@ -71,7 +75,7 @@ describe('question response validation', () => {
|
|||||||
const abort = new AbortController()
|
const abort = new AbortController()
|
||||||
const mux = openMux(api, abort)
|
const mux = openMux(api, abort)
|
||||||
const asked = ctx.userInteraction.ask({
|
const asked = ctx.userInteraction.ask({
|
||||||
agent: agent('session-multi'),
|
agent: agent(ctx),
|
||||||
questions: [{
|
questions: [{
|
||||||
id: 'targets',
|
id: 'targets',
|
||||||
question: 'Choose targets and add another',
|
question: 'Choose targets and add another',
|
||||||
@@ -95,7 +99,7 @@ describe('question response validation', () => {
|
|||||||
const abort = new AbortController()
|
const abort = new AbortController()
|
||||||
const mux = openMux(api, abort)
|
const mux = openMux(api, abort)
|
||||||
const asked = ctx.userInteraction.ask({
|
const asked = ctx.userInteraction.ask({
|
||||||
agent: agent('session-single'),
|
agent: agent(ctx),
|
||||||
questions: [{
|
questions: [{
|
||||||
id: 'target',
|
id: 'target',
|
||||||
question: 'Choose one target',
|
question: 'Choose one target',
|
||||||
|
|||||||
Reference in New Issue
Block a user