@chaoslabs/ai-sdk 0.0.10 → 1.0.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,373 @@
1
+ // Chaos AI SDK - Type Guards
2
+ //
3
+ // Runtime type guards for narrowing discriminated union types.
4
+ // These enable TypeScript to infer specific types after a check.
5
+ import { PRIMITIVE_SWAP, PRIMITIVE_BRIDGE, PRIMITIVE_SUPPLY, PRIMITIVE_WITHDRAW, PRIMITIVE_BORROW, PRIMITIVE_REPAY, PRIMITIVE_STAKE, PRIMITIVE_UNSTAKE, PRIMITIVE_CLAIM, PRIMITIVE_ADD_LIQUIDITY, PRIMITIVE_REMOVE_LIQUIDITY, PRIMITIVE_OPEN_POSITION, PRIMITIVE_CLOSE_POSITION, PRIMITIVE_DEPOSIT, PRIMITIVE_MINT, PRIMITIVE_BURN, PRIMITIVE_RESTAKE, PRIMITIVE_APPROVE, PRIMITIVE_TRANSFER, PRIMITIVE_WRAP, PRIMITIVE_UNWRAP, } from './primitives.js';
6
+ // ============================================================================
7
+ // Primitive Type Guards
8
+ // ============================================================================
9
+ /**
10
+ * Type guard to check if a primitive is a swap operation.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * if (isSwapPrimitive(primitive)) {
15
+ * // TypeScript knows primitive.params is SwapParams
16
+ * console.log(primitive.params.token_in);
17
+ * console.log(primitive.params.token_out);
18
+ * }
19
+ * ```
20
+ */
21
+ export function isSwapPrimitive(p) {
22
+ return p.primitive === PRIMITIVE_SWAP;
23
+ }
24
+ /**
25
+ * Type guard to check if a primitive is a bridge operation.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * if (isBridgePrimitive(primitive)) {
30
+ * // TypeScript knows primitive.params is BridgeParams
31
+ * console.log(primitive.params.from_chain);
32
+ * console.log(primitive.params.to_chain);
33
+ * }
34
+ * ```
35
+ */
36
+ export function isBridgePrimitive(p) {
37
+ return p.primitive === PRIMITIVE_BRIDGE;
38
+ }
39
+ /**
40
+ * Type guard to check if a primitive is a supply operation.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * if (isSupplyPrimitive(primitive)) {
45
+ * // TypeScript knows primitive.params is LendingParams
46
+ * console.log(primitive.params.asset);
47
+ * console.log(primitive.params.amount);
48
+ * }
49
+ * ```
50
+ */
51
+ export function isSupplyPrimitive(p) {
52
+ return p.primitive === PRIMITIVE_SUPPLY;
53
+ }
54
+ /**
55
+ * Type guard to check if a primitive is a withdraw operation.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * if (isWithdrawPrimitive(primitive)) {
60
+ * // TypeScript knows primitive.params is LendingParams
61
+ * console.log(primitive.params.asset);
62
+ * }
63
+ * ```
64
+ */
65
+ export function isWithdrawPrimitive(p) {
66
+ return p.primitive === PRIMITIVE_WITHDRAW;
67
+ }
68
+ /**
69
+ * Type guard to check if a primitive is a borrow operation.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * if (isBorrowPrimitive(primitive)) {
74
+ * // TypeScript knows primitive.params is LendingParams
75
+ * console.log(primitive.params.asset);
76
+ * }
77
+ * ```
78
+ */
79
+ export function isBorrowPrimitive(p) {
80
+ return p.primitive === PRIMITIVE_BORROW;
81
+ }
82
+ /**
83
+ * Type guard to check if a primitive is a repay operation.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * if (isRepayPrimitive(primitive)) {
88
+ * // TypeScript knows primitive.params is LendingParams
89
+ * console.log(primitive.params.asset);
90
+ * }
91
+ * ```
92
+ */
93
+ export function isRepayPrimitive(p) {
94
+ return p.primitive === PRIMITIVE_REPAY;
95
+ }
96
+ /**
97
+ * Type guard to check if a primitive is a stake operation.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * if (isStakePrimitive(primitive)) {
102
+ * // TypeScript knows primitive.params is StakingParams
103
+ * console.log(primitive.params.amount);
104
+ * console.log(primitive.params.protocol);
105
+ * }
106
+ * ```
107
+ */
108
+ export function isStakePrimitive(p) {
109
+ return p.primitive === PRIMITIVE_STAKE;
110
+ }
111
+ /**
112
+ * Type guard to check if a primitive is an unstake operation.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * if (isUnstakePrimitive(primitive)) {
117
+ * // TypeScript knows primitive.params is StakingParams
118
+ * console.log(primitive.params.amount);
119
+ * }
120
+ * ```
121
+ */
122
+ export function isUnstakePrimitive(p) {
123
+ return p.primitive === PRIMITIVE_UNSTAKE;
124
+ }
125
+ /**
126
+ * Type guard to check if a primitive is a claim operation.
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * if (isClaimPrimitive(primitive)) {
131
+ * // TypeScript knows primitive.params is ClaimParams
132
+ * console.log(primitive.params.protocol);
133
+ * }
134
+ * ```
135
+ */
136
+ export function isClaimPrimitive(p) {
137
+ return p.primitive === PRIMITIVE_CLAIM;
138
+ }
139
+ /**
140
+ * Type guard to check if a primitive is an add liquidity operation.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * if (isAddLiquidityPrimitive(primitive)) {
145
+ * // TypeScript knows primitive.params is LiquidityParams
146
+ * console.log(primitive.params.token_a);
147
+ * console.log(primitive.params.token_b);
148
+ * }
149
+ * ```
150
+ */
151
+ export function isAddLiquidityPrimitive(p) {
152
+ return p.primitive === PRIMITIVE_ADD_LIQUIDITY;
153
+ }
154
+ /**
155
+ * Type guard to check if a primitive is a remove liquidity operation.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * if (isRemoveLiquidityPrimitive(primitive)) {
160
+ * // TypeScript knows primitive.params is LiquidityParams
161
+ * console.log(primitive.params.token_a);
162
+ * }
163
+ * ```
164
+ */
165
+ export function isRemoveLiquidityPrimitive(p) {
166
+ return p.primitive === PRIMITIVE_REMOVE_LIQUIDITY;
167
+ }
168
+ /**
169
+ * Type guard to check if a primitive is an open position operation.
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * if (isOpenPositionPrimitive(primitive)) {
174
+ * // TypeScript knows primitive.params is PositionParams
175
+ * console.log(primitive.params.market);
176
+ * console.log(primitive.params.side);
177
+ * }
178
+ * ```
179
+ */
180
+ export function isOpenPositionPrimitive(p) {
181
+ return p.primitive === PRIMITIVE_OPEN_POSITION;
182
+ }
183
+ /**
184
+ * Type guard to check if a primitive is a close position operation.
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * if (isClosePositionPrimitive(primitive)) {
189
+ * // TypeScript knows primitive.params is PositionParams
190
+ * console.log(primitive.params.market);
191
+ * }
192
+ * ```
193
+ */
194
+ export function isClosePositionPrimitive(p) {
195
+ return p.primitive === PRIMITIVE_CLOSE_POSITION;
196
+ }
197
+ /**
198
+ * Type guard to check if a primitive is a deposit operation.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * if (isDepositPrimitive(primitive)) {
203
+ * // TypeScript knows primitive.params is DepositParams
204
+ * console.log(primitive.params.vault);
205
+ * }
206
+ * ```
207
+ */
208
+ export function isDepositPrimitive(p) {
209
+ return p.primitive === PRIMITIVE_DEPOSIT;
210
+ }
211
+ /**
212
+ * Type guard to check if a primitive is a mint operation.
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * if (isMintPrimitive(primitive)) {
217
+ * // TypeScript knows primitive.params is MintParams
218
+ * console.log(primitive.params.asset);
219
+ * console.log(primitive.params.collateral);
220
+ * }
221
+ * ```
222
+ */
223
+ export function isMintPrimitive(p) {
224
+ return p.primitive === PRIMITIVE_MINT;
225
+ }
226
+ /**
227
+ * Type guard to check if a primitive is a burn operation.
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * if (isBurnPrimitive(primitive)) {
232
+ * // TypeScript knows primitive.params is MintParams
233
+ * console.log(primitive.params.asset);
234
+ * }
235
+ * ```
236
+ */
237
+ export function isBurnPrimitive(p) {
238
+ return p.primitive === PRIMITIVE_BURN;
239
+ }
240
+ /**
241
+ * Type guard to check if a primitive is a restake operation.
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * if (isRestakePrimitive(primitive)) {
246
+ * // TypeScript knows primitive.params is StakingParams
247
+ * console.log(primitive.params.amount);
248
+ * console.log(primitive.params.operator);
249
+ * }
250
+ * ```
251
+ */
252
+ export function isRestakePrimitive(p) {
253
+ return p.primitive === PRIMITIVE_RESTAKE;
254
+ }
255
+ /**
256
+ * Type guard to check if a primitive is an approve operation.
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * if (isApprovePrimitive(primitive)) {
261
+ * // TypeScript knows primitive.params is ApproveParams
262
+ * console.log(primitive.params.token);
263
+ * console.log(primitive.params.spender);
264
+ * }
265
+ * ```
266
+ */
267
+ export function isApprovePrimitive(p) {
268
+ return p.primitive === PRIMITIVE_APPROVE;
269
+ }
270
+ /**
271
+ * Type guard to check if a primitive is a transfer operation.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * if (isTransferPrimitive(primitive)) {
276
+ * // TypeScript knows primitive.params is TransferParams
277
+ * console.log(primitive.params.token);
278
+ * console.log(primitive.params.to);
279
+ * }
280
+ * ```
281
+ */
282
+ export function isTransferPrimitive(p) {
283
+ return p.primitive === PRIMITIVE_TRANSFER;
284
+ }
285
+ /**
286
+ * Type guard to check if a primitive is a wrap operation.
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * if (isWrapPrimitive(primitive)) {
291
+ * // TypeScript knows primitive.params is WrapParams
292
+ * console.log(primitive.params.amount);
293
+ * }
294
+ * ```
295
+ */
296
+ export function isWrapPrimitive(p) {
297
+ return p.primitive === PRIMITIVE_WRAP;
298
+ }
299
+ /**
300
+ * Type guard to check if a primitive is an unwrap operation.
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * if (isUnwrapPrimitive(primitive)) {
305
+ * // TypeScript knows primitive.params is WrapParams
306
+ * console.log(primitive.params.amount);
307
+ * }
308
+ * ```
309
+ */
310
+ export function isUnwrapPrimitive(p) {
311
+ return p.primitive === PRIMITIVE_UNWRAP;
312
+ }
313
+ /**
314
+ * Type guard to check if a chart block is a pie chart.
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * if (isPieChartBlock(block)) {
319
+ * // TypeScript knows block.chartType is 'pie'
320
+ * const data = block.data; // [[label, value], ...]
321
+ * }
322
+ * ```
323
+ */
324
+ export function isPieChartBlock(block) {
325
+ return block.chartType === 'pie';
326
+ }
327
+ /**
328
+ * Type guard to check if a chart block is a timeseries chart.
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * if (isTimeseriesChartBlock(block)) {
333
+ * // TypeScript knows block.chartType is 'timeseries'
334
+ * const series = block.series;
335
+ * }
336
+ * ```
337
+ */
338
+ export function isTimeseriesChartBlock(block) {
339
+ return block.chartType === 'timeseries';
340
+ }
341
+ // ============================================================================
342
+ // Block Type Guards
343
+ // ============================================================================
344
+ /**
345
+ * Type guard to check if a block is an info block.
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * if (isInfoBlock(block)) {
350
+ * // TypeScript knows block is InfoBlock
351
+ * console.log(block.message);
352
+ * console.log(block.severity);
353
+ * }
354
+ * ```
355
+ */
356
+ export function isInfoBlock(block) {
357
+ return block.type === 'info';
358
+ }
359
+ /**
360
+ * Type guard to check if a block is a code block.
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * if (isCodeBlock(block)) {
365
+ * // TypeScript knows block is CodeBlock
366
+ * console.log(block.code);
367
+ * console.log(block.language);
368
+ * }
369
+ * ```
370
+ */
371
+ export function isCodeBlock(block) {
372
+ return block.type === 'code';
373
+ }
package/dist/types.d.ts CHANGED
@@ -11,6 +11,8 @@ export interface ChaosConfig {
11
11
  /** Use native http/https modules for streaming instead of fetch (defaults to true) */
12
12
  useNativeHttp?: boolean;
13
13
  }
14
+ import type { Primitive } from './primitives.js';
15
+ export type { Primitive } from './primitives.js';
14
16
  /**
15
17
  * Parameters for creating a response.
16
18
  */
@@ -42,9 +44,18 @@ export interface CreateResponseParams {
42
44
  */
43
45
  export interface InputItem {
44
46
  type: 'message';
45
- role: 'user' | 'system';
47
+ role: 'user' | 'system' | 'assistant';
46
48
  content: string;
47
49
  }
50
+ /**
51
+ * Wallet information for multi-chain support.
52
+ */
53
+ export interface WalletInfo {
54
+ /** Wallet address */
55
+ address: string;
56
+ /** Chain name (e.g., 'ethereum', 'base', 'solana') */
57
+ chain: string;
58
+ }
48
59
  /**
49
60
  * Request metadata including user and session identifiers.
50
61
  */
@@ -53,8 +64,8 @@ export interface RequestMetadata {
53
64
  user_id: string;
54
65
  /** Session identifier for conversation continuity */
55
66
  session_id: string;
56
- /** Wallet identifier (required for WALLET_MODEL) */
57
- wallet_id: string;
67
+ /** Array of wallet addresses across multiple chains */
68
+ wallets?: WalletInfo[];
58
69
  }
59
70
  /**
60
71
  * A response from the Chaos API.
@@ -103,55 +114,26 @@ export interface ChaosBlock {
103
114
  * Union of all block types.
104
115
  * Note: SDK adds 'type' field for consistency, server uses 'blockType'.
105
116
  */
106
- export type Block = MarkdownBlock | TableBlock | ChartBlock | TransactionActionBlock | InteractiveBlock;
117
+ export type Block = MarkdownBlock | TableBlock | ChartBlock | PieChartBlock | TimeseriesChartBlock | TransactionActionBlock | InteractiveBlock | InfoBlock | CodeBlock;
107
118
  /**
108
119
  * Markdown content block.
109
120
  * Server sends: { content: string } (no blockType)
110
121
  */
111
122
  export interface MarkdownBlock {
112
123
  type: 'markdown';
124
+ blockType: 'markdown';
113
125
  content: string;
114
126
  }
115
- /**
116
- * Table column type.
117
- */
118
- export type TableColumnType = 'text' | 'number' | 'currency' | 'percentage' | 'token' | 'date' | 'link' | 'boolean';
119
- /**
120
- * Table sort direction.
121
- */
122
- export type TableSortDirection = 'asc' | 'desc';
123
- /**
124
- * Table column configuration.
125
- */
126
- export interface TableColumnConfig {
127
- type?: TableColumnType;
128
- sortable?: boolean;
129
- align?: 'left' | 'center' | 'right';
130
- width?: string;
131
- }
132
127
  /**
133
128
  * Table visualization block.
134
- * Server sends: { blockType: "table", ... }
135
129
  */
136
130
  export interface TableBlock {
137
131
  type: 'table';
138
- blockType?: 'table';
139
- title: string;
132
+ blockType: 'table';
133
+ title?: string;
140
134
  tableHeaders: string[];
141
- tableRows: Array<Array<string | number | boolean | null>>;
142
- tableHeadersTypes?: Record<string, TableColumnType | 'currency' | 'percentage'> | null;
143
- tableColumnConfigs?: Record<string, TableColumnConfig> | null;
144
- tableHeadersMetadata?: Record<string, {
145
- type?: string;
146
- }> | null;
147
- sourceName?: string | null;
148
- defaultSortColumn?: string | null;
149
- defaultSortDirection?: TableSortDirection | null;
150
- maxRows?: number | null;
151
- searchable?: boolean | null;
152
- exportable?: boolean | null;
153
- tool_params?: unknown;
154
- tool_name?: string | null;
135
+ tableRows: Array<Array<unknown>>;
136
+ tableHeadersMetadata?: Record<string, Record<string, unknown>>;
155
137
  }
156
138
  /**
157
139
  * Chart series data point.
@@ -189,66 +171,44 @@ export interface ChartAxis {
189
171
  * Chart visualization block.
190
172
  * Server sends: { blockType: "chart", data: [[label, value], ...], ... }
191
173
  */
192
- export interface ChartBlock {
193
- type: 'chart';
194
- blockType?: 'chart';
195
- title: string;
196
- chartType?: 'pie' | 'donut' | 'line' | 'area' | 'bar' | 'timeseries' | null;
197
- series?: ChartSeries[] | null;
198
- segments?: ChartSegment[] | null;
199
- /** Legacy data format from server: [[label, value], ...] */
200
- data?: Array<[string, number]> | null;
201
- categories?: string[] | null;
202
- xAxis?: ChartAxis | null;
203
- yAxis?: ChartAxis | null;
204
- isCurrency?: boolean | null;
205
- sourceName?: string | null;
206
- timeframe?: string | null;
207
- tool_params?: unknown;
208
- tool_name?: string | null;
209
- }
210
- /**
211
- * Icon for primitive display.
212
- */
213
- export interface PrimitiveIcon {
214
- type: string;
215
- value: string;
216
- }
217
- /**
218
- * Line item for primitive display.
219
- */
220
- export interface PrimitiveLineItem {
221
- label: string;
222
- value: string;
223
- icon?: PrimitiveIcon;
224
- }
174
+ export type ChartBlock = PieChartBlock | TimeseriesChartBlock;
225
175
  /**
226
- * Display information for a primitive.
176
+ * Pie chart visualization block.
227
177
  */
228
- export interface PrimitiveDisplay {
229
- headline?: string;
230
- action_verb?: string;
231
- primary_icon?: PrimitiveIcon;
232
- secondary_icon?: PrimitiveIcon;
233
- line_items?: PrimitiveLineItem[];
178
+ export interface PieChartBlock {
179
+ type: 'chart';
180
+ blockType: 'chart';
181
+ chartType: 'pie';
182
+ title?: string;
183
+ data: Array<[string, number]>;
184
+ isCurrency?: boolean;
234
185
  }
235
186
  /**
236
- * A primitive action (swap, supply, borrow, etc.)
187
+ * Timeseries chart visualization block.
237
188
  */
238
- export interface Primitive {
239
- primitive: string;
240
- params?: Record<string, unknown>;
241
- display?: PrimitiveDisplay;
189
+ export interface TimeseriesChartBlock {
190
+ type: 'chart';
191
+ blockType: 'chart';
192
+ chartType: 'timeseries';
193
+ title?: string;
194
+ series: Record<string, Array<{
195
+ timestamp: number;
196
+ value: number;
197
+ }>>;
198
+ captions?: Array<Record<string, unknown>>;
199
+ titleCryptoIcons?: Array<Record<string, unknown>>;
200
+ isCurrency?: boolean;
242
201
  }
243
202
  /**
244
203
  * Raw transaction data from server.
245
204
  */
246
205
  export interface RawTransaction {
247
- to?: string;
248
- data?: string;
249
- value?: string;
250
- chainId?: number;
251
- description?: string;
206
+ to: string;
207
+ data: string;
208
+ value: string;
209
+ chainId: number;
210
+ gasEstimate?: number;
211
+ description: string;
252
212
  contractName?: string;
253
213
  contractVerified?: boolean;
254
214
  protocolName?: string;
@@ -258,8 +218,9 @@ export interface RawTransaction {
258
218
  * Group of transactions.
259
219
  */
260
220
  export interface TransactionGroup {
261
- transactions?: RawTransaction[];
262
- requiresApproval?: boolean;
221
+ primitive: string;
222
+ transactions: RawTransaction[];
223
+ requiresApproval: boolean;
263
224
  verificationUnavailable?: boolean;
264
225
  }
265
226
  /**
@@ -267,7 +228,7 @@ export interface TransactionGroup {
267
228
  */
268
229
  export interface RiskInfoItem {
269
230
  id?: string;
270
- severity?: 'info' | 'warning' | 'error' | 'critical';
231
+ severity?: 'block' | 'warn' | 'info';
271
232
  title?: string;
272
233
  message?: string;
273
234
  }
@@ -275,9 +236,9 @@ export interface RiskInfoItem {
275
236
  * Risk assessment for a transaction.
276
237
  */
277
238
  export interface Risks {
278
- level?: string;
279
- blockers?: string[];
280
- warnings?: string[];
239
+ level?: 'low' | 'medium' | 'high' | 'critical';
240
+ blockers?: RiskInfoItem[];
241
+ warnings?: RiskInfoItem[];
281
242
  info?: RiskInfoItem[];
282
243
  }
283
244
  /**
@@ -285,18 +246,17 @@ export interface Risks {
285
246
  * Server sends: { blockType: "transaction_action", primitives: [...], ... }
286
247
  */
287
248
  export interface TransactionActionBlock {
288
- type: 'transaction_action';
289
- blockType?: 'transaction_action';
290
- value?: Record<string, unknown>;
249
+ type: 'action';
250
+ blockType: 'transaction_action';
251
+ metadata: Record<string, unknown>;
252
+ needs_confirmation: boolean;
253
+ notes: string;
254
+ primitives: Primitive[];
255
+ references?: string[];
256
+ risks: Risks;
291
257
  sequence?: boolean;
292
- primitives?: Primitive[];
293
258
  transactions?: TransactionGroup[];
294
- needs_confirmation?: boolean;
295
- notes?: string;
296
- risks?: Risks;
297
- metadata?: Record<string, unknown>;
298
- tool_params?: unknown;
299
- tool_name?: string | null;
259
+ value?: Record<string, unknown>;
300
260
  }
301
261
  /**
302
262
  * Interactive option.
@@ -305,19 +265,36 @@ export interface InteractiveOption {
305
265
  id: string;
306
266
  label: string;
307
267
  description?: string;
308
- value?: unknown;
268
+ metadata?: Record<string, unknown>;
309
269
  }
310
270
  /**
311
271
  * Interactive block for user input.
312
- * Server sends: { blockType: "interactive", ... }
313
272
  */
314
273
  export interface InteractiveBlock {
315
274
  type: 'interactive';
316
- blockType?: 'interactive';
317
- prompt?: string;
275
+ blockType: 'interactive';
276
+ title: string;
277
+ body?: string;
278
+ context?: string;
279
+ style: 'options' | 'confirm_cancel';
318
280
  options?: InteractiveOption[];
319
- allowCustom?: boolean;
320
- multiSelect?: boolean;
281
+ }
282
+ /**
283
+ * Info block for displaying informational messages.
284
+ */
285
+ export interface InfoBlock {
286
+ type: 'info';
287
+ content: string;
288
+ error?: string | null;
289
+ }
290
+ /**
291
+ * Code block for displaying formatted code.
292
+ */
293
+ export interface CodeBlock {
294
+ type: 'code';
295
+ blockType: 'code';
296
+ content: string;
297
+ language: string;
321
298
  }
322
299
  /**
323
300
  * Error information in a response.
package/dist/types.js CHANGED
@@ -43,7 +43,7 @@ export function isMarkdownBlock(block) {
43
43
  * Check if a block is a transaction action block.
44
44
  */
45
45
  export function isTransactionActionBlock(block) {
46
- return block.type === 'transaction_action';
46
+ return block.type === 'action';
47
47
  }
48
48
  /**
49
49
  * Check if a block is an interactive block.
@@ -114,6 +114,7 @@ export function hasBlockers(response) {
114
114
  const blocks = extractBlocks(response);
115
115
  return blocks.some((block) => isTransactionActionBlock(block) &&
116
116
  block.risks &&
117
- ((block.risks.level === 'high' || block.risks.level === 'critical') ||
117
+ (block.risks.level === 'high' ||
118
+ block.risks.level === 'critical' ||
118
119
  (block.risks.blockers && block.risks.blockers.length > 0)));
119
120
  }