MCPcopy
hub / github.com/anomalyco/opencode / withTool

Function withTool

packages/core/test/tool-bash.test.ts:100–125  ·  view source on GitHub ↗
(
  directory: string,
  body: (registry: ToolRegistry.Interface) => Effect.Effect<A, E, R>,
  processLayer: Layer.Layer<AppProcess.Service> = appProcess,
)

Source from the content-addressed store, hash-verified

98}
99
100const withTool = <A, E, R>(
101 directory: string,
102 body: (registry: ToolRegistry.Interface) => Effect.Effect<A, E, R>,
103 processLayer: Layer.Layer<AppProcess.Service> = appProcess,
104) => {
105 const activeLocation = Layer.succeed(
106 Location.Service,
107 Location.Service.of(location({ directory: AbsolutePath.make(directory) })),
108 )
109 return Effect.gen(function* () {
110 return yield* body(yield* ToolRegistry.Service)
111 }).pipe(
112 Effect.provide(
113 AppNodeBuilder.build(
114 LayerNode.group([ToolRegistry.node, ToolRegistry.toolsNode, LocationMutation.node, BashTool.node]),
115 [
116 [Location.node, activeLocation],
117 [PermissionV2.node, permission],
118 [AppProcess.node, processLayer],
119 [Config.node, config],
120 [ToolOutputStore.node, ToolOutputStore.nodeWithoutConfig],
121 ],
122 ),
123 ),
124 )
125}
126
127const call = (input: typeof BashTool.Input.Type, id = "call-bash") => ({
128 sessionID,

Callers 1

tool-bash.test.tsFile · 0.70

Calls 3

locationFunction · 0.90
bodyFunction · 0.50
makeMethod · 0.45

Tested by

no test coverage detected