agentface 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/dist/agentface.mjs +539 -70
  2. package/package.json +2 -2
@@ -3,10 +3,447 @@
3
3
  // cli/agentface.mts
4
4
  import { parseArgs } from "node:util";
5
5
 
6
+ // cli/connect.mts
7
+ import { execFile } from "node:child_process";
8
+ import { createHash, randomBytes } from "node:crypto";
9
+ import { chmod, mkdir, open as openFile, readFile, rm, stat, writeFile } from "node:fs/promises";
10
+ import { createServer } from "node:http";
11
+ import { homedir } from "node:os";
12
+ import path from "node:path";
13
+ var DEFAULT_SERVER = "https://agentface.com";
14
+ var MCP_PATH = "/mcp";
15
+ var PROTOCOL = "2025-06-18";
16
+ var LOGIN_WAIT_MS = 5 * 6e4;
17
+ var configDirOf = (env = process.env) => env.AGENTFACE_CONFIG_DIR || path.join(env.XDG_CONFIG_HOME || path.join(homedir(), ".config"), "agentface");
18
+ var fileIn = (dir) => path.join(dir, "credentials.json");
19
+ var normal = (server) => server.replace(/\/+$/, "");
20
+ async function readKept(dir, server) {
21
+ const all = JSON.parse(await readFile(fileIn(dir), "utf8").catch(() => "{}"));
22
+ return all[server] ?? null;
23
+ }
24
+ async function writeKept(dir, server, kept) {
25
+ const all = JSON.parse(await readFile(fileIn(dir), "utf8").catch(() => "{}"));
26
+ if (kept) all[server] = kept;
27
+ else delete all[server];
28
+ if (!Object.keys(all).length) return rm(fileIn(dir), { force: true });
29
+ await mkdir(dir, { recursive: true, mode: 448 });
30
+ await writeFile(fileIn(dir), `${JSON.stringify(all, null, 2)}
31
+ `, { mode: 384 });
32
+ await chmod(fileIn(dir), 384);
33
+ }
34
+ var LOCK_STALE_MS = 3e4;
35
+ async function alone(dir, work) {
36
+ const lock = path.join(dir, "credentials.lock");
37
+ await mkdir(dir, { recursive: true, mode: 448 });
38
+ for (; ; ) {
39
+ try {
40
+ await (await openFile(lock, "wx", 384)).close();
41
+ break;
42
+ } catch (error) {
43
+ if (error.code !== "EEXIST") throw error;
44
+ const made = await stat(lock).catch(() => null);
45
+ if (!made || Date.now() - made.mtimeMs > LOCK_STALE_MS) await rm(lock, { force: true });
46
+ else await new Promise((done) => setTimeout(done, 50));
47
+ }
48
+ }
49
+ try {
50
+ return await work();
51
+ } finally {
52
+ await rm(lock, { force: true });
53
+ }
54
+ }
55
+ async function json(fetcher, url, init2, server) {
56
+ let response;
57
+ try {
58
+ response = await fetcher(url, init2);
59
+ } catch (error) {
60
+ throw new Error(`Could not reach agentface at ${server}: ${error.message}`, { cause: error });
61
+ }
62
+ const body = await response.json().catch(() => null);
63
+ return { response, body };
64
+ }
65
+ var said = (body, fallback) => typeof body?.error_description === "string" && body.error_description ? body.error_description : fallback;
66
+ async function discover(fetcher, server) {
67
+ const resource = await json(
68
+ fetcher,
69
+ `${server}/.well-known/oauth-protected-resource${MCP_PATH}`,
70
+ { headers: { accept: "application/json" } },
71
+ server
72
+ );
73
+ const issuers = resource.body?.authorization_servers;
74
+ const issuer = Array.isArray(issuers) && typeof issuers[0] === "string" ? normal(issuers[0]) : server;
75
+ const found = await json(
76
+ fetcher,
77
+ `${issuer}/.well-known/oauth-authorization-server`,
78
+ { headers: { accept: "application/json" } },
79
+ server
80
+ );
81
+ const text = (name) => typeof found.body?.[name] === "string" ? found.body[name] : "";
82
+ const [register2, authorize, token] = [
83
+ text("registration_endpoint"),
84
+ text("authorization_endpoint"),
85
+ text("token_endpoint")
86
+ ];
87
+ if (!found.response.ok || !register2 || !authorize || !token)
88
+ throw new Error(`${server} doesn't say how an agent signs in to it. Is that agentface's address?`);
89
+ return { register: register2, authorize, token, revoke: text("revocation_endpoint") || null };
90
+ }
91
+ function openInBrowser(url) {
92
+ const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", '""', url.replace(/&/g, "^&")]] : ["xdg-open", [url]];
93
+ return new Promise((done) => execFile(command, args, (error) => done(!error)));
94
+ }
95
+ var page = (title, words) => `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>agentface</title><meta name="viewport" content="width=device-width, initial-scale=1"></head><body style="font-family: system-ui, sans-serif; max-width: 30rem; margin: 20vh auto; padding: 0 1.5rem; line-height: 1.5"><h1 style="font-size: 1.25rem">${title}</h1><p>${words}</p></body></html>`;
96
+ async function login({
97
+ server = DEFAULT_SERVER,
98
+ fetch: fetcher = fetch,
99
+ log = console.log,
100
+ configDir = configDirOf(),
101
+ open = openInBrowser,
102
+ now = Date.now
103
+ } = {}) {
104
+ server = normal(server);
105
+ const endpoints = await discover(fetcher, server);
106
+ const state = randomBytes(16).toString("base64url");
107
+ const verifier = randomBytes(32).toString("base64url");
108
+ let arrived = () => {
109
+ };
110
+ const came = new Promise((done) => arrived = done);
111
+ const listener = createServer((req, res) => {
112
+ const url = new URL(req.url ?? "/", "http://127.0.0.1");
113
+ if (url.pathname !== "/callback") {
114
+ res.writeHead(404).end();
115
+ return;
116
+ }
117
+ const ours = url.searchParams.get("state") === state;
118
+ const code = url.searchParams.get("code");
119
+ const error = url.searchParams.get("error");
120
+ const ok = ours && !!code;
121
+ res.writeHead(ok ? 200 : 400, {
122
+ "content-type": "text/html; charset=utf-8",
123
+ "cache-control": "no-store",
124
+ connection: "close"
125
+ });
126
+ res.end(
127
+ ok ? page(
128
+ "This machine is connected to agentface.",
129
+ "You can close this tab and go back to the terminal."
130
+ ) : page(
131
+ "Nothing was connected.",
132
+ ours && error === "access_denied" ? "You didn\u2019t allow it. Run the command again to start over." : "This isn\u2019t the answer the command was waiting for. Run it again to start over."
133
+ )
134
+ );
135
+ if (ours) arrived(code ? { code } : { error: error ?? "no code came back" });
136
+ });
137
+ await new Promise((done) => listener.listen(0, "127.0.0.1", done));
138
+ const redirect = `http://127.0.0.1:${listener.address().port}/callback`;
139
+ try {
140
+ const registered = await json(
141
+ fetcher,
142
+ endpoints.register,
143
+ {
144
+ method: "POST",
145
+ headers: { "content-type": "application/json", accept: "application/json" },
146
+ body: JSON.stringify({
147
+ client_name: "agentface CLI",
148
+ redirect_uris: [redirect],
149
+ token_endpoint_auth_method: "none"
150
+ })
151
+ },
152
+ server
153
+ );
154
+ const clientId = registered.body?.client_id;
155
+ if (!registered.response.ok || typeof clientId !== "string")
156
+ throw new Error(
157
+ `agentface didn't take the sign-in: ${said(registered.body, `it answered ${registered.response.status}`)}`
158
+ );
159
+ const ask = new URL(endpoints.authorize);
160
+ for (const [name, value] of Object.entries({
161
+ response_type: "code",
162
+ client_id: clientId,
163
+ redirect_uri: redirect,
164
+ code_challenge: createHash("sha256").update(verifier).digest("base64url"),
165
+ code_challenge_method: "S256",
166
+ state,
167
+ resource: `${server}${MCP_PATH}`
168
+ }))
169
+ ask.searchParams.set(name, value);
170
+ const opened = await open(ask.href);
171
+ log(
172
+ opened ? "Your browser is opening agentface. Allow the connection there." : "Open this address in your browser, and allow the connection there:"
173
+ );
174
+ log(`
175
+ ${ask.href}
176
+ `);
177
+ let timer;
178
+ const answer = await Promise.race([
179
+ came,
180
+ new Promise(
181
+ (done) => timer = setTimeout(() => done({ error: "nobody allowed it in five minutes" }), LOGIN_WAIT_MS)
182
+ )
183
+ ]);
184
+ clearTimeout(timer);
185
+ if ("error" in answer)
186
+ throw new Error(
187
+ answer.error === "access_denied" ? "Nothing was connected: you didn\u2019t allow it." : `Nothing was connected: ${answer.error}.`
188
+ );
189
+ const traded = await json(
190
+ fetcher,
191
+ endpoints.token,
192
+ {
193
+ method: "POST",
194
+ headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
195
+ body: new URLSearchParams({
196
+ grant_type: "authorization_code",
197
+ code: answer.code,
198
+ code_verifier: verifier,
199
+ client_id: clientId,
200
+ redirect_uri: redirect
201
+ }).toString()
202
+ },
203
+ server
204
+ );
205
+ const kept = keptFrom(
206
+ traded.body,
207
+ { server, clientId, tokenEndpoint: endpoints.token, revocationEndpoint: endpoints.revoke },
208
+ now()
209
+ );
210
+ if (!traded.response.ok || !kept)
211
+ throw new Error(
212
+ `agentface didn't finish the sign-in: ${said(traded.body, `it answered ${traded.response.status}`)}`
213
+ );
214
+ await writeKept(configDir, server, kept);
215
+ log(`Connected to ${server}. Try: agentface mcp tools`);
216
+ } finally {
217
+ listener.closeAllConnections?.();
218
+ listener.close();
219
+ }
220
+ }
221
+ function keptFrom(body, rest, at) {
222
+ if (typeof body?.access_token !== "string" || typeof body.refresh_token !== "string") return null;
223
+ const seconds = typeof body.expires_in === "number" ? body.expires_in : 3600;
224
+ return { ...rest, access: body.access_token, refresh: body.refresh_token, expiresAt: at + seconds * 1e3 };
225
+ }
226
+ async function logout({
227
+ server = DEFAULT_SERVER,
228
+ fetch: fetcher = fetch,
229
+ log = console.log,
230
+ configDir = configDirOf()
231
+ } = {}) {
232
+ server = normal(server);
233
+ const kept = await readKept(configDir, server);
234
+ if (!kept) return log(`This machine isn't connected to ${server}.`);
235
+ if (kept.revocationEndpoint) {
236
+ const ended = await fetcher(kept.revocationEndpoint, {
237
+ method: "POST",
238
+ headers: { "content-type": "application/x-www-form-urlencoded" },
239
+ body: new URLSearchParams({ token: kept.refresh }).toString()
240
+ }).then(
241
+ (response) => response.ok,
242
+ () => false
243
+ );
244
+ if (!ended)
245
+ throw new Error(
246
+ `agentface at ${server} couldn't be reached, so the connection is still open. Run the command again in a moment, or disconnect this machine at ${server}/account.`
247
+ );
248
+ }
249
+ await writeKept(configDir, server, null);
250
+ log(`Disconnected from ${server}.`);
251
+ }
252
+ var NOT_CONNECTED = (server) => `This machine isn't connected to ${server}. Run: npx agentface login${server === DEFAULT_SERVER ? "" : ` --server ${server}`}`;
253
+ async function current({
254
+ server,
255
+ fetcher,
256
+ configDir,
257
+ now,
258
+ force = false
259
+ }) {
260
+ const fresh = (kept) => kept.expiresAt - now() > 6e4;
261
+ const first = await readKept(configDir, server);
262
+ if (!first) throw new Error(NOT_CONNECTED(server));
263
+ if (!force && fresh(first)) return first;
264
+ return alone(configDir, () => renew({ server, fetcher, configDir, now, used: first }));
265
+ }
266
+ async function renew({
267
+ server,
268
+ fetcher,
269
+ configDir,
270
+ now,
271
+ used
272
+ }) {
273
+ const kept = await readKept(configDir, server);
274
+ if (!kept) throw new Error(NOT_CONNECTED(server));
275
+ if (kept.access !== used.access && kept.expiresAt - now() > 6e4) return kept;
276
+ const renewed = await json(
277
+ fetcher,
278
+ kept.tokenEndpoint,
279
+ {
280
+ method: "POST",
281
+ headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
282
+ body: new URLSearchParams({
283
+ grant_type: "refresh_token",
284
+ refresh_token: kept.refresh,
285
+ client_id: kept.clientId
286
+ }).toString()
287
+ },
288
+ server
289
+ );
290
+ const next = keptFrom(renewed.body, kept, now());
291
+ if (!renewed.response.ok || !next) {
292
+ if (renewed.response.status === 400 || renewed.response.status === 401) {
293
+ await writeKept(configDir, server, null);
294
+ throw new Error(
295
+ `The connection to ${server} has ended. Run: npx agentface login${server === DEFAULT_SERVER ? "" : ` --server ${server}`}`
296
+ );
297
+ }
298
+ throw new Error(
299
+ `agentface couldn't renew the connection: ${said(renewed.body, `it answered ${renewed.response.status}`)}`
300
+ );
301
+ }
302
+ await writeKept(configDir, server, next);
303
+ return next;
304
+ }
305
+ async function post(fetcher, server, access, message, negotiated) {
306
+ let response;
307
+ try {
308
+ response = await fetcher(`${server}${MCP_PATH}`, {
309
+ method: "POST",
310
+ headers: {
311
+ authorization: `Bearer ${access}`,
312
+ "content-type": "application/json",
313
+ accept: "application/json, text/event-stream",
314
+ ...negotiated ? { "mcp-protocol-version": negotiated } : {}
315
+ },
316
+ body: JSON.stringify(message)
317
+ });
318
+ } catch (error) {
319
+ throw new Error(`Could not reach agentface at ${server}: ${error.message}`, { cause: error });
320
+ }
321
+ const text = await response.text();
322
+ if (!text) return { status: response.status, reply: null };
323
+ const data = /event-stream/.test(response.headers.get("content-type") ?? "") ? text.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).at(-1) : text;
324
+ try {
325
+ return { status: response.status, reply: JSON.parse(data ?? "") };
326
+ } catch {
327
+ return { status: response.status, reply: null };
328
+ }
329
+ }
330
+ async function request(method, params, options = {}) {
331
+ const { fetch: fetcher = fetch, configDir = configDirOf(), now = Date.now } = options;
332
+ const server = normal(options.server ?? DEFAULT_SERVER);
333
+ let kept = await current({ server, fetcher, configDir, now });
334
+ const hello = {
335
+ jsonrpc: "2.0",
336
+ id: 1,
337
+ method: "initialize",
338
+ params: {
339
+ protocolVersion: PROTOCOL,
340
+ capabilities: {},
341
+ clientInfo: { name: "agentface-cli", version: "1" }
342
+ }
343
+ };
344
+ let greeted = await post(fetcher, server, kept.access, hello);
345
+ if (greeted.status === 401) {
346
+ kept = await current({ server, fetcher, configDir, now, force: true });
347
+ greeted = await post(fetcher, server, kept.access, hello);
348
+ }
349
+ if (greeted.status === 401) throw new Error(NOT_CONNECTED(server));
350
+ if (!greeted.reply?.result)
351
+ throw new Error(
352
+ `agentface didn't answer (${greeted.status})${greeted.reply?.error ? `: ${greeted.reply.error.message}` : ""}. Try again in a moment.`
353
+ );
354
+ const version = typeof greeted.reply.result.protocolVersion === "string" ? greeted.reply.result.protocolVersion : PROTOCOL;
355
+ await post(fetcher, server, kept.access, { jsonrpc: "2.0", method: "notifications/initialized" }, version);
356
+ const { status, reply } = await post(
357
+ fetcher,
358
+ server,
359
+ kept.access,
360
+ { jsonrpc: "2.0", id: 2, method, params },
361
+ version
362
+ );
363
+ if (reply?.error) throw new Error(reply.error.message);
364
+ if (!reply?.result) throw new Error(`agentface didn't answer (${status}). Try again in a moment.`);
365
+ return reply.result;
366
+ }
367
+ function readArguments(given) {
368
+ if (given.length === 1 && given[0].trim().startsWith("{")) {
369
+ let parsed;
370
+ try {
371
+ parsed = JSON.parse(given[0]);
372
+ } catch {
373
+ throw new Error("The arguments aren\u2019t JSON. Write them as key=value, or as one JSON object in quotes.");
374
+ }
375
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
376
+ throw new Error("The arguments are one JSON object.");
377
+ return parsed;
378
+ }
379
+ const args = {};
380
+ for (const pair of given) {
381
+ const at = pair.indexOf("=");
382
+ if (at < 1)
383
+ throw new Error(`"${pair}" isn't an argument. Write each as key=value, such as siteId=site-shop.`);
384
+ const value = pair.slice(at + 1);
385
+ args[pair.slice(0, at)] = /^(-?\d+(\.\d+)?|true|false|null)$/.test(value) ? JSON.parse(value) : value;
386
+ }
387
+ return args;
388
+ }
389
+ var MCP_HELP = `Usage:
390
+ agentface mcp tools List agentface's functions, with what each takes.
391
+ agentface mcp call <name> [key=value \u2026] Call one, and print what it returned.
392
+ Arguments can also be one JSON object in quotes.
393
+
394
+ Options:
395
+ --json Print the answer as JSON, as the protocol carries it
396
+ --server agentface's address (default ${DEFAULT_SERVER})
397
+
398
+ Connect this machine first with: agentface login`;
399
+ async function mcp(args, options = {}) {
400
+ const { log = console.log } = options;
401
+ const [action, name, ...rest] = args;
402
+ if (!action || action === "help") {
403
+ log(MCP_HELP);
404
+ return 0;
405
+ }
406
+ if (action === "tools" || action === "list") {
407
+ const result = await request("tools/list", {}, options);
408
+ const tools = Array.isArray(result.tools) ? result.tools : [];
409
+ if (options.json) {
410
+ log(JSON.stringify(result, null, 2));
411
+ return 0;
412
+ }
413
+ for (const tool of tools) {
414
+ const properties = tool.inputSchema?.properties ?? {};
415
+ const required = tool.inputSchema?.required ?? [];
416
+ const takes = Object.entries(properties).map(([key, value]) => {
417
+ const kind = value.enum ? value.enum.join("|") : value.type ?? "value";
418
+ return required.includes(key) ? `${key}=<${kind}>` : `[${key}=<${kind}>]`;
419
+ });
420
+ log(
421
+ `${tool.name}${takes.length ? ` ${takes.join(" ")}` : ""}${tool.annotations?.readOnlyHint === false ? " (changes something)" : ""}`
422
+ );
423
+ if (tool.description) log(` ${tool.description}`);
424
+ }
425
+ return 0;
426
+ }
427
+ if (action === "call") {
428
+ if (!name) throw new Error(`Which function? agentface mcp tools lists them.
429
+
430
+ ${MCP_HELP}`);
431
+ const result = await request("tools/call", { name, arguments: readArguments(rest) }, options);
432
+ if (options.json) log(JSON.stringify(result, null, 2));
433
+ else
434
+ for (const part of Array.isArray(result.content) ? result.content : [])
435
+ if (part.type === "text" && typeof part.text === "string") log(part.text);
436
+ return result.isError === true ? 1 : 0;
437
+ }
438
+ throw new Error(`Unknown: agentface mcp ${action}.
439
+
440
+ ${MCP_HELP}`);
441
+ }
442
+
6
443
  // cli/init.mts
7
- import { execFile as execFile2 } from "node:child_process";
8
- import { mkdir, readFile as readFile2, rm, rmdir, writeFile } from "node:fs/promises";
9
- import path2 from "node:path";
444
+ import { execFile as execFile3 } from "node:child_process";
445
+ import { mkdir as mkdir2, readFile as readFile3, rm as rm2, rmdir, writeFile as writeFile2 } from "node:fs/promises";
446
+ import path3 from "node:path";
10
447
 
11
448
  // worker/origin.ts
12
449
  var PRIVATE_NAMES = /(?:^|\.)(?:localhost|local|internal|lan|intranet|corp|home|arpa)$/;
@@ -41,9 +478,9 @@ function siteNotice(serviceOrigin, id) {
41
478
  }
42
479
 
43
480
  // cli/heads.mts
44
- import { execFile } from "node:child_process";
45
- import { readdir, readFile, stat } from "node:fs/promises";
46
- import path from "node:path";
481
+ import { execFile as execFile2 } from "node:child_process";
482
+ import { readdir, readFile as readFile2, stat as stat2 } from "node:fs/promises";
483
+ import path2 from "node:path";
47
484
 
48
485
  // worker/head.ts
49
486
  var ATTRIBUTES = String.raw`(?:\{[^{}]*(?:\{[^{}]*\}[^{}]*)*\}|"[^"]*"|'[^']*'|[^>"'{/]|\/(?!>))*`;
@@ -78,7 +515,7 @@ function zip(files2, date = /* @__PURE__ */ new Date()) {
78
515
  for (const [name, text] of Object.entries(files2)) {
79
516
  const data = Buffer.from(text);
80
517
  const packed = deflateRawSync(data);
81
- const path3 = Buffer.from(name);
518
+ const path4 = Buffer.from(name);
82
519
  const shared = Buffer.alloc(26);
83
520
  shared.writeUInt16LE(20, 0);
84
521
  shared.writeUInt16LE(2048, 2);
@@ -88,18 +525,18 @@ function zip(files2, date = /* @__PURE__ */ new Date()) {
88
525
  shared.writeUInt32LE(crc32(data), 10);
89
526
  shared.writeUInt32LE(packed.length, 14);
90
527
  shared.writeUInt32LE(data.length, 18);
91
- shared.writeUInt16LE(path3.length, 22);
528
+ shared.writeUInt16LE(path4.length, 22);
92
529
  const local = Buffer.alloc(4);
93
530
  local.writeUInt32LE(67324752);
94
- parts.push(local, shared, path3, packed);
531
+ parts.push(local, shared, path4, packed);
95
532
  const entry = Buffer.alloc(46);
96
533
  entry.writeUInt32LE(33639248, 0);
97
534
  entry.writeUInt16LE(788, 4);
98
535
  shared.copy(entry, 6);
99
536
  entry.writeUInt32LE(33188 * 65536, 38);
100
537
  entry.writeUInt32LE(offset, 42);
101
- directory.push(entry, path3);
102
- offset += 4 + shared.length + path3.length + packed.length;
538
+ directory.push(entry, path4);
539
+ offset += 4 + shared.length + path4.length + packed.length;
103
540
  }
104
541
  const size = directory.reduce((total, part) => total + part.length, 0);
105
542
  const end = Buffer.alloc(22);
@@ -185,33 +622,33 @@ var FRAMEWORKS = [
185
622
  ["@vue/cli-service", "Vue CLI"],
186
623
  ["vite", "Vite"]
187
624
  ];
188
- var read = (file) => readFile(file, "utf8").catch(() => null);
189
- var exists = (file) => stat(file).then(
625
+ var read = (file) => readFile2(file, "utf8").catch(() => null);
626
+ var exists = (file) => stat2(file).then(
190
627
  () => true,
191
628
  () => false
192
629
  );
193
630
  var THEME = /^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name\s*:/im;
194
631
  async function isWordPress(dir) {
195
- if (THEME.test((await read(path.join(dir, "style.css")) ?? "").slice(0, 8192))) return true;
196
- for (const name of ["wp-content", "wp-includes"]) if (await exists(path.join(dir, name))) return true;
197
- for (let at = path.resolve(dir); ; at = path.dirname(at)) {
198
- if (path.basename(at) === "wp-content" || await exists(path.join(at, "wp-config.php"))) return true;
199
- if (path.dirname(at) === at) return false;
632
+ if (THEME.test((await read(path2.join(dir, "style.css")) ?? "").slice(0, 8192))) return true;
633
+ for (const name of ["wp-content", "wp-includes"]) if (await exists(path2.join(dir, name))) return true;
634
+ for (let at = path2.resolve(dir); ; at = path2.dirname(at)) {
635
+ if (path2.basename(at) === "wp-content" || await exists(path2.join(at, "wp-config.php"))) return true;
636
+ if (path2.dirname(at) === at) return false;
200
637
  }
201
638
  }
202
639
  async function contentFolder(dir) {
203
- const here = path.resolve(dir);
204
- for (let at = here; ; at = path.dirname(at)) {
205
- if (path.basename(at) === "wp-content") return at;
206
- const content = path.join(at, "wp-content");
207
- if ((at === here || await exists(path.join(at, "wp-config.php"))) && await exists(content))
640
+ const here = path2.resolve(dir);
641
+ for (let at = here; ; at = path2.dirname(at)) {
642
+ if (path2.basename(at) === "wp-content") return at;
643
+ const content = path2.join(at, "wp-content");
644
+ if ((at === here || await exists(path2.join(at, "wp-config.php"))) && await exists(content))
208
645
  return content;
209
- if (path.dirname(at) === at) return null;
646
+ if (path2.dirname(at) === at) return null;
210
647
  }
211
648
  }
212
649
  async function wordPressFile(dir) {
213
650
  const content = await contentFolder(dir);
214
- return content && path.relative(dir, path.join(content, "mu-plugins", "agentface.php")).split(path.sep).join("/");
651
+ return content && path2.relative(dir, path2.join(content, "mu-plugins", "agentface.php")).split(path2.sep).join("/");
215
652
  }
216
653
  var wordPressPage = (html) => /\/wp-(?:content|includes)\/|["']https:\/\/api\.w\.org\/["']|<meta\b[^>]*\bcontent=["']WordPress\b/i.test(
217
654
  html
@@ -235,17 +672,17 @@ var wordPressManual = (lead) => ({
235
672
  var SHOP = /\b_PS_[A-Z_]+_\b/;
236
673
  var PRESTASHOP_MODULE_FILE = "agentface/agentface.php";
237
674
  async function shopFolder(dir) {
238
- for (let at = path.resolve(dir); ; at = path.dirname(at)) {
239
- if (SHOP.test(await read(path.join(at, "config", "defines.inc.php")) ?? "")) return at;
240
- if (path.dirname(at) === at) return null;
675
+ for (let at = path2.resolve(dir); ; at = path2.dirname(at)) {
676
+ if (SHOP.test(await read(path2.join(at, "config", "defines.inc.php")) ?? "")) return at;
677
+ if (path2.dirname(at) === at) return null;
241
678
  }
242
679
  }
243
680
  async function prestaShopFile(dir) {
244
681
  const shop = await shopFolder(dir);
245
- return shop && path.relative(dir, path.join(shop, "modules", PRESTASHOP_MODULE_FILE)).split(path.sep).join("/");
682
+ return shop && path2.relative(dir, path2.join(shop, "modules", PRESTASHOP_MODULE_FILE)).split(path2.sep).join("/");
246
683
  }
247
684
  async function prestaShopTheme(dir) {
248
- return /^name\s*:/m.test(await read(path.join(dir, "config", "theme.yml")) ?? "") && await exists(path.join(dir, "templates"));
685
+ return /^name\s*:/m.test(await read(path2.join(dir, "config", "theme.yml")) ?? "") && await exists(path2.join(dir, "templates"));
249
686
  }
250
687
  var prestaShopPage = (html) => /\bvar\s+prestashop\s*=/.test(html);
251
688
  var KEY = /\/s\/(site-[a-z0-9-]+)\.js(?=[?#"'`\s]|$)/;
@@ -320,7 +757,7 @@ function addNotice(source, notice) {
320
757
  }
321
758
  function gitFiles(dir) {
322
759
  return new Promise((resolve) => {
323
- execFile(
760
+ execFile2(
324
761
  "git",
325
762
  ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
326
763
  { cwd: dir, maxBuffer: 64 * 1024 * 1024 },
@@ -338,7 +775,7 @@ async function files(dir, skip) {
338
775
  };
339
776
  const found = [];
340
777
  const visit = async (rel) => {
341
- const entries = await readdir(path.join(dir, rel), { withFileTypes: true }).catch(() => []);
778
+ const entries = await readdir(path2.join(dir, rel), { withFileTypes: true }).catch(() => []);
342
779
  for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
343
780
  const file = rel ? `${rel}/${entry.name}` : entry.name;
344
781
  if (entry.isDirectory()) {
@@ -350,13 +787,13 @@ async function files(dir, skip) {
350
787
  return { git: false, files: found };
351
788
  }
352
789
  async function contents(dir, file) {
353
- const info = await stat(path.join(dir, file)).catch(() => null);
354
- return info?.isFile() && info.size <= MAX_BYTES ? read(path.join(dir, file)) : null;
790
+ const info = await stat2(path2.join(dir, file)).catch(() => null);
791
+ return info?.isFile() && info.size <= MAX_BYTES ? read(path2.join(dir, file)) : null;
355
792
  }
356
793
  async function siteGenerator(dir) {
357
794
  for (const file of ["hugo.toml", "hugo.yaml", "hugo.json", "config.toml"])
358
- if (/\bbaseURL\b/i.test(await read(path.join(dir, file)) ?? "")) return "Hugo";
359
- if (await exists(path.join(dir, "_config.yml")) || await exists(path.join(dir, "_layouts")))
795
+ if (/\bbaseURL\b/i.test(await read(path2.join(dir, file)) ?? "")) return "Hugo";
796
+ if (await exists(path2.join(dir, "_config.yml")) || await exists(path2.join(dir, "_layouts")))
360
797
  return "Jekyll";
361
798
  return null;
362
799
  }
@@ -451,7 +888,7 @@ ${notice ? `
451
888
  `;
452
889
  var prestaShopZip = (tag, notice) => zip({ [PRESTASHOP_MODULE_FILE]: PRESTASHOP_MODULE(tag, notice) });
453
890
  async function project(dir) {
454
- const pkg = JSON.parse(await read(path.join(dir, "package.json")) ?? "null");
891
+ const pkg = JSON.parse(await read(path2.join(dir, "package.json")) ?? "null");
455
892
  const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
456
893
  const generator = await siteGenerator(dir);
457
894
  const skip = new Set(SKIP);
@@ -525,7 +962,7 @@ async function findHeads(dir) {
525
962
  if (await isWordPress(dir)) {
526
963
  const file = await wordPressFile(dir);
527
964
  if (file) {
528
- const source = await read(path.join(dir, file));
965
+ const source = await read(path2.join(dir, file));
529
966
  return {
530
967
  framework: "WordPress",
531
968
  heads: [],
@@ -545,7 +982,7 @@ async function findHeads(dir) {
545
982
  }
546
983
  const moduleFile = await prestaShopFile(dir);
547
984
  if (moduleFile) {
548
- const source = await read(path.join(dir, moduleFile));
985
+ const source = await read(path2.join(dir, moduleFile));
549
986
  return {
550
987
  framework: "PrestaShop",
551
988
  heads: [],
@@ -565,7 +1002,7 @@ async function findHeads(dir) {
565
1002
  const bodies = [];
566
1003
  for (const file of list2) {
567
1004
  const markup = MARKUP.test(file);
568
- if (!markup && !LAYOUTS.some((layout) => layout.test(file)) || MAIL.test(path.posix.basename(file)))
1005
+ if (!markup && !LAYOUTS.some((layout) => layout.test(file)) || MAIL.test(path2.posix.basename(file)))
569
1006
  continue;
570
1007
  const text = await contents(dir, file);
571
1008
  if (text === null) continue;
@@ -576,16 +1013,16 @@ async function findHeads(dir) {
576
1013
  const creates = [];
577
1014
  if (deps.next && !heads.some(({ file }) => /(?:^|\/)app\//.test(file))) {
578
1015
  if (!heads.some(({ file }) => /pages\/_document\./.test(file))) {
579
- const pages = await exists(path.join(dir, "pages")) ? "pages" : "src/pages";
580
- if (await exists(path.join(dir, pages)))
1016
+ const pages = await exists(path2.join(dir, "pages")) ? "pages" : "src/pages";
1017
+ if (await exists(path2.join(dir, pages)))
581
1018
  creates.push({ file: `${pages}/_document.js`, content: NEXT_DOCUMENT });
582
1019
  }
583
1020
  }
584
1021
  if (deps.gatsby && !heads.length) {
585
1022
  const own = ["js", "jsx", "ts", "tsx"].map((ext) => `gatsby-ssr.${ext}`);
586
1023
  const present = [];
587
- for (const file of own) if (await exists(path.join(dir, file))) present.push(file);
588
- const text = present.length === 1 ? await read(path.join(dir, present[0])) : null;
1024
+ for (const file of own) if (await exists(path2.join(dir, file))) present.push(file);
1025
+ const text = present.length === 1 ? await read(path2.join(dir, present[0])) : null;
589
1026
  if (present.length && !(present[0] === "gatsby-ssr.js" && text?.includes(OURS)))
590
1027
  return byHand(dir, list2, framework, {
591
1028
  reason: `This Gatsby site has its own ${present[0]}, which init can't edit yet.`,
@@ -689,21 +1126,21 @@ function pathMatches(a, b) {
689
1126
  return listA.every((segment, i) => decode(segment) === decode(listB[i]));
690
1127
  }
691
1128
  var HOST_SOURCE = /^(?:([a-z][a-z0-9+.-]*):\/\/)?(\*|(?:\*\.)?[a-z0-9-]+(?:\.[a-z0-9-]+)*)(?::(\d+|\*))?(\/[^?#]*)?$/i;
692
- function sourceMatches(source, url, page) {
1129
+ function sourceMatches(source, url, page2) {
693
1130
  const lower = source.toLowerCase();
694
- if (lower === "*") return ["http", "https", "ws", "wss", scheme(page)].includes(scheme(url));
1131
+ if (lower === "*") return ["http", "https", "ws", "wss", scheme(page2)].includes(scheme(url));
695
1132
  if (lower === "'self'")
696
- return url.hostname === page.hostname && (url.origin === page.origin || scheme(page) === "http" && scheme(url) === "https" && !url.port);
1133
+ return url.hostname === page2.hostname && (url.origin === page2.origin || scheme(page2) === "http" && scheme(url) === "https" && !url.port);
697
1134
  if (/^[a-z][a-z0-9+.-]*:$/.test(lower)) return schemeMatches(lower.slice(0, -1), scheme(url));
698
- const [, sourceScheme, host, port, path3] = source.match(HOST_SOURCE) ?? [];
1135
+ const [, sourceScheme, host, port, path4] = source.match(HOST_SOURCE) ?? [];
699
1136
  if (!host) return false;
700
- if (!schemeMatches(sourceScheme?.toLowerCase() ?? scheme(page), scheme(url))) return false;
1137
+ if (!schemeMatches(sourceScheme?.toLowerCase() ?? scheme(page2), scheme(url))) return false;
701
1138
  const name = host.toLowerCase();
702
1139
  if (name.startsWith("*.") ? !url.hostname.endsWith(name.slice(1)) : name !== "*" && name !== url.hostname)
703
1140
  return false;
704
1141
  if (port === void 0 ? url.port !== "" : port !== "*" && port !== (url.port || DEFAULT_PORT[scheme(url)]))
705
1142
  return false;
706
- return pathMatches(path3 ?? "", url.pathname);
1143
+ return pathMatches(path4 ?? "", url.pathname);
707
1144
  }
708
1145
  var keyword = (sources, word) => sources.some((source) => source.toLowerCase() === word);
709
1146
  var hasNonce = (sources, nonce) => sources.some((source) => /^'nonce-/i.test(source) && source.slice(7, -1) === nonce && source.endsWith("'"));
@@ -713,7 +1150,7 @@ function fix(policy, decides, name, origin) {
713
1150
  return { name, line: [name, ...sources, origin].join(" "), created: decides !== name };
714
1151
  }
715
1152
  function blockedBy(policies, load) {
716
- const page = new URL(load.page);
1153
+ const page2 = new URL(load.page);
717
1154
  const script = new URL(load.script);
718
1155
  const events = new URL(load.events);
719
1156
  const blocked = [];
@@ -723,7 +1160,7 @@ function blockedBy(policies, load) {
723
1160
  if (scripts) {
724
1161
  const sources = policy.directives.get(scripts);
725
1162
  const dynamic = keyword(sources, "'strict-dynamic'");
726
- const allowed = load.nonce && hasNonce(sources, load.nonce) || (dynamic ? load.added : sources.some((source) => sourceMatches(source, script, page)));
1163
+ const allowed = load.nonce && hasNonce(sources, load.nonce) || (dynamic ? load.added : sources.some((source) => sourceMatches(source, script, page2)));
727
1164
  if (!allowed) {
728
1165
  result.script = true;
729
1166
  if (dynamic) result.nonce = { directive: scripts, named: sources.some((s) => /^'nonce-/i.test(s)) };
@@ -734,7 +1171,7 @@ function blockedBy(policies, load) {
734
1171
  }
735
1172
  }
736
1173
  const connects = governing(policy, ["connect-src", "default-src"]);
737
- if (connects && !policy.directives.get(connects).some((source) => sourceMatches(source, events, page))) {
1174
+ if (connects && !policy.directives.get(connects).some((source) => sourceMatches(source, events, page2))) {
738
1175
  result.connect = true;
739
1176
  result.fixes.push(fix(policy, connects, "connect-src", events.origin));
740
1177
  }
@@ -818,7 +1255,7 @@ function tagBlocked(homepage, site, { added = false } = {}) {
818
1255
  // cli/init.mts
819
1256
  var DEFAULT_SERVICE = "https://cdn.agentfacehq.com";
820
1257
  var BRANCH = "agentface";
821
- var readJson = async (file) => JSON.parse(await readFile2(file, "utf8").catch(() => "null"));
1258
+ var readJson = async (file) => JSON.parse(await readFile3(file, "utf8").catch(() => "null"));
822
1259
  var when = (iso) => iso.slice(0, 16).replace("T", " ") + " UTC";
823
1260
  async function reach(service, url, init2, fetcher) {
824
1261
  try {
@@ -866,14 +1303,14 @@ async function confirm(service, id, fetcher = fetch) {
866
1303
  var option = (source, name) => source?.match(new RegExp(`^\\s*${name}["']?\\s*[:=]\\s*["'\`]?([^"'\`\\s]+)`, "m"))?.[1] ?? null;
867
1304
  var config = async (dir, names) => {
868
1305
  for (const name of names) {
869
- const source = await readFile2(path2.join(dir, name), "utf8").catch(() => null);
1306
+ const source = await readFile3(path3.join(dir, name), "utf8").catch(() => null);
870
1307
  if (source !== null) return { source, name };
871
1308
  }
872
1309
  return { source: null };
873
1310
  };
874
1311
  async function siteUrl(dir, exec = run) {
875
1312
  for (const file of ["CNAME", "public/CNAME", "static/CNAME"]) {
876
- const host = (await readFile2(path2.join(dir, file), "utf8").catch(() => "")).trim().split(/\s+/)[0];
1313
+ const host = (await readFile3(path3.join(dir, file), "utf8").catch(() => "")).trim().split(/\s+/)[0];
877
1314
  if (host) return { url: `https://${host}/`, from: file };
878
1315
  }
879
1316
  for (const [names, key] of [
@@ -885,7 +1322,7 @@ async function siteUrl(dir, exec = run) {
885
1322
  const url = option(source, key);
886
1323
  if (/^https?:\/\//i.test(url ?? "")) return { url, from: name };
887
1324
  }
888
- const homepage = (await readJson(path2.join(dir, "package.json")))?.homepage;
1325
+ const homepage = (await readJson(path3.join(dir, "package.json")))?.homepage;
889
1326
  if (/^https?:\/\//i.test(homepage ?? "")) return { url: homepage, from: 'package.json "homepage"' };
890
1327
  const remote = await exec("git", ["remote", "get-url", "origin"], { cwd: dir }).catch(() => "");
891
1328
  const [, owner, repo] = remote.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i) ?? [];
@@ -895,7 +1332,7 @@ async function siteUrl(dir, exec = run) {
895
1332
  }
896
1333
  function run(command, args, { cwd }) {
897
1334
  return new Promise((resolve, reject) => {
898
- execFile2(command, args, { cwd }, (error, stdout, stderr) => {
1335
+ execFile3(command, args, { cwd }, (error, stdout, stderr) => {
899
1336
  if (error)
900
1337
  reject(
901
1338
  new Error(`${command} ${args.join(" ")} failed: ${(stderr || error.message).trim()}`)
@@ -1005,7 +1442,8 @@ ${warning ? `**Content Security Policy.** ${markdown(warning)}
1005
1442
  **Uninstall.** Revert this pull request, or delete ${site.notice ? "the two lines" : "the line"}.
1006
1443
  `;
1007
1444
  }
1008
- var GTM_HOW = "Can't change the site's code? Add the same line in Google Tag Manager instead: Tags > New > Custom HTML, paste it, set the trigger to Initialization - All Pages, then Submit and Publish the container.";
1445
+ var GTM_WHY = "Why: once loaded, the line registers the site's tools for AI agents, and ask_site when the site has it. AI agents never click a cookie banner, so a line held until someone accepts analytics or marketing cookies never loads, and agent visits get no tools. It sets no cookies and writes nothing to local storage. In first-party session storage, cleared when the tab closes, it keeps a random id for the tab (agentface:sid), the number of the visit's next step (agentface:n), the visit's last steps until an AI agent first uses a tool (agentface:steps), and a note that a tool was used (agentface:tool). If session storage is blocked, these are held only in the page's memory and each page counts as a visit of its own. It sends anonymous page-load and tool-use counts under that tab id, with the page's path but not its query string, and the visit's category, which is worked out in the browser. The visit's steps (pages opened, clicks, typed fields, questions asked) are sent only for a visit in which an AI agent uses a tool. Passwords, payment details, one-time codes and chosen files are never sent: such a field is sent only as hidden. The visitor's IP address is not stored. No sample of the browser's request is kept until Google Consent Mode reports analytics_storage as granted, never while it is denied or unknown, and not on a site with no consent manager. A visitor whose name is marked -User (for example ChatGPT-User) is a classic assistant when they run this line, and a crawler visit in its own bucket, with no visit steps, when they fetch the site's tool list, ask a question or leave a message without running it. Search and training crawlers are not counted as visits. There is no lasting visitor id today. If one is added, it will be written only once Google Consent Mode reports analytics_storage as granted, never while it is denied or unknown. On these facts it is reasonable to class the line as functional or necessary. The site's consent banner, privacy notice and lawful basis stay the site owner's call. This is information, not legal advice. Everything the line stores and agentface receives: https://agentface.com/docs/snippet-storage";
1446
+ var GTM_HOW = `Can't change the site's code? Add the same line in Google Tag Manager instead: Tags > New > Custom HTML, paste it, set the trigger to Initialization - All Pages, then Submit and Publish the container. Under Consent Settings choose No additional consent required: don't make it wait for a Consent Mode signal such as analytics_storage, and don't mark it as an analytics or ads tag. ${GTM_WHY}`;
1009
1447
  function noticeByHand(site, noticed, log) {
1010
1448
  if (site.notice && !noticed.includes(site.id))
1011
1449
  log(
@@ -1017,10 +1455,10 @@ function noticeByHand(site, noticed, log) {
1017
1455
  }
1018
1456
  function byHand2({ manual, tagged, noticed }, site, service, dryRun, warning, log) {
1019
1457
  if (manual.steps) return withPlugin({ manual, tagged }, site, service, dryRun, warning, log);
1020
- const current = tagged.filter(({ key }) => key === site.id).map(({ file }) => file);
1021
- if (current.length) {
1458
+ const current2 = tagged.filter(({ key }) => key === site.id).map(({ file }) => file);
1459
+ if (current2.length) {
1022
1460
  log(
1023
- `${list(current)} already ${current.length === 1 ? "has" : "have"} the Agentface tag for ${site.id}.`
1461
+ `${list(current2)} already ${current2.length === 1 ? "has" : "have"} the Agentface tag for ${site.id}.`
1024
1462
  );
1025
1463
  noticeByHand(site, noticed, log);
1026
1464
  if (warning) log(warning);
@@ -1159,8 +1597,8 @@ async function init({
1159
1597
  await exec("git", ["switch", "-C", BRANCH], { cwd: dir });
1160
1598
  }
1161
1599
  for (const [file, content] of writes) {
1162
- await mkdir(path2.dirname(path2.join(dir, file)), { recursive: true });
1163
- await writeFile(path2.join(dir, file), content);
1600
+ await mkdir2(path3.dirname(path3.join(dir, file)), { recursive: true });
1601
+ await writeFile2(path3.join(dir, file), content);
1164
1602
  }
1165
1603
  log(`Added ${what} to ${list(files2)} (${found.framework}) for ${site.origin}.`);
1166
1604
  if (shop) log(shop);
@@ -1256,7 +1694,7 @@ async function check({
1256
1694
  }
1257
1695
  log(result.message);
1258
1696
  const module = await prestaShopFile(dir);
1259
- if (module && await readFile2(path2.join(dir, module)).catch(() => null))
1697
+ if (module && await readFile3(path3.join(dir, module)).catch(() => null))
1260
1698
  log(
1261
1699
  `PrestaShop runs ${module} only once it's installed. If it isn't yet, open Modules > Module Manager in the shop's back office, search for Agentface and click Install.`
1262
1700
  );
@@ -1295,10 +1733,10 @@ async function uninstall({
1295
1733
  const files2 = edits.map(([file]) => file);
1296
1734
  const module = await prestaShopFile(dir);
1297
1735
  if (!dryRun) {
1298
- for (const [file, content] of edits) await writeFile(path2.join(dir, file), content);
1736
+ for (const [file, content] of edits) await writeFile2(path3.join(dir, file), content);
1299
1737
  for (const file of deleted) {
1300
- await rm(path2.join(dir, file));
1301
- if (file === module) await rmdir(path2.dirname(path2.join(dir, file))).catch(() => {
1738
+ await rm2(path3.join(dir, file));
1739
+ if (file === module) await rmdir(path3.dirname(path3.join(dir, file))).catch(() => {
1302
1740
  });
1303
1741
  }
1304
1742
  }
@@ -1329,13 +1767,27 @@ var HELP = `Usage:
1329
1767
  time, that confirms the site is yours.
1330
1768
  agentface uninstall Remove the Agentface tag from this folder's pages.
1331
1769
 
1770
+ agentface login Connect this machine to your agentface account, in your
1771
+ browser. logout ends the connection.
1772
+ agentface mcp tools List what you can do on agentface from here: your websites,
1773
+ their numbers and sessions, starting a run.
1774
+ agentface mcp call <name> [key=value \u2026]
1775
+ Do one of them, and print what it returned.
1776
+
1332
1777
  Options:
1333
1778
  --url The site's address, like https://example.com (init finds it when it can)
1334
1779
  --site check: the site key (check finds it in the project when it can)
1335
1780
  --pr init: commit the change on a new branch and open a pull request (needs git and gh)
1336
1781
  --dry-run Show what would change, without registering or writing anything
1337
- --service Agentface service URL (default ${DEFAULT_SERVICE})`;
1338
- async function main(argv, { log = console.log, dir = process.cwd(), fetch: fetcher = fetch } = {}) {
1782
+ --service Agentface service URL (default ${DEFAULT_SERVICE})
1783
+ --server login, logout, mcp: agentface's own address (default ${DEFAULT_SERVER})
1784
+ --json mcp: print the answer as JSON`;
1785
+ async function main(argv, {
1786
+ log = console.log,
1787
+ dir = process.cwd(),
1788
+ fetch: fetcher = fetch,
1789
+ connect = {}
1790
+ } = {}) {
1339
1791
  const { values, positionals } = parseArgs({
1340
1792
  args: argv,
1341
1793
  allowPositionals: true,
@@ -1345,6 +1797,8 @@ async function main(argv, { log = console.log, dir = process.cwd(), fetch: fetch
1345
1797
  pr: { type: "boolean" },
1346
1798
  "dry-run": { type: "boolean" },
1347
1799
  service: { type: "string" },
1800
+ server: { type: "string" },
1801
+ json: { type: "boolean" },
1348
1802
  help: { type: "boolean", short: "h" }
1349
1803
  }
1350
1804
  });
@@ -1354,6 +1808,21 @@ async function main(argv, { log = console.log, dir = process.cwd(), fetch: fetch
1354
1808
  log(HELP);
1355
1809
  return 0;
1356
1810
  }
1811
+ const account = {
1812
+ ...connect,
1813
+ server: values.server ?? process.env.AGENTFACE_SERVER ?? DEFAULT_SERVER,
1814
+ fetch: fetcher,
1815
+ log
1816
+ };
1817
+ if (command === "login") {
1818
+ await login(account);
1819
+ return 0;
1820
+ }
1821
+ if (command === "logout") {
1822
+ await logout(account);
1823
+ return 0;
1824
+ }
1825
+ if (command === "mcp") return mcp(positionals.slice(1), { ...account, json: values.json });
1357
1826
  if (command === "init") {
1358
1827
  await init({
1359
1828
  site: arg,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentface",
3
- "version": "0.6.0",
4
- "description": "Add the Agentface tag to a website's pages, so AI agents get tools made for it.",
3
+ "version": "0.7.0",
4
+ "description": "Add the Agentface tag to a website's pages, so AI agents get tools made for it, and use your agentface account from a shell.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/agentfacehq/agentface-app.git",