agent-framework-github-copilot 1.0.0__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.
- agent_framework_github_copilot-1.0.0/LICENSE +21 -0
- agent_framework_github_copilot-1.0.0/PKG-INFO +87 -0
- agent_framework_github_copilot-1.0.0/README.md +61 -0
- agent_framework_github_copilot-1.0.0/agent_framework_github_copilot/__init__.py +18 -0
- agent_framework_github_copilot-1.0.0/agent_framework_github_copilot/_agent.py +1364 -0
- agent_framework_github_copilot-1.0.0/pyproject.toml +104 -0
|
@@ -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,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-framework-github-copilot
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: GitHub Copilot integration 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 :: 5 - Production/Stable
|
|
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: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: agent-framework-core>=1.11.0,<2
|
|
20
|
+
Requires-Dist: github-copilot-sdk==1.0.2; python_version >= '3.11'
|
|
21
|
+
Project-URL: homepage, https://aka.ms/agent-framework
|
|
22
|
+
Project-URL: issues, https://github.com/microsoft/agent-framework/issues
|
|
23
|
+
Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
|
|
24
|
+
Project-URL: source, https://github.com/microsoft/agent-framework/tree/main/python
|
|
25
|
+
|
|
26
|
+
# Get Started with Microsoft Agent Framework GitHub Copilot
|
|
27
|
+
|
|
28
|
+
Please install this package via pip:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install agent-framework-github-copilot
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## GitHub Copilot Agent
|
|
35
|
+
|
|
36
|
+
The GitHub Copilot agent enables integration with GitHub Copilot, allowing you to interact with Copilot's agentic capabilities through the Agent Framework.
|
|
37
|
+
|
|
38
|
+
## Tool approval (`approval_mode="always_require"`)
|
|
39
|
+
|
|
40
|
+
The GitHub Copilot SDK owns the tool-calling loop for this provider, so approval for
|
|
41
|
+
custom function tools is enforced through the SDK's native pre-execution hook rather
|
|
42
|
+
than the standard Agent Framework approval round-trip.
|
|
43
|
+
|
|
44
|
+
When you register a `FunctionTool` declared with `approval_mode="always_require"` and you
|
|
45
|
+
do **not** supply your own `on_pre_tool_use` hook, `GitHubCopilotAgent` installs a default
|
|
46
|
+
`on_pre_tool_use` hook that returns `"ask"` for that tool and defers (`None`) for all other
|
|
47
|
+
tools. The `"ask"` decision routes to your `on_permission_request` handler, where you
|
|
48
|
+
approve or deny the call:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from agent_framework import tool
|
|
52
|
+
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
|
|
53
|
+
from copilot.session import PermissionHandler
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@tool(approval_mode="always_require")
|
|
57
|
+
def delete_file(path: str) -> str:
|
|
58
|
+
"""Delete a file."""
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
agent = GitHubCopilotAgent(
|
|
63
|
+
tools=[delete_file],
|
|
64
|
+
# The "ask" decision is routed here; approve or deny the call.
|
|
65
|
+
default_options=GitHubCopilotOptions(on_permission_request=PermissionHandler.approve_all),
|
|
66
|
+
)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> **⚠️ If you provide your own `on_pre_tool_use` hook**, it takes precedence and the agent
|
|
70
|
+
> does **not** install its default approval hook. In that case **you are fully responsible**
|
|
71
|
+
> for enforcing approval — including for any `approval_mode="always_require"` tool (e.g. by
|
|
72
|
+
> returning a `"deny"` or `"ask"` decision). The agent logs a warning naming any
|
|
73
|
+
> approval-required tool that your hook must handle.
|
|
74
|
+
>
|
|
75
|
+
> Note: with the default (deny-all) permission handler, an `always_require` tool is denied
|
|
76
|
+
> unless you wire an approving `on_permission_request`.
|
|
77
|
+
|
|
78
|
+
### Deprecated: `on_function_approval`
|
|
79
|
+
|
|
80
|
+
The `on_function_approval` callback is **deprecated**. It still works (and is still enforced
|
|
81
|
+
inside the tool handler for backward compatibility), but it emits a `DeprecationWarning` and
|
|
82
|
+
will be removed in a future version. Migrate to the `on_pre_tool_use` + `on_permission_request`
|
|
83
|
+
model described above. When `on_function_approval` is set, it gates `always_require` tools and
|
|
84
|
+
the default ask-hook is not installed. It is **mutually exclusive** with `on_pre_tool_use` —
|
|
85
|
+
setting both (whether at construction or per run) raises `ValueError`.
|
|
86
|
+
|
|
87
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Get Started with Microsoft Agent Framework GitHub Copilot
|
|
2
|
+
|
|
3
|
+
Please install this package via pip:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install agent-framework-github-copilot
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## GitHub Copilot Agent
|
|
10
|
+
|
|
11
|
+
The GitHub Copilot agent enables integration with GitHub Copilot, allowing you to interact with Copilot's agentic capabilities through the Agent Framework.
|
|
12
|
+
|
|
13
|
+
## Tool approval (`approval_mode="always_require"`)
|
|
14
|
+
|
|
15
|
+
The GitHub Copilot SDK owns the tool-calling loop for this provider, so approval for
|
|
16
|
+
custom function tools is enforced through the SDK's native pre-execution hook rather
|
|
17
|
+
than the standard Agent Framework approval round-trip.
|
|
18
|
+
|
|
19
|
+
When you register a `FunctionTool` declared with `approval_mode="always_require"` and you
|
|
20
|
+
do **not** supply your own `on_pre_tool_use` hook, `GitHubCopilotAgent` installs a default
|
|
21
|
+
`on_pre_tool_use` hook that returns `"ask"` for that tool and defers (`None`) for all other
|
|
22
|
+
tools. The `"ask"` decision routes to your `on_permission_request` handler, where you
|
|
23
|
+
approve or deny the call:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from agent_framework import tool
|
|
27
|
+
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
|
|
28
|
+
from copilot.session import PermissionHandler
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@tool(approval_mode="always_require")
|
|
32
|
+
def delete_file(path: str) -> str:
|
|
33
|
+
"""Delete a file."""
|
|
34
|
+
...
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
agent = GitHubCopilotAgent(
|
|
38
|
+
tools=[delete_file],
|
|
39
|
+
# The "ask" decision is routed here; approve or deny the call.
|
|
40
|
+
default_options=GitHubCopilotOptions(on_permission_request=PermissionHandler.approve_all),
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> **⚠️ If you provide your own `on_pre_tool_use` hook**, it takes precedence and the agent
|
|
45
|
+
> does **not** install its default approval hook. In that case **you are fully responsible**
|
|
46
|
+
> for enforcing approval — including for any `approval_mode="always_require"` tool (e.g. by
|
|
47
|
+
> returning a `"deny"` or `"ask"` decision). The agent logs a warning naming any
|
|
48
|
+
> approval-required tool that your hook must handle.
|
|
49
|
+
>
|
|
50
|
+
> Note: with the default (deny-all) permission handler, an `always_require` tool is denied
|
|
51
|
+
> unless you wire an approving `on_permission_request`.
|
|
52
|
+
|
|
53
|
+
### Deprecated: `on_function_approval`
|
|
54
|
+
|
|
55
|
+
The `on_function_approval` callback is **deprecated**. It still works (and is still enforced
|
|
56
|
+
inside the tool handler for backward compatibility), but it emits a `DeprecationWarning` and
|
|
57
|
+
will be removed in a future version. Migrate to the `on_pre_tool_use` + `on_permission_request`
|
|
58
|
+
model described above. When `on_function_approval` is set, it gates `always_require` tools and
|
|
59
|
+
the default ask-hook is not installed. It is **mutually exclusive** with `on_pre_tool_use` —
|
|
60
|
+
setting both (whether at construction or per run) raises `ValueError`.
|
|
61
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import importlib.metadata
|
|
4
|
+
|
|
5
|
+
from ._agent import GitHubCopilotAgent, GitHubCopilotOptions, GitHubCopilotSettings, RawGitHubCopilotAgent
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
__version__ = importlib.metadata.version(__name__)
|
|
9
|
+
except importlib.metadata.PackageNotFoundError:
|
|
10
|
+
__version__ = "0.0.0"
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"GitHubCopilotAgent",
|
|
14
|
+
"GitHubCopilotOptions",
|
|
15
|
+
"GitHubCopilotSettings",
|
|
16
|
+
"RawGitHubCopilotAgent",
|
|
17
|
+
"__version__",
|
|
18
|
+
]
|