@@ -16,6 +16,7 @@ import {
1616 CompanySubscriptionInfoRO ,
1717 PermissionAllowedRO ,
1818 PublicPermissionsRO ,
19+ SiteRuntimePolicyRO ,
1920 ValidatedUserTokenRO ,
2021} from './data-structures/agents-responses.ds.js' ;
2122import {
@@ -28,6 +29,7 @@ import {
2829import { ValidateConnectionEditDto , ValidateTableAiRequestDto , ValidateUserTokenDto } from './dto/agents-auth.dtos.js' ;
2930import { GetCompanySubscriptionInfoDto } from './dto/agents-company.dtos.js' ;
3031import { SetAgentsPublicPermissionsDto } from './dto/agents-public-permissions.dtos.js' ;
32+ import { SetSiteRuntimePolicyDto } from './dto/agents-site-runtime-policy.dtos.js' ;
3133import {
3234 IExecuteAiAggregationPipeline ,
3335 IExecuteAiRawQuery ,
@@ -38,6 +40,7 @@ import {
3840 IGetCompanySubscriptionInfo ,
3941 IScanAndCreateSettings ,
4042 ISetPublicPermissions ,
43+ ISetSiteRuntimePolicy ,
4144 IValidateConnectionEdit ,
4245 IValidateTableAiRequest ,
4346 IValidateUserToken ,
@@ -59,6 +62,8 @@ export class AgentsController {
5962 private readonly validateConnectionEditUseCase : IValidateConnectionEdit ,
6063 @Inject ( UseCaseType . AGENTS_SET_PUBLIC_PERMISSIONS )
6164 private readonly setPublicPermissionsUseCase : ISetPublicPermissions ,
65+ @Inject ( UseCaseType . AGENTS_SET_SITE_RUNTIME_POLICY )
66+ private readonly setSiteRuntimePolicyUseCase : ISetSiteRuntimePolicy ,
6267 @Inject ( UseCaseType . AGENTS_GET_AI_CONNECTION_CONTEXT )
6368 private readonly getAiConnectionContextUseCase : IGetAiConnectionContext ,
6469 @Inject ( UseCaseType . AGENTS_GET_AI_CONNECTION_TABLES )
@@ -127,6 +132,26 @@ export class AgentsController {
127132 ) ;
128133 }
129134
135+ @ApiOperation ( {
136+ summary : 'Write the site data contract (runtime manifest) for a generated site — agent finalize flow' ,
137+ description :
138+ 'Re-checks Cedar connection:edit for the given user, then stores the manifest on the connection ' +
139+ '(site_runtime_policy, replacing any previous one). universal-backend enforces it at the generated-site ' +
140+ 'runtime: auth-table pinning, write allow-lists with ownership, owner-scoped reads (plan 13 Step 2b).' ,
141+ } )
142+ @ApiResponse ( { status : 201 , type : SiteRuntimePolicyRO } )
143+ @ApiBody ( { type : SetSiteRuntimePolicyDto } )
144+ @Post ( '/connection/site-runtime-policy/:connectionId' )
145+ public async setSiteRuntimePolicy (
146+ @SlugUuid ( 'connectionId' ) connectionId : string ,
147+ @Body ( ) body : SetSiteRuntimePolicyDto ,
148+ ) : Promise < SiteRuntimePolicyRO > {
149+ return await this . setSiteRuntimePolicyUseCase . execute (
150+ { connectionId, userId : body . userId , policy : body . policy } ,
151+ InTransactionEnum . OFF ,
152+ ) ;
153+ }
154+
130155 @ApiOperation ( { summary : 'Get AI-relevant connection context (type, schema, MongoDB flag)' } )
131156 @ApiResponse ( { status : 201 , type : AiConnectionContextRO } )
132157 @ApiBody ( { type : AiDataRequestBaseDto } )
0 commit comments