grok-dev 1.0.0-rc7 → 1.1.0

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 (37) hide show
  1. package/.grok/generated-media/image-2026-03-26T16-38-08-388Z.jpg +0 -0
  2. package/.grok/generated-media/video-2026-03-26T16-39-19-329Z.mp4 +0 -0
  3. package/.grok/settings.json +1 -1
  4. package/dist/imessage/bridge.d.ts +41 -0
  5. package/dist/imessage/bridge.js +291 -0
  6. package/dist/imessage/bridge.js.map +1 -0
  7. package/dist/imessage/client.d.ts +64 -0
  8. package/dist/imessage/client.js +98 -0
  9. package/dist/imessage/client.js.map +1 -0
  10. package/dist/imessage/headless-bridge-paths.d.ts +9 -0
  11. package/dist/imessage/headless-bridge-paths.js +8 -0
  12. package/dist/imessage/headless-bridge-paths.js.map +1 -0
  13. package/dist/imessage/headless-bridge.d.ts +15 -0
  14. package/dist/imessage/headless-bridge.js +197 -0
  15. package/dist/imessage/headless-bridge.js.map +1 -0
  16. package/dist/imessage/index.d.ts +5 -0
  17. package/dist/imessage/index.js +6 -0
  18. package/dist/imessage/index.js.map +1 -0
  19. package/dist/imessage/limits.d.ts +7 -0
  20. package/dist/imessage/limits.js +16 -0
  21. package/dist/imessage/limits.js.map +1 -0
  22. package/dist/imessage/pairing.d.ts +9 -0
  23. package/dist/imessage/pairing.js +29 -0
  24. package/dist/imessage/pairing.js.map +1 -0
  25. package/dist/index.js +9 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/ui/app.d.ts +1 -0
  28. package/dist/ui/app.js +59 -2
  29. package/dist/ui/app.js.map +1 -1
  30. package/dist/ui/schedule-modal.js +2 -2
  31. package/dist/ui/schedule-modal.js.map +1 -1
  32. package/dist/utils/update-checker.d.ts +11 -0
  33. package/dist/utils/update-checker.js +46 -0
  34. package/dist/utils/update-checker.js.map +1 -0
  35. package/dist/utils/update-checker.test.d.ts +1 -0
  36. package/dist/utils/update-checker.test.js.map +1 -0
  37. package/package.json +3 -1
@@ -14,7 +14,7 @@
14
14
  "enabled": true
15
15
  }
16
16
  },
17
- "sandboxMode": "shuru",
17
+ "sandboxMode": "off",
18
18
  "sandbox": {
19
19
  "allowNet": false
20
20
  }
@@ -0,0 +1,41 @@
1
+ import type { Agent } from "../agent/agent.js";
2
+ import type { ToolCall, ToolResult } from "../types/index.js";
3
+ import type { TurnCoordinator } from "../telegram/turn-coordinator.js";
4
+ export { splitIMessage, IMESSAGE_MAX_MESSAGE } from "./limits.js";
5
+ export interface IMessageBridgeOptions {
6
+ serverUrl: string;
7
+ password: string;
8
+ getApprovedSenders: () => string[];
9
+ coordinator: TurnCoordinator;
10
+ getIMessageAgent: (sender: string) => Agent;
11
+ pollingIntervalMs?: number;
12
+ onUserMessage?: (event: {
13
+ turnKey: string;
14
+ sender: string;
15
+ content: string;
16
+ }) => void;
17
+ onAssistantMessage?: (event: {
18
+ turnKey: string;
19
+ sender: string;
20
+ content: string;
21
+ done: boolean;
22
+ }) => void;
23
+ onToolCalls?: (event: {
24
+ turnKey: string;
25
+ sender: string;
26
+ toolCalls: ToolCall[];
27
+ }) => void;
28
+ onToolResult?: (event: {
29
+ turnKey: string;
30
+ sender: string;
31
+ toolCall: ToolCall;
32
+ toolResult: ToolResult;
33
+ }) => void;
34
+ onError?: (message: string) => void;
35
+ }
36
+ export interface IMessageBridgeHandle {
37
+ start: () => void;
38
+ stop: () => Promise<void>;
39
+ sendDm: (sender: string, text: string) => Promise<void>;
40
+ }
41
+ export declare function createIMessageBridge(opts: IMessageBridgeOptions): IMessageBridgeHandle;
@@ -0,0 +1,291 @@
1
+ import { BlueBubblesClient } from "./client.js";
2
+ import { IMESSAGE_MAX_MESSAGE, splitIMessage } from "./limits.js";
3
+ import { registerIMessagePairingCode } from "./pairing.js";
4
+ export { splitIMessage, IMESSAGE_MAX_MESSAGE } from "./limits.js";
5
+ /**
6
+ * Self-chat echo dedup cache (inspired by OpenClaw's monitor-self-chat-cache).
7
+ *
8
+ * Keyed by `chatGuid:timestamp:text`. When the bridge sees an isFromMe:true
9
+ * copy it records the key; when the reflected isFromMe:false copy with the
10
+ * same key arrives it is dropped. TTL prevents unbounded growth.
11
+ */
12
+ function createSelfChatCache(ttlMs = 30_000) {
13
+ const cache = new Map();
14
+ const makeKey = (chatGuid, timestamp, text) => `${chatGuid}:${timestamp}:${text}`;
15
+ return {
16
+ remember(chatGuid, timestamp, text) {
17
+ cache.set(makeKey(chatGuid, timestamp, text), Date.now());
18
+ },
19
+ isEcho(chatGuid, timestamp, text) {
20
+ return cache.has(makeKey(chatGuid, timestamp, text));
21
+ },
22
+ cleanup() {
23
+ const cutoff = Date.now() - ttlMs;
24
+ for (const [k, ts] of cache) {
25
+ if (ts < cutoff)
26
+ cache.delete(k);
27
+ }
28
+ },
29
+ };
30
+ }
31
+ export function createIMessageBridge(opts) {
32
+ const client = new BlueBubblesClient({
33
+ serverUrl: opts.serverUrl,
34
+ password: opts.password,
35
+ });
36
+ const pollingMs = opts.pollingIntervalMs ?? 2000;
37
+ let running = false;
38
+ let pollTimer;
39
+ let lastTimestamp = Date.now();
40
+ let polling = false;
41
+ const seenGuids = new Set();
42
+ const selfChatCache = createSelfChatCache();
43
+ /**
44
+ * Secondary dedup: texts the bridge itself sent via API calls.
45
+ * Catches echoes even if they arrive in a later batch than the
46
+ * isFromMe:true copy (edge case the per-batch dedup can miss).
47
+ */
48
+ const outboundTexts = new Map();
49
+ const OUTBOUND_TTL = 60_000;
50
+ const trackOutbound = (text) => {
51
+ outboundTexts.set(text, Date.now());
52
+ if (outboundTexts.size > 300) {
53
+ const cutoff = Date.now() - OUTBOUND_TTL;
54
+ for (const [k, ts] of outboundTexts) {
55
+ if (ts < cutoff)
56
+ outboundTexts.delete(k);
57
+ }
58
+ }
59
+ };
60
+ const isOutboundEcho = (text) => {
61
+ return outboundTexts.has(text);
62
+ };
63
+ const normalizeSender = (addr) => addr.trim().toLowerCase();
64
+ const buildTurnKey = (msg) => {
65
+ const chat = msg.chats?.[0]?.guid ?? "unknown";
66
+ return `imessage:${chat}:${msg.guid}`;
67
+ };
68
+ const isApproved = (sender) => {
69
+ const approved = opts.getApprovedSenders();
70
+ const normalized = normalizeSender(sender);
71
+ return approved.some((s) => normalizeSender(s) === normalized);
72
+ };
73
+ const sendReply = async (chatGuid, text) => {
74
+ const parts = splitIMessage(text);
75
+ for (const part of parts) {
76
+ trackOutbound(part);
77
+ await client.sendMessage(chatGuid, part);
78
+ }
79
+ };
80
+ const replyTurnError = async (msg, sender, message) => {
81
+ const chatGuid = msg.chats?.[0]?.guid;
82
+ const clipped = message.slice(0, IMESSAGE_MAX_MESSAGE);
83
+ opts.onAssistantMessage?.({
84
+ turnKey: buildTurnKey(msg),
85
+ sender,
86
+ content: `Error: ${clipped}`,
87
+ done: true,
88
+ });
89
+ if (chatGuid) {
90
+ try {
91
+ const errorText = `Error: ${clipped}`;
92
+ trackOutbound(errorText);
93
+ await client.sendMessage(chatGuid, errorText);
94
+ }
95
+ catch {
96
+ /* chat may be unreachable */
97
+ }
98
+ }
99
+ };
100
+ const runAgentTurn = async (msg, sender, promptText) => {
101
+ const agent = opts.getIMessageAgent(sender);
102
+ await opts.coordinator.run(async () => {
103
+ try {
104
+ const turnKey = buildTurnKey(msg);
105
+ const chatGuid = msg.chats?.[0]?.guid;
106
+ opts.onUserMessage?.({ turnKey, sender, content: promptText });
107
+ let acc = "";
108
+ try {
109
+ for await (const chunk of agent.processMessage(promptText)) {
110
+ switch (chunk.type) {
111
+ case "content":
112
+ if (chunk.content) {
113
+ acc += chunk.content;
114
+ opts.onAssistantMessage?.({ turnKey, sender, content: acc, done: false });
115
+ }
116
+ break;
117
+ case "tool_calls":
118
+ if (chunk.toolCalls) {
119
+ opts.onToolCalls?.({ turnKey, sender, toolCalls: chunk.toolCalls });
120
+ }
121
+ break;
122
+ case "tool_result":
123
+ if (chunk.toolCall && chunk.toolResult) {
124
+ opts.onToolResult?.({
125
+ turnKey,
126
+ sender,
127
+ toolCall: chunk.toolCall,
128
+ toolResult: chunk.toolResult,
129
+ });
130
+ }
131
+ break;
132
+ }
133
+ }
134
+ }
135
+ catch (err) {
136
+ const errMsg = err instanceof Error ? err.message : String(err);
137
+ await replyTurnError(msg, sender, errMsg);
138
+ return;
139
+ }
140
+ const trimmed = acc.trim() || "(no text output)";
141
+ opts.onAssistantMessage?.({ turnKey, sender, content: trimmed, done: true });
142
+ if (chatGuid) {
143
+ await sendReply(chatGuid, trimmed);
144
+ }
145
+ }
146
+ catch (err) {
147
+ const errMsg = err instanceof Error ? err.message : String(err);
148
+ await replyTurnError(msg, sender, errMsg);
149
+ }
150
+ });
151
+ };
152
+ const handlePairingRequest = async (msg, sender) => {
153
+ const code = registerIMessagePairingCode(sender);
154
+ const chatGuid = msg.chats?.[0]?.guid;
155
+ if (chatGuid) {
156
+ const pairText = `Your pairing code: ${code}\nEnter this code in Grok CLI to approve.`;
157
+ trackOutbound(pairText);
158
+ await client.sendMessage(chatGuid, pairText);
159
+ }
160
+ };
161
+ const processIncomingMessages = async () => {
162
+ if (polling)
163
+ return;
164
+ polling = true;
165
+ try {
166
+ const messages = await client.getRecentMessages({
167
+ after: lastTimestamp,
168
+ limit: 50,
169
+ sort: "ASC",
170
+ });
171
+ // --- Pass 1: advance timestamp + record isFromMe:true for self-chat dedup ---
172
+ for (const msg of messages) {
173
+ if (msg.dateCreated > lastTimestamp) {
174
+ lastTimestamp = msg.dateCreated;
175
+ }
176
+ if (msg.isFromMe) {
177
+ const chatGuid = msg.chats?.[0]?.guid ?? "";
178
+ const text = msg.text?.trim() ?? "";
179
+ if (chatGuid && text) {
180
+ selfChatCache.remember(chatGuid, msg.dateCreated, text);
181
+ }
182
+ }
183
+ }
184
+ // --- Pass 2: process only genuine inbound messages ---
185
+ for (const msg of messages) {
186
+ if (msg.isFromMe)
187
+ continue;
188
+ if (seenGuids.has(msg.guid))
189
+ continue;
190
+ seenGuids.add(msg.guid);
191
+ const sender = msg.handle?.address;
192
+ if (!sender)
193
+ continue;
194
+ const text = msg.text?.trim();
195
+ if (!text)
196
+ continue;
197
+ const chatGuid = msg.chats?.[0]?.guid ?? "";
198
+ // Layer 1: per-batch self-chat echo (isFromMe:true copy in same batch)
199
+ if (chatGuid && selfChatCache.isEcho(chatGuid, msg.dateCreated, text))
200
+ continue;
201
+ // Layer 2: outbound echo (bridge sent this text via API)
202
+ if (isOutboundEcho(text))
203
+ continue;
204
+ if (text.toLowerCase() === "pair") {
205
+ await handlePairingRequest(msg, sender);
206
+ continue;
207
+ }
208
+ if (!isApproved(sender)) {
209
+ const replyGuid = msg.chats?.[0]?.guid;
210
+ if (replyGuid) {
211
+ const notPairedText = "Not paired yet. Text \"pair\" to get a code, then approve in Grok CLI.";
212
+ trackOutbound(notPairedText);
213
+ await client.sendMessage(replyGuid, notPairedText);
214
+ }
215
+ continue;
216
+ }
217
+ await runAgentTurn(msg, sender, text);
218
+ }
219
+ selfChatCache.cleanup();
220
+ if (seenGuids.size > 500) {
221
+ const excess = seenGuids.size - 300;
222
+ const iter = seenGuids.values();
223
+ for (let i = 0; i < excess; i++)
224
+ iter.next();
225
+ const keep = new Set();
226
+ for (const v of iter)
227
+ keep.add(v);
228
+ seenGuids.clear();
229
+ for (const v of keep)
230
+ seenGuids.add(v);
231
+ }
232
+ }
233
+ catch (err) {
234
+ opts.onError?.(err instanceof Error ? err.message : String(err));
235
+ }
236
+ finally {
237
+ polling = false;
238
+ }
239
+ };
240
+ const catchUp = async () => {
241
+ try {
242
+ const messages = await client.getRecentMessages({
243
+ limit: 50,
244
+ sort: "DESC",
245
+ });
246
+ if (messages.length > 0) {
247
+ lastTimestamp = Math.max(...messages.map((m) => m.dateCreated));
248
+ for (const m of messages) {
249
+ seenGuids.add(m.guid);
250
+ // Pre-seed outbound cache with recent bridge-sent texts so echoes
251
+ // arriving after restart are still suppressed.
252
+ if (m.isFromMe && m.text) {
253
+ trackOutbound(m.text.trim());
254
+ }
255
+ }
256
+ }
257
+ }
258
+ catch {
259
+ /* best-effort; will use Date.now() fallback */
260
+ }
261
+ };
262
+ return {
263
+ start() {
264
+ if (running)
265
+ return;
266
+ running = true;
267
+ lastTimestamp = Date.now();
268
+ void catchUp().then(() => {
269
+ if (!running)
270
+ return;
271
+ pollTimer = setInterval(() => {
272
+ void processIncomingMessages();
273
+ }, pollingMs);
274
+ });
275
+ },
276
+ async stop() {
277
+ if (!running)
278
+ return;
279
+ if (pollTimer) {
280
+ clearInterval(pollTimer);
281
+ pollTimer = undefined;
282
+ }
283
+ running = false;
284
+ },
285
+ async sendDm(sender, text) {
286
+ const chatGuid = `iMessage;-;${sender}`;
287
+ await sendReply(chatGuid, text);
288
+ },
289
+ };
290
+ }
291
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/imessage/bridge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAsBlE;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,KAAK,GAAG,MAAM;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAExC,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,IAAY,EAAE,EAAE,CACpE,GAAG,QAAQ,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;IAErC,OAAO;QACL,QAAQ,CAAC,QAAgB,EAAE,SAAiB,EAAE,IAAY;YACxD,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,CAAC,QAAgB,EAAE,SAAiB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,IAAI,CAAC,GAAG,EAAE;gBACvB,IAAI,CAAC,OAAO;oBAAE,OAAO;gBACrB,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;oBAC3B,KAAK,uBAAuB,EAAE,CAAC;gBACjC,CAAC,EAAE,SAAS,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,IAAI;YACR,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,IAAI,SAAS,EAAE,CAAC;gBACd,aAAa,CAAC,SAAS,CAAC,CAAC;gBACzB,SAAS,GAAG,SAAS,CAAC;YACxB,CAAC;YACD,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,IAAY;YACvC,MAAM,QAAQ,GAAG,cAAc,MAAM,EAAE,CAAC;YACxC,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ export interface BlueBubblesMessage {
2
+ guid: string;
3
+ text: string | null;
4
+ isFromMe: boolean;
5
+ dateCreated: number;
6
+ subject: string | null;
7
+ handle: {
8
+ originalROWID?: number;
9
+ address: string;
10
+ service: string;
11
+ country?: string;
12
+ } | null;
13
+ attachments: BlueBubblesAttachment[];
14
+ chats: BlueBubblesChat[];
15
+ associatedMessageGuid: string | null;
16
+ associatedMessageType: number | null;
17
+ isAudioMessage: boolean;
18
+ }
19
+ export interface BlueBubblesAttachment {
20
+ guid: string;
21
+ originalROWID: number;
22
+ mimeType: string | null;
23
+ transferName: string | null;
24
+ totalBytes: number;
25
+ }
26
+ export interface BlueBubblesChat {
27
+ chatIdentifier: string;
28
+ guid: string;
29
+ displayName: string;
30
+ participants: {
31
+ address: string;
32
+ service: string;
33
+ }[];
34
+ }
35
+ export interface BlueBubblesApiResponse<T> {
36
+ status: number;
37
+ message: string;
38
+ data: T;
39
+ error?: {
40
+ type: string;
41
+ error: string;
42
+ };
43
+ }
44
+ export interface BlueBubblesClientOptions {
45
+ serverUrl: string;
46
+ password: string;
47
+ }
48
+ export declare class BlueBubblesClient {
49
+ private readonly baseUrl;
50
+ private readonly password;
51
+ constructor(opts: BlueBubblesClientOptions);
52
+ private url;
53
+ private request;
54
+ ping(signal?: AbortSignal): Promise<string>;
55
+ getRecentMessages(opts?: {
56
+ after?: number;
57
+ limit?: number;
58
+ sort?: "ASC" | "DESC";
59
+ }): Promise<BlueBubblesMessage[]>;
60
+ sendMessage(chatGuid: string, text: string): Promise<BlueBubblesMessage>;
61
+ sendAttachment(chatGuid: string, filePath: string, text?: string): Promise<BlueBubblesMessage>;
62
+ getChats(limit?: number): Promise<BlueBubblesChat[]>;
63
+ getChatMessages(chatGuid: string, limit?: number): Promise<BlueBubblesMessage[]>;
64
+ }
@@ -0,0 +1,98 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export class BlueBubblesClient {
3
+ baseUrl;
4
+ password;
5
+ constructor(opts) {
6
+ this.baseUrl = opts.serverUrl.replace(/\/+$/, "");
7
+ this.password = opts.password;
8
+ }
9
+ url(path, params) {
10
+ const u = new URL(`${this.baseUrl}/api/v1${path}`);
11
+ u.searchParams.set("password", this.password);
12
+ if (params) {
13
+ for (const [k, v] of Object.entries(params)) {
14
+ u.searchParams.set(k, v);
15
+ }
16
+ }
17
+ return u.toString();
18
+ }
19
+ async request(url, init) {
20
+ const response = await fetch(url, init);
21
+ const contentType = response.headers.get("content-type") ?? "";
22
+ if (!contentType.includes("application/json")) {
23
+ const text = await response.text();
24
+ throw new Error(`BlueBubbles returned non-JSON (${response.status}): ${text.slice(0, 200)}`);
25
+ }
26
+ const body = (await response.json());
27
+ if (body.status < 200 || body.status >= 300) {
28
+ throw new Error(body.error?.error ?? body.message ?? `BlueBubbles API error ${body.status}`);
29
+ }
30
+ return body;
31
+ }
32
+ async ping(signal) {
33
+ const res = await this.request(this.url("/ping"), { signal });
34
+ return res.data;
35
+ }
36
+ async getRecentMessages(opts = {}) {
37
+ const body = {
38
+ limit: opts.limit ?? 50,
39
+ sort: opts.sort ?? "ASC",
40
+ with: ["chat"],
41
+ };
42
+ if (opts.after !== undefined) {
43
+ body.after = opts.after;
44
+ }
45
+ const res = await this.request(this.url("/message/query"), {
46
+ method: "POST",
47
+ headers: { "Content-Type": "application/json" },
48
+ body: JSON.stringify(body),
49
+ });
50
+ return res.data;
51
+ }
52
+ async sendMessage(chatGuid, text) {
53
+ const res = await this.request(this.url("/message/text"), {
54
+ method: "POST",
55
+ headers: { "Content-Type": "application/json" },
56
+ body: JSON.stringify({
57
+ chatGuid,
58
+ tempGuid: `temp-${randomUUID()}`,
59
+ message: text,
60
+ }),
61
+ });
62
+ return res.data;
63
+ }
64
+ async sendAttachment(chatGuid, filePath, text) {
65
+ const fs = await import("node:fs");
66
+ const path = await import("node:path");
67
+ const fileBuffer = fs.readFileSync(filePath);
68
+ const fileName = path.basename(filePath);
69
+ const blob = new Blob([fileBuffer]);
70
+ const form = new FormData();
71
+ form.append("chatGuid", chatGuid);
72
+ form.append("tempGuid", `temp-${randomUUID()}`);
73
+ if (text)
74
+ form.append("message", text);
75
+ form.append("attachment", blob, fileName);
76
+ const res = await this.request(this.url("/message/attachment"), {
77
+ method: "POST",
78
+ body: form,
79
+ });
80
+ return res.data;
81
+ }
82
+ async getChats(limit = 20) {
83
+ const res = await this.request(this.url("/chat/query"), {
84
+ method: "POST",
85
+ headers: { "Content-Type": "application/json" },
86
+ body: JSON.stringify({ limit }),
87
+ });
88
+ return res.data;
89
+ }
90
+ async getChatMessages(chatGuid, limit = 25) {
91
+ const res = await this.request(this.url(`/chat/${encodeURIComponent(chatGuid)}/message`, {
92
+ limit: String(limit),
93
+ sort: "DESC",
94
+ }));
95
+ return res.data;
96
+ }
97
+ }
98
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/imessage/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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G,CAAC,qBAAqB,CAAC,EAAE;YAClF,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAoB,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACzE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;SAChC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,QAAgB,EAAE,KAAK,GAAG,EAAE;QAChD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAC5B,IAAI,CAAC,GAAG,CAAC,SAAS,kBAAkB,CAAC,QAAQ,CAAC,UAAU,EAAE;YACxD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;YACpB,IAAI,EAAE,MAAM;SACb,CAAC,CACH,CAAC;QACF,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ export interface IMessageHeadlessBridgePaths {
2
+ logFile: string;
3
+ pairCodeFile: string;
4
+ }
5
+ export interface IMessageHeadlessBridgePathOptions {
6
+ logFile?: string;
7
+ pairCodeFile?: string;
8
+ }
9
+ export declare function resolveIMessageHeadlessBridgePaths(cwd: string, options?: IMessageHeadlessBridgePathOptions): IMessageHeadlessBridgePaths;
@@ -0,0 +1,8 @@
1
+ import * as path from "node:path";
2
+ export function resolveIMessageHeadlessBridgePaths(cwd, options = {}) {
3
+ return {
4
+ logFile: path.resolve(cwd, options.logFile ?? "imessage-remote-bridge.log"),
5
+ pairCodeFile: path.resolve(cwd, options.pairCodeFile ?? "imessage-pair-code.txt"),
6
+ };
7
+ }
8
+ //# sourceMappingURL=headless-bridge-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headless-bridge-paths.js","sourceRoot":"","sources":["../../src/imessage/headless-bridge-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAYlC,MAAM,UAAU,kCAAkC,CAChD,GAAW,EACX,UAA6C,EAAE;IAE/C,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,IAAI,4BAA4B,CAAC;QAC3E,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,YAAY,IAAI,wBAAwB,CAAC;KAClF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type SandboxMode, type SandboxSettings } from "../utils/settings.js";
2
+ export interface IMessageHeadlessBridgeOptions {
3
+ apiKey?: string;
4
+ baseURL?: string;
5
+ model?: string;
6
+ sandboxMode?: SandboxMode;
7
+ sandboxSettings?: SandboxSettings;
8
+ maxToolRounds?: number;
9
+ serverUrl?: string;
10
+ password?: string;
11
+ pollingIntervalMs?: number;
12
+ logFile?: string;
13
+ pairCodeFile?: string;
14
+ }
15
+ export declare function runIMessageHeadlessBridge(options?: IMessageHeadlessBridgeOptions): Promise<void>;