visualproof 0.10.0 → 0.11.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 +6 -3
- package/dist/mcp/visualproof-mcp.mjs +12 -7
- package/dist/server/agent.js +7 -1
- package/dist/server/agententry.js +18 -7
- package/dist/server/agenttalk.js +46 -4
- package/dist/server/app.js +4 -3
- package/dist/server/appagent.js +7 -1
- package/dist/server/appshare.js +22 -117
- package/dist/server/apptalk.js +39 -25
- package/dist/server/children.js +1 -1
- package/dist/server/doctor.js +4 -3
- package/dist/server/hosted.js +475 -260
- package/dist/server/live.js +49 -24
- package/dist/server/main.js +26 -9
- package/dist/server/mcptools.js +2 -2
- package/dist/server/options.js +38 -14
- package/dist/server/prompt.js +19 -11
- package/dist/server/serveragent.js +117 -0
- package/dist/server/talk.js +39 -3
- package/dist/server/tokens.js +12 -2
- package/dist/shared/collab.js +12 -5
- package/dist/web/bundle/app.js +247 -131
- package/dist/web/index.html +1 -1
- package/dist/web/style.css +30 -10
- package/docs/agent-api/mcp.md +4 -3
- package/docs/agent-api/talking.md +23 -6
- package/package.json +1 -1
- package/dist/server/claudetokens.js +0 -113
package/dist/server/apptalk.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// People on the page with one another (the routes of server/app.ts): where each one is, which the
|
|
2
2
|
// others see (presence: CollabSpec decisions 4 and 8), asking others to follow (decision 10), and
|
|
3
3
|
// the conversations (decision 13, AgentSpec decision 8) — the public channel, each agent's private
|
|
4
|
-
// one with its maker,
|
|
4
|
+
// one with its maker, each person's own with the server's agent (AgentSpec decision 10), a new
|
|
5
|
+
// conversation there. Agents do all of it through their API.
|
|
5
6
|
import { agentPlace, cleanFollowing, cleanView, madeBy, nameKey } from "../shared/collab.js";
|
|
6
|
-
import { forPages, MAX_PERSON, PUBLIC, THREAD } from "./talk.js";
|
|
7
|
+
import { forPages, MAX_PERSON, personalChannel, PUBLIC, THREAD } from "./talk.js";
|
|
7
8
|
import { mentioned } from "../shared/mentions.js";
|
|
8
9
|
import { sendJson } from "./send.js";
|
|
9
10
|
import { placeOf } from "./agentfollow.js";
|
|
@@ -46,7 +47,9 @@ export async function pointer(app, req, res) {
|
|
|
46
47
|
/** The conversations (CollabSpec decision 13, AgentSpec decision 8), for pages: a channel read
|
|
47
48
|
* (GET ?channel=public|<agent id>&before=<id>, the newest 200 first) and a message written in it
|
|
48
49
|
* (POST {channel, text, place}). Everyone with a name reads and writes the public channel; an
|
|
49
|
-
* agent's private channel is its maker's alone (shared/collab.ts, madeBy: 403 to anyone else)
|
|
50
|
+
* agent's private channel is its maker's alone (shared/collab.ts, madeBy: 403 to anyone else); the
|
|
51
|
+
* server's own agent's id names the reader's own channel with it, whoever they are (AgentSpec
|
|
52
|
+
* decision 10: an invited person's by their personal link, anyone else's by their name).
|
|
50
53
|
* A read-only reader neither sees nor writes any (403), whatever the page sends; agents talk
|
|
51
54
|
* through their API. A private channel cannot be written to while its agent is offline (409); a
|
|
52
55
|
* mention of it in the public channel can, and is handed to it when it comes back. At most so
|
|
@@ -68,13 +71,14 @@ export async function chat(app, req, res, url) {
|
|
|
68
71
|
const channelOf = (raw) => {
|
|
69
72
|
if (raw === "public" || raw === undefined || raw === null || raw === "")
|
|
70
73
|
return { key: PUBLIC, agent: null };
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
if (!tok || !record)
|
|
74
|
+
const record = privateOf(app, raw);
|
|
75
|
+
if (!record)
|
|
74
76
|
return { status: 404, body: { error: "There is no such channel: public, or the id of an agent with a token of its own." } };
|
|
77
|
+
if (record.runs === "server")
|
|
78
|
+
return { key: personalChannel(record.id, who), agent: { id: raw, record } };
|
|
75
79
|
if (!madeBy(record, who))
|
|
76
80
|
return { status: 403, body: { error: `${record.name}'s private channel is ${record.by}'s, who made its token: nobody else reads or writes it.`, private: true } };
|
|
77
|
-
return { key:
|
|
81
|
+
return { key: record.id, agent: { id: raw, record } };
|
|
78
82
|
};
|
|
79
83
|
if (req.method === "GET") {
|
|
80
84
|
const c = channelOf(url.searchParams.get("channel") ?? url.searchParams.get("agent"));
|
|
@@ -85,7 +89,9 @@ export async function chat(app, req, res, url) {
|
|
|
85
89
|
const messages = live.talk.thread(c.key, THREAD, before).map(forPages);
|
|
86
90
|
if (!c.agent)
|
|
87
91
|
return sendJson(res, { channel: PUBLIC, messages });
|
|
88
|
-
|
|
92
|
+
// the server's agent: its state in this reader's own conversation with it
|
|
93
|
+
const talk = c.agent.record.runs === "server" ? live.hosted.sessionTalk(c.key) : live.talk.talk(c.key);
|
|
94
|
+
return sendJson(res, { channel: c.agent.id, agent: { id: c.agent.id, name: c.agent.record.name, talk, ...(c.agent.record.runs ? { runs: c.agent.record.runs } : {}) }, messages });
|
|
89
95
|
}
|
|
90
96
|
const r = await app.json(req, 1 << 16);
|
|
91
97
|
if (r.error !== undefined)
|
|
@@ -94,7 +100,7 @@ export async function chat(app, req, res, url) {
|
|
|
94
100
|
const c = channelOf(b.channel ?? b.agent);
|
|
95
101
|
if ("status" in c)
|
|
96
102
|
return sendJson(res, c.body, c.status);
|
|
97
|
-
if (c.agent && live.talk.state(c.
|
|
103
|
+
if (c.agent && live.talk.state(c.agent.record.id) === "offline")
|
|
98
104
|
return sendJson(res, { error: "offline", message: `${c.agent.record.name} is offline: it can be written to once it listens again.` }, 409);
|
|
99
105
|
const text = typeof b.text === "string" ? b.text.trim() : "";
|
|
100
106
|
if (!text)
|
|
@@ -120,7 +126,9 @@ export async function chat(app, req, res, url) {
|
|
|
120
126
|
/** A new conversation in an agent's private channel (AgentSpec decision 8, the owner's decisions
|
|
121
127
|
* of 2026-10-11 and 2026-10-19): a divider, from its maker alone, held to the rate of their
|
|
122
128
|
* messages; an offline agent's too, so that its next session starts clean. One right after
|
|
123
|
-
* another divides nothing: it is answered `unchanged`, and neither written nor counted.
|
|
129
|
+
* another divides nothing: it is answered `unchanged`, and neither written nor counted. With the
|
|
130
|
+
* server's own agent, in the reader's own conversation with it: a new session of that one alone
|
|
131
|
+
* (AgentSpec decision 10). */
|
|
124
132
|
export async function chatNew(app, req, res) {
|
|
125
133
|
const live = app.live;
|
|
126
134
|
if (req.method !== "POST")
|
|
@@ -136,24 +144,33 @@ export async function chatNew(app, req, res) {
|
|
|
136
144
|
if (r.error !== undefined)
|
|
137
145
|
return sendJson(res, { error: `The body is ${r.error}.` }, 400);
|
|
138
146
|
const b = (r.body ?? {});
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
if (!tok || !record)
|
|
147
|
+
const record = privateOf(app, b.agent);
|
|
148
|
+
if (!record)
|
|
142
149
|
return sendJson(res, { error: "There is no such agent: only an agent with a token of its own has a private channel." }, 404);
|
|
143
150
|
const person = app.ids.person(req)?.id ?? null;
|
|
144
|
-
if (!madeBy(record, { name: me, person }))
|
|
151
|
+
if (record.runs !== "server" && !madeBy(record, { name: me, person }))
|
|
145
152
|
return sendJson(res, { error: `Only ${record.by}, who made ${record.name}'s token, starts a new conversation with it.`, private: true }, 403);
|
|
146
|
-
|
|
153
|
+
const key = record.runs === "server" ? personalChannel(record.id, { name: me, person }) : record.id;
|
|
154
|
+
if (live.talk.fresh(key))
|
|
147
155
|
return sendJson(res, { ok: true, unchanged: true, divider: null, message: "Nothing was said since the conversation began: it is new already." });
|
|
148
156
|
const wait = live.talk.allow("person", person ? `p:${person}` : `n:${nameKey(me)}`);
|
|
149
157
|
if (wait)
|
|
150
158
|
return sendJson(res, { error: `Too many at once: wait ${wait} s.`, retryAfter: wait }, 429, { "retry-after": String(wait) });
|
|
151
|
-
const divider = live.talk.restart(
|
|
159
|
+
const divider = live.talk.restart(key, me);
|
|
152
160
|
return sendJson(res, { ok: true, divider: divider && forPages(divider) });
|
|
153
161
|
}
|
|
154
|
-
/**
|
|
155
|
-
*
|
|
156
|
-
|
|
162
|
+
/** The agent a page names by its id in presence, that has a private channel: one with a token in
|
|
163
|
+
* force, listed — the server's own agent while the server runs it. */
|
|
164
|
+
function privateOf(app, raw) {
|
|
165
|
+
const tok = typeof raw === "string" ? app.live.presence.tokenOf(raw) : null;
|
|
166
|
+
const record = tok ? app.live.tokens.get(tok) : undefined;
|
|
167
|
+
if (!record || (record.runs === "server" && app.live.hosted?.id !== record.id))
|
|
168
|
+
return null;
|
|
169
|
+
return record;
|
|
170
|
+
}
|
|
171
|
+
/** Stop the turn the server's own agent is taking in the reader's own conversation with it
|
|
172
|
+
* (AgentSpec decision 10): POST /api/chat/stop {agent}, as Esc in a terminal stops an agent someone
|
|
173
|
+
* runs there. What it was answering ends with it; nobody stops another's, nor the public one's. */
|
|
157
174
|
export async function chatStop(app, req, res) {
|
|
158
175
|
const live = app.live;
|
|
159
176
|
if (req.method !== "POST")
|
|
@@ -169,13 +186,10 @@ export async function chatStop(app, req, res) {
|
|
|
169
186
|
if (r.error !== undefined)
|
|
170
187
|
return sendJson(res, { error: `The body is ${r.error}.` }, 400);
|
|
171
188
|
const b = (r.body ?? {});
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
if (!tok || !record || record.runs !== "server")
|
|
189
|
+
const record = privateOf(app, b.agent);
|
|
190
|
+
if (!record || record.runs !== "server")
|
|
175
191
|
return sendJson(res, { error: "There is no such agent running on this server." }, 404);
|
|
176
|
-
|
|
177
|
-
return sendJson(res, { error: `Only ${record.by}, who runs ${record.name}, stops its turn.` }, 403);
|
|
178
|
-
return sendJson(res, { ok: true, stopped: live.hosted?.stopTurn(tok) ?? false });
|
|
192
|
+
return sendJson(res, { ok: true, stopped: live.hosted.stopTurn(personalChannel(record.id, { name: me, person: app.ids.person(req)?.id ?? null })) });
|
|
179
193
|
}
|
|
180
194
|
/** Asking others to follow (CollabSpec decision 10, the owner's decision of 2026-10-12), for pages:
|
|
181
195
|
* POST /api/ask {token, to?} — the page whose event stream holds `token` asks everyone on the
|
package/dist/server/children.js
CHANGED
|
@@ -57,7 +57,7 @@ export function childEnv(extra = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
/** Claude's and Anthropic's credentials, where the server's environment has them: no program the
|
|
59
59
|
* server runs is given them (Lake, Lean, git, a branch's build, which runs whatever its code says);
|
|
60
|
-
* the
|
|
60
|
+
* the server's own agent is given the --claude-oauth token alone (server/hosted.ts). */
|
|
61
61
|
const CREDENTIAL = (k) => k === "CLAUDE_CODE_OAUTH_TOKEN" || k.startsWith("ANTHROPIC_");
|
|
62
62
|
/** How many tracked programs run now. */
|
|
63
63
|
export function childCount() {
|
package/dist/server/doctor.js
CHANGED
|
@@ -183,12 +183,13 @@ export function doctor(o) {
|
|
|
183
183
|
if (exec("git", ["--version"]) === null) {
|
|
184
184
|
checks.push({ level: "info", what: "git not found: builds are kept without their commit, and past sources only as the builds kept them; a branch cannot be followed (serve <git URL>)" });
|
|
185
185
|
}
|
|
186
|
-
// the
|
|
186
|
+
// the server's own agent (--claude-oauth, AgentSpec decision 10): Claude Code, and how to give it
|
|
187
|
+
// its token
|
|
187
188
|
const claude = findClaude();
|
|
188
189
|
const claudeVersion = exec(o.run ? "claude" : (claude ?? "claude"), ["--version"]);
|
|
189
190
|
checks.push(claudeVersion
|
|
190
|
-
? { level: "ok", what: `Claude Code ${claudeVersion.trim().split(/\s/)[0]} (for --claude-oauth,
|
|
191
|
-
: { level: "info", what: "Claude Code (claude) not found: needed only for --claude-oauth (
|
|
191
|
+
? { level: "ok", what: `Claude Code ${claudeVersion.trim().split(/\s/)[0]} (for --claude-oauth, the server's own agent: claude setup-token prints its token; put it alone in a file, chmod 600, and give --claude-oauth <file>, or --claude-oauth env with CLAUDE_CODE_OAUTH_TOKEN set)` }
|
|
192
|
+
: { level: "info", what: "Claude Code (claude) not found: needed only for --claude-oauth (the server's own agent)", fix: "npm install -g @anthropic-ai/claude-code, then claude setup-token: its token alone in a file (chmod 600), and serve … --claude-oauth <file>" });
|
|
192
193
|
const film = filmLine(o.cache ? resolve(o.cache) : cacheHome(), o.updates ?? process.env.VISUALPROOF_UPDATES);
|
|
193
194
|
const updates = updatesLine(exec, node, o.fromPackage ?? FROM_PACKAGE, o.cache ? resolve(o.cache) : cacheHome(), o.updates ?? process.env.VISUALPROOF_UPDATES, o.path === null ? null : projectDirs(resolve(o.path), o.site, o.cache).site);
|
|
194
195
|
if (o.path === null)
|