@elizaos/plugin-imessage 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 +13 -18
- package/auto-enable.ts +1 -1
- package/package.json +21 -4
- package/dist/accounts.d.ts +0 -135
- package/dist/accounts.d.ts.map +0 -1
- package/dist/accounts.js +0 -209
- package/dist/accounts.js.map +0 -1
- package/dist/api/bluebubbles-routes.d.ts +0 -10
- package/dist/api/bluebubbles-routes.d.ts.map +0 -1
- package/dist/api/bluebubbles-routes.js +0 -132
- package/dist/api/bluebubbles-routes.js.map +0 -1
- package/dist/api/imessage-routes.d.ts +0 -80
- package/dist/api/imessage-routes.d.ts.map +0 -1
- package/dist/api/imessage-routes.js +0 -230
- package/dist/api/imessage-routes.js.map +0 -1
- package/dist/chatdb-reader.d.ts +0 -240
- package/dist/chatdb-reader.d.ts.map +0 -1
- package/dist/chatdb-reader.js +0 -647
- package/dist/chatdb-reader.js.map +0 -1
- package/dist/config.d.ts +0 -60
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -8
- package/dist/config.js.map +0 -1
- package/dist/connector-account-provider.d.ts +0 -18
- package/dist/connector-account-provider.d.ts.map +0 -1
- package/dist/connector-account-provider.js +0 -83
- package/dist/connector-account-provider.js.map +0 -1
- package/dist/contacts-reader.d.ts +0 -147
- package/dist/contacts-reader.d.ts.map +0 -1
- package/dist/contacts-reader.js +0 -481
- package/dist/contacts-reader.js.map +0 -1
- package/dist/index.d.ts +0 -23
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -78
- package/dist/index.js.map +0 -1
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -5
- package/dist/providers/index.js.map +0 -1
- package/dist/rpc.d.ts +0 -206
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -393
- package/dist/rpc.js.map +0 -1
- package/dist/service.d.ts +0 -266
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -1694
- package/dist/service.js.map +0 -1
- package/dist/setup-routes.d.ts +0 -38
- package/dist/setup-routes.d.ts.map +0 -1
- package/dist/setup-routes.js +0 -322
- package/dist/setup-routes.js.map +0 -1
- package/dist/types.d.ts +0 -192
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -138
- package/dist/types.js.map +0 -1
package/dist/config.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* iMessage plugin configuration types.
|
|
3
|
-
*
|
|
4
|
-
* These types define the configuration schema for the iMessage plugin.
|
|
5
|
-
* Shared base types are imported from @elizaos/core.
|
|
6
|
-
*/
|
|
7
|
-
import type { BlockStreamingCoalesceConfig, ChannelHeartbeatVisibilityConfig, DmConfig, DmPolicy, GroupPolicy, MarkdownConfig } from "@elizaos/core";
|
|
8
|
-
export type IMessageReactionNotificationMode = "off" | "own" | "all" | "allowlist";
|
|
9
|
-
export type IMessageAccountConfig = {
|
|
10
|
-
/** Optional display name for this account (used in CLI/UI lists). */
|
|
11
|
-
name?: string;
|
|
12
|
-
/** Optional provider capability tags used for agent/runtime guidance. */
|
|
13
|
-
capabilities?: string[];
|
|
14
|
-
/** Markdown formatting overrides (tables). */
|
|
15
|
-
markdown?: MarkdownConfig;
|
|
16
|
-
/** Allow channel-initiated config writes (default: true). */
|
|
17
|
-
configWrites?: boolean;
|
|
18
|
-
/** If false, do not start this iMessage account. Default: true. */
|
|
19
|
-
enabled?: boolean;
|
|
20
|
-
/** Direct message access policy (default: pairing). */
|
|
21
|
-
dmPolicy?: DmPolicy;
|
|
22
|
-
/** Optional allowlist for iMessage senders (phone E.164 or iCloud email). */
|
|
23
|
-
allowFrom?: Array<string | number>;
|
|
24
|
-
/** Optional allowlist for iMessage group senders. */
|
|
25
|
-
groupAllowFrom?: Array<string | number>;
|
|
26
|
-
/**
|
|
27
|
-
* Controls how group messages are handled:
|
|
28
|
-
* - "open": groups bypass allowFrom, no extra gating
|
|
29
|
-
* - "disabled": block all group messages
|
|
30
|
-
* - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
|
31
|
-
*/
|
|
32
|
-
groupPolicy?: GroupPolicy;
|
|
33
|
-
/** Max group messages to keep as history context (0 disables). */
|
|
34
|
-
historyLimit?: number;
|
|
35
|
-
/** Max DM turns to keep as history context. */
|
|
36
|
-
dmHistoryLimit?: number;
|
|
37
|
-
/** Per-DM config overrides keyed by user ID. */
|
|
38
|
-
dms?: Record<string, DmConfig>;
|
|
39
|
-
/** Outbound text chunk size (chars). Default: 4000. */
|
|
40
|
-
textChunkLimit?: number;
|
|
41
|
-
/** Chunking mode: "length" (default) splits by size; "newline" splits on every newline. */
|
|
42
|
-
chunkMode?: "length" | "newline";
|
|
43
|
-
/** Disable block streaming for this account. */
|
|
44
|
-
blockStreaming?: boolean;
|
|
45
|
-
/** Merge streamed block replies before sending. */
|
|
46
|
-
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
|
47
|
-
/** Maximum media file size in MB. Default: 100. */
|
|
48
|
-
mediaMaxMb?: number;
|
|
49
|
-
/** Reaction notification mode (off|own|all|allowlist). Default: own. */
|
|
50
|
-
reactionNotifications?: IMessageReactionNotificationMode;
|
|
51
|
-
/** Allowlist for reaction notifications when mode is allowlist. */
|
|
52
|
-
reactionAllowlist?: Array<string | number>;
|
|
53
|
-
/** Heartbeat visibility settings for this channel. */
|
|
54
|
-
heartbeat?: ChannelHeartbeatVisibilityConfig;
|
|
55
|
-
};
|
|
56
|
-
export type IMessageConfig = {
|
|
57
|
-
/** Optional per-account iMessage configuration (multi-account). */
|
|
58
|
-
accounts?: Record<string, IMessageAccountConfig>;
|
|
59
|
-
} & IMessageAccountConfig;
|
|
60
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot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;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,gCAAgC,CAAC;IACzD,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAC3C,sDAAsD;IACtD,SAAS,CAAC,EAAE,gCAAgC,CAAC;CAC9C,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAClD,GAAG,qBAAqB,CAAC"}
|
package/dist/config.js
DELETED
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* iMessage ConnectorAccountManager provider.
|
|
3
|
-
*
|
|
4
|
-
* Adapts the existing multi-account scaffolding in `accounts.ts` to the
|
|
5
|
-
* `ConnectorAccountProvider` contract from
|
|
6
|
-
* `@elizaos/core/connectors/account-manager`.
|
|
7
|
-
*
|
|
8
|
-
* Source of truth for accounts is character settings (`character.settings.imessage`)
|
|
9
|
-
* plus env-var fallbacks (IMESSAGE_CLI_PATH, IMESSAGE_DB_PATH, ...).
|
|
10
|
-
* In practice there is a single local macOS Messages account per host, but the
|
|
11
|
-
* accountId surface still applies for multi-handle deployments.
|
|
12
|
-
*
|
|
13
|
-
* iMessage does not use OAuth — it reads the local chat.db on macOS.
|
|
14
|
-
*/
|
|
15
|
-
import type { ConnectorAccountProvider, IAgentRuntime } from "@elizaos/core";
|
|
16
|
-
export declare const IMESSAGE_PROVIDER_ID = "imessage";
|
|
17
|
-
export declare function createIMessageConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
|
|
18
|
-
//# sourceMappingURL=connector-account-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector-account-provider.d.ts","sourceRoot":"","sources":["../src/connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAIV,wBAAwB,EACxB,aAAa,EACd,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAuC/C,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,aAAa,GACrB,wBAAwB,CAkC1B"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* iMessage ConnectorAccountManager provider.
|
|
3
|
-
*
|
|
4
|
-
* Adapts the existing multi-account scaffolding in `accounts.ts` to the
|
|
5
|
-
* `ConnectorAccountProvider` contract from
|
|
6
|
-
* `@elizaos/core/connectors/account-manager`.
|
|
7
|
-
*
|
|
8
|
-
* Source of truth for accounts is character settings (`character.settings.imessage`)
|
|
9
|
-
* plus env-var fallbacks (IMESSAGE_CLI_PATH, IMESSAGE_DB_PATH, ...).
|
|
10
|
-
* In practice there is a single local macOS Messages account per host, but the
|
|
11
|
-
* accountId surface still applies for multi-handle deployments.
|
|
12
|
-
*
|
|
13
|
-
* iMessage does not use OAuth — it reads the local chat.db on macOS.
|
|
14
|
-
*/
|
|
15
|
-
import { DEFAULT_ACCOUNT_ID, listEnabledIMessageAccounts, normalizeAccountId, resolveIMessageAccount, } from "./accounts.js";
|
|
16
|
-
export const IMESSAGE_PROVIDER_ID = "imessage";
|
|
17
|
-
function purposeForAccount(_account) {
|
|
18
|
-
return ["messaging"];
|
|
19
|
-
}
|
|
20
|
-
function accessGateForAccount(account) {
|
|
21
|
-
const dmPolicy = account.config?.dmPolicy;
|
|
22
|
-
if (dmPolicy === "disabled")
|
|
23
|
-
return "disabled";
|
|
24
|
-
if (dmPolicy === "pairing")
|
|
25
|
-
return "pairing";
|
|
26
|
-
return "open";
|
|
27
|
-
}
|
|
28
|
-
function roleForAccount(_account) {
|
|
29
|
-
// iMessage uses the macOS user's own Messages app; always OWNER.
|
|
30
|
-
return "OWNER";
|
|
31
|
-
}
|
|
32
|
-
function toConnectorAccount(account) {
|
|
33
|
-
const now = Date.now();
|
|
34
|
-
return {
|
|
35
|
-
id: normalizeAccountId(account.accountId),
|
|
36
|
-
provider: IMESSAGE_PROVIDER_ID,
|
|
37
|
-
label: account.name ?? account.accountId,
|
|
38
|
-
role: roleForAccount(account),
|
|
39
|
-
purpose: purposeForAccount(account),
|
|
40
|
-
accessGate: accessGateForAccount(account),
|
|
41
|
-
status: account.enabled ? "connected" : "disabled",
|
|
42
|
-
createdAt: now,
|
|
43
|
-
updatedAt: now,
|
|
44
|
-
metadata: {
|
|
45
|
-
cliPath: account.cliPath,
|
|
46
|
-
dbPath: account.dbPath ?? null,
|
|
47
|
-
dmPolicy: account.config?.dmPolicy ?? "pairing",
|
|
48
|
-
groupPolicy: account.config?.groupPolicy ?? "allowlist",
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export function createIMessageConnectorAccountProvider(runtime) {
|
|
53
|
-
return {
|
|
54
|
-
provider: IMESSAGE_PROVIDER_ID,
|
|
55
|
-
label: "iMessage",
|
|
56
|
-
listAccounts: async (_manager) => {
|
|
57
|
-
const enabled = listEnabledIMessageAccounts(runtime);
|
|
58
|
-
if (enabled.length > 0) {
|
|
59
|
-
return enabled.map(toConnectorAccount);
|
|
60
|
-
}
|
|
61
|
-
const fallback = resolveIMessageAccount(runtime, DEFAULT_ACCOUNT_ID);
|
|
62
|
-
return [toConnectorAccount(fallback)];
|
|
63
|
-
},
|
|
64
|
-
createAccount: async (input, _manager) => {
|
|
65
|
-
return {
|
|
66
|
-
...input,
|
|
67
|
-
provider: IMESSAGE_PROVIDER_ID,
|
|
68
|
-
role: input.role ?? "OWNER",
|
|
69
|
-
purpose: input.purpose ?? ["messaging"],
|
|
70
|
-
accessGate: input.accessGate ?? "open",
|
|
71
|
-
status: input.status ?? "pending",
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
patchAccount: async (_accountId, patch, _manager) => {
|
|
75
|
-
return { ...patch, provider: IMESSAGE_PROVIDER_ID };
|
|
76
|
-
},
|
|
77
|
-
deleteAccount: async (_accountId, _manager) => {
|
|
78
|
-
// No-op: iMessage account state is the macOS Messages app; out-of-band.
|
|
79
|
-
},
|
|
80
|
-
// No OAuth — iMessage reads the local chat.db on macOS.
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=connector-account-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector-account-provider.js","sourceRoot":"","sources":["../src/connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAElB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAE/C,SAAS,iBAAiB,CAAC,QAAiC;IAC1D,OAAO,CAAC,WAAW,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAgC;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1C,IAAI,QAAQ,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC;IAC/C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,QAAiC;IACvD,iEAAiE;IACjE,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgC;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO;QACL,EAAE,EAAE,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC;QACzC,QAAQ,EAAE,oBAAoB;QAC9B,KAAK,EAAE,OA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AC,OAAO,IAAI,CAAC,WAAW,CAAC;gBACvC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,MAAM;gBACtC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS;aAClC,CAAC;QACJ,CAAC;QACD,YAAY,EAAE,KAAK,EACjB,UAAkB,EAClB,KAA4B,EAC5B,QAAiC,EACjC,EAAE;YACF,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC;QACtD,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,UAAkB,EAAE,QAAiC,EAAE,EAAE;YAC7E,wEAAwE;QAC1E,CAAC;QACD,wDAAwD;KACzD,CAAC;AACJ,CAAC"}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* macOS Contacts reader for @elizaos/plugin-imessage.
|
|
3
|
-
*
|
|
4
|
-
* Incoming iMessages arrive tagged with a raw handle — a phone number in
|
|
5
|
-
* E.164 form (`+15551234567`) or an email address. Raw handles are ugly
|
|
6
|
-
* to read and make the agent's replies feel impersonal. This module
|
|
7
|
-
* resolves each handle to the real display name from the user's Apple
|
|
8
|
-
* Contacts so the agent sees "Mom" or "Alex Chen" instead of a string
|
|
9
|
-
* of digits.
|
|
10
|
-
*
|
|
11
|
-
* ---
|
|
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.
|
|
20
|
-
*
|
|
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.
|
|
24
|
-
*
|
|
25
|
-
* Graceful degradation: if Contacts is not authorized, or returns no
|
|
26
|
-
* rows, or AppleScript fails for any other reason, the reader returns
|
|
27
|
-
* an empty map. The service treats that as "handles remain anonymous"
|
|
28
|
-
* and proceeds normally — no crash, no hard failure.
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* A single resolved contact: the display name and one of the handles
|
|
32
|
-
* (phone or email) through which that contact reaches the agent. The
|
|
33
|
-
* same name can appear under multiple handles.
|
|
34
|
-
*/
|
|
35
|
-
export interface ResolvedContact {
|
|
36
|
-
/** The contact's display name as stored in Contacts.app. */
|
|
37
|
-
name: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Handle → contact map. Keys are normalized handles (phone numbers in
|
|
41
|
-
* digits-only form with a leading `+` if international, emails in
|
|
42
|
-
* lowercase). Callers should normalize their lookup keys with
|
|
43
|
-
* {@link normalizeContactHandle} before querying.
|
|
44
|
-
*/
|
|
45
|
-
export type ContactsMap = Map<string, ResolvedContact>;
|
|
46
|
-
/**
|
|
47
|
-
* Normalize a handle to the canonical form used as a key in the
|
|
48
|
-
* ContactsMap. Strips whitespace, parentheses, hyphens, and dots from
|
|
49
|
-
* phone numbers and lowercases emails. Leaves a leading `+` in place.
|
|
50
|
-
*/
|
|
51
|
-
export declare function normalizeContactHandle(raw: string): string;
|
|
52
|
-
/**
|
|
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.
|
|
56
|
-
*
|
|
57
|
-
* Input format per line: `kind\thandle\tname`.
|
|
58
|
-
* 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).
|
|
61
|
-
*/
|
|
62
|
-
export declare function parseContactsOutput(raw: string): ContactsMap;
|
|
63
|
-
/**
|
|
64
|
-
* Run the contacts dump AppleScript and return a ContactsMap. Returns
|
|
65
|
-
* 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.
|
|
69
|
-
*/
|
|
70
|
-
export declare function loadContacts(): Promise<ContactsMap>;
|
|
71
|
-
/**
|
|
72
|
-
* A full contact record, richer than ContactsMap's handle-keyed entries.
|
|
73
|
-
* Returned by `listAllContacts` and the single-contact CRUD helpers.
|
|
74
|
-
* Each phone/email carries its Contacts.app label when available
|
|
75
|
-
* (`home`, `work`, `mobile`, etc.) so the UI can surface context.
|
|
76
|
-
*/
|
|
77
|
-
export interface FullContact {
|
|
78
|
-
/** Contacts.app stable person id (UUID-ish). Used for update/delete. */
|
|
79
|
-
id: string;
|
|
80
|
-
/** Display name as stored in Contacts.app (composed by the app). */
|
|
81
|
-
name: string;
|
|
82
|
-
firstName: string | null;
|
|
83
|
-
lastName: string | null;
|
|
84
|
-
phones: Array<{
|
|
85
|
-
label: string | null;
|
|
86
|
-
value: string;
|
|
87
|
-
}>;
|
|
88
|
-
emails: Array<{
|
|
89
|
-
label: string | null;
|
|
90
|
-
value: string;
|
|
91
|
-
}>;
|
|
92
|
-
}
|
|
93
|
-
/** Input shape for creating a contact via `addContact`. */
|
|
94
|
-
export interface NewContactInput {
|
|
95
|
-
firstName?: string;
|
|
96
|
-
lastName?: string;
|
|
97
|
-
phones?: Array<{
|
|
98
|
-
label?: string;
|
|
99
|
-
value: string;
|
|
100
|
-
}>;
|
|
101
|
-
emails?: Array<{
|
|
102
|
-
label?: string;
|
|
103
|
-
value: string;
|
|
104
|
-
}>;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* List every contact in the user's address book as a full `FullContact`
|
|
108
|
-
* record. Returns an empty array on any failure (permission denied,
|
|
109
|
-
* script error, etc.) with a warning log.
|
|
110
|
-
*/
|
|
111
|
-
export declare function listAllContacts(): Promise<FullContact[]>;
|
|
112
|
-
/**
|
|
113
|
-
* Create a new contact in Contacts.app. Returns the new person's id on
|
|
114
|
-
* success, or null on failure (permission denied, validation, etc.).
|
|
115
|
-
*
|
|
116
|
-
* Requires Contacts WRITE permission, which macOS prompts for on the
|
|
117
|
-
* first write call. Read-only sessions never trigger this prompt.
|
|
118
|
-
*/
|
|
119
|
-
export declare function addContact(input: NewContactInput): Promise<string | null>;
|
|
120
|
-
/**
|
|
121
|
-
* Patch an existing contact. `firstName` and `lastName` are set when
|
|
122
|
-
* provided. Phones and emails can be added (`addPhones` / `addEmails`)
|
|
123
|
-
* or removed (`removePhones` / `removeEmails`, matched by value). For
|
|
124
|
-
* simplicity we don't support editing an existing phone in place —
|
|
125
|
-
* callers should remove-then-add to achieve that.
|
|
126
|
-
*/
|
|
127
|
-
export interface ContactPatch {
|
|
128
|
-
firstName?: string;
|
|
129
|
-
lastName?: string;
|
|
130
|
-
addPhones?: Array<{
|
|
131
|
-
label?: string;
|
|
132
|
-
value: string;
|
|
133
|
-
}>;
|
|
134
|
-
removePhones?: string[];
|
|
135
|
-
addEmails?: Array<{
|
|
136
|
-
label?: string;
|
|
137
|
-
value: string;
|
|
138
|
-
}>;
|
|
139
|
-
removeEmails?: string[];
|
|
140
|
-
}
|
|
141
|
-
export declare function updateContact(personId: string, patch: ContactPatch): Promise<boolean>;
|
|
142
|
-
/**
|
|
143
|
-
* Delete a contact by Contacts.app id. Requires write permission.
|
|
144
|
-
* Returns false on any failure (not found, permission denied, etc.).
|
|
145
|
-
*/
|
|
146
|
-
export declare function deleteContact(personId: string): Promise<boolean>;
|
|
147
|
-
//# sourceMappingURL=contacts-reader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-reader.d.ts","sourceRoot":"","sources":["../src/contacts-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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