@arinova-ai/agent-sdk 0.0.1

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 ADDED
@@ -0,0 +1,129 @@
1
+ # @arinova-ai/agent-sdk
2
+
3
+ TypeScript SDK for connecting AI agents to [Arinova Chat](https://chat.arinova.ai) via WebSocket. Handles authentication, streaming responses, and automatic reconnection.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @arinova-ai/agent-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ import { ArinovaAgent } from "@arinova-ai/agent-sdk";
15
+
16
+ const agent = new ArinovaAgent({
17
+ serverUrl: "wss://chat.arinova.ai",
18
+ botToken: "your-bot-token",
19
+ });
20
+
21
+ agent.onTask(async (task) => {
22
+ // Stream chunks to the user
23
+ task.sendChunk("Hello, ");
24
+ task.sendChunk("I'm processing your request...\n\n");
25
+
26
+ // Do your work here (call an LLM, run a tool, etc.)
27
+ const result = await doSomething(task.content);
28
+
29
+ // Send the final complete response
30
+ task.sendComplete(result);
31
+ });
32
+
33
+ agent.on("connected", () => {
34
+ console.log("Agent connected to Arinova Chat");
35
+ });
36
+
37
+ agent.on("disconnected", () => {
38
+ console.log("Agent disconnected");
39
+ });
40
+
41
+ agent.on("error", (err) => {
42
+ console.error("Agent error:", err.message);
43
+ });
44
+
45
+ await agent.connect();
46
+ ```
47
+
48
+ ## API Reference
49
+
50
+ ### `new ArinovaAgent(options)`
51
+
52
+ Creates a new agent instance.
53
+
54
+ | Option | Type | Required | Default | Description |
55
+ |---|---|---|---|---|
56
+ | `serverUrl` | `string` | Yes | -- | WebSocket server URL (e.g. `wss://chat.arinova.ai` or `ws://localhost:3501`) |
57
+ | `botToken` | `string` | Yes | -- | Bot token from the Arinova dashboard |
58
+ | `reconnectInterval` | `number` | No | `5000` | Milliseconds to wait before reconnecting after a disconnect |
59
+ | `pingInterval` | `number` | No | `30000` | Milliseconds between keep-alive pings |
60
+
61
+ ### `agent.onTask(handler)`
62
+
63
+ Registers the task handler. Called each time a user sends a message to your agent. The handler receives a `TaskContext` object and may return a `Promise`.
64
+
65
+ ```ts
66
+ agent.onTask(async (task: TaskContext) => {
67
+ // handle the task
68
+ });
69
+ ```
70
+
71
+ ### `agent.on(event, listener)`
72
+
73
+ Subscribes to lifecycle events.
74
+
75
+ | Event | Listener Signature | Description |
76
+ |---|---|---|
77
+ | `"connected"` | `() => void` | Fired after successful authentication |
78
+ | `"disconnected"` | `() => void` | Fired when the WebSocket connection closes |
79
+ | `"error"` | `(error: Error) => void` | Fired on authentication failure, connection errors, or message parse errors |
80
+
81
+ ### `agent.connect()`
82
+
83
+ Connects to the server and authenticates with the bot token. Returns a `Promise<void>` that resolves on successful authentication or rejects on auth failure.
84
+
85
+ ```ts
86
+ try {
87
+ await agent.connect();
88
+ } catch (err) {
89
+ console.error("Failed to connect:", err);
90
+ }
91
+ ```
92
+
93
+ The agent automatically reconnects on unexpected disconnects. It does **not** reconnect on authentication errors.
94
+
95
+ ### `agent.disconnect()`
96
+
97
+ Closes the WebSocket connection and stops automatic reconnection.
98
+
99
+ ```ts
100
+ agent.disconnect();
101
+ ```
102
+
103
+ ### `TaskContext`
104
+
105
+ The object passed to your `onTask` handler.
106
+
107
+ | Property | Type | Description |
108
+ |---|---|---|
109
+ | `taskId` | `string` | Unique task ID assigned by the server |
110
+ | `conversationId` | `string` | ID of the conversation this task belongs to |
111
+ | `content` | `string` | The user's message text |
112
+ | `sendChunk(chunk)` | `(chunk: string) => void` | Send a streaming text chunk to the user |
113
+ | `sendComplete(content)` | `(content: string) => void` | Mark the task as complete with the full response |
114
+ | `sendError(error)` | `(error: string) => void` | Mark the task as failed with an error message |
115
+
116
+ If your `onTask` handler throws, the SDK automatically calls `sendError` with the error message.
117
+
118
+ ## Getting a Bot Token
119
+
120
+ 1. Open the [Arinova Chat](https://chat.arinova.ai) dashboard.
121
+ 2. Navigate to your bot settings (or create a new bot).
122
+ 3. Copy the bot token from the settings page.
123
+ 4. Pass the token as `botToken` when creating your `ArinovaAgent`.
124
+
125
+ Keep your bot token secret. Do not commit it to version control -- use environment variables instead.
126
+
127
+ ## License
128
+
129
+ MIT
@@ -0,0 +1,34 @@
1
+ import type { ArinovaAgentOptions, TaskHandler, AgentEvent, AgentEventListener } from "./types.js";
2
+ export declare class ArinovaAgent {
3
+ private readonly serverUrl;
4
+ private readonly botToken;
5
+ private readonly reconnectInterval;
6
+ private readonly pingInterval;
7
+ private ws;
8
+ private pingTimer;
9
+ private reconnectTimer;
10
+ private stopped;
11
+ private taskHandler;
12
+ private listeners;
13
+ private connectResolve;
14
+ private connectReject;
15
+ constructor(options: ArinovaAgentOptions);
16
+ /** Register a task handler. Called when the server sends a task. */
17
+ onTask(handler: TaskHandler): this;
18
+ /** Register an event listener. */
19
+ on<T extends AgentEvent>(event: T, listener: AgentEventListener<T>): this;
20
+ /**
21
+ * Connect to the Arinova server.
22
+ * Returns a promise that resolves on successful auth, or rejects on auth failure.
23
+ */
24
+ connect(): Promise<void>;
25
+ /** Disconnect and stop reconnecting. */
26
+ disconnect(): void;
27
+ private emit;
28
+ private send;
29
+ private cleanup;
30
+ private scheduleReconnect;
31
+ private doConnect;
32
+ private handleTask;
33
+ }
34
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,WAAW,EACX,UAAU,EACV,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAKpB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAA4B;IAE/C,OAAO,CAAC,SAAS,CAIf;IAGF,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,aAAa,CAAuC;gBAEhD,OAAO,EAAE,mBAAmB;IAOxC,oEAAoE;IACpE,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAKlC,kCAAkC;IAClC,EAAE,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzE;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IASxB,wCAAwC;IACxC,UAAU,IAAI,IAAI;IAKlB,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,SAAS;IA6EjB,OAAO,CAAC,UAAU;CAiBnB"}
package/dist/client.js ADDED
@@ -0,0 +1,174 @@
1
+ const DEFAULT_RECONNECT_INTERVAL = 5_000;
2
+ const DEFAULT_PING_INTERVAL = 30_000;
3
+ export class ArinovaAgent {
4
+ serverUrl;
5
+ botToken;
6
+ reconnectInterval;
7
+ pingInterval;
8
+ ws = null;
9
+ pingTimer = null;
10
+ reconnectTimer = null;
11
+ stopped = false;
12
+ taskHandler = null;
13
+ listeners = {
14
+ connected: [],
15
+ disconnected: [],
16
+ error: [],
17
+ };
18
+ // Used to resolve/reject the connect() promise on first auth
19
+ connectResolve = null;
20
+ connectReject = null;
21
+ constructor(options) {
22
+ this.serverUrl = options.serverUrl.replace(/\/$/, "");
23
+ this.botToken = options.botToken;
24
+ this.reconnectInterval = options.reconnectInterval ?? DEFAULT_RECONNECT_INTERVAL;
25
+ this.pingInterval = options.pingInterval ?? DEFAULT_PING_INTERVAL;
26
+ }
27
+ /** Register a task handler. Called when the server sends a task. */
28
+ onTask(handler) {
29
+ this.taskHandler = handler;
30
+ return this;
31
+ }
32
+ /** Register an event listener. */
33
+ on(event, listener) {
34
+ this.listeners[event]?.push(listener);
35
+ return this;
36
+ }
37
+ /**
38
+ * Connect to the Arinova server.
39
+ * Returns a promise that resolves on successful auth, or rejects on auth failure.
40
+ */
41
+ connect() {
42
+ this.stopped = false;
43
+ return new Promise((resolve, reject) => {
44
+ this.connectResolve = resolve;
45
+ this.connectReject = reject;
46
+ this.doConnect();
47
+ });
48
+ }
49
+ /** Disconnect and stop reconnecting. */
50
+ disconnect() {
51
+ this.stopped = true;
52
+ this.cleanup();
53
+ }
54
+ emit(event, ...args) {
55
+ for (const listener of this.listeners[event] ?? []) {
56
+ listener(...args);
57
+ }
58
+ }
59
+ send(event) {
60
+ if (this.ws && this.ws.readyState === WebSocket.OPEN) {
61
+ this.ws.send(JSON.stringify(event));
62
+ }
63
+ }
64
+ cleanup() {
65
+ if (this.pingTimer) {
66
+ clearInterval(this.pingTimer);
67
+ this.pingTimer = null;
68
+ }
69
+ if (this.reconnectTimer) {
70
+ clearTimeout(this.reconnectTimer);
71
+ this.reconnectTimer = null;
72
+ }
73
+ if (this.ws) {
74
+ try {
75
+ this.ws.close();
76
+ }
77
+ catch { }
78
+ this.ws = null;
79
+ }
80
+ }
81
+ scheduleReconnect() {
82
+ if (this.stopped)
83
+ return;
84
+ this.reconnectTimer = setTimeout(() => {
85
+ if (!this.stopped)
86
+ this.doConnect();
87
+ }, this.reconnectInterval);
88
+ }
89
+ doConnect() {
90
+ if (this.stopped)
91
+ return;
92
+ this.cleanup();
93
+ const wsUrl = `${this.serverUrl}/ws/agent`;
94
+ try {
95
+ this.ws = new WebSocket(wsUrl);
96
+ }
97
+ catch (err) {
98
+ const error = err instanceof Error ? err : new Error(String(err));
99
+ this.emit("error", error);
100
+ this.scheduleReconnect();
101
+ return;
102
+ }
103
+ this.ws.onopen = () => {
104
+ this.send({ type: "agent_auth", botToken: this.botToken });
105
+ this.pingTimer = setInterval(() => {
106
+ this.send({ type: "ping" });
107
+ }, this.pingInterval);
108
+ };
109
+ this.ws.onmessage = (event) => {
110
+ try {
111
+ const data = JSON.parse(String(event.data));
112
+ if (data.type === "auth_ok") {
113
+ this.emit("connected");
114
+ // Resolve the connect() promise on first successful auth
115
+ if (this.connectResolve) {
116
+ this.connectResolve();
117
+ this.connectResolve = null;
118
+ this.connectReject = null;
119
+ }
120
+ return;
121
+ }
122
+ if (data.type === "auth_error") {
123
+ const error = new Error(`Agent auth failed: ${data.error}`);
124
+ this.emit("error", error);
125
+ // Don't reconnect on auth error
126
+ this.stopped = true;
127
+ this.cleanup();
128
+ // Reject the connect() promise
129
+ if (this.connectReject) {
130
+ this.connectReject(error);
131
+ this.connectResolve = null;
132
+ this.connectReject = null;
133
+ }
134
+ return;
135
+ }
136
+ if (data.type === "pong") {
137
+ return;
138
+ }
139
+ if (data.type === "task") {
140
+ this.handleTask(data.taskId, data.conversationId, data.content);
141
+ return;
142
+ }
143
+ }
144
+ catch (err) {
145
+ this.emit("error", err instanceof Error ? err : new Error(String(err)));
146
+ }
147
+ };
148
+ this.ws.onerror = () => {
149
+ // WebSocket errors are followed by close events
150
+ };
151
+ this.ws.onclose = () => {
152
+ this.cleanup();
153
+ this.emit("disconnected");
154
+ this.scheduleReconnect();
155
+ };
156
+ }
157
+ handleTask(taskId, conversationId, content) {
158
+ if (!this.taskHandler)
159
+ return;
160
+ const ctx = {
161
+ taskId,
162
+ conversationId,
163
+ content,
164
+ sendChunk: (chunk) => this.send({ type: "agent_chunk", taskId, chunk }),
165
+ sendComplete: (fullContent) => this.send({ type: "agent_complete", taskId, content: fullContent }),
166
+ sendError: (error) => this.send({ type: "agent_error", taskId, error }),
167
+ };
168
+ Promise.resolve(this.taskHandler(ctx)).catch((err) => {
169
+ const errorMsg = err instanceof Error ? err.message : String(err);
170
+ ctx.sendError(errorMsg);
171
+ });
172
+ }
173
+ }
174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C;QAEF,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACnD,MAAM,QAAQ,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClE,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { ArinovaAgent } from "./client.js";
2
+ export type { ArinovaAgentOptions, TaskContext, TaskHandler, AgentEvent, AgentEventListener, } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { ArinovaAgent } from "./client.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,33 @@
1
+ /** Options for creating an ArinovaAgent. */
2
+ export interface ArinovaAgentOptions {
3
+ /** WebSocket server URL (e.g. "wss://chat.arinova.ai" or "ws://localhost:3501"). */
4
+ serverUrl: string;
5
+ /** Bot token from the Arinova dashboard. */
6
+ botToken: string;
7
+ /** Reconnect interval in ms (default: 5000). */
8
+ reconnectInterval?: number;
9
+ /** Ping interval in ms (default: 30000). */
10
+ pingInterval?: number;
11
+ }
12
+ /** Context passed to the task handler. */
13
+ export interface TaskContext {
14
+ /** Unique task ID assigned by the server. */
15
+ taskId: string;
16
+ /** Conversation ID this task belongs to. */
17
+ conversationId: string;
18
+ /** The user's message content. */
19
+ content: string;
20
+ /** Send a streaming chunk to the user. */
21
+ sendChunk: (chunk: string) => void;
22
+ /** Mark the task as complete with the full response content. */
23
+ sendComplete: (content: string) => void;
24
+ /** Mark the task as failed with an error message. */
25
+ sendError: (error: string) => void;
26
+ }
27
+ /** Task handler function. */
28
+ export type TaskHandler = (task: TaskContext) => void | Promise<void>;
29
+ /** Agent lifecycle event types. */
30
+ export type AgentEvent = "connected" | "disconnected" | "error";
31
+ /** Event listener signatures. */
32
+ export type AgentEventListener<T extends AgentEvent> = T extends "error" ? (error: Error) => void : () => void;
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gEAAgE;IAChE,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,qDAAqD;IACrD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE,mCAAmC;AACnC,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,OAAO,CAAC;AAEhE,iCAAiC;AACjC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,SAAS,OAAO,GACpE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GACtB,MAAM,IAAI,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@arinova-ai/agent-sdk",
3
+ "version": "0.0.1",
4
+ "description": "SDK for connecting AI agents to Arinova Chat",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "dev": "tsc --watch",
21
+ "lint": "tsc --noEmit"
22
+ },
23
+ "keywords": [
24
+ "arinova",
25
+ "agent",
26
+ "sdk",
27
+ "websocket",
28
+ "streaming",
29
+ "ai"
30
+ ],
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "typescript": "^5"
34
+ }
35
+ }