Plugin SDK

包括的なSDKでAdverant Nexusの強力なプラグインを構築

インストール

TypeScript/JavaScript

npm install @adverant-nexus/sdk

SDKはNode.js 18以上と互換性があり、TypeScript定義が含まれています。

Python

pip install adverant-nexus-sdk

Python SDKにはPython 3.9以上が必要です。

コアコンセプト

プラグインアーキテクチャ

プラグインはModel Context Protocol (MCP) を通じてNexusを拡張し、AIエージェントが検出・使用できるツール、リソース、プロンプトを提供します。

  • ツール:アクションを実行する関数(例:データ分析、メール送信)
  • リソース:プラグインが公開するデータソース(例:データベース、API)
  • プロンプト:一般的なワークフロー向けの事前設定済みプロンプト

Nexusクライアント

Nexusクライアントはコアプラットフォームサービスへのアクセスを提供します:

import { NexusClient } from '@adverant-nexus/sdk'

const nexus = new NexusClient({
  apiKey: process.env.BRAIN_API_KEY
})

// Access GraphRAG memory
await nexus.graphrag.storeMemory({
  content: 'Important information',
  tags: ['customer', 'analysis']
})

// Orchestrate sub-agents
await nexus.agents.orchestrate({
  task: 'Analyze customer feedback',
  agents: ['sentiment', 'summarization']
})

APIリファレンス

プラグインサーバーの作成

import { NexusPluginServer, Tool } from '@adverant-nexus/sdk/server'

const server = new NexusPluginServer({
  name: 'my-plugin',
  version: '1.0.0',
  description: 'My awesome plugin'
})

// Define a tool
server.tool(new Tool({
  name: 'analyze_data',
  description: 'Analyzes data and returns insights',
  inputSchema: {
    type: 'object',
    properties: {
      data: { type: 'array' },
      options: { type: 'object' }
    },
    required: ['data']
  },
  execute: async (input) => {
    // Your implementation
    return { insights: [...] }
  }
}))

// Start the server
await server.start()

Nexusサービスへのアクセス

// GraphRAG Memory
await nexus.graphrag.storeMemory({ content, tags })
await nexus.graphrag.query({ query, limit: 10 })

// Agent Orchestration
await nexus.agents.orchestrate({ task, agents })

// Learning System
await nexus.learning.recordPattern({ pattern, feedback })

サンプル

シンプルなプラグインの例

挨拶ツールを提供する基本的なプラグイン:

import { NexusPluginServer, Tool } from '@adverant-nexus/sdk/server'

const server = new NexusPluginServer({
  name: 'greeter',
  version: '1.0.0'
})

server.tool(new Tool({
  name: 'greet',
  description: 'Greets a user by name',
  inputSchema: {
    type: 'object',
    properties: {
      name: { type: 'string' }
    },
    required: ['name']
  },
  execute: async ({ name }) => {
    return { message: `Hello, ${name}!` }
  }
}))

await server.start()

次のステップ