


























@@ -25,6 +25,7 @@ import {
2525type ClawHubPackageCompatibility,
2626type ClawHubPackageDetail,
2727type ClawHubPackageFamily,
28+type ClawHubPackageStorePackSummary,
2829type ClawHubPackageVersion,
2930} from "../infra/clawhub.js";
3031import { formatErrorMessage } from "../infra/errors.js";
@@ -65,6 +66,10 @@ export type ClawHubPluginInstallRecordFields = {
6566integrity?: string;
6667resolvedAt?: string;
6768installedAt?: string;
69+storepackSha256?: string;
70+storepackSpecVersion?: number;
71+storepackManifestSha256?: string;
72+storepackSize?: number;
6873};
69747075type ClawHubInstallFailure = {
@@ -122,6 +127,41 @@ type ClawHubArchiveEntryLimits = {
122127addArchiveBytes: (bytes: number) => boolean;
123128};
124129130+function normalizeClawHubStorePackInstallFields(
131+storepack: ClawHubPackageStorePackSummary | null | undefined,
132+): Pick<
133+ClawHubPluginInstallRecordFields,
134+"storepackSha256" | "storepackSpecVersion" | "storepackManifestSha256" | "storepackSize"
135+> {
136+if (storepack?.available !== true) {
137+return {};
138+}
139+const storepackSha256 =
140+typeof storepack.sha256 === "string" ? normalizeClawHubSha256Hex(storepack.sha256) : null;
141+const storepackManifestSha256 =
142+typeof storepack.manifestSha256 === "string"
143+ ? normalizeClawHubSha256Hex(storepack.manifestSha256)
144+ : null;
145+const storepackSpecVersion =
146+typeof storepack.specVersion === "number" &&
147+Number.isSafeInteger(storepack.specVersion) &&
148+storepack.specVersion >= 0
149+ ? storepack.specVersion
150+ : undefined;
151+const storepackSize =
152+typeof storepack.size === "number" &&
153+Number.isSafeInteger(storepack.size) &&
154+storepack.size >= 0
155+ ? storepack.size
156+ : undefined;
157+return {
158+ ...(storepackSha256 ? { storepackSha256 } : {}),
159+ ...(storepackSpecVersion !== undefined ? { storepackSpecVersion } : {}),
160+ ...(storepackManifestSha256 ? { storepackManifestSha256 } : {}),
161+ ...(storepackSize !== undefined ? { storepackSize } : {}),
162+};
163+}
164+125165export function formatClawHubSpecifier(params: { name: string; version?: string }): string {
126166return `clawhub:${params.name}${params.version ? `@${params.version}` : ""}`;
127167}
@@ -601,6 +641,7 @@ async function resolveCompatiblePackageVersion(params: {
601641version: string;
602642compatibility?: ClawHubPackageCompatibility | null;
603643verification: ClawHubArchiveVerification | null;
644+storepack?: ClawHubPackageStorePackSummary | null;
604645}
605646| ClawHubInstallFailure
606647> {
@@ -635,6 +676,7 @@ async function resolveCompatiblePackageVersion(params: {
635676compatibility:
636677versionDetail.version?.compatibility ?? params.detail.package?.compatibility ?? null,
637678verification: null,
679+storepack: versionDetail.version?.storepack ?? params.detail.package?.storepack ?? null,
638680};
639681}
640682const verificationState = resolveClawHubArchiveVerification(
@@ -651,6 +693,7 @@ async function resolveCompatiblePackageVersion(params: {
651693compatibility:
652694versionDetail.version?.compatibility ?? params.detail.package?.compatibility ?? null,
653695verification: verificationState.verification,
696+storepack: versionDetail.version?.storepack ?? params.detail.package?.storepack ?? null,
654697};
655698}
656699@@ -879,6 +922,7 @@ export async function installPluginFromClawHub(
879922}
880923881924const pkg = detail.package!;
925+const storepackFields = normalizeClawHubStorePackInstallFields(versionState.storepack);
882926const clawhubFamily =
883927pkg.family === "code-plugin" || pkg.family === "bundle-plugin" ? pkg.family : null;
884928if (!clawhubFamily) {
@@ -904,6 +948,7 @@ export async function installPluginFromClawHub(
904948// server-attested sha256hash from ClawHub version metadata.
905949integrity: archive.integrity,
906950resolvedAt: new Date().toISOString(),
951+ ...storepackFields,
907952},
908953};
909954} finally {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。