@openai/agents-core 0.0.15 → 0.0.17
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 +1 -1
- package/dist/agent.js +34 -22
- package/dist/agent.js.map +1 -1
- package/dist/agent.mjs +6 -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/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 -1
- package/dist/index.js +121 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/items.d.ts +0 -32
- 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 +14 -7
- package/dist/mcp.js +119 -96
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +65 -57
- 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 +7 -5
- package/dist/metadata.js.map +1 -1
- package/dist/metadata.mjs +2 -3
- package/dist/metadata.mjs.map +1 -1
- 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.js +106 -95
- package/dist/run.js.map +1 -1
- package/dist/runContext.js +13 -6
- package/dist/runContext.js.map +1 -1
- package/dist/runImplementation.d.ts +1 -1
- package/dist/runImplementation.js +106 -89
- package/dist/runImplementation.js.map +1 -1
- package/dist/runImplementation.mjs +1 -1
- package/dist/runImplementation.mjs.map +1 -1
- package/dist/runState.d.ts +7 -186
- 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 +68 -25
- package/dist/shims/mcp-server/node.js.map +1 -1
- package/dist/shims/mcp-server/node.mjs +1 -0
- package/dist/shims/mcp-server/node.mjs.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.d.ts +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 +12 -4
- 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 +1 -1
- package/dist/tool.js +37 -29
- package/dist/tool.js.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 +31 -20
- package/dist/tracing/processor.js.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 -221
- package/dist/types/protocol.js +188 -186
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/protocol.mjs +1 -2
- package/dist/types/protocol.mjs.map +1 -1
- package/dist/types/providerData.js +2 -1
- package/dist/usage.d.ts +10 -3
- package/dist/usage.js +16 -10
- package/dist/usage.js.map +1 -1
- package/dist/usage.mjs +9 -7
- package/dist/usage.mjs.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 +23 -42
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,344 +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
|
-
|
|
183
|
-
|
|
184
|
-
ImageContent,
|
|
182
|
+
exports.AssistantContent = zod_1.z.discriminatedUnion('type', [
|
|
183
|
+
exports.OutputText,
|
|
184
|
+
exports.Refusal,
|
|
185
|
+
exports.AudioContent,
|
|
186
|
+
exports.ImageContent,
|
|
185
187
|
]);
|
|
186
|
-
const MessageBase = ItemBase.extend({
|
|
188
|
+
const MessageBase = exports.ItemBase.extend({
|
|
187
189
|
/**
|
|
188
190
|
* Any item without a type is treated as a message
|
|
189
191
|
*/
|
|
190
|
-
type: z.literal('message').optional(),
|
|
192
|
+
type: zod_1.z.literal('message').optional(),
|
|
191
193
|
});
|
|
192
|
-
|
|
194
|
+
exports.AssistantMessageItem = MessageBase.extend({
|
|
193
195
|
/**
|
|
194
196
|
* Representing a message from the assistant (i.e. the model)
|
|
195
197
|
*/
|
|
196
|
-
role: z.literal('assistant'),
|
|
198
|
+
role: zod_1.z.literal('assistant'),
|
|
197
199
|
/**
|
|
198
200
|
* The status of the message.
|
|
199
201
|
*/
|
|
200
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
202
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
201
203
|
/**
|
|
202
204
|
* The content of the message.
|
|
203
205
|
*/
|
|
204
|
-
content: z.array(AssistantContent),
|
|
206
|
+
content: zod_1.z.array(exports.AssistantContent),
|
|
205
207
|
});
|
|
206
|
-
|
|
207
|
-
InputText,
|
|
208
|
-
InputImage,
|
|
209
|
-
InputFile,
|
|
210
|
-
AudioContent,
|
|
208
|
+
exports.UserContent = zod_1.z.discriminatedUnion('type', [
|
|
209
|
+
exports.InputText,
|
|
210
|
+
exports.InputImage,
|
|
211
|
+
exports.InputFile,
|
|
212
|
+
exports.AudioContent,
|
|
211
213
|
]);
|
|
212
|
-
|
|
214
|
+
exports.UserMessageItem = MessageBase.extend({
|
|
213
215
|
// type: z.literal('message'),
|
|
214
216
|
/**
|
|
215
217
|
* Representing a message from the user
|
|
216
218
|
*/
|
|
217
|
-
role: z.literal('user'),
|
|
219
|
+
role: zod_1.z.literal('user'),
|
|
218
220
|
/**
|
|
219
221
|
* The content of the message.
|
|
220
222
|
*/
|
|
221
|
-
content: z.array(UserContent).or(z.string()),
|
|
223
|
+
content: zod_1.z.array(exports.UserContent).or(zod_1.z.string()),
|
|
222
224
|
});
|
|
223
225
|
const SystemMessageItem = MessageBase.extend({
|
|
224
226
|
// type: z.literal('message'),
|
|
225
227
|
/**
|
|
226
228
|
* Representing a system message to the user
|
|
227
229
|
*/
|
|
228
|
-
role: z.literal('system'),
|
|
230
|
+
role: zod_1.z.literal('system'),
|
|
229
231
|
/**
|
|
230
232
|
* The content of the message.
|
|
231
233
|
*/
|
|
232
|
-
content: z.string(),
|
|
234
|
+
content: zod_1.z.string(),
|
|
233
235
|
});
|
|
234
|
-
|
|
236
|
+
exports.MessageItem = zod_1.z.discriminatedUnion('role', [
|
|
235
237
|
SystemMessageItem,
|
|
236
|
-
AssistantMessageItem,
|
|
237
|
-
UserMessageItem,
|
|
238
|
+
exports.AssistantMessageItem,
|
|
239
|
+
exports.UserMessageItem,
|
|
238
240
|
]);
|
|
239
241
|
// ----------------------------
|
|
240
242
|
// Tool call types
|
|
241
243
|
// ----------------------------
|
|
242
|
-
|
|
243
|
-
type: z.literal('hosted_tool_call'),
|
|
244
|
+
exports.HostedToolCallItem = exports.ItemBase.extend({
|
|
245
|
+
type: zod_1.z.literal('hosted_tool_call'),
|
|
244
246
|
/**
|
|
245
247
|
* The name of the hosted tool. For example `web_search_call` or `file_search_call`
|
|
246
248
|
*/
|
|
247
|
-
name: z.string().describe('The name of the hosted tool'),
|
|
249
|
+
name: zod_1.z.string().describe('The name of the hosted tool'),
|
|
248
250
|
/**
|
|
249
251
|
* The arguments of the hosted tool call.
|
|
250
252
|
*/
|
|
251
|
-
arguments: z
|
|
253
|
+
arguments: zod_1.z
|
|
252
254
|
.string()
|
|
253
255
|
.describe('The arguments of the hosted tool call')
|
|
254
256
|
.optional(),
|
|
255
257
|
/**
|
|
256
258
|
* The status of the tool call.
|
|
257
259
|
*/
|
|
258
|
-
status: z.string().optional(),
|
|
260
|
+
status: zod_1.z.string().optional(),
|
|
259
261
|
/**
|
|
260
262
|
* The primary output of the tool call. Additional output might be in the `providerData` field.
|
|
261
263
|
*/
|
|
262
|
-
output: z.string().optional(),
|
|
264
|
+
output: zod_1.z.string().optional(),
|
|
263
265
|
});
|
|
264
|
-
|
|
265
|
-
type: z.literal('function_call'),
|
|
266
|
+
exports.FunctionCallItem = exports.ItemBase.extend({
|
|
267
|
+
type: zod_1.z.literal('function_call'),
|
|
266
268
|
/**
|
|
267
269
|
* The ID of the tool call. Required to match up the respective tool call result.
|
|
268
270
|
*/
|
|
269
|
-
callId: z.string().describe('The ID of the tool call'),
|
|
271
|
+
callId: zod_1.z.string().describe('The ID of the tool call'),
|
|
270
272
|
/**
|
|
271
273
|
* The name of the function.
|
|
272
274
|
*/
|
|
273
|
-
name: z.string().describe('The name of the function'),
|
|
275
|
+
name: zod_1.z.string().describe('The name of the function'),
|
|
274
276
|
/**
|
|
275
277
|
* The status of the function call.
|
|
276
278
|
*/
|
|
277
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']).optional(),
|
|
279
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']).optional(),
|
|
278
280
|
/**
|
|
279
281
|
* The arguments of the function call.
|
|
280
282
|
*/
|
|
281
|
-
arguments: z.string(),
|
|
283
|
+
arguments: zod_1.z.string(),
|
|
282
284
|
});
|
|
283
|
-
|
|
284
|
-
type: z.literal('function_call_result'),
|
|
285
|
+
exports.FunctionCallResultItem = exports.ItemBase.extend({
|
|
286
|
+
type: zod_1.z.literal('function_call_result'),
|
|
285
287
|
/**
|
|
286
288
|
* The name of the tool that was called
|
|
287
289
|
*/
|
|
288
|
-
name: z.string().describe('The name of the tool'),
|
|
290
|
+
name: zod_1.z.string().describe('The name of the tool'),
|
|
289
291
|
/**
|
|
290
292
|
* The ID of the tool call. Required to match up the respective tool call result.
|
|
291
293
|
*/
|
|
292
|
-
callId: z.string().describe('The ID of the tool call'),
|
|
294
|
+
callId: zod_1.z.string().describe('The ID of the tool call'),
|
|
293
295
|
/**
|
|
294
296
|
* The status of the tool call.
|
|
295
297
|
*/
|
|
296
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
298
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
297
299
|
/**
|
|
298
300
|
* The output of the tool call.
|
|
299
301
|
*/
|
|
300
|
-
output: z.discriminatedUnion('type', [ToolOutputText, ToolOutputImage]),
|
|
302
|
+
output: zod_1.z.discriminatedUnion('type', [exports.ToolOutputText, exports.ToolOutputImage]),
|
|
301
303
|
});
|
|
302
|
-
|
|
303
|
-
type: z.literal('computer_call'),
|
|
304
|
+
exports.ComputerUseCallItem = exports.ItemBase.extend({
|
|
305
|
+
type: zod_1.z.literal('computer_call'),
|
|
304
306
|
/**
|
|
305
307
|
* The ID of the computer call. Required to match up the respective computer call result.
|
|
306
308
|
*/
|
|
307
|
-
callId: z.string().describe('The ID of the computer call'),
|
|
309
|
+
callId: zod_1.z.string().describe('The ID of the computer call'),
|
|
308
310
|
/**
|
|
309
311
|
* The status of the computer call.
|
|
310
312
|
*/
|
|
311
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
313
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
312
314
|
/**
|
|
313
315
|
* The action to be performed by the computer.
|
|
314
316
|
*/
|
|
315
|
-
action: computerActions,
|
|
317
|
+
action: exports.computerActions,
|
|
316
318
|
});
|
|
317
|
-
|
|
318
|
-
type: z.literal('computer_call_result'),
|
|
319
|
+
exports.ComputerCallResultItem = exports.ItemBase.extend({
|
|
320
|
+
type: zod_1.z.literal('computer_call_result'),
|
|
319
321
|
/**
|
|
320
322
|
* The ID of the computer call. Required to match up the respective computer call result.
|
|
321
323
|
*/
|
|
322
|
-
callId: z.string().describe('The ID of the computer call'),
|
|
324
|
+
callId: zod_1.z.string().describe('The ID of the computer call'),
|
|
323
325
|
/**
|
|
324
326
|
* The output of the computer call.
|
|
325
327
|
*/
|
|
326
|
-
output: ComputerToolOutput,
|
|
328
|
+
output: exports.ComputerToolOutput,
|
|
327
329
|
});
|
|
328
|
-
|
|
329
|
-
ComputerUseCallItem,
|
|
330
|
-
FunctionCallItem,
|
|
331
|
-
HostedToolCallItem,
|
|
330
|
+
exports.ToolCallItem = zod_1.z.discriminatedUnion('type', [
|
|
331
|
+
exports.ComputerUseCallItem,
|
|
332
|
+
exports.FunctionCallItem,
|
|
333
|
+
exports.HostedToolCallItem,
|
|
332
334
|
]);
|
|
333
335
|
// ----------------------------
|
|
334
336
|
// Special item types
|
|
335
337
|
// ----------------------------
|
|
336
|
-
|
|
337
|
-
id: z.string().optional(),
|
|
338
|
-
type: z.literal('reasoning'),
|
|
338
|
+
exports.ReasoningItem = exports.SharedBase.extend({
|
|
339
|
+
id: zod_1.z.string().optional(),
|
|
340
|
+
type: zod_1.z.literal('reasoning'),
|
|
339
341
|
/**
|
|
340
342
|
* The user facing representation of the reasoning. Additional information might be in the `providerData` field.
|
|
341
343
|
*/
|
|
342
|
-
content: z.array(InputText),
|
|
344
|
+
content: zod_1.z.array(exports.InputText),
|
|
343
345
|
/**
|
|
344
346
|
* The raw reasoning text from the model.
|
|
345
347
|
*/
|
|
346
|
-
rawContent: z.array(ReasoningText).optional(),
|
|
348
|
+
rawContent: zod_1.z.array(exports.ReasoningText).optional(),
|
|
347
349
|
});
|
|
348
350
|
/**
|
|
349
351
|
* This is a catch all for items that are not part of the protocol.
|
|
@@ -354,42 +356,42 @@ export const ReasoningItem = SharedBase.extend({
|
|
|
354
356
|
*
|
|
355
357
|
* This enables new features to be added to be added by a model provider without breaking the protocol.
|
|
356
358
|
*/
|
|
357
|
-
|
|
358
|
-
type: z.literal('unknown'),
|
|
359
|
+
exports.UnknownItem = exports.ItemBase.extend({
|
|
360
|
+
type: zod_1.z.literal('unknown'),
|
|
359
361
|
});
|
|
360
362
|
// ----------------------------
|
|
361
363
|
// Joined item types
|
|
362
364
|
// ----------------------------
|
|
363
|
-
|
|
364
|
-
AssistantMessageItem,
|
|
365
|
-
HostedToolCallItem,
|
|
366
|
-
FunctionCallItem,
|
|
367
|
-
ComputerUseCallItem,
|
|
368
|
-
ReasoningItem,
|
|
369
|
-
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,
|
|
370
372
|
]);
|
|
371
|
-
|
|
372
|
-
UserMessageItem,
|
|
373
|
-
AssistantMessageItem,
|
|
373
|
+
exports.ModelItem = zod_1.z.union([
|
|
374
|
+
exports.UserMessageItem,
|
|
375
|
+
exports.AssistantMessageItem,
|
|
374
376
|
SystemMessageItem,
|
|
375
|
-
HostedToolCallItem,
|
|
376
|
-
FunctionCallItem,
|
|
377
|
-
ComputerUseCallItem,
|
|
378
|
-
FunctionCallResultItem,
|
|
379
|
-
ComputerCallResultItem,
|
|
380
|
-
ReasoningItem,
|
|
381
|
-
UnknownItem,
|
|
377
|
+
exports.HostedToolCallItem,
|
|
378
|
+
exports.FunctionCallItem,
|
|
379
|
+
exports.ComputerUseCallItem,
|
|
380
|
+
exports.FunctionCallResultItem,
|
|
381
|
+
exports.ComputerCallResultItem,
|
|
382
|
+
exports.ReasoningItem,
|
|
383
|
+
exports.UnknownItem,
|
|
382
384
|
]);
|
|
383
385
|
// ----------------------------
|
|
384
386
|
// Meta data types
|
|
385
387
|
// ----------------------------
|
|
386
|
-
|
|
387
|
-
requests: z.number().optional(),
|
|
388
|
-
inputTokens: z.number(),
|
|
389
|
-
outputTokens: z.number(),
|
|
390
|
-
totalTokens: z.number(),
|
|
391
|
-
inputTokensDetails: z.record(z.string(), z.number()).optional(),
|
|
392
|
-
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(),
|
|
393
395
|
});
|
|
394
396
|
// ----------------------------
|
|
395
397
|
// Stream event types
|
|
@@ -397,54 +399,54 @@ export const UsageData = z.object({
|
|
|
397
399
|
/**
|
|
398
400
|
* Event returned by the model when new output text is available to stream to the user.
|
|
399
401
|
*/
|
|
400
|
-
|
|
401
|
-
type: z.literal('output_text_delta'),
|
|
402
|
+
exports.StreamEventTextStream = exports.SharedBase.extend({
|
|
403
|
+
type: zod_1.z.literal('output_text_delta'),
|
|
402
404
|
/**
|
|
403
405
|
* The delta text that was streamed by the modelto the user.
|
|
404
406
|
*/
|
|
405
|
-
delta: z.string(),
|
|
407
|
+
delta: zod_1.z.string(),
|
|
406
408
|
});
|
|
407
409
|
/**
|
|
408
410
|
* Event returned by the model when a new response is started.
|
|
409
411
|
*/
|
|
410
|
-
|
|
411
|
-
type: z.literal('response_started'),
|
|
412
|
+
exports.StreamEventResponseStarted = exports.SharedBase.extend({
|
|
413
|
+
type: zod_1.z.literal('response_started'),
|
|
412
414
|
});
|
|
413
415
|
/**
|
|
414
416
|
* Event returned by the model when a response is completed.
|
|
415
417
|
*/
|
|
416
|
-
|
|
417
|
-
type: z.literal('response_done'),
|
|
418
|
+
exports.StreamEventResponseCompleted = exports.SharedBase.extend({
|
|
419
|
+
type: zod_1.z.literal('response_done'),
|
|
418
420
|
/**
|
|
419
421
|
* The response from the model.
|
|
420
422
|
*/
|
|
421
|
-
response: SharedBase.extend({
|
|
423
|
+
response: exports.SharedBase.extend({
|
|
422
424
|
/**
|
|
423
425
|
* The ID of the response.
|
|
424
426
|
*/
|
|
425
|
-
id: z.string(),
|
|
427
|
+
id: zod_1.z.string(),
|
|
426
428
|
/**
|
|
427
429
|
* The usage data for the response.
|
|
428
430
|
*/
|
|
429
|
-
usage: UsageData,
|
|
431
|
+
usage: exports.UsageData,
|
|
430
432
|
/**
|
|
431
433
|
* The output from the model.
|
|
432
434
|
*/
|
|
433
|
-
output: z.array(OutputModelItem),
|
|
435
|
+
output: zod_1.z.array(exports.OutputModelItem),
|
|
434
436
|
}),
|
|
435
437
|
});
|
|
436
438
|
/**
|
|
437
439
|
* Event returned for every item that gets streamed to the model. Used to expose the raw events
|
|
438
440
|
* from the model.
|
|
439
441
|
*/
|
|
440
|
-
|
|
441
|
-
type: z.literal('model'),
|
|
442
|
-
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'),
|
|
443
445
|
});
|
|
444
|
-
|
|
445
|
-
StreamEventTextStream,
|
|
446
|
-
StreamEventResponseCompleted,
|
|
447
|
-
StreamEventResponseStarted,
|
|
448
|
-
StreamEventGenericItem,
|
|
446
|
+
exports.StreamEvent = zod_1.z.discriminatedUnion('type', [
|
|
447
|
+
exports.StreamEventTextStream,
|
|
448
|
+
exports.StreamEventResponseCompleted,
|
|
449
|
+
exports.StreamEventResponseStarted,
|
|
450
|
+
exports.StreamEventGenericItem,
|
|
449
451
|
]);
|
|
450
452
|
//# sourceMappingURL=protocol.js.map
|