@sema-agent/server 7.124.1 → 7.125.1

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 (152) hide show
  1. package/MIGRATION.md +138 -2
  2. package/USAGE.md +46 -8
  3. package/dist/audit.d.ts +27 -5
  4. package/dist/audit.js +42 -8
  5. package/dist/boot/execution-env.d.ts +33 -1
  6. package/dist/boot/execution-env.js +31 -2
  7. package/dist/boot/resolve-spec.js +4 -3
  8. package/dist/boot/session-faces.d.ts +14 -1
  9. package/dist/boot/session-faces.js +6 -5
  10. package/dist/boot/stage-02-web-admin-pull.js +5 -1
  11. package/dist/boot/stage-05-execution-env.js +6 -2
  12. package/dist/boot/stage-09-leader.d.ts +1 -1
  13. package/dist/boot/stage-10-http-server.d.ts +1 -1
  14. package/dist/boot/web-admin.js +130 -140
  15. package/dist/capabilities/center-wiring.d.ts +2 -1
  16. package/dist/capabilities/composite-members.d.ts +1 -0
  17. package/dist/capabilities/composite-members.js +1 -0
  18. package/dist/capability-facts.d.ts +28 -3
  19. package/dist/capability-facts.js +20 -0
  20. package/dist/config-catalog.js +4 -1
  21. package/dist/config-d-migration.js +2 -1
  22. package/dist/config-lkg.d.ts +4 -1
  23. package/dist/config-lkg.js +16 -12
  24. package/dist/config-provider.d.ts +4 -1
  25. package/dist/config-provider.js +1 -0
  26. package/dist/config-types.d.ts +10 -3
  27. package/dist/config.js +44 -14
  28. package/dist/env-facts.d.ts +2 -2
  29. package/dist/env-facts.js +3 -2
  30. package/dist/fleet/fleet-bus.d.ts +24 -12
  31. package/dist/fleet/fleet-bus.js +4 -1
  32. package/dist/fleet/workspace-snapshot-residual.d.ts +10 -0
  33. package/dist/fleet/workspace-snapshot-residual.js +35 -0
  34. package/dist/hooks/hook-runner.d.ts +15 -27
  35. package/dist/hooks/hook-runner.js +19 -59
  36. package/dist/http/active-run-conflict.d.ts +3 -0
  37. package/dist/http/active-run-conflict.js +3 -0
  38. package/dist/http/admission.js +7 -7
  39. package/dist/http/approval-sweeps.js +2 -4
  40. package/dist/http/device-placement.js +1 -0
  41. package/dist/http/dispatch.js +1 -1
  42. package/dist/http/durable-run-leg.d.ts +20 -6
  43. package/dist/http/durable-run-leg.js +4 -4
  44. package/dist/http/idempotency.d.ts +83 -38
  45. package/dist/http/idempotency.js +38 -13
  46. package/dist/http/request-guards.d.ts +18 -0
  47. package/dist/http/request-guards.js +12 -3
  48. package/dist/http/resume-legs.js +7 -1
  49. package/dist/http/route-ctx.d.ts +3 -3
  50. package/dist/http/route-ctx.js +1 -1
  51. package/dist/http/routes/a2a-serve.js +27 -11
  52. package/dist/http/routes/capabilities.js +1 -0
  53. package/dist/http/routes/fleet.js +2 -0
  54. package/dist/http/routes/images.js +2 -2
  55. package/dist/http/routes/leader.d.ts +4 -0
  56. package/dist/http/routes/leader.js +13 -3
  57. package/dist/http/routes/observability.js +2 -0
  58. package/dist/http/routes/runs.d.ts +6 -2
  59. package/dist/http/routes/runs.js +71 -101
  60. package/dist/http/routes/session-sync.d.ts +3 -0
  61. package/dist/http/routes/session-sync.js +30 -1
  62. package/dist/http/routes/sessions-list.d.ts +11 -0
  63. package/dist/http/routes/sessions-list.js +6 -6
  64. package/dist/http/routes/sessions.d.ts +6 -1
  65. package/dist/http/routes/sessions.js +41 -10
  66. package/dist/http/routes/tasks.js +63 -21
  67. package/dist/http/run-read-face.d.ts +26 -0
  68. package/dist/http/run-read-face.js +67 -0
  69. package/dist/http/server.d.ts +4 -4
  70. package/dist/http/server.js +1 -2
  71. package/dist/http/submit-replay.d.ts +40 -0
  72. package/dist/http/submit-replay.js +22 -0
  73. package/dist/leader/endpoint.d.ts +10 -5
  74. package/dist/leader/endpoint.js +27 -5
  75. package/dist/observability/cost-quota.d.ts +51 -7
  76. package/dist/observability/cost-quota.js +35 -17
  77. package/dist/observability/fail-open.d.ts +1 -1
  78. package/dist/observability/fail-open.js +1 -1
  79. package/dist/observability/run-terminal.d.ts +5 -9
  80. package/dist/observability/run-terminal.js +2 -7
  81. package/dist/plugins/approval-ask-store-sql.js +1 -1
  82. package/dist/plugins/caching-session-store.d.ts +7 -2
  83. package/dist/plugins/caching-session-store.js +6 -0
  84. package/dist/plugins/device-store-sql.js +1 -1
  85. package/dist/plugins/ensure-index.js +22 -0
  86. package/dist/plugins/file-run-store.d.ts +24 -14
  87. package/dist/plugins/file-run-store.js +52 -12
  88. package/dist/plugins/leader-run-store-sql.d.ts +1 -11
  89. package/dist/plugins/leader-run-store-sql.js +1 -5
  90. package/dist/plugins/local-session-store.d.ts +35 -6
  91. package/dist/plugins/local-session-store.js +87 -18
  92. package/dist/plugins/memory-run-store.d.ts +13 -12
  93. package/dist/plugins/memory-run-store.js +25 -0
  94. package/dist/plugins/one-time-migrations.js +1 -1
  95. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  96. package/dist/plugins/pg-cost-quota.js +2 -5
  97. package/dist/plugins/pg-pool.js +3 -0
  98. package/dist/plugins/pg-session-storage.d.ts +11 -1
  99. package/dist/plugins/pg-session-storage.js +44 -8
  100. package/dist/plugins/remote-env-k8s.d.ts +127 -12
  101. package/dist/plugins/remote-env-k8s.js +270 -27
  102. package/dist/plugins/run-store-sql.d.ts +26 -12
  103. package/dist/plugins/run-store-sql.js +50 -25
  104. package/dist/plugins/schema-consistency.d.ts +1 -13
  105. package/dist/plugins/schema-consistency.js +1 -41
  106. package/dist/plugins/schema-indexes.js +1 -0
  107. package/dist/plugins/schema-live-columns.d.ts +20 -0
  108. package/dist/plugins/schema-live-columns.js +42 -0
  109. package/dist/plugins/store-contracts.d.ts +40 -2
  110. package/dist/plugins/tidb-cost-quota.d.ts +1 -1
  111. package/dist/plugins/tidb-cost-quota.js +2 -5
  112. package/dist/plugins/tidb-pool.js +14 -3
  113. package/dist/plugins/tidb-session-store.d.ts +22 -2
  114. package/dist/plugins/tidb-session-store.js +33 -6
  115. package/dist/plugins/write-behind-counter.d.ts +12 -5
  116. package/dist/plugins/write-behind-counter.js +14 -7
  117. package/dist/prompts-domain-validate.js +3 -2
  118. package/dist/rules-consent.d.ts +2 -2
  119. package/dist/rules-consent.js +2 -2
  120. package/dist/run-local.js +31 -23
  121. package/dist/runs.d.ts +9 -0
  122. package/dist/runs.js +8 -0
  123. package/dist/runtime-governance.d.ts +3 -3
  124. package/dist/runtime-governance.js +2 -4
  125. package/dist/security.d.ts +19 -2
  126. package/dist/session-row.d.ts +53 -0
  127. package/dist/session-row.js +47 -0
  128. package/dist/session-sync.d.ts +6 -0
  129. package/dist/session-sync.js +5 -1
  130. package/dist/session-titler.d.ts +9 -5
  131. package/dist/session-titler.js +3 -1
  132. package/dist/spec-fields.js +2 -2
  133. package/dist/task-cwd.d.ts +0 -20
  134. package/dist/task-cwd.js +2 -10
  135. package/dist/tool-approval.d.ts +5 -7
  136. package/dist/trace/redact.d.ts +23 -50
  137. package/dist/trace/redact.js +42 -9
  138. package/dist/trace/self-minted-wire.d.ts +25 -0
  139. package/dist/trace/self-minted-wire.js +9 -0
  140. package/dist/web-admin-client/apply-effective.d.ts +10 -12
  141. package/dist/web-admin-client/apply-effective.js +2 -3
  142. package/dist/web-admin-client/candidate-gate.d.ts +69 -0
  143. package/dist/web-admin-client/candidate-gate.js +27 -0
  144. package/dist/web-admin-client/http-client.d.ts +2 -1
  145. package/dist/web-admin-client/http-client.js +2 -1
  146. package/dist/web-admin-client/pull-state.d.ts +6 -4
  147. package/dist/web-admin-client/read-warnings.d.ts +29 -5
  148. package/dist/web-admin-client/read-warnings.js +24 -4
  149. package/dist/web-admin-client/stage-limits.js +4 -1
  150. package/dist/workspace-space.d.ts +41 -0
  151. package/dist/workspace-space.js +5 -0
  152. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import { LIMITS_HTTP_FLOORS } from "../config.js";
2
2
  import { checkCrossInvariants } from "../config-invariants.js";
3
+ import { COST_QUOTA_WINDOW_SEC_RANGE, costQuotaWindowSecInRange } from "../observability/cost-quota.js";
3
4
  import { BATCH1_LIMIT_KEYS, DEFERRED_LIMIT_KEYS } from "./hot-keys-registry.js";
4
5
  const INFRA_RATE_KEYS = ["toolCallMicroUsd", "sandboxSecMicroUsd", "egressGbMicroUsd"];
5
6
  const okNum = (v) => typeof v === "number" && Number.isFinite(v);
@@ -8,7 +9,9 @@ const positive = (key, v) => okNum(v) && v > 0 ? { ok: true, value: v } : { ok:
8
9
  const VALIDATORS = {
9
10
  rateLimitPerMin: (v) => atLeast("rateLimitPerMin", v, 0),
10
11
  maxPrincipalCostUsd: (v) => atLeast("maxPrincipalCostUsd", v, 0),
11
- costQuotaWindowSec: (v) => positive("costQuotaWindowSec", v),
12
+ costQuotaWindowSec: (v) => okNum(v) && costQuotaWindowSecInRange(v)
13
+ ? { ok: true, value: v }
14
+ : { ok: false, reason: `costQuotaWindowSec must be a finite number in [${COST_QUOTA_WINDOW_SEC_RANGE.min}, ${COST_QUOTA_WINDOW_SEC_RANGE.max}] (seconds)` },
12
15
  maxTaskCostUsd: (v) => atLeast("maxTaskCostUsd", v, 0),
13
16
  maxTaskTokens: (v) => atLeast("maxTaskTokens", v, 0),
14
17
  infraCostRates: (v, baseline) => {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Workspace persistence by **space** (k8s lane) — the closed word set, the defaults, the retention domain and
3
+ * the policy shape (pure leaf: no value imports, so `config.ts`, the capability fact and the adapter in `plugins/` can
4
+ * all import it without a load cycle). The effective policy has ONE reading: the capability fact `workspaceSpace`
5
+ * (`src/capability-facts.ts`).
6
+ *
7
+ * The law (one fact, one seat): a k8s pod's `/workspace` is durable across runs as an object-store "space" owned by the
8
+ * session's OCCUPANT (its incarnation, `session-incarnation.ts`) — `<keyPrefix>/<incarnation>/space/<snapshotId>.tar.gz`
9
+ * plus one small `<keyPrefix>/<incarnation>/space/latest` pointer whose body is the newest snapshotId (the durable-suspend
10
+ * archives of parked runs stay flat under `<keyPrefix>/<sessionId>/` and are never pruned; why each lane has the partition
11
+ * it has: `plugins/remote-env-k8s.ts`, `K8sEnvConfig`). `connect()` restores the pointer's snapshot through the adapter's one
12
+ * tar download (shared with `resumeVM`); `destroy()` snapshots through its one tar upload (shared with `suspendVM`),
13
+ * moves the pointer, then keeps the newest `keep` snapshots inside `space/`. No index table: the bucket is the only record.
14
+ *
15
+ * Facility dependence: without a snapshot store (`s3Snapshot`) there is nothing to persist into — the fact is
16
+ * unavailable and the lane behaves exactly as before (fresh pod, empty `/workspace` every run).
17
+ */
18
+ /** `WORKSPACE_PERSIST` closed set. `space` = the k8s workspace persists per space (the session occupant); `off` = a fresh
19
+ * workspace every run. */
20
+ export declare const WORKSPACE_PERSIST_WORDS: readonly ["space", "off"];
21
+ export type WorkspacePersist = (typeof WORKSPACE_PERSIST_WORDS)[number];
22
+ /**
23
+ * Default `off` — persistence is opt-in. Why: the run-end commit's ordering against the NEXT run rests on an object-store
24
+ * marker the commit itself writes, and that PUT can land after the engine's teardown bound; then the next run restores the
25
+ * previous-but-one snapshot and its own commit later overwrites the late one (the preceding run's changes are lost). That
26
+ * window closes only with a commit fence held in server-side durable state, written before the session's active-run slot
27
+ * is released; until then a deployment turns persistence on knowing the window (USAGE §9.3b).
28
+ */
29
+ export declare const WORKSPACE_PERSIST_DEFAULT: WorkspacePersist;
30
+ /** `WORKSPACE_SNAPSHOT_KEEP` — snapshots kept per space key (closed integer domain; out of domain refuses boot). */
31
+ export declare const WORKSPACE_SNAPSHOT_KEEP_DEFAULT = 3;
32
+ export declare const WORKSPACE_SNAPSHOT_KEEP_RANGE: {
33
+ readonly min: 1;
34
+ readonly max: 50;
35
+ };
36
+ /** The effective space policy — the `workspaceSpace` fact's witness and the value of `GET /v1/capabilities.workspaceSync`. */
37
+ export interface WorkspaceSyncCapability {
38
+ persist: WorkspacePersist;
39
+ keep: number;
40
+ }
41
+ //# sourceMappingURL=workspace-space.d.ts.map
@@ -0,0 +1,5 @@
1
+ export const WORKSPACE_PERSIST_WORDS = ["space", "off"];
2
+ export const WORKSPACE_PERSIST_DEFAULT = "off";
3
+ export const WORKSPACE_SNAPSHOT_KEEP_DEFAULT = 3;
4
+ export const WORKSPACE_SNAPSHOT_KEEP_RANGE = { min: 1, max: 50 };
5
+ //# sourceMappingURL=workspace-space.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "7.124.1",
3
+ "version": "7.125.1",
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",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "@sema-agent/core": "7.48.0",
68
- "@sema-agent/settings-schema": "11.2.0",
68
+ "@sema-agent/settings-schema": "11.3.1",
69
69
  "e2b": "^2.28.0",
70
70
  "libsodium-wrappers": "^0.8.4",
71
71
  "mysql2": "^3.22.4",
@@ -80,7 +80,7 @@
80
80
  "sharp": "^0.35.3"
81
81
  },
82
82
  "devDependencies": {
83
- "@sema-agent/sdk": "15.3.0",
83
+ "@sema-agent/sdk": "20.0.0",
84
84
  "@types/libsodium-wrappers": "^0.7.14",
85
85
  "@types/node": "22.10.2",
86
86
  "@types/pg": "^8.20.0",