"Bedrock Knowledge Base Plugin", register(api) { // ── kb_search: Knowledge Base からドキュメントを検索 api.registerTool({ name: "kb_search", description: "...", parameters: Type.Object({ query: Type.String({ description: "Search query text", }), ... }), async execute(_id, params) { try { const client = new BedrockAgentRuntimeClient({ region: AWS_REGION, }); const response = await client.send( new RetrieveCommand({ knowledgeBaseId: KNOWLEDGE_BASE_ID, retrievalQuery: { text: params.query }, retrievalConfiguration: { ... }, }) ); ... } }, }); // ── kb_ingest: S3 にドキュメントをアップロード → Ingestion Job 開始 ── api.registerTool( { name: "kb_ingest", description:"...", parameters: Type.Object({ fileName: Type.String({ description: "File name of the document (e.g. 'report.pdf')", ... }), async execute(_id, params) { ... // Step 1: S3 にドキュメントをアップロード try { const s3 = new S3Client({ region: AWS_REGION }); ... await s3.send( new PutObjectCommand({ Bucket: S3_BUCKET_NAME, ... }) ); // Step 2: Ingestion Job を開始してデータソースを同期 const agent = new BedrockAgentClient({ region: AWS_REGION }); const ingestionResponse = await agent.send( new StartIngestionJobCommand({ knowledgeBaseId: KNOWLEDGE_BASE_ID, dataSourceId: DATA_SOURCE_ID, }) ); ... }