dsh-plugin-mesh 0.5.8 → 0.5.9
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.en.md +28 -9
- package/README.md +77 -1038
- package/client/client.js +358 -8
- package/cordis.patch.yml +6 -0
- package/lib/_selftest-approval.mjs +165 -0
- package/lib/_selftest-capabilities.mjs +11 -7
- package/lib/_selftest-reply-route.mjs +11 -0
- package/lib/_selftest-update.mjs +11 -3
- package/lib/_selftest-upgrade.mjs +5 -1
- package/lib/_selftest-workbench.mjs +33 -0
- package/lib/approval.js +152 -0
- package/lib/index.js +214 -4
- package/llms.txt +20 -2
- package/package.json +9 -8
- package/scripts/check-tdz.mjs +53 -8
package/client/client.js
CHANGED
|
@@ -1094,6 +1094,12 @@ window.__ModuleLoader__.load({
|
|
|
1094
1094
|
.mesh-chip.is-muted { background: transparent; border: 1px solid var(--mesh-line); color: var(--mesh-muted); }
|
|
1095
1095
|
.mesh-chip-label { color: var(--mesh-muted); }
|
|
1096
1096
|
.mesh-chip-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; }
|
|
1097
|
+
.mesh-chip-btn {
|
|
1098
|
+
cursor: pointer; border: 1px solid var(--mesh-line);
|
|
1099
|
+
background: transparent; color: var(--mesh-fg);
|
|
1100
|
+
transition: border-color 140ms ease, background 140ms ease;
|
|
1101
|
+
}
|
|
1102
|
+
.mesh-chip-btn:hover { border-color: var(--mesh-line-2); background: var(--mesh-surface-2); }
|
|
1097
1103
|
.mesh-specs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--mesh-muted); }
|
|
1098
1104
|
.mesh-text-btn {
|
|
1099
1105
|
align-self: flex-start; border: 0; background: transparent;
|
|
@@ -1610,6 +1616,84 @@ window.__ModuleLoader__.load({
|
|
|
1610
1616
|
.mesh-home-empty p { margin: 0 0 12px; font-size: 12px; color: var(--mesh-muted); }
|
|
1611
1617
|
.mesh-home .mesh-firstrun { margin: 0 0 16px; }
|
|
1612
1618
|
|
|
1619
|
+
/* ── 演示(单机也能看见完整闭环) ── */
|
|
1620
|
+
.mesh-demo-layer {
|
|
1621
|
+
position: absolute; inset: 0; z-index: 50;
|
|
1622
|
+
display: flex; align-items: center; justify-content: center;
|
|
1623
|
+
padding: 22px;
|
|
1624
|
+
background: rgba(12, 14, 18, .46);
|
|
1625
|
+
animation: mesh-view-in 160ms ease both;
|
|
1626
|
+
}
|
|
1627
|
+
.mesh-demo-card {
|
|
1628
|
+
width: min(560px, 100%); max-height: min(88vh, 780px);
|
|
1629
|
+
display: flex; flex-direction: column;
|
|
1630
|
+
background: var(--mesh-surface);
|
|
1631
|
+
color: var(--mesh-fg);
|
|
1632
|
+
border: 1px solid var(--mesh-line);
|
|
1633
|
+
border-radius: 18px;
|
|
1634
|
+
box-shadow: 0 24px 80px rgba(0,0,0,.34);
|
|
1635
|
+
overflow: hidden;
|
|
1636
|
+
animation: mesh-detail-in 220ms var(--mesh-ease-out) both;
|
|
1637
|
+
}
|
|
1638
|
+
.mesh-demo-head {
|
|
1639
|
+
flex: 0 0 auto;
|
|
1640
|
+
display: flex; align-items: center; gap: 10px;
|
|
1641
|
+
padding: 15px 18px 12px;
|
|
1642
|
+
border-bottom: 1px solid var(--mesh-line);
|
|
1643
|
+
}
|
|
1644
|
+
.mesh-demo-eyebrow { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--mesh-muted); }
|
|
1645
|
+
.mesh-demo-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
|
|
1646
|
+
.mesh-demo-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 6px; display: flex; flex-direction: column; gap: 12px; }
|
|
1647
|
+
.mesh-demo-peer {
|
|
1648
|
+
display: flex; align-items: center; gap: 10px;
|
|
1649
|
+
padding: 10px 12px; border: 1px solid var(--mesh-line); border-radius: 12px;
|
|
1650
|
+
background: var(--mesh-bg);
|
|
1651
|
+
}
|
|
1652
|
+
.mesh-demo-peer-name { font-size: 13px; font-weight: 600; }
|
|
1653
|
+
.mesh-demo-peer-meta { margin-left: auto; font-size: 11px; color: var(--mesh-muted); }
|
|
1654
|
+
.mesh-demo-task {
|
|
1655
|
+
align-self: flex-end; max-width: 86%;
|
|
1656
|
+
padding: 9px 13px; border-radius: 14px 14px 4px 14px;
|
|
1657
|
+
background: var(--mesh-accent-soft, var(--mesh-surface));
|
|
1658
|
+
border: 1px solid var(--mesh-line);
|
|
1659
|
+
font-size: 12.5px; line-height: 1.6;
|
|
1660
|
+
}
|
|
1661
|
+
.mesh-demo-steps { display: flex; flex-direction: column; gap: 7px; padding: 2px 2px 0; }
|
|
1662
|
+
.mesh-demo-step { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--mesh-muted); }
|
|
1663
|
+
.mesh-demo-step.is-active { color: var(--mesh-fg); font-weight: 550; }
|
|
1664
|
+
.mesh-demo-step.is-done { color: var(--mesh-fg); }
|
|
1665
|
+
.mesh-demo-step-dot {
|
|
1666
|
+
width: 16px; height: 16px; flex: 0 0 auto; border-radius: 50%;
|
|
1667
|
+
border: 1.5px solid var(--mesh-line-2);
|
|
1668
|
+
display: flex; align-items: center; justify-content: center;
|
|
1669
|
+
font-size: 9px; color: transparent;
|
|
1670
|
+
}
|
|
1671
|
+
.mesh-demo-step.is-active .mesh-demo-step-dot { border-color: var(--mesh-accent); }
|
|
1672
|
+
.mesh-demo-step.is-done .mesh-demo-step-dot { border-color: var(--mesh-accent); background: var(--mesh-accent); color: var(--mesh-bg); }
|
|
1673
|
+
.mesh-demo-spin { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--mesh-accent); border-top-color: transparent; animation: mesh-spin .8s linear infinite; }
|
|
1674
|
+
.mesh-demo-result {
|
|
1675
|
+
border: 1px solid var(--mesh-line); border-radius: 13px;
|
|
1676
|
+
padding: 13px 14px; background: var(--mesh-bg);
|
|
1677
|
+
animation: mesh-detail-in 220ms ease both;
|
|
1678
|
+
}
|
|
1679
|
+
.mesh-demo-result-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
|
|
1680
|
+
.mesh-demo-result-title { font-size: 12.5px; font-weight: 600; }
|
|
1681
|
+
.mesh-demo-result-rows { display: flex; flex-direction: column; gap: 5px; }
|
|
1682
|
+
.mesh-demo-result-row { display: flex; gap: 10px; font-size: 11.5px; line-height: 1.5; }
|
|
1683
|
+
.mesh-demo-result-k { flex: 0 0 66px; color: var(--mesh-muted); }
|
|
1684
|
+
.mesh-demo-result-v { flex: 1; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
|
|
1685
|
+
.mesh-demo-caption { font-size: 11px; line-height: 1.65; color: var(--mesh-muted); }
|
|
1686
|
+
.mesh-demo-code {
|
|
1687
|
+
display: flex; align-items: center; gap: 8px;
|
|
1688
|
+
padding: 9px 11px; border: 1px dashed var(--mesh-line-2); border-radius: 10px;
|
|
1689
|
+
font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1690
|
+
background: var(--mesh-code-bg, var(--mesh-bg));
|
|
1691
|
+
overflow-wrap: anywhere;
|
|
1692
|
+
}
|
|
1693
|
+
.mesh-demo-code code { flex: 1; min-width: 0; }
|
|
1694
|
+
.mesh-demo-foot { flex: 0 0 auto; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--mesh-line); flex-wrap: wrap; }
|
|
1695
|
+
.mesh-demo-note { margin-right: auto; font-size: 10.5px; color: var(--mesh-muted); align-self: center; }
|
|
1696
|
+
|
|
1613
1697
|
/* 主页底部的派发面板:视觉上跟卡片同级,但不参与拖动/隐藏。 */
|
|
1614
1698
|
.mesh-dispatch {
|
|
1615
1699
|
margin-top: 16px;
|
|
@@ -2977,6 +3061,183 @@ window.__ModuleLoader__.load({
|
|
|
2977
3061
|
);
|
|
2978
3062
|
}
|
|
2979
3063
|
|
|
3064
|
+
/**
|
|
3065
|
+
* 陌生设备第一次派活的确认条。
|
|
3066
|
+
*
|
|
3067
|
+
* 默认会拦(判定在 lib/approval.js)。这里只负责把「谁、要干什么」摆清楚,
|
|
3068
|
+
* 给两个按钮;点完立刻调接口 —— 任务要么当场开始跑,要么被拒。
|
|
3069
|
+
*/
|
|
3070
|
+
function ApprovalBar({ items, busy, onDecide }) {
|
|
3071
|
+
const list = Array.isArray(items) ? items : [];
|
|
3072
|
+
const first = list[0];
|
|
3073
|
+
if (!first) return null;
|
|
3074
|
+
const name = first.fromMachine || String(first.from || "").split("/")[0] || "一台设备";
|
|
3075
|
+
const more = list.length > 1 ? `(还有 ${list.length - 1} 条待确认)` : "";
|
|
3076
|
+
const preview = String(first.task || "").replace(/\s+/g, " ").slice(0, 68);
|
|
3077
|
+
return h(
|
|
3078
|
+
"div",
|
|
3079
|
+
{ className: "mesh-banner is-warn", role: "status", "data-mesh-approval": first.id },
|
|
3080
|
+
h(Icon, { name: "alert", size: 14 }),
|
|
3081
|
+
h(
|
|
3082
|
+
"div",
|
|
3083
|
+
{ className: "mesh-banner-main" },
|
|
3084
|
+
h("span", { className: "mesh-banner-title" }, `「${name}」想派一个任务过来${more}`),
|
|
3085
|
+
h("span", { className: "mesh-banner-detail" }, `允许后这台设备以后不再问:${preview}`),
|
|
3086
|
+
),
|
|
3087
|
+
h(Button, { variant: "primary", size: "sm", loading: busy, onClick: () => onDecide(first.id, "allow") }, "允许"),
|
|
3088
|
+
h(Button, { variant: "ghost", size: "sm", disabled: busy, onClick: () => onDecide(first.id, "deny") }, "拒绝"),
|
|
3089
|
+
);
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
/**
|
|
3093
|
+
* 「看演示」:没有第二台机器也能看见完整闭环。
|
|
3094
|
+
*
|
|
3095
|
+
* 这是唯一能让单机用户理解产品的东西。它**不连网络、不建会话、不花 token**,
|
|
3096
|
+
* 但结果里的数字是这台机器的真实数据(走 GET /mesh/api/demo),所以看起来
|
|
3097
|
+
* 不像编的。装好第二台之后,同一条链路会真的在那边跑。
|
|
3098
|
+
*/
|
|
3099
|
+
function DemoOverlay({ open, onClose }) {
|
|
3100
|
+
const [phase, setPhase] = react.useState("loading");
|
|
3101
|
+
const [data, setData] = react.useState(null);
|
|
3102
|
+
const [error, setError] = react.useState("");
|
|
3103
|
+
const [run, setRun] = react.useState(0);
|
|
3104
|
+
const [copied, setCopied] = react.useState(false);
|
|
3105
|
+
|
|
3106
|
+
react.useEffect(() => {
|
|
3107
|
+
if (!open) return undefined;
|
|
3108
|
+
let alive = true;
|
|
3109
|
+
const timers = [];
|
|
3110
|
+
setPhase("loading");
|
|
3111
|
+
setError("");
|
|
3112
|
+
setCopied(false);
|
|
3113
|
+
apiGet("/demo")
|
|
3114
|
+
.then((r) => {
|
|
3115
|
+
if (!alive) return;
|
|
3116
|
+
if (!r || !r.ok) {
|
|
3117
|
+
setError(apiErr(r));
|
|
3118
|
+
setPhase("error");
|
|
3119
|
+
return;
|
|
3120
|
+
}
|
|
3121
|
+
setData(r);
|
|
3122
|
+
setPhase("queued");
|
|
3123
|
+
timers.push(setTimeout(() => alive && setPhase("running"), 900));
|
|
3124
|
+
timers.push(setTimeout(() => alive && setPhase("done"), 3000));
|
|
3125
|
+
})
|
|
3126
|
+
.catch((e) => {
|
|
3127
|
+
if (!alive) return;
|
|
3128
|
+
setError(String((e && e.message) || e));
|
|
3129
|
+
setPhase("error");
|
|
3130
|
+
});
|
|
3131
|
+
return () => {
|
|
3132
|
+
alive = false;
|
|
3133
|
+
timers.forEach((t) => clearTimeout(t));
|
|
3134
|
+
};
|
|
3135
|
+
}, [open, run]);
|
|
3136
|
+
|
|
3137
|
+
if (!open) return null;
|
|
3138
|
+
|
|
3139
|
+
const stage = phase === "done" ? 2 : phase === "running" ? 1 : phase === "queued" ? 0 : -1;
|
|
3140
|
+
const stepClass = (i) => cls("mesh-demo-step", stage === i && "is-active", stage > i && "is-done");
|
|
3141
|
+
const dot = (i) => (stage === i ? h("span", { className: "mesh-demo-spin" }) : stage > i ? "✓" : "");
|
|
3142
|
+
const install = "dsh plugin add dsh-plugin-mesh";
|
|
3143
|
+
|
|
3144
|
+
return h(
|
|
3145
|
+
"div",
|
|
3146
|
+
{ className: "mesh-demo-layer", role: "dialog", "aria-modal": "true", "aria-label": "Mesh 演示", onClick: (e) => e.target === e.currentTarget && onClose() },
|
|
3147
|
+
h(
|
|
3148
|
+
"div",
|
|
3149
|
+
{ className: "mesh-demo-card" },
|
|
3150
|
+
h(
|
|
3151
|
+
"div",
|
|
3152
|
+
{ className: "mesh-demo-head" },
|
|
3153
|
+
h(Dot, { kind: "ok" }),
|
|
3154
|
+
h(
|
|
3155
|
+
"div",
|
|
3156
|
+
{ style: { flex: 1, minWidth: 0 } },
|
|
3157
|
+
h("div", { className: "mesh-demo-eyebrow" }, "演示 · 不连接其他机器"),
|
|
3158
|
+
h("div", { className: "mesh-demo-title" }, "一次跨机派发长什么样"),
|
|
3159
|
+
),
|
|
3160
|
+
h(IconButton, { icon: "close", label: "关闭演示", onClick: onClose }),
|
|
3161
|
+
),
|
|
3162
|
+
h(
|
|
3163
|
+
"div",
|
|
3164
|
+
{ className: "mesh-demo-body" },
|
|
3165
|
+
h(
|
|
3166
|
+
"div",
|
|
3167
|
+
{ className: "mesh-demo-peer" },
|
|
3168
|
+
h(Dot, { kind: "ok" }),
|
|
3169
|
+
h("span", { className: "mesh-demo-peer-name" }, "演示机 · Studio"),
|
|
3170
|
+
h("span", { className: "mesh-demo-peer-meta" }, "在线 · 示例"),
|
|
3171
|
+
),
|
|
3172
|
+
h("div", { className: "mesh-demo-task" }, "报一下你的系统和负载"),
|
|
3173
|
+
h(
|
|
3174
|
+
"div",
|
|
3175
|
+
{ className: "mesh-demo-steps" },
|
|
3176
|
+
h("div", { className: stage >= 0 ? "mesh-demo-step is-done" : "mesh-demo-step" }, h("span", { className: "mesh-demo-step-dot" }, stage >= 0 ? "✓" : ""), "已送达对端"),
|
|
3177
|
+
h("div", { className: stepClass(1) }, h("span", { className: "mesh-demo-step-dot" }, dot(1)), stage === 1 ? "对端正在跑" : "对端执行完毕"),
|
|
3178
|
+
h("div", { className: stepClass(2) }, h("span", { className: "mesh-demo-step-dot" }, dot(2)), "结果回到这里"),
|
|
3179
|
+
),
|
|
3180
|
+
phase === "error"
|
|
3181
|
+
? h("div", { className: "mesh-demo-caption" }, `取不到本机数据:${error}(演示依赖插件主机在线)`)
|
|
3182
|
+
: null,
|
|
3183
|
+
phase === "done" && data
|
|
3184
|
+
? h(
|
|
3185
|
+
"div",
|
|
3186
|
+
{ className: "mesh-demo-result" },
|
|
3187
|
+
h(
|
|
3188
|
+
"div",
|
|
3189
|
+
{ className: "mesh-demo-result-head" },
|
|
3190
|
+
h(Icon, { name: "check", size: 14 }),
|
|
3191
|
+
h("span", { className: "mesh-demo-result-title" }, "任务完成 · 结果卡"),
|
|
3192
|
+
),
|
|
3193
|
+
h(
|
|
3194
|
+
"div",
|
|
3195
|
+
{ className: "mesh-demo-result-rows" },
|
|
3196
|
+
h("div", { className: "mesh-demo-result-row" }, h("span", { className: "mesh-demo-result-k" }, "机器"), h("span", { className: "mesh-demo-result-v" }, `${data.hostname || data.machine} · ${osLabel(data.platform)} ${data.release}`)),
|
|
3197
|
+
h("div", { className: "mesh-demo-result-row" }, h("span", { className: "mesh-demo-result-k" }, "CPU"), h("span", { className: "mesh-demo-result-v" }, `${data.cpuModel || "未知型号"} · ${data.cpuCores} 核`)),
|
|
3198
|
+
h("div", { className: "mesh-demo-result-row" }, h("span", { className: "mesh-demo-result-k" }, "内存"), h("span", { className: "mesh-demo-result-v" }, `${data.memFreeGb} GB 可用 / ${data.memTotalGb} GB`)),
|
|
3199
|
+
h("div", { className: "mesh-demo-result-row" }, h("span", { className: "mesh-demo-result-k" }, "负载"), h("span", { className: "mesh-demo-result-v" }, `${data.load1}(1 分钟)· 已运行 ${data.uptimeHours} 小时`)),
|
|
3200
|
+
h("div", { className: "mesh-demo-result-row" }, h("span", { className: "mesh-demo-result-k" }, "运行时"), h("span", { className: "mesh-demo-result-v" }, (data.runtimes || []).map((r) => `${r.name} ${r.version}`).join(" · ") || "未探测到")),
|
|
3201
|
+
),
|
|
3202
|
+
)
|
|
3203
|
+
: null,
|
|
3204
|
+
phase === "done"
|
|
3205
|
+
? h(
|
|
3206
|
+
"div",
|
|
3207
|
+
null,
|
|
3208
|
+
h("p", { className: "mesh-demo-caption" }, "上面的数字来自这台机器本身 —— 演示只证明流程,不假装有第二台。装好第二台之后,同一句话会真的在那边跑,结果回到这里;合上笔记本也不影响。"),
|
|
3209
|
+
h(
|
|
3210
|
+
"div",
|
|
3211
|
+
{ className: "mesh-demo-code" },
|
|
3212
|
+
h("code", null, install),
|
|
3213
|
+
h(
|
|
3214
|
+
Button,
|
|
3215
|
+
{
|
|
3216
|
+
variant: "ghost",
|
|
3217
|
+
size: "sm",
|
|
3218
|
+
icon: copied ? "check" : "copy",
|
|
3219
|
+
onClick: async () => {
|
|
3220
|
+
const ok = await copyText(install);
|
|
3221
|
+
setCopied(ok);
|
|
3222
|
+
},
|
|
3223
|
+
},
|
|
3224
|
+
copied ? "已复制" : "复制",
|
|
3225
|
+
),
|
|
3226
|
+
),
|
|
3227
|
+
)
|
|
3228
|
+
: h("p", { className: "mesh-demo-caption" }, "派发出去之后这里会变成「在跑」,跑完自动变成结果卡 —— 你不用盯着。"),
|
|
3229
|
+
),
|
|
3230
|
+
h(
|
|
3231
|
+
"div",
|
|
3232
|
+
{ className: "mesh-demo-foot" },
|
|
3233
|
+
h("span", { className: "mesh-demo-note" }, "演示不会唤醒 agent,也不花 token。"),
|
|
3234
|
+
h(Button, { variant: "ghost", size: "sm", icon: "refresh", onClick: () => setRun((n) => n + 1) }, "再看一遍"),
|
|
3235
|
+
h(Button, { variant: "primary", size: "sm", onClick: onClose }, "知道了"),
|
|
3236
|
+
),
|
|
3237
|
+
),
|
|
3238
|
+
);
|
|
3239
|
+
}
|
|
3240
|
+
|
|
2980
3241
|
function LoadingView() {
|
|
2981
3242
|
return h("div", { className: "mesh-loading" }, h("span", { className: "mesh-spinner-lg" }), h("span", null, "正在读取 Mesh 状态…"));
|
|
2982
3243
|
}
|
|
@@ -3353,7 +3614,7 @@ window.__ModuleLoader__.load({
|
|
|
3353
3614
|
);
|
|
3354
3615
|
}
|
|
3355
3616
|
|
|
3356
|
-
function DeviceList({ selfPeer, peers, selectedId, onSelect, onWeb, onSsh, now, lastOk, onScan, scanning }) {
|
|
3617
|
+
function DeviceList({ selfPeer, peers, selectedId, onSelect, onWeb, onSsh, now, lastOk, onScan, scanning, onDemo }) {
|
|
3357
3618
|
return h(
|
|
3358
3619
|
"aside",
|
|
3359
3620
|
{ className: "mesh-list-pane" },
|
|
@@ -3380,7 +3641,17 @@ window.__ModuleLoader__.load({
|
|
|
3380
3641
|
h("div", { className: "mesh-list-heading" }, "其他设备"),
|
|
3381
3642
|
peers.length
|
|
3382
3643
|
? peers.map((p, i) => h(DeviceRow, { key: p.id, peer: p, active: selectedId === p.id, onSelect, onWeb, onSsh, now, index: i + 1 }))
|
|
3383
|
-
: h(
|
|
3644
|
+
: h(
|
|
3645
|
+
"div",
|
|
3646
|
+
{ className: "mesh-list-empty" },
|
|
3647
|
+
h("div", null, "还没有发现其他设备。"),
|
|
3648
|
+
h("div", { style: { marginTop: 8 } },
|
|
3649
|
+
onDemo
|
|
3650
|
+
? h(Button, { variant: "primary", size: "sm", icon: "arrowOut", onClick: onDemo }, "看 60 秒演示")
|
|
3651
|
+
: null,
|
|
3652
|
+
),
|
|
3653
|
+
h("div", { style: { marginTop: 6, fontSize: 10.5 } }, "或者在另一台电脑上装一次,它们会自己找到彼此。"),
|
|
3654
|
+
),
|
|
3384
3655
|
h(
|
|
3385
3656
|
"div",
|
|
3386
3657
|
{ className: "mesh-list-actions" },
|
|
@@ -3557,7 +3828,7 @@ window.__ModuleLoader__.load({
|
|
|
3557
3828
|
}
|
|
3558
3829
|
|
|
3559
3830
|
function DeviceView(props) {
|
|
3560
|
-
const { selfPeer, peers, selectedPeer, selectedId, onSelect, onWeb, onSsh, mobilePane, onBack, onCompose, onProbe, probe, hostDown, now, lastOk, onScan, scanning, firstRun, onRename, recentTasks, onOpenTask, onAllTasks } = props;
|
|
3831
|
+
const { selfPeer, peers, selectedPeer, selectedId, onSelect, onWeb, onSsh, mobilePane, onBack, onCompose, onProbe, probe, hostDown, now, lastOk, onScan, scanning, onDemo, firstRun, onRename, recentTasks, onOpenTask, onAllTasks } = props;
|
|
3561
3832
|
return h(
|
|
3562
3833
|
react.Fragment,
|
|
3563
3834
|
null,
|
|
@@ -3565,7 +3836,7 @@ window.__ModuleLoader__.load({
|
|
|
3565
3836
|
h(
|
|
3566
3837
|
"div",
|
|
3567
3838
|
{ className: "mesh-split", "data-pane": mobilePane },
|
|
3568
|
-
h(DeviceList, { selfPeer, peers, selectedId, onSelect, onWeb, onSsh, now, lastOk, onScan, scanning }),
|
|
3839
|
+
h(DeviceList, { selfPeer, peers, selectedId, onSelect, onWeb, onSsh, now, lastOk, onScan, scanning, onDemo }),
|
|
3569
3840
|
h(DeviceDetail, { peer: selectedPeer, isSelf: selectedId === "self", onCompose, onProbe, probe, hostDown, now, onBack, onRename, onScan, recentTasks, onOpenTask, onAllTasks }),
|
|
3570
3841
|
),
|
|
3571
3842
|
);
|
|
@@ -3679,6 +3950,27 @@ window.__ModuleLoader__.load({
|
|
|
3679
3950
|
h("strong", null, target.machine || "?"),
|
|
3680
3951
|
h("span", { style: { marginLeft: "auto" } }, online ? "对端会在自己的会话里执行" : "设备离线"),
|
|
3681
3952
|
),
|
|
3953
|
+
h(
|
|
3954
|
+
"div",
|
|
3955
|
+
{ className: "mesh-chips", style: { marginBottom: 8 } },
|
|
3956
|
+
[
|
|
3957
|
+
"在 Windows 那台编译,产物和报错都发我",
|
|
3958
|
+
"装到 Android 上启动一下,截图和日志发我",
|
|
3959
|
+
"在另一台装新版本插件,重启后确认版本",
|
|
3960
|
+
].map((preset) =>
|
|
3961
|
+
h(
|
|
3962
|
+
"button",
|
|
3963
|
+
{
|
|
3964
|
+
key: preset,
|
|
3965
|
+
type: "button",
|
|
3966
|
+
className: "mesh-chip mesh-chip-btn",
|
|
3967
|
+
onClick: () => setTask(preset),
|
|
3968
|
+
title: "填入这句话",
|
|
3969
|
+
},
|
|
3970
|
+
preset,
|
|
3971
|
+
),
|
|
3972
|
+
),
|
|
3973
|
+
),
|
|
3682
3974
|
h(
|
|
3683
3975
|
Field,
|
|
3684
3976
|
{ label: "要对方做什么?" },
|
|
@@ -3713,7 +4005,7 @@ window.__ModuleLoader__.load({
|
|
|
3713
4005
|
),
|
|
3714
4006
|
),
|
|
3715
4007
|
error ? h("div", { className: "mesh-sheet-error" }, error) : null,
|
|
3716
|
-
h("p", { className: "mesh-hint" }, "
|
|
4008
|
+
h("p", { className: "mesh-hint" }, "派发是异步的:这里成功只代表对端收了。它跑完会把结果派回来,出现在「任务」里。第一次派给陌生设备时,对方会先问你一次。⌘/Ctrl + Enter 发送。"),
|
|
3717
4009
|
),
|
|
3718
4010
|
h(
|
|
3719
4011
|
"div",
|
|
@@ -4437,6 +4729,10 @@ window.__ModuleLoader__.load({
|
|
|
4437
4729
|
dispatched: ["已派发", "ok"],
|
|
4438
4730
|
"queued-lost": ["排队丢失", "err"],
|
|
4439
4731
|
"dispatch-failed": ["派发失败", "err"],
|
|
4732
|
+
// 信任闸门:发出去的还在等对端点「允许」,收到的等本机点「允许」
|
|
4733
|
+
"awaiting-approval": ["等对端确认", "warn"],
|
|
4734
|
+
"needs-approval": ["待本机确认", "warn"],
|
|
4735
|
+
rejected: ["已拒绝", "err"],
|
|
4440
4736
|
};
|
|
4441
4737
|
|
|
4442
4738
|
function taskList(state) {
|
|
@@ -4462,7 +4758,13 @@ window.__ModuleLoader__.load({
|
|
|
4462
4758
|
at: tsOf(t.at),
|
|
4463
4759
|
text: String(t.task || ""),
|
|
4464
4760
|
thread: t.thread || "",
|
|
4465
|
-
status: t.ok
|
|
4761
|
+
status: t.ok
|
|
4762
|
+
? t.remoteStatus === "needs-approval"
|
|
4763
|
+
? "awaiting-approval"
|
|
4764
|
+
: "delivered"
|
|
4765
|
+
: t.status === 403
|
|
4766
|
+
? "pairing-mismatch"
|
|
4767
|
+
: "failed",
|
|
4466
4768
|
raw: t,
|
|
4467
4769
|
}));
|
|
4468
4770
|
return [...inbound, ...outbound].sort((a, b) => b.at - a.at);
|
|
@@ -5953,7 +6255,14 @@ window.__ModuleLoader__.load({
|
|
|
5953
6255
|
h("span", { className: "mesh-mini-meta" }, p.online ? `在线 · ${osLabel(p.os)}` : `${ago(p.lastSeen, now)}`),
|
|
5954
6256
|
),
|
|
5955
6257
|
)
|
|
5956
|
-
: h(
|
|
6258
|
+
: h(
|
|
6259
|
+
"div",
|
|
6260
|
+
null,
|
|
6261
|
+
h("p", { className: "mesh-card-text" }, "还没有发现其他设备。扫描本网段,或让对方也打开 Mesh。"),
|
|
6262
|
+
onDemo
|
|
6263
|
+
? h(Button, { variant: "secondary", size: "sm", icon: "arrowOut", onClick: onDemo }, "看演示:一次派发长什么样")
|
|
6264
|
+
: null,
|
|
6265
|
+
),
|
|
5957
6266
|
footer: h(Button, { variant: "ghost", size: "sm", icon: "device", onClick: onDevices }, "查看全部设备"),
|
|
5958
6267
|
});
|
|
5959
6268
|
}
|
|
@@ -6930,6 +7239,7 @@ window.__ModuleLoader__.load({
|
|
|
6930
7239
|
onSsh,
|
|
6931
7240
|
onScan,
|
|
6932
7241
|
scanning,
|
|
7242
|
+
onDemo,
|
|
6933
7243
|
firstRun,
|
|
6934
7244
|
hostDown,
|
|
6935
7245
|
onDispatched,
|
|
@@ -7663,6 +7973,10 @@ window.__ModuleLoader__.load({
|
|
|
7663
7973
|
const [transferDraft, setTransferDraft] = react.useState(null);
|
|
7664
7974
|
const [transferLogOpen, setTransferLogOpen] = react.useState(false);
|
|
7665
7975
|
const [transfers, setTransfers] = react.useState(() => loadTransfers());
|
|
7976
|
+
// 「看演示」:单机用户也能看见完整闭环(不连网络、不建会话)
|
|
7977
|
+
const [demoOpen, setDemoOpen] = react.useState(false);
|
|
7978
|
+
// 陌生设备首次派活的确认动作进行中
|
|
7979
|
+
const [approvalBusy, setApprovalBusy] = react.useState(false);
|
|
7666
7980
|
const sessionId = currentSessionId();
|
|
7667
7981
|
|
|
7668
7982
|
const self = state && state.self ? state.self : null;
|
|
@@ -7735,6 +8049,30 @@ window.__ModuleLoader__.load({
|
|
|
7735
8049
|
: null;
|
|
7736
8050
|
const hostDown = !!error;
|
|
7737
8051
|
|
|
8052
|
+
/**
|
|
8053
|
+
* 陌生设备第一次派活的确认。
|
|
8054
|
+
*
|
|
8055
|
+
* 允许 = 对端写进本机信任列表并立刻开始执行;拒绝 = 只标记,不执行。
|
|
8056
|
+
* 两种情况都刷新一次状态,让确认条和任务列表同时更新。
|
|
8057
|
+
*/
|
|
8058
|
+
const decideApproval = async (id, action) => {
|
|
8059
|
+
if (!id || approvalBusy) return;
|
|
8060
|
+
setApprovalBusy(true);
|
|
8061
|
+
try {
|
|
8062
|
+
const r = await api("/approval", { id, action });
|
|
8063
|
+
if (r && r.ok) {
|
|
8064
|
+
push("success", action === "allow" ? "已允许这台设备,任务开始执行" : "已拒绝这次派发");
|
|
8065
|
+
} else {
|
|
8066
|
+
push("error", apiErr(r));
|
|
8067
|
+
}
|
|
8068
|
+
await reload();
|
|
8069
|
+
} catch (e) {
|
|
8070
|
+
push("error", String((e && e.message) || e));
|
|
8071
|
+
} finally {
|
|
8072
|
+
setApprovalBusy(false);
|
|
8073
|
+
}
|
|
8074
|
+
};
|
|
8075
|
+
|
|
7738
8076
|
const saveName = async (raw) => {
|
|
7739
8077
|
const name = String(raw || "").trim();
|
|
7740
8078
|
if (!name) return false;
|
|
@@ -7954,7 +8292,11 @@ window.__ModuleLoader__.load({
|
|
|
7954
8292
|
* 设备页弹层和主页的派发面板共用它,免得两处提示文案慢慢走散。
|
|
7955
8293
|
*/
|
|
7956
8294
|
const notifyDispatched = (name, r) => {
|
|
7957
|
-
|
|
8295
|
+
// 202 = 对端收到了,但在等人点「允许」。不能把「送达」说成「开跑」。
|
|
8296
|
+
const pending = !!(r && r.pendingApproval);
|
|
8297
|
+
push(pending ? "info" : "success", pending
|
|
8298
|
+
? `已送达 ${name || "对端"},等它那边点一次「允许」`
|
|
8299
|
+
: `已派发给 ${name || "对端"}${r && r.id ? `(${r.id})` : ""}`, {
|
|
7958
8300
|
label: "查看任务",
|
|
7959
8301
|
onClick: () => {
|
|
7960
8302
|
setView("tasks");
|
|
@@ -8205,6 +8547,9 @@ window.__ModuleLoader__.load({
|
|
|
8205
8547
|
},
|
|
8206
8548
|
})
|
|
8207
8549
|
: null,
|
|
8550
|
+
state.approvals && state.approvals.length
|
|
8551
|
+
? h(ApprovalBar, { items: state.approvals, busy: approvalBusy, onDecide: decideApproval })
|
|
8552
|
+
: null,
|
|
8208
8553
|
h(
|
|
8209
8554
|
"main",
|
|
8210
8555
|
{ key: view, className: "mesh-view", role: "tabpanel", "aria-label": view === "home" ? "主页" : view === "devices" ? "设备" : view === "tasks" ? "任务" : "连接" },
|
|
@@ -8234,6 +8579,7 @@ window.__ModuleLoader__.load({
|
|
|
8234
8579
|
onSsh: (peer) => setSshPeer(peer),
|
|
8235
8580
|
onScan: doScan,
|
|
8236
8581
|
scanning,
|
|
8582
|
+
onDemo: () => setDemoOpen(true),
|
|
8237
8583
|
firstRun: firstRunNode,
|
|
8238
8584
|
hostDown,
|
|
8239
8585
|
onDispatched: (peer, r) => notifyDispatched((peer && peer.machine) || "", r),
|
|
@@ -8259,6 +8605,7 @@ window.__ModuleLoader__.load({
|
|
|
8259
8605
|
lastOk,
|
|
8260
8606
|
onScan: doScan,
|
|
8261
8607
|
scanning,
|
|
8608
|
+
onDemo: () => setDemoOpen(true),
|
|
8262
8609
|
recentTasks,
|
|
8263
8610
|
onOpenTask: openTask,
|
|
8264
8611
|
onAllTasks: openAllTasks,
|
|
@@ -8328,6 +8675,7 @@ window.__ModuleLoader__.load({
|
|
|
8328
8675
|
h(WebPanel, { panel: webPanel, onClose: closeWebPanel, onReload: reloadWebPanel }),
|
|
8329
8676
|
sshPeer ? h(SshPanel, { peer: sshPeer, onClose: () => setSshPeer(null) }) : null,
|
|
8330
8677
|
h(Toasts, { items: toasts, onClose: close }),
|
|
8678
|
+
h(DemoOverlay, { open: demoOpen, onClose: () => setDemoOpen(false) }),
|
|
8331
8679
|
);
|
|
8332
8680
|
}
|
|
8333
8681
|
|
|
@@ -8377,6 +8725,8 @@ window.__ModuleLoader__.load({
|
|
|
8377
8725
|
HomeView,
|
|
8378
8726
|
HomeBoard,
|
|
8379
8727
|
DispatchPanel,
|
|
8728
|
+
DemoOverlay,
|
|
8729
|
+
ApprovalBar,
|
|
8380
8730
|
DeviceList,
|
|
8381
8731
|
TasksView,
|
|
8382
8732
|
DeviceDetail,
|
package/cordis.patch.yml
CHANGED
|
@@ -53,6 +53,12 @@
|
|
|
53
53
|
# 若网络不完全可信(合租/公司/有访客设备),改成 true 再对齐配对码。
|
|
54
54
|
requirePairing: false
|
|
55
55
|
|
|
56
|
+
# 陌生设备第一次派活时,本机先弹一次确认(默认开)。
|
|
57
|
+
# 允许过的设备写进 state.json 的 approvedPeers,同一台不再问。
|
|
58
|
+
# 开了 requirePairing 就不再重复问 —— 配对码是更强的信任动作。
|
|
59
|
+
# 想让内网完全免打扰(自己家几台机器)就改成 false。
|
|
60
|
+
requireApproval: true
|
|
61
|
+
|
|
56
62
|
# 对端任务在本机新建会话时的选项
|
|
57
63
|
agentPreset: standard
|
|
58
64
|
# 对端派来的是外部不可信输入,默认不给 danger-full-access
|