@theoremjs/agents 0.3.4-next.679.gcdf1a3a → 0.3.4-next.711.g78e504a
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 +5 -4
- package/esm/mod.d.ts +6 -3
- package/esm/mod.js +3 -1
- package/esm/src/cli/commands/bench.js +4 -10
- package/esm/src/cli/commands/profile.js +4 -1
- package/esm/src/guardrails/labels.d.ts +1 -1
- package/esm/src/guardrails/labels.js +9 -0
- package/esm/src/interface/blocks.js +19 -0
- package/esm/src/interface/from-profile.d.ts +2 -2
- package/esm/src/interface/from-profile.js +7 -0
- package/esm/src/interface/history.d.ts +2 -2
- package/esm/src/interface/history.js +7 -4
- package/esm/src/interface/mod.d.ts +2 -2
- package/esm/src/interface/mod.js +1 -1
- package/esm/src/interface/profile-interface.js +14 -4
- package/esm/src/interface/tool-calls.d.ts +3 -3
- package/esm/src/interface/tool-calls.js +5 -8
- package/esm/src/interface/tool-invoke.d.ts +3 -1
- package/esm/src/interface/tool-invoke.js +6 -1
- package/esm/src/interface/types.d.ts +7 -5
- package/esm/src/kernel/api-catalog.js +13 -5
- package/esm/src/kernel/auth/oauth.js +3 -1
- package/esm/src/kernel/engine/background.d.ts +7 -0
- package/esm/src/kernel/engine/background.js +18 -0
- package/esm/src/kernel/engine/runner/mod.js +24 -1
- package/esm/src/kernel/engine/runner/state.d.ts +4 -0
- package/esm/src/kernel/engine/runner/state.js +1 -0
- package/esm/src/kernel/engine/runner/step-order.d.ts +8 -0
- package/esm/src/kernel/engine/runner/step-order.js +1 -1
- package/esm/src/kernel/engine/runner/steps.js +1 -0
- package/esm/src/kernel/engine/session/mod.d.ts +2 -0
- package/esm/src/kernel/engine/session/mod.js +20 -2
- package/esm/src/kernel/engine/session/session-trace.js +1 -0
- package/esm/src/kernel/mod.d.ts +6 -3
- package/esm/src/kernel/mod.js +3 -1
- package/esm/src/kernel/profile-presence.js +1 -0
- package/esm/src/kernel/profile-scope.js +23 -21
- package/esm/src/kernel/protocols/protocol.d.ts +1 -1
- package/esm/src/kernel/protocols/protocol.js +1 -0
- package/esm/src/kernel/registry/catalog.js +4 -1
- package/esm/src/kernel/registry/ingress.d.ts +3 -1
- package/esm/src/kernel/registry/ingress.js +12 -1
- package/esm/src/kernel/registry/profile-outputs.js +2 -1
- package/esm/src/kernel/registry/profiles.d.ts +12 -2
- package/esm/src/kernel/registry/profiles.js +37 -7
- package/esm/src/kernel/registry/resolve.js +9 -5
- package/esm/src/kernel/registry/system-prompt.d.ts +6 -1
- package/esm/src/kernel/registry/system-prompt.js +20 -13
- package/esm/src/kernel/schema.d.ts +1 -1
- package/esm/src/kernel/schema.js +24 -8
- package/esm/src/kernel/system-lines.d.ts +22 -0
- package/esm/src/kernel/system-lines.js +162 -0
- package/esm/src/kernel/tools/activity-label.d.ts +15 -0
- package/esm/src/kernel/tools/activity-label.js +12 -7
- package/esm/src/kernel/tools/agent.js +1 -1
- package/esm/src/kernel/tools/background.d.ts +81 -0
- package/esm/src/kernel/tools/background.js +70 -0
- package/esm/src/kernel/tools/call-order.d.ts +18 -0
- package/esm/src/kernel/tools/call-order.js +52 -0
- package/esm/src/kernel/tools/coordinate.d.ts +8 -1
- package/esm/src/kernel/tools/coordinate.js +274 -34
- package/esm/src/kernel/tools/execute.d.ts +2 -0
- package/esm/src/kernel/tools/execute.js +17 -4
- package/esm/src/kernel/tools/invoke.js +40 -13
- package/esm/src/kernel/tools/memory-execution.js +10 -1
- package/esm/src/kernel/tools/operation.d.ts +21 -0
- package/esm/src/kernel/tools/operation.js +19 -10
- package/esm/src/kernel/tools/registry.js +28 -6
- package/esm/src/kernel/tools/resolve.d.ts +4 -2
- package/esm/src/kernel/tools/resolve.js +34 -7
- package/esm/src/kernel/tools/run.d.ts +2 -2
- package/esm/src/kernel/tools/run.js +4 -1
- package/esm/src/kernel/tools/stage-run.d.ts +3 -1
- package/esm/src/kernel/tools/stage-run.js +58 -55
- package/esm/src/kernel/tools/types.d.ts +10 -0
- package/esm/src/kernel/turn-events.d.ts +8 -1
- package/esm/src/kernel/turn-events.js +2 -0
- package/esm/src/kernel/types.d.ts +39 -4
- package/esm/src/observability/trace-catalog.js +3 -0
- package/esm/src/providers/google/interactions/steps.js +14 -3
- package/esm/src/providers/mod.d.ts +2 -0
- package/esm/src/providers/mod.js +1 -0
- package/esm/src/providers/open-ai/protocol.js +8 -4
- package/esm/src/providers/openrouter/protocol.d.ts +26 -0
- package/esm/src/providers/openrouter/protocol.js +58 -2
- package/esm/src/providers/openrouter/provider.d.ts +1 -1
- package/esm/src/providers/openrouter/provider.js +3 -1
- package/esm/src/providers/openrouter/transcriptions-protocol.d.ts +10 -0
- package/esm/src/providers/openrouter/transcriptions-protocol.js +87 -0
- package/package.json +1 -1
- package/esm/src/kernel/registry/system-role.d.ts +0 -3
- package/esm/src/kernel/registry/system-role.js +0 -9
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { startTrace } from '../../observability/trace-span.js';
|
|
2
|
+
import type { DetachedToolTrace } from '../tools/background.js';
|
|
3
|
+
/** A detached call's record, written at its real end: a span in its turn's tree cannot outlive the turn. */
|
|
4
|
+
export declare function detachedTrace(args: {
|
|
5
|
+
traceparent: string;
|
|
6
|
+
write: (spans: ReturnType<ReturnType<typeof startTrace>['collect']>) => void | Promise<void>;
|
|
7
|
+
}): DetachedToolTrace;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { startTrace } from '../../observability/trace-span.js';
|
|
2
|
+
/** A detached call's record, written at its real end: a span in its turn's tree cannot outlive the turn. */
|
|
3
|
+
export function detachedTrace(args) {
|
|
4
|
+
let tree;
|
|
5
|
+
return {
|
|
6
|
+
open: (name, attributes) => {
|
|
7
|
+
tree = startTrace(name, {
|
|
8
|
+
...(attributes ? { attributes } : {}),
|
|
9
|
+
traceparent: args.traceparent,
|
|
10
|
+
});
|
|
11
|
+
return tree.root;
|
|
12
|
+
},
|
|
13
|
+
end: () => {
|
|
14
|
+
if (tree)
|
|
15
|
+
return args.write(tree.collect());
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -13,9 +13,11 @@ import { hostAgentModel, nestedTurnModel } from '../../provider-dispatch.js';
|
|
|
13
13
|
import { profileInputs, requireModelBinding } from '../../registry/catalog.js';
|
|
14
14
|
import { resolveTurnInRegistry } from '../../registry/resolve.js';
|
|
15
15
|
import { bindSystem } from '../../system-parts.js';
|
|
16
|
-
import {
|
|
16
|
+
import { assertBackgroundCoordinator } from '../../tools/background.js';
|
|
17
|
+
import { cloneTurnToolSnapshot, expandT1Policy, promoteTurnTools } from '../../tools/resolve.js';
|
|
17
18
|
import { keptReply, turnDoneOf } from '../../turn-events.js';
|
|
18
19
|
import { findLast } from '../../util/find-last.js';
|
|
20
|
+
import { detachedTrace } from '../background.js';
|
|
19
21
|
import { compactionMeter, compactionResult, compactorHistory, resolveCompactionTokens, shouldCompact, splitForCompaction, } from '../compaction.js';
|
|
20
22
|
import { endThrownSpan, endTurnSpan, guardrailAttributes, guardrailCheckAttributes, OutputFold, turnSpanOptions, } from '../turn-trace.js';
|
|
21
23
|
import { sumEventTokens, sumTurnTokens } from '../usage.js';
|
|
@@ -243,6 +245,7 @@ async function* emitTurn(args) {
|
|
|
243
245
|
generation,
|
|
244
246
|
trace: args.trace,
|
|
245
247
|
...(args.agents ? { agents: args.agents } : {}),
|
|
248
|
+
...(args.background ? { background: args.background } : {}),
|
|
246
249
|
});
|
|
247
250
|
args.outState.state = state;
|
|
248
251
|
const pre = yield* applyTurnStage({
|
|
@@ -304,6 +307,7 @@ async function* streamTurnEvents(ctx, profile, gen, provider, compactionSpec) {
|
|
|
304
307
|
provider,
|
|
305
308
|
trace: ctx.trace,
|
|
306
309
|
agents: ctx.agents,
|
|
310
|
+
background: ctx.background,
|
|
307
311
|
outState: ctx,
|
|
308
312
|
})) {
|
|
309
313
|
const attached = await maybeAttachAfter(event, ctx, gen, compactionSpec);
|
|
@@ -387,6 +391,22 @@ async function* runTurnInRegistry(registry, req, provider, sinkOverride) {
|
|
|
387
391
|
guardrails: ctx.known?.guardrails,
|
|
388
392
|
});
|
|
389
393
|
ctx.observability = policy;
|
|
394
|
+
const { background: service } = req;
|
|
395
|
+
if (service) {
|
|
396
|
+
ctx.background = {
|
|
397
|
+
service,
|
|
398
|
+
project: (event) => withPublicLabels(projectForObs(event, ctx.observability), ctx.known?.labels),
|
|
399
|
+
openTrace: () => detachedTrace({
|
|
400
|
+
traceparent: tree.root.traceparent(),
|
|
401
|
+
write: (spans) => writeTrace(sink, buildRecord({
|
|
402
|
+
spans,
|
|
403
|
+
policy,
|
|
404
|
+
canaries: ctx.canaries,
|
|
405
|
+
...(req.metadata ? { metadata: req.metadata } : {}),
|
|
406
|
+
}), policy),
|
|
407
|
+
}),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
390
410
|
try {
|
|
391
411
|
yield* runTracedTurn(ctx, provider);
|
|
392
412
|
}
|
|
@@ -434,6 +454,7 @@ async function* emitCancelledDoneAfterAbort(ctx) {
|
|
|
434
454
|
}
|
|
435
455
|
}
|
|
436
456
|
async function* runTurnBody(ctx, provider) {
|
|
457
|
+
assertBackgroundCoordinator(ctx.req.background, ctx.req.execution);
|
|
437
458
|
const checkStart = performance.now();
|
|
438
459
|
const sanitized = sanitizeTurnRequestWithEvents(ctx.req, ctx.registry.profiles.get(ctx.req.profile));
|
|
439
460
|
const checkMs = performance.now() - checkStart;
|
|
@@ -455,12 +476,14 @@ async function* runTurnBody(ctx, provider) {
|
|
|
455
476
|
throw sanitized.refusal;
|
|
456
477
|
const { profile, generation: gen } = resolveTurnInRegistry(ctx.registry, ctx.safe);
|
|
457
478
|
await expandT1Policy(ctx.registry.tools, gen.tools, profile, ctx.safe);
|
|
479
|
+
promoteTurnTools(ctx.registry.tools, gen.tools, ctx.safe.promoted);
|
|
458
480
|
if (ctx.compacting === 'self')
|
|
459
481
|
gen.tools = noTools();
|
|
460
482
|
gen.builtins = gen.tools.builtins;
|
|
461
483
|
if (gen.canary)
|
|
462
484
|
gen.canary = await profileCanary(profile.id, gen.resolvedSystem);
|
|
463
485
|
ctx.generation = gen;
|
|
486
|
+
ctx.root.set({ 'theorem.turn.system_lines': [...gen.systemLines] });
|
|
464
487
|
ctx.canary = gen.canary;
|
|
465
488
|
ctx.canaries.push(gen.canary);
|
|
466
489
|
const binding = profile.models[gen.model];
|
|
@@ -4,6 +4,7 @@ import type { OwnTools } from '../../../guardrails/tool-leak.js';
|
|
|
4
4
|
import type { GuardrailHit, TurnTaint } from '../../../guardrails/types.js';
|
|
5
5
|
import type { SpanHandle } from '../../../observability/trace-span.js';
|
|
6
6
|
import type { AgentCaller } from '../../tools/agent.js';
|
|
7
|
+
import type { ToolBackgroundSupport } from '../../tools/background.js';
|
|
7
8
|
import type { ToolRegistry } from '../../tools/registry.js';
|
|
8
9
|
import type { InteractionPart, ModelBinding, Profile, ResolvedGeneration, TurnEvent, TurnHistoryMessage, TurnRequest, TurnStop, TurnToolResult } from '../../types.js';
|
|
9
10
|
import type { ItemFailure } from './schema-validation.js';
|
|
@@ -21,6 +22,8 @@ interface StepExecutionState {
|
|
|
21
22
|
tools: ToolRegistry;
|
|
22
23
|
/** Runs the turn's agent tools; absent where none can run (a compactor's own turn). */
|
|
23
24
|
agents?: AgentCaller;
|
|
25
|
+
/** Absent where every tool runs inline: a nested turn, or no background service. */
|
|
26
|
+
background?: ToolBackgroundSupport;
|
|
24
27
|
trace: TurnTraceState;
|
|
25
28
|
currentHistory: TurnHistoryMessage[];
|
|
26
29
|
/** Where this turn begins in `currentHistory`: what came before is the conversation the host passed. */
|
|
@@ -109,6 +112,7 @@ declare function openTurnState(args: {
|
|
|
109
112
|
trace: TurnTraceState;
|
|
110
113
|
allEmittedEvents?: TurnEvent[];
|
|
111
114
|
agents?: AgentCaller;
|
|
115
|
+
background?: ToolBackgroundSupport;
|
|
112
116
|
}): StepExecutionState;
|
|
113
117
|
/** The history the next model call reads: this turn alone once a retry has cut it. */
|
|
114
118
|
declare function modelHistory(state: StepExecutionState): TurnHistoryMessage[];
|
|
@@ -43,6 +43,7 @@ function openTurnState(args) {
|
|
|
43
43
|
canaryScanned: new WeakSet(),
|
|
44
44
|
...(ownTools ? { ownTools } : {}),
|
|
45
45
|
...(args.agents ? { agents: args.agents } : {}),
|
|
46
|
+
...(args.background ? { background: args.background } : {}),
|
|
46
47
|
};
|
|
47
48
|
if (profile.type === 'text') {
|
|
48
49
|
appendUserInput(state, generation.input);
|
|
@@ -8,6 +8,14 @@ export interface StepOrder {
|
|
|
8
8
|
settle(callId: string): void;
|
|
9
9
|
wait: StepWait;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* A promise and the function that settles it. `Promise.withResolvers` would do, but the React
|
|
13
|
+
* package compiles the kernel against ES2023, which lacks it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function settleable<T>(): {
|
|
16
|
+
promise: Promise<T>;
|
|
17
|
+
resolve: (value: T) => void;
|
|
18
|
+
};
|
|
11
19
|
/**
|
|
12
20
|
* The order of a step's calls. Side by side, every call starts at once. One at a time,
|
|
13
21
|
* each starts when every call before it has settled. A call whose `pre_tool` answers `waitFor`
|
|
@@ -3,7 +3,7 @@ import { throwIfAborted } from '../../../guardrails/error.js';
|
|
|
3
3
|
* A promise and the function that settles it. `Promise.withResolvers` would do, but the React
|
|
4
4
|
* package compiles the kernel against ES2023, which lacks it.
|
|
5
5
|
*/
|
|
6
|
-
function settleable() {
|
|
6
|
+
export function settleable() {
|
|
7
7
|
let resolve = () => undefined;
|
|
8
8
|
const promise = new Promise((settle) => {
|
|
9
9
|
resolve = settle;
|
|
@@ -497,6 +497,7 @@ async function* handleModelCalls(outcome, generation, profile, state, system, {
|
|
|
497
497
|
const execute = (call) => forwardToolEvents(executeRegisteredTool({
|
|
498
498
|
tools: state.tools,
|
|
499
499
|
execution: generation.execution,
|
|
500
|
+
...(state.background ? { background: state.background } : {}),
|
|
500
501
|
invocation: {
|
|
501
502
|
model: generation.model,
|
|
502
503
|
input: generation.input,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { TraceSink } from '../../../observability/trace-sink.js';
|
|
2
2
|
import type { ProviderHostOptions } from '../../protocols/runtime.js';
|
|
3
3
|
import type { KernelRegistry } from '../../registry/kernel-registry.js';
|
|
4
|
+
import { type ToolBackgroundService } from '../../tools/background.js';
|
|
4
5
|
import { type PageToolExecution, type ToolExecutionCoordinator } from '../../tools/operation.js';
|
|
5
6
|
import type { KeyVault, LiveSession, SessionRequest } from '../../types.js';
|
|
6
7
|
export type { LiveSession, SessionRequest };
|
|
7
8
|
/** Options for opening a live session: the key vault, a provider's own settings, a WebSocket opener, how long a gated call waits for its decision, and the sign-in gate policy. */
|
|
8
9
|
export interface RunSessionOptions extends ProviderHostOptions {
|
|
9
10
|
execution?: ToolExecutionCoordinator;
|
|
11
|
+
background?: ToolBackgroundService;
|
|
10
12
|
pageExecution?: PageToolExecution;
|
|
11
13
|
/** The host's keys by slot; the session uses the slots its profile names. */
|
|
12
14
|
vault?: KeyVault;
|
|
@@ -21,6 +21,7 @@ import { DEFAULT_RESUMED_AFTER_MS } from '../../schema.js';
|
|
|
21
21
|
import { injectedStageEvent, runStage, stageEventFields, } from '../../stages.js';
|
|
22
22
|
import { profileAllowsInject, stageAbortStop } from '../../stop.js';
|
|
23
23
|
import { bindSystem } from '../../system-parts.js';
|
|
24
|
+
import { assertBackgroundCoordinator, } from '../../tools/background.js';
|
|
24
25
|
import { failedActivity, failureEvent } from '../../tools/events.js';
|
|
25
26
|
import { executeRegisteredTool, lapsedGateFailure, shownToolArguments, } from '../../tools/execute.js';
|
|
26
27
|
import { answerGatedCall, gateExpired, resolveGateTtlMs, resumeForAnswer, } from '../../tools/gate-answer.js';
|
|
@@ -47,7 +48,10 @@ function isReleased(held) {
|
|
|
47
48
|
return typeof held.state === 'object' && held.state.released === true;
|
|
48
49
|
}
|
|
49
50
|
function isSettledPhase(tool) {
|
|
50
|
-
return tool.phase === 'complete' ||
|
|
51
|
+
return (tool.phase === 'complete' ||
|
|
52
|
+
tool.phase === 'error' ||
|
|
53
|
+
tool.phase === 'gate' ||
|
|
54
|
+
tool.phase === 'background');
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* The provider's close after it warned of it (`goAway`): the session's last
|
|
@@ -116,6 +120,7 @@ function toTurnRequest(req) {
|
|
|
116
120
|
system: req.system,
|
|
117
121
|
builtInArgs: req.builtInArgs,
|
|
118
122
|
path: req.path,
|
|
123
|
+
conditions: req.conditions,
|
|
119
124
|
sessionPermissions: req.sessionPermissions,
|
|
120
125
|
signal: req.signal,
|
|
121
126
|
metadata: req.metadata,
|
|
@@ -337,6 +342,14 @@ function buildLiveSession(args) {
|
|
|
337
342
|
let wakeHost;
|
|
338
343
|
const includeMatch = resolveObservabilityPolicy(profile.observability).include
|
|
339
344
|
.guardrailMatchPreview;
|
|
345
|
+
const background = args.background && {
|
|
346
|
+
service: args.background,
|
|
347
|
+
project: (event) => projectGuardrailTurnEvent(withPublicLabels(event, profile.labels), includeMatch),
|
|
348
|
+
openTrace: (callId) => {
|
|
349
|
+
const { open, finish } = trace.toolRecord(callId);
|
|
350
|
+
return { open, end: finish };
|
|
351
|
+
},
|
|
352
|
+
};
|
|
340
353
|
let cycle = 'idle';
|
|
341
354
|
let cycleStep = 0;
|
|
342
355
|
/** What this cycle's tool results read from outside the host; a cycle starts clean, as a turn does. */
|
|
@@ -665,6 +678,7 @@ function buildLiveSession(args) {
|
|
|
665
678
|
tools: args.tools,
|
|
666
679
|
agents: args.agents,
|
|
667
680
|
execution: args.execution,
|
|
681
|
+
background,
|
|
668
682
|
profile,
|
|
669
683
|
name: held.name,
|
|
670
684
|
input,
|
|
@@ -1071,6 +1085,8 @@ function buildLiveSession(args) {
|
|
|
1071
1085
|
}
|
|
1072
1086
|
forward();
|
|
1073
1087
|
settleHeld(callId, held, readBack);
|
|
1088
|
+
if (settled.phase === 'background')
|
|
1089
|
+
return {};
|
|
1074
1090
|
return settled.phase === 'complete'
|
|
1075
1091
|
? { outputRaw: settled.output, ...(settled.awaiting ? { awaiting: true } : {}) }
|
|
1076
1092
|
: { failure: settled.failure };
|
|
@@ -1123,7 +1139,8 @@ async function openTracedSession(registry, req, options, trace) {
|
|
|
1123
1139
|
if (refusal)
|
|
1124
1140
|
throw refusal;
|
|
1125
1141
|
throwIfAborted(safe.signal);
|
|
1126
|
-
|
|
1142
|
+
assertBackgroundCoordinator(options.background, options.execution);
|
|
1143
|
+
const { profile, generation: gen0 } = resolveTurnInRegistry(registry, options.background ? { ...safe, background: options.background } : safe);
|
|
1127
1144
|
assertLiveProfile(profile);
|
|
1128
1145
|
const openingContext = req.context ? readSessionContext(profile, req.context) : undefined;
|
|
1129
1146
|
if (req.snapshot) {
|
|
@@ -1165,6 +1182,7 @@ async function openTracedSession(registry, req, options, trace) {
|
|
|
1165
1182
|
trace.setup(connection.setup);
|
|
1166
1183
|
return buildLiveSession({
|
|
1167
1184
|
execution: options.execution,
|
|
1185
|
+
...(options.background ? { background: options.background } : {}),
|
|
1168
1186
|
pageExecution: options.pageExecution,
|
|
1169
1187
|
tools: registry.tools,
|
|
1170
1188
|
profile,
|
|
@@ -143,6 +143,7 @@ class LiveTrace {
|
|
|
143
143
|
/** Attach the resolved request; frames are recorded from here on. */
|
|
144
144
|
bind(binding) {
|
|
145
145
|
this.bound = binding;
|
|
146
|
+
this.root.set({ 'theorem.turn.system_lines': [...binding.generation.systemLines] });
|
|
146
147
|
}
|
|
147
148
|
/** The adapter's `tapUpstream`: every frame sent, as it is sent. */
|
|
148
149
|
sent = (row) => {
|
package/esm/src/kernel/mod.d.ts
CHANGED
|
@@ -43,12 +43,13 @@ export type { MediaInputChannel } from './registry/catalog.js';
|
|
|
43
43
|
export { clampThinkingLevel, clampThinkingLevelForApiId, mediaChannelForMime, mediaKindForMime, mimeAllowed, mimeEssence, modelEntryByApiId, requireModelBinding, } from './registry/catalog.js';
|
|
44
44
|
export type { KernelRegistry } from './registry/kernel-registry.js';
|
|
45
45
|
export { createKernelRegistry } from './registry/kernel-registry.js';
|
|
46
|
-
export type { DecisionProfileDefinition, EmbeddingProfileDefinition, HostProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, } from './registry/profiles.js';
|
|
46
|
+
export type { DecisionProfileDefinition, EmbeddingProfileDefinition, HostProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, TranscriptionProfileDefinition, } from './registry/profiles.js';
|
|
47
47
|
export { createProfileRegistry, defineProfile } from './registry/profiles.js';
|
|
48
48
|
export { projectProfileObject, requireModelProfile } from './registry/resolve.js';
|
|
49
49
|
export type { SchemaRegistry } from './registry/schemas.js';
|
|
50
50
|
export { createSchemaRegistry } from './registry/schemas.js';
|
|
51
51
|
export { normalizeProfileInputsSlots, normalizeSlotDecl, normalizeSlots, slotValues, } from './registry/slots.js';
|
|
52
|
+
export { resolveTurnSystemPrompt } from './registry/system-prompt.js';
|
|
52
53
|
export type { CredentialContext, CredentialResolver, KeyCredential } from './registry/vault.js';
|
|
53
54
|
export type { AuthUnauthenticatedPolicy, CustomToolType, HttpMethod, StudioAuthType, ToolAccess, ToolAuthType, ToolPermission, ToolType, } from './schema.js';
|
|
54
55
|
export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
|
|
@@ -58,16 +59,18 @@ export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOut
|
|
|
58
59
|
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './stages.js';
|
|
59
60
|
export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
|
|
60
61
|
export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
|
|
62
|
+
export { systemLinesProblem } from './system-lines.js';
|
|
61
63
|
export { systemPromptProblem } from './system-parts.js';
|
|
62
64
|
export { activityLabelProblem } from './tools/activity-label.js';
|
|
63
65
|
export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
|
|
66
|
+
export type { ToolBackground, ToolBackgroundCall, ToolBackgroundHandle, ToolBackgroundService, } from './tools/background.js';
|
|
64
67
|
export { type AnsweredGate, answerGatedCall, GATE_DECISIONS, type GateAnswerRequest, type GateDecision, gateExpired, type HeldGatedCall, resolveGateTtlMs, sessionPermissionsAfterApproval, type ToolGateAuth, } from './tools/gate-answer.js';
|
|
65
68
|
export type { MemoryToolExecutionOptions } from './tools/memory-execution.js';
|
|
66
69
|
export { createMemoryToolExecution } from './tools/memory-execution.js';
|
|
67
70
|
export type { CredentialQuery, McpProtocolVersion, McpRpcResponse, ToolRegistry, } from './tools/mod.js';
|
|
68
71
|
export { askUserTool, authorizeToolReplay, coerceToolResultParts, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, executeRegisteredTool, formatToolResult, isUnsupportedMcpProtocolError, leanToolResultData, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, projectForModel, registerHarnessTools, resolveToolAuth, withCredentialQuery, } from './tools/mod.js';
|
|
69
|
-
export type { BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationUncertainty, } from './tools/operation.js';
|
|
70
|
-
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './tools/operation.js';
|
|
72
|
+
export type { BackgroundToolEvent, BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationReply, ToolOperationUncertainty, } from './tools/operation.js';
|
|
73
|
+
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './tools/operation.js';
|
|
71
74
|
export { jsonSchemaFromZod } from './tools/schema.js';
|
|
72
75
|
export { CredentialRefusedError } from './tools/signed-in-fetch.js';
|
|
73
76
|
export type { ModelToolResult, PageAnswer, ToolAuthConfig, ToolContext, ToolLabels, } from './tools/types.js';
|
package/esm/src/kernel/mod.js
CHANGED
|
@@ -30,17 +30,19 @@ export { createProfileRegistry, defineProfile } from './registry/profiles.js';
|
|
|
30
30
|
export { projectProfileObject, requireModelProfile } from './registry/resolve.js';
|
|
31
31
|
export { createSchemaRegistry } from './registry/schemas.js';
|
|
32
32
|
export { normalizeProfileInputsSlots, normalizeSlotDecl, normalizeSlots, slotValues, } from './registry/slots.js';
|
|
33
|
+
export { resolveTurnSystemPrompt } from './registry/system-prompt.js';
|
|
33
34
|
export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
|
|
34
35
|
export { createKernelScope, defaultKernelScope } from './scope.js';
|
|
35
36
|
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './stages.js';
|
|
36
37
|
export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
|
|
38
|
+
export { systemLinesProblem } from './system-lines.js';
|
|
37
39
|
export { systemPromptProblem } from './system-parts.js';
|
|
38
40
|
export { activityLabelProblem } from './tools/activity-label.js';
|
|
39
41
|
export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
|
|
40
42
|
export { answerGatedCall, GATE_DECISIONS, gateExpired, resolveGateTtlMs, sessionPermissionsAfterApproval, } from './tools/gate-answer.js';
|
|
41
43
|
export { createMemoryToolExecution } from './tools/memory-execution.js';
|
|
42
44
|
export { askUserTool, authorizeToolReplay, coerceToolResultParts, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, executeRegisteredTool, formatToolResult, isUnsupportedMcpProtocolError, leanToolResultData, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, projectForModel, registerHarnessTools, resolveToolAuth, withCredentialQuery, } from './tools/mod.js';
|
|
43
|
-
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './tools/operation.js';
|
|
45
|
+
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './tools/operation.js';
|
|
44
46
|
export { jsonSchemaFromZod } from './tools/schema.js';
|
|
45
47
|
export { CredentialRefusedError } from './tools/signed-in-fetch.js';
|
|
46
48
|
export { awaitingUserInputSchema, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './turn-events.js';
|
|
@@ -6,6 +6,7 @@ export const PROFILE_FIELD_PRESENCE = {
|
|
|
6
6
|
'profile.type': { required: true },
|
|
7
7
|
identity: { required: true },
|
|
8
8
|
'identity.handle': { required: true },
|
|
9
|
+
'identity.conditions': { unset: 'The turn states no conditions' },
|
|
9
10
|
'identity.system': { unset: "Only the kernel's notes" },
|
|
10
11
|
tools: { required: true },
|
|
11
12
|
'tools.allow': { required: true },
|
|
@@ -9,6 +9,7 @@ export const ALL_PROFILE_TYPES = [
|
|
|
9
9
|
'text',
|
|
10
10
|
'image',
|
|
11
11
|
'speech',
|
|
12
|
+
'transcription',
|
|
12
13
|
'live',
|
|
13
14
|
'decision',
|
|
14
15
|
'embedding',
|
|
@@ -18,6 +19,7 @@ const MODEL_PROFILE_TYPES = [
|
|
|
18
19
|
'text',
|
|
19
20
|
'image',
|
|
20
21
|
'speech',
|
|
22
|
+
'transcription',
|
|
21
23
|
'live',
|
|
22
24
|
'decision',
|
|
23
25
|
'embedding',
|
|
@@ -25,15 +27,15 @@ const MODEL_PROFILE_TYPES = [
|
|
|
25
27
|
const TURN_TYPES = ['text', 'image', 'speech', 'live'];
|
|
26
28
|
/** Types whose `inputs` are turn inputs (text, files, slots) rather than decision state. */
|
|
27
29
|
const TURN_INPUT_TYPES = ['text', 'image'];
|
|
28
|
-
const TURN_INPUT_REASON = 'a decision takes JSON state,
|
|
30
|
+
const TURN_INPUT_REASON = 'a decision takes JSON state, live takes its input through live.ingress, and transcription takes only a clip';
|
|
29
31
|
/** Types that take slots and context: the turn types, and a call. */
|
|
30
32
|
const SLOT_TYPES = ['text', 'image', 'live'];
|
|
31
|
-
const SLOT_REASON = 'a decision takes JSON state, and
|
|
33
|
+
const SLOT_REASON = 'a decision takes JSON state, and transcription and embedding calls take their input alone';
|
|
32
34
|
/** Guardrails a host profile may set keep `host`; the rest guard a model turn. */
|
|
33
35
|
function turnGuardrailTypes(key) {
|
|
34
36
|
return HOST_GUARDRAIL_FIELDS.includes(key)
|
|
35
|
-
? [...TURN_TYPES, 'host']
|
|
36
|
-
: TURN_TYPES;
|
|
37
|
+
? [...TURN_TYPES, 'transcription', 'host']
|
|
38
|
+
: [...TURN_TYPES, 'transcription'];
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* The profile's own settings, which no section holds. The catalog names each `profile.<key>`, as
|
|
@@ -77,11 +79,11 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
77
79
|
profileTypes: MODEL_PROFILE_TYPES,
|
|
78
80
|
reason: 'a host profile has no agent identity — it runs no model',
|
|
79
81
|
},
|
|
80
|
-
'identity.
|
|
82
|
+
'identity.conditions': {
|
|
81
83
|
profileTypes: ['text', 'image', 'live'],
|
|
82
84
|
reason: 'speech has no system channel (the input text is the transcript), a decision is asked only through its questions, and an embedding call embeds its input alone',
|
|
83
85
|
},
|
|
84
|
-
'identity.
|
|
86
|
+
'identity.system': {
|
|
85
87
|
profileTypes: ['text', 'image', 'live'],
|
|
86
88
|
reason: 'speech has no system channel (the input text is the transcript), a decision is asked only through its questions, and an embedding call embeds its input alone',
|
|
87
89
|
},
|
|
@@ -96,14 +98,14 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
96
98
|
},
|
|
97
99
|
'models.*.compaction': {
|
|
98
100
|
profileTypes: ['text', 'image', 'speech'],
|
|
99
|
-
reason: 'live compacts with live.contextCompression, and decision and embedding calls keep no conversation to compact',
|
|
101
|
+
reason: 'live compacts with live.contextCompression, and transcription, decision, and embedding calls keep no conversation to compact',
|
|
100
102
|
},
|
|
101
103
|
'profile.defaultModel': {
|
|
102
|
-
profileTypes: [...TURN_TYPES, 'embedding'],
|
|
104
|
+
profileTypes: [...TURN_TYPES, 'transcription', 'embedding'],
|
|
103
105
|
reason: 'a host profile runs no model and a decision declares exactly one',
|
|
104
106
|
},
|
|
105
107
|
'profile.allowModelSelect': {
|
|
106
|
-
profileTypes: [...TURN_TYPES, 'embedding'],
|
|
108
|
+
profileTypes: [...TURN_TYPES, 'transcription', 'embedding'],
|
|
107
109
|
reason: 'a host profile runs no model and a decision declares exactly one',
|
|
108
110
|
},
|
|
109
111
|
'profile.maxSteps': {
|
|
@@ -116,7 +118,7 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
116
118
|
live: { profileTypes: ['live'], reason: 'only live profiles open a realtime session' },
|
|
117
119
|
tools: {
|
|
118
120
|
profileTypes: ['text', 'image', 'live', 'host'],
|
|
119
|
-
reason: 'speech, decision, and embedding profiles call no tools',
|
|
121
|
+
reason: 'speech, transcription, decision, and embedding profiles call no tools',
|
|
120
122
|
},
|
|
121
123
|
'tools.t1Policy': {
|
|
122
124
|
profileTypes: ['text', 'image'],
|
|
@@ -127,15 +129,15 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
127
129
|
reason: 'live function declarations are fixed at session setup, and a host profile can execute every allowed tool',
|
|
128
130
|
},
|
|
129
131
|
inputs: {
|
|
130
|
-
profileTypes: ['text', 'image', 'live', 'decision', 'embedding'],
|
|
132
|
+
profileTypes: ['text', 'image', 'transcription', 'live', 'decision', 'embedding'],
|
|
131
133
|
reason: 'speech input is the transcript, and a host profile takes no turns',
|
|
132
134
|
},
|
|
133
135
|
'inputs.voice': {
|
|
134
|
-
profileTypes: ['text'],
|
|
136
|
+
profileTypes: ['text', 'transcription'],
|
|
135
137
|
reason: 'no image model reads audio, live takes audio through live.ingress, a decision takes JSON state, and an embedding call takes text and files',
|
|
136
138
|
},
|
|
137
139
|
'inputs.text': {
|
|
138
|
-
profileTypes: [...TURN_INPUT_TYPES, 'embedding'],
|
|
140
|
+
profileTypes: [...TURN_INPUT_TYPES, 'transcription', 'embedding'],
|
|
139
141
|
reason: TURN_INPUT_REASON,
|
|
140
142
|
},
|
|
141
143
|
'inputs.attachments': {
|
|
@@ -143,19 +145,19 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
143
145
|
reason: TURN_INPUT_REASON,
|
|
144
146
|
},
|
|
145
147
|
'inputs.maxFiles': {
|
|
146
|
-
profileTypes: [...TURN_INPUT_TYPES, 'embedding'],
|
|
148
|
+
profileTypes: [...TURN_INPUT_TYPES, 'transcription', 'embedding'],
|
|
147
149
|
reason: TURN_INPUT_REASON,
|
|
148
150
|
},
|
|
149
151
|
'inputs.maxBytes': {
|
|
150
|
-
profileTypes: [...TURN_INPUT_TYPES, 'embedding'],
|
|
152
|
+
profileTypes: [...TURN_INPUT_TYPES, 'transcription', 'embedding'],
|
|
151
153
|
reason: TURN_INPUT_REASON,
|
|
152
154
|
},
|
|
153
155
|
'inputs.maxTurnBytes': {
|
|
154
|
-
profileTypes: [...TURN_INPUT_TYPES, 'embedding'],
|
|
156
|
+
profileTypes: [...TURN_INPUT_TYPES, 'transcription', 'embedding'],
|
|
155
157
|
reason: TURN_INPUT_REASON,
|
|
156
158
|
},
|
|
157
159
|
'inputs.limitsByMime': {
|
|
158
|
-
profileTypes: [...TURN_INPUT_TYPES, 'embedding'],
|
|
160
|
+
profileTypes: [...TURN_INPUT_TYPES, 'transcription', 'embedding'],
|
|
159
161
|
reason: TURN_INPUT_REASON,
|
|
160
162
|
},
|
|
161
163
|
'inputs.slots': {
|
|
@@ -176,7 +178,7 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
176
178
|
},
|
|
177
179
|
outputs: {
|
|
178
180
|
profileTypes: ['text', 'image', 'speech'],
|
|
179
|
-
reason: 'live output is the realtime session, and decision, embedding, and host profiles produce no turn output',
|
|
181
|
+
reason: 'live output is the realtime session, a transcription gives back its text, and decision, embedding, and host profiles produce no turn output',
|
|
180
182
|
},
|
|
181
183
|
'outputs.structured': {
|
|
182
184
|
profileTypes: ['text'],
|
|
@@ -213,15 +215,15 @@ export const PROFILE_FIELD_SCOPE = {
|
|
|
213
215
|
},
|
|
214
216
|
'guardrails.blockedReply': {
|
|
215
217
|
profileTypes: ['text', 'image', 'live'],
|
|
216
|
-
reason: 'only a reply can be blocked, and speech, decision, embedding, and host profiles write none',
|
|
218
|
+
reason: 'only a reply can be blocked, and speech, transcription, decision, embedding, and host profiles write none',
|
|
217
219
|
},
|
|
218
220
|
'guardrails.network': {
|
|
219
221
|
profileTypes: ['text', 'image', 'live', 'host'],
|
|
220
|
-
reason: 'speech, decision, and embedding profiles call no tools',
|
|
222
|
+
reason: 'speech, transcription, decision, and embedding profiles call no tools',
|
|
221
223
|
},
|
|
222
224
|
'guardrails.taint': {
|
|
223
225
|
profileTypes: ['text', 'image', 'live'],
|
|
224
|
-
reason: 'speech, decision, and embedding profiles call no tools, and a host profile runs no turn to taint',
|
|
226
|
+
reason: 'speech, transcription, decision, and embedding profiles call no tools, and a host profile runs no turn to taint',
|
|
225
227
|
},
|
|
226
228
|
'guardrails.disclosure': {
|
|
227
229
|
profileTypes: ['decision'],
|
|
@@ -5,7 +5,7 @@ import type { ReasoningOrigin, ToolCallRequest } from '../turn-events.js';
|
|
|
5
5
|
import type { DecisionRequest, DecisionResult, EmbeddingInput, EmbeddingResult, EmbeddingTask, InteractionPart, ModelRequest, TurnContext, TurnEvent, TurnHistoryMessage, TurnResponse, TurnStop } from '../types.js';
|
|
6
6
|
import type { ProviderLimits } from './limits.js';
|
|
7
7
|
/** The kinds of profile a protocol can serve, each at its own endpoint: every type but `host`. */
|
|
8
|
-
declare const MODEL_PROFILE_TYPES: readonly ["text", "image", "speech", "live", "decision", "embedding"];
|
|
8
|
+
declare const MODEL_PROFILE_TYPES: readonly ["text", "image", "speech", "transcription", "live", "decision", "embedding"];
|
|
9
9
|
export type ModelProfileType = (typeof MODEL_PROFILE_TYPES)[number];
|
|
10
10
|
/** The turn events a protocol yields as they are. */
|
|
11
11
|
export type ProtocolContentEvent = Extract<TurnEvent, {
|
|
@@ -17,7 +17,10 @@ function mediaKindForMime(mime) {
|
|
|
17
17
|
return MEDIA_INPUT_KINDS[mimeEssence(mime)];
|
|
18
18
|
}
|
|
19
19
|
function profileInputs(profile) {
|
|
20
|
-
return profile.type === 'text' ||
|
|
20
|
+
return profile.type === 'text' ||
|
|
21
|
+
profile.type === 'image' ||
|
|
22
|
+
profile.type === 'transcription' ||
|
|
23
|
+
profile.type === 'live'
|
|
21
24
|
? profile.inputs
|
|
22
25
|
: undefined;
|
|
23
26
|
}
|
|
@@ -2,6 +2,8 @@ import type { ImageResponseFormat, InteractionPart, Profile, ProfileSpeechSpec,
|
|
|
2
2
|
/** Typed profiles already make mixed wire formats unrepresentable; this is a safety net. */
|
|
3
3
|
declare function assertOutputMode(profile: Profile, structuredId: string | null): void;
|
|
4
4
|
declare function assertSpeechRole(profile: Profile, req: TurnRequest): void;
|
|
5
|
+
/** A transcription turn has one job: a clip goes in. No system prompt reaches a model that follows none. */
|
|
6
|
+
declare function assertTranscriptionRole(profile: Profile, req: TurnRequest): void;
|
|
5
7
|
/** The profile's speech settings with this turn's laid over them. */
|
|
6
8
|
declare function resolveSpeech(profile: Profile, req: TurnRequest): ProfileSpeechSpec | undefined;
|
|
7
9
|
declare function resolveImageFormat(profile: Profile): ImageResponseFormat | null;
|
|
@@ -9,4 +11,4 @@ declare function resolveInputParts(profile: Profile, req: TurnRequest): Interact
|
|
|
9
11
|
declare function assertTurnSlots(profile: Profile, req: TurnRequest): void;
|
|
10
12
|
/** Refuses context from a sender the profile's `inputs.context` does not list, and a package over its `maxChars`. */
|
|
11
13
|
declare function assertTurnContext(profile: Profile, req: TurnRequest): void;
|
|
12
|
-
export { assertOutputMode, assertSpeechRole, assertTurnContext, assertTurnSlots, resolveImageFormat, resolveInputParts, resolveSpeech, };
|
|
14
|
+
export { assertOutputMode, assertSpeechRole, assertTranscriptionRole, assertTurnContext, assertTurnSlots, resolveImageFormat, resolveInputParts, resolveSpeech, };
|
|
@@ -41,6 +41,17 @@ function assertSpeechRole(profile, req) {
|
|
|
41
41
|
throw new TheoremError('config', `Profile ${profile.id} (speech) takes no system prompt — the input text is the transcript`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
/** A transcription turn has one job: a clip goes in. No system prompt reaches a model that follows none. */
|
|
45
|
+
function assertTranscriptionRole(profile, req) {
|
|
46
|
+
if (profile.type !== 'transcription')
|
|
47
|
+
return;
|
|
48
|
+
if (req.system) {
|
|
49
|
+
throw new TheoremError('config', `Profile ${profile.id} (transcription) takes no system prompt — the input is the clip`);
|
|
50
|
+
}
|
|
51
|
+
if (!req.input?.voice?.length) {
|
|
52
|
+
throw new TheoremError('request', `Profile ${profile.id} (transcription) requires a voice clip`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
/** The profile's speech settings with this turn's laid over them. */
|
|
45
56
|
function resolveSpeech(profile, req) {
|
|
46
57
|
return profile.type === 'speech'
|
|
@@ -178,4 +189,4 @@ function assertTurnContext(profile, req) {
|
|
|
178
189
|
}
|
|
179
190
|
}
|
|
180
191
|
}
|
|
181
|
-
export { assertOutputMode, assertSpeechRole, assertTurnContext, assertTurnSlots, resolveImageFormat, resolveInputParts, resolveSpeech, };
|
|
192
|
+
export { assertOutputMode, assertSpeechRole, assertTranscriptionRole, assertTurnContext, assertTurnSlots, resolveImageFormat, resolveInputParts, resolveSpeech, };
|
|
@@ -3,7 +3,7 @@ import { type DecisionGuardrailsSpec, type HostGuardrailsSpec, type ProfileGuard
|
|
|
3
3
|
import type { ProfileObservabilitySpec } from '../../observability/types.js';
|
|
4
4
|
import type { ProviderRegistry } from '../protocols/provider.js';
|
|
5
5
|
import type { ToolRegistry } from '../tools/registry.js';
|
|
6
|
-
import type { DecisionModelBinding, DecisionProfile, EmbeddingProfile, HostProfile, HostProfileToolsSpec, ImageInputsSpec, ImageProfile, LiveProfile, LiveProfileToolsSpec, MediaTurnBehaviourSpec, ModelBinding, ModelId, Profile, ProfileIdentity, ProfileInputsSpec, ProfileOutputsSpec, ProfileToolsSpec, ProfileTurnBehaviourSpec, SpeechProfile, TextProfile } from '../types.js';
|
|
6
|
+
import type { DecisionModelBinding, DecisionProfile, EmbeddingProfile, HostProfile, HostProfileToolsSpec, ImageInputsSpec, ImageProfile, LiveProfile, LiveProfileToolsSpec, MediaTurnBehaviourSpec, ModelBinding, ModelId, Profile, ProfileIdentity, ProfileInputsSpec, ProfileOutputsSpec, ProfileToolsSpec, ProfileTurnBehaviourSpec, SpeechProfile, TextProfile, TranscriptionInputsSpec, TranscriptionProfile } from '../types.js';
|
|
7
7
|
import type { SchemaRegistry } from './schemas.js';
|
|
8
8
|
/** Not shared by host profiles, which invoke tools without a model turn. */
|
|
9
9
|
export type ProfileDefinitionBase = {
|
|
@@ -47,6 +47,14 @@ export type SpeechProfileDefinition = Omit<ProfileDefinitionBase, 'identity'> &
|
|
|
47
47
|
speech: NonNullable<SpeechProfile['speech']>;
|
|
48
48
|
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
49
49
|
};
|
|
50
|
+
/** What a host writes to define a transcription profile. */
|
|
51
|
+
export type TranscriptionProfileDefinition = Omit<ProfileDefinitionBase, 'identity' | 'outputs' | 'maxSteps'> & {
|
|
52
|
+
type: 'transcription';
|
|
53
|
+
identity: TranscriptionProfile['identity'];
|
|
54
|
+
inputs: TranscriptionInputsSpec & {
|
|
55
|
+
text?: false;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
50
58
|
/** What a host writes to define a live profile. */
|
|
51
59
|
export type LiveProfileDefinition = ProfileDefinitionBase & {
|
|
52
60
|
type: 'live';
|
|
@@ -80,13 +88,15 @@ export type HostProfileDefinition = {
|
|
|
80
88
|
labels?: LabelOverrides;
|
|
81
89
|
};
|
|
82
90
|
/** Any profile definition, discriminated by `type`. */
|
|
83
|
-
export type ProfileDefinition = TextProfileDefinition | ImageProfileDefinition | SpeechProfileDefinition | LiveProfileDefinition | DecisionProfileDefinition | EmbeddingProfileDefinition | HostProfileDefinition;
|
|
91
|
+
export type ProfileDefinition = TextProfileDefinition | ImageProfileDefinition | SpeechProfileDefinition | LiveProfileDefinition | DecisionProfileDefinition | TranscriptionProfileDefinition | EmbeddingProfileDefinition | HostProfileDefinition;
|
|
84
92
|
/** Validate a definition and return the profile; throws on a malformed one. */
|
|
85
93
|
declare function defineProfile(input: TextProfileDefinition): TextProfile;
|
|
86
94
|
/** Validate an image definition and return the profile. */
|
|
87
95
|
declare function defineProfile(input: ImageProfileDefinition): ImageProfile;
|
|
88
96
|
/** Validate a speech definition and return the profile. */
|
|
89
97
|
declare function defineProfile(input: SpeechProfileDefinition): SpeechProfile;
|
|
98
|
+
/** Validate a transcription definition and return the profile. */
|
|
99
|
+
declare function defineProfile(input: TranscriptionProfileDefinition): TranscriptionProfile;
|
|
90
100
|
/** Validate a live definition and return the profile. */
|
|
91
101
|
declare function defineProfile(input: LiveProfileDefinition): LiveProfile;
|
|
92
102
|
/** Validate a decision definition and return the profile. */
|