├── .eslintrc.json ├── .gitignore ├── .npmrc ├── .nvmrc ├── AmazonQ.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DEPLOYMENT.md ├── INVENTORY.md ├── LICENSE ├── NOTICE ├── README.md ├── amplify.yml ├── amplify ├── agents │ ├── maintenance │ │ ├── lambda │ │ │ ├── createCMMSKeyEquipment-Location.sql │ │ │ ├── createCMMSKeyEquipment-Type.sql │ │ │ ├── createCMMSTableBusinessUnits.sql │ │ │ ├── createCMMSTableEquipment.sql │ │ │ ├── createCMMSTableEquipmentTypes.sql │ │ │ ├── createCMMSTableLocationTypes.sql │ │ │ ├── createCMMSTableLocations.sql │ │ │ ├── createCMMSTableMaintTypes.sql │ │ │ ├── createCMMSTableMaintenance.sql │ │ │ ├── createCMMSTableStatusTypes.sql │ │ │ ├── deleteCMMSDataBusinessUnits.sql │ │ │ ├── deleteCMMSDataEquipment.sql │ │ │ ├── deleteCMMSDataEquipmentTypes.sql │ │ │ ├── deleteCMMSDataLocationTypes.sql │ │ │ ├── deleteCMMSDataLocations.sql │ │ │ ├── deleteCMMSDataMaintTypes.sql │ │ │ ├── deleteCMMSDataMaintenance.sql │ │ │ ├── deleteCMMSDataStatusTypes.sql │ │ │ ├── index.js │ │ │ ├── insertCMMSDataBusinessUnits.sql │ │ │ ├── insertCMMSDataEquipment.sql │ │ │ ├── insertCMMSDataEquipmentTypes.sql │ │ │ ├── insertCMMSDataLocationTypes.sql │ │ │ ├── insertCMMSDataLocations.sql │ │ │ ├── insertCMMSDataMaintTypes.sql │ │ │ ├── insertCMMSDataMaintenanceDS.sql │ │ │ ├── insertCMMSDataMaintenanceINS.sql │ │ │ ├── insertCMMSDataMaintenanceMS.sql │ │ │ ├── insertCMMSDataStatusTypes.sql │ │ │ └── package.json │ │ └── maintenanceAgent.ts │ ├── petrophysics │ │ └── petrophysics.ts │ ├── petrophysicsAgent │ │ └── petrophysicsAgent.ts │ ├── production │ │ └── productionAgent.ts │ └── regulatory │ │ └── regulatoryAgent.ts ├── auth │ └── resource.ts ├── backend.ts ├── constructs │ ├── bedrockKnoledgeBase.ts │ └── bedrockKnowledgeBase.ts ├── custom │ ├── appConfigurator.ts │ └── cdkNagHandler.ts ├── data │ ├── invokeBedrockModel.js │ ├── listBedrockAgentAliasIds.js │ ├── listBedrockAgents.js │ ├── publishMessageStreamChunk.js │ ├── receiveMessageStreamChunk.js │ └── resource.ts ├── env │ └── get-structured-output.ts ├── functions │ ├── addIamDirectiveToAllAssets.ts │ ├── configureProdDb │ │ ├── index.ts │ │ └── sqlStatements.ts │ ├── convertPdfToYaml │ │ └── index.ts │ ├── getStructuredOutputFromLangchain.ts │ ├── graphql │ │ ├── API.ts │ │ ├── mutations.ts │ │ ├── queries.ts │ │ └── subscriptions.ts │ ├── invokeBedrockAgent.ts │ ├── planAndExecuteAgent │ │ ├── index.ts │ │ └── toolBox.ts │ ├── preSignUp │ │ ├── handler.ts │ │ └── resource.ts │ ├── productionAgentFunction │ │ ├── index.ts │ │ └── toolBox.ts │ ├── recordTableDefAndStartKBIngestion │ │ └── index.ts │ ├── text2SQL │ │ └── maintenanceAgentAG.py │ └── utils │ │ ├── amplifyUtils.ts │ │ ├── cdkUtils.ts │ │ ├── pdfUtils.ts │ │ └── sdkUtils.ts ├── package.json ├── storage │ └── resource.ts └── tsconfig.json ├── assets └── images │ ├── A4E-Customer-Benefits.png │ ├── A4E-Deploy01.png │ ├── A4E-Deploy02.png │ ├── A4E-Deploy03.png │ ├── A4E-Deploy04.png │ ├── A4E-Deploy05.png │ ├── A4E-Deploy06.png │ ├── A4E-Deploy07.png │ ├── A4E-Deploy08.png │ ├── A4E-Deploy09.png │ ├── A4E-Deploy10.png │ ├── A4E-Deploy11.png │ ├── A4E-Deploy12.png │ ├── A4E-Deploy13.png │ ├── A4E-Deploy14.png │ ├── A4E-Deploy15.png │ ├── A4E-Deploy16.png │ ├── A4E-Deploy17.png │ ├── A4E-Deploy18.png │ ├── A4E-Deploy19.png │ ├── A4E-Deploy20.png │ ├── A4E-Deploy21.png │ ├── A4E-Deploy22.png │ ├── A4E-Deploy23.png │ ├── A4E-Deploy24.png │ ├── A4E-Deploy25.png │ ├── A4E-Deploy26.png │ ├── A4E-Deploy27.png │ ├── A4E-Deploy28.png │ ├── A4E-Deploy29.png │ ├── A4E-Deploy30.png │ ├── A4E-Deploy31.png │ ├── A4E-Deploy32.png │ ├── A4E-Deploy33.png │ ├── A4E-Deploy34.png │ ├── A4E-Deploy35.png │ ├── A4E-Deploy36.png │ ├── A4E-Deploy37.png │ ├── A4E-Deploy38.png │ ├── A4E-Maintenance-Agent.png │ ├── A4E-Open-Source-Architecture.png │ ├── A4E-ProductionAgentScreenShot.png │ └── A4E-Reference-Architecture.png ├── next.config.mjs ├── package-lock.json ├── package.json ├── postcss.config.mjs ├── sampleData ├── maintenance-agent │ ├── Inspections │ │ └── PSV Testing Procedure.html │ ├── Sandy Point Process Diagram.pdf │ ├── cmms │ │ ├── CMMS_Foreign_Keys.csv │ │ ├── CMMS_Nullable_Required_Columns.csv │ │ └── CMMS_Primary_Keys.csv │ ├── handover │ │ ├── SP Shift Handover BIO 2024-09-18 AM.docx │ │ ├── SP Shift Handover BIO 2024-09-18 PM.docx │ │ ├── SP Shift Handover BIO 2024-10-31 AM.docx │ │ ├── SP Shift Handover BIO 2024-10-31 PM.docx │ │ ├── SP Shift Handover COK 2024-10-06 AM.docx │ │ ├── SP Shift Handover CRK 2024-09-18 PM.docx │ │ ├── SP Shift Handover DST 2024-09-18 AM.docx │ │ ├── SP Shift Handover DST 2024-09-18 PM.docx │ │ ├── SP Shift Handover DST 2024-09-25 PM.docx │ │ ├── SP Shift Handover DST 2024-09-26 AM.docx │ │ ├── SP Shift Handover DST 2024-10-06 PM.docx │ │ ├── SP Shift Handover FCC 2024-10-07 PM.docx │ │ └── SP Shift Handover TRT 2024-10-07 AM.docx │ ├── pigging │ │ ├── Photo-5-Aerial-view.png │ │ ├── Pigging Report - Biloea Sep152024.docx │ │ ├── Pigging Report - Chinchilla Jul292024.docx │ │ ├── Pigging Report - Dalby Jul152024.docx │ │ ├── Pigging Report - Wallumbilla Jul12024.docx │ │ ├── Pigging Summary Report - Wallumbilla Gladstone Pipeline.pdf │ │ └── Typical Pigging Job Estimate 150km.docx │ └── repair │ │ ├── EcoSafe Chinchilla HSE Testing.pdf │ │ ├── PRS Leak Repair Invoice.pdf │ │ └── Root Cause Analysis Report - Pipeline Leak.pdf ├── petrophysics-agent │ ├── DHI.docx │ ├── Smit_03.pdf │ └── dhananjay_paper.pdf ├── production-agent │ ├── structured-data-files │ │ ├── monthly_production │ │ │ └── api=30-045-29202 │ │ │ │ └── production.csv │ │ └── pricing │ │ │ └── pricing.csv │ └── well-files │ │ └── field=SanJuanEast │ │ └── api=30-045-29202 │ │ ├── 30-045-29202_48587.pdf │ │ ├── 30-045-29202_48588.pdf │ │ ├── 30-045-29202_48589.pdf │ │ ├── 30-045-29202_48590.pdf │ │ ├── 30-045-29202_48591.pdf │ │ ├── 30-045-29202_48592.pdf │ │ ├── 30-045-29202_48593.pdf │ │ ├── 3003921992_19_wf.pdf │ │ ├── 30045085870000_07_09_2020_03_47_23.pdf │ │ ├── 30045292020000_11_wf.pdf │ │ ├── 30045292020000_12_wf.pdf │ │ ├── 30045292020000_13_wf.pdf │ │ ├── 30045292020000_14_wf.pdf │ │ ├── 3004529202_10_wf.pdf │ │ └── 3004529202_9_wf.pdf └── regulatory-agent │ ├── Bureau of Land Management-BLM │ ├── 2017-28211.pdf │ ├── 2023-11742.pdf │ ├── 2024-06827.pdf │ ├── CFR-2023-title43-vol2-part3100.pdf │ ├── CFR-2023-title43-vol2-part3160.pdf │ ├── CFR-2023-title43-vol2-part3170.pdf │ ├── OO_3173_FAQ_1.pdf │ ├── Onshore Order 3.pdf │ └── Order_3.pdf │ ├── Bureau of Safety and Environmenatl Enforcement-BSEE │ ├── 30 CFR Part 250 (up to date as of 7-05-2024).pdf │ ├── 30 CFR Part 250 Subpart E (up to date as of 7-08-2024).pdf │ ├── 30 CFR Part 250 Subpart F (up to date as of 7-08-2024).pdf │ ├── 30 CFR Part 250 Subpart L (up to date as of 7-08-2024).pdf │ ├── 30 CFR Part 250 Subpart Q (up to date as of 7-08-2024).pdf │ ├── 30 CFR Part 250 Subpart S (up to date as of 7-08-2024).pdf │ ├── 30 CFR Part 550 Subpart A (up to date as of 7-08-2024).pdf │ ├── 30 CFR Part 550 Subpart B (up to date as of 7-08-2024).pdf │ └── 30 CFR Part 550 Subpart D (up to date as of 7-08-2024).pdf │ ├── Environmental Protection Agency-EPA │ ├── 40 CFR Part 112 (up to date as of 7-08-2024).pdf │ ├── 40 CFR Part 144 (up to date as of 7-08-2024).pdf │ ├── 40 CFR Part 148 (up to date as of 7-08-2024).pdf │ ├── 40 CFR Part 435 (up to date as of 7-08-2024).pdf │ ├── 40 CFR Part 60 Subpart OOOOa (up to date as of 7-08-2024).pdf │ ├── 40 CFR Part 63 Subpart HH (up to date as of 7-08-2024).pdf │ ├── 40 CFR Part 63 Subpart HHH (up to date as of 7-08-2024).pdf │ ├── 45Q-primer-Carbon-Capture-Coalition.pdf │ ├── CFR-2023-title40-vol23-part98.pdf │ ├── IF11455.pdf │ ├── ejincwa404_factsheet_2024.pdf │ └── safe_drinking_water_act-title_xiv_of_public_health_service_act.pdf │ ├── Federal Energy Regulatory Comission-FERC │ ├── CFR-2023-title18-vol1-part157.pdf │ └── CFR-2023-title18-vol1-part284.pdf │ ├── Occupational Safety and Health Administration-OSHA │ ├── 2023-04-cpl-04.pdf │ ├── 21-04_CPL_04.pdf │ ├── 404_reg_authority_fact_sheet.pdf │ ├── CFR-2024-title10-vol2.pdf │ ├── CFR-2024-title10-vol3.pdf │ ├── CFR-2024-title10-vol4.pdf │ ├── CPL-02-07-13O.pdf │ └── CPL_20-04_04-01.pdf │ ├── Pipeline and Hazardous Marterials Safety Administration-PHMSA │ ├── CFR-2023-title49-vol2-part171.pdf │ ├── CFR-2023-title49-vol2-part172.pdf │ ├── CFR-2023-title49-vol2-part177.pdf │ ├── CFR-2023-title49-vol3-part180.pdf │ ├── CFR-2023-title49-vol3-part192.pdf │ ├── CFR-2023-title49-vol3-part195.pdf │ └── CFR-2023-title49-vol3-part198.pdf │ └── financial-aspects-offshore-decom-brazil-in-the-light-of-tlo-luciana-braga-helder-queiroz (1).pdf ├── scripts ├── productionAgentScript.md └── uploadCsvProductionData.ts ├── src ├── a4e-logo.png ├── app │ ├── chat │ │ ├── [chatSessionId] │ │ │ └── page.tsx │ │ └── page.tsx │ ├── common │ │ ├── adjust-body-padding.ts │ │ ├── apply-mode.ts │ │ ├── aws-region-utils.ts │ │ ├── breadcrumbs.ts │ │ ├── columnDefinitionsHelper.ts │ │ ├── cookie-consent.ts │ │ ├── localStorage.ts │ │ ├── parse-property-filter.ts │ │ ├── property-filter-operators.ts │ │ ├── s3-resource-selector │ │ │ ├── mock-data.ts │ │ │ └── mock-request.ts │ │ ├── types.ts │ │ └── use-query-params.ts │ ├── favicon.ico │ ├── files │ │ ├── [...s3Key] │ │ │ └── page.tsx │ │ ├── page.module.css │ │ └── page.tsx │ ├── fonts │ │ ├── GeistMonoVF.woff │ │ └── GeistVF.woff │ ├── globals.scss │ ├── layout.tsx │ ├── login │ │ └── page.tsx │ ├── page.tsx │ ├── press-release │ │ └── page.tsx │ └── styles │ │ ├── base.scss │ │ ├── chat.scss │ │ ├── form.scss │ │ ├── onboarding.scss │ │ ├── product-page.scss │ │ ├── table-date-filter.scss │ │ ├── table-select.scss │ │ ├── top-navigation.scss │ │ └── wizard.scss ├── components │ ├── ChatBox.tsx │ ├── ChatMessage.tsx │ ├── ChatMessageElements.tsx │ ├── ClientLayout.tsx │ ├── ConfigureAmplify.tsx │ ├── ContextProviders.tsx │ ├── DropDownMenu.tsx │ ├── SideBar.tsx │ ├── StorageBrowser.tsx │ ├── TopNavBar.tsx │ ├── UserAttributesProvider.tsx │ └── WithAuth.tsx ├── hero-img.jpg ├── hero-img.png ├── logo-small-top-navigation.svg ├── styles │ └── chat-ui.module.scss └── utils │ ├── amplify-utils.ts │ ├── chart-utils.ts │ ├── config.ts │ ├── date-utils.ts │ ├── rateLimiter.ts │ ├── types.ts │ └── ui-utils.tsx ├── tailwind.config.ts ├── test ├── integration │ ├── testAddIamDirective.ts │ ├── testApi.ts │ ├── testConfigureProdDb.ts │ ├── testConvertPdfToImageTool.ts │ ├── testConvertPdfToYaml.ts │ ├── testGetPlanAndExecuteResponse.ts │ ├── testGetProductionAgentResponse.ts │ ├── testGetStructuredOutputRespose.ts │ ├── testModifyPlanAndExecute.ts │ └── testRetrieveTableDefs.ts ├── unit │ ├── testAthenaFederatedQuery.ts │ ├── testBedrockKnowlegeBaseRetriever.ts │ ├── testGetPlotTool.ts │ ├── testGetStructuredOutput.ts │ ├── testInvokeBedrockAgent.ts │ ├── testInvokeProductionAgentFromPlanAndExecute.ts │ └── testWellTableTool.ts └── utils.ts └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["next/core-web-vitals", "next/typescript"] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | /tmp 4 | cdk.context.json 5 | cdk.out 6 | **/*.zip 7 | 8 | # dependencies 9 | /node_modules 10 | /.pnp 11 | .pnp.js 12 | .yarn/install-state.gz 13 | 14 | # testing 15 | /coverage 16 | 17 | # next.js 18 | /.next/ 19 | /out/ 20 | 21 | # production 22 | /build 23 | 24 | # misc 25 | .DS_Store 26 | *.pem 27 | 28 | # debug 29 | npm-debug.log* 30 | yarn-debug.log* 31 | yarn-error.log* 32 | 33 | # local env files 34 | .env*.local 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | 43 | # amplify 44 | .amplify 45 | amplify_outputs* 46 | amplifyconfiguration* 47 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | strict-ssl=false 3 | fetch-retries=5 4 | fetch-retry-factor=2 5 | fetch-retry-mintimeout=10000 6 | fetch-retry-maxtimeout=60000 7 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20.9.0 2 | -------------------------------------------------------------------------------- /AmazonQ.md: -------------------------------------------------------------------------------- 1 | # Agents4Energy Dependency and Build Configuration 2 | 3 | ## Identified Issues 4 | 5 | 1. **Node.js Version Incompatibility** 6 | - Some packages require Node.js v20+ or v22+ 7 | - Build environment was using Node.js v18.20.6 8 | - Affected packages: path-scurry@2.0.0, minimatch@10.0.1 9 | 10 | 2. **Missing Build Script** 11 | - The build process was trying to run `npm run build:backend` 12 | - This script doesn't exist in package.json 13 | 14 | 3. **Package Access Issues** 15 | - 403 Forbidden errors when trying to download npm packages 16 | - Specifically for camelcase@6.3.0 and camel-case@4.1.2 17 | 18 | 4. **AWS Amplify Deprecation Warnings** 19 | - Multiple @aws-amplify/* packages showed deprecation warnings 20 | - Message: "backend-cli 1.6.0 does not work with Amplify Hosting service" 21 | 22 | ## Applied Solutions 23 | 24 | 1. **Build Configuration Alignment** 25 | - Synchronized package.json and amplify.yml with main branch 26 | - Using standard Amplify build configuration with npm ci 27 | - Removed custom build:backend script 28 | 29 | 2. **Dependency Management** 30 | - Using npm ci with cache for faster, more reliable builds 31 | - Using --prefer-offline flag to prioritize cached packages 32 | - Properly configured cache paths for node_modules and .npm 33 | 34 | ## Best Practices for Dependency Management 35 | 36 | 1. **Version Pinning** 37 | - Use exact versions for critical dependencies 38 | - Consider using package locks for consistent installations 39 | 40 | 2. **Regular Updates** 41 | - Run `npm audit` regularly to check for vulnerabilities 42 | - Use `npm update` to keep dependencies current 43 | - Consider automated dependency updates with tools like Dependabot 44 | 45 | 3. **Build Environment Consistency** 46 | - Use `.nvmrc` or similar to specify Node.js version 47 | - Document environment requirements in README 48 | - Consider containerization for complete environment control 49 | 50 | 4. **Amplify-Specific Recommendations** 51 | - Keep Amplify CLI versions aligned with Amplify Hosting requirements 52 | - Test locally before deploying to catch compatibility issues 53 | - Review Amplify documentation for version compatibility guidance 54 | 55 | ## References 56 | - [AWS Amplify Documentation](https://docs.aws.amazon.com/amplify/) 57 | - [Node.js Release Schedule](https://nodejs.org/en/about/releases/) 58 | - [npm Documentation](https://docs.npmjs.com/) 59 | - [AWS Amplify Troubleshooting Guide](https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html) 60 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Agents4Energy is a trademark of Amazon.com, Inc. 2 | 3 | This project may contain trademarks or logos for projects, products, or services. Authorized use of [Agents4Energy trademarks or logos 4 | is subject to and must follow Amazon's Trademark Guidelines or written permission. Use of Agents4Energy trademarks or logos does not imply 5 | any affiliation with or endorsement by Amazon. 6 | 7 | Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. -------------------------------------------------------------------------------- /amplify.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | backend: 3 | phases: 4 | preBuild: 5 | commands: 6 | - echo "Build environment is $CODEBUILD_BUILD_IMAGE" 7 | # - aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws 8 | build: 9 | commands: 10 | - npm ci --cache .npm --prefer-offline 11 | - npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID --debug 12 | frontend: 13 | phases: 14 | build: 15 | commands: 16 | - npm run build 17 | artifacts: 18 | baseDirectory: .next 19 | files: 20 | - '**/*' 21 | cache: 22 | paths: 23 | - .next/cache/**/* 24 | - .npm/**/* 25 | - node_modules/**/* -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSKeyEquipment-Location.sql: -------------------------------------------------------------------------------- 1 | DO \$\$ 2 | BEGIN 3 | IF NOT EXISTS ( 4 | SELECT 1 5 | FROM information_schema.table_constraints 6 | WHERE table_schema = 'public' -- Adjust schema name if necessary 7 | AND table_name = 'equipment' 8 | AND constraint_name = 'installlocationid_fk' 9 | ) THEN 10 | ALTER TABLE equipment 11 | ADD CONSTRAINT installlocationid_fk FOREIGN KEY (installlocationid) 12 | REFERENCES locations (locationid) MATCH SIMPLE 13 | ON UPDATE NO ACTION 14 | ON DELETE NO ACTION 15 | NOT VALID; 16 | END IF; 17 | END \$\$; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSKeyEquipment-Type.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Equipment ( 2 | EquipID varchar(20) NOT NULL 3 | , EquipTypeID int NOT NULL 4 | , EquipName varchar(100) NOT NULL 5 | , EquipLongDesc varchar(250) 6 | , Manufacturer varchar(50) 7 | , Model varchar(50) 8 | , ManfYear int 9 | , WebLink varchar(250) 10 | , SerialNum varchar(50) 11 | , EquipWeight decimal(10,2) 12 | , InstallLocationID int 13 | , lat decimal(10,6) 14 | , lon decimal(10,6) 15 | , SafetyCritical boolean NOT NULL 16 | , StatusID varchar(3) NOT NULL 17 | , ServiceDateStart date 18 | , ServiceDateEnd date 19 | , CreatedBy varchar(50) DEFAULT 'AWS' 20 | , CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP 21 | , UpdatedBy varchar(50) DEFAULT 'AWS' 22 | , UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP 23 | , CONSTRAINT equipment_pkey PRIMARY KEY (equipid) 24 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableBusinessUnits.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS BusinessUnits ( 2 | BUID varchar(3) NOT NULL, 3 | BUName varchar(100) NOT NULL, 4 | CreatedBy varchar(50) DEFAULT 'AWS', 5 | CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 6 | UpdatedBy varchar(50) DEFAULT 'AWS', 7 | UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 8 | CONSTRAINT businessunits_pkey PRIMARY KEY (BUID) 9 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableEquipment.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Equipment ( 2 | EquipID varchar(20) NOT NULL 3 | , EquipTypeID int NOT NULL 4 | , EquipName varchar(100) NOT NULL 5 | , EquipLongDesc varchar(2048) 6 | , Manufacturer varchar(50) 7 | , Model varchar(50) 8 | , ManfYear int 9 | , WebLink varchar(250) 10 | , SerialNum varchar(50) 11 | , EquipWeight decimal(10,2) 12 | , InstallLocationID int 13 | , lat decimal(10,6) 14 | , lon decimal(10,6) 15 | , SafetyCritical boolean NOT NULL 16 | , StatusID varchar(3) NOT NULL 17 | , ServiceDateStart date 18 | , ServiceDateEnd date 19 | , CreatedBy varchar(50) DEFAULT 'AWS' 20 | , CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP 21 | , UpdatedBy varchar(50) DEFAULT 'AWS' 22 | , UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP 23 | , CONSTRAINT equipment_pkey PRIMARY KEY (equipid) 24 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableEquipmentTypes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS EquipmentTypes ( 2 | EquipTypeID int NOT NULL, 3 | EquipTypeName varchar(100) NOT NULL, 4 | CreatedBy varchar(50) DEFAULT 'AWS', 5 | CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 6 | UpdatedBy varchar(50) DEFAULT 'AWS', 7 | UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 8 | CONSTRAINT equipmenttypes_pkey PRIMARY KEY (EquipTypeID) 9 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableLocationTypes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS LocationTypes ( 2 | LocTypeID varchar(3) NOT NULL, 3 | LocTypeName varchar(100) NOT NULL, 4 | CreatedBy varchar(50) DEFAULT 'AWS', 5 | CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 6 | UpdatedBy varchar(50) DEFAULT 'AWS', 7 | UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 8 | CONSTRAINT locationtypes_pkey PRIMARY KEY (LocTypeID) 9 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableLocations.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Locations ( 2 | LocationID int NOT NULL 3 | , LocTypeID varchar(3) NOT NULL REFERENCES LocationTypes(LocTypeID) 4 | , LocName varchar(100) NOT NULL 5 | , BusinessUnit varchar(3) REFERENCES businessunits(buid) 6 | , Facility int REFERENCES locations(locationid) 7 | , Section varchar(20) 8 | , WorkCenter varchar(20) 9 | , LocMgrID varchar(20) 10 | , Latitude float 11 | , Longitude float 12 | , Address1 varchar(100) 13 | , Address2 varchar(100) 14 | , City varchar(100) 15 | , State varchar(100) 16 | , Zip varchar(20) 17 | , Country varchar(100) 18 | , Phone varchar(20) 19 | , Fax varchar(20) 20 | , Email varchar(100) 21 | , CreatedBy varchar(50) DEFAULT 'AWS' 22 | , CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP 23 | , UpdatedBy varchar(50) DEFAULT 'AWS' 24 | , UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP 25 | , CONSTRAINT locations_pkey PRIMARY KEY (locationid) 26 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableMaintTypes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS MaintTypes ( 2 | MaintTypeID varchar(3) NOT NULL, 3 | MaintTypeName varchar(100) NOT NULL, 4 | CreatedBy varchar(50) DEFAULT 'AWS', 5 | CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 6 | UpdatedBy varchar(50) DEFAULT 'AWS', 7 | UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 8 | CONSTRAINT mainttypes_pkey PRIMARY KEY (MaintTypeID) 9 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableMaintenance.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Maintenance ( 2 | MaintID int NOT NULL 3 | , MaintTypeID varchar(3) NOT NULL REFERENCES mainttypes(mainttypeid) 4 | , EquipID varchar(20) 5 | , MaintName varchar(100) NOT NULL 6 | , MaintLongDesc varchar(2048) 7 | , WorkOrderID varchar(20) 8 | , EffortHours int 9 | , EstCost numeric(10,2) 10 | , DowntimeReq boolean 11 | , TechnicianID varchar(50) 12 | , ResponsibleID varchar(50) 13 | , RequiresPermit boolean 14 | , StatusID varchar(3) NOT NULL REFERENCES statustypes(statusid) 15 | , PlannedDateStart date 16 | , PlannedDateEnd date 17 | , ActualDateStart date 18 | , ActualDateEnd date 19 | , CreatedBy varchar(50) DEFAULT 'AWS' 20 | , CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP 21 | , UpdatedBy varchar(50) DEFAULT 'AWS' 22 | , UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP 23 | , CONSTRAINT maintenance_pkey PRIMARY KEY (maintid) 24 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/createCMMSTableStatusTypes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS StatusTypes ( 2 | StatusID varchar(3) NOT NULL, 3 | StatusName varchar(100) NOT NULL, 4 | CreatedBy varchar(50) DEFAULT 'AWS', 5 | CreatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 6 | UpdatedBy varchar(50) DEFAULT 'AWS', 7 | UpdatedDate timestamp DEFAULT CURRENT_TIMESTAMP, 8 | CONSTRAINT statustypes_pkey PRIMARY KEY (StatusID) 9 | ); -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataBusinessUnits.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM businessunits; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataEquipment.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM equipment; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataEquipmentTypes.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM equipmenttypes; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataLocationTypes.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM locationtypes; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataLocations.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM locations; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataMaintTypes.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM mainttypes; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataMaintenance.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM maintenance; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/deleteCMMSDataStatusTypes.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM statustypes; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/index.js: -------------------------------------------------------------------------------- 1 | const { RDSDataClient, ExecuteStatementCommand } = require('@aws-sdk/client-rds-data'); 2 | const rdsDataClient = new RDSDataClient(); 3 | 4 | const fs = require('fs'); 5 | 6 | // Read SQL commands from files 7 | const sqlCommands = [ 8 | // Provide list of .sql files in the correct order to run against CMMS database 9 | fs.readFileSync('./createCMMSTableEquipmentTypes.sql', 'utf8'), 10 | fs.readFileSync('./createCMMSTableLocationTypes.sql', 'utf8'), 11 | fs.readFileSync('./createCMMSTableMaintTypes.sql', 'utf8'), 12 | fs.readFileSync('./createCMMSTableStatusTypes.sql', 'utf8'), 13 | fs.readFileSync('./createCMMSTableBusinessUnits.sql', 'utf8'), 14 | fs.readFileSync('./createCMMSTableLocations.sql', 'utf8'), 15 | fs.readFileSync('./createCMMSTableEquipment.sql', 'utf8'), 16 | fs.readFileSync('./createCMMSTableMaintenance.sql', 'utf8'), 17 | fs.readFileSync('./createCMMSKeyEquipment-Type.sql', 'utf8'), 18 | fs.readFileSync('./createCMMSKeyEquipment-Location.sql', 'utf8'), 19 | 20 | fs.readFileSync('./deleteCMMSDataMaintenance.sql', 'utf8'), 21 | fs.readFileSync('./deleteCMMSDataEquipment.sql', 'utf8'), 22 | fs.readFileSync('./deleteCMMSDataLocations.sql', 'utf8'), 23 | fs.readFileSync('./deleteCMMSDataBusinessUnits.sql', 'utf8'), 24 | fs.readFileSync('./deleteCMMSDataStatusTypes.sql', 'utf8'), 25 | fs.readFileSync('./deleteCMMSDataMaintTypes.sql', 'utf8'), 26 | fs.readFileSync('./deleteCMMSDataLocationTypes.sql', 'utf8'), 27 | fs.readFileSync('./deleteCMMSDataEquipmentTypes.sql', 'utf8'), 28 | 29 | fs.readFileSync('./insertCMMSDataEquipmentTypes.sql', 'utf8'), 30 | fs.readFileSync('./insertCMMSDataLocationTypes.sql', 'utf8'), 31 | fs.readFileSync('./insertCMMSDataMaintTypes.sql', 'utf8'), 32 | fs.readFileSync('./insertCMMSDataStatusTypes.sql', 'utf8'), 33 | fs.readFileSync('./insertCMMSDataBusinessUnits.sql', 'utf8'), 34 | fs.readFileSync('./insertCMMSDataLocations.sql', 'utf8'), 35 | fs.readFileSync('./insertCMMSDataEquipment.sql', 'utf8'), 36 | fs.readFileSync('./insertCMMSDataMaintenanceDS.sql', 'utf8'), 37 | fs.readFileSync('./insertCMMSDataMaintenanceMS.sql', 'utf8'), 38 | fs.readFileSync('./insertCMMSDataMaintenanceINS.sql', 'utf8'), 39 | ]; 40 | 41 | exports.handler = async (event) => { 42 | const { MAINT_DB_CLUSTER_ARN, MAINT_DB_SECRET_ARN, DEFAULT_DATABASE_NAME } = process.env; 43 | 44 | for (const sqlCommand of sqlCommands) { 45 | const params = { 46 | resourceArn: MAINT_DB_CLUSTER_ARN, 47 | secretArn: MAINT_DB_SECRET_ARN, 48 | database: DEFAULT_DATABASE_NAME, 49 | sql: sqlCommand 50 | }; 51 | 52 | console.log('Executing SQL command:', sqlCommand); 53 | 54 | const command = new ExecuteStatementCommand(params); 55 | try { 56 | await rdsDataClient.send(command); 57 | } catch (error) { 58 | console.error('Error executing SQL command:', error); 59 | } 60 | } 61 | }; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/insertCMMSDataBusinessUnits.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO businessunits (buid, buname) VALUES 2 | ('R', 'Refineries'), 3 | ('C', 'Petrochemicals'), 4 | ('T', 'Trading & Forecasting'), 5 | ('L', 'LNG Facilities'), 6 | ('P', 'Pipelines'), 7 | ('U', 'Upstream') 8 | ('N', 'Renewables') 9 | ; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/insertCMMSDataEquipmentTypes.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO equipmenttypes (equiptypeid, equiptypename) VALUES 2 | (1, 'Atmospheric Distillation Tower'), 3 | (2, 'Storage Tank'), 4 | (3, 'Heat Exchanger'), 5 | (4, 'Vacuum Distillation Tower'), 6 | (5, 'Air Cooler'), 7 | (6, 'Evaporator'), 8 | (7, 'Crude Oil Pump'), 9 | (8, 'Furnace'), 10 | (9, 'Hydrotreater'), 11 | (10, 'Hydrocracker'), 12 | (11, 'Coker'), 13 | (12, 'Catalytic Cracker'), 14 | (13, 'Reactor'), 15 | (14, 'Compressors'), 16 | (15, 'Horizontal Tank'), 17 | (16, 'Vertical Tank'), 18 | (17, 'Equipment Skid'), 19 | (18, 'Tanker Truck'), 20 | (20, 'Shipping Container'), 21 | (21, 'Desalter'), 22 | (22, 'Valve'), 23 | (23, 'Separator'), 24 | (24, 'Fractionator'), 25 | (25, 'Conveyor'), 26 | (51, 'Pig Trap'), 27 | (52, 'Compressor Station'), 28 | (53, 'Rectifier'), 29 | (54, 'Anode'), 30 | (55, 'Voltmeter'), 31 | (26, 'Wellhead and Christmas Tree'), 32 | (27, 'Pump Jack'), 33 | (28, 'Well Site Storage Tank'), 34 | (29, 'Separator'), 35 | (30, 'Heater Treater'), 36 | (31, 'Well Site Compressor'), 37 | (32, 'Remote Terminal Unit'), 38 | (33, 'Well Site Meter'), 39 | (34, 'Flare Stack'), 40 | (35, 'Well Site Electrical Equipment'), 41 | (36, 'Chemical Injection Skid'), 42 | (37, 'Well Site Piping and Valves'), 43 | (38, 'LACT Unit') 44 | ; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/insertCMMSDataLocationTypes.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO locationtypes (loctypeid, loctypename) VALUES 2 | ('FCL', 'Facility'), 3 | ('UNT', 'Unit'), 4 | ('OTH', 'Other'), 5 | ('WPD', 'Wellpad'), 6 | ('WEL', 'Well') 7 | ; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/insertCMMSDataMaintTypes.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO MaintTypes (MaintTypeID,MaintTypeName) VALUES 2 | ('CM','Corrective Maintenance'), 3 | ('PM','Preventative Maintenance'), 4 | ('INS','Inspection') 5 | ; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/insertCMMSDataStatusTypes.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO statustypes (statusid, statusname) VALUES 2 | ('NEW', 'New'), 3 | ('ASG', 'Assigned'), 4 | ('INP', 'In Progress'), 5 | ('BLK', 'Blocked'), 6 | ('COM', 'Complete'), 7 | ('VFD', 'Verified'), 8 | ('ACT', 'Active'), 9 | ('DCM', 'Decommissioned'), 10 | ('EXP', 'Inactive') 11 | ; -------------------------------------------------------------------------------- /amplify/agents/maintenance/lambda/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lambda-function", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "@aws-sdk/client-rds-data": "^3.0.0" 6 | } 7 | } -------------------------------------------------------------------------------- /amplify/auth/resource.ts: -------------------------------------------------------------------------------- 1 | // https://docs.amplify.aws/react/build-a-backend/functions/examples/email-domain-filtering/ 2 | 3 | import { defineAuth } from '@aws-amplify/backend'; 4 | import { preSignUp } from '../functions/preSignUp/resource'; 5 | 6 | /** 7 | * Define and configure your auth resource 8 | * @see https://docs.amplify.aws/gen2/build-a-backend/auth 9 | */ 10 | export const auth = defineAuth({ 11 | loginWith: { 12 | email: true, 13 | }, 14 | // // Currently there is a circular dependency issue whith this trigger Caused By: Deployment failed: Error [ValidationError]: Circular dependency between resources: [storage0EC3F24A, auth179371D7, data7552DF31, customStackD2225651, function1351588B] 15 | // // Possibly related to this issue: https://github.com/aws-amplify/amplify-backend/issues/1850 16 | // triggers: { 17 | // preSignUp 18 | // } 19 | }); 20 | -------------------------------------------------------------------------------- /amplify/custom/cdkNagHandler.ts: -------------------------------------------------------------------------------- 1 | import { Stack, NestedStack, Aspects } from 'aws-cdk-lib'; 2 | import { NagSuppressions } from 'cdk-nag' 3 | 4 | 5 | const applyStackSupperssions = (stack: Stack, suppressions: { id: string, reason: string }[]) => { 6 | NagSuppressions.addStackSuppressions(stack, suppressions); 7 | // Recursively apply suppressions to nested stacks 8 | const nestedStacks = stack.node.children 9 | .filter(child => child instanceof NestedStack) 10 | .map(child => child as NestedStack); 11 | 12 | for (const nestedStack of nestedStacks) { 13 | applyStackSupperssions(nestedStack, suppressions); 14 | } 15 | } 16 | 17 | export const cdkNagSupperssionsHandler = (stack: Stack) => { 18 | // Apply suppressions to the current stack 19 | const suppressions = [ 20 | { 21 | id: 'AwsSolutions-IAM4', 22 | reason: 'The lambda execution role must be able to dynamically create log groups, and so will have a * in the iam policy resource section' 23 | }, 24 | { 25 | id: 'AwsSolutions-IAM5', 26 | reason: 'The Lambda function must be able to get any object from the well file drive bucket, so a * in needed in the resource arn.' 27 | }, 28 | { 29 | id: 'AwsSolutions-L1', 30 | reason: `This lambda is created by s3Deployment from 'aws-cdk-lib/aws-s3-deployment'` 31 | }, 32 | { 33 | id: 'AwsSolutions-RDS10', 34 | reason: `This rds database in this sample is meant to be deleted and not for production traffic.` 35 | } 36 | ]; 37 | 38 | applyStackSupperssions(stack, suppressions) 39 | 40 | NagSuppressions.addResourceSuppressionsByPath( 41 | stack, 42 | `/${stack.stackName}/networkingStack/accessLogs/Resource`, 43 | [ 44 | { 45 | id: 'AwsSolutions-S1', 46 | reason: 'The AWS bucket which recieves access logs does not itself have access logs enabled due to recursion.' 47 | } 48 | ] 49 | ) 50 | 51 | NagSuppressions.addResourceSuppressionsByPath( 52 | stack, 53 | `/${stack.stackName}/data/amplifyData/AmplifyCodegenAssets/AmplifyCodegenAssetsBucket/Policy/Resource`, 54 | [ 55 | { 56 | id: 'AwsSolutions-S10', 57 | reason: 'The AWS bucket is created by AWS Amplify.' 58 | } 59 | ] 60 | ) 61 | 62 | NagSuppressions.addResourceSuppressionsByPath( 63 | stack, 64 | `/${stack.stackName}/data/amplifyData/AmplifyCodegenAssets/AmplifyCodegenAssetsBucket/Resource`, 65 | [ 66 | { 67 | id: 'AwsSolutions-S1', 68 | reason: 'The AWS bucket is created by AWS Amplify.' 69 | }, 70 | { 71 | id: 'AwsSolutions-S10', 72 | reason: 'The AWS bucket is created by AWS Amplify.' 73 | } 74 | ] 75 | ) 76 | } -------------------------------------------------------------------------------- /amplify/data/invokeBedrockModel.js: -------------------------------------------------------------------------------- 1 | export function request(ctx) { 2 | const { prompt } = ctx.args; 3 | 4 | return { 5 | resourcePath: `/model/anthropic.claude-3-sonnet-20240229-v1:0/invoke`, 6 | method: "POST", 7 | params: { 8 | headers: { 9 | "Content-Type": "application/json", 10 | }, 11 | body: { 12 | anthropic_version: "bedrock-2023-05-31", 13 | max_tokens: 1000, 14 | messages: [ 15 | { 16 | role: "user", 17 | content: [ 18 | { 19 | type: "text", 20 | text: `\n\nHuman:${prompt}\n\nAssistant:`, 21 | }, 22 | ], 23 | }, 24 | ], 25 | }, 26 | }, 27 | }; 28 | } 29 | 30 | export function response(ctx) { 31 | return { 32 | body: ctx.result.body, 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /amplify/data/listBedrockAgentAliasIds.js: -------------------------------------------------------------------------------- 1 | // https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_ListAgentAliases.html 2 | export function request(ctx) { 3 | const { agentId} = ctx.args; 4 | 5 | return { 6 | resourcePath: `/agents/${agentId}/agentaliases`, 7 | method: "POST", 8 | params: { 9 | headers: { 10 | "Content-Type": "application/json", 11 | }, 12 | body: {}, 13 | }, 14 | }; 15 | } 16 | 17 | export function response(ctx) { 18 | return { 19 | body: ctx.result.body, 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /amplify/data/listBedrockAgents.js: -------------------------------------------------------------------------------- 1 | // https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_ListAgents.html 2 | export function request(ctx) { 3 | return { 4 | resourcePath: `/agents`, 5 | method: "POST", 6 | params: { 7 | headers: { 8 | "Content-Type": "application/json", 9 | }, 10 | body: {}, 11 | }, 12 | }; 13 | } 14 | 15 | export function response(ctx) { 16 | return { 17 | body: ctx.result.body, 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /amplify/data/publishMessageStreamChunk.js: -------------------------------------------------------------------------------- 1 | // This handler simply passes through the arguments of the mutation through as the result 2 | export function request() { 3 | return {} 4 | } 5 | 6 | /** 7 | * @param {import('@aws-appsync/utils').Context} ctx 8 | */ 9 | export function response(ctx) { 10 | return ctx.args 11 | } -------------------------------------------------------------------------------- /amplify/data/receiveMessageStreamChunk.js: -------------------------------------------------------------------------------- 1 | import { util, extensions } from "@aws-appsync/utils" 2 | 3 | export function request() { return { payload: null } } 4 | 5 | 6 | export function response(ctx) { 7 | const filter = { 8 | chatSessionId: { 9 | beginsWith: ctx.args.chatSessionId 10 | } 11 | } 12 | 13 | extensions.setSubscriptionFilter(util.transform.toSubscriptionFilter(filter)) 14 | 15 | return null 16 | } -------------------------------------------------------------------------------- /amplify/env/get-structured-output.ts: -------------------------------------------------------------------------------- 1 | // Environment variables for the get-structured-output Lambda function 2 | export const env = { 3 | AMPLIFY_DATA_GRAPHQL_ENDPOINT: process.env.AMPLIFY_DATA_GRAPHQL_ENDPOINT, 4 | AWS_REGION: process.env.AWS_REGION, 5 | AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID, 6 | AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY, 7 | AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN, 8 | MODEL_ID: process.env.MODEL_ID 9 | }; 10 | -------------------------------------------------------------------------------- /amplify/functions/preSignUp/handler.ts: -------------------------------------------------------------------------------- 1 | import type { PreSignUpTriggerHandler } from 'aws-lambda'; 2 | import { env } from '$amplify/env/preSignUp'; 3 | 4 | export const handler: PreSignUpTriggerHandler = async (event) => { 5 | const email = event.request.userAttributes['email']; 6 | 7 | const allowedEmailSuffixes = (env.ALLOWED_EMAIL_SUFFIXES).split(",") 8 | 9 | for (const domainSuffix of allowedEmailSuffixes) { 10 | if (email.endsWith(domainSuffix)) { 11 | return event; 12 | } 13 | } 14 | 15 | throw new Error(`Invalid email domain. Email address ${event.request.userAttributes['email']} does not end with an allowed suffix: ${allowedEmailSuffixes}`); 16 | }; -------------------------------------------------------------------------------- /amplify/functions/preSignUp/resource.ts: -------------------------------------------------------------------------------- 1 | import { defineFunction } from '@aws-amplify/backend'; 2 | 3 | export const preSignUp = defineFunction({ 4 | name: 'preSignUp', 5 | environment:{ 6 | ALLOWED_EMAIL_SUFFIXES: ".com,@amazon.com,@amazon.co.uk,@amazon.de,@amazon.fr,@amazon.it,@amazon.es,@amazon.ca,@amazon.com.au,@amazon.com.br,@amazon.co.jp,@amazon.in,@amazon.cn,@amazon.com.mx,@amazon.nl,@amazon.pl,@amazon.se,@amazon.sg,@amazon.sa,@amazon.ae,@amazon.com.tr,@amazon.com.be" 7 | } 8 | }); -------------------------------------------------------------------------------- /amplify/functions/text2SQL/maintenanceAgentAG.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | import boto3 4 | from datetime import datetime 5 | 6 | rds_client = boto3.client('rds-data') 7 | database_name = os.environ.get('database_name') 8 | db_resource_arn = os.environ.get('db_resource_arn') 9 | db_credentials_secrets_arn = os.environ.get('db_credentials_secrets_arn') 10 | 11 | def get_tables(): 12 | sql = "select * from information_schema.tables where table_name not like 'pg_%' and table_schema <> 'information_schema'" 13 | print(f"Attempting to run SQL: {sql}") 14 | tables = execute_statement(sql) 15 | return tables 16 | 17 | def get_tables_information(t: list[str]): 18 | sql = "select table_name, column_name, ordinal_position, is_nullable, data_type from information_schema.columns where table_name not like 'pg_%' and table_schema <> 'information_schema'" 19 | print(f"Attempting to run SQL: {sql}") 20 | tables_information = execute_statement(sql) 21 | return tables_information 22 | 23 | def execute_statement(sql): 24 | print(">>>>> EXECUTE_SQL_STATEMENT: Attempting to run SQL: " + sql) 25 | response = rds_client.execute_statement( 26 | secretArn=db_credentials_secrets_arn, 27 | database=database_name, 28 | resourceArn=db_resource_arn, 29 | sql=sql 30 | ) 31 | return response 32 | 33 | 34 | # MAIN LAMBDA FUNCTION ENTRY POINT 35 | def lambda_handler(event, context): 36 | agent = event['agent'] 37 | actionGroup = event['actionGroup'] 38 | function = event['function'] 39 | parameters = event.get('parameters', []) 40 | 41 | print(f"Received request to call {function} with params: {parameters}") 42 | 43 | # Set a default ERROR message in case the correct function could not be determined 44 | responseBody = {"TEXT": {"body": "ERROR: No function found to run".format(function)}} 45 | 46 | # Figure out what tables are in the database 47 | if function == "get_tables": 48 | tables = get_tables() 49 | responseBody = {"TEXT": {"body": f"{tables}"}} 50 | 51 | # Get definition of the tables - column names help to create the query SQL 52 | elif function == "get_tables_information": 53 | tables = None 54 | for param in parameters: 55 | if param["name"] == "tables_list": 56 | tables = param["value"] 57 | if not tables: 58 | raise Exception("Missing mandatory parameter: tables_list") 59 | print(tables) 60 | table_information = get_tables_information(tables) 61 | responseBody = {"TEXT": {"body": f"{table_information}"}} 62 | 63 | 64 | # Business data queries 65 | else: 66 | for param in parameters: 67 | if param["name"] == 'sql_statement': 68 | sql = param["value"] 69 | # Remove newline characters 70 | sql = sql.replace("\n", " ") 71 | print(f"Running agent provided SQL: {sql}") 72 | results = execute_statement(sql) 73 | responseBody = {"TEXT": {"body": f"{results}"}} 74 | if not sql: 75 | raise Exception("Missing SQL statement") 76 | 77 | action_response = { 78 | 'actionGroup': actionGroup, 79 | 'function': function, 80 | 'functionResponse': { 81 | 'responseBody': responseBody 82 | } 83 | } 84 | 85 | function_response = { 86 | "response": action_response, 87 | "messageVersion": event["messageVersion"], 88 | } 89 | 90 | print("Response: {}".format(action_response)) 91 | return function_response 92 | -------------------------------------------------------------------------------- /amplify/functions/utils/cdkUtils.ts: -------------------------------------------------------------------------------- 1 | import * as cdk from 'aws-cdk-lib' 2 | import * as iam from 'aws-cdk-lib/aws-iam' 3 | 4 | 5 | export const addLlmAgentPolicies = (props: { 6 | role: cdk.aws_iam.IRole, 7 | rootStack: cdk.Stack, 8 | athenaWorkgroup: cdk.aws_athena.CfnWorkGroup, 9 | s3Bucket: cdk.aws_s3.IBucket 10 | }) => { 11 | 12 | props.role.addToPrincipalPolicy( 13 | new iam.PolicyStatement({ 14 | actions: ["bedrock:InvokeModel*"], 15 | resources: [ 16 | `arn:aws:bedrock:${props.rootStack.region}:${props.rootStack.account}:inference-profile/*`, 17 | `arn:aws:bedrock:us-*::foundation-model/*`, 18 | ], 19 | }) 20 | ) 21 | 22 | props.role.addToPrincipalPolicy( 23 | new cdk.aws_iam.PolicyStatement({ 24 | actions: [ 25 | 'athena:StartQueryExecution', 26 | 'athena:GetQueryExecution', 27 | 'athena:GetQueryResults', 28 | ], 29 | resources: [`arn:aws:athena:${props.rootStack.region}:${props.rootStack.account}:workgroup/${props.athenaWorkgroup.name}`], 30 | }) 31 | ) 32 | 33 | props.role.addToPrincipalPolicy( 34 | new cdk.aws_iam.PolicyStatement({ 35 | actions: [ 36 | 'athena:GetDataCatalog' 37 | ], 38 | resources: [`arn:aws:athena:*:*:datacatalog/*`], // This function must be able to invoke data catalogs in other accoutns. 39 | conditions: { // The data catalog must be tagged with `AgentsForEnergy: true` in order to be invoked. 40 | 'StringEquals': { 41 | 'aws:ResourceTag/AgentsForEnergy': 'true' 42 | } 43 | } 44 | }) 45 | ) 46 | 47 | props.role.addToPrincipalPolicy( 48 | new cdk.aws_iam.PolicyStatement({ 49 | actions: [ 50 | 'athena:GetDataCatalog' 51 | ], 52 | resources: [`arn:aws:athena:${props.rootStack.region}:${props.rootStack.account}:datacatalog/AwsDataCatalog`], 53 | }) 54 | ) 55 | 56 | props.role.addToPrincipalPolicy( 57 | new cdk.aws_iam.PolicyStatement({ 58 | actions: [ 59 | "glue:GetDatabase", 60 | "glue:GetDatabases", 61 | "glue:GetTable", 62 | "glue:GetTables", 63 | "glue:GetPartitions", 64 | "glue:BatchGetPartition", 65 | ], 66 | resources: [ 67 | `arn:aws:glue:${props.rootStack.region}:${props.rootStack.account}:catalog`, 68 | `arn:aws:glue:${props.rootStack.region}:${props.rootStack.account}:database/*`, 69 | `arn:aws:glue:${props.rootStack.region}:${props.rootStack.account}:table/*` 70 | ], 71 | }) 72 | ) 73 | 74 | //Allow the function to invoke the lambda used to connect Athena to the postgres db 75 | props.role.addToPrincipalPolicy( 76 | new iam.PolicyStatement({ 77 | actions: ["lambda:InvokeFunction"], 78 | resources: [`arn:aws:lambda:*:*:*`], //This function must be able to invoke lambda functions in other accounts so to query Athena federated data sources in other accounts. 79 | conditions: { //The lambda must be tagged with `AgentsForEnergy: true` in order to be invoked. 80 | 'StringEquals': { 81 | 'aws:ResourceTag/AgentsForEnergy': 'true' 82 | } 83 | } 84 | }), 85 | ) 86 | 87 | // Add SSM permissions 88 | props.role.addToPrincipalPolicy(new cdk.aws_iam.PolicyStatement({ 89 | actions: [ 90 | "ssm:GetParameter", 91 | "ssm:GetParameters", 92 | ], 93 | resources: [ 94 | `arn:aws:ssm:${props.rootStack.region}:${props.rootStack.account}:parameter/*` 95 | ], 96 | })) 97 | 98 | props.role.addToPrincipalPolicy(new cdk.aws_iam.PolicyStatement({ 99 | actions: [ 100 | "s3:GetBucketLocation", 101 | "s3:GetObject", 102 | "s3:ListBucket", 103 | "s3:ListBucketMultipartUploads", 104 | "s3:ListMultipartUploadParts", 105 | "s3:AbortMultipartUpload", 106 | "s3:PutObject", 107 | ], 108 | resources: [ 109 | props.s3Bucket.bucketArn, 110 | props.s3Bucket.arnForObjects("*") 111 | ], 112 | })) 113 | } -------------------------------------------------------------------------------- /amplify/functions/utils/pdfUtils.ts: -------------------------------------------------------------------------------- 1 | // import gm from 'gm'; 2 | // import { PDFDocument } from 'pdf-lib'; 3 | // import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'; 4 | 5 | // const imageMagick = gm.subClass({ imageMagick: true }); 6 | 7 | // async function convertPdfPageToPng(pdfBuffer: Buffer, index: number): Promise { 8 | // // Load the PDF document 9 | // const pdfDoc = await PDFDocument.load(pdfBuffer); 10 | 11 | // // Get the first page of the PDF 12 | // const page = pdfDoc.getPages()[index]; 13 | 14 | // // Get the width and height of the page 15 | // const { width, height } = page.getSize(); 16 | 17 | // // Claude supports the images' logest edge bing at most 1568 pixels long https://docs.anthropic.com/en/docs/build-with-claude/vision 18 | // const maxPixelsLongestEdge = 1560 19 | // // Calculate new dimensions maintaining aspect ratio 20 | // let newWidth = width; 21 | // let newHeight = height; 22 | 23 | // if (width > height && width > maxPixelsLongestEdge) { 24 | // // Width is the longest dimension 25 | // const aspectRatio = height / width; 26 | // newWidth = maxPixelsLongestEdge; 27 | // newHeight = Math.round(maxPixelsLongestEdge * aspectRatio); 28 | // } else if (height > width && height > maxPixelsLongestEdge) { 29 | // // Height is the longest dimension 30 | // const aspectRatio = width / height; 31 | // newHeight = maxPixelsLongestEdge; 32 | // newWidth = Math.round(maxPixelsLongestEdge * aspectRatio); 33 | // } 34 | // const pngBuffer = await new Promise((resolve, reject) => { 35 | 36 | // imageMagick(pdfBuffer, `pdf.pdf[${index}]`) 37 | // .resize(newWidth, newHeight)//.resize(width * 2, height * 2) 38 | // .density(400, 400)//600 39 | // .quality(50) 40 | // .toBuffer('PNG', (err, out) => { 41 | // if (err) { 42 | // // console.log('gm conversion error: ', err) 43 | // throw new Error('gm conversion error: ', err); 44 | // } 45 | 46 | // resolve(out) 47 | // }); 48 | // }) 49 | 50 | // const sizeInMB = (pngBuffer.length / (1024 * 1024)).toFixed(2); 51 | 52 | // console.log(`Converted page ${index} to PNG. Size: ${sizeInMB} MB`); 53 | 54 | // return pngBuffer 55 | // } 56 | 57 | // export async function convertPdfToPngs(body: Buffer): Promise { 58 | // try { 59 | // const pdoc = await PDFDocument.load(body); 60 | // const pageCount = pdoc.getPageCount(); 61 | 62 | // console.log(`Converting PDF to PNGs. Pages: ${pageCount}`); 63 | 64 | // const pages = Array.from({ length: pageCount }, (_, i) => i); 65 | // let pngBuffers: Buffer[] = []; 66 | // for (let page of pages) { 67 | // pngBuffers.push(await convertPdfPageToPng(body, page)); 68 | // } 69 | // return pngBuffers; 70 | // } catch (error) { 71 | // console.error(JSON.stringify(error)); 72 | // throw new Error('Failed to convert PDF to images'); 73 | // } 74 | // } 75 | 76 | // export async function convertPdfToB64Strings(props: { s3Key: string, s3BucketName: string },): Promise { 77 | // // Initialize S3 client 78 | // const s3Client = new S3Client(); 79 | 80 | // try { 81 | // // Fetch PDF from S3 82 | // const getObjectParams = { 83 | // Bucket: props.s3BucketName, 84 | // Key: props.s3Key, 85 | // }; 86 | // const { Body } = await s3Client.send(new GetObjectCommand(getObjectParams)); 87 | // if (!Body) throw new Error('Failed to fetch PDF from S3'); 88 | 89 | // // Load PDF document 90 | // const pdfBytes = await Body.transformToByteArray(); 91 | // // console.log("pdf Bytes: ", pdfBytes) 92 | 93 | // const pngBuffers = await convertPdfToPngs(Buffer.from(pdfBytes)) 94 | 95 | // const pngB64Strings = pngBuffers.map((pngBuffer) => { 96 | // return pngBuffer.toString('base64'); 97 | // }) 98 | // // console.log("png Strings: ", pngB64Strings) 99 | 100 | // return pngB64Strings 101 | 102 | // } catch (error) { 103 | // console.error('Error processing PDF:', error); 104 | // throw error; 105 | // } 106 | // } -------------------------------------------------------------------------------- /amplify/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } -------------------------------------------------------------------------------- /amplify/storage/resource.ts: -------------------------------------------------------------------------------- 1 | import { defineStorage } from '@aws-amplify/backend'; 2 | 3 | export const storage = defineStorage({ 4 | name: 'fileDrive', 5 | access: (allow) => ({ 6 | 'production-agent/*': [ 7 | allow.authenticated.to(['read']), 8 | ], 9 | 'maintenance-agent/*': [ 10 | allow.authenticated.to(['read']), 11 | ], 12 | 'petrophysics-agent/*': [ 13 | allow.authenticated.to(['read']), 14 | ], 15 | 'regulatory-agent/*': [ 16 | allow.authenticated.to(['read']) 17 | 18 | ], 19 | }) 20 | }); -------------------------------------------------------------------------------- /amplify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", 4 | "module": "es2022", 5 | "moduleResolution": "bundler", 6 | "resolveJsonModule": true, 7 | "esModuleInterop": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "strict": true, 10 | "skipLibCheck": true, 11 | "paths": { 12 | "$amplify/*": [ 13 | "../.amplify/generated/*" 14 | ] 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /assets/images/A4E-Customer-Benefits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Customer-Benefits.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy01.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy02.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy03.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy04.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy05.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy06.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy07.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy08.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy09.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy10.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy11.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy12.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy13.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy14.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy15.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy16.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy17.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy18.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy19.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy20.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy21.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy22.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy23.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy24.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy25.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy26.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy27.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy28.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy29.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy30.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy31.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy32.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy33.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy34.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy35.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy36.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy37.png -------------------------------------------------------------------------------- /assets/images/A4E-Deploy38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Deploy38.png -------------------------------------------------------------------------------- /assets/images/A4E-Maintenance-Agent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Maintenance-Agent.png -------------------------------------------------------------------------------- /assets/images/A4E-Open-Source-Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Open-Source-Architecture.png -------------------------------------------------------------------------------- /assets/images/A4E-ProductionAgentScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-ProductionAgentScreenShot.png -------------------------------------------------------------------------------- /assets/images/A4E-Reference-Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/assets/images/A4E-Reference-Architecture.png -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | webpack: (config) => { 5 | config.resolve.fallback = { fs: false }; 6 | return config; 7 | }, 8 | }; 9 | 10 | export default nextConfig; 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "agents-for-energy", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "ecrAuth": "aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws", 7 | "cdkDiff": "cdk diff --ci --app \"npx tsx amplify/backend.ts\" --output .amplify/artifacts/cdk.out --context amplify-backend-name=$(whoami) --context amplify-backend-namespace=$(node -e \"console.log(require('./package.json').name)\") --context amplify-backend-type=sandbox", 8 | "dev": "next dev", 9 | "build": "next build", 10 | "start": "next start", 11 | "lint": "next lint" 12 | }, 13 | "dependencies": { 14 | "@aws-amplify/ui-react": "^6.9.1", 15 | "@aws-amplify/ui-react-storage": "^3.7.1", 16 | "@cloudscape-design/chat-components": "^1.0.19", 17 | "@cloudscape-design/code-view": "^3.0.36", 18 | "@cloudscape-design/components": "^3.0.889", 19 | "@cloudscape-design/design-tokens": "^3.0.44", 20 | "@cloudscape-design/global-styles": "^1.0.34", 21 | "@emotion/react": "^11.13.3", 22 | "@emotion/styled": "^11.13.0", 23 | "@langchain/aws": "^0.1.1", 24 | "@langchain/langgraph": "^0.2.22", 25 | "@mui/icons-material": "^6.1.3", 26 | "@mui/material": "^6.4.3", 27 | "@mui/x-data-grid": "^7.22.1", 28 | "aws-amplify": "^6.12.2", 29 | "bedrock-agents-cdk": "^0.0.6", 30 | "chart.js": "^4.4.6", 31 | "chartjs-adapter-date-fns": "^3.0.0", 32 | "chartjs-plugin-annotation": "^3.1.0", 33 | "chartjs-plugin-datalabels": "^2.2.0", 34 | "chartjs-plugin-zoom": "^2.0.1", 35 | "date-fns": "^4.1.0", 36 | "graphql-tag": "^2.12.6", 37 | "jsonschema": "^1.4.1", 38 | "next": "^14.2.23", 39 | "pdf-lib": "^1.17.1", 40 | "react": "^18", 41 | "react-chartjs-2": "^5.2.0", 42 | "react-dom": "^18", 43 | "react-hook-form": "^7.54.2", 44 | "react-markdown": "^9.0.1", 45 | "react-plotly.js": "^2.6.0", 46 | "react-textarea-autosize": "^8.5.4", 47 | "recharts": "^2.13.3", 48 | "remark-gfm": "^4.0.0", 49 | "sass": "^1.79.4", 50 | "sharp": "^0.33.5", 51 | "yaml": "^2.7.0" 52 | }, 53 | "devDependencies": { 54 | "@aws-amplify/backend": "^1.13.0", 55 | "@aws-amplify/backend-cli": "^1.4.7", 56 | "@aws-appsync/utils": "^1.9.0", 57 | "@aws-sdk/client-appsync": "^3.670.0", 58 | "@aws-sdk/client-athena": "^3.679.0", 59 | "@aws-sdk/client-bedrock-agent": "^3.687.0", 60 | "@aws-sdk/client-bedrock-agent-runtime": "^3.670.0", 61 | "@aws-sdk/client-rds-data": "^3.679.0", 62 | "@aws-sdk/client-sfn": "^3.670.0", 63 | "@aws-sdk/client-textract": "^3.716.0", 64 | "@aws-sdk/credential-provider-node": "^3.670.0", 65 | "@cdklabs/generative-ai-cdk-constructs": "^0.1.289", 66 | "@langchain/community": "^0.3.17", 67 | "@tailwindcss/typography": "^0.5.15", 68 | "@types/jsdom": "^21.1.7", 69 | "@types/node": "^20", 70 | "@types/react": "^18", 71 | "@types/react-dom": "^18", 72 | "aws-cdk": "^2.175.1", 73 | "aws-cdk-lib": "^2.177.0", 74 | "aws-sdk": "^2.1691.0", 75 | "constructs": "^10.4.2", 76 | "esbuild": "^0.25.2", 77 | "eslint": "^8", 78 | "eslint-config-next": "14.2.14", 79 | "jsdom": "^25.0.1", 80 | "postcss": "^8", 81 | "tailwindcss": "^3.4.1", 82 | "tsx": "^4.19.1", 83 | "typescript": "^5.6.2" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /sampleData/maintenance-agent/Sandy Point Process Diagram.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/Sandy Point Process Diagram.pdf -------------------------------------------------------------------------------- /sampleData/maintenance-agent/cmms/CMMS_Foreign_Keys.csv: -------------------------------------------------------------------------------- 1 | table_name,column_name,foreign_table_name,foreign_column_name 2 | equipment,equiptypeid,equipmenttypes,equiptypeid 3 | maintenance,mainttypeid,mainttypes,mainttypeid 4 | maintenance,statusid,statustypes,statusid 5 | locations,loctypeid,locationtypes,loctypeid 6 | locations,businessunit,businessunits,buid 7 | locations,facility,locations,locationid -------------------------------------------------------------------------------- /sampleData/maintenance-agent/cmms/CMMS_Nullable_Required_Columns.csv: -------------------------------------------------------------------------------- 1 | table_name,column_name,is_nullable 2 | businessunits,buid,NO 3 | businessunits,buname,NO 4 | businessunits,createdby,YES 5 | businessunits,createddate,YES 6 | businessunits,updatedby,YES 7 | businessunits,updateddate,YES 8 | equipment,equipid,NO 9 | equipment,equiptypeid,NO 10 | equipment,equipname,NO 11 | equipment,equiplongdesc,YES 12 | equipment,manufacturer,YES 13 | equipment,model,YES 14 | equipment,manfyear,YES 15 | equipment,weblink,YES 16 | equipment,serialnum,YES 17 | equipment,equipweight,YES 18 | equipment,installlocationid,YES 19 | equipment,lat,YES 20 | equipment,lon,YES 21 | equipment,safetycritical,NO 22 | equipment,statusid,NO 23 | equipment,servicedatestart,YES 24 | equipment,servicedateend,YES 25 | equipment,createdby,YES 26 | equipment,createddate,YES 27 | equipment,updatedby,YES 28 | equipment,updateddate,YES 29 | equipmenttypes,equiptypeid,NO 30 | equipmenttypes,equiptypename,NO 31 | equipmenttypes,createdby,YES 32 | equipmenttypes,createddate,YES 33 | equipmenttypes,updatedby,YES 34 | equipmenttypes,updateddate,YES 35 | locations,locationid,NO 36 | locations,loctypeid,NO 37 | locations,locname,NO 38 | locations,businessunit,YES 39 | locations,facility,YES 40 | locations,section,YES 41 | locations,workcenter,YES 42 | locations,locmgrid,YES 43 | locations,latitude,YES 44 | locations,longitude,YES 45 | locations,address1,YES 46 | locations,address2,YES 47 | locations,city,YES 48 | locations,state,YES 49 | locations,zip,YES 50 | locations,country,YES 51 | locations,phone,YES 52 | locations,fax,YES 53 | locations,email,YES 54 | locations,createdby,YES 55 | locations,createddate,YES 56 | locations,updatedby,YES 57 | locations,updateddate,YES 58 | locationtypes,loctypeid,NO 59 | locationtypes,loctypename,NO 60 | locationtypes,createdby,YES 61 | locationtypes,createddate,YES 62 | locationtypes,updatedby,YES 63 | locationtypes,updateddate,YES 64 | maintenance,maintid,NO 65 | maintenance,mainttypeid,NO 66 | maintenance,equipid,YES 67 | maintenance,maintname,NO 68 | maintenance,maintlongdesc,YES 69 | maintenance,workorderid,YES 70 | maintenance,efforthours,YES 71 | maintenance,estcost,YES 72 | maintenance,downtimereq,YES 73 | maintenance,technicianid,YES 74 | maintenance,responsibleid,YES 75 | maintenance,requirespermit,YES 76 | maintenance,statusid,NO 77 | maintenance,planneddatestart,YES 78 | maintenance,planneddateend,YES 79 | maintenance,actualdatestart,YES 80 | maintenance,actualdateend,YES 81 | maintenance,createdby,YES 82 | maintenance,createddate,YES 83 | maintenance,updatedby,YES 84 | maintenance,updateddate,YES 85 | mainttypes,mainttypeid,NO 86 | mainttypes,mainttypename,NO 87 | mainttypes,createdby,YES 88 | mainttypes,createddate,YES 89 | mainttypes,updatedby,YES 90 | mainttypes,updateddate,YES 91 | statustypes,statusid,NO 92 | statustypes,statusname,NO 93 | statustypes,createdby,YES 94 | statustypes,createddate,YES 95 | statustypes,updatedby,YES 96 | statustypes,updateddate,YES 97 | -------------------------------------------------------------------------------- /sampleData/maintenance-agent/cmms/CMMS_Primary_Keys.csv: -------------------------------------------------------------------------------- 1 | table_name,column_name 2 | equipmenttypes,equiptypeid 3 | locationtypes,loctypeid 4 | mainttypes,mainttypeid 5 | statustypes,statusid 6 | businessunits,buid 7 | equipment,equipid 8 | maintenance,maintid 9 | locations,locationid -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-09-18 AM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-09-18 AM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-09-18 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-09-18 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-10-31 AM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-10-31 AM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-10-31 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover BIO 2024-10-31 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover COK 2024-10-06 AM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover COK 2024-10-06 AM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover CRK 2024-09-18 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover CRK 2024-09-18 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-18 AM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-18 AM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-18 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-18 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-25 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-25 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-26 AM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-09-26 AM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-10-06 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover DST 2024-10-06 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover FCC 2024-10-07 PM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover FCC 2024-10-07 PM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/handover/SP Shift Handover TRT 2024-10-07 AM.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/handover/SP Shift Handover TRT 2024-10-07 AM.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Photo-5-Aerial-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Photo-5-Aerial-view.png -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Pigging Report - Biloea Sep152024.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Pigging Report - Biloea Sep152024.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Pigging Report - Chinchilla Jul292024.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Pigging Report - Chinchilla Jul292024.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Pigging Report - Dalby Jul152024.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Pigging Report - Dalby Jul152024.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Pigging Report - Wallumbilla Jul12024.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Pigging Report - Wallumbilla Jul12024.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Pigging Summary Report - Wallumbilla Gladstone Pipeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Pigging Summary Report - Wallumbilla Gladstone Pipeline.pdf -------------------------------------------------------------------------------- /sampleData/maintenance-agent/pigging/Typical Pigging Job Estimate 150km.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/pigging/Typical Pigging Job Estimate 150km.docx -------------------------------------------------------------------------------- /sampleData/maintenance-agent/repair/EcoSafe Chinchilla HSE Testing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/repair/EcoSafe Chinchilla HSE Testing.pdf -------------------------------------------------------------------------------- /sampleData/maintenance-agent/repair/PRS Leak Repair Invoice.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/repair/PRS Leak Repair Invoice.pdf -------------------------------------------------------------------------------- /sampleData/maintenance-agent/repair/Root Cause Analysis Report - Pipeline Leak.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/maintenance-agent/repair/Root Cause Analysis Report - Pipeline Leak.pdf -------------------------------------------------------------------------------- /sampleData/petrophysics-agent/DHI.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/petrophysics-agent/DHI.docx -------------------------------------------------------------------------------- /sampleData/petrophysics-agent/Smit_03.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/petrophysics-agent/Smit_03.pdf -------------------------------------------------------------------------------- /sampleData/petrophysics-agent/dhananjay_paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/petrophysics-agent/dhananjay_paper.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/structured-data-files/pricing/pricing.csv: -------------------------------------------------------------------------------- 1 | Date,WTI_Price,Brent_Price,Volume 2 | 2024-03-01,82.45,85.12,125000 3 | 2024-02-29,81.98,84.75,132000 4 | 2024-02-28,82.15,84.90,128500 5 | 2024-02-27,81.75,84.22,130000 6 | 2024-02-26,82.55,85.05,127500 7 | 2024-02-25,82.30,84.88,126000 8 | 2024-02-24,81.95,84.65,129000 9 | 2024-02-23,82.75,85.30,131500 10 | 2024-02-22,82.25,84.95,128000 11 | 2024-02-21,81.85,84.55,133000 12 | 2024-02-20,82.65,85.15,129500 13 | 2024-02-19,82.40,84.92,127000 14 | 2024-02-18,81.90,84.60,130500 15 | 2024-02-17,82.80,85.35,126500 16 | 2024-02-16,82.35,84.98,128000 17 | 2024-02-15,81.95,84.70,131000 18 | 2024-02-14,82.70,85.25,129000 19 | 2024-02-13,82.45,84.96,127500 20 | 2024-02-12,81.88,84.58,130000 21 | 2024-02-11,82.85,85.40,125500 -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48587.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48587.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48588.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48588.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48589.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48589.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48590.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48590.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48591.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48591.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48592.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48592.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48593.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30-045-29202_48593.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/3003921992_19_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/3003921992_19_wf.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045085870000_07_09_2020_03_47_23.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045085870000_07_09_2020_03_47_23.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_11_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_11_wf.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_12_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_12_wf.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_13_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_13_wf.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_14_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/30045292020000_14_wf.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/3004529202_10_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/3004529202_10_wf.pdf -------------------------------------------------------------------------------- /sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/3004529202_9_wf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/production-agent/well-files/field=SanJuanEast/api=30-045-29202/3004529202_9_wf.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/2017-28211.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/2017-28211.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/2023-11742.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/2023-11742.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/2024-06827.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/2024-06827.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/CFR-2023-title43-vol2-part3100.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/CFR-2023-title43-vol2-part3100.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/CFR-2023-title43-vol2-part3160.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/CFR-2023-title43-vol2-part3160.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/CFR-2023-title43-vol2-part3170.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/CFR-2023-title43-vol2-part3170.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/OO_3173_FAQ_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/OO_3173_FAQ_1.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/Onshore Order 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/Onshore Order 3.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Land Management-BLM/Order_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Land Management-BLM/Order_3.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 (up to date as of 7-05-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 (up to date as of 7-05-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart E (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart E (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart F (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart F (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart L (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart L (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart Q (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart Q (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart S (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 250 Subpart S (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 550 Subpart A (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 550 Subpart A (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 550 Subpart B (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 550 Subpart B (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 550 Subpart D (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Bureau of Safety and Environmenatl Enforcement-BSEE/30 CFR Part 550 Subpart D (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 112 (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 112 (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 144 (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 144 (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 148 (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 148 (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 435 (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 435 (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 60 Subpart OOOOa (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 60 Subpart OOOOa (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 63 Subpart HH (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 63 Subpart HH (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 63 Subpart HHH (up to date as of 7-08-2024).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/40 CFR Part 63 Subpart HHH (up to date as of 7-08-2024).pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/45Q-primer-Carbon-Capture-Coalition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/45Q-primer-Carbon-Capture-Coalition.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/CFR-2023-title40-vol23-part98.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/CFR-2023-title40-vol23-part98.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/IF11455.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/IF11455.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/ejincwa404_factsheet_2024.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/ejincwa404_factsheet_2024.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Environmental Protection Agency-EPA/safe_drinking_water_act-title_xiv_of_public_health_service_act.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Environmental Protection Agency-EPA/safe_drinking_water_act-title_xiv_of_public_health_service_act.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Federal Energy Regulatory Comission-FERC/CFR-2023-title18-vol1-part157.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Federal Energy Regulatory Comission-FERC/CFR-2023-title18-vol1-part157.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Federal Energy Regulatory Comission-FERC/CFR-2023-title18-vol1-part284.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Federal Energy Regulatory Comission-FERC/CFR-2023-title18-vol1-part284.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/2023-04-cpl-04.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/2023-04-cpl-04.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/21-04_CPL_04.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/21-04_CPL_04.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/404_reg_authority_fact_sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/404_reg_authority_fact_sheet.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CFR-2024-title10-vol2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CFR-2024-title10-vol2.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CFR-2024-title10-vol3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CFR-2024-title10-vol3.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CFR-2024-title10-vol4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CFR-2024-title10-vol4.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CPL-02-07-13O.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CPL-02-07-13O.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CPL_20-04_04-01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Occupational Safety and Health Administration-OSHA/CPL_20-04_04-01.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol2-part171.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol2-part171.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol2-part172.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol2-part172.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol2-part177.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol2-part177.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part180.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part180.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part192.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part192.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part195.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part195.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part198.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/Pipeline and Hazardous Marterials Safety Administration-PHMSA/CFR-2023-title49-vol3-part198.pdf -------------------------------------------------------------------------------- /sampleData/regulatory-agent/financial-aspects-offshore-decom-brazil-in-the-light-of-tlo-luciana-braga-helder-queiroz (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/sampleData/regulatory-agent/financial-aspects-offshore-decom-brazil-in-the-light-of-tlo-luciana-braga-helder-queiroz (1).pdf -------------------------------------------------------------------------------- /scripts/productionAgentScript.md: -------------------------------------------------------------------------------- 1 | # Production Agent Demo Script 2 | 3 | [Well File View](https://ocdimage.emnrd.nm.gov/imaging/WellFileView.aspx?RefType=WF&RefID=30039077300000) 4 | 5 | Petroleum engineers spend a lot of their time reading well reports. In this demo I'll show how you can make that process much more efficient. 6 | 7 | Here we have a sample set of pdf documents from the state of New Mexico's website about a certain well in the San Juan basin. 8 | 9 | Now say this well developed a hole in tubing. Traditionally, I'd have to go read all of these documents and take notes to understand what happened in the past on this well. That can take a lot of time and it can be quite tedious. 10 | 11 | Instead of doing that, I can let an AI agent read all these PDFs for me, then summarize their information and plot the well's production with these events. That way I can quickly get the context I need to write a procedure and fix this well. 12 | 13 | Here is a demo of that happening. This is a chat with the AI agent. I've asked it to make a table with detailed information about all of the events. 14 | 15 | Here is the table that the AI agent automatically produced. So no human was involved in creating this table, it was just the AI. 16 | 17 | I can quickly read through it in order to learn about what happened in the past on this well. So I can see when it was drilled, that it was stimulated, re-stimulated, the tubing was replaced, and they even plan a workover for the future. 18 | 19 | Now if I want to learn more about any of these events, I have a list to the source document that the generative AI agent read in order to come up with this line of the table. 20 | 21 | So say I want to learn more about the tubing replacement, well I can click the link to the source document and then go look at that pdf that it read in order to generate this information. 22 | 23 | So here I can see the activity from that operation, how they moved in, rigged up, shut down for the weekend, and all the other operational events that are recorded in this document. 24 | 25 | So I can be confident that a generative AI agent is giving me an accurate representation of an operational event. In this way, I can much more quickly learn about the history of a well and know what to look into more if I want to know more information. 26 | 27 | This can make the job of a petroleum engineer a lot more efficient. And if this is exciting to you, talk to your AWS account team about how you can leverage generative AI to make your business better. Thanks, this was Walt Mayfield, software architect at AWS. 28 | -------------------------------------------------------------------------------- /scripts/uploadCsvProductionData.ts: -------------------------------------------------------------------------------- 1 | import { JSDOM } from 'jsdom'; 2 | import * as path from 'path'; 3 | import { writeFile, mkdir } from 'fs/promises'; 4 | 5 | // const wellApiNumber = `30-015-27892` 6 | const wellApiNumber = `30-045-29202` 7 | 8 | 9 | const productionUrl = `https://wwwapps.emnrd.nm.gov/OCD/OCDPermitting/Data/ProductionSummaryPrint.aspx?report=csv&api=${wellApiNumber}` 10 | 11 | console.log("Production URL: ", productionUrl) 12 | const wellFileUrl = `https://ocdimage.emnrd.nm.gov/imaging/WellFileView.aspx?RefType=WF&RefID=${wellApiNumber.replaceAll("-","")}0000` 13 | console.log('Well File URL: ', wellFileUrl) 14 | 15 | async function saveStringToFile(content: string, filename: string) { 16 | try { 17 | await mkdir(path.dirname(filename), { recursive: true }); 18 | await writeFile(filename, content, 'utf8'); 19 | console.log('File has been saved successfully'); 20 | } catch (error) { 21 | console.error('Error writing to file:', error); 22 | } 23 | } 24 | 25 | async function parseHtmlTableToArrays(htmlContent: string): Promise { 26 | // Create a DOM using jsdom 27 | const dom = new JSDOM(htmlContent); 28 | const doc = dom.window.document; 29 | 30 | // Find all tables in the document 31 | const tables = doc.getElementsByTagName('table'); 32 | if (tables.length === 0) return; 33 | 34 | // The first table is the column names 35 | const columnNameElements = tables[0].getElementsByTagName('tr')[2].getElementsByTagName('td') 36 | const columnNames = Array.from(columnNameElements).map(element => element.textContent?.trim() || '').slice(0,7); 37 | 38 | const csvRows: string[][] = [columnNames]; 39 | // const dataColumns: {[name: string]: string[]} = {} 40 | 41 | // Iterate through each table 42 | for (let i = 1; i < tables.length; i++) { 43 | const cells = tables[i].getElementsByTagName('tr')[0].getElementsByTagName('td'); 44 | // const cellsHeader = tables[i].getElementsByTagName('th'); 45 | 46 | // Combine all cells in the row 47 | const rowData: string[] = []; 48 | 49 | // // Handle header cells 50 | // for (let cell of cellsHeader) { 51 | // rowData.push(cell.textContent?.trim() || ''); 52 | // } 53 | 54 | // Handle data cells 55 | for (let cell of Array.from(cells).slice(0,7)) { 56 | rowData.push(cell.textContent?.trim() || ''); 57 | } 58 | 59 | // Add the row to our CSV data, properly escaped 60 | if (rowData.length > 0) { 61 | csvRows.push(rowData.map(cell => `${cell.replace(/"/g, '""')}`)); 62 | } 63 | } 64 | 65 | return csvRows; 66 | } 67 | 68 | 69 | const main = async () => { 70 | const response = await fetch(productionUrl) 71 | const htmlContent = await response.text() 72 | 73 | const csvContent = await parseHtmlTableToArrays(htmlContent); 74 | if (!csvContent) return 75 | 76 | const csvContentWithDate = [["FirstDayOfMonth", ...csvContent[0]]] 77 | 78 | csvContentWithDate.push( 79 | ...csvContent.slice(1).map(row => ([ 80 | new Date(`${row[2]} 1, ${row[0]}`).toISOString().split('T')[0], 81 | ...row, 82 | ])) 83 | ) 84 | 85 | const csvContentString = csvContentWithDate.map(row => row.join(',')).join('\n') 86 | 87 | const productionFilePath = path.join( 88 | '.', 89 | 'tmp', 90 | 'production-agent', 91 | 'structured-data-files', 92 | 'monthly_produciton', 93 | `api=${wellApiNumber}`, 94 | 'production.csv' 95 | ) 96 | 97 | await saveStringToFile(csvContentString, productionFilePath) 98 | 99 | // console.log(csvContentString); 100 | 101 | } 102 | 103 | main() -------------------------------------------------------------------------------- /src/a4e-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/src/a4e-logo.png -------------------------------------------------------------------------------- /src/app/chat/page.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import Page from './[chatSessionId]/page' 4 | 5 | export default function Home() { 6 | return ( 7 | 8 | ) 9 | } -------------------------------------------------------------------------------- /src/app/common/adjust-body-padding.ts: -------------------------------------------------------------------------------- 1 | // // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // // SPDX-License-Identifier: MIT-0 3 | // export function adjustBodyPadding() { 4 | // const header = document.querySelector('#h'); 5 | // if (!header) { 6 | // throw new Error('Header were not found'); 7 | // } 8 | // const { height: headerHeight } = header.getBoundingClientRect(); 9 | // document.documentElement.style.scrollPaddingTop = `${headerHeight}px`; 10 | // } 11 | 12 | // window.addEventListener('DOMContentLoaded', adjustBodyPadding); 13 | // window.addEventListener('resize', adjustBodyPadding); 14 | -------------------------------------------------------------------------------- /src/app/common/apply-mode.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { applyDensity, Density } from '@cloudscape-design/global-styles'; 4 | 5 | // import * as localStorage from './localStorage'; 6 | 7 | import '@cloudscape-design/global-styles/index.css'; 8 | 9 | // (window as any).disableMotionForTests = disableMotion; 10 | 11 | // always `true` in this design 12 | export const isVisualRefresh = true; 13 | 14 | export let currentDensity: Density = localStorage.load('Awsui-Density-Preference') ?? Density.Comfortable; 15 | applyDensity(currentDensity); 16 | 17 | export function updateDensity(density: string) { 18 | applyDensity(density as Density); 19 | localStorage.save('Awsui-Density-Preference', density); 20 | currentDensity = density as Density; 21 | } 22 | -------------------------------------------------------------------------------- /src/app/common/aws-region-utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | export interface Region { 4 | name: string; 5 | code: string; 6 | } 7 | 8 | export const regionsByLocation = { 9 | 'United States': [ 10 | { 11 | name: 'N. Virginia', 12 | code: 'us-east-1', 13 | }, 14 | { 15 | name: 'Ohio', 16 | code: 'us-east-2', 17 | }, 18 | { 19 | name: 'N. California', 20 | code: 'us-west-1', 21 | }, 22 | { 23 | name: 'Oregon', 24 | code: 'us-west-2', 25 | }, 26 | ], 27 | 'Asia Pacific': [ 28 | { 29 | name: 'Mumbai', 30 | code: 'ap-south-1', 31 | }, 32 | { 33 | name: 'Osaka', 34 | code: 'ap-northeast-3', 35 | }, 36 | { 37 | name: 'Seoul', 38 | code: 'ap-northeast-2', 39 | }, 40 | { 41 | name: 'Singapore', 42 | code: 'ap-southeast-1', 43 | }, 44 | { 45 | name: 'Sydney', 46 | code: 'ap-southeast-2', 47 | }, 48 | { 49 | name: 'Tokyo', 50 | code: 'ap-northeast-1', 51 | }, 52 | ], 53 | Canada: [ 54 | { 55 | name: 'Central', 56 | code: 'ca-central-1', 57 | }, 58 | ], 59 | Europe: [ 60 | { 61 | name: 'Frankfurt', 62 | code: 'eu-central-1', 63 | }, 64 | { 65 | name: 'Ireland', 66 | code: 'eu-west-1', 67 | }, 68 | { 69 | name: 'London', 70 | code: 'eu-west-2', 71 | }, 72 | { 73 | name: 'Paris', 74 | code: 'eu-west-3', 75 | }, 76 | { 77 | name: 'Stockholm', 78 | code: 'eu-north-1', 79 | }, 80 | ], 81 | 'Middle East': [ 82 | { 83 | name: 'Bahrain', 84 | code: 'me-south-1', 85 | }, 86 | { 87 | name: 'UAE', 88 | code: 'me-central-1', 89 | }, 90 | ], 91 | 'South America': [ 92 | { 93 | name: 'São Paulo', 94 | code: 'sa-east-1', 95 | }, 96 | ], 97 | }; 98 | 99 | export function formatReadOnlyRegion(regionCode: Region['code']) { 100 | const region = Object.values(regionsByLocation) 101 | .flat() 102 | .filter((region: Region) => region.code === regionCode)[0]; 103 | return region ? `${region.name} (${region.code})` : regionCode; 104 | } 105 | -------------------------------------------------------------------------------- /src/app/common/breadcrumbs.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | export const resourcesBreadcrumbs = [ 4 | { 5 | text: 'Service', 6 | href: '#', 7 | }, 8 | { 9 | text: 'Distributions', 10 | href: '#', 11 | }, 12 | ]; 13 | 14 | export const resourceDetailBreadcrumbs = [ 15 | ...resourcesBreadcrumbs, 16 | { 17 | text: 'SLCCSMWOHOFUY0', 18 | href: '#', 19 | }, 20 | ]; 21 | 22 | export const resourceManageTagsBreadcrumbs = [ 23 | ...resourceDetailBreadcrumbs, 24 | { 25 | text: 'Manage tags', 26 | href: '#', 27 | }, 28 | ]; 29 | 30 | export const resourceEditBreadcrumbs = [ 31 | ...resourceDetailBreadcrumbs, 32 | { 33 | text: 'Edit', 34 | href: '#', 35 | }, 36 | ]; 37 | 38 | export const resourceCreateBreadcrumbs = [ 39 | ...resourcesBreadcrumbs, 40 | { 41 | text: 'Create distribution', 42 | href: '#', 43 | }, 44 | ]; 45 | 46 | export const readFromS3Breadcrumbs = [ 47 | ...resourceDetailBreadcrumbs, 48 | { 49 | text: 'Run simulation', 50 | href: '#', 51 | }, 52 | ]; 53 | 54 | export const writeToS3Breadcrumbs = [ 55 | ...resourceDetailBreadcrumbs, 56 | { 57 | text: 'Create simulation', 58 | href: '#', 59 | }, 60 | ]; 61 | -------------------------------------------------------------------------------- /src/app/common/columnDefinitionsHelper.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { TableProps } from '@cloudscape-design/components/table'; 4 | 5 | export function addToColumnDefinitions>( 6 | columnDefinitions: TableProps.ColumnDefinition[], 7 | propertyName: K, 8 | columns: Partial>[] = [] 9 | ) { 10 | return columnDefinitions.map(colDef => { 11 | const column = columns.find(col => col.id === colDef.id); 12 | return { 13 | ...colDef, 14 | [propertyName]: (column && column[propertyName]) || colDef[propertyName], 15 | }; 16 | }); 17 | } 18 | 19 | export function mapWithColumnDefinitionIds>( 20 | columnDefinitions: TableProps.ColumnDefinition[], 21 | propertyName: K, 22 | items: TableProps.ColumnDefinition[K][] 23 | ) { 24 | return columnDefinitions.map(({ id }, i) => ({ 25 | id, 26 | [propertyName]: items[i], 27 | })); 28 | } 29 | -------------------------------------------------------------------------------- /src/app/common/localStorage.ts: -------------------------------------------------------------------------------- 1 | // // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // // SPDX-License-Identifier: MIT-0 3 | // import { CookieConsent } from './types'; 4 | 5 | // declare global { 6 | // interface Window { 7 | // AwsUiConsent: CookieConsent; 8 | // } 9 | // } 10 | 11 | // const hasConsent = () => { 12 | // if (typeof window.AwsUiConsent === 'undefined') { 13 | // return false; 14 | // } 15 | 16 | // const cookieConsent = window.AwsUiConsent.getConsentCookie(); 17 | // return cookieConsent?.functional ?? false; 18 | // }; 19 | 20 | // export const save = (key: string, value: unknown) => { 21 | // if (hasConsent()) { 22 | // localStorage.setItem(key, JSON.stringify(value)); 23 | // } 24 | // }; 25 | 26 | // export const remove = (key: string) => localStorage.removeItem(key); 27 | 28 | // export const load = (key: string): T | undefined => { 29 | // const value = localStorage.getItem(key); 30 | // try { 31 | // if (!value) { 32 | // return undefined; 33 | // } 34 | // return JSON.parse(value) as T; 35 | // } catch (e) { 36 | // // eslint-disable-next-line no-console 37 | // console.warn( 38 | // `⚠️ The ${key} value that is stored in localStorage is incorrect. Try to remove the value ${key} from localStorage and reload the page` 39 | // ); 40 | // return undefined; 41 | // } 42 | // }; 43 | -------------------------------------------------------------------------------- /src/app/common/parse-property-filter.ts: -------------------------------------------------------------------------------- 1 | // // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // // SPDX-License-Identifier: MIT-0 3 | // import * as z from 'zod'; 4 | 5 | // import { PropertyFilterQuery } from '@cloudscape-design/collection-hooks'; 6 | 7 | // const PropertyFilterOperation = z.enum(['and', 'or']); 8 | 9 | // const propertyFilterTokenSchema = z.object({ 10 | // // There's no other way to enforce this value as required. Using z.any() allows it to be optional, which breaks our types 11 | // value: z.object({}).passthrough().or(z.array(z.any())).or(z.string()).or(z.number()).or(z.boolean()), 12 | // propertyKey: z.string().optional(), 13 | // operator: z.string(), 14 | // }); 15 | 16 | // const propertyFilterQueryBaseSchema = z.object({ 17 | // tokens: z.array(propertyFilterTokenSchema), 18 | // operation: PropertyFilterOperation, 19 | // }); 20 | 21 | // // workaround to validate recursive types: https://zod.dev/?id=recursive-types 22 | // // fyi: same problem in yup and valibot 23 | // type PropertyFilterQuerySchemaType = z.infer & { 24 | // tokenGroups?: PropertyFilterQuery['tokenGroups']; 25 | // }; 26 | 27 | // const propertyFilterQuerySchema: z.ZodType = propertyFilterQueryBaseSchema.extend({ 28 | // tokenGroups: z.lazy(() => z.array(z.union([propertyFilterTokenSchema, propertyFilterQuerySchema])).optional()), 29 | // }); 30 | 31 | // export const parsePropertyFilterQuery = (stringifiedPropertyFilter: string): PropertyFilterQuery => { 32 | // const defaultQuery = { operation: 'and', tokens: [] } as PropertyFilterQuery; 33 | 34 | // if (!stringifiedPropertyFilter) { 35 | // return defaultQuery; 36 | // } 37 | // try { 38 | // const json = JSON.parse(stringifiedPropertyFilter); 39 | // return propertyFilterQuerySchema.parse(json); 40 | // } catch (error) { 41 | // return defaultQuery; 42 | // } 43 | // }; 44 | -------------------------------------------------------------------------------- /src/app/common/property-filter-operators.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | export const stringOperators = [':', '!:', '=', '!=', '^', '!^']; 4 | 5 | export const enumOperators = [ 6 | { operator: '=', tokenType: 'enum' }, 7 | { operator: '!=', tokenType: 'enum' }, 8 | ':', 9 | '!:', 10 | ] as const; 11 | -------------------------------------------------------------------------------- /src/app/common/s3-resource-selector/mock-request.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { S3ResourceSelectorProps } from '@cloudscape-design/components/s3-resource-selector'; 4 | 5 | import { amazonS3Data, S3Error, S3ErrorType, S3Resource } from './mock-data'; 6 | 7 | type ResourceType = 'buckets' | 'objects' | 'versions'; 8 | type ChildResourceKeys = '__objects' | '__versions' | '__folders'; 9 | 10 | export class S3FetchError extends Error { 11 | constructor(error: S3Error) { 12 | super(error.content); 13 | this.type = error.type; 14 | this.header = error.header; 15 | } 16 | 17 | type: S3ErrorType; 18 | header: string | undefined; 19 | } 20 | 21 | amazonS3Data.map(bucket => { 22 | bucket.__objects = [...(bucket.__folders ?? []), ...(bucket.__objects ?? [])]; 23 | }); 24 | const randomDelay = (min = 500) => ~~(Math.random() * 500) + min; 25 | 26 | const findItem = (items: S3Resource[], name: string, itemsType: S3ResourceSelectorProps.SelectableItems) => { 27 | const item = items.filter(item => item.Name === name || item.Key === name)[0]; 28 | if (!item) { 29 | throw `"${name}" ${itemsType.substring(0, itemsType.length - 1)} doesn't exist`; 30 | } 31 | return item; 32 | }; 33 | 34 | const getItemsType = (item: S3Resource): ResourceType => { 35 | return Object.keys(item) 36 | .filter(key => key === '__objects' || key === '__versions')[0] 37 | .replace('__', '') as ResourceType; 38 | }; 39 | 40 | export const getItems = (bucket?: string, path?: string): Promise => { 41 | const entities: string[] = []; 42 | if (bucket) { 43 | entities.push(bucket); 44 | } 45 | if (path && path.length > 0) { 46 | entities.push(...path.split('/')); 47 | } 48 | 49 | let items: S3Resource[] = amazonS3Data; 50 | let itemsType: ResourceType = 'buckets'; 51 | let item: S3Resource; 52 | 53 | for (const entity of entities) { 54 | try { 55 | item = findItem(items, entity, itemsType); 56 | } catch (e) { 57 | throw new S3FetchError({ 58 | content: `Resource "s3://${bucket}/${path}" cannot be found: ${e}`, 59 | type: 'error', 60 | }); 61 | } 62 | itemsType = getItemsType(item); 63 | if (item.__error) { 64 | const error = new S3FetchError(item.__error); 65 | error.type = item.__error.type; 66 | error.header = item.__error.header; 67 | throw error; 68 | } 69 | items = item[('__' + itemsType) as ChildResourceKeys] ?? []; 70 | } 71 | 72 | return new Promise(resolve => { 73 | setTimeout(() => { 74 | resolve(items); 75 | }, randomDelay()); 76 | }); 77 | }; 78 | 79 | export const requestAsyncRegions = (item: S3Resource): Promise => { 80 | return new Promise(resolve => { 81 | setTimeout(() => { 82 | item.Region = item.__region; 83 | resolve(); 84 | }, randomDelay(1000)); 85 | }); 86 | }; 87 | -------------------------------------------------------------------------------- /src/app/common/types.ts: -------------------------------------------------------------------------------- 1 | // // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // // SPDX-License-Identifier: MIT-0 3 | // import { AwsRumConfig } from 'aws-rum-web'; 4 | 5 | // type ConsentCookie = { 6 | // advertising: boolean; 7 | // essential: boolean; 8 | // functional: boolean; 9 | // performance: boolean; 10 | // }; 11 | 12 | // interface CookieCategories { 13 | // functional: boolean; 14 | // } 15 | 16 | // interface ShortbreadParams { 17 | // domain: string; 18 | // onConsentChanged: (cookieCategories: CookieCategories) => void; 19 | // } 20 | // export interface CookieConsent { 21 | // checkForCookieConsent: () => void; 22 | // getConsentCookie: () => ConsentCookie; 23 | // } 24 | 25 | // export interface RumOptions { 26 | // appId: string; 27 | // region: string; 28 | // config: AwsRumConfig; 29 | // } 30 | 31 | // declare global { 32 | // interface Window { 33 | // AWSCShortbread: (shortbreadParams: ShortbreadParams) => CookieConsent; 34 | // AWSUiConsent: CookieConsent; 35 | // } 36 | // } 37 | -------------------------------------------------------------------------------- /src/app/common/use-query-params.ts: -------------------------------------------------------------------------------- 1 | // // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // // SPDX-License-Identifier: MIT-0 3 | // import { useEffect, useState } from 'react'; 4 | 5 | // export const useQueryParams = () => { 6 | // const [queryParams, setParams] = useState(Object.fromEntries(new URLSearchParams(window.location.search))); 7 | 8 | // const getQueryParam = (param: string) => { 9 | // return queryParams[param]; 10 | // }; 11 | 12 | // const setQueryParam = (param: string, value: string | null) => { 13 | // setParams(currentParams => { 14 | // const queryParams = { ...currentParams }; 15 | // if (value === null || value === '') { 16 | // delete queryParams[param]; 17 | // } else { 18 | // queryParams[param] = value; 19 | // } 20 | 21 | // const searchParams = new URLSearchParams(queryParams); 22 | // const newURL = searchParams.toString() ? `${window.location.pathname}?${searchParams}` : window.location.pathname; 23 | 24 | // window.history.pushState('', '', newURL); 25 | 26 | // return queryParams; 27 | // }); 28 | // }; 29 | 30 | // useEffect(() => { 31 | // const handlePopState = () => { 32 | // setParams(Object.fromEntries(new URLSearchParams(window.location.search))); 33 | // }; 34 | 35 | // window.addEventListener('popstate', handlePopState); 36 | // return () => window.removeEventListener('popstate', handlePopState); 37 | // }, []); 38 | 39 | // return { 40 | // getQueryParam, 41 | // setQueryParam, 42 | // queryParams, 43 | // }; 44 | // }; 45 | -------------------------------------------------------------------------------- /src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/agents4energy/40866cab8ce43e16e87f5b51a084538ca8295044/src/app/favicon.ico -------------------------------------------------------------------------------- /src/app/files/[...s3Key]/page.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import React, { useState, useEffect } from 'react'; 3 | 4 | import { getUrl } from 'aws-amplify/storage'; 5 | 6 | export default function Page({ params }: { params: { s3Key: string[] } }) { 7 | 8 | 9 | const [selectedFileUrl, setSelectedFileUrl] = useState(); 10 | 11 | useEffect(() => { 12 | const s3KeyDecoded = params.s3Key.map((item) => decodeURIComponent(item)).join('/') 13 | 14 | console.log('s3 Key: ', s3KeyDecoded) 15 | 16 | getUrl({ 17 | path: s3KeyDecoded, 18 | }).then((response) => { 19 | // console.log('response: ', response) 20 | setSelectedFileUrl(response.url) 21 | // return response.url 22 | } 23 | ).catch((error) => { 24 | console.error('error: ', error) 25 | } 26 | ) 27 | }, [params.s3Key]) 28 | 29 | 30 | // return
My Post: {selectedFileUrl?.toString()}
31 | return ( 32 | <> 33 | {/*
My Post: {selectedFileUrl?.toString()}
*/} 34 | {selectedFileUrl && ( 35 |