@seclai/react 0.0.0-stage → 0.0.0

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.
@@ -0,0 +1,140 @@
1
+ import * as react from 'react';
2
+
3
+ /**
4
+ * The handlers' wire format, declared here rather than imported from
5
+ * `@seclai/handlers` or `@seclai/sdk` so the browser bundle stays free of both.
6
+ * Only the fields this package reads are listed.
7
+ */
8
+ /** A file slot declared by the agent's trigger. */
9
+ interface AcceptedAttachmentSlot {
10
+ name: string;
11
+ label?: string | null;
12
+ min?: number;
13
+ max?: number | null;
14
+ content_types?: string[];
15
+ name_pattern?: string | null;
16
+ }
17
+ /** The response from the `attachment-references` endpoint. */
18
+ interface AttachmentReferences {
19
+ requires_uploads: boolean;
20
+ accepted_attachments?: AcceptedAttachmentSlot[];
21
+ }
22
+ /** The response from the `upload` endpoint. */
23
+ interface UploadResult {
24
+ id: string;
25
+ status: string;
26
+ filename: string;
27
+ content_type: string;
28
+ file_size: number;
29
+ }
30
+ /** A file produced by a run, with a `url` that goes through the download proxy. */
31
+ interface AgentAttachment {
32
+ id: string;
33
+ name: string | null;
34
+ mime: string;
35
+ bytes: number | null;
36
+ url: string;
37
+ }
38
+ /** The latest progress for one step of a run. */
39
+ interface AgentRunStep {
40
+ id: string;
41
+ name: string;
42
+ message: string;
43
+ }
44
+ type AgentRunStatus = "idle" | "running" | "completed" | "failed" | "cancelled";
45
+ /** What the agent UI boots in: a one-shot form, or a multi-turn chat. */
46
+ type AgentUiMode = "form" | "chat";
47
+ /** Where the handlers are mounted. */
48
+ interface AgentEndpointOptions {
49
+ /** Base path the handlers are mounted under. Defaults to `/api/seclai`. */
50
+ basePath?: string;
51
+ /**
52
+ * Adds the agent id to the path, for a server that hosts several agents:
53
+ * `${basePath}/${agentId}/run`. Leave it out when the server has just one. The
54
+ * server still decides which agents it serves.
55
+ */
56
+ agentId?: string;
57
+ }
58
+
59
+ interface AgentChatProps extends AgentEndpointOptions {
60
+ /** Placeholder for the message box. */
61
+ placeholder?: string;
62
+ }
63
+ /**
64
+ * 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.
66
+ */
67
+ declare function AgentChat({ basePath, agentId, placeholder }: AgentChatProps): react.JSX.Element;
68
+
69
+ interface AgentRunState {
70
+ status: AgentRunStatus;
71
+ /** Streamed tokens while running; the run's final `output` once it completes. */
72
+ text: string;
73
+ /** Latest progress per step, in the order the steps started. */
74
+ steps: AgentRunStep[];
75
+ attachments: AgentAttachment[];
76
+ error: string | null;
77
+ runId: string | null;
78
+ }
79
+ interface StartRunOptions {
80
+ input?: string;
81
+ uploadIds?: string[];
82
+ /** Keys a conversation: sent to the agent as `metadata.session_id`. */
83
+ sessionId?: string;
84
+ }
85
+ interface UseAgentRunResult extends AgentRunState {
86
+ /**
87
+ * Start a run, cancelling any run in progress. Resolves with the final state
88
+ * and never rejects: failures are reported through `status` and `error`.
89
+ */
90
+ start(options: StartRunOptions): Promise<AgentRunState>;
91
+ /**
92
+ * Stop streaming this run. This closes the connection but does not cancel the
93
+ * run on Seclai, which may carry on and use credits.
94
+ */
95
+ cancel(): void;
96
+ }
97
+ /** Run an agent through the handlers' `run` endpoint and track the event stream. */
98
+ declare function useAgentRun(options?: AgentEndpointOptions): UseAgentRunResult;
99
+
100
+ interface AgentRunFormProps extends AgentEndpointOptions {
101
+ /** Label for the text input. */
102
+ inputLabel?: string;
103
+ /** Called when a run finishes, whether it succeeded or not. */
104
+ onFinish?(result: AgentRunState): void;
105
+ }
106
+ /**
107
+ * A form built from what the agent accepts: a text input plus one file input per
108
+ * declared attachment. It uploads the files, then runs with text and files
109
+ * together and shows the output.
110
+ */
111
+ declare function AgentRunForm({ basePath, agentId, inputLabel, onFinish }: AgentRunFormProps): react.JSX.Element;
112
+
113
+ interface SeclaiAgentProps extends AgentEndpointOptions {
114
+ /** `form` for a one-shot run, `chat` for a multi-turn conversation. */
115
+ mode: AgentUiMode;
116
+ }
117
+ /** Boots the agent UI from its mode, and its agent id when the server hosts several. */
118
+ declare function SeclaiAgent({ mode, basePath, agentId }: SeclaiAgentProps): react.JSX.Element;
119
+
120
+ declare const DEFAULT_BASE_PATH = "/api/seclai";
121
+
122
+ interface MarkdownContentProps {
123
+ content: string;
124
+ }
125
+ /**
126
+ * Shows agent output. For now it renders plain text, never HTML. Markdown
127
+ * rendering, with tables, maths and diagrams, is coming in a later version.
128
+ */
129
+ declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
130
+
131
+ interface MediaPreviewProps {
132
+ attachment: AgentAttachment;
133
+ }
134
+ /**
135
+ * Shows a file from a run. For now images show inline and everything else is a
136
+ * download link. Audio, video and PDF previews are coming in a later version.
137
+ */
138
+ declare function MediaPreview({ attachment }: MediaPreviewProps): react.JSX.Element;
139
+
140
+ export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatProps, type AgentEndpointOptions, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunResult, useAgentRun };
@@ -0,0 +1,140 @@
1
+ import * as react from 'react';
2
+
3
+ /**
4
+ * The handlers' wire format, declared here rather than imported from
5
+ * `@seclai/handlers` or `@seclai/sdk` so the browser bundle stays free of both.
6
+ * Only the fields this package reads are listed.
7
+ */
8
+ /** A file slot declared by the agent's trigger. */
9
+ interface AcceptedAttachmentSlot {
10
+ name: string;
11
+ label?: string | null;
12
+ min?: number;
13
+ max?: number | null;
14
+ content_types?: string[];
15
+ name_pattern?: string | null;
16
+ }
17
+ /** The response from the `attachment-references` endpoint. */
18
+ interface AttachmentReferences {
19
+ requires_uploads: boolean;
20
+ accepted_attachments?: AcceptedAttachmentSlot[];
21
+ }
22
+ /** The response from the `upload` endpoint. */
23
+ interface UploadResult {
24
+ id: string;
25
+ status: string;
26
+ filename: string;
27
+ content_type: string;
28
+ file_size: number;
29
+ }
30
+ /** A file produced by a run, with a `url` that goes through the download proxy. */
31
+ interface AgentAttachment {
32
+ id: string;
33
+ name: string | null;
34
+ mime: string;
35
+ bytes: number | null;
36
+ url: string;
37
+ }
38
+ /** The latest progress for one step of a run. */
39
+ interface AgentRunStep {
40
+ id: string;
41
+ name: string;
42
+ message: string;
43
+ }
44
+ type AgentRunStatus = "idle" | "running" | "completed" | "failed" | "cancelled";
45
+ /** What the agent UI boots in: a one-shot form, or a multi-turn chat. */
46
+ type AgentUiMode = "form" | "chat";
47
+ /** Where the handlers are mounted. */
48
+ interface AgentEndpointOptions {
49
+ /** Base path the handlers are mounted under. Defaults to `/api/seclai`. */
50
+ basePath?: string;
51
+ /**
52
+ * Adds the agent id to the path, for a server that hosts several agents:
53
+ * `${basePath}/${agentId}/run`. Leave it out when the server has just one. The
54
+ * server still decides which agents it serves.
55
+ */
56
+ agentId?: string;
57
+ }
58
+
59
+ interface AgentChatProps extends AgentEndpointOptions {
60
+ /** Placeholder for the message box. */
61
+ placeholder?: string;
62
+ }
63
+ /**
64
+ * 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.
66
+ */
67
+ declare function AgentChat({ basePath, agentId, placeholder }: AgentChatProps): react.JSX.Element;
68
+
69
+ interface AgentRunState {
70
+ status: AgentRunStatus;
71
+ /** Streamed tokens while running; the run's final `output` once it completes. */
72
+ text: string;
73
+ /** Latest progress per step, in the order the steps started. */
74
+ steps: AgentRunStep[];
75
+ attachments: AgentAttachment[];
76
+ error: string | null;
77
+ runId: string | null;
78
+ }
79
+ interface StartRunOptions {
80
+ input?: string;
81
+ uploadIds?: string[];
82
+ /** Keys a conversation: sent to the agent as `metadata.session_id`. */
83
+ sessionId?: string;
84
+ }
85
+ interface UseAgentRunResult extends AgentRunState {
86
+ /**
87
+ * Start a run, cancelling any run in progress. Resolves with the final state
88
+ * and never rejects: failures are reported through `status` and `error`.
89
+ */
90
+ start(options: StartRunOptions): Promise<AgentRunState>;
91
+ /**
92
+ * Stop streaming this run. This closes the connection but does not cancel the
93
+ * run on Seclai, which may carry on and use credits.
94
+ */
95
+ cancel(): void;
96
+ }
97
+ /** Run an agent through the handlers' `run` endpoint and track the event stream. */
98
+ declare function useAgentRun(options?: AgentEndpointOptions): UseAgentRunResult;
99
+
100
+ interface AgentRunFormProps extends AgentEndpointOptions {
101
+ /** Label for the text input. */
102
+ inputLabel?: string;
103
+ /** Called when a run finishes, whether it succeeded or not. */
104
+ onFinish?(result: AgentRunState): void;
105
+ }
106
+ /**
107
+ * A form built from what the agent accepts: a text input plus one file input per
108
+ * declared attachment. It uploads the files, then runs with text and files
109
+ * together and shows the output.
110
+ */
111
+ declare function AgentRunForm({ basePath, agentId, inputLabel, onFinish }: AgentRunFormProps): react.JSX.Element;
112
+
113
+ interface SeclaiAgentProps extends AgentEndpointOptions {
114
+ /** `form` for a one-shot run, `chat` for a multi-turn conversation. */
115
+ mode: AgentUiMode;
116
+ }
117
+ /** Boots the agent UI from its mode, and its agent id when the server hosts several. */
118
+ declare function SeclaiAgent({ mode, basePath, agentId }: SeclaiAgentProps): react.JSX.Element;
119
+
120
+ declare const DEFAULT_BASE_PATH = "/api/seclai";
121
+
122
+ interface MarkdownContentProps {
123
+ content: string;
124
+ }
125
+ /**
126
+ * Shows agent output. For now it renders plain text, never HTML. Markdown
127
+ * rendering, with tables, maths and diagrams, is coming in a later version.
128
+ */
129
+ declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
130
+
131
+ interface MediaPreviewProps {
132
+ attachment: AgentAttachment;
133
+ }
134
+ /**
135
+ * Shows a file from a run. For now images show inline and everything else is a
136
+ * download link. Audio, video and PDF previews are coming in a later version.
137
+ */
138
+ declare function MediaPreview({ attachment }: MediaPreviewProps): react.JSX.Element;
139
+
140
+ export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatProps, type AgentEndpointOptions, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunResult, useAgentRun };