teapot-coding-agent 0.36.11 → 0.37.1
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/dist/agent/mcp-registry.js +8 -3
- package/dist/agent/mcp.js +35 -7
- package/package.json +1 -1
- package/public/assets/index-Cr_lGhth.js +33 -0
- package/public/assets/index-Cr_lGhth.js.map +1 -0
- package/public/assets/index-UPEwVQvq.css +1 -0
- package/public/assets/{shiki-CPjiSelZ.js → shiki-BFsiuQ1D.js} +2 -2
- package/public/assets/shiki-BFsiuQ1D.js.map +1 -0
- package/public/index.html +2 -2
- package/public/assets/index-BN1B31uj.css +0 -1
- package/public/assets/index-kssN-nWf.js +0 -31
- package/public/assets/index-kssN-nWf.js.map +0 -1
- package/public/assets/shiki-CPjiSelZ.js.map +0 -1
|
@@ -282,9 +282,14 @@ export class McpRegistry {
|
|
|
282
282
|
* wrong iss -> IssuerMismatchError "received https://evil.example"
|
|
283
283
|
* so the check is not disabled — a genuinely mismatched issuer is still rejected.
|
|
284
284
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
/**
|
|
286
|
+
* `finishAuth` returns a NEW connection: the instance that redeemed the code cannot serve
|
|
287
|
+
* requests (a transport is one-shot), so storing `conn` here would leave a dead handle.
|
|
288
|
+
*/
|
|
289
|
+
const live = await conn.finishAuth(code, iss ?? auth.expectedIssuer());
|
|
290
|
+
await conn.close().catch(() => { });
|
|
291
|
+
st.connection = live;
|
|
292
|
+
st.tools = await live.tools();
|
|
288
293
|
st.status = "connected";
|
|
289
294
|
st.oauthRequired = false;
|
|
290
295
|
st.lastError = undefined;
|
package/dist/agent/mcp.js
CHANGED
|
@@ -116,9 +116,24 @@ export async function connectMcp(cfg, auth) {
|
|
|
116
116
|
await client.connect(session);
|
|
117
117
|
}
|
|
118
118
|
catch (err) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
/**
|
|
120
|
+
* A 401 is NOT a dead connection — it is the first half of the OAuth flow.
|
|
121
|
+
*
|
|
122
|
+
* `client.connect()` failing with UnauthorizedError means the server wants a grant. Closing the
|
|
123
|
+
* client here used to destroy the only transport that could complete it: a transport cannot be
|
|
124
|
+
* re-started ("StreamableHTTPClientTransport already started!") and `finishAuth()` exchanges the
|
|
125
|
+
* code through THIS instance's provider, so the second `connect()` after `finishAuth` always
|
|
126
|
+
* threw — surfacing as a bare `UnauthorizedError: Unauthorized` even though the browser had
|
|
127
|
+
* completed the authorization and the token WAS saved.
|
|
128
|
+
*
|
|
129
|
+
* MEASURED: connect → 401; close; connect again → "already started". And with the exchange
|
|
130
|
+
* succeeding, the tokens were present and the connection still failed.
|
|
131
|
+
*
|
|
132
|
+
* So the client stays open when the caller supplied an auth provider (it may need to finish the
|
|
133
|
+
* flow on it). Without a provider there is nothing to complete, so it is closed as before.
|
|
134
|
+
*/
|
|
135
|
+
if (!auth)
|
|
136
|
+
await client.close().catch(() => { });
|
|
122
137
|
throw err;
|
|
123
138
|
}
|
|
124
139
|
return {
|
|
@@ -146,13 +161,26 @@ export async function connectMcp(cfg, auth) {
|
|
|
146
161
|
return resultText(res);
|
|
147
162
|
},
|
|
148
163
|
async finishAuth(code, iss) {
|
|
149
|
-
// the VERIFIER and discovery state live on the transport, so completing the
|
|
150
|
-
// exchange must go through the same instance that started the flow
|
|
151
164
|
if (!(session instanceof StreamableHTTPClientTransport) && !(session instanceof SSEClientTransport))
|
|
152
165
|
throw new Error("this transport has no OAuth flow");
|
|
166
|
+
/**
|
|
167
|
+
* Exchange on THIS transport — the PKCE verifier and the discovery record are read from the
|
|
168
|
+
* provider, but the request is issued with this instance's fetch/init.
|
|
169
|
+
*/
|
|
153
170
|
await session.finishAuth(iss === undefined ? code : new URLSearchParams({ code, iss }));
|
|
154
|
-
|
|
155
|
-
|
|
171
|
+
/**
|
|
172
|
+
* …then build a FRESH connection, because this one cannot be revived.
|
|
173
|
+
*
|
|
174
|
+
* A transport is one-shot: after the 401 that started the flow, connecting again throws
|
|
175
|
+
* "already started" even without `close()`. MEASURED, and it is why the flow appeared to
|
|
176
|
+
* complete and then report `UnauthorizedError: Unauthorized` — `client.connect` on a spent
|
|
177
|
+
* transport fails with no message of its own, and the SDK's UnauthorizedError defaults its
|
|
178
|
+
* text to the word "Unauthorized".
|
|
179
|
+
*
|
|
180
|
+
* The provider is shared, so the new instance reads the tokens the exchange just stored.
|
|
181
|
+
*/
|
|
182
|
+
await client.close().catch(() => { });
|
|
183
|
+
return await connectMcp(cfg, auth);
|
|
156
184
|
},
|
|
157
185
|
async close() {
|
|
158
186
|
await client.close().catch(() => { });
|