@@ -41,6 +41,7 @@ const AGC_URL = (
4141
4242type ComputerRequestBody = {
4343 agentCommonsId ?: string ;
44+ agentCommonsApiUrl ?: string | null ;
4445 ownerUserId ?: string | null ;
4546 workspaceId ?: string | null ;
4647 computerId ?: string ;
@@ -65,6 +66,21 @@ type ComputerRequestBody = {
6566 } ;
6667} ;
6768
69+ function agentCommonsApiUrl ( c : any , value : string | null | undefined ) : string {
70+ if ( c . get ( "authType" ) !== "service" || ! value ?. trim ( ) ) return AGC_URL ;
71+ const url = new URL ( value . trim ( ) ) ;
72+ if (
73+ url . protocol !== "https:" ||
74+ url . username ||
75+ url . password ||
76+ url . search ||
77+ url . hash
78+ ) {
79+ throw new Error ( "agentCommonsApiUrl must be an HTTPS API origin" ) ;
80+ }
81+ return url . origin ;
82+ }
83+
6884function runtimeRequest ( body : ComputerRequestBody ) {
6985 const integrationPath = body . integrationPath ?? "native" ;
7086 if ( ! [ "native" , "openclaw" , "hermes" , "guest" ] . includes ( integrationPath ) ) {
@@ -433,6 +449,7 @@ router.post("/", async (c) => {
433449 if ( "response" in verified ) return verified . response ;
434450
435451 try {
452+ const commonsApiUrl = agentCommonsApiUrl ( c , body . agentCommonsApiUrl ) ;
436453 const runtime = runtimeRequest ( body ) ;
437454 const tenant = await ensureCanonicalComputerTenant ( verified . owner ) ;
438455 const fleet = await ensureTenantComputerFleet ( {
@@ -462,12 +479,14 @@ router.post("/", async (c) => {
462479 fleetId : fleet . _id ,
463480 "compute.ownerUserId" : verified . owner . ownerUserId ,
464481 "compute.workspaceId" : verified . owner . workspaceId ,
482+ "commons.apiUrl" : commonsApiUrl ,
465483 updatedAt : new Date ( ) ,
466484 } ,
467485 }
468486 ) ;
469487 existing = {
470488 ...existing ,
489+ commons : { ...existing . commons , apiUrl : commonsApiUrl } ,
471490 tenantId : tenant . _id ,
472491 fleetId : fleet . _id ,
473492 compute : existing . compute
@@ -567,6 +586,7 @@ router.post("/", async (c) => {
567586 "config.nativeConfig" : updated . config . nativeConfig ,
568587 "config.openclawConfig" : updated . config . openclawConfig ,
569588 "config.hermesConfig" : updated . config . hermesConfig ,
589+ "commons.apiUrl" : commonsApiUrl ,
570590 resourceProfile : updated . resourceProfile ,
571591 resourceMode : updated . resourceMode ,
572592 resourceSpec : updated . resourceSpec ,
@@ -621,6 +641,7 @@ router.post("/", async (c) => {
621641 userId : verified . owner . ownerUserId ,
622642 workspaceId : verified . owner . workspaceId ?? undefined ,
623643 existingCommonsAgentId : agentCommonsId ,
644+ agentCommonsApiUrl : commonsApiUrl ,
624645 fleet,
625646 role,
626647 systemPrompt :
0 commit comments