### Run the blog example app Source: https://github.com/agentlang-ai/agentlang/blob/main/example/blog/README.md Starts the example blog application using the AgentLang CLI. ```shell $ node ./bin/cli.js run example/blog ``` -------------------------------- ### Start the Agentlang runtime Source: https://github.com/agentlang-ai/agentlang/blob/main/example/customer_support_system/README.md Runs the customer support system example with the Agentlang CLI. ```bash $ node ./bin/cli.js run example/customer_support_system ``` -------------------------------- ### Run Agentlang service Source: https://github.com/agentlang-ai/agentlang/blob/main/example/custom_config/README.md Starts the Agentlang service for the custom_config example. Run this command from the project root. ```bash node ./bin/cli.js run example/custom_config ``` -------------------------------- ### Start the knowledge service Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Run the Agentlang CLI to start the knowledge service from the repository root. ```bash node ./bin/cli.js run example/knowledge ``` -------------------------------- ### Install dependencies Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Install the required npm packages for the knowledge service. ```bash cd example/knowledge npm install ``` -------------------------------- ### Example response from supportAgent Source: https://github.com/agentlang-ai/agentlang/blob/main/example/camera_info/README.md Example response from the supportAgent, showing a knowledge-grounded answer about setting white balance on a Canon G7X. ```json "To set the white balance on a Canon G7X camera, you will need to access the white balance settings through the camera's menu. Once there, you can select from various presets such as Auto, Daylight, Cloudy, and Tungsten, or opt for a custom setting. If you want to use a custom white balance, you'll need a gray or white card for calibration. Position the card in the same lighting conditions as your subject, and follow the camera’s instructions to set the custom white balance for accurate color representation in your photos." ``` -------------------------------- ### Example output from runMigrations Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/migrations.md Example output from the runMigrations command, showing pending SQL statements and a successful migration simulation. If the simulation detects problems, it reports errors and aborts. ```text info: Pending migration queries: info: [1] ALTER TABLE "MyApp/Product" ADD "description" varchar info: [2] ALTER TABLE "MyApp/Product" ADD "price" double precision info: Migration simulation passed. info: Run `applyMigration` to apply these changes. ``` -------------------------------- ### Document Service Setup Environment Variables Source: https://github.com/agentlang-ai/agentlang/blob/main/example/custom_config/README.md Bash commands to set environment variables for the document service. Required for the document-service provider examples. ```bash export DOCUMENT_SERVICE_URL=https://docstore.fractl.io export DOCUMENT_SERVICE_AUTH_TOKEN= ``` -------------------------------- ### Install Agentlang CLI globally with npm Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Install the Agentlang CLI globally using npm. ```shell npm i -g @agentlang/cli ``` -------------------------------- ### Full MCP integration example in Agentlang Source: https://github.com/agentlang-ai/agentlang/blob/main/example/mcpdemo/README.md Complete example module 'mcpdemo.core' that defines an agent with an MCP tool, creates an MCP client, and defines a workflow that calls an MCP tool. It includes the MCP server configuration and the client creation event. ```agentlang module mcpdemo.core @public agent chatAgent { instruction "Answer user queries", tools [deepwiki] } { "type": "mcp", "server_label": "deepwiki", "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never" } @as deepwiki { agentlang.mcp/createClient { name "deepwiki", serverUrl "https://mcp.deepwiki.com/mcp" } } @public workflow askDeepWiki { { deepwiki.mcp/ask_question { repoName: askDeepWiki.repName, question: askDeepWiki.question } } } ``` -------------------------------- ### Install dependencies with npm or pnpm Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Install dependencies using either npm or pnpm. If pnpm shows build script warnings, run `pnpm approve-builds` and approve esbuild and sqlite3. ```shell npm install ``` ```shell pnpm install ``` -------------------------------- ### Agentlang ticket triage example with flow, agent, decision, and workflow Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Complete Agentlang example showing a flow, agent, decision table, and workflow for ticket triage. The agent uses the gpt4o LLM with a role and goal, and a glossary of terms. The decision table maps natural-language cases to tags that guide the flow. ```typescript flow TicketFlow { ticketTriager --> "DNS" ticketInProgress ticketTriager --> "WLAN" ticketInProgress ticketTriager --> "NotEnoughInfo" ticketPending } agent TicketFlow { llm "gpt4o", role "ticket_manager", goal "You are a network ticket management application. Your job is to triage any ticket passed to you and update the ticket with appropriate assigned_to, status and triaging comments.", glossary [ {"name": "incident", "meaning": "a problem report", "synonyms": "ticket"}, {"name": "task", "meaning": "a record that captures some work that needs to be done", "synonyms": "ticket"}, {"name": "DNS", "meaning": "Domain Name Service - is used to translate human-readable domain names to IP addresses", "synonyms": "DNS name, CNAME, DNS HOST record"} {"name": "WLAN", "meaning": "Wireless LAN - wireless network to connect devices to each other and the internet", "synonyms": "Office network"} ] } decision ticketTriager { case ("Ticket is related to DNS provisioning. If the request is to point one host/DNS name to an IP address") { DNS } case ("Ticket is related to WLAN provisioning. If the request is to add/whitelist a MAC address on the wireless network") { WLAN } case ("There is not enough information in the ticket about what the category is") { NotEnoughInfo } default { Other } } workflow ticketInProgress { // workflow body is declarative code that is executed by the symbolic runtime ... } ``` -------------------------------- ### Start the rclone daemon Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Start the rclone RC daemon on port 5572, optionally with authentication. ```bash rclone rcd --rc-addr :5572 ``` ```bash export RCLONE_RC_USER=admin export RCLONE_RC_PASS=secret rclone rcd --rc-addr :5572 --rc-user $RCLONE_RC_USER --rc-pass $RCLONE_RC_PASS ``` ```bash curl -s http://localhost:5572/rc/noop -d '{}' | jq . ``` -------------------------------- ### Run Agentlang application: parseAndValidate and run Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Commands to switch to an example directory, parse and validate an Agentlang file, and run the app. ```shell # switch to example directory where package.json is located cd example/blog # Parse and validate an Agentlang file present in that directory agent parseAndValidate blog.al # Run the app agent run ``` -------------------------------- ### POST /knowledge.core/startSyncScheduler Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Start the sync scheduler to begin periodic syncing of ready connections. ```APIDOC ## POST /knowledge.core/startSyncScheduler ### Description Starts the sync scheduler, which syncs all ready connections on a timer. ### Method POST ### Endpoint http://localhost:8080/knowledge.core/startSyncScheduler ### Parameters #### Request Body - (empty object) - Required - An empty JSON object is sent. ### Request Example {} ### Response #### Success Response (200) - No explicit response body described. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Project file structure for Gmail integration Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Shows the directory layout for the Gmail integration example, with config.al at the root and gmail.al and resolver.js under src/. ```text my_app/ config.al src/ gmail.al resolver.js ``` -------------------------------- ### Initialize configuration with config.al Source: https://github.com/agentlang-ai/agentlang/blob/main/example/custom_config/README.md Configuration file for the custom_config example. The first block populates the Config entity at startup with server and key values, using #js expressions to read environment variables or a secret function. The second block defines service and store settings, with the port read from SERVICE_PORT or defaulting to 8080. These values are accessible to resolvers via fetchConfig. ```agentlang { custom_config.core/Config: { server: "https://my.chat", key: "#js process.env.CHAT_SECRET" // or "#js readSecret(\"CHAT_SECRET\")" } } { "service": { "port": "#js parseInt(process.env.SERVICE_PORT || '8080')" }, "store": { "type": "sqlite", "dbname": "cc.db" } } ``` -------------------------------- ### GET /agentlang/oauth/authorize-url Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Starts the OAuth consent flow and returns the authorization URL to redirect the user to. ```APIDOC ## [GET] /agentlang/oauth/authorize-url ### Description Starts the OAuth consent flow. Returns the authorization URL to redirect the user to. ### Method GET ### Endpoint /agentlang/oauth/authorize-url ### Parameters #### Query Parameters - **provider** (string) - Required - Provider key from your connections config - **redirectUri** (string) - Required - URL to redirect the user back to after authorization ### Response #### Success Response (200) - **authorizationUrl** (string) - The authorization URL to redirect the user to - **state** (string) - A state value for CSRF protection #### Response Example { "authorizationUrl": "https://accounts.google.com/o/oauth2/v2/auth?...", "state": "abc123" } ``` -------------------------------- ### Trigger a sync Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Start the sync scheduler or trigger a one-off sync for a specific connection. ```bash curl -s -X POST http://localhost:8080/knowledge.core/startSyncScheduler \ -H 'Content-Type: application/json' \ -d '{}' | jq . ``` ```bash curl -s -X POST http://localhost:8080/knowledge.core/syncTick \ -H 'Content-Type: application/json' \ -d '{}' | jq . ``` -------------------------------- ### GET /knowledge.core/Topic Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md List all topics. ```APIDOC ## GET /knowledge.core/Topic ### Description Lists all topics. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/Topic ### Parameters (No parameters described.) ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns a list of Topic entities. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Recommended production deploy sequence Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/migrations.md Recommended deploy sequence for production. If step 4 is run before step 3, the app will refuse to start with a schema mismatch error. ```text 1. Deploy new code (with updated entity definitions) 2. agentlang runMigrations app.al -c config.json # review 3. agentlang applyMigration app.al -c config.json # apply 4. Start the app in production mode ``` -------------------------------- ### GET /knowledge.core/SyncChangelog Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md List all sync changelog entries. ```APIDOC ## GET /knowledge.core/SyncChangelog ### Description Lists all sync changelog entries. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/SyncChangelog ### Parameters (No parameters described.) ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns a list of SyncChangelog entities. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Fetch monitoring data with pagination Source: https://github.com/agentlang-ai/agentlang/blob/main/example/monitoring/README.md Fetch all monitoring data for an event or agent with pagination using the agentlang/fetchEventMonitors endpoint. The example uses limit 5 and offset 0. ```bash curl -X POST http://localhost:8080/agentlang/fetchEventMonitors \ -H 'Content-Type: application/json' \ -d '{"eventName": "acme.core/customerProductManager", "limit": 5, "offset": 0}' | jq . ``` -------------------------------- ### GET /knowledge.core/SyncJob Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md List all sync jobs. ```APIDOC ## GET /knowledge.core/SyncJob ### Description Lists all sync jobs. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/SyncJob ### Parameters (No parameters described.) ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns a list of SyncJob entities. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Agents and Flows Source: https://github.com/agentlang-ai/agentlang/blob/main/example/monitoring/README.md Defines the three key agents involved in the example: createCustomer, createProduct, and the customerProductManager agent. These agents use the product_manager role and tools from the acme.core module. ```agentlang agent createCustomer { role "product_manager", instruction "Using the data provided by the user, create a new customer.", tools [acme.core/Customer] } agent createProduct { role "product_manager", instruction "Using the data provided by the user, create a new product.", tools [acme.core/Product] } ``` -------------------------------- ### startSyncScheduler and stopSyncScheduler workflows Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/docs/knowledge-architecture.md Start and stop the sync scheduler. startSyncScheduler queries for a Config singleton, creates one with defaults if none exists, and sets a timer using syncSchedulerIntervalSec. stopSyncScheduler deletes the timer. ```agentlang @public workflow startSyncScheduler { {Config {}} @empty {Config {}} @as [config]; {agentlang/timer {name "sync-scheduler", duration config.syncSchedulerIntervalSec, unit "second", trigger "knowledge.core/syncTick"}} } @public workflow stopSyncScheduler { delete {agentlang/timer {name? "sync-scheduler"}} } ``` -------------------------------- ### Agentlang Ontology Blog Example Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Defines a blogging domain with Post, Comment, and Category entities, relationships, RBAC access rules, and a postEditor agent that uses the Post entity as a tool. ```typescript module blog.core entity Post { id UUID @id @default(uuid()), title String, content String, postedBy Email, createdAt DateTime @default(now()), @rbac [(roles: [manager], allow: [create, read])] } entity Comment { id UUID @id @default(uuid()), content String, postedBy Email, postedOn DateTime @default(now()) } relationship PostComment contains(Post, Comment) entity Category { id UUID @id @default(uuid()), name String } relationship PostCategory between(Post, Category) @public agent postEditor { role "content_editor", instruction "Create a new blog post based on the outline provided to you.", tools [blog.core/Post] } ``` -------------------------------- ### Architecture diagram: Studio, Knowledge Service, and Integration Manager stack Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md ASCII diagram showing the three-service stack: Studio (Vite/React) on port 5173, Knowledge Service on 8080 with rclone daemon on 5572 and Integration Manager on 8085, and Integration Manager on 8085. Use this to understand how the services connect before starting them. ```text Studio (Vite/React) :5173 | +---> Knowledge Service :8080 (AgentLang app — document sync, topics, versioning) | | | +---> rclone daemon :5572 (cloud file operations) | +---> Integration Mgr :8085 (OAuth token management) | +---> Integration Manager :8085 (credential storage, OAuth flows) ``` -------------------------------- ### Get User with Posts Source: https://github.com/agentlang-ai/agentlang/blob/main/example/blog/README.md Retrieves posts for a user by providing the user UUID. ```shell POST http://localhost:8080/Blog.Core/GetUserPosts {"userId": ""} ``` -------------------------------- ### Set environment variables for Postgres and OpenAI Source: https://github.com/agentlang-ai/agentlang/blob/main/example/customer_support_system/README.md Set the database type to Postgres and provide the OpenAI API key. Required before starting the runtime. ```bash export AL_DB_TYPE=postgres export AGENTLANG_OPENAI_KEY= ``` -------------------------------- ### Resolver console output Source: https://github.com/agentlang-ai/agentlang/blob/main/example/custom_config/README.md Example console output from the resolver after creating a ChatMessage. Shows the server URL, the key, and the resolved message. ```text Connecting to chat server https://my.chat using key 333dwddsd7738 To: joe@acme.com, Body: Hello! ``` -------------------------------- ### Core model with Customer, Product, and Failure entities Source: https://github.com/agentlang-ai/agentlang/blob/main/example/monitoring/README.md Defines the data model for the monitoring example. The `decision classifyUserRequest` determines whether a request refers to a Customer, Product, or Other type. ```agentlang module acme.core entity Customer { email Email @id, name String, phone String } entity Product { id Int @id, name String, price Number } entity Failure { message String } ``` -------------------------------- ### GET /knowledge.core/Connection Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md List all Connection entities, optionally filtered by provider. ```APIDOC ## GET /knowledge.core/Connection ### Description Lists all Connection entities. Supports querying by provider using query parameters. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/Connection ### Parameters #### Query Parameters - **provider** (string) - Optional - Filter connections by provider (e.g., onedrive). ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns a list of Connection entities. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### GET /knowledge.core/KnowledgeDocument Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md List all knowledge documents, optionally filtered by connection. ```APIDOC ## GET /knowledge.core/KnowledgeDocument ### Description Lists all knowledge documents. Supports querying by connectionId. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/KnowledgeDocument ### Parameters #### Query Parameters - **connectionId** (string) - Optional - Filter documents by connection ID. ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns a list of KnowledgeDocument entities. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Pass extra headers to agentlang.authFetch() Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Shows passing additional headers to agentlang.authFetch(); they are merged on top of the auth headers. This example posts a Slack message. ```javascript const response = await agentlang.authFetch('slack', 'https://slack.com/api/chat.postMessage', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ channel: '#general', text: 'Hello!' }), }); ``` -------------------------------- ### Login to get auth token Source: https://github.com/agentlang-ai/agentlang/blob/main/example/blog/README.md Logs in to obtain an auth token when RBAC is enabled. ```shell POST http://localhost:8080/agentlang.auth/login {"email": "", "password": ""} ``` -------------------------------- ### Example curl request to trigger retry Source: https://github.com/agentlang-ai/agentlang/blob/main/example/validation/README.md Sends a POST request to the network provisioning manager without the required `requestedBy` field, causing validation failure and automatic retry. ```shell curl -X POST http://localhost:8080/net.core/networkProvisioningRequestManager \ -H 'Content-Type: application/json' \ -d '{"message": "provision dns with ip 192.3.3.1 and cname acme.com"}' ``` -------------------------------- ### agentlang.getOAuthAuthorizeUrl(integrationName, redirectUri) Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Initiates an OAuth consent flow by returning the authorization URL and state parameter. Redirect the user to the returned URL to start the consent process. ```APIDOC ## agentlang.getOAuthAuthorizeUrl(integrationName, redirectUri) ### Description Initiates an OAuth consent flow by returning the authorization URL and state parameter. Redirect the user to the returned URL to start the consent process. ### Method N/A (JavaScript function) ### Endpoint N/A ### Parameters - **integrationName** (string) - Required - The name of the integration. - **redirectUri** (string) - Required - The redirect URI to use after consent. ### Request Example ```js const { authorizationUrl, state } = await agentlang.getOAuthAuthorizeUrl( 'google-drive', 'http://localhost:3000/callback' ); ``` ### Response #### Success Response - **authorizationUrl** (string) - The URL to redirect the user to for consent. - **state** (string) - The state parameter to be used in the exchange step. #### Response Example ```js { authorizationUrl: 'https://...', state: '...' } ``` ``` -------------------------------- ### Define Email Qualification Agent Model Source: https://github.com/agentlang-ai/agentlang/blob/main/example/sdr/README.md Defines the email qualification agent model with input and output records. The agent starts with minimal domain knowledge and relies on the LLM's general reasoning ability. ```agentlang module sdr.core record InboundEmailPayload { sender String, recipients String, subject String, body String, date String, threadId String, gmailOwnerEmail String, hubspotOwnerId String } record EmailQualificationResult { needsProcessing Boolean, reason String, category String @enum( "business", "meeting", "sales", "automated", "newsletter", "spam", "unknown" ) @optional, sender String, recipients String, subject String, body String, date String, threadId String, gmailOwnerEmail String, hubspotOwnerId String } @public agent EmailQualificationAgent { llm "sonnet_llm", role "sales_ops", goal "You are an intelligent email qualification agent who determines if an email requires sales engagement processing.", tools [sdr.core/InboundEmailPayload], instruction "You receive an InboundEmailPayload instance as input. Your job is to determine if this email needs sales processing.", retry classifyRetry, responseSchema sdr.core/EmailQualificationResult } ``` -------------------------------- ### Training the Agent via agentLearning API Source: https://github.com/agentlang-ai/agentlang/blob/main/example/sdr/README.md Sends a training request to the agentLearning endpoint to add persistent learnings to the EmailQualificationAgent. The instruction provides keywords and examples to correctly classify meeting requests. This does not affect unrelated behavior and does not require restarting the agent or server. ```bash curl -X POST http://localhost:8080/agentlang.ai/agentLearning \ -H 'Content-Type: application/json' \ -d '{ "agentName": "EmailQualificationAgent", "agentModuleName": "sdr.core", "instruction": "If the email contains the keywords: schedule, meet, demo, call, calendar, available, time, appointment then set category to '\''meeting'\''. Examples of such emails: - Can we schedule a demo next week? - Are you available for a quick call? - Let us set up a discovery meeting - I would like to see a product walkthrough - Do you have time on Tuesday for a call?" }' ``` -------------------------------- ### Get auth headers for named integration via agentlang.getAuthHeaders() Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Returns auth headers for a named integration when outside a resolver or when targeting a different integration than the bound one. The comment shows the expected shape. ```javascript const headers = await agentlang.getAuthHeaders('gmail'); // { "Authorization": "Bearer eyJhbG..." } ``` -------------------------------- ### Inner join: Get customers with orders (customerOrders) Source: https://github.com/agentlang-ai/agentlang/blob/main/example/joins/README.md Performs an inner join, returning only customers who have at least one order. The response lists OrderID, CustomerName, and OrderDate for matching customers. ```bash curl -X POST http://localhost:8080/order.core/customerOrders \ -H 'Content-Type: application/json' \ -d '{}' ``` ```json [ {"OrderID":101,"CustomerName":"Joe","OrderDate":"2025-11-11T10:24:33.853Z"}, {"OrderID":102,"CustomerName":"Jake","OrderDate":"2025-11-11T10:24:33.856Z"}, {"OrderID":103,"CustomerName":"Joe","OrderDate":"2025-11-11T10:24:33.859Z"} ] ``` -------------------------------- ### Initialize sample data with curl POST to /order.core/initSampleData Source: https://github.com/agentlang-ai/agentlang/blob/main/example/joins/README.md Populates the database with a few customers and orders. Use this before running the join workflows so the sample data exists. ```bash curl -X POST http://localhost:8080/order.core/initSampleData \ -H 'Content-Type: application/json' \ -d '{}' ``` -------------------------------- ### Create sample data with curl Source: https://github.com/agentlang-ai/agentlang/blob/main/example/customer_support_system/README.md Adds executives and a customer via the support.core REST API. Requires the runtime to be running on localhost:8080. ```bash # Add executives curl -X POST http://localhost:8080/support.core/SupportExecutive \ -H 'Content-Type: application/json' \ -d '{"email": "exec01@edgy.com", "name": "Carol", "skills": ["IT", "networking", "internet"]}' curl -X POST http://localhost:8080/support.core/SupportExecutive \ -H 'Content-Type: application/json' \ -d '{"email": "exec02@edgy.com", "name": "Kory", "skills": ["payments", "finance", "billing"]}' # Add a customer curl -X POST http://localhost:8080/support.core/Customer \ -H 'Content-Type: application/json' \ -d '{"email": "cust01@acme.com", "name": "Joseph"}' ``` -------------------------------- ### GET Join Parameters Source: https://github.com/agentlang-ai/agentlang/blob/main/example/joins/README.md Auto-generated GET endpoints support join parameters for flexible data exploration. ```APIDOC ## GET Join Parameters ### Description Auto-generated GET endpoints support join parameters to perform inner, left, and right joins on related entities. ### Parameters #### Query Parameters - **@joinOn** (string) - Optional - Specifies an inner join. - **@leftJoinOn** (string) - Optional - Specifies a left join. - **@rightJoinOn** (string) - Optional - Specifies a right join. ### Usage These parameters allow flexible exploration of related entities without explicitly writing workflows. ``` -------------------------------- ### Create a new User with blog-posts Source: https://github.com/agentlang-ai/agentlang/blob/main/example/blog/README.md Creates a new user with blog posts via the CreateUserWithPosts endpoint. ```shell POST http://localhost:8080/Blog.Core/CreateUserWithPosts {"name": "Joe", "email": "joe@blog.com", "post1": "Good day", "post2": "Stay strong"} ``` -------------------------------- ### Configure PostgreSQL storage for the knowledge service Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Sets environment variables to switch the default SQLite storage to PostgreSQL, then runs the service. Required variables include STORE_TYPE, POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, and POSTGRES_PORT. ```bash export STORE_TYPE=postgres export POSTGRES_HOST=localhost export POSTGRES_USER=postgres export POSTGRES_PASSWORD=secret export POSTGRES_DB=knowledge_service export POSTGRES_PORT=5432 node ./bin/cli.js run example/knowledge ``` -------------------------------- ### Initialize schema with agent initSchema Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/migrations.md Use initSchema to create all tables from scratch for a fresh database, such as a first deploy to a new environment. This is a one-time operation. ```bash agent initSchema app.al -c config.json ``` -------------------------------- ### GET /knowledge.core/DocumentVersion Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md List document versions for a specific document. ```APIDOC ## GET /knowledge.core/DocumentVersion ### Description Lists document versions for a given document. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/DocumentVersion ### Parameters #### Query Parameters - **documentId** (string) - Required - The document ID to filter versions. ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns a list of DocumentVersion entities. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Build Agentlang Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Generate the parser and build the project. ```shell npm run langium:generate npm run build ``` -------------------------------- ### Send customer creation request Source: https://github.com/agentlang-ai/agentlang/blob/main/example/monitoring/README.md Sample user request to create a customer. Triggers the customerProductManager agent, which classifies the request as Customer and invokes createCustomer. ```bash curl -X POST http://localhost:8080/acme.core/customerProductManager \ -H 'Content-Type: application/json' \ -d '{"message": "Create a customer named Joe with email joe@acme.com and phone 77838838"}' ``` -------------------------------- ### GET /agentlang/oauth/access-token Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Returns the current access token for a provider, handling refresh automatically. ```APIDOC ## [GET] /agentlang/oauth/access-token ### Description Returns the current access token for a provider (handles refresh automatically). ### Method GET ### Endpoint /agentlang/oauth/access-token ### Parameters #### Query Parameters - **provider** (string) - Required - Provider key from your connections config ### Response #### Success Response (200) - **accessToken** (string) - The current access token - **expiresIn** (number) - Token expiration time in seconds - **tokenType** (string) - The token type (e.g., Bearer) #### Response Example { "accessToken": "ya29...", "expiresIn": 3599, "tokenType": "Bearer" } ``` -------------------------------- ### GET /knowledge.core/CloudFileProxy Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Perform cloud file operations such as health check and listing remote files. ```APIDOC ## GET /knowledge.core/CloudFileProxy ### Description Performs cloud file operations via rclone. Supports health check and listing remote files. ### Method GET ### Endpoint http://localhost:8080/knowledge.core/CloudFileProxy ### Parameters #### Query Parameters - **action** (string) - Required - Action to perform: health or list. - **remoteName** (string) - Required - Name of the remote (e.g., any, my-onedrive). - **remotePath** (string) - Optional - Remote path (e.g., /Documents). ### Request Example (No request body for GET.) ### Response #### Success Response (200) - Returns health status or list of files depending on action. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Run Agentlang from source Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Parse and validate an Agentlang file, or run a specific app. ```shell node ./bin/cli.js parseAndValidate example/blog/blog.al ``` ```shell node ./bin/cli.js run example/blog ``` -------------------------------- ### Validate attribute usage Source: https://github.com/agentlang-ai/agentlang/blob/main/example/validation/README.md The `validate` attribute is used to attach a validation workflow to an agent. In this example, it references `net.core/validateProvisiongRequest`. ```agentlang validate net.core/validateProvisiongRequest ``` -------------------------------- ### POST /knowledge.core/Topic Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Create a new topic. ```APIDOC ## POST /knowledge.core/Topic ### Description Creates a new topic. ### Method POST ### Endpoint http://localhost:8080/knowledge.core/Topic ### Parameters #### Request Body - **name** (string) - Required - Name of the topic. - **description** (string) - Optional - Description of the topic. - **type** (string) - Optional - Type of the topic (e.g., manual). - **tenantId** (string) - Optional - Tenant identifier. - **createdBy** (string) - Optional - User who created the topic. ### Request Example { "name": "Product Specs", "description": "All product specification documents", "type": "manual", "tenantId": "00000000-0000-0000-0000-000000000000", "createdBy": "00000000-0000-0000-0000-000000000000" } ### Response #### Success Response (200) - Returns the created Topic entity. #### Response Example (No explicit response example provided in source.) ``` -------------------------------- ### Document Configuration: Document Service Option A (Direct URL) Source: https://github.com/agentlang-ai/agentlang/blob/main/example/custom_config/README.md JSON configuration for the recommended document-service provider using a direct document-service:// URL. Includes retrievalConfig with baseUrl and authToken from environment variables, and embeddingConfig with OpenAI model. ```json { "agentlang.ai/doc": { "title": "product manual", "url": "document-service:///.pdf", "retrievalConfig": { "provider": "document-service", "config": { "baseUrl": "#js process.env.DOCUMENT_SERVICE_URL", "authToken": "#js process.env.DOCUMENT_SERVICE_AUTH_TOKEN" } }, "embeddingConfig": { "provider": "openai", "model": "text-embedding-3-small", "chunkSize": 1000, "chunkOverlap": 200 } } } ``` -------------------------------- ### View created EV and SUV orders Source: https://github.com/agentlang-ai/agentlang/blob/main/example/car_dealership/README.md Retrieves the created EV and SUV entities after the workflow execution. These GET requests display the persisted order instances. ```shell curl http://localhost:8080/order.core/EV curl http://localhost:8080/order.core/SUV ``` -------------------------------- ### Run tests Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Run all tests, or run tests with verbose output. ```shell npm test ``` ```shell npm run test:verbose ``` -------------------------------- ### POST /Blog.Core/CreateUserWithPosts Source: https://github.com/agentlang-ai/agentlang/blob/main/example/blog/README.md Creates a new user with associated blog posts. The request body includes user details and two post fields. ```APIDOC ## [POST] /Blog.Core/CreateUserWithPosts ### Description Creates a new user with associated blog posts. ### Method POST ### Endpoint http://localhost:8080/Blog.Core/CreateUserWithPosts ### Parameters #### Request Body - **name** (string) - Required - The name of the user. - **email** (string) - Required - The email address of the user. - **post1** (string) - Required - The content of the first blog post. - **post2** (string) - Required - The content of the second blog post. ### Request Example { "name": "Joe", "email": "joe@blog.com", "post1": "Good day", "post2": "Stay strong" } ### Response #### Success Response (200) No response body is documented. #### Response Example {} ``` -------------------------------- ### Document Configuration: Local File Source: https://github.com/agentlang-ai/agentlang/blob/main/example/custom_config/README.md JSON configuration for a document source using a local file path. The 'url' points to a local file './example/camera_info/docs/prices.txt'. ```json { "agentlang.ai/doc": { "title": "price list", "url": "./example/camera_info/docs/prices.txt" } } ``` -------------------------------- ### POST /api/v1/knowledge/connections Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/docs/knowledge-architecture.md Creates a new cloud storage connection for the tenant. ```APIDOC ## POST /api/v1/knowledge/connections ### Description Creates a new cloud storage connection for the tenant. ### Method POST ### Endpoint /api/v1/knowledge/connections ### Parameters #### Request Body - **name** (string) - Required - Name of the connection. - **provider** (string) - Required - Cloud storage provider (e.g., dropbox). - **clientId** (string) - Required - OAuth client ID. - **clientSecret** (string) - Required - OAuth client secret. - **remotePath** (string) - Required - Remote path to sync. - **scope** (string) - Required - Scope of the connection (e.g., org). - **syncIntervalMin** (integer) - Required - Sync interval in minutes. - **retentionPolicy** (string) - Required - Retention policy (e.g., count). - **retentionValue** (integer) - Required - Retention value. ### Request Example { "name": "Engineering Dropbox", "provider": "dropbox", "clientId": "abc123...", "clientSecret": "secret...", "remotePath": "/Shared/Knowledge", "scope": "org", "syncIntervalMin": 60, "retentionPolicy": "count", "retentionValue": 10 } ### Response #### Success Response (201) - **id** (string) - Connection ID. - **tenantId** (string) - Tenant ID. - **name** (string) - Connection name. - **provider** (string) - Provider. - **remotePath** (string) - Remote path. - **scope** (string) - Scope. - **syncIntervalMin** (integer) - Sync interval. - **status** (string) - Status (e.g., awaiting_auth). #### Response Example { "id": "conn_abc123", "tenantId": "tenant_xyz", "name": "Engineering Dropbox", "provider": "dropbox", "remotePath": "/Shared/Knowledge", "scope": "org", "syncIntervalMin": 60, "status": "awaiting_auth" } ``` -------------------------------- ### Enable monitoring in config.al Source: https://github.com/agentlang-ai/agentlang/blob/main/example/monitoring/README.md Configuration for the config.al file to enable monitoring. It sets the service port, uses a SQLite store named monitoring.db, and enables monitoring globally. ```json { "service": { "port": "#js parseInt(process.env.SERVICE_PORT || '8080')" }, "store": { "type": "sqlite", "dbname": "monitoring.db" }, "monitoring": { "enabled": true } } ``` -------------------------------- ### Create HTTP helper using resolver.getAuthHeaders() Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Common pattern for a resolver file: a makeRequest helper that injects auth headers and throws on non-OK responses, then resolver functions queryItems and createItem use it. The helper merges extra headers and options, and createItem reads inst.attributes.get('name') for the POST body. ```javascript const makeRequest = async (resolver, endpoint, options = {}) => { const authHeaders = await resolver.getAuthHeaders(); const response = await fetch(`https://api.example.com${endpoint}`, { ...options, headers: { 'Content-Type': 'application/json', ...authHeaders, ...(options.headers || {}), }, }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } return response.json(); }; // Then use it in all your resolver functions: export const queryItems = async (resolver, inst) => { const data = await makeRequest(resolver, '/v1/items', { method: 'GET' }); // ... }; export const createItem = async (resolver, inst) => { const body = { name: inst.attributes.get('name') }; const data = await makeRequest(resolver, '/v1/items', { method: 'POST', body: JSON.stringify(body), }); // ... }; ``` -------------------------------- ### Create a Connection entity Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Register a cloud storage connection. The externalConnectionId must match the rclone remote name. ```bash curl -s -X POST http://localhost:8080/knowledge.core/Connection \ -H 'Content-Type: application/json' \ -d '{ "name": "My OneDrive", "provider": "onedrive", "remotePath": "/Documents", "scope": "user", "status": "ready", "externalConnectionId": "my-onedrive", "tenantId": "00000000-0000-0000-0000-000000000000", "createdBy": "00000000-0000-0000-0000-000000000000" }' | jq . ``` -------------------------------- ### Create MCP client with agentlang.mcp/createClient Source: https://github.com/agentlang-ai/agentlang/blob/main/example/mcpdemo/README.md Explicitly creates an MCP client named 'deepwiki' connected to the specified server. This dynamically exposes all MCP tools as Agentlang events under the module 'deepwiki.mcp'. ```agentlang { agentlang.mcp/createClient { name "deepwiki", serverUrl "https://mcp.deepwiki.com/mcp" } } ``` -------------------------------- ### agentLearning request to fix misclassification Source: https://github.com/agentlang-ai/agentlang/blob/main/example/sdr/README.md A curl command to the agentLearning endpoint that provides an instruction to set category to business for emails with keywords like partnership, collaborate, integration, questions, interested, evaluate. Includes example email content. ```shell curl -X POST http://localhost:8080/agentlang.ai/agentLearning \ -H 'Content-Type: application/json' \ -d '{"agentName": "EmailQualificationAgent", "agentModuleName": "sdr.core", "instruction": "Set category to \"business\" if the email has keywords like: partnership, collaborate, integration, questions, interested, evaluate \n Examples of emails content:\n - We are interested in learning more about your product\n - How does your solution handle data exports?\n - We are evaluating options for our team\n - Following up on our conversation about the API"}' ``` -------------------------------- ### Watch mode Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Watch for changes and rebuild. ```shell npm run watch ``` -------------------------------- ### Get auth headers via resolver.getAuthHeaders() Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Use inside a resolver function bound to an integration to obtain current auth headers via resolver.getAuthHeaders() and call an external API. The returned headers are spread into the fetch headers alongside Content-Type. ```javascript export const queryEmail = async (resolver, inst) => { // getAuthHeaders() calls Integration Manager and returns // something like: { "Authorization": "Bearer eyJhbG..." } const authHeaders = await resolver.getAuthHeaders(); const response = await fetch('https://gmail.googleapis.com/gmail/v1/users/me/messages', { headers: { 'Content-Type': 'application/json', ...authHeaders, }, }); const data = await response.json(); // ... map data to entity instances and return }; ``` -------------------------------- ### Get raw OAuth token via agentlang.getAccessToken() Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md Returns the current OAuth access token (with automatic refresh) for an integration. Useful when you need the raw token rather than pre-built headers, e.g., to pass to a third-party SDK or tool like rclone. ```javascript const { accessToken, expiresIn, tokenType } = await agentlang.getAccessToken('google-drive'); // Use the token with a third-party tool await configureExternalTool({ token: accessToken }); ``` -------------------------------- ### Enable authentication and RBAC for the knowledge service Source: https://github.com/agentlang-ai/agentlang/blob/main/example/knowledge/README.md Sets AUTH_ENABLED and RBAC_ENABLED to true, then runs the service. When enabled, all requests require a Bearer token and RBAC rules are enforced per entity. See the @rbac annotations in src/core.al for the full permission matrix. ```bash export AUTH_ENABLED=true export RBAC_ENABLED=true node ./bin/cli.js run example/knowledge ``` -------------------------------- ### Define agent with salary hike directives Source: https://github.com/agentlang-ai/agentlang/blob/main/README.md Defines an agent with a role, instruction, and tool, then attaches two directives that guide the agent to give a 5% or 2% salary hike based on sales thresholds. The directives are evaluated when the agent computes salary increments. ```typescript agent salaryHikeAgent { role "hr_manager", instruction "Give an employee a salary-hike based on his/her sales performance", tools acme/employee } directive salaryHikeAgent.hike5p { if ("employee sales exceeded 5000") { "Give a salary hike of 5 percent" }} directive salaryHikeAgent.hike2p { if ("sales is more than 2000 but less than 5000") { "hike salary by 2 percent" }} ``` -------------------------------- ### agentlang.authFetch(integrationName, url, options?) Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/integration-auth-guide.md A drop-in replacement for `fetch()` that automatically injects the integration's auth headers. Additional headers can be passed and are merged on top of the auth headers. ```APIDOC ## agentlang.authFetch(integrationName, url, options?) ### Description A drop-in replacement for `fetch()` that automatically injects the integration's auth headers. Additional headers can be passed and are merged on top of the auth headers. ### Method N/A (JavaScript function) ### Endpoint N/A ### Parameters - **integrationName** (string) - Required - The name of the integration. - **url** (string) - Required - The URL to fetch. - **options** (object) - Optional - Fetch options (e.g., method, headers, body). ### Request Example ```js const response = await agentlang.authFetch( 'gmail', 'https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=10' ); ``` ### Response #### Success Response - **response** (Response) - The fetch Response object. #### Response Example ```js const data = await response.json(); ``` ``` -------------------------------- ### Run app in dev and test modes with auto-sync Source: https://github.com/agentlang-ai/agentlang/blob/main/docs/migrations.md In dev and test modes, TypeORM's synchronize flag is enabled, so schema changes are applied automatically on startup. No explicit migration steps are needed. ```bash # Dev mode — schema auto-syncs on startup agent run app.al ``` ```bash # Test mode — same auto-sync behavior NODE_ENV=test agentlang run app.al ``` -------------------------------- ### Agentlang module defining Forecast entity and REST resolver Source: https://github.com/agentlang-ai/agentlang/blob/main/example/weather/README.md Defines the weather.core module with a Forecast entity (latitude, longitude, days with default 7) and a restResolver that binds the entity to a JavaScript resolver. The query handler is invoked whenever the entity is accessed via a GET request. ```agentlang module weather.core import "resolver.js" @as r entity Forecast { latitude Decimal, longitude Decimal, days Integer @default(7) } resolver restResolver [weather.core/Forecast] { query r.queryForecast } ```