Memory

Memories: named notes any agent of their scope can attach.

company = noclick.Memory.from_name("company", create_if_missing=True)
company.save("refunds", "Within 30 days, to the original card.", description="Our refund rules")
support = noclick.Agent.from_name("support", create_if_missing=True, instructions="...",
                                  memories=[company])              # it reads company
closer = noclick.Agent.from_name("closer", create_if_missing=True, instructions="...",
                                 memories=[company.writable()])     # it reads and writes it

Every agent also has a memory of its own, agent.memory, which it always reads and writes. A memory attached to it is read-only unless attached with writable(); every turn starts with the names and descriptions of every entry it can read, its own memory's first.

class Memory

Named notes any agent of its scope can attach: the account's (every user's agents may read them) or one user's. Its entries are what agent.memory holds: a name, a one-line description, Markdown content and a version. A memory of the account keeps two layers, as an account agent's own memory does: its own entries, and each user's, which only that user's conversations see.

Attributes
idstring
namestring | null

Its name, unique in its scope (null for an agent's own memory).

descriptionstring | null

One line saying what it holds.

agentIdstring | null

The agent whose own memory this is (null for a memory with a name).

attachedToMemoryAttachment[]

The agents that attach it besides, and whether each writes it.

entryCountnumber | null

How many entries it holds, in all its layers.

userIdstring | null
createdAtDate | null
updatedAtDate | null

createstatic

static create(
  name: string,
  options?: CallOptions & { description?: string },
): Promise<Memory>

Create an empty memory (1-64 letters, digits and . _ -), unique by name per user, or for the account outside asUser (a taken name throws Conflict with existingId).

Parameters
namestringrequired
options.descriptionstring
options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

The new, empty memory.

fromNamestatic

static fromName(
  name: string,
  options?: CallOptions & { createIfMissing?: boolean; description?: string },
): Memory

A lazy reference to the memory called name. Acting for a user, that user's own memory is found first, then the account's. With createIfMissing the current (or given) user's is created on first use.

Parameters
namestringrequired
options.createIfMissingboolean
options.descriptionstring
options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

A memory that loads (or is created) the first time it's used. Nothing is sent yet.

fromIdstatic

static fromId(memoryId: string, options?: CallOptions): Memory

A lazy reference to a memory by id, such as an agent's own (agent.memoryId).

Parameters
memoryIdstringrequired
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
Returns

A memory that loads the first time you read a field. Nothing is sent yet.

getstatic

static get(memoryId: string, options?: CallOptions): Promise<Memory>

Load a memory by id now; an unknown id raises noclick.NotFound.

Parameters
memoryIdstringrequired
options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

The memory, loaded: who attaches it and how many entries it holds.

liststatic

static list(options?: ReadOptions & { limit?: number }): Promise<Memory[]>

The current user's named memories and the account's (or those userFilter covers); an agent's own is agent.memory.

Parameters
options.limitnumber

Return at most this many.

options.userFilterUserFilter

Which users the read covers (user_id query), instead of acting as one (user).

options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

Every matching memory, newest first, fetched page by page.

listPagestatic

static listPage(options?: ReadOptions & PageOptions): Promise<Page<Memory>>

One page of named memories; pass nextCursor back as cursor.

Parameters
options.cursorstring | null

The next_cursor of the page before; omit it for the first page.

options.limitnumber

Return at most this many.

options.userFilterUserFilter

Which users the read covers (user_id query), instead of acting as one (user).

options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

A page whose data holds the memories and whose next_cursor is None on the last page.

writable

writable(): MemoryLink

This memory, for an agent's memories, with writes: the agent may save to it and forget from it, not only read it. Only a call acting for the memory's own scope can attach it so.

Returns

What memories= takes for a memory the agent writes.

update

update(changes: { name?: string; description?: string }): Promise<Memory>

Rename it, or change its description; an agent's own memory takes no name.

Parameters
changes{ name?: string; description?: string }required
Returns

This memory, as it is now.

delete

delete(): Promise<TrashItem>

Delete it and every entry in it: it goes to the trash, restorable for 30 days. While an agent attaches it (attachedTo) this throws Conflict; an agent's own memory goes only with its agent.

Returns

Its TrashItem: restore() puts it back.

entries

entries(options?: { user?: UserOption }): Promise<MemoryEntry[]>

The entries of one layer (the account's outside asUser, else the user's), by name, without their content.

Parameters
options.userUserOption

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
Returns

Each entry's name, description, version and when it last changed, by name; content is None here, so read an entry for its body.

search

search(
  query: string,
  options?: { limit?: number; user?: UserOption },
): Promise<MemoryEntry[]>

Search it the way an agent does (a user's entries and the account's): entries whose name, description or content holds any of the query's words, best first, with content (10 unless limit says otherwise).

Parameters
querystringrequired
options.limitnumber

Return at most this many.

options.userUserOption

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
Returns

The best matches first (10 unless limit says otherwise, at most 100), with their content.

read

read(name: string, options?: { user?: UserOption }): Promise<MemoryEntry>

One entry in full; a name with no entry throws NotFound.

Parameters
namestringrequired
options.userUserOption

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
Returns

The entry with its content and the version to pass back when you change it.

save

save(
  name: string,
  content: string,
  options?: { description?: string; version?: number; user?: UserOption },
): Promise<MemoryEntry>

Write an entry, creating it if the name is new. description is the line every agent attaching the memory sees each turn (required for a new entry, kept when omitted). With version the save only lands if the entry is still at that version, else Conflict.

Parameters
namestringrequired
contentstringrequired
options.descriptionstring
options.versionnumber
options.userUserOption

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
Returns

The entry as saved, with its new version.

forget

forget(
  name: string,
  options?: { version?: number; user?: UserOption },
): Promise<void>

Forget an entry; with version, only if it is still at that version (else Conflict).

Parameters
namestringrequired
options.versionnumber
options.userUserOption

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
Returns

None once it's gone; a name with no entry raises noclick.NotFound.