@smart-cloud/ai-kit-ui 1.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,87 @@
1
+ import * as _smart_cloud_ai_kit_core from '@smart-cloud/ai-kit-core';
2
+ import { ContextKind, AiModePreference, AiKitLanguageCode, AiKitStatusEvent, AiWorkerProps } from '@smart-cloud/ai-kit-core';
3
+ import * as react from 'react';
4
+ import { FC, ComponentType } from 'react';
5
+
6
+ declare const AiFeature: FC<_smart_cloud_ai_kit_core.AiWorkerProps & {
7
+ mode: _smart_cloud_ai_kit_core.AiFeatureMode;
8
+ context?: ContextKind;
9
+ modeOverride?: AiModePreference;
10
+ autoRun?: boolean;
11
+ editable?: boolean;
12
+ acceptButtonTitle?: string;
13
+ showRegenerateOnBackendButton?: boolean;
14
+ optionsDisplay?: "collapse" | "horizontal" | "vertical";
15
+ default?: {
16
+ getText?: () => string;
17
+ text?: string;
18
+ image?: Blob;
19
+ instructions?: string;
20
+ inputLanguage?: AiKitLanguageCode | "auto";
21
+ outputLanguage?: AiKitLanguageCode | "auto";
22
+ tone?: WriterTone | RewriterTone;
23
+ length?: WriterLength | RewriterLength | SummarizerLength;
24
+ type?: SummarizerType;
25
+ outputFormat?: "plain-text" | "markdown" | "html";
26
+ };
27
+ allowOverride?: {
28
+ text?: boolean;
29
+ instructions?: boolean;
30
+ tone?: boolean;
31
+ length?: boolean;
32
+ type?: boolean;
33
+ outputLanguage?: boolean;
34
+ outputFormat?: boolean;
35
+ };
36
+ onAccept?: (result: unknown) => void;
37
+ } & Partial<_smart_cloud_ai_kit_core.AiWorkerProps>>;
38
+
39
+ declare const markdownToHtml: (markdown: string) => Promise<string>;
40
+
41
+ type AiRunState<T> = {
42
+ busy: boolean;
43
+ error: string | null;
44
+ statusEvent: AiKitStatusEvent | null;
45
+ result: T | null;
46
+ isCancelled: boolean;
47
+ /** Last known execution source (best-effort). */
48
+ lastSource: "on-device" | "backend" | null;
49
+ };
50
+ type AiFeatureFunction<T> = (args: {
51
+ signal: AbortSignal;
52
+ onStatus: (e: AiKitStatusEvent) => void;
53
+ }) => Promise<T>;
54
+ type UseAiRunResult<T> = AiRunState<T> & {
55
+ run: (func: AiFeatureFunction<T>) => Promise<T | null>;
56
+ cancel: () => void;
57
+ reset: () => void;
58
+ /** Current AbortSignal, if a run is in-flight. */
59
+ signal: AbortSignal | null;
60
+ };
61
+ /**
62
+ * Returns true if backend routing is configured in the current AiKit settings.
63
+ *
64
+ * This is intentionally conservative: it only checks *configuration*, not reachability.
65
+ */
66
+ declare function isBackendConfigured(): Promise<boolean>;
67
+ declare function readDefaultOutputLanguage(): AiKitLanguageCode;
68
+ /**
69
+ * Removes a single surrounding Markdown code fence.
70
+ *
71
+ * Handles common model outputs like:
72
+ * ```json
73
+ * {"a":1}
74
+ * ```
75
+ */
76
+ declare function stripCodeFence(text: string): string;
77
+ declare function useAiRun<T>(): UseAiRunResult<T>;
78
+
79
+ type AiKitShellInjectedProps = {
80
+ language?: string;
81
+ rootElement: HTMLElement;
82
+ };
83
+ declare function withAiKitShell<P extends object>(RootComponent: ComponentType<P & AiKitShellInjectedProps>, propOverrides?: Partial<AiWorkerProps>): react.FC<P & Partial<AiWorkerProps>>;
84
+
85
+ declare const translations: Record<string, Record<string, string>>;
86
+
87
+ export { AiFeature, type AiFeatureFunction, type AiRunState, type UseAiRunResult, isBackendConfigured, markdownToHtml, readDefaultOutputLanguage, stripCodeFence, translations, useAiRun, withAiKitShell };
@@ -0,0 +1,87 @@
1
+ import * as _smart_cloud_ai_kit_core from '@smart-cloud/ai-kit-core';
2
+ import { ContextKind, AiModePreference, AiKitLanguageCode, AiKitStatusEvent, AiWorkerProps } from '@smart-cloud/ai-kit-core';
3
+ import * as react from 'react';
4
+ import { FC, ComponentType } from 'react';
5
+
6
+ declare const AiFeature: FC<_smart_cloud_ai_kit_core.AiWorkerProps & {
7
+ mode: _smart_cloud_ai_kit_core.AiFeatureMode;
8
+ context?: ContextKind;
9
+ modeOverride?: AiModePreference;
10
+ autoRun?: boolean;
11
+ editable?: boolean;
12
+ acceptButtonTitle?: string;
13
+ showRegenerateOnBackendButton?: boolean;
14
+ optionsDisplay?: "collapse" | "horizontal" | "vertical";
15
+ default?: {
16
+ getText?: () => string;
17
+ text?: string;
18
+ image?: Blob;
19
+ instructions?: string;
20
+ inputLanguage?: AiKitLanguageCode | "auto";
21
+ outputLanguage?: AiKitLanguageCode | "auto";
22
+ tone?: WriterTone | RewriterTone;
23
+ length?: WriterLength | RewriterLength | SummarizerLength;
24
+ type?: SummarizerType;
25
+ outputFormat?: "plain-text" | "markdown" | "html";
26
+ };
27
+ allowOverride?: {
28
+ text?: boolean;
29
+ instructions?: boolean;
30
+ tone?: boolean;
31
+ length?: boolean;
32
+ type?: boolean;
33
+ outputLanguage?: boolean;
34
+ outputFormat?: boolean;
35
+ };
36
+ onAccept?: (result: unknown) => void;
37
+ } & Partial<_smart_cloud_ai_kit_core.AiWorkerProps>>;
38
+
39
+ declare const markdownToHtml: (markdown: string) => Promise<string>;
40
+
41
+ type AiRunState<T> = {
42
+ busy: boolean;
43
+ error: string | null;
44
+ statusEvent: AiKitStatusEvent | null;
45
+ result: T | null;
46
+ isCancelled: boolean;
47
+ /** Last known execution source (best-effort). */
48
+ lastSource: "on-device" | "backend" | null;
49
+ };
50
+ type AiFeatureFunction<T> = (args: {
51
+ signal: AbortSignal;
52
+ onStatus: (e: AiKitStatusEvent) => void;
53
+ }) => Promise<T>;
54
+ type UseAiRunResult<T> = AiRunState<T> & {
55
+ run: (func: AiFeatureFunction<T>) => Promise<T | null>;
56
+ cancel: () => void;
57
+ reset: () => void;
58
+ /** Current AbortSignal, if a run is in-flight. */
59
+ signal: AbortSignal | null;
60
+ };
61
+ /**
62
+ * Returns true if backend routing is configured in the current AiKit settings.
63
+ *
64
+ * This is intentionally conservative: it only checks *configuration*, not reachability.
65
+ */
66
+ declare function isBackendConfigured(): Promise<boolean>;
67
+ declare function readDefaultOutputLanguage(): AiKitLanguageCode;
68
+ /**
69
+ * Removes a single surrounding Markdown code fence.
70
+ *
71
+ * Handles common model outputs like:
72
+ * ```json
73
+ * {"a":1}
74
+ * ```
75
+ */
76
+ declare function stripCodeFence(text: string): string;
77
+ declare function useAiRun<T>(): UseAiRunResult<T>;
78
+
79
+ type AiKitShellInjectedProps = {
80
+ language?: string;
81
+ rootElement: HTMLElement;
82
+ };
83
+ declare function withAiKitShell<P extends object>(RootComponent: ComponentType<P & AiKitShellInjectedProps>, propOverrides?: Partial<AiWorkerProps>): react.FC<P & Partial<AiWorkerProps>>;
84
+
85
+ declare const translations: Record<string, Record<string, string>>;
86
+
87
+ export { AiFeature, type AiFeatureFunction, type AiRunState, type UseAiRunResult, isBackendConfigured, markdownToHtml, readDefaultOutputLanguage, stripCodeFence, translations, useAiRun, withAiKitShell };