@adhdev/daemon-core 0.5.27 → 0.5.28

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.d.ts CHANGED
@@ -966,12 +966,16 @@ declare class ProviderLoader {
966
966
  private log;
967
967
  /**
968
968
  * Load all providers (3-tier priority)
969
- * 1. _builtin/ (bundled fallback, or multiple array dirs)
970
- * 2. .upstream/ (GitHub auto-download)
971
- * 3. User custom (~/.adhdev/providers/ excluding _upstream)
972
- * Later loads override earlier ones, so user custom always wins.
969
+ * 1. .upstream/ (GitHub auto-download primary source)
970
+ * 2. User custom (~/.adhdev/providers/ excluding .upstream)
971
+ * User custom always wins (highest priority).
972
+ * If .upstream/ is empty, call fetchLatest() before loadAll().
973
973
  */
974
974
  loadAll(): void;
975
+ /**
976
+ * Check if upstream directory exists and has providers.
977
+ */
978
+ hasUpstream(): boolean;
975
979
  /**
976
980
  * Get raw provider metadata by type (NO scripts loaded).
977
981
  * Use resolve() when you need scripts (readChat, listModels, etc).
package/dist/index.js CHANGED
@@ -4798,20 +4798,13 @@ var ProviderLoader = class _ProviderLoader {
4798
4798
  // ─── Public API ────────────────────────────────
4799
4799
  /**
4800
4800
  * Load all providers (3-tier priority)
4801
- * 1. _builtin/ (bundled fallback, or multiple array dirs)
4802
- * 2. .upstream/ (GitHub auto-download)
4803
- * 3. User custom (~/.adhdev/providers/ excluding _upstream)
4804
- * Later loads override earlier ones, so user custom always wins.
4801
+ * 1. .upstream/ (GitHub auto-download primary source)
4802
+ * 2. User custom (~/.adhdev/providers/ excluding .upstream)
4803
+ * User custom always wins (highest priority).
4804
+ * If .upstream/ is empty, call fetchLatest() before loadAll().
4805
4805
  */
4806
4806
  loadAll() {
4807
4807
  this.providers.clear();
4808
- let builtinCount = 0;
4809
- for (const dir of this.builtinDirs) {
4810
- if (fs5.existsSync(dir)) {
4811
- builtinCount += this.loadDir(dir);
4812
- }
4813
- }
4814
- this.log(`Loaded ${builtinCount} builtin providers`);
4815
4808
  let upstreamCount = 0;
4816
4809
  if (fs5.existsSync(this.upstreamDir)) {
4817
4810
  upstreamCount = this.loadDir(this.upstreamDir);
@@ -4826,11 +4819,21 @@ var ProviderLoader = class _ProviderLoader {
4826
4819
  }
4827
4820
  }
4828
4821
  this.log(`Total: ${this.providers.size} providers [${[...this.providers.keys()].join(", ")}]`);
4829
- if (upstreamCount === 0 && builtinCount > 0) {
4830
- this.log(`\u26A0 Using bundled providers only (upstream not available). Run 'adhdev daemon' with internet to auto-update.`);
4831
- }
4832
4822
  if (this.providers.size === 0) {
4833
- this.log(`\u274C No providers loaded! Check builtinDirs.`);
4823
+ this.log(`\u274C No providers loaded! Run 'adhdev daemon' with internet to download providers.`);
4824
+ }
4825
+ }
4826
+ /**
4827
+ * Check if upstream directory exists and has providers.
4828
+ */
4829
+ hasUpstream() {
4830
+ if (!fs5.existsSync(this.upstreamDir)) return false;
4831
+ try {
4832
+ return fs5.readdirSync(this.upstreamDir).some(
4833
+ (d) => fs5.statSync(path6.join(this.upstreamDir, d)).isDirectory()
4834
+ );
4835
+ } catch {
4836
+ return false;
4834
4837
  }
4835
4838
  }
4836
4839
  /**
@@ -12567,6 +12570,14 @@ async function initDaemonComponents(config) {
12567
12570
  const providerLoader = new ProviderLoader({
12568
12571
  logFn: config.providerLogFn
12569
12572
  });
12573
+ if (!providerLoader.hasUpstream()) {
12574
+ LOG.info("Provider", "No upstream providers found \u2014 downloading from GitHub...");
12575
+ try {
12576
+ await providerLoader.fetchLatest();
12577
+ } catch (e) {
12578
+ LOG.warn("Provider", `\u26A0 Failed to fetch providers: ${e?.message}`);
12579
+ }
12580
+ }
12570
12581
  providerLoader.loadAll();
12571
12582
  providerLoader.registerToDetector();
12572
12583
  const instanceManager = new ProviderInstanceManager();