klaude-code 2.4.1__py3-none-any.whl → 2.5.0__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.
- klaude_code/app/runtime.py +2 -6
- klaude_code/cli/main.py +0 -1
- klaude_code/config/assets/builtin_config.yaml +7 -0
- klaude_code/const.py +7 -4
- klaude_code/core/agent.py +10 -1
- klaude_code/core/agent_profile.py +47 -35
- klaude_code/core/executor.py +6 -21
- klaude_code/core/manager/sub_agent_manager.py +17 -1
- klaude_code/core/prompts/prompt-sub-agent-web.md +4 -4
- klaude_code/core/task.py +65 -4
- klaude_code/core/tool/__init__.py +0 -5
- klaude_code/core/tool/context.py +12 -1
- klaude_code/core/tool/offload.py +311 -0
- klaude_code/core/tool/shell/bash_tool.md +1 -43
- klaude_code/core/tool/sub_agent_tool.py +1 -0
- klaude_code/core/tool/todo/todo_write_tool.md +0 -23
- klaude_code/core/tool/tool_runner.py +14 -9
- klaude_code/core/tool/web/web_fetch_tool.md +1 -1
- klaude_code/core/tool/web/web_fetch_tool.py +14 -39
- klaude_code/core/turn.py +128 -138
- klaude_code/llm/anthropic/client.py +176 -82
- klaude_code/llm/bedrock/client.py +8 -12
- klaude_code/llm/claude/client.py +11 -15
- klaude_code/llm/client.py +31 -4
- klaude_code/llm/codex/client.py +7 -11
- klaude_code/llm/google/client.py +150 -69
- klaude_code/llm/openai_compatible/client.py +10 -15
- klaude_code/llm/openai_compatible/stream.py +68 -6
- klaude_code/llm/openrouter/client.py +9 -15
- klaude_code/llm/partial_message.py +35 -0
- klaude_code/llm/responses/client.py +134 -68
- klaude_code/llm/usage.py +30 -0
- klaude_code/protocol/commands.py +0 -4
- klaude_code/protocol/events/metadata.py +1 -0
- klaude_code/protocol/events/streaming.py +1 -0
- klaude_code/protocol/events/system.py +0 -4
- klaude_code/protocol/model.py +2 -15
- klaude_code/protocol/sub_agent/explore.py +0 -10
- klaude_code/protocol/sub_agent/image_gen.py +0 -7
- klaude_code/protocol/sub_agent/task.py +0 -10
- klaude_code/protocol/sub_agent/web.py +4 -12
- klaude_code/session/templates/export_session.html +4 -4
- klaude_code/skill/manager.py +2 -1
- klaude_code/tui/components/metadata.py +41 -49
- klaude_code/tui/components/rich/markdown.py +1 -3
- klaude_code/tui/components/rich/theme.py +2 -2
- klaude_code/tui/components/sub_agent.py +9 -1
- klaude_code/tui/components/tools.py +0 -31
- klaude_code/tui/components/welcome.py +1 -32
- klaude_code/tui/input/prompt_toolkit.py +25 -9
- klaude_code/tui/machine.py +40 -8
- klaude_code/tui/renderer.py +1 -0
- {klaude_code-2.4.1.dist-info → klaude_code-2.5.0.dist-info}/METADATA +2 -2
- {klaude_code-2.4.1.dist-info → klaude_code-2.5.0.dist-info}/RECORD +56 -56
- klaude_code/core/prompts/prompt-nano-banana.md +0 -1
- klaude_code/core/tool/truncation.py +0 -203
- {klaude_code-2.4.1.dist-info → klaude_code-2.5.0.dist-info}/WHEEL +0 -0
- {klaude_code-2.4.1.dist-info → klaude_code-2.5.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
klaude_code/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
klaude_code/app/__init__.py,sha256=7mgWpN9SFDqe8AW44bBn9M19nVsBcZURrsGB_8l2hrU,264
|
|
3
|
-
klaude_code/app/runtime.py,sha256=
|
|
3
|
+
klaude_code/app/runtime.py,sha256=St5ZVo9snvc90R5fG4OojlWwtlRSB66AZAYfZD7AOCE,5982
|
|
4
4
|
klaude_code/auth/__init__.py,sha256=jLUgi4V4m0t2BlVuuni7iANOErpJgAeEqByuD1sKUvQ,480
|
|
5
5
|
klaude_code/auth/base.py,sha256=ccH2sC0TWB5lPpGm4FSjCgnehwn9riYiXxHCh2iFJe0,3011
|
|
6
6
|
klaude_code/auth/claude/__init__.py,sha256=h1oyqEttDM5TAF6w1Stk6YXYMsbATjODCsi6GhU4zAA,218
|
|
@@ -18,41 +18,40 @@ klaude_code/cli/config_cmd.py,sha256=ZDNt1qtXbiWtFJBIaqtfqKrGHXQ1X-NHBeu1k1DoO1o
|
|
|
18
18
|
klaude_code/cli/cost_cmd.py,sha256=6bL22amGEB2gfCV9KXQfN5cZYyPL6J6JVIjV65_QjJo,12471
|
|
19
19
|
klaude_code/cli/debug.py,sha256=vEHOjObhrIHDAXk3q6cOgeW2NZxCx5AWM1rJ6FiJnVU,1901
|
|
20
20
|
klaude_code/cli/list_model.py,sha256=I3dLrbLfh-cy_FvDCYvKnFGGn9x8v04PtOCcpImUv1U,13258
|
|
21
|
-
klaude_code/cli/main.py,sha256=
|
|
21
|
+
klaude_code/cli/main.py,sha256=w1b7AaDszcQRpMta90ChKEQ9MfJEYdpXs9swv2Nsv2Y,8711
|
|
22
22
|
klaude_code/cli/self_update.py,sha256=mn1B7Xn1keQkbwoDURzsM2fFjorzJTNLlV-Y_NYa6fA,2708
|
|
23
23
|
klaude_code/cli/session_cmd.py,sha256=IyuSkqHOLldcm8qraJWJZEme9TY5Rfqmld9NmVJuHnc,3198
|
|
24
24
|
klaude_code/config/__init__.py,sha256=Qe1BeMekBfO2-Zd30x33lB70hdM1QQZGrp4DbWSQ-II,353
|
|
25
25
|
klaude_code/config/assets/__init__.py,sha256=uMUfmXT3I-gYiI-HVr1DrE60mx5cY1o8V7SYuGqOmvY,32
|
|
26
|
-
klaude_code/config/assets/builtin_config.yaml,sha256=
|
|
26
|
+
klaude_code/config/assets/builtin_config.yaml,sha256=oM191oAgb5Vi7323RsZ1pVbAt6BSwOhnxJ_zZLvpyy0,7202
|
|
27
27
|
klaude_code/config/builtin_config.py,sha256=1rHcFWmS0k6rXeIqR6sF_OgGXSbEd4ugh9bh2N6VSS0,1494
|
|
28
28
|
klaude_code/config/config.py,sha256=0-CLWK5oGGa5PY6o2mVkLNiaiuoaG8zp1UvQ6q0_Xxc,23948
|
|
29
29
|
klaude_code/config/model_matcher.py,sha256=8pYt7DhEhsjLlYS7G14k6KdDtIzcNj2fYhQQach_JTU,6110
|
|
30
30
|
klaude_code/config/sub_agent_model_helper.py,sha256=ntEZXocf3nGesFb8TeyGy1zoB8-yHKih4zngJRdjvf4,8040
|
|
31
31
|
klaude_code/config/thinking.py,sha256=RDWH8UYbeDoIKPXaCIcvVwPAh07Ntaq8w5Zn_fhm-Fk,9329
|
|
32
|
-
klaude_code/const.py,sha256=
|
|
32
|
+
klaude_code/const.py,sha256=VIHmzb1QNNv06bj7uo-y9LOcunhIMYyJe3RUaShIbkM,11153
|
|
33
33
|
klaude_code/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
klaude_code/core/agent.py,sha256=
|
|
35
|
-
klaude_code/core/agent_profile.py,sha256=
|
|
36
|
-
klaude_code/core/executor.py,sha256=
|
|
34
|
+
klaude_code/core/agent.py,sha256=5TNzzzHgKLKpEcFhaM0d136kaGUn_mESC8b1nLoxS2o,3913
|
|
35
|
+
klaude_code/core/agent_profile.py,sha256=FlLDfwyGyoycJYdp70vCuUliZ0GrmcVd0ZCOs4x7MuQ,12776
|
|
36
|
+
klaude_code/core/executor.py,sha256=TKS2TzQM0X1BLxw6x0HoXk0l2QNTrWCPap6wplSgQgQ,33252
|
|
37
37
|
klaude_code/core/manager/__init__.py,sha256=hdIbpnYj6i18byiWjtJIm5l7NYYDQMvafw8fePVPydc,562
|
|
38
38
|
klaude_code/core/manager/llm_clients.py,sha256=X2oMFWgJcP0tK8GEtMMDYR3HyR6_H8FuyCqpzWF5x2k,871
|
|
39
39
|
klaude_code/core/manager/llm_clients_builder.py,sha256=_88MvbjNK-4s3wKTdzP-GmoUVGKyD88oWXZ7oqRWF8A,1902
|
|
40
|
-
klaude_code/core/manager/sub_agent_manager.py,sha256=
|
|
40
|
+
klaude_code/core/manager/sub_agent_manager.py,sha256=sQ88o0ivWHTlaNz-FC23CiHiPXF4mLsQ0T69jPO9Hck,7797
|
|
41
41
|
klaude_code/core/prompts/prompt-claude-code.md,sha256=uuWBv6GrG63mdmBedAHT5U9yOpbHSKFYbbS2xBnUzOE,8290
|
|
42
42
|
klaude_code/core/prompts/prompt-codex-gpt-5-1-codex-max.md,sha256=SW-y8AmR99JL_9j26k9YVAOQuZ18vR12aT5CWHkZDc4,11741
|
|
43
43
|
klaude_code/core/prompts/prompt-codex-gpt-5-2-codex.md,sha256=GA1pIIF6JuAl4P3FIW4tVJ6zL_5iZ8MY_PF0DW9hBuU,11719
|
|
44
44
|
klaude_code/core/prompts/prompt-codex.md,sha256=ybL6CXrGnK6Cw9KuEicQg4kKllIcVa2NwUyuUWitPzk,21672
|
|
45
45
|
klaude_code/core/prompts/prompt-gemini.md,sha256=JjE1tHSByGKJzjn4Gpj1zekT7ry1Yqbwx5qx3fZy2gE,3901
|
|
46
46
|
klaude_code/core/prompts/prompt-minimal.md,sha256=6-ZmQQkE3f92W_3V2wS7ocB13wLog1_UojCjZG0K4v8,1559
|
|
47
|
-
klaude_code/core/prompts/prompt-nano-banana.md,sha256=3e5GUmtW41eX3pCUBB1j5TFgAM71XlFVyIsix66GEvY,81
|
|
48
47
|
klaude_code/core/prompts/prompt-sub-agent-explore.md,sha256=21kFodjhvN0L-c_ZFo4yVhJOyzfgES-Dty9Vz_Ew9q8,2629
|
|
49
48
|
klaude_code/core/prompts/prompt-sub-agent-image-gen.md,sha256=tXYKSzFd04OiC0dmVO9suMKeD5f9qo_4NsvqGo7irfI,78
|
|
50
|
-
klaude_code/core/prompts/prompt-sub-agent-web.md,sha256=
|
|
49
|
+
klaude_code/core/prompts/prompt-sub-agent-web.md,sha256=UwrO5M_jPUbee_8lL7gB-2VFFLxvzEejluXDkMzmR5A,3625
|
|
51
50
|
klaude_code/core/prompts/prompt-sub-agent.md,sha256=dmmdsOenbAOfqG6FmdR88spOLZkXmntDBs-cmZ9DN_g,897
|
|
52
51
|
klaude_code/core/reminders.py,sha256=SOSB1wZMPdCtCwTpvjUW5et-d0JcnUxF7lMg90CZnA4,24384
|
|
53
|
-
klaude_code/core/task.py,sha256=
|
|
54
|
-
klaude_code/core/tool/__init__.py,sha256=
|
|
55
|
-
klaude_code/core/tool/context.py,sha256=
|
|
52
|
+
klaude_code/core/task.py,sha256=eC64_oksvsOdZV_yv16_lWDzqL4QvU_Zs5P5EpitY8c,13911
|
|
53
|
+
klaude_code/core/tool/__init__.py,sha256=ABUzLwQbBoZPirCcgYbI88GEtswfy1JBDkFUsGpQ-zc,1415
|
|
54
|
+
klaude_code/core/tool/context.py,sha256=RnO8gN1w9Lxev0BMqUsZp-zvzD9iKxrYQ3261beLRa4,2975
|
|
56
55
|
klaude_code/core/tool/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
56
|
klaude_code/core/tool/file/_utils.py,sha256=OG4BE9WyJqzH8ilVCL3D9yvAcHk-r-L9snd-E8gO_io,967
|
|
58
57
|
klaude_code/core/tool/file/apply_patch.py,sha256=LZd3pYQ9ow_TxiFnqYuzD216HmvkLX6lW6BoMd9iQRs,17080
|
|
@@ -65,82 +64,83 @@ klaude_code/core/tool/file/read_tool.md,sha256=74SLSl1tq3L0por73M0QV_ws41MRIvGXQ
|
|
|
65
64
|
klaude_code/core/tool/file/read_tool.py,sha256=1y_t8oBSa0WtAgk6eLqGvQqf-MQQnj7YbjpLI9r5b7A,13236
|
|
66
65
|
klaude_code/core/tool/file/write_tool.md,sha256=CNnYgtieUasuHdpXLDpTEsqe492Pf7v75M4RQ3oIer8,613
|
|
67
66
|
klaude_code/core/tool/file/write_tool.py,sha256=2hB3Ioo-H4X9qNoH47_ENAvo8XNwrJfp8m0UqJostEs,5674
|
|
67
|
+
klaude_code/core/tool/offload.py,sha256=y-OgDVFwB-hMdzXll94ylUhFkiK0KwFCu7sxtFLlNxM,12477
|
|
68
68
|
klaude_code/core/tool/report_back_tool.py,sha256=SkuRhfLpVwTOSpIj7XwYfGDNBp8YsCUNXieXDkafS2E,3381
|
|
69
69
|
klaude_code/core/tool/shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
|
-
klaude_code/core/tool/shell/bash_tool.md,sha256=
|
|
70
|
+
klaude_code/core/tool/shell/bash_tool.md,sha256=VqDfwZOy3Ok1t1rEPKEEkN4Rf_1ZFZzDFzpmOstH2Xo,52
|
|
71
71
|
klaude_code/core/tool/shell/bash_tool.py,sha256=LPF-Iqypzfq9IMkumErTSBDgCYYNz8vvZYe7ZobqjYk,14779
|
|
72
72
|
klaude_code/core/tool/shell/command_safety.py,sha256=-x-qs1ctciEvFrBNn2JQq9540lSGacaS5R7e1MmB1y4,6457
|
|
73
|
-
klaude_code/core/tool/sub_agent_tool.py,sha256=
|
|
73
|
+
klaude_code/core/tool/sub_agent_tool.py,sha256=WLhjZ6mqMp9KVDZ37ZPaJRXmvpwUQ2Gq2t_f5mcNub8,4734
|
|
74
74
|
klaude_code/core/tool/todo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
|
-
klaude_code/core/tool/todo/todo_write_tool.md,sha256=
|
|
75
|
+
klaude_code/core/tool/todo/todo_write_tool.md,sha256=0Qf3NXPPfduA0hY8AQ2dE2P64WfY2nSqqTHhk-0R5as,287
|
|
76
76
|
klaude_code/core/tool/todo/todo_write_tool.py,sha256=_94zgZ7N43lQN1x5nD-kd4ayNEwjTQXUiSWLv6MW4FE,4222
|
|
77
77
|
klaude_code/core/tool/todo/todo_write_tool_raw.md,sha256=AJ2OkZGcccQYDXkydPAr5JI2SExBF8qJd0rXsHySLps,9711
|
|
78
78
|
klaude_code/core/tool/todo/update_plan_tool.md,sha256=OoEF4voHHd5J3VDv7tq3UCHdXApkBvxdHXUf5tVOkE8,157
|
|
79
79
|
klaude_code/core/tool/todo/update_plan_tool.py,sha256=ChPgE9ZUU2G0kLu93_ZTTs9J5veySuYR41PIWDQ_Tdc,3703
|
|
80
80
|
klaude_code/core/tool/tool_abc.py,sha256=GtzCGPrPUMJyUVYJAVIMpEcaAJwf-dtisUx-bLdZCX0,1262
|
|
81
81
|
klaude_code/core/tool/tool_registry.py,sha256=-FRU1aCy-jRG6ohdcl20v5_7c6FC3Ixa4GFLr_WkH6M,1336
|
|
82
|
-
klaude_code/core/tool/tool_runner.py,sha256=
|
|
83
|
-
klaude_code/core/tool/truncation.py,sha256=LEK7mgGQ3f08vgouviIcVr53xptiRJAyhgQa0ALITJk,7691
|
|
82
|
+
klaude_code/core/tool/tool_runner.py,sha256=yj9DpXSMd-u8BOAiFsVVxUbB-CEFS8D_Vcv3ytS3vUA,13238
|
|
84
83
|
klaude_code/core/tool/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
85
84
|
klaude_code/core/tool/web/mermaid_tool.md,sha256=vvPSWxbY3P_cBpHh6AM8Je9JJoMY4FBTJzoteEkwuDU,2095
|
|
86
85
|
klaude_code/core/tool/web/mermaid_tool.py,sha256=FELwyLBzFdHhkimGee31_qZlrZq2vTzIaFTsp6qeGus,2715
|
|
87
|
-
klaude_code/core/tool/web/web_fetch_tool.md,sha256=
|
|
88
|
-
klaude_code/core/tool/web/web_fetch_tool.py,sha256=
|
|
86
|
+
klaude_code/core/tool/web/web_fetch_tool.md,sha256=i0IwsZ6r9vAQeCpwDBtEGrWmHPzZk_XE_CsqvjE4aUA,498
|
|
87
|
+
klaude_code/core/tool/web/web_fetch_tool.py,sha256=jXbJTgpI_RvyXy5ac8qIrC-AKOUX1fJ3TpqXq_BfkS4,9596
|
|
89
88
|
klaude_code/core/tool/web/web_search_tool.md,sha256=l5gGPx-fXHFel1zLBljm8isy9pwEYXGrq5cFzzw1VBw,1135
|
|
90
89
|
klaude_code/core/tool/web/web_search_tool.py,sha256=ljkgXxP6L5nJnbYB_IOUtPUN9zA_h5hBD55lhNAja08,4293
|
|
91
|
-
klaude_code/core/turn.py,sha256=
|
|
90
|
+
klaude_code/core/turn.py,sha256=UVCiEpgb5g-yv7zVoelyKdmHgqVEYn5WNiYSVbvu4DA,17976
|
|
92
91
|
klaude_code/llm/__init__.py,sha256=b4AsqnrMIs0a5qR_ti6rZcHwFzAReTwOW96EqozEoSo,287
|
|
93
92
|
klaude_code/llm/anthropic/__init__.py,sha256=PWETvaeNAAX3ue0ww1uRUIxTJG0RpWiutkn7MlwKxBs,67
|
|
94
|
-
klaude_code/llm/anthropic/client.py,sha256=
|
|
93
|
+
klaude_code/llm/anthropic/client.py,sha256=N1p7dll7jxERejsZM5Wh7HbLWcN6bcLQN6LA7OTgRxk,15655
|
|
95
94
|
klaude_code/llm/anthropic/input.py,sha256=FeNhPwP0QJS7E7kICqhRBe2hUNCYkqLf_YP5qWcI_ao,9474
|
|
96
95
|
klaude_code/llm/bedrock/__init__.py,sha256=UmXPBXMmigAJ7euIh59iivSeUdrYJwum0RYU7okkkPM,86
|
|
97
|
-
klaude_code/llm/bedrock/client.py,sha256=
|
|
96
|
+
klaude_code/llm/bedrock/client.py,sha256=mETQrhGDt4uEDXO2c3y5Iao9RngygFSF6MOtwqAy1tk,2279
|
|
98
97
|
klaude_code/llm/claude/__init__.py,sha256=8VCvvEjQQI-RpAMfHCl5ct4zlDU_jgbAuLOc9p9u-B4,61
|
|
99
|
-
klaude_code/llm/claude/client.py,sha256=
|
|
100
|
-
klaude_code/llm/client.py,sha256=
|
|
98
|
+
klaude_code/llm/claude/client.py,sha256=YD0jkzFy1iDngPzaf5uFl_M0CcKh6IeNaujI7ocChA4,3917
|
|
99
|
+
klaude_code/llm/client.py,sha256=2PRxcKBHRk7csw-swglsmLJfYUpbJn6tzNqMb5fJBvE,1820
|
|
101
100
|
klaude_code/llm/codex/__init__.py,sha256=8vN2j2ezWB_UVpfqQ8ooStsBeLL5SY4SUMXOXdWiMaI,132
|
|
102
|
-
klaude_code/llm/codex/client.py,sha256=
|
|
101
|
+
klaude_code/llm/codex/client.py,sha256=d2pDHKokQAaMfnWRoliBtTtjeyElQiPjSwNWyjW_PRs,5389
|
|
103
102
|
klaude_code/llm/google/__init__.py,sha256=tQtf_mh_mC3E4S9XAsnhS2JZXGRnYUsBKF0jpXZTvM0,61
|
|
104
|
-
klaude_code/llm/google/client.py,sha256=
|
|
103
|
+
klaude_code/llm/google/client.py,sha256=28HwOx4ZI1Fd33IGKA7cN1beAlzy3rNDX7zDSWkKvMM,16606
|
|
105
104
|
klaude_code/llm/google/input.py,sha256=EVO-EHbLeD8mSW_3sglfboJzGUwGt2zXqoNRmw__Cbo,8378
|
|
106
105
|
klaude_code/llm/image.py,sha256=jt9FBPFhAIo48pauIEJMIhB9WuDt4wwNs9s3LiEsETE,4272
|
|
107
106
|
klaude_code/llm/input_common.py,sha256=-GnZ87BfzyGqXTP3WYflFOqbRcbKpJjE9mjIv8qKWsQ,6228
|
|
108
107
|
klaude_code/llm/openai_compatible/__init__.py,sha256=ACGpnki7k53mMcCl591aw99pm9jZOZk0ghr7atOfNps,81
|
|
109
|
-
klaude_code/llm/openai_compatible/client.py,sha256=
|
|
108
|
+
klaude_code/llm/openai_compatible/client.py,sha256=9epE7B58UX-Rr8Zw62AwVv1uonajzcT2RLjreQTQ_PU,4683
|
|
110
109
|
klaude_code/llm/openai_compatible/input.py,sha256=VpgT2wbph6bFsB6OFWKnIdjE32W_gKA_p39T-xuJPrE,3217
|
|
111
|
-
klaude_code/llm/openai_compatible/stream.py,sha256=
|
|
110
|
+
klaude_code/llm/openai_compatible/stream.py,sha256=Twi9C0yuWM6pmO_bZpC4VTUqqPfk24kY_AKDdWOSuuo,15280
|
|
112
111
|
klaude_code/llm/openai_compatible/tool_call_accumulator.py,sha256=quajimkUR1uSIPVXYsVNiQSTnOSVt7WuyZ23RyT7lJs,4906
|
|
113
112
|
klaude_code/llm/openrouter/__init__.py,sha256=_As8lHjwj6vapQhLorZttTpukk5ZiCdhFdGT38_ASPo,69
|
|
114
|
-
klaude_code/llm/openrouter/client.py,sha256=
|
|
113
|
+
klaude_code/llm/openrouter/client.py,sha256=dlS6bmg26qkTI_He9FuZw1__6D8CbNufiBLvRHuYHK4,5695
|
|
115
114
|
klaude_code/llm/openrouter/input.py,sha256=Z_Cf6TnMZ5KQNJ0E5IIDCKK2OWlzi8IW0S5A72BBGT0,6176
|
|
116
115
|
klaude_code/llm/openrouter/reasoning.py,sha256=S0s3OAyfFVm5lHYmQqB3ZIUZlbnlV5zB2gNT3ZRbDZs,4335
|
|
116
|
+
klaude_code/llm/partial_message.py,sha256=NdApUSAp9_GqC-bQ_4RdYpIJzqRhkXwO8sGMcf2-4b0,1185
|
|
117
117
|
klaude_code/llm/registry.py,sha256=wEf9wvbb9CMvlNDtndKzKY5LN3zqEJYPI2v9kIrqfGI,2235
|
|
118
118
|
klaude_code/llm/responses/__init__.py,sha256=WsiyvnNiIytaYcaAqNiB8GI-5zcpjjeODPbMlteeFjA,67
|
|
119
|
-
klaude_code/llm/responses/client.py,sha256=
|
|
119
|
+
klaude_code/llm/responses/client.py,sha256=rN9uq1kboVUyUqD4YhblTb2o0LQTX5-wZwnDMmiRHzo,15214
|
|
120
120
|
klaude_code/llm/responses/input.py,sha256=T2mAzSR7-z7AFkUjw33c1U3UCBkGX9hlLJVJk5EUnzg,9178
|
|
121
|
-
klaude_code/llm/usage.py,sha256=
|
|
121
|
+
klaude_code/llm/usage.py,sha256=L6w-DlZ3oF8lOR_SEudPBM9idzIy7__f5FZ4ZJ2smi8,5957
|
|
122
122
|
klaude_code/log.py,sha256=vyCuV18DX0miengbJF9510UsBrWidSln-CM6pVCe0GA,9301
|
|
123
123
|
klaude_code/protocol/__init__.py,sha256=TTPnuyQ22RypoTGKdoiS7ZEgHzinuaRHUrauzHDh7Xo,246
|
|
124
|
-
klaude_code/protocol/commands.py,sha256=
|
|
124
|
+
klaude_code/protocol/commands.py,sha256=MfiUgN7r7VFGh0pel4nCRnk44F2Yzdcd7xqM-M369vY,771
|
|
125
125
|
klaude_code/protocol/events/__init__.py,sha256=5WoUQzj3P7Lih6xO6keaJmaLOyxboO1OtOPavrNNj24,1673
|
|
126
126
|
klaude_code/protocol/events/base.py,sha256=QfqgksjA2Hj-ClmwKVeJ7QA6Z7YdzjswO1NfAVnPCoI,335
|
|
127
127
|
klaude_code/protocol/events/chat.py,sha256=mI_Ks5IIU1ZiywclQYxzhSsGA3ga7ACKShU6d9_KqSs,731
|
|
128
128
|
klaude_code/protocol/events/lifecycle.py,sha256=5csZkv3oZIuLzs_7H84v8HgAYwbjIjkZOHfjxq9YfxM,357
|
|
129
|
-
klaude_code/protocol/events/metadata.py,sha256=
|
|
130
|
-
klaude_code/protocol/events/streaming.py,sha256=
|
|
131
|
-
klaude_code/protocol/events/system.py,sha256=
|
|
129
|
+
klaude_code/protocol/events/metadata.py,sha256=VcktYa6k51vIQ1H_KeOqQYCZkX0K9gaCQR1neOAOENs,313
|
|
130
|
+
klaude_code/protocol/events/streaming.py,sha256=Cn7LRIIzd_7Y0Ex1TnqaLf1imS7m8ZplxfTQSpZy9bY,740
|
|
131
|
+
klaude_code/protocol/events/system.py,sha256=0c3x8WwqAo5Y0JmukKbn7FKtgEv-ErqwJb5PGjuHehk,1294
|
|
132
132
|
klaude_code/protocol/events/tools.py,sha256=8ds_8Zj-wQWvHNAvNt1-fSIHeDffw1dsLWI7ByrAqcM,617
|
|
133
133
|
klaude_code/protocol/llm_param.py,sha256=DSCxBdFSdQV8qOhEjjjYNapgA3v4TBkN5V9HgEWho_k,5164
|
|
134
134
|
klaude_code/protocol/message.py,sha256=pu-wvInS781y-qSKbl9MqO7k3CtAN7Yu4hUHJCXKjZQ,6210
|
|
135
|
-
klaude_code/protocol/model.py,sha256=
|
|
135
|
+
klaude_code/protocol/model.py,sha256=KboyTyfG5DntRMK98oDHomgJfUpHBdeiq51dWXRSqeM,9923
|
|
136
136
|
klaude_code/protocol/op.py,sha256=pYmvSyVrVr6LlJUiSN2GKwXiDX8meCoxYKNYHXdTKGE,5965
|
|
137
137
|
klaude_code/protocol/op_handler.py,sha256=B-dmye-6fgQNUDSa2s9cnHogz_Jl4yoQ9EiNgkgjjtA,1973
|
|
138
138
|
klaude_code/protocol/sub_agent/AGENTS.md,sha256=DHeHl11PYprTOQxInENCEnwnh3kIztBLjvETkwWAO08,1299
|
|
139
139
|
klaude_code/protocol/sub_agent/__init__.py,sha256=RKPFJawd0AB7nRYBxdwuG-14D8pT6HF1-DPCTAxwohI,3784
|
|
140
|
-
klaude_code/protocol/sub_agent/explore.py,sha256=
|
|
141
|
-
klaude_code/protocol/sub_agent/image_gen.py,sha256=
|
|
142
|
-
klaude_code/protocol/sub_agent/task.py,sha256=
|
|
143
|
-
klaude_code/protocol/sub_agent/web.py,sha256=
|
|
140
|
+
klaude_code/protocol/sub_agent/explore.py,sha256=f3fHTyxVeEH4vxJtEts0FbZhdrhOR-_x94QMfNicuUI,1859
|
|
141
|
+
klaude_code/protocol/sub_agent/image_gen.py,sha256=Nd2uzcFViiDfyIVA0XYG9obKAUIEWopIsqWJCjKvVcg,4416
|
|
142
|
+
klaude_code/protocol/sub_agent/task.py,sha256=ZOjzK1itxehlva6WfGKKAJq8FvBOKAywrlgGgfb4Tp4,3441
|
|
143
|
+
klaude_code/protocol/sub_agent/web.py,sha256=XOQdqlIp_xno7Q7YVFPFo4AyKU1wbrVKhIi-NxY8eYM,2506
|
|
144
144
|
klaude_code/protocol/tools.py,sha256=T0mzW9EhidVMNkwH-KTeB5FgwMvXBnV_MYE5ytrU1TM,343
|
|
145
145
|
klaude_code/session/__init__.py,sha256=4sw81uQvEd3YUOOjamKk1KqGmxeb4Ic9T1Tee5zztyU,241
|
|
146
146
|
klaude_code/session/codec.py,sha256=a374UZkOusn9MgFCc--yznDljK_4Qfy6yDPfhQq5_P0,1889
|
|
@@ -148,7 +148,7 @@ klaude_code/session/export.py,sha256=Oa0BdrqipFGkGp62dAsvQ-bPQr0HFAQBpAb7OmgaNno
|
|
|
148
148
|
klaude_code/session/selector.py,sha256=snBpnz9UQCe_0K8HttSGCJECCE4YEzpWs_Fdmk2P9nI,2195
|
|
149
149
|
klaude_code/session/session.py,sha256=iQdjVoiretvsPvVkUv1rW9z5IDnwPQ6RuFAp-gATF9o,23162
|
|
150
150
|
klaude_code/session/store.py,sha256=HRrmFzwEVdExqDQlT9FBZOhlFtQmM9Im9zco8pzvUMY,6455
|
|
151
|
-
klaude_code/session/templates/export_session.html,sha256=
|
|
151
|
+
klaude_code/session/templates/export_session.html,sha256=YIr-jzbgwxPviZ_EE7TeYah7tqzOeNzW-IdpzvlfbcY,125826
|
|
152
152
|
klaude_code/session/templates/mermaid_viewer.html,sha256=Y_wEWFm4mKWpfAz3YMis5DdLEkhw_2d8CpU6jbvGZow,27842
|
|
153
153
|
klaude_code/skill/__init__.py,sha256=yeWeCfRGPOhT4mx_pjdo4fLondQ_Vx0edBtnFusLhls,839
|
|
154
154
|
klaude_code/skill/assets/create-plan/SKILL.md,sha256=g_SLyBid2dwj56FBzh87lZGu1t08edLs0plimT2uNzs,2481
|
|
@@ -157,7 +157,7 @@ klaude_code/skill/assets/handoff/SKILL.md,sha256=GDHrEqWUeAQy7gGhha_y5jzjpv8C-xh
|
|
|
157
157
|
klaude_code/skill/assets/jj-workspace/SKILL.md,sha256=toxoyrBBoGl9Yv4PYrw_gD071LLZ2RoepUR8qTDRn1M,977
|
|
158
158
|
klaude_code/skill/assets/skill-creator/SKILL.md,sha256=0ByoWb9ao0UKSoM5Tmz-Qe5CAPliTrVpUK0gPd9TFqo,5520
|
|
159
159
|
klaude_code/skill/loader.py,sha256=dq-92iX4RWUZd8sFO3KZySOVf5-M6xev29tJlaC0Ivw,8612
|
|
160
|
-
klaude_code/skill/manager.py,sha256=
|
|
160
|
+
klaude_code/skill/manager.py,sha256=GcE6IGooYmWn75wWa2TfJj8VRaBgAlABeK3sD_bIgBY,3448
|
|
161
161
|
klaude_code/skill/system_skills.py,sha256=ryGN07t0Xv2Yn_Prfq072tdIN0Dp4ZpdXLTl7O7rCkg,6122
|
|
162
162
|
klaude_code/tui/__init__.py,sha256=Q8-0D-uesw3oFwHcFLD5UaWlTFbrj8qV7dSn6C6_g_o,274
|
|
163
163
|
klaude_code/tui/command/__init__.py,sha256=qeQYDQ93mCOgP4SdHTXcMvrqQ8xdmMiNH-nBzmMUqIw,3477
|
|
@@ -189,29 +189,29 @@ klaude_code/tui/components/developer.py,sha256=1hDr7boJN1z_JyvvFNn8m7MAf4lPDN3eo
|
|
|
189
189
|
klaude_code/tui/components/diffs.py,sha256=JUokkkJeTIoKD0b-c-chMzIDmMjivBQqH8DYXIA3hHs,10411
|
|
190
190
|
klaude_code/tui/components/errors.py,sha256=_9ojf-23ThR-BoMwNEYG68rzILwA_O59muGvofYL10w,669
|
|
191
191
|
klaude_code/tui/components/mermaid_viewer.py,sha256=MstufMnTauMKzI8cKngXpFqVo-qya20P8ReNkplYtEw,3098
|
|
192
|
-
klaude_code/tui/components/metadata.py,sha256=
|
|
192
|
+
klaude_code/tui/components/metadata.py,sha256=HjIZkMyGu8jgTm4XgkMy82wKsoJXnzQwq_9su7Cqzm4,7227
|
|
193
193
|
klaude_code/tui/components/rich/__init__.py,sha256=zEZjnHR3Fnv_sFMxwIMjoJfwDoC4GRGv3lHJzAGRq_o,236
|
|
194
194
|
klaude_code/tui/components/rich/cjk_wrap.py,sha256=eMqBxftUtll7zrytUb9WtJ6naYLyax0W4KJRpGwWulM,7602
|
|
195
195
|
klaude_code/tui/components/rich/code_panel.py,sha256=ZKuJHh-kh-hIkBXSGLERLaDbJ7I9hvtvmYKocJn39_w,4744
|
|
196
196
|
klaude_code/tui/components/rich/live.py,sha256=xiMT6dPsxM_jaazddKrV9CMJQWwpe2t9OdjffHvo1JU,2821
|
|
197
|
-
klaude_code/tui/components/rich/markdown.py,sha256=
|
|
197
|
+
klaude_code/tui/components/rich/markdown.py,sha256=hMAWhcuu1GVUK3AsE5G_8Qi-_2aVgTvrbu2nC5QAWgQ,19098
|
|
198
198
|
klaude_code/tui/components/rich/quote.py,sha256=gTLwxSPQd9nlp73P1ysQIEgOb-BoTE2gzyiPBLMiHcY,3834
|
|
199
199
|
klaude_code/tui/components/rich/searchable_text.py,sha256=PUe6MotKxSBY4FlPeojVjVQgxCsx_jiQ41bCzLp8WvE,2271
|
|
200
200
|
klaude_code/tui/components/rich/status.py,sha256=kNt08FQGvMZJB-zUhT5UyVFA7jvuRBNqf6yDXLEhb9c,14756
|
|
201
|
-
klaude_code/tui/components/rich/theme.py,sha256=
|
|
202
|
-
klaude_code/tui/components/sub_agent.py,sha256=
|
|
201
|
+
klaude_code/tui/components/rich/theme.py,sha256=IKzOh5ecKyYOHEMvdtsDNRPXDSW98lNc0INHUgnXe5E,15142
|
|
202
|
+
klaude_code/tui/components/sub_agent.py,sha256=afkDbndByQmrxO3lvWR3rSvlbIE0wktbjdnlBTwka5I,6309
|
|
203
203
|
klaude_code/tui/components/thinking.py,sha256=AXC7Xpyiu7ST-eWGLRGY7N8Dak2ny3lV3mvznmfqKmM,2890
|
|
204
|
-
klaude_code/tui/components/tools.py,sha256=
|
|
204
|
+
klaude_code/tui/components/tools.py,sha256=Up8DQbXuiPfcbiFVZD6gmZO0YBz2SExWS-tE_xeriX4,25060
|
|
205
205
|
klaude_code/tui/components/user_input.py,sha256=6VHH77xwUUW0rW7yv8hOwGXsmK52HEsBg9-QZVbOm1A,3427
|
|
206
|
-
klaude_code/tui/components/welcome.py,sha256=
|
|
206
|
+
klaude_code/tui/components/welcome.py,sha256=0IPtYLJG8h1jLp6LtcMuOvmng2FYpGLWP4eP0e2R2ZI,2367
|
|
207
207
|
klaude_code/tui/display.py,sha256=ovM1F8GDG0gTQjOV2KaXnjE9HFHf7AtThqSIXkP6JQY,3073
|
|
208
208
|
klaude_code/tui/input/__init__.py,sha256=cAB38ypo7dHo_jgXUCnoBTUKHtiriVaKCv4YepSU9SU,276
|
|
209
209
|
klaude_code/tui/input/clipboard.py,sha256=HjThFB9MG_YdJ76CQv7B-IUoz5JarbWUZDbUVkH1LpY,5106
|
|
210
210
|
klaude_code/tui/input/completers.py,sha256=lkDBjnqYPLMgR6AZHhx2bfT_vMW-fbV6aqY9SqRwq74,32571
|
|
211
211
|
klaude_code/tui/input/key_bindings.py,sha256=2uN48J1HRHeCBqq7WrH5J82NIU59oQscce0HquAiYCI,18876
|
|
212
|
-
klaude_code/tui/input/prompt_toolkit.py,sha256=
|
|
213
|
-
klaude_code/tui/machine.py,sha256=
|
|
214
|
-
klaude_code/tui/renderer.py,sha256=
|
|
212
|
+
klaude_code/tui/input/prompt_toolkit.py,sha256=ZwkQodc3GufGo7SMmebaOiVopkqxkMDC48y8RFeGuLk,28551
|
|
213
|
+
klaude_code/tui/machine.py,sha256=Mhyhz7lxeMgBfkqA_23ZEhVwv3qq7-g3XTAM6nQm7c4,24759
|
|
214
|
+
klaude_code/tui/renderer.py,sha256=JZu892irKW0aNis3vs5Rq9aqYdcKhllrhnC2kfsC9tM,29522
|
|
215
215
|
klaude_code/tui/runner.py,sha256=nOq8wC78HzgqHLRgHC8OgYubH--2gPcDqA6GoV913Yc,11270
|
|
216
216
|
klaude_code/tui/terminal/__init__.py,sha256=GIMnsEcIAGT_vBHvTlWEdyNmAEpruyscUA6M_j3GQZU,1412
|
|
217
217
|
klaude_code/tui/terminal/color.py,sha256=6SJR2RA8cqJINNoRz65w0HL3x9g46ydIvDOGWMeNnQU,7195
|
|
@@ -229,7 +229,7 @@ klaude_code/ui/debug_mode.py,sha256=ZvqbOx4c_rUerMbEZzOfcbNf9leqEDFjqJUlALtzF9Y,
|
|
|
229
229
|
klaude_code/ui/terminal/__init__.py,sha256=5OeAzr994r8-peWsLON0iXsAvJ2pexwMp36JY7FKGDc,179
|
|
230
230
|
klaude_code/ui/terminal/title.py,sha256=EZpLXTMhunsZPVGaxP317lH0Ad2oOh7OsjbV3yRD5is,1115
|
|
231
231
|
klaude_code/update.py,sha256=QER816AZe9u3RhRvP0Z37Jh2Ch5RLy9PREyDsI0e1dA,4480
|
|
232
|
-
klaude_code-2.
|
|
233
|
-
klaude_code-2.
|
|
234
|
-
klaude_code-2.
|
|
235
|
-
klaude_code-2.
|
|
232
|
+
klaude_code-2.5.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
233
|
+
klaude_code-2.5.0.dist-info/entry_points.txt,sha256=kkXIXedaTOtjXPr2rVjRVVXZYlFUcBHELaqmyVlWUFA,92
|
|
234
|
+
klaude_code-2.5.0.dist-info/METADATA,sha256=0Gzbk9qkofuEKCdq_DADy0_TcsXBCMVXDIR3UvrAKGg,10249
|
|
235
|
+
klaude_code-2.5.0.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
You're a helpful assistant with capabilities to generate images and edit images.
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import re
|
|
3
|
-
import time
|
|
4
|
-
from abc import ABC, abstractmethod
|
|
5
|
-
from dataclasses import dataclass
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from typing import Protocol
|
|
8
|
-
from urllib.parse import urlparse
|
|
9
|
-
|
|
10
|
-
from klaude_code.const import (
|
|
11
|
-
TOOL_OUTPUT_DISPLAY_HEAD,
|
|
12
|
-
TOOL_OUTPUT_DISPLAY_TAIL,
|
|
13
|
-
TOOL_OUTPUT_MAX_LENGTH,
|
|
14
|
-
TOOL_OUTPUT_TRUNCATION_DIR,
|
|
15
|
-
URL_FILENAME_MAX_LENGTH,
|
|
16
|
-
)
|
|
17
|
-
from klaude_code.protocol import tools
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class ToolCallLike(Protocol):
|
|
21
|
-
@property
|
|
22
|
-
def tool_name(self) -> str: ...
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def call_id(self) -> str: ...
|
|
26
|
-
|
|
27
|
-
@property
|
|
28
|
-
def arguments_json(self) -> str: ...
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@dataclass
|
|
32
|
-
class TruncationResult:
|
|
33
|
-
"""Result of truncation operation."""
|
|
34
|
-
|
|
35
|
-
output: str
|
|
36
|
-
was_truncated: bool
|
|
37
|
-
saved_file_path: str | None = None
|
|
38
|
-
original_length: int = 0
|
|
39
|
-
truncated_length: int = 0
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
FILE_SAVED_PATTERN = re.compile(r"<file_saved>([^<]+)</file_saved>")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _extract_saved_file_path(output: str) -> str | None:
|
|
46
|
-
"""Extract file path from <file_saved> tag if present."""
|
|
47
|
-
match = FILE_SAVED_PATTERN.search(output)
|
|
48
|
-
return match.group(1) if match else None
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def _extract_url_filename(url: str) -> str:
|
|
52
|
-
"""Extract a safe filename from a URL."""
|
|
53
|
-
parsed = urlparse(url)
|
|
54
|
-
# Combine host and path for a meaningful filename
|
|
55
|
-
host = parsed.netloc.replace(".", "_").replace(":", "_")
|
|
56
|
-
path = parsed.path.strip("/").replace("/", "_")
|
|
57
|
-
name = f"{host}_{path}" if path else host
|
|
58
|
-
# Sanitize: keep only alphanumeric, underscore, hyphen
|
|
59
|
-
name = re.sub(r"[^a-zA-Z0-9_\-]", "_", name)
|
|
60
|
-
# Limit length
|
|
61
|
-
return name[:URL_FILENAME_MAX_LENGTH] if len(name) > URL_FILENAME_MAX_LENGTH else name
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class TruncationStrategy(ABC):
|
|
65
|
-
"""Abstract base class for tool output truncation strategies."""
|
|
66
|
-
|
|
67
|
-
@abstractmethod
|
|
68
|
-
def truncate(self, output: str, tool_call: ToolCallLike | None = None) -> TruncationResult:
|
|
69
|
-
"""Truncate the output according to the strategy."""
|
|
70
|
-
...
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class SimpleTruncationStrategy(TruncationStrategy):
|
|
74
|
-
"""Simple character-based truncation strategy."""
|
|
75
|
-
|
|
76
|
-
def __init__(self, max_length: int = TOOL_OUTPUT_MAX_LENGTH):
|
|
77
|
-
self.max_length = max_length
|
|
78
|
-
|
|
79
|
-
def truncate(self, output: str, tool_call: ToolCallLike | None = None) -> TruncationResult:
|
|
80
|
-
if len(output) > self.max_length:
|
|
81
|
-
truncated_length = len(output) - self.max_length
|
|
82
|
-
truncated_output = output[: self.max_length] + f"… (truncated {truncated_length} characters)"
|
|
83
|
-
return TruncationResult(
|
|
84
|
-
output=truncated_output,
|
|
85
|
-
was_truncated=True,
|
|
86
|
-
original_length=len(output),
|
|
87
|
-
truncated_length=truncated_length,
|
|
88
|
-
)
|
|
89
|
-
return TruncationResult(output=output, was_truncated=False, original_length=len(output))
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class SmartTruncationStrategy(TruncationStrategy):
|
|
93
|
-
"""Smart truncation strategy that saves full output to file and shows head/tail."""
|
|
94
|
-
|
|
95
|
-
def __init__(
|
|
96
|
-
self,
|
|
97
|
-
max_length: int = TOOL_OUTPUT_MAX_LENGTH,
|
|
98
|
-
head_chars: int = TOOL_OUTPUT_DISPLAY_HEAD,
|
|
99
|
-
tail_chars: int = TOOL_OUTPUT_DISPLAY_TAIL,
|
|
100
|
-
truncation_dir: str = TOOL_OUTPUT_TRUNCATION_DIR,
|
|
101
|
-
):
|
|
102
|
-
self.max_length = max_length
|
|
103
|
-
self.head_chars = head_chars
|
|
104
|
-
self.tail_chars = tail_chars
|
|
105
|
-
self.truncation_dir = Path(truncation_dir)
|
|
106
|
-
|
|
107
|
-
def _get_file_identifier(self, tool_call: ToolCallLike | None) -> str:
|
|
108
|
-
"""Get a file identifier based on tool call. For WebFetch, use URL; otherwise use call_id."""
|
|
109
|
-
if tool_call and tool_call.tool_name == tools.WEB_FETCH:
|
|
110
|
-
try:
|
|
111
|
-
args = json.loads(tool_call.arguments_json)
|
|
112
|
-
url = args.get("url", "")
|
|
113
|
-
if url:
|
|
114
|
-
return _extract_url_filename(url)
|
|
115
|
-
except (json.JSONDecodeError, TypeError):
|
|
116
|
-
pass
|
|
117
|
-
# Fallback to call_id
|
|
118
|
-
if tool_call and tool_call.call_id:
|
|
119
|
-
return tool_call.call_id.replace("/", "_")
|
|
120
|
-
return "unknown"
|
|
121
|
-
|
|
122
|
-
def _save_to_file(self, output: str, tool_call: ToolCallLike | None) -> str | None:
|
|
123
|
-
"""Save full output to file. Returns file path or None on failure."""
|
|
124
|
-
try:
|
|
125
|
-
self.truncation_dir.mkdir(parents=True, exist_ok=True)
|
|
126
|
-
timestamp = int(time.time())
|
|
127
|
-
tool_name = (tool_call.tool_name if tool_call else "unknown").replace("/", "_")
|
|
128
|
-
identifier = self._get_file_identifier(tool_call)
|
|
129
|
-
filename = f"{tool_name}-{identifier}-{timestamp}.txt"
|
|
130
|
-
file_path = self.truncation_dir / filename
|
|
131
|
-
file_path.write_text(output, encoding="utf-8")
|
|
132
|
-
return str(file_path)
|
|
133
|
-
except OSError:
|
|
134
|
-
return None
|
|
135
|
-
|
|
136
|
-
def truncate(self, output: str, tool_call: ToolCallLike | None = None) -> TruncationResult:
|
|
137
|
-
if tool_call and tool_call.tool_name == tools.READ:
|
|
138
|
-
# Do not truncate Read tool outputs
|
|
139
|
-
return TruncationResult(output=output, was_truncated=False, original_length=len(output))
|
|
140
|
-
|
|
141
|
-
original_length = len(output)
|
|
142
|
-
|
|
143
|
-
if original_length <= self.max_length:
|
|
144
|
-
return TruncationResult(output=output, was_truncated=False, original_length=original_length)
|
|
145
|
-
|
|
146
|
-
# Check if file was already saved (e.g., by WebFetch)
|
|
147
|
-
existing_file_path = _extract_saved_file_path(output)
|
|
148
|
-
saved_file_path = existing_file_path or self._save_to_file(output, tool_call)
|
|
149
|
-
|
|
150
|
-
# Strip existing <file_saved> tag to avoid duplication in head/tail
|
|
151
|
-
content_to_truncate = FILE_SAVED_PATTERN.sub("", output).lstrip("\n") if existing_file_path else output
|
|
152
|
-
content_length = len(content_to_truncate)
|
|
153
|
-
|
|
154
|
-
truncated_length = content_length - self.head_chars - self.tail_chars
|
|
155
|
-
head_content = content_to_truncate[: self.head_chars]
|
|
156
|
-
tail_content = content_to_truncate[-self.tail_chars :]
|
|
157
|
-
|
|
158
|
-
# Build truncated output with file info
|
|
159
|
-
if saved_file_path:
|
|
160
|
-
header = (
|
|
161
|
-
f"<system-reminder>Output truncated ({truncated_length} chars hidden) to reduce context usage. "
|
|
162
|
-
f"Full content saved to <file_saved>{saved_file_path}</file_saved>. "
|
|
163
|
-
f"Use Read(offset, limit) or rg to inspect if needed. "
|
|
164
|
-
f"Showing first {self.head_chars} and last {self.tail_chars} chars:</system-reminder>\n\n"
|
|
165
|
-
)
|
|
166
|
-
else:
|
|
167
|
-
header = (
|
|
168
|
-
f"<system-reminder>Output truncated ({truncated_length} chars hidden) to reduce context usage. "
|
|
169
|
-
f"Showing first {self.head_chars} and last {self.tail_chars} chars:</system-reminder>\n\n"
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
truncated_output = (
|
|
173
|
-
f"{header}{head_content}\n\n"
|
|
174
|
-
f"<system-reminder>… {truncated_length} characters omitted …</system-reminder>\n\n"
|
|
175
|
-
f"{tail_content}"
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
return TruncationResult(
|
|
179
|
-
output=truncated_output,
|
|
180
|
-
was_truncated=True,
|
|
181
|
-
saved_file_path=saved_file_path,
|
|
182
|
-
original_length=original_length,
|
|
183
|
-
truncated_length=truncated_length,
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
_default_strategy: TruncationStrategy = SmartTruncationStrategy()
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def get_truncation_strategy() -> TruncationStrategy:
|
|
191
|
-
"""Get the current truncation strategy."""
|
|
192
|
-
return _default_strategy
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
def set_truncation_strategy(strategy: TruncationStrategy) -> None:
|
|
196
|
-
"""Set the truncation strategy to use."""
|
|
197
|
-
global _default_strategy
|
|
198
|
-
_default_strategy = strategy
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def truncate_tool_output(output: str, tool_call: ToolCallLike | None = None) -> TruncationResult:
|
|
202
|
-
"""Truncate tool output using the current strategy."""
|
|
203
|
-
return get_truncation_strategy().truncate(output, tool_call)
|
|
File without changes
|
|
File without changes
|