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

Function capture

packages/core/test/session-runner-tool-events.test.ts:15–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13const base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
14
15const capture = () => {
16 const published: Array<{ readonly type: string; readonly data: unknown }> = []
17 const events = EventV2.Service.of({
18 publish: (definition, data) =>
19 Effect.sync(() => {
20 const event = { id: EventV2.ID.create(), type: definition.type, data } as EventV2.Payload<typeof definition>
21 published.push({
22 type: definition.durable
23 ? EventV2.versionedType(definition.type, definition.durable.version)
24 : definition.type,
25 data,
26 })
27 return event
28 }),
29 subscribe: () => Stream.empty,
30 all: () => Stream.empty,
31 durable: () => Stream.empty,
32 listen: () => Effect.succeed(Effect.void),
33 project: () => Effect.void,
34 replay: () => Effect.void,
35 replayAll: () => Effect.succeed(undefined),
36 remove: () => Effect.void,
37 claim: () => Effect.void,
38 })
39 return {
40 published,
41 publisher: createLLMEventPublisher(events, {
42 sessionID,
43 agent: "build",
44 model: {
45 id: ModelV2.ID.make("model"),
46 providerID: ProviderV2.ID.make("provider"),
47 },
48 }),
49 }
50}
51
52const call = LLMEvent.toolCall({ id: "call-image", name: "read", input: { path: "pixel.png" } })
53const result = LLMEvent.toolResult({

Calls 5

createLLMEventPublisherFunction · 0.90
syncMethod · 0.80
pushMethod · 0.80
createMethod · 0.65
makeMethod · 0.45

Tested by

no test coverage detected