@sema-agent/core 7.6.0 → 7.6.2

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 (78) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/agents/agent-transcript-tool.d.ts +2 -2
  3. package/dist/agents/cascade.d.ts +2 -3
  4. package/dist/agents/repair-loop.d.ts +2 -2
  5. package/dist/agents/retain-ledger.d.ts +2 -3
  6. package/dist/agents/send-message-tool.d.ts +2 -2
  7. package/dist/agents/session-util.d.ts +2 -2
  8. package/dist/agents/subagent.d.ts +3 -4
  9. package/dist/agents/teacher.d.ts +2 -2
  10. package/dist/agents/team.d.ts +2 -2
  11. package/dist/agents/verify.d.ts +5 -6
  12. package/dist/core/agent-definition.d.ts +172 -0
  13. package/dist/core/agent-definition.js +1 -0
  14. package/dist/core/checkpoint-store.d.ts +8 -4
  15. package/dist/core/delegation-frames.d.ts +298 -0
  16. package/dist/core/delegation-frames.js +21 -0
  17. package/dist/core/engine-notice.d.ts +555 -0
  18. package/dist/core/engine-notice.js +55 -0
  19. package/dist/core/gate-fold.d.ts +12 -0
  20. package/dist/core/gate-fold.js +158 -0
  21. package/dist/core/gate-lanes.d.ts +93 -0
  22. package/dist/core/gate-lanes.js +626 -0
  23. package/dist/core/hands-band.d.ts +134 -0
  24. package/dist/core/hands-band.js +1 -0
  25. package/dist/core/hooks.d.ts +20 -101
  26. package/dist/core/hooks.js +53 -854
  27. package/dist/core/mcp-failure.d.ts +43 -5
  28. package/dist/core/mcp-failure.js +31 -14
  29. package/dist/core/mcp-server-spec.d.ts +217 -0
  30. package/dist/core/mcp-server-spec.js +1 -0
  31. package/dist/core/model-seat.d.ts +99 -0
  32. package/dist/core/model-seat.js +1 -0
  33. package/dist/core/reminder-mint.d.ts +10 -0
  34. package/dist/core/reminder-mint.js +3 -0
  35. package/dist/core/runner/contracts.d.ts +382 -6
  36. package/dist/core/runner/gate-exit.d.ts +177 -9
  37. package/dist/core/runner/gate-exit.js +70 -1
  38. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -7
  39. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -7
  40. package/dist/core/runner/prepare-run-refs.d.ts +12 -0
  41. package/dist/core/runner/prepare-run-refs.js +5 -0
  42. package/dist/core/runner/prepare-task.d.ts +2 -2
  43. package/dist/core/runner/runtask.d.ts +4 -71
  44. package/dist/core/runner/runtask.js +18 -6
  45. package/dist/core/runner-deps.d.ts +1416 -0
  46. package/dist/core/runner-deps.js +1 -0
  47. package/dist/core/runtime-caps.d.ts +164 -0
  48. package/dist/core/runtime-caps.js +1 -0
  49. package/dist/core/task-event.d.ts +910 -0
  50. package/dist/core/task-event.js +1 -0
  51. package/dist/core/task-limits.d.ts +110 -0
  52. package/dist/core/task-limits.js +1 -0
  53. package/dist/core/task-result.d.ts +809 -0
  54. package/dist/core/task-result.js +1 -0
  55. package/dist/core/task-spec.d.ts +1370 -0
  56. package/dist/core/task-spec.js +1 -0
  57. package/dist/core/task-stream.d.ts +382 -0
  58. package/dist/core/task-stream.js +1 -0
  59. package/dist/core/tool-spec.d.ts +1174 -0
  60. package/dist/core/tool-spec.js +1 -0
  61. package/dist/core/types.d.ts +26 -7691
  62. package/dist/core/types.js +2 -76
  63. package/dist/core/warm-resume.d.ts +2 -2
  64. package/dist/index.d.ts +2 -1
  65. package/dist/index.js +1 -1
  66. package/dist/orchestration/goal.d.ts +2 -2
  67. package/dist/orchestration/run-spec.d.ts +2 -2
  68. package/dist/orchestration/run-workflow-tool.d.ts +3 -3
  69. package/dist/orchestration/workflow.d.ts +4 -4
  70. package/dist/scenarios/scenario-registry.d.ts +3 -3
  71. package/dist/scenarios/teacher-quickstart.d.ts +2 -2
  72. package/dist/server/http.d.ts +2 -2
  73. package/dist/stores/file/fs-atomic.d.ts +88 -12
  74. package/dist/stores/file/fs-atomic.js +184 -55
  75. package/dist/stores/file/index.d.ts +1 -0
  76. package/dist/stores/file/index.js +1 -0
  77. package/package.json +1 -1
  78. package/test/export-surface.snapshot.json +9 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
1
+ /**
2
+ * The task LIMITS: the allowance axes a caller sets on one run (turns, tokens, cost, wall-clock, the
3
+ * tool-call and idle bounds, the per-model overrides). Its own module rather than a section of
4
+ * `task-spec.ts` because it is the one shape a caller edits without touching anything else in the
5
+ * spec. Layer 0 vocabulary; `types.ts` re-exports the name, so no consumer's import changes.
6
+ */
7
+ import type { ModelRef } from "./model-seat.js";
8
+ /**
9
+ * design/164 — the task's complete limit surface (see {@link TaskSpec.limits}).
10
+ *
11
+ * **Window semantics.** `maxTokens` / `maxCostUsd` / `maxWalltimeMs` are PER-SLICE windows, not
12
+ * whole-task totals: a task that opted into {@link TaskSpec.resourceSuspend} suspends when a window is
13
+ * exhausted and its resume gets the NEXT window of the same size. Whole-task ceilings live on
14
+ * `resourceSuspend` (`totalTokens` / `totalBudgetUsd`) and are frozen on the ledger, so a resume can
15
+ * never refresh them.
16
+ *
17
+ * **Two-tier hit semantics.** When a window is exhausted:
18
+ * - no `resourceSuspend` (the default) ⇒ a LOUD TERMINAL: `status:"failed"` with
19
+ * `limits.max_tokens_exceeded` / `limits.max_cost_exceeded` / `limits.max_turns_exceeded` /
20
+ * `limits.max_walltime_exceeded`, salvaged text attached where there is any. This is the
21
+ * "must have a definite outcome by the deadline" shape — express it by NOT opting in.
22
+ * - `resourceSuspend` set and the durable infrastructure present ⇒ a resumable `suspended` checkpoint.
23
+ *
24
+ * **Priority.** Several axes may be armed at once; the first to trip stops the run. When more than one
25
+ * trips at the same turn boundary the attribution order is tokens > cost > turns > walltime.
26
+ */
27
+ export interface TaskLimits {
28
+ /**
29
+ * Cumulative prompt+completion tokens this slice may spend. The PRIMARY budget axis. Unset ⇒ no token
30
+ * ceiling. Must be a finite, non-negative number (a bad value is a fail-loud config error, never folded
31
+ * to a default) — see the two-tier hit semantics on {@link TaskLimits}.
32
+ */
33
+ maxTokens?: number;
34
+ /**
35
+ * Cumulative spend ceiling for this slice, in USD (requires `model.cost` or `RunnerDeps.pricing`).
36
+ * Checked pre-call and at each turn boundary. Unset ⇒ no cost ceiling. Money and tokens are two
37
+ * genuine mental models and both are kept; documentation leads with `maxTokens`.
38
+ *
39
+ * NOTE: the pre-call check is **best-effort** — it estimates the first call's input from the objective
40
+ * length only (it cannot see the assembled system prompt / history / memory), so it may under-estimate
41
+ * and let an oversized first turn run; the turn-boundary gate then catches it after the spend.
42
+ */
43
+ maxCostUsd?: number;
44
+ /** Turn ceiling for this slice. Unset ⇒ no turn ceiling. `0` is the explicit "unbounded" sentinel
45
+ * (kept for callers that write it deliberately); any other non-positive / non-finite value is a
46
+ * fail-loud config error. */
47
+ maxTurns?: number;
48
+ /**
49
+ * Wall-clock ceiling for this slice, in MILLISECONDS. A PER-SLICE ACTIVE clock: it starts at the
50
+ * slice's first turn on the monotonic clock, suspended time does not count, and a resume opens a
51
+ * fresh window (a new process, a new anchor — no cross-process clock is ever compared). Unset ⇒ no
52
+ * wall-clock ceiling, which is the default: time answers "how long did it take", not "how much work
53
+ * is this allowed to be", so it is the axis of last resort.
54
+ */
55
+ maxWalltimeMs?: number;
56
+ /**
57
+ * design/119 #2: per-REQUEST output-token cap (the provider `max_tokens` / `max_completion_tokens`
58
+ * field). NOT a budget — it bounds each model reply, while {@link maxTokens} bounds the whole slice.
59
+ * Unset ⇒ the brain falls back to `model.maxTokens` (both families; the OpenAI lane omits the
60
+ * wire field — provider default — only when `model.maxTokens` is also absent). A reply
61
+ * that hits it stops with `length` and the loop's truncated-output auto-continue takes over.
62
+ * HARD bound on Anthropic budget-thinking models too: a cap too small to host a legal thinking
63
+ * budget (< 2048) skips thinking for the request rather than silently raising the cap.
64
+ */
65
+ maxOutputTokens?: number;
66
+ /**
67
+ * design/164 — the LIMIT-APPROACH notice. While any of `maxTokens`/`maxCostUsd`/`maxTurns` is armed,
68
+ * the engine injects at most two one-shot reminders at turn boundaries: one when the highest axis
69
+ * ratio crosses the first threshold ("start converging"), one when it crosses the second ("deliver
70
+ * now"). Both are advisory prompt frames — they never stop the run, and they never fire on a
71
+ * resource-suspend task (a slice boundary is not a delivery deadline).
72
+ *
73
+ * Default ON whenever an axis is armed; `false` switches it off. `{ at: [first, second] }` overrides
74
+ * the thresholds (each a fraction in `(0, 1]`, first ≤ second).
75
+ */
76
+ approachNotice?: false | {
77
+ at?: [number, number];
78
+ };
79
+ /** Cancel an in-flight stream the moment cumulative cost/tokens cross their window. Defaults to `true`
80
+ * when {@link maxCostUsd} is set (hard control), `false` otherwise. */
81
+ budgetStreamCancel?: boolean;
82
+ /**
83
+ * **Near-budget degradation** (design/21 §5C). When cumulative cost reaches `atCostFraction` of the
84
+ * effective cost window, **switch the active model to the cheaper `to`** for the rest of the task to
85
+ * stretch the remaining budget — accepting lower quality instead of stopping at the ceiling. One-way
86
+ * (never switches back); sets `TaskResult.degraded = { …, reason: "budget" }`. Requires
87
+ * {@link maxCostUsd} (the fraction is of it); ignored otherwise. This is the proactive, Runner-level
88
+ * complement to the reactive brain-level `createDegradingBrain` (rate_limit / breaker-open).
89
+ */
90
+ degrade?: {
91
+ to: ModelRef;
92
+ atCostFraction: number;
93
+ };
94
+ /**
95
+ * RB-458 (ruled 2026-08-03) — the OUTER wall on how long the engine waits for a single brain
96
+ * call, in ms. Default {@link import("../brain/timeout.js").BRAIN_CALL_GUARDRAIL_DEFAULT_MS}
97
+ * (one hour); `false` or `0` switches it off; any other non-positive / non-finite value is a
98
+ * config error (fail-loud, never folded to a default). Overrides `RunnerDeps.brainCallGuardrailMs`.
99
+ *
100
+ * This is a GUARDRAIL, not a budget: it answers "is the system hung", so unlike every axis above it
101
+ * is armed by default, and it does NOT depend on the brain cooperating — on expiry the engine aborts
102
+ * the signal it handed the brain AND stops awaiting the call, ending the task fail-loud with
103
+ * `errorCode` `"brain.call_guardrail_timeout"`. That is what makes it the backstop for a custom
104
+ * `Brain` that ignores `options.signal` or never settles.
105
+ *
106
+ * It is deliberately COARSE. A task that also sets {@link maxWalltimeMs} runs both clocks in parallel
107
+ * and the tighter one expires first — the guardrail only shows up when everything finer failed to bind.
108
+ */
109
+ brainCallGuardrailMs?: import("../brain/timeout.js").BrainCallGuardrailKnob;
110
+ }
@@ -0,0 +1 @@
1
+ export {};