@sema-agent/server 7.54.0 → 7.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +3 -3
- package/README.md +12 -6
- package/README.zh-CN.md +9 -5
- package/USAGE.md +108 -52
- package/deploy/sema-up/chart/values.yaml +1 -1
- package/dist/approval-ask-audit-store.d.ts +129 -0
- package/dist/approval-ask-audit-store.js +284 -0
- package/dist/approval-card.d.ts +18 -6
- package/dist/approval-card.js +2 -2
- package/dist/approval-content-kind.d.ts +22 -0
- package/dist/approval-content-kind.js +5 -0
- package/dist/approval-reconciler.d.ts +2 -1
- package/dist/approval-reconciler.js +1 -1
- package/dist/boot/coordinators.d.ts +2 -0
- package/dist/boot/coordinators.js +18 -1
- package/dist/boot/leader.d.ts +21 -0
- package/dist/boot/leader.js +6 -0
- package/dist/boot/reapers.d.ts +2 -1
- package/dist/boot/runtime-caps.d.ts +2 -1
- package/dist/boot/runtime-caps.js +3 -1
- package/dist/boot/stores.js +8 -1
- package/dist/config-center/types.d.ts +2 -1
- package/dist/config-provider.js +1 -0
- package/dist/device-store.d.ts +66 -2
- package/dist/device-store.js +35 -0
- package/dist/device-ws-hub.d.ts +8 -0
- package/dist/device-ws-hub.js +6 -0
- package/dist/http/route-ctx.d.ts +15 -3
- package/dist/http/routes/approvals-assistant.js +3 -2
- package/dist/http/routes/devices.d.ts +64 -0
- package/dist/http/routes/devices.js +173 -0
- package/dist/http/routes/leader.js +2 -2
- package/dist/http/routes/workflows.js +1 -1
- package/dist/http/server.d.ts +14 -0
- package/dist/http/server.js +30 -5
- package/dist/leader/endpoint.js +5 -4
- package/dist/leader/wire.d.ts +50 -0
- package/dist/leader/wire.js +19 -7
- package/dist/main.js +4 -2
- package/dist/observability/fail-open.d.ts +7 -3
- package/dist/observability/fail-open.js +7 -3
- package/dist/plugins/approval-ask-store-memory.d.ts +11 -1
- package/dist/plugins/approval-ask-store-memory.js +20 -3
- package/dist/plugins/approval-ask-store-sql.d.ts +82 -0
- package/dist/plugins/approval-ask-store-sql.js +41 -10
- package/dist/plugins/checkpoint-store-sql.d.ts +12 -0
- package/dist/plugins/checkpoint-store-sql.js +4 -1
- package/dist/plugins/device-store-sql.d.ts +38 -1
- package/dist/plugins/device-store-sql.js +82 -2
- package/dist/plugins/file-run-store.js +2 -0
- package/dist/plugins/local-checkpoint-store.js +2 -0
- package/dist/plugins/local-session-store.d.ts +9 -9
- package/dist/plugins/local-session-store.js +5 -3
- package/dist/plugins/memory-run-store.js +2 -0
- package/dist/plugins/permission-rule-store-file.d.ts +22 -4
- package/dist/plugins/permission-rule-store-file.js +17 -8
- package/dist/plugins/permission-rule-store-sql.d.ts +60 -30
- package/dist/plugins/permission-rule-store-sql.js +23 -13
- package/dist/plugins/pg-session-storage.js +17 -13
- package/dist/plugins/remote-env-device.js +8 -1
- package/dist/plugins/run-store-sql.js +6 -4
- package/dist/plugins/sql-errors.d.ts +12 -0
- package/dist/plugins/sql-errors.js +10 -0
- package/dist/plugins/store-contracts.d.ts +4 -0
- package/dist/plugins/tidb-session-store.js +18 -14
- package/dist/rules-consent.d.ts +5 -4
- package/dist/rules-consent.js +5 -33
- package/dist/runs.js +1 -0
- package/dist/runtime-caps-resolver.js +3 -1
- package/dist/security.d.ts +7 -0
- package/dist/tool-approval.d.ts +66 -83
- package/dist/tool-approval.js +222 -186
- package/dist/trace/ledger-events.d.ts +9 -0
- package/package.json +3 -3
- package/skills/find-skills.md +1 -1
- package/skills/loop.md +1 -1
package/MIGRATION.md
CHANGED
|
@@ -15,9 +15,9 @@ file/local 存储形(未配 SQL 后端)的部署不受本节任何条目影响
|
|
|
15
15
|
|
|
16
16
|
| 窗 | 变更 | 升级动作 |
|
|
17
17
|
|---|---|---|
|
|
18
|
-
| **7.6.0**(2026-08-08) | SQL
|
|
19
|
-
| **7.8.0**(2026-08-09) | SQL
|
|
20
|
-
| **7.14.0**(2026-08-12) | `tool_result` 换代(core 5.26.0
|
|
18
|
+
| **7.6.0**(2026-08-08) | SQL 双端归一化第一刀:隔离键排序规则钉死(MySQL 腿表级 `COLLATE utf8mb4_bin`/PG 腿逐列 `COLLATE "C"`)+索引名 36 条+列名/宽度收窄 | **删库重建**(两方言) |
|
|
19
|
+
| **7.8.0**(2026-08-09) | SQL 命名三轴归一化第二刀:9 张表名单数化、epoch 毫秒列补 `_ms` 后缀 5 列、approval 两表 `version→rev`;wire 面零变化 | **删库重建**(两方言) |
|
|
20
|
+
| **7.14.0**(2026-08-12) | `tool_result` 换代(随 core 5.26.0 的 ref 格式换代):ref 四段单射形、主键 `VARCHAR(190)→518`、新增出处两列 `owner_session_id`/`owner_task_id` | 升级前两方言 **`DROP TABLE tool_result`**(不删=boot 拒启;offload 产物是可恢复窗缓存,转录内联预览不受影响) |
|
|
21
21
|
|
|
22
22
|
## server 3.0.0 —— BREAKING 四条(2026-07-31)
|
|
23
23
|
|
package/README.md
CHANGED
|
@@ -150,9 +150,9 @@ The server is configured entirely through environment variables. The most import
|
|
|
150
150
|
| `MODEL_ID` | **required** | Default model id — **no factory default since 3.0.0**. Unset ⇒ the server refuses to boot with a message naming the knob (the old baked-in default was an internal-only model name, so every external deployment failed later and further from the cause: a gateway `400` plus a cascade of title-hook warnings). Set it to whatever model name your gateway serves, or supply the catalog via the config-center control plane |
|
|
151
151
|
| `MODEL_API_KEY` | — | Gateway API key (optional) |
|
|
152
152
|
| `SERVICE_AUTH_TOKEN` | — | Callers must send `Authorization: Bearer <token>` |
|
|
153
|
-
| `DB_BACKEND` | `local`* | `mysql` (any MySQL-protocol DB: MySQL/TiDB/MariaDB) / `pg` (PostgreSQL) / `local` (file-backed, no DB) / `memory` (explicit in-memory: nothing survives a restart, durable-runs faces 501). *Bare boot (no DB env at all) defaults to `local` so a single-user machine keeps its runs across restarts; any SQL signal (`SESSION_BACKEND` or `
|
|
153
|
+
| `DB_BACKEND` | `local`* | `mysql` (any MySQL-protocol DB: MySQL/TiDB/MariaDB) / `pg` (PostgreSQL) / `local` (file-backed, no DB) / `memory` (explicit in-memory: nothing survives a restart, durable-runs faces 501). *Bare boot (no DB env at all) defaults to `local` so a single-user machine keeps its runs across restarts; any SQL signal (`SESSION_BACKEND` or `MYSQL_/PG_HOST`) keeps the `mysql` engine default, and `REQUIRE_PRINCIPAL=true` bare boots stay `memory`. (`TIDB_HOST`/`_PORT`/`_USER`/`_PASSWORD`/`_DATABASE`/`_POOL_SIZE` are retired names, not an alias — since 5.0.0 setting any of them refuses to boot, pointing at the `MYSQL_*` replacement; TiDB itself connects fine through `MYSQL_*`, since it speaks the MySQL protocol.) (the local file store has no tenant isolation — a warning says so). A DEFAULT-derived `local` that cannot create its data root degrades to memory with a warning + the `store_backend_degraded` gauge; an EXPLICIT `DB_BACKEND=local` fails loud instead. Setting `mysql`/`pg` explicitly also switches sessions to durable |
|
|
154
154
|
| `SESSION_BACKEND` | `memory`* | `memory` / `mysql` (durable session center) / `auto`. *Defaults to durable when `DB_BACKEND` is explicitly `mysql`/`pg` |
|
|
155
|
-
| `REMOTE_EXEC` | unset | Sandbox execution lane: `host` / `local-docker` / `e2b` / `k8s` / `ssh` / `adb`; unset = in-process stub (with `CONFIG_PROVIDER=local` the default becomes `host`). Naming a lane without its required env (e.g. `e2b` without `E2B_API_KEY`) or an unrecognized value **refuses to start** — no silent downgrade to the host/in-process lane (
|
|
155
|
+
| `REMOTE_EXEC` | unset | Sandbox execution lane: `host` / `local-docker` / `e2b` / `k8s` / `ssh` / `adb`; unset = in-process stub (with `CONFIG_PROVIDER=local` the default becomes `host`). Naming a lane without its required env (e.g. `e2b` without `E2B_API_KEY`) or an unrecognized value **refuses to start** — no silent downgrade to the host/in-process lane (fail-closed) |
|
|
156
156
|
| `SSH_HOST_FINGERPRINT` / `SSH_KNOWN_HOSTS` | unset | **SSH lane host-key verification** (`REMOTE_EXEC=ssh` only). `SSH_HOST_FINGERPRINT` = the host key's SHA256 base64 fingerprint (`SHA256:` prefix and `=` padding both optional); `SSH_KNOWN_HOSTS` = a path to a `known_hosts` file, matched literally on `host` / `[host]:port`. **Either one present ⇒ strict verification, a mismatch REFUSES the connection** (the error carries both fingerprints plus an `ssh-keyscan` line); both set ⇒ both must pass. **Both unset ⇒ a loud per-connection warning (`ssh_host_key_unverified`, man-in-the-middle risk) and the connection proceeds** — the deliberate posture for the batch-deploy lane, registered as a P-DEBT fail-open (`docs/FAIL-OPEN-CENSUS.md`). A malformed fingerprint or an unreadable `known_hosts` path **refuses to start**. Not supported in `known_hosts`, on purpose: hashed (`\|1\|…`) lines, wildcard patterns, `@cert-authority` — all skipped, so a host whose only entries are those is REFUSED (`@revoked` is honored and wins over any plain line, whatever the order) |
|
|
157
157
|
| `HOOKS_TIMEOUT_MS` | unset (engine default 600000) | Per-invocation time bound for every hook seat (core `Hooks.timeoutMs`). Unset = the engine's own default (this server does not copy upstream defaults). `0` is honored as written (every seat expires immediately). A non-integer, negative, or above-`setTimeout`-ceiling (2147483647) value **refuses to start** |
|
|
158
158
|
| `CONFIG_PROVIDER` | unset | Config source: `local` (file-backed `config.d/`, single machine) / `remote` (registry control plane) |
|
|
@@ -166,9 +166,12 @@ The server is configured entirely through environment variables. The most import
|
|
|
166
166
|
| `MODEL_IDLE_TIMEOUT_MS` | `300000` | Mid-stream idle timeout (`0` = off) |
|
|
167
167
|
| `LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` (structured JSON logs) |
|
|
168
168
|
|
|
169
|
-
**Boolean knobs**
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
**Boolean knobs** accept `true`/`false`/`1`/`0`/`yes`/`no`/`on`/`off` (case-insensitive; word table widened
|
|
170
|
+
in 7.16.0). Any other value makes the process **refuse to boot** — the error names the env var, the value it
|
|
171
|
+
received, and the accepted word list — so a mistyped switch is caught at start, not silently defaulted (the
|
|
172
|
+
older `config_env_invalid_using_default`-warn-and-keep-default behavior no longer applies to booleans; that
|
|
173
|
+
event now fires only for other knob kinds, e.g. a numeric knob out of range). The default is not guessable
|
|
174
|
+
from the name, so the server prints one
|
|
172
175
|
`config_knob_polarity` line per knob at `LOG_LEVEL=debug`: name → polarity (`opt-in` = default OFF,
|
|
173
176
|
`opt-out` = default ON, `posture` = derived from `REQUIRE_PRINCIPAL`) → effective value → where it came from.
|
|
174
177
|
The table describes the knobs live in *this* configuration — a knob gated on an inactive lane (e.g.
|
|
@@ -177,7 +180,10 @@ The table describes the knobs live in *this* configuration — a knob gated on a
|
|
|
177
180
|
|
|
178
181
|
The full surface — cost/quota ceilings, circuit breaker and failover, multi-model roles, approval
|
|
179
182
|
gates, observability (Prometheus `/metrics` + optional OTLP), registry control plane, per-lane
|
|
180
|
-
sandbox settings — is documented in [`USAGE.md`](USAGE.md).
|
|
183
|
+
sandbox settings — is documented in [`USAGE.md`](USAGE.md). Three separate knobs cap spend and they
|
|
184
|
+
stop different things at different moments (per-task ceiling / per-principal ADMISSION gate that does
|
|
185
|
+
not interrupt a run already executing / deployment usage window that does stop one at a turn
|
|
186
|
+
boundary) — the side-by-side table is in `USAGE.md`, worth reading before picking one.
|
|
181
187
|
|
|
182
188
|
## HTTP API overview
|
|
183
189
|
|
package/README.zh-CN.md
CHANGED
|
@@ -134,14 +134,14 @@ curl -s localhost:8090/v1/tasks -H "Authorization: Bearer <SERVICE_AUTH_TOKEN>"
|
|
|
134
134
|
| 变量 | 默认 | 说明 |
|
|
135
135
|
|------|------|------|
|
|
136
136
|
| `PORT` | `8090` | HTTP 监听端口 |
|
|
137
|
-
| `BIND_HOST`(
|
|
137
|
+
| `BIND_HOST`(别名 `HOST`) | 见说明 | 监听地址。显式 `BIND_HOST` **恒生效**。缺省:写面无鉴权时(`ALLOW_UNAUTHED_WRITES=true` **且**未配任何 service token)= `127.0.0.1`,否则全接口——配了 token 的部署不受影响。自 3.15.0 起 `HOST` 别名**不再完全等效**:shell 常把 `HOST` 设成机器名而 operator 并不知情,于是上述收窄条件成立时,收窄压过继承来的 `HOST`(告警事件 `bind_host_from_HOST_env_overridden`)。要暴露写面,显式设 `BIND_HOST`,或配一个 service token。 |
|
|
138
138
|
| `MODEL_GATEWAY_BASEURL` | `http://127.0.0.1:8000/v1` | OpenAI 兼容网关地址(不带 `/chat/completions`) |
|
|
139
139
|
| `MODEL_ID` | **必填** | 缺省模型 id ——**3.0.0 起无出厂缺省**。未设 = 启动即失败并指路该旋钮(旧的烤死缺省是内网模型名,外部部署必炸且炸在离根因最远处:网关 `400` + 标题 hook 连环告警)。填你的网关真正提供的模型名,或改由配置控制面下发目录 |
|
|
140
140
|
| `MODEL_API_KEY` | — | 网关 key(可选) |
|
|
141
141
|
| `SERVICE_AUTH_TOKEN` | — | 调用方需带 `Authorization: Bearer <token>` |
|
|
142
142
|
| `DB_BACKEND` | `local`* | SQL 引擎:`mysql`(任何 MySQL 协议库:MySQL/TiDB/MariaDB —— TiDB 走这个值,**没有** `tidb` 别名,写它启动即拒)/ `pg`(PostgreSQL)/ `local`(免 DB 文件持久化)/ `memory`(显式纯内存)。显式设置 `mysql`/`pg` 时 session 自动转 durable。*单租户裸 boot 缺省 `local`;`REQUIRE_PRINCIPAL=true` 的多租户裸 boot 缺省 `memory`(local 与多租户互斥) |
|
|
143
143
|
| `SESSION_BACKEND` | `memory`* | `memory` / `mysql`(durable 会话中心)/ `auto`。*显式 `DB_BACKEND=mysql/pg` 时默认转 durable |
|
|
144
|
-
| `REMOTE_EXEC` | 未设 | 沙箱执行通道:`host` / `local-docker` / `e2b` / `k8s` / `ssh` / `adb`;未设 = 进程内 stub(`CONFIG_PROVIDER=local` 时缺省转 `host`)。点名了通道但必需 env 不全(如 `e2b` 缺 `E2B_API_KEY`)或值不在闭集内 ⇒ **启动即拒**——不再静默降级到 host/进程内通道(
|
|
144
|
+
| `REMOTE_EXEC` | 未设 | 沙箱执行通道:`host` / `local-docker` / `e2b` / `k8s` / `ssh` / `adb`;未设 = 进程内 stub(`CONFIG_PROVIDER=local` 时缺省转 `host`)。点名了通道但必需 env 不全(如 `e2b` 缺 `E2B_API_KEY`)或值不在闭集内 ⇒ **启动即拒**——不再静默降级到 host/进程内通道(fail-closed) |
|
|
145
145
|
| `SSH_HOST_FINGERPRINT` / `SSH_KNOWN_HOSTS` | 未设 | **SSH 通道主机密钥校验**(仅 `REMOTE_EXEC=ssh`)。前者 = 主机公钥的 SHA256 base64 指纹(`SHA256:` 前缀与 `=` 填充都可选);后者 = `known_hosts` 文件路径,按 `host` / `[host]:port` **逐字**匹配行。**任一在场 ⇒ 严格校验,不符即拒连**(拒因带两半指纹 + `ssh-keyscan` 取指纹指路一行);两只同时在场 ⇒ 合取(都要过)。**两只全缺席 ⇒ 每连接一条响亮 warn(`ssh_host_key_unverified`,中间人风险)后照常连** —— 批量部署通道的既定姿态,已登记为 P-DEBT fail-open(`docs/FAIL-OPEN-CENSUS.md`)。指纹拼错 / `known_hosts` 路径读不到 ⇒ **启动即拒**。`known_hosts` 里**刻意不支持**:hashed(`\|1\|…`)行、通配符 pattern、`@cert-authority` —— 一律跳过,于是只有这些条目的主机会被**拒连**(`@revoked` 照常生效,且无论写在哪一行都优先于普通匹配行) |
|
|
146
146
|
| `HOOKS_TIMEOUT_MS` | 未设(引擎缺省 600000) | 每一只 hook 席位**单次调用**的时间上限(core `Hooks.timeoutMs`)。未设 = 用引擎自己的缺省(本服务不复制上游默认值)。`0` **按字面生效**(每个席位立即到期)。非整数 / 负数 / 超 `setTimeout` 上限(2147483647)⇒ **启动即拒** |
|
|
147
147
|
| `CONFIG_PROVIDER` | 未设 | 配置来源:`local`(单机文件 `config.d/`)/ `remote`(registry 控制面) |
|
|
@@ -153,8 +153,10 @@ curl -s localhost:8090/v1/tasks -H "Authorization: Bearer <SERVICE_AUTH_TOKEN>"
|
|
|
153
153
|
| `MODEL_IDLE_TIMEOUT_MS` | `300000` | 流中 idle 超时(`0` 关) |
|
|
154
154
|
| `LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error`(结构化 JSON 日志) |
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
**布尔旋钮收 `true`/`false`/`1`/`0`/`yes`/`no`/`on`/`off`**(大小写不敏感;词表自 7.16.0 起放宽)。
|
|
157
|
+
词表**外**的值会让进程**直接拒启**——报错信息点名该 env 名、收到的原始值、可接受词表,打错的开关在启动
|
|
158
|
+
那一刻就现形,而不是静默退回默认(旧的「`config_env_invalid_using_default` 警告 + 保留缺省值」这条臂
|
|
159
|
+
已随本次改动退役,不再覆盖布尔旋钮;该事件现在只用于其他种类的越界配置,如数值旋钮被夹取)。
|
|
158
160
|
缺省值无法从名字推出,所以服务在 `LOG_LEVEL=debug` 下每个旋钮打一行 `config_knob_polarity`:
|
|
159
161
|
名字 → 极性(`opt-in`=缺省关、`opt-out`=缺省开、`posture`=由 `REQUIRE_PRINCIPAL` 推导)→ 生效值 → 来源。
|
|
160
162
|
该表描述**本配置下活着的旋钮**——挂在未激活通道上的旋钮(如非 k8s 通道下的 `K8S_INSECURE_TLS`、
|
|
@@ -162,7 +164,9 @@ curl -s localhost:8090/v1/tasks -H "Authorization: Bearer <SERVICE_AUTH_TOKEN>"
|
|
|
162
164
|
|
|
163
165
|
完整配置面 —— 成本/配额上限、断路器与 failover、多模型角色、审批门、可观测
|
|
164
166
|
(Prometheus `/metrics` + 可选 OTLP)、registry 控制面、各沙箱通道细项 ——
|
|
165
|
-
见 [`USAGE.md`](USAGE.md)
|
|
167
|
+
见 [`USAGE.md`](USAGE.md)。⚠️ 封顶花费的旋钮有**三根**,判的时刻和能停住什么各不相同
|
|
168
|
+
(单任务硬闸 / per-principal **进场门**——不打断已在跑的 run / 部署级治理窗——会在 turn 边界停住它);
|
|
169
|
+
选之前请先读 `USAGE.md` 里的「三道 $ 闸的分工」对照表。
|
|
166
170
|
|
|
167
171
|
## HTTP API 概览
|
|
168
172
|
|