dsh-tg-bridge 1.47.0 → 1.48.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 (69) hide show
  1. package/chat/commands-registry.mjs +4 -4
  2. package/chat/control.mjs +2 -1
  3. package/chat/file-press.mjs +28 -1
  4. package/chat/handle-message.mjs +499 -497
  5. package/chat/help-explain.mjs +37 -2
  6. package/chat/help-sections.mjs +4 -4
  7. package/chat/media-text.mjs +6 -1
  8. package/chat/menu-card.mjs +226 -223
  9. package/chat/panel.mjs +13 -1
  10. package/chat/subagents-card.mjs +47 -0
  11. package/chat/topics.mjs +45 -0
  12. package/control/agents.mjs +99 -4
  13. package/control/cmd-balance.mjs +89 -0
  14. package/control/cmd-model.mjs +15 -5
  15. package/control/cmd-session.mjs +107 -9
  16. package/control/cmd-skills.mjs +56 -2
  17. package/control/cmd-subagents.mjs +34 -0
  18. package/control/cmd-views.mjs +7 -0
  19. package/control/model-card.mjs +6 -2
  20. package/control/models.mjs +36 -1
  21. package/control/sessions.mjs +30 -10
  22. package/core/run-command.mjs +4 -3
  23. package/docs/CHANGELOG.md +125 -1
  24. package/docs/COMMANDS.md +18 -3
  25. package/docs/MARKETPLACE.md +24 -0
  26. package/i18n/en/balance.mjs +12 -0
  27. package/i18n/en/branch.mjs +16 -0
  28. package/i18n/en/core.mjs +16 -1
  29. package/i18n/en/cost.mjs +1 -1
  30. package/i18n/en/ctrl.mjs +499 -498
  31. package/i18n/en/files.mjs +9 -0
  32. package/i18n/en/history.mjs +17 -0
  33. package/i18n/en/model.mjs +1 -0
  34. package/i18n/en/remember.mjs +17 -0
  35. package/i18n/en.mjs +6 -1
  36. package/i18n/ru/balance.mjs +12 -0
  37. package/i18n/ru/branch.mjs +16 -0
  38. package/i18n/ru/core.mjs +16 -1
  39. package/i18n/ru/cost.mjs +1 -1
  40. package/i18n/ru/ctrl.mjs +499 -498
  41. package/i18n/ru/files.mjs +9 -0
  42. package/i18n/ru/history.mjs +17 -0
  43. package/i18n/ru/model.mjs +1 -0
  44. package/i18n/ru/remember.mjs +17 -0
  45. package/i18n/ru.mjs +6 -1
  46. package/i18n/zh/balance.mjs +12 -0
  47. package/i18n/zh/branch.mjs +16 -0
  48. package/i18n/zh/core.mjs +17 -2
  49. package/i18n/zh/cost.mjs +1 -1
  50. package/i18n/zh/ctrl.mjs +499 -498
  51. package/i18n/zh/files.mjs +9 -0
  52. package/i18n/zh/history.mjs +17 -0
  53. package/i18n/zh/model.mjs +1 -0
  54. package/i18n/zh/remember.mjs +17 -0
  55. package/i18n/zh.mjs +6 -1
  56. package/model/balance.mjs +102 -0
  57. package/model/fallback.mjs +28 -1
  58. package/package.json +1 -1
  59. package/plugin-bridge.mjs +32 -6
  60. package/profile/agents.mjs +54 -0
  61. package/profile/profiles.mjs +19 -1
  62. package/turn/failures.mjs +6 -0
  63. package/turn/files.mjs +95 -0
  64. package/turn/progress.mjs +496 -459
  65. package/turn/task-arg.mjs +27 -0
  66. package/turn/turn.mjs +7 -1
  67. package/work/history.mjs +42 -0
  68. package/work/rewind.mjs +19 -0
  69. package/work/subagents.mjs +68 -0
@@ -16,11 +16,11 @@ export const EXTERNAL_COMMANDS = ['setinline'];
16
16
  export const CONTROL_COMMANDS = [
17
17
  'status', 'models', 'model', 'effort', 'profile', 'agents', 'preset', 'permissions', 'plan',
18
18
  'jobs', 'remind', 'every', 'sessions', 'resume', 'plugins', 'plugin', 'mcp',
19
- 'skills', 'soul', 'restart', 'app', 'stop', 'new', 'seed', 'send', 'cd',
20
- 'prices', 'cost', 'help', 'doctor', 'logs', 'report', 'lang', 'reasoning', 'pin', 'goal', 'task', 'tasks',
19
+ 'skills', 'soul', 'remember', 'restart', 'app', 'stop', 'new', 'seed', 'send', 'cd',
20
+ 'prices', 'cost', 'balance', 'help', 'doctor', 'logs', 'report', 'lang', 'reasoning', 'pin', 'goal', 'task', 'tasks',
21
21
  'thoughts', 'version', 'update', 'crew', 'agentset', 'subscribe', 'settings',
22
- 'rewind', 'fork', 'branches', 'menu', 'fallback', 'load', 'diff', 'endpoint', 'dsh', 'compact', 'card', 'find', 'start',
23
- 'ls', 'view', 'edit',
22
+ 'rewind', 'fork', 'branches', 'branch', 'history', 'menu', 'fallback', 'load', 'diff', 'endpoint', 'dsh', 'compact', 'card', 'find', 'start',
23
+ 'ls', 'view', 'edit', 'subagents',
24
24
  ];
25
25
 
26
26
  /**
package/chat/control.mjs CHANGED
@@ -37,6 +37,7 @@ import { handlePluginCommands } from '../control/cmd-plugin.mjs';
37
37
  import { handleSessionCommands } from '../control/cmd-session.mjs';
38
38
  import { handleStartCommands } from '../control/cmd-start.mjs';
39
39
  import { handleSkillCommands } from '../control/cmd-skills.mjs';
40
+ import { handleSubagentCommands } from '../control/cmd-subagents.mjs';
40
41
  import { handleTaskCommands } from '../control/cmd-task.mjs';
41
42
  import { handleViewCommands } from '../control/cmd-views.mjs';
42
43
  import { handleEndpointCommands } from '../control/cmd-endpoint.mjs';
@@ -119,7 +120,7 @@ export async function handleControl(ctx) {
119
120
  // that is not its job. The order is alphabetical, not meaningful: no two
120
121
  // groups claim the same command, so a miss falls through to `default` below.
121
122
  const child = { ...ctx, effective, command, arg: effectiveArgText, send, reply, log, profile, state, key, config, lang };
122
- for (const handler of [handleAgentCommands, handleBridgeCommands, handleCardCommands, handleCompactCommands, handleDiffCommands, handleEditCommands, handleEveryCommands, handleDshCommands, handleFallbackCommands, handleFileCommands, handleFindCommands, handleLoadCommands, handleMcpCommands, handlePlanCommands, handlePluginCommands, handleSessionCommands, handleSkillCommands, handleStartCommands, handleTaskCommands, handleViewCommands, handleEndpointCommands]) {
123
+ for (const handler of [handleAgentCommands, handleBridgeCommands, handleCardCommands, handleCompactCommands, handleDiffCommands, handleEditCommands, handleEveryCommands, handleDshCommands, handleFallbackCommands, handleFileCommands, handleFindCommands, handleLoadCommands, handleMcpCommands, handlePlanCommands, handlePluginCommands, handleSessionCommands, handleSkillCommands, handleStartCommands, handleSubagentCommands, handleTaskCommands, handleViewCommands, handleEndpointCommands]) {
123
124
  if (await handler(child)) return true;
124
125
  }
125
126
  // Nothing claimed it: the bridge answers an unknown `/` command itself, with
@@ -8,7 +8,7 @@ import { previewWindow } from './file-preview.mjs';
8
8
  import { listDir, listingCard } from './file-listing.mjs';
9
9
  import { t } from '../core/i18n.mjs';
10
10
  import { saveState, state } from '../core/state.mjs';
11
- import { inlineKeyboard, tg } from './telegram.mjs';
11
+ import { inlineKeyboard, sendFile, tg } from './telegram.mjs';
12
12
 
13
13
  /**
14
14
  * Handle one `fs:` or `fv:` press.
@@ -16,6 +16,9 @@ import { inlineKeyboard, tg } from './telegram.mjs';
16
16
  * @returns {Promise<boolean>} true when the press was this module's to answer.
17
17
  */
18
18
  export async function handleFilePress({ data, key, lang, chatId, threadId, messageId, answer }) {
19
+ if (String(data || '').startsWith('tf:')) {
20
+ return sendTurnFile({ index: Number(String(data).slice(3)) || 0, key, lang, chatId, threadId, answer });
21
+ }
19
22
  if (String(data || '').startsWith('fv:')) {
20
23
  return pressEntry({ data: String(data).slice(3), key, lang, chatId, threadId, messageId, answer });
21
24
  }
@@ -71,6 +74,30 @@ export async function handleFilePress({ data, key, lang, chatId, threadId, messa
71
74
  return true;
72
75
  }
73
76
 
77
+ /**
78
+ * An `tf:` press: send one file the finished turn wrote, as a document.
79
+ *
80
+ * The row comes from `state.turnFiles`, written when the card was drawn, so the
81
+ * button can only send something that turn actually produced. A newer turn
82
+ * replaces the list; a press on the old card then finds no row and answers
83
+ * "stale" instead of sending whatever moved into that slot.
84
+ */
85
+ async function sendTurnFile({ index, key, lang, chatId, threadId, answer }) {
86
+ const rows = state.turnFiles?.[key];
87
+ const row = rows?.[index];
88
+ if (!row) {
89
+ await answer(t(lang, 'card.files.stale'));
90
+ return true;
91
+ }
92
+ try {
93
+ await sendFile(chatId, threadId, row.path, row.name);
94
+ await answer(t(lang, 'card.files.sent', { name: row.name }));
95
+ } catch (error) {
96
+ await answer(t(lang, 'card.files.failed', { err: String(error.message).slice(0, 80) }));
97
+ }
98
+ return true;
99
+ }
100
+
74
101
  /** A `/ls` row pressed: walk into a folder, or open the file it named. */
75
102
  async function pressEntry({ data, key, lang, chatId, threadId, messageId, answer }) {
76
103
  const cur = state.listing?.[key];