@framers/agentos-ext-notifications 0.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.
- package/LICENSE +98 -0
- package/dist/NotificationService.d.ts +84 -0
- package/dist/NotificationService.d.ts.map +1 -0
- package/dist/NotificationService.js +137 -0
- package/dist/NotificationService.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/broadcast.d.ts +43 -0
- package/dist/tools/broadcast.d.ts.map +1 -0
- package/dist/tools/broadcast.js +41 -0
- package/dist/tools/broadcast.js.map +1 -0
- package/dist/tools/schedule.d.ts +49 -0
- package/dist/tools/schedule.d.ts.map +1 -0
- package/dist/tools/schedule.js +75 -0
- package/dist/tools/schedule.js.map +1 -0
- package/dist/tools/send.d.ts +40 -0
- package/dist/tools/send.d.ts.map +1 -0
- package/dist/tools/send.js +41 -0
- package/dist/tools/send.js.map +1 -0
- package/manifest.json +24 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License.
|
|
30
|
+
|
|
31
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License.
|
|
34
|
+
|
|
35
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
36
|
+
|
|
37
|
+
4. Redistribution.
|
|
38
|
+
|
|
39
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
40
|
+
|
|
41
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
42
|
+
|
|
43
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
44
|
+
|
|
45
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
46
|
+
|
|
47
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
48
|
+
|
|
49
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
50
|
+
|
|
51
|
+
5. Submission of Contributions.
|
|
52
|
+
|
|
53
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
54
|
+
|
|
55
|
+
6. Trademarks.
|
|
56
|
+
|
|
57
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
58
|
+
|
|
59
|
+
7. Disclaimer of Warranty.
|
|
60
|
+
|
|
61
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
62
|
+
|
|
63
|
+
8. Limitation of Liability.
|
|
64
|
+
|
|
65
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
66
|
+
|
|
67
|
+
9. Accepting Warranty or Additional Liability.
|
|
68
|
+
|
|
69
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
70
|
+
|
|
71
|
+
END OF TERMS AND CONDITIONS
|
|
72
|
+
|
|
73
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
74
|
+
|
|
75
|
+
To apply the Apache License to your work, attach the following
|
|
76
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
77
|
+
replaced with your own identifying information. (Don't include
|
|
78
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
79
|
+
comment syntax for the file format. We also recommend that a
|
|
80
|
+
file or class name and description of purpose be included on the
|
|
81
|
+
same "printed page" as the copyright notice for easier
|
|
82
|
+
identification within third-party archives.
|
|
83
|
+
|
|
84
|
+
Copyright (c) 2025 Framers
|
|
85
|
+
|
|
86
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
87
|
+
you may not use this file except in compliance with the License.
|
|
88
|
+
You may obtain a copy of the License at
|
|
89
|
+
|
|
90
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
91
|
+
|
|
92
|
+
Unless required by applicable law or agreed to in writing, software
|
|
93
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
94
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
95
|
+
See the License for the specific language governing permissions and
|
|
96
|
+
limitations under the License.
|
|
97
|
+
|
|
98
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Unified multi-channel notification service.
|
|
3
|
+
*
|
|
4
|
+
* Manages a registry of notification channels, routes messages to the
|
|
5
|
+
* best-priority channel, supports broadcasting to all channels, and
|
|
6
|
+
* provides in-memory scheduled notification delivery.
|
|
7
|
+
*/
|
|
8
|
+
export interface NotificationChannel {
|
|
9
|
+
/** Unique channel identifier (e.g. "email", "slack", "telegram"). */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Human-readable channel name. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Higher priority channels are preferred when no explicit channel is specified. */
|
|
14
|
+
priority: number;
|
|
15
|
+
/** Sends a notification through this channel. */
|
|
16
|
+
sendFn: (message: string, opts?: {
|
|
17
|
+
subject?: string;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export interface SendOptions {
|
|
22
|
+
/** Target channel id. If omitted, the highest-priority channel is used. */
|
|
23
|
+
channel?: string;
|
|
24
|
+
/** Notification body text. */
|
|
25
|
+
message: string;
|
|
26
|
+
/** Optional subject / title. */
|
|
27
|
+
subject?: string;
|
|
28
|
+
/** Arbitrary metadata forwarded to the channel sendFn. */
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface BroadcastOptions {
|
|
32
|
+
/** Notification body text. */
|
|
33
|
+
message: string;
|
|
34
|
+
/** Optional subject / title. */
|
|
35
|
+
subject?: string;
|
|
36
|
+
/** Subset of channel ids to target. If omitted, all registered channels are used. */
|
|
37
|
+
channels?: string[];
|
|
38
|
+
/** Arbitrary metadata forwarded to every channel sendFn. */
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
export interface ScheduleOptions {
|
|
42
|
+
/** Target channel id (optional — uses highest priority if omitted). */
|
|
43
|
+
channel?: string;
|
|
44
|
+
/** Notification body text. */
|
|
45
|
+
message: string;
|
|
46
|
+
/** Optional subject / title. */
|
|
47
|
+
subject?: string;
|
|
48
|
+
/** ISO 8601 timestamp for when to send the notification. */
|
|
49
|
+
sendAt: string;
|
|
50
|
+
/** Arbitrary metadata forwarded to the channel sendFn. */
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
export interface ScheduledNotification {
|
|
54
|
+
id: string;
|
|
55
|
+
channel?: string;
|
|
56
|
+
message: string;
|
|
57
|
+
subject?: string;
|
|
58
|
+
sendAt: string;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
export interface SendResult {
|
|
62
|
+
channelId: string;
|
|
63
|
+
channelName: string;
|
|
64
|
+
delivered: boolean;
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare class NotificationService {
|
|
68
|
+
private channels;
|
|
69
|
+
private scheduled;
|
|
70
|
+
private running;
|
|
71
|
+
initialize(): Promise<void>;
|
|
72
|
+
shutdown(): Promise<void>;
|
|
73
|
+
get isRunning(): boolean;
|
|
74
|
+
registerChannel(channel: NotificationChannel): void;
|
|
75
|
+
unregisterChannel(id: string): boolean;
|
|
76
|
+
listChannels(): NotificationChannel[];
|
|
77
|
+
send(opts: SendOptions): Promise<SendResult>;
|
|
78
|
+
broadcast(opts: BroadcastOptions): Promise<SendResult[]>;
|
|
79
|
+
schedule(opts: ScheduleOptions): ScheduledNotification;
|
|
80
|
+
cancelScheduled(scheduleId: string): boolean;
|
|
81
|
+
getScheduled(): ScheduledNotification[];
|
|
82
|
+
private getBestChannel;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=NotificationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../src/NotificationService.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAMH,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7G;AAED,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8B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,CAAC,SAAS,CAA0F;IAC3G,OAAO,CAAC,OAAO,CAAS;IAIlB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAID,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAInD,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAItC,YAAY,IAAI,mBAAmB,EAAE;IAM/B,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAuB5C,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAwB9D,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,qBAAqB;IAgCtD,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAQ5C,YAAY,IAAI,qBAAqB,EAAE;IAMvC,OAAO,CAAC,cAAc;CASvB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Unified multi-channel notification service.
|
|
5
|
+
*
|
|
6
|
+
* Manages a registry of notification channels, routes messages to the
|
|
7
|
+
* best-priority channel, supports broadcasting to all channels, and
|
|
8
|
+
* provides in-memory scheduled notification delivery.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.NotificationService = void 0;
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Service
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
class NotificationService {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.channels = new Map();
|
|
18
|
+
this.scheduled = new Map();
|
|
19
|
+
this.running = false;
|
|
20
|
+
}
|
|
21
|
+
// ── Lifecycle ──
|
|
22
|
+
async initialize() {
|
|
23
|
+
this.running = true;
|
|
24
|
+
}
|
|
25
|
+
async shutdown() {
|
|
26
|
+
// Cancel all pending scheduled notifications
|
|
27
|
+
for (const [, entry] of this.scheduled) {
|
|
28
|
+
clearTimeout(entry.timer);
|
|
29
|
+
}
|
|
30
|
+
this.scheduled.clear();
|
|
31
|
+
this.running = false;
|
|
32
|
+
}
|
|
33
|
+
get isRunning() {
|
|
34
|
+
return this.running;
|
|
35
|
+
}
|
|
36
|
+
// ── Channel Registry ──
|
|
37
|
+
registerChannel(channel) {
|
|
38
|
+
this.channels.set(channel.id, channel);
|
|
39
|
+
}
|
|
40
|
+
unregisterChannel(id) {
|
|
41
|
+
return this.channels.delete(id);
|
|
42
|
+
}
|
|
43
|
+
listChannels() {
|
|
44
|
+
return Array.from(this.channels.values()).sort((a, b) => b.priority - a.priority);
|
|
45
|
+
}
|
|
46
|
+
// ── Send ──
|
|
47
|
+
async send(opts) {
|
|
48
|
+
const channel = opts.channel
|
|
49
|
+
? this.channels.get(opts.channel)
|
|
50
|
+
: this.getBestChannel();
|
|
51
|
+
if (!channel) {
|
|
52
|
+
throw new Error(opts.channel
|
|
53
|
+
? `Notification channel "${opts.channel}" not found`
|
|
54
|
+
: 'No notification channels registered');
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await channel.sendFn(opts.message, { subject: opts.subject, metadata: opts.metadata });
|
|
58
|
+
return { channelId: channel.id, channelName: channel.name, delivered: true };
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
return { channelId: channel.id, channelName: channel.name, delivered: false, error: err.message };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// ── Broadcast ──
|
|
65
|
+
async broadcast(opts) {
|
|
66
|
+
const targets = opts.channels
|
|
67
|
+
? opts.channels.map(id => this.channels.get(id)).filter(Boolean)
|
|
68
|
+
: Array.from(this.channels.values());
|
|
69
|
+
if (targets.length === 0) {
|
|
70
|
+
throw new Error('No notification channels available for broadcast');
|
|
71
|
+
}
|
|
72
|
+
const results = [];
|
|
73
|
+
for (const channel of targets) {
|
|
74
|
+
try {
|
|
75
|
+
await channel.sendFn(opts.message, { subject: opts.subject, metadata: opts.metadata });
|
|
76
|
+
results.push({ channelId: channel.id, channelName: channel.name, delivered: true });
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
results.push({ channelId: channel.id, channelName: channel.name, delivered: false, error: err.message });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
// ── Schedule ──
|
|
85
|
+
schedule(opts) {
|
|
86
|
+
const id = `notif_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
87
|
+
const notification = {
|
|
88
|
+
id,
|
|
89
|
+
channel: opts.channel,
|
|
90
|
+
message: opts.message,
|
|
91
|
+
subject: opts.subject,
|
|
92
|
+
sendAt: opts.sendAt,
|
|
93
|
+
metadata: opts.metadata,
|
|
94
|
+
};
|
|
95
|
+
const delay = new Date(opts.sendAt).getTime() - Date.now();
|
|
96
|
+
const effectiveDelay = Math.max(delay, 0);
|
|
97
|
+
const timer = setTimeout(async () => {
|
|
98
|
+
try {
|
|
99
|
+
await this.send({
|
|
100
|
+
channel: opts.channel,
|
|
101
|
+
message: opts.message,
|
|
102
|
+
subject: opts.subject,
|
|
103
|
+
metadata: opts.metadata,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Scheduled notification delivery failed — logged silently
|
|
108
|
+
}
|
|
109
|
+
this.scheduled.delete(id);
|
|
110
|
+
}, effectiveDelay);
|
|
111
|
+
this.scheduled.set(id, { notification, timer });
|
|
112
|
+
return notification;
|
|
113
|
+
}
|
|
114
|
+
cancelScheduled(scheduleId) {
|
|
115
|
+
const entry = this.scheduled.get(scheduleId);
|
|
116
|
+
if (!entry)
|
|
117
|
+
return false;
|
|
118
|
+
clearTimeout(entry.timer);
|
|
119
|
+
this.scheduled.delete(scheduleId);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
getScheduled() {
|
|
123
|
+
return Array.from(this.scheduled.values()).map(e => e.notification);
|
|
124
|
+
}
|
|
125
|
+
// ── Internal ──
|
|
126
|
+
getBestChannel() {
|
|
127
|
+
let best;
|
|
128
|
+
for (const channel of this.channels.values()) {
|
|
129
|
+
if (!best || channel.priority > best.priority) {
|
|
130
|
+
best = channel;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return best;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.NotificationService = NotificationService;
|
|
137
|
+
//# sourceMappingURL=NotificationService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationService.js","sourceRoot":"","sources":["../src/NotificationService.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;;;;GAMG;;;AAoEH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,MAAa,mBAAmB;IAAhC;QACU,aAAQ,GAAqC,IAAI,GAAG,EAAE,CAAC;QACvD,cAAS,GAAgF,IAAI,GAAG,EAAE,CAAC;QACnG,YAAO,GAAG,KAAK,CAAC;IA2I1B,CAAC;IAzIC,kBAAkB;IAElB,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,6CAA6C;QAC7C,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,yBAAyB;IAEzB,eAAe,CAAC,OAA4B;QAC1C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO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AAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACtE,CAAC;IAED,iBAAiB;IAET,cAAc;QACpB,IAAI,IAAqC,CAAC;QAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC9C,IAAI,GAAG,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9ID,kDA8IC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Notifications Extension for AgentOS.
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified multi-channel notification router with 3 tools:
|
|
5
|
+
* send, broadcast, and schedule.
|
|
6
|
+
*
|
|
7
|
+
* @module @framers/agentos-ext-notifications
|
|
8
|
+
*/
|
|
9
|
+
export interface ExtensionContext {
|
|
10
|
+
options?: Record<string, unknown>;
|
|
11
|
+
secrets?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface ExtensionPack {
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
descriptors: Array<{
|
|
17
|
+
id: string;
|
|
18
|
+
kind: string;
|
|
19
|
+
priority?: number;
|
|
20
|
+
payload: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
onActivate?: () => Promise<void>;
|
|
23
|
+
onDeactivate?: () => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare function createExtensionPack(context: ExtensionContext): ExtensionPack;
|
|
26
|
+
export { NotificationService } from './NotificationService.js';
|
|
27
|
+
export type { NotificationChannel, SendOptions, BroadcastOptions, ScheduleOptions, ScheduledNotification, SendResult, } from './NotificationService.js';
|
|
28
|
+
export { NotifySendTool } from './tools/send.js';
|
|
29
|
+
export { NotifyBroadcastTool } from './tools/broadcast.js';
|
|
30
|
+
export { NotifyScheduleTool } from './tools/schedule.js';
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAWH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACtF,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAsB5E;AAMD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,UAAU,GACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Notifications Extension for AgentOS.
|
|
5
|
+
*
|
|
6
|
+
* Provides a unified multi-channel notification router with 3 tools:
|
|
7
|
+
* send, broadcast, and schedule.
|
|
8
|
+
*
|
|
9
|
+
* @module @framers/agentos-ext-notifications
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NotifyScheduleTool = exports.NotifyBroadcastTool = exports.NotifySendTool = exports.NotificationService = void 0;
|
|
13
|
+
exports.createExtensionPack = createExtensionPack;
|
|
14
|
+
const NotificationService_js_1 = require("./NotificationService.js");
|
|
15
|
+
const send_js_1 = require("./tools/send.js");
|
|
16
|
+
const broadcast_js_1 = require("./tools/broadcast.js");
|
|
17
|
+
const schedule_js_1 = require("./tools/schedule.js");
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Factory
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
function createExtensionPack(context) {
|
|
22
|
+
const service = new NotificationService_js_1.NotificationService();
|
|
23
|
+
const sendTool = new send_js_1.NotifySendTool(service);
|
|
24
|
+
const broadcastTool = new broadcast_js_1.NotifyBroadcastTool(service);
|
|
25
|
+
const scheduleTool = new schedule_js_1.NotifyScheduleTool(service);
|
|
26
|
+
return {
|
|
27
|
+
name: '@framers/agentos-ext-notifications',
|
|
28
|
+
version: '0.1.0',
|
|
29
|
+
descriptors: [
|
|
30
|
+
{ id: 'notifySend', kind: 'tool', priority: 50, payload: sendTool },
|
|
31
|
+
{ id: 'notifyBroadcast', kind: 'tool', priority: 50, payload: broadcastTool },
|
|
32
|
+
{ id: 'notifySchedule', kind: 'tool', priority: 50, payload: scheduleTool },
|
|
33
|
+
],
|
|
34
|
+
onActivate: async () => {
|
|
35
|
+
await service.initialize();
|
|
36
|
+
},
|
|
37
|
+
onDeactivate: async () => {
|
|
38
|
+
await service.shutdown();
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Public exports
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
var NotificationService_js_2 = require("./NotificationService.js");
|
|
46
|
+
Object.defineProperty(exports, "NotificationService", { enumerable: true, get: function () { return NotificationService_js_2.NotificationService; } });
|
|
47
|
+
var send_js_2 = require("./tools/send.js");
|
|
48
|
+
Object.defineProperty(exports, "NotifySendTool", { enumerable: true, get: function () { return send_js_2.NotifySendTool; } });
|
|
49
|
+
var broadcast_js_2 = require("./tools/broadcast.js");
|
|
50
|
+
Object.defineProperty(exports, "NotifyBroadcastTool", { enumerable: true, get: function () { return broadcast_js_2.NotifyBroadcastTool; } });
|
|
51
|
+
var schedule_js_2 = require("./tools/schedule.js");
|
|
52
|
+
Object.defineProperty(exports, "NotifyScheduleTool", { enumerable: true, get: function () { return schedule_js_2.NotifyScheduleTool; } });
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;;;;;GAOG;;;AA4BH,kDAsBC;AAhDD,qEAA+D;AAC/D,6CAAiD;AACjD,uDAA2D;AAC3D,qDAAyD;AAmBzD,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SA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
4
|
+
readonly id = "notifyBroadcast";
|
|
5
|
+
readonly name = "notifyBroadcast";
|
|
6
|
+
readonly displayName = "Broadcast Notification";
|
|
7
|
+
readonly description = "Broadcast a notification to all registered channels or a specified subset.";
|
|
8
|
+
readonly category = "communications";
|
|
9
|
+
readonly version = "0.1.0";
|
|
10
|
+
readonly hasSideEffects = true;
|
|
11
|
+
readonly inputSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: {
|
|
14
|
+
message: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
subject: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
channels: {
|
|
23
|
+
type: string;
|
|
24
|
+
items: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
metadata: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
};
|
|
36
|
+
constructor(service: NotificationService);
|
|
37
|
+
execute(args: Record<string, unknown>): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
data?: unknown;
|
|
40
|
+
error?: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/tools/broadcast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qBAAa,mBAAmB;IAoBlB,OAAO,CAAC,OAAO;IAnB3B,QAAQ,CAAC,EAAE,qBAAqB;IAChC,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,WAAW,4BAA4B;IAChD,QAAQ,CAAC,WAAW,gFAAgF;IACpG,QAAQ,CAAC,QAAQ,oBAAoB;IACrC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,cAAc,QAAQ;IAE/B,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;MASlB;gBAEkB,OAAO,EAAE,mBAAmB;IAE1C,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAa5G"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotifyBroadcastTool = void 0;
|
|
4
|
+
class NotifyBroadcastTool {
|
|
5
|
+
constructor(service) {
|
|
6
|
+
this.service = service;
|
|
7
|
+
this.id = 'notifyBroadcast';
|
|
8
|
+
this.name = 'notifyBroadcast';
|
|
9
|
+
this.displayName = 'Broadcast Notification';
|
|
10
|
+
this.description = 'Broadcast a notification to all registered channels or a specified subset.';
|
|
11
|
+
this.category = 'communications';
|
|
12
|
+
this.version = '0.1.0';
|
|
13
|
+
this.hasSideEffects = true;
|
|
14
|
+
this.inputSchema = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
message: { type: 'string', description: 'Notification body text.' },
|
|
18
|
+
subject: { type: 'string', description: 'Optional subject or title for the notification.' },
|
|
19
|
+
channels: { type: 'array', items: { type: 'string' }, description: 'Subset of channel ids to target. If omitted, all registered channels are used.' },
|
|
20
|
+
metadata: { type: 'object', description: 'Arbitrary metadata forwarded to every channel.' },
|
|
21
|
+
},
|
|
22
|
+
required: ['message'],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async execute(args) {
|
|
26
|
+
try {
|
|
27
|
+
const results = await this.service.broadcast({
|
|
28
|
+
message: args.message,
|
|
29
|
+
subject: args.subject,
|
|
30
|
+
channels: args.channels,
|
|
31
|
+
metadata: args.metadata,
|
|
32
|
+
});
|
|
33
|
+
return { success: true, data: results };
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return { success: false, error: err.message };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.NotifyBroadcastTool = NotifyBroadcastTool;
|
|
41
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/tools/broadcast.ts"],"names":[],"mappings":";;;AAGA,MAAa,mBAAmB;IAoB9B,YAAoB,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAnBvC,OAAE,GAAG,iBAAiB,CAAC;QACvB,SAAI,GAAG,iBAAiB,CAAC;QACzB,gBAAW,GAAG,wBAAwB,CAAC;QACvC,gBAAW,GAAG,4EAA4E,CAAC;QAC3F,aAAQ,GAAG,gBAAgB,CAAC;QAC5B,YAAO,GAAG,OAAO,CAAC;QAClB,mBAAc,GAAG,IAAI,CAAC;QAEtB,gBAAW,GAAG;YACrB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;gBACnE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;gBAC3F,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,gFAAgF,EAAE;gBACrJ,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gDAAgD,EAAE;aAC5F;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB,CAAC;IAEiD,CAAC;IAEpD,KAAK,CAAC,OAAO,CAAC,IAA6B;QACzC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;gBAC3C,OAAO,EAAE,IAAI,CAAC,OAAiB;gBAC/B,OAAO,EAAE,IAAI,CAAC,OAA6B;gBAC3C,QAAQ,EAAE,IAAI,CAAC,QAAgC;gBAC/C,QAAQ,EAAE,IAAI,CAAC,QAA+C;aAC/D,CAAC,CAAC;YACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAnCD,kDAmCC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { NotificationService } from '../NotificationService.js';
|
|
2
|
+
export declare class NotifyScheduleTool {
|
|
3
|
+
private service;
|
|
4
|
+
readonly id = "notifySchedule";
|
|
5
|
+
readonly name = "notifySchedule";
|
|
6
|
+
readonly displayName = "Schedule Notification";
|
|
7
|
+
readonly description = "Schedule, cancel, or list pending notifications. Use action \"schedule\" to create, \"cancel\" to remove, or \"list\" to view all pending.";
|
|
8
|
+
readonly category = "communications";
|
|
9
|
+
readonly version = "0.1.0";
|
|
10
|
+
readonly hasSideEffects = true;
|
|
11
|
+
readonly inputSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: {
|
|
14
|
+
action: {
|
|
15
|
+
type: string;
|
|
16
|
+
enum: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
channel: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
message: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
subject: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
sendAt: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
scheduleId: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
required: string[];
|
|
41
|
+
};
|
|
42
|
+
constructor(service: NotificationService);
|
|
43
|
+
execute(args: Record<string, unknown>): Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
data?: unknown;
|
|
46
|
+
error?: string;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=schedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../src/tools/schedule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qBAAa,kBAAkB;IA0BjB,OAAO,CAAC,OAAO;IAzB3B,QAAQ,CAAC,EAAE,oBAAoB;IAC/B,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,WAAW,2BAA2B;IAC/C,QAAQ,CAAC,WAAW,gJAA0I;IAC9J,QAAQ,CAAC,QAAQ,oBAAoB;IACrC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,cAAc,QAAQ;IAE/B,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAelB;gBAEkB,OAAO,EAAE,mBAAmB;IAE1C,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CA6C5G"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotifyScheduleTool = void 0;
|
|
4
|
+
class NotifyScheduleTool {
|
|
5
|
+
constructor(service) {
|
|
6
|
+
this.service = service;
|
|
7
|
+
this.id = 'notifySchedule';
|
|
8
|
+
this.name = 'notifySchedule';
|
|
9
|
+
this.displayName = 'Schedule Notification';
|
|
10
|
+
this.description = 'Schedule, cancel, or list pending notifications. Use action "schedule" to create, "cancel" to remove, or "list" to view all pending.';
|
|
11
|
+
this.category = 'communications';
|
|
12
|
+
this.version = '0.1.0';
|
|
13
|
+
this.hasSideEffects = true;
|
|
14
|
+
this.inputSchema = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
action: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
enum: ['schedule', 'cancel', 'list'],
|
|
20
|
+
description: 'Action to perform: "schedule" to create, "cancel" to remove, or "list" to view pending notifications.',
|
|
21
|
+
},
|
|
22
|
+
channel: { type: 'string', description: 'Target channel id (used with "schedule" action).' },
|
|
23
|
+
message: { type: 'string', description: 'Notification body text (required for "schedule" action).' },
|
|
24
|
+
subject: { type: 'string', description: 'Optional subject or title (used with "schedule" action).' },
|
|
25
|
+
sendAt: { type: 'string', description: 'ISO 8601 timestamp for when to send (required for "schedule" action).' },
|
|
26
|
+
scheduleId: { type: 'string', description: 'Schedule id to cancel (required for "cancel" action).' },
|
|
27
|
+
},
|
|
28
|
+
required: ['action'],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async execute(args) {
|
|
32
|
+
try {
|
|
33
|
+
const action = args.action;
|
|
34
|
+
switch (action) {
|
|
35
|
+
case 'schedule': {
|
|
36
|
+
if (!args.message) {
|
|
37
|
+
return { success: false, error: 'message is required for "schedule" action' };
|
|
38
|
+
}
|
|
39
|
+
if (!args.sendAt) {
|
|
40
|
+
return { success: false, error: 'sendAt is required for "schedule" action' };
|
|
41
|
+
}
|
|
42
|
+
const notification = this.service.schedule({
|
|
43
|
+
channel: args.channel,
|
|
44
|
+
message: args.message,
|
|
45
|
+
subject: args.subject,
|
|
46
|
+
sendAt: args.sendAt,
|
|
47
|
+
metadata: args.metadata,
|
|
48
|
+
});
|
|
49
|
+
return { success: true, data: notification };
|
|
50
|
+
}
|
|
51
|
+
case 'cancel': {
|
|
52
|
+
if (!args.scheduleId) {
|
|
53
|
+
return { success: false, error: 'scheduleId is required for "cancel" action' };
|
|
54
|
+
}
|
|
55
|
+
const cancelled = this.service.cancelScheduled(args.scheduleId);
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
data: { scheduleId: args.scheduleId, cancelled },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
case 'list': {
|
|
62
|
+
const pending = this.service.getScheduled();
|
|
63
|
+
return { success: true, data: { count: pending.length, notifications: pending } };
|
|
64
|
+
}
|
|
65
|
+
default:
|
|
66
|
+
return { success: false, error: `Unknown action "${action}". Use "schedule", "cancel", or "list".` };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return { success: false, error: err.message };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.NotifyScheduleTool = NotifyScheduleTool;
|
|
75
|
+
//# sourceMappingURL=schedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../src/tools/schedule.ts"],"names":[],"mappings":";;;AAGA,MAAa,kBAAkB;IA0B7B,YAAoB,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAzBvC,OAAE,GAAG,gBAAgB,CAAC;QACtB,SAAI,GAAG,gBAAgB,CAAC;QACxB,gBAAW,GAAG,uBAAuB,CAAC;QACtC,gBAAW,GAAG,sIAAsI,CAAC;QACrJ,aAAQ,GAAG,gBAAgB,CAAC;QAC5B,YAAO,GAAG,OAAO,CAAC;QAClB,mBAAc,GAAG,IAAI,CAAC;QAEtB,gBAAW,GAAG;YACrB,IAAI,EAAE,QAAiB;YACv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6B;wBAC3C,MAAM,EAAE,IAAI,CAAC,MAAgB;wBAC7B,QAAQ,EAAE,IAAI,CAAC,QAA+C;qBAC/D,CAAC,CAAC;oBACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;gBAC/C,CAAC;gBAED,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;wBACrB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,4CAA4C,EAAE,CAAC;oBACjF,CAAC;oBACD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,UAAoB,CAAC,CAAC;oBAC1E,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE;qBACjD,CAAC;gBACJ,CAAC;gBAED,KAAK,MAAM,CAAC,CAAC,CAAC;oBACZ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;oBAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,CAAC;gBACpF,CAAC;gBAED;oBACE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,MAAM,yCAAyC,EAAE,CAAC;YACzG,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAzED,gDAyEC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { NotificationService } from '../NotificationService.js';
|
|
2
|
+
export declare class NotifySendTool {
|
|
3
|
+
private service;
|
|
4
|
+
readonly id = "notifySend";
|
|
5
|
+
readonly name = "notifySend";
|
|
6
|
+
readonly displayName = "Send Notification";
|
|
7
|
+
readonly description = "Send a notification via a specific channel or the highest-priority available channel.";
|
|
8
|
+
readonly category = "communications";
|
|
9
|
+
readonly version = "0.1.0";
|
|
10
|
+
readonly hasSideEffects = true;
|
|
11
|
+
readonly inputSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: {
|
|
14
|
+
channel: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
message: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
subject: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
metadata: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
required: string[];
|
|
32
|
+
};
|
|
33
|
+
constructor(service: NotificationService);
|
|
34
|
+
execute(args: Record<string, unknown>): Promise<{
|
|
35
|
+
success: boolean;
|
|
36
|
+
data?: unknown;
|
|
37
|
+
error?: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/tools/send.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qBAAa,cAAc;IAoBb,OAAO,CAAC,OAAO;IAnB3B,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,uBAAuB;IAC3C,QAAQ,CAAC,WAAW,2FAA2F;IAC/G,QAAQ,CAAC,QAAQ,oBAAoB;IACrC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,cAAc,QAAQ;IAE/B,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;MASlB;gBAEkB,OAAO,EAAE,mBAAmB;IAE1C,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAa5G"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotifySendTool = void 0;
|
|
4
|
+
class NotifySendTool {
|
|
5
|
+
constructor(service) {
|
|
6
|
+
this.service = service;
|
|
7
|
+
this.id = 'notifySend';
|
|
8
|
+
this.name = 'notifySend';
|
|
9
|
+
this.displayName = 'Send Notification';
|
|
10
|
+
this.description = 'Send a notification via a specific channel or the highest-priority available channel.';
|
|
11
|
+
this.category = 'communications';
|
|
12
|
+
this.version = '0.1.0';
|
|
13
|
+
this.hasSideEffects = true;
|
|
14
|
+
this.inputSchema = {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
channel: { type: 'string', description: 'Target channel id. If omitted, the highest-priority channel is used.' },
|
|
18
|
+
message: { type: 'string', description: 'Notification body text.' },
|
|
19
|
+
subject: { type: 'string', description: 'Optional subject or title for the notification.' },
|
|
20
|
+
metadata: { type: 'object', description: 'Arbitrary metadata forwarded to the channel.' },
|
|
21
|
+
},
|
|
22
|
+
required: ['message'],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async execute(args) {
|
|
26
|
+
try {
|
|
27
|
+
const result = await this.service.send({
|
|
28
|
+
channel: args.channel,
|
|
29
|
+
message: args.message,
|
|
30
|
+
subject: args.subject,
|
|
31
|
+
metadata: args.metadata,
|
|
32
|
+
});
|
|
33
|
+
return { success: true, data: result };
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return { success: false, error: err.message };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.NotifySendTool = NotifySendTool;
|
|
41
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/tools/send.ts"],"names":[],"mappings":";;;AAGA,MAAa,cAAc;IAoBzB,YAAoB,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAnBvC,OAAE,GAAG,YAAY,CAAC;QAClB,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,mBAAmB,CAAC;QAClC,gBAAW,GAAG,uFAAuF,CAAC;QACtG,aAAQ,GAAG,gBAAgB,CAAC;QAC5B,YAAO,GAAG,OAAO,CAAC;QAClB,mBAAc,GAAG,IAAI,CAAC;QAEtB,gBAAW,GAAG;YACrB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sEAAsE,EAAE;gBAChH,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;gBACnE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;gBAC3F,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8CAA8C,EAAE;aAC1F;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB,CAAC;IAEiD,CAAC;IAEpD,KAAK,CAAC,OAAO,CAAC,IAA6B;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBACrC,OAAO,EAAE,IAAI,CAAC,OAA6B;gBAC3C,OAAO,EAAE,IAAI,CAAC,OAAiB;gBAC/B,OAAO,EAAE,IAAI,CAAC,OAA6B;gBAC3C,QAAQ,EAAE,IAAI,CAAC,QAA+C;aAC/D,CAAC,CAAC;YACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACzC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAnCD,wCAmCC"}
|
package/manifest.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
|
|
3
|
+
"id": "com.framers.communications.notifications",
|
|
4
|
+
"name": "Notifications Extension",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"description": "Unified multi-channel notification router — send, broadcast, and schedule notifications across all configured channels.",
|
|
7
|
+
"categories": ["communications", "notifications"],
|
|
8
|
+
"platforms": [],
|
|
9
|
+
"sdk": null,
|
|
10
|
+
"extensions": [
|
|
11
|
+
{ "kind": "tool", "id": "notifySend", "displayName": "Send Notification" },
|
|
12
|
+
{ "kind": "tool", "id": "notifyBroadcast", "displayName": "Broadcast Notification" },
|
|
13
|
+
{ "kind": "tool", "id": "notifySchedule", "displayName": "Schedule Notification" }
|
|
14
|
+
],
|
|
15
|
+
"requiredSecrets": [],
|
|
16
|
+
"optionalSecrets": [],
|
|
17
|
+
"features": [
|
|
18
|
+
"Send notifications via a specific channel or the highest-priority available channel",
|
|
19
|
+
"Broadcast notifications to all registered channels simultaneously",
|
|
20
|
+
"Schedule notifications for future delivery with in-memory timer queue",
|
|
21
|
+
"Cancel and list pending scheduled notifications",
|
|
22
|
+
"Register and unregister notification channels at runtime"
|
|
23
|
+
]
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@framers/agentos-ext-notifications",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unified multi-channel notification router for AgentOS — send, broadcast, and schedule notifications across all configured channels.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"manifest.json"
|
|
10
|
+
],
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@framers/agentos": "^0.5.2"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@framers/agentos": "^0.6.6",
|
|
16
|
+
"@types/node": "^20.0.0",
|
|
17
|
+
"typescript": "^5.0.0",
|
|
18
|
+
"vitest": "^1.0.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/framersai/agentos-extensions",
|
|
23
|
+
"directory": "registry/curated/communications/notifications"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"dev": "tsc --watch",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"clean": "rm -rf dist"
|
|
30
|
+
}
|
|
31
|
+
}
|