tokenfold 0.3.1__tar.gz → 0.3.2__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 (36) hide show
  1. {tokenfold-0.3.1 → tokenfold-0.3.2}/Cargo.lock +10 -10
  2. {tokenfold-0.3.1 → tokenfold-0.3.2}/Cargo.toml +1 -1
  3. {tokenfold-0.3.1 → tokenfold-0.3.2}/PKG-INFO +31 -12
  4. {tokenfold-0.3.1 → tokenfold-0.3.2}/README.md +30 -11
  5. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/report.rs +52 -0
  6. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-py/Cargo.toml +1 -1
  7. {tokenfold-0.3.1 → tokenfold-0.3.2}/LICENSE +0 -0
  8. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/Cargo.toml +0 -0
  9. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/benches/THRESHOLDS.toml +0 -0
  10. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/benches/compression_bench.rs +0 -0
  11. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/examples/quickstart.rs +0 -0
  12. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/budget.rs +0 -0
  13. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/errors.rs +0 -0
  14. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/filters.rs +0 -0
  15. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/input.rs +0 -0
  16. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/lib.rs +0 -0
  17. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/modes.rs +0 -0
  18. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/pipeline.rs +0 -0
  19. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/retrieval_store.rs +0 -0
  20. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/safety.rs +0 -0
  21. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/stats.rs +0 -0
  22. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/status.rs +0 -0
  23. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/token_estimator.rs +0 -0
  24. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/diff.rs +0 -0
  25. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/json.rs +0 -0
  26. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/json_dict.rs +0 -0
  27. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/json_fold.rs +0 -0
  28. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/logs.rs +0 -0
  29. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/mod.rs +0 -0
  30. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/redaction.rs +0 -0
  31. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/src/transforms/schema.rs +0 -0
  32. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/tests/golden.rs +0 -0
  33. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/tests/integration.rs +0 -0
  34. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-core/tests/property_tests.rs +0 -0
  35. {tokenfold-0.3.1 → tokenfold-0.3.2}/crates/tokenfold-py/src/lib.rs +0 -0
  36. {tokenfold-0.3.1 → tokenfold-0.3.2}/pyproject.toml +0 -0
@@ -1013,7 +1013,7 @@ dependencies = [
1013
1013
 
1014
1014
  [[package]]
1015
1015
  name = "tokenfold-adapters"
1016
- version = "0.3.1"
1016
+ version = "0.3.2"
1017
1017
  dependencies = [
1018
1018
  "serde",
1019
1019
  "serde_json",
@@ -1022,7 +1022,7 @@ dependencies = [
1022
1022
 
1023
1023
  [[package]]
1024
1024
  name = "tokenfold-admin"
1025
- version = "0.3.1"
1025
+ version = "0.3.2"
1026
1026
  dependencies = [
1027
1027
  "ed25519-dalek",
1028
1028
  "serde",
@@ -1032,7 +1032,7 @@ dependencies = [
1032
1032
 
1033
1033
  [[package]]
1034
1034
  name = "tokenfold-cli"
1035
- version = "0.3.1"
1035
+ version = "0.3.2"
1036
1036
  dependencies = [
1037
1037
  "clap",
1038
1038
  "serde",
@@ -1045,7 +1045,7 @@ dependencies = [
1045
1045
 
1046
1046
  [[package]]
1047
1047
  name = "tokenfold-core"
1048
- version = "0.3.1"
1048
+ version = "0.3.2"
1049
1049
  dependencies = [
1050
1050
  "proptest",
1051
1051
  "regex",
@@ -1059,25 +1059,25 @@ dependencies = [
1059
1059
 
1060
1060
  [[package]]
1061
1061
  name = "tokenfold-image"
1062
- version = "0.3.1"
1062
+ version = "0.3.2"
1063
1063
 
1064
1064
  [[package]]
1065
1065
  name = "tokenfold-learn"
1066
- version = "0.3.1"
1066
+ version = "0.3.2"
1067
1067
  dependencies = [
1068
1068
  "tokenfold-core",
1069
1069
  ]
1070
1070
 
1071
1071
  [[package]]
1072
1072
  name = "tokenfold-output"
1073
- version = "0.3.1"
1073
+ version = "0.3.2"
1074
1074
  dependencies = [
1075
1075
  "tokenfold-core",
1076
1076
  ]
1077
1077
 
1078
1078
  [[package]]
1079
1079
  name = "tokenfold-proxy"
1080
- version = "0.3.1"
1080
+ version = "0.3.2"
1081
1081
  dependencies = [
1082
1082
  "clap",
1083
1083
  "serde",
@@ -1089,7 +1089,7 @@ dependencies = [
1089
1089
 
1090
1090
  [[package]]
1091
1091
  name = "tokenfold-py"
1092
- version = "0.3.1"
1092
+ version = "0.3.2"
1093
1093
  dependencies = [
1094
1094
  "pyo3",
1095
1095
  "serde_json",
@@ -1098,7 +1098,7 @@ dependencies = [
1098
1098
 
1099
1099
  [[package]]
1100
1100
  name = "tokenfold-rag"
1101
- version = "0.3.1"
1101
+ version = "0.3.2"
1102
1102
 
1103
1103
  [[package]]
1104
1104
  name = "toml"
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["crates/tokenfold-core", "crates/tokenfold-py"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.3.1"
6
+ version = "0.3.2"
7
7
  edition = "2024"
8
8
  rust-version = "1.97"
9
9
  license = "Apache-2.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenfold
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: 3 :: Only
@@ -10,7 +10,9 @@ Summary: Token-compression toolkit for LLM payloads (Python binding over the tok
10
10
  Requires-Python: >=3.9
11
11
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
12
 
13
- # tokenfold
13
+ <div align="center">
14
+
15
+ # TOKENFOLD
14
16
 
15
17
  **Send less noise. Fit more context. Pay for fewer input tokens.**
16
18
 
@@ -20,6 +22,8 @@ Local, provider-neutral compression for prompts, tool schemas, JSON, logs, and d
20
22
 
21
23
  [Quick start](#quick-start) · [Why tokenfold](#why-tokenfold) · [Integrations](#pick-your-integration) · [Benchmarks](#reproduce-the-numbers)
22
24
 
25
+ </div>
26
+
23
27
  ---
24
28
 
25
29
  ## Proven compression, not projections
@@ -79,12 +83,21 @@ the canonical compression receipt:
79
83
  ```typescript
80
84
  import { compress } from "tokenfold";
81
85
 
86
+ const input = new TextEncoder().encode(JSON.stringify({
87
+ results: [
88
+ { id: 101, region: "us-east-1", plan: "pro" },
89
+ { id: 102, region: "us-east-1", plan: "pro" },
90
+ { id: 103, region: "us-east-1", plan: "pro" },
91
+ ],
92
+ }, null, 2));
93
+
82
94
  const { payload, report } = await compress(input, {
83
95
  format: "json",
84
96
  mode: "balanced",
85
97
  });
86
98
 
87
99
  console.log(`saved ${report.saved_tokens} tokens`);
100
+ console.log(new TextDecoder().decode(payload));
88
101
  ```
89
102
 
90
103
  Want to try the CLI from source? Inspect the bundled request without changing it:
@@ -96,10 +109,12 @@ cargo run --release --locked -p tokenfold-cli -- \
96
109
  inspect examples/openai_payload.json --format openai
97
110
  ```
98
111
 
112
+ Across 100 requests with the same payload shape, those savings add up to:
113
+
99
114
  ```text
100
- json_minify 346 → 229 saved 117
101
- schema_compaction 229 → 213 saved 16
102
- TOTAL 346 → 213 saved 133 (38.4% reduction, estimated)
115
+ json_minify 34,600 → 22,900 saved 11,700
116
+ schema_compaction 22,900 → 21,300 saved 1,600
117
+ TOTAL 34,600 → 21,300 saved 13,300 (38.4% reduction, estimated)
103
118
  ```
104
119
 
105
120
  ## Why tokenfold
@@ -231,13 +246,17 @@ or compact inputs may save little; Tokenfold reports that result honestly.
231
246
 
232
247
  ## Status
233
248
 
234
- Version **0.3.1** provides SHA-256-checksummed (not signed) CLI binaries for
235
- Linux, macOS, and Windows from [GitHub Releases](https://github.com/snchimata/tokenfold/releases/tag/v0.3.1),
236
- plus CycloneDX SBOMs. Registry packages are published to
237
- [PyPI](https://pypi.org/project/tokenfold/), [npm](https://www.npmjs.com/package/tokenfold),
238
- and [crates.io](https://crates.io/crates/tokenfold-core). npm installs the
239
- matching native binary package without a post-install download or local Rust
240
- build.
249
+ Version **0.3.1** is live on every supported distribution channel:
250
+
251
+ | Ecosystem | Published packages | Artifacts |
252
+ | --- | --- | --- |
253
+ | Python | [`tokenfold==0.3.1`](https://pypi.org/project/tokenfold/0.3.1/) | Source distribution and ABI3 wheels for Linux x64/ARM64, macOS x64/ARM64, and Windows x64 |
254
+ | TypeScript | [`tokenfold@0.3.1`](https://www.npmjs.com/package/tokenfold/v/0.3.1) | Typed Node.js API plus the matching `@tokenfold/cli-*` native package, with no post-install download or local Rust build |
255
+ | Rust | [`tokenfold-core`](https://crates.io/crates/tokenfold-core/0.3.1), [`tokenfold-output`](https://crates.io/crates/tokenfold-output/0.3.1), [`tokenfold-learn`](https://crates.io/crates/tokenfold-learn/0.3.1), and [`tokenfold-cli`](https://crates.io/crates/tokenfold-cli/0.3.1) | Source packages published in dependency order |
256
+
257
+ [GitHub release `v0.3.1`](https://github.com/snchimata/tokenfold/releases/tag/v0.3.1)
258
+ provides SHA-256-checksummed (not signed) CLI binaries for Linux, macOS, and
259
+ Windows, plus CycloneDX SBOMs.
241
260
 
242
261
  ## Contributing
243
262
 
@@ -1,4 +1,6 @@
1
- # tokenfold
1
+ <div align="center">
2
+
3
+ # TOKENFOLD
2
4
 
3
5
  **Send less noise. Fit more context. Pay for fewer input tokens.**
4
6
 
@@ -8,6 +10,8 @@ Local, provider-neutral compression for prompts, tool schemas, JSON, logs, and d
8
10
 
9
11
  [Quick start](#quick-start) · [Why tokenfold](#why-tokenfold) · [Integrations](#pick-your-integration) · [Benchmarks](#reproduce-the-numbers)
10
12
 
13
+ </div>
14
+
11
15
  ---
12
16
 
13
17
  ## Proven compression, not projections
@@ -67,12 +71,21 @@ the canonical compression receipt:
67
71
  ```typescript
68
72
  import { compress } from "tokenfold";
69
73
 
74
+ const input = new TextEncoder().encode(JSON.stringify({
75
+ results: [
76
+ { id: 101, region: "us-east-1", plan: "pro" },
77
+ { id: 102, region: "us-east-1", plan: "pro" },
78
+ { id: 103, region: "us-east-1", plan: "pro" },
79
+ ],
80
+ }, null, 2));
81
+
70
82
  const { payload, report } = await compress(input, {
71
83
  format: "json",
72
84
  mode: "balanced",
73
85
  });
74
86
 
75
87
  console.log(`saved ${report.saved_tokens} tokens`);
88
+ console.log(new TextDecoder().decode(payload));
76
89
  ```
77
90
 
78
91
  Want to try the CLI from source? Inspect the bundled request without changing it:
@@ -84,10 +97,12 @@ cargo run --release --locked -p tokenfold-cli -- \
84
97
  inspect examples/openai_payload.json --format openai
85
98
  ```
86
99
 
100
+ Across 100 requests with the same payload shape, those savings add up to:
101
+
87
102
  ```text
88
- json_minify 346 → 229 saved 117
89
- schema_compaction 229 → 213 saved 16
90
- TOTAL 346 → 213 saved 133 (38.4% reduction, estimated)
103
+ json_minify 34,600 → 22,900 saved 11,700
104
+ schema_compaction 22,900 → 21,300 saved 1,600
105
+ TOTAL 34,600 → 21,300 saved 13,300 (38.4% reduction, estimated)
91
106
  ```
92
107
 
93
108
  ## Why tokenfold
@@ -219,13 +234,17 @@ or compact inputs may save little; Tokenfold reports that result honestly.
219
234
 
220
235
  ## Status
221
236
 
222
- Version **0.3.1** provides SHA-256-checksummed (not signed) CLI binaries for
223
- Linux, macOS, and Windows from [GitHub Releases](https://github.com/snchimata/tokenfold/releases/tag/v0.3.1),
224
- plus CycloneDX SBOMs. Registry packages are published to
225
- [PyPI](https://pypi.org/project/tokenfold/), [npm](https://www.npmjs.com/package/tokenfold),
226
- and [crates.io](https://crates.io/crates/tokenfold-core). npm installs the
227
- matching native binary package without a post-install download or local Rust
228
- build.
237
+ Version **0.3.1** is live on every supported distribution channel:
238
+
239
+ | Ecosystem | Published packages | Artifacts |
240
+ | --- | --- | --- |
241
+ | Python | [`tokenfold==0.3.1`](https://pypi.org/project/tokenfold/0.3.1/) | Source distribution and ABI3 wheels for Linux x64/ARM64, macOS x64/ARM64, and Windows x64 |
242
+ | TypeScript | [`tokenfold@0.3.1`](https://www.npmjs.com/package/tokenfold/v/0.3.1) | Typed Node.js API plus the matching `@tokenfold/cli-*` native package, with no post-install download or local Rust build |
243
+ | Rust | [`tokenfold-core`](https://crates.io/crates/tokenfold-core/0.3.1), [`tokenfold-output`](https://crates.io/crates/tokenfold-output/0.3.1), [`tokenfold-learn`](https://crates.io/crates/tokenfold-learn/0.3.1), and [`tokenfold-cli`](https://crates.io/crates/tokenfold-cli/0.3.1) | Source packages published in dependency order |
244
+
245
+ [GitHub release `v0.3.1`](https://github.com/snchimata/tokenfold/releases/tag/v0.3.1)
246
+ provides SHA-256-checksummed (not signed) CLI binaries for Linux, macOS, and
247
+ Windows, plus CycloneDX SBOMs.
229
248
 
230
249
  ## Contributing
231
250
 
@@ -16,6 +16,10 @@ pub struct CompressionReport {
16
16
  pub format: String,
17
17
  pub task_scope: String,
18
18
  pub request_id: Option<String>,
19
+ /// F-055: staged `raw -> RTK -> tokenfold` accounting. `None` for the common
20
+ /// single-stage path; populated only by RTK-composed `wrap --rtk` runs.
21
+ #[serde(default)]
22
+ pub pipeline: Option<PipelineReport>,
19
23
  pub quality: Option<QualityReport>,
20
24
  pub budget: Option<BudgetReport>,
21
25
  pub cache: Option<CacheReport>,
@@ -61,6 +65,7 @@ impl CompressionReport {
61
65
  format,
62
66
  task_scope,
63
67
  request_id: None,
68
+ pipeline: None,
64
69
  quality: None,
65
70
  budget: None,
66
71
  cache: None,
@@ -82,6 +87,53 @@ pub struct EstimatorInfo {
82
87
  pub is_exact: bool,
83
88
  }
84
89
 
90
+ /// F-055: separates savings and recoverability across composed stages (RTK then
91
+ /// tokenfold) so RTK's savings are never credited to tokenfold. The top-level
92
+ /// `original_tokens` keeps its v1 meaning — tokens *entering* `tokenfold_core`,
93
+ /// which is the post-RTK count when composed. See INTERFACES.md §1.9 / §2.
94
+ #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
95
+ pub struct PipelineReport {
96
+ /// Pre-RTK byte count. `Some` only when a complete raw capture was observed.
97
+ pub raw_input_bytes: Option<usize>,
98
+ /// Pre-RTK token count. `Some` only when raw capture is complete.
99
+ pub raw_input_tokens: Option<usize>,
100
+ pub final_output_bytes: usize,
101
+ /// Equals top-level `compressed_tokens`.
102
+ pub final_output_tokens: usize,
103
+ /// Populated only when raw and final counts use the same estimator.
104
+ pub total_saved_tokens: Option<usize>,
105
+ /// `"complete"`, `"partial"`, `"unavailable"`, or `"not_applicable"`.
106
+ pub raw_capture: String,
107
+ /// `"full"`, `"tokenfold_only"`, `"none"`, or `"not_applicable"`.
108
+ pub upstream_recoverability: String,
109
+ pub stages: Vec<PipelineStageReport>,
110
+ }
111
+
112
+ /// F-055: one composed stage. Count fields are nullable because an unavailable
113
+ /// stage or missing pre-stage capture cannot be measured honestly.
114
+ #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
115
+ pub struct PipelineStageReport {
116
+ /// `"rtk"` or `"tokenfold"`.
117
+ pub id: String,
118
+ pub version: Option<String>,
119
+ pub input_bytes: Option<usize>,
120
+ pub output_bytes: Option<usize>,
121
+ pub saved_bytes: Option<usize>,
122
+ pub input_tokens: Option<usize>,
123
+ pub output_tokens: Option<usize>,
124
+ pub saved_tokens: Option<usize>,
125
+ pub estimator: Option<EstimatorInfo>,
126
+ /// `"applied"`, `"passthrough"`, `"unavailable"`, `"incompatible"`, or `"failed"`.
127
+ pub status: String,
128
+ pub duration_ms: Option<f64>,
129
+ pub bypass_reason: Option<String>,
130
+ /// e.g. `"external:rtk@0.4.1"` or `"tokenfold_core"`.
131
+ pub provenance: String,
132
+ /// `"full"`, `"partial"`, `"none"`, or `"not_applicable"`.
133
+ pub recoverability: String,
134
+ pub evidence_ref: Option<String>,
135
+ }
136
+
85
137
  #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
86
138
  pub struct BudgetReport {
87
139
  pub target_tokens: Option<usize>,
@@ -16,7 +16,7 @@ name = "tokenfold_py"
16
16
  crate-type = ["cdylib", "rlib"]
17
17
 
18
18
  [dependencies]
19
- tokenfold-core = { version = "0.3.1", path = "../tokenfold-core" }
19
+ tokenfold-core = { version = "0.3.2", path = "../tokenfold-core" }
20
20
  serde_json = { workspace = true }
21
21
  pyo3 = { version = "0.29.0", features = ["abi3-py39"] }
22
22
 
File without changes
File without changes