tokenpak 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.
- tokenpak-1.0.0/LICENSE +21 -0
- tokenpak-1.0.0/LICENSE_COMMERCIAL.md +108 -0
- tokenpak-1.0.0/PKG-INFO +517 -0
- tokenpak-1.0.0/README.md +441 -0
- tokenpak-1.0.0/pyproject.toml +146 -0
- tokenpak-1.0.0/setup.cfg +4 -0
- tokenpak-1.0.0/tests/test_ab_optimizer.py +525 -0
- tokenpak-1.0.0/tests/test_adapter_roundtrip.py +62 -0
- tokenpak-1.0.0/tests/test_adoption_killers.py +696 -0
- tokenpak-1.0.0/tests/test_agent_registry.py +417 -0
- tokenpak-1.0.0/tests/test_alias_compressor.py +223 -0
- tokenpak-1.0.0/tests/test_artifact_store_schemas.py +514 -0
- tokenpak-1.0.0/tests/test_async_proxy_server.py +362 -0
- tokenpak-1.0.0/tests/test_attribution.py +188 -0
- tokenpak-1.0.0/tests/test_autonomous_broker.py +374 -0
- tokenpak-1.0.0/tests/test_baseline_registry_delta_detector.py +383 -0
- tokenpak-1.0.0/tests/test_basic.py +69 -0
- tokenpak-1.0.0/tests/test_batch2_core_modules.py +458 -0
- tokenpak-1.0.0/tests/test_benchmark.py +313 -0
- tokenpak-1.0.0/tests/test_budget.py +213 -0
- tokenpak-1.0.0/tests/test_budget_controller.py +87 -0
- tokenpak-1.0.0/tests/test_budget_intelligence.py +195 -0
- tokenpak-1.0.0/tests/test_cache_e2e_determinism.py +514 -0
- tokenpak-1.0.0/tests/test_cache_optimizations.py +519 -0
- tokenpak-1.0.0/tests/test_cache_telemetry.py +263 -0
- tokenpak-1.0.0/tests/test_calibrator.py +347 -0
- tokenpak-1.0.0/tests/test_canon_session_fix.py +215 -0
- tokenpak-1.0.0/tests/test_capabilities.py +30 -0
- tokenpak-1.0.0/tests/test_capsule_builder.py +381 -0
- tokenpak-1.0.0/tests/test_capsule_builder_proxy_module.py +133 -0
- tokenpak-1.0.0/tests/test_capsule_integration.py +380 -0
- tokenpak-1.0.0/tests/test_chunk_shapes.py +354 -0
- tokenpak-1.0.0/tests/test_circuit_breaker.py +524 -0
- tokenpak-1.0.0/tests/test_citation_tracker.py +236 -0
- tokenpak-1.0.0/tests/test_claim_evidence_indexer.py +367 -0
- tokenpak-1.0.0/tests/test_claim_indexer.py +336 -0
- tokenpak-1.0.0/tests/test_classifier_first_router.py +514 -0
- tokenpak-1.0.0/tests/test_cli_proxy_integration.py +463 -0
- tokenpak-1.0.0/tests/test_cli_serve_smoke.py +152 -0
- tokenpak-1.0.0/tests/test_code_compaction_v2.py +406 -0
- tokenpak-1.0.0/tests/test_code_extractor.py +532 -0
- tokenpak-1.0.0/tests/test_compaction_modes.py +407 -0
- tokenpak-1.0.0/tests/test_compare_leaderboard.py +247 -0
- tokenpak-1.0.0/tests/test_compile_report.py +563 -0
- tokenpak-1.0.0/tests/test_compression_dictionary.py +229 -0
- tokenpak-1.0.0/tests/test_compression_ratio_regression.py +197 -0
- tokenpak-1.0.0/tests/test_compression_telemetry.py +323 -0
- tokenpak-1.0.0/tests/test_config.py +25 -0
- tokenpak-1.0.0/tests/test_connection_pool.py +463 -0
- tokenpak-1.0.0/tests/test_context_composer.py +340 -0
- tokenpak-1.0.0/tests/test_context_contracts.py +278 -0
- tokenpak-1.0.0/tests/test_context_handoff.py +359 -0
- tokenpak-1.0.0/tests/test_cooldown_manager.py +575 -0
- tokenpak-1.0.0/tests/test_cost_budget_cli.py +492 -0
- tokenpak-1.0.0/tests/test_cost_intelligence.py +519 -0
- tokenpak-1.0.0/tests/test_cost_tracker.py +162 -0
- tokenpak-1.0.0/tests/test_credential_passthrough.py +241 -0
- tokenpak-1.0.0/tests/test_cross_doc_normalization.py +470 -0
- tokenpak-1.0.0/tests/test_debug_logger.py +26 -0
- tokenpak-1.0.0/tests/test_debug_mode.py +187 -0
- tokenpak-1.0.0/tests/test_dedup.py +225 -0
- tokenpak-1.0.0/tests/test_deterministic_prompt_pack.py +494 -0
- tokenpak-1.0.0/tests/test_diff_command.py +219 -0
- tokenpak-1.0.0/tests/test_directives.py +503 -0
- tokenpak-1.0.0/tests/test_disclosure.py +95 -0
- tokenpak-1.0.0/tests/test_doc_extractor.py +590 -0
- tokenpak-1.0.0/tests/test_doctor.py +722 -0
- tokenpak-1.0.0/tests/test_document_parser.py +544 -0
- tokenpak-1.0.0/tests/test_e2e_proxy.py +300 -0
- tokenpak-1.0.0/tests/test_e2e_proxy_smoke.py +453 -0
- tokenpak-1.0.0/tests/test_enterprise_audit.py +350 -0
- tokenpak-1.0.0/tests/test_enterprise_policy_stubs.py +210 -0
- tokenpak-1.0.0/tests/test_entity_extraction_pipeline.py +66 -0
- tokenpak-1.0.0/tests/test_error_normalizer.py +50 -0
- tokenpak-1.0.0/tests/test_escalation.py +133 -0
- tokenpak-1.0.0/tests/test_exec_cli.py +86 -0
- tokenpak-1.0.0/tests/test_extractors_batch.py +261 -0
- tokenpak-1.0.0/tests/test_failover_engine.py +600 -0
- tokenpak-1.0.0/tests/test_failover_footer.py +277 -0
- tokenpak-1.0.0/tests/test_failover_provider_detection.py +500 -0
- tokenpak-1.0.0/tests/test_failover_translators.py +650 -0
- tokenpak-1.0.0/tests/test_failure_memory.py +243 -0
- tokenpak-1.0.0/tests/test_fidelity_tiers.py +383 -0
- tokenpak-1.0.0/tests/test_file_watcher.py +380 -0
- tokenpak-1.0.0/tests/test_fingerprint_sync.py +324 -0
- tokenpak-1.0.0/tests/test_fleet_command.py +349 -0
- tokenpak-1.0.0/tests/test_glossary.py +103 -0
- tokenpak-1.0.0/tests/test_goals.py +688 -0
- tokenpak-1.0.0/tests/test_graceful_degradation.py +356 -0
- tokenpak-1.0.0/tests/test_graceful_shutdown.py +423 -0
- tokenpak-1.0.0/tests/test_handoff_protocol.py +287 -0
- tokenpak-1.0.0/tests/test_ingest_proxy_v4.py +277 -0
- tokenpak-1.0.0/tests/test_integration_edge_calculation.py +233 -0
- tokenpak-1.0.0/tests/test_integration_feature_engineering.py +445 -0
- tokenpak-1.0.0/tests/test_integration_full_pipeline.py +434 -0
- tokenpak-1.0.0/tests/test_integration_probability_calibration.py +255 -0
- tokenpak-1.0.0/tests/test_integration_xml_parser.py +144 -0
- tokenpak-1.0.0/tests/test_intelligence_deep_health.py +438 -0
- tokenpak-1.0.0/tests/test_intelligence_security.py +343 -0
- tokenpak-1.0.0/tests/test_intent_classifier.py +358 -0
- tokenpak-1.0.0/tests/test_intent_example_selector.py +78 -0
- tokenpak-1.0.0/tests/test_intent_policy.py +240 -0
- tokenpak-1.0.0/tests/test_intent_state_schemas.py +282 -0
- tokenpak-1.0.0/tests/test_learning_store.py +464 -0
- tokenpak-1.0.0/tests/test_license_activation_flow.py +488 -0
- tokenpak-1.0.0/tests/test_license_admin_cli.py +349 -0
- tokenpak-1.0.0/tests/test_license_system.py +353 -0
- tokenpak-1.0.0/tests/test_locks.py +155 -0
- tokenpak-1.0.0/tests/test_log_extractor.py +532 -0
- tokenpak-1.0.0/tests/test_macro_engine.py +456 -0
- tokenpak-1.0.0/tests/test_macro_scheduler_hooks.py +285 -0
- tokenpak-1.0.0/tests/test_memory_promoter.py +381 -0
- tokenpak-1.0.0/tests/test_metrics_reporter.py +374 -0
- tokenpak-1.0.0/tests/test_miss_detector.py +381 -0
- tokenpak-1.0.0/tests/test_module_toggle_matrix.py +515 -0
- tokenpak-1.0.0/tests/test_oauth_routing.py +317 -0
- tokenpak-1.0.0/tests/test_obsidian_frontmatter.py +109 -0
- tokenpak-1.0.0/tests/test_optimize.py +192 -0
- tokenpak-1.0.0/tests/test_oss_recipes.py +293 -0
- tokenpak-1.0.0/tests/test_output_formatter.py +51 -0
- tokenpak-1.0.0/tests/test_passthrough.py +259 -0
- tokenpak-1.0.0/tests/test_phase3_integration.py +592 -0
- tokenpak-1.0.0/tests/test_phase5b_query_api.py +813 -0
- tokenpak-1.0.0/tests/test_platform_adapters.py +165 -0
- tokenpak-1.0.0/tests/test_post_run.py +130 -0
- tokenpak-1.0.0/tests/test_precompute.py +406 -0
- tokenpak-1.0.0/tests/test_precondition_gates.py +317 -0
- tokenpak-1.0.0/tests/test_prefetcher.py +52 -0
- tokenpak-1.0.0/tests/test_prefix_registry.py +317 -0
- tokenpak-1.0.0/tests/test_premade_macros.py +46 -0
- tokenpak-1.0.0/tests/test_preview_command.py +93 -0
- tokenpak-1.0.0/tests/test_privacy.py +382 -0
- tokenpak-1.0.0/tests/test_prometheus_metrics.py +379 -0
- tokenpak-1.0.0/tests/test_prompt_builder.py +178 -0
- tokenpak-1.0.0/tests/test_prompt_cache_breakpoints.py +78 -0
- tokenpak-1.0.0/tests/test_proxy_adapters.py +356 -0
- tokenpak-1.0.0/tests/test_proxy_endpoints.py +622 -0
- tokenpak-1.0.0/tests/test_proxy_error_paths.py +453 -0
- tokenpak-1.0.0/tests/test_proxy_health.py +280 -0
- tokenpak-1.0.0/tests/test_proxy_health_monitoring.py +531 -0
- tokenpak-1.0.0/tests/test_proxy_v4_cache_stats.py +54 -0
- tokenpak-1.0.0/tests/test_proxy_v4_endpoints.py +637 -0
- tokenpak-1.0.0/tests/test_proxy_v4_upstream_routes.py +81 -0
- tokenpak-1.0.0/tests/test_proxy_workflow_integration.py +377 -0
- tokenpak-1.0.0/tests/test_prune_retain.py +288 -0
- tokenpak-1.0.0/tests/test_quality_per_token.py +381 -0
- tokenpak-1.0.0/tests/test_query_rewriter.py +310 -0
- tokenpak-1.0.0/tests/test_recipe_sdk.py +295 -0
- tokenpak-1.0.0/tests/test_recipes_engine.py +409 -0
- tokenpak-1.0.0/tests/test_remaining_modules.py +541 -0
- tokenpak-1.0.0/tests/test_replay_cli.py +315 -0
- tokenpak-1.0.0/tests/test_replay_store.py +230 -0
- tokenpak-1.0.0/tests/test_report_alerts.py +509 -0
- tokenpak-1.0.0/tests/test_request_audit.py +252 -0
- tokenpak-1.0.0/tests/test_request_logging.py +386 -0
- tokenpak-1.0.0/tests/test_request_validation.py +594 -0
- tokenpak-1.0.0/tests/test_response_validation.py +409 -0
- tokenpak-1.0.0/tests/test_retrieval_scoring.py +302 -0
- tokenpak-1.0.0/tests/test_retrieval_scoring_coverage.py +325 -0
- tokenpak-1.0.0/tests/test_retrieval_watchdog.py +351 -0
- tokenpak-1.0.0/tests/test_retry.py +394 -0
- tokenpak-1.0.0/tests/test_router_e2e.py +162 -0
- tokenpak-1.0.0/tests/test_routing_fallback.py +310 -0
- tokenpak-1.0.0/tests/test_routing_rules.py +306 -0
- tokenpak-1.0.0/tests/test_runbook_generator.py +277 -0
- tokenpak-1.0.0/tests/test_salience_extractors.py +299 -0
- tokenpak-1.0.0/tests/test_savings_cmd.py +193 -0
- tokenpak-1.0.0/tests/test_schema_converter.py +121 -0
- tokenpak-1.0.0/tests/test_schema_extractor.py +335 -0
- tokenpak-1.0.0/tests/test_script_hooks.py +41 -0
- tokenpak-1.0.0/tests/test_security_hardening.py +326 -0
- tokenpak-1.0.0/tests/test_segmentizer_coverage.py +488 -0
- tokenpak-1.0.0/tests/test_semantic_cache.py +317 -0
- tokenpak-1.0.0/tests/test_semantic_map.py +378 -0
- tokenpak-1.0.0/tests/test_semantic_slicing.py +410 -0
- tokenpak-1.0.0/tests/test_serve_multiworker.py +332 -0
- tokenpak-1.0.0/tests/test_session_capsules.py +84 -0
- tokenpak-1.0.0/tests/test_setup_wizard.py +312 -0
- tokenpak-1.0.0/tests/test_shadow_mode.py +362 -0
- tokenpak-1.0.0/tests/test_shadow_reader.py +366 -0
- tokenpak-1.0.0/tests/test_skill_compiler.py +255 -0
- tokenpak-1.0.0/tests/test_slot_filler.py +713 -0
- tokenpak-1.0.0/tests/test_source_adapters.py +336 -0
- tokenpak-1.0.0/tests/test_stability_scorer.py +223 -0
- tokenpak-1.0.0/tests/test_stable_cache_wire.py +157 -0
- tokenpak-1.0.0/tests/test_stats_api.py +20 -0
- tokenpak-1.0.0/tests/test_stats_footer.py +247 -0
- tokenpak-1.0.0/tests/test_storage.py +448 -0
- tokenpak-1.0.0/tests/test_stream_translator.py +26 -0
- tokenpak-1.0.0/tests/test_streaming.py +537 -0
- tokenpak-1.0.0/tests/test_table_extractor.py +289 -0
- tokenpak-1.0.0/tests/test_teacher_pack_builder.py +55 -0
- tokenpak-1.0.0/tests/test_team_features.py +337 -0
- tokenpak-1.0.0/tests/test_tier1_integration.py +626 -0
- tokenpak-1.0.0/tests/test_tier2_integration.py +786 -0
- tokenpak-1.0.0/tests/test_tier_aware_help.py +228 -0
- tokenpak-1.0.0/tests/test_tiered_help.py +350 -0
- tokenpak-1.0.0/tests/test_timeline_dashboard.py +196 -0
- tokenpak-1.0.0/tests/test_tool_orchestration.py +306 -0
- tokenpak-1.0.0/tests/test_tool_schema_registry.py +224 -0
- tokenpak-1.0.0/tests/test_topic_aware_compaction.py +425 -0
- tokenpak-1.0.0/tests/test_trace.py +374 -0
- tokenpak-1.0.0/tests/test_trackedge.py +511 -0
- tokenpak-1.0.0/tests/test_trackedge_features.py +359 -0
- tokenpak-1.0.0/tests/test_trackedge_pace_speed.py +189 -0
- tokenpak-1.0.0/tests/test_treesitter.py +861 -0
- tokenpak-1.0.0/tests/test_trigger_cli.py +297 -0
- tokenpak-1.0.0/tests/test_triggers.py +411 -0
- tokenpak-1.0.0/tests/test_triggers_cali.py +153 -0
- tokenpak-1.0.0/tests/test_user_templates.py +205 -0
- tokenpak-1.0.0/tests/test_validation_framework.py +425 -0
- tokenpak-1.0.0/tests/test_validation_gate.py +68 -0
- tokenpak-1.0.0/tests/test_vault_indexer_full.py +91 -0
- tokenpak-1.0.0/tests/test_vendor_classifier.py +219 -0
- tokenpak-1.0.0/tests/test_workflow_budget.py +451 -0
- tokenpak-1.0.0/tests/test_workflow_cli.py +301 -0
- tokenpak-1.0.0/tests/test_workflow_performance.py +237 -0
- tokenpak-1.0.0/tokenpak/__init__.py +171 -0
- tokenpak-1.0.0/tokenpak/__main__.py +7 -0
- tokenpak-1.0.0/tokenpak/adapters/__init__.py +51 -0
- tokenpak-1.0.0/tokenpak/adapters/anthropic.py +258 -0
- tokenpak-1.0.0/tokenpak/adapters/base.py +212 -0
- tokenpak-1.0.0/tokenpak/adapters/langchain.py +174 -0
- tokenpak-1.0.0/tokenpak/adapters/litellm.py +192 -0
- tokenpak-1.0.0/tokenpak/adapters/openai.py +251 -0
- tokenpak-1.0.0/tokenpak/agent/__init__.py +1 -0
- tokenpak-1.0.0/tokenpak/agent/adapters/__init__.py +27 -0
- tokenpak-1.0.0/tokenpak/agent/adapters/base.py +59 -0
- tokenpak-1.0.0/tokenpak/agent/adapters/claude_cli.py +50 -0
- tokenpak-1.0.0/tokenpak/agent/adapters/generic.py +41 -0
- tokenpak-1.0.0/tokenpak/agent/adapters/openclaw.py +50 -0
- tokenpak-1.0.0/tokenpak/agent/adapters/registry.py +56 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/__init__.py +154 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/capabilities.py +269 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/error_normalizer.py +156 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/failure_memory.py +357 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/handoff.py +517 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/learning.py +894 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/locks.py +248 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/memory_promoter.py +304 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/precondition_gates.py +432 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/prefetcher.py +175 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/proxy_workflow.py +167 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/registry.py +211 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/retry.py +528 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/runbook_generator.py +446 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/skill_compiler.py +360 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/state_collector.py +389 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/test_workflow_performance.py +360 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/validation_framework.py +723 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/workflow.py +457 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/workflow_budget.py +363 -0
- tokenpak-1.0.0/tokenpak/agent/agentic/workflow_performance.py +285 -0
- tokenpak-1.0.0/tokenpak/agent/auth/__init__.py +0 -0
- tokenpak-1.0.0/tokenpak/agent/auth/cooldown_manager.py +246 -0
- tokenpak-1.0.0/tokenpak/agent/auth/oauth_manager.py +368 -0
- tokenpak-1.0.0/tokenpak/agent/cli/__init__.py +9 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/__init__.py +23 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/budget.py +633 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/compliance.py +134 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/compression.py +21 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/config.py +123 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/cost.py +403 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/dashboard.py +412 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/debug.py +52 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/diff.py +303 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/doctor.py +480 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/exec.py +198 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/fingerprint.py +209 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/handoff.py +231 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/help.py +324 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/index.py +111 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/last.py +119 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/license.py +121 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/maintenance.py +51 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/metrics.py +233 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/optimize.py +528 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/policy.py +172 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/preview.py +136 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/prune.py +232 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/replay.py +263 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/retain.py +219 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/route.py +36 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/savings.py +319 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/serve.py +99 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/sla.py +147 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/status.py +174 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/teacher.py +68 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/template.py +204 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/trigger.py +7 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/vault.py +32 -0
- tokenpak-1.0.0/tokenpak/agent/cli/commands/workflow.py +428 -0
- tokenpak-1.0.0/tokenpak/agent/cli/main.py +855 -0
- tokenpak-1.0.0/tokenpak/agent/cli/trigger_cmd.py +330 -0
- tokenpak-1.0.0/tokenpak/agent/compression/__init__.py +91 -0
- tokenpak-1.0.0/tokenpak/agent/compression/alias_compressor.py +309 -0
- tokenpak-1.0.0/tokenpak/agent/compression/canon.py +455 -0
- tokenpak-1.0.0/tokenpak/agent/compression/dedup.py +178 -0
- tokenpak-1.0.0/tokenpak/agent/compression/dictionary.py +307 -0
- tokenpak-1.0.0/tokenpak/agent/compression/directives.py +647 -0
- tokenpak-1.0.0/tokenpak/agent/compression/fidelity_tiers.py +545 -0
- tokenpak-1.0.0/tokenpak/agent/compression/instruction_table.py +219 -0
- tokenpak-1.0.0/tokenpak/agent/compression/pipeline.py +205 -0
- tokenpak-1.0.0/tokenpak/agent/compression/query_rewriter.py +365 -0
- tokenpak-1.0.0/tokenpak/agent/compression/recipes.py +637 -0
- tokenpak-1.0.0/tokenpak/agent/compression/salience/__init__.py +34 -0
- tokenpak-1.0.0/tokenpak/agent/compression/salience/code_extractor.py +269 -0
- tokenpak-1.0.0/tokenpak/agent/compression/salience/detect.py +70 -0
- tokenpak-1.0.0/tokenpak/agent/compression/salience/doc_extractor.py +147 -0
- tokenpak-1.0.0/tokenpak/agent/compression/salience/log_extractor.py +196 -0
- tokenpak-1.0.0/tokenpak/agent/compression/salience/router.py +128 -0
- tokenpak-1.0.0/tokenpak/agent/compression/schema_extractor.py +530 -0
- tokenpak-1.0.0/tokenpak/agent/compression/segmentizer.py +594 -0
- tokenpak-1.0.0/tokenpak/agent/compression/slot_filler.py +293 -0
- tokenpak-1.0.0/tokenpak/agent/config.py +166 -0
- tokenpak-1.0.0/tokenpak/agent/dashboard/__init__.py +6 -0
- tokenpak-1.0.0/tokenpak/agent/dashboard/export_api.py +120 -0
- tokenpak-1.0.0/tokenpak/agent/dashboard/export_csv.py +187 -0
- tokenpak-1.0.0/tokenpak/agent/dashboard/session_filter.py +260 -0
- tokenpak-1.0.0/tokenpak/agent/debug/__init__.py +6 -0
- tokenpak-1.0.0/tokenpak/agent/debug/logger.py +61 -0
- tokenpak-1.0.0/tokenpak/agent/debug/state.py +90 -0
- tokenpak-1.0.0/tokenpak/agent/fingerprint/__init__.py +22 -0
- tokenpak-1.0.0/tokenpak/agent/fingerprint/generator.py +207 -0
- tokenpak-1.0.0/tokenpak/agent/fingerprint/privacy.py +44 -0
- tokenpak-1.0.0/tokenpak/agent/fingerprint/sync.py +372 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/__init__.py +37 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/api.py +176 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/claim_indexer.py +276 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/cross_doc.py +784 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/disclosure.py +183 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/document_parser.py +861 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/schema_converter.py +134 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/table_extractor.py +464 -0
- tokenpak-1.0.0/tokenpak/agent/ingest/test_document_parser.py +400 -0
- tokenpak-1.0.0/tokenpak/agent/license/__init__.py +23 -0
- tokenpak-1.0.0/tokenpak/agent/license/activation.py +244 -0
- tokenpak-1.0.0/tokenpak/agent/license/admin_cli.py +267 -0
- tokenpak-1.0.0/tokenpak/agent/license/keys.py +188 -0
- tokenpak-1.0.0/tokenpak/agent/license/store.py +158 -0
- tokenpak-1.0.0/tokenpak/agent/license/validator.py +301 -0
- tokenpak-1.0.0/tokenpak/agent/macros/__init__.py +104 -0
- tokenpak-1.0.0/tokenpak/agent/macros/engine.py +550 -0
- tokenpak-1.0.0/tokenpak/agent/macros/hooks.py +454 -0
- tokenpak-1.0.0/tokenpak/agent/macros/premade_macros.py +225 -0
- tokenpak-1.0.0/tokenpak/agent/macros/scheduler.py +250 -0
- tokenpak-1.0.0/tokenpak/agent/macros/script_hooks.py +235 -0
- tokenpak-1.0.0/tokenpak/agent/memory/__init__.py +17 -0
- tokenpak-1.0.0/tokenpak/agent/memory/session_capsules.py +150 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/__init__.py +35 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/capsule_builder.py +80 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/capsule_integration.py +242 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/circuit_breaker.py +349 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/connection_pool.py +448 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/degradation.py +183 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/example_selector.py +139 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/failover.py +301 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/failover_engine.py +642 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/intent_policy.py +551 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/oauth.py +274 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/passthrough.py +273 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/prompt_builder.py +1088 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/__init__.py +22 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/anthropic.py +229 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/detector.py +183 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/google.py +144 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/openai.py +164 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/stream_translator.py +540 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/providers/translator.py +784 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/proxy.py +62 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/router.py +308 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/server.py +1553 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/server_async.py +1006 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/startup.py +131 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/stats.py +240 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/stats_api.py +49 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/streaming.py +181 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/test_prompt_pack.py +352 -0
- tokenpak-1.0.0/tokenpak/agent/proxy/tool_schema_registry.py +242 -0
- tokenpak-1.0.0/tokenpak/agent/query/__init__.py +1 -0
- tokenpak-1.0.0/tokenpak/agent/query/api.py +408 -0
- tokenpak-1.0.0/tokenpak/agent/recipe_sdk.py +687 -0
- tokenpak-1.0.0/tokenpak/agent/regression/__init__.py +58 -0
- tokenpak-1.0.0/tokenpak/agent/regression/artifact_reuse.py +161 -0
- tokenpak-1.0.0/tokenpak/agent/regression/baseline_registry.py +95 -0
- tokenpak-1.0.0/tokenpak/agent/regression/classifier.py +119 -0
- tokenpak-1.0.0/tokenpak/agent/regression/delta_detector.py +189 -0
- tokenpak-1.0.0/tokenpak/agent/regression/feature_detector.py +168 -0
- tokenpak-1.0.0/tokenpak/agent/regression/retrieval_watchdog.py +437 -0
- tokenpak-1.0.0/tokenpak/agent/regression/stability_scorer.py +330 -0
- tokenpak-1.0.0/tokenpak/agent/regression/tests/test_classifier.py +86 -0
- tokenpak-1.0.0/tokenpak/agent/routing/__init__.py +1 -0
- tokenpak-1.0.0/tokenpak/agent/routing/fallback.py +248 -0
- tokenpak-1.0.0/tokenpak/agent/routing/rules.py +24 -0
- tokenpak-1.0.0/tokenpak/agent/semantic/__init__.py +38 -0
- tokenpak-1.0.0/tokenpak/agent/semantic/term_card_builder.py +492 -0
- tokenpak-1.0.0/tokenpak/agent/semantic/term_resolver.py +343 -0
- tokenpak-1.0.0/tokenpak/agent/semantic/test_proxy_integration.py +342 -0
- tokenpak-1.0.0/tokenpak/agent/semantic/test_term_resolver.py +438 -0
- tokenpak-1.0.0/tokenpak/agent/state_schemas/__init__.py +37 -0
- tokenpak-1.0.0/tokenpak/agent/teacher/__init__.py +5 -0
- tokenpak-1.0.0/tokenpak/agent/teacher/builder.py +217 -0
- tokenpak-1.0.0/tokenpak/agent/team/__init__.py +17 -0
- tokenpak-1.0.0/tokenpak/agent/team/agent_registry.py +223 -0
- tokenpak-1.0.0/tokenpak/agent/team/shared_vault.py +221 -0
- tokenpak-1.0.0/tokenpak/agent/team/templates.py +242 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/__init__.py +35 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/budget.py +389 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/collector.py +194 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/cost_tracker.py +256 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/demo.py +40 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/footer.py +103 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/replay.py +299 -0
- tokenpak-1.0.0/tokenpak/agent/telemetry/storage.py +154 -0
- tokenpak-1.0.0/tokenpak/agent/triggers/__init__.py +7 -0
- tokenpak-1.0.0/tokenpak/agent/triggers/daemon.py +192 -0
- tokenpak-1.0.0/tokenpak/agent/triggers/matcher.py +58 -0
- tokenpak-1.0.0/tokenpak/agent/triggers/store.py +103 -0
- tokenpak-1.0.0/tokenpak/agent/vault/__init__.py +27 -0
- tokenpak-1.0.0/tokenpak/agent/vault/ast_parser.py +245 -0
- tokenpak-1.0.0/tokenpak/agent/vault/blocks.py +290 -0
- tokenpak-1.0.0/tokenpak/agent/vault/chunk_shapes.py +376 -0
- tokenpak-1.0.0/tokenpak/agent/vault/indexer.py +202 -0
- tokenpak-1.0.0/tokenpak/agent/vault/retrieval.py +524 -0
- tokenpak-1.0.0/tokenpak/agent/vault/scoring.py +256 -0
- tokenpak-1.0.0/tokenpak/agent/vault/slicer.py +263 -0
- tokenpak-1.0.0/tokenpak/agent/vault/sqlite_retrieval.py +530 -0
- tokenpak-1.0.0/tokenpak/agent/vault/symbols.py +168 -0
- tokenpak-1.0.0/tokenpak/agent/vault/watcher.py +338 -0
- tokenpak-1.0.0/tokenpak/alerts.py +295 -0
- tokenpak-1.0.0/tokenpak/api/__init__.py +10 -0
- tokenpak-1.0.0/tokenpak/api/routes.py +185 -0
- tokenpak-1.0.0/tokenpak/artifact_store.py +431 -0
- tokenpak-1.0.0/tokenpak/assembler.py +337 -0
- tokenpak-1.0.0/tokenpak/attribution.py +263 -0
- tokenpak-1.0.0/tokenpak/benchmark.py +1405 -0
- tokenpak-1.0.0/tokenpak/broker.py +298 -0
- tokenpak-1.0.0/tokenpak/budget.py +90 -0
- tokenpak-1.0.0/tokenpak/budget_controller.py +149 -0
- tokenpak-1.0.0/tokenpak/budgeter.py +417 -0
- tokenpak-1.0.0/tokenpak/cache/__init__.py +72 -0
- tokenpak-1.0.0/tokenpak/cache/prefix_registry.py +224 -0
- tokenpak-1.0.0/tokenpak/cache/registry.py +121 -0
- tokenpak-1.0.0/tokenpak/cache/semantic_cache.py +341 -0
- tokenpak-1.0.0/tokenpak/cache/stable_cache.py +125 -0
- tokenpak-1.0.0/tokenpak/cache/telemetry.py +356 -0
- tokenpak-1.0.0/tokenpak/cache/volatile_cache.py +122 -0
- tokenpak-1.0.0/tokenpak/cache_report.py +50 -0
- tokenpak-1.0.0/tokenpak/calibration.py +187 -0
- tokenpak-1.0.0/tokenpak/calibrator.py +346 -0
- tokenpak-1.0.0/tokenpak/capsule/__init__.py +15 -0
- tokenpak-1.0.0/tokenpak/capsule/builder.py +362 -0
- tokenpak-1.0.0/tokenpak/citation_tracker.py +200 -0
- tokenpak-1.0.0/tokenpak/cli.py +5533 -0
- tokenpak-1.0.0/tokenpak/cli_doctor.py +198 -0
- tokenpak-1.0.0/tokenpak/compaction/__init__.py +54 -0
- tokenpak-1.0.0/tokenpak/compaction/modes.py +229 -0
- tokenpak-1.0.0/tokenpak/compaction/policy.py +282 -0
- tokenpak-1.0.0/tokenpak/compaction/topic_aware.py +345 -0
- tokenpak-1.0.0/tokenpak/compiler.py +207 -0
- tokenpak-1.0.0/tokenpak/complexity.py +309 -0
- tokenpak-1.0.0/tokenpak/config_loader.py +265 -0
- tokenpak-1.0.0/tokenpak/config_validator.py +294 -0
- tokenpak-1.0.0/tokenpak/connectors/__init__.py +42 -0
- tokenpak-1.0.0/tokenpak/connectors/base.py +95 -0
- tokenpak-1.0.0/tokenpak/connectors/base_source.py +81 -0
- tokenpak-1.0.0/tokenpak/connectors/git_adapter.py +110 -0
- tokenpak-1.0.0/tokenpak/connectors/github.py +174 -0
- tokenpak-1.0.0/tokenpak/connectors/google_drive.py +133 -0
- tokenpak-1.0.0/tokenpak/connectors/local.py +70 -0
- tokenpak-1.0.0/tokenpak/connectors/notion.py +181 -0
- tokenpak-1.0.0/tokenpak/connectors/notion_adapter.py +186 -0
- tokenpak-1.0.0/tokenpak/connectors/obsidian.py +109 -0
- tokenpak-1.0.0/tokenpak/connectors/url_adapter.py +153 -0
- tokenpak-1.0.0/tokenpak/context_composer.py +274 -0
- tokenpak-1.0.0/tokenpak/core.py +342 -0
- tokenpak-1.0.0/tokenpak/daily_report.py +212 -0
- tokenpak-1.0.0/tokenpak/dashboard/__init__.py +47 -0
- tokenpak-1.0.0/tokenpak/elo.py +164 -0
- tokenpak-1.0.0/tokenpak/engines/__init__.py +28 -0
- tokenpak-1.0.0/tokenpak/engines/base.py +42 -0
- tokenpak-1.0.0/tokenpak/engines/heuristic.py +45 -0
- tokenpak-1.0.0/tokenpak/engines/llmlingua.py +80 -0
- tokenpak-1.0.0/tokenpak/enterprise/__init__.py +10 -0
- tokenpak-1.0.0/tokenpak/enterprise/audit.py +413 -0
- tokenpak-1.0.0/tokenpak/enterprise/compliance.py +529 -0
- tokenpak-1.0.0/tokenpak/enterprise/governance.py +240 -0
- tokenpak-1.0.0/tokenpak/enterprise/policy.py +211 -0
- tokenpak-1.0.0/tokenpak/enterprise/sla.py +228 -0
- tokenpak-1.0.0/tokenpak/escalation.py +122 -0
- tokenpak-1.0.0/tokenpak/evidence_pack.py +236 -0
- tokenpak-1.0.0/tokenpak/extraction/__init__.py +13 -0
- tokenpak-1.0.0/tokenpak/extraction/extractor.py +161 -0
- tokenpak-1.0.0/tokenpak/extraction/models.py +88 -0
- tokenpak-1.0.0/tokenpak/extraction/patterns.py +41 -0
- tokenpak-1.0.0/tokenpak/fleet.py +282 -0
- tokenpak-1.0.0/tokenpak/formatting/__init__.py +4 -0
- tokenpak-1.0.0/tokenpak/formatting/colors.py +33 -0
- tokenpak-1.0.0/tokenpak/formatting/formatter.py +56 -0
- tokenpak-1.0.0/tokenpak/formatting/modes.py +19 -0
- tokenpak-1.0.0/tokenpak/formatting/symbols.py +19 -0
- tokenpak-1.0.0/tokenpak/goals.py +492 -0
- tokenpak-1.0.0/tokenpak/handlers/__init__.py +1 -0
- tokenpak-1.0.0/tokenpak/handlers/rate_limit.py +73 -0
- tokenpak-1.0.0/tokenpak/integrations/__init__.py +1 -0
- tokenpak-1.0.0/tokenpak/integrations/litellm/__init__.py +38 -0
- tokenpak-1.0.0/tokenpak/integrations/litellm/formatter.py +158 -0
- tokenpak-1.0.0/tokenpak/integrations/litellm/middleware.py +182 -0
- tokenpak-1.0.0/tokenpak/integrations/litellm/parser.py +76 -0
- tokenpak-1.0.0/tokenpak/integrations/litellm/proxy.py +156 -0
- tokenpak-1.0.0/tokenpak/intelligence/__init__.py +1 -0
- tokenpak-1.0.0/tokenpak/intelligence/ab_optimizer.py +631 -0
- tokenpak-1.0.0/tokenpak/intelligence/ab_router.py +244 -0
- tokenpak-1.0.0/tokenpak/intelligence/auth.py +313 -0
- tokenpak-1.0.0/tokenpak/intelligence/cost_intelligence.py +435 -0
- tokenpak-1.0.0/tokenpak/intelligence/cost_router.py +264 -0
- tokenpak-1.0.0/tokenpak/intelligence/deep_health.py +369 -0
- tokenpak-1.0.0/tokenpak/intelligence/license_endpoint.py +156 -0
- tokenpak-1.0.0/tokenpak/intelligence/server.py +366 -0
- tokenpak-1.0.0/tokenpak/intent_classifier.py +434 -0
- tokenpak-1.0.0/tokenpak/middleware/__init__.py +56 -0
- tokenpak-1.0.0/tokenpak/middleware/audit_trail.py +175 -0
- tokenpak-1.0.0/tokenpak/middleware/logger.py +237 -0
- tokenpak-1.0.0/tokenpak/middleware/logging_middleware.py +209 -0
- tokenpak-1.0.0/tokenpak/middleware/semantic_cache_middleware.py +153 -0
- tokenpak-1.0.0/tokenpak/middleware/tests/__init__.py +0 -0
- tokenpak-1.0.0/tokenpak/middleware/tests/conftest.py +10 -0
- tokenpak-1.0.0/tokenpak/middleware/tests/test_audit_trail.py +220 -0
- tokenpak-1.0.0/tokenpak/middleware/tests/test_logger.py +294 -0
- tokenpak-1.0.0/tokenpak/middleware/tests/test_logging_middleware.py +138 -0
- tokenpak-1.0.0/tokenpak/miss_detector.py +461 -0
- tokenpak-1.0.0/tokenpak/monitoring/__init__.py +21 -0
- tokenpak-1.0.0/tokenpak/monitoring/audit_trail.py +165 -0
- tokenpak-1.0.0/tokenpak/monitoring/health.py +217 -0
- tokenpak-1.0.0/tokenpak/monitoring/metrics.py +386 -0
- tokenpak-1.0.0/tokenpak/monitoring/request_logger.py +517 -0
- tokenpak-1.0.0/tokenpak/pack.py +455 -0
- tokenpak-1.0.0/tokenpak/post_run.py +268 -0
- tokenpak-1.0.0/tokenpak/precompute.py +634 -0
- tokenpak-1.0.0/tokenpak/pricing.py +143 -0
- tokenpak-1.0.0/tokenpak/processors/__init__.py +38 -0
- tokenpak-1.0.0/tokenpak/processors/code.py +474 -0
- tokenpak-1.0.0/tokenpak/processors/code_treesitter.py +532 -0
- tokenpak-1.0.0/tokenpak/processors/data.py +137 -0
- tokenpak-1.0.0/tokenpak/processors/text.py +195 -0
- tokenpak-1.0.0/tokenpak/profiles.py +129 -0
- tokenpak-1.0.0/tokenpak/proxy/__init__.py +3 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/__init__.py +34 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/anthropic_adapter.py +115 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/base.py +179 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/canonical.py +34 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/google_adapter.py +129 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/openai_chat_adapter.py +89 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/openai_responses_adapter.py +114 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/passthrough_adapter.py +76 -0
- tokenpak-1.0.0/tokenpak/proxy/adapters/registry.py +42 -0
- tokenpak-1.0.0/tokenpak/proxy/credential_passthrough.py +283 -0
- tokenpak-1.0.0/tokenpak/py.typed +0 -0
- tokenpak-1.0.0/tokenpak/reference_fetcher.py +151 -0
- tokenpak-1.0.0/tokenpak/reference_scanner.py +124 -0
- tokenpak-1.0.0/tokenpak/registry.py +326 -0
- tokenpak-1.0.0/tokenpak/report.py +299 -0
- tokenpak-1.0.0/tokenpak/request_audit.py +211 -0
- tokenpak-1.0.0/tokenpak/routing/__init__.py +3 -0
- tokenpak-1.0.0/tokenpak/routing/rules.py +359 -0
- tokenpak-1.0.0/tokenpak/routing_ledger.py +268 -0
- tokenpak-1.0.0/tokenpak/schemas/__init__.py +8 -0
- tokenpak-1.0.0/tokenpak/schemas/artifact.py +76 -0
- tokenpak-1.0.0/tokenpak/schemas/chunk.py +66 -0
- tokenpak-1.0.0/tokenpak/schemas/retrieval_cache.py +87 -0
- tokenpak-1.0.0/tokenpak/schemas/source_map.py +69 -0
- tokenpak-1.0.0/tokenpak/security.py +216 -0
- tokenpak-1.0.0/tokenpak/semantic/__init__.py +27 -0
- tokenpak-1.0.0/tokenpak/semantic/loader.py +213 -0
- tokenpak-1.0.0/tokenpak/semantic/resolver.py +292 -0
- tokenpak-1.0.0/tokenpak/shadow_hook.py +157 -0
- tokenpak-1.0.0/tokenpak/shadow_reader.py +558 -0
- tokenpak-1.0.0/tokenpak/span_extractor.py +227 -0
- tokenpak-1.0.0/tokenpak/state_manager.py +388 -0
- tokenpak-1.0.0/tokenpak/telemetry/__init__.py +35 -0
- tokenpak-1.0.0/tokenpak/telemetry/adapters/__init__.py +33 -0
- tokenpak-1.0.0/tokenpak/telemetry/adapters/anthropic.py +199 -0
- tokenpak-1.0.0/tokenpak/telemetry/adapters/base.py +93 -0
- tokenpak-1.0.0/tokenpak/telemetry/adapters/gemini.py +229 -0
- tokenpak-1.0.0/tokenpak/telemetry/adapters/openai.py +231 -0
- tokenpak-1.0.0/tokenpak/telemetry/adapters/registry.py +194 -0
- tokenpak-1.0.0/tokenpak/telemetry/anon_metrics.py +274 -0
- tokenpak-1.0.0/tokenpak/telemetry/api.py +189 -0
- tokenpak-1.0.0/tokenpak/telemetry/cache.py +229 -0
- tokenpak-1.0.0/tokenpak/telemetry/canonical.py +166 -0
- tokenpak-1.0.0/tokenpak/telemetry/collector.py +213 -0
- tokenpak-1.0.0/tokenpak/telemetry/config.py +108 -0
- tokenpak-1.0.0/tokenpak/telemetry/cost.py +659 -0
- tokenpak-1.0.0/tokenpak/telemetry/dashboard/__init__.py +8 -0
- tokenpak-1.0.0/tokenpak/telemetry/dashboard/dashboard.py +1053 -0
- tokenpak-1.0.0/tokenpak/telemetry/dashboard/pagination.py +127 -0
- tokenpak-1.0.0/tokenpak/telemetry/dashboard/query_builder.py +213 -0
- tokenpak-1.0.0/tokenpak/telemetry/event_schema.py +365 -0
- tokenpak-1.0.0/tokenpak/telemetry/insights.py +511 -0
- tokenpak-1.0.0/tokenpak/telemetry/integrity/__init__.py +0 -0
- tokenpak-1.0.0/tokenpak/telemetry/integrity/anomalies.py +353 -0
- tokenpak-1.0.0/tokenpak/telemetry/integrity/reconciliation.py +209 -0
- tokenpak-1.0.0/tokenpak/telemetry/integrity/validation.py +249 -0
- tokenpak-1.0.0/tokenpak/telemetry/milestones.py +391 -0
- tokenpak-1.0.0/tokenpak/telemetry/models.py +344 -0
- tokenpak-1.0.0/tokenpak/telemetry/operational/__init__.py +0 -0
- tokenpak-1.0.0/tokenpak/telemetry/operational/api.py +229 -0
- tokenpak-1.0.0/tokenpak/telemetry/operational/health.py +176 -0
- tokenpak-1.0.0/tokenpak/telemetry/operational/metrics.py +158 -0
- tokenpak-1.0.0/tokenpak/telemetry/operational/pruning.py +166 -0
- tokenpak-1.0.0/tokenpak/telemetry/pipeline.py +364 -0
- tokenpak-1.0.0/tokenpak/telemetry/pipeline_trace.py +106 -0
- tokenpak-1.0.0/tokenpak/telemetry/pricing.py +419 -0
- tokenpak-1.0.0/tokenpak/telemetry/prometheus.py +371 -0
- tokenpak-1.0.0/tokenpak/telemetry/proxy_trace_integration.py +170 -0
- tokenpak-1.0.0/tokenpak/telemetry/query.py +259 -0
- tokenpak-1.0.0/tokenpak/telemetry/query_models.py +50 -0
- tokenpak-1.0.0/tokenpak/telemetry/reporter.py +172 -0
- tokenpak-1.0.0/tokenpak/telemetry/response_models.py +259 -0
- tokenpak-1.0.0/tokenpak/telemetry/rollups.py +641 -0
- tokenpak-1.0.0/tokenpak/telemetry/segmentizer.py +1020 -0
- tokenpak-1.0.0/tokenpak/telemetry/server.py +1055 -0
- tokenpak-1.0.0/tokenpak/telemetry/settings.py +160 -0
- tokenpak-1.0.0/tokenpak/telemetry/stats.py +178 -0
- tokenpak-1.0.0/tokenpak/telemetry/storage.py +1314 -0
- tokenpak-1.0.0/tokenpak/telemetry/storage_base.py +314 -0
- tokenpak-1.0.0/tokenpak/telemetry/storage_events.py +231 -0
- tokenpak-1.0.0/tokenpak/telemetry/storage_rollups.py +340 -0
- tokenpak-1.0.0/tokenpak/telemetry/storage_segments.py +88 -0
- tokenpak-1.0.0/tokenpak/telemetry/storage_usage.py +361 -0
- tokenpak-1.0.0/tokenpak/tests/test_config_validation.py +472 -0
- tokenpak-1.0.0/tokenpak/tests/test_config_validation_simple.py +205 -0
- tokenpak-1.0.0/tokenpak/tests/test_config_validator_edge_cases.py +350 -0
- tokenpak-1.0.0/tokenpak/tests/test_cost_cache_module.py +606 -0
- tokenpak-1.0.0/tokenpak/tests/test_cost_integration.py +420 -0
- tokenpak-1.0.0/tokenpak/tests/test_proxy_integration.py +88 -0
- tokenpak-1.0.0/tokenpak/tests/test_proxy_module.py +359 -0
- tokenpak-1.0.0/tokenpak/tests/test_routing_integration.py +23 -0
- tokenpak-1.0.0/tokenpak/tests/test_savings_display.py +249 -0
- tokenpak-1.0.0/tokenpak/tests/test_schemas_integration.py +79 -0
- tokenpak-1.0.0/tokenpak/tests/test_telemetry_integration.py +278 -0
- tokenpak-1.0.0/tokenpak/tests/test_validation_gate_integration.py +382 -0
- tokenpak-1.0.0/tokenpak/timeline.py +206 -0
- tokenpak-1.0.0/tokenpak/tokens.py +134 -0
- tokenpak-1.0.0/tokenpak/trace.py +404 -0
- tokenpak-1.0.0/tokenpak/user_templates.py +199 -0
- tokenpak-1.0.0/tokenpak/validation/__init__.py +63 -0
- tokenpak-1.0.0/tokenpak/validation/frontmatter.py +120 -0
- tokenpak-1.0.0/tokenpak/validation/request_schema.py +289 -0
- tokenpak-1.0.0/tokenpak/validation/request_validator.py +620 -0
- tokenpak-1.0.0/tokenpak/validation/response_schema.py +120 -0
- tokenpak-1.0.0/tokenpak/validation/validator.py +326 -0
- tokenpak-1.0.0/tokenpak/validation_gate.py +145 -0
- tokenpak-1.0.0/tokenpak/validator.py +470 -0
- tokenpak-1.0.0/tokenpak/vendor_classifier.py +166 -0
- tokenpak-1.0.0/tokenpak/version_check.py +147 -0
- tokenpak-1.0.0/tokenpak/walker.py +82 -0
- tokenpak-1.0.0/tokenpak/watchdog.py +329 -0
- tokenpak-1.0.0/tokenpak/wire.py +62 -0
- tokenpak-1.0.0/tokenpak/workflow_performance.py +321 -0
- tokenpak-1.0.0/tokenpak.egg-info/PKG-INFO +517 -0
- tokenpak-1.0.0/tokenpak.egg-info/SOURCES.txt +664 -0
- tokenpak-1.0.0/tokenpak.egg-info/dependency_links.txt +1 -0
- tokenpak-1.0.0/tokenpak.egg-info/entry_points.txt +3 -0
- tokenpak-1.0.0/tokenpak.egg-info/requires.txt +23 -0
- tokenpak-1.0.0/tokenpak.egg-info/top_level.txt +1 -0
tokenpak-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TokenPak Contributors
|
|
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,108 @@
|
|
|
1
|
+
# TokenPak Commercial License
|
|
2
|
+
|
|
3
|
+
This document describes the commercial licensing terms for TokenPak Pro, Team, and Enterprise editions.
|
|
4
|
+
|
|
5
|
+
## Open Source (TokenPak OSS)
|
|
6
|
+
|
|
7
|
+
TokenPak OSS is licensed under the MIT License. See [LICENSE](./LICENSE) for details.
|
|
8
|
+
|
|
9
|
+
You may use TokenPak OSS for any purpose, including commercial applications, without charge or restriction.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Commercial Editions
|
|
14
|
+
|
|
15
|
+
### TokenPak Pro
|
|
16
|
+
|
|
17
|
+
**Monthly subscription: $99/month**
|
|
18
|
+
|
|
19
|
+
Pro license grants:
|
|
20
|
+
- Access to TokenPak Cloud Dashboard
|
|
21
|
+
- Managed API proxy service
|
|
22
|
+
- Advanced analytics and reporting
|
|
23
|
+
- Priority email support (24-48hr response)
|
|
24
|
+
- All OSS features
|
|
25
|
+
|
|
26
|
+
**Terms:**
|
|
27
|
+
- Per-seat licensing (1 developer per license)
|
|
28
|
+
- Monthly or annual billing (annual = 2 months free)
|
|
29
|
+
- Cancel anytime
|
|
30
|
+
- No refunds for partial months
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### TokenPak Team
|
|
35
|
+
|
|
36
|
+
**Monthly subscription: $299/month (up to 10 users)**
|
|
37
|
+
|
|
38
|
+
Team license grants:
|
|
39
|
+
- All Pro features
|
|
40
|
+
- Multi-user collaboration
|
|
41
|
+
- Team billing and invoicing
|
|
42
|
+
- Role-based access control
|
|
43
|
+
- Shared dashboards and reports
|
|
44
|
+
- Slack integration for alerts
|
|
45
|
+
|
|
46
|
+
**Terms:**
|
|
47
|
+
- Base plan includes 10 seats
|
|
48
|
+
- Additional seats: $25/user/month
|
|
49
|
+
- Annual billing available (2 months free)
|
|
50
|
+
- Cancel anytime
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### TokenPak Enterprise
|
|
55
|
+
|
|
56
|
+
**Custom pricing**
|
|
57
|
+
|
|
58
|
+
Enterprise license grants:
|
|
59
|
+
- All Team features
|
|
60
|
+
- Self-hosted deployment option
|
|
61
|
+
- On-premises installation support
|
|
62
|
+
- Custom integrations (Datadog, Splunk, etc.)
|
|
63
|
+
- Dedicated support engineer
|
|
64
|
+
- SLA with uptime guarantees
|
|
65
|
+
- Compliance documentation (SOC2, HIPAA, GDPR)
|
|
66
|
+
- Volume discounts
|
|
67
|
+
|
|
68
|
+
**Terms:**
|
|
69
|
+
- Annual contracts (minimum 1 year)
|
|
70
|
+
- Custom pricing based on scale and requirements
|
|
71
|
+
- Contact sales@tokenpak.ai for quote
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Usage Restrictions (Commercial Editions)
|
|
76
|
+
|
|
77
|
+
Commercial licenses **do not** permit:
|
|
78
|
+
|
|
79
|
+
1. Reselling or sublicensing TokenPak as a standalone product
|
|
80
|
+
2. Removing or obscuring TokenPak branding in managed services
|
|
81
|
+
3. Using Pro/Team features in competing compression products
|
|
82
|
+
4. Sharing credentials across organizations
|
|
83
|
+
|
|
84
|
+
## Ownership
|
|
85
|
+
|
|
86
|
+
TokenPak and all commercial features remain the intellectual property of TokenPak Inc. Commercial licenses grant usage rights only, not ownership.
|
|
87
|
+
|
|
88
|
+
## Support
|
|
89
|
+
|
|
90
|
+
| Tier | Support Channel | Response Time |
|
|
91
|
+
|------|-----------------|---------------|
|
|
92
|
+
| OSS | GitHub Issues | Community (no SLA) |
|
|
93
|
+
| Pro | Email | 24-48 hours |
|
|
94
|
+
| Team | Email + Slack | 12-24 hours |
|
|
95
|
+
| Enterprise | Dedicated + Phone | 4 hours (critical) |
|
|
96
|
+
|
|
97
|
+
## Upgrades and Downgrades
|
|
98
|
+
|
|
99
|
+
- Upgrade from OSS → Pro: Instant, self-service
|
|
100
|
+
- Upgrade from Pro → Team: Prorated billing
|
|
101
|
+
- Downgrade: Takes effect next billing cycle
|
|
102
|
+
- Enterprise → lower tier: Contact sales
|
|
103
|
+
|
|
104
|
+
## Questions?
|
|
105
|
+
|
|
106
|
+
- Email: licensing@tokenpak.ai
|
|
107
|
+
- Sales: sales@tokenpak.ai
|
|
108
|
+
- Documentation: https://docs.tokenpak.ai
|
tokenpak-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokenpak
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Slash LLM costs with intelligent context compression, smart routing, and cost tracking
|
|
5
|
+
Author-email: Kevin Yang <kaywhy331@gmail.com>
|
|
6
|
+
Maintainer-email: Kevin Yang <kaywhy331@gmail.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 TokenPak Contributors
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/tokenpak/tokenpak
|
|
30
|
+
Project-URL: Documentation, https://github.com/tokenpak/tokenpak/blob/main/README.md
|
|
31
|
+
Project-URL: Bug Reports, https://github.com/tokenpak/tokenpak/issues
|
|
32
|
+
Project-URL: Source Code, https://github.com/tokenpak/tokenpak
|
|
33
|
+
Project-URL: Changelog, https://github.com/tokenpak/tokenpak/blob/main/CHANGELOG.md
|
|
34
|
+
Keywords: llm,ai,proxy,token-optimization,openai,anthropic,compression,context,context-window,tokens,cost-tracking,routing
|
|
35
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
36
|
+
Classifier: Intended Audience :: Developers
|
|
37
|
+
Classifier: Intended Audience :: Science/Research
|
|
38
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
39
|
+
Classifier: Operating System :: OS Independent
|
|
40
|
+
Classifier: Programming Language :: Python :: 3
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
45
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
46
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
47
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
48
|
+
Classifier: Topic :: System :: Networking
|
|
49
|
+
Classifier: Topic :: Utilities
|
|
50
|
+
Classifier: Typing :: Typed
|
|
51
|
+
Requires-Python: >=3.10
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
License-File: LICENSE
|
|
54
|
+
License-File: LICENSE_COMMERCIAL.md
|
|
55
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
56
|
+
Requires-Dist: pyyaml>=6.0
|
|
57
|
+
Requires-Dist: click>=8.1.0
|
|
58
|
+
Requires-Dist: starlette>=0.36.0
|
|
59
|
+
Requires-Dist: uvicorn>=0.27.0
|
|
60
|
+
Requires-Dist: httpx>=0.26.0
|
|
61
|
+
Requires-Dist: h2<5,>=3
|
|
62
|
+
Requires-Dist: watchdog>=3.0.0
|
|
63
|
+
Provides-Extra: dev
|
|
64
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
65
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
66
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
67
|
+
Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
|
|
68
|
+
Requires-Dist: black>=24.0.0; extra == "dev"
|
|
69
|
+
Requires-Dist: ruff>=0.2.0; extra == "dev"
|
|
70
|
+
Provides-Extra: tokens
|
|
71
|
+
Requires-Dist: tiktoken>=0.5.0; extra == "tokens"
|
|
72
|
+
Provides-Extra: docs
|
|
73
|
+
Requires-Dist: mkdocs>=1.5.0; extra == "docs"
|
|
74
|
+
Requires-Dist: mkdocs-material>=9.5.0; extra == "docs"
|
|
75
|
+
Dynamic: license-file
|
|
76
|
+
|
|
77
|
+
# TokenPak
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+

|
|
81
|
+

|
|
82
|
+

|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
> **Zero-token operations. Maximum context efficiency.**
|
|
86
|
+
|
|
87
|
+
TokenPak is an open-source LLM proxy agent that compresses context, routes requests intelligently, and tracks costs — all without touching your prompts or credentials.
|
|
88
|
+
|
|
89
|
+
**Protocol spec (v1.0):**
|
|
90
|
+
- 📜 Spec: [`docs/PROTOCOL.md`](docs/PROTOCOL.md)
|
|
91
|
+
- ✅ Schema: [`schemas/tokenpak-v1.0.json`](schemas/tokenpak-v1.0.json)
|
|
92
|
+
- 🧪 Validator: [`tokenpak/validator.py`](tokenpak/validator.py)
|
|
93
|
+
- 🧩 Examples: [`examples/`](examples/)
|
|
94
|
+
|
|
95
|
+
[](https://github.com/tokenpak/tokenpak/actions)
|
|
96
|
+
[](https://pypi.org/project/tokenpak/)
|
|
97
|
+
[](https://pypi.org/project/tokenpak/)
|
|
98
|
+
[](https://pepy.tech/project/tokenpak)
|
|
99
|
+
[](LICENSE)
|
|
100
|
+
[](https://codecov.io/gh/tokenpak/tokenpak)
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 3 Commands to Savings
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install tokenpak # install
|
|
108
|
+
tokenpak serve --port 8766 --workers 4 # start proxy (4 CPU cores)
|
|
109
|
+
tokenpak cost --week # watch savings grow
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Point your LLM client's base URL at `http://localhost:8766`. That's it — **zero config required.**
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## See It In Action
|
|
117
|
+
|
|
118
|
+

|
|
119
|
+
|
|
120
|
+
> **48.9% token reduction** — across real payloads, zero config. 5,074 → 2,594 tokens in <1ms.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## What It Does
|
|
125
|
+
|
|
126
|
+
- **Compresses context** before it hits the API — fewer tokens, lower cost
|
|
127
|
+
- **Routes requests** to the right model (fast/cheap vs. powerful/expensive)
|
|
128
|
+
- **Tracks costs** locally — per model, per session, per agent
|
|
129
|
+
- **Indexes your vault** for instant semantic search without an LLM call
|
|
130
|
+
- **80%+ of operations cost zero tokens** — CLI-first, deterministic
|
|
131
|
+
|
|
132
|
+
## Core Principles
|
|
133
|
+
|
|
134
|
+
| Principle | What it means |
|
|
135
|
+
|-----------|---------------|
|
|
136
|
+
| **Zero Data** | We never see your prompts, code, or responses |
|
|
137
|
+
| **Zero Credentials** | Pure passthrough proxy — no API keys stored |
|
|
138
|
+
| **Zero Lock-in** | Downgrade anytime; keep all your data |
|
|
139
|
+
| **Zero Tokens for Ops** | Status, search, cost reports — all free |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
144
|
+
|
|
145
|
+
```mermaid
|
|
146
|
+
graph LR
|
|
147
|
+
subgraph Your Machine
|
|
148
|
+
Client["LLM Client\n(Claude Code / OpenAI SDK)"]
|
|
149
|
+
Proxy["TokenPak Proxy\n:8766"]
|
|
150
|
+
Vault["Local Vault\n(semantic index)"]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
subgraph Pipeline
|
|
154
|
+
P1["① Segment\nSplit into blocks"]
|
|
155
|
+
P2["② Fingerprint\nDetect type"]
|
|
156
|
+
P3["③ Compress\nApply recipe"]
|
|
157
|
+
P4["④ Budget\nPrioritize tokens"]
|
|
158
|
+
P5["⑤ Assemble\nRebuild prompt"]
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
subgraph Routing
|
|
162
|
+
R1["Route Rules\n(model/prefix/tokens)"]
|
|
163
|
+
R2["Provider A\n(OpenAI)"]
|
|
164
|
+
R3["Provider B\n(Anthropic)"]
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
Client -->|"request"| Proxy
|
|
168
|
+
Proxy --> R1
|
|
169
|
+
R1 -->|"rule match"| R2
|
|
170
|
+
R1 -->|"fallback"| R3
|
|
171
|
+
Proxy --> P1 --> P2 --> P3 --> P4 --> P5
|
|
172
|
+
Proxy <-->|"zero-token search"| Vault
|
|
173
|
+
P5 -->|"compressed request"| R2
|
|
174
|
+
R2 -->|"response"| Client
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Key insight:** The compression pipeline runs locally, before the request leaves your machine. The LLM never sees your raw tokens — only the compressed version.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Plans
|
|
182
|
+
|
|
183
|
+
| Feature | OSS | Pro | Team |
|
|
184
|
+
|---|:---:|:---:|:---:|
|
|
185
|
+
| Context compression | ✅ | ✅ | ✅ |
|
|
186
|
+
| Model routing | ✅ | ✅ | ✅ |
|
|
187
|
+
| Cost tracking | ✅ | ✅ | ✅ |
|
|
188
|
+
| Vault indexing + search | ✅ | ✅ | ✅ |
|
|
189
|
+
| CLI + proxy | ✅ | ✅ | ✅ |
|
|
190
|
+
| A/B testing | ✅ | ✅ | ✅ |
|
|
191
|
+
| Replay + debug | ✅ | ✅ | ✅ |
|
|
192
|
+
| Advanced compression recipes | — | ✅ | ✅ |
|
|
193
|
+
| Budget enforcement + alerts | — | ✅ | ✅ |
|
|
194
|
+
| Priority support | — | ✅ | ✅ |
|
|
195
|
+
| Multi-agent coordination | — | — | ✅ |
|
|
196
|
+
| Shared vault (team) | — | — | ✅ |
|
|
197
|
+
| RBAC + audit logs | — | — | ✅ |
|
|
198
|
+
| Seat management | — | — | ✅ |
|
|
199
|
+
| SSO / enterprise auth | — | — | ✅ |
|
|
200
|
+
| On-premises deployment | — | — | ✅ |
|
|
201
|
+
| **Price** | **Free** | **$99/mo** | **$299/mo** |
|
|
202
|
+
|
|
203
|
+
**Enterprise:** Custom pricing for large organizations. [Contact sales](mailto:sales@tokenpak.ai).
|
|
204
|
+
|
|
205
|
+
[→ View full pricing](docs/PRODUCT_STRATEGY.md#product-tiers) | [→ License details](LICENSE_COMMERCIAL.md)
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Token Savings (QMD + TokenPak)
|
|
210
|
+
|
|
211
|
+
| Configuration | Avg tokens/req | Reduction |
|
|
212
|
+
|---|---:|---:|
|
|
213
|
+
| Baseline (no optimization) | 20,801 | — |
|
|
214
|
+
| QMD only | 6,136 | 70% |
|
|
215
|
+
| QMD + TokenPak | 3,265 | **84%** |
|
|
216
|
+
|
|
217
|
+
Consistent **~43% additional savings** on top of QMD across writing, coding, legal, and ops tasks.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Performance
|
|
222
|
+
|
|
223
|
+
TokenPak is engineered for speed. Compilation must feel free — if it adds perceptible latency, developers won't adopt it.
|
|
224
|
+
|
|
225
|
+
### Compile Latency Targets
|
|
226
|
+
|
|
227
|
+
| Pack Size | Blocks | Tokens | p50 target | p95 hard limit |
|
|
228
|
+
|-----------|--------|--------|------------|----------------|
|
|
229
|
+
| **Small** | 2–3 | ~500 | < 20ms | < 30ms |
|
|
230
|
+
| **Medium** | ~10 | ~5,000 | < 30ms | < 50ms |
|
|
231
|
+
| **Large** | ~50 | ~50,000 | < 50ms | < 100ms |
|
|
232
|
+
|
|
233
|
+
Latency gates are **enforced in CI on every PR** — p95 breaches block merge.
|
|
234
|
+
|
|
235
|
+
### Run Benchmarks
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Full benchmark suite with pytest-benchmark
|
|
239
|
+
pytest tests/benchmarks/ -v --benchmark-json=benchmark.json
|
|
240
|
+
|
|
241
|
+
# Check thresholds (CI gate)
|
|
242
|
+
python scripts/check_benchmark_thresholds.py benchmark.json
|
|
243
|
+
|
|
244
|
+
# View latency summary
|
|
245
|
+
pytest tests/benchmarks/test_compile_performance.py::TestCompilePerformancePlain::test_all_three_packs_summary -s
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Internal Optimizations
|
|
249
|
+
|
|
250
|
+
| Optimization | Improvement |
|
|
251
|
+
|---|---|
|
|
252
|
+
| LRU token cache | **25x** faster repeated counting |
|
|
253
|
+
| Batch SQLite transactions | **60%** faster indexing |
|
|
254
|
+
| Pre-compiled regex | **30%** faster processing |
|
|
255
|
+
| Connection pooling + WAL | Reduced I/O overhead |
|
|
256
|
+
|
|
257
|
+
**Benchmark (572-file vault):**
|
|
258
|
+
```
|
|
259
|
+
Indexing throughput: 2,738 files/sec
|
|
260
|
+
Indexing speedup: 55x faster than baseline
|
|
261
|
+
Search latency: 22.7ms/query
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Adoption Ladder — Use One Feature First
|
|
267
|
+
|
|
268
|
+
TokenPak is designed for incremental adoption. You don't need to adopt the full system.
|
|
269
|
+
Start with one feature and grow from there.
|
|
270
|
+
|
|
271
|
+
| Level | What you get | Import |
|
|
272
|
+
|-------|-------------|--------|
|
|
273
|
+
| **1 — Token counting** | Count tokens in any string | `from tokenpak import count_tokens` |
|
|
274
|
+
| **2 — Simple packing** | Pack a prompt in one call | `from tokenpak import pack_prompt` |
|
|
275
|
+
| **3 — Block-based context** | Priority + quality control | `from tokenpak import ContextPack, PackBlock` |
|
|
276
|
+
| **4 — Full protocol** | Compile reports + all output formats | `compiled.to_messages()` / `compiled.to_anthropic()` |
|
|
277
|
+
| **5 — Wire format** | Serialize for cross-agent transfer | `compiled.to_json()` |
|
|
278
|
+
|
|
279
|
+
### Level 1: Token counting (zero config)
|
|
280
|
+
|
|
281
|
+
```python
|
|
282
|
+
from tokenpak import count_tokens
|
|
283
|
+
|
|
284
|
+
tokens = count_tokens("My prompt text")
|
|
285
|
+
print(f"{tokens} tokens")
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Level 2: Simple packing (one function)
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
from tokenpak import pack_prompt
|
|
292
|
+
|
|
293
|
+
prompt = pack_prompt(
|
|
294
|
+
system="You are a helpful assistant.",
|
|
295
|
+
docs=my_large_docs, # high priority — kept first
|
|
296
|
+
history=chat_history, # low priority — trimmed if needed
|
|
297
|
+
budget=8000,
|
|
298
|
+
)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Level 3: Block-based context
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
from tokenpak import ContextPack, PackBlock
|
|
305
|
+
|
|
306
|
+
pack = ContextPack(budget=8000)
|
|
307
|
+
pack.add(PackBlock(id="system", type="instructions", content=system_prompt, priority="critical"))
|
|
308
|
+
pack.add(PackBlock(id="docs", type="knowledge", content=api_docs, priority="high"))
|
|
309
|
+
pack.add(PackBlock(id="search", type="evidence", content=results, priority="medium", quality=0.8))
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Level 4: Full protocol
|
|
313
|
+
|
|
314
|
+
```python
|
|
315
|
+
compiled = pack.compile()
|
|
316
|
+
|
|
317
|
+
# Works with OpenAI
|
|
318
|
+
from openai import OpenAI
|
|
319
|
+
OpenAI().chat.completions.create(model="gpt-4o", messages=compiled.to_messages())
|
|
320
|
+
|
|
321
|
+
# Works with Anthropic
|
|
322
|
+
from anthropic import Anthropic
|
|
323
|
+
system, messages = compiled.to_anthropic()
|
|
324
|
+
Anthropic().messages.create(model="claude-3-5-sonnet-latest", system=system, messages=messages)
|
|
325
|
+
|
|
326
|
+
# Works with LiteLLM / Ollama (same format)
|
|
327
|
+
from litellm import completion
|
|
328
|
+
completion(model="ollama/mistral", messages=compiled.to_messages())
|
|
329
|
+
|
|
330
|
+
# Inspect every decision
|
|
331
|
+
print(compiled.report)
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Level 5: Wire format
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
import json
|
|
338
|
+
|
|
339
|
+
payload = json.dumps(compiled.to_json()) # serialize
|
|
340
|
+
recovered = json.loads(payload) # deserialize anywhere
|
|
341
|
+
print(recovered["text"]) # compiled prompt
|
|
342
|
+
print(recovered["report"]["summary"]) # compile stats
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
> **Key guarantee:** Every level works independently. Level 3 does not require Level 4.
|
|
346
|
+
> The SDK works with no gateway, no cloud, and no required external dependencies.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## How Compression Works
|
|
351
|
+
|
|
352
|
+
TokenPak intercepts requests before they reach the LLM and applies a multi-stage pipeline:
|
|
353
|
+
|
|
354
|
+
1. **Segmentize** — split content into semantic blocks
|
|
355
|
+
2. **Fingerprint** — identify block type (code, docs, config…)
|
|
356
|
+
3. **Apply recipe** — use declarative rules to compress that block type
|
|
357
|
+
4. **Budget** — allocate tokens using a quadratic priority algorithm
|
|
358
|
+
5. **Assemble** — reconstruct the compressed prompt
|
|
359
|
+
|
|
360
|
+
Result: same semantic content, 20–60% fewer tokens.
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## CLI Reference
|
|
365
|
+
|
|
366
|
+
### Core
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
tokenpak serve --port 8766 [--workers N] # start proxy (default: cpu_count//2 workers)
|
|
370
|
+
tokenpak status [--full] # proxy health
|
|
371
|
+
tokenpak cost [--week|--month] # cost report
|
|
372
|
+
tokenpak savings [--lifetime] # token savings summary
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Compression & Debug
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
tokenpak compress <file> # dry-run compression
|
|
379
|
+
tokenpak demo [--verbose] # see pipeline on real data
|
|
380
|
+
tokenpak trace [--id <id>] # trace a pipeline run
|
|
381
|
+
tokenpak debug on # capture raw/compressed pairs
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Vault & Indexing
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
tokenpak index [<path>] # index a directory
|
|
388
|
+
tokenpak vault search "query" # semantic search (zero tokens)
|
|
389
|
+
tokenpak calibrate ~/vault # auto-tune workers for this host
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Model Routing
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
tokenpak route add --model 'gpt-4*' --target anthropic/claude-3-haiku-20240307
|
|
396
|
+
tokenpak route list
|
|
397
|
+
tokenpak route test "write unit tests"
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Templates & Replay
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
tokenpak template list
|
|
404
|
+
tokenpak template use my-tpl
|
|
405
|
+
tokenpak replay list
|
|
406
|
+
tokenpak replay <id> --diff
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## Directory Structure
|
|
412
|
+
|
|
413
|
+
```
|
|
414
|
+
tokenpak/
|
|
415
|
+
├── tokenpak/
|
|
416
|
+
│ ├── agent/
|
|
417
|
+
│ │ ├── compression/ # pipeline, segmentizer, recipes, directives
|
|
418
|
+
│ │ ├── proxy/ # request routing + streaming
|
|
419
|
+
│ │ ├── routing/ # manual route rules
|
|
420
|
+
│ │ ├── telemetry/ # cost tracking, storage
|
|
421
|
+
│ │ ├── vault/ # indexer, ast_parser, symbols
|
|
422
|
+
│ │ ├── license/ # key generation, validation, store
|
|
423
|
+
│ │ └── team/ # multi-agent coordination, shared vault
|
|
424
|
+
│ ├── engines/
|
|
425
|
+
│ │ ├── heuristic.py # Rule-based compaction
|
|
426
|
+
│ │ └── llmlingua.py # ML-powered compaction (optional)
|
|
427
|
+
│ └── processors/
|
|
428
|
+
│ ├── code.py # Python/JS structure extraction
|
|
429
|
+
│ ├── text.py # Markdown/HTML compression
|
|
430
|
+
│ └── data.py # JSON/YAML/CSV handling
|
|
431
|
+
├── portal/ # self-service web portal
|
|
432
|
+
├── recipes/oss/ # built-in compression recipes (YAML)
|
|
433
|
+
├── tests/
|
|
434
|
+
└── pyproject.toml
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Configuration
|
|
440
|
+
|
|
441
|
+
Default config: `~/.tokenpak/config.json`
|
|
442
|
+
|
|
443
|
+
```json
|
|
444
|
+
{
|
|
445
|
+
"proxy": {
|
|
446
|
+
"port": 8766,
|
|
447
|
+
"passthrough_url": "https://api.openai.com"
|
|
448
|
+
},
|
|
449
|
+
"compression": {
|
|
450
|
+
"enabled": true,
|
|
451
|
+
"level": "balanced"
|
|
452
|
+
},
|
|
453
|
+
"budget": {
|
|
454
|
+
"monthly_usd": null,
|
|
455
|
+
"alert_at_pct": 80
|
|
456
|
+
},
|
|
457
|
+
"vault": {
|
|
458
|
+
"db_path": ".tokenpak/registry.db",
|
|
459
|
+
"watch": false
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
## Requirements
|
|
467
|
+
|
|
468
|
+
- Python 3.10+
|
|
469
|
+
- No external dependencies for core functionality
|
|
470
|
+
- Optional: `tiktoken` for accurate token counting
|
|
471
|
+
- Optional: `llmlingua` for ML-powered compression
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Contributing
|
|
476
|
+
|
|
477
|
+
We welcome issues, pull requests, and feedback of all kinds!
|
|
478
|
+
|
|
479
|
+
- 🐛 **Bug reports** → [Open an issue](https://github.com/tokenpak/tokenpak/issues/new?template=bug_report.md)
|
|
480
|
+
- 💡 **Feature requests** → [Request a feature](https://github.com/tokenpak/tokenpak/issues/new?template=feature_request.md)
|
|
481
|
+
- 💬 **Questions & ideas** → [GitHub Discussions](https://github.com/tokenpak/tokenpak/discussions)
|
|
482
|
+
- 📖 **Full guide** → [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
483
|
+
- 📋 **Version history** → [CHANGELOG.md](CHANGELOG.md)
|
|
484
|
+
|
|
485
|
+
### Quick setup
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
git clone https://github.com/tokenpak/tokenpak
|
|
489
|
+
cd tokenpak
|
|
490
|
+
pip install -e ".[dev]"
|
|
491
|
+
pytest tests/ -q
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Dual-remote push (required for CI)
|
|
495
|
+
|
|
496
|
+
TokenPak uses two remotes: `origin` (GitHub) and `shared` (internal QA). Always push with the verified script:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
bash scripts/push-verified.sh
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
This pushes to both remotes and SSH-verifies the commit hash landed. **Never use bare `git push origin`** — the QA remote will be skipped.
|
|
503
|
+
|
|
504
|
+
### Guidelines
|
|
505
|
+
|
|
506
|
+
- All new features need tests (`tests/test_<module>.py`)
|
|
507
|
+
- Keep CLI commands backward-compatible
|
|
508
|
+
- Compression recipes live in `recipes/oss/` as YAML
|
|
509
|
+
- Run `pytest tests/ -q` before opening a PR
|
|
510
|
+
- See [ARCHITECTURE.md](ARCHITECTURE.md) for system design
|
|
511
|
+
- See [CHANGELOG.md](CHANGELOG.md) for version history and release notes
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## License
|
|
516
|
+
|
|
517
|
+
MIT — see [LICENSE](LICENSE)
|