docs(i18n): refresh core data translations after merge

This commit is contained in:
Tianyi Cui
2026-07-22 22:58:05 +08:00
parent 58a531ebf5
commit 01622abde7
47 changed files with 2685 additions and 509 deletions

View File

@@ -2,7 +2,7 @@
[English](code-runtime.md) | 中文
代码执行 seam一个[能力 seam](../rfc/implemented/architecture/2026-06-13-capability-seams.md)其接口([dsh-code-runtime](../../packages/code-runtime/code-runtime)`ctx.codeRuntime`运行一段模型编写的程序,对接宿主提供的异步绑定,并报告程序的打印输出与返回值。代码执行是**一项可选能力**,不属于 agent loop(智能体循环)主干,因此其词汇定义在此而非 [core.md](core.md)后端执行基底源语言而异,二者都是服务上的只读描述符worker-thread 后端工具注册表消费方Code Mode [Code Mode RFC](../rfc/implemented/feature/2026-06-15-code-mode.md) 中定义
代码执行 seam一个[能力 seam](../../.agents/notes/implemented/architecture/2026-06-13-capability-seams.md)其接口([dsh-code-runtime](../../packages/code-runtime/code-runtime)`ctx.codeRuntime`针对宿主提供的异步 binding 运行一段模型编写的程序,并报告其打印内容与返回值。代码执行是**一项可选能力**,不属于 agent loop 主干,因此其词汇定义在此而非 [core.md](core.md) 中。各后端执行基底源语言不同,这两项均为服务上的只读描述符worker-thread 后端工具注册表消费方Code Mode [Code Mode Agent Noteagent 决策记录)](../../.agents/notes/implemented/feature/2026-06-15-code-mode.md) 规定
源码:[`packages/code-runtime/code-runtime/src/types.ts`](../../packages/code-runtime/code-runtime/src/types.ts)
@@ -11,6 +11,12 @@
`CodeRunRequest` 携带**运行时所需的一切**。按照「包package边界处显式优于隐式」的规则默认值时间预算、输出上限来自实现的已校验配置绝不是 `run()` 内部隐藏的 `??`
```ts type-equiv
/**
* One run: the program source plus everything the runtime acts on. Per the
* explicit-over-implicit convention, defaulting (time budgets, output caps)
* is the implementation's validated config — a request carries no optional
* tuning knobs for a hidden `??` to fill in.
*/
interface CodeRunRequest {
/**
* The program source, in the runtime's {@link ../index.ts | language}. It
@@ -33,6 +39,11 @@ interface CodeRunRequest {
结果将错误报告为一个**字段**,而非 `run()` 的 rejection。报告失败的程序是调用方的职责不走异常路径与 `BashExecutor.run` 的 resolve-on-failure 契约一致):
```ts type-equiv
/**
* The outcome of one run. An error is a FIELD on a resolved result, never a
* rejection of `run()` — reporting a failed program is the caller's job, not
* an exception path.
*/
interface CodeRunResult {
/**
* The program's completion value (its top-level `return`), when it ran to
@@ -53,6 +64,13 @@ interface CodeRunResult {
每个 `CodeBindingNamespace` 在程序内成为一个由异步可调用函数组成的全局对象Code Mode 消费方传入一个:`tools`)。参数与返回值必须可 structured-clone运行时可能跨序列化边界桥接调用且运行时将绑定名视为不可信输入`__proto__` 是普通自有属性,绝不会发生原型碰撞):
```ts type-equiv
/**
* A named group of {@link CodeBindingFunction}s the runtime exposes to the
* program as one global object (e.g. `tools`). Function names are arbitrary
* strings — a runtime must treat names like `__proto__` or `constructor` as
* ordinary own properties (null-prototype construction), never as prototype
* collisions.
*/
interface CodeBindingNamespace {
/** The global identifier the program sees (must be a valid JS identifier). */
global: string
@@ -62,6 +80,14 @@ interface CodeBindingNamespace {
```
```ts type-equiv
/**
* One host-side function exposed to the program as an async callable. The
* runtime bridges calls to it (possibly across a serialization boundary), so
* `args` and the resolution value MUST be structured-cloneable; a runtime
* rejects a non-cloneable value with a descriptive error rather than
* corrupting the run. A rejection of this function surfaces inside the
* program as a rejection of the corresponding call.
*/
type CodeBindingFunction = (args: unknown) => Promise<unknown>
```
@@ -72,6 +98,16 @@ type CodeBindingFunction = (args: unknown) => Promise<unknown>
失败类型是**正交的结果,独立报告**(见 [defensive-patterns](../defensive-patterns.md)):预算耗尽不是异常,中止不是超时,基底崩溃(如 OOM也不是二者中的任何一个
```ts type-equiv
/**
* Why a run failed. The kinds are orthogonal outcomes reported independently
* (per docs/defensive-patterns.md): a budget expiry is not an exception, an
* abort is not a timeout, and a substrate death is neither.
*
* - `'exception'` — the program threw or failed to parse/transform.
* - `'timeout'` — an implementation-owned budget expired; the message says which.
* - `'abort'` — {@link CodeRunRequest.signal} fired.
* - `'worker-exit'` — the execution substrate died without settling (e.g. OOM).
*/
interface CodeRunFailure {
/** The failure class (see the interface doc for each kind's meaning). */
kind: 'exception' | 'timeout' | 'abort' | 'worker-exit'