@frankieai/react 0.2.7 → 0.2.8
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/index.cjs +21 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/AgentContext.tsx +2 -1
- package/src/hooks/useFrankieChat.ts +8 -2
- package/src/widget.test.tsx +17 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, CSSProperties, ButtonHTMLAttributes, HTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
3
|
-
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme, LoadedSkill } from '@frankieai/core';
|
|
3
|
+
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme, LoadedSkill, ApiToolInventory } from '@frankieai/core';
|
|
4
4
|
export { FrankieServerEvent, PublicWidgetConfig, WidgetTheme } from '@frankieai/core';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -148,6 +148,8 @@ interface SendOptions {
|
|
|
148
148
|
}
|
|
149
149
|
interface UseFrankieChatResult {
|
|
150
150
|
loadedSkills: LoadedSkill[] | null;
|
|
151
|
+
/** Which OpenAPI sources are live for this turn, and a content fingerprint of each. */
|
|
152
|
+
activeApis: ApiToolInventory[] | null;
|
|
151
153
|
restoring: boolean;
|
|
152
154
|
messages: ChatMessage[];
|
|
153
155
|
/** True from the moment a message is sent until the turn ends. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, CSSProperties, ButtonHTMLAttributes, HTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
3
|
-
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme, LoadedSkill } from '@frankieai/core';
|
|
3
|
+
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme, LoadedSkill, ApiToolInventory } from '@frankieai/core';
|
|
4
4
|
export { FrankieServerEvent, PublicWidgetConfig, WidgetTheme } from '@frankieai/core';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -148,6 +148,8 @@ interface SendOptions {
|
|
|
148
148
|
}
|
|
149
149
|
interface UseFrankieChatResult {
|
|
150
150
|
loadedSkills: LoadedSkill[] | null;
|
|
151
|
+
/** Which OpenAPI sources are live for this turn, and a content fingerprint of each. */
|
|
152
|
+
activeApis: ApiToolInventory[] | null;
|
|
151
153
|
restoring: boolean;
|
|
152
154
|
messages: ChatMessage[];
|
|
153
155
|
/** True from the moment a message is sent until the turn ends. */
|
package/dist/index.js
CHANGED
|
@@ -314,6 +314,7 @@ function useFrankieChatState() {
|
|
|
314
314
|
const [error, setError] = useState(void 0);
|
|
315
315
|
const [restored, setRestored] = useState(false);
|
|
316
316
|
const [loadedSkills, setLoadedSkills] = useState(null);
|
|
317
|
+
const [activeApis, setActiveApis] = useState(null);
|
|
317
318
|
const abortRef = useRef(null);
|
|
318
319
|
const mounted = useRef(true);
|
|
319
320
|
const messagesRef = useRef([]);
|
|
@@ -385,6 +386,7 @@ function useFrankieChatState() {
|
|
|
385
386
|
const assistantId = nextId("a");
|
|
386
387
|
setError(void 0);
|
|
387
388
|
setLoadedSkills(null);
|
|
389
|
+
setActiveApis(null);
|
|
388
390
|
setBusy(true);
|
|
389
391
|
const next = [
|
|
390
392
|
...messagesRef.current,
|
|
@@ -415,6 +417,10 @@ function useFrankieChatState() {
|
|
|
415
417
|
setLoadedSkills(event.skills);
|
|
416
418
|
return;
|
|
417
419
|
}
|
|
420
|
+
if (event.type === "tools_active") {
|
|
421
|
+
setActiveApis(event.apis);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
418
424
|
if (event.type === "ping" || event.type === "session") return;
|
|
419
425
|
if (event.type === "text_delta") receivedText = true;
|
|
420
426
|
if (event.type === "tool_start" || event.type === "tool_end") receivedToolActivity = true;
|
|
@@ -465,12 +471,13 @@ function useFrankieChatState() {
|
|
|
465
471
|
setBusy(false);
|
|
466
472
|
setRestored(true);
|
|
467
473
|
setLoadedSkills(null);
|
|
474
|
+
setActiveApis(null);
|
|
468
475
|
try {
|
|
469
476
|
if (client.persist) window.localStorage.removeItem(`${client.namespace}.messages`);
|
|
470
477
|
} catch {
|
|
471
478
|
}
|
|
472
479
|
}, [client]);
|
|
473
|
-
return { messages, busy, loadedSkills, restoring: !restored, ...error ? { error } : {}, send, stop, reset };
|
|
480
|
+
return { messages, busy, loadedSkills, activeApis, restoring: !restored, ...error ? { error } : {}, send, stop, reset };
|
|
474
481
|
}
|
|
475
482
|
function conversationTitle(messages) {
|
|
476
483
|
const first = messages.find((message) => message.role === "user" && message.text.trim());
|
|
@@ -667,7 +674,7 @@ import { ArrowUpRight, Sparkles } from "lucide-react";
|
|
|
667
674
|
import { jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
668
675
|
function AgentContext() {
|
|
669
676
|
const { loading, configError } = useFrankie();
|
|
670
|
-
const { loadedSkills, busy, restoring, error } = useFrankieChat();
|
|
677
|
+
const { loadedSkills, activeApis, busy, restoring, error } = useFrankieChat();
|
|
671
678
|
const status = configError || error ? "Unavailable" : loading || restoring ? "Connecting" : busy && loadedSkills === null ? "Checking" : loadedSkills?.length ? "Active" : loadedSkills ? "Tools only" : "Ready";
|
|
672
679
|
return /* @__PURE__ */ jsxs("div", { className: "frankie-agent-context-wrap", children: [
|
|
673
680
|
/* @__PURE__ */ jsxs("details", { className: "frankie-agent-context", children: [
|
|
@@ -690,7 +697,18 @@ function AgentContext() {
|
|
|
690
697
|
skill.revision
|
|
691
698
|
] })
|
|
692
699
|
] }, skill.id)) }) : /* @__PURE__ */ jsx6("p", { children: "Frankie can use the tools approved for this workspace. Drafts and skills without available tools are not loaded." }),
|
|
693
|
-
/* @__PURE__ */ jsx6("p", { children: "Published skills and updates are checked on every message. Only approved, available tools can run." })
|
|
700
|
+
/* @__PURE__ */ jsx6("p", { children: "Published skills and updates are checked on every message. Only approved, available tools can run." }),
|
|
701
|
+
activeApis?.length ? /* @__PURE__ */ jsx6("ul", { className: "frankie-active-apis", children: activeApis.map((api) => /* @__PURE__ */ jsxs("li", { children: [
|
|
702
|
+
/* @__PURE__ */ jsx6("span", { children: api.name }),
|
|
703
|
+
/* @__PURE__ */ jsxs("small", { children: [
|
|
704
|
+
"spec ",
|
|
705
|
+
api.specHash,
|
|
706
|
+
" \xB7 ",
|
|
707
|
+
api.operationCount,
|
|
708
|
+
" ",
|
|
709
|
+
api.operationCount === 1 ? "operation" : "operations"
|
|
710
|
+
] })
|
|
711
|
+
] }, api.name)) }) : null
|
|
694
712
|
] })
|
|
695
713
|
] }),
|
|
696
714
|
/* @__PURE__ */ jsx6("span", { className: "frankie-sr-only", role: "status", children: loadedSkills === null ? status : `${loadedSkills.length} ${loadedSkills.length === 1 ? "skill" : "skills"} loaded. ${status}.` })
|