You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

clara-flow-sdk

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clara-flow-sdk

Modern JavaScript SDK for executing Clara AI agent workflows with zero configuration

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
48
-21.31%
Maintainers
1
Weekly downloads
 
Created
Source

Clara Flow SDK v2.0 🚀

Modern JavaScript SDK for executing Clara AI agent workflows with zero configuration

npm version License: MIT

✨ Features

  • 🎯 Zero Configuration - Works out of the box
  • 🧠 AI-Ready - Built-in LLM and AI node support
  • 🔗 Universal - Node.js, Browser, and CDN compatible
  • Fast - Lightweight and optimized execution engine
  • 🛡️ Type Safe - Full TypeScript support
  • 🎨 Custom Nodes - Create your own node types
  • 📦 Clara Studio Compatible - Import workflows directly

🚀 Quick Start

Installation

npm install clara-flow-sdk

Basic Usage (5 lines of code!)

import { ClaraFlowRunner } from 'clara-flow-sdk';

const runner = new ClaraFlowRunner();
const result = await runner.execute(workflow, { input: 'Hello World!' });
console.log(result);

📖 Complete Examples

1. Simple Text Processing

import { ClaraFlowRunner } from 'clara-flow-sdk';

// Create a simple workflow
const textWorkflow = {
  nodes: [
    {
      id: 'input-1',
      type: 'input',
      name: 'User Input',
      data: { value: 'Hello' },
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'process-1',
      type: 'static-text',
      name: 'Add Greeting',
      data: { text: 'Welcome: ' },
      inputs: [{ id: 'input', name: 'Input' }],
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'combine-1',
      type: 'combine-text',
      name: 'Combine',
      data: { separator: '' },
      inputs: [
        { id: 'text1', name: 'Text1' },
        { id: 'text2', name: 'Text2' }
      ],
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'output-1',
      type: 'output',
      name: 'Final Result',
      inputs: [{ id: 'input', name: 'Input' }]
    }
  ],
  connections: [
    { sourceNodeId: 'process-1', sourcePortId: 'output', targetNodeId: 'combine-1', targetPortId: 'text1' },
    { sourceNodeId: 'input-1', sourcePortId: 'output', targetNodeId: 'combine-1', targetPortId: 'text2' },
    { sourceNodeId: 'combine-1', sourcePortId: 'output', targetNodeId: 'output-1', targetPortId: 'input' }
  ]
};

// Execute workflow
const runner = new ClaraFlowRunner();
const result = await runner.execute(textWorkflow, { 'input-1': 'Clara!' });
console.log(result); // { "output-1": { "output": "Welcome: Clara!" } }

2. JSON Data Processing

const jsonWorkflow = {
  nodes: [
    {
      id: 'data-input',
      type: 'input',
      name: 'JSON Data',
      data: { value: '{"user": {"name": "Alice", "profile": {"age": 30, "city": "NYC"}}}' },
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'parse-name',
      type: 'json-parse',
      name: 'Extract Name',
      data: { field: 'user.name' },
      inputs: [{ id: 'input', name: 'JSON' }],
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'parse-city',
      type: 'json-parse',
      name: 'Extract City',
      data: { field: 'user.profile.city' },
      inputs: [{ id: 'input', name: 'JSON' }],
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'result',
      type: 'output',
      name: 'User Info',
      inputs: [{ id: 'input', name: 'Input' }]
    }
  ],
  connections: [
    { sourceNodeId: 'data-input', sourcePortId: 'output', targetNodeId: 'parse-name', targetPortId: 'input' },
    { sourceNodeId: 'parse-name', sourcePortId: 'output', targetNodeId: 'result', targetPortId: 'input' }
  ]
};

const result = await runner.execute(jsonWorkflow);
console.log(result); // Extracted: "Alice"

3. Custom Node Creation

const runner = new ClaraFlowRunner();

// Register a custom node
runner.registerCustomNode({
  type: 'email-validator',
  name: 'Email Validator',
  executionCode: `
    function execute(inputs, properties, context) {
      const email = inputs.email || '';
      const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;
      const isValid = emailRegex.test(email);
      
      context.log('Validating email: ' + email);
      
      return {
        output: isValid,
        email: email,
        status: isValid ? 'valid' : 'invalid'
      };
    }
  `
});

// Use custom node in workflow
const emailWorkflow = {
  nodes: [
    {
      id: 'email-input',
      type: 'input',
      name: 'Email',
      data: { value: 'user@example.com' },
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'validator',
      type: 'email-validator',
      name: 'Validate Email',
      inputs: [{ id: 'email', name: 'Email' }],
      outputs: [{ id: 'output', name: 'Valid' }]
    },
    {
      id: 'result',
      type: 'output',
      name: 'Validation Result',
      inputs: [{ id: 'input', name: 'Input' }]
    }
  ],
  connections: [
    { sourceNodeId: 'email-input', sourcePortId: 'output', targetNodeId: 'validator', targetPortId: 'email' },
    { sourceNodeId: 'validator', sourcePortId: 'output', targetNodeId: 'result', targetPortId: 'input' }
  ]
};

const result = await runner.execute(emailWorkflow);
console.log(result); // Email validation result

4. AI/LLM Integration

const aiWorkflow = {
  nodes: [
    {
      id: 'prompt',
      type: 'input',
      name: 'User Prompt',
      data: { value: 'Explain quantum computing in simple terms' },
      outputs: [{ id: 'output', name: 'Output' }]
    },
    {
      id: 'ai-chat',
      type: 'llm',
      name: 'AI Assistant',
      data: {
        apiKey: process.env.OPENAI_API_KEY,
        model: 'gpt-3.5-turbo',
        temperature: 0.7
      },
      inputs: [
        { id: 'user', name: 'User Message' },
        { id: 'system', name: 'System Message' }
      ],
      outputs: [{ id: 'output', name: 'Response' }]
    },
    {
      id: 'response',
      type: 'output',
      name: 'AI Response',
      inputs: [{ id: 'input', name: 'Input' }]
    }
  ],
  connections: [
    { sourceNodeId: 'prompt', sourcePortId: 'output', targetNodeId: 'ai-chat', targetPortId: 'user' },
    { sourceNodeId: 'ai-chat', sourcePortId: 'output', targetNodeId: 'response', targetPortId: 'input' }
  ]
};

const result = await runner.execute(aiWorkflow);
console.log(result['response'].output); // AI explanation

🌐 Browser Usage

CDN (Quick Start)

<!DOCTYPE html>
<html>
<head>
    <title>Clara Flow SDK Demo</title>
</head>
<body>
    <script src="https://unpkg.com/clara-flow-sdk@2.0.0/dist/clara-flow-sdk.umd.min.js"></script>
    <script>
        const runner = new ClaraFlowSDK.ClaraFlowRunner();
        
        const simpleFlow = {
            nodes: [
                { id: 'in', type: 'input', data: { value: 'Hello Browser!' }, outputs: [{ id: 'output' }] },
                { id: 'out', type: 'output', inputs: [{ id: 'input' }] }
            ],
            connections: [
                { sourceNodeId: 'in', sourcePortId: 'output', targetNodeId: 'out', targetPortId: 'input' }
            ]
        };
        
        runner.execute(simpleFlow).then(result => {
            console.log('Result:', result);
        });
    </script>
</body>
</html>

Browser with File Upload

<input type="file" id="workflow-file" accept=".json">
<button onclick="runWorkflow()">Run Workflow</button>

<script>
async function runWorkflow() {
    const fileInput = document.getElementById('workflow-file');
    const file = fileInput.files[0];
    
    if (file) {
        const workflow = await ClaraFlowSDK.BrowserUtils.loadFlowFromFile(file);
        const runner = new ClaraFlowSDK.ClaraFlowRunner();
        const result = await runner.execute(workflow);
        console.log('Workflow result:', result);
    }
}
</script>

📋 Built-in Node Types

Node TypeDescriptionExample Use Case
inputAccept user inputForm data, parameters
outputDisplay resultsFinal output, responses
static-textFixed text contentTemplates, prompts
combine-textMerge text inputsString concatenation
json-parseParse JSON dataAPI response processing
if-elseConditional logicDecision making
llmAI language modelChat, text generation
structured-llmStructured AI outputJSON generation
api-requestHTTP requestsExternal API calls

⚙️ Configuration Options

const runner = new ClaraFlowRunner({
  enableLogging: true,        // Enable console logging
  timeout: 30000,            // Execution timeout (ms)
  logLevel: 'info',          // Log level: 'info', 'warn', 'error'
  maxRetries: 3              // Max retry attempts
});

🔧 Clara Studio Integration

Import workflows directly from Clara Studio:

// Export from Clara Studio as "SDK Enhanced" format
const studioExport = {
  format: 'clara-sdk',
  version: '1.0.0',
  flow: { /* workflow definition */ },
  customNodes: [ /* custom node definitions */ ]
};

// Execute directly
const result = await runner.execute(studioExport, inputs);

🐛 Error Handling

try {
  const result = await runner.execute(workflow, inputs);
  console.log('Success:', result);
} catch (error) {
  console.error('Workflow failed:', error.message);
  
  // Get detailed logs
  const logs = runner.getLogs();
  console.log('Execution logs:', logs);
}

📊 Monitoring & Debugging

const runner = new ClaraFlowRunner({ enableLogging: true });

// Execute workflow
await runner.execute(workflow);

// Get execution logs
const logs = runner.getLogs();
logs.forEach(log => {
  console.log(`[${log.level}] ${log.message}`, log.data);
});

// Clear logs
runner.clearLogs();

🚀 Server Deployment (Coming Soon)

The SDK is designed to work seamlessly with server deployment:

// Future server integration
import express from 'express';
import { ClaraFlowRunner } from 'clara-flow-sdk';

const app = express();
const runner = new ClaraFlowRunner();

app.post('/execute', async (req, res) => {
  try {
    const { workflow, inputs } = req.body;
    const result = await runner.execute(workflow, inputs);
    res.json({ success: true, result });
  } catch (error) {
    res.status(500).json({ success: false, error: error.message });
  }
});

📝 TypeScript Support

import { ClaraFlowRunner, BrowserUtils } from 'clara-flow-sdk';

interface WorkflowResult {
  [key: string]: any;
}

const runner: ClaraFlowRunner = new ClaraFlowRunner({
  enableLogging: true,
  timeout: 30000
});

const result: WorkflowResult = await runner.execute(workflow, inputs);

🤝 Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

Made with ❤️ by the Clara Team

Keywords

clara

FAQs

Package last updated on 27 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.