@sema-agent/server 6.3.1 → 6.4.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.
@@ -14,6 +14,9 @@ function rowToEntry(r) {
14
14
  ...(r.session_scoped !== null && r.session_scoped !== undefined ? { sessionScoped: Boolean(Number(r.session_scoped)) || r.session_scoped === true } : {}),
15
15
  ...(r.root_session_id !== null && r.root_session_id !== undefined ? { rootSessionId: String(r.root_session_id) } : {}),
16
16
  ...(r.model !== null && r.model !== undefined ? { model: String(r.model) } : {}),
17
+ // core 5.10.0 additive:modelFallback(请求词未绑臂,子代跑在继承默认上)——现词表单成员;等值守卫
18
+ // 而非裸 String cast:core 若扩成员,这里 tsc 先红(勿静默放行未知词进 RosterEntry 窄类型)。
19
+ ...(r.model_fallback === "inherit_no_tier_binding" ? { modelFallback: "inherit_no_tier_binding" } : {}),
17
20
  createdAt: Number(r.created_at_ms),
18
21
  };
19
22
  }
@@ -32,7 +35,7 @@ const RESOLVE_WHERE_TIDB = `name_key = ? AND BINARY scope = ? AND (BINARY owner
32
35
  const RESOLVE_WHERE_PG = `name_key = $1 AND scope = $2 AND (owner = $3 OR (session_scoped = 1 AND $4::varchar IS NOT NULL AND owner = $5))`;
33
36
  // core 1.373 additive:RosterEntry.model(spawn 记录的解析后模型 id)——列投影型 store 必须显式接
34
37
  // (File/Memory 后端整对象持久化天然保住;列白名单剥键=SDK 0.0.72 中继剥键同族教训,发车复审抓获)。
35
- const COLS = "name, agent_id, session_id, tool_use_id, owner, scope, session_scoped, root_session_id, model, created_at_ms";
38
+ const COLS = "name, agent_id, session_id, tool_use_id, owner, scope, session_scoped, root_session_id, model, model_fallback, created_at_ms";
36
39
  /* ┌─ 历史:曾经的运行期迁移腿(已折进 CREATE,2026-07-26 clay 裁「删库重建」)────────────────────┐
37
40
  * 本文件的两个 ensure 曾在每次 boot 跑三族迁移语句,现已全部折叠为 CREATE TABLE 里的列定义。
38
41
  * 保留由来,因为它解释了这些列**为什么长这样**,以及当年为什么不能只写一条 CREATE:
@@ -78,6 +81,8 @@ export async function ensureTiDBRosterSchema(pool) {
78
81
  root_session_id VARCHAR(190) NULL,
79
82
  -- core 1.373 additive:spawn 记录的解析后模型 id(NULL = 该 spawn 未记录模型)
80
83
  model VARCHAR(190) NULL,
84
+ -- core 5.10.0 additive:modelFallback 归因(NULL = 请求词已绑或未记录)
85
+ model_fallback VARCHAR(64) NULL,
81
86
  created_at_ms BIGINT NOT NULL,
82
87
  recorded_at_ms BIGINT NOT NULL,
83
88
  PRIMARY KEY (name_key, owner_key, scope_key),
@@ -103,6 +108,8 @@ export async function ensurePgRosterSchema(q) {
103
108
  root_session_id VARCHAR(190),
104
109
  -- core 1.373 additive(TiDB 同案):解析后模型 id(NULL = 该 spawn 未记录模型)
105
110
  model VARCHAR(190),
111
+ -- core 5.10.0 additive(TiDB 同案):modelFallback 归因
112
+ model_fallback VARCHAR(64),
106
113
  created_at_ms BIGINT NOT NULL,
107
114
  recorded_at_ms BIGINT NOT NULL,
108
115
  PRIMARY KEY (name_key, owner_key, scope_key)
@@ -126,6 +133,7 @@ function upsertParams(entry, now) {
126
133
  entry.sessionScoped === undefined ? null : entry.sessionScoped ? 1 : 0,
127
134
  entry.rootSessionId ?? null,
128
135
  entry.model ?? null,
136
+ entry.modelFallback ?? null,
129
137
  entry.createdAt,
130
138
  now,
131
139
  ];
@@ -140,10 +148,10 @@ export class TiDBRosterStore {
140
148
  async record(entry) {
141
149
  const p = upsertParams(entry, this.clock());
142
150
  await this.pool.query(`INSERT INTO ${ROSTER_TABLE} (name_key, owner_key, scope_key, ${COLS}, recorded_at_ms)
143
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
151
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
144
152
  ON DUPLICATE KEY UPDATE name = VALUES(name), agent_id = VALUES(agent_id), session_id = VALUES(session_id),
145
153
  tool_use_id = VALUES(tool_use_id), owner = VALUES(owner), scope = VALUES(scope),
146
- session_scoped = VALUES(session_scoped), root_session_id = VALUES(root_session_id), model = VALUES(model), created_at_ms = VALUES(created_at_ms), recorded_at_ms = VALUES(recorded_at_ms)`, p.map((v) => (typeof v === "boolean" ? (v ? 1 : 0) : v)));
154
+ session_scoped = VALUES(session_scoped), root_session_id = VALUES(root_session_id), model = VALUES(model), model_fallback = VALUES(model_fallback), created_at_ms = VALUES(created_at_ms), recorded_at_ms = VALUES(recorded_at_ms)`, p.map((v) => (typeof v === "boolean" ? (v ? 1 : 0) : v)));
147
155
  }
148
156
  async resolve(name, access) {
149
157
  const key = normalizeAgentName(name);
@@ -176,10 +184,10 @@ export class PgRosterStore {
176
184
  }
177
185
  async record(entry) {
178
186
  await this.q(`INSERT INTO ${ROSTER_TABLE} (name_key, owner_key, scope_key, ${COLS}, recorded_at_ms)
179
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
187
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
180
188
  ON CONFLICT (name_key, owner_key, scope_key) DO UPDATE SET name = EXCLUDED.name, agent_id = EXCLUDED.agent_id,
181
189
  session_id = EXCLUDED.session_id, tool_use_id = EXCLUDED.tool_use_id, owner = EXCLUDED.owner,
182
- scope = EXCLUDED.scope, session_scoped = EXCLUDED.session_scoped, root_session_id = EXCLUDED.root_session_id, model = EXCLUDED.model, created_at_ms = EXCLUDED.created_at_ms,
190
+ scope = EXCLUDED.scope, session_scoped = EXCLUDED.session_scoped, root_session_id = EXCLUDED.root_session_id, model = EXCLUDED.model, model_fallback = EXCLUDED.model_fallback, created_at_ms = EXCLUDED.created_at_ms,
183
191
  recorded_at_ms = EXCLUDED.recorded_at_ms`, upsertParams(entry, this.clock()));
184
192
  }
185
193
  async resolve(name, access) {
@@ -23,7 +23,7 @@ type _GuardNotification = AssertAllKeysHandled<Exclude<keyof TaskNotificationPay
23
23
  type BgNotifProjected = "taskId" | "sessionId" | "seq" | "status" | "summary" | "stoppedBy" | "resumable" | "recentSteps" | "editedFiles" | "usage" | "transcriptId" | "rootSessionId" | "parentTaskId" | "parentToolCallId" | "completionId";
24
24
  type BgNotifExcluded = "kind" | "sessionScoped" | "owner" | "scope" | "description" | "agentType" | "name" | "currentAction" | "currentTool" | "parentSessionId" | "startedAt" | "workflowRunId" | "progressTaskId" | "progressParentTaskId";
25
25
  type _GuardBgNotif = AssertAllKeysHandled<Exclude<keyof BackgroundChildEvent, BgNotifProjected | BgNotifExcluded>>;
26
- type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "createdAt";
26
+ type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "modelFallback" | "createdAt";
27
27
  type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
28
28
  type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "sourceTaskId" | "fromSubagent" | "sourceAgentName" | "delegation";
29
29
  type AskExcluded = "preview" | "principal" | "requiresRealApproval";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "6.3.1",
3
+ "version": "6.4.0",
4
4
  "description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -54,7 +54,7 @@
54
54
  "build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
55
55
  },
56
56
  "dependencies": {
57
- "@sema-agent/core": "^5.9.0",
57
+ "@sema-agent/core": "^5.10.0",
58
58
  "@sema-agent/registry-core": "^0.14.0",
59
59
  "e2b": "^2.28.0",
60
60
  "libsodium-wrappers": "^0.8.4",
@@ -68,7 +68,7 @@
68
68
  "sharp": "^0.35.3"
69
69
  },
70
70
  "devDependencies": {
71
- "@sema-agent/sdk": "^6.2.0",
71
+ "@sema-agent/sdk": "^6.3.0",
72
72
  "@types/libsodium-wrappers": "^0.7.14",
73
73
  "@types/node": "22.10.2",
74
74
  "@types/pg": "^8.20.0",