pub struct HttpRequestTool { /* private fields */ }Implementations§
Source§impl HttpRequestTool
impl HttpRequestTool
pub const AUTH_PROFILE_NAMESPACE: &'static str = "auth_profile:"
pub const ACCOUNT_NAMESPACE: &'static str = "account:"
Sourcepub fn new(profiles: Arc<RwLock<HashMap<String, HttpAuthProfile>>>) -> Self
pub fn new(profiles: Arc<RwLock<HashMap<String, HttpAuthProfile>>>) -> Self
The owner’s approval is asked by the agent kernel (its
ApprovalPolicy with the daemon’s rules, from
HttpRequestTool::owner_approval_request), never by the tool.
pub fn with_oauth_gateway(self, gateway: impl OAuthTokens + 'static) -> Self
pub async fn set_oauth_gateway(&self, gateway: impl OAuthTokens + 'static)
Sourcepub fn domain_matches(request_domain: &str, allowed: &str) -> bool
pub fn domain_matches(request_domain: &str, allowed: &str) -> bool
Check if a request domain is allowed by the profile’s allowed_domains. Supports exact match and subdomain match (api.twitter.com matches twitter.com) but NOT suffix tricks (evil-twitter.com does NOT match twitter.com).
pub fn auth_profile_resource_id(profile_name: &str) -> String
Sourcepub fn apply_auth(
builder: RequestBuilder,
profile: &HttpAuthProfile,
method: &str,
url: &str,
body: Option<&str>,
content_type: Option<&str>,
) -> Result<RequestBuilder>
pub fn apply_auth( builder: RequestBuilder, profile: &HttpAuthProfile, method: &str, url: &str, body: Option<&str>, content_type: Option<&str>, ) -> Result<RequestBuilder>
Apply auth to a request builder based on profile auth_type.
Sourcepub fn owner_approval_request(args: &Value) -> Option<OwnerApprovalRequest>
pub fn owner_approval_request(args: &Value) -> Option<OwnerApprovalRequest>
The owner approval a request needs (H7), from its arguments as the
model wrote them: none for a GET, HEAD or OPTIONS without a body or a
method or authority override header, unless it targets a local site
(one card per site, naming only the site); anything else asks, High
risk, with subject "{METHOD} {url}" (the canonical URL, so grants
match it exactly) and up to 500 characters of the body in the summary.
Sourcepub fn owner_approval_request_for(
args: &Value,
grant_session: &str,
) -> Option<OwnerApprovalRequest>
pub fn owner_approval_request_for( args: &Value, grant_session: &str, ) -> Option<OwnerApprovalRequest>
Self::owner_approval_request for a call made for the work in
grant_session: a read (GET, HEAD or OPTIONS without a body or an
override header) of a local site that work brought up itself
(crate::local_sites::is_work_owned) needs no card, as the
browser opens it without one. A site the owner only named, or one on
the daemon’s own listener, still asks; a write always asks.
Sourcepub fn extract_canonical_created_resource_id(body: &[u8]) -> Option<String>
pub fn extract_canonical_created_resource_id(body: &[u8]) -> Option<String>
Canonical id of the resource a write created, read from the raw
response body (machine-format JSON, before any truncation or display
formatting): /data/id, then /id, as a string or an unsigned
integer. Only [A-Za-z0-9_-]{1,64} is accepted, so whitespace,
quotes, URLs and prose never pass through.
Trait Implementations§
Source§impl OutcomeTool for HttpRequestTool
impl OutcomeTool for HttpRequestTool
fn name(&self) -> &str
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
arguments: &'life1 str,
facts: &'life2 ToolCallContext,
) -> Pin<Box<dyn Future<Output = Result<ToolCallOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
arguments: &'life1 str,
facts: &'life2 ToolCallContext,
) -> Pin<Box<dyn Future<Output = Result<ToolCallOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Err is a failed call whose message the model reads.Source§fn validate_call(&self, _arguments: &Value) -> Result<(), String>
fn validate_call(&self, _arguments: &Value) -> Result<(), String>
Source§fn holds_to_medium_ceiling(&self, _arguments: &str) -> bool
fn holds_to_medium_ceiling(&self, _arguments: &str) -> bool
false: the call is judged from its effects.Source§fn approval_card_mode(&self) -> Option<PermissionMode>
fn approval_card_mode(&self) -> Option<PermissionMode>
None: the default, Cautious.Source§fn approval_card_kind(&self, _request: &OwnerApprovalRequest) -> ApprovalKind
fn approval_card_kind(&self, _request: &OwnerApprovalRequest) -> ApprovalKind
request (from
ToolSemantics::owner_approval_request) with, which picks the
buttons offered: a one-time card or a goal confirmation offers no
session or persistent grant. The default is a standard command card.Source§fn approval_grant<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 ApprovalCall<'life2>,
_facts: &'life3 ToolCallContext,
) -> Pin<Box<dyn Future<Output = Option<GrantOffer>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn approval_grant<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 ApprovalCall<'life2>,
_facts: &'life3 ToolCallContext,
) -> Pin<Box<dyn Future<Output = Option<GrantOffer>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
call (from
ToolSemantics::owner_approval_request): the typed scope an
approval covers and the longest it may last. The runtime captures
the offer when it asks, so the answer is recorded for the scope the
card showed even if live state changed meanwhile; it sends the card
with no button beyond max and caps an answer to it. With a
reusable scope (crate::semantics::GrantScope::is_reusable) and a
tool that does not keep its own grants, a session answer is kept in
ToolCallContext::scoped_grants and later calls in that scope run
without a card. None (the default): the card covers the exact
call, as the tool’s Self::approval_card_kind and
Self::approval_card_mode say.Source§fn record_owner_answer<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 ApprovalCall<'life2>,
_facts: &'life3 ToolCallContext,
_response: Option<ApprovalResponse>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn record_owner_answer<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 ApprovalCall<'life2>,
_facts: &'life3 ToolCallContext,
_response: Option<ApprovalResponse>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
call (from
ToolSemantics::owner_approval_request) to the tool’s own grant
stores. None: the card timed out or never reached the owner. The
default keeps nothing; the kernel’s session grants are separate.Source§impl ToolSemantics for HttpRequestTool
impl ToolSemantics for HttpRequestTool
Source§fn validate_arguments(
&self,
arguments: &str,
) -> Result<(), ToolArgumentContractViolation>
fn validate_arguments( &self, arguments: &str, ) -> Result<(), ToolArgumentContractViolation>
A body declared as JSON must parse. Rejected here, before any grant is reserved or byte is sent, the caller can fix it and call again.
Source§fn owner_approval_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
call: &'life1 ApprovalCall<'life2>,
facts: &'life3 ToolCallContext,
) -> Pin<Box<dyn Future<Output = OwnerApprovalNeed> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn owner_approval_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
call: &'life1 ApprovalCall<'life2>,
facts: &'life3 ToolCallContext,
) -> Pin<Box<dyn Future<Output = OwnerApprovalNeed> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
H7: a trusted scheduled session or a mandate run (whose exact action grant the dispatcher checks) needs no card; otherwise a GET, HEAD or OPTIONS without a body or override header runs and anything else asks, High risk.
Source§fn call_outbound(&self, arguments: &str) -> Outbound
fn call_outbound(&self, arguments: &str) -> Outbound
Only the URL leaves on a plain read. Anything else the call adds (query parameters, headers, a body) is text the model wrote.
Source§fn call_effects(&self, arguments: &str) -> CallEffects
fn call_effects(&self, arguments: &str) -> CallEffects
The request’s host (host:port, the URL’s port or else the scheme’s
default) and the stored credential profile it uses, after the same
URL canonicalization the request runs with (tool parameters embedded
in the query are recovered first).
Source§fn call_annotations_in(
&self,
arguments: &str,
_roots: &TrustRoots<'_>,
) -> ToolAnnotations
fn call_annotations_in( &self, arguments: &str, _roots: &TrustRoots<'_>, ) -> ToolAnnotations
Owner credentials turn any method into egress: a credentialed GET can still trigger actions or leak the account’s data.
Source§fn dispatch_facts(&self) -> ToolDispatchFacts
fn dispatch_facts(&self) -> ToolDispatchFacts
Source§fn capabilities(&self) -> ToolCapabilities
fn capabilities(&self) -> ToolCapabilities
Source§fn stable_observation_subjects(&self) -> Vec<StableObservationSubject>
fn stable_observation_subjects(&self) -> Vec<StableObservationSubject>
Source§fn call_semantics(&self, arguments: &str) -> ToolCallSemantics
fn call_semantics(&self, arguments: &str) -> ToolCallSemantics
Source§fn canonicalize_arguments(
&self,
arguments: &str,
) -> Result<String, ToolArgumentContractViolation>
fn canonicalize_arguments( &self, arguments: &str, ) -> Result<String, ToolArgumentContractViolation>
Source§fn on_task_end<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
_session_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_task_end<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
_session_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
TaskEnd.
Tools that spawn background activity can use this to clean up
task-scoped resources.Source§fn session_context_note<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn session_context_note<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn background_jobs<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundJob>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn background_jobs<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Vec<BackgroundJob>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
session_id
(they outlive the turn that started them), as the chat’s list of
running work shows them.Source§fn stop_background_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop_background_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
key (from Self::background_jobs) and
read its state back: true only once the job is gone.Source§fn jobs_ended_by_task_end<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn jobs_ended_by_task_end<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
task_id started that are still running and that
the task’s end would stop: nothing reports their result, so a run that
ended now would lose their work.Source§fn set_stop_held(&self, _task_id: &str, _held: bool)
fn set_stop_held(&self, _task_id: &str, _held: bool)
held) or stops holding its answer until task
task_id’s jobs (Self::jobs_ended_by_task_end) end. Only while a
run holds may a tool stop such a job for making no progress: while
the run still works, a quiet job (a test server it still uses) is the
run’s own. Holds nest; each start is matched by one stop.Source§fn set_run_live(&self, _task_id: &str, _live: bool)
fn set_run_live(&self, _task_id: &str, _live: bool)
task_id starts (live) or ends, however it ends:
returning, failing, or being cancelled (its future dropped, so its
task-end cleanup never runs). A job whose task has no live run and no
hold (Self::set_stop_held) is nobody’s: a tool may stop it for
making no progress. Runs of one task nest; each start is matched by
one end.Source§fn tool_role(&self) -> ToolRole
fn tool_role(&self) -> ToolRole
Source§fn owner_control_plane(&self) -> bool
fn owner_control_plane(&self) -> bool
owner_control_plane_call
accepts are admitted there.Source§fn owner_control_plane_call(&self, _arguments: &str) -> bool
fn owner_control_plane_call(&self, _arguments: &str) -> bool
Source§fn receipt_kind(&self, _arguments: &str) -> ToolReceiptKind
fn receipt_kind(&self, _arguments: &str) -> ToolReceiptKind
Source§fn call_access_manifest(&self, arguments: &str) -> ToolCallAccessManifest
fn call_access_manifest(&self, arguments: &str) -> ToolCallAccessManifest
Source§fn guarded_paths(&self, arguments: &str) -> (Vec<String>, Vec<String>)
fn guarded_paths(&self, arguments: &str) -> (Vec<String>, Vec<String>)
ProtectedPathGuard judges
them. Defaults to the access manifest; a tool overrides it for a path
that scope checks must not see as a task read.Source§fn adapter_owned_access_manifest(
&self,
_arguments: &str,
) -> ToolCallAccessManifest
fn adapter_owned_access_manifest( &self, _arguments: &str, ) -> ToolCallAccessManifest
Source§fn durable_replay_decision<'life0, 'life1, 'async_trait>(
&'life0 self,
_arguments: &'life1 str,
) -> Pin<Box<dyn Future<Output = DurableReplayDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn durable_replay_decision<'life0, 'life1, 'async_trait>(
&'life0 self,
_arguments: &'life1 str,
) -> Pin<Box<dyn Future<Output = DurableReplayDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn call_file_write(&self, _arguments: &str) -> Option<FileWrite>
fn call_file_write(&self, _arguments: &str) -> Option<FileWrite>
Source§fn file_write_result(
&self,
_arguments: &str,
_current: Option<&[u8]>,
) -> Option<Result<Vec<u8>, String>>
fn file_write_result( &self, _arguments: &str, _current: Option<&[u8]>, ) -> Option<Result<Vec<u8>, String>>
current now (None: no such file). Err is the tool’s own reason
the call cannot apply to that content. A tool that cannot say returns
None, and a host that asks then treats the call as changing all of
the file.Source§fn named_files(&self, arguments: &str) -> Vec<String>
fn named_files(&self, arguments: &str) -> Vec<String>
Source§fn output_trust(&self, _arguments: &str, _roots: &TrustRoots<'_>) -> SourceTrust
fn output_trust(&self, _arguments: &str, _roots: &TrustRoots<'_>) -> SourceTrust
Untrusted iff the tool reaches outside the machine
(external_side_effect); local tools override with the owner’s
trusted roots.