bajaclaw 0.16.2 → 0.17.1
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/README.md +1 -1
- package/dist/channels/imessage.d.ts +7 -0
- package/dist/channels/imessage.js +63 -6
- package/dist/channels/imessage.js.map +1 -1
- package/helpers/bajaclaw-imessage-helper +0 -0
- package/helpers/imessage-typing.m +268 -0
- package/package.json +4 -2
- package/scripts/build-imessage-helper.mjs +103 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
██╔══██╗██╔══██║██ ██║██╔══██║ ██║ ██║ ██╔══██║██║███╗██║
|
|
8
8
|
██████╔╝██║ ██║╚█████╔╝██║ ██║ ╚██████╗███████╗██║ ██║╚███╔███╔╝
|
|
9
9
|
╚═════╝ ╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝
|
|
10
|
-
autonomous agents on your terms · MIT · v0.
|
|
10
|
+
autonomous agents on your terms · MIT · v0.17.1
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## What BajaClaw is
|
|
@@ -26,6 +26,13 @@ export interface InboundIMessage {
|
|
|
26
26
|
service: string;
|
|
27
27
|
}
|
|
28
28
|
export declare function openChatDb(): Database.Database;
|
|
29
|
+
export declare function resolveTypingHelperPath(): string | null;
|
|
30
|
+
export interface TypingResult {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
exitCode: number;
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function sendTypingIndicator(handle: string, typing: boolean, log?: Logger): TypingResult;
|
|
29
36
|
export declare function fetchNewMessages(db: Database.Database, sinceRowId: number): InboundIMessage[];
|
|
30
37
|
export declare function buildSendAppleScript(handle: string, text: string): string;
|
|
31
38
|
export declare function sendViaAppleScript(handle: string, text: string, log?: Logger): Promise<void>;
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
// `[attachment]` markers; agents still see them and can ask the user
|
|
19
19
|
// to forward through another channel.
|
|
20
20
|
import { spawnSync } from "node:child_process";
|
|
21
|
-
import { existsSync, readFileSync, writeFileSync, renameSync, openSync, closeSync } from "node:fs";
|
|
21
|
+
import { existsSync, readFileSync, writeFileSync, renameSync, openSync, closeSync, statSync } from "node:fs";
|
|
22
22
|
import { homedir } from "node:os";
|
|
23
|
-
import { join } from "node:path";
|
|
23
|
+
import { dirname, join } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
24
25
|
import Database from "better-sqlite3";
|
|
25
26
|
import { profileDir, ensureDir } from "../paths.js";
|
|
26
27
|
import { openDb } from "../db.js";
|
|
28
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
27
29
|
// Apple's CFAbsoluteTime epoch: 2001-01-01 00:00:00 UTC, in seconds
|
|
28
30
|
// since Unix epoch. chat.db stores message.date as nanoseconds since
|
|
29
31
|
// that moment (macOS 10.13+; older versions used seconds).
|
|
@@ -116,6 +118,56 @@ export function saveState(profile, state) {
|
|
|
116
118
|
export function openChatDb() {
|
|
117
119
|
return new Database(chatDbPath(), { readonly: true, fileMustExist: true });
|
|
118
120
|
}
|
|
121
|
+
// Native typing helper. Compiled from helpers/imessage-typing.m into a
|
|
122
|
+
// universal Mach-O binary shipped alongside bajaclaw. Calls IMCore's
|
|
123
|
+
// private setLocalUserIsTyping: to produce the "..." indicator on the
|
|
124
|
+
// recipient's device - something AppleScript can't do.
|
|
125
|
+
//
|
|
126
|
+
// Resolves to one of:
|
|
127
|
+
// - <repo>/helpers/bajaclaw-imessage-helper (dev checkout; src/channels -> up two)
|
|
128
|
+
// - <pkg>/helpers/bajaclaw-imessage-helper (installed; dist/channels -> up two)
|
|
129
|
+
// Both paths end up the same shape because `files` in package.json
|
|
130
|
+
// ships helpers/ verbatim next to dist/.
|
|
131
|
+
let cachedHelperPath;
|
|
132
|
+
export function resolveTypingHelperPath() {
|
|
133
|
+
if (cachedHelperPath !== undefined)
|
|
134
|
+
return cachedHelperPath;
|
|
135
|
+
// __dirname is <root>/dist/channels when installed, or <root>/src/channels
|
|
136
|
+
// via tsx. Either way, up two levels is the package root.
|
|
137
|
+
const root = join(__dirname, "..", "..");
|
|
138
|
+
const candidate = join(root, "helpers", "bajaclaw-imessage-helper");
|
|
139
|
+
try {
|
|
140
|
+
const st = statSync(candidate);
|
|
141
|
+
if (st.isFile()) {
|
|
142
|
+
// Strip the quarantine attribute npm applies to files downloaded
|
|
143
|
+
// in tarballs. Idempotent; no-op if absent. Ignored on failure.
|
|
144
|
+
spawnSync("xattr", ["-dr", "com.apple.quarantine", candidate], { stdio: "ignore" });
|
|
145
|
+
cachedHelperPath = candidate;
|
|
146
|
+
return candidate;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch { /* not present */ }
|
|
150
|
+
cachedHelperPath = null;
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
export function sendTypingIndicator(handle, typing, log) {
|
|
154
|
+
if (process.platform !== "darwin") {
|
|
155
|
+
return { ok: false, exitCode: -1, error: "unsupported-platform" };
|
|
156
|
+
}
|
|
157
|
+
const helper = resolveTypingHelperPath();
|
|
158
|
+
if (!helper) {
|
|
159
|
+
return { ok: false, exitCode: -1, error: "helper-not-found" };
|
|
160
|
+
}
|
|
161
|
+
const norm = normalizeHandle(handle);
|
|
162
|
+
const verb = typing ? "start" : "stop";
|
|
163
|
+
const r = spawnSync(helper, [verb, norm], { encoding: "utf8", timeout: 5000 });
|
|
164
|
+
if (r.status === 0) {
|
|
165
|
+
return { ok: true, exitCode: 0 };
|
|
166
|
+
}
|
|
167
|
+
const err = (r.stderr || "").trim();
|
|
168
|
+
log?.warn("gateway.imessage.typing-fail", { verb, handle: norm, status: r.status, err: err.slice(0, 200) });
|
|
169
|
+
return { ok: false, exitCode: r.status ?? -1, error: err };
|
|
170
|
+
}
|
|
119
171
|
// The inbound query. ROWID is monotonic and indexed, so "everything
|
|
120
172
|
// after the last one we saw" is an O(log n) lookup plus a sequential
|
|
121
173
|
// scan over only the new rows. Joins to handle.id for the sender
|
|
@@ -272,10 +324,15 @@ export async function startIMessage(profile, config, log, deps) {
|
|
|
272
324
|
await sendViaAppleScript(String(chatId), text, log);
|
|
273
325
|
},
|
|
274
326
|
startTyping: (_chatId) => {
|
|
275
|
-
// iMessage
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
//
|
|
327
|
+
// iMessage typing indicators are not wired as of v0.17.1. v0.17.0
|
|
328
|
+
// shipped a native helper that talks to IMCore, but the registry
|
|
329
|
+
// stays empty in a standalone process because we don't register
|
|
330
|
+
// as a proper IMDaemonListener - imagent only pushes chat state
|
|
331
|
+
// to subscribed listeners (that's how BlueBubbles works, with a
|
|
332
|
+
// full Obj-C delegate). The helper binary is retained for a
|
|
333
|
+
// future pass that implements the listener properly; for now we
|
|
334
|
+
// keep the shape (startTyping returns a stop fn) so the gateway
|
|
335
|
+
// plumbing stays consistent.
|
|
279
336
|
return () => { };
|
|
280
337
|
},
|
|
281
338
|
stop: async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imessage.js","sourceRoot":"","sources":["../../src/channels/imessage.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,yDAAyD;AACzD,qEAAqE;AACrE,kEAAkE;AAClE,mBAAmB;AACnB,+DAA+D;AAC/D,uDAAuD;AACvD,EAAE;AACF,qEAAqE;AACrE,+DAA+D;AAC/D,+CAA+C;AAC/C,EAAE;AACF,6DAA6D;AAC7D,4DAA4D;AAC5D,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAA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file
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// bajaclaw-imessage-helper
|
|
2
|
+
// ------------------------
|
|
3
|
+
// Long-running Obj-C helper that keeps a live connection to Apple's
|
|
4
|
+
// imagent via IMDaemonController, maintains the IMChatRegistry cache
|
|
5
|
+
// in-process, and toggles the "..." typing indicator on iMessage
|
|
6
|
+
// threads via the private IMCore framework.
|
|
7
|
+
//
|
|
8
|
+
// Why long-running: imagent pushes chat state asynchronously to any
|
|
9
|
+
// process that has registered as an IMDaemonListener. A short-lived
|
|
10
|
+
// one-shot helper exits before that state arrives, so the registry
|
|
11
|
+
// always looks empty. Keeping one helper per daemon lifetime lets us
|
|
12
|
+
// amortize the startup cost and always have a populated registry.
|
|
13
|
+
//
|
|
14
|
+
// Protocol: the helper reads newline-delimited commands from stdin
|
|
15
|
+
// and writes newline-delimited responses to stdout.
|
|
16
|
+
//
|
|
17
|
+
// start <handle-or-guid> -> "ok" | "err <reason>"
|
|
18
|
+
// stop <handle-or-guid> -> "ok" | "err <reason>"
|
|
19
|
+
// ping -> "ok"
|
|
20
|
+
// quit -> exits 0
|
|
21
|
+
//
|
|
22
|
+
// Arg-style legacy mode is also supported so existing callers and
|
|
23
|
+
// unit tests keep working: invoking with `<verb> <handle>` as argv
|
|
24
|
+
// performs a single toggle and exits. In that mode we wait up to
|
|
25
|
+
// 5s for the registry to populate (shorter than the long-running
|
|
26
|
+
// path would need, because a single ask can give up).
|
|
27
|
+
//
|
|
28
|
+
// Graceful-failure contract: any non-zero exit or "err <reason>"
|
|
29
|
+
// line means "typing unavailable for this call". The Node adapter
|
|
30
|
+
// never fails a send because of typing.
|
|
31
|
+
#import <Foundation/Foundation.h>
|
|
32
|
+
#import <dlfcn.h>
|
|
33
|
+
|
|
34
|
+
// Reverse-engineered private class declarations. Apple does not ship
|
|
35
|
+
// these headers; symbols have been stable across macOS 10.14-15.
|
|
36
|
+
@interface IMDaemonController : NSObject
|
|
37
|
+
+ (instancetype)sharedInstance;
|
|
38
|
+
- (BOOL)connectToDaemon;
|
|
39
|
+
- (BOOL)blockUntilConnected;
|
|
40
|
+
- (id)listener;
|
|
41
|
+
@end
|
|
42
|
+
|
|
43
|
+
@interface IMChatRegistry : NSObject
|
|
44
|
+
+ (instancetype)sharedInstance;
|
|
45
|
+
- (id)existingChatWithChatIdentifier:(NSString *)identifier;
|
|
46
|
+
- (id)existingChatWithGUID:(NSString *)guid;
|
|
47
|
+
- (id)_existingChatWithGUID:(NSString *)guid;
|
|
48
|
+
- (NSArray *)allExistingChats;
|
|
49
|
+
@end
|
|
50
|
+
|
|
51
|
+
@interface IMChat : NSObject
|
|
52
|
+
- (void)setLocalUserIsTyping:(BOOL)typing;
|
|
53
|
+
- (NSString *)guid;
|
|
54
|
+
- (NSString *)chatIdentifier;
|
|
55
|
+
@end
|
|
56
|
+
|
|
57
|
+
static NSString * const IMCORE_PATH = @"/System/Library/PrivateFrameworks/IMCore.framework/IMCore";
|
|
58
|
+
static BOOL gVerbose = NO;
|
|
59
|
+
|
|
60
|
+
static void logDebug(NSString *fmt, ...) {
|
|
61
|
+
if (!gVerbose) return;
|
|
62
|
+
va_list args;
|
|
63
|
+
va_start(args, fmt);
|
|
64
|
+
NSString *s = [[NSString alloc] initWithFormat:fmt arguments:args];
|
|
65
|
+
va_end(args);
|
|
66
|
+
fprintf(stderr, "DEBUG: %s\n", [s UTF8String]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static BOOL loadIMCore(void) {
|
|
70
|
+
void *h = dlopen([IMCORE_PATH UTF8String], RTLD_NOW);
|
|
71
|
+
if (!h) {
|
|
72
|
+
fprintf(stderr, "ERROR: failed to load IMCore: %s\n", dlerror());
|
|
73
|
+
return NO;
|
|
74
|
+
}
|
|
75
|
+
return YES;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static BOOL connectDaemon(void) {
|
|
79
|
+
Class daemonClass = NSClassFromString(@"IMDaemonController");
|
|
80
|
+
if (!daemonClass) return NO;
|
|
81
|
+
id daemon = [daemonClass performSelector:@selector(sharedInstance)];
|
|
82
|
+
if (!daemon) return NO;
|
|
83
|
+
if ([daemon respondsToSelector:@selector(connectToDaemon)]) {
|
|
84
|
+
[daemon performSelector:@selector(connectToDaemon)];
|
|
85
|
+
}
|
|
86
|
+
if ([daemon respondsToSelector:@selector(blockUntilConnected)]) {
|
|
87
|
+
[daemon performSelector:@selector(blockUntilConnected)];
|
|
88
|
+
}
|
|
89
|
+
return YES;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Wait up to `seconds` for the registry to report at least one chat.
|
|
93
|
+
// Returns the number of chats when it gave up (may be 0 if the wait
|
|
94
|
+
// expired).
|
|
95
|
+
static NSUInteger waitForChats(NSTimeInterval seconds) {
|
|
96
|
+
NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:seconds];
|
|
97
|
+
NSUInteger last = 0;
|
|
98
|
+
while ([[NSDate date] compare:deadline] == NSOrderedAscending) {
|
|
99
|
+
@autoreleasepool {
|
|
100
|
+
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
|
101
|
+
Class rc = NSClassFromString(@"IMChatRegistry");
|
|
102
|
+
id reg = [rc performSelector:@selector(sharedInstance)];
|
|
103
|
+
id chats = [reg performSelector:@selector(allExistingChats)];
|
|
104
|
+
if ([chats isKindOfClass:[NSArray class]]) {
|
|
105
|
+
last = [(NSArray *)chats count];
|
|
106
|
+
if (last > 0) return last;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return last;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static id findChat(NSString *target) {
|
|
114
|
+
Class rc = NSClassFromString(@"IMChatRegistry");
|
|
115
|
+
id registry = [rc performSelector:@selector(sharedInstance)];
|
|
116
|
+
|
|
117
|
+
NSArray<NSString *> *guids = @[
|
|
118
|
+
[NSString stringWithFormat:@"any;-;%@", target],
|
|
119
|
+
[NSString stringWithFormat:@"iMessage;-;%@", target],
|
|
120
|
+
[NSString stringWithFormat:@"SMS;-;%@", target],
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
// Strategy 1: enumerate allExistingChats and match by
|
|
124
|
+
// chatIdentifier or guid tail. Works once imagent has pushed state.
|
|
125
|
+
if ([registry respondsToSelector:@selector(allExistingChats)]) {
|
|
126
|
+
id allChats = [registry performSelector:@selector(allExistingChats)];
|
|
127
|
+
if ([allChats isKindOfClass:[NSArray class]]) {
|
|
128
|
+
logDebug(@"allExistingChats -> %lu chats", (unsigned long)[(NSArray *)allChats count]);
|
|
129
|
+
for (id chat in (NSArray *)allChats) {
|
|
130
|
+
NSString *cid = [chat respondsToSelector:@selector(chatIdentifier)]
|
|
131
|
+
? [chat performSelector:@selector(chatIdentifier)] : nil;
|
|
132
|
+
NSString *cguid = [chat respondsToSelector:@selector(guid)]
|
|
133
|
+
? [chat performSelector:@selector(guid)] : nil;
|
|
134
|
+
if ([cid isEqualToString:target]) return chat;
|
|
135
|
+
if (cguid) {
|
|
136
|
+
for (NSString *g in guids) if ([cguid isEqualToString:g]) return chat;
|
|
137
|
+
if ([cguid hasSuffix:[NSString stringWithFormat:@";-;%@", target]]) return chat;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Strategy 2: direct GUID lookup on the registry.
|
|
144
|
+
for (NSString *guid in guids) {
|
|
145
|
+
id chat = [registry performSelector:@selector(existingChatWithChatIdentifier:) withObject:guid];
|
|
146
|
+
if (chat) return chat;
|
|
147
|
+
if ([registry respondsToSelector:@selector(_existingChatWithGUID:)]) {
|
|
148
|
+
chat = [registry performSelector:@selector(_existingChatWithGUID:) withObject:guid];
|
|
149
|
+
if (chat) return chat;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Strategy 3: bare handle.
|
|
154
|
+
return [registry performSelector:@selector(existingChatWithChatIdentifier:) withObject:target];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Perform typing toggle; return nil on success or an error string.
|
|
158
|
+
static NSString *toggleTyping(NSString *target, BOOL typing) {
|
|
159
|
+
id chat = findChat(target);
|
|
160
|
+
if (!chat) return @"no existing chat (user must text first)";
|
|
161
|
+
SEL sel = @selector(setLocalUserIsTyping:);
|
|
162
|
+
NSMethodSignature *sig = [chat methodSignatureForSelector:sel];
|
|
163
|
+
if (!sig) return @"setLocalUserIsTyping: not available";
|
|
164
|
+
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
|
|
165
|
+
[inv setTarget:chat];
|
|
166
|
+
[inv setSelector:sel];
|
|
167
|
+
[inv setArgument:&typing atIndex:2];
|
|
168
|
+
@try {
|
|
169
|
+
[inv invoke];
|
|
170
|
+
} @catch (NSException *e) {
|
|
171
|
+
return [NSString stringWithFormat:@"invoke threw: %@", [e reason]];
|
|
172
|
+
}
|
|
173
|
+
return nil;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Long-running stdin loop. Reads line-delimited commands; writes
|
|
177
|
+
// "ok"/"err ..." lines to stdout. Returns when stdin is closed or a
|
|
178
|
+
// "quit" command arrives.
|
|
179
|
+
static int runDaemonLoop(void) {
|
|
180
|
+
logDebug(@"entering daemon loop");
|
|
181
|
+
// Warm up the registry once. A few seconds of waiting at start is
|
|
182
|
+
// fine because we only pay it once per helper lifetime.
|
|
183
|
+
waitForChats(5.0);
|
|
184
|
+
|
|
185
|
+
char *buf = NULL;
|
|
186
|
+
size_t bufSize = 0;
|
|
187
|
+
ssize_t len;
|
|
188
|
+
setvbuf(stdout, NULL, _IOLBF, 0); // line-buffered
|
|
189
|
+
while ((len = getline(&buf, &bufSize, stdin)) != -1) {
|
|
190
|
+
@autoreleasepool {
|
|
191
|
+
// Trim trailing newline.
|
|
192
|
+
while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r')) { buf[--len] = '\0'; }
|
|
193
|
+
if (len == 0) continue;
|
|
194
|
+
NSString *line = [NSString stringWithUTF8String:buf];
|
|
195
|
+
NSArray<NSString *> *parts = [line componentsSeparatedByString:@" "];
|
|
196
|
+
NSString *cmd = parts.count > 0 ? parts[0] : @"";
|
|
197
|
+
NSString *arg = parts.count > 1 ? [[parts subarrayWithRange:NSMakeRange(1, parts.count - 1)] componentsJoinedByString:@" "] : @"";
|
|
198
|
+
|
|
199
|
+
if ([cmd isEqualToString:@"ping"]) {
|
|
200
|
+
printf("ok\n");
|
|
201
|
+
} else if ([cmd isEqualToString:@"quit"]) {
|
|
202
|
+
printf("ok\n");
|
|
203
|
+
break;
|
|
204
|
+
} else if ([cmd isEqualToString:@"start"] || [cmd isEqualToString:@"stop"]) {
|
|
205
|
+
BOOL typing = [cmd isEqualToString:@"start"];
|
|
206
|
+
NSString *err = toggleTyping(arg, typing);
|
|
207
|
+
if (err) {
|
|
208
|
+
printf("err %s\n", [err UTF8String]);
|
|
209
|
+
} else {
|
|
210
|
+
printf("ok\n");
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
printf("err unknown command\n");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
free(buf);
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
int main(int argc, char *argv[]) {
|
|
222
|
+
@autoreleasepool {
|
|
223
|
+
gVerbose = getenv("BAJACLAW_HELPER_DEBUG") != NULL;
|
|
224
|
+
|
|
225
|
+
if (!loadIMCore()) return 2;
|
|
226
|
+
if (!connectDaemon()) {
|
|
227
|
+
fprintf(stderr, "ERROR: IMDaemonController not available\n");
|
|
228
|
+
return 3;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Two modes:
|
|
232
|
+
// argv form (legacy): helper <start|stop> <handle>
|
|
233
|
+
// daemon form: helper serve (reads stdin)
|
|
234
|
+
if (argc >= 2 && strcmp(argv[1], "serve") == 0) {
|
|
235
|
+
return runDaemonLoop();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (argc < 3) {
|
|
239
|
+
fprintf(stderr, "usage: %s <start|stop|serve> [handle]\n", argv[0]);
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const char *cmd = argv[1];
|
|
244
|
+
BOOL typing;
|
|
245
|
+
if (strcmp(cmd, "start") == 0) typing = YES;
|
|
246
|
+
else if (strcmp(cmd, "stop") == 0) typing = NO;
|
|
247
|
+
else {
|
|
248
|
+
fprintf(stderr, "usage: %s <start|stop|serve> [handle]\n", argv[0]);
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
NSString *target = [NSString stringWithUTF8String:argv[2]];
|
|
253
|
+
|
|
254
|
+
// One-shot mode: wait up to 5s for registry. If still empty,
|
|
255
|
+
// we won't find the chat. Callers in long-running setups
|
|
256
|
+
// should use `serve` instead.
|
|
257
|
+
waitForChats(5.0);
|
|
258
|
+
|
|
259
|
+
NSString *err = toggleTyping(target, typing);
|
|
260
|
+
if (err) {
|
|
261
|
+
fprintf(stderr, "ERROR: %s\n", [err UTF8String]);
|
|
262
|
+
return 4;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
fprintf(stdout, "ok\n");
|
|
266
|
+
return 0;
|
|
267
|
+
}
|
|
268
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bajaclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "BajaClaw - autonomous agents on your terms",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bajaclaw": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"bajaclaw": "bin/bajaclaw.js"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "tsc -p tsconfig.json && node scripts/copy-static.js",
|
|
15
|
+
"build": "tsc -p tsconfig.json && node scripts/copy-static.js && node scripts/build-imessage-helper.mjs",
|
|
16
|
+
"build:helper": "node scripts/build-imessage-helper.mjs",
|
|
16
17
|
"dev": "tsx src/cli.ts",
|
|
17
18
|
"dashboard:dev": "tsx watch src/cli.ts dashboard",
|
|
18
19
|
"test": "node scripts/run-tests.js",
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
"files": [
|
|
24
25
|
"bin/",
|
|
25
26
|
"dist/",
|
|
27
|
+
"helpers/",
|
|
26
28
|
"scripts/",
|
|
27
29
|
"skills/",
|
|
28
30
|
"templates/"
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Compile helpers/imessage-typing.m into a universal macOS binary.
|
|
3
|
+
//
|
|
4
|
+
// Invoked at build time (npm run build) on macOS, and also manually via
|
|
5
|
+
// `node scripts/build-imessage-helper.mjs` for contributors. On non-mac
|
|
6
|
+
// platforms it's a no-op (logs and exits 0). The resulting binary lives
|
|
7
|
+
// at helpers/bajaclaw-imessage-helper (checked into git + shipped in the
|
|
8
|
+
// npm tarball so users don't need Xcode CLI Tools).
|
|
9
|
+
//
|
|
10
|
+
// Universal binary: we build arm64 + x86_64 and `lipo` them together so
|
|
11
|
+
// the same helper runs on every modern Mac. If either arch fails (e.g.
|
|
12
|
+
// Rosetta/cross-SDK not available), falls back to the host-native arch.
|
|
13
|
+
import { spawnSync } from "node:child_process";
|
|
14
|
+
import { existsSync, mkdirSync, renameSync, unlinkSync } from "node:fs";
|
|
15
|
+
import { dirname, join } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
|
|
18
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const root = join(__dirname, "..");
|
|
20
|
+
const src = join(root, "helpers", "imessage-typing.m");
|
|
21
|
+
const out = join(root, "helpers", "bajaclaw-imessage-helper");
|
|
22
|
+
|
|
23
|
+
if (process.platform !== "darwin") {
|
|
24
|
+
console.log("[build-imessage-helper] skipping: not macOS");
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!existsSync(src)) {
|
|
29
|
+
console.error(`[build-imessage-helper] source missing: ${src}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Need clang. `xcrun` finds it whether Xcode.app or Command Line Tools
|
|
34
|
+
// are installed. If neither, bail cleanly - the adapter falls back to
|
|
35
|
+
// no-op typing.
|
|
36
|
+
const xcrun = spawnSync("xcrun", ["--find", "clang"], { encoding: "utf8" });
|
|
37
|
+
if (xcrun.status !== 0) {
|
|
38
|
+
console.log("[build-imessage-helper] skipping: xcrun/clang not available (install Xcode Command Line Tools for native typing)");
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
const clang = xcrun.stdout.trim();
|
|
42
|
+
|
|
43
|
+
// Clang on macOS needs `-isysroot` pointing at the SDK or it can't find
|
|
44
|
+
// Foundation.h. `xcrun --show-sdk-path` gives us the right one whether
|
|
45
|
+
// the full Xcode.app or just CommandLineTools is installed.
|
|
46
|
+
const sdkProbe = spawnSync("xcrun", ["--sdk", "macosx", "--show-sdk-path"], { encoding: "utf8" });
|
|
47
|
+
if (sdkProbe.status !== 0) {
|
|
48
|
+
console.log("[build-imessage-helper] skipping: macOS SDK not found");
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
const sdkPath = sdkProbe.stdout.trim();
|
|
52
|
+
|
|
53
|
+
function compile(arch, outPath) {
|
|
54
|
+
const args = [
|
|
55
|
+
"-isysroot", sdkPath,
|
|
56
|
+
"-arch", arch,
|
|
57
|
+
"-framework", "Foundation",
|
|
58
|
+
"-ObjC",
|
|
59
|
+
"-fobjc-arc",
|
|
60
|
+
"-O2",
|
|
61
|
+
"-o", outPath,
|
|
62
|
+
src,
|
|
63
|
+
];
|
|
64
|
+
const r = spawnSync(clang, args, { stdio: "inherit" });
|
|
65
|
+
return r.status === 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
69
|
+
|
|
70
|
+
const tmpArm = out + ".arm64";
|
|
71
|
+
const tmpX86 = out + ".x86_64";
|
|
72
|
+
|
|
73
|
+
const armOk = compile("arm64", tmpArm);
|
|
74
|
+
const x86Ok = compile("x86_64", tmpX86);
|
|
75
|
+
|
|
76
|
+
if (armOk && x86Ok) {
|
|
77
|
+
// lipo into universal
|
|
78
|
+
const lipo = spawnSync("lipo", ["-create", tmpArm, tmpX86, "-output", out], { stdio: "inherit" });
|
|
79
|
+
try { unlinkSync(tmpArm); } catch { /* ignore */ }
|
|
80
|
+
try { unlinkSync(tmpX86); } catch { /* ignore */ }
|
|
81
|
+
if (lipo.status !== 0) {
|
|
82
|
+
console.error("[build-imessage-helper] lipo failed");
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
console.log(`[build-imessage-helper] built universal binary: ${out}`);
|
|
86
|
+
} else if (armOk) {
|
|
87
|
+
renameSync(tmpArm, out);
|
|
88
|
+
try { unlinkSync(tmpX86); } catch { /* ignore */ }
|
|
89
|
+
console.log(`[build-imessage-helper] built arm64 only: ${out}`);
|
|
90
|
+
} else if (x86Ok) {
|
|
91
|
+
renameSync(tmpX86, out);
|
|
92
|
+
try { unlinkSync(tmpArm); } catch { /* ignore */ }
|
|
93
|
+
console.log(`[build-imessage-helper] built x86_64 only: ${out}`);
|
|
94
|
+
} else {
|
|
95
|
+
console.error("[build-imessage-helper] both architectures failed to compile");
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Sanity: make sure it's executable and strip quarantine if present.
|
|
100
|
+
spawnSync("chmod", ["+x", out]);
|
|
101
|
+
spawnSync("xattr", ["-dr", "com.apple.quarantine", out]);
|
|
102
|
+
|
|
103
|
+
process.exit(0);
|