Merge pull request #596 from kinode-dao/hf/terminal-m-caps

terminal: m caps
This commit is contained in:
nick.kino 2024-12-05 08:36:28 -08:00 committed by GitHub
commit df6e97b128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 4 deletions

View File

@ -13,6 +13,23 @@
"grant_capabilities": [ "grant_capabilities": [
"eth:distro:sys", "eth:distro:sys",
"http-server:distro:sys", "http-server:distro:sys",
"terminal:terminal:sys",
{
"process": "terminal:terminal:sys",
"params": "ReadNameOnly"
},
{
"process": "terminal:terminal:sys",
"params": "Read"
},
{
"process": "terminal:terminal:sys",
"params": "Add"
},
{
"process": "terminal:terminal:sys",
"params": "Remove"
},
"vfs:distro:sys" "vfs:distro:sys"
], ],
"public": false "public": false

View File

@ -1,5 +1,5 @@
use clap::{Arg, Command}; use clap::{Arg, Command};
use kinode_process_lib::{println, script, Address, Request, SendErrorKind}; use kinode_process_lib::{our_capabilities, println, script, Address, Request, SendErrorKind};
use regex::Regex; use regex::Regex;
wit_bindgen::generate!({ wit_bindgen::generate!({
@ -10,7 +10,7 @@ wit_bindgen::generate!({
const USAGE: &str = "\x1b[1mUsage:\x1b[0m m <target> <body> [-a <await_time>]"; const USAGE: &str = "\x1b[1mUsage:\x1b[0m m <target> <body> [-a <await_time>]";
script!(init); script!(init);
fn init(_our: Address, args: String) -> String { fn init(our: Address, args: String) -> String {
if args.is_empty() { if args.is_empty() {
return format!("Send a request to a process.\n{USAGE}"); return format!("Send a request to a process.\n{USAGE}");
} }
@ -58,7 +58,21 @@ fn init(_our: Address, args: String) -> String {
return format!("No body given.\n{USAGE}"); return format!("No body given.\n{USAGE}");
}; };
let req = Request::new().target(target).body(body.as_bytes().to_vec()); let target = if target.node() != "our" {
target
} else {
Address::new(our.node(), target.process)
};
let capabilities = our_capabilities()
.into_iter()
.filter(|cap| cap.issuer == target)
.collect();
let req = Request::new()
.target(target)
.body(body.as_bytes().to_vec())
.capabilities(capabilities);
match parsed.get_one::<u64>("await") { match parsed.get_one::<u64>("await") {
Some(s) => { Some(s) => {

View File

@ -6,7 +6,6 @@
"request_networking": true, "request_networking": true,
"request_capabilities": [ "request_capabilities": [
"app-store:app-store:sys", "app-store:app-store:sys",
"contacts:contacts:sys",
"chess:chess:sys", "chess:chess:sys",
"eth:distro:sys", "eth:distro:sys",
{ {