@aiti-ai/aiti-testagent-native 0.1.11 → 0.1.12
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/dev-pack.mjs +16 -3
- package/dist/aiti-testagent-native-client.mjs +294 -32
- package/index.ts +6 -2
- package/package.json +2 -2
- package/tools/build-client.mjs +2 -1
package/dev-pack.mjs
CHANGED
|
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
|
|
|
77
77
|
|
|
78
78
|
/** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
|
|
79
79
|
function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
|
|
80
|
-
|
|
80
|
+
// No hardcoded checkout path: candidates are resolved at run time (see repoCandidates below).
|
|
81
81
|
return `/**
|
|
82
82
|
* ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
|
|
83
83
|
* 用法:node tools/build.mjs
|
|
@@ -96,12 +96,25 @@ const entryRel = ${JSON.stringify(entryRel || "")};
|
|
|
96
96
|
|
|
97
97
|
// esbuild 解析:部署目录 node_modules → 源码仓 node_modules(本机开发场景)→ PATH 上的 esbuild → npm exec 现拉。
|
|
98
98
|
// 注意:node_modules/esbuild/bin/esbuild 是原生二进制(ELF/Mach-O),必须直接执行(不能当 JS 跑)。
|
|
99
|
+
// Checkout roots are discovered by walking up from the extension dir (a root has node_modules/),
|
|
100
|
+
// plus AITI_REPO_ROOT when set — no machine-specific absolute paths baked into generated files.
|
|
101
|
+
function repoCandidates() {
|
|
102
|
+
const out = [];
|
|
103
|
+
if (process.env.AITI_REPO_ROOT) out.push(process.env.AITI_REPO_ROOT.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
|
|
104
|
+
let d = extRoot;
|
|
105
|
+
for (let i = 0; i < 8; i++) {
|
|
106
|
+
out.push(d.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
|
|
107
|
+
const up = dirname(d);
|
|
108
|
+
if (up === d) break;
|
|
109
|
+
d = up;
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
99
113
|
function findEsbuild() {
|
|
100
114
|
const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
|
|
101
115
|
const candidates = [
|
|
102
116
|
extRoot + "/node_modules/esbuild/bin/esbuild",
|
|
103
|
-
|
|
104
|
-
"C:/workspace/aiti-ai/node_modules/esbuild/bin/esbuild", // windows dev box(源码在 D 盘)
|
|
117
|
+
...repoCandidates(),
|
|
105
118
|
];
|
|
106
119
|
for (const c of candidates) {
|
|
107
120
|
if (!existsSync(c)) continue;
|
|
@@ -42,6 +42,8 @@ function t(key, params) {
|
|
|
42
42
|
return typeof fn === "function" ? fn(key, params) : key;
|
|
43
43
|
}
|
|
44
44
|
function isFixedContainingBlock(cs) {
|
|
45
|
+
const zoomValue = parseFloat(cs.zoom || "");
|
|
46
|
+
if (Number.isFinite(zoomValue) && zoomValue !== 1) return true;
|
|
45
47
|
if (cs.transform !== "none" || cs.perspective !== "none" || cs.filter !== "none") return true;
|
|
46
48
|
if (/transform|perspective|filter/.test(cs.willChange || "")) return true;
|
|
47
49
|
const c2 = cs.contain;
|
|
@@ -61,6 +63,19 @@ function fixedOrigin(el) {
|
|
|
61
63
|
}
|
|
62
64
|
return { x: 0, y: 0 };
|
|
63
65
|
}
|
|
66
|
+
function zoomFactorOf(el) {
|
|
67
|
+
let z = 1;
|
|
68
|
+
let n = el.parentElement;
|
|
69
|
+
while (n && n !== document.documentElement) {
|
|
70
|
+
try {
|
|
71
|
+
const zoomValue = parseFloat(getComputedStyle(n).zoom || "");
|
|
72
|
+
if (Number.isFinite(zoomValue) && zoomValue > 0 && zoomValue !== 1) z *= zoomValue;
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
n = n.parentElement;
|
|
76
|
+
}
|
|
77
|
+
return z;
|
|
78
|
+
}
|
|
64
79
|
function clampToViewport(left, top, width, height, pad = 8) {
|
|
65
80
|
const vw = window.innerWidth;
|
|
66
81
|
const vh = window.innerHeight;
|
|
@@ -71,6 +86,7 @@ function clampToViewport(left, top, width, height, pad = 8) {
|
|
|
71
86
|
}
|
|
72
87
|
const P = (d) => ({ tag: "path", attrs: { d } });
|
|
73
88
|
const R = (x, y, width, height, rx = 2) => ({ tag: "rect", attrs: { x, y, width, height, rx } });
|
|
89
|
+
const thin = (n) => ({ ...n, attrs: { ...n.attrs, "stroke-width": 1.5 } });
|
|
74
90
|
const DOCK_ICON_NODES = {
|
|
75
91
|
/** 浮窗:圆角框 + 标题栏 + 圆点(app-window;用户 2026-09-15 定稿 C)。 */
|
|
76
92
|
float: [
|
|
@@ -104,6 +120,12 @@ const DOCK_ICON_NODES = {
|
|
|
104
120
|
],
|
|
105
121
|
/** 关闭:×(lucide x;⋮ 区块操作「关闭」)。 */
|
|
106
122
|
x: [P("M18 6 6 18"), P("m6 6 12 12")],
|
|
123
|
+
/** 取消钉住态:图钉 + 斜删除线(lucide pin-off;移动行钉住钮已钉态,与 MiPin 同语义族)。 */
|
|
124
|
+
"pin-off": [
|
|
125
|
+
{ tag: "line", attrs: { x1: 12, y1: 17, x2: 12, y2: 22 } },
|
|
126
|
+
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"),
|
|
127
|
+
{ tag: "line", attrs: { x1: 2, y1: 2, x2: 22, y2: 22 } }
|
|
128
|
+
],
|
|
107
129
|
/** 移除本实例:垃圾桶(lucide trash;多实例区块 ⋮「移除本实例」,与 aiti-folder MiTrash 同形)。 */
|
|
108
130
|
trash: [
|
|
109
131
|
{ tag: "polyline", attrs: { points: "3 6 5 6 21 6" } },
|
|
@@ -116,6 +138,89 @@ const DOCK_ICON_NODES = {
|
|
|
116
138
|
P("M5 11V5h6"),
|
|
117
139
|
P("M19 13v6h-6"),
|
|
118
140
|
P("M5 5l14 14")
|
|
141
|
+
],
|
|
142
|
+
/* ── Block semantic icons (collapsed-header icons; lucide line style) ── */
|
|
143
|
+
/** Projects block (session-manager projects): the aiti-ai logo as line art (chosen by
|
|
144
|
+
* the user 2026-11-26 from the icon candidates preview; prototype = aiti-docs
|
|
145
|
+
* docs/.vuepress/public/logo.svg). Three brand elements: large-rounded square (the
|
|
146
|
+
* gradient tile) + geometric letter a (circle + stem) + top-right spark (from the
|
|
147
|
+
* logo's yellow dot). Visual weight kept on par with the folder/file glyph family:
|
|
148
|
+
* the spark dot is stroked, not filled (a filled node reads much heavier at 13px),
|
|
149
|
+
* and the letter circle stays small so line density matches single-outline glyphs. */
|
|
150
|
+
"aiti-ai-logo": [
|
|
151
|
+
thin(R(3, 3, 18, 18, 4)),
|
|
152
|
+
thin({ tag: "circle", attrs: { cx: 10, cy: 14, r: 2.8 } }),
|
|
153
|
+
thin(P("M12.8 11.2v5.6")),
|
|
154
|
+
thin({ tag: "circle", attrs: { cx: 16.8, cy: 7.2, r: 1.2 } }),
|
|
155
|
+
thin(P("m18.8 5.3 1.5-1.6")),
|
|
156
|
+
thin(P("m19.2 8.2 2.1-.4"))
|
|
157
|
+
],
|
|
158
|
+
/** Folder block (aiti-folder faces): single folder (lucide folder). */
|
|
159
|
+
folder: [
|
|
160
|
+
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")
|
|
161
|
+
],
|
|
162
|
+
/** Scheduled tasks block (aiti-ai-schedule tasks): clock (lucide clock). */
|
|
163
|
+
clock: [
|
|
164
|
+
{ tag: "circle", attrs: { cx: 12, cy: 12, r: 10 } },
|
|
165
|
+
{ tag: "polyline", attrs: { points: "12 6 12 12 16 14" } }
|
|
166
|
+
],
|
|
167
|
+
/** Subagent fleet block (aiti-subagents fleet): robot (lucide bot). */
|
|
168
|
+
bot: [
|
|
169
|
+
P("M12 8V4H8"),
|
|
170
|
+
R(4, 8, 16, 12),
|
|
171
|
+
P("M2 14h2"),
|
|
172
|
+
P("M20 14h2"),
|
|
173
|
+
P("M15 13v2"),
|
|
174
|
+
P("M9 13v2")
|
|
175
|
+
],
|
|
176
|
+
/** Prompt library block (aiti-prompts panel): bookshelf lines (lucide library). */
|
|
177
|
+
library: [
|
|
178
|
+
P("m16 6 4 14"),
|
|
179
|
+
P("M12 6v14"),
|
|
180
|
+
P("M8 8v12"),
|
|
181
|
+
P("M4 4v16")
|
|
182
|
+
],
|
|
183
|
+
/** Model availability block (aiti-model-check panel): shield + check (lucide shield-check). */
|
|
184
|
+
"shield-check": [
|
|
185
|
+
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"),
|
|
186
|
+
P("m9 12 2 2 4-4")
|
|
187
|
+
],
|
|
188
|
+
/** Watch paths block (aiti-git-trace watch): branch (lucide git-branch). */
|
|
189
|
+
"git-branch": [
|
|
190
|
+
{ tag: "line", attrs: { x1: 6, y1: 3, x2: 6, y2: 15 } },
|
|
191
|
+
{ tag: "circle", attrs: { cx: 18, cy: 6, r: 3 } },
|
|
192
|
+
{ tag: "circle", attrs: { cx: 6, cy: 18, r: 3 } },
|
|
193
|
+
P("M18 9a9 9 0 0 1-9 9")
|
|
194
|
+
],
|
|
195
|
+
/** Timeline block (aiti-git-trace timeline): clock + counterclockwise arrow (lucide history). */
|
|
196
|
+
history: [
|
|
197
|
+
P("M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"),
|
|
198
|
+
P("M3 3v5h5"),
|
|
199
|
+
P("M12 7v5l4 2")
|
|
200
|
+
],
|
|
201
|
+
/** File panel block (aiti-editor file faces): document (lucide file). */
|
|
202
|
+
file: [
|
|
203
|
+
P("M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"),
|
|
204
|
+
P("M14 2v4a2 2 0 0 0 2 2h4")
|
|
205
|
+
],
|
|
206
|
+
/** ACP management block (aiti-acp-agent manage): plug (lucide plug). */
|
|
207
|
+
plug: [
|
|
208
|
+
P("M12 22v-5"),
|
|
209
|
+
P("M9 8V2"),
|
|
210
|
+
P("M15 8V2"),
|
|
211
|
+
P("M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z")
|
|
212
|
+
],
|
|
213
|
+
/** Speech recognition block (aiti-ai-input asr): microphone (lucide mic). */
|
|
214
|
+
mic: [
|
|
215
|
+
P("M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"),
|
|
216
|
+
P("M19 10v2a7 7 0 0 1-14 0v-2"),
|
|
217
|
+
{ tag: "line", attrs: { x1: 12, y1: 19, x2: 12, y2: 22 } }
|
|
218
|
+
],
|
|
219
|
+
/** Dock demo block (demo): 3D box (lucide box). */
|
|
220
|
+
box: [
|
|
221
|
+
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"),
|
|
222
|
+
P("m3.3 7 8.7 5 8.7-5"),
|
|
223
|
+
P("M12 22V12")
|
|
119
224
|
]
|
|
120
225
|
};
|
|
121
226
|
function dockIconOfZone(zone) {
|
|
@@ -151,6 +256,13 @@ const DOCK_ICON_SVG_ROOT_PROPS = {
|
|
|
151
256
|
strokeLinecap: "round",
|
|
152
257
|
strokeLinejoin: "round"
|
|
153
258
|
};
|
|
259
|
+
function dockIconReactAttrs(attrs) {
|
|
260
|
+
const out = {};
|
|
261
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
262
|
+
out[!k.includes("-") || k.startsWith("aria-") || k.startsWith("data-") ? k : k.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase())] = v;
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
154
266
|
function sidebarZoneOf(itemKey) {
|
|
155
267
|
return `sidebar:${itemKey}`;
|
|
156
268
|
}
|
|
@@ -178,6 +290,14 @@ function writeBlockCollapsed(blockKey, collapsed) {
|
|
|
178
290
|
} catch {
|
|
179
291
|
}
|
|
180
292
|
}
|
|
293
|
+
const SIDEBAR_DISMISS_PREFIX = "pi:sidebar-dock:dismissed:";
|
|
294
|
+
function writeBlockDismissed(blockKey, dismissed) {
|
|
295
|
+
try {
|
|
296
|
+
if (dismissed) localStorage.setItem(SIDEBAR_DISMISS_PREFIX + blockKey, "1");
|
|
297
|
+
else localStorage.removeItem(SIDEBAR_DISMISS_PREFIX + blockKey);
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
}
|
|
181
301
|
const FLOAT_INSTALLED_EVENT = "piwe-float-installed";
|
|
182
302
|
const DOCK_HEADER_PENDING_TTL = 1e4;
|
|
183
303
|
function actionSig(list) {
|
|
@@ -186,7 +306,7 @@ function actionSig(list) {
|
|
|
186
306
|
}
|
|
187
307
|
function menuSig(list) {
|
|
188
308
|
if (!list) return "";
|
|
189
|
-
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("§");
|
|
309
|
+
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("§");
|
|
190
310
|
}
|
|
191
311
|
function stateSig(s) {
|
|
192
312
|
try {
|
|
@@ -397,8 +517,10 @@ function localPresent(k, mode, opts) {
|
|
|
397
517
|
next = zone ? `docked:${zone}` : "floating";
|
|
398
518
|
}
|
|
399
519
|
} else if (mode === "float") next = "floating";
|
|
400
|
-
else if (mode === "close")
|
|
401
|
-
|
|
520
|
+
else if (mode === "close") {
|
|
521
|
+
next = "closed";
|
|
522
|
+
writeBlockDismissed(k, true);
|
|
523
|
+
} else if (mode.startsWith("dock:")) {
|
|
402
524
|
const zone = mode.slice(5);
|
|
403
525
|
try {
|
|
404
526
|
localStorage.setItem(DOCKPREF_KEY(k), zone);
|
|
@@ -406,6 +528,7 @@ function localPresent(k, mode, opts) {
|
|
|
406
528
|
}
|
|
407
529
|
next = `docked:${zone}`;
|
|
408
530
|
}
|
|
531
|
+
if (next !== "closed" && isSidebarDockState(next)) writeBlockDismissed(k, false);
|
|
409
532
|
if (next === prev) {
|
|
410
533
|
if (prev.startsWith("docked:")) {
|
|
411
534
|
try {
|
|
@@ -560,9 +683,24 @@ if (typeof window !== "undefined") {
|
|
|
560
683
|
} catch {
|
|
561
684
|
}
|
|
562
685
|
}
|
|
686
|
+
const DOCK_WORDS = {
|
|
687
|
+
newWindow: { "zh-CN": "新窗口打开", en: "Open in new window" },
|
|
688
|
+
float: { "zh-CN": "浮窗", en: "Float" },
|
|
689
|
+
zoneSidebar: { "zh-CN": "左栏 · 区块", en: "Left · blocks" },
|
|
690
|
+
zoneRight: { "zh-CN": "右栏 · 面板", en: "Right · panels" }
|
|
691
|
+
};
|
|
692
|
+
function dockWord(key) {
|
|
693
|
+
let loc = "en";
|
|
694
|
+
try {
|
|
695
|
+
loc = window.localStorage.getItem("pi-locale") || "en";
|
|
696
|
+
} catch {
|
|
697
|
+
}
|
|
698
|
+
const w = DOCK_WORDS[key];
|
|
699
|
+
return w[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
|
|
700
|
+
}
|
|
563
701
|
const DOCK_ZONE_LABELS = {
|
|
564
|
-
"sidebar-explorer": "
|
|
565
|
-
"right-panel": "
|
|
702
|
+
"sidebar-explorer": dockWord("zoneSidebar"),
|
|
703
|
+
"right-panel": dockWord("zoneRight")
|
|
566
704
|
};
|
|
567
705
|
function positionMenuItems(k, zones, defaultZone, cur) {
|
|
568
706
|
const hasSidebar = zones.some((z) => z === "sidebar-explorer" || z.startsWith("sidebar:"));
|
|
@@ -596,8 +734,8 @@ function positionMenuItems(k, zones, defaultZone, cur) {
|
|
|
596
734
|
function positionMenuModel(k, zones, defaultZone, cur, opts) {
|
|
597
735
|
const newWindow = opts?.onNewWindow ?? dockWindowOpenerOf(k);
|
|
598
736
|
return [
|
|
599
|
-
...newWindow ? [{ key: "new-window", icon: "new-window", label: "
|
|
600
|
-
{ key: "float", icon: "float", label: "
|
|
737
|
+
...newWindow ? [{ key: "new-window", icon: "new-window", label: dockWord("newWindow"), run: newWindow }] : [],
|
|
738
|
+
{ key: "float", icon: "float", label: dockWord("float"), active: cur === "floating", run: () => undockToFloat(k) },
|
|
601
739
|
...positionMenuItems(k, zones, defaultZone, cur)
|
|
602
740
|
];
|
|
603
741
|
}
|
|
@@ -693,13 +831,83 @@ function useGate(itemKey, face) {
|
|
|
693
831
|
if (face === "float") return state === "floating";
|
|
694
832
|
return state === `docked:${face.dock}`;
|
|
695
833
|
}
|
|
834
|
+
const DOCK_MENU_WORDS = {
|
|
835
|
+
expand: { "zh-CN": "展开", en: "Expand" },
|
|
836
|
+
collapse: { "zh-CN": "折叠", en: "Collapse" },
|
|
837
|
+
block: { "zh-CN": "区块", en: "Block" },
|
|
838
|
+
position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
|
|
839
|
+
actions: { "zh-CN": "区块操作", en: "Block actions" },
|
|
840
|
+
move: { "zh-CN": "移动", en: "Move" },
|
|
841
|
+
pin: { "zh-CN": "钉住", en: "Pin" },
|
|
842
|
+
unpin: { "zh-CN": "取消钉住", en: "Unpin" },
|
|
843
|
+
moveUp: { "zh-CN": "上移", en: "Move up" },
|
|
844
|
+
moveDown: { "zh-CN": "下移", en: "Move down" },
|
|
845
|
+
tools: { "zh-CN": "工具", en: "Tools" },
|
|
846
|
+
removeInstance: { "zh-CN": "移除本实例", en: "Remove this instance" },
|
|
847
|
+
close: { "zh-CN": "关闭", en: "Close" },
|
|
848
|
+
zones: { "zh-CN": "停靠方位", en: "Dock zones" },
|
|
849
|
+
defaultSuffix: { "zh-CN": "(默认)", en: " (default)" }
|
|
850
|
+
};
|
|
851
|
+
function menuWord(key) {
|
|
852
|
+
let loc = "en";
|
|
853
|
+
try {
|
|
854
|
+
loc = window.localStorage.getItem("pi-locale") || "en";
|
|
855
|
+
} catch {
|
|
856
|
+
}
|
|
857
|
+
const w = DOCK_MENU_WORDS[key];
|
|
858
|
+
return w[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
|
|
859
|
+
}
|
|
696
860
|
function dockIconEl(name, size = 16) {
|
|
697
861
|
return createElement(
|
|
698
862
|
"svg",
|
|
699
863
|
{ width: size, height: size, ...DOCK_ICON_SVG_ROOT_PROPS, "aria-hidden": "true" },
|
|
700
|
-
...DOCK_ICON_NODES[name].map((n, i) => createElement(n.tag, { key: i, ...n.attrs }))
|
|
864
|
+
...DOCK_ICON_NODES[name].map((n, i) => createElement(n.tag, { key: i, ...dockIconReactAttrs(n.attrs) }))
|
|
701
865
|
);
|
|
702
866
|
}
|
|
867
|
+
function maskedIconSpan(url, size) {
|
|
868
|
+
return createElement("span", { "aria-hidden": "true", style: {
|
|
869
|
+
display: "inline-block",
|
|
870
|
+
width: size,
|
|
871
|
+
height: size,
|
|
872
|
+
flexShrink: 0,
|
|
873
|
+
background: "currentColor",
|
|
874
|
+
WebkitMaskImage: `url("${url}")`,
|
|
875
|
+
maskImage: `url("${url}")`,
|
|
876
|
+
WebkitMaskRepeat: "no-repeat",
|
|
877
|
+
maskRepeat: "no-repeat",
|
|
878
|
+
WebkitMaskPosition: "center",
|
|
879
|
+
maskPosition: "center",
|
|
880
|
+
WebkitMaskSize: "contain",
|
|
881
|
+
maskSize: "contain"
|
|
882
|
+
} });
|
|
883
|
+
}
|
|
884
|
+
function dockIconFromDecl(icon, size = 13) {
|
|
885
|
+
if (icon == null) return null;
|
|
886
|
+
if (typeof icon === "object") {
|
|
887
|
+
const o = icon;
|
|
888
|
+
if (typeof o.svg === "string") {
|
|
889
|
+
return createElement("svg", {
|
|
890
|
+
width: size,
|
|
891
|
+
height: size,
|
|
892
|
+
viewBox: "0 0 24 24",
|
|
893
|
+
fill: "none",
|
|
894
|
+
stroke: "currentColor",
|
|
895
|
+
strokeWidth: 2,
|
|
896
|
+
strokeLinecap: "round",
|
|
897
|
+
strokeLinejoin: "round",
|
|
898
|
+
"aria-hidden": "true",
|
|
899
|
+
dangerouslySetInnerHTML: { __html: o.svg }
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
if (typeof o.url === "string") return maskedIconSpan(o.url, size);
|
|
903
|
+
return null;
|
|
904
|
+
}
|
|
905
|
+
if (typeof icon !== "string" || !icon) return null;
|
|
906
|
+
if (/^https?:\/\//.test(icon)) return maskedIconSpan(icon, size);
|
|
907
|
+
if (DOCK_ICON_NODES[icon]) return dockIconEl(icon, size);
|
|
908
|
+
if (icon.endsWith(".svg")) return null;
|
|
909
|
+
return createElement("span", { style: { fontSize: size, lineHeight: 1 } }, icon);
|
|
910
|
+
}
|
|
703
911
|
function headerStore() {
|
|
704
912
|
const api2 = floatApi();
|
|
705
913
|
const svc = api2?.dockHeader;
|
|
@@ -773,7 +981,8 @@ function DockBody(props) {
|
|
|
773
981
|
if (m.height > below && above > below) top = b.top - gap - m.height;
|
|
774
982
|
const c2 = clampToViewport(b.right - m.width, top, m.width, m.height, pad);
|
|
775
983
|
const o = fixedOrigin(menuEl);
|
|
776
|
-
const
|
|
984
|
+
const z = zoomFactorOf(menuEl);
|
|
985
|
+
const next = { left: (c2.left - o.x) / z, top: (c2.top - o.y) / z };
|
|
777
986
|
setMenuPos((cur) => cur && cur.left === next.left && cur.top === next.top ? cur : next);
|
|
778
987
|
}, [menu, menuEl]);
|
|
779
988
|
useEffect(() => {
|
|
@@ -784,8 +993,23 @@ function DockBody(props) {
|
|
|
784
993
|
if (t2 && menu.anchor?.contains(t2)) return;
|
|
785
994
|
setMenu(null);
|
|
786
995
|
};
|
|
996
|
+
let anchorTop = null;
|
|
997
|
+
let anchorLeft = null;
|
|
998
|
+
try {
|
|
999
|
+
const a = menu.anchor?.getBoundingClientRect?.();
|
|
1000
|
+
if (a) {
|
|
1001
|
+
anchorTop = a.top;
|
|
1002
|
+
anchorLeft = a.left;
|
|
1003
|
+
}
|
|
1004
|
+
} catch {
|
|
1005
|
+
}
|
|
787
1006
|
const onScroll = (e) => {
|
|
788
1007
|
if (menuEl && e.target instanceof Node && menuEl.contains(e.target)) return;
|
|
1008
|
+
try {
|
|
1009
|
+
const a = menu.anchor?.getBoundingClientRect?.();
|
|
1010
|
+
if (a && anchorTop !== null && anchorLeft !== null && Math.abs(a.top - anchorTop) < 4 && Math.abs(a.left - anchorLeft) < 4) return;
|
|
1011
|
+
} catch {
|
|
1012
|
+
}
|
|
789
1013
|
setMenu(null);
|
|
790
1014
|
};
|
|
791
1015
|
document.addEventListener("mousedown", onDown);
|
|
@@ -868,42 +1092,63 @@ function DockBody(props) {
|
|
|
868
1092
|
);
|
|
869
1093
|
const buildMainMenu = () => {
|
|
870
1094
|
const out = [];
|
|
1095
|
+
const sortable = kind !== "reserved";
|
|
1096
|
+
const buildMoveRow = () => ({
|
|
1097
|
+
type: "icons",
|
|
1098
|
+
label: menuWord("move"),
|
|
1099
|
+
icon: dockIconEl("move-diagonal-2", 13),
|
|
1100
|
+
items: [
|
|
1101
|
+
...props.moveRowPin ? [{
|
|
1102
|
+
key: "pin",
|
|
1103
|
+
icon: props.moveRowPin.isPinned() ? "pin-off" : "pin",
|
|
1104
|
+
label: props.moveRowPin.isPinned() ? menuWord("unpin") : menuWord("pin"),
|
|
1105
|
+
run: () => props.moveRowPin.toggle()
|
|
1106
|
+
}] : [],
|
|
1107
|
+
{ key: "move-up", icon: "chevron-up", label: menuWord("moveUp"), run: () => requestBlockMove(blockKey, -1) },
|
|
1108
|
+
{ key: "move-down", icon: "chevron-down", label: menuWord("moveDown"), run: () => requestBlockMove(blockKey, 1) }
|
|
1109
|
+
]
|
|
1110
|
+
});
|
|
871
1111
|
if (overflowActions.length > 0) {
|
|
872
|
-
out.push({ type: "head", label: "
|
|
1112
|
+
out.push({ type: "head", label: menuWord("tools") });
|
|
873
1113
|
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 });
|
|
874
1114
|
}
|
|
875
1115
|
if (storeData.menuItems && storeData.menuItems.length > 0) {
|
|
876
1116
|
if (out.length > 0) out.push({ type: "sep" });
|
|
1117
|
+
let moveRowInserted = false;
|
|
877
1118
|
for (const m of storeData.menuItems) {
|
|
1119
|
+
if (m.kind === "moveRow" && sortable && !moveRowInserted) {
|
|
1120
|
+
moveRowInserted = true;
|
|
1121
|
+
out.push(buildMoveRow());
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
878
1124
|
if (m.kind === "head") out.push({ type: "head", label: m.label });
|
|
879
1125
|
else if (m.kind === "sep") out.push({ type: "sep" });
|
|
1126
|
+
else if (m.kind === "iconsRow") out.push({ type: "icons", label: m.label, items: m.items });
|
|
880
1127
|
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 });
|
|
881
1128
|
}
|
|
1129
|
+
if (chrome === "section" && sortable && !moveRowInserted) out.push(buildMoveRow());
|
|
882
1130
|
}
|
|
883
1131
|
const ops = [];
|
|
884
|
-
if (chrome === "section") {
|
|
885
|
-
ops.push(
|
|
886
|
-
{ key: "move-up", icon: "chevron-up", label: "上移", run: () => requestBlockMove(blockKey, -1) },
|
|
887
|
-
{ key: "move-down", icon: "chevron-down", label: "下移", run: () => requestBlockMove(blockKey, 1) }
|
|
888
|
-
] });
|
|
1132
|
+
if (chrome === "section" && sortable && !(storeData.menuItems || []).some((m) => m.kind === "moveRow")) {
|
|
1133
|
+
ops.push(buildMoveRow());
|
|
889
1134
|
}
|
|
890
1135
|
if (kind === "reserved" && typeof props.onRemove === "function") {
|
|
891
|
-
ops.push({ type: "item", label: "
|
|
1136
|
+
ops.push({ type: "item", label: menuWord("removeInstance"), icon: dockIconEl("trash", 13), run: () => props.onRemove() });
|
|
892
1137
|
}
|
|
893
1138
|
if (Array.isArray(props.extraMenuItems)) {
|
|
894
1139
|
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 });
|
|
895
1140
|
}
|
|
896
|
-
if (kind === "dockable" && chrome === "section") {
|
|
897
|
-
ops.push({ type: "item", label: "
|
|
1141
|
+
if (kind === "dockable" && chrome === "section" && props.hideCloseItem !== true) {
|
|
1142
|
+
ops.push({ type: "item", label: menuWord("close"), icon: dockIconEl("x", 13), run: () => props.onClose ? props.onClose() : closePanel(itemKey) });
|
|
898
1143
|
}
|
|
899
1144
|
if (ops.length > 0) {
|
|
900
1145
|
if (out.length > 0) out.push({ type: "sep" });
|
|
901
|
-
out.push({ type: "head", label: "
|
|
1146
|
+
out.push({ type: "head", label: menuWord("block") });
|
|
902
1147
|
out.push(...ops);
|
|
903
1148
|
}
|
|
904
1149
|
return out;
|
|
905
1150
|
};
|
|
906
|
-
const positionRows = menu?.kind === "position" ? [{ type: "icons", label: "
|
|
1151
|
+
const positionRows = menu?.kind === "position" ? [{ type: "icons", label: menuWord("zones"), items: positionMenuModel(itemKey, allZones, defaultZone, state, { onNewWindow: props.onNewWindow }) }] : [];
|
|
907
1152
|
const menuRows = menu?.kind === "position" ? positionRows : menu?.kind === "main" ? buildMainMenu() : [];
|
|
908
1153
|
const renderMenuRow = (it, i) => {
|
|
909
1154
|
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 } });
|
|
@@ -946,7 +1191,7 @@ function DockBody(props) {
|
|
|
946
1191
|
},
|
|
947
1192
|
...it.items.map((x, j) => {
|
|
948
1193
|
const isRadio = x.active === true || x.active === false;
|
|
949
|
-
const tip = x.isDefault ? `${x.label}
|
|
1194
|
+
const tip = x.isDefault ? `${x.label}${menuWord("defaultSuffix")}` : x.label;
|
|
950
1195
|
return createElement(
|
|
951
1196
|
"button",
|
|
952
1197
|
{
|
|
@@ -990,7 +1235,7 @@ function DockBody(props) {
|
|
|
990
1235
|
}
|
|
991
1236
|
}
|
|
992
1237
|
},
|
|
993
|
-
dockIconEl(x.icon, 16),
|
|
1238
|
+
typeof x.icon === "string" ? dockIconEl(x.icon, 16) : x.icon,
|
|
994
1239
|
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
|
|
995
1240
|
);
|
|
996
1241
|
})
|
|
@@ -1058,7 +1303,16 @@ function DockBody(props) {
|
|
|
1058
1303
|
// 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
|
|
1059
1304
|
...menuPos ? { left: menuPos.left, top: menuPos.top } : { left: -99999, top: -99999 }
|
|
1060
1305
|
},
|
|
1061
|
-
|
|
1306
|
+
// hover 关闭仅限真 hover 设备(2026-11-15 小屏反馈「菜单经常自己关掉」):手机上手指
|
|
1307
|
+
// 滑动浏览菜单项时浏览器合成 mouse 事件(touchmove 目标变化 → 合成 mouseleave),
|
|
1308
|
+
// 无条件关闭等于「一滑就关」;触屏(hover:none)忽略 mouseleave,改由外点/滚动关闭。
|
|
1309
|
+
onMouseLeave: () => {
|
|
1310
|
+
try {
|
|
1311
|
+
if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return;
|
|
1312
|
+
} catch {
|
|
1313
|
+
}
|
|
1314
|
+
setMenu(null);
|
|
1315
|
+
}
|
|
1062
1316
|
}, menuRows.map(renderMenuRow)) : null;
|
|
1063
1317
|
const toggleCollapsed = () => setCollapsed(!collapsed);
|
|
1064
1318
|
const onDragStart = (e) => {
|
|
@@ -1105,9 +1359,9 @@ function DockBody(props) {
|
|
|
1105
1359
|
if (e.target && typeof e.target.closest === "function" && e.target.closest("button")) return;
|
|
1106
1360
|
toggleCollapsed();
|
|
1107
1361
|
} };
|
|
1108
|
-
if (chrome === "section") {
|
|
1362
|
+
if (chrome === "section" && kind !== "reserved") {
|
|
1109
1363
|
headerProps.draggable = true;
|
|
1110
|
-
headerProps.title = "拖动排序";
|
|
1364
|
+
headerProps.title = props.headerHint ?? "拖动排序";
|
|
1111
1365
|
headerProps.onDragStart = onDragStart;
|
|
1112
1366
|
headerProps.onDragOver = (e) => {
|
|
1113
1367
|
if (isDockDrag(e) && dragKey !== blockKey) {
|
|
@@ -1128,8 +1382,16 @@ function DockBody(props) {
|
|
|
1128
1382
|
dragKey = null;
|
|
1129
1383
|
document.querySelectorAll(".pi-dock-drop-before, .pi-dock-drop-after").forEach((el) => el.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"));
|
|
1130
1384
|
};
|
|
1385
|
+
} else if (chrome === "section" && props.headerHint) {
|
|
1386
|
+
headerProps.title = props.headerHint;
|
|
1131
1387
|
}
|
|
1132
|
-
const
|
|
1388
|
+
const iconNode = dockIconFromDecl(props.icon, 13);
|
|
1389
|
+
const titleNode = createElement(
|
|
1390
|
+
"span",
|
|
1391
|
+
{ style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center", gap: 5 } },
|
|
1392
|
+
iconNode,
|
|
1393
|
+
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 ?? "")
|
|
1394
|
+
);
|
|
1133
1395
|
const keepAlive = collapsed && storeData.hasCommands;
|
|
1134
1396
|
return createElement(
|
|
1135
1397
|
"div",
|
|
@@ -1152,8 +1414,8 @@ function DockBody(props) {
|
|
|
1152
1414
|
"button",
|
|
1153
1415
|
{
|
|
1154
1416
|
type: "button",
|
|
1155
|
-
title: collapsed ? "
|
|
1156
|
-
"aria-label": (title ?? "
|
|
1417
|
+
title: collapsed ? menuWord("expand") : menuWord("collapse"),
|
|
1418
|
+
"aria-label": (title ?? menuWord("block")) + (collapsed ? " " + menuWord("expand") : " " + menuWord("collapse")),
|
|
1157
1419
|
"aria-expanded": collapsed ? "false" : "true",
|
|
1158
1420
|
style: { ...btnBase, display: "flex", alignItems: "center" },
|
|
1159
1421
|
onClick: toggleCollapsed
|
|
@@ -1184,8 +1446,8 @@ function DockBody(props) {
|
|
|
1184
1446
|
createElement("button", {
|
|
1185
1447
|
ref: setPosBtnEl,
|
|
1186
1448
|
type: "button",
|
|
1187
|
-
title: "
|
|
1188
|
-
"aria-label": "
|
|
1449
|
+
title: menuWord("position"),
|
|
1450
|
+
"aria-label": menuWord("position"),
|
|
1189
1451
|
"aria-haspopup": "menu",
|
|
1190
1452
|
"aria-expanded": menu?.kind === "position" ? "true" : "false",
|
|
1191
1453
|
style: { ...btnBase, fontSize: 12 },
|
|
@@ -1205,8 +1467,8 @@ function DockBody(props) {
|
|
|
1205
1467
|
createElement("button", {
|
|
1206
1468
|
ref: setMenuBtnEl,
|
|
1207
1469
|
type: "button",
|
|
1208
|
-
title: "
|
|
1209
|
-
"aria-label": "
|
|
1470
|
+
title: menuWord("actions"),
|
|
1471
|
+
"aria-label": menuWord("actions"),
|
|
1210
1472
|
"aria-haspopup": "menu",
|
|
1211
1473
|
"aria-expanded": menu?.kind === "main" ? "true" : "false",
|
|
1212
1474
|
style: { ...btnBase, fontSize: 12, fontWeight: 700 },
|
package/index.ts
CHANGED
|
@@ -134,12 +134,15 @@ export default {
|
|
|
134
134
|
},
|
|
135
135
|
|
|
136
136
|
ui: {
|
|
137
|
-
toolbar: [{ id: "testagent-native", label: "Win", title: "
|
|
137
|
+
toolbar: [{ id: "testagent-native", label: "Win", title: "i18n:wt.title", icon: "icons/monitor.svg" }],
|
|
138
138
|
rightFileDock: [{ id: "panel", label: "Win" }],
|
|
139
|
-
dialogs: [{ id: "panel", label: "
|
|
139
|
+
dialogs: [{ id: "panel", label: "i18n:it.panel.label" }],
|
|
140
140
|
clientImmediately: false,
|
|
141
141
|
i18n: {
|
|
142
142
|
en: {
|
|
143
|
+
"it.panel.label": "testagent-native trace panel",
|
|
144
|
+
"ext.displayName": "testagent-native (Windows API/COM trace panel)",
|
|
145
|
+
"feat.panel": "testagent-native trace panel",
|
|
143
146
|
"wt.title": "testagent-native · Windows Native Trace",
|
|
144
147
|
"wt.broker": "Broker",
|
|
145
148
|
"wt.sessions": "Sessions",
|
|
@@ -155,6 +158,7 @@ export default {
|
|
|
155
158
|
"wt.offline": "broker offline (start testagent-native-broker, default 127.0.0.1:8766)",
|
|
156
159
|
},
|
|
157
160
|
"zh-CN": {
|
|
161
|
+
"it.panel.label": "testagent-native 追踪面板",
|
|
158
162
|
"wt.title": "testagent-native · Windows 原生追踪",
|
|
159
163
|
"wt.broker": "Broker",
|
|
160
164
|
"wt.sessions": "会话",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiti-ai/aiti-testagent-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Visual panel for testagent-native (live Windows-native process control) — broker processes/sessions/hooks/event stream; formerly aiti-wintrace (renamed 2026-11-07)",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"aitiExtProtocol": "1.0",
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"contentHash": "
|
|
15
|
+
"contentHash": "2d1a3581ec3dffd2",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "git+https://github.com/aiti-ai/aiti-ai.git",
|
package/tools/build-client.mjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 用法:node tools/build-client.mjs (或 npm run watch 自动重建)
|
|
7
7
|
*/
|
|
8
8
|
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
9
10
|
import { resolve } from "node:path";
|
|
10
11
|
import { fileURLToPath } from "node:url";
|
|
11
12
|
import { existsSync } from "node:fs";
|
|
@@ -13,7 +14,7 @@ import { existsSync } from "node:fs";
|
|
|
13
14
|
const root = resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
14
15
|
|
|
15
16
|
const viteJs = resolve(root, "node_modules", "vite", "bin", "vite.js");
|
|
16
|
-
const viteBin = existsSync(viteJs) ? viteJs : "vite";
|
|
17
|
+
const viteBin = existsSync(viteJs) ? viteJs : resolve(createRequire(import.meta.url).resolve("vite/package.json"), "..", "bin", "vite.js");
|
|
17
18
|
|
|
18
19
|
const r = spawnSync(process.execPath, [viteBin, "build", "--config", resolve(root, "vite.config.ts")], {
|
|
19
20
|
cwd: root,
|