@2en/clawly-plugins 1.34.0-beta.0 → 1.34.0-beta.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/info.ts +5 -1
- package/http/info.ts +28 -0
- package/http/version.ts +29 -0
- package/index.ts +6 -0
- package/package.json +1 -1
package/gateway/info.ts
CHANGED
|
@@ -11,8 +11,12 @@ import type {PluginApi} from '../types'
|
|
|
11
11
|
// @ts-expect-error — JSON import
|
|
12
12
|
import pkg from '../package.json'
|
|
13
13
|
|
|
14
|
+
export function getInfoPayload(): {version: string} {
|
|
15
|
+
return {version: pkg.version}
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
export function registerInfo(api: PluginApi) {
|
|
15
19
|
api.registerGatewayMethod('clawly.info', async ({respond}) => {
|
|
16
|
-
respond(true,
|
|
20
|
+
respond(true, getInfoPayload())
|
|
17
21
|
})
|
|
18
22
|
}
|
package/http/info.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP route for plugin package info.
|
|
3
|
+
*
|
|
4
|
+
* Route: GET /clawly/info → { version: string }
|
|
5
|
+
* Auth: plugin (HMAC access token or gateway Bearer token)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {IncomingMessage, ServerResponse} from 'node:http'
|
|
9
|
+
|
|
10
|
+
import {getInfoPayload} from '../gateway/info'
|
|
11
|
+
import {guardHttpAuth, handleCors, sendJson} from '../lib/httpAuth'
|
|
12
|
+
import type {PluginApi} from '../types'
|
|
13
|
+
|
|
14
|
+
export function registerInfoHttpRoute(api: PluginApi) {
|
|
15
|
+
api.registerHttpRoute({
|
|
16
|
+
path: '/clawly/info',
|
|
17
|
+
auth: 'plugin',
|
|
18
|
+
handler: async (req: IncomingMessage, res: ServerResponse) => {
|
|
19
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`)
|
|
20
|
+
if (handleCors(req, res)) return
|
|
21
|
+
if (!guardHttpAuth(api, req, res, url)) return
|
|
22
|
+
|
|
23
|
+
sendJson(res, 200, getInfoPayload())
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
api.logger.info('http: registered /clawly/info route')
|
|
28
|
+
}
|
package/http/version.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP route for OpenClaw server version.
|
|
3
|
+
*
|
|
4
|
+
* Route: GET /clawly/version → { version: string }
|
|
5
|
+
* Auth: plugin (HMAC access token or gateway Bearer token)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {IncomingMessage, ServerResponse} from 'node:http'
|
|
9
|
+
|
|
10
|
+
import {getOpenClawEnvPromise} from '../lib/resolveOpenClawEnv'
|
|
11
|
+
import {guardHttpAuth, handleCors, sendJson} from '../lib/httpAuth'
|
|
12
|
+
import type {PluginApi} from '../types'
|
|
13
|
+
|
|
14
|
+
export function registerVersionHttpRoute(api: PluginApi) {
|
|
15
|
+
api.registerHttpRoute({
|
|
16
|
+
path: '/clawly/version',
|
|
17
|
+
auth: 'plugin',
|
|
18
|
+
handler: async (req: IncomingMessage, res: ServerResponse) => {
|
|
19
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`)
|
|
20
|
+
if (handleCors(req, res)) return
|
|
21
|
+
if (!guardHttpAuth(api, req, res, url)) return
|
|
22
|
+
|
|
23
|
+
const env = await getOpenClawEnvPromise()
|
|
24
|
+
sendJson(res, 200, {version: env.version})
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
api.logger.info('http: registered /clawly/version route')
|
|
29
|
+
}
|
package/index.ts
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
*
|
|
27
27
|
* HTTP routes:
|
|
28
28
|
* - GET /clawly/file/outbound — serve files (hash lookup first, then direct path with allowlist)
|
|
29
|
+
* - GET /clawly/version — OpenClaw server version
|
|
30
|
+
* - GET /clawly/info — plugin package version
|
|
29
31
|
*
|
|
30
32
|
* Hooks:
|
|
31
33
|
* - before_message_write — restores original /skill command in user messages (undoes gateway rewrite)
|
|
@@ -56,6 +58,8 @@ import {
|
|
|
56
58
|
registerOutboundHttpRoute,
|
|
57
59
|
registerOutboundMethods,
|
|
58
60
|
} from './http/file/outbound'
|
|
61
|
+
import {registerInfoHttpRoute} from './http/info'
|
|
62
|
+
import {registerVersionHttpRoute} from './http/version'
|
|
59
63
|
import {registerMediaUnderstanding} from './media-understanding'
|
|
60
64
|
import {registerSkillCommandRestore} from './skill-command-restore'
|
|
61
65
|
import {registerTools} from './tools'
|
|
@@ -78,6 +82,8 @@ export default {
|
|
|
78
82
|
registerOutboundHook(api)
|
|
79
83
|
registerOutboundMethods(api)
|
|
80
84
|
registerOutboundHttpRoute(api)
|
|
85
|
+
registerVersionHttpRoute(api)
|
|
86
|
+
registerInfoHttpRoute(api)
|
|
81
87
|
registerCommands(api)
|
|
82
88
|
registerTools(api)
|
|
83
89
|
registerCronHook(api)
|