@sema-agent/server 7.75.2 → 7.75.4

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.
@@ -1,5 +1,5 @@
1
1
  import { redactSecrets } from "../trace/redact.js";
2
- import { taskProgressEventData, toolStartEventData, toolEndEventData } from "../trace/project.js";
2
+ import { taskProgressEventData, toolStartEventData, toolEndEventData, textEndEventData } from "../trace/project.js";
3
3
  const TAIL_QUEUE_CAP = 512;
4
4
  export function projectTailFrame(e) {
5
5
  const t = e.type;
@@ -19,14 +19,8 @@ export function projectTailFrame(e) {
19
19
  return { type: "text_delta", delta: td.delta, ...(td.eventId ? { eventId: td.eventId } : {}), ...(td.parentToolCallId ? { parentToolCallId: td.parentToolCallId } : {}) };
20
20
  }
21
21
  if (t === "text_end") {
22
- if (typeof e.content !== "string" || e.content.length === 0)
23
- return null;
24
- return {
25
- type: "text_end",
26
- content: e.content,
27
- ...(typeof e.eventId === "string" ? { eventId: e.eventId } : {}),
28
- ...(typeof e.parentToolCallId === "string" ? { parentToolCallId: e.parentToolCallId } : {}),
29
- };
22
+ const f = textEndEventData(e);
23
+ return f === null ? null : { type: "text_end", ...f };
30
24
  }
31
25
  if (t === "reasoning_delta") {
32
26
  const rd = e;
@@ -12,7 +12,7 @@ import { clearTurnActivity, readTurnActivityMs, recordTurnActivity } from "../..
12
12
  import { mintCancelledResult } from "../../run-cancel-context.js";
13
13
  import { recordResourceWindow } from "../../resource-window.js";
14
14
  import { redactSecrets } from "../../trace/redact.js";
15
- import { contextUsageEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, workspaceChangedEventData, wiringManifestEventData, wiringManifestOperatorEventData, toolRosterDeltaEventData, humanInputEventData, appendModelUsageDelta, attachModelUsage } from "../../trace/project.js";
15
+ import { contextUsageEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, workspaceChangedEventData, wiringManifestEventData, wiringManifestOperatorEventData, toolRosterDeltaEventData, humanInputEventData, appendModelUsageDelta, attachModelUsage, textEndEventData } from "../../trace/project.js";
16
16
  import { cascadeConfig, runMeta } from "../run-meta.js";
17
17
  import { scopedIdempotencyKey } from "../idempotency.js";
18
18
  import { sendJson, sendError, sseHeaders } from "../send.js";
@@ -347,8 +347,9 @@ async function handleTasksBody(req, res, url, ctx, miss) {
347
347
  sseData(res, { type: "text_delta", delta: td.delta, ...(td.eventId ? { eventId: td.eventId } : {}), ...(td.parentToolCallId ? { parentToolCallId: td.parentToolCallId } : {}) });
348
348
  }
349
349
  else if (t === "text_end") {
350
- const tend = e;
351
- sseData(res, { type: "text_end", content: tend.content, ...(tend.eventId ? { eventId: tend.eventId } : {}), ...(tend.parentToolCallId ? { parentToolCallId: tend.parentToolCallId } : {}) });
350
+ const tend = textEndEventData(e);
351
+ if (tend !== null)
352
+ sseData(res, { type: "text_end", ...tend });
352
353
  }
353
354
  else if (t === "reasoning_delta") {
354
355
  const rd = e;
@@ -493,16 +494,19 @@ async function handleTasksBody(req, res, url, ctx, miss) {
493
494
  ...(e.sourceTaskId !== undefined ? { sourceTaskId: e.sourceTaskId } : {}),
494
495
  ...(e.bgAgentId !== undefined ? { bgAgentId: e.bgAgentId } : {}),
495
496
  };
497
+ const textEnd = ev.type === "text_end" ? textEndEventData(e) : undefined;
496
498
  const arm = ev.type === "text_delta"
497
499
  ? { type: "text_delta", delta: e.delta, ...ident }
498
500
  : ev.type === "text_end"
499
- ? { type: "text_end", content: e.content, ...ident }
501
+ ?
502
+ textEnd === null || textEnd === undefined ? null : { type: "text_end", ...textEnd }
500
503
  : ev.type === "turn_end"
501
504
  ? { type: "turn_end", ...(e.usage !== undefined ? { usage: e.usage } : {}), ...(e.usageMissing !== undefined ? { usageMissing: e.usageMissing } : {}), ...(e.stopReason !== undefined ? { stopReason: e.stopReason } : {}), ...ident }
502
505
  : ev.type === "message_committed"
503
506
  ? { type: "message_committed", entryId: e.entryId, role: e.role, ...(e.toolCallId !== undefined ? { toolCallId: e.toolCallId } : {}), ...ident }
504
507
  : { type: "context_usage", ...contextUsageEventData(ev), ...ident };
505
- sseData(res, arm);
508
+ if (arm !== null)
509
+ sseData(res, arm);
506
510
  }
507
511
  else {
508
512
  sseData(res, ev);
@@ -187,6 +187,13 @@ export declare function screenedGate(v: unknown): GateOutcome | undefined;
187
187
  * 不改原对象(调用方与账本共享引用):有变更时换一只信封,原记录一个字节不动。
188
188
  */
189
189
  export declare function screenedStoredEventData(type: string, data: unknown): unknown;
190
+ /** `text_end` 段末帧的**唯一**铸点(三腿共用:top stream / 转发子代腿 / 子代 tail 面)。content = 段权威全文 ⇒ 与
191
+ * durable 面(`result` / 账本 `text` 行)同一只 {@link redactModelText}(认出才改写、抛则占位、不设上限)。
192
+ * 此前三处各自逐字透传 —— 同一份文本毫秒后在 `done.result.result` 上已脱,live 面却在凭据生成瞬间明文(B-114)。
193
+ * `text_delta` 仍逐字:跨 chunk 的凭据无法就地判,流式脱敏是独立设计件(S-270)。
194
+ * 坏形(content 非串/空串)⇒ null(丢帧,不铸「权威空段」:core 契约明言空段不发本帧,消费端收到空段会清掉已攒 delta)。
195
+ * 身份四键零字节变换(live 现状带全四键,消费端可能已依赖)。 */
196
+ export declare function textEndEventData(ev: Record<string, unknown>): Record<string, unknown> | null;
190
197
  /** The durable `tool_end` payload (shared by both append sites). E1: the model-facing `output` is UNTRUSTED RAW
191
198
  * from core (file/shell/API bodies) — core only SIZE-bounds it (`truncated`), REDACTION is ours (same contract as
192
199
  * `tool_start.args`); never re-fed to a model. E2: identity. Absent `output` ⇒ the tool produced no content body.
@@ -1,4 +1,4 @@
1
- import { redactErrorMessage } from "../observability/run-terminal-log.js";
1
+ import { redactErrorMessage, redactModelText } from "../observability/run-terminal-log.js";
2
2
  import { MCP_DELIVERY_VERDICTS, screenGateOutcome, ToolRoster, ToolRosterDelta } from "@sema-agent/core";
3
3
  import { Value } from "typebox/value";
4
4
  import { recordFailOpen } from "../observability/fail-open.js";
@@ -173,6 +173,17 @@ function projectSettlement(st) {
173
173
  ...(typeof st.note === "string" ? { note: redactSecrets(st.note).slice(0, SETTLEMENT_NOTE_MAX) } : {}),
174
174
  };
175
175
  }
176
+ export function textEndEventData(ev) {
177
+ if (typeof ev.content !== "string" || ev.content.length === 0)
178
+ return null;
179
+ return {
180
+ content: redactModelText(ev.content),
181
+ ...(ev.eventId !== undefined ? { eventId: ev.eventId } : {}),
182
+ ...(ev.parentToolCallId !== undefined ? { parentToolCallId: ev.parentToolCallId } : {}),
183
+ ...(ev.sourceTaskId !== undefined ? { sourceTaskId: ev.sourceTaskId } : {}),
184
+ ...(ev.bgAgentId !== undefined ? { bgAgentId: ev.bgAgentId } : {}),
185
+ };
186
+ }
176
187
  export function toolEndEventData(ev) {
177
188
  const gate = ev.gate === undefined ? undefined : screenedGate(ev.gate);
178
189
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "7.75.2",
3
+ "version": "7.75.4",
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": "7.17.5",
57
+ "@sema-agent/core": "7.17.6",
58
58
  "@sema-agent/settings-schema": "1.10.0",
59
59
  "e2b": "^2.28.0",
60
60
  "libsodium-wrappers": "^0.8.4",