@linnlabs/linnkit 0.10.0 → 0.21.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/CHANGELOG.md +156 -1
- package/dist/{agent-invocation-BHcNfrBV.d.cts → agent-invocation-CAlm9qOw.d.cts} +1 -1
- package/dist/{agent-invocation-BznDaXDs.d.ts → agent-invocation-DKoEDLkl.d.ts} +1 -1
- package/dist/{ai-engine.types-vZRnQcJa.d.ts → ai-engine.types-CeLoM624.d.cts} +9 -1
- package/dist/{ai-engine.types-BpeU_XQG.d.cts → ai-engine.types-LqmnfR2W.d.ts} +9 -1
- package/dist/{audit-CtcfART1.d.ts → audit-BuWHoMEr.d.ts} +4 -2
- package/dist/{audit-LeOrm2hX.d.cts → audit-DnzNQzwq.d.cts} +4 -2
- package/dist/cli.cjs +565 -194
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +565 -194
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +590 -26
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.d.cts +84 -7
- package/dist/context-manager.d.ts +84 -7
- package/dist/context-manager.js +590 -26
- package/dist/context-manager.js.map +1 -1
- package/dist/{context-trace-BHKDS-eq.d.cts → context-trace-DrtvKac4.d.cts} +36 -3
- package/dist/{context-trace-CHbqHmyE.d.ts → context-trace-WV1HAZeB.d.ts} +36 -3
- package/dist/contracts.cjs +222 -1
- package/dist/contracts.cjs.map +1 -1
- package/dist/contracts.d.cts +5 -3
- package/dist/contracts.d.ts +5 -3
- package/dist/contracts.js +202 -2
- package/dist/contracts.js.map +1 -1
- package/dist/{defaultGraphExecutor-C2E59v_R.d.cts → defaultGraphExecutor-L1ri3oij.d.cts} +35 -7
- package/dist/{defaultGraphExecutor-B29_qTHy.d.ts → defaultGraphExecutor-QzzdudLQ.d.ts} +35 -7
- package/dist/{index-BAaUP9yU.d.cts → index-BeQO0rx2.d.cts} +328 -263
- package/dist/{index-Cvr23YCl.d.cts → index-CDofGr_4.d.ts} +24 -6
- package/dist/{index-CKQzzZ5Y.d.cts → index-Crl5E4eF.d.cts} +26 -3
- package/dist/{index-C0DAjsdX.d.ts → index-DWGKvssS.d.ts} +2 -2
- package/dist/{index-D0mKxTR5.d.ts → index-X5lYU1Lj.d.ts} +26 -3
- package/dist/{index-DDzuSb0n.d.ts → index-uCNCpJBg.d.cts} +24 -6
- package/dist/{index-BaVpVNi2.d.ts → index-wOZD-p2-.d.ts} +328 -263
- package/dist/{index-BnYCS8Zg.d.cts → index-wXVAHZ0D.d.cts} +2 -2
- package/dist/index.cjs +893 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -14
- package/dist/index.d.ts +17 -14
- package/dist/index.js +893 -312
- package/dist/index.js.map +1 -1
- package/dist/{messages-XthmnHZ3.d.cts → messages-Br5SiLD3.d.cts} +706 -1
- package/dist/{messages-XthmnHZ3.d.ts → messages-Br5SiLD3.d.ts} +706 -1
- package/dist/{ports-s-tSp3sB.d.cts → ports-Dugizzje.d.cts} +4 -0
- package/dist/{ports-DpPTFhSd.d.ts → ports-fhp84x_C.d.ts} +4 -0
- package/dist/ports.d.cts +8 -5
- package/dist/ports.d.ts +8 -5
- package/dist/quickstart.cjs +564 -193
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.d.cts +9 -8
- package/dist/quickstart.d.ts +9 -8
- package/dist/quickstart.js +564 -193
- package/dist/quickstart.js.map +1 -1
- package/dist/{runAgent-C6F-399C.d.ts → runAgent-BmMSju8I.d.ts} +4 -4
- package/dist/{runAgent-ilEj66Ik.d.cts → runAgent-CKgcRSRH.d.cts} +4 -4
- package/dist/{runHandle-BNOqS-Bl.d.cts → runHandle-DH4VmQx6.d.cts} +4 -2
- package/dist/{runHandle-BdLXOFqF.d.ts → runHandle-o3p06Nva.d.ts} +4 -2
- package/dist/runtime-kernel/events.cjs +201 -1
- package/dist/runtime-kernel/events.cjs.map +1 -1
- package/dist/runtime-kernel/events.d.cts +3 -3
- package/dist/runtime-kernel/events.d.ts +3 -3
- package/dist/runtime-kernel/events.js +201 -1
- package/dist/runtime-kernel/events.js.map +1 -1
- package/dist/runtime-kernel.cjs +824 -264
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.d.cts +14 -12
- package/dist/runtime-kernel.d.ts +14 -12
- package/dist/runtime-kernel.js +816 -265
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +847 -264
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.d.cts +14 -12
- package/dist/testkit.d.ts +14 -12
- package/dist/testkit.js +847 -264
- package/dist/testkit.js.map +1 -1
- package/dist/{agentSpec-Du4Iye0q.d.cts → token-accounting-CwpSPg4y.d.cts} +1265 -1
- package/dist/{agentSpec-Du4Iye0q.d.ts → token-accounting-CwpSPg4y.d.ts} +1265 -1
- package/dist/token-calibration-Cxv6dDYF.d.cts +327 -0
- package/dist/token-calibration-Cxv6dDYF.d.ts +327 -0
- package/dist/token-counter-CFfP8PQb.d.cts +26 -0
- package/dist/token-counter-SFyyTeaG.d.ts +26 -0
- package/dist/token-usage-CqwT7-5K.d.cts +133 -0
- package/dist/token-usage-CqwT7-5K.d.ts +133 -0
- package/dist/{tokenizer-DFL4I7-I.d.ts → tokenizer-BFJNCHFX.d.ts} +1 -1
- package/dist/{tokenizer-DH_JXv-H.d.cts → tokenizer-DoGsBE3A.d.cts} +1 -1
- package/docs/README.md +1 -1
- package/docs/integration/README.md +2 -2
- package/docs/integration/agent-registration-guide.md +2 -0
- package/docs/integration/context-engineering.md +53 -1
- package/docs/integration/context-fences.md +12 -0
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as AgentAiEngine } from './audit-
|
|
2
|
-
import { h as AgentSpecContextPolicyInput, f as AgentSpec } from './
|
|
1
|
+
import { A as AgentAiEngine } from './audit-BuWHoMEr.js';
|
|
2
|
+
import { h as AgentSpecContextPolicyInput, f as AgentSpec } from './token-accounting-CwpSPg4y.js';
|
|
3
3
|
import { R as RuntimeEvent } from './todo-Ca8llpRQ.js';
|
|
4
4
|
import { B as BaseTool, T as ToolArgs, O as OpenAIToolSchema, a as ToolExecutionContext } from './toolContracts-f8lzZBNa.js';
|
|
5
|
-
import { T as ToolRuntimeDefinition, a as ToolExecutionResult } from './ports-
|
|
6
|
-
import { R as RunCost$1 } from './runHandle-
|
|
5
|
+
import { T as ToolRuntimeDefinition, a as ToolExecutionResult } from './ports-fhp84x_C.js';
|
|
6
|
+
import { R as RunCost$1 } from './runHandle-o3p06Nva.js';
|
|
7
7
|
|
|
8
8
|
interface DefinedAgent {
|
|
9
9
|
readonly spec: AgentSpec;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as AgentAiEngine } from './audit-
|
|
2
|
-
import { h as AgentSpecContextPolicyInput, f as AgentSpec } from './
|
|
1
|
+
import { A as AgentAiEngine } from './audit-DnzNQzwq.cjs';
|
|
2
|
+
import { h as AgentSpecContextPolicyInput, f as AgentSpec } from './token-accounting-CwpSPg4y.cjs';
|
|
3
3
|
import { R as RuntimeEvent } from './todo-Ca8llpRQ.cjs';
|
|
4
4
|
import { B as BaseTool, T as ToolArgs, O as OpenAIToolSchema, a as ToolExecutionContext } from './toolContracts-Bm3EZ1UM.cjs';
|
|
5
|
-
import { T as ToolRuntimeDefinition, a as ToolExecutionResult } from './ports-
|
|
6
|
-
import { R as RunCost$1 } from './runHandle-
|
|
5
|
+
import { T as ToolRuntimeDefinition, a as ToolExecutionResult } from './ports-Dugizzje.cjs';
|
|
6
|
+
import { R as RunCost$1 } from './runHandle-DH4VmQx6.cjs';
|
|
7
7
|
|
|
8
8
|
interface DefinedAgent {
|
|
9
9
|
readonly spec: AgentSpec;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as AgentSpec } from './
|
|
1
|
+
import { R as RunTokenUsageAggregate, f as AgentSpec } from './token-accounting-CwpSPg4y.cjs';
|
|
2
2
|
import { R as RuntimeEvent } from './todo-Ca8llpRQ.cjs';
|
|
3
|
-
import { b as AuditPort } from './audit-
|
|
3
|
+
import { b as AuditPort } from './audit-DnzNQzwq.cjs';
|
|
4
4
|
import { E as EventEnvelope } from './execution-CAIypb41.cjs';
|
|
5
5
|
|
|
6
6
|
type PersistedEvent = {
|
|
@@ -126,6 +126,8 @@ interface CancelOpts {
|
|
|
126
126
|
interface RunCost {
|
|
127
127
|
tokensInput: number;
|
|
128
128
|
tokensOutput: number;
|
|
129
|
+
tokenUsage?: RunTokenUsageAggregate;
|
|
130
|
+
tokenLedgerEntryIds?: string[];
|
|
129
131
|
totalCostUsd?: number;
|
|
130
132
|
latencyMs?: number;
|
|
131
133
|
childrenTotal?: RunCost;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as AgentSpec } from './
|
|
1
|
+
import { R as RunTokenUsageAggregate, f as AgentSpec } from './token-accounting-CwpSPg4y.js';
|
|
2
2
|
import { R as RuntimeEvent } from './todo-Ca8llpRQ.js';
|
|
3
|
-
import { b as AuditPort } from './audit-
|
|
3
|
+
import { b as AuditPort } from './audit-BuWHoMEr.js';
|
|
4
4
|
import { E as EventEnvelope } from './execution-CAIypb41.js';
|
|
5
5
|
|
|
6
6
|
type PersistedEvent = {
|
|
@@ -126,6 +126,8 @@ interface CancelOpts {
|
|
|
126
126
|
interface RunCost {
|
|
127
127
|
tokensInput: number;
|
|
128
128
|
tokensOutput: number;
|
|
129
|
+
tokenUsage?: RunTokenUsageAggregate;
|
|
130
|
+
tokenLedgerEntryIds?: string[];
|
|
129
131
|
totalCostUsd?: number;
|
|
130
132
|
latencyMs?: number;
|
|
131
133
|
childrenTotal?: RunCost;
|
|
@@ -58,6 +58,12 @@ zod.z.object({
|
|
|
58
58
|
args: zod.z.record(zod.z.unknown()).optional(),
|
|
59
59
|
tool_call_id: zod.z.string()
|
|
60
60
|
});
|
|
61
|
+
var ObservationTruncationMeta = zod.z.object({
|
|
62
|
+
originalChars: zod.z.number().int().nonnegative(),
|
|
63
|
+
previewChars: zod.z.number().int().nonnegative(),
|
|
64
|
+
originalLines: zod.z.number().int().nonnegative().optional(),
|
|
65
|
+
previewLines: zod.z.number().int().nonnegative().optional()
|
|
66
|
+
});
|
|
61
67
|
var ImageInfoMeta = zod.z.object({
|
|
62
68
|
url: zod.z.string().optional(),
|
|
63
69
|
width: zod.z.number().int().positive().optional(),
|
|
@@ -89,6 +95,7 @@ var PersistentMetadata = zod.z.object({
|
|
|
89
95
|
tool_name: zod.z.string().optional(),
|
|
90
96
|
args: zod.z.record(zod.z.unknown()).optional(),
|
|
91
97
|
tool_call_id: zod.z.string().optional(),
|
|
98
|
+
observationTruncation: ObservationTruncationMeta.optional(),
|
|
92
99
|
raw_output: zod.z.string().optional(),
|
|
93
100
|
image_info: ImageInfoMeta.optional(),
|
|
94
101
|
taskType: zod.z.string().optional(),
|
|
@@ -235,7 +242,17 @@ var AgentSpecReasoningRetentionPolicy = zod.z.object({
|
|
|
235
242
|
var AgentSpecTokenEstimationPolicy = zod.z.object({
|
|
236
243
|
encoding: zod.z.string().min(1).optional(),
|
|
237
244
|
avgCharsPerToken: zod.z.number().positive().optional(),
|
|
238
|
-
toolCallOverhead: zod.z.number().int().nonnegative().optional()
|
|
245
|
+
toolCallOverhead: zod.z.number().int().nonnegative().optional(),
|
|
246
|
+
calibration: zod.z.object({
|
|
247
|
+
enabled: zod.z.boolean().optional(),
|
|
248
|
+
minSamples: zod.z.number().int().positive().optional(),
|
|
249
|
+
minCoefficient: zod.z.number().positive().optional(),
|
|
250
|
+
maxCoefficient: zod.z.number().positive().optional()
|
|
251
|
+
}).optional(),
|
|
252
|
+
remoteCount: zod.z.object({
|
|
253
|
+
enabled: zod.z.boolean().optional(),
|
|
254
|
+
failureBehavior: zod.z.enum(["use-local-estimate", "fail-fast"]).optional()
|
|
255
|
+
}).optional()
|
|
239
256
|
});
|
|
240
257
|
var AgentSpecSystemReminderTrigger = zod.z.object({
|
|
241
258
|
kind: zod.z.string().min(1),
|
|
@@ -891,6 +908,189 @@ var createSSEErrorEvent = (id, conversationId, turnId, error, options = {}) => (
|
|
|
891
908
|
error,
|
|
892
909
|
...options
|
|
893
910
|
});
|
|
911
|
+
var TokenCountSource = zod.z.enum([
|
|
912
|
+
"local-estimate",
|
|
913
|
+
"provider-preflight-count",
|
|
914
|
+
"provider-response-usage",
|
|
915
|
+
"host-supplied",
|
|
916
|
+
"test-fixture"
|
|
917
|
+
]);
|
|
918
|
+
var TokenCountConfidence = zod.z.enum([
|
|
919
|
+
"estimate",
|
|
920
|
+
"provider-estimate",
|
|
921
|
+
"actual"
|
|
922
|
+
]);
|
|
923
|
+
var TokenRouteCapabilities = zod.z.object({
|
|
924
|
+
supportsRemoteTokenCount: zod.z.boolean().optional(),
|
|
925
|
+
supportsResponseUsage: zod.z.boolean().optional(),
|
|
926
|
+
supportsImageInput: zod.z.boolean().optional(),
|
|
927
|
+
supportsCachedInputBilling: zod.z.boolean().optional(),
|
|
928
|
+
supportsReasoningTokens: zod.z.boolean().optional()
|
|
929
|
+
});
|
|
930
|
+
var TokenRoute = zod.z.object({
|
|
931
|
+
providerId: zod.z.string().describe("host \u4FA7 provider \u6807\u8BC6\uFF1Aopenai / anthropic / openrouter / siliconflow / zai ..."),
|
|
932
|
+
baseURL: zod.z.string().optional().describe("\u4E2D\u8F6C\u5E73\u53F0\u6216\u79C1\u6709 endpoint\uFF1B\u7528\u4E8E\u533A\u5206\u540C\u540D\u6A21\u578B\u7684\u4E0D\u540C route"),
|
|
933
|
+
modelId: zod.z.string().describe("host \u4FA7\u6A21\u578B id"),
|
|
934
|
+
providerModelId: zod.z.string().optional().describe("provider \u5B9E\u9645\u6A21\u578B\u540D\uFF08\u4E0E host modelId \u53EF\u80FD\u4E0D\u540C\uFF09"),
|
|
935
|
+
capabilities: TokenRouteCapabilities.optional()
|
|
936
|
+
});
|
|
937
|
+
var tokenCount = zod.z.number().int().nonnegative();
|
|
938
|
+
var CanonicalLlmUsage = zod.z.object({
|
|
939
|
+
inputTokens: tokenCount.describe("\u975E\u7F13\u5B58\u666E\u901A\u8F93\u5165 token"),
|
|
940
|
+
outputTokens: tokenCount.describe("\u8F93\u51FA token"),
|
|
941
|
+
reasoningTokens: tokenCount.optional().describe("\u63A8\u7406 token\uFF1Bundefined=\u672A\u5355\u5217\uFF0C0=\u62A5\u544A\u4E3A 0"),
|
|
942
|
+
cacheReadTokens: tokenCount.optional().describe("\u7F13\u5B58\u547D\u4E2D\u8BFB\u53D6 token"),
|
|
943
|
+
cacheWriteTokens: tokenCount.optional().describe("\u7F13\u5B58\u5199\u5165 token"),
|
|
944
|
+
totalTokens: tokenCount.optional().describe("provider \u62A5\u544A\u7684\u603B\u91CF\uFF1B\u53EF\u7F3A\u5931\uFF0C\u4E14\u4E0D\u4FDD\u8BC1\u7B49\u4E8E\u5404\u9879\u4E4B\u548C"),
|
|
945
|
+
source: TokenCountSource,
|
|
946
|
+
confidence: TokenCountConfidence,
|
|
947
|
+
rawUsage: zod.z.unknown().optional().describe("\u539F\u59CB provider usage\uFF0C\u4EC5\u4F9B\u5BA1\u8BA1")
|
|
948
|
+
});
|
|
949
|
+
var tokenCount2 = zod.z.number().int().nonnegative();
|
|
950
|
+
var tokenPrice = zod.z.number().finite().nonnegative();
|
|
951
|
+
zod.z.enum([
|
|
952
|
+
"llm-usage",
|
|
953
|
+
"context-component"
|
|
954
|
+
]);
|
|
955
|
+
var ContextTokenComponentKind = zod.z.enum([
|
|
956
|
+
"system",
|
|
957
|
+
"user",
|
|
958
|
+
"assistant",
|
|
959
|
+
"tool",
|
|
960
|
+
"context-injection",
|
|
961
|
+
"history-summary",
|
|
962
|
+
"working-memory",
|
|
963
|
+
"fence",
|
|
964
|
+
"system-reminder",
|
|
965
|
+
"other"
|
|
966
|
+
]);
|
|
967
|
+
var TokenUsageTotals = zod.z.object({
|
|
968
|
+
inputTokens: tokenCount2,
|
|
969
|
+
outputTokens: tokenCount2,
|
|
970
|
+
reasoningTokens: tokenCount2.optional(),
|
|
971
|
+
cacheReadTokens: tokenCount2.optional(),
|
|
972
|
+
cacheWriteTokens: tokenCount2.optional(),
|
|
973
|
+
totalTokens: tokenCount2.optional(),
|
|
974
|
+
usageCount: zod.z.number().int().nonnegative()
|
|
975
|
+
});
|
|
976
|
+
var ContextTokenComponent = zod.z.object({
|
|
977
|
+
componentId: zod.z.string().min(1),
|
|
978
|
+
kind: ContextTokenComponentKind,
|
|
979
|
+
tokens: tokenCount2,
|
|
980
|
+
source: TokenCountSource,
|
|
981
|
+
confidence: TokenCountConfidence,
|
|
982
|
+
label: zod.z.string().optional(),
|
|
983
|
+
messageId: zod.z.string().optional(),
|
|
984
|
+
role: zod.z.string().optional(),
|
|
985
|
+
action: zod.z.string().optional(),
|
|
986
|
+
kept: zod.z.boolean().optional(),
|
|
987
|
+
truncatedAtExecution: zod.z.boolean().optional(),
|
|
988
|
+
originalTokensEstimate: tokenCount2.optional(),
|
|
989
|
+
droppedTokensEstimate: tokenCount2.optional()
|
|
990
|
+
});
|
|
991
|
+
var TokenLedgerEntryBase = zod.z.object({
|
|
992
|
+
id: zod.z.string().min(1),
|
|
993
|
+
runId: zod.z.string().optional(),
|
|
994
|
+
parentRunId: zod.z.string().optional(),
|
|
995
|
+
conversationId: zod.z.string().optional(),
|
|
996
|
+
turnId: zod.z.string().optional(),
|
|
997
|
+
stepId: zod.z.string().optional(),
|
|
998
|
+
route: TokenRoute.optional(),
|
|
999
|
+
createdAt: zod.z.number().int().nonnegative().optional()
|
|
1000
|
+
});
|
|
1001
|
+
var LlmUsageTokenLedgerEntry = TokenLedgerEntryBase.extend({
|
|
1002
|
+
kind: zod.z.literal("llm-usage"),
|
|
1003
|
+
modelId: zod.z.string().optional(),
|
|
1004
|
+
usage: CanonicalLlmUsage
|
|
1005
|
+
});
|
|
1006
|
+
var ContextComponentTokenLedgerEntry = TokenLedgerEntryBase.extend({
|
|
1007
|
+
kind: zod.z.literal("context-component"),
|
|
1008
|
+
components: zod.z.array(ContextTokenComponent),
|
|
1009
|
+
totalTokens: tokenCount2
|
|
1010
|
+
});
|
|
1011
|
+
zod.z.discriminatedUnion("kind", [
|
|
1012
|
+
LlmUsageTokenLedgerEntry,
|
|
1013
|
+
ContextComponentTokenLedgerEntry
|
|
1014
|
+
]);
|
|
1015
|
+
var TokenLedgerAggregate = zod.z.object({
|
|
1016
|
+
llmUsage: TokenUsageTotals.optional(),
|
|
1017
|
+
contextTokens: tokenCount2,
|
|
1018
|
+
entryCount: zod.z.number().int().nonnegative(),
|
|
1019
|
+
llmCallCount: zod.z.number().int().nonnegative(),
|
|
1020
|
+
contextComponentCount: zod.z.number().int().nonnegative()
|
|
1021
|
+
});
|
|
1022
|
+
zod.z.object({
|
|
1023
|
+
/**
|
|
1024
|
+
* 父 run 自己产生的 usage;子 run 必须放到 children,避免展示或计费时重复相加。
|
|
1025
|
+
*/
|
|
1026
|
+
own: TokenLedgerAggregate,
|
|
1027
|
+
children: TokenLedgerAggregate.optional()
|
|
1028
|
+
});
|
|
1029
|
+
var TokenCostComponent = zod.z.enum([
|
|
1030
|
+
"input",
|
|
1031
|
+
"output",
|
|
1032
|
+
"reasoning",
|
|
1033
|
+
"cacheRead",
|
|
1034
|
+
"cacheWrite"
|
|
1035
|
+
]);
|
|
1036
|
+
zod.z.object({
|
|
1037
|
+
currency: zod.z.string().min(1),
|
|
1038
|
+
unit: zod.z.literal("per_1m_tokens"),
|
|
1039
|
+
input: tokenPrice.optional(),
|
|
1040
|
+
output: tokenPrice.optional(),
|
|
1041
|
+
reasoning: tokenPrice.optional(),
|
|
1042
|
+
cacheRead: tokenPrice.optional(),
|
|
1043
|
+
cacheWrite: tokenPrice.optional()
|
|
1044
|
+
});
|
|
1045
|
+
zod.z.object({
|
|
1046
|
+
status: zod.z.enum(["computed", "unknown"]),
|
|
1047
|
+
currency: zod.z.string().optional(),
|
|
1048
|
+
inputCost: tokenPrice.optional(),
|
|
1049
|
+
outputCost: tokenPrice.optional(),
|
|
1050
|
+
reasoningCost: tokenPrice.optional(),
|
|
1051
|
+
cacheReadCost: tokenPrice.optional(),
|
|
1052
|
+
cacheWriteCost: tokenPrice.optional(),
|
|
1053
|
+
totalCost: tokenPrice.optional(),
|
|
1054
|
+
missingPriceComponents: zod.z.array(TokenCostComponent).optional()
|
|
1055
|
+
});
|
|
1056
|
+
var tokenCount3 = zod.z.number().int().nonnegative();
|
|
1057
|
+
var actualCalibrationSource = zod.z.enum([
|
|
1058
|
+
"provider-response-usage",
|
|
1059
|
+
"host-supplied",
|
|
1060
|
+
"test-fixture"
|
|
1061
|
+
]);
|
|
1062
|
+
zod.z.object({
|
|
1063
|
+
route: TokenRoute,
|
|
1064
|
+
localEstimateTokens: tokenCount3,
|
|
1065
|
+
actualInputTokens: tokenCount3,
|
|
1066
|
+
source: actualCalibrationSource,
|
|
1067
|
+
confidence: zod.z.literal("actual"),
|
|
1068
|
+
observedAt: zod.z.number().int().nonnegative().optional(),
|
|
1069
|
+
runId: zod.z.string().optional(),
|
|
1070
|
+
ledgerEntryId: zod.z.string().optional()
|
|
1071
|
+
});
|
|
1072
|
+
zod.z.object({
|
|
1073
|
+
enabled: zod.z.boolean(),
|
|
1074
|
+
applied: zod.z.boolean(),
|
|
1075
|
+
route: TokenRoute.optional(),
|
|
1076
|
+
sampleCount: zod.z.number().int().nonnegative(),
|
|
1077
|
+
coefficient: zod.z.number().positive().optional(),
|
|
1078
|
+
minSamples: zod.z.number().int().positive().optional(),
|
|
1079
|
+
minCoefficient: zod.z.number().positive().optional(),
|
|
1080
|
+
maxCoefficient: zod.z.number().positive().optional(),
|
|
1081
|
+
localEstimateTokens: tokenCount3.optional(),
|
|
1082
|
+
calibratedEstimateTokens: tokenCount3.optional(),
|
|
1083
|
+
deltaTokens: zod.z.number().int().optional(),
|
|
1084
|
+
sampleLedgerEntryIds: zod.z.array(zod.z.string()).optional()
|
|
1085
|
+
});
|
|
1086
|
+
zod.z.object({
|
|
1087
|
+
route: TokenRoute.optional(),
|
|
1088
|
+
localEstimateTokens: tokenCount3,
|
|
1089
|
+
calibratedEstimateTokens: tokenCount3,
|
|
1090
|
+
finalTokens: tokenCount3,
|
|
1091
|
+
source: zod.z.literal("local-estimate"),
|
|
1092
|
+
confidence: zod.z.literal("estimate")
|
|
1093
|
+
});
|
|
894
1094
|
|
|
895
1095
|
// src/shared/ids.ts
|
|
896
1096
|
function isoRandomUUID() {
|