-
-
Notifications
You must be signed in to change notification settings - Fork 5
Javascript ‐ 2. Protocol Specifications
A ⚪ Universal Model
is a standardized, self-contained and configurable interface able to run a given model, irrespective of the consumer hardware and without requiring domain expertise.
It embeddeds a model (i.e. hosted, fetched, or local), one or more engines (e.g. transformers, lama.cpp, mlx-lm, web-llm), runtime dependencies for each device type (e.g. CUDA, MPS, WebGPU), and exposes a standard interface.
While configurable, every aspect is preset for the user, based on automatic device detection and dynamic model precision, in order to abstract complexity and provide a simplified and portable interface.
Providers: In the intent of preseting a
Universal Model
for non-technical mass adoption, we recommend defaulting to 4/8 bit quantization.
A ⚪ Universal Tool
is a standardized tool interface, usable by any Universal Agent
.
Tools allow interacting with other systems (e.g. API, database) or performing scripted tasks.
When
Universal Tools
require accessing remote services, we recommend standardizing those remote interfaces as well using MCP Servers, for greater portability. Many MCP servers have already been shared with the community and are ready to use, see available MCP servers for details.
A ⚪ Universal Agent
is a standardized, configurable and composable agent, powered by a Universal Model
, Universal Tools
and other Universal Agents
.
While configurable, every aspect is preset for the user, in order to abstract complexity and provide a simplified and portable interface.
Through standardization, Universal Agent
can seemlessly and dynamically integrate with other Universal Intelligence
components to achieve any task, and/or share hardware recources (i.e. sharing a common Universal Model
) —allowing it to generalize and scale at virtually no cost.
When
Universal Agents
require accessing remote agents, we recommend leveraging Google's A2A Protocols, for greater compatibility.
In simple terms:
Universal Model = 🧠
Universal Tool = 🔧
Universal Agent = 🤖
🤖 = 🧠 + [🔧, 🔧,..] + [🤖, 🤖,..]
import Model from "<provider>"
const model = new Model()
const [result, logs] = await model.process("Hello, how are you?") // 'Feeling great! How about you?'
Automatically optimized for any supported browser / native web container 🔥
Simple does not mean limited. Most advanted configuration
options remain available.
Those are defined by and specific to the universal model provider.
We encourage providers to use industry standard Hugging Face Transformers specifications, irrespective of the backend internally used for the detected device and translated accordingly, allowing for greater portability and adoption.
import Model from "<provider>"
const model = new Model({
credentials: '<token>', // (or) object containing credentials eg. { id: 'example', passkey: 'example' }
engine: 'webllm', // (or) ordered by priority ['transformers', 'llama.cpp']
quantization: 'MLC_4', // (or) ordered by priority ['Q4_K_M', 'Q8_0'] (or) auto in range {'default': 'Q4_K_M', 'minPrecision': '4bit', 'maxPrecision': '8bit'}
maxMemoryAllocation: 0.8, // maximum allowed memory allocation in percentage
configuration: {
// (example)
// "processor": {
// e.g. Tokenizer https://huggingface.co/docs/transformers/fast_tokenizers
//
// model_max_length: 4096,
// model_input_names: ['token_type_ids', 'attention_mask']
// ...
// },
// "model": {
// e.g. AutoModel https://huggingface.co/docs/transformers/models
//
// torch_dtype="auto"
// device_map="auto"
// ...
// },
// "disableMemorySafety": false
},
verbose: true // (or) string describing the log level
})
const [result, logs] = await model.process(
[
{
"role": "system",
"content": "You are a helpful model to recall schedules."
},
{
"role": "user",
"content": "What did I do in May?"
},
], // multimodal
{
context: ["May: Went to the Cinema", "June: Listened to Music"], // multimodal
configuration: {
// (example)
// e.g. AutoModel Generate https://huggingface.co/docs/transformers/llm_tutorial
//
// max_new_tokens=2000,
// use_cache=true,
// temperature=1.0
// ...
},
remember: true, // remember this interaction
stream: false, // stream output asynchronously
keepAlive: true // keep model loaded after processing the request
}
) // 'In May, you went to the Cinema.'
import Model from "<provider>"
const model = new Model()
// Optional
await model.load() // loads the model in memory (otherwise automatically loaded/unloaded on execution of `.process()`)
await model.loaded() // checks if model is loaded
await model.unload() // unloads the model from memory (otherwise automatically loaded/unloaded on execution of `.process()`)
await model.reset() // resets remembered chat history
await model.configuration() // gets current model configuration
// Class Optional
Model.contract() // Contract
Model.compatibility() // Compatibility
import Tool from "<provider>"
const tool = new Tool(
// { "any": "configuration" }
)
const [result, logs] = tool.exampleTask(data) // (or async)
import Tool from "<provider>"
// Class Optional
Tool.contract() // Contract
Tool.requirements() // Configuration Requirements
import Agent from "<provider>"
const agent = new Agent(
// {
// model: new Model(), // customize or share 🧠 across [🤖,🤖,🤖,..]
// expandTools: [new Tool()], // expand 🔧 set
// expandTeam: [new OtherAgent()] // expand 🤖 team
// }
)
const [result, logs] = await agent.process('What happened on Friday?') // > (tool call) > 'Friday was your birthday!'
Modular, and automatically optimized for any browser / native web container 🔥
Most advanted configuration
options remain available.
Those are defined by and specific to the universal model provider.
We encourage providers to use industry standard Hugging Face Transformers specifications, irrespective of the backend internally used for the detected device and translated accordingly, allowing for greater portability and adoption.
import Agent from "<provider>"
import OtherAgent from "<other_provider>"
import Model from "<provider>"
import Tool from "<provider>"
// This is where the magic happens ✨
// Standardization of all layers make agents composable and generalized.
// They can now utilize any 3rd party tools or agents on the fly to achieve any tasks.
// Additionally, the models powering each agent can now be hot-swapped so that
// a team of agents shares the same intelligence(s), thus removing hardware overhead,
// and scaling at virtually no cost.
const agent = new Agent({
credentials: '<token>', // (or) object containing credentials eg. { id: 'example', passkey: 'example' }
model: new Model(), // see Universal Model API for customizations
expandTools: [new Tool()], // see Universal Tool API for customizations
expandTeam:[new OtherAgent()], // see Universal Agent API for customizations
configuration: {
// agent configuration (eg. guardrails, behavior, tracing)
},
verbose: true // or string describing log level
})
const [result, logs] = await agent.process(
[
{
"role": "system",
"content": "You are a helpful model to recall schedules and set events."
},
{
"role": "user",
"content": "Can you schedule what we did in May again for the next month?"
},
], // multimodal
{
context: ['May: Went to the Cinema', 'June: Listened to Music'], // multimodal
configuration: {
// (example)
// e.g. AutoModel Generate https://huggingface.co/docs/transformers/llm_tutorial
//
// max_new_tokens=2000,
// use_cache=True,
// temperature=1.0
// ...
},
remember: true, // remember this interaction
stream: false, // stream output asynchronously
extraTools: [new Tool()], // extra tools available for this inference; call `agent.connect()` link during initiation to persist them
extraTeam: [new OtherAgent()], // extra agents available for this inference; call `agent.connect()` link during initiation to persist them
keepAlive: true // keep model loaded after processing the request
}
)
// > "In May, you went to the Cinema. Let me check the location for you."
// > (tool call: database)
// > "It was in Hollywood. Let me schedule a reminder for next month."
// > (agent call: scheduler)
// > "Alright you are all set! Hollywood cinema is now scheduled again in July."
import Agent from "<provider>"
import OtherAgent from "<other_provider>"
import Model from "<provider>"
import Tool from "<provider>" // e.g. API, database
const agent = new Agent()
const otherAgent = new OtherAgent()
const tool = new Tool()
// Optional
await agent.load() // loads the agent's model in memory (otherwise automatically loaded/unloaded on execution of `.process()`)
await agent.loaded() // checks if agent is loaded
await agent.unload() // unloads the agent's model from memory (otherwise automatically loaded/unloaded on execution of `.process()`)
await agent.reset() // resets remembered chat history
await agent.connect({ tools: [tool], agents: [otherAgent] }) // connects additionnal tools/agents
await agent.disconnect({ tools: [tool], agents: [otherAgent] }) // disconnects tools/agents
// Class Optional
Agent.contract() // Contract
Agent.requirements() // Configuration Requirements
Agent.compatibility() // Compatibility
A self-contained environment for running AI models with standardized interfaces.
Method | Parameters | Return Type | Description |
---|---|---|---|
constructor |
• payload.credentials?: str | Record<string, any> = None : Authentication information (e.g. authentication token (or) object containing credentials such as { id: 'example', passkey: 'example' })• payload.engine?: string | string[] : Engine used (e.g., 'transformers', 'llama.cpp', (or) ordered by priority ['transformers', 'llama.cpp']). Prefer setting quantizations over engines for broader portability.• payload.quantization?: string | string[] | QuantizationSettings : Quantization specification (e.g., 'Q4_K_M', (or) ordered by priority ['Q4_K_M', 'Q8_0'] (or) auto in range {'default': 'Q4_K_M', 'minPrecision': '4bit', 'maxPrecision': '8bit'})• payload.maxMemoryAllocation?: number : Maximum allowed memory allocation in percentage• payload.configuration?: Record<string, any> : Configuration for model and processor settings• payload.verbose?: boolean | string = "DEFAULT" : Enable/Disable logs, or set a specific log level |
void |
Initialize a Universal Model |
process |
• input: any | Message[] : Input or input messages• payload.context?: any[] : Context items (multimodal supported)• payload.configuration?: Record<string, any> : Runtime configuration• payload.remember?: boolean : Whether to remember this interaction. Please be mindful of the available context length of the underlaying model.• payload.keepAlive?: boolean : Keep model loaded for faster consecutive interactions• payload.stream?: boolean : Stream output asynchronously |
Promise<[any | null, Record<string, any>]> |
Process input through the model and return output and logs. The output is typically the model's response and the logs contain processing metadata |
load |
None | Promise<void> |
Load model into memory |
loaded |
None | Promise<boolean> |
Check if model is currently loaded in memory |
unload |
None | Promise<void> |
Unload model from memory |
reset |
None | Promise<void> |
Reset model chat history |
configuration |
None | Promise<Record<string, any>> |
Get current model configuration |
ready |
None | Promise<void> |
Wait for the model to be ready |
(class).contract |
None | Contract |
Model description and interface specification |
(class).compatibility |
None | Compatibility[] |
Model compatibility specification |
A standardized interface for tools that can be used by models and agents.
Method | Parameters | Return Type | Description |
---|---|---|---|
constructor |
• configuration?: Record<string, any> : Tool configuration including credentials |
void |
Initialize a Universal Tool |
(class).contract |
None | Contract |
Tool description and interface specification |
(class).requirements |
None | Requirement[] |
Tool configuration requirements |
Additional methods are defined by the specific tool implementation and documented in the tool's contract.
Any tool specific method must return a Promise<[any, Record<string, any>]>
, respectively (result, logs)
.
An AI agent powered by Universal Models and Tools with standardized interfaces.
Method | Parameters | Return Type | Description |
---|---|---|---|
constructor |
• payload.credentials?: str | Record<string, any> = None : Authentication information (e.g. authentication token (or) object containing credentials such as { id: 'example', passkey: 'example' })• payload.model?: AbstractUniversalModel : Model powering this agent• payload.expandTools?: AbstractUniversalTool[] : Tools to connect• payload.expandTeam?: AbstractUniversalAgent[] : Other agents to connect• payload.configuration?: Record<string, any> : Agent configuration (eg. guardrails, behavior, tracing)• payload.verbose?: boolean | string = "DEFAULT" : Enable/Disable logs, or set a specific log level |
void |
Initialize a Universal Agent |
process |
• input: any | Message[] : Input or input messages• payload.context?: any[] : Context items (multimodal)• payload.configuration?: Record<string, any> : Runtime configuration• payload.remember?: boolean : Remember this interaction. Please be mindful of the available context length of the underlaying model.• payload.stream?: boolean : Stream output asynchronously• payload.extraTools?: AbstractUniversalTool[] : Additional tools• payload.extraTeam?: AbstractUniversalAgent[] : Additional agents• payload.keepAlive?: boolean : Keep underlaying model loaded for faster consecutive interactions |
Promise<[any | null, Record<string, any>]> |
Process input through the agent and return output and logs. The output is typically the agent's response and the logs contain processing metadata including tool/agent calls |
load |
None | Promise<void> |
Load agent's model into memory |
loaded |
None | Promise<boolean> |
Check if the agent's model is currently loaded in memory |
unload |
None | Promise<void> |
Unload agent's model from memory |
reset |
None | Promise<void> |
Reset agent's chat history |
connect |
• payload.tools?: AbstractUniversalTool[] : Tools to connect• payload.agents?: AbstractUniversalAgent[] : Agents to connect |
Promise<void> |
Connect additional tools and agents |
disconnect |
• payload.tools?: AbstractUniversalTool[] : Tools to disconnect• payload.agents?: AbstractUniversalAgent[] : Agents to disconnect |
Promise<void> |
Disconnect tools and agents |
(class).contract |
None | Contract |
Agent description and interface specification |
(class).requirements |
None | Requirement[] |
Agent configuration requirements |
(class).compatibility |
None | Compatibility[] |
Agent compatibility specification |
Field | Type | Description |
---|---|---|
role |
string |
The role of the message sender (e.g., "system", "user") |
content |
any |
The content of the message (multimodal supported) |
Field | Type | Description |
---|---|---|
maxLength |
number? |
Maximum length constraint |
pattern |
string? |
Pattern constraint |
minLength |
number? |
Minimum length constraint |
nested |
Argument[]? |
Nested argument definitions for complex types |
properties |
Record<string, Schema>? |
Property definitions for object types |
items |
Schema? |
Schema for array items |
oneOf |
any[]? |
One of the specified schemas |
Field | Type | Description |
---|---|---|
name |
string |
Name of the argument |
type |
string |
Type of the argument |
schema |
Schema? |
Schema constraints |
description |
string |
Description of the argument |
required |
boolean |
Whether the argument is required |
Field | Type | Description |
---|---|---|
type |
string |
Type of the output |
description |
string |
Description of the output |
required |
boolean |
Whether the output is required |
schema |
Schema? |
Schema constraints |
Field | Type | Description |
---|---|---|
name |
string |
Name of the method |
description |
string |
Description of the method |
arguments |
Argument[] |
List of method arguments |
outputs |
Output[] |
List of method outputs |
asynchronous |
boolean? |
Whether the method is asynchronous (default: false) |
Field | Type | Description |
---|---|---|
name |
string |
Name of the contract |
description |
string |
Description of the contract |
methods |
Method[] |
List of available methods |
Field | Type | Description |
---|---|---|
name |
string |
Name of the requirement |
type |
string |
Type of the requirement |
schema |
Schema |
Schema constraints |
description |
string |
Description of the requirement |
required |
boolean |
Whether the requirement is required |
Field | Type | Description |
---|---|---|
engine |
string |
Supported engine |
quantization |
string |
Supported quantization |
devices |
string[] |
List of supported devices |
memory |
number |
Required memory in GB |
dependencies |
string[] |
Required software dependencies |
precision |
number |
Precision in bits |
Field | Type | Description |
---|---|---|
default |
string? |
Default quantization to use (e.g., 'Q4_K_M') |
minPrecision |
string? |
Minimum precision requirement (e.g., '4bit') |
maxPrecision |
string? |
Maximum precision requirement (e.g., '8bit') |
Abstract classes and types for Universal Intelligence
components are made available by the package if you wish to develop and publish your own.
# Install abstracts
npm install universalintelligence
import universalintelligence from "universalintelligence"
const { AbstractUniversalModel, AbstractUniversalTool, AbstractUniversalAgent, UniversalIntelligenceTypes } = universalintelligence
class UniversalModel extends AbstractUniversalModel {
// ...
}
class UniversalTool extends AbstractUniversalTool {
// ...
}
class UniversalAgent extends AbstractUniversalAgent {
// ...
}
If you wish to contribute to community based components, mixins are made available to allow quickly bootstrapping new Universal Models
.
See Community>Development section below for additional information.