agent-framework-hyperlight 1.0.0a260421__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-framework-hyperlight
3
+ Version: 1.0.0a260421
4
+ Summary: Hyperlight CodeAct integrations for Microsoft Agent Framework.
5
+ Author-email: Microsoft <af-support@microsoft.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Typing :: Typed
17
+ License-File: LICENSE
18
+ Requires-Dist: agent-framework-core>=1.1.0,<2
19
+ Requires-Dist: hyperlight-sandbox>=0.3.0,<0.4
20
+ Requires-Dist: hyperlight-sandbox-backend-wasm>=0.3.0,<0.4 ; ((sys_platform == 'linux' and platform_machine == 'x86_64') or (sys_platform == 'win32' and platform_machine == 'AMD64')) and python_version < '3.14'
21
+ Requires-Dist: hyperlight-sandbox-python-guest>=0.3.0,<0.4
22
+ Project-URL: homepage, https://aka.ms/agent-framework
23
+ Project-URL: issues, https://github.com/microsoft/agent-framework/issues
24
+ Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
25
+ Project-URL: source, https://github.com/microsoft/agent-framework/tree/main/python
26
+
27
+ # agent-framework-hyperlight
28
+
29
+ Alpha Hyperlight-backed CodeAct integrations for Microsoft Agent Framework.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install agent-framework-hyperlight --pre
35
+ ```
36
+
37
+ This package depends on `hyperlight-sandbox`, the packaged Python guest, and the
38
+ Wasm backend package on supported platforms. If the backend is not published for
39
+ your current platform yet, `execute_code` will fail at runtime when it tries to
40
+ create the sandbox.
41
+
42
+ ## Quick start
43
+
44
+ ### Context provider (recommended)
45
+
46
+ Use `HyperlightCodeActProvider` to automatically inject the `execute_code` tool
47
+ and CodeAct instructions into every agent run. Tools registered on the provider
48
+ are available inside the sandbox via `call_tool(...)` but are **not** exposed as
49
+ direct agent tools.
50
+
51
+ ```python
52
+ from agent_framework import Agent, tool
53
+ from agent_framework_hyperlight import HyperlightCodeActProvider
54
+
55
+ @tool
56
+ def compute(operation: str, a: float, b: float) -> float:
57
+ """Perform a math operation."""
58
+ ops = {"add": a + b, "subtract": a - b, "multiply": a * b, "divide": a / b}
59
+ return ops[operation]
60
+
61
+ codeact = HyperlightCodeActProvider(
62
+ tools=[compute],
63
+ approval_mode="never_require",
64
+ )
65
+
66
+ agent = Agent(
67
+ client=client,
68
+ name="CodeActAgent",
69
+ instructions="You are a helpful assistant.",
70
+ context_providers=[codeact],
71
+ )
72
+
73
+ result = await agent.run("Multiply 6 by 7 using execute_code.")
74
+ ```
75
+
76
+ ### Standalone tool
77
+
78
+ Use `HyperlightExecuteCodeTool` directly when you want full control over how the
79
+ tool is added to the agent. This is useful when mixing sandbox tools with
80
+ direct-only tools on the same agent.
81
+
82
+ ```python
83
+ from agent_framework import Agent, tool
84
+ from agent_framework_hyperlight import HyperlightExecuteCodeTool
85
+
86
+ @tool
87
+ def send_email(to: str, subject: str, body: str) -> str:
88
+ """Send an email (direct-only, not available inside the sandbox)."""
89
+ return f"Email sent to {to}"
90
+
91
+ execute_code = HyperlightExecuteCodeTool(
92
+ tools=[compute],
93
+ approval_mode="never_require",
94
+ )
95
+
96
+ agent = Agent(
97
+ client=client,
98
+ name="MixedToolsAgent",
99
+ instructions="You are a helpful assistant.",
100
+ tools=[send_email, execute_code],
101
+ )
102
+ ```
103
+
104
+ ### Manual static wiring
105
+
106
+ For fixed configurations where provider lifecycle overhead is unnecessary, build
107
+ the CodeAct instructions once and pass them to the agent at construction time:
108
+
109
+ ```python
110
+ execute_code = HyperlightExecuteCodeTool(
111
+ tools=[compute],
112
+ approval_mode="never_require",
113
+ )
114
+
115
+ codeact_instructions = execute_code.build_instructions(tools_visible_to_model=False)
116
+
117
+ agent = Agent(
118
+ client=client,
119
+ name="StaticWiringAgent",
120
+ instructions=f"You are a helpful assistant.\n\n{codeact_instructions}",
121
+ tools=[execute_code],
122
+ )
123
+ ```
124
+
125
+ ### File mounts and network access
126
+
127
+ Mount host directories into the sandbox and allow outbound HTTP to specific
128
+ domains:
129
+
130
+ ```python
131
+ from agent_framework_hyperlight import HyperlightCodeActProvider, FileMount
132
+
133
+ codeact = HyperlightCodeActProvider(
134
+ tools=[compute],
135
+ file_mounts=[
136
+ "/host/data", # shorthand — same path in sandbox
137
+ ("/host/models", "/sandbox/models"), # explicit host → sandbox mapping
138
+ FileMount("/host/config", "/sandbox/config"), # named tuple
139
+ ],
140
+ allowed_domains=[
141
+ "api.github.com", # all methods
142
+ ("internal.api.example.com", "GET"), # GET only
143
+ ],
144
+ )
145
+ ```
146
+
147
+ ## Notes
148
+
149
+ - This package is intentionally separate from `agent-framework-core` so CodeAct
150
+ usage and installation remain optional.
151
+ - Alpha-package samples live under `packages/hyperlight/samples/`.
152
+ - `file_mounts` accepts a single string shorthand, an explicit `(host_path,
153
+ mount_path)` pair, or a `FileMount` named tuple. The host-side path in the
154
+ explicit forms may be a `str` or `Path`. Use the explicit two-value form when
155
+ the host path differs from the sandbox path.
156
+ - `allowed_domains` accepts a single string target such as `"github.com"` to
157
+ allow all backend-supported methods, an explicit `(target, method_or_methods)`
158
+ tuple such as `("github.com", "GET")`, or an `AllowedDomain` named tuple.
159
+
@@ -0,0 +1,132 @@
1
+ # agent-framework-hyperlight
2
+
3
+ Alpha Hyperlight-backed CodeAct integrations for Microsoft Agent Framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install agent-framework-hyperlight --pre
9
+ ```
10
+
11
+ This package depends on `hyperlight-sandbox`, the packaged Python guest, and the
12
+ Wasm backend package on supported platforms. If the backend is not published for
13
+ your current platform yet, `execute_code` will fail at runtime when it tries to
14
+ create the sandbox.
15
+
16
+ ## Quick start
17
+
18
+ ### Context provider (recommended)
19
+
20
+ Use `HyperlightCodeActProvider` to automatically inject the `execute_code` tool
21
+ and CodeAct instructions into every agent run. Tools registered on the provider
22
+ are available inside the sandbox via `call_tool(...)` but are **not** exposed as
23
+ direct agent tools.
24
+
25
+ ```python
26
+ from agent_framework import Agent, tool
27
+ from agent_framework_hyperlight import HyperlightCodeActProvider
28
+
29
+ @tool
30
+ def compute(operation: str, a: float, b: float) -> float:
31
+ """Perform a math operation."""
32
+ ops = {"add": a + b, "subtract": a - b, "multiply": a * b, "divide": a / b}
33
+ return ops[operation]
34
+
35
+ codeact = HyperlightCodeActProvider(
36
+ tools=[compute],
37
+ approval_mode="never_require",
38
+ )
39
+
40
+ agent = Agent(
41
+ client=client,
42
+ name="CodeActAgent",
43
+ instructions="You are a helpful assistant.",
44
+ context_providers=[codeact],
45
+ )
46
+
47
+ result = await agent.run("Multiply 6 by 7 using execute_code.")
48
+ ```
49
+
50
+ ### Standalone tool
51
+
52
+ Use `HyperlightExecuteCodeTool` directly when you want full control over how the
53
+ tool is added to the agent. This is useful when mixing sandbox tools with
54
+ direct-only tools on the same agent.
55
+
56
+ ```python
57
+ from agent_framework import Agent, tool
58
+ from agent_framework_hyperlight import HyperlightExecuteCodeTool
59
+
60
+ @tool
61
+ def send_email(to: str, subject: str, body: str) -> str:
62
+ """Send an email (direct-only, not available inside the sandbox)."""
63
+ return f"Email sent to {to}"
64
+
65
+ execute_code = HyperlightExecuteCodeTool(
66
+ tools=[compute],
67
+ approval_mode="never_require",
68
+ )
69
+
70
+ agent = Agent(
71
+ client=client,
72
+ name="MixedToolsAgent",
73
+ instructions="You are a helpful assistant.",
74
+ tools=[send_email, execute_code],
75
+ )
76
+ ```
77
+
78
+ ### Manual static wiring
79
+
80
+ For fixed configurations where provider lifecycle overhead is unnecessary, build
81
+ the CodeAct instructions once and pass them to the agent at construction time:
82
+
83
+ ```python
84
+ execute_code = HyperlightExecuteCodeTool(
85
+ tools=[compute],
86
+ approval_mode="never_require",
87
+ )
88
+
89
+ codeact_instructions = execute_code.build_instructions(tools_visible_to_model=False)
90
+
91
+ agent = Agent(
92
+ client=client,
93
+ name="StaticWiringAgent",
94
+ instructions=f"You are a helpful assistant.\n\n{codeact_instructions}",
95
+ tools=[execute_code],
96
+ )
97
+ ```
98
+
99
+ ### File mounts and network access
100
+
101
+ Mount host directories into the sandbox and allow outbound HTTP to specific
102
+ domains:
103
+
104
+ ```python
105
+ from agent_framework_hyperlight import HyperlightCodeActProvider, FileMount
106
+
107
+ codeact = HyperlightCodeActProvider(
108
+ tools=[compute],
109
+ file_mounts=[
110
+ "/host/data", # shorthand — same path in sandbox
111
+ ("/host/models", "/sandbox/models"), # explicit host → sandbox mapping
112
+ FileMount("/host/config", "/sandbox/config"), # named tuple
113
+ ],
114
+ allowed_domains=[
115
+ "api.github.com", # all methods
116
+ ("internal.api.example.com", "GET"), # GET only
117
+ ],
118
+ )
119
+ ```
120
+
121
+ ## Notes
122
+
123
+ - This package is intentionally separate from `agent-framework-core` so CodeAct
124
+ usage and installation remain optional.
125
+ - Alpha-package samples live under `packages/hyperlight/samples/`.
126
+ - `file_mounts` accepts a single string shorthand, an explicit `(host_path,
127
+ mount_path)` pair, or a `FileMount` named tuple. The host-side path in the
128
+ explicit forms may be a `str` or `Path`. Use the explicit two-value form when
129
+ the host path differs from the sandbox path.
130
+ - `allowed_domains` accepts a single string target such as `"github.com"` to
131
+ allow all backend-supported methods, an explicit `(target, method_or_methods)`
132
+ tuple such as `("github.com", "GET")`, or an `AllowedDomain` named tuple.
@@ -0,0 +1,24 @@
1
+ # Copyright (c) Microsoft. All rights reserved.
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.metadata
6
+
7
+ from ._execute_code_tool import HyperlightExecuteCodeTool
8
+ from ._provider import HyperlightCodeActProvider
9
+ from ._types import AllowedDomain, AllowedDomainInput, FileMount, FileMountInput
10
+
11
+ try:
12
+ __version__ = importlib.metadata.version(__name__)
13
+ except importlib.metadata.PackageNotFoundError:
14
+ __version__ = "0.0.0"
15
+
16
+ __all__ = [
17
+ "AllowedDomain",
18
+ "AllowedDomainInput",
19
+ "FileMount",
20
+ "FileMountInput",
21
+ "HyperlightCodeActProvider",
22
+ "HyperlightExecuteCodeTool",
23
+ "__version__",
24
+ ]