teapot-coding-agent 0.37.13 → 0.37.14

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.
@@ -1378,7 +1378,7 @@ export class Agent {
1378
1378
  }
1379
1379
  // newest usage event seeds the context gauge right after reload —
1380
1380
  // inputTokens from the LAST turn is the live context size, and cached
1381
- // must ride along or the "⚡ N% cached" pill disappears after a restart
1381
+ // must ride along or the "⚡️ N% cached" pill disappears after a restart
1382
1382
  for (let i = own.length - 1; i >= 0; i--) {
1383
1383
  if (own[i].type === "usage") {
1384
1384
  const u = own[i].data;
@@ -3615,7 +3615,7 @@ export class Agent {
3615
3615
  operatorFacing: true,
3616
3616
  content: approved
3617
3617
  ? `✅ completion audit: APPROVED — ${feedback}`
3618
- : `🔍 completion audit: CHANGES REQUIRED — ${feedback}`,
3618
+ : `🔍️ completion audit: CHANGES REQUIRED — ${feedback}`,
3619
3619
  });
3620
3620
  if (!approved) {
3621
3621
  this.consecutiveAuditRejects++;
@@ -132,17 +132,81 @@ export class ServerAuth {
132
132
  ...(this.store.clientSecret ? { client_secret: this.store.clientSecret } : {}),
133
133
  };
134
134
  }
135
+ /**
136
+ * Is the STORED registration unusable for this run?
137
+ *
138
+ * True when a redirect URI was recorded and it is not the one this flow listens on — the same
139
+ * condition `clientInformation()` acts on, factored out so `tokens()` cannot disagree with it.
140
+ */
141
+ registrationIsStale() {
142
+ const stored = this.store.clientInformation;
143
+ const uris = Array.isArray(stored?.redirect_uris) ? stored.redirect_uris : [];
144
+ if (uris.length === 0)
145
+ return false; // unknown is not wrong: older records omit the list
146
+ /**
147
+ * A PLACEHOLDER redirect cannot vouch for a registration.
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).
154
+ *
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.
157
+ */
158
+ if (!/:\d+\//.test(this.redirectUrl))
159
+ return true;
160
+ return !uris.includes(this.redirectUrl);
161
+ }
135
162
  async saveClientInformation(info, _ctx) {
136
163
  const i = info;
164
+ const previous = this.store.clientId;
137
165
  if (typeof i?.client_id === "string")
138
166
  this.store.clientId = i.client_id;
139
167
  if (typeof i?.client_secret === "string")
140
168
  this.store.clientSecret = i.client_secret;
169
+ /**
170
+ * A NEW client id INVALIDATES the grant issued to the old one.
171
+ *
172
+ * `clientInformation()` returns undefined when the stored registration cannot match this run's
173
+ * redirect URI, which makes the SDK register afresh. Keeping the old tokens across that is fatal:
174
+ * the refresh request authenticates as the NEW client while presenting a refresh token the
175
+ * authorization server bound to the OLD one, and the server answers
176
+ * `invalid_grant: Client ID mismatch` — MEASURED against both Notion and Canva, where every
177
+ * reconnect failed for exactly this reason while the store still held a valid-looking token.
178
+ *
179
+ * Dropping them turns that into an honest "needs a grant": the panel shows 🔑 authorize, and
180
+ * completing it issues a token pair for the client that actually exists.
181
+ */
182
+ if (previous && typeof i?.client_id === "string" && i.client_id !== previous) {
183
+ this.store.accessToken = undefined;
184
+ this.store.refreshToken = undefined;
185
+ this.store.expiresAt = undefined;
186
+ }
141
187
  // keep the whole payload: a future field (a client id issued with metadata) survives
142
188
  this.store.clientInformation = info;
143
189
  await this.persist(this.server, this.store);
144
190
  }
145
191
  tokens(_ctx) {
192
+ /**
193
+ * A grant whose client can no longer be reused must not be presented.
194
+ *
195
+ * `clientInformation()` returns undefined when the stored registration cannot match this run's
196
+ * redirect URI, which makes the SDK register afresh — but `tokens()` would still hand back the
197
+ * token pair the OLD client obtained. The refresh then authenticates as the new client while
198
+ * presenting the old client's refresh token, and the server answers
199
+ * `invalid_grant: Client ID mismatch` (MEASURED against Notion and Canva: every reconnect failed
200
+ * this way while the store held a token that looked valid).
201
+ *
202
+ * Returning nothing makes the flow an honest "needs a grant" instead: the panel offers 🔑, and
203
+ * completing it issues a pair for the client that actually exists.
204
+ */
205
+ if (this.store.accessToken && this.registrationIsStale()) {
206
+ this.store.accessToken = undefined;
207
+ this.store.refreshToken = undefined;
208
+ this.store.expiresAt = undefined;
209
+ }
146
210
  if (!this.store.accessToken)
147
211
  return undefined;
148
212
  return {
@@ -157,7 +157,7 @@ export class McpRegistry {
157
157
  /unauthoriz|invalid_token|authorization required/i.test(msg);
158
158
  if (needsAuth) {
159
159
  st.oauthRequired = true;
160
- st.lastError = "this server requires OAuth — use 🔑 authorize in ⚙ settings → MCP servers";
160
+ st.lastError = "this server requires OAuth — use 🔑 authorize in ⚙️ settings → MCP servers";
161
161
  }
162
162
  throw err;
163
163
  }
package/dist/master.js CHANGED
@@ -134,7 +134,7 @@ export function resolveWorkspace(input, base) {
134
134
  * usable by agents via spawn_agent({persona}) */
135
135
  export const SUB_PERSONAS = {
136
136
  reviewer: {
137
- label: "🔍 reviewer",
137
+ label: "🔍️ reviewer",
138
138
  directive: "ROLE: code reviewer. Inspect the change set, judge correctness, style, tests; report concrete findings as a prioritized list.",
139
139
  readOnly: true,
140
140
  },
@@ -143,12 +143,12 @@ export const SUB_PERSONAS = {
143
143
  directive: "ROLE: test engineer. Write and run tests for the task at hand, hunt edge cases, report pass/fail with exact commands.",
144
144
  },
145
145
  researcher: {
146
- label: "🔎 researcher",
146
+ label: "🔎️ researcher",
147
147
  directive: "ROLE: read-only explorer. Search the codebase/docs, map how things work, and report a compact briefing with file:line references.",
148
148
  readOnly: true,
149
149
  },
150
150
  implementer: {
151
- label: "🔨 implementer",
151
+ label: "🔨️ implementer",
152
152
  directive: "ROLE: hands-on implementer. Make the change end-to-end (code + tests), keep edits small and verified, then report what changed and why.",
153
153
  },
154
154
  "gyaru-reviewer": {
@@ -332,7 +332,7 @@ function printAgentEvent(e) {
332
332
  line = `${c("33", "▶ prompt")} (${d.source}) ${clip1(d.text, 110)}`;
333
333
  break;
334
334
  case "tool_call":
335
- line = `${c("36", "⚙ exec")} ${d.name} ${dim(clip1(JSON.stringify(d.args ?? {}), 130))}`;
335
+ line = `${c("36", "⚙️ exec")} ${d.name} ${dim(clip1(JSON.stringify(d.args ?? {}), 130))}`;
336
336
  break;
337
337
  case "tool_result": {
338
338
  const ok = d.ok !== false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.13",
3
+ "version": "0.37.14",
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",