(options: {
agentServerUrl: string
workingDirectory?: string
streamFn: StreamFn
})
| 105 | } |
| 106 | |
| 107 | function createMockAgentBootstrap(options: { |
| 108 | agentServerUrl: string |
| 109 | workingDirectory?: string |
| 110 | streamFn: StreamFn |
| 111 | }): MockAgentBootstrap { |
| 112 | const registry = createEntityRegistry() |
| 113 | |
| 114 | registry.define(`chat`, { |
| 115 | description: `Mock chat entity for conformance and end-to-end tests.`, |
| 116 | handler: async (ctx) => { |
| 117 | ctx.useAgent({ |
| 118 | systemPrompt: `You are a concise test assistant.`, |
| 119 | model: MOCK_CHAT_MODEL, |
| 120 | tools: [], |
| 121 | streamFn: options.streamFn, |
| 122 | }) |
| 123 | await ctx.agent.run() |
| 124 | }, |
| 125 | }) |
| 126 | |
| 127 | const runtime = createRuntimeHandler({ |
| 128 | baseUrl: options.agentServerUrl, |
| 129 | serveEndpoint: appendPathToUrl( |
| 130 | options.agentServerUrl, |
| 131 | MOCK_AGENT_HANDLER_PATH |
| 132 | ), |
| 133 | registry, |
| 134 | subscriptionPathForType: (name) => `/${name}/*/main`, |
| 135 | idleTimeout: 100, |
| 136 | }) |
| 137 | |
| 138 | return { runtime, registry } |
| 139 | } |
| 140 | |
| 141 | function durableStreamTestServerBackendUrl(origin: string): string { |
| 142 | // DurableStreamTestServer.start() returns the HTTP origin, while the |
no test coverage detected