@soffits/dsh-matrix-bot 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.1
6
+
7
+ - `!model` and `!effort` switch only the room's session. They used to go through the Web UI's model picker, which also saves every pick as the default for new sessions, so a switch in one room changed the model every other new session started on. The model is still checked with the host before the switch, and `/reset` in the room still starts on the room's pick.
8
+
5
9
  ## 0.2.0
6
10
 
7
11
  - Prompts carry metadata only: the sender on `source.principal` (the room is now `chat: { id, name }`, was `room`), and the send time and the replied-to message on `source.envelope` (`sentAt`, `replyTo`), the shape [dsh-message-context](https://github.com/soffits/dsh-message-context) reads. The bot no longer adds its own `matrix-sender` notice or reply text; install dsh-message-context to show the model who wrote each message.
package/README.md CHANGED
@@ -78,7 +78,7 @@ Commands start with `!`, which works in every Matrix client. `/` works too in cl
78
78
  | `!allow`, `!deny` | Answer the waiting tool request |
79
79
  | `!id`, `!ping`, `!restart` | Ids, a check, and reconnecting |
80
80
 
81
- Lists such as `!model` are numbered; the same command with the numbers picks one (`!model 2 5`).
81
+ Lists such as `!model` are numbered; the same command with the numbers picks one (`!model 2 5`). A model or effort picked in a room applies to that room's session only; the default for new sessions stays as it is.
82
82
 
83
83
  ## Sending from scripts, agents and other plugins
84
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-matrix-bot",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Matrix bot for DeepSeek Harness: an end-to-end encrypted Matrix account, a private Space per person with one room per DSH session, streamed answers, commands, files, voice messages, tool approvals and agent questions.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/controls.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * Session controls from a room: model, reasoning effort, access mode and
3
3
  * context use, picked from numbered lists.
4
4
  */
5
- import { defaultModelOf, effortChoices, effortName, findModel, modelName, pickedSelection, sessionModelOf } from './models.js'
6
- import { controllerOf, currentPermission, permissionOptions, setPermission } from './sessions.js'
5
+ import { defaultModelOf, effortChoices, effortName, findModel, modelName, pickedSelection, selectSessionModel, sessionModelOf } from './models.js'
6
+ import { currentPermission, permissionOptions, setPermission } from './sessions.js'
7
7
 
8
8
  /** @returns `n` as a 1-based list index into `items`, or undefined. */
9
9
  export function pick(items, value) {
@@ -81,18 +81,12 @@ async function contextUse(bridge, roomId, current) {
81
81
  return { windowSize, used }
82
82
  }
83
83
 
84
- /** Apply a model selection the way the Web picker does, and remember it for /new. */
84
+ /** Switch the room's session to a model, and remember it for /new; the default for new sessions stays. */
85
85
  async function selectModel(bridge, roomId, selection) {
86
86
  const store = bridge.store()
87
87
  store.data.picks[roomId] = selection
88
88
  await store.save()
89
- const agent = await bridge.ensureAgent(roomId, { claim: true })
90
- const controller = controllerOf(bridge.ctx)
91
- if (typeof controller?.selectModel === 'function') {
92
- await controller.selectModel({ sessionId: agent.session?.id ?? agent.id, ...selection })
93
- return
94
- }
95
- agent.model.select(selection)
89
+ await selectSessionModel(bridge.ctx, await bridge.ensureAgent(roomId, { claim: true }), selection)
96
90
  }
97
91
 
98
92
  /** Handlers of the control commands, merged into the command table. */
package/src/models.js CHANGED
@@ -48,6 +48,24 @@ export async function sessionModelOf(ctx, sessionId) {
48
48
  }
49
49
  }
50
50
 
51
+ /**
52
+ * Switch one session to a model without touching the default for new
53
+ * sessions. The Web picker's `sessionController.selectModel` saves every pick
54
+ * as that default, so a switch in one room would move every room's next
55
+ * session; this takes its other steps instead: the host checks it can route
56
+ * the model (`llm.resolveCallConfig`, which throws with the reason when it
57
+ * cannot), then the live agent records it.
58
+ * @param ctx - Host context.
59
+ * @param agent - the session's live agent.
60
+ * @param selection - provider, model and optional effort.
61
+ */
62
+ export async function selectSessionModel(ctx, agent, selection) {
63
+ const picked = toSelection(selection)
64
+ const llm = ctx.get('llm')
65
+ if (typeof llm?.resolveCallConfig === 'function') await llm.resolveCallConfig({ ...picked })
66
+ agent.model.select(picked)
67
+ }
68
+
51
69
  /**
52
70
  * Read the deployment default model (the one the Web UI saves).
53
71
  * @param ctx - Host context.