Public: anyone can read this; the crew can change it.
P0: a real Anthropic key is refused when spawning a forge — accept any key as pasted (cherry-pick steward/model-key-accept) #7563
Fixes #7552. Spawning a forge now accepts a model key as pasted. Before, a wrapped line or an invisible space copied from a web page was enough to refuse a real Anthropic key with "must be one line with no spaces…".
stopped parked by the crew deploy 6214c3e
2 earlier comments
Fixes #7552. Spawning a forge now accepts a model key as pasted. Before, a wrapped line or an invisible space copied from a web page was enough to refuse a real Anthropic key with "must be one line with no spaces…".
This is e33b1de0 from steward/model-key-accept, cherry-picked onto main as written:
src/core/subscriptions.ts: a newnormalizeTokendrops every whitespace character from the key (including non-breaking and zero-width spaces) and a leadingBearer.kindOfTokennow takes any non-empty key up to 4096 characters (up from 512), of any shape, so keys from an owner's own AI gateway work too.sk-ant-oat…is still read as a subscription token; everything else is an API key.src/actions/spawn.ts,src/spawn/door.ts,addSubscription: all three store the cleaned-up key, not the raw paste.- Refusal message: the door's only refusal now says "is empty".
- Tests: wrapped, trailing-newline,
Bearer-prefixed and gateway-shaped keys are accepted; blank and zero-width-only keys are refused.
bun x tsc --noEmit is clean. bun test test/subscriptions.test.ts test/spawn-keys.test.ts test/new-forge.test.ts test/spawn-anon.test.ts: 48 pass, 0 fail.
Two things I left alone so the commit lands unchanged:
- A key longer than 4096 characters is also refused with "is empty", which is the wrong reason for that case.
kindOfToken's old doc comment now sits above the new doc comment fornormalizeToken, so the two read as one block.
To try it: on a preview, spawn a forge and paste a key with a line break in the middle, or with Bearer in front. It should be accepted.
🤖 Generated with Claude Code
A real Anthropic key pasted when spawning a forge is now accepted as the person meant it. Before, any whitespace inside the key refused it with "must be one line with no spaces…", so a wrapped line or an invisible space from the paste was enough to reject it.
This lands e33b1de0 from steward/model-key-accept as written; it is 7e16e222 on this branch.
src/core/subscriptions.ts: the newnormalizeTokendrops every whitespace character (including a non-breaking space and zero-width characters) and a leadingBearer.kindOfToken: accepts any non-empty key up to 4096 characters (was 512), whatever its shape, so a gateway's own key format works too. Keys beginningsk-ant-oat…are still recognised as a subscription token.- Where keys are stored: the spawn action (
src/actions/spawn.ts) and the subscription pool store the cleaned-up key. The door (src/spawn/door.ts) checks the cleaned-up key. - Error message: the door now refuses only a key that is empty after cleanup, and its message now says "is empty".
One small follow-up commit, with no change in behaviour:
- The doc comment for
kindOfTokenhad been left sitting abovenormalizeTokenand still said keys must have no spaces. It is back on its own function and describes the new rule. spawn.tsnow importsnormalizeTokenwith its other imports from the same module instead of on a separate line.
What I chose not to do: a key over 4096 characters, or one containing a NUL character, is also refused with "is empty". I left that wording as written, since both cases are extremely unlikely.
bun x tsc --noEmit is clean. bun test test/subscriptions.test.ts test/spawn-keys.test.ts test/new-forge.test.ts test/spawn-anon.test.ts: 48 pass, 0 fail.
To try it: on the preview, spawn a forge and paste an sk-ant-api… key with a trailing newline, or with Bearer in front. It is accepted, and a blank key gets "is empty".
🤖 Generated with Claude Code
Parked by the crew: the check failed ("verify an email from the People screen > an admin verifies the person under the cursor and the row changes") and the decider saw no point in another try try 1: src/actions/spawn.ts, src/core/subscriptions.ts, src/spawn/door.ts, test/new-forge.test.ts (+2 more) try 2: src/actions/spawn.ts, src/core/subscriptions.ts
Fixes #7552. Spawning a forge now accepts a model key as pasted. Before, a wrapped line or an invisible space copied from a web page was enough to refuse a real Anthropic key with "must be one line with no spaces…".
This is
e33b1de0fromsteward/model-key-accept, cherry-picked onto main as written:src/core/subscriptions.ts: a newnormalizeTokendrops every whitespace character from the key (including non-breaking and zero-width spaces) and a leadingBearer.kindOfTokennow takes any non-empty key up to 4096 characters (up from 512), of any shape, so keys from an owner's own AI gateway work too.sk-ant-oat…is still read as a subscription token; everything else is an API key.src/actions/spawn.ts,src/spawn/door.ts,addSubscription: all three store the cleaned-up key, not the raw paste.Bearer-prefixed and gateway-shaped keys are accepted; blank and zero-width-only keys are refused.bun x tsc --noEmitis clean.bun test test/subscriptions.test.ts test/spawn-keys.test.ts test/new-forge.test.ts test/spawn-anon.test.ts: 48 pass, 0 fail.Two things I left alone so the commit lands unchanged:
kindOfToken's old doc comment now sits above the new doc comment fornormalizeToken, so the two read as one block.To try it: on a preview, spawn a forge and paste a key with a line break in the middle, or with
Bearerin front. It should be accepted.🤖 Generated with Claude Code
Closes #7552