@elizaos/capacitor-messages 2.0.0-beta.1 → 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 +21 -0
- package/README.md +80 -0
- package/android/build.gradle +8 -0
- package/android/src/main/java/ai/eliza/plugins/messages/MessagesPlugin.kt +16 -1
- package/dist/esm/definitions.d.ts +9 -0
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/web.d.ts +5 -3
- package/dist/esm/web.d.ts.map +1 -1
- package/dist/esm/web.js +34 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/esm/web.test.d.ts +2 -0
- package/dist/esm/web.test.d.ts.map +1 -0
- package/dist/esm/web.test.js +78 -0
- package/dist/esm/web.test.js.map +1 -0
- package/dist/plugin.cjs.js +34 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +34 -2
- package/dist/plugin.js.map +1 -1
- package/package.json +13 -8
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,80 @@
|
|
|
1
|
+
# @elizaos/capacitor-messages
|
|
2
|
+
|
|
3
|
+
Android SMS/MMS bridge for elizaOS — a Capacitor plugin that lets an Eliza agent send outbound SMS messages and read the device SMS inbox via the Android Telephony API.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- **Send SMS** — dispatches single or multipart text messages using `SmsManager`, waits for radio-layer delivery confirmation, and writes the sent message to the Android sent folder.
|
|
8
|
+
- **Read SMS** — queries the system `content://sms` provider and returns messages sorted newest-first, with optional filtering by conversation thread.
|
|
9
|
+
|
|
10
|
+
The web/browser fallback reports messaging unavailable (`sendSms` throws; `listMessages` returns an empty list). This plugin is meaningful only on Android.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @elizaos/capacitor-messages
|
|
16
|
+
npx cap sync android
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Android permissions
|
|
20
|
+
|
|
21
|
+
Declare in your app's `AndroidManifest.xml` (already present in the plugin manifest, but the host app must request at runtime):
|
|
22
|
+
|
|
23
|
+
| Permission | Required by |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `android.permission.SEND_SMS` | `sendSms` |
|
|
26
|
+
| `android.permission.READ_SMS` | `listMessages` |
|
|
27
|
+
| `android.permission.RECEIVE_SMS` | Declared in plugin manifest |
|
|
28
|
+
| `android.permission.RECEIVE_MMS` | Declared in plugin manifest |
|
|
29
|
+
| `android.permission.RECEIVE_WAP_PUSH` | Declared in plugin manifest |
|
|
30
|
+
|
|
31
|
+
Request the permissions your methods need before calling them. Calls made without the required permission are rejected immediately.
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
### `Messages.sendSms(options)`
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Messages } from "@elizaos/capacitor-messages";
|
|
39
|
+
|
|
40
|
+
const result = await Messages.sendSms({
|
|
41
|
+
address: "+15550001234", // E.164 or local format accepted by SmsManager
|
|
42
|
+
body: "Hello from Eliza",
|
|
43
|
+
});
|
|
44
|
+
// result: { messageId: string, messageUri: string }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Long messages are automatically split into multipart SMS by `SmsManager.divideMessage`. The call resolves only after every part has been confirmed by the radio layer.
|
|
48
|
+
|
|
49
|
+
### `Messages.listMessages(options?)`
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const { messages } = await Messages.listMessages({
|
|
53
|
+
limit: 50, // 1–500, default 100
|
|
54
|
+
threadId: "42", // optional — filter to one conversation
|
|
55
|
+
});
|
|
56
|
+
// messages: SmsMessageSummary[]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Each `SmsMessageSummary` contains: `id`, `threadId`, `address`, `body`, `date` (Unix ms), `type` (Telephony.Sms constants), `read`.
|
|
60
|
+
|
|
61
|
+
## Types
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
interface SendSmsOptions { address: string; body: string }
|
|
65
|
+
interface SendSmsResult { messageId: string; messageUri: string }
|
|
66
|
+
interface ListMessagesOptions { limit?: number; threadId?: string }
|
|
67
|
+
interface SmsMessageSummary {
|
|
68
|
+
id: string; threadId: string; address: string;
|
|
69
|
+
body: string; date: number; type: number; read: boolean;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Building from source
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
bun run --cwd plugins/plugin-native-messages build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Runs with `bun`; `typescript` (`tsc`) and `rollup` are dev dependencies.
|
|
80
|
+
|
package/android/build.gradle
CHANGED
|
@@ -3,6 +3,11 @@ ext {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
apply plugin: 'com.android.library'
|
|
6
|
+
// Apply the Kotlin Android plugin so the plugin's .kt class is bundled into the
|
|
7
|
+
// library AAR. Without it AGP's built-in kotlinc compiles the sources but does
|
|
8
|
+
// NOT bundle the .class files, so the Capacitor plugin class is absent from the
|
|
9
|
+
// app dex at runtime (PluginLoadException -> the whole plugin set fails to load).
|
|
10
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
6
11
|
android {
|
|
7
12
|
namespace = "ai.eliza.plugins.messages"
|
|
8
13
|
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
@@ -14,6 +19,9 @@ android {
|
|
|
14
19
|
sourceCompatibility JavaVersion.VERSION_17
|
|
15
20
|
targetCompatibility JavaVersion.VERSION_17
|
|
16
21
|
}
|
|
22
|
+
kotlinOptions {
|
|
23
|
+
jvmTarget = "17"
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
repositories {
|
|
@@ -18,10 +18,25 @@ import com.getcapacitor.Plugin
|
|
|
18
18
|
import com.getcapacitor.PluginCall
|
|
19
19
|
import com.getcapacitor.PluginMethod
|
|
20
20
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
21
|
+
import com.getcapacitor.annotation.Permission
|
|
21
22
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
22
23
|
import java.util.concurrent.atomic.AtomicInteger
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
// Declares the `sms` alias so the Capacitor base Plugin auto-provides
|
|
26
|
+
// checkPermissions()/requestPermissions() — SMS read/send is requested on first
|
|
27
|
+
// use of the Messages view, not at app launch.
|
|
28
|
+
@CapacitorPlugin(
|
|
29
|
+
name = "ElizaMessages",
|
|
30
|
+
permissions = [
|
|
31
|
+
Permission(
|
|
32
|
+
alias = "sms",
|
|
33
|
+
strings = [
|
|
34
|
+
Manifest.permission.SEND_SMS,
|
|
35
|
+
Manifest.permission.READ_SMS,
|
|
36
|
+
],
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
)
|
|
25
40
|
class MessagesPlugin : Plugin() {
|
|
26
41
|
private val requestCounter = AtomicInteger(1)
|
|
27
42
|
|
|
@@ -24,5 +24,14 @@ export interface MessagesPlugin {
|
|
|
24
24
|
listMessages(options?: ListMessagesOptions): Promise<{
|
|
25
25
|
messages: SmsMessageSummary[];
|
|
26
26
|
}>;
|
|
27
|
+
/** Current SMS (READ_SMS/SEND_SMS) permission state. Web: granted. */
|
|
28
|
+
checkPermissions(): Promise<MessagesPermissionStatus>;
|
|
29
|
+
/** Prompt for SMS access (no-op grant on web). Feature-gated to the Messages
|
|
30
|
+
* view; never requested at launch. */
|
|
31
|
+
requestPermissions(): Promise<MessagesPermissionStatus>;
|
|
32
|
+
}
|
|
33
|
+
/** Runtime permission state for the SMS (READ_SMS/SEND_SMS) alias. */
|
|
34
|
+
export interface MessagesPermissionStatus {
|
|
35
|
+
sms: import("@capacitor/core").PermissionState;
|
|
27
36
|
}
|
|
28
37
|
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CA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B,EAAE,CAAA;KAAE,CAAC,CAAC;IAC9C,sEAAsE;IACtE,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtD;2CACuC;IACvC,kBAAkB,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACzD;AAED,sEAAsE;AACtE,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,OAAO,iBAAiB,EAAE,eAAe,CAAC;CAChD"}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
|
-
import type { ListMessagesOptions, MessagesPlugin, SendSmsOptions, SendSmsResult, SmsMessageSummary } from "./definitions";
|
|
2
|
+
import type { ListMessagesOptions, MessagesPermissionStatus, MessagesPlugin, SendSmsOptions, SendSmsResult, SmsMessageSummary } from "./definitions";
|
|
3
3
|
export declare class MessagesWeb extends WebPlugin implements MessagesPlugin {
|
|
4
|
-
sendSms(
|
|
5
|
-
listMessages(
|
|
4
|
+
sendSms(options: SendSmsOptions): Promise<SendSmsResult>;
|
|
5
|
+
listMessages(options?: ListMessagesOptions): Promise<{
|
|
6
6
|
messages: SmsMessageSummary[];
|
|
7
7
|
}>;
|
|
8
|
+
checkPermissions(): Promise<MessagesPermissionStatus>;
|
|
9
|
+
requestPermissions(): Promise<MessagesPermissionStatus>;
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/esm/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,aAAa,EACb,iBAAiB,EAClB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,aAAa,EACb,iBAAiB,EAClB,MAAM,eAAe,CAAC;AA0BvB,qBAAa,WAAY,SAAQ,SAAU,YAAW,cAAc;IAC5D,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAKxD,YAAY,CAChB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC;QAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;IAOvC,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAIrD,kBAAkB,IAAI,OAAO,CAAC,wBAAwB,CAAC;CAG9D"}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
function validateSendSmsOptions(options) {
|
|
3
|
+
const address = typeof options?.address === "string" ? options.address.trim() : "";
|
|
4
|
+
const body = typeof options?.body === "string" ? options.body.trim() : "";
|
|
5
|
+
if (!address) {
|
|
6
|
+
throw new Error("address is required");
|
|
7
|
+
}
|
|
8
|
+
if (!body) {
|
|
9
|
+
throw new Error("body is required");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function normalizeListLimit(limit) {
|
|
13
|
+
if (limit === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
16
|
+
throw new Error("limit must be between 1 and 500");
|
|
17
|
+
}
|
|
18
|
+
const normalized = Math.trunc(limit);
|
|
19
|
+
if (normalized < 1 || normalized > 500) {
|
|
20
|
+
throw new Error("limit must be between 1 and 500");
|
|
21
|
+
}
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
2
24
|
export class MessagesWeb extends WebPlugin {
|
|
3
|
-
async sendSms(
|
|
25
|
+
async sendSms(options) {
|
|
26
|
+
validateSendSmsOptions(options);
|
|
4
27
|
throw new Error("SMS is only available on Android.");
|
|
5
28
|
}
|
|
6
|
-
async listMessages(
|
|
29
|
+
async listMessages(options) {
|
|
30
|
+
normalizeListLimit(options?.limit);
|
|
7
31
|
return { messages: [] };
|
|
8
32
|
}
|
|
33
|
+
// Web has no SMS permission model; report granted so the shared view flow
|
|
34
|
+
// proceeds (sendSms throws / listMessages returns empty on web anyway).
|
|
35
|
+
async checkPermissions() {
|
|
36
|
+
return { sms: "granted" };
|
|
37
|
+
}
|
|
38
|
+
async requestPermissions() {
|
|
39
|
+
return { sms: "granted" };
|
|
40
|
+
}
|
|
9
41
|
}
|
|
10
42
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,SAAS,sBAAsB,CAAC,OAAuB;IACrD,MAAM,OAAO,GACX,OAAO,OAAO,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,MAAM,IAAI,GAAG,OAAO,OAAO,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,OAAO,CAAC,OAAuB;QACnC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,OAA6B;QAE7B,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACnC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,0EAA0E;IAC1E,wEAAwE;IACxE,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.test.d.ts","sourceRoot":"","sources":["../../src/web.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { MessagesWeb } from "./web";
|
|
3
|
+
describe("MessagesWeb fallback", () => {
|
|
4
|
+
it("rejects malformed outbound SMS payloads before Android-only fallback errors", async () => {
|
|
5
|
+
const messages = new MessagesWeb();
|
|
6
|
+
await expect(messages.sendSms({ address: " \n\t ", body: "hello" })).rejects.toThrow("address is required");
|
|
7
|
+
await expect(messages.sendSms({
|
|
8
|
+
address: ["+15550100"],
|
|
9
|
+
body: { text: "hello" },
|
|
10
|
+
})).rejects.toThrow("address is required");
|
|
11
|
+
await expect(messages.sendSms({ address: "+15550100", body: "" })).rejects.toThrow("body is required");
|
|
12
|
+
await expect(messages.sendSms({ address: "+15550100", body: "hello" })).rejects.toThrow("SMS is only available on Android.");
|
|
13
|
+
});
|
|
14
|
+
it("does not coerce hostile outbound SMS values into valid strings", async () => {
|
|
15
|
+
const messages = new MessagesWeb();
|
|
16
|
+
const hostileAddress = {
|
|
17
|
+
toString: () => "+15550100",
|
|
18
|
+
trim: () => "+15550100",
|
|
19
|
+
};
|
|
20
|
+
const hostileBody = {
|
|
21
|
+
toString: () => "send this",
|
|
22
|
+
trim: () => "send this",
|
|
23
|
+
};
|
|
24
|
+
await expect(messages.sendSms({
|
|
25
|
+
address: hostileAddress,
|
|
26
|
+
body: "hello",
|
|
27
|
+
})).rejects.toThrow("address is required");
|
|
28
|
+
await expect(messages.sendSms({
|
|
29
|
+
address: "+15550100",
|
|
30
|
+
body: hostileBody,
|
|
31
|
+
})).rejects.toThrow("body is required");
|
|
32
|
+
});
|
|
33
|
+
it.each([undefined, null, 42, "sms"])("rejects non-object outbound SMS payload %s as missing an address", async (options) => {
|
|
34
|
+
const messages = new MessagesWeb();
|
|
35
|
+
await expect(messages.sendSms(options)).rejects.toThrow("address is required");
|
|
36
|
+
});
|
|
37
|
+
it.each([
|
|
38
|
+
0,
|
|
39
|
+
-1,
|
|
40
|
+
501,
|
|
41
|
+
"25",
|
|
42
|
+
null,
|
|
43
|
+
{ valueOf: () => 25 },
|
|
44
|
+
Number.POSITIVE_INFINITY,
|
|
45
|
+
Number.NaN,
|
|
46
|
+
])("rejects malformed listMessages limit %s", async (limit) => {
|
|
47
|
+
const messages = new MessagesWeb();
|
|
48
|
+
await expect(messages.listMessages({ limit })).rejects.toThrow("limit must be between 1 and 500");
|
|
49
|
+
});
|
|
50
|
+
it("returns an empty message list for valid web fallback queries", async () => {
|
|
51
|
+
const messages = new MessagesWeb();
|
|
52
|
+
await expect(messages.listMessages({ limit: 25.9, threadId: "../../thread" })).resolves.toEqual({ messages: [] });
|
|
53
|
+
});
|
|
54
|
+
it("keeps fallback state stable across rejected sends and repeated reads", async () => {
|
|
55
|
+
const messages = new MessagesWeb();
|
|
56
|
+
const results = await Promise.allSettled([
|
|
57
|
+
messages.sendSms({ address: "+15550100", body: "hello" }),
|
|
58
|
+
messages.sendSms({ address: "", body: "hello" }),
|
|
59
|
+
messages.listMessages({ limit: 1 }),
|
|
60
|
+
messages.listMessages(),
|
|
61
|
+
]);
|
|
62
|
+
expect(results).toEqual([
|
|
63
|
+
{
|
|
64
|
+
status: "rejected",
|
|
65
|
+
reason: expect.objectContaining({
|
|
66
|
+
message: "SMS is only available on Android.",
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
status: "rejected",
|
|
71
|
+
reason: expect.objectContaining({ message: "address is required" }),
|
|
72
|
+
},
|
|
73
|
+
{ status: "fulfilled", value: { messages: [] } },
|
|
74
|
+
{ status: "fulfilled", value: { messages: [] } },
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=web.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.test.js","sourceRoot":"","sources":["../../src/web.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CA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|
@@ -7,13 +7,45 @@ const Messages = core.registerPlugin("ElizaMessages", {
|
|
|
7
7
|
web: loadWeb,
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
function validateSendSmsOptions(options) {
|
|
11
|
+
const address = typeof options?.address === "string" ? options.address.trim() : "";
|
|
12
|
+
const body = typeof options?.body === "string" ? options.body.trim() : "";
|
|
13
|
+
if (!address) {
|
|
14
|
+
throw new Error("address is required");
|
|
15
|
+
}
|
|
16
|
+
if (!body) {
|
|
17
|
+
throw new Error("body is required");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function normalizeListLimit(limit) {
|
|
21
|
+
if (limit === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
24
|
+
throw new Error("limit must be between 1 and 500");
|
|
25
|
+
}
|
|
26
|
+
const normalized = Math.trunc(limit);
|
|
27
|
+
if (normalized < 1 || normalized > 500) {
|
|
28
|
+
throw new Error("limit must be between 1 and 500");
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
10
32
|
class MessagesWeb extends core.WebPlugin {
|
|
11
|
-
async sendSms(
|
|
33
|
+
async sendSms(options) {
|
|
34
|
+
validateSendSmsOptions(options);
|
|
12
35
|
throw new Error("SMS is only available on Android.");
|
|
13
36
|
}
|
|
14
|
-
async listMessages(
|
|
37
|
+
async listMessages(options) {
|
|
38
|
+
normalizeListLimit(options?.limit);
|
|
15
39
|
return { messages: [] };
|
|
16
40
|
}
|
|
41
|
+
// Web has no SMS permission model; report granted so the shared view flow
|
|
42
|
+
// proceeds (sendSms throws / listMessages returns empty on web anyway).
|
|
43
|
+
async checkPermissions() {
|
|
44
|
+
return { sms: "granted" };
|
|
45
|
+
}
|
|
46
|
+
async requestPermissions() {
|
|
47
|
+
return { sms: "granted" };
|
|
48
|
+
}
|
|
17
49
|
}
|
|
18
50
|
|
|
19
51
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -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.MessagesWeb());\nexport const Messages = registerPlugin(\"ElizaMessages\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class MessagesWeb extends WebPlugin {\n async sendSms(
|
|
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.MessagesWeb());\nexport const Messages = registerPlugin(\"ElizaMessages\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nfunction validateSendSmsOptions(options) {\n const address = typeof options?.address === \"string\" ? options.address.trim() : \"\";\n const body = typeof options?.body === \"string\" ? options.body.trim() : \"\";\n if (!address) {\n throw new Error(\"address is required\");\n }\n if (!body) {\n throw new Error(\"body is required\");\n }\n}\nfunction normalizeListLimit(limit) {\n if (limit === undefined)\n return undefined;\n if (typeof limit !== \"number\" || !Number.isFinite(limit)) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n const normalized = Math.trunc(limit);\n if (normalized < 1 || normalized > 500) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n return normalized;\n}\nexport class MessagesWeb extends WebPlugin {\n async sendSms(options) {\n validateSendSmsOptions(options);\n throw new Error(\"SMS is only available on Android.\");\n }\n async listMessages(options) {\n normalizeListLimit(options?.limit);\n return { messages: [] };\n }\n // Web has no SMS permission model; report granted so the shared view flow\n // proceeds (sendSms throws / listMessages returns empty on web anyway).\n async checkPermissions() {\n return { sms: \"granted\" };\n }\n async requestPermissions() {\n return { sms: \"granted\" };\n }\n}\n//# sourceMappingURL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AACO,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;AAC3B,QAAQ,sBAAsB,CAAC,OAAO,CAAC;AACvC,QAAQ,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC;AAC5D,IAAI;AACJ,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;AAChC,QAAQ,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC;AAC1C,QAAQ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;AAC/B,IAAI;AACJ;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -6,13 +6,45 @@ var capacitorMessages = (function (exports, core) {
|
|
|
6
6
|
web: loadWeb,
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
+
function validateSendSmsOptions(options) {
|
|
10
|
+
const address = typeof options?.address === "string" ? options.address.trim() : "";
|
|
11
|
+
const body = typeof options?.body === "string" ? options.body.trim() : "";
|
|
12
|
+
if (!address) {
|
|
13
|
+
throw new Error("address is required");
|
|
14
|
+
}
|
|
15
|
+
if (!body) {
|
|
16
|
+
throw new Error("body is required");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function normalizeListLimit(limit) {
|
|
20
|
+
if (limit === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
23
|
+
throw new Error("limit must be between 1 and 500");
|
|
24
|
+
}
|
|
25
|
+
const normalized = Math.trunc(limit);
|
|
26
|
+
if (normalized < 1 || normalized > 500) {
|
|
27
|
+
throw new Error("limit must be between 1 and 500");
|
|
28
|
+
}
|
|
29
|
+
return normalized;
|
|
30
|
+
}
|
|
9
31
|
class MessagesWeb extends core.WebPlugin {
|
|
10
|
-
async sendSms(
|
|
32
|
+
async sendSms(options) {
|
|
33
|
+
validateSendSmsOptions(options);
|
|
11
34
|
throw new Error("SMS is only available on Android.");
|
|
12
35
|
}
|
|
13
|
-
async listMessages(
|
|
36
|
+
async listMessages(options) {
|
|
37
|
+
normalizeListLimit(options?.limit);
|
|
14
38
|
return { messages: [] };
|
|
15
39
|
}
|
|
40
|
+
// Web has no SMS permission model; report granted so the shared view flow
|
|
41
|
+
// proceeds (sendSms throws / listMessages returns empty on web anyway).
|
|
42
|
+
async checkPermissions() {
|
|
43
|
+
return { sms: "granted" };
|
|
44
|
+
}
|
|
45
|
+
async requestPermissions() {
|
|
46
|
+
return { sms: "granted" };
|
|
47
|
+
}
|
|
16
48
|
}
|
|
17
49
|
|
|
18
50
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -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.MessagesWeb());\nexport const Messages = registerPlugin(\"ElizaMessages\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class MessagesWeb extends WebPlugin {\n async sendSms(
|
|
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.MessagesWeb());\nexport const Messages = registerPlugin(\"ElizaMessages\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nfunction validateSendSmsOptions(options) {\n const address = typeof options?.address === \"string\" ? options.address.trim() : \"\";\n const body = typeof options?.body === \"string\" ? options.body.trim() : \"\";\n if (!address) {\n throw new Error(\"address is required\");\n }\n if (!body) {\n throw new Error(\"body is required\");\n }\n}\nfunction normalizeListLimit(limit) {\n if (limit === undefined)\n return undefined;\n if (typeof limit !== \"number\" || !Number.isFinite(limit)) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n const normalized = Math.trunc(limit);\n if (normalized < 1 || normalized > 500) {\n throw new Error(\"limit must be between 1 and 500\");\n }\n return normalized;\n}\nexport class MessagesWeb extends WebPlugin {\n async sendSms(options) {\n validateSendSmsOptions(options);\n throw new Error(\"SMS is only available on Android.\");\n }\n async listMessages(options) {\n normalizeListLimit(options?.limit);\n return { messages: [] };\n }\n // Web has no SMS permission model; report granted so the shared view flow\n // proceeds (sendSms throws / listMessages returns empty on web anyway).\n async checkPermissions() {\n return { sms: \"granted\" };\n }\n async requestPermissions() {\n return { sms: \"granted\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,UAAC,QAAQ,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACxD,IAAI,GAAG,EAAE,OAAO;IAChB,CAAC;;ICJD,SAAS,sBAAsB,CAAC,OAAO,EAAE;IACzC,IAAI,MAAM,OAAO,GAAG,OAAO,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;IACtF,IAAI,MAAM,IAAI,GAAG,OAAO,OAAO,EAAE,IAAI,KAAK,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;IAC7E,IAAI,IAAI,CAAC,OAAO,EAAE;IAClB,QAAQ,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;IAC9C,IAAI;IACJ,IAAI,IAAI,CAAC,IAAI,EAAE;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-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11-beta.7",
|
|
4
4
|
"description": "Android SMS/MMS bridge for ElizaOS.",
|
|
5
5
|
"main": "./dist/plugin.cjs.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"bun": "./src/index.ts",
|
|
12
|
+
"development": "./src/index.ts",
|
|
11
13
|
"import": "./dist/esm/index.js",
|
|
12
14
|
"require": "./dist/plugin.cjs.js"
|
|
13
15
|
},
|
|
@@ -20,9 +22,11 @@
|
|
|
20
22
|
"dist"
|
|
21
23
|
],
|
|
22
24
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"clean": "node
|
|
25
|
-
"
|
|
25
|
+
"build": "node ../../packages/scripts/with-package-build-lock.mjs plugins/plugin-native-messages -- bun run build:unlocked",
|
|
26
|
+
"clean": "node ../../packages/scripts/rm-path-recursive.mjs dist",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"prepublishOnly": "bun run build",
|
|
29
|
+
"build:unlocked": "bun run clean && tsc && bunx rollup -c rollup.config.mjs"
|
|
26
30
|
},
|
|
27
31
|
"license": "MIT",
|
|
28
32
|
"capacitor": {
|
|
@@ -31,11 +35,11 @@
|
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
|
-
"@capacitor/cli": "^8.0.0",
|
|
35
38
|
"@capacitor/core": "^8.3.1",
|
|
36
|
-
"
|
|
39
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
37
40
|
"rollup": "^4.60.2",
|
|
38
|
-
"typescript": "^6.0.3"
|
|
41
|
+
"typescript": "^6.0.3",
|
|
42
|
+
"vitest": "^4.0.0"
|
|
39
43
|
},
|
|
40
44
|
"peerDependencies": {
|
|
41
45
|
"@capacitor/core": "^8.3.1"
|
|
@@ -53,5 +57,6 @@
|
|
|
53
57
|
},
|
|
54
58
|
"publishConfig": {
|
|
55
59
|
"access": "public"
|
|
56
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e"
|
|
57
62
|
}
|