@sema-agent/sdk 0.0.75 → 0.0.77
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/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -2
- package/dist/client.js.map +1 -1
- package/dist/control-client.d.ts +21 -0
- package/dist/control-client.d.ts.map +1 -1
- package/dist/control-client.js +42 -1
- package/dist/control-client.js.map +1 -1
- package/dist/control-types.d.ts +108 -0
- package/dist/control-types.d.ts.map +1 -1
- package/dist/control-types.js +15 -0
- package/dist/control-types.js.map +1 -1
- package/dist/errors.d.ts +88 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +105 -8
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +214 -20
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +5 -0
- package/dist/events.js.map +1 -1
- package/dist/health.d.ts +44 -0
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js +32 -0
- package/dist/health.js.map +1 -1
- package/dist/idempotency.d.ts +8 -0
- package/dist/idempotency.d.ts.map +1 -1
- package/dist/idempotency.js +8 -0
- package/dist/idempotency.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/approvals.d.ts +43 -0
- package/dist/resources/approvals.d.ts.map +1 -1
- package/dist/resources/approvals.js +23 -3
- package/dist/resources/approvals.js.map +1 -1
- package/dist/resources/assistant.d.ts +23 -0
- package/dist/resources/assistant.d.ts.map +1 -1
- package/dist/resources/assistant.js +22 -0
- package/dist/resources/assistant.js.map +1 -1
- package/dist/resources/control/auth-providers.d.ts +17 -0
- package/dist/resources/control/auth-providers.d.ts.map +1 -1
- package/dist/resources/control/auth-providers.js +6 -0
- package/dist/resources/control/auth-providers.js.map +1 -1
- package/dist/resources/control/config.d.ts +22 -0
- package/dist/resources/control/config.d.ts.map +1 -1
- package/dist/resources/control/config.js +12 -0
- package/dist/resources/control/config.js.map +1 -1
- package/dist/resources/control/fleet.d.ts +15 -0
- package/dist/resources/control/fleet.d.ts.map +1 -1
- package/dist/resources/control/fleet.js +8 -0
- package/dist/resources/control/fleet.js.map +1 -1
- package/dist/resources/control/images.d.ts +20 -0
- package/dist/resources/control/images.d.ts.map +1 -1
- package/dist/resources/control/images.js +10 -0
- package/dist/resources/control/images.js.map +1 -1
- package/dist/resources/control/lifecycle.d.ts +8 -0
- package/dist/resources/control/lifecycle.d.ts.map +1 -1
- package/dist/resources/control/lifecycle.js +3 -0
- package/dist/resources/control/lifecycle.js.map +1 -1
- package/dist/resources/control/publish.d.ts +12 -0
- package/dist/resources/control/publish.d.ts.map +1 -1
- package/dist/resources/control/publish.js +6 -0
- package/dist/resources/control/publish.js.map +1 -1
- package/dist/resources/control/secrets.d.ts +28 -0
- package/dist/resources/control/secrets.d.ts.map +1 -1
- package/dist/resources/control/secrets.js +16 -0
- package/dist/resources/control/secrets.js.map +1 -1
- package/dist/resources/control/users.d.ts +22 -0
- package/dist/resources/control/users.d.ts.map +1 -1
- package/dist/resources/control/users.js +12 -0
- package/dist/resources/control/users.js.map +1 -1
- package/dist/resources/control/versioning.d.ts +12 -0
- package/dist/resources/control/versioning.d.ts.map +1 -1
- package/dist/resources/control/versioning.js +6 -0
- package/dist/resources/control/versioning.js.map +1 -1
- package/dist/resources/control/workers.d.ts +14 -0
- package/dist/resources/control/workers.d.ts.map +1 -1
- package/dist/resources/control/workers.js +7 -0
- package/dist/resources/control/workers.js.map +1 -1
- package/dist/resources/elicitations.d.ts +43 -0
- package/dist/resources/elicitations.d.ts.map +1 -1
- package/dist/resources/elicitations.js +8 -0
- package/dist/resources/elicitations.js.map +1 -1
- package/dist/resources/fleet.d.ts +101 -0
- package/dist/resources/fleet.d.ts.map +1 -1
- package/dist/resources/fleet.js +27 -4
- package/dist/resources/fleet.js.map +1 -1
- package/dist/resources/images.d.ts +34 -0
- package/dist/resources/images.d.ts.map +1 -1
- package/dist/resources/images.js +29 -3
- package/dist/resources/images.js.map +1 -1
- package/dist/resources/leader.d.ts +10 -0
- package/dist/resources/leader.d.ts.map +1 -1
- package/dist/resources/leader.js +4 -0
- package/dist/resources/leader.js.map +1 -1
- package/dist/resources/memory.d.ts +37 -0
- package/dist/resources/memory.d.ts.map +1 -1
- package/dist/resources/memory.js +28 -0
- package/dist/resources/memory.js.map +1 -1
- package/dist/resources/models.d.ts +12 -0
- package/dist/resources/models.d.ts.map +1 -1
- package/dist/resources/models.js +4 -0
- package/dist/resources/models.js.map +1 -1
- package/dist/resources/ops.d.ts +16 -0
- package/dist/resources/ops.d.ts.map +1 -1
- package/dist/resources/ops.js +6 -0
- package/dist/resources/ops.js.map +1 -1
- package/dist/resources/policy.d.ts +8 -0
- package/dist/resources/policy.d.ts.map +1 -1
- package/dist/resources/policy.js +1 -0
- package/dist/resources/policy.js.map +1 -1
- package/dist/resources/questions.d.ts +57 -0
- package/dist/resources/questions.d.ts.map +1 -1
- package/dist/resources/questions.js +9 -0
- package/dist/resources/questions.js.map +1 -1
- package/dist/resources/runs.d.ts +147 -0
- package/dist/resources/runs.d.ts.map +1 -1
- package/dist/resources/runs.js +129 -2
- package/dist/resources/runs.js.map +1 -1
- package/dist/resources/session-sync.d.ts +61 -0
- package/dist/resources/session-sync.d.ts.map +1 -1
- package/dist/resources/session-sync.js +54 -1
- package/dist/resources/session-sync.js.map +1 -1
- package/dist/resources/sessions.d.ts +74 -0
- package/dist/resources/sessions.d.ts.map +1 -1
- package/dist/resources/sessions.js +64 -2
- package/dist/resources/sessions.js.map +1 -1
- package/dist/resources/side-query.d.ts +18 -0
- package/dist/resources/side-query.d.ts.map +1 -1
- package/dist/resources/side-query.js +1 -0
- package/dist/resources/side-query.js.map +1 -1
- package/dist/resources/tasks.d.ts +19 -0
- package/dist/resources/tasks.d.ts.map +1 -1
- package/dist/resources/tasks.js +21 -2
- package/dist/resources/tasks.js.map +1 -1
- package/dist/resources/tool-approvals.d.ts +60 -0
- package/dist/resources/tool-approvals.d.ts.map +1 -1
- package/dist/resources/tool-approvals.js +10 -0
- package/dist/resources/tool-approvals.js.map +1 -1
- package/dist/resources/trace.d.ts +23 -0
- package/dist/resources/trace.d.ts.map +1 -1
- package/dist/resources/trace.js +27 -2
- package/dist/resources/trace.js.map +1 -1
- package/dist/resources/usage.d.ts +21 -0
- package/dist/resources/usage.d.ts.map +1 -1
- package/dist/resources/usage.js +8 -0
- package/dist/resources/usage.js.map +1 -1
- package/dist/resources/workflows.d.ts +48 -0
- package/dist/resources/workflows.d.ts.map +1 -1
- package/dist/resources/workflows.js +40 -3
- package/dist/resources/workflows.js.map +1 -1
- package/dist/settings.d.ts +90 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +24 -0
- package/dist/settings.js.map +1 -1
- package/dist/sse.d.ts +36 -0
- package/dist/sse.d.ts.map +1 -1
- package/dist/sse.js +53 -8
- package/dist/sse.js.map +1 -1
- package/dist/sync.d.ts +56 -0
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +48 -4
- package/dist/sync.js.map +1 -1
- package/dist/transport.d.ts +32 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +40 -8
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +709 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types — authoritative shapes from the service maintainer (see ../../../docs/SERVICE-CORE-CONTEXT.md).
|
|
3
|
+
* These are NOT guesses; they mirror the live service. They MUST be kept in sync with spec/openapi.yaml (M0):
|
|
4
|
+
* the contract test (producer side = service, consumer side = here) anchors both to the spec.
|
|
5
|
+
*
|
|
6
|
+
* 🔴 The SHARED WORK-VIEW MODEL (Task/Run/Artifact) is the anti-fragmentation substrate (DIRECTION.md §2):
|
|
7
|
+
* ALL doors — CC/Codex via the MCP façade, and web-native — produce the SAME Task/Run/Artifact. A dev's
|
|
8
|
+
* run and an ordinary user's run look identical in the workspace. Do NOT fork this per door.
|
|
9
|
+
*/
|
|
1
10
|
import type { SemaSettings } from "./settings.js";
|
|
11
|
+
/** Authenticated end-user identity. Opaque to the service (used as memory scope + session owner). The SDK
|
|
12
|
+
* normalizes; the service does NOT validate the format. Convention: `user:` / `org:` / `ai:` / `anon:`. */
|
|
2
13
|
export type Principal = string;
|
|
14
|
+
/** Service scenario = the primary routing axis (one image serves many). Open string (unknown → "default"). */
|
|
3
15
|
export type Scenario = "default" | "oa" | "code-review" | "team" | (string & {});
|
|
16
|
+
/** Terminal + in-flight run states. `suspended` = HITL: a policy gate (F4) or AskUserQuestion is waiting on a
|
|
17
|
+
* human — NOT an error (see resources/approvals.ts). */
|
|
18
|
+
/** design/80 D-0: `needs_review` is a durable TERMINAL (dry-run/shadow review) distinct from `suspended`
|
|
19
|
+
* (mid-run HITL pause). Closed set on purpose — a new status is minted only with a proven need (D-0 r2:
|
|
20
|
+
* don't pre-mint `plan_review`); core→wire contract test guards parity. */
|
|
4
21
|
export type RunStatus = "running" | "completed" | "failed" | "suspended" | "needs_review";
|
|
22
|
+
/** Per-task budget/usage the service reports back. */
|
|
5
23
|
export interface TaskStats {
|
|
6
24
|
turns: number;
|
|
7
25
|
tokens: number;
|
|
@@ -10,16 +28,28 @@ export interface TaskStats {
|
|
|
10
28
|
outputTokens?: number;
|
|
11
29
|
costUsd?: number;
|
|
12
30
|
cacheHitRate?: number;
|
|
31
|
+
/** 🔴 Live-verified(@sema-agent/server@1.3.0 `done.result.stats` 真回传;原 TaskStats 漏声明 → 严格消费方读不到,
|
|
32
|
+
* 尤其 `costMicroUsd`/`totalInputTokens` 是成本/总览面板要的。live full-scenario 测逮到,round-6 补)。 */
|
|
13
33
|
toolCalls?: number;
|
|
14
34
|
cacheWriteTokens?: number;
|
|
15
35
|
cacheWriteTokensLong?: number;
|
|
16
36
|
totalInputTokens?: number;
|
|
17
37
|
costMicroUsd?: number;
|
|
38
|
+
/** ASSISTANT-WIRE-CONTRACT §5(service main 6cd0164 / core 1.110.0)— cost + 人工耗时透传, 运行时已经过
|
|
39
|
+
* `GET /v1/runs/:id → result.stats` 原样回传, 这里只补类型层让 N4 总览/成本 UI 能类型安全读取(不另起 wire)。
|
|
40
|
+
* 这些字段是封闭 TaskStats 之外的可选投影, 缺则 OMIT。 */
|
|
41
|
+
/** core LLM 成本明细(开放结构, 透传不解析)。 */
|
|
18
42
|
costBreakdown?: unknown;
|
|
43
|
+
/** 便利字段: LLM + service infra 轴的合计, 仅在 infra 定价已配置且 run 终态时出现。 */
|
|
19
44
|
supervisorCost?: number;
|
|
45
|
+
/** design/89 §2.4 C2 人工复核负担轴(core 1.110.0)—— budget-EXCLUDED(永不折进成本/预算门, 同 stats.memory)。 */
|
|
20
46
|
humanReview?: {
|
|
21
47
|
count: number;
|
|
22
48
|
totalWaitMs: number;
|
|
49
|
+
/** MF-24 denial ledger。🔴 **LIVE 钉死(canary 1.6.1 在线验形 2026-06-27,deny 后 result.stats.humanReview)**:
|
|
50
|
+
* gate **恰好 4 键** `{kind, decision, toolName, waitMs}`,逐键命中、零未声明字段。**`tool_input`/`toolInput` 不在
|
|
51
|
+
* 1.6.1 gate ledger 上**(此前推测 core 1.148 会经开集带被拒入参 —— 本部署证伪;留开集 `[k]` 待更新部署再验,不加为
|
|
52
|
+
* typed 字段)。`toolName` 实采为被拒工具名(Q6/core 1.161 起 = CC 名,如 "Bash")。 */
|
|
23
53
|
gates: Array<{
|
|
24
54
|
kind: string;
|
|
25
55
|
waitMs: number;
|
|
@@ -28,23 +58,67 @@ export interface TaskStats {
|
|
|
28
58
|
[k: string]: unknown;
|
|
29
59
|
}>;
|
|
30
60
|
};
|
|
61
|
+
/** 🔴 开集:引擎 `result.stats` 可携带本类型未命名的字段(如 `costBreakdown.*` 明细;live 实测),原样透传不丢。 */
|
|
31
62
|
[key: string]: unknown;
|
|
32
63
|
}
|
|
64
|
+
/** Common request body. `objective` is required; everything else is optional and server-capped where noted.
|
|
65
|
+
* `[k: string]: unknown` mirrors the service's passthrough (scenario-specific fields like code-review's
|
|
66
|
+
* `repo`/`council`/`debate`/`rounds` ride here). 🔴 `jobId` is the work-view correlation key (DIRECTION §2):
|
|
67
|
+
* set it so the workspace groups the runs of one logical job into one Task — across BOTH doors. */
|
|
33
68
|
export interface TaskRequest {
|
|
69
|
+
/** 🔴 secret discipline: NEVER put tokens/secrets in `objective` or `systemPrompt` — commands/prompts land
|
|
70
|
+
* in the durable event stream (tool_start.args) and the L1 session history. Secrets reach the sandbox
|
|
71
|
+
* OUT-OF-BAND via the worker's `E2B_SANDBOX_ENV` (see service CONSUMER-SANDBOX-SKILLS.md). */
|
|
34
72
|
objective: string;
|
|
35
73
|
scenario?: Scenario;
|
|
74
|
+
/** Continue a conversation: pass the same sessionId across turns. Omit on first turn → service mints one. */
|
|
36
75
|
sessionId?: string;
|
|
76
|
+
/** 🔴 Per-turn MODEL (CC /model picker parity). A model alias ('sonnet'/'opus') or full id. The service
|
|
77
|
+
* resolveTaskModel (main.ts:1217) CATALOG-GATES it (body.model wins over @mention wins over the deployment
|
|
78
|
+
* default; an out-of-roster pick falls back). Maps to core TaskSpec.model. Omit ⇒ deployment/role default. */
|
|
37
79
|
model?: string;
|
|
80
|
+
/** Cheap-model gear for within-task compaction/summarize (server ≥1.243, core design/145). A catalog intent
|
|
81
|
+
* like `model` (name/tier word/id), gated against the SAME allow-list — an unknown value is a 400 on fresh
|
|
82
|
+
* submit. core clamps window-unsafe picks back to the main model (`modelFallback` on the `compacted` event).
|
|
83
|
+
* Probe `capabilities.compactionModel`; older servers drop the field. Omit ⇒ summarize role / main model. */
|
|
38
84
|
compactionModel?: string;
|
|
85
|
+
/** Work-view correlation (the anti-fragmentation substrate). A CC dispatch loop or a web job sets one
|
|
86
|
+
* jobId across its sub-runs so they group into one Task. SDK auto-generates if absent. */
|
|
39
87
|
jobId?: string;
|
|
88
|
+
/** Business/UX system prompt the CLIENT owns (decoupling seam) — STABLE per integrator version (cacheable
|
|
89
|
+
* prefix); put per-request context in `objective`. Server cap: >16384 chars → 400. */
|
|
40
90
|
systemPrompt?: string;
|
|
91
|
+
/** Append-only system prompt rider (server ≥1.243, ≈ CC `--append-system-prompt`): a STABLE block composed
|
|
92
|
+
* after the scenario base + `systemPrompt`, before the volatile tail. First-class lane for the shell's
|
|
93
|
+
* product-knowledge block — `settings.outputStyle` composes AFTER it (byte-stable order), so a style block
|
|
94
|
+
* and this rider coexist. Probe `capabilities.appendSystemPrompt`; on false/absent fall back to the
|
|
95
|
+
* `settings.outputStyle` ride-along. Same cap as `systemPrompt`: >16384 chars → 400. */
|
|
41
96
|
appendSystemPrompt?: string;
|
|
97
|
+
/** Per-request user skills (live, service 170c384): progressive disclosure, same mechanism
|
|
98
|
+
* as scenario skills. Server caps: ≤10 items, name ≤64, description ≤1024, content ≤32768 — violations 400.
|
|
99
|
+
* Merge: scenario WINS on name collision (user's dropped + warn-logged) — the safety baseline can't be
|
|
100
|
+
* overridden. Injected by the trusted BFF, never raw user input. */
|
|
42
101
|
skills?: SkillSpec[];
|
|
102
|
+
/** Per-turn reasoning strength (CC `/effort` parity). One of the core ThinkingLevel tiers:
|
|
103
|
+
* `off`|`minimal`|`low`|`medium`|`high`|`xhigh`|`max`. Service maps it → `TaskSpec.thinking`
|
|
104
|
+
* (server.ts reasoningEffort → main.ts:1270); an UNKNOWN value is a 400 (fail-loud). Omit ⇒ engine
|
|
105
|
+
* default (the model/role default). The shell stamps the user's `/effort` pick here per turn. */
|
|
43
106
|
reasoningEffort?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
107
|
+
/** User context for env-block localization (core 1.181, design/112). The shell/client knows the user's TZ +
|
|
108
|
+
* identity; the worker container runs UTC and knows neither. Threaded → service `body.clientContext` →
|
|
109
|
+
* `TaskSpec.clientContext` → core localizes the `# Environment` block's "today" to the user's zone (+ names
|
|
110
|
+
* who the agent acts for); absent ⇒ UTC date, no user line. Auto-inherited by subagent/Fork children. Shape =
|
|
111
|
+
* core `TaskSpec.clientContext`. The shell stamps `timeZone` from `Intl.DateTimeFormat().resolvedOptions()`. */
|
|
44
112
|
clientContext?: {
|
|
45
113
|
timeZone?: string;
|
|
46
114
|
userEmail?: string;
|
|
47
115
|
};
|
|
116
|
+
/** Per-request MCP servers (CC `.mcp.json` / `claude mcp add` parity). The trusted BFF/shell projects the
|
|
117
|
+
* user's local `.mcp.json` here so the engine mounts those servers' tools. Field shape = core `McpServerSpec`.
|
|
118
|
+
* HONORED only on a SINGLE-USER deployment (service `task-mcp.ts mcpInjectionHonored = requirePrincipal!==true`):
|
|
119
|
+
* there the caller is their own worker's superadmin (= CC). Multi-tenant: ignored (fail-closed, no RCE/SSRF);
|
|
120
|
+
* the fleet gets MCP via center config refs. Merge: deployment/center baseline wins on name collision (caller
|
|
121
|
+
* can ADD, never SHADOW), like `skills`. Gate whether to project via `capabilities.mcpInjection`. */
|
|
48
122
|
mcpServers?: McpServerSpec[];
|
|
49
123
|
images?: Array<{
|
|
50
124
|
data: string;
|
|
@@ -52,32 +126,137 @@ export interface TaskRequest {
|
|
|
52
126
|
} | {
|
|
53
127
|
url: string;
|
|
54
128
|
}>;
|
|
129
|
+
/** Caller-requested ceilings; server caps to the operator max (a caller may ask for less, never more). */
|
|
55
130
|
maxCostUsd?: number;
|
|
56
131
|
maxTokens?: number;
|
|
132
|
+
/** Developer-mode adversarial verify gate (impl → independent read-only verify → fix loop). Not on `stream`. */
|
|
57
133
|
verify?: boolean;
|
|
58
134
|
verifyRounds?: number;
|
|
135
|
+
/** Quality-gate cascade (cheap→strong). Mutually exclusive with verify. Not on `stream`. */
|
|
59
136
|
cascade?: boolean;
|
|
137
|
+
/** §sandbox-image-select(P0.5):送**镜像 profile 意图**(≤128 chars),service 内部按 trusted
|
|
138
|
+
* principal 用 `latestPublished(profile, viewer)` **fail-closed** 解析 digest + 再准入 → per-pod 起像(复用 select 同 visibility)。
|
|
139
|
+
* 🔴 caller **永远只送 profile,绝不送 digest/ref**(信 caller digest = fail-OPEN,对抗审逮 4 越权);解析/准入 100% 在 service 信任边界。
|
|
140
|
+
* v1 约束(违反 → 400):仅 k8s 后端;**不与 `verify`/`cascade` 同用**(镜像绑定按 sessionId,子运行换 session 会静默回退默认像,宁可 fail-loud)。 */
|
|
60
141
|
sandboxImageProfile?: string;
|
|
142
|
+
/** 约束选中像须具备的 bool 能力(`browser`/`db`/`nestedBuild`);**单独给(无 `sandboxImageProfile`)→ 400**。 */
|
|
61
143
|
capabilitiesNeeded?: string[];
|
|
144
|
+
/** E12(shell-host;service `normalizeSuggestNextPrompts` spec-fields.ts:9 / runs.ts:392 + server.ts:3276,SHIPPED)
|
|
145
|
+
* —— opt-in:run 跑完(`status:"completed"`)后 core 跑一次 LLM pass 生成「下一步可问什么」建议,service 持久成一个
|
|
146
|
+
* `suggestions` event(见 {@link AgentEvent} 的 suggestions arm)on the durable run-events tail。`true` = 用 core
|
|
147
|
+
* 默认;`{count?, role?}` = 调条数 / 指定生成用的 model role。🔴 与 `verify`/`cascade` **互斥**(那两个返 result 非
|
|
148
|
+
* streamed run → 400)。只在 `/v1/runs` durable leg 有意义(`POST /v1/tasks` 同步返 result,无 events tail)。
|
|
149
|
+
* UNTRUSTED 模型文本(service 已 redact)→ 仅 UI 展示,**绝不回喂模型**。 */
|
|
62
150
|
suggestNextPrompts?: boolean | {
|
|
63
151
|
count?: number;
|
|
64
152
|
role?: string;
|
|
65
153
|
};
|
|
154
|
+
/** MF-30 PAUSE toggle(per-request,@sema-agent/server 1.4.0 `84ff944` option B,2026-06-27 拍板)——
|
|
155
|
+
* `memoryWrite:false` → 本 run 对 memory **只读**(`writeScope:null`:无 remember 工具、无 consolidation 写;recall 仍可)。
|
|
156
|
+
* 缺省 = 写开启。引擎 main.ts:1183 / security.ts:194 读它。pause 是 per-RUN(非 per-session stored-flag)。 */
|
|
66
157
|
memoryWrite?: boolean;
|
|
158
|
+
/** 🔴 TOB-fleet 透传(core/search AI 2026-06-27,research/toc-settings-adapter/01-design.md §5②)—— fleet/远端模式
|
|
159
|
+
* 把用户 `settings.json`(CC-parity {@link SemaSettings})带给 service;**service** 把它 wire 进引擎同款 seam
|
|
160
|
+
* (SessionPolicyStore / NodeExecutionEnv / RunnerDeps.hooks),同它做 MF-* 数据契约那层。TOC-local 模式**不走这**
|
|
161
|
+
* (shell 适配器直接 wire 本地 `new Runner(deps)`)。⚠️ **service-side wire pending** —— 契约先立、service 接后即 live。
|
|
162
|
+
* SDK 只搬契约、不解释、不跑 shell-hook(那是 shell/profile 层的活)。 */
|
|
67
163
|
settings?: SemaSettings;
|
|
164
|
+
/** 🔴 LOCAL workspace 目录(FATAL 修,service root-cause A)—— 持久 HTTP 引擎(常驻 8788)的 agent
|
|
165
|
+
* bash/file 工具默认跑在**引擎启动时的固定 workspaceDir**,而非每次 `sema` 启动的目录;持久进程无从知 client 的
|
|
166
|
+
* cwd → client 在 launch 时传 `process.cwd()`,service 在 **LOCAL host-adapter 模式** honor 它(executionEnv
|
|
167
|
+
* workspaceDir = cwd)。🔒 安全:cwd 是宿主路径,**只在 local 单用户(REQUIRE_PRINCIPAL=false / host adapter)
|
|
168
|
+
* honor;云/多租户 MUST ignore**(否则租户可把共享 worker 指到任意宿主路径 = 路径穿越,同 env-defer 信任边界)。 */
|
|
68
169
|
cwd?: string;
|
|
170
|
+
/** 🔴 E18 resume-at / REWIND(core 答 §J=方案A "fork-from-entry";core prepare-task.ts:529 `spec.resumeAt`,
|
|
171
|
+
* service main.ts:1150-1166)—— 从会话历史里**某条已发生的消息**分叉一条新支线(不是 mutate 旧 run)。值 = 该消息的
|
|
172
|
+
* **E2 message eventId**(`AgentEvent.eventId`,client 在流里见过的那个),**非** core 内部 entryId —— service 持有
|
|
173
|
+
* eventId→entryId 映射、`resumeAnchorStore.resolve` 折算。**必须配 `sessionId`**(要分叉的会话;session 由 auth 派生,
|
|
174
|
+
* body 不带);**不能与 durable resume 同用**(resume 路径会先剥掉 resumeAt 再 re-resolve)。anchor 未知 → 4xx;已知但
|
|
175
|
+
* 被 compact 掉 → 同步 4xx / 异步 run-result `resume_at.not_found`。worker 无 anchor store(`resumeAnchorStore`+
|
|
176
|
+
* `getLeafId`)→ 501,与 `capabilities.resumeAt` 同对一对(能力说 yes ⟺ 路由 resolve)。 */
|
|
69
177
|
resumeAt?: string;
|
|
178
|
+
/** 🔴 与 {@link resumeAt} 配套(core runtask.ts:1834 `spec.rewindFiles`,service main.ts:1198 `body.rewindFiles===true`)
|
|
179
|
+
* —— 分叉时**同时把工作树恢复**到 resumeAt 那一回合完成时的快照(否则只回退对话、文件留在最新态)。core 自动按
|
|
180
|
+
* completed-turn 快照 capture/restore(任何 ExecutionEnv,当 fileSnapshotStore wired);worker 缺快照存储则 `rewindFiles`
|
|
181
|
+
* 能力位 false。缺省 = 不动文件。 */
|
|
70
182
|
rewindFiles?: boolean;
|
|
183
|
+
/** 🔴 E18 code-only rewind(core 1.166.0 `TaskSpec.rewindFilesTo`,commit 0bf1aeb)—— 把工作树还原到该 message
|
|
184
|
+
* entryId 的快照、**不** fork 对话(无 setLeafId)。= CC Rewind "code"-only 模式(`resumeAt`+`rewindFiles`=both、
|
|
185
|
+
* `resumeAt` 单独=conversation、本字段=code)。收的是 user-message 的 `SessionTreeEntry.id`(server anchor user
|
|
186
|
+
* message 边界后即可端到端)。与 `resumeAt` 互斥使用(code-only 不 fork 对话)。 */
|
|
71
187
|
rewindFilesTo?: string;
|
|
188
|
+
/** 🔴 PERMISSION MODE INTENT (CC permission mode: `default` | `plan` | `acceptEdits` | `bypassPermissions`).
|
|
189
|
+
* The shell/web frontend carries the RAW mode; the SERVICE INTERPRETS it (axis-aware, tighten-only): `plan` ⇒
|
|
190
|
+
* mount the first-party `present_plan` tool (core `TaskSpec.enablePlanMode`, CC ExitPlanMode parity) + read-only
|
|
191
|
+
* hands (`handsReadOnly`) = CC EnterPlanMode read-only research; `acceptEdits`/`bypassPermissions` are LOOSENING
|
|
192
|
+
* → not honorable remotely (tighten-only), coerced to `default` engine-side + enforced client-side. Carrying the
|
|
193
|
+
* INTENT (not the client's pre-interpreted core fields) keeps one interpretation across TUI+web frontends and
|
|
194
|
+
* lets the service govern per deployment axis (single-user vs multi-tenant). Omit/`default` ⇒ no stamp. */
|
|
72
195
|
permissionMode?: "default" | "plan" | "acceptEdits" | "bypassPermissions" | "auto";
|
|
196
|
+
/** 🔴 Workflow super-set (sema-cc-parity) — per-task activation of the LLM-authored workflow engine (core
|
|
197
|
+
* `run_workflow`: the agent/parallel/pipeline/phase/nested orchestrator). The SERVICE reads `body.selfOrchestration`
|
|
198
|
+
* STRICTLY (`=== true`) → `TaskSpec.selfOrchestration`, the gate that MOUNTS run_workflow (the service
|
|
199
|
+
* task-workflow.ts `selfOrchestrationFromBody` / main.ts:1343; server.ts:282 SubmitTaskRequest `selfOrchestration?`).
|
|
200
|
+
* Gated downstream: (1) DEPLOYMENT — the worker's `SELF_ORCHESTRATION_ENABLED` must be on (else a harmless no-op,
|
|
201
|
+
* dropped); (2) MULTI-TENANT — honored only when a per-principal entitlement RESOLVER is wired (fail-closed:
|
|
202
|
+
* no resolver ⇒ dropped); single-user honors directly. Absent/false ⇒ no workflow tool this run (default behaviour
|
|
203
|
+
* unchanged). Three-gate: engine-can ∧ center-may(allowWorkflows) ∧ shell-show. */
|
|
73
204
|
selfOrchestration?: boolean;
|
|
205
|
+
/** 🔴 Fork super-set (sema-cc-parity, CC `subagent_type:fork`) — per-task activation of core's first-party Fork
|
|
206
|
+
* tool: the model can fork itself into a subagent that INHERITS the parent context + shares the prompt cache
|
|
207
|
+
* (vs Task's clean-context subagent). The SERVICE reads `body.enableFork` STRICTLY (`=== true`) → `TaskSpec.enableFork`,
|
|
208
|
+
* the gate that MOUNTS the Fork tool (core prepare-task.ts: `enableFork===true` AND a durable session store with
|
|
209
|
+
* `hasSessionFork` — TOC's file backend qualifies). OPT-IN (default OFF): fork can recurse / burn tokens, so unlike
|
|
210
|
+
* `selfOrchestration` it is NOT default-on — the USER enables it (shell `SEMA_ENABLE_FORK`), the model never gets it
|
|
211
|
+
* by default (2026-07-01 拍板: 用户来开,默认对 LLM 不开). Absent/false ⇒ no fork tool this run (default unchanged).
|
|
212
|
+
* ⚠️ SERVICE must add the `body.enableFork → spec.enableFork` mapping (awaiting per CHANGELOG 1.38; client path
|
|
213
|
+
* now chosen = opt-in model tool). */
|
|
74
214
|
enableFork?: boolean;
|
|
215
|
+
/** 🔴 [876]③ Per-task custom SUBAGENTS — the shell/client projects the user's subagent definitions
|
|
216
|
+
* (`.sema/agents/*.md` or programmatic) here so the ENGINE can mount them as Task-tool agent types for THIS
|
|
217
|
+
* run. 0.0.50 BREAKING vs 0.0.49: the 0.0.49 shape (Record keyed by name, description/prompt/tools keys —
|
|
218
|
+
* a CC-SDK-style guess) never matched the live wire and was rejected 400 by every deployment; this array
|
|
219
|
+
* shape mirrors the server contract verbatim (server 1.205 `spec-fields.js` `validateTaskAgents` /
|
|
220
|
+
* `TASK_AGENT_FIELD_SHAPES` = core 1.295 `AgentDefinition`), so no consumer can have depended on the old
|
|
221
|
+
* type at runtime. Rules enforced server-side: non-empty array, ≤32 items, unique `name`s, unknown keys
|
|
222
|
+
* fail-loud 400 on the strict lane (`permissionMode` is DELIBERATELY excluded from this contract — send it
|
|
223
|
+
* and the request is rejected), body→spec lane drops invalid items with a `task_agent_dropped` warn.
|
|
224
|
+
* `model` = the SHELL-RESOLVED real model name/id (壳侧已解析,引擎零词表负担 — the server does no alias
|
|
225
|
+
* translation; resolve 'sonnet'→id before sending). Multi-tenant deployments ignore this field entirely
|
|
226
|
+
* (fail-closed, `task_agents_ignored`). Probe `capabilities.taskAgents` before sending to older servers. */
|
|
75
227
|
agents?: TaskAgentDefinition[];
|
|
228
|
+
/** 🔴 INTERACTIVE-TOOLS toggle (server 1.214 server.js:4021 — STRICT boolean, anything else 400s).
|
|
229
|
+
* `false` = the CC `-p`/headless UNATTENDED semantic: the engine does NOT mount the interactive HITL tool
|
|
230
|
+
* family (AskUserQuestion etc.) so the run never parks on a live human — it takes the headless default and
|
|
231
|
+
* keeps moving (CI / cron / fire-and-forget). `true`/omit = attended (interactive tools mount where the
|
|
232
|
+
* deployment supports them). Probe `capabilities.interactiveTools` (server hardcodes true at server.js:600)
|
|
233
|
+
* before sending to OLDER servers — an unknown-field deployment on the strict lane would 400. */
|
|
76
234
|
interactiveTools?: boolean;
|
|
235
|
+
/** 🔴 Retain background processes past the turn (server 1.214 server.js:4025 — STRICT boolean, else 400).
|
|
236
|
+
* `true` = backgrounded Bash tasks (b*) survive the run's turn end instead of being reaped (long dev servers,
|
|
237
|
+
* watch builds). HONORED only on a single-user deployment (`capabilities.retainBackgroundProcesses` =
|
|
238
|
+
* `requirePrincipal !== true`, server.js:599) — multi-tenant ignores it (a tenant must not pin processes on
|
|
239
|
+
* a shared worker). */
|
|
77
240
|
retainBackgroundProcesses?: boolean;
|
|
241
|
+
/** server ≥1.221 (core 1.314 工具面控制批,[1052]②): roster TRUE-UNMOUNT list — the named wire tools'
|
|
242
|
+
* schemas never reach the model (the deny gate saves no tokens; this does), and the assembly manifest
|
|
243
|
+
* narrows honestly. Tighten-only: core's inheritance invariant unions it into EVERY child spawn path.
|
|
244
|
+
* Malformed (non-array / empty-string items) → 400 fail-loud at submit. */
|
|
78
245
|
excludeTools?: string[];
|
|
246
|
+
/** server ≥1.221 (core 1.314): DEFERRED DISCLOSURE list — the named MOUNTED tools (built-ins included)
|
|
247
|
+
* ride the wire as a placeholder (schema bytes out of the cache prefix) and materialize via ToolSearch
|
|
248
|
+
* on demand. The carrier for the shell's "Workflow on by default but not exposed" posture. Same
|
|
249
|
+
* validation/inheritance posture as {@link excludeTools}. */
|
|
79
250
|
deferTools?: string[];
|
|
251
|
+
/** server ≥1.227 (core 1.328 R2, [1144]/[1146]): prompt PRESENTATION profile — `"simple"` (CC 212
|
|
252
|
+
* short form; the engine default when omitted) or `"classic"` (the long pre-R2 form; switchable per
|
|
253
|
+
* task/model for A/B). Pure presentation axis (no policy change); inherits through the whole
|
|
254
|
+
* delegation tree. Any other value → 400 fail-loud at submit; omit to stay on the engine default. */
|
|
80
255
|
promptProfile?: "simple" | "classic";
|
|
256
|
+
/** server ≥1.254 — context attachments family (core design/133):literal-true opt-ins
|
|
257
|
+
* (todoReminder/planModeReminder/budgetUsd/backgroundTasks/toolsDelta/mcpInstructions;false=省键),
|
|
258
|
+
* `changedFiles` 可带 {maxFiles};`agentListing`/`skillsListing` 是 core DEFAULT-ON——**explicit false
|
|
259
|
+
* 才关**(1.254 起 false 真透传;更老 server 静默丢);`todoReminderMode` "baseline"|"off"。 */
|
|
81
260
|
attachments?: {
|
|
82
261
|
todoReminder?: true;
|
|
83
262
|
todoReminderMode?: "baseline" | "off";
|
|
@@ -92,6 +271,8 @@ export interface TaskRequest {
|
|
|
92
271
|
skillsListing?: boolean;
|
|
93
272
|
mcpInstructions?: true;
|
|
94
273
|
};
|
|
274
|
+
/** server ≥1.254 — per-task limits(数值三键早有;deadline 族三 **opt-out** 只认 literal false:
|
|
275
|
+
* timeoutSec 在场即默认 ON 的 nudge/call-cap/graceful-finalize 可关)。 */
|
|
95
276
|
limits?: {
|
|
96
277
|
timeoutSec?: number;
|
|
97
278
|
maxOutputTokens?: number;
|
|
@@ -100,18 +281,29 @@ export interface TaskRequest {
|
|
|
100
281
|
callCapByDeadline?: false;
|
|
101
282
|
gracefulFinalize?: false;
|
|
102
283
|
};
|
|
284
|
+
/** server ≥1.254 — retry-on-invalid rounds for `outputSchema`(成对旋钮;1..10,无 schema 时 core 忽略)。 */
|
|
103
285
|
outputRetries?: number;
|
|
286
|
+
/** server ≥1.254 — within-task compaction 的容差旋钮(design/145,与 compactionModel 配套;0..1)。
|
|
287
|
+
* 其余 compaction 键是操作方轴,wire 不开。 */
|
|
104
288
|
compaction?: {
|
|
105
289
|
clampTolerance?: number;
|
|
106
290
|
};
|
|
107
291
|
[k: string]: unknown;
|
|
108
292
|
}
|
|
293
|
+
/** One per-task subagent definition (`TaskRequest.agents[]` item) — mirrors core `AgentDefinition` verbatim
|
|
294
|
+
* (the server whitelists exactly these keys; anything else is a 400 on the strict lane). */
|
|
109
295
|
export interface TaskAgentDefinition {
|
|
296
|
+
/** Agent name = the `subagent_type` the model passes to Task. Non-empty, ≤64 chars, unique per request. */
|
|
110
297
|
name: string;
|
|
298
|
+
/** When the model should delegate to this agent (shown in the Task tool's agent list). ≤4096 chars. */
|
|
111
299
|
whenToUse?: string;
|
|
300
|
+
/** Compact variant of `whenToUse` for lean tool listings. ≤4096 chars. */
|
|
112
301
|
whenToUseLean?: string;
|
|
302
|
+
/** Allowlist of tool names the agent may use. Omit ⇒ inherit all tools. */
|
|
113
303
|
allowTools?: string[];
|
|
304
|
+
/** Denylist of tool names (subtractive; applied after `allowTools`). */
|
|
114
305
|
denyTools?: string[];
|
|
306
|
+
/** Skills preloaded into the agent: `{ name, description, content }` (+ optional manifest/files). */
|
|
115
307
|
skills?: Array<{
|
|
116
308
|
name: string;
|
|
117
309
|
description: string;
|
|
@@ -122,19 +314,30 @@ export interface TaskAgentDefinition {
|
|
|
122
314
|
content: string;
|
|
123
315
|
}>;
|
|
124
316
|
}>;
|
|
317
|
+
/** Run the agent in the background (parent turn continues). */
|
|
125
318
|
background?: boolean;
|
|
319
|
+
/** `"worktree"` = run the agent in an isolated git worktree. */
|
|
126
320
|
isolation?: 'worktree';
|
|
321
|
+
/** Shell-resolved real model name/id — or a Model object with a string `id`. NOT an alias (the server does
|
|
322
|
+
* no translation). Omit ⇒ inherit the parent model. */
|
|
127
323
|
model?: string | {
|
|
128
324
|
id: string;
|
|
129
325
|
[k: string]: unknown;
|
|
130
326
|
};
|
|
327
|
+
/** Thinking level: off | minimal | low | medium | high | xhigh | max. */
|
|
131
328
|
thinking?: string;
|
|
329
|
+
/** The agent's system prompt. ≤65536 chars. */
|
|
132
330
|
systemPrompt?: string;
|
|
331
|
+
/** Max agent turns before the subagent is stopped. Positive integer. */
|
|
133
332
|
maxTurns?: number;
|
|
333
|
+
/** Memory spec (`{ scope?, scopes?, writeScope?, enabled?, scopeContract? }`). */
|
|
134
334
|
memory?: Record<string, unknown>;
|
|
335
|
+
/** Observer prompt (agent-observes-agent lane). ≤4096 chars. */
|
|
135
336
|
observer?: string;
|
|
337
|
+
/** Message template the observer sends. ≤4096 chars. */
|
|
136
338
|
observerMessage?: string;
|
|
137
339
|
}
|
|
340
|
+
/** Synchronous task result (`POST /v1/tasks`). */
|
|
138
341
|
export interface TaskResult {
|
|
139
342
|
taskId: string;
|
|
140
343
|
sessionId: string;
|
|
@@ -143,51 +346,109 @@ export interface TaskResult {
|
|
|
143
346
|
errorCode?: string;
|
|
144
347
|
errorMessage?: string;
|
|
145
348
|
stats: TaskStats;
|
|
349
|
+
/** MF-25 — effective model id that ran the task(`done.result.model`,engine main.ts:1339 `model: config.model.id`)。
|
|
350
|
+
* 成本/总览面板据此知"哪个模型跑的"。live 实测引擎真回传(@sema-agent/server 1.3.0+)。 */
|
|
146
351
|
model?: string;
|
|
352
|
+
/** Present when the task was run behind the verify gate. */
|
|
147
353
|
verification?: {
|
|
148
354
|
verdict: "PASS" | "FAIL" | "PARTIAL" | "unverified";
|
|
149
355
|
rounds: number;
|
|
150
356
|
findings: string[];
|
|
151
357
|
};
|
|
358
|
+
/** [1543] SDK-M 补键(core 真域逐字,engine 一直在发、此前封闭接口读不到):
|
|
359
|
+
* salvagedOutput = degenerate/timeout 终态抢救出的最后模型文本(render as partial);
|
|
360
|
+
* blockedReason = 任务被策略/门挡下的人类可读因;
|
|
361
|
+
* checkpointGate = suspended 时挂起的门(与 events 的 `suspended.gate` 同源——poller 面读这里);
|
|
362
|
+
* degraded = 模型降级链实录(from/to/reason/atTurn);
|
|
363
|
+
* structuredOutput = outputSchema 任务的结构化产出(0.0.74 的 outputRetries 旋钮所服务的产物)。 */
|
|
364
|
+
salvagedOutput?: string;
|
|
365
|
+
blockedReason?: string;
|
|
366
|
+
checkpointGate?: unknown;
|
|
367
|
+
degraded?: {
|
|
368
|
+
from: string;
|
|
369
|
+
to: string;
|
|
370
|
+
reason: "breaker_open" | "rate_limit" | "budget" | "server_error" | "last_resort" | (string & {});
|
|
371
|
+
chain?: string[];
|
|
372
|
+
atTurn: number;
|
|
373
|
+
};
|
|
374
|
+
structuredOutput?: unknown;
|
|
375
|
+
[k: string]: unknown;
|
|
152
376
|
}
|
|
377
|
+
/** Async run receipt (`POST /v1/runs` → 202). The capability token is NEVER on the wire (server-internal). */
|
|
153
378
|
export interface RunReceipt {
|
|
154
379
|
taskId: string;
|
|
155
380
|
sessionId: string;
|
|
156
381
|
status: RunStatus;
|
|
157
382
|
}
|
|
383
|
+
/** §sandbox-image catalog(service IMAGE-API §7)— `GET /v1/images` 的目录行(visibility 按 principal scoped)。
|
|
384
|
+
* 门B「选沙箱模板」UI 据此渲染(profile 卡 + 能力徽章 + toolchain)。开集容多余字段;字段源自 worker → 渲染前 sanitize。 */
|
|
385
|
+
/** `GET /v1/models` 的非密钥模型目录条目(core 1.116 `@model` mention 线;service server.ts:535)。
|
|
386
|
+
* `name` = `@handle`(用户在正文打 `@<name>` per-task 选它)。🔴 **只名/能力,无 baseUrl/apiKey/headers**(service 已剥)。 */
|
|
158
387
|
export interface ModelInfo {
|
|
388
|
+
/** `@mention` 句柄 = 用户可选的模型名。 */
|
|
159
389
|
name: string;
|
|
390
|
+
/** 底层 model id(展示用,如 deepseek-v4-pro)。 */
|
|
160
391
|
id?: string;
|
|
161
392
|
provider?: string;
|
|
393
|
+
/** 该模型是否 reasoning 档(picker 可标徽章)。 */
|
|
162
394
|
reasoning?: boolean;
|
|
395
|
+
/** 是否支持图片输入。 */
|
|
163
396
|
vision?: boolean;
|
|
397
|
+
/** E4(shell-host;service server.ts:868-874,SHIPPED)— 上下文窗口 token 总额 = 「% 上下文已用 / 距 compact N
|
|
398
|
+
* token / 低上下文告警」仪表的**分母**。soft-degrade:未知(0)则 service 省略 → 壳渲染裸 token 数无 %。
|
|
399
|
+
* (分子 `turn_end.usage.contextTokens` 仍 core-blocked;分母此处已可独立用。) */
|
|
164
400
|
contextWindow?: number;
|
|
401
|
+
/** E4(service server.ts:874,SHIPPED)— 该模型单次输出的 max token(`maxTokens`)。未知则省略。 */
|
|
165
402
|
maxOutputTokens?: number;
|
|
403
|
+
/** E7(shell-host;service server.ts:875-879,SHIPPED)— `/effort` picker 的选项 = core 权威默认档集
|
|
404
|
+
* (minimal/low/medium/high)。**仅 reasoning 模型**有(非 reasoning 省略,effort 不适用)。这是 picker 默认展示集,
|
|
405
|
+
* 非硬白名单(请求侧 accept-set 更宽 = 任意 core ThinkingLevel)。 */
|
|
166
406
|
supportedEffortLevels?: string[];
|
|
167
407
|
[k: string]: unknown;
|
|
168
408
|
}
|
|
409
|
+
/** §cost/usage 面板(service `GET /v1/usage`,实测形态已按源审计)—— per-principal 成本配额 + 单任务上限。
|
|
410
|
+
* CLI `/cost` `/usage` 面板 + 门B 用量条据此渲染真数据(取代静态占位)。🔴 owner-scoped:worker 据 request principal 自算。
|
|
411
|
+
* 无配额时 `enabled:false` + 仅 `windowSec`/`maxTask*`(金额/limit 字段缺)→ 渲染须容缺。permissive 开集容未来字段。 */
|
|
169
412
|
export interface UsageInfo {
|
|
413
|
+
/** 是否配置了成本配额窗口(false ⇒ 仅有单任务上限,无窗口用量账本)。 */
|
|
170
414
|
enabled: boolean;
|
|
415
|
+
/** 配额滚动窗口秒数(如 86400=日窗)。 */
|
|
171
416
|
windowSec?: number;
|
|
417
|
+
/** 当前窗口已用(micro-USD,1e-6 美元)。 */
|
|
172
418
|
usedMicroUsd?: number;
|
|
419
|
+
/** 当前窗口已用(USD,便利投影)。 */
|
|
173
420
|
usedUsd?: number;
|
|
421
|
+
/** 窗口配额上限(micro-USD)。 */
|
|
174
422
|
limitMicroUsd?: number;
|
|
423
|
+
/** 窗口配额上限(USD)。 */
|
|
175
424
|
limitUsd?: number;
|
|
425
|
+
/** 窗口剩余额度(micro-USD;limit - used)。 */
|
|
176
426
|
remainingMicroUsd?: number;
|
|
427
|
+
/** 是否已超出窗口配额(超则新任务被拦,等 retryAfterSec)。 */
|
|
177
428
|
overLimit?: boolean;
|
|
429
|
+
/** 超限时建议的重试等待秒数。 */
|
|
178
430
|
retryAfterSec?: number;
|
|
431
|
+
/** 单任务成本硬上限(USD;与窗口配额独立,总在)。 */
|
|
179
432
|
maxTaskCostUsd?: number;
|
|
433
|
+
/** 单任务 token 硬上限(与窗口配额独立,总在)。 */
|
|
180
434
|
maxTaskTokens?: number;
|
|
181
435
|
[k: string]: unknown;
|
|
182
436
|
}
|
|
437
|
+
/** §permissions 面板(service `GET /v1/policy`,实测形态已按源审计)—— 当前生效的自治档 + 命令策略 + 上限。
|
|
438
|
+
* CLI `/permissions` 面板渲它显「现在能自动做什么、哪些要审批、上限多少」(取代静态占位,真实反映 worker 侧策略)。
|
|
439
|
+
* 🔴 只读快照:client 不重算/不据此放行(放行 100% 在 worker;面板仅 inspect)。permissive 开集 + 内部嵌套形态容演进。 */
|
|
183
440
|
export interface PolicyInfo {
|
|
441
|
+
/** 自治档(如 "auto"/"supervised"/...;null = 未设/默认)。开放串,渲染读已知值、容未知。 */
|
|
184
442
|
autonomy?: string | null;
|
|
443
|
+
/** 命令 → 决策(allow/deny/ask 等)的策略表。内部形态 permissive,渲染读 command/decision。 */
|
|
185
444
|
commandPolicy?: Array<{
|
|
186
445
|
command?: string;
|
|
187
446
|
decision?: string;
|
|
188
447
|
[k: string]: unknown;
|
|
189
448
|
}>;
|
|
449
|
+
/** 触发人工审批的条件列表(开放结构,透传不解析)。 */
|
|
190
450
|
approvalRequire?: unknown[];
|
|
451
|
+
/** 生效上限(单任务 + principal 级 + 配额窗口)。缺字段容缺。 */
|
|
191
452
|
limits?: {
|
|
192
453
|
maxTaskCostUsd?: number;
|
|
193
454
|
maxTaskTokens?: number;
|
|
@@ -197,51 +458,98 @@ export interface PolicyInfo {
|
|
|
197
458
|
};
|
|
198
459
|
[k: string]: unknown;
|
|
199
460
|
}
|
|
461
|
+
/** §workflows 可观测(core 1.116 design/97;service `GET /v1/workflows*`)。
|
|
462
|
+
* 生命周期状态;开放联合容未来新态。源=core `WorkflowRunStatus`(running/completed/failed,workflow-run-store.ts)。 */
|
|
200
463
|
export type WorkflowRunStatus = "queued" | "running" | "completed" | "failed" | (string & {});
|
|
464
|
+
/** `GET /v1/workflows` 列表行 = core `summarizeWorkflowRun` 投影(workflow-run-store.ts:34,跨 InMem/File/PG byte-identical)。
|
|
465
|
+
* owner-scoped(service 只返调用方 principal 自己的 run,scope=创建者 principal)。时间均 epoch ms。 */
|
|
201
466
|
export interface WorkflowRunSummary {
|
|
467
|
+
/** run id(= `WorkflowRun.id`)。 */
|
|
202
468
|
id: string;
|
|
469
|
+
/** 租户/分组 scope(= 创建 run 的 principal)。 */
|
|
203
470
|
scope: string;
|
|
471
|
+
/** 🔴 K-2(core SHIPPED 1.155.0)—— `/workflows` 列表渲染:工作流名/描述/当前 phase 标题。core
|
|
472
|
+
* `summarizeWorkflowRun` 投影发(additive/tolerate-absent)。 */
|
|
204
473
|
name?: string;
|
|
205
474
|
description?: string;
|
|
206
475
|
currentPhase?: string;
|
|
207
476
|
status: WorkflowRunStatus;
|
|
477
|
+
/** 已记录的 phase 数。 */
|
|
208
478
|
phaseCount: number;
|
|
479
|
+
/** 已记录的 agent-run 数。 */
|
|
209
480
|
agentCount: number;
|
|
481
|
+
/** 总 token = own + nested(summary 已折叠;triage 排序键)。 */
|
|
210
482
|
tokens: number;
|
|
483
|
+
/** 起始 epoch ms。🔴 MF-W:**queued 态还没起跑 → optional**(1.6.0 / core 1.150,startedAt now optional)。 */
|
|
211
484
|
startedAt?: number;
|
|
485
|
+
/** 结束 epoch ms(running 时缺)。 */
|
|
212
486
|
endedAt?: number;
|
|
487
|
+
/** 记录创建 epoch ms(listByScope 排序键)。 */
|
|
213
488
|
createdAt: number;
|
|
214
489
|
[k: string]: unknown;
|
|
215
490
|
}
|
|
491
|
+
/** MF-W (workflow monitor "Activity · last N of M tool calls") — one tool-call beat on a workflow agent's bounded
|
|
492
|
+
* activity tail. Source = core `ToolActivity` (types.ts:1023-1035), projected verbatim by the service detail
|
|
493
|
+
* handler (`summarizeWorkflowDetail` → `activity: a.activity`, server.ts). Maps to the shell `WorkflowToolCall
|
|
494
|
+
* { name, arg? }` (MF-W-workflow-monitor.md): `toolName`→`name`, `arg`→`arg`.
|
|
495
|
+
* 🔴 `arg` is a SHORT primary-arg summary (command→name, path→basename, url→origin+path), SECRET-SCRUBBED +
|
|
496
|
+
* truncated (~80 code points) by core — it is for the monitor's `Read(path)` / `Bash(grep …)` display, NOT the
|
|
497
|
+
* full args; render it, NEVER re-feed it to a model. Open shape (index sig) — tolerate future fields. */
|
|
216
498
|
export interface WorkflowActivityBeat {
|
|
217
499
|
phase?: "start" | "end";
|
|
218
500
|
toolCallId?: string;
|
|
501
|
+
/** The tool name (shell renders `${toolName}(${arg})`). */
|
|
219
502
|
toolName?: string;
|
|
503
|
+
/** SHORT, secret-scrubbed, ~80-code-point primary-arg summary (set on `phase:"start"`). UNTRUSTED display text. */
|
|
220
504
|
arg?: string;
|
|
505
|
+
/** Set on `phase:"end"` — whether the tool call errored. */
|
|
221
506
|
isError?: boolean;
|
|
222
507
|
[k: string]: unknown;
|
|
223
508
|
}
|
|
509
|
+
/** MF-W — one agent-run row in a workflow's detail (`summarizeWorkflowDetail` agents projection, server.ts). The
|
|
510
|
+
* shape is PERMISSIVE (index sig) — read the known render fields, tolerate the rest as the projection evolves.
|
|
511
|
+
* The typed fields are the ones the monitor keys on; `activity[].arg` is the load-bearing addition (round-3 ③). */
|
|
224
512
|
export interface WorkflowAgentRow {
|
|
513
|
+
/** Display label ("port:/mcp"). */
|
|
225
514
|
label?: string;
|
|
515
|
+
/** Lifecycle status (the input vocab the display derivation reads). */
|
|
226
516
|
status?: string;
|
|
517
|
+
/** The phase title this agent ran under (groups it into a phase bucket). */
|
|
227
518
|
phase?: string;
|
|
519
|
+
/** Per-agent model display label ("Opus 4.8 (1M context)") — SVC-4 / CORE-8 ①. */
|
|
228
520
|
model?: string;
|
|
229
521
|
tokens?: number;
|
|
230
522
|
turns?: number;
|
|
523
|
+
/** Total tool calls ("M" in "last N of M tool calls") — CORE-8 ②. */
|
|
231
524
|
toolCalls?: number;
|
|
525
|
+
/** MF-W "Activity" tail — the LAST-N tool-call beats (bounded; `arg` is the per-beat display summary). CORE-8 ③. */
|
|
232
526
|
activity?: WorkflowActivityBeat[];
|
|
527
|
+
/** What the worker was ASKED (core-redacted + bounded). UNTRUSTED display text. */
|
|
233
528
|
prompt?: string;
|
|
529
|
+
/** The worker's final OUTPUT (core-redacted + bounded). UNTRUSTED display text. */
|
|
234
530
|
output?: string;
|
|
235
531
|
[k: string]: unknown;
|
|
236
532
|
}
|
|
533
|
+
/** `GET /v1/workflows/:id` 完整 run(core `WorkflowRun`,orchestration/workflow.ts;service `summarizeWorkflowDetail`
|
|
534
|
+
* 投影)。非 owner → 404(无 existence oracle)。
|
|
535
|
+
* 🔴 phases/groups/stats 内部嵌套形态可能演进 → 标 permissive(unknown[]/index sig);消费方按需读、容缺。
|
|
536
|
+
* 🔴 round-3 ③: `agents[]` 收紧为 {@link WorkflowAgentRow}(暴露 `activity[].arg`,MF-W 监视器渲染键),仍 index-sig 容缺。
|
|
537
|
+
* 🔴 工作流级 `name`/`description`(core `WorkflowRun.name?/description?` 确有,MF-W 头部要)截至 service `1bf7a5c`
|
|
538
|
+
* **未被 `summarizeWorkflowDetail`/`summarizeWorkflowRun` 投到 wire** → SDK 暂不声明(不造没发的形;service 补投后再加)。 */
|
|
237
539
|
export interface WorkflowRun {
|
|
238
540
|
id: string;
|
|
239
541
|
scope: string;
|
|
240
542
|
status: WorkflowRunStatus;
|
|
543
|
+
/** 🔴 K-2c detail 侧(service `summarizeWorkflowDetail` server.ts:5171-5172,redacted/omit-when-absent)—— 工作流头部
|
|
544
|
+
* 名/副标题(来自脚本 `export const meta={name,description}`)。detail **不带 `currentPhase`**(那是 summary 行字段;
|
|
545
|
+
* detail 有完整 `phases[]` 含 per-phase `title`,当前 phase 自这里取)。老 run 二者皆缺。 */
|
|
241
546
|
name?: string;
|
|
242
547
|
description?: string;
|
|
548
|
+
/** 阶段记录(内部形态 permissive;渲染读 length/已知字段即可。detail 投结构化 `{title,status,startedAt,endedAt,durationMs,done,total}`)。 */
|
|
243
549
|
phases: unknown[];
|
|
550
|
+
/** agent-run 记录(收紧为 {@link WorkflowAgentRow}:暴露 MF-W `activity[].arg`;仍容缺/容演进)。 */
|
|
244
551
|
agents: WorkflowAgentRow[];
|
|
552
|
+
/** 统计(`stats.tokens` own + `stats.nested.tokens`,R-5 own/nested 分开存)。 */
|
|
245
553
|
stats: {
|
|
246
554
|
tokens?: number;
|
|
247
555
|
nested?: {
|
|
@@ -250,6 +558,7 @@ export interface WorkflowRun {
|
|
|
250
558
|
};
|
|
251
559
|
[k: string]: unknown;
|
|
252
560
|
};
|
|
561
|
+
/** 起始 epoch ms。🔴 MF-W:queued 态还没起跑 → optional(1.6.0 / core 1.150)。 */
|
|
253
562
|
startedAt?: number;
|
|
254
563
|
endedAt?: number;
|
|
255
564
|
createdAt: number;
|
|
@@ -267,9 +576,11 @@ export interface ImageIndexEntry {
|
|
|
267
576
|
podContract?: Record<string, unknown>;
|
|
268
577
|
status?: string;
|
|
269
578
|
visibility?: string;
|
|
579
|
+
/** 不可变 digest(一个 running sandbox 由它 build)。🔴 UI **仅展示**,caller **绝不送它回去绑定**(绑定送 profile)。 */
|
|
270
580
|
digest?: string;
|
|
271
581
|
[k: string]: unknown;
|
|
272
582
|
}
|
|
583
|
+
/** `POST /v1/images/select` 的 §7 resolution 结果(**仅 UI 预览"这 profile 解析到哪个 digest/能力",非绑定凭证**)。 */
|
|
273
584
|
export interface ImageSelectResult {
|
|
274
585
|
profile?: string;
|
|
275
586
|
digest?: string;
|
|
@@ -283,6 +594,8 @@ export interface ImageSelectResult {
|
|
|
283
594
|
manifestSha?: string;
|
|
284
595
|
[k: string]: unknown;
|
|
285
596
|
}
|
|
597
|
+
/** Run state (`GET /v1/runs/:id`) — LIVE shape (service Drift 2): `result` is the NESTED TaskResult
|
|
598
|
+
* (output text = result.result, stats = result.stats; no top-level stats); error text field is `error`. */
|
|
286
599
|
export interface RunRecord {
|
|
287
600
|
taskId: string;
|
|
288
601
|
sessionId: string;
|
|
@@ -290,17 +603,30 @@ export interface RunRecord {
|
|
|
290
603
|
result?: TaskResult;
|
|
291
604
|
errorCode?: string;
|
|
292
605
|
error?: string;
|
|
606
|
+
/** Work-view correlation. Present when the run has a jobId (omitted when null). LIVE server-side
|
|
607
|
+
* (service 63b8696): persisted + groupable via `GET /v1/tasks?jobId=`. */
|
|
293
608
|
jobId?: string;
|
|
609
|
+
/** System-level attribution, DERIVED FROM the authenticating credential (unforgeable; body injection is
|
|
610
|
+
* ignored). e.g. "oa" | "cc-mcp" | "portal". LIVE (service cf1be73). */
|
|
294
611
|
source?: string;
|
|
612
|
+
/** E12 prompt-suggestions(`suggestNextPrompts:true` 提交后)—— **完成后**才产(settle 前 undefined,轮询到出现);
|
|
613
|
+
* UNTRUSTED 模型文本、仅 UI、绝不回喂模型。🔴 **LIVE 验证(tidb 引擎 2026-06-27)**:`runs.get`
|
|
614
|
+
* 把 events tail 上最后一个 `suggestions` 事件读进此字段(server.ts:1371)—— 不流式消费 events 的轮询方从这读。
|
|
615
|
+
* 仅 durable run(async,需 TiDB run store);流式消费方读 {@link AgentEvent} 的 `suggestions` arm(两路同源)。 */
|
|
295
616
|
suggestions?: string[];
|
|
296
617
|
}
|
|
618
|
+
/** Run list item (`GET /v1/tasks` items) — the live cheap `runSummary` shape (service Drift 1).
|
|
619
|
+
* NOTE wire names: `id` (not taskId), `startedAt` (not createdAt), `costMicroUsd` (micro-USD); no sessionId. */
|
|
297
620
|
export interface TaskSummary {
|
|
298
621
|
id: string;
|
|
299
622
|
status: RunStatus;
|
|
300
623
|
scenario?: string;
|
|
301
624
|
jobId?: string;
|
|
625
|
+
/** Credential-derived system attribution. */
|
|
302
626
|
source?: string;
|
|
627
|
+
/** Objective, secret-redacted then truncated to 120 chars (the pinned wire contract; older rows null/absent). */
|
|
303
628
|
objectivePreview?: string;
|
|
629
|
+
/** Run owner principal (boss/operator view; the pinned wire contract). */
|
|
304
630
|
owner?: string;
|
|
305
631
|
startedAt: string;
|
|
306
632
|
endedAt?: string;
|
|
@@ -313,25 +639,59 @@ export interface TaskSummary {
|
|
|
313
639
|
};
|
|
314
640
|
[k: string]: unknown;
|
|
315
641
|
}
|
|
642
|
+
/** A workspace artifact — deterministic projection of persisted tool events (co-signed with the service).
|
|
643
|
+
* `kind` is an OPEN set: render unknown kinds as a generic row, never crash. v1 emits "file" | "git-push"
|
|
644
|
+
* ("diff" reserved, not emitted). */
|
|
316
645
|
export interface Artifact {
|
|
646
|
+
/** "<taskId>:<n>" — stable within the task (UI key). */
|
|
317
647
|
id: string;
|
|
318
648
|
taskId: string;
|
|
649
|
+
/** Present when the run has a job (job-level aggregation key). */
|
|
319
650
|
jobId?: string;
|
|
320
651
|
kind: "file" | "git-push" | "diff" | (string & {});
|
|
652
|
+
/** file: workspace-relative path; git-push: refspec tail or command. */
|
|
321
653
|
ref: string;
|
|
322
654
|
summary?: string;
|
|
655
|
+
/** ts of the last successful contributing call. */
|
|
323
656
|
createdAt: string;
|
|
657
|
+
/** file kind only — HUNK-LEVEL line stats derived from logged call args (NOT a git diff; upgrades to the
|
|
658
|
+
* reserved `diff` kind when a real patch store lands). the pinned wire contract. */
|
|
324
659
|
additions?: number;
|
|
325
660
|
deletions?: number;
|
|
326
661
|
[k: string]: unknown;
|
|
327
662
|
}
|
|
663
|
+
/** The `suspended` event's gate payload (core checkpoint-store). Tool args / question text
|
|
664
|
+
* are NOT here — join the same task's trace tool-call block via approvals' toolCallId.
|
|
665
|
+
*
|
|
666
|
+
* OPEN DISCRIMINATED SET (design/80 D-0) — mirrors core `src/core/checkpoint-store.ts` CheckpointGate.
|
|
667
|
+
* Consumers MUST branch on `kind` and render an unknown `kind` generically (never crash): core can mint a
|
|
668
|
+
* kind this wire predates, and a contract test pins core→wire parity so a new core arm fails CI, not prod. */
|
|
328
669
|
export interface CheckpointGate {
|
|
670
|
+
/** OPEN SET — branch on this, render an UNKNOWN kind generically (interface, not a closed union, so a new
|
|
671
|
+
* core kind doesn't break narrowing — same idiom as `Artifact.kind`). Known kinds:
|
|
672
|
+
* - `human` — plain HITL approval (budget-auto-approvable). has `reason`, `toolName`.
|
|
673
|
+
* - `irreversible_ask` — design/37 irreversibility / design/70 egress safety-tighten; NOT budgetable
|
|
674
|
+
* (load-bearing safety gate). has `reason`, `toolName`.
|
|
675
|
+
* - `resource_limit` — design/74 cost/token/time slice boundary; resolve `{decision:"continue"}`. has `reason`.
|
|
676
|
+
* - `needs_review` — design/76 dry-run/shadow → durable `needs_review` TERMINAL (POST-prediction review,
|
|
677
|
+
* disjoint from the approval family). has `reason`.
|
|
678
|
+
* - `task_done` — design/38 Path A background sub-task handle (door B never sees it). */
|
|
329
679
|
kind: "human" | "irreversible_ask" | "resource_limit" | "needs_review" | "task_done" | (string & {});
|
|
680
|
+
/** Present on human / irreversible_ask / resource_limit / needs_review (not task_done). */
|
|
330
681
|
reason?: string;
|
|
682
|
+
/** Present on human / irreversible_ask. */
|
|
331
683
|
toolName?: string;
|
|
332
684
|
[k: string]: unknown;
|
|
333
685
|
}
|
|
686
|
+
/** The prompt-assembly manifest (server ≥1.219 — core `prompt.assembled` trace contract verbatim,
|
|
687
|
+
* service budget.ts `promptManifestRecordOf` 实拆): constitution ownership + per-section digests +
|
|
688
|
+
* the tool contract summary. Carries ONLY ids/digests/counts — NEVER prompt bodies (privacy boundary);
|
|
689
|
+
* hashes are process-salted (NOT comparable across worker restarts — UI must not diff them cross-process).
|
|
690
|
+
* v1 face = constitution/blocks/totalChars; `sections`/`tools` are the v2 additive face (absent on a
|
|
691
|
+
* v1-only engine). ⚠️ One task can carry MULTIPLE manifests: a cascade/verify run re-prepares under one
|
|
692
|
+
* taskId and every rung's manifest is persisted in emission order (server runs.ts flushPromptManifest). */
|
|
334
693
|
export interface PromptManifest {
|
|
694
|
+
/** Who owned the constitution layer: "core" is the steady state; anything else is worth eyes. */
|
|
335
695
|
constitution: "core" | "replaced" | "provider-assembled" | "legacy" | (string & {});
|
|
336
696
|
blocks: Array<{
|
|
337
697
|
id: string;
|
|
@@ -362,14 +722,21 @@ export interface PromptManifest {
|
|
|
362
722
|
totalChars: number;
|
|
363
723
|
[k: string]: unknown;
|
|
364
724
|
}
|
|
725
|
+
/** A session's prompt-epoch pin (server ≥1.220 `GET /v1/sessions/:id` additive `promptEpoch`; core
|
|
726
|
+
* `session.getPromptEpoch()` contract verbatim, service audit.ts 实拆). Absent key = a pre-epoch
|
|
727
|
+
* session (never null). `activatedBy: "legacy_migration"` = the one-time re-pin after an engine
|
|
728
|
+
* upgrade (normal, not an anomaly). */
|
|
365
729
|
export interface PromptEpoch {
|
|
366
730
|
epoch: number;
|
|
731
|
+
/** `sha256:<64 hex>` — core's normalize gate rejects anything else (a bad pin reads as absent). */
|
|
367
732
|
artifactDigest: string;
|
|
368
733
|
packId: string;
|
|
369
734
|
assemblyApi: number;
|
|
370
735
|
activatedBy: "session_start" | "compaction" | "legacy_migration" | (string & {});
|
|
371
736
|
[k: string]: unknown;
|
|
372
737
|
}
|
|
738
|
+
/** A trace turn (GET /v1/tasks/:id/turns items — true shape). role currently only
|
|
739
|
+
* "assistant" (user/system/tool reserved). */
|
|
373
740
|
export interface TraceTurn {
|
|
374
741
|
seq: number;
|
|
375
742
|
ts: string;
|
|
@@ -383,6 +750,14 @@ export interface TraceTurn {
|
|
|
383
750
|
};
|
|
384
751
|
[k: string]: unknown;
|
|
385
752
|
}
|
|
753
|
+
/** Open set — render unknown types generically, never crash.
|
|
754
|
+
*
|
|
755
|
+
* design/99 §E1/§E2 (SHIPPED, service `TraceBlock`/`projectEvents` project.ts:69-73,160-165): the action-card
|
|
756
|
+
* BODY now rides the trace. `tool-result.output` (+ `truncated`) is the model-facing result content — UNTRUSTED
|
|
757
|
+
* RAW, but the service has already `redactDeep`'d + SIZE-bounded it at append (the old "ALWAYS absent" gap is
|
|
758
|
+
* CLOSED). NON-UNIFORM (string | (TextContent|ImageContent)[]; truncated ⇒ a single string); absent ⇒ no body.
|
|
759
|
+
* Both `tool-call` and `tool-result` also carry the §E2 identity (`eventId` = dedup/resume handle;
|
|
760
|
+
* `parentToolCallId` = sub-agent attribution), additive / tolerate-absent. */
|
|
386
761
|
export type TraceBlock = {
|
|
387
762
|
type: "thinking";
|
|
388
763
|
text: string;
|
|
@@ -404,27 +779,66 @@ export type TraceBlock = {
|
|
|
404
779
|
truncated?: boolean;
|
|
405
780
|
eventId?: string;
|
|
406
781
|
parentToolCallId?: string;
|
|
407
|
-
}
|
|
782
|
+
}
|
|
783
|
+
/** server ≥1.219 ([998]②/[1005]①b): the assembly manifest rendered at the TOP of the turn it prepared
|
|
784
|
+
* (web's "Prompt 组成" card source; service project.ts projectEvents `prompt_assembled` 实拆). */
|
|
785
|
+
| ({
|
|
408
786
|
type: "prompt-assembled";
|
|
409
787
|
} & PromptManifest) | {
|
|
410
788
|
type: string;
|
|
411
789
|
[k: string]: unknown;
|
|
412
790
|
};
|
|
791
|
+
/** A trace-relay SSE event (`GET /v1/tasks/:id/stream` — the workspace LIVE timeline, `streamTaskTrace` +
|
|
792
|
+
* `mapTraceEvent`, server.ts). This is a DISTINCT vocabulary from `AgentEvent` (do NOT confuse with
|
|
793
|
+
* `runs.events`): the durable log is BLOCK-grained, so each frame is a "delta" the client appends. Resumable
|
|
794
|
+
* (each `id:` = the durable `task_event.seq`); on a window eviction the server returns 416 → resync via
|
|
795
|
+
* `trace.turns` then resume from `retainedFrom`.
|
|
796
|
+
*
|
|
797
|
+
* OPEN set — branch on `event`, render an unknown one generically (never crash). Known frames (mapTraceEvent):
|
|
798
|
+
* - `meta` — FIRST frame: `{ version, mode, resumeFrom }` (stream contract, NOT id-stamped).
|
|
799
|
+
* - `block-thinking-delta` — `{ seq, text }` collapsible thinking append.
|
|
800
|
+
* - `block-content-delta` — `{ seq, text }` answer text append.
|
|
801
|
+
* - `tool-call` — `{ seq, id, name, input, eventId?, parentToolCallId? }` an action started (§E2 identity additive).
|
|
802
|
+
* - `tool-result` — `{ seq, callId, isError, output?, truncated?, eventId?, parentToolCallId? }` an action closed.
|
|
803
|
+
* §E1 (SHIPPED, mapTraceEvent project.ts:248-250): `output`/`truncated` = the model-facing
|
|
804
|
+
* BODY (redacted+bounded at append; absent ⇒ no body). The old "output absent" gap is CLOSED.
|
|
805
|
+
* - `prompt-assembled` — `{ seq, ...PromptManifest }` (server ≥1.219): the prepare's assembly manifest
|
|
806
|
+
* (constitution/blocks/sections?/tools?/totalChars — mapTraceEvent passthrough,
|
|
807
|
+
* whitelisted at append). MULTIPLE per task on cascade/verify runs.
|
|
808
|
+
* - `turn` — `{ seq, tokens? }` a turn boundary (+ usage if present).
|
|
809
|
+
* - `done` — `{ seq, suspended? }` terminal (suspended:true = paused on HITL, NOT completed).
|
|
810
|
+
* - `error` — `{ code, message }` terminal failure / `WORKER_DOWN` (stalled) / `STREAM_MAX_DURATION`.
|
|
811
|
+
* - `heartbeat` — `{}` keep-alive (the SDK reader swallows these; not yielded). */
|
|
413
812
|
export interface TraceStreamEvent {
|
|
813
|
+
/** SSE event name (open set; dispatch on this). */
|
|
414
814
|
event: "meta" | "block-thinking-delta" | "block-content-delta" | "tool-call" | "tool-result" | "prompt-assembled" | "turn" | "done" | "error" | (string & {});
|
|
815
|
+
/** The durable seq (`id:` line) when the frame carries one — feed it back as Last-Event-ID to resume. `meta`
|
|
816
|
+
* and `heartbeat` carry none. */
|
|
415
817
|
id?: string;
|
|
818
|
+
/** The frame's JSON `data:` payload (shape varies by `event`; permissive — read known fields, tolerate the rest). */
|
|
416
819
|
data: Record<string, unknown>;
|
|
417
820
|
}
|
|
821
|
+
/** A workflow-run SSE event (`GET /v1/workflows/:id/stream` — S8 self-orchestration LIVE progress,
|
|
822
|
+
* `streamWorkflowRun` + core `subscribeWorkflow`, server.ts). NOT resumable (replica-local, in-process;
|
|
823
|
+
* no `id:`/Last-Event-ID — a drop is a full restart, NOT a resume). FIRST frame is `meta` `{ version, runId }`;
|
|
824
|
+
* subsequent frames carry the core `WorkflowEvent` (its `type` becomes the SSE event name). OPEN set — branch on
|
|
825
|
+
* `event`, the `data` shape is core-internal and may evolve (read known fields, tolerate the rest). */
|
|
418
826
|
export interface WorkflowStreamEvent {
|
|
827
|
+
/** SSE event name = `meta` for the opener, else the core WorkflowEvent `type` (open set). */
|
|
419
828
|
event: "meta" | "error" | (string & {});
|
|
829
|
+
/** The frame's JSON `data:` payload (core `WorkflowEvent` shape; permissive). */
|
|
420
830
|
data: Record<string, unknown>;
|
|
421
831
|
}
|
|
832
|
+
/** A per-request skill (passed as an object, not loaded from disk) — core-native TaskSpec.skills shape. */
|
|
422
833
|
export interface SkillSpec {
|
|
423
834
|
name: string;
|
|
424
835
|
description: string;
|
|
425
836
|
content: string;
|
|
426
837
|
}
|
|
838
|
+
/** A per-request MCP server (CC `.mcp.json` parity) — core-native `McpServerSpec` shape (core types.ts:277).
|
|
839
|
+
* `stdio` = a local command the worker spawns (single-user only); `http` = a remote streamable-HTTP server. */
|
|
427
840
|
export interface McpServerSpec {
|
|
841
|
+
/** Stable name; the server's tools are namespaced `<name>__<tool>`. */
|
|
428
842
|
name: string;
|
|
429
843
|
transport: {
|
|
430
844
|
kind: "stdio";
|
|
@@ -434,59 +848,123 @@ export interface McpServerSpec {
|
|
|
434
848
|
} | {
|
|
435
849
|
kind: "http";
|
|
436
850
|
url: string;
|
|
851
|
+
/** Static headers sent on every request (e.g. an auth bearer for the MCP server itself). */
|
|
437
852
|
headers?: Record<string, string>;
|
|
853
|
+
/** Header name into which the Runner-held principal is injected (model/worker can't read/set it). */
|
|
438
854
|
principalHeader?: string;
|
|
439
855
|
};
|
|
856
|
+
/** Optional allowlist of tool names to expose (others dropped). */
|
|
440
857
|
allowTools?: string[];
|
|
858
|
+
/** Opt in to INBOUND elicitation for this server (server may ask the END USER mid-tool-call). Default OFF. */
|
|
441
859
|
elicitation?: boolean;
|
|
860
|
+
/** Caller-side per-tool safety-axis overrides, keyed by the server's remote (un-namespaced) tool name. */
|
|
442
861
|
toolAxes?: Record<string, {
|
|
443
862
|
effect?: "read" | "write";
|
|
444
863
|
egress?: boolean;
|
|
445
864
|
irreversibility?: "always" | "never";
|
|
446
865
|
}>;
|
|
447
866
|
}
|
|
867
|
+
/** The user's `<user_memory>` (GET /v1/memory) — owner-scoped by construction (scope derived from the
|
|
868
|
+
* request principal; cannot address others' memory). content null = empty. the pinned wire contract. */
|
|
448
869
|
export interface MemoryRecord {
|
|
449
870
|
scope: string;
|
|
450
871
|
content: string | null;
|
|
451
872
|
}
|
|
873
|
+
/** MF-30 memory WRITE ack —— append/edit/remove **统一形** `{ ok, id, scope }`(service `@sema-agent/server@1.3.0`,
|
|
874
|
+
* 实际 handler append=2917 / patch=2926 / delete=2933 全返此形;locked 测试断言 append 含 `ok`)。
|
|
875
|
+
* 🔴 service 订正:旧源**摘要注释** server.ts:2880 误写 append 漏 `ok`,**实际代码一直含 `ok`** —— 代码为准,三 verb 统一。
|
|
876
|
+
* 🔴 **memory 是 per-PRINCIPAL,不是 per-session** —— path 的 `:id`(session)只是 shell 的**寻址上下文**(`/memory`
|
|
877
|
+
* 命令在某 session 里跑),**非 per-session 分区**;为某 principal append 的 note,该 principal **所有 session 都读得到**。
|
|
878
|
+
* note **VERBATIM 存(≤8 KiB,用户授权内容、不 redact)**;空/超长/缺字段 → 400 fail-loud。edit/remove 需 store 的
|
|
879
|
+
* id-addressable update/delete,后端缺 → **501**(honest degrade,绝非假 200);append 永远可用(memoryWrite=true 时)。 */
|
|
452
880
|
export interface MemoryWriteAck {
|
|
453
881
|
ok: boolean;
|
|
454
882
|
id: string;
|
|
455
883
|
scope: string;
|
|
456
884
|
}
|
|
885
|
+
/** Worker capability map (`GET /v1/capabilities`). Open set — ignore unknown keys. Booleans
|
|
886
|
+
* share deps with the route gates ("says yes but 501s" is structurally impossible, producer-tested). */
|
|
457
887
|
export interface Capabilities {
|
|
458
888
|
asyncRuns?: boolean;
|
|
459
889
|
artifacts?: boolean;
|
|
460
890
|
approvals?: boolean;
|
|
461
891
|
leader?: boolean;
|
|
892
|
+
/** 🔴 K-2(core SHIPPED 1.155.0;service `/v1/capabilities` 暴 `workflows: Boolean(deps.workflowRunStore)`,
|
|
893
|
+
* server.ts:930)—— worker 支持工作流编排(`/workflows` 可观测 + workflow 提交)。false/缺 ⇒ shell 隐藏 `/workflows`
|
|
894
|
+
* 面板,别 trial-by-501。注:per-principal `allowWorkflows`(center runtimeCaps,core 1.157.0)是更细的**授权**轴,
|
|
895
|
+
* 与本 worker 能力位正交。 */
|
|
462
896
|
workflows?: boolean;
|
|
897
|
+
/** 🔴 E18 rewind gate(service server.ts:911 `Boolean(resumeAnchorStore && sessionStorage.getLeafId)`)—— `TaskRequest.resumeAt`
|
|
898
|
+
* 能否 resolve。false/缺 ⇒ shell 隐藏「rewind 到某条消息」入口,别 trial-by-4xx。本/云均可(anchor store 各后端都在),
|
|
899
|
+
* 仅 env-only/无后端 worker false。 */
|
|
463
900
|
resumeAt?: boolean;
|
|
901
|
+
/** 🔴 E19 rewind-files gate(service server.ts:921 `Boolean(fileSnapshotStore)`)—— `TaskRequest.rewindFiles` 能否生效
|
|
902
|
+
* (分叉时同步回退工作树)。false/缺 ⇒ rewind 仅回退对话、文件留最新态(shell 该把「连同文件回退」选项灰掉)。 */
|
|
464
903
|
rewindFiles?: boolean;
|
|
904
|
+
/** 🔴 K-1c 手动 compact gate(service server.ts:~932 `Boolean(runStore)`,POST /v1/runs/:id/compact → core 1.156
|
|
905
|
+
* `TaskStream.compact()`)—— 手动 `/compact` 命令是否可发。配 `compacted` 事件的 `trigger:"manual"`。false/缺 ⇒ 灰掉
|
|
906
|
+
* `/compact`(非 live run 409、无 store 501)。 */
|
|
465
907
|
manualCompact?: boolean;
|
|
466
908
|
version: string;
|
|
467
909
|
scenarios?: string[];
|
|
910
|
+
/** false ⇒ stats.costMicroUsd=0 may mean "no MODEL_COST_* configured", not "free". Worker-level. */
|
|
468
911
|
pricingConfigured?: boolean;
|
|
912
|
+
/** Memory transparency endpoints available (GET/DELETE /v1/memory). the pinned wire contract. */
|
|
469
913
|
memory?: boolean;
|
|
914
|
+
/** MF-30 — memory WRITE available (`deps.memory?.append`;server.ts:828)。true ⇒ `memory.append/edit/remove` 可用,
|
|
915
|
+
* UI 显写入入口。append 永远可用(memoryWrite=true 时);edit/remove 后端缺 id-addressable 时各自 501。 */
|
|
470
916
|
memoryWrite?: boolean;
|
|
917
|
+
/** 2c session-sync (P1d) — the `/v1/sessions/:id/sync/*` peer routes resolve (durable backend + entry-export seam
|
|
918
|
+
* + a file-snapshot store all wired; server.ts:850). Gate the whole `client.sessions.sync.*` surface off this —
|
|
919
|
+
* DON'T trial-by-501. False ⇒ the routes 501 (no durable session store). */
|
|
471
920
|
sessionSync?: boolean;
|
|
921
|
+
/** 🔴 K-5 session-resume gates(service server.ts:894/836/+,§0.5 session 抽象)—— shell 的 `/resume` picker 据此诚实
|
|
922
|
+
* gate,别 trial-by-501:`sessionList` = list 可用(`Boolean(sessionStorage.listSessions ?? runStore.listSessions)`,
|
|
923
|
+
* 喂 picker 行);`sessions` = transcript preview 可用(`Boolean(sessionAudit)`,`GET /v1/sessions/:id`→SessionAudit)。
|
|
924
|
+
* `sessionFork`(E17,`sessionStorage.fork`)/`sessionDelete`(E21,`purgeSession`)是 fork/删的 producing-path gate。
|
|
925
|
+
* 各 false ⇒ 对应路由 501(「says yes ⟺ route works」)。 */
|
|
472
926
|
sessions?: boolean;
|
|
473
927
|
sessionList?: boolean;
|
|
928
|
+
/** K-5 session-search — same producing gate as `sessionList` (server.js:610 — the picker's search leg). */
|
|
474
929
|
sessionSearch?: boolean;
|
|
475
930
|
sessionFork?: boolean;
|
|
476
931
|
sessionDelete?: boolean;
|
|
932
|
+
/** /v1/usage 成本面可用(server.js:588 `Boolean(costQuota)`)。 */
|
|
477
933
|
usage?: boolean;
|
|
934
|
+
/** /v1/policy 面(server.js:587 硬编码 true)。 */
|
|
478
935
|
policy?: boolean;
|
|
936
|
+
/** 会话内改 permission mode 的写面 —— server 1.214 恒 false(server.js:589,未上线;mode 走 TaskRequest.permissionMode)。 */
|
|
479
937
|
permissionModeWrite?: boolean;
|
|
938
|
+
/** per-turn `model` 字段可用(server.js:590 硬编码 true;TaskRequest.model → CC /model parity)。 */
|
|
480
939
|
modelSelection?: boolean;
|
|
940
|
+
/** per-turn `reasoningEffort` 可用(server.js:591 硬编码 true;CC /effort parity)。 */
|
|
481
941
|
effortSelection?: boolean;
|
|
942
|
+
/** tool_end 带完整 toolOutput(server.js:592 硬编码 true)。 */
|
|
482
943
|
toolOutput?: boolean;
|
|
944
|
+
/** 事件带 message identity(eventId/messageId 族;server.js:593 硬编码 true)。 */
|
|
483
945
|
messageIdentity?: boolean;
|
|
946
|
+
/** 子代理内容事件前向转发(parentToolCallId stamped;server.js:594 硬编码 true)。 */
|
|
484
947
|
forwardSubagentEvents?: boolean;
|
|
948
|
+
/** C2 子代理 steer 面(server.js:595 `Boolean(subagentSteerRegistry && runStore)`;POST /v1/runs/:id/subagents/:t/steer)。 */
|
|
485
949
|
subagentSteer?: boolean;
|
|
950
|
+
/** 子代理 resume/复活面(server.js:596 同 subagentSteer 双 dep;POST …/subagents/:t/resume,还需 run 侧 retainSubagentSessions)。 */
|
|
486
951
|
subagentResume?: boolean;
|
|
952
|
+
/** server 1.244 [1488]③(b):后台子代(a… 句柄,background_agent ONLY;wa… 观测行走 workflow journal)终报读面
|
|
953
|
+
* —— GET /v1/runs/:id/subagents/:handle/output(引擎 TaskRegistry 的 TaskOutput 工具投影过 HTTP;
|
|
954
|
+
* bg 子代永不在 run store)。副本本地,同 steer。 */
|
|
487
955
|
subagentOutput?: boolean;
|
|
956
|
+
/** server 1.251(S2,core 1.370 bgAgentId):per-agent live tail —— GET /v1/runs/:id/subagents/:handle/stream
|
|
957
|
+
* (SSE:meta/forward/heartbeat;replay+tail 的 tail 半场,replay=subagentOutput 面)。live 帧
|
|
958
|
+
* replica-local(帧只在宿主 run 所在副本产生;meta 帧如实声明)。同门同寻址同 404 形,session-enforced。 */
|
|
488
959
|
subagentStream?: boolean;
|
|
960
|
+
/** server 1.246 [1499]:泛后台任务句柄双 verb(CC TaskOutput/TaskStop 人侧对位)——
|
|
961
|
+
* GET/POST /v1/runs/:id/tasks/:handle/{output,stop}:background_bash(stdout;是否消费游标取决于句柄形态,
|
|
962
|
+
* spooled 全量可重读/cursor-only 增量,投影 flags 权威)/monitor(批)/background_agent(终报);workflow
|
|
963
|
+
* 句柄 404(读走 journal 面;wire 上无 workflow 停止面)。出生即 session-enforced(session-bound run 必带
|
|
964
|
+
* 匹配 ?session=)。副本本地,同 subagentOutput。 */
|
|
489
965
|
taskHandles?: boolean;
|
|
966
|
+
/** TaskRequest.settings 各分片是否 honored(server.js:597 —— 唯一对象形能力位;`env` 恒 false,
|
|
967
|
+
* `hooks` 单用户部署(requirePrincipal!==true)才 true)。 */
|
|
490
968
|
taskSettings?: {
|
|
491
969
|
permissions?: boolean;
|
|
492
970
|
permissionMode?: boolean;
|
|
@@ -496,31 +974,69 @@ export interface Capabilities {
|
|
|
496
974
|
hooks?: boolean;
|
|
497
975
|
[k: string]: unknown;
|
|
498
976
|
};
|
|
977
|
+
/** server ≥1.243 ([1478] R2): TaskRequest.appendSystemPrompt accepted top-level → core TaskSpec.appendSystemPrompt.
|
|
978
|
+
* false/absent ⇒ fall back to the `settings.outputStyle` ride-along (older servers fold it into the same field). */
|
|
499
979
|
appendSystemPrompt?: boolean;
|
|
980
|
+
/** server ≥1.243 ([1479]①): TaskRequest.compactionModel accepted (catalog-gated cheap compaction gear).
|
|
981
|
+
* false/absent ⇒ older server drops the field — don't offer the picker. */
|
|
500
982
|
compactionModel?: boolean;
|
|
983
|
+
/** [876]③ TaskRequest.agents per-task 子代理定义 honored(server.js:598 `requirePrincipal !== true` —— 单用户部署才收)。 */
|
|
501
984
|
taskAgents?: boolean;
|
|
985
|
+
/** TaskRequest.retainBackgroundProcesses honored(server.js:599 单用户部署才收)。 */
|
|
502
986
|
retainBackgroundProcesses?: boolean;
|
|
987
|
+
/** server ≥1.221 (core 1.314 工具面控制批,[1052]②): roster TRUE-UNMOUNT list — the named wire tools'
|
|
988
|
+
* schemas never reach the model (the deny gate saves no tokens; this does), and the assembly manifest
|
|
989
|
+
* narrows honestly. Tighten-only: core's inheritance invariant unions it into EVERY child spawn path.
|
|
990
|
+
* Malformed (non-array / empty-string items) → 400 fail-loud at submit. */
|
|
503
991
|
excludeTools?: string[];
|
|
992
|
+
/** server ≥1.221 (core 1.314): DEFERRED DISCLOSURE list — the named MOUNTED tools (built-ins included)
|
|
993
|
+
* ride the wire as a placeholder (schema bytes out of the cache prefix) and materialize via ToolSearch
|
|
994
|
+
* on demand. The carrier for the shell's "Workflow on by default but not exposed" posture. Same
|
|
995
|
+
* validation/inheritance posture as {@link excludeTools}. */
|
|
504
996
|
deferTools?: string[];
|
|
997
|
+
/** TaskRequest.interactiveTools 认词(server.js:600 硬编码 true;-p 无人值守语义探测位 —— 见 TaskRequest 注)。 */
|
|
505
998
|
interactiveTools?: boolean;
|
|
999
|
+
/** TaskRequest.cwd honored(server.js:601 `cwdHonored`:local 单用户 host-adapter 才 true;多租户 fail-closed)。 */
|
|
506
1000
|
projectContext?: boolean;
|
|
1001
|
+
/** TaskRequest.mcpServers honored(server.js:602 `mcpInjectionHonored`:单用户才 true,多租户 ignore)。 */
|
|
507
1002
|
mcpInjection?: boolean;
|
|
1003
|
+
/** GET /v1/runs/:id/model-usage 面(server.js:603 `Boolean(runStore && modelUsage)`)。 */
|
|
508
1004
|
modelUsage?: boolean;
|
|
1005
|
+
/** session_init 首帧(CC parity;server.js:604 硬编码 true)。 */
|
|
509
1006
|
sessionInit?: boolean;
|
|
1007
|
+
/** MCP 面总位(/v1/mcp status 等;server.js:605 硬编码 true)。 */
|
|
510
1008
|
mcp?: boolean;
|
|
1009
|
+
/** §E23 inbound-MCP elicitation HITL(server.js:606 `Boolean(elicitation)` = MCP_ELICITATION_ENABLED)。 */
|
|
511
1010
|
mcpElicitation?: boolean;
|
|
1011
|
+
/** §4④ live AskUserQuestion HITL(server.js:607 `Boolean(question)` = ASK_QUESTION_ENABLED)。 */
|
|
512
1012
|
askUserQuestion?: boolean;
|
|
1013
|
+
/** [830]① live tool-approval HITL(server.js:608 `Boolean(toolApproval)` = TOOL_APPROVAL_ENABLED;
|
|
1014
|
+
* gate `client.toolApprovals` 整面,别 trial-by-501)。 */
|
|
513
1015
|
toolApproval?: boolean;
|
|
1016
|
+
/** E12 suggestNextPrompts 认词(server.js:614 硬编码 true)。 */
|
|
514
1017
|
promptSuggestions?: boolean;
|
|
1018
|
+
/** PUT /v1/sessions/:id/policy 面(server.js:615 `Boolean(sessionPolicyStore)`)。 */
|
|
515
1019
|
sessionPolicy?: boolean;
|
|
1020
|
+
/** E18 code-only rewind(TaskRequest.rewindFilesTo;server.js:617 `Boolean(fileSnapshotStore && resumeAnchorStore && getLeafId)`)。 */
|
|
516
1021
|
rewindFilesTo?: boolean;
|
|
1022
|
+
/** assistant-scheduler 面(server.js:618 `schedulerEnabled && requirePrincipal!==true && remoteExec==="host"` 三与)。 */
|
|
517
1023
|
scheduler?: boolean;
|
|
1024
|
+
/** SendUserFile 工具面(server.js:620 `Boolean(sendUserFile && publicEndpoint)`)。 */
|
|
518
1025
|
sendUserFile?: boolean;
|
|
1026
|
+
/** SendUserFile 的 S3 公网端点(server.js:621 —— 唯一 string|null 位;null = 未配)。 */
|
|
519
1027
|
s3PublicEndpoint?: string | null;
|
|
1028
|
+
/** GET /v1/files/sent 台账面(server.js:622 `Boolean(sendFileLedger)`)。 */
|
|
520
1029
|
sendUserFileLedger?: boolean;
|
|
1030
|
+
/** GET /v1/workflows 列表面(server.js:624 `Boolean(workflowRunStore)`;`workflows` 总位见上)。 */
|
|
521
1031
|
workflowsList?: boolean;
|
|
522
1032
|
[k: string]: unknown;
|
|
523
1033
|
}
|
|
1034
|
+
/** One scenario's detail card (`GET /v1/capabilities/scenarios/:name` — server 1.214 server.js:567-576 handler,
|
|
1035
|
+
* shape = capabilities/scenarios.d.ts `ScenarioDetail` verbatim; the LIST of names rides `capabilities.scenarios`).
|
|
1036
|
+
* `source`/`builtin` = builtin vs center-config overlay; `toolset` names the tool bundle, `tools` the resolved
|
|
1037
|
+
* tool names; `promptSummary` is a human-readable prompt digest (NOT the full prompt); `enabled` = a center
|
|
1038
|
+
* scenario can be declared-but-disabled. UNKNOWN name → 404 `{error:{code:"scenario_not_found"}}` (note the
|
|
1039
|
+
* OBJECT-shaped error body — unique to this route). */
|
|
524
1040
|
export interface ScenarioDetail {
|
|
525
1041
|
name: string;
|
|
526
1042
|
source: "builtin" | "center";
|
|
@@ -532,17 +1048,49 @@ export interface ScenarioDetail {
|
|
|
532
1048
|
enabled: boolean;
|
|
533
1049
|
[k: string]: unknown;
|
|
534
1050
|
}
|
|
1051
|
+
/** A pending HITL checkpoint — the RICH `/v1/approvals` operator-queue row (true shape;
|
|
1052
|
+
* ASSISTANT-WIRE-CONTRACT §7(b), service main 1fafeec / core 1.110.0). ⚠️ createdAt/deadline are EPOCH MS.
|
|
1053
|
+
*
|
|
1054
|
+
* 🔴 §7 钉死两形状不可混 —— 本类型是 **(b) 富 /v1/approvals 行**(`GET /v1/approvals` + `/stream` 用,
|
|
1055
|
+
* decide-ready operator queue),**不是** (a) inbox/tasks 的标量 `CheckpointSummary`(见下文 CheckpointSummary)。
|
|
1056
|
+
* 与标量形状的精确差(§7b/§4a):
|
|
1057
|
+
* - severity 嵌在 **`riskDescriptor.severity`** 内 —— 富行**无顶层 severity 标量**;
|
|
1058
|
+
* - 富行**无 `gateKind`**(消费方要类别时回退 `toolName`/`riskDescriptor.toolName`);
|
|
1059
|
+
* - 富行**无 `token`**(§1:resume capability token 是永不上线的 secret,server 自按 sessionId 解析);
|
|
1060
|
+
* - **无 `checkpointToken`**(§4a:server-INTERNAL,NOT surfaced 在 /v1/approvals 记录上;合规 client 只回传
|
|
1061
|
+
* boundCallId+boundInputHash 两件套,可选 checkpointToken→409 approval_stale 是 deprecated legacy 路径)。
|
|
1062
|
+
* 这是 boundCallId/boundInputHash decide 绑定的唯一 surface 处。契约说"可选字段缺则 OMIT 不是 null"。 */
|
|
535
1063
|
export interface PendingCheckpoint {
|
|
1064
|
+
/** The decide handle: POST /v1/approvals/:sessionId/decide. */
|
|
536
1065
|
sessionId: string;
|
|
1066
|
+
/** Principal / 多租户 owner scope; "_" = submitted without one. */
|
|
537
1067
|
scope: string;
|
|
1068
|
+
/** The suspended run holding the session claim — the JOIN KEY to the task's trace
|
|
1069
|
+
* tool-call block (block.id == toolCallId → input = full args/question payload) and the context link. */
|
|
538
1070
|
taskId?: string | null;
|
|
1071
|
+
/** Tool awaiting approval (AskUserQuestion = the question gate)。富行无 gateKind → 类别从 toolName 推。 */
|
|
539
1072
|
toolName?: string | null;
|
|
540
1073
|
toolCallId?: string | null;
|
|
1074
|
+
/** design/80 D-1 — the TWO binding values the human implicitly approves; the consumer reads them here and
|
|
1075
|
+
* echoes them VERBATIM into `decide` (TOCTOU guard: "I'm approving THIS pending action, not one swapped in").
|
|
1076
|
+
* Absent on checkpoints minted before D-1 → omit from decide (server falls back to the legacy resolve).
|
|
1077
|
+
* = `toolCallId` of the action the human saw (the bound call). */
|
|
541
1078
|
boundCallId?: string;
|
|
1079
|
+
/** SERVER-MINTED OPAQUE sha256 over the pending action's args at mint time. Echo VERBATIM; NEVER recompute
|
|
1080
|
+
* (no canonical-JSON on the client — a false mismatch would fail-close a legitimate approval). It binds the
|
|
1081
|
+
* input the human SAW, NOT any `updatedInput` (which is applied AFTER binding, design/37 last-wins). */
|
|
542
1082
|
boundInputHash?: string;
|
|
1083
|
+
/** The pending tool call's args (post-hook), REDACTED + size-bounded by the producer:
|
|
1084
|
+
* for a tool gate the write payload, for an AskUserQuestion the question itself. Lets an approval card
|
|
1085
|
+
* render WITHOUT an N+1 `trace.turns` fetch per item. Oversized → `{ truncated, bytes }`. NEVER a
|
|
1086
|
+
* capability token. `null`/absent = checkpoint suspended before this field existed → fall back to the
|
|
1087
|
+
* trace join (block.id == toolCallId). */
|
|
543
1088
|
input?: unknown;
|
|
544
1089
|
createdAt: number;
|
|
1090
|
+
/** epoch ms; expired checkpoints are reaped. */
|
|
545
1091
|
deadline?: number | null;
|
|
1092
|
+
/** §7(b) — 富行的**完整 RiskDescriptor 对象**;**severity 在此处**(无顶层 severity 标量)。
|
|
1093
|
+
* axes/toolName/summary/touchedPaths 是引擎内部投影出的风险画像。缺则 OMIT(早期 checkpoint 可能无)。 */
|
|
546
1094
|
riskDescriptor?: {
|
|
547
1095
|
severity?: 1 | 2 | 3 | 4 | 5;
|
|
548
1096
|
axes?: Record<string, unknown>;
|
|
@@ -552,10 +1100,17 @@ export interface PendingCheckpoint {
|
|
|
552
1100
|
};
|
|
553
1101
|
[k: string]: unknown;
|
|
554
1102
|
}
|
|
1103
|
+
/** Session audit (`GET /v1/sessions/:id`) — true shape. `messages` = CURRENT model context
|
|
1104
|
+
* (older history folded into a summary message); can be LARGE — lazy-expand in UIs.
|
|
1105
|
+
* With window params (server ≥1.162 four-face, board [611]) the response additionally carries
|
|
1106
|
+
* `window` — ABSENT on an old engine (<1.162 strips the query before routing and returns the
|
|
1107
|
+
* full record): probe "no `window` in the response" to degrade honestly, never error. */
|
|
555
1108
|
export interface SessionRecord {
|
|
556
1109
|
sessionId: string;
|
|
557
1110
|
owner?: string | null;
|
|
1111
|
+
/** ISO timestamp (unlike approvals' epoch-ms). */
|
|
558
1112
|
createdAt: string;
|
|
1113
|
+
/** Compaction window floor; null = never compacted. */
|
|
559
1114
|
floorEntryId?: string | null;
|
|
560
1115
|
thinkingLevel?: string;
|
|
561
1116
|
model?: {
|
|
@@ -563,15 +1118,24 @@ export interface SessionRecord {
|
|
|
563
1118
|
modelId: string;
|
|
564
1119
|
} | null;
|
|
565
1120
|
messages: unknown[];
|
|
1121
|
+
/** Present ONLY on a windowed read (`tail`/`before`) against server ≥1.162. */
|
|
566
1122
|
window?: SessionWindow;
|
|
1123
|
+
/** server ≥1.220 ([1023]①): the session's prompt-epoch pin (additive; absent = pre-epoch session
|
|
1124
|
+
* OR an older engine — never null). The typed entry is NOT an LLM message, so it never appears
|
|
1125
|
+
* in `messages`. */
|
|
567
1126
|
promptEpoch?: PromptEpoch;
|
|
568
1127
|
[k: string]: unknown;
|
|
569
1128
|
}
|
|
1129
|
+
/** The `window` companion of a windowed session read: `messages` is the slice
|
|
1130
|
+
* `[offset, offset+messages.length)` of `total`. `offset` is stable within one `floorEntryId`
|
|
1131
|
+
* generation — compaction swaps the generation (floorEntryId changes) ⇒ re-pull from scratch. */
|
|
570
1132
|
export interface SessionWindow {
|
|
571
1133
|
offset: number;
|
|
572
1134
|
total: number;
|
|
573
1135
|
[k: string]: unknown;
|
|
574
1136
|
}
|
|
1137
|
+
/** `GET /v1/sessions/:id?message=<index>` — the single-message expand leg (server ≥1.162).
|
|
1138
|
+
* Out-of-range index → 404 (typed NotFoundError; wire body carries `total`). */
|
|
575
1139
|
export interface SessionMessageEnvelope {
|
|
576
1140
|
sessionId: string;
|
|
577
1141
|
floorEntryId?: string | null;
|
|
@@ -579,31 +1143,63 @@ export interface SessionMessageEnvelope {
|
|
|
579
1143
|
message: unknown;
|
|
580
1144
|
[k: string]: unknown;
|
|
581
1145
|
}
|
|
1146
|
+
/** E16(shell-host sessionPicker;service `SessionSummary` plugins/tidb-run-store.ts:42,SHIPPED `6cbf61e`)—
|
|
1147
|
+
* `GET /v1/sessions` 列表行 = keyset 聚合一个 session 的 run 账本(**不是** TaskSummary 的单 run 行)。owner-scoped
|
|
1148
|
+
* (service 据 principal 自算;non-owner 不出现)。门B/CLI 的「会话/对话历史」picker 据此渲染(last activity + 最近
|
|
1149
|
+
* objective 预览 + 最近状态)。`objectivePreview` 已 service 侧脱敏 + 截断,真回 `null`(无 run 时)故保 `| null`。
|
|
1150
|
+
* 所有时间 ISO 串。permissive 开集容未来字段。 */
|
|
582
1151
|
export interface SessionSummary {
|
|
583
1152
|
sessionId: string;
|
|
1153
|
+
/** 租户/owner(ownerless session = null)。 */
|
|
584
1154
|
owner: string | null;
|
|
1155
|
+
/** 最近一个 run 的创建时间(keyset 排序键)。 */
|
|
585
1156
|
lastActivityAt: string;
|
|
1157
|
+
/** 该 session 第一个 run 的创建时间。 */
|
|
586
1158
|
firstActivityAt: string;
|
|
1159
|
+
/** 该 session 下的 run 数。 */
|
|
587
1160
|
runCount: number;
|
|
1161
|
+
/** 最近 run 的 objective 预览(service 脱敏 + 截断;无 run → null)。 */
|
|
588
1162
|
objectivePreview: string | null;
|
|
1163
|
+
/** 最近 run 的状态("completed"/"running"/... 开放串)。 */
|
|
589
1164
|
lastStatus: string;
|
|
1165
|
+
/** 🔴 K-5c(service SHIPPED 全后端:security.ts:19 + tidb/pg/file/memory/local-session-store)—— 最近 run 的 taskId,
|
|
1166
|
+
* = **一跳 live-tail re-attach 锚**:picker 选中会话 → 直接 `GET /v1/runs/:lastRunId/events?from=seq` 续 live 尾,
|
|
1167
|
+
* 免二次查。无 run → null(空会话)。running/suspended run 也会冒出来(noteTaskRun seam),故选中即可续在跑的尾。 */
|
|
590
1168
|
lastRunId: string | null;
|
|
591
1169
|
[k: string]: unknown;
|
|
592
1170
|
}
|
|
1171
|
+
/** `GET /v1/sessions` 的分页信封(service handleSessionList,keyset)。`nextCursor` 缺 = 末页。 */
|
|
593
1172
|
export interface SessionListPage {
|
|
594
1173
|
sessions: SessionSummary[];
|
|
1174
|
+
/** 不透明 keyset 游标;原样回送 `?cursor=` 取下一页(绝不 parse)。缺 = 没有更多。 */
|
|
595
1175
|
nextCursor?: string;
|
|
596
1176
|
}
|
|
1177
|
+
/** E6(shell-host permissionMode;core `SessionPermissionRules` session-policy-store.ts:23,service `GET/PUT
|
|
1178
|
+
* /v1/sessions/:id/policy`,SHIPPED)—— operator 收紧的 per-session 工具权限规则(core 在 prepare-time SUBTRACT-only
|
|
1179
|
+
* 读它)。5 个开放可选 string[] 字段;读写均经 {@link StoredSessionRules}(带 `rev` OCC 键)。🔴 **tighten-only 不变式**
|
|
1180
|
+
* core 强制:普通(非 operator)写只能收紧(删 deny / 不能放宽 allowlist/allowDirs)→ 放宽 403 `loosen_forbidden`;
|
|
1181
|
+
* CAS `expectedRev` 不符 → 409 `conflict`;ownerless session → 409;non-owner → 404(无 existence oracle)。 */
|
|
597
1182
|
export interface SessionPermissionRules {
|
|
1183
|
+
/** 设了 = 仅这些工具名放行(白名单收紧)。 */
|
|
598
1184
|
toolAllow?: string[];
|
|
1185
|
+
/** 总禁的工具名(deny wins)。 */
|
|
599
1186
|
toolDeny?: string[];
|
|
1187
|
+
/** 设了 = 写工具(Q6/core 1.161 起 CC 名 `Write`/`Edit`)仅可写这些目录内;不能路径约束的写工具(如 `Bash`)在它设了时被禁。RAW 存,run 时解析。 */
|
|
600
1188
|
allowDirs?: string[];
|
|
1189
|
+
/** 设了 = 仅这些 bash 命令名(argv[0])放行。 */
|
|
601
1190
|
commandAllow?: string[];
|
|
1191
|
+
/** 总禁的 bash 命令名(argv[0])。 */
|
|
602
1192
|
commandDeny?: string[];
|
|
603
1193
|
}
|
|
1194
|
+
/** {@link SessionPermissionRules} + store 盖的单调 `rev`(OCC 键)。GET/PUT 的 `{rules}` 信封里就是这个。
|
|
1195
|
+
* PUT 回送 `rev` 作下次 `expectedRev`(CAS)。 */
|
|
604
1196
|
export interface StoredSessionRules extends SessionPermissionRules {
|
|
605
1197
|
rev: number;
|
|
606
1198
|
}
|
|
1199
|
+
/** E9(shell-host mcpStatus;core `McpServerStatus` core/mcp.ts:76,service `GET /v1/sessions/:id/mcp`,SHIPPED
|
|
1200
|
+
* core 1.124)—— 单 MCP server 的状态。🔴 core 不持久化 MCP 连接(task-scoped)→ 无「存的 session MCP 健康」;service
|
|
1201
|
+
* **按需 materialize**(fresh connect→list→dispose,fail-open)→ 这是 **materialization-time** 状态,非 live session
|
|
1202
|
+
* 健康(壳渲「as of <asOf>」)。`status` 仅 connected/failed(core 不发 disabled)。`error` service 已脱敏 + 限 200 字符。 */
|
|
607
1203
|
export interface McpServerStatus {
|
|
608
1204
|
name: string;
|
|
609
1205
|
status: "connected" | "failed" | (string & {});
|
|
@@ -612,50 +1208,87 @@ export interface McpServerStatus {
|
|
|
612
1208
|
version: string;
|
|
613
1209
|
};
|
|
614
1210
|
toolNames?: string[];
|
|
1211
|
+
/** 仅 failed 时;service redact + slice(200)。 */
|
|
615
1212
|
error?: string;
|
|
616
1213
|
[k: string]: unknown;
|
|
617
1214
|
}
|
|
1215
|
+
/** `GET /v1/sessions/:id/mcp` 的信封(service server.ts:2640-2672)。`asOf` = THIS materialize 时刻(ISO);
|
|
1216
|
+
* `degraded:true` = materialize 超时/失败 → `servers` 空但非「无 MCP」(壳显「状态暂不可得」)。无 MCP 配置 → `servers:[]`。 */
|
|
618
1217
|
export interface McpStatusPanel {
|
|
619
1218
|
asOf: string;
|
|
620
1219
|
servers: McpServerStatus[];
|
|
1220
|
+
/** materialize 超时/失败的降级标记(servers 空且 degraded 时 = 取不到,非「没有」)。 */
|
|
621
1221
|
degraded?: boolean;
|
|
622
1222
|
[k: string]: unknown;
|
|
623
1223
|
}
|
|
1224
|
+
/** ONE session-tree entry as it crosses the sync wire — the SDK treats it as an OPAQUE payload (verbatim,
|
|
1225
|
+
* cross-backend stable ids/parents). It is core's `SessionTreeEntry`; the SDK only ever reads `.id` (for the
|
|
1226
|
+
* §7 id-set classify) and otherwise pipes it through untouched (the cloud re-validates the whole tree). */
|
|
624
1227
|
export interface SyncEntry {
|
|
1228
|
+
/** Stable entry id, unique within a session (verbatim across backends — the §7 divergence key). */
|
|
625
1229
|
id: string;
|
|
1230
|
+
/** Parent entry id, or null for a root. */
|
|
626
1231
|
parentId?: string | null;
|
|
1232
|
+
/** Entry discriminator (message / leaf / compaction / …) — opaque to the SDK. */
|
|
627
1233
|
type?: string;
|
|
628
1234
|
[k: string]: unknown;
|
|
629
1235
|
}
|
|
1236
|
+
/** A (principal, rules) record — one row of a session's policy across ALL principals (E6 `listBySession`).
|
|
1237
|
+
* Replayed verbatim on import (the cloud applies the E6 tighten-only gate). `principal` absent = the
|
|
1238
|
+
* session-default rules. */
|
|
630
1239
|
export interface SessionRulesRecord {
|
|
631
1240
|
principal?: string;
|
|
632
1241
|
rules: StoredSessionRules;
|
|
633
1242
|
}
|
|
1243
|
+
/** One E19 file snapshot keyed by a `SessionTreeEntry.id` — `manifest` = `[relPath, blobHash]` tuples. The blob
|
|
1244
|
+
* BYTES are NOT inlined (a turn's working tree can be tens of MiB → OOM/413); they ride the content-addressed
|
|
1245
|
+
* blob routes (GET …/snapshots/:key/blobs/:hash to pull, PUT …/blobs/:hash to push). */
|
|
634
1246
|
export interface SyncSnapshot {
|
|
635
1247
|
key: string;
|
|
636
1248
|
manifest: Array<[string, string]>;
|
|
637
1249
|
}
|
|
1250
|
+
/** One E18 resume-at anchor (eventId→entryId + its source owner). `owner` is RE-KEYED to the importing principal
|
|
1251
|
+
* on a PUSH (§9) — the local peer sends what it has; the cloud overwrites it. */
|
|
638
1252
|
export interface SyncAnchor {
|
|
639
1253
|
eventId: string;
|
|
640
1254
|
entryId: string;
|
|
641
1255
|
owner: string | null;
|
|
642
1256
|
}
|
|
1257
|
+
/** `GET …/sync/manifest` → `{ manifest: SessionManifest }`. The THIN cross-backend snapshot: entry IDS (oldest-first,
|
|
1258
|
+
* NOT payloads — those stream via `/sync/entries`) + per-snapshot relPath→blobHash + policy + anchors + leaf. The
|
|
1259
|
+
* local peer feeds `entryIds` to {@link classifySyncRelationshipByIds} to decide fast-forward/fork BEFORE pulling
|
|
1260
|
+
* the entry stream + only the blob hashes it lacks. Mirrors session-sync.ts SessionManifest:213. */
|
|
643
1261
|
export interface SessionManifest {
|
|
644
1262
|
sessionId: string;
|
|
1263
|
+
/** The full durable log's entry IDS, oldest-first (verbatim, cross-backend stable). NOT the payloads. */
|
|
645
1264
|
entryIds: string[];
|
|
1265
|
+
/** `entryIds.length` — the count the paired `/sync/entries` NDJSON trailer must report. */
|
|
646
1266
|
entryCount: number;
|
|
1267
|
+
/** The session's current leaf entry id, or null. */
|
|
647
1268
|
leafId: string | null;
|
|
648
1269
|
snapshots: SyncSnapshot[];
|
|
649
1270
|
policy: SessionRulesRecord[];
|
|
650
1271
|
anchors: SyncAnchor[];
|
|
651
1272
|
}
|
|
1273
|
+
/** The portable state of ONE session, ready to replay into another backend (mirrors session-sync.ts SessionBundle:193).
|
|
1274
|
+
* Blobs are deliberately NOT inlined — each snapshot carries only its `manifest`; the bytes stream through the
|
|
1275
|
+
* content-addressed blob routes. The SDK assembles this from a manifest + the streamed entries for a PUSH. */
|
|
652
1276
|
export interface SessionBundle {
|
|
653
1277
|
sessionId: string;
|
|
1278
|
+
/** The FULL durable conversation log, verbatim ids/parents/payload (oldest-first). */
|
|
654
1279
|
entries: SyncEntry[];
|
|
655
1280
|
snapshots: SyncSnapshot[];
|
|
656
1281
|
policy: SessionRulesRecord[];
|
|
657
1282
|
anchors: SyncAnchor[];
|
|
658
1283
|
}
|
|
1284
|
+
/** §7 — how a SOURCE log relates to a DESTINATION log, decided over the entry-ID SETS (mirrors session-sync.ts
|
|
1285
|
+
* SyncRelation:95). A discriminated union the local peer reads to decide what a PUSH/PULL would do:
|
|
1286
|
+
* - `fresh` — dst has no such session → an unconditional fresh import.
|
|
1287
|
+
* - `identical` — the id sets are equal → a no-op.
|
|
1288
|
+
* - `fast_forward` — dst ⊊ src (src strictly ahead = clean append) → SAFE to apply; `newEntryIds` = the tail.
|
|
1289
|
+
* - `stale` — src ⊊ dst (src strictly behind) → applying LOSES dst entries → a conflict (`dstAheadBy`).
|
|
1290
|
+
* - `fork` — each side has ≥1 exclusive entry (true divergence) → a conflict; `commonAncestor` = the
|
|
1291
|
+
* deepest shared id (null if none), `srcExclusive`/`dstExclusive` = each side's extra ids. */
|
|
659
1292
|
export type SyncRelation = {
|
|
660
1293
|
relation: "fresh";
|
|
661
1294
|
} | {
|
|
@@ -672,21 +1305,40 @@ export type SyncRelation = {
|
|
|
672
1305
|
srcExclusive: string[];
|
|
673
1306
|
dstExclusive: string[];
|
|
674
1307
|
};
|
|
1308
|
+
/** The two conflicting relations (`fork`/`stale`) the cloud refuses on a PUSH without `{resolution:"overwrite-dst"}`
|
|
1309
|
+
* — the payload of the 409 typed {@link import("./errors.js").SyncConflictError}. */
|
|
675
1310
|
export type SyncConflictRelation = Extract<SyncRelation, {
|
|
676
1311
|
relation: "fork" | "stale";
|
|
677
1312
|
}>;
|
|
1313
|
+
/** `POST …/sync/import` Phase-A result. A `fork`/`stale` without `overwrite-dst` → 409 (typed SyncConflictError),
|
|
1314
|
+
* never this. `identical` → `{ relation:"identical" }` with NO `stagingId` (the dst already holds the log; Phase B
|
|
1315
|
+
* is skipped). Anything that needs entries → `{ stagingId, relation }` (drive Phase B with the `stagingId`).
|
|
1316
|
+
* `relation` is the BARE classifier tag (server sends `relA.relation`, not the full object — server.ts:3037/2986). */
|
|
678
1317
|
export interface ImportStaged {
|
|
1318
|
+
/** Present iff Phase B is needed (absent on `identical`). Feed it to `importEntries(...)`. */
|
|
679
1319
|
stagingId?: string;
|
|
1320
|
+
/** The §7 relation tag classified at Phase A (`fresh` | `fast_forward` | `identical`). */
|
|
680
1321
|
relation: SyncRelation["relation"];
|
|
681
1322
|
}
|
|
1323
|
+
/** `POST …/sync/import/:stagingId/entries` (Phase B) commit result — `{ relation }` (the AUTHORITATIVE in-txn
|
|
1324
|
+
* re-classify tag; server.ts:3138). */
|
|
682
1325
|
export interface ImportCommitted {
|
|
683
1326
|
relation: SyncRelation["relation"];
|
|
684
1327
|
}
|
|
1328
|
+
/** Synchronous ack for `POST /v1/runs/:id/cancel` (LIVE, service ced3d88). `status` is
|
|
1329
|
+
* "cancelling" (accepted) or a terminal status (idempotent no-op). NOT a RunStatus member. The run then
|
|
1330
|
+
* settles to `failed` + `errorCode:"cancelled"`. */
|
|
685
1331
|
export interface CancelAck {
|
|
686
1332
|
taskId: string;
|
|
687
1333
|
status: string;
|
|
688
1334
|
note?: string;
|
|
689
1335
|
}
|
|
1336
|
+
/** Leader run (`POST /v1/leader`) — the **v2 leader pipeline** (E2B workers + git push), gated server-side
|
|
1337
|
+
* (`LEADER_ENABLED` + `REMOTE_EXEC=e2b`, both default OFF). Mode is a SERVER deploy flag, NOT a client choice:
|
|
1338
|
+
* `LEADER_FANOUT_ENABLED=true` (default) = router decides single-vs-decompose and CAN fan out to N workers
|
|
1339
|
+
* (= the value-HOLD correctness path); `=false` pins it to a deterministic single worker. ⚠️ This is NOT the
|
|
1340
|
+
* default door-B brain — **door B uses `/v1/tasks`+`/v1/runs`+`scenario`** (strong single, live today, no
|
|
1341
|
+
* E2B-leader machinery). Keep this resource as a clearly-labeled v2/optional path. See DIRECTION §1. */
|
|
690
1342
|
export interface LeaderReceipt {
|
|
691
1343
|
leaderRunId: string;
|
|
692
1344
|
status: "running" | "completed" | "failed";
|
|
@@ -697,52 +1349,108 @@ export interface LeaderRecord {
|
|
|
697
1349
|
result?: unknown;
|
|
698
1350
|
error?: string;
|
|
699
1351
|
}
|
|
1352
|
+
/** §1 CheckpointSummary —— core 对每个 PENDING checkpoint 的轻量投影(summarizeCheckpoint, 全 store 后端一致)。
|
|
1353
|
+
* inbox/总览 的共享行形状。可选字段缺则 OMIT 不是 null。🔴 只投影 severity 标量, **不带 riskDescriptor 对象**。 */
|
|
700
1354
|
export interface CheckpointSummary {
|
|
1355
|
+
/** resume capability token(opaque; echo, 绝不 parse)。 */
|
|
701
1356
|
token: string;
|
|
1357
|
+
/** 被暂停的 task/session id。 */
|
|
702
1358
|
sessionId: string;
|
|
1359
|
+
/** 多租户 owner scope。 */
|
|
703
1360
|
scope: string;
|
|
1361
|
+
/** 哪种暂停(6-arm 开集)。开放联合留 `(string & {})` 容未来新 arm。 */
|
|
704
1362
|
gateKind: "human" | "irreversible_ask" | "resource_limit" | "needs_review" | "plan_review" | "task_done" | (string & {});
|
|
1363
|
+
/** MF-14 contentKind passthrough(@sema-agent/server 1.6.0 / core 1.150 checkpoint-store.d.ts:765)—— `needs_review`/
|
|
1364
|
+
* `suspended` gate 上 core 透传的内容类型;`"content_ask"` = 被 gate 的工具是 AskUserQuestion(让 shell 渲染问答式 UI
|
|
1365
|
+
* 而非普通审批)。开放联合容未来新 kind。缺省 = 普通 gate。 */
|
|
705
1366
|
contentKind?: "content_ask" | (string & {});
|
|
1367
|
+
/** 确定性风险层 = inbox 排序键。**仅 human/irreversible_ask 有**; 其余无 → 排序须容 undefined。 */
|
|
706
1368
|
severity?: 1 | 2 | 3 | 4 | 5;
|
|
1369
|
+
/** suspend 链上累计花费(资源账本附着时出现)。 */
|
|
707
1370
|
spentMicroUsd?: number;
|
|
1371
|
+
/** awaiting-human SLA deadline(epoch ms)。 */
|
|
708
1372
|
deadline?: number;
|
|
1373
|
+
/** §assistant-scheduler 归因(core 1.114.0 source-tag 持久化 + summarizeCheckpoint 投影自动带;the pinned wire contract)。
|
|
1374
|
+
* echo-only triage 显示 —— **core 门控不读、跨副本持久化带着、跨后端 byte-identical**。单收件箱跨任务聚合时,
|
|
1375
|
+
* 消费方据此显「这条 ask 属哪个任务/用户」。缺则 OMIT(旧 worker / 未持久化场景)。 */
|
|
1376
|
+
/** 发起此 ask 的任务身份(= 发起 ask 的 worker session id;delegated worker-unforgeable)。 */
|
|
709
1377
|
sourceTaskId?: string;
|
|
1378
|
+
/** 发起此 ask 的 end-user principal(per-ask 用户归因;与多租户 `scope` 不同层 —— scope=租户命名空间, principal=具体用户)。 */
|
|
710
1379
|
principal?: string;
|
|
1380
|
+
/** §assistant-scheduler 下批(service b96b76b):ask 创建时间(epoch ms)→ 面板显「挂了多久」。
|
|
1381
|
+
* 非轻量 summary 字段,inbox 端点并行 get 完整 Checkpoint best-effort 取;缺/过期 cp → OMIT(容缺降级)。 */
|
|
711
1382
|
createdAt?: number;
|
|
712
1383
|
}
|
|
1384
|
+
/** §2 GET /v1/assistant/inbox 的行 = CheckpointSummary + objective(从 task ctx 富化)。
|
|
1385
|
+
* objective 契约明确"`null` if unavailable"故保留 `| null`(不与"缺则 OMIT"冲突, 这是真的回 null 的字段)。
|
|
1386
|
+
* 已由 core listPending 按 severity 排序 —— 消费方**不要再排**。 */
|
|
713
1387
|
export interface InboxRow extends CheckpointSummary {
|
|
714
1388
|
objective?: string | null;
|
|
1389
|
+
/** 🔴 LIVE 契约偏差(实测,已 flag service):部署的 worker(42c7a65,≥6cd0164)
|
|
1390
|
+
* 的 `/v1/assistant/inbox` 实返**富 pending**(server.ts:1414 直接 spread `listPending()`,**没走 summarizeCheckpoint**),
|
|
1391
|
+
* 即 `severity` 藏在 **`riskDescriptor.severity`** 里、无顶层 `severity` 标量、无 `gateKind`、无 `token`,且带 decide 三绑定。
|
|
1392
|
+
* 这与契约文档「只 severity 标量、不上 riskDescriptor、有 gateKind/token」矛盾(文档自述"code wins")。
|
|
1393
|
+
* `assistant.inbox()` 防御性归一:severity 优先顶层标量(文档/未来态),缺则回退 `riskDescriptor.severity`(当前 live 态)——
|
|
1394
|
+
* service 修 handler 后顶层标量自动接管,前向兼容。下列字段标 optional 容当前富形状。 */
|
|
715
1395
|
riskDescriptor?: {
|
|
716
1396
|
severity?: 1 | 2 | 3 | 4 | 5;
|
|
717
1397
|
axes?: Record<string, unknown>;
|
|
718
1398
|
toolName?: string;
|
|
719
1399
|
} | null;
|
|
720
1400
|
toolName?: string | null;
|
|
1401
|
+
/** decide 三绑定(富 inbox 行直接带 → 可不回拉 /api/approvals 决策;opaque echo)。 */
|
|
721
1402
|
boundCallId?: string;
|
|
722
1403
|
boundInputHash?: string;
|
|
1404
|
+
/** §assistant-scheduler(core 1.114.0;the pinned wire contract)approval-suspend 时的 per-call 身份 = S3 D-1 精确锚。
|
|
1405
|
+
* 🔴 聚合单收件箱**必保** toolCallId —— 否则 decide 仅按 taskId+sessionId 在 boundCallId 缺时退化 first-match(D-1 锚定回归)。 */
|
|
723
1406
|
toolCallId?: string;
|
|
1407
|
+
/** §assistant-scheduler 下批(service b96b76b):挂起工具调用的 args **脱敏预览**("这条 ask 关于什么")。
|
|
1408
|
+
* 🔴 server 侧已 `redactDeep` scrub 密钥族 + 限长 2KB(inbox owner-scoped,仅 ask 自己 principal/operator 见);
|
|
1409
|
+
* 仅 `tool_approval` gate 带 args,`resource_limit`/`plan_review` 无 args → `null`(容缺渲染)。client 只展示、不重算。 */
|
|
724
1410
|
input?: unknown;
|
|
725
1411
|
}
|
|
1412
|
+
/** §3 GET /v1/assistant/tasks 行内联的 gate。wire 上 severity/spentMicroUsd/deadline 形如 `4 | null` —
|
|
1413
|
+
* SDK 侧规约为 `?:number`(缺/null 都容忍, OMIT 优先)。整个 gate 在 wire 上可为 null → AssistantTask.gate 是 `AssistantGate | null`。 */
|
|
726
1414
|
export interface AssistantGate {
|
|
1415
|
+
/** 同 gateKind 开集。 */
|
|
727
1416
|
kind: string;
|
|
1417
|
+
/** wire 可能回 null, 容忍。 */
|
|
728
1418
|
severity?: number;
|
|
729
1419
|
spentMicroUsd?: number;
|
|
1420
|
+
/** epoch ms; wire 可能回 null, 容忍。 */
|
|
730
1421
|
deadline?: number;
|
|
731
1422
|
}
|
|
1423
|
+
/** §3 N-task 调度总览行 = run-store listRuns(owner) join 核心 scheduler seam listByScope。
|
|
1424
|
+
* Triage 序: needs-attention 优先, 再 severity DESC, 再 spend DESC(**core 已排, 不要再排**)。
|
|
1425
|
+
* 需 TiDB run store 否则 `{tasks:[]}`。⚠️ createdAt/updatedAt 是 **ISO 串**(与 inbox/§1 的 epoch-ms 不同)。 */
|
|
732
1426
|
export interface AssistantTask {
|
|
733
1427
|
taskId: string;
|
|
734
1428
|
sessionId: string;
|
|
1429
|
+
/** §3 状态三态(service 源审计 fix):
|
|
1430
|
+
* - `running` — 在跑。
|
|
1431
|
+
* - `suspended` — 在 HITL 门上 durable 挂起(resource_limit / 人审 tool gate 等)→ 走 §4b resume / §4a decide。
|
|
1432
|
+
* - `needs_review` — **first-class triage 态**:plan_review / dry-run review park 持久化成此态(**非 suspended**;
|
|
1433
|
+
* 旧 handler filter 漏了它)。带 needsAttention:true + gate.kind=`plan_review`/`needs_review`(severity 缺)、
|
|
1434
|
+
* 排最前。🔴 解析走 §4c plan_review(POST /v1/assistant/tasks/:id/plan_review),**非 §4b resume**。
|
|
1435
|
+
* 注:与 L23 RunStatus 的 `needs_review`(design/80 D-0 dry-run TERMINAL 终态)语义不同 —— 那是 run 终态,
|
|
1436
|
+
* 这是调度总览行上的 park 态;同名不同轴。 */
|
|
735
1437
|
status: "running" | "suspended" | "needs_review";
|
|
1438
|
+
/** = 在 HITL 门上 park(suspended 或 needs_review)。 */
|
|
736
1439
|
needsAttention: boolean;
|
|
737
1440
|
gate: AssistantGate | null;
|
|
1441
|
+
/** ISO 时间串。 */
|
|
738
1442
|
createdAt: string;
|
|
739
1443
|
updatedAt: string;
|
|
740
1444
|
}
|
|
1445
|
+
/** §4c plan_review 请求体(3-state)。editedPlan 仅 decision==="edit" 时必带, 其余禁带(→ 400, BFF 也会守)。 */
|
|
741
1446
|
export interface PlanReviewRequest {
|
|
742
1447
|
decision: "approve" | "edit" | "reject";
|
|
1448
|
+
/** operator 改写后的 plan; REQUIRED iff decision==="edit", 否则禁带。 */
|
|
743
1449
|
editedPlan?: string;
|
|
744
1450
|
reason?: string;
|
|
745
1451
|
}
|
|
1452
|
+
/** §4b/§4c/§4d 决策端点的轻量返回(resume/plan_review→200 {status}, preempt→202 {status})。
|
|
1453
|
+
* status 形如 "completed"|"preempting"|… —— 开放串, 不窄化。 */
|
|
746
1454
|
export interface AssistantTaskStatus {
|
|
747
1455
|
status: string;
|
|
748
1456
|
}
|