MCPcopy Create free account
hub / github.com/Effect-TS/effect / toContext

Function toContext

packages/ai/ai/src/Toolkit.ts:249–263  ·  view source on GitHub ↗
(
    this: Toolkit<Record<string, Tool.Any>>,
    build: Record<string, (params: any) => any> | Effect.Effect<Record<string, (params: any) => any>>
  )

Source from the content-addressed store, hash-verified

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>>

Callers

nothing calls this directly

Calls 3

entriesMethod · 0.80
contextMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected