@theoremjs/web 0.0.0-stage → 0.3.4-next.375.ga2d1878
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 +493 -2
- package/client/audio-level.d.ts +5 -0
- package/client/audio-level.js +24 -0
- package/client/chat.d.ts +144 -0
- package/client/chat.js +760 -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 +18 -0
- package/client/composer-primary.js +29 -0
- package/client/decision-transport.d.ts +70 -0
- package/client/decision-transport.js +175 -0
- package/client/decode-composer-draft.d.ts +11 -0
- package/client/decode-composer-draft.js +12 -0
- package/client/embedding-input.d.ts +84 -0
- package/client/embedding-input.js +194 -0
- package/client/embedding-space.d.ts +82 -0
- package/client/embedding-space.js +389 -0
- package/client/embedding-transport.d.ts +40 -0
- package/client/embedding-transport.js +71 -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 +29 -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-transport.d.ts +70 -0
- package/client/host-transport.js +75 -0
- package/client/index.d.ts +37 -0
- package/client/index.js +31 -0
- package/client/live/live-mic-forward.d.ts +30 -0
- package/client/live/live-mic-forward.js +46 -0
- package/client/live/live-page-tool.d.ts +39 -0
- package/client/live/live-page-tool.js +26 -0
- package/client/live/live-state.d.ts +13 -0
- package/client/live/live-state.js +22 -0
- package/client/live/live-tool.d.ts +11 -0
- package/client/live/live-tool.js +1 -0
- package/client/live-client.d.ts +189 -0
- package/client/live-client.js +829 -0
- package/client/live-errors.d.ts +2 -0
- package/client/live-errors.js +9 -0
- package/client/live-messages.d.ts +148 -0
- package/client/live-messages.js +100 -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/page-dispatch.d.ts +15 -0
- package/client/page-dispatch.js +63 -0
- package/client/pcm-downsample.d.ts +4 -0
- package/client/pcm-downsample.js +45 -0
- package/client/run-commit.d.ts +34 -0
- package/client/run-commit.js +49 -0
- package/client/run-session.d.ts +79 -0
- package/client/run-session.js +207 -0
- package/client/schema-fields.d.ts +63 -0
- package/client/schema-fields.js +199 -0
- package/client/shaped-data.d.ts +118 -0
- package/client/shaped-data.js +343 -0
- package/client/source-citations.d.ts +13 -0
- package/client/source-citations.js +56 -0
- package/client/space-geometry.d.ts +39 -0
- package/client/space-geometry.js +183 -0
- package/client/tool-result.d.ts +78 -0
- package/client/tool-result.js +293 -0
- package/client/tool-resume.d.ts +50 -0
- package/client/tool-resume.js +14 -0
- package/client/trace-feed.d.ts +13 -0
- package/client/trace-feed.js +18 -0
- package/client/transcript-schema.d.ts +10 -0
- package/client/transcript-schema.js +120 -0
- package/client/transport.d.ts +264 -0
- package/client/transport.js +330 -0
- package/client/turn-client.d.ts +44 -0
- package/client/turn-client.js +88 -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/package.json +28 -4
- package/server/checkpoint-ownership.d.ts +6 -0
- package/server/checkpoint-ownership.js +42 -0
- package/server/conversation-store.d.ts +92 -0
- package/server/conversation-store.js +131 -0
- package/server/conversation.d.ts +193 -0
- package/server/conversation.js +552 -0
- package/server/credential-store.d.ts +24 -0
- package/server/credential-store.js +14 -0
- package/server/decision-handler.d.ts +42 -0
- package/server/decision-handler.js +46 -0
- package/server/embedding-handler.d.ts +33 -0
- package/server/embedding-handler.js +45 -0
- package/server/handler.d.ts +158 -0
- package/server/handler.js +775 -0
- package/server/json-response.d.ts +2 -0
- package/server/json-response.js +7 -0
- package/server/mcp-handler.d.ts +46 -0
- package/server/mcp-handler.js +312 -0
- package/server/mod.d.ts +27 -0
- package/server/mod.js +25 -0
- package/server/page-dispatch.d.ts +22 -0
- package/server/page-dispatch.js +127 -0
- package/server/request-body.d.ts +2 -0
- package/server/request-body.js +42 -0
- package/server/request-check.d.ts +21 -0
- package/server/request-check.js +49 -0
- package/server/session-authority.d.ts +8 -0
- package/server/session-authority.js +78 -0
- package/server/session-boundary.d.ts +26 -0
- package/server/session-boundary.js +64 -0
- package/server/session-identity.d.ts +16 -0
- package/server/session-identity.js +41 -0
- package/server/session-limits.d.ts +12 -0
- package/server/session-limits.js +59 -0
- package/server/session-store.d.ts +123 -0
- package/server/session-store.js +264 -0
- package/server/single-action.d.ts +21 -0
- package/server/single-action.js +30 -0
- package/server/steer-inbox.d.ts +35 -0
- package/server/steer-inbox.js +52 -0
- package/server/tool-operations.d.ts +6 -0
- package/server/tool-operations.js +132 -0
- package/server/turn-input.d.ts +10 -0
- package/server/turn-input.js +29 -0
package/client/chat.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type AttachmentValidationIssue, type ComposerMenuAction, type ComposerPendingMessage, type ComposerProfileInterface, type ComposerRunPhase, type InterfaceTurnSession, type TranscriptBlock } from '@theoremjs/agents/interface';
|
|
2
|
+
import { type ClientFailure } from './failure.ts';
|
|
3
|
+
import { type PageTools } from './live/live-page-tool.ts';
|
|
4
|
+
import type { AnsweringGate, ToolDecisionAction } from './tool-resume.ts';
|
|
5
|
+
import type { ConversationView, TheoremTransport, TurnEventSink } from './transport.ts';
|
|
6
|
+
export type ChatOptions = {
|
|
7
|
+
transport: TheoremTransport;
|
|
8
|
+
/** The profile's composer interface, as `transport.describe()` returns it. `null` while it loads. */
|
|
9
|
+
iface: ComposerProfileInterface | null;
|
|
10
|
+
/**
|
|
11
|
+
* The ref of a conversation to resume, as `onConversationChange` reported it. Read once, when
|
|
12
|
+
* the chat is created: the chat draws the conversation as the host keeps it. A stateless profile
|
|
13
|
+
* keeps no conversation, so it has no ref.
|
|
14
|
+
*/
|
|
15
|
+
conversation?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The conversation under `conversation` as the host showed it with the ref, as
|
|
18
|
+
* `startConversation` returns it. Read once, when the chat is created: the chat draws it at
|
|
19
|
+
* once, and does not read it from the host again.
|
|
20
|
+
*/
|
|
21
|
+
conversationView?: ConversationView;
|
|
22
|
+
/** The text the composer starts with. Read once, when the chat is created. */
|
|
23
|
+
initialText?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Each new ref the host issues for the conversation: once the message posts, and again as the
|
|
26
|
+
* reply's runs are saved. Keep the latest to resume the chat later.
|
|
27
|
+
*/
|
|
28
|
+
onConversationChange?: (ref: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* The value chosen for each of the profile's `inputs.slots`. Sent with every turn. A slot you
|
|
31
|
+
* name here is fixed to that value; one you leave out is chosen with `pickSlot`, starting at
|
|
32
|
+
* its first allowed value.
|
|
33
|
+
*/
|
|
34
|
+
slots?: Record<string, string>;
|
|
35
|
+
/** Told each time the visitor picks a slot, with every slot's value. */
|
|
36
|
+
onSlotsChange?: (slots: Record<string, string>) => void;
|
|
37
|
+
/** What the page wants the agent to know: any JSON. The latest value goes with every turn. */
|
|
38
|
+
context?: unknown;
|
|
39
|
+
/** The page's tools, by name: each answers a tool the profile declares with `answeredBy: 'page'`. */
|
|
40
|
+
pageTools?: PageTools;
|
|
41
|
+
/**
|
|
42
|
+
* Every event of every turn, as it arrives and before the transcript takes it: the ones the
|
|
43
|
+
* transcript shows, and the ones it does not (a stage, a session, a guardrail decision).
|
|
44
|
+
*/
|
|
45
|
+
onTurnEvent?: TurnEventSink;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* How far the latest message has got: posted (`sending`), taken by the server
|
|
49
|
+
* (`sent`), reached the model (`delivered`), answered (`read`).
|
|
50
|
+
*/
|
|
51
|
+
export type MessageDelivery = 'sending' | 'sent' | 'delivered' | 'read';
|
|
52
|
+
/** The slots the profile declares, and the value of each: the page's, else the picked one, else the first allowed. */
|
|
53
|
+
export type ChatSlots = {
|
|
54
|
+
declared: Record<string, string[]>;
|
|
55
|
+
values: Record<string, string>;
|
|
56
|
+
};
|
|
57
|
+
/** Everything a chat shows. A new object on each change, the same one between changes. */
|
|
58
|
+
export type ChatState = {
|
|
59
|
+
iface: ComposerProfileInterface | null;
|
|
60
|
+
/** The transcript. */
|
|
61
|
+
blocks: TranscriptBlock[];
|
|
62
|
+
/** The reply as it streams, or the reply that waits on a gate. */
|
|
63
|
+
streamBlocks: TranscriptBlock[];
|
|
64
|
+
chatStarted: boolean;
|
|
65
|
+
draftText: string;
|
|
66
|
+
pendingFiles: File[];
|
|
67
|
+
pendingVoice: File[];
|
|
68
|
+
/** Steered, queued, and stashed messages. */
|
|
69
|
+
pendingMessages: ComposerPendingMessage[];
|
|
70
|
+
issues: AttachmentValidationIssue[];
|
|
71
|
+
/** The failure the composer shows. */
|
|
72
|
+
failure: ClientFailure | null;
|
|
73
|
+
/** The answer on its way to a gate, shown on it until the answer settles or fails. */
|
|
74
|
+
answering: AnsweringGate | null;
|
|
75
|
+
phase: ComposerRunPhase;
|
|
76
|
+
session: InterfaceTurnSession;
|
|
77
|
+
/** The latest message's delivery; `null` before the first and once its turn failed. */
|
|
78
|
+
delivery: MessageDelivery | null;
|
|
79
|
+
streaming: boolean;
|
|
80
|
+
/** `undefined` when the profile declares no slots. */
|
|
81
|
+
slots: ChatSlots | undefined;
|
|
82
|
+
};
|
|
83
|
+
/** What `sendText` hands back: the blocks the turn added, its user message, and the reply. */
|
|
84
|
+
export type SentTurn = {
|
|
85
|
+
blocks: TranscriptBlock[];
|
|
86
|
+
};
|
|
87
|
+
/** A new value, or a function of the current one. */
|
|
88
|
+
export type ChatUpdate<T> = T | ((prev: T) => T);
|
|
89
|
+
/**
|
|
90
|
+
* A chat with no UI framework: transcript, streaming, the composer's draft, the pending
|
|
91
|
+
* steer / queue / stash, gates, branching, and resuming a conversation. Read it with `getState`,
|
|
92
|
+
* follow it with `subscribe`, and act through its methods. Every method is bound, so pass them
|
|
93
|
+
* as callbacks as they are.
|
|
94
|
+
*/
|
|
95
|
+
export type ChatController = {
|
|
96
|
+
getState(): ChatState;
|
|
97
|
+
/** Called after each change, once per batch of changes. Returns the unsubscribe. */
|
|
98
|
+
subscribe(listener: () => void): () => void;
|
|
99
|
+
/** The latest options. `conversation`, `conversationView` and `initialText` are read only at creation. */
|
|
100
|
+
update(options: ChatOptions): void;
|
|
101
|
+
setDraftText(value: ChatUpdate<string>): void;
|
|
102
|
+
setPendingFiles(value: ChatUpdate<File[]>): void;
|
|
103
|
+
setPendingVoice(value: ChatUpdate<File[]>): void;
|
|
104
|
+
setPendingMessages(value: ChatUpdate<ComposerPendingMessage[]>): void;
|
|
105
|
+
setIssues(value: ChatUpdate<AttachmentValidationIssue[]>): void;
|
|
106
|
+
/** Sends the composer's draft when idle; queues it while a reply streams or waits on a gate. */
|
|
107
|
+
submit(): Promise<void>;
|
|
108
|
+
/** Stops the reply that is streaming. */
|
|
109
|
+
stop(): void;
|
|
110
|
+
/** Steers, queues, or stashes the composer's draft. A steer goes to the running turn. */
|
|
111
|
+
enqueue(kind: 'queue' | 'steer' | 'stash'): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Sends a pending message, or the composer's draft, now: a streaming reply stops first, and a
|
|
114
|
+
* reply that waits on gates is walked away from.
|
|
115
|
+
*/
|
|
116
|
+
sendNow(source?: ComposerPendingMessage): Promise<void>;
|
|
117
|
+
menuAction(action: ComposerMenuAction): void;
|
|
118
|
+
/** Puts a pending message back in the composer. What the composer holds is stashed first. */
|
|
119
|
+
restorePending(id: string): Promise<void>;
|
|
120
|
+
/** Moves a stashed message into the queue. At idle, the queue starts sending. */
|
|
121
|
+
queuePending(id: string): void;
|
|
122
|
+
/** Answers the gate the reply waits on. */
|
|
123
|
+
decide(action: ToolDecisionAction): Promise<void>;
|
|
124
|
+
/** The visitor signed in for the gated call, or gave its secret. */
|
|
125
|
+
authenticate(secret?: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Cuts the conversation after transcript block `index`. A host that keeps the conversation
|
|
128
|
+
* cuts it (walking away from a reply that waits on gates); a stateless chat cuts its own.
|
|
129
|
+
*/
|
|
130
|
+
branch(index: number): Promise<void>;
|
|
131
|
+
/** The model, and its effort (its default when left out), for the next turn. */
|
|
132
|
+
setGeneration(next: {
|
|
133
|
+
modelId: string;
|
|
134
|
+
effort?: string;
|
|
135
|
+
}): void;
|
|
136
|
+
pickSlot(name: string, value: string): void;
|
|
137
|
+
/**
|
|
138
|
+
* Sends `text` and optional files as the composer would, and resolves once the reply is done;
|
|
139
|
+
* `null` when it can't go now (a reply is streaming, or waits on a gate).
|
|
140
|
+
*/
|
|
141
|
+
sendText(text: string, files?: readonly File[]): Promise<SentTurn | null>;
|
|
142
|
+
};
|
|
143
|
+
/** A chat for `options`. Framework-free: see `ChatController`. */
|
|
144
|
+
export declare function createChatController(options: ChatOptions): ChatController;
|