dsh-more 0.1.0 → 0.1.2

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.
Files changed (35) hide show
  1. package/CONTRIBUTING.md +13 -0
  2. package/README.md +26 -7
  3. package/README.zh-CN.md +40 -7
  4. package/cordis.patch.yml +2 -0
  5. package/dist/client.js +876 -303
  6. package/dist/fast-mode.js +34 -0
  7. package/dist/index.js +324 -35
  8. package/dist/types/generated/host-settings-schema.d.ts +21 -17
  9. package/dist/types/generated/patch-catalog.d.ts +16 -0
  10. package/dist/types/kernel/client/activation.d.ts +2 -2
  11. package/dist/types/kernel/host/activation.d.ts +1 -0
  12. package/dist/types/kernel/host/patch.d.ts +2 -0
  13. package/dist/types/kernel/host/settings.d.ts +7 -3
  14. package/dist/types/patches/fast-mode/client/index.d.ts +19 -0
  15. package/dist/types/patches/fast-mode/client/styles.d.ts +1 -0
  16. package/dist/types/patches/fast-mode/host/index.d.ts +26 -0
  17. package/dist/types/patches/fast-mode/host/settings.d.ts +6 -0
  18. package/dist/types/patches/fast-mode/shared.d.ts +17 -0
  19. package/dist/types/patches/model-capabilities/client/index.d.ts +1 -1
  20. package/dist/types/patches/projectless-tasks/client/adapter.d.ts +2 -3
  21. package/dist/types/patches/projectless-tasks/client/create-task.d.ts +2 -2
  22. package/dist/types/patches/projectless-tasks/client/groups.d.ts +2 -2
  23. package/dist/types/patches/projectless-tasks/client/new-session.d.ts +2 -1
  24. package/dist/types/patches/terminal-clipboard/client/clipboard.d.ts +5 -0
  25. package/dist/types/patches/terminal-clipboard/client/index.d.ts +2 -0
  26. package/dist/types/patches/terminal-clipboard/client/terminal.d.ts +17 -0
  27. package/dist/types/patches/terminal-clipboard/host/index.d.ts +2 -0
  28. package/dist/types/patches/terminal-clipboard/shared.d.ts +1 -0
  29. package/dist/types/platform/dsh/client/runtime.d.ts +20 -2
  30. package/dist/types/platform/dsh/client/session-menu.d.ts +10 -0
  31. package/dist/types/platform/dsh/client/settings.d.ts +15 -1
  32. package/dist/types/platform/dsh/identity.d.ts +1 -1
  33. package/docs/desktop-compatibility.md +158 -0
  34. package/dsh.plugin.json +2 -2
  35. package/package.json +72 -61
@@ -0,0 +1,34 @@
1
+ // src/patches/fast-mode/host/settings.ts
2
+ import z from "@deepseek-ai/schemastery";
3
+
4
+ // src/platform/dsh/host/settings.ts
5
+ function liveSetting(schema) {
6
+ const volatile = Reflect.get(schema, "volatile");
7
+ return typeof volatile === "function" ? volatile.call(schema) : schema;
8
+ }
9
+
10
+ // src/patches/fast-mode/shared.ts
11
+ var DEFAULT_FAST_MODE_SETTINGS = {
12
+ defaultEnabled: false,
13
+ serviceTier: "priority",
14
+ speed: 1.5,
15
+ enableAnthropicFastMode: true,
16
+ customBodyParams: {},
17
+ customHeaders: {}
18
+ };
19
+
20
+ // src/patches/fast-mode/host/settings.ts
21
+ var Config = z.object({
22
+ defaultEnabled: liveSetting(z.boolean().default(DEFAULT_FAST_MODE_SETTINGS.defaultEnabled)),
23
+ serviceTier: liveSetting(z.string().default(DEFAULT_FAST_MODE_SETTINGS.serviceTier)),
24
+ speed: liveSetting(z.number().default(DEFAULT_FAST_MODE_SETTINGS.speed)),
25
+ enableAnthropicFastMode: liveSetting(z.boolean().default(DEFAULT_FAST_MODE_SETTINGS.enableAnthropicFastMode)),
26
+ customBodyParams: liveSetting(z.dict(z.any()).default({})),
27
+ customHeaders: liveSetting(z.dict(z.string()).default({}))
28
+ });
29
+ function apply() {
30
+ }
31
+ export {
32
+ Config,
33
+ apply
34
+ };
package/dist/index.js CHANGED
@@ -180,7 +180,7 @@ function retainedRuntimeContexts(seed) {
180
180
  const event = seed[index];
181
181
  if (event?.type !== "user/message") continue;
182
182
  const source = event.data.source;
183
- if (source.plugin !== RUNTIME_CONTEXT_PLUGIN) continue;
183
+ if (source.kind !== "runtime-context" && source.plugin !== RUNTIME_CONTEXT_PLUGIN) continue;
184
184
  if (source.form === "snapshot" && Array.isArray(source.sections)) {
185
185
  const sections = source.sections.filter((section) => {
186
186
  const value = section;
@@ -409,7 +409,7 @@ var MESSAGE_VISIBILITY_PROJECTION_KEY = "dshMoreMessageDelete";
409
409
 
410
410
  // src/platform/dsh/identity.ts
411
411
  var PLUGIN_NAME = "dsh-more";
412
- var PLUGIN_API_PREFIX = `/${PLUGIN_NAME}/api`;
412
+ var PLUGIN_API_PREFIX = `/api/${PLUGIN_NAME}`;
413
413
  var PLUGIN_MUTATION_HEADER = "x-dsh-more";
414
414
  var PATCH_SETTINGS_NAMESPACE = PLUGIN_NAME;
415
415
 
@@ -760,8 +760,12 @@ function installLiveSessionHandleTracker(ctx) {
760
760
  tracker.originalResume = originalResume;
761
761
  tracker.createDescriptor = Object.getOwnPropertyDescriptor(registry, "create");
762
762
  tracker.resumeDescriptor = Object.getOwnPropertyDescriptor(registry, "resume");
763
- tracker.wrappedCreate = async (options) => trackedHandle(tracker, await originalCreate.call(registry, options));
764
- tracker.wrappedResume = async (options) => trackedHandle(tracker, await originalResume.call(registry, options));
763
+ tracker.wrappedCreate = async function(options) {
764
+ return trackedHandle(tracker, await originalCreate.call(this, options));
765
+ };
766
+ tracker.wrappedResume = async function(options) {
767
+ return trackedHandle(tracker, await originalResume.call(this, options));
768
+ };
765
769
  tracker.references = 1;
766
770
  registry[TRACKER] = tracker;
767
771
  registry.create = tracker.wrappedCreate;
@@ -882,7 +886,9 @@ async function deleteSessionPermanently(ctx, rawSessionId) {
882
886
  // src/patches/session-delete/host/index.ts
883
887
  var hostPatch3 = {
884
888
  id: SESSION_DELETE_PATCH_ID,
885
- setup: installLiveSessionHandleTracker,
889
+ // A disabled action still needs to remember handles created during that time.
890
+ // Track for the plugin lifetime; the API router remains gated by the switch.
891
+ observe: installLiveSessionHandleTracker,
886
892
  routes: ({ ctx }) => ({
887
893
  commit: async (payload) => {
888
894
  const sessionId = requireString(payload, "sessionId");
@@ -985,7 +991,7 @@ ${body}`;
985
991
  function sourceLabel(event) {
986
992
  const source = event.data.source;
987
993
  if (source.kind === "user") return "\u7528\u6237";
988
- if (source.kind === "plugin") return `\u4E0A\u4E0B\u6587 \xB7 ${singleLine(source.plugin) || "\u63D2\u4EF6"}`;
994
+ if (source.kind === "plugin") return `\u4E0A\u4E0B\u6587 \xB7 ${singleLine(source.plugin ?? "") || "\u63D2\u4EF6"}`;
989
995
  return "\u4E0A\u4E0B\u6587";
990
996
  }
991
997
  function conversationMarkdown(events, options) {
@@ -1020,7 +1026,7 @@ function conversationMarkdown(events, options) {
1020
1026
  if (event.type === "tool/result") {
1021
1027
  const callId = String(event.data.message.source.callId);
1022
1028
  const block = event.data.message.content[0];
1023
- const failed = block?.type === "tool-result" && block.isError === true;
1029
+ const failed = event.data.message.isError === true || block?.type === "tool-result" && block.isError === true;
1024
1030
  const resultContent = block?.type === "tool-result" ? block.content : event.data.message.content;
1025
1031
  const name2 = singleLine(callNames.get(callId) ?? callId) || "\u672A\u547D\u540D\u5DE5\u5177";
1026
1032
  sections.push(messageSection(
@@ -1154,7 +1160,8 @@ function settingValue(value) {
1154
1160
  return typeof get === "function" ? get.call(value) : value;
1155
1161
  }
1156
1162
  function readSettings(ctx, namespace) {
1157
- if (typeof ctx.settings.get === "function") return ctx.settings.get(namespace);
1163
+ const legacy = ctx.settings;
1164
+ if (typeof legacy.get === "function") return legacy.get(namespace);
1158
1165
  return ctx.settings.describe().find((entry) => entry.ns === namespace)?.value;
1159
1166
  }
1160
1167
 
@@ -1415,6 +1422,203 @@ var hostPatch5 = {
1415
1422
  routes: ({ ctx }) => ({ read: () => read(ctx), save: (payload) => save(ctx, payload) })
1416
1423
  };
1417
1424
 
1425
+ // src/patches/fast-mode/host/index.ts
1426
+ import { AsyncLocalStorage } from "node:async_hooks";
1427
+
1428
+ // src/patches/fast-mode/host/settings.ts
1429
+ import z2 from "@deepseek-ai/schemastery";
1430
+
1431
+ // src/patches/fast-mode/shared.ts
1432
+ var FAST_MODE_PATCH_ID = "fast-mode";
1433
+ var FAST_MODE_SETTINGS_NS = "dsh-more/fast-mode";
1434
+ var DEFAULT_FAST_MODE_SETTINGS = {
1435
+ defaultEnabled: false,
1436
+ serviceTier: "priority",
1437
+ speed: 1.5,
1438
+ enableAnthropicFastMode: true,
1439
+ customBodyParams: {},
1440
+ customHeaders: {}
1441
+ };
1442
+
1443
+ // src/patches/fast-mode/host/settings.ts
1444
+ var Config = z2.object({
1445
+ defaultEnabled: liveSetting(z2.boolean().default(DEFAULT_FAST_MODE_SETTINGS.defaultEnabled)),
1446
+ serviceTier: liveSetting(z2.string().default(DEFAULT_FAST_MODE_SETTINGS.serviceTier)),
1447
+ speed: liveSetting(z2.number().default(DEFAULT_FAST_MODE_SETTINGS.speed)),
1448
+ enableAnthropicFastMode: liveSetting(z2.boolean().default(DEFAULT_FAST_MODE_SETTINGS.enableAnthropicFastMode)),
1449
+ customBodyParams: liveSetting(z2.dict(z2.any()).default({})),
1450
+ customHeaders: liveSetting(z2.dict(z2.string()).default({}))
1451
+ });
1452
+
1453
+ // src/patches/fast-mode/host/index.ts
1454
+ var activeFastSessionStorage = new AsyncLocalStorage();
1455
+ var fastSessions = /* @__PURE__ */ new Set();
1456
+ function isFastSession(sessionId) {
1457
+ if (!sessionId) return false;
1458
+ return fastSessions.has(sessionId);
1459
+ }
1460
+ function setFastSession(sessionId, enabled) {
1461
+ if (enabled) fastSessions.add(sessionId);
1462
+ else fastSessions.delete(sessionId);
1463
+ }
1464
+ function toggleFastSession(sessionId) {
1465
+ const next = !fastSessions.has(sessionId);
1466
+ setFastSession(sessionId, next);
1467
+ return next;
1468
+ }
1469
+ var interceptorInstalled = false;
1470
+ var currentSettings = { ...DEFAULT_FAST_MODE_SETTINGS };
1471
+ function readSettings2(ctx) {
1472
+ const value = readSettings(ctx, FAST_MODE_SETTINGS_NS);
1473
+ if (typeof value !== "object" || value === null) {
1474
+ return { ...DEFAULT_FAST_MODE_SETTINGS };
1475
+ }
1476
+ const val = value;
1477
+ return {
1478
+ defaultEnabled: typeof val.defaultEnabled === "boolean" ? val.defaultEnabled : false,
1479
+ serviceTier: typeof val.serviceTier === "string" && val.serviceTier ? val.serviceTier : "priority",
1480
+ speed: typeof val.speed === "number" && val.speed > 0 ? val.speed : 1.5,
1481
+ enableAnthropicFastMode: typeof val.enableAnthropicFastMode === "boolean" ? val.enableAnthropicFastMode : true,
1482
+ customBodyParams: typeof val.customBodyParams === "object" && val.customBodyParams !== null ? val.customBodyParams : {},
1483
+ customHeaders: typeof val.customHeaders === "object" && val.customHeaders !== null ? val.customHeaders : {}
1484
+ };
1485
+ }
1486
+ function bodyText(body) {
1487
+ if (typeof body === "string") return body;
1488
+ if (body instanceof Uint8Array) return new TextDecoder().decode(body);
1489
+ return void 0;
1490
+ }
1491
+ function codexFastTier(value) {
1492
+ const tier = (value ?? "").trim().toLowerCase();
1493
+ if (tier === "" || tier === "fast" || tier === "priority") return "priority";
1494
+ return tier;
1495
+ }
1496
+ function isModelPayload(value) {
1497
+ return typeof value.model === "string" && ("messages" in value || "input" in value || "contents" in value);
1498
+ }
1499
+ function requestUrl(input) {
1500
+ if (typeof input === "string") return input;
1501
+ if (input instanceof URL) return input.toString();
1502
+ return input.url;
1503
+ }
1504
+ function patchFastRequest(input, init) {
1505
+ const store = activeFastSessionStorage.getStore();
1506
+ if (!store?.isFast || init?.body == null) return { input, init };
1507
+ const text = bodyText(init.body);
1508
+ if (text === void 0) return { input, init };
1509
+ let parsed;
1510
+ try {
1511
+ parsed = JSON.parse(text);
1512
+ } catch {
1513
+ return { input, init };
1514
+ }
1515
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return { input, init };
1516
+ const body = parsed;
1517
+ if (!isModelPayload(body)) return { input, init };
1518
+ body.service_tier = codexFastTier(currentSettings.serviceTier);
1519
+ if (currentSettings.customBodyParams) Object.assign(body, currentSettings.customBodyParams);
1520
+ const nextBody = JSON.stringify(body);
1521
+ const headers = new Headers(init.headers);
1522
+ if (headers.has("content-length")) headers.set("content-length", String(Buffer.byteLength(nextBody)));
1523
+ const url = requestUrl(input);
1524
+ if (currentSettings.enableAnthropicFastMode && /anthropic\.com|\/v1\/messages\b/.test(url)) {
1525
+ const beta = headers.get("anthropic-beta");
1526
+ headers.set("anthropic-beta", beta && !beta.includes("fast-mode") ? `${beta},fast-mode-2026-02-01` : beta ?? "fast-mode-2026-02-01");
1527
+ }
1528
+ if (currentSettings.customHeaders) {
1529
+ for (const [name2, value] of Object.entries(currentSettings.customHeaders)) headers.set(name2, value);
1530
+ }
1531
+ return { input, init: { ...init, body: nextBody, headers } };
1532
+ }
1533
+ function bindFastStream(stream, store) {
1534
+ const iterator = stream[Symbol.asyncIterator]();
1535
+ const pull = (run) => activeFastSessionStorage.run(store, run);
1536
+ const bound = {
1537
+ [Symbol.asyncIterator]() {
1538
+ return bound;
1539
+ },
1540
+ next: () => pull(() => iterator.next()),
1541
+ return: (value) => pull(() => iterator.return?.(value) ?? Promise.resolve({ done: true, value: void 0 })),
1542
+ throw: (error) => pull(() => iterator.throw?.(error) ?? Promise.reject(error))
1543
+ };
1544
+ return bound;
1545
+ }
1546
+ function installFastModeInterceptor() {
1547
+ if (interceptorInstalled) return;
1548
+ interceptorInstalled = true;
1549
+ const originalFetch = globalThis.fetch;
1550
+ globalThis.fetch = async function(input, init) {
1551
+ let patched = { input, init };
1552
+ try {
1553
+ patched = patchFastRequest(input, init);
1554
+ } catch (error) {
1555
+ console.warn("fast-mode fetch interceptor error, sending the original request", error);
1556
+ }
1557
+ return originalFetch.call(this, patched.input, patched.init);
1558
+ };
1559
+ }
1560
+ var hostPatch6 = {
1561
+ id: FAST_MODE_PATCH_ID,
1562
+ setup: (ctx) => {
1563
+ const legacy = ctx.settings;
1564
+ legacy.register?.(FAST_MODE_SETTINGS_NS, Config);
1565
+ const refreshSettings = () => {
1566
+ currentSettings = readSettings2(ctx);
1567
+ };
1568
+ refreshSettings();
1569
+ const disposeSettings = ctx.on("settings/document-updated", (namespace) => {
1570
+ if (namespace === FAST_MODE_SETTINGS_NS) refreshSettings();
1571
+ });
1572
+ installFastModeInterceptor();
1573
+ const dispose = ctx.on("llm/stream", (options, next) => {
1574
+ if (options?.purpose === "session-title" || options?.purpose === "compaction") return next();
1575
+ const sessionId = options?.sessionId === void 0 ? void 0 : String(options.sessionId);
1576
+ const enabled = sessionId !== void 0 && isFastSession(sessionId) || currentSettings.defaultEnabled;
1577
+ if (!enabled) return next();
1578
+ return bindFastStream(next(), { sessionId, isFast: true });
1579
+ }, { global: true, prepend: true });
1580
+ return () => {
1581
+ if (typeof dispose === "function") dispose();
1582
+ if (typeof disposeSettings === "function") disposeSettings();
1583
+ };
1584
+ },
1585
+ routes: ({ ctx }) => ({
1586
+ getState: (payload) => {
1587
+ const sessionId = typeof payload?.sessionId === "string" ? payload.sessionId : void 0;
1588
+ return { enabled: sessionId ? isFastSession(sessionId) : false, settings: readSettings2(ctx) };
1589
+ },
1590
+ toggle: (payload) => {
1591
+ const sessionId = typeof payload?.sessionId === "string" ? payload.sessionId : "";
1592
+ if (!sessionId) throw new Error("\u7F3A\u5C11 sessionId");
1593
+ return { enabled: toggleFastSession(sessionId) };
1594
+ },
1595
+ set: (payload) => {
1596
+ const sessionId = typeof payload?.sessionId === "string" ? payload.sessionId : "";
1597
+ if (!sessionId) throw new Error("\u7F3A\u5C11 sessionId");
1598
+ const enabled = Boolean(payload?.enabled);
1599
+ setFastSession(sessionId, enabled);
1600
+ return { enabled };
1601
+ },
1602
+ getSettings: () => readSettings2(ctx),
1603
+ saveSettings: async (payload) => {
1604
+ if (typeof payload !== "object" || payload === null) throw new Error("\u65E0\u6548\u7684\u914D\u7F6E\u5185\u5BB9");
1605
+ const descriptor = ctx.settings?.describe?.().find((entry) => entry.ns === FAST_MODE_SETTINGS_NS);
1606
+ const next = {
1607
+ defaultEnabled: Boolean(payload.defaultEnabled),
1608
+ serviceTier: typeof payload.serviceTier === "string" && payload.serviceTier ? payload.serviceTier : "priority",
1609
+ speed: typeof payload.speed === "number" && payload.speed > 0 ? payload.speed : 1.5,
1610
+ enableAnthropicFastMode: payload.enableAnthropicFastMode !== false,
1611
+ customBodyParams: typeof payload.customBodyParams === "object" && payload.customBodyParams !== null ? payload.customBodyParams : {},
1612
+ customHeaders: typeof payload.customHeaders === "object" && payload.customHeaders !== null ? payload.customHeaders : {}
1613
+ };
1614
+ if (!descriptor || typeof ctx.settings?.mutate !== "function") throw new Error("\u52A0\u901F\u914D\u7F6E\u5C1A\u672A\u6CE8\u518C\uFF0C\u65E0\u6CD5\u4FDD\u5B58");
1615
+ await ctx.settings.mutate(FAST_MODE_SETTINGS_NS, [{ op: "set", path: [], value: next }], descriptor.revision);
1616
+ currentSettings = next;
1617
+ return next;
1618
+ }
1619
+ })
1620
+ };
1621
+
1418
1622
  // src/patches/session-auto-title/host/index.ts
1419
1623
  import { setTimeout as delay } from "node:timers/promises";
1420
1624
 
@@ -1477,7 +1681,7 @@ async function* validate(stream, signal, status) {
1477
1681
  throw error;
1478
1682
  }
1479
1683
  }
1480
- var hostPatch6 = {
1684
+ var hostPatch7 = {
1481
1685
  id: SESSION_AUTO_TITLE_PATCH_ID,
1482
1686
  setup: (ctx) => {
1483
1687
  const status = { requests: 0, successes: 0, failures: 0, retries: 0 };
@@ -1554,10 +1758,10 @@ function decodeSessionGroups(value) {
1554
1758
  }
1555
1759
 
1556
1760
  // src/patches/projectless-tasks/host/groups.ts
1557
- import z2 from "@deepseek-ai/schemastery";
1761
+ import z3 from "@deepseek-ai/schemastery";
1558
1762
  import { SessionId as SessionId7 } from "@deepseek-ai/dsh-session";
1559
1763
  import { WorkspaceId } from "@deepseek-ai/dsh-workspace";
1560
- var SessionGroupsSchema = z2.object({ assignments: z2.dict(z2.string()).default({}) });
1764
+ var SessionGroupsSchema = z3.object({ assignments: z3.dict(z3.string()).default({}) });
1561
1765
  async function moveSessionGroup(ctx, payload) {
1562
1766
  const sessionId = SessionId7(requireString(payload, "sessionId"));
1563
1767
  if (typeof payload !== "object" || payload === null || !("workspaceId" in payload) || !(payload.workspaceId === null || typeof payload.workspaceId === "string" && payload.workspaceId.length > 0)) {
@@ -1592,12 +1796,13 @@ function prepareTask(payload, homeDirectory = homedir()) {
1592
1796
  }
1593
1797
  return { sessionId: payload.sessionId, cwd: join(homeDirectory, "Documents", "DSH", "tasks", payload.sessionId) };
1594
1798
  }
1595
- var hostPatch7 = {
1799
+ var hostPatch8 = {
1596
1800
  id: PROJECTLESS_TASKS_PATCH_ID,
1597
1801
  setup: (ctx) => {
1598
1802
  const fiber = ctx.inject(["settings"], (scope) => {
1599
- if (typeof scope.settings.register === "function") {
1600
- scope.settings.register(SESSION_GROUPS_NAMESPACE, SessionGroupsSchema);
1803
+ const legacy = scope.settings;
1804
+ if (typeof legacy.register === "function") {
1805
+ legacy.register(SESSION_GROUPS_NAMESPACE, SessionGroupsSchema);
1601
1806
  }
1602
1807
  });
1603
1808
  return () => {
@@ -1607,8 +1812,17 @@ var hostPatch7 = {
1607
1812
  routes: ({ ctx }) => ({ prepare: (payload) => prepareTask(payload), move: (payload) => moveSessionGroup(ctx, payload) })
1608
1813
  };
1609
1814
 
1815
+ // src/patches/terminal-clipboard/shared.ts
1816
+ var TERMINAL_CLIPBOARD_PATCH_ID = "terminal-clipboard";
1817
+
1818
+ // src/patches/terminal-clipboard/host/index.ts
1819
+ var hostPatch9 = {
1820
+ id: TERMINAL_CLIPBOARD_PATCH_ID,
1821
+ routes: () => ({ status: () => ({ available: true }) })
1822
+ };
1823
+
1610
1824
  // src/generated/host-registry.ts
1611
- var HOST_PATCHES = [hostPatch, hostPatch2, hostPatch3, hostPatch4, hostPatch5, hostPatch6, hostPatch7];
1825
+ var HOST_PATCHES = [hostPatch, hostPatch2, hostPatch3, hostPatch4, hostPatch5, hostPatch6, hostPatch7, hostPatch8, hostPatch9];
1612
1826
 
1613
1827
  // src/generated/patch-catalog.ts
1614
1828
  var PATCH_CATALOG = [
@@ -1617,8 +1831,10 @@ var PATCH_CATALOG = [
1617
1831
  { "id": "session-delete", "name": "\u6C38\u4E45\u5220\u9664\u4F1A\u8BDD", "description": "\u505C\u6B62\u76EE\u6807\u4F1A\u8BDD\u5E76\u4ECE\u78C1\u76D8\u6C38\u4E45\u5220\u9664\uFF0C\u4E0D\u5F71\u54CD\u539F\u751F\u5F52\u6863", "defaultEnabled": true, "order": 300, "clientKind": "standalone" },
1618
1832
  { "id": "conversation-markdown-export", "name": "\u5BFC\u51FA\u5B8C\u6574\u804A\u5929\u8BB0\u5F55", "description": "\u5C06\u5F53\u524D\u4F1A\u8BDD\u7684\u5B8C\u6574\u804A\u5929\u8BB0\u5F55\u4E0B\u8F7D\u4E3A Markdown \u6587\u4EF6", "defaultEnabled": true, "order": 400, "clientKind": "standalone" },
1619
1833
  { "id": "model-capabilities", "name": "\u6A21\u578B\u80FD\u529B\u914D\u7F6E", "description": "\u5728\u6A21\u578B\u914D\u7F6E\u9875\u8BBE\u7F6E\u6BCF\u4E2A\u6A21\u578B\u7684\u8BC6\u56FE\u80FD\u529B\u3001\u53EF\u9009\u601D\u8003\u7C7B\u578B\u4E0E\u601D\u8003\u53C2\u6570\u683C\u5F0F", "defaultEnabled": true, "order": 500, "clientKind": "standalone" },
1834
+ { "id": "fast-mode", "name": "\u52A0\u901F", "description": "\u5728\u8F93\u5165\u6846\u548C /fast \u547D\u4EE4\u4E2D\u5F00\u5173\u52A0\u901F\u3002\u54CD\u5E94\u66F4\u5FEB\uFF0C\u4F46\u4F1A\u66F4\u5FEB\u6D88\u8017\u989D\u5EA6", "defaultEnabled": true, "order": 550, "clientKind": "standalone" },
1620
1835
  { "id": "session-auto-title", "name": "\u4F1A\u8BDD\u81EA\u52A8\u547D\u540D", "description": "\u65B0\u4F1A\u8BDD\u9996\u6761\u9700\u6C42\u540E\uFF0C\u4F7F\u7528\u5F53\u524D\u6A21\u578B\u751F\u6210\u300C\u7C7B\u578B \xB7 \u5177\u4F53\u4EFB\u52A1\u300D\u6807\u9898\uFF1B\u4FDD\u7559\u624B\u52A8\u547D\u540D\uFF0C\u5931\u8D25\u65F6\u4FDD\u7559\u539F\u6709\u6807\u9898", "defaultEnabled": true, "order": 600, "clientKind": "standalone" },
1621
- { "id": "projectless-tasks", "name": "\u72EC\u7ACB\u4EFB\u52A1", "description": "\u5728\u5DE5\u4F5C\u533A\u4E0B\u62C9\u6846\u521B\u5EFA\u72EC\u7ACB\u4EFB\u52A1\u5E76\u4FDD\u7559\u8349\u7A3F\uFF0C\u4E5F\u53EF\u5C06\u672A\u5206\u7EC4\u4F1A\u8BDD\u79FB\u5165\u5DE5\u4F5C\u533A\u5217\u8868", "defaultEnabled": true, "order": 700, "clientKind": "standalone" }
1836
+ { "id": "projectless-tasks", "name": "\u72EC\u7ACB\u4EFB\u52A1", "description": "\u5728\u5DE5\u4F5C\u533A\u4E0B\u62C9\u6846\u521B\u5EFA\u72EC\u7ACB\u4EFB\u52A1\u5E76\u4FDD\u7559\u8349\u7A3F\uFF0C\u4E5F\u53EF\u5C06\u672A\u5206\u7EC4\u4F1A\u8BDD\u79FB\u5165\u5DE5\u4F5C\u533A\u5217\u8868", "defaultEnabled": true, "order": 700, "clientKind": "standalone" },
1837
+ { "id": "terminal-clipboard", "name": "\u7EC8\u7AEF\u590D\u5236\u7C98\u8D34", "description": "\u53F3\u4FA7\u7EC8\u7AEF\u9009\u4E2D\u81EA\u52A8\u590D\u5236\u3001\u53F3\u952E\u7C98\u8D34\uFF0C\u652F\u6301 Ctrl+Shift+C/V \u548C Shift+Insert\uFF1B\u65E0\u9009\u533A\u65F6\u4FDD\u7559 Ctrl+C \u4E2D\u65AD", "defaultEnabled": true, "order": 800, "clientKind": "standalone" }
1622
1838
  ];
1623
1839
  var DEFAULT_PATCH_SETTINGS = {
1624
1840
  "message-edit": true,
@@ -1626,8 +1842,10 @@ var DEFAULT_PATCH_SETTINGS = {
1626
1842
  "session-delete": true,
1627
1843
  "conversation-markdown-export": true,
1628
1844
  "model-capabilities": true,
1845
+ "fast-mode": true,
1629
1846
  "session-auto-title": true,
1630
- "projectless-tasks": true
1847
+ "projectless-tasks": true,
1848
+ "terminal-clipboard": true
1631
1849
  };
1632
1850
  function decodePatchSettings(value) {
1633
1851
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
@@ -1647,10 +1865,28 @@ var HostPatchActivation = class {
1647
1865
  constructor(ctx, patches) {
1648
1866
  this.ctx = ctx;
1649
1867
  this.byId = new Map(patches.map((patch) => [patch.id, patch]));
1868
+ try {
1869
+ for (const patch of patches) {
1870
+ const dispose = patch.observe?.(ctx);
1871
+ if (dispose !== void 0) this.observers.push(dispose);
1872
+ }
1873
+ } catch (error) {
1874
+ const failures = [error];
1875
+ for (const dispose of this.observers.splice(0).reverse()) {
1876
+ try {
1877
+ dispose();
1878
+ } catch (failure) {
1879
+ failures.push(failure);
1880
+ }
1881
+ }
1882
+ if (failures.length > 1) throw new AggregateError(failures, "patch observation failed");
1883
+ throw error;
1884
+ }
1650
1885
  }
1651
1886
  ctx;
1652
1887
  byId;
1653
1888
  disposers = /* @__PURE__ */ new Map();
1889
+ observers = [];
1654
1890
  settings = { ...DEFAULT_PATCH_SETTINGS };
1655
1891
  apply(next) {
1656
1892
  for (const [id, patch] of this.byId) {
@@ -1669,45 +1905,58 @@ var HostPatchActivation = class {
1669
1905
  return this.settings[id] === true && this.byId.has(id);
1670
1906
  }
1671
1907
  dispose() {
1672
- for (const dispose of [...this.disposers.values()].reverse()) dispose();
1908
+ const disposers = [...this.disposers.values()].reverse();
1673
1909
  this.disposers.clear();
1910
+ disposers.push(...this.observers.splice(0).reverse());
1911
+ const failures = [];
1912
+ for (const dispose of disposers) {
1913
+ try {
1914
+ dispose();
1915
+ } catch (error) {
1916
+ failures.push(error);
1917
+ }
1918
+ }
1919
+ if (failures.length > 0) throw new AggregateError(failures, "patch cleanup failed");
1674
1920
  }
1675
1921
  };
1676
1922
 
1677
1923
  // src/kernel/host/settings.ts
1678
- import z4 from "@deepseek-ai/schemastery";
1924
+ import z5 from "@deepseek-ai/schemastery";
1679
1925
 
1680
1926
  // src/generated/host-settings-schema.ts
1681
- import z3 from "@deepseek-ai/schemastery";
1682
- var PatchSettingsSchema = z3.object({
1683
- "message-edit": z3.boolean().default(true),
1684
- "message-delete": z3.boolean().default(true),
1685
- "session-delete": z3.boolean().default(true),
1686
- "conversation-markdown-export": z3.boolean().default(true),
1687
- "model-capabilities": z3.boolean().default(true),
1688
- "session-auto-title": z3.boolean().default(true),
1689
- "projectless-tasks": z3.boolean().default(true)
1927
+ import z4 from "@deepseek-ai/schemastery";
1928
+ var PatchSettingsSchema = z4.object({
1929
+ "message-edit": z4.boolean().default(true),
1930
+ "message-delete": z4.boolean().default(true),
1931
+ "session-delete": z4.boolean().default(true),
1932
+ "conversation-markdown-export": z4.boolean().default(true),
1933
+ "model-capabilities": z4.boolean().default(true),
1934
+ "fast-mode": z4.boolean().default(true),
1935
+ "session-auto-title": z4.boolean().default(true),
1936
+ "projectless-tasks": z4.boolean().default(true),
1937
+ "terminal-clipboard": z4.boolean().default(true)
1690
1938
  });
1691
1939
 
1692
1940
  // src/kernel/host/settings.ts
1693
1941
  var PATCH_SETTINGS_NAMESPACE2 = PATCH_SETTINGS_NAMESPACE;
1694
- var PatchConfig = z4.object(Object.fromEntries(
1942
+ var PatchConfig = z5.object(Object.fromEntries(
1695
1943
  Object.entries(PatchSettingsSchema.dict ?? {}).map(([key, schema2]) => [key, liveSetting(schema2)])
1696
1944
  ));
1697
1945
  function installPatchSettings(ctx, activation, config = DEFAULT_PATCH_SETTINGS) {
1698
- if (typeof ctx.settings.installSection !== "function") {
1946
+ const settings = ctx.settings;
1947
+ if (typeof settings.installSection !== "function") {
1699
1948
  const refresh = () => {
1700
1949
  const values = typeof config === "object" && config !== null ? Object.fromEntries(Object.entries(config).map(([key, value]) => [key, settingValue(value)])) : config;
1701
- const settings = decodePatchSettings(values);
1702
- if (settings === void 0) throw new TypeError("Invalid DSH More patch configuration");
1703
- activation.apply(settings);
1950
+ const settings2 = decodePatchSettings(values);
1951
+ if (settings2 === void 0) throw new TypeError("Invalid DSH More patch configuration");
1952
+ activation.apply(settings2);
1704
1953
  };
1705
1954
  ctx.on("loader/volatile-update", refresh);
1706
1955
  refresh();
1707
1956
  return;
1708
1957
  }
1709
1958
  let source = () => DEFAULT_PATCH_SETTINGS;
1710
- ctx.settings.installSection(ctx, PATCH_SETTINGS_NAMESPACE2, PatchSettingsSchema, DEFAULT_PATCH_SETTINGS, {
1959
+ settings.installSection(ctx, PATCH_SETTINGS_NAMESPACE2, PatchSettingsSchema, DEFAULT_PATCH_SETTINGS, {
1711
1960
  setSource: (next) => {
1712
1961
  source = next;
1713
1962
  },
@@ -1717,6 +1966,9 @@ function installPatchSettings(ctx, activation, config = DEFAULT_PATCH_SETTINGS)
1717
1966
  });
1718
1967
  }
1719
1968
 
1969
+ // src/platform/dsh/host/api-router.ts
1970
+ import { Readable } from "node:stream";
1971
+
1720
1972
  // src/platform/dsh/host/trust.ts
1721
1973
  function header(req, name2) {
1722
1974
  const value = req.headers[name2];
@@ -1773,6 +2025,43 @@ function registerPatchApi(ctx, patches, confirmationSecret, isEnabled) {
1773
2025
  const host = ctx;
1774
2026
  const routes = collectRoutes(patches, { ctx, confirmationSecret });
1775
2027
  const logger = ctx.logger(PLUGIN_NAME);
2028
+ const connection = typeof ctx.get === "function" ? ctx.get("connection") : void 0;
2029
+ if (connection?.fetch?.register !== void 0) {
2030
+ for (const [route, registered] of routes) {
2031
+ connection.fetch.register({
2032
+ path: `${PLUGIN_API_PREFIX}/${route}`,
2033
+ methods: ["POST"],
2034
+ requestBody: "buffered",
2035
+ fetch: async (request) => {
2036
+ let status = 200;
2037
+ let headers = {};
2038
+ let body = "";
2039
+ const res = {
2040
+ writeHead(code, values) {
2041
+ status = code;
2042
+ headers = values;
2043
+ },
2044
+ end(value) {
2045
+ body = value;
2046
+ }
2047
+ };
2048
+ try {
2049
+ if (request.headers.get(PLUGIN_MUTATION_HEADER) !== "1") throw new DshMoreError("forbidden", "\u8BF7\u6C42\u6765\u6E90\u4E0D\u53D7\u4FE1\u4EFB\u3002", 403);
2050
+ if (!isEnabled(registered.patchId)) throw new DshMoreError("patch-disabled", "\u8FD9\u4E2A\u8865\u4E01\u5F53\u524D\u5DF2\u5173\u95ED\u3002", 409);
2051
+ const req = request.body === null ? Readable.from([]) : Readable.fromWeb(request.body);
2052
+ req.headers = Object.fromEntries(request.headers);
2053
+ requireJsonContentType(req);
2054
+ writeOk(res, await registered.handler(await readJson(req)));
2055
+ } catch (error) {
2056
+ if (!(error instanceof DshMoreError) || error.status >= 500) logger.error("patch API %s failed: %s", route, String(error));
2057
+ writeError(res, error);
2058
+ }
2059
+ return new Response(body, { status, headers });
2060
+ }
2061
+ });
2062
+ }
2063
+ return;
2064
+ }
1776
2065
  ctx.effect(() => ctx.webServer.register({
1777
2066
  kind: "prefix",
1778
2067
  path: PLUGIN_API_PREFIX,
@@ -1815,9 +2104,9 @@ function registerPatchApi(ctx, patches, confirmationSecret, isEnabled) {
1815
2104
  var name = PLUGIN_NAME;
1816
2105
  var inject = [
1817
2106
  "webServer",
1818
- "webRuntime",
1819
2107
  "agents",
1820
2108
  "sessions",
2109
+ "connection",
1821
2110
  "sessionPersistence",
1822
2111
  "sessionProjections",
1823
2112
  "workspaceRegistry",
@@ -1,18 +1,22 @@
1
1
  import z from '@deepseek-ai/schemastery';
2
- export declare const PatchSettingsSchema: z<Schemastery.ObjectS<{
3
- "message-edit": z<boolean, boolean>;
4
- "message-delete": z<boolean, boolean>;
5
- "session-delete": z<boolean, boolean>;
6
- "conversation-markdown-export": z<boolean, boolean>;
7
- "model-capabilities": z<boolean, boolean>;
8
- "session-auto-title": z<boolean, boolean>;
9
- "projectless-tasks": z<boolean, boolean>;
10
- }>, Schemastery.ObjectT<{
11
- "message-edit": z<boolean, boolean>;
12
- "message-delete": z<boolean, boolean>;
13
- "session-delete": z<boolean, boolean>;
14
- "conversation-markdown-export": z<boolean, boolean>;
15
- "model-capabilities": z<boolean, boolean>;
16
- "session-auto-title": z<boolean, boolean>;
17
- "projectless-tasks": z<boolean, boolean>;
18
- }>>;
2
+ export declare const PatchSettingsSchema: z<Schemastery.ObjectS<NoInfer<{
3
+ "message-edit": z<boolean, boolean, "defined">;
4
+ "message-delete": z<boolean, boolean, "defined">;
5
+ "session-delete": z<boolean, boolean, "defined">;
6
+ "conversation-markdown-export": z<boolean, boolean, "defined">;
7
+ "model-capabilities": z<boolean, boolean, "defined">;
8
+ "fast-mode": z<boolean, boolean, "defined">;
9
+ "session-auto-title": z<boolean, boolean, "defined">;
10
+ "projectless-tasks": z<boolean, boolean, "defined">;
11
+ "terminal-clipboard": z<boolean, boolean, "defined">;
12
+ }>>, Schemastery.ObjectT<NoInfer<{
13
+ "message-edit": z<boolean, boolean, "defined">;
14
+ "message-delete": z<boolean, boolean, "defined">;
15
+ "session-delete": z<boolean, boolean, "defined">;
16
+ "conversation-markdown-export": z<boolean, boolean, "defined">;
17
+ "model-capabilities": z<boolean, boolean, "defined">;
18
+ "fast-mode": z<boolean, boolean, "defined">;
19
+ "session-auto-title": z<boolean, boolean, "defined">;
20
+ "projectless-tasks": z<boolean, boolean, "defined">;
21
+ "terminal-clipboard": z<boolean, boolean, "defined">;
22
+ }>>, "plain">;
@@ -33,6 +33,13 @@ export declare const PATCH_CATALOG: readonly [{
33
33
  readonly defaultEnabled: true;
34
34
  readonly order: 500;
35
35
  readonly clientKind: "standalone";
36
+ }, {
37
+ readonly id: "fast-mode";
38
+ readonly name: "加速";
39
+ readonly description: "在输入框和 /fast 命令中开关加速。响应更快,但会更快消耗额度";
40
+ readonly defaultEnabled: true;
41
+ readonly order: 550;
42
+ readonly clientKind: "standalone";
36
43
  }, {
37
44
  readonly id: "session-auto-title";
38
45
  readonly name: "会话自动命名";
@@ -47,6 +54,13 @@ export declare const PATCH_CATALOG: readonly [{
47
54
  readonly defaultEnabled: true;
48
55
  readonly order: 700;
49
56
  readonly clientKind: "standalone";
57
+ }, {
58
+ readonly id: "terminal-clipboard";
59
+ readonly name: "终端复制粘贴";
60
+ readonly description: "右侧终端选中自动复制、右键粘贴,支持 Ctrl+Shift+C/V 和 Shift+Insert;无选区时保留 Ctrl+C 中断";
61
+ readonly defaultEnabled: true;
62
+ readonly order: 800;
63
+ readonly clientKind: "standalone";
50
64
  }];
51
65
  export type PatchId = typeof PATCH_CATALOG[number]['id'];
52
66
  export interface PatchSettings {
@@ -55,8 +69,10 @@ export interface PatchSettings {
55
69
  "session-delete": boolean;
56
70
  "conversation-markdown-export": boolean;
57
71
  "model-capabilities": boolean;
72
+ "fast-mode": boolean;
58
73
  "session-auto-title": boolean;
59
74
  "projectless-tasks": boolean;
75
+ "terminal-clipboard": boolean;
60
76
  }
61
77
  export declare const DEFAULT_PATCH_SETTINGS: PatchSettings;
62
78
  export declare function decodePatchSettings(value: unknown): PatchSettings | undefined;
@@ -1,5 +1,5 @@
1
- import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
2
- import type { SettingsScopeSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client';
1
+ import type { SettingsScope } from '../../platform/dsh/client/settings.js';
2
+ import type { SettingsScopeSnapshot } from '../../platform/dsh/client/settings.js';
3
3
  import { type PatchId, type PatchSettings } from '../../generated/patch-catalog.js';
4
4
  export interface PatchActivationSource {
5
5
  getSnapshot(): PatchSettings;
@@ -6,6 +6,7 @@ export declare class HostPatchActivation {
6
6
  private readonly ctx;
7
7
  private readonly byId;
8
8
  private readonly disposers;
9
+ private readonly observers;
9
10
  private settings;
10
11
  constructor(ctx: Context, patches: readonly HostPatch[]);
11
12
  apply(next: PatchSettings): void;