@adhdev/daemon-core 0.8.57 → 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.
- package/dist/boot/daemon-lifecycle.d.ts +1 -0
- package/dist/commands/handler.d.ts +1 -0
- package/dist/commands/stream-commands.d.ts +2 -0
- package/dist/config/chat-history.d.ts +3 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/config/provider-source-config.d.ts +23 -0
- package/dist/daemon/dev-server-types.d.ts +1 -0
- package/dist/daemon/dev-server.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +316 -155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -155
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +9 -0
- package/dist/providers/contracts.d.ts +1 -0
- package/dist/providers/provider-loader.d.ts +14 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/boot/daemon-lifecycle.ts +13 -3
- package/src/commands/handler.ts +3 -0
- package/src/commands/router.ts +5 -4
- package/src/commands/stream-commands.ts +41 -0
- package/src/config/chat-history.ts +39 -0
- package/src/config/config.d.ts +3 -0
- package/src/config/config.ts +19 -3
- package/src/config/provider-source-config.ts +42 -0
- package/src/daemon/dev-auto-implement.ts +0 -13
- package/src/daemon/dev-server-types.ts +1 -0
- package/src/daemon/dev-server.ts +45 -20
- package/src/index.ts +2 -0
- package/src/providers/cli-provider-instance.ts +25 -0
- package/src/providers/contracts.ts +1 -0
- package/src/providers/provider-loader.d.ts +4 -1
- package/src/providers/provider-loader.ts +61 -23
- 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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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 (
|
|
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 (
|
|
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')) {
|