organify-ui 0.3.3 → 0.3.5

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,201 @@
1
+ import { a as AiChatMessage } from '../ai-chat-sidebar-DnEOUzSL.js';
2
+ import 'react/jsx-runtime';
3
+
4
+ interface AiAction {
5
+ type: string;
6
+ label: string;
7
+ description?: string;
8
+ applied?: boolean;
9
+ }
10
+ interface AiChatResponse {
11
+ message: string;
12
+ provider: string;
13
+ tokensUsed: number;
14
+ actions: AiAction[];
15
+ }
16
+ interface AiCommandResponse {
17
+ message: string;
18
+ provider: string;
19
+ tokensUsed: number;
20
+ actions: AiAction[];
21
+ }
22
+ interface AiSuggestResponse {
23
+ suggestion: string;
24
+ }
25
+ interface AiResetResponse {
26
+ message: string;
27
+ }
28
+ interface AiUsageResponse {
29
+ used: number;
30
+ limit: number;
31
+ remaining: number;
32
+ }
33
+ interface AiAdminLogsResponse {
34
+ logs: AiAdminLog[];
35
+ total: number;
36
+ }
37
+ interface AiAdminLog {
38
+ userId: string;
39
+ action: string;
40
+ tokensUsed: number;
41
+ timestamp: string;
42
+ workspaceId?: string;
43
+ projectId?: string;
44
+ }
45
+ interface AiAdminStatsResponse {
46
+ totalRequests: number;
47
+ totalTokens: number;
48
+ uniqueUsers: number;
49
+ [key: string]: unknown;
50
+ }
51
+ interface AiAdminUsersResponse {
52
+ users: AiAdminUserStat[];
53
+ }
54
+ interface AiAdminUserStat {
55
+ userId: string;
56
+ requests: number;
57
+ tokens: number;
58
+ }
59
+ interface AiClientConfig {
60
+ /**
61
+ * Base URL of the API gateway (e.g. "https://api.organify.app" or
62
+ * "http://localhost:4000"). Must NOT have a trailing slash.
63
+ */
64
+ baseUrl: string;
65
+ /**
66
+ * Optional – if provided, sends as `Authorization: Bearer <token>`.
67
+ * The gateway will forward it and inject user-identity headers before
68
+ * reaching the AI service.
69
+ */
70
+ getToken?: () => string | null | undefined;
71
+ }
72
+ declare function createAiClient(config: AiClientConfig): {
73
+ /**
74
+ * Multi-turn conversational chat.
75
+ * The gateway injects `x-user-id` / `x-user-plan` from the JWT.
76
+ */
77
+ chat(params: {
78
+ message: string;
79
+ workspaceId: string;
80
+ projectId?: string;
81
+ }): Promise<AiChatResponse>;
82
+ /**
83
+ * Single-shot command (⌘K palette).
84
+ */
85
+ command(params: {
86
+ prompt: string;
87
+ workspaceId: string;
88
+ projectId?: string;
89
+ }): Promise<AiCommandResponse>;
90
+ /**
91
+ * Lightweight inline suggestion (no rate-limit increment).
92
+ */
93
+ suggest(params: {
94
+ prompt: string;
95
+ }): Promise<AiSuggestResponse>;
96
+ /**
97
+ * Reset conversation context for a workspace.
98
+ */
99
+ reset(params: {
100
+ workspaceId: string;
101
+ }): Promise<AiResetResponse>;
102
+ /**
103
+ * Get per-user usage stats (requests used today, daily limit, remaining).
104
+ */
105
+ getUsage(): Promise<AiUsageResponse>;
106
+ /** [Admin] Get request logs. Requires `x-user-role: admin` in JWT. */
107
+ adminLogs(query?: Record<string, string>): Promise<AiAdminLogsResponse>;
108
+ /** [Admin] Get aggregate stats. Requires `x-user-role: admin` in JWT. */
109
+ adminStats(query?: Record<string, string>): Promise<AiAdminStatsResponse>;
110
+ /** [Admin] Get per-user usage stats. Requires `x-user-role: admin` in JWT. */
111
+ adminUsers(query?: Record<string, string>): Promise<AiAdminUsersResponse>;
112
+ };
113
+ type AiClient = ReturnType<typeof createAiClient>;
114
+
115
+ interface UseAiChatOptions {
116
+ client: AiClient | AiClientConfig;
117
+ workspaceId: string;
118
+ projectId?: string;
119
+ }
120
+ interface UseAiChatResult {
121
+ messages: AiChatMessage[];
122
+ loading: boolean;
123
+ error: string | null;
124
+ send: (message: string) => Promise<void>;
125
+ reset: () => Promise<void>;
126
+ clearMessages: () => void;
127
+ }
128
+ /**
129
+ * Manages conversation state for `<AiChatSidebar>`.
130
+ *
131
+ * @example
132
+ * const chat = useAiChat({ client: ai, workspaceId: 'ws_1' });
133
+ * <AiChatSidebar messages={chat.messages} onSend={chat.send} loading={chat.loading} ... />
134
+ */
135
+ declare function useAiChat({ client: clientOrConfig, workspaceId, projectId, }: UseAiChatOptions): UseAiChatResult;
136
+ interface UseAiCommandOptions {
137
+ client: AiClient | AiClientConfig;
138
+ workspaceId: string;
139
+ projectId?: string;
140
+ }
141
+ interface UseAiCommandResult {
142
+ loading: boolean;
143
+ response: string | null;
144
+ actions: AiAction[];
145
+ error: string | null;
146
+ runCommand: (prompt: string) => Promise<void>;
147
+ clear: () => void;
148
+ }
149
+ /**
150
+ * Handles a single ⌘K command prompt for `<CommandBar>`.
151
+ *
152
+ * @example
153
+ * const cmd = useAiCommand({ client: ai, workspaceId: 'ws_1' });
154
+ * <CommandBar onAiPrompt={cmd.runCommand} aiLoading={cmd.loading} aiResponse={cmd.response ?? undefined} ... />
155
+ */
156
+ declare function useAiCommand({ client: clientOrConfig, workspaceId, projectId, }: UseAiCommandOptions): UseAiCommandResult;
157
+ interface UseAiSuggestOptions {
158
+ client: AiClient | AiClientConfig;
159
+ /** Debounce delay in ms before firing the API call (default: 400) */
160
+ debounceMs?: number;
161
+ }
162
+ interface UseAiSuggestResult {
163
+ loading: boolean;
164
+ suggestion: string | null;
165
+ error: string | null;
166
+ getSuggestion: (prompt: string) => void;
167
+ accept: () => string | null;
168
+ dismiss: () => void;
169
+ }
170
+ /**
171
+ * Provides debounced inline AI suggestions for `<InlineAiButton>`.
172
+ *
173
+ * @example
174
+ * const inline = useAiSuggest({ client: ai });
175
+ * <InlineAiButton
176
+ * onTrigger={(text) => inline.getSuggestion(text ?? '')}
177
+ * loading={inline.loading}
178
+ * suggestion={inline.suggestion ?? undefined}
179
+ * onAccept={inline.accept}
180
+ * onDismiss={inline.dismiss}
181
+ * />
182
+ */
183
+ declare function useAiSuggest({ client: clientOrConfig, debounceMs, }: UseAiSuggestOptions): UseAiSuggestResult;
184
+ interface UseAiUsageResult {
185
+ usage: AiUsageResponse | null;
186
+ loading: boolean;
187
+ error: string | null;
188
+ refresh: () => Promise<void>;
189
+ }
190
+ /**
191
+ * Fetches and caches the current user's AI usage stats.
192
+ *
193
+ * @example
194
+ * const { usage } = useAiUsage({ client: ai });
195
+ * <p>{usage?.remaining} requests left today</p>
196
+ */
197
+ declare function useAiUsage({ client: clientOrConfig }: {
198
+ client: AiClient | AiClientConfig;
199
+ }): UseAiUsageResult;
200
+
201
+ export { type AiAction, type AiAdminLog, type AiAdminLogsResponse, type AiAdminStatsResponse, type AiAdminUserStat, type AiAdminUsersResponse, type AiChatResponse, type AiClient, type AiClientConfig, type AiCommandResponse, type AiResetResponse, type AiSuggestResponse, type AiUsageResponse, type UseAiChatOptions, type UseAiChatResult, type UseAiCommandOptions, type UseAiCommandResult, type UseAiSuggestOptions, type UseAiSuggestResult, type UseAiUsageResult, createAiClient, useAiChat, useAiCommand, useAiSuggest, useAiUsage };
@@ -0,0 +1,3 @@
1
+ export { createAiClient, useAiChat, useAiCommand, useAiSuggest, useAiUsage } from '../chunk-P2ORBJBL.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,29 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface AiChatMessage {
4
+ id: string;
5
+ role: 'user' | 'assistant' | 'system';
6
+ content: string;
7
+ timestamp: Date;
8
+ actions?: AiAction[];
9
+ loading?: boolean;
10
+ }
11
+ interface AiAction {
12
+ type: string;
13
+ label: string;
14
+ description?: string;
15
+ applied?: boolean;
16
+ }
17
+ interface AiChatSidebarProps {
18
+ open: boolean;
19
+ onOpenChange: (open: boolean) => void;
20
+ messages: AiChatMessage[];
21
+ onSend: (message: string) => void;
22
+ loading?: boolean;
23
+ userName?: string;
24
+ contextLabel?: string;
25
+ placeholder?: string;
26
+ }
27
+ declare function AiChatSidebar({ open, onOpenChange, messages, onSend, loading, userName, contextLabel, placeholder, }: AiChatSidebarProps): react_jsx_runtime.JSX.Element;
28
+
29
+ export { type AiAction as A, type AiChatMessage as a, AiChatSidebar as b, type AiChatSidebarProps as c };