@acryldev/harness-runtime 0.0.0-stage → 0.2.11
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/LICENSE +49 -0
- package/lib/index.mjs +5693 -0
- package/lib/index.mjs.map +1 -0
- package/lib/types/acryl-home.d.ts +81 -0
- package/lib/types/app/new-app.d.ts +65 -0
- package/lib/types/app/start-source.d.ts +47 -0
- package/lib/types/blueprint/blueprint.d.ts +74 -0
- package/lib/types/blueprint/brand-identity.d.ts +26 -0
- package/lib/types/blueprint/compose.d.ts +53 -0
- package/lib/types/blueprint/definition.d.ts +22 -0
- package/lib/types/blueprint/index.d.ts +7 -0
- package/lib/types/blueprint/manifest.d.ts +35 -0
- package/lib/types/blueprint/selection.d.ts +19 -0
- package/lib/types/cli-market-install.d.ts +97 -0
- package/lib/types/cli-market-plugins.d.ts +81 -0
- package/lib/types/coding-capabilities.d.ts +29 -0
- package/lib/types/durable-message.d.ts +18 -0
- package/lib/types/engine-dsh.d.ts +181 -0
- package/lib/types/engine-files.d.ts +8 -0
- package/lib/types/engine-host.d.ts +32 -0
- package/lib/types/engine-tools.d.ts +11 -0
- package/lib/types/index.d.ts +67 -0
- package/lib/types/instance/announce-self.d.ts +38 -0
- package/lib/types/instance/app-instance.d.ts +125 -0
- package/lib/types/instance/index.d.ts +6 -0
- package/lib/types/instance/offline-lock.d.ts +29 -0
- package/lib/types/instance/online-secret.d.ts +29 -0
- package/lib/types/instance/registry.d.ts +26 -0
- package/lib/types/instance/select.d.ts +43 -0
- package/lib/types/module-hooks.d.ts +19 -0
- package/lib/types/module-resolution.d.ts +31 -0
- package/lib/types/package-overlay.d.ts +41 -0
- package/lib/types/pinned-pnpm.d.ts +15 -0
- package/lib/types/plugin-acryl-workspace-status.d.ts +24 -0
- package/lib/types/plugin-doctor.d.ts +49 -0
- package/lib/types/plugin-lifecycle-state.d.ts +92 -0
- package/lib/types/plugin-lifecycle.d.ts +87 -0
- package/lib/types/profile-layout.d.ts +17 -0
- package/lib/types/profile-owner.d.ts +25 -0
- package/lib/types/profile-repair/backup.d.ts +37 -0
- package/lib/types/profile-repair/findings.d.ts +29 -0
- package/lib/types/profile-repair/index.d.ts +9 -0
- package/lib/types/profile-repair/inspector.d.ts +11 -0
- package/lib/types/profile-repair/repair.d.ts +38 -0
- package/lib/types/profile-resolution/moved-framework.d.ts +21 -0
- package/lib/types/profile-resolution/resolver.d.ts +41 -0
- package/lib/types/profile-resolution/service.d.ts +22 -0
- package/lib/types/prompt-budget.d.ts +44 -0
- package/lib/types/session-bridge.d.ts +57 -0
- package/lib/types/session-log-exporter.d.ts +31 -0
- package/lib/types/system-prompt-capture.d.ts +29 -0
- package/lib/types/web-favicon-data.d.ts +5 -0
- package/lib/types/web-favicon.d.ts +23 -0
- package/lib/types/web-market-install.d.ts +114 -0
- package/lib/types/web-market-plugins.d.ts +106 -0
- package/lib/types/web-port.d.ts +15 -0
- package/package.json +211 -3
- package/src/acryl-home.ts +103 -0
- package/src/app/new-app.ts +239 -0
- package/src/app/start-source.ts +110 -0
- package/src/blueprint/blueprint.ts +141 -0
- package/src/blueprint/brand-identity.ts +75 -0
- package/src/blueprint/compose.ts +222 -0
- package/src/blueprint/definition.ts +92 -0
- package/src/blueprint/index.ts +20 -0
- package/src/blueprint/manifest.ts +145 -0
- package/src/blueprint/selection.ts +74 -0
- package/src/cli-market-install.ts +181 -0
- package/src/cli-market-plugins.ts +176 -0
- package/src/coding-capabilities.ts +61 -0
- package/src/durable-message.ts +23 -0
- package/src/engine-dsh.ts +856 -0
- package/src/engine-files.ts +9 -0
- package/src/engine-host.ts +128 -0
- package/src/engine-tools.ts +26 -0
- package/src/index.ts +436 -0
- package/src/instance/announce-self.ts +88 -0
- package/src/instance/app-instance.ts +240 -0
- package/src/instance/index.ts +45 -0
- package/src/instance/offline-lock.ts +71 -0
- package/src/instance/online-secret.ts +55 -0
- package/src/instance/registry.ts +53 -0
- package/src/instance/select.ts +134 -0
- package/src/module-hooks.ts +41 -0
- package/src/module-resolution.ts +187 -0
- package/src/package-overlay.ts +160 -0
- package/src/pinned-pnpm.ts +67 -0
- package/src/plugin-acryl-workspace-status.ts +99 -0
- package/src/plugin-doctor.ts +141 -0
- package/src/plugin-lifecycle-state.ts +347 -0
- package/src/plugin-lifecycle.ts +223 -0
- package/src/profile-layout.ts +97 -0
- package/src/profile-owner.ts +52 -0
- package/src/profile-repair/backup.ts +119 -0
- package/src/profile-repair/findings.ts +43 -0
- package/src/profile-repair/index.ts +10 -0
- package/src/profile-repair/inspector.ts +156 -0
- package/src/profile-repair/repair.ts +137 -0
- package/src/profile-resolution/moved-framework.ts +64 -0
- package/src/profile-resolution/resolver.ts +876 -0
- package/src/profile-resolution/service.ts +99 -0
- package/src/prompt-budget.ts +118 -0
- package/src/session-bridge.ts +350 -0
- package/src/session-log-exporter.ts +68 -0
- package/src/system-prompt-capture.ts +99 -0
- package/src/web-favicon-data.ts +6 -0
- package/src/web-favicon.ts +43 -0
- package/src/web-market-install.ts +206 -0
- package/src/web-market-plugins.ts +215 -0
- package/src/web-port.ts +39 -0
- package/tests/account-callback.spec.ts +173 -0
- package/tests/acryl-home.spec.ts +39 -0
- package/tests/agent-self-hosting.spec.ts +101 -0
- package/tests/announce-self.spec.ts +84 -0
- package/tests/app-lifecycle.spec.ts +99 -0
- package/tests/blank-blueprint.spec.ts +110 -0
- package/tests/blueprint-definition.spec.ts +128 -0
- package/tests/blueprint.spec.ts +138 -0
- package/tests/bulkhead.spec.ts +187 -0
- package/tests/coding-vocabulary.spec.ts +15 -0
- package/tests/dump-system-prompt.spec.ts +65 -0
- package/tests/e2e-real-model.spec.ts +71 -0
- package/tests/e2e-restart-real-model.spec.ts +77 -0
- package/tests/engine-dsh.spec.ts +340 -0
- package/tests/engine-host-mount-root-include.spec.ts +118 -0
- package/tests/engine-host.spec.ts +176 -0
- package/tests/engine-optional.spec.ts +81 -0
- package/tests/extension-examples.spec.ts +261 -0
- package/tests/hooks-thread-stack.ts +27 -0
- package/tests/instance-patches.spec.ts +25 -0
- package/tests/instance.spec.ts +235 -0
- package/tests/live/community-plugins.spec.ts +83 -0
- package/tests/module-hooks.spec.ts +35 -0
- package/tests/module-resolution.spec.ts +265 -0
- package/tests/moved-framework.spec.ts +61 -0
- package/tests/new-app.spec.ts +132 -0
- package/tests/organizer-growth.spec.ts +117 -0
- package/tests/pinned-pnpm.spec.ts +34 -0
- package/tests/plugin-acryl-workspace-status.spec.ts +63 -0
- package/tests/plugin-context.spec.ts +640 -0
- package/tests/plugin-doctor.spec.ts +183 -0
- package/tests/plugin-enablement-one-store.spec.ts +130 -0
- package/tests/plugin-lifecycle-state.spec.ts +169 -0
- package/tests/profile-layout.spec.ts +58 -0
- package/tests/profile-owner.spec.ts +38 -0
- package/tests/profile-repair/profile-repair.spec.ts +231 -0
- package/tests/profile-resolution-port.spec.ts +30 -0
- package/tests/profile-resolution-service.spec.ts +273 -0
- package/tests/profile-resolution-swap.spec.ts +69 -0
- package/tests/profile-resolution.spec.ts +2535 -0
- package/tests/profile.spec.ts +70 -0
- package/tests/project-registry.spec.ts +81 -0
- package/tests/prompt-budget.spec.ts +58 -0
- package/tests/real-home-guard.spec.ts +178 -0
- package/tests/session-bridge.spec.ts +316 -0
- package/tests/start-source.spec.ts +65 -0
- package/tests/system-prompt-shape.spec.ts +95 -0
- package/tests/three-levels.spec.ts +84 -0
- package/tests/tool-gateway.spec.ts +116 -0
- package/tests/tool-schemas.spec.ts +41 -0
- package/tests/web-favicon.spec.ts +42 -0
- package/tests/web-port.spec.ts +38 -0
- package/tests/web-startup-hold.spec.ts +79 -0
- package/tsconfig.json +24 -0
- package/tsdown.config.ts +2 -0
- package/vitest.config.ts +18 -0
- package/README.md +0 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one way this runtime registers Node module hooks. Profile package routing (the overlay resolver and the DSH engine's profile
|
|
3
|
+
* resolution) needs the public `module.registerHooks`; a Node or Electron build without it fails here with a message that names the
|
|
4
|
+
* runtime, instead of a bare TypeError deep inside a boot.
|
|
5
|
+
*/
|
|
6
|
+
import { type ModuleHooks, type RegisterHooksOptions } from 'node:module';
|
|
7
|
+
export declare class ModuleHooksUnavailableError extends Error {
|
|
8
|
+
readonly name = "ModuleHooksUnavailableError";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The public `module.registerHooks`, checked before a caller patches anything it would have to undo.
|
|
12
|
+
* @throws {ModuleHooksUnavailableError} when this Node has none (it needs Node 22.15, 23.5 or newer).
|
|
13
|
+
*/
|
|
14
|
+
export declare function requireModuleHooks(): (options: RegisterHooksOptions) => ModuleHooks;
|
|
15
|
+
/**
|
|
16
|
+
* Register synchronous module hooks on Node's default loaders.
|
|
17
|
+
* @throws {ModuleHooksUnavailableError} when this Node has no `module.registerHooks`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerModuleHooks(options: RegisterHooksOptions): ModuleHooks;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-relative package resolution for a Node runtime with a persistent,
|
|
3
|
+
* user-mutable profile directory.
|
|
4
|
+
*
|
|
5
|
+
* Extracted verbatim from acryl-desktop's own module-resolution.ts (first
|
|
6
|
+
* built and proven there against Electron's restricted runtime) - the two
|
|
7
|
+
* anchors that varied per surface (the calling installation's own entry
|
|
8
|
+
* module and its own package.json) are now parameters
|
|
9
|
+
* ({@link InstallProfilePackageResolverOptions}) instead of hardcoded
|
|
10
|
+
* Desktop paths; every other line, including the two-layer CJS/ESM hook
|
|
11
|
+
* strategy and its comments, is unchanged. Desktop's own module-resolution.ts
|
|
12
|
+
* is now a thin wrapper supplying its Electron-specific anchors (unpacked
|
|
13
|
+
* ASAR paths) to this function - its own behavior is unaffected.
|
|
14
|
+
*/
|
|
15
|
+
export interface InstallProfilePackageResolverOptions {
|
|
16
|
+
/** Diagnostic prefix on thrown errors - the calling surface's own bin name. */
|
|
17
|
+
readonly binName: string;
|
|
18
|
+
/** File URL of the calling installation's own package.json. */
|
|
19
|
+
readonly installPackageUrl: string;
|
|
20
|
+
/** File URL of the calling installation's own compiled entry module. */
|
|
21
|
+
readonly installEntryUrl: string;
|
|
22
|
+
/** File URL resolved by `import.meta.resolve('@deepseek-ai/cordis-plugin-loader')`. */
|
|
23
|
+
readonly loaderEntryUrl: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve Cordis Loader bare imports from the selected persistent profile.
|
|
27
|
+
* @param profileBaseUrl - file URL inside the profile that owns plugin dependencies.
|
|
28
|
+
* @param options - the calling installation's own resolution anchors.
|
|
29
|
+
* @returns an idempotent hook disposer.
|
|
30
|
+
*/
|
|
31
|
+
export declare function installProfilePackageResolver(profileBaseUrl: string, options: InstallProfilePackageResolverOptions): () => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic package selection between one surface's own installation and
|
|
3
|
+
* one Profile - shared by every surface with a persistent, user-mutable
|
|
4
|
+
* profile directory (Desktop's Market-installed plugins, or any surface's
|
|
5
|
+
* own ACRYL-only packages a shipped DSH profile has no dependency path to).
|
|
6
|
+
* Extracted verbatim from acryl-desktop's own package-overlay.ts (first
|
|
7
|
+
* built and proven there); `binName` is the one parameter that varies per
|
|
8
|
+
* caller, keeping every message and this module's own behavior otherwise
|
|
9
|
+
* identical to what Desktop already shipped.
|
|
10
|
+
*/
|
|
11
|
+
export type PackageOverlaySource = 'install' | 'profile';
|
|
12
|
+
export interface PackageOverlayCandidate {
|
|
13
|
+
readonly packageName: string;
|
|
14
|
+
readonly packageDir: string;
|
|
15
|
+
readonly manifestPath: string;
|
|
16
|
+
readonly version?: string;
|
|
17
|
+
readonly source: PackageOverlaySource;
|
|
18
|
+
}
|
|
19
|
+
export interface PackageOverlaySelection {
|
|
20
|
+
readonly packageName: string;
|
|
21
|
+
readonly selected: PackageOverlayCandidate;
|
|
22
|
+
readonly install?: PackageOverlayCandidate;
|
|
23
|
+
readonly profile?: PackageOverlayCandidate;
|
|
24
|
+
}
|
|
25
|
+
export interface PackageOverlayOptions {
|
|
26
|
+
/** Diagnostic prefix on thrown errors - the calling surface's own bin name. */
|
|
27
|
+
readonly binName: string;
|
|
28
|
+
/** File URL inside the exact calling surface's own installation dependency graph. */
|
|
29
|
+
readonly installPackageUrl: string;
|
|
30
|
+
/** File URL for the active Profile package.json. */
|
|
31
|
+
readonly profilePackageUrl: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class PackageOverlayNotFoundError extends Error {
|
|
34
|
+
constructor(binName: string, packageName: string);
|
|
35
|
+
}
|
|
36
|
+
/** Extract an npm package root from one Loader bare specifier. */
|
|
37
|
+
export declare function packageNameFromSpecifier(specifier: string): string | undefined;
|
|
38
|
+
/** Find one package root using the installation/Profile overlay rule. */
|
|
39
|
+
export declare function findOverlayPackage(packageName: string, options: PackageOverlayOptions): PackageOverlaySelection | undefined;
|
|
40
|
+
/** Resolve one package root, failing when neither overlay side provides it. */
|
|
41
|
+
export declare function resolveOverlayPackage(packageName: string, options: PackageOverlayOptions): PackageOverlaySelection;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PinnedPnpm {
|
|
2
|
+
/** Absolute path of the pinned pnpm entry (`bin/pnpm.mjs`). */
|
|
3
|
+
readonly entry: string;
|
|
4
|
+
/** The pinned version (`package.json` of the resolved `pnpm` package). */
|
|
5
|
+
readonly version: string;
|
|
6
|
+
}
|
|
7
|
+
/** The pnpm this runtime depends on, or undefined when it is not installed. */
|
|
8
|
+
export declare function resolvePinnedPnpm(): PinnedPnpm | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Environment for a spawned `dsh plugin` process with the pinned pnpm first on PATH.
|
|
11
|
+
* @param env - the parent environment.
|
|
12
|
+
* @param binDir - where the shim lives (default: `<acryl home>/runtime/pnpm-bin`).
|
|
13
|
+
* @param platform - target platform (tests).
|
|
14
|
+
*/
|
|
15
|
+
export declare function pinnedPnpmEnv(env?: NodeJS.ProcessEnv, binDir?: string, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACRYL's first real model-facing tool, registered as an ordinary Cordis plugin
|
|
3
|
+
* on the native `ctx.tools` seam.
|
|
4
|
+
*
|
|
5
|
+
* @module @acryldev/harness-runtime/acryl-workspace-status
|
|
6
|
+
*
|
|
7
|
+
* This is the ACRYL hard gate: a genuine model-facing Tool that injects `tools`,
|
|
8
|
+
* registers via `ctx.tools.register(defineTool(...))`, declares a canonical
|
|
9
|
+
* typed `output.schema` and a separate `render(...)` for model-facing content,
|
|
10
|
+
* honours `exec.signal`, and disposes cleanly when its owning Fiber unloads.
|
|
11
|
+
* It is ACRYL-owned context (the workspace/profile the agent is running in) and
|
|
12
|
+
* deliberately does NOT re-implement a DSH file/shell/web tool.
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
16
|
+
export declare const name = "acryl-workspace-status";
|
|
17
|
+
/** Services required: the tool registry. */
|
|
18
|
+
export declare const inject: string[];
|
|
19
|
+
/** Canonical tool name exposed to the model. */
|
|
20
|
+
export declare const TOOL_NAME = "acryl_workspace_status";
|
|
21
|
+
/** Register the `acryl_workspace_status` tool on `ctx.tools`. Returns a disposer. */
|
|
22
|
+
export declare function installAcrylWorkspaceStatusTool(ctx: Context): () => void;
|
|
23
|
+
/** Cordis plugin entry point for idiomatic composition via a Loader row. */
|
|
24
|
+
export declare function apply(ctx: Context): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only health of one profile's plugin layer (spec 034, FR-001).
|
|
3
|
+
*
|
|
4
|
+
* `acryl plugin doctor` prints this and the Web panel can render the same
|
|
5
|
+
* report; the diagnosis itself is neither surface's code, because "why is my
|
|
6
|
+
* plugin missing" has the same answers everywhere: the override file does not
|
|
7
|
+
* parse, an override outlived the row it names, a bundle is installed but
|
|
8
|
+
* composes nothing, or a bundle the profile lists cannot be resolved at all.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here mutates: the caller passes the live snapshot it already has and
|
|
11
|
+
* gets findings back.
|
|
12
|
+
*
|
|
13
|
+
* @module @acryldev/harness-runtime/plugin-doctor
|
|
14
|
+
*/
|
|
15
|
+
import type { PluginLifecycleSnapshot } from '@acryldev/control';
|
|
16
|
+
import { type PluginLifecycleStatePersistence } from './plugin-lifecycle-state.ts';
|
|
17
|
+
export type PluginHealthSeverity = 'error' | 'warning';
|
|
18
|
+
export type PluginHealthCode = 'state-unreadable' | 'stale-override' | 'unmanaged-override' | 'bundle-not-composed' | 'bundle-missing';
|
|
19
|
+
export interface PluginHealthFinding {
|
|
20
|
+
/** `error` means the profile is broken; `warning` means it is surprising. */
|
|
21
|
+
readonly severity: PluginHealthSeverity;
|
|
22
|
+
readonly code: PluginHealthCode;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
/** The entry or package a finding is about, when it names one. */
|
|
25
|
+
readonly entryId?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PluginHealthReport {
|
|
28
|
+
readonly profileName: string;
|
|
29
|
+
readonly profileDir: string;
|
|
30
|
+
readonly statePath: string;
|
|
31
|
+
/** Composed Loader rows in the snapshot, mutable and protected alike. */
|
|
32
|
+
readonly pluginCount: number;
|
|
33
|
+
readonly findings: readonly PluginHealthFinding[];
|
|
34
|
+
}
|
|
35
|
+
export interface PluginHealthInput extends PluginLifecycleStatePersistence {
|
|
36
|
+
readonly profileDir: string;
|
|
37
|
+
readonly snapshot: PluginLifecycleSnapshot;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves an installed package's manifest path, or throws when it is not
|
|
40
|
+
* resolvable from this profile. Omitted when the caller has no resolution
|
|
41
|
+
* base (the bundle is then only checked for a composed row).
|
|
42
|
+
*/
|
|
43
|
+
readonly resolvePackageJson?: (packageName: string) => string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Diagnose one profile against its own snapshot and override file. Returns
|
|
47
|
+
* findings in a stable order: state, then overrides, then bundles.
|
|
48
|
+
*/
|
|
49
|
+
export declare function diagnosePluginLifecycle(input: PluginHealthInput): PluginHealthReport;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one persistent store of plugin enablement overrides, keyed by profile.
|
|
3
|
+
*
|
|
4
|
+
* Every surface that offers plugin enable/disable - Desktop's Lifecycle tab,
|
|
5
|
+
* the Web panel, `acryl plugin enable` on the CLI - reads and writes the same
|
|
6
|
+
* `plugin-lifecycle/state.json`, so a disable applies to the whole profile the
|
|
7
|
+
* next time it boots no matter which surface asked for it.
|
|
8
|
+
*
|
|
9
|
+
* @module @acryldev/harness-runtime/plugin-lifecycle-state
|
|
10
|
+
*/
|
|
11
|
+
/** Rejects a profile name, in the words of the surface that owns the rule. */
|
|
12
|
+
export type ProfileNameValidator = (profileName: string) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The portable rule: a profile name must be usable as one profile directory
|
|
15
|
+
* under the harness home. A surface whose profiles are named by other rules
|
|
16
|
+
* (Desktop's CLI accepts localized names) supplies its own validator instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertProfileName(name: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Persistence inputs: enough to read and write the override file for one
|
|
21
|
+
* profile.
|
|
22
|
+
*/
|
|
23
|
+
export interface PluginLifecycleStatePersistence {
|
|
24
|
+
readonly profileName: string;
|
|
25
|
+
readonly statePath: string;
|
|
26
|
+
/** Overrides {@link assertProfileName} when a surface names profiles its own way. */
|
|
27
|
+
readonly validateProfileName?: ProfileNameValidator;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The one override file every surface reads and writes, inside the engine home
|
|
31
|
+
* whose profiles these overrides describe.
|
|
32
|
+
*
|
|
33
|
+
* The overrides are a property of a profile, and the profiles themselves live
|
|
34
|
+
* under the engine home - so the store shares their root, their lifetime, and
|
|
35
|
+
* their isolation switch. It is deliberately not a surface's private data
|
|
36
|
+
* directory (the Electron userData path it used to be), because then
|
|
37
|
+
* `acryl plugin disable x` and the Desktop panel would give two different
|
|
38
|
+
* answers about one profile: the defect spec 034 exists to fix.
|
|
39
|
+
*
|
|
40
|
+
* The engine home, not a bare `~/.acryl`, is also what keeps an isolated run
|
|
41
|
+
* isolated: `resolveAcrylHome()` ignores `$DSH_HOME`, so a dev or throwaway
|
|
42
|
+
* `DSH_HOME=~/.acryl-dev/.dsh` would otherwise read and write overrides in the
|
|
43
|
+
* operator's real install. Every surface already agrees on this root - each one
|
|
44
|
+
* boots through `resolveAcrylDshHome()`.
|
|
45
|
+
*
|
|
46
|
+
* @param dshHome - the engine home this process booted; defaults to the one
|
|
47
|
+
* `$ACRYL_HOME` / `$DSH_HOME` resolve to.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolvePluginLifecycleStatePath(dshHome?: string): string;
|
|
50
|
+
/** Runtime entry id -> the patch-local row id it disables during composition. */
|
|
51
|
+
export declare function entryPatchId(entryId: string): string;
|
|
52
|
+
/** Whether a persisted disabled-entry id is structurally a Loader entry id. */
|
|
53
|
+
export declare function isPluginLifecycleEntryId(value: unknown): value is string;
|
|
54
|
+
/** Base-template bundles: never user-mutable. Every other profile bundle is. */
|
|
55
|
+
export declare const BASE_TEMPLATE_BUNDLE_NAMES: ReadonlySet<string>;
|
|
56
|
+
/** Read disabled Loader entry ids for one profile. */
|
|
57
|
+
export declare function readDisabledPluginLifecycleEntries(persistence: PluginLifecycleStatePersistence): ReadonlySet<string>;
|
|
58
|
+
/**
|
|
59
|
+
* User-added profile bundles from `dsh.profile.bundles`, minus the base
|
|
60
|
+
* template. Each such package's inserted Loader row is user-mutable. A missing
|
|
61
|
+
* or malformed manifest yields an empty set (nothing user-mutable by bundle).
|
|
62
|
+
*/
|
|
63
|
+
export declare function readUserMutableBundleNames(profileDir: string): ReadonlySet<string>;
|
|
64
|
+
/** Persist one desired entry enablement with locking and atomic replace. */
|
|
65
|
+
export declare function setPluginLifecycleEntryEnabled(persistence: PluginLifecycleStatePersistence, entryId: string, enabled: boolean): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Remove a disable DSH's own Plugins page wrote for one row into the profile's patch file (`{ id, disabled: true }`,
|
|
68
|
+
* `plugin-manager/src/patch.ts`), keeping every comment and every other key. Before spec 001 T089 both pages wrote, each
|
|
69
|
+
* to its own store, and a disable in either kept the row off however the other was set; now every toggle of a row ACRYL
|
|
70
|
+
* admits goes through this lifecycle (DSH's page too, through ACRYL's plugin manager), and an enable clears the old
|
|
71
|
+
* page's disable here, so the override file stays the row's only store. An entry left with only `id` (and `name`) is
|
|
72
|
+
* removed; one with other keys keeps them.
|
|
73
|
+
*
|
|
74
|
+
* @returns whether the patch file changed.
|
|
75
|
+
*/
|
|
76
|
+
export declare function clearProfilePatchDisable(profileDir: string, patchId: string): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Convert persisted overrides into profile overlay rows for the rows this
|
|
79
|
+
* composition has. A disable patch matches its target by id only - no `name`,
|
|
80
|
+
* so a row whose id and package name differ (e.g. `dsh-editor` /
|
|
81
|
+
* `acryl-dsh-editor-plugin`) still disables. A disable whose row is not
|
|
82
|
+
* composed (its plugin was uninstalled) yields no patch, so the Loader does not
|
|
83
|
+
* warn on every boot; it stays stored, applies again when the plugin comes
|
|
84
|
+
* back, and `acryl plugin doctor` reports it as a stale override.
|
|
85
|
+
* @param persistence - the override file and profile to read.
|
|
86
|
+
* @param composedRowIds - the Loader row ids the composition already has.
|
|
87
|
+
* @returns one disable patch per stored disable whose row is composed.
|
|
88
|
+
*/
|
|
89
|
+
export declare function pluginLifecyclePatches(persistence: PluginLifecycleStatePersistence, composedRowIds: ReadonlySet<string>): readonly {
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly disabled: true;
|
|
92
|
+
}[];
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DSH-profile plugin lifecycle: one host policy, mounted as one Cordis
|
|
3
|
+
* service, for every ACRYL surface (spec 034, T005).
|
|
4
|
+
*
|
|
5
|
+
* The lifecycle mechanics live in `@acryldev/control`'s host-neutral controller.
|
|
6
|
+
* What is left here is the part that is the same on the Desktop, the Web host,
|
|
7
|
+
* and the CLI: which rows a DSH profile admits to user control, where the
|
|
8
|
+
* override file lives, and how a just-installed profile bundle inserts its row.
|
|
9
|
+
* A surface that needs more (Desktop's Blend rows and market bookkeeping)
|
|
10
|
+
* passes it in through the options rather than forking the policy.
|
|
11
|
+
*
|
|
12
|
+
* @module @acryldev/harness-runtime/plugin-lifecycle
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import { AcrPluginLifecycleController, AcrPluginLifecycleService, type PluginLifecycleHost } from '@acryldev/control';
|
|
16
|
+
import { type ProfileNameValidator } from './plugin-lifecycle-state.ts';
|
|
17
|
+
/** Options every surface's DSH-profile lifecycle host is built from. */
|
|
18
|
+
export interface DshPluginLifecycleOptions {
|
|
19
|
+
/** Profile whose override list this host reads and writes. */
|
|
20
|
+
readonly profileName: string;
|
|
21
|
+
/** Profile directory - the source of the user-installed bundle list. */
|
|
22
|
+
readonly profileDir: string;
|
|
23
|
+
/** Absolute path of the shared `plugin-lifecycle/state.json`. */
|
|
24
|
+
readonly statePath: string;
|
|
25
|
+
/**
|
|
26
|
+
* Loader row ids this surface itself admits to user control, in their runtime
|
|
27
|
+
* spelling (`include:<row>` when the row is composed through an include).
|
|
28
|
+
* Called on every policy read, so a surface may derive it lazily; the rows of
|
|
29
|
+
* the profile's own `dsh.profile.bundles` are admitted on top of it.
|
|
30
|
+
*/
|
|
31
|
+
readonly mutableEntryIds?: () => ReadonlySet<string>;
|
|
32
|
+
/** Name this host's bundle-patch diagnostics attribute a failure to. */
|
|
33
|
+
readonly binName?: string;
|
|
34
|
+
/** Explanation shown for a non-mutable entry. */
|
|
35
|
+
readonly protectedReason?: string;
|
|
36
|
+
/** Bookkeeping after a package leaves the Loader tree. Best effort. */
|
|
37
|
+
readonly afterDeactivate?: (packageName: string) => Promise<void>;
|
|
38
|
+
/** Narrower reload-all sweep, when restarting every mutable entry is too much. */
|
|
39
|
+
readonly reloadAllEntryIds?: () => ReadonlySet<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolves a bare module specifier from the profile's own module base (a
|
|
42
|
+
* profile's `node_modules`, where a user-installed bundle lives) - normally
|
|
43
|
+
* just `require.resolve`/`createRequire(...).resolve` bound to that base.
|
|
44
|
+
* Despite the parameter's own name, `createDshPluginLifecycleHost`'s
|
|
45
|
+
* internal caller always passes the full `"<packageName>/package.json"`
|
|
46
|
+
* specifier already, never the bare package name - do not re-append
|
|
47
|
+
* `/package.json` inside this callback (a real, reproduced bug: doing so
|
|
48
|
+
* throws `ERR_PACKAGE_PATH_NOT_EXPORTED` on a literal
|
|
49
|
+
* `package.json/package.json` subpath). Defaults to the context's base URL,
|
|
50
|
+
* which is the profile directory for a surface that boots the profile
|
|
51
|
+
* itself and is not for one whose root is elsewhere - the CLI composes the
|
|
52
|
+
* profile under its own engine host, so it passes the profile-resolving
|
|
53
|
+
* form explicitly.
|
|
54
|
+
*/
|
|
55
|
+
readonly resolvePackageJson?: (specifier: string) => string;
|
|
56
|
+
/** Reports a best-effort failure that must not throw to its caller. */
|
|
57
|
+
readonly warn?: (message: string) => void;
|
|
58
|
+
/** Profile-name rule, when this surface names profiles its own way. */
|
|
59
|
+
readonly validateProfileName?: ProfileNameValidator;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Build the host policy for one DSH profile.
|
|
63
|
+
*
|
|
64
|
+
* @param ctx - the context whose Loader tree is being steered and whose
|
|
65
|
+
* base URL resolves installed packages.
|
|
66
|
+
* @param options - which profile, and whatever this surface adds to the
|
|
67
|
+
* shared bundle policy.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createDshPluginLifecycleHost(ctx: Context, options: DshPluginLifecycleOptions): PluginLifecycleHost;
|
|
70
|
+
/**
|
|
71
|
+
* Build the lifecycle authority for one context: the one controller every
|
|
72
|
+
* surface drives. Publishes nothing, so a surface that composes its own
|
|
73
|
+
* capabilities (Desktop) can build it before deciding what to register.
|
|
74
|
+
*
|
|
75
|
+
* @param ctx - the context whose Loader tree it steers.
|
|
76
|
+
* @param options - that surface's DSH-profile lifecycle host options.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createAcrylPluginLifecycle(ctx: Context, options: DshPluginLifecycleOptions): AcrPluginLifecycleController;
|
|
79
|
+
/**
|
|
80
|
+
* Publish that authority on `ctx.acrPluginLifecycle` for the caller's fiber
|
|
81
|
+
* lifetime. Every surface renders its own view of the snapshot; none of them
|
|
82
|
+
* re-implements enable, disable, or reload.
|
|
83
|
+
*
|
|
84
|
+
* @param ctx - the plugin context the service belongs to.
|
|
85
|
+
* @param options - that surface's DSH-profile lifecycle host options.
|
|
86
|
+
*/
|
|
87
|
+
export declare function mountAcrylPluginLifecycle(ctx: Context, options: DshPluginLifecycleOptions): AcrPluginLifecycleService;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Which profile a pnpm service operates on. */
|
|
2
|
+
export interface PnpmProfileConfig {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly dir: string;
|
|
5
|
+
}
|
|
6
|
+
/** What a reconcile changed; empty when the workspace file already agreed. */
|
|
7
|
+
export interface LayoutChange {
|
|
8
|
+
readonly key: 'nodeLinker' | 'publicHoistPattern';
|
|
9
|
+
readonly from: unknown;
|
|
10
|
+
readonly to: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pin the recorded `nodeLinker` / `publicHoistPattern` into the profile's `pnpm-workspace.yaml`.
|
|
14
|
+
* A profile with no installed `node_modules` (or no workspace file) has no layout to protect and is left alone.
|
|
15
|
+
* @returns the changes made (empty when nothing needed pinning)
|
|
16
|
+
*/
|
|
17
|
+
export declare function reconcileProfileLayout(profileDir: string): LayoutChange[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One profile, one live installation (spec 036, "Self-containment"): a Protection Proxy in front of the one resource two installations can still point at.
|
|
3
|
+
*
|
|
4
|
+
* A Web or CLI profile links ACRYL's own packages into its `node_modules` from the installation that boots it. Two installations (a main checkout and a
|
|
5
|
+
* worktree, a dev build and an installed app) booting the SAME profile silently re-point each other's links, and the one still running then serves the
|
|
6
|
+
* other's code: that is how a worktree run blanked a running main-branch app. So every write to a profile goes through this guard, which holds the profile
|
|
7
|
+
* with a Pessimistic Offline Lock (`instance/offline-lock.ts`): the same installation is always admitted, another is refused while the holder is alive,
|
|
8
|
+
* and a stopped holder is taken over.
|
|
9
|
+
*
|
|
10
|
+
* @module @acryldev/harness-runtime/profile-owner
|
|
11
|
+
*/
|
|
12
|
+
export declare const PROFILE_OWNER_FILE = ".acryl-owner.json";
|
|
13
|
+
export interface ProfileOwner {
|
|
14
|
+
readonly installRoot: string;
|
|
15
|
+
readonly pid: number;
|
|
16
|
+
readonly since: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class ProfileInUseError extends Error {
|
|
19
|
+
constructor(profileDir: string, owner: {
|
|
20
|
+
installRoot: unknown;
|
|
21
|
+
pid: number;
|
|
22
|
+
}, installRoot: string);
|
|
23
|
+
}
|
|
24
|
+
/** Take the profile for this installation, or throw naming the live installation that holds it. */
|
|
25
|
+
export declare function claimProfile(profileDir: string, installRoot: string, pid?: number, alive?: (pid: number) => boolean): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-image backups for repairs: every file a repair may change is copied first, so a repair can be undone
|
|
3
|
+
* and an interrupted one can be rolled back.
|
|
4
|
+
*
|
|
5
|
+
* A backup is complete only when its manifest exists, and the manifest is written last and atomically, so a
|
|
6
|
+
* repair killed halfway through making the backup leaves nothing that looks valid.
|
|
7
|
+
*/
|
|
8
|
+
export interface BackupEntry {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
/** False when the file did not exist, so undoing the repair removes it. */
|
|
11
|
+
readonly existed: boolean;
|
|
12
|
+
/** The pre-image's name inside the backup directory. */
|
|
13
|
+
readonly stored?: string;
|
|
14
|
+
readonly sha256?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BackupManifest {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly createdAt: string;
|
|
19
|
+
readonly profileName: string;
|
|
20
|
+
readonly recipes: readonly string[];
|
|
21
|
+
readonly entries: readonly BackupEntry[];
|
|
22
|
+
}
|
|
23
|
+
export declare const backupsDir: (dshHome: string) => string;
|
|
24
|
+
/** Copy each file's current content aside. @returns the manifest of the new backup. */
|
|
25
|
+
export declare function createBackup(input: {
|
|
26
|
+
readonly dshHome: string;
|
|
27
|
+
readonly profileName: string;
|
|
28
|
+
readonly recipes: readonly string[];
|
|
29
|
+
readonly files: readonly string[];
|
|
30
|
+
readonly now?: () => Date;
|
|
31
|
+
}): Promise<BackupManifest>;
|
|
32
|
+
/** Complete backups, newest first; incomplete or damaged ones are skipped. */
|
|
33
|
+
export declare function listBackups(dshHome: string): BackupManifest[];
|
|
34
|
+
/** The pre-image bytes of one stored file, verified against its recorded hash. */
|
|
35
|
+
export declare function readPreImage(dshHome: string, manifest: BackupManifest, entry: BackupEntry): Buffer;
|
|
36
|
+
/** Put every file back as it was: restore what existed, remove what the repair created. */
|
|
37
|
+
export declare function restoreBackup(dshHome: string, id: string): Promise<BackupManifest>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** What a static diagnosis of a profile can say, and what repairs exist for it. */
|
|
2
|
+
export type ProfileFindingCode = 'profile-missing' | 'state-unreadable' | 'profile-manifest-unreadable' | 'bundle-missing' | 'pnpm-layout-mismatch' | 'plugin-activation-failed' | 'pnpm-store-mismatch';
|
|
3
|
+
/**
|
|
4
|
+
* The repairs that may ever run without a person choosing each step. The list is short on purpose: it grows
|
|
5
|
+
* only by a reviewed change (spec 041, question 6).
|
|
6
|
+
*/
|
|
7
|
+
export declare const SAFE_RECIPES: readonly ["restore-override-file", "disable-failing-row"];
|
|
8
|
+
export type RecipeId = (typeof SAFE_RECIPES)[number];
|
|
9
|
+
export interface ProfileFinding {
|
|
10
|
+
/** `error` means the profile is broken; `warning` means it is surprising or degraded. */
|
|
11
|
+
readonly severity: 'error' | 'warning';
|
|
12
|
+
readonly code: ProfileFindingCode;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
/** The file the finding is about. */
|
|
15
|
+
readonly file?: string;
|
|
16
|
+
/** The Loader row or package it is about. */
|
|
17
|
+
readonly entryId?: string;
|
|
18
|
+
/** The safe recipe that addresses it, when there is one. */
|
|
19
|
+
readonly recipe?: RecipeId;
|
|
20
|
+
/** What a person should do when no safe recipe applies. */
|
|
21
|
+
readonly guidance?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ProfileDiagnosis {
|
|
24
|
+
readonly profileName: string;
|
|
25
|
+
readonly profileDir: string;
|
|
26
|
+
readonly dshHome: string;
|
|
27
|
+
readonly findings: readonly ProfileFinding[];
|
|
28
|
+
}
|
|
29
|
+
export declare function isSafeRecipe(value: string): value is RecipeId;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Offline diagnosis and repair of a profile (spec 041, Scope B): static, reversible, and safe to run when the app cannot start. */
|
|
2
|
+
export { createBackup, listBackups, restoreBackup, backupsDir } from './backup.ts';
|
|
3
|
+
export type { BackupEntry, BackupManifest } from './backup.ts';
|
|
4
|
+
export { SAFE_RECIPES, isSafeRecipe } from './findings.ts';
|
|
5
|
+
export type { ProfileDiagnosis, ProfileFinding, ProfileFindingCode, RecipeId } from './findings.ts';
|
|
6
|
+
export { inspectProfile } from './inspector.ts';
|
|
7
|
+
export type { InspectOptions } from './inspector.ts';
|
|
8
|
+
export { applyRepairPlan, describePlan, planRepairs, undoRepair } from './repair.ts';
|
|
9
|
+
export type { RepairPlan, RepairResult, RepairStep } from './repair.ts';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static diagnosis of a profile: files, manifests and logs only. It never starts the app, never imports a
|
|
3
|
+
* plugin, and never writes anything, so it works when the app is too broken to launch (spec 041, Scope B).
|
|
4
|
+
*/
|
|
5
|
+
import type { ProfileDiagnosis } from './findings.ts';
|
|
6
|
+
export interface InspectOptions {
|
|
7
|
+
readonly dshHome: string;
|
|
8
|
+
readonly profileName: string;
|
|
9
|
+
}
|
|
10
|
+
/** Diagnose a profile from its files and recent logs. Never throws for a broken profile: that is the finding. */
|
|
11
|
+
export declare function inspectProfile(options: InspectOptions): ProfileDiagnosis;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repair recipes and the plan that runs them.
|
|
3
|
+
*
|
|
4
|
+
* A recipe is a named step with a precondition, a dry-run description that names the exact files it will
|
|
5
|
+
* change, and an undo through the pre-image backup. Nothing is guessed: with no matching finding a recipe does
|
|
6
|
+
* not exist in the plan. There are only two recipes and they can only grow by a reviewed change.
|
|
7
|
+
*/
|
|
8
|
+
import { type BackupManifest } from './backup.ts';
|
|
9
|
+
import { type ProfileDiagnosis, type ProfileFinding, type RecipeId } from './findings.ts';
|
|
10
|
+
export interface RepairStep {
|
|
11
|
+
readonly recipe: RecipeId;
|
|
12
|
+
/** What will change, in words, naming the file or row. */
|
|
13
|
+
readonly description: string;
|
|
14
|
+
/** Every file the step may write; each is backed up first. */
|
|
15
|
+
readonly files: readonly string[];
|
|
16
|
+
/** The finding that made this step applicable. */
|
|
17
|
+
readonly because: ProfileFinding;
|
|
18
|
+
}
|
|
19
|
+
export interface RepairPlan {
|
|
20
|
+
readonly profileName: string;
|
|
21
|
+
readonly dshHome: string;
|
|
22
|
+
readonly steps: readonly RepairStep[];
|
|
23
|
+
}
|
|
24
|
+
export interface RepairResult {
|
|
25
|
+
readonly backupId: string;
|
|
26
|
+
readonly applied: readonly RecipeId[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the plan for the chosen recipes.
|
|
30
|
+
* @param recipes - the recipes to include; only ones with a matching finding are planned.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planRepairs(diagnosis: ProfileDiagnosis, recipes?: readonly RecipeId[]): RepairPlan;
|
|
33
|
+
/** Back up, then apply every step; on any failure the backup is put back and the error is thrown. */
|
|
34
|
+
export declare function applyRepairPlan(plan: RepairPlan): Promise<RepairResult>;
|
|
35
|
+
/** Undo a repair by putting its pre-images back. */
|
|
36
|
+
export declare function undoRepair(dshHome: string, backupId: string): Promise<BackupManifest>;
|
|
37
|
+
/** The plan as readable text, for a dry run or a confirmation. */
|
|
38
|
+
export declare function describePlan(plan: RepairPlan): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framework packages that moved into `acrylblends` (spec 049 slice 17). An app plugin written before the move imports them by
|
|
3
|
+
* their old names, which no longer resolve; there is no alias, because `@acryldev/router/middleware` maps to one subpath per middleware
|
|
4
|
+
* and an alias would hide that. This module names what to import instead, and `movedFrameworkImports` registers a resolve hook
|
|
5
|
+
* that adds it to the "cannot find package" error a boot would otherwise end on.
|
|
6
|
+
*
|
|
7
|
+
* @module @acryldev/harness-runtime/profile-resolution/moved-framework
|
|
8
|
+
*/
|
|
9
|
+
import type { ModuleHooks } from 'node:module';
|
|
10
|
+
/** Each old specifier and what replaces it. */
|
|
11
|
+
export declare const MOVED_FRAMEWORK_IMPORTS: Readonly<Record<string, string>>;
|
|
12
|
+
/** What replaces an old framework import, or undefined for any other specifier. */
|
|
13
|
+
export declare function movedFrameworkImport(specifier: string): string | undefined;
|
|
14
|
+
/** The message for an old framework import that did not resolve. */
|
|
15
|
+
export declare function movedFrameworkMessage(specifier: string, original: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* A resolve hook that names the replacement when an old framework import does not resolve. Registered after the profile's own
|
|
18
|
+
* resolution, so it sees that resolution's failure; anything that resolves, and every other error, passes through unchanged.
|
|
19
|
+
* @returns the hooks, for the caller to deregister with the resolution it wraps.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerMovedFrameworkImports(): ModuleHooks;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** In-memory profile package routing for Node's default ESM and CommonJS loaders. */
|
|
2
|
+
import type { RuntimeResolution } from '@deepseek-ai/dsh-app-boot';
|
|
3
|
+
/** Active interception in one Node isolate. */
|
|
4
|
+
export interface RuntimeInterception {
|
|
5
|
+
/**
|
|
6
|
+
* Locate a bare package without requiring one of its exports.
|
|
7
|
+
* A package subpath selects its package directory without resolving or validating the requested file.
|
|
8
|
+
* @param specifier - bare package or package-subpath specifier.
|
|
9
|
+
* @param parentURL - file URL whose lookup order applies.
|
|
10
|
+
* @returns selected package directory, or undefined when it is absent.
|
|
11
|
+
*/
|
|
12
|
+
packageDir(specifier: string, parentURL: string): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Atomically publish a complete successor and fresh caches. Linked roots may be added or removed.
|
|
15
|
+
* Removed roots stop intercepting uncovered directories; existing modules and Node caches remain intact.
|
|
16
|
+
* @param successor - fully constructed generation retaining existing package mappings and local names.
|
|
17
|
+
* @throws when the profile scope or existing mappings change, local names are removed or override
|
|
18
|
+
* existing mappings, or a previously published link name selects a different real directory.
|
|
19
|
+
*/
|
|
20
|
+
replace(successor: RuntimeResolution): void;
|
|
21
|
+
/** Restore the native resolver methods. Interceptions dispose in reverse order. */
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Split a bare request into its package name without allocating path segments.
|
|
26
|
+
* @param request - module specifier to classify.
|
|
27
|
+
* @returns the bare package name, or undefined for non-package requests.
|
|
28
|
+
*/
|
|
29
|
+
export declare function barePackageName(request: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Install one runtime resolution as the interception on Node's default ESM and CommonJS resolvers.
|
|
32
|
+
* @param resolution - complete package table and profile scope.
|
|
33
|
+
* @returns an interception that publishes a successor or restores the native methods.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installRuntimeInterception(resolution: RuntimeResolution): RuntimeInterception;
|
|
36
|
+
/**
|
|
37
|
+
* Publish one runtime resolution for Harness-owned Workers.
|
|
38
|
+
* @param resolution - complete package table and profile scope.
|
|
39
|
+
* @returns a disposer restoring the previous thread environment data.
|
|
40
|
+
*/
|
|
41
|
+
export declare function registerWorkerResolution(resolution: RuntimeResolution): () => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { PluginPackages, type PluginPackage, type PluginPackagesConfig, type RuntimeResolution } from '@deepseek-ai/dsh-app-boot';
|
|
3
|
+
/** Package lookup shared by metadata consumers in one profile process, on Node's public module hooks. */
|
|
4
|
+
export declare class ProfilePluginPackages extends PluginPackages {
|
|
5
|
+
private table;
|
|
6
|
+
private readonly routing;
|
|
7
|
+
private disposeWorkers;
|
|
8
|
+
constructor(ctx: Context, config?: PluginPackagesConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Publish a complete successor generation for this process and subsequently created Workers.
|
|
11
|
+
* Linked roots may be removed without unloading modules or clearing Node caches.
|
|
12
|
+
* @param successor - fully constructed generation accepted by {@link RuntimeInterception.replace}.
|
|
13
|
+
*/
|
|
14
|
+
replace(successor: RuntimeResolution): void;
|
|
15
|
+
/**
|
|
16
|
+
* Locate the package named by a specifier without requiring a package export.
|
|
17
|
+
* @param specifier - module specifier whose package owns the requested module.
|
|
18
|
+
* @param parentURL - URL whose Node lookup order applies.
|
|
19
|
+
* @returns the parsed package, or undefined when no package owns the request.
|
|
20
|
+
*/
|
|
21
|
+
packageOf(specifier: string, parentURL: string): PluginPackage | undefined;
|
|
22
|
+
}
|