@effect-uai/core 0.18.0 → 0.19.0-dev-20261109183959
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.
- package/README.md +4 -4
- package/dist/Content-D_Qfn8Ja.d.mts +48 -0
- package/dist/Content-D_Qfn8Ja.d.mts.map +1 -0
- package/dist/File-B923KvZ9.d.mts +46 -0
- package/dist/File-B923KvZ9.d.mts.map +1 -0
- package/dist/{Image-Cv6iBLTy.d.mts → Image-Bzc1H_UK.d.mts} +19 -8
- package/dist/Image-Bzc1H_UK.d.mts.map +1 -0
- package/dist/{Items-C7MyrYPX.d.mts → Items-Bvx8s9QH.d.mts} +109 -16
- package/dist/Items-Bvx8s9QH.d.mts.map +1 -0
- package/dist/{Loop-ChpaO-ya.d.mts → Loop-CeA0AelN.d.mts} +7 -6
- package/dist/Loop-CeA0AelN.d.mts.map +1 -0
- package/dist/Tool-Bkryw6-h.d.mts +206 -0
- package/dist/Tool-Bkryw6-h.d.mts.map +1 -0
- package/dist/ToolEvent-9inLx5cI.d.mts +22 -0
- package/dist/ToolEvent-9inLx5cI.d.mts.map +1 -0
- package/dist/ToolOutput-BNTIQgGB.d.mts +151 -0
- package/dist/ToolOutput-BNTIQgGB.d.mts.map +1 -0
- package/dist/Toolkit-D2VGeD5R.d.mts +212 -0
- package/dist/Toolkit-D2VGeD5R.d.mts.map +1 -0
- package/dist/browser/BrowserTool.d.mts +84 -22
- package/dist/browser/BrowserTool.d.mts.map +1 -1
- package/dist/browser/BrowserTool.mjs +5 -0
- package/dist/browser/BrowserTool.mjs.map +1 -1
- package/dist/capabilities/Capabilities.d.mts +1 -1
- package/dist/decision-model/Decision.test.mjs +1 -1
- package/dist/{dist-C8RmtoR8.mjs → dist-B5K-y4Be.mjs} +51 -32
- package/dist/dist-B5K-y4Be.mjs.map +1 -0
- package/dist/domain/File.d.mts +2 -0
- package/dist/domain/File.mjs +51 -0
- package/dist/domain/File.mjs.map +1 -0
- package/dist/domain/Image.d.mts +2 -2
- package/dist/domain/Image.mjs +12 -2
- package/dist/domain/Image.mjs.map +1 -1
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +65 -4
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Realtime.d.mts +72 -490
- package/dist/domain/Realtime.d.mts.map +1 -1
- package/dist/domain/Research.d.mts +1 -1
- package/dist/domain/Transcript.test.mjs +1 -1
- package/dist/domain/Turn.d.mts +57 -262
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/domain/Turn.mjs +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -1
- package/dist/image-generator/ImageGenerator.d.mts +10 -66
- package/dist/image-generator/ImageGenerator.d.mts.map +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +7 -6
- package/dist/language-model/LanguageModel.d.mts +2 -2
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/messenger/Messenger.d.mts +43 -289
- package/dist/messenger/Messenger.d.mts.map +1 -1
- package/dist/messenger/MessengerAdapter.test.mjs +1 -1
- package/dist/observability/Metrics.d.mts +1 -1
- package/dist/observability/Metrics.test.mjs +1 -1
- package/dist/observability/Telemetry.test.mjs +1 -1
- package/dist/realtime/RealtimeSession.d.mts +1 -1
- package/dist/realtime/RealtimeSession.test.mjs +1 -1
- package/dist/sandbox/Sandbox.d.mts +32 -237
- package/dist/sandbox/Sandbox.d.mts.map +1 -1
- package/dist/streaming/Multipart.mjs +2 -1
- package/dist/streaming/Multipart.mjs.map +1 -1
- package/dist/streaming/Multipart.test.mjs +28 -0
- package/dist/streaming/Multipart.test.mjs.map +1 -0
- package/dist/streaming/Settle.test.mjs +1 -1
- package/dist/streaming/WebSocketSession.test.mjs +1 -1
- package/dist/testing/MockMessenger.d.mts +19 -134
- package/dist/testing/MockMessenger.d.mts.map +1 -1
- package/dist/testing/MockProvider.d.mts +1 -1
- package/dist/testing/MockSandbox.d.mts +65 -446
- package/dist/testing/MockSandbox.d.mts.map +1 -1
- package/dist/tool/Content.d.mts +2 -0
- package/dist/tool/Content.mjs +46 -0
- package/dist/tool/Content.mjs.map +1 -0
- package/dist/tool/Content.test.d.mts +1 -0
- package/dist/tool/Content.test.mjs +48 -0
- package/dist/tool/Content.test.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +6 -15
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +10 -24
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +55 -130
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +220 -176
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolDecision.d.mts +164 -0
- package/dist/tool/ToolDecision.d.mts.map +1 -0
- package/dist/tool/ToolDecision.mjs +146 -0
- package/dist/tool/ToolDecision.mjs.map +1 -0
- package/dist/tool/ToolDecision.test.d.mts +1 -0
- package/dist/tool/ToolDecision.test.mjs +330 -0
- package/dist/tool/ToolDecision.test.mjs.map +1 -0
- package/dist/tool/ToolEvent.d.mts +2 -2
- package/dist/tool/ToolEvent.mjs +2 -34
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/ToolOutput.d.mts +2 -0
- package/dist/tool/ToolOutput.mjs +128 -0
- package/dist/tool/ToolOutput.mjs.map +1 -0
- package/dist/tool/ToolOutput.test.d.mts +1 -0
- package/dist/tool/ToolOutput.test.mjs +153 -0
- package/dist/tool/ToolOutput.test.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +2 -2
- package/dist/tool/Toolkit.mjs +230 -165
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +431 -389
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/web-read/WebReadTool.d.mts +2 -2
- package/dist/web-read/WebReadTool.mjs +1 -0
- package/dist/web-read/WebReadTool.mjs.map +1 -1
- package/dist/web-search/WebSearchTool.d.mts +2 -2
- package/dist/web-search/WebSearchTool.mjs +1 -0
- package/dist/web-search/WebSearchTool.mjs.map +1 -1
- package/package.json +17 -9
- package/src/browser/BrowserTool.ts +5 -0
- package/src/domain/File.ts +79 -0
- package/src/domain/Image.ts +14 -4
- package/src/domain/Items.ts +39 -3
- package/src/index.ts +3 -2
- package/src/loop/Loop.ts +24 -13
- package/src/streaming/Multipart.test.ts +26 -0
- package/src/streaming/Multipart.ts +5 -4
- package/src/tool/Content.test.ts +40 -0
- package/src/tool/Content.ts +38 -0
- package/src/tool/HistoryCheck.ts +21 -26
- package/src/tool/Tool.test.ts +240 -241
- package/src/tool/Tool.ts +203 -308
- package/src/tool/ToolDecision.test.ts +301 -0
- package/src/tool/ToolDecision.ts +360 -0
- package/src/tool/ToolEvent.ts +21 -41
- package/src/tool/ToolOutput.test.ts +132 -0
- package/src/tool/ToolOutput.ts +198 -0
- package/src/tool/Toolkit.test.ts +594 -454
- package/src/tool/Toolkit.ts +631 -356
- package/src/web-read/WebReadTool.ts +2 -1
- package/src/web-search/WebSearchTool.ts +2 -1
- package/dist/Image-Cv6iBLTy.d.mts.map +0 -1
- package/dist/Items-C7MyrYPX.d.mts.map +0 -1
- package/dist/Loop-ChpaO-ya.d.mts.map +0 -1
- package/dist/Tool-BF78QWtn.d.mts +0 -314
- package/dist/Tool-BF78QWtn.d.mts.map +0 -1
- package/dist/ToolEvent-Di4a723B.d.mts +0 -144
- package/dist/ToolEvent-Di4a723B.d.mts.map +0 -1
- package/dist/ToolResult-BsYQRjmW.d.mts +0 -152
- package/dist/ToolResult-BsYQRjmW.d.mts.map +0 -1
- package/dist/Toolkit-tlL0F2YR.d.mts +0 -193
- package/dist/Toolkit-tlL0F2YR.d.mts.map +0 -1
- package/dist/dist-C8RmtoR8.mjs.map +0 -1
- package/dist/tool/Approval.d.mts +0 -113
- package/dist/tool/Approval.d.mts.map +0 -1
- package/dist/tool/Approval.mjs +0 -80
- package/dist/tool/Approval.mjs.map +0 -1
- package/dist/tool/Approval.test.mjs +0 -371
- package/dist/tool/Approval.test.mjs.map +0 -1
- package/dist/tool/ToolResult.d.mts +0 -2
- package/dist/tool/ToolResult.mjs +0 -85
- package/dist/tool/ToolResult.mjs.map +0 -1
- package/src/tool/Approval.test.ts +0 -400
- package/src/tool/Approval.ts +0 -181
- package/src/tool/ToolResult.ts +0 -114
- /package/dist/{tool/Approval.test.d.mts → streaming/Multipart.test.d.mts} +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { x as ToolCall } from "./Items-Bvx8s9QH.mjs";
|
|
2
|
+
import { Effect, Schema, Stream } from "effect";
|
|
3
|
+
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
declare namespace Tool_d_exports {
|
|
5
|
+
export { AnyDeclared, AnyDescribed, AnyLocalTool, AnyTool, Declared, DecodableTool, DecodeResult, InputSchema, ProviderTool, Run, Tool, ToolDescriptor, ToolE, ToolError, ToolFailed, ToolFailure, ToolInputSchema, ToolOutput, ToolR, ToolUnhandled, ToolValidationError, WithFailures, declare, decodeArgs, decodeCallInput, descriptorsOf, fail, fromEffectSchema, fromStandardSchema, isProviderTool, isStreamed, make, noInput, provider, providerToolsOf, toDescriptors, toStream, withFailures, withName, withRun };
|
|
6
|
+
}
|
|
7
|
+
declare const ToolError_base: Schema.Class<ToolError, Schema.TaggedStruct<"ToolError", {
|
|
8
|
+
readonly call_id: Schema.String;
|
|
9
|
+
readonly tool: Schema.String;
|
|
10
|
+
readonly message: Schema.String;
|
|
11
|
+
readonly cause: Schema.optional<Schema.Unknown>;
|
|
12
|
+
}>, import("effect/Cause").YieldableError>;
|
|
13
|
+
declare class ToolError extends ToolError_base {}
|
|
14
|
+
declare const ToolValidationError_base: Schema.Class<ToolValidationError, Schema.TaggedStruct<"ToolValidationError", {
|
|
15
|
+
readonly call_id: Schema.String;
|
|
16
|
+
readonly tool: Schema.String;
|
|
17
|
+
readonly issues: Schema.$Array<Schema.Struct<{
|
|
18
|
+
readonly message: Schema.String;
|
|
19
|
+
readonly path: Schema.optional<Schema.$Array<Schema.Unknown>>;
|
|
20
|
+
}>>;
|
|
21
|
+
}>, import("effect/Cause").YieldableError>;
|
|
22
|
+
/** A call's `arguments` failed the tool's `inputSchema` (from `decodeArgs`). */
|
|
23
|
+
declare class ToolValidationError extends ToolValidationError_base {}
|
|
24
|
+
declare const ToolFailed_base: Schema.Class<ToolFailed, Schema.TaggedStruct<"ToolFailed", {
|
|
25
|
+
readonly message: Schema.String;
|
|
26
|
+
}>, import("effect/Cause").YieldableError>;
|
|
27
|
+
/**
|
|
28
|
+
* A ready-made model-visible error for one-off messages. It reaches the model
|
|
29
|
+
* only when listed in the tool's `failureSchema` (or via `Toolkit.describeFailures`).
|
|
30
|
+
*/
|
|
31
|
+
declare class ToolFailed extends ToolFailed_base {}
|
|
32
|
+
/** `yield* Tool.fail("page not found")` inside a `run`. */
|
|
33
|
+
declare const fail: (message: string) => Effect.Effect<never, ToolFailed>;
|
|
34
|
+
/**
|
|
35
|
+
* Standard Schema with JSON Schema conversion (Zod 4+, Valibot, ArkType, or an
|
|
36
|
+
* Effect Schema via `fromEffectSchema`). Validates the model's arguments and
|
|
37
|
+
* renders the provider descriptor.
|
|
38
|
+
*/
|
|
39
|
+
type ToolInputSchema<Input = unknown> = StandardSchemaV1<unknown, Input> & StandardJSONSchemaV1<unknown, Input>;
|
|
40
|
+
/** What `inputSchema` accepts: an Effect Schema directly, or a `ToolInputSchema`. */
|
|
41
|
+
type InputSchema<Input> = Schema.Codec<Input, any, never, any> | ToolInputSchema<Input>;
|
|
42
|
+
/** Adds the Standard Schema and Standard JSON Schema interfaces to an Effect Schema. */
|
|
43
|
+
declare const fromEffectSchema: <S extends Schema.Codec<any, any, never, any>>(schema: S) => S & ToolInputSchema<S["Type"]>;
|
|
44
|
+
/**
|
|
45
|
+
* Types a schema that implements both Standard Schema and Standard JSON Schema
|
|
46
|
+
* (Zod 4.2+, Valibot 1.2+, ArkType 2.1.28+). A schema missing either half is a
|
|
47
|
+
* compile error here rather than a runtime surprise.
|
|
48
|
+
*/
|
|
49
|
+
declare const fromStandardSchema: <S extends StandardSchemaV1 & StandardJSONSchemaV1>(schema: S) => S & ToolInputSchema<StandardSchemaV1.InferOutput<S>>;
|
|
50
|
+
/**
|
|
51
|
+
* Input for a tool without arguments: renders `{ type: "object", properties: {} }`
|
|
52
|
+
* (an empty `Schema.Struct` renders an `anyOf` that strict providers reject).
|
|
53
|
+
*/
|
|
54
|
+
declare const noInput: ToolInputSchema<Record<string, never>>;
|
|
55
|
+
/** One result (`Effect`) or partial results whose last element is the result (`Stream`). */
|
|
56
|
+
type Run<Input, Output, E, R> = (input: Input) => Effect.Effect<Output, E, R> | Stream.Stream<Output, E, R>;
|
|
57
|
+
/** Whether `run` returned a `Stream` (values as partials) rather than an `Effect` (one value). */
|
|
58
|
+
declare const isStreamed: <A, E, R>(out: Effect.Effect<A, E, R> | Stream.Stream<A, E, R>) => out is Stream.Stream<A, E, R>;
|
|
59
|
+
/** An `Effect` is a one-element stream. */
|
|
60
|
+
declare const toStream: <A, E, R>(out: Effect.Effect<A, E, R> | Stream.Stream<A, E, R>) => Stream.Stream<A, E, R>;
|
|
61
|
+
type Described<Name extends string, Input, Output, Failure> = {
|
|
62
|
+
readonly name: Name;
|
|
63
|
+
readonly description: string;
|
|
64
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
65
|
+
/** Checks every value and encodes it for history and the UI. A rejected value is `OutputInvalid`. */
|
|
66
|
+
readonly outputSchema?: Schema.Codec<Output, any>;
|
|
67
|
+
/**
|
|
68
|
+
* Every error a call may end with that the model sees: errors `run` raises and
|
|
69
|
+
* errors the app closes calls with (`ToolDecision.Denied`, see `Toolkit.close`).
|
|
70
|
+
*/
|
|
71
|
+
readonly failureSchema?: Schema.Codec<Failure, any>;
|
|
72
|
+
/** Render with the provider's strict-mode flag. Default: true. */
|
|
73
|
+
readonly strict?: boolean;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* A model-visible tool that `Toolkit.run` executes: errors matching
|
|
77
|
+
* `failureSchema` reach the model, any other error fails the stream.
|
|
78
|
+
*/
|
|
79
|
+
type Tool<Name extends string, Input, Output, Failure = never, E = never, R = never> = Described<Name, Input, Output, Failure> & {
|
|
80
|
+
readonly _tag: "LocalTool";
|
|
81
|
+
readonly run: Run<Input, Output, E, R>;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* A model-visible tool without `run`: the app handles its calls. A signal to
|
|
85
|
+
* the loop (`escalate`), or a call answered elsewhere (`ask_user`, typed by
|
|
86
|
+
* `outputSchema`). `Tool.withRun` turns it into a `Tool`.
|
|
87
|
+
*/
|
|
88
|
+
type Declared<Name extends string, Input, Output = never, Failure = never> = Described<Name, Input, Output, Failure> & {
|
|
89
|
+
readonly _tag: "DeclaredTool";
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* A provider-hosted tool (native web search, code execution, grounding), executed
|
|
93
|
+
* by the provider. `provider` / `config` drive the adapter's rendering.
|
|
94
|
+
*/
|
|
95
|
+
type ProviderTool<Name extends string, Input, Provider extends string, Config> = {
|
|
96
|
+
readonly _tag: "ProviderTool";
|
|
97
|
+
readonly name: Name;
|
|
98
|
+
readonly description: string;
|
|
99
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
100
|
+
readonly provider: Provider;
|
|
101
|
+
readonly config: Config;
|
|
102
|
+
readonly strict?: boolean;
|
|
103
|
+
};
|
|
104
|
+
type AnyLocalTool<E = any, R = any> = Tool<string, any, any, any, E, R>;
|
|
105
|
+
type AnyDeclared = Declared<string, any, any, any>;
|
|
106
|
+
/** A tool with schemas the app sees: `Tool` or `Declared`. */
|
|
107
|
+
type AnyDescribed = AnyLocalTool | AnyDeclared;
|
|
108
|
+
type AnyTool<E = any, R = any> = AnyLocalTool<E, R> | AnyDeclared | ProviderTool<string, any, string, any>;
|
|
109
|
+
/** Any tool kind with a decodable input schema. */
|
|
110
|
+
type DecodableTool<Input> = {
|
|
111
|
+
readonly name: string;
|
|
112
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
113
|
+
};
|
|
114
|
+
type DescribedTag = {
|
|
115
|
+
readonly _tag: "LocalTool" | "DeclaredTool";
|
|
116
|
+
};
|
|
117
|
+
type ToolOutput<T> = T extends DescribedTag & Described<string, any, infer O, any> ? O : never;
|
|
118
|
+
type ToolFailure<T> = T extends DescribedTag & Described<string, any, any, infer F> ? F : never;
|
|
119
|
+
type ToolE<T> = T extends Tool<string, any, any, any, infer E, any> ? E : never;
|
|
120
|
+
type ToolR<T> = T extends Tool<string, any, any, any, any, infer R> ? R : never;
|
|
121
|
+
/** The errors a tool did not declare: these fail `Toolkit.run`'s stream. */
|
|
122
|
+
type ToolUnhandled<T> = T extends Tool<string, any, any, infer F, infer E, any> ? Exclude<E, F> : never;
|
|
123
|
+
type Spec<Name extends string, Input, Failure, FailureEncoded> = {
|
|
124
|
+
readonly name: Name;
|
|
125
|
+
readonly description: string;
|
|
126
|
+
readonly inputSchema: InputSchema<Input>;
|
|
127
|
+
readonly failureSchema?: Schema.Codec<Failure, FailureEncoded>;
|
|
128
|
+
readonly strict?: boolean;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* A tool `Toolkit.run` executes. `outputSchema` says what `run` returns and its
|
|
132
|
+
* encoded side must be JSON. `Content.Value` is the explicit "anything": text,
|
|
133
|
+
* JSON or media.
|
|
134
|
+
*/
|
|
135
|
+
declare const make: <const Name extends string, Input, Output, Encoded extends Schema.Json, Failure = never, FailureEncoded extends Schema.Json = never, E = never, R = never>(spec: Spec<Name, Input, Failure, FailureEncoded> & {
|
|
136
|
+
readonly outputSchema: Schema.Codec<Output, Encoded>;
|
|
137
|
+
readonly run: Run<Input, Output, E, R>;
|
|
138
|
+
}) => Tool<Name, Input, Output, Failure, E, R>;
|
|
139
|
+
/**
|
|
140
|
+
* A tool without `run`: the app handles its calls. A signal to the loop (no
|
|
141
|
+
* `outputSchema`), or a call answered elsewhere (typed by `outputSchema`).
|
|
142
|
+
*/
|
|
143
|
+
declare const declare: <const Name extends string, Input, Output = never, Encoded extends Schema.Json = never, Failure = never, FailureEncoded extends Schema.Json = never>(spec: Spec<Name, Input, Failure, FailureEncoded> & {
|
|
144
|
+
readonly outputSchema?: Schema.Codec<Output, Encoded>;
|
|
145
|
+
}) => Declared<Name, Input, Output, Failure>;
|
|
146
|
+
/** A provider-hosted tool. */
|
|
147
|
+
declare const provider: <const Name extends string, Input, Provider extends string, Config>(spec: Omit<ProviderTool<Name, Input, Provider, Config>, "_tag" | "inputSchema"> & {
|
|
148
|
+
readonly inputSchema: InputSchema<Input>;
|
|
149
|
+
}) => ProviderTool<Name, Input, Provider, Config>;
|
|
150
|
+
/** A copy of a tool under a new `name`, e.g. to resolve a clash before `Toolkit.compose`. */
|
|
151
|
+
declare const withName: <N extends string, T extends AnyTool>(tool: T, name: N) => Omit<T, "name"> & {
|
|
152
|
+
readonly name: N;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Give a tool a `run`, keeping everything else (name, description, schemas):
|
|
156
|
+
* implement a declared tool (a spec shared with the browser), or mock a tool.
|
|
157
|
+
* The new `run` returns the same output type.
|
|
158
|
+
*/
|
|
159
|
+
declare const withRun: <Name extends string, Input, Output, Failure, E2 = never, R2 = never>(tool: Tool<Name, Input, Output, Failure, any, any> | Declared<Name, Input, Output, Failure>, run: Run<Input, Output, E2, R2>) => Tool<Name, Input, Output, Failure, E2, R2>;
|
|
160
|
+
/** The same kind of tool, with more failures. */
|
|
161
|
+
type WithFailures<T, F2> = T extends Tool<infer N, infer I, infer O, infer F, infer E, infer R> ? Tool<N, I, O, F | F2, E, R> : T extends Declared<infer N, infer I, infer O, infer F> ? Declared<N, I, O, F | F2> : never;
|
|
162
|
+
/**
|
|
163
|
+
* Add errors a call of this tool may end with, e.g. the app's `ToolDecision.Denied`
|
|
164
|
+
* for a tool that needs approval. Its `run` need not raise them; the app closes
|
|
165
|
+
* calls with them (`Toolkit.close`).
|
|
166
|
+
*/
|
|
167
|
+
declare const withFailures: {
|
|
168
|
+
<F2, F2Encoded extends Schema.Json>(failures: Schema.Codec<F2, F2Encoded>): <T extends AnyDescribed>(tool: T) => WithFailures<T, F2>;
|
|
169
|
+
<T extends AnyDescribed, F2, F2Encoded extends Schema.Json>(tool: T, failures: Schema.Codec<F2, F2Encoded>): WithFailures<T, F2>;
|
|
170
|
+
};
|
|
171
|
+
/** Provider-agnostic descriptor; each provider maps `inputSchema` to its own field. */
|
|
172
|
+
type ToolDescriptor = {
|
|
173
|
+
readonly name: string;
|
|
174
|
+
readonly description: string;
|
|
175
|
+
readonly inputSchema: Record<string, unknown>;
|
|
176
|
+
readonly strict?: boolean;
|
|
177
|
+
};
|
|
178
|
+
declare const isProviderTool: (tool: AnyTool) => tool is ProviderTool<string, any, string, any>;
|
|
179
|
+
/** The provider-hosted tools in a toolkit, for an adapter to render natively. */
|
|
180
|
+
declare const providerToolsOf: (toolkit?: Readonly<Record<string, AnyTool>>) => ReadonlyArray<ProviderTool<string, any, string, any>>;
|
|
181
|
+
/** Function descriptors for every tool except provider-hosted ones. */
|
|
182
|
+
declare const toDescriptors: (tools: ReadonlyArray<AnyTool>) => ReadonlyArray<ToolDescriptor>;
|
|
183
|
+
/** `toDescriptors` over a toolkit record; an absent toolkit has none. */
|
|
184
|
+
declare const descriptorsOf: (toolkit?: Readonly<Record<string, AnyTool>>) => ReadonlyArray<ToolDescriptor>;
|
|
185
|
+
type DecodeResult<Input> = {
|
|
186
|
+
readonly _tag: "ok";
|
|
187
|
+
readonly input: Input;
|
|
188
|
+
} | {
|
|
189
|
+
readonly _tag: "parseError";
|
|
190
|
+
} | {
|
|
191
|
+
readonly _tag: "invalid";
|
|
192
|
+
readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Parse and validate a call's `arguments`, as data. Empty arguments read as `{}`
|
|
196
|
+
* (some models send `""` for tools without arguments). Never fails.
|
|
197
|
+
*/
|
|
198
|
+
declare const decodeCallInput: <Input>(tool: DecodableTool<Input>, call: ToolCall) => Effect.Effect<DecodeResult<Input>>;
|
|
199
|
+
/**
|
|
200
|
+
* A call's typed input, e.g. for a tool without `run` the loop handles itself.
|
|
201
|
+
* Bad JSON fails with `ToolError`, a schema violation with `ToolValidationError`.
|
|
202
|
+
*/
|
|
203
|
+
declare const decodeArgs: <Input>(tool: DecodableTool<Input>, call: ToolCall) => Effect.Effect<Input, ToolError | ToolValidationError>;
|
|
204
|
+
//#endregion
|
|
205
|
+
export { fromStandardSchema as A, withName as B, WithFailures as C, descriptorsOf as D, decodeCallInput as E, provider as F, providerToolsOf as I, toDescriptors as L, isStreamed as M, make as N, fail as O, noInput as P, toStream as R, Tool_d_exports as S, decodeArgs as T, withRun as V, ToolInputSchema as _, Declared as a, ToolUnhandled as b, InputSchema as c, Tool as d, ToolDescriptor as f, ToolFailure as g, ToolFailed as h, AnyTool as i, isProviderTool as j, fromEffectSchema as k, ProviderTool as l, ToolError as m, AnyDescribed as n, DecodableTool as o, ToolE as p, AnyLocalTool as r, DecodeResult as s, AnyDeclared as t, Run as u, ToolOutput as v, declare as w, ToolValidationError as x, ToolR as y, withFailures as z };
|
|
206
|
+
//# sourceMappingURL=Tool-Bkryw6-h.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tool-Bkryw6-h.d.mts","names":[],"sources":["../src/tool/Tool.ts"],"mappings":";;;;;;;;;;;;cAIa,kBAAkB;;;;;;;;;;cAoBlB,4BAA4B;;;;;;;;cAY5B,mBAAmB;;cAMnB,OAAI,oBAAsB,OAAO,cAAc;;;;;;KAYhD,gBAAgB,mBAAmB,0BAA0B,SACvE,8BAA8B;;KAGpB,YAAY,SAAS,OAAO,MAAM,0BAA0B,gBAAgB;;cAG3E,mBAAoB,UAAU,OAAO,6BAA2B,QACnE,MACP,IAAI,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jB;GACV,IAAI,kBAAkB,OAAO,MAC5B,UAAU,OAAO,MAAM,IAAI,cACzB,UAAU,cAAc,MAAM,MAAM,aAAa,GAAG;GACvD,UAAU,cAAc,IAAI,kBAAkB,OAAO,MACpD,MAAM,GACN,UAAU,OAAO,MAAM,IAAI,aAC1B,aAAa,GAAG;;;KAYT;WACD;WACA;WACA,aAAa;WACb;;cAGE,iBAAc,MAAU,YAAU,QAAQ;;cAI1C,kBAAe,UAChB,SAAS,eAAe,cACjC,cAAc;;cAIJ,gBAAa,OAAW,cAAc,aAAW,cAAc;;cAc/D,gBAAa,UACd,SAAS,eAAe,cACjC,cAAc;KAOL,aAAa;WACV;WAAqB,OAAO;;WAC5B;;WACA;WAA0B,QAAQ,cAAc,iBAAiB;;;;;;cAUnE,kBAAmB,OAAK,MAC7B,cAAc,QAAM,MACpB,aACL,OAAO,OAAO,aAAa;;;;;cA2BjB,aAAc,OAAK,MACxB,cAAc,QAAM,MACpB,aACL,OAAO,OAAO,OAAO,YAAY"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
2
|
+
declare namespace ToolEvent_d_exports {
|
|
3
|
+
export { Output, Partial, ToolEvent };
|
|
4
|
+
}
|
|
5
|
+
/** An intermediate value of a `Stream` tool. */
|
|
6
|
+
type Partial<Name extends string = string, Output = unknown> = {
|
|
7
|
+
readonly _tag: "Partial";
|
|
8
|
+
readonly call_id: string;
|
|
9
|
+
readonly tool: Name;
|
|
10
|
+
readonly value: Output;
|
|
11
|
+
};
|
|
12
|
+
/** The call ended: `Success` with its value, or `Failure` with a declared or core error. */
|
|
13
|
+
type Output<Name extends string = string, Out = unknown, E = unknown> = {
|
|
14
|
+
readonly _tag: "Output";
|
|
15
|
+
readonly call_id: string;
|
|
16
|
+
readonly tool: Name;
|
|
17
|
+
readonly result: Result.Result<Out, E>;
|
|
18
|
+
};
|
|
19
|
+
type ToolEvent<Name extends string = string, Out = unknown, E = unknown> = Partial<Name, Out> | Output<Name, Out, E>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ToolEvent_d_exports as i, Partial as n, ToolEvent as r, Output as t };
|
|
22
|
+
//# sourceMappingURL=ToolEvent-9inLx5cI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolEvent-9inLx5cI.d.mts","names":[],"sources":["../src/tool/ToolEvent.ts"],"mappings":";;;;;KAQY,QAAQ,8BAA8B;WACvC;WACA;WACA,MAAM;WACN,OAAO;;;KAIN,OAAO,8BAA8B,eAAe;WACrD;WACA;WACA,MAAM;WACN,QAAQ,OAAO,OAAO,KAAK;;KAG1B,UAAU,8BAA8B,eAAe,eAC/D,QAAQ,MAAM,OACd,OAAO,MAAM,KAAK"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { i as FileSource, r as FileMimeType } from "./File-B923KvZ9.mjs";
|
|
2
|
+
import { i as ImageMimeType, o as ImageSource } from "./Image-Bzc1H_UK.mjs";
|
|
3
|
+
import { C as ToolOutputContent, S as ToolCallOutput, l as InputJson, u as InputText, x as ToolCall } from "./Items-Bvx8s9QH.mjs";
|
|
4
|
+
import { a as Value, n as File, r as Image } from "./Content-D_Qfn8Ja.mjs";
|
|
5
|
+
import { Effect, Option, Schema } from "effect";
|
|
6
|
+
declare namespace ToolOutput_d_exports {
|
|
7
|
+
export { Cancelled, CoreError, InputInvalid, OutputInvalid, PartJson, RunError, UnknownTool, ValueParts, encoded, failure, isTextual, make, partText, parts, single, success, text, value, valueParts };
|
|
8
|
+
}
|
|
9
|
+
type CallId = Pick<ToolCall, "call_id">;
|
|
10
|
+
/** `decoded` decides the shape and supplies media; `encoded` supplies the JSON. */
|
|
11
|
+
declare const parts: (decoded: unknown, encoded: Schema.Json) => ReadonlyArray<ToolOutputContent>;
|
|
12
|
+
/** A value, encoded by `schema`, as the call's output. */
|
|
13
|
+
declare const success: <A>(call: CallId, schema: Schema.Codec<A, Schema.Json>, value: A) => Effect.Effect<ToolCallOutput, Schema.SchemaError>;
|
|
14
|
+
/** An error, encoded by `schema`, as the call's output, flagged `isError`. */
|
|
15
|
+
declare const failure: <E>(call: CallId, schema: Schema.Codec<E, Schema.Json>, error: E) => Effect.Effect<ToolCallOutput, Schema.SchemaError>;
|
|
16
|
+
/** Any `Content.Value` as the call's output, for calls the app closes itself. */
|
|
17
|
+
declare const make: (call: CallId, value: Value) => Effect.Effect<{
|
|
18
|
+
readonly type: "function_call_output";
|
|
19
|
+
readonly call_id: string;
|
|
20
|
+
readonly output: readonly ({
|
|
21
|
+
readonly type: "input_text";
|
|
22
|
+
readonly text: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: "input_json";
|
|
25
|
+
readonly value: Schema.Json;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "input_image";
|
|
28
|
+
readonly source: ImageSource;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "input_file";
|
|
31
|
+
readonly source: FileSource;
|
|
32
|
+
readonly filename?: string;
|
|
33
|
+
})[];
|
|
34
|
+
readonly isError?: boolean;
|
|
35
|
+
readonly providerData?: unknown;
|
|
36
|
+
}, Schema.SchemaError, never>;
|
|
37
|
+
/** One value as itself, several (or none) as the array: how parts read back as a value. */
|
|
38
|
+
declare const single: <A>(values: ReadonlyArray<A>) => A | ReadonlyArray<A>;
|
|
39
|
+
/** A text or JSON part. */
|
|
40
|
+
declare const isTextual: (p: ToolOutputContent) => p is InputText | InputJson;
|
|
41
|
+
/** A text part verbatim, a JSON part serialized. */
|
|
42
|
+
declare const partText: (p: InputText | InputJson) => string;
|
|
43
|
+
/**
|
|
44
|
+
* The parts as one string joined by newlines, for wires (or wire paths) whose
|
|
45
|
+
* tool outputs carry text only. `None` when a part is media.
|
|
46
|
+
*/
|
|
47
|
+
declare const text: (output: ReadonlyArray<ToolOutputContent>) => Option.Option<string>;
|
|
48
|
+
/** Parts back to a `Content.Value`, read from the parts' own types. */
|
|
49
|
+
declare const value: (output: ReadonlyArray<ToolOutputContent>) => Value;
|
|
50
|
+
/** Parts back to the encoded form an `outputSchema` decodes (media re-encoded). */
|
|
51
|
+
declare const encoded: (output: ReadonlyArray<ToolOutputContent>) => Effect.Effect<unknown, Schema.SchemaError>;
|
|
52
|
+
/** A `Content.Value` as history parts, by the same rule as `parts` (its JSON is itself). */
|
|
53
|
+
declare const valueParts: (v: Value) => ReadonlyArray<ToolOutputContent>;
|
|
54
|
+
/** A history part with JSON sources (bytes as base64), as it travels to a UI. */
|
|
55
|
+
declare const PartJson: Schema.Union<readonly [Schema.Struct<{
|
|
56
|
+
readonly type: Schema.Literal<"input_text">;
|
|
57
|
+
readonly text: Schema.String;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly type: Schema.Literal<"input_json">;
|
|
60
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
61
|
+
}>, Schema.Struct<{
|
|
62
|
+
readonly type: Schema.Literal<"input_image">;
|
|
63
|
+
readonly source: Schema.Union<readonly [Schema.TaggedStruct<"url", {
|
|
64
|
+
readonly url: Schema.String;
|
|
65
|
+
readonly mimeType: Schema.optionalKey<Schema.Codec<ImageMimeType, ImageMimeType, never, never>>;
|
|
66
|
+
}>, Schema.TaggedStruct<"base64", {
|
|
67
|
+
readonly base64: Schema.String;
|
|
68
|
+
readonly mimeType: Schema.Codec<ImageMimeType, ImageMimeType, never, never>;
|
|
69
|
+
}>, Schema.TaggedStruct<"bytes", {
|
|
70
|
+
readonly bytes: Schema.Uint8ArrayFromBase64;
|
|
71
|
+
readonly mimeType: Schema.Codec<ImageMimeType, ImageMimeType, never, never>;
|
|
72
|
+
}>]>;
|
|
73
|
+
}>, Schema.Struct<{
|
|
74
|
+
readonly type: Schema.Literal<"input_file">;
|
|
75
|
+
readonly source: Schema.Union<readonly [Schema.TaggedStruct<"url", {
|
|
76
|
+
readonly url: Schema.String;
|
|
77
|
+
readonly mimeType: Schema.optionalKey<Schema.Codec<FileMimeType, FileMimeType, never, never>>;
|
|
78
|
+
}>, Schema.TaggedStruct<"base64", {
|
|
79
|
+
readonly base64: Schema.String;
|
|
80
|
+
readonly mimeType: Schema.Codec<FileMimeType, FileMimeType, never, never>;
|
|
81
|
+
}>, Schema.TaggedStruct<"bytes", {
|
|
82
|
+
readonly bytes: Schema.Uint8ArrayFromBase64;
|
|
83
|
+
readonly mimeType: Schema.Codec<FileMimeType, FileMimeType, never, never>;
|
|
84
|
+
}>]>;
|
|
85
|
+
readonly filename: Schema.optionalKey<Schema.String>;
|
|
86
|
+
}>]>;
|
|
87
|
+
/**
|
|
88
|
+
* A `Content.Value` on the wire to a UI: typed parts instead of its plain JSON,
|
|
89
|
+
* so JSON shaped like `{ _tag: "Image", source }` can't come back as an image.
|
|
90
|
+
*/
|
|
91
|
+
declare const ValueParts: Schema.decodeTo<Schema.toType<Schema.Union<readonly [Schema.String, Schema.Union<readonly [typeof Image, typeof File]>, Schema.$Array<Schema.Union<readonly [Schema.Union<readonly [typeof Image, typeof File]>, Schema.Codec<Schema.Json, Schema.Json, never, never>]>>, Schema.Codec<Schema.Json, Schema.Json, never, never>]>>, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
92
|
+
readonly type: Schema.Literal<"input_text">;
|
|
93
|
+
readonly text: Schema.String;
|
|
94
|
+
}>, Schema.Struct<{
|
|
95
|
+
readonly type: Schema.Literal<"input_json">;
|
|
96
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
97
|
+
}>, Schema.Struct<{
|
|
98
|
+
readonly type: Schema.Literal<"input_image">;
|
|
99
|
+
readonly source: Schema.Union<readonly [Schema.TaggedStruct<"url", {
|
|
100
|
+
readonly url: Schema.String;
|
|
101
|
+
readonly mimeType: Schema.optionalKey<Schema.Codec<ImageMimeType, ImageMimeType, never, never>>;
|
|
102
|
+
}>, Schema.TaggedStruct<"base64", {
|
|
103
|
+
readonly base64: Schema.String;
|
|
104
|
+
readonly mimeType: Schema.Codec<ImageMimeType, ImageMimeType, never, never>;
|
|
105
|
+
}>, Schema.TaggedStruct<"bytes", {
|
|
106
|
+
readonly bytes: Schema.Uint8ArrayFromBase64;
|
|
107
|
+
readonly mimeType: Schema.Codec<ImageMimeType, ImageMimeType, never, never>;
|
|
108
|
+
}>]>;
|
|
109
|
+
}>, Schema.Struct<{
|
|
110
|
+
readonly type: Schema.Literal<"input_file">;
|
|
111
|
+
readonly source: Schema.Union<readonly [Schema.TaggedStruct<"url", {
|
|
112
|
+
readonly url: Schema.String;
|
|
113
|
+
readonly mimeType: Schema.optionalKey<Schema.Codec<FileMimeType, FileMimeType, never, never>>;
|
|
114
|
+
}>, Schema.TaggedStruct<"base64", {
|
|
115
|
+
readonly base64: Schema.String;
|
|
116
|
+
readonly mimeType: Schema.Codec<FileMimeType, FileMimeType, never, never>;
|
|
117
|
+
}>, Schema.TaggedStruct<"bytes", {
|
|
118
|
+
readonly bytes: Schema.Uint8ArrayFromBase64;
|
|
119
|
+
readonly mimeType: Schema.Codec<FileMimeType, FileMimeType, never, never>;
|
|
120
|
+
}>]>;
|
|
121
|
+
readonly filename: Schema.optionalKey<Schema.String>;
|
|
122
|
+
}>]>>, never, never>;
|
|
123
|
+
declare const InputInvalid_base: Schema.Class<InputInvalid, Schema.TaggedStruct<"InputInvalid", {
|
|
124
|
+
readonly message: Schema.String;
|
|
125
|
+
}>, import("effect/Cause").YieldableError>;
|
|
126
|
+
/** The model's arguments are not JSON or fail `inputSchema`. */
|
|
127
|
+
declare class InputInvalid extends InputInvalid_base {}
|
|
128
|
+
declare const OutputInvalid_base: Schema.Class<OutputInvalid, Schema.TaggedStruct<"OutputInvalid", {
|
|
129
|
+
readonly message: Schema.String;
|
|
130
|
+
}>, import("effect/Cause").YieldableError>;
|
|
131
|
+
/** `run` returned a value its `outputSchema` rejects: a bug in the tool. */
|
|
132
|
+
declare class OutputInvalid extends OutputInvalid_base {}
|
|
133
|
+
declare const UnknownTool_base: Schema.Class<UnknownTool, Schema.TaggedStruct<"UnknownTool", {
|
|
134
|
+
readonly message: Schema.String;
|
|
135
|
+
}>, import("effect/Cause").YieldableError>;
|
|
136
|
+
/** No local tool by that name (hallucinated, removed, or a declared or provider tool). */
|
|
137
|
+
declare class UnknownTool extends UnknownTool_base {}
|
|
138
|
+
declare const Cancelled_base: Schema.Class<Cancelled, Schema.TaggedStruct<"Cancelled", {
|
|
139
|
+
readonly message: Schema.String;
|
|
140
|
+
}>, import("effect/Cause").YieldableError>;
|
|
141
|
+
/** The call was left unanswered and closed before the next model call. */
|
|
142
|
+
declare class Cancelled extends Cancelled_base {}
|
|
143
|
+
/** What `Toolkit.run` produces itself. */
|
|
144
|
+
type RunError = InputInvalid | OutputInvalid | UnknownTool;
|
|
145
|
+
declare const RunError: Schema.Union<readonly [typeof InputInvalid, typeof OutputInvalid, typeof UnknownTool]>;
|
|
146
|
+
/** Every error core writes into history; what history and the UI always decode. */
|
|
147
|
+
type CoreError = RunError | Cancelled;
|
|
148
|
+
declare const CoreError: Schema.Union<readonly [typeof InputInvalid, typeof OutputInvalid, typeof UnknownTool, typeof Cancelled]>;
|
|
149
|
+
//#endregion
|
|
150
|
+
export { success as _, PartJson as a, valueParts as b, UnknownTool as c, failure as d, isTextual as f, single as g, parts as h, OutputInvalid as i, ValueParts as l, partText as m, CoreError as n, RunError as o, make as p, InputInvalid as r, ToolOutput_d_exports as s, Cancelled as t, encoded as u, text as v, value as y };
|
|
151
|
+
//# sourceMappingURL=ToolOutput-BNTIQgGB.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolOutput-BNTIQgGB.d.mts","names":[],"sources":["../src/tool/ToolOutput.ts"],"mappings":";;;;;;;;KAsBK,SAAS,KAAK;;cAmCN,QAAK,kBAAoB,SAAW,OAAO,SAAO,cAAc;;cAShE,UAAW,GAAC,MACjB,QAAM,QACJ,OAAO,MAAM,GAAG,OAAO,OAAK,OAC7B,MACN,OAAO,OAAO,gBAAgB,OAAO;;cAQ3B,UAAW,GAAC,MACjB,QAAM,QACJ,OAAO,MAAM,GAAG,OAAO,OAAK,OAC7B,MACN,OAAO,OAAO,gBAAgB,OAAO;;cAS3B,OAAI,MAAU,QAAM,OAAS,UAAa,OAAA;;;;;;;;;;;;;;;;;;;GAAwC,OAAA;;cAGlF,SAAU,GAAC,QAAU,cAAc,OAAK,IAAI,cAAc;;cAI1D,YAAS,GAAO,sBAAoB,KAAK,YAAkB;;cAI3D,WAAQ,GAAO,YAAkB;;;;;cAOjC,OAAI,QAAY,cAAc,uBAAqB,OAAO;;cAI1D,QAAK,QAAY,cAAc,uBAAqB;;cAIpD,UAAO,QACV,cAAc,uBACrB,OAAO,gBAAgB,OAAO;;cAgBpB,aAAU,GAAO,UAAgB,cAAc;;cAW/C,UAAQ,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAeR,YAAU,OAAA,SAAA,OAAA,OAAA,OAAA,gBAAA,OAAA,QAAA,OAAA,uBAAA,cAAA,QAAA,OAAA,OAAA,OAAA,gBAAA,OAAA,uBAAA,cAAA,QAAA,OAAA,MAAA,OAAA,MAAA,OAAA,wBAAA,OAAA,MAAA,OAAA,MAAA,OAAA,wBAAA,OAAA,OAAA,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAUV,qBAAqB;;;;;cAKrB,sBAAsB;;;;;cAKtB,oBAAoB;;;;;cAKpB,kBAAkB;;KAMnB,WAAW,eAAe,gBAAgB;cACzC,UAAQ,OAAA,uBAAA,qBAAA,sBAAA;;KAGT,YAAY,WAAW;cACtB,WAAS,OAAA,uBAAA,qBAAA,sBAAA,oBAAA"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { S as ToolCallOutput, o as HistoryItem, x as ToolCall } from "./Items-Bvx8s9QH.mjs";
|
|
2
|
+
import { b as ToolUnhandled, d as Tool, f as ToolDescriptor, g as ToolFailure, h as ToolFailed, i as AnyTool, l as ProviderTool, v as ToolOutput, y as ToolR } from "./Tool-Bkryw6-h.mjs";
|
|
3
|
+
import { Turn } from "./domain/Turn.mjs";
|
|
4
|
+
import { r as Step } from "./Loop-CeA0AelN.mjs";
|
|
5
|
+
import { r as ToolEvent, t as Output } from "./ToolEvent-9inLx5cI.mjs";
|
|
6
|
+
import { i as OutputInvalid, n as CoreError, o as RunError, r as InputInvalid } from "./ToolOutput-BNTIQgGB.mjs";
|
|
7
|
+
import { Cause, Effect, Result, Schema, Stream } from "effect";
|
|
8
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
|
+
declare namespace Toolkit_d_exports {
|
|
10
|
+
export { DeclaredCall, DuplicateToolName, Event, ExecuteOptions, Handler, Middleware, NoDuplicateNames, Outcome, Split, ToolMap, Toolkit, ToolkitE, ToolkitFailure, ToolkitR, UndeclaredFailure, UniqueTools, appendResults, close, complete, compose, continueWith, decode, describeFailures, descriptors, fromArray, isOutcome, make, makeNamespaced, namespace, next, output, run, split, withFailures, wrap };
|
|
11
|
+
}
|
|
12
|
+
type ToolMap = Record<string, AnyTool>;
|
|
13
|
+
type Toolkit<Tools extends ToolMap = ToolMap> = Tools;
|
|
14
|
+
type Indexed<Tools extends ReadonlyArray<AnyTool>> = { [T in Tools[number] as T["name"]]: T; };
|
|
15
|
+
/** Index tools by `name`. A repeated literal name is a compile error. */
|
|
16
|
+
declare const make: <const Tools extends ReadonlyArray<AnyTool>>(...tools: UniqueTools<Tools>) => Toolkit<Indexed<Tools>>;
|
|
17
|
+
/** A toolkit from a dynamic source (MCP server, plugin). Same-named tools: last wins. */
|
|
18
|
+
declare const fromArray: (tools: ReadonlyArray<AnyTool>) => Toolkit;
|
|
19
|
+
declare const descriptors: (toolkit: Toolkit) => ReadonlyArray<ToolDescriptor>;
|
|
20
|
+
type Locals<T extends Toolkit> = Extract<T[keyof T], {
|
|
21
|
+
readonly _tag: "LocalTool";
|
|
22
|
+
}>;
|
|
23
|
+
/** Every tool's requirements. */
|
|
24
|
+
type ToolkitR<T extends Toolkit> = ToolMap extends T ? never : ToolR<T[keyof T]>;
|
|
25
|
+
/** Every error a tool did not declare in `failureSchema`: these fail `run`'s stream. */
|
|
26
|
+
type ToolkitE<T extends Toolkit> = ToolMap extends T ? never : ToolUnhandled<T[keyof T]>;
|
|
27
|
+
/** What `run` emits: one member per local tool, plus calls it could not run at all. */
|
|
28
|
+
type Event<T extends Toolkit> = (Locals<T> extends (infer X) ? X extends Tool<infer N, any, infer O, infer F, any, any> ? ToolEvent<N, O, F | RunError> : never : never) | Output<string, never, RunError>;
|
|
29
|
+
type DuplicateName<Tools extends ReadonlyArray<AnyTool>, Seen extends string = never> = Tools extends readonly [infer Head extends AnyTool, ...infer Tail extends ReadonlyArray<AnyTool>] ? Head["name"] extends Seen ? Head["name"] : DuplicateName<Tail, Seen | Head["name"]> : never;
|
|
30
|
+
type DuplicateNameError<Name extends string> = {
|
|
31
|
+
readonly __error: `Duplicate tool name: ${Name}`;
|
|
32
|
+
};
|
|
33
|
+
type NoDuplicateNames<Tools extends ReadonlyArray<AnyTool>> = [DuplicateName<Tools>] extends [never] ? unknown : DuplicateNameError<DuplicateName<Tools>>;
|
|
34
|
+
type UniqueTools<Tools extends ReadonlyArray<AnyTool>> = Tools & NoDuplicateNames<Tools>;
|
|
35
|
+
type ComposeDuplicateKey<Kits extends ReadonlyArray<Toolkit>, Seen extends string = never> = Kits extends readonly [infer Head extends Toolkit, ...infer Tail extends ReadonlyArray<Toolkit>] ? string extends keyof Head ? ComposeDuplicateKey<Tail, Seen> : Extract<keyof Head & string, Seen> extends never ? ComposeDuplicateKey<Tail, Seen | (keyof Head & string)> : Extract<keyof Head & string, Seen> : never;
|
|
36
|
+
type NoDuplicateComposedKeys<Kits extends ReadonlyArray<Toolkit>> = [ComposeDuplicateKey<Kits>] extends [never] ? unknown : DuplicateNameError<ComposeDuplicateKey<Kits>>;
|
|
37
|
+
type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
|
|
38
|
+
type Composed<Kits extends ReadonlyArray<Toolkit>> = UnionToIntersection<Kits[number]> extends (infer M) ? (M extends ToolMap ? M : ToolMap) : ToolMap;
|
|
39
|
+
declare const DuplicateToolName_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
40
|
+
readonly _tag: "DuplicateToolName";
|
|
41
|
+
} & Readonly<A>;
|
|
42
|
+
/** Two composed toolkits share a final name; `sources` are their positions. */
|
|
43
|
+
declare class DuplicateToolName extends DuplicateToolName_base<{
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly sources: ReadonlyArray<string>;
|
|
46
|
+
}> {}
|
|
47
|
+
type PrefixName<Prefix extends string, Name extends string> = `${Prefix}__${Name}`;
|
|
48
|
+
type PrefixTool<Prefix extends string, T extends AnyTool> = T extends Tool<infer N, infer I, infer O, infer F, infer E, infer R> ? Tool<PrefixName<Prefix, N>, I, O, F, E, R> : T extends ProviderTool<infer N, infer I, infer P, infer C> ? ProviderTool<PrefixName<Prefix, N>, I, P, C> : T;
|
|
49
|
+
type Namespaced<Prefix extends string, T extends ToolMap> = { readonly [K in keyof T & string as PrefixName<Prefix, K>]: T[K] extends AnyTool ? PrefixTool<Prefix, T[K]> : never; };
|
|
50
|
+
/** Prefix every tool name with `<namespace>__`, e.g. to keep two `search` tools apart. */
|
|
51
|
+
declare const namespace: <const Prefix extends string, const T extends ToolMap>(prefix: Prefix, toolkit: Toolkit<T>) => Toolkit<Namespaced<Prefix, T>>;
|
|
52
|
+
/** `namespace(prefix, make(...tools))` in one step. */
|
|
53
|
+
declare const makeNamespaced: <const Prefix extends string, const Tools extends ReadonlyArray<AnyTool>>(prefix: Prefix, ...tools: UniqueTools<Tools>) => Toolkit<Namespaced<Prefix, Indexed<Tools>>>;
|
|
54
|
+
/**
|
|
55
|
+
* Join independently built toolkits. A duplicate final name fails with
|
|
56
|
+
* `DuplicateToolName`; statically known duplicates are a compile error too.
|
|
57
|
+
*/
|
|
58
|
+
declare const compose: <const Kits extends ReadonlyArray<Toolkit>>(...toolkits: Kits & NoDuplicateComposedKeys<Kits>) => Effect.Effect<Toolkit<Composed<Kits>>, DuplicateToolName>;
|
|
59
|
+
type Handler<Input, Output, E, R> = (input: Input) => Stream.Stream<Output, E, R>;
|
|
60
|
+
type Middleware<R2 = never, E2 = never> = <Input, Output, E, R>(run: Handler<Input, Output, E, R>, name: string) => Handler<Input, Output, E | E2, R | R2>;
|
|
61
|
+
type WrapTool<T extends AnyTool, R2, E2> = T extends Tool<infer N, infer I, infer O, infer F, infer E, infer R> ? Tool<N, I, O, F, E | E2, R | R2> : T;
|
|
62
|
+
type WrapToolkit<T extends ToolMap, R2, E2> = { readonly [K in keyof T]: T[K] extends AnyTool ? WrapTool<T[K], R2, E2> : T[K]; };
|
|
63
|
+
/**
|
|
64
|
+
* Wrap every local tool's `run`. Stacks with `pipe`, inner first: the last
|
|
65
|
+
* `wrap` runs first. The middleware sees a stream; an `Effect` tool stays one,
|
|
66
|
+
* with the stream's last value.
|
|
67
|
+
*
|
|
68
|
+
* const observed = pipe(toolkit, Toolkit.wrap(logging), Toolkit.wrap(authz))
|
|
69
|
+
*/
|
|
70
|
+
declare const wrap: {
|
|
71
|
+
<R2, E2>(middleware: Middleware<R2, E2>): <T extends Toolkit>(toolkit: T) => WrapToolkit<T, R2, E2>;
|
|
72
|
+
<T extends Toolkit, R2, E2>(toolkit: T, middleware: Middleware<R2, E2>): WrapToolkit<T, R2, E2>;
|
|
73
|
+
};
|
|
74
|
+
type AddFailures<T extends AnyTool, F2> = T extends Tool<infer N, infer I, infer O, infer F, infer E, infer R> ? Tool<N, I, O, F | F2, E, R> : T;
|
|
75
|
+
type AddFailuresToolkit<T extends ToolMap, F2> = { readonly [K in keyof T]: T[K] extends AnyTool ? AddFailures<T[K], F2> : T[K]; };
|
|
76
|
+
/**
|
|
77
|
+
* `Tool.withFailures` for every local tool, e.g. a whole MCP toolkit that needs
|
|
78
|
+
* approval. Prefer it per tool when only some tools are gated.
|
|
79
|
+
*/
|
|
80
|
+
declare const withFailures: {
|
|
81
|
+
<F2, F2Encoded extends Schema.Json>(failures: Schema.Codec<F2, F2Encoded>): <T extends Toolkit>(toolkit: T) => AddFailuresToolkit<T, F2>;
|
|
82
|
+
<T extends Toolkit, F2, F2Encoded extends Schema.Json>(toolkit: T, failures: Schema.Codec<F2, F2Encoded>): AddFailuresToolkit<T, F2>;
|
|
83
|
+
};
|
|
84
|
+
type DescribeTool<T extends AnyTool, D> = T extends Tool<infer N, infer I, infer O, infer F, infer E, infer R> ? Tool<N, I, O, F | ToolFailed, F | ToolFailed | (undefined extends D ? E : never), R> : T;
|
|
85
|
+
type DescribeToolkit<T extends ToolMap, D> = { readonly [K in keyof T]: T[K] extends AnyTool ? DescribeTool<T[K], D> : T[K]; };
|
|
86
|
+
/**
|
|
87
|
+
* Undeclared errors become a `ToolFailed` the model reads, e.g. with
|
|
88
|
+
* `AiError.describe`. Declared failures pass through unchanged. Return
|
|
89
|
+
* `undefined` for an error that should still fail the run (a dead session).
|
|
90
|
+
*/
|
|
91
|
+
declare const describeFailures: {
|
|
92
|
+
<E, D extends string | undefined>(describe: (e: E) => D): <T extends Toolkit>(toolkit: T) => DescribeToolkit<T, D>;
|
|
93
|
+
<T extends Toolkit, D extends string | undefined>(toolkit: T, describe: (e: ToolkitE<T>) => D): DescribeToolkit<T, D>;
|
|
94
|
+
};
|
|
95
|
+
type ExecuteOptions = {
|
|
96
|
+
readonly concurrency?: number | "unbounded";
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Run the calls, emitting each one's partials and its `Output`, typed per tool
|
|
100
|
+
* and decoded. An error matching the tool's `failureSchema` becomes a `Failure`;
|
|
101
|
+
* any other error fails the stream (siblings of a failed batch may then stay
|
|
102
|
+
* unanswered: see `HistoryCheck.cancelAllPending`). Which calls run is the caller's call.
|
|
103
|
+
*/
|
|
104
|
+
declare const run: <T extends Toolkit>(toolkit: T, calls: ReadonlyArray<ToolCall>, options?: ExecuteOptions) => Stream.Stream<Event<T>, ToolkitE<T>, ToolkitR<T>>;
|
|
105
|
+
/** Any call's outcome, as `run` emits it. */
|
|
106
|
+
type Outcome = Output<string, unknown, unknown>;
|
|
107
|
+
/** Every error the toolkit's tools declare (core's errors are always possible too). */
|
|
108
|
+
type ToolkitFailure<T extends Toolkit> = ToolMap extends T ? unknown : ToolFailure<T[keyof T]>;
|
|
109
|
+
declare const UndeclaredFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
110
|
+
readonly _tag: "UndeclaredFailure";
|
|
111
|
+
} & Readonly<A>;
|
|
112
|
+
/** `Toolkit.close` got an error the call's tool doesn't declare: a bug in the app. */
|
|
113
|
+
declare class UndeclaredFailure extends UndeclaredFailure_base<{
|
|
114
|
+
readonly tool: string;
|
|
115
|
+
readonly message: string;
|
|
116
|
+
}> {}
|
|
117
|
+
/**
|
|
118
|
+
* A call the app closes itself (denied, superseded), as the outcome `run`
|
|
119
|
+
* would emit. `error` must be core's or declared by the call's tool
|
|
120
|
+
* (`failureSchema`, `Tool.withFailures`), else this fails with `UndeclaredFailure`.
|
|
121
|
+
* Pass the tool's name to check `error` against that tool at compile time:
|
|
122
|
+
*
|
|
123
|
+
* Toolkit.close(toolkit, "issue_refund", call, new Escalated({ team: "finance" }))
|
|
124
|
+
*/
|
|
125
|
+
declare function close<T extends Toolkit, N extends keyof T & string>(toolkit: T, name: N, call: ToolCall, error: ToolFailure<T[N]> | CoreError): Effect.Effect<Output<N, never, ToolFailure<T[N]> | CoreError>, UndeclaredFailure>;
|
|
126
|
+
declare function close<T extends Toolkit>(toolkit: T, call: ToolCall, error: ToolkitFailure<T> | CoreError): Effect.Effect<Output<string, never, ToolkitFailure<T> | CoreError>, UndeclaredFailure>;
|
|
127
|
+
/**
|
|
128
|
+
* A call the app answers itself (`ask_user`, a signal's acknowledgement), as
|
|
129
|
+
* the outcome `run` would emit: `close`'s success side. `value` is typed by the
|
|
130
|
+
* tool's `outputSchema`; a value it rejects ends the call with `OutputInvalid`,
|
|
131
|
+
* as from `run`. Fails with `UndeclaredFailure` if `call` is for another tool.
|
|
132
|
+
*/
|
|
133
|
+
declare const complete: <T extends Toolkit, N extends keyof T & string>(toolkit: T, name: N, call: ToolCall, value: ToolOutput<T[N]>) => Effect.Effect<Output<N, ToolOutput<T[N]>, OutputInvalid>, UndeclaredFailure>;
|
|
134
|
+
type InputOf<T> = T extends {
|
|
135
|
+
readonly inputSchema: StandardSchemaV1<any, infer I>;
|
|
136
|
+
} ? I : never;
|
|
137
|
+
type DeclaredCallOf<K extends string, X> = X extends {
|
|
138
|
+
readonly _tag: "DeclaredTool";
|
|
139
|
+
} ? {
|
|
140
|
+
readonly tool: K;
|
|
141
|
+
readonly call: ToolCall;
|
|
142
|
+
readonly input: InputOf<X>;
|
|
143
|
+
} : never;
|
|
144
|
+
/** A call to one of the toolkit's declared tools, its input decoded. `tool` is the discriminant. */
|
|
145
|
+
type DeclaredCall<T extends Toolkit> = { [K in keyof T & string]: DeclaredCallOf<K, T[K]>; }[keyof T & string];
|
|
146
|
+
/** A turn's calls, sorted for the loop. */
|
|
147
|
+
type Split<T extends Toolkit> = {
|
|
148
|
+
/** For `Toolkit.run`: calls to tools with `run`, and to unknown names (closed there). */
|
|
149
|
+
readonly run: ReadonlyArray<ToolCall>;
|
|
150
|
+
/** Calls to declared tools, decoded: handle them with `Match.discriminatorsExhaustive("tool")`. */
|
|
151
|
+
readonly declared: ReadonlyArray<DeclaredCall<T>>;
|
|
152
|
+
/** Calls to declared tools with bad arguments, closed with `InputInvalid` for the model. */
|
|
153
|
+
readonly invalid: ReadonlyArray<Output<string, never, InputInvalid>>;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The turn's tool calls, sorted: `run` for `Toolkit.run`, and the calls to
|
|
157
|
+
* declared tools decoded and typed per tool. Handling `declared` with
|
|
158
|
+
* `Match.discriminatorsExhaustive("tool")` makes a new declared tool a compile
|
|
159
|
+
* error until the loop handles it:
|
|
160
|
+
*
|
|
161
|
+
* const { run, declared, invalid } = yield* Toolkit.split(toolkit, turn)
|
|
162
|
+
* declared.map(Match.discriminatorsExhaustive("tool")({ ask_user: ..., escalate: ... }))
|
|
163
|
+
*/
|
|
164
|
+
declare const split: <T extends Toolkit>(toolkit: T, turn: Turn) => Effect.Effect<Split<T>>;
|
|
165
|
+
/** Narrows to the `Output` members (also in a loop's mixed stream), keeping the per-tool types. */
|
|
166
|
+
declare const isOutcome: <A extends {
|
|
167
|
+
readonly _tag: string;
|
|
168
|
+
}>(e: A) => e is Extract<A, {
|
|
169
|
+
readonly _tag: "Output";
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* An outcome as history, encoded with the tool's schemas (never stringified:
|
|
173
|
+
* that is the provider codec's job). `output(toolkit)` is the pipeable form.
|
|
174
|
+
*/
|
|
175
|
+
declare function output(toolkit: Toolkit): (event: Outcome) => Effect.Effect<ToolCallOutput, Schema.SchemaError>;
|
|
176
|
+
declare function output(toolkit: Toolkit, event: Outcome): Effect.Effect<ToolCallOutput, Schema.SchemaError>;
|
|
177
|
+
/** History back to a typed `Result` for tool `name`, decoded with its schemas. */
|
|
178
|
+
declare function decode<T extends Toolkit, N extends keyof T & string>(toolkit: T, name: N, item: ToolCallOutput): Effect.Effect<Result.Result<ToolOutput<T[N]>, ToolFailure<T[N]> | CoreError>, Schema.SchemaError>;
|
|
179
|
+
type Tagged = {
|
|
180
|
+
readonly _tag: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Forward every event as a `Loop.value`, then continue the loop with
|
|
184
|
+
* `build(outcomes)`. `build` is an Effect, so it can encode. The stream may
|
|
185
|
+
* carry the app's own tagged events too (any tag but `Output`).
|
|
186
|
+
*/
|
|
187
|
+
declare const continueWith: {
|
|
188
|
+
<S, E2, R2>(build: (outcomes: ReadonlyArray<Outcome>) => Effect.Effect<S, E2, R2>): <A extends Tagged, E, R>(stream: Stream.Stream<A, E, R>) => Stream.Stream<Step<A, S>, E | E2, R | R2>;
|
|
189
|
+
<A extends Tagged, E, R, S, E2, R2>(stream: Stream.Stream<A, E, R>, build: (outcomes: ReadonlyArray<Outcome>) => Effect.Effect<S, E2, R2>): Stream.Stream<Step<A, S>, E | E2, R | R2>;
|
|
190
|
+
};
|
|
191
|
+
/** Encode each outcome with `output` and append the turn plus the outputs to history. */
|
|
192
|
+
declare const appendResults: <S extends {
|
|
193
|
+
readonly history: ReadonlyArray<HistoryItem>;
|
|
194
|
+
}>(toolkit: Toolkit, state: S, turn: Turn) => (outcomes: ReadonlyArray<Outcome>) => Effect.Effect<S, Schema.SchemaError>;
|
|
195
|
+
/** `continueWith(appendResults(toolkit, state, turn))`. */
|
|
196
|
+
declare const next: <S extends {
|
|
197
|
+
readonly history: ReadonlyArray<HistoryItem>;
|
|
198
|
+
}>(toolkit: Toolkit, state: S, turn: Turn) => <A extends Tagged, E, R>(stream: Stream.Stream<A, E, R>) => Stream.Stream<{
|
|
199
|
+
readonly _tag: "Next";
|
|
200
|
+
readonly state: S;
|
|
201
|
+
} | {
|
|
202
|
+
readonly _tag: "Stop";
|
|
203
|
+
} | {
|
|
204
|
+
readonly _tag: "StopWith";
|
|
205
|
+
readonly state: S;
|
|
206
|
+
} | {
|
|
207
|
+
readonly _tag: "Value";
|
|
208
|
+
readonly value: A;
|
|
209
|
+
}, E | Schema.SchemaError, R>;
|
|
210
|
+
//#endregion
|
|
211
|
+
export { namespace as A, decode as C, isOutcome as D, fromArray as E, withFailures as F, wrap as I, output as M, run as N, make as O, split as P, continueWith as S, descriptors as T, UniqueTools as _, Handler as a, complete as b, Outcome as c, Toolkit as d, ToolkitE as f, UndeclaredFailure as g, Toolkit_d_exports as h, ExecuteOptions as i, next as j, makeNamespaced as k, Split as l, ToolkitR as m, DuplicateToolName as n, Middleware as o, ToolkitFailure as p, Event as r, NoDuplicateNames as s, DeclaredCall as t, ToolMap as u, appendResults as v, describeFailures as w, compose as x, close as y };
|
|
212
|
+
//# sourceMappingURL=Toolkit-D2VGeD5R.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toolkit-D2VGeD5R.d.mts","names":[],"sources":["../src/tool/Toolkit.ts"],"mappings":";;;;;;;;;;;KAiDY,UAAU,eAAe;KAEzB,QAAQ,cAAc,UAAU,WAAW;KAElD,QAAQ,cAAc,cAAc,eAAe,KAAK,iBAAiB,YAAY;;cAS7E,aAAc,cAAc,cAAc,aAAQ,OACnD,YAAY,WACrB,QAAQ,QAAQ;;cAGN,YAAS,OAAW,cAAc,aAAW;cAE7C,cAAW,SAAa,YAAU,cAAc;KAIxD,OAAO,UAAU,WAAW,QAAQ,QAAQ;WAAe;;;KAGpD,SAAS,UAAU,WAAW,gBAAgB,YAAY,MAAM,QAAQ;;KAGxE,SAAS,UAAU,WAAW,gBAAgB,YAAY,cAAc,QAAQ;;KAGhF,MAAM,UAAU,YACvB,OAAO,kBAAiB,KACrB,UAAU,WAAW,cAAc,SAAS,eAC1C,UAAoB,GAAG,GAAG,IAAI,6BAGpC,sBAAgC;KAM/B,cACH,cAAc,cAAc,UAC5B,+BACE,8BACI,aAAa,kBACV,aAAa,cAAc,YAElC,qBAAqB,OACnB,eACA,cAAc,MAAM,OAAO;KAG5B,mBAAmB;WACb,iCAAiC;;KAGhC,iBAAiB,cAAc,cAAc,aACvD,cAAc,oCAGZ,mBAAmB,cAAc;KAEzB,YAAY,cAAc,cAAc,YAAY,QAAQ,iBAAiB;KAGpF,oBACH,aAAa,cAAc,UAC3B,+BACE,6BAA6B,aAAa,kBAAkB,aAAa,cAAc,iCAClE,OACnB,oBAAoB,MAAM,QAC1B,cAAc,eAAe,sBAC3B,oBAAoB,MAAM,cAAc,kBACxC,cAAc,eAAe;KAGhC,wBAAwB,aAAa,cAAc,aACtD,oBAAoB,mCAGlB,mBAAmB,oBAA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