@effect-uai/core 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/dist/{AiError-CAX_48RU.d.mts → AiError-Bf1pq4BB.d.mts} +9 -4
  2. package/dist/{AiError-CAX_48RU.d.mts.map → AiError-Bf1pq4BB.d.mts.map} +1 -1
  3. package/dist/{Audio-DPlTsNdz.d.mts → Audio-CR7CSljJ.d.mts} +1 -1
  4. package/dist/{Audio-DPlTsNdz.d.mts.map → Audio-CR7CSljJ.d.mts.map} +1 -1
  5. package/dist/{Image-HNmMpMTh.d.mts → Image-BZmKfIdq.d.mts} +1 -1
  6. package/dist/{Image-HNmMpMTh.d.mts.map → Image-BZmKfIdq.d.mts.map} +1 -1
  7. package/dist/{Items-7ljaVxH_.d.mts → Items-BnIduEV2.d.mts} +7 -7
  8. package/dist/{Items-7ljaVxH_.d.mts.map → Items-BnIduEV2.d.mts.map} +1 -1
  9. package/dist/Loop-D8nWpowc.d.mts +173 -0
  10. package/dist/Loop-D8nWpowc.d.mts.map +1 -0
  11. package/dist/{SandboxError-BvKypkJm.d.mts → SandboxError-CIrVDOMV.d.mts} +2 -2
  12. package/dist/{SandboxError-BvKypkJm.d.mts.map → SandboxError-CIrVDOMV.d.mts.map} +1 -1
  13. package/dist/{StructuredFormat-BbN4dosH.d.mts → StructuredFormat-DHaUJBdd.d.mts} +2 -2
  14. package/dist/{StructuredFormat-BbN4dosH.d.mts.map → StructuredFormat-DHaUJBdd.d.mts.map} +1 -1
  15. package/dist/Tool-2lC_XMth.d.mts +284 -0
  16. package/dist/Tool-2lC_XMth.d.mts.map +1 -0
  17. package/dist/ToolEvent-cWZ2BnbS.d.mts +151 -0
  18. package/dist/ToolEvent-cWZ2BnbS.d.mts.map +1 -0
  19. package/dist/ToolResult-CL4hK_9z.d.mts +157 -0
  20. package/dist/ToolResult-CL4hK_9z.d.mts.map +1 -0
  21. package/dist/Toolkit-Dr9l_hNy.d.mts +196 -0
  22. package/dist/Toolkit-Dr9l_hNy.d.mts.map +1 -0
  23. package/dist/browser/Browser.d.mts +190 -0
  24. package/dist/browser/Browser.d.mts.map +1 -0
  25. package/dist/browser/Browser.mjs +34 -0
  26. package/dist/browser/Browser.mjs.map +1 -0
  27. package/dist/browser/BrowserError.d.mts +141 -0
  28. package/dist/browser/BrowserError.d.mts.map +1 -0
  29. package/dist/browser/BrowserError.mjs +89 -0
  30. package/dist/browser/BrowserError.mjs.map +1 -0
  31. package/dist/browser/BrowserTool.d.mts +58 -0
  32. package/dist/browser/BrowserTool.d.mts.map +1 -0
  33. package/dist/browser/BrowserTool.mjs +86 -0
  34. package/dist/browser/BrowserTool.mjs.map +1 -0
  35. package/dist/{dist-DV5ISja1.mjs → dist-B04dlFHg.mjs} +3 -3
  36. package/dist/{dist-DV5ISja1.mjs.map → dist-B04dlFHg.mjs.map} +1 -1
  37. package/dist/dist-DWgRbDN3.mjs +140 -0
  38. package/dist/dist-DWgRbDN3.mjs.map +1 -0
  39. package/dist/domain/AiError.d.mts +2 -2
  40. package/dist/domain/AiError.mjs +22 -3
  41. package/dist/domain/AiError.mjs.map +1 -1
  42. package/dist/domain/Audio.d.mts +1 -1
  43. package/dist/domain/Image.d.mts +1 -1
  44. package/dist/domain/Items.d.mts +1 -1
  45. package/dist/domain/Music.d.mts +1 -1
  46. package/dist/domain/Turn.d.mts +4 -4
  47. package/dist/domain/Turn.test.mjs +1 -1
  48. package/dist/embedding-model/Embedding.d.mts +1 -1
  49. package/dist/embedding-model/EmbeddingModel.d.mts +1 -1
  50. package/dist/embedding-model/EmbeddingModel.test.mjs +1 -1
  51. package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
  52. package/dist/index.d.mts +19 -13
  53. package/dist/index.mjs +15 -9
  54. package/dist/language-model/LanguageModel.d.mts +10 -5
  55. package/dist/language-model/LanguageModel.d.mts.map +1 -1
  56. package/dist/language-model/LanguageModel.mjs.map +1 -1
  57. package/dist/language-model/LanguageModel.test.mjs +1 -1
  58. package/dist/loop/Loop.d.mts +2 -141
  59. package/dist/loop/Loop.mjs +16 -20
  60. package/dist/loop/Loop.mjs.map +1 -1
  61. package/dist/loop/Loop.test.mjs +18 -1
  62. package/dist/loop/Loop.test.mjs.map +1 -1
  63. package/dist/{magic-string.es-BgIV5Mu3.mjs → magic-string.es-Dk-MMA0F.mjs} +1 -1
  64. package/dist/{magic-string.es-BgIV5Mu3.mjs.map → magic-string.es-Dk-MMA0F.mjs.map} +1 -1
  65. package/dist/music-generator/MusicGenerator.d.mts +2 -2
  66. package/dist/music-generator/MusicGenerator.test.mjs +1 -1
  67. package/dist/observability/Metrics.d.mts +116 -28
  68. package/dist/observability/Metrics.d.mts.map +1 -1
  69. package/dist/observability/Metrics.mjs +250 -38
  70. package/dist/observability/Metrics.mjs.map +1 -1
  71. package/dist/observability/Metrics.test.d.mts +1 -0
  72. package/dist/observability/Metrics.test.mjs +187 -0
  73. package/dist/observability/Metrics.test.mjs.map +1 -0
  74. package/dist/observability/Telemetry.d.mts +37 -0
  75. package/dist/observability/Telemetry.d.mts.map +1 -0
  76. package/dist/observability/Telemetry.mjs +57 -0
  77. package/dist/observability/Telemetry.mjs.map +1 -0
  78. package/dist/observability/Telemetry.test.d.mts +1 -0
  79. package/dist/observability/Telemetry.test.mjs +92 -0
  80. package/dist/observability/Telemetry.test.mjs.map +1 -0
  81. package/dist/retry/Retry.d.mts +2 -2
  82. package/dist/retry/Retry.test.mjs +1 -1
  83. package/dist/sandbox/Sandbox.d.mts +1 -1
  84. package/dist/sandbox/SandboxError.d.mts +1 -1
  85. package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +2 -2
  86. package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +1 -1
  87. package/dist/streaming/JSONL.d.mts +1 -1
  88. package/dist/streaming/JSONL.test.mjs +1 -1
  89. package/dist/streaming/SSE.test.mjs +1 -1
  90. package/dist/structured-format/StructuredFormat.d.mts +1 -1
  91. package/dist/structured-format/StructuredFormat.mjs.map +1 -1
  92. package/dist/structured-format/StructuredFormat.test.mjs +1 -1
  93. package/dist/testing/MockMusicGenerator.d.mts +1 -1
  94. package/dist/testing/MockProvider.d.mts +1 -1
  95. package/dist/testing/MockSpeechSynthesizer.d.mts +1 -1
  96. package/dist/tool/Approval.d.mts +19 -7
  97. package/dist/tool/Approval.d.mts.map +1 -1
  98. package/dist/tool/Approval.mjs +18 -11
  99. package/dist/tool/Approval.mjs.map +1 -1
  100. package/dist/tool/Approval.test.mjs +80 -40
  101. package/dist/tool/Approval.test.mjs.map +1 -1
  102. package/dist/tool/HistoryCheck.d.mts +2 -2
  103. package/dist/tool/Tool.d.mts +2 -2
  104. package/dist/tool/Tool.mjs +190 -36
  105. package/dist/tool/Tool.mjs.map +1 -1
  106. package/dist/tool/Tool.test.mjs +41 -3
  107. package/dist/tool/Tool.test.mjs.map +1 -1
  108. package/dist/tool/ToolEvent.d.mts +2 -151
  109. package/dist/tool/ToolEvent.mjs +5 -0
  110. package/dist/tool/ToolEvent.mjs.map +1 -1
  111. package/dist/tool/ToolResult.d.mts +2 -138
  112. package/dist/tool/ToolResult.mjs +32 -8
  113. package/dist/tool/ToolResult.mjs.map +1 -1
  114. package/dist/tool/Toolkit.d.mts +2 -73
  115. package/dist/tool/Toolkit.mjs +153 -35
  116. package/dist/tool/Toolkit.mjs.map +1 -1
  117. package/dist/tool/Toolkit.test.mjs +271 -11
  118. package/dist/tool/Toolkit.test.mjs.map +1 -1
  119. package/dist/transcriber/Transcriber.d.mts +2 -2
  120. package/dist/transcriber/Transcriber.test.mjs +1 -1
  121. package/dist/web-read/WebRead.d.mts +44 -0
  122. package/dist/web-read/WebRead.d.mts.map +1 -0
  123. package/dist/web-read/WebRead.mjs +18 -0
  124. package/dist/web-read/WebRead.mjs.map +1 -0
  125. package/dist/web-read/WebReadTool.d.mts +57 -0
  126. package/dist/web-read/WebReadTool.d.mts.map +1 -0
  127. package/dist/web-read/WebReadTool.mjs +59 -0
  128. package/dist/web-read/WebReadTool.mjs.map +1 -0
  129. package/dist/web-search/WebSearch.d.mts +1 -1
  130. package/dist/web-search/WebSearchTool.d.mts +12 -6
  131. package/dist/web-search/WebSearchTool.d.mts.map +1 -1
  132. package/dist/web-search/WebSearchTool.mjs +10 -5
  133. package/dist/web-search/WebSearchTool.mjs.map +1 -1
  134. package/package.json +21 -1
  135. package/src/browser/Browser.ts +268 -0
  136. package/src/browser/BrowserError.ts +145 -0
  137. package/src/browser/BrowserTool.ts +161 -0
  138. package/src/domain/AiError.ts +27 -1
  139. package/src/embedding-model/EmbeddingModel.test.ts +4 -0
  140. package/src/index.ts +6 -0
  141. package/src/language-model/LanguageModel.ts +7 -2
  142. package/src/loop/Loop.test.ts +22 -0
  143. package/src/loop/Loop.ts +27 -4
  144. package/src/observability/Metrics.test.ts +266 -0
  145. package/src/observability/Metrics.ts +505 -65
  146. package/src/observability/Telemetry.test.ts +123 -0
  147. package/src/observability/Telemetry.ts +96 -0
  148. package/src/structured-format/StructuredFormat.ts +4 -0
  149. package/src/tool/Approval.test.ts +77 -26
  150. package/src/tool/Approval.ts +72 -27
  151. package/src/tool/Tool.test.ts +55 -2
  152. package/src/tool/Tool.ts +335 -70
  153. package/src/tool/ToolEvent.ts +5 -0
  154. package/src/tool/ToolResult.ts +36 -9
  155. package/src/tool/Toolkit.test.ts +339 -9
  156. package/src/tool/Toolkit.ts +470 -120
  157. package/src/web-read/WebRead.ts +70 -0
  158. package/src/web-read/WebReadTool.ts +96 -0
  159. package/src/web-search/WebSearchTool.ts +11 -5
  160. package/dist/Tool-BKiieFXk.d.mts +0 -102
  161. package/dist/Tool-BKiieFXk.d.mts.map +0 -1
  162. package/dist/loop/Loop.d.mts.map +0 -1
  163. package/dist/tool/ToolEvent.d.mts.map +0 -1
  164. package/dist/tool/ToolResult.d.mts.map +0 -1
  165. package/dist/tool/Toolkit.d.mts.map +0 -1
@@ -0,0 +1,284 @@
1
+ import { v as ToolCall, y as ToolCallOutput } from "./Items-BnIduEV2.mjs";
2
+ import { Effect, Schema } from "effect";
3
+ import * as _$effect_Cause0 from "effect/Cause";
4
+ import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
5
+
6
+ //#region src/tool/Tool.d.ts
7
+ declare namespace Tool_d_exports {
8
+ export { AnyLocalTool, AnyTool, DecodableTool, DecodeResult, Emit, InteractionTool, ProviderTool, SignalTool, Tool, ToolDescriptor, ToolE, ToolError, ToolFailed, ToolInputSchema, ToolR, ToolValidationError, decodeArgs, decodeCallInput, descriptorsOf, execute, fail, fromEffectSchema, fromStandardSchema, interaction, make, noInput, provider, signal, toDescriptors, withName, withRun };
9
+ }
10
+ declare const ToolError_base: Schema.Class<ToolError, Schema.TaggedStruct<"ToolError", {
11
+ readonly call_id: Schema.String;
12
+ readonly tool: Schema.String;
13
+ readonly message: Schema.String;
14
+ readonly cause: Schema.optional<Schema.Unknown>;
15
+ }>, _$effect_Cause0.YieldableError>;
16
+ declare class ToolError extends ToolError_base {}
17
+ declare const ToolValidationError_base: Schema.Class<ToolValidationError, Schema.TaggedStruct<"ToolValidationError", {
18
+ readonly call_id: Schema.String;
19
+ readonly tool: Schema.String;
20
+ readonly issues: Schema.$Array<Schema.Struct<{
21
+ readonly message: Schema.String;
22
+ readonly path: Schema.optional<Schema.$Array<Schema.Unknown>>;
23
+ }>>;
24
+ }>, _$effect_Cause0.YieldableError>;
25
+ /**
26
+ * The model's `arguments` for a call failed the tool's `inputSchema`. Distinct
27
+ * from `ToolError` (malformed JSON, runtime crash) so callers can tell a
28
+ * contract violation apart from a parse or execution failure, and so the
29
+ * structured `issues` survive instead of being flattened into a message string.
30
+ */
31
+ declare class ToolValidationError extends ToolValidationError_base {}
32
+ declare const ToolFailed_base: Schema.Class<ToolFailed, Schema.TaggedStruct<"ToolFailed", {
33
+ readonly message: Schema.String;
34
+ readonly kind: Schema.optional<Schema.String>;
35
+ }>, _$effect_Cause0.YieldableError>;
36
+ /**
37
+ * The deliberate "speak to the model" failure sentinel. A tool's `run` that
38
+ * fails with a `ToolFailed` (or a bare `string`, its sugar) is absorbed by
39
+ * `Toolkit.run` into a `ToolResult.Failure` the model reads and adapts to,
40
+ * instead of ending the run. Every other error type propagates typed on the
41
+ * executor's stream. `kind` overrides the synthesized `Failure.kind`
42
+ * (default `"tool_failed"`) so a tool can hand the model a distinguishable
43
+ * category (`"not_found"`, `"rate_limited"`) without a new result variant.
44
+ */
45
+ declare class ToolFailed extends ToolFailed_base {}
46
+ /**
47
+ * Fail a tool's `run` with a model-visible message (optionally a `kind`).
48
+ * `yield* Tool.fail("page not found", { kind: "not_found" })` inside a
49
+ * `run`'s `Effect.gen`; the executor absorbs it as `ToolResult.Failure`.
50
+ */
51
+ declare const fail: (message: string, options?: {
52
+ readonly kind?: string;
53
+ }) => Effect.Effect<never, ToolFailed>;
54
+ /**
55
+ * Schemas accepted on `Tool.inputSchema`. Must implement both Standard
56
+ * Schema validation and JSON Schema conversion (for rendering tool
57
+ * descriptors to provider request bodies).
58
+ *
59
+ * Any Standard-Schema-compliant library that exposes both interfaces
60
+ * works directly: Zod 4+, Valibot, ArkType, Effect Schema (after
61
+ * `fromEffectSchema`), etc.
62
+ */
63
+ type ToolInputSchema<Input = unknown> = StandardSchemaV1<unknown, Input> & StandardJSONSchemaV1<unknown, Input>;
64
+ /**
65
+ * Convenience wrapper for Effect Schema users - adds both the
66
+ * `validate` and `jsonSchema` extensions to a plain Effect Schema so it
67
+ * can be used as a `Tool.inputSchema`.
68
+ */
69
+ declare const fromEffectSchema: <S extends Schema.Codec<any, any, never, any>>(schema: S) => S & ToolInputSchema<S["Type"]>;
70
+ /**
71
+ * Use any schema library that implements both Standard Schema (validation)
72
+ * and Standard JSON Schema (JSON Schema generation) as a `Tool.inputSchema`.
73
+ * Covers Zod 4.2+, Valibot 1.2+, and ArkType 2.1.28+ in one helper.
74
+ *
75
+ * Effect Schema doesn't implement Standard JSON Schema natively — use
76
+ * `fromEffectSchema` for those.
77
+ *
78
+ * The intersection constraint catches missing interfaces at compile time:
79
+ * a Zod v3 schema (no Standard JSON Schema) produces a precise type error
80
+ * pointing at the missing interface rather than a runtime surprise. The
81
+ * helper itself is a thin type-narrowing identity — schemas that satisfy
82
+ * both standards already structurally satisfy `ToolInputSchema`; the
83
+ * helper makes the input type inference explicit at the call site.
84
+ */
85
+ declare const fromStandardSchema: <S extends StandardSchemaV1 & StandardJSONSchemaV1>(schema: S) => S & ToolInputSchema<StandardSchemaV1.InferOutput<S>>;
86
+ /**
87
+ * Input schema for a tool that takes no arguments. Renders a clean
88
+ * `{ type: "object", properties: {} }`; validation accepts anything and
89
+ * yields `{}`. Use it instead of `fromEffectSchema(Schema.Struct({}))`,
90
+ * which renders a degenerate `anyOf` (object-or-array) that strict
91
+ * providers like Gemini reject.
92
+ */
93
+ declare const noInput: ToolInputSchema<Record<string, never>>;
94
+ /**
95
+ * Emit one intermediate `Event` from inside a tool's `run`. Backed by the
96
+ * executor's per-call queue, so it returns an `Effect` (backpressure) and
97
+ * composes with `Stream.runForEach(emit)`.
98
+ */
99
+ type Emit<Event> = (event: Event) => Effect.Effect<void>;
100
+ /**
101
+ * A model-visible tool with a local `Effect` executor. `run` computes the
102
+ * model-facing `Output`; emitting progress is a side channel via `emit`. A
103
+ * plain tool never calls `emit` (its `Event` is irrelevant); a streaming tool
104
+ * emits intermediate `Event`s that flow to the consumer as
105
+ * `ToolEvent.Progress` in real time.
106
+ *
107
+ * This is one of four tool *kinds*, discriminated by `_tag`. The other three
108
+ * (`ProviderTool`, `SignalTool`, `InteractionTool`) are model-visible but have
109
+ * no local executor — see their constructors below. `Tool` keeps its name (and
110
+ * the `Tool.make` constructor) because the local kind is by far the common one.
111
+ */
112
+ type Tool<Name extends string, Input, Event, Output, E = unknown, R = never> = {
113
+ readonly _tag: "LocalTool";
114
+ readonly name: Name;
115
+ readonly description: string;
116
+ readonly inputSchema: ToolInputSchema<Input>;
117
+ readonly run: (input: Input, emit: Emit<Event>) => Effect.Effect<Output, E, R>;
118
+ /**
119
+ * Bound on this tool's emit queue. Unbounded when omitted. Per-tool because
120
+ * backpressure depends on how a given tool emits, unlike `concurrency`
121
+ * (cross-tool, on `Toolkit.run`'s options).
122
+ */
123
+ readonly emitBufferSize?: number;
124
+ /**
125
+ * Whether the provider should render this tool with its strict-mode
126
+ * flag (OpenAI's `strict: true`, etc). Default: true. The framework
127
+ * never rewrites the schema; if the rendered JSON Schema isn't
128
+ * compatible, the provider returns an error.
129
+ */
130
+ readonly strict?: boolean;
131
+ };
132
+ /**
133
+ * A provider-hosted tool: visible to the model and executed by the *provider*
134
+ * (native web search, code execution, RAG grounding), never by this process.
135
+ * It has no local `run`; `provider`/`config` tell the provider adapter how to
136
+ * render it. Passing it to `Toolkit.run` yields a `non_local_tool` result.
137
+ */
138
+ type ProviderTool<Name extends string, Input, Provider extends string, Config> = {
139
+ readonly _tag: "ProviderTool";
140
+ readonly name: Name;
141
+ readonly description: string;
142
+ readonly inputSchema: ToolInputSchema<Input>;
143
+ readonly provider: Provider;
144
+ readonly config: Config;
145
+ readonly strict?: boolean;
146
+ };
147
+ /**
148
+ * A typed request for the agent loop to change control flow (escalate, pause,
149
+ * schedule, hand off). Model-visible and decodable (`decodeArgs`) but never
150
+ * locally executed — the loop intercepts the call in `onTurnComplete` and acts
151
+ * on it, so there is no fake `run`. `Toolkit.run` reports it as `non_local_tool`.
152
+ */
153
+ type SignalTool<Name extends string, Input> = {
154
+ readonly _tag: "SignalTool";
155
+ readonly name: Name;
156
+ readonly description: string;
157
+ readonly inputSchema: ToolInputSchema<Input>;
158
+ };
159
+ /**
160
+ * A typed request for an external actor (user, channel, frontend) to respond
161
+ * before the loop resumes. Like `SignalTool` it is decode-only, but its
162
+ * lifecycle differs: the loop usually stops/pauses and resumes later by
163
+ * appending a `function_call_output` once the actor replies.
164
+ */
165
+ type InteractionTool<Name extends string, Input> = {
166
+ readonly _tag: "InteractionTool";
167
+ readonly name: Name;
168
+ readonly description: string;
169
+ readonly inputSchema: ToolInputSchema<Input>;
170
+ };
171
+ /** A local (executable) tool of any shape. Readability alias. */
172
+ type AnyLocalTool<E = any, R = any> = Tool<string, any, any, any, E, R>;
173
+ /** Any of the four model-visible tool kinds. */
174
+ type AnyTool<E = any, R = any> = Tool<string, any, any, any, E, R> | ProviderTool<string, any, string, any> | SignalTool<string, any> | InteractionTool<string, any>;
175
+ /** A model-visible tool that carries a decodable input schema (every kind). */
176
+ type DecodableTool<Input> = {
177
+ readonly name: string;
178
+ readonly inputSchema: ToolInputSchema<Input>;
179
+ };
180
+ /** Extract the `R` of a local tool; non-local kinds contribute `never`. */
181
+ type ToolR<T> = T extends Tool<string, any, any, any, any, infer R> ? R : never;
182
+ /** Extract the `E` of a local tool; non-local kinds contribute `never`. */
183
+ type ToolE<T> = T extends Tool<string, any, any, any, infer E, any> ? E : never;
184
+ /**
185
+ * Provider-agnostic tool descriptor. Each provider maps `inputSchema`
186
+ * to its own wire field (OpenAI → `parameters`, Anthropic →
187
+ * `input_schema`). Built from a `Tool` by `Tool.toDescriptors`.
188
+ */
189
+ type ToolDescriptor = {
190
+ readonly name: string;
191
+ readonly description: string;
192
+ readonly inputSchema: Record<string, unknown>;
193
+ readonly strict?: boolean;
194
+ };
195
+ /** A model-visible tool with a local `Effect` executor. */
196
+ declare const make: <Name extends string, Input, Event, Output, E = never, R = never>(spec: Omit<Tool<Name, Input, Event, Output, E, R>, "_tag">) => Tool<Name, Input, Event, Output, E, R>;
197
+ /**
198
+ * A provider-hosted tool (native web search, code execution, RAG grounding).
199
+ * No local executor — `provider`/`config` drive the provider adapter's
200
+ * rendering. The model sees it; `Toolkit.run` reports it as `non_local_tool`.
201
+ */
202
+ declare const provider: <Name extends string, Input, Provider extends string, Config>(spec: Omit<ProviderTool<Name, Input, Provider, Config>, "_tag">) => ProviderTool<Name, Input, Provider, Config>;
203
+ /**
204
+ * A typed control-flow signal to the agent loop (escalate, pause, schedule,
205
+ * hand off). Decode-only: the loop interprets the call rather than executing a
206
+ * handler, so there is no `run`.
207
+ */
208
+ declare const signal: <Name extends string, Input>(spec: Omit<SignalTool<Name, Input>, "_tag">) => SignalTool<Name, Input>;
209
+ /**
210
+ * A typed request for an external actor to respond before the loop resumes
211
+ * (frontend, Telegram, CLI prompt). Decode-only; the loop stops/pauses and
212
+ * resumes by appending the actor's `function_call_output`.
213
+ */
214
+ declare const interaction: <Name extends string, Input>(spec: Omit<InteractionTool<Name, Input>, "_tag">) => InteractionTool<Name, Input>;
215
+ /**
216
+ * Return a copy of a tool under a new `name`. Useful for resolving a name
217
+ * clash before combining tools into one `Toolkit`. Literal-preserving, so the
218
+ * renamed tool keys the toolkit record under the new name statically.
219
+ */
220
+ declare const withName: <N extends string, T extends AnyTool>(tool: T, name: N) => Omit<T, "name"> & {
221
+ readonly name: N;
222
+ };
223
+ /**
224
+ * Replace a local tool's `run`, keeping its model-facing definition (name,
225
+ * description, schema, `_tag`) identical. The new `run`'s `input` is typed from
226
+ * the original tool, so override/mock need no annotation:
227
+ *
228
+ * const safe = { ...toolkit, send_email: Tool.withRun(toolkit.send_email,
229
+ * ({ to }) => Effect.succeed({ status: "dry-run", to })) }
230
+ *
231
+ * Descriptors stay identical to production, so a mocked toolkit can't drift
232
+ * from the contract the model sees.
233
+ */
234
+ declare const withRun: <Name extends string, Input, Event, Output, E, R, Output2, E2 = never, R2 = never>(tool: Tool<Name, Input, Event, Output, E, R>, run: (input: Input, emit: Emit<Event>) => Effect.Effect<Output2, E2, R2>) => Tool<Name, Input, Event, Output2, E2, R2>;
235
+ /** Render tools to provider-agnostic descriptors. Every kind is model-visible. */
236
+ declare const toDescriptors: (tools: ReadonlyArray<AnyTool>) => ReadonlyArray<ToolDescriptor>;
237
+ /**
238
+ * Render a `Toolkit` (a name-indexed record of tools) to descriptors, treating
239
+ * an absent toolkit as no tools. The normalization point the `LanguageModel`
240
+ * boundary uses so a request can carry the toolkit itself instead of a
241
+ * pre-rendered descriptor array. Lives here (not on `Toolkit`) to keep providers
242
+ * free of a dependency on the toolkit module — it only needs the tool values.
243
+ */
244
+ declare const descriptorsOf: (toolkit?: Readonly<Record<string, AnyTool>>) => ReadonlyArray<ToolDescriptor>;
245
+ /**
246
+ * Outcome of decoding a call's `arguments` against a tool's `inputSchema`,
247
+ * as data so both the typed (`decodeArgs`) and result-synthesizing
248
+ * (`Toolkit.run`) callers can translate it their own way.
249
+ */
250
+ type DecodeResult<Input> = {
251
+ readonly _tag: "ok";
252
+ readonly input: Input;
253
+ } | {
254
+ readonly _tag: "parseError";
255
+ } | {
256
+ readonly _tag: "invalid";
257
+ readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
258
+ };
259
+ /**
260
+ * Parse and validate a call's `arguments`. Empty arguments normalize to
261
+ * `{}` (some models emit `""` for zero-arg tools); a throwing validator is
262
+ * captured, not propagated. Never fails.
263
+ */
264
+ declare const decodeCallInput: <Input>(tool: DecodableTool<Input>, call: ToolCall) => Effect.Effect<DecodeResult<Input>>;
265
+ /**
266
+ * Decode and validate a function_call's JSON `arguments` against the tool's
267
+ * own `inputSchema`, yielding the typed input. The decode-only half of
268
+ * `execute` - reach for it when you intercept a call to translate it into a
269
+ * control-flow decision rather than running the tool's `run`.
270
+ *
271
+ * Malformed JSON fails with `ToolError`; a parsed body that violates
272
+ * `inputSchema` fails with `ToolValidationError` carrying the issues.
273
+ */
274
+ declare const decodeArgs: <Input>(tool: DecodableTool<Input>, call: ToolCall) => Effect.Effect<Input, ToolError | ToolValidationError>;
275
+ /**
276
+ * Decode and validate the JSON arguments of a function_call against the
277
+ * tool's input schema, run the tool, and serialize the output into a
278
+ * function_call_output item. Single-shot: intermediate events emitted by
279
+ * `run` are discarded (use `Toolkit.run` to stream them).
280
+ */
281
+ declare const execute: <Name extends string, Input, Event, Output, E, R>(tool: Tool<Name, Input, Event, Output, E, R>, call: ToolCall) => Effect.Effect<ToolCallOutput, E | ToolError | ToolValidationError, R>;
282
+ //#endregion
283
+ export { toDescriptors as A, fromEffectSchema as C, noInput as D, make as E, withRun as M, provider as O, fail as S, interaction as T, Tool_d_exports as _, Emit as a, descriptorsOf as b, SignalTool as c, ToolE as d, ToolError as f, ToolValidationError as g, ToolR as h, DecodeResult as i, withName as j, signal as k, Tool as l, ToolInputSchema as m, AnyTool as n, InteractionTool as o, ToolFailed as p, DecodableTool as r, ProviderTool as s, AnyLocalTool as t, ToolDescriptor as u, decodeArgs as v, fromStandardSchema as w, execute as x, decodeCallInput as y };
284
+ //# sourceMappingURL=Tool-2lC_XMth.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tool-2lC_XMth.d.mts","names":[],"sources":["../src/tool/Tool.ts"],"mappings":"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"}
@@ -0,0 +1,151 @@
1
+ import { t as ToolResult } from "./ToolResult-CL4hK_9z.mjs";
2
+ import { Data } from "effect";
3
+ import * as _$effect_Unify0 from "effect/Unify";
4
+
5
+ //#region src/tool/ToolEvent.d.ts
6
+ declare namespace ToolEvent_d_exports {
7
+ export { ToolEvent, isApprovalRequested, isOutput, isProgress };
8
+ }
9
+ type ToolEvent = Data.TaggedEnum<{
10
+ ApprovalRequested: {
11
+ readonly call_id: string;
12
+ readonly tool: string;
13
+ readonly arguments: string;
14
+ };
15
+ Progress: {
16
+ readonly call_id: string;
17
+ readonly tool: string;
18
+ readonly data: unknown;
19
+ };
20
+ Output: {
21
+ readonly result: ToolResult;
22
+ };
23
+ }>;
24
+ /**
25
+ * Namespace of constructors, type guards, and matchers for `ToolEvent`,
26
+ * provided by `Data.taggedEnum`. Use `ToolEvent.Output({ result })` to build
27
+ * an event, `ToolEvent.$is("Output")` for type narrowing,
28
+ * `ToolEvent.$match({ ApprovalRequested, Progress, Output })` for
29
+ * exhaustive pattern matching.
30
+ */
31
+ declare const ToolEvent: {
32
+ readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
33
+ readonly _tag: "ApprovalRequested";
34
+ readonly call_id: string;
35
+ readonly tool: string;
36
+ readonly arguments: string;
37
+ }, "_tag">;
38
+ readonly Progress: Data.TaggedEnum.ConstructorFrom<{
39
+ readonly _tag: "Progress";
40
+ readonly call_id: string;
41
+ readonly tool: string;
42
+ readonly data: unknown;
43
+ }, "_tag">;
44
+ readonly Output: Data.TaggedEnum.ConstructorFrom<{
45
+ readonly _tag: "Output";
46
+ readonly result: ToolResult;
47
+ }, "_tag">;
48
+ readonly $is: <Tag extends "ApprovalRequested" | "Progress" | "Output">(tag: Tag) => (u: unknown) => u is Extract<{
49
+ readonly _tag: "ApprovalRequested";
50
+ readonly call_id: string;
51
+ readonly tool: string;
52
+ readonly arguments: string;
53
+ }, {
54
+ readonly _tag: Tag;
55
+ }> | Extract<{
56
+ readonly _tag: "Progress";
57
+ readonly call_id: string;
58
+ readonly tool: string;
59
+ readonly data: unknown;
60
+ }, {
61
+ readonly _tag: Tag;
62
+ }> | Extract<{
63
+ readonly _tag: "Output";
64
+ readonly result: ToolResult;
65
+ }, {
66
+ readonly _tag: Tag;
67
+ }>;
68
+ readonly $match: {
69
+ <Cases extends {
70
+ readonly ApprovalRequested: (args: {
71
+ readonly _tag: "ApprovalRequested";
72
+ readonly call_id: string;
73
+ readonly tool: string;
74
+ readonly arguments: string;
75
+ }) => any;
76
+ readonly Progress: (args: {
77
+ readonly _tag: "Progress";
78
+ readonly call_id: string;
79
+ readonly tool: string;
80
+ readonly data: unknown;
81
+ }) => any;
82
+ readonly Output: (args: {
83
+ readonly _tag: "Output";
84
+ readonly result: ToolResult;
85
+ }) => any;
86
+ }>(cases: Cases): (value: {
87
+ readonly _tag: "ApprovalRequested";
88
+ readonly call_id: string;
89
+ readonly tool: string;
90
+ readonly arguments: string;
91
+ } | {
92
+ readonly _tag: "Progress";
93
+ readonly call_id: string;
94
+ readonly tool: string;
95
+ readonly data: unknown;
96
+ } | {
97
+ readonly _tag: "Output";
98
+ readonly result: ToolResult;
99
+ }) => _$effect_Unify0.Unify<ReturnType<Cases["ApprovalRequested" | "Progress" | "Output"]>>;
100
+ <Cases extends {
101
+ readonly ApprovalRequested: (args: {
102
+ readonly _tag: "ApprovalRequested";
103
+ readonly call_id: string;
104
+ readonly tool: string;
105
+ readonly arguments: string;
106
+ }) => any;
107
+ readonly Progress: (args: {
108
+ readonly _tag: "Progress";
109
+ readonly call_id: string;
110
+ readonly tool: string;
111
+ readonly data: unknown;
112
+ }) => any;
113
+ readonly Output: (args: {
114
+ readonly _tag: "Output";
115
+ readonly result: ToolResult;
116
+ }) => any;
117
+ }>(value: {
118
+ readonly _tag: "ApprovalRequested";
119
+ readonly call_id: string;
120
+ readonly tool: string;
121
+ readonly arguments: string;
122
+ } | {
123
+ readonly _tag: "Progress";
124
+ readonly call_id: string;
125
+ readonly tool: string;
126
+ readonly data: unknown;
127
+ } | {
128
+ readonly _tag: "Output";
129
+ readonly result: ToolResult;
130
+ }, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["ApprovalRequested" | "Progress" | "Output"]>>;
131
+ };
132
+ };
133
+ declare const isApprovalRequested: (u: unknown) => u is {
134
+ readonly _tag: "ApprovalRequested";
135
+ readonly call_id: string;
136
+ readonly tool: string;
137
+ readonly arguments: string;
138
+ };
139
+ declare const isProgress: (u: unknown) => u is {
140
+ readonly _tag: "Progress";
141
+ readonly call_id: string;
142
+ readonly tool: string;
143
+ readonly data: unknown;
144
+ };
145
+ declare const isOutput: (u: unknown) => u is {
146
+ readonly _tag: "Output";
147
+ readonly result: ToolResult;
148
+ };
149
+ //#endregion
150
+ export { isProgress as a, isOutput as i, ToolEvent_d_exports as n, isApprovalRequested as r, ToolEvent as t };
151
+ //# sourceMappingURL=ToolEvent-cWZ2BnbS.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolEvent-cWZ2BnbS.d.mts","names":[],"sources":["../src/tool/ToolEvent.ts"],"mappings":";;;;;;;;KAkBY,SAAA,GAAY,IAAA,CAAK,UAAA;EAC3B,iBAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,SAAA;EAAA;EAEX,QAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,IAAA;EAAA;EAEX,MAAA;IAAA,SACW,MAAA,EAAQ,UAAA;EAAA;AAAA;;;;;;;;cAWR,SAAA;EAAA;;;;;;;;;;;;;;qBAXQ,UAAA;EAAA;EAAA;;;;;;;;;;;;;;;;qBAAA,UAAA;EAAA;IAAA;;;;;;;;;;;;;;;;;;yBAAA,UAAA;MAAA;IAAA;;;;;;;;;;;;uBAAA,UAAA;IAAA;;;;;;;;;;;;;;;;yBAAA,UAAA;MAAA;IAAA;;;;;;;;;;;;uBAAA,UAAA;IAAA;;;cAaR,mBAAA,GAAmB,CAAA,cAAA,CAAA;EAAA;;;;;cACnB,UAAA,GAAU,CAAA,cAAA,CAAA;EAAA;;;;;cACV,QAAA,GAAQ,CAAA,cAAA,CAAA;EAAA;mBAfA,UAAA;AAAA"}
@@ -0,0 +1,157 @@
1
+ import { v as ToolCall, y as ToolCallOutput } from "./Items-BnIduEV2.mjs";
2
+ import { Data } from "effect";
3
+ import * as _$effect_Unify0 from "effect/Unify";
4
+
5
+ //#region src/tool/ToolResult.d.ts
6
+ declare namespace ToolResult_d_exports {
7
+ export { ToolResult, cancelled, denied, executionError, failed, isFailure, isOk, nonLocalTool, serializeValue, toToolCallOutput, validationError };
8
+ }
9
+ type ToolResult = Data.TaggedEnum<{
10
+ Ok: {
11
+ readonly call_id: string;
12
+ readonly tool: string;
13
+ readonly value: unknown;
14
+ };
15
+ Failure: {
16
+ readonly call_id: string;
17
+ readonly tool: string;
18
+ readonly kind: string;
19
+ readonly reason?: string;
20
+ };
21
+ }>;
22
+ /**
23
+ * Namespace of constructors, type guards, and matchers for `ToolResult`,
24
+ * provided by `Data.taggedEnum`. Use `ToolResult.$is("Ok")` for type
25
+ * narrowing and `ToolResult.$match({ Ok, Failure })` for exhaustive
26
+ * pattern matching. Synthetic-result helpers (`denied`, `cancelled`,
27
+ * `executionError`, `failed`) below are kinder constructors than the
28
+ * raw `ToolResult.Failure(...)`.
29
+ */
30
+ declare const ToolResult: {
31
+ readonly Ok: Data.TaggedEnum.ConstructorFrom<{
32
+ readonly _tag: "Ok";
33
+ readonly call_id: string;
34
+ readonly tool: string;
35
+ readonly value: unknown;
36
+ }, "_tag">;
37
+ readonly Failure: Data.TaggedEnum.ConstructorFrom<{
38
+ readonly _tag: "Failure";
39
+ readonly call_id: string;
40
+ readonly tool: string;
41
+ readonly kind: string;
42
+ readonly reason?: string;
43
+ }, "_tag">;
44
+ readonly $is: <Tag extends "Ok" | "Failure">(tag: Tag) => (u: unknown) => u is Extract<{
45
+ readonly _tag: "Ok";
46
+ readonly call_id: string;
47
+ readonly tool: string;
48
+ readonly value: unknown;
49
+ }, {
50
+ readonly _tag: Tag;
51
+ }> | Extract<{
52
+ readonly _tag: "Failure";
53
+ readonly call_id: string;
54
+ readonly tool: string;
55
+ readonly kind: string;
56
+ readonly reason?: string;
57
+ }, {
58
+ readonly _tag: Tag;
59
+ }>;
60
+ readonly $match: {
61
+ <Cases extends {
62
+ readonly Ok: (args: {
63
+ readonly _tag: "Ok";
64
+ readonly call_id: string;
65
+ readonly tool: string;
66
+ readonly value: unknown;
67
+ }) => any;
68
+ readonly Failure: (args: {
69
+ readonly _tag: "Failure";
70
+ readonly call_id: string;
71
+ readonly tool: string;
72
+ readonly kind: string;
73
+ readonly reason?: string;
74
+ }) => any;
75
+ }>(cases: Cases): (value: {
76
+ readonly _tag: "Ok";
77
+ readonly call_id: string;
78
+ readonly tool: string;
79
+ readonly value: unknown;
80
+ } | {
81
+ readonly _tag: "Failure";
82
+ readonly call_id: string;
83
+ readonly tool: string;
84
+ readonly kind: string;
85
+ readonly reason?: string;
86
+ }) => _$effect_Unify0.Unify<ReturnType<Cases["Ok" | "Failure"]>>;
87
+ <Cases extends {
88
+ readonly Ok: (args: {
89
+ readonly _tag: "Ok";
90
+ readonly call_id: string;
91
+ readonly tool: string;
92
+ readonly value: unknown;
93
+ }) => any;
94
+ readonly Failure: (args: {
95
+ readonly _tag: "Failure";
96
+ readonly call_id: string;
97
+ readonly tool: string;
98
+ readonly kind: string;
99
+ readonly reason?: string;
100
+ }) => any;
101
+ }>(value: {
102
+ readonly _tag: "Ok";
103
+ readonly call_id: string;
104
+ readonly tool: string;
105
+ readonly value: unknown;
106
+ } | {
107
+ readonly _tag: "Failure";
108
+ readonly call_id: string;
109
+ readonly tool: string;
110
+ readonly kind: string;
111
+ readonly reason?: string;
112
+ }, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["Ok" | "Failure"]>>;
113
+ };
114
+ };
115
+ declare const isOk: (u: unknown) => u is {
116
+ readonly _tag: "Ok";
117
+ readonly call_id: string;
118
+ readonly tool: string;
119
+ readonly value: unknown;
120
+ };
121
+ declare const isFailure: (u: unknown) => u is {
122
+ readonly _tag: "Failure";
123
+ readonly call_id: string;
124
+ readonly tool: string;
125
+ readonly kind: string;
126
+ readonly reason?: string;
127
+ };
128
+ declare const failed: (call: ToolCall, kind: string, reason?: string) => ToolResult;
129
+ /** Explicit user/policy rejection. */
130
+ declare const denied: (call: ToolCall, reason?: string) => ToolResult;
131
+ /** Implicit non-answer (follow-up, inactivity, abort). */
132
+ declare const cancelled: (call: ToolCall, reason?: string) => ToolResult;
133
+ /** Tool's own execution failed (JSON parse error, runtime crash). */
134
+ declare const executionError: (call: ToolCall, reason: string) => ToolResult;
135
+ /**
136
+ * The model called a tool that is visible to it but has no local executor — a
137
+ * provider-hosted, signal, or interaction tool routed through `Toolkit.run`.
138
+ * Distinct from `unknown_tool` (no such tool at all): the loop is expected to
139
+ * intercept these kinds before execution, so this kind flags a missing handler.
140
+ */
141
+ declare const nonLocalTool: (call: ToolCall, reason?: string) => ToolResult;
142
+ /**
143
+ * The model's `arguments` failed the tool's input schema. Distinct kind from
144
+ * `execution_error` so recipes can tell a contract violation apart from a
145
+ * runtime crash.
146
+ */
147
+ declare const validationError: (call: ToolCall, reason?: string) => ToolResult;
148
+ /**
149
+ * Serialize a success value for the wire. A `string` passes through raw
150
+ * (models read plain text best; JSON.stringify would quote and escape it);
151
+ * `undefined` becomes `"null"`; anything else is JSON.
152
+ */
153
+ declare const serializeValue: (value: unknown) => string;
154
+ declare const toToolCallOutput: (r: ToolResult) => ToolCallOutput;
155
+ //#endregion
156
+ export { executionError as a, isOk as c, toToolCallOutput as d, validationError as f, denied as i, nonLocalTool as l, ToolResult_d_exports as n, failed as o, cancelled as r, isFailure as s, ToolResult as t, serializeValue as u };
157
+ //# sourceMappingURL=ToolResult-CL4hK_9z.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolResult-CL4hK_9z.d.mts","names":[],"sources":["../src/tool/ToolResult.ts"],"mappings":";;;;;;;;KAqBY,UAAA,GAAa,IAAA,CAAK,UAAA;EAC5B,EAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,KAAA;EAAA;EAEX,OAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,IAAA;IAAA,SACA,MAAA;EAAA;AAAA;;;;;;;;;cAYA,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEA,IAAA,GAAI,CAAA,cAAA,CAAA;EAAA;;;;;cACJ,SAAA,GAAS,CAAA,cAAA,CAAA;EAAA;;;;;;cAMT,MAAA,GAAU,IAAA,EAAM,QAAA,EAAU,IAAA,UAAc,MAAA,cAAkB,UAAA;;cAS1D,MAAA,GAAU,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;cAI5C,SAAA,GAAa,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;cAI/C,cAAA,GAAkB,IAAA,EAAM,QAAA,EAAU,MAAA,aAAiB,UAAA;;;;;;;cASnD,YAAA,GAAgB,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;;;;;cAYlD,eAAA,GAAmB,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;AA7ClE;;;;cAyDa,cAAA,GAAkB,KAAA;AAAA,cAOlB,gBAAA,GAAoB,CAAA,EAAG,UAAA,KAAa,cAAA"}