1- import type { MemoryStrategyType } from '../../../../schema' ;
1+ import type { MemoryStrategyType , StreamContentLevel } from '../../../../schema' ;
22import { AgentNameSchema } from '../../../../schema' ;
33import {
44 ConfirmReview ,
@@ -14,7 +14,7 @@ import { HELP_TEXT } from '../../constants';
1414import { useListNavigation , useMultiSelectNavigation } from '../../hooks' ;
1515import { generateUniqueName } from '../../utils' ;
1616import type { AddMemoryConfig } from './types' ;
17- import { EVENT_EXPIRY_OPTIONS , MEMORY_STEP_LABELS , MEMORY_STRATEGY_OPTIONS } from './types' ;
17+ import { CONTENT_LEVEL_OPTIONS , EVENT_EXPIRY_OPTIONS , MEMORY_STEP_LABELS , MEMORY_STRATEGY_OPTIONS } from './types' ;
1818import { useAddMemoryWizard } from './useAddMemoryWizard' ;
1919import React , { useMemo } from 'react' ;
2020
@@ -24,6 +24,11 @@ interface AddMemoryScreenProps {
2424 existingMemoryNames : string [ ] ;
2525}
2626
27+ const STREAMING_OPTIONS : SelectableItem [ ] = [
28+ { id : 'yes' , title : 'Yes' , description : 'Stream memory record events to a delivery target (e.g. Kinesis)' } ,
29+ { id : 'no' , title : 'No' , description : 'No streaming' } ,
30+ ] ;
31+
2732export function AddMemoryScreen ( { onComplete, onExit, existingMemoryNames } : AddMemoryScreenProps ) {
2833 const wizard = useAddMemoryWizard ( ) ;
2934
@@ -37,9 +42,17 @@ export function AddMemoryScreen({ onComplete, onExit, existingMemoryNames }: Add
3742 [ ]
3843 ) ;
3944
45+ const contentLevelItems : SelectableItem [ ] = useMemo (
46+ ( ) => CONTENT_LEVEL_OPTIONS . map ( opt => ( { id : opt . id , title : opt . title , description : opt . description } ) ) ,
47+ [ ]
48+ ) ;
49+
4050 const isNameStep = wizard . step === 'name' ;
4151 const isExpiryStep = wizard . step === 'expiry' ;
4252 const isStrategiesStep = wizard . step === 'strategies' ;
53+ const isStreamingStep = wizard . step === 'streaming' ;
54+ const isStreamArnStep = wizard . step === 'streamArn' ;
55+ const isContentLevelStep = wizard . step === 'contentLevel' ;
4356 const isConfirmStep = wizard . step === 'confirm' ;
4457
4558 const expiryNav = useListNavigation ( {
@@ -58,6 +71,20 @@ export function AddMemoryScreen({ onComplete, onExit, existingMemoryNames }: Add
5871 requireSelection : false ,
5972 } ) ;
6073
74+ const streamingNav = useListNavigation ( {
75+ items : STREAMING_OPTIONS ,
76+ onSelect : item => wizard . setStreamingEnabled ( item . id === 'yes' ) ,
77+ onExit : ( ) => wizard . goBack ( ) ,
78+ isActive : isStreamingStep ,
79+ } ) ;
80+
81+ const contentLevelNav = useListNavigation ( {
82+ items : contentLevelItems ,
83+ onSelect : item => wizard . setContentLevel ( item . id as StreamContentLevel ) ,
84+ onExit : ( ) => wizard . goBack ( ) ,
85+ isActive : isContentLevelStep ,
86+ } ) ;
87+
6188 useListNavigation ( {
6289 items : [ { id : 'confirm' , title : 'Confirm' } ] ,
6390 onSelect : ( ) => onComplete ( wizard . config ) ,
@@ -67,14 +94,29 @@ export function AddMemoryScreen({ onComplete, onExit, existingMemoryNames }: Add
6794
6895 const helpText = isStrategiesStep
6996 ? 'Space toggle · Enter confirm · Esc back'
70- : isExpiryStep
97+ : isExpiryStep || isStreamingStep || isContentLevelStep
7198 ? HELP_TEXT . NAVIGATE_SELECT
7299 : isConfirmStep
73100 ? HELP_TEXT . CONFIRM_CANCEL
74101 : HELP_TEXT . TEXT_INPUT ;
75102
76103 const headerContent = < StepIndicator steps = { wizard . steps } currentStep = { wizard . step } labels = { MEMORY_STEP_LABELS } /> ;
77104
105+ const confirmFields = useMemo (
106+ ( ) => [
107+ { label : 'Name' , value : wizard . config . name } ,
108+ { label : 'Event Expiry' , value : `${ wizard . config . eventExpiryDuration } days` } ,
109+ { label : 'Strategies' , value : wizard . config . strategies . map ( s => s . type ) . join ( ', ' ) || 'None' } ,
110+ ...( wizard . config . streaming
111+ ? [
112+ { label : 'Stream ARN' , value : wizard . config . streaming . dataStreamArn } ,
113+ { label : 'Content Level' , value : wizard . config . streaming . contentLevel } ,
114+ ]
115+ : [ { label : 'Streaming' , value : 'Disabled' } ] ) ,
116+ ] ,
117+ [ wizard . config ]
118+ ) ;
119+
78120 return (
79121 < Screen title = "Add Memory" onExit = { onExit } helpText = { helpText } headerContent = { headerContent } >
80122 < Panel >
@@ -109,15 +151,36 @@ export function AddMemoryScreen({ onComplete, onExit, existingMemoryNames }: Add
109151 />
110152 ) }
111153
112- { isConfirmStep && (
113- < ConfirmReview
114- fields = { [
115- { label : 'Name' , value : wizard . config . name } ,
116- { label : 'Event Expiry' , value : `${ wizard . config . eventExpiryDuration } days` } ,
117- { label : 'Strategies' , value : wizard . config . strategies . map ( s => s . type ) . join ( ', ' ) || 'None' } ,
118- ] }
154+ { isStreamingStep && (
155+ < WizardSelect
156+ title = "Enable memory record streaming?"
157+ description = "Stream memory record lifecycle events to a delivery target"
158+ items = { STREAMING_OPTIONS }
159+ selectedIndex = { streamingNav . selectedIndex }
160+ />
161+ ) }
162+
163+ { isStreamArnStep && (
164+ < TextInput
165+ key = "streamArn"
166+ prompt = "Delivery target ARN (e.g. Kinesis stream)"
167+ initialValue = ""
168+ onSubmit = { wizard . setStreamArn }
169+ onCancel = { ( ) => wizard . goBack ( ) }
170+ customValidation = { value => value . startsWith ( 'arn:' ) || 'Must be a valid ARN (starts with arn:)' }
119171 />
120172 ) }
173+
174+ { isContentLevelStep && (
175+ < WizardSelect
176+ title = "Stream content level"
177+ description = "What data to include in stream events"
178+ items = { contentLevelItems }
179+ selectedIndex = { contentLevelNav . selectedIndex }
180+ />
181+ ) }
182+
183+ { isConfirmStep && < ConfirmReview fields = { confirmFields } /> }
121184 </ Panel >
122185 </ Screen >
123186 ) ;
0 commit comments