@2en/clawly-plugins 1.21.2 → 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.
- package/cron-hook.ts +1 -3
- package/index.ts +2 -0
- package/package.json +2 -1
- package/session-setup.ts +61 -0
package/cron-hook.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* before_tool_call hook for cron (action=add) — ensures delivery fields are
|
|
3
3
|
* always set correctly, even when the LLM omits them.
|
|
4
4
|
*
|
|
5
|
-
* Forces: delivery.mode = "none" (agent uses clawly_send_message
|
|
5
|
+
* Forces: delivery.mode = "none" (agent uses clawly_send_message tool)
|
|
6
6
|
* Appends: delivery instructions to payload.message
|
|
7
7
|
* Patches: payload.kind "systemEvent" → "agentTurn"
|
|
8
8
|
*
|
|
@@ -25,8 +25,6 @@ const DELIVERY_SUFFIX = [
|
|
|
25
25
|
'DELIVERY INSTRUCTIONS (mandatory):',
|
|
26
26
|
'When done, you MUST deliver your result to the user:',
|
|
27
27
|
'1. Call the clawly_send_message tool with role="assistant" and a brief, natural summary of your result.',
|
|
28
|
-
'2. Call clawly_is_user_online to check if the user is online.',
|
|
29
|
-
'3. If offline, also call clawly_send_app_push with a short notification.',
|
|
30
28
|
].join('\n')
|
|
31
29
|
|
|
32
30
|
function patchJob(job: UnknownRecord): UnknownRecord {
|
package/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ import {registerEmail} from './email'
|
|
|
36
36
|
import {registerGateway} from './gateway'
|
|
37
37
|
import {getGatewayConfig} from './gateway-fetch'
|
|
38
38
|
import {setupModelGateway} from './model-gateway-setup'
|
|
39
|
+
import {setupSession} from './session-setup'
|
|
39
40
|
import {registerOutboundHook, registerOutboundHttpRoute, registerOutboundMethods} from './outbound'
|
|
40
41
|
import {registerSkillCommandRestore} from './skill-command-restore'
|
|
41
42
|
import {registerTools} from './tools'
|
|
@@ -120,6 +121,7 @@ export default {
|
|
|
120
121
|
registerGateway(api)
|
|
121
122
|
registerAutoPair(api)
|
|
122
123
|
setupModelGateway(api)
|
|
124
|
+
setupSession(api)
|
|
123
125
|
|
|
124
126
|
// Email & calendar (optional — requires skillGatewayBaseUrl + skillGatewayToken in config)
|
|
125
127
|
const gw = getGatewayConfig(api)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2en/clawly-plugins",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.4",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"gateway-fetch.ts",
|
|
25
25
|
"outbound.ts",
|
|
26
26
|
"model-gateway-setup.ts",
|
|
27
|
+
"session-setup.ts",
|
|
27
28
|
"skill-command-restore.ts",
|
|
28
29
|
"openclaw.plugin.json"
|
|
29
30
|
],
|
package/session-setup.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
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).
|
|
8
|
+
*
|
|
9
|
+
* Runs synchronously during plugin registration, same pattern as
|
|
10
|
+
* model-gateway-setup.ts.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import path from 'node:path'
|
|
14
|
+
|
|
15
|
+
import type {PluginApi} from './index'
|
|
16
|
+
import {readOpenclawConfig, resolveStateDir, writeOpenclawConfig} from './model-gateway-setup'
|
|
17
|
+
|
|
18
|
+
const DESIRED_DM_SCOPE = 'per-channel-peer'
|
|
19
|
+
const DESIRED_SESSION_VISIBILITY = 'agent'
|
|
20
|
+
|
|
21
|
+
export function setupSession(api: PluginApi): void {
|
|
22
|
+
const stateDir = resolveStateDir(api)
|
|
23
|
+
if (!stateDir) {
|
|
24
|
+
api.logger.warn('Cannot resolve state dir — session setup skipped.')
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const configPath = path.join(stateDir, 'openclaw.json')
|
|
29
|
+
const config = readOpenclawConfig(configPath)
|
|
30
|
+
|
|
31
|
+
let dirty = false
|
|
32
|
+
|
|
33
|
+
// 1. dmScope
|
|
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
|
+
}
|
|
40
|
+
|
|
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
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!dirty) return
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
writeOpenclawConfig(configPath, config)
|
|
55
|
+
api.logger.info(
|
|
56
|
+
`Session: dmScope="${DESIRED_DM_SCOPE}", tools.sessions.visibility="${DESIRED_SESSION_VISIBILITY}".`,
|
|
57
|
+
)
|
|
58
|
+
} catch (err) {
|
|
59
|
+
api.logger.error(`Failed to update session config: ${(err as Error).message}`)
|
|
60
|
+
}
|
|
61
|
+
}
|