export * from "@motebit/protocol"; export * from "./models.js"; export * from "./provider-mode.js"; export * from "./provider-resolver.js"; export * from "./color-presets.js"; export * from "./identity-sigil.js"; export * from "./approval-presets.js"; export * from "./risk-labels.js"; export * from "./surface-options.js"; export * from "./governance-config.js"; export * from "./voice-config.js"; export * from "./appearance-config.js"; export * from "./pixel-consent.js"; export * from "./session-state.js"; import type { SensitivityLevel, NodeId, MotebitId, TrustMode, BatteryMode, EventLogEntry, MemoryContent, MemoryCandidate, ToolDefinition, AgentTrustRecord, EventStoreAdapter, IdentityStorage, AuditLogAdapter, StateSnapshotAdapter, AuditLogSink, ConversationStoreAdapter, PlanStoreAdapter, AgentTrustStoreAdapter, ServiceListingStoreAdapter, BudgetAllocationStoreAdapter, SettlementStoreAdapter, LatencyStatsStoreAdapter, CredentialStoreAdapter, ApprovalStoreAdapter, MotebitIdentity, AuditRecord } from "@motebit/protocol"; import type { SessionStateSnapshot } from "./session-state.js"; export declare enum RelationType { Related = "related", CausedBy = "caused_by", FollowedBy = "followed_by", ConflictsWith = "conflicts_with", Reinforces = "reinforces", PartOf = "part_of", Supersedes = "supersedes", DerivedFrom = "derived_from" } export interface MotebitState { attention: number; processing: number; confidence: number; affect_valence: number; affect_arousal: number; social_distance: number; curiosity: number; trust_mode: TrustMode; battery_mode: BatteryMode; } export interface BehaviorCues { hover_distance: number; drift_amplitude: number; glow_intensity: number; eye_dilation: number; smile_curvature: number; speaking_activity: number; } export declare const SPECIES_CONSTRAINTS: Readonly<{ readonly MAX_AROUSAL: 0.35; readonly SMILE_DELTA_MAX: 0.08; readonly GLOW_DELTA_MAX: 0.15; readonly DRIFT_VARIATION_MAX: 0.1; }>; export type SpeciesConstraints = typeof SPECIES_CONSTRAINTS; /** Full memory node including persistence metadata. */ export interface MemoryNode extends MemoryContent { node_id: NodeId; motebit_id: MotebitId; embedding: number[]; created_at: number; last_accessed: number; half_life: number; tombstoned: boolean; pinned: boolean; } export interface MemoryEdge { edge_id: string; source_id: NodeId; target_id: NodeId; relation_type: RelationType; weight: number; confidence: number; } export interface MemoryQuery { motebit_id: string; min_confidence?: number; sensitivity_filter?: SensitivityLevel[]; limit?: number; include_tombstoned?: boolean; pinned?: boolean; } export interface MemoryStorageAdapter { saveNode(node: MemoryNode): Promise; getNode(nodeId: string): Promise; queryNodes(query: MemoryQuery): Promise; saveEdge(edge: MemoryEdge): Promise; getEdges(nodeId: string): Promise; tombstoneNode(nodeId: string): Promise; /** Tombstone with ownership check. Returns true if the node existed and belonged to motebitId. */ tombstoneNodeOwned?(nodeId: string, motebitId: string): Promise; /** * Erase a node — physically remove the row and any edges referencing it. * Required by the `mutable_pruning` retention contract per * docs/doctrine/retention-policy.md §"Decision 7": certificates of * kind `mutable_pruning` attest that the bytes are unrecoverable, so * a tombstoned-but-stored node would silently weaken the cert's * claim. Distinct from `tombstoneNode`, which keeps the row with a * `tombstoned: true` flag for soft-delete lifecycle (decay / * notability passes that don't issue a deletion cert). * * Implementations MUST remove the node row and every edge whose * `source_id` or `target_id` references the erased node. After * `eraseNode(id)` resolves, `getNode(id)` returns `null` and * `getEdges(id)` returns `[]`. */ eraseNode(nodeId: string): Promise; pinNode(nodeId: string, pinned: boolean): Promise; getAllNodes(motebitId: string): Promise; getAllEdges(motebitId: string): Promise; } export interface RenderSpec { geometry: GeometrySpec; material: MaterialSpec; lighting: LightingSpec; } export interface GeometrySpec { form: "droplet"; base_radius: number; height: number; } export interface MaterialSpec { ior: number; subsurface: number; roughness: number; clearcoat: number; surface_noise_amplitude: number; base_color: [number, number, number]; emissive_intensity: number; tint: [number, number, number]; } export interface LightingSpec { environment: "hdri"; exposure: number; ambient_intensity: number; } export interface ContextPack { recent_events: EventLogEntry[]; relevant_memories: MemoryContent[]; current_state: MotebitState; user_message: string; conversation_history?: ConversationMessage[]; behavior_cues?: BehaviorCues; tools?: ToolDefinition[]; /** Session resumption info — set when continuing a persisted conversation. */ sessionInfo?: { continued: boolean; lastActiveAt: number; }; /** Fading memories the agent might want to check in about, if relevant to conversation. */ curiosityHints?: Array<{ content: string; daysSinceDiscussed: number; }>; /** Known agents this motebit has interacted with — trust levels, reputation, interaction history. */ knownAgents?: AgentTrustRecord[]; /** Capabilities per agent ID — used to enrich [Agents I Know] so the AI knows what each agent can do. */ agentCapabilities?: Record; /** Active inference precision context — modulates agent behavior based on intelligence gradient. */ precisionContext?: string; /** First conversation ever — creature should form memories eagerly and discover direction. */ firstConversation?: boolean; /** System-triggered generation — appended to system prompt, no user message sent. */ activationPrompt?: string; /** * Layer-1 memory index (spec/memory-delta-v1.md §5.8) — a compact * always-loaded projection of the motebit's live memory graph as * short-id + summary + certainty lines. Injected into the system * prompt's dynamic suffix so the agent has a cheap overview of what * it knows without round-tripping retrieval. * * Absent on iterations past the first (memory doesn't change * mid-turn) and absent on surfaces that haven't opted in yet. */ memoryIndex?: string; /** * Skills selected by the runtime's `SkillSelectorHook` for this turn * (spec/skills-v1.md §7). Absent when no hook is wired or no skill * passed every gate (provenance + platform + sensitivity + HA + relevance). * First iteration only — same pattern as `memoryIndex` and * `curiosityHints`. */ selectedSkills?: SkillInjection[]; /** * Prompt-1 — runtime session-state snapshot, formatted into a * `[Session]` block in the system prompt's dynamic suffix. * * Surfaces the truth the AI tends to confabulate: whether a * cloud-browser session is open, who holds control, what * sensitivity tier the session operates at, whether pixel * passthrough is granted. Composed by the runtime from a * surface-supplied `BrowserSessionInfo` plus its own sensitivity * + consent fields. * * Absent when the runtime hasn't wired a session-state provider * (in-tree tests, surfaces without computer-use). Absence means * "no session-state context" — the prompt omits the block * entirely rather than emitting a misleading "Browser: unknown" * default. * * Doctrine: `packages/sdk/src/session-state.ts` + the * PERCEPTION_DOCTRINE block in `packages/ai-core/src/prompt.ts` * (runtime gates / state arrive as typed signal, never inference). */ sessionState?: SessionStateSnapshot; } /** * One skill body the runtime resolved as relevant for the current turn, * passed verbatim into the system prompt (spec/skills-v1.md §7.3). The * `provenance` field drives the display badge: `verified` means the * envelope signature passed; `trusted_unsigned` means the operator * manually attested via `motebit skills trust `. * * The `score` and `signature` fields are audit-only — they ride into the * runtime's `SkillLoaded` event-log emission (§7.4) and are ignored by * the AI loop's prompt builder. */ export interface SkillInjection { /** Skill slug (e.g., `"git-commit-motebit-style"`). */ name: string; /** Skill SemVer (e.g., `"1.0.0"`). */ version: string; /** SKILL.md body bytes decoded as UTF-8 — injected into system context verbatim. */ body: string; /** Display-grade provenance status. */ provenance: "verified" | "trusted_unsigned"; /** BM25 relevance score from the selector. Audit-only; ignored by the prompt builder. */ score: number; /** * Base64url envelope `signature.value`. Empty string when manifest is * `trusted_unsigned`. Audit-only; ignored by the prompt builder. The * runtime emits this on the `SkillLoaded` event-log entry so a stale * audit row whose signature no longer resolves in the registry remains * a useful audit signal. */ signature: string; } /** * Per-turn hook the runtime calls to resolve relevant skills for the * current user message. Implementations bind to a SkillRegistry + * SkillSelector (in `@motebit/skills`) and return at most top-K skills * that pass every gate (§7.2). Returning an empty array is normal * (no skills installed, all filtered, or no relevance match). * * The runtime calls this once per turn at the entry of * `sendMessageStreaming` / `sendMessage`. Throws are caught and treated * as an empty result — selector failures must never block the AI loop. * * Adapter pattern: the runtime is unaware of the BSL `@motebit/skills` * package; surfaces (CLI / desktop / mobile) wire the concrete impl * behind this interface. */ export interface SkillSelectorHook { selectForTurn(turn: string): Promise; } /** * In-memory conversation message. Optional `sensitivity` field is the * runtime's effective tier at write time (composed from session tier * × tier-bounded slab items via `getEffectiveSessionSensitivity`). * Persisted messages carry the same value via the conversation * store's `appendMessage`. The runtime's `trimmed()` consumes this * field to filter trimmed history at AI-context construction time * — read-side companion to the write-side floor that landed in * commit 6a3c3b9a. Untagged messages (legacy data, in-memory * pre-floor) flow through filters unchanged for backward compat. * * Same compounding pattern as `MemoryNode.sensitivity` and * `SlabItem.sensitivity`: write-side classification → tag → read- * side filter. See doctrine: motebit-computer.md §"Mode contract." */ export type ConversationMessage = { role: "user"; content: string; sensitivity?: SensitivityLevel; } | { role: "assistant"; content: string; tool_calls?: ToolCall[]; sensitivity?: SensitivityLevel; /** * Provider-native thinking blocks from this assistant turn, preserved for * tool-use continuation (see `ThinkingBlock`). Present only when extended * thinking is enabled; `buildMessages` re-emits them ahead of the turn's * text/tool_use blocks. Inert (absent) by default. */ thinking_blocks?: ThinkingBlock[]; } | { role: "tool"; content: string; tool_call_id: string; sensitivity?: SensitivityLevel; }; export interface ToolCall { id: string; name: string; args: Record; } /** * A provider-native reasoning block that must be round-tripped verbatim, with * its cryptographic `signature`, for a multi-turn tool-use conversation to stay * valid (Anthropic extended-thinking: when thinking is enabled and the assistant * turn used a tool, the thinking block + signature MUST be preserved in the * assistant message on the follow-up request, or the API rejects it). Distinct * from `AIResponse.reasoning` (the display text): this is the opaque * round-trip artifact, never rendered. Absent unless extended thinking is * enabled (off by default), so it is inert for every other provider/config. */ export interface ThinkingBlock { thinking: string; signature: string; } export interface AIResponse { text: string; confidence: number; memory_candidates: MemoryCandidate[]; state_updates: Partial; tool_calls?: ToolCall[]; /** Token usage from the provider, if available. */ usage?: { input_tokens: number; output_tokens: number; }; /** * Task-step narration — what motebit is currently doing, at the * supervisor-cares-about granularity. Single first-person present- * tense sentence ("Reading the page" / "Filling in the form" / * "Hit a paywall — need your input"). Cap ~80 chars; the chrome is * calm. Granularity is between action-step (too noisy) and * goal-step (too sparse) — the chunk a supervisor cares about. * * Consumed by the slab's chrome in the `motebit × virtual_browser` * register (and other `motebit × *` cells). Validated by * `validateTaskStepNarration` in `@motebit/ai-core` before display * — falsified narration is replaced with a runtime-templated * fallback so the chrome never renders model claims contradicted * by typed truth. Doctrine: third graduation of * `runtime-invariants-over-prompt-rules.md`, the typed-truth- * perception triple applied to in-flight motebit-voiced text. * Architectural primitive: `chrome-as-state-render.md`. * * Optional. Absent / null when the model didn't emit a narration * for this turn (idle, thinking, no active task-step). The chrome * recedes to the empty register when absent. */ task_step_narration?: string; /** * Interior reasoning — the model's own cognition trace (``), * captured for the owner-facing `mind` embodiment organ (render-engine * `EMBODIMENT_MODE_CONTRACTS.mind`: `source:"interior"`, `observer:"self"`, * `consent:"always-permitted"`, `sensitivity:"all-tiers"`). Stripped from the * visible `text` (interior cognition must not clutter the conversation), but * — unlike before — no longer destroyed: the `mind` organ is the surface * built to render it (`felt-interior.md`, maximum interiority made legible to * the sovereign). * * INTERIOR-ONLY by contract: this is the full reasoning trace and it MUST NOT * be synced, egressed, persisted to a shared surface, or sent to an external * AI — the `mind` contract's `observer:"self"` is the boundary. Producer is * `extractReasoningTags` in `@motebit/ai-core`. * * Optional. Absent when the model emitted no reasoning this turn (the organ * renders empty). */ reasoning?: string; /** * Provider-native thinking blocks (with signatures) for this turn, for * tool-use continuation round-tripping (see `ThinkingBlock`). Opaque — * NEVER rendered (that is `reasoning`). Present only when extended thinking * is enabled; the loop carries them onto the assistant history message. */ thinking_blocks?: ThinkingBlock[]; } export interface IntelligenceProvider { generate(contextPack: ContextPack): Promise; estimateConfidence(): Promise; extractMemoryCandidates(response: AIResponse): Promise; } export interface ExportManifest { motebit_id: MotebitId; exported_at: number; identity: MotebitIdentity; memories: MemoryNode[]; edges: MemoryEdge[]; events: EventLogEntry[]; audit_log: AuditRecord[]; } /** * Precision weights derived from the intelligence gradient. * * In active inference, precision modulates the balance between epistemic value * (exploration/curiosity) and pragmatic value (exploitation/reputation). * The gradient measures model evidence; precision is the agent's confidence * in its own generative model. * * High gradient → high self-trust → exploit known-good routes, trust memory. * Low gradient → low self-trust → explore, diversify, question memory. */ export interface PrecisionWeights { /** Overall self-trust [0-1]. Sigmoid of composite gradient. */ selfTrust: number; /** Exploration drive [0-1]. Inverse of self-trust, modulated by gradient delta. */ explorationDrive: number; /** Memory retrieval precision [0-1]. High = trust similarity, low = diversify. */ retrievalPrecision: number; /** Curiosity modulation [0-1]. Fed back into state vector curiosity field. */ curiosityModulation: number; } export interface GradientSnapshot { motebit_id: string; timestamp: number; gradient: number; delta: number; knowledge_density: number; knowledge_density_raw: number; knowledge_quality: number; graph_connectivity: number; graph_connectivity_raw: number; temporal_stability: number; retrieval_quality: number; interaction_efficiency: number; tool_efficiency: number; curiosity_pressure: number; stats: { live_nodes: number; live_edges: number; semantic_count: number; episodic_count: number; pinned_count: number; avg_confidence: number; avg_half_life: number; consolidation_add: number; consolidation_update: number; consolidation_reinforce: number; consolidation_noop: number; total_confidence_mass: number; avg_retrieval_score: number; retrieval_count: number; avg_iterations_per_turn: number; total_turns: number; tool_calls_succeeded: number; tool_calls_blocked: number; tool_calls_failed: number; curiosity_target_count: number; avg_curiosity_score: number; }; } export interface GradientStoreAdapter { save(snapshot: GradientSnapshot): void; latest(motebitId: string): GradientSnapshot | null; list(motebitId: string, limit?: number): GradientSnapshot[]; } export interface StorageAdapters { eventStore: EventStoreAdapter; memoryStorage: MemoryStorageAdapter; identityStorage: IdentityStorage; auditLog: AuditLogAdapter; stateSnapshot?: StateSnapshotAdapter; toolAuditSink?: AuditLogSink; /** * audit-chain-2 — durable hash-chained audit store. When provided * alongside `toolAuditSink`, the runtime wraps the sink in a * `ChainedAuditSink` so every appended entry lands in the chain * with a `previous_hash`-linked SHA-256 — tamper-evident trail * across restart. Surfaces with a SQLite driver pass * `new SqliteAuditChainStore(driver)`; surfaces without omit it * (the runtime still gets per-entry signed receipts via the * existing crypto path; chain-level integrity is the optional * upgrade). * * Doctrine: `audit_chain_signing_endgame` memory + audit-chain-1 * (`ChainedAuditSink` in `@motebit/policy`) + audit-chain-2 * (`SqliteAuditChainStore` in `@motebit/persistence`). */ auditChainStore?: import("@motebit/protocol").AuditChainStoreAdapter; conversationStore?: ConversationStoreAdapter; planStore?: PlanStoreAdapter; gradientStore?: GradientStoreAdapter; agentTrustStore?: AgentTrustStoreAdapter; serviceListingStore?: ServiceListingStoreAdapter; budgetAllocationStore?: BudgetAllocationStoreAdapter; settlementStore?: SettlementStoreAdapter; latencyStatsStore?: LatencyStatsStoreAdapter; credentialStore?: CredentialStoreAdapter; approvalStore?: ApprovalStoreAdapter; } /** Context passed to CredentialSource when requesting a credential. */ export interface CredentialRequest { /** URL of the MCP server being called. */ serverUrl: string; /** Tool name being invoked, if known at credential-acquisition time. */ toolName?: string; /** Requested scope or audience for scoped credentials. */ scope?: string; /** Motebit ID of the calling agent, if available. */ agentId?: string; } /** * Adapter interface for obtaining credentials at tool-call time. * Implementations may read from OS keyring, external vaults, or wrap static tokens. */ export interface CredentialSource { getCredential(request: CredentialRequest): Promise; } /** Config fields that server verifiers can update via VerificationResult. */ export interface VerifierConfigUpdates { toolManifestHash?: string; pinnedToolNames?: string[]; trusted?: boolean; tlsCertFingerprint?: string; } /** Result of server verification. */ export interface VerificationResult { ok: boolean; error?: string; configUpdates?: VerifierConfigUpdates; } /** * Adapter interface for verifying an MCP server's integrity after connect. * Fail-closed: ok:false or thrown errors should tear down the connection. */ export interface ServerVerifier { verify(config: { name: string; url?: string; toolManifestHash?: string; pinnedToolNames?: string[]; trusted?: boolean; tlsCertFingerprint?: string; }, tools: ToolDefinition[]): Promise; } //# sourceMappingURL=index.d.ts.map