mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-23 14:17:06 +00:00
4d4b0b0990b45a6797feab68a8b8a91f85b42478
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2d12dcc99f |
Reorganize AI drivers and harden request handling (#4614)
* Move the AI drivers into drivers/ai
The seven drivers/ai-* folders and the AI-only helpers in drivers/util
become one tree:
drivers/ai/interfaces/<interface>/ the Puter-facing drivers
drivers/ai/providers/<vendor>/<interface>/ vendor adapters, catalogs, tests
drivers/ai/protocols/openaiCompatible/ the shared OpenAI wire protocol
drivers/ai/shared/ helpers several interfaces use
Files are moved and their relative imports rewritten; no implementation
changes. Driver names, aliases, interfaces, config keys, model ids and
usage keys are unchanged.
The chat catalog registration test scanned providers/*/ next to itself.
It now scans providers/*/chat/ and fails if the scan finds no catalog, so
a wrong directory can't pass it.
General helpers that non-AI code also uses stay in drivers/util: file
input, data URIs, upstream errors, stream piping, CRUD limits.
* Document the AI driver layout
doc/ai-drivers.md explains what interfaces, providers, protocols and
shared each own, the import rules between them, where a new file goes,
and the steps for adding a provider or an AI interface. It also lists
the three places that don't follow the layout yet.
doc/architecture.md and AGENTS.md link to it.
* Move catalogPrice into ai/shared
Chat providers and the Cloudflare and xAI image catalogs all parse vendor
prices with catalogPrice, so it lives in shared/ instead of the chat
interface's pricing helpers. The image catalogs no longer import from
the chat interface.
* Move the Textract and Mistral OCR calls into provider classes
OCRDriver held both vendors' clients, request building, response
normalizing and metering. That now lives in TextractOcrProvider
(providers/awsTextract/ocr) and MistralOcrProvider (providers/mistral/ocr),
both implementing IOcrProvider. The driver keeps the provider catalog,
model resolution, auth and credit gates, and input resolution.
The page estimate, document detection and credit hold both providers use
are in interfaces/ocr/common.ts.
No behavior change: same validation order, error messages, usage keys,
holds and charges.
* Move the ElevenLabs voice changer into a provider class
VoiceChangerDriver built the ElevenLabs request, measured the converted
audio and metered it, and imported the output formats from the ElevenLabs
text-to-speech provider. That code is now in providers/elevenlabs:
outputFormats.ts formats both speech interfaces use
speechToSpeech/ElevenLabsSpeechToSpeechProvider.ts
speechToSpeech/measuredOutput.ts WAV, Opus and byte-rate timing
speechToSpeech/costs.ts
The driver keeps provider resolution, test mode and the auth check. With
one provider it holds the class directly; there is no provider interface.
No behavior change: same validation order, error messages, usage keys,
holds and charges.
* Move the AI billing helpers the realtime relay uses below the driver layer
OpenAIRealtimeRelayService is a service, and it imported the cost factor,
the provider key reader and a transcription price from drivers/ai. Those
now live in src/backend/util, which both layers can import:
util/aiCostFactor.ts withAiCostFactor, withAiCreditHold and the
request cost helpers, unchanged
util/aiProviderKey.ts readProviderKey, cut from providerRegistry.ts
util/aiPrices.ts the gpt-transcribe per-second price, read by the
OpenAI speech-to-text cost table and the relay
withStreamedAiCharge returns a DriverStreamResult, so it stays in the
driver layer as drivers/ai/shared/streamedAiCharge.ts with its tests.
MeteringService is untouched. No prices or billing behavior change.
* Remove the aiUserIdentifier alias
shared/aiUserIdentifier.ts re-exported upstreamUserIdentifier under a
second name, and only its own test imported it. The alias is gone; its
tests, which cover truncation and actor shapes the other file didn't,
replace the four cases in upstreamIdentifier.test.ts.
* Move the AI test helpers into the AI tree
drivers/integrationTestUtil.ts held helpers for AI provider tests, but a
store test and the realtime relay test imported from it too.
drivers/ai/shared/integrationTestUtil.ts the provider test helpers
testEnv.ts optionalEnv and skipUnlessEnv,
for any env-gated suite
testUtil.ts withAiCostFactorHook, next to
the server it hooks
No test under services/ or stores/ imports from the driver layer's AI
code now. The typecheck baseline entry for the moved file is renamed, not
regenerated.
* Split the tool and compaction helpers by dialect
FunctionCalling.js and compaction.js each held Puter-facing parsing next
to OpenAI and Anthropic request shapes. Each dialect now owns its mapping:
interfaces/chat/utils normalize_tools_object, readCompaction and the
other dialect-neutral checks
protocols/openaiCompatible/openaiParams.ts
toolsToWire (was make_openai_tools) and
toOpenAiContextManagement
providers/claude/chat/contextManagement.ts
toAnthropicContextManagement
toolsToWire takes the dialect as its second argument, like the other
mappers in that module, and takes an array; every caller already guarded
the empty case.
make_claude_tools is removed. Nothing but its tests called it: the Claude
provider uses claudeToolPolicy directly. The three cases only those tests
had are added to the claudeToolPolicy tests. The chat interface helpers no
longer import from providers/claude.
* Remove the unused ImageProvider base class
Every image provider implements IImageProvider directly; nothing extended
or imported the abstract class in interfaces/image/ImageProvider.ts.
The guide's import rules now say that only an interface's driver file
imports providers, which holds since the tool helpers stopped importing
the Claude policy.
* Rerun Replicate predictions an output safety checker rejects
Some community models check the generated image and fail the
prediction with "Try running it again" for a share of seeds, whatever
the prompt. adirik/realvisxl-v3.0-turbo failed 5 of 24 runs of "a small
red cube on a white table" that way.
A prediction that fails with that message is now run again, up to two
more times, inside the same deadline and credit hold. A request that
pins a seed is not rerun, because the same seed is rejected again.
Only the prediction that succeeds is metered, as before.
* Answer malformed AI requests with a 400 where they enter
A value that used to end in an unclassified error, in a request or in
an upstream answer, now gets a classified one before provider code runs
on it. A value a driver or provider ignored or refused before is
handled as it was.
Every driver:
- shared/scalarOptions.ts answers 400 for a value that cannot be
converted to text, such as { "toString": null }, in the options a
driver reads as text, a number or a flag. The chat, video, text to
speech, speech to text, voice changer and OCR drivers call it first.
- An unknown provider name that is not text gets the same 400 as any
other unknown name.
Chat requests:
- A falsy `tools` means no tools on every provider.
- A tool call id or a content block type that cannot be converted to
text is a 400.
- A tool result that is an object is sent as its JSON, like the content
of a `tool` message.
- `include` that is not an array is a 400.
- `anthropicBetas` that is not a list of names is dropped.
- Gemini's native route answers 400 when no user or assistant message
is left to send.
- The prompt estimate reads a compaction block whose content is not a
string.
Image, video, speech and OCR requests:
- The image driver checks `input_image_mime_type` with `quality` and
`resolution`.
- The video driver answers 400 for a model that is not a string.
- The voice changer answers 400 for an `output_format` that is not a
string.
- Mistral OCR answers 400 when the SDK refuses the options before
sending them, as Mistral chat does.
Upstream answers to chat:
- A choice without a message is the existing 400 bad_response, which
still falls back.
- A usage count that is not a number is reported as zero in the cost
event, as pricing already skips it.
* Fuzz the AI drivers with seeded requests and upstream answers
Two seeded suites send malformed input through the real drivers and
providers. The vendors are played at the HTTP boundary, so each
provider's request and response code runs.
- ChatCompletionDriver.fuzz.test.ts covers the 17 chat providers that
have a static catalog. Requests with a few values changed must
resolve or reject below 500 without marking a route unhealthy.
Valid requests against wrong statuses, bodies of the wrong shape and
broken event streams must end with an answer or a classified error.
A stream only has to end; the error line it carries is not checked.
- mediaDrivers.fuzz.test.ts covers the image, video, speech and OCR
drivers, called as a user with unlimited metering so a request gets
past file input and the credit hold. Every vendor refuses the
request, and every call must end with a classified error.
shared/fuzzTestUtil.ts holds the seeded random source, the hostile JSON
values, the mutation, and the stand-in for fetch, undici and axios. An
SDK that calls https.request itself fails the suite. PUTER_FUZZ_CASES
raises the case count for a longer run. doc/ai-drivers.md describes the
suites.
* Restore the CODEOWNERS default owner and wildcard patterns
The default owner line read `- @Salazareo`, which only matches a file
named `-`, so files without a specific owner had none. Three patterns
had their `*` escaped, which GitHub rejects as invalid, so their lines
assigned no owner.
---------
Co-authored-by: Daniel Salazar <daniel.salazar@puter.com>
|
||
|
|
37dcee78f0 |
Move login, signup, account picker, password recovery and 2FA to dashboard-style dialogs (#4522)
* Move login, signup, account picker, password recovery and 2FA to dashboard-style dialogs The sign-in surfaces were separate UIWindows that opened over each other (login, then a recovery window over it, then a 2FA window over that). They are now screens of one dashboard-style card built on mountDashboardOverlay, the same shell, fields, buttons and status line as the dashboard's account dialogs. Screens replace each other in place, with Back, and keep what was typed. - Page presentation for cover pages and sign-in popups: an opaque page with a centered card, filling the screen on phones and in popups. Dialog presentation elsewhere: dimmed backdrop, centered card, bottom sheet on phones. - Each call site keeps whether it could be dismissed, its promise contract, OIDC gating in popups, Turnstile, the honeypot, bonus codes, the post-signup verification gates, reauth auth_id, and redirect handling. - Keys typed in the card no longer reach the desktop's document shortcuts. - A second sign-in prompt joins the open flow instead of stacking a card. - Server messages render as text; prefilled values are encoded. * Show the signup screen's errors above the provider buttons The status line lived inside the email form, which hides behind the provider buttons (or for good, when only provider signups are open), so an error the screen opened with, like a refused provider signup, was never shown. * Cover the page with a new account's checks when signup was a page Signup as a page (a sign-in popup, /action/signup) closes its card for the email, phone and card checks; they opened as floating windows over an empty backdrop instead of covering the page as they did before. * Give the auth card's Back and close bar a background once it scrolls On a short screen the card's content scrolled under the bare Back and close buttons, which then sat on top of it: the Back chevron covered the edge of a provider button and took its taps. Once the showing screen is scrolled, the bar turns opaque with a divider, as the footer has; at rest nothing changes. * Raise a failed session-cookie sync alert above the sign-in card Signing in waits on this alert with the auth card still up. The card sits above every ordinary window, so the alert opened underneath it and the login spun forever. It now opens in the stay-on-top band. * Keep focus where it is when a second sign-in prompt joins the card A prompt that joins the open auth card focused the screen's first field, so one arriving while the user typed their password sent the rest of it into the username field. It now only brings focus back when it has left the card. * Keep focus in the auth card while its form is busy Submitting disabled the focused field, which dropped focus to the page, so keys pressed while the request was in flight (Delete, Enter, letters) reached the desktop's document shortcuts. * Keep focus in the auth card when its backdrop is pressed A press on the dimmed backdrop (or a page's background) that didn't dismiss the card moved focus to the page, so the next keys went to the desktop's document shortcuts and Tab could leave the card. * Point the Turnstile migration note at the new signup screen UIWindowSignup no longer exists; the widget renders in UI/Auth/UIAuthSignup.js. * Reload after sign-in when only the URL's hash would change On a dashboard tab (/#files) the redirect after a login or signup was the same page with a hash, so location.replace only scrolled: the new account was signed in but the page never reloaded, and the card stayed up, busy, until closed. * Span the screen with the auth bottom sheet on wider phones The card's 400px cap outranked the dashboard sheet's full width, so on phones between 401 and 600px wide the sheet left gaps on both sides. * Return focus to the auth form when a request fails A busy card parks focus on itself while its fields are locked. When the server refused a signup, focus stayed there, so Enter did nothing and the user had to tab back in. Ending busy now hands focus back to the control that had it, once that control is enabled again. * Keep the current account when a login is dismissed mid-request Closing the auth card while its login request was out still signed the browser in to the other account and reloaded once the server answered, though the caller had already been told the user dismissed it. A login that answers after the card closed is now dropped. * Make the auth card's logo a link where it leads somewhere On a cover page the Puter logo was an image with a click handler: no keyboard access, no name for screen readers, no middle-click. It is now a link named Puter. Everywhere else the logo is marked decorative, since the title beside it names the screen. * Return to the login screen when signing in fails after a 2FA code If storing the new session failed after a verified code, the error went to the hidden login screen while the code screen stayed up, busy, with its boxes locked. The card now goes back to the login screen first. * Hand the session cookie back when a login is dismissed mid-request The server sets the session cookie as soon as it accepts a login or a second-factor code. Dropping an answer that arrived after the card closed kept the page on its account while the cookie had moved to the other one, so cookie-gated actions (password, 2FA) applied to that account and the next load picked up its token. The cookie is now synced back to the account the page is signed in as. * Keep padded notices inside the auth page's column On a phone-width page or in a sign-in popup, every direct child of the auth body is stretched to the column's width. The overlay sits outside .dashboard, so it isn't border-box, and the padded error line and bonus notice came out wider than the fields and scrolled the page sideways. * Keep the recovery-code field one size when it takes focus On phones the generic dialog-input and phone input rules outranked the recovery-code field's style until it was focused, so tapping it grew the text from 16-17px to 20px and shifted the screen. The field's rule now carries the same weight as theirs, like the code boxes beside it. * Show the provider buttons' hover in dark mode The hover shade was the sidebar background, which in dark mode is one step off the card's, so Google, Apple and the other sign-in buttons gave no feedback under the pointer. Dark mode now uses the hover shade. * Theme the signup bonus notice with the auth card The notice kept the old signup window's fixed pastel colors, which stood out as a light box on the card in dark mode. It now uses the dashboard's success and danger colors, which follow the color scheme. * Keep a new account's email check from closing without an answer A signup that needs its email confirmed takes the auth card down and waits on the confirmation window, whose ✕ closed it without ever answering. In a sign-in popup reached from the account picker that left an empty popup with nothing to pick. The check now stays until the code is confirmed, like the phone and card checks and the boot-time email check. |
||
|
|
6146ab9dd3 |
feat(ai): refresh txt2vid catalogs, retire Sora, default to Veo 3.1 Lite (#3828)
OpenAI shuts the Sora Videos API down on 2026-09-24 and sora-2 was the default txt2vid model, so the default moves to Veo 3.1 Lite on Gemini and the OpenAI video provider goes. While there, the video catalogs are brought in line with what each vendor serves today, the request options are unified across providers, and the txt2vid docs are rewritten. - driver: default provider gemini-video-generation with veo-3.1-lite-generate-preview; a request under the generic `ai-video` driver name lands on the default instead of the first-registered provider; `WIDTHxHEIGHT` sizes map onto tier catalogs by the shorter side and fill width/height - openai video provider, the `openai-video-generation` alias, its config template and migration entries, and Together's openai/sora-2* rows removed - gemini: Veo 3.1 Fast rates 10/12/30 cents per second for 720p/1080p/4K, Veo 3.1 Lite accepts reference images, URL image inputs are fetched server-side through the SSRF-guarded fetch - together: drop nine models retired upstream, add eighteen from the live listing; per-second models are estimated from the catalog rate, clamped to remaining credit and billed at the cost Together reports on the job; tier-sized models take resolution/ratio; input_reference/last_frame map onto keyframes; generate_audio is forwarded - byteplus: Seedance 2.5 (dreamina-seedance-2-5-260628) with per-model reference-image caps - util/imageInput: string-level image helpers shared by the image and video drivers; ai-image/inputImage re-exports them unchanged - puter.js types: provider and generate_audio options; docs: txt2vid page rewritten with per-provider model tables, unified options and four new playground examples Known follow-up: Veo returns a key-protected Google file URL, so the default clip cannot be played directly by a browser until the provider fetches it server-side. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
d897cc5dd0 |
refactor: move subscriptions to webhook system (#3193)
* fix: dont sign write urls if they don't have write perm * wip: new subscriptions * refactor: move subscriptions to |
||
|
|
d4d78ac7db |
rework: change backend and backend extensions to use simpler code structure and patterns (#2815)
* fix: dynamodb health checks and client recreation (#2789) * wip: no nanoServices groundwork * feat: data clients in new shape * wip: auth and perms in new system * more wip * middlewaters mainly done * wip: fsv2 in new layout * old fs v2 migration * driver system * driver and old fs fixes * ai drivers wip * stream support * metering in ai chat driver * wip: new auth * rate limit and auth routes * captcha and anti csrf * fix: types * auth store * app logic * wip most other dricvers * fs * mostly kill all legacy stuff * fs finish * fix: redis usage * ai controller * driver cleanup * socket io in v2 * broadcast and crudq stuff * subdomains * notifcations and shares * fix bad syntaxes * auth wip Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * extensions * extension setup * more routes * sql migrations and default services * home router * tier 7 * everything else * everything else * remaining missing bits * server health * logs * cleanup * deps * cleanup 2 * more cleanup 2 * boot * fix launch * config fix * move file * fix: tsconfig things * fix: extension loading * launching * fix: drivers * fix: others * fix: icons * fix: file uploads * fs fixes * fix: fs api * fix: dev-center * config * add back telemetry * lint stuff * husky hooks * fix: fs oss * fix: config migration * config migration * migrate scripts + replicate * runner * fix: merge defafult config * fix: default region * fix: api domain * fix paths in readfile * fix fs entry default s3 * NS: Remove Referral && Entri Service * dep cleanups * fix: static assets * fix: kv and perms * fix: driver registrations * fix: home mapping * fix: rao * adding back 500 alarm * fix: build paths * fix: fs and kv shapes * fix: kv shape * more kv coercing and ai chat matching format as prior * fix: private app gates * private app caches * fix: whole bunch of legacy shape issues * update template jsonc * fix caching partial oidc and fs signed paths * more oidc fixes * fix: wip * fix: private apps * admin route fixes * fix: last few things hopefully * claude uploads * fix security for app only routes * fix kv system namespace * stuff * fix: app and kv and suggested apps * fix:open item * fix: FS operations * fix: default app icons * add back token-read and WSL support * metering fixes * fix: fsEntry * perm scanners and implicators * proper download endpoint * fix: download * fix anti csrft on v2 * fix file extensions, app icons * fold in v1 fixes from origin/main into v2 equivalents Re-applies the v1 fixes that landed on origin/main into their v2 counterparts since the v1 files were deleted on DS/wip during the v2 migration. v1 commits referenced below. - SQLBatcher: flush immediately when queue hits maxBatchSize instead of racing the timer (v1 12f48238). - RedisClient: drop maxRetriesPerRequest from 2 to 1 to shrink failure window (v1 |