@aintela/chat 0.6.0 → 0.8.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 (71) hide show
  1. package/README.md +43 -0
  2. package/dist/components.js +9004 -7708
  3. package/dist/components.js.map +1 -1
  4. package/dist/{httpArtifactService-DYQDPVVH.js → detachedRunActivity-RNg1JDDW.js} +799 -334
  5. package/dist/detachedRunActivity-RNg1JDDW.js.map +1 -0
  6. package/dist/detachedRunModel-X59Pb5V-.js +67 -0
  7. package/dist/{detachedRunModel-1ii9qGTW.js.map → detachedRunModel-X59Pb5V-.js.map} +1 -1
  8. package/dist/hooks.js +1 -1
  9. package/dist/httpSessionService-DLdoBZRW.js +320 -0
  10. package/dist/httpSessionService-DLdoBZRW.js.map +1 -0
  11. package/dist/index.js +325 -275
  12. package/dist/models.js +47 -41
  13. package/dist/{serializer-BNsp8xs2.js → serializer-DvR3nOcf.js} +781 -652
  14. package/dist/serializer-DvR3nOcf.js.map +1 -0
  15. package/dist/services.js +22 -15
  16. package/dist/src/components/AgentTeam/BillingLimitBanner.d.ts +7 -0
  17. package/dist/src/components/AgentTeam/ChatAgentHeader.d.ts +34 -0
  18. package/dist/src/components/AgentTeam/HandoffDivider.d.ts +13 -0
  19. package/dist/src/components/AgentTeam/PersonaAvatar.d.ts +20 -0
  20. package/dist/src/components/AgentTeam/__tests__/agentTeam.test.d.ts +0 -0
  21. package/dist/src/components/AgentTeam/__tests__/billingLimit.test.d.ts +0 -0
  22. package/dist/src/components/AgentTeam/__tests__/messagePersona.test.d.ts +0 -0
  23. package/dist/src/components/AgentTeam/agentRoles.d.ts +33 -0
  24. package/dist/src/components/AgentTeam/chatAgent.d.ts +24 -0
  25. package/dist/src/components/AgentTeam/index.d.ts +7 -0
  26. package/dist/src/components/AgentTeam/personas.d.ts +60 -0
  27. package/dist/src/components/AiChat/AiChatContext.d.ts +9 -1
  28. package/dist/src/components/AiChat/AiChatTypes.d.ts +17 -1
  29. package/dist/src/components/AiChat/ChatPane/InteractionOriginBadge.d.ts +15 -0
  30. package/dist/src/components/AiChat/ChatPane/messageUserOrigin.test.d.ts +1 -0
  31. package/dist/src/components/AiChat/aiChatEngine.d.ts +13 -1
  32. package/dist/src/components/AiChat/stateConfiguration.d.ts +7 -0
  33. package/dist/src/components/index.d.ts +3 -0
  34. package/dist/src/components/v2/DetachedRunTaskBox.d.ts +30 -5
  35. package/dist/src/components/v2/DetachedRunTaskBox.live.test.d.ts +1 -0
  36. package/dist/src/components/v2/DetachedRunTranscript.d.ts +89 -0
  37. package/dist/src/components/v2/DetachedRunTranscript.test.d.ts +1 -0
  38. package/dist/src/components/v2/index.d.ts +5 -0
  39. package/dist/src/components/v2/useDetachedRunLiveActivity.d.ts +30 -0
  40. package/dist/src/components/v2/useDetachedRunResumeKey.d.ts +15 -0
  41. package/dist/src/components/v2/useDetachedRunResumeKey.test.d.ts +1 -0
  42. package/dist/src/models/Interaction.d.ts +26 -0
  43. package/dist/src/models/ServerEvent.d.ts +3 -0
  44. package/dist/src/models/billingLimit.d.ts +23 -0
  45. package/dist/src/models/detachedRunModel.d.ts +11 -0
  46. package/dist/src/models/enums.d.ts +3 -1
  47. package/dist/src/models/index.d.ts +5 -3
  48. package/dist/src/models/semanticKernelModel/models.d.ts +40 -1
  49. package/dist/src/services/WebSocketConnection/WebSocketConnectionV2.d.ts +4 -1
  50. package/dist/src/services/WebSocketConnection/webSocketConnection.d.ts +18 -2
  51. package/dist/src/services/detachedRun/DetachedRunFramesTransport.d.ts +68 -0
  52. package/dist/src/services/detachedRun/DetachedRunFramesTransport.test.d.ts +1 -0
  53. package/dist/src/services/detachedRun/detachedRunActivity.d.ts +25 -0
  54. package/dist/src/services/detachedRun/streamDetachedRunFrames.d.ts +110 -0
  55. package/dist/src/services/detachedRun/streamDetachedRunFrames.test.d.ts +1 -0
  56. package/dist/src/services/index.d.ts +7 -0
  57. package/dist/src/services/servers/AgentGatewayService.d.ts +1 -1
  58. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +67 -1
  59. package/dist/src/services/servers/gatewayAnnounceDetachedRun.test.d.ts +1 -0
  60. package/dist/src/services/servers/gatewayInteractionStarted.test.d.ts +1 -0
  61. package/dist/src/services/wire/decodeFrame.d.ts +6 -1
  62. package/dist/tests/fakes/fakeWebSocket.d.ts +8 -2
  63. package/dist/tests/fakes/makeGateway.d.ts +3 -1
  64. package/dist/{useChatSessions-Q41Jmr6P.js → useChatSessions-DwqgYo79.js} +2 -2
  65. package/dist/{useChatSessions-Q41Jmr6P.js.map → useChatSessions-DwqgYo79.js.map} +1 -1
  66. package/package.json +1 -1
  67. package/dist/detachedRunModel-1ii9qGTW.js +0 -50
  68. package/dist/httpArtifactService-DYQDPVVH.js.map +0 -1
  69. package/dist/httpSessionService-BY7JeW8d.js +0 -309
  70. package/dist/httpSessionService-BY7JeW8d.js.map +0 -1
  71. package/dist/serializer-BNsp8xs2.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { BillingLimitNotice } from '../../models/billingLimit';
1
2
  import { ComponentType, ReactNode } from 'react';
2
3
  import { AgentGatewayService } from '../../services/servers/AgentGatewayService';
3
4
  import { EventBusService } from '../../services/eventBusService';
@@ -8,7 +9,7 @@ import { INotificationPort } from '../../interfaces/INotificationPort';
8
9
  import { AiChatState, AiChatStore } from './stateConfiguration';
9
10
  import { SessionStateManagerService } from './sessionStateManagerService';
10
11
  import { PartRendererMap, UiToolRegistry } from './ChatPane/parts';
11
- import { Interaction } from '../../models/Interaction';
12
+ import { Interaction, InteractionOrigin } from '../../models/Interaction';
12
13
  import { AuthPromptContext, SendMessageOptions, UserMessageRendererProps } from './AiChatTypes';
13
14
  import { SendMessageResponse } from '../../models/SendMessageResponse';
14
15
  import { ChatVerbosity } from './ChatPane/verbosity';
@@ -101,9 +102,16 @@ export interface AiChatContextState {
101
102
  label: string;
102
103
  initials?: string;
103
104
  picture?: string;
105
+ personaId?: string;
104
106
  };
107
+ /** Draw the account's BillingLimit notice above the composer (default true). See AiChatProps.showBillingLimit. */
108
+ showBillingLimit?: boolean;
109
+ /** Host renderer for the BillingLimit notice. See AiChatProps.renderBillingLimit. */
110
+ renderBillingLimit?: (notice: BillingLimitNotice, dismiss: () => void) => ReactNode;
105
111
  /** Custom renderer for the user-message body (the persona row is still shown above it). */
106
112
  userMessageRenderer?: ComponentType<UserMessageRendererProps>;
113
+ /** Badge words per turn origin (see AiChatProps.interactionOriginLabels). */
114
+ interactionOriginLabels?: Partial<Record<InteractionOrigin, string>>;
107
115
  sendMessage: (text: string, options?: SendMessageOptions) => Promise<SendMessageResponse>;
108
116
  }
109
117
  export declare const AiChatServiceContext: import('react').Context<AiChatContextState | undefined>;
@@ -1,5 +1,6 @@
1
+ import { BillingLimitNotice } from '../../models/billingLimit';
1
2
  import { default as React } from 'react';
2
- import { Interaction } from '../../models/Interaction';
3
+ import { Interaction, InteractionOrigin } from '../../models/Interaction';
3
4
  import { ChatSession } from '../../models/ChatSession';
4
5
  import { ConnectionState } from '../../models/connectionState';
5
6
  import { AgentContext, User } from '../../models/contexts';
@@ -288,7 +289,16 @@ export interface AiChatBaseProps extends AiChatStyleProps {
288
289
  label: string;
289
290
  initials?: string;
290
291
  picture?: string;
292
+ personaId?: string;
291
293
  };
294
+ /**
295
+ * Equipe de agentes: draw the account's plan notice (the server's out-of-band BillingLimit part — free plan,
296
+ * team near or at its limit, renewal declined) above the composer. Default true; a server that sends no such
297
+ * part shows nothing either way.
298
+ */
299
+ showBillingLimit?: boolean;
300
+ /** Replace the built-in BillingLimit banner. `dismiss` hides it until the notice changes. */
301
+ renderBillingLimit?: (notice: BillingLimitNotice, dismiss: () => void) => React.ReactNode;
292
302
  /**
293
303
  * Custom renderer for the BODY of a user message. The persona row (when `showPersona`) still
294
304
  * shows above it — this only replaces the default question bubble/icon, e.g. to render plain
@@ -296,6 +306,12 @@ export interface AiChatBaseProps extends AiChatStyleProps {
296
306
  * reference (module scope), like `partRenderers`.
297
307
  */
298
308
  userMessageRenderer?: React.ComponentType<UserMessageRendererProps>;
309
+ /**
310
+ * The words on the small badge a user message carries when it did not come from a person typing here (AIA Issue
311
+ * 1548): a WhatsApp message, a platform wake turn, an API call. Merged over the pt-BR defaults ("WhatsApp",
312
+ * "Plataforma", "API"); an empty string hides the badge for that origin. `user` never carries one.
313
+ */
314
+ interactionOriginLabels?: Partial<Record<InteractionOrigin, string>>;
299
315
  onMessage?: (message: Interaction) => void;
300
316
  onTurnComplete?: (message: Interaction) => void;
301
317
  onTurnOpen?: (iteractionId: string) => void;
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+ import { InteractionOrigin } from '../../../models/Interaction';
3
+ /** The badge words per origin — pt-BR, the product's language. A host overrides them with `interactionOriginLabels`. */
4
+ export declare const DEFAULT_INTERACTION_ORIGIN_LABELS: Readonly<Record<InteractionOrigin, string>>;
5
+ export interface InteractionOriginBadgeProps {
6
+ origin?: InteractionOrigin;
7
+ labels?: Partial<Record<InteractionOrigin, string>>;
8
+ }
9
+ /**
10
+ * Where a user message came from, when it was not a person typing here (AIA Issue 1548): a small, quiet tag above the
11
+ * message — a WhatsApp message relayed into the conversation, a platform turn after a task settled, an API call.
12
+ * Nothing for `user` or an unknown origin, and nothing when the host's label for it is empty.
13
+ */
14
+ export declare const InteractionOriginBadge: React.FC<InteractionOriginBadgeProps>;
15
+ export default InteractionOriginBadge;
@@ -2,7 +2,7 @@ import { AgentContext, User } from '../../models/contexts';
2
2
  import { Customer } from '../../models/Customer';
3
3
  import { SendMessageResponse } from '../../models/SendMessageResponse';
4
4
  import { EventBusService } from '../../services/eventBusService';
5
- import { AgentGatewayService, GatewaySendMessageOptions } from '../../services/servers/AgentGatewayService';
5
+ import { AgentGatewayService, AnnounceDetachedRunResult, GatewaySendMessageOptions } from '../../services/servers/AgentGatewayService';
6
6
  import { IStorageService } from '../../services/storageService';
7
7
  import { ISessionService } from '../../services/servers/sessionService/ISessionService';
8
8
  import { IArtifactService } from '../../services/interfaces/artifactService';
@@ -50,6 +50,12 @@ export interface AiChatEngineConfig {
50
50
  json?: string;
51
51
  };
52
52
  onGatewayReady?: (gateway: AgentGatewayService) => void;
53
+ /**
54
+ * The engine shows ONE detached run's own session (AIA Issue 1548): frames carrying `detachedRunId` are the
55
+ * transcript, not a run box beside it. See `AgentGatewayOptions.transcriptOfDetachedRun` and
56
+ * `DetachedRunTranscript`, which sets it.
57
+ */
58
+ transcriptOfDetachedRun?: boolean;
53
59
  }
54
60
  /**
55
61
  * A standalone, React-independent AiChat engine — the long-lived services that
@@ -98,6 +104,12 @@ export interface AiChatEngine {
98
104
  setModel: (modelId: string) => void;
99
105
  /** The model the engine currently ships. */
100
106
  getModel: () => string | undefined;
107
+ /**
108
+ * Ask for the announcement turn of a settled detached run of this conversation (AIA Issue 1548 §5) — queued while
109
+ * a turn is open, deduped per `(runId, settleKey)`. Pass the run's `settledAt` as `settleKey`. See
110
+ * {@link AgentGatewayService.announceDetachedRun}.
111
+ */
112
+ announceDetachedRun: (runId: string, settleKey?: string | null) => Promise<AnnounceDetachedRunResult>;
101
113
  /** Tear the engine down (stop the manager + close the socket). Not called for shared engines. */
102
114
  dispose: () => Promise<void>;
103
115
  }
@@ -1,3 +1,4 @@
1
+ import { BillingLimitNotice } from '../../models/billingLimit';
1
2
  import { ChatSession } from '../../models/ChatSession';
2
3
  import { Interaction } from '../../models/Interaction';
3
4
  import { ConnectionState } from '../../models/connectionState';
@@ -63,6 +64,11 @@ export interface AiChatState {
63
64
  * the outage interrupts — and a host can draw its own affordance from it anywhere.
64
65
  */
65
66
  connectionOutage: ConnectionOutage | null;
67
+ /**
68
+ * Where the account's plan stands (Equipe de agentes), from the server's out-of-band BillingLimit part — the
69
+ * latest one wins. Null until the server says something. Drawn above the composer.
70
+ */
71
+ billingLimit: BillingLimitNotice | null;
66
72
  statistics?: InteractionStatistics;
67
73
  connectionStatus: ConnectionState;
68
74
  lastToolEvent?: ToolEventDetails;
@@ -84,6 +90,7 @@ export interface AiChatState {
84
90
  setTurnOpen: (status: boolean) => void;
85
91
  setSuspendState: (status: SuspendState) => void;
86
92
  setConnectionOutage: (outage: ConnectionOutage | null) => void;
93
+ setBillingLimit: (notice: BillingLimitNotice | null) => void;
87
94
  setConnectionStatus: (status: ConnectionState) => void;
88
95
  setDetachedRunMessage: (detachedRunId: string, interaction: Interaction, name?: string) => void;
89
96
  completeDetachedRun: (detachedRunId: string) => void;
@@ -18,6 +18,8 @@ export type { AiChatEngine, AiChatEngineConfig } from './AiChat/aiChatEngine';
18
18
  export { useAgentEngine, engineKeyFor, getSharedAiChatEngine, disposeSharedAiChatEngine, } from './AiChat/useAgentEngine';
19
19
  export type { LiveSession, UseAgentEngineOptions } from './AiChat/useAgentEngine';
20
20
  export { default as Message } from './AiChat/ChatPane/Message';
21
+ export { InteractionOriginBadge, DEFAULT_INTERACTION_ORIGIN_LABELS } from './AiChat/ChatPane/InteractionOriginBadge';
22
+ export type { InteractionOriginBadgeProps } from './AiChat/ChatPane/InteractionOriginBadge';
21
23
  export { default as AskUserSheet } from './AiChat/ChatPane/AskUserSheet';
22
24
  export type { AskUserSheetProps } from './AiChat/ChatPane/AskUserSheet';
23
25
  export { default as AskUserDialog } from './AiChat/ChatPane/AskUserDialog';
@@ -49,3 +51,4 @@ export type { ContentBlock } from './LlmResponseRender';
49
51
  export * from './v2';
50
52
  export { MessageScopeProvider, useMessageScope } from './AiChat/ChatPane/MessageScope';
51
53
  export type { MessageScope } from './AiChat/ChatPane/MessageScope';
54
+ export * from './AgentTeam';
@@ -1,12 +1,16 @@
1
1
  import { default as React } from 'react';
2
2
  import { DetachedRunView } from '../../models/detachedRunModel';
3
+ import { DetachedRunStreamAuth } from './useDetachedRunLiveActivity';
4
+ import { DetachedRunTranscriptPresentationProps } from './DetachedRunTranscript';
5
+ import { PartRendererMap, UiToolRegistry } from '../AiChat/ChatPane/parts';
6
+ import { User } from '../../models/contexts';
3
7
  /** A task's structured conclusion, as far as the box reads it: `{ outcome?, summary, question? }`. */
4
8
  export interface DetachedRunConclusion {
5
9
  outcome?: string;
6
10
  summary: string;
7
11
  question?: string;
8
12
  }
9
- export interface DetachedRunTaskBoxProps {
13
+ export interface DetachedRunTaskBoxProps extends DetachedRunStreamAuth {
10
14
  /** The run's id — what `start_task` returned. */
11
15
  runId: string;
12
16
  /** Display name until the first read answers. */
@@ -23,19 +27,40 @@ export interface DetachedRunTaskBoxProps {
23
27
  renderConclusion?: (conclusion: DetachedRunConclusion, run: DetachedRunView) => React.ReactNode;
24
28
  /** The word before the name in the header. Default "tarefa". */
25
29
  label?: string;
30
+ /**
31
+ * Called once per settle the conversation has not been told about (`announced === false` on a Completed / Failed /
32
+ * Cancelled / WaitingForInput record) — whether the box watched it settle or found it so on its first read (a
33
+ * conversation reopened later). Once per `(runId, settledAt)`: a resumed run that settles anew calls it again. The
34
+ * host answers it with `engine.announceDetachedRun(run.id, run.settledAt)` (AIA Issue 1548 §5).
35
+ */
36
+ onSettled?: (run: DetachedRunView) => void;
37
+ /** The user whose token reads the run's artifacts in the detailed view (see `DetachedRunTranscript`). */
38
+ user?: User;
39
+ getUser?: () => User | undefined;
40
+ /** Renderers for the detailed view — the host's, so the run's tool cards look as they do in the chat. */
41
+ uiTools?: UiToolRegistry;
42
+ partRenderers?: PartRendererMap;
43
+ /** Any other presentation prop for the detailed view's `DetachedRunTranscript`. */
44
+ transcriptProps?: Partial<DetachedRunTranscriptPresentationProps>;
45
+ /** Height of the detailed view. Default 360 px. */
46
+ transcriptHeight?: number | string;
26
47
  }
27
48
  /**
28
49
  * A detached run (a task) drawn where the conversation started it, kept current until it ends (AIA Issue 1548).
29
50
  *
30
- * <p><b>Driven by a read, not by the stream.</b> A run executes on its own session — in-process or on a worker —
31
- * and its frames do not reach the conversation's socket, so the box reads the run's stored state every few
32
- * seconds. That is current wherever the run executes, and survives a reconnect or a session reopened tomorrow.</p>
51
+ * <p><b>Driven by a read; enlivened by the stream.</b> A run executes on its own session — in-process or on a worker —
52
+ * and its frames do not reach the conversation's socket, so the box reads the run's stored state every few seconds:
53
+ * the record is the source of truth (status, progress, conclusion), current wherever the run executes, and it survives
54
+ * a reconnect or a session reopened tomorrow. Given a `baseUrl` and credentials (`fetchImpl` / `getToken`), the box
55
+ * also follows the run's frames while it is Pending/Running — for a live activity line and a task list that moves the
56
+ * moment the agent updates it, the record winning whenever it is newer. Expanded ("ver detalhes"), it shows the run's
57
+ * whole transcript. Without credentials it polls only, as before.</p>
33
58
  *
34
59
  * <p>The read stops at a terminal status and when the box unmounts. `WaitingForInput` is not terminal: the task
35
60
  * stopped to ask, and the answer resumes it on the same id, so the box keeps reading it, slowly. A failed read is
36
61
  * shown quietly and retried — a box that goes blank because one request failed reads as the task having vanished.</p>
37
62
  */
38
- export declare function DetachedRunTaskBox({ runId, name, initialStatus, fetchRun, pollIntervalMs, waitingPollMs, renderConclusion, label, }: DetachedRunTaskBoxProps): import("react/jsx-runtime").JSX.Element;
63
+ export declare function DetachedRunTaskBox({ runId, name, initialStatus, fetchRun, pollIntervalMs, waitingPollMs, renderConclusion, label, onSettled, baseUrl, fetchImpl, getToken, onUnauthorized, user, getUser, uiTools, partRenderers, transcriptProps, transcriptHeight, }: DetachedRunTaskBoxProps): import("react/jsx-runtime").JSX.Element;
39
64
  /** A task's conclusion is JSON in its own format (`{ outcome, summary, question }` for the booking task); anything
40
65
  * else is shown as it came. */
41
66
  export declare function parseDetachedRunConclusion(conclusion: string | null | undefined): DetachedRunConclusion | null;
@@ -0,0 +1,89 @@
1
+ import { default as React } from 'react';
2
+ import { AiChatBaseProps } from '../AiChat/AiChatTypes';
3
+ import { AiChatEngine } from '../AiChat/aiChatEngine';
4
+ import { User } from '../../models/contexts';
5
+ import { INotificationPort } from '../../interfaces/INotificationPort';
6
+ import { DetachedRunFramesTransport } from '../../services/detachedRun/DetachedRunFramesTransport';
7
+ import { DetachedRunFetch, DetachedRunFollowError, DetachedRunFramesRetry } from '../../services/detachedRun/streamDetachedRunFrames';
8
+ /** Where a run's frames come from, and with whose credentials. */
9
+ export interface DetachedRunTranscriptSource {
10
+ /** The run — what `start_task` returned. */
11
+ runId: string;
12
+ /** The agents server the run lives on (the chat's `serverBaseUrl`). */
13
+ baseUrl: string;
14
+ /** The HTTP layer for the frames stream — a host's authenticated `fetch` wrapper. Default: the global `fetch`. */
15
+ fetchImpl?: DetachedRunFetch;
16
+ /** The bearer for the frames stream, read on every (re)connect. Default: the user's `access_token`. */
17
+ getToken?: () => string | undefined | null | Promise<string | undefined | null>;
18
+ /**
19
+ * Called on a 401 from the frames stream: refresh the credentials and resolve true to retry once with a fresh
20
+ * token. Without it a 401 is retried only when `getToken` already returns a different token.
21
+ */
22
+ onUnauthorized?: () => Promise<boolean>;
23
+ /** The signed-in user — whose token reads the run's artifacts. Prefer `getUser` (read live). */
24
+ user?: User;
25
+ getUser?: () => User | undefined;
26
+ notificationPort?: INotificationPort;
27
+ retry?: DetachedRunFramesRetry;
28
+ }
29
+ export interface DetachedRunTranscriptEngine {
30
+ /** An ordinary chat engine over the run's frames — adopt it with `<AiChat engine={…}>` like any other. */
31
+ engine: AiChatEngine;
32
+ transport: DetachedRunFramesTransport;
33
+ }
34
+ /**
35
+ * A chat engine that draws one detached run as a read-only transcript (AIA Issue 1548, phase 5): the ordinary engine,
36
+ * gateway and store, over a {@link DetachedRunFramesTransport} instead of a socket, with
37
+ * `transcriptOfDetachedRun` so the run's frames are the conversation. Creating it touches no network; call
38
+ * {@link openDetachedRunTranscript} to follow the run, `engine.dispose()` to stop.
39
+ */
40
+ export declare function createDetachedRunTranscriptEngine(source: DetachedRunTranscriptSource): DetachedRunTranscriptEngine;
41
+ /**
42
+ * Start following the run. The session record is bound first, under the run id, so the connect that follows finds it
43
+ * in place rather than replacing the store's session while the first frames land.
44
+ */
45
+ export declare function openDetachedRunTranscript({ engine }: DetachedRunTranscriptEngine, runId: string): Promise<string>;
46
+ export interface UseDetachedRunTranscriptOptions extends DetachedRunTranscriptSource {
47
+ /**
48
+ * Change it to follow the run again from where the transcript is — after the host answered the run. The frames
49
+ * stream ends when the run stops (settled, or waiting for an answer) and does not reopen by itself.
50
+ */
51
+ resumeKey?: unknown;
52
+ /** The run's stream ended: it settled, or stopped to ask. */
53
+ onStreamEnd?: (lastSeq: number) => void;
54
+ /**
55
+ * Following stopped for good, and why — so the page can say it: `notFound` (404), `forbidden` (403),
56
+ * `unauthorized` (401 after the refresh chance), `gaveUp` (anything else, or retries ran out).
57
+ */
58
+ onError?: (error: DetachedRunFollowError) => void;
59
+ }
60
+ /**
61
+ * The engine of {@link createDetachedRunTranscriptEngine}, owned by the calling component: one per run, following
62
+ * from mount, stopped on unmount. For a host that mounts its own `<AiChat engine={…}>` wrapper (with its UI tools and
63
+ * renderers) around a `<ChatPane />`; {@link DetachedRunTranscript} is that wrapper, ready-made.
64
+ */
65
+ export declare function useDetachedRunTranscript(options: UseDetachedRunTranscriptOptions): DetachedRunTranscriptEngine;
66
+ /**
67
+ * The chat presentation props a transcript passes through to `<AiChat>` — everything the component does not set
68
+ * itself. Omitted: the engine's own inputs (it builds the engine), the session/connection inputs (it follows the run),
69
+ * the prompt (there is none), `children` / `bottomSlot` (use `footer`) and `onError` (the transcript's own, below).
70
+ */
71
+ export type DetachedRunTranscriptPresentationProps = Omit<AiChatBaseProps, 'serverBaseUrl' | 'user' | 'getUser' | 'sessionService' | 'sessionId' | 'autoCreateSession' | 'hidePromptInput' | 'onGetWebSocketProvider' | 'children' | 'bottomSlot' | 'notificationPort' | 'artifactService' | 'storageService' | 'eventBusService' | 'onError' | 'onSessionCreated' | 'onSessionEstablished' | 'onGatewayReady'>;
72
+ export interface DetachedRunTranscriptProps extends UseDetachedRunTranscriptOptions, DetachedRunTranscriptPresentationProps {
73
+ /** Drawn under the transcript, inside the chat's providers — where a host puts its answer composer. */
74
+ footer?: React.ReactNode;
75
+ /** Not accepted: the transcript builds its own engine over the run's frames. */
76
+ engine?: never;
77
+ /** Not accepted: a transcript speaks as nobody. */
78
+ agentContext?: never;
79
+ }
80
+ /**
81
+ * A detached run as a read-only chat transcript (AIA Issue 1548, phase 5): its briefing and follow-ups as the user's
82
+ * bubbles, the agent's reasoning, tool calls and answer streaming exactly as the chat draws them — it IS the chat,
83
+ * over the run's frames stream instead of a socket, with no prompt. Presentation props (`uiTools`, `partRenderers`,
84
+ * `showPersona`, `verbosity`, …) pass through to `<AiChat>`; `footer` is the host's place for an answer composer.
85
+ *
86
+ * <p>Give it a definite height, like `ChatPane`: the transcript scrolls inside it.</p>
87
+ */
88
+ export declare function DetachedRunTranscript(props: DetachedRunTranscriptProps): import("react/jsx-runtime").JSX.Element;
89
+ export default DetachedRunTranscript;
@@ -41,6 +41,11 @@ export type { TaskListV2Props as TaskListProps, TaskListV2Props } from './TaskLi
41
41
  export { DetachedRunBoxV2 as DetachedRunBox, DetachedRunBoxV2 } from './DetachedRunBoxV2';
42
42
  export { DetachedRunTaskBox, parseDetachedRunConclusion, detachedRunHeadline } from './DetachedRunTaskBox';
43
43
  export type { DetachedRunTaskBoxProps, DetachedRunConclusion } from './DetachedRunTaskBox';
44
+ export { useDetachedRunLiveActivity, canStreamDetachedRun } from './useDetachedRunLiveActivity';
45
+ export type { DetachedRunStreamAuth, DetachedRunLiveActivity } from './useDetachedRunLiveActivity';
46
+ export { DetachedRunTranscript, useDetachedRunTranscript, createDetachedRunTranscriptEngine, openDetachedRunTranscript, } from './DetachedRunTranscript';
47
+ export type { DetachedRunTranscriptProps, DetachedRunTranscriptSource, DetachedRunTranscriptEngine, DetachedRunTranscriptPresentationProps, UseDetachedRunTranscriptOptions, } from './DetachedRunTranscript';
48
+ export { useDetachedRunResumeKey } from './useDetachedRunResumeKey';
44
49
  export type { DetachedRunBoxV2Props as DetachedRunBoxProps, DetachedRunBoxV2Props, DetachedRunBoxV2Level as DetachedRunBoxLevel, DetachedRunBoxV2Level } from './DetachedRunBoxV2';
45
50
  export { AgentActivityV2 as AgentActivity, AgentActivityV2 } from './AgentActivityV2';
46
51
  export type { AgentActivityV2Props as AgentActivityProps, AgentActivityV2Props } from './AgentActivityV2';
@@ -0,0 +1,30 @@
1
+ import { TodoList } from '../../models/todoListModel';
2
+ import { DetachedRunFetch } from '../../services/detachedRun/streamDetachedRunFrames';
3
+ /** How a box reaches a run's frames — the same credentials the transcript takes. */
4
+ export interface DetachedRunStreamAuth {
5
+ /** The agents server the run lives on. Without it (and `fetchImpl` or `getToken`) nothing is streamed. */
6
+ baseUrl?: string;
7
+ fetchImpl?: DetachedRunFetch;
8
+ getToken?: () => string | undefined | null | Promise<string | undefined | null>;
9
+ onUnauthorized?: () => Promise<boolean>;
10
+ }
11
+ export interface DetachedRunLiveActivity {
12
+ /** One quiet line: the latest tool call in friendly words, or the tail of what the agent is writing. */
13
+ activity: string | null;
14
+ /** The task list as the latest `todolistUpdated` frame left it, and when that frame arrived (epoch ms). */
15
+ todo: {
16
+ todoList: TodoList;
17
+ at: number;
18
+ } | null;
19
+ /** A stream is open right now. */
20
+ streaming: boolean;
21
+ }
22
+ /** Whether the box has what it needs to stream: a base URL and some way to authenticate. */
23
+ export declare function canStreamDetachedRun(auth: DetachedRunStreamAuth): boolean;
24
+ /**
25
+ * Follow a run's frames while it is `active` (AIA Issue 1548 §3b): the latest activity for a one-line ticker and the
26
+ * task list the moment it changes. Closes when `active` turns false, when the server ends the stream, and on unmount;
27
+ * opens again when the run becomes active again after having stopped (it was resumed). The cursor survives a reopen,
28
+ * so a resumed run is not replayed from the start.
29
+ */
30
+ export declare function useDetachedRunLiveActivity(runId: string, active: boolean, auth: DetachedRunStreamAuth): DetachedRunLiveActivity;
@@ -0,0 +1,15 @@
1
+ import { DetachedRunView } from '../../models/detachedRunModel';
2
+ /**
3
+ * The `resumeKey` for a {@link DetachedRunTranscript} that follows a run you also READ (AIA Issue 1548): it changes
4
+ * whenever the record leaves a wait — resumed, settled, or waiting on a NEWER question.
5
+ *
6
+ * <p>The frames stream ends when the run stops to ask, and the answer can come from any channel — a page's composer,
7
+ * the conversation's task box, WhatsApp. Keyed on a host's own send, a transcript answered elsewhere stayed frozen on
8
+ * the first question while the record already said the run had moved on (seen 2026-10-12: a WhatsApp answer, a second
9
+ * question, then a failure, and the details still drawing the first question). The record is the one thing every
10
+ * channel moves, so it is the cue.</p>
11
+ *
12
+ * <p>A host that answers optimistically (sets the record out of the wait before the next read) gets its re-follow
13
+ * from the same change — it needs no key of its own.</p>
14
+ */
15
+ export declare function useDetachedRunResumeKey(run: Pick<DetachedRunView, 'status' | 'updatedAt'> | null | undefined): number;
@@ -1,10 +1,27 @@
1
1
  import { TodoList } from './todoListModel';
2
2
  import { Artifact } from './Artifact';
3
3
  import { InteractionPart } from './InteractionPart';
4
+ /**
5
+ * Where a turn came from (AIA Issue 1548), as the SDK's `InteractionOrigins` name it: `user` — a person typing in a
6
+ * client; `whatsapp` — a WhatsApp message relayed by the WhatsApp host; `platform` — the platform itself (a wake turn
7
+ * after a task settled, a detached run's briefing); `api` — any other `POST /run` caller.
8
+ */
9
+ export type InteractionOrigin = 'user' | 'whatsapp' | 'platform' | 'api';
10
+ /** The wire's origin string as an {@link InteractionOrigin}, case-insensitively; undefined for anything unknown. */
11
+ export declare function toInteractionOrigin(value: string | null | undefined): InteractionOrigin | undefined;
4
12
  export interface TurnOpenCloseDetails {
5
13
  stack: string[];
6
14
  turnClosed: boolean;
7
15
  }
16
+ /**
17
+ * The named agent (persona) that answered a turn — Equipe de agentes. `personaId` keys the persona catalog
18
+ * (`PERSONA_BY_ID`), `role` the specialty (`res` | `pos` | `pol` | `evt`). Kept as plain strings: the wire may
19
+ * name a persona this client build does not know yet, and the renderer falls back to the generic agent.
20
+ */
21
+ export interface ChatAgentIdentity {
22
+ personaId: string;
23
+ role: string;
24
+ }
8
25
  export interface Interaction {
9
26
  isSuspended?: boolean;
10
27
  created: Date;
@@ -16,6 +33,13 @@ export interface Interaction {
16
33
  turn_complete?: boolean;
17
34
  isFinalResponse?: boolean;
18
35
  interactionQuestion?: string;
36
+ /** Where the turn came from; absent means a person typing (`user`). See {@link InteractionOrigin}. */
37
+ origin?: InteractionOrigin;
38
+ /**
39
+ * True for a turn this client did not send — the server announced it (`InteractionStarted`), or its frames
40
+ * arrived without one. The live view draws such a turn's question itself, since no composer here holds it.
41
+ */
42
+ remote?: boolean;
19
43
  asyncFinalResponse?: boolean;
20
44
  version: number;
21
45
  parts: InteractionPart[];
@@ -24,4 +48,6 @@ export interface Interaction {
24
48
  functionMap?: Map<string, InteractionPart>;
25
49
  contextStatus?: any;
26
50
  taskLists?: Map<string, string>;
51
+ /** Who answered this turn. Sticky: once a turn names its agent, later events without one keep it. */
52
+ agent?: ChatAgentIdentity;
27
53
  }
@@ -1,6 +1,7 @@
1
1
  import { EventType } from './enums';
2
2
  import { InteractionPart } from './InteractionPart';
3
3
  import { EndMessageData } from './EndMessageData';
4
+ import { ChatAgentIdentity } from './Interaction';
4
5
  import { KernelContent, LlmArtifact, LlmEvent, PartType, SessionInformation, StreamingKernelContent } from './semanticKernelModel/models';
5
6
  export interface FunctionDetails {
6
7
  id: string;
@@ -129,6 +130,8 @@ export declare class ServerEvent {
129
130
  session_information?: SessionInformation;
130
131
  detachedRunId?: string;
131
132
  detachedRunName?: string;
133
+ /** The named agent answering this turn, when the server stamps one (Equipe de agentes). */
134
+ agent?: ChatAgentIdentity;
132
135
  visible: boolean;
133
136
  constructor(interactionId: string);
134
137
  static createErrorEvent(errorMessage: string, interactionId: string): ServerEvent;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Where the account's plan stands (Equipe de agentes) — what the server's BillingLimit part says. Session-level state:
3
+ * the agents server sends it out of band on connect (no turn) and at a turn's start. Held in
4
+ * `AiChatState.billingLimit`; the chat draws it as a banner above the composer (or the host's `renderBillingLimit`).
5
+ */
6
+ export interface BillingLimitNotice {
7
+ /** `free` (no hired agent) or `team`. */
8
+ plan: string;
9
+ /** `ok`, `a70`, `a90`, `temp`, `full`, `hold` or `pastdue`. */
10
+ state: string;
11
+ used: number;
12
+ included: number;
13
+ /** True when the next trip would not be issued without a hire. */
14
+ limitReached: boolean;
15
+ /** True when this user can act on it (hire, update the card). */
16
+ canManage: boolean;
17
+ title?: string;
18
+ message?: string;
19
+ /** A host route where the user acts on it. */
20
+ actionUrl?: string;
21
+ /** The turn it came with; empty for a notice sent on connect. */
22
+ interactionId?: string;
23
+ }
@@ -37,7 +37,18 @@ export interface DetachedRunView {
37
37
  created?: string | null;
38
38
  updatedAt?: string | null;
39
39
  settledAt?: string | null;
40
+ /**
41
+ * True once the conversation that started the run was told about its latest settle (the SDK's
42
+ * `AnnouncedAt >= SettledAt`, AIA Issue 1548 §5). False on a settled run nobody announced yet — the cue for the
43
+ * client to ask for the announcement. Absent on records from an SDK that predates it.
44
+ */
45
+ announced?: boolean;
40
46
  }
47
+ /** The statuses a run SETTLES on — it stopped, for good or to ask — and that the conversation is told about. */
48
+ export declare const DETACHED_RUN_SETTLED_STATUSES: ReadonlyArray<DetachedRunStatus>;
49
+ export declare function isDetachedRunSettledStatus(status: string | undefined | null): boolean;
50
+ /** True while the run executes (or is about to): the statuses a live view follows. */
51
+ export declare function isDetachedRunActiveStatus(status: string | undefined | null): boolean;
41
52
  /**
42
53
  * Status values after which the detached run will never change again. `WaitingForInput` is deliberately absent:
43
54
  * the run has stopped, but the task resumes when its question is answered.
@@ -11,7 +11,7 @@ export declare const RunMode: {
11
11
  readonly Interactive: "interactive";
12
12
  readonly Autonomous: "autonomous";
13
13
  };
14
- export type ChatAction = 'SendMessage' | 'Suspend' | 'Ping' | 'Close' | 'Other' | 'AnswerHumanTool';
14
+ export type ChatAction = 'SendMessage' | 'Suspend' | 'Ping' | 'Close' | 'Other' | 'AnswerHumanTool' | 'AnnounceDetachedRun';
15
15
  export declare const ChatAction: {
16
16
  readonly SendMessage: "SendMessage";
17
17
  readonly Other: "Other";
@@ -19,6 +19,8 @@ export declare const ChatAction: {
19
19
  readonly Close: "Close";
20
20
  readonly Ping: "Ping";
21
21
  readonly AnswerHumanTool: "AnswerHumanTool";
22
+ /** Ask the server for the announcement turn of this conversation's settled detached runs (AIA Issue 1548 §5). */
23
+ readonly AnnounceDetachedRun: "AnnounceDetachedRun";
22
24
  };
23
25
  export type EventType = 'partial_function_call' | 'tool_event' | 'function_call' | 'not_defined' | 'function_response' | 'function_client_output' | 'user_answer' | 'video' | 'thought' | 'thought_highlight' | 'inline_data' | 'file_data' | 'code_execution_result' | 'executable_code' | 'text' | 'other' | 'waiting' | 'suspended' | 'server_error';
24
26
  export declare const EventType: {
@@ -1,4 +1,6 @@
1
- export type { Interaction, TurnOpenCloseDetails } from './Interaction';
1
+ export type { Interaction, TurnOpenCloseDetails, InteractionOrigin, ChatAgentIdentity } from './Interaction';
2
+ export { toInteractionOrigin } from './Interaction';
3
+ export type { BillingLimitNotice } from './billingLimit';
2
4
  export type { InteractionPart } from './InteractionPart';
3
5
  export { InteractionPartUtils } from './InteractionPart';
4
6
  export type { ChatSession } from './ChatSession';
@@ -19,7 +21,7 @@ export type { Artifact } from './Artifact';
19
21
  export type { ArtifactData } from './ArtifactData';
20
22
  export type { TodoList, TodoItem, TodoItemStatus } from './todoListModel';
21
23
  export type { DetachedRunView, DetachedRunStatus, DetachedRunStopReason } from './detachedRunModel';
22
- export { isDetachedRunTerminalStatus, isDetachedRunWaitingForInput, DETACHED_RUN_TERMINAL_STATUSES } from './detachedRunModel';
24
+ export { isDetachedRunTerminalStatus, isDetachedRunWaitingForInput, DETACHED_RUN_TERMINAL_STATUSES, DETACHED_RUN_SETTLED_STATUSES, isDetachedRunSettledStatus, isDetachedRunActiveStatus } from './detachedRunModel';
23
25
  export type { SendMessageResponse, StartStreamResponse, ServerSendMessageResponse } from './SendMessageResponse';
24
26
  export type { Prompt as PromptModel } from './Prompt';
25
27
  export { PromptUtils } from './Prompt';
@@ -32,4 +34,4 @@ export type { SemanticMemory, SemanticMemoryInput, SemanticMemorySearchOptions }
32
34
  export type { FunctionDetails, ThoughtDetails, TextDetails, ErrorDetails, ToolEventDetails, ExecutableCodeDetails, CodeExecutionResultDetails, } from './ServerEvent';
33
35
  export { ServerEvent } from './ServerEvent';
34
36
  export { deserializeEvent, deserializePayload, serializeEvent, createEventSerializer, createStreamingResponseSerializer, sanitizeJsonString, } from './semanticKernelModel/serializer';
35
- export { LlmEvent, StreamingResponse, TextContent, FunctionCallContent, FunctionResultContent, ChatMessageContent, StreamingTextContent, StreamingReasoningContent, StreamingFunctionCallUpdateContent, } from './semanticKernelModel/models';
37
+ export { LlmEvent, StreamingResponse, TextContent, FunctionCallContent, FunctionResultContent, ChatMessageContent, StreamingTextContent, StreamingReasoningContent, StreamingFunctionCallUpdateContent, InteractionStart, InteractionOriginContent, } from './semanticKernelModel/models';
@@ -1,5 +1,5 @@
1
1
  import { Artifact } from '../../models/Artifact';
2
- export type PartType = 'ToolEventContent' | 'StreamingToolEventContent' | 'TextContent' | 'StreamingFinalFunctionCallContent' | 'StreamingFinalFunctionResultContent' | 'StreamingClientOutputContent' | 'StreamingReasoningContent' | 'StreamingThoughtHighlightContent' | 'ImageContent' | 'FunctionCallContent' | 'FunctionResultContent' | 'FunctionClientOutputContent' | 'UserUiContent' | 'ChatMessageContent' | 'StreamingTextContent' | 'StreamingFunctionCallUpdateContent' | 'Unknown';
2
+ export type PartType = 'ToolEventContent' | 'StreamingToolEventContent' | 'TextContent' | 'StreamingFinalFunctionCallContent' | 'StreamingFinalFunctionResultContent' | 'StreamingClientOutputContent' | 'StreamingReasoningContent' | 'StreamingThoughtHighlightContent' | 'ImageContent' | 'FunctionCallContent' | 'FunctionResultContent' | 'FunctionClientOutputContent' | 'UserUiContent' | 'InteractionOriginContent' | 'BillingLimitContent' | 'ChatMessageContent' | 'StreamingTextContent' | 'StreamingFunctionCallUpdateContent' | 'Unknown';
3
3
  export declare const PartType: {
4
4
  readonly TextContent: "TextContent";
5
5
  readonly ToolEventContent: "ToolEventContent";
@@ -11,6 +11,8 @@ export declare const PartType: {
11
11
  readonly FunctionResultContent: "FunctionResultContent";
12
12
  readonly FunctionClientOutputContent: "FunctionClientOutputContent";
13
13
  readonly UserUiContent: "UserUiContent";
14
+ readonly InteractionOriginContent: "InteractionOriginContent";
15
+ readonly BillingLimitContent: "BillingLimitContent";
14
16
  readonly ChatMessageContent: "ChatMessageContent";
15
17
  readonly StreamingTextContent: "StreamingTextContent";
16
18
  readonly StreamingFunctionCallUpdateContent: "StreamingFunctionCallUpdateContent";
@@ -119,6 +121,20 @@ export declare class UserUiContent extends KernelContent {
119
121
  name?: string;
120
122
  args?: string;
121
123
  }
124
+ export declare class InteractionOriginContent extends KernelContent {
125
+ origin?: string;
126
+ }
127
+ export declare class BillingLimitContent extends KernelContent {
128
+ plan?: string;
129
+ state?: string;
130
+ used?: number;
131
+ included?: number;
132
+ limitReached?: boolean;
133
+ canManage?: boolean;
134
+ title?: string;
135
+ message?: string;
136
+ actionUrl?: string;
137
+ }
122
138
  export declare class ChatMessageContent extends KernelContent {
123
139
  role?: AuthorRole;
124
140
  items?: KernelContent[];
@@ -150,6 +166,10 @@ export declare class InstructionSummary {
150
166
  description: string;
151
167
  interactionId: string;
152
168
  }
169
+ export declare class AgentIdentityWire {
170
+ personaId: string;
171
+ role: string;
172
+ }
153
173
  export declare class SessionInformation {
154
174
  size: number;
155
175
  originalSize: number;
@@ -173,6 +193,8 @@ export declare class LlmEvent {
173
193
  serverError?: string;
174
194
  interactionId: string;
175
195
  sessionInformation?: SessionInformation;
196
+ /** The named agent answering this turn (Equipe de agentes). Absent on servers without personas. */
197
+ agent?: AgentIdentityWire;
176
198
  eventType?: EventTypeInformation;
177
199
  artifactsGenerated: LlmArtifact[];
178
200
  author?: string;
@@ -196,6 +218,21 @@ export declare class PartialLlmEvent {
196
218
  partialEventType?: EventTypeInformation;
197
219
  detachedRunId?: string;
198
220
  }
221
+ /**
222
+ * The payload of an `InteractionStarted` frame (AIA Issue 1548): a turn announcing itself before its first delta, so a
223
+ * client that did not send it — a WhatsApp message, a platform wake turn, a detached run's briefing — can open it with
224
+ * the text that started it. Server-side `InteractionStart`, camelCase, nulls omitted.
225
+ */
226
+ export declare class InteractionStart {
227
+ interactionId?: string;
228
+ /** The text that started the turn — what the client draws as the user's bubble. */
229
+ content?: string;
230
+ /** `user` | `whatsapp` | `platform` | `api` (the SDK's `InteractionOrigins`). */
231
+ origin?: string;
232
+ agentId?: string;
233
+ /** Set when the turn belongs to a detached run (it executes on the run's own session). */
234
+ detachedRunId?: string;
235
+ }
199
236
  export declare class StreamingResponse {
200
237
  type: string;
201
238
  event?: LlmEvent;
@@ -208,6 +245,8 @@ export declare class StreamingResponse {
208
245
  */
209
246
  accessToken?: string;
210
247
  partialEvent?: PartialLlmEvent;
248
+ /** Only on `type: "InteractionStarted"`: the turn that is about to stream. */
249
+ interaction?: InteractionStart;
211
250
  detachedRunId?: string;
212
251
  detachedRunName?: string;
213
252
  /**