mirror of
https://github.com/bitbaum/openclaw.git
synced 2026-12-04 08:47:47 +01:00
* fix(sessions): preserve participant identity and input provenance Keep profile, agent, remote, observed, and legacy identities distinct in the existing participant table. Record accepted input at admission, including steering, instead of inferring a person from the session creator. Preserve historical membership and counts while leaving ambiguous profile timestamps unknown through stopped-writer Doctor migration. Project full visibility-filtered person membership before preview limits so Activity does not misattribute channel identities or omit people outside the facepile. Keep participant membership separate from authorization and expose raw-selector ambiguity to memory operators. Repair Doctor readiness reporting, generic Swift inline-union generation, direct-dispatch metadata handling, and fixture-owned database lifetimes. Verify namespace collisions, real provider input, accepted steering, visibility, backup/migration/reopen boundaries, native decoding, and the built-CLI lifecycle. Fixes #130661 * fix(macos): isolate readiness and discovery lifecycles Keep readiness fixtures private for their entire lifetime and give health readiness one deadline owner. Start and cancel slow host discovery with active discovery, not model construction. Make native protocol, callback, onboarding, and process-cleanup tests observe their intended lifecycle phases without expanding deadlines or weakening assertions. Correct the documented signing default. Validated with 1,839 parallel native tests, the release product build, causal negative controls, pinned Swift lint/format checks, and fresh isolated autoreview. Native production delta: -5 lines. * docs(macos): clarify app profile isolation boundaries * build(protocol): refresh generated Swift install models * fix(protocol): preserve optional literal field presence * fix(ci): bound SDK declarations and isolate test lifecycles Discover the current declaration source graph in a joined child before normal eager emission, and track its complete source-bearing cache inputs. Repair shared jsdom focus teardown and native worker fixture request ordering without changing UI focus ownership or execution fallback policy. * test(sessions): prove Goal participant upgrade boundaries
128 lines
4.6 KiB
TypeScript
128 lines
4.6 KiB
TypeScript
// Write Plugin Sdk Entry Dts script supports OpenClaw repository automation.
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { build } from "tsdown";
|
|
import { discoverDeclarationSources } from "./lib/declaration-source-index.mts";
|
|
import {
|
|
buildPluginSdkEntrySources,
|
|
listPluginSdkDeclarationOutputs,
|
|
pluginSdkEntrypoints,
|
|
productionPluginSdkEntrypoints,
|
|
} from "./lib/plugin-sdk-entries.mts";
|
|
|
|
const USE_CANONICAL_DECLARATIONS = process.env.OPENCLAW_PLUGIN_SDK_CANONICAL_DTS === "1";
|
|
|
|
function isBareImportSpecifier(id: string): boolean {
|
|
if (
|
|
id === "@openclaw/llm-core" ||
|
|
id.startsWith("@openclaw/llm-core/") ||
|
|
id === "@openclaw/model-catalog-core/model-catalog-types" ||
|
|
id === "@openclaw/retry" ||
|
|
id.startsWith("@openclaw/normalization-core/") ||
|
|
id.startsWith("@openclaw/media-core/") ||
|
|
id.startsWith("@openclaw/acp-core/")
|
|
) {
|
|
return false;
|
|
}
|
|
return !id.startsWith(".") && !id.startsWith("/") && !/^[A-Za-z]:[\\/]/u.test(id);
|
|
}
|
|
|
|
function removeExistingFlatDeclarations(outDir: string): void {
|
|
if (!fs.existsSync(outDir)) {
|
|
return;
|
|
}
|
|
for (const entry of fs.readdirSync(outDir, { withFileTypes: true })) {
|
|
if (!entry.isFile() || !entry.name.endsWith(".d.ts")) {
|
|
continue;
|
|
}
|
|
fs.rmSync(path.join(outDir, entry.name), { force: true });
|
|
}
|
|
}
|
|
|
|
function copyFlatDeclarations(fromDir: string, toDir: string): void {
|
|
fs.mkdirSync(toDir, { recursive: true });
|
|
for (const entry of fs.readdirSync(fromDir, { withFileTypes: true })) {
|
|
if (!entry.isFile() || !entry.name.endsWith(".d.ts")) {
|
|
continue;
|
|
}
|
|
fs.copyFileSync(path.join(fromDir, entry.name), path.join(toDir, entry.name));
|
|
}
|
|
}
|
|
|
|
const distPluginSdkDir = path.join(process.cwd(), "dist/plugin-sdk");
|
|
const shouldBuildPrivateQaEntries = process.env.OPENCLAW_BUILD_PRIVATE_QA === "1";
|
|
const flatDeclarationEntrypoints = shouldBuildPrivateQaEntries
|
|
? pluginSdkEntrypoints
|
|
: productionPluginSdkEntrypoints;
|
|
const flatDeclarationEntrypointSet = new Set(flatDeclarationEntrypoints);
|
|
|
|
if (USE_CANONICAL_DECLARATIONS) {
|
|
for (const relativePath of listPluginSdkDeclarationOutputs(flatDeclarationEntrypoints)) {
|
|
const declarationPath = path.resolve(process.cwd(), relativePath);
|
|
if (!fs.existsSync(declarationPath)) {
|
|
throw new Error(
|
|
`Missing canonical plugin SDK declaration: ${path.relative(process.cwd(), declarationPath)}`,
|
|
);
|
|
}
|
|
}
|
|
} else {
|
|
const flatDeclarationTempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-sdk-dts-"));
|
|
try {
|
|
const entry = buildPluginSdkEntrySources(flatDeclarationEntrypoints);
|
|
const tsconfig = "tsconfig.plugin-sdk.dts.json";
|
|
const files = discoverDeclarationSources(tsconfig, Object.values(entry));
|
|
await build({
|
|
clean: true,
|
|
config: false,
|
|
deps: { neverBundle: (id) => isBareImportSpecifier(id) },
|
|
// Eager reuse checks source root membership, including transitive emit requests.
|
|
dts: { emitDtsOnly: true, eager: true, tsconfigRaw: { files, include: [] } },
|
|
entry,
|
|
failOnWarn: false,
|
|
fixedExtension: false,
|
|
format: "esm",
|
|
logLevel: "error",
|
|
outDir: flatDeclarationTempDir,
|
|
outExtensions: () => ({ js: ".js", dts: ".d.ts" }),
|
|
platform: "node",
|
|
report: false,
|
|
tsconfig,
|
|
});
|
|
|
|
for (const name of flatDeclarationEntrypoints) {
|
|
if (!fs.existsSync(path.join(flatDeclarationTempDir, `${name}.d.ts`))) {
|
|
throw new Error(`Missing plugin SDK declaration: ${name}.d.ts`);
|
|
}
|
|
}
|
|
removeExistingFlatDeclarations(distPluginSdkDir);
|
|
copyFlatDeclarations(flatDeclarationTempDir, distPluginSdkDir);
|
|
} finally {
|
|
fs.rmSync(flatDeclarationTempDir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
// The root npm package ships flat bundled declarations under `dist/plugin-sdk`.
|
|
// The private workspace package keeps source-shaped declaration paths for local
|
|
// package-boundary projects, so bridge them back to the packaged flat entries.
|
|
for (const entry of pluginSdkEntrypoints) {
|
|
if (!flatDeclarationEntrypointSet.has(entry)) {
|
|
continue;
|
|
}
|
|
|
|
const packageTypeOut = path.join(
|
|
process.cwd(),
|
|
`packages/plugin-sdk/dist/src/plugin-sdk/${entry}.d.ts`,
|
|
);
|
|
fs.mkdirSync(path.dirname(packageTypeOut), { recursive: true });
|
|
fs.writeFileSync(
|
|
packageTypeOut,
|
|
`export * from "../../../../../dist/plugin-sdk/${entry}.js";\n`,
|
|
"utf8",
|
|
);
|
|
}
|
|
|
|
const stampPath = path.join(process.cwd(), "dist/plugin-sdk/.boundary-entry-shims.stamp");
|
|
fs.mkdirSync(path.dirname(stampPath), { recursive: true });
|
|
fs.writeFileSync(stampPath, `${new Date().toISOString()}\n`, "utf8");
|