@sema-agent/client-core 0.11.11 → 0.11.13
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/README.md +2 -1
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +5 -3
- package/dist/adapter/downstream/terminalToSdkResult.js +12 -2
- package/dist/adapter/runStream.js +5 -1
- package/dist/headlessReconnectWire.js +1 -1
- package/dist/hitl/askGateWire.js +19 -0
- package/dist/subagent/engineTaskHandleWire.js +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Renamed from **`@sema-agent/wire-cc-adapter`** (0.1.x, deprecated — see *Migra
|
|
|
23
23
|
|
|
24
24
|
## Scope
|
|
25
25
|
|
|
26
|
-
**Version:** 0.11.
|
|
26
|
+
**Version:** 0.11.12
|
|
27
27
|
|
|
28
28
|
- **Today** — the adapter seam, the whole `adapt()` pipeline (all 14 A-layer arms plus the
|
|
29
29
|
B/D/E tool-card layers), the notification/caps/model families, the adapter kernel (stream driver
|
|
@@ -213,6 +213,7 @@ itself (FAILED names + skipped names + arithmetic reconciliation). All-SKIP repo
|
|
|
213
213
|
| `scripts/run-print-bash-iserror-test.mjs` | The print lane's Bash `is_error` authority (structured over regex) |
|
|
214
214
|
| `scripts/run-sdk-floor-test.mjs` | The SDK version floor — and, more to the point, that the *installed* type declarations still carry the keys this package reads |
|
|
215
215
|
| `scripts/run-engine-vocab-floor-test.mjs` | Engine-mirrored vocabularies (structured card whitelist, self-reported tool face, control verbs, recogniser sets) against the *installed* `@sema-agent/core` |
|
|
216
|
+
| `scripts/run-streamjson-timing-honesty-test.mjs` | Stream timing & terminal honesty ([2084]): held errored fs-write results release on model progress; wall-clock timeout maps to `error_during_execution` with a truthful salvage note; the synthetic API-error assistant row carries the `<synthetic>` in-message sentinel |
|
|
216
217
|
| `scripts/run-public-surface-test.mjs` | The outward promises: the npm export surface baseline, the peer floor witness, and this README's claims |
|
|
217
218
|
|
|
218
219
|
Each suite carries a floor that only moves up — a refactor that stops executing a group of
|
|
@@ -35,9 +35,11 @@
|
|
|
35
35
|
* failed limit.max_turns → 'error_max_turns' true
|
|
36
36
|
* failed output.invalid → 'error_max_structured_output_retries' true
|
|
37
37
|
* failed 其余(含 cancelled/conflict…) → 'error_during_execution' true
|
|
38
|
-
* timeout limit.timeout → '
|
|
39
|
-
* (CC 无 wall-clock deadline
|
|
40
|
-
*
|
|
38
|
+
* timeout limit.timeout → 'error_during_execution' true
|
|
39
|
+
* (CC 无 wall-clock deadline 概念。曾选 error_max_turns「唯一 run-limit 族词」,
|
|
40
|
+
* [2084]②a 定谳那是帧内自相矛盾(errorCode=limit.timeout+num_turns 远小于上限)
|
|
41
|
+
* 且对墙钟停指错旋钮(max-turns 是可恢复失败)⇒ 改诚实兜底词。
|
|
42
|
+
* 真实语义靠 errors[] 文案 + errorCode 透传辨认,不变。)
|
|
41
43
|
* blocked —(engine 只给 blockedReason)→ 'error_during_execution' true
|
|
42
44
|
* suspended — → 'error_during_execution' true([884]A1)
|
|
43
45
|
* needs_review review.pending → 'error_during_execution' true([884]A1)
|
|
@@ -203,7 +203,14 @@ export function doneToSdkResult(ev, ctx) {
|
|
|
203
203
|
uuid: undefined,
|
|
204
204
|
session_id: undefined,
|
|
205
205
|
type: 'result',
|
|
206
|
-
|
|
206
|
+
// [2084]②a(2026-07-30,repro/cli-walltime-timeout-reported-as-max-turns):此前硬编码
|
|
207
|
+
// error_max_turns(选型理由是「CC 词表唯一 run-limit 族词」),但那让同一帧自相矛盾
|
|
208
|
+
// (errorCode=limit.timeout + num_turns 远小于上限,test 实测 num_turns:2 且根本没设
|
|
209
|
+
// --max-turns),而且 max-turns 是**可恢复失败**——标准应对是调大 --max-turns 重试,对
|
|
210
|
+
// 墙钟停这恰好是那个帮不上忙的旋钮。改 error_during_execution(CC 词表内的诚实兜底);
|
|
211
|
+
// 真实语义仍靠 errorCode:"limit.timeout" + errors[] 文案判别(原设计轴不动)。
|
|
212
|
+
// 副产品:真 limit.max_turns 停(failed 臂)与墙钟停在 subtype 上重新可分。
|
|
213
|
+
subtype: 'error_during_execution',
|
|
207
214
|
duration_ms: durationMs,
|
|
208
215
|
duration_api_ms: durationMs,
|
|
209
216
|
is_error: true,
|
|
@@ -213,8 +220,11 @@ export function doneToSdkResult(ev, ctx) {
|
|
|
213
220
|
usage,
|
|
214
221
|
modelUsage,
|
|
215
222
|
permission_denials: [],
|
|
223
|
+
// [2084]②b:引擎的 cutoff 句承诺「cut off to preserve a write-out window」,但 pre-call
|
|
224
|
+
// throw 路径上写出窗可能零兑现(core dist/brain/stream-engine 五处 throw,载体天生空)。
|
|
225
|
+
// 抢救为空时补诚实尾注——每一层都复述没兑现的承诺,消费者就无从分辨救没救回来。
|
|
216
226
|
errors: [
|
|
217
|
-
`${rr.errorMessage ?? 'run hit its wall-clock deadline and was finalized by the engine'} (${rr.errorCode ?? 'limit.timeout'})`,
|
|
227
|
+
`${rr.errorMessage ?? 'run hit its wall-clock deadline and was finalized by the engine'} (${rr.errorCode ?? 'limit.timeout'})${salvaged === undefined ? ' — no output survived the cutoff' : ''}`,
|
|
218
228
|
],
|
|
219
229
|
...errorCodeField,
|
|
220
230
|
// 写出窗 salvage(additive seam 字段):deadline 前引擎救回的最终文本非空时随帧带出——
|
|
@@ -149,7 +149,11 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
149
149
|
session_id: ctx.sessionId ?? '',
|
|
150
150
|
uuid: `err-${Date.now().toString(36)}`,
|
|
151
151
|
type: 'assistant',
|
|
152
|
-
|
|
152
|
+
// [2084]③:message 内部要有判别哨兵——外层 isApiErrorMessage/err- uuid 只护住读信封的
|
|
153
|
+
// 消费者,而转录回喂/摘要器/评分器读的是 message 本体,没有 in-message 标记就会把这句
|
|
154
|
+
// 引擎文案当成模型自己说的话。CC 2.1.220 同款哨兵 = model:'<synthetic>'(下游投影层对
|
|
155
|
+
// string 型 model 原样保留,不再回填真模型名)。
|
|
156
|
+
message: { role: 'assistant', model: '<synthetic>', content: [{ type: 'text', text: rowText }] },
|
|
153
157
|
parent_tool_use_id: null,
|
|
154
158
|
isApiErrorMessage: true,
|
|
155
159
|
};
|
|
@@ -100,7 +100,7 @@ export async function* withHeadlessR1Reconnect(live, deps) {
|
|
|
100
100
|
if (t === 'error') {
|
|
101
101
|
// STREAM_MAX_DURATION cap 帧(server streamSseLog):SDK parseSse 已锁存 Last-Event-ID
|
|
102
102
|
// 并自动重开(同一次 openEvents 内部,计入同一次预算)——本帧是车道协议杂音,不下发。
|
|
103
|
-
debugLog(`runs.events lane frame type=error code=${String(rec?.code ?? '')} — SDK resumes with Last-Event-ID internally`);
|
|
103
|
+
debugLog(`runs.events lane frame type=error code=${String(rec?.errorCode ?? rec?.code ?? '')} — SDK resumes with Last-Event-ID internally`);
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
106
|
const seq = typeof rec?.id === 'string' && /^\d+$/.test(rec.id) ? Number(rec.id) : undefined;
|
package/dist/hitl/askGateWire.js
CHANGED
|
@@ -140,6 +140,10 @@ export function observeCancelByDeny(settle, taskId) {
|
|
|
140
140
|
hostLog('debug', `[hitl-ask] cancel-by-deny settled for run ${taskId} (session unlocked)`);
|
|
141
141
|
})
|
|
142
142
|
.catch((e) => {
|
|
143
|
+
// ⚠️ 这里的 `.code` 是 **client-core 自家 HitlSafetyError 的契约属性**(hitlBridge.ts,词表
|
|
144
|
+
// binding_mismatch|no_pending|wrong_gate|bad_plan_edit)—— 不是 SDK 错误的 `errorCode`。
|
|
145
|
+
// 2026-07-30 `.code` 普查曾把本处误判成 SDK 属性名病改成 errorCode,pure 门 B7 腿当场拦下
|
|
146
|
+
// (反向修复);判 `.code` 读点的病与否,先看**谁抛的**,别按属性名模式匹配。
|
|
143
147
|
if (e?.code === 'no_pending') {
|
|
144
148
|
hostLog('debug', `[hitl-ask] cancel-by-deny no_pending for run ${taskId} (benign — already resolved)`);
|
|
145
149
|
return;
|
|
@@ -293,6 +297,21 @@ export async function* bridgeAskUserQuestionGates(source, deps, opts) {
|
|
|
293
297
|
const seq = ev.id;
|
|
294
298
|
if (typeof seq === 'string' && seq.length > 0)
|
|
295
299
|
lastSeq = seq;
|
|
300
|
+
// ── [2084]① 扣留帧「模型推进即放行」(2026-07-30)─────────────────────────────────────
|
|
301
|
+
// HOLD 的本意只护 park 窗口:毒化 tool_end 与 park 信号(suspended/done-park/approval 帧)
|
|
302
|
+
// 之间只会隔 sibling tool_end 与通知类帧——引擎 park 时模型**不可能**推进。反之,host-lane
|
|
303
|
+
// 的 text_delta/reasoning_delta/tool_start/turn_end 任一到达 = 没有 park 会来,扣着的是
|
|
304
|
+
// **真工具错**,立即放行。修前真错只能等终帧 flush ⇒ `-p` stream-json 里 errored Edit/Write
|
|
305
|
+
// 结果滞后无上界(test 生产轨迹最大 195 行,repro/cli-tool-streamjson-failed-result-delayed)。
|
|
306
|
+
// parentToolCallId 在场 = sub-agent 行帧,park 期间孙代照常说话,不算 host 推进(负控①C)。
|
|
307
|
+
if (heldAskEnds.size > 0 &&
|
|
308
|
+
(ev.type === 'text_delta' ||
|
|
309
|
+
ev.type === 'reasoning_delta' ||
|
|
310
|
+
ev.type === 'tool_start' ||
|
|
311
|
+
ev.type === 'turn_end') &&
|
|
312
|
+
ev.parentToolCallId === undefined) {
|
|
313
|
+
yield* flushHeld();
|
|
314
|
+
}
|
|
296
315
|
// ── server 1.191 同步帧腿([830]①):`tool_approval` 帧 → 三选卡 → respond ────────────────
|
|
297
316
|
// 引擎此刻同步阻塞在帧上(fail-closed:无 respond/TTL 5min/abort ⇒ deny),await 卡决断安全。
|
|
298
317
|
// 帧是 HITL 词汇非 AgentEvent arm——两种帧都不外泄到渲染管道。
|
|
@@ -134,10 +134,14 @@ export function mergeTaskOutput(prev, fresh) {
|
|
|
134
134
|
*/
|
|
135
135
|
export function classifyTaskStopConflict(e) {
|
|
136
136
|
const detail = e instanceof Error ? e.message : String(e);
|
|
137
|
-
const raw = e?.
|
|
138
|
-
// typed 优先:SDK
|
|
139
|
-
//
|
|
140
|
-
//
|
|
137
|
+
const raw = e?.errorCode;
|
|
138
|
+
// typed 优先:SDK typed 错误(APIError 族)的机器码属性是 **`errorCode`**(peer 地板 >=2.0.0 恒有)。
|
|
139
|
+
// 🔴 2026-07-30 提货批实锤:此前这里读 `.code` —— 那是 0.x SDK 的属性名,1.0.0 错误层级重做后
|
|
140
|
+
// typed 类只带 `.errorCode`,于是五形分类整体塌 `unknown_conflict`。本仓 pure 门没抓到,因为
|
|
141
|
+
// 测试 fixture 也是手搓 `{status, code}` 老形 —— 实现与 fixture 同错互证(假绿)。壳的
|
|
142
|
+
// run-bulk-stop-engine-rows 门用**真 SDK** 打假 HTTP 引擎才现形(跨仓交叉验证)。修后 fixture
|
|
143
|
+
// 改锚实装 SDK 的 TaskStopConflictError 真类,fixture 再也漂不动。
|
|
144
|
+
// 兜底(非 typed 抛点):errorCode 非串时从 message 里认字面 —— 回落,不是主判据。
|
|
141
145
|
const code = typeof raw === 'string'
|
|
142
146
|
? raw
|
|
143
147
|
: (STOP_CONFLICT_CODES.find(c => detail.includes(c)) ?? '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/client-core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.13",
|
|
4
4
|
"description": "Client-side session runtime shared by every sema human client (TUI / web / desktop): sema wire frames (AgentEvent) -> CC session vocabulary (SDKMessage) with dual-plane output (transcript/chrome), deterministic transcript ids, lane discipline as a type, and the notification/dedup ledgers. Every CC-skin shape is collected here so the wire itself stays neutral. Blackboard [1832] design axioms; [1651]/[1652]/[1653] signed seam design. Renamed from @sema-agent/wire-cc-adapter (0.1.x).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|