@eum-agent/system-notifications 1.0.1 → 1.2.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/dist/index.js +5 -2
- package/package.json +2 -2
- package/ui/ui.js +41 -16
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
4
|
//#region src/index.ts
|
|
4
|
-
/** Owns this optional client feature and its browser activation. */
|
|
5
5
|
const plugin = {
|
|
6
6
|
name: "@eum-agent/system-notifications",
|
|
7
7
|
apply(ctx) {
|
|
8
8
|
const module = fileURLToPath(new URL("../ui/ui.js", import.meta.url));
|
|
9
|
-
if (existsSync(module)) ctx.client.
|
|
9
|
+
if (existsSync(module)) ctx.client.registerPackageFiles({
|
|
10
|
+
root: dirname(module),
|
|
11
|
+
entry: "ui.js"
|
|
12
|
+
});
|
|
10
13
|
}
|
|
11
14
|
};
|
|
12
15
|
//#endregion
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"en-US": "System Notifications",
|
|
5
5
|
"zh-CN": "系统通知"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.0
|
|
7
|
+
"version": "1.2.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"description": "System reminders for completed tasks and pending requests",
|
|
10
10
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"i18next": "^26.4.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@eum-agent/plugin": "1.0
|
|
25
|
+
"@eum-agent/plugin": "1.2.0",
|
|
26
26
|
"@types/react": "^19.2.18",
|
|
27
27
|
"@types/react-dom": "^19.2.5",
|
|
28
28
|
"react": "^19.2.0",
|
package/ui/ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Alert, Button, Disclosure, DisclosureSummary, NavEntryBody, Panel, Popover,
|
|
1
|
+
import { Alert, Button, Disclosure, DisclosureSummary, NavEntryBody, Panel, Popover, Segmented, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipTrigger, goToSession, isOnline, localeLeaves, navEntryClass, onInboxCandidates, openInbox, pageKey, sessionTitle, useConnection, useFailureToast, useGateway, useInbox, useNotices, useOpenSession, usePage, usePendingRequests, usePlugins, useSessions, useTranslation, useTriggers } from "@eum-agent/host/framework";
|
|
2
2
|
import React, { createContext, createElement, forwardRef, useContext, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region ui-src/activation.ts
|
|
@@ -78,6 +78,7 @@ var en_US_default = {
|
|
|
78
78
|
"turnCompleted": "Turn completed",
|
|
79
79
|
"turnFailed": "Turn failed",
|
|
80
80
|
"turnInterrupted": "Turn interrupted",
|
|
81
|
+
"turnStopped": "Turn stopped",
|
|
81
82
|
"subprocessEnded": "Process ended",
|
|
82
83
|
"subprocessFailed": "Process failed",
|
|
83
84
|
"participantJoined": "Participant joined",
|
|
@@ -100,7 +101,8 @@ var en_US_default = {
|
|
|
100
101
|
"outcome": {
|
|
101
102
|
"completed": "Session completed",
|
|
102
103
|
"failed": "Session failed",
|
|
103
|
-
"interrupted": "Session stopped"
|
|
104
|
+
"interrupted": "Session stopped",
|
|
105
|
+
"stopped": "Session stopped"
|
|
104
106
|
},
|
|
105
107
|
"label": "Inbox",
|
|
106
108
|
"labelCount": "Inbox, {{count}} to look at",
|
|
@@ -128,6 +130,7 @@ var en_US_default = {
|
|
|
128
130
|
"turnCompleted": "“{{session}}” finished",
|
|
129
131
|
"turnFailed": "“{{session}}” failed",
|
|
130
132
|
"turnInterrupted": "“{{session}}” was interrupted",
|
|
133
|
+
"turnStopped": "“{{session}}” was stopped",
|
|
131
134
|
"processEnded": "Background command ended: {{command}}",
|
|
132
135
|
"processFailed": "Background command failed: {{command}}",
|
|
133
136
|
"generic": "A new message",
|
|
@@ -139,6 +142,8 @@ var en_US_default = {
|
|
|
139
142
|
},
|
|
140
143
|
requests: { "approvalOf": "{{tool}} asks for permission" },
|
|
141
144
|
common: {
|
|
145
|
+
"on": "On",
|
|
146
|
+
"off": "Off",
|
|
142
147
|
"working": "Working…",
|
|
143
148
|
"retry": "Retry"
|
|
144
149
|
}
|
|
@@ -186,6 +191,7 @@ var zh_CN_default = {
|
|
|
186
191
|
"turnCompleted": "回合完成",
|
|
187
192
|
"turnFailed": "回合失败",
|
|
188
193
|
"turnInterrupted": "回合中断",
|
|
194
|
+
"turnStopped": "回合已停止",
|
|
189
195
|
"subprocessEnded": "进程结束",
|
|
190
196
|
"subprocessFailed": "进程失败",
|
|
191
197
|
"participantJoined": "参与者加入",
|
|
@@ -208,7 +214,8 @@ var zh_CN_default = {
|
|
|
208
214
|
"outcome": {
|
|
209
215
|
"completed": "会话已完成",
|
|
210
216
|
"failed": "会话出错了",
|
|
211
|
-
"interrupted": "会话已停止"
|
|
217
|
+
"interrupted": "会话已停止",
|
|
218
|
+
"stopped": "会话已停止"
|
|
212
219
|
},
|
|
213
220
|
"label": "消息",
|
|
214
221
|
"labelCount": "消息,{{count}} 项待看",
|
|
@@ -235,6 +242,7 @@ var zh_CN_default = {
|
|
|
235
242
|
"turnCompleted": "「{{session}}」已完成",
|
|
236
243
|
"turnFailed": "「{{session}}」出错了",
|
|
237
244
|
"turnInterrupted": "「{{session}}」已中断",
|
|
245
|
+
"turnStopped": "「{{session}}」已停止",
|
|
238
246
|
"processEnded": "后台命令已结束:{{command}}",
|
|
239
247
|
"processFailed": "后台命令失败:{{command}}",
|
|
240
248
|
"generic": "有一条新消息",
|
|
@@ -246,6 +254,8 @@ var zh_CN_default = {
|
|
|
246
254
|
},
|
|
247
255
|
requests: { "approvalOf": "{{tool}} 请求授权" },
|
|
248
256
|
common: {
|
|
257
|
+
"on": "开启",
|
|
258
|
+
"off": "关闭",
|
|
249
259
|
"working": "处理中……",
|
|
250
260
|
"retry": "重试"
|
|
251
261
|
}
|
|
@@ -495,11 +505,18 @@ function NotificationsPanel() {
|
|
|
495
505
|
inline: true,
|
|
496
506
|
children: /* @__PURE__ */ jsx("div", {
|
|
497
507
|
className: "flex min-w-0 justify-end",
|
|
498
|
-
children: /* @__PURE__ */ jsx(
|
|
499
|
-
|
|
500
|
-
|
|
508
|
+
children: /* @__PURE__ */ jsx(Segmented, {
|
|
509
|
+
label: t("notifications.enabled"),
|
|
510
|
+
value: enabled ? "on" : "off",
|
|
511
|
+
options: [{
|
|
512
|
+
value: "off",
|
|
513
|
+
label: t("common.off")
|
|
514
|
+
}, {
|
|
515
|
+
value: "on",
|
|
516
|
+
label: t("common.on")
|
|
517
|
+
}],
|
|
501
518
|
disabled: !initialized || pending || permission === "unsupported",
|
|
502
|
-
|
|
519
|
+
onSelect: (value) => toggle(value === "on")
|
|
503
520
|
})
|
|
504
521
|
})
|
|
505
522
|
}),
|
|
@@ -743,6 +760,7 @@ function category(item) {
|
|
|
743
760
|
case "completed": return platformText("notifications.category.turnCompleted", { defaultValue: "Turn completed" });
|
|
744
761
|
case "failed": return platformText("notifications.category.turnFailed", { defaultValue: "Turn failed" });
|
|
745
762
|
case "interrupted": return platformText("notifications.category.turnInterrupted", { defaultValue: "Turn interrupted" });
|
|
763
|
+
case "stopped": return platformText("notifications.category.turnStopped", { defaultValue: "Turn stopped" });
|
|
746
764
|
}
|
|
747
765
|
break;
|
|
748
766
|
case "subprocess-ended": return detail.ending.kind === "exited" && detail.ending.code === 0 ? platformText("notifications.category.subprocessEnded", { defaultValue: "Process ended" }) : platformText("notifications.category.subprocessFailed", { defaultValue: "Process failed" });
|
|
@@ -788,15 +806,18 @@ function registerInboxNotifications(ctx) {
|
|
|
788
806
|
if (!host) return;
|
|
789
807
|
const epoch = generation;
|
|
790
808
|
const current = () => epoch === generation && !ctx.signal.aborted && useConnection.getState().status === "online" && notificationHost() === host;
|
|
791
|
-
for (const item of items)
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
809
|
+
for (const item of items) {
|
|
810
|
+
if (item.detail.category !== "human-request" && item.detail.category !== "turn-ended") continue;
|
|
811
|
+
(async () => {
|
|
812
|
+
try {
|
|
813
|
+
const state = await host.state();
|
|
814
|
+
if (!current() || !state.enabled || state.permission !== "granted" && state.permission !== "system-managed") return;
|
|
815
|
+
await host.show(notificationSummary(item));
|
|
816
|
+
} catch (error) {
|
|
817
|
+
if (current()) reportNotificationFailure(error, host);
|
|
818
|
+
}
|
|
819
|
+
})();
|
|
820
|
+
}
|
|
800
821
|
});
|
|
801
822
|
return () => {
|
|
802
823
|
generation++;
|
|
@@ -1079,6 +1100,10 @@ function noticeText(item, t, name) {
|
|
|
1079
1100
|
text: t("inbox.turnFailed", { session }),
|
|
1080
1101
|
tone: "failure"
|
|
1081
1102
|
};
|
|
1103
|
+
if (detail.outcome.kind === "stopped") return {
|
|
1104
|
+
text: t("inbox.turnStopped", { session }),
|
|
1105
|
+
tone: "neutral"
|
|
1106
|
+
};
|
|
1082
1107
|
return {
|
|
1083
1108
|
text: t("inbox.turnInterrupted", { session }),
|
|
1084
1109
|
tone: "neutral"
|