llm.rb 15.0.3 → 15.2.0

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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +433 -3
  3. data/README.md +188 -71
  4. data/bin/llm.rb +50 -7
  5. data/data/alibaba.json +912 -823
  6. data/data/anthropic.json +234 -187
  7. data/data/bedrock.json +3702 -2058
  8. data/data/deepinfra.json +1288 -951
  9. data/data/deepseek.json +87 -53
  10. data/data/google.json +670 -670
  11. data/data/mistral.json +501 -460
  12. data/data/moonshot.json +43 -248
  13. data/data/openai.json +1008 -914
  14. data/data/openrouter.json +14417 -0
  15. data/data/xai.json +213 -201
  16. data/data/zai.json +242 -149
  17. data/docs/deepdive/advanced/compaction.md +5 -5
  18. data/docs/deepdive/advanced/context.md +8 -6
  19. data/docs/deepdive/advanced/guard.md +2 -2
  20. data/docs/deepdive/features/builtin_tools.md +93 -22
  21. data/docs/deepdive/features/{repl.md → console.md} +28 -28
  22. data/docs/deepdive/features/database.md +3 -3
  23. data/docs/deepdive/fundamentals/agents.md +13 -12
  24. data/docs/deepdive/fundamentals/providers.md +91 -6
  25. data/docs/deepdive/fundamentals/skills.md +14 -6
  26. data/docs/deepdive/fundamentals/stream.md +4 -4
  27. data/docs/deepdive/fundamentals/tools.md +63 -31
  28. data/docs/deepdive/reference/cost.md +2 -2
  29. data/docs/deepdive/reference/model_registry.md +2 -2
  30. data/docs/deepdive/reference/tracer.md +15 -13
  31. data/docs/deepdive.md +2 -2
  32. data/lib/llm/active_record/acts_as_agent.rb +9 -5
  33. data/lib/llm/agent.rb +40 -15
  34. data/lib/llm/{repl → console}/bar.rb +3 -3
  35. data/lib/llm/{repl → console}/buffer.rb +24 -9
  36. data/lib/llm/{repl → console}/color.rb +2 -2
  37. data/lib/llm/{repl → console}/command.rb +12 -12
  38. data/lib/llm/{repl → console}/commands/exit.rb +4 -4
  39. data/lib/llm/{repl → console}/commands/help.rb +1 -1
  40. data/lib/llm/{repl/commands/compact.rb → console/commands/keep.rb} +11 -9
  41. data/lib/llm/{repl → console}/commands/model.rb +2 -2
  42. data/lib/llm/{repl → console}/input/cache.rb +2 -2
  43. data/lib/llm/{repl → console}/input/char.rb +2 -2
  44. data/lib/llm/{repl → console}/input/row.rb +1 -1
  45. data/lib/llm/{repl → console}/input.rb +18 -10
  46. data/lib/llm/console/markdown/parser.rb +78 -0
  47. data/lib/llm/{repl → console}/markdown/table.rb +8 -5
  48. data/lib/llm/{repl → console}/markdown.rb +13 -30
  49. data/lib/llm/console/node.rb +69 -0
  50. data/lib/llm/{repl → console}/status.rb +11 -11
  51. data/lib/llm/{repl → console}/stream.rb +36 -9
  52. data/lib/llm/{repl → console}/walker.rb +1 -1
  53. data/lib/llm/{repl → console}/window.rb +17 -17
  54. data/lib/llm/{repl.rb → console.rb} +39 -19
  55. data/lib/llm/context/deserializer.rb +2 -1
  56. data/lib/llm/context.rb +29 -13
  57. data/lib/llm/cost.rb +13 -0
  58. data/lib/llm/function/async/reactor.rb +20 -1
  59. data/lib/llm/function/fork/task.rb +14 -10
  60. data/lib/llm/function.rb +1 -1
  61. data/lib/llm/json_adapter.rb +40 -28
  62. data/lib/llm/message.rb +7 -0
  63. data/lib/llm/provider.rb +31 -10
  64. data/lib/llm/providers/alibaba.rb +1 -1
  65. data/lib/llm/providers/anthropic.rb +1 -1
  66. data/lib/llm/providers/bedrock/models.rb +2 -2
  67. data/lib/llm/providers/bedrock.rb +1 -1
  68. data/lib/llm/providers/deepseek.rb +1 -1
  69. data/lib/llm/providers/google.rb +1 -1
  70. data/lib/llm/providers/ollama.rb +1 -1
  71. data/lib/llm/providers/openai/responses.rb +2 -1
  72. data/lib/llm/providers/openai.rb +2 -1
  73. data/lib/llm/providers/openrouter.rb +87 -0
  74. data/lib/llm/schema/leaf.rb +34 -2
  75. data/lib/llm/schema.rb +4 -2
  76. data/lib/llm/sequel/agent.rb +9 -5
  77. data/lib/llm/skill.rb +7 -1
  78. data/lib/llm/stream.rb +8 -3
  79. data/lib/llm/tool/param.rb +5 -1
  80. data/lib/llm/tool.rb +5 -0
  81. data/lib/llm/tools/bundle.rb +53 -0
  82. data/lib/llm/tools/edit-file.rb +7 -2
  83. data/lib/llm/tools/exec.rb +78 -0
  84. data/lib/llm/tools/git.rb +27 -26
  85. data/lib/llm/tools/mkdir.rb +12 -19
  86. data/lib/llm/tools/read_file.rb +69 -9
  87. data/lib/llm/tools/rg.rb +20 -24
  88. data/lib/llm/tools/ruby.rb +17 -25
  89. data/lib/llm/tools/utils.rb +75 -2
  90. data/lib/llm/tools/write_file.rb +4 -1
  91. data/lib/llm/tracer/logger.rb +2 -2
  92. data/lib/llm/tracer/pretty_logger.rb +4 -4
  93. data/lib/llm/tracer/telemetry.rb +2 -2
  94. data/lib/llm/tracer.rb +33 -0
  95. data/lib/llm/transport/curb.rb +5 -3
  96. data/lib/llm/transport/http.rb +5 -2
  97. data/lib/llm/transport/persistent_http.rb +6 -4
  98. data/lib/llm/transport/utils.rb +8 -6
  99. data/lib/llm/version.rb +1 -1
  100. data/lib/llm.rb +18 -12
  101. data/llm.gemspec +8 -8
  102. metadata +80 -37
  103. data/lib/llm/repl/node.rb +0 -44
  104. data/lib/llm/tools/shell.rb +0 -55
data/data/moonshot.json CHANGED
@@ -8,9 +8,9 @@
8
8
  "name": "Moonshot AI",
9
9
  "doc": "https://platform.moonshot.ai/docs/api/chat",
10
10
  "models": {
11
- "kimi-k2.7-code": {
12
- "id": "kimi-k2.7-code",
13
- "name": "Kimi K2.7 Code",
11
+ "kimi-k2.7-code-highspeed": {
12
+ "id": "kimi-k2.7-code-highspeed",
13
+ "name": "Kimi K2.7 Code HighSpeed",
14
14
  "description": "Coding-focused Kimi model, stronger on long-horizon repo work with less overthinking",
15
15
  "family": "kimi-k2",
16
16
  "attachment": true,
@@ -41,132 +41,17 @@
41
41
  "output": 262144
42
42
  },
43
43
  "cost": {
44
- "input": 0.95,
45
- "output": 4,
46
- "cache_read": 0.19
47
- }
48
- },
49
- "kimi-k3": {
50
- "id": "kimi-k3",
51
- "name": "Kimi K3",
52
- "description": "Multimodal Kimi model with 1M context and toggleable max-effort thinking for long-horizon agent work",
53
- "family": "kimi-k3",
54
- "attachment": true,
55
- "reasoning": true,
56
- "reasoning_options": [
57
- {
58
- "type": "toggle"
59
- },
60
- {
61
- "type": "effort",
62
- "values": [
63
- "low",
64
- "high",
65
- "max"
66
- ]
67
- }
68
- ],
69
- "tool_call": true,
70
- "interleaved": {
71
- "field": "reasoning_content"
72
- },
73
- "structured_output": true,
74
- "temperature": false,
75
- "release_date": "2026-07-16",
76
- "last_updated": "2026-07-16",
77
- "modalities": {
78
- "input": [
79
- "text",
80
- "image",
81
- "video"
82
- ],
83
- "output": [
84
- "text"
85
- ]
86
- },
87
- "open_weights": true,
88
- "limit": {
89
- "context": 1048576,
90
- "output": 131072
91
- },
92
- "cost": {
93
- "input": 3,
94
- "output": 15,
95
- "cache_read": 0.3
96
- }
97
- },
98
- "kimi-k2-0711-preview": {
99
- "id": "kimi-k2-0711-preview",
100
- "name": "Kimi K2 0711",
101
- "description": "Kimi model for long-context chat, coding, and agentic reasoning",
102
- "family": "kimi-k2",
103
- "attachment": false,
104
- "reasoning": false,
105
- "tool_call": true,
106
- "temperature": true,
107
- "knowledge": "2024-10",
108
- "release_date": "2025-07-14",
109
- "last_updated": "2025-07-14",
110
- "modalities": {
111
- "input": [
112
- "text"
113
- ],
114
- "output": [
115
- "text"
116
- ]
117
- },
118
- "open_weights": true,
119
- "limit": {
120
- "context": 131072,
121
- "output": 16384
122
- },
123
- "cost": {
124
- "input": 0.6,
125
- "output": 2.5,
126
- "cache_read": 0.15
127
- }
128
- },
129
- "kimi-k2-thinking-turbo": {
130
- "id": "kimi-k2-thinking-turbo",
131
- "name": "Kimi K2 Thinking Turbo",
132
- "description": "Kimi reasoning model for long-horizon research, planning, and tool use",
133
- "family": "kimi-thinking",
134
- "attachment": false,
135
- "reasoning": true,
136
- "reasoning_options": [],
137
- "tool_call": true,
138
- "interleaved": {
139
- "field": "reasoning_content"
140
- },
141
- "temperature": true,
142
- "knowledge": "2024-08",
143
- "release_date": "2025-11-06",
144
- "last_updated": "2025-11-06",
145
- "modalities": {
146
- "input": [
147
- "text"
148
- ],
149
- "output": [
150
- "text"
151
- ]
152
- },
153
- "open_weights": true,
154
- "limit": {
155
- "context": 262144,
156
- "output": 262144
157
- },
158
- "cost": {
159
- "input": 1.15,
44
+ "input": 1.9,
160
45
  "output": 8,
161
- "cache_read": 0.15
46
+ "cache_read": 0.38
162
47
  }
163
48
  },
164
- "kimi-k2.5": {
165
- "id": "kimi-k2.5",
166
- "name": "Kimi K2.5",
167
- "description": "Earlier Kimi frontier model for long-context agents, coding, and multimodal work",
49
+ "kimi-k2.6": {
50
+ "id": "kimi-k2.6",
51
+ "name": "Kimi K2.6",
52
+ "description": "Multimodal Kimi workhorse for agent loops, coding tasks, and visual context",
168
53
  "family": "kimi-k2",
169
- "attachment": false,
54
+ "attachment": true,
170
55
  "reasoning": true,
171
56
  "reasoning_options": [
172
57
  {
@@ -178,10 +63,10 @@
178
63
  "field": "reasoning_content"
179
64
  },
180
65
  "structured_output": true,
181
- "temperature": false,
66
+ "temperature": true,
182
67
  "knowledge": "2025-01",
183
- "release_date": "2026-01",
184
- "last_updated": "2026-01",
68
+ "release_date": "2026-04-21",
69
+ "last_updated": "2026-04-21",
185
70
  "modalities": {
186
71
  "input": [
187
72
  "text",
@@ -198,76 +83,14 @@
198
83
  "output": 262144
199
84
  },
200
85
  "cost": {
201
- "input": 0.6,
202
- "output": 3,
203
- "cache_read": 0.1
204
- }
205
- },
206
- "kimi-k2-0905-preview": {
207
- "id": "kimi-k2-0905-preview",
208
- "name": "Kimi K2 0905",
209
- "description": "Kimi model for long-context chat, coding, and agentic reasoning",
210
- "family": "kimi-k2",
211
- "attachment": false,
212
- "reasoning": false,
213
- "tool_call": true,
214
- "temperature": true,
215
- "knowledge": "2024-10",
216
- "release_date": "2025-09-05",
217
- "last_updated": "2025-09-05",
218
- "modalities": {
219
- "input": [
220
- "text"
221
- ],
222
- "output": [
223
- "text"
224
- ]
225
- },
226
- "open_weights": true,
227
- "limit": {
228
- "context": 262144,
229
- "output": 262144
230
- },
231
- "cost": {
232
- "input": 0.6,
233
- "output": 2.5,
234
- "cache_read": 0.15
235
- }
236
- },
237
- "kimi-k2-turbo-preview": {
238
- "id": "kimi-k2-turbo-preview",
239
- "name": "Kimi K2 Turbo",
240
- "description": "Fast Kimi model for responsive chat, coding help, and agent loops",
241
- "family": "kimi-k2",
242
- "attachment": false,
243
- "reasoning": false,
244
- "tool_call": true,
245
- "temperature": true,
246
- "knowledge": "2024-10",
247
- "release_date": "2025-09-05",
248
- "last_updated": "2025-09-05",
249
- "modalities": {
250
- "input": [
251
- "text"
252
- ],
253
- "output": [
254
- "text"
255
- ]
256
- },
257
- "open_weights": true,
258
- "limit": {
259
- "context": 262144,
260
- "output": 262144
261
- },
262
- "cost": {
263
- "input": 2.4,
264
- "output": 10,
265
- "cache_read": 0.6
86
+ "input": 0.95,
87
+ "output": 4,
88
+ "cache_read": 0.16
266
89
  }
267
90
  },
268
- "kimi-k2.7-code-highspeed": {
269
- "id": "kimi-k2.7-code-highspeed",
270
- "name": "Kimi K2.7 Code HighSpeed",
91
+ "kimi-k2.7-code": {
92
+ "id": "kimi-k2.7-code",
93
+ "name": "Kimi K2.7 Code",
271
94
  "description": "Coding-focused Kimi model, stronger on long-horizon repo work with less overthinking",
272
95
  "family": "kimi-k2",
273
96
  "attachment": true,
@@ -298,56 +121,29 @@
298
121
  "output": 262144
299
122
  },
300
123
  "cost": {
301
- "input": 1.9,
302
- "output": 8,
303
- "cache_read": 0.38
304
- }
305
- },
306
- "kimi-k2-thinking": {
307
- "id": "kimi-k2-thinking",
308
- "name": "Kimi K2 Thinking",
309
- "description": "Thinking Kimi model for slower research passes, planning, and hard technical questions",
310
- "family": "kimi-thinking",
311
- "attachment": false,
312
- "reasoning": true,
313
- "reasoning_options": [],
314
- "tool_call": true,
315
- "interleaved": {
316
- "field": "reasoning_content"
317
- },
318
- "temperature": true,
319
- "knowledge": "2024-08",
320
- "release_date": "2025-11-06",
321
- "last_updated": "2025-11-06",
322
- "modalities": {
323
- "input": [
324
- "text"
325
- ],
326
- "output": [
327
- "text"
328
- ]
329
- },
330
- "open_weights": true,
331
- "limit": {
332
- "context": 262144,
333
- "output": 262144
334
- },
335
- "cost": {
336
- "input": 0.6,
337
- "output": 2.5,
338
- "cache_read": 0.15
124
+ "input": 0.95,
125
+ "output": 4,
126
+ "cache_read": 0.19
339
127
  }
340
128
  },
341
- "kimi-k2.6": {
342
- "id": "kimi-k2.6",
343
- "name": "Kimi K2.6",
344
- "description": "Multimodal Kimi workhorse for agent loops, coding tasks, and visual context",
345
- "family": "kimi-k2",
129
+ "kimi-k3": {
130
+ "id": "kimi-k3",
131
+ "name": "Kimi K3",
132
+ "description": "Multimodal Kimi model with 1M context and toggleable max-effort thinking for long-horizon agent work",
133
+ "family": "kimi-k3",
346
134
  "attachment": true,
347
135
  "reasoning": true,
348
136
  "reasoning_options": [
349
137
  {
350
138
  "type": "toggle"
139
+ },
140
+ {
141
+ "type": "effort",
142
+ "values": [
143
+ "low",
144
+ "high",
145
+ "max"
146
+ ]
351
147
  }
352
148
  ],
353
149
  "tool_call": true,
@@ -355,10 +151,9 @@
355
151
  "field": "reasoning_content"
356
152
  },
357
153
  "structured_output": true,
358
- "temperature": true,
359
- "knowledge": "2025-01",
360
- "release_date": "2026-04-21",
361
- "last_updated": "2026-04-21",
154
+ "temperature": false,
155
+ "release_date": "2026-07-16",
156
+ "last_updated": "2026-07-16",
362
157
  "modalities": {
363
158
  "input": [
364
159
  "text",
@@ -371,13 +166,13 @@
371
166
  },
372
167
  "open_weights": true,
373
168
  "limit": {
374
- "context": 262144,
375
- "output": 262144
169
+ "context": 1048576,
170
+ "output": 131072
376
171
  },
377
172
  "cost": {
378
- "input": 0.95,
379
- "output": 4,
380
- "cache_read": 0.16
173
+ "input": 3,
174
+ "output": 15,
175
+ "cache_read": 0.3
381
176
  }
382
177
  }
383
178
  }