@sw-market/openclaw-opencode-bridge 0.1.1 → 0.1.2
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/README.md +13 -2
- package/dist/openclaw-extension.js +8 -4
- package/openclaw.plugin.json +2 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ After install, verify plugin exists:
|
|
|
21
21
|
openclaw plugins list
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## OpenClaw Config
|
|
25
25
|
|
|
26
|
-
In `~/.openclaw/openclaw.json`,
|
|
26
|
+
In `~/.openclaw/openclaw.json`, enable plugin and set SDK adapter config:
|
|
27
27
|
|
|
28
28
|
```json
|
|
29
29
|
{
|
|
@@ -43,10 +43,21 @@ In `~/.openclaw/openclaw.json`, add plugin entry and SDK adapter config:
|
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
You can also set adapter location by environment variable:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
export OPENCODE_SDK_ADAPTER_MODULE=/abs/path/to/opencode_sdk_adapter.mjs
|
|
50
|
+
export OPENCODE_SDK_ADAPTER_EXPORT=createOpenCodeSdkAdapter
|
|
51
|
+
```
|
|
52
|
+
|
|
46
53
|
Adapter module contract:
|
|
47
54
|
- export function `createOpenCodeSdkAdapter(ctx)` or export object directly.
|
|
48
55
|
- returned object must implement `createSession(args)`.
|
|
49
56
|
|
|
57
|
+
Note:
|
|
58
|
+
- Plugin installation no longer requires `sdkAdapterModule` in config.
|
|
59
|
+
- But runtime calls will fail until adapter module is provided via config or env.
|
|
60
|
+
|
|
50
61
|
## Gateway Methods Provided
|
|
51
62
|
|
|
52
63
|
This plugin registers:
|
|
@@ -49,8 +49,11 @@ function toErrorMessage(error) {
|
|
|
49
49
|
}
|
|
50
50
|
function parseConfig(pluginConfig) {
|
|
51
51
|
const raw = pluginConfig ?? {};
|
|
52
|
-
const
|
|
53
|
-
const
|
|
52
|
+
const sdkAdapterModuleRaw = readString(raw, "sdkAdapterModule") || String(process.env.OPENCODE_SDK_ADAPTER_MODULE || "").trim();
|
|
53
|
+
const sdkAdapterModule = sdkAdapterModuleRaw || undefined;
|
|
54
|
+
const sdkAdapterExport = readString(raw, "sdkAdapterExport") ||
|
|
55
|
+
String(process.env.OPENCODE_SDK_ADAPTER_EXPORT || "").trim() ||
|
|
56
|
+
DEFAULT_ADAPTER_EXPORT;
|
|
54
57
|
const sessionTtlMs = readOptionalPositiveInt(raw, "sessionTtlMs");
|
|
55
58
|
const cleanupIntervalMs = readOptionalPositiveInt(raw, "cleanupIntervalMs");
|
|
56
59
|
const emitToAllClients = raw.emitToAllClients === true;
|
|
@@ -65,7 +68,8 @@ function parseConfig(pluginConfig) {
|
|
|
65
68
|
function resolveModuleSpecifier(api, moduleSpecifier) {
|
|
66
69
|
const raw = moduleSpecifier.trim();
|
|
67
70
|
if (!raw) {
|
|
68
|
-
throw new Error("
|
|
71
|
+
throw new Error("OpenCode SDK adapter is not configured. Set plugins.entries.openclaw-opencode-bridge.config.sdkAdapterModule " +
|
|
72
|
+
"or env OPENCODE_SDK_ADAPTER_MODULE.");
|
|
69
73
|
}
|
|
70
74
|
const looksLikePath = raw.startsWith("./") ||
|
|
71
75
|
raw.startsWith("../") ||
|
|
@@ -89,7 +93,7 @@ function isOpenCodeSdkAdapter(value) {
|
|
|
89
93
|
return typeof obj.createSession === "function";
|
|
90
94
|
}
|
|
91
95
|
async function loadSdkAdapter(api, config) {
|
|
92
|
-
const moduleSpecifier = resolveModuleSpecifier(api, config.sdkAdapterModule);
|
|
96
|
+
const moduleSpecifier = resolveModuleSpecifier(api, config.sdkAdapterModule ?? "");
|
|
93
97
|
const loaded = await import(moduleSpecifier);
|
|
94
98
|
const exported = loaded[config.sdkAdapterExport];
|
|
95
99
|
let candidate = exported;
|
package/openclaw.plugin.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"properties": {
|
|
9
9
|
"sdkAdapterModule": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "Node module specifier or path to SDK adapter module"
|
|
11
|
+
"description": "Node module specifier or path to SDK adapter module (optional if OPENCODE_SDK_ADAPTER_MODULE is set)"
|
|
12
12
|
},
|
|
13
13
|
"sdkAdapterExport": {
|
|
14
14
|
"type": "string",
|
|
@@ -26,10 +26,7 @@
|
|
|
26
26
|
"type": "boolean",
|
|
27
27
|
"description": "Broadcast events to all gateway clients instead of only requester"
|
|
28
28
|
}
|
|
29
|
-
}
|
|
30
|
-
"required": [
|
|
31
|
-
"sdkAdapterModule"
|
|
32
|
-
]
|
|
29
|
+
}
|
|
33
30
|
},
|
|
34
31
|
"uiHints": {
|
|
35
32
|
"sdkAdapterModule": {
|
package/package.json
CHANGED