@effect-uai/core 0.5.2 → 0.6.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/README.md +1 -1
- package/dist/{Items-BH8xUkoR.d.mts → Items-pXR5BAgW.d.mts} +12 -12
- package/dist/Items-pXR5BAgW.d.mts.map +1 -0
- package/dist/SandboxError-BvKypkJm.d.mts +158 -0
- package/dist/SandboxError-BvKypkJm.d.mts.map +1 -0
- package/dist/{Tool-87ViKCCO.d.mts → Tool-DP-AwKOf.d.mts} +11 -11
- package/dist/{Tool-87ViKCCO.d.mts.map → Tool-DP-AwKOf.d.mts.map} +1 -1
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +15 -15
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Turn.d.mts +388 -2
- package/dist/domain/Turn.d.mts.map +1 -0
- package/dist/domain/Turn.mjs +13 -13
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/index.d.mts +11 -6
- package/dist/index.mjs +8 -3
- package/dist/language-model/LanguageModel.d.mts +5 -5
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +37 -90
- package/dist/loop/Loop.d.mts.map +1 -1
- package/dist/loop/Loop.mjs +39 -93
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +46 -54
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/sandbox/Memory.d.mts +53 -0
- package/dist/sandbox/Memory.d.mts.map +1 -0
- package/dist/sandbox/Memory.mjs +68 -0
- package/dist/sandbox/Memory.mjs.map +1 -0
- package/dist/sandbox/Sandbox.d.mts +717 -0
- package/dist/sandbox/Sandbox.d.mts.map +1 -0
- package/dist/sandbox/Sandbox.mjs +192 -0
- package/dist/sandbox/Sandbox.mjs.map +1 -0
- package/dist/sandbox/SandboxError.d.mts +2 -0
- package/dist/sandbox/SandboxError.mjs +89 -0
- package/dist/sandbox/SandboxError.mjs.map +1 -0
- package/dist/sandbox/SandboxImage.d.mts +28 -0
- package/dist/sandbox/SandboxImage.d.mts.map +1 -0
- package/dist/sandbox/SandboxImage.mjs +32 -0
- package/dist/sandbox/SandboxImage.mjs.map +1 -0
- package/dist/sandbox/SandboxNetwork.d.mts +34 -0
- package/dist/sandbox/SandboxNetwork.d.mts.map +1 -0
- package/dist/sandbox/SandboxNetwork.mjs +36 -0
- package/dist/sandbox/SandboxNetwork.mjs.map +1 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +98 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +32 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +56 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +3 -3
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSandbox.d.mts +604 -0
- package/dist/testing/MockSandbox.d.mts.map +1 -0
- package/dist/testing/MockSandbox.mjs +160 -0
- package/dist/testing/MockSandbox.mjs.map +1 -0
- package/dist/testing/MockSpeechSynthesizer.d.mts +26 -11
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.mjs +75 -51
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
- package/dist/tool/{Resolvers.d.mts → Approval.d.mts} +27 -27
- package/dist/tool/Approval.d.mts.map +1 -0
- package/dist/tool/{Resolvers.mjs → Approval.mjs} +18 -18
- package/dist/tool/Approval.mjs.map +1 -0
- package/dist/tool/{Resolvers.test.mjs → Approval.test.mjs} +40 -40
- package/dist/tool/Approval.test.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +6 -6
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +5 -5
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +4 -4
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +19 -19
- package/dist/tool/ToolEvent.d.mts.map +1 -1
- package/dist/tool/ToolEvent.mjs +8 -8
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/{Outcome.d.mts → ToolResult.d.mts} +29 -29
- package/dist/tool/ToolResult.d.mts.map +1 -0
- package/dist/tool/ToolResult.mjs +61 -0
- package/dist/tool/ToolResult.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +58 -26
- package/dist/tool/Toolkit.d.mts.map +1 -1
- package/dist/tool/Toolkit.mjs +62 -34
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +13 -13
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/package.json +31 -7
- package/src/domain/Items.ts +9 -9
- package/src/domain/Turn.ts +16 -16
- package/src/index.ts +7 -2
- package/src/language-model/LanguageModel.ts +3 -3
- package/src/loop/Loop.test.ts +93 -91
- package/src/loop/Loop.ts +72 -170
- package/src/sandbox/Memory.ts +128 -0
- package/src/sandbox/Sandbox.ts +639 -0
- package/src/sandbox/SandboxError.ts +140 -0
- package/src/sandbox/SandboxImage.ts +26 -0
- package/src/sandbox/SandboxNetwork.ts +34 -0
- package/src/speech-synthesizer/SpeechSynthesizer.test.ts +89 -0
- package/src/speech-synthesizer/SpeechSynthesizer.ts +124 -0
- package/src/testing/MockProvider.ts +21 -20
- package/src/testing/MockSandbox.ts +342 -0
- package/src/testing/MockSpeechSynthesizer.ts +137 -77
- package/src/tool/{Resolvers.test.ts → Approval.test.ts} +45 -54
- package/src/tool/{Resolvers.ts → Approval.ts} +25 -25
- package/src/tool/HistoryCheck.ts +10 -13
- package/src/tool/Tool.ts +13 -15
- package/src/tool/ToolEvent.ts +7 -7
- package/src/tool/{Outcome.ts → ToolResult.ts} +20 -20
- package/src/tool/Toolkit.test.ts +13 -13
- package/src/tool/Toolkit.ts +97 -73
- package/dist/Items-BH8xUkoR.d.mts.map +0 -1
- package/dist/Turn-0CwCAyVe.d.mts +0 -388
- package/dist/Turn-0CwCAyVe.d.mts.map +0 -1
- package/dist/tool/Outcome.d.mts.map +0 -1
- package/dist/tool/Outcome.mjs +0 -61
- package/dist/tool/Outcome.mjs.map +0 -1
- package/dist/tool/Resolvers.d.mts.map +0 -1
- package/dist/tool/Resolvers.mjs.map +0 -1
- package/dist/tool/Resolvers.test.mjs.map +0 -1
- /package/dist/tool/{Resolvers.test.d.mts → Approval.test.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This package exposes:
|
|
|
10
10
|
|
|
11
11
|
- **Domain types** - `Items`, `Turn`, `AiError`
|
|
12
12
|
- **Provider contract** - `LanguageModel`
|
|
13
|
-
- **Loop primitive** - `Loop` (`loop`, `loopWithState`, `value`, `next`, `stop`, `nextAfter`, `
|
|
13
|
+
- **Loop primitive** - `Loop` (`loop`, `loopWithState`, `value`, `next`, `stop`, `nextAfter`, `emitValues`, `emitNext`, `onTurnComplete`)
|
|
14
14
|
- **Tools** - `Tool`, `Toolkit`, `Outcome`, `ToolEvent`, `Resolvers`, `HistoryCheck`
|
|
15
15
|
- **Streaming codecs** - `SSE`, `JSONL`, `Lines`
|
|
16
16
|
- **Structured output** - `StructuredFormat`
|
|
@@ -3,7 +3,7 @@ import { Schema } from "effect";
|
|
|
3
3
|
|
|
4
4
|
//#region src/domain/Items.d.ts
|
|
5
5
|
declare namespace Items_d_exports {
|
|
6
|
-
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath,
|
|
6
|
+
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, toolCallOutput, userText };
|
|
7
7
|
}
|
|
8
8
|
declare const InputText: Schema.Struct<{
|
|
9
9
|
readonly type: Schema.Literal<"input_text">;
|
|
@@ -211,21 +211,21 @@ declare const Message: Schema.Struct<{
|
|
|
211
211
|
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
212
212
|
}>;
|
|
213
213
|
type Message = typeof Message.Type;
|
|
214
|
-
declare const
|
|
214
|
+
declare const ToolCall: Schema.Struct<{
|
|
215
215
|
readonly type: Schema.Literal<"function_call">;
|
|
216
216
|
readonly call_id: Schema.String;
|
|
217
217
|
readonly name: Schema.String;
|
|
218
218
|
readonly arguments: Schema.String;
|
|
219
219
|
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
220
220
|
}>;
|
|
221
|
-
type
|
|
222
|
-
declare const
|
|
221
|
+
type ToolCall = typeof ToolCall.Type;
|
|
222
|
+
declare const ToolCallOutput: Schema.Struct<{
|
|
223
223
|
readonly type: Schema.Literal<"function_call_output">;
|
|
224
224
|
readonly call_id: Schema.String;
|
|
225
225
|
readonly output: Schema.String;
|
|
226
226
|
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
227
227
|
}>;
|
|
228
|
-
type
|
|
228
|
+
type ToolCallOutput = typeof ToolCallOutput.Type;
|
|
229
229
|
/**
|
|
230
230
|
* Reasoning item - top-level, mirrors OpenAI Responses API. Common shape
|
|
231
231
|
* across providers covers `summary` (human-readable text) and `signature`
|
|
@@ -240,7 +240,7 @@ declare const Reasoning: Schema.Struct<{
|
|
|
240
240
|
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
241
241
|
}>;
|
|
242
242
|
type Reasoning = typeof Reasoning.Type;
|
|
243
|
-
declare const
|
|
243
|
+
declare const HistoryItem: Schema.Union<readonly [Schema.Struct<{
|
|
244
244
|
readonly type: Schema.Literal<"message">;
|
|
245
245
|
readonly role: Schema.Literals<readonly ["user", "assistant", "system"]>;
|
|
246
246
|
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -296,7 +296,7 @@ declare const Item: Schema.Union<readonly [Schema.Struct<{
|
|
|
296
296
|
readonly signature: Schema.optional<Schema.String>;
|
|
297
297
|
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
298
298
|
}>]>;
|
|
299
|
-
type
|
|
299
|
+
type HistoryItem = typeof HistoryItem.Type;
|
|
300
300
|
declare const isInputText: <I>(input: I) => input is I & {
|
|
301
301
|
readonly type: "input_text";
|
|
302
302
|
readonly text: string;
|
|
@@ -373,14 +373,14 @@ declare const isMessage: <I>(input: I) => input is I & {
|
|
|
373
373
|
readonly role: "user" | "assistant" | "system";
|
|
374
374
|
readonly providerData?: unknown;
|
|
375
375
|
};
|
|
376
|
-
declare const
|
|
376
|
+
declare const isToolCall: <I>(input: I) => input is I & {
|
|
377
377
|
readonly type: "function_call";
|
|
378
378
|
readonly call_id: string;
|
|
379
379
|
readonly name: string;
|
|
380
380
|
readonly arguments: string;
|
|
381
381
|
readonly providerData?: unknown;
|
|
382
382
|
};
|
|
383
|
-
declare const
|
|
383
|
+
declare const isToolCallOutput: <I>(input: I) => input is I & {
|
|
384
384
|
readonly type: "function_call_output";
|
|
385
385
|
readonly call_id: string;
|
|
386
386
|
readonly output: string;
|
|
@@ -418,7 +418,7 @@ type StopReason = typeof StopReason.Type;
|
|
|
418
418
|
declare const userText: (text: string) => Message;
|
|
419
419
|
declare const systemText: (text: string) => Message;
|
|
420
420
|
declare const assistantText: (text: string) => Message;
|
|
421
|
-
declare const
|
|
421
|
+
declare const toolCallOutput: (call_id: string, output: string) => ToolCallOutput;
|
|
422
422
|
//#endregion
|
|
423
|
-
export {
|
|
424
|
-
//# sourceMappingURL=Items-
|
|
423
|
+
export { isReasoning as A, isContainerFileCitation as C, isInputText as D, isInputImage as E, systemText as F, toolCallOutput as I, userText as L, isToolCall as M, isToolCallOutput as N, isMessage as O, isUrlCitation as P, assistantText as S, isFilePath as T, StopReason as _, FilePath as a, UrlCitation as b, InputText as c, Message as d, OutputText as f, Role as g, Refusal as h, FileCitation as i, isRefusal as j, isOutputText as k, InputTokensDetails as l, Reasoning as m, ContainerFileCitation as n, HistoryItem as o, OutputTokensDetails as p, ContentBlock as r, InputImage as s, Annotation as t, Items_d_exports as u, ToolCall as v, isFileCitation as w, Usage as x, ToolCallOutput as y };
|
|
424
|
+
//# sourceMappingURL=Items-pXR5BAgW.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Items-pXR5BAgW.d.mts","names":[],"sources":["../src/domain/Items.ts"],"mappings":";;;;;;;cAOa,SAAA,EAAS,MAAA,CAAA,MAAA;EAAA;;;KAIV,SAAA,UAAmB,SAAA,CAAU,IAAA;;;;;;;;;cAU5B,UAAA,EAAU,MAAA,CAAA,MAAA;EAAA;;;KAIX,UAAA,UAAoB,UAAA,CAAW,IAAA;AAAA,cAQ9B,WAAA,EAAW,MAAA,CAAA,MAAA;EAAA;;;;;;KAOZ,WAAA,UAAqB,WAAA,CAAY,IAAA;AAAA,cAEhC,YAAA,EAAY,MAAA,CAAA,MAAA;EAAA;;;;KAKb,YAAA,UAAsB,YAAA,CAAa,IAAA;AAAA,cAElC,qBAAA,EAAqB,MAAA,CAAA,MAAA;EAAA;;;;;;KAOtB,qBAAA,UAA+B,qBAAA,CAAsB,IAAA;AAAA,cAEpD,QAAA,EAAQ,MAAA,CAAA,MAAA;EAAA;;;;KAKT,QAAA,UAAkB,QAAA,CAAS,IAAA;AAAA,cAE1B,UAAA,EAAU,MAAA,CAAA,KAAA,WAAA,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;;KACX,UAAA,UAAoB,UAAA,CAAW,IAAA;AAAA,cAE9B,aAAA,MAAa,KAAA,EAAA,CAAA,KAAA,KAAA,IAAA,CA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
|
1
|
+
import { Duration } from "effect";
|
|
2
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
3
|
+
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
|
+
|
|
5
|
+
//#region src/sandbox/SandboxError.d.ts
|
|
6
|
+
declare namespace SandboxError_d_exports {
|
|
7
|
+
export { SandboxAlreadyExists, SandboxAuthFailed, SandboxAuthSubtype, SandboxCreateFailed, SandboxError, SandboxExecFailed, SandboxInvalidRequest, SandboxNetworkPolicyDenied, SandboxNotFound, SandboxQuotaExceeded, SandboxTimeout, SandboxUnsupported };
|
|
8
|
+
}
|
|
9
|
+
declare const SandboxCreateFailed_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 & {
|
|
10
|
+
readonly _tag: "SandboxCreateFailed";
|
|
11
|
+
} & Readonly<A>;
|
|
12
|
+
/**
|
|
13
|
+
* Failed to provision a sandbox. Covers image pull failures, region
|
|
14
|
+
* unavailability, the provider being unreachable, etc. The provider's
|
|
15
|
+
* structured reason (if any) is on `reason`; the raw error from the
|
|
16
|
+
* underlying SDK is on `raw`.
|
|
17
|
+
*/
|
|
18
|
+
declare class SandboxCreateFailed extends SandboxCreateFailed_base<{
|
|
19
|
+
provider: string;
|
|
20
|
+
reason?: string;
|
|
21
|
+
raw: unknown;
|
|
22
|
+
}> {}
|
|
23
|
+
declare const SandboxNotFound_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 & {
|
|
24
|
+
readonly _tag: "SandboxNotFound";
|
|
25
|
+
} & Readonly<A>;
|
|
26
|
+
/**
|
|
27
|
+
* The requested sandbox id does not exist (or was already destroyed).
|
|
28
|
+
* Distinct from `SandboxCreateFailed` — this is for `attach` / `destroy` /
|
|
29
|
+
* `get`-style lookups against a stale id.
|
|
30
|
+
*/
|
|
31
|
+
declare class SandboxNotFound extends SandboxNotFound_base<{
|
|
32
|
+
provider: string;
|
|
33
|
+
id: string;
|
|
34
|
+
}> {}
|
|
35
|
+
declare const SandboxAlreadyExists_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 & {
|
|
36
|
+
readonly _tag: "SandboxAlreadyExists";
|
|
37
|
+
} & Readonly<A>;
|
|
38
|
+
/**
|
|
39
|
+
* Caller tried to create a sandbox whose id is already taken. Providers
|
|
40
|
+
* that keyed by name (Microsandbox, Modal) surface this when a previous
|
|
41
|
+
* sandbox with the same name is still alive. Distinct from
|
|
42
|
+
* `SandboxCreateFailed` so callers can retry with `replace` semantics.
|
|
43
|
+
*/
|
|
44
|
+
declare class SandboxAlreadyExists extends SandboxAlreadyExists_base<{
|
|
45
|
+
provider: string;
|
|
46
|
+
id: string;
|
|
47
|
+
}> {}
|
|
48
|
+
declare const SandboxExecFailed_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: "SandboxExecFailed";
|
|
50
|
+
} & Readonly<A>;
|
|
51
|
+
/**
|
|
52
|
+
* A shell exec inside the sandbox failed at the transport / SDK layer —
|
|
53
|
+
* i.e. the SDK couldn't deliver the command to the guest, or the guest
|
|
54
|
+
* agent itself errored. A non-zero exit code from the guest's command
|
|
55
|
+
* is NOT an error; it's an `ExecResult` with `exitCode !== 0`.
|
|
56
|
+
*/
|
|
57
|
+
declare class SandboxExecFailed extends SandboxExecFailed_base<{
|
|
58
|
+
provider: string;
|
|
59
|
+
reason?: string;
|
|
60
|
+
raw: unknown;
|
|
61
|
+
}> {}
|
|
62
|
+
declare const SandboxTimeout_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 & {
|
|
63
|
+
readonly _tag: "SandboxTimeout";
|
|
64
|
+
} & Readonly<A>;
|
|
65
|
+
/**
|
|
66
|
+
* A sandbox operation (create, exec, file op) exceeded its time budget.
|
|
67
|
+
* Carries the budget that was breached for observability.
|
|
68
|
+
*/
|
|
69
|
+
declare class SandboxTimeout extends SandboxTimeout_base<{
|
|
70
|
+
provider: string;
|
|
71
|
+
operation: "create" | "exec" | "filesystem" | "attach";
|
|
72
|
+
budget?: Duration.Duration;
|
|
73
|
+
raw?: unknown;
|
|
74
|
+
}> {}
|
|
75
|
+
declare const SandboxNetworkPolicyDenied_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 & {
|
|
76
|
+
readonly _tag: "SandboxNetworkPolicyDenied";
|
|
77
|
+
} & Readonly<A>;
|
|
78
|
+
/**
|
|
79
|
+
* Outbound network request from inside the sandbox was blocked by the
|
|
80
|
+
* configured egress policy (host not on allowlist, CIDR mismatch, etc.).
|
|
81
|
+
* Surfaced when the provider's SDK reports the denial back to the host
|
|
82
|
+
* — many providers simply let the request fail inside the guest and
|
|
83
|
+
* never report this to the host, in which case this error is never
|
|
84
|
+
* raised by the adapter.
|
|
85
|
+
*/
|
|
86
|
+
declare class SandboxNetworkPolicyDenied extends SandboxNetworkPolicyDenied_base<{
|
|
87
|
+
provider: string;
|
|
88
|
+
host?: string;
|
|
89
|
+
reason?: string;
|
|
90
|
+
raw: unknown;
|
|
91
|
+
}> {}
|
|
92
|
+
declare const SandboxQuotaExceeded_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 & {
|
|
93
|
+
readonly _tag: "SandboxQuotaExceeded";
|
|
94
|
+
} & Readonly<A>;
|
|
95
|
+
/**
|
|
96
|
+
* Provider rejected the create / exec because account / org / project
|
|
97
|
+
* quota or concurrency limit was exceeded. Surfaced separately from
|
|
98
|
+
* `SandboxCreateFailed` so callers can back off and retry intelligently.
|
|
99
|
+
*/
|
|
100
|
+
declare class SandboxQuotaExceeded extends SandboxQuotaExceeded_base<{
|
|
101
|
+
provider: string;
|
|
102
|
+
reason?: string;
|
|
103
|
+
raw: unknown;
|
|
104
|
+
}> {}
|
|
105
|
+
declare const SandboxInvalidRequest_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 & {
|
|
106
|
+
readonly _tag: "SandboxInvalidRequest";
|
|
107
|
+
} & Readonly<A>;
|
|
108
|
+
/**
|
|
109
|
+
* Caller's request shape is malformed for the wired provider — e.g. a
|
|
110
|
+
* Dockerfile passed to a provider that only accepts registry refs, a
|
|
111
|
+
* hostname allowlist passed to a CIDR-only provider, etc. Adapters
|
|
112
|
+
* should also reject these at the request-schema layer where possible;
|
|
113
|
+
* this is the runtime fallback.
|
|
114
|
+
*/
|
|
115
|
+
declare class SandboxInvalidRequest extends SandboxInvalidRequest_base<{
|
|
116
|
+
provider: string;
|
|
117
|
+
param?: string;
|
|
118
|
+
reason?: string;
|
|
119
|
+
raw?: unknown;
|
|
120
|
+
}> {}
|
|
121
|
+
/**
|
|
122
|
+
* Sandbox SDK could not authenticate against the provider. Subtype
|
|
123
|
+
* mirrors the model-side `AiError.AuthFailed` shape for consistency.
|
|
124
|
+
*/
|
|
125
|
+
type SandboxAuthSubtype = "auth" | "permission" | "billing" | "quota";
|
|
126
|
+
declare const SandboxAuthFailed_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 & {
|
|
127
|
+
readonly _tag: "SandboxAuthFailed";
|
|
128
|
+
} & Readonly<A>;
|
|
129
|
+
declare class SandboxAuthFailed extends SandboxAuthFailed_base<{
|
|
130
|
+
provider: string;
|
|
131
|
+
subtype: SandboxAuthSubtype;
|
|
132
|
+
raw: unknown;
|
|
133
|
+
}> {}
|
|
134
|
+
declare const SandboxUnsupported_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 & {
|
|
135
|
+
readonly _tag: "SandboxUnsupported";
|
|
136
|
+
} & Readonly<A>;
|
|
137
|
+
/**
|
|
138
|
+
* The wired provider does not implement the requested capability for
|
|
139
|
+
* this specific request. Distinct from `SandboxInvalidRequest` (the
|
|
140
|
+
* request shape is malformed) and from compile-time capability
|
|
141
|
+
* markers (`SandboxSnapshots`, `SandboxSecretInjection`, …) which gate
|
|
142
|
+
* blanket provider-level gaps.
|
|
143
|
+
*
|
|
144
|
+
* Reserved for request-data-dependent gaps where the provider supports
|
|
145
|
+
* the method in general but not for these inputs — e.g. passing
|
|
146
|
+
* `hosts: [...]` to a CIDR-only allowlist provider, or passing
|
|
147
|
+
* `dockerfile: ...` to a provider whose `SandboxCustomImage` marker
|
|
148
|
+
* was provided but which only accepts a flat Dockerfile string.
|
|
149
|
+
*/
|
|
150
|
+
declare class SandboxUnsupported extends SandboxUnsupported_base<{
|
|
151
|
+
provider: string;
|
|
152
|
+
capability: string;
|
|
153
|
+
reason?: string;
|
|
154
|
+
}> {}
|
|
155
|
+
type SandboxError = SandboxCreateFailed | SandboxNotFound | SandboxAlreadyExists | SandboxExecFailed | SandboxTimeout | SandboxNetworkPolicyDenied | SandboxQuotaExceeded | SandboxInvalidRequest | SandboxAuthFailed | SandboxUnsupported;
|
|
156
|
+
//#endregion
|
|
157
|
+
export { SandboxError as a, SandboxInvalidRequest as c, SandboxQuotaExceeded as d, SandboxTimeout as f, SandboxCreateFailed as i, SandboxNetworkPolicyDenied as l, SandboxAuthFailed as n, SandboxError_d_exports as o, SandboxUnsupported as p, SandboxAuthSubtype as r, SandboxExecFailed as s, SandboxAlreadyExists as t, SandboxNotFound as u };
|
|
158
|
+
//# sourceMappingURL=SandboxError-BvKypkJm.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SandboxError-BvKypkJm.d.mts","names":[],"sources":["../src/sandbox/SandboxError.ts"],"mappings":";;;;;;;;cAAuC,wBAAA;;;;;;;;;cAQ1B,mBAAA,SAA4B,wBAAA;EACvC,QAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,oBAAA;;;;AAZkC;;;;cAmB1B,eAAA,SAAwB,oBAAA;EACnC,QAAA;EACA,EAAA;AAAA;AAAA,cACG,yBAAA;;;;;;;;;cAQQ,oBAAA,SAA6B,yBAAA;EACxC,QAAA;EACA,EAAA;AAAA;AAAA,cACG,sBAAA;;;;;;;;AAzBL;cAiCa,iBAAA,SAA0B,sBAAA;EACrC,QAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,mBAAA;;;AAjCA;;;;AAAA,cAuCQ,cAAA,SAAuB,mBAAA;EAClC,QAAA;EACA,SAAA;EACA,MAAA,GAAS,QAAA,CAAS,QAAA;EAClB,GAAA;AAAA;AAAA,cACG,+BAAA;;;;;;;;;;;cAUQ,0BAAA,SAAmC,+BAAA;EAC9C,QAAA;EACA,IAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,yBAAA;;;;;;;;cAOQ,oBAAA,SAA6B,yBAAA;EACxC,QAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,0BAAA;;;;;;;;;;cASQ,qBAAA,SAA8B,0BAAA;EACzC,QAAA;EACA,KAAA;EACA,MAAA;EACA,GAAA;AAAA;;;;;KAOU,kBAAA;AAAA,cAAgE,sBAAA;;;cAE/D,iBAAA,SAA0B,sBAAA;EACrC,QAAA;EACA,OAAA,EAAS,kBAAA;EACT,GAAA;AAAA;AAAA,cACG,uBAAA;;;;;;AA3EA;;;;;;;;;;cA0FQ,kBAAA,SAA2B,uBAAA;EACtC,QAAA;EACA,UAAA;EACA,MAAA;AAAA;AAAA,KAGU,YAAA,GACR,mBAAA,GACA,eAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,GACA,0BAAA,GACA,oBAAA,GACA,qBAAA,GACA,iBAAA,GACA,kBAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as ToolCall, y as ToolCallOutput } from "./Items-pXR5BAgW.mjs";
|
|
2
2
|
import { Effect, Schema, Stream } from "effect";
|
|
3
3
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
4
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/tool/Tool.d.ts
|
|
7
7
|
declare namespace Tool_d_exports {
|
|
8
|
-
export {
|
|
8
|
+
export { AnyPlainTool, AnyStreamingTool, AnyTool, StreamingTool, Tool, ToolDescriptor, ToolError, ToolInputSchema, execute, fromEffectSchema, fromStandardSchema, isStreamingTool, make, streaming, toDescriptors };
|
|
9
9
|
}
|
|
10
10
|
declare const ToolError_base: Schema.Class<ToolError, Schema.TaggedStruct<"ToolError", {
|
|
11
11
|
readonly call_id: Schema.String;
|
|
@@ -62,7 +62,7 @@ type Tool<Name extends string, Input, Output, R = never> = {
|
|
|
62
62
|
/**
|
|
63
63
|
* Provider-agnostic tool descriptor. Each provider maps `inputSchema`
|
|
64
64
|
* to its own wire field (OpenAI → `parameters`, Anthropic →
|
|
65
|
-
* `input_schema`). Built from a `Tool` by `
|
|
65
|
+
* `input_schema`). Built from a `Tool` by `Tool.toDescriptors`.
|
|
66
66
|
*/
|
|
67
67
|
type ToolDescriptor = {
|
|
68
68
|
readonly name: string;
|
|
@@ -83,20 +83,20 @@ type StreamingTool<Name extends string, Input, Event, Output, R = never> = {
|
|
|
83
83
|
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>;
|
|
84
84
|
type AnyStreamingTool<R = any> = StreamingTool<string, any, any, any, R>;
|
|
85
85
|
type AnyPlainTool<R = any> = Tool<string, any, any, R>;
|
|
86
|
-
type
|
|
87
|
-
declare const isStreamingTool: <R>(t:
|
|
86
|
+
type AnyTool<R = any> = AnyStreamingTool<R> | AnyPlainTool<R>;
|
|
87
|
+
declare const isStreamingTool: <R>(t: AnyTool<R>) => t is AnyStreamingTool<R>;
|
|
88
88
|
/**
|
|
89
89
|
* Render any-kind tools (mixed plain and streaming) to provider-agnostic
|
|
90
|
-
* descriptors.
|
|
91
|
-
*
|
|
90
|
+
* descriptors. Accepts the union type so a single list can carry both
|
|
91
|
+
* plain and streaming tools.
|
|
92
92
|
*/
|
|
93
|
-
declare const toDescriptors: <R>(tools: ReadonlyArray<
|
|
93
|
+
declare const toDescriptors: <R>(tools: ReadonlyArray<AnyTool<R>>) => ReadonlyArray<ToolDescriptor>;
|
|
94
94
|
/**
|
|
95
95
|
* Decode and validate the JSON arguments of a function_call against the
|
|
96
96
|
* tool's input schema, run the tool, and serialize the output into a
|
|
97
97
|
* function_call_output item.
|
|
98
98
|
*/
|
|
99
|
-
declare const execute: <Name extends string, Input, Output, R>(tool: Tool<Name, Input, Output, R>, call:
|
|
99
|
+
declare const execute: <Name extends string, Input, Output, R>(tool: Tool<Name, Input, Output, R>, call: ToolCall) => Effect.Effect<ToolCallOutput, ToolError, R>;
|
|
100
100
|
//#endregion
|
|
101
|
-
export { Tool as a, ToolInputSchema as c, fromEffectSchema as d, fromStandardSchema as f, toDescriptors as g, streaming as h, StreamingTool as i, Tool_d_exports as l, make as m,
|
|
102
|
-
//# sourceMappingURL=Tool-
|
|
101
|
+
export { Tool as a, ToolInputSchema as c, fromEffectSchema as d, fromStandardSchema as f, toDescriptors as g, streaming as h, StreamingTool as i, Tool_d_exports as l, make as m, AnyStreamingTool as n, ToolDescriptor as o, isStreamingTool as p, AnyTool as r, ToolError as s, AnyPlainTool as t, execute as u };
|
|
102
|
+
//# sourceMappingURL=Tool-DP-AwKOf.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool-
|
|
1
|
+
{"version":3,"file":"Tool-DP-AwKOf.d.mts","names":[],"sources":["../src/tool/Tool.ts"],"mappings":";;;;;;;;;cAEkE,cAAA;;;;;;cAGrD,SAAA,SAAkB,cAAA;;;;;;;;;;KAmBnB,eAAA,oBAAmC,gBAAA,UAA0B,KAAA,IACvE,oBAAA,UAA8B,KAAA;;;;AAvBkC;;cA8BrD,gBAAA,aAA8B,MAAA,CAAO,KAAA,wBAChD,MAAA,EAAQ,CAAA,KACP,CAAA,GAAI,eAAA,CAAgB,CAAA;;;;;;;;;;;;;;;;cAmBV,kBAAA,aAAgC,gBAAA,GAAmB,oBAAA,EAC9D,MAAA,EAAQ,CAAA,KACP,CAAA,GAAI,eAAA,CAAgB,gBAAA,CAAiB,WAAA,CAAY,CAAA;AAAA,KAGxC,IAAA;EAAA,SACD,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;;;;;AAhEX;KAwEY,cAAA;EAAA,SACD,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,KAWjB,aAAA;EAAA,SACD,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,YAA4B,aAAA,wBAAqC,CAAA;AAAA,KACjE,YAAA,YAAwB,IAAA,mBAAuB,CAAA;AAAA,KAC/C,OAAA,YAAmB,gBAAA,CAAiB,CAAA,IAAK,YAAA,CAAa,CAAA;AAAA,cAErD,eAAA,MAAsB,CAAA,EAAG,OAAA,CAAQ,CAAA,MAAK,CAAA,IAAK,gBAAA,CAAiB,CAAA;;;;;;cAQ5D,aAAA,MAAoB,KAAA,EAAO,aAAA,CAAc,OAAA,CAAQ,CAAA,OAAM,aAAA,CAAc,cAAA;;;;;;cAkBrE,OAAA,0CACX,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,CAAA,GAChC,IAAA,EAAM,QAAA,KACL,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB,SAAA,EAAW,CAAA"}
|
package/dist/domain/Items.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath,
|
|
1
|
+
import { A as isReasoning, C as isContainerFileCitation, D as isInputText, E as isInputImage, F as systemText, I as toolCallOutput, L as userText, M as isToolCall, N as isToolCallOutput, O as isMessage, P as isUrlCitation, S as assistantText, T as isFilePath, _ as StopReason, a as FilePath, b as UrlCitation, c as InputText, d as Message, f as OutputText, g as Role, h as Refusal, i as FileCitation, j as isRefusal, k as isOutputText, l as InputTokensDetails, m as Reasoning, n as ContainerFileCitation, o as HistoryItem, p as OutputTokensDetails, r as ContentBlock, s as InputImage, t as Annotation, v as ToolCall, w as isFileCitation, x as Usage, y as ToolCallOutput } from "../Items-pXR5BAgW.mjs";
|
|
2
|
+
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, toolCallOutput, userText };
|
package/dist/domain/Items.mjs
CHANGED
|
@@ -8,12 +8,10 @@ var Items_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
8
|
ContentBlock: () => ContentBlock,
|
|
9
9
|
FileCitation: () => FileCitation,
|
|
10
10
|
FilePath: () => FilePath,
|
|
11
|
-
|
|
12
|
-
FunctionCallOutput: () => FunctionCallOutput,
|
|
11
|
+
HistoryItem: () => HistoryItem,
|
|
13
12
|
InputImage: () => InputImage,
|
|
14
13
|
InputText: () => InputText,
|
|
15
14
|
InputTokensDetails: () => InputTokensDetails,
|
|
16
|
-
Item: () => Item,
|
|
17
15
|
Message: () => Message,
|
|
18
16
|
OutputText: () => OutputText,
|
|
19
17
|
OutputTokensDetails: () => OutputTokensDetails,
|
|
@@ -21,23 +19,25 @@ var Items_exports = /* @__PURE__ */ __exportAll({
|
|
|
21
19
|
Refusal: () => Refusal,
|
|
22
20
|
Role: () => Role,
|
|
23
21
|
StopReason: () => StopReason,
|
|
22
|
+
ToolCall: () => ToolCall,
|
|
23
|
+
ToolCallOutput: () => ToolCallOutput,
|
|
24
24
|
UrlCitation: () => UrlCitation,
|
|
25
25
|
Usage: () => Usage,
|
|
26
26
|
assistantText: () => assistantText,
|
|
27
|
-
functionCallOutput: () => functionCallOutput,
|
|
28
27
|
isContainerFileCitation: () => isContainerFileCitation,
|
|
29
28
|
isFileCitation: () => isFileCitation,
|
|
30
29
|
isFilePath: () => isFilePath,
|
|
31
|
-
isFunctionCall: () => isFunctionCall,
|
|
32
|
-
isFunctionCallOutput: () => isFunctionCallOutput,
|
|
33
30
|
isInputImage: () => isInputImage,
|
|
34
31
|
isInputText: () => isInputText,
|
|
35
32
|
isMessage: () => isMessage,
|
|
36
33
|
isOutputText: () => isOutputText,
|
|
37
34
|
isReasoning: () => isReasoning,
|
|
38
35
|
isRefusal: () => isRefusal,
|
|
36
|
+
isToolCall: () => isToolCall,
|
|
37
|
+
isToolCallOutput: () => isToolCallOutput,
|
|
39
38
|
isUrlCitation: () => isUrlCitation,
|
|
40
39
|
systemText: () => systemText,
|
|
40
|
+
toolCallOutput: () => toolCallOutput,
|
|
41
41
|
userText: () => userText
|
|
42
42
|
});
|
|
43
43
|
const InputText = Schema.Struct({
|
|
@@ -123,14 +123,14 @@ const Message = Schema.Struct({
|
|
|
123
123
|
content: Schema.Array(ContentBlock),
|
|
124
124
|
providerData: ProviderData
|
|
125
125
|
});
|
|
126
|
-
const
|
|
126
|
+
const ToolCall = Schema.Struct({
|
|
127
127
|
type: Schema.Literal("function_call"),
|
|
128
128
|
call_id: Schema.String,
|
|
129
129
|
name: Schema.String,
|
|
130
130
|
arguments: Schema.String,
|
|
131
131
|
providerData: ProviderData
|
|
132
132
|
});
|
|
133
|
-
const
|
|
133
|
+
const ToolCallOutput = Schema.Struct({
|
|
134
134
|
type: Schema.Literal("function_call_output"),
|
|
135
135
|
call_id: Schema.String,
|
|
136
136
|
output: Schema.String,
|
|
@@ -149,10 +149,10 @@ const Reasoning = Schema.Struct({
|
|
|
149
149
|
signature: Schema.optional(Schema.String),
|
|
150
150
|
providerData: ProviderData
|
|
151
151
|
});
|
|
152
|
-
const
|
|
152
|
+
const HistoryItem = Schema.Union([
|
|
153
153
|
Message,
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
ToolCall,
|
|
155
|
+
ToolCallOutput,
|
|
156
156
|
Reasoning
|
|
157
157
|
]);
|
|
158
158
|
const isInputText = Schema.is(InputText);
|
|
@@ -160,8 +160,8 @@ const isInputImage = Schema.is(InputImage);
|
|
|
160
160
|
const isOutputText = Schema.is(OutputText);
|
|
161
161
|
const isRefusal = Schema.is(Refusal);
|
|
162
162
|
const isMessage = Schema.is(Message);
|
|
163
|
-
const
|
|
164
|
-
const
|
|
163
|
+
const isToolCall = Schema.is(ToolCall);
|
|
164
|
+
const isToolCallOutput = Schema.is(ToolCallOutput);
|
|
165
165
|
const isReasoning = Schema.is(Reasoning);
|
|
166
166
|
const InputTokensDetails = Schema.Struct({ cached_tokens: Schema.optional(Schema.Number) });
|
|
167
167
|
const OutputTokensDetails = Schema.Struct({ reasoning_tokens: Schema.optional(Schema.Number) });
|
|
@@ -204,12 +204,12 @@ const assistantText = (text) => ({
|
|
|
204
204
|
text
|
|
205
205
|
}]
|
|
206
206
|
});
|
|
207
|
-
const
|
|
207
|
+
const toolCallOutput = (call_id, output) => ({
|
|
208
208
|
type: "function_call_output",
|
|
209
209
|
call_id,
|
|
210
210
|
output
|
|
211
211
|
});
|
|
212
212
|
//#endregion
|
|
213
|
-
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath,
|
|
213
|
+
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, Items_exports as t, toolCallOutput, userText };
|
|
214
214
|
|
|
215
215
|
//# sourceMappingURL=Items.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const FunctionCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCall = typeof FunctionCall.Type\n\nexport const FunctionCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type FunctionCallOutput = typeof FunctionCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const Item = Schema.Union([Message, FunctionCall, FunctionCallOutput, Reasoning])\nexport type Item = typeof Item.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isFunctionCall = Schema.is(FunctionCall)\nexport const isFunctionCallOutput = Schema.is(FunctionCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const functionCallOutput = (call_id: string, output: string): FunctionCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cAAc;CACnC,QAAQ;CACT,CAAC;AASF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO;CACZ,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,gBAAgB;CACrC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,wBAAwB,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,0BAA0B;CAC/C,cAAc,OAAO;CACrB,SAAS,OAAO;CAChB,aAAa,OAAO;CACpB,WAAW,OAAO;CACnB,CAAC;AAGF,MAAa,WAAW,OAAO,OAAO;CACpC,MAAM,OAAO,QAAQ,YAAY;CACjC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,aAAa,OAAO,MAAM;CAAC;CAAa;CAAc;CAAuB;CAAS,CAAC;AAGpG,MAAa,gBAAgB,OAAO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,UAAU;AAC/C,MAAa,eAAe,OAAO,GAAG,WAAW;AACjD,MAAa,eAAe,OAAO,GAAG,WAAW;AACjD,MAAa,YAAY,OAAO,GAAG,QAAQ;AAE3C,MAAa,YAAY,OAAO,GAAG,QAAQ;AAC3C,MAAa,iBAAiB,OAAO,GAAG,aAAa;AACrD,MAAa,uBAAuB,OAAO,GAAG,mBAAmB;AACjE,MAAa,cAAc,OAAO,GAAG,UAAU;AAM/C,MAAa,qBAAqB,OAAO,OAAO,EAC9C,eAAe,OAAO,SAAS,OAAO,OAAO,EAC9C,CAAC;AAGF,MAAa,sBAAsB,OAAO,OAAO,EAC/C,kBAAkB,OAAO,SAAS,OAAO,OAAO,EACjD,CAAC;AAGF,MAAa,QAAQ,OAAO,OAAO;CACjC,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,eAAe,OAAO,SAAS,OAAO,OAAO;CAC7C,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,sBAAsB,OAAO,SAAS,mBAAmB;CACzD,uBAAuB,OAAO,SAAS,oBAAoB;CAC5D,CAAC;AAGF,MAAa,aAAa,OAAO,SAAS;CACxC;CACA;CACA;CACA;CAEA;CAEA;CACD,CAAC;AAOF,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;EAAM,CAAC;CACzC;AAED,MAAa,sBAAsB,SAAiB,YAAwC;CAC1F,MAAM;CACN;CACA;CACD"}
|
|
1
|
+
{"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const ToolCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCall = typeof ToolCall.Type\n\nexport const ToolCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCallOutput = typeof ToolCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const HistoryItem = Schema.Union([Message, ToolCall, ToolCallOutput, Reasoning])\nexport type HistoryItem = typeof HistoryItem.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isToolCall = Schema.is(ToolCall)\nexport const isToolCallOutput = Schema.is(ToolCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const toolCallOutput = (call_id: string, output: string): ToolCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cAAc;CACnC,QAAQ;CACT,CAAC;AASF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO;CACZ,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,gBAAgB;CACrC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,wBAAwB,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,0BAA0B;CAC/C,cAAc,OAAO;CACrB,SAAS,OAAO;CAChB,aAAa,OAAO;CACpB,WAAW,OAAO;CACnB,CAAC;AAGF,MAAa,WAAW,OAAO,OAAO;CACpC,MAAM,OAAO,QAAQ,YAAY;CACjC,SAAS,OAAO;CAChB,OAAO,OAAO;CACf,CAAC;AAGF,MAAa,aAAa,OAAO,MAAM;CAAC;CAAa;CAAc;CAAuB;CAAS,CAAC;AAGpG,MAAa,gBAAgB,OAAO,GAAG,YAAY;AACnD,MAAa,iBAAiB,OAAO,GAAG,aAAa;AACrD,MAAa,0BAA0B,OAAO,GAAG,sBAAsB;AACvE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