clanka 0.23.1 → 0.24.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 +24 -1
- package/dist/Acp.test.js +5 -4
- package/dist/Acp.test.js.map +1 -1
- package/dist/Agent.js +2 -2
- package/dist/Agent.js.map +1 -1
- package/dist/AgentBashJobs.test.js +5 -4
- package/dist/AgentBashJobs.test.js.map +1 -1
- package/dist/AgentExecutor.test.js +1 -1
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentSubagents.test.js +19 -16
- package/dist/AgentSubagents.test.js.map +1 -1
- package/dist/ModelLayer.d.ts +31 -6
- package/dist/ModelLayer.d.ts.map +1 -1
- package/dist/ModelLayer.js +49 -7
- package/dist/ModelLayer.js.map +1 -1
- package/dist/ModelLayer.test.js +39 -0
- package/dist/ModelLayer.test.js.map +1 -1
- package/dist/ModelsRepo.d.ts +7 -5
- package/dist/ModelsRepo.d.ts.map +1 -1
- package/dist/ModelsRepo.js +12 -4
- package/dist/ModelsRepo.js.map +1 -1
- package/dist/OpenAiCompat.d.ts +59 -0
- package/dist/OpenAiCompat.d.ts.map +1 -0
- package/dist/OpenAiCompat.js +96 -0
- package/dist/OpenAiCompat.js.map +1 -0
- package/dist/OpenAiCompat.test.d.ts +2 -0
- package/dist/OpenAiCompat.test.d.ts.map +1 -0
- package/dist/OpenAiCompat.test.js +110 -0
- package/dist/OpenAiCompat.test.js.map +1 -0
- package/dist/bin/cli.mjs +108 -51
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/cli.js +38 -31
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/src/Acp.test.ts +8 -4
- package/src/Agent.ts +2 -2
- package/src/AgentBashJobs.test.ts +16 -5
- package/src/AgentExecutor.test.ts +1 -1
- package/src/AgentSubagents.test.ts +25 -23
- package/src/ModelLayer.test.ts +62 -0
- package/src/ModelLayer.ts +60 -7
- package/src/ModelsRepo.ts +12 -4
- package/src/OpenAiCompat.test.ts +166 -0
- package/src/OpenAiCompat.ts +175 -0
- package/src/cli.ts +51 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAiCompat.test.js","sourceRoot":"","sources":["../src/OpenAiCompat.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAEpD,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,uBAAuB;IAC/B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;CACnC,CAAA;AAED,4EAA4E;AAC5E,MAAM,SAAS,GAAG,CAAC,QAAwB,EAAE,EAAE;IAC7C,MAAM,QAAQ,GAA+C,EAAE,CAAA;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CACzB,UAAU,CAAC,UAAU,EACrB,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC1B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACtB,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;IACxD,CAAC,CAAC,CACH,C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8B,CAAC,CAAA;QACpE,MAAM,CAAC,WAAW,CAChB,QAAQ,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,aAAa,EAClC,kBAAkB,CACnB,CAAA;QACD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE;YAC7B,IAAI;YACJ,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,GAAG,CACrC,CAAC,EAAE,EAAE,EAAE,CACL,IAAI,UAAU,CAAC,SAAS,CAAC;gBACvB,QAAQ,EAAE,eAAe;gBACzB,EAAE;gBACF,IAAI,EAAE,EAAE;aACT,CAAC,CACL;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CACL,CAAA;IAED,EAAE,CAAC,MAAM,CAAC,sDAAsD,EAAE,GAAG,EAAE,CACrE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAC/B,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAC1C,CAAA;QACD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/dist/bin/cli.mjs
CHANGED
|
@@ -21423,7 +21423,7 @@ const makeMailbox = () => ({
|
|
|
21423
21423
|
const taskMessage = (task) => {
|
|
21424
21424
|
const exitCode = task.exitCode === void 0 ? "" : ` exitCode="${task.exitCode}"`;
|
|
21425
21425
|
return `<task id="${task.id}" kind="${task.kind}" status="${task.status}"${exitCode}>
|
|
21426
|
-
${
|
|
21426
|
+
To read the output, call taskOutput(${JSON.stringify(task.id)}).
|
|
21427
21427
|
</task>`;
|
|
21428
21428
|
};
|
|
21429
21429
|
const makeTurn = (background) => ({
|
|
@@ -21478,7 +21478,7 @@ const taskInstructions = (tools) => {
|
|
|
21478
21478
|
["listTasks", `"listTasks" lists yours`]
|
|
21479
21479
|
].filter(([name]) => tools.offers(name)).map(([, text]) => text);
|
|
21480
21480
|
return `
|
|
21481
|
-
- ${bash && subagent ? "Background commands and sub-agents are" : bash ? "Background commands are" : "Sub-agents are"} tasks with ids.${functions.length === 0 ? "" : ` ${functions.length === 1 ? functions[0] : `${functions.slice(0, -1).join(", ")} and ${functions.at(-1)}`}.`}${tools.taskPushes ? ` When a task ends, its status and output are sent to you as a \`<task id="..." kind="..." status="...">\` message, unless a task function already gave you its final status, so you do not need to poll.` : bash && tools.offers("taskOutput") ? ` Background commands are not sent to you when they end: check them with "taskOutput".` : ""}`;
|
|
21481
|
+
- ${bash && subagent ? "Background commands and sub-agents are" : bash ? "Background commands are" : "Sub-agents are"} tasks with ids.${functions.length === 0 ? "" : ` ${functions.length === 1 ? functions[0] : `${functions.slice(0, -1).join(", ")} and ${functions.at(-1)}`}.`}${tools.taskPushes ? ` When a task ends, its status and a call to retrieve its output are sent to you as a \`<task id="..." kind="..." status="...">\` message, unless a task function already gave you its final status, so you do not need to poll.` : bash && tools.offers("taskOutput") ? ` Background commands are not sent to you when they end: check them with "taskOutput".` : ""}`;
|
|
21482
21482
|
};
|
|
21483
21483
|
const generateSystemTools = (tools, conversationMode) => `YOU ONLY HAVE ONE TOOL AVAILABLE: "execute", to run javascript code to do your work.
|
|
21484
21484
|
|
|
@@ -22395,7 +22395,7 @@ const load = fnUntraced(function* (options) {
|
|
|
22395
22395
|
const text = yield* fs.readFileString(file).pipe(catchReason("PlatformError", "NotFound", (_, error) => required ? fail$1(error) : void_), mapError((error) => fail(error.message)));
|
|
22396
22396
|
if (text === void 0) continue;
|
|
22397
22397
|
const { mcpServers } = yield* decodeFile(text).pipe(mapError((error) => fail(error.message)));
|
|
22398
|
-
for (const [name, entry] of Object.entries(mcpServers ?? {})) servers[name] = yield* decodeEntry(entry, {
|
|
22398
|
+
for (const [name, entry] of Object.entries(mcpServers ?? {})) servers[name] = yield* decodeEntry$1(entry, {
|
|
22399
22399
|
directory: path.dirname(file),
|
|
22400
22400
|
fail: (message) => fail(`MCP server "${name}": ${message}`),
|
|
22401
22401
|
resolve: path.resolve
|
|
@@ -22403,7 +22403,7 @@ const load = fnUntraced(function* (options) {
|
|
|
22403
22403
|
}
|
|
22404
22404
|
return servers;
|
|
22405
22405
|
});
|
|
22406
|
-
const decodeEntry = fnUntraced(function* (raw, options) {
|
|
22406
|
+
const decodeEntry$1 = fnUntraced(function* (raw, options) {
|
|
22407
22407
|
const entry = yield* decodeFileEntry(yield* expandEntry(raw)).pipe(mapError((error) => options.fail(error.message)));
|
|
22408
22408
|
switch (entry.type ?? (entry.command !== void 0 ? "stdio" : entry.url !== void 0 ? "http" : void 0)) {
|
|
22409
22409
|
case void 0: return yield* options.fail("needs a command or a url");
|
|
@@ -26435,7 +26435,7 @@ const mapProviderResults = (inputLength, results) => {
|
|
|
26435
26435
|
};
|
|
26436
26436
|
// node_modules/.pnpm/@effect+ai-openai@4.1.1_effect@4.1.1/node_modules/@effect/ai-openai/dist/OpenAiEmbeddingModel.js
|
|
26437
26437
|
var Config$2 = class extends Service()("@effect/ai-openai/OpenAiEmbeddingModel/Config") {};
|
|
26438
|
-
const model$
|
|
26438
|
+
const model$5 = (model, options) => make$19("openai", model, merge$2(layer$3({
|
|
26439
26439
|
model,
|
|
26440
26440
|
config: {
|
|
26441
26441
|
...options.config,
|
|
@@ -28631,7 +28631,7 @@ const transformToolCallParams$1 = fnUntraced(function* (options, toolName, toolP
|
|
|
28631
28631
|
return yield* decodeEffect(codec)(toolParams).pipe(flatMap$1((decoded) => encodeUnknownEffect(tool.parametersSchema)(decoded)), orElseSucceed(() => toolParams));
|
|
28632
28632
|
});
|
|
28633
28633
|
// package.json
|
|
28634
|
-
var version$1 = "0.
|
|
28634
|
+
var version$1 = "0.24.0";
|
|
28635
28635
|
// src/ClaudeAgent.ts
|
|
28636
28636
|
const minimumClaudeCodeVersion = "2.1.248";
|
|
28637
28637
|
const serverName = "clanka";
|
|
@@ -29304,7 +29304,7 @@ const toParts = (parts) => {
|
|
|
29304
29304
|
}
|
|
29305
29305
|
return result;
|
|
29306
29306
|
};
|
|
29307
|
-
const model$
|
|
29307
|
+
const model$4 = (model, options) => make$19("claude", model, merge$2(layerLanguageModel(model, options), AgentModelConfig.layer({
|
|
29308
29308
|
supportsImages: options?.supportsImages,
|
|
29309
29309
|
cutStreamOnSteering: false
|
|
29310
29310
|
})));
|
|
@@ -29542,8 +29542,8 @@ var CodexAuth = class CodexAuth extends Service()("clanka/CodexAuth") {
|
|
|
29542
29542
|
static layerClient = this.layerClientNoDeps.pipe(provide$3(CodexAuth.layer));
|
|
29543
29543
|
};
|
|
29544
29544
|
// src/Codex.ts
|
|
29545
|
-
const layerClient$
|
|
29546
|
-
const model$
|
|
29545
|
+
const layerClient$3 = layer$4({ apiUrl: "https://chatgpt.com/backend-api/codex" }).pipe(provide$3(CodexAuth.layerClient));
|
|
29546
|
+
const model$3 = (model, options) => make$19("openai", model, layerModel(model, options));
|
|
29547
29547
|
const modelWebSocket$1 = (model, options) => make$19("openai", model, layerModel(model, options).pipe(merge$2(fresh(layerWebSocketMode))));
|
|
29548
29548
|
const layerModel = (model, options) => suspend$1(() => layer$2({
|
|
29549
29549
|
model,
|
|
@@ -30879,8 +30879,8 @@ var GithubCopilotAuth = class GithubCopilotAuth extends Service()("clanka/Github
|
|
|
30879
30879
|
static layerClient = this.layerClientNoDeps.pipe(provide$3(GithubCopilotAuth.layer));
|
|
30880
30880
|
};
|
|
30881
30881
|
// src/Copilot.ts
|
|
30882
|
-
const layerClient$
|
|
30883
|
-
const model$
|
|
30882
|
+
const layerClient$2 = layer$1({ apiUrl: API_URL }).pipe(provide$3(GithubCopilotAuth.layerClient));
|
|
30883
|
+
const model$2 = (model, options) => make$19("openai", model, mergeAll(layer({
|
|
30884
30884
|
model,
|
|
30885
30885
|
config: omit(options ?? {}, options?.reasoning === null ? ["reasoning", ...AgentModelConfig.optionKeys] : AgentModelConfig.optionKeys)
|
|
30886
30886
|
}), AgentModelConfig.layer(pick(options ?? {}, AgentModelConfig.optionKeys)), succeed$4(SummarizerTransform, (effect) => withConfigOverride(effect, { max_output_tokens: summarizerMaxOutputTokens }))));
|
|
@@ -30889,13 +30889,14 @@ const Provider = Literals$2([
|
|
|
30889
30889
|
"openai",
|
|
30890
30890
|
"copilot",
|
|
30891
30891
|
"xai",
|
|
30892
|
-
"claude"
|
|
30892
|
+
"claude",
|
|
30893
|
+
"openai-compat"
|
|
30893
30894
|
]);
|
|
30894
30895
|
var ModelInfo = class extends Class$1("clanka/ModelsRepo/ModelInfo")({
|
|
30895
30896
|
provider: Provider,
|
|
30896
30897
|
id: String$7,
|
|
30897
30898
|
name: String$7,
|
|
30898
|
-
efforts: ArraySchema(ThoughtLevel)
|
|
30899
|
+
efforts: optionalKey(ArraySchema(ThoughtLevel))
|
|
30899
30900
|
}) {};
|
|
30900
30901
|
const fallback = [
|
|
30901
30902
|
new ModelInfo({
|
|
@@ -31014,6 +31015,34 @@ var ModelsRepo = class ModelsRepo extends Service()("clanka/ModelsRepo") {
|
|
|
31014
31015
|
return ModelsRepo.of({ models: yield* cached(load) });
|
|
31015
31016
|
}));
|
|
31016
31017
|
};
|
|
31018
|
+
// src/OpenAiCompat.ts
|
|
31019
|
+
const layerClient$1 = (options) => layer$1(options);
|
|
31020
|
+
const model$1 = (model, options) => make$19("openai-compat", model, mergeAll(layer({
|
|
31021
|
+
model,
|
|
31022
|
+
config: {
|
|
31023
|
+
...omit(options ?? {}, ["reasoning", ...AgentModelConfig.optionKeys]),
|
|
31024
|
+
...options?.reasoning?.effort === void 0 ? void 0 : { reasoning_effort: options.reasoning.effort }
|
|
31025
|
+
}
|
|
31026
|
+
}), AgentModelConfig.layer(pick(options ?? {}, AgentModelConfig.optionKeys)), succeed$4(SummarizerTransform, (effect) => withConfigOverride(effect, { max_output_tokens: summarizerMaxOutputTokens }))));
|
|
31027
|
+
const ModelsResponse = Struct({ data: ArraySchema(Unknown) });
|
|
31028
|
+
const ModelEntry = Struct({
|
|
31029
|
+
id: String$7,
|
|
31030
|
+
created: optionalKey(Finite)
|
|
31031
|
+
});
|
|
31032
|
+
const decodeEntry = decodeUnknownOption(ModelEntry);
|
|
31033
|
+
const models = gen(function* () {
|
|
31034
|
+
const { client } = yield* OpenAiClient;
|
|
31035
|
+
return (yield* filterStatusOk(client).get("/models").pipe(flatMap$1(schemaBodyJson(ModelsResponse)))).data.flatMap((entry) => decodeEntry(entry).pipe(toArray)).toSorted((a, b) => (b.created ?? 0) - (a.created ?? 0) || a.id.localeCompare(b.id)).map((entry) => new ModelInfo({
|
|
31036
|
+
provider: "openai-compat",
|
|
31037
|
+
id: entry.id,
|
|
31038
|
+
name: entry.id
|
|
31039
|
+
}));
|
|
31040
|
+
}).pipe(timeout("15 seconds"), catch_((error) => logWarning("Failed to list the openai-compat models", error).pipe(as([]))));
|
|
31041
|
+
const layerModelsRepo = (client) => effect(ModelsRepo, gen(function* () {
|
|
31042
|
+
const repo = yield* ModelsRepo;
|
|
31043
|
+
const listed = yield* cached(provideService(models, OpenAiClient, yield* OpenAiClient));
|
|
31044
|
+
return ModelsRepo.of({ models: zipWith(repo.models, listed, (catalog, compat) => [...catalog, ...compat], { concurrent: true }) });
|
|
31045
|
+
})).pipe(provide$3(layerClient$1(client)));
|
|
31017
31046
|
// src/XaiAuth.ts
|
|
31018
31047
|
const CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
|
|
31019
31048
|
const ISSUER = "https://auth.x.ai";
|
|
@@ -31177,10 +31206,14 @@ const languageModel = (provider, model, effort, openai, fastMode) => {
|
|
|
31177
31206
|
service_tier: "priority"
|
|
31178
31207
|
} : options;
|
|
31179
31208
|
switch (provider) {
|
|
31180
|
-
case "openai": return openai.apiKey !== void 0 ? model$
|
|
31209
|
+
case "openai": return openai.apiKey !== void 0 ? model$3(model, openaiOptions).pipe(provide$3(layer$4(openai))) : modelWebSocket$1(model, openaiOptions).pipe(provide$3(layerClient$3));
|
|
31181
31210
|
case "xai": return modelWebSocket(model, options).pipe(provide$3(layerClient));
|
|
31182
|
-
case "claude": return model$
|
|
31183
|
-
case "copilot": return model$
|
|
31211
|
+
case "claude": return model$4(model, { effort });
|
|
31212
|
+
case "copilot": return model$2(model, options).pipe(provide$3(layerClient$2));
|
|
31213
|
+
case "openai-compat": return model$1(model, options).pipe(provide$3(layerClient$1({
|
|
31214
|
+
apiKey: openai.apiKey,
|
|
31215
|
+
apiUrl: openai.apiUrl
|
|
31216
|
+
})));
|
|
31184
31217
|
}
|
|
31185
31218
|
};
|
|
31186
31219
|
const make = (provider, model, effort, openai, fastMode = false, auxiliary) => {
|
|
@@ -31188,14 +31221,38 @@ const make = (provider, model, effort, openai, fastMode = false, auxiliary) => {
|
|
|
31188
31221
|
const main = languageModel(provider, model, effort, openai, fastMode);
|
|
31189
31222
|
return mergeAll(main, layerSubagentModel(auxiliary?.subagent === void 0 ? main : fromSpec(auxiliary.subagent)), layerSummarizerModel(auxiliary?.summarizer === void 0 ? main : fromSpec(auxiliary.summarizer)));
|
|
31190
31223
|
};
|
|
31191
|
-
const isProvider
|
|
31224
|
+
const isProvider = is(Provider);
|
|
31192
31225
|
const parseAcpModelId = (modelId) => {
|
|
31193
|
-
const
|
|
31194
|
-
|
|
31226
|
+
const index = modelId.indexOf(":");
|
|
31227
|
+
const provider = modelId.slice(0, index);
|
|
31228
|
+
const model = modelId.slice(index + 1);
|
|
31229
|
+
return index !== -1 && isProvider(provider) && model !== "" ? some({
|
|
31195
31230
|
provider,
|
|
31196
31231
|
model
|
|
31197
31232
|
}) : none();
|
|
31198
31233
|
};
|
|
31234
|
+
const isThoughtLevel = is(ThoughtLevel);
|
|
31235
|
+
const parseModel = (value) => {
|
|
31236
|
+
const index = value.lastIndexOf("/");
|
|
31237
|
+
const effort = value.slice(index + 1);
|
|
31238
|
+
return index > 0 && isThoughtLevel(effort) ? {
|
|
31239
|
+
model: value.slice(0, index),
|
|
31240
|
+
effort
|
|
31241
|
+
} : {
|
|
31242
|
+
model: value,
|
|
31243
|
+
effort: void 0
|
|
31244
|
+
};
|
|
31245
|
+
};
|
|
31246
|
+
const parseModelSpec = (value) => {
|
|
31247
|
+
const index = value.indexOf("/");
|
|
31248
|
+
const provider = value.slice(0, index);
|
|
31249
|
+
const { model, effort } = parseModel(value.slice(index + 1));
|
|
31250
|
+
return index !== -1 && isProvider(provider) && model !== "" ? some({
|
|
31251
|
+
provider,
|
|
31252
|
+
model,
|
|
31253
|
+
effort
|
|
31254
|
+
}) : none();
|
|
31255
|
+
};
|
|
31199
31256
|
const acpSupportsFastMode = (modelId) => exists(parseAcpModelId(modelId), ({ provider }) => supportsFastMode(provider));
|
|
31200
31257
|
const acpModels = (models) => models.map((model) => ({
|
|
31201
31258
|
modelId: `${model.provider}:${model.id}`,
|
|
@@ -31210,7 +31267,7 @@ const resolveEffort = (efforts, thoughtLevel) => {
|
|
|
31210
31267
|
};
|
|
31211
31268
|
const makeAcp = (options) => (modelId, thoughtLevel, fastMode = false) => map$8(parseAcpModelId(modelId), ({ provider, model }) => unwrap$3(map$5(options.models, (catalog) => {
|
|
31212
31269
|
const info = catalog.find((entry) => entry.provider === provider && entry.id === model);
|
|
31213
|
-
return make(provider, model, info === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai, fastMode, options.auxiliary);
|
|
31270
|
+
return make(provider, model, info?.efforts === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai, fastMode, options.auxiliary);
|
|
31214
31271
|
})));
|
|
31215
31272
|
// node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Logger.js
|
|
31216
31273
|
const LogToStderr = LogToStderr$1;
|
|
@@ -31229,6 +31286,7 @@ const providers = Provider.literals;
|
|
|
31229
31286
|
const selectModel = fnUntraced(function* (provider) {
|
|
31230
31287
|
const catalog = (yield* (yield* ModelsRepo).models).filter((model) => model.provider === provider);
|
|
31231
31288
|
const models = catalog.length > 0 ? catalog : fallback.filter((model) => model.provider === provider);
|
|
31289
|
+
if (models.length === 0) return parseModel(yield* String$5({ message: "Enter a model id" }));
|
|
31232
31290
|
const defaultId = fallback.find((model) => model.provider === provider)?.id;
|
|
31233
31291
|
const model = yield* AutoComplete({
|
|
31234
31292
|
message: "Select a model",
|
|
@@ -31239,6 +31297,10 @@ const selectModel = fnUntraced(function* (provider) {
|
|
|
31239
31297
|
selected: model.id === defaultId
|
|
31240
31298
|
}))
|
|
31241
31299
|
});
|
|
31300
|
+
if (model.efforts === void 0) return {
|
|
31301
|
+
model: model.id,
|
|
31302
|
+
effort: void 0
|
|
31303
|
+
};
|
|
31242
31304
|
if (model.efforts.length === 0) return {
|
|
31243
31305
|
model: model.id,
|
|
31244
31306
|
effort: null
|
|
@@ -31256,24 +31318,8 @@ const selectModel = fnUntraced(function* (provider) {
|
|
|
31256
31318
|
effort
|
|
31257
31319
|
};
|
|
31258
31320
|
});
|
|
31259
|
-
const
|
|
31260
|
-
const
|
|
31261
|
-
const parseModelId = (modelId) => {
|
|
31262
|
-
const [provider, model, effort, ...rest] = modelId.split("/");
|
|
31263
|
-
return isProvider(provider) && model !== void 0 && (effort === void 0 || isThoughtLevel(effort)) && rest.length === 0 ? some({
|
|
31264
|
-
model: `${provider}:${model}`,
|
|
31265
|
-
thoughtLevel: fromUndefinedOr(effort)
|
|
31266
|
-
}) : none();
|
|
31267
|
-
};
|
|
31268
|
-
const ModelId = String$7.pipe(check(makeFilter$1((modelId) => isSome(parseModelId(modelId)) || `Invalid model "${modelId}", expected <provider>/<model>[/<effort>] with effort one of ${ThoughtLevel.literals.join(", ")}`)));
|
|
31269
|
-
const auxiliaryModel = (options) => String$1(options.name).pipe(withDescription$1(`${options.description} As <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/low; also ${options.env}.`), withFallbackConfig(String$4(options.env)), withSchema(ModelId), map$1((modelId) => {
|
|
31270
|
-
const [provider, model, effort] = modelId.split("/");
|
|
31271
|
-
return {
|
|
31272
|
-
provider,
|
|
31273
|
-
model,
|
|
31274
|
-
effort
|
|
31275
|
-
};
|
|
31276
|
-
}), optional);
|
|
31321
|
+
const ModelId = String$7.pipe(check(makeFilter$1((modelId) => isSome(parseModelSpec(modelId)) || `Invalid model "${modelId}", expected <provider>/<model>[/<effort>] with provider one of ${providers.join(", ")}`)));
|
|
31322
|
+
const auxiliaryModel = (options) => String$1(options.name).pipe(withDescription$1(`${options.description} As <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/low; also ${options.env}.`), withFallbackConfig(String$4(options.env)), withSchema(ModelId), map$1((modelId) => getOrThrow$1(parseModelSpec(modelId))), optional);
|
|
31277
31323
|
const subagentModel = auxiliaryModel({
|
|
31278
31324
|
name: "subagent-model",
|
|
31279
31325
|
env: "CLANKA_SUBAGENT_MODEL",
|
|
@@ -31307,12 +31353,23 @@ const provider = Literals("provider", providers).pipe(withAlias("p"), withFallba
|
|
|
31307
31353
|
{
|
|
31308
31354
|
title: "claude",
|
|
31309
31355
|
value: "claude"
|
|
31356
|
+
},
|
|
31357
|
+
{
|
|
31358
|
+
title: "openai-compat",
|
|
31359
|
+
value: "openai-compat"
|
|
31310
31360
|
}
|
|
31311
31361
|
]
|
|
31312
31362
|
})));
|
|
31313
31363
|
const model = String$1("model").pipe(withAlias("m"), optional);
|
|
31314
|
-
const apiKey = Redacted("api-key").pipe(withDescription$1("
|
|
31315
|
-
const apiUrl = String$1("api-url").pipe(withDescription$1("
|
|
31364
|
+
const apiKey = Redacted("api-key").pipe(withDescription$1("API key for the openai API-key mode and the openai-compat provider (defaults to CLANKA_OPENAI_API_KEY)"), withFallbackConfig(Redacted$3("CLANKA_OPENAI_API_KEY")), optional);
|
|
31365
|
+
const apiUrl = String$1("api-url").pipe(withDescription$1("API base URL for the openai API-key mode and the openai-compat provider (defaults to CLANKA_OPENAI_API_URL or https://api.openai.com/v1). When set, the models it lists at /models are offered as openai-compat models."), withFallbackConfig(String$4("CLANKA_OPENAI_API_URL")), optional);
|
|
31366
|
+
const openAiCompatModels = (flags) => match$2(flags.apiUrl, {
|
|
31367
|
+
onNone: () => empty$7,
|
|
31368
|
+
onSome: (apiUrl) => layerModelsRepo({
|
|
31369
|
+
apiUrl,
|
|
31370
|
+
apiKey: getOrUndefined(flags.apiKey)
|
|
31371
|
+
})
|
|
31372
|
+
});
|
|
31316
31373
|
const fast = Boolean("fast").pipe(withDescription$1("Use OpenAI fast mode (the priority service tier) for faster responses at a higher cost. Applies to the openai provider only; also CLANKA_FAST=true."), withFallbackConfig(Boolean$3("CLANKA_FAST").pipe(withDefault$2(false))));
|
|
31317
31374
|
const semantic = Directory("search").pipe(withDescription$1("Directory for semantic search data (uses OPENAI_API_KEY env var)"), withAlias("s"), optional);
|
|
31318
31375
|
const prompt = String$1("prompt").pipe(withDescription$1("Pass a prompt in non-interactive mode"), optional);
|
|
@@ -31348,9 +31405,15 @@ const Search = (directory) => unwrap$3(gen(function* () {
|
|
|
31348
31405
|
return (yield* promise(() => import("./SemanticSearch-CH125AHH.mjs"))).layer({
|
|
31349
31406
|
directory: process.cwd(),
|
|
31350
31407
|
database: path.join(directory, "search.sqlite")
|
|
31351
|
-
}).pipe(provide$3(model$
|
|
31408
|
+
}).pipe(provide$3(model$5("text-embedding-3-small", { dimensions: 1536 })), provide$3(layer$4({ apiKey: apiKey.value })));
|
|
31352
31409
|
})).pipe(provide$3([layer$9, HttpClientLive]));
|
|
31353
|
-
const acpModel = String$1("model").pipe(withAlias("m"), withDescription$1("Default model as <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/medium. Without an effort, uses CLANKA_REASONING, or medium."), withSchema(ModelId), withDefault("openai/gpt-6-astra"), map$1((modelId) =>
|
|
31410
|
+
const acpModel = String$1("model").pipe(withAlias("m"), withDescription$1("Default model as <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/medium. Without an effort, uses CLANKA_REASONING, or medium."), withSchema(ModelId), withDefault("openai/gpt-6-astra"), map$1((modelId) => {
|
|
31411
|
+
const spec = getOrThrow$1(parseModelSpec(modelId));
|
|
31412
|
+
return {
|
|
31413
|
+
model: `${spec.provider}:${spec.model}`,
|
|
31414
|
+
thoughtLevel: fromUndefinedOr(spec.effort)
|
|
31415
|
+
};
|
|
31416
|
+
}));
|
|
31354
31417
|
const trustAllTools = Boolean("trust-all-tools").pipe(withDescription$1("Accepted for kiro-cli compatibility. Has no effect: clanka runs every tool call without asking."), withDefault(false));
|
|
31355
31418
|
const reasoning = schema$1(ThoughtLevel, "CLANKA_REASONING").pipe(withDefault$2("medium"));
|
|
31356
31419
|
const acp = make$27("acp", {
|
|
@@ -31387,7 +31450,7 @@ const acp = make$27("acp", {
|
|
|
31387
31450
|
auxiliary: auxiliaryModels(flags)
|
|
31388
31451
|
})
|
|
31389
31452
|
});
|
|
31390
|
-
})), provide((flags) => mergeAll(ConversationMode.layer(false), succeed$4(LogToStderr, true), layerLog, compactionConfig(flags))));
|
|
31453
|
+
})), provide((flags) => mergeAll(ConversationMode.layer(false), succeed$4(LogToStderr, true), layerLog, compactionConfig(flags), openAiCompatModels(flags))));
|
|
31391
31454
|
make$27("clanka", {
|
|
31392
31455
|
provider,
|
|
31393
31456
|
fetch: fetch$1,
|
|
@@ -31412,13 +31475,7 @@ make$27("clanka", {
|
|
|
31412
31475
|
});
|
|
31413
31476
|
const OutputFormatter = yield* promise(() => import("./OutputFormatter-U02YKTfy.mjs"));
|
|
31414
31477
|
const { model, effort } = yield* match$2(modelRaw, {
|
|
31415
|
-
onSome: (selected) =>
|
|
31416
|
-
const [model, effort] = selected.split("/");
|
|
31417
|
-
return succeed$1({
|
|
31418
|
-
model,
|
|
31419
|
-
effort
|
|
31420
|
-
});
|
|
31421
|
-
},
|
|
31478
|
+
onSome: (selected) => succeed$1(parseModel(selected)),
|
|
31422
31479
|
onNone: () => selectModel(provider)
|
|
31423
31480
|
});
|
|
31424
31481
|
const Model = make(provider, model, effort, {
|
|
@@ -31444,7 +31501,7 @@ make$27("clanka", {
|
|
|
31444
31501
|
onNone: () => empty$7,
|
|
31445
31502
|
onSome: Search
|
|
31446
31503
|
})), provideMerge(layer$6(mcpServers))), Model]));
|
|
31447
|
-
})), provide(({ prompt, ...flags }) => mergeAll(ConversationMode.layer(isNone(prompt)), compactionConfig(flags))), withSubcommands([acp]), withGlobalFlags([ReportedVersion]), run$1({ version }), provide$1([
|
|
31504
|
+
})), provide(({ prompt, ...flags }) => mergeAll(ConversationMode.layer(isNone(prompt)), compactionConfig(flags), openAiCompatModels(flags))), withSubcommands([acp]), withGlobalFlags([ReportedVersion]), run$1({ version }), provide$1([
|
|
31448
31505
|
layer$9,
|
|
31449
31506
|
ModelsRepo.layerModelsDev().pipe(provideMerge([Kvs, HttpClientLive])),
|
|
31450
31507
|
layerWebSocketConstructor,
|