@fencyai/react 0.1.110 → 0.1.112

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.
Files changed (30) hide show
  1. package/dist/{chat → agent-task}/AgentTaskProgress.d.ts +2 -3
  2. package/dist/agent-task/AgentTaskProgressSimple.d.ts +5 -0
  3. package/dist/agent-task/AgentTaskProgressVerbose.d.ts +9 -0
  4. package/dist/agent-task/ProgressViewItem.d.ts +9 -0
  5. package/dist/agent-task/data-types/GenericAgentTaskExecution.d.ts +11 -0
  6. package/dist/agent-task/data-types/GenericAgentTaskFinalResponse.d.ts +13 -0
  7. package/dist/agent-task/data-types/GenericAgentTaskReasoning.d.ts +11 -0
  8. package/dist/assets/index.css +1 -1
  9. package/dist/index.d.ts +7 -6
  10. package/dist/index.js +867 -849
  11. package/dist/provider/StreamEventManager.d.ts +36 -0
  12. package/dist/types/{StreamingAgentTask.d.ts → AgentTask.d.ts} +6 -4
  13. package/dist/types/{StreamingAgentTaskData.d.ts → AgentTaskData.d.ts} +1 -1
  14. package/dist/types/AgentTaskEventData.d.ts +11 -0
  15. package/dist/types/FencyContext.d.ts +4 -1
  16. package/dist/types/StreamData.d.ts +2 -4
  17. package/dist/types/UseAgentTasks.d.ts +3 -3
  18. package/dist/types/index.d.ts +2 -2
  19. package/package.json +6 -4
  20. package/dist/chat/ChatResponse.d.ts +0 -22
  21. package/dist/chat/ChatResponseComplete.d.ts +0 -10
  22. package/dist/chat/ChatResponseLoading.d.ts +0 -8
  23. package/dist/chat/ChatResponseThinking.d.ts +0 -8
  24. package/dist/chat/EditableContent.d.ts +0 -11
  25. package/dist/chat/GhostWrapper.d.ts +0 -10
  26. /package/dist/{chat → agent-task}/ShimmeringText.d.ts +0 -0
  27. /package/dist/{chat → agent-task}/hooks/useContentEditable.d.ts +0 -0
  28. /package/dist/{chat → agent-task}/hooks/useMentionParser.d.ts +0 -0
  29. /package/dist/{chat → agent-task}/hooks/useMentionRenderer.d.ts +0 -0
  30. /package/dist/{chat → agent-task}/hooks/useMentionState.d.ts +0 -0
@@ -0,0 +1,36 @@
1
+ import { FencyInstance } from '@fencyai/js';
2
+ import { StreamCache } from '../types/FencyContext';
3
+ type EventCallback = (data: string, streamId: string) => void;
4
+ type ErrorCallback = (streamId: string) => void;
5
+ interface Subscription {
6
+ onMessage: EventCallback;
7
+ onError: ErrorCallback;
8
+ }
9
+ /**
10
+ * Centralized manager for EventSource connections to streams.
11
+ * Ensures only one connection per stream regardless of how many hooks subscribe.
12
+ */
13
+ export declare class StreamEventManager {
14
+ private eventSources;
15
+ private subscribers;
16
+ private fency;
17
+ constructor(fency: FencyInstance);
18
+ /**
19
+ * Called by FencyProvider when activeStreams changes.
20
+ * Creates new connections and removes old ones.
21
+ */
22
+ updateStreams(streams: StreamCache[]): void;
23
+ private connectStream;
24
+ /**
25
+ * Subscribe to events from all active streams.
26
+ * Returns an unsubscribe function.
27
+ */
28
+ subscribe(subscriberId: string, callbacks: Subscription): () => void;
29
+ private broadcast;
30
+ private broadcastError;
31
+ /**
32
+ * Cleanup all connections and subscriptions
33
+ */
34
+ cleanup(): void;
35
+ }
36
+ export {};
@@ -1,14 +1,16 @@
1
1
  import { ApiError } from '@fencyai/js';
2
2
  import { CreateAgentTaskParams } from './CreateAgentTaskParams';
3
3
  import { AgentTaskProgressItemUpdated } from './StreamData';
4
- import { StreamingAgentTaskData } from './StreamingAgentTaskData';
5
- export interface StreamingAgentTask {
4
+ export interface AgentTask {
6
5
  streamId: string;
7
6
  triggeredAt: string;
8
- data: StreamingAgentTaskData | null;
9
7
  error: ApiError | null;
10
- prompt: CreateAgentTaskParams;
8
+ params: CreateAgentTaskParams;
11
9
  progressItems: AgentTaskProgressItemUpdated[];
12
10
  loading: boolean;
13
11
  doneStreaming: boolean;
12
+ confirmedData: {
13
+ taskId: string;
14
+ createdAt: string;
15
+ } | null;
14
16
  }
@@ -1,4 +1,4 @@
1
- export interface StreamingAgentTaskData {
1
+ export interface AgentTaskData {
2
2
  id: string;
3
3
  createdAt: string;
4
4
  streamId: string;
@@ -0,0 +1,11 @@
1
+ export type AgentTaskEventData = {
2
+ type: 'GenericAgentTaskFinalResponse';
3
+ response: string;
4
+ } | {
5
+ type: 'GenericAgentTaskExecution';
6
+ title: string;
7
+ } | {
8
+ type: 'GenericAgentTaskReasoning';
9
+ title: string;
10
+ reasoning: string;
11
+ };
@@ -1,4 +1,5 @@
1
1
  import { FencyInstance, Stream } from '@fencyai/js';
2
+ import { StreamEventManager } from '../provider/StreamEventManager';
2
3
  export interface StreamCache {
3
4
  stream: Stream;
4
5
  createdAt: number;
@@ -7,7 +8,9 @@ export interface FencyContext {
7
8
  fency: FencyInstance;
8
9
  loading: boolean;
9
10
  error: Error | null;
10
- activeStream: StreamCache | null;
11
+ activeStreams: StreamCache[];
12
+ latestStream: StreamCache | null;
13
+ eventManager: StreamEventManager | null;
11
14
  getOrCreateStream: (fetchTokens: () => Promise<{
12
15
  clientToken: string;
13
16
  streamToken: string;
@@ -1,4 +1,4 @@
1
- import { AgentTaskProgressItemType } from '@fencyai/js';
1
+ import { AgentTaskEventData } from './AgentTaskEventData';
2
2
  export type NewChatCompletionStreamChunk = {
3
3
  type: 'NewChatCompletionStreamChunk';
4
4
  streamId: string;
@@ -61,10 +61,8 @@ export type AgentTaskProgressItemUpdated = {
61
61
  streamId: string;
62
62
  agentTaskId: string;
63
63
  progressItemId: string;
64
- title: string;
65
64
  timestamp: string;
66
65
  createdAt: string;
67
- response: string;
68
- progressItemType: AgentTaskProgressItemType;
66
+ data: AgentTaskEventData;
69
67
  };
70
68
  export type StreamData = NewChatCompletionStreamChunk | ChatCompletionStreamCompleted | StreamTimeout | StreamNotFound | FileUploadCompleted | FileTextContentReady | WebsiteHtmlContentReady | WebsiteTextContentReady | FileSearchIndexReady | AgentTaskProgressItemUpdated;
@@ -1,8 +1,8 @@
1
1
  import { CreateAgentTaskParams } from './CreateAgentTaskParams';
2
2
  import { CreateAgentTaskResponse } from './CreateAgentTaskResponse';
3
- import { StreamingAgentTask } from './StreamingAgentTask';
3
+ import { AgentTask } from './AgentTask';
4
4
  export interface UseAgentTasks {
5
- agentTasks: StreamingAgentTask[];
5
+ agentTasks: AgentTask[];
6
6
  createAgentTask: (params: CreateAgentTaskParams) => Promise<CreateAgentTaskResponse>;
7
- latest?: StreamingAgentTask;
7
+ latest?: AgentTask;
8
8
  }
@@ -6,7 +6,7 @@ export * from './UseStream';
6
6
  export * from './UseStreamProps';
7
7
  export * from './CreateAgentTaskParams';
8
8
  export * from './CreateAgentTaskResponse';
9
- export * from './StreamingAgentTask';
10
- export * from './StreamingAgentTaskData';
9
+ export * from './AgentTask';
10
+ export * from './AgentTaskData';
11
11
  export * from './UseAgentTasks';
12
12
  export * from './UseAgentTasksProps';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/react",
3
- "version": "0.1.110",
3
+ "version": "0.1.112",
4
4
  "description": "> TODO: description",
5
5
  "author": "staklau <steinaageklaussen@gmail.com>",
6
6
  "homepage": "",
@@ -35,13 +35,15 @@
35
35
  "@microsoft/fetch-event-source": "^2.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@fencyai/js": "^0.1.110",
38
+ "@fencyai/js": "^0.1.112",
39
+ "@testing-library/react": "^16.3.2",
39
40
  "@types/jest": "^29.5.11",
40
41
  "@types/node": "^20.10.5",
41
42
  "@types/react": "^18.2.45",
42
43
  "@types/react-syntax-highlighter": "^15.5.13",
43
44
  "@vitejs/plugin-react": "^4.3.4",
44
45
  "jest": "^29.7.0",
46
+ "jest-environment-jsdom": "^30.2.0",
45
47
  "ts-jest": "^29.1.1",
46
48
  "typescript": "^5.3.3",
47
49
  "vite": "^5.4.11",
@@ -50,7 +52,7 @@
50
52
  },
51
53
  "peerDependencies": {
52
54
  "@emotion/is-prop-valid": "^1.3.0",
53
- "@fencyai/js": "^0.1.110",
55
+ "@fencyai/js": "^0.1.112",
54
56
  "@radix-ui/react-popover": "^1.1.15",
55
57
  "motion": "^11.15.0",
56
58
  "react": ">=16.8.0",
@@ -65,5 +67,5 @@
65
67
  "optional": false
66
68
  }
67
69
  },
68
- "gitHead": "9836dad9a8577fb445a3a378490071c0522fbca7"
70
+ "gitHead": "ec810f984fd9010de0c81701cfb60547ab7584b8"
69
71
  }
@@ -1,22 +0,0 @@
1
- import { AgentTaskProgressItemType } from '@fencyai/js';
2
- import { default as React } from 'react';
3
- export type ChatResponseState = 'thinking' | 'loading' | 'complete';
4
- export type ChatResponseMessage = {
5
- id: string;
6
- title: string;
7
- markdown: string;
8
- state: AgentTaskProgressItemType;
9
- completed: boolean;
10
- startedAt?: string;
11
- completedAt?: string;
12
- durationSeconds?: number;
13
- };
14
- export interface ChatResponseProps {
15
- message: ChatResponseMessage;
16
- isLatest?: boolean;
17
- streamToken: string;
18
- fetchClientToken: () => Promise<{
19
- clientToken: string;
20
- }>;
21
- }
22
- export declare const ChatResponse: React.FC<ChatResponseProps>;
@@ -1,10 +0,0 @@
1
- import { default as React } from 'react';
2
- export interface ChatResponseCompleteProps {
3
- markdown: string;
4
- streamToken: string;
5
- fetchClientToken: () => Promise<{
6
- clientToken: string;
7
- }>;
8
- durationSeconds?: number;
9
- }
10
- export declare const ChatResponseComplete: React.FC<ChatResponseCompleteProps>;
@@ -1,8 +0,0 @@
1
- import { default as React } from 'react';
2
- export interface ChatResponseLoadingProps {
3
- title: string;
4
- completed: boolean;
5
- isLatest?: boolean;
6
- durationSeconds?: number;
7
- }
8
- export declare const ChatResponseLoading: React.FC<ChatResponseLoadingProps>;
@@ -1,8 +0,0 @@
1
- export interface ChatResponseThinkingProps {
2
- title: string;
3
- markdown: string;
4
- completed: boolean;
5
- isLatest?: boolean;
6
- durationSeconds?: number;
7
- }
8
- export declare const ChatResponseThinking: React.FC<ChatResponseThinkingProps>;
@@ -1,11 +0,0 @@
1
- import { default as React } from 'react';
2
- interface EditableContentProps {
3
- editableRef: React.RefObject<HTMLDivElement>;
4
- onInput: () => void;
5
- onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
6
- isComposingRef: React.MutableRefObject<boolean>;
7
- handleInput: () => void;
8
- placeholder?: string;
9
- }
10
- export declare const EditableContent: React.FC<EditableContentProps>;
11
- export {};
@@ -1,10 +0,0 @@
1
- import { default as React } from 'react';
2
- interface GhostWrapperProps {
3
- ghostRef: React.RefObject<HTMLDivElement>;
4
- isOpen: boolean;
5
- value: string;
6
- atPosition: number;
7
- caretPos: number;
8
- }
9
- export declare const GhostWrapper: React.FC<GhostWrapperProps>;
10
- export {};
File without changes