@deepseek-ai/dsh-app-boot 0.2.2-alpha.3 → 0.2.2-rc.2
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/README.i18n.yaml +4 -4
- package/README.md +4 -2
- package/README.zh.md +4 -2
- package/lib/index.js +37 -17
- package/lib/types/bundle-platform.d.ts +4 -2
- package/lib/types/bundle-platform.d.ts.map +1 -0
- package/lib/types/bundle-platform.js.map +1 -0
- package/lib/types/compatibility-preflight.d.ts.map +1 -0
- package/lib/types/compatibility-preflight.js.map +1 -0
- package/lib/types/config-schema/collect.d.ts.map +1 -0
- package/lib/types/config-schema/collect.js.map +1 -0
- package/lib/types/config-schema/document.d.ts.map +1 -0
- package/lib/types/config-schema/document.js.map +1 -0
- package/lib/types/config-schema/index.d.ts.map +1 -0
- package/lib/types/config-schema/index.js.map +1 -0
- package/lib/types/config-schema/native.d.ts.map +1 -0
- package/lib/types/config-schema/native.js.map +1 -0
- package/lib/types/config-schema/pattern.d.ts.map +1 -0
- package/lib/types/config-schema/pattern.js.map +1 -0
- package/lib/types/config-schema/projector.d.ts.map +1 -0
- package/lib/types/config-schema/projector.js.map +1 -0
- package/lib/types/config-schema/types.d.ts.map +1 -0
- package/lib/types/config-schema/types.js.map +1 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/package-meta.d.ts.map +1 -0
- package/lib/types/package-meta.js.map +1 -0
- package/lib/types/plugin-compatibility.d.ts.map +1 -0
- package/lib/types/plugin-compatibility.js.map +1 -0
- package/lib/types/profile-compatibility.d.ts.map +1 -0
- package/lib/types/profile-compatibility.js.map +1 -0
- package/lib/types/profile-context.d.ts.map +1 -0
- package/lib/types/profile-context.js.map +1 -0
- package/lib/types/profile-plugins.d.ts.map +1 -0
- package/lib/types/profile-plugins.js.map +1 -0
- package/lib/types/profile-resolution/legacy-links.d.ts.map +1 -0
- package/lib/types/profile-resolution/legacy-links.js.map +1 -0
- package/lib/types/profile-resolution/resolver.d.ts.map +1 -0
- package/lib/types/profile-resolution/resolver.js.map +1 -0
- package/lib/types/profile-resolution/service.d.ts.map +1 -0
- package/lib/types/profile-resolution/service.js.map +1 -0
- package/lib/types/profile-resolution/worker-bootstrap.d.ts.map +1 -0
- package/lib/types/profile-resolution/worker-bootstrap.js.map +1 -0
- package/lib/types/profile-sanitize.d.ts.map +1 -0
- package/lib/types/profile-sanitize.js.map +1 -0
- package/lib/types/profile.d.ts.map +1 -0
- package/lib/types/profile.js.map +1 -0
- package/lib/types/startup-diagnostics.d.ts.map +1 -0
- package/lib/types/startup-diagnostics.js.map +1 -0
- package/package.json +25 -21
- package/src/bundle-platform.ts +35 -0
- package/src/compatibility-preflight.ts +187 -0
- package/src/config-schema/collect.ts +249 -0
- package/src/config-schema/document.ts +169 -0
- package/src/config-schema/index.ts +36 -0
- package/src/config-schema/native.ts +16 -0
- package/src/config-schema/pattern.ts +62 -0
- package/src/config-schema/projector.ts +455 -0
- package/src/config-schema/types.ts +95 -0
- package/src/index.ts +1286 -0
- package/src/package-meta.ts +200 -0
- package/src/plugin-compatibility.ts +117 -0
- package/src/profile-compatibility.ts +141 -0
- package/src/profile-context.ts +85 -0
- package/src/profile-plugins.ts +133 -0
- package/src/profile-resolution/legacy-links.ts +33 -0
- package/src/profile-resolution/resolver.ts +1072 -0
- package/src/profile-resolution/service.ts +148 -0
- package/src/profile-resolution/worker-bootstrap.ts +12 -0
- package/src/profile-sanitize.ts +34 -0
- package/src/profile.ts +762 -0
- package/src/startup-diagnostics.ts +104 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** Configuration-free snapshots captured before a failed startup disposes its plugins. */
|
|
2
|
+
|
|
3
|
+
import { Context, type FiberState } from '@deepseek-ai/cordis'
|
|
4
|
+
import type { Entry } from '@deepseek-ai/cordis-plugin-loader'
|
|
5
|
+
import type {} from './profile-resolution/service.ts'
|
|
6
|
+
|
|
7
|
+
/** One configured entry at the time startup failed. */
|
|
8
|
+
export interface StartupPluginState {
|
|
9
|
+
readonly id: string
|
|
10
|
+
readonly module: string
|
|
11
|
+
readonly version: string
|
|
12
|
+
readonly state: 'disabled' | 'active' | 'pending' | 'failed' | 'disposed' | 'loading' | 'unloading'
|
|
13
|
+
/** Loader source URL; individual overlay ownership may be unavailable. */
|
|
14
|
+
readonly source: string
|
|
15
|
+
readonly missing: readonly string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Observed registrations for one service missing from a consumer. */
|
|
19
|
+
export interface StartupServiceState {
|
|
20
|
+
readonly consumer: string
|
|
21
|
+
readonly service: string
|
|
22
|
+
/** Empty means no registration was observed, not that no configured plugin can provide it. */
|
|
23
|
+
readonly providers: readonly {
|
|
24
|
+
readonly entry: string
|
|
25
|
+
readonly state: string
|
|
26
|
+
readonly visibility: 'same-scope' | 'other-scope'
|
|
27
|
+
}[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Bounded startup state without plugin config, service values, or logger arguments. */
|
|
31
|
+
export interface StartupCompositionDiagnostic {
|
|
32
|
+
readonly plugins: readonly StartupPluginState[]
|
|
33
|
+
readonly services: readonly StartupServiceState[]
|
|
34
|
+
readonly omittedPlugins: number
|
|
35
|
+
readonly omittedServices: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function stateName(state: FiberState): StartupPluginState['state'] {
|
|
39
|
+
const names: Record<FiberState, StartupPluginState['state']> = {
|
|
40
|
+
0: 'pending', 1: 'loading', 2: 'active', 3: 'failed', 4: 'disposed', 5: 'unloading',
|
|
41
|
+
}
|
|
42
|
+
return names[state]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function pluginState(ctx: Context, entry: Entry): StartupPluginState {
|
|
46
|
+
let state: StartupPluginState['state']
|
|
47
|
+
try {
|
|
48
|
+
state = entry.disabled ? 'disabled' : entry.fiber === undefined ? 'failed' : stateName(entry.fiber.state)
|
|
49
|
+
} catch (_error) {
|
|
50
|
+
// The activation diagnostic owns the disabled-expression error.
|
|
51
|
+
state = 'failed'
|
|
52
|
+
}
|
|
53
|
+
let version = 'unknown'
|
|
54
|
+
const source = entry.parent.tree.ctx.baseUrl
|
|
55
|
+
try {
|
|
56
|
+
if (source !== undefined) version = ctx.get('pluginPackages')?.packageOf(entry.options.name, source)?.version ?? 'unknown'
|
|
57
|
+
} catch (_error) {
|
|
58
|
+
// Missing or damaged metadata must not replace the startup failure.
|
|
59
|
+
}
|
|
60
|
+
const fiber = entry.fiber
|
|
61
|
+
return {
|
|
62
|
+
id: entry.id, module: entry.options.name, version, state, source: source ?? 'unknown',
|
|
63
|
+
missing: state === 'pending' && fiber !== undefined
|
|
64
|
+
? Object.keys(fiber.inject).filter(name => fiber.ctx.get(name) === undefined) : [],
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Capture Loader state and registered service ownership before teardown.
|
|
70
|
+
* Providers that never registered cannot be inferred from their package names.
|
|
71
|
+
* @param ctx - Live application context with its Loader still mounted.
|
|
72
|
+
* @returns At most 256 plugin rows and 256 missing-service observations, with omission counts.
|
|
73
|
+
*/
|
|
74
|
+
export function captureStartupComposition(ctx: Context): StartupCompositionDiagnostic {
|
|
75
|
+
const entries = [...ctx.loader.entries()]
|
|
76
|
+
const rows = entries.map(entry => ({ entry, state: pluginState(ctx, entry) }))
|
|
77
|
+
// Inactive rows precede healthy rows so bounded reports retain the failure context.
|
|
78
|
+
rows.sort((a, b) => Number(a.state.state === 'active') - Number(b.state.state === 'active'))
|
|
79
|
+
const services: StartupServiceState[] = []
|
|
80
|
+
let omittedServices = 0
|
|
81
|
+
const store = ctx.reflect.store
|
|
82
|
+
for (const { entry, state } of rows) {
|
|
83
|
+
const fiber = entry.fiber
|
|
84
|
+
if (fiber === undefined) continue
|
|
85
|
+
for (const service of state.missing) {
|
|
86
|
+
if (services.length === 256) { omittedServices++; continue }
|
|
87
|
+
const scope = fiber.ctx[Context.isolate][service]
|
|
88
|
+
const providers: StartupServiceState['providers'][number][] = []
|
|
89
|
+
for (const key of Object.getOwnPropertySymbols(store)) {
|
|
90
|
+
const impl = store[key]
|
|
91
|
+
if (impl?.name !== service) continue
|
|
92
|
+
providers.push({
|
|
93
|
+
entry: impl.ctx.fiber.entry?.id ?? 'unknown', state: stateName(impl.ctx.fiber.state),
|
|
94
|
+
visibility: key === scope ? 'same-scope' : 'other-scope',
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
services.push({ consumer: state.id, service, providers })
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
plugins: rows.slice(0, 256).map(row => row.state), services,
|
|
102
|
+
omittedPlugins: Math.max(0, rows.length - 256), omittedServices,
|
|
103
|
+
}
|
|
104
|
+
}
|