@yarvelle/ui 0.0.0-stage → 0.1.1

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 (42) hide show
  1. package/bin/yarvelle-ui-codegen.js +115 -0
  2. package/dist/index-DLbrj3Po.d.ts +90 -0
  3. package/dist/index.d.ts +706 -0
  4. package/dist/index.js +4418 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/api/index.d.ts +99 -0
  7. package/dist/lib/api/index.js +113 -0
  8. package/dist/lib/api/index.js.map +1 -0
  9. package/dist/lib/auth/index.d.ts +21 -0
  10. package/dist/lib/auth/index.js +37 -0
  11. package/dist/lib/auth/index.js.map +1 -0
  12. package/dist/lib/cn.d.ts +5 -0
  13. package/dist/lib/cn.js +10 -0
  14. package/dist/lib/cn.js.map +1 -0
  15. package/dist/lib/i18n/index.d.ts +7 -0
  16. package/dist/lib/i18n/index.js +45 -0
  17. package/dist/lib/i18n/index.js.map +1 -0
  18. package/dist/lib/index.d.ts +8 -0
  19. package/dist/lib/index.js +272 -0
  20. package/dist/lib/index.js.map +1 -0
  21. package/dist/lib/sse/index.d.ts +11 -0
  22. package/dist/lib/sse/index.js +43 -0
  23. package/dist/lib/sse/index.js.map +1 -0
  24. package/dist/lib/storage-namespace.d.ts +6 -0
  25. package/dist/lib/storage-namespace.js +34 -0
  26. package/dist/lib/storage-namespace.js.map +1 -0
  27. package/dist/slots/index.d.ts +12 -0
  28. package/dist/slots/index.js +86 -0
  29. package/dist/slots/index.js.map +1 -0
  30. package/dist/styles.css +270 -0
  31. package/dist/testing/index.d.ts +3 -0
  32. package/dist/testing/index.js +36 -0
  33. package/dist/testing/index.js.map +1 -0
  34. package/dist/tokens/index.d.ts +37 -0
  35. package/dist/tokens/index.js +155 -0
  36. package/dist/tokens/index.js.map +1 -0
  37. package/dist/tokens/tailwind-preset.d.ts +5 -0
  38. package/dist/tokens/tailwind-preset.js +155 -0
  39. package/dist/tokens/tailwind-preset.js.map +1 -0
  40. package/dist/types-CP_CDg6G.d.ts +51 -0
  41. package/package.json +69 -4
  42. package/README.md +0 -3
@@ -0,0 +1,99 @@
1
+ type AudienceBand = 'adult' | 'teen' | 'child' | 'viewer';
2
+ interface UiContext {
3
+ profile_id: string;
4
+ scopes: string[];
5
+ hidden_panels: string[];
6
+ audience: AudienceBand;
7
+ }
8
+ interface UiPreference {
9
+ profile_id: string;
10
+ hidden_panels: string[];
11
+ theme_preference?: string | null;
12
+ }
13
+ interface UiPreferenceUpdate {
14
+ hidden_panels: string[];
15
+ theme_preference?: string | null;
16
+ }
17
+ type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
18
+ interface ApprovalRisk {
19
+ level: RiskLevel;
20
+ label: string;
21
+ }
22
+ interface ApprovalItem {
23
+ id: string;
24
+ profile_id: string;
25
+ tool_name: string;
26
+ action_summary: string;
27
+ parameters: Record<string, unknown>;
28
+ risk: ApprovalRisk;
29
+ status: 'pending' | 'approved' | 'rejected' | 'expired';
30
+ created_at: string;
31
+ expires_at?: string;
32
+ }
33
+ interface ApprovalDecisionRequest {
34
+ decision: 'approve' | 'reject';
35
+ reason?: string;
36
+ }
37
+ interface NoteItem {
38
+ id: string;
39
+ title: string;
40
+ content: string;
41
+ tags?: string[];
42
+ created_at: string;
43
+ updated_at: string;
44
+ }
45
+ interface ReminderItem {
46
+ id: string;
47
+ profile_id: string;
48
+ title: string;
49
+ rrule?: string;
50
+ due_date?: string;
51
+ completed: boolean;
52
+ snoozed_until?: string;
53
+ }
54
+ interface TaskItemData {
55
+ id: string;
56
+ profile_id: string;
57
+ title: string;
58
+ completed: boolean;
59
+ priority?: 'low' | 'medium' | 'high';
60
+ due_date?: string;
61
+ }
62
+ interface RoutineItem {
63
+ id: string;
64
+ profile_id: string;
65
+ name: string;
66
+ schedule: string;
67
+ steps: string[];
68
+ enabled: boolean;
69
+ }
70
+
71
+ declare class ApiClient {
72
+ private baseUrl;
73
+ constructor(baseUrl?: string);
74
+ private request;
75
+ getUiContext(profileId?: string): Promise<UiContext>;
76
+ getUiPrefs(profileId: string): Promise<UiPreference>;
77
+ updateUiPrefs(profileId: string, prefs: UiPreferenceUpdate): Promise<UiPreference>;
78
+ decideApproval(approvalId: string, decision: 'approve' | 'reject', reason?: string): Promise<ApprovalItem>;
79
+ resumeChat(threadId: string, payload?: Record<string, unknown>): Promise<{
80
+ status: string;
81
+ }>;
82
+ }
83
+ declare const defaultApiClient: ApiClient;
84
+
85
+ declare function useUiContext(profileId?: string): {
86
+ data: UiContext | null;
87
+ loading: boolean;
88
+ error: Error | null;
89
+ refetch: () => Promise<void>;
90
+ };
91
+ declare function useUiPrefs(profileId: string): {
92
+ data: UiPreference | null;
93
+ loading: boolean;
94
+ error: Error | null;
95
+ refetch: () => Promise<void>;
96
+ updatePrefs: (prefs: UiPreferenceUpdate) => Promise<UiPreference>;
97
+ };
98
+
99
+ export { ApiClient, type ApprovalDecisionRequest, type ApprovalItem, type ApprovalRisk, type AudienceBand, type NoteItem, type ReminderItem, type RiskLevel, type RoutineItem, type TaskItemData, type UiContext, type UiPreference, type UiPreferenceUpdate, defaultApiClient, useUiContext, useUiPrefs };
@@ -0,0 +1,113 @@
1
+ // src/lib/api/client.ts
2
+ var ApiClient = class {
3
+ baseUrl;
4
+ constructor(baseUrl = "/api/v1") {
5
+ this.baseUrl = baseUrl.replace(/\/+$/, "");
6
+ }
7
+ async request(path, options = {}) {
8
+ const url = `${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
9
+ const headers = new Headers(options.headers || {});
10
+ if (!headers.has("Content-Type") && options.body && typeof options.body === "string") {
11
+ headers.set("Content-Type", "application/json");
12
+ }
13
+ const response = await fetch(url, { ...options, headers });
14
+ if (!response.ok) {
15
+ let detail = `HTTP ${response.status} ${response.statusText}`;
16
+ try {
17
+ const body = await response.json();
18
+ if (body.detail) detail = body.detail;
19
+ } catch {
20
+ }
21
+ throw new Error(detail);
22
+ }
23
+ return response.json();
24
+ }
25
+ async getUiContext(profileId) {
26
+ const q = profileId ? `?profile_id=${encodeURIComponent(profileId)}` : "";
27
+ return this.request(`/me/ui-context${q}`);
28
+ }
29
+ async getUiPrefs(profileId) {
30
+ return this.request(`/me/profiles/${encodeURIComponent(profileId)}/ui-prefs`);
31
+ }
32
+ async updateUiPrefs(profileId, prefs) {
33
+ return this.request(`/me/profiles/${encodeURIComponent(profileId)}/ui-prefs`, {
34
+ method: "PUT",
35
+ body: JSON.stringify(prefs)
36
+ });
37
+ }
38
+ async decideApproval(approvalId, decision, reason) {
39
+ const body = { decision, reason };
40
+ return this.request(`/approvals/${encodeURIComponent(approvalId)}/decide`, {
41
+ method: "POST",
42
+ body: JSON.stringify(body)
43
+ });
44
+ }
45
+ async resumeChat(threadId, payload = {}) {
46
+ return this.request(`/chat/resume`, {
47
+ method: "POST",
48
+ body: JSON.stringify({ thread_id: threadId, ...payload })
49
+ });
50
+ }
51
+ };
52
+ var defaultApiClient = new ApiClient();
53
+
54
+ // src/lib/api/hooks.ts
55
+ import { useCallback, useEffect, useState } from "react";
56
+ function useUiContext(profileId) {
57
+ const [data, setData] = useState(null);
58
+ const [loading, setLoading] = useState(true);
59
+ const [error, setError] = useState(null);
60
+ const refetch = useCallback(async () => {
61
+ setLoading(true);
62
+ setError(null);
63
+ try {
64
+ const result = await defaultApiClient.getUiContext(profileId);
65
+ setData(result);
66
+ } catch (err) {
67
+ setError(err instanceof Error ? err : new Error(String(err)));
68
+ } finally {
69
+ setLoading(false);
70
+ }
71
+ }, [profileId]);
72
+ useEffect(() => {
73
+ refetch();
74
+ }, [refetch]);
75
+ return { data, loading, error, refetch };
76
+ }
77
+ function useUiPrefs(profileId) {
78
+ const [data, setData] = useState(null);
79
+ const [loading, setLoading] = useState(true);
80
+ const [error, setError] = useState(null);
81
+ const refetch = useCallback(async () => {
82
+ if (!profileId) return;
83
+ setLoading(true);
84
+ setError(null);
85
+ try {
86
+ const result = await defaultApiClient.getUiPrefs(profileId);
87
+ setData(result);
88
+ } catch (err) {
89
+ setError(err instanceof Error ? err : new Error(String(err)));
90
+ } finally {
91
+ setLoading(false);
92
+ }
93
+ }, [profileId]);
94
+ useEffect(() => {
95
+ refetch();
96
+ }, [refetch]);
97
+ const updatePrefs = useCallback(
98
+ async (prefs) => {
99
+ const updated = await defaultApiClient.updateUiPrefs(profileId, prefs);
100
+ setData(updated);
101
+ return updated;
102
+ },
103
+ [profileId]
104
+ );
105
+ return { data, loading, error, refetch, updatePrefs };
106
+ }
107
+ export {
108
+ ApiClient,
109
+ defaultApiClient,
110
+ useUiContext,
111
+ useUiPrefs
112
+ };
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/api/client.ts","../../../src/lib/api/hooks.ts"],"sourcesContent":["// Yarvelle Core — Domain-Neutral AI Agent Runtime & Execution Engine\n// Copyright 2026 Spectrayan (https://spectrayan.com)\n//\n// Licensed under the PolyForm Noncommercial License 1.0.0 and the\n// Yarvelle Core Additional Terms (see LICENSE and ADDITIONAL-TERMS.md).\n// Personal and household local use only. Commercial use, hosted service\n// offering, rebranding, white-labeling, and redistribution of modified\n// forks are prohibited without a written commercial license from Spectrayan.\n//\n// Required Notice: Copyright 2026 Spectrayan (https://spectrayan.com)\n\nimport type {\n ApprovalDecisionRequest,\n ApprovalItem,\n NoteItem,\n ReminderItem,\n RoutineItem,\n TaskItemData,\n UiContext,\n UiPreference,\n UiPreferenceUpdate,\n} from './types.js';\n\nexport class ApiClient {\n private baseUrl: string;\n\n constructor(baseUrl: string = '/api/v1') {\n this.baseUrl = baseUrl.replace(/\\/+$/, '');\n }\n\n private async request<T>(path: string, options: RequestInit = {}): Promise<T> {\n const url = `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;\n const headers = new Headers(options.headers || {});\n if (!headers.has('Content-Type') && options.body && typeof options.body === 'string') {\n headers.set('Content-Type', 'application/json');\n }\n\n const response = await fetch(url, { ...options, headers });\n if (!response.ok) {\n let detail = `HTTP ${response.status} ${response.statusText}`;\n try {\n const body = await response.json();\n if (body.detail) detail = body.detail;\n } catch {\n // Fallback to text status\n }\n throw new Error(detail);\n }\n return response.json() as Promise<T>;\n }\n\n async getUiContext(profileId?: string): Promise<UiContext> {\n const q = profileId ? `?profile_id=${encodeURIComponent(profileId)}` : '';\n return this.request<UiContext>(`/me/ui-context${q}`);\n }\n\n async getUiPrefs(profileId: string): Promise<UiPreference> {\n return this.request<UiPreference>(`/me/profiles/${encodeURIComponent(profileId)}/ui-prefs`);\n }\n\n async updateUiPrefs(profileId: string, prefs: UiPreferenceUpdate): Promise<UiPreference> {\n return this.request<UiPreference>(`/me/profiles/${encodeURIComponent(profileId)}/ui-prefs`, {\n method: 'PUT',\n body: JSON.stringify(prefs),\n });\n }\n\n async decideApproval(approvalId: string, decision: 'approve' | 'reject', reason?: string): Promise<ApprovalItem> {\n const body: ApprovalDecisionRequest = { decision, reason };\n return this.request<ApprovalItem>(`/approvals/${encodeURIComponent(approvalId)}/decide`, {\n method: 'POST',\n body: JSON.stringify(body),\n });\n }\n\n async resumeChat(threadId: string, payload: Record<string, unknown> = {}): Promise<{ status: string }> {\n return this.request<{ status: string }>(`/chat/resume`, {\n method: 'POST',\n body: JSON.stringify({ thread_id: threadId, ...payload }),\n });\n }\n}\n\nexport const defaultApiClient = new ApiClient();\n","// Yarvelle Core — Domain-Neutral AI Agent Runtime & Execution Engine\n// Copyright 2026 Spectrayan (https://spectrayan.com)\n//\n// Licensed under the PolyForm Noncommercial License 1.0.0 and the\n// Yarvelle Core Additional Terms (see LICENSE and ADDITIONAL-TERMS.md).\n// Personal and household local use only. Commercial use, hosted service\n// offering, rebranding, white-labeling, and redistribution of modified\n// forks are prohibited without a written commercial license from Spectrayan.\n//\n// Required Notice: Copyright 2026 Spectrayan (https://spectrayan.com)\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { defaultApiClient } from './client.js';\nimport type { UiContext, UiPreference, UiPreferenceUpdate } from './types.js';\n\nexport function useUiContext(profileId?: string) {\n const [data, setData] = useState<UiContext | null>(null);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await defaultApiClient.getUiContext(profileId);\n setData(result);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setLoading(false);\n }\n }, [profileId]);\n\n useEffect(() => {\n refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useUiPrefs(profileId: string) {\n const [data, setData] = useState<UiPreference | null>(null);\n const [loading, setLoading] = useState<boolean>(true);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!profileId) return;\n setLoading(true);\n setError(null);\n try {\n const result = await defaultApiClient.getUiPrefs(profileId);\n setData(result);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setLoading(false);\n }\n }, [profileId]);\n\n useEffect(() => {\n refetch();\n }, [refetch]);\n\n const updatePrefs = useCallback(\n async (prefs: UiPreferenceUpdate) => {\n const updated = await defaultApiClient.updateUiPrefs(profileId, prefs);\n setData(updated);\n return updated;\n },\n [profileId]\n );\n\n return { data, loading, error, refetch, updatePrefs };\n}\n"],"mappings":";AAuBO,IAAM,YAAN,MAAgB;AAAA,EACb;AAAA,EAER,YAAY,UAAkB,WAAW;AACvC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,EAAE;AAAA,EAC3C;AAAA,EAEA,MAAc,QAAW,MAAc,UAAuB,CAAC,GAAe;AAC5E,UAAM,MAAM,GAAG,KAAK,OAAO,GAAG,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,IAAI,EAAE;AACtE,UAAM,UAAU,IAAI,QAAQ,QAAQ,WAAW,CAAC,CAAC;AACjD,QAAI,CAAC,QAAQ,IAAI,cAAc,KAAK,QAAQ,QAAQ,OAAO,QAAQ,SAAS,UAAU;AACpF,cAAQ,IAAI,gBAAgB,kBAAkB;AAAA,IAChD;AAEA,UAAM,W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AAM,cAAc;AAAA,IAClB,OAAO,UAA8B;AACnC,YAAM,UAAU,MAAM,iBAAiB,cAAc,WAAW,KAAK;AACrE,cAAQ,OAAO;AACf,aAAO;AAAA,IACT;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AAEA,SAAO,EAAE,MAAM,SAAS,OAAO,SAAS,YAAY;AACtD;","names":[]}
@@ -0,0 +1,21 @@
1
+ import React__default from 'react';
2
+
3
+ interface UserSession {
4
+ userId: string;
5
+ username: string;
6
+ role: string;
7
+ token?: string;
8
+ }
9
+ interface AuthContextValue {
10
+ session: UserSession | null;
11
+ isAuthenticated: boolean;
12
+ setSession: (session: UserSession | null) => void;
13
+ logout: () => void;
14
+ }
15
+ declare const AuthProvider: React__default.FC<{
16
+ children: React__default.ReactNode;
17
+ initialSession?: UserSession | null;
18
+ }>;
19
+ declare const useAuth: () => AuthContextValue;
20
+
21
+ export { type AuthContextValue, AuthProvider, type UserSession, useAuth };
@@ -0,0 +1,37 @@
1
+ // src/lib/auth/auth-context.ts
2
+ import React, { createContext, useContext, useState } from "react";
3
+ var AuthContext = createContext({
4
+ session: null,
5
+ isAuthenticated: false,
6
+ setSession: () => {
7
+ },
8
+ logout: () => {
9
+ }
10
+ });
11
+ var AuthProvider = ({
12
+ children,
13
+ initialSession = null
14
+ }) => {
15
+ const [session, setSession] = useState(initialSession);
16
+ const logout = () => {
17
+ setSession(null);
18
+ };
19
+ return React.createElement(
20
+ AuthContext.Provider,
21
+ {
22
+ value: {
23
+ session,
24
+ isAuthenticated: !!session,
25
+ setSession,
26
+ logout
27
+ }
28
+ },
29
+ children
30
+ );
31
+ };
32
+ var useAuth = () => useContext(AuthContext);
33
+ export {
34
+ AuthProvider,
35
+ useAuth
36
+ };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/auth/auth-context.ts"],"sourcesContent":["// Yarvelle Core — Domain-Neutral AI Agent Runtime & Execution Engine\n// Copyright 2026 Spectrayan (https://spectrayan.com)\n//\n// Licensed under the PolyForm Noncommercial License 1.0.0 and the\n// Yarvelle Core Additional Terms (see LICENSE and ADDITIONAL-TERMS.md).\n// Personal and household local use only. Commercial use, hosted service\n// offering, rebranding, white-labeling, and redistribution of modified\n// forks are prohibited without a written commercial license from Spectrayan.\n//\n// Required Notice: Copyright 2026 Spectrayan (https://spectrayan.com)\n\nimport React, { createContext, useContext, useState } from 'react';\n\nexport interface UserSession {\n userId: string;\n username: string;\n role: string;\n token?: string;\n}\n\nexport interface AuthContextValue {\n session: UserSession | null;\n isAuthenticated: boolean;\n setSession: (session: UserSession | null) => void;\n logout: () => void;\n}\n\nconst AuthContext = createContext<AuthContextValue>({\n session: null,\n isAuthenticated: false,\n setSession: () => {},\n logout: () => {},\n});\n\nexport const AuthProvider: React.FC<{ children: React.ReactNode; initialSession?: UserSession | null }> = ({\n children,\n initialSession = null,\n}) => {\n const [session, setSession] = useState<UserSession | null>(initialSession);\n\n const logout = () => {\n setSession(null);\n };\n\n return React.createElement(\n AuthContext.Provider,\n {\n value: {\n session,\n isAuthenticated: !!session,\n setSession,\n logout,\n },\n },\n children\n );\n};\n\nexport const useAuth = () => useContext(AuthContext);\n"],"mappings":";AAWA,OAAO,SAAS,eAAe,YAAY,gBAAgB;AAgB3D,IAAM,cAAc,cAAgC;AAAA,EAClD,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,YAAY,MAAM;AAAA,EAAC;AAAA,EACnB,QAAQ,MAAM;AAAA,EAAC;AACjB,CAAC;AAEM,IAAM,eAA6F,CAAC;AAAA,EACzG;AAAA,EACA,iBAAiB;AACnB,MAAM;AACJ,QAAM,CAAC,SAAS,UAAU,IAAI,SAA6B,cAAc;AAEzE,QAAM,SAAS,MAAM;AACnB,eAAW,IAAI;AAAA,EACjB;AAEA,SAAO,MAAM;AAAA,IACX,YAAY;AAAA,IACZ;AAAA,MACE,OAAO;AAAA,QACL;AAAA,QACA,iBAAiB,CAAC,CAAC;AAAA,QACnB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEO,IAAM,UAAU,MAAM,WAAW,WAAW;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ declare function cn(...inputs: ClassValue[]): string;
4
+
5
+ export { cn };
package/dist/lib/cn.js ADDED
@@ -0,0 +1,10 @@
1
+ // src/lib/cn.ts
2
+ import { clsx } from "clsx";
3
+ import { twMerge } from "tailwind-merge";
4
+ function cn(...inputs) {
5
+ return twMerge(clsx(inputs));
6
+ }
7
+ export {
8
+ cn
9
+ };
10
+ //# sourceMappingURL=cn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/cn.ts"],"sourcesContent":["// Yarvelle Core — Domain-Neutral AI Agent Runtime & Execution Engine\n// Copyright 2026 Spectrayan (https://spectrayan.com)\n//\n// Licensed under the PolyForm Noncommercial License 1.0.0 and the\n// Yarvelle Core Additional Terms (see LICENSE and ADDITIONAL-TERMS.md).\n// Personal and household local use only. Commercial use, hosted service\n// offering, rebranding, white-labeling, and redistribution of modified\n// forks are prohibited without a written commercial license from Spectrayan.\n//\n// Required Notice: Copyright 2026 Spectrayan (https://spectrayan.com)\n\nimport { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";AAWA,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAA8B;AAClD,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;","names":[]}
@@ -0,0 +1,7 @@
1
+ declare function getTextDirection(locale: string): 'ltr' | 'rtl';
2
+ declare function formatDate(value: Date | string | number, locale?: string, options?: Intl.DateTimeFormatOptions): string;
3
+ declare function formatTime(value: Date | string | number, locale?: string, options?: Intl.DateTimeFormatOptions): string;
4
+ declare function formatDateTime(value: Date | string | number, locale?: string, options?: Intl.DateTimeFormatOptions): string;
5
+ declare function formatNumber(value: number, locale?: string, options?: Intl.NumberFormatOptions): string;
6
+
7
+ export { formatDate, formatDateTime, formatNumber, formatTime, getTextDirection };
@@ -0,0 +1,45 @@
1
+ // src/lib/i18n/formatters.ts
2
+ function getTextDirection(locale) {
3
+ const rtlLocales = ["ar", "he", "fa", "ur", "ar-SA", "he-IL"];
4
+ const prefix = locale.split("-")[0].toLowerCase();
5
+ return rtlLocales.includes(locale) || rtlLocales.includes(prefix) ? "rtl" : "ltr";
6
+ }
7
+ function formatDate(value, locale = "en-US", options = { dateStyle: "medium" }) {
8
+ const d = typeof value === "object" ? value : new Date(value);
9
+ try {
10
+ return new Intl.DateTimeFormat(locale, options).format(d);
11
+ } catch {
12
+ return d.toLocaleDateString();
13
+ }
14
+ }
15
+ function formatTime(value, locale = "en-US", options = { timeStyle: "short" }) {
16
+ const d = typeof value === "object" ? value : new Date(value);
17
+ try {
18
+ return new Intl.DateTimeFormat(locale, options).format(d);
19
+ } catch {
20
+ return d.toLocaleTimeString();
21
+ }
22
+ }
23
+ function formatDateTime(value, locale = "en-US", options = { dateStyle: "medium", timeStyle: "short" }) {
24
+ const d = typeof value === "object" ? value : new Date(value);
25
+ try {
26
+ return new Intl.DateTimeFormat(locale, options).format(d);
27
+ } catch {
28
+ return `${d.toLocaleDateString()} ${d.toLocaleTimeString()}`;
29
+ }
30
+ }
31
+ function formatNumber(value, locale = "en-US", options = {}) {
32
+ try {
33
+ return new Intl.NumberFormat(locale, options).format(value);
34
+ } catch {
35
+ return String(value);
36
+ }
37
+ }
38
+ export {
39
+ formatDate,
40
+ formatDateTime,
41
+ formatNumber,
42
+ formatTime,
43
+ getTextDirection
44
+ };
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/i18n/formatters.ts"],"sourcesContent":["// Yarvelle Core — Domain-Neutral AI Agent Runtime & Execution Engine\n// Copyright 2026 Spectrayan (https://spectrayan.com)\n//\n// Licensed under the PolyForm Noncommercial License 1.0.0 and the\n// Yarvelle Core Additional Terms (see LICENSE and ADDITIONAL-TERMS.md).\n// Personal and household local use only. Commercial use, hosted service\n// offering, rebranding, white-labeling, and redistribution of modified\n// forks are prohibited without a written commercial license from Spectrayan.\n//\n// Required Notice: Copyright 2026 Spectrayan (https://spectrayan.com)\n\nexport function getTextDirection(locale: string): 'ltr' | 'rtl' {\n const rtlLocales = ['ar', 'he', 'fa', 'ur', 'ar-SA', 'he-IL'];\n const prefix = locale.split('-')[0].toLowerCase();\n return rtlLocales.includes(locale) || rtlLocales.includes(prefix) ? 'rtl' : 'ltr';\n}\n\nexport function formatDate(\n value: Date | string | number,\n locale: string = 'en-US',\n options: Intl.DateTimeFormatOptions = { dateStyle: 'medium' }\n): string {\n const d = typeof value === 'object' ? value : new Date(value);\n try {\n return new Intl.DateTimeFormat(locale, options).format(d);\n } catch {\n return d.toLocaleDateString();\n }\n}\n\nexport function formatTime(\n value: Date | string | number,\n locale: string = 'en-US',\n options: Intl.DateTimeFormatOptions = { timeStyle: 'short' }\n): string {\n const d = typeof value === 'object' ? value : new Date(value);\n try {\n return new Intl.DateTimeFormat(locale, options).format(d);\n } catch {\n return d.toLocaleTimeString();\n }\n}\n\nexport function formatDateTime(\n value: Date | string | number,\n locale: string = 'en-US',\n options: Intl.DateTimeFormatOptions = { dateStyle: 'medium', timeStyle: 'short' }\n): string {\n const d = typeof value === 'object' ? value : new Date(value);\n try {\n return new Intl.DateTimeFormat(locale, options).format(d);\n } catch {\n return `${d.toLocaleDateString()} ${d.toLocaleTimeString()}`;\n }\n}\n\nexport function formatNumber(\n value: number,\n locale: string = 'en-US',\n options: Intl.NumberFormatOptions = {}\n): string {\n try {\n return new Intl.NumberFormat(locale, options).format(value);\n } catch {\n return String(value);\n }\n}\n"],"mappings":";AAWO,SAAS,iBAAiB,QAA+B;AAC9D,QAAM,aAAa,CAAC,MAAM,MAAM,MAAM,MAAM,SAAS,OAAO;AAC5D,QAAM,SAAS,OAAO,MAAM,G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ApprovalDecisionRequest, ApprovalItem, ApprovalRisk, AudienceBand, NoteItem, ReminderItem, RiskLevel, RoutineItem, TaskItemData, UiContext, UiPreference, UiPreferenceUpdate, defaultApiClient, useUiContext, useUiPrefs } from './api/index.js';
3
+ export { SseEvent, parseSseChunk } from './sse/index.js';
4
+ export { AuthContextValue, AuthProvider, UserSession, useAuth } from './auth/index.js';
5
+ export { formatDate, formatDateTime, formatNumber, formatTime, getTextDirection } from './i18n/index.js';
6
+ export { cn } from './cn.js';
7
+ import 'react';
8
+ import 'clsx';
@@ -0,0 +1,272 @@
1
+ // src/lib/storage-namespace.ts
2
+ function getStorageKey(namespace, key, suffix) {
3
+ const base = `${namespace}_${key}`;
4
+ return suffix ? `${base}_${suffix}` : base;
5
+ }
6
+ function getScopedItem(namespace, key, suffix) {
7
+ if (typeof window === "undefined") return null;
8
+ try {
9
+ return localStorage.getItem(getStorageKey(namespace, key, suffix));
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+ function setScopedItem(namespace, key, value, suffix) {
15
+ if (typeof window === "undefined") return;
16
+ try {
17
+ localStorage.setItem(getStorageKey(namespace, key, suffix), value);
18
+ } catch {
19
+ }
20
+ }
21
+ function removeScopedItem(namespace, key, suffix) {
22
+ if (typeof window === "undefined") return;
23
+ try {
24
+ localStorage.removeItem(getStorageKey(namespace, key, suffix));
25
+ } catch {
26
+ }
27
+ }
28
+
29
+ // src/lib/api/client.ts
30
+ var ApiClient = class {
31
+ baseUrl;
32
+ constructor(baseUrl = "/api/v1") {
33
+ this.baseUrl = baseUrl.replace(/\/+$/, "");
34
+ }
35
+ async request(path, options = {}) {
36
+ const url = `${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
37
+ const headers = new Headers(options.headers || {});
38
+ if (!headers.has("Content-Type") && options.body && typeof options.body === "string") {
39
+ headers.set("Content-Type", "application/json");
40
+ }
41
+ const response = await fetch(url, { ...options, headers });
42
+ if (!response.ok) {
43
+ let detail = `HTTP ${response.status} ${response.statusText}`;
44
+ try {
45
+ const body = await response.json();
46
+ if (body.detail) detail = body.detail;
47
+ } catch {
48
+ }
49
+ throw new Error(detail);
50
+ }
51
+ return response.json();
52
+ }
53
+ async getUiContext(profileId) {
54
+ const q = profileId ? `?profile_id=${encodeURIComponent(profileId)}` : "";
55
+ return this.request(`/me/ui-context${q}`);
56
+ }
57
+ async getUiPrefs(profileId) {
58
+ return this.request(`/me/profiles/${encodeURIComponent(profileId)}/ui-prefs`);
59
+ }
60
+ async updateUiPrefs(profileId, prefs) {
61
+ return this.request(`/me/profiles/${encodeURIComponent(profileId)}/ui-prefs`, {
62
+ method: "PUT",
63
+ body: JSON.stringify(prefs)
64
+ });
65
+ }
66
+ async decideApproval(approvalId, decision, reason) {
67
+ const body = { decision, reason };
68
+ return this.request(`/approvals/${encodeURIComponent(approvalId)}/decide`, {
69
+ method: "POST",
70
+ body: JSON.stringify(body)
71
+ });
72
+ }
73
+ async resumeChat(threadId, payload = {}) {
74
+ return this.request(`/chat/resume`, {
75
+ method: "POST",
76
+ body: JSON.stringify({ thread_id: threadId, ...payload })
77
+ });
78
+ }
79
+ };
80
+ var defaultApiClient = new ApiClient();
81
+
82
+ // src/lib/api/hooks.ts
83
+ import { useCallback, useEffect, useState } from "react";
84
+ function useUiContext(profileId) {
85
+ const [data, setData] = useState(null);
86
+ const [loading, setLoading] = useState(true);
87
+ const [error, setError] = useState(null);
88
+ const refetch = useCallback(async () => {
89
+ setLoading(true);
90
+ setError(null);
91
+ try {
92
+ const result = await defaultApiClient.getUiContext(profileId);
93
+ setData(result);
94
+ } catch (err) {
95
+ setError(err instanceof Error ? err : new Error(String(err)));
96
+ } finally {
97
+ setLoading(false);
98
+ }
99
+ }, [profileId]);
100
+ useEffect(() => {
101
+ refetch();
102
+ }, [refetch]);
103
+ return { data, loading, error, refetch };
104
+ }
105
+ function useUiPrefs(profileId) {
106
+ const [data, setData] = useState(null);
107
+ const [loading, setLoading] = useState(true);
108
+ const [error, setError] = useState(null);
109
+ const refetch = useCallback(async () => {
110
+ if (!profileId) return;
111
+ setLoading(true);
112
+ setError(null);
113
+ try {
114
+ const result = await defaultApiClient.getUiPrefs(profileId);
115
+ setData(result);
116
+ } catch (err) {
117
+ setError(err instanceof Error ? err : new Error(String(err)));
118
+ } finally {
119
+ setLoading(false);
120
+ }
121
+ }, [profileId]);
122
+ useEffect(() => {
123
+ refetch();
124
+ }, [refetch]);
125
+ const updatePrefs = useCallback(
126
+ async (prefs) => {
127
+ const updated = await defaultApiClient.updateUiPrefs(profileId, prefs);
128
+ setData(updated);
129
+ return updated;
130
+ },
131
+ [profileId]
132
+ );
133
+ return { data, loading, error, refetch, updatePrefs };
134
+ }
135
+
136
+ // src/lib/sse/parser.ts
137
+ function parseSseChunk(chunk, buffer = "") {
138
+ const combined = buffer + chunk;
139
+ const lines = combined.split(/\r?\n/);
140
+ const events = [];
141
+ let currentEvent = { data: "" };
142
+ let hasData = false;
143
+ const completeLines = lines.slice(0, -1);
144
+ const remaining = lines[lines.length - 1];
145
+ for (const line of completeLines) {
146
+ if (line.trim() === "") {
147
+ if (hasData) {
148
+ events.push(currentEvent);
149
+ currentEvent = { data: "" };
150
+ hasData = false;
151
+ }
152
+ continue;
153
+ }
154
+ if (line.startsWith(":")) {
155
+ continue;
156
+ }
157
+ const colonIdx = line.indexOf(":");
158
+ if (colonIdx === -1) {
159
+ continue;
160
+ }
161
+ const field = line.slice(0, colonIdx).trim();
162
+ const value = line.slice(colonIdx + 1).replace(/^\s/, "");
163
+ if (field === "event") {
164
+ currentEvent.event = value;
165
+ } else if (field === "data") {
166
+ currentEvent.data = currentEvent.data ? `${currentEvent.data}
167
+ ${value}` : value;
168
+ hasData = true;
169
+ } else if (field === "id") {
170
+ currentEvent.id = value;
171
+ }
172
+ }
173
+ return { events, remainingBuffer: remaining };
174
+ }
175
+
176
+ // src/lib/auth/auth-context.ts
177
+ import React, { createContext, useContext, useState as useState2 } from "react";
178
+ var AuthContext = createContext({
179
+ session: null,
180
+ isAuthenticated: false,
181
+ setSession: () => {
182
+ },
183
+ logout: () => {
184
+ }
185
+ });
186
+ var AuthProvider = ({
187
+ children,
188
+ initialSession = null
189
+ }) => {
190
+ const [session, setSession] = useState2(initialSession);
191
+ const logout = () => {
192
+ setSession(null);
193
+ };
194
+ return React.createElement(
195
+ AuthContext.Provider,
196
+ {
197
+ value: {
198
+ session,
199
+ isAuthenticated: !!session,
200
+ setSession,
201
+ logout
202
+ }
203
+ },
204
+ children
205
+ );
206
+ };
207
+ var useAuth = () => useContext(AuthContext);
208
+
209
+ // src/lib/i18n/formatters.ts
210
+ function getTextDirection(locale) {
211
+ const rtlLocales = ["ar", "he", "fa", "ur", "ar-SA", "he-IL"];
212
+ const prefix = locale.split("-")[0].toLowerCase();
213
+ return rtlLocales.includes(locale) || rtlLocales.includes(prefix) ? "rtl" : "ltr";
214
+ }
215
+ function formatDate(value, locale = "en-US", options = { dateStyle: "medium" }) {
216
+ const d = typeof value === "object" ? value : new Date(value);
217
+ try {
218
+ return new Intl.DateTimeFormat(locale, options).format(d);
219
+ } catch {
220
+ return d.toLocaleDateString();
221
+ }
222
+ }
223
+ function formatTime(value, locale = "en-US", options = { timeStyle: "short" }) {
224
+ const d = typeof value === "object" ? value : new Date(value);
225
+ try {
226
+ return new Intl.DateTimeFormat(locale, options).format(d);
227
+ } catch {
228
+ return d.toLocaleTimeString();
229
+ }
230
+ }
231
+ function formatDateTime(value, locale = "en-US", options = { dateStyle: "medium", timeStyle: "short" }) {
232
+ const d = typeof value === "object" ? value : new Date(value);
233
+ try {
234
+ return new Intl.DateTimeFormat(locale, options).format(d);
235
+ } catch {
236
+ return `${d.toLocaleDateString()} ${d.toLocaleTimeString()}`;
237
+ }
238
+ }
239
+ function formatNumber(value, locale = "en-US", options = {}) {
240
+ try {
241
+ return new Intl.NumberFormat(locale, options).format(value);
242
+ } catch {
243
+ return String(value);
244
+ }
245
+ }
246
+
247
+ // src/lib/cn.ts
248
+ import { clsx } from "clsx";
249
+ import { twMerge } from "tailwind-merge";
250
+ function cn(...inputs) {
251
+ return twMerge(clsx(inputs));
252
+ }
253
+ export {
254
+ ApiClient,
255
+ AuthProvider,
256
+ cn,
257
+ defaultApiClient,
258
+ formatDate,
259
+ formatDateTime,
260
+ formatNumber,
261
+ formatTime,
262
+ getScopedItem,
263
+ getStorageKey,
264
+ getTextDirection,
265
+ parseSseChunk,
266
+ removeScopedItem,
267
+ setScopedItem,
268
+ useAuth,
269
+ useUiContext,
270
+ useUiPrefs
271
+ };
272
+ //# sourceMappingURL=index.js.map