@@ -262,7 +262,7 @@ function addManagerRoutes(
262262 path : "/actors" ,
263263 request : {
264264 query : z . object ( {
265- name : z . string ( ) ,
265+ name : z . string ( ) . optional ( ) ,
266266 actor_ids : z . string ( ) . optional ( ) ,
267267 key : z . string ( ) . optional ( ) ,
268268 } ) ,
@@ -282,6 +282,37 @@ function addManagerRoutes(
282282
283283 const actors : ActorOutput [ ] = [ ] ;
284284
285+ // Validate: cannot provide both actor_ids and (name or key)
286+ if ( actorIdsParsed && ( name || key ) ) {
287+ return c . json (
288+ {
289+ error :
290+ "Cannot provide both actor_ids and (name + key). Use either actor_ids or (name + key)." ,
291+ } ,
292+ 400 ,
293+ ) ;
294+ }
295+
296+ // Validate: when key is provided, name must also be provided
297+ if ( key && ! name ) {
298+ return c . json (
299+ {
300+ error : "When providing 'key', 'name' must also be provided." ,
301+ } ,
302+ 400 ,
303+ ) ;
304+ }
305+
306+ // Validate: must provide either actor_ids or (name + key)
307+ if ( ! actorIdsParsed && ! key ) {
308+ return c . json (
309+ {
310+ error : "Must provide either 'actor_ids' or both 'name' and 'key'." ,
311+ } ,
312+ 400 ,
313+ ) ;
314+ }
315+
285316 if ( actorIdsParsed ) {
286317 if ( actorIdsParsed . length > 32 ) {
287318 return c . json (
@@ -298,8 +329,10 @@ function addManagerRoutes(
298329 } ) ;
299330 }
300331
332+ // Fetch actors by ID
301333 for ( const actorId of actorIdsParsed ) {
302334 if ( name ) {
335+ // If name is provided, use it directly
303336 const actorOutput = await managerDriver . getForId ( {
304337 c,
305338 name,
@@ -308,12 +341,27 @@ function addManagerRoutes(
308341 if ( actorOutput ) {
309342 actors . push ( actorOutput ) ;
310343 }
344+ } else {
345+ // If no name is provided, try all registered actor types
346+ // Actor IDs are globally unique, so we'll find it in one of them
347+ for ( const actorName of Object . keys ( registryConfig . use ) ) {
348+ const actorOutput = await managerDriver . getForId ( {
349+ c,
350+ name : actorName ,
351+ actorId,
352+ } ) ;
353+ if ( actorOutput ) {
354+ actors . push ( actorOutput ) ;
355+ break ; // Found the actor, no need to check other names
356+ }
357+ }
311358 }
312359 }
313360 } else if ( key ) {
361+ // At this point, name is guaranteed to be defined due to validation above
314362 const actorOutput = await managerDriver . getWithKey ( {
315363 c,
316- name,
364+ name : name ! ,
317365 key : [ key ] , // Convert string to ActorKey array
318366 } ) ;
319367 if ( actorOutput ) {
0 commit comments