@oneciel-ai/ciel-runtime 0.2.2 → 0.2.4

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 (136) hide show
  1. package/ciel_runtime.py +2555 -9635
  2. package/ciel_runtime_support/advisor_request_builder.py +8 -21
  3. package/ciel_runtime_support/anthropic_tool_turns.py +13 -8
  4. package/ciel_runtime_support/architecture.py +68 -0
  5. package/ciel_runtime_support/architecture_budget.py +1 -1
  6. package/ciel_runtime_support/channel_connection_context.py +233 -0
  7. package/ciel_runtime_support/channel_delivery_context.py +332 -0
  8. package/ciel_runtime_support/channel_mcp_context.py +313 -0
  9. package/ciel_runtime_support/channel_mcp_discovery.py +47 -0
  10. package/ciel_runtime_support/channel_mcp_transport.py +5 -1
  11. package/ciel_runtime_support/channel_message_context.py +212 -0
  12. package/ciel_runtime_support/channel_message_repository.py +14 -3
  13. package/ciel_runtime_support/channel_pending_injection.py +9 -0
  14. package/ciel_runtime_support/channel_probe_launch_context.py +213 -0
  15. package/ciel_runtime_support/channel_replay_policy.py +38 -0
  16. package/ciel_runtime_support/channel_runtime_environment.py +8 -0
  17. package/ciel_runtime_support/channel_session_context.py +236 -0
  18. package/ciel_runtime_support/channel_terminal_context.py +350 -0
  19. package/ciel_runtime_support/channel_wake_context.py +532 -0
  20. package/ciel_runtime_support/claude_environment.py +60 -0
  21. package/ciel_runtime_support/claude_launch_assembly.py +249 -0
  22. package/ciel_runtime_support/claude_router.py +62 -12
  23. package/ciel_runtime_support/cli_application_context.py +132 -0
  24. package/ciel_runtime_support/cli_assembly.py +50 -0
  25. package/ciel_runtime_support/codex_backend_context.py +363 -0
  26. package/ciel_runtime_support/codex_config.py +13 -1
  27. package/ciel_runtime_support/codex_launch_assembly.py +213 -0
  28. package/ciel_runtime_support/codex_launch_configuration.py +30 -1
  29. package/ciel_runtime_support/codex_mcp_integration.py +90 -8
  30. package/ciel_runtime_support/codex_model_catalog.py +4 -1
  31. package/ciel_runtime_support/codex_reasoning_rejects.py +225 -0
  32. package/ciel_runtime_support/codex_router.py +38 -8
  33. package/ciel_runtime_support/codex_turn_recovery.py +154 -0
  34. package/ciel_runtime_support/config_migrations.py +103 -0
  35. package/ciel_runtime_support/config_repository.py +30 -0
  36. package/ciel_runtime_support/configuration_cli.py +38 -0
  37. package/ciel_runtime_support/context_compaction.py +9 -4
  38. package/ciel_runtime_support/credential_management.py +12 -0
  39. package/ciel_runtime_support/credentials.py +12 -0
  40. package/ciel_runtime_support/github_copilot_oauth.py +2 -2
  41. package/ciel_runtime_support/hosted_formula_tools.py +216 -0
  42. package/ciel_runtime_support/kimi_runtime_context.py +208 -0
  43. package/ciel_runtime_support/llm_preset_context.py +338 -0
  44. package/ciel_runtime_support/managed_mcp_config.py +8 -4
  45. package/ciel_runtime_support/mcp_configuration_context.py +291 -0
  46. package/ciel_runtime_support/mcp_http_proxy.py +14 -8
  47. package/ciel_runtime_support/mcp_probe_transport.py +47 -15
  48. package/ciel_runtime_support/mcp_transport.py +14 -1
  49. package/ciel_runtime_support/native_context_recovery.py +72 -0
  50. package/ciel_runtime_support/ollama_catalog_context.py +213 -0
  51. package/ciel_runtime_support/ollama_stream_collection.py +103 -0
  52. package/ciel_runtime_support/ollama_thinking.py +6 -1
  53. package/ciel_runtime_support/ollama_wire_projection.py +157 -0
  54. package/ciel_runtime_support/openai_forwarding.py +32 -10
  55. package/ciel_runtime_support/openai_responses_router.py +12 -0
  56. package/ciel_runtime_support/package_lifecycle.py +39 -0
  57. package/ciel_runtime_support/prelaunch_assembly.py +37 -0
  58. package/ciel_runtime_support/prelaunch_panel_context.py +418 -0
  59. package/ciel_runtime_support/prelaunch_shell_context.py +394 -0
  60. package/ciel_runtime_support/prompt_compaction.py +144 -0
  61. package/ciel_runtime_support/prompt_injection.py +45 -0
  62. package/ciel_runtime_support/protocols/anthropic_thinking_policy.py +1 -1
  63. package/ciel_runtime_support/protocols/chat_projection.py +85 -5
  64. package/ciel_runtime_support/protocols/conversation_turn_policy.py +43 -0
  65. package/ciel_runtime_support/protocols/ollama_chat.py +31 -0
  66. package/ciel_runtime_support/protocols/ollama_response.py +57 -5
  67. package/ciel_runtime_support/protocols/openai_reasoning.py +5 -2
  68. package/ciel_runtime_support/protocols/openai_responses.py +61 -15
  69. package/ciel_runtime_support/provider_adapters.py +26 -0
  70. package/ciel_runtime_support/provider_administration_context.py +207 -0
  71. package/ciel_runtime_support/provider_config_mutations.py +3 -0
  72. package/ciel_runtime_support/provider_model_catalog_context.py +137 -0
  73. package/ciel_runtime_support/provider_model_context.py +107 -0
  74. package/ciel_runtime_support/provider_model_metadata_context.py +197 -0
  75. package/ciel_runtime_support/provider_model_selection.py +10 -3
  76. package/ciel_runtime_support/provider_models.py +45 -2
  77. package/ciel_runtime_support/provider_option_cli.py +19 -0
  78. package/ciel_runtime_support/provider_policy.py +1 -1
  79. package/ciel_runtime_support/provider_readiness_context.py +189 -0
  80. package/ciel_runtime_support/provider_request_builder.py +64 -28
  81. package/ciel_runtime_support/provider_responses_passthrough.py +21 -2
  82. package/ciel_runtime_support/provider_timeout_policy.py +54 -0
  83. package/ciel_runtime_support/provider_tool_policy.py +9 -1
  84. package/ciel_runtime_support/providers/__init__.py +6 -0
  85. package/ciel_runtime_support/providers/alibaba.py +634 -0
  86. package/ciel_runtime_support/providers/catalog.py +24 -16
  87. package/ciel_runtime_support/providers/deepseek.py +73 -0
  88. package/ciel_runtime_support/providers/github_copilot_oauth.py +22 -1
  89. package/ciel_runtime_support/providers/kimi.py +69 -9
  90. package/ciel_runtime_support/providers/ollama.py +8 -0
  91. package/ciel_runtime_support/providers/ollama_context.py +21 -2
  92. package/ciel_runtime_support/providers/vllm.py +7 -1
  93. package/ciel_runtime_support/response_collection.py +68 -18
  94. package/ciel_runtime_support/response_collection_context.py +391 -0
  95. package/ciel_runtime_support/response_stream_context.py +555 -0
  96. package/ciel_runtime_support/responses_input_compatibility.py +121 -0
  97. package/ciel_runtime_support/responses_usage_observer.py +83 -0
  98. package/ciel_runtime_support/router_client_lifecycle.py +1 -0
  99. package/ciel_runtime_support/router_http.py +245 -3
  100. package/ciel_runtime_support/router_observability_context.py +251 -0
  101. package/ciel_runtime_support/router_process_context.py +200 -0
  102. package/ciel_runtime_support/router_process_lifecycle.py +2 -0
  103. package/ciel_runtime_support/router_request_assembly.py +399 -0
  104. package/ciel_runtime_support/router_request_context.py +215 -0
  105. package/ciel_runtime_support/router_server_context.py +84 -0
  106. package/ciel_runtime_support/runaway_output_guard.py +488 -0
  107. package/ciel_runtime_support/runtime_asset_assembly.py +147 -0
  108. package/ciel_runtime_support/runtime_asset_context.py +297 -0
  109. package/ciel_runtime_support/runtime_constants.py +16 -1
  110. package/ciel_runtime_support/runtime_launch.py +9 -5
  111. package/ciel_runtime_support/runtime_launch_context.py +130 -0
  112. package/ciel_runtime_support/runtime_maintenance_assembly.py +60 -0
  113. package/ciel_runtime_support/runtime_maintenance_context.py +309 -0
  114. package/ciel_runtime_support/runtime_maintenance_services.py +265 -0
  115. package/ciel_runtime_support/runtime_paths.py +60 -40
  116. package/ciel_runtime_support/runtime_primitives.py +78 -0
  117. package/ciel_runtime_support/speech_http_controller.py +335 -0
  118. package/ciel_runtime_support/sse_stream_collection.py +236 -0
  119. package/ciel_runtime_support/statusline_script.py +57 -8
  120. package/ciel_runtime_support/streaming_anthropic.py +361 -24
  121. package/ciel_runtime_support/tool_schema.py +40 -2
  122. package/ciel_runtime_support/tool_side_effect_dedupe.py +117 -12
  123. package/ciel_runtime_support/upstream_dump.py +68 -0
  124. package/ciel_runtime_support/upstream_retry_context.py +259 -0
  125. package/ciel_runtime_support/web_ui.py +248 -1
  126. package/ciel_runtime_support/workspace_router_selection.py +86 -0
  127. package/docs/COLAB_SPEECH.md +32 -0
  128. package/docs/Configuration.md +50 -0
  129. package/docs/Test-Suite.md +1 -0
  130. package/package.json +4 -1
  131. package/scripts/colab/__pycache__/bootstrap_moss_tts.cpython-311.pyc +0 -0
  132. package/scripts/colab/__pycache__/bootstrap_qwen_asr.cpython-311.pyc +0 -0
  133. package/scripts/colab/bootstrap_moss_tts.py +106 -0
  134. package/scripts/colab/bootstrap_qwen_asr.py +106 -0
  135. package/scripts/configure_speech_workers.py +37 -0
  136. package/scripts/deploy_colab_speech.ps1 +47 -0
@@ -25,14 +25,15 @@ def default_config_dir():
25
25
 
26
26
 
27
27
  CONFIG_DIR = default_config_dir()
28
+ STATE_DIR = Path(os.environ.get("CIEL_RUNTIME_STATE_DIR") or CONFIG_DIR)
28
29
  CONFIG_PATH = CONFIG_DIR / "config.json"
29
- STATE_PATH = CONFIG_DIR / "rate-limit-state.json"
30
- ACTIVITY_PATH = CONFIG_DIR / "router-activity.json"
31
- COMPACT_ACTIVITY_PATH = CONFIG_DIR / "context-compact-activity.json"
32
- CONTEXT_PATH = CONFIG_DIR / "context-usage.json"
33
- CHAT_MESSAGES_PATH = CONFIG_DIR / "chat-messages.jsonl"
34
- CHANNEL_LLM_CURSOR_PATH = CONFIG_DIR / "channel-llm-cursor.json"
35
- CHANNEL_LLM_CLEAR_FLOOR_PATH = CONFIG_DIR / "channel-llm-clear-floor.json"
30
+ STATE_PATH = STATE_DIR / "rate-limit-state.json"
31
+ ACTIVITY_PATH = STATE_DIR / "router-activity.json"
32
+ COMPACT_ACTIVITY_PATH = STATE_DIR / "context-compact-activity.json"
33
+ CONTEXT_PATH = STATE_DIR / "context-usage.json"
34
+ CHAT_MESSAGES_PATH = STATE_DIR / "chat-messages.jsonl"
35
+ CHANNEL_LLM_CURSOR_PATH = STATE_DIR / "channel-llm-cursor.json"
36
+ CHANNEL_LLM_CLEAR_FLOOR_PATH = STATE_DIR / "channel-llm-clear-floor.json"
36
37
  PALETTE = (203, 209, 215, 221, 229, 187, 151, 116, 111, 147, 183, 219)
37
38
 
38
39
 
@@ -247,6 +248,42 @@ def session_context_status_text(session):
247
248
  return f"ctx {tokens:,} tok"
248
249
 
249
250
 
251
+ def session_cache_status_text(session):
252
+ if not isinstance(session, dict):
253
+ return ""
254
+ context_window = session.get("context_window")
255
+ if not isinstance(context_window, dict):
256
+ return ""
257
+ usage = context_window.get("current_usage")
258
+ if not isinstance(usage, dict):
259
+ return ""
260
+ details = usage.get("input_tokens_details")
261
+ details = details if isinstance(details, dict) else {}
262
+ cache_read = _as_int(
263
+ usage.get("cache_read_input_tokens"),
264
+ _as_int(details.get("cached_tokens")),
265
+ )
266
+ cache_write = _as_int(
267
+ usage.get("cache_creation_input_tokens"),
268
+ _as_int(details.get("cache_write_tokens")),
269
+ )
270
+ input_tokens = max(0, _as_int(usage.get("input_tokens")))
271
+ uncached = (
272
+ max(0, input_tokens - cache_read - cache_write)
273
+ if details
274
+ else input_tokens
275
+ )
276
+ total = uncached + cache_read + cache_write
277
+ if total <= 0 or (cache_read <= 0 and cache_write <= 0):
278
+ return ""
279
+ hit_pct = (cache_read / total) * 100.0
280
+ parts = [f"cache {hit_pct:.1f}%", f"hit {cache_read:,}"]
281
+ if cache_write > 0:
282
+ parts.append(f"write {cache_write:,}")
283
+ parts.append(f"new {uncached:,}")
284
+ return " ".join(parts)
285
+
286
+
250
287
  def _status_as_string_list(value):
251
288
  if value is None:
252
289
  return []
@@ -472,6 +509,9 @@ def main():
472
509
  ctx_text = router_ctx_text or session_ctx_text
473
510
  if ctx_text:
474
511
  status_parts.append(gray(ctx_text))
512
+ cache_text = session_cache_status_text(session)
513
+ if cache_text:
514
+ status_parts.append(color(cache_text))
475
515
  channel_pending = channel_pending_status_count()
476
516
  if channel_pending > 0:
477
517
  status_parts.append(color(f"channel queue {channel_pending}"))
@@ -554,6 +594,16 @@ def main():
554
594
  activity_text += " " + color(f"({chunks} chunks)")
555
595
  elif event in ("success", "error"):
556
596
  activity_text = color(f"{event} {age:.0f}s")
597
+ cache_read = max(0, _as_int(activity.get("cache_read_tokens")))
598
+ cache_write = max(0, _as_int(activity.get("cache_creation_tokens")))
599
+ uncached = max(0, _as_int(activity.get("uncached_input_tokens")))
600
+ cache_total = cache_read + cache_write + uncached
601
+ if not cache_text and cache_total > 0 and (cache_read > 0 or cache_write > 0):
602
+ cache_pct = (cache_read / cache_total) * 100.0
603
+ activity_text += " " + color(
604
+ f"cache {cache_pct:.1f}% hit {cache_read:,} "
605
+ f"write {cache_write:,} new {uncached:,}"
606
+ )
557
607
  if activity_text:
558
608
  status_parts.append(activity_text)
559
609
  compact_text = ""
@@ -590,4 +640,3 @@ if __name__ == "__main__":
590
640
  main()
591
641
 
592
642
  '''
593
-