clanka 0.16.1 → 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 -6
- package/dist/ModelsRepo.d.ts.map +1 -1
- package/dist/ModelsRepo.js +44 -27
- package/dist/ModelsRepo.js.map +1 -1
- package/dist/ModelsRepo.test.js +47 -3
- 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 +1256 -12867
- 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 +69 -3
- package/src/ModelsRepo.ts +24 -8
- 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,11 +98,26 @@ 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
|
},
|
|
@@ -115,6 +130,12 @@ const catalog = [
|
|
|
115
130
|
name: "Claude Fable 5.1",
|
|
116
131
|
efforts: ["low", "high"],
|
|
117
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
|
+
}),
|
|
118
139
|
new ModelsRepo.ModelInfo({
|
|
119
140
|
provider: "openai",
|
|
120
141
|
id: "gpt-6-astra",
|
|
@@ -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,7 +214,7 @@ 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)
|
|
@@ -231,6 +269,34 @@ describe("ModelsRepo.layerModelsDev", () => {
|
|
|
231
269
|
}).pipe(Effect.provide(KeyValueStore.layerMemory)),
|
|
232
270
|
)
|
|
233
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
|
+
|
|
234
300
|
it.effect("serves an expired cached catalog when the refresh fails", () =>
|
|
235
301
|
Effect.gen(function* () {
|
|
236
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
|
|
@@ -106,6 +112,7 @@ const providerIds: ReadonlyArray<readonly [string, Provider]> = [
|
|
|
106
112
|
["openai", "openai"],
|
|
107
113
|
["github-copilot", "copilot"],
|
|
108
114
|
["xai", "xai"],
|
|
115
|
+
["anthropic", "claude"],
|
|
109
116
|
]
|
|
110
117
|
|
|
111
118
|
const ModelsDevApi = Schema.Struct(
|
|
@@ -117,8 +124,9 @@ const ModelsDevApi = Schema.Struct(
|
|
|
117
124
|
const decodeModel = Schema.decodeUnknownOption(ModelsDevModel)
|
|
118
125
|
const isThoughtLevel = Schema.is(ThoughtLevel)
|
|
119
126
|
|
|
120
|
-
const toCatalog = (api: typeof ModelsDevApi.Type): ReadonlyArray<ModelInfo> =>
|
|
121
|
-
|
|
127
|
+
const toCatalog = (api: typeof ModelsDevApi.Type): ReadonlyArray<ModelInfo> => {
|
|
128
|
+
const counts = new Map<Provider, number>()
|
|
129
|
+
return providerIds
|
|
122
130
|
.flatMap(([id, provider]) =>
|
|
123
131
|
Object.values(api[id]?.models ?? {}).flatMap((entry) => {
|
|
124
132
|
const model = Option.getOrUndefined(decodeModel(entry))
|
|
@@ -138,7 +146,13 @@ const toCatalog = (api: typeof ModelsDevApi.Type): ReadonlyArray<ModelInfo> =>
|
|
|
138
146
|
(b.release_date ?? "").localeCompare(a.release_date ?? "") ||
|
|
139
147
|
a.name.localeCompare(b.name),
|
|
140
148
|
)
|
|
141
|
-
.
|
|
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
|
+
})
|
|
142
156
|
.map((model) => {
|
|
143
157
|
const effort = model.reasoning_options?.find(
|
|
144
158
|
(option) => option.type === "effort",
|
|
@@ -150,6 +164,7 @@ const toCatalog = (api: typeof ModelsDevApi.Type): ReadonlyArray<ModelInfo> =>
|
|
|
150
164
|
efforts: (effort?.values ?? []).filter(isThoughtLevel),
|
|
151
165
|
})
|
|
152
166
|
})
|
|
167
|
+
}
|
|
153
168
|
|
|
154
169
|
class CachedCatalog extends Schema.Class<CachedCatalog>(
|
|
155
170
|
"clanka/ModelsRepo/CachedCatalog",
|
|
@@ -185,10 +200,11 @@ export class ModelsRepo extends Context.Service<
|
|
|
185
200
|
|
|
186
201
|
/**
|
|
187
202
|
* The catalog built from `https://models.dev/api.json`: the `openai`,
|
|
188
|
-
* `github-copilot` and `
|
|
189
|
-
* tool calls. Keeps the 10 newest models
|
|
190
|
-
*
|
|
191
|
-
*
|
|
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).
|
|
192
208
|
* Serves the cached catalog when the fetch fails, then `fallback`.
|
|
193
209
|
*
|
|
194
210
|
* @since 1.0.0
|
package/src/cli.ts
CHANGED