KosmoKrator

productivity

Agora Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Agora KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.agora.*. Use lua_read_doc("integrations.agora") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Agora workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.agora.acquire_recording_resource({cname = "example_cname", uid = "example_uid", scene = 1, resource_expired_hour = 1, start_parameter = "example_start_parameter", client_request = "example_client_request"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("agora"))' --json
kosmo integrations:lua --eval 'print(docs.read("agora.acquire_recording_resource"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local agora = app.integrations.agora
local result = agora.acquire_recording_resource({cname = "example_cname", uid = "example_uid", scene = 1, resource_expired_hour = 1, start_parameter = "example_start_parameter", client_request = "example_client_request"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.agora, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.agora.default.* or app.integrations.agora.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Agora, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Agora Cloud Recording — Lua API Supplement

The Agora integration exposes the documented Cloud Recording RESTful API. Use it to acquire a recording resource, start a recording session, query status, update subscriptions or layouts, stop the session, and maintain notification-service firewall allowlists.

Agora uses Basic REST authentication with a customer ID and customer secret plus an App ID with Cloud Recording enabled.

Recording Workflow

Cloud Recording is a stateful workflow:

  1. acquire_recording_resource
  2. start_recording
  3. query_recording while active
  4. update_recording or update_recording_layout when needed
  5. stop_recording

The resource_id from acquire is single-use. The sid from start identifies the active recording session.

acquire_recording_resource

Request a resource ID for one recording session.

local acquired = app.integrations.agora.acquire_recording_resource({
  cname = "team-standup",
  uid = "527841",
  scene = 0,
  resource_expired_hour = 24,
})

local resource_id = acquired.resourceId

The uid must be unique inside the channel and must be reused in start and stop calls.

start_recording

Start individual, composite, or web page recording. mode is individual, mix, or web.

local started = app.integrations.agora.start_recording({
  resource_id = resource_id,
  mode = "mix",
  cname = "team-standup",
  uid = "527841",
  recording_config = {
    channelType = 1,
    streamTypes = 2,
    maxIdleTime = 30,
  },
  recording_file_config = {
    avFileType = { "hls" },
  },
  storage_config = {
    vendor = 1,
    region = 0,
    bucket = "recordings-example",
    accessKey = "fake-access-key",
    secretKey = "fake-secret-key",
    fileNamePrefix = { "agora", "team-standup" },
  },
})

local sid = started.sid

Storage credentials are sent directly to Agora. Use fake values in tests and docs, never real bucket credentials.

query_recording

Check whether a session is active and inspect file or extension service state.

local status = app.integrations.agora.query_recording({
  resource_id = resource_id,
  sid = sid,
  mode = "mix",
})

print(status.serverResponse.status)

Agora’s serverResponse differs by mode and configuration. Composite recordings can return fileListMode, fileList, and uploadingStatus; web recordings can return extension service state.

update_recording

Update subscription lists or web recording extension state while a session is active.

app.integrations.agora.update_recording({
  resource_id = resource_id,
  sid = sid,
  mode = "mix",
  cname = "team-standup",
  uid = "527841",
  stream_subscribe = {
    audioUidList = {
      subscribeAudioUids = { "123", "456" },
    },
    videoUidList = {
      subscribeVideoUids = { "123" },
    },
  },
})

For newer Agora fields not yet promoted to first-class parameters, pass the documented client_request object directly. The tool still adds credentials and wraps it correctly.

update_recording_layout

Update the mixed video layout for composite recordings.

app.integrations.agora.update_recording_layout({
  resource_id = resource_id,
  sid = sid,
  cname = "team-standup",
  uid = "527841",
  mixed_video_layout = 3,
  background_color = "#000000",
  layout_config = {
    { uid = "123", x_axis = 0, y_axis = 0, width = 0.5, height = 1, alpha = 1 },
    { uid = "456", x_axis = 0.5, y_axis = 0, width = 0.5, height = 1, alpha = 1 },
  },
})

This tool always calls Agora’s mode/mix/updateLayout endpoint.

stop_recording

Stop the active session. After stop, acquire a new resource before recording again.

local stopped = app.integrations.agora.stop_recording({
  resource_id = resource_id,
  sid = sid,
  mode = "mix",
  cname = "team-standup",
  uid = "527841",
  async_stop = false,
})

print(stopped.serverResponse.uploadingStatus)

If async_stop is true, Agora returns before all files finish uploading.

get_notification_ips

Fetch message notification service IP addresses for firewall allowlists.

local ips = app.integrations.agora.get_notification_ips({})

for _, host in ipairs(ips.data.service.hosts) do
  print(host.primaryIP)
end

Agora recommends keeping this allowlist current because the notification service IPs can change.

Multi-Account Usage

If multiple Agora accounts are configured, use account-specific namespaces:

app.integrations.agora.acquire_recording_resource({...})
app.integrations.agora.default.acquire_recording_resource({...})
app.integrations.agora.production.acquire_recording_resource({...})
Raw agent markdown
# Agora Cloud Recording — Lua API Supplement

The Agora integration exposes the documented Cloud Recording RESTful API. Use it to acquire a recording resource, start a recording session, query status, update subscriptions or layouts, stop the session, and maintain notification-service firewall allowlists.

Agora uses Basic REST authentication with a customer ID and customer secret plus an App ID with Cloud Recording enabled.

## Recording Workflow

Cloud Recording is a stateful workflow:

1. `acquire_recording_resource`
2. `start_recording`
3. `query_recording` while active
4. `update_recording` or `update_recording_layout` when needed
5. `stop_recording`

The `resource_id` from acquire is single-use. The `sid` from start identifies the active recording session.

## acquire_recording_resource

Request a resource ID for one recording session.

```lua
local acquired = app.integrations.agora.acquire_recording_resource({
  cname = "team-standup",
  uid = "527841",
  scene = 0,
  resource_expired_hour = 24,
})

local resource_id = acquired.resourceId
```

The `uid` must be unique inside the channel and must be reused in start and stop calls.

## start_recording

Start individual, composite, or web page recording. `mode` is `individual`, `mix`, or `web`.

```lua
local started = app.integrations.agora.start_recording({
  resource_id = resource_id,
  mode = "mix",
  cname = "team-standup",
  uid = "527841",
  recording_config = {
    channelType = 1,
    streamTypes = 2,
    maxIdleTime = 30,
  },
  recording_file_config = {
    avFileType = { "hls" },
  },
  storage_config = {
    vendor = 1,
    region = 0,
    bucket = "recordings-example",
    accessKey = "fake-access-key",
    secretKey = "fake-secret-key",
    fileNamePrefix = { "agora", "team-standup" },
  },
})

local sid = started.sid
```

Storage credentials are sent directly to Agora. Use fake values in tests and docs, never real bucket credentials.

## query_recording

Check whether a session is active and inspect file or extension service state.

```lua
local status = app.integrations.agora.query_recording({
  resource_id = resource_id,
  sid = sid,
  mode = "mix",
})

print(status.serverResponse.status)
```

Agora's `serverResponse` differs by mode and configuration. Composite recordings can return `fileListMode`, `fileList`, and `uploadingStatus`; web recordings can return extension service state.

## update_recording

Update subscription lists or web recording extension state while a session is active.

```lua
app.integrations.agora.update_recording({
  resource_id = resource_id,
  sid = sid,
  mode = "mix",
  cname = "team-standup",
  uid = "527841",
  stream_subscribe = {
    audioUidList = {
      subscribeAudioUids = { "123", "456" },
    },
    videoUidList = {
      subscribeVideoUids = { "123" },
    },
  },
})
```

For newer Agora fields not yet promoted to first-class parameters, pass the documented `client_request` object directly. The tool still adds credentials and wraps it correctly.

## update_recording_layout

Update the mixed video layout for composite recordings.

```lua
app.integrations.agora.update_recording_layout({
  resource_id = resource_id,
  sid = sid,
  cname = "team-standup",
  uid = "527841",
  mixed_video_layout = 3,
  background_color = "#000000",
  layout_config = {
    { uid = "123", x_axis = 0, y_axis = 0, width = 0.5, height = 1, alpha = 1 },
    { uid = "456", x_axis = 0.5, y_axis = 0, width = 0.5, height = 1, alpha = 1 },
  },
})
```

This tool always calls Agora's `mode/mix/updateLayout` endpoint.

## stop_recording

Stop the active session. After stop, acquire a new resource before recording again.

```lua
local stopped = app.integrations.agora.stop_recording({
  resource_id = resource_id,
  sid = sid,
  mode = "mix",
  cname = "team-standup",
  uid = "527841",
  async_stop = false,
})

print(stopped.serverResponse.uploadingStatus)
```

If `async_stop` is true, Agora returns before all files finish uploading.

## get_notification_ips

Fetch message notification service IP addresses for firewall allowlists.

```lua
local ips = app.integrations.agora.get_notification_ips({})

for _, host in ipairs(ips.data.service.hosts) do
  print(host.primaryIP)
end
```

Agora recommends keeping this allowlist current because the notification service IPs can change.

## Multi-Account Usage

If multiple Agora accounts are configured, use account-specific namespaces:

```lua
app.integrations.agora.acquire_recording_resource({...})
app.integrations.agora.default.acquire_recording_resource({...})
app.integrations.agora.production.acquire_recording_resource({...})
```
Metadata-derived Lua example
local result = app.integrations.agora.acquire_recording_resource({cname = "example_cname", uid = "example_uid", scene = 1, resource_expired_hour = 1, start_parameter = "example_start_parameter", client_request = "example_client_request"})
print(result)

Functions

acquire_recording_resource Write

Request a resource ID before starting an Agora Cloud Recording session.

Lua path
app.integrations.agora.acquire_recording_resource
Full name
agora.agora_acquire_recording_resource
ParameterTypeRequiredDescription
cname string yes Agora channel name to record.
uid string yes Recording client UID. Must be unique in the channel.
scene integer no Optional Agora scene value. Common default is 0.
resource_expired_hour integer no Optional resource expiration in hours.
start_parameter object no Optional Agora startParameter object for chained acquire/start configuration.
client_request object no Raw acquire clientRequest object. Explicit fields above override matching values.
start_recording Write

Start an Agora Cloud Recording session using a resource ID returned by agora_acquire_recording_resource.

Lua path
app.integrations.agora.start_recording
Full name
agora.agora_start_recording
ParameterTypeRequiredDescription
resource_id string yes Resource ID returned by acquire.
mode string yes Recording mode: individual, mix, or web.
cname string yes Agora channel name to record.
uid string yes Recording client UID used in acquire.
token string no Optional RTC token for the recording client.
recording_config object no Agora recordingConfig object.
recording_file_config object no Agora recordingFileConfig object, for example avFileType.
storage_config object no Agora storageConfig object for the destination cloud storage.
snapshot_config object no Optional snapshotConfig object.
extension_service_config object no Optional extensionServiceConfig object for web recording or streaming extensions.
client_request object no Raw start clientRequest object. Explicit fields above override matching values.
query_recording Read

Query the status of an active Agora Cloud Recording session.

Lua path
app.integrations.agora.query_recording
Full name
agora.agora_query_recording
ParameterTypeRequiredDescription
resource_id string yes Resource ID returned by acquire.
sid string yes Recording session ID returned by start.
mode string yes Recording mode: individual, mix, or web.
update_recording Write

Update an active Agora Cloud Recording subscription list or web recorder state.

Lua path
app.integrations.agora.update_recording
Full name
agora.agora_update_recording
ParameterTypeRequiredDescription
resource_id string yes Resource ID returned by acquire.
sid string yes Recording session ID returned by start.
mode string yes Recording mode: individual, mix, or web.
cname string yes Agora channel name used for the recording.
uid string yes Recording client UID used in acquire and start.
stream_subscribe object no Agora streamSubscribe object for subscription updates.
web_recorder_config object no Agora webRecorderConfig object for web recording updates.
rtmp_publish_config object no Agora rtmpPublishConfig object for web recording stream publishing updates.
client_request object no Raw update clientRequest object. Explicit fields above override matching values.
update_recording_layout Write

Update the video mixing layout for an active Agora composite recording.

Lua path
app.integrations.agora.update_recording_layout
Full name
agora.agora_update_recording_layout
ParameterTypeRequiredDescription
resource_id string yes Resource ID returned by acquire.
sid string yes Recording session ID returned by start.
cname string yes Agora channel name used for the recording.
uid string yes Recording client UID used in acquire and start.
mixed_video_layout integer no Agora mixedVideoLayout value.
background_color string no Background color for mixed layout, for example "#000000".
layout_config array no Agora layoutConfig array for custom mixed layout regions.
background_config array no Agora backgroundConfig array.
default_user_background_image string no Default user background image URL.
client_request object no Raw updateLayout clientRequest object. Explicit fields above override matching values.
stop_recording Write

Stop an active Agora Cloud Recording session.

Lua path
app.integrations.agora.stop_recording
Full name
agora.agora_stop_recording
ParameterTypeRequiredDescription
resource_id string yes Resource ID returned by acquire.
sid string yes Recording session ID returned by start.
mode string yes Recording mode: individual, mix, or web.
cname string yes Agora channel name used for the recording.
uid string yes Recording client UID used in acquire and start.
async_stop boolean no Return immediately instead of waiting for files to upload.
client_request object no Raw stop clientRequest object. async_stop overrides async_stop inside this object.
get_notification_ips Read

Fetch Agora message notification service IP addresses for firewall allowlists.

Lua path
app.integrations.agora.get_notification_ips
Full name
agora.agora_get_notification_ips
ParameterTypeRequiredDescription
No parameters.