@xmanrui/dsh-im 5.9.1 → 5.11.0

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 (135) hide show
  1. package/PROACTIVE_DELIVERY.en.md +33 -9
  2. package/PROACTIVE_DELIVERY.md +33 -9
  3. package/README.en.md +42 -7
  4. package/README.md +46 -8
  5. package/bin/dsh-im.mjs +65 -0
  6. package/docs/client-integration.md +4 -0
  7. package/lib/client.js +1735 -203
  8. package/lib/index.js +367 -341
  9. package/package.json +7 -6
  10. package/plugin-src/client/access-policy-settings.js +210 -12
  11. package/plugin-src/client/bot-general-settings.js +44 -3
  12. package/plugin-src/client/delivery-settings.js +2 -0
  13. package/plugin-src/client/delivery-sync-settings.js +269 -0
  14. package/plugin-src/client/global-settings.js +45 -7
  15. package/plugin-src/client/i18n-ru.js +112 -0
  16. package/plugin-src/client/i18n.js +110 -0
  17. package/plugin-src/client/im-channels.js +419 -0
  18. package/plugin-src/client/index.js +50 -2
  19. package/plugin-src/client/model-setting.js +6 -3
  20. package/plugin-src/client/styles.js +23 -7
  21. package/plugin-src/client/update-panel.js +2 -1
  22. package/plugin-src/host/channel-list-rpc.mjs +280 -0
  23. package/plugin-src/host/channels/dingtalk/production.mjs +28 -10
  24. package/plugin-src/host/channels/dingtalk/rpc.mjs +10 -1
  25. package/plugin-src/host/channels/feishu/production.mjs +50 -37
  26. package/plugin-src/host/channels/feishu/rpc.mjs +10 -1
  27. package/plugin-src/host/channels/matrix/production.mjs +28 -10
  28. package/plugin-src/host/channels/matrix/rpc.mjs +10 -0
  29. package/plugin-src/host/channels/qq/production.mjs +30 -11
  30. package/plugin-src/host/channels/qq/rpc.mjs +10 -1
  31. package/plugin-src/host/channels/shared/access-policy-production.mjs +9 -0
  32. package/plugin-src/host/channels/shared/binding-events.mjs +109 -0
  33. package/plugin-src/host/channels/shared/production.mjs +14 -1
  34. package/plugin-src/host/channels/shared/reply-content-rpc.mjs +17 -0
  35. package/plugin-src/host/channels/shared/rpc.mjs +9 -0
  36. package/plugin-src/host/channels/shared/workspace-rpc.mjs +1 -0
  37. package/plugin-src/host/channels/slack/production.mjs +28 -10
  38. package/plugin-src/host/channels/slack/rpc.mjs +10 -0
  39. package/plugin-src/host/channels/telegram/production.mjs +5 -0
  40. package/plugin-src/host/channels/wecom/production.mjs +28 -10
  41. package/plugin-src/host/channels/wecom/rpc.mjs +10 -1
  42. package/plugin-src/host/channels/wecom-app/production.mjs +28 -10
  43. package/plugin-src/host/channels/wecom-app/rpc.mjs +9 -0
  44. package/plugin-src/host/channels/weixin/production.mjs +28 -10
  45. package/plugin-src/host/channels/weixin/rpc.mjs +10 -1
  46. package/plugin-src/host/channels/whatsapp/production.mjs +28 -10
  47. package/plugin-src/host/channels/whatsapp/rpc.mjs +10 -1
  48. package/plugin-src/host/delivery-adapter.mjs +35 -20
  49. package/plugin-src/host/delivery-service.mjs +99 -1
  50. package/plugin-src/host/delivery-suggestions.mjs +31 -1
  51. package/plugin-src/host/delivery-sync-rpc.mjs +100 -0
  52. package/plugin-src/host/harness-connection.mjs +2 -1
  53. package/plugin-src/host/harness-peer.mjs +3 -1
  54. package/plugin-src/host/host-language-rpc.mjs +16 -2
  55. package/plugin-src/host/host-language.mjs +29 -0
  56. package/plugin-src/host/index.mjs +30 -1
  57. package/plugin-src/host/modern-harness-api.mjs +5 -1
  58. package/plugin-src/host/root-scope.mjs +32 -0
  59. package/plugin-src/host/session-sync-coordinator.mjs +290 -122
  60. package/plugin-src/host/session-sync-targets.mjs +71 -0
  61. package/plugin-src/management-rpc.mjs +18 -2
  62. package/scripts/verify-package.mjs +48 -10
  63. package/src/channels/dingtalk/dingtalk-bridge.mjs +50 -6
  64. package/src/channels/dingtalk/state-store.mjs +56 -0
  65. package/src/channels/discord/discord-api.mjs +2 -1
  66. package/src/channels/feishu/bridge.mjs +154 -58
  67. package/src/channels/feishu/feishu-cards.mjs +10 -4
  68. package/src/channels/feishu/feishu-runtime.mjs +11 -3
  69. package/src/channels/feishu/message-utils.mjs +106 -30
  70. package/src/channels/feishu/slash-command-panel.mjs +26 -0
  71. package/src/channels/feishu/state-store.mjs +14 -0
  72. package/src/channels/matrix/matrix-api.mjs +2 -1
  73. package/src/channels/qq/qq-bridge.mjs +114 -14
  74. package/src/channels/qq/state-store.mjs +55 -1
  75. package/src/channels/shared/access-policy.mjs +60 -7
  76. package/src/channels/shared/action-card.mjs +83 -7
  77. package/src/channels/shared/bot-workspace-store.mjs +255 -11
  78. package/src/channels/shared/busy-message-dispatcher.mjs +2 -2
  79. package/src/channels/shared/channel-capabilities.mjs +44 -0
  80. package/src/channels/shared/command-catalog.mjs +68 -3
  81. package/src/channels/shared/command-permission.mjs +6 -2
  82. package/src/channels/shared/conversation-state-store.mjs +16 -0
  83. package/src/channels/shared/deferred-delivery-coordinator.mjs +6 -1
  84. package/src/channels/shared/deferred-delivery.mjs +4 -0
  85. package/src/channels/shared/delivery-sync-settings-store.mjs +86 -0
  86. package/src/channels/shared/delivery-sync-settings.mjs +122 -0
  87. package/src/channels/shared/diagnostic-details.mjs +6 -1
  88. package/src/channels/shared/failure-log-file.mjs +79 -0
  89. package/src/channels/shared/harness-client.mjs +259 -96
  90. package/src/channels/shared/i18n-en/diagnostics.mjs +1 -0
  91. package/src/channels/shared/i18n-en/feishu.mjs +2 -2
  92. package/src/channels/shared/i18n-en/shared-a.mjs +13 -2
  93. package/src/channels/shared/i18n-en/shared-b.mjs +73 -4
  94. package/src/channels/shared/i18n-en/shared-d.mjs +144 -0
  95. package/src/channels/shared/i18n-en/weixin.mjs +4 -0
  96. package/src/channels/shared/i18n-en.mjs +2 -0
  97. package/src/channels/shared/i18n-ru/diagnostics.mjs +1 -0
  98. package/src/channels/shared/i18n-ru/feishu.mjs +2 -2
  99. package/src/channels/shared/i18n-ru/shared-a.mjs +13 -2
  100. package/src/channels/shared/i18n-ru/shared-b.mjs +72 -4
  101. package/src/channels/shared/i18n-ru/shared-d.mjs +144 -0
  102. package/src/channels/shared/i18n-ru/weixin.mjs +4 -0
  103. package/src/channels/shared/i18n-ru.mjs +2 -0
  104. package/src/channels/shared/inbound-access.mjs +10 -0
  105. package/src/channels/shared/interface-language-store.mjs +49 -10
  106. package/src/channels/shared/interface-language.mjs +19 -1
  107. package/src/channels/shared/markdown-chunks.mjs +5 -0
  108. package/src/channels/shared/message-failure.mjs +22 -1
  109. package/src/channels/shared/model-setting.mjs +6 -3
  110. package/src/channels/shared/new-command.mjs +158 -4
  111. package/src/channels/shared/plan-goal-command.mjs +132 -0
  112. package/src/channels/shared/qrcode.mjs +5 -0
  113. package/src/channels/shared/reply-content.mjs +102 -0
  114. package/src/channels/shared/reset-command.mjs +46 -0
  115. package/src/channels/shared/semantic/artifact.mjs +133 -29
  116. package/src/channels/shared/semantic/reply-reference.mjs +18 -3
  117. package/src/channels/shared/session-nav-command.mjs +999 -0
  118. package/src/channels/shared/session-ring-support.mjs +184 -0
  119. package/src/channels/shared/session-ring.mjs +202 -0
  120. package/src/channels/shared/session-title.mjs +11 -0
  121. package/src/channels/shared/status-command.mjs +2 -1
  122. package/src/channels/shared/text-harness-bridge.mjs +166 -7
  123. package/src/channels/shared/workspace-command.mjs +567 -31
  124. package/src/channels/shared/workspace-session.mjs +52 -4
  125. package/src/channels/slack/slack-api.mjs +2 -1
  126. package/src/channels/telegram/config-store.mjs +10 -2
  127. package/src/channels/telegram/telegram-api.mjs +19 -1
  128. package/src/channels/telegram/telegram-rich-message.mjs +17 -5
  129. package/src/channels/telegram/telegram-runtime.mjs +14 -1
  130. package/src/channels/wecom/state-store.mjs +13 -1
  131. package/src/channels/wecom/wecom-bridge.mjs +183 -26
  132. package/src/channels/wecom-app/state-store.mjs +13 -1
  133. package/src/channels/wecom-app/wecom-app-bridge.mjs +44 -4
  134. package/src/channels/weixin/state-store.mjs +13 -1
  135. package/src/channels/weixin/weixin-bridge.mjs +71 -4
@@ -25,6 +25,7 @@ import { t } from './i18n.mjs';
25
25
  import { watchHarnessMux } from './harness-mux.mjs';
26
26
  import { extractConnectionEvidence, messageDiagnosticError } from './connection-error.mjs';
27
27
  import { PromptFailureTracker } from './prompt-failure-tracker.mjs';
28
+ import { allowsReplyContent, normalizeReplyContent } from './reply-content.mjs';
28
29
  import { isSessionLogCorrupt, isSessionNotFound } from './session-error.mjs';
29
30
 
30
31
  // Every channel plugin runs in the same Host process. Sharing ownership by
@@ -169,6 +170,23 @@ export function consumeDshImInputOrigin(scope, rpcId) {
169
170
  return origins.delete(rpcId);
170
171
  }
171
172
 
173
+ /**
174
+ * Whether a dsh-im prompt id is registered, without claiming it.
175
+ *
176
+ * An observer such as the Session sync coordinator must be able to ask "did a
177
+ * messenger start this turn?" without taking the id away from the channel that
178
+ * still owns it. The entry lives until its TTL or the size cap evicts it, so a
179
+ * repeated question keeps answering the same way, while the one-shot
180
+ * `consumeDshImInputOrigin` stays the only way to claim it.
181
+ */
182
+ export function isDshImInputOrigin(scope, rpcId) {
183
+ if (!scope || !['object', 'function', 'string'].includes(typeof scope)
184
+ || typeof rpcId !== 'string' || !rpcId) return false;
185
+ const origins = interactionRegistry(scope).imInputOrigins;
186
+ pruneImInputOrigins(origins);
187
+ return origins.has(rpcId);
188
+ }
189
+
172
190
  // A Host RPC may not accept cancellation itself. Bound the caller's wait
173
191
  // without retrying an operation that the Host may already have accepted.
174
192
  function callWithSignal(call, signal) {
@@ -471,6 +489,48 @@ export function accumulateFinalAssistantText(accumulator, event) {
471
489
  }
472
490
  }
473
491
 
492
+ /**
493
+ * The switch that owns a progress update. Text updates are the assistant's own
494
+ * prose, tool traffic is the step itself, and reasoning is the trace; anything
495
+ * else (turn boundaries) is always delivered because the consumer needs it to
496
+ * end the turn correctly.
497
+ */
498
+ function replyContentKindOf(update) {
499
+ switch (update?.type) {
500
+ case 'tool':
501
+ case 'tool-result':
502
+ case 'status':
503
+ return 'tools';
504
+ case 'reasoning':
505
+ return 'thinking';
506
+ case 'assistant-message':
507
+ case 'text':
508
+ return 'narration';
509
+ default:
510
+ return null;
511
+ }
512
+ }
513
+
514
+ function allowsUpdate(replyContent, update) {
515
+ const kind = replyContentKindOf(update);
516
+ return kind === null || allowsReplyContent(replyContent, kind);
517
+ }
518
+
519
+ /**
520
+ * The updates a channel may forward for this batch.
521
+ *
522
+ * The bot's switches are applied before the `latest` reduction: a hidden
523
+ * update must not take the single slot and swallow an allowed update that
524
+ * arrived in the same poll.
525
+ */
526
+ export function selectProgressUpdates(updates, { mode = 'latest', replyContent } = {}) {
527
+ const allowed = updates.filter((update) => allowsUpdate(replyContent, update));
528
+ if (mode === 'all' || mode === 'live') return allowed;
529
+ return allowed
530
+ .filter((update) => update.type !== 'assistant-message' && update.type !== 'reasoning')
531
+ .slice(-1);
532
+ }
533
+
474
534
  function nonEmptyText(value) {
475
535
  return typeof value === 'string' && value.trim() ? value.trim() : null;
476
536
  }
@@ -1184,6 +1244,33 @@ export class HarnessClient {
1184
1244
  return workspaceEntries(await this.rpc('workspace.list', {}, 30_000, options));
1185
1245
  }
1186
1246
 
1247
+ /**
1248
+ * Hide one known Session from the Workspace grouping surfaces. Archiving is a
1249
+ * Harness capability: this only carries the request, so an older Host that
1250
+ * does not expose it fails loudly instead of silently doing nothing.
1251
+ *
1252
+ * @param {string} sessionId - Session to archive.
1253
+ * @param {object} [options] - `stopActivity` lets the Host stop running work.
1254
+ */
1255
+ async archiveWorkspaceSession(sessionId, options = {}) {
1256
+ const { stopActivity = false, ...rpcOptions } = options;
1257
+ await this.ensureRunning(rpcOptions);
1258
+ const value = await this.rpc('workspace.archiveSession', {
1259
+ sessionId,
1260
+ ...(stopActivity === true ? { stopActivity: true } : {}),
1261
+ }, 30_000, rpcOptions);
1262
+ if (value === null || typeof value !== 'object') {
1263
+ throw new Error('Harness returned an invalid response for workspace.archiveSession');
1264
+ }
1265
+ const archivedSessionIds = value.archivedSessionIds;
1266
+ if (archivedSessionIds !== undefined
1267
+ && (!Array.isArray(archivedSessionIds)
1268
+ || archivedSessionIds.some((id) => typeof id !== 'string' || !id))) {
1269
+ throw new Error('Harness returned invalid archived ids for workspace.archiveSession');
1270
+ }
1271
+ return { archivedSessionIds: archivedSessionIds ?? null };
1272
+ }
1273
+
1187
1274
  async listWorkspaceSessions(workspacePath, options = {}) {
1188
1275
  await this.ensureRunning(options);
1189
1276
  const workspaceList = await this.rpc('workspace.list', {}, 30_000, options);
@@ -1388,6 +1475,31 @@ export class HarnessClient {
1388
1475
  return this.rpc('session.rename', { sessionId, title }, 30_000, options);
1389
1476
  }
1390
1477
 
1478
+ /**
1479
+ * Branch a Session at the latest completed turn (or atSeq when given). The
1480
+ * Host answers with the child session id; a Session with no completed turn is
1481
+ * reported as fork-unavailable. Throws harness-api-not-found when the Host
1482
+ * has no session.fork primitive.
1483
+ */
1484
+ async forkSession(sessionId, options = {}) {
1485
+ if (typeof sessionId !== 'string' || !sessionId) throw new TypeError('sessionId is required');
1486
+ const { atSeq, timeoutMs = 30_000, ...rpcOptions } = options;
1487
+ return this.rpc('session.fork', {
1488
+ sessionId,
1489
+ ...(atSeq === undefined ? {} : { atSeq }),
1490
+ }, timeoutMs, rpcOptions);
1491
+ }
1492
+
1493
+ /**
1494
+ * Whether the connected Host can fork sessions. With the host-api transport
1495
+ * this is the facade's sessions.fork member; the http transport reaches the
1496
+ * Host endpoint directly, so a missing member here is not observable.
1497
+ */
1498
+ supportsSessionFork() {
1499
+ if (this.#apiProxy) return typeof this.#apiProxy?.sessions?.fork === 'function';
1500
+ return true;
1501
+ }
1502
+
1391
1503
  async executeCommand(sessionId, line, options = {}) {
1392
1504
  if (typeof sessionId !== 'string' || !sessionId) throw new TypeError('sessionId is required');
1393
1505
  if (typeof line !== 'string' || !line) throw new TypeError('command line is required');
@@ -1497,6 +1609,10 @@ export class HarnessClient {
1497
1609
  return false;
1498
1610
  }
1499
1611
 
1612
+ async isSessionArchived(sessionId, options = {}) {
1613
+ return this.#isSessionArchived(sessionId, options);
1614
+ }
1615
+
1500
1616
  async sessionExists(sessionId, options = {}) {
1501
1617
  // Archived Sessions still exist. Returning false here would silently bind
1502
1618
  // the conversation to a new Session; reading their active log can also fail.
@@ -1878,7 +1994,45 @@ export class HarnessClient {
1878
1994
  }
1879
1995
  }
1880
1996
 
1881
- async #ask(sessionId, prompt, options, diagnostic) {
1997
+ /** Follow a prompt DS Bot carried to another Session, without submitting it again. */
1998
+ async waitForTransferredReply(sessionId, { promptRpcId, ...options } = {}) {
1999
+ if (typeof promptRpcId !== 'string' || !promptRpcId) {
2000
+ throw new TypeError('Transferred prompt identity is required');
2001
+ }
2002
+ const diagnostic = { stage: 'reply.wait', submissionState: 'accepted', sessionId, promptRpcId };
2003
+ try {
2004
+ return await this.#ask(sessionId, null, options, diagnostic, promptRpcId);
2005
+ } catch (error) {
2006
+ if (options.signal?.aborted) throw options.signal.reason ?? error;
2007
+ // Preflight failures must retain the accepted input's identity too. A
2008
+ // fresh part may itself have rolled over before its watcher was opened.
2009
+ error.promptAccepted = true;
2010
+ error.details = { sessionId, promptRpcId, baselineSeq: -1, ...error.details };
2011
+ throw messageDiagnosticError(error, diagnostic);
2012
+ }
2013
+ }
2014
+
2015
+ async #replyHistory(sessionId, afterSeq, transferred, signal) {
2016
+ const events = [];
2017
+ let beforeSeq;
2018
+ for (let page = 0; page < 20; page += 1) {
2019
+ signal?.throwIfAborted();
2020
+ const history = await this.#sessionRpc('session.history', {
2021
+ sessionId, maxMessages: 50,
2022
+ ...(beforeSeq === undefined ? {} : { beforeSeq }),
2023
+ }, 30_000, { signal });
2024
+ signal?.throwIfAborted();
2025
+ events.push(...(history.events ?? []));
2026
+ const oldest = Math.min(...(history.events ?? []).map((entry) => (entry.event ?? entry).seq));
2027
+ if (!transferred || !history.hasMore || oldest <= afterSeq + 1) return { events };
2028
+ if (!Number.isSafeInteger(oldest) || oldest === beforeSeq) break;
2029
+ beforeSeq = oldest;
2030
+ }
2031
+ // Do not attribute or complete a turn from an incomplete replay window.
2032
+ return { events: [] };
2033
+ }
2034
+
2035
+ async #ask(sessionId, prompt, options, diagnostic, transferredPromptRpcId = null) {
1882
2036
  const timeoutMs = options.timeoutMs ?? 600_000;
1883
2037
  const signal = options.signal;
1884
2038
  const onUpdate = typeof options.onUpdate === 'function' ? options.onUpdate : null;
@@ -1888,6 +2042,9 @@ export class HarnessClient {
1888
2042
  // Reasoning updates only exist for consumers that opt in (thinking-trace
1889
2043
  // mode); default ask() consumers keep the pre-thinking-traces stream.
1890
2044
  const reasoning = options.reasoning === true;
2045
+ // Per-bot content switches: a bot may hide the assistant's process prose,
2046
+ // its tool traffic or the reasoning trace while still receiving the answer.
2047
+ const replyContent = normalizeReplyContent(options.replyContent);
1891
2048
  const onArtifact = typeof options.onArtifact === 'function' ? options.onArtifact : null;
1892
2049
  const onInteraction = typeof options.onInteraction === 'function'
1893
2050
  ? options.onInteraction
@@ -1896,22 +2053,27 @@ export class HarnessClient {
1896
2053
  ? options.onInteractionResolved
1897
2054
  : undefined;
1898
2055
  const control = normalizeControl(options.control);
1899
- const inboundFiles = Array.isArray(options.files) ? options.files.filter(Boolean) : [];
1900
- const inboundImages = Array.isArray(options.images) ? options.images.filter(Boolean) : [];
2056
+ const inboundFiles = !transferredPromptRpcId && Array.isArray(options.files) ? options.files.filter(Boolean) : [];
2057
+ const inboundImages = !transferredPromptRpcId && Array.isArray(options.images) ? options.images.filter(Boolean) : [];
1901
2058
  await this.ensureRunning({ signal });
1902
2059
  if (await this.#isSessionArchived(sessionId, { signal })) throw sessionArchivedError(sessionId);
1903
- const before = await this.#sessionRpc(
2060
+ const before = transferredPromptRpcId ? { events: [] } : await this.#sessionRpc(
1904
2061
  'session.history',
1905
2062
  { sessionId, maxMessages: 1 },
1906
2063
  30_000,
1907
2064
  { signal },
1908
2065
  );
1909
2066
  const baselineSeq = Math.max(-1, ...(before.events ?? []).map(({ event }) => event.seq ?? -1));
1910
- const promptRpcId = `${this.#rpcIdPrefix}-${randomUUID()}`;
2067
+ const promptRpcId = transferredPromptRpcId ?? `${this.#rpcIdPrefix}-${randomUUID()}`;
1911
2068
  diagnostic.promptRpcId = promptRpcId;
1912
2069
  const releasePromptInputOrigin = registerImInputOrigin(this.#interactionRegistry, promptRpcId);
1913
2070
  const tracker = new HarnessReplyTracker({
1914
- promptRpcId, afterSeq: baselineSeq, reasoning, finalAnswerOnly: options.finalAnswerOnly,
2071
+ promptRpcId,
2072
+ afterSeq: baselineSeq,
2073
+ reasoning,
2074
+ // Hiding the assistant's process prose also means the delivered answer
2075
+ // must not carry it: keep only the text after the last tool call.
2076
+ finalAnswerOnly: options.finalAnswerOnly === true || replyContent.narration === false,
1915
2077
  });
1916
2078
  let checkedBlockedSeq = baselineSeq;
1917
2079
  let lastProgressAt = Date.now();
@@ -1926,11 +2088,10 @@ export class HarnessClient {
1926
2088
  lastPollSeq = tracker.lastSeq;
1927
2089
  if (seqAdvanced) lastProgressAt = Date.now();
1928
2090
  if (!onUpdate) return progressTail;
1929
- const visibleUpdates = progressMode === 'all' || progressMode === 'live'
1930
- ? updates
1931
- : updates
1932
- .filter((update) => update.type !== 'assistant-message' && update.type !== 'reasoning')
1933
- .slice(-1);
2091
+ const visibleUpdates = selectProgressUpdates(updates, {
2092
+ mode: progressMode,
2093
+ replyContent,
2094
+ });
1934
2095
  for (const update of visibleUpdates) {
1935
2096
  progressTail = progressTail
1936
2097
  .then(() => onUpdate(update))
@@ -1983,15 +2144,19 @@ export class HarnessClient {
1983
2144
  let artifactsDelivered = false;
1984
2145
  let deliveredArtifactCount = 0;
1985
2146
  let artifactHandoffError = null;
1986
- const stagedBatches = [];
1987
- let promptAccepted = false;
2147
+ const stagedBatches = options.handoffResources?.stagedBatches ?? [];
2148
+ let promptAccepted = Boolean(transferredPromptRpcId);
1988
2149
  let turnFinished = false;
2150
+ let handedOff = false;
1989
2151
 
1990
2152
  const deliverArtifacts = async () => {
1991
2153
  if (!onArtifact || artifactsDelivered || tracker.turn === null) {
1992
2154
  return deliveredArtifactCount;
1993
2155
  }
1994
2156
  artifactsDelivered = true;
2157
+ // Files the host `present` tool recorded live on the Session, not in the
2158
+ // registry: adopt them before claiming, or they are dropped silently.
2159
+ await outboundArtifactRegistry.adoptionsSettled(sessionId, tracker.turn);
1995
2160
  const artifacts = outboundArtifactRegistry.take(sessionId, tracker.turn, { signal });
1996
2161
  for (const artifact of artifacts) {
1997
2162
  try {
@@ -2076,87 +2241,86 @@ export class HarnessClient {
2076
2241
  }),
2077
2242
  ]);
2078
2243
  }
2079
- diagnostic.stage = 'prompt.prepare';
2080
- const content = typeof prompt === 'string'
2081
- ? [{ type: 'text', text: prompt }]
2082
- : prompt;
2083
- if (!Array.isArray(content) || content.length === 0) {
2084
- throw new TypeError('Harness prompt content is required');
2085
- }
2086
- // Publish the guidance the channel's own captured settings produced, so
2087
- // the Host materializes it once per Session as prompt context instead of
2088
- // per user message. It is passed in and never parsed back out of
2089
- // `content`: the prompt also carries whatever the user typed, and a
2090
- // message that merely looks like a guidance block is not configuration.
2244
+ // Restore the channel's trusted guidance in a fresh part too; never
2245
+ // derive it from the forwarded message's content.
2091
2246
  imSourceGuidance.publish(sessionId, options.sourceGuidance);
2092
- const timeZoneFields = clientTimeZoneFields();
2093
- const sendPrompt = (promptContent) => {
2094
- diagnostic.stage = 'prompt.submit';
2095
- diagnostic.submissionState = 'unknown';
2096
- return this.#sessionRpc('session.prompt', {
2097
- sessionId,
2098
- mode: 'queue',
2099
- content: promptContent,
2100
- ...timeZoneFields,
2101
- }, 30_000, { rpcId: promptRpcId, signal });
2102
- };
2103
- // 30 秒提交窗口到期只说明 Host 忙到没来得及应答,prompt 可能早已入队。
2104
- // 先按 promptRpcId 回查持久账本,确认入库就继续等回复;确认不到才把
2105
- // 原始超时错误向上抛,由文案层标注「提交请求超时、是否送达未知」。
2106
- const submitPrompt = async (promptContent) => {
2107
- try {
2108
- await sendPrompt(promptContent);
2109
- } catch (error) {
2110
- if (!isPromptSubmitTimeout(error) || signal?.aborted) throw error;
2111
- let confirmed = false;
2112
- try {
2113
- confirmed = await this.#confirmPromptSubmit(sessionId, promptRpcId, { signal });
2114
- } catch (confirmError) {
2115
- // 确认途中被取消时恢复调用方的取消语义(与图片暂存路径一致)。
2116
- if (signal?.aborted) throw signal.reason ?? confirmError;
2117
- throw error;
2118
- }
2119
- if (!confirmed) throw error;
2120
- diagnostic.submissionState = 'accepted';
2247
+ if (!transferredPromptRpcId) {
2248
+ diagnostic.stage = 'prompt.prepare';
2249
+ const content = typeof prompt === 'string'
2250
+ ? [{ type: 'text', text: prompt }]
2251
+ : prompt;
2252
+ if (!Array.isArray(content) || content.length === 0) {
2253
+ throw new TypeError('Harness prompt content is required');
2121
2254
  }
2122
- };
2123
- try {
2124
- await submitPrompt(content);
2125
- } catch (error) {
2126
- // The Host refuses image blocks for a non-vision model before any
2127
- // durable user message exists. Re-deliver the same bytes the way
2128
- // ordinary uploads (zip, documents) already travel — staged into the
2129
- // Session workspace and named in a text manifest — then retry once
2130
- // with a text-only prompt. The retry reuses promptRpcId so reply
2131
- // tracking, control and interaction ownership stay bound to this ask.
2132
- const originalsStaged = inboundImages.length > 0 && isImageAdmissionRejection(error)
2133
- && content.some((part) => part.type === 'image');
2134
- const imageSources = !originalsStaged && isModelImageRejection(error)
2135
- ? imageFileSourcesFromContent(content) : [];
2136
- if (!originalsStaged && imageSources.length === 0) throw error;
2137
- if (!originalsStaged) {
2138
- let stagedImages;
2255
+ const timeZoneFields = clientTimeZoneFields();
2256
+ const sendPrompt = (promptContent) => {
2257
+ diagnostic.stage = 'prompt.submit';
2258
+ diagnostic.submissionState = 'unknown';
2259
+ return this.#sessionRpc('session.prompt', {
2260
+ sessionId,
2261
+ mode: 'queue',
2262
+ content: promptContent,
2263
+ ...timeZoneFields,
2264
+ }, 30_000, { rpcId: promptRpcId, signal });
2265
+ };
2266
+ // 30 秒提交窗口到期只说明 Host 忙到没来得及应答,prompt 可能早已入队。
2267
+ // 先按 promptRpcId 回查持久账本,确认入库就继续等回复;确认不到才把
2268
+ // 原始超时错误向上抛,由文案层标注「提交请求超时、是否送达未知」。
2269
+ const submitPrompt = async (promptContent) => {
2139
2270
  try {
2140
- stagedImages = await this.#stageWorkspaceFiles(sessionId, imageSources, signal);
2141
- } catch (stagingError) {
2142
- if (signal?.aborted) throw signal.reason ?? stagingError;
2143
- console.warn(
2144
- '[dsh-im] unable to restage rejected images as workspace files:',
2145
- this.#logPrefix,
2146
- stagingError?.message ?? String(stagingError),
2147
- );
2148
- throw error;
2271
+ await sendPrompt(promptContent);
2272
+ } catch (error) {
2273
+ if (!isPromptSubmitTimeout(error) || signal?.aborted) throw error;
2274
+ let confirmed = false;
2275
+ try {
2276
+ confirmed = await this.#confirmPromptSubmit(sessionId, promptRpcId, { signal });
2277
+ } catch (confirmError) {
2278
+ // 确认途中被取消时恢复调用方的取消语义(与图片暂存路径一致)。
2279
+ if (signal?.aborted) throw signal.reason ?? confirmError;
2280
+ throw error;
2281
+ }
2282
+ if (!confirmed) throw error;
2283
+ diagnostic.submissionState = 'accepted';
2284
+ }
2285
+ };
2286
+ try {
2287
+ await submitPrompt(content);
2288
+ } catch (error) {
2289
+ // The Host refuses image blocks for a non-vision model before any
2290
+ // durable user message exists. Re-deliver the same bytes the way
2291
+ // ordinary uploads (zip, documents) already travel — staged into the
2292
+ // Session workspace and named in a text manifest — then retry once
2293
+ // with a text-only prompt. The retry reuses promptRpcId so reply
2294
+ // tracking, control and interaction ownership stay bound to this ask.
2295
+ const originalsStaged = inboundImages.length > 0 && isImageAdmissionRejection(error)
2296
+ && content.some((part) => part.type === 'image');
2297
+ const imageSources = !originalsStaged && isModelImageRejection(error)
2298
+ ? imageFileSourcesFromContent(content) : [];
2299
+ if (!originalsStaged && imageSources.length === 0) throw error;
2300
+ if (!originalsStaged) {
2301
+ let stagedImages;
2302
+ try {
2303
+ stagedImages = await this.#stageWorkspaceFiles(sessionId, imageSources, signal);
2304
+ } catch (stagingError) {
2305
+ if (signal?.aborted) throw signal.reason ?? stagingError;
2306
+ console.warn(
2307
+ '[dsh-im] unable to restage rejected images as workspace files:',
2308
+ this.#logPrefix,
2309
+ stagingError?.message ?? String(stagingError),
2310
+ );
2311
+ throw error;
2312
+ }
2313
+ stagedBatches.push(stagedImages);
2149
2314
  }
2150
- stagedBatches.push(stagedImages);
2315
+ const baseContent = typeof basePrompt === 'string'
2316
+ ? [{ type: 'text', text: basePrompt }]
2317
+ : basePrompt;
2318
+ const fallbackPrompt = appendInboundFilesToPrompt([
2319
+ ...contentWithoutImages(baseContent),
2320
+ { type: 'text', text: t(isModelImageRejection(error) ? IMAGE_FILE_FALLBACK_PROMPT : IMAGE_HOST_LIMIT_FALLBACK_PROMPT) },
2321
+ ], { files: stagedBatches.flatMap((batch) => batch?.files ?? []) });
2322
+ await submitPrompt(fallbackPrompt);
2151
2323
  }
2152
- const baseContent = typeof basePrompt === 'string'
2153
- ? [{ type: 'text', text: basePrompt }]
2154
- : basePrompt;
2155
- const fallbackPrompt = appendInboundFilesToPrompt([
2156
- ...contentWithoutImages(baseContent),
2157
- { type: 'text', text: t(isModelImageRejection(error) ? IMAGE_FILE_FALLBACK_PROMPT : IMAGE_HOST_LIMIT_FALLBACK_PROMPT) },
2158
- ], { files: stagedBatches.flatMap((batch) => batch?.files ?? []) });
2159
- await submitPrompt(fallbackPrompt);
2160
2324
  }
2161
2325
  promptAccepted = true;
2162
2326
  diagnostic.submissionState = 'accepted';
@@ -2170,12 +2334,9 @@ export class HarnessClient {
2170
2334
  // active until turn/end and can therefore outlive a stalled turn.
2171
2335
  while (true) {
2172
2336
  await sleep(300, signal);
2173
- const history = await this.#sessionRpc(
2174
- 'session.history',
2175
- { sessionId, maxMessages: 50 },
2176
- 30_000,
2177
- { signal },
2178
- );
2337
+ options.assertCurrent?.();
2338
+ const history = await this.#replyHistory(sessionId, tracker.lastSeq, Boolean(transferredPromptRpcId), signal);
2339
+ options.assertCurrent?.();
2179
2340
  const wasActive = ownership?.active === true;
2180
2341
  if (ownership) {
2181
2342
  this.#consumeInteractionOwnerships(sessionId, history.events ?? []);
@@ -2252,6 +2413,8 @@ export class HarnessClient {
2252
2413
  throw timeoutError;
2253
2414
  }
2254
2415
  } catch (error) {
2416
+ handedOff = Boolean(options.handoffResources)
2417
+ && ['turn-blocked', 'session-archived'].includes(error.code);
2255
2418
  if (error.code === 'session-archived') {
2256
2419
  error.promptAccepted = promptAccepted;
2257
2420
  error.details = { ...error.details, promptRpcId, baselineSeq, turn: tracker.turn, lastSeq: tracker.lastSeq };
@@ -2272,7 +2435,7 @@ export class HarnessClient {
2272
2435
  }
2273
2436
  } finally {
2274
2437
  releasePromptInputOrigin();
2275
- if (!promptAccepted || turnFinished) {
2438
+ if (!promptAccepted || (turnFinished && !handedOff)) {
2276
2439
  for (const staged of stagedBatches) {
2277
2440
  try {
2278
2441
  await staged?.cleanup?.();
@@ -1,4 +1,5 @@
1
1
  export default Object.freeze({
2
+ '无法读取所选模型的列表,模型设置未保存,请重试。': 'Could not load the selected model’s catalog. The model setting was not saved. Try again.',
2
3
  '异常类型': 'Exception types',
3
4
  '二维码编码器': 'QR encoder',
4
5
  '二维码图片格式': 'QR image format',
@@ -267,8 +267,8 @@ export default {
267
267
  '/steer 指令 给 Agent 补充指令': '/steer INSTRUCTION Steer the Agent',
268
268
  '**📋 卡片功能**\n\n1. 会话下拉 — 切换当前绑定会话\n2. 工作区下拉 — 切换工作区\n3. 🤖 预设下拉 — 切换 Agent 预设\n4. 🧠 模型下拉 — 切换模型\n5. 🆕 新会话 — 开启全新会话\n6. 📋 会话/关注 — 查看/绑定会话,管理关注\n7. ⏹ 停止 — 停止当前任务\n8. 📐 压缩 — 压缩当前会话上下文\n9. 🧹 清空上下文 — 清空上下文并保留绑定和历史记录\n10. 补充指令 — 给 Agent 发送指令\n11. 🗄 归档切换 — 显示/隐藏归档会话\n12. 📊 状态 — 查看系统连接状态\n13. 📖 帮助 — 查看本帮助':
269
269
  '**📋 Card features**\n\n1. Session dropdown — switch the bound session\n2. Workspace dropdown — switch workspace\n3. 🤖 Preset dropdown — switch Agent Preset\n4. 🧠 Model dropdown — switch model\n5. 🆕 New session — start fresh\n6. 📋 Sessions/watches — view or bind sessions and manage watches\n7. ⏹ Stop — stop the current task\n8. 📐 Compact — compact the current session context\n9. 🧹 Clear context — clear context while keeping the binding and history\n10. Steer task — send an instruction to the Agent\n11. 🗄 Archived toggle — show or hide archived sessions\n12. 📊 Status — view connection status\n13. 📖 Help — view this help',
270
- '**⌨️ 文本命令**\n\n`/m` — 打开菜单卡片\n`/new` — 开启全新会话\n`/session ID` — 绑定已有会话\n`/sessionlist [工作区]` 或 `/sessions [工作区]` — 列出会话\n`/sessionlist --limit N` 或 `/sessions --limit N` — 仅列出当前工作区前 N 个会话\n`/workspace 工作区序号或绝对路径` — 切换工作区\n`/workspacelist` — 列出工作区\n`/status` — 查看连接状态\n`/compact` — 压缩上下文\n`/clear` — 清空上下文并保留 Session 绑定和历史记录\n`/stop` — 停止当前任务\n`/steer 指令` — 补充指令\n`/watch ID` — 关注会话\n`/watchlist` — 关注列表\n`/unwatch ID` — 取消关注\n`/archived on/off` — 归档显隐\n`/presetlist` 或 `/presets` — 列出预设\n`/preset [序号/ID]` — 切换预设\n`/preset --default` — 跟随默认\n`/models` — 列出模型\n`/reasoninglist` 或 `/reasonings` — 按序号列出当前模型可用推理等级\n`/reasoning [序号、等级ID或 --default]` — 查看或切换当前推理等级\n`/model [序号或完整模型ID] [推理等级ID]` — 查看或切换当前会话模型\n`/batch` — 开启批量输入(仅私聊,最多 10 条文字)\n`/send` — 提交当前批次\n`/cancel` — 取消当前批次\n`/repair` — 补全飞书权限与卡片回调':
271
- '**⌨️ Text commands**\n\n`/m` — open the menu card\n`/new` — start a new session\n`/session ID` — bind an existing session\n`/sessionlist [workspace]` or `/sessions [workspace]` — list sessions\n`/sessionlist --limit N` or `/sessions --limit N` — list only the first N sessions in the current workspace\n`/workspace <workspace index or absolute path>` — switch workspace\n`/workspacelist` — list workspaces\n`/status` — view connection status\n`/compact` — compact context\n`/clear` — clear context while keeping the Session binding and history\n`/stop` — stop the current task\n`/steer INSTRUCTION` — steer the task\n`/watch ID` — watch a session\n`/watchlist` — list watched sessions\n`/unwatch ID` — stop watching\n`/archived on/off` — show or hide archived sessions\n`/presetlist` or `/presets` — list presets\n`/preset [index/ID]` — switch preset\n`/preset --default` — follow default\n`/models` — list models\n`/reasoninglist` or `/reasonings` — list reasoning efforts for the current model\n`/reasoning [index, effort ID, or --default]` — show or switch reasoning effort\n`/model [index or full model ID] [reasoning effort ID]` — show or switch the current Session model\n`/batch` — start batch input (direct messages only, up to 10 text messages)\n`/send` — submit the current batch\n`/cancel` — cancel the current batch\n`/repair` — complete Feishu permissions and the card callback',
270
+ '**⌨️ 文本命令**\n\n`/m` — 打开菜单卡片\n`/new` — 开启全新会话\n`/session Session ID、当前工作区序号或标题关键词` — 绑定已有会话\n`/sessionlist [工作区]` 或 `/sessions [工作区]` — 列出会话\n`/sessionlist --all` 或 `/sessions --all` — 跨工作区汇总会话(每个工作区默认显示 10 个,可用 --limit N 调整)\n`/sessionlist --limit N` 或 `/sessions --limit N` — 仅列出当前工作区前 N 个会话\n`/workspace 工作区序号或绝对路径` — 切换工作区\n`/workspacelist` — 列出工作区\n`/status` — 查看连接状态\n`/compact` — 压缩上下文\n`/clear` — 清空上下文并保留 Session 绑定和历史记录\n`/stop` — 停止当前任务\n`/steer 指令` — 补充指令\n`/watch ID` — 关注会话\n`/watchlist` — 关注列表\n`/unwatch ID` — 取消关注\n`/archived on/off` — 归档显隐\n`/presetlist` 或 `/presets` — 列出预设\n`/preset [序号/ID]` — 切换预设\n`/preset --default` — 跟随默认\n`/models` — 列出模型\n`/reasoninglist` 或 `/reasonings` — 按序号列出当前模型可用推理等级\n`/reasoning [序号、等级ID或 --default]` — 查看或切换当前推理等级\n`/model [序号或完整模型ID] [推理等级ID]` — 查看或切换当前会话模型\n`/batch` — 开启批量输入(仅私聊,最多 10 条文字)\n`/send` — 提交当前批次\n`/cancel` — 取消当前批次\n`/repair` — 补全飞书权限与卡片回调':
271
+ '**⌨️ Text commands**\n\n`/m` — open the menu card\n`/new` — start a new session\n`/session Session ID, current workspace index, or title keyword` — bind an existing session\n`/sessionlist [workspace]` or `/sessions [workspace]` — list sessions\n`/sessionlist --all` or `/sessions --all` — summarize sessions across workspaces (10 per workspace by default; use --limit N to change)\n`/sessionlist --limit N` or `/sessions --limit N` — list only the first N sessions in the current workspace\n`/workspace <workspace index or absolute path>` — switch workspace\n`/workspacelist` — list workspaces\n`/status` — view connection status\n`/compact` — compact context\n`/clear` — clear context while keeping the Session binding and history\n`/stop` — stop the current task\n`/steer INSTRUCTION` — steer the task\n`/watch ID` — watch a session\n`/watchlist` — list watched sessions\n`/unwatch ID` — stop watching\n`/archived on/off` — show or hide archived sessions\n`/presetlist` or `/presets` — list presets\n`/preset [index/ID]` — switch preset\n`/preset --default` — follow default\n`/models` — list models\n`/reasoninglist` or `/reasonings` — list reasoning efforts for the current model\n`/reasoning [index, effort ID, or --default]` — show or switch reasoning effort\n`/model [index or full model ID] [reasoning effort ID]` — show or switch the current Session model\n`/batch` — start batch input (direct messages only, up to 10 text messages)\n`/send` — submit the current batch\n`/cancel` — cancel the current batch\n`/repair` — complete Feishu permissions and the card callback',
272
272
  '**💡 数字兜底**\n回复数字快速操作:\n**1**工作区列表 · **2**新会话 · **3**会话/关注\n**4**状态 · **5**补全权限 · **6**帮助':
273
273
  '**💡 Number fallback**\nReply with a number for a quick action:\n**1** Workspace list · **2** New session · **3** Sessions/watches\n**4** Status · **5** Complete permissions · **6** Help',
274
274
  '从下方下拉选择补充指令;最后一项可自定义输入。':
@@ -75,6 +75,8 @@ export default {
75
75
  'The model service is temporarily unreachable and the task did not finish. Please try again later.',
76
76
  '模型服务暂时异常,本次任务未完成。请稍后重试。':
77
77
  'The model service is temporarily unavailable and the task did not finish. Please try again later.',
78
+ '模型请求被服务拒绝(可能是上下文过长或该模型当前不可用)。请发送 /compact 或 /new 后重试,或改用其他模型。':
79
+ 'The model service rejected the request (the context may be too long, or that model may be unavailable right now). Send /compact or /new and try again, or switch to another model.',
78
80
  '模型回复中断或格式异常,本次任务未完成。请重试。':
79
81
  'The model reply was interrupted or malformed, so the task did not finish. Please try again.',
80
82
  '模型没有返回可显示的内容。请重试;若持续发生,请切换模型。':
@@ -186,10 +188,19 @@ export default {
186
188
  '/sessionlist [workspace index or absolute path] List session IDs and titles',
187
189
  '/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题':
188
190
  '/sessionlist or /sessions [workspace index or absolute path] List session IDs and titles',
191
+ '/sessionlist --all 跨工作区汇总会话(每个工作区默认显示 10 个,可用 --limit N 调整)':
192
+ '/sessionlist --all Summarize sessions across Workspaces (10 per Workspace by default; use --limit N to change)',
189
193
  '/sessionlist --limit N 仅列出当前工作区前 N 个会话':
190
194
  '/sessionlist --limit N List only the first N sessions in the current workspace',
191
- '/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话':
192
- '/session <Session ID or workspace index> Bind this chat to the specified session',
195
+ '/session Session ID、当前工作区序号或标题关键词 将当前聊天绑定到指定会话':
196
+ '/session <Session ID, workspace index, or title keyword> Bind this chat to the specified session',
197
+ '/sess 同一命令的别名(/session 被客户端同名命令抢占时使用)':
198
+ '/sess Alias of the same command (use it when a client claims /session)',
199
+ '归档指定会话(DSH 能力)': 'Archive a session (a DSH capability)',
200
+ '/sessionarchive(或 /sessarchive)Session ID 归档一个会话;序号只做预览':
201
+ '/sessionarchive (or /sessarchive) <Session ID> Archive one session; an index only previews',
202
+ '/sessionarchive <Session ID> --stop 归档前先停止该会话正在运行的任务':
203
+ '/sessionarchive <Session ID> --stop Stop that session\'s running work before archiving it',
193
204
  '/models 按序号列出所有可用模型': '/models List all available models by index',
194
205
  '/reasoninglist 或 /reasonings 按序号列出当前模型可用推理等级':
195
206
  '/reasoninglist or /reasonings List reasoning efforts for the current model by index',
@@ -1,10 +1,10 @@
1
1
  // English translations (shared-b area). Keys are exact Chinese literals passed to t().
2
2
  export default {
3
3
  // workspace-command.mjs
4
- '用法:/session Session ID 或当前工作区序号(/session N)':
5
- 'Usage: /session Session ID or the session index in the current Workspace (/session N)',
6
- '用法:\n/sessionlist 列出当前工作区会话\n/sessionlist --limit N 列出当前工作区前 N 个会话(N 为正整数)\n/sessionlist 工作区序号 按 /workspacelist 序号列出会话\n/sessionlist 工作区绝对路径 列出指定工作区会话\n不带工作区参数时,默认列出当前对话的有效工作区(未设置对话专属工作区时即 bot 默认工作区)。':
7
- 'Usage:\n/sessionlist List Sessions in the current Workspace\n/sessionlist --limit N List the first N Sessions in the current Workspace (N must be a positive integer)\n/sessionlist Workspace index List Sessions by /workspacelist index\n/sessionlist Workspace absolute path List Sessions in the given Workspace\nWithout a workspace argument it lists the workspace this conversation effectively uses (the bot default when no conversation workspace is set).',
4
+ '用法:/session Session ID、当前工作区序号(/session N)或会话标题关键词':
5
+ 'Usage: /session Session ID, the Session index in the current Workspace (/session N), or a Session title keyword',
6
+ '用法:\n/sessionlist 列出当前工作区会话\n/sessionlist --all 跨工作区汇总列出会话(每个工作区默认显示 10 个)\n/sessionlist --all --limit N 跨工作区汇总列出会话,每个工作区显示前 N 个\n/sessionlist --limit N 列出当前工作区前 N 个会话(N 为正整数)\n/sessionlist --archived 一并列出已归档会话(序号仍只对应未归档会话)\n/sessionlist 工作区序号 按 /workspacelist 序号列出会话\n/sessionlist 工作区绝对路径 列出指定工作区会话\n不带工作区参数时,默认列出当前对话的有效工作区(未设置对话专属工作区时即 bot 默认工作区)。':
7
+ 'Usage:\n/sessionlist List Sessions in the current Workspace\n/sessionlist --all List Sessions across all Workspaces (10 per Workspace by default)\n/sessionlist --all --limit N List Sessions across all Workspaces, the first N per Workspace\n/sessionlist --limit N List the first N Sessions in the current Workspace (N must be a positive integer)\n/sessionlist --archived Also list archived Sessions (indices still cover non-archived Sessions only)\n/sessionlist Workspace index List Sessions by /workspacelist index\n/sessionlist Workspace absolute path List Sessions in the given Workspace\nWithout a workspace argument it lists the workspace this conversation effectively uses (the bot default when no conversation workspace is set).',
8
8
  '工作区必须是绝对路径。\n{usage}': 'The Workspace must be an absolute path.\n{usage}',
9
9
  '工作区路径包含不支持的字符或长度超过限制。\n{usage}':
10
10
  'The Workspace path contains unsupported characters or exceeds the length limit.\n{usage}',
@@ -51,6 +51,58 @@ export default {
51
51
  'The bot is being removed or has been reconnected; cannot list Workspace Sessions of the original Session.',
52
52
  '暂时无法获取工作区会话列表,请稍后重试。':
53
53
  'Unable to get the Workspace Session list right now; please try again later.',
54
+ '(当前绑定)': '(currently bound)',
55
+ '跨工作区会话({workspaces} 个工作区,共 {sessions} 个会话):':
56
+ 'Sessions across Workspaces ({workspaces} Workspaces, {sessions} Sessions in total):',
57
+ '当前工作区:{workspace}': 'Current Workspace: {workspace}',
58
+ '另有 {count} 个工作区暂时无法读取,未包含在汇总中。':
59
+ '{count} more Workspace(s) could not be read and are not included in the summary.',
60
+ '{workspace}({count} 个会话)': '{workspace} ({count} Sessions)',
61
+ '(共 {total} 个,显示前 {shown} 个;用 --limit N 调整)':
62
+ '(of {total} total, showing the first {shown}; use --limit N to change)',
63
+ '该工作区暂无会话。': 'This Workspace has no Sessions yet.',
64
+ '(已隐藏 {count} 条归档会话,用 --archived 查看)':
65
+ '(hid {count} archived Session(s); use --archived to see them)',
66
+ '归档会话(只能用完整 Session ID 绑定):':
67
+ 'Archived Sessions (bind them with the full Session ID):',
68
+ '({count} 条会话记录无效,已跳过)':
69
+ '({count} invalid Session records skipped)',
70
+ '当前机器人暂不支持跨工作区列出会话。':
71
+ 'This bot does not support listing Sessions across Workspaces yet.',
72
+ '用法:/sessionarchive Session ID 归档一个会话;/sessionarchive 序号 只预览该序号对应的会话(编号会随列表变化,归档请用完整 ID)。加 --stop 可让 DSH 先停止该会话正在运行的任务':
73
+ 'Usage: /sessionarchive <Session ID> archives a Session; /sessionarchive <index> only previews the Session behind that index (indices shift, so archiving needs the full ID). Add --stop to let DSH stop that Session\'s running work first',
74
+ '按序号归档只做预览:/sessionarchive {index} 现在对应这条会话。':
75
+ 'Archiving by index is preview-only: /sessionarchive {index} currently points at this Session.',
76
+ '(编号会随会话列表变化,所以不按序号直接归档;确认归档请发送:/sessionarchive {sessionId})':
77
+ '(Indices shift as the list changes, so archiving by index is never executed; to confirm, send: /sessionarchive {sessionId})',
78
+ '当前机器人暂不支持归档会话。': 'This bot does not support archiving Sessions yet.',
79
+ '该会话已经归档。': 'This Session is already archived.',
80
+ '这是本对话当前绑定的会话,请先 /new 或绑定其他会话,再归档它。':
81
+ 'This is the Session this chat is bound to; send /new or bind another Session before archiving it.',
82
+ '已归档会话:': 'Archived Session:',
83
+ '机器人正在移除或已重新接入,无法归档原会话的会话。':
84
+ 'The bot is being removed or has been reconnected; cannot archive Sessions of the original conversation.',
85
+ '当前 DSH 版本不支持通过机器人归档会话。':
86
+ 'This DSH version does not expose Session archiving to the bot.',
87
+ '该会话仍有任务在运行,请先 /stop,或使用 /sessionarchive <目标> --stop。':
88
+ 'That Session still has running work; send /stop first, or use /sessionarchive <target> --stop.',
89
+ '暂时无法归档该会话,请稍后重试。': 'Unable to archive that Session right now; please try again later.',
90
+ '标题包含「{keyword}」的会话有多个,请改用完整 Session ID 绑定:':
91
+ 'Several Sessions have titles containing "{keyword}"; bind with the full Session ID instead:',
92
+ '标题包含「{keyword}」的会话位于其他工作区,请使用完整 Session ID 绑定:':
93
+ 'Sessions whose titles contain "{keyword}" are in other Workspaces; bind with the full Session ID:',
94
+ '部分工作区暂时无法读取,搜索结果可能不完整;请使用完整 Session ID 绑定:':
95
+ 'Some Workspaces could not be read, so the search may be incomplete; bind with the full Session ID:',
96
+ '部分工作区暂时无法读取,未能确认标题包含「{keyword}」的会话。请稍后重试或使用完整 Session ID。':
97
+ 'Some Workspaces could not be read, so no Session title containing "{keyword}" could be confirmed. Try again later or use the full Session ID.',
98
+ '匹配较多,只显示前 {count} 个,请使用更精确的关键词。':
99
+ 'Many matches; only the first {count} are shown. Please use a more specific keyword.',
100
+ '标题包含「{keyword}」的会话已归档,按标题绑定不会接管归档会话,请用完整 Session ID 绑定:':
101
+ 'Sessions whose titles contain "{keyword}" are archived, and a title keyword never takes over an archived Session; bind one with its full Session ID:',
102
+ '按标题匹配到「{title}」(ID: {sessionId},工作区: {workspace}),但 Harness 当前无法接管这个会话,请稍后重试或用完整 Session ID 绑定。':
103
+ 'The keyword matched "{title}" (ID: {sessionId}, Workspace: {workspace}), but Harness cannot take over that Session right now. Try again later or bind it with the full Session ID.',
104
+ '没有标题包含「{keyword}」的会话,请先执行 /sessionlist --all 查看完整 Session ID。':
105
+ 'No Session title contains "{keyword}"; run /sessionlist --all to find the full Session ID.',
54
106
  'Session ID 格式无效。\n{usage}': 'Invalid Session ID format.\n{usage}',
55
107
  '未找到该会话,请先执行 /sessionlist 确认 Session ID。':
56
108
  'Session not found; please run /sessionlist to confirm the Session ID.',
@@ -294,4 +346,21 @@ export default {
294
346
  'A queued message was interrupted when the service restarted. It was not replayed automatically to avoid running it twice; if it was not processed, please send it again.',
295
347
  '已提交补充指令,Agent 会在下一步读取。':
296
348
  'Additional instruction submitted; the Agent will read it at the next step.',
349
+ // delivery-sync-rpc.mjs
350
+ '请求已取消。': 'The request was cancelled.',
351
+ '无效的会话同步设置:开关必须是布尔值,图标是不超过 32 个字符的文本。':
352
+ 'Invalid Session sync settings: each switch must be a boolean and an icon is text of at most 32 characters.',
353
+ '无法读取或保存会话同步设置,请稍后重试。':
354
+ 'Could not read or save Session sync settings. Try again later.',
355
+
356
+ // plan-goal-command.mjs
357
+ '当前聊天还没有可用的会话,请先发送一条消息。':
358
+ 'This chat has no available Session yet; please send a message first.',
359
+ '当前 Host 不支持命令委派,请确认 DSH 命令网关可用。':
360
+ 'The current Host does not support command delegation; make sure the DSH command gateway is available.',
361
+ '{name} 已执行。': '{name} executed.',
362
+ '{name} 执行失败。': '{name} failed.',
363
+ '{name} 执行失败,请稍后重试。': '{name} failed; please try again later.',
364
+ '当前机器人暂不支持 {name} 命令。': 'This bot does not support the {name} command yet.',
365
+ '当前 Host 未注册 {name} 命令。': 'The current Host has not registered the {name} command.',
297
366
  };