@anusornneal/chat-relay 0.13.0 → 1.1.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/README.md +55 -0
- package/agent/toolcall-summary.mjs +1 -3
- package/cli/tui.mjs +25 -55
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Remote MCP relay that lets ChatGPT work with a local Windows or macOS machine th
|
|
|
4
4
|
|
|
5
5
|
**Dashboard:** https://chat-relay.anusorn-hank.workers.dev/
|
|
6
6
|
|
|
7
|
+
**Release status:** v1.0 stable for internal use. Windows and macOS local agents are supported; Linux desktop control is not currently implemented. Post-1.0 fixes and operational hardening are shipped as normal patch releases.
|
|
8
|
+
|
|
7
9
|
## Quick start
|
|
8
10
|
|
|
9
11
|
There are two parts:
|
|
@@ -203,3 +205,56 @@ Optional Cloudflare-pressure circuit breakers can be configured with `USAGE_RECO
|
|
|
203
205
|
- Public plugin/reviewer flow: `docs/plugin-review.md`
|
|
204
206
|
- Google sign-in setup: `docs/google-login.md`
|
|
205
207
|
- Source: https://github.com/anusornNeal/chat-relay
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## Account-scoped Learn
|
|
211
|
+
|
|
212
|
+
Chat Relay can persist small, structured pieces of execution context per authenticated account. Learn is **not model training** and it does not capture conversations or tool payloads automatically.
|
|
213
|
+
|
|
214
|
+
The MCP surface is:
|
|
215
|
+
|
|
216
|
+
- `learn_get` reads explicit memories for selected scopes.
|
|
217
|
+
- `learn_put` creates or updates one memory.
|
|
218
|
+
- `learn_delete` removes one memory.
|
|
219
|
+
- `learn_feedback` records positive or negative feedback on one memory.
|
|
220
|
+
|
|
221
|
+
Memories are partitioned by authenticated account using a dedicated Learning Durable Object selected from the server-side `user.id`. Callers cannot provide or override an account id. Supported scopes are `global`, `project`, and `agent`; project and agent memories require a scope key.
|
|
222
|
+
|
|
223
|
+
The first version is intentionally lightweight: there are no embeddings, vector database, local LLM, transcript ingestion, or per-tool-call writes. A normal tool call causes no Learn storage write. Storage changes happen only when an explicit Learn mutation is requested. Each account is capped at 512 memories, each memory content field is capped at 4,000 characters, and reads return at most 100 records. Do not store credentials, tokens, secrets, raw tool payloads, terminal output, file contents, or screenshots in Learn.
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## Progressive Learn bootstrap and routing
|
|
227
|
+
|
|
228
|
+
Learn context is loaded progressively so a fresh ChatGPT conversation does not need to remember to call `learn_get` before using Relay.
|
|
229
|
+
|
|
230
|
+
```mermaid
|
|
231
|
+
flowchart TD
|
|
232
|
+
U[User starts or continues a chat] --> M[ChatGPT calls Relay]
|
|
233
|
+
M --> A[Authenticate account]
|
|
234
|
+
A --> G{Global context loaded in this MCP session?}
|
|
235
|
+
G -- No --> LG[Read global Learn once]
|
|
236
|
+
G -- Yes --> S[Continue]
|
|
237
|
+
LG --> S
|
|
238
|
+
S --> P{Concrete project signal? path / cwd / repo}
|
|
239
|
+
P -- Yes --> PR[Match explicit project-root hint]
|
|
240
|
+
PR --> LP[Read project Learn once]
|
|
241
|
+
P -- No --> AG
|
|
242
|
+
LP --> AG
|
|
243
|
+
AG{Agent selected or safely resolved?}
|
|
244
|
+
AG -- Yes --> LA[Read agent Learn once]
|
|
245
|
+
AG -- No --> E
|
|
246
|
+
LA --> E
|
|
247
|
+
E[Attach bounded learnedContext envelope] --> R[ChatGPT chooses action and tool]
|
|
248
|
+
R --> SEC[Relay enforces auth, grants, allowedRoots and capabilities]
|
|
249
|
+
SEC --> X[Execute]
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The decision boundary is deliberate:
|
|
253
|
+
|
|
254
|
+
- **Relay decides mechanical routing only:** authenticated account, whether a scope was already loaded, project identity from explicit `project-root:<projectKey>` memories, explicit/resolved agent, and available permissions/capabilities.
|
|
255
|
+
- **ChatGPT decides semantic actions and tools:** whether to read files, search, edit, run terminal commands, use desktop control, or re-plan after a failure.
|
|
256
|
+
- Learned hints never override authorization, grants, allowed roots, destructive-tool policy, or capability checks.
|
|
257
|
+
|
|
258
|
+
Routing hints are explicit memories. A global `project_context` memory with key `project-root:<projectKey>` stores the concrete project root. A `preferred-agent` memory may exist in project scope (preferred) or global scope (fallback); Relay surfaces it in `routingContext` as guidance and does not execute or retry a tool solely because of that hint. No project is guessed when no explicit root hint matches.
|
|
259
|
+
|
|
260
|
+
The intended read budget is bounded by an in-memory warm-cache: global context is normally read once per conversation/session, each activated project once, and each activated agent once. A Worker isolate restart/eviction may cause a scope to be read again; this is intentionally best-effort so bootstrap performs no durable session writes. Learned content is advisory user memory, not system/developer instruction authority.
|
|
@@ -249,9 +249,7 @@ export function humanizeToolCall(payload = {}) {
|
|
|
249
249
|
return `Focus window · ${cleanText(payload.title ?? payload.windowId ?? payload.handle ?? "", 64)}`;
|
|
250
250
|
case "desktop.mouse.click": {
|
|
251
251
|
const button = cleanText(payload.button || "left", 12);
|
|
252
|
-
|
|
253
|
-
const y = number(payload.y);
|
|
254
|
-
return `${button[0]?.toUpperCase() || "L"}${button.slice(1)} click · x ${x}, y ${y}`;
|
|
252
|
+
return `${button[0]?.toUpperCase() || "L"}${button.slice(1)} click`;
|
|
255
253
|
}
|
|
256
254
|
case "desktop.keyboard.input":
|
|
257
255
|
return `Type on keyboard · ${countKeyboardInput(payload)}`;
|
package/cli/tui.mjs
CHANGED
|
@@ -101,58 +101,22 @@ function field(label, value, width, color = false, valueStyle = null) {
|
|
|
101
101
|
return renderedLabel + renderedValue + " ".repeat(Math.max(0, width - plainLabel.length - plainValue.length));
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
function
|
|
105
|
-
switch (String(value || "").toLowerCase()) {
|
|
106
|
-
case "connected": return STYLE.green;
|
|
107
|
-
case "connecting":
|
|
108
|
-
case "reconnecting": return STYLE.yellow;
|
|
109
|
-
case "offline": return STYLE.red;
|
|
110
|
-
default: return STYLE.gray;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function relayHealthStyle(health) {
|
|
104
|
+
function relayIsOnline(health) {
|
|
115
105
|
const code = Number(health?.code);
|
|
116
|
-
if (Number.isFinite(code)
|
|
117
|
-
|
|
118
|
-
case "reachable": return STYLE.green;
|
|
119
|
-
case "checking": return STYLE.yellow;
|
|
120
|
-
default: return STYLE.red;
|
|
121
|
-
}
|
|
106
|
+
if (Number.isFinite(code)) return code >= 200 && code < 300;
|
|
107
|
+
return health?.state === "reachable";
|
|
122
108
|
}
|
|
123
109
|
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
case "reachable": return "● Online";
|
|
129
|
-
case "checking": return "◐ Checking";
|
|
130
|
-
case "limited":
|
|
131
|
-
return health.code === 1027
|
|
132
|
-
? "✕ Cloudflare 1027"
|
|
133
|
-
: `✕ Rate limited (${health.code || "429"})`;
|
|
134
|
-
case "cloudflare-error": return `✕ Cloudflare ${health.code || "error"}`;
|
|
135
|
-
case "unauthorized": return health.code === 403 ? "✕ Access denied" : "✕ Sign-in required";
|
|
136
|
-
case "reauthorize": return "✕ Agent reauthorization required";
|
|
137
|
-
case "agent-disabled": return "✕ Agent disabled";
|
|
138
|
-
case "agent-access": return "✕ Agent access required";
|
|
139
|
-
case "unavailable":
|
|
140
|
-
if (health.reason === "relay_unavailable") return "✕ Relay unavailable";
|
|
141
|
-
if (health.reason === "agent_offline") return "✕ Agent offline";
|
|
142
|
-
return `✕ ${health.code ? `HTTP ${health.code}` : "Unavailable"}`;
|
|
143
|
-
default: return "? Unknown";
|
|
144
|
-
}
|
|
110
|
+
function combinedStatusText(status, relayHealth) {
|
|
111
|
+
return String(status || "").toLowerCase() === "connected" && relayIsOnline(relayHealth)
|
|
112
|
+
? "● Online"
|
|
113
|
+
: "○ Offline";
|
|
145
114
|
}
|
|
146
115
|
|
|
147
|
-
function
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (ageSeconds < 10) return "just now";
|
|
152
|
-
if (ageSeconds < 60) return `${ageSeconds}s ago`;
|
|
153
|
-
const ageMinutes = Math.floor(ageSeconds / 60);
|
|
154
|
-
if (ageMinutes < 60) return `${ageMinutes}m ago`;
|
|
155
|
-
return `${Math.floor(ageMinutes / 60)}h ago`;
|
|
116
|
+
function combinedStatusStyle(status, relayHealth) {
|
|
117
|
+
return String(status || "").toLowerCase() === "connected" && relayIsOnline(relayHealth)
|
|
118
|
+
? STYLE.green
|
|
119
|
+
: STYLE.red;
|
|
156
120
|
}
|
|
157
121
|
|
|
158
122
|
export function formatTwoColumnHeader(state, width = 110, { color = false } = {}) {
|
|
@@ -161,17 +125,21 @@ export function formatTwoColumnHeader(state, width = 110, { color = false } = {}
|
|
|
161
125
|
const rightWidth = usable - GAP - leftWidth;
|
|
162
126
|
const rows = [
|
|
163
127
|
["Account", state.account || "-", "Agent", state.agent || "-"],
|
|
164
|
-
["
|
|
165
|
-
["
|
|
128
|
+
["Status", combinedStatusText(state.status, state.relayHealth), "Relay", state.relay || "-"],
|
|
129
|
+
["Root", state.root || "-", "Reconnects", String(state.reconnects ?? 0)],
|
|
166
130
|
["Session up", formatUptime(state.uptimeMs), "Terminal", state.terminal ? "enabled" : "disabled"],
|
|
167
|
-
["Desktop", state.desktop ? "enabled" : "disabled", "
|
|
131
|
+
["Desktop", state.desktop ? "enabled" : "disabled", "Learn", state.learn !== false ? "enabled" : "disabled"],
|
|
168
132
|
];
|
|
169
133
|
return rows
|
|
170
134
|
.map(([leftLabel, leftValue, rightLabel, rightValue]) => {
|
|
171
|
-
const leftStyle = leftLabel === "
|
|
172
|
-
?
|
|
173
|
-
:
|
|
174
|
-
const rightStyle = rightLabel === "Reconnects" && Number(state.reconnects || 0) > 0
|
|
135
|
+
const leftStyle = leftLabel === "Status"
|
|
136
|
+
? combinedStatusStyle(state.status, state.relayHealth)
|
|
137
|
+
: null;
|
|
138
|
+
const rightStyle = rightLabel === "Reconnects" && Number(state.reconnects || 0) > 0
|
|
139
|
+
? STYLE.yellow
|
|
140
|
+
: rightLabel === "Learn"
|
|
141
|
+
? (state.learn !== false ? STYLE.green : STYLE.red)
|
|
142
|
+
: null;
|
|
175
143
|
return field(leftLabel, leftValue, leftWidth, color, leftStyle)
|
|
176
144
|
+ " ".repeat(GAP)
|
|
177
145
|
+ field(rightLabel, rightValue, rightWidth, color, rightStyle).trimEnd();
|
|
@@ -318,11 +286,13 @@ export class RemoteTui {
|
|
|
318
286
|
account: config.user?.name || config.user?.login || "signed in",
|
|
319
287
|
agent: config.agentName || config.agentId || "-",
|
|
320
288
|
relay: normalizeRelay(config.relayUrl),
|
|
289
|
+
root: config.allowedRoots || "-",
|
|
321
290
|
status: "starting",
|
|
322
291
|
relayHealth: { state: "checking" },
|
|
323
292
|
reconnects: 0,
|
|
324
293
|
terminal: config.terminalEnabled !== false,
|
|
325
294
|
desktop: config.desktopEnabled === true,
|
|
295
|
+
learn: config.learnEnabled !== false,
|
|
326
296
|
};
|
|
327
297
|
this.version = version || "-";
|
|
328
298
|
this.colorEnabled = shouldUseColor(output, env);
|
|
@@ -527,7 +497,7 @@ export class RemoteTui {
|
|
|
527
497
|
if (width < MIN_FRAME_WIDTH) {
|
|
528
498
|
const compactHeader = [
|
|
529
499
|
truncateCells(`👤 ${headerState.account || "-"} · 💻 ${headerState.agent || "-"}`, width),
|
|
530
|
-
truncateCells(`🔗 ${
|
|
500
|
+
truncateCells(`🔗 ${combinedStatusText(headerState.status, headerState.relayHealth)} · 🧠 Learn ${headerState.learn !== false ? "on" : "off"} · 📁 ${headerState.root || "-"}`, width),
|
|
531
501
|
];
|
|
532
502
|
headerLines = compactHeader.map((line) => this.colorEnabled ? paint(line, STYLE.gray) : line);
|
|
533
503
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anusornneal/chat-relay",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.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": {
|
|
@@ -55,8 +55,10 @@
|
|
|
55
55
|
"test:self-update": "node --test test/self-update.test.mjs test/agent-lifecycle-upgrade.test.mjs",
|
|
56
56
|
"test:budget": "node --test test/relay-health.test.mjs test/usage-budget.test.mjs",
|
|
57
57
|
"test:soak": "node test/soak-smoke.mjs",
|
|
58
|
-
"test:hardening": "npm run test:tui && npm run test:config-security && npm run test:self-update && npm run test:budget && node --test test/connection-generation.test.mjs && npm run test:agent-state && node test/heartbeat-ack-watchdog.test.mjs && npm run test:usage-storage && npm run test:soak",
|
|
59
|
-
"verify:review": "node scripts/verify-review-artifacts.mjs"
|
|
58
|
+
"test:hardening": "npm run test:tui && npm run test:config-security && npm run test:self-update && npm run test:budget && node --test test/connection-generation.test.mjs && npm run test:agent-state && node test/heartbeat-ack-watchdog.test.mjs && npm run test:usage-storage && npm run test:learn && npm run test:learn-bootstrap && npm run test:soak",
|
|
59
|
+
"verify:review": "node scripts/verify-review-artifacts.mjs",
|
|
60
|
+
"test:learn": "node test/learning-smoke.mjs",
|
|
61
|
+
"test:learn-bootstrap": "node test/learning-bootstrap-smoke.mjs"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
64
|
"ws": "^8.22.0"
|