klaude-code 2.7.0__py3-none-any.whl → 2.8.1__py3-none-any.whl

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 (74) hide show
  1. klaude_code/auth/AGENTS.md +325 -0
  2. klaude_code/auth/__init__.py +17 -1
  3. klaude_code/auth/antigravity/__init__.py +20 -0
  4. klaude_code/auth/antigravity/exceptions.py +17 -0
  5. klaude_code/auth/antigravity/oauth.py +320 -0
  6. klaude_code/auth/antigravity/pkce.py +25 -0
  7. klaude_code/auth/antigravity/token_manager.py +45 -0
  8. klaude_code/auth/base.py +4 -0
  9. klaude_code/auth/claude/oauth.py +29 -9
  10. klaude_code/auth/codex/exceptions.py +4 -0
  11. klaude_code/cli/auth_cmd.py +53 -3
  12. klaude_code/cli/cost_cmd.py +83 -160
  13. klaude_code/cli/list_model.py +50 -0
  14. klaude_code/cli/main.py +2 -2
  15. klaude_code/config/assets/builtin_config.yaml +108 -0
  16. klaude_code/config/builtin_config.py +5 -11
  17. klaude_code/config/config.py +24 -10
  18. klaude_code/const.py +2 -1
  19. klaude_code/core/agent.py +5 -1
  20. klaude_code/core/agent_profile.py +29 -33
  21. klaude_code/core/compaction/AGENTS.md +112 -0
  22. klaude_code/core/compaction/__init__.py +11 -0
  23. klaude_code/core/compaction/compaction.py +705 -0
  24. klaude_code/core/compaction/overflow.py +30 -0
  25. klaude_code/core/compaction/prompts.py +97 -0
  26. klaude_code/core/executor.py +121 -2
  27. klaude_code/core/manager/llm_clients.py +5 -0
  28. klaude_code/core/manager/llm_clients_builder.py +14 -2
  29. klaude_code/core/prompts/prompt-antigravity.md +80 -0
  30. klaude_code/core/prompts/prompt-codex-gpt-5-2.md +335 -0
  31. klaude_code/core/reminders.py +7 -2
  32. klaude_code/core/task.py +126 -0
  33. klaude_code/core/tool/file/edit_tool.py +1 -2
  34. klaude_code/core/tool/todo/todo_write_tool.py +1 -1
  35. klaude_code/core/turn.py +3 -1
  36. klaude_code/llm/antigravity/__init__.py +3 -0
  37. klaude_code/llm/antigravity/client.py +558 -0
  38. klaude_code/llm/antigravity/input.py +261 -0
  39. klaude_code/llm/registry.py +1 -0
  40. klaude_code/protocol/commands.py +1 -0
  41. klaude_code/protocol/events.py +18 -0
  42. klaude_code/protocol/llm_param.py +1 -0
  43. klaude_code/protocol/message.py +23 -1
  44. klaude_code/protocol/op.py +29 -1
  45. klaude_code/protocol/op_handler.py +10 -0
  46. klaude_code/session/export.py +308 -299
  47. klaude_code/session/session.py +36 -0
  48. klaude_code/session/templates/export_session.html +430 -134
  49. klaude_code/skill/assets/create-plan/SKILL.md +6 -6
  50. klaude_code/tui/command/__init__.py +6 -0
  51. klaude_code/tui/command/compact_cmd.py +32 -0
  52. klaude_code/tui/command/continue_cmd.py +34 -0
  53. klaude_code/tui/command/fork_session_cmd.py +110 -14
  54. klaude_code/tui/command/model_picker.py +5 -1
  55. klaude_code/tui/command/thinking_cmd.py +1 -1
  56. klaude_code/tui/commands.py +6 -0
  57. klaude_code/tui/components/rich/markdown.py +119 -12
  58. klaude_code/tui/components/rich/theme.py +10 -2
  59. klaude_code/tui/components/tools.py +39 -25
  60. klaude_code/tui/components/user_input.py +1 -1
  61. klaude_code/tui/input/__init__.py +5 -2
  62. klaude_code/tui/input/drag_drop.py +6 -57
  63. klaude_code/tui/input/key_bindings.py +10 -0
  64. klaude_code/tui/input/prompt_toolkit.py +19 -6
  65. klaude_code/tui/machine.py +25 -0
  66. klaude_code/tui/renderer.py +68 -4
  67. klaude_code/tui/runner.py +18 -2
  68. klaude_code/tui/terminal/image.py +72 -10
  69. klaude_code/tui/terminal/selector.py +31 -7
  70. {klaude_code-2.7.0.dist-info → klaude_code-2.8.1.dist-info}/METADATA +1 -1
  71. {klaude_code-2.7.0.dist-info → klaude_code-2.8.1.dist-info}/RECORD +73 -56
  72. klaude_code/core/prompts/prompt-codex-gpt-5-1-codex-max.md +0 -117
  73. {klaude_code-2.7.0.dist-info → klaude_code-2.8.1.dist-info}/WHEEL +0 -0
  74. {klaude_code-2.7.0.dist-info → klaude_code-2.8.1.dist-info}/entry_points.txt +0 -0
@@ -228,6 +228,30 @@ class Session(BaseModel):
228
228
  )
229
229
  self._store.append_and_flush(session_id=self.id, items=items, meta=meta)
230
230
 
231
+ def get_llm_history(self) -> list[message.HistoryEvent]:
232
+ """Return the LLM-facing history view with compaction summary injected."""
233
+ history = self.conversation_history
234
+ last_compaction: message.CompactionEntry | None = None
235
+ for item in reversed(history):
236
+ if isinstance(item, message.CompactionEntry):
237
+ last_compaction = item
238
+ break
239
+ if last_compaction is None:
240
+ return [it for it in history if not isinstance(it, message.CompactionEntry)]
241
+
242
+ summary_message = message.UserMessage(parts=[message.TextPart(text=last_compaction.summary)])
243
+ kept = [it for it in history[last_compaction.first_kept_index :] if not isinstance(it, message.CompactionEntry)]
244
+
245
+ # Guard against old/bad persisted compaction boundaries that start with tool results.
246
+ # Tool results must not appear without their corresponding assistant tool call.
247
+ if kept and isinstance(kept[0], message.ToolResultMessage):
248
+ first_non_tool = 0
249
+ while first_non_tool < len(kept) and isinstance(kept[first_non_tool], message.ToolResultMessage):
250
+ first_non_tool += 1
251
+ kept = kept[first_non_tool:]
252
+
253
+ return [summary_message, *kept]
254
+
231
255
  def fork(self, *, new_id: str | None = None, until_index: int | None = None) -> Session:
232
256
  """Create a new session as a fork of the current session.
233
257
 
@@ -399,6 +423,18 @@ class Session(BaseModel):
399
423
  yield events.DeveloperMessageEvent(session_id=self.id, item=dm)
400
424
  case message.StreamErrorItem() as se:
401
425
  yield events.ErrorEvent(error_message=se.error, can_retry=False, session_id=self.id)
426
+ case message.CompactionEntry() as ce:
427
+ yield events.CompactionStartEvent(session_id=self.id, reason="threshold")
428
+ yield events.CompactionEndEvent(
429
+ session_id=self.id,
430
+ reason="threshold",
431
+ aborted=False,
432
+ will_retry=False,
433
+ tokens_before=ce.tokens_before,
434
+ kept_from_index=ce.first_kept_index,
435
+ summary=ce.summary,
436
+ kept_items_brief=ce.kept_items_brief,
437
+ )
402
438
  case message.SystemMessage():
403
439
  pass
404
440
  prev_item = it