| 247 | ...InspectableProto, |
| 248 | of: identity, |
| 249 | toContext( |
| 250 | this: Toolkit<Record<string, Tool.Any>>, |
| 251 | build: Record<string, (params: any) => any> | Effect.Effect<Record<string, (params: any) => any>> |
| 252 | ) { |
| 253 | return Effect.gen(this, function*() { |
| 254 | const context = yield* Effect.context<never>() |
| 255 | const handlers = Effect.isEffect(build) ? yield* build : build |
| 256 | const contextMap = new Map<string, unknown>() |
| 257 | for (const [name, handler] of Object.entries(handlers)) { |
| 258 | const tool = this.tools[name]! |
| 259 | contextMap.set(tool.id, { handler, context }) |
| 260 | } |
| 261 | return Context.unsafeMake(contextMap) |
| 262 | }) |
| 263 | }, |
| 264 | toLayer( |
| 265 | this: Toolkit<Record<string, Tool.Any>>, |
| 266 | build: Record<string, (params: any) => any> | Effect.Effect<Record<string, (params: any) => any>> |