rocketride 1.0.4 → 1.0.6

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.
Files changed (74) hide show
  1. package/README.md +129 -118
  2. package/dist/cjs/client.js +136 -72
  3. package/dist/cjs/client.js.map +1 -1
  4. package/dist/cjs/core/DAPClient.js +4 -4
  5. package/dist/cjs/core/DAPClient.js.map +1 -1
  6. package/dist/cjs/core/TransportWebSocket.js +7 -7
  7. package/dist/cjs/core/TransportWebSocket.js.map +1 -1
  8. package/dist/cjs/index.js +4 -4
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/schema/DocGroup.js +2 -2
  11. package/dist/cjs/schema/DocGroup.js.map +1 -1
  12. package/dist/cjs/schema/Question.js +18 -35
  13. package/dist/cjs/schema/Question.js.map +1 -1
  14. package/dist/cjs/schema/index.js +5 -5
  15. package/dist/cjs/schema/index.js.map +1 -1
  16. package/dist/cjs/types/index.js +5 -5
  17. package/dist/cjs/types/index.js.map +1 -1
  18. package/dist/cli/client/client.js +136 -72
  19. package/dist/cli/client/client.js.map +1 -1
  20. package/dist/cli/client/core/DAPClient.js +4 -4
  21. package/dist/cli/client/core/DAPClient.js.map +1 -1
  22. package/dist/cli/client/core/TransportWebSocket.js +7 -7
  23. package/dist/cli/client/core/TransportWebSocket.js.map +1 -1
  24. package/dist/cli/client/index.js +4 -4
  25. package/dist/cli/client/index.js.map +1 -1
  26. package/dist/cli/client/schema/DocGroup.js +2 -2
  27. package/dist/cli/client/schema/DocGroup.js.map +1 -1
  28. package/dist/cli/client/schema/Question.js +18 -35
  29. package/dist/cli/client/schema/Question.js.map +1 -1
  30. package/dist/cli/client/schema/index.js +5 -5
  31. package/dist/cli/client/schema/index.js.map +1 -1
  32. package/dist/cli/client/types/index.js +5 -5
  33. package/dist/cli/client/types/index.js.map +1 -1
  34. package/dist/esm/client.js +130 -66
  35. package/dist/esm/client.js.map +1 -1
  36. package/dist/esm/core/DAPClient.js +2 -2
  37. package/dist/esm/core/DAPClient.js.map +1 -1
  38. package/dist/esm/core/TransportWebSocket.js +2 -2
  39. package/dist/esm/core/TransportWebSocket.js.map +1 -1
  40. package/dist/esm/index.js +4 -4
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/esm/schema/DocGroup.js +1 -1
  43. package/dist/esm/schema/DocGroup.js.map +1 -1
  44. package/dist/esm/schema/Question.js +18 -35
  45. package/dist/esm/schema/Question.js.map +1 -1
  46. package/dist/esm/schema/index.js +5 -5
  47. package/dist/esm/schema/index.js.map +1 -1
  48. package/dist/esm/types/index.js +5 -5
  49. package/dist/esm/types/index.js.map +1 -1
  50. package/dist/types/client.d.ts +43 -20
  51. package/dist/types/client.d.ts.map +1 -1
  52. package/dist/types/core/DAPBase.d.ts +2 -2
  53. package/dist/types/core/DAPBase.d.ts.map +1 -1
  54. package/dist/types/core/DAPClient.d.ts +3 -3
  55. package/dist/types/core/DAPClient.d.ts.map +1 -1
  56. package/dist/types/core/TransportWebSocket.d.ts +2 -2
  57. package/dist/types/core/TransportWebSocket.d.ts.map +1 -1
  58. package/dist/types/index.d.ts +4 -4
  59. package/dist/types/index.d.ts.map +1 -1
  60. package/dist/types/schema/Doc.d.ts +1 -1
  61. package/dist/types/schema/Doc.d.ts.map +1 -1
  62. package/dist/types/schema/DocGroup.d.ts +1 -1
  63. package/dist/types/schema/DocGroup.d.ts.map +1 -1
  64. package/dist/types/schema/Question.d.ts +7 -6
  65. package/dist/types/schema/Question.d.ts.map +1 -1
  66. package/dist/types/schema/index.d.ts +5 -5
  67. package/dist/types/schema/index.d.ts.map +1 -1
  68. package/dist/types/types/events.d.ts +1 -1
  69. package/dist/types/types/events.d.ts.map +1 -1
  70. package/dist/types/types/index.d.ts +5 -5
  71. package/dist/types/types/index.d.ts.map +1 -1
  72. package/dist/types/types/pipeline.d.ts +11 -0
  73. package/dist/types/types/pipeline.d.ts.map +1 -1
  74. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,17 @@
1
- # RocketRide
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/rocketride-org/rocketride-server/main/images/banner-typescript.png" alt="RocketRide TypeScript SDK" width="900">
3
+ </p>
4
+
5
+ <p align="center">
6
+ Build, run, and manage AI pipelines from Node.js or the browser.
7
+ </p>
2
8
 
3
- TypeScript/JavaScript SDK for the RocketRide Engine - build, run, and manage AI pipelines from Node.js or the browser.
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/rocketride"><img src="https://img.shields.io/npm/v/rocketride?color=222223&label=npm" alt="npm"></a>
11
+ <a href="https://github.com/rocketride-org/rocketride-server"><img src="https://img.shields.io/github/stars/rocketride-org/rocketride-server?style=flat&color=238636&label=GitHub&logo=github&logoColor=white" alt="GitHub"></a>
12
+ <a href="https://discord.gg/9hr3tdZmEG"><img src="https://img.shields.io/badge/Discord-Join-370b7a?logo=discord&logoColor=white" alt="Discord"></a>
13
+ <a href="https://github.com/rocketride-org/rocketride-server/blob/develop/LICENSE"><img src="https://img.shields.io/badge/license-MIT-41b6e6" alt="MIT License"></a>
14
+ </p>
4
15
 
5
16
  ## Quick Start
6
17
 
@@ -17,8 +28,8 @@ pnpm add rocketride
17
28
  import { RocketRideClient } from 'rocketride';
18
29
 
19
30
  const client = new RocketRideClient({
20
- auth: process.env.ROCKETRIDE_APIKEY!,
21
- uri: 'https://cloud.rocketride.ai',
31
+ auth: process.env.ROCKETRIDE_APIKEY!,
32
+ uri: 'https://cloud.rocketride.ai',
22
33
  });
23
34
  await client.connect();
24
35
  const { token } = await client.use({ filepath: './pipeline.pipe' });
@@ -31,7 +42,7 @@ await client.disconnect();
31
42
  Don't have a pipeline yet? Visit [RocketRide on GitHub](https://github.com/rocketride-org/rocketride-server) or download the extension directly in your IDE.
32
43
 
33
44
  <p align="center">
34
- <img src="https://raw.githubusercontent.com/rocketride-org/rocketride-server/develop/images/install.png" alt="Install RocketRide extension" width="600">
45
+ <img src="https://raw.githubusercontent.com/rocketride-org/rocketride-server/main/images/install.png" alt="Install RocketRide extension" width="600">
35
46
  </p>
36
47
 
37
48
  ## What is RocketRide?
@@ -66,35 +77,35 @@ Configuration object passed to `new RocketRideClient(config)`.
66
77
 
67
78
  **Why it matters:** The config controls not only where you connect and how you authenticate, but also how the client behaves when the connection drops or when the server is slow to start. Getting `persist`, `maxRetryTime`, and the callbacks right avoids confusing "connection lost" vs "never connected" UX.
68
79
 
69
- | Property | Type | Required | Description |
70
- | ------------------- | ------------------------------------------------------- | -------- | ----------- |
71
- | `auth` | `string` | No | API key. Optional: omit and set via `env.ROCKETRIDE_APIKEY` or `.env` (Node only), or set later with `setConnectionParams({ auth })` before calling `connect()`. |
72
- | `uri` | `string` | No | Server URI (e.g. `https://cloud.rocketride.ai` or `ws://localhost:8080`). Optional: omit and use `env.ROCKETRIDE_URI` or built-in default, or set later with `setConnectionParams({ uri })` before calling `connect()`. |
73
- | `env` | `Record<string, string>` | No | Override env; if omitted, `.env` is loaded in Node (only). Used for `${ROCKETRIDE_*}` substitution in pipeline config and for `ROCKETRIDE_APIKEY`/`ROCKETRIDE_URI` when not passed as `auth`/`uri`. |
74
- | `persist` | `boolean` | No | Enable automatic reconnection with exponential backoff. Default: `false`. **Use `true`** for long-lived UIs or when the server may restart; the client will retry (250ms -> 2500ms) and call `onConnectError` on each failure until `maxRetryTime` or success. |
75
- | `maxRetryTime` | `number` | No | Max time in ms to keep retrying connection. Default: no limit. **Use** (e.g. 300000 for 5 min) so you can show "gave up" after a bounded time instead of retrying forever. |
76
- | `requestTimeout` | `number` | No | Default timeout in ms for each request; overridable per `request()` call. Prevents a single slow DAP call from hanging indefinitely. |
77
- | `onConnected` | `(info?: string) => Promise<void>` | No | Called when connection is established. **Use** to refresh UI, refetch services, or clear "connecting" state. |
78
- | `onDisconnected` | `(reason?: string, hasError?: boolean) => Promise<void>` | No | Called when connection is lost **only if** `onConnected` was already called. So "failed to connect in the first place" does *not* fire this - use `onConnectError` for that. **Do not** call `client.disconnect()` here if you want the client to auto-reconnect in persist mode. |
79
- | `onConnectError` | `(message: string) => void \| Promise<void>` | No | Called on each failed connection attempt (e.g. while retrying in persist mode). **Use** to show "Connection failed: ..." or "Still connecting..."; on auth failure the client stops retrying, so you can prompt the user to fix credentials and call `connect()` again. |
80
- | `onEvent` | `(event: DAPMessage) => Promise<void>` | No | Called for each server event (e.g. upload progress, task status). **Use** to drive progress bars or status text; event type is `event.event`, payload in `event.body`. |
81
- | `onProtocolMessage` | `(message: string) => void` | No | Optional; for logging raw DAP messages. Helpful when debugging protocol issues. |
82
- | `onDebugMessage` | `(message: string) => void` | No | Optional; for debug output. |
83
- | `module` | `string` | No | Client name for logging. Default: `CLIENT-0`, `CLIENT-1`, ... |
80
+ | Property | Type | Required | Description |
81
+ | ------------------- | -------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
82
+ | `auth` | `string` | No | API key. Optional: omit and set via `env.ROCKETRIDE_APIKEY` or `.env` (Node only), or set later with `setConnectionParams({ auth })` before calling `connect()`. |
83
+ | `uri` | `string` | No | Server URI (e.g. `https://cloud.rocketride.ai` or `ws://localhost:8080`). Optional: omit and use `env.ROCKETRIDE_URI` or built-in default, or set later with `setConnectionParams({ uri })` before calling `connect()`. |
84
+ | `env` | `Record<string, string>` | No | Override env; if omitted, `.env` is loaded in Node (only). Used for `${ROCKETRIDE_*}` substitution in pipeline config and for `ROCKETRIDE_APIKEY`/`ROCKETRIDE_URI` when not passed as `auth`/`uri`. |
85
+ | `persist` | `boolean` | No | Enable automatic reconnection with exponential backoff. Default: `false`. **Use `true`** for long-lived UIs or when the server may restart; the client will retry (250ms -> 2500ms) and call `onConnectError` on each failure until `maxRetryTime` or success. |
86
+ | `maxRetryTime` | `number` | No | Max time in ms to keep retrying connection. Default: no limit. **Use** (e.g. 300000 for 5 min) so you can show "gave up" after a bounded time instead of retrying forever. |
87
+ | `requestTimeout` | `number` | No | Default timeout in ms for each request; overridable per `request()` call. Prevents a single slow DAP call from hanging indefinitely. |
88
+ | `onConnected` | `(info?: string) => Promise<void>` | No | Called when connection is established. **Use** to refresh UI, refetch services, or clear "connecting" state. |
89
+ | `onDisconnected` | `(reason?: string, hasError?: boolean) => Promise<void>` | No | Called when connection is lost **only if** `onConnected` was already called. So "failed to connect in the first place" does _not_ fire this - use `onConnectError` for that. **Do not** call `client.disconnect()` here if you want the client to auto-reconnect in persist mode. |
90
+ | `onConnectError` | `(message: string) => void \| Promise<void>` | No | Called on each failed connection attempt (e.g. while retrying in persist mode). **Use** to show "Connection failed: ..." or "Still connecting..."; on auth failure the client stops retrying, so you can prompt the user to fix credentials and call `connect()` again. |
91
+ | `onEvent` | `(event: DAPMessage) => Promise<void>` | No | Called for each server event (e.g. upload progress, task status). **Use** to drive progress bars or status text; event type is `event.event`, payload in `event.body`. |
92
+ | `onProtocolMessage` | `(message: string) => void` | No | Optional; for logging raw DAP messages. Helpful when debugging protocol issues. |
93
+ | `onDebugMessage` | `(message: string) => void` | No | Optional; for debug output. |
94
+ | `module` | `string` | No | Client name for logging. Default: `CLIENT-0`, `CLIENT-1`, ... |
84
95
 
85
96
  **Example - long-lived app with persist and status:**
86
97
 
87
98
  ```typescript
88
99
  const client = new RocketRideClient({
89
- auth: process.env.ROCKETRIDE_APIKEY!,
90
- uri: 'wss://cloud.rocketride.ai',
91
- persist: true,
92
- maxRetryTime: 300000,
93
- requestTimeout: 30000,
94
- onConnected: async () => setStatus('connected'),
95
- onDisconnected: async () => setStatus('disconnected'),
96
- onConnectError: (msg) => setStatus('error', msg),
97
- onEvent: async (e) => handleServerEvent(e),
100
+ auth: process.env.ROCKETRIDE_APIKEY!,
101
+ uri: 'wss://cloud.rocketride.ai',
102
+ persist: true,
103
+ maxRetryTime: 300000,
104
+ requestTimeout: 30000,
105
+ onConnected: async () => setStatus('connected'),
106
+ onDisconnected: async () => setStatus('disconnected'),
107
+ onConnectError: (msg) => setStatus('error', msg),
108
+ onEvent: async (e) => handleServerEvent(e),
98
109
  });
99
110
  ```
100
111
 
@@ -117,23 +128,23 @@ await client.connect();
117
128
 
118
129
  ### Connection
119
130
 
120
- | Method | Signature | Returns | Description |
121
- | --------------------- | --------- | ------- | ----------- |
122
- | `connect` | `connect(timeout?: number): Promise<void>` | - | Opens the WebSocket and performs DAP auth. Optional `timeout` (ms) bounds the connect + auth handshake (non-persist only; in persist mode timeout is not applied). In **persist** mode, if this fails the client calls `onConnectError` and schedules retries (exponential backoff); on **auth** failure it does *not* retry so the app can fix credentials and call `connect()` again. |
123
- | `disconnect` | `disconnect(): Promise<void>` | - | Closes the connection and cancels any pending reconnection. Call when the user explicitly disconnects or the app is shutting down. |
124
- | `isConnected` | `isConnected(): boolean` | `boolean` | Whether the client is currently connected. Use before calling `use()` or `send()` to avoid confusing errors. |
125
- | `setConnectionParams` | `setConnectionParams(options: { uri?: string; auth?: string }): Promise<void>` | - | Updates server URI and/or auth at runtime. If currently connected, disconnects and reconnects with the new params (in persist mode, reconnection is scheduled; otherwise reconnects once). Use when the user changes server or credentials without creating a new client. |
131
+ | Method | Signature | Returns | Description |
132
+ | --------------------- | ------------------------------------------------------------------------------ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
133
+ | `connect` | `connect(timeout?: number): Promise<void>` | - | Opens the WebSocket and performs DAP auth. Optional `timeout` (ms) bounds the connect + auth handshake (non-persist only; in persist mode timeout is not applied). In **persist** mode, if this fails the client calls `onConnectError` and schedules retries (exponential backoff); on **auth** failure it does _not_ retry so the app can fix credentials and call `connect()` again. |
134
+ | `disconnect` | `disconnect(): Promise<void>` | - | Closes the connection and cancels any pending reconnection. Call when the user explicitly disconnects or the app is shutting down. |
135
+ | `isConnected` | `isConnected(): boolean` | `boolean` | Whether the client is currently connected. Use before calling `use()` or `send()` to avoid confusing errors. |
136
+ | `setConnectionParams` | `setConnectionParams(options: { uri?: string; auth?: string }): Promise<void>` | - | Updates server URI and/or auth at runtime. If currently connected, disconnects and reconnects with the new params (in persist mode, reconnection is scheduled; otherwise reconnects once). Use when the user changes server or credentials without creating a new client. |
126
137
 
127
138
  **How to use:** For one-off scripts, call `connect()` once, do your work, then `disconnect()`. For UIs, use `persist: true` and rely on the client to reconnect; only call `disconnect()` when the user logs out or you are done with the client. The client supports `await using` (Symbol.asyncDispose) for automatic disconnect when exiting scope.
128
139
 
129
140
  ### Low-level DAP
130
141
 
131
- | Method | Signature | Returns | Description |
132
- | -------------- | --------- | ------- | ----------- |
133
- | `buildRequest` | `buildRequest(command: string, options?: { token?: string; arguments?: Record<string, unknown>; data?: Uint8Array \| string }): DAPMessage` | `DAPMessage` | Builds a DAP request message with the next sequence number. Use when you need a custom command not wrapped by `use()`, `send()`, etc. |
134
- | `request` | `request(request: DAPMessage, timeout?: number): Promise<DAPMessage>` | `Promise<DAPMessage>` | Sends the request and returns the response. Pass `timeout` (ms) to override the config default for this call. Check `didFail(response)` or `response.success` before using `response.body`. |
135
- | `dapRequest` | `dapRequest(command: string, args?: Record<string, unknown>, token?: string, timeout?: number): Promise<DAPMessage>` | `Promise<DAPMessage>` | Shorthand: builds a request and sends it in one call. Equivalent to `buildRequest()` + `request()`. |
136
- | `didFail` | `didFail(response: DAPMessage): boolean` | `boolean` | Returns `true` when the server indicated failure (`success === false`). Use after `request()` to decide whether to use `body` or surface `message` as an error. |
142
+ | Method | Signature | Returns | Description |
143
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
144
+ | `buildRequest` | `buildRequest(command: string, options?: { token?: string; arguments?: Record<string, unknown>; data?: Uint8Array \| string }): DAPMessage` | `DAPMessage` | Builds a DAP request message with the next sequence number. Use when you need a custom command not wrapped by `use()`, `send()`, etc. |
145
+ | `request` | `request(request: DAPMessage, timeout?: number): Promise<DAPMessage>` | `Promise<DAPMessage>` | Sends the request and returns the response. Pass `timeout` (ms) to override the config default for this call. Check `didFail(response)` or `response.success` before using `response.body`. |
146
+ | `dapRequest` | `dapRequest(command: string, args?: Record<string, unknown>, token?: string, timeout?: number): Promise<DAPMessage>` | `Promise<DAPMessage>` | Shorthand: builds a request and sends it in one call. Equivalent to `buildRequest()` + `request()`. |
147
+ | `didFail` | `didFail(response: DAPMessage): boolean` | `boolean` | Returns `true` when the server indicated failure (`success === false`). Use after `request()` to decide whether to use `body` or surface `message` as an error. |
137
148
 
138
149
  **Example - custom DAP command:**
139
150
 
@@ -145,12 +156,12 @@ if (client.didFail(res)) throw new Error(res.message);
145
156
 
146
157
  ### Pipeline execution
147
158
 
148
- | Method | Signature | Returns | Description |
149
- | --------------- | --------- | ------- | ----------- |
150
- | `use` | `use(options?: { token?: string; filepath?: string; pipeline?: PipelineConfig; source?: string; threads?: number; useExisting?: boolean; args?: string[]; ttl?: number }): Promise<Record<string, any> & { token: string }>` | `Promise<{ token: string, ... }>` | Starts a pipeline. You must pass either `pipeline` (object) or `filepath` (path to a JSON file; Node only). The client substitutes `${ROCKETRIDE_*}` in the config from its `env` (or `.env`). Returns at least `token`; use that token for `send()`, `sendFiles()`, `pipe()`, `chat()`, `getTaskStatus()`, and `terminate()`. |
151
- | `validate` | `validate(options: { pipeline: PipelineConfig \| Record<string, unknown>; source?: string }): Promise<Record<string, unknown>>` | `Promise<Record<string, unknown>>` | Validates a pipeline configuration without starting it. Returns validation results (e.g. errors, warnings). Use to check pipeline correctness before `use()`. |
152
- | `terminate` | `terminate(token: string): Promise<void>` | - | Stops the pipeline for that token and frees server resources. Call when the user cancels or when you are done sending data. |
153
- | `getTaskStatus` | `getTaskStatus(token: string): Promise<TASK_STATUS>` | `Promise<TASK_STATUS>` | Returns current task status: e.g. `completedCount`, `totalCount`, `completed`, `state`, `exitCode`. Use to poll until `completed` is true or to show progress. |
159
+ | Method | Signature | Returns | Description |
160
+ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
161
+ | `use` | `use(options?: { token?: string; filepath?: string; pipeline?: PipelineConfig; source?: string; threads?: number; useExisting?: boolean; args?: string[]; ttl?: number }): Promise<Record<string, any> & { token: string }>` | `Promise<{ token: string, ... }>` | Starts a pipeline. You must pass either `pipeline` (object) or `filepath` (path to a JSON file; Node only). The client substitutes `${ROCKETRIDE_*}` in the config from its `env` (or `.env`). Returns at least `token`; use that token for `send()`, `sendFiles()`, `pipe()`, `chat()`, `getTaskStatus()`, and `terminate()`. |
162
+ | `validate` | `validate(options: { pipeline: PipelineConfig \| Record<string, unknown>; source?: string }): Promise<Record<string, unknown>>` | `Promise<Record<string, unknown>>` | Validates a pipeline configuration without starting it. Returns validation results (e.g. errors, warnings). Use to check pipeline correctness before `use()`. |
163
+ | `terminate` | `terminate(token: string): Promise<void>` | - | Stops the pipeline for that token and frees server resources. Call when the user cancels or when you are done sending data. |
164
+ | `getTaskStatus` | `getTaskStatus(token: string): Promise<TASK_STATUS>` | `Promise<TASK_STATUS>` | Returns current task status: e.g. `completedCount`, `totalCount`, `completed`, `state`, `exitCode`. Use to poll until `completed` is true or to show progress. |
154
165
 
155
166
  **Why `use()` returns a token:** The server runs each pipeline as a separate task. The token identifies that task so all subsequent operations (sending data, chat, status, terminate) target the right pipeline.
156
167
 
@@ -161,20 +172,20 @@ const { token } = await client.use({ filepath: './pipeline.json', ttl: 3600 });
161
172
  await client.setEvents(token, ['apaevt_status_processing']);
162
173
  // ... send data ...
163
174
  while (true) {
164
- const status = await client.getTaskStatus(token);
165
- if (status.completed) break;
166
- await new Promise(r => setTimeout(r, 2000));
175
+ const status = await client.getTaskStatus(token);
176
+ if (status.completed) break;
177
+ await new Promise((r) => setTimeout(r, 2000));
167
178
  }
168
179
  await client.terminate(token);
169
180
  ```
170
181
 
171
182
  ### Data
172
183
 
173
- | Method | Signature | Returns | Description |
174
- | ----------- | --------- | ------- | ----------- |
175
- | `pipe` | `pipe(token: string, objinfo?: Record<string, any>, mimeType?: string, provider?: string): Promise<DataPipe>` | `Promise<DataPipe>` | Creates a **streaming** data pipe. Use when you have large payloads or chunks arriving over time; you call `open()`, then one or more `write()`, then `close()`. Default MIME: `application/octet-stream`. |
176
- | `send` | `send(token: string, data: string \| Uint8Array, objinfo?: Record<string, any>, mimetype?: string): Promise<PIPELINE_RESULT \| undefined>` | `Promise<PIPELINE_RESULT \| undefined>` | Sends data in **one shot** (internally: open pipe, write once, close). Use for small payloads when you have the full buffer in memory. |
177
- | `sendFiles` | `sendFiles(files: Array<{ file: File; objinfo?: Record<string, any>; mimetype?: string }>, token: string): Promise<UPLOAD_RESULT[]>` | `Promise<UPLOAD_RESULT[]>` | Uploads multiple browser `File` objects. Results are in the same order as `files`. Progress is reported via `onEvent` as `apaevt_status_upload` events (e.g. `body.filepath`, `body.bytes_sent`, `body.file_size`). |
184
+ | Method | Signature | Returns | Description |
185
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
186
+ | `pipe` | `pipe(token: string, objinfo?: Record<string, any>, mimeType?: string, provider?: string): Promise<DataPipe>` | `Promise<DataPipe>` | Creates a **streaming** data pipe. Use when you have large payloads or chunks arriving over time; you call `open()`, then one or more `write()`, then `close()`. Default MIME: `application/octet-stream`. |
187
+ | `send` | `send(token: string, data: string \| Uint8Array, objinfo?: Record<string, any>, mimetype?: string): Promise<PIPELINE_RESULT \| undefined>` | `Promise<PIPELINE_RESULT \| undefined>` | Sends data in **one shot** (internally: open pipe, write once, close). Use for small payloads when you have the full buffer in memory. |
188
+ | `sendFiles` | `sendFiles(files: Array<{ file: File; objinfo?: Record<string, any>; mimetype?: string }>, token: string): Promise<UPLOAD_RESULT[]>` | `Promise<UPLOAD_RESULT[]>` | Uploads multiple browser `File` objects. Results are in the same order as `files`. Progress is reported via `onEvent` as `apaevt_status_upload` events (e.g. `body.filepath`, `body.bytes_sent`, `body.file_size`). |
178
189
 
179
190
  **When to use `pipe` vs `send`:** Use `send()` when you have a single blob (e.g. a string or one `Uint8Array`) and don't need to stream. Use `pipe()` when you are reading a large file in chunks, or when data arrives incrementally (e.g. from a stream or multiple buffers).
180
191
 
@@ -195,37 +206,37 @@ const result = await pipe.close();
195
206
 
196
207
  ### Events
197
208
 
198
- | Method | Signature | Returns | Description |
199
- | ----------- | --------- | ------- | ----------- |
200
- | `setEvents` | `setEvents(token: string, eventTypes: string[]): Promise<void>` | - | Subscribes this task to the given event types (e.g. `apaevt_status_upload`, `apaevt_status_processing`). After this, those events are delivered to your `onEvent` callback. Call after `use()` and before or while sending data. |
209
+ | Method | Signature | Returns | Description |
210
+ | ----------- | --------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
211
+ | `setEvents` | `setEvents(token: string, eventTypes: string[]): Promise<void>` | - | Subscribes this task to the given event types (e.g. `apaevt_status_upload`, `apaevt_status_processing`). After this, those events are delivered to your `onEvent` callback. Call after `use()` and before or while sending data. |
201
212
 
202
213
  ### Services, validation, and ping
203
214
 
204
- | Method | Signature | Returns | Description |
205
- | ------------- | --------- | ------- | ----------- |
206
- | `getServices` | `getServices(): Promise<Record<string, any>>` | `Promise<Record<string, any>>` | Returns all service/connector definitions from the server (schemas, UI schemas). Use to discover what pipelines or features the server supports. |
207
- | `getService` | `getService(service: string): Promise<Record<string, any> \| undefined>` | `Promise<Record<string, any> \| undefined>` | Returns the definition for one service by name. Throws if the request fails. |
208
- | `ping` | `ping(token?: string): Promise<void>` | - | Lightweight liveness check. Throws if the server responds with an error. Optional `token` for task-scoped ping. |
215
+ | Method | Signature | Returns | Description |
216
+ | ------------- | ------------------------------------------------------------------------ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
217
+ | `getServices` | `getServices(): Promise<Record<string, any>>` | `Promise<Record<string, any>>` | Returns all service/connector definitions from the server (schemas, UI schemas). Use to discover what pipelines or features the server supports. |
218
+ | `getService` | `getService(service: string): Promise<Record<string, any> \| undefined>` | `Promise<Record<string, any> \| undefined>` | Returns the definition for one service by name. Throws if the request fails. |
219
+ | `ping` | `ping(token?: string): Promise<void>` | - | Lightweight liveness check. Throws if the server responds with an error. Optional `token` for task-scoped ping. |
209
220
 
210
221
  ### Chat
211
222
 
212
- | Method | Signature | Returns | Description |
213
- | ------ | --------- | ------- | ----------- |
223
+ | Method | Signature | Returns | Description |
224
+ | ------ | -------------------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
214
225
  | `chat` | `chat(options: { token: string; question: Question }): Promise<PIPELINE_RESULT>` | `Promise<PIPELINE_RESULT>` | Sends the `Question` to the AI for the given pipeline token and returns the pipeline result. The answer content is in the result body (e.g. fields described by `result_types`); you can use `Answer.parseJson()` on raw text if the AI returned JSON. |
215
226
 
216
227
  **How it works:** The client opens a pipe with MIME type `application/rocketride-question`, writes the serialized `Question`, closes the pipe, and returns the server's result. The pipeline must support the chat provider for that token.
217
228
 
218
229
  ### Convenience
219
230
 
220
- | Method | Signature | Returns | Description |
221
- | ------------------- | --------- | ------- | ----------- |
222
- | `getConnectionInfo` | `getConnectionInfo(): { connected: boolean; transport: string; uri: string }` | object | Current connection state and URI. Useful for debugging or displaying "Connected to ..." in the UI. |
223
- | `getApiKey` | `getApiKey(): string \| undefined` | `string \| undefined` | The API key in use (for debugging only; avoid logging in production). |
231
+ | Method | Signature | Returns | Description |
232
+ | ------------------- | ----------------------------------------------------------------------------- | --------------------- | -------------------------------------------------------------------------------------------------- |
233
+ | `getConnectionInfo` | `getConnectionInfo(): { connected: boolean; transport: string; uri: string }` | object | Current connection state and URI. Useful for debugging or displaying "Connected to ..." in the UI. |
234
+ | `getApiKey` | `getApiKey(): string \| undefined` | `string \| undefined` | The API key in use (for debugging only; avoid logging in production). |
224
235
 
225
236
  ### Static
226
237
 
227
- | Method | Signature | Returns | Description |
228
- | ---------------- | --------- | ------- | ----------- |
238
+ | Method | Signature | Returns | Description |
239
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
229
240
  | `withConnection` | `RocketRideClient.withConnection<T>(config: RocketRideClientConfig, callback: (client: RocketRideClient) => Promise<T>): Promise<T>` | `Promise<T>` | Creates a client, calls `connect()`, runs `callback(client)`, then `disconnect()` in a `finally` block. Returns the callback result. **Use** for one-off scripts so you never forget to disconnect. |
230
241
 
231
242
  ---
@@ -234,15 +245,15 @@ const result = await pipe.close();
234
245
 
235
246
  Returned by `client.pipe()`. Represents one streaming upload: **open** -> one or more **write** -> **close**. The server assigns a `pipeId` when you open; each `write()` sends a chunk for that pipe, and `close()` finalizes the stream and returns the pipeline result.
236
247
 
237
- | Member | Type | Description |
238
- | ---------- | ----------------------------- | ---------------------------------------------------- |
239
- | `isOpened` | `boolean` (getter) | Whether the pipe has been opened and not yet closed. |
240
- | `pipeId` | `number \| undefined` (getter) | Server-assigned pipe ID; set after `open()`. |
248
+ | Member | Type | Description |
249
+ | ---------- | ------------------------------ | ---------------------------------------------------- |
250
+ | `isOpened` | `boolean` (getter) | Whether the pipe has been opened and not yet closed. |
251
+ | `pipeId` | `number \| undefined` (getter) | Server-assigned pipe ID; set after `open()`. |
241
252
 
242
- | Method | Signature | Returns | Description |
243
- | ------- | --------- | ------- | ----------- |
244
- | `open` | `open(): Promise<DataPipe>` | `Promise<DataPipe>` | Opens the pipe on the server. Must be called before `write()`. |
245
- | `write` | `write(buffer: Uint8Array): Promise<void>` | - | Writes a chunk. Pipe must be open. |
253
+ | Method | Signature | Returns | Description |
254
+ | ------- | ------------------------------------------------ | --------------------------------------- | --------------------------------------------------------------------------- |
255
+ | `open` | `open(): Promise<DataPipe>` | `Promise<DataPipe>` | Opens the pipe on the server. Must be called before `write()`. |
256
+ | `write` | `write(buffer: Uint8Array): Promise<void>` | - | Writes a chunk. Pipe must be open. |
246
257
  | `close` | `close(): Promise<PIPELINE_RESULT \| undefined>` | `Promise<PIPELINE_RESULT \| undefined>` | Closes the pipe and returns the processing result. No-op if already closed. |
247
258
 
248
259
  ---
@@ -266,15 +277,15 @@ constructor(options?: {
266
277
 
267
278
  ### Methods
268
279
 
269
- | Method | Signature | Description |
270
- | ---------------- | --------- | ----------- |
271
- | `addInstruction` | `addInstruction(title: string, instruction: string): void` | Adds an instruction for the AI (e.g. "Answer in bullet points"). |
272
- | `addExample` | `addExample(given: string, result: string \| object \| any[]): void` | Adds an example input/output so the AI can match format. |
273
- | `addContext` | `addContext(context: string \| object \| string[] \| object[]): void` | Adds context (e.g. "Q4 2024 data"). |
274
- | `addHistory` | `addHistory(item: QuestionHistory): void` | Adds a history item (`{ role, content }`) for multi-turn chat. |
275
- | `addQuestion` | `addQuestion(question: string): void` | Appends the main question text. |
276
- | `addDocuments` | `addDocuments(documents: Doc \| Doc[]): void` | Adds documents for the AI to reference. |
277
- | `getPrompt` | `getPrompt(hasPreviousJsonFailed?: boolean): string` | Returns the full prompt (internal use). |
280
+ | Method | Signature | Description |
281
+ | ---------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------- |
282
+ | `addInstruction` | `addInstruction(title: string, instruction: string): void` | Adds an instruction for the AI (e.g. "Answer in bullet points"). |
283
+ | `addExample` | `addExample(given: string, result: string \| object \| any[]): void` | Adds an example input/output so the AI can match format. |
284
+ | `addContext` | `addContext(context: string \| object \| string[] \| object[]): void` | Adds context (e.g. "Q4 2024 data"). |
285
+ | `addHistory` | `addHistory(item: QuestionHistory): void` | Adds a history item (`{ role, content }`) for multi-turn chat. |
286
+ | `addQuestion` | `addQuestion(question: string): void` | Appends the main question text. |
287
+ | `addDocuments` | `addDocuments(documents: Doc \| Doc[]): void` | Adds documents for the AI to reference. |
288
+ | `getPrompt` | `getPrompt(hasPreviousJsonFailed?: boolean): string` | Returns the full prompt (internal use). |
278
289
 
279
290
  ---
280
291
 
@@ -282,9 +293,9 @@ constructor(options?: {
282
293
 
283
294
  Used to parse chat response content. The client does not attach an `Answer` instance to the pipeline result; you read the response body and, if needed, use these static helpers to extract JSON or code from AI text (which often includes markdown or code fences).
284
295
 
285
- | Method | Signature | Description |
286
- | ------------------ | --------- | ----------- |
287
- | `Answer.parseJson` | `parseJson(value: string): any` | Parses JSON from AI text (strips markdown/code blocks). |
296
+ | Method | Signature | Description |
297
+ | -------------------- | ------------------------------------ | ------------------------------------------------------- |
298
+ | `Answer.parseJson` | `parseJson(value: string): any` | Parses JSON from AI text (strips markdown/code blocks). |
288
299
  | `Answer.parsePython` | `parsePython(value: string): string` | Extracts Python code from a code block in the response. |
289
300
 
290
301
  ---
@@ -316,8 +327,8 @@ Used to parse chat response content. The client does not attach an `Answer` inst
316
327
  import { RocketRideClient } from 'rocketride';
317
328
 
318
329
  const client = new RocketRideClient({
319
- auth: process.env.ROCKETRIDE_APIKEY!,
320
- uri: 'https://cloud.rocketride.ai',
330
+ auth: process.env.ROCKETRIDE_APIKEY!,
331
+ uri: 'https://cloud.rocketride.ai',
321
332
  });
322
333
  await client.connect();
323
334
  const { token } = await client.use({ filepath: './pipeline.json' });
@@ -332,14 +343,11 @@ await client.disconnect();
332
343
  ```typescript
333
344
  import { RocketRideClient } from 'rocketride';
334
345
 
335
- const status = await RocketRideClient.withConnection(
336
- { auth: 'my-key', uri: 'wss://cloud.rocketride.ai' },
337
- async (client) => {
338
- const { token } = await client.use({ pipeline: { pipeline: myPipelineConfig } });
339
- await client.send(token, JSON.stringify({ data: 1 }));
340
- return await client.getTaskStatus(token);
341
- }
342
- );
346
+ const status = await RocketRideClient.withConnection({ auth: 'my-key', uri: 'wss://cloud.rocketride.ai' }, async (client) => {
347
+ const { token } = await client.use({ pipeline: { pipeline: myPipelineConfig } });
348
+ await client.send(token, JSON.stringify({ data: 1 }));
349
+ return await client.getTaskStatus(token);
350
+ });
343
351
  console.log(status);
344
352
  ```
345
353
 
@@ -349,16 +357,16 @@ console.log(status);
349
357
  import { RocketRideClient } from 'rocketride';
350
358
 
351
359
  const client = new RocketRideClient({
352
- auth: apiKey,
353
- uri: serverUri,
354
- persist: true,
355
- maxRetryTime: 300000,
356
- onConnected: async () => updateUI({ state: 'connected' }),
357
- onDisconnected: async (reason, hasError) => updateUI({ state: 'disconnected', reason, hasError }),
358
- onConnectError: (msg) => updateUI({ state: 'error', message: msg }),
359
- onEvent: async (e) => {
360
- if (e.event === 'apaevt_status_upload') updateProgress(e.body);
361
- },
360
+ auth: apiKey,
361
+ uri: serverUri,
362
+ persist: true,
363
+ maxRetryTime: 300000,
364
+ onConnected: async () => updateUI({ state: 'connected' }),
365
+ onDisconnected: async (reason, hasError) => updateUI({ state: 'disconnected', reason, hasError }),
366
+ onConnectError: (msg) => updateUI({ state: 'error', message: msg }),
367
+ onEvent: async (e) => {
368
+ if (e.event === 'apaevt_status_upload') updateProgress(e.body);
369
+ },
362
370
  });
363
371
  await client.connect();
364
372
  // Later: use(), sendFiles(), etc. If connection drops, client retries; do not call disconnect() in onDisconnected.
@@ -375,14 +383,17 @@ const { token } = await client.use({ filepath: './vectorize.json' });
375
383
  await client.setEvents(token, ['apaevt_status_upload', 'apaevt_status_processing']);
376
384
 
377
385
  const files = [new File([content1], 'a.md'), new File([content2], 'b.md')];
378
- const uploadResults = await client.sendFiles(files.map(file => ({ file })), token);
379
- console.log('Uploaded:', uploadResults.filter(r => r.action === 'complete').length);
386
+ const uploadResults = await client.sendFiles(
387
+ files.map((file) => ({ file })),
388
+ token
389
+ );
390
+ console.log('Uploaded:', uploadResults.filter((r) => r.action === 'complete').length);
380
391
 
381
392
  while (true) {
382
- const status = await client.getTaskStatus(token);
383
- console.log(`Progress: ${status.completedCount}/${status.totalCount}`);
384
- if (status.completed) break;
385
- await new Promise(r => setTimeout(r, 2000));
393
+ const status = await client.getTaskStatus(token);
394
+ console.log(`Progress: ${status.completedCount}/${status.totalCount}`);
395
+ if (status.completed) break;
396
+ await new Promise((r) => setTimeout(r, 2000));
386
397
  }
387
398
  await client.terminate(token);
388
399
  await client.disconnect();
@@ -403,7 +414,7 @@ const pipe = await client.pipe(token, { name: 'large.csv' }, 'text/csv');
403
414
  await pipe.open();
404
415
  const rl = createInterface({ input: createReadStream('large.csv') });
405
416
  for await (const line of rl) {
406
- await pipe.write(new TextEncoder().encode(line + '\n'));
417
+ await pipe.write(new TextEncoder().encode(line + '\n'));
407
418
  }
408
419
  const result = await pipe.close();
409
420
  console.log(result);