clanka 0.16.0 → 0.17.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.
- package/README.md +61 -0
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +5 -1
- package/dist/Agent.js.map +1 -1
- package/dist/ClaudeAgent.d.ts +111 -0
- package/dist/ClaudeAgent.d.ts.map +1 -0
- package/dist/ClaudeAgent.js +772 -0
- package/dist/ClaudeAgent.js.map +1 -0
- package/dist/ClaudeAgent.test.d.ts +2 -0
- package/dist/ClaudeAgent.test.d.ts.map +1 -0
- package/dist/ClaudeAgent.test.js +416 -0
- package/dist/ClaudeAgent.test.js.map +1 -0
- package/dist/ModelLayer.d.ts +2 -2
- package/dist/ModelLayer.d.ts.map +1 -1
- package/dist/ModelLayer.js +13 -7
- package/dist/ModelLayer.js.map +1 -1
- package/dist/ModelLayer.test.js +3 -0
- package/dist/ModelLayer.test.js.map +1 -1
- package/dist/ModelsRepo.d.ts +7 -4
- package/dist/ModelsRepo.d.ts.map +1 -1
- package/dist/ModelsRepo.js +44 -19
- package/dist/ModelsRepo.js.map +1 -1
- package/dist/ModelsRepo.test.js +86 -9
- package/dist/ModelsRepo.test.js.map +1 -1
- package/dist/bin/{Effect-4B1lzxy4.mjs → Effect-On-1ks2z.mjs} +50 -2
- package/dist/bin/Effect-On-1ks2z.mjs.map +1 -0
- package/dist/bin/{McpClient-DMfHHEx3.mjs → McpClient-iwrW83Si.mjs} +3 -3
- package/dist/bin/{McpClient-DMfHHEx3.mjs.map → McpClient-iwrW83Si.mjs.map} +1 -1
- package/dist/bin/{OutputFormatter-DRycCEdr.mjs → OutputFormatter-DeNaqhQM.mjs} +3 -3
- package/dist/bin/{OutputFormatter-DRycCEdr.mjs.map → OutputFormatter-DeNaqhQM.mjs.map} +1 -1
- package/dist/bin/{Schema-D4fxUgEU.mjs → Schema-B3pFcw4E.mjs} +2 -2
- package/dist/bin/{Schema-D4fxUgEU.mjs.map → Schema-B3pFcw4E.mjs.map} +1 -1
- package/dist/bin/{SemanticSearch-BcLFv9qz.mjs → SemanticSearch-BZIXkWYz.mjs} +4 -4
- package/dist/bin/{SemanticSearch-BcLFv9qz.mjs.map → SemanticSearch-BZIXkWYz.mjs.map} +1 -1
- package/dist/bin/{Stream-i37nF1ep.mjs → Stream-DCB3_nIX.mjs} +91 -12
- package/dist/bin/Stream-DCB3_nIX.mjs.map +1 -0
- package/dist/bin/cli.mjs +1255 -12860
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/helpers-BPLUsjsL.mjs +7191 -0
- package/dist/bin/helpers-BPLUsjsL.mjs.map +1 -0
- package/dist/bin/{rolldown-runtime-zY4HT0JA.mjs → rolldown-runtime-Cjv6nE1W.mjs} +14 -1
- package/dist/bin/server-CBmuybpI.mjs +321 -0
- package/dist/bin/server-CBmuybpI.mjs.map +1 -0
- package/dist/bin/{turndown.cjs-LntFxFyd.mjs → turndown.cjs-cie0BXQQ.mjs} +2 -2
- package/dist/bin/{turndown.cjs-LntFxFyd.mjs.map → turndown.cjs-cie0BXQQ.mjs.map} +1 -1
- package/dist/bin/types-RT_9fFNm.mjs +5278 -0
- package/dist/bin/types-RT_9fFNm.mjs.map +1 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -1
- package/src/Agent.ts +7 -1
- package/src/ClaudeAgent.test.ts +526 -0
- package/src/ClaudeAgent.ts +1113 -0
- package/src/ModelLayer.test.ts +4 -0
- package/src/ModelLayer.ts +21 -15
- package/src/ModelsRepo.test.ts +123 -9
- package/src/ModelsRepo.ts +53 -26
- package/src/cli.ts +4 -0
- package/src/index.ts +5 -0
- package/dist/bin/Effect-4B1lzxy4.mjs.map +0 -1
- package/dist/bin/Stream-i37nF1ep.mjs.map +0 -1
package/src/ModelLayer.test.ts
CHANGED
|
@@ -132,4 +132,8 @@ describe("ModelLayer.makeAcp", () => {
|
|
|
132
132
|
it("rejects ids that are not <provider>:<model>", () => {
|
|
133
133
|
assert.isTrue(Option.isNone(makeModel("nope", "high")))
|
|
134
134
|
})
|
|
135
|
+
|
|
136
|
+
it("builds claude models", () => {
|
|
137
|
+
assert.isTrue(Option.isSome(makeModel("claude:claude-opus-5-5", "high")))
|
|
138
|
+
})
|
|
135
139
|
})
|
package/src/ModelLayer.ts
CHANGED
|
@@ -13,6 +13,7 @@ import * as Option from "effect/Option"
|
|
|
13
13
|
import * as Schema from "effect/Schema"
|
|
14
14
|
import { ThoughtLevel } from "./Acp.ts"
|
|
15
15
|
import * as Agent from "./Agent.ts"
|
|
16
|
+
import * as ClaudeAgent from "./ClaudeAgent.ts"
|
|
16
17
|
import * as Codex from "./Codex.ts"
|
|
17
18
|
import * as Copilot from "./Copilot.ts"
|
|
18
19
|
import * as ModelsRepo from "./ModelsRepo.ts"
|
|
@@ -59,21 +60,26 @@ export const make = (
|
|
|
59
60
|
const openaiOptions = fastMode
|
|
60
61
|
? { ...options, service_tier: "priority" }
|
|
61
62
|
: options
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
switch (provider) {
|
|
64
|
+
case "openai":
|
|
65
|
+
return openai.apiKey !== undefined
|
|
66
|
+
? withSubagentModel(Codex.model(model, openaiOptions)).pipe(
|
|
67
|
+
Layer.provide(OpenAiClient.layer(openai)),
|
|
68
|
+
)
|
|
69
|
+
: withSubagentModel(Codex.modelWebSocket(model, openaiOptions)).pipe(
|
|
70
|
+
Layer.provide(Codex.layerClient),
|
|
71
|
+
)
|
|
72
|
+
case "xai":
|
|
73
|
+
return withSubagentModel(Xai.modelWebSocket(model, options)).pipe(
|
|
74
|
+
Layer.provide(Xai.layerClient),
|
|
75
|
+
)
|
|
76
|
+
case "claude":
|
|
77
|
+
return withSubagentModel(ClaudeAgent.model(model, { effort }))
|
|
78
|
+
case "copilot":
|
|
79
|
+
return withSubagentModel(Copilot.model(model, options)).pipe(
|
|
80
|
+
Layer.provide(Copilot.layerClient),
|
|
81
|
+
)
|
|
82
|
+
}
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
const isProvider = Schema.is(ModelsRepo.Provider)
|
package/src/ModelsRepo.test.ts
CHANGED
|
@@ -98,29 +98,50 @@ const apiJson = {
|
|
|
98
98
|
id: "anthropic",
|
|
99
99
|
name: "Anthropic",
|
|
100
100
|
models: {
|
|
101
|
-
"claude-opus-5
|
|
102
|
-
id: "claude-opus-5
|
|
101
|
+
"claude-opus-5-5": {
|
|
102
|
+
id: "claude-opus-5-5",
|
|
103
103
|
name: "Claude Opus 5.5",
|
|
104
104
|
tool_call: true,
|
|
105
105
|
reasoning: true,
|
|
106
|
+
reasoning_options: [
|
|
107
|
+
{ type: "effort", values: ["low", "medium", "high", "xhigh", "max"] },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
google: {
|
|
113
|
+
id: "google",
|
|
114
|
+
name: "Google",
|
|
115
|
+
models: {
|
|
116
|
+
"gemini-4-pro": {
|
|
117
|
+
id: "gemini-4-pro",
|
|
118
|
+
name: "Gemini 4 Pro",
|
|
119
|
+
tool_call: true,
|
|
120
|
+
reasoning: true,
|
|
106
121
|
},
|
|
107
122
|
},
|
|
108
123
|
},
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
const catalog = [
|
|
112
|
-
new ModelsRepo.ModelInfo({
|
|
113
|
-
provider: "openai",
|
|
114
|
-
id: "gpt-6-astra",
|
|
115
|
-
name: "GPT-6 Astra",
|
|
116
|
-
efforts: ["low", "medium", "high", "xhigh", "max"],
|
|
117
|
-
}),
|
|
118
127
|
new ModelsRepo.ModelInfo({
|
|
119
128
|
provider: "copilot",
|
|
120
129
|
id: "claude-fable-5.1",
|
|
121
130
|
name: "Claude Fable 5.1",
|
|
122
131
|
efforts: ["low", "high"],
|
|
123
132
|
}),
|
|
133
|
+
new ModelsRepo.ModelInfo({
|
|
134
|
+
provider: "claude",
|
|
135
|
+
id: "claude-opus-5-5",
|
|
136
|
+
name: "Claude Opus 5.5",
|
|
137
|
+
efforts: ["low", "medium", "high", "xhigh", "max"],
|
|
138
|
+
}),
|
|
139
|
+
new ModelsRepo.ModelInfo({
|
|
140
|
+
provider: "openai",
|
|
141
|
+
id: "gpt-6-astra",
|
|
142
|
+
name: "GPT-6 Astra",
|
|
143
|
+
efforts: ["low", "medium", "high", "xhigh", "max"],
|
|
144
|
+
}),
|
|
124
145
|
new ModelsRepo.ModelInfo({
|
|
125
146
|
provider: "xai",
|
|
126
147
|
id: "grok-4.6",
|
|
@@ -135,6 +156,23 @@ const catalog = [
|
|
|
135
156
|
}),
|
|
136
157
|
]
|
|
137
158
|
|
|
159
|
+
const provider = (prefix: string, count: number, year: number) => ({
|
|
160
|
+
models: Object.fromEntries(
|
|
161
|
+
Array.from({ length: count }, (_, i) => {
|
|
162
|
+
const id = `${prefix}-${i}`
|
|
163
|
+
return [
|
|
164
|
+
id,
|
|
165
|
+
{
|
|
166
|
+
id,
|
|
167
|
+
name: id,
|
|
168
|
+
release_date: `${year}-01-${String(i + 1).padStart(2, "0")}`,
|
|
169
|
+
tool_call: true,
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
}),
|
|
173
|
+
),
|
|
174
|
+
})
|
|
175
|
+
|
|
138
176
|
const online = HttpClient.make((request) =>
|
|
139
177
|
Effect.succeed(
|
|
140
178
|
HttpClientResponse.fromWeb(
|
|
@@ -176,13 +214,89 @@ const modelsWith = (client: HttpClient.HttpClient) =>
|
|
|
176
214
|
|
|
177
215
|
describe("ModelsRepo.layerModelsDev", () => {
|
|
178
216
|
it.effect(
|
|
179
|
-
"lists the openai, copilot and
|
|
217
|
+
"lists the openai, copilot, xai and anthropic text models that accept tool calls",
|
|
180
218
|
() =>
|
|
181
219
|
Effect.gen(function* () {
|
|
182
220
|
assert.deepStrictEqual(yield* modelsWith(online), catalog)
|
|
183
221
|
}).pipe(Effect.provide(KeyValueStore.layerMemory)),
|
|
184
222
|
)
|
|
185
223
|
|
|
224
|
+
it.effect("keeps the 10 newest models, breaking date ties by name", () =>
|
|
225
|
+
Effect.gen(function* () {
|
|
226
|
+
const models = Object.fromEntries(
|
|
227
|
+
[
|
|
228
|
+
["oldest", "Alpha old", "2020-01-01"],
|
|
229
|
+
["undated-z", "Zulu undated"],
|
|
230
|
+
["first-tie", "Zulu tie", "2026-06-01"],
|
|
231
|
+
["march", "Gamma", "2026-03-01"],
|
|
232
|
+
["newest", "Zulu newest", "2026-10-01"],
|
|
233
|
+
["january", "Delta", "2026-01-01"],
|
|
234
|
+
["undated-a", "Alpha undated"],
|
|
235
|
+
["december", "Epsilon", "2025-12-01"],
|
|
236
|
+
["second-tie", "Alpha tie", "2026-06-01"],
|
|
237
|
+
["november", "Eta", "2025-11-01"],
|
|
238
|
+
["older", "Theta", "2024-01-01"],
|
|
239
|
+
].map(([id, name, release_date]) => [
|
|
240
|
+
id,
|
|
241
|
+
{ id, name, release_date, tool_call: true },
|
|
242
|
+
]),
|
|
243
|
+
)
|
|
244
|
+
const client = HttpClient.make((request) =>
|
|
245
|
+
Effect.succeed(
|
|
246
|
+
HttpClientResponse.fromWeb(
|
|
247
|
+
request,
|
|
248
|
+
new Response(JSON.stringify({ openai: { models } }), {
|
|
249
|
+
headers: { "content-type": "application/json" },
|
|
250
|
+
}),
|
|
251
|
+
),
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
assert.deepStrictEqual(
|
|
255
|
+
(yield* modelsWith(client)).map((model) => model.id),
|
|
256
|
+
[
|
|
257
|
+
"newest",
|
|
258
|
+
"second-tie",
|
|
259
|
+
"first-tie",
|
|
260
|
+
"march",
|
|
261
|
+
"january",
|
|
262
|
+
"december",
|
|
263
|
+
"november",
|
|
264
|
+
"older",
|
|
265
|
+
"oldest",
|
|
266
|
+
"undated-a",
|
|
267
|
+
],
|
|
268
|
+
)
|
|
269
|
+
}).pipe(Effect.provide(KeyValueStore.layerMemory)),
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
it.effect("caps each provider at its 10 newest models", () =>
|
|
273
|
+
Effect.gen(function* () {
|
|
274
|
+
const client = HttpClient.make((request) =>
|
|
275
|
+
Effect.succeed(
|
|
276
|
+
HttpClientResponse.fromWeb(
|
|
277
|
+
request,
|
|
278
|
+
new Response(
|
|
279
|
+
JSON.stringify({
|
|
280
|
+
openai: provider("gpt", 12, 2026),
|
|
281
|
+
anthropic: provider("claude", 12, 2025),
|
|
282
|
+
}),
|
|
283
|
+
{ headers: { "content-type": "application/json" } },
|
|
284
|
+
),
|
|
285
|
+
),
|
|
286
|
+
),
|
|
287
|
+
)
|
|
288
|
+
const models = yield* modelsWith(client)
|
|
289
|
+
assert.strictEqual(
|
|
290
|
+
models.filter((m) => m.provider === "openai").length,
|
|
291
|
+
10,
|
|
292
|
+
)
|
|
293
|
+
assert.deepStrictEqual(
|
|
294
|
+
models.filter((m) => m.provider === "claude").map((m) => m.id),
|
|
295
|
+
Array.from({ length: 10 }, (_, i) => `claude-${11 - i}`),
|
|
296
|
+
)
|
|
297
|
+
}).pipe(Effect.provide(KeyValueStore.layerMemory)),
|
|
298
|
+
)
|
|
299
|
+
|
|
186
300
|
it.effect("serves an expired cached catalog when the refresh fails", () =>
|
|
187
301
|
Effect.gen(function* () {
|
|
188
302
|
yield* modelsWith(online)
|
package/src/ModelsRepo.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { ThoughtLevel } from "./Acp.ts"
|
|
|
23
23
|
* @since 1.0.0
|
|
24
24
|
* @category Models
|
|
25
25
|
*/
|
|
26
|
-
export const Provider = Schema.Literals(["openai", "copilot", "xai"])
|
|
26
|
+
export const Provider = Schema.Literals(["openai", "copilot", "xai", "claude"])
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* @since 1.0.0
|
|
@@ -76,6 +76,12 @@ export const fallback: ReadonlyArray<ModelInfo> = [
|
|
|
76
76
|
name: "Grok 4.6",
|
|
77
77
|
efforts: ["low", "medium", "high", "xhigh"],
|
|
78
78
|
}),
|
|
79
|
+
new ModelInfo({
|
|
80
|
+
provider: "claude",
|
|
81
|
+
id: "claude-opus-5-5",
|
|
82
|
+
name: "Claude Opus 5.5",
|
|
83
|
+
efforts: ["low", "medium", "high", "xhigh", "max"],
|
|
84
|
+
}),
|
|
79
85
|
]
|
|
80
86
|
|
|
81
87
|
// The fields of a models.dev model entry the catalog reads. Entries are
|
|
@@ -84,6 +90,7 @@ const ModelsDevModel = Schema.Struct({
|
|
|
84
90
|
id: Schema.String,
|
|
85
91
|
name: Schema.String,
|
|
86
92
|
type: Schema.optionalKey(Schema.String),
|
|
93
|
+
release_date: Schema.optionalKey(Schema.String),
|
|
87
94
|
status: Schema.optionalKey(Schema.String),
|
|
88
95
|
tool_call: Schema.optionalKey(Schema.Boolean),
|
|
89
96
|
reasoning_options: Schema.optionalKey(
|
|
@@ -100,11 +107,12 @@ const ModelsDevProvider = Schema.Struct({
|
|
|
100
107
|
models: Schema.Record(Schema.String, Schema.Unknown),
|
|
101
108
|
})
|
|
102
109
|
|
|
103
|
-
// models.dev provider id to clanka provider
|
|
110
|
+
// models.dev provider id to clanka provider.
|
|
104
111
|
const providerIds: ReadonlyArray<readonly [string, Provider]> = [
|
|
105
112
|
["openai", "openai"],
|
|
106
113
|
["github-copilot", "copilot"],
|
|
107
114
|
["xai", "xai"],
|
|
115
|
+
["anthropic", "claude"],
|
|
108
116
|
]
|
|
109
117
|
|
|
110
118
|
const ModelsDevApi = Schema.Struct(
|
|
@@ -116,31 +124,47 @@ const ModelsDevApi = Schema.Struct(
|
|
|
116
124
|
const decodeModel = Schema.decodeUnknownOption(ModelsDevModel)
|
|
117
125
|
const isThoughtLevel = Schema.is(ThoughtLevel)
|
|
118
126
|
|
|
119
|
-
const toCatalog = (api: typeof ModelsDevApi.Type): ReadonlyArray<ModelInfo> =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
model
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
const toCatalog = (api: typeof ModelsDevApi.Type): ReadonlyArray<ModelInfo> => {
|
|
128
|
+
const counts = new Map<Provider, number>()
|
|
129
|
+
return providerIds
|
|
130
|
+
.flatMap(([id, provider]) =>
|
|
131
|
+
Object.values(api[id]?.models ?? {}).flatMap((entry) => {
|
|
132
|
+
const model = Option.getOrUndefined(decodeModel(entry))
|
|
133
|
+
if (
|
|
134
|
+
model === undefined ||
|
|
135
|
+
model.type !== undefined ||
|
|
136
|
+
model.status === "deprecated" ||
|
|
137
|
+
model.tool_call !== true
|
|
138
|
+
) {
|
|
139
|
+
return []
|
|
140
|
+
}
|
|
141
|
+
return [{ ...model, provider }]
|
|
142
|
+
}),
|
|
143
|
+
)
|
|
144
|
+
.toSorted(
|
|
145
|
+
(a, b) =>
|
|
146
|
+
(b.release_date ?? "").localeCompare(a.release_date ?? "") ||
|
|
147
|
+
a.name.localeCompare(b.name),
|
|
148
|
+
)
|
|
149
|
+
.filter((model) => {
|
|
150
|
+
// Keep the 10 newest per provider, so providers that list many models
|
|
151
|
+
// (or the same models as another provider) cannot crowd out the rest.
|
|
152
|
+
const count = (counts.get(model.provider) ?? 0) + 1
|
|
153
|
+
counts.set(model.provider, count)
|
|
154
|
+
return count <= 10
|
|
155
|
+
})
|
|
156
|
+
.map((model) => {
|
|
131
157
|
const effort = model.reasoning_options?.find(
|
|
132
158
|
(option) => option.type === "effort",
|
|
133
159
|
)
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}),
|
|
143
|
-
)
|
|
160
|
+
return new ModelInfo({
|
|
161
|
+
provider: model.provider,
|
|
162
|
+
id: model.id,
|
|
163
|
+
name: model.name,
|
|
164
|
+
efforts: (effort?.values ?? []).filter(isThoughtLevel),
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
}
|
|
144
168
|
|
|
145
169
|
class CachedCatalog extends Schema.Class<CachedCatalog>(
|
|
146
170
|
"clanka/ModelsRepo/CachedCatalog",
|
|
@@ -176,8 +200,11 @@ export class ModelsRepo extends Context.Service<
|
|
|
176
200
|
|
|
177
201
|
/**
|
|
178
202
|
* The catalog built from `https://models.dev/api.json`: the `openai`,
|
|
179
|
-
* `github-copilot` and `
|
|
180
|
-
* tool calls
|
|
203
|
+
* `github-copilot`, `xai` and `anthropic` (as `claude`) text models that
|
|
204
|
+
* are not deprecated and accept tool calls. Keeps the 10 newest models of
|
|
205
|
+
* each provider by release date, then name alphabetically, with undated
|
|
206
|
+
* models last. The combined catalog is in that same order. Cached
|
|
207
|
+
* in the `KeyValueStore` for `ttl` (default 24 hours).
|
|
181
208
|
* Serves the cached catalog when the fetch fails, then `fallback`.
|
|
182
209
|
*
|
|
183
210
|
* @since 1.0.0
|
package/src/cli.ts
CHANGED