feat(foreign): structured invoke, presets, probe and config
F0/F1: safe execution core (exec gate, bounded IO, process-group timeout), structured invoke records, run options, 15 language presets, register/unset/probe/config, view stderr/exit/ms, and node/bash gold tests.
This commit is contained in:
1 parent
c21a28c3bc
commit
e32ff8f6b3
21 files changed
+2301
-282
No files matched your search
+79
-6
@@ -8,29 +8,102 @@ Run bound code fences and inline sources via local interpreters.
|
||||
## set_cmd
|
||||
+ `lang`
|
||||
+ `cmd`
|
||||
+ `args`=None
|
||||
|
||||
Bind interpreter command cmd for language lang.
|
||||
Bind interpreter command cmd for language lang; optional extra argv.
|
||||
|
||||
*> host_foreign_set_cmd lang=`lang` cmd=`cmd`*
|
||||
*> host_foreign_set_cmd lang=`lang` cmd=`cmd` args=`args`*
|
||||
|
||||
## run
|
||||
+ `code`
|
||||
+ `stdin`=None
|
||||
+ `env`=None
|
||||
+ `cwd`=None
|
||||
+ `timeout`=None
|
||||
+ `args`=None
|
||||
+ `max_output`=None
|
||||
|
||||
Run a bound code fence value; optional stdin.
|
||||
Run a bound code fence value; optional stdin, env map, cwd, timeout (seconds),
|
||||
extra argv and output cap. Returns stdout text; non-zero exit is an error.
|
||||
|
||||
Caller: [foreign.run] code=`block`
|
||||
|
||||
*> host_foreign_run code=`code` stdin=`stdin`*
|
||||
*> host_foreign_run code=`code` stdin=`stdin` env=`env` cwd=`cwd` timeout=`timeout` args=`args` max_output=`max_output`*
|
||||
|
||||
## run_lang
|
||||
+ `lang`
|
||||
+ `source`
|
||||
+ `stdin`=None
|
||||
+ `env`=None
|
||||
+ `cwd`=None
|
||||
+ `timeout`=None
|
||||
+ `args`=None
|
||||
+ `max_output`=None
|
||||
|
||||
Run source text with language lang; optional stdin.
|
||||
Run source text with language lang; same options as run.
|
||||
|
||||
*> host_foreign_run_lang lang=`lang` source=`source` stdin=`stdin`*
|
||||
*> host_foreign_run_lang lang=`lang` source=`source` stdin=`stdin` env=`env` cwd=`cwd` timeout=`timeout` args=`args` max_output=`max_output`*
|
||||
|
||||
## invoke
|
||||
+ `code`=None
|
||||
+ `lang`=None
|
||||
+ `source`=None
|
||||
+ `stdin`=None
|
||||
+ `input`=None
|
||||
+ `env`=None
|
||||
+ `cwd`=None
|
||||
+ `timeout`=None
|
||||
+ `args`=None
|
||||
+ `output`=auto
|
||||
+ `max_output`=None
|
||||
+ `cmd`=None
|
||||
+ `keep`=False
|
||||
|
||||
Run code or lang+source and return a record map instead of raising on process
|
||||
failure. Fields: ok, code, stdout, stderr, ms, lang, cmd, timed_out, truncated,
|
||||
result, result_error, error, script, cached.
|
||||
|
||||
`input` is encoded as JSON on stdin (mutually exclusive with `stdin`). `output`
|
||||
is auto | text | json | lines. `cmd` overrides the interpreter for this call.
|
||||
|
||||
*> host_foreign_invoke code=`code` lang=`lang` source=`source` stdin=`stdin` input=`input` env=`env` cwd=`cwd` timeout=`timeout` args=`args` output=`output` max_output=`max_output` cmd=`cmd` keep=`keep`*
|
||||
|
||||
## probe
|
||||
+ `lang`=None
|
||||
|
||||
Probe one language, or every known language when lang is omitted. Returns
|
||||
{lang, cmd, path, ok, version, error} (a list when lang is omitted).
|
||||
|
||||
*> host_foreign_probe lang=`lang`*
|
||||
|
||||
## register
|
||||
+ `lang`
|
||||
+ `cmd`=None
|
||||
+ `args`=None
|
||||
+ `template`=None
|
||||
+ `ext`=None
|
||||
+ `env`=None
|
||||
+ `version_args`=None
|
||||
|
||||
Register a language invocation. Provide cmd (+args) or template (placeholders
|
||||
{file}, {dir}, {base}, {inline}, {lang}, {cwd}); they are mutually exclusive.
|
||||
|
||||
*> host_foreign_register lang=`lang` cmd=`cmd` args=`args` template=`template` ext=`ext` env=`env` version_args=`version_args`*
|
||||
|
||||
## unset
|
||||
+ `lang`
|
||||
|
||||
Remove a process-local registration. Presets/config/env still apply.
|
||||
|
||||
*> host_foreign_unset lang=`lang`*
|
||||
|
||||
## load_config
|
||||
+ `path`=None
|
||||
|
||||
Load .marqdo/foreign.toml (or an explicit path); returns the number of language
|
||||
tables read.
|
||||
|
||||
*> host_foreign_load_config path=`path`*
|
||||
|
||||
## langs
|
||||
|
||||
|
||||
+78
-6
@@ -8,29 +8,101 @@ description: 通过本机解释器运行绑定的代码围栏与内联源码
|
||||
## 设置命令
|
||||
+ `语言`
|
||||
+ `命令`
|
||||
+ `参数`=None
|
||||
|
||||
为语言绑定解释器命令。
|
||||
为语言绑定解释器命令;可选附加参数。
|
||||
|
||||
*> host_foreign_set_cmd lang=`语言` cmd=`命令`*
|
||||
*> host_foreign_set_cmd lang=`语言` cmd=`命令` args=`参数`*
|
||||
|
||||
## 运行
|
||||
+ `代码`
|
||||
+ `标准输入`=None
|
||||
+ `环境`=None
|
||||
+ `工作目录`=None
|
||||
+ `超时`=None
|
||||
+ `参数`=None
|
||||
+ `最大输出`=None
|
||||
|
||||
运行已绑定的代码围栏值;可选标准输入。
|
||||
运行已绑定的代码围栏值;可选标准输入、环境表、工作目录、超时(秒)、
|
||||
附加参数与输出上限。返回 stdout 文本;非 0 退出即报错。
|
||||
|
||||
调用例:[外联.运行] 代码=`块`
|
||||
|
||||
*> host_foreign_run code=`代码` stdin=`标准输入`*
|
||||
*> host_foreign_run code=`代码` stdin=`标准输入` env=`环境` cwd=`工作目录` timeout=`超时` args=`参数` max_output=`最大输出`*
|
||||
|
||||
## 按语言运行
|
||||
+ `语言`
|
||||
+ `源码`
|
||||
+ `标准输入`=None
|
||||
+ `环境`=None
|
||||
+ `工作目录`=None
|
||||
+ `超时`=None
|
||||
+ `参数`=None
|
||||
+ `最大输出`=None
|
||||
|
||||
用语言运行源码文本;可选标准输入。
|
||||
用语言运行源码文本;选项同“运行”。
|
||||
|
||||
*> host_foreign_run_lang lang=`语言` source=`源码` stdin=`标准输入`*
|
||||
*> host_foreign_run_lang lang=`语言` source=`源码` stdin=`标准输入` env=`环境` cwd=`工作目录` timeout=`超时` args=`参数` max_output=`最大输出`*
|
||||
|
||||
## 执行
|
||||
+ `代码`=None
|
||||
+ `语言`=None
|
||||
+ `源码`=None
|
||||
+ `标准输入`=None
|
||||
+ `输入`=None
|
||||
+ `环境`=None
|
||||
+ `工作目录`=None
|
||||
+ `超时`=None
|
||||
+ `参数`=None
|
||||
+ `输出`=auto
|
||||
+ `最大输出`=None
|
||||
+ `命令`=None
|
||||
+ `保留`=False
|
||||
|
||||
运行代码或“语言+源码”,返回记录 map,而不是在进程失败时直接报错。
|
||||
字段:ok、code、stdout、stderr、ms、lang、cmd、timed_out、truncated、
|
||||
result、result_error、error、script、cached。
|
||||
|
||||
`输入` 会编码为 JSON 写入 stdin(与 `标准输入` 互斥)。`输出` 可取
|
||||
auto | text | json | lines。`命令` 仅本次覆盖解释器。
|
||||
|
||||
*> host_foreign_invoke code=`代码` lang=`语言` source=`源码` stdin=`标准输入` input=`输入` env=`环境` cwd=`工作目录` timeout=`超时` args=`参数` output=`输出` max_output=`最大输出` cmd=`命令` keep=`保留`*
|
||||
|
||||
## 探测
|
||||
+ `语言`=None
|
||||
|
||||
探测一个语言;省略语言时探测所有已知语言。返回
|
||||
{lang, cmd, path, ok, version, error}(省略语言时是列表)。
|
||||
|
||||
*> host_foreign_probe lang=`语言`*
|
||||
|
||||
## 注册
|
||||
+ `语言`
|
||||
+ `命令`=None
|
||||
+ `参数`=None
|
||||
+ `模板`=None
|
||||
+ `扩展名`=None
|
||||
+ `环境`=None
|
||||
+ `版本参数`=None
|
||||
|
||||
注册语言调用。提供命令(+参数)或模板(占位符
|
||||
{file}、{dir}、{base}、{inline}、{lang}、{cwd});二者互斥。
|
||||
|
||||
*> host_foreign_register lang=`语言` cmd=`命令` args=`参数` template=`模板` ext=`扩展名` env=`环境` version_args=`版本参数`*
|
||||
|
||||
## 注销
|
||||
+ `语言`
|
||||
|
||||
移除进程内注册;预设 / 配置 / 环境变量仍然生效。
|
||||
|
||||
*> host_foreign_unset lang=`语言`*
|
||||
|
||||
## 加载配置
|
||||
+ `路径`=None
|
||||
|
||||
加载 .marqdo/foreign.toml(或显式路径);返回读取到的语言表数量。
|
||||
|
||||
*> host_foreign_load_config path=`路径`*
|
||||
|
||||
## 语言表
|
||||
|
||||
|
||||
Reference in new issue
Block a user