@adhdev/daemon-core 0.8.56 → 0.8.58

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.
Files changed (35) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +1 -0
  2. package/dist/commands/handler.d.ts +1 -0
  3. package/dist/commands/stream-commands.d.ts +2 -0
  4. package/dist/config/chat-history.d.ts +3 -0
  5. package/dist/config/config.d.ts +3 -0
  6. package/dist/config/provider-source-config.d.ts +23 -0
  7. package/dist/daemon/dev-server-types.d.ts +1 -0
  8. package/dist/daemon/dev-server.d.ts +4 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +316 -155
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +315 -155
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/providers/cli-provider-instance.d.ts +9 -0
  15. package/dist/providers/contracts.d.ts +1 -0
  16. package/dist/providers/provider-loader.d.ts +14 -1
  17. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  18. package/package.json +1 -1
  19. package/src/boot/daemon-lifecycle.ts +13 -3
  20. package/src/commands/handler.ts +3 -0
  21. package/src/commands/router.ts +5 -4
  22. package/src/commands/stream-commands.ts +41 -0
  23. package/src/config/chat-history.ts +39 -0
  24. package/src/config/config.d.ts +3 -0
  25. package/src/config/config.ts +19 -3
  26. package/src/config/provider-source-config.ts +42 -0
  27. package/src/daemon/dev-auto-implement.ts +0 -13
  28. package/src/daemon/dev-server-types.ts +1 -0
  29. package/src/daemon/dev-server.ts +45 -20
  30. package/src/index.ts +2 -0
  31. package/src/providers/cli-provider-instance.ts +25 -0
  32. package/src/providers/contracts.ts +1 -0
  33. package/src/providers/provider-loader.d.ts +4 -1
  34. package/src/providers/provider-loader.ts +61 -23
  35. package/src/providers/provider-schema.ts +3 -0
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import { VersionArchive } from './version-archive.js';
16
16
  import type { ProviderModule, ProviderCategory, ProviderSettingSchema, ResolvedProvider } from './contracts.js';
17
+ import type { ProviderSourceMode } from '../config/config.js';
17
18
  export declare class ProviderLoader {
18
19
  private providers;
19
20
  private providerAvailability;
@@ -31,7 +32,9 @@ export declare class ProviderLoader {
31
32
  constructor(options?: {
32
33
  userDir?: string;
33
34
  logFn?: (msg: string) => void;
34
- /** Disable upstream auto-download (for dev/testing/OSS) */
35
+ /** Explicit machine-level provider source policy */
36
+ sourceMode?: ProviderSourceMode;
37
+ /** Deprecated alias for sourceMode='no-upstream' */
35
38
  disableUpstream?: boolean;
36
39
  });
37
40
  private log;
@@ -30,6 +30,8 @@ import type {
30
30
  ResolvedProvider,
31
31
  } from './contracts.js';
32
32
  import { validateProviderDefinition } from './provider-schema.js';
33
+ import type { ProviderSourceMode } from '../config/config.js';
34
+ import type { ProviderSourceConfigSnapshot } from '../config/provider-source-config.js';
33
35
 
34
36
  interface ProviderAvailabilityState {
35
37
  installed: boolean;
@@ -39,8 +41,11 @@ interface ProviderAvailabilityState {
39
41
  export class ProviderLoader {
40
42
  private providers = new Map<string, ProviderModule>();
41
43
  private providerAvailability = new Map<string, ProviderAvailabilityState>();
44
+ private defaultProvidersDir: string;
45
+ private explicitProviderDir: string | null = null;
42
46
  private userDir: string;
43
47
  private upstreamDir: string;
48
+ private sourceMode: ProviderSourceMode = 'normal';
44
49
  private disableUpstream: boolean;
45
50
  private watchers: any[] = [];
46
51
  private logFn: (msg: string) => void;
@@ -58,32 +63,24 @@ export class ProviderLoader {
58
63
  constructor(options?: {
59
64
  userDir?: string;
60
65
  logFn?: (msg: string) => void;
61
- /** Disable upstream auto-download (for dev/testing/OSS) */
66
+ /** Explicit machine-level provider source policy */
67
+ sourceMode?: ProviderSourceMode;
68
+ /** Deprecated alias for sourceMode='no-upstream' */
62
69
  disableUpstream?: boolean;
63
70
  }) {
64
71
  this.logFn = options?.logFn || LOG.forComponent('Provider').asLogFn();
65
72
 
66
73
  // Default directory for auto-downloads
67
- const defaultProvidersDir = path.join(os.homedir(), '.adhdev', 'providers');
68
-
69
- if (options?.userDir) {
70
- this.userDir = options.userDir;
71
- this.log(`Config 'providerDir' applied: ${this.userDir}`);
72
- } else {
73
- // Local dev overrides: Auto-detect local adhdev-providers repo for speed
74
- const localRepoPath = path.resolve(__dirname, '../../../../../adhdev-providers');
75
- if (fs.existsSync(localRepoPath)) {
76
- this.userDir = localRepoPath;
77
- this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
78
- } else {
79
- this.userDir = defaultProvidersDir;
80
- this.log(`Using default user providers directory: ${this.userDir}`);
81
- }
82
- }
83
-
84
- // Upstream auto-download directory is always in the default location
85
- this.upstreamDir = path.join(defaultProvidersDir, '.upstream');
86
- this.disableUpstream = options?.disableUpstream ?? false;
74
+ this.defaultProvidersDir = path.join(os.homedir(), '.adhdev', 'providers');
75
+ this.userDir = this.defaultProvidersDir;
76
+ this.upstreamDir = path.join(this.defaultProvidersDir, '.upstream');
77
+ this.disableUpstream = false;
78
+
79
+ this.applySourceConfig({
80
+ userDir: options?.userDir,
81
+ sourceMode: options?.sourceMode,
82
+ disableUpstream: options?.disableUpstream,
83
+ });
87
84
  }
88
85
 
89
86
  private log(msg: string): void {
@@ -114,6 +111,47 @@ export class ProviderLoader {
114
111
  return [this.userDir, this.upstreamDir];
115
112
  }
116
113
 
114
+ getSourceConfig(): ProviderSourceConfigSnapshot {
115
+ return {
116
+ sourceMode: this.sourceMode,
117
+ disableUpstream: this.disableUpstream,
118
+ explicitProviderDir: this.explicitProviderDir,
119
+ userDir: this.userDir,
120
+ upstreamDir: this.upstreamDir,
121
+ providerRoots: this.getProviderRoots(),
122
+ };
123
+ }
124
+
125
+ applySourceConfig(options?: {
126
+ userDir?: string;
127
+ sourceMode?: ProviderSourceMode;
128
+ disableUpstream?: boolean;
129
+ }): ProviderSourceConfigSnapshot {
130
+ const nextSourceMode = options?.sourceMode === 'no-upstream'
131
+ ? 'no-upstream'
132
+ : (options?.sourceMode === 'normal'
133
+ ? 'normal'
134
+ : (options?.disableUpstream ? 'no-upstream' : this.sourceMode || 'normal'));
135
+
136
+ if (options && Object.prototype.hasOwnProperty.call(options, 'userDir')) {
137
+ this.explicitProviderDir = options.userDir?.trim() ? options.userDir : null;
138
+ }
139
+
140
+ this.sourceMode = nextSourceMode;
141
+ this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
142
+ this.upstreamDir = path.join(this.defaultProvidersDir, '.upstream');
143
+ this.disableUpstream = this.sourceMode === 'no-upstream';
144
+
145
+ if (this.explicitProviderDir) {
146
+ this.log(`Config 'providerDir' applied: ${this.userDir}`);
147
+ } else {
148
+ this.log(`Using default user providers directory: ${this.userDir}`);
149
+ }
150
+ this.log(`Provider source config: mode=${this.sourceMode} explicitProviderDir=${this.explicitProviderDir || '-'} userDir=${this.userDir} upstreamDir=${this.upstreamDir}`);
151
+
152
+ return this.getSourceConfig();
153
+ }
154
+
117
155
  /**
118
156
  * Canonical provider directory shape for a given root.
119
157
  */
@@ -171,7 +209,7 @@ export class ProviderLoader {
171
209
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
172
210
  }
173
211
  } else if (this.disableUpstream) {
174
- this.log('Upstream loading disabled (disableUpstream=true)');
212
+ this.log('Upstream loading disabled (sourceMode=no-upstream)');
175
213
  }
176
214
 
177
215
  // 2. Load user custom (excluding .upstream — highest priority, never auto-updated)
@@ -760,7 +798,7 @@ export class ProviderLoader {
760
798
  */
761
799
  async fetchLatest(): Promise<{ updated: boolean; error?: string }> {
762
800
  if (this.disableUpstream) {
763
- this.log('Upstream fetch skipped (disableUpstream=true)');
801
+ this.log('Upstream fetch skipped (sourceMode=no-upstream)');
764
802
  return { updated: false };
765
803
  }
766
804
  const https = require('https') as typeof import('https');
@@ -83,6 +83,9 @@ export function validateProviderDefinition(raw: unknown): ProviderValidationResu
83
83
  warnings.push(`Unknown provider field: ${key}`)
84
84
  }
85
85
  }
86
+ if (provider.disableUpstream !== undefined) {
87
+ warnings.push('disableUpstream is deprecated in provider definitions; use machine-level provider source policy instead')
88
+ }
86
89
 
87
90
  const category = provider.category
88
91
  if ((category === 'cli' || category === 'acp')) {