pub struct WasmAgentStateGraph { /* private fields */ }Expand description
AgentStateGraph for WASM — uses IndexedDB for persistent browser storage.
Architecture: in-memory cache with write-through to IndexedDB.
- All reads are instant (from memory)
- All writes queue changes for IndexedDB flush
- Call
drain_pending()from JS to get queued writes, then persist to IndexedDB - Call
load_data()on startup to hydrate from IndexedDB
Implementations§
Source§impl WasmAgentStateGraph
impl WasmAgentStateGraph
Sourcepub fn new(db_name: Option<String>) -> Result<WasmAgentStateGraph, JsValue>
pub fn new(db_name: Option<String>) -> Result<WasmAgentStateGraph, JsValue>
Create a new AgentStateGraph with IndexedDB-backed storage.
After construction, call load_data() with data from IndexedDB to restore state.
Sourcepub fn load_objects(&self, json_pairs: &str) -> Result<(), JsValue>
pub fn load_objects(&self, json_pairs: &str) -> Result<(), JsValue>
Load objects from IndexedDB dump. Call on startup. Pass a JSON string: [[“hex_id”, “json”], …]
Sourcepub fn load_commits(&self, json_pairs: &str) -> Result<(), JsValue>
pub fn load_commits(&self, json_pairs: &str) -> Result<(), JsValue>
Load commits from IndexedDB dump.
Sourcepub fn load_refs(&self, json_pairs: &str) -> Result<(), JsValue>
pub fn load_refs(&self, json_pairs: &str) -> Result<(), JsValue>
Load refs from IndexedDB dump.
Sourcepub fn drain_pending_objects(&self) -> String
pub fn drain_pending_objects(&self) -> String
Get pending object writes for flushing to IndexedDB. Returns JSON.
Sourcepub fn drain_pending_commits(&self) -> String
pub fn drain_pending_commits(&self) -> String
Get pending commit writes.
Sourcepub fn drain_pending_refs(&self) -> String
pub fn drain_pending_refs(&self) -> String
Get pending ref writes.
Sourcepub fn drain_deleted_refs(&self) -> String
pub fn drain_deleted_refs(&self) -> String
Get pending ref deletions (keys to delete from the refs store), so a deleted branch does not come back on the next load.
Sourcepub fn get(
&self,
path: &str,
reference: Option<String>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn get( &self, path: &str, reference: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>
Get a JSON value at a path.
Sourcepub fn set(
&self,
path: &str,
json_value: &str,
category: &str,
description: &str,
reference: Option<String>,
reasoning: Option<String>,
confidence: Option<f64>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn set( &self, path: &str, json_value: &str, category: &str, description: &str, reference: Option<String>, reasoning: Option<String>, confidence: Option<f64>, namespace: Option<String>, ) -> Result<String, JsValue>
Set a JSON value at a path.
Sourcepub fn delete(
&self,
path: &str,
category: &str,
description: &str,
reference: Option<String>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn delete( &self, path: &str, category: &str, description: &str, reference: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>
Delete a value at a path.
Sourcepub fn branch(
&self,
name: &str,
from: Option<String>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn branch( &self, name: &str, from: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>
Create a branch.
Sourcepub fn merge(
&self,
source: &str,
target: Option<String>,
description: Option<String>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn merge( &self, source: &str, target: Option<String>, description: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>
Merge source into target.
Sourcepub fn diff(
&self,
ref_a: &str,
ref_b: &str,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn diff( &self, ref_a: &str, ref_b: &str, namespace: Option<String>, ) -> Result<String, JsValue>
Structured diff between two refs. Returns JSON.
Sourcepub fn log(
&self,
reference: Option<String>,
limit: Option<u32>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn log( &self, reference: Option<String>, limit: Option<u32>, namespace: Option<String>, ) -> Result<String, JsValue>
Commit log. Returns JSON.
Sourcepub fn blame(
&self,
path: &str,
reference: Option<String>,
namespace: Option<String>,
) -> Result<String, JsValue>
pub fn blame( &self, path: &str, reference: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>
Blame — who modified a path and why.
Sourcepub fn speculate(
&self,
from: Option<String>,
label: Option<String>,
namespace: Option<String>,
) -> Result<u32, JsValue>
pub fn speculate( &self, from: Option<String>, label: Option<String>, namespace: Option<String>, ) -> Result<u32, JsValue>
Create a speculation. Returns handle ID.
Sourcepub fn spec_get(&self, handle_id: u32, path: &str) -> Result<String, JsValue>
pub fn spec_get(&self, handle_id: u32, path: &str) -> Result<String, JsValue>
Get from a speculation.
Sourcepub fn spec_set(
&self,
handle_id: u32,
path: &str,
json_value: &str,
) -> Result<(), JsValue>
pub fn spec_set( &self, handle_id: u32, path: &str, json_value: &str, ) -> Result<(), JsValue>
Set in a speculation.
Sourcepub fn commit_speculation(
&self,
handle_id: u32,
category: &str,
description: &str,
reasoning: Option<String>,
confidence: Option<f64>,
) -> Result<String, JsValue>
pub fn commit_speculation( &self, handle_id: u32, category: &str, description: &str, reasoning: Option<String>, confidence: Option<f64>, ) -> Result<String, JsValue>
Commit a speculation.
Sourcepub fn discard_speculation(&self, handle_id: u32) -> Result<(), JsValue>
pub fn discard_speculation(&self, handle_id: u32) -> Result<(), JsValue>
Discard a speculation.
Sourcepub fn create_epoch(
&self,
id: &str,
description: &str,
) -> Result<String, JsValue>
pub fn create_epoch( &self, id: &str, description: &str, ) -> Result<String, JsValue>
Create an epoch.
Sourcepub fn tasks_create_plan(
&self,
prefix: &str,
agent_id: &str,
ref_name: &str,
name: &str,
description: Option<String>,
) -> Result<String, JsValue>
pub fn tasks_create_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, description: Option<String>, ) -> Result<String, JsValue>
Create a plan. Returns the Plan as JSON.
pub fn tasks_list_plans( &self, prefix: &str, agent_id: &str, ref_name: &str, ) -> Result<String, JsValue>
pub fn tasks_list_plans_by_status( &self, prefix: &str, agent_id: &str, ref_name: &str, status: Option<String>, ) -> Result<String, JsValue>
pub fn tasks_get_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, ) -> Result<String, JsValue>
pub fn tasks_archive_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, ) -> Result<String, JsValue>
pub fn tasks_delete_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, ) -> Result<(), JsValue>
Sourcepub fn tasks_add_task(
&self,
prefix: &str,
agent_id: &str,
ref_name: &str,
plan: &str,
title: &str,
priority: &str,
parent_id: Option<String>,
blockers_json: Option<String>,
assigned_to: Option<String>,
) -> Result<String, JsValue>
pub fn tasks_add_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, title: &str, priority: &str, parent_id: Option<String>, blockers_json: Option<String>, assigned_to: Option<String>, ) -> Result<String, JsValue>
Add a task. priority is “low”|“medium”|“high”|“critical”.
blockers_json is a JSON array of task id strings (or null).
Sourcepub fn tasks_add_task_with_extensions(
&self,
prefix: &str,
agent_id: &str,
ref_name: &str,
plan: &str,
title: &str,
priority: &str,
parent_id: Option<String>,
blockers_json: Option<String>,
assigned_to: Option<String>,
payload_json: Option<String>,
parent_change: Option<String>,
on_complete_json: Option<String>,
) -> Result<String, JsValue>
pub fn tasks_add_task_with_extensions( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, title: &str, priority: &str, parent_id: Option<String>, blockers_json: Option<String>, assigned_to: Option<String>, payload_json: Option<String>, parent_change: Option<String>, on_complete_json: Option<String>, ) -> Result<String, JsValue>
Add a task with the 0.6.0 extension fields (payload,
parent_change, on_complete). All three are JSON strings; pass
None / null for unset. payload is an arbitrary JSON value,
parent_change a "spec-id@version" handle, on_complete a
JSON-serialized OnCompleteHook.
pub fn tasks_list_tasks( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, ) -> Result<String, JsValue>
pub fn tasks_task_ids( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, ) -> Result<String, JsValue>
pub fn tasks_get_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, ) -> Result<String, JsValue>
pub fn tasks_start_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, ) -> Result<String, JsValue>
Sourcepub fn tasks_complete_task(
&self,
prefix: &str,
agent_id: &str,
ref_name: &str,
plan: &str,
task_id: &str,
proof_kind: &str,
proof_value: &str,
proof_note: Option<String>,
) -> Result<String, JsValue>
pub fn tasks_complete_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, proof_kind: &str, proof_value: &str, proof_note: Option<String>, ) -> Result<String, JsValue>
Complete a task. proof_kind is “commit”|“file”|“test”|“text”.
pub fn tasks_abandon_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, reason: &str, ) -> Result<String, JsValue>
pub fn tasks_set_priority( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, priority: &str, ) -> Result<String, JsValue>
pub fn tasks_set_title( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, title: &str, ) -> Result<String, JsValue>
pub fn tasks_set_blockers( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, blockers_json: &str, ) -> Result<String, JsValue>
pub fn tasks_assign_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, agent: &str, ) -> Result<String, JsValue>
pub fn tasks_unassign_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, ) -> Result<String, JsValue>
pub fn tasks_next_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, ) -> Result<String, JsValue>
pub fn tasks_next_task_for( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, agent: Option<String>, include_unassigned: bool, ) -> Result<String, JsValue>
pub fn tasks_derived_status( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, parent_id: &str, ) -> Result<String, JsValue>
Sourcepub fn migrate_check(
&self,
ref_name: &str,
target: Option<String>,
) -> Result<String, JsValue>
pub fn migrate_check( &self, ref_name: &str, target: Option<String>, ) -> Result<String, JsValue>
Check migration status. Returns a JSON report (see CheckResult).
Sourcepub fn migrate_run(
&self,
ref_name: &str,
target: Option<String>,
mode: &str,
) -> Result<String, JsValue>
pub fn migrate_run( &self, ref_name: &str, target: Option<String>, mode: &str, ) -> Result<String, JsValue>
Run migrations. mode is "apply" or "dry-run".
Sourcepub fn create_session(
&self,
agent_id: &str,
working_branch: Option<String>,
parent_session: Option<String>,
delegated_intent: Option<String>,
report_to: Option<String>,
path_scope: Option<String>,
) -> Result<String, JsValue>
pub fn create_session( &self, agent_id: &str, working_branch: Option<String>, parent_session: Option<String>, delegated_intent: Option<String>, report_to: Option<String>, path_scope: Option<String>, ) -> Result<String, JsValue>
Create a durable session record. Returns the Session as JSON.
Sourcepub fn get_session(&self, id: &str) -> Result<String, JsValue>
pub fn get_session(&self, id: &str) -> Result<String, JsValue>
Fetch a session by id. Returns JSON, or “null” if not found.
Sourcepub fn list_sessions(
&self,
agent_filter: Option<String>,
) -> Result<String, JsValue>
pub fn list_sessions( &self, agent_filter: Option<String>, ) -> Result<String, JsValue>
List sessions, optionally filtered by agent_id.
Sourcepub fn end_session(&self, id: &str, status: &str) -> Result<(), JsValue>
pub fn end_session(&self, id: &str, status: &str) -> Result<(), JsValue>
End a session. status is “active” | “completed” | “abandoned”.
Sourcepub fn taint(
&self,
ref_name: &str,
path: &str,
params_json: &str,
) -> Result<String, JsValue>
pub fn taint( &self, ref_name: &str, path: &str, params_json: &str, ) -> Result<String, JsValue>
Apply a taint. params_json shape:
{"name","effect","reason","severity","expires","propagate","agent_id","metadata"}.
Returns the new taint id.
Sourcepub fn untaint(
&self,
ref_name: &str,
path: &str,
name: &str,
params_json: &str,
) -> Result<(), JsValue>
pub fn untaint( &self, ref_name: &str, path: &str, name: &str, params_json: &str, ) -> Result<(), JsValue>
Resolve a taint by name on path. params_json shape:
{"reason","proof","agent_id"}.
Sourcepub fn quarantine(
&self,
ref_name: &str,
path: &str,
params_json: &str,
) -> Result<String, JsValue>
pub fn quarantine( &self, ref_name: &str, path: &str, params_json: &str, ) -> Result<String, JsValue>
Apply a quarantine. params_json shape:
{"name","reason","severity","authorized_agents","expires","propagate","agent_id"}.
Sourcepub fn unquarantine(
&self,
ref_name: &str,
path: &str,
name: &str,
params_json: &str,
) -> Result<(), JsValue>
pub fn unquarantine( &self, ref_name: &str, path: &str, name: &str, params_json: &str, ) -> Result<(), JsValue>
Release a quarantine. params_json shape matches untaint.
Sourcepub fn watch(
&self,
ref_name: &str,
path: &str,
params_json: &str,
) -> Result<String, JsValue>
pub fn watch( &self, ref_name: &str, path: &str, params_json: &str, ) -> Result<String, JsValue>
Apply a watch. params_json shape:
{"name","reason","metric","threshold","direction","check_interval_secs","expires", "severity","propagate","agent_id"}.
Sourcepub fn unwatch(
&self,
ref_name: &str,
path: &str,
name: &str,
params_json: &str,
) -> Result<(), JsValue>
pub fn unwatch( &self, ref_name: &str, path: &str, name: &str, params_json: &str, ) -> Result<(), JsValue>
Remove a watch. params_json shape: {"reason","agent_id"}.
Sourcepub fn list_taints(
&self,
path_prefix: Option<String>,
kind: Option<String>,
include_resolved: bool,
) -> Result<String, JsValue>
pub fn list_taints( &self, path_prefix: Option<String>, kind: Option<String>, include_resolved: bool, ) -> Result<String, JsValue>
List taints / quarantines / watches. Returns a JSON array of
[Taint] records.
Sourcepub fn check_taint(
&self,
path: &str,
agent_id: Option<String>,
confidence: Option<f64>,
) -> Result<String, JsValue>
pub fn check_taint( &self, path: &str, agent_id: Option<String>, confidence: Option<f64>, ) -> Result<String, JsValue>
Check taint status for path given agent_id + confidence.
Returns a [TaintCheck] JSON object.
Sourcepub fn list_epochs(&self) -> Result<String, JsValue>
pub fn list_epochs(&self) -> Result<String, JsValue>
List epochs. Returns JSON.
Sourcepub fn list_all_epochs(&self) -> Result<String, JsValue>
pub fn list_all_epochs(&self) -> Result<String, JsValue>
List epochs across every workspace. Returns JSON.
list_epochs returns only the active workspace’s epochs. This binding
cannot select a workspace, so without this it could not reach epochs
outside the default one at all.
Trait Implementations§
Source§impl From<WasmAgentStateGraph> for JsValue
impl From<WasmAgentStateGraph> for JsValue
Source§fn from(value: WasmAgentStateGraph) -> Self
fn from(value: WasmAgentStateGraph) -> Self
Source§impl FromWasmAbi for WasmAgentStateGraph
impl FromWasmAbi for WasmAgentStateGraph
Source§impl IntoWasmAbi for WasmAgentStateGraph
impl IntoWasmAbi for WasmAgentStateGraph
Source§impl LongRefFromWasmAbi for WasmAgentStateGraph
impl LongRefFromWasmAbi for WasmAgentStateGraph
Source§type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>
type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmAgentStateGraph>
type Anchor = RcRef<WasmAgentStateGraph>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl RefFromWasmAbi for WasmAgentStateGraph
impl RefFromWasmAbi for WasmAgentStateGraph
Source§type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>
type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>
Self are recovered from.Source§type Anchor = RcRef<WasmAgentStateGraph>
type Anchor = RcRef<WasmAgentStateGraph>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmAgentStateGraph
impl RefMutFromWasmAbi for WasmAgentStateGraph
Source§type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>
type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmAgentStateGraph>
type Anchor = RcRefMut<WasmAgentStateGraph>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for WasmAgentStateGraph
impl SupportsInstanceProperty for WasmAgentStateGraph
impl SupportsStaticProperty for WasmAgentStateGraph
Source§impl TryFromJsValue for WasmAgentStateGraph
impl TryFromJsValue for WasmAgentStateGraph
Source§impl VectorFromWasmAbi for WasmAgentStateGraph
impl VectorFromWasmAbi for WasmAgentStateGraph
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmAgentStateGraph]>
Source§impl VectorIntoWasmAbi for WasmAgentStateGraph
impl VectorIntoWasmAbi for WasmAgentStateGraph
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmAgentStateGraph]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmAgentStateGraph
impl WasmDescribeVector for WasmAgentStateGraph
Auto Trait Implementations§
impl !RefUnwindSafe for WasmAgentStateGraph
impl !UnwindSafe for WasmAgentStateGraph
impl Freeze for WasmAgentStateGraph
impl Send for WasmAgentStateGraph
impl Sync for WasmAgentStateGraph
impl Unpin for WasmAgentStateGraph
impl UnsafeUnpin for WasmAgentStateGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.