@anusornneal/chat-relay 1.3.2 → 1.3.4
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 +22 -1
- package/agent/connection-state.mjs +4 -2
- package/agent/local-agent.mjs +19 -1
- package/agent/toolcall-context.mjs +220 -0
- package/cli/demo.mjs +194 -0
- package/cli/device-login.mjs +7 -1
- package/cli/index.mjs +15 -2
- package/cli/remote.mjs +2 -2
- package/cli/tui.mjs +254 -62
- package/package.json +13 -8
package/README.md
CHANGED
|
@@ -4,6 +4,12 @@ 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
|
+
**Learn Baseline:** See [scope, writing format, and safe agent environment guidance](docs/learn-baseline.md).
|
|
8
|
+
|
|
9
|
+
**Learn Usage Ranking:** See [receipt semantics, scoring and Cloudflare resource cost](docs/learn-usage-ranking.md).
|
|
10
|
+
|
|
11
|
+
**Shared Learn Groups:** See [group setup, roles, approval flow and resource limits](docs/shared-learn.md).
|
|
12
|
+
|
|
7
13
|
**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
14
|
|
|
9
15
|
## Quick start
|
|
@@ -57,6 +63,18 @@ Limit filesystem access to a specific root:
|
|
|
57
63
|
npx @anusornneal/chat-relay@latest remote --root "C:\Users\you\Projects"
|
|
58
64
|
```
|
|
59
65
|
|
|
66
|
+
## Self-hosting on your own Cloudflare account
|
|
67
|
+
|
|
68
|
+
A Git clone includes source and deployment templates, not Cloudflare resources, accounts, secrets, or existing data. The default `wrangler.jsonc` contains no production URL or Google OAuth client ID.
|
|
69
|
+
|
|
70
|
+
1. Create your own Cloudflare account and Google OAuth Web application. Register `https://YOUR-WORKER.workers.dev/admin/google/callback` as an authorized redirect URI.
|
|
71
|
+
2. Copy `wrangler.selfhost.example.jsonc` to `wrangler.selfhost.jsonc`, and update `PUBLIC_BASE_URL`, `GOOGLE_CLIENT_ID` and Worker name.
|
|
72
|
+
3. Supply Worker secrets using `npx wrangler secret put SECRET_NAME --config wrangler.selfhost.jsonc` for `ADMIN_TOKEN`, `AGENT_TOKEN`, `CALLER_TOKEN`, and `GOOGLE_CLIENT_SECRET`. Never commit values.
|
|
73
|
+
4. Run `npm run deploy:selfhost`. Missing values or the original hosted production URL are rejected.
|
|
74
|
+
5. Connect ChatGPT to `https://YOUR-WORKER.workers.dev/mcp`, then connect an agent using `npx @anusornneal/chat-relay@latest remote --relay https://YOUR-WORKER.workers.dev`.
|
|
75
|
+
|
|
76
|
+
The CLI's no-argument mode remains connected to the hosted service for existing users. Setting `--relay` explicitly changes the target (and triggers sign-in if it differs). Administrative scripts require `RELAY_URL` to be explicitly configured. The hosted production deployment uses `wrangler.production.jsonc` and is only enabled through an explicit CI deployment flag.
|
|
77
|
+
|
|
60
78
|
## `npx` commands
|
|
61
79
|
|
|
62
80
|
| Command | What it does |
|
|
@@ -152,6 +170,8 @@ A single account can own multiple computers. Each computer keeps its own agent i
|
|
|
152
170
|
|
|
153
171
|
Clone the repository only when developing Chat Relay itself. Normal users should use the zero-checkout `npx` flow above.
|
|
154
172
|
|
|
173
|
+
Agents must create new WIP backups or Git worktrees only when necessary and only inside the **owning target project's** `workspace/` folder (e.g. `chat-relay/workspace/worktrees/<id>`). Do not create sibling project folders. See [Project workspace policy](docs/PROJECT_WORKSPACE_POLICY.md) and `AGENTS.md`; existing legacy folders remain untouched until verified cleanup.
|
|
174
|
+
|
|
155
175
|
Common development commands:
|
|
156
176
|
|
|
157
177
|
```bash
|
|
@@ -217,6 +237,7 @@ The MCP surface is:
|
|
|
217
237
|
- `learn_get` reads raw memories for selected scopes when targeted inspection is needed.
|
|
218
238
|
- `learn_put` creates or updates one durable memory when Chat decides a reusable signal is worth keeping.
|
|
219
239
|
- `learn_delete` removes one memory.
|
|
240
|
+
- `learn_merge_projects` supports direct chat project merging without desktop control. Call `action=preview` with `from` and `to` first; show counts/conflicting keys and obtain explicit user confirmation before `action=commit` with `confirmed=true` and the one-use `confirmationToken`. Previews expire after 10 minutes or when source/target memory metadata changes. Merges use the existing account-scoped transactional backend, preserve IDs and feedback, and permanently alias the source name. The tool never merges based on similar names automatically.
|
|
220
241
|
- `learn_feedback` records positive or negative feedback on one memory.
|
|
221
242
|
|
|
222
243
|
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.
|
|
@@ -251,6 +272,6 @@ The decision boundary is deliberate:
|
|
|
251
272
|
- **Ordinary tools stay hot-path clean:** `ping_agent`, file tools, terminal tools, desktop tools, and other MCP calls do not automatically read, rank, inject, or write Learn.
|
|
252
273
|
- Learned hints remain advisory and never override authorization, grants, allowed roots, destructive-tool policy, capability checks, safety, or the current user request.
|
|
253
274
|
|
|
254
|
-
|
|
275
|
+
Project aliases are account-scoped mappings stored in the Learning Durable Object. Use **My Learn → Merge projects** to join workspace names (for example `buddy-android` → `buddy2`) once, while retaining memory IDs, feedback, and timestamps; the source becomes a permanent alias for future Learn reads/writes across machines. Aliases are never inferred from similar names, and project resolution occurs only during Learn requests—not on ordinary tool calls. Merges run transactionally; conflicting keys with distinct content are renamed instead of discarded.\n\nRouting 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). `learn_prepare` can also take explicit `projectKey` and `agentId` values when Chat already knows them.
|
|
255
276
|
|
|
256
277
|
`learn_prepare` is intentionally one-shot and stateless at the Worker level. There is no warm session cache or durable Learn session state to maintain. This prevents Learn from becoming an implicit per-tool CPU/subrequest tax while still allowing relevance-aware context preparation when it is actually useful.
|
|
@@ -29,7 +29,9 @@ export function classifySocketDisconnect(code, reason, socketError = null) {
|
|
|
29
29
|
if (code === 4001 || reason === "credential_revoked" || reason === "credential_rejected") return "authorization";
|
|
30
30
|
if (code === 4002 || reason === "protocol_incompatible") return "protocol";
|
|
31
31
|
if (reason?.startsWith("unexpected_response_")) return "handshake";
|
|
32
|
-
if (["transport_pong_timeout", "heartbeat_ack_timeout"].includes(socketError)) return "timeout";
|
|
32
|
+
if (["transport_pong_timeout", "heartbeat_ack_timeout", "ETIMEDOUT"].includes(socketError)) return "timeout";
|
|
33
|
+
if (socketError === "ENOTFOUND") return "dns";
|
|
34
|
+
if (["ECONNRESET", "ECONNREFUSED", "EPIPE"].includes(socketError)) return "network";
|
|
33
35
|
if (code === 1006) return "abnormal_transport";
|
|
34
36
|
if (code === 1012 || reason === "restart_requested" || reason === "upgrade_requested") return "restart";
|
|
35
37
|
if (code === 1000 || code === 1001) return "normal";
|
|
@@ -45,7 +47,7 @@ export function computeReconnectDelay(attempt, options = {}) {
|
|
|
45
47
|
const raw = Math.min(maxMs, baseMs * (2 ** exponent));
|
|
46
48
|
const spread = raw * jitterRatio;
|
|
47
49
|
const sample = Math.min(Math.max(Number(random()) || 0, 0), 1);
|
|
48
|
-
return Math.max(100, Math.round(raw - spread + (spread * 2 * sample)));
|
|
50
|
+
return Math.min(maxMs, Math.max(100, Math.round(raw - spread + (spread * 2 * sample))));
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export class AgentConnectionState {
|
package/agent/local-agent.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
summarizeAgentWork,
|
|
15
15
|
} from "./lifecycle.mjs";
|
|
16
16
|
import { humanizeToolCall } from "./toolcall-summary.mjs";
|
|
17
|
+
import { describeToolActivity } from "./toolcall-context.mjs";
|
|
17
18
|
import { toolErrorGuidance } from "./tool-error-guidance.mjs";
|
|
18
19
|
import {
|
|
19
20
|
HeartbeatAckWatchdog,
|
|
@@ -83,6 +84,16 @@ const desktop = new DesktopManager({
|
|
|
83
84
|
controlQueueTimeoutMs: process.env.AGENT_QUEUE_TIMEOUT_MS,
|
|
84
85
|
});
|
|
85
86
|
const recentCalls = [];
|
|
87
|
+
// Correlate asynchronous batch/session output with the project where work began.
|
|
88
|
+
// Local only, bounded and never queried from the Worker.
|
|
89
|
+
const recentToolProjects = new Map();
|
|
90
|
+
function rememberToolProject(id, project) {
|
|
91
|
+
if (!id || !project) return;
|
|
92
|
+
const key = String(id);
|
|
93
|
+
recentToolProjects.delete(key);
|
|
94
|
+
recentToolProjects.set(key, project);
|
|
95
|
+
if (recentToolProjects.size > 96) recentToolProjects.delete(recentToolProjects.keys().next().value);
|
|
96
|
+
}
|
|
86
97
|
const RECENT_TIMING_KEYS = ["queueWaitMs", "inputMs", "explicitWaitMs", "settleMs", "captureMs", "encodeMs", "workerMs", "managerMs", "totalMs", "requestedActions", "executedActions"];
|
|
87
98
|
function recentTiming(value) {
|
|
88
99
|
if (!value || typeof value !== "object") return null;
|
|
@@ -518,8 +529,9 @@ function connect() {
|
|
|
518
529
|
? String(message.payload.action ?? "unknown")
|
|
519
530
|
: "unknown";
|
|
520
531
|
const callSummary = humanizeToolCall(message.payload);
|
|
532
|
+
const uiActivity = describeToolActivity(message.payload, files.getRoots(), recentToolProjects);
|
|
521
533
|
const requestBytes = Buffer.byteLength(JSON.stringify(message), "utf8");
|
|
522
|
-
emitUi("tool:start", { requestId: message.requestId, action, summary: callSummary, requestBytes });
|
|
534
|
+
emitUi("tool:start", { requestId: message.requestId, action, summary: callSummary, ...uiActivity, requestBytes });
|
|
523
535
|
let scheduleMeta = { lane: "unknown", queueWaitMs: 0, queueDepthAtStart: 0, activeAtStart: 0 };
|
|
524
536
|
let handlerDurationMs = 0;
|
|
525
537
|
try {
|
|
@@ -533,6 +545,12 @@ function connect() {
|
|
|
533
545
|
}
|
|
534
546
|
});
|
|
535
547
|
const timing = recentTiming(result?.timing);
|
|
548
|
+
if (result?.ok !== false) {
|
|
549
|
+
if (action === "terminal.batch.start") rememberToolProject(result?.batchId, uiActivity.project);
|
|
550
|
+
if (action === "terminal.start" || action === "terminal.shell.start" || action === "fs.search.start") {
|
|
551
|
+
rememberToolProject(result?.sessionId, uiActivity.project);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
536
554
|
recentCalls.push({
|
|
537
555
|
at: new Date().toISOString(),
|
|
538
556
|
action,
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { humanizeToolCall } from "./toolcall-summary.mjs";
|
|
3
|
+
|
|
4
|
+
// Derive concise local UI labels, not raw commands or full request payloads.
|
|
5
|
+
const WORKSPACE_DIR = /^(projects?|workspaces?|repos?|repositories|code|src)$/i;
|
|
6
|
+
|
|
7
|
+
function safeLabel(value) {
|
|
8
|
+
const text = String(value ?? "").trim();
|
|
9
|
+
if (!text || text.length > 64 || /[\u0000-\u001f\u007f/\\]/.test(text) || text === "." || text === "..") return null;
|
|
10
|
+
return text;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function normalizeLocation(value) {
|
|
14
|
+
if (typeof value !== "string" || !value.trim()) return null;
|
|
15
|
+
const raw = value.trim().replace(/\\/g, "/");
|
|
16
|
+
if (!/^(?:[a-zA-Z]:\/|\/)/.test(raw)) return null;
|
|
17
|
+
const normalized = path.posix.normalize(raw);
|
|
18
|
+
return normalized.length > 1 ? normalized.replace(/\/+$/, "") : normalized;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function samePathOrWithin(location, root) {
|
|
22
|
+
const windows = /^[A-Za-z]:\//.test(location) && /^[A-Za-z]:\//.test(root);
|
|
23
|
+
const current = windows ? location.toLowerCase() : location;
|
|
24
|
+
const boundary = windows ? root.toLowerCase() : root;
|
|
25
|
+
return current === boundary || current.startsWith(boundary + "/");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function rootsFrom(value) {
|
|
29
|
+
const inputs = Array.isArray(value) ? value : typeof value === "string" ? value.split(";") : [];
|
|
30
|
+
return inputs.map(normalizeLocation).filter(Boolean).sort((a, b) => b.length - a.length);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function pathProject(value, roots, { cwd, directory = false } = {}) {
|
|
34
|
+
let location = normalizeLocation(value);
|
|
35
|
+
if (!location && typeof value === "string" && value.trim() && cwd) {
|
|
36
|
+
const base = normalizeLocation(cwd);
|
|
37
|
+
if (base) location = normalizeLocation(path.posix.join(base, value.replace(/\\/g, "/")));
|
|
38
|
+
}
|
|
39
|
+
if (!location) return null;
|
|
40
|
+
for (const root of roots) {
|
|
41
|
+
if (!samePathOrWithin(location, root)) continue;
|
|
42
|
+
const relative = location.slice(root.length).replace(/^\/+/, "");
|
|
43
|
+
const segments = relative.split("/").filter(Boolean);
|
|
44
|
+
const rootName = root.split("/").filter(Boolean).at(-1) || "";
|
|
45
|
+
if (WORKSPACE_DIR.test(rootName)) {
|
|
46
|
+
// A file directly in the workspace root is not a project.
|
|
47
|
+
if (segments.length < 2 && !directory) return null;
|
|
48
|
+
return safeLabel(segments[0]);
|
|
49
|
+
}
|
|
50
|
+
// A configured root can itself be a project, e.g. ~/repo/chat-relay.
|
|
51
|
+
if (segments[0] && WORKSPACE_DIR.test(segments[0])) {
|
|
52
|
+
if (segments.length < 3 && !directory) return null;
|
|
53
|
+
return safeLabel(segments[1]);
|
|
54
|
+
}
|
|
55
|
+
return safeLabel(rootName);
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function candidatePaths(payload) {
|
|
61
|
+
const action = String(payload?.action || "");
|
|
62
|
+
if (action === "terminal.batch.start") {
|
|
63
|
+
const fallbackCwd = payload.cwd;
|
|
64
|
+
return (Array.isArray(payload.jobs) ? payload.jobs : [])
|
|
65
|
+
.map((job) => ({ value: job && typeof job === "object" ? job.cwd || fallbackCwd : fallbackCwd, directory: true }));
|
|
66
|
+
}
|
|
67
|
+
if (action.startsWith("terminal.")) {
|
|
68
|
+
if (action === "terminal.exec" || action === "terminal.start" || action === "terminal.shell.start") {
|
|
69
|
+
return [{ value: payload.cwd, directory: true }];
|
|
70
|
+
}
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
if (action === "fs.batch") {
|
|
74
|
+
return (Array.isArray(payload.operations) ? payload.operations : [])
|
|
75
|
+
.flatMap((item) => [item?.path, item?.source, item?.destination]
|
|
76
|
+
.filter((value) => typeof value === "string")
|
|
77
|
+
.map((value) => ({ value, cwd: payload.cwd, directory: item?.op === "list" })));
|
|
78
|
+
}
|
|
79
|
+
if (action === "fs.readMany") {
|
|
80
|
+
return (Array.isArray(payload.paths) ? payload.paths : [])
|
|
81
|
+
.map((item) => ({ value: typeof item === "string" ? item : item?.path, cwd: payload.cwd }));
|
|
82
|
+
}
|
|
83
|
+
if (action === "fs.move") {
|
|
84
|
+
return [{ value: payload.source, cwd: payload.cwd }, { value: payload.destination, cwd: payload.cwd }];
|
|
85
|
+
}
|
|
86
|
+
if (action.startsWith("fs.")) {
|
|
87
|
+
return [{ value: payload.path, cwd: payload.cwd, directory: action === "fs.list" || action === "fs.search.start" }];
|
|
88
|
+
}
|
|
89
|
+
if (action === "git.worktree.cleanup") return [{ value: payload.repoPath, directory: true }];
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function resolveToolProject(payload = {}, allowedRoots = [], linkedContexts = null) {
|
|
94
|
+
payload = payload && typeof payload === "object" ? payload : {};
|
|
95
|
+
const explicit = safeLabel(payload.projectKey);
|
|
96
|
+
if (explicit) return explicit;
|
|
97
|
+
const roots = rootsFrom(allowedRoots);
|
|
98
|
+
const paths = candidatePaths(payload);
|
|
99
|
+
const names = new Set();
|
|
100
|
+
let unresolved = 0;
|
|
101
|
+
for (const candidate of paths) {
|
|
102
|
+
const result = pathProject(candidate.value, roots, candidate);
|
|
103
|
+
if (result) names.add(result);
|
|
104
|
+
else unresolved += 1;
|
|
105
|
+
}
|
|
106
|
+
if (names.size > 1 || (names.size && unresolved)) return "Multiple projects";
|
|
107
|
+
if (names.size === 1) return [...names][0];
|
|
108
|
+
const lookupId = payload.batchId || payload.sessionId;
|
|
109
|
+
const linked = lookupId && linkedContexts?.get?.(String(lookupId));
|
|
110
|
+
return safeLabel(linked);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function shortName(value) {
|
|
114
|
+
const filename = String(value ?? "").trim().replace(/\\/g, "/").split("/").filter(Boolean).at(-1);
|
|
115
|
+
return filename ? filename.slice(0, 90) : "file";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function relativeLocation(value, project) {
|
|
119
|
+
const normalized = String(value ?? "").trim().replace(/\\/g, "/");
|
|
120
|
+
if (!normalized) return "";
|
|
121
|
+
const parts = normalized.split("/").filter(Boolean);
|
|
122
|
+
const index = parts.findIndex((part) => part.toLowerCase() === String(project || "").toLowerCase());
|
|
123
|
+
if (index >= 0 && index < parts.length - 1) return parts.slice(index + 1).join("/").slice(0, 130);
|
|
124
|
+
return parts.length > 3 ? "…/" + parts.slice(-3).join("/") : normalized.slice(0, 130);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function terminalTitle(payload) {
|
|
128
|
+
const command = String(payload.command || "");
|
|
129
|
+
if (/\bGet-Command\s+(?:rg|ripgrep)\b/i.test(command)) return "Check ripgrep availability";
|
|
130
|
+
const toolCheck = command.match(/\bGet-Command\s+([a-z][a-z0-9.-]{0,25})\b/i);
|
|
131
|
+
if (toolCheck?.[1]) return "Check " + toolCheck[1] + " availability";
|
|
132
|
+
if (/\b(?:Select-String|rg)\b/i.test(command) && !/Get-Command/i.test(command)) return "Search project files";
|
|
133
|
+
const npmScript = command.match(/\bnpm\s+run\s+([a-z][a-z0-9:_-]+)/i);
|
|
134
|
+
if (npmScript?.[1]) {
|
|
135
|
+
const script = npmScript[1].toLowerCase();
|
|
136
|
+
if (script === "test:tui") return "Run terminal UI tests";
|
|
137
|
+
if (script === "test:hardening") return "Run hardening tests";
|
|
138
|
+
if (script === "verify:publish") return "Verify release package";
|
|
139
|
+
if (script === "test:learn-bootstrap") return "Run Learn routing tests";
|
|
140
|
+
if (script.startsWith("test:")) return "Run " + script.slice(5).replace(/-/g, " ") + " tests";
|
|
141
|
+
if (script === "build") return "Build project";
|
|
142
|
+
return "Run npm script " + script.slice(0, 40);
|
|
143
|
+
}
|
|
144
|
+
if (/\bnode\s+--test\b/i.test(command)) return "Run unit tests";
|
|
145
|
+
if (/\bgit\s+diff\s+--check\b/i.test(command)) return "Validate Git changes";
|
|
146
|
+
if (/\bgit\s+status\b/i.test(command) && !/\bgit\s+commit\b/i.test(command)) return "Review Git status";
|
|
147
|
+
if (/\bgit\s+commit\b/i.test(command)) return "Commit changes";
|
|
148
|
+
if (/\bGet-ChildItem\b/i.test(command)) return "Inspect project files";
|
|
149
|
+
const translated = humanizeToolCall(payload).replace(/\s+· in [^·]+$/, "");
|
|
150
|
+
if (translated.startsWith("Run ")) {
|
|
151
|
+
// Do not display arbitrary shell scripts as activity headlines.
|
|
152
|
+
const gitPush = command.match(/\bgit\s+push\s+(?:-u\s+)?origin\s+([a-zA-Z0-9/_-]+)/i);
|
|
153
|
+
if (gitPush?.[1]) return "Push " + gitPush[1].slice(0, 40) + " to origin";
|
|
154
|
+
const getContent = command.match(/\bGet-Content\s+(["']?)([a-zA-Z0-9_./\\:-]+\.[a-z0-9]+)\1/i);
|
|
155
|
+
if (getContent?.[2]) return "Read " + shortName(getContent[2]);
|
|
156
|
+
return "Execute terminal command";
|
|
157
|
+
}
|
|
158
|
+
return translated.slice(0, 160);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function describeToolActivity(payload = {}, allowedRoots = [], linkedContexts = null) {
|
|
162
|
+
payload = payload && typeof payload === "object" ? payload : {};
|
|
163
|
+
const action = String(payload.action || "unknown");
|
|
164
|
+
const project = resolveToolProject(payload, allowedRoots, linkedContexts);
|
|
165
|
+
const filePath = payload.path || payload.source || payload.destination;
|
|
166
|
+
const category = action.startsWith("fs.") ? "Filesystem"
|
|
167
|
+
: action.startsWith("terminal.batch.") ? "Terminal batch"
|
|
168
|
+
: action.startsWith("terminal.") ? "Terminal"
|
|
169
|
+
: action.startsWith("desktop.") ? "Desktop"
|
|
170
|
+
: action.startsWith("process.") ? "Process"
|
|
171
|
+
: action.startsWith("git.") ? "Git"
|
|
172
|
+
: "Agent";
|
|
173
|
+
let operation = humanizeToolCall(payload);
|
|
174
|
+
let detail = "";
|
|
175
|
+
const count = (arr) => Array.isArray(arr) ? arr.length : 0;
|
|
176
|
+
switch (action) {
|
|
177
|
+
case "fs.write":
|
|
178
|
+
operation = (payload.mode === "append" ? "Append " : "Write ") + shortName(payload.path);
|
|
179
|
+
break;
|
|
180
|
+
case "fs.edit":
|
|
181
|
+
operation = "Edit " + shortName(payload.path);
|
|
182
|
+
break;
|
|
183
|
+
case "fs.read":
|
|
184
|
+
operation = "Read " + shortName(payload.path);
|
|
185
|
+
break;
|
|
186
|
+
case "fs.readMany":
|
|
187
|
+
operation = "Read " + count(payload.paths) + " files";
|
|
188
|
+
break;
|
|
189
|
+
case "fs.batch":
|
|
190
|
+
operation = "Inspect " + count(payload.operations) + " filesystem items";
|
|
191
|
+
break;
|
|
192
|
+
case "fs.stat":
|
|
193
|
+
operation = "Inspect " + shortName(payload.path);
|
|
194
|
+
break;
|
|
195
|
+
case "fs.list":
|
|
196
|
+
operation = "Browse " + shortName(payload.path);
|
|
197
|
+
break;
|
|
198
|
+
case "terminal.exec":
|
|
199
|
+
case "terminal.start":
|
|
200
|
+
operation = terminalTitle(payload);
|
|
201
|
+
break;
|
|
202
|
+
case "terminal.batch.start":
|
|
203
|
+
operation = "Run " + count(payload.jobs) + " terminal tasks";
|
|
204
|
+
break;
|
|
205
|
+
case "terminal.batch.read":
|
|
206
|
+
operation = "Review terminal batch results";
|
|
207
|
+
break;
|
|
208
|
+
case "terminal.batch.status":
|
|
209
|
+
operation = "Check terminal batch progress";
|
|
210
|
+
break;
|
|
211
|
+
case "terminal.read":
|
|
212
|
+
operation = "Review terminal output";
|
|
213
|
+
break;
|
|
214
|
+
case "terminal.list":
|
|
215
|
+
operation = "List terminal sessions";
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (filePath && category === "Filesystem") detail = relativeLocation(filePath, project);
|
|
219
|
+
return { project, category, operation: String(operation).slice(0, 160), detail };
|
|
220
|
+
}
|
package/cli/demo.mjs
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { getAgentVersion } from "../agent/protocol.mjs";
|
|
2
|
+
import { describeToolActivity } from "../agent/toolcall-context.mjs";
|
|
3
|
+
import { RemoteTui } from "./tui.mjs";
|
|
4
|
+
|
|
5
|
+
// Demo uses only synthetic inputs. It neither loads credentials nor starts an
|
|
6
|
+
// agent, a child process, a health monitor, or a network request.
|
|
7
|
+
const DEMO_ROOT = "C:\\Projects";
|
|
8
|
+
const DEMO_ROOTS = [DEMO_ROOT];
|
|
9
|
+
const SIMULATED_AGENT = {
|
|
10
|
+
user: { name: "Demo Account" },
|
|
11
|
+
agentName: "DESKTOP-DEMO",
|
|
12
|
+
allowedRoots: DEMO_ROOT,
|
|
13
|
+
relayUrl: "https://demo.invalid",
|
|
14
|
+
terminalEnabled: true,
|
|
15
|
+
desktopEnabled: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const SAMPLES = [
|
|
19
|
+
{
|
|
20
|
+
action: "fs.write",
|
|
21
|
+
path: "C:\\Projects\\flowly\\apps\\web\\src\\SkillAdminOverview.tsx",
|
|
22
|
+
mode: "rewrite",
|
|
23
|
+
content: "",
|
|
24
|
+
durationMs: 2,
|
|
25
|
+
requestBytes: 6800,
|
|
26
|
+
responseBytes: 330,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
action: "terminal.exec", cwd: "C:\\Projects\\chat-relay",
|
|
30
|
+
command: "git status --short",
|
|
31
|
+
durationMs: 162, requestBytes: 264, responseBytes: 1200,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
action: "terminal.batch.start", cwd: "C:\\Projects\\flowly",
|
|
35
|
+
jobs: [
|
|
36
|
+
{ command: "npm run test:tui" },
|
|
37
|
+
{ command: "git status --short" },
|
|
38
|
+
{ command: "node --check cli/tui.mjs" },
|
|
39
|
+
],
|
|
40
|
+
concurrency: 3,
|
|
41
|
+
durationMs: 31, requestBytes: 1800, responseBytes: 1100,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
action: "terminal.batch.read", batchId: "demo-batch",
|
|
45
|
+
durationMs: 16, requestBytes: 455, responseBytes: 9800,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
action: "fs.batch",
|
|
49
|
+
operations: [
|
|
50
|
+
{ op: "read", path: "C:\\Projects\\flowly\\apps\\web\\src\\App.tsx" },
|
|
51
|
+
{ op: "read", path: "C:\\Projects\\chat-relay\\cli\\tui.mjs" },
|
|
52
|
+
],
|
|
53
|
+
durationMs: 7, requestBytes: 1600, responseBytes: 2600,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
action: "fs.readMany",
|
|
57
|
+
paths: [
|
|
58
|
+
"C:\\Projects\\buddy-android\\app\\src\\main\\java\\NotificationHome.kt",
|
|
59
|
+
"C:\\Projects\\buddy-android\\app\\src\\main\\java\\NewsDetail.kt",
|
|
60
|
+
],
|
|
61
|
+
durationMs: 12, requestBytes: 1300, responseBytes: 4900,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
action: "terminal.exec", cwd: "C:\\Projects\\chat-relay",
|
|
65
|
+
command: "npm run test:hardening",
|
|
66
|
+
durationMs: 380, requestBytes: 450, responseBytes: 240,
|
|
67
|
+
ok: false, error: "Test failed",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
action: "terminal.start", cwd: "C:\\Projects\\flowly",
|
|
71
|
+
command: "npm run build",
|
|
72
|
+
requestBytes: 310, running: true,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
export function buildDemoConfig() {
|
|
77
|
+
return {
|
|
78
|
+
...SIMULATED_AGENT,
|
|
79
|
+
user: { ...SIMULATED_AGENT.user },
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function demoTui({ output, input, env, onInterrupt } = {}) {
|
|
84
|
+
return new RemoteTui({
|
|
85
|
+
config: buildDemoConfig(),
|
|
86
|
+
version: getAgentVersion(),
|
|
87
|
+
output, input, env, onInterrupt, demo: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function seedDemo(tui, { now = Date.now() } = {}) {
|
|
92
|
+
// Synthetic states: they are deliberately not connected to Relay or a real
|
|
93
|
+
// Agent. The TUI marks this status as DEMO rather than Connected.
|
|
94
|
+
tui.state.status = "connected";
|
|
95
|
+
tui.state.relayHealth = { state: "reachable", code: 200 };
|
|
96
|
+
tui.state.learn = true;
|
|
97
|
+
tui.state.reconnects = 0;
|
|
98
|
+
tui.startedAt = now - (3 * 3600 + 24 * 60 + 7) * 1000;
|
|
99
|
+
const linked = new Map([["demo-batch", "flowly"]]);
|
|
100
|
+
|
|
101
|
+
for (let index = 0; index < SAMPLES.length; index += 1) {
|
|
102
|
+
const sample = SAMPLES[index];
|
|
103
|
+
const { durationMs, requestBytes, responseBytes, running, ok, error, ...payload } = sample;
|
|
104
|
+
const activity = describeToolActivity(payload, DEMO_ROOTS, linked);
|
|
105
|
+
const requestId = "demo-" + (index + 1);
|
|
106
|
+
const at = new Date(now - (SAMPLES.length - index) * 50_000).toISOString();
|
|
107
|
+
tui.handleMessage({
|
|
108
|
+
type: "chat-relay-ui", event: "tool:start", requestId, at,
|
|
109
|
+
action: payload.action, summary: activity.operation, ...activity, requestBytes,
|
|
110
|
+
});
|
|
111
|
+
if (!running) tui.handleMessage({
|
|
112
|
+
type: "chat-relay-ui", event: "tool:end", requestId, at,
|
|
113
|
+
ok: ok !== false, durationMs, responseBytes, ...(error ? { error } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// Show the same Learn activity indicator used by the real local agent.
|
|
117
|
+
tui.handleMessage({
|
|
118
|
+
type: "chat-relay-ui", event: "learn",
|
|
119
|
+
activity: {
|
|
120
|
+
eventId: "demo-learn-1", tool: "learn_prepare", projectKey: "chat-relay",
|
|
121
|
+
scopeSummary: "project", durationMs: 24, ok: true,
|
|
122
|
+
at: new Date(now).toISOString(),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
return tui;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function boundedDimension(value, fallback, min, max) {
|
|
129
|
+
const parsed = Number(value);
|
|
130
|
+
return Number.isFinite(parsed) ? Math.max(min, Math.min(max, Math.trunc(parsed))) : fallback;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function renderDemoSnapshot({ width = 112, height = 30, now } = {}) {
|
|
134
|
+
const fragments = [];
|
|
135
|
+
const output = {
|
|
136
|
+
isTTY: false,
|
|
137
|
+
columns: boundedDimension(width, 112, 1, 2048),
|
|
138
|
+
rows: boundedDimension(height, 30, 1, 90),
|
|
139
|
+
write: (value) => { fragments.push(String(value)); return true; },
|
|
140
|
+
};
|
|
141
|
+
const tui = demoTui({ output, input: { isTTY: false }, env: { NO_COLOR: "1" } });
|
|
142
|
+
seedDemo(tui, { now });
|
|
143
|
+
tui.render();
|
|
144
|
+
const frame = fragments.at(-1) || "";
|
|
145
|
+
tui.stop();
|
|
146
|
+
return frame.replace(/^\x1b\[2J\x1b\[H/, "");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function runTuiDemo({
|
|
150
|
+
output = process.stdout,
|
|
151
|
+
input = process.stdin,
|
|
152
|
+
env = process.env,
|
|
153
|
+
snapshot = false,
|
|
154
|
+
width,
|
|
155
|
+
height,
|
|
156
|
+
} = {}) {
|
|
157
|
+
const interactive = output?.isTTY && input?.isTTY && typeof input.setRawMode === "function";
|
|
158
|
+
if (snapshot || !interactive) {
|
|
159
|
+
output.write(renderDemoSnapshot({
|
|
160
|
+
width: width ?? output?.columns ?? 112,
|
|
161
|
+
height: height ?? output?.rows ?? 30,
|
|
162
|
+
}) + "\n");
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return new Promise((resolve, reject) => {
|
|
167
|
+
let done = false;
|
|
168
|
+
let tui;
|
|
169
|
+
function stop() {
|
|
170
|
+
if (done) return;
|
|
171
|
+
done = true;
|
|
172
|
+
process.removeListener("SIGINT", stop);
|
|
173
|
+
process.removeListener("SIGTERM", stop);
|
|
174
|
+
tui?.stop();
|
|
175
|
+
resolve(0);
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
tui = demoTui({ output, input, env, onInterrupt: stop });
|
|
179
|
+
process.once("SIGINT", stop);
|
|
180
|
+
process.once("SIGTERM", stop);
|
|
181
|
+
tui.start();
|
|
182
|
+
seedDemo(tui);
|
|
183
|
+
tui.render();
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (!done) {
|
|
186
|
+
done = true;
|
|
187
|
+
process.removeListener("SIGINT", stop);
|
|
188
|
+
process.removeListener("SIGTERM", stop);
|
|
189
|
+
tui?.stop();
|
|
190
|
+
}
|
|
191
|
+
reject(error);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
package/cli/device-login.mjs
CHANGED
|
@@ -9,8 +9,14 @@ import {
|
|
|
9
9
|
saveIdentity,
|
|
10
10
|
} from "./config.mjs";
|
|
11
11
|
|
|
12
|
+
// Hosted mode default. Self-hosted deployments must select their own URL with --relay.
|
|
12
13
|
const DEFAULT_RELAY_URL = "https://chat-relay.anusorn-hank.workers.dev";
|
|
13
14
|
|
|
15
|
+
export function needsRelayLogin(config, requestedRelayUrl) {
|
|
16
|
+
if (!requestedRelayUrl) return false;
|
|
17
|
+
return String(config?.relayUrl || "").replace(/\/+$/, "") !== String(requestedRelayUrl).replace(/\/+$/, "");
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
function sanitizeAgentId(value) {
|
|
15
21
|
const normalized = value.toLowerCase().trim()
|
|
16
22
|
.replace(/[^a-z0-9_-]+/g, "-")
|
|
@@ -73,7 +79,7 @@ function openBrowser(url) {
|
|
|
73
79
|
|
|
74
80
|
export async function login(options = {}) {
|
|
75
81
|
const existing = loadConfig() || {};
|
|
76
|
-
const relayUrl = String(options.relayUrl || existing.relayUrl || DEFAULT_RELAY_URL).replace(/\/$/, "");
|
|
82
|
+
const relayUrl = String(options.relayUrl || process.env.RELAY_URL || existing.relayUrl || DEFAULT_RELAY_URL).replace(/\/$/, "");
|
|
77
83
|
const hostname = os.hostname();
|
|
78
84
|
const identity = loadIdentity() || {};
|
|
79
85
|
const requestedAgentId = options.agentId ||
|
package/cli/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clearConfig, configPath, loadConfig, saveConfig } from "./config.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { runTuiDemo } from "./demo.mjs";
|
|
3
|
+
import { login, needsRelayLogin, requestJson } from "./device-login.mjs";
|
|
3
4
|
import { protocolCompatibility, remote, validateConfig } from "./remote.mjs";
|
|
4
5
|
import { launchLatestRemote } from "./self-update.mjs";
|
|
5
6
|
import { AGENT_UPGRADE_EXIT_CODE } from "../agent/lifecycle.mjs";
|
|
@@ -15,6 +16,11 @@ function parseOptions(args) {
|
|
|
15
16
|
else if (arg === "--no-desktop") options.desktopEnabled = false;
|
|
16
17
|
else if (arg === "--plain") options.tuiEnabled = false;
|
|
17
18
|
else if (arg === "--tui") options.tuiEnabled = true;
|
|
19
|
+
else if (arg === "--snapshot") options.snapshot = true;
|
|
20
|
+
else if (arg === "--width") options.width = args[++index];
|
|
21
|
+
else if (arg.startsWith("--width=")) options.width = arg.slice(8);
|
|
22
|
+
else if (arg === "--height") options.height = args[++index];
|
|
23
|
+
else if (arg.startsWith("--height=")) options.height = arg.slice(9);
|
|
18
24
|
else if (arg === "--relay") options.relayUrl = args[++index];
|
|
19
25
|
else if (arg.startsWith("--relay=")) options.relayUrl = arg.slice(8);
|
|
20
26
|
else if (arg === "--root") options.allowedRoot = args[++index];
|
|
@@ -33,6 +39,7 @@ function help() {
|
|
|
33
39
|
|
|
34
40
|
Usage:
|
|
35
41
|
chat-relay remote [options] Connect this computer to ChatGPT
|
|
42
|
+
chat-relay demo [options] Preview the real TUI offline with sample activity
|
|
36
43
|
chat-relay login [options] Sign in and register this computer
|
|
37
44
|
chat-relay status Show account and connection status
|
|
38
45
|
chat-relay drain Stop accepting new long-running work
|
|
@@ -51,11 +58,15 @@ Options:
|
|
|
51
58
|
--no-desktop Disable desktop access (default)
|
|
52
59
|
--plain Use legacy line-by-line logs
|
|
53
60
|
--tui Force interactive terminal UI
|
|
61
|
+
--snapshot Print demo as plain text and exit
|
|
62
|
+
--width <columns> Demo snapshot width
|
|
63
|
+
--height <rows> Demo snapshot height
|
|
54
64
|
--no-open Do not open the browser automatically
|
|
55
65
|
--force Force a new login
|
|
56
66
|
|
|
57
67
|
Examples:
|
|
58
68
|
npx @anusornneal/chat-relay@latest remote
|
|
69
|
+
node bin/chat-relay.js demo
|
|
59
70
|
npx @anusornneal/chat-relay@latest login
|
|
60
71
|
npx @anusornneal/chat-relay@latest status
|
|
61
72
|
`);
|
|
@@ -238,9 +249,11 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
238
249
|
return 0;
|
|
239
250
|
}
|
|
240
251
|
|
|
252
|
+
if (command === "demo" || command === "preview") return runTuiDemo(options);
|
|
253
|
+
|
|
241
254
|
if (command === "login") {
|
|
242
255
|
const current = loadConfig();
|
|
243
|
-
if (!options.force && await validateConfig(current)) {
|
|
256
|
+
if (!options.force && !needsRelayLogin(current, options.relayUrl) && await validateConfig(current)) {
|
|
244
257
|
console.log(`Already signed in as ${current.user?.name || current.user?.login || "user"}.`);
|
|
245
258
|
console.log("Use --force to sign in again.");
|
|
246
259
|
return 0;
|
package/cli/remote.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { execFile, spawn } from "node:child_process";
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { loadConfig, saveConfig } from "./config.mjs";
|
|
5
|
-
import { login, requestJson } from "./device-login.mjs";
|
|
5
|
+
import { login, needsRelayLogin, requestJson } from "./device-login.mjs";
|
|
6
6
|
import { acquireRunnerOwnership, RunnerAlreadyActiveError } from "./runner-ownership.mjs";
|
|
7
7
|
import { getAgentVersion } from "../agent/protocol.mjs";
|
|
8
8
|
import { AGENT_UPGRADE_EXIT_CODE } from "../agent/lifecycle.mjs";
|
|
@@ -94,7 +94,7 @@ function spawnAgent(config, { tui = null, onConnectionState = null } = {}) {
|
|
|
94
94
|
export async function remote(options = {}) {
|
|
95
95
|
stopping = false;
|
|
96
96
|
let config = loadConfig();
|
|
97
|
-
if (!(await validateConfig(config))) {
|
|
97
|
+
if (needsRelayLogin(config, options.relayUrl) || !(await validateConfig(config))) {
|
|
98
98
|
console.log("No valid Chat Relay login found. Starting sign in...");
|
|
99
99
|
config = await login(options);
|
|
100
100
|
}
|
package/cli/tui.mjs
CHANGED
|
@@ -15,8 +15,8 @@ const STYLE = {
|
|
|
15
15
|
const LABEL_WIDTH = 12;
|
|
16
16
|
const GAP = 3;
|
|
17
17
|
const MIN_FRAME_WIDTH = 60;
|
|
18
|
-
const MAX_FRAME_WIDTH = 179;
|
|
19
|
-
const
|
|
18
|
+
const MAX_FRAME_WIDTH = 179; // Legacy fixed-width formatter only.
|
|
19
|
+
const MAX_TUI_VIEWPORT_WIDTH = 2048; // Full-width monitor, bounded for unusual terminals.
|
|
20
20
|
const FRAME_BOTTOM_MARGIN = 1;
|
|
21
21
|
|
|
22
22
|
function clamp(value, min, max) {
|
|
@@ -41,6 +41,9 @@ function codePointCellWidth(codePoint) {
|
|
|
41
41
|
|| (codePoint >= 0x20d0 && codePoint <= 0x20ff)
|
|
42
42
|
|| (codePoint >= 0xfe20 && codePoint <= 0xfe2f)
|
|
43
43
|
|| codePoint === 0xfe0f
|
|
44
|
+
|| codePoint === 0x0e31
|
|
45
|
+
|| (codePoint >= 0x0e34 && codePoint <= 0x0e3a)
|
|
46
|
+
|| (codePoint >= 0x0e47 && codePoint <= 0x0e4e)
|
|
44
47
|
|| codePoint === 0x200d
|
|
45
48
|
) return 0;
|
|
46
49
|
if (
|
|
@@ -298,6 +301,161 @@ export function shouldUseColor(stdout = process.stdout, env = process.env) {
|
|
|
298
301
|
return true;
|
|
299
302
|
}
|
|
300
303
|
|
|
304
|
+
const MONITOR = {
|
|
305
|
+
accent: "\x1b[38;2;93;218;203m",
|
|
306
|
+
bright: "\x1b[38;2;235;241;248m",
|
|
307
|
+
muted: "\x1b[38;2;128;145;164m",
|
|
308
|
+
dim: "\x1b[38;2;104;121;139m",
|
|
309
|
+
border: "\x1b[38;2;45;60;77m",
|
|
310
|
+
good: "\x1b[38;2;91;218;163m",
|
|
311
|
+
bad: "\x1b[38;2;247;114;114m",
|
|
312
|
+
warning: "\x1b[38;2;243;192;101m",
|
|
313
|
+
liveBg: "\x1b[48;2;20;62;55m",
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
function tint(value, style, enabled) {
|
|
317
|
+
return enabled ? paint(value, style) : value;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function cellPad(value, width) {
|
|
321
|
+
const clipped = truncateCells(value, Math.max(0, width));
|
|
322
|
+
return clipped + " ".repeat(Math.max(0, width - terminalCellWidth(clipped)));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function activityCategory(item) {
|
|
326
|
+
if (item.category) return String(item.category);
|
|
327
|
+
const action = String(item.action || "");
|
|
328
|
+
if (action.startsWith("fs.")) return "Filesystem";
|
|
329
|
+
if (action.startsWith("terminal.")) return "Terminal";
|
|
330
|
+
if (action.startsWith("desktop.")) return "Desktop";
|
|
331
|
+
if (action.startsWith("learn")) return "Learn";
|
|
332
|
+
return "Agent";
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function activityTitle(item) {
|
|
336
|
+
const value = String(item.operation || item.summary || item.action || "Tool call").replace(/\s+/g, " ").trim();
|
|
337
|
+
if (!item.operation && /^Run (?:Write-Output|Get-Command|Get-Content|Set-Variable|Start-Process)\b/i.test(value)) {
|
|
338
|
+
return "Execute terminal command";
|
|
339
|
+
}
|
|
340
|
+
// Preserve the familiar Learn marker even when an operation is humanized.
|
|
341
|
+
return activityCategory(item) === "Learn" && !value.startsWith("🧠") ? "🧠 " + value : value;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function activityRows(item, width, { color = false, twoLines = false } = {}) {
|
|
345
|
+
const limit = Math.max(1, width);
|
|
346
|
+
const project = String(item.project || "General");
|
|
347
|
+
const title = activityTitle(item);
|
|
348
|
+
const symbol = item.status === "running" ? "◌" : item.ok === false ? "×" : "✓";
|
|
349
|
+
const symbolColor = item.status === "running" ? MONITOR.warning : item.ok === false ? MONITOR.bad : MONITOR.good;
|
|
350
|
+
const time = clock(item.at);
|
|
351
|
+
if (limit < 52) {
|
|
352
|
+
if (limit <= 2) return [tint(truncateCells(symbol, limit), symbolColor, color)];
|
|
353
|
+
const prefix = limit >= 37 ? time.slice(0, 5) + " " : "";
|
|
354
|
+
const bodyWidth = Math.max(0, limit - terminalCellWidth(prefix) - 2);
|
|
355
|
+
const projectText = truncateCells(project + " · ", bodyWidth);
|
|
356
|
+
const titleText = truncateCells(title, Math.max(0, bodyWidth - terminalCellWidth(projectText)));
|
|
357
|
+
const plain = prefix + symbol + " " + projectText + titleText;
|
|
358
|
+
return [color
|
|
359
|
+
? tint(prefix, MONITOR.dim, true) + tint(symbol, symbolColor, true) + " "
|
|
360
|
+
+ tint(projectText, MONITOR.muted, true) + tint(titleText, MONITOR.bright, true)
|
|
361
|
+
: plain];
|
|
362
|
+
}
|
|
363
|
+
const opStart = 13;
|
|
364
|
+
const durationWidth = 10;
|
|
365
|
+
const operationWidth = Math.max(1, limit - opStart - durationWidth);
|
|
366
|
+
const duration = formatDuration(item.durationMs, item.status);
|
|
367
|
+
const operation = cellPad(title, operationWidth);
|
|
368
|
+
const prefix = cellPad(time, 8) + " ";
|
|
369
|
+
const ending = cellPad(duration, durationWidth);
|
|
370
|
+
const headline = color
|
|
371
|
+
? tint(prefix, MONITOR.dim, true) + tint(symbol, symbolColor, true) + " " + tint(operation, MONITOR.bright, true) + tint(ending, MONITOR.dim, true)
|
|
372
|
+
: prefix + symbol + " " + operation + ending;
|
|
373
|
+
if (!twoLines) return [headline];
|
|
374
|
+
|
|
375
|
+
const category = activityCategory(item);
|
|
376
|
+
const extra = item.error && item.ok === false
|
|
377
|
+
? " · Error: " + String(item.error).replace(/\s+/g, " ").slice(0, 70)
|
|
378
|
+
: item.detail ? " · " + String(item.detail).replace(/\s+/g, " ").slice(0, 100) : "";
|
|
379
|
+
const secondary = " · " + category + extra;
|
|
380
|
+
// Keep request/response telemetry in transaction state but leave it out of
|
|
381
|
+
// the monitoring view, where it competes with operation and project context.
|
|
382
|
+
const textWidth = Math.max(1, limit - opStart);
|
|
383
|
+
const name = truncateCells(project, textWidth);
|
|
384
|
+
const rest = truncateCells(secondary, Math.max(0, textWidth - terminalCellWidth(name)));
|
|
385
|
+
const metadata = " ".repeat(opStart)
|
|
386
|
+
+ (color
|
|
387
|
+
? tint(name, item.project ? MONITOR.muted : MONITOR.dim, true)
|
|
388
|
+
+ tint(rest, item.ok === false ? MONITOR.bad : MONITOR.dim, true)
|
|
389
|
+
: name + rest);
|
|
390
|
+
return [headline, metadata];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function monitorCapabilities(state, width, color) {
|
|
394
|
+
const parts = [
|
|
395
|
+
{ text: (state.terminal ? "✓" : "×") + " Terminal", color: state.terminal ? MONITOR.good : MONITOR.dim },
|
|
396
|
+
{ text: (state.desktop ? "✓" : "×") + " Desktop", color: state.desktop ? MONITOR.good : MONITOR.dim },
|
|
397
|
+
{ text: (state.learn === null ? "◌" : state.learn ? "✓" : "×") + " Learn",
|
|
398
|
+
color: state.learn === null ? MONITOR.warning : state.learn ? MONITOR.good : MONITOR.dim },
|
|
399
|
+
];
|
|
400
|
+
const plain = parts.map((part) => part.text).join(" ");
|
|
401
|
+
if (terminalCellWidth(plain) > width) return tint(truncateCells(plain, width), MONITOR.muted, color);
|
|
402
|
+
return parts.map((part) => tint(part.text, part.color, color)).join(" ");
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function monitoringSummary(state, width, layout, color) {
|
|
406
|
+
if (layout === "tiny") {
|
|
407
|
+
return [tint(truncateCells((state.agent || "Agent") + " · " + formatUptime(state.uptimeMs), width), MONITOR.muted, color)];
|
|
408
|
+
}
|
|
409
|
+
if (layout === "medium") {
|
|
410
|
+
const line = "Agent " + String(state.agent || "-") + " Session " + formatUptime(state.uptimeMs)
|
|
411
|
+
+ " Reconnects " + (state.reconnects ?? 0);
|
|
412
|
+
return [
|
|
413
|
+
tint(truncateCells(line, width), MONITOR.bright, color),
|
|
414
|
+
tint(truncateCells("Root " + String(state.root || "-"), width), MONITOR.muted, color),
|
|
415
|
+
monitorCapabilities(state, width, color),
|
|
416
|
+
];
|
|
417
|
+
}
|
|
418
|
+
const w1 = Math.floor(width * 0.49);
|
|
419
|
+
const w2 = Math.floor(width * 0.29);
|
|
420
|
+
const w3 = width - w1 - w2;
|
|
421
|
+
const headings = [
|
|
422
|
+
tint(cellPad("AGENT", w1), MONITOR.muted, color),
|
|
423
|
+
tint(cellPad("SESSION", w2), MONITOR.muted, color),
|
|
424
|
+
tint(cellPad("RECONNECTS", w3), MONITOR.muted, color),
|
|
425
|
+
].join("");
|
|
426
|
+
const stats = [
|
|
427
|
+
tint(cellPad(state.agent || "-", w1), MONITOR.bright, color),
|
|
428
|
+
tint(cellPad(formatUptime(state.uptimeMs), w2), MONITOR.bright, color),
|
|
429
|
+
tint(cellPad(String(state.reconnects ?? 0), w3), state.reconnects > 0 ? MONITOR.warning : MONITOR.bright, color),
|
|
430
|
+
].join("");
|
|
431
|
+
return [
|
|
432
|
+
headings,
|
|
433
|
+
stats,
|
|
434
|
+
tint(truncateCells("Root " + String(state.root || "-"), width), MONITOR.muted, color),
|
|
435
|
+
monitorCapabilities(state, width, color),
|
|
436
|
+
];
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function headingRow(width, color) {
|
|
440
|
+
const left = cellPad("TIME", 13);
|
|
441
|
+
const op = cellPad("OPERATION", Math.max(1, width - 23));
|
|
442
|
+
const right = cellPad("DURATION", 10);
|
|
443
|
+
return tint(left + op + right, MONITOR.muted, color);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function monitorFooter(width, color, online, demo = false) {
|
|
447
|
+
const hint = width >= 65
|
|
448
|
+
? "↑↓ Scroll · End " + (demo ? "Newest" : "Live") + " · Ctrl+C Exit"
|
|
449
|
+
: "Ctrl+C Exit";
|
|
450
|
+
const status = demo ? "◈ Offline preview" : online ? "● Connected" : "○ Disconnected";
|
|
451
|
+
if (terminalCellWidth(hint) + terminalCellWidth(status) + 3 > width) {
|
|
452
|
+
return tint(truncateCells(hint, width), MONITOR.dim, color);
|
|
453
|
+
}
|
|
454
|
+
return tint(hint, MONITOR.dim, color)
|
|
455
|
+
+ " ".repeat(width - terminalCellWidth(hint) - terminalCellWidth(status))
|
|
456
|
+
+ tint(status, demo ? MONITOR.accent : online ? MONITOR.accent : MONITOR.warning, color);
|
|
457
|
+
}
|
|
458
|
+
|
|
301
459
|
export class RemoteTui {
|
|
302
460
|
constructor({
|
|
303
461
|
config,
|
|
@@ -306,6 +464,7 @@ export class RemoteTui {
|
|
|
306
464
|
input = process.stdin,
|
|
307
465
|
env = process.env,
|
|
308
466
|
onInterrupt = () => process.emit("SIGINT"),
|
|
467
|
+
demo = false,
|
|
309
468
|
}) {
|
|
310
469
|
this.output = output;
|
|
311
470
|
this.input = input;
|
|
@@ -325,6 +484,7 @@ export class RemoteTui {
|
|
|
325
484
|
};
|
|
326
485
|
this.version = version || "-";
|
|
327
486
|
this.colorEnabled = shouldUseColor(output, env);
|
|
487
|
+
this.demoMode = demo === true;
|
|
328
488
|
this.transactions = [];
|
|
329
489
|
this.timer = null;
|
|
330
490
|
this.closed = false;
|
|
@@ -388,23 +548,40 @@ export class RemoteTui {
|
|
|
388
548
|
}
|
|
389
549
|
|
|
390
550
|
viewportMetrics() {
|
|
391
|
-
const
|
|
392
|
-
|
|
551
|
+
const columns = Math.max(1, Number(this.output.columns) || 110);
|
|
552
|
+
// Fill the actual terminal width; reserve one cell to avoid line wrapping.
|
|
553
|
+
const width = Math.min(Math.max(1, columns - 1), MAX_TUI_VIEWPORT_WIDTH);
|
|
393
554
|
const height = Math.max(1, Number(this.output.rows) || 30);
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
555
|
+
const usableHeight = Math.max(1, height - FRAME_BOTTOM_MARGIN);
|
|
556
|
+
let layout = width >= 88 && usableHeight >= 15 ? "wide"
|
|
557
|
+
: width >= 54 && usableHeight >= 11 ? "medium" : "tiny";
|
|
558
|
+
let topLine = layout === "wide" ? 1 : 0;
|
|
559
|
+
let summaryRows = layout === "wide" ? 4 : layout === "medium" ? 3 : 1;
|
|
560
|
+
let dividerRows = usableHeight >= 6 ? 1 : 0;
|
|
561
|
+
let headingRows = layout === "tiny" ? 0 : 2;
|
|
562
|
+
const footerRows = usableHeight >= 6 ? 1 : 0;
|
|
563
|
+
let fixedRows = 1 + topLine + summaryRows + dividerRows + 1 + headingRows + footerRows;
|
|
564
|
+
if (fixedRows >= usableHeight && layout !== "tiny") {
|
|
565
|
+
layout = "tiny";
|
|
566
|
+
topLine = 0;
|
|
567
|
+
summaryRows = 1;
|
|
568
|
+
headingRows = 0;
|
|
569
|
+
fixedRows = 1 + summaryRows + dividerRows + 1 + footerRows;
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
width, height, layout, usableHeight, topLine, dividerRows, headingRows, footerRows,
|
|
573
|
+
availableRows: Math.max(0, usableHeight - fixedRows),
|
|
574
|
+
twoLines: layout !== "tiny" && height >= 17,
|
|
575
|
+
};
|
|
399
576
|
}
|
|
400
577
|
|
|
401
|
-
transactionRows(width) {
|
|
402
|
-
return this.transactions.flatMap((item) =>
|
|
578
|
+
transactionRows(width, twoLines = this.viewportMetrics().twoLines) {
|
|
579
|
+
return this.transactions.flatMap((item) => activityRows(item, width, { color: this.colorEnabled, twoLines }));
|
|
403
580
|
}
|
|
404
581
|
|
|
405
582
|
maxScrollOffset() {
|
|
406
|
-
const { width, availableRows } = this.viewportMetrics();
|
|
407
|
-
return Math.max(0, this.transactionRows(width).length - availableRows);
|
|
583
|
+
const { width, twoLines, availableRows } = this.viewportMetrics();
|
|
584
|
+
return Math.max(0, this.transactionRows(width, twoLines).length - availableRows);
|
|
408
585
|
}
|
|
409
586
|
|
|
410
587
|
scrollBy(lines) {
|
|
@@ -454,8 +631,8 @@ export class RemoteTui {
|
|
|
454
631
|
|
|
455
632
|
appendTransaction(item) {
|
|
456
633
|
if (this.scrollOffset > 0) {
|
|
457
|
-
const { width } = this.viewportMetrics();
|
|
458
|
-
this.scrollOffset +=
|
|
634
|
+
const { width, twoLines } = this.viewportMetrics();
|
|
635
|
+
this.scrollOffset += activityRows(item, width, { twoLines }).length;
|
|
459
636
|
this.unseenTransactions += 1;
|
|
460
637
|
}
|
|
461
638
|
this.transactions.push(item);
|
|
@@ -473,6 +650,10 @@ export class RemoteTui {
|
|
|
473
650
|
at: message.at || new Date().toISOString(),
|
|
474
651
|
action: message.action,
|
|
475
652
|
summary: message.summary || humanizeToolCall({ action: message.action }),
|
|
653
|
+
operation: typeof message.operation === "string" ? message.operation : undefined,
|
|
654
|
+
project: typeof message.project === "string" ? message.project : null,
|
|
655
|
+
category: typeof message.category === "string" ? message.category : undefined,
|
|
656
|
+
detail: typeof message.detail === "string" ? message.detail : "",
|
|
476
657
|
status: "running",
|
|
477
658
|
ok: null,
|
|
478
659
|
requestBytes: Number.isFinite(Number(message.requestBytes)) ? Number(message.requestBytes) : undefined,
|
|
@@ -484,7 +665,7 @@ export class RemoteTui {
|
|
|
484
665
|
item.ok = message.ok !== false;
|
|
485
666
|
item.durationMs = message.durationMs;
|
|
486
667
|
if (Number.isFinite(Number(message.responseBytes))) item.responseBytes = Number(message.responseBytes);
|
|
487
|
-
if (message.error && message.ok === false) item.
|
|
668
|
+
if (message.error && message.ok === false) item.error = truncate(message.error, 90);
|
|
488
669
|
}
|
|
489
670
|
} else if (message.event === "learn") {
|
|
490
671
|
const activity = message.activity && typeof message.activity === "object" ? message.activity : null;
|
|
@@ -523,6 +704,12 @@ export class RemoteTui {
|
|
|
523
704
|
at: activity.at || message.at || new Date().toISOString(),
|
|
524
705
|
action: tool,
|
|
525
706
|
summary: "🧠 Learn · " + truncate(detail, 120),
|
|
707
|
+
operation: tool === "learn_prepare" ? "Load relevant Learn context"
|
|
708
|
+
: tool === "learn_get" ? "Read Learn memories"
|
|
709
|
+
: tool === "learn_delete" ? "Delete Learn memory" : "Update Learn memory",
|
|
710
|
+
category: "Learn",
|
|
711
|
+
project: typeof activity.projectKey === "string" ? activity.projectKey
|
|
712
|
+
: activity.scope === "project" && typeof activity.scopeKey === "string" ? activity.scopeKey : null,
|
|
526
713
|
status: "done",
|
|
527
714
|
ok: activity.ok !== false,
|
|
528
715
|
...(Number.isFinite(durationMs) ? { durationMs } : {}),
|
|
@@ -542,6 +729,9 @@ export class RemoteTui {
|
|
|
542
729
|
at: change.at || message.at || new Date().toISOString(),
|
|
543
730
|
action: "learn",
|
|
544
731
|
summary: "Learn " + marker + " " + truncate(detail, 120),
|
|
732
|
+
operation: "Update Learn memory",
|
|
733
|
+
category: "Learn",
|
|
734
|
+
project: typeof change.projectKey === "string" ? change.projectKey : null,
|
|
545
735
|
status: "done",
|
|
546
736
|
ok: true,
|
|
547
737
|
});
|
|
@@ -583,52 +773,54 @@ export class RemoteTui {
|
|
|
583
773
|
|
|
584
774
|
render() {
|
|
585
775
|
if (this.closed) return;
|
|
586
|
-
const { width, height,
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
if (compact) headerLines = headerLines.slice(0, headerRows);
|
|
603
|
-
|
|
604
|
-
const allRows = this.transactionRows(width);
|
|
605
|
-
const maxOffset = Math.max(0, allRows.length - availableRows);
|
|
606
|
-
this.scrollOffset = clamp(this.scrollOffset, 0, maxOffset);
|
|
776
|
+
const { width, height, layout, usableHeight, topLine, dividerRows,
|
|
777
|
+
headingRows, footerRows, availableRows, twoLines } = this.viewportMetrics();
|
|
778
|
+
const state = { ...this.state, uptimeMs: Date.now() - this.startedAt };
|
|
779
|
+
const online = state.status === "connected" && relayIsOnline(state.relayHealth);
|
|
780
|
+
const health = this.demoMode ? "◈ DEMO" : online ? "● ONLINE" : state.status === "connected" ? "○ OFFLINE" : statusText(state.status);
|
|
781
|
+
const headline = "Chat Relay v" + this.version + (this.demoMode ? " · PREVIEW" : "");
|
|
782
|
+
const headlineRoom = width - terminalCellWidth(health) - 2;
|
|
783
|
+
const title = headlineRoom >= 12
|
|
784
|
+
? tint(truncateCells(headline, headlineRoom), MONITOR.accent, this.colorEnabled)
|
|
785
|
+
+ " ".repeat(width - terminalCellWidth(truncateCells(headline, headlineRoom)) - terminalCellWidth(health))
|
|
786
|
+
+ tint(health, online ? MONITOR.good : MONITOR.warning, this.colorEnabled)
|
|
787
|
+
: tint(truncateCells(headline, width), MONITOR.accent, this.colorEnabled);
|
|
788
|
+
const divider = tint("─".repeat(width), MONITOR.border, this.colorEnabled);
|
|
789
|
+
const allRows = this.transactionRows(width, twoLines);
|
|
790
|
+
this.scrollOffset = clamp(this.scrollOffset, 0, Math.max(0, allRows.length - availableRows));
|
|
791
|
+
if (this.scrollOffset === 0) this.unseenTransactions = 0;
|
|
607
792
|
const end = Math.max(0, allRows.length - this.scrollOffset);
|
|
608
|
-
const
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
?
|
|
617
|
-
: this.
|
|
618
|
-
|
|
619
|
-
:
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
width
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
793
|
+
const begin = Math.max(0, end - availableRows);
|
|
794
|
+
const visible = allRows.slice(begin, end);
|
|
795
|
+
const badge = this.demoMode ? "◈ SAMPLE" : this.scrollOffset === 0 ? "● LIVE"
|
|
796
|
+
: this.unseenTransactions ? "+" + this.unseenTransactions + " NEW" : "HISTORY";
|
|
797
|
+
const left = "Activity " + badge;
|
|
798
|
+
const count = this.transactions.length + (this.transactions.length === 1 ? " operation" : " operations");
|
|
799
|
+
const showCount = width >= terminalCellWidth(left) + terminalCellWidth(count) + 3;
|
|
800
|
+
const section = terminalCellWidth(left) > width
|
|
801
|
+
? tint(truncateCells(left, width), MONITOR.accent, this.colorEnabled)
|
|
802
|
+
: this.colorEnabled
|
|
803
|
+
? tint("Activity", MONITOR.bright, true) + " "
|
|
804
|
+
+ (this.scrollOffset === 0 ? paint(badge, MONITOR.good, MONITOR.liveBg) : tint(badge, MONITOR.warning, true))
|
|
805
|
+
+ (showCount ? " ".repeat(width - terminalCellWidth(left) - terminalCellWidth(count))
|
|
806
|
+
+ tint(count, MONITOR.muted, true) : "")
|
|
807
|
+
: left + (showCount ? " ".repeat(width - terminalCellWidth(left) - terminalCellWidth(count)) + count : "");
|
|
808
|
+
const lines = [title];
|
|
809
|
+
if (topLine) lines.push(divider);
|
|
810
|
+
lines.push(...monitoringSummary(state, width, layout, this.colorEnabled));
|
|
811
|
+
if (dividerRows) lines.push(divider);
|
|
812
|
+
lines.push(section);
|
|
813
|
+
if (headingRows) lines.push(headingRow(width, this.colorEnabled), divider);
|
|
814
|
+
if (availableRows > 0 && visible.length === 0) {
|
|
815
|
+
visible.push(tint(" No recent activity", MONITOR.dim, this.colorEnabled));
|
|
816
|
+
}
|
|
817
|
+
lines.push(...visible);
|
|
818
|
+
while (lines.length < usableHeight - footerRows) lines.push("");
|
|
819
|
+
if (footerRows) lines.push(monitorFooter(width, this.colorEnabled, online, this.demoMode));
|
|
820
|
+
const screen = lines.slice(0, Math.max(1, usableHeight)).join("\n");
|
|
821
|
+
if (screen !== this.previousFrame) {
|
|
822
|
+
this.previousFrame = screen;
|
|
823
|
+
this.output.write(ESC + "2J" + ESC + "H" + screen);
|
|
824
|
+
}
|
|
633
825
|
}
|
|
634
826
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anusornneal/chat-relay",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
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": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
@@ -21,12 +21,16 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"start": "node bin/chat-relay.js remote",
|
|
23
23
|
"remote": "node bin/chat-relay.js remote",
|
|
24
|
+
"demo": "node bin/chat-relay.js demo",
|
|
24
25
|
"login": "node bin/chat-relay.js login",
|
|
25
26
|
"logout": "node bin/chat-relay.js logout",
|
|
26
27
|
"status": "node bin/chat-relay.js status",
|
|
27
28
|
"dev": "wrangler dev",
|
|
28
29
|
"dev:test": "wrangler dev --local --port 8790 --var AGENT_TOKEN:test-agent --var CALLER_TOKEN:test-caller --var ADMIN_TOKEN:test-admin --var OPENAI_APPS_CHALLENGE:test-openai-apps-challenge",
|
|
29
|
-
"deploy": "
|
|
30
|
+
"deploy": "node scripts/deploy-worker.mjs selfhost",
|
|
31
|
+
"deploy:selfhost": "node scripts/deploy-worker.mjs selfhost",
|
|
32
|
+
"deploy:production": "node scripts/deploy-worker.mjs production",
|
|
33
|
+
"test:deployment-config": "node --test test/deployment-config.test.mjs",
|
|
30
34
|
"agent": "node --env-file-if-exists=.dev.vars agent/local-agent.mjs",
|
|
31
35
|
"admin": "node scripts/admin.mjs",
|
|
32
36
|
"test:terminal": "node test/mcp-terminal-smoke.mjs",
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
"prepublishOnly": "npm run verify:publish",
|
|
40
44
|
"test:oauth": "node test/oauth-smoke.mjs",
|
|
41
45
|
"test:usage": "node test/usage-smoke.mjs",
|
|
42
|
-
"test:usage-storage": "node test/usage-storage.test.mjs",
|
|
46
|
+
"test:usage-storage": "node test/usage-storage.test.mjs && node --test test/usage-batch.test.mjs",
|
|
43
47
|
"test:no-quota": "node test/no-quota-regression.test.mjs",
|
|
44
48
|
"test:admin-api": "node test/admin-api-smoke.mjs",
|
|
45
49
|
"test:admin-auth": "node test/admin-auth-smoke.mjs",
|
|
@@ -49,8 +53,8 @@
|
|
|
49
53
|
"test:desktop": "node test/mcp-desktop-smoke.mjs",
|
|
50
54
|
"test:device-management": "node test/device-management-smoke.mjs",
|
|
51
55
|
"test:submission": "node test/submission-smoke.mjs",
|
|
52
|
-
"test:agent-state": "node --experimental-strip-types --test test/agent-state.test.mjs",
|
|
53
|
-
"test:tui": "node --test test/cli-tui.test.mjs",
|
|
56
|
+
"test:agent-state": "node --experimental-strip-types --test test/agent-state.test.mjs test/reconnect-chaos.test.mjs",
|
|
57
|
+
"test:tui": "node --test test/cli-tui.test.mjs test/toolcall-context.test.mjs test/cli-demo.test.mjs",
|
|
54
58
|
"test:config-security": "node --test test/config-security.test.mjs",
|
|
55
59
|
"test:self-update": "node --test test/self-update.test.mjs test/agent-lifecycle-upgrade.test.mjs",
|
|
56
60
|
"test:budget": "node --test test/relay-health.test.mjs test/usage-budget.test.mjs",
|
|
@@ -58,8 +62,9 @@
|
|
|
58
62
|
"test:hardening": "npm run test:tool-guidance && npm run test:tui && npm run test:config-security && npm run test:self-update && npm run test:budget && npm run test:worker-hotpath && node --test test/connection-generation.test.mjs && npm run test:agent-state && node test/heartbeat-ack-watchdog.test.mjs && npm run test:no-quota && npm run test:usage-storage && npm run test:learn && npm run test:learn-bootstrap && npm run test:soak",
|
|
59
63
|
"test:tool-guidance": "node --test test/tool-error-guidance.test.mjs",
|
|
60
64
|
"verify:review": "node scripts/verify-review-artifacts.mjs",
|
|
61
|
-
"test:learn": "node test/learning-smoke.mjs",
|
|
62
|
-
"test:learn-
|
|
65
|
+
"test:learn": "node test/learning-smoke.mjs && node test/project-alias-sqlite.test.mjs && node test/project-merge-mcp.test.mjs && node --test test/shared-learn.test.mjs test/shared-learn-ui.test.mjs && npm run test:learn-usage",
|
|
66
|
+
"test:learn-usage": "node test/learn-usage.test.mjs && node test/learn-usage-integration.test.mjs && node test/learn-usage-mcp.test.mjs",
|
|
67
|
+
"test:learn-bootstrap": "node test/learning-bootstrap-smoke.mjs && node test/learning-thai-fixtures.mjs",
|
|
63
68
|
"test:worker-hotpath": "node --experimental-strip-types --test test/relay-result.test.mjs"
|
|
64
69
|
},
|
|
65
70
|
"dependencies": {
|