@sema-agent/server 3.21.0 → 3.22.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.
Files changed (41) hide show
  1. package/dist/approval-hmac.d.ts +9 -9
  2. package/dist/approval-hmac.js +0 -31
  3. package/dist/approval.js +8 -1
  4. package/dist/boot/config-center.d.ts +3 -2
  5. package/dist/boot/resolve-spec.js +4 -4
  6. package/dist/boot/session-faces.js +3 -2
  7. package/dist/boot/workflow-orchestration.js +1 -1
  8. package/dist/budget.d.ts +2 -2
  9. package/dist/budget.js +11 -6
  10. package/dist/hooks/hook-llm.d.ts +2 -2
  11. package/dist/hooks/hook-llm.js +1 -1
  12. package/dist/http/principal-gate.d.ts +7 -3
  13. package/dist/http/principal-gate.js +7 -5
  14. package/dist/http/route-ctx.d.ts +34 -25
  15. package/dist/http/routes/approvals-assistant.js +5 -5
  16. package/dist/http/routes/images.js +8 -8
  17. package/dist/http/server.d.ts +2 -2
  18. package/dist/http/server.js +2 -2
  19. package/dist/key-resolver.d.ts +7 -1
  20. package/dist/key-resolver.js +0 -23
  21. package/dist/leader/wire.d.ts +19 -1
  22. package/dist/leader/wire.js +48 -18
  23. package/dist/main.js +2 -2
  24. package/dist/parked-decide.js +4 -1
  25. package/dist/plugins/file-run-store.js +5 -5
  26. package/dist/plugins/host-platform.d.ts +11 -24
  27. package/dist/plugins/host-platform.js +14 -0
  28. package/dist/plugins/memory-engine-tidb.js +16 -0
  29. package/dist/plugins/memory-run-store.js +5 -5
  30. package/dist/plugins/remote-env-adb.js +12 -5
  31. package/dist/plugins/remote-env-local-docker.js +3 -7
  32. package/dist/plugins/remote-env-ssh.js +17 -2
  33. package/dist/plugins/run-store-sql.js +12 -12
  34. package/dist/plugins/store-backend.d.ts +1 -1
  35. package/dist/plugins/store-backend.js +2 -2
  36. package/dist/plugins/tool-result-store-sql.d.ts +7 -1
  37. package/dist/plugins/tool-result-store-sql.js +9 -8
  38. package/dist/plugins/workflow-run-store-sql.d.ts +11 -6
  39. package/dist/plugins/workflow-run-store-sql.js +18 -8
  40. package/dist/session-sync.js +6 -3
  41. package/package.json +1 -1
@@ -29,11 +29,15 @@ export function slimOversizeRun(run, maxBytes) {
29
29
  blob = JSON.stringify(step2);
30
30
  return Buffer.byteLength(blob) <= maxBytes ? blob : null;
31
31
  }
32
- /** Dual-dialect durable `WorkflowRunStore`. See the file header for the dialect-delta ledger. */
32
+ /** Dual-dialect durable `WorkflowRunStore`. See the file header for the dialect-delta ledger.
33
+ * `onWarn` (optional, same shape as the completion-inbox's {@link InboxWarn}) is the C5 trace channel for
34
+ * `update`'s oversize-slim degrade (see there) — omit it and construction/behavior is unchanged (additive). */
33
35
  export class SqlWorkflowRunStore {
34
36
  db;
35
- constructor(db) {
37
+ onWarn;
38
+ constructor(db, onWarn) {
36
39
  this.db = db;
40
+ this.onWarn = onWarn;
37
41
  }
38
42
  /** Pick the dialect's SQL text. Both statements stay written out at the call site ON PURPOSE. */
39
43
  q(tidb, pg) {
@@ -70,6 +74,10 @@ export class SqlWorkflowRunStore {
70
74
  if (Buffer.byteLength(blob) > MAX_RUN_BLOB_BYTES) {
71
75
  // Oversize degrade (1.108 review fix): slim the payload so the write — critically the TERMINAL one —
72
76
  // still lands (a `false` here would never be retried with a smaller payload; see slimOversizeRun).
77
+ // C5 (2026-07-31): the degrade drops real data (phases/agents/groups → []) — that must leave a trace
78
+ // reaching whoever can act on it, not just a same-shaped `true` return. `onWarn` is optional so a
79
+ // caller that hasn't wired a sink yet keeps building/running unchanged.
80
+ this.onWarn?.("workflow_run_blob_oversize_slimmed", { id, scope, fullBytes: Buffer.byteLength(blob), capBytes: MAX_RUN_BLOB_BYTES });
73
81
  const slim = slimOversizeRun({ ...run, id, scope }, MAX_RUN_BLOB_BYTES);
74
82
  if (slim === null)
75
83
  return false; // even the skeleton is oversize — keep the prior revision
@@ -342,10 +350,11 @@ export class SqlWorkflowNotifyJournalStore {
342
350
  };
343
351
  }
344
352
  }
345
- /** MySQL-protocol (TiDB) bindings — historical class names + ctor shapes preserved. */
353
+ /** MySQL-protocol (TiDB) bindings — historical class names preserved; `onWarn` is an ADDITIVE optional 2nd
354
+ * ctor arg (existing 1-arg call sites are unaffected — see {@link SqlWorkflowRunStore}'s C5 trace channel). */
346
355
  export class TiDBWorkflowRunStore extends SqlWorkflowRunStore {
347
- constructor(pool) {
348
- super(mysqlDriver(pool));
356
+ constructor(pool, onWarn) {
357
+ super(mysqlDriver(pool), onWarn);
349
358
  }
350
359
  }
351
360
  export class TiDBWorkflowCompletionInbox extends SqlWorkflowCompletionInbox {
@@ -358,10 +367,11 @@ export class TiDBWorkflowNotifyJournalStore extends SqlWorkflowNotifyJournalStor
358
367
  super(mysqlDriver(pool));
359
368
  }
360
369
  }
361
- /** PostgreSQL bindings — historical class names + ctor shapes preserved. */
370
+ /** PostgreSQL bindings — historical class names preserved; `onWarn` is an ADDITIVE optional 2nd ctor arg
371
+ * (existing 1-arg call sites are unaffected — see {@link SqlWorkflowRunStore}'s C5 trace channel). */
362
372
  export class PgWorkflowRunStore extends SqlWorkflowRunStore {
363
- constructor(pool) {
364
- super(pgDriver(pool));
373
+ constructor(pool, onWarn) {
374
+ super(pgDriver(pool), onWarn);
365
375
  }
366
376
  }
367
377
  export class PgWorkflowCompletionInbox extends SqlWorkflowCompletionInbox {
@@ -310,9 +310,12 @@ export async function importSession(bundle, getBlob, dstBackend, importingPrinci
310
310
  // entirely (the snapshot/policy/anchor replay below is idempotent and still runs to heal anything missing). A
311
311
  // destination without the replace seam can't accept a session at all → throw.
312
312
  // 🔴 同上(`session-sync-content.ts` 顶注):`identical` 只说明 id 集合相等,不说明内容相同。这条路上
313
- // `bundle.entries` 与目的端日志都在手上 ⇒ 直接比内容摘要;不符就照常改写(不抛错、不 409)
314
- const dstEntriesForContent = await ownerAware(dstBackend).exportEntries?.(sessionId).catch(() => null) ?? null;
315
- const contentEqual = rel.relation === "identical" && identicalIdsAlsoIdenticalContent(bundle.entries, dstEntriesForContent);
313
+ // `bundle.entries` 与目的端日志都在手上 ⇒ 直接比内容摘要;不符就照常改写(不抛错、不 409)。复用 §7 已经
314
+ // 读到的 `dstEntries`(同一个 dstBackend/sessionId)——这两次读之间 dst 未被任何写触碰(overwrite-dst 擦除
315
+ // 只在 relation fork/stale 时才跑,identical 分支不可能落进那条腿),不必也不该对同一行重新 exportEntries
316
+ // 一次(旧实现还用 `.catch(() => null)` 把这次读的故障裸吞成"目的端为空",见下方 identicalIdsAlsoIdenticalContent
317
+ // 对 null 的处置——一次真实的店读故障会被悄悄当成"内容不等"而不是 fail-loud)。
318
+ const contentEqual = rel.relation === "identical" && identicalIdsAlsoIdenticalContent(bundle.entries, dstEntries);
316
319
  if (rel.relation !== "identical" || !contentEqual) {
317
320
  const session = ownerAware(dstBackend);
318
321
  const replaceEntries = session.replaceEntries?.bind(session);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "3.21.0",
3
+ "version": "3.22.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",