@openai/agents-core 0.0.16 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +5 -3
- package/dist/agent.js +46 -23
- package/dist/agent.js.map +1 -1
- package/dist/agent.mjs +17 -1
- package/dist/agent.mjs.map +1 -1
- package/dist/computer.js +2 -1
- package/dist/config.js +12 -6
- package/dist/config.js.map +1 -1
- package/dist/defaultModel.d.ts +22 -0
- package/dist/defaultModel.js +56 -0
- package/dist/defaultModel.js.map +1 -0
- package/dist/defaultModel.mjs +49 -0
- package/dist/defaultModel.mjs.map +1 -0
- package/dist/errors.js +21 -9
- package/dist/errors.js.map +1 -1
- package/dist/events.js +9 -3
- package/dist/events.js.map +1 -1
- package/dist/extensions/handoffFilters.js +9 -6
- package/dist/extensions/handoffFilters.js.map +1 -1
- package/dist/extensions/handoffPrompt.js +7 -3
- package/dist/extensions/handoffPrompt.js.map +1 -1
- package/dist/extensions/index.js +8 -2
- package/dist/extensions/index.js.map +1 -1
- package/dist/guardrail.js +6 -2
- package/dist/guardrail.js.map +1 -1
- package/dist/handoff.js +28 -18
- package/dist/handoff.js.map +1 -1
- package/dist/helpers/message.js +8 -3
- package/dist/helpers/message.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +127 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/items.js +23 -11
- package/dist/items.js.map +1 -1
- package/dist/lifecycle.js +12 -6
- package/dist/lifecycle.js.map +1 -1
- package/dist/logger.js +15 -8
- package/dist/logger.js.map +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +60 -45
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +1 -1
- package/dist/mcp.mjs.map +1 -1
- package/dist/mcpUtil.js +4 -1
- package/dist/mcpUtil.js.map +1 -1
- package/dist/metadata.d.ts +0 -1
- package/dist/metadata.js +8 -6
- package/dist/metadata.js.map +1 -1
- package/dist/metadata.mjs +3 -4
- package/dist/metadata.mjs.map +1 -1
- package/dist/model.d.ts +7 -0
- package/dist/model.js +2 -1
- package/dist/providers.js +6 -2
- package/dist/providers.js.map +1 -1
- package/dist/result.js +22 -14
- package/dist/result.js.map +1 -1
- package/dist/run.d.ts +1 -0
- package/dist/run.js +145 -95
- package/dist/run.js.map +1 -1
- package/dist/run.mjs +39 -0
- package/dist/run.mjs.map +1 -1
- package/dist/runContext.d.ts +1 -1
- package/dist/runContext.js +14 -7
- package/dist/runContext.js.map +1 -1
- package/dist/runContext.mjs +1 -1
- package/dist/runImplementation.d.ts +1 -1
- package/dist/runImplementation.js +107 -90
- package/dist/runImplementation.js.map +1 -1
- package/dist/runImplementation.mjs +2 -2
- package/dist/runImplementation.mjs.map +1 -1
- package/dist/runState.d.ts +7 -1
- package/dist/runState.js +204 -151
- package/dist/runState.js.map +1 -1
- package/dist/runState.mjs +10 -1
- package/dist/runState.mjs.map +1 -1
- package/dist/shims/interface.js +2 -1
- package/dist/shims/mcp-server/browser.js +10 -4
- package/dist/shims/mcp-server/browser.js.map +1 -1
- package/dist/shims/mcp-server/node.js +67 -25
- package/dist/shims/mcp-server/node.js.map +1 -1
- package/dist/shims/shims-browser.js +25 -13
- package/dist/shims/shims-browser.js.map +1 -1
- package/dist/shims/shims-node.js +72 -15
- package/dist/shims/shims-node.js.map +1 -1
- package/dist/shims/shims-node.mjs +11 -3
- package/dist/shims/shims-node.mjs.map +1 -1
- package/dist/shims/shims-workerd.js +77 -18
- package/dist/shims/shims-workerd.js.map +1 -1
- package/dist/shims/shims-workerd.mjs +11 -3
- package/dist/shims/shims-workerd.mjs.map +1 -1
- package/dist/shims/shims.js +17 -1
- package/dist/shims/shims.js.map +1 -1
- package/dist/tool.d.ts +11 -4
- package/dist/tool.js +121 -54
- package/dist/tool.js.map +1 -1
- package/dist/tool.mjs +84 -25
- package/dist/tool.mjs.map +1 -1
- package/dist/tracing/context.js +25 -14
- package/dist/tracing/context.js.map +1 -1
- package/dist/tracing/createSpans.js +52 -38
- package/dist/tracing/createSpans.js.map +1 -1
- package/dist/tracing/index.js +51 -15
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/processor.js +32 -21
- package/dist/tracing/processor.js.map +1 -1
- package/dist/tracing/processor.mjs +1 -1
- package/dist/tracing/processor.mjs.map +1 -1
- package/dist/tracing/provider.js +53 -45
- package/dist/tracing/provider.js.map +1 -1
- package/dist/tracing/spans.js +18 -10
- package/dist/tracing/spans.js.map +1 -1
- package/dist/tracing/traces.js +11 -6
- package/dist/tracing/traces.js.map +1 -1
- package/dist/tracing/utils.js +16 -9
- package/dist/tracing/utils.js.map +1 -1
- package/dist/types/aliases.js +2 -1
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/helpers.js +2 -1
- package/dist/types/index.js +44 -5
- package/dist/types/index.js.map +1 -1
- package/dist/types/protocol.d.ts +1 -1
- package/dist/types/protocol.js +188 -185
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/protocol.mjs +1 -1
- package/dist/types/protocol.mjs.map +1 -1
- package/dist/types/providerData.d.ts +11 -3
- package/dist/types/providerData.js +2 -1
- package/dist/usage.js +7 -3
- package/dist/usage.js.map +1 -1
- package/dist/utils/index.js +9 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/messages.js +6 -2
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/safeExecute.js +4 -1
- package/dist/utils/safeExecute.js.map +1 -1
- package/dist/utils/serialize.js +6 -2
- package/dist/utils/serialize.js.map +1 -1
- package/dist/utils/smartString.js +4 -1
- package/dist/utils/smartString.js.map +1 -1
- package/dist/utils/tools.js +16 -11
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/typeGuards.d.ts +1 -1
- package/dist/utils/typeGuards.js +6 -2
- package/dist/utils/typeGuards.js.map +1 -1
- package/package.json +24 -43
package/dist/types/protocol.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamEvent = exports.StreamEventGenericItem = exports.StreamEventResponseCompleted = exports.StreamEventResponseStarted = exports.StreamEventTextStream = exports.UsageData = exports.ModelItem = exports.OutputModelItem = exports.UnknownItem = exports.ReasoningItem = exports.ToolCallItem = exports.ComputerCallResultItem = exports.ComputerUseCallItem = exports.FunctionCallResultItem = exports.FunctionCallItem = exports.HostedToolCallItem = exports.MessageItem = exports.UserMessageItem = exports.UserContent = exports.AssistantMessageItem = exports.AssistantContent = exports.computerActions = exports.ComputerToolOutput = exports.ToolOutputImage = exports.ToolOutputText = exports.ImageContent = exports.AudioContent = exports.InputFile = exports.InputImage = exports.ReasoningText = exports.InputText = exports.OutputText = exports.Refusal = exports.ItemBase = exports.SharedBase = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
2
5
|
// ----------------------------
|
|
3
6
|
// Shared base types
|
|
4
7
|
// ----------------------------
|
|
@@ -6,343 +9,343 @@ import { z } from '@openai/zod/v3';
|
|
|
6
9
|
* Every item in the protocol provides a `providerData` field to accommodate custom functionality
|
|
7
10
|
* or new fields
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
exports.SharedBase = zod_1.z.object({
|
|
10
13
|
/**
|
|
11
14
|
* Additional optional provider specific data. Used for custom functionality or model provider
|
|
12
15
|
* specific fields.
|
|
13
16
|
*/
|
|
14
|
-
providerData: z.record(z.string(), z.any()).optional(),
|
|
17
|
+
providerData: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
15
18
|
});
|
|
16
19
|
/**
|
|
17
20
|
* Every item has a shared of shared item data including an optional ID.
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
exports.ItemBase = exports.SharedBase.extend({
|
|
20
23
|
/**
|
|
21
24
|
* An ID to identify the item. This is optional by default. If a model provider absolutely
|
|
22
25
|
* requires this field, it will be validated on the model level.
|
|
23
26
|
*/
|
|
24
|
-
id: z.string().optional(),
|
|
27
|
+
id: zod_1.z.string().optional(),
|
|
25
28
|
});
|
|
26
29
|
// ----------------------------
|
|
27
30
|
// Content types
|
|
28
31
|
// ----------------------------
|
|
29
|
-
|
|
30
|
-
type: z.literal('refusal'),
|
|
32
|
+
exports.Refusal = exports.SharedBase.extend({
|
|
33
|
+
type: zod_1.z.literal('refusal'),
|
|
31
34
|
/**
|
|
32
35
|
* The refusal explanation from the model.
|
|
33
36
|
*/
|
|
34
|
-
refusal: z.string(),
|
|
37
|
+
refusal: zod_1.z.string(),
|
|
35
38
|
});
|
|
36
|
-
|
|
37
|
-
type: z.literal('output_text'),
|
|
39
|
+
exports.OutputText = exports.SharedBase.extend({
|
|
40
|
+
type: zod_1.z.literal('output_text'),
|
|
38
41
|
/**
|
|
39
42
|
* The text output from the model.
|
|
40
43
|
*/
|
|
41
|
-
text: z.string(),
|
|
44
|
+
text: zod_1.z.string(),
|
|
42
45
|
});
|
|
43
|
-
|
|
44
|
-
type: z.literal('input_text'),
|
|
46
|
+
exports.InputText = exports.SharedBase.extend({
|
|
47
|
+
type: zod_1.z.literal('input_text'),
|
|
45
48
|
/**
|
|
46
49
|
* A text input for example a message from a user
|
|
47
50
|
*/
|
|
48
|
-
text: z.string(),
|
|
51
|
+
text: zod_1.z.string(),
|
|
49
52
|
});
|
|
50
|
-
|
|
51
|
-
type: z.literal('reasoning_text'),
|
|
53
|
+
exports.ReasoningText = exports.SharedBase.extend({
|
|
54
|
+
type: zod_1.z.literal('reasoning_text'),
|
|
52
55
|
/**
|
|
53
56
|
* A text input for example a message from a user
|
|
54
57
|
*/
|
|
55
|
-
text: z.string(),
|
|
58
|
+
text: zod_1.z.string(),
|
|
56
59
|
});
|
|
57
|
-
|
|
58
|
-
type: z.literal('input_image'),
|
|
60
|
+
exports.InputImage = exports.SharedBase.extend({
|
|
61
|
+
type: zod_1.z.literal('input_image'),
|
|
59
62
|
/**
|
|
60
63
|
* The image input to the model. Could be a URL, base64 or an object with a file ID.
|
|
61
64
|
*/
|
|
62
|
-
image: z
|
|
65
|
+
image: zod_1.z
|
|
63
66
|
.string()
|
|
64
|
-
.or(z.object({
|
|
65
|
-
id: z.string(),
|
|
67
|
+
.or(zod_1.z.object({
|
|
68
|
+
id: zod_1.z.string(),
|
|
66
69
|
}))
|
|
67
70
|
.describe('Could be a URL, base64 or an object with a file ID.'),
|
|
68
71
|
});
|
|
69
|
-
|
|
70
|
-
type: z.literal('input_file'),
|
|
72
|
+
exports.InputFile = exports.SharedBase.extend({
|
|
73
|
+
type: zod_1.z.literal('input_file'),
|
|
71
74
|
/**
|
|
72
75
|
* The file input to the model. Could be a URL, base64 or an object with a file ID.
|
|
73
76
|
*/
|
|
74
|
-
file: z
|
|
77
|
+
file: zod_1.z
|
|
75
78
|
.string()
|
|
76
79
|
.describe('Either base64 encoded file data or a publicly accessible file URL')
|
|
77
|
-
.or(z.object({
|
|
78
|
-
id: z.string().describe('OpenAI file ID'),
|
|
80
|
+
.or(zod_1.z.object({
|
|
81
|
+
id: zod_1.z.string().describe('OpenAI file ID'),
|
|
79
82
|
}))
|
|
80
|
-
.or(z.object({
|
|
81
|
-
url: z.string().describe('Publicly accessible PDF file URL'),
|
|
83
|
+
.or(zod_1.z.object({
|
|
84
|
+
url: zod_1.z.string().describe('Publicly accessible PDF file URL'),
|
|
82
85
|
}))
|
|
83
86
|
.describe('Contents of the file or an object with a file ID.'),
|
|
84
87
|
});
|
|
85
|
-
|
|
86
|
-
type: z.literal('audio'),
|
|
88
|
+
exports.AudioContent = exports.SharedBase.extend({
|
|
89
|
+
type: zod_1.z.literal('audio'),
|
|
87
90
|
/**
|
|
88
91
|
* The audio input to the model. Could be base64 encoded audio data or an object with a file ID.
|
|
89
92
|
*/
|
|
90
|
-
audio: z
|
|
93
|
+
audio: zod_1.z
|
|
91
94
|
.string()
|
|
92
|
-
.or(z.object({
|
|
93
|
-
id: z.string(),
|
|
95
|
+
.or(zod_1.z.object({
|
|
96
|
+
id: zod_1.z.string(),
|
|
94
97
|
}))
|
|
95
98
|
.describe('Base64 encoded audio data or file id'),
|
|
96
99
|
/**
|
|
97
100
|
* The format of the audio.
|
|
98
101
|
*/
|
|
99
|
-
format: z.string().nullable().optional(),
|
|
102
|
+
format: zod_1.z.string().nullable().optional(),
|
|
100
103
|
/**
|
|
101
104
|
* The transcript of the audio.
|
|
102
105
|
*/
|
|
103
|
-
transcript: z.string().nullable().optional(),
|
|
106
|
+
transcript: zod_1.z.string().nullable().optional(),
|
|
104
107
|
});
|
|
105
|
-
|
|
106
|
-
type: z.literal('image'),
|
|
108
|
+
exports.ImageContent = exports.SharedBase.extend({
|
|
109
|
+
type: zod_1.z.literal('image'),
|
|
107
110
|
/**
|
|
108
111
|
* The image input to the model. Could be base64 encoded image data or an object with a file ID.
|
|
109
112
|
*/
|
|
110
|
-
image: z.string().describe('Base64 encoded image data'),
|
|
113
|
+
image: zod_1.z.string().describe('Base64 encoded image data'),
|
|
111
114
|
});
|
|
112
|
-
|
|
113
|
-
type: z.literal('text'),
|
|
115
|
+
exports.ToolOutputText = exports.SharedBase.extend({
|
|
116
|
+
type: zod_1.z.literal('text'),
|
|
114
117
|
/**
|
|
115
118
|
* The text output from the model.
|
|
116
119
|
*/
|
|
117
|
-
text: z.string(),
|
|
120
|
+
text: zod_1.z.string(),
|
|
118
121
|
});
|
|
119
|
-
|
|
120
|
-
type: z.literal('image'),
|
|
122
|
+
exports.ToolOutputImage = exports.SharedBase.extend({
|
|
123
|
+
type: zod_1.z.literal('image'),
|
|
121
124
|
/**
|
|
122
125
|
* The image data. Could be base64 encoded image data or an object with a file ID.
|
|
123
126
|
*/
|
|
124
|
-
data: z.string().describe('Base64 encoded image data'),
|
|
127
|
+
data: zod_1.z.string().describe('Base64 encoded image data'),
|
|
125
128
|
/**
|
|
126
129
|
* The media type of the image.
|
|
127
130
|
*/
|
|
128
|
-
mediaType: z.string().describe('IANA media type of the image'),
|
|
131
|
+
mediaType: zod_1.z.string().describe('IANA media type of the image'),
|
|
129
132
|
});
|
|
130
|
-
|
|
131
|
-
type: z.literal('computer_screenshot'),
|
|
133
|
+
exports.ComputerToolOutput = exports.SharedBase.extend({
|
|
134
|
+
type: zod_1.z.literal('computer_screenshot'),
|
|
132
135
|
/**
|
|
133
136
|
* A base64 encoded image data or a URL representing the screenshot.
|
|
134
137
|
*/
|
|
135
|
-
data: z.string().describe('Base64 encoded image data or URL'),
|
|
138
|
+
data: zod_1.z.string().describe('Base64 encoded image data or URL'),
|
|
136
139
|
});
|
|
137
|
-
|
|
138
|
-
z.object({ type: z.literal('screenshot') }),
|
|
139
|
-
z.object({
|
|
140
|
-
type: z.literal('click'),
|
|
141
|
-
x: z.number(),
|
|
142
|
-
y: z.number(),
|
|
143
|
-
button: z.enum(['left', 'right', 'wheel', 'back', 'forward']),
|
|
140
|
+
exports.computerActions = zod_1.z.discriminatedUnion('type', [
|
|
141
|
+
zod_1.z.object({ type: zod_1.z.literal('screenshot') }),
|
|
142
|
+
zod_1.z.object({
|
|
143
|
+
type: zod_1.z.literal('click'),
|
|
144
|
+
x: zod_1.z.number(),
|
|
145
|
+
y: zod_1.z.number(),
|
|
146
|
+
button: zod_1.z.enum(['left', 'right', 'wheel', 'back', 'forward']),
|
|
144
147
|
}),
|
|
145
|
-
z.object({
|
|
146
|
-
type: z.literal('double_click'),
|
|
147
|
-
x: z.number(),
|
|
148
|
-
y: z.number(),
|
|
148
|
+
zod_1.z.object({
|
|
149
|
+
type: zod_1.z.literal('double_click'),
|
|
150
|
+
x: zod_1.z.number(),
|
|
151
|
+
y: zod_1.z.number(),
|
|
149
152
|
}),
|
|
150
|
-
z.object({
|
|
151
|
-
type: z.literal('scroll'),
|
|
152
|
-
x: z.number(),
|
|
153
|
-
y: z.number(),
|
|
154
|
-
scroll_x: z.number(),
|
|
155
|
-
scroll_y: z.number(),
|
|
153
|
+
zod_1.z.object({
|
|
154
|
+
type: zod_1.z.literal('scroll'),
|
|
155
|
+
x: zod_1.z.number(),
|
|
156
|
+
y: zod_1.z.number(),
|
|
157
|
+
scroll_x: zod_1.z.number(),
|
|
158
|
+
scroll_y: zod_1.z.number(),
|
|
156
159
|
}),
|
|
157
|
-
z.object({
|
|
158
|
-
type: z.literal('type'),
|
|
159
|
-
text: z.string(),
|
|
160
|
+
zod_1.z.object({
|
|
161
|
+
type: zod_1.z.literal('type'),
|
|
162
|
+
text: zod_1.z.string(),
|
|
160
163
|
}),
|
|
161
|
-
z.object({ type: z.literal('wait') }),
|
|
162
|
-
z.object({
|
|
163
|
-
type: z.literal('move'),
|
|
164
|
-
x: z.number(),
|
|
165
|
-
y: z.number(),
|
|
164
|
+
zod_1.z.object({ type: zod_1.z.literal('wait') }),
|
|
165
|
+
zod_1.z.object({
|
|
166
|
+
type: zod_1.z.literal('move'),
|
|
167
|
+
x: zod_1.z.number(),
|
|
168
|
+
y: zod_1.z.number(),
|
|
166
169
|
}),
|
|
167
|
-
z.object({
|
|
168
|
-
type: z.literal('keypress'),
|
|
169
|
-
keys: z.array(z.string()),
|
|
170
|
+
zod_1.z.object({
|
|
171
|
+
type: zod_1.z.literal('keypress'),
|
|
172
|
+
keys: zod_1.z.array(zod_1.z.string()),
|
|
170
173
|
}),
|
|
171
|
-
z.object({
|
|
172
|
-
type: z.literal('drag'),
|
|
173
|
-
path: z.array(z.object({ x: z.number(), y: z.number() })),
|
|
174
|
+
zod_1.z.object({
|
|
175
|
+
type: zod_1.z.literal('drag'),
|
|
176
|
+
path: zod_1.z.array(zod_1.z.object({ x: zod_1.z.number(), y: zod_1.z.number() })),
|
|
174
177
|
}),
|
|
175
178
|
]);
|
|
176
179
|
// ----------------------------
|
|
177
180
|
// Message types
|
|
178
181
|
// ----------------------------
|
|
179
|
-
|
|
180
|
-
OutputText,
|
|
181
|
-
Refusal,
|
|
182
|
-
AudioContent,
|
|
183
|
-
ImageContent,
|
|
182
|
+
exports.AssistantContent = zod_1.z.discriminatedUnion('type', [
|
|
183
|
+
exports.OutputText,
|
|
184
|
+
exports.Refusal,
|
|
185
|
+
exports.AudioContent,
|
|
186
|
+
exports.ImageContent,
|
|
184
187
|
]);
|
|
185
|
-
const MessageBase = ItemBase.extend({
|
|
188
|
+
const MessageBase = exports.ItemBase.extend({
|
|
186
189
|
/**
|
|
187
190
|
* Any item without a type is treated as a message
|
|
188
191
|
*/
|
|
189
|
-
type: z.literal('message').optional(),
|
|
192
|
+
type: zod_1.z.literal('message').optional(),
|
|
190
193
|
});
|
|
191
|
-
|
|
194
|
+
exports.AssistantMessageItem = MessageBase.extend({
|
|
192
195
|
/**
|
|
193
196
|
* Representing a message from the assistant (i.e. the model)
|
|
194
197
|
*/
|
|
195
|
-
role: z.literal('assistant'),
|
|
198
|
+
role: zod_1.z.literal('assistant'),
|
|
196
199
|
/**
|
|
197
200
|
* The status of the message.
|
|
198
201
|
*/
|
|
199
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
202
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
200
203
|
/**
|
|
201
204
|
* The content of the message.
|
|
202
205
|
*/
|
|
203
|
-
content: z.array(AssistantContent),
|
|
206
|
+
content: zod_1.z.array(exports.AssistantContent),
|
|
204
207
|
});
|
|
205
|
-
|
|
206
|
-
InputText,
|
|
207
|
-
InputImage,
|
|
208
|
-
InputFile,
|
|
209
|
-
AudioContent,
|
|
208
|
+
exports.UserContent = zod_1.z.discriminatedUnion('type', [
|
|
209
|
+
exports.InputText,
|
|
210
|
+
exports.InputImage,
|
|
211
|
+
exports.InputFile,
|
|
212
|
+
exports.AudioContent,
|
|
210
213
|
]);
|
|
211
|
-
|
|
214
|
+
exports.UserMessageItem = MessageBase.extend({
|
|
212
215
|
// type: z.literal('message'),
|
|
213
216
|
/**
|
|
214
217
|
* Representing a message from the user
|
|
215
218
|
*/
|
|
216
|
-
role: z.literal('user'),
|
|
219
|
+
role: zod_1.z.literal('user'),
|
|
217
220
|
/**
|
|
218
221
|
* The content of the message.
|
|
219
222
|
*/
|
|
220
|
-
content: z.array(UserContent).or(z.string()),
|
|
223
|
+
content: zod_1.z.array(exports.UserContent).or(zod_1.z.string()),
|
|
221
224
|
});
|
|
222
225
|
const SystemMessageItem = MessageBase.extend({
|
|
223
226
|
// type: z.literal('message'),
|
|
224
227
|
/**
|
|
225
228
|
* Representing a system message to the user
|
|
226
229
|
*/
|
|
227
|
-
role: z.literal('system'),
|
|
230
|
+
role: zod_1.z.literal('system'),
|
|
228
231
|
/**
|
|
229
232
|
* The content of the message.
|
|
230
233
|
*/
|
|
231
|
-
content: z.string(),
|
|
234
|
+
content: zod_1.z.string(),
|
|
232
235
|
});
|
|
233
|
-
|
|
236
|
+
exports.MessageItem = zod_1.z.discriminatedUnion('role', [
|
|
234
237
|
SystemMessageItem,
|
|
235
|
-
AssistantMessageItem,
|
|
236
|
-
UserMessageItem,
|
|
238
|
+
exports.AssistantMessageItem,
|
|
239
|
+
exports.UserMessageItem,
|
|
237
240
|
]);
|
|
238
241
|
// ----------------------------
|
|
239
242
|
// Tool call types
|
|
240
243
|
// ----------------------------
|
|
241
|
-
|
|
242
|
-
type: z.literal('hosted_tool_call'),
|
|
244
|
+
exports.HostedToolCallItem = exports.ItemBase.extend({
|
|
245
|
+
type: zod_1.z.literal('hosted_tool_call'),
|
|
243
246
|
/**
|
|
244
247
|
* The name of the hosted tool. For example `web_search_call` or `file_search_call`
|
|
245
248
|
*/
|
|
246
|
-
name: z.string().describe('The name of the hosted tool'),
|
|
249
|
+
name: zod_1.z.string().describe('The name of the hosted tool'),
|
|
247
250
|
/**
|
|
248
251
|
* The arguments of the hosted tool call.
|
|
249
252
|
*/
|
|
250
|
-
arguments: z
|
|
253
|
+
arguments: zod_1.z
|
|
251
254
|
.string()
|
|
252
255
|
.describe('The arguments of the hosted tool call')
|
|
253
256
|
.optional(),
|
|
254
257
|
/**
|
|
255
258
|
* The status of the tool call.
|
|
256
259
|
*/
|
|
257
|
-
status: z.string().optional(),
|
|
260
|
+
status: zod_1.z.string().optional(),
|
|
258
261
|
/**
|
|
259
262
|
* The primary output of the tool call. Additional output might be in the `providerData` field.
|
|
260
263
|
*/
|
|
261
|
-
output: z.string().optional(),
|
|
264
|
+
output: zod_1.z.string().optional(),
|
|
262
265
|
});
|
|
263
|
-
|
|
264
|
-
type: z.literal('function_call'),
|
|
266
|
+
exports.FunctionCallItem = exports.ItemBase.extend({
|
|
267
|
+
type: zod_1.z.literal('function_call'),
|
|
265
268
|
/**
|
|
266
269
|
* The ID of the tool call. Required to match up the respective tool call result.
|
|
267
270
|
*/
|
|
268
|
-
callId: z.string().describe('The ID of the tool call'),
|
|
271
|
+
callId: zod_1.z.string().describe('The ID of the tool call'),
|
|
269
272
|
/**
|
|
270
273
|
* The name of the function.
|
|
271
274
|
*/
|
|
272
|
-
name: z.string().describe('The name of the function'),
|
|
275
|
+
name: zod_1.z.string().describe('The name of the function'),
|
|
273
276
|
/**
|
|
274
277
|
* The status of the function call.
|
|
275
278
|
*/
|
|
276
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']).optional(),
|
|
279
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']).optional(),
|
|
277
280
|
/**
|
|
278
281
|
* The arguments of the function call.
|
|
279
282
|
*/
|
|
280
|
-
arguments: z.string(),
|
|
283
|
+
arguments: zod_1.z.string(),
|
|
281
284
|
});
|
|
282
|
-
|
|
283
|
-
type: z.literal('function_call_result'),
|
|
285
|
+
exports.FunctionCallResultItem = exports.ItemBase.extend({
|
|
286
|
+
type: zod_1.z.literal('function_call_result'),
|
|
284
287
|
/**
|
|
285
288
|
* The name of the tool that was called
|
|
286
289
|
*/
|
|
287
|
-
name: z.string().describe('The name of the tool'),
|
|
290
|
+
name: zod_1.z.string().describe('The name of the tool'),
|
|
288
291
|
/**
|
|
289
292
|
* The ID of the tool call. Required to match up the respective tool call result.
|
|
290
293
|
*/
|
|
291
|
-
callId: z.string().describe('The ID of the tool call'),
|
|
294
|
+
callId: zod_1.z.string().describe('The ID of the tool call'),
|
|
292
295
|
/**
|
|
293
296
|
* The status of the tool call.
|
|
294
297
|
*/
|
|
295
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
298
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
296
299
|
/**
|
|
297
300
|
* The output of the tool call.
|
|
298
301
|
*/
|
|
299
|
-
output: z.discriminatedUnion('type', [ToolOutputText, ToolOutputImage]),
|
|
302
|
+
output: zod_1.z.discriminatedUnion('type', [exports.ToolOutputText, exports.ToolOutputImage]),
|
|
300
303
|
});
|
|
301
|
-
|
|
302
|
-
type: z.literal('computer_call'),
|
|
304
|
+
exports.ComputerUseCallItem = exports.ItemBase.extend({
|
|
305
|
+
type: zod_1.z.literal('computer_call'),
|
|
303
306
|
/**
|
|
304
307
|
* The ID of the computer call. Required to match up the respective computer call result.
|
|
305
308
|
*/
|
|
306
|
-
callId: z.string().describe('The ID of the computer call'),
|
|
309
|
+
callId: zod_1.z.string().describe('The ID of the computer call'),
|
|
307
310
|
/**
|
|
308
311
|
* The status of the computer call.
|
|
309
312
|
*/
|
|
310
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
313
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
311
314
|
/**
|
|
312
315
|
* The action to be performed by the computer.
|
|
313
316
|
*/
|
|
314
|
-
action: computerActions,
|
|
317
|
+
action: exports.computerActions,
|
|
315
318
|
});
|
|
316
|
-
|
|
317
|
-
type: z.literal('computer_call_result'),
|
|
319
|
+
exports.ComputerCallResultItem = exports.ItemBase.extend({
|
|
320
|
+
type: zod_1.z.literal('computer_call_result'),
|
|
318
321
|
/**
|
|
319
322
|
* The ID of the computer call. Required to match up the respective computer call result.
|
|
320
323
|
*/
|
|
321
|
-
callId: z.string().describe('The ID of the computer call'),
|
|
324
|
+
callId: zod_1.z.string().describe('The ID of the computer call'),
|
|
322
325
|
/**
|
|
323
326
|
* The output of the computer call.
|
|
324
327
|
*/
|
|
325
|
-
output: ComputerToolOutput,
|
|
328
|
+
output: exports.ComputerToolOutput,
|
|
326
329
|
});
|
|
327
|
-
|
|
328
|
-
ComputerUseCallItem,
|
|
329
|
-
FunctionCallItem,
|
|
330
|
-
HostedToolCallItem,
|
|
330
|
+
exports.ToolCallItem = zod_1.z.discriminatedUnion('type', [
|
|
331
|
+
exports.ComputerUseCallItem,
|
|
332
|
+
exports.FunctionCallItem,
|
|
333
|
+
exports.HostedToolCallItem,
|
|
331
334
|
]);
|
|
332
335
|
// ----------------------------
|
|
333
336
|
// Special item types
|
|
334
337
|
// ----------------------------
|
|
335
|
-
|
|
336
|
-
id: z.string().optional(),
|
|
337
|
-
type: z.literal('reasoning'),
|
|
338
|
+
exports.ReasoningItem = exports.SharedBase.extend({
|
|
339
|
+
id: zod_1.z.string().optional(),
|
|
340
|
+
type: zod_1.z.literal('reasoning'),
|
|
338
341
|
/**
|
|
339
342
|
* The user facing representation of the reasoning. Additional information might be in the `providerData` field.
|
|
340
343
|
*/
|
|
341
|
-
content: z.array(InputText),
|
|
344
|
+
content: zod_1.z.array(exports.InputText),
|
|
342
345
|
/**
|
|
343
346
|
* The raw reasoning text from the model.
|
|
344
347
|
*/
|
|
345
|
-
rawContent: z.array(ReasoningText).optional(),
|
|
348
|
+
rawContent: zod_1.z.array(exports.ReasoningText).optional(),
|
|
346
349
|
});
|
|
347
350
|
/**
|
|
348
351
|
* This is a catch all for items that are not part of the protocol.
|
|
@@ -353,42 +356,42 @@ export const ReasoningItem = SharedBase.extend({
|
|
|
353
356
|
*
|
|
354
357
|
* This enables new features to be added to be added by a model provider without breaking the protocol.
|
|
355
358
|
*/
|
|
356
|
-
|
|
357
|
-
type: z.literal('unknown'),
|
|
359
|
+
exports.UnknownItem = exports.ItemBase.extend({
|
|
360
|
+
type: zod_1.z.literal('unknown'),
|
|
358
361
|
});
|
|
359
362
|
// ----------------------------
|
|
360
363
|
// Joined item types
|
|
361
364
|
// ----------------------------
|
|
362
|
-
|
|
363
|
-
AssistantMessageItem,
|
|
364
|
-
HostedToolCallItem,
|
|
365
|
-
FunctionCallItem,
|
|
366
|
-
ComputerUseCallItem,
|
|
367
|
-
ReasoningItem,
|
|
368
|
-
UnknownItem,
|
|
365
|
+
exports.OutputModelItem = zod_1.z.discriminatedUnion('type', [
|
|
366
|
+
exports.AssistantMessageItem,
|
|
367
|
+
exports.HostedToolCallItem,
|
|
368
|
+
exports.FunctionCallItem,
|
|
369
|
+
exports.ComputerUseCallItem,
|
|
370
|
+
exports.ReasoningItem,
|
|
371
|
+
exports.UnknownItem,
|
|
369
372
|
]);
|
|
370
|
-
|
|
371
|
-
UserMessageItem,
|
|
372
|
-
AssistantMessageItem,
|
|
373
|
+
exports.ModelItem = zod_1.z.union([
|
|
374
|
+
exports.UserMessageItem,
|
|
375
|
+
exports.AssistantMessageItem,
|
|
373
376
|
SystemMessageItem,
|
|
374
|
-
HostedToolCallItem,
|
|
375
|
-
FunctionCallItem,
|
|
376
|
-
ComputerUseCallItem,
|
|
377
|
-
FunctionCallResultItem,
|
|
378
|
-
ComputerCallResultItem,
|
|
379
|
-
ReasoningItem,
|
|
380
|
-
UnknownItem,
|
|
377
|
+
exports.HostedToolCallItem,
|
|
378
|
+
exports.FunctionCallItem,
|
|
379
|
+
exports.ComputerUseCallItem,
|
|
380
|
+
exports.FunctionCallResultItem,
|
|
381
|
+
exports.ComputerCallResultItem,
|
|
382
|
+
exports.ReasoningItem,
|
|
383
|
+
exports.UnknownItem,
|
|
381
384
|
]);
|
|
382
385
|
// ----------------------------
|
|
383
386
|
// Meta data types
|
|
384
387
|
// ----------------------------
|
|
385
|
-
|
|
386
|
-
requests: z.number().optional(),
|
|
387
|
-
inputTokens: z.number(),
|
|
388
|
-
outputTokens: z.number(),
|
|
389
|
-
totalTokens: z.number(),
|
|
390
|
-
inputTokensDetails: z.record(z.string(), z.number()).optional(),
|
|
391
|
-
outputTokensDetails: z.record(z.string(), z.number()).optional(),
|
|
388
|
+
exports.UsageData = zod_1.z.object({
|
|
389
|
+
requests: zod_1.z.number().optional(),
|
|
390
|
+
inputTokens: zod_1.z.number(),
|
|
391
|
+
outputTokens: zod_1.z.number(),
|
|
392
|
+
totalTokens: zod_1.z.number(),
|
|
393
|
+
inputTokensDetails: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
|
|
394
|
+
outputTokensDetails: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
|
|
392
395
|
});
|
|
393
396
|
// ----------------------------
|
|
394
397
|
// Stream event types
|
|
@@ -396,54 +399,54 @@ export const UsageData = z.object({
|
|
|
396
399
|
/**
|
|
397
400
|
* Event returned by the model when new output text is available to stream to the user.
|
|
398
401
|
*/
|
|
399
|
-
|
|
400
|
-
type: z.literal('output_text_delta'),
|
|
402
|
+
exports.StreamEventTextStream = exports.SharedBase.extend({
|
|
403
|
+
type: zod_1.z.literal('output_text_delta'),
|
|
401
404
|
/**
|
|
402
405
|
* The delta text that was streamed by the modelto the user.
|
|
403
406
|
*/
|
|
404
|
-
delta: z.string(),
|
|
407
|
+
delta: zod_1.z.string(),
|
|
405
408
|
});
|
|
406
409
|
/**
|
|
407
410
|
* Event returned by the model when a new response is started.
|
|
408
411
|
*/
|
|
409
|
-
|
|
410
|
-
type: z.literal('response_started'),
|
|
412
|
+
exports.StreamEventResponseStarted = exports.SharedBase.extend({
|
|
413
|
+
type: zod_1.z.literal('response_started'),
|
|
411
414
|
});
|
|
412
415
|
/**
|
|
413
416
|
* Event returned by the model when a response is completed.
|
|
414
417
|
*/
|
|
415
|
-
|
|
416
|
-
type: z.literal('response_done'),
|
|
418
|
+
exports.StreamEventResponseCompleted = exports.SharedBase.extend({
|
|
419
|
+
type: zod_1.z.literal('response_done'),
|
|
417
420
|
/**
|
|
418
421
|
* The response from the model.
|
|
419
422
|
*/
|
|
420
|
-
response: SharedBase.extend({
|
|
423
|
+
response: exports.SharedBase.extend({
|
|
421
424
|
/**
|
|
422
425
|
* The ID of the response.
|
|
423
426
|
*/
|
|
424
|
-
id: z.string(),
|
|
427
|
+
id: zod_1.z.string(),
|
|
425
428
|
/**
|
|
426
429
|
* The usage data for the response.
|
|
427
430
|
*/
|
|
428
|
-
usage: UsageData,
|
|
431
|
+
usage: exports.UsageData,
|
|
429
432
|
/**
|
|
430
433
|
* The output from the model.
|
|
431
434
|
*/
|
|
432
|
-
output: z.array(OutputModelItem),
|
|
435
|
+
output: zod_1.z.array(exports.OutputModelItem),
|
|
433
436
|
}),
|
|
434
437
|
});
|
|
435
438
|
/**
|
|
436
439
|
* Event returned for every item that gets streamed to the model. Used to expose the raw events
|
|
437
440
|
* from the model.
|
|
438
441
|
*/
|
|
439
|
-
|
|
440
|
-
type: z.literal('model'),
|
|
441
|
-
event: z.any().describe('The event from the model'),
|
|
442
|
+
exports.StreamEventGenericItem = exports.SharedBase.extend({
|
|
443
|
+
type: zod_1.z.literal('model'),
|
|
444
|
+
event: zod_1.z.any().describe('The event from the model'),
|
|
442
445
|
});
|
|
443
|
-
|
|
444
|
-
StreamEventTextStream,
|
|
445
|
-
StreamEventResponseCompleted,
|
|
446
|
-
StreamEventResponseStarted,
|
|
447
|
-
StreamEventGenericItem,
|
|
446
|
+
exports.StreamEvent = zod_1.z.discriminatedUnion('type', [
|
|
447
|
+
exports.StreamEventTextStream,
|
|
448
|
+
exports.StreamEventResponseCompleted,
|
|
449
|
+
exports.StreamEventResponseStarted,
|
|
450
|
+
exports.StreamEventGenericItem,
|
|
448
451
|
]);
|
|
449
452
|
//# sourceMappingURL=protocol.js.map
|