@theoremjs/react 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +246 -2
- package/client/attachment-hover-preview.d.ts +11 -0
- package/client/attachment-hover-preview.js +36 -0
- package/client/audio-level.d.ts +5 -0
- package/client/audio-level.js +24 -0
- package/client/composer-attachments.d.ts +30 -0
- package/client/composer-attachments.js +33 -0
- package/client/composer-drawer.d.ts +19 -0
- package/client/composer-drawer.js +15 -0
- package/client/composer-hints.d.ts +25 -0
- package/client/composer-hints.js +20 -0
- package/client/composer-primary.d.ts +16 -0
- package/client/composer-primary.js +25 -0
- package/client/decision-transport.d.ts +48 -0
- package/client/decision-transport.js +102 -0
- package/client/decode-composer-draft.d.ts +11 -0
- package/client/decode-composer-draft.js +12 -0
- package/client/encode-composer-draft.d.ts +9 -0
- package/client/encode-composer-draft.js +34 -0
- package/client/encode-files.d.ts +18 -0
- package/client/encode-files.js +54 -0
- package/client/failure.d.ts +32 -0
- package/client/failure.js +34 -0
- package/client/generation-selection.d.ts +15 -0
- package/client/generation-selection.js +24 -0
- package/client/host-call.d.ts +51 -0
- package/client/host-call.js +42 -0
- package/client/host-transport.d.ts +68 -0
- package/client/host-transport.js +74 -0
- package/client/image-output.d.ts +6 -0
- package/client/image-output.js +13 -0
- package/client/index.d.ts +20 -0
- package/client/index.js +18 -0
- package/client/ink-waveform.d.ts +17 -0
- package/client/ink-waveform.js +69 -0
- package/client/live/apply-live-turn-tool-event.d.ts +14 -0
- package/client/live/apply-live-turn-tool-event.js +39 -0
- package/client/live/live-captions.d.ts +23 -0
- package/client/live/live-captions.js +70 -0
- package/client/live/live-mic-forward.d.ts +29 -0
- package/client/live/live-mic-forward.js +37 -0
- package/client/live/live-state.d.ts +11 -0
- package/client/live/live-state.js +20 -0
- package/client/live/live-tool.d.ts +11 -0
- package/client/live/live-tool.js +1 -0
- package/client/live/live-video.d.ts +10 -0
- package/client/live/live-video.js +71 -0
- package/client/live/run-live-tool-call.d.ts +17 -0
- package/client/live/run-live-tool-call.js +32 -0
- package/client/live-client.d.ts +141 -0
- package/client/live-client.js +638 -0
- package/client/live-errors.d.ts +2 -0
- package/client/live-errors.js +9 -0
- package/client/live-messages.d.ts +110 -0
- package/client/live-messages.js +67 -0
- package/client/mic-capture.d.ts +4 -0
- package/client/mic-capture.js +6 -0
- package/client/oauth-popup.d.ts +26 -0
- package/client/oauth-popup.js +30 -0
- package/client/pcm-downsample.d.ts +4 -0
- package/client/pcm-downsample.js +45 -0
- package/client/run-commit.d.ts +61 -0
- package/client/run-commit.js +124 -0
- package/client/run-session.d.ts +80 -0
- package/client/run-session.js +215 -0
- package/client/schema-fields.d.ts +63 -0
- package/client/schema-fields.js +178 -0
- package/client/shaped-data.d.ts +118 -0
- package/client/shaped-data.js +314 -0
- package/client/source-citations.d.ts +13 -0
- package/client/source-citations.js +56 -0
- package/client/state-fields.d.ts +16 -0
- package/client/state-fields.js +44 -0
- package/client/tool-result.d.ts +78 -0
- package/client/tool-result.js +275 -0
- package/client/tool-resume.d.ts +33 -0
- package/client/tool-resume.js +11 -0
- package/client/trace-feed.d.ts +13 -0
- package/client/trace-feed.js +18 -0
- package/client/trace-story.d.ts +163 -0
- package/client/trace-story.js +416 -0
- package/client/trace-view.d.ts +130 -0
- package/client/trace-view.js +293 -0
- package/client/transcript-groups.d.ts +114 -0
- package/client/transcript-groups.js +167 -0
- package/client/transcript-scroll.d.ts +7 -0
- package/client/transcript-scroll.js +6 -0
- package/client/transport.d.ts +176 -0
- package/client/transport.js +256 -0
- package/client/turn-client.d.ts +35 -0
- package/client/turn-client.js +93 -0
- package/client/voice-label.d.ts +2 -0
- package/client/voice-label.js +15 -0
- package/client/voice-recorder.d.ts +27 -0
- package/client/voice-recorder.js +165 -0
- package/client/walk-away.d.ts +34 -0
- package/client/walk-away.js +48 -0
- package/client/wire-line.d.ts +56 -0
- package/client/wire-line.js +90 -0
- package/client/worklets/mic-capture.js +16 -0
- package/components/InkWaveform.d.ts +10 -0
- package/components/InkWaveform.js +108 -0
- package/components/live/use-live-runner-controls.d.ts +48 -0
- package/components/live/use-live-runner-controls.js +100 -0
- package/components/live/use-live-runner-model.d.ts +45 -0
- package/components/live/use-live-runner-model.js +175 -0
- package/components/live/use-live-runner-ui.d.ts +65 -0
- package/components/live/use-live-runner-ui.js +159 -0
- package/components/live/use-live-session-client.d.ts +41 -0
- package/components/live/use-live-session-client.js +123 -0
- package/components/use-composer-voice.d.ts +28 -0
- package/components/use-composer-voice.js +90 -0
- package/components/use-editor-selection.d.ts +3 -0
- package/components/use-editor-selection.js +16 -0
- package/components/use-voice-playback.d.ts +16 -0
- package/components/use-voice-playback.js +68 -0
- package/hooks/use-described.d.ts +8 -0
- package/hooks/use-described.js +23 -0
- package/hooks/use-theorem-chat-actions.d.ts +75 -0
- package/hooks/use-theorem-chat-actions.js +265 -0
- package/hooks/use-theorem-chat-state.d.ts +66 -0
- package/hooks/use-theorem-chat-state.js +118 -0
- package/hooks/use-theorem-chat.d.ts +63 -0
- package/hooks/use-theorem-chat.js +340 -0
- package/hooks/use-theorem-decision.d.ts +23 -0
- package/hooks/use-theorem-decision.js +75 -0
- package/hooks/use-theorem-host.d.ts +44 -0
- package/hooks/use-theorem-host.js +117 -0
- package/hooks/use-theorem-interface.d.ts +19 -0
- package/hooks/use-theorem-interface.js +25 -0
- package/hooks/use-trace-records.d.ts +4 -0
- package/hooks/use-trace-records.js +7 -0
- package/index.d.ts +14 -0
- package/index.js +14 -0
- package/live.d.ts +8 -0
- package/live.js +10 -0
- package/package.json +73 -4
- package/server/credential-store.d.ts +24 -0
- package/server/credential-store.js +14 -0
- package/server/decision-handler.d.ts +34 -0
- package/server/decision-handler.js +55 -0
- package/server/handler.d.ts +114 -0
- package/server/handler.js +568 -0
- package/server/json-response.d.ts +2 -0
- package/server/json-response.js +7 -0
- package/server/mod.d.ts +16 -0
- package/server/mod.js +15 -0
- package/server/request-check.d.ts +16 -0
- package/server/request-check.js +34 -0
- package/server/session-store.d.ts +74 -0
- package/server/session-store.js +49 -0
- package/server/steer-inbox.d.ts +35 -0
- package/server/steer-inbox.js +52 -0
- package/server/walk-away.d.ts +22 -0
- package/server/walk-away.js +41 -0
- package/styles/ink-controls.css +134 -0
- package/ui/ChatComposerBar.d.ts +39 -0
- package/ui/ChatComposerBar.js +251 -0
- package/ui/ChatTranscript.d.ts +30 -0
- package/ui/ChatTranscript.js +474 -0
- package/ui/ConsoleFrame.d.ts +47 -0
- package/ui/ConsoleFrame.js +46 -0
- package/ui/DecisionAnswers.d.ts +15 -0
- package/ui/DecisionAnswers.js +102 -0
- package/ui/LiveRunner.d.ts +28 -0
- package/ui/LiveRunner.js +193 -0
- package/ui/SchemaFields.d.ts +10 -0
- package/ui/SchemaFields.js +122 -0
- package/ui/ShapedData.d.ts +11 -0
- package/ui/ShapedData.js +151 -0
- package/ui/SidePanel.d.ts +57 -0
- package/ui/SidePanel.js +50 -0
- package/ui/StateFields.d.ts +36 -0
- package/ui/StateFields.js +96 -0
- package/ui/TheoremChat.d.ts +71 -0
- package/ui/TheoremChat.js +146 -0
- package/ui/TheoremDecision.d.ts +38 -0
- package/ui/TheoremDecision.js +87 -0
- package/ui/TheoremHost.d.ts +38 -0
- package/ui/TheoremHost.js +150 -0
- package/ui/ToolGateCard.d.ts +28 -0
- package/ui/ToolGateCard.js +100 -0
- package/ui/ToolResult.d.ts +10 -0
- package/ui/ToolResult.js +60 -0
- package/ui/ToolResultCharts.d.ts +5 -0
- package/ui/ToolResultCharts.js +86 -0
- package/ui/TraceCharts.d.ts +13 -0
- package/ui/TraceCharts.js +235 -0
- package/ui/TraceGuardrails.d.ts +10 -0
- package/ui/TraceGuardrails.js +56 -0
- package/ui/TraceInspector.d.ts +6 -0
- package/ui/TraceInspector.js +189 -0
- package/ui/TraceInspectorPanel.d.ts +24 -0
- package/ui/TraceInspectorPanel.js +57 -0
- package/ui/TraceOverview.d.ts +34 -0
- package/ui/TraceOverview.js +96 -0
- package/ui/TraceSpanDetail.d.ts +10 -0
- package/ui/TraceSpanDetail.js +188 -0
- package/ui/TraceStory.d.ts +20 -0
- package/ui/TraceStory.js +107 -0
- package/ui/TraceValues.d.ts +36 -0
- package/ui/TraceValues.js +113 -0
- package/ui/TraceWaterfall.d.ts +13 -0
- package/ui/TraceWaterfall.js +132 -0
- package/ui/VoiceNote.d.ts +12 -0
- package/ui/VoiceNote.js +28 -0
- package/ui/built/theme.css +774 -0
- package/ui/built/theorem.d.ts +13 -0
- package/ui/built/theorem.js +631 -0
- package/ui/built/theorem.variants.d.ts +16 -0
- package/ui/disclosure-motion.d.ts +6 -0
- package/ui/disclosure-motion.js +163 -0
- package/ui/icons.d.ts +4 -0
- package/ui/icons.js +37 -0
- package/ui/index.d.ts +25 -0
- package/ui/index.js +29 -0
- package/ui/labels-provider.d.ts +16 -0
- package/ui/labels-provider.js +61 -0
- package/ui/labels.d.ts +1153 -0
- package/ui/labels.js +603 -0
- package/ui/theme.d.ts +10 -0
- package/ui/theme.js +13 -0
- package/ui/theorem-theme.d.ts +10 -0
- package/ui/theorem-theme.js +83 -0
- package/ui/trace-palette.d.ts +24 -0
- package/ui/trace-palette.js +24 -0
- package/ui/trace-patterns.d.ts +32 -0
- package/ui/trace-patterns.js +44 -0
- package/ui/transcript-copy-text.d.ts +4 -0
- package/ui/transcript-copy-text.js +39 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser side of a decision profile: what the host lets the page see of
|
|
3
|
+
* it, and the one call that asks its questions about some state.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { resolveObservabilityPolicy, traceRecordSchema, z, } from '@theoremjs/agents';
|
|
8
|
+
import { fetchJson } from "./transport.js";
|
|
9
|
+
import { checkWire } from "./wire-line.js";
|
|
10
|
+
/** A score level's name: its text, or the first text inside a structured entry. */
|
|
11
|
+
function entryLabel(entry, fallback) {
|
|
12
|
+
if (typeof entry === 'string')
|
|
13
|
+
return entry;
|
|
14
|
+
const entries = Array.isArray(entry) ? entry : Object.keys(entry);
|
|
15
|
+
return entries.length ? entryLabel(entries[0], fallback) : fallback;
|
|
16
|
+
}
|
|
17
|
+
/** The page's view of a decision profile and the questions its host asks. */
|
|
18
|
+
export function decisionInterface(profile, questions) {
|
|
19
|
+
return {
|
|
20
|
+
type: 'decision',
|
|
21
|
+
identity: { handle: profile.identity.handle },
|
|
22
|
+
contract: profile.decision.contract,
|
|
23
|
+
...(profile.inputs.maxStateBytes === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: { maxStateBytes: profile.inputs.maxStateBytes }),
|
|
26
|
+
questions: Object.entries(questions).map(([id, question]) => ({
|
|
27
|
+
id,
|
|
28
|
+
type: question.type,
|
|
29
|
+
labels: question.type === 'choice'
|
|
30
|
+
? Object.keys(question.criteria)
|
|
31
|
+
: question.type === 'score'
|
|
32
|
+
? question.criteria.map((entry, level) => entryLabel(entry, String(level)))
|
|
33
|
+
: [],
|
|
34
|
+
})),
|
|
35
|
+
...(profile.observability
|
|
36
|
+
? { observability: { record: resolveObservabilityPolicy(profile.observability).record } }
|
|
37
|
+
: {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const probability = z.number().min(0).max(1);
|
|
41
|
+
const probabilities = z
|
|
42
|
+
.record(z.string(), probability)
|
|
43
|
+
.refine((record) => Math.abs(Object.values(record).reduce((sum, value) => sum + value, 0) - 1) <= 0.001);
|
|
44
|
+
const answerSchema = z.discriminatedUnion('type', [
|
|
45
|
+
z.object({
|
|
46
|
+
type: z.literal('choice'),
|
|
47
|
+
choice: z.string(),
|
|
48
|
+
confidence: probability,
|
|
49
|
+
probabilities,
|
|
50
|
+
}),
|
|
51
|
+
z.object({ type: z.literal('noul'), noul: probability }),
|
|
52
|
+
z.object({
|
|
53
|
+
type: z.literal('score'),
|
|
54
|
+
score: z.number().nonnegative(),
|
|
55
|
+
confidence: probability,
|
|
56
|
+
legend: z.record(z.string(), z.string().min(1)),
|
|
57
|
+
probabilities,
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
60
|
+
const replySchema = z.object({
|
|
61
|
+
result: z.object({
|
|
62
|
+
model: z.string().min(1),
|
|
63
|
+
answers: z.record(z.string(), answerSchema),
|
|
64
|
+
usage: z
|
|
65
|
+
.object({
|
|
66
|
+
inputTokens: z.number().int().nonnegative(),
|
|
67
|
+
outputTokens: z.number().int().nonnegative(),
|
|
68
|
+
costUsd: z.number().nonnegative().optional(),
|
|
69
|
+
})
|
|
70
|
+
.optional(),
|
|
71
|
+
}),
|
|
72
|
+
traces: z.array(traceRecordSchema).optional(),
|
|
73
|
+
});
|
|
74
|
+
/** A host's decide reply, checked: the answers, and any trace records it delivers. */
|
|
75
|
+
export function readDecisionReply(raw) {
|
|
76
|
+
// lexicon-exempt: internal diagnostic; the user reads error.bad_response
|
|
77
|
+
return checkWire(replySchema, raw, 'the decision');
|
|
78
|
+
}
|
|
79
|
+
const describedSchema = z.object({
|
|
80
|
+
interface: z.object({
|
|
81
|
+
type: z.literal('decision'),
|
|
82
|
+
identity: z.object({ handle: z.string() }),
|
|
83
|
+
contract: z.string(),
|
|
84
|
+
maxStateBytes: z.number().optional(),
|
|
85
|
+
questions: z.array(z.object({
|
|
86
|
+
id: z.string(),
|
|
87
|
+
type: z.enum(['choice', 'noul', 'score']),
|
|
88
|
+
labels: z.array(z.string()),
|
|
89
|
+
})),
|
|
90
|
+
observability: z.object({ record: z.boolean() }).optional(),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
/** Transport for a host mounted with `createTheoremDecisionHandler`. Default endpoint `/api/decision`. */
|
|
94
|
+
export function createDecisionTransport(options = {}) {
|
|
95
|
+
const base = (options.endpoint ?? '/api/decision').replace(/\/$/, '');
|
|
96
|
+
return {
|
|
97
|
+
async describe(signal) {
|
|
98
|
+
return checkWire(describedSchema, await fetchJson(base, { signal }, options), 'the decision description').interface;
|
|
99
|
+
},
|
|
100
|
+
decide: async (state, signal) => readDecisionReply(await fetchJson(`${base}/decide`, { body: { state }, signal }, options)),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restore composer fields from a serializable pending `UserTurnDraft`.
|
|
3
|
+
*/
|
|
4
|
+
import type { UserTurnDraft } from '@theoremjs/agents/interface';
|
|
5
|
+
export type ComposerDraftFields = {
|
|
6
|
+
text: string;
|
|
7
|
+
files: File[];
|
|
8
|
+
voice: File[];
|
|
9
|
+
};
|
|
10
|
+
/** Map an encoded pending draft back into live composer file fields. */
|
|
11
|
+
export declare function composerFieldsFromDraft(draft: UserTurnDraft): ComposerDraftFields;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restore composer fields from a serializable pending `UserTurnDraft`.
|
|
3
|
+
*/
|
|
4
|
+
import { pendingAttachmentsToFiles } from "./encode-files.js";
|
|
5
|
+
/** Map an encoded pending draft back into live composer file fields. */
|
|
6
|
+
export function composerFieldsFromDraft(draft) {
|
|
7
|
+
return {
|
|
8
|
+
text: draft.text ?? '',
|
|
9
|
+
files: pendingAttachmentsToFiles(draft.attachments ?? []),
|
|
10
|
+
voice: pendingAttachmentsToFiles(draft.voice ?? []),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode composer fields into a serializable `UserTurnDraft` for pending intents.
|
|
3
|
+
*/
|
|
4
|
+
import type { UserTurnDraft } from '@theoremjs/agents/interface';
|
|
5
|
+
export declare function encodeComposerDraft(args: {
|
|
6
|
+
text: string;
|
|
7
|
+
pendingFiles?: readonly File[];
|
|
8
|
+
pendingVoice?: readonly File[];
|
|
9
|
+
}): Promise<UserTurnDraft>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode composer fields into a serializable `UserTurnDraft` for pending intents.
|
|
3
|
+
*/
|
|
4
|
+
import { encodeFiles } from "./encode-files.js";
|
|
5
|
+
export async function encodeComposerDraft(args) {
|
|
6
|
+
const text = args.text.trim();
|
|
7
|
+
const files = args.pendingFiles ?? [];
|
|
8
|
+
const voice = args.pendingVoice ?? [];
|
|
9
|
+
const encodedFiles = files.length ? await encodeFiles(files) : [];
|
|
10
|
+
const encodedVoice = voice.length ? await encodeFiles(voice) : [];
|
|
11
|
+
return {
|
|
12
|
+
...(text ? { text } : {}),
|
|
13
|
+
...(encodedFiles.length
|
|
14
|
+
? {
|
|
15
|
+
attachments: encodedFiles.map((blob, index) => ({
|
|
16
|
+
name: blob.name,
|
|
17
|
+
mimeType: blob.mimeType,
|
|
18
|
+
sizeBytes: files[index]?.size ?? 0,
|
|
19
|
+
data: blob.data,
|
|
20
|
+
})),
|
|
21
|
+
}
|
|
22
|
+
: {}),
|
|
23
|
+
...(encodedVoice.length
|
|
24
|
+
? {
|
|
25
|
+
voice: encodedVoice.map((blob, index) => ({
|
|
26
|
+
name: blob.name,
|
|
27
|
+
mimeType: blob.mimeType,
|
|
28
|
+
sizeBytes: voice[index]?.size ?? 0,
|
|
29
|
+
data: blob.data,
|
|
30
|
+
})),
|
|
31
|
+
}
|
|
32
|
+
: {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PendingAttachment, TranscriptBlock } from '@theoremjs/agents/interface';
|
|
2
|
+
export declare function filesToPending(files: readonly File[]): PendingAttachment[];
|
|
3
|
+
/**
|
|
4
|
+
* Rebuild `File`s from encoded pending attachments (stash / queue restore).
|
|
5
|
+
* Attachments without `data` cannot be restored and are skipped.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pendingAttachmentsToFiles(attachments: readonly PendingAttachment[]): File[];
|
|
8
|
+
export declare function encodeFiles(files: readonly File[]): Promise<Array<{
|
|
9
|
+
name: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
data: string;
|
|
12
|
+
}>>;
|
|
13
|
+
/** Copy encoded base64 onto matching user attachment/voice transcript blocks for UI preview. */
|
|
14
|
+
export declare function attachPreviewData(blocks: readonly TranscriptBlock[], attachments?: ReadonlyArray<{
|
|
15
|
+
data: string;
|
|
16
|
+
}>, voice?: ReadonlyArray<{
|
|
17
|
+
data: string;
|
|
18
|
+
}>): TranscriptBlock[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { base64ToBytes, bytesToBase64 } from '@theoremjs/agents/kernel';
|
|
2
|
+
export function filesToPending(files) {
|
|
3
|
+
return files.map((file) => ({
|
|
4
|
+
name: file.name,
|
|
5
|
+
mimeType: file.type || 'application/octet-stream',
|
|
6
|
+
sizeBytes: file.size,
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Rebuild `File`s from encoded pending attachments (stash / queue restore).
|
|
11
|
+
* Attachments without `data` cannot be restored and are skipped.
|
|
12
|
+
*/
|
|
13
|
+
export function pendingAttachmentsToFiles(attachments) {
|
|
14
|
+
const files = [];
|
|
15
|
+
for (const attachment of attachments) {
|
|
16
|
+
if (typeof attachment.data !== 'string' || attachment.data.length === 0)
|
|
17
|
+
continue;
|
|
18
|
+
const bytes = base64ToBytes(attachment.data);
|
|
19
|
+
const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
20
|
+
files.push(new File([buffer], attachment.name, {
|
|
21
|
+
type: attachment.mimeType || 'application/octet-stream',
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
return files;
|
|
25
|
+
}
|
|
26
|
+
export async function encodeFiles(files) {
|
|
27
|
+
const out = [];
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
out.push({
|
|
30
|
+
name: file.name,
|
|
31
|
+
mimeType: file.type || 'application/octet-stream',
|
|
32
|
+
data: bytesToBase64(new Uint8Array(await file.arrayBuffer())),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/** Copy encoded base64 onto matching user attachment/voice transcript blocks for UI preview. */
|
|
38
|
+
export function attachPreviewData(blocks, attachments, voice) {
|
|
39
|
+
let attachmentIndex = 0;
|
|
40
|
+
let voiceIndex = 0;
|
|
41
|
+
return blocks.map((block) => {
|
|
42
|
+
if (block.kind === 'user-attachment') {
|
|
43
|
+
const data = attachments?.[attachmentIndex]?.data;
|
|
44
|
+
attachmentIndex += 1;
|
|
45
|
+
return data !== undefined ? { ...block, data } : block;
|
|
46
|
+
}
|
|
47
|
+
if (block.kind === 'user-voice') {
|
|
48
|
+
const data = voice?.[voiceIndex]?.data;
|
|
49
|
+
voiceIndex += 1;
|
|
50
|
+
return data !== undefined ? { ...block, data } : block;
|
|
51
|
+
}
|
|
52
|
+
return block;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One failure, two worlds, in the browser: the builder reads `errorKind` and
|
|
3
|
+
* `errorInternal`; the user reads `error`, the profile's wording for it.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type ErrorKind, type LexiconOverrides } from '@theoremjs/agents';
|
|
8
|
+
import type { AttachmentValidationIssue, InterfaceTurnSession } from '@theoremjs/agents/interface';
|
|
9
|
+
export type ClientFailure = {
|
|
10
|
+
/** What the user reads: the host's wording, else the profile lexicon's for the failure. */
|
|
11
|
+
error: string;
|
|
12
|
+
errorKind: ErrorKind;
|
|
13
|
+
/** Raw detail for the builder; never shown to the user. */
|
|
14
|
+
errorInternal?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Word a caught value for the user with the profile's `lexicon` (the interface's
|
|
18
|
+
* `lexicon`). A host-reported failure keeps the host's wording.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clientFailure(err: unknown, lexicon?: LexiconOverrides): ClientFailure;
|
|
21
|
+
/** A turn that did not run or did not finish. */
|
|
22
|
+
export type TurnFailure = ClientFailure & {
|
|
23
|
+
ok: false;
|
|
24
|
+
/** The files the profile refused, one entry per reason (the kernel's check). */
|
|
25
|
+
issues?: AttachmentValidationIssue[];
|
|
26
|
+
/** The user stopped it; nothing to show. */
|
|
27
|
+
aborted?: boolean;
|
|
28
|
+
/** The conversation with what the turn got through before it stopped; the next turn resumes from it. */
|
|
29
|
+
session?: InterfaceTurnSession;
|
|
30
|
+
};
|
|
31
|
+
/** A caught value as a turn failure; an aborted `signal` marks it the user's stop. */
|
|
32
|
+
export declare function turnFailure(err: unknown, lexicon?: LexiconOverrides, signal?: AbortSignal): TurnFailure;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One failure, two worlds, in the browser: the builder reads `errorKind` and
|
|
3
|
+
* `errorInternal`; the user reads `error`, the profile's wording for it.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { describeError, errorKind, lexiconText, publicError, } from '@theoremjs/agents';
|
|
8
|
+
import { isTheoremStreamError } from "./transport.js";
|
|
9
|
+
/**
|
|
10
|
+
* Word a caught value for the user with the profile's `lexicon` (the interface's
|
|
11
|
+
* `lexicon`). A host-reported failure keeps the host's wording.
|
|
12
|
+
*/
|
|
13
|
+
export function clientFailure(err, lexicon) {
|
|
14
|
+
if (isTheoremStreamError(err)) {
|
|
15
|
+
return {
|
|
16
|
+
error: err.publicMessage ?? lexiconText(`error.${err.kind}`, {}, lexicon),
|
|
17
|
+
errorKind: err.kind,
|
|
18
|
+
...(err.internalMessage ? { errorInternal: err.internalMessage } : {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const error = publicError(err, lexicon);
|
|
22
|
+
const internal = describeError(err);
|
|
23
|
+
return {
|
|
24
|
+
error,
|
|
25
|
+
errorKind: errorKind(err),
|
|
26
|
+
...(internal && internal !== error ? { errorInternal: internal } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** A caught value as a turn failure; an aborted `signal` marks it the user's stop. */
|
|
30
|
+
export function turnFailure(err, lexicon, signal) {
|
|
31
|
+
const failure = clientFailure(err, lexicon);
|
|
32
|
+
const aborted = failure.errorKind === 'cancelled' || signal?.aborted === true;
|
|
33
|
+
return { ok: false, ...failure, ...(aborted ? { aborted: true } : {}) };
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComposerProfileInterface } from '@theoremjs/agents/interface';
|
|
2
|
+
/** A model and effort for the next turn. */
|
|
3
|
+
export type GenerationSelection = {
|
|
4
|
+
model?: string;
|
|
5
|
+
effort?: string;
|
|
6
|
+
};
|
|
7
|
+
/** The profile's default model (its first, when it names none). */
|
|
8
|
+
export declare function defaultModel(iface: ComposerProfileInterface): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The selection for `iface`, given what was `selected` under the `previous` interface (none on
|
|
11
|
+
* first load). A pick that was on the previous default follows the new one, and a pick `iface` no
|
|
12
|
+
* longer has falls back to its default; any other pick is kept. Model and effort are each judged
|
|
13
|
+
* this way, the effort against its model's default, and a new model takes its own default effort.
|
|
14
|
+
*/
|
|
15
|
+
export declare function followGenerationDefaults(iface: ComposerProfileInterface, selected: GenerationSelection, previous: ComposerProfileInterface | undefined): GenerationSelection;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defaultInterfaceEffort } from '@theoremjs/agents/interface';
|
|
2
|
+
/** The profile's default model (its first, when it names none). */
|
|
3
|
+
export function defaultModel(iface) {
|
|
4
|
+
return iface.defaultModel ?? Object.keys(iface.models)[0];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The selection for `iface`, given what was `selected` under the `previous` interface (none on
|
|
8
|
+
* first load). A pick that was on the previous default follows the new one, and a pick `iface` no
|
|
9
|
+
* longer has falls back to its default; any other pick is kept. Model and effort are each judged
|
|
10
|
+
* this way, the effort against its model's default, and a new model takes its own default effort.
|
|
11
|
+
*/
|
|
12
|
+
export function followGenerationDefaults(iface, selected, previous) {
|
|
13
|
+
const keepModel = selected.model !== undefined &&
|
|
14
|
+
Object.hasOwn(iface.models, selected.model) &&
|
|
15
|
+
(previous === undefined || selected.model !== defaultModel(previous));
|
|
16
|
+
const model = keepModel ? selected.model : defaultModel(iface);
|
|
17
|
+
const efforts = model === undefined ? undefined : iface.models[model]?.efforts;
|
|
18
|
+
const keepEffort = model === selected.model &&
|
|
19
|
+
selected.effort !== undefined &&
|
|
20
|
+
efforts !== undefined &&
|
|
21
|
+
Object.hasOwn(efforts, selected.effort) &&
|
|
22
|
+
(previous === undefined || selected.effort !== defaultInterfaceEffort(previous, model));
|
|
23
|
+
return { model, effort: keepEffort ? selected.effort : defaultInterfaceEffort(iface, model) };
|
|
24
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A host call's standing, read from its folded state: the phase it's in, and
|
|
3
|
+
* what to say when it failed.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { TranscriptBlock } from '@theoremjs/agents/interface';
|
|
8
|
+
import type { ClientFailure } from './failure.ts';
|
|
9
|
+
import { type JsonSchema } from './schema-fields.ts';
|
|
10
|
+
export type ToolCall = Extract<TranscriptBlock, {
|
|
11
|
+
kind: 'tool';
|
|
12
|
+
}>['tool'];
|
|
13
|
+
export type HostCallStatus = 'running' | 'gate' | 'complete' | 'error' | 'cancel';
|
|
14
|
+
/** What a call's standing reads from. */
|
|
15
|
+
export type HostCallState = {
|
|
16
|
+
call: ToolCall | null;
|
|
17
|
+
failure: ClientFailure | null;
|
|
18
|
+
isRunning: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** The phase a call is in; a stream that broke is an error, one that stopped short a cancel. */
|
|
21
|
+
export declare function hostCallStatus({ call, failure, isRunning }: HostCallState): HostCallStatus;
|
|
22
|
+
/** Why a call failed, as a banner reads it: it never reached its tool, or the tool failed. */
|
|
23
|
+
export declare function hostCallFailure({ call, failure }: HostCallState): {
|
|
24
|
+
title: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/** What the console shows: the picked tool, its request text, its call on show, and the calls before it. */
|
|
28
|
+
export type HostConsoleView<Tool, Call> = {
|
|
29
|
+
tool: Tool | undefined;
|
|
30
|
+
text: string;
|
|
31
|
+
shown: Call | null;
|
|
32
|
+
earlier: Call[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The console's view of its state. An unknown pick falls back to the first
|
|
36
|
+
* tool; a tool's request is its draft, else a sample of its schema; the call on
|
|
37
|
+
* show is the one opened from history, else the tool's latest.
|
|
38
|
+
*/
|
|
39
|
+
export declare function hostConsoleView<Tool extends {
|
|
40
|
+
name: string;
|
|
41
|
+
inputSchema: JsonSchema;
|
|
42
|
+
}, Call extends {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
}>(args: {
|
|
46
|
+
tools: readonly Tool[];
|
|
47
|
+
picked: string | undefined;
|
|
48
|
+
drafts: Readonly<Record<string, string>>;
|
|
49
|
+
calls: readonly Call[];
|
|
50
|
+
shownId: string | null;
|
|
51
|
+
}): HostConsoleView<Tool, Call>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A host call's standing, read from its folded state: the phase it's in, and
|
|
3
|
+
* what to say when it failed.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { sampleFromSchema } from "./schema-fields.js";
|
|
8
|
+
import { json } from "./shaped-data.js";
|
|
9
|
+
const SETTLED = new Set(['gate', 'complete', 'error', 'cancel']);
|
|
10
|
+
/** The phase a call is in; a stream that broke is an error, one that stopped short a cancel. */
|
|
11
|
+
export function hostCallStatus({ call, failure, isRunning }) {
|
|
12
|
+
const phase = call?.state?.phase;
|
|
13
|
+
if (phase !== undefined && SETTLED.has(phase))
|
|
14
|
+
return phase;
|
|
15
|
+
if (failure)
|
|
16
|
+
return 'error';
|
|
17
|
+
return isRunning ? 'running' : 'cancel';
|
|
18
|
+
}
|
|
19
|
+
/** Why a call failed, as a banner reads it: it never reached its tool, or the tool failed. */
|
|
20
|
+
export function hostCallFailure({ call, failure }) {
|
|
21
|
+
if (failure)
|
|
22
|
+
return { title: failure.error };
|
|
23
|
+
const state = call?.state;
|
|
24
|
+
if (state?.phase !== 'error')
|
|
25
|
+
return null;
|
|
26
|
+
const { error, message } = state.failure;
|
|
27
|
+
if (!error)
|
|
28
|
+
return { title: message };
|
|
29
|
+
return error === message ? { title: error } : { title: error, description: message };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The console's view of its state. An unknown pick falls back to the first
|
|
33
|
+
* tool; a tool's request is its draft, else a sample of its schema; the call on
|
|
34
|
+
* show is the one opened from history, else the tool's latest.
|
|
35
|
+
*/
|
|
36
|
+
export function hostConsoleView(args) {
|
|
37
|
+
const tool = args.tools.find((candidate) => candidate.name === args.picked) ?? args.tools[0];
|
|
38
|
+
const text = tool ? (args.drafts[tool.name] ?? json(sampleFromSchema(tool.inputSchema))) : '';
|
|
39
|
+
const ofTool = args.calls.filter((call) => call.name === tool?.name);
|
|
40
|
+
const shown = ofTool.find((call) => call.id === args.shownId) ?? ofTool[0] ?? null;
|
|
41
|
+
return { tool, text, shown, earlier: args.calls.filter((call) => call !== shown) };
|
|
42
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser side of a host profile: the tools the host lets the page call,
|
|
3
|
+
* each with the schemas its request and response are drawn from, and the calls
|
|
4
|
+
* themselves, streamed as the kernel runs them.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { type Profile, type ToolAccess, type ToolPermission, z } from '@theoremjs/agents';
|
|
9
|
+
import type { TraceFeed } from './trace-feed.ts';
|
|
10
|
+
import { type HttpOptions, type TheoremInvokeRequest, type TurnEventSink } from './transport.ts';
|
|
11
|
+
/** How a tool reaches its work: a function on the host, an HTTP endpoint, or an MCP server. */
|
|
12
|
+
export declare const HOST_TOOL_KINDS: readonly ["function", "http", "mcp"];
|
|
13
|
+
export type HostToolKind = (typeof HOST_TOOL_KINDS)[number];
|
|
14
|
+
/** One tool as the page sees it. Its endpoint, headers, and credentials stay on the host. */
|
|
15
|
+
export type HostToolView = {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
kind: HostToolKind;
|
|
19
|
+
access: ToolAccess;
|
|
20
|
+
permission: ToolPermission;
|
|
21
|
+
/** JSON Schema for the call's input: the form is drawn from it. */
|
|
22
|
+
inputSchema: Record<string, unknown>;
|
|
23
|
+
/** JSON Schema for the tool's output: the result is laid out from it. */
|
|
24
|
+
outputSchema: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
/** What a host profile shows the page. */
|
|
27
|
+
export type HostInterface = {
|
|
28
|
+
type: 'host';
|
|
29
|
+
id: string;
|
|
30
|
+
tools: HostToolView[];
|
|
31
|
+
observability?: {
|
|
32
|
+
record: boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/** A tool as registered: the fields the page's view keeps. */
|
|
36
|
+
export type HostToolSource = {
|
|
37
|
+
type: string;
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
access: ToolAccess;
|
|
41
|
+
permission: ToolPermission;
|
|
42
|
+
inputSchema: Record<string, unknown>;
|
|
43
|
+
outputSchema: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
/** The page's view of a host profile: its allowed tools, in the order it allows them. */
|
|
46
|
+
export declare function hostInterface(profile: Pick<Extract<Profile, {
|
|
47
|
+
type: 'host';
|
|
48
|
+
}>, 'id' | 'tools' | 'observability'>, tools: (name: string) => HostToolSource | undefined): HostInterface;
|
|
49
|
+
/** One call of one of the host's tools. */
|
|
50
|
+
export type TheoremHostCallRequest = {
|
|
51
|
+
name: string;
|
|
52
|
+
input: unknown;
|
|
53
|
+
};
|
|
54
|
+
/** A `/call` body as `createTheoremHostHandler` reads it. */
|
|
55
|
+
export declare const theoremHostCallRequestSchema: z.ZodType<TheoremHostCallRequest>;
|
|
56
|
+
export interface HostTransport {
|
|
57
|
+
describe(signal?: AbortSignal): Promise<HostInterface>;
|
|
58
|
+
/** Runs one tool; its events stream to `onEvent`, ending in `done`. */
|
|
59
|
+
call(request: TheoremHostCallRequest, onEvent: TurnEventSink, signal?: AbortSignal): Promise<void>;
|
|
60
|
+
/** The user's answer to a call the host paused on a gate. */
|
|
61
|
+
invoke(request: TheoremInvokeRequest, onEvent: TurnEventSink, signal?: AbortSignal): Promise<void>;
|
|
62
|
+
/** Where the host's trace records land, for the inspector. */
|
|
63
|
+
traces?: TraceFeed;
|
|
64
|
+
}
|
|
65
|
+
/** Transport for a host mounted with `createTheoremHostHandler`. Default endpoint `/api/host`. */
|
|
66
|
+
export declare function createHostTransport(options?: HttpOptions & {
|
|
67
|
+
endpoint?: string;
|
|
68
|
+
}): HostTransport;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser side of a host profile: the tools the host lets the page call,
|
|
3
|
+
* each with the schemas its request and response are drawn from, and the calls
|
|
4
|
+
* themselves, streamed as the kernel runs them.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { resolveObservabilityPolicy, TOOL_ACCESS, TOOL_PERMISSION, TURN_EVENT_SCHEMAS, z, } from '@theoremjs/agents';
|
|
9
|
+
import { fetchJson, postNdjson, } from "./transport.js";
|
|
10
|
+
import { checkWire } from "./wire-line.js";
|
|
11
|
+
/** How a tool reaches its work: a function on the host, an HTTP endpoint, or an MCP server. */
|
|
12
|
+
export const HOST_TOOL_KINDS = ['function', 'http', 'mcp'];
|
|
13
|
+
function isHostToolKind(type) {
|
|
14
|
+
return HOST_TOOL_KINDS.includes(type);
|
|
15
|
+
}
|
|
16
|
+
/** The page's view of a host profile: its allowed tools, in the order it allows them. */
|
|
17
|
+
export function hostInterface(profile, tools) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'host',
|
|
20
|
+
id: profile.id,
|
|
21
|
+
tools: profile.tools.allow.flatMap((name) => {
|
|
22
|
+
const tool = tools(name);
|
|
23
|
+
if (!tool || !isHostToolKind(tool.type))
|
|
24
|
+
return [];
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
name: tool.name,
|
|
28
|
+
description: tool.description,
|
|
29
|
+
kind: tool.type,
|
|
30
|
+
access: tool.access,
|
|
31
|
+
permission: tool.permission,
|
|
32
|
+
inputSchema: tool.inputSchema,
|
|
33
|
+
outputSchema: tool.outputSchema,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}),
|
|
37
|
+
...(profile.observability
|
|
38
|
+
? { observability: { record: resolveObservabilityPolicy(profile.observability).record } }
|
|
39
|
+
: {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const theoremHostCallRequest = z.object({ name: z.string().min(1).max(128), input: z.unknown() });
|
|
43
|
+
true;
|
|
44
|
+
/** A `/call` body as `createTheoremHostHandler` reads it. */
|
|
45
|
+
export const theoremHostCallRequestSchema = theoremHostCallRequest;
|
|
46
|
+
const schemaObject = z.record(z.string(), z.unknown());
|
|
47
|
+
const describedSchema = z.object({
|
|
48
|
+
interface: z.object({
|
|
49
|
+
type: z.literal('host'),
|
|
50
|
+
id: z.string(),
|
|
51
|
+
tools: z.array(z.object({
|
|
52
|
+
name: z.string(),
|
|
53
|
+
description: z.string(),
|
|
54
|
+
kind: z.enum(HOST_TOOL_KINDS),
|
|
55
|
+
access: z.enum(TOOL_ACCESS),
|
|
56
|
+
permission: z.enum(TOOL_PERMISSION),
|
|
57
|
+
inputSchema: schemaObject,
|
|
58
|
+
outputSchema: schemaObject,
|
|
59
|
+
})),
|
|
60
|
+
observability: z.object({ record: z.boolean() }).optional(),
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
/** Transport for a host mounted with `createTheoremHostHandler`. Default endpoint `/api/host`. */
|
|
64
|
+
export function createHostTransport(options = {}) {
|
|
65
|
+
const base = (options.endpoint ?? '/api/host').replace(/\/$/, '');
|
|
66
|
+
return {
|
|
67
|
+
async describe(signal) {
|
|
68
|
+
// lexicon-exempt: internal diagnostic; the user reads error.bad_response
|
|
69
|
+
return checkWire(describedSchema, await fetchJson(base, { signal }, options), 'the host description').interface;
|
|
70
|
+
},
|
|
71
|
+
call: (body, onEvent, signal) => postNdjson(`${base}/call`, body, TURN_EVENT_SCHEMAS, onEvent, { ...options, signal }),
|
|
72
|
+
invoke: ({ replay: _replay, ...body }, onEvent, signal) => postNdjson(`${base}/invoke`, body, TURN_EVENT_SCHEMAS, onEvent, { ...options, signal }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Display helpers for image-profile output. */
|
|
2
|
+
/**
|
|
3
|
+
* Profile `image.aspectRatio` (`"16:9"`) as width / height, for Astryx
|
|
4
|
+
* `AspectRatio`. Undefined when unset or malformed — the provider picks.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseAspectRatio(value: string | undefined): number | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Display helpers for image-profile output. */
|
|
2
|
+
/**
|
|
3
|
+
* Profile `image.aspectRatio` (`"16:9"`) as width / height, for Astryx
|
|
4
|
+
* `AspectRatio`. Undefined when unset or malformed — the provider picks.
|
|
5
|
+
*/
|
|
6
|
+
export function parseAspectRatio(value) {
|
|
7
|
+
const match = value?.trim().match(/^(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)$/);
|
|
8
|
+
if (!match)
|
|
9
|
+
return undefined;
|
|
10
|
+
const width = Number(match[1]);
|
|
11
|
+
const height = Number(match[2]);
|
|
12
|
+
return width > 0 && height > 0 ? width / height : undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { float32Rms, float32RmsToLevel, INPUT_LEVEL_GAIN, timeDomainBytesToLevel, } from './audio-level.ts';
|
|
2
|
+
export { createDecisionTransport, type DecisionInterface, decisionInterface, type DecisionQuestionView, type DecisionReply, type DecisionTransport, readDecisionReply, } from './decision-transport.ts';
|
|
3
|
+
export { filesToPending, pendingAttachmentsToFiles } from './encode-files.ts';
|
|
4
|
+
export { createHostTransport, HOST_TOOL_KINDS, type HostInterface, hostInterface, type HostToolKind, type HostToolSource, type HostToolView, type HostTransport, type TheoremHostCallRequest, } from './host-transport.ts';
|
|
5
|
+
export { layoutResult, type ResultChart, type ResultFigure, type ResultImage, type ResultLayout } from './tool-result.ts';
|
|
6
|
+
export { type JsonSchema, sampleFromSchema, type SchemaControl, type SchemaField, schemaControl, schemaFields } from './schema-fields.ts';
|
|
7
|
+
export { composerFieldsFromDraft, type ComposerDraftFields } from './decode-composer-draft.ts';
|
|
8
|
+
export { encodeComposerDraft } from './encode-composer-draft.ts';
|
|
9
|
+
export { type ClientFailure, clientFailure, type TurnFailure } from './failure.ts';
|
|
10
|
+
export { type LiveConnectPhase, type LiveSessionStatus, type LiveState, liveState, } from './live/live-state.ts';
|
|
11
|
+
export type { LiveToolGatePrompt } from './live/live-tool.ts';
|
|
12
|
+
export { LiveSessionClient } from './live-client.ts';
|
|
13
|
+
export { isOAuthComplete, notifyOAuthComplete } from './oauth-popup.ts';
|
|
14
|
+
export { applyTurnResultToTranscript, resumeInterfaceTool, type StreamView, streamInterfaceDraftTurn, streamInterfaceTurn, } from './run-session.ts';
|
|
15
|
+
export type { AnsweringGate, ToolDecisionAction, ToolGateResolution, } from './tool-resume.ts';
|
|
16
|
+
export { continueGatedToolInvocation, } from './tool-resume.ts';
|
|
17
|
+
export { citationsFromBlock, type SourceCitation, type SourceCitationBlock } from './source-citations.ts';
|
|
18
|
+
export { createTraceFeed, type TraceFeed } from './trace-feed.ts';
|
|
19
|
+
export { buildInvokeRequest, buildTurnRequest, turnInputFromSession, type WalkAway } from './turn-client.ts';
|
|
20
|
+
export { type ClientTurnEvent, createHttpTransport, type HostErrorBody, type HttpOptions, type HttpTransportOptions, isTheoremStreamError, type MalformedEvent, postJson, postNdjson, readNdjsonStream, type TheoremInvokeRequest, type TheoremReplay, type TheoremSteerRequest, TheoremStreamError, type TheoremTransport, type TheoremTurnInput, type TheoremTurnRequest, type TurnEventSink, type UnsupportedEvent, type WireLines, } from './transport.ts';
|
package/client/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { float32Rms, float32RmsToLevel, INPUT_LEVEL_GAIN, timeDomainBytesToLevel, } from "./audio-level.js";
|
|
2
|
+
export { createDecisionTransport, decisionInterface, readDecisionReply, } from "./decision-transport.js";
|
|
3
|
+
export { filesToPending, pendingAttachmentsToFiles } from "./encode-files.js";
|
|
4
|
+
export { createHostTransport, HOST_TOOL_KINDS, hostInterface, } from "./host-transport.js";
|
|
5
|
+
export { layoutResult } from "./tool-result.js";
|
|
6
|
+
export { sampleFromSchema, schemaControl, schemaFields } from "./schema-fields.js";
|
|
7
|
+
export { composerFieldsFromDraft } from "./decode-composer-draft.js";
|
|
8
|
+
export { encodeComposerDraft } from "./encode-composer-draft.js";
|
|
9
|
+
export { clientFailure } from "./failure.js";
|
|
10
|
+
export { liveState, } from "./live/live-state.js";
|
|
11
|
+
export { LiveSessionClient } from "./live-client.js";
|
|
12
|
+
export { isOAuthComplete, notifyOAuthComplete } from "./oauth-popup.js";
|
|
13
|
+
export { applyTurnResultToTranscript, resumeInterfaceTool, streamInterfaceDraftTurn, streamInterfaceTurn, } from "./run-session.js";
|
|
14
|
+
export { continueGatedToolInvocation, } from "./tool-resume.js";
|
|
15
|
+
export { citationsFromBlock } from "./source-citations.js";
|
|
16
|
+
export { createTraceFeed } from "./trace-feed.js";
|
|
17
|
+
export { buildInvokeRequest, buildTurnRequest, turnInputFromSession } from "./turn-client.js";
|
|
18
|
+
export { createHttpTransport, isTheoremStreamError, postJson, postNdjson, readNdjsonStream, TheoremStreamError, } from "./transport.js";
|