agentshim 0.6.7__tar.gz → 0.7.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.
- {agentshim-0.6.7 → agentshim-0.7.0}/CHANGELOG.md +75 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/PKG-INFO +4 -3
- {agentshim-0.6.7 → agentshim-0.7.0}/README.md +3 -2
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/__init__.py +15 -1
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/__init__.py +9 -1
- agentshim-0.7.0/agentshim/core/pricing.py +466 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/profile.py +6 -3
- agentshim-0.7.0/agentshim/core/schema.py +352 -0
- agentshim-0.7.0/agentshim/core/usage.py +287 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/parser.py +18 -10
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/scripted.py +8 -4
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/events.py +7 -2
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/parser.py +9 -6
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/scripted.py +13 -4
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/copilot/parser.py +7 -8
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/copilot/scripted.py +2 -3
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/gemini/parser.py +9 -8
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/opencode/parser.py +9 -8
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/opencode/scripted.py +3 -3
- {agentshim-0.6.7 → agentshim-0.7.0}/pyproject.toml +1 -1
- agentshim-0.6.7/agentshim/core/schema.py +0 -281
- agentshim-0.6.7/agentshim/core/usage.py +0 -78
- {agentshim-0.6.7 → agentshim-0.7.0}/.gitignore +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/agent.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/_files.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/env.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/errors.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/events.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/mcp.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/provider.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/stream.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/core/turn.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/execution/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/execution/executor.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/execution/host.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/execution/transform.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/events.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/hooks/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/hooks/confine_reads.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/provider.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/sandbox.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/claude/user_hooks.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/_toml.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/provider.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/rules.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/codex/sandbox.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/copilot/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/copilot/events.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/copilot/provider.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/gemini/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/gemini/events.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/gemini/provider.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/gemini/scripted.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/opencode/__init__.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/opencode/events.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/providers/opencode/provider.py +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/py.typed +0 -0
- {agentshim-0.6.7 → agentshim-0.7.0}/agentshim/testing/__init__.py +0 -0
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0 (2026-09-27)
|
|
4
|
+
|
|
5
|
+
First-class cache accounting and a static pricing table. Additive except one
|
|
6
|
+
change of meaning: `cached_input_tokens` now counts cache reads only (see
|
|
7
|
+
Changed).
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `TokenUsage.cache_read_input_tokens` (input served from the prompt cache),
|
|
12
|
+
`cache_write_1h_input_tokens` (the one-hour-TTL part of cache writes, from
|
|
13
|
+
Claude's `cache_creation` breakdown) and the derived
|
|
14
|
+
`uncached_input_tokens` (`input - cache_read - cache_write`). `to_dict()`
|
|
15
|
+
gains the three keys; no key was removed.
|
|
16
|
+
- Codex turns now report `cache_write_input_tokens` and
|
|
17
|
+
`reasoning_output_tokens` from `turn.completed` (both used to be dropped).
|
|
18
|
+
- `TokenUsage` checks its invariants on construction:
|
|
19
|
+
`cache_read + cache_write <= input`, `cache_write_1h <= cache_write`,
|
|
20
|
+
`reasoning <= output`, no negative counts. Parsers build it through the new
|
|
21
|
+
`normalized_usage`, which clamps a CLI's inconsistent counts instead.
|
|
22
|
+
- `TokenUsage.from_dict` reads a `to_dict()` mapping back, including one
|
|
23
|
+
written before 0.7.0.
|
|
24
|
+
- `TokenWeights` and `TokenUsage.weighted_total(weights)`: a total weighted by
|
|
25
|
+
token class (uncached input, cache reads, 5m and 1h cache writes, output,
|
|
26
|
+
reasoning), each token weighted once.
|
|
27
|
+
- A static, versioned pricing table (`agentshim.core.pricing`):
|
|
28
|
+
`ModelPricing`, `PricingTable`, `default_pricing()`,
|
|
29
|
+
`price_for(provider, model, table=None)` (`None` for an unknown model, never
|
|
30
|
+
zero), `cost_usd(usage, pricing)` and `ModelPricing.relative_weights()`.
|
|
31
|
+
It covers OpenAI GPT-6 (astra, sol, luna), GPT-5.6, GPT-5.5 and earlier
|
|
32
|
+
GPT-5 models, and Claude Fable 5.1, Fable 5, Opus 5.5, Opus 5, Opus 4.8,
|
|
33
|
+
Sonnet 5, Sonnet 4.6 and Haiku 4.5, each with its official source URL and
|
|
34
|
+
check date (all 2026-09-27). Callers override or extend it with
|
|
35
|
+
`PricingTable.with_entries` or `PricingTable.from_dict`. Holding prices in
|
|
36
|
+
agentshim is a user-directed decision; see `docs/pricing.md`.
|
|
37
|
+
- Recorded Codex, Claude (5m and 1h cache writes), opencode and Gemini
|
|
38
|
+
streams under `tests/fixtures/`, with tests pinning each provider's mapping.
|
|
39
|
+
The Claude Haiku 4.5 recording's `total_cost_usd` is reproduced exactly by
|
|
40
|
+
the table.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- `cached_input_tokens` is a deprecated alias of `cache_read_input_tokens`.
|
|
45
|
+
On Claude, opencode and Copilot it used to be reads plus writes; it is now
|
|
46
|
+
reads only, since a cache write is billed above base input and a read far
|
|
47
|
+
below it. Codex and Gemini report no writes in their cached count, so their
|
|
48
|
+
value is unchanged. Constructing with `cached_input_tokens=` still works.
|
|
49
|
+
|
|
50
|
+
### Documented
|
|
51
|
+
|
|
52
|
+
- Claude's `result.usage` covers the main conversation only; a Task
|
|
53
|
+
subagent's tokens appear only in `modelUsage` and `total_cost_usd`.
|
|
54
|
+
|
|
55
|
+
## 0.6.8 (2026-09-27)
|
|
56
|
+
|
|
57
|
+
A tightening of the Codex (`STRICT`) schema check: schemas it now rejects
|
|
58
|
+
were already rejected by the API, after a full model turn.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- A Codex output schema is checked against OpenAI's strict structured-output
|
|
63
|
+
rules before the CLI starts. `turn()` raises `SchemaDialectError`, naming
|
|
64
|
+
each offending node by JSON pointer, when an object leaves a property out
|
|
65
|
+
of `required` (declare it required and nullable instead), lists a
|
|
66
|
+
`required` name missing from `properties`, omits `properties` (`{}` is
|
|
67
|
+
fine) or `additionalProperties: false` (including on a nullable
|
|
68
|
+
`["object", "null"]` object), uses `anyOf` at
|
|
69
|
+
the root, or has a `$ref` that resolves to nothing. Codex used to fail such
|
|
70
|
+
a turn with `invalid_json_schema` only after the model ran. The Claude
|
|
71
|
+
(`OPEN`) dialect is unchanged.
|
|
72
|
+
- A `$ref` of `"#"` (root recursion) is accepted as local in both dialects.
|
|
73
|
+
- Problem pointers escape `/` and `~` in property names (RFC 6901), and
|
|
74
|
+
`enum`, `const` and `required` values are no longer inspected as schemas.
|
|
75
|
+
- `normalize` closes a nullable object node too, and gives an object with
|
|
76
|
+
no `properties` an empty one, so its output passes the `STRICT` check.
|
|
77
|
+
|
|
3
78
|
## 0.6.7 (2026-09-27)
|
|
4
79
|
|
|
5
80
|
Additive, with one tightening: a sandboxed Codex turn no longer applies the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agentshim
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Provider-agnostic coding-agent CLI shims
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Provides-Extra: test
|
|
@@ -23,8 +23,9 @@ No required runtime dependencies. Python 3.10+.
|
|
|
23
23
|
|
|
24
24
|
- `CliAgent` / `AgentSession`: one turn at a time, resumable, cancellable
|
|
25
25
|
- typed events delivered on the calling thread
|
|
26
|
-
- normalized token accounting
|
|
27
|
-
every provider
|
|
26
|
+
- normalized token accounting (total input, cache reads, cache writes,
|
|
27
|
+
uncached input, output and reasoning) on every provider, plus a static,
|
|
28
|
+
versioned pricing table (see [Usage and Pricing](docs/pricing.md))
|
|
28
29
|
- declared capabilities on `ProviderProfile`, so no caller probes a provider
|
|
29
30
|
- injectable `CommandExecutor`s for running the CLI in a container or over a
|
|
30
31
|
remote shell
|
|
@@ -14,8 +14,9 @@ No required runtime dependencies. Python 3.10+.
|
|
|
14
14
|
|
|
15
15
|
- `CliAgent` / `AgentSession`: one turn at a time, resumable, cancellable
|
|
16
16
|
- typed events delivered on the calling thread
|
|
17
|
-
- normalized token accounting
|
|
18
|
-
every provider
|
|
17
|
+
- normalized token accounting (total input, cache reads, cache writes,
|
|
18
|
+
uncached input, output and reasoning) on every provider, plus a static,
|
|
19
|
+
versioned pricing table (see [Usage and Pricing](docs/pricing.md))
|
|
19
20
|
- declared capabilities on `ProviderProfile`, so no caller probes a provider
|
|
20
21
|
- injectable `CommandExecutor`s for running the CLI in a container or over a
|
|
21
22
|
remote shell
|
|
@@ -29,11 +29,13 @@ from .core import (
|
|
|
29
29
|
McpMechanism,
|
|
30
30
|
McpServer,
|
|
31
31
|
McpTransport,
|
|
32
|
+
ModelPricing,
|
|
32
33
|
NoopInstallation,
|
|
33
34
|
NullEventHandler,
|
|
34
35
|
OutputSchema,
|
|
35
36
|
OutputSchemaStyle,
|
|
36
37
|
ParsedTurn,
|
|
38
|
+
PricingTable,
|
|
37
39
|
Provider,
|
|
38
40
|
ProviderCapabilityError,
|
|
39
41
|
ProviderError,
|
|
@@ -51,6 +53,7 @@ from .core import (
|
|
|
51
53
|
StdioMcpServer,
|
|
52
54
|
StreamParser,
|
|
53
55
|
TokenUsage,
|
|
56
|
+
TokenWeights,
|
|
54
57
|
ToolCall,
|
|
55
58
|
ToolResult,
|
|
56
59
|
ToolTracker,
|
|
@@ -59,12 +62,16 @@ from .core import (
|
|
|
59
62
|
UsageReport,
|
|
60
63
|
compact_json,
|
|
61
64
|
compose_event_handlers,
|
|
65
|
+
cost_usd,
|
|
66
|
+
default_pricing,
|
|
62
67
|
dialect_problems,
|
|
63
68
|
install_config_file,
|
|
64
69
|
interactive_env,
|
|
65
70
|
materialize,
|
|
66
71
|
normalize,
|
|
72
|
+
normalized_usage,
|
|
67
73
|
parse_json_object,
|
|
74
|
+
price_for,
|
|
68
75
|
)
|
|
69
76
|
from .execution import (
|
|
70
77
|
CallbackCommandStreamSink,
|
|
@@ -84,7 +91,7 @@ from .providers.copilot import CopilotProvider
|
|
|
84
91
|
from .providers.gemini import GeminiProvider
|
|
85
92
|
from .providers.opencode import OpencodeProvider
|
|
86
93
|
|
|
87
|
-
__version__ = "0.
|
|
94
|
+
__version__ = "0.7.0"
|
|
88
95
|
|
|
89
96
|
__all__ = [
|
|
90
97
|
"AgentEvent",
|
|
@@ -123,6 +130,7 @@ __all__ = [
|
|
|
123
130
|
"McpMechanism",
|
|
124
131
|
"McpServer",
|
|
125
132
|
"McpTransport",
|
|
133
|
+
"ModelPricing",
|
|
126
134
|
"NoopInstallation",
|
|
127
135
|
"NullEventHandler",
|
|
128
136
|
"NullSink",
|
|
@@ -130,6 +138,7 @@ __all__ = [
|
|
|
130
138
|
"OutputSchema",
|
|
131
139
|
"OutputSchemaStyle",
|
|
132
140
|
"ParsedTurn",
|
|
141
|
+
"PricingTable",
|
|
133
142
|
"Provider",
|
|
134
143
|
"ProviderCapabilityError",
|
|
135
144
|
"ProviderError",
|
|
@@ -148,6 +157,7 @@ __all__ = [
|
|
|
148
157
|
"StdioMcpServer",
|
|
149
158
|
"StreamParser",
|
|
150
159
|
"TokenUsage",
|
|
160
|
+
"TokenWeights",
|
|
151
161
|
"ToolCall",
|
|
152
162
|
"ToolResult",
|
|
153
163
|
"ToolTracker",
|
|
@@ -158,12 +168,16 @@ __all__ = [
|
|
|
158
168
|
"__version__",
|
|
159
169
|
"compact_json",
|
|
160
170
|
"compose_event_handlers",
|
|
171
|
+
"cost_usd",
|
|
172
|
+
"default_pricing",
|
|
161
173
|
"dialect_problems",
|
|
162
174
|
"get_provider",
|
|
163
175
|
"install_config_file",
|
|
164
176
|
"interactive_env",
|
|
165
177
|
"materialize",
|
|
166
178
|
"normalize",
|
|
179
|
+
"normalized_usage",
|
|
167
180
|
"parse_json_object",
|
|
181
|
+
"price_for",
|
|
168
182
|
"provider_names",
|
|
169
183
|
]
|
|
@@ -50,12 +50,13 @@ from .mcp import (
|
|
|
50
50
|
StdioMcpServer,
|
|
51
51
|
install_config_file,
|
|
52
52
|
)
|
|
53
|
+
from .pricing import ModelPricing, PricingTable, cost_usd, default_pricing, price_for
|
|
53
54
|
from .profile import McpMechanism, OutputSchemaStyle, ProviderProfile, SchemaDialect
|
|
54
55
|
from .provider import ArgvContext, McpInstallation, ParsedTurn, Provider, StreamParser
|
|
55
56
|
from .schema import compact_json, dialect_problems, materialize, normalize
|
|
56
57
|
from .stream import ToolTracker, parse_json_object
|
|
57
58
|
from .turn import OutputSchema, TurnRequest, TurnResult
|
|
58
|
-
from .usage import ProviderUsage, TokenUsage
|
|
59
|
+
from .usage import ProviderUsage, TokenUsage, TokenWeights, normalized_usage
|
|
59
60
|
|
|
60
61
|
__all__ = [
|
|
61
62
|
"AgentEvent",
|
|
@@ -79,11 +80,13 @@ __all__ = [
|
|
|
79
80
|
"McpMechanism",
|
|
80
81
|
"McpServer",
|
|
81
82
|
"McpTransport",
|
|
83
|
+
"ModelPricing",
|
|
82
84
|
"NoopInstallation",
|
|
83
85
|
"NullEventHandler",
|
|
84
86
|
"OutputSchema",
|
|
85
87
|
"OutputSchemaStyle",
|
|
86
88
|
"ParsedTurn",
|
|
89
|
+
"PricingTable",
|
|
87
90
|
"Provider",
|
|
88
91
|
"ProviderCapabilityError",
|
|
89
92
|
"ProviderError",
|
|
@@ -101,6 +104,7 @@ __all__ = [
|
|
|
101
104
|
"StdioMcpServer",
|
|
102
105
|
"StreamParser",
|
|
103
106
|
"TokenUsage",
|
|
107
|
+
"TokenWeights",
|
|
104
108
|
"ToolCall",
|
|
105
109
|
"ToolResult",
|
|
106
110
|
"ToolTracker",
|
|
@@ -109,10 +113,14 @@ __all__ = [
|
|
|
109
113
|
"UsageReport",
|
|
110
114
|
"compact_json",
|
|
111
115
|
"compose_event_handlers",
|
|
116
|
+
"cost_usd",
|
|
117
|
+
"default_pricing",
|
|
112
118
|
"dialect_problems",
|
|
113
119
|
"install_config_file",
|
|
114
120
|
"interactive_env",
|
|
115
121
|
"materialize",
|
|
116
122
|
"normalize",
|
|
123
|
+
"normalized_usage",
|
|
117
124
|
"parse_json_object",
|
|
125
|
+
"price_for",
|
|
118
126
|
]
|