Merge branch 'development' into development_heroprompt_v2

This commit is contained in:
Mahmoud-Emad
2025-09-07 14:52:43 +03:00
2 changed files with 54 additions and 53 deletions

View File

@@ -24,7 +24,7 @@ fn (mut executor ExecutorCrun) init() ! {
}
// Parse state to ensure container is running
if !result.contains('"status":"running"') {
if !result.output.contains('"status":"running"') {
return error('Container ${executor.container_id} is not running')
}
}
@@ -126,7 +126,10 @@ pub fn (mut executor ExecutorCrun) upload(args SyncArgs) ! {
if src_path.is_dir() {
// For directories, use tar to transfer
temp_tar := '/tmp/crun_upload_${rand.uuid_v4()}.tar'
osal.exec(cmd: 'tar -cf ${temp_tar} -C ${src_path.path_dir()} ${src_path.name()}', stdout: false)!
osal.exec(
cmd: 'tar -cf ${temp_tar} -C ${src_path.path_dir()} ${src_path.name()}'
stdout: false
)!
defer { os.rm(temp_tar) or {} }
// Extract in container
@@ -148,7 +151,10 @@ pub fn (mut executor ExecutorCrun) download(args SyncArgs) ! {
defer { os.rm(temp_tar) or {} }
// Extract on host
osal.exec(cmd: 'mkdir -p ${args.dest} && tar -xf ${temp_tar} -C ${args.dest}', stdout: args.stdout)!
osal.exec(
cmd: 'mkdir -p ${args.dest} && tar -xf ${temp_tar} -C ${args.dest}'
stdout: args.stdout
)!
} else {
// For single files
content := executor.file_read(args.source)!
@@ -164,9 +170,9 @@ pub fn (mut executor ExecutorCrun) environ_get() !map[string]string {
mut res := map[string]string{}
for line in env.split('\n') {
if line.contains('=') {
parts := line.split_once('=') or { continue }
key := parts[0].trim(' ')
val := parts[1].trim(' ')
mut key, mut val := line.split_once('=') or { continue }
key = key.trim(' ')
val = val.trim(' ')
res[key] = val
}
}
@@ -175,9 +181,9 @@ pub fn (mut executor ExecutorCrun) environ_get() !map[string]string {
pub fn (mut executor ExecutorCrun) info() map[string]string {
return {
'category': 'crun'
'category': 'crun'
'container_id': executor.container_id
'runtime': 'crun'
'runtime': 'crun'
}
}

View File

@@ -2,29 +2,21 @@ module console
import freeflowuniverse.herolib.core.texttools
pub struct ConsoleFactory {
pub mut:
__global (
consoles map[string]&UIConsole
silent bool
)
pub fn silent_set() {
silent = true
}
pub fn new_console_factory() &ConsoleFactory {
return &ConsoleFactory{
consoles: map[string]&UIConsole{}
silent: false
}
pub fn silent_unset() {
silent = false
}
pub fn (mut cf ConsoleFactory) silent_set() {
cf.silent = true
}
pub fn (mut cf ConsoleFactory) silent_unset() {
cf.silent = false
}
pub fn (cf ConsoleFactory) silent_get() bool {
return cf.silent
pub fn silent_get() bool {
return silent
}
pub struct UIConsole {
@@ -56,14 +48,17 @@ pub fn (mut c UIConsole) status() string {
return out.trim_space()
}
pub fn (mut cf ConsoleFactory) new_console() &UIConsole {
mut c := UIConsole{}
cf.consoles['main'] = &c
return &c
pub fn new() UIConsole {
return UIConsole{}
}
pub fn (cf ConsoleFactory) get_console() &UIConsole {
return cf.consoles['main'] or { panic('bug') }
fn init() {
mut c := UIConsole{}
consoles['main'] = &c
}
fn get() &UIConsole {
return consoles['main'] or { panic('bug') }
}
pub fn trim(c_ string) string {
@@ -72,12 +67,12 @@ pub fn trim(c_ string) string {
}
// line feed
pub fn (mut cf ConsoleFactory) lf() {
mut c := cf.get_console()
pub fn lf() {
mut c := get()
if c.prev_lf {
return
}
if !cf.silent_get() {
if !silent_get() {
print('\n')
}
c.prev_lf = true