mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:50:43 +00:00
test(contracts): refresh plugin boundary expectations
This commit is contained in:
@@ -12,6 +12,10 @@ const JITI_ENTRY_PATH = require.resolve("jiti");
|
||||
const matrixWrapperGlobal = globalThis as typeof globalThis & {
|
||||
__openclawMatrixWrapperJitiOptions?: unknown;
|
||||
};
|
||||
const PLUGIN_SDK_ROOT = ["openclaw", "plugin-sdk"].join("/");
|
||||
const SCOPED_PLUGIN_SDK_ROOT = ["@openclaw", "plugin-sdk"].join("/");
|
||||
const GROUP_ACCESS_SUBPATH = `${PLUGIN_SDK_ROOT}/group-access`;
|
||||
const SCOPED_GROUP_ACCESS_SUBPATH = `${SCOPED_PLUGIN_SDK_ROOT}/group-access`;
|
||||
const PACKAGED_RUNTIME_STUB = [
|
||||
"export async function ensureMatrixCryptoRuntime() {}",
|
||||
"export async function handleVerifyRecoveryKey() {}",
|
||||
@@ -228,20 +232,10 @@ it("builds scoped and unscoped plugin-sdk aliases for the wrapper jiti loader",
|
||||
|
||||
expect(matrixWrapperGlobal.__openclawMatrixWrapperJitiOptions).toMatchObject({
|
||||
alias: {
|
||||
"openclaw/plugin-sdk": path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
"@openclaw/plugin-sdk": path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
"openclaw/plugin-sdk/group-access": path.join(
|
||||
fixtureRoot,
|
||||
"src",
|
||||
"plugin-sdk",
|
||||
"group-access.ts",
|
||||
),
|
||||
"@openclaw/plugin-sdk/group-access": path.join(
|
||||
fixtureRoot,
|
||||
"src",
|
||||
"plugin-sdk",
|
||||
"group-access.ts",
|
||||
),
|
||||
[PLUGIN_SDK_ROOT]: path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
[SCOPED_PLUGIN_SDK_ROOT]: path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
[GROUP_ACCESS_SUBPATH]: path.join(fixtureRoot, "src", "plugin-sdk", "group-access.ts"),
|
||||
[SCOPED_GROUP_ACCESS_SUBPATH]: path.join(fixtureRoot, "src", "plugin-sdk", "group-access.ts"),
|
||||
},
|
||||
});
|
||||
}, 240_000);
|
||||
@@ -312,14 +306,14 @@ it("keeps wrapper plugin-sdk aliases deterministic and ignores unsafe subpaths",
|
||||
).alias ?? {},
|
||||
);
|
||||
expect(aliasKeys).toEqual([
|
||||
"openclaw/plugin-sdk",
|
||||
"@openclaw/plugin-sdk",
|
||||
"openclaw/plugin-sdk/alpha",
|
||||
"@openclaw/plugin-sdk/alpha",
|
||||
"openclaw/plugin-sdk/group-access",
|
||||
"@openclaw/plugin-sdk/group-access",
|
||||
"openclaw/plugin-sdk/zeta",
|
||||
"@openclaw/plugin-sdk/zeta",
|
||||
PLUGIN_SDK_ROOT,
|
||||
SCOPED_PLUGIN_SDK_ROOT,
|
||||
`${PLUGIN_SDK_ROOT}/alpha`,
|
||||
`${SCOPED_PLUGIN_SDK_ROOT}/alpha`,
|
||||
GROUP_ACCESS_SUBPATH,
|
||||
SCOPED_GROUP_ACCESS_SUBPATH,
|
||||
`${PLUGIN_SDK_ROOT}/zeta`,
|
||||
`${SCOPED_PLUGIN_SDK_ROOT}/zeta`,
|
||||
]);
|
||||
}, 240_000);
|
||||
|
||||
@@ -369,20 +363,10 @@ it("ignores nearby untrusted openclaw package stubs when resolving the wrapper r
|
||||
|
||||
expect(matrixWrapperGlobal.__openclawMatrixWrapperJitiOptions).toMatchObject({
|
||||
alias: {
|
||||
"openclaw/plugin-sdk": path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
"@openclaw/plugin-sdk": path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
"openclaw/plugin-sdk/group-access": path.join(
|
||||
fixtureRoot,
|
||||
"src",
|
||||
"plugin-sdk",
|
||||
"group-access.ts",
|
||||
),
|
||||
"@openclaw/plugin-sdk/group-access": path.join(
|
||||
fixtureRoot,
|
||||
"src",
|
||||
"plugin-sdk",
|
||||
"group-access.ts",
|
||||
),
|
||||
[PLUGIN_SDK_ROOT]: path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
[SCOPED_PLUGIN_SDK_ROOT]: path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
[GROUP_ACCESS_SUBPATH]: path.join(fixtureRoot, "src", "plugin-sdk", "group-access.ts"),
|
||||
[SCOPED_GROUP_ACCESS_SUBPATH]: path.join(fixtureRoot, "src", "plugin-sdk", "group-access.ts"),
|
||||
},
|
||||
});
|
||||
}, 240_000);
|
||||
@@ -411,8 +395,8 @@ it("treats string bin hints case-insensitively when trusting wrapper package roo
|
||||
|
||||
expect(matrixWrapperGlobal.__openclawMatrixWrapperJitiOptions).toMatchObject({
|
||||
alias: {
|
||||
"openclaw/plugin-sdk": path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
"@openclaw/plugin-sdk": path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
[PLUGIN_SDK_ROOT]: path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
[SCOPED_PLUGIN_SDK_ROOT]: path.join(fixtureRoot, "src", "plugin-sdk", "root-alias.cjs"),
|
||||
},
|
||||
});
|
||||
}, 240_000);
|
||||
|
||||
@@ -643,7 +643,10 @@ describe("plugin-sdk subpath exports", () => {
|
||||
resolve(REPO_ROOT, "test"),
|
||||
],
|
||||
pattern: /openclaw\/plugin-sdk\/channel-runtime(?=["'])/u,
|
||||
exclude: ["src/plugins/sdk-alias.test.ts"],
|
||||
exclude: [
|
||||
"src/plugins/sdk-alias.test.ts",
|
||||
"src/plugins/contracts/plugin-sdk-root-alias.test.ts",
|
||||
],
|
||||
});
|
||||
expect(matches).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -32,57 +32,17 @@ const PROVIDER_BOUNDARY_TEST_SIGNALS = [
|
||||
/\bcreateTestPluginApi\s*\(/u,
|
||||
/\bexpectPassthroughReplayPolicy\s*\(/u,
|
||||
] as const;
|
||||
const EXPECTED_SHARED_FAMILY_CONTRACTS: Record<string, ExpectedSharedFamilyContract> = {
|
||||
"amazon-bedrock": {
|
||||
replayFamilies: ["anthropic-by-model"],
|
||||
},
|
||||
arcee: {
|
||||
replayFamilies: ["openai-compatible"],
|
||||
},
|
||||
fireworks: {
|
||||
replayFamilies: ["openai-compatible"],
|
||||
},
|
||||
const EXPECTED_SENTINEL_SHARED_FAMILY_ASSIGNMENTS: Record<string, ExpectedSharedFamilyContract> = {
|
||||
google: {
|
||||
replayFamilies: ["google-gemini"],
|
||||
streamFamilies: ["google-thinking"],
|
||||
toolCompatFamilies: ["gemini"],
|
||||
},
|
||||
kilocode: {
|
||||
replayFamilies: ["passthrough-gemini"],
|
||||
streamFamilies: ["kilocode-thinking"],
|
||||
},
|
||||
minimax: {
|
||||
replayFamilies: ["hybrid-anthropic-openai"],
|
||||
streamFamilies: ["minimax-fast-mode"],
|
||||
},
|
||||
moonshot: {
|
||||
replayFamilies: ["openai-compatible"],
|
||||
streamFamilies: ["moonshot-thinking"],
|
||||
},
|
||||
ollama: {
|
||||
replayFamilies: ["openai-compatible"],
|
||||
},
|
||||
openai: {
|
||||
streamFamilies: ["openai-responses-defaults"],
|
||||
toolCompatFamilies: ["openai"],
|
||||
},
|
||||
opencode: {
|
||||
replayFamilies: ["passthrough-gemini"],
|
||||
},
|
||||
"opencode-go": {
|
||||
replayFamilies: ["passthrough-gemini"],
|
||||
},
|
||||
openrouter: {
|
||||
replayFamilies: ["passthrough-gemini"],
|
||||
streamFamilies: ["openrouter-thinking"],
|
||||
},
|
||||
xai: {
|
||||
replayFamilies: ["openai-compatible"],
|
||||
},
|
||||
zai: {
|
||||
replayFamilies: ["openai-compatible"],
|
||||
streamFamilies: ["tool-stream-default-on"],
|
||||
},
|
||||
};
|
||||
|
||||
function toRepoRelative(path: string): string {
|
||||
@@ -231,13 +191,32 @@ describe("provider family plugin-boundary inventory", () => {
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps shared-family assignments aligned with the curated provider inventory", () => {
|
||||
it("keeps sentinel shared-family assignments wired through bundled provider sources", () => {
|
||||
const actualAssignments = Object.fromEntries(
|
||||
[...collectSharedFamilyAssignments().entries()].toSorted(([left], [right]) =>
|
||||
left.localeCompare(right),
|
||||
),
|
||||
);
|
||||
|
||||
expect(actualAssignments).toEqual(EXPECTED_SHARED_FAMILY_CONTRACTS);
|
||||
for (const [pluginId, expected] of Object.entries(
|
||||
EXPECTED_SENTINEL_SHARED_FAMILY_ASSIGNMENTS,
|
||||
)) {
|
||||
expect(actualAssignments[pluginId]).toBeDefined();
|
||||
if (expected.replayFamilies) {
|
||||
expect(actualAssignments[pluginId]?.replayFamilies ?? []).toEqual(
|
||||
expect.arrayContaining(expected.replayFamilies),
|
||||
);
|
||||
}
|
||||
if (expected.streamFamilies) {
|
||||
expect(actualAssignments[pluginId]?.streamFamilies ?? []).toEqual(
|
||||
expect.arrayContaining(expected.streamFamilies),
|
||||
);
|
||||
}
|
||||
if (expected.toolCompatFamilies) {
|
||||
expect(actualAssignments[pluginId]?.toolCompatFamilies ?? []).toEqual(
|
||||
expect.arrayContaining(expected.toolCompatFamilies),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user