Commit Graph

5685 Commits

Author SHA1 Message Date
Daniel Salazar 4bcfe6c7f4 tests: add unit tests for GeminiChatProvider with mocked client (#3044)
Mocks the OpenAI SDK at the module boundary (Gemini speaks the
OpenAI-compat dialect at the v1beta/openai endpoint), boots a real
PuterServer for the wired MeteringService, and exercises construction,
model catalog/resolution, request shape (max_completion_tokens rename,
cache_control stripping, stream_options gating), non-stream + streaming
output (cached-token splitting in the metered usage shape), error
mapping, and moderation.

closes #2961
2026-05-08 23:01:08 -07:00
Daniel Salazar 3ada6f1569 tests: XAIProvider uses setupTestServer + real metering:[#2982] (#3035)
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
Drops the local makeMeteringStub in favour of a live PuterServer-wired
MeteringService. The OpenAI SDK is still mocked at the module boundary
(the real network egress point); the mock now also exposes a default
export so the test server can boot every chat provider (some import
the default and read .OpenAI off it). Aligns with AGENTS.md: "Prefer
test server over mocking deps."

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:21:52 -07:00
Daniel Salazar 64402b01db tests: add tests for OCRDriver: [#2964] (#3028)
* tests: add tests for OCRDriver: [#2964]

Adds offline OCRDriver.test.ts covering both providers:

  • test_mode short-circuit; argument validation (missing actor, missing
    source, unknown provider, AWS/Mistral not configured)
  • aws-textract: raw-bytes vs S3Object source selection (regional
    client when fsEntry has a bucket), block normalisation (PAGE/WORD/
    TABLE filtered, LINE/LAYOUT_TITLE → text/textract:* blocks),
    402 on insufficient credits, per-page metering
  • mistral: image vs PDF chunk packaging (image_url with base64 data
    URL vs document_url with documentName), pass-through of pages /
    annotation / image-limit options, markdown → LINE-block
    normalisation with page indices, per-page metering, additional
    annotations metering when bbox/document annotation formats are set
  • default-provider selection (AWS preferred → Mistral fallback →
    500 when neither is configured)
  • getReportedCosts mirrors costs.ts

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tests: OCRDriver uses setupTestServer + real fs/metering

Drops the manual config/clients/stores/services stub apparatus and
the loadFileInput mock in favour of the live wired driver from
server.drivers.aiOcr. The Textract and Mistral SDKs are still mocked
at the module boundary (the real network egress points); inputs go
through the real loadFileInput against real fs/store wiring (data
URLs for most cases; FSService.write produces a real fsEntry for the
PDF documentName test). Aligns with AGENTS.md: "Prefer test server
over mocking deps."

The S3Object-source/regional-client assertion was dropped because it
isn't deterministic against the in-memory S3 store and the driver's
per-region TextractClient cache leaks across tests. That branch is
better exercised by a real-cloud integration test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:15:57 -07:00
Daniel Salazar 6226db73d4 tests: add unit tests for MoonshotProvider with mocked client: [#2979] (#3030)
* tests: add unit tests for MoonshotProvider with mocked client: [#2979]

Adds offline MoonshotProvider.test.ts covering construction, model
resolution and aliasing, request shape (hardcoded max_tokens=1000,
stream_options gating, tool_use → tool_calls hoisting), vision-model
image-inlining hook, non-stream and streaming output, error logging
and rethrow, and metering. Existing integration test is left
untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tests: MoonshotProvider uses setupTestServer + real metering

Drops the local makeMeteringStub in favour of a live PuterServer-wired
MeteringService. The OpenAI SDK is still mocked at the module boundary
(the real network egress point); inlineHttpImageUrls is mocked because
verifying the provider invokes it for vision-capable models is the
unit's concern. Aligns with AGENTS.md: "Prefer test server over
mocking deps."

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:15:45 -07:00
Daniel Salazar 6ab2a2a6cc tests: add unit tests for MistralAiProvider with mocked client: [#2978] (#3032)
* tests: add unit tests for MistralAiProvider with mocked client: [#2978]

Adds offline MistralAiProvider.test.ts covering construction, model
resolution and aliasing, request shape (camelCase maxTokens, tool_calls
→ toolCalls and tool_call_id → toolCallId rewrite, complete-vs-stream
routing), non-stream output with the camelCase usage coercion,
streaming with the chunk.data unwrap and toolCalls deviation, error
mapping, and metering. Existing integration test is left untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tests: MistralAiProvider uses setupTestServer + real metering

Drops the local makeMeteringStub in favour of a live PuterServer-wired
MeteringService. The Mistral SDK is still mocked at the module
boundary (the real network egress point); everything else runs through
the real wired graph. Aligns with AGENTS.md: "Prefer test server over
mocking deps."

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:15:34 -07:00
Daniel Salazar ba03fd7965 tests: add unit tests for PuterAIController: [#2965] (#3031)
* tests: add unit tests for PuterAIController: [#2965]

Adds offline PuterAIController.test.ts with stubbed drivers covering:
route registration (paths and per-route auth options), app-actor
gating across all four chat-proxy routes, body validation (messages
must be an array; openaiCompletions prompt must be a string;
openaiResponses provider must be openai-responses), driver delegation
and request shaping (model + messages + provider defaults), response
shaping for OpenAI chat-completion / text-completion / Responses
envelopes and Anthropic message envelope (text + tool_use blocks),
SSE streaming with [DONE] terminator, model-listing endpoints with
hidden-id filtering and 501 when list() is unavailable, and the
HMAC-gated video proxy's input/expiry/secret guards.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tests: PuterAIController uses setupTestServer + spy on aiChat.complete

Drops the manual driver/controller stub apparatus (makeStubDriver,
makeController, custom dep builders) in favour of the live wired
controller from server.controllers.puterAi. Each test that needs a
canned chat completion result spies on server.drivers.aiChat.complete,
which keeps the unit-of-test focused on the controller (validation,
response shape, SSE streaming) without dragging in chat-driver model
resolution and credit checks. Aligns with AGENTS.md: "Prefer test
server over mocking deps."

The "500 when URL signature secret missing" assertion was dropped —
the default config wires a secret, so the branch is unreachable in
the live test server. Replaced with the equivalent 403-on-invalid-
signature assertion which actually exercises the HMAC gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:15:23 -07:00
Daniel Salazar 1c188d6325 tests: add unit tests for ZAIProvider with mocked client: [#2983] (#3029)
* tests: add unit tests for ZAIProvider with mocked client: [#2983]

Adds offline ZAIProvider.test.ts covering construction, model
resolution and aliasing, GLM-specific request shape (custom params,
cache_control stripping, user_id derivation, stream_options gating),
non-stream output with reasoning_content normalisation, streaming
deltas (text and tool_use), error mapping, and metering. Existing
integration test is left untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tests: ZAIProvider uses setupTestServer + real metering

Drops the local makeMeteringStub in favour of a live PuterServer-wired
MeteringService. The OpenAI SDK is still mocked at the module boundary
(the real network egress point); everything else — config, Context,
metering recording — runs through the real wired graph. Aligns with
AGENTS.md: "Prefer test server over mocking deps."

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:14:15 -07:00
ProgrammerIn-wonderland 8b1226aa1b OIDC referrer (#3034)
* oidc referrer

* optionally infer referrer from window.openerOrigin

* infer referrer from openerOrigin if there

* add log in signupCb

* remove excess logs

* remove FSEntry.js
2026-05-08 22:05:09 -04:00
Daniel Salazar 2c1d320bba ci: push to dockerhub too (#3033) 2026-05-08 17:36:21 -07:00
Daniel Salazar b6414442dd fix: contributing (#3027) 2026-05-08 16:58:05 -07:00
Daniel Salazar f5470f123f tests: add tests for xaiProvider: [#2982] (#3026) 2026-05-08 16:09:25 -07:00
Nariman Jelveh ea9a44c9ad Implement inline 2FA UI, remove old components (#3025)
* Implement inline 2FA UI, remove old components

* Re-enable login button on window close
2026-05-08 15:59:40 -07:00
jelveh 881ee90e76 Remove stray fullscreen hint from translations 2026-05-08 15:16:47 -07:00
jelveh fbb570fb36 Reapply "Remove toolbar clock feature (#3024)"
This reverts commit e781b60bcb.
2026-05-08 15:15:03 -07:00
jelveh e781b60bcb Revert "Remove toolbar clock feature (#3024)"
This reverts commit 78a071ae54.
2026-05-08 15:11:55 -07:00
Nariman Jelveh 78a071ae54 Remove toolbar clock feature (#3024) 2026-05-08 15:08:15 -07:00
Daniel Salazar 9bcd77c85b chore: add legacy codes back to all errors (#3022) 2026-05-08 13:51:55 -07:00
Daniel Salazar 960bbb6965 doc: code architecture doc + contributing guide for backend (#2953)
* architecture doc

* agents and contributor md guides

* fix: userStore
2026-05-08 13:51:41 -07:00
Nariman Jelveh 46a56e474b README edit (#3012)
* Add 'For Users' and 'For Developers' sections

* Update README.md

* Update README.md

* Update README.md
2026-05-08 13:30:33 -07:00
Reynaldi Chernando 666b60bd29 Use GA version of gemini 3.1 flash lite (#3013)
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
* Use GA version of gemini 3.1 flash lite

* add model name alias
2026-05-08 13:51:56 -04:00
Daniel Salazar 63f128457e remove driver usage endpoint (#3017) 26.05.1 2026-05-08 10:18:26 -07:00
Daniel Salazar 5e8e9a852d test: add unit tests for ai-chat utils (#3016)
Covers `Messages` (normalize_single_message / normalize_messages /
extract_and_remove_system_messages / extract_text), `FunctionCalling`
(normalize_json_schema / normalize_tools_object /
make_openai_tools / make_claude_tools), and `Streaming`
(AIChatStream / AIChatMessageStream / AIChatTextStream /
AIChatToolUseStream). All three are pure data transforms — Streaming
is exercised against a real `AIChatStream` wired to a buffering
Writable, so no method-level spies are needed.

Closes #2956
2026-05-08 10:17:46 -07:00
Daniel Salazar 3166ad933c test: add unit tests for OpenAIUtil shape normalization (#3015)
Covers the Puter↔OpenAI shape conversion (`process_input_messages`,
`process_input_messages_responses_api`), usage extraction
(`extractMeteredUsage`, `create_usage_calculator`), the streaming
handlers (`create_chat_stream_handler` and the responses-API variant),
and the non-stream `handle_completion_output[_responses_api]` paths
including moderation, missing-content, and per-provider deviations.
Streaming is exercised via a real `AIChatStream` wired to a buffering
Writable so no method-level spies are needed.

Closes #2955
2026-05-08 10:17:42 -07:00
Reynaldi Chernando 7e5f64e04b Fix minor typo for tls cert in self hosting docs (#3014) 2026-05-08 09:23:06 -07:00
jelveh 908c02fd99 fix ASCII art for PUTER.JS 2026-05-08 08:04:21 -07:00
jelveh 38fcc6d6bd Detect fullpage apps early and skip desktop load
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
2026-05-07 22:17:27 -07:00
Daniel Salazar 16652347c6 test: add tests for HomepageController (#3010)
Covers the early-return guard when the homepage service is unwired,
shell rendering at /, /settings, /dashboard, /action, /@:username,
canonical_url + meta inheritance from gui_params, /app/:name (404 +
shell, embedded app metadata, JSON / object metadata, malformed JSON),
and /show/* launching the explorer with the trimmed path.

Closes #2973
2026-05-07 21:41:16 -07:00
Daniel Salazar 5f28b988ec test: add tests for SystemController (#3009)
Covers /healthcheck (live status, 503 on failure, fallback when service
unavailable), /version (semver parsing, env defaults), /contactUs
(validation, persistence, email best-effort, default support address),
/whoarewe, /lsmod (interface grouping + driverName fallback), and the
prepareShutdown drain-flag flip.

Closes #2971
2026-05-07 21:40:27 -07:00
Daniel Salazar 160631b158 test: add tests for OIDCController (#3008)
Covers the provider listing route, the auth-start redirect (404 / 400 /
500 / 302), all three callback flows (login / signup / revalidate)
including state validation, suspended accounts, unconfirmed-email
linking refusal, redirect_uri origin clamping, and the
revalidate-done landing page. Routes are collected via PuterRouter and
invoked with stubbed services that return prefab data.

Closes #2966
2026-05-07 21:38:47 -07:00
Daniel Salazar 3ab9923f0c fix: ai provider integration tests (#3011)
* fix: ai provider integration tests

* change name for ai test
2026-05-07 21:38:40 -07:00
Daniel Salazar cc799e069f test: add unit tests for fileInput driver utility (#3007)
Covers `loadFileInput` (validation, data-URL decoding, FS-path resolution,
maxBytes enforcement, ACL gating) and `inferFilenameFromUrlOrPath`. Stubs
stores/fsService with prefab data so tests don't require a real server.

Closes #2957
2026-05-07 21:38:27 -07:00
Daniel Salazar 9a7d3bac5f test: add tests for DesktopController (#3006)
Covers /set-desktop-bg (partial updates, null clearing, type validation),
/update-taskbar-items (JSON serialization), /set_layout (layout
allowlist, ownership gate, path/uuid resolution), and /set_sort_by
(sort_by/sort_order allowlists, default ordering). Routes are
collected via PuterRouter and driven with stub stores returning
prefab fsentry rows.

Closes #2970
2026-05-07 21:37:34 -07:00
Daniel Salazar 0a9a4f629d test: add tests for StaticPagesController (#3005)
Covers /robots.txt (bot disallow + sitemap), /sitemap.xml (docs +
approved-listing apps), /unsubscribe (missing/invalid uuid, idempotent
re-runs), and /confirm-email-by-token (token mismatch, already-confirmed
short-circuit, duplicate-email rejection, success path with verified-
group promotion + best-effort side channels). Stub stores hold prefab
user rows; the DB stub returns canned EXISTS / SELECT results.

Closes #2975
2026-05-07 21:36:50 -07:00
Daniel Salazar 32c2c0c1a5 test: add tests for AppController (#3004)
Covers /apps, /apps/nameAvailable, /rao, /apps/:name (single + batch),
/query/app (max-entries cap, marketplace shape, hidden-app gating), and
/app-icon (default fallback, data-URL decoding, MIME allowlist, CDN
redirect). Routes are collected via PuterRouter; AppDriver is injected
through the shared `driversContainers` registry, and stub stores return
prefab app rows.

Closes #2969
2026-05-07 21:35:49 -07:00
Daniel Salazar 508d652194 test: add tests for StaticAssetsController (#3003)
Covers each config-gated branch (client_libs_root, puterjs_root,
gui_assets_root, builtin_apps) using real temp directories so the
existsSync checks see real files instead of mocked module behavior.
Asserts both registration outcomes (which routes appear, on which
subdomains) and the file resolution rules for the puter.js / puter.dev.js
fallback.

Closes #2974
2026-05-07 21:35:17 -07:00
jelveh 471ba94ba2 Update index.js 2026-05-07 20:04:43 -07:00
jelveh 66e24a07d4 Update console banner and messaging 2026-05-07 19:49:01 -07:00
jelveh 5ffac54c86 experimental cute CTA 2026-05-07 19:39:06 -07:00
ProgrammerIn-wonderland c5b12b61d9 Unconditionally send Access-Control-Allow-Private-Network, fix LNA fix in GUI (#2954)
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
2026-05-07 16:38:04 -07:00
Daniel Salazar 8d5e9ef9cf fix: types for open ai driver (#2950)
* fix: types for open ai driver

* fix: add extra time to tests

* fix: test

* fix: together ai tests

* fix: tests
2026-05-07 14:48:47 -07:00
Daniel Salazar 25fe9a3cdf fix: add coverage reports for changes (#2949)
* tests: ai integraton tests

* fix: add coverage reports for this too
2026-05-07 13:55:09 -07:00
Daniel Salazar 05425d20a7 chore: cleanup types for tests (#2948) 2026-05-07 13:40:58 -07:00
Nariman Jelveh ff10e47d67 Show fullscreen overlay when signup is blocked (#2947) 2026-05-07 11:37:23 -07:00
Daniel Salazar 6c19dfbafd fix: linux build (#2946) 2026-05-07 11:23:10 -07:00
Nariman Jelveh 360cbf48af feat: support code in puter.signup.validate error responses (#2945)
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
Extensions listening on the `puter.signup.validate` event can now set a
`code` field (in addition to `message`) when blocking signups. The code
is forwarded through HttpError and appears in the JSON error response,
giving clients a stable, machine-readable signal to act on.

Covers both the AuthController (password signup) and OIDCService paths.
Adds tests for the new field.
2026-05-07 10:11:08 -07:00
Daniel Salazar bbe93defe9 tests: add some more driver tests (#2944) 2026-05-07 10:04:39 -07:00
Reynaldi Chernando 5e01c13b31 Fix duplicate textract result (#2943) 2026-05-07 09:15:28 -07:00
Daniel Salazar 4b37f35803 test: tests for fs endpoints (#2942)
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
2026-05-06 22:55:53 -07:00
Daniel Salazar 775c9c49e2 test: add harness and some examples (#2941)
* test: add harness and some examples

* feat: tests ran on pr
2026-05-06 22:43:22 -07:00
Nariman Jelveh e35260924e Scope .myapps-search to input and tweak UI styles
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
2026-05-06 17:59:54 -07:00