@elizaos/plugin-imessage 2.0.0-alpha.9 → 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 +179 -0
- package/auto-enable.ts +21 -0
- package/package.json +38 -12
- 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/actions/index.d.ts +0 -5
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/index.js +0 -5
- package/dist/actions/index.js.map +0 -1
- package/dist/actions/sendMessage.d.ts +0 -6
- package/dist/actions/sendMessage.d.ts.map +0 -1
- package/dist/actions/sendMessage.js +0 -178
- package/dist/actions/sendMessage.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/index.d.ts +0 -23
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -46
- package/dist/index.js.map +0 -1
- package/dist/providers/chatContext.d.ts +0 -6
- package/dist/providers/chatContext.d.ts.map +0 -1
- package/dist/providers/chatContext.js +0 -60
- package/dist/providers/chatContext.js.map +0 -1
- package/dist/providers/index.d.ts +0 -5
- 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 -194
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -301
- package/dist/rpc.js.map +0 -1
- package/dist/service.d.ts +0 -71
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -433
- package/dist/service.js.map +0 -1
- package/dist/types.d.ts +0 -163
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -136
- package/dist/types.js.map +0 -1
package/dist/actions/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,eAAe,CAAC;AA8BvB,eAAO,MAAM,WAAW,EAAE,MAwLzB,CAAC"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Send message action for the iMessage plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { composePromptFromState, logger, ModelType, parseJSONObjectFromText } from "@elizaos/core";
|
|
5
|
-
import { IMESSAGE_SERVICE_NAME, isValidIMessageTarget, normalizeIMessageTarget } from "../types.js";
|
|
6
|
-
const SEND_MESSAGE_TEMPLATE = `# Task: Extract iMessage parameters
|
|
7
|
-
|
|
8
|
-
Based on the conversation, determine what message to send and to whom.
|
|
9
|
-
|
|
10
|
-
Recent conversation:
|
|
11
|
-
{{recentMessages}}
|
|
12
|
-
|
|
13
|
-
Extract the following:
|
|
14
|
-
1. text: The message content to send
|
|
15
|
-
2. to: The recipient (phone number, email, or "current" to reply)
|
|
16
|
-
|
|
17
|
-
Respond with a JSON object:
|
|
18
|
-
\`\`\`json
|
|
19
|
-
{
|
|
20
|
-
"text": "message to send",
|
|
21
|
-
"to": "phone/email or 'current'"
|
|
22
|
-
}
|
|
23
|
-
\`\`\`
|
|
24
|
-
`;
|
|
25
|
-
export const sendMessage = {
|
|
26
|
-
name: "IMESSAGE_SEND_MESSAGE",
|
|
27
|
-
similes: ["SEND_IMESSAGE", "IMESSAGE_TEXT", "TEXT_IMESSAGE", "SEND_IMSG"],
|
|
28
|
-
description: "Send a text message via iMessage (macOS only)",
|
|
29
|
-
validate: async (runtime, message, state) => {
|
|
30
|
-
const source = String(message.content.source ?? "");
|
|
31
|
-
if (source !== "imessage")
|
|
32
|
-
return false;
|
|
33
|
-
const text = typeof message.content.text === "string" ? message.content.text.trim() : "";
|
|
34
|
-
const lower = text.toLowerCase();
|
|
35
|
-
const keywords = ["send", "text", "message", "reply", "imessage"];
|
|
36
|
-
const hasKeyword = keywords.some((kw) => lower.includes(kw)) || source === "imessage";
|
|
37
|
-
const hasIntentPattern = /\b(send|text|message|reply|imessage)\b/i.test(text) || source === "imessage";
|
|
38
|
-
const hasContext = source === "imessage" &&
|
|
39
|
-
(Boolean(message.content.source) ||
|
|
40
|
-
Boolean(state?.roomId || state?.conversationId || message.roomId) ||
|
|
41
|
-
(typeof runtime?.getService === "function" &&
|
|
42
|
-
Boolean(runtime.getService(IMESSAGE_SERVICE_NAME))));
|
|
43
|
-
const hasStructuredInput = Boolean(message.content.actions?.includes("IMESSAGE_SEND_MESSAGE")) ||
|
|
44
|
-
(typeof message.content === "object" &&
|
|
45
|
-
typeof message.content.to === "string");
|
|
46
|
-
const hasInput = text.length > 0 || hasStructuredInput || source === "imessage";
|
|
47
|
-
return hasKeyword && hasIntentPattern && hasContext && hasInput;
|
|
48
|
-
},
|
|
49
|
-
handler: async (runtime, message, state, _options, callback) => {
|
|
50
|
-
const imessageService = runtime.getService(IMESSAGE_SERVICE_NAME);
|
|
51
|
-
if (!imessageService || !imessageService.isConnected()) {
|
|
52
|
-
if (callback) {
|
|
53
|
-
callback({
|
|
54
|
-
text: "iMessage service is not available.",
|
|
55
|
-
source: "imessage",
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return { success: false, error: "iMessage service not available" };
|
|
59
|
-
}
|
|
60
|
-
if (!imessageService.isMacOS()) {
|
|
61
|
-
if (callback) {
|
|
62
|
-
callback({
|
|
63
|
-
text: "iMessage is only available on macOS.",
|
|
64
|
-
source: "imessage",
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return { success: false, error: "iMessage requires macOS" };
|
|
68
|
-
}
|
|
69
|
-
// Compose state if not provided
|
|
70
|
-
const currentState = state ?? (await runtime.composeState(message));
|
|
71
|
-
// Extract parameters using LLM
|
|
72
|
-
const prompt = await composePromptFromState({
|
|
73
|
-
template: SEND_MESSAGE_TEMPLATE,
|
|
74
|
-
state: currentState,
|
|
75
|
-
});
|
|
76
|
-
let msgInfo = null;
|
|
77
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
78
|
-
const response = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
79
|
-
prompt,
|
|
80
|
-
});
|
|
81
|
-
const parsed = parseJSONObjectFromText(response);
|
|
82
|
-
if (parsed?.text) {
|
|
83
|
-
msgInfo = {
|
|
84
|
-
text: String(parsed.text),
|
|
85
|
-
to: String(parsed.to || "current"),
|
|
86
|
-
};
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (!msgInfo || !msgInfo.text) {
|
|
91
|
-
if (callback) {
|
|
92
|
-
callback({
|
|
93
|
-
text: "I couldn't understand what message you want me to send. Please try again.",
|
|
94
|
-
source: "imessage",
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return { success: false, error: "Could not extract message parameters" };
|
|
98
|
-
}
|
|
99
|
-
// Determine target
|
|
100
|
-
let targetId;
|
|
101
|
-
if (msgInfo.to && msgInfo.to !== "current") {
|
|
102
|
-
const normalized = normalizeIMessageTarget(msgInfo.to);
|
|
103
|
-
if (normalized && isValidIMessageTarget(normalized)) {
|
|
104
|
-
targetId = normalized;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Fall back to current chat
|
|
108
|
-
if (!targetId) {
|
|
109
|
-
const stateData = (currentState.data || {});
|
|
110
|
-
targetId = stateData.chatId || stateData.handle;
|
|
111
|
-
}
|
|
112
|
-
if (!targetId) {
|
|
113
|
-
if (callback) {
|
|
114
|
-
callback({
|
|
115
|
-
text: "I couldn't determine who to send the message to. Please specify a phone number or email.",
|
|
116
|
-
source: "imessage",
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return { success: false, error: "Could not determine recipient" };
|
|
120
|
-
}
|
|
121
|
-
// Send message
|
|
122
|
-
const result = await imessageService.sendMessage(targetId, msgInfo.text);
|
|
123
|
-
if (!result.success) {
|
|
124
|
-
if (callback) {
|
|
125
|
-
callback({
|
|
126
|
-
text: `Failed to send message: ${result.error}`,
|
|
127
|
-
source: "imessage",
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return { success: false, error: result.error };
|
|
131
|
-
}
|
|
132
|
-
logger.debug(`Sent iMessage to ${targetId}`);
|
|
133
|
-
if (callback) {
|
|
134
|
-
callback({
|
|
135
|
-
text: "Message sent successfully.",
|
|
136
|
-
source: message.content.source,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
success: true,
|
|
141
|
-
data: {
|
|
142
|
-
to: targetId,
|
|
143
|
-
messageId: result.messageId,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
examples: [
|
|
148
|
-
[
|
|
149
|
-
{
|
|
150
|
-
name: "{{user1}}",
|
|
151
|
-
content: { text: "Send them a message saying 'Hello!'" },
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: "{{agent}}",
|
|
155
|
-
content: {
|
|
156
|
-
text: "I'll send that message via iMessage.",
|
|
157
|
-
actions: ["IMESSAGE_SEND_MESSAGE"],
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
[
|
|
162
|
-
{
|
|
163
|
-
name: "{{user1}}",
|
|
164
|
-
content: {
|
|
165
|
-
text: "Text +1234567890 saying 'I'll be there in 10 minutes'",
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
name: "{{agent}}",
|
|
170
|
-
content: {
|
|
171
|
-
text: "I'll send that text.",
|
|
172
|
-
actions: ["IMESSAGE_SEND_MESSAGE"],
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
],
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AAU;iBACnB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QACjD,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;QAE7C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC;gBACP,IAAI,EAAE,4BAA4B;gBAClC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAgB;aACzC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,EAAE,EAAE,QAAQ;gBACZ,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B;SACF,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE;QACR;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,qCAAqC,EAAE;aACzD;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,sCAAsC;oBAC5C,OAAO,EAAE,CAAC,uBAAuB,CAAC;iBACnC;aACF;SACF;QACD;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,uDAAuD;iBAC9D;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,sBAAsB;oBAC5B,OAAO,EAAE,CAAC,uBAAuB,CAAC;iBACnC;aACF;SACF;KACF;CACF,CAAC"}
|
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":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,cAAc,EACf,MAAM,eAAe,CAAC;AAMvB,MAAM,MAAM,gCAAgC,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,CAAC;AAMnF,MAAM,MAAM,qBAAqB,GAAG;IAClC,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACnC,qDAAqD;IACrD,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACxC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/B,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2FAA2F;IAC3F,SAAS,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,gDAAgD;IAChD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,4BAA4B,CAAC;IACtD,mDAAmD;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"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* iMessage Plugin for ElizaOS
|
|
3
|
-
*
|
|
4
|
-
* Provides iMessage integration for ElizaOS agents on macOS.
|
|
5
|
-
* Uses AppleScript and/or CLI tools to send and receive messages.
|
|
6
|
-
*/
|
|
7
|
-
import type { Plugin } from "@elizaos/core";
|
|
8
|
-
import { sendMessage } from "./actions/index.js";
|
|
9
|
-
import { chatContextProvider } from "./providers/index.js";
|
|
10
|
-
import { IMessageService, parseChatsFromAppleScript, parseMessagesFromAppleScript } from "./service.js";
|
|
11
|
-
export * from "./types.js";
|
|
12
|
-
export { IMessageService, parseMessagesFromAppleScript, parseChatsFromAppleScript };
|
|
13
|
-
export { sendMessage };
|
|
14
|
-
export { chatContextProvider };
|
|
15
|
-
export { DEFAULT_ACCOUNT_ID, type IMessageAccountConfig, type IMessageGroupConfig, type IMessageMultiAccountConfig, isIMessageMentionRequired, isIMessageUserAllowed, isMultiAccountEnabled, listEnabledIMessageAccounts, listIMessageAccountIds, normalizeAccountId, type ResolvedIMessageAccount, resolveDefaultIMessageAccountId, resolveIMessageAccount, resolveIMessageGroupConfig, } from "./accounts.js";
|
|
16
|
-
export { createIMessageRpcClient, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, getChatInfo, getContactInfo, getMessages, type IMessageAttachment, type IMessageChat, type IMessageContact, type IMessageMessage, IMessageRpcClient, type IMessageRpcClientOptions, type IMessageRpcError, type IMessageRpcNotification, type IMessageRpcResponse, listChats, listContacts, probeIMessageRpc, sendIMessageRpc, } from "./rpc.js";
|
|
17
|
-
/**
|
|
18
|
-
* iMessage plugin for ElizaOS agents.
|
|
19
|
-
*/
|
|
20
|
-
declare const imessagePlugin: Plugin;
|
|
21
|
-
export default imessagePlugin;
|
|
22
|
-
export type { IMessageConfig, IMessageReactionNotificationMode, } from "./config.js";
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AAGtB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAG/B,OAAO,EACL,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,+BAA+B,EAC/B,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,WAAW,EACX,cAAc,EACd,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,QAAA,MAAM,cAAc,EAAE,MAgCrB,CAAC;AAEF,eAAe,cAAc,CAAC;AAG9B,YAAY,EACV,cAAc,EACd,gCAAgC,GACjC,MAAM,aAAa,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* iMessage Plugin for ElizaOS
|
|
3
|
-
*
|
|
4
|
-
* Provides iMessage integration for ElizaOS agents on macOS.
|
|
5
|
-
* Uses AppleScript and/or CLI tools to send and receive messages.
|
|
6
|
-
*/
|
|
7
|
-
import { platform } from "node:os";
|
|
8
|
-
import { logger } from "@elizaos/core";
|
|
9
|
-
import { sendMessage } from "./actions/index.js";
|
|
10
|
-
import { chatContextProvider } from "./providers/index.js";
|
|
11
|
-
import { IMessageService, parseChatsFromAppleScript, parseMessagesFromAppleScript, } from "./service.js";
|
|
12
|
-
// Re-export types and service
|
|
13
|
-
export * from "./types.js";
|
|
14
|
-
export { IMessageService, parseMessagesFromAppleScript, parseChatsFromAppleScript };
|
|
15
|
-
export { sendMessage };
|
|
16
|
-
export { chatContextProvider };
|
|
17
|
-
// Account management exports
|
|
18
|
-
export { DEFAULT_ACCOUNT_ID, isIMessageMentionRequired, isIMessageUserAllowed, isMultiAccountEnabled, listEnabledIMessageAccounts, listIMessageAccountIds, normalizeAccountId, resolveDefaultIMessageAccountId, resolveIMessageAccount, resolveIMessageGroupConfig, } from "./accounts.js";
|
|
19
|
-
// RPC client exports
|
|
20
|
-
export { createIMessageRpcClient, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, getChatInfo, getContactInfo, getMessages, IMessageRpcClient, listChats, listContacts, probeIMessageRpc, sendIMessageRpc, } from "./rpc.js";
|
|
21
|
-
/**
|
|
22
|
-
* iMessage plugin for ElizaOS agents.
|
|
23
|
-
*/
|
|
24
|
-
const imessagePlugin = {
|
|
25
|
-
name: "imessage",
|
|
26
|
-
description: "iMessage plugin for ElizaOS agents (macOS only)",
|
|
27
|
-
services: [IMessageService],
|
|
28
|
-
actions: [sendMessage],
|
|
29
|
-
providers: [chatContextProvider],
|
|
30
|
-
tests: [],
|
|
31
|
-
init: async (config, _runtime) => {
|
|
32
|
-
logger.info("Initializing iMessage plugin...");
|
|
33
|
-
const isMacOS = platform() === "darwin";
|
|
34
|
-
logger.info("iMessage plugin configuration:");
|
|
35
|
-
logger.info(` - Platform: ${platform()}`);
|
|
36
|
-
logger.info(` - macOS: ${isMacOS ? "Yes" : "No"}`);
|
|
37
|
-
logger.info(` - CLI path: ${config.IMESSAGE_CLI_PATH || process.env.IMESSAGE_CLI_PATH || "imsg (default)"}`);
|
|
38
|
-
logger.info(` - DM policy: ${config.IMESSAGE_DM_POLICY || process.env.IMESSAGE_DM_POLICY || "pairing"}`);
|
|
39
|
-
if (!isMacOS) {
|
|
40
|
-
logger.warn("iMessage plugin is only supported on macOS. The plugin will be inactive on this platform.");
|
|
41
|
-
}
|
|
42
|
-
logger.info("iMessage plugin initialized");
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
export default imessagePlugin;
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAEtB,8BAA8B;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,CAAC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,CAAC,kBAAkB,IAAI,SAAS,EAAE,CAC7F,CAAC;QAEF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CACT,2FAA2F,CAC5F,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../src/providers/chatContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAyB,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAI5F,eAAO,MAAM,mBAAmB,EAAE,QA8DjC,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chat context provider for the iMessage plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { IMESSAGE_SERVICE_NAME } from "../types.js";
|
|
5
|
-
export const chatContextProvider = {
|
|
6
|
-
name: "imessageChatContext",
|
|
7
|
-
description: "Provides information about the current iMessage chat context",
|
|
8
|
-
dynamic: true,
|
|
9
|
-
get: async (runtime, message, state) => {
|
|
10
|
-
// Only provide context for iMessage messages
|
|
11
|
-
if (message.content.source !== "imessage") {
|
|
12
|
-
return {
|
|
13
|
-
data: {},
|
|
14
|
-
values: {},
|
|
15
|
-
text: "",
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const imessageService = runtime.getService(IMESSAGE_SERVICE_NAME);
|
|
19
|
-
if (!imessageService || !imessageService.isConnected()) {
|
|
20
|
-
return {
|
|
21
|
-
data: { connected: false },
|
|
22
|
-
values: { connected: false },
|
|
23
|
-
text: "",
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const agentName = state?.agentName || "The agent";
|
|
27
|
-
const stateData = (state?.data || {});
|
|
28
|
-
const handle = stateData.handle;
|
|
29
|
-
const chatId = stateData.chatId;
|
|
30
|
-
const chatType = stateData.chatType;
|
|
31
|
-
const displayName = stateData.displayName;
|
|
32
|
-
let chatDescription = "";
|
|
33
|
-
if (chatType === "group") {
|
|
34
|
-
chatDescription = displayName ? `group chat "${displayName}"` : "a group chat";
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
chatDescription = handle ? `direct message with ${handle}` : "a direct message";
|
|
38
|
-
}
|
|
39
|
-
const responseText = `${agentName} is chatting via iMessage in ${chatDescription}. ` +
|
|
40
|
-
"iMessage supports text messages and attachments.";
|
|
41
|
-
return {
|
|
42
|
-
data: {
|
|
43
|
-
handle,
|
|
44
|
-
chatId,
|
|
45
|
-
chatType: chatType || "direct",
|
|
46
|
-
displayName,
|
|
47
|
-
connected: true,
|
|
48
|
-
platform: "imessage",
|
|
49
|
-
},
|
|
50
|
-
values: {
|
|
51
|
-
handle,
|
|
52
|
-
chatId,
|
|
53
|
-
chatType: chatType || "direct",
|
|
54
|
-
displayName,
|
|
55
|
-
},
|
|
56
|
-
text: responseText,
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=chatContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.js","sourceRoot":"","sources":["../../src/providers/chatContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,CAAC,MAAM,mBAAmB,GAAa;IAC3C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,8DAA8D;IAE3E,OAAO,EAAE,IAAI;IACb,GAAG,EAAE,KAAK,EAAE,OAAsB,EAAE,OAAe,EAAE,KAAY,EAA2B,EAAE;QAC5F,6CAA6C;QAC7C,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC1C,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,IAAI,EAAE,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M;gBACN,MAAM;gBACN,QAAQ,EAAE,QAAQ,IAAI,QAAQ;gBAC9B,WAAW;aACZ;YACD,IAAI,EAAE,YAAY;SACnB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/providers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/rpc.d.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default probe timeout in milliseconds
|
|
3
|
-
*/
|
|
4
|
-
export declare const DEFAULT_PROBE_TIMEOUT_MS = 5000;
|
|
5
|
-
/**
|
|
6
|
-
* Default request timeout in milliseconds
|
|
7
|
-
*/
|
|
8
|
-
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
|
|
9
|
-
/**
|
|
10
|
-
* iMessage RPC error structure
|
|
11
|
-
*/
|
|
12
|
-
export interface IMessageRpcError {
|
|
13
|
-
code?: number;
|
|
14
|
-
message?: string;
|
|
15
|
-
data?: unknown;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* iMessage RPC response structure
|
|
19
|
-
*/
|
|
20
|
-
export interface IMessageRpcResponse<T> {
|
|
21
|
-
jsonrpc?: string;
|
|
22
|
-
id?: string | number | null;
|
|
23
|
-
result?: T;
|
|
24
|
-
error?: IMessageRpcError;
|
|
25
|
-
method?: string;
|
|
26
|
-
params?: unknown;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* iMessage RPC notification structure
|
|
30
|
-
*/
|
|
31
|
-
export interface IMessageRpcNotification {
|
|
32
|
-
method: string;
|
|
33
|
-
params?: unknown;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Options for creating an iMessage RPC client
|
|
37
|
-
*/
|
|
38
|
-
export interface IMessageRpcClientOptions {
|
|
39
|
-
cliPath?: string;
|
|
40
|
-
dbPath?: string;
|
|
41
|
-
onNotification?: (msg: IMessageRpcNotification) => void;
|
|
42
|
-
onError?: (error: Error) => void;
|
|
43
|
-
onClose?: (code: number | null, signal: NodeJS.Signals | null) => void;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* iMessage RPC client for communicating with the imsg CLI tool
|
|
47
|
-
*/
|
|
48
|
-
export declare class IMessageRpcClient {
|
|
49
|
-
private readonly cliPath;
|
|
50
|
-
private readonly dbPath?;
|
|
51
|
-
private readonly onNotification?;
|
|
52
|
-
private readonly onError?;
|
|
53
|
-
private readonly onClose?;
|
|
54
|
-
private readonly pending;
|
|
55
|
-
private readonly closedPromise;
|
|
56
|
-
private closedResolve;
|
|
57
|
-
private child;
|
|
58
|
-
private reader;
|
|
59
|
-
private nextId;
|
|
60
|
-
private started;
|
|
61
|
-
constructor(opts?: IMessageRpcClientOptions);
|
|
62
|
-
/**
|
|
63
|
-
* Starts the RPC client by spawning the CLI process
|
|
64
|
-
*/
|
|
65
|
-
start(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Stops the RPC client
|
|
68
|
-
*/
|
|
69
|
-
stop(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Waits for the RPC client to close
|
|
72
|
-
*/
|
|
73
|
-
waitForClose(): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Checks if the client is running
|
|
76
|
-
*/
|
|
77
|
-
isRunning(): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Makes an RPC request
|
|
80
|
-
*/
|
|
81
|
-
request<T = unknown>(method: string, params?: Record<string, unknown>, opts?: {
|
|
82
|
-
timeoutMs?: number;
|
|
83
|
-
}): Promise<T>;
|
|
84
|
-
/**
|
|
85
|
-
* Handles an incoming line from the RPC process
|
|
86
|
-
*/
|
|
87
|
-
private handleLine;
|
|
88
|
-
/**
|
|
89
|
-
* Fails all pending requests
|
|
90
|
-
*/
|
|
91
|
-
private failAll;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Creates and starts an iMessage RPC client
|
|
95
|
-
*/
|
|
96
|
-
export declare function createIMessageRpcClient(opts?: IMessageRpcClientOptions): Promise<IMessageRpcClient>;
|
|
97
|
-
/**
|
|
98
|
-
* iMessage contact information
|
|
99
|
-
*/
|
|
100
|
-
export interface IMessageContact {
|
|
101
|
-
id: string;
|
|
102
|
-
firstName?: string;
|
|
103
|
-
lastName?: string;
|
|
104
|
-
displayName?: string;
|
|
105
|
-
phones?: string[];
|
|
106
|
-
emails?: string[];
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* iMessage chat information
|
|
110
|
-
*/
|
|
111
|
-
export interface IMessageChat {
|
|
112
|
-
id: string;
|
|
113
|
-
chatIdentifier: string;
|
|
114
|
-
displayName?: string;
|
|
115
|
-
isGroup: boolean;
|
|
116
|
-
participants: string[];
|
|
117
|
-
lastMessageDate?: number;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* iMessage message information
|
|
121
|
-
*/
|
|
122
|
-
export interface IMessageMessage {
|
|
123
|
-
id: string;
|
|
124
|
-
chatId: string;
|
|
125
|
-
text?: string;
|
|
126
|
-
sender: string;
|
|
127
|
-
isFromMe: boolean;
|
|
128
|
-
date: number;
|
|
129
|
-
dateRead?: number;
|
|
130
|
-
dateDelivered?: number;
|
|
131
|
-
attachments?: IMessageAttachment[];
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* iMessage attachment information
|
|
135
|
-
*/
|
|
136
|
-
export interface IMessageAttachment {
|
|
137
|
-
id: string;
|
|
138
|
-
filename?: string;
|
|
139
|
-
mimeType?: string;
|
|
140
|
-
path?: string;
|
|
141
|
-
size?: number;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Probes the iMessage RPC to check connectivity
|
|
145
|
-
*/
|
|
146
|
-
export declare function probeIMessageRpc(params: {
|
|
147
|
-
cliPath?: string;
|
|
148
|
-
dbPath?: string;
|
|
149
|
-
timeoutMs?: number;
|
|
150
|
-
}): Promise<{
|
|
151
|
-
ok: boolean;
|
|
152
|
-
error?: string;
|
|
153
|
-
version?: string;
|
|
154
|
-
}>;
|
|
155
|
-
/**
|
|
156
|
-
* Lists all contacts via iMessage RPC
|
|
157
|
-
*/
|
|
158
|
-
export declare function listContacts(client: IMessageRpcClient): Promise<IMessageContact[]>;
|
|
159
|
-
/**
|
|
160
|
-
* Lists all chats via iMessage RPC
|
|
161
|
-
*/
|
|
162
|
-
export declare function listChats(client: IMessageRpcClient): Promise<IMessageChat[]>;
|
|
163
|
-
/**
|
|
164
|
-
* Gets recent messages from a chat
|
|
165
|
-
*/
|
|
166
|
-
export declare function getMessages(client: IMessageRpcClient, params: {
|
|
167
|
-
chatId: string;
|
|
168
|
-
limit?: number;
|
|
169
|
-
before?: number;
|
|
170
|
-
}): Promise<IMessageMessage[]>;
|
|
171
|
-
/**
|
|
172
|
-
* Sends a message via iMessage RPC
|
|
173
|
-
*/
|
|
174
|
-
export declare function sendIMessageRpc(client: IMessageRpcClient, params: {
|
|
175
|
-
to: string;
|
|
176
|
-
text: string;
|
|
177
|
-
attachments?: string[];
|
|
178
|
-
service?: "iMessage" | "SMS";
|
|
179
|
-
}): Promise<{
|
|
180
|
-
messageId: string;
|
|
181
|
-
}>;
|
|
182
|
-
/**
|
|
183
|
-
* Gets chat info via iMessage RPC
|
|
184
|
-
*/
|
|
185
|
-
export declare function getChatInfo(client: IMessageRpcClient, params: {
|
|
186
|
-
chatId: string;
|
|
187
|
-
}): Promise<IMessageChat | null>;
|
|
188
|
-
/**
|
|
189
|
-
* Gets contact info via iMessage RPC
|
|
190
|
-
*/
|
|
191
|
-
export declare function getContactInfo(client: IMessageRpcClient, params: {
|
|
192
|
-
identifier: string;
|
|
193
|
-
}): Promise<IMessageContact | null>;
|
|
194
|
-
//# sourceMappingURL=rpc.d.ts.map
|