Class Session
Index
Properties
Readonlyid
The session id that was opened.
Readonlyinstructions
What the service said when the session was opened.
Readonlydomain
What the service said about the session's domain, or null
when its listing did not describe it.
ReadonlytoolCatalog
What MemoryOperations.listTools reported when
this session was opened, which tools filters against. null
when that fetch failed -- every tool is then treated as available
rather than none.
Methods
[asyncDispose]
close
-
Close the session, ending the key it holds if it acts for one of your users.
Only a session opened with an
externalIdholds anything: its key, which is revoked here rather than left live until it expires. Every later call through the session, its tools, or a memory it returned is then refused locally with MemcoConfigError. A call still in flight keeps the key until it finishes, and the key is ended then.Ending the key is best effort. If the service cannot end it, a warning naming the key's id — never its value — is logged and nothing is thrown: the client tries again before it next opens a session for that user, and when it closes, and the key expires on its own regardless. After the client is closed, this does nothing.
A session opened without an
externalIdholds nothing, so closing it changes nothing and it stays usable. Safe to call more than once.Returns Promise<void>
getSession
-
Look this session up: its domain and what has happened under it.
Parameters
- options: TimeoutOptions = {}
Per-call deadline.
Returns Promise<SessionInfo>
What MemoryOperations.getSession reports for this session.
- options: TimeoutOptions = {}
search
-
Search within this session.
Parameters
- query: string
What you want to know, in plain language.
- options: ScopedSearchOptions = {}
Tags to narrow by, and a deadline.
Returns Promise<SearchResult>
What matched.
- query: string
getMemory
-
Fetch one memory in full, by an idx this session returned.
Parameters
- idx: string
The handle, copied exactly as it appeared in a search response.
- options: TimeoutOptions = {}
Per-call deadline.
Returns Promise<Memory>
The memory, its
feedback()bound to this session — unlike MemoryOperations.getMemory, which has no session of its own to bind. - idx: string
createMemory
-
Save new knowledge into this session's domain.
Parameters
- options: ScopedCreateMemoryOptions
What to save, and a deadline.
Returns Promise<WriteResult>
The operation id, when the write can be undone, and guidance.
- options: ScopedCreateMemoryOptions
enrichMemory
-
Add to a memory this session returned, or open a new one.
Parameters
- options: ScopedEnrichMemoryOptions
What to add, which memory to add it to, and a deadline.
Returns Promise<WriteResult>
The operation id, when the write can be undone, and guidance.
- options: ScopedEnrichMemoryOptions
shareFeedback
-
Rate what this session returned.
Parameters
- options: ScopedShareFeedbackOptions
The ratings, and a deadline.
Returns Promise<FeedbackResult>
What was recorded, and anything the service wants to say back.
- options: ScopedShareFeedbackOptions
revertMemory
-
Undo one of your own writes.
Parameters
- operationId: string
The handle a write returned.
- options: TimeoutOptions = {}
Per-call deadline.
Returns Promise<RevertResult>
What the revert actually removed.
- operationId: string
importMemories
-
importMemories(
memories: Iterable<ImportedMemory>,
options?: TimeoutOptions,
): Promise<ImportResult>Contribute many memories at once, recorded against this session.
Parameters
- memories: Iterable<ImportedMemory>
The memories to import.
- options: TimeoutOptions = {}
Per-call deadline.
Returns Promise<ImportResult>
One outcome per memory, in the order they were given.
- memories: Iterable<ImportedMemory>
tools
-
This session's operations, described and rendered for an LLM.
Each tool carries what the operation is for, a JSON Schema for its arguments, and a call that renders the result as text. Every one is bound to this session, so nothing a model sends can change which session a call is recorded under.
The toolset hands itself to a framework —
toLangChain(),toAnthropic(),toOpenAI()— or runs what a model named withcall().An operation is included only when your token's role permits it, as reported by MemoryOperations.listTools when this session was opened. This only shapes what is offered here — it does not gate calling a Session method directly.
Parameters
- options: ToolsOptions = {}
The prefix every tool name starts with, when a host calls the tools by other names than
memco_<op>.
Returns Toolset
One tool per operation your role permits, as a Toolset.
- options: ToolsOptions = {}
An open session, with every session-bound memory operation applied.
Returned by MemoryOperations.startSession, MemoryOperations.withSession and MemoryOperations.resumeSession alike; not constructed directly. No method here takes a session id or a domain: this object supplies both. That is the point of it — a call that silently drops the session id is still a valid call. It opens a session of its own and records the search there, so the series you were assembling quietly splits in two, and a later rating lands against a search you did not mean to make.
A session opened with an
externalIdholds a key acting as that user, and Session.close ends it; so does leaving anawait usingblock. Close it when you are done: the service caps how many live keys each user may hold. A session dropped without closing has its key ended eventually — once the session has been garbage-collected, by the next call the client makes — but closing ends it at once, and is the only way that says when.Any other session holds nothing: the contract has no operation that ends a session, and a session id stays usable for as long as it is named, so closing one changes nothing and
await usingbounds the region of code a session belongs to, which is a claim about the reader's attention rather than about a resource.