@adminide-stack/yantra-mobile 12.0.21-alpha.84

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2017 CDMBase LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,104 @@
1
+ import {config}from'../config/env-config.js';const GROQ_ENDPOINT = "https://api.groq.com/openai/v1/chat/completions";
2
+ const DEFAULT_MODEL = "meta-llama/llama-4-scout-17b-16e-instruct";
3
+ function getApiKey() {
4
+ const key = config.GROQ_API_KEY || "";
5
+ if (!key) {
6
+ throw new Error("GROQ_API_KEY is not configured. Add it to your .env file (e.g. config/development/dev.env).");
7
+ }
8
+ return key;
9
+ }
10
+ async function fetchNonStreaming(messages, key, signal) {
11
+ var _a, _b, _c, _d, _e, _f, _g;
12
+ const response = await fetch(GROQ_ENDPOINT, {
13
+ method: "POST",
14
+ headers: {
15
+ Authorization: `Bearer ${key}`,
16
+ "Content-Type": "application/json"
17
+ },
18
+ body: JSON.stringify({
19
+ model: DEFAULT_MODEL,
20
+ messages,
21
+ stream: false,
22
+ temperature: 1
23
+ }),
24
+ signal
25
+ });
26
+ if (!response.ok) {
27
+ const err = await response.text();
28
+ throw new Error(`Groq API error (${response.status}): ${err}`);
29
+ }
30
+ const data = await response.json();
31
+ const content = (_d = (_c = (_b = (_a = data.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.message) == null ? void 0 : _c.content) != null ? _d : "";
32
+ const usage = data.usage;
33
+ return {
34
+ content,
35
+ tokenUsage: usage ? {
36
+ inputTokens: (_e = usage.prompt_tokens) != null ? _e : 0,
37
+ outputTokens: (_f = usage.completion_tokens) != null ? _f : 0,
38
+ totalTokens: (_g = usage.total_tokens) != null ? _g : 0
39
+ } : void 0
40
+ };
41
+ }
42
+ async function streamChatResponse(messages, apiKey, signal, options) {
43
+ var _a, _b, _c;
44
+ const key = getApiKey();
45
+ if (options == null ? void 0 : options.preferNonStreaming) {
46
+ return fetchNonStreaming(messages, key, signal);
47
+ }
48
+ const response = await fetch(GROQ_ENDPOINT, {
49
+ method: "POST",
50
+ headers: {
51
+ Authorization: `Bearer ${key}`,
52
+ "Content-Type": "application/json"
53
+ },
54
+ body: JSON.stringify({
55
+ model: DEFAULT_MODEL,
56
+ messages,
57
+ stream: true,
58
+ temperature: 1
59
+ }),
60
+ signal
61
+ });
62
+ if (!response.ok) {
63
+ const err = await response.text();
64
+ throw new Error(`Groq API error (${response.status}): ${err}`);
65
+ }
66
+ if (!response.body || typeof response.body.getReader !== "function") {
67
+ return fetchNonStreaming(messages, key, signal);
68
+ }
69
+ const reader = response.body.getReader();
70
+ const decoder = new TextDecoder();
71
+ let fullContent = "";
72
+ let buffer = "";
73
+ while (true) {
74
+ const {
75
+ done,
76
+ value
77
+ } = await reader.read();
78
+ if (done)
79
+ break;
80
+ buffer += decoder.decode(value, {
81
+ stream: true
82
+ });
83
+ const lines = buffer.split("\n");
84
+ buffer = lines.pop() || "";
85
+ for (const line of lines) {
86
+ if (line.startsWith("data: ")) {
87
+ const data = line.slice(6);
88
+ if (data === "[DONE]")
89
+ continue;
90
+ try {
91
+ const parsed = JSON.parse(data);
92
+ const delta = (_c = (_b = (_a = parsed.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.delta) == null ? void 0 : _c.content;
93
+ if (delta)
94
+ fullContent += delta;
95
+ } catch (e) {
96
+ }
97
+ }
98
+ }
99
+ }
100
+ return {
101
+ content: fullContent,
102
+ tokenUsage: void 0
103
+ };
104
+ }export{streamChatResponse};//# sourceMappingURL=chatApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatApi.js","sources":["../../src/api/chatApi.ts"],"sourcesContent":["/**\n * Minimal Groq API client for mobile chat.\n * Uses GROQ_API_KEY from config (packages-modules/account/mobile/src/config/env-config.ts).\n */\n\nimport { config } from '../config';\n\nconst GROQ_ENDPOINT = 'https://api.groq.com/openai/v1/chat/completions';\nconst DEFAULT_MODEL = 'meta-llama/llama-4-scout-17b-16e-instruct';\n\nfunction getApiKey(): string {\n const key = config.GROQ_API_KEY || '';\n if (!key) {\n throw new Error('GROQ_API_KEY is not configured. Add it to your .env file (e.g. config/development/dev.env).');\n }\n return key;\n}\n\nexport interface ChatMessage {\n role: 'user' | 'assistant' | 'system';\n content: string;\n}\n\nexport interface StreamResult {\n content: string;\n tokenUsage?: {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n };\n}\n\n/**\n * Perform a non-streaming request (used when response.body/ReadableStream is not available, e.g. React Native).\n */\nasync function fetchNonStreaming(messages: ChatMessage[], key: string, signal?: AbortSignal): Promise<StreamResult> {\n const response = await fetch(GROQ_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${key}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: DEFAULT_MODEL,\n messages,\n stream: false,\n temperature: 1,\n }),\n signal,\n });\n\n if (!response.ok) {\n const err = await response.text();\n throw new Error(`Groq API error (${response.status}): ${err}`);\n }\n\n const data = await response.json();\n const content = data.choices?.[0]?.message?.content ?? '';\n const usage = data.usage;\n\n return {\n content,\n tokenUsage: usage\n ? {\n inputTokens: usage.prompt_tokens ?? 0,\n outputTokens: usage.completion_tokens ?? 0,\n totalTokens: usage.total_tokens ?? 0,\n }\n : undefined,\n };\n}\n\nexport interface StreamChatOptions {\n /** Set to true when response.body/ReadableStream is not available (e.g. React Native) to use a single non-streaming request. */\n preferNonStreaming?: boolean;\n}\n\nexport async function streamChatResponse(\n messages: ChatMessage[],\n apiKey?: string,\n signal?: AbortSignal,\n options?: StreamChatOptions,\n): Promise<StreamResult> {\n const key = apiKey || getApiKey();\n\n if (options?.preferNonStreaming) {\n return fetchNonStreaming(messages, key, signal);\n }\n\n const response = await fetch(GROQ_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${key}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: DEFAULT_MODEL,\n messages,\n stream: true,\n temperature: 1,\n }),\n signal,\n });\n\n if (!response.ok) {\n const err = await response.text();\n throw new Error(`Groq API error (${response.status}): ${err}`);\n }\n\n // React Native's fetch often does not expose response.body (ReadableStream).\n // Fall back to a non-streaming request so we can read the full response.\n if (!response.body || typeof response.body.getReader !== 'function') {\n return fetchNonStreaming(messages, key, signal);\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let fullContent = '';\n let buffer = '';\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() || '';\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.slice(6);\n // eslint-disable-next-line no-continue\n if (data === '[DONE]') continue;\n\n try {\n const parsed = JSON.parse(data);\n const delta = parsed.choices?.[0]?.delta?.content;\n if (delta) fullContent += delta;\n } catch {\n // ignore parse errors\n }\n }\n }\n }\n\n return {\n content: fullContent,\n tokenUsage: undefined, // Groq streaming doesn't always return usage in stream\n };\n}\n"],"names":[],"mappings":"6CAMA,MAAM,aAAgB,GAAA,iDAAA;AACtB,MAAM,aAAgB,GAAA,2CAAA;AACtB,SAAS,SAAoB,GAAA;AAC3B,EAAM,MAAA,GAAA,GAAM,OAAO,YAAgB,IAAA,EAAA;AACnC,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAM,MAAA,IAAI,MAAM,6FAA6F,CAAA;AAAA;AAE/G,EAAO,OAAA,GAAA;AACT;AAiBA,eAAe,iBAAA,CAAkB,QAAyB,EAAA,GAAA,EAAa,MAA6C,EAAA;AA/BpH,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAgCE,EAAM,MAAA,QAAA,GAAW,MAAM,KAAA,CAAM,aAAe,EAAA;AAAA,IAC1C,MAAQ,EAAA,MAAA;AAAA,IACR,OAAS,EAAA;AAAA,MACP,eAAe,CAAU,OAAA,EAAA,GAAA,CAAA,CAAA;AAAA,MACzB,cAAgB,EAAA;AAAA,KAClB;AAAA,IACA,IAAA,EAAM,KAAK,SAAU,CAAA;AAAA,MACnB,KAAO,EAAA,aAAA;AAAA,MACP,QAAA;AAAA,MACA,MAAQ,EAAA,KAAA;AAAA,MACR,WAAa,EAAA;AAAA,KACd,CAAA;AAAA,IACD;AAAA,GACD,CAAA;AACD,EAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,IAAM,MAAA,GAAA,GAAM,MAAM,QAAA,CAAS,IAAK,EAAA;AAChC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAmB,gBAAA,EAAA,QAAA,CAAS,YAAY,GAAK,CAAA,CAAA,CAAA;AAAA;AAE/D,EAAM,MAAA,IAAA,GAAO,MAAM,QAAA,CAAS,IAAK,EAAA;AACjC,EAAM,MAAA,OAA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AAA,QAAA;AAAU,UAAA;AACvB,QAAI,IAAA;AACF,UAAM,MAAA,MAAA,GAAS,IAAK,CAAA,KAAA,CAAM,IAAI,CAAA;AAC9B,UAAA,MAAM,SAAQ,EAAO,GAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAA,CAAA,OAAA,KAAP,mBAAiB,CAAjB,CAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAqB,UAArB,IAA4B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA;AAC1C,UAAI,IAAA,KAAA;AAAO,YAAe,WAAA,IAAA,KAAA;AAAA,iBACpB,CAAN,EAAA;AAAA;AAEF;AACF;AACF;AAEF,EAAO,OAAA;AAAA,IACL,OAAS,EAAA,WAAA;AAAA,IACT,UAAY,EAAA;AAAA,GACd;AACF"}
package/lib/compute.js ADDED
@@ -0,0 +1,33 @@
1
+ import { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';
2
+ const yantraMobilePageStore = [{
3
+ key: "home",
4
+ path: "/l/home",
5
+ name: "Home",
6
+ exact: true,
7
+ index: true,
8
+ priority: 1,
9
+ hideInMenu: true,
10
+ auth: true,
11
+ menu_position: "side",
12
+ props: {
13
+ initialParams: {
14
+ initialSessionId: null
15
+ },
16
+ options: {
17
+ title: "Yantra",
18
+ headerTintColor: "black",
19
+ headerTitleStyle: {
20
+ fontWeight: "bold"
21
+ },
22
+ drawerLabel: "Home",
23
+ headerTitleAlign: "left",
24
+ gestureEnabled: false,
25
+ swipeEnabled: false
26
+ }
27
+ },
28
+ componentPath: "@adminide-stack/yantra-mobile/lib/screens/Home/index.js",
29
+ hasComponent: true
30
+ }];
31
+ const selectedRoutes = ["home"];
32
+ const filteredRoutes = getFilteredRoutes(yantraMobilePageStore, selectedRoutes);
33
+ export { filteredRoutes, yantraMobilePageStore }; //# sourceMappingURL=compute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.js","sources":["../src/compute.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';\nimport type { IRouteModule } from '@common-stack/core';\n\nexport const yantraMobilePageStore: IRouteModule[] = [\n {\n key: 'home',\n path: '/l/home',\n name: 'Home',\n exact: true,\n index: true,\n priority: 1,\n hideInMenu: true,\n auth: true,\n menu_position: 'side',\n component: () => import('./screens/Home'),\n props: {\n initialParams: { initialSessionId: null },\n options: {\n title: 'Yantra',\n headerTintColor: 'black',\n headerTitleStyle: {\n fontWeight: 'bold',\n },\n drawerLabel: 'Home',\n headerTitleAlign: 'left',\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n];\n\nconst selectedRoutes = ['home'];\n\nconst filteredRoutes = getFilteredRoutes(yantraMobilePageStore, selectedRoutes);\n\nexport { filteredRoutes };\n"],"names":[],"mappings":"uFAGO,MAAM,wBAAwC,CAAC;AAAA,EACpD,GAAK,EAAA,MAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,IAAM,EAAA,MAAA;AAAA,EACN,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,QAAU,EAAA,CAAA;AAAA,EACV,UAAY,EAAA,IAAA;AAAA,EACZ,IAAM,EAAA,IAAA;AAAA,EACN,aAAe,EAAA,MAAA;AAAA,EACf,SAAA,EAAW,MAAM,OAAO,yBAAA,CAAA;AAAA,EACxB,KAAO,EAAA;AAAA,IACL,aAAe,EAAA;AAAA,MACb,gBAAkB,EAAA;AAAA,KACpB;AAAA,IACA,OAAS,EAAA;AAAA,MACP,KAAO,EAAA,QAAA;AAAA,MACP,eAAiB,EAAA,OAAA;AAAA,MACjB,gBAAkB,EAAA;AAAA,QAChB,UAAY,EAAA;AAAA,OACd;AAAA,MACA,WAAa,EAAA,MAAA;AAAA,MACb,gBAAkB,EAAA,MAAA;AAAA,MAClB,cAAgB,EAAA,KAAA;AAAA,MAChB,YAAc,EAAA;AAAA;AAChB;AAEJ,CAAC;AACD,MAAM,cAAA,GAAiB,CAAC,MAAM,CAAA;AACxB,MAAA,cAAA,GAAiB,iBAAkB,CAAA,qBAAA,EAAuB,cAAc"}
@@ -0,0 +1,18 @@
1
+ import {cleanEnv,str}from'envalid';const env = process.APP_ENV || process.env;
2
+ const config = cleanEnv(
3
+ env,
4
+ {
5
+ GRAPHQL_URL: str({
6
+ default: "http://localhost:8080/graphql"
7
+ }),
8
+ CLIENT_URL: str({
9
+ default: "http://localhost:3000"
10
+ }),
11
+ APP_NAME: str({
12
+ default: "CDMBASE"
13
+ }),
14
+ GROQ_API_KEY: str({
15
+ default: ""
16
+ })
17
+ }
18
+ );export{config};//# sourceMappingURL=env-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-config.js","sources":["../../src/config/env-config.ts"],"sourcesContent":["import { str, cleanEnv } from 'envalid';\n\nconst env = (process as any).APP_ENV || process.env;\n\nexport const config = cleanEnv(\n env,\n /* start */\n {\n GRAPHQL_URL: str({ default: 'http://localhost:8080/graphql' }),\n CLIENT_URL: str({ default: 'http://localhost:3000' }),\n APP_NAME: str({ default: 'CDMBASE' }),\n GROQ_API_KEY: str({ default: '' }),\n } /* end */,\n);\n"],"names":[],"mappings":"mCACA,MAAM,GAAA,GAAO,OAAgB,CAAA,OAAA,IAAW,OAAQ,CAAA,GAAA;AACzC,MAAM,MAAS,GAAA,QAAA;AAAA,EAAS,GAAA;AAAA,EAC/B;AAAA,IACE,aAAa,GAAI,CAAA;AAAA,MACf,OAAS,EAAA;AAAA,KACV,CAAA;AAAA,IACD,YAAY,GAAI,CAAA;AAAA,MACd,OAAS,EAAA;AAAA,KACV,CAAA;AAAA,IACD,UAAU,GAAI,CAAA;AAAA,MACZ,OAAS,EAAA;AAAA,KACV,CAAA;AAAA,IACD,cAAc,GAAI,CAAA;AAAA,MAChB,OAAS,EAAA;AAAA,KACV;AAAA;AACQ"}
@@ -0,0 +1,236 @@
1
+ import {useCreateAccountChatSessionMutation,useSaveAccountChatMessagesMutation,GetAccountChatSessionsDocument,GetAccountChatMessagesDocument,useGetAccountChatMessagesQuery}from'common/graphql';import {useCallback,useMemo}from'react';var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const SESSIONS_QUERY_VARS = {
21
+ first: 25,
22
+ includeArchived: false
23
+ };
24
+ function readSessionsCache(cache) {
25
+ try {
26
+ return cache.readQuery({
27
+ query: GetAccountChatSessionsDocument,
28
+ variables: SESSIONS_QUERY_VARS
29
+ });
30
+ } catch (e) {
31
+ return null;
32
+ }
33
+ }
34
+ function readMessagesCache(cache, sessionId) {
35
+ try {
36
+ return cache.readQuery({
37
+ query: GetAccountChatMessagesDocument,
38
+ variables: {
39
+ sessionId,
40
+ first: 100
41
+ }
42
+ });
43
+ } catch (e) {
44
+ return null;
45
+ }
46
+ }
47
+ function buildSessionEdge(node) {
48
+ return {
49
+ __typename: "AccountChatSessionEdge",
50
+ cursor: "",
51
+ node: __spreadValues({
52
+ __typename: "AccountChatSession"
53
+ }, node)
54
+ };
55
+ }
56
+ function buildMessageEdge(node) {
57
+ return {
58
+ __typename: "AccountChatMessageEdge",
59
+ cursor: "",
60
+ node: __spreadValues({
61
+ __typename: "AccountChatMessage"
62
+ }, node)
63
+ };
64
+ }
65
+ function useChatMessages(sessionId, options) {
66
+ const {
67
+ data,
68
+ loading,
69
+ error,
70
+ refetch
71
+ } = useGetAccountChatMessagesQuery({
72
+ variables: {
73
+ sessionId,
74
+ first: 100
75
+ },
76
+ skip: !sessionId || (void 0 ),
77
+ fetchPolicy: "cache-first"
78
+ });
79
+ const messages = useMemo(() => {
80
+ var _a;
81
+ if (!((_a = data == null ? void 0 : data.getAccountChatMessages) == null ? void 0 : _a.edges))
82
+ return [];
83
+ return data.getAccountChatMessages.edges.map((edge) => {
84
+ var _a2, _b;
85
+ const n = edge.node;
86
+ return {
87
+ id: n.id,
88
+ sessionId: n.sessionId,
89
+ role: n.role,
90
+ content: (_a2 = n.content) != null ? _a2 : "",
91
+ attachments: (_b = n.attachments) != null ? _b : void 0,
92
+ tokenCount: n.tokenCount,
93
+ model: n.model,
94
+ createdAt: new Date(n.createdAt),
95
+ updatedAt: new Date(n.updatedAt)
96
+ };
97
+ });
98
+ }, [data]);
99
+ return {
100
+ messages,
101
+ loading,
102
+ error,
103
+ refetch
104
+ };
105
+ }
106
+ function useChatMutations() {
107
+ const [createSessionMutation, {
108
+ loading: createLoading
109
+ }] = useCreateAccountChatSessionMutation();
110
+ const [saveMessagesMutation, {
111
+ loading: saveMessagesLoading
112
+ }] = useSaveAccountChatMessagesMutation();
113
+ const createSession = useCallback(async (input) => {
114
+ var _a, _b;
115
+ const inputWithId = __spreadValues(__spreadValues({
116
+ id: input == null ? void 0 : input.id,
117
+ title: (_a = input == null ? void 0 : input.title) != null ? _a : "New Chat"
118
+ }, (input == null ? void 0 : input.model) && {
119
+ model: input.model
120
+ }), (input == null ? void 0 : input.systemPrompt) && {
121
+ systemPrompt: input.systemPrompt
122
+ });
123
+ const {
124
+ data
125
+ } = await createSessionMutation({
126
+ variables: {
127
+ input: inputWithId
128
+ },
129
+ update: (cache, {
130
+ data: result
131
+ }) => {
132
+ var _a2;
133
+ if (!(result == null ? void 0 : result.createAccountChatSession))
134
+ return;
135
+ try {
136
+ const existing = readSessionsCache(cache);
137
+ if (existing == null ? void 0 : existing.getAccountChatSessions) {
138
+ const newEdge = buildSessionEdge(result.createAccountChatSession);
139
+ cache.writeQuery({
140
+ query: GetAccountChatSessionsDocument,
141
+ variables: SESSIONS_QUERY_VARS,
142
+ data: {
143
+ getAccountChatSessions: __spreadProps(__spreadValues({}, existing.getAccountChatSessions), {
144
+ edges: [newEdge, ...existing.getAccountChatSessions.edges],
145
+ totalCount: ((_a2 = existing.getAccountChatSessions.totalCount) != null ? _a2 : 0) + 1
146
+ })
147
+ }
148
+ });
149
+ }
150
+ } catch (err) {
151
+ console.warn("[useChatApi] createSession cache update failed:", err);
152
+ }
153
+ }
154
+ });
155
+ if (!(data == null ? void 0 : data.createAccountChatSession)) {
156
+ throw new Error("Failed to create session");
157
+ }
158
+ const s = data.createAccountChatSession;
159
+ return {
160
+ id: s.id,
161
+ title: (_b = s.title) != null ? _b : "New Chat",
162
+ createdAt: new Date(s.createdAt),
163
+ updatedAt: new Date(s.updatedAt)
164
+ };
165
+ }, [createSessionMutation]);
166
+ const saveMessages = useCallback(async (input) => {
167
+ const {
168
+ data
169
+ } = await saveMessagesMutation({
170
+ variables: {
171
+ input
172
+ },
173
+ update: (cache, {
174
+ data: result
175
+ }) => {
176
+ var _a;
177
+ if (!(result == null ? void 0 : result.saveAccountChatMessages))
178
+ return;
179
+ const res = result.saveAccountChatMessages;
180
+ try {
181
+ const existingMessages = readMessagesCache(cache, input.sessionId);
182
+ if (existingMessages == null ? void 0 : existingMessages.getAccountChatMessages) {
183
+ const userEdge = buildMessageEdge(res.userMessage);
184
+ const assistantEdge = buildMessageEdge(res.assistantMessage);
185
+ cache.writeQuery({
186
+ query: GetAccountChatMessagesDocument,
187
+ variables: {
188
+ sessionId: input.sessionId,
189
+ first: 100
190
+ },
191
+ data: {
192
+ getAccountChatMessages: __spreadProps(__spreadValues({}, existingMessages.getAccountChatMessages), {
193
+ edges: [...existingMessages.getAccountChatMessages.edges, userEdge, assistantEdge],
194
+ totalCount: ((_a = existingMessages.getAccountChatMessages.totalCount) != null ? _a : 0) + 2
195
+ })
196
+ }
197
+ });
198
+ }
199
+ } catch (err) {
200
+ console.warn("[useChatApi] saveMessages cache update failed:", err);
201
+ }
202
+ try {
203
+ const existingSessions = readSessionsCache(cache);
204
+ if (existingSessions == null ? void 0 : existingSessions.getAccountChatSessions) {
205
+ const sessionData = res.session;
206
+ const updatedEdges = existingSessions.getAccountChatSessions.edges.map((edge) => edge.node.id === sessionData.id ? __spreadProps(__spreadValues({}, edge), {
207
+ node: __spreadValues(__spreadValues({}, edge.node), sessionData)
208
+ }) : edge);
209
+ cache.writeQuery({
210
+ query: GetAccountChatSessionsDocument,
211
+ variables: SESSIONS_QUERY_VARS,
212
+ data: {
213
+ getAccountChatSessions: __spreadProps(__spreadValues({}, existingSessions.getAccountChatSessions), {
214
+ edges: updatedEdges
215
+ })
216
+ }
217
+ });
218
+ }
219
+ } catch (err) {
220
+ console.warn("[useChatApi] saveMessages session cache update failed:", err);
221
+ }
222
+ }
223
+ });
224
+ if (!(data == null ? void 0 : data.saveAccountChatMessages)) {
225
+ throw new Error("Failed to save messages");
226
+ }
227
+ }, [saveMessagesMutation]);
228
+ return {
229
+ createSession,
230
+ saveMessages,
231
+ loading: {
232
+ create: createLoading,
233
+ saveMessages: saveMessagesLoading
234
+ }
235
+ };
236
+ }export{useChatMessages,useChatMutations};//# sourceMappingURL=useChatApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatApi.js","sources":["../../src/hooks/useChatApi.ts"],"sourcesContent":["import type { ApolloCache } from '@apollo/client';\nimport {\n GetAccountChatMessagesDocument,\n GetAccountChatSessionsDocument,\n useCreateAccountChatSessionMutation,\n useGetAccountChatMessagesQuery,\n useGetAccountChatSessionsQuery,\n useSaveAccountChatMessagesMutation,\n} from 'common/graphql';\nimport type { IAccountCreateChatSessionInput, IAccountSaveChatMessagesInput } from 'common/server';\nimport { useCallback, useMemo } from 'react';\n\nconst SESSIONS_QUERY_VARS = { first: 25, includeArchived: false };\n\nfunction readSessionsCache(cache: ApolloCache<unknown>) {\n try {\n return cache.readQuery({\n query: GetAccountChatSessionsDocument,\n variables: SESSIONS_QUERY_VARS,\n }) as { getAccountChatSessions?: { edges: unknown[]; totalCount?: number } } | null;\n } catch {\n return null;\n }\n}\n\nfunction readMessagesCache(cache: ApolloCache<unknown>, sessionId: string) {\n try {\n return cache.readQuery({\n query: GetAccountChatMessagesDocument,\n variables: { sessionId, first: 100 },\n }) as { getAccountChatMessages?: { edges: unknown[]; totalCount?: number } } | null;\n } catch {\n return null;\n }\n}\n\nfunction buildSessionEdge(node: Record<string, unknown>) {\n return {\n __typename: 'AccountChatSessionEdge',\n cursor: '',\n node: {\n __typename: 'AccountChatSession',\n ...node,\n },\n };\n}\n\nfunction buildMessageEdge(node: Record<string, unknown>) {\n return {\n __typename: 'AccountChatMessageEdge',\n cursor: '',\n node: {\n __typename: 'AccountChatMessage',\n ...node,\n },\n };\n}\n\nexport interface ChatSessionUI {\n id: string;\n title: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport function useChatSessions(options?: { includeArchived?: boolean; skip?: boolean }) {\n const { data, loading, error, refetch } = useGetAccountChatSessionsQuery({\n variables: {\n first: 25,\n includeArchived: options?.includeArchived ?? false,\n },\n skip: options?.skip,\n fetchPolicy: 'cache-first',\n });\n\n const sessions: ChatSessionUI[] = useMemo(() => {\n if (!data?.getAccountChatSessions?.edges) return [];\n return data.getAccountChatSessions.edges.map((edge: { node: Record<string, unknown> }) => ({\n id: edge.node.id as string,\n title: (edge.node.title as string) ?? 'New Chat',\n createdAt: new Date(edge.node.createdAt as string),\n updatedAt: new Date(edge.node.updatedAt as string),\n }));\n }, [data]);\n\n return { sessions, loading, error, refetch };\n}\n\nexport interface ChatMessageUI {\n id: string;\n sessionId: string;\n role: 'user' | 'assistant' | 'system';\n content: string;\n attachments?: Array<{ id: string; name: string; type: string; mimeType?: string; size?: number; url?: string }>;\n tokenCount?: number;\n model?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport function useChatMessages(sessionId: string | null, options?: { skip?: boolean }) {\n const { data, loading, error, refetch } = useGetAccountChatMessagesQuery({\n variables: { sessionId: sessionId!, first: 100 },\n skip: !sessionId || options?.skip,\n fetchPolicy: 'cache-first',\n });\n\n const messages: ChatMessageUI[] = useMemo(() => {\n if (!data?.getAccountChatMessages?.edges) return [];\n return data.getAccountChatMessages.edges.map((edge: { node: Record<string, unknown> }) => {\n const n = edge.node;\n return {\n id: n.id as string,\n sessionId: n.sessionId as string,\n role: n.role as 'user' | 'assistant' | 'system',\n content: (n.content as string) ?? '',\n attachments: (n.attachments as ChatMessageUI['attachments']) ?? undefined,\n tokenCount: n.tokenCount as number | undefined,\n model: n.model as string | undefined,\n createdAt: new Date(n.createdAt as string),\n updatedAt: new Date(n.updatedAt as string),\n };\n });\n }, [data]);\n\n return { messages, loading, error, refetch };\n}\n\nexport function useChatMutations() {\n const [createSessionMutation, { loading: createLoading }] = useCreateAccountChatSessionMutation();\n const [saveMessagesMutation, { loading: saveMessagesLoading }] = useSaveAccountChatMessagesMutation();\n\n const createSession = useCallback(\n async (input?: IAccountCreateChatSessionInput): Promise<ChatSessionUI> => {\n const inputWithId = {\n id: input?.id,\n title: input?.title ?? 'New Chat',\n ...(input?.model && { model: input.model }),\n ...(input?.systemPrompt && { systemPrompt: input.systemPrompt }),\n };\n\n const { data } = await createSessionMutation({\n variables: { input: inputWithId },\n update: (cache, { data: result }) => {\n if (!result?.createAccountChatSession) return;\n try {\n const existing = readSessionsCache(cache);\n if (existing?.getAccountChatSessions) {\n const newEdge = buildSessionEdge(result.createAccountChatSession);\n cache.writeQuery({\n query: GetAccountChatSessionsDocument,\n variables: SESSIONS_QUERY_VARS,\n data: {\n getAccountChatSessions: {\n ...existing.getAccountChatSessions,\n edges: [newEdge, ...existing.getAccountChatSessions.edges],\n totalCount: (existing.getAccountChatSessions.totalCount ?? 0) + 1,\n },\n },\n });\n }\n } catch (err) {\n console.warn('[useChatApi] createSession cache update failed:', err);\n }\n },\n });\n\n if (!data?.createAccountChatSession) {\n throw new Error('Failed to create session');\n }\n\n const s = data.createAccountChatSession;\n return {\n id: s.id,\n title: s.title ?? 'New Chat',\n createdAt: new Date(s.createdAt),\n updatedAt: new Date(s.updatedAt),\n };\n },\n [createSessionMutation],\n );\n\n const saveMessages = useCallback(\n async (input: IAccountSaveChatMessagesInput): Promise<void> => {\n const { data } = await saveMessagesMutation({\n variables: { input },\n update: (cache, { data: result }) => {\n if (!result?.saveAccountChatMessages) return;\n const res = result.saveAccountChatMessages;\n try {\n const existingMessages = readMessagesCache(cache, input.sessionId);\n if (existingMessages?.getAccountChatMessages) {\n const userEdge = buildMessageEdge(res.userMessage);\n const assistantEdge = buildMessageEdge(res.assistantMessage);\n cache.writeQuery({\n query: GetAccountChatMessagesDocument,\n variables: { sessionId: input.sessionId, first: 100 },\n data: {\n getAccountChatMessages: {\n ...existingMessages.getAccountChatMessages,\n edges: [\n ...existingMessages.getAccountChatMessages.edges,\n userEdge,\n assistantEdge,\n ],\n totalCount: (existingMessages.getAccountChatMessages.totalCount ?? 0) + 2,\n },\n },\n });\n }\n } catch (err) {\n console.warn('[useChatApi] saveMessages cache update failed:', err);\n }\n try {\n const existingSessions = readSessionsCache(cache);\n if (existingSessions?.getAccountChatSessions) {\n const sessionData = res.session;\n const updatedEdges = existingSessions.getAccountChatSessions.edges.map((edge: any) =>\n edge.node.id === sessionData.id\n ? { ...edge, node: { ...edge.node, ...sessionData } }\n : edge,\n );\n cache.writeQuery({\n query: GetAccountChatSessionsDocument,\n variables: SESSIONS_QUERY_VARS,\n data: {\n getAccountChatSessions: {\n ...existingSessions.getAccountChatSessions,\n edges: updatedEdges,\n },\n },\n });\n }\n } catch (err) {\n console.warn('[useChatApi] saveMessages session cache update failed:', err);\n }\n },\n });\n if (!data?.saveAccountChatMessages) {\n throw new Error('Failed to save messages');\n }\n },\n [saveMessagesMutation],\n );\n\n return {\n createSession,\n saveMessages,\n loading: { create: createLoading, saveMessages: saveMessagesLoading },\n };\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA,MAAM,mBAAsB,GAAA;AAAA,EAC1B,KAAO,EAAA,EAAA;AAAA,EACP,eAAiB,EAAA;AACnB,CAAA;AACA,SAAS,kBAAkB,KAA6B,EAAA;AACtD,EAAI,IAAA;AACF,IAAA,OAAO,MAAM,SAAU,CAAA;AAAA,MACrB,KAAO,EAAA,8BAAA;AAAA,MACP,SAAW,EAAA;AAAA,KACZ,CAAA;AAAA,WAMK,CAAN,EAAA;AACA,IAAO,OAAA,IAAA;AAAA;AAEX;AACA,SAAS,iBAAA,CAAkB,OAA6B,SAAmB,EAAA;AACzE,EAAI,IAAA;AACF,IAAA,OAAO,MAAM,SAAU,CAAA;AAAA,MACrB,KAAO,EAAA,8BAAA;AAAA,MACP,SAAW,EAAA;AAAA,QACT,SAAA;AAAA,QACA,KAAO,EAAA;AAAA;AACT,KACD,CAAA;AAAA,WAMK,CAAN,EAAA;AACA,IAAO,OAAA,IAAA;AAAA;AAEX;AACA,SAAS,iBAAiB,IAA+B,EAAA;AACvD,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,wBAAA;AAAA,IACZ,MAAQ,EAAA,EAAA;AAAA,IACR,IAAM,EAAA,cAAA,CAAA;AAAA,MACJ,UAAY,EAAA;AAAA,KACT,EAAA,IAAA;AAAA,GAEP;AACF;AACA,SAAS,iBAAiB,IAA+B,EAAA;AACvD,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,wBAAA;AAAA,IACZ,MAAQ,EAAA,EAAA;AAAA,IACR,IAAM,EAAA,cAAA,CAAA;AAAA,MACJ,UAAY,EAAA;AAAA,KACT,EAAA,IAAA;AAAA,GAEP;AACF;AA4DgB,SAAA,eAAA,CAAgB,WAA0B,OAEvD,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useCallback}from'react';import {useChatMutations,useChatMessages}from'./useChatApi.js';import {streamChatResponse}from'../api/chatApi.js';const REVEAL_CHUNK_SIZE = 6;
2
+ const REVEAL_INTERVAL_MS = 20;
3
+ function useChatStream(sessionId) {
4
+ const [messages, setMessages] = useState([]);
5
+ const [response, setResponse] = useState("");
6
+ const [isLoading, setIsLoading] = useState(false);
7
+ const [isStreaming, setIsStreaming] = useState(false);
8
+ const [error, setError] = useState(null);
9
+ const abortRef = useRef(null);
10
+ const isSendingRef = useRef(false);
11
+ const revealIntervalRef = useRef(null);
12
+ const {
13
+ saveMessages
14
+ } = useChatMutations();
15
+ const {
16
+ messages: backendMessages
17
+ } = useChatMessages(sessionId);
18
+ useEffect(() => () => {
19
+ if (revealIntervalRef.current) {
20
+ clearInterval(revealIntervalRef.current);
21
+ revealIntervalRef.current = null;
22
+ }
23
+ }, []);
24
+ useEffect(() => {
25
+ if (isSendingRef.current)
26
+ return;
27
+ if (!sessionId) {
28
+ setMessages([]);
29
+ setResponse("");
30
+ return;
31
+ }
32
+ if (backendMessages && backendMessages.length > 0) {
33
+ const formatted = backendMessages.map((msg) => {
34
+ var _a;
35
+ return {
36
+ role: msg.role,
37
+ content: (_a = msg.content) != null ? _a : "",
38
+ metadata: msg.tokenCount ? {
39
+ tokenUsage: {
40
+ inputTokens: 0,
41
+ outputTokens: msg.tokenCount,
42
+ totalTokens: msg.tokenCount
43
+ },
44
+ model: msg.model
45
+ } : void 0
46
+ };
47
+ });
48
+ setMessages(formatted);
49
+ setResponse("");
50
+ }
51
+ }, [sessionId, backendMessages]);
52
+ const sendMessage = useCallback(async (content, attachments, sessionIdOverride) => {
53
+ var _a, _b;
54
+ if (!content.trim())
55
+ return;
56
+ const effectiveSessionId = sessionIdOverride !== void 0 ? sessionIdOverride : sessionId;
57
+ const userMessage = {
58
+ role: "user",
59
+ content: content.trim(),
60
+ attachments
61
+ };
62
+ isSendingRef.current = true;
63
+ setMessages((prev) => [...prev, userMessage]);
64
+ setResponse("");
65
+ setIsLoading(true);
66
+ setIsStreaming(true);
67
+ setError(null);
68
+ abortRef.current = new AbortController();
69
+ const chatMessages = [...messages.map((m) => ({
70
+ role: m.role,
71
+ content: m.content
72
+ })), {
73
+ role: "user",
74
+ content: content.trim()
75
+ }];
76
+ let doingChunkedReveal = false;
77
+ try {
78
+ const g = global;
79
+ const preferNonStreaming = typeof (g == null ? void 0 : g.nativeCallSyncHook) === "function" || typeof (g == null ? void 0 : g.__fbBatchedBridge) !== "undefined";
80
+ const result = await streamChatResponse(chatMessages, void 0, abortRef.current.signal, {
81
+ preferNonStreaming
82
+ });
83
+ const fullContent = result.content;
84
+ if (preferNonStreaming && fullContent.length > 0) {
85
+ doingChunkedReveal = true;
86
+ if (revealIntervalRef.current) {
87
+ clearInterval(revealIntervalRef.current);
88
+ revealIntervalRef.current = null;
89
+ }
90
+ let revealedLen = 0;
91
+ revealIntervalRef.current = setInterval(() => {
92
+ var _a2, _b2;
93
+ revealedLen = Math.min(revealedLen + REVEAL_CHUNK_SIZE, fullContent.length);
94
+ setResponse(fullContent.slice(0, revealedLen));
95
+ if (revealedLen >= fullContent.length) {
96
+ if (revealIntervalRef.current) {
97
+ clearInterval(revealIntervalRef.current);
98
+ revealIntervalRef.current = null;
99
+ }
100
+ const assistantMessage2 = {
101
+ role: "assistant",
102
+ content: fullContent,
103
+ metadata: result.tokenUsage ? {
104
+ tokenUsage: {
105
+ inputTokens: result.tokenUsage.inputTokens,
106
+ outputTokens: result.tokenUsage.outputTokens,
107
+ totalTokens: result.tokenUsage.totalTokens
108
+ }
109
+ } : void 0
110
+ };
111
+ setMessages((prev) => [...prev, assistantMessage2]);
112
+ setResponse("");
113
+ if (effectiveSessionId) {
114
+ saveMessages({
115
+ sessionId: effectiveSessionId,
116
+ userMessage: {
117
+ content: userMessage.content,
118
+ attachments: (_a2 = userMessage.attachments) == null ? void 0 : _a2.map((a) => ({
119
+ id: a.id,
120
+ name: a.name,
121
+ type: a.type,
122
+ mimeType: a.mimeType,
123
+ size: a.size,
124
+ url: a.url
125
+ }))
126
+ },
127
+ assistantMessage: {
128
+ content: fullContent,
129
+ tokenCount: (_b2 = result.tokenUsage) == null ? void 0 : _b2.totalTokens,
130
+ model: void 0
131
+ }
132
+ }).catch((e) => console.error("[useChatStream] saveMessages:", e));
133
+ }
134
+ isSendingRef.current = false;
135
+ setIsLoading(false);
136
+ setIsStreaming(false);
137
+ abortRef.current = null;
138
+ }
139
+ }, REVEAL_INTERVAL_MS);
140
+ return;
141
+ }
142
+ const assistantMessage = {
143
+ role: "assistant",
144
+ content: fullContent,
145
+ metadata: result.tokenUsage ? {
146
+ tokenUsage: {
147
+ inputTokens: result.tokenUsage.inputTokens,
148
+ outputTokens: result.tokenUsage.outputTokens,
149
+ totalTokens: result.tokenUsage.totalTokens
150
+ }
151
+ } : void 0
152
+ };
153
+ setMessages((prev) => [...prev, assistantMessage]);
154
+ setResponse("");
155
+ if (effectiveSessionId) {
156
+ await saveMessages({
157
+ sessionId: effectiveSessionId,
158
+ userMessage: {
159
+ content: userMessage.content,
160
+ attachments: (_a = userMessage.attachments) == null ? void 0 : _a.map((a) => ({
161
+ id: a.id,
162
+ name: a.name,
163
+ type: a.type,
164
+ mimeType: a.mimeType,
165
+ size: a.size,
166
+ url: a.url
167
+ }))
168
+ },
169
+ assistantMessage: {
170
+ content: fullContent,
171
+ tokenCount: (_b = result.tokenUsage) == null ? void 0 : _b.totalTokens,
172
+ model: void 0
173
+ }
174
+ });
175
+ }
176
+ } catch (err) {
177
+ const msg = err instanceof Error ? err.message : String(err);
178
+ if (msg.includes("abort"))
179
+ return;
180
+ setError(msg);
181
+ setResponse("");
182
+ } finally {
183
+ if (!doingChunkedReveal) {
184
+ isSendingRef.current = false;
185
+ setIsLoading(false);
186
+ setIsStreaming(false);
187
+ abortRef.current = null;
188
+ }
189
+ }
190
+ }, [messages, sessionId, saveMessages]);
191
+ const cancel = useCallback(() => {
192
+ if (abortRef.current) {
193
+ abortRef.current.abort();
194
+ }
195
+ }, []);
196
+ const clearMessages = useCallback(() => {
197
+ setMessages([]);
198
+ setResponse("");
199
+ setError(null);
200
+ }, []);
201
+ return {
202
+ messages,
203
+ response,
204
+ error,
205
+ isLoading,
206
+ isStreaming,
207
+ hasMessages: messages.length > 0 || !!response,
208
+ sendMessage,
209
+ cancel,
210
+ clearMessages
211
+ };
212
+ }export{useChatStream};//# sourceMappingURL=useChatStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatStream.js","sources":["../../src/hooks/useChatStream.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { useChatMutations, useChatMessages } from './useChatApi';\nimport { streamChatResponse } from '../api/chatApi';\n\n/** Chunk size for simulated streaming reveal (Kimi-style step-by-step) */\nconst REVEAL_CHUNK_SIZE = 6;\n/** Delay in ms between chunks */\nconst REVEAL_INTERVAL_MS = 20;\n\nexport interface MessageAttachment {\n id: string;\n name: string;\n type: 'file' | 'screenshot';\n dataUrl?: string;\n mimeType?: string;\n size?: number;\n url?: string;\n}\n\nexport interface ChatMessage {\n role: 'user' | 'assistant';\n content: string;\n attachments?: MessageAttachment[];\n metadata?: {\n tokenUsage?: { inputTokens: number; outputTokens: number; totalTokens: number };\n model?: string;\n };\n}\n\nexport function useChatStream(sessionId: string | null) {\n const [messages, setMessages] = useState<ChatMessage[]>([]);\n const [response, setResponse] = useState('');\n const [isLoading, setIsLoading] = useState(false);\n const [isStreaming, setIsStreaming] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const isSendingRef = useRef(false);\n const revealIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const { saveMessages } = useChatMutations();\n const { messages: backendMessages } = useChatMessages(sessionId);\n\n useEffect(\n () => () => {\n if (revealIntervalRef.current) {\n clearInterval(revealIntervalRef.current);\n revealIntervalRef.current = null;\n }\n },\n [],\n );\n\n // Load messages from backend when session changes (skip if we're actively sending)\n useEffect(() => {\n if (isSendingRef.current) return;\n\n if (!sessionId) {\n setMessages([]);\n setResponse('');\n return;\n }\n // Only sync from backend when we have data - never clear when backend is empty\n // (we may have local messages from a send that just completed)\n if (backendMessages && backendMessages.length > 0) {\n const formatted: ChatMessage[] = backendMessages.map((msg) => ({\n role: msg.role as 'user' | 'assistant',\n content: msg.content ?? '',\n metadata: msg.tokenCount\n ? {\n tokenUsage: {\n inputTokens: 0,\n outputTokens: msg.tokenCount,\n totalTokens: msg.tokenCount,\n },\n model: msg.model,\n }\n : undefined,\n }));\n setMessages(formatted);\n setResponse('');\n }\n }, [sessionId, backendMessages]);\n\n const sendMessage = useCallback(\n async (content: string, attachments?: MessageAttachment[], sessionIdOverride?: string | null) => {\n if (!content.trim()) return;\n\n const effectiveSessionId = sessionIdOverride !== undefined ? sessionIdOverride : sessionId;\n\n const userMessage: ChatMessage = {\n role: 'user',\n content: content.trim(),\n attachments,\n };\n\n isSendingRef.current = true;\n setMessages((prev) => [...prev, userMessage]);\n setResponse('');\n setIsLoading(true);\n setIsStreaming(true);\n setError(null);\n\n abortRef.current = new AbortController();\n\n const chatMessages = [\n ...messages.map((m) => ({ role: m.role, content: m.content })),\n { role: 'user' as const, content: content.trim() },\n ];\n\n let doingChunkedReveal = false;\n try {\n const g = global as Record<string, unknown>;\n const preferNonStreaming =\n typeof g?.nativeCallSyncHook === 'function' || typeof g?.__fbBatchedBridge !== 'undefined';\n const result = await streamChatResponse(chatMessages, undefined, abortRef.current.signal, {\n preferNonStreaming,\n });\n const fullContent = result.content;\n\n if (preferNonStreaming && fullContent.length > 0) {\n doingChunkedReveal = true;\n if (revealIntervalRef.current) {\n clearInterval(revealIntervalRef.current);\n revealIntervalRef.current = null;\n }\n let revealedLen = 0;\n revealIntervalRef.current = setInterval(() => {\n revealedLen = Math.min(revealedLen + REVEAL_CHUNK_SIZE, fullContent.length);\n setResponse(fullContent.slice(0, revealedLen));\n if (revealedLen >= fullContent.length) {\n if (revealIntervalRef.current) {\n clearInterval(revealIntervalRef.current);\n revealIntervalRef.current = null;\n }\n const assistantMessage: ChatMessage = {\n role: 'assistant',\n content: fullContent,\n metadata: result.tokenUsage\n ? {\n tokenUsage: {\n inputTokens: result.tokenUsage.inputTokens,\n outputTokens: result.tokenUsage.outputTokens,\n totalTokens: result.tokenUsage.totalTokens,\n },\n }\n : undefined,\n };\n setMessages((prev) => [...prev, assistantMessage]);\n setResponse('');\n if (effectiveSessionId) {\n saveMessages({\n sessionId: effectiveSessionId,\n userMessage: {\n content: userMessage.content,\n attachments: userMessage.attachments?.map((a) => ({\n id: a.id,\n name: a.name,\n type: a.type,\n mimeType: a.mimeType,\n size: a.size,\n url: a.url,\n })),\n },\n assistantMessage: {\n content: fullContent,\n tokenCount: result.tokenUsage?.totalTokens,\n model: undefined,\n },\n }).catch((e) => console.error('[useChatStream] saveMessages:', e));\n }\n isSendingRef.current = false;\n setIsLoading(false);\n setIsStreaming(false);\n abortRef.current = null;\n }\n }, REVEAL_INTERVAL_MS);\n return;\n }\n\n const assistantMessage: ChatMessage = {\n role: 'assistant',\n content: fullContent,\n metadata: result.tokenUsage\n ? {\n tokenUsage: {\n inputTokens: result.tokenUsage.inputTokens,\n outputTokens: result.tokenUsage.outputTokens,\n totalTokens: result.tokenUsage.totalTokens,\n },\n }\n : undefined,\n };\n\n setMessages((prev) => [...prev, assistantMessage]);\n setResponse('');\n\n if (effectiveSessionId) {\n await saveMessages({\n sessionId: effectiveSessionId,\n userMessage: {\n content: userMessage.content,\n attachments: userMessage.attachments?.map((a) => ({\n id: a.id,\n name: a.name,\n type: a.type,\n mimeType: a.mimeType,\n size: a.size,\n url: a.url,\n })),\n },\n assistantMessage: {\n content: fullContent,\n tokenCount: result.tokenUsage?.totalTokens,\n model: undefined,\n },\n });\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n if (msg.includes('abort')) return;\n setError(msg);\n setResponse('');\n } finally {\n if (!doingChunkedReveal) {\n isSendingRef.current = false;\n setIsLoading(false);\n setIsStreaming(false);\n abortRef.current = null;\n }\n }\n },\n [messages, sessionId, saveMessages],\n );\n\n const cancel = useCallback(() => {\n if (abortRef.current) {\n abortRef.current.abort();\n }\n }, []);\n\n const clearMessages = useCallback(() => {\n setMessages([]);\n setResponse('');\n setError(null);\n }, []);\n\n return {\n messages,\n response,\n error,\n isLoading,\n isStreaming,\n hasMessages: messages.length > 0 || !!response,\n sendMessage,\n cancel,\n clearMessages,\n };\n}\n"],"names":["_a","_b","assistantMessage"],"mappings":"4KAKA,MAAM,iBAAoB,GAAA,CAAA;AAE1B,MAAM,kBAAqB,GAAA,EAAA;AAuBpB,SAAS,cAAc,SAA0B,EAAA;AACtD,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,QAAA,CAAwB,EAAE,CAAA;AAC1D,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,EAAE,CAAA;AAC3C,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA;AACpD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAwB,IAAI,CAAA;AACtD,EAAM,MAAA,QAAA,GAAW,OAA+B,IAAI,CAAA;AACpD,EAAM,MAAA,YAAA,GAAe,OAAO,KAAK,CAAA;AACjC,EAAM,MAAA,iBAAA,GAAoB,OAA8C,IAAI,CAAA;AAC5E,EAAM,MAAA;AAAA,IACJ;AAAA,MACE,gBAAiB,EAAA;AACrB,EAAM,MAAA;AAAA,IACJ,QAAU,EAAA;AAAA,GACZ,GAAI,gBAAgB,SAAS,CAAA;AAC7B,EAAA,SAAA,CAAU,MAAM,MAAM;AACpB,IAAA,IAAI,kBAAkB,OAAS,EAAA;AAC7B,MAAA,aAAA,CAAc,kBAAkB,OAAO,CAAA;AACvC,MAAA,iBAAA,CAAkB,OAAU,GAAA,IAAA;AAAA;AAC9B,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AU,GAAA,IAAA;AAAA;AACrB;AACF,GACC,EAAA,CAAC,QAAU,EAAA,SAAA,EAAW,YAAY,CAAC,CAAA;AACtC,EAAM,MAAA,MAAA,GAAS,YAAY,MAAM;AAC/B,IAAA,IAAI,SAAS,OAAS,EAAA;AACpB,MAAA,QAAA,CAAS,QAAQ,KAAM,EAAA;AAAA;AACzB,GACF,EAAG,EAAE,CAAA;AACL,EAAM,MAAA,aAAA,GAAgB,YAAY,MAAM;AACtC,IAAA,WAAA,CAAY,EAAE,CAAA;AACd,IAAA,WAAA,CAAY,EAAE,CAAA;AACd,IAAA,QAAA,CAAS,IAAI,CAAA;AAAA,GACf,EAAG,EAAE,CAAA;AACL,EAAO,OAAA;AAAA,IACL,QAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAa,EAAA,QAAA,CAAS,MAAS,GAAA,CAAA,IAAK,CAAC,CAAC,QAAA;AAAA,IACtC,WAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF"}
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ import {Feature}from'@common-stack/client-react';import YantraMobileModule from'./module.js';export{default as Home}from'./screens/Home/HomeScreen.js';var index = new Feature(YantraMobileModule);export{index as default};//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { Feature } from '@common-stack/client-react';\nimport YantraMobileModule from './module';\n\nexport default new Feature(YantraMobileModule);\nexport * from './screens';\n"],"names":[],"mappings":"uJAEA,YAAe,IAAI,QAAQ,kBAAkB,CAAA"}
package/lib/module.js ADDED
@@ -0,0 +1,3 @@
1
+ import {Feature}from'@common-stack/client-react';import {filteredRoutes}from'./compute.js';var YantraMobileModule = new Feature({
2
+ routeConfig: filteredRoutes
3
+ });export{YantraMobileModule as default};//# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { Feature } from '@common-stack/client-react';\nimport { filteredRoutes } from './compute';\n\nexport default new Feature({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n routeConfig: filteredRoutes as any,\n});\n"],"names":[],"mappings":"2FAGA,yBAAe,IAAI,OAAQ,CAAA;AAAA,EAEzB,WAAa,EAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ [
2
+ {
3
+ "/l/home": {
4
+ "key": "home",
5
+ "path": "/l/home",
6
+ "name": "Home",
7
+ "exact": true,
8
+ "index": true,
9
+ "priority": 1,
10
+ "hideInMenu": true,
11
+ "auth": true,
12
+ "menu_position": "side",
13
+ "props": {
14
+ "initialParams": {
15
+ "initialSessionId": null
16
+ },
17
+ "options": {
18
+ "title": "Yantra",
19
+ "headerTintColor": "black",
20
+ "headerTitleStyle": {
21
+ "fontWeight": "bold"
22
+ },
23
+ "drawerLabel": "Home",
24
+ "headerTitleAlign": "left",
25
+ "gestureEnabled": false,
26
+ "swipeEnabled": false
27
+ }
28
+ },
29
+ "componentPath": "@adminide-stack/yantra-mobile/lib/screens/Home/index.js",
30
+ "hasComponent": true
31
+ }
32
+ }
33
+ ]
@@ -0,0 +1,226 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';import {useState,useCallback,useEffect}from'react';import {Pressable,StyleSheet}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {getDefaultLeftItems,getDefaultRightItems,Box,Text,InputToolBar}from'@admin-layout/gluestack-ui-mobile';import {SafeAreaView}from'react-native-safe-area-context';import {useGetAccountChatSessionsQuery}from'common/graphql';import {v4}from'uuid';import {useNavigation}from'@react-navigation/native';import {MessagesContainerUI}from'@messenger-box/platform-mobile';import {useChatMutations}from'../../hooks/useChatApi.js';import {useChatStream}from'../../hooks/useChatStream.js';var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ function HomeScreenContent({
18
+ initialMode = "chat",
19
+ onSubmit: onSubmitProp,
20
+ onStop,
21
+ isLoading: isLoadingProp = false,
22
+ disabled = false
23
+ }) {
24
+ const navigation = useNavigation();
25
+ const [value, setValue] = useState("");
26
+ const [activeMode, setActiveMode] = useState(initialMode);
27
+ const [activeSessionId, setActiveSessionId] = useState(null);
28
+ const {
29
+ createSession
30
+ } = useChatMutations();
31
+ const chat = useChatStream(activeSessionId);
32
+ useGetAccountChatSessionsQuery({
33
+ variables: {
34
+ first: 25,
35
+ includeArchived: false
36
+ },
37
+ fetchPolicy: "cache-first"
38
+ });
39
+ const {
40
+ messages,
41
+ response,
42
+ error: chatError,
43
+ isLoading: chatLoading,
44
+ isStreaming,
45
+ hasMessages,
46
+ sendMessage,
47
+ cancel
48
+ } = chat;
49
+ const trimmedQuery = value.trim();
50
+ const hasQuery = trimmedQuery.length > 0;
51
+ const canSubmit = hasQuery;
52
+ const isLoading = isLoadingProp || chatLoading;
53
+ const isResearchMode = activeMode === "deep-search";
54
+ const inputPlaceholder = isResearchMode ? "Research anything..." : "Ask anything...";
55
+ const handleModeSwitch = useCallback((mode) => {
56
+ setActiveMode(mode);
57
+ }, []);
58
+ const handleSubmit = useCallback(async (attachments) => {
59
+ if (!canSubmit || isLoading || disabled)
60
+ return;
61
+ const submission = {
62
+ mode: activeMode,
63
+ query: trimmedQuery,
64
+ attachments
65
+ };
66
+ if (activeMode === "deep-search" && onSubmitProp) {
67
+ onSubmitProp(submission);
68
+ setValue("");
69
+ return;
70
+ }
71
+ if (onSubmitProp && activeMode === "chat") {
72
+ onSubmitProp(submission);
73
+ setValue("");
74
+ return;
75
+ }
76
+ if (!activeSessionId) {
77
+ const newSessionId = v4();
78
+ const title = activeMode === "deep-search" ? "Deep Search" : "New Chat";
79
+ try {
80
+ await createSession({
81
+ id: newSessionId,
82
+ title
83
+ });
84
+ setActiveSessionId(newSessionId);
85
+ setValue("");
86
+ sendMessage(trimmedQuery, void 0, newSessionId);
87
+ } catch (err) {
88
+ console.error("[HomeScreen] Failed to create session:", err);
89
+ }
90
+ } else {
91
+ setValue("");
92
+ sendMessage(trimmedQuery);
93
+ }
94
+ }, [canSubmit, isLoading, disabled, activeMode, trimmedQuery, activeSessionId, onSubmitProp, createSession, sendMessage]);
95
+ const handleNewChat = useCallback(() => {
96
+ setActiveSessionId(null);
97
+ setValue("");
98
+ }, []);
99
+ useEffect(() => {
100
+ navigation.setOptions({
101
+ headerRight: () => /* @__PURE__ */ jsx(Pressable, { onPress: handleNewChat, style: ({
102
+ pressed
103
+ }) => [styles.newChatButton, pressed && styles.newChatButtonPressed], accessibilityLabel: "New chat", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chat-plus-outline", size: 26, color: "#000" }) })
104
+ });
105
+ }, [navigation, handleNewChat]);
106
+ const handleSendMessage = useCallback(async (text) => {
107
+ if (!text.trim() || isLoading || disabled)
108
+ return;
109
+ const submission = {
110
+ mode: activeMode,
111
+ query: text.trim()
112
+ };
113
+ if (activeMode === "deep-search" && onSubmitProp) {
114
+ onSubmitProp(submission);
115
+ return;
116
+ }
117
+ if (!activeSessionId) {
118
+ const newSessionId = v4();
119
+ const title = activeMode === "deep-search" ? "Deep Search" : "New Chat";
120
+ try {
121
+ await createSession({
122
+ id: newSessionId,
123
+ title
124
+ });
125
+ setActiveSessionId(newSessionId);
126
+ sendMessage(text.trim(), void 0, newSessionId);
127
+ } catch (err) {
128
+ console.error("[HomeScreen] Failed to create session:", err);
129
+ }
130
+ } else {
131
+ sendMessage(text.trim());
132
+ }
133
+ }, [isLoading, disabled, activeSessionId, activeMode, onSubmitProp, createSession, sendMessage]);
134
+ const leftItems = getDefaultLeftItems({
135
+ search: {
136
+ active: activeMode === "chat",
137
+ onClick: () => handleModeSwitch("chat")
138
+ },
139
+ zap: {
140
+ active: activeMode === "deep-search",
141
+ onClick: () => handleModeSwitch("deep-search")
142
+ },
143
+ lightbulb: {
144
+ enabled: false
145
+ }
146
+ });
147
+ const rightItems = getDefaultRightItems({
148
+ tag: {
149
+ enabled: false
150
+ },
151
+ chip: {
152
+ enabled: false
153
+ },
154
+ camera: {
155
+ onClick: () => console.log("camera")
156
+ },
157
+ image: {
158
+ onClick: () => console.log("image")
159
+ },
160
+ attach: {
161
+ onClick: () => console.log("attach")
162
+ }
163
+ });
164
+ return /* @__PURE__ */ jsx(SafeAreaView, { style: {
165
+ flex: 1,
166
+ backgroundColor: "#fff"
167
+ }, children: /* @__PURE__ */ jsxs(Box, { flex: 1, width: "100%", children: [
168
+ chatError && /* @__PURE__ */ jsx(Box, { mb: "$2", mx: "$4", p: "$3", bg: "$gray200", borderRadius: "$md", children: /* @__PURE__ */ jsx(Text, { fontSize: "$sm", color: "$gray900", children: chatError }) }),
169
+ hasMessages || response ? /* @__PURE__ */ jsx(Box, { flex: 1, width: "100%", alignSelf: "stretch", children: /* @__PURE__ */ jsx(MessagesContainerUI, { mode: "plan", showBackButton: false, onBackPress: handleNewChat, compactTop: true, messagesContainerStyle: {
170
+ paddingHorizontal: 0,
171
+ paddingTop: 0,
172
+ margin: 0
173
+ }, listContentStyle: {
174
+ paddingTop: 0,
175
+ margin: 0
176
+ }, messages: messages.map((msg, index) => ({
177
+ id: `msg-${index}-${msg.role}`,
178
+ role: msg.role,
179
+ content: msg.content,
180
+ metadata: msg.metadata
181
+ })), streamingContent: response, currentUser: {
182
+ id: "user"
183
+ }, onSend: handleSendMessage, disabled: isLoading || disabled, isLoading, onStop: isStreaming ? cancel : onStop, renderPlanInputToolbar: ({
184
+ value: value2,
185
+ onChange,
186
+ onSend,
187
+ disabled: inputDisabled
188
+ }) => /* @__PURE__ */ jsx(InputToolBar, { inputConfig: {
189
+ value: value2,
190
+ onChange: (e) => onChange(e.nativeEvent.text),
191
+ placeholder: inputPlaceholder,
192
+ disabled: inputDisabled
193
+ }, leftItems, rightItems, templateButton: null, templateModalConfig: null, micSendButton: {
194
+ hasContent: value2.trim().length > 0,
195
+ onSend: () => onSend(value2.trim()),
196
+ onMic: () => console.log("mic"),
197
+ disabled: inputDisabled,
198
+ isLoading,
199
+ onStop: isStreaming ? cancel : onStop
200
+ } }), renderBuildInputToolbar: () => null }) }) : /* @__PURE__ */ jsx(Box, { flex: 1, justifyContent: "center", alignItems: "stretch", p: "$4", children: /* @__PURE__ */ jsx(InputToolBar, { inputConfig: {
201
+ value,
202
+ onChange: (e) => setValue(e.nativeEvent.text),
203
+ placeholder: inputPlaceholder,
204
+ disabled: isLoading || disabled
205
+ }, leftItems, rightItems, templateButton: null, templateModalConfig: null, micSendButton: {
206
+ hasContent: canSubmit,
207
+ onSend: () => handleSubmit(),
208
+ onMic: () => console.log("mic"),
209
+ disabled: isLoading || disabled,
210
+ isLoading,
211
+ onStop
212
+ } }) })
213
+ ] }) });
214
+ }
215
+ const styles = StyleSheet.create({
216
+ newChatButton: {
217
+ padding: 6,
218
+ marginRight: 4,
219
+ alignItems: "center",
220
+ justifyContent: "center"
221
+ },
222
+ newChatButtonPressed: {
223
+ opacity: 0.6
224
+ }
225
+ });
226
+ const HomeScreen = (props) => /* @__PURE__ */ jsx(HomeScreenContent, __spreadValues({}, props));export{HomeScreen as default};//# sourceMappingURL=HomeScreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HomeScreen.js","sources":["../../../src/screens/Home/HomeScreen.tsx"],"sourcesContent":["import React, { FC, useState, useCallback, useEffect } from 'react';\nimport { Pressable, StyleSheet } from 'react-native';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { Box, InputToolBar, Text, getDefaultLeftItems, getDefaultRightItems } from '@admin-layout/gluestack-ui-mobile';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport { useGetAccountChatSessionsQuery } from 'common/graphql';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useNavigation } from '@react-navigation/native';\nimport { MessagesContainerUI } from '@messenger-box/platform-mobile';\nimport { useChatMutations } from '../../hooks/useChatApi';\nimport { useChatStream } from '../../hooks/useChatStream';\nimport type { ModeSubmission, RoutingMode } from './types';\n\nexport type { RoutingMode, ModeSubmission };\n\nexport interface HomeScreenProps {\n initialMode?: RoutingMode;\n onSubmit?: (submission: ModeSubmission) => void;\n onStop?: () => void;\n isLoading?: boolean;\n disabled?: boolean;\n}\n\nfunction HomeScreenContent({\n initialMode = 'chat',\n onSubmit: onSubmitProp,\n onStop,\n isLoading: isLoadingProp = false,\n disabled = false,\n}: HomeScreenProps) {\n const navigation = useNavigation();\n const [value, setValue] = useState('');\n const [activeMode, setActiveMode] = useState<RoutingMode>(initialMode);\n const [activeSessionId, setActiveSessionId] = useState<string | null>(null);\n\n const { createSession } = useChatMutations();\n const chat = useChatStream(activeSessionId);\n\n useGetAccountChatSessionsQuery({\n variables: { first: 25, includeArchived: false },\n fetchPolicy: 'cache-first',\n });\n\n const {\n messages,\n response,\n error: chatError,\n isLoading: chatLoading,\n isStreaming,\n hasMessages,\n sendMessage,\n cancel,\n } = chat;\n\n const trimmedQuery = value.trim();\n const hasQuery = trimmedQuery.length > 0;\n const canSubmit = hasQuery;\n const isLoading = isLoadingProp || chatLoading;\n const isResearchMode = activeMode === 'deep-search';\n const inputPlaceholder = isResearchMode ? 'Research anything...' : 'Ask anything...';\n\n // useEffect(() => {\n // navigation.setOptions({\n // headerLeft: () => null,\n // });\n // }, []);\n\n const handleModeSwitch = useCallback((mode: RoutingMode) => {\n setActiveMode(mode);\n }, []);\n\n const handleSubmit = useCallback(\n async (attachments?: ModeSubmission['attachments']) => {\n if (!canSubmit || isLoading || disabled) return;\n\n const submission: ModeSubmission = {\n mode: activeMode,\n query: trimmedQuery,\n attachments,\n };\n\n // Research (deep-search): delegate to parent when provided, like browser NewChatPage → session page\n if (activeMode === 'deep-search' && onSubmitProp) {\n onSubmitProp(submission);\n setValue('');\n return;\n }\n\n if (onSubmitProp && activeMode === 'chat') {\n onSubmitProp(submission);\n setValue('');\n return;\n }\n\n if (!activeSessionId) {\n const newSessionId = uuidv4();\n const title = activeMode === 'deep-search' ? 'Deep Search' : 'New Chat';\n try {\n await createSession({ id: newSessionId, title });\n setActiveSessionId(newSessionId);\n setValue('');\n sendMessage(trimmedQuery, undefined, newSessionId);\n } catch (err) {\n console.error('[HomeScreen] Failed to create session:', err);\n }\n } else {\n setValue('');\n sendMessage(trimmedQuery);\n }\n },\n [\n canSubmit,\n isLoading,\n disabled,\n activeMode,\n trimmedQuery,\n activeSessionId,\n onSubmitProp,\n createSession,\n sendMessage,\n ],\n );\n\n const handleNewChat = useCallback(() => {\n setActiveSessionId(null);\n setValue('');\n }, []);\n\n useEffect(() => {\n navigation.setOptions({\n headerRight: () => (\n <Pressable\n onPress={handleNewChat}\n style={({ pressed }) => [styles.newChatButton, pressed && styles.newChatButtonPressed]}\n accessibilityLabel=\"New chat\"\n >\n <MaterialCommunityIcons name=\"chat-plus-outline\" size={26} color=\"#000\" />\n </Pressable>\n ),\n });\n }, [navigation, handleNewChat]);\n\n const handleSendMessage = useCallback(\n async (text: string) => {\n if (!text.trim() || isLoading || disabled) return;\n const submission: ModeSubmission = { mode: activeMode, query: text.trim() };\n if (activeMode === 'deep-search' && onSubmitProp) {\n onSubmitProp(submission);\n return;\n }\n if (!activeSessionId) {\n const newSessionId = uuidv4();\n const title = activeMode === 'deep-search' ? 'Deep Search' : 'New Chat';\n try {\n await createSession({ id: newSessionId, title });\n setActiveSessionId(newSessionId);\n sendMessage(text.trim(), undefined, newSessionId);\n } catch (err) {\n console.error('[HomeScreen] Failed to create session:', err);\n }\n } else {\n sendMessage(text.trim());\n }\n },\n [isLoading, disabled, activeSessionId, activeMode, onSubmitProp, createSession, sendMessage],\n );\n\n const leftItems = getDefaultLeftItems({\n search: {\n active: activeMode === 'chat',\n onClick: () => handleModeSwitch('chat'),\n },\n zap: {\n active: activeMode === 'deep-search',\n onClick: () => handleModeSwitch('deep-search'),\n },\n lightbulb: { enabled: false },\n });\n\n const rightItems = getDefaultRightItems({\n tag: { enabled: false },\n chip: { enabled: false },\n camera: { onClick: () => console.log('camera') },\n image: { onClick: () => console.log('image') },\n attach: { onClick: () => console.log('attach') },\n });\n\n return (\n <SafeAreaView style={{ flex: 1, backgroundColor: '#fff' }}>\n <Box flex={1} width=\"100%\">\n {chatError && (\n <Box mb=\"$2\" mx=\"$4\" p=\"$3\" bg=\"$gray200\" borderRadius=\"$md\">\n <Text fontSize=\"$sm\" color=\"$gray900\">\n {chatError}\n </Text>\n </Box>\n )}\n {hasMessages || response ? (\n <Box flex={1} width=\"100%\" alignSelf=\"stretch\">\n <MessagesContainerUI\n mode=\"plan\"\n showBackButton={false}\n onBackPress={handleNewChat}\n compactTop={true}\n messagesContainerStyle={{ paddingHorizontal: 0, paddingTop: 0, margin: 0 }}\n listContentStyle={{ paddingTop: 0, margin: 0 }}\n messages={messages.map((msg, index) => ({\n id: `msg-${index}-${msg.role}`,\n role: msg.role,\n content: msg.content,\n metadata: msg.metadata,\n }))}\n streamingContent={response}\n currentUser={{ id: 'user' }}\n onSend={handleSendMessage}\n disabled={isLoading || disabled}\n isLoading={isLoading}\n onStop={isStreaming ? cancel : onStop}\n renderPlanInputToolbar={({ value, onChange, onSend, disabled: inputDisabled }) => (\n <InputToolBar\n inputConfig={{\n value,\n onChange: (e) => onChange(e.nativeEvent.text),\n placeholder: inputPlaceholder,\n disabled: inputDisabled,\n }}\n leftItems={leftItems}\n rightItems={rightItems}\n templateButton={null}\n templateModalConfig={null}\n micSendButton={{\n hasContent: value.trim().length > 0,\n onSend: () => onSend(value.trim()),\n onMic: () => console.log('mic'),\n disabled: inputDisabled,\n isLoading,\n onStop: isStreaming ? cancel : onStop,\n }}\n />\n )}\n renderBuildInputToolbar={() => null}\n />\n </Box>\n ) : (\n <Box flex={1} justifyContent=\"center\" alignItems=\"stretch\" p=\"$4\">\n <InputToolBar\n inputConfig={{\n value,\n onChange: (e) => setValue(e.nativeEvent.text),\n placeholder: inputPlaceholder,\n disabled: isLoading || disabled,\n }}\n leftItems={leftItems}\n rightItems={rightItems}\n templateButton={null}\n templateModalConfig={null}\n micSendButton={{\n hasContent: canSubmit,\n onSend: () => handleSubmit(),\n onMic: () => console.log('mic'),\n disabled: isLoading || disabled,\n isLoading,\n onStop,\n }}\n />\n </Box>\n )}\n </Box>\n </SafeAreaView>\n );\n}\n\nconst styles = StyleSheet.create({\n newChatButton: {\n padding: 6,\n marginRight: 4,\n alignItems: 'center',\n justifyContent: 'center',\n },\n newChatButtonPressed: {\n opacity: 0.6,\n },\n});\n\nconst HomeScreen: FC<HomeScreenProps> = (props) => <HomeScreenContent {...props} />;\n\nexport default HomeScreen;\n"],"names":["uuidv4","value"],"mappings":";;;;;;;;;;;;;;;;AAoBA,SAAS,iBAAkB,CAAA;AAAA,EACzB,WAAc,GAAA,MAAA;AAAA,EACd,QAAU,EAAA,YAAA;AAAA,EACV,MAAA;AAAA,EACA,WAAW,aAAgB,GAAA,KAAA;AAAA,EAC3B,QAAW,GAAA;AACb,CAAoB,EAAA;AAClB,EAAA,MAAM,aAAa,aAAc,EAAA;AACjC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,EAAE,CAAA;AACrC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAsB,WAAW,CAAA;AACrE,EAAA,MAAM,CAAC,eAAA,EAAiB,kBAAkB,CAAA,GAAI,SAAwB,IAAI,CAAA;AAC1E,EAAM,MAAA;AAAA,IACJ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aAAe,EAAA;AAAA,IACb,OAAS,EAAA,CAAA;AAAA,IACT,WAAa,EAAA,CAAA;AAAA,IACb,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,oBAAsB,EAAA;AAAA,IACpB,OAAS,EAAA;AAAA;AAEb,CAAC,CAAA;AACD,MAAM,UAAkC,GAAA,CAAA,KAAA,qBAAU,GAAA,CAAA,iBAAA,EAAA,cAAA,CAAA,EAAA,EAAsB,KAAO,CAAA"}
@@ -0,0 +1 @@
1
+ import HomeScreen from'./HomeScreen.js';export{HomeScreen as default};//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@adminide-stack/yantra-mobile",
3
+ "version": "12.0.21-alpha.84",
4
+ "description": "Sample core for higher packages to depend on",
5
+ "license": "ISC",
6
+ "author": "CDMBase LLC",
7
+ "type": "module",
8
+ "main": "lib/index.js",
9
+ "module": "lib/index.js",
10
+ "typings": "lib/index.d.ts",
11
+ "scripts": {
12
+ "build": "yarn build:clean && yarn build:lib",
13
+ "build:clean": "rimraf lib",
14
+ "build:lib": "rollup -c rollup.config.mjs",
15
+ "build:lib:watch": "yarn build:lib -- --watch",
16
+ "jest": "./node_modules/.bin/jest",
17
+ "prepublish": "yarn build",
18
+ "test": "jest",
19
+ "test:debug": "npm test -- --runInBand",
20
+ "test:watch": "npm test -- --watch",
21
+ "watch": "yarn build:lib:watch",
22
+ "watch-ts": "tsc --watch"
23
+ },
24
+ "dependencies": {
25
+ "uuid": "^9.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "common": "12.0.21-alpha.67"
29
+ },
30
+ "peerDependencies": {
31
+ "@admin-layout/gluestack-ui-mobile": "*",
32
+ "@adminide-stack/core": "*",
33
+ "@apollo/client": "*",
34
+ "@cdm-logger/client": "*",
35
+ "@common-stack/client-core": "*",
36
+ "@common-stack/client-react": "*",
37
+ "@common-stack/core": "*",
38
+ "@expo/vector-icons": "*",
39
+ "@messenger-box/platform-mobile": "*",
40
+ "lodash": "*"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "typescript": {
46
+ "definition": "lib/index.d.ts"
47
+ },
48
+ "gitHead": "82173225a15325cede457f33cef82ad275c6da73"
49
+ }