@dsh-ray/lark-channel 0.0.1-seed.0 → 0.2.0
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 +21 -0
- package/README.md +206 -1
- package/bin/dsh-lark-setup.js +37 -0
- package/bin/dsh-ray-setup.js +34 -0
- package/bin/dsh-supervised-growth-setup.js +34 -0
- package/cordis.patch.yml +23 -0
- package/docs/operations.md +133 -0
- package/docs/progress-security.md +125 -0
- package/docs/rsi-setup.md +216 -0
- package/docs/setup.md +358 -0
- package/docs/supervised-growth.md +95 -0
- package/lib/adapter.d.ts +185 -0
- package/lib/adapter.d.ts.map +1 -0
- package/lib/adapter.js +2072 -0
- package/lib/adapter.js.map +1 -0
- package/lib/answer-card.d.ts +40 -0
- package/lib/answer-card.d.ts.map +1 -0
- package/lib/answer-card.js +262 -0
- package/lib/answer-card.js.map +1 -0
- package/lib/approval.d.ts +26 -0
- package/lib/approval.d.ts.map +1 -0
- package/lib/approval.js +104 -0
- package/lib/approval.js.map +1 -0
- package/lib/business-cli-install.d.ts +9 -0
- package/lib/business-cli-install.d.ts.map +1 -0
- package/lib/business-cli-install.js +367 -0
- package/lib/business-cli-install.js.map +1 -0
- package/lib/business-environment.d.ts +2 -0
- package/lib/business-environment.d.ts.map +1 -0
- package/lib/business-environment.js +16 -0
- package/lib/business-environment.js.map +1 -0
- package/lib/business-skill.d.ts +32 -0
- package/lib/business-skill.d.ts.map +1 -0
- package/lib/business-skill.js +202 -0
- package/lib/business-skill.js.map +1 -0
- package/lib/command-card.d.ts +3 -0
- package/lib/command-card.d.ts.map +1 -0
- package/lib/command-card.js +480 -0
- package/lib/command-card.js.map +1 -0
- package/lib/config.d.ts +32 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +115 -0
- package/lib/config.js.map +1 -0
- package/lib/group-thread.d.ts +20 -0
- package/lib/group-thread.d.ts.map +1 -0
- package/lib/group-thread.js +36 -0
- package/lib/group-thread.js.map +1 -0
- package/lib/index.d.ts +34 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +53 -0
- package/lib/index.js.map +1 -0
- package/lib/launchd-control.d.ts +24 -0
- package/lib/launchd-control.d.ts.map +1 -0
- package/lib/launchd-control.js +68 -0
- package/lib/launchd-control.js.map +1 -0
- package/lib/launchd-identity.d.ts +34 -0
- package/lib/launchd-identity.d.ts.map +1 -0
- package/lib/launchd-identity.js +184 -0
- package/lib/launchd-identity.js.map +1 -0
- package/lib/launchd-target-lock.d.ts +6 -0
- package/lib/launchd-target-lock.d.ts.map +1 -0
- package/lib/launchd-target-lock.js +48 -0
- package/lib/launchd-target-lock.js.map +1 -0
- package/lib/launchd.d.ts +62 -0
- package/lib/launchd.d.ts.map +1 -0
- package/lib/launchd.js +370 -0
- package/lib/launchd.js.map +1 -0
- package/lib/model-picker.d.ts +24 -0
- package/lib/model-picker.d.ts.map +1 -0
- package/lib/model-picker.js +95 -0
- package/lib/model-picker.js.map +1 -0
- package/lib/normalize.d.ts +12 -0
- package/lib/normalize.d.ts.map +1 -0
- package/lib/normalize.js +85 -0
- package/lib/normalize.js.map +1 -0
- package/lib/permission-picker.d.ts +29 -0
- package/lib/permission-picker.d.ts.map +1 -0
- package/lib/permission-picker.js +145 -0
- package/lib/permission-picker.js.map +1 -0
- package/lib/progress.d.ts +34 -0
- package/lib/progress.d.ts.map +1 -0
- package/lib/progress.js +354 -0
- package/lib/progress.js.map +1 -0
- package/lib/resident.d.ts +13 -0
- package/lib/resident.d.ts.map +1 -0
- package/lib/resident.js +41 -0
- package/lib/resident.js.map +1 -0
- package/lib/rsi-authority-config.d.ts +29 -0
- package/lib/rsi-authority-config.d.ts.map +1 -0
- package/lib/rsi-authority-config.js +233 -0
- package/lib/rsi-authority-config.js.map +1 -0
- package/lib/rsi-authority-resources.d.ts +36 -0
- package/lib/rsi-authority-resources.d.ts.map +1 -0
- package/lib/rsi-authority-resources.js +139 -0
- package/lib/rsi-authority-resources.js.map +1 -0
- package/lib/rsi-authority-runtime.d.ts +51 -0
- package/lib/rsi-authority-runtime.d.ts.map +1 -0
- package/lib/rsi-authority-runtime.js +496 -0
- package/lib/rsi-authority-runtime.js.map +1 -0
- package/lib/rsi-bootstrap-manifest.d.ts +53 -0
- package/lib/rsi-bootstrap-manifest.d.ts.map +1 -0
- package/lib/rsi-bootstrap-manifest.js +507 -0
- package/lib/rsi-bootstrap-manifest.js.map +1 -0
- package/lib/rsi-bootstrap.d.ts +61 -0
- package/lib/rsi-bootstrap.d.ts.map +1 -0
- package/lib/rsi-bootstrap.js +597 -0
- package/lib/rsi-bootstrap.js.map +1 -0
- package/lib/rsi-build.d.ts +76 -0
- package/lib/rsi-build.d.ts.map +1 -0
- package/lib/rsi-build.js +210 -0
- package/lib/rsi-build.js.map +1 -0
- package/lib/rsi-host-authorities.d.ts +18 -0
- package/lib/rsi-host-authorities.d.ts.map +1 -0
- package/lib/rsi-host-authorities.js +129 -0
- package/lib/rsi-host-authorities.js.map +1 -0
- package/lib/rsi-host-update.d.ts +179 -0
- package/lib/rsi-host-update.d.ts.map +1 -0
- package/lib/rsi-host-update.js +568 -0
- package/lib/rsi-host-update.js.map +1 -0
- package/lib/rsi-install-inputs.d.ts +45 -0
- package/lib/rsi-install-inputs.d.ts.map +1 -0
- package/lib/rsi-install-inputs.js +345 -0
- package/lib/rsi-install-inputs.js.map +1 -0
- package/lib/rsi-install.d.ts +117 -0
- package/lib/rsi-install.d.ts.map +1 -0
- package/lib/rsi-install.js +791 -0
- package/lib/rsi-install.js.map +1 -0
- package/lib/rsi-linux-cgroup-roots.d.ts +3 -0
- package/lib/rsi-linux-cgroup-roots.d.ts.map +1 -0
- package/lib/rsi-linux-cgroup-roots.js +3 -0
- package/lib/rsi-linux-cgroup-roots.js.map +1 -0
- package/lib/rsi-linux-creation-build.d.ts +36 -0
- package/lib/rsi-linux-creation-build.d.ts.map +1 -0
- package/lib/rsi-linux-creation-build.js +213 -0
- package/lib/rsi-linux-creation-build.js.map +1 -0
- package/lib/rsi-linux-native-materialize.d.ts +31 -0
- package/lib/rsi-linux-native-materialize.d.ts.map +1 -0
- package/lib/rsi-linux-native-materialize.js +162 -0
- package/lib/rsi-linux-native-materialize.js.map +1 -0
- package/lib/rsi-linux-native-relocation.d.ts +124 -0
- package/lib/rsi-linux-native-relocation.d.ts.map +1 -0
- package/lib/rsi-linux-native-relocation.js +1571 -0
- package/lib/rsi-linux-native-relocation.js.map +1 -0
- package/lib/rsi-linux-native-resources.d.ts +97 -0
- package/lib/rsi-linux-native-resources.d.ts.map +1 -0
- package/lib/rsi-linux-native-resources.js +521 -0
- package/lib/rsi-linux-native-resources.js.map +1 -0
- package/lib/rsi-linux-repository-bootstrap.d.ts +17 -0
- package/lib/rsi-linux-repository-bootstrap.d.ts.map +1 -0
- package/lib/rsi-linux-repository-bootstrap.js +317 -0
- package/lib/rsi-linux-repository-bootstrap.js.map +1 -0
- package/lib/rsi-linux-runner-states.d.ts +20 -0
- package/lib/rsi-linux-runner-states.d.ts.map +1 -0
- package/lib/rsi-linux-runner-states.js +70 -0
- package/lib/rsi-linux-runner-states.js.map +1 -0
- package/lib/rsi-linux-runtime-bootstrap.d.ts +10 -0
- package/lib/rsi-linux-runtime-bootstrap.d.ts.map +1 -0
- package/lib/rsi-linux-runtime-bootstrap.js +38 -0
- package/lib/rsi-linux-runtime-bootstrap.js.map +1 -0
- package/lib/rsi-linux-source-build.d.ts +28 -0
- package/lib/rsi-linux-source-build.d.ts.map +1 -0
- package/lib/rsi-linux-source-build.js +43 -0
- package/lib/rsi-linux-source-build.js.map +1 -0
- package/lib/rsi-local-activation.d.ts +78 -0
- package/lib/rsi-local-activation.d.ts.map +1 -0
- package/lib/rsi-local-activation.js +486 -0
- package/lib/rsi-local-activation.js.map +1 -0
- package/lib/rsi-local-cohort.d.ts +70 -0
- package/lib/rsi-local-cohort.d.ts.map +1 -0
- package/lib/rsi-local-cohort.js +810 -0
- package/lib/rsi-local-cohort.js.map +1 -0
- package/lib/rsi-local-install.d.ts +70 -0
- package/lib/rsi-local-install.d.ts.map +1 -0
- package/lib/rsi-local-install.js +363 -0
- package/lib/rsi-local-install.js.map +1 -0
- package/lib/rsi-local-pair-install.d.ts +53 -0
- package/lib/rsi-local-pair-install.d.ts.map +1 -0
- package/lib/rsi-local-pair-install.js +215 -0
- package/lib/rsi-local-pair-install.js.map +1 -0
- package/lib/rsi-local-profile-update.d.ts +25 -0
- package/lib/rsi-local-profile-update.d.ts.map +1 -0
- package/lib/rsi-local-profile-update.js +226 -0
- package/lib/rsi-local-profile-update.js.map +1 -0
- package/lib/rsi-local-roots-extension.d.ts +11 -0
- package/lib/rsi-local-roots-extension.d.ts.map +1 -0
- package/lib/rsi-local-roots-extension.js +31 -0
- package/lib/rsi-local-roots-extension.js.map +1 -0
- package/lib/rsi-local-update-build.d.ts +37 -0
- package/lib/rsi-local-update-build.d.ts.map +1 -0
- package/lib/rsi-local-update-build.js +75 -0
- package/lib/rsi-local-update-build.js.map +1 -0
- package/lib/rsi-local-update.d.ts +39 -0
- package/lib/rsi-local-update.d.ts.map +1 -0
- package/lib/rsi-local-update.js +205 -0
- package/lib/rsi-local-update.js.map +1 -0
- package/lib/rsi-memory-learning.d.ts +36 -0
- package/lib/rsi-memory-learning.d.ts.map +1 -0
- package/lib/rsi-memory-learning.js +111 -0
- package/lib/rsi-memory-learning.js.map +1 -0
- package/lib/rsi-native-install.d.ts +38 -0
- package/lib/rsi-native-install.d.ts.map +1 -0
- package/lib/rsi-native-install.js +312 -0
- package/lib/rsi-native-install.js.map +1 -0
- package/lib/rsi-native-launchd.d.ts +7 -0
- package/lib/rsi-native-launchd.d.ts.map +1 -0
- package/lib/rsi-native-launchd.js +49 -0
- package/lib/rsi-native-launchd.js.map +1 -0
- package/lib/rsi-native-profile.d.ts +76 -0
- package/lib/rsi-native-profile.d.ts.map +1 -0
- package/lib/rsi-native-profile.js +530 -0
- package/lib/rsi-native-profile.js.map +1 -0
- package/lib/rsi-native-runtime-bootstrap.d.ts +44 -0
- package/lib/rsi-native-runtime-bootstrap.d.ts.map +1 -0
- package/lib/rsi-native-runtime-bootstrap.js +619 -0
- package/lib/rsi-native-runtime-bootstrap.js.map +1 -0
- package/lib/rsi-ordinary-use-learning.d.ts +60 -0
- package/lib/rsi-ordinary-use-learning.d.ts.map +1 -0
- package/lib/rsi-ordinary-use-learning.js +103 -0
- package/lib/rsi-ordinary-use-learning.js.map +1 -0
- package/lib/rsi-owner-profile.d.ts +37 -0
- package/lib/rsi-owner-profile.d.ts.map +1 -0
- package/lib/rsi-owner-profile.js +178 -0
- package/lib/rsi-owner-profile.js.map +1 -0
- package/lib/rsi-plugin-creation.d.ts +46 -0
- package/lib/rsi-plugin-creation.d.ts.map +1 -0
- package/lib/rsi-plugin-creation.js +227 -0
- package/lib/rsi-plugin-creation.js.map +1 -0
- package/lib/rsi-plugin-revision.d.ts +38 -0
- package/lib/rsi-plugin-revision.d.ts.map +1 -0
- package/lib/rsi-plugin-revision.js +221 -0
- package/lib/rsi-plugin-revision.js.map +1 -0
- package/lib/rsi-profile.d.ts +81 -0
- package/lib/rsi-profile.d.ts.map +1 -0
- package/lib/rsi-profile.js +551 -0
- package/lib/rsi-profile.js.map +1 -0
- package/lib/rsi-release-build.d.ts +59 -0
- package/lib/rsi-release-build.d.ts.map +1 -0
- package/lib/rsi-release-build.js +219 -0
- package/lib/rsi-release-build.js.map +1 -0
- package/lib/rsi-scanner-retirement-config.d.ts +34 -0
- package/lib/rsi-scanner-retirement-config.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-config.js +272 -0
- package/lib/rsi-scanner-retirement-config.js.map +1 -0
- package/lib/rsi-scanner-retirement-runtime.d.ts +23 -0
- package/lib/rsi-scanner-retirement-runtime.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-runtime.js +98 -0
- package/lib/rsi-scanner-retirement-runtime.js.map +1 -0
- package/lib/rsi-scanner-retirement-stage.d.ts +55 -0
- package/lib/rsi-scanner-retirement-stage.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-stage.js +181 -0
- package/lib/rsi-scanner-retirement-stage.js.map +1 -0
- package/lib/rsi-scanner-retirement-transition.d.ts +57 -0
- package/lib/rsi-scanner-retirement-transition.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-transition.js +330 -0
- package/lib/rsi-scanner-retirement-transition.js.map +1 -0
- package/lib/rsi-service-environment.d.ts +6 -0
- package/lib/rsi-service-environment.d.ts.map +1 -0
- package/lib/rsi-service-environment.js +113 -0
- package/lib/rsi-service-environment.js.map +1 -0
- package/lib/rsi-service-setup.d.ts +10 -0
- package/lib/rsi-service-setup.d.ts.map +1 -0
- package/lib/rsi-service-setup.js +34 -0
- package/lib/rsi-service-setup.js.map +1 -0
- package/lib/rsi-setup.d.ts +92 -0
- package/lib/rsi-setup.d.ts.map +1 -0
- package/lib/rsi-setup.js +908 -0
- package/lib/rsi-setup.js.map +1 -0
- package/lib/rsi-source-maintenance.d.ts +33 -0
- package/lib/rsi-source-maintenance.d.ts.map +1 -0
- package/lib/rsi-source-maintenance.js +407 -0
- package/lib/rsi-source-maintenance.js.map +1 -0
- package/lib/rsi-source-update.d.ts +26 -0
- package/lib/rsi-source-update.d.ts.map +1 -0
- package/lib/rsi-source-update.js +276 -0
- package/lib/rsi-source-update.js.map +1 -0
- package/lib/rsi-source.d.ts +34 -0
- package/lib/rsi-source.d.ts.map +1 -0
- package/lib/rsi-source.js +487 -0
- package/lib/rsi-source.js.map +1 -0
- package/lib/rsi-systemd-bootstrap.d.ts +46 -0
- package/lib/rsi-systemd-bootstrap.d.ts.map +1 -0
- package/lib/rsi-systemd-bootstrap.js +271 -0
- package/lib/rsi-systemd-bootstrap.js.map +1 -0
- package/lib/sdk.d.ts +216 -0
- package/lib/sdk.d.ts.map +1 -0
- package/lib/sdk.js +1990 -0
- package/lib/sdk.js.map +1 -0
- package/lib/service.d.ts +63 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +599 -0
- package/lib/service.js.map +1 -0
- package/lib/setup-business.d.ts +49 -0
- package/lib/setup-business.d.ts.map +1 -0
- package/lib/setup-business.js +335 -0
- package/lib/setup-business.js.map +1 -0
- package/lib/setup-materialization.d.ts +15 -0
- package/lib/setup-materialization.d.ts.map +1 -0
- package/lib/setup-materialization.js +221 -0
- package/lib/setup-materialization.js.map +1 -0
- package/lib/setup-profile.d.ts +23 -0
- package/lib/setup-profile.d.ts.map +1 -0
- package/lib/setup-profile.js +1248 -0
- package/lib/setup-profile.js.map +1 -0
- package/lib/setup.d.ts +298 -0
- package/lib/setup.d.ts.map +1 -0
- package/lib/setup.js +3310 -0
- package/lib/setup.js.map +1 -0
- package/lib/supervised-growth-profile.d.ts +111 -0
- package/lib/supervised-growth-profile.d.ts.map +1 -0
- package/lib/supervised-growth-profile.js +903 -0
- package/lib/supervised-growth-profile.js.map +1 -0
- package/lib/supervised-growth-setup.d.ts +201 -0
- package/lib/supervised-growth-setup.d.ts.map +1 -0
- package/lib/supervised-growth-setup.js +1005 -0
- package/lib/supervised-growth-setup.js.map +1 -0
- package/lib/systemd.d.ts +70 -0
- package/lib/systemd.d.ts.map +1 -0
- package/lib/systemd.js +308 -0
- package/lib/systemd.js.map +1 -0
- package/lib/tool-approval.d.ts +22 -0
- package/lib/tool-approval.d.ts.map +1 -0
- package/lib/tool-approval.js +107 -0
- package/lib/tool-approval.js.map +1 -0
- package/lib/types.d.ts +351 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +11 -0
- package/lib/types.js.map +1 -0
- package/lib/user-question.d.ts +31 -0
- package/lib/user-question.d.ts.map +1 -0
- package/lib/user-question.js +161 -0
- package/lib/user-question.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +2 -0
- package/lib/version.js.map +1 -0
- package/lib/windows-task.d.ts +42 -0
- package/lib/windows-task.d.ts.map +1 -0
- package/lib/windows-task.js +143 -0
- package/lib/windows-task.js.map +1 -0
- package/lib/ws-card-callback.d.ts +7 -0
- package/lib/ws-card-callback.d.ts.map +1 -0
- package/lib/ws-card-callback.js +51 -0
- package/lib/ws-card-callback.js.map +1 -0
- package/package.json +162 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type NativeMacRuntime } from '@dsh-ray/assistant-isolation';
|
|
2
|
+
import { type RsiSourceWorkspace } from './rsi-source.js';
|
|
3
|
+
export interface FrozenNativeManifestSource {
|
|
4
|
+
version: string;
|
|
5
|
+
manifests: readonly {
|
|
6
|
+
path: string;
|
|
7
|
+
bytes: Uint8Array;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
export interface NativeRsiBuildEnvironment {
|
|
11
|
+
schemaVersion: 2;
|
|
12
|
+
sourceCommit: string;
|
|
13
|
+
lockSha256: string;
|
|
14
|
+
runtime: NativeMacRuntime;
|
|
15
|
+
sourceBuild: {
|
|
16
|
+
backend: 'macos-seatbelt';
|
|
17
|
+
runtime: NativeMacRuntime;
|
|
18
|
+
timeoutMs: 60_000;
|
|
19
|
+
outputBytes: 1_048_576;
|
|
20
|
+
versioning: 'patch';
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface NativeRsiCreationBuildEnvironment {
|
|
24
|
+
schemaVersion: 2;
|
|
25
|
+
backend: 'macos-seatbelt';
|
|
26
|
+
sourceCommit: string;
|
|
27
|
+
runtime: NativeMacRuntime;
|
|
28
|
+
}
|
|
29
|
+
export declare function nativeRsiCreationBuild(build: NativeRsiBuildEnvironment): NativeRsiCreationBuildEnvironment;
|
|
30
|
+
export interface NativeRsiBootstrapInput {
|
|
31
|
+
dshHome: string;
|
|
32
|
+
profile: string;
|
|
33
|
+
source: RsiSourceWorkspace;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
/** Exact predownloaded official bytes; only intended for an isolated installer cache or test. */
|
|
36
|
+
nodeArchivePath?: string;
|
|
37
|
+
pnpmArchivePath?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Validate and copy frozen manifests using strict YAML/lockfile structural checks. */
|
|
40
|
+
export declare function validateFrozenNativeManifests(source: FrozenNativeManifestSource): Map<string, Buffer>;
|
|
41
|
+
/** Install only committed manifests and their frozen dependencies into a private native runtime. */
|
|
42
|
+
export declare function prepareNativeRsiRuntime(input: NativeRsiBootstrapInput): Promise<NativeRsiBuildEnvironment>;
|
|
43
|
+
export declare function readNativeRsiRuntime(input: NativeRsiBootstrapInput): Promise<NativeRsiBuildEnvironment>;
|
|
44
|
+
//# sourceMappingURL=rsi-native-runtime-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsi-native-runtime-bootstrap.d.ts","sourceRoot":"","sources":["../src/rsi-native-runtime-bootstrap.ts"],"names":[],"mappings":"AAOA,OAAO,EAAoD,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAEtH,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAuBjF,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,EAAE,CAAA;CAC1D;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,CAAC,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,gBAAgB,CAAA;IACzB,WAAW,EAAE;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QACrF,WAAW,EAAE,SAAS,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAA;CAChD;AACD,MAAM,WAAW,iCAAiC;IAChD,aAAa,EAAE,CAAC,CAAA;IAChB,OAAO,EAAE,gBAAgB,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,gBAAgB,CAAA;CAC1B;AACD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,yBAAyB,GAAG,iCAAiC,CAE1G;AASD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAClF,iGAAiG;IACjG,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CACnD;AAkKD,uFAAuF;AACvF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,0BAA0B,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA8FrG;AAiID,oGAAoG;AACpG,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA4FhH;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAK7G"}
|
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
+
import { constants } from 'node:fs';
|
|
4
|
+
import { chmod, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, symlink, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { request } from 'node:https';
|
|
6
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
7
|
+
import { isDeepStrictEqual, TextDecoder } from 'node:util';
|
|
8
|
+
import { hashNativeMacRuntimeTree, verifyNativeMacRuntime } from '@dsh-ray/assistant-isolation';
|
|
9
|
+
import { parse as parseYaml } from 'yaml';
|
|
10
|
+
import { readRsiSourceWorkspace } from './rsi-source.js';
|
|
11
|
+
const NODE_VERSION = 'v24.22.0';
|
|
12
|
+
const PNPM_VERSION = '11.7.0';
|
|
13
|
+
const NODE_ARCHIVES = {
|
|
14
|
+
arm64: '6a9724d9b50a5f22b4816cded441b5a8d9ddae546191a5e5b7efa5a5e2ee26d5',
|
|
15
|
+
x64: '495e3f273c645f3c4677d438304cdfc701729ea5dec5728f5c8e76a2dece4b91',
|
|
16
|
+
};
|
|
17
|
+
const ARM64_NODE_SHA = 'b468fb9c67427c9d3aec07ee1105e63020923a631a9a2a00beb71a7ba3768bfd';
|
|
18
|
+
const PNPM_ARCHIVE_SHA = 'deafa7ec98a1218b6a047289b92fbe2395c1e22d3495bb711653013218ee15ee';
|
|
19
|
+
const PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
20
|
+
const MAX_NODE_ARCHIVE = 100_000_000;
|
|
21
|
+
const MAX_PNPM_ARCHIVE = 10_000_000;
|
|
22
|
+
const MAX_GIT_OUTPUT = 4_194_304;
|
|
23
|
+
const MAX_MANIFESTS = 256;
|
|
24
|
+
const MAX_MANIFEST_BYTES = 8_388_608;
|
|
25
|
+
const VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
26
|
+
const ROOTS = ['package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml'];
|
|
27
|
+
const MANIFEST = /^(?:plugins|packages)\/[a-z0-9-]+\/package\.json$/u;
|
|
28
|
+
const PACKAGE = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u;
|
|
29
|
+
const EXACT_VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
30
|
+
const DISALLOWED_LOCK_VALUE = /(?:git\+|\b(?:https?|ssh|ftp|git|tarball|github|gitlab|bitbucket|file):)/iu;
|
|
31
|
+
export function nativeRsiCreationBuild(build) {
|
|
32
|
+
return { schemaVersion: 2, backend: 'macos-seatbelt', sourceCommit: build.sourceCommit, runtime: build.runtime };
|
|
33
|
+
}
|
|
34
|
+
function fail(message) { throw new Error(`rsi native bootstrap: ${message}`); }
|
|
35
|
+
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
36
|
+
const canonical = (path) => typeof path === 'string' && isAbsolute(path) && resolve(path) === path
|
|
37
|
+
&& !path.includes('\0') && !/[\r\n]/u.test(path);
|
|
38
|
+
async function privateDirectory(path) {
|
|
39
|
+
if (!canonical(path) || await realpath(path) !== path)
|
|
40
|
+
fail('noncanonical private directory');
|
|
41
|
+
const item = await lstat(path);
|
|
42
|
+
if (!item.isDirectory() || item.isSymbolicLink() || (item.mode & 0o077) !== 0
|
|
43
|
+
|| typeof process.getuid === 'function' && item.uid !== process.getuid())
|
|
44
|
+
fail('unsafe private directory');
|
|
45
|
+
}
|
|
46
|
+
async function syncDirectory(path) {
|
|
47
|
+
const fd = await open(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
48
|
+
try {
|
|
49
|
+
await fd.sync();
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
await fd.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function git(repository, args) {
|
|
56
|
+
const result = spawnSync('/usr/bin/git', ['-c', 'core.hooksPath=/dev/null', '-c', 'core.fsmonitor=false', ...args], {
|
|
57
|
+
cwd: repository, env: { PATH: '/usr/bin:/bin', HOME: '/nonexistent', LANG: 'C', LC_ALL: 'C',
|
|
58
|
+
GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null',
|
|
59
|
+
GIT_TERMINAL_PROMPT: '0', GIT_NO_LAZY_FETCH: '1', GIT_NO_REPLACE_OBJECTS: '1', GIT_ALLOW_PROTOCOL: 'file' },
|
|
60
|
+
maxBuffer: MAX_GIT_OUTPUT, timeout: 30_000,
|
|
61
|
+
});
|
|
62
|
+
if (result.status !== 0 || result.error)
|
|
63
|
+
fail('frozen Git object is unavailable');
|
|
64
|
+
return result.stdout;
|
|
65
|
+
}
|
|
66
|
+
const decode = (bytes) => new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
67
|
+
const record = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
68
|
+
function packageConfiguration(value) {
|
|
69
|
+
if (!record(value) || Object.hasOwn(value, 'pnpm') || Object.hasOwn(value, 'devEngines')
|
|
70
|
+
|| value.engines !== undefined && (!record(value.engines) || Object.hasOwn(value.engines, 'runtime'))) {
|
|
71
|
+
fail('frozen package configuration unsupported');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function workspaceConfiguration(value) {
|
|
75
|
+
const allowed = new Set(['packages', 'catalog', 'linkWorkspacePackages', 'enableGlobalVirtualStore', 'allowBuilds', 'minimumReleaseAgeExclude']);
|
|
76
|
+
if (!record(value) || Object.keys(value).some(key => !allowed.has(key)))
|
|
77
|
+
fail('frozen workspace configuration unsupported');
|
|
78
|
+
if (value.catalog !== undefined && (!record(value.catalog) || Object.entries(value.catalog).some(([name, version]) => !PACKAGE.test(name) || typeof version !== 'string' || !EXACT_VERSION.test(version))))
|
|
79
|
+
fail('frozen workspace configuration catalog invalid');
|
|
80
|
+
if (value.linkWorkspacePackages !== undefined && typeof value.linkWorkspacePackages !== 'boolean')
|
|
81
|
+
fail('frozen workspace configuration links invalid');
|
|
82
|
+
if (value.enableGlobalVirtualStore !== undefined && value.enableGlobalVirtualStore !== false)
|
|
83
|
+
fail('frozen workspace configuration virtual store invalid');
|
|
84
|
+
if (value.allowBuilds !== undefined && (!record(value.allowBuilds) || Object.entries(value.allowBuilds).some(([name, enabled]) => !PACKAGE.test(name) || typeof enabled !== 'boolean')))
|
|
85
|
+
fail('frozen workspace configuration builds invalid');
|
|
86
|
+
if (value.minimumReleaseAgeExclude !== undefined && (!Array.isArray(value.minimumReleaseAgeExclude)
|
|
87
|
+
|| value.minimumReleaseAgeExclude.some(entry => {
|
|
88
|
+
if (typeof entry !== 'string')
|
|
89
|
+
return true;
|
|
90
|
+
const split = entry.lastIndexOf('@');
|
|
91
|
+
return split < 1 || !PACKAGE.test(entry.slice(0, split)) || !EXACT_VERSION.test(entry.slice(split + 1));
|
|
92
|
+
})))
|
|
93
|
+
fail('frozen workspace configuration release exclusions invalid');
|
|
94
|
+
}
|
|
95
|
+
function hasControlOrWhitespace(value) {
|
|
96
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
97
|
+
const code = value.charCodeAt(index);
|
|
98
|
+
if (code <= 0x20 || code === 0x7f)
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return /\s/u.test(value);
|
|
102
|
+
}
|
|
103
|
+
function isRegistryNpmjsTarballUrl(tarball) {
|
|
104
|
+
if (!tarball.startsWith('https://registry.npmjs.org/') || tarball.includes('\\')
|
|
105
|
+
|| tarball.includes('?') || tarball.includes('#') || hasControlOrWhitespace(tarball)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
let url;
|
|
109
|
+
try {
|
|
110
|
+
url = new URL(tarball);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (url.protocol !== 'https:' || url.hostname !== 'registry.npmjs.org' || url.port !== ''
|
|
116
|
+
|| url.username !== '' || url.password !== '' || url.search !== '' || url.hash !== '' || url.pathname.length <= 1) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const rawSegments = tarball.slice('https://registry.npmjs.org/'.length).split('/');
|
|
120
|
+
if (rawSegments.length === 0 || rawSegments.some(segment => segment === '' || segment === '.' || segment === '..')) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
for (const segment of rawSegments) {
|
|
124
|
+
let decoded;
|
|
125
|
+
try {
|
|
126
|
+
decoded = decodeURIComponent(segment);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (decoded === '' || decoded === '.' || decoded === '..' || decoded.includes('/')
|
|
132
|
+
|| decoded.includes('\\') || hasControlOrWhitespace(decoded)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const parsedSegments = url.pathname.slice(1).split('/');
|
|
137
|
+
return !parsedSegments.includes('..') && !parsedSegments.includes('.');
|
|
138
|
+
}
|
|
139
|
+
function validateLockfileNode(value, allowPackageEntryFields = false) {
|
|
140
|
+
if (typeof value === 'string') {
|
|
141
|
+
if (DISALLOWED_LOCK_VALUE.test(value))
|
|
142
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(value)) {
|
|
146
|
+
for (const item of value)
|
|
147
|
+
validateLockfileNode(item);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (record(value)) {
|
|
151
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
152
|
+
if (DISALLOWED_LOCK_VALUE.test(key))
|
|
153
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
154
|
+
if (allowPackageEntryFields && key === 'deprecated') {
|
|
155
|
+
if (typeof entry !== 'string')
|
|
156
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (allowPackageEntryFields && key === 'resolution' && record(entry)) {
|
|
160
|
+
for (const [resKey, resValue] of Object.entries(entry)) {
|
|
161
|
+
if (DISALLOWED_LOCK_VALUE.test(resKey))
|
|
162
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
163
|
+
if (resKey === 'tarball')
|
|
164
|
+
continue;
|
|
165
|
+
validateLockfileNode(resValue);
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
validateLockfileNode(entry);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function validateLockfileResolutions(parsed) {
|
|
174
|
+
for (const [key, entry] of Object.entries(parsed)) {
|
|
175
|
+
if (DISALLOWED_LOCK_VALUE.test(key))
|
|
176
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
177
|
+
if (key !== 'packages') {
|
|
178
|
+
validateLockfileNode(entry);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (entry === undefined)
|
|
182
|
+
continue;
|
|
183
|
+
if (!record(entry))
|
|
184
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
185
|
+
for (const [pkgKey, pkgEntry] of Object.entries(entry)) {
|
|
186
|
+
if (DISALLOWED_LOCK_VALUE.test(pkgKey))
|
|
187
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
188
|
+
if (record(pkgEntry)) {
|
|
189
|
+
if (Object.hasOwn(pkgEntry, 'resolution')) {
|
|
190
|
+
const resolution = pkgEntry.resolution;
|
|
191
|
+
if (!record(resolution) || Object.hasOwn(resolution, 'directory')
|
|
192
|
+
|| Object.hasOwn(resolution, 'repo') || Object.hasOwn(resolution, 'commit')) {
|
|
193
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
194
|
+
}
|
|
195
|
+
if (Object.hasOwn(resolution, 'type') && resolution.type !== 'tarball') {
|
|
196
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
197
|
+
}
|
|
198
|
+
if (Object.hasOwn(resolution, 'tarball')) {
|
|
199
|
+
if (typeof resolution.tarball !== 'string' || !isRegistryNpmjsTarballUrl(resolution.tarball)) {
|
|
200
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else if (Object.hasOwn(resolution, 'type')) {
|
|
204
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
validateLockfileNode(pkgEntry, true);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
validateLockfileNode(pkgEntry);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Validate and copy frozen manifests using strict YAML/lockfile structural checks. */
|
|
216
|
+
export function validateFrozenNativeManifests(source) {
|
|
217
|
+
if (!source || !VERSION.test(source.version)
|
|
218
|
+
|| !Array.isArray(source.manifests) || source.manifests.length < 3 || source.manifests.length > MAX_MANIFESTS) {
|
|
219
|
+
fail('frozen manifest inventory is incomplete');
|
|
220
|
+
}
|
|
221
|
+
const files = new Map();
|
|
222
|
+
let total = 0;
|
|
223
|
+
for (const entry of source.manifests) {
|
|
224
|
+
if (!entry || typeof entry.path !== 'string' || (!ROOTS.includes(entry.path) && !MANIFEST.test(entry.path))
|
|
225
|
+
|| files.has(entry.path) || !(entry.bytes instanceof Uint8Array) || entry.bytes.byteLength > MAX_GIT_OUTPUT) {
|
|
226
|
+
fail('frozen manifest inventory is invalid');
|
|
227
|
+
}
|
|
228
|
+
const bytes = Buffer.from(entry.bytes);
|
|
229
|
+
total += bytes.length;
|
|
230
|
+
if (total > MAX_MANIFEST_BYTES)
|
|
231
|
+
fail('frozen manifests exceed bound');
|
|
232
|
+
files.set(entry.path, bytes);
|
|
233
|
+
}
|
|
234
|
+
if (!ROOTS.every(name => files.has(name)))
|
|
235
|
+
fail('frozen manifest inventory is incomplete');
|
|
236
|
+
const sorted = new Map([...files].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
237
|
+
let manifest;
|
|
238
|
+
try {
|
|
239
|
+
manifest = JSON.parse(decode(sorted.get('package.json')));
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return fail('frozen root manifest is invalid');
|
|
243
|
+
}
|
|
244
|
+
if (manifest?.name !== 'dsh-ray' || manifest.version !== source.version
|
|
245
|
+
|| manifest.packageManager !== `pnpm@${PNPM_VERSION}`)
|
|
246
|
+
fail('frozen root manifest identity differs');
|
|
247
|
+
packageConfiguration(manifest);
|
|
248
|
+
const workspaces = new Set([...sorted.keys()].filter(name => MANIFEST.test(name)).map(dirname));
|
|
249
|
+
const packageNames = new Set();
|
|
250
|
+
for (const name of workspaces) {
|
|
251
|
+
try {
|
|
252
|
+
const workspaceManifest = JSON.parse(decode(sorted.get(`${name}/package.json`)));
|
|
253
|
+
if (!workspaceManifest || typeof workspaceManifest.name !== 'string' || !workspaceManifest.name || packageNames.has(workspaceManifest.name)
|
|
254
|
+
|| workspaceManifest.version !== source.version
|
|
255
|
+
|| workspaceManifest.packageManager !== undefined && workspaceManifest.packageManager !== `pnpm@${PNPM_VERSION}`) {
|
|
256
|
+
fail('frozen workspace manifest identity differs');
|
|
257
|
+
}
|
|
258
|
+
packageConfiguration(workspaceManifest);
|
|
259
|
+
packageNames.add(workspaceManifest.name);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
if (error instanceof Error && error.message.startsWith('rsi native bootstrap: '))
|
|
263
|
+
throw error;
|
|
264
|
+
fail('frozen workspace manifest is invalid');
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
let workspace;
|
|
268
|
+
try {
|
|
269
|
+
workspace = parseYaml(decode(sorted.get('pnpm-workspace.yaml')), { maxAliasCount: 0, uniqueKeys: true });
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return fail('frozen workspace inventory is invalid');
|
|
273
|
+
}
|
|
274
|
+
workspaceConfiguration(workspace);
|
|
275
|
+
if (!workspace || !Array.isArray(workspace.packages)
|
|
276
|
+
|| workspace.packages.some((pattern) => !['plugins/*', 'packages/*'].includes(pattern))
|
|
277
|
+
|| new Set(workspace.packages).size !== workspace.packages.length
|
|
278
|
+
|| [...workspaces].some(name => !workspace.packages.includes(name.split('/')[0] + '/*'))) {
|
|
279
|
+
fail('frozen workspace inventory is invalid');
|
|
280
|
+
}
|
|
281
|
+
let lock;
|
|
282
|
+
try {
|
|
283
|
+
lock = decode(sorted.get('pnpm-lock.yaml'));
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return fail('frozen lockfile is invalid');
|
|
287
|
+
}
|
|
288
|
+
if (!lock.startsWith("lockfileVersion: '9.0'\n"))
|
|
289
|
+
fail('frozen lockfile contains an unsupported resolution');
|
|
290
|
+
let parsed;
|
|
291
|
+
try {
|
|
292
|
+
parsed = parseYaml(lock, { maxAliasCount: 0, uniqueKeys: true });
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return fail('frozen lockfile is invalid');
|
|
296
|
+
}
|
|
297
|
+
if (!record(parsed))
|
|
298
|
+
fail('frozen lockfile is invalid');
|
|
299
|
+
validateLockfileResolutions(parsed);
|
|
300
|
+
if (Object.keys(parsed).some(key => !['lockfileVersion', 'settings', 'catalogs', 'importers', 'packages', 'snapshots'].includes(key))) {
|
|
301
|
+
fail('frozen lockfile configuration unsupported');
|
|
302
|
+
}
|
|
303
|
+
if (parsed.settings !== undefined && (!record(parsed.settings)
|
|
304
|
+
|| Object.entries(parsed.settings).some(([key, value]) => !['autoInstallPeers', 'excludeLinksFromLockfile'].includes(key) || typeof value !== 'boolean'))) {
|
|
305
|
+
fail('frozen lockfile configuration settings unsupported');
|
|
306
|
+
}
|
|
307
|
+
if (!parsed.importers || typeof parsed.importers !== 'object' || !Object.hasOwn(parsed.importers, '.')) {
|
|
308
|
+
fail('frozen lockfile has no importers');
|
|
309
|
+
}
|
|
310
|
+
if ([...workspaces].some(name => !Object.hasOwn(parsed.importers, name))) {
|
|
311
|
+
fail('frozen lockfile importers missing');
|
|
312
|
+
}
|
|
313
|
+
for (const [importer, groups] of Object.entries(parsed.importers)) {
|
|
314
|
+
if (importer !== '.' && !workspaces.has(importer))
|
|
315
|
+
fail('frozen lockfile importer is outside manifests');
|
|
316
|
+
if (!record(groups) || Object.keys(groups).some(key => !['dependencies', 'devDependencies', 'optionalDependencies'].includes(key))) {
|
|
317
|
+
fail('frozen importer configuration unsupported');
|
|
318
|
+
}
|
|
319
|
+
for (const group of ['dependencies', 'devDependencies', 'optionalDependencies']) {
|
|
320
|
+
for (const value of Object.values(groups[group] ?? {})) {
|
|
321
|
+
if (!record(value) || typeof value.specifier !== 'string' || typeof value.version !== 'string')
|
|
322
|
+
fail('frozen dependency is invalid');
|
|
323
|
+
if (DISALLOWED_LOCK_VALUE.test(value.specifier) || DISALLOWED_LOCK_VALUE.test(value.version))
|
|
324
|
+
fail('frozen dependency uses an unsupported source');
|
|
325
|
+
if (value.specifier.startsWith('link:') && value.specifier !== value.version)
|
|
326
|
+
fail('frozen dependency uses an unsupported source');
|
|
327
|
+
if (value.version.startsWith('link:')) {
|
|
328
|
+
const target = resolve('/frozen', importer === '.' ? '' : importer, value.version.slice(5));
|
|
329
|
+
if (!target.startsWith('/frozen/') || !workspaces.has(target.slice('/frozen/'.length))) {
|
|
330
|
+
fail('frozen workspace link escapes manifests');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return sorted;
|
|
337
|
+
}
|
|
338
|
+
async function frozenManifests(source) {
|
|
339
|
+
const listed = git(source.repository, ['ls-tree', '-r', '--name-only', '-z', source.sourceCommit]).toString('utf8').split('\0');
|
|
340
|
+
const names = listed.filter(name => ROOTS.includes(name) || MANIFEST.test(name)).sort();
|
|
341
|
+
if (names.length < 3 || names.length > MAX_MANIFESTS
|
|
342
|
+
|| !ROOTS.every(name => names.includes(name)))
|
|
343
|
+
fail('frozen manifest inventory is incomplete');
|
|
344
|
+
const manifests = [];
|
|
345
|
+
let total = 0;
|
|
346
|
+
for (const name of names) {
|
|
347
|
+
const bytes = git(source.repository, ['show', `${source.sourceCommit}:${name}`]);
|
|
348
|
+
if ((total += bytes.length) > MAX_MANIFEST_BYTES || bytes.length > MAX_GIT_OUTPUT)
|
|
349
|
+
fail('frozen manifests exceed bound');
|
|
350
|
+
manifests.push({ path: name, bytes });
|
|
351
|
+
}
|
|
352
|
+
return validateFrozenNativeManifests({ version: source.version, manifests });
|
|
353
|
+
}
|
|
354
|
+
async function download(url, maximum, signal) {
|
|
355
|
+
signal.throwIfAborted();
|
|
356
|
+
return new Promise((resolveBytes, reject) => {
|
|
357
|
+
const chunks = [];
|
|
358
|
+
let size = 0;
|
|
359
|
+
let settled = false;
|
|
360
|
+
const finish = (error, bytes) => {
|
|
361
|
+
if (settled)
|
|
362
|
+
return;
|
|
363
|
+
settled = true;
|
|
364
|
+
signal.removeEventListener('abort', abort);
|
|
365
|
+
if (error)
|
|
366
|
+
reject(error);
|
|
367
|
+
else
|
|
368
|
+
resolveBytes(bytes);
|
|
369
|
+
};
|
|
370
|
+
const req = request(url, { method: 'GET', timeout: 120_000, headers: { 'User-Agent': 'dsh-native-bootstrap/1' } }, res => {
|
|
371
|
+
if (res.statusCode !== 200 || res.headers.location || Number(res.headers['content-length'] ?? 0) > maximum) {
|
|
372
|
+
const error = new Error('official bootstrap download refused');
|
|
373
|
+
req.destroy(error);
|
|
374
|
+
finish(error);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
res.on('data', (chunk) => {
|
|
378
|
+
size += chunk.length;
|
|
379
|
+
if (size > maximum) {
|
|
380
|
+
const error = new Error('official bootstrap archive exceeds bound');
|
|
381
|
+
req.destroy(error);
|
|
382
|
+
finish(error);
|
|
383
|
+
}
|
|
384
|
+
else
|
|
385
|
+
chunks.push(chunk);
|
|
386
|
+
});
|
|
387
|
+
res.once('end', () => finish(undefined, Buffer.concat(chunks)));
|
|
388
|
+
res.once('error', error => finish(error));
|
|
389
|
+
});
|
|
390
|
+
const abort = () => req.destroy(signal.reason);
|
|
391
|
+
req.once('error', error => finish(error));
|
|
392
|
+
req.once('timeout', () => req.destroy(new Error('official bootstrap download timed out')));
|
|
393
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
394
|
+
req.end();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async function officialArchive(path, url, expected, maximum, signal) {
|
|
398
|
+
let bytes;
|
|
399
|
+
if (path === undefined)
|
|
400
|
+
bytes = await download(url, maximum, signal);
|
|
401
|
+
else {
|
|
402
|
+
if (!canonical(path) || await realpath(path) !== path)
|
|
403
|
+
fail('bootstrap archive path is not canonical');
|
|
404
|
+
const item = await lstat(path);
|
|
405
|
+
if (!item.isFile() || item.isSymbolicLink() || item.nlink !== 1 || item.size > maximum)
|
|
406
|
+
fail('bootstrap archive is unsafe');
|
|
407
|
+
bytes = await readFile(path);
|
|
408
|
+
}
|
|
409
|
+
if (bytes.length < 1 || bytes.length > maximum || sha(bytes) !== expected)
|
|
410
|
+
fail('official bootstrap archive digest differs');
|
|
411
|
+
return bytes;
|
|
412
|
+
}
|
|
413
|
+
async function run(file, args, cwd, environment, signal, timeoutMs, maximumOutput = 4_194_304) {
|
|
414
|
+
signal.throwIfAborted();
|
|
415
|
+
return new Promise((resolveOutput, reject) => {
|
|
416
|
+
const child = spawn(file, args, { cwd, env: environment, stdio: ['ignore', 'pipe', 'pipe'], detached: true });
|
|
417
|
+
const chunks = [];
|
|
418
|
+
let size = 0;
|
|
419
|
+
let stderr = '';
|
|
420
|
+
let settled = false;
|
|
421
|
+
const stop = () => { if (child.pid)
|
|
422
|
+
try {
|
|
423
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
child.kill('SIGKILL');
|
|
427
|
+
} };
|
|
428
|
+
const timer = setTimeout(stop, timeoutMs);
|
|
429
|
+
const abort = () => stop();
|
|
430
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
431
|
+
child.stdout.on('data', (chunk) => { size += chunk.length; if (size > maximumOutput)
|
|
432
|
+
stop();
|
|
433
|
+
else
|
|
434
|
+
chunks.push(chunk); });
|
|
435
|
+
child.stderr.on('data', (chunk) => { stderr = (stderr + chunk.toString()).slice(-2048); });
|
|
436
|
+
child.once('error', error => { settled = true; clearTimeout(timer); signal.removeEventListener('abort', abort); reject(error); });
|
|
437
|
+
child.once('close', code => {
|
|
438
|
+
if (settled)
|
|
439
|
+
return;
|
|
440
|
+
clearTimeout(timer);
|
|
441
|
+
signal.removeEventListener('abort', abort);
|
|
442
|
+
if (signal.aborted || code !== 0 || size > maximumOutput)
|
|
443
|
+
reject(new Error(`native bootstrap command failed: ${stderr.slice(-200)}`));
|
|
444
|
+
else
|
|
445
|
+
resolveOutput(Buffer.concat(chunks));
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
async function extractExact(archive, member, cwd, signal) {
|
|
450
|
+
return run('/usr/bin/tar', ['-xOzf', archive, member], cwd, { PATH: '/usr/bin:/bin', LANG: 'C', LC_ALL: 'C', COPYFILE_DISABLE: '1' }, signal, 120_000, 150_000_000);
|
|
451
|
+
}
|
|
452
|
+
async function sourceIdentity(input) {
|
|
453
|
+
const current = await readRsiSourceWorkspace({ dshHome: input.dshHome, profile: input.profile,
|
|
454
|
+
version: input.source.version, ...(input.source.origin.kind === 'local-head' ? { sourceRepository: input.source.origin.locator } : {}),
|
|
455
|
+
...(input.signal ? { signal: input.signal } : {}) });
|
|
456
|
+
if (!isDeepStrictEqual(current, input.source))
|
|
457
|
+
fail('frozen source receipt changed');
|
|
458
|
+
}
|
|
459
|
+
function asEnvironment(receipt) {
|
|
460
|
+
return { schemaVersion: 2, sourceCommit: receipt.sourceCommit, lockSha256: receipt.lockSha256,
|
|
461
|
+
runtime: receipt.runtime, sourceBuild: receipt.sourceBuild };
|
|
462
|
+
}
|
|
463
|
+
async function readExisting(final, input, manifests) {
|
|
464
|
+
await privateDirectory(final);
|
|
465
|
+
if (JSON.stringify((await readdir(final)).sort()) !== JSON.stringify(['bootstrap.json', 'runtime']))
|
|
466
|
+
fail('native runtime is incomplete');
|
|
467
|
+
const receiptPath = join(final, 'bootstrap.json'), receiptInfo = await lstat(receiptPath);
|
|
468
|
+
if (!receiptInfo.isFile() || receiptInfo.isSymbolicLink() || receiptInfo.nlink !== 1 || receiptInfo.size > 4_194_304
|
|
469
|
+
|| (receiptInfo.mode & 0o077) !== 0 || typeof process.getuid === 'function' && receiptInfo.uid !== process.getuid()
|
|
470
|
+
|| await realpath(receiptPath) !== receiptPath)
|
|
471
|
+
fail('native bootstrap receipt is unsafe');
|
|
472
|
+
const descriptor = await open(receiptPath, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
473
|
+
let receipt;
|
|
474
|
+
try {
|
|
475
|
+
const checked = await descriptor.stat();
|
|
476
|
+
if (checked.dev !== receiptInfo.dev || checked.ino !== receiptInfo.ino || checked.size !== receiptInfo.size)
|
|
477
|
+
fail('native bootstrap receipt changed');
|
|
478
|
+
receipt = JSON.parse(await descriptor.readFile({ encoding: 'utf8' }));
|
|
479
|
+
}
|
|
480
|
+
finally {
|
|
481
|
+
await descriptor.close();
|
|
482
|
+
}
|
|
483
|
+
const { receiptDigest, ...content } = receipt;
|
|
484
|
+
const hashes = Object.fromEntries([...manifests].map(([name, bytes]) => [name, sha(bytes)]));
|
|
485
|
+
if (receiptDigest !== sha(JSON.stringify(content)) || receipt.schemaVersion !== 2
|
|
486
|
+
|| receipt.dshHome !== input.dshHome || receipt.profile !== input.profile
|
|
487
|
+
|| receipt.sourceCommit !== input.source.sourceCommit || receipt.lockSha256 !== hashes['pnpm-lock.yaml']
|
|
488
|
+
|| !isDeepStrictEqual(receipt.manifestHashes, hashes)
|
|
489
|
+
|| receipt.nodeArchiveSha256 !== NODE_ARCHIVES[process.arch]
|
|
490
|
+
|| receipt.pnpmArchiveSha256 !== PNPM_ARCHIVE_SHA
|
|
491
|
+
|| receipt.runtime.nodePath !== join(final, 'runtime', 'bin', 'node')
|
|
492
|
+
|| receipt.runtime.modulesPath !== join(final, 'runtime', 'node_modules')
|
|
493
|
+
|| receipt.runtime.roots.length !== 1 || receipt.runtime.roots[0]?.path !== join(final, 'runtime')
|
|
494
|
+
|| !isDeepStrictEqual(receipt.sourceBuild, { backend: 'macos-seatbelt', runtime: receipt.runtime,
|
|
495
|
+
timeoutMs: 60_000, outputBytes: 1_048_576, versioning: 'patch' }))
|
|
496
|
+
fail('native bootstrap receipt differs');
|
|
497
|
+
await verifyNativeMacRuntime(receipt.runtime);
|
|
498
|
+
return asEnvironment(receipt);
|
|
499
|
+
}
|
|
500
|
+
/** Install only committed manifests and their frozen dependencies into a private native runtime. */
|
|
501
|
+
export async function prepareNativeRsiRuntime(input) {
|
|
502
|
+
if (process.platform !== 'darwin' || !['arm64', 'x64'].includes(process.arch))
|
|
503
|
+
fail('native runtime requires macOS');
|
|
504
|
+
if (!canonical(input.dshHome) || !PROFILE.test(input.profile) || input.source.schemaVersion !== 1)
|
|
505
|
+
fail('invalid bootstrap identity');
|
|
506
|
+
await privateDirectory(input.dshHome);
|
|
507
|
+
await sourceIdentity(input);
|
|
508
|
+
const manifests = await frozenManifests(input.source);
|
|
509
|
+
const parent = join(input.dshHome, 'rsi-native-runtimes');
|
|
510
|
+
await mkdir(parent, { mode: 0o700 }).catch(error => { if (error.code !== 'EEXIST')
|
|
511
|
+
throw error; });
|
|
512
|
+
await privateDirectory(parent);
|
|
513
|
+
const final = join(parent, input.profile);
|
|
514
|
+
if (await lstat(final).then(() => true, error => { if (error.code === 'ENOENT')
|
|
515
|
+
return false; throw error; })) {
|
|
516
|
+
return readExisting(final, input, manifests);
|
|
517
|
+
}
|
|
518
|
+
const signal = AbortSignal.any([input.signal ?? new AbortController().signal, AbortSignal.timeout(1_200_000)]);
|
|
519
|
+
const stage = await mkdtemp(join(parent, `.${input.profile}-stage-`));
|
|
520
|
+
await chmod(stage, 0o700);
|
|
521
|
+
try {
|
|
522
|
+
const root = join(stage, 'runtime'), tool = join(stage, 'tool'), cache = join(stage, 'cache');
|
|
523
|
+
for (const directory of [root, tool, cache])
|
|
524
|
+
await mkdir(directory, { mode: 0o700 });
|
|
525
|
+
const nodeArchive = await officialArchive(input.nodeArchivePath, `https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-darwin-${process.arch}.tar.gz`, NODE_ARCHIVES[process.arch], MAX_NODE_ARCHIVE, signal);
|
|
526
|
+
const pnpmArchive = await officialArchive(input.pnpmArchivePath, `https://registry.npmjs.org/pnpm/-/pnpm-${PNPM_VERSION}.tgz`, PNPM_ARCHIVE_SHA, MAX_PNPM_ARCHIVE, signal);
|
|
527
|
+
const nodeArchiveFile = join(stage, 'node.tgz'), pnpmArchiveFile = join(stage, 'pnpm.tgz');
|
|
528
|
+
await writeFile(nodeArchiveFile, nodeArchive, { mode: 0o600 });
|
|
529
|
+
await writeFile(pnpmArchiveFile, pnpmArchive, { mode: 0o600 });
|
|
530
|
+
const bin = join(root, 'bin');
|
|
531
|
+
await mkdir(bin, { mode: 0o700 });
|
|
532
|
+
const nodePath = join(bin, 'node');
|
|
533
|
+
const node = await extractExact(nodeArchiveFile, `node-${NODE_VERSION}-darwin-${process.arch}/bin/node`, stage, signal);
|
|
534
|
+
if (process.arch === 'arm64' && sha(node) !== ARM64_NODE_SHA)
|
|
535
|
+
fail('official Node binary digest differs');
|
|
536
|
+
await writeFile(nodePath, node, { mode: 0o500 });
|
|
537
|
+
await chmod(nodePath, 0o500);
|
|
538
|
+
await run('/usr/bin/tar', ['-xzf', pnpmArchiveFile, '-C', tool], stage, { PATH: '/usr/bin:/bin', LANG: 'C', LC_ALL: 'C', COPYFILE_DISABLE: '1' }, signal, 120_000);
|
|
539
|
+
for (const [name, bytes] of manifests) {
|
|
540
|
+
const path = join(root, name);
|
|
541
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
542
|
+
await writeFile(path, bytes, { mode: 0o600 });
|
|
543
|
+
}
|
|
544
|
+
const env = { PATH: `${bin}:/usr/bin:/bin`, HOME: cache, LANG: 'C', LC_ALL: 'C', CI: 'true',
|
|
545
|
+
npm_config_userconfig: '/dev/null', npm_config_globalconfig: '/dev/null',
|
|
546
|
+
npm_config_registry: 'https://registry.npmjs.org/', npm_config_store_dir: join(stage, 'store'),
|
|
547
|
+
COREPACK_ENABLE_PROJECT_SPEC: '0' };
|
|
548
|
+
await run(nodePath, [join(tool, 'package', 'bin', 'pnpm.mjs'), 'install', '--frozen-lockfile',
|
|
549
|
+
'--ignore-scripts', '--config.package-import-method=copy', '--reporter=append-only'], root, env, signal, 900_000);
|
|
550
|
+
await sourceIdentity(input);
|
|
551
|
+
const fresh = await frozenManifests(input.source);
|
|
552
|
+
if (!isDeepStrictEqual([...fresh], [...manifests]))
|
|
553
|
+
fail('frozen manifest changed during install');
|
|
554
|
+
const modulesPath = join(root, 'node_modules');
|
|
555
|
+
// pnpm links dependencies into the workspace that declares them. Expose the
|
|
556
|
+
// fixed compiler closure at one runtime-local module root for the runner.
|
|
557
|
+
for (const name of ['@deepseek-ai/dsh-tools', '@deepseek-ai/dsh-system-prompt']) {
|
|
558
|
+
const link = join(modulesPath, name);
|
|
559
|
+
if (await lstat(link).then(() => true, error => { if (error.code === 'ENOENT')
|
|
560
|
+
return false; throw error; }))
|
|
561
|
+
continue;
|
|
562
|
+
const candidates = ['plugins/assistant-verifier', 'plugins/assistant-isolation',
|
|
563
|
+
'plugins/plugin-control-plane', 'plugins/lark-channel'].map(workspace => join(root, workspace, 'node_modules', name));
|
|
564
|
+
let target;
|
|
565
|
+
for (const candidate of candidates) {
|
|
566
|
+
const actual = await realpath(candidate).catch(error => { if (error.code === 'ENOENT')
|
|
567
|
+
return undefined; throw error; });
|
|
568
|
+
if (actual && actual.startsWith(`${root}${sep}`)) {
|
|
569
|
+
target = actual;
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (!target)
|
|
574
|
+
fail(`native runtime package missing: ${name}`);
|
|
575
|
+
await mkdir(dirname(link), { recursive: true, mode: 0o700 });
|
|
576
|
+
await symlink(relative(dirname(link), target), link);
|
|
577
|
+
}
|
|
578
|
+
const versions = { node: NODE_VERSION, typescript: '', cordis: '', tools: '', systemPrompt: '' };
|
|
579
|
+
for (const [key, name] of [['typescript', 'typescript'], ['cordis', '@deepseek-ai/cordis'],
|
|
580
|
+
['tools', '@deepseek-ai/dsh-tools'], ['systemPrompt', '@deepseek-ai/dsh-system-prompt']]) {
|
|
581
|
+
const manifest = JSON.parse(await readFile(join(modulesPath, name, 'package.json'), 'utf8'));
|
|
582
|
+
if (!manifest.version)
|
|
583
|
+
fail(`native runtime package missing: ${name}`);
|
|
584
|
+
versions[key] = manifest.version;
|
|
585
|
+
}
|
|
586
|
+
const treeSha = await hashNativeMacRuntimeTree(root);
|
|
587
|
+
const identity = await stat(root);
|
|
588
|
+
const runtime = { schemaVersion: 1, platform: `darwin-${process.arch}`,
|
|
589
|
+
nodePath: join(final, 'runtime', 'bin', 'node'), nodeSha256: sha(node),
|
|
590
|
+
roots: [{ path: join(final, 'runtime'), dev: identity.dev, ino: identity.ino, sha256: treeSha }],
|
|
591
|
+
modulesPath: join(final, 'runtime', 'node_modules'), versions };
|
|
592
|
+
const manifestHashes = Object.fromEntries([...manifests].map(([name, bytes]) => [name, sha(bytes)]));
|
|
593
|
+
const content = { schemaVersion: 2, sourceCommit: input.source.sourceCommit,
|
|
594
|
+
lockSha256: manifestHashes['pnpm-lock.yaml'], runtime,
|
|
595
|
+
sourceBuild: { backend: 'macos-seatbelt', runtime, timeoutMs: 60_000,
|
|
596
|
+
outputBytes: 1_048_576, versioning: 'patch' },
|
|
597
|
+
dshHome: input.dshHome, profile: input.profile, manifestHashes,
|
|
598
|
+
nodeArchiveSha256: NODE_ARCHIVES[process.arch], pnpmArchiveSha256: PNPM_ARCHIVE_SHA };
|
|
599
|
+
await writeFile(join(stage, 'bootstrap.json'), JSON.stringify({ ...content, receiptDigest: sha(JSON.stringify(content)) }), { mode: 0o600 });
|
|
600
|
+
for (const name of ['tool', 'cache', 'store', 'node.tgz', 'pnpm.tgz'])
|
|
601
|
+
await rm(join(stage, name), { recursive: true, force: true });
|
|
602
|
+
await syncDirectory(root);
|
|
603
|
+
await syncDirectory(stage);
|
|
604
|
+
await rename(stage, final);
|
|
605
|
+
await syncDirectory(parent);
|
|
606
|
+
return readExisting(final, input, manifests);
|
|
607
|
+
}
|
|
608
|
+
finally {
|
|
609
|
+
await rm(stage, { recursive: true, force: true });
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
export async function readNativeRsiRuntime(input) {
|
|
613
|
+
if (process.platform !== 'darwin' || !['arm64', 'x64'].includes(process.arch))
|
|
614
|
+
fail('native runtime requires macOS');
|
|
615
|
+
await privateDirectory(input.dshHome);
|
|
616
|
+
await sourceIdentity(input);
|
|
617
|
+
return readExisting(join(input.dshHome, 'rsi-native-runtimes', input.profile), input, await frozenManifests(input.source));
|
|
618
|
+
}
|
|
619
|
+
//# sourceMappingURL=rsi-native-runtime-bootstrap.js.map
|