@@ -10,6 +10,10 @@ export type IdentitySource =
1010 | { type : "inline" ; manifest : Record < string , unknown > ; files ?: Record < string , string > } ;
1111
1212export interface Agent {
13+ /** Registry surrogate key (Mongo ObjectId, stringified). The public/API
14+ * identifier — routes are `/agents/:id` and all agent-scoped calls pass it.
15+ * `name` is the human label/FK; never use it as the addressing key. */
16+ id : string ;
1317 name : string ;
1418 label : string ;
1519 harness : string ;
@@ -207,7 +211,7 @@ export interface Schedule {
207211 lastResult ?: string | null ;
208212}
209213export interface NewSchedule {
210- agentName : string ;
214+ agentId : string ;
211215 prompt : string ;
212216 kind : "interval" | "daily" ;
213217 intervalMinutes ?: number ;
@@ -336,35 +340,35 @@ export interface EvalRun {
336340export const api = {
337341 agents : ( ) => getJSON < { agents : Agent [ ] } > ( "/agents" ) . then ( ( d ) => d . agents ) ,
338342 registerAgent : ( input : RegisterAgentInput ) =>
339- postJSON < { ok : boolean ; name : string } > ( "/agents/register" , input ) ,
340- unregisterAgent : ( name : string ) =>
341- reqJSON < DeleteResult > ( "DELETE" , `/agents/${ encodeURIComponent ( name ) } ` ) ,
342- patchAgent : ( name : string , fields : Partial < Omit < RegisterAgentInput , "name" > > ) =>
343- reqJSON < { ok : boolean } > ( "PATCH" , `/agents/${ encodeURIComponent ( name ) } ` , fields ) ,
344- logs : ( bot ?: string , limit = 100 ) =>
345- getJSON < { logs : LogEntry [ ] } > ( `/logs?limit=${ limit } ${ bot ? `&bot =${ encodeURIComponent ( bot ) } ` : "" } ` ) . then ( ( d ) => d . logs ) ,
346- sessions : ( bot ?: string , limit = 100 ) =>
347- getJSON < { sessions : SessionSummary [ ] } > ( `/sessions?limit=${ limit } ${ bot ? `&bot =${ encodeURIComponent ( bot ) } ` : "" } ` ) . then ( ( d ) => d . sessions ) ,
343+ postJSON < { ok : boolean ; id : string ; name : string } > ( "/agents/register" , input ) ,
344+ unregisterAgent : ( agentId : string ) =>
345+ reqJSON < DeleteResult > ( "DELETE" , `/agents/${ encodeURIComponent ( agentId ) } ` ) ,
346+ patchAgent : ( agentId : string , fields : Partial < Omit < RegisterAgentInput , "name" > > ) =>
347+ reqJSON < { ok : boolean } > ( "PATCH" , `/agents/${ encodeURIComponent ( agentId ) } ` , fields ) ,
348+ logs : ( agentId ?: string , limit = 100 ) =>
349+ getJSON < { logs : LogEntry [ ] } > ( `/logs?limit=${ limit } ${ agentId ? `&agentId =${ encodeURIComponent ( agentId ) } ` : "" } ` ) . then ( ( d ) => d . logs ) ,
350+ sessions : ( agentId ?: string , limit = 100 ) =>
351+ getJSON < { sessions : SessionSummary [ ] } > ( `/sessions?limit=${ limit } ${ agentId ? `&agentId =${ encodeURIComponent ( agentId ) } ` : "" } ` ) . then ( ( d ) => d . sessions ) ,
348352 session : ( id : string ) => getJSON < SessionDetail > ( `/sessions/${ encodeURIComponent ( id ) } ` ) ,
349- deleteSession : ( id : string , bot ?: string ) =>
353+ deleteSession : ( id : string , agentId ?: string ) =>
350354 reqJSON < DeleteResult > (
351355 "DELETE" ,
352- `/sessions/${ encodeURIComponent ( id ) } ${ bot ? `?bot =${ encodeURIComponent ( bot ) } ` : "" } ` ,
356+ `/sessions/${ encodeURIComponent ( id ) } ${ agentId ? `?agentId =${ encodeURIComponent ( agentId ) } ` : "" } ` ,
353357 ) ,
354- chatSandbox : ( agent : string , opts ?: { sessionId ?: string ; forceNew ?: boolean } ) =>
358+ chatSandbox : ( agentId : string , opts ?: { sessionId ?: string ; forceNew ?: boolean } ) =>
355359 postJSON < { sandboxId : string ; sessionId : string ; bot : string } > (
356- `/agents/${ encodeURIComponent ( agent ) } /chat-sandbox` ,
360+ `/agents/${ encodeURIComponent ( agentId ) } /chat-sandbox` ,
357361 opts ?. sessionId ? { sessionId : opts . sessionId } : opts ?. forceNew ? { forceNew : true } : { } ,
358362 ) ,
359363 logWebTurn : ( entry : { bot : string ; sessionId : string ; query : string ; reply : string ; ok : boolean } ) =>
360364 postJSON < { ok : boolean } > ( "/logs" , { ...entry , requester : "web" } ) ,
361365 // SSE chat — caller reads the stream. Path goes through the same /api proxy.
362366 chatStreamUrl : ( sandboxId : string ) => `/api/sandboxes/${ encodeURIComponent ( sandboxId ) } /chat` ,
363367 // SSE one-shot run (deepagents). Server builds the /run body from {message}.
364- runStreamUrl : ( agent : string ) => `/api/agents/${ encodeURIComponent ( agent ) } /run` ,
368+ runStreamUrl : ( agentId : string ) => `/api/agents/${ encodeURIComponent ( agentId ) } /run` ,
365369 // Schedules
366- schedules : ( agent ?: string ) =>
367- getJSON < { schedules : Schedule [ ] } > ( `/schedules${ agent ? `?agent =${ encodeURIComponent ( agent ) } ` : "" } ` ) . then ( ( d ) => d . schedules ) ,
370+ schedules : ( agentId ?: string ) =>
371+ getJSON < { schedules : Schedule [ ] } > ( `/schedules${ agentId ? `?agentId =${ encodeURIComponent ( agentId ) } ` : "" } ` ) . then ( ( d ) => d . schedules ) ,
368372 createSchedule : ( s : NewSchedule ) => postJSON < { schedule : Schedule } > ( "/schedules" , s ) . then ( ( d ) => d . schedule ) ,
369373 updateSchedule : ( id : string , fields : Partial < NewSchedule > & { enabled ?: boolean } ) =>
370374 reqJSON < { schedule : Schedule } > ( "PATCH" , `/schedules/${ encodeURIComponent ( id ) } ` , fields ) . then ( ( d ) => d . schedule ) ,
@@ -379,10 +383,10 @@ export const api = {
379383 deletePolicy : ( id : string ) =>
380384 reqJSON < { success ?: boolean } > ( "DELETE" , `/policies/${ encodeURIComponent ( id ) } ` ) ,
381385 // Per-agent policy binding (Mongo, ours).
382- getAgentPolicy : ( agent : string ) =>
383- getJSON < { binding : AgentPolicyBinding | null } > ( `/agents/${ encodeURIComponent ( agent ) } /policy` ) . then ( ( d ) => d . binding ) ,
384- setAgentPolicy : ( agent : string , policyId : string | null ) =>
385- reqJSON < { binding : AgentPolicyBinding | null } > ( "PUT" , `/agents/${ encodeURIComponent ( agent ) } /policy` , { policy_id : policyId } ) . then ( ( d ) => d . binding ) ,
386+ getAgentPolicy : ( agentId : string ) =>
387+ getJSON < { binding : AgentPolicyBinding | null } > ( `/agents/${ encodeURIComponent ( agentId ) } /policy` ) . then ( ( d ) => d . binding ) ,
388+ setAgentPolicy : ( agentId : string , policyId : string | null ) =>
389+ reqJSON < { binding : AgentPolicyBinding | null } > ( "PUT" , `/agents/${ encodeURIComponent ( agentId ) } /policy` , { policy_id : policyId } ) . then ( ( d ) => d . binding ) ,
386390 // OPA rego policies (managed by SRS, referenced from RAI policies' opa_guardrail).
387391 opaPolicies : ( ) => getJSON < { policies : OPAPolicyDoc [ ] } | OPAPolicyDoc [ ] > ( "/opa-policies" ) . then ( ( d ) => ( Array . isArray ( d ) ? d : d . policies ) ) ,
388392 opaPolicy : ( id : string ) => getJSON < OPAPolicyDoc > ( `/opa-policies/${ encodeURIComponent ( id ) } ` ) ,
0 commit comments