@theoremjs/react 0.3.4-next.377.g4dbec64 → 0.3.4-next.381.g9417e5a
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ChatOptions, type SentTurn } from '@theoremjs/web/client';
|
|
1
|
+
import { type ChatOptions, type SentTurn, type ToolDecisionAction } from '@theoremjs/web/client';
|
|
2
2
|
export type { SentTurn };
|
|
3
3
|
export type UseTheoremChatOptions = ChatOptions;
|
|
4
4
|
/**
|
|
@@ -26,7 +26,7 @@ export declare function useTheoremChat(options: UseTheoremChatOptions): {
|
|
|
26
26
|
handlePendingQueue: (id: string) => void;
|
|
27
27
|
handlePendingRestore: (id: string) => Promise<void>;
|
|
28
28
|
handleSendNow: (source?: import("../../../src/interface/pending").ComposerPendingMessage) => Promise<void>;
|
|
29
|
-
handleToolDecision: (_index: number, action:
|
|
29
|
+
handleToolDecision: (_index: number, action: ToolDecisionAction) => Promise<void>;
|
|
30
30
|
handleGenerationChange: (next: {
|
|
31
31
|
modelId: string;
|
|
32
32
|
effort?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createChatController } from '@theoremjs/web/client';
|
|
2
|
-
import { useEffect, useLayoutEffect, useMemo, useState, useSyncExternalStore } from 'react';
|
|
1
|
+
import { createChatController, } from '@theoremjs/web/client';
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useState, useSyncExternalStore, } from 'react';
|
|
3
3
|
// why: Options reach the chat before the browser paints, and before a line can arrive; a server render runs no effects.
|
|
4
4
|
const useOptionsEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
5
5
|
/**
|
|
@@ -13,6 +13,9 @@ export function useTheoremChat(options) {
|
|
|
13
13
|
useOptionsEffect(() => chat.update(options));
|
|
14
14
|
const state = useSyncExternalStore(chat.subscribe, chat.getState, chat.getState);
|
|
15
15
|
const slotChoices = useMemo(() => (state.slots ? { ...state.slots, onChange: chat.pickSlot } : undefined), [chat, state.slots]);
|
|
16
|
+
// why: The transcript draws each gate by its index; the chat answers the one gate that waits.
|
|
17
|
+
const handleAuthenticated = useCallback((_index, secret) => chat.authenticate(secret), [chat]);
|
|
18
|
+
const handleToolDecision = useCallback((_index, action) => chat.decide(action), [chat]);
|
|
16
19
|
return {
|
|
17
20
|
...state,
|
|
18
21
|
slotChoices,
|
|
@@ -21,7 +24,7 @@ export function useTheoremChat(options) {
|
|
|
21
24
|
setPendingVoice: chat.setPendingVoice,
|
|
22
25
|
setPendingMessages: chat.setPendingMessages,
|
|
23
26
|
setIssues: chat.setIssues,
|
|
24
|
-
handleAuthenticated
|
|
27
|
+
handleAuthenticated,
|
|
25
28
|
handleBranch: chat.branch,
|
|
26
29
|
handleSubmit: chat.submit,
|
|
27
30
|
handleStop: chat.stop,
|
|
@@ -29,7 +32,7 @@ export function useTheoremChat(options) {
|
|
|
29
32
|
handlePendingQueue: chat.queuePending,
|
|
30
33
|
handlePendingRestore: chat.restorePending,
|
|
31
34
|
handleSendNow: chat.sendNow,
|
|
32
|
-
handleToolDecision
|
|
35
|
+
handleToolDecision,
|
|
33
36
|
handleGenerationChange: chat.setGeneration,
|
|
34
37
|
sendText: chat.sendText,
|
|
35
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/react",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.381.g9417e5a",
|
|
4
4
|
"description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@stylexjs/stylex": "0.19.0",
|
|
61
61
|
"react": "^19.0.0",
|
|
62
62
|
"react-dom": "^19.0.0",
|
|
63
|
-
"@theoremjs/agents": "^0.3.4-next.
|
|
64
|
-
"@theoremjs/web": "^0.3.4-next.
|
|
63
|
+
"@theoremjs/agents": "^0.3.4-next.381.g9417e5a",
|
|
64
|
+
"@theoremjs/web": "^0.3.4-next.381.g9417e5a"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|