# egbejoe06/agentic_sdk architecture

> Architecture diagram of the GitHub repository egbejoe06/agentic_sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/egbejoe06/agentic_sdk
- Repository: https://github.com/egbejoe06/agentic_sdk

## Overview

#### Purpose and entry points
Agentic Wallet SDK is a TypeScript library for AI-controlled, policy-governed Solana devnet wallets. Its public export surface is `src/index.ts`; consumers create/configure wallets and submit typed intents. Runnable integration entry points are the demos, notably `demo/agentDemo.ts`, `demo/multiAgentDemo.ts`, and `demo/whirlpoolSwapDemo.ts`.

#### Execution pipeline
The central control flow is `agent/application → wallet.execute(intent) → policy validation → transaction simulation → signing/submission → Solana`. `src/core/AgenticWallet.ts` orchestrates this pipeline and represents the wallet-facing API. Shared request, policy, and result contracts define the boundary between intent producers and core execution in `src/core/types.ts`.

#### Policy enforcement
`src/core/PolicyEngine.ts` is the pre-execution authorization boundary. Every intent must pass configured transaction constraints before it can reach transaction construction or private-key operations. This isolates AI agents and application code from direct signing authority while allowing explicit, typed operation classes.

#### Simulation and signing isolation
`src/core/Sandbox.ts` validates proposed transactions against Solana before broadcast, providing a failure/safety boundary ahead of signing. `src/core/SecureSigner.ts` owns private-key-backed signing; keys are sourced from environment-backed setup rather than exposed to agents. `src/core/WalletFactory.ts` constructs wallet instances and wires the core components.

#### Intent-to-transaction layer
Intent modules turn constrained, high-level requests into Solana instructions/transactions. Core transfer and arbitrary program paths are `src/intents/transferSol.ts`, `src/intents/transferSpl.ts`, and `src/intents/interactProgram.ts`. Stateful staking flows are represented by `src/intents/stakeSol.ts`, `src/intents/unstakeSol.ts`, and `src/intents/withdrawStakeSol.ts`. This layer is the main protocol-specific boundary below policy and above simulation/signing.

#### DeFi protocol operations
Orca Whirlpool operations—swap, liquidity provisioning, and reward harvesting—are encapsulated in `src/intents/whirlpoolSwap.ts`, `src/intents/whirlpoolAddLiquidity.ts`, and `src/intents/whirlpoolHarvest.ts`. These intents let agents request specialized DeFi actions without bypassing the same policy, sandbox, and signer pipeline. Instruction compatibility utilities live in `src/utils/kitInstructionToWeb3.ts`.

#### Agent integration and multi-agent use
`src/agent/walletTools.ts` exposes wallet execution as LangChain-compatible tools; `src/agent/LangChainAgent.ts` binds an LLM agent to those tools. Agents do not receive signing keys: they emit intent/tool calls that return through `AgenticWallet`. Multi-wallet coordination is demonstrated by `demo/multiAgentDemo.ts` and `demo/twoAgentSwap.ts`, where wallets interact over normal on-chain transfers rather than a trusted off-chain custody layer.

#### Runtime and external boundaries
The project runs on Node.js 18+ and compiles TypeScript into `dist/`. It uses Solana devnet RPC and programs, including stake operations and Orca Whirlpool; demos require a funded devnet wallet. LLM-backed demos additionally depend on a provider API key such as `GOOGLE_GENAI_API_KEY`. Environment key material is configured via `.env.example`; agent command/schema guidance is supplied in `SKILLS.md`.

Main entry points: [`src/core/Sandbox.ts`](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/Sandbox.ts) (Transaction sandbox), [`src/core/PolicyEngine.ts`](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/PolicyEngine.ts) (Policy engine), [`src/core/WalletFactory.ts`](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/WalletFactory.ts) (Wallet factory), [`src/core/AgenticWallet.ts`](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/AgenticWallet.ts) (Agentic wallet)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public API"]
  node_sdk_exports["SDK exports<br/>TypeScript entrypoint<br/>[index.ts]"]
  node_contracts["Intent contracts<br/>TypeScript contracts<br/>[types.ts]"]
  node_demos["Agent demos<br/>integration entrypoints"]
end

subgraph group_agent["Agent Integration"]
  node_agent_tools["Wallet tools<br/>LangChain tools<br/>[walletTools.ts]"]
  node_langchain_agent["LangChain agent<br/>LLM adapter<br/>[LangChainAgent.ts]"]
end

subgraph group_core["Wallet Control Plane"]
  node_wallet_factory["Wallet factory<br/>composition root<br/>[WalletFactory.ts]"]
  node_wallet["Agentic wallet<br/>execution orchestrator<br/>[AgenticWallet.ts]"]
  node_policy{{"Policy engine<br/>authorization boundary<br/>[PolicyEngine.ts]"}}
  node_sandbox{{"Transaction sandbox<br/>simulation boundary<br/>[Sandbox.ts]"}}
  node_signer{{"Secure signer<br/>key custody<br/>[SecureSigner.ts]"}}
end

subgraph group_intents["Intent Builders"]
  node_transfer_intents["Transfer intents<br/>transaction builders"]
  node_program_intent["Program interaction<br/>transaction builder<br/>[interactProgram.ts]"]
  node_staking_intents["Staking intents<br/>stateful transaction builders"]
  node_whirlpool_intents["Whirlpool intents<br/>DeFi transaction builders"]
  node_instruction_compat["Instruction compatibility<br/>conversion utility"]
end

subgraph group_runtime["Runtime Boundaries"]
  node_solana[("Solana devnet<br/>RPC and programs")]
  node_llm_provider(("LLM provider<br/>external API"))
end

node_sdk_exports -->|"creates wallets"| node_wallet_factory
node_sdk_exports -->|"exports types"| node_contracts
node_wallet_factory -->|"constructs"| node_wallet
node_wallet_factory -->|"wires"| node_policy
node_wallet_factory -->|"wires"| node_sandbox
node_wallet_factory -->|"wires"| node_signer
node_langchain_agent -->|"uses"| node_agent_tools
node_agent_tools -->|"submits intents"| node_wallet
node_llm_provider -->|"powers"| node_langchain_agent
node_demos -->|"runs agent flows"| node_langchain_agent
node_demos -->|"uses wallets"| node_wallet
node_contracts -->|"typed intents"| node_wallet
node_wallet -->|"validates intent"| node_policy
node_policy -->|"approved transfers"| node_transfer_intents
node_policy -->|"approved program calls"| node_program_intent
node_policy -->|"approved staking"| node_staking_intents
node_policy -->|"approved DeFi actions"| node_whirlpool_intents
node_transfer_intents -->|"builds transaction"| node_sandbox
node_program_intent -->|"builds transaction"| node_sandbox
node_staking_intents -->|"builds transaction"| node_sandbox
node_whirlpool_intents -->|"converts instructions"| node_instruction_compat
node_instruction_compat -->|"web3 transaction"| node_sandbox
node_sandbox -->|"simulates against"| node_solana
node_sandbox -->|"approved transaction"| node_signer
node_signer -->|"signs and submits"| node_solana

click node_sdk_exports "https://github.com/egbejoe06/agentic_sdk/blob/main/src/index.ts"
click node_contracts "https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/types.ts"
click node_wallet_factory "https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/WalletFactory.ts"
click node_wallet "https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/AgenticWallet.ts"
click node_policy "https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/PolicyEngine.ts"
click node_sandbox "https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/Sandbox.ts"
click node_signer "https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/SecureSigner.ts"
click node_agent_tools "https://github.com/egbejoe06/agentic_sdk/blob/main/src/agent/walletTools.ts"
click node_langchain_agent "https://github.com/egbejoe06/agentic_sdk/blob/main/src/agent/LangChainAgent.ts"
click node_program_intent "https://github.com/egbejoe06/agentic_sdk/blob/main/src/intents/interactProgram.ts"
click node_instruction_compat "https://github.com/egbejoe06/agentic_sdk/blob/main/src/utils/kitInstructionToWeb3.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sdk_exports,node_contracts,node_demos toneBlue
class node_agent_tools,node_langchain_agent toneAmber
class node_wallet_factory,node_wallet,node_policy,node_sandbox,node_signer toneMint
class node_transfer_intents,node_program_intent,node_staking_intents,node_whirlpool_intents,node_instruction_compat toneRose
class node_solana,node_llm_provider toneIndigo
```

## Components

### Public API

- [SDK exports](https://github.com/egbejoe06/agentic_sdk/blob/main/src/index.ts): TypeScript entrypoint · Consumer-facing wallet and intent API. · `src/index.ts`
- [Intent contracts](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/types.ts): TypeScript contracts · Typed requests, policies, and execution results. · `src/core/types.ts`
- **Agent demos**: integration entrypoints · Single-agent, multi-agent, and Whirlpool runnable flows.

### Agent Integration

- [Wallet tools](https://github.com/egbejoe06/agentic_sdk/blob/main/src/agent/walletTools.ts): LangChain tools · Exposes typed wallet execution to agent tool calls. · `src/agent/walletTools.ts`
- [LangChain agent](https://github.com/egbejoe06/agentic_sdk/blob/main/src/agent/LangChainAgent.ts): LLM adapter · Binds an LLM agent to wallet tools. · `src/agent/LangChainAgent.ts`

### Wallet Control Plane

- [Wallet factory](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/WalletFactory.ts): composition root · Builds wallets and wires execution dependencies. · `src/core/WalletFactory.ts`
- [Agentic wallet](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/AgenticWallet.ts): execution orchestrator · Executes intents through policy, simulation, signing, and submission. · `src/core/AgenticWallet.ts`
- [Policy engine](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/PolicyEngine.ts): authorization boundary · Rejects intents outside configured transaction constraints. · `src/core/PolicyEngine.ts`
- [Transaction sandbox](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/Sandbox.ts): simulation boundary · Simulates proposed transactions before signing. · `src/core/Sandbox.ts`
- [Secure signer](https://github.com/egbejoe06/agentic_sdk/blob/main/src/core/SecureSigner.ts): key custody · Signs approved transactions with environment-sourced keys. · `src/core/SecureSigner.ts`

### Intent Builders

- **Transfer intents**: transaction builders · SOL and SPL transfer instruction paths.
- [Program interaction](https://github.com/egbejoe06/agentic_sdk/blob/main/src/intents/interactProgram.ts): transaction builder · Builds constrained arbitrary-program transactions. · `src/intents/interactProgram.ts`
- **Staking intents**: stateful transaction builders · Stake, unstake, and withdraw-stake flows.
- **Whirlpool intents**: DeFi transaction builders · Swap, liquidity, and reward-harvest operations.
- [Instruction compatibility](https://github.com/egbejoe06/agentic_sdk/blob/main/src/utils/kitInstructionToWeb3.ts): conversion utility · Bridges kit instructions to web3-compatible instructions. · `src/utils/kitInstructionToWeb3.ts`

### Runtime Boundaries

- **Solana devnet**: RPC and programs · Simulation, transaction submission, stake, and Whirlpool execution.
- **LLM provider**: external API · Supplies models for LLM-backed demos.

## Connections

- SDK exports → Wallet factory: creates wallets
- SDK exports → Intent contracts: exports types
- Wallet factory → Agentic wallet: constructs
- Wallet factory → Policy engine: wires
- Wallet factory → Transaction sandbox: wires
- Wallet factory → Secure signer: wires
- LangChain agent → Wallet tools: uses
- Wallet tools → Agentic wallet: submits intents
- LLM provider → LangChain agent: powers
- Agent demos → LangChain agent: runs agent flows
- Agent demos → Agentic wallet: uses wallets
- Intent contracts → Agentic wallet: typed intents
- Agentic wallet → Policy engine: validates intent
- Policy engine → Transfer intents: approved transfers
- Policy engine → Program interaction: approved program calls
- Policy engine → Staking intents: approved staking
- Policy engine → Whirlpool intents: approved DeFi actions
- Transfer intents → Transaction sandbox: builds transaction
- Program interaction → Transaction sandbox: builds transaction
- Staking intents → Transaction sandbox: builds transaction
- Whirlpool intents → Instruction compatibility: converts instructions
- Instruction compatibility → Transaction sandbox: web3 transaction
- Transaction sandbox → Solana devnet: simulates against
- Transaction sandbox → Secure signer: approved transaction
- Secure signer → Solana devnet: signs and submits
