@2en/clawly-plugins 1.17.6 → 1.18.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/gateway/index.ts CHANGED
@@ -3,6 +3,7 @@ import {registerAgentSend} from './agent'
3
3
  import {registerChannelsConfigure} from './channels-configure'
4
4
  import {registerClawhub2gateway} from './clawhub2gateway'
5
5
  import {registerConfigRepair} from './config-repair'
6
+ import {registerPairing} from './pairing'
6
7
  import {registerMemoryBrowser} from './memory'
7
8
  import {registerNotification} from './notification'
8
9
  import {registerOfflinePush} from './offline-push'
@@ -19,4 +20,5 @@ export function registerGateway(api: PluginApi) {
19
20
  registerChannelsConfigure(api)
20
21
  registerOfflinePush(api)
21
22
  registerConfigRepair(api)
23
+ registerPairing(api)
22
24
  }
package/gateway/inject.ts CHANGED
@@ -54,7 +54,7 @@ export async function injectAssistantMessage(
54
54
  */
55
55
  export async function resolveSessionKey(agentId: string, api: PluginApi): Promise<string> {
56
56
  try {
57
- const rpcParams = JSON.stringify({agentId})
57
+ const rpcParams = JSON.stringify({key: 'main', agentId})
58
58
  const result = await $`openclaw gateway call sessions.resolve --json --params ${rpcParams}`
59
59
  const jsonStr = stripCliLogs(result.stdout)
60
60
  const parsed = JSON.parse(jsonStr)
@@ -0,0 +1,42 @@
1
+ import {$} from 'zx'
2
+ import type {PluginApi} from '../index'
3
+ import {stripCliLogs} from '../lib/stripCliLogs'
4
+
5
+ $.verbose = false
6
+
7
+ export function registerPairing(api: PluginApi) {
8
+ api.registerGatewayMethod('clawly.pairing.list', async ({params, respond}) => {
9
+ const channel = typeof params.channel === 'string' ? params.channel.trim() : ''
10
+ if (!channel) {
11
+ respond(false, undefined, {code: 'invalid_params', message: 'channel is required'})
12
+ return
13
+ }
14
+ try {
15
+ const result = await $`openclaw pairing list ${channel} --json`
16
+ const parsed = JSON.parse(stripCliLogs(result.stdout))
17
+ respond(true, parsed)
18
+ } catch (err) {
19
+ const msg = err instanceof Error ? err.message : String(err)
20
+ api.logger.error(`pairing.list: ${msg}`)
21
+ respond(false, undefined, {code: 'cli_error', message: msg})
22
+ }
23
+ })
24
+ api.registerGatewayMethod('clawly.pairing.approve', async ({params, respond}) => {
25
+ const channel = typeof params.channel === 'string' ? params.channel.trim() : ''
26
+ const code = typeof params.code === 'string' ? params.code.trim() : ''
27
+ if (!channel || !code) {
28
+ respond(false, undefined, {code: 'invalid_params', message: 'channel and code are required'})
29
+ return
30
+ }
31
+ try {
32
+ const result = await $`openclaw pairing approve ${channel} ${code}`
33
+ respond(true, {ok: true, output: result.stdout.trim()})
34
+ } catch (err) {
35
+ const msg = err instanceof Error ? err.message : String(err)
36
+ api.logger.error(`pairing.approve: ${msg}`)
37
+ respond(false, undefined, {code: 'cli_error', message: msg})
38
+ }
39
+ })
40
+
41
+ api.logger.info('pairing: registered clawly.pairing.list + clawly.pairing.approve')
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2en/clawly-plugins",
3
- "version": "1.17.6",
3
+ "version": "1.18.1",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "repository": {