dsh-workbench-message 0.1.0 → 0.1.1
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/lib/client.js +115 -12
- package/lib/index.js +1 -1
- package/package.json +4 -4
package/lib/client.js
CHANGED
|
@@ -3149,8 +3149,21 @@ var require_action_schema_style = __commonJS({
|
|
|
3149
3149
|
"." + P + " select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
|
|
3150
3150
|
"." + P + "-list{display:flex;flex-direction:column;gap:8px}",
|
|
3151
3151
|
"." + P + "-card{border:1px solid var(--wb-border,#e3e5e9);border-radius:10px;padding:10px 12px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));display:flex;flex-direction:column;gap:8px;min-width:0}",
|
|
3152
|
-
"." + P + "-cardhead{display:
|
|
3153
|
-
"." + P + "-
|
|
3152
|
+
"." + P + "-cardhead{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px}",
|
|
3153
|
+
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
3154
|
+
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
3155
|
+
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
3156
|
+
"." + P + "-toggle{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:0 2px;border:0;background:transparent;font:inherit;font-size:11.5px;color:var(--wb-muted);cursor:pointer}",
|
|
3157
|
+
"." + P + "-track{display:inline-flex;align-items:center;box-sizing:border-box;width:30px;height:18px;padding:2px;border:1px solid var(--wb-muted);border-radius:999px;background:var(--wb-surface);color:var(--wb-muted)}",
|
|
3158
|
+
"." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
|
|
3159
|
+
"." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
|
|
3160
|
+
"." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
|
|
3161
|
+
"." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
|
|
3162
|
+
"." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
3163
|
+
"." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
|
|
3164
|
+
"@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
|
|
3165
|
+
// 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
|
|
3166
|
+
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
3154
3167
|
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
|
|
3155
3168
|
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
3156
3169
|
"." + P + " mark." + P + "-hit{background:color-mix(in oklab,var(--dsw-alias-brand-primary,#4f6ef7) 22%,transparent);color:inherit;border-radius:2px;padding:0;font:inherit;box-decoration-break:clone;-webkit-box-decoration-break:clone}",
|
|
@@ -3202,6 +3215,15 @@ var require_action_schema_view = __commonJS({
|
|
|
3202
3215
|
zh: {
|
|
3203
3216
|
title: "Action",
|
|
3204
3217
|
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
3218
|
+
switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
|
|
3219
|
+
hostHint: "\u5BBF\u4E3B action \u7684 agent \u5F00\u5173\uFF1B\u6807\u300C\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F\u300D\u7684\u4E0D\u53EF\u653E\u5F00\u3002",
|
|
3220
|
+
agentSwitch: "agent \u53EF\u7528",
|
|
3221
|
+
agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
|
|
3222
|
+
agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
|
|
3223
|
+
agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
3224
|
+
agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
|
|
3225
|
+
agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
|
|
3226
|
+
agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
|
|
3205
3227
|
domain: "\u57DF",
|
|
3206
3228
|
versionLabel: "\u7248\u672C",
|
|
3207
3229
|
shell: "\u5BBF\u4E3B",
|
|
@@ -3247,6 +3269,15 @@ var require_action_schema_view = __commonJS({
|
|
|
3247
3269
|
en: {
|
|
3248
3270
|
title: "Actions",
|
|
3249
3271
|
hint: "runtime registry \xB7 read-only",
|
|
3272
|
+
switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
|
|
3273
|
+
hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
|
|
3274
|
+
agentSwitch: "Agent callable",
|
|
3275
|
+
agentLocked: "UI only \xB7 security",
|
|
3276
|
+
agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
|
|
3277
|
+
agentSaving: "Saving\u2026",
|
|
3278
|
+
agentOnToast: "Agent calls allowed",
|
|
3279
|
+
agentOffToast: "Agent calls blocked",
|
|
3280
|
+
agentFail: "Failed to change the agent switch",
|
|
3250
3281
|
domain: "Domain",
|
|
3251
3282
|
versionLabel: "Version",
|
|
3252
3283
|
shell: "Host",
|
|
@@ -3359,7 +3390,9 @@ var require_action_schema_view = __commonJS({
|
|
|
3359
3390
|
}
|
|
3360
3391
|
module2.exports = function createActionSchemaView(options) {
|
|
3361
3392
|
var raw = String(options.domain || "");
|
|
3362
|
-
var
|
|
3393
|
+
var SOURCE = options.source === "actions.list" ? "actions.list" : "actionSchema";
|
|
3394
|
+
var DOMAIN = SOURCE === "actions.list" ? raw : raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
|
|
3395
|
+
var LIST_DOMAIN = options.listDomain ? String(options.listDomain) : DOMAIN;
|
|
3363
3396
|
var prefix = options.prefix;
|
|
3364
3397
|
var P = prefix + "-as";
|
|
3365
3398
|
var Icon2 = options.Icon || null;
|
|
@@ -3403,6 +3436,8 @@ var require_action_schema_view = __commonJS({
|
|
|
3403
3436
|
var typePick = typeState[0], setTypePick = typeState[1];
|
|
3404
3437
|
var toastState = React.useState("");
|
|
3405
3438
|
var toast = toastState[0], setToast = toastState[1];
|
|
3439
|
+
var savingState = React.useState("");
|
|
3440
|
+
var saving = savingState[0], setSaving = savingState[1];
|
|
3406
3441
|
React.useEffect(function() {
|
|
3407
3442
|
injectCss();
|
|
3408
3443
|
}, []);
|
|
@@ -3411,9 +3446,10 @@ var require_action_schema_view = __commonJS({
|
|
|
3411
3446
|
setLoading(true);
|
|
3412
3447
|
setErr("");
|
|
3413
3448
|
var pending;
|
|
3414
|
-
var actionName = DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
|
|
3449
|
+
var actionName = SOURCE === "actions.list" ? "actions.list" : DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
|
|
3450
|
+
var callArgs = SOURCE === "actions.list" ? { detail: true, domain: LIST_DOMAIN } : void 0;
|
|
3415
3451
|
if (api && typeof api.call === "function") {
|
|
3416
|
-
pending = Promise.resolve(api.call(actionName)).then(function(r) {
|
|
3452
|
+
pending = Promise.resolve(api.call(actionName, callArgs)).then(function(r) {
|
|
3417
3453
|
if (r && r.ok === false) return r;
|
|
3418
3454
|
return r && r.result || r;
|
|
3419
3455
|
});
|
|
@@ -3453,6 +3489,39 @@ var require_action_schema_view = __commonJS({
|
|
|
3453
3489
|
plainCopy(text);
|
|
3454
3490
|
done();
|
|
3455
3491
|
}
|
|
3492
|
+
function setAgent(action, next) {
|
|
3493
|
+
var name = action.name;
|
|
3494
|
+
setSaving(name);
|
|
3495
|
+
setToast("");
|
|
3496
|
+
var fail = function(e) {
|
|
3497
|
+
setSaving("");
|
|
3498
|
+
setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
3499
|
+
};
|
|
3500
|
+
var done = function(r) {
|
|
3501
|
+
setSaving("");
|
|
3502
|
+
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
3503
|
+
if (r && r.ok === false) {
|
|
3504
|
+
setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
3505
|
+
return;
|
|
3506
|
+
}
|
|
3507
|
+
var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
|
|
3508
|
+
setSnap(function(prev) {
|
|
3509
|
+
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
3510
|
+
return Object.assign({}, prev, {
|
|
3511
|
+
actions: prev.actions.map(function(a) {
|
|
3512
|
+
if (!a || a.name !== name) return a;
|
|
3513
|
+
return Object.assign({}, a, { agentEnabled: value });
|
|
3514
|
+
})
|
|
3515
|
+
});
|
|
3516
|
+
});
|
|
3517
|
+
setToast(value ? t.agentOnToast : t.agentOffToast);
|
|
3518
|
+
};
|
|
3519
|
+
if (!api || typeof api.call !== "function") {
|
|
3520
|
+
fail(new Error("no call api"));
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
|
|
3524
|
+
}
|
|
3456
3525
|
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
3457
3526
|
return a && a.domain === DOMAIN;
|
|
3458
3527
|
}) : [];
|
|
@@ -3501,6 +3570,35 @@ var require_action_schema_view = __commonJS({
|
|
|
3501
3570
|
h("td", null, Highlight.hit(row.description, kw))
|
|
3502
3571
|
);
|
|
3503
3572
|
}
|
|
3573
|
+
function agentSwitch(action) {
|
|
3574
|
+
if (action.agentLocked === true) {
|
|
3575
|
+
return h("span", {
|
|
3576
|
+
className: P + "-badge " + P + "-locked",
|
|
3577
|
+
title: t.agentLockedHint,
|
|
3578
|
+
"data-agent-locked": action.name
|
|
3579
|
+
}, t.agentLocked);
|
|
3580
|
+
}
|
|
3581
|
+
if (typeof action.agentEnabled !== "boolean") return null;
|
|
3582
|
+
var busy = saving === action.name;
|
|
3583
|
+
return h(
|
|
3584
|
+
"button",
|
|
3585
|
+
{
|
|
3586
|
+
className: P + "-toggle",
|
|
3587
|
+
"data-agent-row": action.name,
|
|
3588
|
+
type: "button",
|
|
3589
|
+
role: "switch",
|
|
3590
|
+
"aria-checked": action.agentEnabled,
|
|
3591
|
+
disabled: busy,
|
|
3592
|
+
"data-agent-toggle": action.name,
|
|
3593
|
+
"aria-label": t.agentSwitch + " \xB7 " + action.name,
|
|
3594
|
+
onClick: function() {
|
|
3595
|
+
setAgent(action, !action.agentEnabled);
|
|
3596
|
+
}
|
|
3597
|
+
},
|
|
3598
|
+
h("span", { className: P + "-track", "aria-hidden": true }),
|
|
3599
|
+
h("span", null, busy ? t.agentSaving : t.agentSwitch)
|
|
3600
|
+
);
|
|
3601
|
+
}
|
|
3504
3602
|
function card(action) {
|
|
3505
3603
|
var rows = paramRows(action);
|
|
3506
3604
|
var examples = Array.isArray(action.examples) ? action.examples : [];
|
|
@@ -3510,12 +3608,16 @@ var require_action_schema_view = __commonJS({
|
|
|
3510
3608
|
h(
|
|
3511
3609
|
"div",
|
|
3512
3610
|
{ className: P + "-cardhead" },
|
|
3513
|
-
h(
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3611
|
+
h(
|
|
3612
|
+
"div",
|
|
3613
|
+
{ className: P + "-cardmeta" },
|
|
3614
|
+
h("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
|
|
3615
|
+
h("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
|
|
3616
|
+
rows.some(function(row) {
|
|
3617
|
+
return row.required;
|
|
3618
|
+
}) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
3619
|
+
),
|
|
3620
|
+
agentSwitch(action)
|
|
3519
3621
|
),
|
|
3520
3622
|
action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
3521
3623
|
rows.length ? h(
|
|
@@ -3592,6 +3694,7 @@ var require_action_schema_view = __commonJS({
|
|
|
3592
3694
|
h("span", { className: P + "-badge" }, t.count(visible.length, all.length)),
|
|
3593
3695
|
h("span", { className: P + "-none" }, t.hint)
|
|
3594
3696
|
),
|
|
3697
|
+
h("p", { className: P + "-hintline" }, SOURCE === "actions.list" ? t.hostHint : t.switchHint),
|
|
3595
3698
|
snap ? h(
|
|
3596
3699
|
"div",
|
|
3597
3700
|
{ className: P + "-toolbar" },
|
|
@@ -3771,7 +3874,7 @@ var init_message_square = __esm({
|
|
|
3771
3874
|
ensureStyles();
|
|
3772
3875
|
host.registerAddon({
|
|
3773
3876
|
id: "wb-addon-message",
|
|
3774
|
-
version: "0.1.
|
|
3877
|
+
version: "0.1.1",
|
|
3775
3878
|
icon: (init_message_square(), __toCommonJS(message_square_exports)).default,
|
|
3776
3879
|
views: [
|
|
3777
3880
|
{ id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: Stats },
|
package/lib/index.js
CHANGED
|
@@ -82,7 +82,7 @@ export function apply(ctx) {
|
|
|
82
82
|
id: "wb-addon-message",
|
|
83
83
|
title: "消息",
|
|
84
84
|
description: "统一消息入口:子插件与 agent 都能发消息,含未读计数、提示音与保留期清理;含统计、收件箱、配置、数据与 Action 五个视图",
|
|
85
|
-
version: "0.1.
|
|
85
|
+
version: "0.1.1",
|
|
86
86
|
tables: ["message"],
|
|
87
87
|
// 只在本机保存:显式声明不同步任何表(不写 sync 时宿主默认按行同步)。
|
|
88
88
|
sync: { tables: [] },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-message",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "个人工作台消息插件:统一消息发送入口、收件箱、未读统计与提示音",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"id": "wb-addon-message",
|
|
17
17
|
"title": "消息",
|
|
18
18
|
"description": "统一消息入口 + 统计/收件箱/配置/数据四个视图:子插件与 agent 都能发消息,带未读计数与提示音",
|
|
19
|
-
"version": "0.1.
|
|
20
|
-
"minShell": "0.
|
|
19
|
+
"version": "0.1.1",
|
|
20
|
+
"minShell": "0.8.0",
|
|
21
21
|
"tables": [
|
|
22
22
|
"message"
|
|
23
23
|
],
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"./package.json": "./package.json"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"dsh-workbench-host": "^0.
|
|
52
|
+
"dsh-workbench-host": "^0.8.0"
|
|
53
53
|
},
|
|
54
54
|
"dsh": {
|
|
55
55
|
"bundle": {
|