@coclaw/openclaw-coclaw 0.1.3 → 0.1.5
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/index.js
CHANGED
|
@@ -117,8 +117,8 @@ const plugin = {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
try {
|
|
120
|
-
const serverUrl = options.server ?? api.pluginConfig?.serverUrl;
|
|
121
120
|
if (action === 'bind') {
|
|
121
|
+
const serverUrl = options.server ?? api.pluginConfig?.serverUrl;
|
|
122
122
|
const result = await bindBot({
|
|
123
123
|
code: positionals[0],
|
|
124
124
|
serverUrl,
|
|
@@ -128,7 +128,7 @@ const plugin = {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
if (action === 'unbind') {
|
|
131
|
-
const result = await unbindBot({ serverUrl });
|
|
131
|
+
const result = await unbindBot({ serverUrl: options.server });
|
|
132
132
|
await stopRealtimeBridge();
|
|
133
133
|
return { text: unbindOk(result) };
|
|
134
134
|
}
|
package/package.json
CHANGED
package/src/cli-registrar.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
function resolveServerUrl(opts, config) {
|
|
10
10
|
return opts?.server
|
|
11
|
-
?? config?.plugins?.entries?.['coclaw']?.config?.serverUrl
|
|
11
|
+
?? config?.plugins?.entries?.['openclaw-coclaw']?.config?.serverUrl
|
|
12
12
|
?? process.env.COCLAW_SERVER_URL;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -69,8 +69,7 @@ export function registerCoclawCli({ program, config, logger }, deps = {}) {
|
|
|
69
69
|
.option('--server <url>', 'CoClaw server URL')
|
|
70
70
|
.action(async (opts) => {
|
|
71
71
|
try {
|
|
72
|
-
const
|
|
73
|
-
const result = await unbindBot({ serverUrl });
|
|
72
|
+
const result = await unbindBot({ serverUrl: opts?.server });
|
|
74
73
|
/* c8 ignore next */
|
|
75
74
|
console.log(unbindOk(result));
|
|
76
75
|
await notifyGateway('coclaw.stopBridge');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bindWithServer, unbindWithServer } from '../api.js';
|
|
2
2
|
import { clearConfig, readConfig, writeConfig } from '../config.js';
|
|
3
3
|
|
|
4
|
-
const DEFAULT_SERVER_URL = '
|
|
4
|
+
const DEFAULT_SERVER_URL = 'https://im.coclaw.net';
|
|
5
5
|
|
|
6
6
|
export async function bindBot({ code, serverUrl }) {
|
|
7
7
|
if (!code) {
|
|
@@ -50,8 +50,10 @@ export async function unbindBot({ serverUrl }) {
|
|
|
50
50
|
throw err;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const baseUrl = serverUrl ?? config.serverUrl;
|
|
54
|
+
if (!baseUrl) {
|
|
55
|
+
throw new Error('cannot determine server URL for unbind: missing in bindings config');
|
|
56
|
+
}
|
|
55
57
|
let data = null;
|
|
56
58
|
let alreadyServerUnbound = false;
|
|
57
59
|
try {
|
package/src/realtime-bridge.js
CHANGED
|
@@ -6,7 +6,6 @@ import nodePath from 'node:path';
|
|
|
6
6
|
import { clearConfig, getBindingsPath, readConfig } from './config.js';
|
|
7
7
|
import { getRuntime } from './runtime.js';
|
|
8
8
|
|
|
9
|
-
const DEFAULT_SERVER_URL = 'http://127.0.0.1:3000';
|
|
10
9
|
const DEFAULT_GATEWAY_WS_URL = 'ws://127.0.0.1:18789';
|
|
11
10
|
const RECONNECT_MS = 10_000;
|
|
12
11
|
const CONNECT_TIMEOUT_MS = 10_000;
|
|
@@ -410,7 +409,11 @@ async function connectIfNeeded() {
|
|
|
410
409
|
return;
|
|
411
410
|
}
|
|
412
411
|
|
|
413
|
-
const baseUrl =
|
|
412
|
+
const baseUrl = cfg.serverUrl;
|
|
413
|
+
if (!baseUrl) {
|
|
414
|
+
currentLogger.warn?.(`[coclaw] realtime bridge skip connect: missing serverUrl in ${bindingsPath}`);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
414
417
|
const target = toServerWsUrl(baseUrl, cfg.token);
|
|
415
418
|
const WebSocketCtor = globalThis.WebSocket;
|
|
416
419
|
if (!WebSocketCtor) {
|
|
@@ -264,7 +264,9 @@ export function createSessionManager(options = {}) {
|
|
|
264
264
|
const limit = clamp(params.limit, 1, 500, 100);
|
|
265
265
|
const cursor = clamp(params.cursor, 0, Number.MAX_SAFE_INTEGER, 0);
|
|
266
266
|
const file = resolveTranscriptFile(agentId, sessionId);
|
|
267
|
-
if (!file)
|
|
267
|
+
if (!file) {
|
|
268
|
+
return { agentId, sessionId, total: 0, cursor: String(cursor), nextCursor: null, messages: [] };
|
|
269
|
+
}
|
|
268
270
|
|
|
269
271
|
const all = [];
|
|
270
272
|
for (const line of fs.readFileSync(file, 'utf8').split(/\r?\n/).filter(Boolean)) {
|