create-agents24-app 0.2.47 → 0.2.49

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.
@@ -6,7 +6,7 @@ import {
6
6
  type AgentChatRuntimeAgent,
7
7
  useAgentChatRuntime,
8
8
  } from "@agents24/chat-react/runtime"
9
- import type { HitlActionState } from "@agents24/chat-react/ui"
9
+ import type { AgentResponseTimelineProps, HitlActionState } from "@agents24/chat-react/ui"
10
10
  import {
11
11
  Agents24Provider,
12
12
  type ChatHitlPart,
@@ -24,7 +24,11 @@ import { GUEST_CHAT_IDENTITY, type Agents24ChatIdentity } from "./identity"
24
24
  const createBrowserAbortController = () => new AbortController()
25
25
  const browserVisibility = createBrowserVisibility()
26
26
 
27
- export type Agents24ChatAppProps = {
27
+ export type Agents24ChatTimelineOptions = Pick<AgentResponseTimelineProps,
28
+ "nodeActivityMode" | "renderUiBlocks" | "toolLabelMode" | "toolSlots" | "toolViewMode">
29
+
30
+ export type Agents24ChatAppProps = Agents24ChatTimelineOptions & {
31
+ attachmentTextOutputs?: readonly string[]
28
32
  activeThreadId?: string | null
29
33
  agent?: AgentChatRuntimeAgent
30
34
  client: AgentClient
@@ -47,7 +51,7 @@ export type Agents24ChatScaffoldComponents = {
47
51
 
48
52
  export type ChatHitlResponse = HitlResponse
49
53
 
50
- export type Agents24ChatTimelineSlotProps = {
54
+ export type Agents24ChatTimelineSlotProps = Agents24ChatTimelineOptions & {
51
55
  message: ChatMessage
52
56
  parts: readonly ChatPart[]
53
57
  isLoading: boolean
@@ -58,6 +62,11 @@ export type Agents24ChatTimelineSlotProps = {
58
62
  function RuntimeChat({
59
63
  components,
60
64
  identity = GUEST_CHAT_IDENTITY,
65
+ nodeActivityMode,
66
+ renderUiBlocks,
67
+ toolLabelMode,
68
+ toolSlots,
69
+ toolViewMode,
61
70
  ...props
62
71
  }: Agents24ChatAppProps) {
63
72
  const runtime = useAgentChatRuntime({
@@ -67,7 +76,7 @@ function RuntimeChat({
67
76
  ),
68
77
  })
69
78
 
70
- return <ChatShell components={components} identity={identity} runtime={runtime} sidebar={props.sidebar} />
79
+ return <ChatShell components={components} identity={identity} runtime={runtime} sidebar={props.sidebar} timelineOptions={{ nodeActivityMode, renderUiBlocks, toolLabelMode, toolSlots, toolViewMode }} />
71
80
  }
72
81
 
73
82
  export function App(props: Agents24ChatAppProps) {
@@ -27,7 +27,6 @@
27
27
  [data-agents24-theme-root] .a24-message-response {
28
28
  max-width: 100%;
29
29
  min-width: 0;
30
- padding-inline: 6px;
31
30
  width: 100%;
32
31
  }
33
32
 
@@ -1,9 +1,11 @@
1
- import { ArrowUp, ChevronDown, LoaderCircle, Mic, Square } from "lucide-react"
1
+ import type { RealtimeDictationOptions, AgentChatSubmissionContext } from "@agents24/chat-react/ui";
2
+ import { ArrowUp, ChevronDown, LoaderCircle, Square } from "lucide-react"
2
3
  import * as React from "react"
3
4
  import {
5
+ MicrophoneInput,
4
6
  AgentChatContextStatus,
5
7
  ChatAttachmentRows,
6
- useAgentChatComposer,
8
+ useAgentChatDictation,
7
9
  type AgentChatComposerFile,
8
10
  } from "@agents24/chat-react/ui"
9
11
  import { attachmentFileAccept, type AgentChatInputContract } from "@agents24/chat-react/runtime"
@@ -20,6 +22,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"
20
22
  import { cn } from "../../lib/utils"
21
23
 
22
24
  export type Agents24ChatComposerProps = {
25
+ realtimeDictation?: RealtimeDictationOptions;
23
26
  queue?: React.ReactNode
24
27
  onRecordingStreamChange?: (stream: MediaStream | null) => void
25
28
  inputContract: AgentChatInputContract
@@ -37,13 +40,13 @@ export type Agents24ChatComposerProps = {
37
40
  onModelChange: (modelId: string) => void
38
41
  onAgentChange: (agentId: string) => void
39
42
  onStop: () => void
40
- onSubmit: (text: string, files: AgentChatComposerFile[]) => Promise<void>
43
+ onSubmit: (text: string, files: AgentChatComposerFile[], context?: AgentChatSubmissionContext) => Promise<void>
41
44
  restoredDraft?: { revision: number; text: string; files: AgentChatComposerFile[] } | null
42
45
  utilityRow?: "inline" | "below"
43
46
  }
44
47
 
45
48
  export function ChatComposer({
46
- inputContract,
49
+ inputContract, realtimeDictation,
47
50
  queue,
48
51
  onRecordingStreamChange,
49
52
  disabled,
@@ -64,13 +67,18 @@ export function ChatComposer({
64
67
  restoredDraft,
65
68
  utilityRow = "inline",
66
69
  }: Agents24ChatComposerProps) {
70
+ const [audioRecording, setAudioRecording] = React.useState(false);
67
71
  const inputRef = React.useRef<HTMLInputElement>(null)
68
- const { text, setText, files, removeFile, addFiles, textareaRef, submit,
69
- attachmentError, attachmentMimeTypes, allowAttachments, recordingAllowed,
70
- recorder, isExpanded, validationError, action, canSubmit } = useAgentChatComposer({
71
- inputContract, disabled, scopeKey, focusKey, forceExpanded, isCancelling, isRunning,
72
- onSubmit, restoredDraft, onRecordingStreamChange,
73
- })
72
+ const textareaRef = React.useRef<HTMLTextAreaElement>(null)
73
+ const voice = useAgentChatDictation({
74
+ props:{inputContract,disabled:disabled || audioRecording,scopeKey,focusKey,forceExpanded,isCancelling,isRunning,restoredDraft,onSubmit},
75
+ textareaRef,scopeKey:scopeKey||"default",realtime:realtimeDictation,
76
+ onSubmit,onEdit:()=>undefined,onStreamChange:stream=>onRecordingStreamChange?.(stream),
77
+ })
78
+ const sendingDictation = voice.intent === "send" && ["stopping", "transcribing", "submitting"].includes(voice.phase);
79
+ const { text, setText, files, removeFile, addFiles, submit,
80
+ attachmentError, attachmentMimeTypes, allowAttachments,
81
+ recorder, isExpanded, validationError, action, canSubmit } = voice.composer
74
82
 
75
83
  const selectedAgent = agents.find((item) => item.id === agentId)
76
84
  const selectedModel = models.find((item) => item.id === modelId)
@@ -183,7 +191,7 @@ export function ChatComposer({
183
191
  rows={1}
184
192
  placeholder="Message the agent"
185
193
  aria-label="Message"
186
- disabled={disabled}
194
+ disabled={disabled || voice.busy || audioRecording}
187
195
  className={cn(
188
196
  "agents24-composer-textarea max-h-56 min-h-9 field-sizing-content resize-none overflow-y-auto border-0 bg-transparent px-2 shadow-none focus-visible:ring-0 dark:bg-transparent",
189
197
  isExpanded ? "py-2" : "h-9 py-2",
@@ -201,33 +209,29 @@ export function ChatComposer({
201
209
  <div className="agents24-composer-actions flex items-center gap-1">
202
210
  {utilityRow === "inline" ? <AgentChatContextStatus contextWindow={contextWindow} /> : null}
203
211
  {utilityRow === "inline" ? runtimeSelector : null}
204
- {recordingAllowed ? (
205
- <Button
206
- variant={recorder.isRecording ? "default" : "ghost"}
207
- size="icon"
208
- aria-label={recorder.isRecording ? "Stop recording" : "Record audio"}
209
- disabled={disabled || isRunning}
210
- onClick={() => { if (recorder.isRecording) recorder.stop(); else void recorder.start() }}
211
- >
212
- {recorder.isRecording ? <Square className="fill-current" /> : <Mic />}
213
- </Button>
214
- ) : null}
212
+ <MicrophoneInput scopeKey={scopeKey} className="inline-flex size-9 items-center justify-center rounded-full"
213
+ disabled={disabled || voice.composer.isSubmitting}
214
+ dictation={{enabled:realtimeDictation?.feature.enabled === true,phase:voice.phase,start:voice.start,stop:()=>voice.finish('edit'),cancel:voice.cancel}}
215
+ audioEnabled={inputContract.modalities.audio.enabled && inputContract.modalities.audio.recording_enabled}
216
+ acceptedMimeTypes={inputContract.modalities.audio.allowed_mime_types}
217
+ onRecordingChange={setAudioRecording} onStreamChange={onRecordingStreamChange}
218
+ onRecorded={file=>addFiles([file])} />
215
219
  {action === "stop" ? (
216
220
  <Button size="icon" aria-label={isCancelling ? "Cancelling response" : "Stop response"}
217
221
  disabled={disabled || isCancelling} onClick={onStop}>
218
222
  {isCancelling ? <LoaderCircle className="animate-spin" /> : <Square className="fill-current" />}
219
223
  </Button>
220
- ) : validationError ? (
224
+ ) : validationError && !voice.busy ? (
221
225
  <Tooltip>
222
226
  <TooltipTrigger asChild>
223
227
  <span tabIndex={0} aria-label={validationError}>
224
- <Button size="icon" aria-label={isRunning ? "Queue message" : "Send message"} disabled onClick={() => void submit()}><ArrowUp /></Button>
228
+ <Button size="icon" aria-label={isRunning ? "Queue message" : "Send message"} disabled onClick={() => void submit()}>{sendingDictation ? <LoaderCircle className="animate-spin" /> : <ArrowUp />}</Button>
225
229
  </span>
226
230
  </TooltipTrigger>
227
231
  <TooltipContent>{validationError}</TooltipContent>
228
232
  </Tooltip>
229
233
  ) : (
230
- <Button size="icon" aria-label={isRunning ? "Queue message" : "Send message"} disabled={!canSubmit} onClick={() => void submit()}><ArrowUp /></Button>
234
+ <Button size="icon" aria-label={isRunning ? "Queue message" : "Send message"} aria-busy={sendingDictation || undefined} disabled={sendingDictation || !canSubmit} onClick={() => void submit()}>{sendingDictation ? <LoaderCircle className="animate-spin" /> : <ArrowUp />}</Button>
231
235
  )}
232
236
  </div>
233
237
  </div>
@@ -7,13 +7,14 @@ import * as React from "react"
7
7
  import { MessageParts } from "./message-parts"
8
8
  import { Bubble, BubbleContent } from "../ui/bubble"
9
9
  import { Message, MessageContent, MessageFooter } from "../ui/message"
10
- import type { Agents24ChatTimelineSlotProps } from "../../app"
10
+ import type { Agents24ChatTimelineSlotProps, Agents24ChatTimelineOptions } from "../../app"
11
11
 
12
12
  type Props = {
13
13
  animateCompletion: boolean
14
14
  message: ChatMessageModel
15
15
  getHitlActionState: (part: ChatHitlPart) => AgentChatRuntimeHitlActionState | undefined
16
16
  isLoading: boolean
17
+ timelineOptions?: Agents24ChatTimelineOptions
17
18
  onHitlAction: (part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions) => Promise<void>
18
19
  onRegenerate: () => Promise<void>
19
20
  allowFeedback: boolean
@@ -29,6 +30,7 @@ export function ChatMessage({
29
30
  allowFeedback,
30
31
  getHitlActionState,
31
32
  isLoading,
33
+ timelineOptions,
32
34
  message,
33
35
  onHitlAction,
34
36
  onRegenerate,
@@ -54,6 +56,7 @@ export function ChatMessage({
54
56
  <MessageParts
55
57
  getHitlActionState={getHitlActionState}
56
58
  isLoading={isLoading}
59
+ timelineOptions={timelineOptions}
57
60
  message={message}
58
61
  onHitlAction={onHitlAction}
59
62
  Timeline={Timeline}
@@ -2,7 +2,7 @@ import {
2
2
  agentChatRuntimeErrorMessage,
3
3
  type AgentChatRuntime,
4
4
  } from "@agents24/chat-react/runtime"
5
- import type { Agents24ChatScaffoldComponents } from "../../app"
5
+ import type { Agents24ChatScaffoldComponents, Agents24ChatTimelineOptions } from "../../app"
6
6
  import type { ThreadMessage } from "@agents24/client"
7
7
  import { AgentChatQueue, queuedMessageComposerFiles, useLiveCompletionRuns, type AgentChatComposerFile } from "@agents24/chat-react/ui"
8
8
  import { CircleAlert, LoaderCircle, SquarePen, X } from "lucide-react"
@@ -87,11 +87,13 @@ export function ChatShell({
87
87
  identity,
88
88
  runtime,
89
89
  sidebar,
90
+ timelineOptions,
90
91
  }: {
91
92
  components?: Agents24ChatScaffoldComponents
92
93
  identity: Agents24ChatIdentity
93
94
  runtime: AgentChatRuntime
94
95
  sidebar?: React.ReactNode
96
+ timelineOptions?: Agents24ChatTimelineOptions
95
97
  }) {
96
98
  const Composer = components?.Composer || ChatComposer
97
99
  const { controller } = runtime
@@ -218,6 +220,7 @@ export function ChatShell({
218
220
  onSetFeedback={(input) => controller.setFeedback(message, input)}
219
221
  resolveAttachmentContent={runtime.resolveAttachmentContent}
220
222
  Timeline={components?.Timeline}
223
+ timelineOptions={timelineOptions}
221
224
  />
222
225
  </LatestThreadScroller.Item>
223
226
  ))}
@@ -248,6 +251,7 @@ export function ChatShell({
248
251
  onEdit={retractForEdit} onResume={controller.resumeQueue} />}
249
252
  restoredDraft={restoredDraft}
250
253
  inputContract={runtime.inputContract || LOADING_INPUT_CONTRACT}
254
+ realtimeDictation={runtime.dictation}
251
255
  contextWindow={runtime.contextWindow}
252
256
  disabled={runtime.isBootstrapping || runtime.isChangingAgent || isUploading || hasBlockingError}
253
257
  scopeKey={controller.activeThreadId}
@@ -262,10 +266,11 @@ export function ChatShell({
262
266
  modelId={runtime.modelId}
263
267
  models={runtime.models}
264
268
  onModelChange={runtime.changeModel}
265
- onSubmit={(text, files) => runtime.submit({
266
- text,
269
+ onSubmit={(text, files, context) => runtime.submit({
270
+ text, dictationSessionId: context?.dictationSessionId,
267
271
  files: files.filter((file) => file.source).map((file) => ({
268
272
  data: file.source!,
273
+ transcriptPresentation: file.transcriptPresentation,
269
274
  mediaType: file.mediaType,
270
275
  name: file.filename,
271
276
  })),
@@ -2,18 +2,20 @@ import type { LinkSafetyModalProps } from "streamdown"
2
2
  import * as React from "react"
3
3
 
4
4
  import { Button } from "../ui/button"
5
- import {
6
- Dialog,
7
- DialogContent,
8
- DialogDescription,
9
- DialogFooter,
10
- DialogHeader,
11
- DialogTitle,
12
- } from "../ui/dialog"
13
5
 
14
6
  export function ExternalLinkDialog({ isOpen, onClose, onConfirm, url }: LinkSafetyModalProps) {
7
+ const dialogRef = React.useRef<HTMLDialogElement>(null)
8
+ const headingId = React.useId()
9
+ const descriptionId = React.useId()
15
10
  const [copied, setCopied] = React.useState(false)
16
11
 
12
+ React.useEffect(() => {
13
+ const dialog = dialogRef.current
14
+ if (!dialog) return
15
+ if (isOpen && !dialog.open) dialog.showModal()
16
+ if (!isOpen && dialog.open) dialog.close()
17
+ }, [isOpen])
18
+
17
19
  const close = () => {
18
20
  setCopied(false)
19
21
  onClose()
@@ -30,20 +32,28 @@ export function ExternalLinkDialog({ isOpen, onClose, onConfirm, url }: LinkSafe
30
32
  }
31
33
 
32
34
  return (
33
- <Dialog open={isOpen} onOpenChange={(open) => { if (!open) close() }}>
34
- <DialogContent className="max-h-[calc(100dvh-2rem)] min-w-0 overflow-hidden sm:max-w-md">
35
- <DialogHeader>
36
- <DialogTitle>Open external link?</DialogTitle>
37
- <DialogDescription>You’re about to visit an external website.</DialogDescription>
38
- </DialogHeader>
35
+ <dialog
36
+ aria-describedby={descriptionId}
37
+ aria-labelledby={headingId}
38
+ className="m-auto max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-md overflow-auto rounded-lg border bg-background p-0 text-foreground shadow-lg backdrop:bg-black/50"
39
+ onCancel={(event) => { event.preventDefault(); close() }}
40
+ onClick={(event) => { if (event.target === event.currentTarget) close() }}
41
+ ref={dialogRef}
42
+ >
43
+ <div className="grid gap-4 p-6">
44
+ <div className="grid gap-2">
45
+ <h2 className="text-lg leading-none font-semibold" id={headingId}>Open external link?</h2>
46
+ <p className="text-sm text-muted-foreground" id={descriptionId}>You’re about to visit an external website.</p>
47
+ </div>
39
48
  <div className="max-h-32 overflow-auto rounded-md bg-muted p-3 font-mono text-xs wrap-break-word">
40
49
  {url}
41
50
  </div>
42
- <DialogFooter>
43
- <Button variant="outline" onClick={() => void copyUrl()}>{copied ? "Copied" : "Copy link"}</Button>
44
- <Button onClick={openUrl}>Open link</Button>
45
- </DialogFooter>
46
- </DialogContent>
47
- </Dialog>
51
+ <div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
52
+ <Button onClick={close} type="button" variant="ghost">Cancel</Button>
53
+ <Button onClick={() => void copyUrl()} type="button" variant="outline">{copied ? "Copied" : "Copy link"}</Button>
54
+ <Button onClick={openUrl} type="button">Open link</Button>
55
+ </div>
56
+ </div>
57
+ </dialog>
48
58
  )
49
59
  }
@@ -10,7 +10,7 @@ import type { LinkSafetyConfig } from "streamdown"
10
10
 
11
11
  import { CollapsibleUserMessage } from "./collapsible-user-message"
12
12
  import { ExternalLinkDialog } from "./external-link-dialog"
13
- import type { Agents24ChatTimelineSlotProps } from "../../app"
13
+ import type { Agents24ChatTimelineSlotProps, Agents24ChatTimelineOptions } from "../../app"
14
14
 
15
15
  const linkSafety = {
16
16
  enabled: true,
@@ -33,12 +33,14 @@ export function MessageParts({
33
33
  message,
34
34
  getHitlActionState,
35
35
  isLoading,
36
+ timelineOptions,
36
37
  onHitlAction,
37
38
  Timeline = ScaffoldTimeline,
38
39
  }: {
39
40
  message: ChatMessage
40
41
  getHitlActionState: (part: ChatHitlPart) => AgentChatRuntimeHitlActionState | undefined
41
42
  isLoading: boolean
43
+ timelineOptions?: Agents24ChatTimelineOptions
42
44
  onHitlAction: (part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions) => Promise<void>
43
45
  Timeline?: React.ComponentType<Agents24ChatTimelineSlotProps>
44
46
  }) {
@@ -47,6 +49,7 @@ export function MessageParts({
47
49
  <Timeline
48
50
  getHitlActionState={getHitlActionState}
49
51
  isLoading={isLoading}
52
+ {...timelineOptions}
50
53
  message={message}
51
54
  onHitlAction={(part, response, options) => {
52
55
  void onHitlAction(part, response, options).catch(() => undefined)
@@ -38,6 +38,7 @@ export type {
38
38
  ChatHitlResponse,
39
39
  Agents24ChatScaffoldComponents,
40
40
  Agents24ChatTimelineSlotProps,
41
+ Agents24ChatTimelineOptions,
41
42
  Agents24ChatComposerSlotProps,
42
43
  } from "./app"
43
44
  export { TooltipProvider as Agents24ChatTooltipProvider }
@@ -20,7 +20,7 @@
20
20
  "tailwindcss": "4.3.3"
21
21
  },
22
22
  "source": "packages/agents24-chat-react/scaffold",
23
- "sha256": "0daf777bf4152d36ca52c27920d47830ede2ecccec51701e8de0dc4161211155",
23
+ "sha256": "29af42767ffef4611c3b4630377fe2fc6f5ca825bf67f1487edd1b17e076d884",
24
24
  "files": [
25
25
  "components.json",
26
26
  "host-styles.css",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-agents24-app",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "description": "Create a production-ready Agents24 React application.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "provenance": false
34
34
  },
35
35
  "dependencies": {
36
- "@agents24/cli": "0.3.37",
36
+ "@agents24/cli": "0.3.39",
37
37
  "@clack/prompts": "1.7.0",
38
38
  "shadcn": "4.13.1"
39
39
  },
package/versions.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "agents24": {
3
- "@agents24/client": "^0.2.24",
4
- "@agents24/react": "^0.2.30",
5
- "@agents24/chat-react": "^0.5.46",
6
- "@agents24/node": "^0.5.34"
3
+ "@agents24/client": "^0.2.26",
4
+ "@agents24/react": "^0.2.32",
5
+ "@agents24/chat-react": "^0.5.48",
6
+ "@agents24/node": "^0.5.36"
7
7
  },
8
8
  "runtime": {
9
9
  "next": "^16.3.4",