teapot-coding-agent 0.37.19 → 0.37.20

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.
@@ -144,19 +144,22 @@ export class ServerAuth {
144
144
  if (uris.length === 0)
145
145
  return false; // unknown is not wrong: older records omit the list
146
146
  /**
147
- * A PLACEHOLDER redirect cannot vouch for a registration.
147
+ * A PLACEHOLDER redirect says NOTHING either way — so it must not be treated as stale.
148
148
  *
149
- * `authFor()` builds a provider with `http://127.0.0.1/callback` — no port, because none exists
150
- * until a flow opens a listener — and a REconnect uses that instance. A record registered from
151
- * the same placeholder therefore MATCHES, the check says "not stale", and the grant obtained
152
- * under a real port is presented to a client the server no longer knows: `Client ID mismatch`
153
- * (MEASURED on Notion and Canva, every reconnect).
149
+ * `authFor()` builds every reconnect's provider with `http://127.0.0.1/callback`, no port,
150
+ * because none exists until a flow opens a listener. An earlier version called that
151
+ * unconditionally stale, which made `tokens()` DROP the grant on every reconnect: a server that
152
+ * had been authorized minutes earlier reported "needs a grant" again (MEASURED: Notion and
153
+ * Canva both lost their access token after a restart, with `teapot.theme`-style certainty that
154
+ * the authorization itself had worked).
154
155
  *
155
- * Only a listener-backed URL can confirm a registration, so this refuses to reuse tokens
156
- * without one. The panel then shows 🔑 authorize instead of a failure with no way forward.
156
+ * A placeholder can neither confirm nor refute a registration, so the honest answer is "I do not
157
+ * know" — and an unknown registration keeps its grant. A real mismatch (a listener-backed URL
158
+ * the record does not list) is still reported, which is the case that actually produced
159
+ * `Client ID mismatch`.
157
160
  */
158
161
  if (!/:\d+\//.test(this.redirectUrl))
159
- return true;
162
+ return false;
160
163
  return !uris.includes(this.redirectUrl);
161
164
  }
162
165
  async saveClientInformation(info, _ctx) {
@@ -202,11 +205,21 @@ export class ServerAuth {
202
205
  * Returning nothing makes the flow an honest "needs a grant" instead: the panel offers 🔑, and
203
206
  * completing it issues a pair for the client that actually exists.
204
207
  */
205
- if (this.store.accessToken && this.registrationIsStale()) {
206
- this.store.accessToken = undefined;
207
- this.store.refreshToken = undefined;
208
- this.store.expiresAt = undefined;
209
- }
208
+ /**
209
+ * A registration we cannot vouch for means DO NOT PRESENT the grant — never DELETE it.
210
+ *
211
+ * This used to clear the stored tokens here, and clearing is not the same as declining: the
212
+ * store persists on the next write, so an "I cannot verify this" answer from a placeholder
213
+ * provider ERASED a working grant minutes after it was obtained (MEASURED on this machine:
214
+ * both Notion's and Canva's `accessToken`/`refreshToken` were gone from mcp-oauth.json while the
215
+ * authorizations themselves had succeeded).
216
+ *
217
+ * Declining is reversible — the next connect that CAN verify the registration reads the tokens
218
+ * again. Erasing is not: it costs the operator a full re-authorization for a transient
219
+ * uncertainty.
220
+ */
221
+ if (this.store.accessToken && this.registrationIsStale())
222
+ return undefined;
210
223
  if (!this.store.accessToken)
211
224
  return undefined;
212
225
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.19",
3
+ "version": "0.37.20",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",