MCPcopy Index your code
hub / github.com/anomalyco/opencode / contextual

Function contextual

packages/core/test/application-tools.test.ts:25–39  ·  view source on GitHub ↗
(contexts: Tool.Context[])

Source from the content-addressed store, hash-verified

23const agent = AgentV2.ID.make("build")
24const assistantMessageID = SessionMessage.ID.make("msg_application_tool")
25const contextual = (contexts: Tool.Context[]) =>
26 Tool.make({
27 description: "Read application context",
28 input: Schema.Struct({ query: Schema.String }),
29 output: Schema.Struct({ answer: Schema.String }),
30 execute: ({ query }, context) =>
31 Effect.sync(() => {
32 contexts.push(context)
33 return { answer: query.toUpperCase() }
34 }),
35 toModelOutput: ({ output }) => [
36 { type: "text", text: output.answer },
37 { type: "file", data: "aGVsbG8=", mime: "image/png", name: "result.png" },
38 ],
39 })
40
41describe("ApplicationTools", () => {
42 it.effect("keeps the Core carrier opaque and executes its single handler", () =>

Callers 1

Calls 3

syncMethod · 0.80
pushMethod · 0.80
makeMethod · 0.45

Tested by

no test coverage detected