@theoremjs/agents 0.3.4-next.855.gc82d4ec → 0.3.4-next.869.gb64db05

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/esm/src/guardrails/detectors.d.ts +91 -21
  2. package/esm/src/guardrails/host-patterns.d.ts +15 -2
  3. package/esm/src/guardrails/labels.d.ts +11 -3
  4. package/esm/src/guardrails/labels.js +42 -23
  5. package/esm/src/guardrails/quota.d.ts +9 -3
  6. package/esm/src/guardrails/quota.js +9 -3
  7. package/esm/src/guardrails/theorem-error.d.ts +5 -1
  8. package/esm/src/guardrails/theorem-error.js +8 -4
  9. package/esm/src/guardrails/types.d.ts +66 -18
  10. package/esm/src/guardrails/types.js +22 -3
  11. package/esm/src/kernel/api-catalog.d.ts +26 -75
  12. package/esm/src/kernel/api-catalog.js +37 -119
  13. package/esm/src/kernel/checkpoint.d.ts +5 -1
  14. package/esm/src/kernel/default-scope.d.ts +52 -10
  15. package/esm/src/kernel/default-scope.js +52 -10
  16. package/esm/src/kernel/engine/runner/gates.js +66 -22
  17. package/esm/src/kernel/engine/runner/state.d.ts +5 -2
  18. package/esm/src/kernel/engine/runner/steps.js +15 -15
  19. package/esm/src/kernel/engine/runner/stream.d.ts +5 -0
  20. package/esm/src/kernel/engine/runner/stream.js +12 -1
  21. package/esm/src/kernel/field-docs.d.ts +13 -0
  22. package/esm/src/kernel/field-docs.js +613 -0
  23. package/esm/src/kernel/protocols/binding.d.ts +56 -0
  24. package/esm/src/kernel/protocols/limits.d.ts +9 -0
  25. package/esm/src/kernel/protocols/provider.d.ts +5 -1
  26. package/esm/src/kernel/protocols/provider.js +5 -1
  27. package/esm/src/kernel/registry/profiles.d.ts +154 -5
  28. package/esm/src/kernel/schema.d.ts +5 -7
  29. package/esm/src/kernel/schema.js +511 -470
  30. package/esm/src/kernel/stop.d.ts +41 -17
  31. package/esm/src/kernel/stop.js +9 -1
  32. package/esm/src/kernel/tools/background.d.ts +4 -0
  33. package/esm/src/kernel/tools/types.d.ts +331 -43
  34. package/esm/src/kernel/turn-events.d.ts +4 -3
  35. package/esm/src/kernel/types.d.ts +482 -89
  36. package/esm/src/observability/destinations.d.ts +5 -1
  37. package/esm/src/observability/destinations.js +5 -1
  38. package/esm/src/observability/trace-catalog.js +62 -102
  39. package/esm/src/observability/types.d.ts +93 -19
  40. package/esm/src/providers/shared/carried-tool-files.js +9 -8
  41. package/package.json +1 -1
@@ -17,26 +17,39 @@ export declare const AUTO_CONTINUE_DELAY_MS = 1500;
17
17
  /** Which stops a profile offers Continue for, and which the host continues on its own. */
18
18
  export interface ProfileTurnResumptionSpec {
19
19
  /**
20
- * The host's UI policy for offering Continue: the kernel does not refuse a `continueFrom`
21
- * outside it, since a continue is one more turn the host could send as plain text anyway.
22
- * Omit → length / stream_incomplete / provider_error; `[]` = none.
20
+ * Which early stops the host offers the user a Continue for; the kernel doesn't refuse a continue
21
+ * after other stops.
22
+ *
23
+ * @remarks The host's UI policy for offering Continue: the kernel does not refuse a
24
+ * `continueFrom` outside it, since a continue is one more turn the host could send as plain text
25
+ * anyway. Omit → length / stream_incomplete / provider_error; `[]` = none.
23
26
  */
24
27
  allowContinue?: ContinueStopKind[];
25
28
  /**
26
- * Omit → length / stream_incomplete; `[]` = none. Apart from `allowContinue`: a stop can be
27
- * continued without Continue being offered for it. The host sends the `continueFrom` turn
28
- * with `continuation`. A text turn also sends a failed model call (`provider_error`,
29
- * `stream_incomplete`) again itself when this list is set and names that stop, and the
30
- * call gave no reply and no tool call: the turn keeps its history, its step count and
31
- * what it has read. A failure the same call would meet again (the provider refused the
32
- * request) is not sent again, except once without its files when it carried any: accepted
33
- * that way, the turn goes on and `done.mediaRefused` names them. Omitted, a turn sends
34
- * nothing again.
29
+ * Which early stops are continued without asking, whether or not allowContinue offers a Continue
30
+ * for them. When set, a text turn sends a listed failed model call that gave no reply again
31
+ * itself; the host continues the rest. Naming length also repairs a call the output limit cut
32
+ * off: the model gets back what it wrote, or that it wrote nothing, and is asked again to fit.
33
+ *
34
+ * @remarks Omit → length / stream_incomplete; `[]` = none. Apart from `allowContinue`: a stop can
35
+ * be continued without Continue being offered for it. The host sends the `continueFrom` turn with
36
+ * `continuation`. A text turn also sends a failed model call (`provider_error`,
37
+ * `stream_incomplete`) again itself when this list is set and names that stop, and the call gave
38
+ * no reply and no tool call: the turn keeps its history, its step count and what it has read. A
39
+ * failure the same call would meet again (the provider refused the request) is not sent again,
40
+ * except once without its files when it carried any: accepted that way, the turn goes on and
41
+ * `done.mediaRefused` names them. Named here, `length` also repairs a call the output limit cut
42
+ * off: the model gets back what it wrote, or that it wrote nothing, and is asked again to fit.
43
+ * Omitted, a turn sends nothing again.
35
44
  */
36
45
  autoContinue?: ContinueStopKind[];
37
46
  /**
38
- * Compared against `TurnRequest.continuation`; omit → no count cap. Also how many model
39
- * calls one text turn sends again itself; omit → one.
47
+ * How many times one reply may be continued; once set, each continue must say which one it is.
48
+ * Also how many model calls one text turn sends again itself, failed calls and cut-off repairs
49
+ * together (one when unset).
50
+ *
51
+ * @remarks Compared against `TurnRequest.continuation`; omit → no count cap. Also how many model
52
+ * calls one text turn sends again itself, failed calls and cut-off repairs together; omit → one.
40
53
  */
41
54
  maxContinues?: number;
42
55
  }
@@ -47,12 +60,20 @@ export declare function isContinueStopKind(kind: string): kind is ContinueStopKi
47
60
  * interfaces always project `canStop: true` because `TurnRequest.signal` is always wired.
48
61
  */
49
62
  export interface ProfileTurnBehaviourSpec {
63
+ /** Continuing a reply that stopped early; live uses sessionResumption instead. */
50
64
  resumption?: ProfileTurnResumptionSpec;
51
- /** Default true on text / live. Gates injects only; stage events still emit. */
65
+ /**
66
+ * Lets your onStage hook add messages to a running turn. Text profiles also let the user steer.
67
+ *
68
+ * @remarks Default true on text / live. Gates injects only; stage events still emit.
69
+ */
52
70
  allowSteering?: boolean;
53
71
  /**
54
- * Text only. What the last model call under `maxSteps` may do. Omit = `'stop'`: it may call
55
- * tools, and if it does the turn stops as `step_limit`. `'answer'` sends it without tools.
72
+ * What happens when a turn reaches maxSteps while the model still wants tools: the turn stops
73
+ * with no answer, or the last call is made without tools so it answers.
74
+ *
75
+ * @remarks Text only. What the last model call under `maxSteps` may do. Omit = `'stop'`: it may
76
+ * call tools, and if it does the turn stops as `step_limit`. `'answer'` sends it without tools.
56
77
  */
57
78
  atStepLimit?: StepLimitMode;
58
79
  }
@@ -62,6 +83,7 @@ export interface ProfileTurnBehaviourSpec {
62
83
  * no mid-turn inject to steer.
63
84
  */
64
85
  export interface MediaTurnBehaviourSpec {
86
+ /** Continuing a reply that stopped early; live uses sessionResumption instead. */
65
87
  resumption?: ProfileTurnResumptionSpec;
66
88
  }
67
89
  /**
@@ -92,6 +114,8 @@ export declare function profileTurnResumption(profile: {
92
114
  type: string;
93
115
  turnBehaviour?: ProfileTurnBehaviourSpec;
94
116
  }): ProfileTurnResumptionSpec | undefined;
117
+ /** How many model calls a turn sends again when the output limit cuts one off: `maxContinues` (one when unset) while `autoContinue` names `length`, else none. */
118
+ export declare function cutOffRepairs(profile: Parameters<typeof profileTurnResumption>[0]): number;
95
119
  /** Text-only, for the interface `allowSteering` projection; `profileAllowsInject` adds live. */
96
120
  export declare function profileAllowsSteering(profile: {
97
121
  type: string;
@@ -67,6 +67,13 @@ export function profileTurnResumption(profile) {
67
67
  return undefined;
68
68
  return profile.turnBehaviour?.resumption;
69
69
  }
70
+ /** How many model calls a turn sends again when the output limit cuts one off: `maxContinues` (one when unset) while `autoContinue` names `length`, else none. */
71
+ export function cutOffRepairs(profile) {
72
+ const policy = profileTurnResumption(profile);
73
+ if (!policy?.autoContinue?.includes('length'))
74
+ return 0;
75
+ return policy.maxContinues ?? 1;
76
+ }
70
77
  /** Text-only, for the interface `allowSteering` projection; `profileAllowsInject` adds live. */
71
78
  export function profileAllowsSteering(profile) {
72
79
  if (profile.type !== 'text')
@@ -97,7 +104,8 @@ function openAiFinishKind(finish, effective, native) {
97
104
  ? { kind: 'provider_error', native }
98
105
  : { kind: 'completed', native };
99
106
  }
100
- if (finish === 'length')
107
+ // probed 2026-11-04: OpenRouter ends a call the output limit cut off with `tool_calls`; only the upstream's own reason says `length`.
108
+ if (finish === 'length' || effective === 'length')
101
109
  return { kind: 'length', native };
102
110
  if (finish === 'tool_calls' || finish === 'tool-calls')
103
111
  return { kind: 'tool', native };
@@ -6,6 +6,10 @@ import { type ToolCallBase } from './events.js';
6
6
  import { type ToolExecutionCoordinator, type ToolOperationReply } from './operation.js';
7
7
  /** When the model gets its reply: at the hand-off, past a time, if it asks, or when the body ends. */
8
8
  export type ToolBackground = 'always' | {
9
+ /**
10
+ * Milliseconds the body runs before the model gets its reply. A body that ends sooner answers
11
+ * in the turn.
12
+ */
9
13
  afterMs: number;
10
14
  } | 'ask' | 'never';
11
15
  /** The call a detached event belongs to. */