@seclai/react 0.0.5 → 0.0.7
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/README.md +57 -3
- package/dist/index.cjs +361 -83
- package/dist/index.d.cts +66 -4
- package/dist/index.d.ts +66 -4
- package/dist/index.js +361 -78
- package/dist/styles.css +134 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -56,15 +56,52 @@ interface AgentEndpointOptions {
|
|
|
56
56
|
agentId?: string;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** A named attach button, such as "+ Headshot". */
|
|
60
|
+
interface AgentChatAttachButton {
|
|
61
|
+
label: string;
|
|
62
|
+
/** Stays with every file added through this button. See `onBeforeSend`. */
|
|
63
|
+
tag?: string;
|
|
64
|
+
}
|
|
65
|
+
/** A file the user sent with a message. */
|
|
66
|
+
interface AgentChatFile {
|
|
67
|
+
uploadId: string;
|
|
68
|
+
name: string;
|
|
69
|
+
contentType: string;
|
|
70
|
+
/** The tag of the attach button it was added with. Dropped and pasted files have none. */
|
|
71
|
+
tag?: string;
|
|
72
|
+
}
|
|
73
|
+
/** What `onBeforeSend` gets: the typed text and the files going with it. */
|
|
74
|
+
interface AgentChatMessage {
|
|
75
|
+
input: string;
|
|
76
|
+
files: AgentChatFile[];
|
|
77
|
+
}
|
|
59
78
|
interface AgentChatProps extends AgentEndpointOptions {
|
|
60
79
|
/** Placeholder for the message box. */
|
|
61
80
|
placeholder?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Named attach buttons, for agents that take files. Without them the chat shows
|
|
83
|
+
* one "Attach" button, and only when the agent accepts files.
|
|
84
|
+
*/
|
|
85
|
+
attachButtons?: AgentChatAttachButton[];
|
|
86
|
+
/**
|
|
87
|
+
* Called as a message is sent. Return a string to send that as the run's input
|
|
88
|
+
* in place of the typed text, for example to tell the agent which file is which
|
|
89
|
+
* from their tags. The transcript still shows what the user typed.
|
|
90
|
+
*/
|
|
91
|
+
onBeforeSend?(message: AgentChatMessage): string | void;
|
|
62
92
|
}
|
|
63
93
|
/**
|
|
64
94
|
* A multi-turn chat. Each message is its own run, and the agent ties them into a
|
|
65
|
-
* conversation through the session id in the run's metadata.
|
|
95
|
+
* conversation through the session id in the run's metadata. When the agent
|
|
96
|
+
* accepts files they can be attached, dropped or pasted, and each one uploads
|
|
97
|
+
* as soon as it's added.
|
|
66
98
|
*/
|
|
67
|
-
declare function AgentChat({ basePath, agentId, placeholder }: AgentChatProps): react.JSX.Element;
|
|
99
|
+
declare function AgentChat({ basePath, agentId, placeholder, attachButtons, onBeforeSend, }: AgentChatProps): react.JSX.Element;
|
|
100
|
+
|
|
101
|
+
interface SseEvent {
|
|
102
|
+
event: string;
|
|
103
|
+
data: unknown;
|
|
104
|
+
}
|
|
68
105
|
|
|
69
106
|
interface AgentRunState {
|
|
70
107
|
status: AgentRunStatus;
|
|
@@ -75,6 +112,24 @@ interface AgentRunState {
|
|
|
75
112
|
attachments: AgentAttachment[];
|
|
76
113
|
error: string | null;
|
|
77
114
|
runId: string | null;
|
|
115
|
+
/**
|
|
116
|
+
* When the current run started, from `Date.now()`. Kept once the run ends, so
|
|
117
|
+
* a UI can show how long it took. `null` until `start` is called, and again
|
|
118
|
+
* after `reset`.
|
|
119
|
+
*/
|
|
120
|
+
startedAt: number | null;
|
|
121
|
+
}
|
|
122
|
+
/** One event from the run stream: the SSE event name and its parsed JSON data. */
|
|
123
|
+
type AgentRunEvent = SseEvent;
|
|
124
|
+
interface UseAgentRunOptions extends AgentEndpointOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Called with each event read from the run stream, in order, as the hook
|
|
127
|
+
* applies it to the state. The latest callback is always used, so it can be
|
|
128
|
+
* an inline function. Events from a cancelled, reset or superseded run are
|
|
129
|
+
* not passed on. If it throws, the error is logged with `console.error` and
|
|
130
|
+
* the run carries on.
|
|
131
|
+
*/
|
|
132
|
+
onEvent?(event: AgentRunEvent): void;
|
|
78
133
|
}
|
|
79
134
|
interface StartRunOptions {
|
|
80
135
|
input?: string;
|
|
@@ -93,9 +148,16 @@ interface UseAgentRunResult extends AgentRunState {
|
|
|
93
148
|
* run on Seclai, which may carry on and use credits.
|
|
94
149
|
*/
|
|
95
150
|
cancel(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Return to `idle` and clear the state, stopping any stream in progress as
|
|
153
|
+
* `cancel` does. Like `cancel`, it doesn't stop the run on Seclai. A pending
|
|
154
|
+
* `start` still resolves, with `status: "cancelled"` and the run's last
|
|
155
|
+
* `text`, `runId` and `startedAt`, while the hook itself shows `idle`.
|
|
156
|
+
*/
|
|
157
|
+
reset(): void;
|
|
96
158
|
}
|
|
97
159
|
/** Run an agent through the handlers' `run` endpoint and track the event stream. */
|
|
98
|
-
declare function useAgentRun(options?:
|
|
160
|
+
declare function useAgentRun(options?: UseAgentRunOptions): UseAgentRunResult;
|
|
99
161
|
|
|
100
162
|
interface AgentRunFormProps extends AgentEndpointOptions {
|
|
101
163
|
/** Label for the text input. */
|
|
@@ -193,4 +255,4 @@ interface MediaPreviewProps {
|
|
|
193
255
|
*/
|
|
194
256
|
declare function MediaPreview({ attachment }: MediaPreviewProps): react.JSX.Element;
|
|
195
257
|
|
|
196
|
-
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunResult, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|
|
258
|
+
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,15 +56,52 @@ interface AgentEndpointOptions {
|
|
|
56
56
|
agentId?: string;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** A named attach button, such as "+ Headshot". */
|
|
60
|
+
interface AgentChatAttachButton {
|
|
61
|
+
label: string;
|
|
62
|
+
/** Stays with every file added through this button. See `onBeforeSend`. */
|
|
63
|
+
tag?: string;
|
|
64
|
+
}
|
|
65
|
+
/** A file the user sent with a message. */
|
|
66
|
+
interface AgentChatFile {
|
|
67
|
+
uploadId: string;
|
|
68
|
+
name: string;
|
|
69
|
+
contentType: string;
|
|
70
|
+
/** The tag of the attach button it was added with. Dropped and pasted files have none. */
|
|
71
|
+
tag?: string;
|
|
72
|
+
}
|
|
73
|
+
/** What `onBeforeSend` gets: the typed text and the files going with it. */
|
|
74
|
+
interface AgentChatMessage {
|
|
75
|
+
input: string;
|
|
76
|
+
files: AgentChatFile[];
|
|
77
|
+
}
|
|
59
78
|
interface AgentChatProps extends AgentEndpointOptions {
|
|
60
79
|
/** Placeholder for the message box. */
|
|
61
80
|
placeholder?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Named attach buttons, for agents that take files. Without them the chat shows
|
|
83
|
+
* one "Attach" button, and only when the agent accepts files.
|
|
84
|
+
*/
|
|
85
|
+
attachButtons?: AgentChatAttachButton[];
|
|
86
|
+
/**
|
|
87
|
+
* Called as a message is sent. Return a string to send that as the run's input
|
|
88
|
+
* in place of the typed text, for example to tell the agent which file is which
|
|
89
|
+
* from their tags. The transcript still shows what the user typed.
|
|
90
|
+
*/
|
|
91
|
+
onBeforeSend?(message: AgentChatMessage): string | void;
|
|
62
92
|
}
|
|
63
93
|
/**
|
|
64
94
|
* A multi-turn chat. Each message is its own run, and the agent ties them into a
|
|
65
|
-
* conversation through the session id in the run's metadata.
|
|
95
|
+
* conversation through the session id in the run's metadata. When the agent
|
|
96
|
+
* accepts files they can be attached, dropped or pasted, and each one uploads
|
|
97
|
+
* as soon as it's added.
|
|
66
98
|
*/
|
|
67
|
-
declare function AgentChat({ basePath, agentId, placeholder }: AgentChatProps): react.JSX.Element;
|
|
99
|
+
declare function AgentChat({ basePath, agentId, placeholder, attachButtons, onBeforeSend, }: AgentChatProps): react.JSX.Element;
|
|
100
|
+
|
|
101
|
+
interface SseEvent {
|
|
102
|
+
event: string;
|
|
103
|
+
data: unknown;
|
|
104
|
+
}
|
|
68
105
|
|
|
69
106
|
interface AgentRunState {
|
|
70
107
|
status: AgentRunStatus;
|
|
@@ -75,6 +112,24 @@ interface AgentRunState {
|
|
|
75
112
|
attachments: AgentAttachment[];
|
|
76
113
|
error: string | null;
|
|
77
114
|
runId: string | null;
|
|
115
|
+
/**
|
|
116
|
+
* When the current run started, from `Date.now()`. Kept once the run ends, so
|
|
117
|
+
* a UI can show how long it took. `null` until `start` is called, and again
|
|
118
|
+
* after `reset`.
|
|
119
|
+
*/
|
|
120
|
+
startedAt: number | null;
|
|
121
|
+
}
|
|
122
|
+
/** One event from the run stream: the SSE event name and its parsed JSON data. */
|
|
123
|
+
type AgentRunEvent = SseEvent;
|
|
124
|
+
interface UseAgentRunOptions extends AgentEndpointOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Called with each event read from the run stream, in order, as the hook
|
|
127
|
+
* applies it to the state. The latest callback is always used, so it can be
|
|
128
|
+
* an inline function. Events from a cancelled, reset or superseded run are
|
|
129
|
+
* not passed on. If it throws, the error is logged with `console.error` and
|
|
130
|
+
* the run carries on.
|
|
131
|
+
*/
|
|
132
|
+
onEvent?(event: AgentRunEvent): void;
|
|
78
133
|
}
|
|
79
134
|
interface StartRunOptions {
|
|
80
135
|
input?: string;
|
|
@@ -93,9 +148,16 @@ interface UseAgentRunResult extends AgentRunState {
|
|
|
93
148
|
* run on Seclai, which may carry on and use credits.
|
|
94
149
|
*/
|
|
95
150
|
cancel(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Return to `idle` and clear the state, stopping any stream in progress as
|
|
153
|
+
* `cancel` does. Like `cancel`, it doesn't stop the run on Seclai. A pending
|
|
154
|
+
* `start` still resolves, with `status: "cancelled"` and the run's last
|
|
155
|
+
* `text`, `runId` and `startedAt`, while the hook itself shows `idle`.
|
|
156
|
+
*/
|
|
157
|
+
reset(): void;
|
|
96
158
|
}
|
|
97
159
|
/** Run an agent through the handlers' `run` endpoint and track the event stream. */
|
|
98
|
-
declare function useAgentRun(options?:
|
|
160
|
+
declare function useAgentRun(options?: UseAgentRunOptions): UseAgentRunResult;
|
|
99
161
|
|
|
100
162
|
interface AgentRunFormProps extends AgentEndpointOptions {
|
|
101
163
|
/** Label for the text input. */
|
|
@@ -193,4 +255,4 @@ interface MediaPreviewProps {
|
|
|
193
255
|
*/
|
|
194
256
|
declare function MediaPreview({ attachment }: MediaPreviewProps): react.JSX.Element;
|
|
195
257
|
|
|
196
|
-
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunResult, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|
|
258
|
+
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|