@theoremjs/agents 0.3.4-next.401.gec4c582 → 0.3.4-next.405.g57fd3a0

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.
@@ -682,7 +682,7 @@ export const LABEL_NOTES = {
682
682
  'stop.cancelled': 'Status on a reply or message the person stopped.',
683
683
  'stop.interrupted': 'Status on a Live reply the person spoke over.',
684
684
  'stop.length': 'Status on a reply the model ended at its output limit.',
685
- 'stop.filtered': "Status on a reply the provider's content filter ended. A reply Theorem's own guardrails stopped shows its error instead.",
685
+ 'stop.filtered': "Status on a reply the provider's content filter ended. A reply Theorem's own guardrails stopped shows its error or refusal instead.",
686
686
  'stop.provider_error': 'Status on a reply the provider ended with an error and no error message.',
687
687
  'stop.stream_incomplete': 'Status on a reply whose stream ended before the model finished.',
688
688
  'stop.step_limit': 'Status on a turn that made its last allowed model call and got no answer.',
@@ -7,7 +7,7 @@ export declare const WORDED_STOP_KINDS: readonly ["cancelled", "interrupted", "l
7
7
  export type WordedStopKind = (typeof WORDED_STOP_KINDS)[number];
8
8
  /**
9
9
  * Why a turn ended short, in the person's words: its `stop.<kind>` label, the profile's own when it
10
- * sets one. `undefined` when the turn ended whole, or when an error in `blocks` (the turn's
11
- * transcript blocks) already says why.
10
+ * sets one. `undefined` when the turn ended whole, when Theorem's own guardrail stopped it, or when
11
+ * an error in `blocks` (the turn's transcript blocks) already says why.
12
12
  */
13
13
  export declare function stopText(stop: TurnStop | undefined, blocks: readonly TranscriptBlock[], labels?: LabelOverrides): string | undefined;
@@ -1,4 +1,5 @@
1
1
  import { labelText } from '../guardrails/labels.js';
2
+ import { isGuardrailStop } from '../kernel/stop.js';
2
3
  /** The stops that end a reply short of a whole answer. Each is worded by its `stop.<kind>` label. */
3
4
  export const WORDED_STOP_KINDS = [
4
5
  'cancelled',
@@ -15,11 +16,11 @@ function isWorded(kind) {
15
16
  }
16
17
  /**
17
18
  * Why a turn ended short, in the person's words: its `stop.<kind>` label, the profile's own when it
18
- * sets one. `undefined` when the turn ended whole, or when an error in `blocks` (the turn's
19
- * transcript blocks) already says why.
19
+ * sets one. `undefined` when the turn ended whole, when Theorem's own guardrail stopped it, or when
20
+ * an error in `blocks` (the turn's transcript blocks) already says why.
20
21
  */
21
22
  export function stopText(stop, blocks, labels) {
22
- if (!stop || !isWorded(stop.kind))
23
+ if (!stop || !isWorded(stop.kind) || isGuardrailStop(stop))
23
24
  return undefined;
24
25
  if (blocks.some((block) => block.kind === 'error'))
25
26
  return undefined;
@@ -10,6 +10,8 @@ export declare const CONTINUE_INSTRUCTION_TYPES: readonly ProfileType[];
10
10
  export declare const DEFAULT_ALLOW_CONTINUE: readonly ContinueStopKind[];
11
11
  /** Hosts wait briefly, then continue once on their own. */
12
12
  export declare const DEFAULT_AUTO_CONTINUE: readonly ContinueStopKind[];
13
+ /** Whether Theorem's own guardrail ended the turn, so its error or refusal already says why. */
14
+ export declare function isGuardrailStop(stop: TurnStop): boolean;
13
15
  /** Pause before an auto-continue, the host's or the turn's own, so a flaky tunnel can settle. */
14
16
  export declare const AUTO_CONTINUE_DELAY_MS = 1500;
15
17
  /** Which stops a profile offers Continue for, and which the host continues on its own. */
@@ -8,6 +8,17 @@ export const CONTINUE_INSTRUCTION_TYPES = ['text'];
8
8
  export const DEFAULT_ALLOW_CONTINUE = CONTINUE_STOP_KINDS;
9
9
  /** Hosts wait briefly, then continue once on their own. */
10
10
  export const DEFAULT_AUTO_CONTINUE = ['length', 'stream_incomplete'];
11
+ /** The `native` of a `filtered` stop that Theorem's own guardrail made, not the provider's filter. */
12
+ const GUARDRAIL_STOP_NATIVES = new Set([
13
+ 'egress',
14
+ 'canary',
15
+ 'prompt_echo',
16
+ 'provider_tool_leak',
17
+ ]);
18
+ /** Whether Theorem's own guardrail ended the turn, so its error or refusal already says why. */
19
+ export function isGuardrailStop(stop) {
20
+ return stop.kind === 'filtered' && GUARDRAIL_STOP_NATIVES.has(stop.native ?? '');
21
+ }
11
22
  /** Pause before an auto-continue, the host's or the turn's own, so a flaky tunnel can settle. */
12
23
  export const AUTO_CONTINUE_DELAY_MS = 1_500;
13
24
  const CONTINUE_KIND_SET = new Set(CONTINUE_STOP_KINDS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/agents",
3
- "version": "0.3.4-next.401.gec4c582",
3
+ "version": "0.3.4-next.405.g57fd3a0",
4
4
  "description": "A flat TypeScript agent kernel for typed profiles, deterministic turn execution, registered tools, provider adapters, guardrails, and host-injected traces.",
5
5
  "keywords": [
6
6
  "agent",