@@ -11,6 +11,22 @@ const EXTENSION_PACKAGE_BOUNDARY_PATHS_CONFIG =
1111 "extensions/tsconfig.package-boundary.paths.json" as const ;
1212const EXTENSION_PACKAGE_BOUNDARY_BASE_CONFIG =
1313 "extensions/tsconfig.package-boundary.base.json" as const ;
14+ const XAI_OMITTED_BOUNDARY_PATHS = {
15+ "openclaw/plugin-sdk/channel-secret-basic-runtime" : [
16+ "../dist/plugin-sdk/channel-secret-basic-runtime.d.ts" ,
17+ ] ,
18+ "openclaw/plugin-sdk/channel-secret-owner-runtime" : [
19+ "../packages/plugin-sdk/dist/src/plugin-sdk/channel-secret-owner-runtime.d.ts" ,
20+ ] ,
21+ "openclaw/plugin-sdk/channel-secret-tts-runtime" : [
22+ "../packages/plugin-sdk/dist/src/plugin-sdk/channel-secret-tts-runtime.d.ts" ,
23+ ] ,
24+ "@openclaw/matrix/test-api.js" : [ "../dist/plugin-sdk/extensions/matrix/test-api.d.ts" ] ,
25+ "@openclaw/discord/api.js" : [ "../dist/plugin-sdk/extensions/discord/api.d.ts" ] ,
26+ "@openclaw/slack/api.js" : [ "../dist/plugin-sdk/extensions/slack/api.d.ts" ] ,
27+ "@openclaw/telegram/api.js" : [ "../dist/plugin-sdk/extensions/telegram/api.d.ts" ] ,
28+ "@openclaw/whatsapp/api.js" : [ "../dist/plugin-sdk/extensions/whatsapp/api.d.ts" ] ,
29+ } as const ;
1430const trackedCodeFilesByRoot = new Map < string , readonly string [ ] | null > ( ) ;
1531
1632type TsConfigJson = {
@@ -71,6 +87,11 @@ function readExtensionTsconfig(extensionName: string): TsConfigJson {
7187 return readJsonFile < TsConfigJson > ( `extensions/${ extensionName } /tsconfig.json` ) ;
7288}
7389
90+ function isContainedPackageBoundaryTarget ( target : string ) : boolean {
91+ const root = / ^ \. \. \/ ( d i s t | p a c k a g e s | e x t e n s i o n s ) \/ / u. exec ( target ) ?. [ 1 ] ;
92+ return root !== undefined && posix . normalize ( target ) . startsWith ( `../${ root } /` ) ;
93+ }
94+
7495function collectExtensionsWithTsconfig ( ) : string [ ] {
7596 return fs
7697 . readdirSync ( resolve ( REPO_ROOT , "extensions" ) , { withFileTypes : true } )
@@ -158,6 +179,9 @@ describe("opt-in extension package boundaries", () => {
158179 throw new Error ( "Missing shared extension package boundary aliases" ) ;
159180 }
160181 expect ( paths [ "openclaw/plugin-sdk/*" ] ) . toEqual ( [ "../dist/plugin-sdk/*.d.ts" ] ) ;
182+ for ( const [ specifier , targets ] of Object . entries ( XAI_OMITTED_BOUNDARY_PATHS ) ) {
183+ expect ( paths [ specifier ] , specifier ) . toEqual ( targets ) ;
184+ }
161185 for ( const entrypoint of privateLocalOnlyPluginSdkEntrypoints ) {
162186 expect ( paths [ `openclaw/plugin-sdk/${ entrypoint } ` ] , entrypoint ) . toEqual ( [
163187 `../packages/plugin-sdk/dist/src/plugin-sdk/${ entrypoint } .d.ts` ,
@@ -180,7 +204,7 @@ describe("opt-in extension package boundaries", () => {
180204 for ( const [ specifier , targets ] of Object . entries ( paths ) ) {
181205 expect ( targets . length , specifier ) . toBeGreaterThan ( 0 ) ;
182206 for ( const target of targets ) {
183- expect ( target , specifier ) . toMatch ( / ^ \. \. \/ (?: d i s t | p a c k a g e s | e x t e n s i o n s ) \/ / u ) ;
207+ expect ( isContainedPackageBoundaryTarget ( target ) , specifier ) . toBe ( true ) ;
184208 }
185209 }
186210
@@ -202,6 +226,16 @@ describe("opt-in extension package boundaries", () => {
202226 ] ) ;
203227 } ) ;
204228
229+ it ( "rejects package aliases that escape their declared declaration root" , ( ) => {
230+ for ( const target of [
231+ "../dist/../src/gateway/auth.ts" ,
232+ "../packages/../../src/gateway/auth.ts" ,
233+ "../extensions/../src/gateway/auth.ts" ,
234+ ] ) {
235+ expect ( isContainedPackageBoundaryTarget ( target ) , target ) . toBe ( false ) ;
236+ }
237+ } ) ;
238+
205239 it ( "keeps every opt-in extension rooted inside its package and on the package sdk" , ( ) => {
206240 for ( const extensionName of collectExtensionsWithTsconfig ( ) ) {
207241 const tsconfig = readExtensionTsconfig ( extensionName ) ;
@@ -230,16 +264,7 @@ describe("opt-in extension package boundaries", () => {
230264 if ( ! paths ) {
231265 throw new Error ( "Missing shared extension package boundary aliases" ) ;
232266 }
233- const omitted = new Set ( [
234- "openclaw/plugin-sdk/channel-secret-basic-runtime" ,
235- "openclaw/plugin-sdk/channel-secret-owner-runtime" ,
236- "openclaw/plugin-sdk/channel-secret-tts-runtime" ,
237- "@openclaw/matrix/test-api.js" ,
238- "@openclaw/discord/api.js" ,
239- "@openclaw/slack/api.js" ,
240- "@openclaw/telegram/api.js" ,
241- "@openclaw/whatsapp/api.js" ,
242- ] ) ;
267+ const omitted = new Set ( Object . keys ( XAI_OMITTED_BOUNDARY_PATHS ) ) ;
243268 const expectedPaths = Object . fromEntries (
244269 Object . entries ( paths )
245270 . filter ( ( [ specifier ] ) => ! omitted . has ( specifier ) )
0 commit comments