> For the complete documentation index, see [llms.txt](https://oobe-protocol.gitbook.io/oobe-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oobe-protocol.gitbook.io/oobe-protocol/getting-started/quickstart/initializing-the-core-module.md).

# Initializing The Core Module

OobeCore Initialization and Usage

The `OobeCore` class is a central component in our project, responsible for managing the core functionalities of the oobe-protocol system. Below, we will walk through the initialization process and how to use the `OobeCore` class effectively.

```typescript
import { OobeCore, ConfigManager, IConfiguration } from "oobe-protocol";

const configManager = new ConfigManager();
const config: IConfiguration = {...}

const overrideDefConfig = configManager.createDefaultConfig(config)
  
const oobe = new OobeCore(configManager.getDefaultConfig()) || new OobeCore(overrideDefConfig)
```

The <mark style="color:red;">`configManager.`</mark><mark style="color:purple;">`getDefaultConfig()`</mark> method returns the default configuration, which is then passed to the <mark style="color:red;">`OobeCore`</mark> constructor.\
\
The <mark style="color:red;">`configManager.`</mark><mark style="color:purple;">`createDefaultConfig()`</mark> method returns a custom configuration, which is then passed to the <mark style="color:red;">`OobeCore`</mark> constructor to override the default configuration.

**Constructor Details**

The <mark style="color:red;">`OobeCore`</mark> constructor performs several key tasks:

1. **Logger Initialization**: A <mark style="color:red;">`Logger`</mark> instance is created to handle logging throughout the lifecycle of <mark style="color:red;">`OobeCore`</mark>.
2. **Configuration Verification**: The provided configuration is verified using the <mark style="color:red;">`verifyConfig`</mark> function. If the configuration is invalid, an error is logged, and an exception is thrown.
3. **Agent Initialization**: If the configuration is valid, an <mark style="color:red;">`Agent`</mark> instance is created using the configuration details.
4. **Memory Saver Initialization**: A <mark style="color:red;">`MemorySaver`</mark> instance is created to manage memory-related operations.

**Reference Costructor Core:**

<pre class="language-typescript"><code class="lang-typescript"> */
 * @name OobeCore
 * @description Core module for the OOBE protocol
 * @example const core = new OobeCore(config)
 * @author oobe-protocol                   
<strong> */
</strong>export class OobeCore {
  private agent: Agent;
  private logger: Logger;
  private memory: MemorySaver;

  constructor(config: IConfiguration) {
    this.logger = new Logger();
    if (verifyConfig(config)) {
      this.agent = new Agent(config.solanaEndpoint, config.private_key, config.openAiKey, this.logger);
    } else {
      this.logger.error("Invalid configuration");
      throw new Error("Invalid configuration");
    }
    this.memory = new MemorySaver();
  }
}
</code></pre>

### Usage

Once the instance is initialized, you can start using its various methods to interact with the system.

#### 1. Starting the OobeCore

Use the `start` method to initialize the core functionalities:

```ts
await oobe.start();
```

#### 2. Creating and Executing the Agent

Register actions, create tools, setup memory, and initialize the agent loop using `AgentExecution`:

```ts
await AgentExecution(oobe);
```

#### 3. Accessing the Agent Instance

Retrieve the agent instance from the OobeCore:

```ts
const agent = oobe.getAgent();
```

#### 4. Registering OOBE Actions

Register all predefined OOBE actions with the agent:

```ts
agent.registerActions(Actions.map((action) => action.action));
```

#### 5. Creating Solana Tools

Generate the toolset to enable on-chain capabilities:

```ts
const tools = await createSolanaTools(agent);
```

#### 6. Setting up Agent Memory

Use `MemorySaver` to provide persistent memory to the agent:

```ts
const memory = new MemorySaver();
```

#### 7. Creating a React Agent

Build the interactive agent with tool access and custom personality instructions:

```ts
const oobe_agent = createReactAgent({
  llm: agent.genAi(),
  tools: tools as ToolNode<any>,
  checkpointSaver: memory,
  messageModifier: `You are a person with this personality "${JSON.stringify(await agent.getDefaultPersonality())}"...`,
});
```

#### 8. Sending Human Messages

Interact with the agent using user input through streaming:

```ts
const stream = await oobe_agent.stream(
  { messages: [new HumanMessage("Your prompt here")] },
  { configurable: { thread_id: "OOBE AGENT BUILDER!" } }
);
```

#### 9. Merkle Validation and On-Chain Inscription

After tool execution, validate and inscribe the result on-chain:

```ts
const data_merkle = agent.merkleValidate(toolsRes, agentRes as Record<string, any>);
await agent.merkle.onChainMerkleInscription(data_merkle);
```

#### 10. Stopping the OobeCore

Gracefully shut down the system when done:

```ts
await oobe.stop();
```

<br>
