@elizaos/plugin-imessage 2.0.0-beta.1 → 2.0.3-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -18
  3. package/auto-enable.ts +1 -1
  4. package/dist/accounts.d.ts +2 -2
  5. package/dist/accounts.js +3 -3
  6. package/dist/accounts.js.map +1 -1
  7. package/dist/api/bluebubbles-routes.d.ts +1 -1
  8. package/dist/api/bluebubbles-routes.d.ts.map +1 -1
  9. package/dist/api/imessage-routes.d.ts +9 -21
  10. package/dist/api/imessage-routes.d.ts.map +1 -1
  11. package/dist/api/imessage-routes.js +5 -7
  12. package/dist/api/imessage-routes.js.map +1 -1
  13. package/dist/chatdb-reader.d.ts +1 -1
  14. package/dist/chatdb-reader.d.ts.map +1 -1
  15. package/dist/chatdb-reader.js +21 -1
  16. package/dist/chatdb-reader.js.map +1 -1
  17. package/dist/config.d.ts +1 -1
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/connector-account-provider.d.ts +1 -1
  20. package/dist/connector-account-provider.js +5 -5
  21. package/dist/connector-account-provider.js.map +1 -1
  22. package/dist/contacts-reader.d.ts +23 -29
  23. package/dist/contacts-reader.d.ts.map +1 -1
  24. package/dist/contacts-reader.js +250 -372
  25. package/dist/contacts-reader.js.map +1 -1
  26. package/dist/data-routes.d.ts +21 -0
  27. package/dist/data-routes.d.ts.map +1 -0
  28. package/dist/data-routes.js +280 -0
  29. package/dist/data-routes.js.map +1 -0
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +6 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/rpc.js +5 -5
  35. package/dist/rpc.js.map +1 -1
  36. package/dist/service.d.ts +20 -22
  37. package/dist/service.d.ts.map +1 -1
  38. package/dist/service.js +65 -54
  39. package/dist/service.js.map +1 -1
  40. package/dist/setup-routes.d.ts +15 -27
  41. package/dist/setup-routes.d.ts.map +1 -1
  42. package/dist/setup-routes.js +101 -284
  43. package/dist/setup-routes.js.map +1 -1
  44. package/package.json +22 -4
  45. package/registry-entry.json +103 -0
@@ -10,20 +10,16 @@
10
10
  *
11
11
  * ---
12
12
  *
13
- * Backend: **AppleScript against Contacts.app**. Unlike Messages.app
14
- * (whose scripting dictionary does not expose the message table), the
15
- * Contacts app ships with a complete and officially-supported AppleScript
16
- * vocabulary covering `person`, `phone`, and `email` classes. Reading
17
- * contacts this way is the Apple-blessed path and does not require Full
18
- * Disk Access — only the macOS "Contacts" TCC permission, which the OS
19
- * prompts for on first use.
13
+ * Backend: **CNContactStore** through the shared native macOS dylib. This
14
+ * keeps the feature aligned with the macOS Contacts privacy grant and avoids
15
+ * asking for Automation access to the Contacts app.
20
16
  *
21
- * The reader runs once on service start and caches the result. Contacts
22
- * rarely change mid-session, so a periodic refresh is overkill for v1.
23
- * Callers can force a reload by constructing a fresh reader instance.
17
+ * The service calls this lazily when it actually needs name resolution or
18
+ * contact CRUD. Contacts rarely change mid-session, so the iMessage service
19
+ * caches the returned map for v1.
24
20
  *
25
21
  * Graceful degradation: if Contacts is not authorized, or returns no
26
- * rows, or AppleScript fails for any other reason, the reader returns
22
+ * rows, or the native bridge fails for any other reason, the reader returns
27
23
  * an empty map. The service treats that as "handles remain anonymous"
28
24
  * and proceeds normally — no crash, no hard failure.
29
25
  */
@@ -33,7 +29,7 @@
33
29
  * same name can appear under multiple handles.
34
30
  */
35
31
  export interface ResolvedContact {
36
- /** The contact's display name as stored in Contacts.app. */
32
+ /** The contact's display name as stored in Apple Contacts. */
37
33
  name: string;
38
34
  }
39
35
  /**
@@ -43,6 +39,8 @@ export interface ResolvedContact {
43
39
  * {@link normalizeContactHandle} before querying.
44
40
  */
45
41
  export type ContactsMap = Map<string, ResolvedContact>;
42
+ type ContactsFailure = "bridge_unavailable" | "native_error" | "permission" | null;
43
+ export declare function getLastContactsFailure(): ContactsFailure;
46
44
  /**
47
45
  * Normalize a handle to the canonical form used as a key in the
48
46
  * ContactsMap. Strips whitespace, parentheses, hyphens, and dots from
@@ -50,34 +48,30 @@ export type ContactsMap = Map<string, ResolvedContact>;
50
48
  */
51
49
  export declare function normalizeContactHandle(raw: string): string;
52
50
  /**
53
- * Parse the tab-delimited output of `CONTACTS_DUMP_SCRIPT` into a
54
- * ContactsMap. Exported so tests can exercise it with fixture strings
55
- * without needing a live Contacts.app.
51
+ * Parse legacy tab-delimited contact fixture output into a ContactsMap.
52
+ * Exported so tests can exercise normalization without a live address book.
56
53
  *
57
54
  * Input format per line: `kind\thandle\tname`.
58
55
  * Empty lines are skipped. Lines with fewer than 3 fields are skipped.
59
- * Empty handles are skipped. Duplicate handles keep the first entry
60
- * (AppleScript's iteration order is generally stable).
56
+ * Empty handles are skipped. Duplicate handles keep the first entry.
61
57
  */
62
58
  export declare function parseContactsOutput(raw: string): ContactsMap;
63
59
  /**
64
- * Run the contacts dump AppleScript and return a ContactsMap. Returns
60
+ * Read Apple Contacts through CNContactStore and return a ContactsMap. Returns
65
61
  * an empty map (with a warning log) on any failure — most commonly, the
66
- * user hasn't authorized Contacts access yet, in which case macOS
67
- * surfaces a one-time system prompt and this call returns empty until
68
- * the user accepts on a subsequent run.
62
+ * user hasn't authorized Contacts access yet.
69
63
  */
70
64
  export declare function loadContacts(): Promise<ContactsMap>;
71
65
  /**
72
66
  * A full contact record, richer than ContactsMap's handle-keyed entries.
73
67
  * Returned by `listAllContacts` and the single-contact CRUD helpers.
74
- * Each phone/email carries its Contacts.app label when available
68
+ * Each phone/email carries its Apple Contacts label when available
75
69
  * (`home`, `work`, `mobile`, etc.) so the UI can surface context.
76
70
  */
77
71
  export interface FullContact {
78
- /** Contacts.app stable person id (UUID-ish). Used for update/delete. */
72
+ /** Apple Contacts stable person id. Used for update/delete. */
79
73
  id: string;
80
- /** Display name as stored in Contacts.app (composed by the app). */
74
+ /** Display name as stored in Apple Contacts. */
81
75
  name: string;
82
76
  firstName: string | null;
83
77
  lastName: string | null;
@@ -106,15 +100,14 @@ export interface NewContactInput {
106
100
  /**
107
101
  * List every contact in the user's address book as a full `FullContact`
108
102
  * record. Returns an empty array on any failure (permission denied,
109
- * script error, etc.) with a warning log.
103
+ * native bridge error, etc.) with a warning log.
110
104
  */
111
105
  export declare function listAllContacts(): Promise<FullContact[]>;
112
106
  /**
113
- * Create a new contact in Contacts.app. Returns the new person's id on
107
+ * Create a new Apple Contacts record. Returns the new person's id on
114
108
  * success, or null on failure (permission denied, validation, etc.).
115
109
  *
116
- * Requires Contacts WRITE permission, which macOS prompts for on the
117
- * first write call. Read-only sessions never trigger this prompt.
110
+ * Requires the Contacts privacy grant.
118
111
  */
119
112
  export declare function addContact(input: NewContactInput): Promise<string | null>;
120
113
  /**
@@ -140,8 +133,9 @@ export interface ContactPatch {
140
133
  }
141
134
  export declare function updateContact(personId: string, patch: ContactPatch): Promise<boolean>;
142
135
  /**
143
- * Delete a contact by Contacts.app id. Requires write permission.
136
+ * Delete a contact by Apple Contacts id. Requires the Contacts privacy grant.
144
137
  * Returns false on any failure (not found, permission denied, etc.).
145
138
  */
146
139
  export declare function deleteContact(personId: string): Promise<boolean>;
140
+ export {};
147
141
  //# sourceMappingURL=contacts-reader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contacts-reader.d.ts","sourceRoot":"","sources":["../src/contacts-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AASH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa1D;AAqCD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,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