@chaoslabs/ai-sdk 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -3,7 +3,12 @@
3
3
  Official TypeScript SDK for the Chaos AI API. Build DeFi-aware applications with portfolio analysis, swap operations, lending, and more.
4
4
 
5
5
  ## Installation
6
- `TBD`
6
+
7
+ ```bash
8
+ npm install @chaoslabs/ai-sdk
9
+ # or
10
+ bun add @chaoslabs/ai-sdk
11
+ ```
7
12
 
8
13
  ## Quick Start
9
14
 
@@ -50,6 +55,36 @@ for (const block of blocks) {
50
55
  }
51
56
  ```
52
57
 
58
+ ### 4. Real-Time Streaming (Optional)
59
+
60
+ Get real-time updates as the AI processes your request:
61
+
62
+ ```typescript
63
+ import { Chaos, WALLET_MODEL, type StreamMessage } from '@chaoslabs/ai-sdk';
64
+
65
+ const response = await chaos.chat.responses.create({
66
+ model: WALLET_MODEL,
67
+ input: [
68
+ { type: 'message', role: 'user', content: 'What is in my portfolio?' }
69
+ ],
70
+ metadata: { user_id: 'user-123', session_id: 'session-abc', wallet_id: '0x...' },
71
+ onStreamEvent: (msg: StreamMessage) => {
72
+ // Called immediately as each message arrives from the server
73
+ console.log(`[${msg.type}]`, msg.content);
74
+ },
75
+ });
76
+ ```
77
+
78
+ **Stream Message Types:**
79
+
80
+ | Type | Description |
81
+ |------|-------------|
82
+ | `agent_status_change` | Status updates: `processing`, `done`, `error` |
83
+ | `agent_message` | Progress messages during processing |
84
+ | `report` | Content blocks as they're generated |
85
+ | `follow_up_suggestions` | Suggested follow-up queries |
86
+ | `user_input` | Clarification requests |
87
+
53
88
  ## API Reference
54
89
 
55
90
  ### Chaos Client
@@ -66,6 +101,15 @@ new Chaos(config: ChaosConfig)
66
101
  | `baseUrl` | `string` | `https://ai-staging.chaoslabs.co` | API base URL |
67
102
  | `timeout` | `number` | `120000` | Request timeout in milliseconds |
68
103
 
104
+ ### Request Options
105
+
106
+ | Option | Type | Description |
107
+ |--------|------|-------------|
108
+ | `model` | `string` | Model to use (e.g., `WALLET_MODEL`) |
109
+ | `input` | `InputItem[]` | Conversation messages |
110
+ | `metadata` | `RequestMetadata` | User, session, and wallet info |
111
+ | `onStreamEvent` | `(msg: StreamMessage) => void` | Real-time streaming callback |
112
+
69
113
  > **Important:** API keys are environment-specific. A staging API key will not work with the production API, and vice versa. Make sure your `apiKey` and `baseUrl` are from the same environment.
70
114
 
71
115
  **Available Environments:**
@@ -220,6 +264,7 @@ import type {
220
264
  Block,
221
265
  TableBlock,
222
266
  TransactionActionBlock,
267
+ StreamMessage,
223
268
  // ... and more
224
269
  } from '@chaoslabs/ai-sdk';
225
270
  ```
@@ -0,0 +1,15 @@
1
+ /**
2
+ * HTTP Streaming Tests (TDD - RED Phase)
3
+ *
4
+ * These tests verify the http-based streaming implementation that will replace fetch.
5
+ * Tests are written BEFORE the implementation (TDD RED phase).
6
+ *
7
+ * The implementation will use Node's native http/https modules for streaming
8
+ * instead of fetch to ensure proper incremental streaming behavior.
9
+ *
10
+ * KEY TESTS THAT MUST FAIL INITIALLY:
11
+ * - httpStreamRequest function (doesn't exist yet)
12
+ * - StreamingHttpClient class (doesn't exist yet)
13
+ * - useNativeHttp option (doesn't exist yet)
14
+ */
15
+ export {};