@bytexbyte/nxtlinq-ai-agent-ui-react-development 0.4.7 → 0.4.9
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/dist/context/ChatBotContext.d.ts.map +1 -1
- package/dist/context/ChatBotContext.js +22 -35
- package/dist/types/ChatBotTypes.d.ts +1 -1
- package/dist/types/ChatBotTypes.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/context/ChatBotContext.tsx +28 -49
- package/src/types/ChatBotTypes.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+B/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+B/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAuB/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA8+FlD,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { AuthorizationLoadingState } from '../authorizationLoadingState';
|
|
|
10
10
|
import { PendingTextToolRetryController } from '../pendingTextToolRetry';
|
|
11
11
|
import { completePiiScan } from '../piiMessageState';
|
|
12
12
|
import { filterSuggestions } from '../suggestionState';
|
|
13
|
-
import {
|
|
13
|
+
import { RuntimeAITMutationQueue, RuntimeAITRecomputeCoordinator, StaleRuntimeAITResponseError, runtimeAITContextKey, runtimeAITSubjectKey, runtimeAuthorizationMatchesContext, runtimeAuthorizationState, unavailableRuntimeAuthorization, useProviderRuntimeCommit, useRuntimeAITContextCommit, } from '../permissionState';
|
|
14
14
|
const MIC_ENABLED_SESSION_KEY = 'chatbot-mic-enabled';
|
|
15
15
|
const ChatBotContext = React.createContext(undefined);
|
|
16
16
|
export const useChatBot = () => {
|
|
@@ -938,30 +938,23 @@ customError, voiceThresholds, debugVoiceRms = false, sttGlossary, }) => {
|
|
|
938
938
|
setRuntimeAuthorizationContextKey(activeContext ? runtimeAITContextKey(activeContext) : null);
|
|
939
939
|
}, []);
|
|
940
940
|
useRuntimeAITContextCommit(runtimeRecomputeCoordinatorRef.current, runtimeContext, invalidateCommittedRuntimeContext);
|
|
941
|
-
const
|
|
941
|
+
const readRuntimeAIT = React.useCallback(async (context) => {
|
|
942
942
|
const capturedContext = {
|
|
943
943
|
controller: context.controller,
|
|
944
944
|
serviceId: context.serviceId,
|
|
945
945
|
...(context.roles !== undefined ? { roles: [...context.roles] } : {}),
|
|
946
946
|
...(context.permissionGroup !== undefined ? { permissionGroup: context.permissionGroup } : {}),
|
|
947
947
|
};
|
|
948
|
-
return runtimeRecomputeCoordinatorRef.current.run(capturedContext, () => nxtlinqApi.ait.
|
|
948
|
+
return runtimeRecomputeCoordinatorRef.current.run(capturedContext, () => nxtlinqApi.ait.readAIT(capturedContext), applyRuntimeResult, clearRuntimeAuthorization);
|
|
949
949
|
}, [applyRuntimeResult, clearRuntimeAuthorization, nxtlinqApi]);
|
|
950
950
|
const queueRuntimeAITRefresh = React.useCallback((context) => runtimeMutationQueueRef.current.run(runtimeAITSubjectKey(context), async () => {
|
|
951
951
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
952
|
-
return
|
|
953
|
-
}), [
|
|
954
|
-
const
|
|
955
|
-
const activeContext = runtimeRecomputeCoordinatorRef.current.getActiveContext();
|
|
956
|
-
if (!activeContext || runtimeAITSubjectKey(activeContext) !== subjectKey) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
await recomputeRuntimeAIT(activeContext);
|
|
960
|
-
}, [recomputeRuntimeAIT]);
|
|
961
|
-
const dispatchRuntimeDenyListReplacement = React.useCallback(async (context, nextDeniedPermissions) => dispatchRuntimeAITCompleteReplacement(runtimeRecomputeCoordinatorRef.current, context, () => nxtlinqApi.ait.updatePermissionDenyList({
|
|
952
|
+
return readRuntimeAIT(context);
|
|
953
|
+
}), [readRuntimeAIT]);
|
|
954
|
+
const replaceRuntimeActivePermissions = React.useCallback(async (context, activePermissions) => runtimeRecomputeCoordinatorRef.current.run(context, () => nxtlinqApi.ait.updateActivePermissions({
|
|
962
955
|
...context,
|
|
963
|
-
|
|
964
|
-
}),
|
|
956
|
+
activePermissions,
|
|
957
|
+
}), applyRuntimeResult, clearRuntimeAuthorization), [applyRuntimeResult, clearRuntimeAuthorization, nxtlinqApi]);
|
|
965
958
|
// Refresh the authoritative runtime AIT state.
|
|
966
959
|
const refreshAIT = async (forceUpdatePermissions = false) => {
|
|
967
960
|
const currentHitAddress = hitAddressRef.current || hitAddress;
|
|
@@ -1652,6 +1645,10 @@ customError, voiceThresholds, debugVoiceRms = false, sttGlossary, }) => {
|
|
|
1652
1645
|
const isToolAllowed = await hasPermission(toolUse.name);
|
|
1653
1646
|
// Typed preflight already emitted the only permitted recovery UI.
|
|
1654
1647
|
if (!isToolAllowed) {
|
|
1648
|
+
// Do not leave suggestions from the previous turn visible while
|
|
1649
|
+
// authorization recovery short-circuits the normal response path.
|
|
1650
|
+
setSuggestions([]);
|
|
1651
|
+
void updateSuggestions(pseudoId, localStorage.getItem('walletAddress') || undefined, content);
|
|
1655
1652
|
pendingTextToolRetryRef.current.set({
|
|
1656
1653
|
content,
|
|
1657
1654
|
isPresetMessage,
|
|
@@ -2277,18 +2274,6 @@ customError, voiceThresholds, debugVoiceRms = false, sttGlossary, }) => {
|
|
|
2277
2274
|
setIsAITEnabling(false);
|
|
2278
2275
|
return false;
|
|
2279
2276
|
}
|
|
2280
|
-
// If we don't have AIT loaded but we have a token, try to refresh it first
|
|
2281
|
-
if (!aitRef.current && nxtlinqAITServiceAccessToken) {
|
|
2282
|
-
try {
|
|
2283
|
-
await refreshAIT();
|
|
2284
|
-
// Wait a bit for AIT to be loaded
|
|
2285
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
2286
|
-
}
|
|
2287
|
-
catch (error) {
|
|
2288
|
-
// Continue anyway, we'll create a new AIT if needed
|
|
2289
|
-
console.error('Failed to refresh AIT:', error);
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
2277
|
try {
|
|
2293
2278
|
const context = {
|
|
2294
2279
|
controller: currentHitAddress,
|
|
@@ -2298,13 +2283,19 @@ customError, voiceThresholds, debugVoiceRms = false, sttGlossary, }) => {
|
|
|
2298
2283
|
};
|
|
2299
2284
|
const enabled = await runtimeMutationQueueRef.current.run(runtimeAITSubjectKey(context), async () => {
|
|
2300
2285
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2301
|
-
const current = await
|
|
2286
|
+
const current = await readRuntimeAIT(context);
|
|
2302
2287
|
if (!current.maximumPermissions.includes(toolName)) {
|
|
2303
2288
|
return false;
|
|
2304
2289
|
}
|
|
2305
|
-
|
|
2290
|
+
if (current.effectivePermissions.includes(toolName) && current.aitId) {
|
|
2291
|
+
return true;
|
|
2292
|
+
}
|
|
2293
|
+
const nextActivePermissions = Array.from(new Set([
|
|
2294
|
+
...current.effectivePermissions,
|
|
2295
|
+
toolName,
|
|
2296
|
+
]));
|
|
2306
2297
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2307
|
-
await
|
|
2298
|
+
await replaceRuntimeActivePermissions(context, nextActivePermissions);
|
|
2308
2299
|
return true;
|
|
2309
2300
|
});
|
|
2310
2301
|
if (!enabled) {
|
|
@@ -2349,15 +2340,11 @@ customError, voiceThresholds, debugVoiceRms = false, sttGlossary, }) => {
|
|
|
2349
2340
|
const checkedPermissions = [...(newPermissions ?? permissions)];
|
|
2350
2341
|
await runtimeMutationQueueRef.current.run(runtimeAITSubjectKey(context), async () => {
|
|
2351
2342
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2352
|
-
|
|
2353
|
-
const nextDeniedPermissions = replaceCurrentMaximumDenyList(fresh.deniedPermissions, fresh.maximumPermissions, checkedPermissions);
|
|
2354
|
-
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2355
|
-
await dispatchRuntimeDenyListReplacement(context, nextDeniedPermissions);
|
|
2343
|
+
await replaceRuntimeActivePermissions(context, checkedPermissions);
|
|
2356
2344
|
});
|
|
2357
2345
|
showSuccess('AIT permissions saved successfully! You can now use the AI agent with your configured permissions.');
|
|
2358
2346
|
setShowPermissionForm(false);
|
|
2359
2347
|
setIsPermissionFormOpen(false);
|
|
2360
|
-
await refreshAIT(true);
|
|
2361
2348
|
await retryPendingTextTool();
|
|
2362
2349
|
}
|
|
2363
2350
|
catch (error) {
|
|
@@ -44,7 +44,7 @@ export interface ChatBotProps {
|
|
|
44
44
|
apiSecret?: string;
|
|
45
45
|
serviceToken?: string;
|
|
46
46
|
getAuthToken?: () => Promise<string>;
|
|
47
|
-
environment?: 'production' | 'staging';
|
|
47
|
+
environment?: 'production' | 'staging' | 'local';
|
|
48
48
|
onVerifyWallet?: () => Promise<{
|
|
49
49
|
token: string;
|
|
50
50
|
} | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../src/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAErI,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,C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C;IAC3D,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAGjB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytexbyte/nxtlinq-ai-agent-ui-react-development",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "Official React Web UI for nxtlinq AI Agent — drop-in chat widget",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"react-dom": ">=18.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@bytexbyte/nxtlinq-ai-agent-core-development": "2.0.
|
|
42
|
-
"@bytexbyte/nxtlinq-ai-agent-web-development": "1.0.
|
|
41
|
+
"@bytexbyte/nxtlinq-ai-agent-core-development": "2.0.4",
|
|
42
|
+
"@bytexbyte/nxtlinq-ai-agent-web-development": "1.0.4",
|
|
43
43
|
"@emotion/react": "^11.14.0",
|
|
44
44
|
"@emotion/styled": "^11.14.1",
|
|
45
45
|
"@mui/icons-material": "^7.2.0",
|
|
@@ -42,9 +42,6 @@ import { PendingTextToolRetryController } from '../pendingTextToolRetry';
|
|
|
42
42
|
import { completePiiScan } from '../piiMessageState';
|
|
43
43
|
import { filterSuggestions } from '../suggestionState';
|
|
44
44
|
import {
|
|
45
|
-
dispatchRuntimeAITCompleteReplacement,
|
|
46
|
-
removeOneDeniedPermission,
|
|
47
|
-
replaceCurrentMaximumDenyList,
|
|
48
45
|
RuntimeAITMutationQueue,
|
|
49
46
|
RuntimeAITRecomputeCoordinator,
|
|
50
47
|
StaleRuntimeAITResponseError,
|
|
@@ -1125,7 +1122,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1125
1122
|
invalidateCommittedRuntimeContext,
|
|
1126
1123
|
);
|
|
1127
1124
|
|
|
1128
|
-
const
|
|
1125
|
+
const readRuntimeAIT = React.useCallback(async (context: RuntimeAITContext) => {
|
|
1129
1126
|
const capturedContext: RuntimeAITContext = {
|
|
1130
1127
|
controller: context.controller,
|
|
1131
1128
|
serviceId: context.serviceId,
|
|
@@ -1134,7 +1131,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1134
1131
|
};
|
|
1135
1132
|
return runtimeRecomputeCoordinatorRef.current.run(
|
|
1136
1133
|
capturedContext,
|
|
1137
|
-
() => nxtlinqApi.ait.
|
|
1134
|
+
() => nxtlinqApi.ait.readAIT(capturedContext),
|
|
1138
1135
|
applyRuntimeResult,
|
|
1139
1136
|
clearRuntimeAuthorization,
|
|
1140
1137
|
);
|
|
@@ -1145,33 +1142,24 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1145
1142
|
runtimeAITSubjectKey(context),
|
|
1146
1143
|
async () => {
|
|
1147
1144
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
1148
|
-
return
|
|
1145
|
+
return readRuntimeAIT(context);
|
|
1149
1146
|
},
|
|
1150
1147
|
),
|
|
1151
|
-
[
|
|
1148
|
+
[readRuntimeAIT],
|
|
1152
1149
|
);
|
|
1153
1150
|
|
|
1154
|
-
const
|
|
1155
|
-
const activeContext = runtimeRecomputeCoordinatorRef.current.getActiveContext();
|
|
1156
|
-
if (!activeContext || runtimeAITSubjectKey(activeContext) !== subjectKey) {
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
await recomputeRuntimeAIT(activeContext);
|
|
1160
|
-
}, [recomputeRuntimeAIT]);
|
|
1161
|
-
|
|
1162
|
-
const dispatchRuntimeDenyListReplacement = React.useCallback(async (
|
|
1151
|
+
const replaceRuntimeActivePermissions = React.useCallback(async (
|
|
1163
1152
|
context: RuntimeAITContext,
|
|
1164
|
-
|
|
1165
|
-
) =>
|
|
1166
|
-
runtimeRecomputeCoordinatorRef.current,
|
|
1153
|
+
activePermissions: string[],
|
|
1154
|
+
) => runtimeRecomputeCoordinatorRef.current.run(
|
|
1167
1155
|
context,
|
|
1168
|
-
() => nxtlinqApi.ait.
|
|
1156
|
+
() => nxtlinqApi.ait.updateActivePermissions({
|
|
1169
1157
|
...context,
|
|
1170
|
-
|
|
1158
|
+
activePermissions,
|
|
1171
1159
|
}),
|
|
1172
|
-
|
|
1160
|
+
applyRuntimeResult,
|
|
1173
1161
|
clearRuntimeAuthorization,
|
|
1174
|
-
), [
|
|
1162
|
+
), [applyRuntimeResult, clearRuntimeAuthorization, nxtlinqApi]);
|
|
1175
1163
|
|
|
1176
1164
|
// Refresh the authoritative runtime AIT state.
|
|
1177
1165
|
const refreshAIT = async (forceUpdatePermissions = false) => {
|
|
@@ -1932,6 +1920,14 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1932
1920
|
|
|
1933
1921
|
// Typed preflight already emitted the only permitted recovery UI.
|
|
1934
1922
|
if (!isToolAllowed) {
|
|
1923
|
+
// Do not leave suggestions from the previous turn visible while
|
|
1924
|
+
// authorization recovery short-circuits the normal response path.
|
|
1925
|
+
setSuggestions([]);
|
|
1926
|
+
void updateSuggestions(
|
|
1927
|
+
pseudoId,
|
|
1928
|
+
localStorage.getItem('walletAddress') || undefined,
|
|
1929
|
+
content,
|
|
1930
|
+
);
|
|
1935
1931
|
pendingTextToolRetryRef.current.set({
|
|
1936
1932
|
content,
|
|
1937
1933
|
isPresetMessage,
|
|
@@ -2609,18 +2605,6 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2609
2605
|
return false;
|
|
2610
2606
|
}
|
|
2611
2607
|
|
|
2612
|
-
// If we don't have AIT loaded but we have a token, try to refresh it first
|
|
2613
|
-
if (!aitRef.current && nxtlinqAITServiceAccessToken) {
|
|
2614
|
-
try {
|
|
2615
|
-
await refreshAIT();
|
|
2616
|
-
// Wait a bit for AIT to be loaded
|
|
2617
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
2618
|
-
} catch (error) {
|
|
2619
|
-
// Continue anyway, we'll create a new AIT if needed
|
|
2620
|
-
console.error('Failed to refresh AIT:', error);
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
2608
|
try {
|
|
2625
2609
|
const context: RuntimeAITContext = {
|
|
2626
2610
|
controller: currentHitAddress,
|
|
@@ -2632,16 +2616,19 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2632
2616
|
runtimeAITSubjectKey(context),
|
|
2633
2617
|
async () => {
|
|
2634
2618
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2635
|
-
const current = await
|
|
2619
|
+
const current = await readRuntimeAIT(context);
|
|
2636
2620
|
if (!current.maximumPermissions.includes(toolName)) {
|
|
2637
2621
|
return false;
|
|
2638
2622
|
}
|
|
2639
|
-
|
|
2640
|
-
|
|
2623
|
+
if (current.effectivePermissions.includes(toolName) && current.aitId) {
|
|
2624
|
+
return true;
|
|
2625
|
+
}
|
|
2626
|
+
const nextActivePermissions = Array.from(new Set([
|
|
2627
|
+
...current.effectivePermissions,
|
|
2641
2628
|
toolName,
|
|
2642
|
-
);
|
|
2629
|
+
]));
|
|
2643
2630
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2644
|
-
await
|
|
2631
|
+
await replaceRuntimeActivePermissions(context, nextActivePermissions);
|
|
2645
2632
|
return true;
|
|
2646
2633
|
},
|
|
2647
2634
|
);
|
|
@@ -2687,20 +2674,12 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2687
2674
|
runtimeAITSubjectKey(context),
|
|
2688
2675
|
async () => {
|
|
2689
2676
|
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2690
|
-
|
|
2691
|
-
const nextDeniedPermissions = replaceCurrentMaximumDenyList(
|
|
2692
|
-
fresh.deniedPermissions,
|
|
2693
|
-
fresh.maximumPermissions,
|
|
2694
|
-
checkedPermissions,
|
|
2695
|
-
);
|
|
2696
|
-
runtimeRecomputeCoordinatorRef.current.assertContextActive(context);
|
|
2697
|
-
await dispatchRuntimeDenyListReplacement(context, nextDeniedPermissions);
|
|
2677
|
+
await replaceRuntimeActivePermissions(context, checkedPermissions);
|
|
2698
2678
|
},
|
|
2699
2679
|
);
|
|
2700
2680
|
showSuccess('AIT permissions saved successfully! You can now use the AI agent with your configured permissions.');
|
|
2701
2681
|
setShowPermissionForm(false);
|
|
2702
2682
|
setIsPermissionFormOpen(false);
|
|
2703
|
-
await refreshAIT(true);
|
|
2704
2683
|
await retryPendingTextTool();
|
|
2705
2684
|
} catch (error) {
|
|
2706
2685
|
if (!(error instanceof StaleRuntimeAITResponseError)) {
|
|
@@ -52,7 +52,7 @@ export interface ChatBotProps {
|
|
|
52
52
|
apiSecret?: string;
|
|
53
53
|
serviceToken?: string;
|
|
54
54
|
getAuthToken?: () => Promise<string>;
|
|
55
|
-
environment?: 'production' | 'staging'; // API environment (default: production)
|
|
55
|
+
environment?: 'production' | 'staging' | 'local'; // API environment (default: production)
|
|
56
56
|
onVerifyWallet?: () => Promise<{
|
|
57
57
|
token: string;
|
|
58
58
|
} | undefined>;
|