@arvo-tools/agentic 0.2.0 → 0.3.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.
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __rest = (this && this.__rest) || function (s, e) {
50
+ var t = {};
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
+ t[p] = s[p];
53
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
+ t[p[i]] = s[p[i]];
57
+ }
58
+ return t;
59
+ };
60
+ var __read = (this && this.__read) || function (o, n) {
61
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
62
+ if (!m) return o;
63
+ var i = m.call(o), r, ar = [], e;
64
+ try {
65
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
66
+ }
67
+ catch (error) { e = { error: error }; }
68
+ finally {
69
+ try {
70
+ if (r && !r.done && (m = i["return"])) m.call(i);
71
+ }
72
+ finally { if (e) throw e.error; }
73
+ }
74
+ return ar;
75
+ };
76
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
77
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
78
+ if (ar || !(i in from)) {
79
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
80
+ ar[i] = from[i];
81
+ }
82
+ }
83
+ return to.concat(ar || Array.prototype.slice.call(from));
84
+ };
85
+ var __values = (this && this.__values) || function(o) {
86
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
87
+ if (m) return m.call(o);
88
+ if (o && typeof o.length === "number") return {
89
+ next: function () {
90
+ if (o && i >= o.length) o = void 0;
91
+ return { value: o && o[i++], done: !o };
92
+ }
93
+ };
94
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
95
+ };
96
+ Object.defineProperty(exports, "__esModule", { value: true });
97
+ exports.createArvoAgent = void 0;
98
+ var arvo_core_1 = require("arvo-core");
99
+ var arvo_event_handler_1 = require("arvo-event-handler");
100
+ var agentLoop_js_1 = require("./agentLoop.js");
101
+ var utils_js_1 = require("./utils.js");
102
+ var createArvoAgent = function (_a) {
103
+ var contracts = _a.contracts, memory = _a.memory, handler = _a.handler, llm = _a.llm, mcp = _a.mcp, _b = _a.maxToolInteractions, maxToolInteractions = _b === void 0 ? 5 : _b, _c = _a.llmResponseType, llmResponseType = _c === void 0 ? 'text' : _c, tools = _a.tools;
104
+ var serviceContracts = Object.fromEntries(Object.entries(contracts.services).map(function (_a) {
105
+ var _b = __read(_a, 2), key = _b[0], contract = _b[1].contract;
106
+ return [key, contract];
107
+ }));
108
+ var serviceTypeToDomainMap = Object.fromEntries(Object.values(contracts.services)
109
+ .filter(function (item) { var _a; return (_a = item.domains) === null || _a === void 0 ? void 0 : _a.length; })
110
+ .map(function (item) { return [item.contract.accepts.type, item.domains]; }));
111
+ return (0, arvo_event_handler_1.createArvoResumable)({
112
+ contracts: {
113
+ self: contracts.self,
114
+ services: serviceContracts,
115
+ },
116
+ memory: memory,
117
+ types: {
118
+ context: {},
119
+ },
120
+ executionunits: 0,
121
+ handler: Object.fromEntries(Object.keys(contracts.self.versions).map(function (ver) { return [
122
+ ver,
123
+ (function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
124
+ var otelInfo, contextBuilder, outputBuilder, selfVersionedContract, outputFormat, serviceTools, mcpTools, internalTools, toolInteraction, _c, parentSubject$$, inputData, llmContext, response_1, resumableContextToPersist_1, resumedContext, messages, _d, _e, _f, toolUseId, data, response_2, resumableContextToPersist_2;
125
+ var e_1, _g;
126
+ var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
127
+ var span = _b.span, input = _b.input, context = _b.context, service = _b.service;
128
+ return __generator(this, function (_u) {
129
+ switch (_u.label) {
130
+ case 0:
131
+ otelInfo = {
132
+ span: span,
133
+ headers: (0, arvo_core_1.getOtelHeaderFromSpan)(span),
134
+ };
135
+ _u.label = 1;
136
+ case 1:
137
+ _u.trys.push([1, , 8, 10]);
138
+ contextBuilder = (_h = handler[ver]) === null || _h === void 0 ? void 0 : _h.context;
139
+ outputBuilder = (_j = handler[ver]) === null || _j === void 0 ? void 0 : _j.output;
140
+ selfVersionedContract = contracts.self.version(ver);
141
+ outputFormat = selfVersionedContract.emits[selfVersionedContract.metadata.completeEventType];
142
+ return [4 /*yield*/, (mcp === null || mcp === void 0 ? void 0 : mcp.connect({ otelInfo: otelInfo }))];
143
+ case 2:
144
+ _u.sent();
145
+ serviceTools = (0, utils_js_1.generateServiceToolDefinitions)(contracts.services);
146
+ return [4 /*yield*/, (0, utils_js_1.generateMcpToolDefinitions)(mcp !== null && mcp !== void 0 ? mcp : null, { otelInfo: otelInfo })];
147
+ case 3:
148
+ mcpTools = _u.sent();
149
+ internalTools = (0, utils_js_1.generateAgentInternalToolDefinitions)(tools !== null && tools !== void 0 ? tools : {});
150
+ toolInteraction = (_k = context === null || context === void 0 ? void 0 : context.toolInteractions) !== null && _k !== void 0 ? _k : {
151
+ max: maxToolInteractions,
152
+ current: 0,
153
+ };
154
+ if (!input) return [3 /*break*/, 6];
155
+ _c = input.data, parentSubject$$ = _c.parentSubject$$, inputData = __rest(_c, ["parentSubject$$"]);
156
+ return [4 /*yield*/, contextBuilder({
157
+ lifecycle: 'init',
158
+ input: input,
159
+ tools: { services: serviceTools, mcp: mcpTools, tools: internalTools },
160
+ span: span,
161
+ })];
162
+ case 4:
163
+ llmContext = (_l = (_u.sent())) !== null && _l !== void 0 ? _l : null;
164
+ return [4 /*yield*/, (0, agentLoop_js_1.agentLoop)({
165
+ initLifecycle: 'init',
166
+ system: (_m = llmContext === null || llmContext === void 0 ? void 0 : llmContext.system) !== null && _m !== void 0 ? _m : null,
167
+ messages: ((_o = llmContext === null || llmContext === void 0 ? void 0 : llmContext.messages) === null || _o === void 0 ? void 0 : _o.length)
168
+ ? llmContext.messages
169
+ : [
170
+ {
171
+ role: 'user',
172
+ content: { type: 'text', content: JSON.stringify(inputData) },
173
+ },
174
+ ],
175
+ tools: Object.values(__assign(__assign(__assign({}, mcpTools), serviceTools), internalTools)),
176
+ outputFormat: outputFormat,
177
+ outputBuilder: outputBuilder,
178
+ llmResponseType: llmResponseType,
179
+ llm: llm,
180
+ mcp: mcp !== null && mcp !== void 0 ? mcp : null,
181
+ toolInteraction: toolInteraction,
182
+ currentTotalExecutionUnits: 0,
183
+ }, { otelInfo: otelInfo })];
184
+ case 5:
185
+ response_1 = _u.sent();
186
+ resumableContextToPersist_1 = {
187
+ currentSubject: input.subject,
188
+ system: (_p = llmContext === null || llmContext === void 0 ? void 0 : llmContext.system) !== null && _p !== void 0 ? _p : null,
189
+ messages: response_1.messages,
190
+ toolInteractions: response_1.toolInteractions,
191
+ awaitingToolCalls: Object.fromEntries(((_q = response_1.toolCalls) !== null && _q !== void 0 ? _q : []).map(function (item) { return [
192
+ item.toolUseId,
193
+ { type: item.name, data: null },
194
+ ]; })),
195
+ totalExecutionUnits: response_1.executionUnits,
196
+ };
197
+ if (response_1.toolCalls) {
198
+ return [2 /*return*/, {
199
+ context: resumableContextToPersist_1,
200
+ services: response_1.toolCalls.map(function (item) { return ({
201
+ id: { deduplication: 'DEVELOPER_MANAGED', value: item.toolUseId },
202
+ type: item.name,
203
+ data: __assign(__assign({}, item.input), { parentSubject$$: resumableContextToPersist_1.currentSubject }),
204
+ domain: serviceTypeToDomainMap[item.name],
205
+ executionunits: response_1.executionUnits,
206
+ }); }),
207
+ }];
208
+ }
209
+ return [2 /*return*/, {
210
+ context: resumableContextToPersist_1,
211
+ output: __assign({ __executionunits: response_1.executionUnits }, response_1.output),
212
+ }];
213
+ case 6:
214
+ if (!context) {
215
+ throw new Error('Context is not properly set. Faulty initialization');
216
+ }
217
+ resumedContext = __assign({}, context);
218
+ if ((service === null || service === void 0 ? void 0 : service.parentid) && resumedContext.awaitingToolCalls[service.parentid]) {
219
+ // biome-ignore lint/style/noNonNullAssertion: It cannot be null. The if clause does already
220
+ resumedContext.awaitingToolCalls[service.parentid].data = service.data;
221
+ }
222
+ if (Object.values(resumedContext.awaitingToolCalls).some(function (item) { return item.data === null; })) {
223
+ return [2 /*return*/, { context: resumedContext }];
224
+ }
225
+ messages = __spreadArray([], __read(resumedContext.messages), false);
226
+ try {
227
+ for (_d = __values(Object.entries(resumedContext.awaitingToolCalls)), _e = _d.next(); !_e.done; _e = _d.next()) {
228
+ _f = __read(_e.value, 2), toolUseId = _f[0], data = _f[1].data;
229
+ messages.push({
230
+ role: 'user',
231
+ content: {
232
+ type: 'tool_result',
233
+ toolUseId: toolUseId,
234
+ content: JSON.stringify(data !== null && data !== void 0 ? data : {}),
235
+ },
236
+ });
237
+ }
238
+ }
239
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
240
+ finally {
241
+ try {
242
+ if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
243
+ }
244
+ finally { if (e_1) throw e_1.error; }
245
+ }
246
+ return [4 /*yield*/, (0, agentLoop_js_1.agentLoop)({
247
+ initLifecycle: 'tool_result',
248
+ system: (_r = resumedContext.system) !== null && _r !== void 0 ? _r : null,
249
+ messages: messages,
250
+ tools: Object.values(__assign(__assign(__assign({}, mcpTools), serviceTools), internalTools)),
251
+ outputFormat: outputFormat,
252
+ outputBuilder: outputBuilder,
253
+ llmResponseType: llmResponseType,
254
+ llm: llm,
255
+ mcp: mcp !== null && mcp !== void 0 ? mcp : null,
256
+ toolInteraction: toolInteraction,
257
+ currentTotalExecutionUnits: resumedContext.totalExecutionUnits,
258
+ }, { otelInfo: otelInfo })];
259
+ case 7:
260
+ response_2 = _u.sent();
261
+ resumableContextToPersist_2 = __assign(__assign({}, resumedContext), { messages: response_2.messages, toolInteractions: response_2.toolInteractions, awaitingToolCalls: Object.fromEntries(((_s = response_2.toolCalls) !== null && _s !== void 0 ? _s : []).map(function (item) { return [
262
+ item.toolUseId,
263
+ { type: item.name, data: null },
264
+ ]; })), totalExecutionUnits: response_2.executionUnits });
265
+ if (response_2.toolCalls) {
266
+ return [2 /*return*/, {
267
+ context: resumableContextToPersist_2,
268
+ services: response_2.toolCalls.map(function (item) { return ({
269
+ id: { deduplication: 'DEVELOPER_MANAGED', value: item.toolUseId },
270
+ type: item.name,
271
+ data: __assign(__assign({}, item.input), { parentSubject$$: resumableContextToPersist_2.currentSubject }),
272
+ domain: serviceTypeToDomainMap[item.name],
273
+ executionunits: response_2.executionUnits,
274
+ }); }),
275
+ }];
276
+ }
277
+ return [2 /*return*/, {
278
+ context: resumableContextToPersist_2,
279
+ output: __assign({ __executionunits: response_2.executionUnits }, response_2.output),
280
+ }];
281
+ case 8: return [4 /*yield*/, ((_t = mcp === null || mcp === void 0 ? void 0 : mcp.disconnect({ otelInfo: otelInfo })) === null || _t === void 0 ? void 0 : _t.catch(console.error))];
282
+ case 9:
283
+ _u.sent();
284
+ return [7 /*endfinally*/];
285
+ case 10: return [2 /*return*/];
286
+ }
287
+ });
288
+ }); }),
289
+ ]; })),
290
+ });
291
+ };
292
+ exports.createArvoAgent = createArvoAgent;
293
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources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IAAI,CAAC,IAAI,CAAC;4CACzC,cAAc,EAAE,UAAQ,CAAC,cAAc;yCACxC,CAAC,EATyC,CASzC,CAAC;qCACJ,EAAC;4BACJ,CAAC;4BAED,sBAAO;oCACL,OAAO,EAAE,2BAAyB;oCAClC,MAAM,aACJ,gBAAgB,EAAE,UAAQ,CAAC,cAAc,IACtC,UAAQ,CAAC,MAAM,CACnB;iCACF,EAAC;gCAEF,qBAAM,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,0CAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA,EAAA;;4BAAzD,SAAyD,CAAC;;;;;iBAE7D,CAIqB;SACvB,EA7LiD,CA6LjD,CAAC,CAKH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAvOW,QAAA,eAAe,mBAuO1B"}
@@ -0,0 +1,363 @@
1
+ import z from 'zod';
2
+ export declare const AgentTextContentSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"text">;
4
+ content: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ type: "text";
7
+ content: string;
8
+ }, {
9
+ type: "text";
10
+ content: string;
11
+ }>;
12
+ export declare const AgentMediaContentSchema: z.ZodObject<{
13
+ type: z.ZodLiteral<"media">;
14
+ content: z.ZodString;
15
+ contentType: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
16
+ filename: z.ZodString;
17
+ filetype: z.ZodString;
18
+ type: z.ZodLiteral<"image">;
19
+ format: z.ZodEnum<["base64"]>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ type: "image";
22
+ filename: string;
23
+ filetype: string;
24
+ format: "base64";
25
+ }, {
26
+ type: "image";
27
+ filename: string;
28
+ filetype: string;
29
+ format: "base64";
30
+ }>, z.ZodObject<{
31
+ filename: z.ZodString;
32
+ filetype: z.ZodString;
33
+ type: z.ZodLiteral<"file">;
34
+ format: z.ZodEnum<["base64"]>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ type: "file";
37
+ filename: string;
38
+ filetype: string;
39
+ format: "base64";
40
+ }, {
41
+ type: "file";
42
+ filename: string;
43
+ filetype: string;
44
+ format: "base64";
45
+ }>]>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ type: "media";
48
+ content: string;
49
+ contentType: {
50
+ type: "image";
51
+ filename: string;
52
+ filetype: string;
53
+ format: "base64";
54
+ } | {
55
+ type: "file";
56
+ filename: string;
57
+ filetype: string;
58
+ format: "base64";
59
+ };
60
+ }, {
61
+ type: "media";
62
+ content: string;
63
+ contentType: {
64
+ type: "image";
65
+ filename: string;
66
+ filetype: string;
67
+ format: "base64";
68
+ } | {
69
+ type: "file";
70
+ filename: string;
71
+ filetype: string;
72
+ format: "base64";
73
+ };
74
+ }>;
75
+ export declare const AgentToolResultContentSchema: z.ZodObject<{
76
+ type: z.ZodLiteral<"tool_result">;
77
+ toolUseId: z.ZodString;
78
+ content: z.ZodString;
79
+ }, "strip", z.ZodTypeAny, {
80
+ type: "tool_result";
81
+ content: string;
82
+ toolUseId: string;
83
+ }, {
84
+ type: "tool_result";
85
+ content: string;
86
+ toolUseId: string;
87
+ }>;
88
+ export declare const AgentToolCallContentSchema: z.ZodObject<{
89
+ type: z.ZodLiteral<"tool_use">;
90
+ toolUseId: z.ZodString;
91
+ name: z.ZodString;
92
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ type: "tool_use";
95
+ toolUseId: string;
96
+ name: string;
97
+ input: Record<string, any>;
98
+ }, {
99
+ type: "tool_use";
100
+ toolUseId: string;
101
+ name: string;
102
+ input: Record<string, any>;
103
+ }>;
104
+ export declare const AgentMessageContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
105
+ type: z.ZodLiteral<"text">;
106
+ content: z.ZodString;
107
+ }, "strip", z.ZodTypeAny, {
108
+ type: "text";
109
+ content: string;
110
+ }, {
111
+ type: "text";
112
+ content: string;
113
+ }>, z.ZodObject<{
114
+ type: z.ZodLiteral<"media">;
115
+ content: z.ZodString;
116
+ contentType: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
117
+ filename: z.ZodString;
118
+ filetype: z.ZodString;
119
+ type: z.ZodLiteral<"image">;
120
+ format: z.ZodEnum<["base64"]>;
121
+ }, "strip", z.ZodTypeAny, {
122
+ type: "image";
123
+ filename: string;
124
+ filetype: string;
125
+ format: "base64";
126
+ }, {
127
+ type: "image";
128
+ filename: string;
129
+ filetype: string;
130
+ format: "base64";
131
+ }>, z.ZodObject<{
132
+ filename: z.ZodString;
133
+ filetype: z.ZodString;
134
+ type: z.ZodLiteral<"file">;
135
+ format: z.ZodEnum<["base64"]>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ type: "file";
138
+ filename: string;
139
+ filetype: string;
140
+ format: "base64";
141
+ }, {
142
+ type: "file";
143
+ filename: string;
144
+ filetype: string;
145
+ format: "base64";
146
+ }>]>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ type: "media";
149
+ content: string;
150
+ contentType: {
151
+ type: "image";
152
+ filename: string;
153
+ filetype: string;
154
+ format: "base64";
155
+ } | {
156
+ type: "file";
157
+ filename: string;
158
+ filetype: string;
159
+ format: "base64";
160
+ };
161
+ }, {
162
+ type: "media";
163
+ content: string;
164
+ contentType: {
165
+ type: "image";
166
+ filename: string;
167
+ filetype: string;
168
+ format: "base64";
169
+ } | {
170
+ type: "file";
171
+ filename: string;
172
+ filetype: string;
173
+ format: "base64";
174
+ };
175
+ }>, z.ZodObject<{
176
+ type: z.ZodLiteral<"tool_result">;
177
+ toolUseId: z.ZodString;
178
+ content: z.ZodString;
179
+ }, "strip", z.ZodTypeAny, {
180
+ type: "tool_result";
181
+ content: string;
182
+ toolUseId: string;
183
+ }, {
184
+ type: "tool_result";
185
+ content: string;
186
+ toolUseId: string;
187
+ }>, z.ZodObject<{
188
+ type: z.ZodLiteral<"tool_use">;
189
+ toolUseId: z.ZodString;
190
+ name: z.ZodString;
191
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
192
+ }, "strip", z.ZodTypeAny, {
193
+ type: "tool_use";
194
+ toolUseId: string;
195
+ name: string;
196
+ input: Record<string, any>;
197
+ }, {
198
+ type: "tool_use";
199
+ toolUseId: string;
200
+ name: string;
201
+ input: Record<string, any>;
202
+ }>]>;
203
+ export declare const AgentMessageSchema: z.ZodObject<{
204
+ role: z.ZodEnum<["user", "assistant"]>;
205
+ content: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
206
+ type: z.ZodLiteral<"text">;
207
+ content: z.ZodString;
208
+ }, "strip", z.ZodTypeAny, {
209
+ type: "text";
210
+ content: string;
211
+ }, {
212
+ type: "text";
213
+ content: string;
214
+ }>, z.ZodObject<{
215
+ type: z.ZodLiteral<"media">;
216
+ content: z.ZodString;
217
+ contentType: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
218
+ filename: z.ZodString;
219
+ filetype: z.ZodString;
220
+ type: z.ZodLiteral<"image">;
221
+ format: z.ZodEnum<["base64"]>;
222
+ }, "strip", z.ZodTypeAny, {
223
+ type: "image";
224
+ filename: string;
225
+ filetype: string;
226
+ format: "base64";
227
+ }, {
228
+ type: "image";
229
+ filename: string;
230
+ filetype: string;
231
+ format: "base64";
232
+ }>, z.ZodObject<{
233
+ filename: z.ZodString;
234
+ filetype: z.ZodString;
235
+ type: z.ZodLiteral<"file">;
236
+ format: z.ZodEnum<["base64"]>;
237
+ }, "strip", z.ZodTypeAny, {
238
+ type: "file";
239
+ filename: string;
240
+ filetype: string;
241
+ format: "base64";
242
+ }, {
243
+ type: "file";
244
+ filename: string;
245
+ filetype: string;
246
+ format: "base64";
247
+ }>]>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ type: "media";
250
+ content: string;
251
+ contentType: {
252
+ type: "image";
253
+ filename: string;
254
+ filetype: string;
255
+ format: "base64";
256
+ } | {
257
+ type: "file";
258
+ filename: string;
259
+ filetype: string;
260
+ format: "base64";
261
+ };
262
+ }, {
263
+ type: "media";
264
+ content: string;
265
+ contentType: {
266
+ type: "image";
267
+ filename: string;
268
+ filetype: string;
269
+ format: "base64";
270
+ } | {
271
+ type: "file";
272
+ filename: string;
273
+ filetype: string;
274
+ format: "base64";
275
+ };
276
+ }>, z.ZodObject<{
277
+ type: z.ZodLiteral<"tool_result">;
278
+ toolUseId: z.ZodString;
279
+ content: z.ZodString;
280
+ }, "strip", z.ZodTypeAny, {
281
+ type: "tool_result";
282
+ content: string;
283
+ toolUseId: string;
284
+ }, {
285
+ type: "tool_result";
286
+ content: string;
287
+ toolUseId: string;
288
+ }>, z.ZodObject<{
289
+ type: z.ZodLiteral<"tool_use">;
290
+ toolUseId: z.ZodString;
291
+ name: z.ZodString;
292
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
293
+ }, "strip", z.ZodTypeAny, {
294
+ type: "tool_use";
295
+ toolUseId: string;
296
+ name: string;
297
+ input: Record<string, any>;
298
+ }, {
299
+ type: "tool_use";
300
+ toolUseId: string;
301
+ name: string;
302
+ input: Record<string, any>;
303
+ }>]>;
304
+ }, "strip", z.ZodTypeAny, {
305
+ content: {
306
+ type: "text";
307
+ content: string;
308
+ } | {
309
+ type: "media";
310
+ content: string;
311
+ contentType: {
312
+ type: "image";
313
+ filename: string;
314
+ filetype: string;
315
+ format: "base64";
316
+ } | {
317
+ type: "file";
318
+ filename: string;
319
+ filetype: string;
320
+ format: "base64";
321
+ };
322
+ } | {
323
+ type: "tool_result";
324
+ content: string;
325
+ toolUseId: string;
326
+ } | {
327
+ type: "tool_use";
328
+ toolUseId: string;
329
+ name: string;
330
+ input: Record<string, any>;
331
+ };
332
+ role: "user" | "assistant";
333
+ }, {
334
+ content: {
335
+ type: "text";
336
+ content: string;
337
+ } | {
338
+ type: "media";
339
+ content: string;
340
+ contentType: {
341
+ type: "image";
342
+ filename: string;
343
+ filetype: string;
344
+ format: "base64";
345
+ } | {
346
+ type: "file";
347
+ filename: string;
348
+ filetype: string;
349
+ format: "base64";
350
+ };
351
+ } | {
352
+ type: "tool_result";
353
+ content: string;
354
+ toolUseId: string;
355
+ } | {
356
+ type: "tool_use";
357
+ toolUseId: string;
358
+ name: string;
359
+ input: Record<string, any>;
360
+ };
361
+ role: "user" | "assistant";
362
+ }>;
363
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/Agent/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBlC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;EAIvC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAKrC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKpC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG7B,CAAC"}