kernl 0.2.0 → 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/.turbo/turbo-build.log +4 -5
- package/.turbo/turbo-check-types.log +4 -0
- package/CHANGELOG.md +147 -0
- package/LICENSE +1 -1
- package/dist/agent/__tests__/concurrency.test.d.ts +2 -0
- package/dist/agent/__tests__/concurrency.test.d.ts.map +1 -0
- package/dist/agent/__tests__/concurrency.test.js +152 -0
- package/dist/agent/__tests__/run.test.d.ts +2 -0
- package/dist/agent/__tests__/run.test.d.ts.map +1 -0
- package/dist/agent/__tests__/run.test.js +357 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent.d.ts +32 -9
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +102 -14
- package/dist/api/__tests__/cursor-page.test.d.ts +2 -0
- package/dist/api/__tests__/cursor-page.test.d.ts.map +1 -0
- package/dist/api/__tests__/cursor-page.test.js +414 -0
- package/dist/api/__tests__/offset-page.test.d.ts +2 -0
- package/dist/api/__tests__/offset-page.test.d.ts.map +1 -0
- package/dist/api/__tests__/offset-page.test.js +510 -0
- package/dist/api/__tests__/threads.test.d.ts +2 -0
- package/dist/api/__tests__/threads.test.d.ts.map +1 -0
- package/dist/api/__tests__/threads.test.js +338 -0
- package/dist/api/models/index.d.ts +2 -0
- package/dist/api/models/index.d.ts.map +1 -0
- package/dist/api/models/thread.d.ts +120 -0
- package/dist/api/models/thread.d.ts.map +1 -0
- package/dist/api/pagination/base.d.ts +48 -0
- package/dist/api/pagination/base.d.ts.map +1 -0
- package/dist/api/pagination/base.js +45 -0
- package/dist/api/pagination/cursor.d.ts +44 -0
- package/dist/api/pagination/cursor.d.ts.map +1 -0
- package/dist/api/pagination/cursor.js +52 -0
- package/dist/api/pagination/offset.d.ts +42 -0
- package/dist/api/pagination/offset.d.ts.map +1 -0
- package/dist/api/pagination/offset.js +55 -0
- package/dist/api/resources/threads/events.d.ts +21 -0
- package/dist/api/resources/threads/events.d.ts.map +1 -0
- package/dist/api/resources/threads/events.js +24 -0
- package/dist/api/resources/threads/index.d.ts +4 -0
- package/dist/api/resources/threads/index.d.ts.map +1 -0
- package/dist/api/resources/threads/index.js +2 -0
- package/dist/api/resources/threads/threads.d.ts +57 -0
- package/dist/api/resources/threads/threads.d.ts.map +1 -0
- package/dist/api/resources/threads/threads.js +199 -0
- package/dist/api/resources/threads/types.d.ts +123 -0
- package/dist/api/resources/threads/types.d.ts.map +1 -0
- package/dist/api/resources/threads/utils.d.ts +18 -0
- package/dist/api/resources/threads/utils.d.ts.map +1 -0
- package/dist/api/resources/threads/utils.js +78 -0
- package/dist/context.d.ts +5 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +6 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +2 -0
- package/dist/kernl/index.d.ts +3 -0
- package/dist/kernl/index.d.ts.map +1 -0
- package/dist/kernl/index.js +2 -0
- package/dist/kernl/kernl.d.ts +64 -0
- package/dist/kernl/kernl.d.ts.map +1 -0
- package/dist/kernl/kernl.js +116 -0
- package/dist/kernl/threads.d.ts +110 -0
- package/dist/kernl/threads.d.ts.map +1 -0
- package/dist/kernl/threads.js +126 -0
- package/dist/kernl.d.ts +22 -6
- package/dist/kernl.d.ts.map +1 -1
- package/dist/kernl.js +73 -10
- package/dist/lib/env.d.ts +3 -3
- package/dist/lib/env.js +1 -1
- package/dist/mcp/__tests__/integration.test.js +8 -8
- package/dist/mcp/__tests__/utils.test.js +6 -6
- package/dist/mcp/http.d.ts +1 -1
- package/dist/mcp/http.d.ts.map +1 -1
- package/dist/mcp/http.js +9 -9
- package/dist/mcp/sse.d.ts +1 -1
- package/dist/mcp/sse.d.ts.map +1 -1
- package/dist/mcp/sse.js +7 -7
- package/dist/mcp/utils.d.ts +1 -1
- package/dist/mcp/utils.d.ts.map +1 -1
- package/dist/mcp/utils.js +4 -5
- package/dist/storage/__tests__/in-memory.test.d.ts +2 -0
- package/dist/storage/__tests__/in-memory.test.d.ts.map +1 -0
- package/dist/storage/__tests__/in-memory.test.js +455 -0
- package/dist/storage/base.d.ts +64 -0
- package/dist/storage/base.d.ts.map +1 -0
- package/dist/storage/base.js +4 -0
- package/dist/storage/in-memory.d.ts +62 -0
- package/dist/storage/in-memory.d.ts.map +1 -0
- package/dist/storage/in-memory.js +283 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +7 -0
- package/dist/storage/thread.d.ts +123 -0
- package/dist/storage/thread.d.ts.map +1 -0
- package/dist/storage/thread.js +4 -0
- package/dist/task.d.ts +5 -3
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +10 -8
- package/dist/thread/__tests__/fixtures/mock-model.d.ts +1 -2
- package/dist/thread/__tests__/fixtures/mock-model.d.ts.map +1 -1
- package/dist/thread/__tests__/integration.test.js +73 -5
- package/dist/thread/__tests__/namespace.test.d.ts +2 -0
- package/dist/thread/__tests__/namespace.test.d.ts.map +1 -0
- package/dist/thread/__tests__/namespace.test.js +131 -0
- package/dist/thread/__tests__/thread-persistence.test.d.ts +2 -0
- package/dist/thread/__tests__/thread-persistence.test.d.ts.map +1 -0
- package/dist/thread/__tests__/thread-persistence.test.js +351 -0
- package/dist/thread/__tests__/thread.test.js +49 -51
- package/dist/thread/thread.d.ts +70 -18
- package/dist/thread/thread.d.ts.map +1 -1
- package/dist/thread/thread.js +211 -73
- package/dist/thread/utils.d.ts +36 -8
- package/dist/thread/utils.d.ts.map +1 -1
- package/dist/thread/utils.js +52 -8
- package/dist/tool/__tests__/fixtures.js +1 -1
- package/dist/tool/__tests__/toolkit.test.js +15 -12
- package/dist/tool/tool.js +3 -3
- package/dist/types/kernl.d.ts +42 -0
- package/dist/types/kernl.d.ts.map +1 -0
- package/dist/types/thread.d.ts +108 -22
- package/dist/types/thread.d.ts.map +1 -1
- package/dist/types/thread.js +12 -0
- package/package.json +11 -7
- package/src/agent/__tests__/concurrency.test.ts +194 -0
- package/src/agent/__tests__/run.test.ts +441 -0
- package/src/agent/index.ts +0 -0
- package/src/agent.ts +141 -24
- package/src/api/__tests__/cursor-page.test.ts +512 -0
- package/src/api/__tests__/offset-page.test.ts +624 -0
- package/src/api/__tests__/threads.test.ts +415 -0
- package/src/api/models/index.ts +6 -0
- package/src/api/models/thread.ts +138 -0
- package/src/api/pagination/base.ts +79 -0
- package/src/api/pagination/cursor.ts +86 -0
- package/src/api/pagination/offset.ts +89 -0
- package/src/api/resources/threads/events.ts +26 -0
- package/src/api/resources/threads/index.ts +9 -0
- package/src/api/resources/threads/threads.ts +256 -0
- package/src/api/resources/threads/types.ts +143 -0
- package/src/api/resources/threads/utils.ts +104 -0
- package/src/context.ts +10 -1
- package/src/index.ts +49 -1
- package/src/internal.ts +15 -0
- package/src/kernl.ts +86 -17
- package/src/mcp/__tests__/integration.test.ts +8 -9
- package/src/mcp/__tests__/utils.test.ts +6 -6
- package/src/mcp/http.ts +9 -9
- package/src/mcp/sse.ts +7 -7
- package/src/mcp/utils.ts +6 -5
- package/src/storage/__tests__/in-memory.test.ts +534 -0
- package/src/storage/base.ts +77 -0
- package/src/storage/in-memory.ts +372 -0
- package/src/storage/index.ts +21 -0
- package/src/storage/thread.ts +141 -0
- package/src/task.ts +12 -10
- package/src/thread/__tests__/fixtures/mock-model.ts +2 -4
- package/src/thread/__tests__/integration.test.ts +111 -10
- package/src/thread/__tests__/namespace.test.ts +158 -0
- package/src/thread/__tests__/thread-persistence.test.ts +367 -0
- package/src/thread/__tests__/thread.test.ts +52 -54
- package/src/thread/thread.ts +247 -96
- package/src/thread/utils.ts +76 -13
- package/src/tool/__tests__/fixtures.ts +1 -1
- package/src/tool/__tests__/toolkit.test.ts +15 -12
- package/src/tool/tool.ts +3 -3
- package/src/types/kernl.ts +51 -0
- package/src/types/thread.ts +139 -25
- package/vitest.config.ts +1 -0
- package/dist/env.d.ts +0 -45
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -31
- package/dist/error.d.ts +0 -1
- package/dist/error.d.ts.map +0 -1
- package/dist/kernel.d.ts +0 -7
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js +0 -7
- package/dist/lib/serde/__tests__/codec.test.d.ts +0 -2
- package/dist/lib/serde/__tests__/codec.test.d.ts.map +0 -1
- package/dist/lib/serde/__tests__/codec.test.js +0 -75
- package/dist/lib/serde/codec.d.ts +0 -12
- package/dist/lib/serde/codec.d.ts.map +0 -1
- package/dist/lib/serde/codec.js +0 -54
- package/dist/lib/serde/thread.d.ts +0 -1
- package/dist/lib/serde/thread.d.ts.map +0 -1
- package/dist/lib/serde/thread.js +0 -172
- package/dist/lib/serde/tool.d.ts +0 -36
- package/dist/lib/serde/tool.d.ts.map +0 -1
- package/dist/lib/utils.d.ts +0 -19
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -41
- package/dist/logger.d.ts +0 -36
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -43
- package/dist/mcp/__tests__/fixtures/echo-server.d.ts +0 -3
- package/dist/mcp/__tests__/fixtures/echo-server.d.ts.map +0 -1
- package/dist/mcp/__tests__/fixtures/echo-server.js +0 -92
- package/dist/mcp/__tests__/fixtures/math-server.d.ts +0 -3
- package/dist/mcp/__tests__/fixtures/math-server.d.ts.map +0 -1
- package/dist/mcp/__tests__/fixtures/math-server.js +0 -98
- package/dist/mcp/__tests__/fixtures/test-server.d.ts +0 -3
- package/dist/mcp/__tests__/fixtures/test-server.d.ts.map +0 -1
- package/dist/mcp/__tests__/fixtures/test-server.js +0 -163
- package/dist/mcp/__tests__/test-utils.d.ts +0 -17
- package/dist/mcp/__tests__/test-utils.d.ts.map +0 -1
- package/dist/mcp/__tests__/test-utils.js +0 -42
- package/dist/mcp/node.d.ts +0 -60
- package/dist/mcp/node.d.ts.map +0 -1
- package/dist/mcp/node.js +0 -297
- package/dist/model.d.ts +0 -175
- package/dist/model.d.ts.map +0 -1
- package/dist/providers/ai.d.ts +0 -1
- package/dist/providers/ai.d.ts.map +0 -1
- package/dist/providers/ai.js +0 -1
- package/dist/providers/default.d.ts +0 -16
- package/dist/providers/default.d.ts.map +0 -1
- package/dist/providers/default.js +0 -17
- package/dist/providers/registry.d.ts +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js +0 -1
- package/dist/sched/scheduler.d.ts +0 -20
- package/dist/sched/scheduler.d.ts.map +0 -1
- package/dist/sched/task.d.ts +0 -92
- package/dist/sched/task.d.ts.map +0 -1
- package/dist/sched/task.js +0 -102
- package/dist/serde/__tests__/codec.test.d.ts +0 -2
- package/dist/serde/__tests__/codec.test.d.ts.map +0 -1
- package/dist/serde/__tests__/codec.test.js +0 -75
- package/dist/serde/codec.d.ts +0 -12
- package/dist/serde/codec.d.ts.map +0 -1
- package/dist/serde/codec.js +0 -54
- package/dist/serde/json.d.ts +0 -8
- package/dist/serde/json.d.ts.map +0 -1
- package/dist/serde/json.js +0 -13
- package/dist/serde/thread.d.ts +0 -687
- package/dist/serde/thread.d.ts.map +0 -1
- package/dist/serde/thread.js +0 -158
- package/dist/serde/tool.d.ts +0 -36
- package/dist/serde/tool.d.ts.map +0 -1
- package/dist/session.d.ts +0 -1
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -1
- package/dist/thread/__tests__/stream.test.d.ts +0 -2
- package/dist/thread/__tests__/stream.test.d.ts.map +0 -1
- package/dist/thread/__tests__/stream.test.js +0 -244
- package/dist/tool/mcp.d.ts +0 -75
- package/dist/tool/mcp.d.ts.map +0 -1
- package/dist/tool/mcp.js +0 -111
- package/dist/tools.d.ts +0 -362
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -220
- package/dist/types/proto.d.ts +0 -1551
- package/dist/types/proto.d.ts.map +0 -1
- package/dist/types/proto.js +0 -531
- package/dist/usage.d.ts +0 -43
- package/dist/usage.d.ts.map +0 -1
- package/dist/usage.js +0 -61
- package/src/lib/serde/thread.ts +0 -188
- /package/dist/{error.js → agent/index.js} +0 -0
- /package/dist/{lib/serde/tool.js → api/models/index.js} +0 -0
- /package/dist/{model.js → api/models/thread.js} +0 -0
- /package/dist/{sched/scheduler.js → api/resources/threads/types.js} +0 -0
- /package/dist/{serde/tool.js → types/kernl.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../src/types/proto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,UAAU;;iBAMrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;iBAMnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAMhD,eAAO,MAAM,OAAO;;;;iBAMlB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAE9C,eAAO,MAAM,UAAU;;;;iBAMrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,SAAS;;;;iBAMpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,aAAa;;;;iBAMxB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,eAAO,MAAM,UAAU;;;;;;;iBAsBrB,CAAC;A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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqBvC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,4BAA4B,CACpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;iBAGjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAKtB,CAAC;AAEH,MAAM,MAAM,WAAW,GACnB,qBAAqB,GACrB,4BAA4B,GAC5B,0BAA0B,GAC1B,sBAAsB,CAAC"}
|
package/dist/types/proto.js
DELETED
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// ----------------------------
|
|
3
|
-
// Shared base types
|
|
4
|
-
// ----------------------------
|
|
5
|
-
/**
|
|
6
|
-
* Every item in the protocol provides a `providerData` field to accommodate custom functionality
|
|
7
|
-
* or new fields
|
|
8
|
-
*/
|
|
9
|
-
export const SharedBase = z.object({
|
|
10
|
-
/**
|
|
11
|
-
* Additional optional provider specific data. Used for custom functionality or model provider
|
|
12
|
-
* specific fields.
|
|
13
|
-
*/
|
|
14
|
-
providerData: z.record(z.string(), z.any()).optional(),
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Every item has a shared of shared item data including an optional ID.
|
|
18
|
-
*/
|
|
19
|
-
export const ItemBase = SharedBase.extend({
|
|
20
|
-
/**
|
|
21
|
-
* An ID to identify the item. This is optional by default. If a model provider absolutely
|
|
22
|
-
* requires this field, it will be validated on the model level.
|
|
23
|
-
*/
|
|
24
|
-
id: z.string().optional(),
|
|
25
|
-
});
|
|
26
|
-
// ----------------------------
|
|
27
|
-
// Content types
|
|
28
|
-
// ----------------------------
|
|
29
|
-
export const Refusal = SharedBase.extend({
|
|
30
|
-
type: z.literal("refusal"),
|
|
31
|
-
/**
|
|
32
|
-
* The refusal explanation from the model.
|
|
33
|
-
*/
|
|
34
|
-
refusal: z.string(),
|
|
35
|
-
});
|
|
36
|
-
export const OutputText = SharedBase.extend({
|
|
37
|
-
type: z.literal("output_text"),
|
|
38
|
-
/**
|
|
39
|
-
* The text output from the model.
|
|
40
|
-
*/
|
|
41
|
-
text: z.string(),
|
|
42
|
-
});
|
|
43
|
-
export const InputText = SharedBase.extend({
|
|
44
|
-
type: z.literal("input_text"),
|
|
45
|
-
/**
|
|
46
|
-
* A text input for example a message from a user
|
|
47
|
-
*/
|
|
48
|
-
text: z.string(),
|
|
49
|
-
});
|
|
50
|
-
export const ReasoningText = SharedBase.extend({
|
|
51
|
-
type: z.literal("reasoning_text"),
|
|
52
|
-
/**
|
|
53
|
-
* A text input for example a message from a user
|
|
54
|
-
*/
|
|
55
|
-
text: z.string(),
|
|
56
|
-
});
|
|
57
|
-
export const InputImage = SharedBase.extend({
|
|
58
|
-
type: z.literal("input_image"),
|
|
59
|
-
/**
|
|
60
|
-
* The image input to the model. Could be provided inline (`image`), as a URL, or by reference to a
|
|
61
|
-
* previously uploaded OpenAI file.
|
|
62
|
-
*/
|
|
63
|
-
image: z
|
|
64
|
-
// 1. image data
|
|
65
|
-
.string()
|
|
66
|
-
// 2.file ID for the image
|
|
67
|
-
.or(z.object({ id: z.string().describe("OpenAI file ID") }))
|
|
68
|
-
.describe("Either base64 encoded image data, a data URL, or an object with a file ID.")
|
|
69
|
-
.optional(),
|
|
70
|
-
/**
|
|
71
|
-
* Controls the level of detail requested for image understanding tasks.
|
|
72
|
-
* Future models may add new values, therefore this accepts any string.
|
|
73
|
-
*/
|
|
74
|
-
detail: z.string().optional(),
|
|
75
|
-
});
|
|
76
|
-
export const InputFile = SharedBase.extend({
|
|
77
|
-
type: z.literal("input_file"),
|
|
78
|
-
/**
|
|
79
|
-
* The file input to the model. Could be raw data, a URL, or an OpenAI file ID.
|
|
80
|
-
*/
|
|
81
|
-
file: z
|
|
82
|
-
// 1. file data
|
|
83
|
-
.string()
|
|
84
|
-
.describe("Either base64 encoded file data or a publicly accessible file URL")
|
|
85
|
-
// 2. file ID
|
|
86
|
-
.or(z.object({ id: z.string().describe("OpenAI file ID") }))
|
|
87
|
-
// 3. publicly accessible file URL
|
|
88
|
-
.or(z.object({ url: z.string().describe("Publicly accessible file URL") }))
|
|
89
|
-
.describe("Contents of the file or an object with a file ID.")
|
|
90
|
-
.optional(),
|
|
91
|
-
/**
|
|
92
|
-
* Optional filename metadata when uploading file data inline.
|
|
93
|
-
*/
|
|
94
|
-
filename: z.string().optional(),
|
|
95
|
-
});
|
|
96
|
-
export const AudioContent = SharedBase.extend({
|
|
97
|
-
type: z.literal("audio"),
|
|
98
|
-
/**
|
|
99
|
-
* The audio input to the model. Could be base64 encoded audio data or an object with a file ID.
|
|
100
|
-
*/
|
|
101
|
-
audio: z
|
|
102
|
-
.string()
|
|
103
|
-
.or(z.object({
|
|
104
|
-
id: z.string(),
|
|
105
|
-
}))
|
|
106
|
-
.describe("Base64 encoded audio data or file id"),
|
|
107
|
-
/**
|
|
108
|
-
* The format of the audio.
|
|
109
|
-
*/
|
|
110
|
-
format: z.string().nullable().optional(),
|
|
111
|
-
/**
|
|
112
|
-
* The transcript of the audio.
|
|
113
|
-
*/
|
|
114
|
-
transcript: z.string().nullable().optional(),
|
|
115
|
-
});
|
|
116
|
-
export const ImageContent = SharedBase.extend({
|
|
117
|
-
type: z.literal("image"),
|
|
118
|
-
/**
|
|
119
|
-
* The image input to the model. Could be base64 encoded image data or an object with a file ID.
|
|
120
|
-
*/
|
|
121
|
-
image: z.string().describe("Base64 encoded image data"),
|
|
122
|
-
});
|
|
123
|
-
export const ToolOutputText = SharedBase.extend({
|
|
124
|
-
type: z.literal("text"),
|
|
125
|
-
/**
|
|
126
|
-
* The text output from the model.
|
|
127
|
-
*/
|
|
128
|
-
text: z.string(),
|
|
129
|
-
});
|
|
130
|
-
const ImageDataObjectSchema = z.object({
|
|
131
|
-
data: z
|
|
132
|
-
.union([z.string(), z.instanceof(Uint8Array)])
|
|
133
|
-
.describe("Base64 image data, or raw bytes that will be base64 encoded automatically."),
|
|
134
|
-
mediaType: z.string().optional(),
|
|
135
|
-
});
|
|
136
|
-
const ImageUrlObjectSchema = z.object({
|
|
137
|
-
url: z
|
|
138
|
-
.string()
|
|
139
|
-
.describe("Publicly accessible URL pointing to the image content"),
|
|
140
|
-
});
|
|
141
|
-
const ImageFileIdObjectSchema = z.object({
|
|
142
|
-
fileId: z
|
|
143
|
-
.string()
|
|
144
|
-
.describe("OpenAI file ID referencing uploaded image content"),
|
|
145
|
-
});
|
|
146
|
-
const ImageObjectSchema = z
|
|
147
|
-
.union([ImageDataObjectSchema, ImageUrlObjectSchema, ImageFileIdObjectSchema])
|
|
148
|
-
.describe("Inline image data or references to uploaded content.");
|
|
149
|
-
const FileDataObjectSchema = z.object({
|
|
150
|
-
data: z
|
|
151
|
-
.union([z.string(), z.instanceof(Uint8Array)])
|
|
152
|
-
.describe("Base64 encoded file data, or raw bytes that will be encoded automatically."),
|
|
153
|
-
mediaType: z
|
|
154
|
-
.string()
|
|
155
|
-
.describe("IANA media type describing the file contents"),
|
|
156
|
-
filename: z.string().describe("Filename associated with the inline data"),
|
|
157
|
-
});
|
|
158
|
-
const FileUrlObjectSchema = z.object({
|
|
159
|
-
url: z.string().describe("Publicly accessible URL for the file content"),
|
|
160
|
-
filename: z.string().optional(),
|
|
161
|
-
});
|
|
162
|
-
const FileIdObjectSchema = z.object({
|
|
163
|
-
id: z.string().describe("OpenAI file ID referencing uploaded content"),
|
|
164
|
-
filename: z.string().optional(),
|
|
165
|
-
});
|
|
166
|
-
const FileReferenceSchema = z
|
|
167
|
-
.union([
|
|
168
|
-
z.string().describe("Existing data URL or base64 string"),
|
|
169
|
-
FileDataObjectSchema,
|
|
170
|
-
FileUrlObjectSchema,
|
|
171
|
-
FileIdObjectSchema,
|
|
172
|
-
])
|
|
173
|
-
.describe("Inline data (with metadata) or references pointing to file contents.");
|
|
174
|
-
const zStringWithHints = (..._hints) => z.string();
|
|
175
|
-
export const ToolOutputImage = SharedBase.extend({
|
|
176
|
-
type: z.literal("image"),
|
|
177
|
-
/**
|
|
178
|
-
* Inline image content or a reference to an uploaded file. Accepts a URL/data URL string or an
|
|
179
|
-
* object describing the data/url/fileId source.
|
|
180
|
-
*/
|
|
181
|
-
image: z.string().or(ImageObjectSchema).optional(),
|
|
182
|
-
/**
|
|
183
|
-
* Controls the requested level of detail for vision models.
|
|
184
|
-
* Use a string to avoid constraining future model capabilities.
|
|
185
|
-
*/
|
|
186
|
-
detail: zStringWithHints("low", "high", "auto").optional(),
|
|
187
|
-
});
|
|
188
|
-
export const ToolOutputFileContent = SharedBase.extend({
|
|
189
|
-
type: z.literal("file"),
|
|
190
|
-
/**
|
|
191
|
-
* File output reference. Provide either a string (data URL / base64), a data object (requires
|
|
192
|
-
* mediaType + filename), or an object pointing to an uploaded file/URL.
|
|
193
|
-
*/
|
|
194
|
-
file: FileReferenceSchema,
|
|
195
|
-
});
|
|
196
|
-
export const ComputerToolOutput = SharedBase.extend({
|
|
197
|
-
type: z.literal("computer_screenshot"),
|
|
198
|
-
/**
|
|
199
|
-
* A base64 encoded image data or a URL representing the screenshot.
|
|
200
|
-
*/
|
|
201
|
-
data: z.string().describe("Base64 encoded image data or URL"),
|
|
202
|
-
});
|
|
203
|
-
export const computerActions = z.discriminatedUnion("type", [
|
|
204
|
-
z.object({ type: z.literal("screenshot") }),
|
|
205
|
-
z.object({
|
|
206
|
-
type: z.literal("click"),
|
|
207
|
-
x: z.number(),
|
|
208
|
-
y: z.number(),
|
|
209
|
-
button: z.enum(["left", "right", "wheel", "back", "forward"]),
|
|
210
|
-
}),
|
|
211
|
-
z.object({
|
|
212
|
-
type: z.literal("double_click"),
|
|
213
|
-
x: z.number(),
|
|
214
|
-
y: z.number(),
|
|
215
|
-
}),
|
|
216
|
-
z.object({
|
|
217
|
-
type: z.literal("scroll"),
|
|
218
|
-
x: z.number(),
|
|
219
|
-
y: z.number(),
|
|
220
|
-
scroll_x: z.number(),
|
|
221
|
-
scroll_y: z.number(),
|
|
222
|
-
}),
|
|
223
|
-
z.object({
|
|
224
|
-
type: z.literal("type"),
|
|
225
|
-
text: z.string(),
|
|
226
|
-
}),
|
|
227
|
-
z.object({ type: z.literal("wait") }),
|
|
228
|
-
z.object({
|
|
229
|
-
type: z.literal("move"),
|
|
230
|
-
x: z.number(),
|
|
231
|
-
y: z.number(),
|
|
232
|
-
}),
|
|
233
|
-
z.object({
|
|
234
|
-
type: z.literal("keypress"),
|
|
235
|
-
keys: z.array(z.string()),
|
|
236
|
-
}),
|
|
237
|
-
z.object({
|
|
238
|
-
type: z.literal("drag"),
|
|
239
|
-
path: z.array(z.object({ x: z.number(), y: z.number() })),
|
|
240
|
-
}),
|
|
241
|
-
]);
|
|
242
|
-
// ----------------------------
|
|
243
|
-
// Message types
|
|
244
|
-
// ----------------------------
|
|
245
|
-
export const AssistantContent = z.discriminatedUnion("type", [
|
|
246
|
-
OutputText,
|
|
247
|
-
Refusal,
|
|
248
|
-
AudioContent,
|
|
249
|
-
ImageContent,
|
|
250
|
-
]);
|
|
251
|
-
const MessageBase = ItemBase.extend({
|
|
252
|
-
/**
|
|
253
|
-
* Any item without a type is treated as a message
|
|
254
|
-
*/
|
|
255
|
-
type: z.literal("message").optional(),
|
|
256
|
-
});
|
|
257
|
-
export const AssistantMessageItem = MessageBase.extend({
|
|
258
|
-
/**
|
|
259
|
-
* Representing a message from the assistant (i.e. the model)
|
|
260
|
-
*/
|
|
261
|
-
role: z.literal("assistant"),
|
|
262
|
-
/**
|
|
263
|
-
* The status of the message.
|
|
264
|
-
*/
|
|
265
|
-
status: z.enum(["in_progress", "completed", "incomplete"]),
|
|
266
|
-
/**
|
|
267
|
-
* The content of the message.
|
|
268
|
-
*/
|
|
269
|
-
content: z.array(AssistantContent),
|
|
270
|
-
});
|
|
271
|
-
export const UserContent = z.discriminatedUnion("type", [
|
|
272
|
-
InputText,
|
|
273
|
-
InputImage,
|
|
274
|
-
InputFile,
|
|
275
|
-
AudioContent,
|
|
276
|
-
]);
|
|
277
|
-
export const UserMessageItem = MessageBase.extend({
|
|
278
|
-
// type: z.literal('message'),
|
|
279
|
-
/**
|
|
280
|
-
* Representing a message from the user
|
|
281
|
-
*/
|
|
282
|
-
role: z.literal("user"),
|
|
283
|
-
/**
|
|
284
|
-
* The content of the message.
|
|
285
|
-
*/
|
|
286
|
-
content: z.array(UserContent).or(z.string()),
|
|
287
|
-
});
|
|
288
|
-
const SystemMessageItem = MessageBase.extend({
|
|
289
|
-
// type: z.literal('message'),
|
|
290
|
-
/**
|
|
291
|
-
* Representing a system message to the user
|
|
292
|
-
*/
|
|
293
|
-
role: z.literal("system"),
|
|
294
|
-
/**
|
|
295
|
-
* The content of the message.
|
|
296
|
-
*/
|
|
297
|
-
content: z.string(),
|
|
298
|
-
});
|
|
299
|
-
export const MessageItem = z.discriminatedUnion("role", [
|
|
300
|
-
SystemMessageItem,
|
|
301
|
-
AssistantMessageItem,
|
|
302
|
-
UserMessageItem,
|
|
303
|
-
]);
|
|
304
|
-
// ----------------------------
|
|
305
|
-
// Tool call types
|
|
306
|
-
// ----------------------------
|
|
307
|
-
export const HostedToolCallItem = ItemBase.extend({
|
|
308
|
-
type: z.literal("hosted_tool_call"),
|
|
309
|
-
/**
|
|
310
|
-
* The name of the hosted tool. For example `web_search_call` or `file_search_call`
|
|
311
|
-
*/
|
|
312
|
-
name: z.string().describe("The name of the hosted tool"),
|
|
313
|
-
/**
|
|
314
|
-
* The arguments of the hosted tool call.
|
|
315
|
-
*/
|
|
316
|
-
arguments: z
|
|
317
|
-
.string()
|
|
318
|
-
.describe("The arguments of the hosted tool call")
|
|
319
|
-
.optional(),
|
|
320
|
-
/**
|
|
321
|
-
* The status of the tool call.
|
|
322
|
-
*/
|
|
323
|
-
status: z.string().optional(),
|
|
324
|
-
/**
|
|
325
|
-
* The primary output of the tool call. Additional output might be in the `providerData` field.
|
|
326
|
-
*/
|
|
327
|
-
output: z.string().optional(),
|
|
328
|
-
});
|
|
329
|
-
export const FunctionCallItem = ItemBase.extend({
|
|
330
|
-
type: z.literal("function_call"),
|
|
331
|
-
/**
|
|
332
|
-
* The ID of the tool call. Required to match up the respective tool call result.
|
|
333
|
-
*/
|
|
334
|
-
callId: z.string().describe("The ID of the tool call"),
|
|
335
|
-
/**
|
|
336
|
-
* The name of the function.
|
|
337
|
-
*/
|
|
338
|
-
name: z.string().describe("The name of the function"),
|
|
339
|
-
/**
|
|
340
|
-
* The status of the function call.
|
|
341
|
-
*/
|
|
342
|
-
status: z.enum(["in_progress", "completed", "incomplete"]).optional(),
|
|
343
|
-
/**
|
|
344
|
-
* The arguments of the function call.
|
|
345
|
-
*/
|
|
346
|
-
arguments: z.string(),
|
|
347
|
-
});
|
|
348
|
-
export const ToolCallOutputContent = z.discriminatedUnion("type", [
|
|
349
|
-
ToolOutputText,
|
|
350
|
-
ToolOutputImage,
|
|
351
|
-
ToolOutputFileContent,
|
|
352
|
-
]);
|
|
353
|
-
export const ToolCallStructuredOutput = z.discriminatedUnion("type", [
|
|
354
|
-
InputText,
|
|
355
|
-
InputImage,
|
|
356
|
-
InputFile,
|
|
357
|
-
]);
|
|
358
|
-
export const FunctionCallResultItem = ItemBase.extend({
|
|
359
|
-
type: z.literal("function_call_result"),
|
|
360
|
-
/**
|
|
361
|
-
* The name of the tool that was called
|
|
362
|
-
*/
|
|
363
|
-
name: z.string().describe("The name of the tool"),
|
|
364
|
-
/**
|
|
365
|
-
* The ID of the tool call. Required to match up the respective tool call result.
|
|
366
|
-
*/
|
|
367
|
-
callId: z.string().describe("The ID of the tool call"),
|
|
368
|
-
/**
|
|
369
|
-
* The status of the tool call.
|
|
370
|
-
*/
|
|
371
|
-
status: z.enum(["in_progress", "completed", "incomplete"]),
|
|
372
|
-
/**
|
|
373
|
-
* The output of the tool call.
|
|
374
|
-
*/
|
|
375
|
-
output: z
|
|
376
|
-
.union([
|
|
377
|
-
z.string(),
|
|
378
|
-
ToolCallOutputContent,
|
|
379
|
-
z.array(ToolCallStructuredOutput),
|
|
380
|
-
])
|
|
381
|
-
.describe("Output returned by the tool call. Supports plain strings, legacy ToolOutput items, or structured input_* items."),
|
|
382
|
-
});
|
|
383
|
-
export const ComputerUseCallItem = ItemBase.extend({
|
|
384
|
-
type: z.literal("computer_call"),
|
|
385
|
-
/**
|
|
386
|
-
* The ID of the computer call. Required to match up the respective computer call result.
|
|
387
|
-
*/
|
|
388
|
-
callId: z.string().describe("The ID of the computer call"),
|
|
389
|
-
/**
|
|
390
|
-
* The status of the computer call.
|
|
391
|
-
*/
|
|
392
|
-
status: z.enum(["in_progress", "completed", "incomplete"]),
|
|
393
|
-
/**
|
|
394
|
-
* The action to be performed by the computer.
|
|
395
|
-
*/
|
|
396
|
-
action: computerActions,
|
|
397
|
-
});
|
|
398
|
-
export const ComputerCallResultItem = ItemBase.extend({
|
|
399
|
-
type: z.literal("computer_call_result"),
|
|
400
|
-
/**
|
|
401
|
-
* The ID of the computer call. Required to match up the respective computer call result.
|
|
402
|
-
*/
|
|
403
|
-
callId: z.string().describe("The ID of the computer call"),
|
|
404
|
-
/**
|
|
405
|
-
* The output of the computer call.
|
|
406
|
-
*/
|
|
407
|
-
output: ComputerToolOutput,
|
|
408
|
-
});
|
|
409
|
-
export const ToolCallItem = z.discriminatedUnion("type", [
|
|
410
|
-
ComputerUseCallItem,
|
|
411
|
-
FunctionCallItem,
|
|
412
|
-
HostedToolCallItem,
|
|
413
|
-
]);
|
|
414
|
-
// ----------------------------
|
|
415
|
-
// Special item types
|
|
416
|
-
// ----------------------------
|
|
417
|
-
export const ReasoningItem = SharedBase.extend({
|
|
418
|
-
id: z.string().optional(),
|
|
419
|
-
type: z.literal("reasoning"),
|
|
420
|
-
/**
|
|
421
|
-
* The user facing representation of the reasoning. Additional information might be in the `providerData` field.
|
|
422
|
-
*/
|
|
423
|
-
content: z.array(InputText),
|
|
424
|
-
/**
|
|
425
|
-
* The raw reasoning text from the model.
|
|
426
|
-
*/
|
|
427
|
-
rawContent: z.array(ReasoningText).optional(),
|
|
428
|
-
});
|
|
429
|
-
/**
|
|
430
|
-
* This is a catch all for items that are not part of the protocol.
|
|
431
|
-
*
|
|
432
|
-
* For example, a model might return an item that is not part of the protocol using this type.
|
|
433
|
-
*
|
|
434
|
-
* In that case everything returned from the model should be passed in the `providerData` field.
|
|
435
|
-
*
|
|
436
|
-
* This enables new features to be added to be added by a model provider without breaking the protocol.
|
|
437
|
-
*/
|
|
438
|
-
export const UnknownItem = ItemBase.extend({
|
|
439
|
-
type: z.literal("unknown"),
|
|
440
|
-
});
|
|
441
|
-
// ----------------------------
|
|
442
|
-
// Joined item types
|
|
443
|
-
// ----------------------------
|
|
444
|
-
export const OutputModelItem = z.discriminatedUnion("type", [
|
|
445
|
-
AssistantMessageItem,
|
|
446
|
-
HostedToolCallItem,
|
|
447
|
-
FunctionCallItem,
|
|
448
|
-
ComputerUseCallItem,
|
|
449
|
-
FunctionCallResultItem,
|
|
450
|
-
ReasoningItem,
|
|
451
|
-
UnknownItem,
|
|
452
|
-
]);
|
|
453
|
-
export const ModelItem = z.union([
|
|
454
|
-
UserMessageItem,
|
|
455
|
-
AssistantMessageItem,
|
|
456
|
-
SystemMessageItem,
|
|
457
|
-
HostedToolCallItem,
|
|
458
|
-
FunctionCallItem,
|
|
459
|
-
ComputerUseCallItem,
|
|
460
|
-
FunctionCallResultItem,
|
|
461
|
-
ComputerCallResultItem,
|
|
462
|
-
ReasoningItem,
|
|
463
|
-
UnknownItem,
|
|
464
|
-
]);
|
|
465
|
-
// ----------------------------
|
|
466
|
-
// Meta data types
|
|
467
|
-
// ----------------------------
|
|
468
|
-
export const UsageData = z.object({
|
|
469
|
-
requests: z.number().optional(),
|
|
470
|
-
inputTokens: z.number(),
|
|
471
|
-
outputTokens: z.number(),
|
|
472
|
-
totalTokens: z.number(),
|
|
473
|
-
inputTokensDetails: z.record(z.string(), z.number()).optional(),
|
|
474
|
-
outputTokensDetails: z.record(z.string(), z.number()).optional(),
|
|
475
|
-
});
|
|
476
|
-
// ----------------------------
|
|
477
|
-
// Stream event types
|
|
478
|
-
// ----------------------------
|
|
479
|
-
/**
|
|
480
|
-
* Event returned by the model when new output text is available to stream to the user.
|
|
481
|
-
*/
|
|
482
|
-
export const StreamEventTextStream = SharedBase.extend({
|
|
483
|
-
type: z.literal("output_text_delta"),
|
|
484
|
-
/**
|
|
485
|
-
* The delta text that was streamed by the modelto the user.
|
|
486
|
-
*/
|
|
487
|
-
delta: z.string(),
|
|
488
|
-
});
|
|
489
|
-
/**
|
|
490
|
-
* Event returned by the model when a new response is started.
|
|
491
|
-
*/
|
|
492
|
-
export const StreamEventResponseStarted = SharedBase.extend({
|
|
493
|
-
type: z.literal("response_started"),
|
|
494
|
-
});
|
|
495
|
-
/**
|
|
496
|
-
* Event returned by the model when a response is completed.
|
|
497
|
-
*/
|
|
498
|
-
export const StreamEventResponseCompleted = SharedBase.extend({
|
|
499
|
-
type: z.literal("response_done"),
|
|
500
|
-
/**
|
|
501
|
-
* The response from the model.
|
|
502
|
-
*/
|
|
503
|
-
response: SharedBase.extend({
|
|
504
|
-
/**
|
|
505
|
-
* The ID of the response.
|
|
506
|
-
*/
|
|
507
|
-
id: z.string(),
|
|
508
|
-
/**
|
|
509
|
-
* The usage data for the response.
|
|
510
|
-
*/
|
|
511
|
-
usage: UsageData,
|
|
512
|
-
/**
|
|
513
|
-
* The output from the model.
|
|
514
|
-
*/
|
|
515
|
-
output: z.array(OutputModelItem),
|
|
516
|
-
}),
|
|
517
|
-
});
|
|
518
|
-
/**
|
|
519
|
-
* Event returned for every item that gets streamed to the model. Used to expose the raw events
|
|
520
|
-
* from the model.
|
|
521
|
-
*/
|
|
522
|
-
export const StreamEventGenericItem = SharedBase.extend({
|
|
523
|
-
type: z.literal("model"),
|
|
524
|
-
event: z.any().describe("The event from the model"),
|
|
525
|
-
});
|
|
526
|
-
export const StreamEvent = z.discriminatedUnion("type", [
|
|
527
|
-
StreamEventTextStream,
|
|
528
|
-
StreamEventResponseCompleted,
|
|
529
|
-
StreamEventResponseStarted,
|
|
530
|
-
StreamEventGenericItem,
|
|
531
|
-
]);
|
package/dist/usage.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { UsageData } from "./types/thread";
|
|
2
|
-
type UsageInput = Partial<UsageData & {
|
|
3
|
-
input_tokens: number;
|
|
4
|
-
output_tokens: number;
|
|
5
|
-
total_tokens: number;
|
|
6
|
-
input_tokens_details: object;
|
|
7
|
-
output_tokens_details: object;
|
|
8
|
-
}> & {
|
|
9
|
-
requests?: number;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Tracks token usage and request counts for an agent run.
|
|
13
|
-
*/
|
|
14
|
-
export declare class Usage {
|
|
15
|
-
/**
|
|
16
|
-
* The number of requests made to the LLM API.
|
|
17
|
-
*/
|
|
18
|
-
requests: number;
|
|
19
|
-
/**
|
|
20
|
-
* The number of input tokens used across all requests.
|
|
21
|
-
*/
|
|
22
|
-
inputTokens: number;
|
|
23
|
-
/**
|
|
24
|
-
* The number of output tokens used across all requests.
|
|
25
|
-
*/
|
|
26
|
-
outputTokens: number;
|
|
27
|
-
/**
|
|
28
|
-
* The total number of tokens sent and received, across all requests.
|
|
29
|
-
*/
|
|
30
|
-
totalTokens: number;
|
|
31
|
-
/**
|
|
32
|
-
* Details about the input tokens used across all requests.
|
|
33
|
-
*/
|
|
34
|
-
inputTokensDetails: Array<Record<string, number>>;
|
|
35
|
-
/**
|
|
36
|
-
* Details about the output tokens used across all requests.
|
|
37
|
-
*/
|
|
38
|
-
outputTokensDetails: Array<Record<string, number>>;
|
|
39
|
-
constructor(input?: UsageInput);
|
|
40
|
-
add(newUsage: Usage): void;
|
|
41
|
-
}
|
|
42
|
-
export { UsageData };
|
|
43
|
-
//# sourceMappingURL=usage.d.ts.map
|
package/dist/usage.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,KAAK,UAAU,GAAG,OAAO,CACvB,SAAS,GAAG;IACV,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CACF,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1B;;GAEG;AACH,qBAAa,KAAK;IAChB;;OAEG;IACI,QAAQ,EAAE,MAAM,CAAC;IAExB;;OAEG;IACI,WAAW,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACI,YAAY,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACI,WAAW,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACI,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAM;IAE9D;;OAEG;IACI,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAM;gBAEnD,KAAK,CAAC,EAAE,UAAU;IAgB9B,GAAG,CAAC,QAAQ,EAAE,KAAK;CAcpB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/usage.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { UsageData } from "./types/thread";
|
|
2
|
-
/**
|
|
3
|
-
* Tracks token usage and request counts for an agent run.
|
|
4
|
-
*/
|
|
5
|
-
export class Usage {
|
|
6
|
-
/**
|
|
7
|
-
* The number of requests made to the LLM API.
|
|
8
|
-
*/
|
|
9
|
-
requests;
|
|
10
|
-
/**
|
|
11
|
-
* The number of input tokens used across all requests.
|
|
12
|
-
*/
|
|
13
|
-
inputTokens;
|
|
14
|
-
/**
|
|
15
|
-
* The number of output tokens used across all requests.
|
|
16
|
-
*/
|
|
17
|
-
outputTokens;
|
|
18
|
-
/**
|
|
19
|
-
* The total number of tokens sent and received, across all requests.
|
|
20
|
-
*/
|
|
21
|
-
totalTokens;
|
|
22
|
-
/**
|
|
23
|
-
* Details about the input tokens used across all requests.
|
|
24
|
-
*/
|
|
25
|
-
inputTokensDetails = [];
|
|
26
|
-
/**
|
|
27
|
-
* Details about the output tokens used across all requests.
|
|
28
|
-
*/
|
|
29
|
-
outputTokensDetails = [];
|
|
30
|
-
constructor(input) {
|
|
31
|
-
if (typeof input === "undefined") {
|
|
32
|
-
this.requests = 0;
|
|
33
|
-
this.inputTokens = 0;
|
|
34
|
-
this.outputTokens = 0;
|
|
35
|
-
this.totalTokens = 0;
|
|
36
|
-
this.inputTokensDetails = [];
|
|
37
|
-
this.outputTokensDetails = [];
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.requests = input?.requests ?? 1;
|
|
41
|
-
this.inputTokens = input?.inputTokens ?? input?.input_tokens ?? 0;
|
|
42
|
-
this.outputTokens = input?.outputTokens ?? input?.output_tokens ?? 0;
|
|
43
|
-
this.totalTokens = input?.totalTokens ?? input?.total_tokens ?? 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
add(newUsage) {
|
|
47
|
-
this.requests += newUsage.requests;
|
|
48
|
-
this.inputTokens += newUsage.inputTokens;
|
|
49
|
-
this.outputTokens += newUsage.outputTokens;
|
|
50
|
-
this.totalTokens += newUsage.totalTokens;
|
|
51
|
-
if (newUsage.inputTokensDetails) {
|
|
52
|
-
// The type does not allow undefined, but it could happen runtime
|
|
53
|
-
this.inputTokensDetails.push(...newUsage.inputTokensDetails);
|
|
54
|
-
}
|
|
55
|
-
if (newUsage.outputTokensDetails) {
|
|
56
|
-
// The type does not allow undefined, but it could happen runtime
|
|
57
|
-
this.outputTokensDetails.push(...newUsage.outputTokensDetails);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export { UsageData };
|