@aintela/chat 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +3 -3
  2. package/dist/Memory-BUnmYGNv.js +37 -0
  3. package/dist/Memory-BUnmYGNv.js.map +1 -0
  4. package/dist/components.js +4855 -4618
  5. package/dist/components.js.map +1 -1
  6. package/dist/detachedRunModel-1ii9qGTW.js +50 -0
  7. package/dist/detachedRunModel-1ii9qGTW.js.map +1 -0
  8. package/dist/hooks.js +1 -1
  9. package/dist/{httpArtifactService-EEhF_mp9.js → httpArtifactService-DYQDPVVH.js} +61 -61
  10. package/dist/httpArtifactService-DYQDPVVH.js.map +1 -0
  11. package/dist/{httpSessionService-wBby4ggl.js → httpSessionService-BY7JeW8d.js} +2 -2
  12. package/dist/{httpSessionService-wBby4ggl.js.map → httpSessionService-BY7JeW8d.js.map} +1 -1
  13. package/dist/index.js +252 -246
  14. package/dist/models.js +35 -34
  15. package/dist/{serializer-CC-nM3ig.js → serializer-BNsp8xs2.js} +161 -161
  16. package/dist/serializer-BNsp8xs2.js.map +1 -0
  17. package/dist/services.js +2 -2
  18. package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.d.ts +1 -1
  19. package/dist/src/components/AiChat/ChatPane/verbosity.d.ts +8 -1
  20. package/dist/src/components/AiChat/ChatPane/verbosityContentTools.test.d.ts +1 -0
  21. package/dist/src/components/AiChat/index.d.ts +1 -1
  22. package/dist/src/components/AiChat/stateConfiguration.d.ts +5 -5
  23. package/dist/src/components/index.d.ts +2 -2
  24. package/dist/src/components/v2/{SubAgentBoxV2.d.ts → DetachedRunBoxV2.d.ts} +6 -6
  25. package/dist/src/components/v2/DetachedRunTaskBox.d.ts +43 -0
  26. package/dist/src/components/v2/DetachedRunTaskBox.test.d.ts +1 -0
  27. package/dist/src/components/v2/index.d.ts +4 -2
  28. package/dist/src/components/v2/toolCategories.d.ts +1 -1
  29. package/dist/src/models/ServerEvent.d.ts +3 -3
  30. package/dist/src/models/detachedRunModel.d.ts +48 -0
  31. package/dist/src/models/detachedRunModel.test.d.ts +1 -0
  32. package/dist/src/models/index.d.ts +2 -2
  33. package/dist/src/models/semanticKernelModel/models.d.ts +5 -5
  34. package/dist/src/services/WebSocketConnection/streamStats.d.ts +2 -2
  35. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +5 -5
  36. package/dist/src/services/wire/decodeFrame.d.ts +1 -1
  37. package/dist/tests/fixtures.d.ts +8 -8
  38. package/dist/{useChatSessions-C6sYF4U6.js → useChatSessions-Q41Jmr6P.js} +2 -2
  39. package/dist/{useChatSessions-C6sYF4U6.js.map → useChatSessions-Q41Jmr6P.js.map} +1 -1
  40. package/package.json +1 -1
  41. package/dist/ClientMessage-DUby3KyC.js +0 -34
  42. package/dist/ClientMessage-DUby3KyC.js.map +0 -1
  43. package/dist/Memory-CjrYSkzB.js +0 -47
  44. package/dist/Memory-CjrYSkzB.js.map +0 -1
  45. package/dist/httpArtifactService-EEhF_mp9.js.map +0 -1
  46. package/dist/serializer-CC-nM3ig.js.map +0 -1
  47. package/dist/src/models/subAgentModel.d.ts +0 -48
@@ -18,8 +18,8 @@ export * from './enums';
18
18
  export type { Artifact } from './Artifact';
19
19
  export type { ArtifactData } from './ArtifactData';
20
20
  export type { TodoList, TodoItem, TodoItemStatus } from './todoListModel';
21
- export type { SubAgentDto, SubAgentMessage, SubAgentStatus } from './subAgentModel';
22
- export { isSubAgentTerminalStatus, SUB_AGENT_TERMINAL_STATUSES } from './subAgentModel';
21
+ export type { DetachedRunView, DetachedRunStatus, DetachedRunStopReason } from './detachedRunModel';
22
+ export { isDetachedRunTerminalStatus, isDetachedRunWaitingForInput, DETACHED_RUN_TERMINAL_STATUSES } from './detachedRunModel';
23
23
  export type { SendMessageResponse, StartStreamResponse, ServerSendMessageResponse } from './SendMessageResponse';
24
24
  export type { Prompt as PromptModel } from './Prompt';
25
25
  export { PromptUtils } from './Prompt';
@@ -180,8 +180,8 @@ export declare class LlmEvent {
180
180
  command?: Commands;
181
181
  content?: ChatMessageContent;
182
182
  streamingParts?: StreamingKernelContent[];
183
- subAgentId?: string;
184
- subAgentName?: string;
183
+ detachedRunId?: string;
184
+ detachedRunName?: string;
185
185
  text?: string;
186
186
  }
187
187
  export declare class PartialLlmEvent {
@@ -194,7 +194,7 @@ export declare class PartialLlmEvent {
194
194
  type?: string;
195
195
  iteractionId?: string;
196
196
  partialEventType?: EventTypeInformation;
197
- subAgentId?: string;
197
+ detachedRunId?: string;
198
198
  }
199
199
  export declare class StreamingResponse {
200
200
  type: string;
@@ -208,8 +208,8 @@ export declare class StreamingResponse {
208
208
  */
209
209
  accessToken?: string;
210
210
  partialEvent?: PartialLlmEvent;
211
- subAgentId?: string;
212
- subAgentName?: string;
211
+ detachedRunId?: string;
212
+ detachedRunName?: string;
213
213
  /**
214
214
  * Server-assigned monotonic sequence number for events emitted by an InteractionRun.
215
215
  * Tracked client-side as `lastSeq` so reconnects can resume mid-stream via
@@ -29,13 +29,13 @@ export declare class StreamStatsTracker {
29
29
  resetForInteraction(): void;
30
30
  /**
31
31
  * Account for one decoded frame. `sessionInformation` is only read off main-agent
32
- * frames — a sub-agent's reading describes a different session.
32
+ * frames — a detached run's reading describes a different session.
33
33
  */
34
34
  record(opts: {
35
35
  rawLength: number;
36
36
  textLength: number;
37
37
  sessionInformation?: SessionInformation;
38
- fromSubAgent: boolean;
38
+ fromDetachedRun: boolean;
39
39
  }): void;
40
40
  private flushCoalesced;
41
41
  }
@@ -118,19 +118,19 @@ export declare class AgentGatewayWSAsync {
118
118
  protected updateMap(serverEvent: ServerEvent): Interaction | undefined;
119
119
  protected getNewInteractionId(): string;
120
120
  Message(event: MessageEvent | ServerEvent): Promise<void>;
121
- protected subAgentInteractions: Map<string, Interaction>;
122
- protected subAgentInteractionServices: Map<string, InteractionService>;
123
- protected getOrCreateSubAgentInteraction(subAgentId: string, interactionId: string, subAgentName?: string): {
121
+ protected detachedRunInteractions: Map<string, Interaction>;
122
+ protected detachedRunInteractionServices: Map<string, InteractionService>;
123
+ protected getOrCreateDetachedRunInteraction(detachedRunId: string, interactionId: string, detachedRunName?: string): {
124
124
  interaction: Interaction;
125
125
  service: InteractionService;
126
126
  };
127
- protected handleSubAgentEvent(serverEvent: ServerEvent): void;
127
+ protected handleDetachedRunEvent(serverEvent: ServerEvent): void;
128
128
  protected localEmitToolEvent(toolDetails: ToolEventDetails): void;
129
129
  protected registerInteractionCallId(interactionId: string, options?: GatewaySendMessageOptions): void;
130
130
  protected localEmitFirstToken(interactionId: string): void;
131
131
  protected localEmitMessage(message: Interaction): void;
132
132
  protected localOpen(interactionId: string, _author: string): void;
133
- protected turnComplete(interactionId: string, agentInteraction: Interaction, _author: string, subAgentId?: string): Promise<void>;
133
+ protected turnComplete(interactionId: string, agentInteraction: Interaction, _author: string, detachedRunId?: string): Promise<void>;
134
134
  runningRequests: Map<string, Promise<Artifact | null>>;
135
135
  asyncLoadArtifact(artifactId: string): Promise<Artifact | null>;
136
136
  /**
@@ -13,7 +13,7 @@ export declare function llmEventFromPartial(pe: PartialLlmEvent): LlmEvent;
13
13
  /**
14
14
  * The LlmEvent carried by a frame, whichever form it took — the full `event`,
15
15
  * or the narrowed `pe` widened back. Control frames (Pong, Suspended,
16
- * RewindLost without a payload) yield nothing. The envelope's sub-agent identity
16
+ * RewindLost without a payload) yield nothing. The envelope's detached run identity
17
17
  * is stamped onto the event so the gateway can route it.
18
18
  */
19
19
  export declare function llmEventFromFrame(frame: StreamingResponse): LlmEvent | undefined;
@@ -35,17 +35,17 @@ export declare function serverEvent(opts: {
35
35
  asyncFinalResponse?: boolean;
36
36
  author?: 'main' | 'tool' | 'system';
37
37
  llmArtifacts?: LlmArtifact[];
38
- subAgentId?: string;
39
- subAgentName?: string;
38
+ detachedRunId?: string;
39
+ detachedRunName?: string;
40
40
  }): ServerEventType;
41
41
  /**
42
- * A sub-agent text event. Same shape as `partialTextEvent` but carries
43
- * the `subAgentId` / `subAgentName` that routes the event through
44
- * `handleSubAgentEvent` (separate Interaction tree from the main turn).
42
+ * A detached run text event. Same shape as `partialTextEvent` but carries
43
+ * the `detachedRunId` / `detachedRunName` that routes the event through
44
+ * `handleDetachedRunEvent` (separate Interaction tree from the main turn).
45
45
  */
46
- export declare function subAgentTextEvent(interactionId: string, opts: {
47
- subAgentId: string;
48
- subAgentName?: string;
46
+ export declare function detachedRunTextEvent(interactionId: string, opts: {
47
+ detachedRunId: string;
48
+ detachedRunName?: string;
49
49
  text: string;
50
50
  partial?: boolean;
51
51
  turn_complete?: boolean;
@@ -1,7 +1,7 @@
1
1
  var L = Object.defineProperty;
2
2
  var d = (e, t) => L(e, "name", { value: t, configurable: !0 });
3
3
  import { useMemo as h, useState as v, useCallback as g, useEffect as C } from "react";
4
- import { H } from "./httpSessionService-wBby4ggl.js";
4
+ import { H } from "./httpSessionService-BY7JeW8d.js";
5
5
  const w = 6e4, y = 60 * w, l = 24 * y;
6
6
  function k(e) {
7
7
  if (!e) return;
@@ -104,4 +104,4 @@ d(Y, "useChatSessions");
104
104
  export {
105
105
  Y as u
106
106
  };
107
- //# sourceMappingURL=useChatSessions-C6sYF4U6.js.map
107
+ //# sourceMappingURL=useChatSessions-Q41Jmr6P.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChatSessions-C6sYF4U6.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,OAAO,MAAMC,EAAE,QAAA,CAAS,IAAI,SAAYA;AACnD;AALSC,EAAAH,GAAA;AAOT,SAASI,EAAgBC,GAAgC;AACrD,MAAI,CAACA,EAAM,QAAO;AAClB,QAAMC,IAAO,KAAK,IAAA,IAAQD,EAAK,QAAA;AAC/B,SAAIC,IAAOT,IAAkB,QACzBS,IAAOR,IAAgB,GAAG,KAAK,MAAMQ,IAAOT,CAAS,CAAC,MACtDS,IAAOP,IAAe,GAAG,KAAK,MAAMO,IAAOR,CAAO,CAAC,MACnDQ,IAAO,IAAIP,IAAe,GAAG,KAAK,MAAMO,IAAOP,CAAM,CAAC,MACnDM,EAAK,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,WAAW;AAChF;AARSF,EAAAC,GAAA;AAUT,SAASG,IAAqB;AAC1B,QAAML,wBAAQ,KAAA;AACd,SAAAA,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACdA;AACX;AAJSC,EAAAI,GAAA;AAMT,SAASC,EAAYC,GAAkD;AACnE,QAAMC,IAAQH,EAAA,GACRI,IAAY,IAAI,KAAKD,EAAM,QAAA,IAAYX,CAAM,GAC7Ca,IAAU,IAAI,KAAKF,EAAM,QAAA,IAAY,IAAIX,CAAM,GAC/Cc,IAAW,IAAI,KAAKH,EAAM,QAAA,IAAY,KAAKX,CAAM,GAGjDe,IAAkD;AAAA,IACpD,CAAC,SAAS,CAAA,CAAE;AAAA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IAAQiB;AAAA,IACV,MAAMe,EAAO,IAAI,OAAKtB,EAAUwB,GAAGtB,CAAQ,CAAC;AAAA,IAC5C,CAACoB,GAAQpB,CAAQ;AAAA,EAAA,GAGfwB,IAASnB,EAAQ,MAAMlB,EAAYC,CAAK,GAAG,CAACA,CAAK,CAAC,GAElDqC,IAASR,EAAY,OAAOS,GAAYC,MAAkB;AAC5D,IAAAjB;AAAA,MAAY,CAAAkB,MACRA,EAAQ,IAAI,CAAAN,MAAMA,EAAE,OAAOI,IAAK,EAAE,GAAGJ,GAAG,UAAUK,EAAA,IAAUL,CAAE;AAAA,IAAA;AAElE,QAAI;AACA,YAAMf,EAAe,aAAamB,GAAI,EAAE,UAAUC,GAAO;AAAA,IAC7D,SAAST,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC,GAEtBa,IAASZ,EAAY,OAAOS,MAAe;AAC7C,IAAAhB,EAAY,OAAWkB,EAAQ,OAAO,OAAKN,EAAE,OAAOI,CAAE,CAAC;AACvD,QAAI;AACA,YAAMnB,EAAe,cAAcmB,CAAE;AAAA,IACzC,SAASR,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC;AAE5B,SAAO,EAAE,UAAUI,GAAQ,QAAAI,GAAQ,WAAAZ,GAAW,OAAAE,GAAO,SAAAE,GAAS,QAAAS,GAAQ,QAAAI,EAAA;AAC1E;AAtEgB/C,EAAAoB,GAAA;"}
1
+ {"version":3,"file":"useChatSessions-Q41Jmr6P.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,OAAO,MAAMC,EAAE,QAAA,CAAS,IAAI,SAAYA;AACnD;AALSC,EAAAH,GAAA;AAOT,SAASI,EAAgBC,GAAgC;AACrD,MAAI,CAACA,EAAM,QAAO;AAClB,QAAMC,IAAO,KAAK,IAAA,IAAQD,EAAK,QAAA;AAC/B,SAAIC,IAAOT,IAAkB,QACzBS,IAAOR,IAAgB,GAAG,KAAK,MAAMQ,IAAOT,CAAS,CAAC,MACtDS,IAAOP,IAAe,GAAG,KAAK,MAAMO,IAAOR,CAAO,CAAC,MACnDQ,IAAO,IAAIP,IAAe,GAAG,KAAK,MAAMO,IAAOP,CAAM,CAAC,MACnDM,EAAK,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,WAAW;AAChF;AARSF,EAAAC,GAAA;AAUT,SAASG,IAAqB;AAC1B,QAAML,wBAAQ,KAAA;AACd,SAAAA,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACdA;AACX;AAJSC,EAAAI,GAAA;AAMT,SAASC,EAAYC,GAAkD;AACnE,QAAMC,IAAQH,EAAA,GACRI,IAAY,IAA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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aintela/chat",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,34 +0,0 @@
1
- var m = Object.defineProperty;
2
- var c = (a, s, i) => s in a ? m(a, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[s] = i;
3
- var r = (a, s) => m(a, "name", { value: s, configurable: !0 });
4
- var e = (a, s, i) => c(a, typeof s != "symbol" ? s + "" : s, i);
5
- const t = class t {
6
- constructor(s, i, d, f, y) {
7
- e(this, "mimeType");
8
- e(this, "data");
9
- e(this, "friendlyMessage");
10
- e(this, "fake");
11
- /**
12
- * Optional image attachments that travel as a structured payload
13
- * on the WS frame (see `IMessage.Images`). Kept separate from
14
- * `data` so we don't have to encode them into the text body — the
15
- * server adds them as `ImageContent` entries on the user turn.
16
- */
17
- e(this, "images");
18
- /**
19
- * Optional client-only UI representation for this user turn. Carried to the
20
- * server as a `UserUiContent` sibling (persisted + replayed) but stripped from
21
- * every model request — `data` stays the only model-facing text. `args` is a
22
- * serialized JSON string. The gateway also injects a matching `UserAnswer` part
23
- * on the live interaction so the component renders immediately.
24
- */
25
- e(this, "userUi");
26
- this.data = s, this.mimeType = i, this.friendlyMessage = f, this.fake = d, this.images = y;
27
- }
28
- };
29
- r(t, "ClientMessage");
30
- let h = t;
31
- export {
32
- h as C
33
- };
34
- //# sourceMappingURL=ClientMessage-DUby3KyC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClientMessage-DUby3KyC.js","sources":["../src/models/ClientMessage.ts"],"sourcesContent":["/**\n * A single image attachment carried alongside a ClientMessage. `data`\n * is the raw base64 payload (no `data:<mime>;base64,` prefix) so the\n * server can `Convert.FromBase64String` directly into bytes.\n */\nexport interface ClientMessageImage {\n mimeType: string;\n data: string;\n}\n\nexport class ClientMessage {\n mimeType: string;\n data: string;\n friendlyMessage?: string;\n fake?: boolean;\n /**\n * Optional image attachments that travel as a structured payload\n * on the WS frame (see `IMessage.Images`). Kept separate from\n * `data` so we don't have to encode them into the text body — the\n * server adds them as `ImageContent` entries on the user turn.\n */\n images?: ClientMessageImage[];\n\n /**\n * Optional client-only UI representation for this user turn. Carried to the\n * server as a `UserUiContent` sibling (persisted + replayed) but stripped from\n * every model request — `data` stays the only model-facing text. `args` is a\n * serialized JSON string. The gateway also injects a matching `UserAnswer` part\n * on the live interaction so the component renders immediately.\n */\n userUi?: { name: string; args?: string };\n\n constructor(data: string, mimeType: string, fake?: boolean, friendlyMessage?: string, images?: ClientMessageImage[]) {\n this.data = data;\n this.mimeType = mimeType;\n this.friendlyMessage = friendlyMessage;\n this.fake = fake;\n this.images = images;\n }\n}"],"names":["_ClientMessage","data","mimeType","fake","friendlyMessage","images","__publicField","__name","ClientMessage"],"mappings":";;;;AAUO,MAAMA,IAAN,MAAMA,EAAc;AAAA,EAsBzB,YAAYC,GAAcC,GAAkBC,GAAgBC,GAA0BC,GAA+B;AArBrH,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,EAAA;AASA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,EAAA;AAGE,SAAK,OAAOL,GACZ,KAAK,WAAWC,GAChB,KAAK,kBAAkBE,GACvB,KAAK,OAAOD,GACZ,KAAK,SAASE;AAAA,EAChB;AACF;AA7B2BE,EAAAP,GAAA;AAApB,IAAMQ,IAANR;"}
@@ -1,47 +0,0 @@
1
- var b = Object.defineProperty;
2
- var g = (a, i, r) => i in a ? b(a, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[i] = r;
3
- var s = (a, i) => b(a, "name", { value: i, configurable: !0 });
4
- var e = (a, i, r) => g(a, typeof i != "symbol" ? i + "" : i, r);
5
- const n = class n {
6
- constructor(i, r) {
7
- e(this, "id");
8
- e(this, "biName");
9
- this.id = i, this.biName = r;
10
- }
11
- getBiName() {
12
- return `BI_${this.biName}`;
13
- }
14
- };
15
- s(n, "Account");
16
- let l = n;
17
- const t = {
18
- ExplorerAgent: "ExplorerAgent",
19
- DashboardAgent: "DashboardAgent",
20
- Unknown: "Unknown"
21
- }, d = [
22
- "Completed",
23
- "Failed",
24
- "Cancelled"
25
- ];
26
- function u(a) {
27
- return a ? d.includes(a) : !1;
28
- }
29
- s(u, "isSubAgentTerminalStatus");
30
- var h = /* @__PURE__ */ ((a) => (a[a.Table = 0] = "Table", a[a.Metric = 1] = "Metric", a[a.Chart = 2] = "Chart", a[a.Dashboards = 3] = "Dashboards", a[a.Suggestions = 4] = "Suggestions", a[a.Memory = 5] = "Memory", a))(h || {});
31
- const c = {
32
- 0: "Table",
33
- 1: "Metric",
34
- 2: "Chart",
35
- 3: "Dashboards",
36
- 4: "Suggestions",
37
- 5: "Memory"
38
- };
39
- export {
40
- l as A,
41
- c as M,
42
- d as S,
43
- t as a,
44
- h as b,
45
- u as i
46
- };
47
- //# sourceMappingURL=Memory-CjrYSkzB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Memory-CjrYSkzB.js","sources":["../src/models/contexts.ts","../src/models/Agent.ts","../src/models/subAgentModel.ts","../src/models/Memory.ts"],"sourcesContent":["import type { Customer } from \"./Customer\";\nimport type { Agent } from \"./Agent\";\nimport { type IDBStorable } from \"./IDBStorable\";\n\nexport class Account {\n id: string;\n biName: string;\n\n constructor(id: string, biName: string) {\n this.id = id;\n this.biName = biName;\n }\n\n getBiName() {\n return `BI_${this.biName}`;\n }\n}\n\nexport interface User extends IDBStorable {\n email: string;\n family_name: string;\n given_name: string;\n name: string;\n hd: string;\n picture: string;\n access_token: string;\n previous_access_token?: string;\n refresh_token?: string;\n account?: Account;\n}\n\nexport interface AuthState {\n isAuthenticated: boolean;\n isLoading: boolean;\n login: (userData: User) => void;\n logout: () => void;\n errorMessage: string | null;\n}\n\nexport interface AgentContext {\n agentConfig: Partial<Agent>;\n customer?: Customer;\n model?: string;\n}\n","export type AgentKind = 'ExplorerAgent' | 'DashboardAgent' | 'Unknown';\nexport const AgentKind = {\n ExplorerAgent: 'ExplorerAgent' as AgentKind,\n DashboardAgent: 'DashboardAgent' as AgentKind,\n Unknown: 'Unknown' as AgentKind,\n} as const;\n\n/**\n * Agent model - represents an AI agent configuration\n * Mirrors the .NET Agent entity in Envision.SemanticKernel.Models.Agent\n */\nexport interface Agent {\n id: string;\n name: string;\n type?: AgentKind;\n defaultModelId?: string;\n defaultQuickModelId?: string;\n description?: string;\n muiIconName?: string;\n embeddingConfigurationId: string;\n agentImplementation?: string;\n agentBootStrapImplementation?: string;\n parameters?: Record<string, string>;\n plugins: string[];\n /** List of additional main instruction IDs (Category: Main or Generic) for this agent */\n mainInstructionIds?: string[];\n lastUpdated?: Date;\n created?: Date;\n}\n\n/**\n * Partial agent for listing purposes (only essential fields)\n */\nexport type AgentSummary = Pick<Agent, 'id' | 'name' | 'description' | 'muiIconName' | 'type'>;\n","import type { TodoList } from './todoListModel';\n\n/**\n * Mirrors `Envision.SemanticKernel.Core.SubAgent.SubAgentStatus` enum on the\n * server. Values come back as plain strings (the controller uses `Status.ToString()`).\n */\nexport type SubAgentStatus =\n | 'Pending'\n | 'Running'\n | 'Completed'\n | 'Failed'\n | 'Cancelled'\n | 'Unknown';\n\n/**\n * Lightweight representation of a chat message embedded in the SubAgentDto.\n * The server-side `Message` type carries more fields, but only the basics are\n * needed for status polling on the client.\n */\nexport interface SubAgentMessage {\n id?: string;\n role?: string;\n content?: string;\n [key: string]: unknown;\n}\n\n/**\n * TypeScript counterpart of `Envision.SemanticKernel.Core.SubAgent.SubAgentDto`.\n *\n * This is the payload returned by `GET /SubAgent/{sessionId}/{id}`.\n *\n * `TodoList.percentComplete` is serialized by the server as a fraction in the\n * range `[0, 1]` (i.e. `completedItems / totalItems`). It can be `NaN` when the\n * todo list is empty, so consumers should guard against non-finite values.\n */\nexport interface SubAgentDto {\n id?: string;\n subAgentId: string;\n name: string;\n sessionId?: string;\n dashboardId?: string | null;\n todoList?: TodoList | null;\n generalInstructions?: string | null;\n dashboardInstructions?: string | null;\n detailedStatus?: string | null;\n status: SubAgentStatus | string;\n error?: string | null;\n hasResult?: boolean | null;\n finalSummary?: string | null;\n parameters?: Record<string, string> | null;\n updatedAt?: string | Date | null;\n created?: string | Date | null;\n message?: SubAgentMessage | null;\n}\n\n/** Status values that indicate the sub-agent is no longer making progress. */\nexport const SUB_AGENT_TERMINAL_STATUSES: ReadonlyArray<SubAgentStatus> = [\n 'Completed',\n 'Failed',\n 'Cancelled',\n];\n\nexport function isSubAgentTerminalStatus(status: string | undefined | null): boolean {\n if (!status) return false;\n return (SUB_AGENT_TERMINAL_STATUSES as readonly string[]).includes(status);\n}\n","/**\n * Memory model - represents a semantic memory stored in MongoDB and Qdrant\n * Mirrors the .NET Memory entity in Envision.SemanticKernel.Core/Memory/Memory.cs\n */\n\n/**\n * Context types for memories - determines how they're filtered in semantic search\n */\nexport enum MemoryContexts {\n Table = 0, // Table schema information\n Metric = 1, // Business metrics and KPIs\n Chart = 2, // Chart/visualization descriptions\n Dashboards = 3, // Dashboard information\n Suggestions = 4, // Business recommendations\n Memory = 5 // General memories (no filter applied in search)\n}\n\n/**\n * Human-readable labels for each context type\n */\nexport const MemoryContextLabels: Record<MemoryContexts, string> = {\n [MemoryContexts.Table]: 'Table',\n [MemoryContexts.Metric]: 'Metric',\n [MemoryContexts.Chart]: 'Chart',\n [MemoryContexts.Dashboards]: 'Dashboards',\n [MemoryContexts.Suggestions]: 'Suggestions',\n [MemoryContexts.Memory]: 'Memory',\n};\n\n/**\n * Full Memory entity as stored in the database\n */\nexport interface SemanticMemory {\n id: string;\n memoryText: string;\n relatedTags?: string;\n created?: string;\n updatedAt?: string;\n // Runtime properties (populated by search results only)\n runtimeScore?: number;\n runtimeRank?: number;\n}\n\n/**\n * Input model for creating/updating memories\n * Does not include id, created, or runtime properties\n */\nexport interface SemanticMemoryInput {\n memoryText: string;\n relatedTags?: string;\n}\n\n/**\n * Options for semantic search\n */\nexport interface SemanticMemorySearchOptions {\n relatedTable?: string;\n relatedContext?: MemoryContexts;\n relatedTags?: string;\n limit?: number;\n}\n"],"names":["_Account","id","biName","__publicField","__name","Account","AgentKind","SUB_AGENT_TERMINAL_STATUSES","isSubAgentTerminalStatus","status","MemoryContexts","MemoryContextLabels"],"mappings":";;;;AAIO,MAAMA,IAAN,MAAMA,EAAQ;AAAA,EAIjB,YAAYC,GAAYC,GAAgB;AAHxC,IAAAC,EAAA;AACA,IAAAA,EAAA;AAGI,SAAK,KAAKF,GACV,KAAK,SAASC;AAAA,EAClB;AAAA,EAEA,YAAY;AACR,WAAO,MAAM,KAAK,MAAM;AAAA,EAC5B;AACJ;AAZqBE,EAAAJ,GAAA;AAAd,IAAMK,IAANL;ACHA,MAAMM,IAAY;AAAA,EACrB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,SAAS;AACb,GCmDaC,IAA6D;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACJ;AAEO,SAASC,EAAyBC,GAA4C;AACjF,SAAKA,IACGF,EAAkD,SAASE,CAAM,IADrD;AAExB;AAHgBL,EAAAI,GAAA;ACtDT,IAAKE,sBAAAA,OACRA,EAAAA,EAAA,QAAQ,CAAA,IAAR,SACAA,EAAAA,EAAA,SAAS,CAAA,IAAT,UACAA,EAAAA,EAAA,QAAQ,CAAA,IAAR,SACAA,EAAAA,EAAA,aAAa,CAAA,IAAb,cACAA,EAAAA,EAAA,cAAc,CAAA,IAAd,eACAA,EAAAA,EAAA,SAAS,CAAA,IAAT,UANQA,IAAAA,KAAA,CAAA,CAAA;AAYL,MAAMC,IAAsD;AAAA,EAC9D,GAAuB;AAAA,EACvB,GAAwB;AAAA,EACxB,GAAuB;AAAA,EACvB,GAA4B;AAAA,EAC5B,GAA6B;AAAA,EAC7B,GAAwB;AAC7B;"}