kimiflare 0.76.0 → 0.76.1

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/index.js CHANGED
@@ -7988,8 +7988,18 @@ var camouflage_resume_exports = {};
7988
7988
  __export(camouflage_resume_exports, {
7989
7989
  runCamouflageResume: () => runCamouflageResume
7990
7990
  });
7991
- import { mount, selectList } from "camouflage";
7992
7991
  async function runCamouflageResume(opts2 = {}) {
7992
+ let camMod;
7993
+ try {
7994
+ camMod = await import("camouflage-tui");
7995
+ } catch {
7996
+ process.stderr.write(
7997
+ "kimiflare resume: the 'camouflage-tui' package is required.\nInstall it with: npm install -g camouflage-tui\n"
7998
+ );
7999
+ process.exitCode = 2;
8000
+ return;
8001
+ }
8002
+ const { mount: mount2, selectList: selectList2 } = camMod;
7993
8003
  const sessions = await listSessions(opts2.limit ?? 20, process.cwd());
7994
8004
  if (sessions.length === 0) {
7995
8005
  process.stderr.write("kimiflare resume: no saved sessions for this cwd.\n");
@@ -7998,7 +8008,7 @@ async function runCamouflageResume(opts2 = {}) {
7998
8008
  }
7999
8009
  let cam;
8000
8010
  try {
8001
- cam = await mount({
8011
+ cam = await mount2({
8002
8012
  bin: opts2.camouflageBin,
8003
8013
  renderToTerminal: true
8004
8014
  });
@@ -8012,7 +8022,7 @@ ${err instanceof Error ? err.message : err}
8012
8022
  return;
8013
8023
  }
8014
8024
  cam.send("SessionStarted", {});
8015
- const resp = await selectList(cam, {
8025
+ const resp = await selectList2(cam, {
8016
8026
  id: "resume-picker",
8017
8027
  prompt: `Resume which session? (${sessions.length} found in ${process.cwd()})`,
8018
8028
  options: sessions.map((s) => ({
@@ -14157,8 +14167,6 @@ import { appendFileSync, openSync } from "fs";
14157
14167
  import { readdir as readdir6 } from "fs/promises";
14158
14168
  import { join as join26, relative as relative6 } from "path";
14159
14169
  import { platform as platform3 } from "os";
14160
- import { mount as mount2 } from "camouflage";
14161
- import { selectList as selectList2, form, confirm } from "camouflage";
14162
14170
  function kimiLog(payload) {
14163
14171
  if (!KIMI_LOG_PATH) return;
14164
14172
  try {
@@ -14167,14 +14175,34 @@ function kimiLog(payload) {
14167
14175
  } catch {
14168
14176
  }
14169
14177
  }
14178
+ async function requireCamouflage() {
14179
+ try {
14180
+ return await import("camouflage-tui");
14181
+ } catch {
14182
+ console.error(
14183
+ "kimiflare: the 'camouflage-tui' package is required for the Camouflage UI.\nInstall it with:\n npm install -g camouflage-tui\nOr switch to the default Ink UI:\n kimiflare --ui ink"
14184
+ );
14185
+ process.exit(2);
14186
+ }
14187
+ }
14188
+ async function loadCamouflage() {
14189
+ if (_loaded) return;
14190
+ const mod = await requireCamouflage();
14191
+ mount = mod.mount;
14192
+ selectList = mod.selectList;
14193
+ form = mod.form;
14194
+ confirm = mod.confirm;
14195
+ _loaded = true;
14196
+ }
14170
14197
  function gatewayFromOpts2(opts2) {
14171
14198
  if (!opts2.aiGatewayId) return void 0;
14172
14199
  return { id: opts2.aiGatewayId };
14173
14200
  }
14174
14201
  async function runUiMode(opts2) {
14202
+ await loadCamouflage();
14175
14203
  let cam;
14176
14204
  try {
14177
- cam = await mount2({
14205
+ cam = await mount({
14178
14206
  bin: opts2.camouflageBin,
14179
14207
  renderToTerminal: true
14180
14208
  });
@@ -14523,7 +14551,7 @@ ${err instanceof Error ? err.message : err}`);
14523
14551
  // surface via SelectList instead of Confirm to keep the
14524
14552
  // "synthesize" verb visible.
14525
14553
  onLoopDetected: async () => {
14526
- const r = await selectList2(cam, {
14554
+ const r = await selectList(cam, {
14527
14555
  id: `loop-${Date.now()}`,
14528
14556
  prompt: "Tool-call loop detected \u2014 pick a recovery",
14529
14557
  options: [
@@ -14664,7 +14692,7 @@ ${err instanceof Error ? err.message : err}`);
14664
14692
  cam.send("ShowToast", { text: `no messages yet for @${handle}`, kind: "info", ttl_ms: 2500 });
14665
14693
  return;
14666
14694
  }
14667
- const pick3 = await selectList2(cam, {
14695
+ const pick3 = await selectList(cam, {
14668
14696
  id: `inbox-msgs-${Date.now()}`,
14669
14697
  prompt: `Inbox (${msgs.length} message${msgs.length === 1 ? "" : "s"}${msgs.some((m) => !m.seen) ? ", new!" : ""}) \xB7 Enter opens in browser`,
14670
14698
  options: msgs.map((m) => ({
@@ -14684,7 +14712,7 @@ ${err instanceof Error ? err.message : err}`);
14684
14712
  while (true) {
14685
14713
  const cfg = await loadConfig() ?? null;
14686
14714
  const servers = { ...cfg?.lspServers ?? {} };
14687
- const main2 = await selectList2(cam, {
14715
+ const main2 = await selectList(cam, {
14688
14716
  id: `lsp-main-${Date.now()}`,
14689
14717
  prompt: `LSP Servers \xB7 ${Object.keys(servers).length} configured`,
14690
14718
  options: [
@@ -14709,7 +14737,7 @@ ${err instanceof Error ? err.message : err}`);
14709
14737
  continue;
14710
14738
  }
14711
14739
  if (main2.value === "add") {
14712
- const pick3 = await selectList2(cam, {
14740
+ const pick3 = await selectList(cam, {
14713
14741
  id: `lsp-presets-${Date.now()}`,
14714
14742
  prompt: "Pick a preset (or Custom)",
14715
14743
  options: [...LSP_PRESETS, { id: "custom", name: "Custom", description: "enter your own command", command: [], installCommand: "", installHint: "" }].map((p) => ({
@@ -14749,7 +14777,7 @@ ${err instanceof Error ? err.message : err}`);
14749
14777
  });
14750
14778
  }
14751
14779
  }
14752
- const scope = await selectList2(cam, {
14780
+ const scope = await selectList(cam, {
14753
14781
  id: `lsp-scope-${Date.now()}`,
14754
14782
  prompt: "Where to save this configuration?",
14755
14783
  options: [
@@ -14773,7 +14801,7 @@ ${err instanceof Error ? err.message : err}`);
14773
14801
  cam.send("ShowToast", { text: "no servers configured", kind: "info", ttl_ms: 2e3 });
14774
14802
  continue;
14775
14803
  }
14776
- const pick3 = await selectList2(cam, {
14804
+ const pick3 = await selectList(cam, {
14777
14805
  id: `lsp-${main2.value}-${Date.now()}`,
14778
14806
  prompt: main2.value === "edit" ? "Toggle which server?" : "Delete which server?",
14779
14807
  options: keys.map((k) => ({
@@ -14808,7 +14836,7 @@ ${err instanceof Error ? err.message : err}`);
14808
14836
  cam.send("ShowToast", { text: "no custom commands to delete", kind: "info", ttl_ms: 2e3 });
14809
14837
  return;
14810
14838
  }
14811
- const pick3 = await selectList2(cam, {
14839
+ const pick3 = await selectList(cam, {
14812
14840
  id: `cmd-del-${Date.now()}`,
14813
14841
  prompt: "Delete which custom command?",
14814
14842
  options: existing.map((c) => ({
@@ -14835,7 +14863,7 @@ ${err instanceof Error ? err.message : err}`);
14835
14863
  cam.send("ShowToast", { text: "no custom commands to edit", kind: "info", ttl_ms: 2e3 });
14836
14864
  return;
14837
14865
  }
14838
- const pick3 = await selectList2(cam, {
14866
+ const pick3 = await selectList(cam, {
14839
14867
  id: `cmd-pick-${Date.now()}`,
14840
14868
  prompt: "Edit which custom command?",
14841
14869
  options: existing.map((c) => ({
@@ -14879,7 +14907,7 @@ ${err instanceof Error ? err.message : err}`);
14879
14907
  cam.send("ShowToast", { text: "template cannot be empty", kind: "error", ttl_ms: 3e3 });
14880
14908
  return;
14881
14909
  }
14882
- const adv = await selectList2(cam, {
14910
+ const adv = await selectList(cam, {
14883
14911
  id: `cmd-adv-${Date.now()}`,
14884
14912
  prompt: "Advanced options (mode / effort / model)?",
14885
14913
  options: [
@@ -14893,7 +14921,7 @@ ${err instanceof Error ? err.message : err}`);
14893
14921
  let cmdEffort = initial?.effort;
14894
14922
  let cmdModel = initial?.model;
14895
14923
  if (adv.value === "set") {
14896
- const modePick = await selectList2(cam, {
14924
+ const modePick = await selectList(cam, {
14897
14925
  id: `cmd-mode-${Date.now()}`,
14898
14926
  prompt: "Default mode for this command?",
14899
14927
  options: [
@@ -14907,7 +14935,7 @@ ${err instanceof Error ? err.message : err}`);
14907
14935
  });
14908
14936
  if (modePick.cancelled) return;
14909
14937
  cmdMode = modePick.value === "none" ? void 0 : modePick.value;
14910
- const effortPick = await selectList2(cam, {
14938
+ const effortPick = await selectList(cam, {
14911
14939
  id: `cmd-effort-${Date.now()}`,
14912
14940
  prompt: "Reasoning effort?",
14913
14941
  options: [
@@ -14933,7 +14961,7 @@ ${err instanceof Error ? err.message : err}`);
14933
14961
  }
14934
14962
  let source = initial?.source ?? "project";
14935
14963
  if (action === "create") {
14936
- const loc = await selectList2(cam, {
14964
+ const loc = await selectList(cam, {
14937
14965
  id: `cmd-loc-${Date.now()}`,
14938
14966
  prompt: "Where to save?",
14939
14967
  options: [
@@ -14998,7 +15026,7 @@ ${err instanceof Error ? err.message : err}`);
14998
15026
  label: formatRemoteLine(s2)
14999
15027
  }));
15000
15028
  options.push({ value: "__refresh__", label: "\u21BB refresh" });
15001
- const pick3 = await selectList2(cam, {
15029
+ const pick3 = await selectList(cam, {
15002
15030
  id: `remote-${Date.now()}`,
15003
15031
  prompt: `Recent remote tasks (${sessions.length})`,
15004
15032
  options,
@@ -15025,7 +15053,7 @@ ${err instanceof Error ? err.message : err}`);
15025
15053
  items
15026
15054
  });
15027
15055
  if (s.status === "running" || s.status === "pending") {
15028
- const conf = await selectList2(cam, {
15056
+ const conf = await selectList(cam, {
15029
15057
  id: `remote-actions-${Date.now()}`,
15030
15058
  prompt: "Action?",
15031
15059
  options: [
@@ -15065,7 +15093,7 @@ ${err instanceof Error ? err.message : err}`);
15065
15093
  label: `Resume from: "${c.label}" \u2014 turn ${c.turnIndex} \xB7 ${formatShortDate(c.timestamp)}`
15066
15094
  }))
15067
15095
  ];
15068
- const choice = await selectList2(cam, {
15096
+ const choice = await selectList(cam, {
15069
15097
  id: `cp-${Date.now()}`,
15070
15098
  prompt: `${(file.title ?? file.id).slice(0, 50)} (${cps.length} checkpoint${cps.length === 1 ? "" : "s"})`,
15071
15099
  options,
@@ -15097,7 +15125,7 @@ ${err instanceof Error ? err.message : err}`);
15097
15125
  while (true) {
15098
15126
  const mainOptions = HELP_CATEGORIES.filter((c) => c.key !== "__none__").map((c) => ({ value: c.key, label: c.label, description: c.tagline }));
15099
15127
  mainOptions.push({ value: "__keys__", label: "Keys & shortcuts", description: "global keybinds" });
15100
- const choice = await selectList2(cam, {
15128
+ const choice = await selectList(cam, {
15101
15129
  id: `help-main-${Date.now()}`,
15102
15130
  prompt: "Help \xB7 \u2191\u2193 select \xB7 Enter drill in \xB7 Esc close",
15103
15131
  options: mainOptions,
@@ -15105,7 +15133,7 @@ ${err instanceof Error ? err.message : err}`);
15105
15133
  });
15106
15134
  if (choice.cancelled || !choice.value || choice.value === "__close__") return;
15107
15135
  if (choice.value === "__keys__") {
15108
- await selectList2(cam, {
15136
+ await selectList(cam, {
15109
15137
  id: `help-keys-${Date.now()}`,
15110
15138
  prompt: "Keys & shortcuts (Esc to go back)",
15111
15139
  options: HELP_KEYS.map((k) => ({ value: k.key, label: k.key, description: k.desc })),
@@ -15115,7 +15143,7 @@ ${err instanceof Error ? err.message : err}`);
15115
15143
  }
15116
15144
  const cat = HELP_CATEGORIES.find((c) => c.key === choice.value);
15117
15145
  if (!cat) continue;
15118
- const subChoice = await selectList2(cam, {
15146
+ const subChoice = await selectList(cam, {
15119
15147
  id: `help-${cat.key}-${Date.now()}`,
15120
15148
  prompt: `${cat.label} \xB7 Enter execute \xB7 Esc back`,
15121
15149
  options: cat.commands.map((c) => ({
@@ -15218,7 +15246,7 @@ ${err instanceof Error ? err.message : err}`);
15218
15246
  cam.send("ShowToast", { text: "no saved sessions yet for this cwd", kind: "info", ttl_ms: 2500 });
15219
15247
  return true;
15220
15248
  }
15221
- const choice = await selectList2(cam, {
15249
+ const choice = await selectList(cam, {
15222
15250
  id: `resume-${Date.now()}`,
15223
15251
  prompt: `Resume a session (${sessions.length} total)`,
15224
15252
  options: sessions.map((s) => ({
@@ -15288,7 +15316,7 @@ ${err instanceof Error ? err.message : err}`);
15288
15316
  if (!args) {
15289
15317
  const existing = await loadConfig().catch(() => null) ?? null;
15290
15318
  const current = existing?.uiEngine ?? "ink";
15291
- const choice = await selectList2(cam, {
15319
+ const choice = await selectList(cam, {
15292
15320
  id: `ui-${Date.now()}`,
15293
15321
  prompt: "Pick UI engine (takes effect on next launch)",
15294
15322
  options: [
@@ -15346,7 +15374,7 @@ ${err instanceof Error ? err.message : err}`);
15346
15374
  cam.send("ShowToast", { text: "no themes registered", kind: "warn", ttl_ms: 2e3 });
15347
15375
  return true;
15348
15376
  }
15349
- const choice = await selectList2(cam, {
15377
+ const choice = await selectList(cam, {
15350
15378
  id: `theme-${Date.now()}`,
15351
15379
  prompt: "Pick a theme (note: applied to Ink only; Camouflage TUI ignores)",
15352
15380
  options: themes.map((t) => ({
@@ -15915,7 +15943,8 @@ function tryGitBranch2() {
15915
15943
  }
15916
15944
  }
15917
15945
  async function runCamouflageOnboarding(opts2) {
15918
- const cam = await mount2({ bin: opts2.camouflageBin, renderToTerminal: true });
15946
+ await loadCamouflage();
15947
+ const cam = await mount({ bin: opts2.camouflageBin, renderToTerminal: true });
15919
15948
  cam.send("SessionStarted", {});
15920
15949
  cam.send("StatusUpdate", { segments: { mode: "setup", phase: "onboarding" } });
15921
15950
  cam.send("ShowToast", {
@@ -15952,7 +15981,7 @@ async function runCamouflageOnboarding(opts2) {
15952
15981
  const opts22 = gws.map((g) => ({ value: g.id, label: g.id }));
15953
15982
  opts22.push({ value: "__create__", label: "Create a new gateway" });
15954
15983
  opts22.push({ value: "__skip__", label: "Skip \u2014 direct Workers AI" });
15955
- const pick3 = await selectList2(cam, {
15984
+ const pick3 = await selectList(cam, {
15956
15985
  id: "onb-gw",
15957
15986
  prompt: gws.length > 0 ? `Pick a gateway (${gws.length} available)` : "No gateways yet",
15958
15987
  options: opts22,
@@ -16000,7 +16029,7 @@ async function runCamouflageOnboarding(opts2) {
16000
16029
  });
16001
16030
  }
16002
16031
  }
16003
- var KIMI_LOG_PATH, BUILTIN_SLASH_COMMANDS, MODES2, HELP_CATEGORIES, LSP_PRESETS, HELP_KEYS;
16032
+ var KIMI_LOG_PATH, _loaded, mount, selectList, form, confirm, BUILTIN_SLASH_COMMANDS, MODES2, HELP_CATEGORIES, LSP_PRESETS, HELP_KEYS;
16004
16033
  var init_ui_mode = __esm({
16005
16034
  "src/ui-mode.ts"() {
16006
16035
  "use strict";
@@ -16034,6 +16063,7 @@ var init_ui_mode = __esm({
16034
16063
  } catch {
16035
16064
  }
16036
16065
  }
16066
+ _loaded = false;
16037
16067
  BUILTIN_SLASH_COMMANDS = BUILTIN_COMMANDS.map((c) => ({
16038
16068
  name: c.name,
16039
16069
  description: c.description,