@aiti-ai/aiti-ai-usage 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -22
- package/README.zh-CN.md +31 -0
- package/client/src/entry.tsx +2 -2
- package/client/src/report.tsx +180 -3
- package/dev-pack.mjs +16 -3
- package/dist/aiti-ai-usage.mjs +474 -37
- package/index.ts +64 -4
- package/lib/catalog.ts +199 -0
- package/lib/db.ts +27 -0
- package/lib/ingest.ts +118 -3
- package/package.json +3 -3
- package/server/api.ts +24 -0
- package/skills/usage-report/SKILL.md +2 -0
- package/tool-usage.test.mjs +192 -0
- package/tools/build-client.mjs +2 -1
- package/tools/deploy.mjs +1 -1
package/dist/aiti-ai-usage.mjs
CHANGED
|
@@ -47,6 +47,8 @@ function t(key, params) {
|
|
|
47
47
|
return typeof fn === "function" ? fn(key, params) : key;
|
|
48
48
|
}
|
|
49
49
|
function isFixedContainingBlock(cs) {
|
|
50
|
+
const zoomValue = parseFloat(cs.zoom || "");
|
|
51
|
+
if (Number.isFinite(zoomValue) && zoomValue !== 1) return true;
|
|
50
52
|
if (cs.transform !== "none" || cs.perspective !== "none" || cs.filter !== "none") return true;
|
|
51
53
|
if (/transform|perspective|filter/.test(cs.willChange || "")) return true;
|
|
52
54
|
const c2 = cs.contain;
|
|
@@ -66,6 +68,19 @@ function fixedOrigin(el) {
|
|
|
66
68
|
}
|
|
67
69
|
return { x: 0, y: 0 };
|
|
68
70
|
}
|
|
71
|
+
function zoomFactorOf(el) {
|
|
72
|
+
let z = 1;
|
|
73
|
+
let n = el.parentElement;
|
|
74
|
+
while (n && n !== document.documentElement) {
|
|
75
|
+
try {
|
|
76
|
+
const zoomValue = parseFloat(getComputedStyle(n).zoom || "");
|
|
77
|
+
if (Number.isFinite(zoomValue) && zoomValue > 0 && zoomValue !== 1) z *= zoomValue;
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
n = n.parentElement;
|
|
81
|
+
}
|
|
82
|
+
return z;
|
|
83
|
+
}
|
|
69
84
|
function clampToViewport(left, top, width, height, pad = 8) {
|
|
70
85
|
const vw = window.innerWidth;
|
|
71
86
|
const vh = window.innerHeight;
|
|
@@ -76,6 +91,7 @@ function clampToViewport(left, top, width, height, pad = 8) {
|
|
|
76
91
|
}
|
|
77
92
|
const P = (d) => ({ tag: "path", attrs: { d } });
|
|
78
93
|
const R = (x, y, width, height, rx = 2) => ({ tag: "rect", attrs: { x, y, width, height, rx } });
|
|
94
|
+
const thin = (n) => ({ ...n, attrs: { ...n.attrs, "stroke-width": 1.5 } });
|
|
79
95
|
const DOCK_ICON_NODES = {
|
|
80
96
|
/** 浮窗:圆角框 + 标题栏 + 圆点(app-window;用户 2026-09-15 定稿 C)。 */
|
|
81
97
|
float: [
|
|
@@ -109,6 +125,12 @@ const DOCK_ICON_NODES = {
|
|
|
109
125
|
],
|
|
110
126
|
/** 关闭:×(lucide x;⋮ 区块操作「关闭」)。 */
|
|
111
127
|
x: [P("M18 6 6 18"), P("m6 6 12 12")],
|
|
128
|
+
/** 取消钉住态:图钉 + 斜删除线(lucide pin-off;移动行钉住钮已钉态,与 MiPin 同语义族)。 */
|
|
129
|
+
"pin-off": [
|
|
130
|
+
{ tag: "line", attrs: { x1: 12, y1: 17, x2: 12, y2: 22 } },
|
|
131
|
+
P("M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16h14v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"),
|
|
132
|
+
{ tag: "line", attrs: { x1: 2, y1: 2, x2: 22, y2: 22 } }
|
|
133
|
+
],
|
|
112
134
|
/** 移除本实例:垃圾桶(lucide trash;多实例区块 ⋮「移除本实例」,与 aiti-folder MiTrash 同形)。 */
|
|
113
135
|
trash: [
|
|
114
136
|
{ tag: "polyline", attrs: { points: "3 6 5 6 21 6" } },
|
|
@@ -121,6 +143,89 @@ const DOCK_ICON_NODES = {
|
|
|
121
143
|
P("M5 11V5h6"),
|
|
122
144
|
P("M19 13v6h-6"),
|
|
123
145
|
P("M5 5l14 14")
|
|
146
|
+
],
|
|
147
|
+
/* ── Block semantic icons (collapsed-header icons; lucide line style) ── */
|
|
148
|
+
/** Projects block (session-manager projects): the aiti-ai logo as line art (chosen by
|
|
149
|
+
* the user 2026-11-26 from the icon candidates preview; prototype = aiti-docs
|
|
150
|
+
* docs/.vuepress/public/logo.svg). Three brand elements: large-rounded square (the
|
|
151
|
+
* gradient tile) + geometric letter a (circle + stem) + top-right spark (from the
|
|
152
|
+
* logo's yellow dot). Visual weight kept on par with the folder/file glyph family:
|
|
153
|
+
* the spark dot is stroked, not filled (a filled node reads much heavier at 13px),
|
|
154
|
+
* and the letter circle stays small so line density matches single-outline glyphs. */
|
|
155
|
+
"aiti-ai-logo": [
|
|
156
|
+
thin(R(3, 3, 18, 18, 4)),
|
|
157
|
+
thin({ tag: "circle", attrs: { cx: 10, cy: 14, r: 2.8 } }),
|
|
158
|
+
thin(P("M12.8 11.2v5.6")),
|
|
159
|
+
thin({ tag: "circle", attrs: { cx: 16.8, cy: 7.2, r: 1.2 } }),
|
|
160
|
+
thin(P("m18.8 5.3 1.5-1.6")),
|
|
161
|
+
thin(P("m19.2 8.2 2.1-.4"))
|
|
162
|
+
],
|
|
163
|
+
/** Folder block (aiti-folder faces): single folder (lucide folder). */
|
|
164
|
+
folder: [
|
|
165
|
+
P("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z")
|
|
166
|
+
],
|
|
167
|
+
/** Scheduled tasks block (aiti-ai-schedule tasks): clock (lucide clock). */
|
|
168
|
+
clock: [
|
|
169
|
+
{ tag: "circle", attrs: { cx: 12, cy: 12, r: 10 } },
|
|
170
|
+
{ tag: "polyline", attrs: { points: "12 6 12 12 16 14" } }
|
|
171
|
+
],
|
|
172
|
+
/** Subagent fleet block (aiti-subagents fleet): robot (lucide bot). */
|
|
173
|
+
bot: [
|
|
174
|
+
P("M12 8V4H8"),
|
|
175
|
+
R(4, 8, 16, 12),
|
|
176
|
+
P("M2 14h2"),
|
|
177
|
+
P("M20 14h2"),
|
|
178
|
+
P("M15 13v2"),
|
|
179
|
+
P("M9 13v2")
|
|
180
|
+
],
|
|
181
|
+
/** Prompt library block (aiti-prompts panel): bookshelf lines (lucide library). */
|
|
182
|
+
library: [
|
|
183
|
+
P("m16 6 4 14"),
|
|
184
|
+
P("M12 6v14"),
|
|
185
|
+
P("M8 8v12"),
|
|
186
|
+
P("M4 4v16")
|
|
187
|
+
],
|
|
188
|
+
/** Model availability block (aiti-model-check panel): shield + check (lucide shield-check). */
|
|
189
|
+
"shield-check": [
|
|
190
|
+
P("M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"),
|
|
191
|
+
P("m9 12 2 2 4-4")
|
|
192
|
+
],
|
|
193
|
+
/** Watch paths block (aiti-git-trace watch): branch (lucide git-branch). */
|
|
194
|
+
"git-branch": [
|
|
195
|
+
{ tag: "line", attrs: { x1: 6, y1: 3, x2: 6, y2: 15 } },
|
|
196
|
+
{ tag: "circle", attrs: { cx: 18, cy: 6, r: 3 } },
|
|
197
|
+
{ tag: "circle", attrs: { cx: 6, cy: 18, r: 3 } },
|
|
198
|
+
P("M18 9a9 9 0 0 1-9 9")
|
|
199
|
+
],
|
|
200
|
+
/** Timeline block (aiti-git-trace timeline): clock + counterclockwise arrow (lucide history). */
|
|
201
|
+
history: [
|
|
202
|
+
P("M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"),
|
|
203
|
+
P("M3 3v5h5"),
|
|
204
|
+
P("M12 7v5l4 2")
|
|
205
|
+
],
|
|
206
|
+
/** File panel block (aiti-editor file faces): document (lucide file). */
|
|
207
|
+
file: [
|
|
208
|
+
P("M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"),
|
|
209
|
+
P("M14 2v4a2 2 0 0 0 2 2h4")
|
|
210
|
+
],
|
|
211
|
+
/** ACP management block (aiti-acp-agent manage): plug (lucide plug). */
|
|
212
|
+
plug: [
|
|
213
|
+
P("M12 22v-5"),
|
|
214
|
+
P("M9 8V2"),
|
|
215
|
+
P("M15 8V2"),
|
|
216
|
+
P("M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z")
|
|
217
|
+
],
|
|
218
|
+
/** Speech recognition block (aiti-ai-input asr): microphone (lucide mic). */
|
|
219
|
+
mic: [
|
|
220
|
+
P("M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"),
|
|
221
|
+
P("M19 10v2a7 7 0 0 1-14 0v-2"),
|
|
222
|
+
{ tag: "line", attrs: { x1: 12, y1: 19, x2: 12, y2: 22 } }
|
|
223
|
+
],
|
|
224
|
+
/** Dock demo block (demo): 3D box (lucide box). */
|
|
225
|
+
box: [
|
|
226
|
+
P("M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"),
|
|
227
|
+
P("m3.3 7 8.7 5 8.7-5"),
|
|
228
|
+
P("M12 22V12")
|
|
124
229
|
]
|
|
125
230
|
};
|
|
126
231
|
function dockIconOfZone(zone) {
|
|
@@ -156,6 +261,13 @@ const DOCK_ICON_SVG_ROOT_PROPS = {
|
|
|
156
261
|
strokeLinecap: "round",
|
|
157
262
|
strokeLinejoin: "round"
|
|
158
263
|
};
|
|
264
|
+
function dockIconReactAttrs(attrs) {
|
|
265
|
+
const out = {};
|
|
266
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
267
|
+
out[!k.includes("-") || k.startsWith("aria-") || k.startsWith("data-") ? k : k.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase())] = v;
|
|
268
|
+
}
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
159
271
|
function sidebarZoneOf(itemKey) {
|
|
160
272
|
return `sidebar:${itemKey}`;
|
|
161
273
|
}
|
|
@@ -183,6 +295,14 @@ function writeBlockCollapsed(blockKey, collapsed) {
|
|
|
183
295
|
} catch {
|
|
184
296
|
}
|
|
185
297
|
}
|
|
298
|
+
const SIDEBAR_DISMISS_PREFIX = "pi:sidebar-dock:dismissed:";
|
|
299
|
+
function writeBlockDismissed(blockKey, dismissed) {
|
|
300
|
+
try {
|
|
301
|
+
if (dismissed) localStorage.setItem(SIDEBAR_DISMISS_PREFIX + blockKey, "1");
|
|
302
|
+
else localStorage.removeItem(SIDEBAR_DISMISS_PREFIX + blockKey);
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
}
|
|
186
306
|
const FLOAT_INSTALLED_EVENT = "piwe-float-installed";
|
|
187
307
|
const DOCK_HEADER_PENDING_TTL = 1e4;
|
|
188
308
|
function actionSig(list) {
|
|
@@ -191,7 +311,7 @@ function actionSig(list) {
|
|
|
191
311
|
}
|
|
192
312
|
function menuSig(list) {
|
|
193
313
|
if (!list) return "";
|
|
194
|
-
return list.map((m) => m.kind === "item" ? `i:${m.id ?? m.label}:${m.label}:${m.hint ?? ""}:${m.active ? 1 : 0}:${m.alwaysRun ? 1 : 0}:${m.disabled ? 1 : 0}` : m.kind === "head" ? `h:${m.label}` : "s").join("§");
|
|
314
|
+
return list.map((m) => m.kind === "item" ? `i:${m.id ?? m.label}:${m.label}:${m.hint ?? ""}:${m.active ? 1 : 0}:${m.alwaysRun ? 1 : 0}:${m.disabled ? 1 : 0}` : m.kind === "head" ? `h:${m.label}` : m.kind === "iconsRow" ? `r:${m.label ?? ""}:${m.items.map((i) => i.key).join(",")}` : m.kind === "moveRow" ? "mv-row" : "s").join("§");
|
|
195
315
|
}
|
|
196
316
|
function stateSig(s) {
|
|
197
317
|
try {
|
|
@@ -402,8 +522,10 @@ function localPresent(k, mode, opts) {
|
|
|
402
522
|
next = zone ? `docked:${zone}` : "floating";
|
|
403
523
|
}
|
|
404
524
|
} else if (mode === "float") next = "floating";
|
|
405
|
-
else if (mode === "close")
|
|
406
|
-
|
|
525
|
+
else if (mode === "close") {
|
|
526
|
+
next = "closed";
|
|
527
|
+
writeBlockDismissed(k, true);
|
|
528
|
+
} else if (mode.startsWith("dock:")) {
|
|
407
529
|
const zone = mode.slice(5);
|
|
408
530
|
try {
|
|
409
531
|
localStorage.setItem(DOCKPREF_KEY(k), zone);
|
|
@@ -411,6 +533,7 @@ function localPresent(k, mode, opts) {
|
|
|
411
533
|
}
|
|
412
534
|
next = `docked:${zone}`;
|
|
413
535
|
}
|
|
536
|
+
if (next !== "closed" && isSidebarDockState(next)) writeBlockDismissed(k, false);
|
|
414
537
|
if (next === prev) {
|
|
415
538
|
if (prev.startsWith("docked:")) {
|
|
416
539
|
try {
|
|
@@ -565,9 +688,24 @@ if (typeof window !== "undefined") {
|
|
|
565
688
|
} catch {
|
|
566
689
|
}
|
|
567
690
|
}
|
|
691
|
+
const DOCK_WORDS = {
|
|
692
|
+
newWindow: { "zh-CN": "新窗口打开", en: "Open in new window" },
|
|
693
|
+
float: { "zh-CN": "浮窗", en: "Float" },
|
|
694
|
+
zoneSidebar: { "zh-CN": "左栏 · 区块", en: "Left · blocks" },
|
|
695
|
+
zoneRight: { "zh-CN": "右栏 · 面板", en: "Right · panels" }
|
|
696
|
+
};
|
|
697
|
+
function dockWord(key) {
|
|
698
|
+
let loc = "en";
|
|
699
|
+
try {
|
|
700
|
+
loc = window.localStorage.getItem("pi-locale") || "en";
|
|
701
|
+
} catch {
|
|
702
|
+
}
|
|
703
|
+
const w = DOCK_WORDS[key];
|
|
704
|
+
return w[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
|
|
705
|
+
}
|
|
568
706
|
const DOCK_ZONE_LABELS = {
|
|
569
|
-
"sidebar-explorer": "
|
|
570
|
-
"right-panel": "
|
|
707
|
+
"sidebar-explorer": dockWord("zoneSidebar"),
|
|
708
|
+
"right-panel": dockWord("zoneRight")
|
|
571
709
|
};
|
|
572
710
|
function positionMenuItems(k, zones, defaultZone, cur) {
|
|
573
711
|
const hasSidebar = zones.some((z) => z === "sidebar-explorer" || z.startsWith("sidebar:"));
|
|
@@ -601,8 +739,8 @@ function positionMenuItems(k, zones, defaultZone, cur) {
|
|
|
601
739
|
function positionMenuModel(k, zones, defaultZone, cur, opts) {
|
|
602
740
|
const newWindow = opts?.onNewWindow ?? dockWindowOpenerOf(k);
|
|
603
741
|
return [
|
|
604
|
-
...newWindow ? [{ key: "new-window", icon: "new-window", label: "
|
|
605
|
-
{ key: "float", icon: "float", label: "
|
|
742
|
+
...newWindow ? [{ key: "new-window", icon: "new-window", label: dockWord("newWindow"), run: newWindow }] : [],
|
|
743
|
+
{ key: "float", icon: "float", label: dockWord("float"), active: cur === "floating", run: () => undockToFloat(k) },
|
|
606
744
|
...positionMenuItems(k, zones, defaultZone, cur)
|
|
607
745
|
];
|
|
608
746
|
}
|
|
@@ -698,13 +836,83 @@ function useGate(itemKey, face) {
|
|
|
698
836
|
if (face === "float") return state === "floating";
|
|
699
837
|
return state === `docked:${face.dock}`;
|
|
700
838
|
}
|
|
839
|
+
const DOCK_MENU_WORDS = {
|
|
840
|
+
expand: { "zh-CN": "展开", en: "Expand" },
|
|
841
|
+
collapse: { "zh-CN": "折叠", en: "Collapse" },
|
|
842
|
+
block: { "zh-CN": "区块", en: "Block" },
|
|
843
|
+
position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
|
|
844
|
+
actions: { "zh-CN": "区块操作", en: "Block actions" },
|
|
845
|
+
move: { "zh-CN": "移动", en: "Move" },
|
|
846
|
+
pin: { "zh-CN": "钉住", en: "Pin" },
|
|
847
|
+
unpin: { "zh-CN": "取消钉住", en: "Unpin" },
|
|
848
|
+
moveUp: { "zh-CN": "上移", en: "Move up" },
|
|
849
|
+
moveDown: { "zh-CN": "下移", en: "Move down" },
|
|
850
|
+
tools: { "zh-CN": "工具", en: "Tools" },
|
|
851
|
+
removeInstance: { "zh-CN": "移除本实例", en: "Remove this instance" },
|
|
852
|
+
close: { "zh-CN": "关闭", en: "Close" },
|
|
853
|
+
zones: { "zh-CN": "停靠方位", en: "Dock zones" },
|
|
854
|
+
defaultSuffix: { "zh-CN": "(默认)", en: " (default)" }
|
|
855
|
+
};
|
|
856
|
+
function menuWord(key) {
|
|
857
|
+
let loc = "en";
|
|
858
|
+
try {
|
|
859
|
+
loc = window.localStorage.getItem("pi-locale") || "en";
|
|
860
|
+
} catch {
|
|
861
|
+
}
|
|
862
|
+
const w = DOCK_MENU_WORDS[key];
|
|
863
|
+
return w[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
|
|
864
|
+
}
|
|
701
865
|
function dockIconEl(name, size = 16) {
|
|
702
866
|
return createElement(
|
|
703
867
|
"svg",
|
|
704
868
|
{ width: size, height: size, ...DOCK_ICON_SVG_ROOT_PROPS, "aria-hidden": "true" },
|
|
705
|
-
...DOCK_ICON_NODES[name].map((n, i) => createElement(n.tag, { key: i, ...n.attrs }))
|
|
869
|
+
...DOCK_ICON_NODES[name].map((n, i) => createElement(n.tag, { key: i, ...dockIconReactAttrs(n.attrs) }))
|
|
706
870
|
);
|
|
707
871
|
}
|
|
872
|
+
function maskedIconSpan(url, size) {
|
|
873
|
+
return createElement("span", { "aria-hidden": "true", style: {
|
|
874
|
+
display: "inline-block",
|
|
875
|
+
width: size,
|
|
876
|
+
height: size,
|
|
877
|
+
flexShrink: 0,
|
|
878
|
+
background: "currentColor",
|
|
879
|
+
WebkitMaskImage: `url("${url}")`,
|
|
880
|
+
maskImage: `url("${url}")`,
|
|
881
|
+
WebkitMaskRepeat: "no-repeat",
|
|
882
|
+
maskRepeat: "no-repeat",
|
|
883
|
+
WebkitMaskPosition: "center",
|
|
884
|
+
maskPosition: "center",
|
|
885
|
+
WebkitMaskSize: "contain",
|
|
886
|
+
maskSize: "contain"
|
|
887
|
+
} });
|
|
888
|
+
}
|
|
889
|
+
function dockIconFromDecl(icon, size = 13) {
|
|
890
|
+
if (icon == null) return null;
|
|
891
|
+
if (typeof icon === "object") {
|
|
892
|
+
const o = icon;
|
|
893
|
+
if (typeof o.svg === "string") {
|
|
894
|
+
return createElement("svg", {
|
|
895
|
+
width: size,
|
|
896
|
+
height: size,
|
|
897
|
+
viewBox: "0 0 24 24",
|
|
898
|
+
fill: "none",
|
|
899
|
+
stroke: "currentColor",
|
|
900
|
+
strokeWidth: 2,
|
|
901
|
+
strokeLinecap: "round",
|
|
902
|
+
strokeLinejoin: "round",
|
|
903
|
+
"aria-hidden": "true",
|
|
904
|
+
dangerouslySetInnerHTML: { __html: o.svg }
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
if (typeof o.url === "string") return maskedIconSpan(o.url, size);
|
|
908
|
+
return null;
|
|
909
|
+
}
|
|
910
|
+
if (typeof icon !== "string" || !icon) return null;
|
|
911
|
+
if (/^https?:\/\//.test(icon)) return maskedIconSpan(icon, size);
|
|
912
|
+
if (DOCK_ICON_NODES[icon]) return dockIconEl(icon, size);
|
|
913
|
+
if (icon.endsWith(".svg")) return null;
|
|
914
|
+
return createElement("span", { style: { fontSize: size, lineHeight: 1 } }, icon);
|
|
915
|
+
}
|
|
708
916
|
function headerStore() {
|
|
709
917
|
const api = floatApi();
|
|
710
918
|
const svc = api?.dockHeader;
|
|
@@ -778,7 +986,8 @@ function DockBody(props) {
|
|
|
778
986
|
if (m.height > below && above > below) top = b.top - gap - m.height;
|
|
779
987
|
const c2 = clampToViewport(b.right - m.width, top, m.width, m.height, pad);
|
|
780
988
|
const o = fixedOrigin(menuEl);
|
|
781
|
-
const
|
|
989
|
+
const z = zoomFactorOf(menuEl);
|
|
990
|
+
const next = { left: (c2.left - o.x) / z, top: (c2.top - o.y) / z };
|
|
782
991
|
setMenuPos((cur) => cur && cur.left === next.left && cur.top === next.top ? cur : next);
|
|
783
992
|
}, [menu, menuEl]);
|
|
784
993
|
useEffect(() => {
|
|
@@ -789,8 +998,23 @@ function DockBody(props) {
|
|
|
789
998
|
if (t2 && menu.anchor?.contains(t2)) return;
|
|
790
999
|
setMenu(null);
|
|
791
1000
|
};
|
|
1001
|
+
let anchorTop = null;
|
|
1002
|
+
let anchorLeft = null;
|
|
1003
|
+
try {
|
|
1004
|
+
const a = menu.anchor?.getBoundingClientRect?.();
|
|
1005
|
+
if (a) {
|
|
1006
|
+
anchorTop = a.top;
|
|
1007
|
+
anchorLeft = a.left;
|
|
1008
|
+
}
|
|
1009
|
+
} catch {
|
|
1010
|
+
}
|
|
792
1011
|
const onScroll = (e) => {
|
|
793
1012
|
if (menuEl && e.target instanceof Node && menuEl.contains(e.target)) return;
|
|
1013
|
+
try {
|
|
1014
|
+
const a = menu.anchor?.getBoundingClientRect?.();
|
|
1015
|
+
if (a && anchorTop !== null && anchorLeft !== null && Math.abs(a.top - anchorTop) < 4 && Math.abs(a.left - anchorLeft) < 4) return;
|
|
1016
|
+
} catch {
|
|
1017
|
+
}
|
|
794
1018
|
setMenu(null);
|
|
795
1019
|
};
|
|
796
1020
|
document.addEventListener("mousedown", onDown);
|
|
@@ -873,42 +1097,63 @@ function DockBody(props) {
|
|
|
873
1097
|
);
|
|
874
1098
|
const buildMainMenu = () => {
|
|
875
1099
|
const out = [];
|
|
1100
|
+
const sortable = kind !== "reserved";
|
|
1101
|
+
const buildMoveRow = () => ({
|
|
1102
|
+
type: "icons",
|
|
1103
|
+
label: menuWord("move"),
|
|
1104
|
+
icon: dockIconEl("move-diagonal-2", 13),
|
|
1105
|
+
items: [
|
|
1106
|
+
...props.moveRowPin ? [{
|
|
1107
|
+
key: "pin",
|
|
1108
|
+
icon: props.moveRowPin.isPinned() ? "pin-off" : "pin",
|
|
1109
|
+
label: props.moveRowPin.isPinned() ? menuWord("unpin") : menuWord("pin"),
|
|
1110
|
+
run: () => props.moveRowPin.toggle()
|
|
1111
|
+
}] : [],
|
|
1112
|
+
{ key: "move-up", icon: "chevron-up", label: menuWord("moveUp"), run: () => requestBlockMove(blockKey, -1) },
|
|
1113
|
+
{ key: "move-down", icon: "chevron-down", label: menuWord("moveDown"), run: () => requestBlockMove(blockKey, 1) }
|
|
1114
|
+
]
|
|
1115
|
+
});
|
|
876
1116
|
if (overflowActions.length > 0) {
|
|
877
|
-
out.push({ type: "head", label: "
|
|
1117
|
+
out.push({ type: "head", label: menuWord("tools") });
|
|
878
1118
|
for (const a of overflowActions) out.push({ type: "item", label: a.title, icon: a.icon, badge: a.badge, active: a.active, alwaysRun: true, disabled: a.disabled, run: a.onClick });
|
|
879
1119
|
}
|
|
880
1120
|
if (storeData.menuItems && storeData.menuItems.length > 0) {
|
|
881
1121
|
if (out.length > 0) out.push({ type: "sep" });
|
|
1122
|
+
let moveRowInserted = false;
|
|
882
1123
|
for (const m of storeData.menuItems) {
|
|
1124
|
+
if (m.kind === "moveRow" && sortable && !moveRowInserted) {
|
|
1125
|
+
moveRowInserted = true;
|
|
1126
|
+
out.push(buildMoveRow());
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
883
1129
|
if (m.kind === "head") out.push({ type: "head", label: m.label });
|
|
884
1130
|
else if (m.kind === "sep") out.push({ type: "sep" });
|
|
1131
|
+
else if (m.kind === "iconsRow") out.push({ type: "icons", label: m.label, items: m.items });
|
|
885
1132
|
else out.push({ type: "item", label: m.label, icon: m.icon, hint: m.hint, active: m.active, alwaysRun: m.alwaysRun, disabled: m.disabled, run: m.run });
|
|
886
1133
|
}
|
|
1134
|
+
if (chrome === "section" && sortable && !moveRowInserted) out.push(buildMoveRow());
|
|
887
1135
|
}
|
|
888
1136
|
const ops = [];
|
|
889
|
-
if (chrome === "section") {
|
|
890
|
-
ops.push(
|
|
891
|
-
{ key: "move-up", icon: "chevron-up", label: "上移", run: () => requestBlockMove(blockKey, -1) },
|
|
892
|
-
{ key: "move-down", icon: "chevron-down", label: "下移", run: () => requestBlockMove(blockKey, 1) }
|
|
893
|
-
] });
|
|
1137
|
+
if (chrome === "section" && sortable && !(storeData.menuItems || []).some((m) => m.kind === "moveRow")) {
|
|
1138
|
+
ops.push(buildMoveRow());
|
|
894
1139
|
}
|
|
895
1140
|
if (kind === "reserved" && typeof props.onRemove === "function") {
|
|
896
|
-
ops.push({ type: "item", label: "
|
|
1141
|
+
ops.push({ type: "item", label: menuWord("removeInstance"), icon: dockIconEl("trash", 13), run: () => props.onRemove() });
|
|
897
1142
|
}
|
|
898
1143
|
if (Array.isArray(props.extraMenuItems)) {
|
|
899
1144
|
for (const m of props.extraMenuItems) ops.push({ type: "item", label: m.label, icon: m.icon, hint: m.hint, active: m.active, alwaysRun: m.alwaysRun, run: m.run });
|
|
900
1145
|
}
|
|
901
|
-
if (kind === "dockable" && chrome === "section") {
|
|
902
|
-
ops.push({ type: "item", label: "
|
|
1146
|
+
if (kind === "dockable" && chrome === "section" && props.hideCloseItem !== true) {
|
|
1147
|
+
ops.push({ type: "item", label: menuWord("close"), icon: dockIconEl("x", 13), run: () => props.onClose ? props.onClose() : closePanel(itemKey) });
|
|
903
1148
|
}
|
|
904
1149
|
if (ops.length > 0) {
|
|
905
1150
|
if (out.length > 0) out.push({ type: "sep" });
|
|
906
|
-
out.push({ type: "head", label: "
|
|
1151
|
+
out.push({ type: "head", label: menuWord("block") });
|
|
907
1152
|
out.push(...ops);
|
|
908
1153
|
}
|
|
909
1154
|
return out;
|
|
910
1155
|
};
|
|
911
|
-
const positionRows = menu?.kind === "position" ? [{ type: "icons", label: "
|
|
1156
|
+
const positionRows = menu?.kind === "position" ? [{ type: "icons", label: menuWord("zones"), items: positionMenuModel(itemKey, allZones, defaultZone, state, { onNewWindow: props.onNewWindow }) }] : [];
|
|
912
1157
|
const menuRows = menu?.kind === "position" ? positionRows : menu?.kind === "main" ? buildMainMenu() : [];
|
|
913
1158
|
const renderMenuRow = (it, i) => {
|
|
914
1159
|
if (it.type === "sep") return createElement("div", { key: `sep-${i}`, style: { height: 1, background: "var(--border, #444)", margin: "3px 4px", opacity: 0.7, flexShrink: 0 } });
|
|
@@ -951,7 +1196,7 @@ function DockBody(props) {
|
|
|
951
1196
|
},
|
|
952
1197
|
...it.items.map((x, j) => {
|
|
953
1198
|
const isRadio = x.active === true || x.active === false;
|
|
954
|
-
const tip = x.isDefault ? `${x.label}
|
|
1199
|
+
const tip = x.isDefault ? `${x.label}${menuWord("defaultSuffix")}` : x.label;
|
|
955
1200
|
return createElement(
|
|
956
1201
|
"button",
|
|
957
1202
|
{
|
|
@@ -995,7 +1240,7 @@ function DockBody(props) {
|
|
|
995
1240
|
}
|
|
996
1241
|
}
|
|
997
1242
|
},
|
|
998
|
-
dockIconEl(x.icon, 16),
|
|
1243
|
+
typeof x.icon === "string" ? dockIconEl(x.icon, 16) : x.icon,
|
|
999
1244
|
x.isDefault ? createElement("span", { key: "dot", "data-ext-dock-icon-default": "1", style: { position: "absolute", top: 3, right: 3, width: 4, height: 4, borderRadius: "50%", background: "var(--accent, #2563eb)", pointerEvents: "none" } }) : null
|
|
1000
1245
|
);
|
|
1001
1246
|
})
|
|
@@ -1063,7 +1308,16 @@ function DockBody(props) {
|
|
|
1063
1308
|
// 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
|
|
1064
1309
|
...menuPos ? { left: menuPos.left, top: menuPos.top } : { left: -99999, top: -99999 }
|
|
1065
1310
|
},
|
|
1066
|
-
|
|
1311
|
+
// hover 关闭仅限真 hover 设备(2026-11-15 小屏反馈「菜单经常自己关掉」):手机上手指
|
|
1312
|
+
// 滑动浏览菜单项时浏览器合成 mouse 事件(touchmove 目标变化 → 合成 mouseleave),
|
|
1313
|
+
// 无条件关闭等于「一滑就关」;触屏(hover:none)忽略 mouseleave,改由外点/滚动关闭。
|
|
1314
|
+
onMouseLeave: () => {
|
|
1315
|
+
try {
|
|
1316
|
+
if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return;
|
|
1317
|
+
} catch {
|
|
1318
|
+
}
|
|
1319
|
+
setMenu(null);
|
|
1320
|
+
}
|
|
1067
1321
|
}, menuRows.map(renderMenuRow)) : null;
|
|
1068
1322
|
const toggleCollapsed = () => setCollapsed(!collapsed);
|
|
1069
1323
|
const onDragStart = (e) => {
|
|
@@ -1110,9 +1364,9 @@ function DockBody(props) {
|
|
|
1110
1364
|
if (e.target && typeof e.target.closest === "function" && e.target.closest("button")) return;
|
|
1111
1365
|
toggleCollapsed();
|
|
1112
1366
|
} };
|
|
1113
|
-
if (chrome === "section") {
|
|
1367
|
+
if (chrome === "section" && kind !== "reserved") {
|
|
1114
1368
|
headerProps.draggable = true;
|
|
1115
|
-
headerProps.title = "拖动排序";
|
|
1369
|
+
headerProps.title = props.headerHint ?? "拖动排序";
|
|
1116
1370
|
headerProps.onDragStart = onDragStart;
|
|
1117
1371
|
headerProps.onDragOver = (e) => {
|
|
1118
1372
|
if (isDockDrag(e) && dragKey !== blockKey) {
|
|
@@ -1133,8 +1387,16 @@ function DockBody(props) {
|
|
|
1133
1387
|
dragKey = null;
|
|
1134
1388
|
document.querySelectorAll(".pi-dock-drop-before, .pi-dock-drop-after").forEach((el) => el.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"));
|
|
1135
1389
|
};
|
|
1390
|
+
} else if (chrome === "section" && props.headerHint) {
|
|
1391
|
+
headerProps.title = props.headerHint;
|
|
1136
1392
|
}
|
|
1137
|
-
const
|
|
1393
|
+
const iconNode = dockIconFromDecl(props.icon, 13);
|
|
1394
|
+
const titleNode = createElement(
|
|
1395
|
+
"span",
|
|
1396
|
+
{ style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center", gap: 5 } },
|
|
1397
|
+
iconNode,
|
|
1398
|
+
props.renderTitle ? props.renderTitle() : createElement("span", { style: { fontSize: 13, fontWeight: 500, color: "var(--text, #222)", flex: "0 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, title ?? "")
|
|
1399
|
+
);
|
|
1138
1400
|
const keepAlive = collapsed && storeData.hasCommands;
|
|
1139
1401
|
return createElement(
|
|
1140
1402
|
"div",
|
|
@@ -1157,8 +1419,8 @@ function DockBody(props) {
|
|
|
1157
1419
|
"button",
|
|
1158
1420
|
{
|
|
1159
1421
|
type: "button",
|
|
1160
|
-
title: collapsed ? "
|
|
1161
|
-
"aria-label": (title ?? "
|
|
1422
|
+
title: collapsed ? menuWord("expand") : menuWord("collapse"),
|
|
1423
|
+
"aria-label": (title ?? menuWord("block")) + (collapsed ? " " + menuWord("expand") : " " + menuWord("collapse")),
|
|
1162
1424
|
"aria-expanded": collapsed ? "false" : "true",
|
|
1163
1425
|
style: { ...btnBase, display: "flex", alignItems: "center" },
|
|
1164
1426
|
onClick: toggleCollapsed
|
|
@@ -1189,8 +1451,8 @@ function DockBody(props) {
|
|
|
1189
1451
|
createElement("button", {
|
|
1190
1452
|
ref: setPosBtnEl,
|
|
1191
1453
|
type: "button",
|
|
1192
|
-
title: "
|
|
1193
|
-
"aria-label": "
|
|
1454
|
+
title: menuWord("position"),
|
|
1455
|
+
"aria-label": menuWord("position"),
|
|
1194
1456
|
"aria-haspopup": "menu",
|
|
1195
1457
|
"aria-expanded": menu?.kind === "position" ? "true" : "false",
|
|
1196
1458
|
style: { ...btnBase, fontSize: 12 },
|
|
@@ -1210,8 +1472,8 @@ function DockBody(props) {
|
|
|
1210
1472
|
createElement("button", {
|
|
1211
1473
|
ref: setMenuBtnEl,
|
|
1212
1474
|
type: "button",
|
|
1213
|
-
title: "
|
|
1214
|
-
"aria-label": "
|
|
1475
|
+
title: menuWord("actions"),
|
|
1476
|
+
"aria-label": menuWord("actions"),
|
|
1215
1477
|
"aria-haspopup": "menu",
|
|
1216
1478
|
"aria-expanded": menu?.kind === "main" ? "true" : "false",
|
|
1217
1479
|
style: { ...btnBase, fontSize: 12, fontWeight: 700 },
|
|
@@ -1333,6 +1595,10 @@ function useMoneyTick() {
|
|
|
1333
1595
|
};
|
|
1334
1596
|
}, []);
|
|
1335
1597
|
}
|
|
1598
|
+
function globToRegExp(pattern) {
|
|
1599
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[\\s\\S]*");
|
|
1600
|
+
return new RegExp("^" + escaped + "$", "i");
|
|
1601
|
+
}
|
|
1336
1602
|
const REPORT_KEY = "aiti-ai-usage:report";
|
|
1337
1603
|
const dedupeBy = (arr, key) => {
|
|
1338
1604
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3230,6 +3496,175 @@ const Loading = () => /* @__PURE__ */ jsx("div", { style: { padding: 32, textAli
|
|
|
3230
3496
|
const Empty = () => /* @__PURE__ */ jsx("div", { style: { padding: 20, textAlign: "center", color: "var(--text-dim)", fontSize: 12 }, children: t("au.empty") });
|
|
3231
3497
|
const Err = ({ msg }) => /* @__PURE__ */ jsx("div", { style: { padding: 24, color: "var(--danger, #f87171)", fontSize: 12 }, children: msg });
|
|
3232
3498
|
const PickHint = () => /* @__PURE__ */ jsx("div", { style: { padding: 24, textAlign: "center", color: "var(--text-dim)", fontSize: 12 }, children: t("au.range.pick") });
|
|
3499
|
+
function CatalogTab() {
|
|
3500
|
+
const cwd = (() => {
|
|
3501
|
+
try {
|
|
3502
|
+
const ui = extSvc?.("pi-web.ui");
|
|
3503
|
+
const v = ui?.get?.("selectedCwd");
|
|
3504
|
+
return typeof v === "string" && v ? v : "";
|
|
3505
|
+
} catch {
|
|
3506
|
+
return "";
|
|
3507
|
+
}
|
|
3508
|
+
})();
|
|
3509
|
+
const { data, err, reload } = useFetch("/catalog" + (cwd ? "?cwd=" + encodeURIComponent(cwd) : ""), []);
|
|
3510
|
+
const [busyKey, setBusyKey] = useState(null);
|
|
3511
|
+
const [openSrv, setOpenSrv] = useState(null);
|
|
3512
|
+
const cat = data && data.ok !== false ? data : null;
|
|
3513
|
+
const act = async (key, fn) => {
|
|
3514
|
+
setBusyKey(key);
|
|
3515
|
+
try {
|
|
3516
|
+
await fn();
|
|
3517
|
+
reload();
|
|
3518
|
+
} catch {
|
|
3519
|
+
} finally {
|
|
3520
|
+
setBusyKey(null);
|
|
3521
|
+
}
|
|
3522
|
+
};
|
|
3523
|
+
const toggleServer = (name, enabled) => act("srv:" + name, () => fetch(apiUrl("/api/mcp"), {
|
|
3524
|
+
method: "POST",
|
|
3525
|
+
headers: { "content-type": "application/json" },
|
|
3526
|
+
body: JSON.stringify({ action: enabled ? "enable" : "disable", scope: "global", name })
|
|
3527
|
+
}));
|
|
3528
|
+
const setExcluded = (server, nextPatterns) => act("srv:" + server.name, () => fetch(apiUrl("/api/mcp"), {
|
|
3529
|
+
method: "POST",
|
|
3530
|
+
headers: { "content-type": "application/json" },
|
|
3531
|
+
body: JSON.stringify({ action: "set-excluded-tools", scope: "global", name: server.name, excludeTools: nextPatterns })
|
|
3532
|
+
}));
|
|
3533
|
+
const excludeTool = (server, toolName) => {
|
|
3534
|
+
const cur = server.excludedPatterns || [];
|
|
3535
|
+
if (cur.some((p) => p.toLowerCase() === toolName.toLowerCase())) return;
|
|
3536
|
+
void setExcluded(server, [...cur, toolName]);
|
|
3537
|
+
};
|
|
3538
|
+
const restoreTool = (server, toolName) => {
|
|
3539
|
+
const cur = server.excludedPatterns || [];
|
|
3540
|
+
void setExcluded(server, cur.filter((p) => {
|
|
3541
|
+
try {
|
|
3542
|
+
return !globToRegExp(p).test(toolName);
|
|
3543
|
+
} catch {
|
|
3544
|
+
return true;
|
|
3545
|
+
}
|
|
3546
|
+
}));
|
|
3547
|
+
};
|
|
3548
|
+
const toggleSkill = (filePath, disabled) => act("sk:" + filePath, () => fetch(apiUrl("/api/skills"), {
|
|
3549
|
+
method: "PATCH",
|
|
3550
|
+
headers: { "content-type": "application/json" },
|
|
3551
|
+
body: JSON.stringify({ filePath, disableModelInvocation: disabled })
|
|
3552
|
+
}));
|
|
3553
|
+
if (err) return /* @__PURE__ */ jsx("div", { style: { padding: 16, color: "var(--danger, #ef4444)", fontSize: 12 }, children: err });
|
|
3554
|
+
if (!cat) return /* @__PURE__ */ jsx("div", { style: { padding: 16, color: "var(--text-muted)", fontSize: 12 }, children: t("ui.loading") });
|
|
3555
|
+
const thStyle = { textAlign: "left", padding: "4px 8px", borderBottom: "1px solid var(--border)", color: "var(--text-dim)", fontSize: 10.5, fontWeight: 600 };
|
|
3556
|
+
const tdStyle = { padding: "4px 8px", borderBottom: "1px solid var(--border)", fontSize: 11.5, verticalAlign: "top" };
|
|
3557
|
+
return /* @__PURE__ */ jsxs("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", padding: "10px 12px" }, children: [
|
|
3558
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "var(--text-muted)", marginBottom: 8, lineHeight: 1.5 }, children: t("au.catalog.intro", { n: cat.mcpTotalTools, tok: cat.mcpTotalTokens }) }),
|
|
3559
|
+
(cat.notes || []).map((note, i) => /* @__PURE__ */ jsxs("div", { style: { fontSize: 10.5, color: "var(--text-dim)", marginBottom: 4 }, children: [
|
|
3560
|
+
"· ",
|
|
3561
|
+
note
|
|
3562
|
+
] }, i)),
|
|
3563
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10, fontWeight: 600, letterSpacing: "0.06em", textTransform: "uppercase", color: "var(--text-dim)", margin: "8px 0 4px" }, children: t("au.catalog.mcp") }),
|
|
3564
|
+
/* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
3565
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: [t("au.catalog.server"), t("au.catalog.state"), t("au.catalog.tools"), t("au.catalog.estTok"), t("au.catalog.used30d"), ""].map((h, i) => /* @__PURE__ */ jsx("th", { style: thStyle, children: h }, i)) }) }),
|
|
3566
|
+
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
3567
|
+
(cat.mcp || []).map((s) => /* @__PURE__ */ jsx(
|
|
3568
|
+
CatalogMcpRow,
|
|
3569
|
+
{
|
|
3570
|
+
s,
|
|
3571
|
+
open: openSrv === s.name,
|
|
3572
|
+
onOpen: () => setOpenSrv(openSrv === s.name ? null : s.name),
|
|
3573
|
+
busy: busyKey === "srv:" + s.name,
|
|
3574
|
+
onToggle: () => toggleServer(s.name, !s.enabled),
|
|
3575
|
+
tdStyle,
|
|
3576
|
+
onExcludeTool: (tool) => excludeTool(s, tool),
|
|
3577
|
+
onRestoreTool: (tool) => restoreTool(s, tool),
|
|
3578
|
+
onDropPattern: (p) => setExcluded(s, (s.excludedPatterns || []).filter((x) => x !== p)),
|
|
3579
|
+
busyKey
|
|
3580
|
+
},
|
|
3581
|
+
s.name
|
|
3582
|
+
)),
|
|
3583
|
+
(cat.mcp || []).length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { style: tdStyle, colSpan: 6, children: t("au.catalog.noMcp") }) })
|
|
3584
|
+
] })
|
|
3585
|
+
] }),
|
|
3586
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10, fontWeight: 600, letterSpacing: "0.06em", textTransform: "uppercase", color: "var(--text-dim)", margin: "14px 0 4px" }, children: t("au.catalog.skills") }),
|
|
3587
|
+
/* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
3588
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: [t("au.catalog.skillName"), t("au.catalog.state"), t("au.catalog.used30d"), ""].map((h, i) => /* @__PURE__ */ jsx("th", { style: thStyle, children: h }, i)) }) }),
|
|
3589
|
+
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
3590
|
+
(cat.skills || []).map((sk) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
3591
|
+
/* @__PURE__ */ jsxs("td", { style: tdStyle, children: [
|
|
3592
|
+
/* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--font-mono)" }, children: sk.name }),
|
|
3593
|
+
sk.filePath ? /* @__PURE__ */ jsx("span", { title: sk.filePath, style: { fontSize: 10, color: "var(--text-dim)", marginLeft: 6 }, children: sk.filePath.split("/").slice(-2).join("/") }) : null
|
|
3594
|
+
] }),
|
|
3595
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: /* @__PURE__ */ jsx(
|
|
3596
|
+
"button",
|
|
3597
|
+
{
|
|
3598
|
+
disabled: busyKey === "sk:" + sk.filePath,
|
|
3599
|
+
onClick: () => toggleSkill(sk.filePath, !sk.disabled),
|
|
3600
|
+
style: { ...ghostBtn, padding: "1px 8px", fontSize: 10.5 },
|
|
3601
|
+
children: sk.disabled ? t("au.catalog.enable") : t("au.catalog.disable")
|
|
3602
|
+
}
|
|
3603
|
+
) }),
|
|
3604
|
+
/* @__PURE__ */ jsx("td", { style: { ...tdStyle, color: sk.calls30d === 0 ? "var(--text-dim)" : void 0 }, children: sk.calls30d }),
|
|
3605
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: sk.disabled ? /* @__PURE__ */ jsx("span", { style: { fontSize: 10, color: "var(--text-dim)" }, children: t("au.catalog.disabledNote") }) : null })
|
|
3606
|
+
] }, sk.filePath || sk.name)),
|
|
3607
|
+
(cat.skills || []).length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { style: tdStyle, colSpan: 4, children: t("au.catalog.noSkills") }) })
|
|
3608
|
+
] })
|
|
3609
|
+
] }),
|
|
3610
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "var(--text-dim)", marginTop: 10, lineHeight: 1.5 }, children: t("au.catalog.rules") })
|
|
3611
|
+
] });
|
|
3612
|
+
}
|
|
3613
|
+
function CatalogMcpRow({ s, open, onOpen, busy, onToggle, tdStyle, onExcludeTool, onRestoreTool, onDropPattern, busyKey }) {
|
|
3614
|
+
const globPatterns = (s.excludedPatterns || []).filter((p) => p.includes("*"));
|
|
3615
|
+
const chipStyle = { fontSize: 9.5, padding: "1px 6px", borderRadius: 4, border: "1px solid var(--border)", color: "var(--text-muted)", background: "none", cursor: "pointer" };
|
|
3616
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3617
|
+
/* @__PURE__ */ jsxs("tr", { children: [
|
|
3618
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: /* @__PURE__ */ jsxs("span", { role: "button", tabIndex: 0, onClick: onOpen, style: { cursor: "pointer", fontFamily: "var(--font-mono)", color: "var(--text)" }, children: [
|
|
3619
|
+
open ? "▾ " : "▸ ",
|
|
3620
|
+
s.name
|
|
3621
|
+
] }) }),
|
|
3622
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: /* @__PURE__ */ jsx("button", { disabled: busy, onClick: onToggle, style: { ...ghostBtn, padding: "1px 8px", fontSize: 10.5 }, children: busy ? "…" : s.enabled ? t("au.catalog.disable") : t("au.catalog.enable") }) }),
|
|
3623
|
+
/* @__PURE__ */ jsx("td", { style: { ...tdStyle, color: s.toolCount === 0 ? "var(--text-dim)" : void 0 }, children: s.toolCount }),
|
|
3624
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: s.estTokens ? `~${s.estTokens}` : "—" }),
|
|
3625
|
+
/* @__PURE__ */ jsx("td", { style: { ...tdStyle, color: s.calls30d === 0 ? "var(--danger, #ef4444)" : void 0 }, children: s.calls30d }),
|
|
3626
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: s.enabled ? "" : /* @__PURE__ */ jsx("span", { style: { fontSize: 10, color: "var(--text-dim)" }, children: t("au.catalog.disabledNote") }) })
|
|
3627
|
+
] }),
|
|
3628
|
+
open && globPatterns.length > 0 ? /* @__PURE__ */ jsx("tr", { style: { background: "var(--bg-hover)" }, children: /* @__PURE__ */ jsxs("td", { style: { ...tdStyle, paddingLeft: 26, fontSize: 10, color: "var(--text-dim)" }, colSpan: 6, children: [
|
|
3629
|
+
t("au.catalog.patterns"),
|
|
3630
|
+
":",
|
|
3631
|
+
globPatterns.map((p) => /* @__PURE__ */ jsxs(
|
|
3632
|
+
"button",
|
|
3633
|
+
{
|
|
3634
|
+
type: "button",
|
|
3635
|
+
title: t("au.catalog.dropPattern"),
|
|
3636
|
+
style: { ...chipStyle, marginRight: 4 },
|
|
3637
|
+
onClick: () => onDropPattern(p),
|
|
3638
|
+
children: [
|
|
3639
|
+
p,
|
|
3640
|
+
" ✕"
|
|
3641
|
+
]
|
|
3642
|
+
},
|
|
3643
|
+
p
|
|
3644
|
+
))
|
|
3645
|
+
] }) }) : null,
|
|
3646
|
+
open && (s.tools || []).map((tool) => /* @__PURE__ */ jsxs("tr", { style: { background: tool.excluded ? "color-mix(in srgb, var(--danger, #ef4444) 6%, transparent)" : "var(--bg-hover)" }, children: [
|
|
3647
|
+
/* @__PURE__ */ jsxs("td", { style: { ...tdStyle, paddingLeft: 26, fontFamily: "var(--font-mono)", fontSize: 10.5, color: tool.excluded ? "var(--text-dim)" : void 0 }, children: [
|
|
3648
|
+
tool.name,
|
|
3649
|
+
tool.excluded ? /* @__PURE__ */ jsx("span", { style: { fontSize: 9, color: "var(--text-dim)", marginLeft: 6, border: "1px solid var(--border)", borderRadius: 4, padding: "0 4px" }, children: t("au.catalog.excludedBadge") }) : null,
|
|
3650
|
+
tool.phantom ? /* @__PURE__ */ jsx("span", { title: t("au.catalog.phantomNote"), style: { fontSize: 9, color: "var(--text-dim)", marginLeft: 4 }, children: "?" }) : null
|
|
3651
|
+
] }),
|
|
3652
|
+
/* @__PURE__ */ jsx("td", { style: { ...tdStyle, fontSize: 10, color: "var(--text-dim)" }, colSpan: 3, children: t("au.catalog.toolMeta", { tok: tool.estTokens, n: tool.calls30d }) }),
|
|
3653
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle, children: /* @__PURE__ */ jsx(
|
|
3654
|
+
"button",
|
|
3655
|
+
{
|
|
3656
|
+
type: "button",
|
|
3657
|
+
disabled: busyKey === "srv:" + s.name,
|
|
3658
|
+
onClick: () => tool.excluded ? onRestoreTool(tool.name) : onExcludeTool(tool.name),
|
|
3659
|
+
title: tool.excluded ? t("au.catalog.restoreNote") : t("au.catalog.excludeNote"),
|
|
3660
|
+
style: { ...chipStyle, color: tool.excluded ? "var(--text)" : "var(--text-muted)" },
|
|
3661
|
+
children: busyKey === "srv:" + s.name ? "…" : tool.excluded ? t("au.catalog.restore") : t("au.catalog.exclude")
|
|
3662
|
+
}
|
|
3663
|
+
) }),
|
|
3664
|
+
/* @__PURE__ */ jsx("td", { style: tdStyle })
|
|
3665
|
+
] }, tool.name))
|
|
3666
|
+
] });
|
|
3667
|
+
}
|
|
3233
3668
|
function ReportBody({ inDock = false }) {
|
|
3234
3669
|
useMoneyTick();
|
|
3235
3670
|
const [tab, setTab] = useState("overview");
|
|
@@ -3247,7 +3682,8 @@ function ReportBody({ inDock = false }) {
|
|
|
3247
3682
|
["pivot", t("au.tabPivot")],
|
|
3248
3683
|
["trend", t("au.tabTrend")],
|
|
3249
3684
|
["input", t("au.tabInput")],
|
|
3250
|
-
["sessions", t("au.tabSessions")]
|
|
3685
|
+
["sessions", t("au.tabSessions")],
|
|
3686
|
+
["catalog", t("au.tabCatalog")]
|
|
3251
3687
|
];
|
|
3252
3688
|
const ranges = [
|
|
3253
3689
|
["today", t("au.range.today")],
|
|
@@ -3283,7 +3719,7 @@ function ReportBody({ inDock = false }) {
|
|
|
3283
3719
|
id
|
|
3284
3720
|
)) }),
|
|
3285
3721
|
/* @__PURE__ */ jsx("span", { style: { width: 1, height: 18, background: "var(--border)", margin: "0 4px" } }),
|
|
3286
|
-
tab !== "sessions" && tab !== "input" && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", alignItems: "center" }, children: [
|
|
3722
|
+
tab !== "sessions" && tab !== "input" && tab !== "catalog" && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", alignItems: "center" }, children: [
|
|
3287
3723
|
ranges.map(([id, label]) => /* @__PURE__ */ jsx(
|
|
3288
3724
|
"button",
|
|
3289
3725
|
{
|
|
@@ -3345,7 +3781,8 @@ function ReportBody({ inDock = false }) {
|
|
|
3345
3781
|
tab === "pivot" && /* @__PURE__ */ jsx(PivotTab, { range, custom, filters }),
|
|
3346
3782
|
tab === "trend" && /* @__PURE__ */ jsx(TrendTab, { range, custom, filters }, `td-${range}-${custom.from}~${custom.to}`),
|
|
3347
3783
|
tab === "input" && /* @__PURE__ */ jsx(InputTab, { range, custom }, `in-${range}-${custom.from}~${custom.to}`),
|
|
3348
|
-
tab === "sessions" && /* @__PURE__ */ jsx(SessionsTab, {})
|
|
3784
|
+
tab === "sessions" && /* @__PURE__ */ jsx(SessionsTab, {}),
|
|
3785
|
+
tab === "catalog" && /* @__PURE__ */ jsx(CatalogTab, {})
|
|
3349
3786
|
] })
|
|
3350
3787
|
] });
|
|
3351
3788
|
}
|
|
@@ -3470,10 +3907,10 @@ function ToolbarEntry() {
|
|
|
3470
3907
|
function register(ctx) {
|
|
3471
3908
|
__setCtx(ctx);
|
|
3472
3909
|
seedDockDefault(REPORT_KEY, "right-panel");
|
|
3473
|
-
ctx.registerItems?.("toolbar", [{ id: "usage", render: ToolbarEntry, meta: { label: "
|
|
3910
|
+
ctx.registerItems?.("toolbar", [{ id: "usage", render: ToolbarEntry, meta: { label: "i18n:au.app.label", icon: "icons/chart-column.svg", onClick: () => panel.open() } }]);
|
|
3474
3911
|
ctx.registerItems?.("sessionStats", [{ id: "report-entry", render: SessionStatsEntry }]);
|
|
3475
3912
|
ctx.registerItems?.("dialogs", [{ id: "report", render: UsageReport }]);
|
|
3476
|
-
ctx.registerItems?.("rightFileDock", [{ id: "report", render: ReportDockFace, meta: { title: "
|
|
3913
|
+
ctx.registerItems?.("rightFileDock", [{ id: "report", render: ReportDockFace, meta: { title: "i18n:it.report.title" } }]);
|
|
3477
3914
|
}
|
|
3478
3915
|
export {
|
|
3479
3916
|
register as default
|