@chaoslabs/ai-sdk 0.0.7 → 0.0.9
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/blocks.d.ts +108 -0
- package/dist/blocks.js +246 -0
- package/dist/conversation.d.ts +136 -0
- package/dist/conversation.js +230 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +26 -0
- package/dist/primitives.d.ts +157 -0
- package/dist/primitives.js +220 -0
- package/dist/schemas.d.ts +405 -97
- package/dist/schemas.js +47 -18
- package/package.json +2 -2
package/dist/schemas.js
CHANGED
|
@@ -52,11 +52,24 @@ export const ChartDataPointSchema = z.union([
|
|
|
52
52
|
z.object({ x: z.union([z.number(), z.string()]), y: z.number() }),
|
|
53
53
|
z.array(z.unknown()),
|
|
54
54
|
]);
|
|
55
|
+
// Array format series item (legacy)
|
|
55
56
|
export const ChartSeriesSchema = z.object({
|
|
56
57
|
name: z.string(),
|
|
57
58
|
data: z.array(ChartDataPointSchema),
|
|
58
59
|
color: z.string().optional(),
|
|
59
60
|
});
|
|
61
|
+
// Timeseries format: server sends series as { "24H": [{ label, data }, ...] }
|
|
62
|
+
export const TimeseriesSeriesItemSchema = z.object({
|
|
63
|
+
label: z.string(),
|
|
64
|
+
data: z.array(z.array(z.union([z.number(), z.string()]))), // [[timestamp, value], ...]
|
|
65
|
+
});
|
|
66
|
+
// Series can be either:
|
|
67
|
+
// - Array format: [{ name, data, color }, ...]
|
|
68
|
+
// - Object format (timeseries): { "24H": [{ label, data }, ...], "7D": [...] }
|
|
69
|
+
export const ChartSeriesFieldSchema = z.union([
|
|
70
|
+
z.array(ChartSeriesSchema),
|
|
71
|
+
z.record(z.string(), z.array(TimeseriesSeriesItemSchema)),
|
|
72
|
+
]);
|
|
60
73
|
export const ChartSegmentSchema = z.object({
|
|
61
74
|
label: z.string(),
|
|
62
75
|
value: z.number(),
|
|
@@ -74,7 +87,7 @@ export const ChartBlockSchema = z.object({
|
|
|
74
87
|
blockType: z.literal('chart'),
|
|
75
88
|
title: z.string(),
|
|
76
89
|
chartType: z.enum(['pie', 'donut', 'line', 'area', 'bar', 'timeseries']).optional().nullable(),
|
|
77
|
-
series:
|
|
90
|
+
series: ChartSeriesFieldSchema.nullish(),
|
|
78
91
|
segments: z.array(ChartSegmentSchema).optional().nullable(),
|
|
79
92
|
// Legacy data format from server: [[label, value], ...]
|
|
80
93
|
data: ChartLegacyDataSchema.optional().nullable(),
|
|
@@ -84,6 +97,8 @@ export const ChartBlockSchema = z.object({
|
|
|
84
97
|
isCurrency: z.boolean().optional().nullable(),
|
|
85
98
|
sourceName: z.string().optional().nullable(),
|
|
86
99
|
timeframe: z.string().optional().nullable(),
|
|
100
|
+
captions: z.array(z.object({ label: z.string(), value: z.string() })).nullish(),
|
|
101
|
+
titleCryptIcons: z.array(z.object({ name: z.string(), entity: z.string().optional() })).nullish(),
|
|
87
102
|
tool_params: z.unknown().optional().nullable(),
|
|
88
103
|
tool_name: z.string().optional().nullable(),
|
|
89
104
|
});
|
|
@@ -132,19 +147,31 @@ export const TransactionGroupSchema = z.object({
|
|
|
132
147
|
requiresApproval: z.boolean().optional(),
|
|
133
148
|
verificationUnavailable: z.boolean().optional(),
|
|
134
149
|
});
|
|
135
|
-
// Risk
|
|
136
|
-
export const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
// Risk impact (quantified risk details)
|
|
151
|
+
export const RiskImpactSchema = z.object({
|
|
152
|
+
metric: z.string(),
|
|
153
|
+
current: z.number().nullish(),
|
|
154
|
+
projected: z.number().nullish(),
|
|
155
|
+
threshold: z.number().nullish(),
|
|
156
|
+
at_risk_usd: z.number().nullish(),
|
|
157
|
+
liquidation_price: z.string().nullish(),
|
|
141
158
|
});
|
|
159
|
+
// Risk check item (used in blockers, warnings, info arrays)
|
|
160
|
+
export const RiskCheckSchema = z.object({
|
|
161
|
+
id: z.string(),
|
|
162
|
+
severity: z.enum(['block', 'warn', 'info']),
|
|
163
|
+
title: z.string(),
|
|
164
|
+
message: z.string(),
|
|
165
|
+
impact: RiskImpactSchema.nullish(),
|
|
166
|
+
});
|
|
167
|
+
// Legacy alias for backwards compatibility
|
|
168
|
+
export const RiskInfoItemSchema = RiskCheckSchema;
|
|
142
169
|
// Risks object
|
|
143
170
|
export const RisksSchema = z.object({
|
|
144
|
-
level: z.
|
|
145
|
-
blockers: z.array(
|
|
146
|
-
warnings: z.array(
|
|
147
|
-
info: z.array(
|
|
171
|
+
level: z.enum(['low', 'medium', 'high', 'critical']).nullish(),
|
|
172
|
+
blockers: z.array(RiskCheckSchema).nullish(),
|
|
173
|
+
warnings: z.array(RiskCheckSchema).nullish(),
|
|
174
|
+
info: z.array(RiskCheckSchema).nullish(),
|
|
148
175
|
});
|
|
149
176
|
export const TransactionActionBlockSchema = z.object({
|
|
150
177
|
blockType: z.literal('transaction_action'),
|
|
@@ -160,19 +187,21 @@ export const TransactionActionBlockSchema = z.object({
|
|
|
160
187
|
tool_name: z.string().optional().nullable(),
|
|
161
188
|
});
|
|
162
189
|
// --- Interactive Block ---
|
|
163
|
-
// Server sends: { blockType: "interactive",
|
|
190
|
+
// Server sends: { blockType: "interactive", title, body?, context?, style?, options? }
|
|
191
|
+
// Note: Using .nullish() to accept both null and undefined (Python sends null for None)
|
|
164
192
|
export const InteractiveOptionSchema = z.object({
|
|
165
193
|
id: z.string(),
|
|
166
194
|
label: z.string(),
|
|
167
|
-
description: z.string().
|
|
168
|
-
|
|
195
|
+
description: z.string().nullish(), // Accept null OR undefined
|
|
196
|
+
metadata: z.record(z.string(), z.unknown()).nullish(),
|
|
169
197
|
});
|
|
170
198
|
export const InteractiveBlockSchema = z.object({
|
|
171
199
|
blockType: z.literal('interactive'),
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
title: z.string(), // Required, matches Python
|
|
201
|
+
body: z.string().nullish(), // Optional, matches Python
|
|
202
|
+
context: z.string().nullish(), // Optional, matches Python
|
|
203
|
+
style: z.enum(['options', 'confirm_cancel']).nullish(),
|
|
204
|
+
options: z.array(InteractiveOptionSchema).nullish(),
|
|
176
205
|
});
|
|
177
206
|
// ============================================================================
|
|
178
207
|
// Block Detection and Parsing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaoslabs/ai-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Chaos AI SDK - TypeScript SDK for the Chaos AI API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"bugs": {
|
|
48
48
|
"url": "https://github.com/ChaosLabsInc/ai-sdk/issues"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"dependencies": {
|
|
51
51
|
"zod": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|