ms-tau-sdk 3.0.0.dev101__tar.gz → 3.0.1.dev102__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/CHANGELOG.md +23 -0
  2. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/PKG-INFO +1 -1
  3. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/pyproject.toml +1 -1
  4. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/tau_local_development/SKILL.md +3 -0
  5. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/tau_security_and_access/SKILL.md +30 -3
  6. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/client.py +7 -0
  7. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/hydrate_endpoint.py +113 -2
  8. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/model_relay/__init__.py +4 -0
  9. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/model_relay/component.py +29 -6
  10. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/providers/factory.py +39 -0
  11. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/.gitignore +0 -0
  12. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/README.md +0 -0
  13. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/__init__.py +0 -0
  14. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/app.py +0 -0
  15. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/cli.py +0 -0
  16. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/config.py +0 -0
  17. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/env_file.py +0 -0
  18. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/logs.py +0 -0
  19. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/proxy.py +0 -0
  20. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/state.py +0 -0
  21. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/static/BULMA-LICENSE.txt +0 -0
  22. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/static/app.js +0 -0
  23. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/static/board.css +0 -0
  24. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/static/bulma.min.css +0 -0
  25. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/packages/tau-board/src/ms_tau_board/static/index.html +0 -0
  26. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/__init__.py +0 -0
  27. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/design-agent-icons-and-motion/SKILL.md +0 -0
  28. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/design-agent-icons-and-motion/agents/openai.yaml +0 -0
  29. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/design-agent-icons-and-motion/references/metatables-example.html +0 -0
  30. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/tau_a2a_runtime_adapter/SKILL.md +0 -0
  31. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/tau_project_customization/SKILL.md +0 -0
  32. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/agent_skills/tau_repository_integration/SKILL.md +0 -0
  33. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/__init__.py +0 -0
  34. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/a2a.py +0 -0
  35. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/chat.py +0 -0
  36. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/conversations.py +0 -0
  37. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/dependencies.py +0 -0
  38. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/health.py +0 -0
  39. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/inspection.py +0 -0
  40. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/local_chat.py +0 -0
  41. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/models.py +0 -0
  42. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/request_identity.py +0 -0
  43. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/api/sessions.py +0 -0
  44. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/app.py +0 -0
  45. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/application.py +0 -0
  46. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/__init__.py +0 -0
  47. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/assertions.py +0 -0
  48. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/auth.py +0 -0
  49. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/local.py +0 -0
  50. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/mcp.py +0 -0
  51. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/models.py +0 -0
  52. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/release_access.py +0 -0
  53. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/release_readiness.py +0 -0
  54. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/routes.py +0 -0
  55. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/backend/team_memberships.py +0 -0
  56. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/cli.py +0 -0
  57. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/errors.py +0 -0
  58. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/logging.py +0 -0
  59. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/model_relay/contract.py +0 -0
  60. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/__init__.py +0 -0
  61. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/a2a_failure.py +0 -0
  62. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/a2a_message.py +0 -0
  63. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/a2a_roles.py +0 -0
  64. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/assistant_ui.py +0 -0
  65. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/caller_context.py +0 -0
  66. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/chat_history.py +0 -0
  67. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/protocols/strict_json.py +0 -0
  68. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/providers/__init__.py +0 -0
  69. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/providers/definitions.py +0 -0
  70. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/providers/tau_compat.py +0 -0
  71. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/resources/SYSTEM.md +0 -0
  72. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/resources/__init__.py +0 -0
  73. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/resources/context_compat.py +0 -0
  74. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/resources/loader.py +0 -0
  75. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/resources/prompts/review-code-repository.md +0 -0
  76. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/resources/selection.py +0 -0
  77. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/__init__.py +0 -0
  78. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/deployment_health.py +0 -0
  79. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/events.py +0 -0
  80. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/extensions.py +0 -0
  81. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/failures.py +0 -0
  82. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/live_turns.py +0 -0
  83. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/manager.py +0 -0
  84. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/observability.py +0 -0
  85. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/provenance.py +0 -0
  86. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/requester.py +0 -0
  87. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/session.py +0 -0
  88. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/snapshots.py +0 -0
  89. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/runtime/task_context.py +0 -0
  90. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/sessions/__init__.py +0 -0
  91. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/sessions/storage.py +0 -0
  92. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/settings.py +0 -0
  93. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/skills.py +0 -0
  94. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/tools/__init__.py +0 -0
  95. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/tools/mainsequence_mcp.py +0 -0
  96. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/tools/mcp_applications.py +0 -0
  97. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/tools/mcp_connection.py +0 -0
  98. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/tools/skill_read.py +0 -0
  99. {ms_tau_sdk-3.0.0.dev101 → ms_tau_sdk-3.0.1.dev102}/src/ms_tau_sdk/tools/task_control.py +0 -0
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.1 — 2026-11-14
4
+
5
+ - **An application's own model relay can be reached from a hosted session.** In 3.0.0 a model
6
+ call to the relay an application with its own hydrate endpoint serves carried only the session
7
+ pass. The application's request identity refuses a call with no Main Sequence caller before any
8
+ route runs, so the relay never ran and no hosted session of such an application could call a
9
+ model ([#142](https://github.com/mainsequence-sdk/ms-tau-sdk/issues/142)). Now the runtime calls
10
+ that relay as it calls the hydrate endpoint: with the token the platform mints for the hydrate
11
+ release in `Authorization`, renewed once on a `401`, after waking a release that may have scaled
12
+ to zero. The pass moves to `X-Model-Relay-Pass`, with `X-Model-Relay-Pass-Place` naming where
13
+ the transport put it, and `create_model_relay_router` reads it from there. `resolve_pass` runs
14
+ after request identity, so it can check that `User.get_logged_user()` is the application's own
15
+ Agent. The relay stays an ordinary route behind request identity, with no public route.
16
+ - **The token goes only to the hydrate release.** A hosted hydrate answer whose
17
+ `relay_definition.base_url` is not the release's RPC URL or below it is refused, and a model
18
+ call to any other address is refused before it is sent. An application that answered a relay
19
+ on another host must move it onto the hydrate release.
20
+ - **The platform's relay is unchanged.**
21
+
22
+ Tested against the SDK's relay component behind a stand-in for request identity, on the Responses,
23
+ Anthropic, Google and Codex transports; nothing was tried against a deployed application. See
24
+ the amendment to [ADR 0030](docs/adrs/0030-hosted-model-calls-go-through-a-relay.md), section 7.
25
+
3
26
  ## 3.0.0 — 2026-11-13
4
27
 
5
28
  Breaking: 3.0.0 is a hard cut with no transition and no setting to turn it off. Read the upgrade
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ms-tau-sdk
3
- Version: 3.0.0.dev101
3
+ Version: 3.0.1.dev102
4
4
  Summary: Workspace-bound Tau application primitives for Main Sequence projects
5
5
  Project-URL: Changelog, https://github.com/mainsequence-sdk/ms-tau-sdk/blob/development/CHANGELOG.md
6
6
  Project-URL: Documentation, https://github.com/mainsequence-sdk/ms-tau-sdk/tree/development/docs
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "ms-tau-sdk"
7
- version = "3.0.0.dev101"
7
+ version = "3.0.1.dev102"
8
8
  description = "Workspace-bound Tau application primitives for Main Sequence projects"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.13"
@@ -56,6 +56,9 @@ An application that keeps its own people's model credentials can hydrate them in
56
56
  `TAU_LOCAL_PROVIDER_CREDENTIAL_HYDRATE_URL` to its service on a loopback origin such as
57
57
  `http://127.0.0.1:8611`. Every hydration then names the local session in `agent_session_uid`, and
58
58
  readiness hydrates nothing. A loopback address receives no credential of any kind. See ADR 0027.
59
+ In local mode the endpoint answers the real credential. A hosted session receives a pass instead,
60
+ and the release must also serve the model relay under its own RPC URL; the
61
+ `tau_security_and_access` skill says how (ADR 0030).
59
62
 
60
63
  ## Exact local/remote boundary
61
64
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: tau-security-and-access
3
- description: Build and review project tools that call the platform or other applications for the person a turn serves, including tools that use a person's Secret without exposing it or read the caller context another application sends, and explain how delegation and policies decide what those tools can reach.
3
+ description: Build and review project tools that call the platform or other applications for the person a turn serves, including tools that use a person's Secret without exposing it or read the caller context another application sends, and explain how delegation and policies decide what those tools can reach. Also serve the model relay of an application that hydrates its own people's model credentials.
4
4
  ---
5
5
 
6
6
  # TAU Security and Access
@@ -241,8 +241,33 @@ made. To let a team run an Agent on one credential, its owner gives the team `us
241
241
 
242
242
  From ms-tau-sdk 3.0.0 a hosted session never receives the secret: it receives a session pass and a
243
243
  relay address, and every model call goes through the relay, which holds the secret. The pass works
244
- only at that relay and only while the run holds the session. An application with its own hydrate
245
- endpoint serves its relay with `ms_tau_sdk.model_relay` (ADR 0030).
244
+ only at that relay and only while the run holds the session.
245
+
246
+ ### Serving the relay of your own hydrate endpoint
247
+
248
+ An application whose own hydrate endpoint (ADR 0027) answers its people's model credentials, named
249
+ by `MAINSEQUENCE_TAU_PROVIDER_CREDENTIAL_HYDRATE_RELEASE_UID`, must serve the relay for those
250
+ credentials too, because only it holds them. Use ms-tau-sdk 3.0.1 or later on the runtime: in
251
+ 3.0.0 a model call carried only the pass, the application's request identity refused it for
252
+ having no Main Sequence caller, and no hosted session could call a model.
253
+
254
+ - Mount `ms_tau_sdk.model_relay.create_model_relay_router` on the hydrate release itself, as an
255
+ ordinary route behind its request identity, for example under `/model-relay`. Do not make it a
256
+ public route: request identity strips `Authorization` from a public call.
257
+ - In the hosted hydrate answer, give a session pass where the secret goes and
258
+ `relay_definition: {"base_url": "<the release's RPC URL>/model-relay"}`. The runtime sends the
259
+ release's token with every model call, as with the hydrate call, and only under that RPC URL: it
260
+ refuses a relay on another host or path. Never put `base_url` or `headers` in a relayed entry.
261
+ - The runtime moves the pass into `X-Model-Relay-Pass`, with `X-Model-Relay-Pass-Place`, and the
262
+ router reads it from there. Do not read the pass yourself.
263
+ - In `resolve_pass`, refuse a caller that is not your own Agent: `User.get_logged_user()` is the
264
+ verified runtime. Then refuse a pass that names no running session, with `RelayRefused` and a
265
+ detail that holds no pass or secret.
266
+ - In `resolve_upstream`, answer the provider's own address and the real secret for that session.
267
+ - In local mode the endpoint answers the real credential and no relay is called.
268
+
269
+ The public API page shows the full example, and the Security and access guide's "Running your
270
+ own relay" lists what the application still owns: pass lifetime, URL logging and body size.
246
271
 
247
272
  ## Agents
248
273
 
@@ -375,3 +400,5 @@ Patch the extension module's `current_requester` and `platform_client` with fake
375
400
  absence is refused, never read as everyone.
376
401
  - The Agent's workload holds no grants it does not need, and none on people's Secrets; `user` is
377
402
  enough on an Agent it only sends work to.
403
+ - A hydrate release's model relay is a route of that release behind request identity, its
404
+ address is under the release's RPC URL, and `resolve_pass` checks the caller and the pass.
@@ -229,6 +229,13 @@ class MainSequenceClient:
229
229
  self._owns_hydrate_http = hydrate_client is None
230
230
  self._hydrate_endpoint = self._custom_hydrate_endpoint()
231
231
 
232
+ @property
233
+ def model_relay_release(self) -> ReleaseHydrateEndpoint | None:
234
+ """The hydrate release, which serves the model relay of the sessions it hydrates."""
235
+
236
+ endpoint = self._hydrate_endpoint
237
+ return endpoint if isinstance(endpoint, ReleaseHydrateEndpoint) else None
238
+
232
239
  @staticmethod
233
240
  def _timeout(settings: TauSDKSettings) -> httpx.Timeout:
234
241
  return httpx.Timeout(
@@ -13,14 +13,19 @@ custom endpoint implements the same contract for people the platform does not kn
13
13
  Only the token, to the release, crosses: never the runtime's Main Sequence credential, a caller
14
14
  assertion, a lease token, caller context or an ``X-MainSequence-*`` header. No answer, token or
15
15
  credential value is logged or kept in an error.
16
+
17
+ In a hosted session the release also serves the model relay (ADR 0030, section 7). Its model calls
18
+ are admitted as the hydrate call is: ``ReleaseRelayAuth`` sends the same token, only to an address
19
+ under the release's RPC URL, and moves the session pass into its own header.
16
20
  """
17
21
 
18
22
  from __future__ import annotations
19
23
 
20
24
  import asyncio
21
25
  import time
22
- from collections.abc import Awaitable, Callable, Mapping
26
+ from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping
23
27
  from typing import Any
28
+ from urllib.parse import unquote
24
29
 
25
30
  import httpx
26
31
  import structlog
@@ -29,7 +34,9 @@ from ms_tau_sdk.errors import (
29
34
  BackendConflictError,
30
35
  BackendError,
31
36
  BackendTimeoutError,
37
+ ConfigurationError,
32
38
  )
39
+ from ms_tau_sdk.model_relay import RELAY_PASS_HEADER, RELAY_PASS_PLACE_HEADER
33
40
  from ms_tau_sdk.settings import TauSDKSettings
34
41
 
35
42
  from .models import ReleaseRuntimeAccess
@@ -68,6 +75,25 @@ def _refusal_detail(response: httpx.Response) -> dict[str, str] | None:
68
75
  return detail or None
69
76
 
70
77
 
78
+ def on_release(url: httpx.URL | str, rpc_url: httpx.URL) -> bool:
79
+ """Whether ``url`` is the release's RPC URL or below it, the only place its token may go."""
80
+
81
+ url = httpx.URL(url)
82
+ if (
83
+ url.scheme,
84
+ url.host,
85
+ url.port,
86
+ url.username,
87
+ url.password,
88
+ ) != (rpc_url.scheme, rpc_url.host, rpc_url.port, "", ""):
89
+ return False
90
+ # httpx resolves literal dot segments, not encoded ones, which a server may resolve later.
91
+ if any(unquote(segment) in {".", ".."} for segment in url.raw_path.decode().split("/")):
92
+ return False
93
+ base = rpc_url.path.rstrip("/")
94
+ return url.path == base or url.path.startswith(f"{base}/")
95
+
96
+
71
97
  def _log_fields(detail: Mapping[str, str] | None) -> dict[str, str]:
72
98
  if not detail:
73
99
  return {}
@@ -278,7 +304,30 @@ class ReleaseHydrateEndpoint(CustomHydrateEndpoint):
278
304
  raise
279
305
  if response.status_code < 500:
280
306
  release_warmth.served(self.release_uid)
281
- return self._answer(response)
307
+ data = self._answer(response)
308
+ self._refuse_relays_elsewhere(data, access)
309
+ return data
310
+
311
+ async def relay_access(self, *, stale: ReleaseAccess | None = None) -> ReleaseAccess:
312
+ """The token and RPC URL a model call to this release's relay uses, as hydration does."""
313
+
314
+ return await self._release_access(stale=stale)
315
+
316
+ @staticmethod
317
+ def _refuse_relays_elsewhere(data: Mapping[str, Any], access: ReleaseAccess) -> None:
318
+ """Refuse a relay that is not the release's own: its token would follow the model calls."""
319
+
320
+ credentials = data.get("credentials")
321
+ if not isinstance(credentials, Mapping):
322
+ return
323
+ for entry in credentials.values():
324
+ relay = entry.get("relay_definition") if isinstance(entry, Mapping) else None
325
+ base_url = relay.get("base_url") if isinstance(relay, Mapping) else None
326
+ if isinstance(base_url, str) and not on_release(base_url, access.rpc_url):
327
+ raise ConfigurationError(
328
+ "The provider credential hydrate release answered a relay_definition "
329
+ "that is not under its own address"
330
+ )
282
331
 
283
332
  def _url(self, access: ReleaseAccess) -> httpx.URL:
284
333
  url = httpx.URL(str(access.rpc_url).rstrip("/") + HYDRATE_PATH)
@@ -335,9 +384,71 @@ class ReleaseHydrateEndpoint(CustomHydrateEndpoint):
335
384
  raise failure
336
385
 
337
386
 
387
+ class ReleaseRelayAuth(httpx.Auth):
388
+ """Admit a model call at the relay the hydrate release serves, as its hydrate call is admitted.
389
+
390
+ Request identity admits a call by its ``Authorization``, so the transport's pass moves to
391
+ ``X-Model-Relay-Pass``, with its place, and ``Authorization`` carries the release token. The
392
+ token goes only to an address under the release's RPC URL; a call anywhere else is refused
393
+ before it is sent. A ``401`` gets a new token once.
394
+ """
395
+
396
+ requires_request_body = True
397
+
398
+ def __init__(self, release: ReleaseHydrateEndpoint) -> None:
399
+ self._release = release
400
+
401
+ def __repr__(self) -> str:
402
+ return f"ReleaseRelayAuth(release_uid={self._release.release_uid!r})"
403
+
404
+ async def async_auth_flow(
405
+ self,
406
+ request: httpx.Request,
407
+ ) -> AsyncGenerator[httpx.Request, httpx.Response]:
408
+ self._move_pass(request)
409
+ access = await self._release.relay_access()
410
+ self._authorize(request, access)
411
+ response = yield request
412
+ if response.status_code == 401:
413
+ access = await self._release.relay_access(stale=access)
414
+ self._authorize(request, access)
415
+ response = yield request
416
+ if response.status_code < 500:
417
+ release_warmth.served(self._release.release_uid)
418
+
419
+ @staticmethod
420
+ def _move_pass(request: httpx.Request) -> None:
421
+ """Move the pass from where the transport put a secret, in the relay's order."""
422
+
423
+ authorization = request.headers.get("authorization", "")
424
+ if authorization[:7].lower() == "bearer " and authorization[7:].strip():
425
+ place, session_pass = "bearer", authorization[7:].strip()
426
+ del request.headers["authorization"]
427
+ elif request.headers.get("x-api-key"):
428
+ place, session_pass = "x-api-key", request.headers["x-api-key"]
429
+ del request.headers["x-api-key"]
430
+ elif request.url.params.get("key"):
431
+ place, session_pass = "query", request.url.params["key"]
432
+ request.url = request.url.copy_remove_param("key")
433
+ else:
434
+ raise ConfigurationError("A model call to the hydrate release carries no session pass")
435
+ request.headers[RELAY_PASS_HEADER] = session_pass
436
+ request.headers[RELAY_PASS_PLACE_HEADER] = place
437
+
438
+ @staticmethod
439
+ def _authorize(request: httpx.Request, access: ReleaseAccess) -> None:
440
+ if not on_release(request.url, access.rpc_url):
441
+ raise ConfigurationError(
442
+ "The model relay is not under the provider credential hydrate release's address"
443
+ )
444
+ request.headers["Authorization"] = f"Bearer {access.token.value}"
445
+
446
+
338
447
  __all__ = [
339
448
  "HYDRATE_PATH",
340
449
  "CustomHydrateEndpoint",
341
450
  "LocalAddressHydrateEndpoint",
342
451
  "ReleaseHydrateEndpoint",
452
+ "ReleaseRelayAuth",
453
+ "on_release",
343
454
  ]
@@ -1,6 +1,8 @@
1
1
  """The model relay component for applications with their own hydrate endpoint (ADR 0030)."""
2
2
 
3
3
  from .component import (
4
+ RELAY_PASS_HEADER,
5
+ RELAY_PASS_PLACE_HEADER,
4
6
  RELAY_PATHS,
5
7
  RelayRefused,
6
8
  RelayUpstream,
@@ -8,6 +10,8 @@ from .component import (
8
10
  )
9
11
 
10
12
  __all__ = [
13
+ "RELAY_PASS_HEADER",
14
+ "RELAY_PASS_PLACE_HEADER",
11
15
  "RELAY_PATHS",
12
16
  "RelayRefused",
13
17
  "RelayUpstream",
@@ -9,9 +9,13 @@ The application supplies two things: who a pass belongs to, and the provider, ad
9
9
  for that session. Everything else is fixed here and behaves as the platform's relay does towards a
10
10
  runtime:
11
11
 
12
- - the pass is read where the runtime's transport puts a secret: an ``Authorization`` bearer
13
- token, ``x-api-key``, or the ``key`` query parameter. The real secret goes back in the place the
14
- pass arrived, and the pass is never forwarded;
12
+ - the pass is read from ``X-Model-Relay-Pass``, with the place the transport put it in
13
+ ``X-Model-Relay-Pass-Place``. A runtime sends it there when the relay is served by its hydrate
14
+ release, because ``Authorization`` then carries the release token that request identity admits,
15
+ as on the hydrate call. Without those headers the pass is read where the transport puts a
16
+ secret: an ``Authorization`` bearer token, ``x-api-key``, or the ``key`` query parameter. The
17
+ real secret goes back in the place the pass was put, and neither the pass nor ``Authorization``
18
+ is ever forwarded;
15
19
  - the upstream address comes only from the application's answer, never from the request;
16
20
  - only the methods and paths the session's wire protocol uses are forwarded. A leading ``/v1`` in
17
21
  the request path is the transport's own;
@@ -46,6 +50,11 @@ logger = structlog.get_logger(__name__)
46
50
  RELAY_CONNECT_TIMEOUT_SECONDS = 10
47
51
  RELAY_READ_TIMEOUT_SECONDS = 180
48
52
  RELAY_METHODS = ("GET", "POST", "PUT", "PATCH", "DELETE")
53
+ # Where a runtime sends the pass to a relay its hydrate release serves, and the place its transport
54
+ # put it: "bearer", "x-api-key" or "query" (ADR 0030, section 7).
55
+ RELAY_PASS_HEADER = "X-Model-Relay-Pass"
56
+ RELAY_PASS_PLACE_HEADER = "X-Model-Relay-Pass-Place"
57
+ RELAY_PASS_PLACES = frozenset({"bearer", "x-api-key", "query"})
49
58
 
50
59
  # The methods and paths each Tau wire protocol calls, after a leading /v1. The platform's relay
51
60
  # allows the same ones.
@@ -80,6 +89,8 @@ _NOT_FORWARDED = _HOP_BY_HOP | frozenset(
80
89
  "cookie",
81
90
  "forwarded",
82
91
  "x-real-ip",
92
+ RELAY_PASS_HEADER.lower(),
93
+ RELAY_PASS_PLACE_HEADER.lower(),
83
94
  }
84
95
  )
85
96
  _NOT_RETURNED = _HOP_BY_HOP | frozenset({"content-length", "set-cookie"})
@@ -138,8 +149,17 @@ def _refusal(detail: str) -> JSONResponse:
138
149
  def _session_pass(
139
150
  headers: Mapping[str, str], query: Mapping[str, str]
140
151
  ) -> tuple[str, str] | tuple[None, None]:
141
- """Where the runtime's transport put the pass, and the pass, in the platform's order."""
152
+ """Where the runtime's transport put the pass, and the pass, in the platform's order.
142
153
 
154
+ The pass header comes first: beside it, ``Authorization`` carries the release token.
155
+ """
156
+
157
+ if RELAY_PASS_HEADER.lower() in headers:
158
+ place = str(headers.get(RELAY_PASS_PLACE_HEADER.lower()) or "")
159
+ relayed_pass = str(headers[RELAY_PASS_HEADER.lower()]).strip()
160
+ if place in RELAY_PASS_PLACES and relayed_pass:
161
+ return place, relayed_pass
162
+ return None, None
143
163
  authorization = str(headers.get("authorization") or "")
144
164
  if authorization[:7].lower() == "bearer " and authorization[7:].strip():
145
165
  return "bearer", authorization[7:].strip()
@@ -226,8 +246,11 @@ def create_model_relay_router[SessionT](
226
246
  for example ``app.include_router(router, prefix="/model-relay")``.
227
247
 
228
248
  ``resolve_pass`` answers the session a pass names and ``resolve_upstream`` the provider call
229
- for that session; either raises ``RelayRefused`` to refuse the call. ``http`` replaces the
230
- client the relay calls providers with; it must not follow redirects. The caller owns it.
249
+ for that session; either raises ``RelayRefused`` to refuse the call. Both run inside the
250
+ request, after request identity admitted it, so ``resolve_pass`` can check the verified
251
+ caller, for example that ``User.get_logged_user()`` is the application's own Agent. ``http``
252
+ replaces the client the relay calls providers with; it must not follow redirects. The caller
253
+ owns it.
231
254
  """
232
255
 
233
256
  for name in ("httpx", "httpcore"):
@@ -7,6 +7,7 @@ import ipaddress
7
7
  from collections.abc import Awaitable, Callable
8
8
  from dataclasses import dataclass
9
9
  from datetime import UTC, datetime, timedelta
10
+ from typing import Any
10
11
  from urllib.parse import urlsplit
11
12
 
12
13
  import structlog
@@ -19,6 +20,7 @@ from tau_ai.env import (
19
20
  RuntimeProviderAuthResolver,
20
21
  )
21
22
  from tau_ai.google import GoogleGenerativeAIProvider
23
+ from tau_ai.http import create_async_client
22
24
  from tau_ai.mistral import MistralConversationsProvider
23
25
  from tau_ai.openai_cache import is_direct_openai_url
24
26
  from tau_ai.openai_codex import (
@@ -40,6 +42,7 @@ from tau_coding.thinking import (
40
42
  )
41
43
 
42
44
  from ms_tau_sdk.backend.client import MainSequenceClient
45
+ from ms_tau_sdk.backend.hydrate_endpoint import ReleaseRelayAuth
43
46
  from ms_tau_sdk.backend.models import (
44
47
  AgentSession,
45
48
  ProviderControl,
@@ -522,6 +525,42 @@ class ProviderFactory:
522
525
  ) -> ModelProvider:
523
526
  if timeout_seconds is None:
524
527
  timeout_seconds = self.provider_timeout_seconds
528
+ provider = self._build(
529
+ credential,
530
+ provider_control=provider_control,
531
+ model=model,
532
+ credential_resolver=credential_resolver,
533
+ thinking_level=thinking_level,
534
+ max_tokens=max_tokens,
535
+ timeout_seconds=timeout_seconds,
536
+ )
537
+ release = getattr(self.backend, "model_relay_release", None)
538
+ if credential.relay_definition is not None and release is not None:
539
+ # The hydrate release serves this relay behind request identity, which admits its
540
+ # model calls by the release token, as it admits the hydrate call (ADR 0030, section
541
+ # 7). Tau's transports take no auth of their own, so each owns a client that has it.
542
+ transport: Any = provider
543
+ if not hasattr(transport, "_owns_client"):
544
+ raise ConfigurationError(
545
+ f"Provider {credential.provider} cannot call the hydrate release's relay"
546
+ )
547
+ transport._client = create_async_client(
548
+ timeout=timeout_seconds, auth=ReleaseRelayAuth(release)
549
+ )
550
+ transport._owns_client = True
551
+ return provider
552
+
553
+ def _build(
554
+ self,
555
+ credential: ProviderCredential,
556
+ *,
557
+ provider_control: ProviderControl,
558
+ model: str | None,
559
+ credential_resolver: CredentialResolver | None,
560
+ thinking_level: str | None,
561
+ max_tokens: int | None,
562
+ timeout_seconds: float,
563
+ ) -> ModelProvider:
525
564
  definition = PROVIDER_DEFINITIONS.get(credential.provider)
526
565
  catalog_provider = CATALOG_BY_NAME.get(credential.provider)
527
566
  # A provider this Tau does not know runs only through Tau's OpenAI-compatible constructor,