@unagents/messenger-broker 0.11.0 → 0.12.0
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/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'listhen';
|
|
2
2
|
import 'h3';
|
|
3
3
|
import '@unagents/messenger-protocol';
|
|
4
|
-
export { D as DEFAULT_STATE_FILE, F as FALLBACK_ENV, a as FALLBACK_INTERVAL_ENV, M as MESH_ENV, S as STATE_DIR, V as VERSION, c as configFromEnv, r as resolveConfig, s as startBroker } from './shared/messenger-broker.
|
|
4
|
+
export { D as DEFAULT_STATE_FILE, F as FALLBACK_ENV, a as FALLBACK_INTERVAL_ENV, M as MESH_ENV, S as STATE_DIR, V as VERSION, c as configFromEnv, r as resolveConfig, s as startBroker } from './shared/messenger-broker.Rw_ZTtUy.mjs';
|
|
5
5
|
import 'node:os';
|
|
6
6
|
import 'node:path';
|
|
7
7
|
import 'defu';
|
package/dist/main.mjs
CHANGED
|
@@ -226,6 +226,8 @@ function compareVersions(a, b) {
|
|
|
226
226
|
const PENDING_RELAY_TTL_MS = 60 * 60 * 1e3;
|
|
227
227
|
const DEFAULT_MESH_PEER_TTL_MS = 3e5;
|
|
228
228
|
const MESH_KEY_MEMORY = 2e3;
|
|
229
|
+
class BadRequestError extends Error {
|
|
230
|
+
}
|
|
229
231
|
class BrokerHandlers {
|
|
230
232
|
constructor(state, opts = {}) {
|
|
231
233
|
this.state = state;
|
|
@@ -427,6 +429,9 @@ class BrokerHandlers {
|
|
|
427
429
|
return list.map(({ origin: _origin, ...p }) => p);
|
|
428
430
|
}
|
|
429
431
|
sendMessage(body) {
|
|
432
|
+
const rawText = body.text;
|
|
433
|
+
if (rawText !== void 0 && typeof rawText !== "string") throw new BadRequestError("invalid text: expected a string");
|
|
434
|
+
if (body.mode !== "ping" && (rawText === void 0 || rawText === "")) throw new BadRequestError("invalid text: expected a non-empty string");
|
|
430
435
|
const resolved = this.resolvePeer(body.to);
|
|
431
436
|
if (resolved.error !== void 0) return { ok: false, error: resolved.error };
|
|
432
437
|
const { peer } = resolved;
|
|
@@ -967,7 +972,7 @@ function createBrokerApp(opts) {
|
|
|
967
972
|
try {
|
|
968
973
|
return run(await readJson(event));
|
|
969
974
|
} catch (e) {
|
|
970
|
-
setResponseStatus(event, 500);
|
|
975
|
+
setResponseStatus(event, e instanceof BadRequestError ? 400 : 500);
|
|
971
976
|
return { error: e.message };
|
|
972
977
|
}
|
|
973
978
|
}));
|
|
@@ -1191,7 +1196,7 @@ async function relayUndelivered(state, url, token) {
|
|
|
1191
1196
|
return { sent, dropped };
|
|
1192
1197
|
}
|
|
1193
1198
|
|
|
1194
|
-
const version = "0.
|
|
1199
|
+
const version = "0.12.0";
|
|
1195
1200
|
const pkg = {
|
|
1196
1201
|
version: version};
|
|
1197
1202
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unagents/messenger-broker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "agent-messenger broker: HTTP daemon that tracks peers and routes messages between Claude Code sessions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "vitest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@unagents/messenger-protocol": "0.
|
|
31
|
+
"@unagents/messenger-protocol": "0.12.0",
|
|
32
32
|
"consola": "^3.4.2",
|
|
33
33
|
"defu": "^6.1.7",
|
|
34
34
|
"h3": "^1.15.11",
|