@effect-uai/core 0.1.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.
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/dist/AiError-CqmYjXyx.d.mts +110 -0
- package/dist/AiError-CqmYjXyx.d.mts.map +1 -0
- package/dist/Items-D1C2686t.d.mts +372 -0
- package/dist/Items-D1C2686t.d.mts.map +1 -0
- package/dist/Loop-CzSJo1h8.d.mts +87 -0
- package/dist/Loop-CzSJo1h8.d.mts.map +1 -0
- package/dist/Outcome-C2JYknCu.d.mts +40 -0
- package/dist/Outcome-C2JYknCu.d.mts.map +1 -0
- package/dist/StructuredFormat-B5ueioNr.d.mts +88 -0
- package/dist/StructuredFormat-B5ueioNr.d.mts.map +1 -0
- package/dist/Tool-5wxOCuOh.d.mts +86 -0
- package/dist/Tool-5wxOCuOh.d.mts.map +1 -0
- package/dist/ToolEvent-B2N10hr3.d.mts +29 -0
- package/dist/ToolEvent-B2N10hr3.d.mts.map +1 -0
- package/dist/Turn-rlTfuHaQ.d.mts +211 -0
- package/dist/Turn-rlTfuHaQ.d.mts.map +1 -0
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/domain/AiError.d.mts +2 -0
- package/dist/domain/AiError.mjs +40 -0
- package/dist/domain/AiError.mjs.map +1 -0
- package/dist/domain/Items.d.mts +2 -0
- package/dist/domain/Items.mjs +238 -0
- package/dist/domain/Items.mjs.map +1 -0
- package/dist/domain/Turn.d.mts +2 -0
- package/dist/domain/Turn.mjs +82 -0
- package/dist/domain/Turn.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +14 -0
- package/dist/language-model/LanguageModel.d.mts +60 -0
- package/dist/language-model/LanguageModel.d.mts.map +1 -0
- package/dist/language-model/LanguageModel.mjs +33 -0
- package/dist/language-model/LanguageModel.mjs.map +1 -0
- package/dist/loop/Loop.d.mts +2 -0
- package/dist/loop/Loop.mjs +172 -0
- package/dist/loop/Loop.mjs.map +1 -0
- package/dist/match/Match.d.mts +16 -0
- package/dist/match/Match.d.mts.map +1 -0
- package/dist/match/Match.mjs +15 -0
- package/dist/match/Match.mjs.map +1 -0
- package/dist/observability/Metrics.d.mts +45 -0
- package/dist/observability/Metrics.d.mts.map +1 -0
- package/dist/observability/Metrics.mjs +52 -0
- package/dist/observability/Metrics.mjs.map +1 -0
- package/dist/streaming/JSONL.d.mts +34 -0
- package/dist/streaming/JSONL.d.mts.map +1 -0
- package/dist/streaming/JSONL.mjs +51 -0
- package/dist/streaming/JSONL.mjs.map +1 -0
- package/dist/streaming/Lines.d.mts +27 -0
- package/dist/streaming/Lines.d.mts.map +1 -0
- package/dist/streaming/Lines.mjs +32 -0
- package/dist/streaming/Lines.mjs.map +1 -0
- package/dist/streaming/SSE.d.mts +31 -0
- package/dist/streaming/SSE.d.mts.map +1 -0
- package/dist/streaming/SSE.mjs +58 -0
- package/dist/streaming/SSE.mjs.map +1 -0
- package/dist/structured-format/StructuredFormat.d.mts +2 -0
- package/dist/structured-format/StructuredFormat.mjs +68 -0
- package/dist/structured-format/StructuredFormat.mjs.map +1 -0
- package/dist/testing/MockProvider.d.mts +48 -0
- package/dist/testing/MockProvider.d.mts.map +1 -0
- package/dist/testing/MockProvider.mjs +95 -0
- package/dist/testing/MockProvider.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +24 -0
- package/dist/tool/HistoryCheck.d.mts.map +1 -0
- package/dist/tool/HistoryCheck.mjs +39 -0
- package/dist/tool/HistoryCheck.mjs.map +1 -0
- package/dist/tool/Outcome.d.mts +2 -0
- package/dist/tool/Outcome.mjs +45 -0
- package/dist/tool/Outcome.mjs.map +1 -0
- package/dist/tool/Resolvers.d.mts +44 -0
- package/dist/tool/Resolvers.d.mts.map +1 -0
- package/dist/tool/Resolvers.mjs +67 -0
- package/dist/tool/Resolvers.mjs.map +1 -0
- package/dist/tool/Tool.d.mts +2 -0
- package/dist/tool/Tool.mjs +79 -0
- package/dist/tool/Tool.mjs.map +1 -0
- package/dist/tool/ToolEvent.d.mts +2 -0
- package/dist/tool/ToolEvent.mjs +8 -0
- package/dist/tool/ToolEvent.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +34 -0
- package/dist/tool/Toolkit.d.mts.map +1 -0
- package/dist/tool/Toolkit.mjs +105 -0
- package/dist/tool/Toolkit.mjs.map +1 -0
- package/package.json +127 -0
- package/src/domain/AiError.ts +93 -0
- package/src/domain/Items.ts +260 -0
- package/src/domain/Turn.ts +174 -0
- package/src/index.ts +13 -0
- package/src/language-model/LanguageModel.ts +73 -0
- package/src/loop/Loop.test.ts +412 -0
- package/src/loop/Loop.ts +295 -0
- package/src/match/Match.ts +9 -0
- package/src/observability/Metrics.ts +87 -0
- package/src/streaming/JSONL.test.ts +85 -0
- package/src/streaming/JSONL.ts +96 -0
- package/src/streaming/Lines.ts +34 -0
- package/src/streaming/SSE.test.ts +72 -0
- package/src/streaming/SSE.ts +114 -0
- package/src/structured-format/StructuredFormat.ts +160 -0
- package/src/testing/MockProvider.ts +161 -0
- package/src/tool/HistoryCheck.ts +49 -0
- package/src/tool/Outcome.ts +101 -0
- package/src/tool/Resolvers.test.ts +426 -0
- package/src/tool/Resolvers.ts +166 -0
- package/src/tool/Tool.ts +150 -0
- package/src/tool/ToolEvent.ts +37 -0
- package/src/tool/Toolkit.test.ts +45 -0
- package/src/tool/Toolkit.ts +228 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { o as FunctionCall, s as FunctionCallOutput } from "./Items-D1C2686t.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/tool/Outcome.d.ts
|
|
4
|
+
type ToolResult = {
|
|
5
|
+
readonly _tag: "Value";
|
|
6
|
+
readonly call_id: string;
|
|
7
|
+
readonly tool: string;
|
|
8
|
+
readonly value: unknown;
|
|
9
|
+
} | {
|
|
10
|
+
readonly _tag: "Failure";
|
|
11
|
+
readonly call_id: string;
|
|
12
|
+
readonly tool: string;
|
|
13
|
+
readonly kind: string;
|
|
14
|
+
readonly reason?: string;
|
|
15
|
+
};
|
|
16
|
+
declare const isValue: (r: ToolResult) => r is Extract<ToolResult, {
|
|
17
|
+
_tag: "Value";
|
|
18
|
+
}>;
|
|
19
|
+
declare const isFailure: (r: ToolResult) => r is Extract<ToolResult, {
|
|
20
|
+
_tag: "Failure";
|
|
21
|
+
}>;
|
|
22
|
+
type ToolDecision = {
|
|
23
|
+
readonly _tag: "Execute";
|
|
24
|
+
} | {
|
|
25
|
+
readonly _tag: "Reject";
|
|
26
|
+
readonly result: ToolResult;
|
|
27
|
+
};
|
|
28
|
+
declare const execute: ToolDecision;
|
|
29
|
+
declare const reject: (result: ToolResult) => ToolDecision;
|
|
30
|
+
declare const rejected: (call: FunctionCall, kind: string, reason?: string) => ToolResult;
|
|
31
|
+
/** Explicit user/policy rejection. */
|
|
32
|
+
declare const denied: (call: FunctionCall, reason?: string) => ToolResult;
|
|
33
|
+
/** Implicit non-answer (follow-up, inactivity, abort). */
|
|
34
|
+
declare const cancelled: (call: FunctionCall, reason?: string) => ToolResult;
|
|
35
|
+
/** Tool's own execution failed (parse error, schema, runtime crash). */
|
|
36
|
+
declare const executionError: (call: FunctionCall, reason: string) => ToolResult;
|
|
37
|
+
declare const toFunctionCallOutput: (r: ToolResult) => FunctionCallOutput;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { execute as a, isValue as c, toFunctionCallOutput as d, denied as i, reject as l, ToolResult as n, executionError as o, cancelled as r, isFailure as s, ToolDecision as t, rejected as u };
|
|
40
|
+
//# sourceMappingURL=Outcome-C2JYknCu.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Outcome-C2JYknCu.d.mts","names":[],"sources":["../src/tool/Outcome.ts"],"mappings":";;;KAsBY,UAAA;EAAA,SAEG,IAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,cAGF,OAAA,GAAW,CAAA,EAAG,UAAA,KAAa,CAAA,IAAK,OAAA,CAAQ,UAAA;EAAc,IAAA;AAAA;AAAA,cAGtD,SAAA,GAAa,CAAA,EAAG,UAAA,KAAa,CAAA,IAAK,OAAA,CAAQ,UAAA;EAAc,IAAA;AAAA;AAAA,KAOzD,YAAA;EAAA,SACG,IAAA;AAAA;EAAA,SACA,IAAA;EAAA,SAAyB,MAAA,EAAQ,UAAA;AAAA;AAAA,cAEnC,OAAA,EAAS,YAAA;AAAA,cAET,MAAA,GAAU,MAAA,EAAQ,UAAA,KAAa,YAAA;AAAA,cAO/B,QAAA,GACX,IAAA,EAAM,YAAA,EACN,IAAA,UACA,MAAA,cACC,UAAA;;cASU,MAAA,GAAU,IAAA,EAAM,YAAA,EAAc,MAAA,cAAkB,UAAA;;cAIhD,SAAA,GAAa,IAAA,EAAM,YAAA,EAAc,MAAA,cAAkB,UAAA;;cAInD,cAAA,GAAkB,IAAA,EAAM,YAAA,EAAc,MAAA,aAAiB,UAAA;AAAA,cAOvD,oBAAA,GAAwB,CAAA,EAAG,UAAA,KAAa,kBAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Effect, Schema, Stream } from "effect";
|
|
2
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
3
|
+
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
|
+
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
+
|
|
6
|
+
//#region src/structured-format/StructuredFormat.d.ts
|
|
7
|
+
declare namespace StructuredFormat_d_exports {
|
|
8
|
+
export { DecodeIssue, JsonParseError, StructuredDecodeError, StructuredFormat, StructuredSchema, decode, decodeJsonLines, fromEffectSchema, parseJson };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Cross-validator schema constraint for structured outputs. Any schema
|
|
12
|
+
* implementing both Standard Schema (runtime validation) and Standard
|
|
13
|
+
* JSON Schema (wire encoding) works directly: Zod 4+, Valibot, ArkType,
|
|
14
|
+
* and Effect Schema after `fromEffectSchema`.
|
|
15
|
+
*/
|
|
16
|
+
type StructuredSchema<Output = unknown> = StandardSchemaV1<unknown, Output> & StandardJSONSchemaV1<unknown, Output>;
|
|
17
|
+
/**
|
|
18
|
+
* A schema-bound output the user wants the model to produce. Pairs the
|
|
19
|
+
* cross-validator schema with metadata providers need (name, description,
|
|
20
|
+
* strict-mode flag).
|
|
21
|
+
*/
|
|
22
|
+
interface StructuredFormat<A> {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
readonly schema: StructuredSchema<A>;
|
|
26
|
+
/**
|
|
27
|
+
* Provider strict-mode flag. OpenAI, Anthropic, and Mistral honour it
|
|
28
|
+
* (constrained decoding); other providers ignore.
|
|
29
|
+
*/
|
|
30
|
+
readonly strict?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** A single path-scoped validation problem. Library-agnostic shape. */
|
|
33
|
+
interface DecodeIssue {
|
|
34
|
+
readonly path: ReadonlyArray<string | number>;
|
|
35
|
+
readonly message: string;
|
|
36
|
+
}
|
|
37
|
+
declare const StructuredDecodeError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
38
|
+
readonly _tag: "StructuredDecodeError";
|
|
39
|
+
} & Readonly<A>;
|
|
40
|
+
/**
|
|
41
|
+
* Schema validation failed. `raw` is the original text (or stringified
|
|
42
|
+
* value) that failed; `issues` is a flat list of per-field problems.
|
|
43
|
+
*/
|
|
44
|
+
declare class StructuredDecodeError extends StructuredDecodeError_base<{
|
|
45
|
+
readonly raw: string;
|
|
46
|
+
readonly issues: ReadonlyArray<DecodeIssue>;
|
|
47
|
+
}> {}
|
|
48
|
+
declare const JsonParseError_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
49
|
+
readonly _tag: "StructuredJsonParseError";
|
|
50
|
+
} & Readonly<A>;
|
|
51
|
+
/**
|
|
52
|
+
* `JSON.parse` threw on a string that was supposed to be JSON. Distinct
|
|
53
|
+
* from `StructuredDecodeError`: the bytes weren't even JSON.
|
|
54
|
+
*/
|
|
55
|
+
declare class JsonParseError extends JsonParseError_base<{
|
|
56
|
+
readonly raw: string;
|
|
57
|
+
readonly cause: unknown;
|
|
58
|
+
}> {}
|
|
59
|
+
/**
|
|
60
|
+
* Wrap an Effect `Schema` as a `StructuredFormat`. Effect Schema doesn't
|
|
61
|
+
* natively implement Standard Schema; this helper installs the
|
|
62
|
+
* `~standard` and JSON Schema interfaces.
|
|
63
|
+
*/
|
|
64
|
+
declare const fromEffectSchema: <S extends Schema.Codec<any, any, never, any>>(schema: S, options?: {
|
|
65
|
+
readonly name?: string;
|
|
66
|
+
readonly description?: string;
|
|
67
|
+
readonly strict?: boolean;
|
|
68
|
+
}) => StructuredFormat<S["Type"]>;
|
|
69
|
+
/**
|
|
70
|
+
* Validate an `unknown` against the format's schema. Returns the typed
|
|
71
|
+
* value or a `StructuredDecodeError`. Standard Schema's `validate` may
|
|
72
|
+
* be async; this function handles both sync and async results.
|
|
73
|
+
*/
|
|
74
|
+
declare const decode: <A>(format: StructuredFormat<A>) => (raw: unknown) => Effect.Effect<A, StructuredDecodeError>;
|
|
75
|
+
/**
|
|
76
|
+
* Parse a JSON string then validate against the format's schema. Two
|
|
77
|
+
* failure modes: `JsonParseError` (bytes weren't JSON) and
|
|
78
|
+
* `StructuredDecodeError` (JSON didn't match the schema).
|
|
79
|
+
*/
|
|
80
|
+
declare const parseJson: <A>(format: StructuredFormat<A>) => (raw: string) => Effect.Effect<A, JsonParseError | StructuredDecodeError>;
|
|
81
|
+
/**
|
|
82
|
+
* Stream operator: each input string is JSON-parsed and validated.
|
|
83
|
+
* Failures surface in the stream's failure channel, distinguished by tag.
|
|
84
|
+
*/
|
|
85
|
+
declare const decodeJsonLines: <A>(format: StructuredFormat<A>) => <E, R>(self: Stream.Stream<string, E, R>) => Stream.Stream<A, E | JsonParseError | StructuredDecodeError, R>;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { StructuredFormat_d_exports as a, decodeJsonLines as c, StructuredFormat as i, fromEffectSchema as l, JsonParseError as n, StructuredSchema as o, StructuredDecodeError as r, decode as s, DecodeIssue as t, parseJson as u };
|
|
88
|
+
//# sourceMappingURL=StructuredFormat-B5ueioNr.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructuredFormat-B5ueioNr.d.mts","names":[],"sources":["../src/structured-format/StructuredFormat.ts"],"mappings":";;;;;;;;;;;;;;;KAaY,gBAAA,qBAAqC,gBAAA,UAA0B,MAAA,IACzE,oBAAA,UAA8B,MAAA;;;;;;UAOf,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,gBAAA,CAAiB,CAAA;EAXxB;;;;EAAA,SAgBD,MAAA;AAAA;;UAIM,WAAA;EAAA,SACN,IAAA,EAAM,aAAA;EAAA,SACN,OAAA;AAAA;AAAA,cACV,0BAAA;;;;;AAfD;;cAyBa,qBAAA,SAA8B,0BAAA;EAAA,SAChC,GAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,WAAA;AAAA;AAAA,cAC5B,mBAAA;;;;;;AAhBL;cAsBa,cAAA,SAAuB,mBAAA;EAAA,SACzB,GAAA;EAAA,SACA,KAAA;AAAA;;;;AArBV;;cAiCY,gBAAA,aAA8B,MAAA,CAAO,KAAA,wBAChD,MAAA,EAAQ,CAAA,EACR,OAAA;EAAA,SACW,IAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA;AAAA,MAEV,gBAAA,CAAiB,CAAA;;;;;;cAyCP,MAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,OAC5B,GAAA,cAAe,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,qBAAA;;;;;;cAoBtB,SAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,OAC5B,GAAA,aAAc,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,cAAA,GAAiB,qBAAA;;;;;cAatC,eAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,aAE3B,IAAA,EAAM,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA,MAC9B,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,cAAA,GAAiB,qBAAA,EAAuB,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { o as FunctionCall, s as FunctionCallOutput } from "./Items-D1C2686t.mjs";
|
|
2
|
+
import { Effect, Schema, Stream } 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 { AnyKindTool, AnyPlainTool, AnyStreamingTool, StreamingTool, Tool, ToolDescriptor, ToolError, ToolInputSchema, execute, fromEffectSchema, isStreamingTool, make, streaming, toDescriptors };
|
|
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
|
+
/**
|
|
18
|
+
* Schemas accepted on `Tool.inputSchema`. Must implement both Standard
|
|
19
|
+
* Schema validation and JSON Schema conversion (for rendering tool
|
|
20
|
+
* descriptors to provider request bodies).
|
|
21
|
+
*
|
|
22
|
+
* Any Standard-Schema-compliant library that exposes both interfaces
|
|
23
|
+
* works directly: Zod 4+, Valibot, ArkType, Effect Schema (after
|
|
24
|
+
* `fromEffectSchema`), etc.
|
|
25
|
+
*/
|
|
26
|
+
type ToolInputSchema<Input = unknown> = StandardSchemaV1<unknown, Input> & StandardJSONSchemaV1<unknown, Input>;
|
|
27
|
+
/**
|
|
28
|
+
* Convenience wrapper for Effect Schema users - adds both the
|
|
29
|
+
* `validate` and `jsonSchema` extensions to a plain Effect Schema so it
|
|
30
|
+
* can be used as a `Tool.inputSchema`.
|
|
31
|
+
*/
|
|
32
|
+
declare const fromEffectSchema: <S extends Schema.Codec<any, any, never, any>>(schema: S) => S & ToolInputSchema<S["Type"]>;
|
|
33
|
+
interface Tool<Name extends string, Input, Output, R = never> {
|
|
34
|
+
readonly name: Name;
|
|
35
|
+
readonly description: string;
|
|
36
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
37
|
+
readonly run: (input: Input) => Effect.Effect<Output, unknown, R>;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the provider should render this tool with its strict-mode
|
|
40
|
+
* flag (OpenAI's `strict: true`, etc). Default: true. The framework
|
|
41
|
+
* never rewrites the schema; if the rendered JSON Schema isn't
|
|
42
|
+
* compatible, the provider returns an error.
|
|
43
|
+
*/
|
|
44
|
+
readonly strict?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Provider-agnostic tool descriptor. Each provider maps `inputSchema`
|
|
48
|
+
* to its own wire field (OpenAI → `parameters`, Anthropic →
|
|
49
|
+
* `input_schema`). Built from a `Tool` by `Toolkit.toDescriptors`.
|
|
50
|
+
*/
|
|
51
|
+
interface ToolDescriptor {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
readonly inputSchema: Record<string, unknown>;
|
|
55
|
+
readonly strict?: boolean;
|
|
56
|
+
}
|
|
57
|
+
declare const make: <Name extends string, Input, Output, R = never>(spec: Tool<Name, Input, Output, R>) => Tool<Name, Input, Output, R>;
|
|
58
|
+
interface StreamingTool<Name extends string, Input, Event, Output, R = never> {
|
|
59
|
+
readonly _kind: "streaming";
|
|
60
|
+
readonly name: Name;
|
|
61
|
+
readonly description: string;
|
|
62
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
63
|
+
readonly run: (input: Input) => Stream.Stream<Event, unknown, R>;
|
|
64
|
+
readonly finalize: (events: ReadonlyArray<Event>) => Output;
|
|
65
|
+
readonly strict?: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare const streaming: <Name extends string, Input, Event, Output, R = never>(spec: Omit<StreamingTool<Name, Input, Event, Output, R>, "_kind">) => StreamingTool<Name, Input, Event, Output, R>;
|
|
68
|
+
type AnyStreamingTool = StreamingTool<string, any, any, any, never>;
|
|
69
|
+
type AnyPlainTool = Tool<string, any, any, never>;
|
|
70
|
+
type AnyKindTool = AnyStreamingTool | AnyPlainTool;
|
|
71
|
+
declare const isStreamingTool: (t: AnyKindTool) => t is AnyStreamingTool;
|
|
72
|
+
/**
|
|
73
|
+
* Render any-kind tools (mixed plain and streaming) to provider-agnostic
|
|
74
|
+
* descriptors. Mirrors `Toolkit.toDescriptors` but accepts the union type
|
|
75
|
+
* so a single list can carry both kinds.
|
|
76
|
+
*/
|
|
77
|
+
declare const toDescriptors: (tools: ReadonlyArray<AnyKindTool>) => ReadonlyArray<ToolDescriptor>;
|
|
78
|
+
/**
|
|
79
|
+
* Decode and validate the JSON arguments of a function_call against the
|
|
80
|
+
* tool's input schema, run the tool, and serialize the output into a
|
|
81
|
+
* function_call_output item.
|
|
82
|
+
*/
|
|
83
|
+
declare const execute: <Name extends string, Input, Output, R>(tool: Tool<Name, Input, Output, R>, call: FunctionCall) => Effect.Effect<FunctionCallOutput, ToolError, R>;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { Tool as a, ToolInputSchema as c, fromEffectSchema as d, isStreamingTool as f, toDescriptors as h, StreamingTool as i, Tool_d_exports as l, streaming as m, AnyPlainTool as n, ToolDescriptor as o, make as p, AnyStreamingTool as r, ToolError as s, AnyKindTool as t, execute as u };
|
|
86
|
+
//# sourceMappingURL=Tool-5wxOCuOh.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tool-5wxOCuOh.d.mts","names":[],"sources":["../src/tool/Tool.ts"],"mappings":";;;;;;;;;cAE0E,cAAA;;;;;;cAG7D,SAAA,SAAkB,cAAA;;;;;;;;;;KAmBnB,eAAA,oBAAmC,gBAAA,UAA0B,KAAA,IACvE,oBAAA,UAA8B,KAAA;;;AAvB0C;;;cA8B7D,gBAAA,aAA8B,MAAA,CAAO,KAAA,wBAChD,MAAA,EAAQ,CAAA,KACP,CAAA,GAAI,eAAA,CAAgB,CAAA;AAAA,UAIN,IAAA;EAAA,SACN,IAAA,EAAM,IAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,GAAA,GAAM,KAAA,EAAO,KAAA,KAAU,MAAA,CAAO,MAAA,CAAO,MAAA,WAAiB,CAAA;;;;;;;WAOtD,MAAA;AAAA;;;;;;UAQM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,WAAA;EAAA,SACA,WAAA,EAAa,MAAA;EAAA,SACb,MAAA;AAAA;AAAA,cAGE,IAAA,kDACX,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,CAAA,MAC/B,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,CAAA;AAAA,UAWZ,aAAA;EAAA,SACN,KAAA;EAAA,SACA,IAAA,EAAM,IAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,GAAA,GAAM,KAAA,EAAO,KAAA,KAAU,MAAA,CAAO,MAAA,CAAO,KAAA,WAAgB,CAAA;EAAA,SACrD,QAAA,GAAW,MAAA,EAAQ,aAAA,CAAc,KAAA,MAAW,MAAA;EAAA,SAC5C,MAAA;AAAA;AAAA,cAGE,SAAA,yDACX,IAAA,EAAM,IAAA,CAAK,aAAA,CAAc,IAAA,EAAM,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,CAAA,gBACpD,aAAA,CAAc,IAAA,EAAM,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,CAAA;AAAA,KAEjC,gBAAA,GAAmB,aAAA;AAAA,KACnB,YAAA,GAAe,IAAA;AAAA,KACf,WAAA,GAAc,gBAAA,GAAmB,YAAA;AAAA,cAEhC,eAAA,GAAmB,CAAA,EAAG,WAAA,KAAc,CAAA,IAAK,gBAAA;;;;;;cAQzC,aAAA,GACX,KAAA,EAAO,aAAA,CAAc,WAAA,MACpB,aAAA,CAAc,cAAA;;;;;;cAkBJ,OAAA,0CACX,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,CAAA,GAChC,IAAA,EAAM,YAAA,KACL,MAAA,CAAO,MAAA,CAAO,kBAAA,EAAoB,SAAA,EAAW,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { n as ToolResult } from "./Outcome-C2JYknCu.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/tool/ToolEvent.d.ts
|
|
4
|
+
type ToolEvent = {
|
|
5
|
+
readonly _tag: "ApprovalRequested";
|
|
6
|
+
readonly call_id: string;
|
|
7
|
+
readonly tool: string;
|
|
8
|
+
readonly arguments: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly _tag: "Intermediate";
|
|
11
|
+
readonly call_id: string;
|
|
12
|
+
readonly tool: string;
|
|
13
|
+
readonly data: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
readonly _tag: "Output";
|
|
16
|
+
readonly result: ToolResult;
|
|
17
|
+
};
|
|
18
|
+
declare const isApprovalRequested: (e: ToolEvent) => e is Extract<ToolEvent, {
|
|
19
|
+
_tag: "ApprovalRequested";
|
|
20
|
+
}>;
|
|
21
|
+
declare const isIntermediate: (e: ToolEvent) => e is Extract<ToolEvent, {
|
|
22
|
+
_tag: "Intermediate";
|
|
23
|
+
}>;
|
|
24
|
+
declare const isOutput: (e: ToolEvent) => e is Extract<ToolEvent, {
|
|
25
|
+
_tag: "Output";
|
|
26
|
+
}>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isOutput as i, isApprovalRequested as n, isIntermediate as r, ToolEvent as t };
|
|
29
|
+
//# sourceMappingURL=ToolEvent-B2N10hr3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolEvent-B2N10hr3.d.mts","names":[],"sources":["../src/tool/ToolEvent.ts"],"mappings":";;;KAYY,SAAA;EAAA,SAEG,IAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,SAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAAyB,MAAA,EAAQ,UAAA;AAAA;AAAA,cAEnC,mBAAA,GACX,CAAA,EAAG,SAAA,KACF,CAAA,IAAK,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA;AAAA,cAEhB,cAAA,GACX,CAAA,EAAG,SAAA,KACF,CAAA,IAAK,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA;AAAA,cAEhB,QAAA,GAAY,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { g as Message, m as Item, o as FunctionCall, s as FunctionCallOutput, w as Usage, y as Reasoning } from "./Items-D1C2686t.mjs";
|
|
2
|
+
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "./StructuredFormat-B5ueioNr.mjs";
|
|
3
|
+
import { Effect, Schema, Stream } from "effect";
|
|
4
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
5
|
+
import * as _$effect_Cause0 from "effect/Cause";
|
|
6
|
+
|
|
7
|
+
//#region src/domain/Turn.d.ts
|
|
8
|
+
declare namespace Turn_d_exports {
|
|
9
|
+
export { Cursor, InteractionEvent, RefusalRejected, Turn, TurnEvent, assistantMessages, cursor, functionCalls, isTurnComplete, reasonings, textDeltas, toStructured };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The result of a single LLM generation. A turn produces zero or more items
|
|
13
|
+
* (typically one assistant message and zero or more function_call items)
|
|
14
|
+
* and reports usage + a stop reason.
|
|
15
|
+
*/
|
|
16
|
+
declare const Turn: Schema.Struct<{
|
|
17
|
+
readonly items: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
18
|
+
readonly type: Schema.Literal<"message">;
|
|
19
|
+
readonly role: Schema.Literals<readonly ["user", "assistant", "system"]>;
|
|
20
|
+
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
21
|
+
readonly type: Schema.Literal<"input_text">;
|
|
22
|
+
readonly text: Schema.String;
|
|
23
|
+
}>, Schema.Struct<{
|
|
24
|
+
readonly type: Schema.Literal<"input_image">;
|
|
25
|
+
readonly source: Schema.Union<readonly [Schema.Struct<{
|
|
26
|
+
readonly _tag: Schema.Literal<"url">;
|
|
27
|
+
readonly url: Schema.String;
|
|
28
|
+
}>, Schema.Struct<{
|
|
29
|
+
readonly _tag: Schema.Literal<"base64">;
|
|
30
|
+
readonly media_type: Schema.String;
|
|
31
|
+
readonly data: Schema.String;
|
|
32
|
+
}>]>;
|
|
33
|
+
}>, Schema.Struct<{
|
|
34
|
+
readonly type: Schema.Literal<"output_text">;
|
|
35
|
+
readonly text: Schema.String;
|
|
36
|
+
readonly annotations: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
37
|
+
readonly type: Schema.Literal<"url_citation">;
|
|
38
|
+
readonly url: Schema.String;
|
|
39
|
+
readonly start_index: Schema.Number;
|
|
40
|
+
readonly end_index: Schema.Number;
|
|
41
|
+
readonly title: Schema.String;
|
|
42
|
+
}>, Schema.Struct<{
|
|
43
|
+
readonly type: Schema.Literal<"file_citation">;
|
|
44
|
+
readonly file_id: Schema.String;
|
|
45
|
+
readonly index: Schema.Number;
|
|
46
|
+
}>, Schema.Struct<{
|
|
47
|
+
readonly type: Schema.Literal<"container_file_citation">;
|
|
48
|
+
readonly container_id: Schema.String;
|
|
49
|
+
readonly file_id: Schema.String;
|
|
50
|
+
readonly start_index: Schema.Number;
|
|
51
|
+
readonly end_index: Schema.Number;
|
|
52
|
+
}>, Schema.Struct<{
|
|
53
|
+
readonly type: Schema.Literal<"file_path">;
|
|
54
|
+
readonly file_id: Schema.String;
|
|
55
|
+
readonly index: Schema.Number;
|
|
56
|
+
}>]>>>;
|
|
57
|
+
}>, Schema.Struct<{
|
|
58
|
+
readonly type: Schema.Literal<"refusal">;
|
|
59
|
+
readonly text: Schema.String;
|
|
60
|
+
}>]>>;
|
|
61
|
+
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
62
|
+
}>, Schema.Struct<{
|
|
63
|
+
readonly type: Schema.Literal<"function_call">;
|
|
64
|
+
readonly call_id: Schema.String;
|
|
65
|
+
readonly name: Schema.String;
|
|
66
|
+
readonly arguments: Schema.String;
|
|
67
|
+
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
68
|
+
}>, Schema.Struct<{
|
|
69
|
+
readonly type: Schema.Literal<"function_call_output">;
|
|
70
|
+
readonly call_id: Schema.String;
|
|
71
|
+
readonly output: Schema.String;
|
|
72
|
+
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
73
|
+
}>, Schema.Struct<{
|
|
74
|
+
readonly type: Schema.Literal<"reasoning">;
|
|
75
|
+
readonly id: Schema.optional<Schema.String>;
|
|
76
|
+
readonly summary: Schema.optional<Schema.String>;
|
|
77
|
+
readonly signature: Schema.optional<Schema.String>;
|
|
78
|
+
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
79
|
+
}>]>>;
|
|
80
|
+
readonly usage: Schema.Struct<{
|
|
81
|
+
readonly input_tokens: Schema.optional<Schema.Number>;
|
|
82
|
+
readonly output_tokens: Schema.optional<Schema.Number>;
|
|
83
|
+
readonly total_tokens: Schema.optional<Schema.Number>;
|
|
84
|
+
readonly input_tokens_details: Schema.optional<Schema.Struct<{
|
|
85
|
+
readonly cached_tokens: Schema.optional<Schema.Number>;
|
|
86
|
+
}>>;
|
|
87
|
+
readonly output_tokens_details: Schema.optional<Schema.Struct<{
|
|
88
|
+
readonly reasoning_tokens: Schema.optional<Schema.Number>;
|
|
89
|
+
}>>;
|
|
90
|
+
}>;
|
|
91
|
+
readonly stop_reason: Schema.Literals<readonly ["stop", "tool_calls", "max_tokens", "refusal", "content_filter", "max_tool_calls"]>;
|
|
92
|
+
}>;
|
|
93
|
+
type Turn = typeof Turn.Type;
|
|
94
|
+
/**
|
|
95
|
+
* Canonical events emitted while a single turn is being generated. Most
|
|
96
|
+
* variants are streaming deltas (text, reasoning, tool-call args); the
|
|
97
|
+
* terminal `turn_complete` carries the assembled `Turn`. Lifecycle members
|
|
98
|
+
* aren't deltas, hence the union name.
|
|
99
|
+
*/
|
|
100
|
+
type TurnEvent = {
|
|
101
|
+
readonly type: "text_delta";
|
|
102
|
+
readonly text: string;
|
|
103
|
+
} | {
|
|
104
|
+
readonly type: "reasoning_delta";
|
|
105
|
+
readonly text: string;
|
|
106
|
+
/**
|
|
107
|
+
* `trace` is the model's raw chain-of-thought; `summary` is a
|
|
108
|
+
* model-written summary intended for display. OpenAI Responses emits
|
|
109
|
+
* both as separate wire events; Anthropic and Gemini only emit
|
|
110
|
+
* `trace`. Consumers who just want any reasoning text match once;
|
|
111
|
+
* those who want only summaries filter `kind === "summary"`.
|
|
112
|
+
*/
|
|
113
|
+
readonly kind: "trace" | "summary";
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The model declined to answer. `text` is the (streamed) explanation.
|
|
117
|
+
* Distinct from the failure channel: a refusal is normal model output and
|
|
118
|
+
* the stream still completes with `turn_complete`. OpenAI Responses emits
|
|
119
|
+
* this; Anthropic surfaces refusals via `stop_reason`, and Gemini collapses
|
|
120
|
+
* them into `finishReason: SAFETY` - both go without a `refusal_delta`.
|
|
121
|
+
*/
|
|
122
|
+
| {
|
|
123
|
+
readonly type: "refusal_delta";
|
|
124
|
+
readonly text: string;
|
|
125
|
+
} | {
|
|
126
|
+
readonly type: "tool_call_start";
|
|
127
|
+
readonly call_id: string;
|
|
128
|
+
readonly name: string;
|
|
129
|
+
} | {
|
|
130
|
+
readonly type: "tool_call_args_delta";
|
|
131
|
+
readonly call_id: string;
|
|
132
|
+
readonly delta: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Mid-stream cumulative usage. Carries the full `Usage` (including cache
|
|
136
|
+
* token fields when the provider surfaces them) so consumers can drive
|
|
137
|
+
* live budget / cost tracking without waiting for `turn_complete`.
|
|
138
|
+
* Anthropic emits this on `message_start` and `message_delta`; other
|
|
139
|
+
* providers may not emit any `usage_update` and only deliver usage via
|
|
140
|
+
* `turn_complete.turn.usage`.
|
|
141
|
+
*/
|
|
142
|
+
| {
|
|
143
|
+
readonly type: "usage_update";
|
|
144
|
+
readonly usage: Usage;
|
|
145
|
+
} | {
|
|
146
|
+
readonly type: "turn_complete";
|
|
147
|
+
readonly turn: Turn;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* What flows out of an agent loop body to its consumer per turn: every
|
|
151
|
+
* `TurnEvent` the provider emits (including the terminal `turn_complete`
|
|
152
|
+
* carrying the assembled `Turn`), plus the output of any tool the loop ran.
|
|
153
|
+
* Both variants carry a `type` discriminator.
|
|
154
|
+
*/
|
|
155
|
+
type InteractionEvent = TurnEvent | FunctionCallOutput;
|
|
156
|
+
declare const isTurnComplete: (d: TurnEvent) => d is Extract<TurnEvent, {
|
|
157
|
+
type: "turn_complete";
|
|
158
|
+
}>;
|
|
159
|
+
declare const functionCalls: (turn: Turn) => ReadonlyArray<FunctionCall>;
|
|
160
|
+
declare const reasonings: (turn: Turn) => ReadonlyArray<Reasoning>;
|
|
161
|
+
declare const assistantMessages: (turn: Turn) => ReadonlyArray<Message>;
|
|
162
|
+
/**
|
|
163
|
+
* State stamped with the just-completed `Turn`. Recipes use this as the
|
|
164
|
+
* intermediate value between "turn lands" and "compute next state": extend
|
|
165
|
+
* `state.history` with the turn's items, and keep the assembled turn
|
|
166
|
+
* around for stop-reason / usage / function-call inspection.
|
|
167
|
+
*
|
|
168
|
+
* Generic over the recipe's state shape - any record carrying a
|
|
169
|
+
* `history: ReadonlyArray<Item>` field works.
|
|
170
|
+
*/
|
|
171
|
+
type Cursor<S> = S & {
|
|
172
|
+
readonly turn: Turn;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Build a `Cursor<S>` from a state record and the just-completed turn.
|
|
176
|
+
* Extends `state.history` with `turn.items` and stamps the turn.
|
|
177
|
+
*/
|
|
178
|
+
declare const cursor: <S extends {
|
|
179
|
+
readonly history: ReadonlyArray<Item>;
|
|
180
|
+
}>(state: S, turn: Turn) => Cursor<S>;
|
|
181
|
+
/**
|
|
182
|
+
* Project a `TurnEvent` stream onto its `text_delta` payloads. Other
|
|
183
|
+
* variants are dropped. Composes with `Lines.lines` +
|
|
184
|
+
* `decodeJsonLines` for prompted-JSONL streaming.
|
|
185
|
+
*/
|
|
186
|
+
declare const textDeltas: <E, R>(self: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<string, E, R>;
|
|
187
|
+
declare const RefusalRejected_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
188
|
+
readonly _tag: "RefusalRejected";
|
|
189
|
+
} & Readonly<A>;
|
|
190
|
+
/**
|
|
191
|
+
* The assistant message on the just-completed turn was a refusal block,
|
|
192
|
+
* not an `output_text` payload. Returned by `toStructured` to short-circuit
|
|
193
|
+
* decoding before `JSON.parse` / schema validation runs.
|
|
194
|
+
*/
|
|
195
|
+
declare class RefusalRejected extends RefusalRejected_base<{
|
|
196
|
+
readonly turn: Turn;
|
|
197
|
+
}> {}
|
|
198
|
+
/**
|
|
199
|
+
* Validate a completed `Turn` against a `StructuredFormat`. Concatenates
|
|
200
|
+
* `output_text` blocks on the last assistant message, then runs
|
|
201
|
+
* `JSON.parse` + the format's schema validation.
|
|
202
|
+
*
|
|
203
|
+
* Three failure modes:
|
|
204
|
+
* - `RefusalRejected` — the assistant emitted a refusal block.
|
|
205
|
+
* - `JsonParseError` — the assembled text wasn't valid JSON.
|
|
206
|
+
* - `StructuredDecodeError` — the JSON didn't match the schema.
|
|
207
|
+
*/
|
|
208
|
+
declare const toStructured: <A>(turn: Turn, format: StructuredFormat<A>) => Effect.Effect<A, RefusalRejected | JsonParseError | StructuredDecodeError>;
|
|
209
|
+
//#endregion
|
|
210
|
+
export { TurnEvent as a, cursor as c, reasonings as d, textDeltas as f, Turn as i, functionCalls as l, InteractionEvent as n, Turn_d_exports as o, toStructured as p, RefusalRejected as r, assistantMessages as s, Cursor as t, isTurnComplete as u };
|
|
211
|
+
//# sourceMappingURL=Turn-rlTfuHaQ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Turn-rlTfuHaQ.d.mts","names":[],"sources":["../src/domain/Turn.ts"],"mappings":";;;;;;;;;;;;;;;cAmBa,IAAA,EAAI,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKL,IAAA,UAAc,IAAA,CAAK,IAAA;;;;;;;KAQnB,SAAA;EAAA,SACG,IAAA;EAAA,SAA6B,IAAA;AAAA;EAAA,SAE7B,IAAA;EAAA,SACA,IAAA;;;;;;;;WAQA,IAAA;AAAA;;;;;;;;;WASA,IAAA;EAAA,SAAgC,IAAA;AAAA;EAAA,SAChC,IAAA;EAAA,SAAkC,OAAA;EAAA,SAA0B,IAAA;AAAA;EAAA,SAC5D,IAAA;EAAA,SAAuC,OAAA;EAAA,SAA0B,KAAA;AAAA;;;;;;;;;;WASjE,IAAA;EAAA,SAA+B,KAAA,EAAO,KAAA;AAAA;EAAA,SACtC,IAAA;EAAA,SAAgC,IAAA,EAAM,IAAA;AAAA;;;;;;;KAQzC,gBAAA,GAAmB,SAAA,GAAY,kBAAA;AAAA,cAE9B,cAAA,GAAkB,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA;AAAA,cAG3D,aAAA,GAAiB,IAAA,EAAM,IAAA,KAAO,aAAA,CAAc,YAAA;AAAA,cAG5C,UAAA,GAAc,IAAA,EAAM,IAAA,KAAO,aAAA,CAAc,SAAA;AAAA,cAGzC,iBAAA,GAAqB,IAAA,EAAM,IAAA,KAAO,aAAA,CAAc,OAAA;;;;;;;;;;KAYjD,MAAA,MAAY,CAAA;EAAA,SAAe,IAAA,EAAM,IAAA;AAAA;;;;;cAMhC,MAAA;EAAA,SAA+B,OAAA,EAAS,aAAA,CAAc,IAAA;AAAA,GACjE,KAAA,EAAO,CAAA,EACP,IAAA,EAAM,IAAA,KACL,MAAA,CAAO,CAAA;;;;;;cAeG,UAAA,SACX,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG,CAAA,MACjC,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA;AAAA,cAKzB,oBAAA;;;;;;;;cAWU,eAAA,SAAwB,oBAAA;EAAA,SAC1B,IAAA,EAAM,IAAA;AAAA;;;;;;;;;;;cAyBJ,YAAA,MACX,IAAA,EAAM,IAAA,EACN,MAAA,EAAQ,gBAAA,CAAkC,CAAA,MACzC,MAAA,CAAO,MAAA,CACR,CAAA,EACA,eAAA,GAAkB,cAAA,GAAkC,qBAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-CqmYjXyx.mjs";
|
|
2
|
+
export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-CfYAbeIz.mjs";
|
|
2
|
+
import { Data } from "effect";
|
|
3
|
+
//#region src/domain/AiError.ts
|
|
4
|
+
var AiError_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
AuthFailed: () => AuthFailed,
|
|
6
|
+
Cancelled: () => Cancelled,
|
|
7
|
+
ContentFiltered: () => ContentFiltered,
|
|
8
|
+
ContextLengthExceeded: () => ContextLengthExceeded,
|
|
9
|
+
GenerationFailed: () => GenerationFailed,
|
|
10
|
+
IncompleteTurn: () => IncompleteTurn,
|
|
11
|
+
InvalidRequest: () => InvalidRequest,
|
|
12
|
+
RateLimited: () => RateLimited,
|
|
13
|
+
Timeout: () => Timeout,
|
|
14
|
+
Unavailable: () => Unavailable
|
|
15
|
+
});
|
|
16
|
+
var RateLimited = class extends Data.TaggedError("RateLimited") {};
|
|
17
|
+
var Unavailable = class extends Data.TaggedError("Unavailable") {};
|
|
18
|
+
var Timeout = class extends Data.TaggedError("Timeout") {};
|
|
19
|
+
var ContentFiltered = class extends Data.TaggedError("ContentFiltered") {};
|
|
20
|
+
var ContextLengthExceeded = class extends Data.TaggedError("ContextLengthExceeded") {};
|
|
21
|
+
var InvalidRequest = class extends Data.TaggedError("InvalidRequest") {};
|
|
22
|
+
var AuthFailed = class extends Data.TaggedError("AuthFailed") {};
|
|
23
|
+
var Cancelled = class extends Data.TaggedError("Cancelled") {};
|
|
24
|
+
/**
|
|
25
|
+
* The model errored mid-generation. Distinct from `Unavailable` (transport
|
|
26
|
+
* problem before generation started) and from `IncompleteTurn` (provider
|
|
27
|
+
* stream ended without a terminal event). The provider's own error message,
|
|
28
|
+
* if any, is on `message`.
|
|
29
|
+
*/
|
|
30
|
+
var GenerationFailed = class extends Data.TaggedError("GenerationFailed") {};
|
|
31
|
+
/**
|
|
32
|
+
* The provider's delta stream ended without a terminal `turn_complete`.
|
|
33
|
+
* Indicates a misbehaving provider or a connection that dropped mid-flight.
|
|
34
|
+
* Non-terminal deltas seen so far have already been emitted downstream.
|
|
35
|
+
*/
|
|
36
|
+
var IncompleteTurn = class extends Data.TaggedError("IncompleteTurn") {};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AuthFailed, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Timeout, Unavailable, AiError_exports as t };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=AiError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiError.mjs","names":[],"sources":["../../src/domain/AiError.ts"],"sourcesContent":["import { Data, Duration } from \"effect\"\n\nexport type Scope = \"rpm\" | \"tpm\" | \"rpd\" | \"tpd\"\n\nexport class RateLimited extends Data.TaggedError(\"RateLimited\")<{\n provider: string\n retryAfter?: Duration.Duration\n scope?: Scope\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Unavailable extends Data.TaggedError(\"Unavailable\")<{\n provider: string\n retryAfter?: Duration.Duration\n status?: number\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Timeout extends Data.TaggedError(\"Timeout\")<{\n provider: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContentFiltered extends Data.TaggedError(\"ContentFiltered\")<{\n provider: string\n reason?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContextLengthExceeded extends Data.TaggedError(\"ContextLengthExceeded\")<{\n provider: string\n modelLimit?: number\n requested?: number\n raw: unknown\n}> {}\n\nexport class InvalidRequest extends Data.TaggedError(\"InvalidRequest\")<{\n provider: string\n param?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport type AuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class AuthFailed extends Data.TaggedError(\"AuthFailed\")<{\n provider: string\n subtype: AuthSubtype\n raw: unknown\n}> {}\n\nexport class Cancelled extends Data.TaggedError(\"Cancelled\")<{\n provider: string\n}> {}\n\n/**\n * The model errored mid-generation. Distinct from `Unavailable` (transport\n * problem before generation started) and from `IncompleteTurn` (provider\n * stream ended without a terminal event). The provider's own error message,\n * if any, is on `message`.\n */\nexport class GenerationFailed extends Data.TaggedError(\"GenerationFailed\")<{\n provider: string\n code?: string\n message?: string\n requestId?: string\n raw: unknown\n}> {}\n\n/**\n * The provider's delta stream ended without a terminal `turn_complete`.\n * Indicates a misbehaving provider or a connection that dropped mid-flight.\n * Non-terminal deltas seen so far have already been emitted downstream.\n */\nexport class IncompleteTurn extends Data.TaggedError(\"IncompleteTurn\")<{\n raw?: unknown\n}> {}\n\nexport type AiError =\n | RateLimited\n | Unavailable\n | Timeout\n | ContentFiltered\n | ContextLengthExceeded\n | InvalidRequest\n | AuthFailed\n | Cancelled\n | IncompleteTurn\n | GenerationFailed\n"],"mappings":";;;;;;;;;;;;;;;AAIA,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAM7D;AAEH,IAAa,cAAb,cAAiC,KAAK,YAAY,cAAc,CAM7D;AAEH,IAAa,UAAb,cAA6B,KAAK,YAAY,UAAU,CAIrD;AAEH,IAAa,kBAAb,cAAqC,KAAK,YAAY,kBAAkB,CAKrE;AAEH,IAAa,wBAAb,cAA2C,KAAK,YAAY,wBAAwB,CAKjF;AAEH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAKnE;AAIH,IAAa,aAAb,cAAgC,KAAK,YAAY,aAAa,CAI3D;AAEH,IAAa,YAAb,cAA+B,KAAK,YAAY,YAAY,CAEzD;;;;;;;AAQH,IAAa,mBAAb,cAAsC,KAAK,YAAY,mBAAmB,CAMvE;;;;;;AAOH,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAEnE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as isFunctionCall, B as isUrlCitation, C as UrlCitation, D as isContainerFileCitation, E as functionCallOutput, F as isInputText, H as userText, I as isMessage, L as isOutputText, M as isImageBase64Source, N as isImageUrlSource, O as isFileCitation, P as isInputImage, R as isReasoning, S as StopReason, T as assistantText, V as systemText, _ as OutputText, a as FilePath, b as Refusal, c as ImageBase64Source, d as InputImage, f as InputText, g as Message, i as FileCitation, j as isFunctionCallOutput, k as isFilePath, l as ImageSource, m as Item, n as ContainerFileCitation, o as FunctionCall, p as InputTokensDetails, r as ContentBlock, s as FunctionCallOutput, t as Annotation, u as ImageUrlSource, v as OutputTokensDetails, w as Usage, x as Role, y as Reasoning, z as isRefusal } from "../Items-D1C2686t.mjs";
|
|
2
|
+
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, FunctionCall, FunctionCallOutput, ImageBase64Source, ImageSource, ImageUrlSource, InputImage, InputText, InputTokensDetails, Item, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, UrlCitation, Usage, assistantText, functionCallOutput, isContainerFileCitation, isFileCitation, isFilePath, isFunctionCall, isFunctionCallOutput, isImageBase64Source, isImageUrlSource, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isUrlCitation, systemText, userText };
|