@musdrop/ds-harness-remote 0.6.25 → 0.6.27

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/dist/client.js CHANGED
@@ -2199,7 +2199,9 @@ If a code was sent, recover the original submission without changing it.`,
2199
2199
  modelShareBorrowing: "Borrow models",
2200
2200
  modelShareBorrowingHint: "Borrowed models appear in your model picker.",
2201
2201
  modelShareEnableLending: "Allow lending models",
2202
- modelShareNoGrants: "No models are lent yet.",
2202
+ modelShareNoGrants: "No local models are available to share.",
2203
+ modelShareNoLocalModels: "No local models are available to share.",
2204
+ modelShareRefresh: "Refresh",
2203
2205
  modelShareNoSources: "No borrowing sources are configured yet.",
2204
2206
  modelShareAddGrant: "Add rule",
2205
2207
  modelShareRemove: "Remove",
@@ -2213,7 +2215,7 @@ If a code was sent, recover the original submission without changing it.`,
2213
2215
  modelShareSaved: "Model sharing settings saved.",
2214
2216
  modelShareSelectProvider: "Select a provider",
2215
2217
  modelShareSelectModels: "Select models",
2216
- modelShareBorrowFrom: "Borrow from",
2218
+ modelShareBorrowFrom: "Borrow from {name}",
2217
2219
  modelShareOffline: "offline",
2218
2220
  modelShareOnline: "online",
2219
2221
  modelShareNotLoaded: "Model sharing settings are unavailable.",
@@ -2648,7 +2650,9 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
2648
2650
  modelShareBorrowing: "\u501F\u7528\u6A21\u578B",
2649
2651
  modelShareBorrowingHint: "\u501F\u5230\u7684\u6A21\u578B\u4F1A\u51FA\u73B0\u5728\u672C\u673A\u7684\u6A21\u578B\u9009\u62E9\u5668\u4E2D\u3002",
2650
2652
  modelShareEnableLending: "\u5141\u8BB8\u501F\u51FA\u6A21\u578B",
2651
- modelShareNoGrants: "\u8FD8\u6CA1\u6709\u501F\u51FA\u4EFB\u4F55\u6A21\u578B\u3002",
2653
+ modelShareNoGrants: "\u6CA1\u6709\u53EF\u5171\u4EAB\u7684\u672C\u5730\u6A21\u578B\u3002",
2654
+ modelShareNoLocalModels: "\u6CA1\u6709\u53EF\u5171\u4EAB\u7684\u672C\u5730\u6A21\u578B\u3002",
2655
+ modelShareRefresh: "\u5237\u65B0",
2652
2656
  modelShareNoSources: "\u8FD8\u6CA1\u6709\u914D\u7F6E\u501F\u7528\u6765\u6E90\u3002",
2653
2657
  modelShareAddGrant: "\u6DFB\u52A0\u89C4\u5219",
2654
2658
  modelShareRemove: "\u5220\u9664",
@@ -2662,7 +2666,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
2662
2666
  modelShareSaved: "\u6A21\u578B\u5171\u4EAB\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002",
2663
2667
  modelShareSelectProvider: "\u9009\u62E9\u63D0\u4F9B\u5546",
2664
2668
  modelShareSelectModels: "\u9009\u62E9\u6A21\u578B",
2665
- modelShareBorrowFrom: "\u501F\u7528\u81EA",
2669
+ modelShareBorrowFrom: "\u501F\u7528\u81EA {name}",
2666
2670
  modelShareOffline: "\u79BB\u7EBF",
2667
2671
  modelShareOnline: "\u5728\u7EBF",
2668
2672
  modelShareNotLoaded: "\u6A21\u578B\u5171\u4EAB\u8BBE\u7F6E\u4E0D\u53EF\u7528\u3002",
@@ -3097,7 +3101,9 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
3097
3101
  modelShareBorrowing: "\u0417\u0430\u0438\u043C\u0441\u0442\u0432\u043E\u0432\u0430\u043D\u0438\u0435 \u043C\u043E\u0434\u0435\u043B\u0435\u0439",
3098
3102
  modelShareBorrowingHint: "\u041C\u043E\u0434\u0435\u043B\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432 \u043F\u043E\u044F\u0432\u044F\u0442\u0441\u044F \u0432 \u0432\u0430\u0448\u0435\u043C \u0432\u044B\u0431\u043E\u0440\u0435 \u043C\u043E\u0434\u0435\u043B\u0435\u0439.",
3099
3103
  modelShareEnableLending: "\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044C \u043F\u0440\u0435\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u043C\u043E\u0434\u0435\u043B\u0435\u0439",
3100
- modelShareNoGrants: "\u041C\u043E\u0434\u0435\u043B\u0438 \u0435\u0449\u0451 \u043D\u0435 \u043F\u0440\u0435\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u044B.",
3104
+ modelShareNoGrants: "\u041D\u0435\u0442 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0445 \u043C\u043E\u0434\u0435\u043B\u0435\u0439 \u0434\u043B\u044F \u043E\u0431\u0449\u0435\u0433\u043E \u0434\u043E\u0441\u0442\u0443\u043F\u0430.",
3105
+ modelShareNoLocalModels: "\u041D\u0435\u0442 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0445 \u043C\u043E\u0434\u0435\u043B\u0435\u0439 \u0434\u043B\u044F \u043E\u0431\u0449\u0435\u0433\u043E \u0434\u043E\u0441\u0442\u0443\u043F\u0430.",
3106
+ modelShareRefresh: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C",
3101
3107
  modelShareNoSources: "\u0417\u0430\u0438\u043C\u0441\u0442\u0432\u043E\u0432\u0430\u043D\u0438\u0435 \u0435\u0449\u0451 \u043D\u0435 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u043E.",
3102
3108
  modelShareAddGrant: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043F\u0440\u0430\u0432\u0438\u043B\u043E",
3103
3109
  modelShareRemove: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
@@ -3111,7 +3117,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
3111
3117
  modelShareSaved: "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043E\u0431\u043C\u0435\u043D\u0430 \u043C\u043E\u0434\u0435\u043B\u044F\u043C\u0438 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u044B.",
3112
3118
  modelShareSelectProvider: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430",
3113
3119
  modelShareSelectModels: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043C\u043E\u0434\u0435\u043B\u0438",
3114
- modelShareBorrowFrom: "\u0417\u0430\u0438\u043C\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0438\u0437",
3120
+ modelShareBorrowFrom: "\u0417\u0430\u0438\u043C\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0438\u0437 {name}",
3115
3121
  modelShareOffline: "\u043E\u0444\u043B\u0430\u0439\u043D",
3116
3122
  modelShareOnline: "\u043E\u043D\u043B\u0430\u0439\u043D",
3117
3123
  modelShareNotLoaded: "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043E\u0431\u043C\u0435\u043D\u0430 \u043C\u043E\u0434\u0435\u043B\u044F\u043C\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B.",
@@ -3546,7 +3552,9 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
3546
3552
  modelShareBorrowing: "\u041F\u043E\u0437\u0438\u0447\u0430\u043D\u043D\u044F \u043C\u043E\u0434\u0435\u043B\u0435\u0439",
3547
3553
  modelShareBorrowingHint: "\u041C\u043E\u0434\u0435\u043B\u0456 \u0437 \u0456\u043D\u0448\u0438\u0445 \u043F\u0440\u0438\u0441\u0442\u0440\u043E\u0457\u0432 \u0437\u2019\u044F\u0432\u043B\u044F\u0442\u044C\u0441\u044F \u0443 \u0432\u0430\u0448\u043E\u043C\u0443 \u0432\u0438\u0431\u043E\u0440\u0456 \u043C\u043E\u0434\u0435\u043B\u0435\u0439.",
3548
3554
  modelShareEnableLending: "\u0414\u043E\u0437\u0432\u043E\u043B\u0438\u0442\u0438 \u043D\u0430\u0434\u0430\u043D\u043D\u044F \u043C\u043E\u0434\u0435\u043B\u0435\u0439",
3549
- modelShareNoGrants: "\u041C\u043E\u0434\u0435\u043B\u0456 \u0449\u0435 \u043D\u0435 \u043D\u0430\u0434\u0430\u043D\u0456.",
3555
+ modelShareNoGrants: "\u041D\u0435\u043C\u0430\u0454 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u0438\u0445 \u043C\u043E\u0434\u0435\u043B\u0435\u0439 \u0434\u043B\u044F \u0441\u043F\u0456\u043B\u044C\u043D\u043E\u0433\u043E \u0434\u043E\u0441\u0442\u0443\u043F\u0443.",
3556
+ modelShareNoLocalModels: "\u041D\u0435\u043C\u0430\u0454 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u0438\u0445 \u043C\u043E\u0434\u0435\u043B\u0435\u0439 \u0434\u043B\u044F \u0441\u043F\u0456\u043B\u044C\u043D\u043E\u0433\u043E \u0434\u043E\u0441\u0442\u0443\u043F\u0443.",
3557
+ modelShareRefresh: "\u041E\u043D\u043E\u0432\u0438\u0442\u0438",
3550
3558
  modelShareNoSources: "\u041F\u043E\u0437\u0438\u0447\u0430\u043D\u043D\u044F \u0449\u0435 \u043D\u0435 \u043D\u0430\u043B\u0430\u0448\u0442\u043E\u0432\u0430\u043D\u043E.",
3551
3559
  modelShareAddGrant: "\u0414\u043E\u0434\u0430\u0442\u0438 \u043F\u0440\u0430\u0432\u0438\u043B\u043E",
3552
3560
  modelShareRemove: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
@@ -3560,7 +3568,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
3560
3568
  modelShareSaved: "\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u043C\u043E\u0434\u0435\u043B\u044C\u043E\u0432\u043E\u0433\u043E \u043E\u0431\u043C\u0456\u043D\u0443 \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E.",
3561
3569
  modelShareSelectProvider: "\u0412\u0438\u0431\u0435\u0440\u0456\u0442\u044C \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430",
3562
3570
  modelShareSelectModels: "\u0412\u0438\u0431\u0435\u0440\u0456\u0442\u044C \u043C\u043E\u0434\u0435\u043B\u0456",
3563
- modelShareBorrowFrom: "\u041F\u043E\u0437\u0438\u0447\u0430\u0442\u0438 \u0437",
3571
+ modelShareBorrowFrom: "\u041F\u043E\u0437\u0438\u0447\u0430\u0442\u0438 \u0437 {name}",
3564
3572
  modelShareOffline: "\u043E\u0444\u043B\u0430\u0439\u043D",
3565
3573
  modelShareOnline: "\u043E\u043D\u043B\u0430\u0439\u043D",
3566
3574
  modelShareNotLoaded: "\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u043C\u043E\u0434\u0435\u043B\u044C\u043E\u0432\u043E\u0433\u043E \u043E\u0431\u043C\u0456\u043D\u0443 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0456.",
@@ -4087,6 +4095,139 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4087
4095
  return snapshot.baselinesReady === !0 || snapshot.phase === "ready";
4088
4096
  }
4089
4097
 
4098
+ // packages/plugin/src/client/host-mention.ts
4099
+ init_page_globals();
4100
+ var DEFAULT_RETRY_DELAYS_MS = [1e3, 2e3, 5e3, 1e4, 3e4];
4101
+ function isUnsupportedSettingsEndpointError(reason) {
4102
+ if (typeof reason != "object" || reason === null || !("code" in reason)) return !1;
4103
+ let code = reason.code;
4104
+ return code === "METHOD_NOT_FOUND" || code === "METHOD_NOT_ALLOWED" || code === "FEATURE_NOT_SUPPORTED";
4105
+ }
4106
+ function createSource(deps, settingsSupport) {
4107
+ return {
4108
+ trigger: "@",
4109
+ name: "\u4E3B\u673A",
4110
+ order: -20,
4111
+ showGroupTitle: !1,
4112
+ candidates: async (_session, request) => {
4113
+ if (deps.remoteTools.read() === !1 || request.signal?.aborted) return [];
4114
+ if (!settingsSupport.unsupported) {
4115
+ let settings;
4116
+ try {
4117
+ settings = await deps.control("settings.get");
4118
+ } catch (reason) {
4119
+ if (request.signal?.aborted || deps.remoteTools.read() === !1) return [];
4120
+ if (!isUnsupportedSettingsEndpointError(reason)) return [];
4121
+ settingsSupport.unsupported = !0, deps.remoteTools.read() === void 0 && deps.remoteTools.publish(!0);
4122
+ }
4123
+ if (request.signal?.aborted || deps.remoteTools.read() === !1) return [];
4124
+ if (settings !== void 0) {
4125
+ let nextEnabled = settings.config?.remoteTools?.enabled !== !1;
4126
+ if (deps.remoteTools.publish(nextEnabled), !nextEnabled) return [];
4127
+ }
4128
+ }
4129
+ let devices = await deps.control("devices").catch(() => []);
4130
+ if (request.signal?.aborted || deps.remoteTools.read() === !1) return [];
4131
+ let query = request.query.trim().toLocaleLowerCase(), section = deps.t("host");
4132
+ return devices.filter((device) => device.online && (query === "" || `${device.name} ${device.deviceId}`.toLocaleLowerCase().includes(query))).map((device) => (deps.hostCache.set(device.name, device), {
4133
+ name: device.name,
4134
+ label: device.name,
4135
+ description: deps.t("remoteHostMention", { platform: device.platform }),
4136
+ icon: deps.icon,
4137
+ section,
4138
+ value: JSON.stringify({ deviceId: device.deviceId, label: device.name, platform: device.platform })
4139
+ }));
4140
+ },
4141
+ onPick: (pick) => {
4142
+ let host = JSON.parse(pick.candidate.value);
4143
+ return { text: `@${host.label} (Remote hostId=${JSON.stringify(host.deviceId)}) ` };
4144
+ }
4145
+ };
4146
+ }
4147
+ function installRemoteHostMentionSource(options) {
4148
+ if (options.isHostcTunnel) return () => {
4149
+ };
4150
+ let hostCache = options.hostCache ?? /* @__PURE__ */ new Map(), retryDelaysMs = options.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS, settingsSupport = { unsupported: !1 }, source = createSource({
4151
+ control: options.control,
4152
+ remoteTools: options.remoteTools,
4153
+ t: options.t,
4154
+ icon: options.icon,
4155
+ hostCache
4156
+ }, settingsSupport), disposed = !1, unregisterSource, clickBound = !1, probing = !1, retryIndex = 0, retryTimer, preferenceVersion = 0, lastStatusRemoteToolsEnabled, wasControlUnavailable = !1, stopHostFileOpen = (event) => {
4157
+ if (typeof Element > "u") return;
4158
+ let target = event.target instanceof Element ? event.target.closest('button,[role="button"],a') ?? event.target : void 0;
4159
+ if (!(target instanceof Element)) return;
4160
+ let text = target.textContent?.trim().replace(/^@/, "") ?? "", device = hostCache.get(text);
4161
+ if (!device) return;
4162
+ event.preventDefault(), event.stopImmediatePropagation();
4163
+ let invocation = `@${device.name}`, container = target;
4164
+ for (let depth = 0; depth < 20 && container !== null; depth += 1) {
4165
+ let candidate = container.textContent?.trim() ?? "";
4166
+ candidate.includes(device.name) && candidate.length > invocation.length && candidate.length < 4e3 && (invocation = candidate), container = container.parentElement;
4167
+ }
4168
+ typeof page < "u" && typeof CustomEvent < "u" && page.dispatchEvent(new CustomEvent("dsh-remote-host-reference", {
4169
+ detail: { label: device.name, platform: device.platform, deviceId: device.deviceId, invocation }
4170
+ }));
4171
+ }, mount = () => {
4172
+ disposed || unregisterSource !== void 0 || (!clickBound && typeof pageDocument < "u" && typeof pageDocument.addEventListener == "function" && (pageDocument.addEventListener("click", stopHostFileOpen, !0), clickBound = !0), unregisterSource = options.inputTriggers.registerSource(source));
4173
+ }, unmount = () => {
4174
+ if (clickBound && typeof pageDocument < "u" && typeof pageDocument.removeEventListener == "function" && (pageDocument.removeEventListener("click", stopHostFileOpen, !0), clickBound = !1), unregisterSource !== void 0) {
4175
+ let unregister = unregisterSource;
4176
+ unregisterSource = void 0, unregister();
4177
+ }
4178
+ hostCache.clear();
4179
+ }, clearRetryTimer = () => {
4180
+ retryTimer !== void 0 && (clearTimeout(retryTimer), retryTimer = void 0);
4181
+ }, sync = () => {
4182
+ let enabled = options.remoteTools.read();
4183
+ enabled === !0 ? (clearRetryTimer(), mount()) : enabled === !1 && (clearRetryTimer(), unmount());
4184
+ }, scheduleRetryTimer = () => {
4185
+ if (!(disposed || options.remoteTools.read() !== void 0) && retryTimer === void 0 && retryIndex < retryDelaysMs.length) {
4186
+ let delayMs = retryDelaysMs[retryIndex++];
4187
+ retryTimer = setTimeout(() => {
4188
+ retryTimer = void 0, probe(!1);
4189
+ }, delayMs);
4190
+ }
4191
+ }, probe = async (force = !1) => {
4192
+ if (disposed || probing || !force && options.remoteTools.read() !== void 0) return;
4193
+ probing = !0;
4194
+ let startVersion = preferenceVersion, shouldRetry = !1;
4195
+ try {
4196
+ let settings = await options.control("settings.get");
4197
+ if (disposed || preferenceVersion !== startVersion) return;
4198
+ clearRetryTimer(), options.remoteTools.publish(settings?.config?.remoteTools?.enabled !== !1);
4199
+ } catch (reason) {
4200
+ if (disposed || preferenceVersion !== startVersion) return;
4201
+ isUnsupportedSettingsEndpointError(reason) ? (settingsSupport.unsupported = !0, clearRetryTimer(), options.remoteTools.read() === void 0 && options.remoteTools.publish(!0)) : options.remoteTools.read() === void 0 && (shouldRetry = !0);
4202
+ } finally {
4203
+ probing = !1;
4204
+ }
4205
+ shouldRetry && scheduleRetryTimer();
4206
+ }, unsubscribePreference = options.remoteTools.subscribe(() => {
4207
+ preferenceVersion += 1, sync();
4208
+ }), ignoreInitialStatusReplay = !0, unsubscribeStatus = options.statusFeed.subscribe((status) => {
4209
+ if (disposed) return;
4210
+ if (status.controlUnavailable === !0) {
4211
+ wasControlUnavailable = !0, ignoreInitialStatusReplay = !1;
4212
+ return;
4213
+ }
4214
+ let recoveredFromUnavailable = wasControlUnavailable;
4215
+ if (wasControlUnavailable = !1, typeof status.remoteToolsEnabled == "boolean") {
4216
+ let previousStatusValue = lastStatusRemoteToolsEnabled;
4217
+ lastStatusRemoteToolsEnabled = status.remoteToolsEnabled, clearRetryTimer(), (options.remoteTools.read() === void 0 || previousStatusValue !== void 0 && previousStatusValue !== status.remoteToolsEnabled || previousStatusValue === void 0 && !ignoreInitialStatusReplay && options.remoteTools.read() !== status.remoteToolsEnabled) && options.remoteTools.publish(status.remoteToolsEnabled), ignoreInitialStatusReplay = !1;
4218
+ return;
4219
+ }
4220
+ if (ignoreInitialStatusReplay) {
4221
+ ignoreInitialStatusReplay = !1;
4222
+ return;
4223
+ }
4224
+ (options.remoteTools.read() === void 0 || recoveredFromUnavailable) && probe(recoveredFromUnavailable);
4225
+ });
4226
+ return ignoreInitialStatusReplay = !1, options.remoteTools.read() !== void 0 ? sync() : probe(!1), () => {
4227
+ disposed = !0, clearRetryTimer(), unsubscribeStatus(), unsubscribePreference(), unmount();
4228
+ };
4229
+ }
4230
+
4090
4231
  // packages/plugin/src/client/progress.ts
4091
4232
  init_page_globals();
4092
4233
  function createRemoteProgressView(React) {
@@ -4383,7 +4524,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4383
4524
  }
4384
4525
  function createModelSharingSection(React) {
4385
4526
  return function(props) {
4386
- let { control, t, available = !0 } = props, [view, setView] = React.useState(void 0), [busy, setBusy] = React.useState(!1), [error, setError] = React.useState(void 0), [notice, setNotice] = React.useState(void 0), [draftModels, setDraftModels] = React.useState([]), [concurrencyDraft, setConcurrencyDraft] = React.useState(void 0), viewRef = React.useRef(void 0), queueRef = React.useRef(Promise.resolve()), busyRef = React.useRef(!1), applyView = (next) => {
4527
+ let { control, t, available = !0 } = props, [view, setView] = React.useState(void 0), [busy, setBusy] = React.useState(!1), [error, setError] = React.useState(void 0), [notice, setNotice] = React.useState(void 0), [concurrencyDraft, setConcurrencyDraft] = React.useState(void 0), viewRef = React.useRef(void 0), queueRef = React.useRef(Promise.resolve()), busyRef = React.useRef(!1), applyView = (next) => {
4387
4528
  viewRef.current = next, setView(next), setConcurrencyDraft(void 0);
4388
4529
  }, load = React.useCallback(async () => {
4389
4530
  setError(void 0);
@@ -4412,27 +4553,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4412
4553
  enqueue((current) => ({ ...current, host: { ...current.host, ...changes } }));
4413
4554
  }, patchSources = (sources) => {
4414
4555
  enqueue((current) => ({ ...current, borrower: { ...current.borrower, sources } }));
4415
- }, toggleDraftModel = (route) => {
4416
- setDraftModels((current) => current.includes(route) ? current.filter((id) => id !== route) : [...current, route]);
4417
- }, resetDraft = () => {
4418
- setDraftModels([]);
4419
- }, saveRule = () => {
4420
- view === void 0 || draftModels.length === 0 || (enqueue((current) => ({
4421
- ...current,
4422
- host: {
4423
- ...current.host,
4424
- models: [.../* @__PURE__ */ new Set([...current.host.models, ...draftModels])],
4425
- enabled: !0
4426
- }
4427
- })), resetDraft());
4428
- }, removeModel = (route) => {
4429
- view !== void 0 && patchHost({ models: view.store.host.models.filter((model) => model !== route) });
4430
- }, label = (device) => `${device.name}${device.online ? ` \xB7 ${t("modelShareOnline")}` : device.known ? ` \xB7 ${t("modelShareOffline")}` : ""}`, ruleSummary = (route) => {
4431
- let separator = route.indexOf(ROUTE_SEPARATOR), provider = route.slice(0, separator), model = route.slice(separator + ROUTE_SEPARATOR.length), providerName = view?.localProviders.find((candidate) => candidate.id === provider)?.name ?? provider;
4432
- if (model === "*") return `${providerName}: ${t("modelShareAllModels")}`;
4433
- let modelName = view?.localProviders.find((candidate) => candidate.id === provider)?.models.find((candidate) => candidate.id === model)?.name;
4434
- return `${providerName} / ${modelName ?? model}`;
4435
- }, borrowStatus = (deviceId, source) => {
4556
+ }, label = (device) => `${device.name}${device.online ? ` \xB7 ${t("modelShareOnline")}` : device.known ? ` \xB7 ${t("modelShareOffline")}` : ""}`, borrowStatus = (deviceId, source) => {
4436
4557
  if (view === void 0 || source?.enabled !== !0) return;
4437
4558
  let diagnostics = view.borrowerDiagnostics;
4438
4559
  if (diagnostics.syncAvailable !== !0)
@@ -4463,7 +4584,15 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4463
4584
  React.createElement("p", null, error ?? t("modelShareNotLoaded"))
4464
4585
  )
4465
4586
  );
4466
- let { host, borrower } = view.store, disabled = busy || !view.writable || !available, selectedCount = draftModels.length, modelsSummary = selectedCount === 0 ? t("modelShareSelectModelsHint") : t("modelShareSelectedCount", { count: selectedCount }), modelSummaryLine = `${t("modelShareModels")}: ${modelsSummary}`, lendingRows = React.createElement(
4587
+ let { host, borrower } = view.store, disabled = busy || !view.writable || !available, toggleShared = (route) => {
4588
+ let current = viewRef.current?.store.host.models ?? [];
4589
+ patchHost({
4590
+ models: current.includes(route) ? current.filter((model) => model !== route) : [...current, route]
4591
+ });
4592
+ }, toggleProvider = (provider) => {
4593
+ let current = viewRef.current?.store.host.models ?? [], routes = provider.models.map((model) => `${provider.id}${ROUTE_SEPARATOR}${model.id}`), next = routes.length > 0 && routes.every((route) => current.includes(route)) ? current.filter((route) => !routes.includes(route)) : [.../* @__PURE__ */ new Set([...current, ...routes])];
4594
+ patchHost({ models: next });
4595
+ }, sharedCount = host.models.length, modelSummaryLine = sharedCount === 0 ? t("modelShareSelectModelsHint") : t("modelShareSelectedCount", { count: sharedCount }), lendingRows = React.createElement(
4467
4596
  "div",
4468
4597
  { className: "dshRemoteAcpList" },
4469
4598
  React.createElement(
@@ -4498,94 +4627,60 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4498
4627
  ),
4499
4628
  React.createElement("p", { className: "dshRemoteAcpDiag" }, t("modelShareRuleAnyDeviceHint"))
4500
4629
  ),
4501
- ...host.models.map((route) => React.createElement(
4502
- "div",
4503
- {
4504
- key: `shared-${route}`,
4505
- className: "dshRemoteModelShareGrantEntry"
4506
- },
4507
- React.createElement("span", null, ruleSummary(route)),
4508
- React.createElement(
4509
- "div",
4510
- { className: "dshRemoteAcpRowActions" },
4511
- React.createElement("button", {
4512
- type: "button",
4513
- className: "dshRemoteAcpRemoveBtn",
4514
- disabled,
4515
- "aria-label": `${t("modelShareRemove")}: ${route}`,
4516
- onClick: () => removeModel(route)
4517
- }, t("modelShareRemove"))
4518
- )
4519
- )),
4520
- host.models.length === 0 ? React.createElement("p", { className: "dshRemoteAcpDiag" }, t("modelShareNoGrants")) : null,
4521
- React.createElement(
4522
- "div",
4523
- { className: "dshRemoteAcpAddForm" },
4524
- React.createElement(
4630
+ view.localProviders.length === 0 ? React.createElement("p", { className: "dshRemoteAcpDiag" }, t("modelShareNoLocalModels")) : null,
4631
+ ...view.localProviders.map((provider) => {
4632
+ let routes = provider.models.map((model) => `${provider.id}${ROUTE_SEPARATOR}${model.id}`), allShared = routes.length > 0 && routes.every((route) => host.models.includes(route)), someShared = routes.some((route) => host.models.includes(route));
4633
+ return React.createElement(
4525
4634
  "div",
4526
- { className: "dshRemoteAcpAddInputs" },
4527
- React.createElement("button", {
4528
- type: "button",
4529
- className: "dshRemoteAcpAddTrigger",
4530
- disabled: disabled || draftModels.length === 0,
4531
- onClick: saveRule
4532
- }, t("modelShareAddGrant")),
4533
- draftModels.length > 0 ? React.createElement("button", {
4534
- type: "button",
4535
- className: "dshRemoteAcpAddTrigger",
4536
- disabled,
4537
- onClick: resetDraft
4538
- }, t("modelShareClearDraft")) : null
4539
- ),
4540
- // One flat picker: every provider's models under provider headings,
4541
- // all selectable in a single pass. The heading checkbox adds that
4542
- // provider's wildcard route (all current models).
4543
- React.createElement(
4544
- "details",
4545
- { className: "dshRemoteModelSharePicker" },
4546
- React.createElement("summary", null, modelSummaryLine),
4635
+ {
4636
+ key: `prov-${provider.id}`,
4637
+ className: "dshRemoteAcpRow dshRemoteModelShareProviderRow"
4638
+ },
4547
4639
  React.createElement(
4548
4640
  "div",
4549
- { className: "dshRemoteModelSharePickerList", role: "group", "aria-label": t("modelShareModels") },
4550
- ...view.localProviders.map((provider) => {
4551
- let wildcard = `${provider.id}${ROUTE_SEPARATOR}*`;
4641
+ { className: "dshRemoteAcpRowMain" },
4642
+ React.createElement(
4643
+ "label",
4644
+ { className: "dshRemoteModelShareProviderHeading" },
4645
+ React.createElement("input", {
4646
+ type: "checkbox",
4647
+ checked: allShared,
4648
+ // Show a mixed provider as indeterminate rather than "off".
4649
+ ref: (node) => {
4650
+ node !== null && typeof node == "object" && "indeterminate" in node && (node.indeterminate = someShared && !allShared);
4651
+ },
4652
+ disabled,
4653
+ "aria-label": `${t("modelShareAllModels")}: ${provider.name ?? provider.id}`,
4654
+ onChange: () => toggleProvider(provider)
4655
+ }),
4656
+ React.createElement("strong", { className: "dshRemoteAcpName" }, provider.name ?? provider.id)
4657
+ )
4658
+ ),
4659
+ React.createElement(
4660
+ "div",
4661
+ { className: "dshRemoteModelSharePickerList", role: "group", "aria-label": provider.name ?? provider.id },
4662
+ ...provider.models.map((model) => {
4663
+ let route = `${provider.id}${ROUTE_SEPARATOR}${model.id}`;
4552
4664
  return React.createElement(
4553
- "div",
4554
- { key: `prov-${provider.id}`, className: "dshRemoteModelShareProviderGroup" },
4555
- React.createElement(
4556
- "label",
4557
- { className: "dshRemoteModelShareProviderHeading" },
4558
- React.createElement("input", {
4559
- type: "checkbox",
4560
- checked: draftModels.includes(wildcard),
4561
- disabled,
4562
- "aria-label": `${t("modelShareAllModels")}: ${provider.name ?? provider.id}`,
4563
- onChange: () => toggleDraftModel(wildcard)
4564
- }),
4565
- React.createElement("strong", null, provider.name ?? provider.id)
4566
- ),
4567
- ...provider.models.map((model) => {
4568
- let route = `${provider.id}${ROUTE_SEPARATOR}${model.id}`;
4569
- return React.createElement(
4570
- "label",
4571
- { key: `model-${route}` },
4572
- React.createElement("input", {
4573
- type: "checkbox",
4574
- checked: draftModels.includes(route) || draftModels.includes(wildcard),
4575
- // The provider wildcard supersedes its individual boxes.
4576
- disabled: disabled || draftModels.includes(wildcard),
4577
- "aria-label": `${provider.name ?? provider.id} / ${model.name ?? model.id}`,
4578
- onChange: () => toggleDraftModel(route)
4579
- }),
4580
- model.name ?? model.id
4581
- );
4582
- })
4665
+ "label",
4666
+ { key: `model-${route}`, className: "dshRemoteModelShareModelRow" },
4667
+ React.createElement("input", {
4668
+ type: "checkbox",
4669
+ checked: host.models.includes(route),
4670
+ disabled,
4671
+ "aria-label": `${provider.name ?? provider.id} / ${model.name ?? model.id}`,
4672
+ onChange: () => toggleShared(route)
4673
+ }),
4674
+ model.name ?? model.id
4583
4675
  );
4584
4676
  })
4585
4677
  )
4586
- )
4587
- )
4588
- ), borrowingRows = React.createElement(
4678
+ );
4679
+ }),
4680
+ React.createElement("p", { className: "dshRemoteAcpDiag" }, modelSummaryLine)
4681
+ ), refreshSources = () => {
4682
+ control("modelshare.resync").then((next) => applyView(next)).catch((reason) => setError(messageOf(reason, t)));
4683
+ }, borrowingRows = React.createElement(
4589
4684
  "div",
4590
4685
  { className: "dshRemoteAcpList" },
4591
4686
  ...view.peers.map((device) => {
@@ -4603,29 +4698,35 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4603
4698
  "div",
4604
4699
  { className: "dshRemoteAcpRowInfo" },
4605
4700
  React.createElement("strong", { className: "dshRemoteAcpName" }, label(device)),
4606
- React.createElement(
4607
- "p",
4608
- null,
4609
- `${t("modelShareBorrowFrom")} ${device.name}`
4610
- )
4701
+ React.createElement("p", null, t("modelShareBorrowFrom", { name: device.name }))
4611
4702
  ),
4612
- React.createElement("input", {
4613
- type: "checkbox",
4614
- role: "switch",
4615
- className: "dshRemoteSwitch",
4616
- checked: source?.enabled ?? !1,
4617
- "aria-checked": source?.enabled ?? !1,
4618
- disabled,
4619
- "aria-label": `${t("modelShareBorrowFrom")}: ${label(device)}`,
4620
- onChange: () => {
4621
- let sources = { ...borrower.sources };
4622
- sources[device.deviceId] = {
4623
- enabled: !(source?.enabled ?? !1),
4624
- models: source?.models ?? [],
4625
- hostName: source?.hostName ?? device.name
4626
- }, patchSources(sources);
4627
- }
4628
- })
4703
+ React.createElement(
4704
+ "div",
4705
+ { className: "dshRemoteAcpRowActions" },
4706
+ source?.enabled === !0 ? React.createElement("button", {
4707
+ type: "button",
4708
+ className: "dshRemoteAcpActionBtn",
4709
+ disabled,
4710
+ "aria-label": `${t("modelShareRefresh")}: ${label(device)}`,
4711
+ onClick: refreshSources
4712
+ }, t("modelShareRefresh")) : null,
4713
+ React.createElement("input", {
4714
+ type: "checkbox",
4715
+ role: "switch",
4716
+ className: "dshRemoteSwitch",
4717
+ checked: source?.enabled ?? !1,
4718
+ "aria-checked": source?.enabled ?? !1,
4719
+ disabled,
4720
+ "aria-label": `${t("modelShareBorrowFrom", { name: label(device) })}`,
4721
+ onChange: () => {
4722
+ let sources = { ...borrower.sources };
4723
+ sources[device.deviceId] = {
4724
+ enabled: !(source?.enabled ?? !1),
4725
+ hostName: source?.hostName ?? device.name
4726
+ }, patchSources(sources);
4727
+ }
4728
+ })
4729
+ )
4629
4730
  ),
4630
4731
  status !== void 0 ? React.createElement("p", {
4631
4732
  className: `dshRemoteAcpDiag${status.cls}`,
@@ -4633,7 +4734,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4633
4734
  }, status.text) : null
4634
4735
  );
4635
4736
  }),
4636
- Object.keys(borrower.sources).length === 0 ? React.createElement("p", { className: "dshRemoteAcpDiag" }, t("modelShareNoSources")) : null
4737
+ view.peers.length === 0 ? React.createElement("p", { className: "dshRemoteAcpDiag" }, t("modelShareNoSources")) : null
4637
4738
  );
4638
4739
  return React.createElement(
4639
4740
  "div",
@@ -4718,7 +4819,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4718
4819
  subscribeStatus,
4719
4820
  getStatusSnapshot,
4720
4821
  getStatusSnapshot
4721
- ), [open, setOpen] = React.useState(props.view === "page"), [serverUrl, setServerUrl] = React.useState(""), [savingServer, setSavingServer] = React.useState(!1), [editingServer, setEditingServer] = React.useState(!1), serverDraftEdited = React.useRef(!1), [remoteToolsBusy, setRemoteToolsBusy] = React.useState(!1), [remoteToolsEnabled, setRemoteToolsEnabled] = React.useState(!0), [associations, setAssociations] = React.useState({}), [loaded, setLoaded] = React.useState(!1), [writable, setWritable] = React.useState(!1), [busy, setBusy] = React.useState(!1), [terminalEnabled, setTerminalEnabled] = React.useState(!1), [debugBusy, setDebugBusy] = React.useState(!1), [debugLogging, setDebugLogging] = React.useState(!1), [logsOpen, setLogsOpen] = React.useState(!1), [logsFilter, setLogsFilter] = React.useState("all"), [logsLoading, setLogsLoading] = React.useState(!1), [logsClearing, setLogsClearing] = React.useState(!1), [logsSnapshot, setLogsSnapshot] = React.useState(void 0), [logsError, setLogsError] = React.useState(void 0), [logsCopyState, setLogsCopyState] = React.useState("idle"), logsRequestRun = React.useRef(0), logsCopyTimer = React.useRef(void 0), logsViewportRef = React.useRef(null), [resetBusy, setResetBusy] = React.useState(!1), [retryStartupBusy, setRetryStartupBusy] = React.useState(!1), [terminalBusy, setTerminalBusy] = React.useState(!1), [sidebarEntry, setSidebarEntry] = React.useState(() => props.sidebarEntry?.read?.() ?? "standard"), [sidebarEntryBusy, setSidebarEntryBusy] = React.useState(!1), [acpBackends, setAcpBackends] = React.useState([]), [acpAvailability, setAcpAvailability] = React.useState({}), [acpDiagnostics, setAcpDiagnostics] = React.useState({}), [acpChecking, setAcpChecking] = React.useState({}), [acpInstalling, setAcpInstalling] = React.useState({}), [acpCheckResults, setAcpCheckResults] = React.useState({}), [newAcpId, setNewAcpId] = React.useState(""), [newAcpCommand, setNewAcpCommand] = React.useState(""), [newAcpArgs, setNewAcpArgs] = React.useState("acp"), [addingAcp, setAddingAcp] = React.useState(!1), [addAcpFormOpen, setAddAcpFormOpen] = React.useState(!1), [reconnectBusy, setReconnectBusy] = React.useState(!1), [hostStatus, setHostStatus] = React.useState(void 0), [hostName, setHostName] = React.useState(""), [hostDeviceId, setHostDeviceId] = React.useState(""), [notice, setNotice] = React.useState(void 0), [failure, setError] = React.useState(void 0), error = failure instanceof ControlRouteUnavailableError ? t("remoteControlUnavailable") : failure, reportError = (reason) => {
4822
+ ), [open, setOpen] = React.useState(props.view === "page"), [serverUrl, setServerUrl] = React.useState(""), [savingServer, setSavingServer] = React.useState(!1), [editingServer, setEditingServer] = React.useState(!1), serverDraftEdited = React.useRef(!1), [remoteToolsBusy, setRemoteToolsBusy] = React.useState(!1), [remoteToolsEnabled, setRemoteToolsEnabled] = React.useState(() => props.remoteTools?.read?.() ?? !0), [associations, setAssociations] = React.useState({}), [loaded, setLoaded] = React.useState(!1), [writable, setWritable] = React.useState(!1), [busy, setBusy] = React.useState(!1), [terminalEnabled, setTerminalEnabled] = React.useState(!1), [debugBusy, setDebugBusy] = React.useState(!1), [debugLogging, setDebugLogging] = React.useState(!1), [logsOpen, setLogsOpen] = React.useState(!1), [logsFilter, setLogsFilter] = React.useState("all"), [logsLoading, setLogsLoading] = React.useState(!1), [logsClearing, setLogsClearing] = React.useState(!1), [logsSnapshot, setLogsSnapshot] = React.useState(void 0), [logsError, setLogsError] = React.useState(void 0), [logsCopyState, setLogsCopyState] = React.useState("idle"), logsRequestRun = React.useRef(0), logsCopyTimer = React.useRef(void 0), logsViewportRef = React.useRef(null), [resetBusy, setResetBusy] = React.useState(!1), [retryStartupBusy, setRetryStartupBusy] = React.useState(!1), [terminalBusy, setTerminalBusy] = React.useState(!1), [sidebarEntry, setSidebarEntry] = React.useState(() => props.sidebarEntry?.read?.() ?? "standard"), [sidebarEntryBusy, setSidebarEntryBusy] = React.useState(!1), [acpBackends, setAcpBackends] = React.useState([]), [acpAvailability, setAcpAvailability] = React.useState({}), [acpDiagnostics, setAcpDiagnostics] = React.useState({}), [acpChecking, setAcpChecking] = React.useState({}), [acpInstalling, setAcpInstalling] = React.useState({}), [acpCheckResults, setAcpCheckResults] = React.useState({}), [newAcpId, setNewAcpId] = React.useState(""), [newAcpCommand, setNewAcpCommand] = React.useState(""), [newAcpArgs, setNewAcpArgs] = React.useState("acp"), [addingAcp, setAddingAcp] = React.useState(!1), [addAcpFormOpen, setAddAcpFormOpen] = React.useState(!1), [reconnectBusy, setReconnectBusy] = React.useState(!1), [hostStatus, setHostStatus] = React.useState(void 0), [hostName, setHostName] = React.useState(""), [hostDeviceId, setHostDeviceId] = React.useState(""), [notice, setNotice] = React.useState(void 0), [failure, setError] = React.useState(void 0), error = failure instanceof ControlRouteUnavailableError ? t("remoteControlUnavailable") : failure, reportError = (reason) => {
4722
4823
  setError(reason instanceof ControlRouteUnavailableError ? reason : messageOf(reason, t));
4723
4824
  }, [settingsView, setSettingsView] = React.useState(void 0), [signInOpen, setSignInOpen] = React.useState(!1), [loginEmail, setLoginEmail] = React.useState(""), [loginPassword, setLoginPassword] = React.useState(""), [loginMethod, setLoginMethod] = React.useState("password"), [oauthProviders, setOAuthProviders] = React.useState([]), [providersLoading, setProvidersLoading] = React.useState(!1), [providersFailed, setProvidersFailed] = React.useState(!1), [pairingServerUrl, setPairingServerUrl] = React.useState(void 0), [qrSession, setQrSession] = React.useState(void 0), [qrImage, setQrImage] = React.useState(void 0), [qrExpired, setQrExpired] = React.useState(!1), [qrFailed, setQrFailed] = React.useState(!1), [qrBusy, setQrBusy] = React.useState(!1), [qrCompleted, setQrCompleted] = React.useState(!1), [providerReload, setProviderReload] = React.useState(0), [completionReload, setCompletionReload] = React.useState(0), qrFlowRun = React.useRef(0), providerRequestRun = React.useRef(0), loginMethodManuallySelected = React.useRef(!1), associationReadRun = React.useRef(0), association = associations.client ?? associations.host;
4724
4825
  React.useEffect(() => {
@@ -4731,7 +4832,9 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
4731
4832
  let applyAssociations = (view) => {
4732
4833
  setAssociations(view.associations ?? (view.association === void 0 ? {} : { host: view.association }));
4733
4834
  }, applyView = (view, updateAssociations = !0) => {
4734
- setError((current) => current instanceof ControlRouteUnavailableError ? void 0 : current), setSettingsView(view), serverDraftEdited.current || setServerUrl(view.config.serverUrl ?? "https://dsh.r2049.cn"), setTerminalEnabled(view.config.terminal?.enabled ?? !0), setDebugLogging(view.config.logLevel === "debug"), setRemoteToolsEnabled(view.config.remoteTools?.enabled ?? !0), setSidebarEntry(view.config.sidebar?.entry ?? "standard"), props.sidebarEntry?.publish(view.config.sidebar?.entry ?? "standard"), setAcpBackends((view.config.acp?.backends ?? []).map((item) => ({ id: item.id, enabled: item.enabled !== !1 }))), setAcpAvailability(view.acpAvailability ?? {}), setAcpDiagnostics(view.acpDiagnostics ?? {}), updateAssociations && applyAssociations(view), setWritable(view.writable), setLoaded(!0);
4835
+ setError((current) => current instanceof ControlRouteUnavailableError ? void 0 : current), setSettingsView(view), serverDraftEdited.current || setServerUrl(view.config.serverUrl ?? "https://dsh.r2049.cn"), setTerminalEnabled(view.config.terminal?.enabled ?? !0), setDebugLogging(view.config.logLevel === "debug");
4836
+ let nextRemoteToolsEnabled = view.config.remoteTools?.enabled !== !1;
4837
+ setRemoteToolsEnabled(nextRemoteToolsEnabled), props.remoteTools?.publish(nextRemoteToolsEnabled), setSidebarEntry(view.config.sidebar?.entry ?? "standard"), props.sidebarEntry?.publish(view.config.sidebar?.entry ?? "standard"), setAcpBackends((view.config.acp?.backends ?? []).map((item) => ({ id: item.id, enabled: item.enabled !== !1 }))), setAcpAvailability(view.acpAvailability ?? {}), setAcpDiagnostics(view.acpDiagnostics ?? {}), updateAssociations && applyAssociations(view), setWritable(view.writable), setLoaded(!0);
4735
4838
  };
4736
4839
  React.useEffect(() => {
4737
4840
  if (!(failure instanceof ControlRouteUnavailableError)) return;
@@ -8250,7 +8353,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
8250
8353
  }
8251
8354
  }
8252
8355
  function createStatusFeed(options) {
8253
- let listeners = /* @__PURE__ */ new Set(), pollIntervalMs = options.pollIntervalMs ?? 1500, openTimeoutMs = options.openTimeoutMs ?? 4e3, createSource = options.createSource ?? ((url) => new EventSource(url)), status, source, openTimer, pollTimer, publish = (next) => {
8356
+ let listeners = /* @__PURE__ */ new Set(), pollIntervalMs = options.pollIntervalMs ?? 1500, openTimeoutMs = options.openTimeoutMs ?? 4e3, createSource2 = options.createSource ?? ((url) => new EventSource(url)), status, source, openTimer, pollTimer, publish = (next) => {
8254
8357
  status = next;
8255
8358
  for (let listener of [...listeners]) listener(next);
8256
8359
  }, teardown = () => {
@@ -8265,7 +8368,7 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
8265
8368
  }, openStream = () => {
8266
8369
  let opened;
8267
8370
  try {
8268
- opened = createSource(options.url);
8371
+ opened = createSource2(options.url);
8269
8372
  } catch {
8270
8373
  fallbackToPolling("unsupported");
8271
8374
  return;
@@ -8635,6 +8738,17 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
8635
8738
  for (let listener of sidebarEntryListeners) listener();
8636
8739
  }
8637
8740
  }
8741
+ }, remoteToolsEnabled, remoteToolsListeners = /* @__PURE__ */ new Set(), remoteTools = {
8742
+ read: () => remoteToolsEnabled,
8743
+ subscribe: (listener) => (remoteToolsListeners.add(listener), () => {
8744
+ remoteToolsListeners.delete(listener);
8745
+ }),
8746
+ publish: (enabled) => {
8747
+ if (enabled !== remoteToolsEnabled) {
8748
+ remoteToolsEnabled = enabled;
8749
+ for (let listener of [...remoteToolsListeners]) listener();
8750
+ }
8751
+ }
8638
8752
  }, controlRouteRetryAfter = 0, controlRouteBackoffIndex = 0, control = async (endpoint, payload = {}) => {
8639
8753
  if (endpoint === "status" && (isHostcTunnel || Date.now() < controlRouteRetryAfter))
8640
8754
  return controlRouteUnavailableStatus();
@@ -8722,49 +8836,18 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
8722
8836
  React.createElement("path", { d: "M5 14h6M8 11.5v2.5" })
8723
8837
  );
8724
8838
  if (ctx.inject(["inputTriggers"], (inputContext) => {
8725
- let hostCache = /* @__PURE__ */ new Map();
8726
8839
  inputContext.effect(() => {
8727
- let inputTriggers = inputContext.inputTriggers, source = {
8728
- trigger: "@",
8729
- name: "\u4E3B\u673A",
8730
- order: -20,
8731
- showGroupTitle: !0,
8732
- candidates: async (_session, request) => {
8733
- if ((await control("settings.get").catch(() => {
8734
- }))?.config?.remoteTools?.enabled === !1) return [];
8735
- let devices = await control("devices").catch(() => []), query = request.query.trim().toLocaleLowerCase();
8736
- return devices.filter((device) => device.online && (query === "" || `${device.name} ${device.deviceId}`.toLocaleLowerCase().includes(query))).map((device) => (hostCache.set(device.name, device), {
8737
- name: device.name,
8738
- label: device.name,
8739
- description: t("remoteHostMention", { platform: device.platform }),
8740
- icon: RemoteMentionIcon,
8741
- value: JSON.stringify({ deviceId: device.deviceId, label: device.name, platform: device.platform })
8742
- }));
8743
- },
8744
- onPick: (pick) => {
8745
- let host = JSON.parse(pick.candidate.value);
8746
- return { text: `@${host.label} (Remote hostId=${JSON.stringify(host.deviceId)}) ` };
8747
- }
8748
- }, stopHostFileOpen = (event) => {
8749
- let target = event.target instanceof Element ? event.target.closest('button,[role="button"],a') ?? event.target : void 0;
8750
- if (!(target instanceof Element)) return;
8751
- let text = target.textContent?.trim().replace(/^@/, "") ?? "", device = hostCache.get(text);
8752
- if (!device) return;
8753
- event.preventDefault(), event.stopImmediatePropagation();
8754
- let invocation = `@${device.name}`, container = target;
8755
- for (let depth = 0; depth < 20 && container !== null; depth += 1) {
8756
- let candidate = container.textContent?.trim() ?? "";
8757
- candidate.includes(device.name) && candidate.length > invocation.length && candidate.length < 4e3 && (invocation = candidate), container = container.parentElement;
8758
- }
8759
- page.dispatchEvent(new CustomEvent("dsh-remote-host-reference", {
8760
- detail: { label: device.name, platform: device.platform, deviceId: device.deviceId, invocation }
8761
- }));
8762
- };
8763
- pageDocument.addEventListener("click", stopHostFileOpen, !0);
8764
- let unregister = inputTriggers.registerSource(source);
8765
- return () => {
8766
- pageDocument.removeEventListener("click", stopHostFileOpen, !0), unregister();
8767
- };
8840
+ let inputTriggers = inputContext.get("inputTriggers") ?? inputContext.inputTriggers;
8841
+ return typeof inputTriggers?.registerSource != "function" ? () => {
8842
+ } : installRemoteHostMentionSource({
8843
+ inputTriggers,
8844
+ control,
8845
+ statusFeed,
8846
+ remoteTools,
8847
+ t,
8848
+ icon: RemoteMentionIcon,
8849
+ isHostcTunnel
8850
+ });
8768
8851
  }, "ds-harness-remote: host mention source");
8769
8852
  }), ctx.effect(() => ctx.locale.register(localeNamespace, { zh, en, ru, uk }), "ds-harness-remote: dictionaries"), ctx.effect(() => installStyle(clientModuleId), "ds-harness-remote: client styles"), ctx.effect(() => installTerminalAvailabilityNotice(statusFeed, t), "ds-harness-remote: terminal availability notice"), isHostcTunnel) {
8770
8853
  let WebFooter2 = function() {
@@ -8853,7 +8936,8 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
8853
8936
  statusFeed,
8854
8937
  onSignIn: openRemote,
8855
8938
  preferredQrProvider: ctx.locale.getLocale().active === "zh" ? "zhihu" : "github",
8856
- sidebarEntry
8939
+ sidebarEntry,
8940
+ remoteTools
8857
8941
  })
8858
8942
  }, RemotePluginOptions)), ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
8859
8943
  name: "plugins.bundle.config",
@@ -8866,7 +8950,8 @@ DSH Go \u626B\u7801\u6682\u4E0D\u652F\u6301\u591A\u53F0\u8BBE\u5907\u63A7\u5236\
8866
8950
  statusFeed,
8867
8951
  onSignIn: openRemote,
8868
8952
  preferredQrProvider: ctx.locale.getLocale().active === "zh" ? "zhihu" : "github",
8869
- sidebarEntry
8953
+ sidebarEntry,
8954
+ remoteTools
8870
8955
  })
8871
8956
  }, RemotePluginOptions)), ctx.slots.inject("plugins.detail.actions", () => ctx.slots.register({
8872
8957
  name: "plugins.detail.actions",