Apps Guide
Apps are reusable, versioned computational units written in Cogniscript that can be compiled, stored, and executed with input parameters. They are first-class citizens in Maitento alongside Agents, Capsules, and Interactions.
Table of Contents
- Key Concepts
- App Structure
- App Versions
- Build Process
- Execution Flow
- Inputs and Outputs
- Process Status
- API Reference
- SDK Usage
- Shell Commands
- Cogniscript Syscalls
- Best Practices
Key Concepts
- Apps represent compiled Cogniscript programs that define automation logic
- AppVersions are immutable snapshots of an app’s code at a point in time
- AppProcesses are running instances of an app version
Apps are written in Cogniscript, a purpose-built programming language for the Maitento ecosystem. Cogniscript provides a C-like syntax with 80+ built-in functions and 109 Maitento-specific syscalls. See the Cogniscript Language Guide for complete language documentation.
App Structure
Each App contains:
| Property | Description |
|---|---|
Id | Unique identifier for the app |
Name | Human-readable name (unique within namespace) |
NamespaceId | Namespace scope for the app |
Versions | List of app versions |
UserCreatedById | Creator of the app |
DateCreated / DateUpdated | Timestamps |
App Versions
Each version includes:
| Property | Description |
|---|---|
Version | Integer version number (starts at 1) |
Inputs | Array of input parameter definitions |
FileChecksum | MD5 checksum of compiled binary |
ExecutionTimeLimit | Optional timeout for execution |
IsDisabled | Whether this version can be executed |
ExternalOperations | MCP/OpenAPI bindings |
Versions are immutable once created. To update app logic, create a new version rather than modifying existing ones. This ensures traceability and allows rollback to previous versions if needed.
Build Process
Apps go through a three-phase build process:
- Compile Phase: Cogniscript source code is compiled into operations
- Reference Resolution: External bindings (MCP, OpenAPI) are validated
- Create & Deploy: Binary is persisted to storage (
{tenantId}/apps/{appId}/{version}.mtb)
The compilation pipeline transforms your Cogniscript source through tokenization, parsing, assembly generation, and finally produces executable bytecode that runs on the Cogniscript Virtual Machine.
Execution Flow
AppService.Start()creates an AppProcess with statusNewAppProcessRunner.Run()loads the compiled app, validates checksum, and maps inputsAppExecutor.ExecuteApp()runs the VM in a dedicated thread- Process status updates to
Running, thenFinished,Error, orKilled
Inputs and Outputs
Supported Data Types
Apps support the following data types for inputs and outputs:
| Type | Description |
|---|---|
String | Text value |
Integer | Whole number |
Decimal | Floating-point number |
Guid | UUID identifier |
Bool | Boolean true/false |
Date | Date/time value |
JsonObject | JSON object |
JsonArray | JSON array |
Reading Inputs in Cogniscript
// Read inputs
var value = appState.getInput("paramName")
// Set outputs
appState.setOutputString("result", "value")
appState.setOutputInteger("count", 42)
// Chain apps
var processId = app.start("appName@namespace", { "input": "value" })
// Query apps
var appInfo = app.get("appName@namespace")
var apps = app.list("namespace")
Process Status
Status Values
| Status | Description |
|---|---|
New | Process created but not yet started |
Running | Process is actively executing |
HumanInteractionRequired | Waiting for user input |
WaitingToResume | Queued to resume after pause |
Paused | Execution is paused |
Finished | Completed successfully |
Error | Terminated due to error |
Killed | Manually terminated |
Pause Types
| Type | Description |
|---|---|
None | Not paused |
App | Paused by app logic (e.g., waiting for another app) |
Interaction | Paused for human interaction |
CodeGeneration | Paused during AI code generation |
API Reference
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/apps | GET | List all apps |
/namespaces/{ns}/apps | GET | List apps in namespace |
/namespaces/{ns}/apps | POST | Create app |
/apps/by-id/{id} | GET | Get app by ID |
/namespaces/{ns}/apps/by-name/{name} | GET | Get app by name |
/apps/by-id/{id}/versions/{v}/start | PUT | Start app by ID/version |
/namespaces/{ns}/apps/by-name/{name}/versions/latest/start | PUT | Start latest version |
/apps/processes/by-id/{id} | GET | Get process by ID |
/apps/processes/by-id/{id}/inputs | PUT | Update process inputs |
/namespaces/{ns}/apps/processes | GET | List active processes |
Authentication
All endpoints require authentication:
| Method | Header | Description |
|---|---|---|
| Bearer Token | Authorization: Bearer <token> | JWT token |
| API Key | X-Api-Key: <api-key> | API key |
Required Roles: Tenant.Admin or Tenant.User
SDK Usage
Working with Apps
// Create client
var client = MaitentoClient.Create("your-api-key");
// List all apps
App[] allApps = await client.Apps.GetAllAsync();
// Get app by name
App? app = await client.Apps.GetByNameAsync("production", "data-processor");
// Start an app with inputs
NameValuePair[] inputs = new[]
{
new NameValuePair("reportType", "monthly"),
new NameValuePair("outputFormat", "pdf")
};
AppProcess process = await client.Apps.StartAsync(
"production",
"report-generator",
inputs
);
Console.WriteLine($"Started process: {process.Id}");
// Poll for completion
while (process.Status == AppProcessStatus.Running ||
process.Status == AppProcessStatus.New)
{
await Task.Delay(1000);
process = await client.Apps.GetProcessAsync(process.Id) ?? process;
}
Console.WriteLine($"Final Status: {process.Status}");
Console.WriteLine($"Return Value: {process.ReturnValue}");
// Handle human interaction
if (process.Status == AppProcessStatus.HumanInteractionRequired)
{
NameValuePair[] additionalInputs = new[]
{
new NameValuePair("approvalDecision", "approved")
};
process = await client.Apps.ProcessPatchInputs(process.Id, additionalInputs);
}
Exception Handling
try
{
var process = await client.Apps.StartAsync(...);
}
catch (MaitentoValidationException ex)
{
Console.WriteLine("Validation errors:");
foreach (var error in ex.ValidationErrors)
{
Console.WriteLine($" {error.Key}: {string.Join(", ", error.Value)}");
}
}
catch (MaitentoApiException ex)
{
Console.WriteLine($"API error ({ex.StatusCode}): {ex.ResponseBody}");
}
catch (MaitentoApiAuthenticationException ex)
{
Console.WriteLine("Authentication failed - check your API key");
}
Shell Commands
Listing Apps
# List all apps in default namespace
app-list
# List apps in specific namespace
app-list --namespace production
Getting App Details
# Get app details
app-get data-processor --namespace production
Starting Apps
# Start an app (fire and forget)
app-start report-generator --namespace production
# Start with inputs
app-start data-processor --input-file-path "/data/input.csv" --input-batch-size 100
# Run and wait for completion
app-run simple-task --namespace production
Monitoring Apps
# List running processes
app-ps --namespace production
# Attach to a running process
app-attach a1b2c3d4-e5f6-7890-abcd-ef1234567890
Cogniscript Syscalls
The following syscalls are available for working with Apps from within Cogniscript code:
| Syscall | Description | Parameters | Returns |
|---|---|---|---|
AppList | List all apps | namespaceName | App[] JSON |
AppGet | Get app by name | name* | App JSON |
AppStart | Start app process | name*, inputs (JsonObject) | ProcessId |
AppProcessGet | Get process details | processId* | AppProcess JSON |
AppStateGetInput | Get input value | name* | String or null |
AppStateSetInput | Set input value | name*, value* | void |
AppStateSetOutputString | Set string output | name*, value | void |
AppStateSetOutputInteger | Set integer output | name*, value | void |
AppStateSetOutputBool | Set boolean output | name*, value | void |
AppStateSetOutputDecimal | Set decimal output | name*, value | void |
AppStateSetOutputGuid | Set GUID output | name*, value | void |
AppStateSetOutputDate | Set date output | name*, value | void |
AppStateSetOutputJsonObject | Set JSON object output | name*, value | void |
AppStateSetOutputJsonArray | Set JSON array output | name*, value | void |
Example: Maitento Integration
void main() {
// Create a VFS file
VfsWriteText("data", "default", "/logs/output.txt", "Processing started...");
// Start an app process
jsonObject inputs = JsonObjectCreate();
inputs = JsonObjectSetString(inputs, "task", "analyze");
string processId = AppStart("data-processor", inputs);
PrintLine("Started process: " + processId);
// Wait for completion
string process = AppProcessGet(processId);
PrintLine("Process status: " + process);
}
Best Practices
- Versioning: Create new versions rather than modifying existing ones for traceability
- Inputs: Define clear input types and validate early in your Cogniscript code
- Timeouts: Set appropriate
ExecutionTimeLimitto prevent runaway processes - Composition: Use
app.start()to chain apps for complex workflows - Error Handling: Always check process status and handle errors appropriately
- Outputs: Use typed output methods (
setOutputString,setOutputInteger, etc.) for type safety
Related Documentation
- Cogniscript Language Guide - Programming language for Apps
- Capsules Guide - Isolated container workloads
- Automated Actions - Schedule and trigger Apps automatically