@2en/clawly-plugins 1.21.3 → 1.21.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/session-setup.ts +27 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2en/clawly-plugins",
3
- "version": "1.21.3",
3
+ "version": "1.21.4",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "repository": {
package/session-setup.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  /**
2
- * On plugin init, patches openclaw.json to set `session.dmScope` to
3
- * "per-channel-peer". This isolates Telegram (and other channel) DMs from the
4
- * Clawly mobile session so messages don't leak across channels.
2
+ * On plugin init, patches openclaw.json to:
3
+ * 1. Set `session.dmScope` to "per-channel-peer" isolates Telegram (and
4
+ * other channel) DMs from the Clawly mobile session.
5
+ * 2. Set `tools.sessions.visibility` to "agent" — lets the agent read
6
+ * conversation history from other sessions under the same agent (e.g.
7
+ * reference recent Telegram chats from the mobile session).
5
8
  *
6
9
  * Runs synchronously during plugin registration, same pattern as
7
10
  * model-gateway-setup.ts.
@@ -13,6 +16,7 @@ import type {PluginApi} from './index'
13
16
  import {readOpenclawConfig, resolveStateDir, writeOpenclawConfig} from './model-gateway-setup'
14
17
 
15
18
  const DESIRED_DM_SCOPE = 'per-channel-peer'
19
+ const DESIRED_SESSION_VISIBILITY = 'agent'
16
20
 
17
21
  export function setupSession(api: PluginApi): void {
18
22
  const stateDir = resolveStateDir(api)
@@ -24,18 +28,33 @@ export function setupSession(api: PluginApi): void {
24
28
  const configPath = path.join(stateDir, 'openclaw.json')
25
29
  const config = readOpenclawConfig(configPath)
26
30
 
31
+ let dirty = false
32
+
33
+ // 1. dmScope
27
34
  const session = ((config.session as Record<string, unknown>) ?? {}) as Record<string, unknown>
35
+ if (session.dmScope !== DESIRED_DM_SCOPE) {
36
+ session.dmScope = DESIRED_DM_SCOPE
37
+ config.session = session
38
+ dirty = true
39
+ }
28
40
 
29
- if (session.dmScope === DESIRED_DM_SCOPE) {
30
- return
41
+ // 2. tools.sessions.visibility
42
+ const tools = ((config.tools as Record<string, unknown>) ?? {}) as Record<string, unknown>
43
+ const sessions = ((tools.sessions as Record<string, unknown>) ?? {}) as Record<string, unknown>
44
+ if (sessions.visibility !== DESIRED_SESSION_VISIBILITY) {
45
+ sessions.visibility = DESIRED_SESSION_VISIBILITY
46
+ tools.sessions = sessions
47
+ config.tools = tools
48
+ dirty = true
31
49
  }
32
50
 
33
- session.dmScope = DESIRED_DM_SCOPE
34
- config.session = session
51
+ if (!dirty) return
35
52
 
36
53
  try {
37
54
  writeOpenclawConfig(configPath, config)
38
- api.logger.info(`Session: set dmScope to "${DESIRED_DM_SCOPE}".`)
55
+ api.logger.info(
56
+ `Session: dmScope="${DESIRED_DM_SCOPE}", tools.sessions.visibility="${DESIRED_SESSION_VISIBILITY}".`,
57
+ )
39
58
  } catch (err) {
40
59
  api.logger.error(`Failed to update session config: ${(err as Error).message}`)
41
60
  }