@sema-agent/server 7.140.0 → 7.142.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 +505 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +142 -25
- package/dist/approval-ask-audit-store.d.ts +54 -38
- package/dist/approval-ask-audit-store.js +58 -39
- package/dist/approval-batch-census.d.ts +27 -0
- package/dist/approval-batch-census.js +27 -0
- package/dist/approval-card.d.ts +39 -24
- package/dist/approval-card.js +6 -3
- package/dist/approval-crash-convergence.d.ts +17 -7
- package/dist/approval-crash-convergence.js +94 -22
- package/dist/approval-deny-reasons.d.ts +34 -30
- package/dist/approval-deny-reasons.js +21 -6
- package/dist/approval-policy-settlement.d.ts +1 -1
- package/dist/approval-reconciler.d.ts +33 -1
- package/dist/approval-reconciler.js +43 -40
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +10 -0
- package/dist/audit.d.ts +4 -2
- package/dist/audit.js +2 -2
- package/dist/auth-bridge.d.ts +9 -6
- package/dist/auth-bridge.js +9 -3
- package/dist/boot/adoption.js +2 -1
- package/dist/boot/budget-tracing.d.ts +16 -0
- package/dist/boot/budget-tracing.js +10 -6
- package/dist/boot/device-lane.d.ts +11 -0
- package/dist/boot/device-lane.js +16 -0
- package/dist/boot/engine-lease.d.ts +24 -3
- package/dist/boot/engine-lease.js +9 -2
- package/dist/boot/execution-env.d.ts +24 -4
- package/dist/boot/execution-env.js +34 -27
- package/dist/boot/execution-lane.js +2 -1
- package/dist/boot/exit-boundary.js +5 -4
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +1 -1
- package/dist/boot/memory-consolidation.js +3 -2
- package/dist/boot/parked-revive-gate.js +2 -1
- package/dist/boot/permission-rules-audit.d.ts +0 -28
- package/dist/boot/permission-rules-audit.js +2 -1
- package/dist/boot/read-deny-anchor-audit.js +2 -1
- package/dist/boot/reapers.d.ts +2 -2
- package/dist/boot/reapers.js +4 -3
- package/dist/boot/resolve-spec.js +18 -6
- package/dist/boot/retention-lane.js +5 -3
- package/dist/boot/runner-deps.js +16 -13
- package/dist/boot/runtime-caps.js +3 -2
- package/dist/boot/session-faces.d.ts +1 -1
- package/dist/boot/session-faces.js +8 -6
- package/dist/boot/shutdown.js +8 -2
- package/dist/boot/stage-04-stores.js +3 -2
- package/dist/boot/stage-05-execution-env.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.js +11 -7
- package/dist/boot/stage-06-runners.d.ts +1 -3
- package/dist/boot/stage-06-runners.js +3 -2
- package/dist/boot/stage-07-capability-layer.d.ts +1 -2
- package/dist/boot/stage-07-capability-layer.js +10 -11
- package/dist/boot/stage-08-reapers.d.ts +1 -2
- package/dist/boot/stage-08-reapers.js +3 -2
- package/dist/boot/stage-09-leader.d.ts +1 -2
- package/dist/boot/stage-10-http-server.d.ts +1 -2
- package/dist/boot/stage-10-http-server.js +6 -4
- package/dist/boot/stores.js +13 -6
- package/dist/boot/web-admin.js +18 -17
- package/dist/boot/webfetch-summarize-lane.js +2 -1
- package/dist/boot/workflow-orchestration.js +3 -2
- package/dist/capabilities/builtin-tools.d.ts +2 -1
- package/dist/capabilities/builtin-tools.js +2 -4
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/scenarios.d.ts +1 -1
- package/dist/capability-facts.d.ts +33 -0
- package/dist/capability-facts.js +32 -0
- package/dist/card-void.d.ts +38 -0
- package/dist/card-void.js +23 -0
- package/dist/config-catalog.js +12 -8
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +19 -33
- package/dist/config-types.d.ts +39 -10
- package/dist/config.d.ts +6 -0
- package/dist/config.js +72 -49
- package/dist/delegated-session-owner.d.ts +21 -19
- package/dist/delegated-session-owner.js +1 -1
- package/dist/device-store.d.ts +7 -0
- package/dist/device-store.js +3 -0
- package/dist/execution-config-root.d.ts +22 -0
- package/dist/execution-config-root.js +35 -0
- package/dist/execution-lane-caps.d.ts +50 -2
- package/dist/execution-lane-caps.js +90 -13
- package/dist/execution-placement.d.ts +3 -0
- package/dist/execution-placement.js +7 -0
- package/dist/fleet/drain-entry.d.ts +3 -0
- package/dist/fleet/fleet-bus.d.ts +6 -3
- package/dist/hooks/hook-runner.d.ts +6 -0
- package/dist/hooks/hook-runner.js +30 -1
- package/dist/hosted-posture.d.ts +8 -0
- package/dist/hosted-posture.js +4 -0
- package/dist/http/admission.js +3 -3
- package/dist/http/caller-trust.d.ts +3 -2
- package/dist/http/caller-trust.js +2 -1
- package/dist/http/dispatch.js +8 -2
- package/dist/http/execution-context.d.ts +2 -2
- package/dist/http/idempotency.d.ts +1 -1
- package/dist/http/live-frame.d.ts +24 -0
- package/dist/http/live-frame.js +16 -0
- package/dist/http/principal-gate.d.ts +3 -1
- package/dist/http/principal-gate.js +17 -8
- package/dist/http/resume-legs.js +42 -29
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/approvals-assistant.js +1 -0
- package/dist/http/routes/attachments.js +18 -0
- package/dist/http/routes/capabilities.js +10 -6
- package/dist/http/routes/diagnostics.d.ts +0 -19
- package/dist/http/routes/diagnostics.js +16 -2
- package/dist/http/routes/memory-bundle.d.ts +2 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-policy.js +27 -7
- package/dist/http/routes/run-permission-mode.d.ts +75 -0
- package/dist/http/routes/run-permission-mode.js +170 -0
- package/dist/http/routes/runs.js +3 -3
- package/dist/http/routes/session-memory-sync.d.ts +63 -0
- package/dist/http/routes/session-memory-sync.js +157 -0
- package/dist/http/routes/session-sync.d.ts +3 -6
- package/dist/http/routes/session-sync.js +7 -2
- package/dist/http/routes/sessions-list.d.ts +2 -1
- package/dist/http/routes/sessions.js +5 -4
- package/dist/http/routes/tasks.js +70 -71
- package/dist/http/run-read-face.d.ts +7 -0
- package/dist/http/run-read-face.js +10 -4
- package/dist/http/send.d.ts +6 -1
- package/dist/http/send.js +10 -3
- package/dist/http/server.d.ts +20 -7
- package/dist/http/server.js +2 -4
- package/dist/http/sse-log.d.ts +3 -8
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +3 -1
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +2 -2
- package/dist/http/sync-submit-body.d.ts +21 -4
- package/dist/http/sync-submit-body.js +13 -0
- package/dist/identity-source.d.ts +21 -2
- package/dist/identity-source.js +6 -0
- package/dist/instruction-source-notice.d.ts +7 -0
- package/dist/instruction-source-notice.js +6 -6
- package/dist/mcp-assertion-header.d.ts +4 -0
- package/dist/mcp-assertion-header.js +5 -0
- package/dist/memory-incident-sink.d.ts +19 -6
- package/dist/memory-incident-sink.js +8 -4
- package/dist/memory-posture.d.ts +1 -1
- package/dist/memory-scope.d.ts +4 -4
- package/dist/memory-scope.js +1 -1
- package/dist/memory-sync-client.d.ts +35 -23
- package/dist/memory-sync-client.js +122 -52
- package/dist/memory-sync-identity.d.ts +24 -0
- package/dist/memory-sync-identity.js +57 -0
- package/dist/memory-sync.d.ts +7 -1
- package/dist/memory-sync.js +6 -3
- package/dist/observability/fail-open.d.ts +57 -12
- package/dist/observability/fail-open.js +50 -9
- package/dist/observability/metrics.js +0 -1
- package/dist/observability/run-terminal.d.ts +93 -31
- package/dist/observability/run-terminal.js +175 -171
- package/dist/observability/secret-env-scrub.d.ts +20 -1
- package/dist/observability/secret-env-scrub.js +14 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -2
- package/dist/orchestration/workflow-completion-inbox.js +13 -5
- package/dist/orchestration/workflow-notify-journal.d.ts +5 -3
- package/dist/orchestration/workflow-notify-journal.js +2 -1
- package/dist/permission-mode-admission.d.ts +68 -0
- package/dist/permission-mode-admission.js +23 -0
- package/dist/permission-rule-list.d.ts +55 -6
- package/dist/permission-rule-list.js +52 -5
- package/dist/plugins/approval-ask-store-file.d.ts +14 -4
- package/dist/plugins/approval-ask-store-file.js +48 -7
- package/dist/plugins/approval-ask-store-memory.d.ts +2 -1
- package/dist/plugins/approval-ask-store-memory.js +9 -8
- package/dist/plugins/approval-ask-store-sql.d.ts +42 -10
- package/dist/plugins/approval-ask-store-sql.js +49 -19
- package/dist/plugins/caching-session-store.d.ts +6 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +65 -17
- package/dist/plugins/checkpoint-store-sql.js +74 -3
- package/dist/plugins/device-store-sql.d.ts +5 -2
- package/dist/plugins/device-store-sql.js +4 -1
- package/dist/plugins/execution-placement-sql.d.ts +11 -1
- package/dist/plugins/execution-placement-sql.js +12 -1
- package/dist/plugins/file-run-store.d.ts +7 -2
- package/dist/plugins/file-run-store.js +12 -2
- package/dist/plugins/fork-routing-session-store.d.ts +10 -32
- package/dist/plugins/fork-routing-session-store.js +2 -61
- package/dist/plugins/k8s-exec-protocol.d.ts +4 -1
- package/dist/plugins/k8s-exec-protocol.js +6 -1
- package/dist/plugins/local-checkpoint-store.d.ts +10 -1
- package/dist/plugins/local-checkpoint-store.js +22 -0
- package/dist/plugins/local-session-store.d.ts +260 -39
- package/dist/plugins/local-session-store.js +582 -57
- package/dist/plugins/local-session-window.d.ts +17 -3
- package/dist/plugins/local-session-window.js +7 -13
- package/dist/plugins/local-task-attachment-store.d.ts +12 -2
- package/dist/plugins/local-task-attachment-store.js +67 -43
- package/dist/plugins/memory-key-guards.d.ts +3 -3
- package/dist/plugins/memory-run-store.d.ts +7 -2
- package/dist/plugins/memory-run-store.js +12 -2
- package/dist/plugins/one-time-migrations.d.ts +68 -2
- package/dist/plugins/one-time-migrations.js +120 -4
- package/dist/plugins/pg-pool.js +3 -2
- package/dist/plugins/pg-session-storage.d.ts +2 -0
- package/dist/plugins/pg-session-storage.js +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +47 -7
- package/dist/plugins/remote-env-e2b.js +242 -46
- package/dist/plugins/remote-env-k8s.d.ts +51 -6
- package/dist/plugins/remote-env-k8s.js +234 -44
- package/dist/plugins/remote-env-local-docker.d.ts +40 -14
- package/dist/plugins/remote-env-local-docker.js +127 -33
- package/dist/plugins/run-store-sql.d.ts +11 -3
- package/dist/plugins/run-store-sql.js +13 -4
- package/dist/plugins/sandbox-read-floor.d.ts +273 -0
- package/dist/plugins/sandbox-read-floor.js +608 -0
- package/dist/plugins/session-ownership.d.ts +2 -1
- package/dist/plugins/session-placement.d.ts +17 -4
- package/dist/plugins/session-placement.js +2 -1
- package/dist/plugins/session-store.d.ts +18 -20
- package/dist/plugins/session-store.js +4 -12
- package/dist/plugins/store-backend.d.ts +41 -7
- package/dist/plugins/store-backend.js +22 -4
- package/dist/plugins/store-contracts.d.ts +35 -3
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +112 -14
- package/dist/plugins/task-attachment-store.js +221 -28
- package/dist/plugins/tidb-pool.js +2 -1
- package/dist/plugins/tidb-session-store.d.ts +4 -1
- package/dist/plugins/tidb-session-store.js +3 -2
- package/dist/plugins/workspace-fill.d.ts +60 -0
- package/dist/plugins/workspace-fill.js +106 -0
- package/dist/project-bundle.d.ts +38 -0
- package/dist/project-bundle.js +609 -0
- package/dist/run-cancel-context.d.ts +34 -0
- package/dist/run-cancel-context.js +7 -0
- package/dist/run-local.js +2 -8
- package/dist/runs.d.ts +39 -12
- package/dist/runs.js +69 -55
- package/dist/sandbox-egress-policy.d.ts +4 -1
- package/dist/sandbox-egress-policy.js +3 -1
- package/dist/sandbox-git-plane.d.ts +31 -12
- package/dist/sandbox-git-plane.js +24 -4
- package/dist/security.d.ts +11 -2
- package/dist/security.js +8 -0
- package/dist/server-secret-env.d.ts +2 -1
- package/dist/server-secret-env.js +2 -4
- package/dist/session-error-wire.d.ts +46 -4
- package/dist/session-error-wire.js +23 -0
- package/dist/session-incarnation.d.ts +9 -3
- package/dist/session-sync-kernel.d.ts +42 -1
- package/dist/session-sync-kernel.js +17 -0
- package/dist/session-sync.js +16 -4
- package/dist/sql-engine-coordinates.d.ts +49 -0
- package/dist/sql-engine-coordinates.js +27 -0
- package/dist/standing-answer-grant.d.ts +31 -2
- package/dist/standing-answer-grant.js +14 -2
- package/dist/store-posture.d.ts +1 -1
- package/dist/task-a2a.d.ts +1 -1
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +62 -27
- package/dist/task-settings.js +105 -29
- package/dist/terminal.d.ts +97 -20
- package/dist/terminal.js +107 -18
- package/dist/tool-approval.d.ts +4 -3
- package/dist/tool-approval.js +12 -14
- package/dist/trace/core-keyset-guard.d.ts +196 -2
- package/dist/trace/engine-notice-wire.d.ts +8 -2
- package/dist/trace/engine-notice-wire.js +4 -2
- package/dist/trace/exit-seat.d.ts +9 -1
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/ledger-sink.d.ts +8 -4
- package/dist/trace/ledger-sink.js +2 -2
- package/dist/trace/model-segment.d.ts +2 -2
- package/dist/trace/project.d.ts +18 -1
- package/dist/trace/project.js +16 -0
- package/dist/trace/redact.js +323 -90
- package/dist/trace/self-minted-wire.d.ts +419 -4
- package/dist/trace/self-minted-wire.js +145 -0
- package/dist/trace/wire-projection-faces.d.ts +1 -1
- package/dist/trace/wire-projection-faces.js +1 -1
- package/dist/verifier-pause-card.d.ts +8 -0
- package/dist/verifier-pause-card.js +19 -0
- package/dist/web-admin-client/apply-effective.d.ts +5 -7
- package/dist/web-admin-client/apply-effective.js +22 -2
- package/dist/web-admin-client/candidate-gate.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +2 -0
- package/dist/web-admin-client/read-warnings.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +4 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -2
- package/package.json +2 -2
- package/wire-changes/server@7.141.0.json +367 -0
- package/wire-changes/server@7.142.0.json +639 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { ExecutionError, type ReadFloor, type Result } from "@sema-agent/core";
|
|
2
|
+
import { type SandboxFloorLane, type SandboxReadFloorKnob, type SandboxReadFloorState } from "../execution-lane-caps.js";
|
|
3
|
+
/** F2 原因词闭集:连接时附着不过的那一步。 */
|
|
4
|
+
export declare const READ_FLOOR_UNAVAILABLE_REASONS: readonly ["arch", "user_notif", "addfd_send", "uid_zero", "writable_system_path", "binary_digest", "relay_silent", "relay_identity", "provenance"];
|
|
5
|
+
export type ReadFloorUnavailableReason = (typeof READ_FLOOR_UNAVAILABLE_REASONS)[number];
|
|
6
|
+
/** F2:附着不过的环境上,带地板起动的拒句(纯字符串 ⇒ `build*`)。首句点名原因词;点名表的首行与旋钮。 */
|
|
7
|
+
export declare function buildReadFloorUnavailableMessage(reason: ReadFloorUnavailableReason, detail: string | undefined, floor: ReadFloor | undefined): string;
|
|
8
|
+
/** F6:守地板的环境上,不带地板的引擎起动的拒句。 */
|
|
9
|
+
export declare function buildReadFloorMissingMessage(lane: SandboxFloorLane): string;
|
|
10
|
+
/**
|
|
11
|
+
* 一次起动是什么(闭集,调用方必须表态 —— 没有缺省臂):
|
|
12
|
+
* · `engine` —— 经执行环境公共起动口要起的命令(引擎的,或替引擎干活的服务端调用方的);带不带地板是它交来的事实。`hold` = 适配器之后还会以
|
|
13
|
+
* 同一起动号再起 `run`(k8s 后台作业的轮询 / 停 / 收尾读的是这次起动的产物,按这次起动的地板跑),登记留到 {@link SandboxReadFloor.release};
|
|
14
|
+
* · `under` —— 以一次已登记(`hold`)起动的号再起一只 `run`(上面那类轮询);
|
|
15
|
+
* · `adapter` —— 适配器自己的固定命令(文件面助手、探针、数据搬运、全杀);附着成功之后经监督者的 `plain` 起;
|
|
16
|
+
* · `bootstrap` —— 本模块附着期间经适配器起动口跑的引导命令(量架构 / 工作区属主、放置、自检);只在附着中合法,别的时刻一律拒(响亮)。
|
|
17
|
+
*/
|
|
18
|
+
export type FloorStart = {
|
|
19
|
+
readonly kind: "engine";
|
|
20
|
+
readonly readFloor: ReadFloor | undefined;
|
|
21
|
+
readonly hold?: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "under";
|
|
24
|
+
readonly startId: string | undefined;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "adapter";
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: "bootstrap";
|
|
29
|
+
};
|
|
30
|
+
export declare const ADAPTER_START: FloorStart;
|
|
31
|
+
export declare const BOOTSTRAP_START: FloorStart;
|
|
32
|
+
/** 引擎起动:`readFloor` 原样交(`undefined` = 这次起动不带地板)。 */
|
|
33
|
+
export declare function engineStart(readFloor: ReadFloor | undefined, hold?: boolean): FloorStart;
|
|
34
|
+
/** 起动身份:`root` = 车道以 root 起(e2b `user:"root"`、local-docker `-u 0`);`exec-user` = 车道自己的执行身份(改前的形)。 */
|
|
35
|
+
export type FloorLaunchIdentity = "root" | "exec-user";
|
|
36
|
+
/**
|
|
37
|
+
* 一次起动的答案(闭集;落到 argv 只经 {@link floorArgv} / {@link e2bFloorCommand} / {@link dockerIdentityFlags} 三只编码器):
|
|
38
|
+
* · `bare` —— 与改前逐字同(车道自己的 shell argv 原样);
|
|
39
|
+
* · `control` —— 附着中的引导命令:车道自己的 shell argv,以 `identity` 起,不经监督者;
|
|
40
|
+
* · `run` —— 监督者 `run`(受滤):命令行头(`--` 之前,不含 `--env`)+ 起动身份 + 登记的起动号;
|
|
41
|
+
* · `plain` —— 监督者 `plain`(不受滤、环境恒为构建形):命令行头 + 起动身份。不受滤的代码不得读受滤 uid 改得动的东西 ⇒ e2b 的编码不走登录 shell。
|
|
42
|
+
*/
|
|
43
|
+
export type FloorLaunch = {
|
|
44
|
+
readonly mode: "bare";
|
|
45
|
+
} | {
|
|
46
|
+
readonly mode: "control";
|
|
47
|
+
readonly identity: FloorLaunchIdentity;
|
|
48
|
+
} | {
|
|
49
|
+
readonly mode: "run";
|
|
50
|
+
readonly head: readonly string[];
|
|
51
|
+
readonly identity: FloorLaunchIdentity;
|
|
52
|
+
readonly startId: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly mode: "plain";
|
|
55
|
+
readonly head: readonly string[];
|
|
56
|
+
readonly identity: FloorLaunchIdentity;
|
|
57
|
+
};
|
|
58
|
+
/** 监督者支持的架构(闭集)。 */
|
|
59
|
+
export type FloorArch = "x86_64" | "aarch64";
|
|
60
|
+
/** 沙箱里放监督者的目录:`<dir>/<arch>/sema-floor`(root 属主、0755,受滤用户不可写)。 */
|
|
61
|
+
export declare const FLOOR_DIR = "/opt/sema/floor";
|
|
62
|
+
export declare function floorBinaryPath(arch: FloorArch): string;
|
|
63
|
+
/**
|
|
64
|
+
* 监督者四个模式的命令行头(唯一写处;`--env` 与 `--` 由编码器接)。`as` = 降权目标 uid(只 e2b:root 起的 L 降到工作区属主)。
|
|
65
|
+
* 环境一条规则(协议 §3.6):`run` 下受滤的命令继承起它的进程的环境(`--as` 时 HOME / USER / LOGNAME / SHELL 取 passwd),再叠 `--env`;
|
|
66
|
+
* `plain` 的环境恒为构建形(固定 PATH + 运行 uid 的 passwd 四项 + `--env`),不继承。
|
|
67
|
+
*/
|
|
68
|
+
export declare const FLOOR_ARGV: {
|
|
69
|
+
readonly run: (bin: string, startId: string, as: string | undefined) => readonly string[];
|
|
70
|
+
readonly plain: (bin: string, as: string | undefined) => readonly string[];
|
|
71
|
+
readonly serve: (bin: string, stateDir: string, fresh: boolean) => readonly string[];
|
|
72
|
+
readonly selfcheck: (bin: string, digest: string, as: string | undefined) => readonly string[];
|
|
73
|
+
};
|
|
74
|
+
/** 沙箱的来历:`created` = 本次连接新建、还没跑过命令(`serve --fresh` 落来历标记)· `resumed` = 恢复 / 重新附着(标记必须在,否则 `provenance`)。 */
|
|
75
|
+
export type FloorOrigin = "created" | "resumed";
|
|
76
|
+
/** 自检的答案:`sema-floor selfcheck ok <version> <arch>`(退出 0)或 `sema-floor selfcheck refused <word>: <detail>`(退出 125)。 */
|
|
77
|
+
export type SelfcheckVerdict = {
|
|
78
|
+
readonly ok: true;
|
|
79
|
+
readonly version: string;
|
|
80
|
+
readonly arch: string;
|
|
81
|
+
} | {
|
|
82
|
+
readonly ok: false;
|
|
83
|
+
readonly reason: ReadFloorUnavailableReason;
|
|
84
|
+
readonly detail?: string;
|
|
85
|
+
};
|
|
86
|
+
/** 读自检输出(恰一行)。读不出 / 原因词不在闭集 ⇒ `binary_digest`(这只二进制答的不是本服务读得懂的话 —— 与钉住的不是同一只)。 */
|
|
87
|
+
export declare function parseSelfcheck(stdout: string, exitCode: number): SelfcheckVerdict;
|
|
88
|
+
/** 一问最多几条路径(协议 v1 §5.1)。 */
|
|
89
|
+
export declare const MAX_PATHS_PER_QUESTION = 256;
|
|
90
|
+
/** 一帧(一行)的字节上界(协议 §5:每行至多 1 MiB)。超了 ⇒ 这只中继违约(关掉、按掉线处置)。 */
|
|
91
|
+
export declare const MAX_RELAY_LINE_BYTES: number;
|
|
92
|
+
/**
|
|
93
|
+
* 中继帧(D 的 stdout → 适配器;协议 v1 §5.2)。每帧**恰好**列出的字段,多一个 / 少一个 / 型错 / 不认识的 `t` ⇒ `broken`(`why` 说坏在哪,进日志;
|
|
94
|
+
* 带得出问号与路径数就带上:那一问整问拒,长度对齐)。
|
|
95
|
+
*/
|
|
96
|
+
export type RelayFrameIn = {
|
|
97
|
+
readonly t: "ready";
|
|
98
|
+
readonly pid: number;
|
|
99
|
+
} | {
|
|
100
|
+
readonly t: "refused";
|
|
101
|
+
readonly why: string;
|
|
102
|
+
readonly detail: string;
|
|
103
|
+
} | {
|
|
104
|
+
readonly t: "q";
|
|
105
|
+
readonly id: number;
|
|
106
|
+
readonly start: string;
|
|
107
|
+
readonly paths: readonly string[];
|
|
108
|
+
} | {
|
|
109
|
+
readonly t: "gone";
|
|
110
|
+
readonly start: string;
|
|
111
|
+
} | {
|
|
112
|
+
readonly t: "broken";
|
|
113
|
+
readonly why: string;
|
|
114
|
+
readonly id?: number;
|
|
115
|
+
readonly count?: number;
|
|
116
|
+
};
|
|
117
|
+
export declare function parseRelayFrame(line: string): RelayFrameIn;
|
|
118
|
+
/** 适配器 → D 的唯一帧:与所问路径逐条对齐的判决(`null` = 放;非空串 = 拒,通常是判官答的拒行)。 */
|
|
119
|
+
export interface RelayAnswer {
|
|
120
|
+
readonly t: "a";
|
|
121
|
+
readonly id: number;
|
|
122
|
+
readonly verdicts: readonly (string | null)[];
|
|
123
|
+
}
|
|
124
|
+
/** 未登记(或已撤)的起动、保留号、坏帧的那一问:每条路径一律拒,判决串是这一句(监督者不解读它)。 */
|
|
125
|
+
export declare const UNJUDGED_VERDICT = "read floor: no verdict for this start";
|
|
126
|
+
/** 判官:适配器进程里唯一回答「这条路径拒不拒」的东西。live object ⇒ `create*`。 */
|
|
127
|
+
export interface FloorJudge {
|
|
128
|
+
/** 登记一次带地板的起动,回它的起动号(随机、不可猜)。`held` ⇒ 之后还会以这个号再起 `run`(`under`),直到 {@link release};否则这一次就是它唯一的起动。 */
|
|
129
|
+
register(floor: ReadFloor, held: boolean): string;
|
|
130
|
+
/** 以这个号再起一次 `run`(`under`)之前问:在册且适配器没说过「不再起」⇒ `true`(记下又有一只监督者将连上);否则 `false`(起动拒)。 */
|
|
131
|
+
launch(startId: string): boolean;
|
|
132
|
+
/** 适配器不会再以这个号起 `run` 了。登记要两件都到才撤(协议 §5.5):这一句 ∧ 此后的 `gone` —— `gone` 已在 ⇒ 当即撤;否则等它(还连着的监督者照旧有判官答)。 */
|
|
133
|
+
release(startId: string): void;
|
|
134
|
+
/** 一帧 → 要回的答(`undefined` = 不回:`ready` / `refused` / `gone` / 读不出问号或路径数的坏帧)。 */
|
|
135
|
+
answer(frame: RelayFrameIn): RelayAnswer | undefined;
|
|
136
|
+
/** 在册的起动数(钉与日志)。 */
|
|
137
|
+
readonly size: number;
|
|
138
|
+
clear(): void;
|
|
139
|
+
}
|
|
140
|
+
export declare function createFloorJudge(): FloorJudge;
|
|
141
|
+
/** 一个架构的监督者构建:钉住的摘要 + 自核过的字节;没有 ⇒ 为什么没有(附着的拒起句带上它)。 */
|
|
142
|
+
export type FloorBuild = {
|
|
143
|
+
readonly ok: true;
|
|
144
|
+
readonly digest: string;
|
|
145
|
+
readonly bytes: Uint8Array;
|
|
146
|
+
} | {
|
|
147
|
+
readonly ok: false;
|
|
148
|
+
readonly why: string;
|
|
149
|
+
};
|
|
150
|
+
/** 监督者二进制的来源:每个架构一次读法 —— 摘要与字节同出一处,不会一个在一个不在。 */
|
|
151
|
+
export interface FloorBinaries {
|
|
152
|
+
build(arch: FloorArch): FloorBuild;
|
|
153
|
+
}
|
|
154
|
+
/** 随包的二进制(`native/sandbox-read-floor/`):`DIGESTS` 每行 `<sha256> <arch>/sema-floor`;字节读出来先自核摘要,不符 / 读不出 ⇒ 这个架构没有可用构建(拒起点名 `binary_digest`)。 */
|
|
155
|
+
export declare function createPackagedFloorBinaries(root?: URL): FloorBinaries;
|
|
156
|
+
export type FloorBootstrapResult = {
|
|
157
|
+
readonly ok: true;
|
|
158
|
+
readonly exitCode: number;
|
|
159
|
+
readonly stdout: string;
|
|
160
|
+
readonly stderr: string;
|
|
161
|
+
} | {
|
|
162
|
+
readonly ok: false;
|
|
163
|
+
readonly error: string;
|
|
164
|
+
};
|
|
165
|
+
/** 中继长连的出口(本模块写帧、关连)。 */
|
|
166
|
+
export interface FloorRelayLink {
|
|
167
|
+
send(line: string): void;
|
|
168
|
+
close(): void;
|
|
169
|
+
}
|
|
170
|
+
/** 中继长连的进口(传输把字节与关闭交给本模块)。 */
|
|
171
|
+
export interface FloorRelayEvents {
|
|
172
|
+
data(chunk: string): void;
|
|
173
|
+
closed(why: string): void;
|
|
174
|
+
}
|
|
175
|
+
/** 一只适配器交给本模块的三件原语。引导命令经适配器**自己的起动接缝**(起动形 {@link BOOTSTRAP_START})起 —— 本模块只给命令行。 */
|
|
176
|
+
export interface FloorTransport {
|
|
177
|
+
/** 跑一行 POSIX shell(本模块写的固定命令)作引导起动,收输出。 */
|
|
178
|
+
bootstrap(command: string): Promise<FloorBootstrapResult>;
|
|
179
|
+
/** 把 `bytes` 放到 `path`(root 属主、0755);k8s 由 pod 的只读卷带来,答 ok 不写。 */
|
|
180
|
+
place(path: string, bytes: Uint8Array): Promise<{
|
|
181
|
+
readonly ok: true;
|
|
182
|
+
} | {
|
|
183
|
+
readonly ok: false;
|
|
184
|
+
readonly error: string;
|
|
185
|
+
}>;
|
|
186
|
+
/** 以 `identity` 起中继(本模块写的一行 shell),stdin / stdout 作一条双工。 */
|
|
187
|
+
openRelay(identity: FloorLaunchIdentity, command: string, events: FloorRelayEvents): FloorRelayLink;
|
|
188
|
+
}
|
|
189
|
+
/** 一次附着的输入:沙箱来历,与工作区目录(e2b 降到它的属主)。 */
|
|
190
|
+
export interface FloorAttach {
|
|
191
|
+
readonly origin: FloorOrigin;
|
|
192
|
+
readonly workspaceRoot: string;
|
|
193
|
+
}
|
|
194
|
+
export interface FloorLogger {
|
|
195
|
+
info?(event: string, fields?: Record<string, unknown>): void;
|
|
196
|
+
warn?(event: string, fields?: Record<string, unknown>): void;
|
|
197
|
+
}
|
|
198
|
+
/** 一只执行环境手里的地板模块。live object ⇒ `create*`。 */
|
|
199
|
+
export interface SandboxReadFloor {
|
|
200
|
+
readonly lane: SandboxFloorLane;
|
|
201
|
+
/** 这只模块所在车道的状态({@link sandboxReadFloorState} 的读数;注入的守地板模块恒 `kept`)。 */
|
|
202
|
+
readonly state: SandboxReadFloorState;
|
|
203
|
+
/** 这只模块钉住的监督者二进制(守地板 ⇒ 在;裸模块 ⇒ 缺席)。k8s 的 pod 座({@link buildFloorPodSeat})只读它 —— 放进 pod 的与自检核的是同一份钉。 */
|
|
204
|
+
readonly binaries: FloorBinaries | undefined;
|
|
205
|
+
/** 唯一接缝:一次起动 → 答案,或 `spawn_error`(F2 / F6 / 时机不对的引导起动 / 已撤的号)。 */
|
|
206
|
+
wrap(start: FloorStart): Result<FloorLaunch, ExecutionError>;
|
|
207
|
+
/** 适配器不会再以这个号起 `run`(`hold` 起动的收尾)。登记在其后的 `gone` 到时撤(还连着的监督者照旧有判官答)。 */
|
|
208
|
+
release(startId: string | undefined): void;
|
|
209
|
+
/** 连接时附着(量架构 → 放置 → 中继 → 自检);不守地板的模块什么都不做。从不抛:不过 ⇒ 记原因词,带地板的起动按 F2 拒。 */
|
|
210
|
+
attach(transport: FloorTransport, how: FloorAttach): Promise<void>;
|
|
211
|
+
/** 把一次放置失败记下(k8s:pod 带不上二进制卷时由适配器告知;附着按 `binary_digest` 拒)。 */
|
|
212
|
+
refusePlacement(detail: string): void;
|
|
213
|
+
/** 环境拆掉:关中继、清登记、不再重起。 */
|
|
214
|
+
dispose(): void;
|
|
215
|
+
}
|
|
216
|
+
export interface KeptFloorOptions {
|
|
217
|
+
readonly lane: SandboxFloorLane;
|
|
218
|
+
readonly binaries: FloorBinaries;
|
|
219
|
+
readonly logger?: FloorLogger;
|
|
220
|
+
/** 中继起来后等首帧(`ready` / `refused`)的上界(ms;缺省 15 s)。 */
|
|
221
|
+
readonly relayReadyMs?: number;
|
|
222
|
+
/** 中继掉线后重起的次数上界(缺省 3;间隔自 `relayRestartBackoffMs` 起翻倍)。 */
|
|
223
|
+
readonly relayRestarts?: number;
|
|
224
|
+
readonly relayRestartBackoffMs?: number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 守地板的模块(服务集里的车道,或钉注入)。状态机:`idle` →(附着)`attaching` → `ready` | `unavailable(原因词)`;中继掉线 ⇒ 重起
|
|
228
|
+
* (`serve` 不带 `--fresh`),重起不成 ⇒ `unavailable(relay_silent)`。
|
|
229
|
+
* 适配器自己的固定命令(I1):附着**从未开始**才裸起(这只模块还没把沙箱交给过受滤代码;恢复的沙箱由适配器先附着、再起任何命令);
|
|
230
|
+
* 附着一旦开始就再不裸起 —— 有过验明的监督者 ⇒ 经它的 `plain`(不依赖中继:掉线 / 重附着不成也照用),从没验明过 ⇒ 拒。
|
|
231
|
+
*/
|
|
232
|
+
export declare function createKeptSandboxReadFloor(opts: KeptFloorOptions): SandboxReadFloor;
|
|
233
|
+
/**
|
|
234
|
+
* 一只执行环境的地板模块 —— 适配器构造时调一次。状态 = {@link sandboxReadFloorState}(与车道块同一只判据):`kept` ⇒ 守地板的模块
|
|
235
|
+
* (随包二进制),否则裸模块。
|
|
236
|
+
*/
|
|
237
|
+
export declare function createSandboxReadFloor(opts: {
|
|
238
|
+
readonly lane: SandboxFloorLane;
|
|
239
|
+
readonly knob: SandboxReadFloorKnob | undefined;
|
|
240
|
+
readonly logger?: FloorLogger;
|
|
241
|
+
}): SandboxReadFloor;
|
|
242
|
+
/** k8s / local-docker:答案 + 车道自己的 shell argv(`<shell> -c <command>`)→ 最终 argv。`bare` ⇒ 原样(改前逐字同)。 */
|
|
243
|
+
export declare function floorArgv(launch: FloorLaunch, shellArgv: readonly string[]): readonly string[];
|
|
244
|
+
/**
|
|
245
|
+
* e2b:SDK 恒以 `/bin/bash -l -c <cmd>` 起。`bare` ⇒ `cmd` 原样、这次命令的 env 交 SDK(改前的形)。`run` / `plain` ⇒ 外层 root shell 只 `exec`
|
|
246
|
+
* 监督者;这次命令的 env 经 `--env` 交监督者,外层 shell 不带任何每命令 env(`BASH_ENV` 一类不在过滤之前生效)。沙箱级 env(建沙箱时给的)本就在
|
|
247
|
+
* 每个进程的环境里,受滤命令照旧继承(协议 §3.6),不必再传。`run` 里命令照旧是登录 shell(读 profile 发生在地板之下,与改前同);`plain` 里是
|
|
248
|
+
* 非登录 `/bin/bash -c`:不受滤的代码不读工作区属主改得动的 profile。`control`(引导)⇒ root 跑原命令,不带每命令 env。
|
|
249
|
+
*/
|
|
250
|
+
export declare function e2bFloorCommand(launch: FloorLaunch, command: string, envs: Readonly<Record<string, string>> | undefined): {
|
|
251
|
+
readonly cmd: string;
|
|
252
|
+
readonly user?: "root";
|
|
253
|
+
readonly envs?: Record<string, string>;
|
|
254
|
+
};
|
|
255
|
+
/** local-docker:`docker exec` 的身份旗标(`root` ⇒ `-u 0`;否则无,改前的形)。 */
|
|
256
|
+
export declare function dockerIdentityFlags(launch: FloorLaunch): readonly string[];
|
|
257
|
+
/** k8s 卷名:唯一一张在 `ADAPTER_VOLUME_NAMES`(补丁卷不得复用)。 */
|
|
258
|
+
export declare const FLOOR_K8S_VOLUME_NAMES: Readonly<Record<FloorArch, string>>;
|
|
259
|
+
/** ConfigMap 里放二进制的键。 */
|
|
260
|
+
export declare const FLOOR_K8S_CONFIGMAP_KEY = "sema-floor";
|
|
261
|
+
/** 一只 pod 要带的地板座(纯数据 ⇒ `build*`):先建(或已在)的 ConfigMap、pod 卷、sandbox 容器的只读挂载。 */
|
|
262
|
+
export interface FloorPodSeat {
|
|
263
|
+
readonly configMaps: ReadonlyArray<{
|
|
264
|
+
readonly name: string;
|
|
265
|
+
readonly arch: FloorArch;
|
|
266
|
+
readonly binaryDataB64: string;
|
|
267
|
+
}>;
|
|
268
|
+
readonly volumes: readonly unknown[];
|
|
269
|
+
readonly mounts: readonly unknown[];
|
|
270
|
+
}
|
|
271
|
+
/** 守地板的 k8s 模块 ⇒ 它钉住的每个架构一只 ConfigMap(名 = 架构 + 摘要前 16 位;同摘要同内容,409 = 已在)+ 卷 + 只读挂载;否则 `undefined`(pod 与改前逐字同)。 */
|
|
272
|
+
export declare function buildFloorPodSeat(floor: SandboxReadFloor): FloorPodSeat | undefined;
|
|
273
|
+
//# sourceMappingURL=sandbox-read-floor.d.ts.map
|