Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
a8d06b9
Send chache markers for byok
ZoranPandovski Nov 1, 2026
fc80ee0
Add tests
ZoranPandovski Nov 1, 2026
0d02d41
Mark the last message only on streamed Anthropic calls
ZoranPandovski Nov 2, 2026
10d149e
Pin memory
ZoranPandovski Nov 2, 2026
580e47a
Add tests
ZoranPandovski Nov 2, 2026
7a70863
fix(session): ask a long turn to commit to its answer before the toke…
ZoranPandovski Nov 2, 2026
138e7bc
Sync main into staging
mindsdb-release-train[bot] Nov 3, 2026
4dd6546
Ask for the literal reading and complete final answers (#738)
StpMax Nov 3, 2026
27f7e32
Internet research flag for data-only sessions (ENG-3935 1/2) (#739)
StpMax Nov 3, 2026
67d097c
Merge pull request #735 from mindsdb/bugfix/anthropic-byok-prompt-cac…
ZoranPandovski Nov 3, 2026
14f6c1e
Merge staging into bugfix/pin-memory-prompt-per-conversation
ZoranPandovski Nov 3, 2026
68e33a4
fix(session): past the budget checkpoint, finish an unfinished verdic…
ZoranPandovski Nov 3, 2026
151b86f
Keep the memory pin in the process and drop it on compaction
ZoranPandovski Nov 3, 2026
72e051e
Merge pull request #740 from mindsdb/bugfix/pin-memory-prompt-per-con…
ZoranPandovski Nov 3, 2026
13a48b2
Pin the workspace listing per conversation and save the pin for new p…
ZoranPandovski Nov 3, 2026
caa2dc8
Save only the workspace names for a new process, never prompt text
ZoranPandovski Nov 3, 2026
06c27db
Merge pull request #744 from mindsdb/bugfix/pin-workspace-listing-per…
ZoranPandovski Nov 3, 2026
da4b370
ENG-1165: Name the request, status and server message when a Minds ca…
alecantu7 Nov 3, 2026
b58cb39
fix(memory): keep hand-written lines when saving, editing or deleting…
pnewsam Nov 3, 2026
17584a2
fix(minds_client): quote the server's message and label anton's note …
alecantu7 Nov 4, 2026
2ff94cb
Merge remote-tracking branch 'origin/staging' into fix/token-budget-c…
ZoranPandovski Nov 4, 2026
b33912c
fix(session): keep only the hand-back fix; drop the budget checkpoint
ZoranPandovski Nov 4, 2026
58b249a
ENG-3454: Label anton's PostHog events with the deployment that sent …
alecantu7 Nov 4, 2026
ad407d0
fix: upgrade react-dom from 19.3.0 to 19.3.1
snyk-bot Nov 5, 2026
298a07e
Sync main into staging
mindsdb-release-train[bot] Nov 5, 2026
4fe56ca
Sync main into staging
mindsdb-release-train[bot] Nov 5, 2026
c10b359
Merge pull request #750 from mindsdb/fix/token-budget-checkpoint
ZoranPandovski Nov 5, 2026
71b1b1d
Give the long-conversation write-check timing test a 2s bound (#756)
martyna-mindsdb Nov 5, 2026
465a2c6
Stop asking Jev after a refusal, and honor the Jev opt-out on cloud t…
SailingSF Nov 6, 2026
7007712
Merge pull request #751 from mindsdb/feature/test-suite-cleanup
ZoranPandovski Nov 6, 2026
7fad101
Pass auth's _method through TurnKeyDataVault (#579)
martyna-mindsdb Nov 6, 2026
6ffdd86
Describe memory scopes without storage paths in the system prompt (#759)
StpMax Nov 6, 2026
fddd84b
Flag cut query results in chat, and stop calling "not in the data" an…
ZoranPandovski Nov 6, 2026
11e9b83
Test the cut-result note on several paging conventions
ZoranPandovski Nov 6, 2026
88a8fdd
Add the create_connector_draft tool for cloud turns
tino097 Nov 6, 2026
fd81179
Refuse invisible characters and help_url queries in a connector draft
tino097 Nov 6, 2026
dae2184
Tell cloud turns they can build a connector template
tino097 Nov 6, 2026
a9eaa85
Refuse a connector draft help_url with an invalid port
tino097 Nov 7, 2026
6851e9a
[ENG-3296] Add a browser tool that shares the user's MindsHub browser…
torrmal Nov 8, 2026
01e2f99
Answer page requests with an HTML page, not chat or Markdown
ZoranPandovski Nov 8, 2026
9e871ca
Run day-dated rows through the last week of a weekly plan
ZoranPandovski Nov 8, 2026
9032e71
feat(cloud-turn): name the artifacts a turn touched on turn_completed…
lucas-koontz Nov 8, 2026
d8637e4
fix(session): enforce the step limit per task, with no silent extensi…
hamishfagg Nov 9, 2026
23d634a
Sync main into staging
mindsdb-release-train[bot] Nov 9, 2026
33b396b
Merge pull request #755 from mindsdb/snyk-upgrade-182863de95a1c1d7fc8…
ZoranPandovski Nov 9, 2026
6f8e3c0
Update docs dependencies to patched versions
ZoranPandovski Nov 9, 2026
c40e32d
Merge pull request #760 from mindsdb/bugfix/truncated-results-and-stu…
ZoranPandovski Nov 9, 2026
006fd84
Merge pull request #769 from mindsdb/bugfix/docs-dependency-alerts
ZoranPandovski Nov 9, 2026
9fc2d07
Merge staging into bugfix/page-requests-build-html
ZoranPandovski Nov 9, 2026
f801a1b
Merge pull request #766 from mindsdb/bugfix/page-requests-build-html
ZoranPandovski Nov 9, 2026
7130267
Skip the unedited anton.md template in prompts (ENG-4059) (#761)
StpMax Nov 9, 2026
b36dd61
ENG-1580: publish fullstack artifacts asynchronously and poll the job…
StpMax Nov 9, 2026
9ba225c
Cache Cowork's shared prompt across conversations on Claude through M…
ZoranPandovski Nov 9, 2026
ceeb93a
Split the system prompt without importing the Anthropic provider
ZoranPandovski Nov 9, 2026
1555de4
Make the static artifact fast path, single call and component writer …
ZoranPandovski Nov 9, 2026
1c0948b
Merge staging into the connector template branch
tino097 Nov 9, 2026
d70de79
Merge pull request #771 from mindsdb/feature/static-artifact-defaults
ZoranPandovski Nov 9, 2026
38a19a1
Use a half-open date window for weekly and monthly plans
ZoranPandovski Nov 9, 2026
42d4dde
Merge pull request #765 from mindsdb/bugfix/day-dated-rows-last-week
ZoranPandovski Nov 9, 2026
9c60960
[SOC2] Bump pyjwt to 2.15.0 for CVE-2026-102275
martyna-mindsdb Nov 9, 2026
6c37a80
Let a connector template declare how to test its credentials
tino097 Nov 9, 2026
d531c06
Refuse percent-encoding in a connector check path
tino097 Nov 9, 2026
1b4c1c9
ENG-3444: Apply the tenant's per-task limits to web turns (#577)
alecantu7 Nov 9, 2026
585597a
Pin each connector check refusal test to the rule it tests
tino097 Nov 9, 2026
a20b3da
ENG-1585: Raise BudgetExceededError for a spent organization budget
MinuraPunchihewa Nov 10, 2026
1a8e587
ENG-1585: Count the budget stop in the billing-stop base docstring
MinuraPunchihewa Nov 10, 2026
09dadf4
Pin path and header refusal tests to the part they refuse
tino097 Nov 10, 2026
15ea156
Point the model at read_text_file for reading text files
ZoranPandovski Nov 10, 2026
e554702
Update the default prompt snapshot for the reading guidance
ZoranPandovski Nov 10, 2026
2298e64
Recognize a truncation note wherever scrubbing left it
ZoranPandovski Nov 10, 2026
da06987
Wait for the resident to bind its name instead of sleeping a fixed time
tino097 Nov 10, 2026
6f1083b
Merge pull request #775 from mindsdb/bugfix/read-text-files-whole
ZoranPandovski Nov 10, 2026
10537bb
Mark only the system prompt on one-off MindsHub calls
ZoranPandovski Nov 10, 2026
c22f477
Merge pull request #770 from mindsdb/bugfix/minds-claude-cache-breakp…
ZoranPandovski Nov 10, 2026
0c96d60
ENG-4096: tell the user when an artifact to edit is missing (#772)
StpMax Nov 10, 2026
e8f9fd4
[ENG-3419] Honor the selected reasoning effort in cloud turns (#568)
tino097 Nov 10, 2026
96e27fb
Check one connector draft text on its own, with the parser's rule
tino097 Nov 10, 2026
40f2a02
Refuse key-shaped connector ids and field names, and name the rule a …
tino097 Nov 10, 2026
1e5fafe
Merge remote-tracking branch 'origin/staging' into tino097/eng-3838-c…
tino097 Nov 10, 2026
eff6bf4
Merge pull request #773 from mindsdb/martyna/soc2-pyjwt-2.15.0
ZoranPandovski Nov 10, 2026
36bbbcb
ENG-1585: Say a budget stop latches the verifier too, and lifts when …
MinuraPunchihewa Nov 10, 2026
905ec61
Merge pull request #774 from mindsdb/feature/org_budget
MinuraPunchihewa Nov 10, 2026
23dd530
Check every template header name with one shared rule and case list
tino097 Nov 11, 2026
09ab5d1
Require an auth section on every connector template and narrow the ch…
tino097 Nov 11, 2026
8a402e1
Teach the connector draft tool the auth section and helper-based usag…
tino097 Nov 11, 2026
e6d221f
Refuse known secrets as header names and hand-built Basic headers in …
tino097 Nov 11, 2026
1276a70
Refuse a Basic value under any template header name
tino097 Nov 11, 2026
63ea6a1
Count only tool blocks in the compaction rows test helper (ENG-4187)
ZoranPandovski Nov 11, 2026
5994371
Keep the text beside tool calls in saved history rows (ENG-4187)
ZoranPandovski Nov 11, 2026
942f8cb
Move the template auth rules into a standard-library module other ser…
tino097 Nov 11, 2026
0c62765
Let a template place its key in a URL parameter that only the gateway…
tino097 Nov 11, 2026
5f1bffe
Require every template field, since auth sends each one on every request
tino097 Nov 11, 2026
abe1c8c
Generate the auth section case list that other services run against t…
tino097 Nov 11, 2026
8f3f8d8
Read query parameter names as servers do when checking for a collisio…
tino097 Nov 11, 2026
ac0cec3
Also read an unmatched bracket, padding and plus in a parameter name …
tino097 Nov 11, 2026
49ab7c3
Allow only plain query parameter names beside a placed key, and widen…
tino097 Nov 11, 2026
a0d543b
feat(i18n): Anton replies in the user's UI language (ENG-4149) (#776)
torrmal Nov 11, 2026
79e3251
Refuse every control and line-separator character in a placed value, …
tino097 Nov 11, 2026
e55e31e
ENG-4006: Ask at a per-task time limit and hand back with a summary (…
alecantu7 Nov 11, 2026
37c9887
[ENG-4194] Let a running turn take input the user adds mid-task (#784)
torrmal Nov 12, 2026
db09b14
ENG-3443: Raise the built-in turn limits to safety limits (#576)
alecantu7 Nov 12, 2026
3df0563
Tell the model every path starts at the host and carries the API's ve…
tino097 Nov 12, 2026
c38a515
Keep MCP connections' tokens out of the Scratchpad env (#762)
martyna-mindsdb Nov 12, 2026
a69f945
Notion MCP connector: server URL, read-only tools, general MCP fixes …
martyna-mindsdb Nov 12, 2026
bb8cafc
Give the check path refusal a versioned example, and pin the tool's o…
tino097 Nov 12, 2026
bb1d8cc
[ENG-4204] Name each cloud datasource connection in the prompt (#792)
tino097 Nov 12, 2026
77b69f2
Say that anton is the only place a connection label is cleaned, and p…
tino097 Nov 12, 2026
afff8a8
Merge pull request #795 from mindsdb/tino097/eng-4204-web-agent-canno…
ZoranPandovski Nov 12, 2026
ed6c89c
Merge pull request #764 from mindsdb/tino097/eng-3838-custom-connecto…
tino097 Nov 12, 2026
8fd273f
Show the step's code and a reason on every can't-be-checked card
ZoranPandovski Nov 12, 2026
8cfecbf
Let operators choose which can't-be-checked cards a deployment shows
ZoranPandovski Nov 12, 2026
b2b1c79
fix(write-approval): keep check stops and whole cards under the unche…
lucas-koontz Nov 13, 2026
0a435ca
Test that text beside a tool_result is not saved (ENG-4187)
ZoranPandovski Nov 13, 2026
6987423
Merge pull request #783 from mindsdb/bugfix/replay-assistant-text
ZoranPandovski Nov 13, 2026
b7f1ba0
Artifact editor v2 and the quick-edit bar's direct edit (ENG-4207, EN…
torrmal Nov 13, 2026
4651c5a
Restore the quick-edit router context and cloud-turn preview checks (…
torrmal Nov 13, 2026
2fbe16f
test(write-check): replay a labeled chat corpus and hold the check to…
lucas-koontz Nov 14, 2026
35bcf0f
Add a FrontierHarness Eval adapter under contrib/frontierharness (ENG…
ZoranPandovski Nov 15, 2026
3e92d3a
Merge pull request #799 from mindsdb/fix/eng-4246-pr797-fixes
lucas-koontz Nov 15, 2026
38f18ed
Keep the card on a startup hook write under every unchecked setting
ZoranPandovski Nov 15, 2026
d32ca3c
Say in the setting's docs that a startup hook write keeps its card, a…
ZoranPandovski Nov 15, 2026
94f9582
Pin the verifier eval's haiku slot to claude-haiku-5-5
ZoranPandovski Nov 15, 2026
bbbabd9
Merge pull request #797 from mindsdb/feature/unchecked-card-setting
ZoranPandovski Nov 15, 2026
6172932
Sync main into staging
mindsdb-release-train[bot] Nov 15, 2026
c5b9d82
Browser: Jev picks the steps, a tab budget with saved tabs, tidy-up a…
torrmal Nov 16, 2026
4fa1f7c
Merge pull request #806 from mindsdb/feature/frontierharness-adapter
ZoranPandovski Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ A host gives a session the `browser` tool by passing `ChatSessionConfig.browser`
- **A browser router**, for cloud turns: an `https` base URL with no credential. The cloud turn reads it from the turn request's `params.browser` block (`{base_url, profile, project?}`), and the tool calls the router with the turn's own key.
- **The Cowork desktop app's own browser**: exactly `http://127.0.0.1:<port>` and the app's per-launch key, built by the host in its own process. It never travels in a turn request, and its client ignores system proxies.

The tool reads pages as numbered elements and acts on them by number. The person shares the browser: only they hand it back after a hand-over, with Done in the browser. A step that commits something (submit, buy, send, delete, grant access) or acts by position waits for the person's Approve on a card. On the router, the browser itself holds those steps and anton shows the card when it answers `approval_required`; on the desktop, anton shows the card before it sends the step. The desktop app's browser sends no page content to MindsHub's decision service.
The tool reads pages as numbered elements and acts on them by number. The person shares the browser: they hand it back after a hand-over with Done in the browser, or, when the hand-over names what it waits for (`wait_for`: one checkbox, toggle or text field, or the page changing after a human check), a host that watches for it and says so in its answer (`watching`) hands it back by itself once that's done. A step that commits something (submit, buy, send, delete, grant access) waits for the person's Approve on a card. On the router, the browser itself holds those steps and anton shows the card when it answers `approval_required`; a click by position runs at once there unless it lands on a commit control, which holds as that control's click. On the desktop, anton shows the card before it sends the step, and a click by position first shows an "Allow clicks by position on this page" card, once per page address, which then covers every click by position on that page, except on an OAuth authorization or consent page, where every click waits for Approve as a commit step on both hosts. The desktop app's own browser runs on the person's machine, so it needs no browser server; it picks its steps the same way as the router's.

A decision model picks the browser's steps: Jev on the session's MindsHub connection, for either form, or a decision model of the host's own, which wins. A host running the turn in its own process passes it as `BrowserConfig.decisions` (a `DecisionsTarget`: the endpoint's full URL, its key and its model name); like the launch key, it stays in the host's process and never travels in a turn request. For a turn it hands to a cloud pod, the host passes `BrowserConfig.decisions_proxy` instead (a `DecisionsProxy`: the full URL of a route of the host's own and the model name, no key), which the turn request carries: the tool posts each decision there with the session's MindsHub credential, the turn key, and the host forwards it to its decision model with the key it keeps. Without any, the model picks every step.

`tests/fixtures/browser_contract/` pins the HTTP contract both hosts serve, including the commit list both read; each host's tests keep a copy. Its README explains the format.

Expand Down
14 changes: 6 additions & 8 deletions anton/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,6 @@
# value as a pre-ENG-2243 build, never as "no parent".
# (anton/core/session.py::_emit_tool_completed)
#
# browser_jev_shadow jev_action, llm_action, agree_action, agree_target,
# p_action, p_target: in shadow mode, the step Jev picked
# for a page against the step the model then took on that
# same page, and Jev's probabilities. Action names and
# numbers only, never page content
# (anton/core/browser/tool.py::_record_shadow_agreement)
#
# browser_jev_step jev_action, p_action, ms: one step Jev took in `run`
# when browser_jev is "on". Not `action`: send_event's own
# parameter has that name
Expand All @@ -283,6 +276,11 @@
# security check"): the tool handed a human check to the
# user (anton/core/browser/tool.py::_unless_human_check)
#
# browser_hand_over_waits state ("checked" or "filled"): the model handed
# the browser to the user with wait_for naming one element,
# a checkbox or toggle to be checked or a field to be
# filled (anton/core/browser/tool.py::_do_hand_to_user)
#
# Every event listed here also carries `environment`: the deployment that sent
# it, from ANTON_DEPLOYMENT_ENV (`prod`, `staging`, `dev`, ...). It is "" wherever
# no host set it, such as the CLI, so "" means unknown, not production. Absent
Expand All @@ -296,9 +294,9 @@
"rule_retrieval",
"scratchpad_package_installed",
"tool_completed",
"browser_jev_shadow",
"browser_jev_step",
"browser_human_check",
"browser_hand_over_waits",
}
)

Expand Down
5 changes: 5 additions & 0 deletions anton/cloud_turn/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
)
from anton.cloud_turn.preview_check import CloudPreviewChecks
from anton.cloud_turn.stdin import start_answer_reader
from anton.core.browser.tool import tidy_after_turn
from anton.core.llm.liveness import MODEL_WAIT_PHASE, MODEL_WAIT_TICK_S
from anton.core.llm.provider import ProviderErrorFilter

Expand Down Expand Up @@ -509,6 +510,10 @@ async def _heartbeat() -> None:
if rows:
logger.info("emitting %d turn-history row(s)", len(rows))
wire({"kind": "history", "rows": rows})
# Before the terminal: the browser tidy asks its decision with the
# turn key, which the host revokes once `turn_completed` arrives.
# Bounded by TIDY_TIMEOUT_S and never raises; close() then skips it.
await tidy_after_turn(session)
logger.info("cloud turn completed")
completed = {"kind": "turn_completed"}
# The folders this turn's tools and cells touched, so the host stats
Expand Down
7 changes: 5 additions & 2 deletions anton/cloud_turn/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,13 @@ class TurnRequestV1:
#: Absent, null, blank, or non-string keeps the configured default.
reasoning_effort: str | None = None
#: The MindsHub browser router, when cowork-server turned the browser on for
#: this turn: {"base_url", "profile", "project"?}, read by
#: BrowserConfig.from_dict. The pod reaches the router with this turn's
#: this turn: {"base_url", "profile", "project"?, "decisions_proxy"?}, read
#: by BrowserConfig.from_dict. The pod reaches the router with this turn's
#: `llm` key. A block with a `token`, or with any address but the https
#: router, is refused. Absent or malformed means no browser tool this turn.
#: `decisions_proxy` ({"url", "model"}, no key) is cowork-server's route
#: to the organization's own decision model, which the pod calls with the
#: same `llm` key.
browser: BrowserConfig | None = None
#: The tenant's per-task limits cowork-server resolved: any of
#: ``max_tool_rounds``, ``max_continuations``, ``max_turn_tokens``,
Expand Down
24 changes: 18 additions & 6 deletions anton/core/browser/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Tab,
TabAnswer,
TabsAnswer,
WaitFor,
)

#: Page loads and clicks that navigate can take a while; the hosts cap their
Expand Down Expand Up @@ -199,12 +200,19 @@ async def control(self, *, session_id: str) -> Control:
"""Who holds the browser. Answers even while the person holds it."""
return (await self.session_info(session_id=session_id)).control

async def hand_to_person(self, *, session_id: str, reason: str) -> Control:
async def hand_to_person(self, *, session_id: str, reason: str, wait_for: WaitFor | None = None) -> Control:
"""Give the browser to the person. While they hold it the host refuses
the agent's actions and page reads, and shows them it's their turn.
Only the person hands it back, with Done in the browser; the agent
never asks for it back."""
body = {"holder": "human", "reason": cut_reason(reason)}
never asks for it back.

``wait_for`` names what the person is there to do. A host that
watches for it says so in its answer (``watching``) and hands the
browser back by itself, as the person's Done, once they did it and
left the page alone for a few seconds."""
body: dict = {"holder": "human", "reason": cut_reason(reason)}
if wait_for is not None:
body["wait_for"] = wait_for.model_dump(exclude_none=True)
return await self._read(Control, "POST", f"/sessions/{quote(session_id)}/control", json=body)

async def tabs(self, *, session_id: str) -> list[Tab]:
Expand All @@ -219,9 +227,13 @@ async def activate_tab(self, *, session_id: str, tab_id: str) -> Tab:
path = f"/sessions/{quote(session_id)}/tabs/{quote(tab_id, safe='')}/activate"
return (await self._read(TabAnswer, "POST", path)).tab

async def close_tab(self, *, session_id: str, tab_id: str) -> None:
"""Closing the last tab leaves a blank one."""
await self._request("DELETE", f"/sessions/{quote(session_id)}/tabs/{quote(tab_id, safe='')}")
async def close_tab(self, *, session_id: str, tab_id: str, park: bool = False) -> None:
"""Closing the last tab leaves a blank one. ``park`` notes the tab
(address and title) among the session's parked tabs, to reopen later."""
await self._request(
"DELETE", f"/sessions/{quote(session_id)}/tabs/{quote(tab_id, safe='')}",
params={"park": "true"} if park else None,
)

async def saved_tabs(self, *, project: str) -> list[SavedTab]:
"""The project's saved tabs, newest first."""
Expand Down
129 changes: 121 additions & 8 deletions anton/core/browser/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,95 @@
_TOKEN = re.compile(r"[\x21-\x7e]+")


class DecisionsTarget(BaseModel):
"""A decision model of the host's own that picks the browser's steps,
instead of Jev on the session's MindsHub connection.

``url`` is the endpoint's full URL, which takes the decision body
``anton.core.llm.jev.decide`` sends (model, state, questions): hosts serve
it at different paths (TypeSafe's ``/v1/systemone``, a gateway's
``/v1/decisions``), so nothing is appended to it. ``model`` is the name
that endpoint expects. Only a host builds one, in its own process, as it
does the in-app browser's launch key: ``from_dict`` never reads one and
``to_dict`` refuses one. ``repr`` and validation errors leave the key out.
"""

model_config = ConfigDict(frozen=True, extra="forbid", hide_input_in_errors=True)

url: str
api_key: SecretStr
model: str = "jev"

@field_validator("url")
@classmethod
def _url_is_http(cls, value: str) -> str:
url = urlsplit(value)
if url.scheme not in ("http", "https") or not url.hostname or "@" in url.netloc:
raise ValueError("the decision endpoint must be an http(s) URL with a host and no user")
return value

@field_validator("api_key")
@classmethod
def _key_is_set(cls, value: SecretStr) -> SecretStr:
if not value.get_secret_value().strip():
raise ValueError("the decision endpoint needs its API key")
return value

@field_validator("model")
@classmethod
def _model_is_set(cls, value: str) -> str:
if not value.strip():
raise ValueError("the decision endpoint needs a model name")
return value.strip()


class DecisionsProxy(BaseModel):
"""A decision model of the host's own, reached through the host: the
form a turn request can carry, since it holds no key.

A cloud pod must not hold the organization's decision model key, so the
host serves a route that forwards each decision to that model with the
key it keeps. ``url`` is that route's full URL (https, no user, query or
fragment), and the tool calls it with the session's MindsHub credential,
the turn key the router takes too, which the host checks and maps to the
organization. ``model`` is the name the organization's endpoint expects.
"""

model_config = ConfigDict(frozen=True, extra="forbid", hide_input_in_errors=True)

url: str
model: str = "jev"

@field_validator("url")
@classmethod
def _url_is_https(cls, value: str) -> str:
url = urlsplit(value)
if url.scheme != "https" or not url.hostname or "@" in url.netloc or url.query or url.fragment:
raise ValueError("the decisions proxy must be https://<host>[/path], with no user, query or fragment")
return value

@field_validator("model")
@classmethod
def _model_is_set(cls, value: str) -> str:
if not value.strip():
raise ValueError("the decisions proxy needs a model name")
return value.strip()

@classmethod
def from_dict(cls, raw: object) -> DecisionsProxy | None:
"""A turn request's ``{"url", "model"?}``, or None when unusable. A
block with any other key, a ``api_key`` above all, is refused whole."""
if not isinstance(raw, dict) or not set(raw) <= {"url", "model"}:
return None
url, model = raw.get("url"), raw.get("model", "jev")
if not isinstance(url, str) or not isinstance(model, str):
return None
try:
return cls(url=url, model=model)
except ValueError:
return None


class BrowserConfig(BaseModel):
"""Where the browser the tool drives is, and which session to drive.

Expand All @@ -36,6 +125,13 @@ class BrowserConfig(BaseModel):
keys the tabs saved for the conversation's project; empty when there is
none, and saved tabs are then unavailable.

``decisions`` is the host's own decision model for the browser's steps
(``DecisionsTarget``), for either form. ``decisions_proxy`` is the same
model reached through the host with the session's MindsHub credential
(``DecisionsProxy``), for the router form: the one a turn request
carries, since it holds no key. With neither, Jev on the session's
MindsHub connection picks them, where there is one.

Validation errors never echo the input, so a refused config can be
logged without its key. ``repr`` masks the key too.
"""
Expand All @@ -46,6 +142,8 @@ class BrowserConfig(BaseModel):
profile: str
project: str = ""
token: SecretStr | None = None
decisions: DecisionsTarget | None = None
decisions_proxy: DecisionsProxy | None = None

@field_validator("base_url", mode="before")
@classmethod
Expand Down Expand Up @@ -84,6 +182,8 @@ def _one_of_two_forms(self) -> BrowserConfig:
raise ValueError(f"the in-app browser's base_url must be exactly http://{LOOPBACK_HOST}:<port>")
if self.token is None or not _TOKEN.fullmatch(self.token.get_secret_value()):
raise ValueError("the in-app browser needs its launch key as the token")
if self.decisions_proxy is not None:
raise ValueError("the in-app browser's host hands it its decision model directly")
return self
raise ValueError(f"base_url must be the https router or http://{LOOPBACK_HOST}:<port>")

Expand All @@ -94,13 +194,16 @@ def in_app(self) -> bool:

@classmethod
def from_dict(cls, raw: object) -> BrowserConfig | None:
"""Read a turn request's router block, ``{"base_url", "profile", "project"?}``.
"""Read a turn request's router block, ``{"base_url", "profile", "project"?,
"decisions_proxy"?}``.

None when the block is absent or unusable: not a dict, a ``token``
key of any value, a base_url that isn't an https router, or a
missing or malformed ``profile``. A malformed ``project`` reads as
none. So nothing a request carries can point the tool at a browser
that takes its own key.
none, and so does a malformed ``decisions_proxy``
(``DecisionsProxy.from_dict``); a ``decisions`` key is never read. So
nothing a request carries can point the tool at a browser that takes
its own key, or hand it a decision model's key.
"""
if not isinstance(raw, dict) or "token" in raw:
return None
Expand All @@ -112,21 +215,31 @@ def from_dict(cls, raw: object) -> BrowserConfig | None:
try:
if urlsplit(base_url).scheme != "https":
return None
return cls(base_url=base_url, profile=profile, project=project)
return cls(
base_url=base_url, profile=profile, project=project,
decisions_proxy=DecisionsProxy.from_dict(raw.get("decisions_proxy")),
)
except ValueError:
return None

def to_dict(self) -> dict[str, str]:
def to_dict(self) -> dict:
"""The router block a host puts in a turn request: ``base_url`` and
``profile``, plus ``project`` when there is one. Never a ``token``
key, so ``from_dict`` reads it back as this same config.
``profile``, plus ``project`` and ``decisions_proxy`` (``{"url",
"model"}``, no key) when there are. Never a ``token`` or
``decisions`` key, so ``from_dict`` reads it back as this same config.

The in-app browser's config has no dict form: its launch key stays in
the host's process. Raises ValueError for it.
the host's process. Nor has one with a decision model of the host's
own (``decisions``), for its key: a host hands a turn elsewhere the
same model as a ``decisions_proxy``. Raises ValueError for either.
"""
if self.in_app:
raise ValueError("the in-app browser's config stays in the host's process")
if self.decisions is not None:
raise ValueError("a config with the host's own decision model stays in the host's process")
block = {"base_url": self.base_url, "profile": self.profile}
if self.project:
block["project"] = self.project
if self.decisions_proxy is not None:
block["decisions_proxy"] = {"url": self.decisions_proxy.url, "model": self.decisions_proxy.model}
return block
Loading
Loading