@elizaos/macosalarm 2.0.0-beta.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/bin/macosalarm-helper +0 -0
- package/dist/actions.d.ts +7 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +443 -0
- package/dist/actions.js.map +1 -0
- package/dist/helper.d.ts +16 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/helper.js +82 -0
- package/dist/helper.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +10 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +73 -0
- package/scripts/build-helper.mjs +44 -0
- package/swift-helper/main.swift +248 -0
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Action } from "@elizaos/core";
|
|
2
|
+
import { type HelperRunOptions } from "./helper";
|
|
3
|
+
export interface MacosAlarmActionDeps {
|
|
4
|
+
helperOptions?: HelperRunOptions;
|
|
5
|
+
}
|
|
6
|
+
export declare function createAlarmAction(deps?: MacosAlarmActionDeps): Action;
|
|
7
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,MAAM,EAQZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,UAAU,CAAC;AASlB,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAuWD,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,oBAAyB,GAAG,MAAM,CA8JzE"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { logger, } from "@elizaos/core";
|
|
3
|
+
import { MacosAlarmHelperUnavailableError, runHelper, } from "./helper";
|
|
4
|
+
const ALARM_SUBACTIONS = ["set", "cancel", "list"];
|
|
5
|
+
const NOT_SUPPORTED = {
|
|
6
|
+
success: false,
|
|
7
|
+
text: "I can only use native alarms on macOS.",
|
|
8
|
+
error: "macos-only",
|
|
9
|
+
};
|
|
10
|
+
const ALARM_CONTEXTS = ["tasks", "calendar", "automation"];
|
|
11
|
+
const ALARM_TERMS = [
|
|
12
|
+
"alarm",
|
|
13
|
+
"alarms",
|
|
14
|
+
"wake",
|
|
15
|
+
"despertador",
|
|
16
|
+
"alarma",
|
|
17
|
+
"alarmas",
|
|
18
|
+
"reveil",
|
|
19
|
+
"réveil",
|
|
20
|
+
"alarme",
|
|
21
|
+
"wecker",
|
|
22
|
+
"alarm anzeigen",
|
|
23
|
+
"闹钟",
|
|
24
|
+
"提醒",
|
|
25
|
+
"アラーム",
|
|
26
|
+
"알람",
|
|
27
|
+
"báo thức",
|
|
28
|
+
"bao thuc",
|
|
29
|
+
];
|
|
30
|
+
function isDarwin() {
|
|
31
|
+
return process.platform === "darwin";
|
|
32
|
+
}
|
|
33
|
+
function getText(message) {
|
|
34
|
+
return (message.content.text ?? "").toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
function normalizeContextList(value) {
|
|
37
|
+
if (!Array.isArray(value))
|
|
38
|
+
return [];
|
|
39
|
+
return value
|
|
40
|
+
.flatMap((item) => (typeof item === "string" ? [item.toLowerCase()] : []))
|
|
41
|
+
.filter(Boolean);
|
|
42
|
+
}
|
|
43
|
+
function hasAlarmContext(message, state) {
|
|
44
|
+
const values = state?.values ?? {};
|
|
45
|
+
const content = message.content;
|
|
46
|
+
const contexts = [
|
|
47
|
+
...normalizeContextList(values.activeContexts),
|
|
48
|
+
...normalizeContextList(values.selectedContexts),
|
|
49
|
+
...normalizeContextList(content.activeContexts),
|
|
50
|
+
...normalizeContextList(content.selectedContexts),
|
|
51
|
+
...normalizeContextList(content.contexts),
|
|
52
|
+
];
|
|
53
|
+
return contexts.some((context) => ALARM_CONTEXTS.includes(context));
|
|
54
|
+
}
|
|
55
|
+
function hasAlarmSignal(message, state) {
|
|
56
|
+
if (hasAlarmContext(message, state))
|
|
57
|
+
return true;
|
|
58
|
+
const text = getText(message);
|
|
59
|
+
return ALARM_TERMS.some((term) => text.includes(term.toLowerCase()));
|
|
60
|
+
}
|
|
61
|
+
function readParameters(options) {
|
|
62
|
+
const params = options?.parameters;
|
|
63
|
+
return params && typeof params === "object" ? params : {};
|
|
64
|
+
}
|
|
65
|
+
function normalizeSubactionValue(value) {
|
|
66
|
+
if (typeof value !== "string")
|
|
67
|
+
return null;
|
|
68
|
+
const normalized = value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
69
|
+
const aliases = {
|
|
70
|
+
schedule: "set",
|
|
71
|
+
create: "set",
|
|
72
|
+
add: "set",
|
|
73
|
+
remove: "cancel",
|
|
74
|
+
delete: "cancel",
|
|
75
|
+
show: "list",
|
|
76
|
+
pending: "list",
|
|
77
|
+
};
|
|
78
|
+
if (aliases[normalized])
|
|
79
|
+
return aliases[normalized];
|
|
80
|
+
return ALARM_SUBACTIONS.includes(normalized)
|
|
81
|
+
? normalized
|
|
82
|
+
: null;
|
|
83
|
+
}
|
|
84
|
+
function inferSubactionFromText(text) {
|
|
85
|
+
const lower = text.toLowerCase();
|
|
86
|
+
if (/\b(list|show|pending|view|see|what)\b.*\balarm/.test(lower) ||
|
|
87
|
+
/\balarms?\s*(?:list|pending)\b/.test(lower)) {
|
|
88
|
+
return "list";
|
|
89
|
+
}
|
|
90
|
+
if (/\b(cancel|stop|remove|delete|kill|clear)\b.*\balarm/.test(lower) ||
|
|
91
|
+
/\balarm\b.*\b(cancel|stop|remove|delete|kill|clear)\b/.test(lower)) {
|
|
92
|
+
return "cancel";
|
|
93
|
+
}
|
|
94
|
+
if (/\b(set|schedule|create|add|new|wake)\b.*\balarm/.test(lower) ||
|
|
95
|
+
/\balarm\b.*\b(set|schedule|create|add|for)\b/.test(lower) ||
|
|
96
|
+
/\bwake me\b/.test(lower)) {
|
|
97
|
+
return "set";
|
|
98
|
+
}
|
|
99
|
+
if (lower.includes("alarm")) {
|
|
100
|
+
// Default to list when alarm mentioned without a clear verb.
|
|
101
|
+
return "list";
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
function parseSchedule(params) {
|
|
106
|
+
const timeIso = typeof params.timeIso === "string" ? params.timeIso : null;
|
|
107
|
+
const title = typeof params.title === "string" ? params.title : null;
|
|
108
|
+
if (!timeIso || !title)
|
|
109
|
+
return null;
|
|
110
|
+
const body = typeof params.body === "string" ? params.body : undefined;
|
|
111
|
+
const id = typeof params.id === "string" ? params.id : undefined;
|
|
112
|
+
const sound = typeof params.sound === "string" ? params.sound : undefined;
|
|
113
|
+
return { timeIso, title, body, id, sound };
|
|
114
|
+
}
|
|
115
|
+
function parseCancel(params) {
|
|
116
|
+
const id = typeof params.id === "string"
|
|
117
|
+
? params.id
|
|
118
|
+
: typeof params.alarmId === "string"
|
|
119
|
+
? params.alarmId
|
|
120
|
+
: null;
|
|
121
|
+
if (!id)
|
|
122
|
+
return null;
|
|
123
|
+
return { id };
|
|
124
|
+
}
|
|
125
|
+
async function runSet(message, params, deps, callback) {
|
|
126
|
+
const parsed = parseSchedule(params);
|
|
127
|
+
if (!parsed) {
|
|
128
|
+
const err = "ALARM set requires timeIso and title parameters.";
|
|
129
|
+
logger.warn(`[ALARM/set] ${err}`);
|
|
130
|
+
if (callback) {
|
|
131
|
+
await callback({ text: err, source: message.content.source });
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
success: false,
|
|
135
|
+
error: err,
|
|
136
|
+
data: { actionName: "ALARM", subaction: "set" },
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const id = parsed.id ?? `alarm-${randomUUID()}`;
|
|
140
|
+
try {
|
|
141
|
+
const response = await runHelper({
|
|
142
|
+
action: "schedule",
|
|
143
|
+
id,
|
|
144
|
+
timeIso: parsed.timeIso,
|
|
145
|
+
title: parsed.title,
|
|
146
|
+
body: parsed.body,
|
|
147
|
+
sound: parsed.sound,
|
|
148
|
+
}, deps.helperOptions);
|
|
149
|
+
if (!response.success) {
|
|
150
|
+
logger.error(`[ALARM/set] helper returned error: ${response.error}`);
|
|
151
|
+
if (callback) {
|
|
152
|
+
await callback({
|
|
153
|
+
text: `Could not set alarm: ${response.error}`,
|
|
154
|
+
source: message.content.source,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: response.error,
|
|
160
|
+
data: { actionName: "ALARM", subaction: "set" },
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const scheduled = response;
|
|
164
|
+
logger.info(`[ALARM/set] scheduled id=${scheduled.id} fireAt=${scheduled.fireAt}`);
|
|
165
|
+
if (callback) {
|
|
166
|
+
await callback({
|
|
167
|
+
text: `Alarm set for ${scheduled.fireAt}: "${parsed.title}".`,
|
|
168
|
+
source: message.content.source,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
data: {
|
|
174
|
+
actionName: "ALARM",
|
|
175
|
+
subaction: "set",
|
|
176
|
+
id: scheduled.id,
|
|
177
|
+
fireAt: scheduled.fireAt,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
if (err instanceof MacosAlarmHelperUnavailableError) {
|
|
183
|
+
logger.warn(`[ALARM/set] helper unavailable: ${err.reason}`);
|
|
184
|
+
if (callback) {
|
|
185
|
+
await callback({
|
|
186
|
+
text: "The macOS alarm helper is not installed on this machine.",
|
|
187
|
+
source: message.content.source,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
success: false,
|
|
192
|
+
error: err.reason,
|
|
193
|
+
data: { actionName: "ALARM", subaction: "set" },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const failureMessage = err instanceof Error ? err.message : "Unknown macOS alarm failure.";
|
|
197
|
+
logger.error(`[ALARM/set] helper failed: ${failureMessage}`);
|
|
198
|
+
return {
|
|
199
|
+
success: false,
|
|
200
|
+
text: `Could not set alarm: ${failureMessage}`,
|
|
201
|
+
error: failureMessage,
|
|
202
|
+
data: { actionName: "ALARM", subaction: "set" },
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function runCancel(message, params, deps, callback) {
|
|
207
|
+
const parsed = parseCancel(params);
|
|
208
|
+
if (!parsed) {
|
|
209
|
+
const err = "ALARM cancel requires an id parameter.";
|
|
210
|
+
logger.warn(`[ALARM/cancel] ${err}`);
|
|
211
|
+
return {
|
|
212
|
+
success: false,
|
|
213
|
+
error: err,
|
|
214
|
+
data: { actionName: "ALARM", subaction: "cancel" },
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
const response = await runHelper({ action: "cancel", id: parsed.id }, deps.helperOptions);
|
|
219
|
+
if (!response.success) {
|
|
220
|
+
return {
|
|
221
|
+
success: false,
|
|
222
|
+
error: response.error,
|
|
223
|
+
data: { actionName: "ALARM", subaction: "cancel" },
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const cancelled = response;
|
|
227
|
+
logger.info(`[ALARM/cancel] cancelled id=${cancelled.id}`);
|
|
228
|
+
if (callback) {
|
|
229
|
+
await callback({
|
|
230
|
+
text: `Alarm ${cancelled.id} cancelled.`,
|
|
231
|
+
source: message.content.source,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
success: true,
|
|
236
|
+
data: { actionName: "ALARM", subaction: "cancel", id: cancelled.id },
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
if (err instanceof MacosAlarmHelperUnavailableError) {
|
|
241
|
+
logger.warn(`[ALARM/cancel] helper unavailable: ${err.reason}`);
|
|
242
|
+
return {
|
|
243
|
+
success: false,
|
|
244
|
+
error: err.reason,
|
|
245
|
+
data: { actionName: "ALARM", subaction: "cancel" },
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const failureMessage = err instanceof Error ? err.message : "Unknown macOS alarm failure.";
|
|
249
|
+
logger.error(`[ALARM/cancel] helper failed: ${failureMessage}`);
|
|
250
|
+
return {
|
|
251
|
+
success: false,
|
|
252
|
+
text: `Could not cancel alarm: ${failureMessage}`,
|
|
253
|
+
error: failureMessage,
|
|
254
|
+
data: { actionName: "ALARM", subaction: "cancel" },
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function runList(message, deps, callback) {
|
|
259
|
+
try {
|
|
260
|
+
const response = await runHelper({ action: "list" }, deps.helperOptions);
|
|
261
|
+
if (!response.success) {
|
|
262
|
+
return {
|
|
263
|
+
success: false,
|
|
264
|
+
error: response.error,
|
|
265
|
+
data: { actionName: "ALARM", subaction: "list" },
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const list = response;
|
|
269
|
+
logger.info(`[ALARM/list] pending count=${list.alarms.length}`);
|
|
270
|
+
if (callback) {
|
|
271
|
+
const summary = list.alarms.length === 0
|
|
272
|
+
? "No macOS alarms are pending."
|
|
273
|
+
: `Pending macOS alarms: ${list.alarms
|
|
274
|
+
.map((a) => `${a.id} @ ${a.fireAt ?? "unknown"}`)
|
|
275
|
+
.join(", ")}`;
|
|
276
|
+
await callback({ text: summary, source: message.content.source });
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
success: true,
|
|
280
|
+
data: {
|
|
281
|
+
actionName: "ALARM",
|
|
282
|
+
subaction: "list",
|
|
283
|
+
alarms: list.alarms,
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
catch (err) {
|
|
288
|
+
if (err instanceof MacosAlarmHelperUnavailableError) {
|
|
289
|
+
logger.warn(`[ALARM/list] helper unavailable: ${err.reason}`);
|
|
290
|
+
return {
|
|
291
|
+
success: false,
|
|
292
|
+
error: err.reason,
|
|
293
|
+
data: { actionName: "ALARM", subaction: "list" },
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
const failureMessage = err instanceof Error ? err.message : "Unknown macOS alarm failure.";
|
|
297
|
+
logger.error(`[ALARM/list] helper failed: ${failureMessage}`);
|
|
298
|
+
return {
|
|
299
|
+
success: false,
|
|
300
|
+
text: `Could not list alarms: ${failureMessage}`,
|
|
301
|
+
error: failureMessage,
|
|
302
|
+
data: { actionName: "ALARM", subaction: "list" },
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
export function createAlarmAction(deps = {}) {
|
|
307
|
+
return {
|
|
308
|
+
name: "ALARM",
|
|
309
|
+
description: "Manage native macOS alarms via UNUserNotificationCenter. Subactions: set (schedule a new alarm), cancel (remove a scheduled alarm by id), list (show pending alarms). Subaction inferred from message text when not explicitly provided.",
|
|
310
|
+
descriptionCompressed: "macOS alarm: set / cancel / list (UNUserNotificationCenter).",
|
|
311
|
+
contexts: [...ALARM_CONTEXTS],
|
|
312
|
+
contextGate: { anyOf: [...ALARM_CONTEXTS] },
|
|
313
|
+
roleGate: { minRole: "ADMIN" },
|
|
314
|
+
similes: [
|
|
315
|
+
"SET_ALARM_MACOS",
|
|
316
|
+
"CANCEL_ALARM_MACOS",
|
|
317
|
+
"LIST_ALARMS_MACOS",
|
|
318
|
+
"schedule macos alarm",
|
|
319
|
+
"create mac alarm",
|
|
320
|
+
"set a mac alarm",
|
|
321
|
+
"wake me up on mac",
|
|
322
|
+
"cancel macos alarm",
|
|
323
|
+
"remove mac alarm",
|
|
324
|
+
"list macos alarms",
|
|
325
|
+
"show pending alarms",
|
|
326
|
+
],
|
|
327
|
+
parameters: [
|
|
328
|
+
{
|
|
329
|
+
name: "subaction",
|
|
330
|
+
description: "Operation to perform: set, cancel, or list. Inferred from message text when omitted.",
|
|
331
|
+
required: false,
|
|
332
|
+
schema: { type: "string", enum: [...ALARM_SUBACTIONS] },
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "timeIso",
|
|
336
|
+
description: "For subaction=set: ISO-8601 timestamp when the alarm should fire.",
|
|
337
|
+
required: false,
|
|
338
|
+
schema: { type: "string" },
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "title",
|
|
342
|
+
description: "For subaction=set: short title displayed in the notification.",
|
|
343
|
+
required: false,
|
|
344
|
+
schema: { type: "string" },
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "body",
|
|
348
|
+
description: "For subaction=set: optional longer body text for the notification.",
|
|
349
|
+
required: false,
|
|
350
|
+
schema: { type: "string" },
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "sound",
|
|
354
|
+
description: "For subaction=set: optional notification sound name.",
|
|
355
|
+
required: false,
|
|
356
|
+
schema: { type: "string" },
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "id",
|
|
360
|
+
description: "For subaction=set: optional explicit alarm id; for subaction=cancel: required alarm id returned from a previous set operation.",
|
|
361
|
+
required: false,
|
|
362
|
+
schema: { type: "string" },
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
validate: async (_runtime, message, state) => {
|
|
366
|
+
if (!isDarwin())
|
|
367
|
+
return false;
|
|
368
|
+
return hasAlarmSignal(message, state);
|
|
369
|
+
},
|
|
370
|
+
handler: async (_runtime, message, _state, options, callback) => {
|
|
371
|
+
if (!isDarwin()) {
|
|
372
|
+
logger.info("[ALARM] skipping on non-darwin platform; returning macos-only");
|
|
373
|
+
if (callback) {
|
|
374
|
+
await callback({
|
|
375
|
+
text: "I can only set native alarms on macOS.",
|
|
376
|
+
source: message.content.source,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return NOT_SUPPORTED;
|
|
380
|
+
}
|
|
381
|
+
const params = readParameters(options);
|
|
382
|
+
const explicit = normalizeSubactionValue(params.subaction) ??
|
|
383
|
+
normalizeSubactionValue(params.op);
|
|
384
|
+
const subaction = explicit ?? inferSubactionFromText(getText(message));
|
|
385
|
+
if (!subaction) {
|
|
386
|
+
const text = `ALARM could not determine the subaction. Specify one of: ${ALARM_SUBACTIONS.join(", ")}.`;
|
|
387
|
+
if (callback) {
|
|
388
|
+
await callback({ text, source: message.content.source });
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
success: false,
|
|
392
|
+
text,
|
|
393
|
+
values: { error: "MISSING_SUBACTION" },
|
|
394
|
+
data: {
|
|
395
|
+
actionName: "ALARM",
|
|
396
|
+
availableSubactions: [...ALARM_SUBACTIONS],
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
switch (subaction) {
|
|
401
|
+
case "set":
|
|
402
|
+
return runSet(message, params, deps, callback);
|
|
403
|
+
case "cancel":
|
|
404
|
+
return runCancel(message, params, deps, callback);
|
|
405
|
+
case "list":
|
|
406
|
+
return runList(message, deps, callback);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
examples: [
|
|
410
|
+
[
|
|
411
|
+
{ name: "{{user}}", content: { text: "set an alarm for 7am tomorrow" } },
|
|
412
|
+
{
|
|
413
|
+
name: "{{agent}}",
|
|
414
|
+
content: {
|
|
415
|
+
actions: ["ALARM"],
|
|
416
|
+
text: "Alarm set for 2026-05-08T07:00:00-07:00: \"Wake up\".",
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
{ name: "{{user}}", content: { text: "cancel alarm alarm-1234" } },
|
|
422
|
+
{
|
|
423
|
+
name: "{{agent}}",
|
|
424
|
+
content: {
|
|
425
|
+
actions: ["ALARM"],
|
|
426
|
+
text: "Alarm alarm-1234 cancelled.",
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
[
|
|
431
|
+
{ name: "{{user}}", content: { text: "list pending alarms" } },
|
|
432
|
+
{
|
|
433
|
+
name: "{{agent}}",
|
|
434
|
+
content: {
|
|
435
|
+
actions: ["ALARM"],
|
|
436
|
+
text: "Pending macOS alarms: alarm-1234 @ 2026-05-08T07:00:00-07:00",
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
],
|
|
440
|
+
],
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAML,MAAM,GAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,gCAAgC,EAChC,SAAS,GACV,MAAM,UAAU,CAAC;AAalB,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAG5D,MAAM,aAAa,GAAiB;IAClC,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,wCAAwC;IAC9C,KAAK,EAAE,YAAY;CACpB,CAAC;AACF,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAU,CAAC;AACpE,MAAM,WAAW,GAAG;IAClB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,aAAa;IACb,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,gBAAgB;IAChB,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,UAAU;IACV,UAAU;CACX,CAAC;AAEF,SAAS,QAAQ;IACf,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,SAAS,OAAO,CAAC,OAA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AC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACpD,KAAK,MAAM;oBACT,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QACD,QAAQ,EAAE;YACR;gBACE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,+BAA+B,EAAE,EAAE;gBACxE;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP,OAAO,EAAE,CAAC,OAAO,CAAC;wBAClB,IAAI,EAAE,uDAAuD;qBAC9D;iBACF;aACF;YACD;gBACE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE;gBAClE;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP,OAAO,EAAE,CAAC,OAAO,CAAC;wBAClB,IAAI,EAAE,6BAA6B;qBACpC;iBACF;aACF;YACD;gBACE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE;gBAC9D;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP,OAAO,EAAE,CAAC,OAAO,CAAC;wBAClB,IAAI,EAAE,8DAA8D;qBACrE;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/helper.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
import type { MacosAlarmHelperRequest, MacosAlarmHelperResponse } from "./types";
|
|
3
|
+
export interface HelperSpawn {
|
|
4
|
+
(bin: string, args: string[]): ChildProcessWithoutNullStreams;
|
|
5
|
+
}
|
|
6
|
+
export interface HelperRunOptions {
|
|
7
|
+
spawnImpl?: HelperSpawn;
|
|
8
|
+
binPathOverride?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class MacosAlarmHelperUnavailableError extends Error {
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
constructor(reason: string);
|
|
14
|
+
}
|
|
15
|
+
export declare function runHelper(request: MacosAlarmHelperRequest, options?: HelperRunOptions): Promise<MacosAlarmHelperResponse>;
|
|
16
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAKhF,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAIjB,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,8BAA8B,CAAC;CAC/D;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD,qBAAa,gCAAiC,SAAQ,KAAK;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM;CAK3B;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,uBAAuB,EAChC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CA4EnC"}
|
package/dist/helper.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { logger } from "@elizaos/core";
|
|
6
|
+
const HELPER_ENV_OVERRIDE = "ELIZA_MACOSALARM_HELPER_BIN";
|
|
7
|
+
const defaultSpawnHelper = (bin, args) => spawn(bin, args);
|
|
8
|
+
function resolveHelperBin(override) {
|
|
9
|
+
if (override && override.length > 0)
|
|
10
|
+
return override;
|
|
11
|
+
const envOverride = process.env[HELPER_ENV_OVERRIDE];
|
|
12
|
+
if (envOverride && envOverride.length > 0)
|
|
13
|
+
return envOverride;
|
|
14
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
// Built binary lives at <package>/bin/macosalarm-helper; this file compiles
|
|
16
|
+
// to <package>/dist/helper.js, so one-level-up gets us to the package root.
|
|
17
|
+
const pkgRoot = resolve(here, "..");
|
|
18
|
+
return resolve(pkgRoot, "bin", "macosalarm-helper");
|
|
19
|
+
}
|
|
20
|
+
export class MacosAlarmHelperUnavailableError extends Error {
|
|
21
|
+
reason;
|
|
22
|
+
constructor(reason) {
|
|
23
|
+
super(`macosalarm helper unavailable: ${reason}`);
|
|
24
|
+
this.name = "MacosAlarmHelperUnavailableError";
|
|
25
|
+
this.reason = reason;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function runHelper(request, options = {}) {
|
|
29
|
+
if (process.platform !== "darwin" && !options.spawnImpl) {
|
|
30
|
+
logger.warn(`[MacosAlarmHelper] refusing to run helper on non-darwin platform=${process.platform}`);
|
|
31
|
+
throw new MacosAlarmHelperUnavailableError("macos-only");
|
|
32
|
+
}
|
|
33
|
+
const bin = resolveHelperBin(options.binPathOverride);
|
|
34
|
+
if (!options.spawnImpl && !existsSync(bin)) {
|
|
35
|
+
logger.warn(`[MacosAlarmHelper] helper binary missing at ${bin}; run the package build-helper script`);
|
|
36
|
+
throw new MacosAlarmHelperUnavailableError("helper-binary-missing");
|
|
37
|
+
}
|
|
38
|
+
const spawnImpl = options.spawnImpl ?? defaultSpawnHelper;
|
|
39
|
+
const proc = spawnImpl(bin, []);
|
|
40
|
+
const stdoutChunks = [];
|
|
41
|
+
const stderrChunks = [];
|
|
42
|
+
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
43
|
+
proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
44
|
+
const payload = `${JSON.stringify(request)}\n`;
|
|
45
|
+
proc.stdin.end(payload);
|
|
46
|
+
const exitCode = await new Promise((resolvePromise, rejectPromise) => {
|
|
47
|
+
let timer;
|
|
48
|
+
if (options.timeoutMs && options.timeoutMs > 0) {
|
|
49
|
+
timer = setTimeout(() => {
|
|
50
|
+
rejectPromise(new Error(`macosalarm helper timed out after ${options.timeoutMs}ms`));
|
|
51
|
+
}, options.timeoutMs);
|
|
52
|
+
}
|
|
53
|
+
proc.on("error", (err) => {
|
|
54
|
+
if (timer)
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
rejectPromise(err);
|
|
57
|
+
});
|
|
58
|
+
proc.on("close", (code) => {
|
|
59
|
+
if (timer)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
resolvePromise(code);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
const stdout = Buffer.concat(stdoutChunks).toString("utf8").trim();
|
|
65
|
+
const stderr = Buffer.concat(stderrChunks).toString("utf8").trim();
|
|
66
|
+
if (stderr.length > 0) {
|
|
67
|
+
logger.debug(`[MacosAlarmHelper] stderr: ${stderr}`);
|
|
68
|
+
}
|
|
69
|
+
if (stdout.length === 0) {
|
|
70
|
+
throw new Error(`macosalarm helper produced no stdout (exit=${exitCode}); stderr=${stderr}`);
|
|
71
|
+
}
|
|
72
|
+
const lastLine = stdout
|
|
73
|
+
.split("\n")
|
|
74
|
+
.filter((line) => line.length > 0)
|
|
75
|
+
.pop();
|
|
76
|
+
if (!lastLine) {
|
|
77
|
+
throw new Error(`macosalarm helper produced empty response (exit=${exitCode})`);
|
|
78
|
+
}
|
|
79
|
+
const parsed = JSON.parse(lastLine);
|
|
80
|
+
return parsed;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","source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;SACpB,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,GAAG,EAAE,CAAC;IACT,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,mDAAmD,QAAQ,GAAG,CAC/D,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA6B,CAAC;IAChE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin } from "@elizaos/core";
|
|
2
|
+
import { type MacosAlarmActionDeps } from "./actions";
|
|
3
|
+
export declare function createMacosAlarmPlugin(deps?: MacosAlarmActionDeps): Plugin;
|
|
4
|
+
export declare const macosAlarmPlugin: Plugin;
|
|
5
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,WAAW,CAAC;AAEzE,wBAAgB,sBAAsB,CACpC,IAAI,GAAE,oBAAyB,GAC9B,MAAM,CAOR;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAiC,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAlarmAction } from "./actions";
|
|
2
|
+
export function createMacosAlarmPlugin(deps = {}) {
|
|
3
|
+
return {
|
|
4
|
+
name: "macosalarm",
|
|
5
|
+
description: "macOS native alarm scheduling via UNUserNotificationCenter. Auto-enabled on darwin only.",
|
|
6
|
+
actions: [createAlarmAction(deps)],
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export const macosAlarmPlugin = createMacosAlarmPlugin();
|
|
10
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEzE,MAAM,UAAU,sBAAsB,CACpC,OAA6B,EAAE;IAE/B,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,0FAA0F;QAC5F,OAAO,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;KACnC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAW,sBAAsB,EAAE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type MacosAlarmAction = "schedule" | "cancel" | "list" | "permission";
|
|
2
|
+
export interface MacosAlarmHelperRequest {
|
|
3
|
+
action: MacosAlarmAction;
|
|
4
|
+
id?: string;
|
|
5
|
+
timeIso?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
body?: string;
|
|
8
|
+
sound?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface MacosAlarmHelperScheduleResponse {
|
|
11
|
+
success: true;
|
|
12
|
+
id: string;
|
|
13
|
+
fireAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MacosAlarmHelperCancelResponse {
|
|
16
|
+
success: true;
|
|
17
|
+
id: string;
|
|
18
|
+
cancelled: true;
|
|
19
|
+
}
|
|
20
|
+
export interface MacosAlarmPendingEntry {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
body: string;
|
|
24
|
+
fireAt?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MacosAlarmHelperListResponse {
|
|
27
|
+
success: true;
|
|
28
|
+
alarms: MacosAlarmPendingEntry[];
|
|
29
|
+
}
|
|
30
|
+
export type MacosAlarmPermissionStatus = "authorized" | "provisional" | "denied" | "not-determined" | "ephemeral" | "unknown";
|
|
31
|
+
export interface MacosAlarmHelperPermissionResponse {
|
|
32
|
+
success: true;
|
|
33
|
+
status: MacosAlarmPermissionStatus;
|
|
34
|
+
}
|
|
35
|
+
export interface MacosAlarmHelperErrorResponse {
|
|
36
|
+
success: false;
|
|
37
|
+
error: string;
|
|
38
|
+
}
|
|
39
|
+
export type MacosAlarmHelperResponse = MacosAlarmHelperScheduleResponse | MacosAlarmHelperCancelResponse | MacosAlarmHelperListResponse | MacosAlarmHelperPermissionResponse | MacosAlarmHelperErrorResponse;
|
|
40
|
+
export interface MacosAlarmActionResult<T> {
|
|
41
|
+
success: boolean;
|
|
42
|
+
reason?: string;
|
|
43
|
+
data?: T;
|
|
44
|
+
}
|
|
45
|
+
export interface ScheduleAlarmParams {
|
|
46
|
+
timeIso: string;
|
|
47
|
+
title: string;
|
|
48
|
+
body?: string;
|
|
49
|
+
id?: string;
|
|
50
|
+
sound?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface CancelAlarmParams {
|
|
53
|
+
id: string;
|
|
54
|
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M,CAAC;CACf;AAED,MAAM,MAAM,wBAAwB,GAChC,gCAAgC,GAChC,8BAA8B,GAC9B,4BAA4B,GAC5B,kCAAkC,GAClC,6BAA6B,CAAC;AAElC,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elizaos/macosalarm",
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
|
+
"description": "macOS native alarm helper plugin. Schedules UNUserNotificationCenter calendar-trigger alarms via a self-contained Swift CLI invoked from the Eliza runtime.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"swift-helper/",
|
|
21
|
+
"scripts/",
|
|
22
|
+
"bin/",
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=24.0.0"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/elizaOS/eliza",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/elizaOS/eliza.git",
|
|
32
|
+
"directory": "packages/native-plugins/macosalarm"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"elizaos",
|
|
36
|
+
"macos",
|
|
37
|
+
"alarm",
|
|
38
|
+
"notifications",
|
|
39
|
+
"swift"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"prepublishOnly": "bun run build",
|
|
43
|
+
"build": "tsc -p tsconfig.json && node scripts/build-helper.mjs",
|
|
44
|
+
"build:ts": "tsc --noCheck -p tsconfig.json",
|
|
45
|
+
"build:helper": "node scripts/build-helper.mjs",
|
|
46
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"clean": "rm -rf dist bin"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@elizaos/core": "2.0.0-beta.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^24.0.0",
|
|
55
|
+
"typescript": "^6.0.3",
|
|
56
|
+
"vitest": "^4.0.0"
|
|
57
|
+
},
|
|
58
|
+
"author": "elizaOS",
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"eliza": {
|
|
61
|
+
"platforms": [
|
|
62
|
+
"darwin"
|
|
63
|
+
],
|
|
64
|
+
"runtime": "node",
|
|
65
|
+
"autoEnable": "darwin",
|
|
66
|
+
"platformDetails": {
|
|
67
|
+
"darwin": "Swift CLI helper using UNUserNotificationCenter. Non-darwin platforms receive macos-only failures."
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Builds the macOS alarm helper binary via `swiftc`.
|
|
3
|
+
//
|
|
4
|
+
// Outputs the binary to `bin/macosalarm-helper` inside this package so the
|
|
5
|
+
// TS runtime can locate it deterministically. Skips on non-darwin platforms.
|
|
6
|
+
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { dirname, resolve } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
|
|
12
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const pkgRoot = resolve(here, "..");
|
|
14
|
+
const source = resolve(pkgRoot, "swift-helper", "main.swift");
|
|
15
|
+
const outDir = resolve(pkgRoot, "bin");
|
|
16
|
+
const outBin = resolve(outDir, "macosalarm-helper");
|
|
17
|
+
const verbosePluginBuild =
|
|
18
|
+
process.env.ELIZA_VERBOSE_PLUGIN_BUILD === "1" ||
|
|
19
|
+
process.env.ELIZA_VERBOSE_PLUGIN_BUILD === "1";
|
|
20
|
+
|
|
21
|
+
if (process.platform !== "darwin") {
|
|
22
|
+
console.warn(
|
|
23
|
+
`[macosalarm] skipping swift helper build on ${process.platform}`,
|
|
24
|
+
);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!existsSync(source)) {
|
|
29
|
+
throw new Error(`macosalarm swift source missing: ${source}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
mkdirSync(outDir, { recursive: true });
|
|
33
|
+
|
|
34
|
+
const result = spawnSync("swiftc", [source, "-O", "-o", outBin], {
|
|
35
|
+
stdio: "inherit",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (result.status !== 0) {
|
|
39
|
+
throw new Error(`swiftc failed with status ${result.status ?? "unknown"}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (verbosePluginBuild) {
|
|
43
|
+
console.log(`[macosalarm] built ${outBin}`);
|
|
44
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UserNotifications
|
|
3
|
+
|
|
4
|
+
// macOS native alarm helper.
|
|
5
|
+
//
|
|
6
|
+
// Reads one JSON request from stdin and writes exactly one JSON response to
|
|
7
|
+
// stdout before exiting. All diagnostic messages go to stderr so the parent
|
|
8
|
+
// process can cleanly parse stdout as JSON.
|
|
9
|
+
//
|
|
10
|
+
// Request shape:
|
|
11
|
+
// { "action": "schedule" | "cancel" | "list" | "permission",
|
|
12
|
+
// "id": "...", // required for schedule/cancel
|
|
13
|
+
// "timeIso": "...", // required for schedule (ISO-8601)
|
|
14
|
+
// "title": "...", // required for schedule
|
|
15
|
+
// "body": "...", // optional for schedule
|
|
16
|
+
// "sound": "..." } // optional for schedule ("default" or named)
|
|
17
|
+
//
|
|
18
|
+
// Response shape:
|
|
19
|
+
// { "success": true, ... fields per action ... }
|
|
20
|
+
// { "success": false, "error": "reason" }
|
|
21
|
+
|
|
22
|
+
struct Request: Decodable {
|
|
23
|
+
let action: String
|
|
24
|
+
let id: String?
|
|
25
|
+
let timeIso: String?
|
|
26
|
+
let title: String?
|
|
27
|
+
let body: String?
|
|
28
|
+
let sound: String?
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enum HelperError: Error {
|
|
32
|
+
case invalidRequest(String)
|
|
33
|
+
case permissionDenied(String)
|
|
34
|
+
case scheduleFailed(String)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func writeJSON(_ value: [String: Any]) {
|
|
38
|
+
let data = try! JSONSerialization.data(withJSONObject: value, options: [.sortedKeys])
|
|
39
|
+
FileHandle.standardOutput.write(data)
|
|
40
|
+
FileHandle.standardOutput.write("\n".data(using: .utf8)!)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func writeError(_ message: String) {
|
|
44
|
+
writeJSON(["success": false, "error": message])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func log(_ message: String) {
|
|
48
|
+
FileHandle.standardError.write("[macosalarm-helper] \(message)\n".data(using: .utf8)!)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func readRequest() throws -> Request {
|
|
52
|
+
let data = FileHandle.standardInput.readDataToEndOfFile()
|
|
53
|
+
guard !data.isEmpty else {
|
|
54
|
+
throw HelperError.invalidRequest("empty stdin")
|
|
55
|
+
}
|
|
56
|
+
let decoder = JSONDecoder()
|
|
57
|
+
do {
|
|
58
|
+
return try decoder.decode(Request.self, from: data)
|
|
59
|
+
} catch {
|
|
60
|
+
throw HelperError.invalidRequest("could not decode request json: \(error.localizedDescription)")
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// UNUserNotificationCenter APIs are mostly async with completion handlers.
|
|
65
|
+
// We drive them synchronously from a CLI using DispatchSemaphore.
|
|
66
|
+
|
|
67
|
+
func ensureAuthorization() throws {
|
|
68
|
+
let center = UNUserNotificationCenter.current()
|
|
69
|
+
let sem = DispatchSemaphore(value: 0)
|
|
70
|
+
var authorized = false
|
|
71
|
+
var errorMessage: String?
|
|
72
|
+
|
|
73
|
+
center.getNotificationSettings { settings in
|
|
74
|
+
switch settings.authorizationStatus {
|
|
75
|
+
case .authorized, .provisional:
|
|
76
|
+
authorized = true
|
|
77
|
+
sem.signal()
|
|
78
|
+
case .notDetermined:
|
|
79
|
+
center.requestAuthorization(options: [.alert, .sound]) { granted, err in
|
|
80
|
+
authorized = granted
|
|
81
|
+
if let err = err {
|
|
82
|
+
errorMessage = err.localizedDescription
|
|
83
|
+
}
|
|
84
|
+
sem.signal()
|
|
85
|
+
}
|
|
86
|
+
case .denied:
|
|
87
|
+
errorMessage = "notification permission denied by user"
|
|
88
|
+
sem.signal()
|
|
89
|
+
@unknown default:
|
|
90
|
+
errorMessage = "unknown notification authorization status"
|
|
91
|
+
sem.signal()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
sem.wait()
|
|
96
|
+
|
|
97
|
+
if !authorized {
|
|
98
|
+
throw HelperError.permissionDenied(errorMessage ?? "notification permission not granted")
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
func schedule(_ req: Request) throws -> [String: Any] {
|
|
103
|
+
guard let id = req.id, !id.isEmpty else {
|
|
104
|
+
throw HelperError.invalidRequest("id is required")
|
|
105
|
+
}
|
|
106
|
+
guard let title = req.title, !title.isEmpty else {
|
|
107
|
+
throw HelperError.invalidRequest("title is required")
|
|
108
|
+
}
|
|
109
|
+
guard let timeIso = req.timeIso else {
|
|
110
|
+
throw HelperError.invalidRequest("timeIso is required")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let iso = ISO8601DateFormatter()
|
|
114
|
+
iso.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
|
115
|
+
var when = iso.date(from: timeIso)
|
|
116
|
+
if when == nil {
|
|
117
|
+
iso.formatOptions = [.withInternetDateTime]
|
|
118
|
+
when = iso.date(from: timeIso)
|
|
119
|
+
}
|
|
120
|
+
guard let fireDate = when else {
|
|
121
|
+
throw HelperError.invalidRequest("timeIso is not a valid ISO-8601 timestamp")
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try ensureAuthorization()
|
|
125
|
+
|
|
126
|
+
let content = UNMutableNotificationContent()
|
|
127
|
+
content.title = title
|
|
128
|
+
if let body = req.body {
|
|
129
|
+
content.body = body
|
|
130
|
+
}
|
|
131
|
+
let soundName = req.sound ?? "default"
|
|
132
|
+
if soundName == "default" {
|
|
133
|
+
content.sound = .defaultCritical
|
|
134
|
+
} else {
|
|
135
|
+
content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: soundName))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let comps = Calendar.current.dateComponents(
|
|
139
|
+
[.year, .month, .day, .hour, .minute, .second],
|
|
140
|
+
from: fireDate
|
|
141
|
+
)
|
|
142
|
+
let trigger = UNCalendarNotificationTrigger(dateMatching: comps, repeats: false)
|
|
143
|
+
let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger)
|
|
144
|
+
|
|
145
|
+
let center = UNUserNotificationCenter.current()
|
|
146
|
+
let sem = DispatchSemaphore(value: 0)
|
|
147
|
+
var addError: String?
|
|
148
|
+
center.add(request) { err in
|
|
149
|
+
if let err = err {
|
|
150
|
+
addError = err.localizedDescription
|
|
151
|
+
}
|
|
152
|
+
sem.signal()
|
|
153
|
+
}
|
|
154
|
+
sem.wait()
|
|
155
|
+
|
|
156
|
+
if let err = addError {
|
|
157
|
+
throw HelperError.scheduleFailed(err)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return [
|
|
161
|
+
"success": true,
|
|
162
|
+
"id": id,
|
|
163
|
+
"fireAt": ISO8601DateFormatter().string(from: fireDate),
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func cancel(_ req: Request) throws -> [String: Any] {
|
|
168
|
+
guard let id = req.id, !id.isEmpty else {
|
|
169
|
+
throw HelperError.invalidRequest("id is required")
|
|
170
|
+
}
|
|
171
|
+
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [id])
|
|
172
|
+
return ["success": true, "id": id, "cancelled": true]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
func list() -> [String: Any] {
|
|
176
|
+
let center = UNUserNotificationCenter.current()
|
|
177
|
+
let sem = DispatchSemaphore(value: 0)
|
|
178
|
+
var items: [[String: Any]] = []
|
|
179
|
+
center.getPendingNotificationRequests { requests in
|
|
180
|
+
for req in requests {
|
|
181
|
+
var entry: [String: Any] = [
|
|
182
|
+
"id": req.identifier,
|
|
183
|
+
"title": req.content.title,
|
|
184
|
+
"body": req.content.body,
|
|
185
|
+
]
|
|
186
|
+
if let cal = req.trigger as? UNCalendarNotificationTrigger,
|
|
187
|
+
let next = cal.nextTriggerDate() {
|
|
188
|
+
entry["fireAt"] = ISO8601DateFormatter().string(from: next)
|
|
189
|
+
}
|
|
190
|
+
items.append(entry)
|
|
191
|
+
}
|
|
192
|
+
sem.signal()
|
|
193
|
+
}
|
|
194
|
+
sem.wait()
|
|
195
|
+
return ["success": true, "alarms": items]
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
func permission() -> [String: Any] {
|
|
199
|
+
let center = UNUserNotificationCenter.current()
|
|
200
|
+
let sem = DispatchSemaphore(value: 0)
|
|
201
|
+
var status = "unknown"
|
|
202
|
+
center.getNotificationSettings { settings in
|
|
203
|
+
switch settings.authorizationStatus {
|
|
204
|
+
case .authorized: status = "authorized"
|
|
205
|
+
case .provisional: status = "provisional"
|
|
206
|
+
case .denied: status = "denied"
|
|
207
|
+
case .notDetermined: status = "not-determined"
|
|
208
|
+
case .ephemeral: status = "ephemeral"
|
|
209
|
+
@unknown default: status = "unknown"
|
|
210
|
+
}
|
|
211
|
+
sem.signal()
|
|
212
|
+
}
|
|
213
|
+
sem.wait()
|
|
214
|
+
return ["success": true, "status": status]
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
do {
|
|
218
|
+
let req = try readRequest()
|
|
219
|
+
switch req.action {
|
|
220
|
+
case "schedule":
|
|
221
|
+
writeJSON(try schedule(req))
|
|
222
|
+
case "cancel":
|
|
223
|
+
writeJSON(try cancel(req))
|
|
224
|
+
case "list":
|
|
225
|
+
writeJSON(list())
|
|
226
|
+
case "permission":
|
|
227
|
+
writeJSON(permission())
|
|
228
|
+
default:
|
|
229
|
+
writeError("unknown action: \(req.action)")
|
|
230
|
+
exit(2)
|
|
231
|
+
}
|
|
232
|
+
} catch HelperError.invalidRequest(let msg) {
|
|
233
|
+
log("invalid request: \(msg)")
|
|
234
|
+
writeError("invalid-request: \(msg)")
|
|
235
|
+
exit(2)
|
|
236
|
+
} catch HelperError.permissionDenied(let msg) {
|
|
237
|
+
log("permission denied: \(msg)")
|
|
238
|
+
writeError("permission-denied: \(msg)")
|
|
239
|
+
exit(3)
|
|
240
|
+
} catch HelperError.scheduleFailed(let msg) {
|
|
241
|
+
log("schedule failed: \(msg)")
|
|
242
|
+
writeError("schedule-failed: \(msg)")
|
|
243
|
+
exit(4)
|
|
244
|
+
} catch {
|
|
245
|
+
log("unexpected error: \(error.localizedDescription)")
|
|
246
|
+
writeError("unexpected: \(error.localizedDescription)")
|
|
247
|
+
exit(1)
|
|
248
|
+
}
|