@theoremjs/agents 0.3.4-next.528.g44c76f9 → 0.3.4-next.540.g67b727f

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 (54) hide show
  1. package/README.md +4 -7
  2. package/esm/mod.d.ts +0 -1
  3. package/esm/mod.js +0 -1
  4. package/esm/src/cli/commands/fuzz-canary.js +7 -0
  5. package/esm/src/guardrails/corpus/fuzz-inbound.js +11 -2
  6. package/esm/src/guardrails/detectors.js +12 -13
  7. package/esm/src/guardrails/error.d.ts +1 -1
  8. package/esm/src/guardrails/error.js +3 -1
  9. package/esm/src/guardrails/labels.d.ts +2 -2
  10. package/esm/src/guardrails/labels.js +8 -0
  11. package/esm/src/guardrails/network.d.ts +2 -0
  12. package/esm/src/guardrails/network.js +1 -0
  13. package/esm/src/guardrails/theorem-error.d.ts +1 -1
  14. package/esm/src/guardrails/theorem-error.js +4 -0
  15. package/esm/src/host/reply.js +2 -0
  16. package/esm/src/kernel/engine/decision.d.ts +2 -0
  17. package/esm/src/kernel/engine/decision.js +4 -0
  18. package/esm/src/kernel/engine/session/mod.d.ts +1 -1
  19. package/esm/src/kernel/engine/session/mod.js +5 -8
  20. package/esm/src/kernel/engine/tree.d.ts +2 -1
  21. package/esm/src/kernel/engine/tree.js +17 -6
  22. package/esm/src/kernel/protocols/protocol.d.ts +2 -1
  23. package/esm/src/kernel/protocols/runtime.js +8 -1
  24. package/esm/src/kernel/schema.js +1 -2
  25. package/esm/src/kernel/tools/coordinate.js +13 -13
  26. package/esm/src/kernel/tools/events.d.ts +11 -1
  27. package/esm/src/kernel/tools/events.js +22 -2
  28. package/esm/src/kernel/tools/execute.js +5 -3
  29. package/esm/src/kernel/tools/operation.d.ts +5 -1
  30. package/esm/src/kernel/tools/operation.js +8 -0
  31. package/esm/src/kernel/tools/remote.js +15 -6
  32. package/esm/src/observability/spans.d.ts +2 -1
  33. package/esm/src/observability/spans.js +1 -1
  34. package/esm/src/observability/trace-catalog.js +8 -0
  35. package/esm/src/providers/google/interactions/framing.js +1 -1
  36. package/esm/src/providers/google/limits.d.ts +4 -0
  37. package/esm/src/providers/google/limits.js +4 -0
  38. package/esm/src/providers/google/thinking.js +1 -1
  39. package/esm/src/providers/google/urls.d.ts +1 -3
  40. package/esm/src/providers/google/urls.js +1 -3
  41. package/esm/src/providers/open-ai/protocol.js +5 -0
  42. package/package.json +1 -10
  43. package/esm/src/presets/google/speech-voices.d.ts +0 -9
  44. package/esm/src/presets/google/speech-voices.js +0 -38
  45. package/esm/src/presets/google-limits.d.ts +0 -13
  46. package/esm/src/presets/google-limits.js +0 -18
  47. package/esm/src/presets/google.d.ts +0 -119
  48. package/esm/src/presets/google.js +0 -197
  49. package/esm/src/presets/local.d.ts +0 -26
  50. package/esm/src/presets/local.js +0 -30
  51. package/esm/src/presets/mod.d.ts +0 -11
  52. package/esm/src/presets/mod.js +0 -9
  53. package/esm/src/presets/openrouter.d.ts +0 -26
  54. package/esm/src/presets/openrouter.js +0 -31
@@ -1,197 +0,0 @@
1
- /**
2
- * Google / Gemini convenience preset.
3
- *
4
- * @module
5
- */
6
- import "../../_dnt.polyfills.js";
7
- import { registerTools } from '../kernel/default-scope.js';
8
- import { GOOGLE_SPEECH_VOICES } from './google/speech-voices.js';
9
- import { GOOGLE_SPEECH_FORMATS, GOOGLE_THINKING_LEVELS, googleEfforts, } from './google-limits.js';
10
- /** The image MIME types a Gemini profile can take as input. */
11
- const GOOGLE_IMAGE_INPUT_MIMES = [
12
- 'image/png',
13
- 'image/jpeg',
14
- 'image/webp',
15
- 'image/heic',
16
- 'image/heif',
17
- ];
18
- /** The audio MIME types a Gemini profile can take as voice input. */
19
- const GOOGLE_VOICE_INPUT_MIMES = ['audio/webm', 'audio/wav', 'audio/mpeg', 'audio/mp4'];
20
- /**
21
- * TTS models that reject any history with a model turn, so compaction's summary fails them
22
- * (live, 29/09/2026).
23
- */
24
- const GOOGLE_SINGLE_TURN_API_IDS = [
25
- 'gemini-2.5-flash-preview-tts',
26
- 'gemini-3.1-flash-tts-preview',
27
- 'gemini-3.8-flash-tts',
28
- 'gemini-3.8-flash-lite-tts',
29
- ];
30
- /**
31
- * Models that reject any thinking setting, `summaries: false` included: leave
32
- * `efforts` and `summaries` unset (live, 30/09/2026).
33
- */
34
- const GOOGLE_NO_THINKING_API_IDS = [
35
- 'gemini-2.5-flash-image',
36
- 'antigravity-preview-05-2026',
37
- 'antigravity-preview-09-2026',
38
- 'antigravity-preview-latest',
39
- ];
40
- /**
41
- * Models that refuse a thinking level and take `summaries`: leave `efforts` unset
42
- * (live, 01/10/2026: Live closes 1007 "Thinking level is not supported for this model";
43
- * 04/10/2026: setup takes `includeThoughts` either way).
44
- */
45
- const GOOGLE_NO_EFFORT_API_IDS = ['gemini-3.8-live'];
46
- /**
47
- * Models that refuse a session without a thinking level: pin `efforts`
48
- * (live, 01/10/2026: Live closes 1007 "Thinking level must be specified for this model").
49
- */
50
- const GOOGLE_THINKING_REQUIRED_API_IDS = ['gemini-3.8-live-extended-thinking'];
51
- const grounding = (googleSearch, googleMaps) => ({
52
- googleSearch,
53
- googleMaps,
54
- });
55
- /**
56
- * Models with a non-zero free-tier quota, and the grounding each allows (AI Studio, Sep 2026).
57
- * No model keeps free Maps quota: 3.5 Flash-Lite turns with Maps are refused as over quota
58
- * (live, 13/10/2026).
59
- * A builtin with no quota is refused as if over quota: on Live, a close 1011 "You exceeded your
60
- * current quota" at setup, whatever the key's usage (live, 01/10/2026).
61
- */
62
- const GOOGLE_FREE_TIER_GROUNDING = {
63
- 'gemini-2.5-flash-lite': grounding(true, false),
64
- 'gemini-2.5-flash': grounding(true, false),
65
- 'gemini-2.5-flash-preview-tts': grounding(true, false),
66
- 'gemini-3-flash-preview': grounding(false, false),
67
- 'gemini-3.1-flash-lite': grounding(false, false),
68
- 'gemini-3.1-flash-lite-image': grounding(false, false),
69
- 'gemini-3.1-flash-tts-preview': grounding(false, false),
70
- 'gemini-3.5-flash-lite': grounding(false, false),
71
- 'gemini-3.5-flash': grounding(false, false),
72
- 'gemini-3.6-flash': grounding(false, false),
73
- 'gemini-3.7-flash': grounding(false, false),
74
- 'gemini-3.8-flash-tts': grounding(false, false),
75
- 'gemini-3.8-flash-lite-tts': grounding(false, false),
76
- 'gemma-4-26b-a4b-it': grounding(false, false),
77
- 'gemma-4-31b-it': grounding(false, false),
78
- 'gemini-3.1-flash-live-preview': grounding(false, false),
79
- 'gemini-3.8-live': grounding(false, false),
80
- 'gemini-3.8-live-extended-thinking': grounding(false, false),
81
- };
82
- /** Grounding builtins the free tier allows on `apiId`; none for a model with no free quota. */
83
- function googleFreeTierBuiltins(apiId) {
84
- const allowed = GOOGLE_FREE_TIER_GROUNDING[apiId.trim()];
85
- if (!allowed)
86
- return [];
87
- return ['googleSearch', 'googleMaps'].filter((id) => allowed[id]);
88
- }
89
- function pinsEffort(binding) {
90
- return Object.keys(binding.efforts ?? {}).length > 0;
91
- }
92
- /**
93
- * The first setting Google would refuse on this binding, or `undefined`. With `freeTier`, it
94
- * also holds the binding to the free-tier table: a listed model, and only the grounding its
95
- * quota allows.
96
- */
97
- function googleBindingViolation(binding, options = {}) {
98
- const apiId = binding.apiId.trim();
99
- const noThinking = GOOGLE_NO_THINKING_API_IDS;
100
- const noEffort = GOOGLE_NO_EFFORT_API_IDS;
101
- const thinkingRequired = GOOGLE_THINKING_REQUIRED_API_IDS;
102
- if ((noThinking.includes(apiId) || noEffort.includes(apiId)) && pinsEffort(binding)) {
103
- return {
104
- field: 'efforts',
105
- message: `${apiId} takes no thinking level; leave efforts unset.`,
106
- };
107
- }
108
- if (noThinking.includes(apiId) && binding.summaries !== undefined) {
109
- return {
110
- field: 'summaries',
111
- message: `${apiId} takes no thinking setting; leave summaries unset.`,
112
- };
113
- }
114
- if (thinkingRequired.includes(apiId) && !pinsEffort(binding)) {
115
- return { field: 'efforts', message: `${apiId} needs a thinking level; pin efforts.` };
116
- }
117
- if (!options.freeTier)
118
- return undefined;
119
- if (!GOOGLE_FREE_TIER_GROUNDING[apiId]) {
120
- return { field: 'apiId', message: `${apiId} has no free-tier quota.` };
121
- }
122
- const allowed = googleFreeTierBuiltins(apiId);
123
- for (const builtin of binding.builtInTools ?? []) {
124
- if ((builtin === 'googleSearch' || builtin === 'googleMaps') && !allowed.includes(builtin)) {
125
- return { field: 'builtInTools', message: `${apiId} has no free-tier quota for ${builtin}.` };
126
- }
127
- }
128
- return undefined;
129
- }
130
- /** The aspect ratios a Gemini image model can return. */
131
- const GOOGLE_IMAGE_ASPECT_RATIOS = [
132
- '1:1',
133
- '3:2',
134
- '2:3',
135
- '3:4',
136
- '4:3',
137
- '4:5',
138
- '5:4',
139
- '9:16',
140
- '16:9',
141
- '21:9',
142
- ];
143
- /** The resolutions a Gemini image model can return. */
144
- const GOOGLE_IMAGE_RESOLUTIONS = ['1K', '2K', '4K'];
145
- /** What a Gemini image model can be asked to return. */
146
- const GOOGLE_IMAGE_OUTPUT_MIMES = ['image/png', 'image/jpeg'];
147
- /** The tools Gemini runs itself, as `builtin` tool definitions. */
148
- const GOOGLE_BUILTIN_TOOLS = [
149
- {
150
- type: 'builtin',
151
- name: 'googleSearch',
152
- description: 'Google Search grounding',
153
- category: 'grounding',
154
- access: 'read-only',
155
- paths: ['*'],
156
- loadTier: 'T0',
157
- permission: 'auto',
158
- },
159
- {
160
- type: 'builtin',
161
- name: 'googleMaps',
162
- description: 'Google Maps grounding',
163
- category: 'grounding',
164
- access: 'read-only',
165
- paths: ['*'],
166
- loadTier: 'T0',
167
- permission: 'auto',
168
- // why: Google refuses a request that carries Maps with Search or URL context.
169
- conflictsWith: ['googleSearch', 'urlContext'],
170
- },
171
- {
172
- type: 'builtin',
173
- name: 'urlContext',
174
- description: 'Fetch URL context',
175
- category: 'grounding',
176
- access: 'read-only',
177
- paths: ['*'],
178
- loadTier: 'T0',
179
- permission: 'auto',
180
- },
181
- {
182
- type: 'builtin',
183
- name: 'codeExecution',
184
- description: 'Google code execution',
185
- category: 'grounding',
186
- access: 'read-only',
187
- paths: ['*'],
188
- loadTier: 'T0',
189
- permission: 'auto',
190
- },
191
- ];
192
- /** Registers into the default scope; a scope of its own takes `GOOGLE_BUILTIN_TOOLS`. */
193
- function registerGooglePreset() {
194
- registerTools(GOOGLE_BUILTIN_TOOLS);
195
- }
196
- export { GEMINI_MODELS_URL } from '../providers/google/urls.js';
197
- export { GOOGLE_BUILTIN_TOOLS, GOOGLE_FREE_TIER_GROUNDING, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_NO_EFFORT_API_IDS, GOOGLE_NO_THINKING_API_IDS, GOOGLE_SINGLE_TURN_API_IDS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, GOOGLE_THINKING_LEVELS, GOOGLE_THINKING_REQUIRED_API_IDS, GOOGLE_VOICE_INPUT_MIMES, googleBindingViolation, googleEfforts, googleFreeTierBuiltins, registerGooglePreset, };
@@ -1,26 +0,0 @@
1
- /**
2
- * Local model convenience preset.
3
- *
4
- * @module
5
- */
6
- import type { ModelBinding } from '../kernel/types.js';
7
- /**
8
- * Whether an Ollama model thinks, read from the server's `POST /api/show` reply for it:
9
- * `capabilities` lists `thinking` (Ollama 0.34.0, 04/10/2026). The host fetches the reply.
10
- */
11
- declare function ollamaModelThinks(show: unknown): boolean;
12
- /** A local binding field its model would refuse, and what is wrong with it. */
13
- interface LocalBindingViolation {
14
- field: 'efforts';
15
- message: string;
16
- }
17
- /**
18
- * The first setting a local server would refuse on this binding, or `undefined`. A thinking
19
- * level goes to the server as `reasoning_effort`; Ollama answers HTTP 400 "does not support
20
- * thinking" for a model that does not think (04/10/2026).
21
- */
22
- declare function localBindingViolation(binding: Pick<ModelBinding, 'apiId' | 'efforts'>, model: {
23
- thinks: boolean;
24
- }): LocalBindingViolation | undefined;
25
- export type { LocalBindingViolation };
26
- export { localBindingViolation, ollamaModelThinks };
@@ -1,30 +0,0 @@
1
- /**
2
- * Local model convenience preset.
3
- *
4
- * @module
5
- */
6
- /**
7
- * Whether an Ollama model thinks, read from the server's `POST /api/show` reply for it:
8
- * `capabilities` lists `thinking` (Ollama 0.34.0, 04/10/2026). The host fetches the reply.
9
- */
10
- function ollamaModelThinks(show) {
11
- if (!show || typeof show !== 'object')
12
- return false;
13
- const { capabilities } = show;
14
- return Array.isArray(capabilities) && capabilities.includes('thinking');
15
- }
16
- /**
17
- * The first setting a local server would refuse on this binding, or `undefined`. A thinking
18
- * level goes to the server as `reasoning_effort`; Ollama answers HTTP 400 "does not support
19
- * thinking" for a model that does not think (04/10/2026).
20
- */
21
- function localBindingViolation(binding, model) {
22
- if (!model.thinks && Object.keys(binding.efforts ?? {}).length > 0) {
23
- return {
24
- field: 'efforts',
25
- message: `${binding.apiId.trim()} does not think; leave efforts unset.`,
26
- };
27
- }
28
- return undefined;
29
- }
30
- export { localBindingViolation, ollamaModelThinks };
@@ -1,11 +0,0 @@
1
- /**
2
- * Host-convenience catalogs for first-party providers: provider builtins and media vocabularies.
3
- *
4
- * @module
5
- */
6
- import "../../_dnt.polyfills.js";
7
- export type { GoogleBindingViolation, GoogleFreeTierGrounding, GoogleImageAspectRatio, GoogleImageInputMime, GoogleImageOutputMime, GoogleImagePins, GoogleImageResolution, GoogleSpeechVoice, GoogleThinkingLevel, GoogleVoiceInputMime, } from './google.js';
8
- export { GOOGLE_BUILTIN_TOOLS, GOOGLE_FREE_TIER_GROUNDING, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_NO_EFFORT_API_IDS, GOOGLE_NO_THINKING_API_IDS, GOOGLE_SINGLE_TURN_API_IDS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, GOOGLE_THINKING_LEVELS, GOOGLE_THINKING_REQUIRED_API_IDS, GOOGLE_VOICE_INPUT_MIMES, googleBindingViolation, googleEfforts, googleFreeTierBuiltins, registerGooglePreset, } from './google.js';
9
- export type { LocalBindingViolation } from './local.js';
10
- export { localBindingViolation, ollamaModelThinks } from './local.js';
11
- export { OPENROUTER_BUILTIN_TOOLS, OPENROUTER_IMAGES_IGNORED_INPUTS, OPENROUTER_IMAGES_INPUT_MIMES, registerOpenRouterPreset, } from './openrouter.js';
@@ -1,9 +0,0 @@
1
- /**
2
- * Host-convenience catalogs for first-party providers: provider builtins and media vocabularies.
3
- *
4
- * @module
5
- */
6
- import "../../_dnt.polyfills.js";
7
- export { GOOGLE_BUILTIN_TOOLS, GOOGLE_FREE_TIER_GROUNDING, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_NO_EFFORT_API_IDS, GOOGLE_NO_THINKING_API_IDS, GOOGLE_SINGLE_TURN_API_IDS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, GOOGLE_THINKING_LEVELS, GOOGLE_THINKING_REQUIRED_API_IDS, GOOGLE_VOICE_INPUT_MIMES, googleBindingViolation, googleEfforts, googleFreeTierBuiltins, registerGooglePreset, } from './google.js';
8
- export { localBindingViolation, ollamaModelThinks } from './local.js';
9
- export { OPENROUTER_BUILTIN_TOOLS, OPENROUTER_IMAGES_IGNORED_INPUTS, OPENROUTER_IMAGES_INPUT_MIMES, registerOpenRouterPreset, } from './openrouter.js';
@@ -1,26 +0,0 @@
1
- /**
2
- * OpenRouter convenience preset.
3
- *
4
- * @module
5
- */
6
- /** `/images` takes image references only; a profile on it lists nothing wider in `inputs.attachments.accept`. */
7
- declare const OPENROUTER_IMAGES_INPUT_MIMES: readonly ["image/*"];
8
- /**
9
- * What `/images` never sends the model: it reads the prompt text and the reference images
10
- * only. The chat path (`image.includeText`) sends the system prompt and history.
11
- */
12
- declare const OPENROUTER_IMAGES_IGNORED_INPUTS: readonly ["system", "history"];
13
- /** The tools OpenRouter runs itself, as `builtin` tool definitions. */
14
- declare const OPENROUTER_BUILTIN_TOOLS: {
15
- type: "builtin";
16
- name: string;
17
- description: string;
18
- category: string;
19
- access: "read-only";
20
- paths: string[];
21
- loadTier: "T0";
22
- permission: "auto";
23
- }[];
24
- /** Registers into the default scope; a scope of its own takes `OPENROUTER_BUILTIN_TOOLS`. */
25
- declare function registerOpenRouterPreset(): void;
26
- export { OPENROUTER_BUILTIN_TOOLS, OPENROUTER_IMAGES_IGNORED_INPUTS, OPENROUTER_IMAGES_INPUT_MIMES, registerOpenRouterPreset, };
@@ -1,31 +0,0 @@
1
- /**
2
- * OpenRouter convenience preset.
3
- *
4
- * @module
5
- */
6
- import { registerTools } from '../kernel/default-scope.js';
7
- /** `/images` takes image references only; a profile on it lists nothing wider in `inputs.attachments.accept`. */
8
- const OPENROUTER_IMAGES_INPUT_MIMES = ['image/*'];
9
- /**
10
- * What `/images` never sends the model: it reads the prompt text and the reference images
11
- * only. The chat path (`image.includeText`) sends the system prompt and history.
12
- */
13
- const OPENROUTER_IMAGES_IGNORED_INPUTS = ['system', 'history'];
14
- /** The tools OpenRouter runs itself, as `builtin` tool definitions. */
15
- const OPENROUTER_BUILTIN_TOOLS = [
16
- {
17
- type: 'builtin',
18
- name: 'webSearch',
19
- description: 'OpenRouter web search',
20
- category: 'grounding',
21
- access: 'read-only',
22
- paths: ['*'],
23
- loadTier: 'T0',
24
- permission: 'auto',
25
- },
26
- ];
27
- /** Registers into the default scope; a scope of its own takes `OPENROUTER_BUILTIN_TOOLS`. */
28
- function registerOpenRouterPreset() {
29
- registerTools(OPENROUTER_BUILTIN_TOOLS);
30
- }
31
- export { OPENROUTER_BUILTIN_TOOLS, OPENROUTER_IMAGES_IGNORED_INPUTS, OPENROUTER_IMAGES_INPUT_MIMES, registerOpenRouterPreset, };