@effect-uai/core 0.11.0 → 0.12.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/dist/{Items-BWNu6VGp.d.mts → Items-BKQgqJ8A.d.mts} +21 -8
- package/dist/Items-BKQgqJ8A.d.mts.map +1 -0
- package/dist/{Tool-CXFHCQrT.d.mts → Tool-u5bag8SO.d.mts} +2 -2
- package/dist/{Tool-CXFHCQrT.d.mts.map → Tool-u5bag8SO.d.mts.map} +1 -1
- package/dist/{ToolEvent-nVijCrvm.d.mts → ToolEvent-BBfOdhF_.d.mts} +2 -2
- package/dist/{ToolEvent-nVijCrvm.d.mts.map → ToolEvent-BBfOdhF_.d.mts.map} +1 -1
- package/dist/{ToolResult-CQqKkcDa.d.mts → ToolResult-CRpmkBXR.d.mts} +2 -2
- package/dist/{ToolResult-CQqKkcDa.d.mts.map → ToolResult-CRpmkBXR.d.mts.map} +1 -1
- package/dist/{Toolkit-BYPwwu-j.d.mts → Toolkit-D4mQvhjq.d.mts} +5 -5
- package/dist/{Toolkit-BYPwwu-j.d.mts.map → Toolkit-D4mQvhjq.d.mts.map} +1 -1
- package/dist/browser/BrowserTool.d.mts +1 -1
- package/dist/domain/Items.d.mts +1 -1
- package/dist/domain/Items.mjs +15 -1
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Research.d.mts +1 -1
- package/dist/domain/Turn.d.mts +2 -1
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/language-model/LanguageModel.d.mts +2 -2
- package/dist/observability/Metrics.d.mts +13 -5
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +30 -7
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/observability/Metrics.test.mjs +42 -0
- package/dist/observability/Metrics.test.mjs.map +1 -1
- package/dist/retry/Retry.d.mts +3 -3
- package/dist/retry/Retry.d.mts.map +1 -1
- package/dist/retry/Retry.mjs +30 -1
- package/dist/retry/Retry.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +1 -1
- package/dist/testing/MockSandbox.d.mts +1 -1
- package/dist/tool/Approval.d.mts +3 -3
- package/dist/tool/HistoryCheck.d.mts +2 -2
- package/dist/tool/Tool.d.mts +1 -1
- package/dist/tool/ToolEvent.d.mts +1 -1
- package/dist/tool/ToolResult.d.mts +1 -1
- package/dist/tool/Toolkit.d.mts +1 -1
- package/dist/web-read/WebReadTool.d.mts +1 -1
- package/dist/web-search/WebSearchTool.d.mts +1 -1
- package/package.json +1 -1
- package/src/domain/Items.ts +18 -0
- package/src/observability/Metrics.test.ts +65 -0
- package/src/observability/Metrics.ts +53 -11
- package/src/retry/Retry.ts +44 -3
- package/dist/Items-BWNu6VGp.d.mts.map +0 -1
|
@@ -86,8 +86,8 @@ declare const Annotation: Schema.Union<readonly [Schema.Struct<{
|
|
|
86
86
|
}>]>;
|
|
87
87
|
type Annotation = typeof Annotation.Type;
|
|
88
88
|
declare const isUrlCitation: <I>(input: I) => input is I & {
|
|
89
|
-
readonly url: string;
|
|
90
89
|
readonly type: "url_citation";
|
|
90
|
+
readonly url: string;
|
|
91
91
|
readonly title: string;
|
|
92
92
|
readonly start_index?: number | undefined;
|
|
93
93
|
readonly end_index?: number | undefined;
|
|
@@ -328,11 +328,11 @@ declare const isInputImage: <I>(input: I) => input is I & Schema.Struct.Readonly
|
|
|
328
328
|
readonly source: Schema.Schema<ImageSource>;
|
|
329
329
|
}, "Type">;
|
|
330
330
|
declare const isOutputText: <I>(input: I) => input is I & {
|
|
331
|
-
readonly text: string;
|
|
332
331
|
readonly type: "output_text";
|
|
332
|
+
readonly text: string;
|
|
333
333
|
readonly annotations?: readonly ({
|
|
334
|
-
readonly url: string;
|
|
335
334
|
readonly type: "url_citation";
|
|
335
|
+
readonly url: string;
|
|
336
336
|
readonly title: string;
|
|
337
337
|
readonly start_index?: number | undefined;
|
|
338
338
|
readonly end_index?: number | undefined;
|
|
@@ -367,11 +367,11 @@ declare const isMessage: <I>(input: I) => input is I & {
|
|
|
367
367
|
readonly type: Schema.Literal<"input_image">;
|
|
368
368
|
readonly source: Schema.Schema<ImageSource>;
|
|
369
369
|
}, "Type"> | {
|
|
370
|
-
readonly text: string;
|
|
371
370
|
readonly type: "output_text";
|
|
371
|
+
readonly text: string;
|
|
372
372
|
readonly annotations?: readonly ({
|
|
373
|
-
readonly url: string;
|
|
374
373
|
readonly type: "url_citation";
|
|
374
|
+
readonly url: string;
|
|
375
375
|
readonly title: string;
|
|
376
376
|
readonly start_index?: number | undefined;
|
|
377
377
|
readonly end_index?: number | undefined;
|
|
@@ -400,9 +400,9 @@ declare const isMessage: <I>(input: I) => input is I & {
|
|
|
400
400
|
readonly providerData?: unknown;
|
|
401
401
|
};
|
|
402
402
|
declare const isToolCall: <I>(input: I) => input is I & {
|
|
403
|
-
readonly name: string;
|
|
404
403
|
readonly type: "function_call";
|
|
405
404
|
readonly call_id: string;
|
|
405
|
+
readonly name: string;
|
|
406
406
|
readonly arguments: string;
|
|
407
407
|
readonly providerData?: unknown;
|
|
408
408
|
};
|
|
@@ -414,13 +414,25 @@ declare const isToolCallOutput: <I>(input: I) => input is I & {
|
|
|
414
414
|
};
|
|
415
415
|
declare const isReasoning: <I>(input: I) => input is I & {
|
|
416
416
|
readonly type: "reasoning";
|
|
417
|
-
readonly providerData?: unknown;
|
|
418
417
|
readonly id?: string | undefined;
|
|
418
|
+
readonly providerData?: unknown;
|
|
419
419
|
readonly summary?: string | undefined;
|
|
420
420
|
readonly signature?: string | undefined;
|
|
421
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* Prompt-cache token breakdown. `cached_tokens` is cache reads;
|
|
424
|
+
* `cache_write_tokens` is tokens written to the cache this turn (billed at a
|
|
425
|
+
* premium). Field names mirror the OpenAI Responses usage shape.
|
|
426
|
+
*
|
|
427
|
+
* Whether these are a subset of `input_tokens` or a separate bucket is
|
|
428
|
+
* provider-specific: OpenAI counts cache reads inside `input_tokens`, while
|
|
429
|
+
* Anthropic reports `input_tokens` as post-breakpoint tokens only, with reads
|
|
430
|
+
* and writes as separate additive buckets. Read a provider's usage in its own
|
|
431
|
+
* terms; do not assume one relationship holds everywhere.
|
|
432
|
+
*/
|
|
422
433
|
declare const InputTokensDetails: Schema.Struct<{
|
|
423
434
|
readonly cached_tokens: Schema.optional<Schema.Number>;
|
|
435
|
+
readonly cache_write_tokens: Schema.optional<Schema.Number>;
|
|
424
436
|
}>;
|
|
425
437
|
type InputTokensDetails = typeof InputTokensDetails.Type;
|
|
426
438
|
declare const OutputTokensDetails: Schema.Struct<{
|
|
@@ -433,6 +445,7 @@ declare const Usage: Schema.Struct<{
|
|
|
433
445
|
readonly total_tokens: Schema.optional<Schema.Number>;
|
|
434
446
|
readonly input_tokens_details: Schema.optional<Schema.Struct<{
|
|
435
447
|
readonly cached_tokens: Schema.optional<Schema.Number>;
|
|
448
|
+
readonly cache_write_tokens: Schema.optional<Schema.Number>;
|
|
436
449
|
}>>;
|
|
437
450
|
readonly output_tokens_details: Schema.optional<Schema.Struct<{
|
|
438
451
|
readonly reasoning_tokens: Schema.optional<Schema.Number>;
|
|
@@ -447,4 +460,4 @@ declare const assistantText: (text: string) => Message;
|
|
|
447
460
|
declare const toolCallOutput: (call_id: string, output: string) => ToolCallOutput;
|
|
448
461
|
//#endregion
|
|
449
462
|
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 };
|
|
450
|
-
//# sourceMappingURL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ToolCall, y as ToolCallOutput } from "./Items-BKQgqJ8A.mjs";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
4
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -314,4 +314,4 @@ declare const decodeArgs: <Input>(tool: DecodableTool<Input>, call: ToolCall) =>
|
|
|
314
314
|
declare const execute: <Name extends string, Input, Event, Output, E, R>(tool: Tool<Name, Input, Event, Output, E, R>, call: ToolCall) => Effect.Effect<ToolCallOutput, E | ToolError | ToolValidationError, R>;
|
|
315
315
|
//#endregion
|
|
316
316
|
export { providerToolsOf as A, fromEffectSchema as C, make as D, isProviderTool as E, toDescriptors as M, withName as N, noInput as O, withRun as P, fail as S, interaction as T, Tool_d_exports as _, Emit as a, descriptorsOf as b, SignalTool as c, ToolE as d, ToolError as f, ToolValidationError as g, ToolR as h, DecodeResult as i, signal as j, provider as k, Tool as l, ToolInputSchema as m, AnyTool as n, InteractionTool as o, ToolFailed as p, DecodableTool as r, ProviderTool as s, AnyLocalTool as t, ToolDescriptor as u, decodeArgs as v, fromStandardSchema as w, execute as x, decodeCallInput as y };
|
|
317
|
-
//# sourceMappingURL=Tool-
|
|
317
|
+
//# sourceMappingURL=Tool-u5bag8SO.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool-
|
|
1
|
+
{"version":3,"file":"Tool-u5bag8SO.d.mts","names":[],"sources":["../src/tool/Tool.ts"],"mappings":";;;;;;;;;cAEkE,cAAA;;;;;;cAIrD,SAAA,SAAkB,cAAA;AAAA,cAQ3B,wBAAA;;;;;;;;;;;;;;cAkBS,mBAAA,SAA4B,wBAAA;AAAA,cAMpC,eAAA;;;;;;;;;;;;;cAWQ,UAAA,SAAmB,eAAA;AA/CkC;;;;;AAAA,cA2DrD,IAAA,GACX,OAAA,UACA,OAAA;EAAA,SAAqB,IAAA;AAAA,MACpB,MAAA,CAAO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EAAA,EAAI,EAAA;;cAG5B,cAAA,GAAkB,IAAA,EAAM,OAAA,KAAU,IAAA,IAAQ,YAAA;;;AAnPvD;;;cA2Pa,eAAA,GACX,OAAA,GAAU,QAAA,CAAS,MAAA,SAAe,OAAA,OACjC,aAAA,CAAc,YAAA;;;;;;;cASJ,aAAA,GAAiB,KAAA,EAAO,aAAA,CAAc,OAAA,MAAW,aAAA,CAAc,cAAA;;;;;;;;cAqB/D,aAAA,GACX,OAAA,GAAU,QAAA,CAAS,MAAA,SAAe,OAAA,OACjC,aAAA,CAAc,cAAA;;;;;;KAQL,YAAA;EAAA,SACG,IAAA;EAAA,SAAqB,KAAA,EAAO,KAAA;AAAA;EAAA,SAC5B,IAAA;AAAA;EAAA,SACA,IAAA;EAAA,SAA0B,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;;;;;cAWnE,eAAA,UACX,IAAA,EAAM,aAAA,CAAc,KAAA,GACpB,IAAA,EAAM,QAAA,KACL,MAAA,CAAO,MAAA,CAAO,YAAA,CAAa,KAAA;;;;;AA3R9B;;;;;cA4Ta,UAAA,UACX,IAAA,EAAM,aAAA,CAAc,KAAA,GACpB,IAAA,EAAM,QAAA,KACL,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,SAAA,GAAY,mBAAA;;;;;;;cA4BvB,OAAA,oDACX,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,CAAA,EAAG,CAAA,GAC1C,IAAA,EAAM,QAAA,KACL,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB,CAAA,GAAI,SAAA,GAAY,mBAAA,EAAqB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ToolResult } from "./ToolResult-
|
|
1
|
+
import { t as ToolResult } from "./ToolResult-CRpmkBXR.mjs";
|
|
2
2
|
import { Data } from "effect";
|
|
3
3
|
import * as _$effect_Unify0 from "effect/Unify";
|
|
4
4
|
|
|
@@ -148,4 +148,4 @@ declare const isOutput: (u: unknown) => u is {
|
|
|
148
148
|
};
|
|
149
149
|
//#endregion
|
|
150
150
|
export { isProgress as a, isOutput as i, ToolEvent_d_exports as n, isApprovalRequested as r, ToolEvent as t };
|
|
151
|
-
//# sourceMappingURL=ToolEvent-
|
|
151
|
+
//# sourceMappingURL=ToolEvent-BBfOdhF_.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolEvent-
|
|
1
|
+
{"version":3,"file":"ToolEvent-BBfOdhF_.d.mts","names":[],"sources":["../src/tool/ToolEvent.ts"],"mappings":";;;;;;;;KAkBY,SAAA,GAAY,IAAA,CAAK,UAAA;EAC3B,iBAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,SAAA;EAAA;EAEX,QAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,IAAA;EAAA;EAEX,MAAA;IAAA,SACW,MAAA,EAAQ,UAAA;EAAA;AAAA;;;;;;;;cAWR,SAAA;EAAA;;;;;;;;;;;;;;qBAXQ,UAAA;EAAA;EAAA;;;;;;;;;;;;;;;;qBAAA,UAAA;EAAA;IAAA;;;;;;;;;;;;;;;;;;yBAAA,UAAA;MAAA;IAAA;;;;;;;;;;;;uBAAA,UAAA;IAAA;;;;;;;;;;;;;;;;yBAAA,UAAA;MAAA;IAAA;;;;;;;;;;;;uBAAA,UAAA;IAAA;;;cAaR,mBAAA,GAAmB,CAAA,cAAA,CAAA;EAAA;;;;;cACnB,UAAA,GAAU,CAAA,cAAA,CAAA;EAAA;;;;;cACV,QAAA,GAAQ,CAAA,cAAA,CAAA;EAAA;mBAfA,UAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as ToolCall, y as ToolCallOutput } from "./Items-
|
|
1
|
+
import { v as ToolCall, y as ToolCallOutput } from "./Items-BKQgqJ8A.mjs";
|
|
2
2
|
import { Data } from "effect";
|
|
3
3
|
import * as _$effect_Unify0 from "effect/Unify";
|
|
4
4
|
|
|
@@ -154,4 +154,4 @@ declare const serializeValue: (value: unknown) => string;
|
|
|
154
154
|
declare const toToolCallOutput: (r: ToolResult) => ToolCallOutput;
|
|
155
155
|
//#endregion
|
|
156
156
|
export { executionError as a, isOk as c, toToolCallOutput as d, validationError as f, denied as i, nonLocalTool as l, ToolResult_d_exports as n, failed as o, cancelled as r, isFailure as s, ToolResult as t, serializeValue as u };
|
|
157
|
-
//# sourceMappingURL=ToolResult-
|
|
157
|
+
//# sourceMappingURL=ToolResult-CRpmkBXR.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolResult-
|
|
1
|
+
{"version":3,"file":"ToolResult-CRpmkBXR.d.mts","names":[],"sources":["../src/tool/ToolResult.ts"],"mappings":";;;;;;;;KAqBY,UAAA,GAAa,IAAA,CAAK,UAAA;EAC5B,EAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,KAAA;EAAA;EAEX,OAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,IAAA;IAAA,SACA,MAAA;EAAA;AAAA;;;;;;;;;cAYA,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEA,IAAA,GAAI,CAAA,cAAA,CAAA;EAAA;;;;;cACJ,SAAA,GAAS,CAAA,cAAA,CAAA;EAAA;;;;;;cAMT,MAAA,GAAU,IAAA,EAAM,QAAA,EAAU,IAAA,UAAc,MAAA,cAAkB,UAAA;;cAS1D,MAAA,GAAU,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;cAI5C,SAAA,GAAa,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;cAI/C,cAAA,GAAkB,IAAA,EAAM,QAAA,EAAU,MAAA,aAAiB,UAAA;;;;;;;cASnD,YAAA,GAAgB,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;;;;;cAYlD,eAAA,GAAmB,IAAA,EAAM,QAAA,EAAU,MAAA,cAAkB,UAAA;;AA7ClE;;;;cAyDa,cAAA,GAAkB,KAAA;AAAA,cAOlB,gBAAA,GAAoB,CAAA,EAAG,UAAA,KAAa,cAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { o as HistoryItem, v as ToolCall } from "./Items-
|
|
2
|
-
import { a as Emit, c as SignalTool, d as ToolE, h as ToolR, l as Tool, n as AnyTool, o as InteractionTool, p as ToolFailed, s as ProviderTool, u as ToolDescriptor } from "./Tool-
|
|
1
|
+
import { o as HistoryItem, v as ToolCall } from "./Items-BKQgqJ8A.mjs";
|
|
2
|
+
import { a as Emit, c as SignalTool, d as ToolE, h as ToolR, l as Tool, n as AnyTool, o as InteractionTool, p as ToolFailed, s as ProviderTool, u as ToolDescriptor } from "./Tool-u5bag8SO.mjs";
|
|
3
3
|
import { Turn } from "./domain/Turn.mjs";
|
|
4
4
|
import { r as Step } from "./Loop-D8nWpowc.mjs";
|
|
5
|
-
import { t as ToolResult } from "./ToolResult-
|
|
6
|
-
import { t as ToolEvent } from "./ToolEvent-
|
|
5
|
+
import { t as ToolResult } from "./ToolResult-CRpmkBXR.mjs";
|
|
6
|
+
import { t as ToolEvent } from "./ToolEvent-BBfOdhF_.mjs";
|
|
7
7
|
import { Cause, Effect, Stream } from "effect";
|
|
8
8
|
import * as _$effect_Types0 from "effect/Types";
|
|
9
9
|
|
|
@@ -193,4 +193,4 @@ declare const continueWithResults: {
|
|
|
193
193
|
};
|
|
194
194
|
//#endregion
|
|
195
195
|
export { wrap as S, fromArray as _, ToolMap as a, namespace as b, ToolkitR as c, appendToolResults as d, collectResults as f, descriptors as g, describeFailures as h, NoDuplicateNames as i, Toolkit_d_exports as l, continueWithResults as m, ExecuteOptions as n, Toolkit as o, compose as p, Middleware as r, ToolkitE as s, DuplicateToolName as t, UniqueTools as u, make as v, run as x, makeNamespaced as y };
|
|
196
|
-
//# sourceMappingURL=Toolkit-
|
|
196
|
+
//# sourceMappingURL=Toolkit-D4mQvhjq.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolkit-
|
|
1
|
+
{"version":3,"file":"Toolkit-D4mQvhjq.d.mts","names":[],"sources":["../src/tool/Toolkit.ts"],"mappings":";;;;;;;;;;;;;KAqDY,OAAA,GAAU,MAAA,SAAe,OAAA;AAAA,KAEzB,OAAA,eAAsB,OAAA,GAAU,OAAA,IAAW,KAAA;AAAA,cAgB1C,IAAA,uBAA4B,aAAA,CAAc,OAAA,MAClD,KAAA,EAAO,WAAA,CAAY,KAAA,MACrB,OAAA,SAAgB,KAAA,YAAiB,CAAA,WAAY,CAAA;;;;;;;cAQnC,SAAA,GAAa,KAAA,EAAO,aAAA,CAAc,OAAA,MAAW,OAAA;;cAG7C,WAAA,GAAe,OAAA,EAAS,OAAA,KAAU,aAAA,CAAc,cAAA;;;;;;;;;;KAYjD,QAAA,WAAmB,OAAA,IAAW,OAAA,SAAgB,CAAA,WAAY,KAAA,CAAM,CAAA,OAAQ,CAAA;;;;;;AA3CpF;;KAoDY,QAAA,WAAmB,OAAA,IAAW,OAAA,SAAgB,CAAA,WAAY,KAAA,CAAM,CAAA,OAAQ,CAAA;AAAA,KAY/E,aAAA,eACW,aAAA,CAAc,OAAA,kCAE1B,KAAA,sCACiB,OAAA,wBACG,aAAA,CAAc,OAAA,KAElC,IAAA,iBAAqB,IAAA,GACnB,IAAA,WACA,aAAA,CAAc,IAAA,EAAM,IAAA,GAAO,IAAA;AAAA,KAG5B,kBAAA;EAAA,SACM,OAAA,0BAAiC,IAAA;AAAA;AAAA,KAGhC,gBAAA,eAA+B,aAAA,CAAc,OAAA,MACvD,aAAA,CAAc,KAAA,+BAGZ,kBAAA,CAAmB,aAAA,CAAc,KAAA;;KAGzB,WAAA,eAA0B,aAAA,CAAc,OAAA,KAAY,KAAA,GAAQ,g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AA,EAAW,OAAA,CAAQ,QAAA,CAAS,CAAA,YAAa,UAAA,GAAa,QAAA,CAAS,CAAA;;;;;;;;;;;;;cA2InE,iBAAA;EAAA,SACW,OAAA,EAAS,aAAA,CAAc,WAAA;AAAA,GAAgB,KAAA,EAAO,CAAA,EAAG,IAAA,EAAM,IAAA,MAC5E,OAAA,EAAS,aAAA,CAAc,UAAA,MAAc,CAAA;;;;;;;;;;;;cAc3B,cAAA,SACX,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG,CAAA,MACnC,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,UAAA,GAAa,CAAA,EAAG,CAAA;;;;AApaV;;;;;;;;;AAOrC;;;;cAoba,mBAAA;EAAA,IAET,KAAA,GAAQ,OAAA,EAAS,aAAA,CAAc,UAAA,MAAgB,CAAA,UACvC,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG,CAAA,MAAO,MAAA,CAAO,MAAA,CAAO,IAAA,CAAU,SAAA,EAAW,CAAA,GAAI,CAAA,EAAG,CAAA;EAAA,UAE7F,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG,CAAA,GACpC,KAAA,GAAQ,OAAA,EAAS,aAAA,CAAc,UAAA,MAAgB,CAAA,GAC9C,MAAA,CAAO,MAAA,CAAO,IAAA,CAAU,SAAA,EAAW,CAAA,GAAI,CAAA,EAAG,CAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BrowserError } from "./BrowserError.mjs";
|
|
2
2
|
import { BrowserSession } from "./Browser.mjs";
|
|
3
|
-
import { l as Tool } from "../Tool-
|
|
3
|
+
import { l as Tool } from "../Tool-u5bag8SO.mjs";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/browser/BrowserTool.d.ts
|
package/dist/domain/Items.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-BKQgqJ8A.mjs";
|
|
2
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
|
@@ -173,7 +173,21 @@ const isMessage = Schema.is(Message);
|
|
|
173
173
|
const isToolCall = Schema.is(ToolCall);
|
|
174
174
|
const isToolCallOutput = Schema.is(ToolCallOutput);
|
|
175
175
|
const isReasoning = Schema.is(Reasoning);
|
|
176
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Prompt-cache token breakdown. `cached_tokens` is cache reads;
|
|
178
|
+
* `cache_write_tokens` is tokens written to the cache this turn (billed at a
|
|
179
|
+
* premium). Field names mirror the OpenAI Responses usage shape.
|
|
180
|
+
*
|
|
181
|
+
* Whether these are a subset of `input_tokens` or a separate bucket is
|
|
182
|
+
* provider-specific: OpenAI counts cache reads inside `input_tokens`, while
|
|
183
|
+
* Anthropic reports `input_tokens` as post-breakpoint tokens only, with reads
|
|
184
|
+
* and writes as separate additive buckets. Read a provider's usage in its own
|
|
185
|
+
* terms; do not assume one relationship holds everywhere.
|
|
186
|
+
*/
|
|
187
|
+
const InputTokensDetails = Schema.Struct({
|
|
188
|
+
cached_tokens: Schema.optional(Schema.Number),
|
|
189
|
+
cache_write_tokens: Schema.optional(Schema.Number)
|
|
190
|
+
});
|
|
177
191
|
const OutputTokensDetails = Schema.Struct({ reasoning_tokens: Schema.optional(Schema.Number) });
|
|
178
192
|
const Usage = Schema.Struct({
|
|
179
193
|
input_tokens: Schema.optional(Schema.Number),
|
|
@@ -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// Provider-agnostic: each provider populates the fields it has (character\n// span, quote, or positional marker) and omits the rest.\n// ---------------------------------------------------------------------------\n\n/**\n * A cited source. `url` + `title` are the only near-universal fields; the\n * link from a source to the answer text varies by provider, so it is optional\n * and expressed three ways: `start_index`/`end_index` (a character span into\n * the answer), `cited_text` (an exact quote of the source, when no offsets are\n * given), or `marker` (a positional `[n]` reference into an ordered list). A\n * provider populates whichever it has; a bare source list sets none.\n */\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n title: Schema.String,\n start_index: Schema.optional(Schema.Number),\n end_index: Schema.optional(Schema.Number),\n cited_text: Schema.optional(Schema.String),\n marker: Schema.optional(Schema.Number),\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;;;;;;;;;AAiBF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,aAAa,OAAO,SAAS,OAAO,OAAO;CAC3C,WAAW,OAAO,SAAS,OAAO,OAAO;CACzC,YAAY,OAAO,SAAS,OAAO,OAAO;CAC1C,QAAQ,OAAO,SAAS,OAAO,OAAO;CACvC,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,MAAa,a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AAG,QAAQ;AAE3C,MAAa,YAAY,OAAO,GAAG,QAAQ;AAC3C,MAAa,aAAa,OAAO,GAAG,SAAS;AAC7C,MAAa,mBAAmB,OAAO,GAAG,eAAe;AACzD,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,kBAAkB,SAAiB,YAAoC;CAClF,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// Provider-agnostic: each provider populates the fields it has (character\n// span, quote, or positional marker) and omits the rest.\n// ---------------------------------------------------------------------------\n\n/**\n * A cited source. `url` + `title` are the only near-universal fields; the\n * link from a source to the answer text varies by provider, so it is optional\n * and expressed three ways: `start_index`/`end_index` (a character span into\n * the answer), `cited_text` (an exact quote of the source, when no offsets are\n * given), or `marker` (a positional `[n]` reference into an ordered list). A\n * provider populates whichever it has; a bare source list sets none.\n */\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n title: Schema.String,\n start_index: Schema.optional(Schema.Number),\n end_index: Schema.optional(Schema.Number),\n cited_text: Schema.optional(Schema.String),\n marker: Schema.optional(Schema.Number),\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// The slot is shared, so a provider keys its data under its own name\n// (`{ responses: ... }`, `{ gemini: ... }`) and reads only that key. One item\n// can pass through several providers - falling back from one to another\n// leaves both keys on it - and a provider that finds no key of its own must\n// encode the item normally rather than assume the slot is its own.\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\n/**\n * Prompt-cache token breakdown. `cached_tokens` is cache reads;\n * `cache_write_tokens` is tokens written to the cache this turn (billed at a\n * premium). Field names mirror the OpenAI Responses usage shape.\n *\n * Whether these are a subset of `input_tokens` or a separate bucket is\n * provider-specific: OpenAI counts cache reads inside `input_tokens`, while\n * Anthropic reports `input_tokens` as post-breakpoint tokens only, with reads\n * and writes as separate additive buckets. Read a provider's usage in its own\n * terms; do not assume one relationship holds everywhere.\n */\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n cache_write_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;;;;;;;;;AAiBF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK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,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,kBAAkB,SAAiB,YAAoC;CAClF,MAAM;CACN;CACA;CACD"}
|
package/dist/domain/Turn.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as ImageSource } from "../Image-C4vuBmu0.mjs";
|
|
2
|
-
import { d as Message, m as Reasoning, o as HistoryItem, t as Annotation, v as ToolCall, x as Usage, y as ToolCallOutput } from "../Items-
|
|
2
|
+
import { d as Message, m as Reasoning, o as HistoryItem, t as Annotation, v as ToolCall, x as Usage, y as ToolCallOutput } from "../Items-BKQgqJ8A.mjs";
|
|
3
3
|
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-DHaUJBdd.mjs";
|
|
4
4
|
import { Data, Effect, Schema, Stream } from "effect";
|
|
5
5
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
@@ -80,6 +80,7 @@ declare const Turn: Schema.Struct<{
|
|
|
80
80
|
readonly total_tokens: Schema.optional<Schema.Number>;
|
|
81
81
|
readonly input_tokens_details: Schema.optional<Schema.Struct<{
|
|
82
82
|
readonly cached_tokens: Schema.optional<Schema.Number>;
|
|
83
|
+
readonly cache_write_tokens: Schema.optional<Schema.Number>;
|
|
83
84
|
}>>;
|
|
84
85
|
readonly output_tokens_details: Schema.optional<Schema.Struct<{
|
|
85
86
|
readonly reasoning_tokens: Schema.optional<Schema.Number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Turn.d.mts","names":[],"sources":["../../src/domain/Turn.ts"],"mappings":";;;;;;;;;;;;;;;;;cAsBa,IAAA,EAAI,MAAA,CAAA,MAAA;EAAA
|
|
1
|
+
{"version":3,"file":"Turn.d.mts","names":[],"sources":["../../src/domain/Turn.ts"],"mappings":";;;;;;;;;;;;;;;;;cAsBa,IAAA,EAAI,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKL,IAAA,UAAc,IAAA,CAAK,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BnB,SAAA,GAAY,IAAA,CAAK,UAAA;EAC3B,SAAA;IAAA,SAAsB,IAAA;EAAA;EACtB,cAAA;IAAA,SAA2B,IAAA;IAAA,SAAuB,IAAA;EAAA;EAClD,YAAA;IAAA,SAAyB,IAAA;EAAA;EACzB,aAAA;IAAA,SAA0B,OAAA;IAAA,SAA0B,IAAA;EAAA;EACpD,iBAAA;IAAA,SAA8B,OAAA;IAAA,SAA0B,KAAA;EAAA;EACxD,WAAA;IAAA,SAAwB,KAAA,EAAO,KAAA;EAAA;EAC/B,aAAA;IAAA,SACW,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA;EAEX,aAAA;IAAA,SAA0B,UAAA,EAAY,UAAA;EAAA;EACtC,YAAA;IAAA,SAAyB,IAAA,EAAM,IAAA;EAAA;AAAA;AAAA,cAGpB,SAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;oBAVoB,KAAA;EAAA;EAAA;;;;;;;;yBAMO,UAAA;EAAA;EAAA;;mBACP,IAAA;EAAA;EAAA;;;;;;;;;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X,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG,CAAA,MACjC,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA;AAAA,cAGzB,oBAAA;;;;;;;;cAWU,eAAA,SAAwB,oBAAA;EAAA,SAC1B,IAAA,EAAM,IAAA;AAAA;;;;;;;;;;;cAyBJ,gBAAA,MACX,IAAA,EAAM,IAAA,EACN,MAAA,EAAQ,gBAAA,CAAkC,CAAA,MACzC,MAAA,CAAO,MAAA,CACR,CAAA,EACA,eAAA,GAAkB,cAAA,GAAkC,qBAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { t as BrowserError_d_exports } from "./browser/BrowserError.mjs";
|
|
|
2
2
|
import { t as Browser_d_exports } from "./browser/Browser.mjs";
|
|
3
3
|
import { a as Media_d_exports } from "./Media-D_CpcM1Z.mjs";
|
|
4
4
|
import { o as Image_d_exports } from "./Image-C4vuBmu0.mjs";
|
|
5
|
-
import { u as Items_d_exports } from "./Items-
|
|
6
|
-
import { _ as Tool_d_exports } from "./Tool-
|
|
5
|
+
import { u as Items_d_exports } from "./Items-BKQgqJ8A.mjs";
|
|
6
|
+
import { _ as Tool_d_exports } from "./Tool-u5bag8SO.mjs";
|
|
7
7
|
import { t as BrowserTool_d_exports } from "./browser/BrowserTool.mjs";
|
|
8
8
|
import { t as Capabilities_d_exports } from "./capabilities/Capabilities.mjs";
|
|
9
9
|
import { n as AiError_d_exports } from "./AiError-Bf1pq4BB.mjs";
|
|
@@ -19,9 +19,9 @@ import { t as Embedding_d_exports } from "./embedding-model/Embedding.mjs";
|
|
|
19
19
|
import { t as EmbeddingModel_d_exports } from "./embedding-model/EmbeddingModel.mjs";
|
|
20
20
|
import { t as DeepResearch_d_exports } from "./research/DeepResearch.mjs";
|
|
21
21
|
import { t as Loop_d_exports } from "./Loop-D8nWpowc.mjs";
|
|
22
|
-
import { n as ToolResult_d_exports } from "./ToolResult-
|
|
23
|
-
import { n as ToolEvent_d_exports } from "./ToolEvent-
|
|
24
|
-
import { l as Toolkit_d_exports } from "./Toolkit-
|
|
22
|
+
import { n as ToolResult_d_exports } from "./ToolResult-CRpmkBXR.mjs";
|
|
23
|
+
import { n as ToolEvent_d_exports } from "./ToolEvent-BBfOdhF_.mjs";
|
|
24
|
+
import { l as Toolkit_d_exports } from "./Toolkit-D4mQvhjq.mjs";
|
|
25
25
|
import { t as LanguageModel_d_exports } from "./language-model/LanguageModel.mjs";
|
|
26
26
|
import { t as MusicGenerator_d_exports } from "./music-generator/MusicGenerator.mjs";
|
|
27
27
|
import { t as Memory_d_exports } from "./sandbox/Memory.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as HistoryItem } from "../Items-
|
|
1
|
+
import { o as HistoryItem } from "../Items-BKQgqJ8A.mjs";
|
|
2
2
|
import { t as AiError } from "../AiError-Bf1pq4BB.mjs";
|
|
3
3
|
import { i as StructuredFormat } from "../StructuredFormat-DHaUJBdd.mjs";
|
|
4
4
|
import { Turn, TurnEvent } from "../domain/Turn.mjs";
|
|
5
|
-
import { o as Toolkit } from "../Toolkit-
|
|
5
|
+
import { o as Toolkit } from "../Toolkit-D4mQvhjq.mjs";
|
|
6
6
|
import { Context, Effect, Stream } from "effect";
|
|
7
7
|
|
|
8
8
|
//#region src/language-model/LanguageModel.d.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { x as Usage } from "../Items-
|
|
1
|
+
import { x as Usage } from "../Items-BKQgqJ8A.mjs";
|
|
2
2
|
import { TurnEvent } from "../domain/Turn.mjs";
|
|
3
3
|
import { Duration, Effect, Option, Stream } from "effect";
|
|
4
4
|
|
|
5
5
|
//#region src/observability/Metrics.d.ts
|
|
6
6
|
declare namespace Metrics_d_exports {
|
|
7
|
-
export { AllMetricsOptions, Measurement, MetricEvent, MetricEventTypeId, RateState, Throughput, ThroughputOptions, TimeToCompletion, TimeToFirstToken, TimeToFirstTokenOptions, TokenTotals, allMetrics, computeThroughputTick, isMetricEvent, makeEvent, metricEvents, throughput, timeToCompletion, timeToFirstToken, tokenTotals };
|
|
7
|
+
export { AllMetricsOptions, Measurement, MetricEvent, MetricEventTypeId, OutputDelta, RateState, Throughput, ThroughputOptions, TimeToCompletion, TimeToFirstToken, TimeToFirstTokenOptions, TokenTotals, allMetrics, computeThroughputTick, isMetricEvent, makeEvent, metricEvents, throughput, timeToCompletion, timeToFirstToken, tokenTotals };
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* The instrument-agnostic description of a single recorded value. The
|
|
@@ -77,6 +77,10 @@ declare const isMetricEvent: (u: unknown) => u is MetricEvent;
|
|
|
77
77
|
* channel or a frontend feed.
|
|
78
78
|
*/
|
|
79
79
|
declare const metricEvents: <A, E, R>(self: Stream.Stream<A, E, R>) => Stream.Stream<MetricEvent, E, R>;
|
|
80
|
+
/** A delta carrying generated output, whatever the model was producing. */
|
|
81
|
+
type OutputDelta = Extract<TurnEvent, {
|
|
82
|
+
readonly _tag: "TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallArgsDelta";
|
|
83
|
+
}>;
|
|
80
84
|
type TimeToFirstTokenOptions = {
|
|
81
85
|
/**
|
|
82
86
|
* Where the clock starts. `"request"` (default) anchors at stream
|
|
@@ -91,8 +95,12 @@ declare const timeToCompletion: <A, E, R>(self: Stream.Stream<A, E, R>) => Strea
|
|
|
91
95
|
declare const tokenTotals: <A, E, R>(self: Stream.Stream<A, E, R>) => Stream.Stream<A | MetricEvent, E, R>;
|
|
92
96
|
type ThroughputOptions = {
|
|
93
97
|
/** Tick interval. Default `"1 second"`. */readonly every?: Duration.Input; /** What a "unit" is. Default `"char"` (exact and chunking-independent). */
|
|
94
|
-
readonly unit?: "char" | "token" | "event";
|
|
95
|
-
|
|
98
|
+
readonly unit?: "char" | "token" | "event";
|
|
99
|
+
/**
|
|
100
|
+
* Token counter for `unit: "token"`. Called only for deltas that carry
|
|
101
|
+
* generated output. Absent => approximate 1 per such delta.
|
|
102
|
+
*/
|
|
103
|
+
readonly tokenizer?: (event: OutputDelta) => Effect.Effect<number>; /** Rate definition. Default `"windowed"` (current speed, no cold-start bias). */
|
|
96
104
|
readonly mode?: "windowed" | "cumulative"; /** EWMA smoothing. Omitted => off; `"default"` => a sensible factor. */
|
|
97
105
|
readonly smooth?: "default" | number;
|
|
98
106
|
};
|
|
@@ -129,5 +137,5 @@ type AllMetricsOptions = {
|
|
|
129
137
|
};
|
|
130
138
|
declare const allMetrics: (options?: AllMetricsOptions) => <A, E, R>(self: Stream.Stream<A, E, R>) => Stream.Stream<A | MetricEvent, E, R>;
|
|
131
139
|
//#endregion
|
|
132
|
-
export { AllMetricsOptions, Measurement, MetricEvent, MetricEventTypeId, RateState, Throughput, ThroughputOptions, TimeToCompletion, TimeToFirstToken, TimeToFirstTokenOptions, TokenTotals, allMetrics, computeThroughputTick, isMetricEvent, makeEvent, metricEvents, Metrics_d_exports as t, throughput, timeToCompletion, timeToFirstToken, tokenTotals };
|
|
140
|
+
export { AllMetricsOptions, Measurement, MetricEvent, MetricEventTypeId, OutputDelta, RateState, Throughput, ThroughputOptions, TimeToCompletion, TimeToFirstToken, TimeToFirstTokenOptions, TokenTotals, allMetrics, computeThroughputTick, isMetricEvent, makeEvent, metricEvents, Metrics_d_exports as t, throughput, timeToCompletion, timeToFirstToken, tokenTotals };
|
|
133
141
|
//# sourceMappingURL=Metrics.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metrics.d.mts","names":[],"sources":["../../src/observability/Metrics.ts"],"mappings":";;;;;;;;;;;;;;KA0BY,WAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA,WAAgB,QAAA,CAAS,QAAA;EAAA,SACzB,UAAA,GAAa,QAAA,CAAS,MAAA;AAAA;;;;;;;cAapB,iBAAA;;;;;;KASD,WAAA;EAAA,UACA,iBAAA,UAA2B,iBAAA;EAAA,SAC5B,IAAA;
|
|
1
|
+
{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AA,EAAM,SAAA;AAAA;AAAA,cAiDJ,UAAA,GACV,OAAA,GAAU,iBAAA,eACD,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,MAAA,CAAO,CAAA,GAAI,WAAA,EAAa,CAAA,EAAG,CAAA;AAAA,KA4DjE,iBAAA;EAAA,SACD,gBAAA,GAAmB,uBAAA;EAAA,SACnB,UAAA,GAAa,iBAAA;AAAA;AAAA,cAGX,UAAA,GACV,OAAA,GAAU,iBAAA,eACD,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,MAAA,CAAO,CAAA,GAAI,WAAA,EAAa,CAAA,EAAG,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
+
import { TurnEvent } from "../domain/Turn.mjs";
|
|
2
3
|
import { Array, Clock, Duration, Effect, Match, Option, Predicate, Ref, Result, Schedule, Stream } from "effect";
|
|
3
4
|
//#region src/observability/Metrics.ts
|
|
4
5
|
var Metrics_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -45,7 +46,8 @@ const MetricName = {
|
|
|
45
46
|
outputTokens: "effect_uai_output_tokens",
|
|
46
47
|
totalTokens: "effect_uai_total_tokens",
|
|
47
48
|
reasoningTokens: "effect_uai_reasoning_tokens",
|
|
48
|
-
cachedInputTokens: "effect_uai_cached_input_tokens"
|
|
49
|
+
cachedInputTokens: "effect_uai_cached_input_tokens",
|
|
50
|
+
cacheWriteTokens: "effect_uai_cache_write_tokens"
|
|
49
51
|
};
|
|
50
52
|
/** Read a structural `_tag` off any value without narrowing to a closed union. */
|
|
51
53
|
const tagOf = (u) => Predicate.hasProperty(u, "_tag") && Predicate.isString(u._tag) ? u._tag : void 0;
|
|
@@ -53,17 +55,36 @@ const contentDeltaKind = (ev) => {
|
|
|
53
55
|
const t = tagOf(ev);
|
|
54
56
|
return t === "TextDelta" ? Option.some("text") : t === "ReasoningDelta" ? Option.some("reasoning") : Option.none();
|
|
55
57
|
};
|
|
58
|
+
const isTextDelta = TurnEvent.$is("TextDelta");
|
|
59
|
+
const isReasoningDelta = TurnEvent.$is("ReasoningDelta");
|
|
60
|
+
const isRefusalDelta = TurnEvent.$is("RefusalDelta");
|
|
61
|
+
const isToolCallArgsDelta = TurnEvent.$is("ToolCallArgsDelta");
|
|
62
|
+
/**
|
|
63
|
+
* Narrow to a delta that contributes to the model's output stream. Tool-call
|
|
64
|
+
* arguments count: an agent turn can be almost entirely `ToolCallArgsDelta`,
|
|
65
|
+
* and measuring only prose reports a near-zero rate for it.
|
|
66
|
+
*
|
|
67
|
+
* The single place the output-delta tag list lives — the throughput
|
|
68
|
+
* accumulator and `unitCount` both read it. Distinct from `contentDeltaKind`,
|
|
69
|
+
* which answers a narrower question for first-token latency.
|
|
70
|
+
*/
|
|
71
|
+
const outputDelta = (ev) => isTextDelta(ev) || isReasoningDelta(ev) || isRefusalDelta(ev) || isToolCallArgsDelta(ev) ? Option.some(ev) : Option.none();
|
|
72
|
+
const outputTextOf = (delta) => isToolCallArgsDelta(delta) ? delta.delta : delta.text;
|
|
56
73
|
const isTurnCompleteEvent = (ev) => tagOf(ev) === "TurnComplete";
|
|
57
74
|
const turnOf = (ev) => ev.turn;
|
|
58
75
|
const sumOptional = (a, b) => a === void 0 && b === void 0 ? void 0 : (a ?? 0) + (b ?? 0);
|
|
59
76
|
const addUsage = (a, b) => {
|
|
60
77
|
const cached = sumOptional(a.input_tokens_details?.cached_tokens, b.input_tokens_details?.cached_tokens);
|
|
78
|
+
const cacheWrite = sumOptional(a.input_tokens_details?.cache_write_tokens, b.input_tokens_details?.cache_write_tokens);
|
|
61
79
|
const reasoning = sumOptional(a.output_tokens_details?.reasoning_tokens, b.output_tokens_details?.reasoning_tokens);
|
|
62
80
|
return {
|
|
63
81
|
input_tokens: sumOptional(a.input_tokens, b.input_tokens),
|
|
64
82
|
output_tokens: sumOptional(a.output_tokens, b.output_tokens),
|
|
65
83
|
total_tokens: sumOptional(a.total_tokens, b.total_tokens),
|
|
66
|
-
input_tokens_details: cached === void 0 ? void 0 : {
|
|
84
|
+
input_tokens_details: cached === void 0 && cacheWrite === void 0 ? void 0 : {
|
|
85
|
+
...cached !== void 0 && { cached_tokens: cached },
|
|
86
|
+
...cacheWrite !== void 0 && { cache_write_tokens: cacheWrite }
|
|
87
|
+
},
|
|
67
88
|
output_tokens_details: reasoning === void 0 ? void 0 : { reasoning_tokens: reasoning }
|
|
68
89
|
};
|
|
69
90
|
};
|
|
@@ -74,7 +95,8 @@ const usageMeasurements = (usage) => {
|
|
|
74
95
|
[MetricName.outputTokens, usage.output_tokens],
|
|
75
96
|
[MetricName.totalTokens, usage.total_tokens],
|
|
76
97
|
[MetricName.reasoningTokens, usage.output_tokens_details?.reasoning_tokens],
|
|
77
|
-
[MetricName.cachedInputTokens, usage.input_tokens_details?.cached_tokens]
|
|
98
|
+
[MetricName.cachedInputTokens, usage.input_tokens_details?.cached_tokens],
|
|
99
|
+
[MetricName.cacheWriteTokens, usage.input_tokens_details?.cache_write_tokens]
|
|
78
100
|
];
|
|
79
101
|
return Array.filterMap(pairs, ([name, value]) => value === void 0 ? Result.failVoid : Result.succeed({
|
|
80
102
|
name,
|
|
@@ -225,9 +247,10 @@ const resetTurn = (state) => ({
|
|
|
225
247
|
turnIndex: state.turnIndex + 1
|
|
226
248
|
});
|
|
227
249
|
const unitCount = (ev, unit, tokenizer) => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
250
|
+
const output = outputDelta(ev);
|
|
251
|
+
if (Option.isNone(output)) return Effect.succeed(0);
|
|
252
|
+
const delta = output.value;
|
|
253
|
+
return Match.value(unit).pipe(Match.when("char", () => Effect.succeed([...outputTextOf(delta)].length)), Match.when("event", () => Effect.succeed(1)), Match.when("token", () => tokenizer === void 0 ? Effect.succeed(1) : tokenizer(delta)), Match.exhaustive);
|
|
231
254
|
};
|
|
232
255
|
const throughputName = (unit) => `effect_uai_output_${unit}s_per_second`;
|
|
233
256
|
const throughput = (options) => (self) => {
|
|
@@ -238,7 +261,7 @@ const throughput = (options) => (self) => {
|
|
|
238
261
|
const tokenizer = options?.tokenizer;
|
|
239
262
|
const name = throughputName(unit);
|
|
240
263
|
return Stream.unwrap(Effect.map(Ref.make(initRateState), (ref) => {
|
|
241
|
-
const source = self.pipe(Stream.tap((ev) => isTurnCompleteEvent(ev) ? Ref.update(ref, resetTurn) :
|
|
264
|
+
const source = self.pipe(Stream.tap((ev) => isTurnCompleteEvent(ev) ? Ref.update(ref, resetTurn) : Option.isSome(outputDelta(ev)) ? Effect.flatMap(Clock.currentTimeMillis, (now) => Effect.flatMap(unitCount(ev, unit, tokenizer), (n) => Ref.update(ref, (state) => addUnits(state, n, now)))) : Effect.void));
|
|
242
265
|
const metronome = Stream.fromSchedule(Schedule.spaced(every)).pipe(Stream.mapEffect(() => Effect.flatMap(Clock.currentTimeMillis, (now) => Ref.modify(ref, (state) => Option.match(computeThroughputTick(state, now, mode, smooth), {
|
|
243
266
|
onNone: () => [Option.none(), state],
|
|
244
267
|
onSome: ({ next, rate, window }) => [Option.some(makeEvent({
|