@aiti-ai/aiti-ai-schedule 0.4.11 → 0.4.13
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/client/src/schedule-app.tsx +25 -3
- package/dist/aiti-ai-schedule.mjs +67 -4
- package/index.ts +5 -0
- package/package.json +2 -2
- package/vite.config.ts +4 -0
|
@@ -15,6 +15,21 @@ import {
|
|
|
15
15
|
} from "../../../_shared/ext-float-dock";
|
|
16
16
|
import type { DockHeaderAction } from "../../../_shared/ext-float-dock";
|
|
17
17
|
import { uiAlert, uiConfirm } from "../../../_shared/ui-dialogs";
|
|
18
|
+
import { extItemText, primeExtRegistry, onExtRegistryReady, currentUiLocale } from "../../../_shared/ext-display-names";
|
|
19
|
+
|
|
20
|
+
// ---------- Hook-task display name (cross-extension i18n) ----------
|
|
21
|
+
// Declarative hook tasks registered by other extensions carry "i18n:<key>" names, resolved against
|
|
22
|
+
// the DECLARING extension's own manifest ui.i18n table (shared resolver; same protocol as the host
|
|
23
|
+
// translateExtItemText). Legacy plain names — and historical run records already stored with the
|
|
24
|
+
// old Chinese text — pass through untouched.
|
|
25
|
+
function taskDisplayName(targetId: string | undefined, rawName: string): string {
|
|
26
|
+
if (!rawName || !rawName.startsWith("i18n:")) return rawName;
|
|
27
|
+
const bare = rawName.slice("i18n:".length);
|
|
28
|
+
if (!targetId || !targetId.startsWith("hook:")) return bare;
|
|
29
|
+
const rest = targetId.slice("hook:".length);
|
|
30
|
+
const extId = rest.slice(0, rest.indexOf(":"));
|
|
31
|
+
return extId ? extItemText(extId, rawName, currentUiLocale()) : bare;
|
|
32
|
+
}
|
|
18
33
|
|
|
19
34
|
/** 面板 itemKey(= rightFileDock 注册复合 id "aiti-ai-schedule:panel") */
|
|
20
35
|
export const SCHED_KEY = "aiti-ai-schedule:panel";
|
|
@@ -1140,7 +1155,7 @@ function RunsPanel({ onClose }: { onClose: () => void }) {
|
|
|
1140
1155
|
return (
|
|
1141
1156
|
<tr key={r.id}>
|
|
1142
1157
|
<td style={tdStyle} title={r.at}>{new Date(r.at).toLocaleString()}</td>
|
|
1143
|
-
<td style={tdStyle}>{r.name}</td>
|
|
1158
|
+
<td style={tdStyle}>{taskDisplayName(r.targetId, r.name)}</td>
|
|
1144
1159
|
<td style={{ ...tdStyle, color: r.status === "ok" ? "var(--ok, #10b981)" : r.status === "error" ? "var(--danger, #ef4444)" : r.status === "missed" ? "var(--warn, #f59e0b)" : "inherit" }}>
|
|
1145
1160
|
{r.status}{r.retry ? t("run.retry") : ""}
|
|
1146
1161
|
</td>
|
|
@@ -1171,6 +1186,13 @@ function RunsPanel({ onClose }: { onClose: () => void }) {
|
|
|
1171
1186
|
function ScheduleDialog({ onClose, initialEditing, embedded, dockItemKey }: { onClose: () => void; initialEditing?: any; embedded?: boolean; dockItemKey?: string }) {
|
|
1172
1187
|
// 最大化按钮由 aiti-float 自动注入(⛶/❐,小屏全屏态自动隐藏)——不再自备
|
|
1173
1188
|
const [tasks, setTasks] = useState<any[] | null>(null);
|
|
1189
|
+
// Cross-extension i18n registry (hook-task names): prime once at mount; re-render when the
|
|
1190
|
+
// manifest cache lands (async fetch) so "i18n:" hook names resolve in the current locale.
|
|
1191
|
+
const [, setRegistryTick] = useState(0);
|
|
1192
|
+
useEffect(() => {
|
|
1193
|
+
primeExtRegistry(apiUrl);
|
|
1194
|
+
return onExtRegistryReady(() => setRegistryTick((x) => x + 1));
|
|
1195
|
+
}, []);
|
|
1174
1196
|
const [editing, setEditing] = useState<any | undefined>(initialEditing); // undefined=关 | null=新建 | object=预填/编辑
|
|
1175
1197
|
const [showRuns, setShowRuns] = useState(false);
|
|
1176
1198
|
const [config, setConfig] = useState<any>(null);
|
|
@@ -1206,7 +1228,7 @@ function ScheduleDialog({ onClose, initialEditing, embedded, dockItemKey }: { on
|
|
|
1206
1228
|
try {
|
|
1207
1229
|
if (m.type === "run" && m.notify && typeof Notification !== "undefined" && Notification.permission === "granted") {
|
|
1208
1230
|
const ok = m.status === "ok";
|
|
1209
|
-
new Notification((ok ? "✅ " : "❌ ") + t("dlg.notify.title", { name: m.name }), {
|
|
1231
|
+
new Notification((ok ? "✅ " : "❌ ") + t("dlg.notify.title", { name: taskDisplayName(m.targetId, String(m.name || "")) }), {
|
|
1210
1232
|
body: ok ? t("dlg.notify.ok") : String(m.error || t("dlg.notify.fail")).slice(0, 120), tag: m.targetId,
|
|
1211
1233
|
});
|
|
1212
1234
|
}
|
|
@@ -1327,7 +1349,7 @@ function ScheduleDialog({ onClose, initialEditing, embedded, dockItemKey }: { on
|
|
|
1327
1349
|
<span style={{ fontSize: 10, padding: "1px 6px", borderRadius: 5, background: isAi ? "rgba(59,130,246,.15)" : "rgba(122,122,122,.15)", color: isAi ? "#60a5fa" : "var(--text-muted)" }}>
|
|
1328
1350
|
{isAi ? t("dlg.badge.ai") : t("dlg.badge.ext")}
|
|
1329
1351
|
</span>
|
|
1330
|
-
<strong style={{ fontSize: 13.5 }}>{task.name}</strong>
|
|
1352
|
+
<strong style={{ fontSize: 13.5 }}>{taskDisplayName(task.key, task.name)}</strong>
|
|
1331
1353
|
<span style={{ fontSize: 11, padding: "1px 6px", borderRadius: 5, background: badgeColor + "22", color: badgeColor }}>{badgeText}</span>
|
|
1332
1354
|
</div>
|
|
1333
1355
|
<div style={{ display: "flex", gap: 6, alignItems: "center" }}>
|
|
@@ -859,6 +859,7 @@ const DOCK_MENU_WORDS = {
|
|
|
859
859
|
block: { "zh-CN": "区块", en: "Block" },
|
|
860
860
|
position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
|
|
861
861
|
actions: { "zh-CN": "区块操作", en: "Block actions" },
|
|
862
|
+
dragReorder: { "zh-CN": "拖动排序", en: "Drag to reorder" },
|
|
862
863
|
move: { "zh-CN": "移动", en: "Move" },
|
|
863
864
|
pin: { "zh-CN": "钉住", en: "Pin" },
|
|
864
865
|
unpin: { "zh-CN": "取消钉住", en: "Unpin" },
|
|
@@ -1433,7 +1434,7 @@ function DockBody(props) {
|
|
|
1433
1434
|
} };
|
|
1434
1435
|
if (chrome === "section" && kind !== "reserved") {
|
|
1435
1436
|
headerProps.draggable = true;
|
|
1436
|
-
headerProps.title = props.headerHint ?? "
|
|
1437
|
+
headerProps.title = props.headerHint ?? menuWord("dragReorder");
|
|
1437
1438
|
headerProps.onDragStart = onDragStart;
|
|
1438
1439
|
headerProps.onDragOver = (e) => {
|
|
1439
1440
|
if (isDockDrag(e) && dragKey !== blockKey) {
|
|
@@ -1861,6 +1862,63 @@ function uiAlert(opts) {
|
|
|
1861
1862
|
const o = typeof opts === "string" ? { message: opts } : opts;
|
|
1862
1863
|
return enqueue("alert", o);
|
|
1863
1864
|
}
|
|
1865
|
+
function currentUiLocale() {
|
|
1866
|
+
try {
|
|
1867
|
+
const v = window.localStorage.getItem("pi-locale");
|
|
1868
|
+
if (v === "zh-CN" || v === "zh-TW" || v === "en") return v;
|
|
1869
|
+
} catch {
|
|
1870
|
+
}
|
|
1871
|
+
return "en";
|
|
1872
|
+
}
|
|
1873
|
+
let registry = null;
|
|
1874
|
+
let registryPrimed = false;
|
|
1875
|
+
let registryApiUrl = null;
|
|
1876
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1877
|
+
function primeExtRegistry(apiUrlFn) {
|
|
1878
|
+
if (apiUrlFn) registryApiUrl = apiUrlFn;
|
|
1879
|
+
if (registryPrimed || typeof window === "undefined") return;
|
|
1880
|
+
const urlFn = registryApiUrl;
|
|
1881
|
+
if (!urlFn) return;
|
|
1882
|
+
registryPrimed = true;
|
|
1883
|
+
fetch(urlFn("/api/extensions/manifest")).then((r) => r.json()).then((d) => {
|
|
1884
|
+
const map = {};
|
|
1885
|
+
for (const e of d?.extensions ?? []) if (e?.id) map[e.id] = e;
|
|
1886
|
+
registry = map;
|
|
1887
|
+
for (const l of [...listeners]) {
|
|
1888
|
+
try {
|
|
1889
|
+
l();
|
|
1890
|
+
} catch {
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
}).catch(() => {
|
|
1894
|
+
registryPrimed = false;
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
function onExtRegistryReady(fn) {
|
|
1898
|
+
listeners.add(fn);
|
|
1899
|
+
return () => {
|
|
1900
|
+
listeners.delete(fn);
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
function extItemText(extId, text, locale) {
|
|
1904
|
+
if (!text) return "";
|
|
1905
|
+
if (!extId || !text.startsWith("i18n:")) return text;
|
|
1906
|
+
primeExtRegistry();
|
|
1907
|
+
const key = text.slice("i18n:".length);
|
|
1908
|
+
const ui18n = registry?.[extId]?.ui?.i18n;
|
|
1909
|
+
if (!ui18n) return key;
|
|
1910
|
+
const short = locale.split("-")[0];
|
|
1911
|
+
const tbl = ui18n[locale] ?? ui18n[short] ?? (short === "zh" ? ui18n["zh-CN"] : void 0) ?? ui18n.en ?? Object.values(ui18n)[0] ?? {};
|
|
1912
|
+
return tbl[key] ?? key;
|
|
1913
|
+
}
|
|
1914
|
+
function taskDisplayName(targetId, rawName) {
|
|
1915
|
+
if (!rawName || !rawName.startsWith("i18n:")) return rawName;
|
|
1916
|
+
const bare = rawName.slice("i18n:".length);
|
|
1917
|
+
if (!targetId || !targetId.startsWith("hook:")) return bare;
|
|
1918
|
+
const rest = targetId.slice("hook:".length);
|
|
1919
|
+
const extId = rest.slice(0, rest.indexOf(":"));
|
|
1920
|
+
return extId ? extItemText(extId, rawName, currentUiLocale()) : bare;
|
|
1921
|
+
}
|
|
1864
1922
|
const SCHED_KEY = "aiti-ai-schedule:panel";
|
|
1865
1923
|
const API = (p) => apiUrl("/api/extensions/aiti-ai-schedule" + p);
|
|
1866
1924
|
const ICONS = {
|
|
@@ -3235,7 +3293,7 @@ function RunsPanel({ onClose }) {
|
|
|
3235
3293
|
const mailOk = r.mailSent === "ok";
|
|
3236
3294
|
return /* @__PURE__ */ jsxs("tr", { children: [
|
|
3237
3295
|
/* @__PURE__ */ jsx("td", { style: tdStyle, title: r.at, children: new Date(r.at).toLocaleString() }),
|
|
3238
|
-
/* @__PURE__ */ jsx("td", { style: tdStyle, children: r.name }),
|
|
3296
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: taskDisplayName(r.targetId, r.name) }),
|
|
3239
3297
|
/* @__PURE__ */ jsxs("td", { style: { ...tdStyle, color: r.status === "ok" ? "var(--ok, #10b981)" : r.status === "error" ? "var(--danger, #ef4444)" : r.status === "missed" ? "var(--warn, #f59e0b)" : "inherit" }, children: [
|
|
3240
3298
|
r.status,
|
|
3241
3299
|
r.retry ? t("run.retry") : ""
|
|
@@ -3274,6 +3332,11 @@ function RunsPanel({ onClose }) {
|
|
|
3274
3332
|
}
|
|
3275
3333
|
function ScheduleDialog({ onClose, initialEditing, embedded, dockItemKey }) {
|
|
3276
3334
|
const [tasks, setTasks] = useState(null);
|
|
3335
|
+
const [, setRegistryTick] = useState(0);
|
|
3336
|
+
useEffect(() => {
|
|
3337
|
+
primeExtRegistry(apiUrl);
|
|
3338
|
+
return onExtRegistryReady(() => setRegistryTick((x) => x + 1));
|
|
3339
|
+
}, []);
|
|
3277
3340
|
const [editing, setEditing] = useState(initialEditing);
|
|
3278
3341
|
const [showRuns, setShowRuns] = useState(false);
|
|
3279
3342
|
const [config, setConfig] = useState(null);
|
|
@@ -3311,7 +3374,7 @@ function ScheduleDialog({ onClose, initialEditing, embedded, dockItemKey }) {
|
|
|
3311
3374
|
try {
|
|
3312
3375
|
if (m.type === "run" && m.notify && typeof Notification !== "undefined" && Notification.permission === "granted") {
|
|
3313
3376
|
const ok = m.status === "ok";
|
|
3314
|
-
new Notification((ok ? "✅ " : "❌ ") + t("dlg.notify.title", { name: m.name }), {
|
|
3377
|
+
new Notification((ok ? "✅ " : "❌ ") + t("dlg.notify.title", { name: taskDisplayName(m.targetId, String(m.name || "")) }), {
|
|
3315
3378
|
body: ok ? t("dlg.notify.ok") : String(m.error || t("dlg.notify.fail")).slice(0, 120),
|
|
3316
3379
|
tag: m.targetId
|
|
3317
3380
|
});
|
|
@@ -3456,7 +3519,7 @@ function ScheduleDialog({ onClose, initialEditing, embedded, dockItemKey }) {
|
|
|
3456
3519
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 8 }, children: [
|
|
3457
3520
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, alignItems: "center", minWidth: 0 }, children: [
|
|
3458
3521
|
/* @__PURE__ */ jsx("span", { style: { fontSize: 10, padding: "1px 6px", borderRadius: 5, background: isAi ? "rgba(59,130,246,.15)" : "rgba(122,122,122,.15)", color: isAi ? "#60a5fa" : "var(--text-muted)" }, children: isAi ? t("dlg.badge.ai") : t("dlg.badge.ext") }),
|
|
3459
|
-
/* @__PURE__ */ jsx("strong", { style: { fontSize: 13.5 }, children: task.name }),
|
|
3522
|
+
/* @__PURE__ */ jsx("strong", { style: { fontSize: 13.5 }, children: taskDisplayName(task.key, task.name) }),
|
|
3460
3523
|
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, padding: "1px 6px", borderRadius: 5, background: badgeColor + "22", color: badgeColor }, children: badgeText })
|
|
3461
3524
|
] }),
|
|
3462
3525
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
|
package/index.ts
CHANGED
|
@@ -68,6 +68,11 @@ export default {
|
|
|
68
68
|
name: "AI 自调度(计划管理)",
|
|
69
69
|
icon: "icon.svg",
|
|
70
70
|
client: "dist/aiti-ai-schedule.mjs",
|
|
71
|
+
// App-center / launcher search vocabulary (self-declared; retires the legacy APP_OVERRIDES row).
|
|
72
|
+
// "task(s)" matters: the sidebar dock block is literally named Tasks (sb.tasks) — searching
|
|
73
|
+
// "task" must land here. English + Chinese synonyms both included (hay matches either locale).
|
|
74
|
+
category: "auto",
|
|
75
|
+
keywords: ["schedule", "task", "tasks", "cron", "timer", "job", "定时", "任务", "计划", "调度"],
|
|
71
76
|
|
|
72
77
|
ai: {
|
|
73
78
|
manage: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiti-ai/aiti-ai-schedule",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "pi-web resident scheduler — extension declarative scheduled tasks + AI plans (cron/interval/one-shot) + three-mode execution engine + AI self-service plan tool + management page",
|
|
6
6
|
"displayNameI18n": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"aitiExtProtocol": "1.0",
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"contentHash": "
|
|
22
|
+
"contentHash": "a3cbe77b12aa5642",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
25
|
"url": "git+https://github.com/aiti-ai/aiti-ai.git",
|
package/vite.config.ts
CHANGED
|
@@ -30,6 +30,10 @@ export default defineConfig({
|
|
|
30
30
|
esbuild: {
|
|
31
31
|
jsx: "automatic",
|
|
32
32
|
jsxImportSource: "react",
|
|
33
|
+
// Production lib bundle: never let the JSX runtime follow the build shell's NODE_ENV.
|
|
34
|
+
// Vite infers jsxDev from NODE_ENV; a build from a dev-instance shell inherits
|
|
35
|
+
// NODE_ENV=development -> jsxDEV(), but jsx-runtime.ts only exports jsx/jsxs/Fragment.
|
|
36
|
+
jsxDev: false,
|
|
33
37
|
},
|
|
34
38
|
resolve: {
|
|
35
39
|
alias: [
|