@elizaos/capacitor-gateway 1.0.0 → 2.0.11-beta.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @elizaos/capacitor-gateway
2
+
3
+ A [Capacitor](https://capacitorjs.com/) plugin that connects an elizaOS app to an **Eliza Gateway** server. Provides service discovery via Bonjour/mDNS, authenticated WebSocket connectivity, RPC request/response, and realtime event streaming — with native implementations on iOS (Swift + NWBrowser), Android (Kotlin + OkHttp + NsdManager), and web (browser WebSocket).
4
+
5
+ ---
6
+
7
+ ## What it does
8
+
9
+ - **Discovery** — finds Eliza Gateway instances on the local network via Bonjour/mDNS (`_eliza-gw._tcp`). Supports optional wide-area DNS-SD discovery (e.g. via Tailscale). Not available on web.
10
+ - **Authenticated connection** — opens a WebSocket to the gateway, sends a `connect` frame with credentials (token or password), and negotiates protocol version 3. Returns session ID, role, scopes, and the methods/events the gateway exposes.
11
+ - **RPC** — `Gateway.send({ method, params })` sends a JSON request frame and resolves with the response payload or structured error.
12
+ - **Realtime events** — listen to server-pushed events via `addListener("gatewayEvent", ...)`.
13
+ - **Connection lifecycle** — state changes (`connecting`, `connected`, `disconnected`, `reconnecting`) and errors are surfaced as typed events. Reconnection uses exponential backoff (800 ms → 15 s).
14
+
15
+ ---
16
+
17
+ ## Platforms
18
+
19
+ | Platform | Discovery | WebSocket | Notes |
20
+ |---|---|---|---|
21
+ | iOS | Native Bonjour (NWBrowser) | URLSessionWebSocketTask | Min iOS 15.0 |
22
+ | Android | NsdManager | OkHttp | kotlinx.coroutines |
23
+ | Web/Node | Not supported | Browser WebSocket | Discovery returns empty list |
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @elizaos/capacitor-gateway
31
+ npx cap sync
32
+ ```
33
+
34
+ For iOS, add the pod to your `Podfile`:
35
+
36
+ ```ruby
37
+ pod 'ElizaosCapacitorGateway'
38
+ ```
39
+
40
+ ---
41
+
42
+ ## API
43
+
44
+ ### Import
45
+
46
+ ```typescript
47
+ import { Gateway } from '@elizaos/capacitor-gateway';
48
+ ```
49
+
50
+ ### Discover gateways
51
+
52
+ ```typescript
53
+ // Start streaming discovery events
54
+ await Gateway.addListener('discovery', (event) => {
55
+ if (event.type === 'found') {
56
+ console.log('Found gateway:', event.gateway.name, event.gateway.host, event.gateway.port);
57
+ }
58
+ });
59
+
60
+ await Gateway.startDiscovery({ timeout: 10000 });
61
+
62
+ // One-shot snapshot
63
+ const { gateways } = await Gateway.getDiscoveredGateways();
64
+
65
+ await Gateway.stopDiscovery();
66
+ ```
67
+
68
+ ### Connect
69
+
70
+ ```typescript
71
+ const result = await Gateway.connect({
72
+ url: 'wss://192.168.1.42:8080',
73
+ token: 'your-jwt-token', // or use password: '...'
74
+ clientName: 'my-app',
75
+ role: 'operator',
76
+ scopes: ['operator.admin'],
77
+ });
78
+
79
+ if (result.connected) {
80
+ console.log('Session:', result.sessionId);
81
+ console.log('Role:', result.role);
82
+ console.log('Available methods:', result.methods);
83
+ }
84
+ ```
85
+
86
+ ### Send an RPC request
87
+
88
+ ```typescript
89
+ const response = await Gateway.send({
90
+ method: 'agents.list',
91
+ params: {},
92
+ });
93
+
94
+ if (response.ok) {
95
+ console.log(response.payload);
96
+ } else {
97
+ console.error(response.error?.code, response.error?.message);
98
+ }
99
+ ```
100
+
101
+ ### Listen for realtime events
102
+
103
+ ```typescript
104
+ await Gateway.addListener('gatewayEvent', (event) => {
105
+ console.log(event.event, event.payload, event.seq);
106
+ });
107
+
108
+ await Gateway.addListener('stateChange', (event) => {
109
+ console.log('Connection state:', event.state, event.reason);
110
+ });
111
+
112
+ await Gateway.addListener('error', (event) => {
113
+ console.warn(event.message, 'willRetry:', event.willRetry);
114
+ });
115
+ ```
116
+
117
+ ### Disconnect
118
+
119
+ ```typescript
120
+ await Gateway.disconnect();
121
+ await Gateway.removeAllListeners();
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Connection options reference
127
+
128
+ | Option | Type | Default | Description |
129
+ |---|---|---|---|
130
+ | `url` | `string` | required | WebSocket URL (`ws://` or `wss://`) |
131
+ | `token` | `string` | — | JWT / bearer token |
132
+ | `password` | `string` | — | Password-based auth |
133
+ | `clientName` | `string` | `"eliza-capacitor"` | Client identifier sent in connect frame |
134
+ | `clientVersion` | `string` | `"1.0.0"` | Client version string |
135
+ | `sessionKey` | `string` | — | Session key for chat sessions |
136
+ | `role` | `string` | `"operator"` | Role to request from the gateway |
137
+ | `scopes` | `string[]` | `["operator.admin"]` | Scopes to request |
138
+
139
+ ---
140
+
141
+ ## Building
142
+
143
+ ```bash
144
+ bun run build # tsc + rollup → dist/
145
+ bun run build:docs # regenerate README from JSDoc, then build
146
+ bun run verify:ios # pod install + xcodebuild
147
+ bun run verify:android # ./gradlew clean build test
148
+ ```
149
+
150
+ > **Note:** `bun run build:docs` regenerates this README from JSDoc comments in `src/definitions.ts`. Manual edits will be overwritten on the next docgen run.
151
+
@@ -7,6 +7,16 @@ ext {
7
7
  }
8
8
 
9
9
  apply plugin: 'com.android.library'
10
+ // Explicitly apply the Kotlin Android plugin. The kotlin-gradle-plugin is on
11
+ // the root buildscript classpath, but without applying it here AGP 8.13 falls
12
+ // back to its "built-in Kotlin" compile path (build/intermediates/
13
+ // built_in_kotlinc), which compiles the .kt sources but does NOT bundle the
14
+ // resulting .class files into the *release* library jar. The app's
15
+ // :app:assembleRelease then links a library AAR with zero plugin classes, so
16
+ // the Capacitor plugin (and any manifest-declared component) is absent from
17
+ // the release dex. Applying the standard Kotlin plugin wires Kotlin
18
+ // compilation into both the debug and release jar-bundling tasks.
19
+ apply plugin: 'org.jetbrains.kotlin.android'
10
20
  android {
11
21
  namespace = "ai.eliza.plugins.gateway"
12
22
  compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
@@ -22,15 +32,19 @@ android {
22
32
  }
23
33
  }
24
34
  compileOptions {
25
- sourceCompatibility JavaVersion.VERSION_17
26
- targetCompatibility JavaVersion.VERSION_17
35
+ sourceCompatibility JavaVersion.VERSION_21
36
+ targetCompatibility JavaVersion.VERSION_21
37
+ }
38
+
39
+ kotlinOptions {
40
+ jvmTarget = "21"
27
41
  }
28
42
  }
29
43
 
30
44
  repositories {
31
45
  google()
32
46
  maven {
33
- url = uri(rootProject.ext.mavenCentralMirrorUrl)
47
+ url = uri(rootProject.ext.has('mavenCentralMirrorUrl') ? rootProject.ext.mavenCentralMirrorUrl : 'https://repo.maven.apache.org/maven2')
34
48
  }
35
49
  mavenCentral()
36
50
  }
package/dist/esm/web.d.ts CHANGED
@@ -30,7 +30,8 @@ export declare class GatewayWeb extends WebPlugin {
30
30
  */
31
31
  startDiscovery(): Promise<GatewayDiscoveryResult>;
32
32
  /**
33
- * Stop gateway discovery (no-op on web)
33
+ * Stop gateway discovery. Web discovery is unsupported, so there is no
34
+ * active browser discovery session to stop.
34
35
  */
35
36
  stopDiscovery(): Promise<void>;
36
37
  /**
package/dist/esm/web.js CHANGED
@@ -37,6 +37,35 @@ const parseGatewayError = (value) => {
37
37
  details: value.details,
38
38
  };
39
39
  };
40
+ function assertGatewayUrl(url) {
41
+ if (typeof url !== "string" || url.trim().length === 0) {
42
+ throw new Error("url must be a non-empty WebSocket URL");
43
+ }
44
+ let parsed;
45
+ try {
46
+ parsed = new URL(url);
47
+ }
48
+ catch {
49
+ throw new Error("url must be a valid WebSocket URL");
50
+ }
51
+ if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
52
+ throw new Error("url must use ws: or wss:");
53
+ }
54
+ return parsed.toString();
55
+ }
56
+ function assertRpcMethod(method) {
57
+ if (typeof method !== "string" || method.trim().length === 0) {
58
+ throw new Error("method must be a non-empty string");
59
+ }
60
+ const normalized = method.trim();
61
+ if (normalized !== method) {
62
+ throw new Error("method must not contain leading or trailing whitespace");
63
+ }
64
+ if (!/^[a-zA-Z][a-zA-Z0-9_.:-]{0,127}$/.test(normalized)) {
65
+ throw new Error("method contains invalid characters");
66
+ }
67
+ return normalized;
68
+ }
40
69
  /**
41
70
  * Web implementation of the Gateway Plugin
42
71
  *
@@ -75,10 +104,11 @@ export class GatewayWeb extends WebPlugin {
75
104
  };
76
105
  }
77
106
  /**
78
- * Stop gateway discovery (no-op on web)
107
+ * Stop gateway discovery. Web discovery is unsupported, so there is no
108
+ * active browser discovery session to stop.
79
109
  */
80
110
  async stopDiscovery() {
81
- // No-op on web
111
+ // Web platforms never start Bonjour/mDNS discovery.
82
112
  }
83
113
  /**
84
114
  * Get discovered gateways (always empty on web)
@@ -93,13 +123,14 @@ export class GatewayWeb extends WebPlugin {
93
123
  * Connect to a Gateway server
94
124
  */
95
125
  async connect(options) {
126
+ const url = assertGatewayUrl(options.url);
96
127
  // Close existing connection if any
97
128
  if (this.ws) {
98
129
  this.closed = true;
99
130
  this.ws.close();
100
131
  this.ws = null;
101
132
  }
102
- this.options = options;
133
+ this.options = { ...options, url };
103
134
  this.closed = false;
104
135
  this.backoffMs = 800;
105
136
  return new Promise((resolve, reject) => {
@@ -370,6 +401,7 @@ export class GatewayWeb extends WebPlugin {
370
401
  * Send an RPC request
371
402
  */
372
403
  async send(options) {
404
+ const method = assertRpcMethod(options.method);
373
405
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
374
406
  return {
375
407
  ok: false,
@@ -383,7 +415,7 @@ export class GatewayWeb extends WebPlugin {
383
415
  const frame = {
384
416
  type: "req",
385
417
  id,
386
- method: options.method,
418
+ method,
387
419
  params: options.params || {},
388
420
  };
389
421
  return new Promise((resolve, reject) => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,169 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { GatewayWeb } from "./web";
3
+ class FakeWebSocket {
4
+ constructor(url) {
5
+ this.url = url;
6
+ this.readyState = FakeWebSocket.CONNECTING;
7
+ this.sent = [];
8
+ this.listeners = new Map();
9
+ FakeWebSocket.instances.push(this);
10
+ }
11
+ addEventListener(eventName, listener) {
12
+ const listeners = this.listeners.get(eventName) ?? [];
13
+ listeners.push(listener);
14
+ this.listeners.set(eventName, listeners);
15
+ }
16
+ send(data) {
17
+ this.sent.push(data);
18
+ }
19
+ close(code = 1000, reason = "closed") {
20
+ this.readyState = FakeWebSocket.CLOSED;
21
+ this.emit("close", { code, reason });
22
+ }
23
+ open() {
24
+ this.readyState = FakeWebSocket.OPEN;
25
+ this.emit("open", {});
26
+ }
27
+ message(data) {
28
+ this.emit("message", { data });
29
+ }
30
+ emit(eventName, event) {
31
+ this.listeners.get(eventName)?.forEach((listener) => {
32
+ listener(event);
33
+ });
34
+ }
35
+ }
36
+ FakeWebSocket.instances = [];
37
+ FakeWebSocket.CONNECTING = 0;
38
+ FakeWebSocket.OPEN = 1;
39
+ FakeWebSocket.CLOSED = 3;
40
+ function parseSent(socket, index) {
41
+ return JSON.parse(socket.sent[index] ?? "{}");
42
+ }
43
+ describe("GatewayWeb", () => {
44
+ beforeEach(() => {
45
+ FakeWebSocket.instances = [];
46
+ Object.assign(FakeWebSocket, {
47
+ CONNECTING: 0,
48
+ OPEN: 1,
49
+ CLOSED: 3,
50
+ });
51
+ vi.stubGlobal("WebSocket", FakeWebSocket);
52
+ vi.stubGlobal("crypto", {
53
+ randomUUID: vi.fn(() => "00000000-0000-4000-8000-000000000001"),
54
+ });
55
+ });
56
+ afterEach(() => {
57
+ vi.restoreAllMocks();
58
+ vi.unstubAllGlobals();
59
+ });
60
+ it.each([
61
+ "",
62
+ "https://example.test",
63
+ "javascript:alert(1)",
64
+ "not a url",
65
+ ])("rejects invalid gateway URL %s before opening a socket", async (url) => {
66
+ await expect(new GatewayWeb().connect({ url })).rejects.toThrow(/WebSocket URL|ws: or wss:/);
67
+ expect(FakeWebSocket.instances).toHaveLength(0);
68
+ });
69
+ it("sends a connect frame and resolves from a valid hello response", async () => {
70
+ const gateway = new GatewayWeb();
71
+ const states = [];
72
+ await gateway.addListener("stateChange", (event) => {
73
+ states.push(event);
74
+ });
75
+ const connected = gateway.connect({
76
+ url: "wss://gateway.example/socket",
77
+ clientName: "tester",
78
+ role: "viewer",
79
+ scopes: ["chat.read"],
80
+ token: "secret-token",
81
+ });
82
+ const socket = FakeWebSocket.instances[0];
83
+ socket.open();
84
+ const connectFrame = parseSent(socket, 0);
85
+ expect(connectFrame).toMatchObject({
86
+ type: "req",
87
+ id: "00000000-0000-4000-8000-000000000001",
88
+ method: "connect",
89
+ });
90
+ socket.message(JSON.stringify({
91
+ type: "res",
92
+ id: connectFrame.id,
93
+ ok: true,
94
+ payload: {
95
+ protocol: 3,
96
+ auth: { role: "viewer", scopes: ["chat.read"] },
97
+ features: { methods: ["chat.send"], events: ["chat.delta"] },
98
+ },
99
+ }));
100
+ await expect(connected).resolves.toMatchObject({
101
+ connected: true,
102
+ protocol: 3,
103
+ methods: ["chat.send"],
104
+ events: ["chat.delta"],
105
+ role: "viewer",
106
+ scopes: ["chat.read"],
107
+ });
108
+ expect(states).toEqual([{ state: "connecting" }, { state: "connected" }]);
109
+ });
110
+ it("ignores malformed inbound frames and emits valid gateway events", async () => {
111
+ const gateway = new GatewayWeb();
112
+ const events = [];
113
+ await gateway.addListener("gatewayEvent", (event) => {
114
+ events.push(event);
115
+ });
116
+ const connected = gateway.connect({ url: "ws://localhost:1234" });
117
+ const socket = FakeWebSocket.instances[0];
118
+ socket.open();
119
+ const connectFrame = parseSent(socket, 0);
120
+ socket.message(JSON.stringify({
121
+ type: "res",
122
+ id: connectFrame.id,
123
+ ok: true,
124
+ payload: {},
125
+ }));
126
+ await connected;
127
+ socket.message("not json");
128
+ socket.message(JSON.stringify({ type: "event", event: "", payload: {} }));
129
+ socket.message(JSON.stringify({
130
+ type: "event",
131
+ event: "chat.delta",
132
+ payload: { n: 1 },
133
+ seq: 1,
134
+ }));
135
+ expect(events).toEqual([
136
+ { event: "chat.delta", payload: { n: 1 }, seq: 1 },
137
+ ]);
138
+ });
139
+ it.each([
140
+ "",
141
+ " spaces ",
142
+ "../escape",
143
+ "1bad",
144
+ ])("rejects invalid RPC method %s before sending", async (method) => {
145
+ const gateway = new GatewayWeb();
146
+ const connected = gateway.connect({ url: "ws://localhost:1234" });
147
+ const socket = FakeWebSocket.instances[0];
148
+ socket.open();
149
+ const connectFrame = parseSent(socket, 0);
150
+ socket.message(JSON.stringify({
151
+ type: "res",
152
+ id: connectFrame.id,
153
+ ok: true,
154
+ payload: {},
155
+ }));
156
+ await connected;
157
+ await expect(gateway.send({ method })).rejects.toThrow(/method/);
158
+ expect(socket.sent).toHaveLength(1);
159
+ });
160
+ it("returns NOT_CONNECTED for valid RPC methods when disconnected", async () => {
161
+ await expect(new GatewayWeb().send({ method: "chat.send" })).resolves.toEqual({
162
+ ok: false,
163
+ error: {
164
+ code: "NOT_CONNECTED",
165
+ message: "Not connected to gateway",
166
+ },
167
+ });
168
+ });
169
+ });
@@ -45,6 +45,35 @@ const parseGatewayError = (value) => {
45
45
  details: value.details,
46
46
  };
47
47
  };
48
+ function assertGatewayUrl(url) {
49
+ if (typeof url !== "string" || url.trim().length === 0) {
50
+ throw new Error("url must be a non-empty WebSocket URL");
51
+ }
52
+ let parsed;
53
+ try {
54
+ parsed = new URL(url);
55
+ }
56
+ catch {
57
+ throw new Error("url must be a valid WebSocket URL");
58
+ }
59
+ if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
60
+ throw new Error("url must use ws: or wss:");
61
+ }
62
+ return parsed.toString();
63
+ }
64
+ function assertRpcMethod(method) {
65
+ if (typeof method !== "string" || method.trim().length === 0) {
66
+ throw new Error("method must be a non-empty string");
67
+ }
68
+ const normalized = method.trim();
69
+ if (normalized !== method) {
70
+ throw new Error("method must not contain leading or trailing whitespace");
71
+ }
72
+ if (!/^[a-zA-Z][a-zA-Z0-9_.:-]{0,127}$/.test(normalized)) {
73
+ throw new Error("method contains invalid characters");
74
+ }
75
+ return normalized;
76
+ }
48
77
  /**
49
78
  * Web implementation of the Gateway Plugin
50
79
  *
@@ -83,10 +112,11 @@ class GatewayWeb extends core.WebPlugin {
83
112
  };
84
113
  }
85
114
  /**
86
- * Stop gateway discovery (no-op on web)
115
+ * Stop gateway discovery. Web discovery is unsupported, so there is no
116
+ * active browser discovery session to stop.
87
117
  */
88
118
  async stopDiscovery() {
89
- // No-op on web
119
+ // Web platforms never start Bonjour/mDNS discovery.
90
120
  }
91
121
  /**
92
122
  * Get discovered gateways (always empty on web)
@@ -101,13 +131,14 @@ class GatewayWeb extends core.WebPlugin {
101
131
  * Connect to a Gateway server
102
132
  */
103
133
  async connect(options) {
134
+ const url = assertGatewayUrl(options.url);
104
135
  // Close existing connection if any
105
136
  if (this.ws) {
106
137
  this.closed = true;
107
138
  this.ws.close();
108
139
  this.ws = null;
109
140
  }
110
- this.options = options;
141
+ this.options = { ...options, url };
111
142
  this.closed = false;
112
143
  this.backoffMs = 800;
113
144
  return new Promise((resolve, reject) => {
@@ -378,6 +409,7 @@ class GatewayWeb extends core.WebPlugin {
378
409
  * Send an RPC request
379
410
  */
380
411
  async send(options) {
412
+ const method = assertRpcMethod(options.method);
381
413
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
382
414
  return {
383
415
  ok: false,
@@ -391,7 +423,7 @@ class GatewayWeb extends core.WebPlugin {
391
423
  const frame = {
392
424
  type: "req",
393
425
  id,
394
- method: options.method,
426
+ method,
395
427
  params: options.params || {},
396
428
  };
397
429
  return new Promise((resolve, reject) => {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.GatewayWeb());\nexport const Gateway = registerPlugin(\"Gateway\", {\n web: loadWeb,\n});\n","import { WebPlugin } from \"@capacitor/core\";\n/**\n * Generate a UUID v4\n */\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n if (typeof crypto !== \"undefined\" &&\n typeof crypto.getRandomValues === \"function\") {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n }\n throw new Error(\"No secure random source available for UUID generation\");\n}\nconst isJsonObject = (value) => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst getString = (value) => typeof value === \"string\" ? value : undefined;\nconst getNumber = (value) => typeof value === \"number\" ? value : undefined;\nconst getBoolean = (value) => typeof value === \"boolean\" ? value : undefined;\nconst toStringArray = (value) => Array.isArray(value)\n ? value.filter((item) => typeof item === \"string\")\n : [];\nconst parseGatewayError = (value) => {\n if (!value || !isJsonObject(value))\n return undefined;\n const code = getString(value.code);\n const message = getString(value.message);\n if (!code || !message)\n return undefined;\n return {\n code,\n message,\n details: value.details,\n };\n};\n/**\n * Web implementation of the Gateway Plugin\n *\n * Uses browser WebSocket API for connectivity.\n * Note: Web platform cannot perform Bonjour/mDNS discovery.\n */\nexport class GatewayWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.ws = null;\n this.pending = new Map();\n this.options = null;\n this.sessionId = null;\n this.protocol = null;\n this.role = null;\n this.scopes = [];\n this.methods = [];\n this.events = [];\n this.lastSeq = null;\n this.reconnectTimer = null;\n this.backoffMs = 800;\n this.closed = false;\n this.connectResolve = null;\n this.connectReject = null;\n }\n /**\n * Start gateway discovery (not supported on web)\n *\n * On web platforms, Bonjour/mDNS discovery is not available.\n * Returns an empty list of gateways.\n */\n async startDiscovery() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Stop gateway discovery (no-op on web)\n */\n async stopDiscovery() {\n // No-op on web\n }\n /**\n * Get discovered gateways (always empty on web)\n */\n async getDiscoveredGateways() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Connect to a Gateway server\n */\n async connect(options) {\n // Close existing connection if any\n if (this.ws) {\n this.closed = true;\n this.ws.close();\n this.ws = null;\n }\n this.options = options;\n this.closed = false;\n this.backoffMs = 800;\n return new Promise((resolve, reject) => {\n this.connectResolve = resolve;\n this.connectReject = reject;\n this.establishConnection();\n });\n }\n /**\n * Establish WebSocket connection\n */\n establishConnection() {\n if (this.closed || !this.options) {\n return;\n }\n this.notifyStateChange(\"connecting\");\n this.ws = new WebSocket(this.options.url);\n this.ws.addEventListener(\"open\", () => {\n this.sendConnectFrame();\n });\n this.ws.addEventListener(\"message\", (event) => {\n this.handleMessage(String(event.data));\n });\n this.ws.addEventListener(\"close\", (event) => {\n const reason = event.reason || \"Connection closed\";\n this.handleClose(event.code, reason);\n });\n this.ws.addEventListener(\"error\", (event) => {\n console.warn(\"[Gateway] WebSocket error:\", event);\n });\n }\n /**\n * Send the connect frame to authenticate\n */\n sendConnectFrame() {\n if (!this.ws || !this.options || this.ws.readyState !== WebSocket.OPEN) {\n return;\n }\n const auth = {};\n if (this.options.token) {\n auth.token = this.options.token;\n }\n if (this.options.password) {\n auth.password = this.options.password;\n }\n const params = {\n minProtocol: 3,\n maxProtocol: 3,\n client: {\n id: this.options.clientName || \"eliza-capacitor\",\n version: this.options.clientVersion || \"1.0.0\",\n platform: this.getPlatform(),\n mode: \"ui\",\n },\n role: this.options.role || \"operator\",\n scopes: this.options.scopes || [\"operator.admin\"],\n caps: [],\n auth,\n };\n const frame = {\n type: \"req\",\n id: generateUUID(),\n method: \"connect\",\n params,\n };\n this.ws.send(JSON.stringify(frame));\n // Set up timeout for connect response\n const timeout = setTimeout(() => {\n if (this.connectReject) {\n this.connectReject(new Error(\"Connection timeout\"));\n this.connectReject = null;\n this.connectResolve = null;\n }\n }, 30000);\n this.pending.set(frame.id, {\n resolve: (result) => {\n clearTimeout(timeout);\n if (result.ok && result.payload && isJsonObject(result.payload)) {\n this.handleHelloOk(result.payload);\n }\n else {\n if (this.connectReject) {\n this.connectReject(new Error(result.error?.message || \"Connection failed\"));\n }\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n reject: (error) => {\n clearTimeout(timeout);\n if (this.connectReject) {\n this.connectReject(error);\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n timeout,\n });\n }\n /**\n * Handle successful hello response\n */\n handleHelloOk(hello) {\n const protocol = getNumber(hello.protocol);\n const auth = isJsonObject(hello.auth) ? hello.auth : null;\n const features = isJsonObject(hello.features) ? hello.features : null;\n this.sessionId = generateUUID();\n this.protocol = protocol ?? null;\n this.role = getString(auth?.role) || this.options?.role || \"operator\";\n this.scopes = toStringArray(auth?.scopes);\n this.methods = toStringArray(features?.methods);\n this.events = toStringArray(features?.events);\n this.backoffMs = 800;\n this.notifyStateChange(\"connected\");\n if (this.connectResolve) {\n this.connectResolve({\n connected: true,\n sessionId: this.sessionId,\n protocol: this.protocol ?? undefined,\n methods: this.methods,\n events: this.events,\n role: this.role,\n scopes: this.scopes,\n });\n }\n }\n /**\n * Handle incoming WebSocket message\n */\n handleMessage(raw) {\n let parsedValue;\n try {\n parsedValue = JSON.parse(raw);\n }\n catch {\n return;\n }\n if (!isJsonObject(parsedValue)) {\n return;\n }\n const frameType = getString(parsedValue.type);\n if (!frameType) {\n return;\n }\n // Handle response frames\n if (frameType === \"res\") {\n const id = getString(parsedValue.id);\n if (!id)\n return;\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n clearTimeout(pending.timeout);\n pending.resolve({\n ok: getBoolean(parsedValue.ok) ?? false,\n payload: parsedValue.payload,\n error: parseGatewayError(parsedValue.error),\n });\n }\n return;\n }\n // Handle event frames\n if (frameType === \"event\") {\n const event = getString(parsedValue.event);\n if (!event)\n return;\n const payload = parsedValue.payload;\n const seq = getNumber(parsedValue.seq);\n // Check for sequence gap\n if (seq !== undefined &&\n this.lastSeq !== null &&\n seq > this.lastSeq + 1) {\n console.warn(`[Gateway] Event sequence gap: expected ${this.lastSeq + 1}, got ${seq}`);\n }\n if (seq !== undefined) {\n this.lastSeq = seq;\n }\n // Emit the event\n this.notifyListeners(\"gatewayEvent\", {\n event,\n payload,\n seq,\n });\n return;\n }\n }\n /**\n * Handle WebSocket close\n */\n handleClose(code, reason) {\n this.ws = null;\n // Reject all pending requests\n for (const [id, pending] of this.pending) {\n clearTimeout(pending.timeout);\n pending.reject(new Error(`Connection closed: ${reason}`));\n this.pending.delete(id);\n }\n if (this.closed) {\n this.notifyStateChange(\"disconnected\", reason);\n return;\n }\n // Attempt reconnection\n this.notifyStateChange(\"reconnecting\", reason);\n this.notifyListeners(\"error\", {\n message: `Connection lost: ${reason}`,\n code: String(code),\n willRetry: true,\n });\n this.scheduleReconnect();\n }\n /**\n * Schedule a reconnection attempt\n */\n scheduleReconnect() {\n if (this.closed || this.reconnectTimer) {\n return;\n }\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.backoffMs = Math.min(this.backoffMs * 1.7, 15000);\n this.establishConnection();\n }, this.backoffMs);\n }\n /**\n * Notify state change listeners\n */\n notifyStateChange(state, reason) {\n this.notifyListeners(\"stateChange\", {\n state,\n reason,\n });\n }\n /**\n * Get platform identifier\n */\n getPlatform() {\n if (typeof navigator !== \"undefined\") {\n return navigator.platform || \"web\";\n }\n return \"web\";\n }\n /**\n * Disconnect from the Gateway\n */\n async disconnect() {\n this.closed = true;\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.ws) {\n this.ws.close(1000, \"Client disconnect\");\n this.ws = null;\n }\n this.sessionId = null;\n this.protocol = null;\n this.notifyStateChange(\"disconnected\", \"Client disconnect\");\n }\n /**\n * Check if connected\n */\n async isConnected() {\n return {\n connected: this.ws !== null && this.ws.readyState === WebSocket.OPEN,\n };\n }\n /**\n * Send an RPC request\n */\n async send(options) {\n if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n return {\n ok: false,\n error: {\n code: \"NOT_CONNECTED\",\n message: \"Not connected to gateway\",\n },\n };\n }\n const id = generateUUID();\n const frame = {\n type: \"req\",\n id,\n method: options.method,\n params: options.params || {},\n };\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(id);\n resolve({\n ok: false,\n error: {\n code: \"TIMEOUT\",\n message: \"Request timed out\",\n },\n });\n }, 60000); // 60 second timeout\n this.pending.set(id, {\n resolve,\n reject,\n timeout,\n });\n this.ws?.send(JSON.stringify(frame));\n });\n }\n /**\n * Get connection info\n */\n async getConnectionInfo() {\n return {\n url: this.options?.url || null,\n sessionId: this.sessionId,\n protocol: this.protocol,\n role: this.role,\n };\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAEA,MA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AAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAChD,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,OAAO;AACf,YAAY,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI;AAC1C,YAAY,SAAS,EAAE,IAAI,CAAC,SAAS;AACrC,YAAY,QAAQ,EAAE,IAAI,CAAC,QAAQ;AACnC,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,SAAS;AACT,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.GatewayWeb());\nexport const Gateway = registerPlugin(\"Gateway\", {\n web: loadWeb,\n});\n","import { WebPlugin } from \"@capacitor/core\";\n/**\n * Generate a UUID v4\n */\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n if (typeof crypto !== \"undefined\" &&\n typeof crypto.getRandomValues === \"function\") {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n }\n throw new Error(\"No secure random source available for UUID generation\");\n}\nconst isJsonObject = (value) => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst getString = (value) => typeof value === \"string\" ? value : undefined;\nconst getNumber = (value) => typeof value === \"number\" ? value : undefined;\nconst getBoolean = (value) => typeof value === \"boolean\" ? value : undefined;\nconst toStringArray = (value) => Array.isArray(value)\n ? value.filter((item) => typeof item === \"string\")\n : [];\nconst parseGatewayError = (value) => {\n if (!value || !isJsonObject(value))\n return undefined;\n const code = getString(value.code);\n const message = getString(value.message);\n if (!code || !message)\n return undefined;\n return {\n code,\n message,\n details: value.details,\n };\n};\nfunction assertGatewayUrl(url) {\n if (typeof url !== \"string\" || url.trim().length === 0) {\n throw new Error(\"url must be a non-empty WebSocket URL\");\n }\n let parsed;\n try {\n parsed = new URL(url);\n }\n catch {\n throw new Error(\"url must be a valid WebSocket URL\");\n }\n if (parsed.protocol !== \"ws:\" && parsed.protocol !== \"wss:\") {\n throw new Error(\"url must use ws: or wss:\");\n }\n return parsed.toString();\n}\nfunction assertRpcMethod(method) {\n if (typeof method !== \"string\" || method.trim().length === 0) {\n throw new Error(\"method must be a non-empty string\");\n }\n const normalized = method.trim();\n if (normalized !== method) {\n throw new Error(\"method must not contain leading or trailing whitespace\");\n }\n if (!/^[a-zA-Z][a-zA-Z0-9_.:-]{0,127}$/.test(normalized)) {\n throw new Error(\"method contains invalid characters\");\n }\n return normalized;\n}\n/**\n * Web implementation of the Gateway Plugin\n *\n * Uses browser WebSocket API for connectivity.\n * Note: Web platform cannot perform Bonjour/mDNS discovery.\n */\nexport class GatewayWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.ws = null;\n this.pending = new Map();\n this.options = null;\n this.sessionId = null;\n this.protocol = null;\n this.role = null;\n this.scopes = [];\n this.methods = [];\n this.events = [];\n this.lastSeq = null;\n this.reconnectTimer = null;\n this.backoffMs = 800;\n this.closed = false;\n this.connectResolve = null;\n this.connectReject = null;\n }\n /**\n * Start gateway discovery (not supported on web)\n *\n * On web platforms, Bonjour/mDNS discovery is not available.\n * Returns an empty list of gateways.\n */\n async startDiscovery() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Stop gateway discovery. Web discovery is unsupported, so there is no\n * active browser discovery session to stop.\n */\n async stopDiscovery() {\n // Web platforms never start Bonjour/mDNS discovery.\n }\n /**\n * Get discovered gateways (always empty on web)\n */\n async getDiscoveredGateways() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Connect to a Gateway server\n */\n async connect(options) {\n const url = assertGatewayUrl(options.url);\n // Close existing connection if any\n if (this.ws) {\n this.closed = true;\n this.ws.close();\n this.ws = null;\n }\n this.options = { ...options, url };\n this.closed = false;\n this.backoffMs = 800;\n return new Promise((resolve, reject) => {\n this.connectResolve = resolve;\n this.connectReject = reject;\n this.establishConnection();\n });\n }\n /**\n * Establish WebSocket connection\n */\n establishConnection() {\n if (this.closed || !this.options) {\n return;\n }\n this.notifyStateChange(\"connecting\");\n this.ws = new WebSocket(this.options.url);\n this.ws.addEventListener(\"open\", () => {\n this.sendConnectFrame();\n });\n this.ws.addEventListener(\"message\", (event) => {\n this.handleMessage(String(event.data));\n });\n this.ws.addEventListener(\"close\", (event) => {\n const reason = event.reason || \"Connection closed\";\n this.handleClose(event.code, reason);\n });\n this.ws.addEventListener(\"error\", (event) => {\n console.warn(\"[Gateway] WebSocket error:\", event);\n });\n }\n /**\n * Send the connect frame to authenticate\n */\n sendConnectFrame() {\n if (!this.ws || !this.options || this.ws.readyState !== WebSocket.OPEN) {\n return;\n }\n const auth = {};\n if (this.options.token) {\n auth.token = this.options.token;\n }\n if (this.options.password) {\n auth.password = this.options.password;\n }\n const params = {\n minProtocol: 3,\n maxProtocol: 3,\n client: {\n id: this.options.clientName || \"eliza-capacitor\",\n version: this.options.clientVersion || \"1.0.0\",\n platform: this.getPlatform(),\n mode: \"ui\",\n },\n role: this.options.role || \"operator\",\n scopes: this.options.scopes || [\"operator.admin\"],\n caps: [],\n auth,\n };\n const frame = {\n type: \"req\",\n id: generateUUID(),\n method: \"connect\",\n params,\n };\n this.ws.send(JSON.stringify(frame));\n // Set up timeout for connect response\n const timeout = setTimeout(() => {\n if (this.connectReject) {\n this.connectReject(new Error(\"Connection timeout\"));\n this.connectReject = null;\n this.connectResolve = null;\n }\n }, 30000);\n this.pending.set(frame.id, {\n resolve: (result) => {\n clearTimeout(timeout);\n if (result.ok && result.payload && isJsonObject(result.payload)) {\n this.handleHelloOk(result.payload);\n }\n else {\n if (this.connectReject) {\n this.connectReject(new Error(result.error?.message || \"Connection failed\"));\n }\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n reject: (error) => {\n clearTimeout(timeout);\n if (this.connectReject) {\n this.connectReject(error);\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n timeout,\n });\n }\n /**\n * Handle successful hello response\n */\n handleHelloOk(hello) {\n const protocol = getNumber(hello.protocol);\n const auth = isJsonObject(hello.auth) ? hello.auth : null;\n const features = isJsonObject(hello.features) ? hello.features : null;\n this.sessionId = generateUUID();\n this.protocol = protocol ?? null;\n this.role = getString(auth?.role) || this.options?.role || \"operator\";\n this.scopes = toStringArray(auth?.scopes);\n this.methods = toStringArray(features?.methods);\n this.events = toStringArray(features?.events);\n this.backoffMs = 800;\n this.notifyStateChange(\"connected\");\n if (this.connectResolve) {\n this.connectResolve({\n connected: true,\n sessionId: this.sessionId,\n protocol: this.protocol ?? undefined,\n methods: this.methods,\n events: this.events,\n role: this.role,\n scopes: this.scopes,\n });\n }\n }\n /**\n * Handle incoming WebSocket message\n */\n handleMessage(raw) {\n let parsedValue;\n try {\n parsedValue = JSON.parse(raw);\n }\n catch {\n return;\n }\n if (!isJsonObject(parsedValue)) {\n return;\n }\n const frameType = getString(parsedValue.type);\n if (!frameType) {\n return;\n }\n // Handle response frames\n if (frameType === \"res\") {\n const id = getString(parsedValue.id);\n if (!id)\n return;\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n clearTimeout(pending.timeout);\n pending.resolve({\n ok: getBoolean(parsedValue.ok) ?? false,\n payload: parsedValue.payload,\n error: parseGatewayError(parsedValue.error),\n });\n }\n return;\n }\n // Handle event frames\n if (frameType === \"event\") {\n const event = getString(parsedValue.event);\n if (!event)\n return;\n const payload = parsedValue.payload;\n const seq = getNumber(parsedValue.seq);\n // Check for sequence gap\n if (seq !== undefined &&\n this.lastSeq !== null &&\n seq > this.lastSeq + 1) {\n console.warn(`[Gateway] Event sequence gap: expected ${this.lastSeq + 1}, got ${seq}`);\n }\n if (seq !== undefined) {\n this.lastSeq = seq;\n }\n // Emit the event\n this.notifyListeners(\"gatewayEvent\", {\n event,\n payload,\n seq,\n });\n return;\n }\n }\n /**\n * Handle WebSocket close\n */\n handleClose(code, reason) {\n this.ws = null;\n // Reject all pending requests\n for (const [id, pending] of this.pending) {\n clearTimeout(pending.timeout);\n pending.reject(new Error(`Connection closed: ${reason}`));\n this.pending.delete(id);\n }\n if (this.closed) {\n this.notifyStateChange(\"disconnected\", reason);\n return;\n }\n // Attempt reconnection\n this.notifyStateChange(\"reconnecting\", reason);\n this.notifyListeners(\"error\", {\n message: `Connection lost: ${reason}`,\n code: String(code),\n willRetry: true,\n });\n this.scheduleReconnect();\n }\n /**\n * Schedule a reconnection attempt\n */\n scheduleReconnect() {\n if (this.closed || this.reconnectTimer) {\n return;\n }\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.backoffMs = Math.min(this.backoffMs * 1.7, 15000);\n this.establishConnection();\n }, this.backoffMs);\n }\n /**\n * Notify state change listeners\n */\n notifyStateChange(state, reason) {\n this.notifyListeners(\"stateChange\", {\n state,\n reason,\n });\n }\n /**\n * Get platform identifier\n */\n getPlatform() {\n if (typeof navigator !== \"undefined\") {\n return navigator.platform || \"web\";\n }\n return \"web\";\n }\n /**\n * Disconnect from the Gateway\n */\n async disconnect() {\n this.closed = true;\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.ws) {\n this.ws.close(1000, \"Client disconnect\");\n this.ws = null;\n }\n this.sessionId = null;\n this.protocol = null;\n this.notifyStateChange(\"disconnected\", \"Client disconnect\");\n }\n /**\n * Check if connected\n */\n async isConnected() {\n return {\n connected: this.ws !== null && this.ws.readyState === WebSocket.OPEN,\n };\n }\n /**\n * Send an RPC request\n */\n async send(options) {\n const method = assertRpcMethod(options.method);\n if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n return {\n ok: false,\n error: {\n code: \"NOT_CONNECTED\",\n message: \"Not connected to gateway\",\n },\n };\n }\n const id = generateUUID();\n const frame = {\n type: \"req\",\n id,\n method,\n params: options.params || {},\n };\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(id);\n resolve({\n ok: false,\n error: {\n code: \"TIMEOUT\",\n message: \"Request timed out\",\n },\n });\n }, 60000); // 60 second timeout\n this.pending.set(id, {\n resolve,\n reject,\n timeout,\n });\n this.ws?.send(JSON.stringify(frame));\n });\n }\n /**\n * Get connection info\n */\n async getConnectionInfo() {\n return {\n url: this.options?.url || null,\n sessionId: this.sessionId,\n protocol: this.protocol,\n role: this.role,\n };\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;AACzD,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;AACjD,IAAI,GAAG,EAAE,OAAO;AAChB,CAAC;;ACJD;AACA;AACA;AACA,SAAS,YAAY,GAAG;AACxB,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,EAAE;AAC5D,QAAQ,OAAO,MAAM,CAAC,UAAU,EAAE;AAClC,IAAI;AACJ,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW;AACrC,QAAQ,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE;AACtD,QAAQ,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;AACxC,QAAQ,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC;AACrC,QAAQ,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAA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EAAE;AACxC,SAAS;AACT,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;AAC7C,gBAAgB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;AACvC,gBAAgB,OAAO,CAAC;AACxB,oBAAoB,EAAE,EAAE,KAAK;AAC7B,oBAAoB,KAAK,EAAE;AAC3B,wBAAwB,IAAI,EAAE,SAAS;AACvC,wBAAwB,OAAO,EAAE,mBAAmB;AACpD,qBAAqB;AACrB,iBAAiB,CAAC;AAClB,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;AACtB,YAAY,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE;AACjC,gBAAgB,OAAO;AACvB,gBAAgB,MAAM;AACtB,gBAAgB,OAAO;AACvB,aAAa,CAAC;AACd,YAAY,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAChD,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,OAAO;AACf,YAAY,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI;AAC1C,YAAY,SAAS,EAAE,IAAI,CAAC,SAAS;AACrC,YAAY,QAAQ,EAAE,IAAI,CAAC,QAAQ;AACnC,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,SAAS;AACT,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -44,6 +44,35 @@ var capacitorGateway = (function (exports, core) {
44
44
  details: value.details,
45
45
  };
46
46
  };
47
+ function assertGatewayUrl(url) {
48
+ if (typeof url !== "string" || url.trim().length === 0) {
49
+ throw new Error("url must be a non-empty WebSocket URL");
50
+ }
51
+ let parsed;
52
+ try {
53
+ parsed = new URL(url);
54
+ }
55
+ catch {
56
+ throw new Error("url must be a valid WebSocket URL");
57
+ }
58
+ if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
59
+ throw new Error("url must use ws: or wss:");
60
+ }
61
+ return parsed.toString();
62
+ }
63
+ function assertRpcMethod(method) {
64
+ if (typeof method !== "string" || method.trim().length === 0) {
65
+ throw new Error("method must be a non-empty string");
66
+ }
67
+ const normalized = method.trim();
68
+ if (normalized !== method) {
69
+ throw new Error("method must not contain leading or trailing whitespace");
70
+ }
71
+ if (!/^[a-zA-Z][a-zA-Z0-9_.:-]{0,127}$/.test(normalized)) {
72
+ throw new Error("method contains invalid characters");
73
+ }
74
+ return normalized;
75
+ }
47
76
  /**
48
77
  * Web implementation of the Gateway Plugin
49
78
  *
@@ -82,10 +111,11 @@ var capacitorGateway = (function (exports, core) {
82
111
  };
83
112
  }
84
113
  /**
85
- * Stop gateway discovery (no-op on web)
114
+ * Stop gateway discovery. Web discovery is unsupported, so there is no
115
+ * active browser discovery session to stop.
86
116
  */
87
117
  async stopDiscovery() {
88
- // No-op on web
118
+ // Web platforms never start Bonjour/mDNS discovery.
89
119
  }
90
120
  /**
91
121
  * Get discovered gateways (always empty on web)
@@ -100,13 +130,14 @@ var capacitorGateway = (function (exports, core) {
100
130
  * Connect to a Gateway server
101
131
  */
102
132
  async connect(options) {
133
+ const url = assertGatewayUrl(options.url);
103
134
  // Close existing connection if any
104
135
  if (this.ws) {
105
136
  this.closed = true;
106
137
  this.ws.close();
107
138
  this.ws = null;
108
139
  }
109
- this.options = options;
140
+ this.options = { ...options, url };
110
141
  this.closed = false;
111
142
  this.backoffMs = 800;
112
143
  return new Promise((resolve, reject) => {
@@ -377,6 +408,7 @@ var capacitorGateway = (function (exports, core) {
377
408
  * Send an RPC request
378
409
  */
379
410
  async send(options) {
411
+ const method = assertRpcMethod(options.method);
380
412
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
381
413
  return {
382
414
  ok: false,
@@ -390,7 +422,7 @@ var capacitorGateway = (function (exports, core) {
390
422
  const frame = {
391
423
  type: "req",
392
424
  id,
393
- method: options.method,
425
+ method,
394
426
  params: options.params || {},
395
427
  };
396
428
  return new Promise((resolve, reject) => {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.GatewayWeb());\nexport const Gateway = registerPlugin(\"Gateway\", {\n web: loadWeb,\n});\n","import { WebPlugin } from \"@capacitor/core\";\n/**\n * Generate a UUID v4\n */\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n if (typeof crypto !== \"undefined\" &&\n typeof crypto.getRandomValues === \"function\") {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n }\n throw new Error(\"No secure random source available for UUID generation\");\n}\nconst isJsonObject = (value) => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst getString = (value) => typeof value === \"string\" ? value : undefined;\nconst getNumber = (value) => typeof value === \"number\" ? value : undefined;\nconst getBoolean = (value) => typeof value === \"boolean\" ? value : undefined;\nconst toStringArray = (value) => Array.isArray(value)\n ? value.filter((item) => typeof item === \"string\")\n : [];\nconst parseGatewayError = (value) => {\n if (!value || !isJsonObject(value))\n return undefined;\n const code = getString(value.code);\n const message = getString(value.message);\n if (!code || !message)\n return undefined;\n return {\n code,\n message,\n details: value.details,\n };\n};\n/**\n * Web implementation of the Gateway Plugin\n *\n * Uses browser WebSocket API for connectivity.\n * Note: Web platform cannot perform Bonjour/mDNS discovery.\n */\nexport class GatewayWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.ws = null;\n this.pending = new Map();\n this.options = null;\n this.sessionId = null;\n this.protocol = null;\n this.role = null;\n this.scopes = [];\n this.methods = [];\n this.events = [];\n this.lastSeq = null;\n this.reconnectTimer = null;\n this.backoffMs = 800;\n this.closed = false;\n this.connectResolve = null;\n this.connectReject = null;\n }\n /**\n * Start gateway discovery (not supported on web)\n *\n * On web platforms, Bonjour/mDNS discovery is not available.\n * Returns an empty list of gateways.\n */\n async startDiscovery() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Stop gateway discovery (no-op on web)\n */\n async stopDiscovery() {\n // No-op on web\n }\n /**\n * Get discovered gateways (always empty on web)\n */\n async getDiscoveredGateways() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Connect to a Gateway server\n */\n async connect(options) {\n // Close existing connection if any\n if (this.ws) {\n this.closed = true;\n this.ws.close();\n this.ws = null;\n }\n this.options = options;\n this.closed = false;\n this.backoffMs = 800;\n return new Promise((resolve, reject) => {\n this.connectResolve = resolve;\n this.connectReject = reject;\n this.establishConnection();\n });\n }\n /**\n * Establish WebSocket connection\n */\n establishConnection() {\n if (this.closed || !this.options) {\n return;\n }\n this.notifyStateChange(\"connecting\");\n this.ws = new WebSocket(this.options.url);\n this.ws.addEventListener(\"open\", () => {\n this.sendConnectFrame();\n });\n this.ws.addEventListener(\"message\", (event) => {\n this.handleMessage(String(event.data));\n });\n this.ws.addEventListener(\"close\", (event) => {\n const reason = event.reason || \"Connection closed\";\n this.handleClose(event.code, reason);\n });\n this.ws.addEventListener(\"error\", (event) => {\n console.warn(\"[Gateway] WebSocket error:\", event);\n });\n }\n /**\n * Send the connect frame to authenticate\n */\n sendConnectFrame() {\n if (!this.ws || !this.options || this.ws.readyState !== WebSocket.OPEN) {\n return;\n }\n const auth = {};\n if (this.options.token) {\n auth.token = this.options.token;\n }\n if (this.options.password) {\n auth.password = this.options.password;\n }\n const params = {\n minProtocol: 3,\n maxProtocol: 3,\n client: {\n id: this.options.clientName || \"eliza-capacitor\",\n version: this.options.clientVersion || \"1.0.0\",\n platform: this.getPlatform(),\n mode: \"ui\",\n },\n role: this.options.role || \"operator\",\n scopes: this.options.scopes || [\"operator.admin\"],\n caps: [],\n auth,\n };\n const frame = {\n type: \"req\",\n id: generateUUID(),\n method: \"connect\",\n params,\n };\n this.ws.send(JSON.stringify(frame));\n // Set up timeout for connect response\n const timeout = setTimeout(() => {\n if (this.connectReject) {\n this.connectReject(new Error(\"Connection timeout\"));\n this.connectReject = null;\n this.connectResolve = null;\n }\n }, 30000);\n this.pending.set(frame.id, {\n resolve: (result) => {\n clearTimeout(timeout);\n if (result.ok && result.payload && isJsonObject(result.payload)) {\n this.handleHelloOk(result.payload);\n }\n else {\n if (this.connectReject) {\n this.connectReject(new Error(result.error?.message || \"Connection failed\"));\n }\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n reject: (error) => {\n clearTimeout(timeout);\n if (this.connectReject) {\n this.connectReject(error);\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n timeout,\n });\n }\n /**\n * Handle successful hello response\n */\n handleHelloOk(hello) {\n const protocol = getNumber(hello.protocol);\n const auth = isJsonObject(hello.auth) ? hello.auth : null;\n const features = isJsonObject(hello.features) ? hello.features : null;\n this.sessionId = generateUUID();\n this.protocol = protocol ?? null;\n this.role = getString(auth?.role) || this.options?.role || \"operator\";\n this.scopes = toStringArray(auth?.scopes);\n this.methods = toStringArray(features?.methods);\n this.events = toStringArray(features?.events);\n this.backoffMs = 800;\n this.notifyStateChange(\"connected\");\n if (this.connectResolve) {\n this.connectResolve({\n connected: true,\n sessionId: this.sessionId,\n protocol: this.protocol ?? undefined,\n methods: this.methods,\n events: this.events,\n role: this.role,\n scopes: this.scopes,\n });\n }\n }\n /**\n * Handle incoming WebSocket message\n */\n handleMessage(raw) {\n let parsedValue;\n try {\n parsedValue = JSON.parse(raw);\n }\n catch {\n return;\n }\n if (!isJsonObject(parsedValue)) {\n return;\n }\n const frameType = getString(parsedValue.type);\n if (!frameType) {\n return;\n }\n // Handle response frames\n if (frameType === \"res\") {\n const id = getString(parsedValue.id);\n if (!id)\n return;\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n clearTimeout(pending.timeout);\n pending.resolve({\n ok: getBoolean(parsedValue.ok) ?? false,\n payload: parsedValue.payload,\n error: parseGatewayError(parsedValue.error),\n });\n }\n return;\n }\n // Handle event frames\n if (frameType === \"event\") {\n const event = getString(parsedValue.event);\n if (!event)\n return;\n const payload = parsedValue.payload;\n const seq = getNumber(parsedValue.seq);\n // Check for sequence gap\n if (seq !== undefined &&\n this.lastSeq !== null &&\n seq > this.lastSeq + 1) {\n console.warn(`[Gateway] Event sequence gap: expected ${this.lastSeq + 1}, got ${seq}`);\n }\n if (seq !== undefined) {\n this.lastSeq = seq;\n }\n // Emit the event\n this.notifyListeners(\"gatewayEvent\", {\n event,\n payload,\n seq,\n });\n return;\n }\n }\n /**\n * Handle WebSocket close\n */\n handleClose(code, reason) {\n this.ws = null;\n // Reject all pending requests\n for (const [id, pending] of this.pending) {\n clearTimeout(pending.timeout);\n pending.reject(new Error(`Connection closed: ${reason}`));\n this.pending.delete(id);\n }\n if (this.closed) {\n this.notifyStateChange(\"disconnected\", reason);\n return;\n }\n // Attempt reconnection\n this.notifyStateChange(\"reconnecting\", reason);\n this.notifyListeners(\"error\", {\n message: `Connection lost: ${reason}`,\n code: String(code),\n willRetry: true,\n });\n this.scheduleReconnect();\n }\n /**\n * Schedule a reconnection attempt\n */\n scheduleReconnect() {\n if (this.closed || this.reconnectTimer) {\n return;\n }\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.backoffMs = Math.min(this.backoffMs * 1.7, 15000);\n this.establishConnection();\n }, this.backoffMs);\n }\n /**\n * Notify state change listeners\n */\n notifyStateChange(state, reason) {\n this.notifyListeners(\"stateChange\", {\n state,\n reason,\n });\n }\n /**\n * Get platform identifier\n */\n getPlatform() {\n if (typeof navigator !== \"undefined\") {\n return navigator.platform || \"web\";\n }\n return \"web\";\n }\n /**\n * Disconnect from the Gateway\n */\n async disconnect() {\n this.closed = true;\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.ws) {\n this.ws.close(1000, \"Client disconnect\");\n this.ws = null;\n }\n this.sessionId = null;\n this.protocol = null;\n this.notifyStateChange(\"disconnected\", \"Client disconnect\");\n }\n /**\n * Check if connected\n */\n async isConnected() {\n return {\n connected: this.ws !== null && this.ws.readyState === WebSocket.OPEN,\n };\n }\n /**\n * Send an RPC request\n */\n async send(options) {\n if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n return {\n ok: false,\n error: {\n code: \"NOT_CONNECTED\",\n message: \"Not connected to gateway\",\n },\n };\n }\n const id = generateUUID();\n const frame = {\n type: \"req\",\n id,\n method: options.method,\n params: options.params || {},\n };\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(id);\n resolve({\n ok: false,\n error: {\n code: \"TIMEOUT\",\n message: \"Request timed out\",\n },\n });\n }, 60000); // 60 second timeout\n this.pending.set(id, {\n resolve,\n reject,\n timeout,\n });\n this.ws?.send(JSON.stringify(frame));\n });\n }\n /**\n * Get connection info\n */\n async getConnectionInfo() {\n return {\n url: this.options?.url || null,\n sessionId: this.sessionId,\n protocol: this.protocol,\n role: this.role,\n };\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;AACzD,UAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;IACjD,IAAI,GAAG,EAAE,OAAO;IAChB,CAAC;;ICJD;IACA;IACA;IACA,SAAS,YAAY,GAAG;IACxB,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW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AE,IAAI,CAAC,QAAQ;IACnC,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;IAC3B,SAAS;IACT,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.GatewayWeb());\nexport const Gateway = registerPlugin(\"Gateway\", {\n web: loadWeb,\n});\n","import { WebPlugin } from \"@capacitor/core\";\n/**\n * Generate a UUID v4\n */\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n if (typeof crypto !== \"undefined\" &&\n typeof crypto.getRandomValues === \"function\") {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n }\n throw new Error(\"No secure random source available for UUID generation\");\n}\nconst isJsonObject = (value) => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst getString = (value) => typeof value === \"string\" ? value : undefined;\nconst getNumber = (value) => typeof value === \"number\" ? value : undefined;\nconst getBoolean = (value) => typeof value === \"boolean\" ? value : undefined;\nconst toStringArray = (value) => Array.isArray(value)\n ? value.filter((item) => typeof item === \"string\")\n : [];\nconst parseGatewayError = (value) => {\n if (!value || !isJsonObject(value))\n return undefined;\n const code = getString(value.code);\n const message = getString(value.message);\n if (!code || !message)\n return undefined;\n return {\n code,\n message,\n details: value.details,\n };\n};\nfunction assertGatewayUrl(url) {\n if (typeof url !== \"string\" || url.trim().length === 0) {\n throw new Error(\"url must be a non-empty WebSocket URL\");\n }\n let parsed;\n try {\n parsed = new URL(url);\n }\n catch {\n throw new Error(\"url must be a valid WebSocket URL\");\n }\n if (parsed.protocol !== \"ws:\" && parsed.protocol !== \"wss:\") {\n throw new Error(\"url must use ws: or wss:\");\n }\n return parsed.toString();\n}\nfunction assertRpcMethod(method) {\n if (typeof method !== \"string\" || method.trim().length === 0) {\n throw new Error(\"method must be a non-empty string\");\n }\n const normalized = method.trim();\n if (normalized !== method) {\n throw new Error(\"method must not contain leading or trailing whitespace\");\n }\n if (!/^[a-zA-Z][a-zA-Z0-9_.:-]{0,127}$/.test(normalized)) {\n throw new Error(\"method contains invalid characters\");\n }\n return normalized;\n}\n/**\n * Web implementation of the Gateway Plugin\n *\n * Uses browser WebSocket API for connectivity.\n * Note: Web platform cannot perform Bonjour/mDNS discovery.\n */\nexport class GatewayWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.ws = null;\n this.pending = new Map();\n this.options = null;\n this.sessionId = null;\n this.protocol = null;\n this.role = null;\n this.scopes = [];\n this.methods = [];\n this.events = [];\n this.lastSeq = null;\n this.reconnectTimer = null;\n this.backoffMs = 800;\n this.closed = false;\n this.connectResolve = null;\n this.connectReject = null;\n }\n /**\n * Start gateway discovery (not supported on web)\n *\n * On web platforms, Bonjour/mDNS discovery is not available.\n * Returns an empty list of gateways.\n */\n async startDiscovery() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Stop gateway discovery. Web discovery is unsupported, so there is no\n * active browser discovery session to stop.\n */\n async stopDiscovery() {\n // Web platforms never start Bonjour/mDNS discovery.\n }\n /**\n * Get discovered gateways (always empty on web)\n */\n async getDiscoveredGateways() {\n return {\n gateways: [],\n status: \"Discovery not supported on web platform\",\n };\n }\n /**\n * Connect to a Gateway server\n */\n async connect(options) {\n const url = assertGatewayUrl(options.url);\n // Close existing connection if any\n if (this.ws) {\n this.closed = true;\n this.ws.close();\n this.ws = null;\n }\n this.options = { ...options, url };\n this.closed = false;\n this.backoffMs = 800;\n return new Promise((resolve, reject) => {\n this.connectResolve = resolve;\n this.connectReject = reject;\n this.establishConnection();\n });\n }\n /**\n * Establish WebSocket connection\n */\n establishConnection() {\n if (this.closed || !this.options) {\n return;\n }\n this.notifyStateChange(\"connecting\");\n this.ws = new WebSocket(this.options.url);\n this.ws.addEventListener(\"open\", () => {\n this.sendConnectFrame();\n });\n this.ws.addEventListener(\"message\", (event) => {\n this.handleMessage(String(event.data));\n });\n this.ws.addEventListener(\"close\", (event) => {\n const reason = event.reason || \"Connection closed\";\n this.handleClose(event.code, reason);\n });\n this.ws.addEventListener(\"error\", (event) => {\n console.warn(\"[Gateway] WebSocket error:\", event);\n });\n }\n /**\n * Send the connect frame to authenticate\n */\n sendConnectFrame() {\n if (!this.ws || !this.options || this.ws.readyState !== WebSocket.OPEN) {\n return;\n }\n const auth = {};\n if (this.options.token) {\n auth.token = this.options.token;\n }\n if (this.options.password) {\n auth.password = this.options.password;\n }\n const params = {\n minProtocol: 3,\n maxProtocol: 3,\n client: {\n id: this.options.clientName || \"eliza-capacitor\",\n version: this.options.clientVersion || \"1.0.0\",\n platform: this.getPlatform(),\n mode: \"ui\",\n },\n role: this.options.role || \"operator\",\n scopes: this.options.scopes || [\"operator.admin\"],\n caps: [],\n auth,\n };\n const frame = {\n type: \"req\",\n id: generateUUID(),\n method: \"connect\",\n params,\n };\n this.ws.send(JSON.stringify(frame));\n // Set up timeout for connect response\n const timeout = setTimeout(() => {\n if (this.connectReject) {\n this.connectReject(new Error(\"Connection timeout\"));\n this.connectReject = null;\n this.connectResolve = null;\n }\n }, 30000);\n this.pending.set(frame.id, {\n resolve: (result) => {\n clearTimeout(timeout);\n if (result.ok && result.payload && isJsonObject(result.payload)) {\n this.handleHelloOk(result.payload);\n }\n else {\n if (this.connectReject) {\n this.connectReject(new Error(result.error?.message || \"Connection failed\"));\n }\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n reject: (error) => {\n clearTimeout(timeout);\n if (this.connectReject) {\n this.connectReject(error);\n }\n this.connectReject = null;\n this.connectResolve = null;\n },\n timeout,\n });\n }\n /**\n * Handle successful hello response\n */\n handleHelloOk(hello) {\n const protocol = getNumber(hello.protocol);\n const auth = isJsonObject(hello.auth) ? hello.auth : null;\n const features = isJsonObject(hello.features) ? hello.features : null;\n this.sessionId = generateUUID();\n this.protocol = protocol ?? null;\n this.role = getString(auth?.role) || this.options?.role || \"operator\";\n this.scopes = toStringArray(auth?.scopes);\n this.methods = toStringArray(features?.methods);\n this.events = toStringArray(features?.events);\n this.backoffMs = 800;\n this.notifyStateChange(\"connected\");\n if (this.connectResolve) {\n this.connectResolve({\n connected: true,\n sessionId: this.sessionId,\n protocol: this.protocol ?? undefined,\n methods: this.methods,\n events: this.events,\n role: this.role,\n scopes: this.scopes,\n });\n }\n }\n /**\n * Handle incoming WebSocket message\n */\n handleMessage(raw) {\n let parsedValue;\n try {\n parsedValue = JSON.parse(raw);\n }\n catch {\n return;\n }\n if (!isJsonObject(parsedValue)) {\n return;\n }\n const frameType = getString(parsedValue.type);\n if (!frameType) {\n return;\n }\n // Handle response frames\n if (frameType === \"res\") {\n const id = getString(parsedValue.id);\n if (!id)\n return;\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n clearTimeout(pending.timeout);\n pending.resolve({\n ok: getBoolean(parsedValue.ok) ?? false,\n payload: parsedValue.payload,\n error: parseGatewayError(parsedValue.error),\n });\n }\n return;\n }\n // Handle event frames\n if (frameType === \"event\") {\n const event = getString(parsedValue.event);\n if (!event)\n return;\n const payload = parsedValue.payload;\n const seq = getNumber(parsedValue.seq);\n // Check for sequence gap\n if (seq !== undefined &&\n this.lastSeq !== null &&\n seq > this.lastSeq + 1) {\n console.warn(`[Gateway] Event sequence gap: expected ${this.lastSeq + 1}, got ${seq}`);\n }\n if (seq !== undefined) {\n this.lastSeq = seq;\n }\n // Emit the event\n this.notifyListeners(\"gatewayEvent\", {\n event,\n payload,\n seq,\n });\n return;\n }\n }\n /**\n * Handle WebSocket close\n */\n handleClose(code, reason) {\n this.ws = null;\n // Reject all pending requests\n for (const [id, pending] of this.pending) {\n clearTimeout(pending.timeout);\n pending.reject(new Error(`Connection closed: ${reason}`));\n this.pending.delete(id);\n }\n if (this.closed) {\n this.notifyStateChange(\"disconnected\", reason);\n return;\n }\n // Attempt reconnection\n this.notifyStateChange(\"reconnecting\", reason);\n this.notifyListeners(\"error\", {\n message: `Connection lost: ${reason}`,\n code: String(code),\n willRetry: true,\n });\n this.scheduleReconnect();\n }\n /**\n * Schedule a reconnection attempt\n */\n scheduleReconnect() {\n if (this.closed || this.reconnectTimer) {\n return;\n }\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.backoffMs = Math.min(this.backoffMs * 1.7, 15000);\n this.establishConnection();\n }, this.backoffMs);\n }\n /**\n * Notify state change listeners\n */\n notifyStateChange(state, reason) {\n this.notifyListeners(\"stateChange\", {\n state,\n reason,\n });\n }\n /**\n * Get platform identifier\n */\n getPlatform() {\n if (typeof navigator !== \"undefined\") {\n return navigator.platform || \"web\";\n }\n return \"web\";\n }\n /**\n * Disconnect from the Gateway\n */\n async disconnect() {\n this.closed = true;\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.ws) {\n this.ws.close(1000, \"Client disconnect\");\n this.ws = null;\n }\n this.sessionId = null;\n this.protocol = null;\n this.notifyStateChange(\"disconnected\", \"Client disconnect\");\n }\n /**\n * Check if connected\n */\n async isConnected() {\n return {\n connected: this.ws !== null && this.ws.readyState === WebSocket.OPEN,\n };\n }\n /**\n * Send an RPC request\n */\n async send(options) {\n const method = assertRpcMethod(options.method);\n if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n return {\n ok: false,\n error: {\n code: \"NOT_CONNECTED\",\n message: \"Not connected to gateway\",\n },\n };\n }\n const id = generateUUID();\n const frame = {\n type: \"req\",\n id,\n method,\n params: options.params || {},\n };\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(id);\n resolve({\n ok: false,\n error: {\n code: \"TIMEOUT\",\n message: \"Request timed out\",\n },\n });\n }, 60000); // 60 second timeout\n this.pending.set(id, {\n resolve,\n reject,\n timeout,\n });\n this.ws?.send(JSON.stringify(frame));\n });\n }\n /**\n * Get connection info\n */\n async getConnectionInfo() {\n return {\n url: this.options?.url || null,\n sessionId: this.sessionId,\n protocol: this.protocol,\n role: this.role,\n };\n }\n}\n"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;AACzD,UAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;IACjD,IAAI,GAAG,EAAE,OAAO;IAChB,CAAC;;ICJD;IACA;IACA;IACA,SAAS,YAAY,GAAG;IACxB,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,EAAE;IAC5D,QAAQ,OAAO,MAAM,CAAC,UAAU,EAAE;IAClC,IAAI;IACJ,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW;IACrC,QAAQ,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE;IACtD,QAAQ,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC;IACxC,QAAQ,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC;IACrC,QAAQ,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI;IAC3C,QAAQ,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI;IAC3C,QAAQ,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC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AK,EAAE;IAC3B,wBAAwB,IAAI,EAAE,SAAS;IACvC,wBAAwB,OAAO,EAAE,mBAAmB;IACpD,qBAAqB;IACrB,iBAAiB,CAAC;IAClB,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IACtB,YAAY,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE;IACjC,gBAAgB,OAAO;IACvB,gBAAgB,MAAM;IACtB,gBAAgB,OAAO;IACvB,aAAa,CAAC;IACd,YAAY,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAChD,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ;IACA;IACA;IACA,IAAI,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,OAAO;IACf,YAAY,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI;IAC1C,YAAY,SAAS,EAAE,IAAI,CAAC,SAAS;IACrC,YAAY,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACnC,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;IAC3B,SAAS;IACT,IAAI;IACJ;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/capacitor-gateway",
3
- "version": "1.0.0",
3
+ "version": "2.0.11-beta.7",
4
4
  "description": "Connects the app to an Eliza Gateway with discovery, RPC, and realtime events.",
5
5
  "keywords": [
6
6
  "gateway",
@@ -14,6 +14,8 @@
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/esm/index.d.ts",
17
+ "bun": "./src/index.ts",
18
+ "development": "./src/index.ts",
17
19
  "import": "./dist/esm/index.js",
18
20
  "require": "./dist/plugin.cjs.js"
19
21
  },
@@ -26,51 +28,43 @@
26
28
  "dist/",
27
29
  "ios/Sources/",
28
30
  "ios/Plugin.xcodeproj/",
29
- "*.podspec"
31
+ "*.podspec",
32
+ "dist"
30
33
  ],
31
34
  "author": "elizaOS",
32
35
  "license": "MIT",
33
- "dependencies": {
34
- "@elizaos/app-core": "2.0.0-alpha.537"
35
- },
36
36
  "repository": {
37
37
  "type": "git",
38
38
  "url": "https://github.com/elizaOS/eliza"
39
39
  },
40
40
  "scripts": {
41
- "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
41
+ "verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
42
42
  "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
43
43
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
44
- "verify:web": "npm run build",
45
- "lint": "npm run eslint && npm run prettier -- --check && bash -c 'if command -v swiftlint >/dev/null 2>&1; then npm run swiftlint -- lint; fi'",
46
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && bash -c 'if command -v swiftlint >/dev/null 2>&1; then npm run swiftlint -- lint --fix; fi'",
47
- "eslint": "eslint . --ext ts --config eslint.config.mjs",
48
- "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
44
+ "verify:web": "bun run build",
45
+ "lint": "bunx @biomejs/biome check . && bash -c 'if command -v swiftlint >/dev/null 2>&1; then bun run swiftlint -- lint; fi'",
46
+ "lint:check": "bunx @biomejs/biome check .",
47
+ "fmt": "bunx @biomejs/biome check --write --unsafe . && bash -c 'if command -v swiftlint >/dev/null 2>&1; then bun run swiftlint -- lint --fix; fi'",
48
+ "format": "bunx @biomejs/biome format --write .",
49
+ "format:check": "bunx @biomejs/biome format .",
49
50
  "swiftlint": "node-swiftlint",
50
51
  "docgen": "docgen --api GatewayPlugin --output-readme README.md --output-json dist/docs.json",
51
- "build": "npm run clean && tsc && rollup -c rollup.config.mjs",
52
- "build:docs": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
53
- "clean": "rimraf ./dist",
52
+ "build": "node ../../packages/scripts/with-package-build-lock.mjs plugins/plugin-native-gateway -- bun run build:unlocked",
53
+ "build:docs": "bun run clean && bun run docgen && tsc && bunx rollup -c rollup.config.mjs",
54
+ "clean": "node ../../packages/scripts/rm-path-recursive.mjs dist",
55
+ "test": "vitest run",
54
56
  "watch": "tsc --watch",
55
- "prepublishOnly": "npm run build"
57
+ "prepublishOnly": "bun run build",
58
+ "build:unlocked": "bun run clean && tsc && bunx rollup -c rollup.config.mjs"
56
59
  },
57
60
  "devDependencies": {
58
- "@capacitor/android": "^8.0.0",
59
- "@capacitor/cli": "^8.0.0",
61
+ "@biomejs/biome": "^2.4.14",
60
62
  "@capacitor/core": "^8.3.1",
61
63
  "@capacitor/docgen": "^0.3.0",
62
- "@capacitor/ios": "^8.0.0",
63
- "@ionic/eslint-config": "^0.4.0",
64
- "@ionic/prettier-config": "^4.0.0",
65
- "@ionic/swiftlint-config": "^2.0.0",
66
- "@typescript-eslint/eslint-plugin": "^8.22.0",
67
- "@typescript-eslint/parser": "^8.22.0",
68
- "eslint": "^10.0.0",
69
- "prettier": "^3.8.3",
70
- "rimraf": "^6.0.0",
71
64
  "rollup": "^4.60.2",
72
65
  "swiftlint": "^2.0.0",
73
- "typescript": "^6.0.0"
66
+ "typescript": "^6.0.3",
67
+ "vitest": "^4.0.0"
74
68
  },
75
69
  "peerDependencies": {
76
70
  "@capacitor/core": "^8.3.1"
@@ -99,5 +93,6 @@
99
93
  "ios": true,
100
94
  "android": true
101
95
  }
102
- }
96
+ },
97
+ "gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e"
103
98
  }