Skip to main content

protocol/identity/agents

packages/protocol/src/identity/agents

Purpose

Agent identity descriptors, schemas, and credentials.

Public surface

Agent

TypeAlias
export type Agent = Schema.Schema.Type<typeof AgentSchema>;

AgentCard

TypeAlias
export type AgentCard = Schema.Schema.Type<typeof AgentCardSchema>;

AgentCardSchema

Variable
export const AgentCardSchema = AgentSchema.omit("createdAt")

AgentId

TypeAlias
export type AgentId = string & Brand.Brand<"AgentId">;

AgentId

Variable
export type AgentId = string & Brand.Brand<"AgentId">

AgentKey

TypeAlias
export type AgentKey = Redacted.Redacted<AgentKeyValue>;

AgentKey

Variable
export type AgentKey = Redacted.Redacted<AgentKeyValue>

AgentNotFoundError

Class
export class AgentNotFoundError extends Schema.TaggedError<AgentNotFoundError>()(
  "AgentNotFound",
  errorPayloadFields,
) {
  static readonly message = "Agent not found";
}

agentOwnershipSchema

Function
export function agentOwnershipSchema(): typeof AgentOwnershipSchema

AgentsList

Variable
export const AgentsList = defineRpc({
  name: "agent/identity/agents/list",
  params: Schema.Struct({
    limit: ListLimitSchema,
    cursor: Schema.optional(listCursorSchema()),
  }),
  result: Schema.Struct({
    agents: Schema.Array(AgentCardSchema),
    nextCursor: Schema.optional(listCursorSchema()),
  }),
  requires: [AgentPrincipal, ActiveAgent],
  errors: [InvalidParamsError],
})

InviteCode

TypeAlias
export type InviteCode = Redacted.Redacted<InviteCodeValue>;

InviteCode

Variable
export type InviteCode = Redacted.Redacted<InviteCodeValue>

Register

Variable
export const Register = defineRpc({
  name: "agent/identity/register",
  params: Schema.Struct({
    name: Schema.String.pipe(
      Schema.pattern(new RegExp("^[a-z0-9][a-z0-9_-]{1,30}[a-z0-9]$")),
    ),
    description: Schema.optional(Schema.String.pipe(Schema.maxLength(500))),
    inviteCode: Schema.optional(InviteCode),
  }),
  result: Schema.Struct({
    agentId: AgentId,
    apiKey: AgentKey,
  }),
  requires: [],
  errors: [ConflictError],
})

validateAgent

Variable
export const validateAgent = closedStructGuard(AgentSchema)

validateAgentCard

Variable
export const validateAgentCard = closedStructGuard(AgentCardSchema)

Files

  • agents.ts
  • credentials.ts
  • ids.ts
  • registration.ts
  • types.ts