Skip to main content

Client

Struct Client 

Source
pub struct Client {
    pub commit_author_name: String,
    pub commit_author_email: String,
    /* private fields */
}
Expand description

On-disk layout root + state selection.

<dir>                              default: ~/.objectiveai
├── bin/                           ── shared across states ──
│   ├── objectiveai[.exe]          (+ -api, -viewer, -mcp, -db)
│   ├── pg-bin/                    postgres install (objectiveai-db)
│   ├── plugins/<owner>/<name>/<version>/
│   └── tools/<owner>/<name>/<version>/
└── state/<state>/                 default state: "default"
    ├── config.json
    ├── db/  .pgpass  db.lock      (cluster, per state)
    ├── logs/
    └── instances/agents/

Binaries, the postgres install, plugins and tools are machine-wide (Self::bin_dir); everything else is per-state (Self::state_dir), so independent states coexist under one install by switching OBJECTIVEAI_STATE.

Fields§

§commit_author_name: String§commit_author_email: String

Implementations§

Source§

impl Client

Source

pub fn new( dir: Option<impl Into<PathBuf>>, state: Option<impl Into<String>>, commit_author_name: Option<impl Into<String>>, commit_author_email: Option<impl Into<String>>, ) -> Self

Resolution per field: explicit arg → env (OBJECTIVEAI_DIR / OBJECTIVEAI_STATE, feature env) → default (~/.objectiveai / "default").

Panics when the state name doesn’t match [A-Za-z0-9_-]+ — state names become directory names under <dir>/state/, so separators, dot-segments, and empty names are rejected outright.

Source

pub fn dir(&self) -> &PathBuf

The layout root (OBJECTIVEAI_DIR). Forward this (with Self::state) to child processes so they resolve the same tree.

Source

pub fn state(&self) -> &str

The state name (OBJECTIVEAI_STATE).

Source

pub fn bin_dir(&self) -> PathBuf

<dir>/bin — binaries, the postgres install, plugins, tools. Shared across every state.

Source

pub fn state_dir(&self) -> PathBuf

<dir>/state/<state> — config, database cluster, logs, agent registry. Per state.

Source

pub fn config_path(&self) -> PathBuf

Per-state config: <dir>/state/<state>/config.json.

Source

pub fn global_config_path(&self) -> PathBuf

Machine-wide (global) config: <dir>/bin/config.json — lives with the other machine-wide artifacts.

Source

pub fn logs_dir(&self) -> PathBuf

Source§

impl Client

Source

pub async fn read_config(&self) -> Result<Config, Error>

Source

pub async fn write_config(&self, config: &Config) -> Result<(), Error>

Source

pub async fn read_config_at(&self, scope: SetScope) -> Result<Config, Error>

Read the config file a MUTATION targets — no merging, ever: --global edits <dir>/bin/config.json, --state edits <dir>/state/<state>/config.json. Missing file = defaults.

Source

pub async fn write_config_at( &self, scope: SetScope, config: &Config, ) -> Result<(), Error>

Write back the file Self::read_config_at selected.

Source

pub async fn read_config_view(&self, scope: GetScope) -> Result<Config, Error>

Read the config VIEW a get targets: --global and --state return their file verbatim; --final joins them — the global (root) config is the base and the per-state config is layered on top, winning every conflict (recursively: maps like api.mcp_authorization union per key with the per-state entry overwriting the global one).

Source§

impl Client

Source

pub fn plugins_dir(&self) -> PathBuf

The plugins directory: <bin_dir>/plugins — installed plugins are machine-wide, shared by every state.

Source

pub fn plugin_dir(&self, owner: &str, name: &str, version: &str) -> PathBuf

The directory that holds a plugin’s installed artifacts: <plugins_dir>/<owner>/<name>/<version>/. Contains the manifest objectiveai.json, the cli/ exec working directory, and an optional viewer/ bundle.

Source

pub fn plugin_cli_dir(&self, owner: &str, name: &str, version: &str) -> PathBuf

A plugin’s cli working directory: <plugin_dir>/cli/. The manifest’s exec runs with this as CWD; cli_zip extracts into it at install time.

Source

pub async fn resolve_plugin( &self, owner: &str, name: &str, version: &str, ) -> Option<(Vec<String>, PathBuf)>

Resolve a plugin coordinate to its (exec_vector, cli_dir) for the current platform — the same contract Client::resolve_tool has, with the plugin’s cli/ folder as the working directory. exec_vector may be empty when the manifest declares no command for this platform (viewer-only plugins; the caller treats that as an error). None when the manifest is missing/malformed/invalid.

Source

pub async fn get_plugin( &self, owner: &str, name: &str, version: &str, ) -> Option<ManifestWithNameAndSource>

Look up a single plugin manifest by coordinate. Reads <base_dir>/plugins/<owner>/<name>/<version>/objectiveai.json. Returns None if the file is missing, unreadable, malformed, or invalid.

Source

pub async fn list_plugins( &self, offset: usize, limit: usize, ) -> Vec<ManifestWithNameAndSource>

Enumerate plugin manifests by walking the plugins/<owner>/<name>/<version>/objectiveai.json tree. Every failure mode — missing dir, unreadable file, malformed JSON, missing required field — is silently skipped; the return type is plain Vec rather than Result to reflect that.

Results are sorted by manifest mtime descending (most recently modified first), then skip(offset).take(limit) is applied — matching the convention of the logs list endpoints. Pass (0, usize::MAX) for an unbounded list.

The directory walk is sequential but per-file read+parse runs concurrently via futures::future::join_all.

Source§

impl Client

Source

pub async fn install_plugin( &self, owner: &str, repository: &str, commit_sha: Option<&str>, headers: Option<&IndexMap<String, String>>, upgrade: bool, ) -> Result<bool, Error>

Install a plugin from a GitHub repository.

  1. Fetches objectiveai.json from raw.githubusercontent.com at the supplied commit_sha (or the default branch via HEAD when none).
  2. Parses it as a Manifest.
  3. Downloads the declared release assets from https://github.com/<owner>/<repository>/releases/download/v<version>/<asset>: cli_zip (when declared) extracts into <plugin dir>/cli/, viewer_zip into …/viewer/. Neither is required — a manifest whose exec invokes PATH-resolved programs installs with just the manifest.

headers is an optional IndexMap<String, String> that gets attached to every HTTP request (e.g. Authorization for private repos / higher rate limits). The cli always passes None.

Failures are returned as super::InstallError wrapped by super::super::Error::Install. The bool is retained for wire compatibility and is always true on success — the platform gate that used to yield Ok(false) died with the per-platform binaries map (per-OS support is now expressed by the exec vectors themselves).

Source

pub async fn fetch_plugin_manifest( &self, owner: &str, repository: &str, commit_sha: Option<&str>, headers: Option<&IndexMap<String, String>>, ) -> Result<Manifest, Error>

Step 1 of install_plugin: fetch <owner>/<repo>/<ref>/objectiveai.json from raw.githubusercontent.com and parse it as a Manifest. Exposed publicly so callers can inspect the manifest before committing to an install (e.g. for whitelist checks).

Source

pub async fn install_plugin_from_manifest( &self, owner: &str, repository: &str, manifest: &Manifest, source: &str, headers: Option<&IndexMap<String, String>>, upgrade: bool, ) -> Result<bool, Error>

Step 2 of install_plugin: given an already-parsed manifest, download its declared release assets (cli_zipcli/, viewer_zipviewer/) and persist the manifest.

Source§

impl Client

Source

pub fn tools_dir(&self) -> PathBuf

The tools directory: <bin_dir>/tools.

Source

pub fn tool_dir(&self, owner: &str, name: &str, version: &str) -> PathBuf

A tool’s version directory: <base_dir>/tools/<owner>/<name>/<version>.

Source

pub async fn resolve_tool( &self, owner: &str, name: &str, version: &str, ) -> Option<(Vec<String>, PathBuf)>

Resolve a tool coordinate to its (exec_vector, cwd) for the current platform. cwd is the version folder; exec_vector is the manifest’s per-OS command (possibly empty when the tool declares no command for this platform — the caller treats that as an error). None when the manifest is missing/malformed.

Source

pub async fn get_tool( &self, owner: &str, name: &str, version: &str, ) -> Option<ManifestWithNameAndSource>

Look up a single tool manifest by coordinate. Reads <base_dir>/tools/<owner>/<name>/<version>/objectiveai.json. None on missing / unreadable / malformed files.

Source

pub async fn list_tools( &self, offset: usize, limit: usize, ) -> Vec<ManifestWithNameAndSource>

Enumerate tool manifests by walking the tools/<owner>/<name>/<version>/objectiveai.json tree. Every failure mode — missing dir, unreadable file, malformed JSON — is silently skipped.

Results are sorted by manifest mtime descending, then skip(offset).take(limit) is applied — matching list_plugins. Pass (0, usize::MAX) for an unbounded list.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more