cosmos-agent-sdk 0.0.1a0__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 (49) hide show
  1. cosmos_agent_sdk-0.0.1a0/PKG-INFO +101 -0
  2. cosmos_agent_sdk-0.0.1a0/README.md +70 -0
  3. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/__init__.py +197 -0
  4. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/acp/__init__.py +43 -0
  5. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/acp/client.py +554 -0
  6. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/acp/events.py +214 -0
  7. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/client.py +476 -0
  8. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/__init__.py +118 -0
  9. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/auth.py +178 -0
  10. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/capabilities.py +119 -0
  11. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/client.py +143 -0
  12. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/experts.py +605 -0
  13. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/from_expert.py +248 -0
  14. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/http.py +198 -0
  15. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/mcp.py +140 -0
  16. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/cloud/transport.py +363 -0
  17. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/conformance.py +239 -0
  18. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/protocol.py +489 -0
  19. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/redaction.py +383 -0
  20. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/session_reader.py +879 -0
  21. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/session_sink.py +295 -0
  22. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/sinks/__init__.py +15 -0
  23. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/sinks/mongo.py +196 -0
  24. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk/transport.py +495 -0
  25. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk.egg-info/PKG-INFO +101 -0
  26. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk.egg-info/SOURCES.txt +47 -0
  27. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk.egg-info/dependency_links.txt +1 -0
  28. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk.egg-info/requires.txt +18 -0
  29. cosmos_agent_sdk-0.0.1a0/cosmos_agent_sdk.egg-info/top_level.txt +1 -0
  30. cosmos_agent_sdk-0.0.1a0/pyproject.toml +92 -0
  31. cosmos_agent_sdk-0.0.1a0/setup.cfg +4 -0
  32. cosmos_agent_sdk-0.0.1a0/tests/test_acp.py +331 -0
  33. cosmos_agent_sdk-0.0.1a0/tests/test_client.py +536 -0
  34. cosmos_agent_sdk-0.0.1a0/tests/test_cloud_auth.py +108 -0
  35. cosmos_agent_sdk-0.0.1a0/tests/test_cloud_capabilities.py +59 -0
  36. cosmos_agent_sdk-0.0.1a0/tests/test_cloud_experts.py +402 -0
  37. cosmos_agent_sdk-0.0.1a0/tests/test_cloud_mcp.py +77 -0
  38. cosmos_agent_sdk-0.0.1a0/tests/test_cloud_transport.py +340 -0
  39. cosmos_agent_sdk-0.0.1a0/tests/test_cloud_zero_dep.py +85 -0
  40. cosmos_agent_sdk-0.0.1a0/tests/test_conformance.py +103 -0
  41. cosmos_agent_sdk-0.0.1a0/tests/test_dependency_isolation.py +62 -0
  42. cosmos_agent_sdk-0.0.1a0/tests/test_integration.py +255 -0
  43. cosmos_agent_sdk-0.0.1a0/tests/test_protocol.py +147 -0
  44. cosmos_agent_sdk-0.0.1a0/tests/test_redaction.py +296 -0
  45. cosmos_agent_sdk-0.0.1a0/tests/test_session_reader.py +500 -0
  46. cosmos_agent_sdk-0.0.1a0/tests/test_session_sink.py +258 -0
  47. cosmos_agent_sdk-0.0.1a0/tests/test_transport.py +139 -0
  48. cosmos_agent_sdk-0.0.1a0/tests/test_websocket_conformance.py +233 -0
  49. cosmos_agent_sdk-0.0.1a0/tests/test_websocket_transport.py +232 -0
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: cosmos-agent-sdk
3
+ Version: 0.0.1a0
4
+ Summary: Python client for the Auggie v2 SDK / RPC protocol
5
+ Author-email: Augment Code <support@augmentcode.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://augmentcode.com
8
+ Project-URL: Repository, https://github.com/augmentcode/cosmos-agent-sdk
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
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ Provides-Extra: ws
18
+ Requires-Dist: websocket-client>=1.7.0; extra == "ws"
19
+ Provides-Extra: mongo
20
+ Requires-Dist: pymongo>=4.6.0; extra == "mongo"
21
+ Provides-Extra: cloud
22
+ Requires-Dist: httpx>=0.27.0; extra == "cloud"
23
+ Provides-Extra: dev
24
+ Requires-Dist: ruff>=0.6.0; extra == "dev"
25
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
26
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
27
+ Requires-Dist: websocket-client>=1.7.0; extra == "dev"
28
+ Requires-Dist: pymongo>=4.6.0; extra == "dev"
29
+ Requires-Dist: mongomock>=4.1.0; extra == "dev"
30
+ Requires-Dist: httpx>=0.27.0; extra == "dev"
31
+
32
+ # cosmos-agent-sdk — Python client
33
+
34
+ RPC-first Python client for the Auggie v2 SDK / RPC protocol. It implements the
35
+ shared spec under [`../../spec`](../../spec) and passes the shared
36
+ [`../../conformance`](../../conformance) fixtures, in lockstep with the
37
+ TypeScript client.
38
+
39
+ ## Layers
40
+
41
+ - **Transport** (`cosmos_agent_sdk.transport`) — JSONL framing, request/response
42
+ correlation by `id`, protocol-version handshake, and message routing. Spawns
43
+ `auggie-v2 --mode rpc` (`SubprocessTransport`); a `FakeTransport` replays
44
+ canned wire messages through the same code paths for tests/conformance. Single
45
+ session per process (multi-session = a client-side process pool).
46
+ - **Protocol** (`cosmos_agent_sdk.protocol`) — typed command / response / event /
47
+ extension-UI models mirroring the four JSON Schemas. Deep external structures
48
+ are forwarded verbatim as permissive objects (see the spec's "Permissiveness
49
+ policy").
50
+ - **Facade** (`cosmos_agent_sdk.client.AgentClient`) — the ergonomic API:
51
+ `prompt`, `wait_for_idle` (idle = the `agent_end` event), the full typed
52
+ command surface, and bidirectional extension-UI round-trips (reply-expecting
53
+ methods are answered; fire-and-forget methods are not).
54
+
55
+ ```python
56
+ from cosmos_agent_sdk import AgentClient, SubprocessTransport
57
+
58
+ transport = SubprocessTransport("auggie-v2")
59
+ transport.start()
60
+ with AgentClient(transport) as client:
61
+ client.prompt("List the files in this repo")
62
+ client.wait_for_idle()
63
+ print(client.get_last_assistant_text()["data"]["text"])
64
+ ```
65
+
66
+ ## Toolchain
67
+
68
+ - [uv](https://docs.astral.sh/uv/) for environment management and building.
69
+ - [ruff](https://docs.astral.sh/ruff/) for lint / format.
70
+ - [mypy](https://mypy-lang.org/) for type-checking.
71
+ - [pytest](https://docs.pytest.org/) for the unit suite.
72
+
73
+ ## Commands
74
+
75
+ ```bash
76
+ uv sync --extra dev # create a venv and install dev dependencies
77
+ uv run ruff check . # lint
78
+ uv run ruff format . # format
79
+ uv run mypy cosmos_agent_sdk # type-check
80
+ uv run pytest # unit tests
81
+ uv build # build the sdist + wheel
82
+ ```
83
+
84
+ ## Conformance
85
+
86
+ The cross-client conformance runner is JavaScript. The Python client binds to it
87
+ through a thin JS shim, [`conformance-adapter.mjs`](./conformance-adapter.mjs),
88
+ that shells out to the real Python client
89
+ (`python -m cosmos_agent_sdk.conformance`) driven over an in-memory fake
90
+ transport replaying the fixture wire messages through the real
91
+ parsing / correlation / extension-UI code paths (v0 does not spawn a real
92
+ `auggie-v2` binary).
93
+
94
+ ```bash
95
+ # from clients/python/ — requires the conformance deps installed once:
96
+ ( cd ../../conformance && npm install )
97
+ uv sync --extra dev
98
+ make conformance # or: node conformance-adapter.mjs
99
+ ```
100
+
101
+ Exits non-zero if any of the 40 shared vectors fails.
@@ -0,0 +1,70 @@
1
+ # cosmos-agent-sdk — Python client
2
+
3
+ RPC-first Python client for the Auggie v2 SDK / RPC protocol. It implements the
4
+ shared spec under [`../../spec`](../../spec) and passes the shared
5
+ [`../../conformance`](../../conformance) fixtures, in lockstep with the
6
+ TypeScript client.
7
+
8
+ ## Layers
9
+
10
+ - **Transport** (`cosmos_agent_sdk.transport`) — JSONL framing, request/response
11
+ correlation by `id`, protocol-version handshake, and message routing. Spawns
12
+ `auggie-v2 --mode rpc` (`SubprocessTransport`); a `FakeTransport` replays
13
+ canned wire messages through the same code paths for tests/conformance. Single
14
+ session per process (multi-session = a client-side process pool).
15
+ - **Protocol** (`cosmos_agent_sdk.protocol`) — typed command / response / event /
16
+ extension-UI models mirroring the four JSON Schemas. Deep external structures
17
+ are forwarded verbatim as permissive objects (see the spec's "Permissiveness
18
+ policy").
19
+ - **Facade** (`cosmos_agent_sdk.client.AgentClient`) — the ergonomic API:
20
+ `prompt`, `wait_for_idle` (idle = the `agent_end` event), the full typed
21
+ command surface, and bidirectional extension-UI round-trips (reply-expecting
22
+ methods are answered; fire-and-forget methods are not).
23
+
24
+ ```python
25
+ from cosmos_agent_sdk import AgentClient, SubprocessTransport
26
+
27
+ transport = SubprocessTransport("auggie-v2")
28
+ transport.start()
29
+ with AgentClient(transport) as client:
30
+ client.prompt("List the files in this repo")
31
+ client.wait_for_idle()
32
+ print(client.get_last_assistant_text()["data"]["text"])
33
+ ```
34
+
35
+ ## Toolchain
36
+
37
+ - [uv](https://docs.astral.sh/uv/) for environment management and building.
38
+ - [ruff](https://docs.astral.sh/ruff/) for lint / format.
39
+ - [mypy](https://mypy-lang.org/) for type-checking.
40
+ - [pytest](https://docs.pytest.org/) for the unit suite.
41
+
42
+ ## Commands
43
+
44
+ ```bash
45
+ uv sync --extra dev # create a venv and install dev dependencies
46
+ uv run ruff check . # lint
47
+ uv run ruff format . # format
48
+ uv run mypy cosmos_agent_sdk # type-check
49
+ uv run pytest # unit tests
50
+ uv build # build the sdist + wheel
51
+ ```
52
+
53
+ ## Conformance
54
+
55
+ The cross-client conformance runner is JavaScript. The Python client binds to it
56
+ through a thin JS shim, [`conformance-adapter.mjs`](./conformance-adapter.mjs),
57
+ that shells out to the real Python client
58
+ (`python -m cosmos_agent_sdk.conformance`) driven over an in-memory fake
59
+ transport replaying the fixture wire messages through the real
60
+ parsing / correlation / extension-UI code paths (v0 does not spawn a real
61
+ `auggie-v2` binary).
62
+
63
+ ```bash
64
+ # from clients/python/ — requires the conformance deps installed once:
65
+ ( cd ../../conformance && npm install )
66
+ uv sync --extra dev
67
+ make conformance # or: node conformance-adapter.mjs
68
+ ```
69
+
70
+ Exits non-zero if any of the 40 shared vectors fails.
@@ -0,0 +1,197 @@
1
+ """Python client for the Auggie v2 SDK / RPC protocol.
2
+
3
+ RPC-first client mirroring the shared spec under ``spec/``: a JSONL transport
4
+ that spawns ``auggie-v2 --mode rpc`` (single session per process), a typed
5
+ command / response / event / extension-UI layer, and an ergonomic
6
+ :class:`AgentClient` facade with ``prompt`` / ``wait_for_idle`` and bidirectional
7
+ extension-UI round-trips. Conformance parity with the TypeScript client is
8
+ proved by the shared fixtures (see ``clients/python/conformance-adapter.mjs``).
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from .acp import (
14
+ AcpClient,
15
+ AcpCost,
16
+ AcpEventListener,
17
+ AcpNotInitializedError,
18
+ AcpPermissionHandler,
19
+ AcpRpcError,
20
+ AcpWarning,
21
+ AcpWarningListener,
22
+ MappedSessionUpdate,
23
+ UsageUpdateEvent,
24
+ map_session_update,
25
+ )
26
+ from .client import (
27
+ AgentClient,
28
+ CommandError,
29
+ ExtensionUIResponder,
30
+ RpcError,
31
+ make_confirm_all_responder,
32
+ )
33
+ from .cloud import (
34
+ AugmentCredentials,
35
+ CloudAgentCapability,
36
+ CloudAgentClient,
37
+ CloudHttpError,
38
+ CosmosTransport,
39
+ CredentialsNotFoundError,
40
+ HttpClient,
41
+ McpServerConfig,
42
+ UnselectableCapabilityError,
43
+ UrllibHttpClient,
44
+ capability_from,
45
+ default_http_client,
46
+ resolve_credentials,
47
+ resolve_mcp_servers,
48
+ )
49
+ from .redaction import (
50
+ DEFAULT_REDACTION_POLICY,
51
+ RedactionMode,
52
+ RedactionPolicy,
53
+ redact,
54
+ )
55
+ from .session_reader import (
56
+ CURRENT_SESSION_VERSION,
57
+ ParsedSession,
58
+ PerModelUsage,
59
+ SessionStats,
60
+ SessionTreeNode,
61
+ UsageAggregation,
62
+ aggregate_stats,
63
+ aggregate_usage,
64
+ build_tree,
65
+ deterministic_id_generator,
66
+ header,
67
+ latest_queue_state,
68
+ migrate_session_entries,
69
+ parse_session,
70
+ read_session,
71
+ session_entries,
72
+ watch_session,
73
+ )
74
+ from .session_sink import (
75
+ EntryUsage,
76
+ RollupModelSpend,
77
+ SessionEntryDocument,
78
+ SessionRollupDocument,
79
+ SessionSink,
80
+ session_id_of,
81
+ split_header_and_entries,
82
+ to_session_documents,
83
+ to_session_rollup,
84
+ )
85
+ from .protocol import (
86
+ ASYNC_COMMANDS,
87
+ COMMAND_TYPES,
88
+ EVENT_TYPES,
89
+ FIRE_AND_FORGET_METHODS,
90
+ IDLE_EVENT,
91
+ NO_DATA_COMMANDS,
92
+ PROTOCOL_VERSION,
93
+ REPLY_EXPECTING_METHODS,
94
+ classify_stdout,
95
+ is_idle_event,
96
+ is_reply_expecting,
97
+ is_response_success,
98
+ make_extension_ui_response,
99
+ )
100
+ from .transport import (
101
+ FakeTransport,
102
+ ProtocolVersionMismatch,
103
+ SubprocessTransport,
104
+ Transport,
105
+ WebSocketConnection,
106
+ WebSocketConnector,
107
+ WebSocketTransport,
108
+ assert_protocol_version,
109
+ decode_line,
110
+ encode_line,
111
+ )
112
+
113
+ __all__ = [
114
+ "ASYNC_COMMANDS",
115
+ "CURRENT_SESSION_VERSION",
116
+ "DEFAULT_REDACTION_POLICY",
117
+ "RedactionMode",
118
+ "RedactionPolicy",
119
+ "redact",
120
+ "ParsedSession",
121
+ "PerModelUsage",
122
+ "SessionStats",
123
+ "SessionTreeNode",
124
+ "UsageAggregation",
125
+ "aggregate_stats",
126
+ "aggregate_usage",
127
+ "build_tree",
128
+ "deterministic_id_generator",
129
+ "header",
130
+ "latest_queue_state",
131
+ "migrate_session_entries",
132
+ "parse_session",
133
+ "read_session",
134
+ "session_entries",
135
+ "watch_session",
136
+ "EntryUsage",
137
+ "RollupModelSpend",
138
+ "SessionEntryDocument",
139
+ "SessionRollupDocument",
140
+ "SessionSink",
141
+ "session_id_of",
142
+ "split_header_and_entries",
143
+ "to_session_documents",
144
+ "to_session_rollup",
145
+ "COMMAND_TYPES",
146
+ "EVENT_TYPES",
147
+ "FIRE_AND_FORGET_METHODS",
148
+ "IDLE_EVENT",
149
+ "NO_DATA_COMMANDS",
150
+ "PROTOCOL_VERSION",
151
+ "REPLY_EXPECTING_METHODS",
152
+ "AcpClient",
153
+ "AcpCost",
154
+ "AcpEventListener",
155
+ "AcpNotInitializedError",
156
+ "AcpPermissionHandler",
157
+ "AcpRpcError",
158
+ "AcpWarning",
159
+ "AcpWarningListener",
160
+ "AgentClient",
161
+ "AugmentCredentials",
162
+ "CloudAgentCapability",
163
+ "CloudAgentClient",
164
+ "CloudHttpError",
165
+ "CommandError",
166
+ "CosmosTransport",
167
+ "CredentialsNotFoundError",
168
+ "HttpClient",
169
+ "McpServerConfig",
170
+ "UnselectableCapabilityError",
171
+ "UrllibHttpClient",
172
+ "capability_from",
173
+ "default_http_client",
174
+ "resolve_credentials",
175
+ "resolve_mcp_servers",
176
+ "MappedSessionUpdate",
177
+ "UsageUpdateEvent",
178
+ "ExtensionUIResponder",
179
+ "FakeTransport",
180
+ "ProtocolVersionMismatch",
181
+ "RpcError",
182
+ "SubprocessTransport",
183
+ "Transport",
184
+ "WebSocketConnection",
185
+ "WebSocketConnector",
186
+ "WebSocketTransport",
187
+ "assert_protocol_version",
188
+ "classify_stdout",
189
+ "decode_line",
190
+ "encode_line",
191
+ "is_idle_event",
192
+ "is_reply_expecting",
193
+ "is_response_success",
194
+ "make_confirm_all_responder",
195
+ "map_session_update",
196
+ "make_extension_ui_response",
197
+ ]
@@ -0,0 +1,43 @@
1
+ """ACP-transport adapter for the Auggie v2 SDK (CSS-1414).
2
+
3
+ An additive sibling of the RPC client: :class:`AcpClient` drives
4
+ ``auggie-v2 --acp`` as an Agent Client Protocol *client* over the child's stdio
5
+ and re-exposes the SAME ``on_event`` / ``on_warning`` / ``prompt`` /
6
+ ``prompt_and_wait`` / ``wait_for_idle`` / ``close`` ergonomics as
7
+ :class:`~cosmos_agent_sdk.AgentClient`, so consumer code looks the same on either
8
+ transport. ``on_event`` also delivers the SDK-owned ``UsageUpdateEvent`` for the
9
+ ACP ``usage_update`` notification (CSS-2258); see ``events.py``.
10
+
11
+ Zero base dependencies: the minimal ACP client (newline-delimited JSON-RPC 2.0
12
+ over stdio) is hand-rolled here and is fully synchronous, matching the RPC
13
+ client's threads + :class:`threading.Condition` model.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from .client import (
19
+ PROTOCOL_VERSION,
20
+ AcpClient,
21
+ AcpEventListener,
22
+ AcpNotInitializedError,
23
+ AcpPermissionHandler,
24
+ AcpRpcError,
25
+ AcpWarning,
26
+ AcpWarningListener,
27
+ )
28
+ from .events import AcpCost, MappedSessionUpdate, UsageUpdateEvent, map_session_update
29
+
30
+ __all__ = [
31
+ "PROTOCOL_VERSION",
32
+ "AcpClient",
33
+ "AcpCost",
34
+ "AcpEventListener",
35
+ "AcpNotInitializedError",
36
+ "AcpPermissionHandler",
37
+ "AcpRpcError",
38
+ "AcpWarning",
39
+ "AcpWarningListener",
40
+ "MappedSessionUpdate",
41
+ "UsageUpdateEvent",
42
+ "map_session_update",
43
+ ]