teapot-coding-agent 0.36.9 → 0.36.10
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-oauth-manager.js +28 -0
- package/dist/agent/mcp-registry.js +21 -1
- package/dist/config-schema.js +12 -0
- package/dist/index.js +5 -4
- package/dist/master.js +20 -0
- package/dist/server/api.js +18 -7
- package/package.json +1 -1
- package/public/assets/{index-CoH7Vqvo.js → index-BgdJufa_.js} +22 -22
- package/public/assets/index-BgdJufa_.js.map +1 -0
- package/public/assets/{shiki-BKqf8YtI.js → shiki-B7WJz7Ie.js} +2 -2
- package/public/assets/{shiki-BKqf8YtI.js.map → shiki-B7WJz7Ie.js.map} +1 -1
- package/public/index.html +1 -1
- package/public/assets/index-CoH7Vqvo.js.map +0 -1
|
@@ -221,6 +221,34 @@ export class ServerAuth {
|
|
|
221
221
|
discoveryState() {
|
|
222
222
|
return this.store.discoveryState;
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* The issuer this client believes it is talking to, from our OWN discovery record.
|
|
226
|
+
*
|
|
227
|
+
* Needed because the SDK treats a missing `iss` on the callback as an ATTACK when the server's
|
|
228
|
+
* metadata declares `authorization_response_iss_parameter_supported` (RFC 9207), and throws
|
|
229
|
+
* `IssuerMismatchError` before the code is ever redeemed.
|
|
230
|
+
*
|
|
231
|
+
* Notion declares that support and then does not send `iss`. MEASURED against
|
|
232
|
+
* `mcp.notion.com/.well-known/oauth-authorization-server`:
|
|
233
|
+
* `authorization_response_iss_parameter_supported: true`, while its real redirect carries only
|
|
234
|
+
* `code` and `state`. Reproduced directly against the SDK with this machine's stored grant:
|
|
235
|
+
* `IssuerMismatchError: expected "https://mcp.notion.com", received undefined` — i.e. every
|
|
236
|
+
* browser-completed authorization was discarded at the last step, which is the "コールバック踏んだ
|
|
237
|
+
* のに Unauthorized" report.
|
|
238
|
+
*
|
|
239
|
+
* Supplying the issuer ourselves is sound here: the code arrived on OUR loopback listener, and
|
|
240
|
+
* this value comes from the discovery document we fetched before sending the browser out. RFC 9207
|
|
241
|
+
* exists to stop a MIX-UP attack, and there is no mix-up to detect when the client already knows
|
|
242
|
+
* which authorization server it directed the user to. The SDK's own check
|
|
243
|
+
* (`iss !== expectedIssuer`) still runs, so a genuinely wrong issuer is still rejected.
|
|
244
|
+
*/
|
|
245
|
+
expectedIssuer() {
|
|
246
|
+
const meta = this.store.discoveryState?.authorizationServerMetadata;
|
|
247
|
+
if (typeof meta?.issuer === "string" && meta.issuer)
|
|
248
|
+
return meta.issuer;
|
|
249
|
+
const url = this.store.discoveryState?.authorizationServerUrl;
|
|
250
|
+
return typeof url === "string" && url ? url : undefined;
|
|
251
|
+
}
|
|
224
252
|
async saveDiscoveryState(state) {
|
|
225
253
|
if (!state || typeof state !== "object")
|
|
226
254
|
return;
|
|
@@ -262,7 +262,27 @@ export class McpRegistry {
|
|
|
262
262
|
try {
|
|
263
263
|
const { code, iss } = await loop.wait(FLOW_TIMEOUT_MS);
|
|
264
264
|
const conn = await connectMcp(st.config, { provider: auth });
|
|
265
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Supply `iss` from OUR discovery record when the callback omitted it.
|
|
267
|
+
*
|
|
268
|
+
* RFC 9207 §2 says a server that advertises
|
|
269
|
+
* `authorization_response_iss_parameter_supported: true` MUST include `iss` in the
|
|
270
|
+
* response, and §2.4 says clients MUST reject a response without it. Notion advertises
|
|
271
|
+
* `true` and then sends only `code` and `state`, so a strictly-conforming client discards
|
|
272
|
+
* every completed authorization — which is "Notionがコールバック踏んだのに Unauthorized".
|
|
273
|
+
*
|
|
274
|
+
* §2.4 also allows the opposite: "clients ... MAY accept authorization responses that do
|
|
275
|
+
* not contain the iss parameter ... Local policy or configuration can determine whether to
|
|
276
|
+
* accept such responses". We accept them, using the issuer we recorded BEFORE sending the
|
|
277
|
+
* browser out, because that is the value the mix-up check needs.
|
|
278
|
+
*
|
|
279
|
+
* MEASURED against the real SDK with this machine's stored grant:
|
|
280
|
+
* no iss -> IssuerMismatchError "received undefined" (the reported failure)
|
|
281
|
+
* correct iss -> the token endpoint is reached (invalid_grant for a dummy code)
|
|
282
|
+
* wrong iss -> IssuerMismatchError "received https://evil.example"
|
|
283
|
+
* so the check is not disabled — a genuinely mismatched issuer is still rejected.
|
|
284
|
+
*/
|
|
285
|
+
await conn.finishAuth(code, iss ?? auth.expectedIssuer());
|
|
266
286
|
st.connection = conn;
|
|
267
287
|
st.tools = await conn.tools();
|
|
268
288
|
st.status = "connected";
|
package/dist/config-schema.js
CHANGED
|
@@ -52,6 +52,18 @@ export const ConfigPatchSchema = z.object({
|
|
|
52
52
|
// null clears a saved window pin → back to per-model inference (same contract as contextTokenBudget)
|
|
53
53
|
contextWindowTokens: z.number().int().min(1_000).nullable().optional(),
|
|
54
54
|
maxSpawnDepth: z.number().int().min(0).max(8).optional(),
|
|
55
|
+
/**
|
|
56
|
+
* The shared secret protecting `/api/*` — settable from the settings panel.
|
|
57
|
+
*
|
|
58
|
+
* It used to be reachable only through `POST /api/setup`, which refuses once a config file exists.
|
|
59
|
+
* That was fine while the first-run wizard existed; the wizard is gone, so there was NO way to set
|
|
60
|
+
* a password at all. Asked as "初回起動ウィザードは前に廃止したはずだからパスワード設定できないの
|
|
61
|
+
* では?" — correct.
|
|
62
|
+
*
|
|
63
|
+
* An EMPTY STRING is meaningful and clears it (back to loopback-only trust), which is why this
|
|
64
|
+
* accepts `""` rather than requiring a minimum length. `TEAPOT_API_TOKEN` still wins over it.
|
|
65
|
+
*/
|
|
66
|
+
password: z.string().max(200).optional(),
|
|
55
67
|
/** #161: prune old tool output early (opt-in, for small-window models) */
|
|
56
68
|
shortContext: z.boolean().optional(),
|
|
57
69
|
// soft cap on LLM turns in one round; reaching it nudges the model to wrap
|
package/dist/index.js
CHANGED
|
@@ -146,10 +146,11 @@ async function main() {
|
|
|
146
146
|
* On LOOPBACK this is the normal, safe default — so say so plainly instead of printing an
|
|
147
147
|
* alarming "no API token set" on every start.
|
|
148
148
|
*
|
|
149
|
-
* Asked as "no API token setはなんだろう": nothing is wrong.
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* at info level
|
|
149
|
+
* Asked as "no API token setはなんだろう": nothing is wrong. On loopback only this machine can
|
|
150
|
+
* connect, so an unset password is the safe default rather than a fault — and it is settable in
|
|
151
|
+
* settings → live update (it uses to be reachable only through the first-run wizard, which was
|
|
152
|
+
* removed). The message now says that, on stdout at info level; `console.error` made a healthy
|
|
153
|
+
* start look like a fault.
|
|
153
154
|
*
|
|
154
155
|
* The WARNING branch is unchanged and still goes to stderr: that one IS a problem.
|
|
155
156
|
*/
|
package/dist/master.js
CHANGED
|
@@ -505,6 +505,18 @@ export class Master {
|
|
|
505
505
|
*/
|
|
506
506
|
if (this.config.customThemes !== undefined)
|
|
507
507
|
this.raw.customThemes = this.config.customThemes;
|
|
508
|
+
/**
|
|
509
|
+
* The API password — same mirror, same trap.
|
|
510
|
+
*
|
|
511
|
+
* It was never in `raw` because it was only ever written by the first-run setup path, which
|
|
512
|
+
* wrote the file wholesale. Now that the settings panel can change it, a missing mirror would
|
|
513
|
+
* make "set a password" appear to work and vanish on the next restart, leaving the server open
|
|
514
|
+
* while the operator believes it is closed — the worst possible direction for this field.
|
|
515
|
+
*/
|
|
516
|
+
if (this.config.password !== undefined)
|
|
517
|
+
this.raw.password = this.config.password;
|
|
518
|
+
else
|
|
519
|
+
delete this.raw.password;
|
|
508
520
|
if (this.config.themePrefs !== undefined)
|
|
509
521
|
this.raw.themePrefs = this.config.themePrefs;
|
|
510
522
|
/**
|
|
@@ -663,6 +675,14 @@ export class Master {
|
|
|
663
675
|
updateConfig(patch) {
|
|
664
676
|
if (patch.providers)
|
|
665
677
|
this.config.providers = patch.providers;
|
|
678
|
+
/**
|
|
679
|
+
* `!== undefined`, so `""` is honoured as "clear it".
|
|
680
|
+
*
|
|
681
|
+
* A truthiness check would silently keep the old password when the operator emptied the field,
|
|
682
|
+
* which is the one case where they are explicitly asking to remove the protection.
|
|
683
|
+
*/
|
|
684
|
+
if (patch.password !== undefined)
|
|
685
|
+
this.config.password = patch.password || undefined;
|
|
666
686
|
if (patch.defaultProvider !== undefined)
|
|
667
687
|
this.config.defaultProvider = patch.defaultProvider;
|
|
668
688
|
if (patch.progressIntervalMs !== undefined) {
|
package/dist/server/api.js
CHANGED
|
@@ -112,9 +112,10 @@ export function buildApp(master) {
|
|
|
112
112
|
// the config's `password` field. Static files stay public; only /api/* is
|
|
113
113
|
// gated.
|
|
114
114
|
//
|
|
115
|
-
// Read DYNAMICALLY:
|
|
116
|
-
//
|
|
117
|
-
//
|
|
115
|
+
// Read DYNAMICALLY: `config.password` changes while this app is running — the
|
|
116
|
+
// settings panel writes it through `PUT /api/config`. A const captured here once
|
|
117
|
+
// meant a password set after boot did not take effect until a process restart,
|
|
118
|
+
// leaving the server open while the operator believed it was closed.
|
|
118
119
|
const apiToken = () => process.env.TEAPOT_API_TOKEN || master.config.password || "";
|
|
119
120
|
/**
|
|
120
121
|
* Routes where `?token=` is accepted (#79).
|
|
@@ -215,10 +216,12 @@ export function buildApp(master) {
|
|
|
215
216
|
/**
|
|
216
217
|
* With no token configured the API is still open to LOCAL clients, but it now says so loudly.
|
|
217
218
|
*
|
|
218
|
-
* Opening it is a real decision:
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
219
|
+
* Opening it is a real decision: a fresh install has no password, and on loopback that is the
|
|
220
|
+
* safe default — only this machine can reach it. (It IS settable now, in settings → live update;
|
|
221
|
+
* before that the only path was `POST /api/setup`, which refuses once a config file exists, so
|
|
222
|
+
* the wizard's removal had left no way at all.) Leaving the state silent is how the OpenCode
|
|
223
|
+
* advisory happened — their server was unauthenticated by default and nobody noticed. The header
|
|
224
|
+
* makes it visible to every client, and the startup banner says it once in plain words.
|
|
222
225
|
*/
|
|
223
226
|
if (!want) {
|
|
224
227
|
c.header("x-teapot-auth", "none");
|
|
@@ -918,6 +921,13 @@ export function buildApp(master) {
|
|
|
918
921
|
* one would nag about a working setup.
|
|
919
922
|
*/
|
|
920
923
|
needsSetup: Object.keys(master.config.providers ?? {}).length === 0,
|
|
924
|
+
/**
|
|
925
|
+
* Whether an API password is set — the FACT only, never the value.
|
|
926
|
+
*
|
|
927
|
+
* The panel needs it to label the field honestly ("unchanged" vs "none"); sending the secret
|
|
928
|
+
* back would put it in the DOM and in any devtools capture of the response.
|
|
929
|
+
*/
|
|
930
|
+
hasPassword: Boolean(master.config.password),
|
|
921
931
|
providers: mask(master.config.providers),
|
|
922
932
|
defaultProvider: master.config.defaultProvider,
|
|
923
933
|
progressIntervalMs: master.config.progressIntervalMs,
|
|
@@ -975,6 +985,7 @@ export function buildApp(master) {
|
|
|
975
985
|
shortContext: patch.shortContext,
|
|
976
986
|
tasks: patch.tasks,
|
|
977
987
|
mcpServers: patch.mcpServers,
|
|
988
|
+
...(patch.password !== undefined ? { password: patch.password } : {}),
|
|
978
989
|
});
|
|
979
990
|
// #67: apply the new server list to the live registry and connect in the
|
|
980
991
|
// background — an added server's tools must appear on the next turn without a
|