@sema-agent/client-core 0.11.0 → 0.11.2

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.
@@ -219,7 +219,8 @@ function errCodes(e) {
219
219
  if (!e || typeof e !== 'object')
220
220
  return {};
221
221
  const o = e;
222
- return { code: o.errorCode ?? o.code, name: o.name, status: o.status ?? o.statusCode };
222
+ // [1912] errorCode 恒在(server ≥1.302 canonical)——`?? o.code` 老兜底已清;status 双键保留(HTTP 层形非 wire 键)。
223
+ return { code: o.errorCode, name: o.name, status: o.status ?? o.statusCode };
223
224
  }
224
225
  /** 409 `steering.not_running` / `SteeringNotRunningError` — the run is suspended/terminal (runs.ts:45). */
225
226
  function isSteeringNotRunning(e) {
@@ -248,7 +248,8 @@ function isBindingMismatch(e) {
248
248
  if (!e || typeof e !== 'object')
249
249
  return false;
250
250
  const o = e;
251
- const code = o.errorCode ?? o.code;
251
+ // [1912] errorCode 恒在(server ≥1.302 canonical;全端引擎达标线 ≥1.303)——`?? o.code` 老兜底已清。
252
+ const code = o.errorCode;
252
253
  if (code === 'approval_binding_mismatch')
253
254
  return true;
254
255
  // SDK throws a named ApprovalBindingMismatchError (index.ts:19).
@@ -98,6 +98,9 @@ export const ENGINE_RUNNER_FACE = [
98
98
  'Skill',
99
99
  'TaskOutput',
100
100
  'TaskStop',
101
+ // [1870] L2 半条(0.11.1):deferred-tools 取回工具,runner 恒挂——引擎对模型的真实请求
102
+ // 恒声明它(sema-test repro A2 双向断言实证),此前自报面漏它=显示轨迹失真误导归因。
103
+ 'ToolSearch',
101
104
  'Workflow',
102
105
  ];
103
106
  /** [1036]/clay 裁:runner 恒挂段按壳已知 env 门过滤——print 宿主前置 SCHEDULER_ENABLED=false
@@ -47,6 +47,8 @@ export interface ToolEndResultArmLike {
47
47
  toolName?: unknown;
48
48
  isError?: unknown;
49
49
  output?: unknown;
50
+ /** 引擎 CC-shaped details(core 1.199+ AgentToolResult.details;Bash 时带 exitCode)。 */
51
+ structured?: unknown;
50
52
  truncated?: unknown;
51
53
  parentToolCallId?: unknown;
52
54
  uuid?: unknown;
@@ -25,12 +25,21 @@ export function flattenToolOutput(output) {
25
25
  * Bash 臂的 is_error 派生(真行为实证,2026-07-16):引擎 tool_end.isError 语义 = 「工具本身
26
26
  * 是否执行失败」——命令非零退出时工具照常返回模型面框架文本(core runShell `exit code: N\n---
27
27
  * stdout ---…`)且 isError:false。CC 2.1.207 的 Bash tool_result 对非零退出置 is_error:true;
28
- * 交互 REPL 桥已按同款派生(upstreamBridge.ts:384 `failed = isError || exitCode !== 0`)。
29
- * 这里对 Bash 输出的框架头做同源轻量嗅探(不拖 REPL 桥的重 import 图)。
28
+ * 交互 REPL 桥按同款派生。
29
+ *
30
+ * 🔴 语序与 toolResult.ts T11 逐字同款([1948] E4 / core RB-257,2026-07-29):
31
+ * **structured.exitCode 在场 ⇒ 权威直读;缺席 ⇒ 正则反解兜底**。此前只有正则——输出超
32
+ * 30000 字符溢写成 persisted-output 引用后,前缀把 `exit code: N` 挤出行首,锚失配 ⇒
33
+ * 非零退出照样 is_error:false(test AI 生产轨迹 2/2 命中);而 structured 字段在溢写时
34
+ * **完好保留**,正是为这种形准备的。兜底失锚时如实 false,绝不按内容嗅探瞎猜
35
+ * (与 core [1951] 同判断:拿前缀猜 isError = 用一个谎换另一个谎)。
30
36
  */
31
- function bashExitCodeFailed(toolName, text) {
37
+ function bashExitCodeFailed(toolName, text, structured) {
32
38
  if (typeof toolName !== 'string' || toolName.toLowerCase() !== 'bash')
33
39
  return false;
40
+ const ec = structured?.exitCode;
41
+ if (typeof ec === 'number')
42
+ return ec !== 0;
34
43
  const m = /^exit code: (\d+)\b/.exec(text);
35
44
  return m !== null && m[1] !== '0';
36
45
  }
@@ -52,7 +61,7 @@ export function toolEndResultToUserFrame(arm) {
52
61
  tool_use_id: arm.toolCallId,
53
62
  // truncated 输出如实标注(观察面注记;截断体绝不回喂模型——upstreamBridge 同款)。
54
63
  content: arm.truncated === true ? `${text}\n…(truncated)` : text,
55
- is_error: arm.isError === true || bashExitCodeFailed(arm.toolName, text),
64
+ is_error: arm.isError === true || bashExitCodeFailed(arm.toolName, text, arm.structured),
56
65
  },
57
66
  ],
58
67
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/client-core",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
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",
@@ -14,7 +14,7 @@
14
14
  "sideEffects": false,
15
15
  "scripts": {
16
16
  "build": "tsc -p tsconfig.json",
17
- "test": "node scripts/run-client-core-pure-test.mjs && node scripts/run-client-core-portability-test.mjs && node scripts/run-client-core-diff-test.mjs"
17
+ "test": "node scripts/run-client-core-pure-test.mjs && node scripts/run-client-core-portability-test.mjs && node scripts/run-client-core-diff-test.mjs && node scripts/run-print-bash-iserror-test.mjs"
18
18
  },
19
19
  "dependencies": {
20
20
  "diff": "^9.0.0"