@anusornneal/chat-relay 1.1.0 โ 1.2.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/agent/local-agent.mjs +4 -0
- package/cli/relay-health.mjs +14 -9
- package/cli/tui.mjs +45 -4
- package/package.json +2 -1
package/agent/local-agent.mjs
CHANGED
|
@@ -484,6 +484,10 @@ function connect() {
|
|
|
484
484
|
}
|
|
485
485
|
return;
|
|
486
486
|
}
|
|
487
|
+
if (message?.control === "learn_activity") {
|
|
488
|
+
emitUi("learn", { change: message.change && typeof message.change === "object" ? message.change : {} });
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
487
491
|
if (message?.control === "credential_revoked") {
|
|
488
492
|
requireReauthorization("credential_revoked");
|
|
489
493
|
return;
|
package/cli/relay-health.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const RELAY_HEALTH_CHECK_INTERVAL_MS =
|
|
1
|
+
export const RELAY_HEALTH_CHECK_INTERVAL_MS = 15 * 60 * 1000;
|
|
2
2
|
export const RELAY_HEALTH_CHECK_TIMEOUT_MS = 8 * 1000;
|
|
3
3
|
export const RELAY_HEALTH_LIMITED_INTERVAL_MS = 60 * 60 * 1000;
|
|
4
4
|
export const RELAY_HEALTH_CLOUDFLARE_ERROR_INTERVAL_MS = 15 * 60 * 1000;
|
|
@@ -64,16 +64,20 @@ function classifyResponse(response, body) {
|
|
|
64
64
|
|
|
65
65
|
try {
|
|
66
66
|
const health = JSON.parse(body);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const features = health?.features && typeof health.features === "object"
|
|
68
|
+
? { learn: health.features.learn === true }
|
|
69
|
+
: null;
|
|
70
|
+
const withFeatures = (value) => features ? { ...value, features } : value;
|
|
71
|
+
if (health?.error === "relay_unavailable") return withFeatures({ state: "unavailable", reason: "relay_unavailable" });
|
|
72
|
+
if (!response.ok) return withFeatures({ state: "unavailable", code: response.status });
|
|
73
|
+
if (health?.reauthorizationRequired === true) return withFeatures({ state: "reauthorize" });
|
|
70
74
|
if (health?.authorized === false) {
|
|
71
|
-
return health?.enabled === false
|
|
75
|
+
return withFeatures(health?.enabled === false
|
|
72
76
|
? { state: "agent-disabled" }
|
|
73
|
-
: { state: "agent-access" };
|
|
77
|
+
: { state: "agent-access" });
|
|
74
78
|
}
|
|
75
|
-
if (health?.online === true) return { state: "reachable" };
|
|
76
|
-
if (health?.online === false) return { state: "unavailable", reason: "agent_offline" };
|
|
79
|
+
if (health?.online === true) return withFeatures({ state: "reachable" });
|
|
80
|
+
if (health?.online === false) return withFeatures({ state: "unavailable", reason: "agent_offline" });
|
|
77
81
|
} catch {}
|
|
78
82
|
if (!response.ok) return { state: "unavailable", code: response.status };
|
|
79
83
|
return { state: "unavailable", code: response.status };
|
|
@@ -97,6 +101,7 @@ export async function checkRelayHealth(relayUrl, {
|
|
|
97
101
|
healthUrl.pathname = `${healthUrl.pathname.replace(/\/+$/, "")}/status`;
|
|
98
102
|
healthUrl.search = "";
|
|
99
103
|
if (agentId) healthUrl.searchParams.set("agentId", String(agentId));
|
|
104
|
+
healthUrl.searchParams.set("compact", "1");
|
|
100
105
|
healthUrl.hash = "";
|
|
101
106
|
} catch {
|
|
102
107
|
return { state: "unavailable" };
|
|
@@ -131,7 +136,7 @@ export async function checkRelayHealth(relayUrl, {
|
|
|
131
136
|
|
|
132
137
|
export function startRelayHealthMonitor(relayUrl, {
|
|
133
138
|
onStatus,
|
|
134
|
-
// Per active TUI, this adds
|
|
139
|
+
// Per active TUI, this adds 96 Worker requests and up to 288 DO fetches daily.
|
|
135
140
|
intervalMs = RELAY_HEALTH_CHECK_INTERVAL_MS,
|
|
136
141
|
...checkOptions
|
|
137
142
|
} = {}) {
|
package/cli/tui.mjs
CHANGED
|
@@ -119,6 +119,24 @@ function combinedStatusStyle(status, relayHealth) {
|
|
|
119
119
|
: STYLE.red;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
function learnStatusText(value) {
|
|
123
|
+
if (value === true) return "enabled";
|
|
124
|
+
if (value === false) return "disabled";
|
|
125
|
+
return "checking";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function learnStatusStyle(value) {
|
|
129
|
+
if (value === true) return STYLE.green;
|
|
130
|
+
if (value === false) return STYLE.red;
|
|
131
|
+
return STYLE.yellow;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function compactLearnStatus(value) {
|
|
135
|
+
if (value === true) return "on";
|
|
136
|
+
if (value === false) return "off";
|
|
137
|
+
return "checking";
|
|
138
|
+
}
|
|
139
|
+
|
|
122
140
|
export function formatTwoColumnHeader(state, width = 110, { color = false } = {}) {
|
|
123
141
|
const usable = clamp(Number(width) || 110, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH);
|
|
124
142
|
const leftWidth = Math.floor((usable - GAP) / 2);
|
|
@@ -128,7 +146,7 @@ export function formatTwoColumnHeader(state, width = 110, { color = false } = {}
|
|
|
128
146
|
["Status", combinedStatusText(state.status, state.relayHealth), "Relay", state.relay || "-"],
|
|
129
147
|
["Root", state.root || "-", "Reconnects", String(state.reconnects ?? 0)],
|
|
130
148
|
["Session up", formatUptime(state.uptimeMs), "Terminal", state.terminal ? "enabled" : "disabled"],
|
|
131
|
-
["Desktop", state.desktop ? "enabled" : "disabled", "Learn", state.learn
|
|
149
|
+
["Desktop", state.desktop ? "enabled" : "disabled", "Learn", learnStatusText(state.learn)],
|
|
132
150
|
];
|
|
133
151
|
return rows
|
|
134
152
|
.map(([leftLabel, leftValue, rightLabel, rightValue]) => {
|
|
@@ -138,7 +156,7 @@ export function formatTwoColumnHeader(state, width = 110, { color = false } = {}
|
|
|
138
156
|
const rightStyle = rightLabel === "Reconnects" && Number(state.reconnects || 0) > 0
|
|
139
157
|
? STYLE.yellow
|
|
140
158
|
: rightLabel === "Learn"
|
|
141
|
-
? (state.learn
|
|
159
|
+
? learnStatusStyle(state.learn)
|
|
142
160
|
: null;
|
|
143
161
|
return field(leftLabel, leftValue, leftWidth, color, leftStyle)
|
|
144
162
|
+ " ".repeat(GAP)
|
|
@@ -292,7 +310,7 @@ export class RemoteTui {
|
|
|
292
310
|
reconnects: 0,
|
|
293
311
|
terminal: config.terminalEnabled !== false,
|
|
294
312
|
desktop: config.desktopEnabled === true,
|
|
295
|
-
learn:
|
|
313
|
+
learn: null,
|
|
296
314
|
};
|
|
297
315
|
this.version = version || "-";
|
|
298
316
|
this.colorEnabled = shouldUseColor(output, env);
|
|
@@ -455,6 +473,24 @@ export class RemoteTui {
|
|
|
455
473
|
item.durationMs = message.durationMs;
|
|
456
474
|
if (message.error && message.ok === false) item.summary += ` ยท ${truncate(message.error, 48)}`;
|
|
457
475
|
}
|
|
476
|
+
} else if (message.event === "learn") {
|
|
477
|
+
const change = message.change && typeof message.change === "object" ? message.change : {};
|
|
478
|
+
const marker = {
|
|
479
|
+
created: "+",
|
|
480
|
+
updated: "~",
|
|
481
|
+
reinforced: "^",
|
|
482
|
+
weakened: "v",
|
|
483
|
+
removed: "-",
|
|
484
|
+
}[String(change.type || "")] || "~";
|
|
485
|
+
const detail = String(change.summary || change.key || "Learn updated").replace(/\s+/g, " ").trim();
|
|
486
|
+
this.appendTransaction({
|
|
487
|
+
requestId: "learn-" + String(change.eventId || Date.now()),
|
|
488
|
+
at: change.at || message.at || new Date().toISOString(),
|
|
489
|
+
action: "learn",
|
|
490
|
+
summary: "Learn " + marker + " " + truncate(detail, 120),
|
|
491
|
+
status: "done",
|
|
492
|
+
ok: true,
|
|
493
|
+
});
|
|
458
494
|
} else if (message.event === "system") {
|
|
459
495
|
this.appendTransaction({
|
|
460
496
|
requestId: "system-" + Date.now() + "-" + Math.random(),
|
|
@@ -473,6 +509,11 @@ export class RemoteTui {
|
|
|
473
509
|
...(health && typeof health === "object" ? health : { state: "unavailable" }),
|
|
474
510
|
checkedAt: Date.now(),
|
|
475
511
|
};
|
|
512
|
+
if (health?.features && Object.prototype.hasOwnProperty.call(health.features, "learn")) {
|
|
513
|
+
this.state.learn = health.features.learn === true;
|
|
514
|
+
} else if (health?.state === "reachable") {
|
|
515
|
+
this.state.learn = false;
|
|
516
|
+
}
|
|
476
517
|
this.scheduleRender();
|
|
477
518
|
}
|
|
478
519
|
|
|
@@ -497,7 +538,7 @@ export class RemoteTui {
|
|
|
497
538
|
if (width < MIN_FRAME_WIDTH) {
|
|
498
539
|
const compactHeader = [
|
|
499
540
|
truncateCells(`๐ค ${headerState.account || "-"} ยท ๐ป ${headerState.agent || "-"}`, width),
|
|
500
|
-
truncateCells(`๐ ${combinedStatusText(headerState.status, headerState.relayHealth)} ยท ๐ง Learn ${headerState.learn
|
|
541
|
+
truncateCells(`๐ ${combinedStatusText(headerState.status, headerState.relayHealth)} ยท ๐ง Learn ${compactLearnStatus(headerState.learn)} ยท ๐ ${headerState.root || "-"}`, width),
|
|
501
542
|
];
|
|
502
543
|
headerLines = compactHeader.map((line) => this.colorEnabled ? paint(line, STYLE.gray) : line);
|
|
503
544
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anusornneal/chat-relay",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Zero-checkout remote MCP agent for ChatGPT with terminal, filesystem, process, multi-user, and multi-agent support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
68
68
|
"agents": "^0.24.0",
|
|
69
|
+
"esbuild": "^0.28.1",
|
|
69
70
|
"wrangler": "^4.143.0",
|
|
70
71
|
"zod": "^4.6.5"
|
|
71
72
|
},
|