(
method: string,
params: unknown,
)
| 24 | const agent = toAgent(this); |
| 25 | |
| 26 | const handler = async ( |
| 27 | method: string, |
| 28 | params: unknown, |
| 29 | ): Promise<unknown> => { |
| 30 | switch (method) { |
| 31 | case schema.AGENT_METHODS.initialize: { |
| 32 | const validatedParams = schema.initializeRequestSchema.parse(params); |
| 33 | return agent.initialize(validatedParams); |
| 34 | } |
| 35 | case schema.AGENT_METHODS.session_new: { |
| 36 | const validatedParams = schema.newSessionRequestSchema.parse(params); |
| 37 | return agent.newSession(validatedParams); |
| 38 | } |
| 39 | case schema.AGENT_METHODS.session_load: { |
| 40 | if (!agent.loadSession) { |
| 41 | throw RequestError.methodNotFound(); |
| 42 | } |
| 43 | const validatedParams = schema.loadSessionRequestSchema.parse(params); |
| 44 | return agent.loadSession(validatedParams); |
| 45 | } |
| 46 | case schema.AGENT_METHODS.authenticate: { |
| 47 | const validatedParams = |
| 48 | schema.authenticateRequestSchema.parse(params); |
| 49 | return agent.authenticate(validatedParams); |
| 50 | } |
| 51 | case schema.AGENT_METHODS.session_prompt: { |
| 52 | const validatedParams = schema.promptRequestSchema.parse(params); |
| 53 | return agent.prompt(validatedParams); |
| 54 | } |
| 55 | case schema.AGENT_METHODS.session_cancel: { |
| 56 | const validatedParams = schema.cancelNotificationSchema.parse(params); |
| 57 | return agent.cancel(validatedParams); |
| 58 | } |
| 59 | default: |
| 60 | throw RequestError.methodNotFound(method); |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | this.#connection = new Connection(handler, input, output); |
| 65 | } |
nothing calls this directly
no test coverage detected