pi-durable-bot 0.8.2 → 0.8.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +11 -6
  3. package/dist/agent/mcp.js +4 -2
  4. package/dist/agent/mcp.js.map +1 -1
  5. package/dist/agent/models.js +60 -0
  6. package/dist/agent/models.js.map +1 -1
  7. package/dist/bot/bot.js +9 -0
  8. package/dist/bot/bot.js.map +1 -1
  9. package/dist/bot/prompt.js +3 -1
  10. package/dist/bot/prompt.js.map +1 -1
  11. package/dist/channels/teams/index.js +1327 -0
  12. package/dist/channels/teams/index.js.map +1 -0
  13. package/dist/channels/teams/sdk.js +57 -0
  14. package/dist/channels/teams/sdk.js.map +1 -0
  15. package/dist/cli/ai.js +6 -58
  16. package/dist/cli/ai.js.map +1 -1
  17. package/dist/cli/login-link.js +90 -0
  18. package/dist/cli/login-link.js.map +1 -0
  19. package/dist/cli/login.js +24 -2
  20. package/dist/cli/login.js.map +1 -1
  21. package/dist/cli/mcp.js +7 -2
  22. package/dist/cli/mcp.js.map +1 -1
  23. package/dist/cli/pages.js +20 -6
  24. package/dist/cli/pages.js.map +1 -1
  25. package/dist/gateway/log.js +4 -1
  26. package/dist/gateway/log.js.map +1 -1
  27. package/dist/pages/host.js +68 -2
  28. package/dist/pages/host.js.map +1 -1
  29. package/dist/pages/login-page.js +202 -0
  30. package/dist/pages/login-page.js.map +1 -0
  31. package/dist/pages/login.js +848 -0
  32. package/dist/pages/login.js.map +1 -0
  33. package/dist/pages/server.js +121 -6
  34. package/dist/pages/server.js.map +1 -1
  35. package/dist/pages/store.js +22 -4
  36. package/dist/pages/store.js.map +1 -1
  37. package/docs/for-agents.md +6 -3
  38. package/kit/login/login.css +498 -0
  39. package/kit/login/login.js +481 -0
  40. package/package.json +17 -14
  41. package/skills/pages/SKILL.md +32 -3
  42. package/skills/teams-channel/SKILL.md +131 -0
@@ -0,0 +1,481 @@
1
+ // The login page of Pots: a person signs in to a model provider for the bot's computer, from any device. Pots serves
2
+ // this page for a login link (/g/<token>/) and runs pi's own login on its computer; this script shows what pi asks and
3
+ // shows (a choice, a field, a sign-in link, a device code), sends the answers, and follows pi while it waits, by asking
4
+ // Pots for news (state?after=<version>), which answers when something changed. Every request goes relative to the
5
+ // page's address, so a path that a proxy puts in front stays.
6
+
7
+ const facts = JSON.parse(document.getElementById("pots-facts").textContent);
8
+ const W = facts.words;
9
+ const $ = (id) => document.getElementById(id);
10
+ const fill = (text, values) => text.replace(/\{(\w+)\}/g, (all, key) => (key in values ? String(values[key]) : all));
11
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
12
+ const base = new URL(".", location.href);
13
+
14
+ /** Pots' answer to a request under the link's address; status 0 when there was no connection. */
15
+ async function api(path, body) {
16
+ try {
17
+ const response = await fetch(new URL(path, base), {
18
+ method: body === undefined ? "GET" : "POST",
19
+ cache: "no-store",
20
+ credentials: "same-origin",
21
+ headers: body === undefined ? undefined : { "content-type": "application/json" },
22
+ body: body === undefined ? undefined : JSON.stringify(body),
23
+ });
24
+ let value = {};
25
+ try {
26
+ value = await response.json();
27
+ } catch {
28
+ // not JSON
29
+ }
30
+ return { status: response.status, ...value };
31
+ } catch {
32
+ return { status: 0, ok: false };
33
+ }
34
+ }
35
+
36
+ function h(tag, attributes = {}, ...children) {
37
+ const element = document.createElement(tag);
38
+ for (const [name, value] of Object.entries(attributes)) {
39
+ if (value === false || value === undefined || value === null) continue;
40
+ if (name === "class") element.className = value;
41
+ else if (name === "text") element.textContent = value;
42
+ else if (name.startsWith("on")) element.addEventListener(name.slice(2), value);
43
+ else element.setAttribute(name, value === true ? "" : value);
44
+ }
45
+ for (const child of children.flat()) if (child !== null && child !== undefined && child !== false) element.append(child);
46
+ return element;
47
+ }
48
+
49
+ /** A link to a page of the provider, in a new tab, that tells it nothing of this page. */
50
+ const outLink = (url, text, className) => h("a", { href: url, target: "_blank", rel: "noreferrer noopener", class: className, text });
51
+ const hostOf = (url) => {
52
+ try {
53
+ return new URL(url).host;
54
+ } catch {
55
+ return url;
56
+ }
57
+ };
58
+
59
+ // ---- The link ----
60
+
61
+ /** The last state from Pots. */
62
+ let link = null;
63
+ /** Pots' clock minus this device's. */
64
+ let offset = 0;
65
+ let over = false;
66
+ const localTime = (ms) => new Date(ms - offset).toLocaleTimeString(document.documentElement.lang || [], { hour: "2-digit", minute: "2-digit" });
67
+
68
+ function showEnded(state) {
69
+ if (over) return;
70
+ over = true;
71
+ // Pots' own page for the ended link, as a reload shows it.
72
+ location.reload();
73
+ }
74
+
75
+ /** The link's state, or undefined when Pots did not answer. missing: Pots does not know the link (now). */
76
+ /** Replace an element's children; empty places (null, false) are left out. */
77
+ const show = (element, ...children) => element.replaceChildren(...children.flat().filter((child) => child !== null && child !== undefined && child !== false));
78
+
79
+ async function refresh(after, { missing = () => showEnded("missing") } = {}) {
80
+ const answer = await api(after === undefined ? "state" : `state?after=${after}`);
81
+ if (answer.status === 404) return missing();
82
+ if (!answer.state) return undefined;
83
+ link = answer;
84
+ offset = answer.now - Date.now();
85
+ if (answer.state !== "open" && answer.state !== "started") showEnded(answer.state);
86
+ return answer;
87
+ }
88
+
89
+ // ---- The start screen ----
90
+
91
+ const startButton = $("start-button");
92
+ const startMessage = (text) => ($("start-msg").textContent = text || "");
93
+
94
+ function showStart() {
95
+ if (!link) return;
96
+ $("start-meta").textContent = `${fill(W.linkUntil, { time: localTime(link.expires) })} · ${fill(W.afterStart, { n: facts.minutes })}`;
97
+ if (link.state === "started" && !link.mine) {
98
+ startButton.disabled = true;
99
+ startMessage(W.elsewhere);
100
+ return;
101
+ }
102
+ startButton.textContent = link.state === "started" ? W.continue : W.start;
103
+ startButton.disabled = false;
104
+ }
105
+
106
+ async function start() {
107
+ startButton.disabled = true;
108
+ startMessage("");
109
+ const answer = await api("start", {});
110
+ if (!answer.ok) {
111
+ if (answer.status === 0) startMessage(fill(W.network, { bot: facts.bot }));
112
+ else if (answer.code === "elsewhere") startMessage(W.elsewhere);
113
+ else if (answer.status === 404 || answer.status === 410) return refresh();
114
+ else startMessage(answer.error || W.network);
115
+ startButton.disabled = answer.code === "elsewhere";
116
+ return;
117
+ }
118
+ $("start").hidden = true;
119
+ $("session").hidden = false;
120
+ follow();
121
+ }
122
+
123
+ // ---- The session ----
124
+
125
+ /** What the person is doing between pi's logins: choosing, confirming a replacement, or reading an outcome. */
126
+ const ui = { screen: "choose", tab: "oauth", filter: "", pending: null, seen: 0, question: null, message: "" };
127
+
128
+ /** Ask Pots for news again and again while the link is started, and show each state. */
129
+ async function follow() {
130
+ let failures = 0;
131
+ let version;
132
+ while (!over) {
133
+ const asked = Date.now();
134
+ // While Pots restarts, its page server may not know the link for a moment.
135
+ const answer = await refresh(version, { missing: () => (failures > 20 ? showEnded("missing") : undefined) });
136
+ if (over) return;
137
+ if (!answer) {
138
+ failures += 1;
139
+ ui.message = fill(W.network, { bot: facts.bot });
140
+ if (link) render();
141
+ await sleep(Math.min(5_000, 500 * failures));
142
+ continue;
143
+ }
144
+ if (failures > 0) ui.message = "";
145
+ failures = 0;
146
+ render();
147
+ if (answer.state === "started" && !answer.mine) return;
148
+ // An answer with no news that came at once, as from a Pots that does not wait: ask again a moment later.
149
+ if (answer.version === version && Date.now() - asked < 500) await sleep(1_000);
150
+ version = answer.version;
151
+ }
152
+ }
153
+
154
+ function render() {
155
+ if (!link || over) return;
156
+ const session = $("session");
157
+ if (link.state === "started" && !link.mine) {
158
+ show(session, h("p", { class: "msg", text: W.elsewhere }));
159
+ return;
160
+ }
161
+ const outcomes = link.outcomes || [];
162
+ if (link.login) {
163
+ renderLogin(session, link.login);
164
+ return;
165
+ }
166
+ ui.question = null;
167
+ if (outcomes.length > ui.seen && ui.screen !== "outcome") ui.screen = "outcome";
168
+ if (ui.screen === "outcome" && outcomes.length > 0) return renderOutcome(session, outcomes[outcomes.length - 1]);
169
+ if (ui.screen === "confirm" && ui.pending) return renderConfirm(session, ui.pending);
170
+ renderChoose(session);
171
+ }
172
+
173
+ function header(title) {
174
+ const left = link.expires - (Date.now() + offset);
175
+ const meta = left < 60_000 ? W.oneMinute : fill(W.linkUntil, { time: localTime(link.expires) });
176
+ return [h("h1", { text: title }), h("p", { class: "meta", text: meta }), ui.message ? h("p", { class: "msg", role: "alert", text: ui.message }) : null];
177
+ }
178
+
179
+ /** The choices of the link: a subscription or an API key, and the provider. */
180
+ function choices() {
181
+ const all = link.choices || { oauth: [], api_key: [] };
182
+ if (!facts.provider) return all;
183
+ return { oauth: all.oauth.filter((item) => item.id === facts.provider), api_key: all.api_key.filter((item) => item.id === facts.provider) };
184
+ }
185
+
186
+ function renderChoose(session) {
187
+ const all = choices();
188
+ const ways = ["oauth", "api_key"].filter((way) => all[way].length > 0);
189
+ if (!ways.includes(ui.tab)) ui.tab = ways[0] || "oauth";
190
+ const title = facts.provider ? fill(W.signingIn, { provider: (all.oauth[0] || all.api_key[0] || { name: facts.provider }).name }) : document.title;
191
+ const tabs = h(
192
+ "div",
193
+ { class: "tabs", role: "tablist" },
194
+ ways.map((way) =>
195
+ h(
196
+ "button",
197
+ { type: "button", role: "tab", class: ui.tab === way ? "tab on" : "tab", "aria-selected": ui.tab === way ? "true" : "false", onclick: () => ((ui.tab = way), render()) },
198
+ h("strong", { text: way === "oauth" ? W.subscription : W.apiKey }),
199
+ facts.provider ? null : h("span", { text: way === "oauth" ? W.subscriptionNote : W.apiKeyNote }),
200
+ ),
201
+ ),
202
+ );
203
+ const items = all[ui.tab].filter((item) => !ui.filter || `${item.name} ${item.id}`.toLowerCase().includes(ui.filter.toLowerCase()));
204
+ const list = h(
205
+ "div",
206
+ { class: "list" },
207
+ items.length === 0
208
+ ? h("p", { class: "meta", text: W.noMatch })
209
+ : items.map((item) =>
210
+ h(
211
+ "button",
212
+ { type: "button", class: "item", onclick: () => choose(item, ui.tab) },
213
+ h("span", { class: "name", text: item.name }),
214
+ h("span", { class: "id", text: item.id }),
215
+ item.replaces ? h("span", { class: "badge", text: W.there }) : null,
216
+ ),
217
+ ),
218
+ );
219
+ const search =
220
+ !facts.provider && all[ui.tab].length > 8
221
+ ? h("input", {
222
+ type: "search",
223
+ class: "search",
224
+ placeholder: W.search,
225
+ value: ui.filter,
226
+ oninput: (event) => {
227
+ ui.filter = event.target.value;
228
+ const at = event.target.selectionStart;
229
+ render();
230
+ const again = document.querySelector("input.search");
231
+ again.focus();
232
+ again.setSelectionRange(at, at);
233
+ },
234
+ })
235
+ : null;
236
+ show(session, ...header(title), ways.length > 1 ? tabs : null, search, list, footer());
237
+ }
238
+
239
+ function footer() {
240
+ return h("div", { class: "foot" }, h("p", { class: "fine", text: W.doneNote }), h("button", { type: "button", class: "plain", onclick: done, text: W.done }));
241
+ }
242
+
243
+ function choose(item, way) {
244
+ ui.pending = { ...item, way };
245
+ if (item.replaces) {
246
+ ui.screen = "confirm";
247
+ return render();
248
+ }
249
+ begin();
250
+ }
251
+
252
+ function renderConfirm(session, item) {
253
+ show(
254
+ session,
255
+ ...header(fill(W.replaceTitle, { provider: item.name })),
256
+ h("p", { text: fill(W.replaceText, { provider: item.name }) }),
257
+ h("button", { type: "button", class: "big", onclick: () => begin(true), text: W.replaceGo }),
258
+ h("button", { type: "button", class: "plain", onclick: () => ((ui.screen = "choose"), render()), text: W.back }),
259
+ );
260
+ }
261
+
262
+ /** Start pi's login. confirmed: the person said here to replace the login that is stored, as the choices showed it. */
263
+ async function begin(confirmed = false) {
264
+ const item = ui.pending;
265
+ if (!item) return;
266
+ ui.screen = "choose";
267
+ ui.message = "";
268
+ ui.seen = (link.outcomes || []).length;
269
+ const answer = await api("login", { provider: item.id, way: item.way, ...(confirmed && item.stored ? { replace: item.stored } : {}) });
270
+ if (!answer.ok) {
271
+ ui.message = answer.status === 0 ? fill(W.network, { bot: facts.bot }) : answer.error || W.network;
272
+ render();
273
+ }
274
+ // The news of the login comes with the next state.
275
+ }
276
+
277
+ /** pi's sign-in that runs: its events, and its open question. The question's field stays while events come. */
278
+ function renderLogin(session, login) {
279
+ let box = $("login-box");
280
+ if (!box || box.dataset.provider !== `${login.way}:${login.provider}`) {
281
+ box = h("div", { id: "login-box", "data-provider": `${login.way}:${login.provider}` });
282
+ show(
283
+ session,
284
+ h("h1", { text: fill(W.signingIn, { provider: login.name }) }),
285
+ h("p", { class: "meta", id: "login-meta" }),
286
+ h("p", { class: "msg", id: "login-msg", role: "alert" }),
287
+ box,
288
+ h("div", { id: "events" }),
289
+ h("div", { id: "question" }),
290
+ h("button", { type: "button", class: "plain", onclick: cancel, text: W.cancel }),
291
+ );
292
+ ui.question = null;
293
+ }
294
+ const left = link.expires - (Date.now() + offset);
295
+ $("login-meta").textContent = left < 60_000 ? W.oneMinute : fill(W.linkUntil, { time: localTime(link.expires) });
296
+ $("login-msg").textContent = ui.message;
297
+ show($("events"), ...login.events.map(renderEvent));
298
+ const question = login.question || null;
299
+ if ((question && question.id) !== (ui.question && ui.question.id)) {
300
+ ui.question = question;
301
+ show($("question"), question ? renderQuestion(question) : "");
302
+ const field = $("question").querySelector("input");
303
+ if (field && !matchMedia("(pointer: coarse)").matches) field.focus();
304
+ }
305
+ }
306
+
307
+ function renderEvent(event) {
308
+ if (event.type === "auth_url") {
309
+ return h("div", { class: "event" }, event.instructions ? h("p", { text: event.instructions }) : null, outLink(event.url, W.openSignIn, "big link"));
310
+ }
311
+ if (event.type === "device_code") {
312
+ const copy = h("button", {
313
+ type: "button",
314
+ class: "plain small",
315
+ text: W.copy,
316
+ onclick: async () => {
317
+ try {
318
+ await navigator.clipboard.writeText(event.userCode);
319
+ copy.textContent = W.copied;
320
+ } catch {
321
+ const range = document.createRange();
322
+ range.selectNodeContents(code);
323
+ getSelection().removeAllRanges();
324
+ getSelection().addRange(range);
325
+ }
326
+ },
327
+ });
328
+ const code = h("span", { class: "code", text: event.userCode });
329
+ return h(
330
+ "div",
331
+ { class: "event device" },
332
+ h("p", { text: fill(W.deviceCode, { host: hostOf(event.verificationUri) }) }),
333
+ h("div", { class: "coderow" }, code, copy),
334
+ outLink(event.verificationUri, fill(W.openSite, { host: hostOf(event.verificationUri) }), "big link"),
335
+ event.expiresAt ? h("p", { class: "fine", text: fill(W.codeUntil, { time: localTime(event.expiresAt) }) }) : null,
336
+ );
337
+ }
338
+ if (event.type === "info") {
339
+ return h("div", { class: "event" }, h("p", { text: event.message }), (event.links || []).map((item) => h("p", {}, outLink(item.url, item.label || hostOf(item.url)))));
340
+ }
341
+ return h("p", { class: "progress" }, h("span", { class: "spin", "aria-hidden": "true" }), event.message);
342
+ }
343
+
344
+ function renderQuestion(question) {
345
+ if (question.type === "select") {
346
+ return h(
347
+ "div",
348
+ { class: "question" },
349
+ h("p", { class: "q", text: question.message }),
350
+ h(
351
+ "div",
352
+ { class: "list" },
353
+ question.options.map((option) =>
354
+ h(
355
+ "button",
356
+ { type: "button", class: option.recommended ? "item best" : "item", onclick: () => answer(question, option.id) },
357
+ h("span", { class: "name", text: option.label }),
358
+ option.description ? h("span", { class: "id", text: option.description }) : null,
359
+ option.recommended ? h("span", { class: "badge", text: W.recommended }) : null,
360
+ ),
361
+ ),
362
+ ),
363
+ question.hidden.length > 0 ? h("p", { class: "fine", text: fill(W.hidden, { ways: question.hidden.join(", ") }) }) : null,
364
+ );
365
+ }
366
+ // Pots' own question: the provider got a login while this one waited for its turn.
367
+ if (question.type === "replace") {
368
+ return h(
369
+ "div",
370
+ { class: "question" },
371
+ h("p", { class: "q", text: fill(W.replaceTitle, { provider: question.provider }) }),
372
+ h("p", { text: fill(W.replaceText, { provider: question.provider }) }),
373
+ h("button", { type: "button", class: "big", onclick: () => answer(question, "replace"), text: W.replaceGo }),
374
+ h("button", { type: "button", class: "plain", onclick: () => answer(question, "cancel"), text: W.back }),
375
+ );
376
+ }
377
+ const secret = question.type === "secret";
378
+ const input = h("input", {
379
+ type: secret ? "password" : "text",
380
+ autocomplete: "off",
381
+ autocapitalize: "off",
382
+ autocorrect: "off",
383
+ spellcheck: "false",
384
+ placeholder: question.placeholder || "",
385
+ "aria-label": question.message,
386
+ });
387
+ const form = h(
388
+ "form",
389
+ {
390
+ class: "question",
391
+ onsubmit: (event) => {
392
+ event.preventDefault();
393
+ if (question.type !== "text" && !input.value.trim()) {
394
+ ui.message = W.empty;
395
+ $("login-msg").textContent = W.empty;
396
+ return;
397
+ }
398
+ answer(question, input.value);
399
+ },
400
+ },
401
+ h("label", { class: "q", text: question.message }),
402
+ input,
403
+ question.type === "manual_code" ? h("p", { class: "fine", text: W.pasteHint }) : null,
404
+ secret && facts.quickTunnel ? h("p", { class: "warn", text: W.secretWarn }) : null,
405
+ question.type === "manual_code" && facts.quickTunnel ? h("p", { class: "warn", text: W.codeWarn }) : null,
406
+ h("button", { type: "submit", class: "big", text: W.send }),
407
+ );
408
+ return form;
409
+ }
410
+
411
+ async function answer(question, value) {
412
+ for (const button of $("question").querySelectorAll("button")) button.disabled = true;
413
+ ui.message = "";
414
+ const result = await api("answer", { question: question.id, value });
415
+ if (result.ok) return;
416
+ for (const button of $("question").querySelectorAll("button")) button.disabled = false;
417
+ ui.message = result.status === 0 ? fill(W.network, { bot: facts.bot }) : result.code === "gone" ? W.gone : result.error || W.network;
418
+ $("login-msg").textContent = ui.message;
419
+ }
420
+
421
+ async function cancel() {
422
+ ui.message = "";
423
+ await api("cancel", {});
424
+ }
425
+
426
+ function renderOutcome(session, outcome) {
427
+ const lines = [];
428
+ if (outcome.ok) {
429
+ if (outcome.replaced) lines.push(W.replaced);
430
+ if (outcome.model) lines.push(outcome.modelProblem ? fill(W.notAnswer, { model: outcome.model, reason: outcome.modelProblem }) : fill(W.ready, { model: outcome.model }));
431
+ if (outcome.judge) lines.push(outcome.judgeProblem ? fill(W.notAnswer, { model: outcome.judge, reason: outcome.judgeProblem }) : fill(W.judgeReady, { model: outcome.judge }));
432
+ if (!outcome.model && !outcome.judge) lines.push(W.noModels);
433
+ } else lines.push(outcome.cancelled ? W.cancelled : outcome.error);
434
+ show(
435
+ session,
436
+ h("div", { class: `check ${outcome.ok ? "good" : "gone"}`, "aria-hidden": "true" }),
437
+ ...header(fill(outcome.ok ? W.signedIn : W.failed, { provider: outcome.name })),
438
+ ...lines.map((line) => h("p", { class: "result", text: line })),
439
+ h(
440
+ "button",
441
+ {
442
+ type: "button",
443
+ class: "big",
444
+ onclick: () => {
445
+ ui.seen = (link.outcomes || []).length;
446
+ ui.screen = "choose";
447
+ if (!outcome.ok && !facts.provider) ui.pending = null;
448
+ render();
449
+ },
450
+ text: outcome.ok ? W.another : W.tryAgain,
451
+ },
452
+ ),
453
+ h("button", { type: "button", class: "plain", onclick: done, text: W.done }),
454
+ );
455
+ }
456
+
457
+ async function done() {
458
+ const answer = await api("done", {});
459
+ if (answer.ok || answer.status === 410 || answer.status === 404) return showEnded("done");
460
+ ui.message = answer.status === 0 ? fill(W.network, { bot: facts.bot }) : answer.error || W.network;
461
+ render();
462
+ }
463
+
464
+ // ---- Begin ----
465
+
466
+ startButton.addEventListener("click", start);
467
+ (async () => {
468
+ const answer = await refresh();
469
+ if (!answer) {
470
+ startMessage(fill(W.network, { bot: facts.bot }));
471
+ startButton.disabled = false;
472
+ return;
473
+ }
474
+ if (answer.state === "started" && answer.mine) {
475
+ $("start").hidden = true;
476
+ $("session").hidden = false;
477
+ follow();
478
+ return;
479
+ }
480
+ showStart();
481
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-durable-bot",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "Open-source AI coworkers that read every channel, decide what matters, and act on their own computer. Self-hosted, any model.",
5
5
  "license": "MIT AND MPL-2.0",
6
6
  "type": "module",
@@ -57,24 +57,27 @@
57
57
  "@chat-adapter/discord": "4.44.0",
58
58
  "@chat-adapter/slack": "4.44.0",
59
59
  "@chat-adapter/state-memory": "4.44.0",
60
+ "@chat-adapter/teams": "4.44.0",
60
61
  "@chat-adapter/telegram": "4.44.0",
61
- "@earendil-works/chord": "1.5.0",
62
- "@earendil-works/pi-ai": "1.5.0",
63
- "@earendil-works/pi-codemode": "1.5.0",
64
- "@earendil-works/pi-coding-agent": "1.5.0",
65
- "@earendil-works/pi-durable": "1.5.0",
66
- "@earendil-works/pi-mcp": "1.5.0",
67
- "@earendil-works/pi-schema": "1.5.0",
68
- "@earendil-works/pi-telemetry": "1.5.0",
69
- "@effect/platform-node": "4.1.2",
70
- "@effect/platform-node-shared": "4.1.2",
62
+ "@earendil-works/chord": "1.5.2",
63
+ "@earendil-works/pi-ai": "1.5.2",
64
+ "@earendil-works/pi-codemode": "1.5.2",
65
+ "@earendil-works/pi-coding-agent": "1.5.2",
66
+ "@earendil-works/pi-durable": "1.5.2",
67
+ "@earendil-works/pi-mcp": "1.5.2",
68
+ "@earendil-works/pi-schema": "1.5.2",
69
+ "@earendil-works/pi-telemetry": "1.5.2",
70
+ "@effect/platform-node": "4.1.4",
71
+ "@effect/platform-node-shared": "4.1.4",
72
+ "@microsoft/teams.api": "2.2.1",
73
+ "@microsoft/teams.apps": "2.2.1",
71
74
  "chat": "4.44.0",
72
75
  "discord.js": "14.28.1",
73
- "effect": "4.1.2",
74
- "ws": "8.22.1"
76
+ "effect": "4.1.4",
77
+ "ws": "8.23.0"
75
78
  },
76
79
  "devDependencies": {
77
- "@effect/vitest": "4.1.2",
80
+ "@effect/vitest": "4.1.4",
78
81
  "@types/node": "26.6.6",
79
82
  "@types/ws": "8.18.2",
80
83
  "fast-check": "4.10.2",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pages
3
- description: Web pages you write and send to people as a link. A display page shows what is too big for a chat message (a plan, a report, tables, charts); an answer page collects many answers at once (choices, text, comments on sections, approve or reject) and sends them back to you; the Pots password page takes a secret such as a token. Also how page links reach the internet (Cloudflare Quick Tunnel, Tailscale Funnel), website projects, and cleanup. Use when a chat message is too small for what you must show or ask, or when a person has to give you a secret.
3
+ description: Web pages you write and send to people as a link. A display page shows what is too big for a chat message (a plan, a report, tables, charts); an answer page collects many answers at once (choices, text, comments on sections, approve or reject) and sends them back to you; the Pots password page takes a secret such as a token; the Pots login page signs this computer in to a model. Also how page links reach the internet (Cloudflare Quick Tunnel, Tailscale Funnel), website projects, and cleanup. Use when a chat message is too small for what you must show or ask, or when a person has to give you a secret.
4
4
  ---
5
5
 
6
6
  # Pages
@@ -19,6 +19,7 @@ A guide, not a rule; you decide.
19
19
  | Many inputs at once: choices, text, a comment on each step, approve or reject | An answer page | One page, one submit |
20
20
  | A secret: a password, a token, a key | The Pots password page (`pots page secret`) | The value goes straight to a file in the secrets folder, never into the chat, the log or your conversation |
21
21
  | A step only a person can do on your screen: a sign-in, a CAPTCHA, an approval | The Pots desktop page (`pots page desktop`): the desktop-page skill | They see and control your screen from their phone or computer, and hand it back |
22
+ | A login to a model: a subscription or an API key, also TypeSafe's for Jev | The Pots login page (`pots page login`) | They sign in from any device; pi keeps the login, and you never see it |
22
23
 
23
24
  Never ask for a secret in a chat message, and never write your own page for one. If someone pastes a secret into a chat, tell them that the chat keeps it, and suggest they replace it. In the terminal channel (`pots chat`), ask-secret works as before.
24
25
 
@@ -45,7 +46,7 @@ pots page unlink <link ID or URL> # the link stops working at on
45
46
  pots page list # your pages, their links, when each was last opened and changed
46
47
  ```
47
48
 
48
- `pots page list` also lists your password links (`secretLinks`, IDs S1, S2, …) and desktop links (`desktopLinks`, D1, D2, …), and `pots page unlink` takes those back too.
49
+ `pots page list` also lists your password links (`secretLinks`, IDs S1, S2, …), desktop links (`desktopLinks`, D1, D2, …) and login links (`loginLinks`, G1, G2, …), and `pots page unlink` takes those back too.
49
50
 
50
51
  `pots page link` prints JSON: `{"link": "<link ID>", "url": "https://…/p/<token>/", "via": "public-url" or "quick-tunnel", "note": "…"}`. `note` comes with a Quick Tunnel and gives its facts (see below). Nobody can guess a link, but anyone who has it can open it, and a link can be forwarded.
51
52
 
@@ -190,12 +191,40 @@ secret page: someone used link <link ID> (made for <person address | anyone>) an
190
191
 
191
192
  You never see the values; they are not in the log, the wake or a trace. Then use the file as after ask-secret, for example as `secrets` of a channel in bot.json. The file has the values exactly as they were typed, one `KEY=value` line each, so never `source` it or `.` it in a shell: a value can hold `$(…)`. To use one value in a command, read just that line, for example `"$(grep '^SLACK_BOT_TOKEN=' ~/.pots/secrets/slack-ada.env | cut -d= -f2-)"`, and never print it. Send the link in a DM to that person when you can. With a Quick Tunnel, tell them every time that Cloudflare can see what they type into the page (see below), and offer Tailscale Funnel.
192
193
 
194
+ ## The login page
195
+
196
+ When you need a model or a judge that is not signed in on this computer, or a login has expired, and the person who pays for it is not at a terminal here, send them a login link:
197
+
198
+ ```sh
199
+ pots page login --provider openai-codex --text "Sign in with your ChatGPT account, so I can use GPT for the reports" --for slack:@U123
200
+ ```
201
+
202
+ `--provider` is optional: without it, they choose. pi's provider IDs are in `pots login --list` (those signed in) and in the error of a wrong `--provider`. It prints JSON: `{"link": "G1", "url": "https://…/g/<token>/", "expires": "<time>", "via": …, "note": …}`.
203
+
204
+ The page is Pots' own. It runs pi's own login on this computer, as `pots login` does in a terminal: the person chooses a subscription (ChatGPT, Claude, GitHub Copilot, Grok, Kimi and more) or an API key (any of pi's providers, also TypeSafe for Jev), and the page shows what pi asks and shows. A sign-in that needs a browser on this computer works from their phone too: where pi offers a device code or a copy code, the page puts it first; otherwise they copy the address of the page that cannot load at the end and paste it. Ways that need setting up on this computer itself (an AWS credential chain or profile, Google's Application Default Credentials or a service account file) are not offered there; the page tells them to ask you, and you set those up in your shell.
205
+
206
+ - Nothing happens before they press Start, and only the browser that pressed Start first can use the link. It works for an hour unopened, then 15 minutes after Start, for one login or several, until they press Done.
207
+ - A login is for every bot and pi program of this user on this computer, and a new one replaces the provider's old one. The page says so before they sign in.
208
+ - Logins belong to whoever pays for them. Send the link to the person who runs you, or to someone they named, in a DM.
209
+ - When Pots restarts during a sign-in, that sign-in is lost and the link ends; you are told, and a new link lets them try again.
210
+ - A local or OpenAI-compatible server is not on the page. Add it to pi's `~/.pi/agent/models.json` yourself. When it needs a key, take the key with the password page, and give `apiKey` as a command that reads it, as pi allows (`"apiKey": "!grep '^LOCAL_KEY=' ~/.pots/secrets/local-ada.env | cut -d= -f2-"`).
211
+
212
+ You are woken once for each login:
213
+
214
+ ```
215
+ login page: someone used link G1 (made for slack:@U123) and signed in to OpenAI (ChatGPT Plus/Pro) (provider openai-codex, subscription), for every bot and pi on this computer. Usable now: openai-codex/…, …. openai-codex/gpt-… answered when Pots tried it.
216
+ ```
217
+
218
+ It says when the login replaced one, and lists the judges for a provider that has them. You never see a key, a code, a sign-in address or the account. The page tried pi's default model of the provider, as `pots login` does, but chose nothing for you: the model you think with is `model` in your bot.json, and which models do which work is the person's to say, so ask them, or follow what your AGENTS.md says. When nobody signed in by the end of the link, you are woken once more with that, and with how many sign-ins failed; the page showed them why.
219
+
220
+ When you cannot think at all, because your only login has expired, you cannot make the link. The person, or an agent in a terminal on this computer, then runs `pots login --link`: it serves the same page without a bot, prints the link, and prints each login.
221
+
193
222
  ## Where links point: a Quick Tunnel or your own address
194
223
 
195
224
  Pots serves pages on this computer only (127.0.0.1, at `pagePort` in `~/.pots/settings.json`). The internet reaches them in one of two ways:
196
225
 
197
226
  - `publicUrl` in `~/.pots/settings.json` is set (a Tailscale Funnel address, a domain, a reverse proxy): links use it, and no Quick Tunnel starts. `via` is `public-url`.
198
- - `publicUrl` is not set: Pots starts a Cloudflare [Quick Tunnel](https://developers.cloudflare.com/tunnel/get-started/quick-tunnels/) at the first `pots page link`, `pots page secret` or `pots page desktop`, and keeps it until the gateway stops. `via` is `quick-tunnel`. All bots of this computer share it.
227
+ - `publicUrl` is not set: Pots starts a Cloudflare [Quick Tunnel](https://developers.cloudflare.com/tunnel/get-started/quick-tunnels/) at the first `pots page link`, `pots page secret`, `pots page desktop` or `pots page login`, and keeps it until the gateway stops. `via` is `quick-tunnel`. All bots of this computer share it.
199
228
 
200
229
  What a Quick Tunnel means, from Cloudflare's docs and how it works:
201
230