Domain
URL-based namespaces that define context for AI and data
Domain
A Domain is the foundational namespace for all primitives. In this architecture, everything is URL-addressable - agents don't know file systems, they only know URLs.
The Namespace IS the Context
Here's the key insight: your domain namespace IS the $context - and this works on two levels simultaneously:
Semantic Context (JSON-LD)
In mdxld, every domain defines a JSON-LD @context that gives semantic meaning to your data:
$context: https://acme.do/
$type: Customer
name: Acme CorpThe namespace https://acme.do/ becomes the context that defines what "Customer", "name", and every other term means within your domain.
AI Context (LLM)
But here's the beautiful double-entendre: in AI systems, context is everything. The context window is what the LLM uses to understand, reason, and respond. When you define a domain:
- You're giving the AI the semantic context to understand your business vocabulary
- You're providing the cognitive context for the AI to reason about your domain
- Every Noun, Verb, and Function you define enriches this context
// Your domain IS the context
const acme = Domain('acme.do')
// When an AI agent operates in this domain,
// it understands what "Customer", "Invoice", "approve" mean
// because the domain provides both semantic AND cognitive contextThe namespace doesn't just organize your data - it teaches AI how to think about your business.
Overview
Every Noun, Verb, Thing, Function, and Agent lives within a domain. Domains provide identity, discovery, and access control.
import { Domain } from 'ai-functions'
// Define your domain
const domain = Domain('acme.do')
// Everything is URL-addressable
domain.nouns // https://acme.do/nouns
domain.functions // https://acme.do/functions
domain.agents // https://acme.do/agents
domain.things // https://acme.do/thingsURL-First Architecture
Agents interact with the world through URLs:
// Agents discover capabilities via URLs
const customer = await fetch('https://acme.do/things/customer/cust_123')
const approve = await fetch('https://acme.do/verbs/approve')
const summarize = await fetch('https://acme.do/functions/summarize')
// Execute functions via HTTP
const result = await fetch('https://acme.do/functions/summarize', {
method: 'POST',
body: JSON.stringify({ text: document }),
})Domain Configuration
import { Domain } from 'ai-functions'
const domain = Domain('mycompany.do', {
// Display name
name: 'My Company',
// Domain description for discovery
description: 'AI-powered business automation',
// Authentication
auth: {
provider: 'oauth.do',
methods: ['api-key', 'oauth2'],
},
// Access control
access: {
public: ['functions/summarize', 'nouns/*'],
authenticated: ['things/*', 'actions/*'],
admin: ['agents/*', 'config/*'],
},
})Resource URLs
Every resource has a canonical URL:
// Nouns (type definitions)
https://acme.do/nouns/Customer
https://acme.do/nouns/Invoice
// Things (instances)
https://acme.do/things/customer/cust_123
https://acme.do/things/invoice/inv_456
// Verbs (operations)
https://acme.do/verbs/approve
https://acme.do/verbs/ship
// Functions (AI capabilities)
https://acme.do/functions/summarize
https://acme.do/functions/translate
// Agents
https://acme.do/agents/sales-assistant
https://acme.do/agents/support-bot
// Workflows
https://acme.do/workflows/onboarding
https://acme.do/workflows/order-fulfillmentDiscovery
Domains expose their capabilities for AI discovery:
// Well-known discovery endpoint
const capabilities = await fetch('https://acme.do/.well-known/ai')
// Returns structured capability manifest
{
domain: 'acme.do',
nouns: ['Customer', 'Invoice', 'Order'],
verbs: ['create', 'approve', 'ship', 'refund'],
functions: ['summarize', 'classify', 'extract'],
agents: ['sales-assistant', 'support-bot'],
}Cross-Domain References
Things can reference resources in other domains:
const order = Thing(Order, {
customer: 'https://crm.do/things/customer/cust_123',
payment: 'https://payments.do/things/charge/ch_789',
shipping: 'https://logistics.do/things/shipment/ship_456',
})Domain Federation
Domains can federate and trust each other:
const domain = Domain('acme.do', {
federation: {
trusted: ['partners.do', 'suppliers.do'],
permissions: {
'partners.do': ['read:things', 'execute:functions'],
'suppliers.do': ['read:nouns'],
},
},
})Context Propagation
When you execute a function or deploy an agent, the domain context flows through:
// The domain context enriches every operation
const result = await domain.functions.summarize({
text: customerFeedback,
// The AI knows "customer" means YOUR definition of customer
// It knows your business vocabulary, your entities, your relationships
})
// Agents inherit domain context
const agent = domain.agents.supportBot
// This agent thinks in terms of YOUR Nouns, YOUR Verbs, YOUR business rulesThis is why domains are so powerful: they're not just organizational units or URL prefixes. They're the shared understanding between your data, your code, and your AI.
See Also
- Noun - Types within a domain
- Thing - Instances within a domain
- Function - Capabilities exposed by a domain
- Agent - Actors operating within domains
- mdxld - MDX with Linked Data and
$context