API reference
scp-protocol v0.5.0.
PatternStore
| Method | Returns | Notes |
|---|---|---|
lookup(entity) | { decision, confidence, source } | null | source is "exact" or "similar" |
learn(entity, decision) | void | bumps count or creates new pattern |
correct(entity, brainDecision) | void | resets confidence and decision |
report(entity, success: boolean) | { found, invalidated } | tracks consecutive failures |
getSuccessRate(entity) | number | null | per-pattern rate |
save() | void | localStorage or sqlite |
load() | void | localStorage or sqlite |
stats() | object | hits, misses, hitRate, … |
pattern_invalidated fires when a pattern crosses failureThreshold.
AdaptiveMemory
| Method | Returns | Notes |
|---|---|---|
store(features, decision, outcome?) | entry | reinforces if features already present |
lookup(features) | { decision, confidence } | null | top-k blended |
report(features, success) | { found, purged? } | auto-purges at threshold |
save() | number | rows written to SQLite |
load() | number | rows loaded from SQLite |
stats() | object | entries, hits, misses, avgConfidence |
entry_purged fires when a decision is removed.
SCPBody
| Method | Returns | Notes |
|---|---|---|
invokeTool(name, params) | result | calls the matching async method |
decideLocally(entity) | { decision, confidence, source } | null | walks pattern then adaptive |
learnFromBrain(entity, decision) | void | writes to both cache layers |
notifyDecision(entity, decision, meta) | void | tells the Space (managed mode) |
rememberCachedEntity(entity) | void | for outcome reporting |
evaluateOutcome(state) | true | false | null | override to enable auto-report |
tick() | promise | sensor loop; override and call super |
setState(patch) | void | merges into the live snapshot |
emit(type, payload, priority) | void | priority is CRITICAL, HIGH, NORMAL, LOW |
snapshot() | object | aggregator-shaped state |
installShutdownHandlers() | this | persists stores on SIGINT / SIGTERM |
clearPendingEvents() | void | empties the queue |
SCPAdapter (legacy)
The v0.1 contract. Kept for backward compatibility. New code should useSCPBody.
| Method | Notes |
|---|---|
reflex(name, fn) | register a sync rule |
_scpCall(method, args) | legacy transport hook |
SCPBridge
Base class for any LLM client.| Method | Returns | Notes |
|---|---|---|
call(prompt, tools) | { decision, raw } | implement in subclass |
invoke(prompt, tools) | same as call | adds timing |
stats() | object | callCount, errorCount, lastCallMs, avgCallMs |
Bridges
OllamaBridge— local, free.hostdefaults tohttp://localhost:11434.BedrockBridge— AWS Converse. Requires@aws-sdk/client-bedrock-runtime.OpenAIBridge— raw HTTPS toapi.openai.com. ReadsOPENAI_API_KEY.
Transports
SCPBody is in-process by default. Two explicit transports:
HTTPTransport—node:httpserver with/emit,/poll,/health. No external dependency.WebSocketTransport— requiresws(optional peer dep).