Skip to content

Commit 9d2e6ff

Browse files
authored
feat: support BYOC tunnel bindings for MCP requests (#42)
1 parent cc9d824 commit 9d2e6ff

13 files changed

Lines changed: 129 additions & 0 deletions

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ existing `0.1.0` release; earlier development prereleases are not listed.
77

88
### Added
99

10+
- Bind a Managed Session to a BYOC MCP tunnel with `tunnel_id` at creation. On Forward, set the tunnel on a Template for its sessions to inherit. Managed Deployments also accept and return the binding. Template and Deployment updates can replace or clear it.
11+
1012
- Add typed Forward Session budgets across create/update responses and events, including omission, explicit null clearing and decimal-string limits.
1113
- Add Forward Session `config.model` overrides and model `speed` configuration, plus optional approval evaluation details, Outcome/status event fields and cumulative top-level Credits on `session.usage`.
1214
- Add `startup_script` to Forward/Managed Environment models and Managed cloud/self-hosted parameters. It runs on sandbox start/resume; the external worker controls self-hosted execution.

‎docs/api/reference.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9775,6 +9775,7 @@ def create(
97759775
name: str,
97769776
model: Union[str, ModelConfigParam],
97779777
environment_id: str,
9778+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
97789779
description: Union[str, None, NotGiven] = NOT_GIVEN,
97799780
system: Union[str, None, NotGiven] = NOT_GIVEN,
97809781
tools: Union[List[ToolParam], None, NotGiven] = NOT_GIVEN,
@@ -9845,6 +9846,7 @@ def update(
98459846
managed_tool_config: Union[ManagedToolConfigParam, None,
98469847
NotGiven] = NOT_GIVEN,
98479848
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
9849+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
98489850
vaults: Union[Dict[str, ResourceBindingParam], None,
98499851
NotGiven] = NOT_GIVEN,
98509852
files: Union[Dict[str, ResourceBindingParam], None,
@@ -9951,6 +9953,7 @@ async def create(
99519953
name: str,
99529954
model: Union[str, ModelConfigParam],
99539955
environment_id: str,
9956+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
99549957
description: Union[str, None, NotGiven] = NOT_GIVEN,
99559958
system: Union[str, None, NotGiven] = NOT_GIVEN,
99569959
tools: Union[List[ToolParam], None, NotGiven] = NOT_GIVEN,
@@ -10021,6 +10024,7 @@ async def update(
1002110024
managed_tool_config: Union[ManagedToolConfigParam, None,
1002210025
NotGiven] = NOT_GIVEN,
1002310026
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
10027+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
1002410028
vaults: Union[Dict[str, ResourceBindingParam], None,
1002510029
NotGiven] = NOT_GIVEN,
1002610030
files: Union[Dict[str, ResourceBindingParam], None,
@@ -19174,6 +19178,10 @@ class Template(BaseModel)
1917419178

1917519179
#### environment\_id
1917619180

19181+
<a id="qca.forward.types.template.Template.tunnel_id"></a>
19182+
19183+
#### tunnel\_id
19184+
1917719185
<a id="qca.forward.types.template.Template.vaults"></a>
1917819186

1917919187
#### vaults
@@ -19288,6 +19296,10 @@ class TemplateCreateParams(TypedDict)
1928819296

1928919297
#### environment\_id
1929019298

19299+
<a id="qca.forward.types.template_create_params.TemplateCreateParams.tunnel_id"></a>
19300+
19301+
#### tunnel\_id
19302+
1929119303
<a id="qca.forward.types.template_create_params.TemplateCreateParams.description"></a>
1929219304

1929319305
#### description
@@ -19428,6 +19440,10 @@ class TemplateUpdateParams(TypedDict)
1942819440

1942919441
#### environment\_id
1943019442

19443+
<a id="qca.forward.types.template_update_params.TemplateUpdateParams.tunnel_id"></a>
19444+
19445+
#### tunnel\_id
19446+
1943119447
<a id="qca.forward.types.template_update_params.TemplateUpdateParams.vaults"></a>
1943219448

1943319449
#### vaults
@@ -21483,6 +21499,7 @@ def create(
2148321499
*,
2148421500
agent: Union[str, AgentParams],
2148521501
environment_id: str,
21502+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
2148621503
initial_events: List[Union[UserMessageEventParams,
2148721504
UserDefineOutcomeEventParams,
2148821505
SystemMessageEventParams]],
@@ -21548,6 +21565,7 @@ def update(
2154821565
environment_variables: Union[str, None, NotGiven] = NOT_GIVEN,
2154921566
description: Union[str, None, NotGiven] = NOT_GIVEN,
2155021567
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
21568+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
2155121569
name: Union[str, None, NotGiven] = NOT_GIVEN,
2155221570
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
2155321571
metadata: Union[Dict[str, Any], None, NotGiven] = NOT_GIVEN,
@@ -21756,6 +21774,7 @@ async def create(
2175621774
*,
2175721775
agent: Union[str, AgentParams],
2175821776
environment_id: str,
21777+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
2175921778
initial_events: List[Union[UserMessageEventParams,
2176021779
UserDefineOutcomeEventParams,
2176121780
SystemMessageEventParams]],
@@ -21821,6 +21840,7 @@ async def update(
2182121840
environment_variables: Union[str, None, NotGiven] = NOT_GIVEN,
2182221841
description: Union[str, None, NotGiven] = NOT_GIVEN,
2182321842
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
21843+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
2182421844
name: Union[str, None, NotGiven] = NOT_GIVEN,
2182521845
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
2182621846
metadata: Union[Dict[str, Any], None, NotGiven] = NOT_GIVEN,
@@ -24908,6 +24928,7 @@ def create(
2490824928
*,
2490924929
agent: Union[str, AgentParams, AgentWithOverridesParams],
2491024930
environment_id: str,
24931+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
2491124932
environment_variables: Union[Dict[str, str], None,
2491224933
NotGiven] = NOT_GIVEN,
2491324934
title: Union[str, None, NotGiven] = NOT_GIVEN,
@@ -25178,6 +25199,7 @@ async def create(
2517825199
*,
2517925200
agent: Union[str, AgentParams, AgentWithOverridesParams],
2518025201
environment_id: str,
25202+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
2518125203
environment_variables: Union[Dict[str, str], None,
2518225204
NotGiven] = NOT_GIVEN,
2518325205
title: Union[str, None, NotGiven] = NOT_GIVEN,
@@ -28965,6 +28987,10 @@ class Deployment(BaseModel)
2896528987

2896628988
#### environment\_id
2896728989

28990+
<a id="qca.managed.types.deployment.Deployment.tunnel_id"></a>
28991+
28992+
#### tunnel\_id
28993+
2896828994
<a id="qca.managed.types.deployment.Deployment.initial_events"></a>
2896928995

2897028996
#### initial\_events
@@ -29057,6 +29083,10 @@ class DeploymentCreateParams(TypedDict)
2905729083

2905829084
#### environment\_id
2905929085

29086+
<a id="qca.managed.types.deployment_create_params.DeploymentCreateParams.tunnel_id"></a>
29087+
29088+
#### tunnel\_id
29089+
2906029090
<a id="qca.managed.types.deployment_create_params.DeploymentCreateParams.initial_events"></a>
2906129091

2906229092
#### initial\_events
@@ -29633,6 +29663,10 @@ class DeploymentUpdateParams(TypedDict)
2963329663

2963429664
#### environment\_id
2963529665

29666+
<a id="qca.managed.types.deployment_update_params.DeploymentUpdateParams.tunnel_id"></a>
29667+
29668+
#### tunnel\_id
29669+
2963629670
<a id="qca.managed.types.deployment_update_params.DeploymentUpdateParams.name"></a>
2963729671

2963829672
#### name
@@ -34541,6 +34575,10 @@ class SessionCreateParams(TypedDict)
3454134575

3454234576
#### environment\_id
3454334577

34578+
<a id="qca.managed.types.session_create_params.SessionCreateParams.tunnel_id"></a>
34579+
34580+
#### tunnel\_id
34581+
3454434582
<a id="qca.managed.types.session_create_params.SessionCreateParams.title"></a>
3454534583

3454634584
#### title

‎src/qca/forward/resources/templates.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def create(
5353
name: str,
5454
model: Union[str, ModelConfigParam],
5555
environment_id: str,
56+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
5657
description: Union[str, None, NotGiven] = NOT_GIVEN,
5758
system: Union[str, None, NotGiven] = NOT_GIVEN,
5859
tools: Union[List[ToolParam], None, NotGiven] = NOT_GIVEN,
@@ -80,6 +81,7 @@ def create(
8081
"name": name,
8182
"model": model,
8283
"environment_id": environment_id,
84+
"tunnel_id": tunnel_id,
8385
"description": description,
8486
"system": system,
8587
"tools": tools,
@@ -140,6 +142,7 @@ def update(
140142
max_tool_rounds: Union[int, None, NotGiven] = NOT_GIVEN,
141143
managed_tool_config: Union[ManagedToolConfigParam, None, NotGiven] = NOT_GIVEN,
142144
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
145+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
143146
vaults: Union[Dict[str, ResourceBindingParam], None, NotGiven] = NOT_GIVEN,
144147
files: Union[Dict[str, ResourceBindingParam], None, NotGiven] = NOT_GIVEN,
145148
github_repositories: Union[Dict[str, GitHubRepositoryParam], None, NotGiven] = NOT_GIVEN,
@@ -167,6 +170,7 @@ def update(
167170
"max_tool_rounds": max_tool_rounds,
168171
"managed_tool_config": managed_tool_config,
169172
"environment_id": environment_id,
173+
"tunnel_id": tunnel_id,
170174
"vaults": vaults,
171175
"files": files,
172176
"github_repositories": github_repositories,
@@ -265,6 +269,7 @@ async def create(
265269
name: str,
266270
model: Union[str, ModelConfigParam],
267271
environment_id: str,
272+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
268273
description: Union[str, None, NotGiven] = NOT_GIVEN,
269274
system: Union[str, None, NotGiven] = NOT_GIVEN,
270275
tools: Union[List[ToolParam], None, NotGiven] = NOT_GIVEN,
@@ -292,6 +297,7 @@ async def create(
292297
"name": name,
293298
"model": model,
294299
"environment_id": environment_id,
300+
"tunnel_id": tunnel_id,
295301
"description": description,
296302
"system": system,
297303
"tools": tools,
@@ -352,6 +358,7 @@ async def update(
352358
max_tool_rounds: Union[int, None, NotGiven] = NOT_GIVEN,
353359
managed_tool_config: Union[ManagedToolConfigParam, None, NotGiven] = NOT_GIVEN,
354360
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
361+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
355362
vaults: Union[Dict[str, ResourceBindingParam], None, NotGiven] = NOT_GIVEN,
356363
files: Union[Dict[str, ResourceBindingParam], None, NotGiven] = NOT_GIVEN,
357364
github_repositories: Union[Dict[str, GitHubRepositoryParam], None, NotGiven] = NOT_GIVEN,
@@ -379,6 +386,7 @@ async def update(
379386
"max_tool_rounds": max_tool_rounds,
380387
"managed_tool_config": managed_tool_config,
381388
"environment_id": environment_id,
389+
"tunnel_id": tunnel_id,
382390
"vaults": vaults,
383391
"files": files,
384392
"github_repositories": github_repositories,

‎src/qca/forward/types/template.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Template(BaseModel):
3131
model: Optional[Union[str, ModelConfig]] = None
3232
multiagent: Optional[MultiagentConfig] = None
3333
environment_id: Optional[str] = None
34+
tunnel_id: Optional[str] = None
3435
vaults: Optional[Dict[str, ResourceBinding]] = None
3536
files: Optional[Dict[str, ResourceBinding]] = None
3637
github_repositories: Optional[Dict[str, GitHubRepository]] = None

‎src/qca/forward/types/template_create_params.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TemplateCreateParams(TypedDict, total=False):
2323
name: Required[str]
2424
model: Required[Union[str, ModelConfigParam]]
2525
environment_id: Required[str]
26+
tunnel_id: str
2627
description: Optional[str]
2728
system: Optional[str]
2829
tools: List[ToolParam]

‎src/qca/forward/types/template_update_params.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class TemplateUpdateParams(TypedDict, total=False):
2929
skills: List[SkillBindingParam]
3030
multiagent: MultiagentConfigParam
3131
environment_id: Optional[str]
32+
tunnel_id: Optional[str]
3233
vaults: Dict[str, ResourceBindingParam]
3334
files: Dict[str, ResourceBindingParam]
3435
github_repositories: Dict[str, GitHubRepositoryParam]

‎src/qca/managed/resources/deployments.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def create(
3737
*,
3838
agent: Union[str, AgentParams],
3939
environment_id: str,
40+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
4041
initial_events: List[Union[UserMessageEventParams, UserDefineOutcomeEventParams, SystemMessageEventParams]],
4142
name: str,
4243
environment_variables: Union[str, None, NotGiven] = NOT_GIVEN,
@@ -71,6 +72,7 @@ def create(
7172
"environment_variables": environment_variables,
7273
"agent": agent,
7374
"environment_id": environment_id,
75+
"tunnel_id": tunnel_id,
7476
"initial_events": initial_events,
7577
"name": name,
7678
"description": description,
@@ -120,6 +122,7 @@ def update(
120122
environment_variables: Union[str, None, NotGiven] = NOT_GIVEN,
121123
description: Union[str, None, NotGiven] = NOT_GIVEN,
122124
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
125+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
123126
name: Union[str, None, NotGiven] = NOT_GIVEN,
124127
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
125128
metadata: Union[Dict[str, Any], None, NotGiven] = NOT_GIVEN,
@@ -155,6 +158,7 @@ def update(
155158
"environment_variables": environment_variables,
156159
"description": description,
157160
"environment_id": environment_id,
161+
"tunnel_id": tunnel_id,
158162
"name": name,
159163
"metadata": metadata,
160164
"resources": resources,
@@ -370,6 +374,7 @@ async def create(
370374
*,
371375
agent: Union[str, AgentParams],
372376
environment_id: str,
377+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
373378
initial_events: List[Union[UserMessageEventParams, UserDefineOutcomeEventParams, SystemMessageEventParams]],
374379
name: str,
375380
environment_variables: Union[str, None, NotGiven] = NOT_GIVEN,
@@ -404,6 +409,7 @@ async def create(
404409
"environment_variables": environment_variables,
405410
"agent": agent,
406411
"environment_id": environment_id,
412+
"tunnel_id": tunnel_id,
407413
"initial_events": initial_events,
408414
"name": name,
409415
"description": description,
@@ -453,6 +459,7 @@ async def update(
453459
environment_variables: Union[str, None, NotGiven] = NOT_GIVEN,
454460
description: Union[str, None, NotGiven] = NOT_GIVEN,
455461
environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
462+
tunnel_id: Union[str, None, NotGiven] = NOT_GIVEN,
456463
name: Union[str, None, NotGiven] = NOT_GIVEN,
457464
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
458465
metadata: Union[Dict[str, Any], None, NotGiven] = NOT_GIVEN,
@@ -488,6 +495,7 @@ async def update(
488495
"environment_variables": environment_variables,
489496
"description": description,
490497
"environment_id": environment_id,
498+
"tunnel_id": tunnel_id,
491499
"name": name,
492500
"metadata": metadata,
493501
"resources": resources,

‎src/qca/managed/resources/sessions/sessions.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def create(
7676
*,
7777
agent: Union[str, AgentParams, AgentWithOverridesParams],
7878
environment_id: str,
79+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
7980
environment_variables: Union[Dict[str, str], None, NotGiven] = NOT_GIVEN,
8081
title: Union[str, None, NotGiven] = NOT_GIVEN,
8182
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
@@ -110,6 +111,7 @@ def create(
110111
"environment_variables": environment_variables,
111112
"agent": agent,
112113
"environment_id": environment_id,
114+
"tunnel_id": tunnel_id,
113115
"title": title,
114116
"budget": budget,
115117
"initial_events": initial_events,
@@ -394,6 +396,7 @@ async def create(
394396
*,
395397
agent: Union[str, AgentParams, AgentWithOverridesParams],
396398
environment_id: str,
399+
tunnel_id: Union[str, NotGiven] = NOT_GIVEN,
397400
environment_variables: Union[Dict[str, str], None, NotGiven] = NOT_GIVEN,
398401
title: Union[str, None, NotGiven] = NOT_GIVEN,
399402
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
@@ -428,6 +431,7 @@ async def create(
428431
"environment_variables": environment_variables,
429432
"agent": agent,
430433
"environment_id": environment_id,
434+
"tunnel_id": tunnel_id,
431435
"title": title,
432436
"budget": budget,
433437
"initial_events": initial_events,

‎src/qca/managed/types/deployment.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Deployment(BaseModel):
2424
created_at: Optional[datetime] = None
2525
description: Optional[str] = None
2626
environment_id: Optional[str] = None
27+
tunnel_id: Optional[str] = None
2728
initial_events: Optional[List[DeploymentInitialEventUnion]] = None
2829
metadata: Optional[Dict[str, str]] = None
2930
name: Optional[str] = None

‎src/qca/managed/types/deployment_create_params.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DeploymentCreateParams(TypedDict, total=False):
2323
environment_variables: Optional[str]
2424
agent: Required[Union[str, AgentParams]]
2525
environment_id: Required[str]
26+
tunnel_id: str
2627
initial_events: Required[
2728
List[Union[UserMessageEventParams, UserDefineOutcomeEventParams, SystemMessageEventParams]]
2829
]

0 commit comments

Comments
 (0)