@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.
- package/README.md +4 -7
- package/esm/mod.d.ts +0 -1
- package/esm/mod.js +0 -1
- package/esm/src/cli/commands/fuzz-canary.js +7 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +11 -2
- package/esm/src/guardrails/detectors.js +12 -13
- package/esm/src/guardrails/error.d.ts +1 -1
- package/esm/src/guardrails/error.js +3 -1
- package/esm/src/guardrails/labels.d.ts +2 -2
- package/esm/src/guardrails/labels.js +8 -0
- package/esm/src/guardrails/network.d.ts +2 -0
- package/esm/src/guardrails/network.js +1 -0
- package/esm/src/guardrails/theorem-error.d.ts +1 -1
- package/esm/src/guardrails/theorem-error.js +4 -0
- package/esm/src/host/reply.js +2 -0
- package/esm/src/kernel/engine/decision.d.ts +2 -0
- package/esm/src/kernel/engine/decision.js +4 -0
- package/esm/src/kernel/engine/session/mod.d.ts +1 -1
- package/esm/src/kernel/engine/session/mod.js +5 -8
- package/esm/src/kernel/engine/tree.d.ts +2 -1
- package/esm/src/kernel/engine/tree.js +17 -6
- package/esm/src/kernel/protocols/protocol.d.ts +2 -1
- package/esm/src/kernel/protocols/runtime.js +8 -1
- package/esm/src/kernel/schema.js +1 -2
- package/esm/src/kernel/tools/coordinate.js +13 -13
- package/esm/src/kernel/tools/events.d.ts +11 -1
- package/esm/src/kernel/tools/events.js +22 -2
- package/esm/src/kernel/tools/execute.js +5 -3
- package/esm/src/kernel/tools/operation.d.ts +5 -1
- package/esm/src/kernel/tools/operation.js +8 -0
- package/esm/src/kernel/tools/remote.js +15 -6
- package/esm/src/observability/spans.d.ts +2 -1
- package/esm/src/observability/spans.js +1 -1
- package/esm/src/observability/trace-catalog.js +8 -0
- package/esm/src/providers/google/interactions/framing.js +1 -1
- package/esm/src/providers/google/limits.d.ts +4 -0
- package/esm/src/providers/google/limits.js +4 -0
- package/esm/src/providers/google/thinking.js +1 -1
- package/esm/src/providers/google/urls.d.ts +1 -3
- package/esm/src/providers/google/urls.js +1 -3
- package/esm/src/providers/open-ai/protocol.js +5 -0
- package/package.json +1 -10
- package/esm/src/presets/google/speech-voices.d.ts +0 -9
- package/esm/src/presets/google/speech-voices.js +0 -38
- package/esm/src/presets/google-limits.d.ts +0 -13
- package/esm/src/presets/google-limits.js +0 -18
- package/esm/src/presets/google.d.ts +0 -119
- package/esm/src/presets/google.js +0 -197
- package/esm/src/presets/local.d.ts +0 -26
- package/esm/src/presets/local.js +0 -30
- package/esm/src/presets/mod.d.ts +0 -11
- package/esm/src/presets/mod.js +0 -9
- package/esm/src/presets/openrouter.d.ts +0 -26
- package/esm/src/presets/openrouter.js +0 -31
|
@@ -111,11 +111,31 @@ function toolRunningEvent(tool, rawInput, ctx, base) {
|
|
|
111
111
|
...(activity ? { activity } : {}),
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
+
/** A call's claim, taken once at the hand-off: right before the destination is asked. */
|
|
115
|
+
export class HandOff {
|
|
116
|
+
begin;
|
|
117
|
+
taken;
|
|
118
|
+
failed;
|
|
119
|
+
constructor(begin) {
|
|
120
|
+
this.begin = begin;
|
|
121
|
+
}
|
|
122
|
+
claim() {
|
|
123
|
+
this.taken ??= (this.begin?.() ?? Promise.resolve(undefined)).catch((error) => {
|
|
124
|
+
this.failed = { error };
|
|
125
|
+
throw error;
|
|
126
|
+
});
|
|
127
|
+
return this.taken;
|
|
128
|
+
}
|
|
129
|
+
/** The claim's own failure is the coordinator's, so no tool catch may turn it into a tool failure. */
|
|
130
|
+
rethrowClaimFailure() {
|
|
131
|
+
if (this.failed)
|
|
132
|
+
throw this.failed.error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
114
135
|
export async function* dispatchToolBody(tool, input, ctx, base, beginBody) {
|
|
115
|
-
const claim = await beginBody?.(input);
|
|
116
136
|
throwIfAborted(ctx.signal);
|
|
117
137
|
yield toolRunningEvent(tool, input, ctx, base);
|
|
118
|
-
return
|
|
138
|
+
return new HandOff(beginBody && (() => beginBody(input)));
|
|
119
139
|
}
|
|
120
140
|
export function startToolExecution(tool, rawInput, ctx) {
|
|
121
141
|
throwIfAborted(ctx.signal);
|
|
@@ -463,10 +463,11 @@ function functionHandlerFailure(error) {
|
|
|
463
463
|
function waitsForPage(tool, ctx) {
|
|
464
464
|
return tool.answeredBy === 'page' && ctx.page === undefined && !ctx.pageExecution;
|
|
465
465
|
}
|
|
466
|
-
async function* receivePageAnswer(tool, ctx,
|
|
466
|
+
async function* receivePageAnswer(tool, ctx, handOff, base) {
|
|
467
467
|
const execution = ctx.pageExecution;
|
|
468
468
|
if (tool.answeredBy !== 'page' || !execution)
|
|
469
469
|
return ctx;
|
|
470
|
+
const claim = await handOff.claim();
|
|
470
471
|
if (!claim?.invocation) {
|
|
471
472
|
throw new TheoremError('config', `Page tool '${tool.name}' needs a tool execution coordinator (execution)`);
|
|
472
473
|
}
|
|
@@ -542,8 +543,8 @@ agent, beginBody) {
|
|
|
542
543
|
return { gated: gate, callNotStarted: true };
|
|
543
544
|
}
|
|
544
545
|
throwIfAborted(ctx.signal);
|
|
545
|
-
const
|
|
546
|
-
ctx = yield* receivePageAnswer(tool, ctx,
|
|
546
|
+
const handOff = yield* dispatchToolBody(tool, input, ctx, base, beginBody);
|
|
547
|
+
ctx = yield* receivePageAnswer(tool, ctx, handOff, base);
|
|
547
548
|
const { secret } = signedIn;
|
|
548
549
|
const fail = (failure) => settleToolFailure(guard, base, secret ? failureWithoutSecret(failure, secret) : failure, stages, { toolName: tool.name, callId, input });
|
|
549
550
|
const checks = requestChecks(stages?.span);
|
|
@@ -551,6 +552,7 @@ agent, beginBody) {
|
|
|
551
552
|
? { ...ctx, signedInFetch: signedInFetch(signedIn.prepared, ctx, checks) }
|
|
552
553
|
: ctx;
|
|
553
554
|
let output;
|
|
555
|
+
await handOff.claim();
|
|
554
556
|
try {
|
|
555
557
|
const shown = new HandlerEvents(base, guard.handlerEvents(stages?.drafts === true));
|
|
556
558
|
output = yield* runHandler(tool.handler, input, handlerCtx, shown);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TheoremError } from '../../guardrails/error.js';
|
|
2
|
+
import { type ErrorKind, TheoremError } from '../../guardrails/error.js';
|
|
3
3
|
import { type JsonObject, type JsonValue } from '../json.js';
|
|
4
4
|
import type { InjectUnit } from '../stages.js';
|
|
5
5
|
import type { GateReference, TurnEventOf } from '../turn-events.js';
|
|
@@ -69,6 +69,10 @@ export interface ToolExecutionCoordinator {
|
|
|
69
69
|
}
|
|
70
70
|
/** A coordinator, a page dispatch or the kernel broke the tool-operation contract. */
|
|
71
71
|
export declare function operationBroken(reason: string): TheoremError;
|
|
72
|
+
/** The user reads that the action is unresolved; the builder reads why, under the kind of what happened. */
|
|
73
|
+
export declare function unresolvedOperation(kind: ErrorKind, reason: string, cause?: unknown): TheoremError;
|
|
74
|
+
/** The host asked to run an operation that is still running or uncertain, so the host settles it first. */
|
|
75
|
+
export declare function heldOperation(state: 'running' | 'uncertain'): TheoremError;
|
|
72
76
|
export declare function toolInvocationHash(value: unknown): Promise<string>;
|
|
73
77
|
export declare const toolOperationOutcomeSchema: z.ZodType<ToolOperationOutcome>;
|
|
74
78
|
export declare function operationWireValue(value: unknown): JsonValue;
|
|
@@ -11,6 +11,14 @@ export const savedToolInvocationSchema = z.strictObject({
|
|
|
11
11
|
export function operationBroken(reason) {
|
|
12
12
|
return new TheoremError('internal', reason);
|
|
13
13
|
}
|
|
14
|
+
/** The user reads that the action is unresolved; the builder reads why, under the kind of what happened. */
|
|
15
|
+
export function unresolvedOperation(kind, reason, cause) {
|
|
16
|
+
return new TheoremError(kind, reason, { copy: { key: 'tool.execution_uncertain' }, cause });
|
|
17
|
+
}
|
|
18
|
+
/** The host asked to run an operation that is still running or uncertain, so the host settles it first. */
|
|
19
|
+
export function heldOperation(state) {
|
|
20
|
+
return unresolvedOperation('conflict', `The tool operation is ${state}, so it does not run again until the host settles it`);
|
|
21
|
+
}
|
|
14
22
|
export async function toolInvocationHash(value) {
|
|
15
23
|
const ordered = (item) => {
|
|
16
24
|
if (Array.isArray(item))
|
|
@@ -562,8 +562,8 @@ export async function* executeHttpTool(tool, rawInput, ctx, base, stages, beginB
|
|
|
562
562
|
const guarded = yield* guardToolTarget(target.url, ctx, stages?.span);
|
|
563
563
|
if (!guarded.ok)
|
|
564
564
|
return failureOutcome(guarded.failure, true);
|
|
565
|
-
yield* dispatchToolBody(tool, input, ctx, base, beginBody);
|
|
566
|
-
return yield* sendWithCredential(prepared, guarded.url, (url) => sendHttpRequest(tool, url, target.body, prepared, ctx, base, stages?.span, shown));
|
|
565
|
+
const handOff = yield* dispatchToolBody(tool, input, ctx, base, beginBody);
|
|
566
|
+
return yield* sendWithCredential(prepared, guarded.url, (url) => sendHttpRequest(tool, url, target.body, prepared, ctx, base, stages?.span, shown, handOff));
|
|
567
567
|
}
|
|
568
568
|
/** A body that is text, read so far: what a successful call's drafts show. */
|
|
569
569
|
function isDraftable(response) {
|
|
@@ -578,7 +578,7 @@ async function* readHttpBody(response, shown, secret, maxBytes) {
|
|
|
578
578
|
return await readCappedText(response, maxBytes);
|
|
579
579
|
return yield* readCappedTextShowing(response, shown, secret, maxBytes);
|
|
580
580
|
}
|
|
581
|
-
async function* sendHttpRequest(tool, targetUrl, body, { authHeaders, secret }, ctx, base, span, shown) {
|
|
581
|
+
async function* sendHttpRequest(tool, targetUrl, body, { authHeaders, secret }, ctx, base, span, shown, handOff) {
|
|
582
582
|
const checks = requestChecks(span);
|
|
583
583
|
const headers = { Accept: 'application/json' };
|
|
584
584
|
if (tool.method !== 'GET') {
|
|
@@ -601,6 +601,9 @@ async function* sendHttpRequest(tool, targetUrl, body, { authHeaders, secret },
|
|
|
601
601
|
originBoundHeaders: { ...tool.headers, ...authHeaders },
|
|
602
602
|
resolveHost: ctx.resolveHost,
|
|
603
603
|
onCheck: checks.onCheck,
|
|
604
|
+
beforeSend: async () => {
|
|
605
|
+
await handOff.claim();
|
|
606
|
+
},
|
|
604
607
|
}));
|
|
605
608
|
const text = yield* readHttpBody(response, shown, secret, tool.maxResponseBytes);
|
|
606
609
|
if (text === undefined) {
|
|
@@ -635,6 +638,7 @@ async function* sendHttpRequest(tool, targetUrl, body, { authHeaders, secret },
|
|
|
635
638
|
};
|
|
636
639
|
}
|
|
637
640
|
catch (err) {
|
|
641
|
+
handOff.rethrowClaimFailure();
|
|
638
642
|
if (tool.timeoutMs !== undefined && timedOut?.aborted && !ctx.signal?.aborted) {
|
|
639
643
|
return failureOutcome(timeoutFailure(targetUrl.hostname, tool.timeoutMs), false);
|
|
640
644
|
}
|
|
@@ -752,6 +756,7 @@ async function fetchMcpProtocolAttempt(transport, rpcId, mcpToolName, input, pro
|
|
|
752
756
|
originBoundHeaders: transport.originBoundHeaders,
|
|
753
757
|
resolveHost: transport.resolveHost,
|
|
754
758
|
onCheck: transport.onCheck,
|
|
759
|
+
...(transport.beforeSend ? { beforeSend: transport.beforeSend } : {}),
|
|
755
760
|
});
|
|
756
761
|
const text = await readCappedText(response, transport.maxResponseBytes);
|
|
757
762
|
if (text === undefined) {
|
|
@@ -1081,10 +1086,10 @@ sessions = createMcpSessionCache(), beginBody) {
|
|
|
1081
1086
|
const prepared = yield* remoteAuthAndPreBody({ tool, input: permitted.input, ctx, base, stages });
|
|
1082
1087
|
if (!('ok' in prepared))
|
|
1083
1088
|
return prepared;
|
|
1084
|
-
yield* dispatchToolBody(tool, prepared.input, ctx, base, beginBody);
|
|
1085
|
-
return yield* sendWithCredential(prepared, guarded.url, (url) => sendMcpRequest(tool, url, prepared.input, prepared, ctx, base, stages?.span, sessions));
|
|
1089
|
+
const handOff = yield* dispatchToolBody(tool, prepared.input, ctx, base, beginBody);
|
|
1090
|
+
return yield* sendWithCredential(prepared, guarded.url, (url) => sendMcpRequest(tool, url, prepared.input, prepared, ctx, base, stages?.span, sessions, handOff));
|
|
1086
1091
|
}
|
|
1087
|
-
async function* sendMcpRequest(tool, url, input, { authHeaders, secret }, ctx, base, span, sessions) {
|
|
1092
|
+
async function* sendMcpRequest(tool, url, input, { authHeaders, secret }, ctx, base, span, sessions, handOff) {
|
|
1088
1093
|
const checks = requestChecks(span);
|
|
1089
1094
|
try {
|
|
1090
1095
|
const transport = {
|
|
@@ -1099,6 +1104,9 @@ async function* sendMcpRequest(tool, url, input, { authHeaders, secret }, ctx, b
|
|
|
1099
1104
|
signal: ctx.signal,
|
|
1100
1105
|
onCheck: checks.onCheck,
|
|
1101
1106
|
...(tool.maxResponseBytes === undefined ? {} : { maxResponseBytes: tool.maxResponseBytes }),
|
|
1107
|
+
beforeSend: async () => {
|
|
1108
|
+
await handOff.claim();
|
|
1109
|
+
},
|
|
1102
1110
|
};
|
|
1103
1111
|
const key = await mcpSessionKey(url.href, transport.originBoundHeaders);
|
|
1104
1112
|
const use = { tool: tool.name, ...tool.session };
|
|
@@ -1135,6 +1143,7 @@ async function* sendMcpRequest(tool, url, input, { authHeaders, secret }, ctx, b
|
|
|
1135
1143
|
};
|
|
1136
1144
|
}
|
|
1137
1145
|
catch (err) {
|
|
1146
|
+
handOff.rethrowClaimFailure();
|
|
1138
1147
|
return yield* thrownOutcome(err, checks);
|
|
1139
1148
|
}
|
|
1140
1149
|
finally {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const OMIT_INJECTION = "[omitted - injection]";
|
|
2
2
|
declare const OMIT_SENSITIVE = "[omitted -sensitive]";
|
|
3
3
|
declare const OMIT_CANARY = "[omitted - canary]";
|
|
4
|
+
declare const OMIT_PROMPT = "[omitted - instructions]";
|
|
4
5
|
type RedactKind = 'injection' | 'sensitive' | 'canary' | 'prompt' | 'image' | 'link' | 'tool' | 'directive' | 'host';
|
|
5
6
|
interface RedactSpan {
|
|
6
7
|
start: number;
|
|
@@ -19,4 +20,4 @@ declare function mergeSpans(spans: RedactSpan[]): RedactSpan[];
|
|
|
19
20
|
declare function applySpans(text: string, spans: RedactSpan[]): string;
|
|
20
21
|
declare function spansFromPatterns(text: string, patterns: RegExp[], kind: RedactKind): RedactSpan[];
|
|
21
22
|
export type { RedactKind, RedactSpan };
|
|
22
|
-
export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_SENSITIVE, spansFromPatterns, };
|
|
23
|
+
export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_PROMPT, OMIT_SENSITIVE, spansFromPatterns, };
|
|
@@ -68,4 +68,4 @@ function spansFromPatterns(text, patterns, kind) {
|
|
|
68
68
|
}
|
|
69
69
|
return spans;
|
|
70
70
|
}
|
|
71
|
-
export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_SENSITIVE, spansFromPatterns, };
|
|
71
|
+
export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_PROMPT, OMIT_SENSITIVE, spansFromPatterns, };
|
|
@@ -88,6 +88,14 @@ const STOP_KINDS = {
|
|
|
88
88
|
const ERROR_KIND_OPTIONS = {
|
|
89
89
|
config: { label: 'Setup', doc: 'The profile, tool, or schema is set up wrong.' },
|
|
90
90
|
request: { label: 'Host request', doc: 'The host called theorem wrongly.' },
|
|
91
|
+
conflict: {
|
|
92
|
+
label: 'Conflict',
|
|
93
|
+
doc: 'The call conflicts with the state it acts on, such as an operation that is still running or not settled.',
|
|
94
|
+
},
|
|
95
|
+
not_found: {
|
|
96
|
+
label: 'Not found',
|
|
97
|
+
doc: 'Something the call names by id is not there, such as a conversation the store no longer holds.',
|
|
98
|
+
},
|
|
91
99
|
input: { label: 'User input', doc: 'The user sent input the profile does not accept.' },
|
|
92
100
|
action: { label: 'Not allowed', doc: 'The user asked for something the profile does not allow.' },
|
|
93
101
|
auth: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TheoremError } from '../../../guardrails/error.js';
|
|
3
3
|
import { historyMessageParts, wireInteractionPart } from '../../../kernel/interaction-parts.js';
|
|
4
|
-
import { GOOGLE_SPEECH_FORMATS } from '../../../presets/google-limits.js';
|
|
5
4
|
import { withCarriedToolFiles } from '../../shared/carried-tool-files.js';
|
|
6
5
|
import { historyToolArguments, historyToolIdentity } from '../../shared/tool-args.js';
|
|
7
6
|
import { interactionsBuiltinTool } from '../builtins.js';
|
|
7
|
+
import { GOOGLE_SPEECH_FORMATS } from '../limits.js';
|
|
8
8
|
import { assertGoogleThinkingLevel } from '../thinking.js';
|
|
9
9
|
export function camelToSnake(key) {
|
|
10
10
|
return key.replaceAll(/[A-Z]/g, (ch) => `_${ch.toLowerCase()}`);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The thinking levels Gemini's `thinkingLevel` takes; OpenRouter models take them all. */
|
|
2
|
+
export declare const GOOGLE_THINKING_LEVELS: readonly ["minimal", "low", "medium", "high"];
|
|
3
|
+
/** The audio format Gemini speech returns (PCM, wrapped as WAV); OpenRouter speech also takes `mp3`. */
|
|
4
|
+
export declare const GOOGLE_SPEECH_FORMATS: readonly ["pcm"];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The thinking levels Gemini's `thinkingLevel` takes; OpenRouter models take them all. */
|
|
2
|
+
export const GOOGLE_THINKING_LEVELS = ['minimal', 'low', 'medium', 'high'];
|
|
3
|
+
/** The audio format Gemini speech returns (PCM, wrapped as WAV); OpenRouter speech also takes `mp3`. */
|
|
4
|
+
export const GOOGLE_SPEECH_FORMATS = ['pcm'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TheoremError } from '../../guardrails/error.js';
|
|
2
|
-
import { GOOGLE_THINKING_LEVELS } from '
|
|
2
|
+
import { GOOGLE_THINKING_LEVELS } from './limits.js';
|
|
3
3
|
/** Refuses a thinking level Gemini does not take, rather than sending it. */
|
|
4
4
|
export function assertGoogleThinkingLevel(level) {
|
|
5
5
|
if (level && !GOOGLE_THINKING_LEVELS.includes(level)) {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
/** The models a key's project can call; paged with `pageToken`. */
|
|
2
|
-
declare const GEMINI_MODELS_URL = "https://generativelanguage.googleapis.com/v1beta/models";
|
|
3
1
|
declare const GEMINI_LIVE_WS_URL = "wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent";
|
|
4
|
-
export { GEMINI_LIVE_WS_URL
|
|
2
|
+
export { GEMINI_LIVE_WS_URL };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
/** The models a key's project can call; paged with `pageToken`. */
|
|
2
|
-
const GEMINI_MODELS_URL = 'https://generativelanguage.googleapis.com/v1beta/models';
|
|
3
1
|
const GEMINI_LIVE_WS_URL = 'wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent';
|
|
4
|
-
export { GEMINI_LIVE_WS_URL
|
|
2
|
+
export { GEMINI_LIVE_WS_URL };
|
|
@@ -150,7 +150,12 @@ async function* speech(context, request) {
|
|
|
150
150
|
// why: `instructions` is the endpoint's own field for delivery, never read aloud (probe 07/10/2026: Gemini 3.8 slowed and sped by it).
|
|
151
151
|
...(spec?.style ? { instructions: spec.style } : {}),
|
|
152
152
|
};
|
|
153
|
+
let known;
|
|
153
154
|
for await (const row of context.send(body, { stream: false })) {
|
|
155
|
+
const identity = foldResponse(known, openAiResponse(row));
|
|
156
|
+
known = identity.known;
|
|
157
|
+
if (identity.event)
|
|
158
|
+
yield identity.event;
|
|
154
159
|
const type = typeof row.mime_type === 'string' ? row.mime_type : '';
|
|
155
160
|
const bytes = typeof row.data === 'string' ? base64ToBytes(row.data) : new Uint8Array();
|
|
156
161
|
if (!bytes.length)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/agents",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.540.g67b727f",
|
|
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",
|
|
@@ -62,15 +62,6 @@
|
|
|
62
62
|
"./cli": {
|
|
63
63
|
"import": "./esm/src/cli/index.js"
|
|
64
64
|
},
|
|
65
|
-
"./presets": {
|
|
66
|
-
"import": "./esm/src/presets/mod.js"
|
|
67
|
-
},
|
|
68
|
-
"./presets/google": {
|
|
69
|
-
"import": "./esm/src/presets/google.js"
|
|
70
|
-
},
|
|
71
|
-
"./presets/google/speech-voices": {
|
|
72
|
-
"import": "./esm/src/presets/google/speech-voices.js"
|
|
73
|
-
},
|
|
74
65
|
"./schema": {
|
|
75
66
|
"import": "./esm/src/kernel/schema.js"
|
|
76
67
|
},
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini TTS voice names for `speech.voice`. No imports, so docs UIs can load it alone.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import "../../../_dnt.polyfills.js";
|
|
7
|
-
export declare const GOOGLE_SPEECH_VOICES: readonly ["Zephyr", "Puck", "Charon", "Kore", "Fenrir", "Leda", "Orus", "Aoede", "Callirrhoe", "Autonoe", "Enceladus", "Iapetus", "Umbriel", "Algieba", "Despina", "Erinome", "Algenib", "Rasalgethi", "Laomedeia", "Achernar", "Alnilam", "Schedar", "Gacrux", "Pulcherrima", "Achird", "Zubenelgenubi", "Vindemiatrix", "Sadachbia", "Sadaltager", "Sulafat"];
|
|
8
|
-
/** The name of a Gemini speech voice. */
|
|
9
|
-
export type GoogleSpeechVoice = (typeof GOOGLE_SPEECH_VOICES)[number];
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini TTS voice names for `speech.voice`. No imports, so docs UIs can load it alone.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import "../../../_dnt.polyfills.js";
|
|
7
|
-
export const GOOGLE_SPEECH_VOICES = [
|
|
8
|
-
'Zephyr',
|
|
9
|
-
'Puck',
|
|
10
|
-
'Charon',
|
|
11
|
-
'Kore',
|
|
12
|
-
'Fenrir',
|
|
13
|
-
'Leda',
|
|
14
|
-
'Orus',
|
|
15
|
-
'Aoede',
|
|
16
|
-
'Callirrhoe',
|
|
17
|
-
'Autonoe',
|
|
18
|
-
'Enceladus',
|
|
19
|
-
'Iapetus',
|
|
20
|
-
'Umbriel',
|
|
21
|
-
'Algieba',
|
|
22
|
-
'Despina',
|
|
23
|
-
'Erinome',
|
|
24
|
-
'Algenib',
|
|
25
|
-
'Rasalgethi',
|
|
26
|
-
'Laomedeia',
|
|
27
|
-
'Achernar',
|
|
28
|
-
'Alnilam',
|
|
29
|
-
'Schedar',
|
|
30
|
-
'Gacrux',
|
|
31
|
-
'Pulcherrima',
|
|
32
|
-
'Achird',
|
|
33
|
-
'Zubenelgenubi',
|
|
34
|
-
'Vindemiatrix',
|
|
35
|
-
'Sadachbia',
|
|
36
|
-
'Sadaltager',
|
|
37
|
-
'Sulafat',
|
|
38
|
-
];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** The thinking levels Gemini's `thinkingLevel` takes; OpenRouter models take them all. */
|
|
2
|
-
declare const GOOGLE_THINKING_LEVELS: readonly ["minimal", "low", "medium", "high"];
|
|
3
|
-
/** The audio format Gemini speech returns (PCM, wrapped as WAV); OpenRouter speech also takes `mp3`. */
|
|
4
|
-
declare const GOOGLE_SPEECH_FORMATS: readonly ["pcm"];
|
|
5
|
-
/** A thinking level Gemini takes: minimal, low, medium, or high. */
|
|
6
|
-
type GoogleThinkingLevel = (typeof GOOGLE_THINKING_LEVELS)[number];
|
|
7
|
-
/**
|
|
8
|
-
* A `geminiInteractions` or `geminiLive` binding's `efforts`, typed to the levels Gemini takes.
|
|
9
|
-
* The runtime check refuses an untyped host's level when the binding is built, not when a turn runs.
|
|
10
|
-
*/
|
|
11
|
-
declare function googleEfforts<Efforts extends Record<string, GoogleThinkingLevel>>(efforts: Efforts): Efforts;
|
|
12
|
-
export type { GoogleThinkingLevel };
|
|
13
|
-
export { GOOGLE_SPEECH_FORMATS, GOOGLE_THINKING_LEVELS, googleEfforts };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { TheoremError } from '../guardrails/theorem-error.js';
|
|
2
|
-
/** The thinking levels Gemini's `thinkingLevel` takes; OpenRouter models take them all. */
|
|
3
|
-
const GOOGLE_THINKING_LEVELS = ['minimal', 'low', 'medium', 'high'];
|
|
4
|
-
/** The audio format Gemini speech returns (PCM, wrapped as WAV); OpenRouter speech also takes `mp3`. */
|
|
5
|
-
const GOOGLE_SPEECH_FORMATS = ['pcm'];
|
|
6
|
-
/**
|
|
7
|
-
* A `geminiInteractions` or `geminiLive` binding's `efforts`, typed to the levels Gemini takes.
|
|
8
|
-
* The runtime check refuses an untyped host's level when the binding is built, not when a turn runs.
|
|
9
|
-
*/
|
|
10
|
-
function googleEfforts(efforts) {
|
|
11
|
-
for (const [alias, level] of Object.entries(efforts)) {
|
|
12
|
-
if (!GOOGLE_THINKING_LEVELS.includes(level)) {
|
|
13
|
-
throw new TheoremError('config', `Effort '${alias}': Gemini does not take '${level}' (${GOOGLE_THINKING_LEVELS.join(', ')})`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return efforts;
|
|
17
|
-
}
|
|
18
|
-
export { GOOGLE_SPEECH_FORMATS, GOOGLE_THINKING_LEVELS, googleEfforts };
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Google / Gemini convenience preset.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import "../../_dnt.polyfills.js";
|
|
7
|
-
import type { ModelBinding, ProfileImageSpec, ProfileLiveSpec, ProfileSpeechSpec } from '../kernel/types.js';
|
|
8
|
-
import { GOOGLE_SPEECH_VOICES, type GoogleSpeechVoice } from './google/speech-voices.js';
|
|
9
|
-
import { GOOGLE_SPEECH_FORMATS, GOOGLE_THINKING_LEVELS, type GoogleThinkingLevel, googleEfforts } from './google-limits.js';
|
|
10
|
-
/** The image MIME types a Gemini profile can take as input. */
|
|
11
|
-
declare const GOOGLE_IMAGE_INPUT_MIMES: readonly ["image/png", "image/jpeg", "image/webp", "image/heic", "image/heif"];
|
|
12
|
-
/** The audio MIME types a Gemini profile can take as voice input. */
|
|
13
|
-
declare const GOOGLE_VOICE_INPUT_MIMES: readonly ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4"];
|
|
14
|
-
/**
|
|
15
|
-
* TTS models that reject any history with a model turn, so compaction's summary fails them
|
|
16
|
-
* (live, 29/09/2026).
|
|
17
|
-
*/
|
|
18
|
-
declare const GOOGLE_SINGLE_TURN_API_IDS: readonly ["gemini-2.5-flash-preview-tts", "gemini-3.1-flash-tts-preview", "gemini-3.8-flash-tts", "gemini-3.8-flash-lite-tts"];
|
|
19
|
-
/**
|
|
20
|
-
* Models that reject any thinking setting, `summaries: false` included: leave
|
|
21
|
-
* `efforts` and `summaries` unset (live, 30/09/2026).
|
|
22
|
-
*/
|
|
23
|
-
declare const GOOGLE_NO_THINKING_API_IDS: readonly ["gemini-2.5-flash-image", "antigravity-preview-05-2026", "antigravity-preview-09-2026", "antigravity-preview-latest"];
|
|
24
|
-
/**
|
|
25
|
-
* Models that refuse a thinking level and take `summaries`: leave `efforts` unset
|
|
26
|
-
* (live, 01/10/2026: Live closes 1007 "Thinking level is not supported for this model";
|
|
27
|
-
* 04/10/2026: setup takes `includeThoughts` either way).
|
|
28
|
-
*/
|
|
29
|
-
declare const GOOGLE_NO_EFFORT_API_IDS: readonly ["gemini-3.8-live"];
|
|
30
|
-
/**
|
|
31
|
-
* Models that refuse a session without a thinking level: pin `efforts`
|
|
32
|
-
* (live, 01/10/2026: Live closes 1007 "Thinking level must be specified for this model").
|
|
33
|
-
*/
|
|
34
|
-
declare const GOOGLE_THINKING_REQUIRED_API_IDS: readonly ["gemini-3.8-live-extended-thinking"];
|
|
35
|
-
/** Which grounding builtins a model's free-tier quota allows. */
|
|
36
|
-
interface GoogleFreeTierGrounding {
|
|
37
|
-
googleSearch: boolean;
|
|
38
|
-
googleMaps: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Models with a non-zero free-tier quota, and the grounding each allows (AI Studio, Sep 2026).
|
|
42
|
-
* No model keeps free Maps quota: 3.5 Flash-Lite turns with Maps are refused as over quota
|
|
43
|
-
* (live, 13/10/2026).
|
|
44
|
-
* A builtin with no quota is refused as if over quota: on Live, a close 1011 "You exceeded your
|
|
45
|
-
* current quota" at setup, whatever the key's usage (live, 01/10/2026).
|
|
46
|
-
*/
|
|
47
|
-
declare const GOOGLE_FREE_TIER_GROUNDING: Readonly<Record<string, GoogleFreeTierGrounding>>;
|
|
48
|
-
/** Grounding builtins the free tier allows on `apiId`; none for a model with no free quota. */
|
|
49
|
-
declare function googleFreeTierBuiltins(apiId: string): Array<'googleSearch' | 'googleMaps'>;
|
|
50
|
-
/** A Gemini binding field that breaks a Gemini rule, and what is wrong with it. */
|
|
51
|
-
interface GoogleBindingViolation {
|
|
52
|
-
field: 'apiId' | 'efforts' | 'summaries' | 'builtInTools';
|
|
53
|
-
message: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The first setting Google would refuse on this binding, or `undefined`. With `freeTier`, it
|
|
57
|
-
* also holds the binding to the free-tier table: a listed model, and only the grounding its
|
|
58
|
-
* quota allows.
|
|
59
|
-
*/
|
|
60
|
-
declare function googleBindingViolation(binding: Pick<ModelBinding, 'apiId' | 'efforts' | 'summaries' | 'builtInTools'>, options?: {
|
|
61
|
-
freeTier?: boolean;
|
|
62
|
-
}): GoogleBindingViolation | undefined;
|
|
63
|
-
/** The speech settings a Gemini profile may pin, with the voice narrowed to Gemini's. */
|
|
64
|
-
type GoogleSpeechPins = Omit<ProfileSpeechSpec, 'voice'> & {
|
|
65
|
-
voice?: GoogleSpeechVoice;
|
|
66
|
-
};
|
|
67
|
-
/** The live settings a Gemini profile may pin, with the voice narrowed to Gemini's. */
|
|
68
|
-
type GoogleLivePins = Omit<ProfileLiveSpec, 'voice'> & {
|
|
69
|
-
voice?: GoogleSpeechVoice;
|
|
70
|
-
};
|
|
71
|
-
/** The aspect ratios a Gemini image model can return. */
|
|
72
|
-
declare const GOOGLE_IMAGE_ASPECT_RATIOS: readonly ["1:1", "3:2", "2:3", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
|
|
73
|
-
/** The resolutions a Gemini image model can return. */
|
|
74
|
-
declare const GOOGLE_IMAGE_RESOLUTIONS: readonly ["1K", "2K", "4K"];
|
|
75
|
-
/** What a Gemini image model can be asked to return. */
|
|
76
|
-
declare const GOOGLE_IMAGE_OUTPUT_MIMES: readonly ["image/png", "image/jpeg"];
|
|
77
|
-
/** One of {@linkcode GOOGLE_IMAGE_INPUT_MIMES}. */
|
|
78
|
-
type GoogleImageInputMime = (typeof GOOGLE_IMAGE_INPUT_MIMES)[number];
|
|
79
|
-
/** One of {@linkcode GOOGLE_VOICE_INPUT_MIMES}. */
|
|
80
|
-
type GoogleVoiceInputMime = (typeof GOOGLE_VOICE_INPUT_MIMES)[number];
|
|
81
|
-
/** One of {@linkcode GOOGLE_IMAGE_ASPECT_RATIOS}. */
|
|
82
|
-
type GoogleImageAspectRatio = (typeof GOOGLE_IMAGE_ASPECT_RATIOS)[number];
|
|
83
|
-
/** One of {@linkcode GOOGLE_IMAGE_RESOLUTIONS}. */
|
|
84
|
-
type GoogleImageResolution = (typeof GOOGLE_IMAGE_RESOLUTIONS)[number];
|
|
85
|
-
/** One of {@linkcode GOOGLE_IMAGE_OUTPUT_MIMES}. */
|
|
86
|
-
type GoogleImageOutputMime = (typeof GOOGLE_IMAGE_OUTPUT_MIMES)[number];
|
|
87
|
-
/** The image settings a Gemini profile may pin, narrowed to what Gemini accepts. */
|
|
88
|
-
type GoogleImagePins = Omit<ProfileImageSpec, 'aspectRatio' | 'resolution' | 'mimeType'> & {
|
|
89
|
-
aspectRatio?: GoogleImageAspectRatio;
|
|
90
|
-
resolution?: GoogleImageResolution;
|
|
91
|
-
mimeType?: GoogleImageOutputMime;
|
|
92
|
-
};
|
|
93
|
-
/** The tools Gemini runs itself, as `builtin` tool definitions. */
|
|
94
|
-
declare const GOOGLE_BUILTIN_TOOLS: ({
|
|
95
|
-
type: "builtin";
|
|
96
|
-
name: string;
|
|
97
|
-
description: string;
|
|
98
|
-
category: string;
|
|
99
|
-
access: "read-only";
|
|
100
|
-
paths: string[];
|
|
101
|
-
loadTier: "T0";
|
|
102
|
-
permission: "auto";
|
|
103
|
-
conflictsWith?: undefined;
|
|
104
|
-
} | {
|
|
105
|
-
type: "builtin";
|
|
106
|
-
name: string;
|
|
107
|
-
description: string;
|
|
108
|
-
category: string;
|
|
109
|
-
access: "read-only";
|
|
110
|
-
paths: string[];
|
|
111
|
-
loadTier: "T0";
|
|
112
|
-
permission: "auto";
|
|
113
|
-
conflictsWith: string[];
|
|
114
|
-
})[];
|
|
115
|
-
/** Registers into the default scope; a scope of its own takes `GOOGLE_BUILTIN_TOOLS`. */
|
|
116
|
-
declare function registerGooglePreset(): void;
|
|
117
|
-
export { GEMINI_MODELS_URL } from '../providers/google/urls.js';
|
|
118
|
-
export type { GoogleBindingViolation, GoogleFreeTierGrounding, GoogleImageAspectRatio, GoogleImageInputMime, GoogleImageOutputMime, GoogleImagePins, GoogleImageResolution, GoogleLivePins, GoogleSpeechPins, GoogleSpeechVoice, GoogleThinkingLevel, GoogleVoiceInputMime, };
|
|
119
|
-
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, };
|