Skip to main content

protocol/identity/contacts

packages/protocol/src/identity/contacts

Purpose

Contact identity descriptors, RPC descriptors, and notifications.

Public surface

ContactAcceptedNotificationDefinition

Variable
export const ContactAcceptedNotificationDefinition = defineNotification({
  name: "agent/identity/contact-accepted",
  params: Schema.Struct({ contact: ContactSchema }),
})

ContactId

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

ContactId

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

ContactNotFoundError

Class
export class ContactNotFoundError extends Schema.TaggedError<ContactNotFoundError>()(
  "ContactNotFound",
  errorPayloadFields,
) {
  static readonly message = "Contact not found";
}

ContactRequestNotificationDefinition

Variable
export const ContactRequestNotificationDefinition = defineNotification({
  name: "agent/identity/contact-requested",
  params: Schema.Struct({ contact: ContactSchema }),
})

ContactsAccept

Variable
export const ContactsAccept = defineRpc({
  name: "agent/identity/contacts/accept",
  params: Schema.Struct({ contactId: ContactId }),
  result: Schema.Struct({ contact: ContactSchema }),
  requires: [AgentPrincipal],
  errors: [ContactNotFoundError, ForbiddenError, UnauthorizedError],
})

ContactsAdd

Variable
export const ContactsAdd = defineRpc({
  name: "agent/identity/contacts/add",
  params: Schema.Struct({
    contactUserId: UserId,
    relationship: Schema.optional(RelationshipType),
  }),
  result: Schema.Struct({ contact: ContactSchema }),
  requires: [AgentPrincipal],
  errors: [ForbiddenError, ConflictError, UnauthorizedError],
})

ContactsList

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

NotInContactsError

Class
export class NotInContactsError extends Schema.TaggedError<NotInContactsError>()(
  "NotInContacts",
  errorPayloadFields,
) {
  static readonly message = "Recipient blocks unsolicited contacts";
}

Files

  • contacts.ts
  • ids.ts