Download src/plugin-sdk/test-helpers/import-side-effects.ts from SaylorTwift/openclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/plugin-sdk/test-helpers/import-side-effects.ts
- Command line
-
hf download hf://SaylorTwift/openclaw/src/plugin-sdk/test-helpers/import-side-effects.ts
-
curl -L -o import-side-effects.ts https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/plugin-sdk/test-helpers/import-side-effects.ts
1.05 kB
| /** | |
| * Shared assertions for import-time side effect detection. | |
| */ | |
| function formatImportSideEffectCall(args: readonly unknown[]): string { | |
| if (args.length === 0) { | |
| return "(no args)"; | |
| } | |
| return args | |
| .map((arg) => { | |
| try { | |
| return JSON.stringify(arg); | |
| } catch { | |
| return String(arg); | |
| } | |
| }) | |
| .join(", "); | |
| } | |
| export function assertNoImportTimeSideEffects(params: { | |
| moduleId: string; | |
| forbiddenSeam: string; | |
| calls: readonly (readonly unknown[])[]; | |
| why: string; | |
| fixHint: string; | |
| }) { | |
| if (params.calls.length === 0) { | |
| return; | |
| } | |
| const observedCalls = params.calls | |
| .slice(0, 3) | |
| .map((call, index) => ` ${index + 1}. ${formatImportSideEffectCall(call)}`) | |
| .join("\n"); | |
| throw new Error( | |
| [ | |
| `[runtime contract] ${params.moduleId} touched ${params.forbiddenSeam} during module import.`, | |
| `why this is banned: ${params.why}`, | |
| `expected fix: ${params.fixHint}`, | |
| `observed calls (${params.calls.length}):`, | |
| observedCalls, | |
| ].join("\n"), | |
| ); | |
| } | |