kimiflare 0.59.0 → 0.60.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
@@ -6740,6 +6740,7 @@ async function loadCloudCredentials() {
6740
6740
  }
6741
6741
  async function saveCloudCredentials(creds) {
6742
6742
  const p = cloudCredPath();
6743
+ await mkdir8(join15(p, ".."), { recursive: true });
6743
6744
  await writeFile8(p, JSON.stringify(creds, null, 2), "utf8");
6744
6745
  if (creds.deviceId) {
6745
6746
  await persistDeviceId(creds.deviceId).catch(() => {
@@ -12816,7 +12817,7 @@ function Onboarding({ onDone, onCancel }) {
12816
12817
  try {
12817
12818
  const path = await saveConfig(cfg);
12818
12819
  setSavedPath(path);
12819
- onDone(cfg);
12820
+ onDone(cfg, cloudAuth.creds);
12820
12821
  } catch (e) {
12821
12822
  setSavedPath(`error: ${e.message}`);
12822
12823
  }
@@ -20775,13 +20776,13 @@ ${lines.join("\n")}` }]);
20775
20776
  Onboarding,
20776
20777
  {
20777
20778
  onCancel: () => exit(),
20778
- onDone: async (newCfg) => {
20779
+ onDone: async (newCfg, cloudCredentials) => {
20779
20780
  setCfg(newCfg);
20780
20781
  if (newCfg.cloudMode) {
20781
- const { loadCloudCredentials: loadCloudCredentials2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
20782
- const creds = await loadCloudCredentials2();
20782
+ const creds = cloudCredentials;
20783
20783
  if (creds) {
20784
20784
  setCloudToken(creds.accessToken);
20785
+ setCloudDeviceId(creds.deviceId);
20785
20786
  setEvents((e) => [
20786
20787
  ...e,
20787
20788
  { kind: "info", key: mkKey(), text: "configuration saved \u2014 welcome to kimiflare! (cloud mode)" }
@@ -21374,6 +21375,13 @@ Kimiflare Cloud Authentication`);
21374
21375
  }
21375
21376
  });
21376
21377
  console.log(`Authenticated! Token expires at ${new Date(creds.expiresAt * 1e3).toISOString()}`);
21378
+ const existing = await loadConfig();
21379
+ await saveConfig({
21380
+ accountId: "",
21381
+ apiToken: "",
21382
+ model: existing?.model ?? DEFAULT_MODEL,
21383
+ cloudMode: true
21384
+ });
21377
21385
  const { fetchCloudUsage: fetchCloudUsage2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
21378
21386
  const usage = await fetchCloudUsage2(creds.accessToken, creds.deviceId);
21379
21387
  if (usage) {