[PR #7088] [MERGED] fix(decision): let a TypeSafe connection use another address (#7084) #7468

Closed
opened 2026-10-23 04:20:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7088
Author: @SpicyMarinara
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/typesafe-endpoint-7084


📝 Commits (7)

  • 230b438 fix(decision): let a TypeSafe connection use another address
  • 7e1cd8c test(decision): prove the TypeSafe address refusal, clarify its copy
  • e6cc62e Merge remote-tracking branch 'origin/staging' into fix/typesafe-endpoint-7084
  • c0873b8 Merge remote-tracking branch 'origin/staging' into fix/typesafe-endpoint-7084
  • b8de78f Merge remote-tracking branch 'origin/staging' into fix/typesafe-endpoint-7084
  • e15a537 fix(decision): send a TypeSafe key unencrypted only to a local address (#7084)
  • c52904c fix(decision): allow http for TypeSafe only on localhost or a local IP (#7084)

📊 Changes

9 files changed (+375 additions, -7 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/connections/decision-models.md (+1 -1)
➕ e2e/decision-typesafe-address.e2e.ts (+80 -0)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+6 -2)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/services/decision/decision-connection.ts (+10 -2)
📝 packages/server/src/utils/security.ts (+10 -1)
📝 packages/shared/src/types/connection.ts (+6 -1)
➕ scripts/regressions/decision-typesafe-address.regression.ts (+258 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7084

Why this change

  • A TypeSafe Decision connection always sent to https://api.typesafe.ai, and its Base URL field was locked. So the only way to reach another server that runs TypeSafe's API (a proxy or another deployment) was Custom System One endpoint.
  • That gives up TypeSafe's own rules: Custom doesn't require a key, can borrow one from a chat connection, and defaults to a 3,500-token budget instead of 30,000. People look for this option under TypeSafe.

What changed

  • Server (decision-connection.ts): a TypeSafe connection now uses its saved Base URL; a blank one still means https://api.typesafe.ai.
    • From there it goes through exactly the code Custom already uses: the same URL checks (http/https only; no user/password, query or hash), the same network rule (PROVIDER_LOCAL_URLS_ENABLED for private LAN addresses; loopback and mDNS allowed; no redirects to another origin) and the same request.
    • Chats, Test and the advanced-memory availability check all use it, because they all resolve through resolveDecisionConnection.
    • TypeSafe keeps its own rules: a key is required, it can't borrow one, the budget stays 30,000 tokens and the calibration is unchanged. OpenRouter stays pinned.
  • No schema change. The connection's existing baseUrl is reused; it's already saved, exported, backed up and duplicated. Every TypeSafe connection already stores https://api.typesafe.ai, so existing connections keep sending where they did. A profile import that changes a TypeSafe connection's address drops the stored key and marks the connection for review, because baseUrl is one of the fields that do that.
  • Client (ConnectionEditor.tsx):
    • Base URL can now be edited for TypeSafe (it stays locked for OpenRouter).
    • One help sentence shows only for TypeSafe (connections.decision.typesafeAddressHelp).
    • The existing billing/privacy notice still shows, and the trust warning under Base URL ("A malicious endpoint could intercept your messages and API keys") still applies.
  • Why it isn't just Custom under another name: the request is identical, which is why the Custom code is reused rather than copied. The key requirement and the token default differ.
  • Tests:
    • New scripts/regressions/decision-typesafe-address.regression.ts. A stand-in server on 127.0.0.1 replaces TypeSafe; no real TypeSafe or OpenRouter endpoint is called.
    • New e2e/decision-typesafe-address.e2e.ts.
  • Docs: docs/connections/decision-models.md and CHANGELOG.md.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run validation (not a substitute for the boxes above):

  • pnpm check: passes. That includes localization:check, format:check, lint and the build.
  • decision-typesafe-address regression: passes 1/1. It covers:
    • blank or default addresses still going to https://api.typesafe.ai/v1/systemone;
    • a custom address being used by a direct request, a chat and Test, with Authorization: Bearer <key> and jev-latest;
    • the 30,000-token budget and the default calibration staying the same;
    • missing_key and needs_relinking still applying;
    • bad URLs giving the same invalid_url as Custom;
    • private and metadata addresses being refused by the URL rule itself.
  • Fails before the fix: with the staging resolver it fails (actual https://api.typesafe.ai/v1/systemone). With the local-URL rule forced on, the refusal check fails too.
  • Regressions with "decision" in the name: 13 of 14 pass. The failure, decision-sidecar-runtime (not_enough_disk vs unsupported), also fails on unmodified staging and doesn't involve connections.
  • Other regressions: advanced-memory-decisions passes 1/1 and agent-activation passes 2/2.
  • e2e: e2e/decision-typesafe-address.e2e.ts passes on desktop-chromium, mobile-chromium and mobile-webkit.
  • Pre-existing e2e failure: e2e/decision-time-limit.e2e.ts fails on staging because it still expects copy changed in bb7c394ab. This PR doesn't cause it.

Manual verification notes

Local CodeRabbit CLI was rate-limited (shared quota) when this was opened; GitHub CodeRabbit reviews the PR.

  • Manually verify in a browser that an existing TypeSafe Decision connection still shows https://api.typesafe.ai and that Test still reaches TypeSafe with a real key.
  • Manually verify that changing a TypeSafe connection's Base URL to a server that runs TypeSafe's API, saving, and clicking Test reports that server's answer.
  • Manually verify that the help sentence appears only when TypeSafe is selected, and that Base URL stays locked for OpenRouter.
  • Manually verify that a TypeSafe Base URL on a LAN address (e.g. http://192.168.x.x) fails Test without PROVIDER_LOCAL_URLS_ENABLED=true and works with it.
  • Manually verify that a chat with a Decision-gated feature uses the custom TypeSafe address.
  • Manually check the editor in light and dark mode and at phone width.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs changed: docs/connections/decision-models.md (step 2 of "Set up a Decision connection") and CHANGELOG.md. The docs-i18n translations still need this change, or a [docs-i18n] docs/connections/decision-models.md follow-up issue.

UI evidence (if applicable)

The e2e test attaches a screenshot of the TypeSafe connection editor (decision-typesafe-address.png) for each project.

Summary by CodeRabbit

  • New Features
    • TypeSafe Decision connections can now send requests and connection tests to a custom server running TypeSafe’s API. The hosted TypeSafe API remains the default.
    • Custom servers still require a TypeSafe API key. Addresses outside the computer or local network must use HTTPS; local network access follows the provider’s URL settings.
  • Documentation
    • Updated TypeSafe connection setup guidance with Base URL requirements and local network configuration details.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7088 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/typesafe-endpoint-7084` --- ### 📝 Commits (7) - [`230b438`](https://github.com/Pasta-Devs/Marinara-Engine/commit/230b43826e12f2a9cb903304dc7ae717293b695e) fix(decision): let a TypeSafe connection use another address - [`7e1cd8c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7e1cd8c261d6995997f8cc514aa141fe19e67c8f) test(decision): prove the TypeSafe address refusal, clarify its copy - [`e6cc62e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e6cc62ede8a0bef4a1dbeb94d83f3dcba7ab1fd0) Merge remote-tracking branch 'origin/staging' into fix/typesafe-endpoint-7084 - [`c0873b8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c0873b81c3d4611109a1e1301fb02f648b3a3d71) Merge remote-tracking branch 'origin/staging' into fix/typesafe-endpoint-7084 - [`b8de78f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b8de78fe46de2b7942553d74ce1fba37865fb030) Merge remote-tracking branch 'origin/staging' into fix/typesafe-endpoint-7084 - [`e15a537`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e15a537ef68fb06b32b77f8f40368ac58c0a64bf) fix(decision): send a TypeSafe key unencrypted only to a local address (#7084) - [`c52904c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c52904c25571e4f3aaadc2e0880c3f477b8ed226) fix(decision): allow http for TypeSafe only on localhost or a local IP (#7084) ### 📊 Changes **9 files changed** (+375 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/connections/decision-models.md` (+1 -1) ➕ `e2e/decision-typesafe-address.e2e.ts` (+80 -0) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+6 -2) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/services/decision/decision-connection.ts` (+10 -2) 📝 `packages/server/src/utils/security.ts` (+10 -1) 📝 `packages/shared/src/types/connection.ts` (+6 -1) ➕ `scripts/regressions/decision-typesafe-address.regression.ts` (+258 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7084 ## Why this change - A TypeSafe Decision connection always sent to `https://api.typesafe.ai`, and its Base URL field was locked. So the only way to reach another server that runs TypeSafe's API (a proxy or another deployment) was **Custom System One endpoint**. - That gives up TypeSafe's own rules: Custom doesn't require a key, can borrow one from a chat connection, and defaults to a 3,500-token budget instead of 30,000. People look for this option under TypeSafe. ## What changed - **Server** (`decision-connection.ts`): a TypeSafe connection now uses its saved Base URL; a blank one still means `https://api.typesafe.ai`. - From there it goes through exactly the code Custom already uses: the same URL checks (http/https only; no user/password, query or hash), the same network rule (`PROVIDER_LOCAL_URLS_ENABLED` for private LAN addresses; loopback and mDNS allowed; no redirects to another origin) and the same request. - Chats, Test and the advanced-memory availability check all use it, because they all resolve through `resolveDecisionConnection`. - TypeSafe keeps its own rules: a key is required, it can't borrow one, the budget stays 30,000 tokens and the calibration is unchanged. OpenRouter stays pinned. - **No schema change.** The connection's existing `baseUrl` is reused; it's already saved, exported, backed up and duplicated. Every TypeSafe connection already stores `https://api.typesafe.ai`, so existing connections keep sending where they did. A profile import that changes a TypeSafe connection's address drops the stored key and marks the connection for review, because `baseUrl` is one of the fields that do that. - **Client** (`ConnectionEditor.tsx`): - Base URL can now be edited for TypeSafe (it stays locked for OpenRouter). - One help sentence shows only for TypeSafe (`connections.decision.typesafeAddressHelp`). - The existing billing/privacy notice still shows, and the trust warning under Base URL ("A malicious endpoint could intercept your messages and API keys") still applies. - **Why it isn't just Custom under another name:** the request is identical, which is why the Custom code is reused rather than copied. The key requirement and the token default differ. - **Tests:** - New `scripts/regressions/decision-typesafe-address.regression.ts`. A stand-in server on 127.0.0.1 replaces TypeSafe; no real TypeSafe or OpenRouter endpoint is called. - New `e2e/decision-typesafe-address.e2e.ts`. - **Docs:** `docs/connections/decision-models.md` and `CHANGELOG.md`. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run validation (not a substitute for the boxes above): - **`pnpm check`:** passes. That includes `localization:check`, `format:check`, lint and the build. - **`decision-typesafe-address` regression:** passes 1/1. It covers: - blank or default addresses still going to `https://api.typesafe.ai/v1/systemone`; - a custom address being used by a direct request, a chat and Test, with `Authorization: Bearer <key>` and `jev-latest`; - the 30,000-token budget and the default calibration staying the same; - `missing_key` and `needs_relinking` still applying; - bad URLs giving the same `invalid_url` as Custom; - private and metadata addresses being refused by the URL rule itself. - **Fails before the fix:** with the staging resolver it fails (actual `https://api.typesafe.ai/v1/systemone`). With the local-URL rule forced on, the refusal check fails too. - **Regressions with "decision" in the name:** 13 of 14 pass. The failure, `decision-sidecar-runtime` (`not_enough_disk` vs `unsupported`), also fails on unmodified staging and doesn't involve connections. - **Other regressions:** `advanced-memory-decisions` passes 1/1 and `agent-activation` passes 2/2. - **e2e:** `e2e/decision-typesafe-address.e2e.ts` passes on desktop-chromium, mobile-chromium and mobile-webkit. - **Pre-existing e2e failure:** `e2e/decision-time-limit.e2e.ts` fails on staging because it still expects copy changed in `bb7c394ab`. This PR doesn't cause it. ### Manual verification notes Local CodeRabbit CLI was rate-limited (shared quota) when this was opened; GitHub CodeRabbit reviews the PR. - [ ] Manually verify in a browser that an existing TypeSafe Decision connection still shows `https://api.typesafe.ai` and that Test still reaches TypeSafe with a real key. - [ ] Manually verify that changing a TypeSafe connection's Base URL to a server that runs TypeSafe's API, saving, and clicking Test reports that server's answer. - [ ] Manually verify that the help sentence appears only when TypeSafe is selected, and that Base URL stays locked for OpenRouter. - [ ] Manually verify that a TypeSafe Base URL on a LAN address (e.g. `http://192.168.x.x`) fails Test without `PROVIDER_LOCAL_URLS_ENABLED=true` and works with it. - [ ] Manually verify that a chat with a Decision-gated feature uses the custom TypeSafe address. - [ ] Manually check the editor in light and dark mode and at phone width. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs changed: `docs/connections/decision-models.md` (step 2 of "Set up a Decision connection") and `CHANGELOG.md`. The `docs-i18n` translations still need this change, or a `[docs-i18n] docs/connections/decision-models.md` follow-up issue. ## UI evidence (if applicable) The e2e test attaches a screenshot of the TypeSafe connection editor (`decision-typesafe-address.png`) for each project. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * TypeSafe Decision connections can now send requests and connection tests to a custom server running TypeSafe’s API. The hosted TypeSafe API remains the default. * Custom servers still require a TypeSafe API key. Addresses outside the computer or local network must use HTTPS; local network access follows the provider’s URL settings. * **Documentation** * Updated TypeSafe connection setup guidance with Base URL requirements and local network configuration details. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:20:06 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7468
No description provided.