@illalabs/interfaces 0.3.0-canary.56299752 → 0.3.0-canary.842eb5db
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/errors/endpoints/chat/ChatBaseError.d.ts +16 -5
- package/dist/errors/endpoints/chat/ChatBaseError.d.ts.map +1 -1
- package/dist/external.d.ts +1 -0
- package/dist/external.d.ts.map +1 -1
- package/dist/external.js +1 -0
- package/dist/external.js.map +1 -1
- package/dist/interfaces/chat/response.d.ts +5 -3
- package/dist/interfaces/chat/response.d.ts.map +1 -1
- package/dist/schemas/chatContext.d.ts +79 -645
- package/dist/schemas/chatContext.d.ts.map +1 -1
- package/dist/schemas/chatRequestBody.d.ts +268 -2172
- package/dist/schemas/chatRequestBody.d.ts.map +1 -1
- package/dist/schemas/chatRequestBody.js +5 -3
- package/dist/schemas/chatRequestBody.js.map +1 -1
- package/dist/schemas/executionCheckerQueryParams.d.ts +2 -2
- package/dist/schemas/illaTools.d.ts +266 -0
- package/dist/schemas/illaTools.d.ts.map +1 -0
- package/dist/schemas/illaTools.js +58 -0
- package/dist/schemas/illaTools.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/messages.d.ts +558 -1027
- package/dist/schemas/messages.d.ts.map +1 -1
- package/dist/schemas/messages.js +74 -121
- package/dist/schemas/messages.js.map +1 -1
- package/dist/schemas/modelContext.d.ts +3 -3
- package/dist/schemas/telemetryEvents.d.ts +2417 -0
- package/dist/schemas/telemetryEvents.d.ts.map +1 -0
- package/dist/schemas/telemetryEvents.js +236 -0
- package/dist/schemas/telemetryEvents.js.map +1 -0
- package/dist/schemas/userContext.d.ts +3 -0
- package/dist/schemas/userContext.d.ts.map +1 -1
- package/dist/schemas/userContext.js +4 -0
- package/dist/schemas/userContext.js.map +1 -1
- package/dist/tools/IllaToolError.d.ts +117 -0
- package/dist/tools/IllaToolError.d.ts.map +1 -0
- package/dist/tools/IllaToolError.js +147 -0
- package/dist/tools/IllaToolError.js.map +1 -0
- package/dist/tools/IllaToolOutcome.d.ts +131 -0
- package/dist/tools/IllaToolOutcome.d.ts.map +1 -0
- package/dist/tools/IllaToolOutcome.js +191 -0
- package/dist/tools/IllaToolOutcome.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/actions/inputs.d.ts +6 -2
- package/dist/types/actions/inputs.d.ts.map +1 -1
- package/dist/types/actions/outputs.d.ts +19 -1
- package/dist/types/actions/outputs.d.ts.map +1 -1
- package/dist/types/actions/tools/bridgeAction.d.ts +1 -1
- package/dist/types/actions/tools/bridgeAction.d.ts.map +1 -1
- package/dist/types/actions/tools/defiFetchListingsAction.d.ts +1 -2
- package/dist/types/actions/tools/defiFetchListingsAction.d.ts.map +1 -1
- package/dist/types/actions/tools/defiFetchListingsAction.js +1 -1
- package/dist/types/actions/tools/defiFetchListingsAction.js.map +1 -1
- package/dist/types/actions/tools/defiPositionsAction.d.ts +1 -2
- package/dist/types/actions/tools/defiPositionsAction.d.ts.map +1 -1
- package/dist/types/actions/tools/defiPositionsAction.js +1 -1
- package/dist/types/actions/tools/defiPositionsAction.js.map +1 -1
- package/dist/types/actions/tools/defiSupplyAction.d.ts +1 -2
- package/dist/types/actions/tools/defiSupplyAction.d.ts.map +1 -1
- package/dist/types/actions/tools/defiSupplyAction.js +1 -1
- package/dist/types/actions/tools/defiSupplyAction.js.map +1 -1
- package/dist/types/actions/tools/defiWithdrawAction.d.ts +1 -2
- package/dist/types/actions/tools/defiWithdrawAction.d.ts.map +1 -1
- package/dist/types/actions/tools/defiWithdrawAction.js +1 -1
- package/dist/types/actions/tools/defiWithdrawAction.js.map +1 -1
- package/dist/types/actions/tools/exchangeRateAction.d.ts +1 -2
- package/dist/types/actions/tools/exchangeRateAction.d.ts.map +1 -1
- package/dist/types/actions/tools/exchangeRateAction.js +1 -1
- package/dist/types/actions/tools/exchangeRateAction.js.map +1 -1
- package/dist/types/actions/tools/getWalletBalanceAction.d.ts +4 -3
- package/dist/types/actions/tools/getWalletBalanceAction.d.ts.map +1 -1
- package/dist/types/actions/tools/getWalletBalanceAction.js +1 -1
- package/dist/types/actions/tools/getWalletBalanceAction.js.map +1 -1
- package/dist/types/actions/tools/index.d.ts +12 -0
- package/dist/types/actions/tools/index.d.ts.map +1 -1
- package/dist/types/actions/tools/polymarketPostOrderAction.d.ts +83 -0
- package/dist/types/actions/tools/polymarketPostOrderAction.d.ts.map +1 -0
- package/dist/types/actions/tools/polymarketPostOrderAction.js +2 -0
- package/dist/types/actions/tools/polymarketPostOrderAction.js.map +1 -0
- package/dist/types/actions/tools/predictionMarketsBetAction.d.ts +19 -0
- package/dist/types/actions/tools/predictionMarketsBetAction.d.ts.map +1 -0
- package/dist/types/actions/tools/predictionMarketsBetAction.js +2 -0
- package/dist/types/actions/tools/predictionMarketsBetAction.js.map +1 -0
- package/dist/types/actions/tools/predictionMarketsFetchAction.d.ts +21 -0
- package/dist/types/actions/tools/predictionMarketsFetchAction.d.ts.map +1 -0
- package/dist/types/actions/tools/predictionMarketsFetchAction.js +2 -0
- package/dist/types/actions/tools/predictionMarketsFetchAction.js.map +1 -0
- package/dist/types/actions/tools/predictionMarketsPositionsAction.d.ts +25 -0
- package/dist/types/actions/tools/predictionMarketsPositionsAction.d.ts.map +1 -0
- package/dist/types/actions/tools/predictionMarketsPositionsAction.js +2 -0
- package/dist/types/actions/tools/predictionMarketsPositionsAction.js.map +1 -0
- package/dist/types/actions/tools/tokenTransferAction.d.ts +1 -2
- package/dist/types/actions/tools/tokenTransferAction.d.ts.map +1 -1
- package/dist/types/actions/tools/tokenTransferAction.js +1 -1
- package/dist/types/actions/tools/tokenTransferAction.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/messages.d.ts +3 -6
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/messages.js +1 -1
- package/dist/types/messages.js.map +1 -1
- package/dist/types/streaming.d.ts +81 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/streaming.js +2 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/telemetry.d.ts +139 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/telemetry.js +7 -0
- package/dist/types/telemetry.js.map +1 -0
- package/dist/utils/constants.d.ts +5 -3
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +11 -1
- package/dist/utils/constants.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetryEvents.d.ts","sourceRoot":"","sources":["../../src/schemas/telemetryEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,mBAAmB,yLAatB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;EAE/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;EAExC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;EAKpC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOlC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIhC,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { IllaToolErrorSchema } from "./illaTools.js";
|
|
3
|
+
import { PendingToolCallSchema } from "./messages.js";
|
|
4
|
+
/**
|
|
5
|
+
* Telemetry event type enum values.
|
|
6
|
+
* Used to infer TelemetryEventType in types/telemetry.ts
|
|
7
|
+
*/
|
|
8
|
+
export const telemetryEventTypes = [
|
|
9
|
+
"iteration_start",
|
|
10
|
+
"iteration_end",
|
|
11
|
+
"tool_call_batch",
|
|
12
|
+
"tool_result",
|
|
13
|
+
"scratchpad_reset",
|
|
14
|
+
"llm_start",
|
|
15
|
+
"llm_end",
|
|
16
|
+
"text_delta",
|
|
17
|
+
"finish",
|
|
18
|
+
"error",
|
|
19
|
+
"connected",
|
|
20
|
+
"stream_end",
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Base telemetry event schema with common fields
|
|
24
|
+
*/
|
|
25
|
+
export const baseTelemetryEventSchema = z.object({
|
|
26
|
+
requestId: z.string(),
|
|
27
|
+
type: z.enum(telemetryEventTypes),
|
|
28
|
+
timestamp: z.number().optional(),
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Connected event schema - emitted when connected to telemetry stream
|
|
32
|
+
*/
|
|
33
|
+
export const connectedEventSchema = baseTelemetryEventSchema.extend({
|
|
34
|
+
type: z.literal("connected"),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Stream end telemetry event schema - emitted when stream ends
|
|
38
|
+
*/
|
|
39
|
+
export const streamEndTelemetryEventSchema = baseTelemetryEventSchema.extend({
|
|
40
|
+
type: z.literal("stream_end"),
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Iteration start event schema - emitted when an iteration starts
|
|
44
|
+
*/
|
|
45
|
+
export const iterationStartEventSchema = baseTelemetryEventSchema.extend({
|
|
46
|
+
type: z.literal("iteration_start"),
|
|
47
|
+
data: z.object({
|
|
48
|
+
iteration: z.number(),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Iteration end event schema - emitted when an iteration ends
|
|
53
|
+
*/
|
|
54
|
+
export const iterationEndEventSchema = baseTelemetryEventSchema.extend({
|
|
55
|
+
type: z.literal("iteration_end"),
|
|
56
|
+
data: z.object({
|
|
57
|
+
iteration: z.number(),
|
|
58
|
+
hasToolCalls: z.boolean(),
|
|
59
|
+
shouldContinue: z.boolean(),
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Tool call batch event schema - emitted when tool calls are batched for execution
|
|
64
|
+
*/
|
|
65
|
+
export const toolCallBatchEventSchema = baseTelemetryEventSchema.extend({
|
|
66
|
+
type: z.literal("tool_call_batch"),
|
|
67
|
+
data: z.object({
|
|
68
|
+
iteration: z.number(),
|
|
69
|
+
tools: z.array(z.object({
|
|
70
|
+
toolCallId: z.string(),
|
|
71
|
+
toolName: z.string(),
|
|
72
|
+
})),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Tool result event schema - emitted when a tool execution completes
|
|
77
|
+
*/
|
|
78
|
+
export const toolResultEventSchema = baseTelemetryEventSchema.extend({
|
|
79
|
+
type: z.literal("tool_result"),
|
|
80
|
+
data: z.discriminatedUnion("status", [
|
|
81
|
+
z.object({
|
|
82
|
+
toolCallId: z.string(),
|
|
83
|
+
toolName: z.string(),
|
|
84
|
+
status: z.literal("pending"),
|
|
85
|
+
}),
|
|
86
|
+
z.object({
|
|
87
|
+
toolCallId: z.string(),
|
|
88
|
+
toolName: z.string(),
|
|
89
|
+
status: z.literal("success"),
|
|
90
|
+
}),
|
|
91
|
+
z.object({
|
|
92
|
+
toolCallId: z.string(),
|
|
93
|
+
toolName: z.string(),
|
|
94
|
+
status: z.literal("failure"),
|
|
95
|
+
error: z.string(),
|
|
96
|
+
}),
|
|
97
|
+
]),
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Scratchpad reset event schema - emitted when the scratchpad is reset
|
|
101
|
+
*/
|
|
102
|
+
export const scratchpadResetEventSchema = baseTelemetryEventSchema.extend({
|
|
103
|
+
type: z.literal("scratchpad_reset"),
|
|
104
|
+
data: z.object({
|
|
105
|
+
reason: z.string(),
|
|
106
|
+
}),
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* LLM start event schema - emitted when LLM generation starts
|
|
110
|
+
*/
|
|
111
|
+
export const llmStartEventSchema = baseTelemetryEventSchema.extend({
|
|
112
|
+
type: z.literal("llm_start"),
|
|
113
|
+
data: z.object({
|
|
114
|
+
iteration: z.number(),
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* LLM end event schema - emitted when LLM generation ends
|
|
119
|
+
*/
|
|
120
|
+
export const llmEndEventSchema = baseTelemetryEventSchema.extend({
|
|
121
|
+
type: z.literal("llm_end"),
|
|
122
|
+
data: z.object({
|
|
123
|
+
iteration: z.number(),
|
|
124
|
+
hasText: z.boolean(),
|
|
125
|
+
toolCallCount: z.number(),
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Text delta event schema - emitted when a text chunk is received from LLM
|
|
130
|
+
*/
|
|
131
|
+
export const textDeltaEventSchema = baseTelemetryEventSchema.extend({
|
|
132
|
+
type: z.literal("text_delta"),
|
|
133
|
+
data: z.object({
|
|
134
|
+
delta: z.string(),
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* Finish event schema - emitted when orchestration finishes
|
|
139
|
+
*/
|
|
140
|
+
export const finishEventSchema = baseTelemetryEventSchema.extend({
|
|
141
|
+
type: z.literal("finish"),
|
|
142
|
+
data: z.object({
|
|
143
|
+
totalIterations: z.number(),
|
|
144
|
+
hasPendingTools: z.boolean(),
|
|
145
|
+
hasToolErrors: z.boolean(),
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* Error telemetry event schema - emitted when an error occurs.
|
|
150
|
+
* The data field is always present per the ErrorEvent type definition.
|
|
151
|
+
*/
|
|
152
|
+
export const errorTelemetryEventSchema = baseTelemetryEventSchema.extend({
|
|
153
|
+
type: z.literal("error"),
|
|
154
|
+
data: z.object({
|
|
155
|
+
message: z.string(),
|
|
156
|
+
code: z.string().optional(),
|
|
157
|
+
}),
|
|
158
|
+
});
|
|
159
|
+
/**
|
|
160
|
+
* Schema for validating telemetry events.
|
|
161
|
+
* Discriminated union using the "type" field.
|
|
162
|
+
*/
|
|
163
|
+
export const telemetryEventSchema = z.discriminatedUnion("type", [
|
|
164
|
+
connectedEventSchema,
|
|
165
|
+
streamEndTelemetryEventSchema,
|
|
166
|
+
iterationStartEventSchema,
|
|
167
|
+
iterationEndEventSchema,
|
|
168
|
+
toolCallBatchEventSchema,
|
|
169
|
+
toolResultEventSchema,
|
|
170
|
+
scratchpadResetEventSchema,
|
|
171
|
+
llmStartEventSchema,
|
|
172
|
+
llmEndEventSchema,
|
|
173
|
+
textDeltaEventSchema,
|
|
174
|
+
finishEventSchema,
|
|
175
|
+
errorTelemetryEventSchema,
|
|
176
|
+
]);
|
|
177
|
+
/**
|
|
178
|
+
* Message schema for result events.
|
|
179
|
+
* Uses z.custom<ModelMessage>() to ensure type compatibility with the AI SDK's
|
|
180
|
+
* ModelMessage type. Runtime validation of the message structure happens at the
|
|
181
|
+
* API layer; this schema trusts the structure and preserves the correct TypeScript type.
|
|
182
|
+
*/
|
|
183
|
+
const messageSchema = z.custom();
|
|
184
|
+
/**
|
|
185
|
+
* Incomplete tool call schema for result events
|
|
186
|
+
*/
|
|
187
|
+
const incompleteToolCallSchema = z.object({
|
|
188
|
+
toolCallId: z.string(),
|
|
189
|
+
toolName: z.string(),
|
|
190
|
+
toolInput: z.unknown().optional(),
|
|
191
|
+
});
|
|
192
|
+
/**
|
|
193
|
+
* Schema for validating result events from the streaming endpoint.
|
|
194
|
+
* Uses type: "result" as discriminator for consistency with other event schemas.
|
|
195
|
+
* Also includes status: 200 for backward compatibility with CoreApiChatSuccessResponse.
|
|
196
|
+
*/
|
|
197
|
+
export const resultEventDataSchema = z.object({
|
|
198
|
+
type: z.literal("result"),
|
|
199
|
+
status: z.literal(200),
|
|
200
|
+
messages: z.array(messageSchema),
|
|
201
|
+
text: z.string(),
|
|
202
|
+
pendingTools: z.array(PendingToolCallSchema).optional(),
|
|
203
|
+
incompleteTools: z.array(incompleteToolCallSchema).optional(),
|
|
204
|
+
toolErrors: z.array(IllaToolErrorSchema).optional(),
|
|
205
|
+
requestId: z.string(),
|
|
206
|
+
});
|
|
207
|
+
/**
|
|
208
|
+
* Schema for validating error events from the streaming endpoint
|
|
209
|
+
*/
|
|
210
|
+
export const errorEventDataSchema = z.object({
|
|
211
|
+
type: z.literal("error"),
|
|
212
|
+
requestId: z.string(),
|
|
213
|
+
timestamp: z.number().optional(),
|
|
214
|
+
data: z.object({
|
|
215
|
+
message: z.string(),
|
|
216
|
+
code: z.string().optional(),
|
|
217
|
+
}),
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* Schema for validating stream_end events from the streaming endpoint
|
|
221
|
+
*/
|
|
222
|
+
export const streamEndEventDataSchema = z.object({
|
|
223
|
+
type: z.literal("stream_end"),
|
|
224
|
+
requestId: z.string(),
|
|
225
|
+
timestamp: z.number().optional(),
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* Unified discriminated union for all stream event data types.
|
|
229
|
+
* Uses "type" as the discriminator field for runtime validation.
|
|
230
|
+
*/
|
|
231
|
+
export const streamEventDataSchema = z.discriminatedUnion("type", [
|
|
232
|
+
resultEventDataSchema,
|
|
233
|
+
errorEventDataSchema,
|
|
234
|
+
streamEndEventDataSchema,
|
|
235
|
+
]);
|
|
236
|
+
//# sourceMappingURL=telemetryEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetryEvents.js","sourceRoot":"","sources":["../../src/schemas/telemetryEvents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,iBAAiB;IACjB,eAAe;IACf,iBAAiB;IACjB,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,OAAO;IACP,WAAW;IACX,YAAY;CACN,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,SAAS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AC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE;IAC7D,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IACnD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC9B,CAAC;CACL,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC9D,qBAAqB;IACrB,oBAAoB;IACpB,wBAAwB;CAC3B,CAAC,CAAC"}
|
|
@@ -2,10 +2,13 @@ import type { TypeOf } from "zod";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
export declare const UserContextSchema: z.ZodObject<{
|
|
4
4
|
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
|
|
5
|
+
signerWallet: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
|
|
5
6
|
}, "strict", z.ZodTypeAny, {
|
|
6
7
|
address: `0x${string}`;
|
|
8
|
+
signerWallet?: `0x${string}` | undefined;
|
|
7
9
|
}, {
|
|
8
10
|
address: string;
|
|
11
|
+
signerWallet?: string | undefined;
|
|
9
12
|
}>;
|
|
10
13
|
export type UserContext = TypeOf<typeof UserContextSchema>;
|
|
11
14
|
//# sourceMappingURL=userContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userContext.d.ts","sourceRoot":"","sources":["../../src/schemas/userContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"userContext.d.ts","sourceRoot":"","sources":["../../src/schemas/userContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;;EAQjB,CAAC;AAEd,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -3,6 +3,10 @@ import { z } from "zod";
|
|
|
3
3
|
export const UserContextSchema = z
|
|
4
4
|
.object({
|
|
5
5
|
address: z.string().refine(isAddress, { message: "Invalid address" }),
|
|
6
|
+
signerWallet: z
|
|
7
|
+
.string()
|
|
8
|
+
.refine(isAddress, { message: "Invalid signer wallet address" })
|
|
9
|
+
.optional(),
|
|
6
10
|
})
|
|
7
11
|
.strict();
|
|
8
12
|
//# sourceMappingURL=userContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userContext.js","sourceRoot":"","sources":["../../src/schemas/userContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC7B,MAAM,CAAC;IACJ,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"userContext.js","sourceRoot":"","sources":["../../src/schemas/userContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC7B,MAAM,CAAC;IACJ,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;IACrE,YAAY,EAAE,CAAC;SACV,MAAM,EAAE;SACR,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;SAC/D,QAAQ,EAAE;CAClB,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { IllaToolErrorData, IllaToolExecutionErrorData, IllaToolInputErrorData } from "../internal.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an error that occurred during tool call validation or execution.
|
|
4
|
+
* This is a structured error class that distinguishes between input validation
|
|
5
|
+
* errors and execution errors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Create an input validation error
|
|
10
|
+
* const inputError = IllaToolError.input('call-123', 'tokenTransfer', [
|
|
11
|
+
* { path: 'amount', message: 'Amount is required' }
|
|
12
|
+
* ]);
|
|
13
|
+
*
|
|
14
|
+
* // Create an execution error
|
|
15
|
+
* const execError = IllaToolError.execution('call-123', 'tokenTransfer', 'Network timeout');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class IllaToolError {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly data: IllaToolErrorData;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new IllaToolError instance
|
|
24
|
+
* @param id - The tool call ID this error is associated with
|
|
25
|
+
* @param name - The name of the tool/action that errored
|
|
26
|
+
* @param data - The structured error data
|
|
27
|
+
*/
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* The type of error ("input" or "execution")
|
|
31
|
+
*/
|
|
32
|
+
get type(): "input" | "execution";
|
|
33
|
+
/**
|
|
34
|
+
* Creates an input validation error
|
|
35
|
+
* @param id - The tool call ID
|
|
36
|
+
* @param name - The tool/action name
|
|
37
|
+
* @param errors - Array of validation errors with path and message
|
|
38
|
+
* @returns A new IllaToolError representing input validation failure
|
|
39
|
+
*/
|
|
40
|
+
static input(id: string, name: string, errors: Array<{
|
|
41
|
+
path: string;
|
|
42
|
+
message: string;
|
|
43
|
+
}>): IllaToolError;
|
|
44
|
+
/**
|
|
45
|
+
* Creates an execution error
|
|
46
|
+
* @param id - The tool call ID
|
|
47
|
+
* @param name - The tool/action name
|
|
48
|
+
* @param message - Human-readable error message
|
|
49
|
+
* @param details - Optional additional error details
|
|
50
|
+
* @returns A new IllaToolError representing execution failure
|
|
51
|
+
*/
|
|
52
|
+
static execution(id: string, name: string, message: string, details?: unknown): IllaToolError;
|
|
53
|
+
/**
|
|
54
|
+
* Parses and validates unknown input to create an IllaToolError instance.
|
|
55
|
+
* Expects an object with id, name, and data properties.
|
|
56
|
+
*
|
|
57
|
+
* @param input - Unknown input to parse
|
|
58
|
+
* @returns A new IllaToolError instance
|
|
59
|
+
* @throws ZodError if the input doesn't match the expected schema
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const error = IllaToolError.parse({
|
|
64
|
+
* id: 'call-123',
|
|
65
|
+
* name: 'tokenTransfer',
|
|
66
|
+
* data: { type: 'execution', message: 'Failed' }
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
static parse(input: unknown): IllaToolError;
|
|
71
|
+
/**
|
|
72
|
+
* Parses error data and creates an IllaToolError with the provided id and name.
|
|
73
|
+
* Useful when reconstructing from IllaToolOutcome where id/name are separate.
|
|
74
|
+
*
|
|
75
|
+
* @param id - The tool call ID
|
|
76
|
+
* @param name - The tool/action name
|
|
77
|
+
* @param data - Unknown error data to parse
|
|
78
|
+
* @returns A new IllaToolError instance
|
|
79
|
+
* @throws ZodError if the data doesn't match the expected schema
|
|
80
|
+
*/
|
|
81
|
+
static parseData(id: string, name: string, data: unknown): IllaToolError;
|
|
82
|
+
/**
|
|
83
|
+
* Check if this is an input validation error
|
|
84
|
+
*/
|
|
85
|
+
isInputError(): this is IllaToolError & {
|
|
86
|
+
data: IllaToolInputErrorData;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Check if this is an execution error
|
|
90
|
+
*/
|
|
91
|
+
isExecutionError(): this is IllaToolError & {
|
|
92
|
+
data: IllaToolExecutionErrorData;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Get the validation errors if this is an input error
|
|
96
|
+
* @returns Array of validation errors or undefined if not an input error
|
|
97
|
+
*/
|
|
98
|
+
getValidationErrors(): Array<{
|
|
99
|
+
path: string;
|
|
100
|
+
message: string;
|
|
101
|
+
}> | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Get the error message
|
|
104
|
+
* @returns The error message (for execution errors) or a summary of validation errors
|
|
105
|
+
*/
|
|
106
|
+
getMessage(): string;
|
|
107
|
+
/**
|
|
108
|
+
* Convert to a plain JSON object for serialization
|
|
109
|
+
* @returns The full error object
|
|
110
|
+
*/
|
|
111
|
+
toJSON(): {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
data: IllaToolErrorData;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=IllaToolError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IllaToolError.d.ts","sourceRoot":"","sources":["../../src/tools/IllaToolError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACzB,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAa;aAQF,EAAE,EAAE,MAAM;aACV,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,iBAAiB;IAT3C;;;;;OAKG;IACH,OAAO;IAMP;;OAEG;IACH,IAAW,IAAI,IAAI,OAAO,GAAG,WAAW,CAEvC;IAED;;;;;;OAMG;WACW,KAAK,CACf,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GACjD,aAAa;IAOhB;;;;;;;OAOG;WACW,SAAS,CACnB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,GAClB,aAAa;IAQhB;;;;;;;;;;;;;;;;OAgBG;WACW,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa;IAKlD;;;;;;;;;OASG;WACW,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,aAAa;IAK/E;;OAEG;IACI,YAAY,IAAI,IAAI,IAAI,aAAa,GAAG;QAAE,IAAI,EAAE,sBAAsB,CAAA;KAAE;IAI/E;;OAEG;IACI,gBAAgB,IAAI,IAAI,IAAI,aAAa,GAAG;QAAE,IAAI,EAAE,0BAA0B,CAAA;KAAE;IAIvF;;;OAGG;IACI,mBAAmB,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS;IAOlF;;;OAGG;IACI,UAAU,IAAI,MAAM;IAQ3B;;;OAGG;IACI,MAAM,IAAI;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE;CAOzE"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { IllaToolErrorDataSchema, IllaToolErrorSchema } from "../internal.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an error that occurred during tool call validation or execution.
|
|
4
|
+
* This is a structured error class that distinguishes between input validation
|
|
5
|
+
* errors and execution errors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Create an input validation error
|
|
10
|
+
* const inputError = IllaToolError.input('call-123', 'tokenTransfer', [
|
|
11
|
+
* { path: 'amount', message: 'Amount is required' }
|
|
12
|
+
* ]);
|
|
13
|
+
*
|
|
14
|
+
* // Create an execution error
|
|
15
|
+
* const execError = IllaToolError.execution('call-123', 'tokenTransfer', 'Network timeout');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class IllaToolError {
|
|
19
|
+
id;
|
|
20
|
+
name;
|
|
21
|
+
data;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new IllaToolError instance
|
|
24
|
+
* @param id - The tool call ID this error is associated with
|
|
25
|
+
* @param name - The name of the tool/action that errored
|
|
26
|
+
* @param data - The structured error data
|
|
27
|
+
*/
|
|
28
|
+
constructor(id, name, data) {
|
|
29
|
+
this.id = id;
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.data = data;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The type of error ("input" or "execution")
|
|
35
|
+
*/
|
|
36
|
+
get type() {
|
|
37
|
+
return this.data.type;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an input validation error
|
|
41
|
+
* @param id - The tool call ID
|
|
42
|
+
* @param name - The tool/action name
|
|
43
|
+
* @param errors - Array of validation errors with path and message
|
|
44
|
+
* @returns A new IllaToolError representing input validation failure
|
|
45
|
+
*/
|
|
46
|
+
static input(id, name, errors) {
|
|
47
|
+
return new IllaToolError(id, name, {
|
|
48
|
+
type: "input",
|
|
49
|
+
errors,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates an execution error
|
|
54
|
+
* @param id - The tool call ID
|
|
55
|
+
* @param name - The tool/action name
|
|
56
|
+
* @param message - Human-readable error message
|
|
57
|
+
* @param details - Optional additional error details
|
|
58
|
+
* @returns A new IllaToolError representing execution failure
|
|
59
|
+
*/
|
|
60
|
+
static execution(id, name, message, details) {
|
|
61
|
+
return new IllaToolError(id, name, {
|
|
62
|
+
type: "execution",
|
|
63
|
+
message,
|
|
64
|
+
details,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parses and validates unknown input to create an IllaToolError instance.
|
|
69
|
+
* Expects an object with id, name, and data properties.
|
|
70
|
+
*
|
|
71
|
+
* @param input - Unknown input to parse
|
|
72
|
+
* @returns A new IllaToolError instance
|
|
73
|
+
* @throws ZodError if the input doesn't match the expected schema
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const error = IllaToolError.parse({
|
|
78
|
+
* id: 'call-123',
|
|
79
|
+
* name: 'tokenTransfer',
|
|
80
|
+
* data: { type: 'execution', message: 'Failed' }
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
static parse(input) {
|
|
85
|
+
const parsed = IllaToolErrorSchema.parse(input);
|
|
86
|
+
return new IllaToolError(parsed.id, parsed.name, parsed.data);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parses error data and creates an IllaToolError with the provided id and name.
|
|
90
|
+
* Useful when reconstructing from IllaToolOutcome where id/name are separate.
|
|
91
|
+
*
|
|
92
|
+
* @param id - The tool call ID
|
|
93
|
+
* @param name - The tool/action name
|
|
94
|
+
* @param data - Unknown error data to parse
|
|
95
|
+
* @returns A new IllaToolError instance
|
|
96
|
+
* @throws ZodError if the data doesn't match the expected schema
|
|
97
|
+
*/
|
|
98
|
+
static parseData(id, name, data) {
|
|
99
|
+
const parsedData = IllaToolErrorDataSchema.parse(data);
|
|
100
|
+
return new IllaToolError(id, name, parsedData);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if this is an input validation error
|
|
104
|
+
*/
|
|
105
|
+
isInputError() {
|
|
106
|
+
return this.data.type === "input";
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check if this is an execution error
|
|
110
|
+
*/
|
|
111
|
+
isExecutionError() {
|
|
112
|
+
return this.data.type === "execution";
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get the validation errors if this is an input error
|
|
116
|
+
* @returns Array of validation errors or undefined if not an input error
|
|
117
|
+
*/
|
|
118
|
+
getValidationErrors() {
|
|
119
|
+
if (this.isInputError()) {
|
|
120
|
+
return this.data.errors;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get the error message
|
|
126
|
+
* @returns The error message (for execution errors) or a summary of validation errors
|
|
127
|
+
*/
|
|
128
|
+
getMessage() {
|
|
129
|
+
if (this.data.type === "execution") {
|
|
130
|
+
return this.data.message;
|
|
131
|
+
}
|
|
132
|
+
const errors = this.data.errors;
|
|
133
|
+
return errors.map((error) => `${error.path}: ${error.message}`).join(", ");
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert to a plain JSON object for serialization
|
|
137
|
+
* @returns The full error object
|
|
138
|
+
*/
|
|
139
|
+
toJSON() {
|
|
140
|
+
return {
|
|
141
|
+
id: this.id,
|
|
142
|
+
name: this.name,
|
|
143
|
+
data: this.data,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=IllaToolError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IllaToolError.js","sourceRoot":"","sources":["../../src/tools/IllaToolError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,aAAa;IAQF;IACA;IACA;IATpB;;;;;OAKG;IACH,YACoB,EAAU,EACV,IAAY,EACZ,IAAuB;QAFvB,OAAE,GAAF,EAAE,CAAQ;QACV,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAmB;IACxC,CAAC;IAEJ;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CACf,EAAU,EACV,IAAY,EACZ,MAAgD;QAEhD,OAAO,IAAI,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE;YAC/B,IAAI,EAAE,OAAO;YACb,MAAM;SACT,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,SAAS,CACnB,EAAU,EACV,IAAY,EACZ,OAAe,EACf,OAAiB;QAEjB,OAAO,IAAI,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE;YAC/B,IAAI,EAAE,WAAW;YACjB,OAAO;YACP,OAAO;SACV,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACI,MAAM,CAAC,KAAK,CAAC,KAAc;QAC9B,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,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