agent-roster 0.1.0__py3-none-any.whl

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,133 @@
1
+ """agent-roster: supported coding agents, launch plans, and per-agent ACP behavior."""
2
+
3
+ from agent_roster.acp_session import (
4
+ ConfigOption,
5
+ apply_session_settings,
6
+ check_offered,
7
+ )
8
+ from agent_roster.agents import (
9
+ AgyDefinition,
10
+ AgyOptions,
11
+ ClaudeCodeDefinition,
12
+ ClaudeCodeOptions,
13
+ ClineDefinition,
14
+ ClineOptions,
15
+ CodexDefinition,
16
+ CodexOptions,
17
+ CopilotDefinition,
18
+ CopilotOptions,
19
+ CursorDefinition,
20
+ CursorOptions,
21
+ OpencodeDefinition,
22
+ OpencodeOptions,
23
+ )
24
+ from agent_roster.definitions import (
25
+ PACKAGE_RUNNERS,
26
+ AgentDefinition,
27
+ AgentOptions,
28
+ Delivery,
29
+ LaunchFile,
30
+ LaunchFlag,
31
+ SafeToken,
32
+ SessionSetting,
33
+ SettingString,
34
+ SettingValue,
35
+ reject_package_runner,
36
+ )
37
+ from agent_roster.errors import (
38
+ DefinitionError,
39
+ InvalidRequestError,
40
+ LaunchFileError,
41
+ RosterError,
42
+ SessionError,
43
+ UnknownAgentError,
44
+ UnsupportedOperationError,
45
+ )
46
+ from agent_roster.launch import (
47
+ LaunchPlan,
48
+ choice_name,
49
+ describe_choices,
50
+ describe_launch,
51
+ describe_options,
52
+ fit_launch,
53
+ launch_differences,
54
+ launch_mismatch,
55
+ plan_launch,
56
+ )
57
+ from agent_roster.launch_files import write_launch_files
58
+ from agent_roster.permissions import (
59
+ Allow,
60
+ Decision,
61
+ Deny,
62
+ PermissionOption,
63
+ PermissionRequest,
64
+ Policy,
65
+ Unknown,
66
+ UnknownCause,
67
+ allow_kinds,
68
+ compose_policies,
69
+ reply_permission,
70
+ )
71
+ from agent_roster.roster import BUILTIN_ROSTER, BuiltinRoster, Roster
72
+
73
+ __all__ = [
74
+ "BUILTIN_ROSTER",
75
+ "PACKAGE_RUNNERS",
76
+ "AgentDefinition",
77
+ "AgentOptions",
78
+ "AgyDefinition",
79
+ "AgyOptions",
80
+ "Allow",
81
+ "BuiltinRoster",
82
+ "ClaudeCodeDefinition",
83
+ "ClaudeCodeOptions",
84
+ "ClineDefinition",
85
+ "ClineOptions",
86
+ "CodexDefinition",
87
+ "CodexOptions",
88
+ "ConfigOption",
89
+ "CopilotDefinition",
90
+ "CopilotOptions",
91
+ "CursorDefinition",
92
+ "CursorOptions",
93
+ "Decision",
94
+ "DefinitionError",
95
+ "Delivery",
96
+ "Deny",
97
+ "InvalidRequestError",
98
+ "LaunchFile",
99
+ "LaunchFileError",
100
+ "LaunchFlag",
101
+ "LaunchPlan",
102
+ "OpencodeDefinition",
103
+ "OpencodeOptions",
104
+ "PermissionOption",
105
+ "PermissionRequest",
106
+ "Policy",
107
+ "Roster",
108
+ "RosterError",
109
+ "SafeToken",
110
+ "SessionError",
111
+ "SessionSetting",
112
+ "SettingString",
113
+ "SettingValue",
114
+ "Unknown",
115
+ "UnknownAgentError",
116
+ "UnknownCause",
117
+ "UnsupportedOperationError",
118
+ "allow_kinds",
119
+ "apply_session_settings",
120
+ "check_offered",
121
+ "choice_name",
122
+ "compose_policies",
123
+ "describe_choices",
124
+ "describe_launch",
125
+ "describe_options",
126
+ "fit_launch",
127
+ "launch_differences",
128
+ "launch_mismatch",
129
+ "plan_launch",
130
+ "reject_package_runner",
131
+ "reply_permission",
132
+ "write_launch_files",
133
+ ]
@@ -0,0 +1,96 @@
1
+ """ACP session configuration helpers over a consumer-supplied connection."""
2
+
3
+ from collections.abc import Sequence
4
+ from typing import Any
5
+
6
+ from acp import schema
7
+
8
+ from agent_roster.definitions import SettingValue
9
+ from agent_roster.errors import SessionError
10
+ from agent_roster.launch import LaunchPlan
11
+
12
+ MAX_OFFERED_VALUES = 20
13
+ MAX_OFFERED_VALUE_CHARS = 80
14
+
15
+ ConfigOption = schema.SessionConfigOptionSelect | schema.SessionConfigOptionBoolean
16
+
17
+
18
+ def _advertised(
19
+ options: Sequence[ConfigOption] | None,
20
+ ) -> dict[str, set[SettingValue] | type[bool]]:
21
+ advertised: dict[str, set[SettingValue] | type[bool]] = {}
22
+ for option in options or ():
23
+ if isinstance(option, schema.SessionConfigOptionBoolean):
24
+ advertised[option.id] = bool
25
+ continue
26
+ values: set[SettingValue] = set()
27
+ for entry in option.options:
28
+ if isinstance(entry, schema.SessionConfigSelectGroup):
29
+ values.update(item.value for item in entry.options)
30
+ else:
31
+ values.add(entry.value)
32
+ advertised[option.id] = values
33
+ return advertised
34
+
35
+
36
+ def check_offered(
37
+ config_options: Sequence[ConfigOption] | None,
38
+ setting: str,
39
+ value: SettingValue,
40
+ agent: str,
41
+ ) -> None:
42
+ """Refuse a setting value the offer in ``config_options`` does not contain."""
43
+ _check(_advertised(config_options), setting, value, agent)
44
+
45
+
46
+ def _check(
47
+ advertised: dict[str, set[SettingValue] | type[bool]],
48
+ setting: str,
49
+ value: SettingValue,
50
+ agent: str,
51
+ ) -> None:
52
+ allowed = advertised.get(setting)
53
+ if allowed is None:
54
+ raise SessionError(f"{agent} does not offer the session setting {setting!r}")
55
+ if allowed is bool:
56
+ if not isinstance(value, bool):
57
+ raise SessionError(f"{agent} expects true or false for {setting!r}")
58
+ elif value not in allowed:
59
+ offered = sorted(allowed, key=str)
60
+ shown = offered[:MAX_OFFERED_VALUES]
61
+ values = ", ".join(
62
+ repr(
63
+ option[: MAX_OFFERED_VALUE_CHARS - 1] + "…"
64
+ if isinstance(option, str) and len(option) > MAX_OFFERED_VALUE_CHARS
65
+ else option
66
+ )
67
+ for option in shown
68
+ )
69
+ remaining = len(offered) - len(shown)
70
+ suffix = f" ({remaining} more)" if remaining else ""
71
+ raise SessionError(
72
+ f"{agent} does not offer {setting}={value!r}; offered values: {values}{suffix}"
73
+ )
74
+
75
+
76
+ async def apply_session_settings(
77
+ conn: Any,
78
+ session_id: str,
79
+ plan: LaunchPlan,
80
+ agent: str,
81
+ config_options: Sequence[ConfigOption] | None,
82
+ ) -> Sequence[ConfigOption] | None:
83
+ """Check and apply ``plan``'s pinned and requested session settings over ``conn``."""
84
+ latest = config_options
85
+ advertised = _advertised(latest)
86
+ to_apply = (*plan.pins, *plan.session_settings)
87
+ for setting, value in to_apply:
88
+ _check(advertised, setting, value, agent)
89
+ for setting, value in to_apply:
90
+ changed = await conn.set_config_option(
91
+ config_id=setting, session_id=session_id, value=value
92
+ )
93
+ reported = getattr(changed, "config_options", None)
94
+ if reported:
95
+ latest = reported
96
+ return latest
@@ -0,0 +1,26 @@
1
+ """Built-in agent definitions."""
2
+
3
+ from agent_roster.agents.agy import AgyDefinition, AgyOptions
4
+ from agent_roster.agents.claude_code import ClaudeCodeDefinition, ClaudeCodeOptions
5
+ from agent_roster.agents.cline import ClineDefinition, ClineOptions
6
+ from agent_roster.agents.codex import CodexDefinition, CodexOptions
7
+ from agent_roster.agents.copilot import CopilotDefinition, CopilotOptions
8
+ from agent_roster.agents.cursor import CursorDefinition, CursorOptions
9
+ from agent_roster.agents.opencode import OpencodeDefinition, OpencodeOptions
10
+
11
+ __all__ = [
12
+ "AgyDefinition",
13
+ "AgyOptions",
14
+ "ClaudeCodeDefinition",
15
+ "ClaudeCodeOptions",
16
+ "ClineDefinition",
17
+ "ClineOptions",
18
+ "CodexDefinition",
19
+ "CodexOptions",
20
+ "CopilotDefinition",
21
+ "CopilotOptions",
22
+ "CursorDefinition",
23
+ "CursorOptions",
24
+ "OpencodeDefinition",
25
+ "OpencodeOptions",
26
+ ]
@@ -0,0 +1,67 @@
1
+ """Google Antigravity CLI over ACP (``agy acp --cli_dir_name <client_name>``)."""
2
+
3
+ import json
4
+ import os
5
+ from collections.abc import Mapping
6
+ from pathlib import Path
7
+ from types import MappingProxyType
8
+
9
+ from agent_roster.definitions import (
10
+ AgentDefinition,
11
+ AgentOptions,
12
+ LaunchFile,
13
+ SessionSetting,
14
+ SettingString,
15
+ )
16
+ from agent_roster.errors import InvalidRequestError
17
+
18
+ PINNED_CLI_SETTINGS = MappingProxyType(
19
+ {"toolPermission": "strict", "permissions": {"allow": []}}
20
+ )
21
+
22
+
23
+ class AgyOptions(AgentOptions):
24
+ model: SettingString | None = None
25
+ effort: SettingString | None = None
26
+
27
+
28
+ class AgyDefinition(AgentDefinition):
29
+ name = "agy"
30
+ executable = "agy"
31
+ base_args = ("acp",)
32
+ options_model = AgyOptions
33
+ resume_session = True
34
+ # "default" asks before edits and commands; "accept-edits" approves workspace edits unasked.
35
+ pins = (("mode", "default"),)
36
+ deliveries = MappingProxyType(
37
+ {"model": SessionSetting("model"), "effort": SessionSetting("thought_level")}
38
+ )
39
+
40
+ def launch_args(self, client_name: str) -> tuple[str, ...]:
41
+ return ("--cli_dir_name", client_name)
42
+
43
+ def launch_files(
44
+ self,
45
+ options: AgentOptions,
46
+ environ: Mapping[str, str],
47
+ *,
48
+ client_name: str,
49
+ ) -> tuple[LaunchFile, ...]:
50
+ home = environ.get("HOME", "")
51
+ if not home or not os.path.isabs(home):
52
+ raise InvalidRequestError(
53
+ "cannot pin agy CLI settings: HOME must be an absolute path"
54
+ )
55
+ target = Path(home, ".gemini", "antigravity-cli", client_name, "settings.json")
56
+ payload = json.dumps(dict(PINNED_CLI_SETTINGS), indent=2) + "\n"
57
+ return (LaunchFile(path=str(target), content=payload, mode=0o600),)
58
+
59
+ def describe_launch_files(
60
+ self, *, client_name: str
61
+ ) -> tuple[dict[str, object], ...]:
62
+ return (
63
+ {
64
+ "path": f"$HOME/.gemini/antigravity-cli/{client_name}/settings.json",
65
+ "content": dict(PINNED_CLI_SETTINGS),
66
+ },
67
+ )
@@ -0,0 +1,27 @@
1
+ """Claude Code over ACP, through the user-installed ``claude-agent-acp`` adapter."""
2
+
3
+ from types import MappingProxyType
4
+
5
+ from agent_roster.definitions import (
6
+ AgentDefinition,
7
+ AgentOptions,
8
+ SessionSetting,
9
+ SettingString,
10
+ )
11
+
12
+
13
+ class ClaudeCodeOptions(AgentOptions):
14
+ model: SettingString | None = None
15
+ effort: SettingString | None = None
16
+
17
+
18
+ class ClaudeCodeDefinition(AgentDefinition):
19
+ name = "claude_code"
20
+ executable = "claude-agent-acp"
21
+ options_model = ClaudeCodeOptions
22
+ resume_session = True
23
+ # "default" asks before edits and commands; other modes widen or bypass permissions.
24
+ pins = (("mode", "default"),)
25
+ deliveries = MappingProxyType(
26
+ {"model": SessionSetting("model"), "effort": SessionSetting("effort")}
27
+ )
@@ -0,0 +1,30 @@
1
+ """Cline CLI over ACP (``cline --acp``)."""
2
+
3
+ from types import MappingProxyType
4
+ from typing import Literal
5
+
6
+ from agent_roster.definitions import (
7
+ AgentDefinition,
8
+ AgentOptions,
9
+ LaunchFlag,
10
+ SessionSetting,
11
+ SettingString,
12
+ )
13
+
14
+
15
+ class ClineOptions(AgentOptions):
16
+ model: SettingString | None = None
17
+ effort: Literal["none", "low", "medium", "high", "xhigh"] | None = None
18
+
19
+
20
+ class ClineDefinition(AgentDefinition):
21
+ name = "cline"
22
+ executable = "cline"
23
+ base_args = ("--acp",)
24
+ options_model = ClineOptions
25
+ resume_session = True
26
+ # Cline auto-approves every tool unless told otherwise.
27
+ pins = (("auto_approve", False),)
28
+ deliveries = MappingProxyType(
29
+ {"model": SessionSetting("model"), "effort": LaunchFlag("--thinking")}
30
+ )
@@ -0,0 +1,30 @@
1
+ """Codex over ACP, through the user-installed ``codex-acp`` adapter."""
2
+
3
+ from types import MappingProxyType
4
+
5
+ from agent_roster.definitions import (
6
+ AgentDefinition,
7
+ AgentOptions,
8
+ SessionSetting,
9
+ SettingString,
10
+ )
11
+
12
+
13
+ class CodexOptions(AgentOptions):
14
+ model: SettingString | None = None
15
+ effort: SettingString | None = None
16
+
17
+
18
+ class CodexDefinition(AgentDefinition):
19
+ name = "codex"
20
+ executable = "codex-acp"
21
+ options_model = CodexOptions
22
+ resume_session = True
23
+ # In read-only mode Codex asks before writing or running commands.
24
+ pins = (("mode", "read-only"),)
25
+ deliveries = MappingProxyType(
26
+ {
27
+ "model": SessionSetting("model"),
28
+ "effort": SessionSetting("reasoning_effort"),
29
+ }
30
+ )
@@ -0,0 +1,34 @@
1
+ """GitHub Copilot CLI over ACP (``copilot --acp``)."""
2
+
3
+ from types import MappingProxyType
4
+
5
+ from agent_roster.definitions import (
6
+ AgentDefinition,
7
+ AgentOptions,
8
+ SessionSetting,
9
+ SettingString,
10
+ )
11
+
12
+ AGENT_MODE = "https://agentclientprotocol.com/protocol/session-modes#agent"
13
+
14
+
15
+ class CopilotOptions(AgentOptions):
16
+ model: SettingString | None = None
17
+ effort: SettingString | None = None
18
+
19
+
20
+ class CopilotDefinition(AgentDefinition):
21
+ name = "copilot"
22
+ executable = "copilot"
23
+ base_args = ("--acp",)
24
+ options_model = CopilotOptions
25
+ resume_session = True
26
+ # allow_all=on would approve every tool without asking. The mode goes first: switching
27
+ # out of autopilot is not known to turn allow-all back off.
28
+ pins = (("mode", AGENT_MODE), ("allow_all", "off"))
29
+ deliveries = MappingProxyType(
30
+ {
31
+ "model": SessionSetting("model"),
32
+ "effort": SessionSetting("reasoning_effort"),
33
+ }
34
+ )
@@ -0,0 +1,29 @@
1
+ """Cursor Agent over ACP (``cursor-agent acp``)."""
2
+
3
+ from types import MappingProxyType
4
+
5
+ from agent_roster.definitions import (
6
+ AgentDefinition,
7
+ AgentOptions,
8
+ SessionSetting,
9
+ SettingString,
10
+ SettingValue,
11
+ )
12
+
13
+
14
+ class CursorOptions(AgentOptions):
15
+ model: SettingString | None = None
16
+
17
+
18
+ class CursorDefinition(AgentDefinition):
19
+ name = "cursor"
20
+ executable = "cursor-agent"
21
+ base_args = ("acp",)
22
+ options_model = CursorOptions
23
+ resume_session = True
24
+ deliveries = MappingProxyType({"model": SessionSetting("model")})
25
+
26
+ def pinned(
27
+ self, grant: frozenset[str] = frozenset()
28
+ ) -> tuple[tuple[str, SettingValue], ...]:
29
+ return (("mode", "agent" if "edit" in grant else "plan"),)
@@ -0,0 +1,55 @@
1
+ """opencode over ACP (``opencode acp``)."""
2
+
3
+ import json
4
+ from collections.abc import Mapping
5
+ from types import MappingProxyType
6
+
7
+ from agent_roster.definitions import (
8
+ AgentDefinition,
9
+ AgentOptions,
10
+ SessionSetting,
11
+ SettingString,
12
+ )
13
+ from agent_roster.errors import InvalidRequestError
14
+
15
+ ASK = MappingProxyType({"edit": "ask", "bash": "ask", "webfetch": "ask"})
16
+
17
+
18
+ class OpencodeOptions(AgentOptions):
19
+ # A provider/model id, e.g. "opencode/big-pickle".
20
+ model: SettingString | None = None
21
+
22
+
23
+ class OpencodeDefinition(AgentDefinition):
24
+ name = "opencode"
25
+ executable = "opencode"
26
+ base_args = ("acp",)
27
+ options_model = OpencodeOptions
28
+ resume_session = True
29
+ pins = (("mode", "build"),)
30
+ deliveries = MappingProxyType({"model": SessionSetting("model")})
31
+
32
+ def environment(
33
+ self, options: AgentOptions, environ: Mapping[str, str]
34
+ ) -> Mapping[str, str]:
35
+ # Keep the user's inline config; only its permission entries are overridden.
36
+ # Only JSON's own whitespace counts as empty; anything else is parsed as given
37
+ # and refused if it is not a JSON object.
38
+ raw = environ.get("OPENCODE_CONFIG_CONTENT", "")
39
+ if not raw.strip(" \t\n\r"):
40
+ raw = "{}"
41
+ try:
42
+ config = json.loads(raw)
43
+ except json.JSONDecodeError:
44
+ config = None
45
+ if not isinstance(config, dict):
46
+ raise InvalidRequestError(
47
+ "OPENCODE_CONFIG_CONTENT in the environment is not a JSON object; "
48
+ "fix or unset it"
49
+ )
50
+ permission = config.get("permission")
51
+ config["permission"] = {
52
+ **(permission if isinstance(permission, dict) else {}),
53
+ **ASK,
54
+ }
55
+ return {"OPENCODE_CONFIG_CONTENT": json.dumps(config)}