#[non_exhaustive]pub struct AgentRecord {Show 19 fields
pub id: String,
pub display_name: String,
pub color: AvatarColor,
pub description: String,
pub instructions: String,
pub area: PartitionId,
pub mode: PartitionMode,
pub model: Option<ModelChoice>,
pub uses: AgentUses,
pub daily_limit_micro_usd: Option<u64>,
pub state: AgentRecordState,
pub origin: AgentOrigin,
pub created_by: SubjectRef,
pub approved_by: Option<SubjectRef>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub version: u64,
pub digest: String,
pub changed_on: Option<String>,
}Expand description
An agent the kernel keeps (spec 3.3 §5.7, §10 K7): its definition, beside its id, state, how it was added, who added and approved it, when, a version per change and the digest of its definition.
§Example
use adk_core::principal::SubjectRef;
use adk_kernel::agents::{AgentDefinition, AgentOrigin, AgentRecord, AgentRecordState};
let record = AgentRecord::new(
"finance",
AgentDefinition::new("Finance", "default"),
AgentRecordState::Active,
AgentOrigin::ByHand,
SubjectRef::human("alice"),
chrono::Utc::now(),
);
assert_eq!(record.version, 1);
assert_eq!(record.digest, record.definition().digest());
assert!(record.validate().is_ok());
let wire = serde_json::to_value(&record).unwrap();
assert_eq!(wire["displayName"], "Finance");
assert_eq!(serde_json::from_value::<AgentRecord>(wire).unwrap(), record);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringThe id, given once from its first name: its kernel target, its root agent name and
the last part of its identity, urn:adk:agent:{app}/{id}.
display_name: StringThe name on screen.
color: AvatarColorThe avatar colour.
description: StringWhat it does, one line.
instructions: StringHow it works.
area: PartitionIdIts area.
mode: PartitionModeHow much it asks first.
model: Option<ModelChoice>The model it runs on; None for the primary agent’s.
uses: AgentUsesWhat it can use.
daily_limit_micro_usd: Option<u64>Its daily spending limit in micro-USD.
state: AgentRecordStateWhere it is in its life.
origin: AgentOriginHow it was added.
created_by: SubjectRefWho added it: the person who set it up, or the suggesting agent.
approved_by: Option<SubjectRef>The person who approved its suggestion.
created_at: DateTime<Utc>When it was first stored.
updated_at: DateTime<Utc>When it last changed.
version: u641 when first stored, one more with every change; the compare-and-set token.
digest: StringThe digest of its definition (AgentDefinition::digest).
changed_on: Option<String>The surface its last change was made on — web, terminal, phone — or inbox
for a suggestion approved where the kernel cannot tell; a change refused as out of
date names it (spec 3.3 §5.7).
Implementations§
Source§impl AgentRecord
impl AgentRecord
Sourcepub fn new(
id: impl Into<String>,
definition: AgentDefinition,
state: AgentRecordState,
origin: AgentOrigin,
created_by: SubjectRef,
at: DateTime<Utc>,
) -> Self
pub fn new( id: impl Into<String>, definition: AgentDefinition, state: AgentRecordState, origin: AgentOrigin, created_by: SubjectRef, at: DateTime<Utc>, ) -> Self
A record of definition under id, at version 1, created at at.
Sourcepub fn definition(&self) -> AgentDefinition
pub fn definition(&self) -> AgentDefinition
Its definition.
Sourcepub fn with_definition(self, definition: AgentDefinition) -> Self
pub fn with_definition(self, definition: AgentDefinition) -> Self
The record with definition in place of its own and the digest recomputed; the
area is the record’s own whatever definition says (K-I15). The version and times
are the agent table’s to move.
Sourcepub fn with_state(self, state: AgentRecordState) -> Self
pub fn with_state(self, state: AgentRecordState) -> Self
Sets the state.
Sourcepub fn with_approved_by(self, by: SubjectRef) -> Self
pub fn with_approved_by(self, by: SubjectRef) -> Self
Sets the person who approved it.
Sourcepub fn with_changed_on(self, surface: impl Into<String>) -> Self
pub fn with_changed_on(self, surface: impl Into<String>) -> Self
Sets the surface its last change was made on.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Checks the id (check_agent_id) and the definition (AgentDefinition::validate),
and that the digest is the definition’s.
§Errors
Returns a kernel.agent.invalid error saying which rule the record breaks.
Sourcepub fn principal(&self, app_name: &str, area: &Partition) -> AgentPrincipal
pub fn principal(&self, app_name: &str, area: &Partition) -> AgentPrincipal
The agent’s identity in area (spec 3.3 §5.7): urn:adk:agent:{app}/{id} with the
area’s class, tenant and partition attribute, and as its sponsor the person who
approved it, or who added it by hand.
§Example
use adk_core::principal::SubjectRef;
use adk_kernel::agents::{AgentDefinition, AgentOrigin, AgentRecord, AgentRecordState};
use adk_kernel::Partition;
let record = AgentRecord::new("finance", AgentDefinition::new("Finance", "home"),
AgentRecordState::Active, AgentOrigin::ByHand, SubjectRef::human("alice"), chrono::Utc::now());
let principal = record.principal("adk-rust", &Partition::new("home", "home"));
assert_eq!(principal.id.as_str(), "urn:adk:agent:adk-rust/finance");
assert_eq!(principal.class.as_deref(), Some("home"));
assert_eq!(principal.sponsor, Some(SubjectRef::human("alice")));Trait Implementations§
Source§impl Clone for AgentRecord
impl Clone for AgentRecord
Source§impl Debug for AgentRecord
impl Debug for AgentRecord
Source§impl<'de> Deserialize<'de> for AgentRecord
impl<'de> Deserialize<'de> for AgentRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AgentRecord
Source§impl PartialEq for AgentRecord
impl PartialEq for AgentRecord
Source§impl Serialize for AgentRecord
impl Serialize for AgentRecord
impl StructuralPartialEq for AgentRecord
Auto Trait Implementations§
impl Forget for AgentRecord
impl Freeze for AgentRecord
impl Move for AgentRecord
impl RefUnwindSafe for AgentRecord
impl Send for AgentRecord
impl Sync for AgentRecord
impl Unpin for AgentRecord
impl UnsafeUnpin for AgentRecordwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
impl UnwindSafe for AgentRecord
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.