@sema-agent/client-core 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.22.0
26
+ **Version:** 0.23.0
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
@@ -35,6 +35,18 @@
35
35
  */
36
36
  import type { AgentEvent, CheckpointGate } from '@sema-agent/sdk';
37
37
  import { type SDKMessage, type EmitContext, type ModelUsage } from '../types.js';
38
+ /**
39
+ * 本适配器铸出的**内部臂** `type` 全集(A-004.4 上游半场,2026-08-08)——「内部臂」= 桥面
40
+ * (bridge-facing)消息,**不是** CC SDK stdout 联合体里的帧形(那些是 assistant/stream_event/
41
+ * system 等真帧)。消费方(壳 REPL 桥、`-p` print 出口、web/desktop 座位层)对内部臂只有两种
42
+ * 合法处置:**吞**(不外泄)或**转成真 CC 帧**;顺着兜底裸透传到 stdout/wire = 病族⑥投影缺口
43
+ * (cli A-004.11/12 实翻:human_input/diagnostics/workspace_changed 曾漏进 `-p` stream-json)。
44
+ *
45
+ * 这张表是**唯一权威源**:消费方的吞/转名单必须对账本表(全覆盖,禁手抄子集——A-004.4 的病形
46
+ * 就是壳手抄了 4 词的子集);本包 pure 门有源码对账腿(armBody 铸点抽取 ≡ 本表),加臂不登记
47
+ * 即红。`turn_usage` 的铸点在 runStream.ts(usage 聚合腿),不在本文件的 switch 里,同属本表。
48
+ */
49
+ export declare const INTERNAL_SDK_ARM_TYPES: ReadonlySet<string>;
38
50
  /** 「本切片不投影这条臂」的**如实分类**(REF-CC-058 / xlate-04)。 */
39
51
  export type EventProjectionNoneReason =
40
52
  /** `turn_end`:usage 折叠是 run driver 的活(`turnEndUsage`),本层无独立可渲染臂。 */
@@ -19,6 +19,30 @@ function armBody(body) {
19
19
  const SUGGESTION_BATCH_CAP = 8;
20
20
  /** 单条建议的字符上界;超出截断并留可见痕迹(尾部 `…`)。 */
21
21
  const SUGGESTION_CHARS_CAP = 200;
22
+ /**
23
+ * 本适配器铸出的**内部臂** `type` 全集(A-004.4 上游半场,2026-08-08)——「内部臂」= 桥面
24
+ * (bridge-facing)消息,**不是** CC SDK stdout 联合体里的帧形(那些是 assistant/stream_event/
25
+ * system 等真帧)。消费方(壳 REPL 桥、`-p` print 出口、web/desktop 座位层)对内部臂只有两种
26
+ * 合法处置:**吞**(不外泄)或**转成真 CC 帧**;顺着兜底裸透传到 stdout/wire = 病族⑥投影缺口
27
+ * (cli A-004.11/12 实翻:human_input/diagnostics/workspace_changed 曾漏进 `-p` stream-json)。
28
+ *
29
+ * 这张表是**唯一权威源**:消费方的吞/转名单必须对账本表(全覆盖,禁手抄子集——A-004.4 的病形
30
+ * 就是壳手抄了 4 词的子集);本包 pure 门有源码对账腿(armBody 铸点抽取 ≡ 本表),加臂不登记
31
+ * 即红。`turn_usage` 的铸点在 runStream.ts(usage 聚合腿),不在本文件的 switch 里,同属本表。
32
+ */
33
+ export const INTERNAL_SDK_ARM_TYPES = new Set([
34
+ 'workflow_complete',
35
+ 'tool_end_result',
36
+ 'retry_status',
37
+ 'task_progress',
38
+ 'task_notification',
39
+ 'diagnostics',
40
+ 'steering_injected',
41
+ 'workspace_changed',
42
+ 'prompt_suggestions',
43
+ 'human_input',
44
+ 'turn_usage',
45
+ ]);
22
46
  /** Wrap neutral content blocks in the CC `assistant` message envelope. */
23
47
  function assistantArm(ctx, content) {
24
48
  return stamp(ctx, armBody({
@@ -91,9 +115,19 @@ export function eventToSdkMessage(ev, ctx) {
91
115
  if (typeof ev.runId !== 'string' || ev.runId.length === 0) {
92
116
  return dropped('malformed', 'workflow_complete');
93
117
  }
118
+ // A-004.9(病族⑤ default-arm-lie,2026-08-08):status 的**合同**是闭集 'completed'|'failed'
119
+ // (server workflow-completion-inbox.d.ts `status: "completed" | "failed"` 直证;sdk events.d.ts
120
+ // 宽成 string 只是类型面松),但 wire 是 JSON 开集——此前 `=== 'failed' ? failed : completed`
121
+ // 把任何第三词(上游未来加终态/坏帧垃圾值)**谎成 completed**。诚实形=与本臂 runId 缺失同款
122
+ // malformed 处置(dropped 留痕):第三词到达=上游换了合同,提货跟车该在这里翻红显形,而
123
+ // server 的 WorkflowStatus poll floor 对被丢的完成推送有结构性兜底(inbox 头注明写)。
124
+ if (ev.status !== 'completed' && ev.status !== 'failed') {
125
+ return dropped('malformed', 'workflow_complete');
126
+ }
94
127
  return projected(stamp(ctx, armBody({
95
128
  type: 'workflow_complete',
96
129
  runId: ev.runId,
130
+ // 卫后二值闭集,三元只在 known 词间选路(TS 不从 string 否定收窄字面量,故保留三元形)。
97
131
  status: ev.status === 'failed' ? 'failed' : 'completed',
98
132
  summary: typeof ev.summary === 'string' ? ev.summary : '',
99
133
  })));
@@ -16,8 +16,9 @@ export function backgroundStatusFromAssistant(s) {
16
16
  default: {
17
17
  const exhaustive = s; // 上游加词 ⇒ 这里编译红(闭集穷举卫兵)
18
18
  void exhaustive;
19
- // wire 开集回落:assistant.tasks 只列活跃调度行,未知新词按「活着」渲(同 workflowClient coerce 族)。
20
- return 'running';
19
+ // A-004.10:wire 开集回落改诚实形——此前未知新词按「活着」渲 'running',上游若加的是
20
+ // 终态词就是幽灵活跃行(#182 同病)。'unknown' = 不编造任何一头。
21
+ return 'unknown';
21
22
  }
22
23
  }
23
24
  }
@@ -45,9 +46,9 @@ export function backgroundStatusFromFleet(s) {
45
46
  case 'killed':
46
47
  return 'stopped';
47
48
  default: {
48
- const exhaustive = s; // 上游加词 ⇒ 编译红;wire 未知词(读侧开集)⇒ 按活跃行回落
49
+ const exhaustive = s; // 上游加词 ⇒ 编译红;wire 未知词(读侧开集)⇒ 'unknown' 诚实回落(A-004.10)
49
50
  void exhaustive;
50
- return 'running';
51
+ return 'unknown';
51
52
  }
52
53
  }
53
54
  }
@@ -117,7 +117,7 @@ export type BackgroundSource = 'assistant' | 'fleet';
117
117
  /** not-configured = assistant 无 TiDB 时的 `{tasks:[]}` 形 —— 与「真没有任务」必须可区分。 */
118
118
  export type BackgroundSourceHealth = 'ok' | 'unavailable' | 'not-configured';
119
119
  /** 第三套中性词表(不用任一方词表:3 值压不住 9 值,9 值会造 assistant 侧不存在的态)。 */
120
- export type BackgroundStatus = 'running' | 'waiting-on-human' | 'queued' | 'stopping' | 'done' | 'failed' | 'stopped';
120
+ export type BackgroundStatus = 'running' | 'waiting-on-human' | 'queued' | 'stopping' | 'done' | 'failed' | 'stopped' | 'unknown';
121
121
  export interface BackgroundRow {
122
122
  /** 带来源判别;fleet 复合 id("<runId> <taskId>")不拆 —— 裸 id union 会重复计数。 */
123
123
  readonly key: {
@@ -95,6 +95,13 @@ export const STRUCTURED_DETAIL_TYPES = new Set([
95
95
  'agent-transcript',
96
96
  'a2a',
97
97
  'document',
98
+ // ── core 5.20.0 跟车两词(A-004.5,2026-08-08;engine-vocab 等值门对 5.20.0 实装物直证)──────
99
+ // 本条的病根不在词表本身,在**对账物**:门锚的是本仓 devDep core,而 devDep 停在 5.10.0 ⇒
100
+ // 生态已 5.17.0+(ask-question 已实发)门仍恒绿。修 = devDep 升 5.20.0(门自然翻红显出全部
101
+ // 漂移)+ 补词。`ask-question` = AskUserQuestion 卡;`bash_invalid_timeout` 与
102
+ // `path_not_in_root`/`readonly_out_of_root` 同族(参数拒绝的结构化错误卡)。
103
+ 'ask-question',
104
+ 'bash_invalid_timeout',
98
105
  ]);
99
106
  // 🔴 同批**删三词**(core 5.10.0 BREAKING「幽灵卡」清仓):`multiedit` / `memory-saved` /
100
107
  // `memory-recall` —— 全树零铸点(MultiEdit/批量重放铸的是 `type:"edit"` 带 `edits[]`;core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/client-core",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
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",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@sema-agent/agent-types": "^0.2.0",
35
- "@sema-agent/core": "^5.10.0",
35
+ "@sema-agent/core": "^5.20.0",
36
36
  "@sema-agent/sdk": "^6.9.0",
37
37
  "esbuild": "^0.27.4",
38
38
  "typescript": "^6.0.2"