Graphorin API reference v0.1.0
Graphorin API reference / @graphorin/memory / / WorkingMemory
Class: WorkingMemory
Defined in: packages/memory/src/tiers/working-memory.ts:101
WorkingMemory — labeled, character-bounded blocks rendered into every system prompt. Operations:
define(spec): idempotently registers a block definition; the block's row is created in storage on the nextwritecall so operators can changedescriptionbetween runs without triggering a write.read(scope, label)/list(scope): surface the current block contents.write(scope, label, value): full replace.append(scope, label, content): append-with-newline.replace(scope, label, oldUnique, newText): targeted replace with a uniqueness check.compile(scope): render the active blocks for the context engine (used by Phase 10d).
Stable
Constructors
Constructor
new WorkingMemory(args): WorkingMemory;Defined in: packages/memory/src/tiers/working-memory.ts:107
Parameters
| Parameter | Type |
|---|---|
args | { store: MemoryStoreAdapter; tracer: Tracer; } |
args.store | MemoryStoreAdapter |
args.tracer | Tracer |
Returns
WorkingMemory
Methods
append()
append(
scope,
label,
content): Promise<Block>;Defined in: packages/memory/src/tiers/working-memory.ts:159
Append content to a block (with a newline separator).
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
label | string |
content | string |
Returns
Promise<Block>
attach()
attach(
scope,
blockId,
agentId): Promise<void>;Defined in: packages/memory/src/tiers/working-memory.ts:214
Attach a working block to an additional agent. Backed by the adapter's shared.attach(...) join table so multi-agent crews can share the same block without duplicating storage.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
blockId | string |
agentId | string |
Returns
Promise<void>
compile()
compile(scope, agentId?): Promise<string>;Defined in: packages/memory/src/tiers/working-memory.ts:257
Render a deterministic <memory_blocks> XML fragment for the supplied scope. The full layered system prompt (six layers) is produced by Phase 10d's ContextEngine; this method ships the minimum-viable rendering used by the smoke acceptance criteria.
The optional agentId argument is reserved for the per-agent filtering Phase 10d wires through. In Phase 10a the argument is accepted but ignored — the rendering is scope-wide.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
agentId? | string |
Returns
Promise<string>
define()
define(definition): BlockDefinition;Defined in: packages/memory/src/tiers/working-memory.ts:114
Register a block definition. Returns the same definition object.
Parameters
| Parameter | Type |
|---|---|
definition | BlockDefinition |
Returns
definitionFor()
definitionFor(label):
| BlockDefinition
| undefined;Defined in: packages/memory/src/tiers/working-memory.ts:125
Lookup a definition by label.
Parameters
| Parameter | Type |
|---|---|
label | string |
Returns
| BlockDefinition | undefined
definitions()
definitions(): readonly BlockDefinition[];Defined in: packages/memory/src/tiers/working-memory.ts:120
Snapshot of every registered definition.
Returns
readonly BlockDefinition[]
detach()
detach(
scope,
blockId,
agentId): Promise<void>;Defined in: packages/memory/src/tiers/working-memory.ts:231
Detach a working block from an agent.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
blockId | string |
agentId | string |
Returns
Promise<void>
forget()
forget(
scope,
label,
reason?): Promise<void>;Defined in: packages/memory/src/tiers/working-memory.ts:197
Soft-delete a block.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
label | string |
reason? | string |
Returns
Promise<void>
list()
list(scope): Promise<readonly Block[]>;Defined in: packages/memory/src/tiers/working-memory.ts:130
List active (non-deleted) blocks for the supplied scope.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
Returns
Promise<readonly Block[]>
read()
read(scope, label): Promise<string | null>;Defined in: packages/memory/src/tiers/working-memory.ts:139
Read a single block's value (or null when absent).
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
label | string |
Returns
Promise<string | null>
replace()
replace(
scope,
label,
oldUnique,
newText): Promise<Block>;Defined in: packages/memory/src/tiers/working-memory.ts:171
Replace the unique substring oldUnique inside the block's value with newText. Throws WorkingBlockReplaceMismatchError when the substring is missing or appears more than once.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
label | string |
oldUnique | string |
newText | string |
Returns
Promise<Block>
rethink()
rethink(
scope,
label,
mutator): Promise<Block>;Defined in: packages/memory/src/tiers/working-memory.ts:188
Run mutator(current) => next and persist the result.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
label | string |
mutator | (current) => string | Promise<string> |
Returns
Promise<Block>
write()
write(
scope,
label,
value): Promise<Block>;Defined in: packages/memory/src/tiers/working-memory.ts:154
Replace a block's value entirely. Honours overflow policy.
Parameters
| Parameter | Type |
|---|---|
scope | SessionScope |
label | string |
value | string |
Returns
Promise<Block>