clanka 0.13.2 → 0.14.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/dist/bin/cli.mjs CHANGED
@@ -32581,6 +32581,7 @@ var SessionRecord = class extends Class$1("clanka/Acp/SessionRecord")({
32581
32581
  cwd: String$6,
32582
32582
  model: String$6,
32583
32583
  thoughtLevel: ThoughtLevel,
32584
+ fastMode: optionalKey(Boolean$5),
32584
32585
  history: Prompt,
32585
32586
  environment: optionalKey(ExecutionEnvironment)
32586
32587
  }) {};
@@ -32667,11 +32668,16 @@ const SetModelParams = Struct({
32667
32668
  sessionId: String$6,
32668
32669
  modelId: String$6
32669
32670
  });
32670
- const SetConfigOptionParams = Struct({
32671
+ const FastModeValue = Literals$2(["off", "on"]);
32672
+ const SetConfigOptionParams = Union([Struct({
32671
32673
  sessionId: String$6,
32672
32674
  configId: Literal("thought_level"),
32673
32675
  value: ThoughtLevel
32674
- });
32676
+ }), Struct({
32677
+ sessionId: String$6,
32678
+ configId: Literal("fast_mode"),
32679
+ value: FastModeValue
32680
+ })]);
32675
32681
  const TextBlock = Struct({
32676
32682
  type: Literal("text"),
32677
32683
  text: String$6
@@ -32791,7 +32797,8 @@ const make$8 = fnUntraced(function* (options) {
32791
32797
  update
32792
32798
  });
32793
32799
  const getSession = (sessionId) => fromOption(fromNullishOr(sessions.get(sessionId)), () => sessionNotFound(sessionId));
32794
- const requireModel = (modelId, thoughtLevel) => fromOption(options.makeModel(modelId, thoughtLevel), () => new RpcError({
32800
+ const supportsFastMode = (modelId) => options.supportsFastMode?.(modelId) ?? false;
32801
+ const requireModel = (modelId, thoughtLevel, fastMode) => fromOption(options.makeModel(modelId, thoughtLevel, fastMode && supportsFastMode(modelId)), () => new RpcError({
32795
32802
  code: -32602,
32796
32803
  message: `Unknown model: ${modelId}`
32797
32804
  }));
@@ -32805,7 +32812,21 @@ const make$8 = fnUntraced(function* (options) {
32805
32812
  value,
32806
32813
  name: value
32807
32814
  }))
32808
- }];
32815
+ }, ...supportsFastMode(session.model) ? [{
32816
+ id: "fast_mode",
32817
+ name: "Fast mode",
32818
+ description: "Faster responses at a higher cost",
32819
+ category: "model_config",
32820
+ type: "select",
32821
+ currentValue: session.fastMode ? "on" : "off",
32822
+ options: [{
32823
+ value: "off",
32824
+ name: "Default"
32825
+ }, {
32826
+ value: "on",
32827
+ name: "On"
32828
+ }]
32829
+ }] : []];
32809
32830
  const sessionState = fnUntraced(function* (session) {
32810
32831
  const catalog = options.availableModels === void 0 ? [] : yield* options.availableModels;
32811
32832
  const listed = new Set(catalog.map((model) => model.modelId));
@@ -32824,6 +32845,7 @@ const make$8 = fnUntraced(function* (options) {
32824
32845
  cwd: session.cwd,
32825
32846
  model: session.model,
32826
32847
  thoughtLevel: session.thoughtLevel,
32848
+ fastMode: session.fastMode,
32827
32849
  history: session.agent.history.current,
32828
32850
  environment: session.agent.environment.current
32829
32851
  })).pipe(catch_((error) => logWarning("Failed to persist session", error)));
@@ -32846,6 +32868,7 @@ const make$8 = fnUntraced(function* (options) {
32846
32868
  cwd: record.cwd,
32847
32869
  model: record.model,
32848
32870
  thoughtLevel: record.thoughtLevel,
32871
+ fastMode: record.fastMode ?? false,
32849
32872
  agent,
32850
32873
  running: void 0,
32851
32874
  toolCalls: 0,
@@ -33050,11 +33073,13 @@ const make$8 = fnUntraced(function* (options) {
33050
33073
  const { cwd, model, mcpServers } = yield* decodeParams(NewSessionParams, params);
33051
33074
  const modelId = model ?? options.defaultModel;
33052
33075
  const thoughtLevel = options.defaultThoughtLevel;
33053
- yield* requireModel(modelId, thoughtLevel);
33076
+ const fastMode = options.defaultFastMode ?? false;
33077
+ yield* requireModel(modelId, thoughtLevel, fastMode);
33054
33078
  const session = yield* openSession(crypto.randomUUID(), new SessionRecord({
33055
33079
  cwd,
33056
33080
  model: modelId,
33057
33081
  thoughtLevel,
33082
+ fastMode,
33058
33083
  history: empty$1
33059
33084
  }), mcpServers ?? []);
33060
33085
  yield* persist(session);
@@ -33073,11 +33098,13 @@ const make$8 = fnUntraced(function* (options) {
33073
33098
  })));
33074
33099
  if (isNone(record)) return yield* sessionNotFound(sessionId);
33075
33100
  const modelId = model ?? record.value.model;
33076
- yield* requireModel(modelId, record.value.thoughtLevel);
33101
+ const fastMode = record.value.fastMode ?? false;
33102
+ yield* requireModel(modelId, record.value.thoughtLevel, fastMode);
33077
33103
  const session = yield* openSession(sessionId, new SessionRecord({
33078
33104
  cwd: cwd ?? record.value.cwd,
33079
33105
  model: modelId,
33080
33106
  thoughtLevel: record.value.thoughtLevel,
33107
+ fastMode,
33081
33108
  history: record.value.history,
33082
33109
  ...record.value.environment !== void 0 && (cwd === void 0 || cwd === record.value.cwd) ? { environment: record.value.environment } : {}
33083
33110
  }), mcpServers ?? []);
@@ -33087,16 +33114,28 @@ const make$8 = fnUntraced(function* (options) {
33087
33114
  const setModel = fnUntraced(function* (params) {
33088
33115
  const { sessionId, modelId } = yield* decodeParams(SetModelParams, params);
33089
33116
  const session = yield* getSession(sessionId);
33090
- yield* requireModel(modelId, session.thoughtLevel);
33117
+ yield* requireModel(modelId, session.thoughtLevel, session.fastMode);
33091
33118
  session.model = modelId;
33092
33119
  yield* persist(session);
33093
- return { configOptions: configOptions(session) };
33120
+ const options = configOptions(session);
33121
+ yield* update(sessionId, {
33122
+ sessionUpdate: "config_option_update",
33123
+ configOptions: options
33124
+ });
33125
+ return { configOptions: options };
33094
33126
  });
33095
33127
  const setConfigOption = fnUntraced(function* (params) {
33096
- const { sessionId, value } = yield* decodeParams(SetConfigOptionParams, params);
33097
- const session = yield* getSession(sessionId);
33098
- yield* requireModel(session.model, value);
33099
- session.thoughtLevel = value;
33128
+ const option = yield* decodeParams(SetConfigOptionParams, params);
33129
+ const session = yield* getSession(option.sessionId);
33130
+ if (option.configId === "thought_level") {
33131
+ yield* requireModel(session.model, option.value, session.fastMode);
33132
+ session.thoughtLevel = option.value;
33133
+ } else {
33134
+ const fastMode = option.value === "on";
33135
+ if (fastMode && !supportsFastMode(session.model)) return yield* invalidParams(`Fast mode is not supported by model: ${session.model}`);
33136
+ yield* requireModel(session.model, session.thoughtLevel, fastMode);
33137
+ session.fastMode = fastMode;
33138
+ }
33100
33139
  yield* persist(session);
33101
33140
  return { configOptions: configOptions(session) };
33102
33141
  });
@@ -33107,7 +33146,7 @@ const make$8 = fnUntraced(function* (options) {
33107
33146
  code: -32e3,
33108
33147
  message: `Session ${sessionId} already has a prompt in progress`
33109
33148
  });
33110
- const model = yield* requireModel(session.model, session.thoughtLevel);
33149
+ const model = yield* requireModel(session.model, session.thoughtLevel, session.fastMode);
33111
33150
  const input = yield* promptFromBlocks(session.cwd, prompt);
33112
33151
  if (session.mcpFailures !== void 0) {
33113
33152
  yield* update(sessionId, {
@@ -41422,9 +41461,14 @@ const modelWebSocket = (model, options) => make$20("xai", model, mergeAll(layer$
41422
41461
  //#endregion
41423
41462
  //#region src/ModelLayer.ts
41424
41463
  const withSubagentModel = (model) => merge$3(model, layerSubagentModel(model));
41425
- const make = (provider, model, effort, openai) => {
41464
+ const supportsFastMode = (provider) => provider === "openai";
41465
+ const make = (provider, model, effort, openai, fastMode = false) => {
41426
41466
  const options = effort === void 0 ? void 0 : { reasoning: effort === null ? null : { effort } };
41427
- return provider === "openai" ? openai.apiKey !== void 0 ? withSubagentModel(model$2(model, options)).pipe(provide$3(layer$4(openai))) : withSubagentModel(modelWebSocket$1(model, options)).pipe(provide$3(layerClient$2)) : provider === "xai" ? withSubagentModel(modelWebSocket(model, options)).pipe(provide$3(layerClient)) : withSubagentModel(model$1(model, options)).pipe(provide$3(layerClient$1));
41467
+ const openaiOptions = fastMode ? {
41468
+ ...options,
41469
+ service_tier: "priority"
41470
+ } : options;
41471
+ return provider === "openai" ? openai.apiKey !== void 0 ? withSubagentModel(model$2(model, openaiOptions)).pipe(provide$3(layer$4(openai))) : withSubagentModel(modelWebSocket$1(model, openaiOptions)).pipe(provide$3(layerClient$2)) : provider === "xai" ? withSubagentModel(modelWebSocket(model, options)).pipe(provide$3(layerClient)) : withSubagentModel(model$1(model, options)).pipe(provide$3(layerClient$1));
41428
41472
  };
41429
41473
  const isProvider$1 = is(Provider);
41430
41474
  const parseAcpModelId = (modelId) => {
@@ -41434,6 +41478,7 @@ const parseAcpModelId = (modelId) => {
41434
41478
  model
41435
41479
  }) : none();
41436
41480
  };
41481
+ const acpSupportsFastMode = (modelId) => exists(parseAcpModelId(modelId), ({ provider }) => supportsFastMode(provider));
41437
41482
  const acpModels = (models) => models.map((model) => ({
41438
41483
  modelId: `${model.provider}:${model.id}`,
41439
41484
  name: `${model.name} (${model.provider})`
@@ -41445,16 +41490,16 @@ const resolveEffort = (efforts, thoughtLevel) => {
41445
41490
  for (const effort of efforts) if (resolved === null || distance(effort) < distance(resolved) || distance(effort) === distance(resolved) && rank(effort) > rank(resolved)) resolved = effort;
41446
41491
  return resolved;
41447
41492
  };
41448
- const makeAcp = (options) => (modelId, thoughtLevel) => map$8(parseAcpModelId(modelId), ({ provider, model }) => unwrap$1(map$5(options.models, (catalog) => {
41493
+ const makeAcp = (options) => (modelId, thoughtLevel, fastMode = false) => map$8(parseAcpModelId(modelId), ({ provider, model }) => unwrap$1(map$5(options.models, (catalog) => {
41449
41494
  const info = catalog.find((entry) => entry.provider === provider && entry.id === model);
41450
- return make(provider, model, info === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai);
41495
+ return make(provider, model, info === void 0 ? thoughtLevel : resolveEffort(info.efforts, thoughtLevel), options.openai, fastMode);
41451
41496
  })));
41452
41497
  //#endregion
41453
41498
  //#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Logger.js
41454
41499
  const LogToStderr = LogToStderr$1;
41455
41500
  //#endregion
41456
41501
  //#region package.json
41457
- var version$1 = "0.13.2";
41502
+ var version$1 = "0.14.0";
41458
41503
  //#endregion
41459
41504
  //#region src/cli.ts
41460
41505
  const version = version$1;
@@ -41520,6 +41565,7 @@ const provider = Literals("provider", providers).pipe(withAlias("p"), withFallba
41520
41565
  const model = String$1("model").pipe(withAlias("m"), optional$1);
41521
41566
  const apiKey = Redacted("api-key").pipe(withDescription$1("OpenAI API key (defaults to CLANKA_OPENAI_API_KEY)"), withFallbackConfig(Redacted$3("CLANKA_OPENAI_API_KEY")), optional$1);
41522
41567
  const apiUrl = String$1("api-url").pipe(withDescription$1("OpenAI API base URL for API-key mode (defaults to CLANKA_OPENAI_API_URL or https://api.openai.com/v1)"), withFallbackConfig(String$4("CLANKA_OPENAI_API_URL")), optional$1);
41568
+ const fast = Boolean$1("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$4("CLANKA_FAST").pipe(withDefault$2(false))));
41523
41569
  const semantic = Directory("search").pipe(withDescription$1("Directory for semantic search data (uses OPENAI_API_KEY env var)"), withAlias("s"), optional$1);
41524
41570
  const prompt = String$1("prompt").pipe(withDescription$1("Pass a prompt in non-interactive mode"), optional$1);
41525
41571
  const compaction = Boolean$1("compaction").pipe(withDescription$1("Auto-compact the conversation history when it nears the context window. Disable with --no-compaction or CLANKA_COMPACTION=false; the execute output cap stays on."), withFallbackConfig(Boolean$4("CLANKA_COMPACTION").pipe(withDefault$2(true))));
@@ -41546,15 +41592,18 @@ const Search = (directory) => unwrap$1(gen(function* () {
41546
41592
  const acpModel = String$1("model").pipe(withAlias("m"), withDescription$1("Default model as <provider>/<model>/<effort>, e.g. openai/gpt-6-astra/medium"), withSchema(ModelId), withDefault("openai/gpt-6-astra/medium"), map$1((modelId) => getOrThrow(parseModelId(modelId))));
41547
41593
  const acp = make$30("acp", {
41548
41594
  model: acpModel,
41595
+ fast,
41549
41596
  compaction,
41550
41597
  apiKey,
41551
41598
  apiUrl
41552
- }).pipe(withDescription("Run as an Agent Client Protocol (ACP) server over stdio"), withHandler(({ model, apiKey, apiUrl }) => gen(function* () {
41599
+ }).pipe(withDescription("Run as an Agent Client Protocol (ACP) server over stdio"), withHandler(({ model, fast, apiKey, apiUrl }) => gen(function* () {
41553
41600
  const repo = yield* ModelsRepo;
41554
41601
  return yield* runStdio({
41555
41602
  version,
41556
41603
  defaultModel: model.model,
41557
41604
  defaultThoughtLevel: model.thoughtLevel,
41605
+ defaultFastMode: fast,
41606
+ supportsFastMode: acpSupportsFastMode,
41558
41607
  availableModels: map$5(repo.models, acpModels),
41559
41608
  makeAgent: (cwd) => make$9.pipe(provide$1(layerLocal$1({ directory: cwd }))),
41560
41609
  makeModel: makeAcp({
@@ -41569,6 +41618,7 @@ const acp = make$30("acp", {
41569
41618
  make$30("clanka", {
41570
41619
  provider,
41571
41620
  model,
41621
+ fast,
41572
41622
  semantic,
41573
41623
  prompt,
41574
41624
  compaction,
@@ -41576,7 +41626,7 @@ make$30("clanka", {
41576
41626
  apiUrl,
41577
41627
  mcp,
41578
41628
  mcpConfig
41579
- }).pipe(withHandler(fnUntraced(function* ({ provider, model: modelRaw, semantic, prompt: nonInteractivePrompt, apiKey, apiUrl, mcp, mcpConfig }) {
41629
+ }).pipe(withHandler(fnUntraced(function* ({ provider, model: modelRaw, fast, semantic, prompt: nonInteractivePrompt, apiKey, apiUrl, mcp, mcpConfig }) {
41580
41630
  const stdio = yield* Stdio;
41581
41631
  const mcpServers = yield* load({
41582
41632
  cwd: process.cwd(),
@@ -41597,7 +41647,7 @@ make$30("clanka", {
41597
41647
  const Model = make(provider, model, effort, {
41598
41648
  apiKey: getOrUndefined(apiKey),
41599
41649
  apiUrl: getOrUndefined(apiUrl)
41600
- });
41650
+ }, fast);
41601
41651
  return yield* gen(function* () {
41602
41652
  const agent = yield* Agent;
41603
41653
  if (isSome(nonInteractivePrompt)) return yield* pipe$1(agent.send({ prompt: nonInteractivePrompt.value }), unwrap$3, OutputFormatter.pretty(), run$4(stdio.stdout()));