KosmoKrator

productivity

Argo CD Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API key auth

Lua Namespace

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

Agent-Facing Lua Docs

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

Argo CD — Lua API Reference

Overview

The Argo CD integration provides access to GitOps applications, projects, and repositories. All 7 tools are available under the app.integrations.argocd namespace.

Every tool call accepts a single Lua table with named parameters and returns a Lua table with the API response data.

Authentication

The Argo CD integration authenticates via a Bearer token. Generate a token from the Argo CD UI (User Settings → Generate New Token) or via the CLI:

argocd account generate-token --account <username>

The token is sent as an Authorization: Bearer <token> header on every request. You can also configure a custom base URL if your Argo CD instance is hosted elsewhere.

-- All calls use the same namespace — no per-call auth needed
local apps = app.integrations.argocd.list_applications({})

Applications

app.integrations.argocd.list_applications({})

List all Argo CD applications. Optionally filter by project, label selector, or repository.

NameTypeRequiredDescription
projectstringnoFilter applications by project name
selectorstringnoLabel selector to filter applications (e.g. "env=production")
repostringnoFilter by source repository URL
local result = app.integrations.argocd.list_applications({})

for _, app in ipairs(result.items or {}) do
  print(app.metadata.name .. " — " .. (app.status.health.status or "unknown"))
end

Filter by project:

local result = app.integrations.argocd.list_applications({
  project = "default",
})

for _, app in ipairs(result.items or {}) do
  print(app.metadata.name)
end

app.integrations.argocd.get_application({ name })

Get details for a specific Argo CD application, including sync status, health, source, and destination.

NameTypeRequiredDescription
namestringyesThe name of the application
projectstringnoThe project the application belongs to
refreshstringnoForce a refresh ("true" or "hard")
local app = app.integrations.argocd.get_application({
  name = "my-app",
  refresh = "true",
})

print("Health: " .. app.status.health.status)
print("Sync:   " .. app.status.sync.status)
print("Source: " .. app.spec.source.repoURL)
print("Path:   " .. app.spec.source.path)

app.integrations.argocd.create_application({ name, project, repo_url, path, dest_namespace })

Create a new Argo CD application.

NameTypeRequiredDescription
namestringyesApplication name
projectstringyesArgo CD project name
repo_urlstringyesGit repository URL
pathstringyesPath within the repository to Kubernetes manifests
revisionstringnoGit revision (branch, tag, or SHA). Defaults to HEAD
dest_serverstringnoDestination cluster API URL. Defaults to https://kubernetes.default.svc
dest_namespacestringyesDestination Kubernetes namespace
sync_policystringno"automated" for auto-sync, "manual" or empty for manual
sync_optionsstringnoComma-separated sync options (e.g. "CreateNamespace=true")
labelsobjectnoKey-value labels (e.g. { env = "production" })
descriptionstringnoHuman-readable description
local app = app.integrations.argocd.create_application({
  name = "my-app",
  project = "default",
  repo_url = "https://github.com/my-org/my-manifests.git",
  path = "k8s/overlays/production",
  revision = "main",
  dest_namespace = "production",
  sync_policy = "automated",
  sync_options = "CreateNamespace=true",
  labels = { env = "production", team = "platform" },
  description = "Production deployment for my-app",
})

print("Created: " .. app.metadata.name)

Projects

app.integrations.argocd.list_projects({})

List all Argo CD projects.

NameTypeRequiredDescription
(none)Takes no parameters
local result = app.integrations.argocd.list_projects({})

for _, project in ipairs(result.items or {}) do
  print(project.metadata.name)
end

app.integrations.argocd.get_project({ name })

Get details for a specific Argo CD project, including source/destination rules and cluster configurations.

NameTypeRequiredDescription
namestringyesThe name of the project
local project = app.integrations.argocd.get_project({
  name = "default",
})

print("Project: " .. project.metadata.name)

-- List source repositories
for _, src in ipairs(project.spec.sourceRepos or {}) do
  print("Source repo: " .. src)
end

-- List destinations
for _, dest in ipairs(project.spec.destinations or {}) do
  print("Destination: " .. dest.namespace .. " on " .. dest.server)
end

Repositories

app.integrations.argocd.list_repositories({})

List all configured Git repositories in Argo CD, including connection status.

NameTypeRequiredDescription
repostringnoFilter by repository URL
local result = app.integrations.argocd.list_repositories({})

for _, repo in ipairs(result.items or result or {}) do
  print(repo.repo .. " — " .. (repo.connectionState.status or "unknown"))
end

Filter by repository URL:

local result = app.integrations.argocd.list_repositories({
  repo = "https://github.com/my-org",
})

User

app.integrations.argocd.get_current_user({})

Get the authenticated Argo CD user’s profile information.

NameTypeRequiredDescription
(none)Takes no parameters
local user = app.integrations.argocd.get_current_user({})

print("Logged in as: " .. (user.username or "unknown"))

Common Workflows

Check Application Health Across a Project

local result = app.integrations.argocd.list_applications({
  project = "production",
})

for _, app in ipairs(result.items or {}) do
  local health = app.status.health.status
  local sync = app.status.sync.status

  if health ~= "Healthy" or sync ~= "Synced" then
    print("⚠ " .. app.metadata.name .. " — health: " .. health .. ", sync: " .. sync)
  else
    print("✓ " .. app.metadata.name .. " — OK")
  end
end

Create and Monitor a New Application

-- 1. Create the application
local app = app.integrations.argocd.create_application({
  name = "new-service",
  project = "default",
  repo_url = "https://github.com/my-org/manifests.git",
  path = "services/new-service",
  dest_namespace = "staging",
  sync_policy = "automated",
})

print("Created application: " .. app.metadata.name)

-- 2. Check its status
local status = app.integrations.argocd.get_application({
  name = "new-service",
  refresh = "true",
})

print("Health: " .. status.status.health.status)
print("Sync:   " .. status.status.sync.status)

Audit Repository Connections

local repos = app.integrations.argocd.list_repositories({})

for _, repo in ipairs(repos.items or repos or {}) do
  local state = repo.connectionState
  if state and state.status == "Failed" then
    print("❌ " .. repo.repo .. " — connection failed: " .. (state.message or ""))
  else
    print("✓ " .. repo.repo)
  end
end
Raw agent markdown
# Argo CD — Lua API Reference

## Overview

The Argo CD integration provides access to GitOps applications, projects, and repositories. All 7 tools are available under the `app.integrations.argocd` namespace.

Every tool call accepts a single Lua table with named parameters and returns a Lua table with the API response data.

## Authentication

The Argo CD integration authenticates via a **Bearer token**. Generate a token from the Argo CD UI (**User Settings → Generate New Token**) or via the CLI:

```bash
argocd account generate-token --account <username>
```

The token is sent as an `Authorization: Bearer <token>` header on every request. You can also configure a custom base URL if your Argo CD instance is hosted elsewhere.

```lua
-- All calls use the same namespace — no per-call auth needed
local apps = app.integrations.argocd.list_applications({})
```

## Applications

### `app.integrations.argocd.list_applications({})`

List all Argo CD applications. Optionally filter by project, label selector, or repository.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project` | string | no | Filter applications by project name |
| `selector` | string | no | Label selector to filter applications (e.g. `"env=production"`) |
| `repo` | string | no | Filter by source repository URL |

```lua
local result = app.integrations.argocd.list_applications({})

for _, app in ipairs(result.items or {}) do
  print(app.metadata.name .. " — " .. (app.status.health.status or "unknown"))
end
```

Filter by project:

```lua
local result = app.integrations.argocd.list_applications({
  project = "default",
})

for _, app in ipairs(result.items or {}) do
  print(app.metadata.name)
end
```

### `app.integrations.argocd.get_application({ name })`

Get details for a specific Argo CD application, including sync status, health, source, and destination.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | The name of the application |
| `project` | string | no | The project the application belongs to |
| `refresh` | string | no | Force a refresh (`"true"` or `"hard"`) |

```lua
local app = app.integrations.argocd.get_application({
  name = "my-app",
  refresh = "true",
})

print("Health: " .. app.status.health.status)
print("Sync:   " .. app.status.sync.status)
print("Source: " .. app.spec.source.repoURL)
print("Path:   " .. app.spec.source.path)
```

### `app.integrations.argocd.create_application({ name, project, repo_url, path, dest_namespace })`

Create a new Argo CD application.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Application name |
| `project` | string | yes | Argo CD project name |
| `repo_url` | string | yes | Git repository URL |
| `path` | string | yes | Path within the repository to Kubernetes manifests |
| `revision` | string | no | Git revision (branch, tag, or SHA). Defaults to HEAD |
| `dest_server` | string | no | Destination cluster API URL. Defaults to `https://kubernetes.default.svc` |
| `dest_namespace` | string | yes | Destination Kubernetes namespace |
| `sync_policy` | string | no | `"automated"` for auto-sync, `"manual"` or empty for manual |
| `sync_options` | string | no | Comma-separated sync options (e.g. `"CreateNamespace=true"`) |
| `labels` | object | no | Key-value labels (e.g. `{ env = "production" }`) |
| `description` | string | no | Human-readable description |

```lua
local app = app.integrations.argocd.create_application({
  name = "my-app",
  project = "default",
  repo_url = "https://github.com/my-org/my-manifests.git",
  path = "k8s/overlays/production",
  revision = "main",
  dest_namespace = "production",
  sync_policy = "automated",
  sync_options = "CreateNamespace=true",
  labels = { env = "production", team = "platform" },
  description = "Production deployment for my-app",
})

print("Created: " .. app.metadata.name)
```

## Projects

### `app.integrations.argocd.list_projects({})`

List all Argo CD projects.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| *(none)* | — | — | Takes no parameters |

```lua
local result = app.integrations.argocd.list_projects({})

for _, project in ipairs(result.items or {}) do
  print(project.metadata.name)
end
```

### `app.integrations.argocd.get_project({ name })`

Get details for a specific Argo CD project, including source/destination rules and cluster configurations.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | The name of the project |

```lua
local project = app.integrations.argocd.get_project({
  name = "default",
})

print("Project: " .. project.metadata.name)

-- List source repositories
for _, src in ipairs(project.spec.sourceRepos or {}) do
  print("Source repo: " .. src)
end

-- List destinations
for _, dest in ipairs(project.spec.destinations or {}) do
  print("Destination: " .. dest.namespace .. " on " .. dest.server)
end
```

## Repositories

### `app.integrations.argocd.list_repositories({})`

List all configured Git repositories in Argo CD, including connection status.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `repo` | string | no | Filter by repository URL |

```lua
local result = app.integrations.argocd.list_repositories({})

for _, repo in ipairs(result.items or result or {}) do
  print(repo.repo .. " — " .. (repo.connectionState.status or "unknown"))
end
```

Filter by repository URL:

```lua
local result = app.integrations.argocd.list_repositories({
  repo = "https://github.com/my-org",
})
```

## User

### `app.integrations.argocd.get_current_user({})`

Get the authenticated Argo CD user's profile information.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| *(none)* | — | — | Takes no parameters |

```lua
local user = app.integrations.argocd.get_current_user({})

print("Logged in as: " .. (user.username or "unknown"))
```

## Common Workflows

### Check Application Health Across a Project

```lua
local result = app.integrations.argocd.list_applications({
  project = "production",
})

for _, app in ipairs(result.items or {}) do
  local health = app.status.health.status
  local sync = app.status.sync.status

  if health ~= "Healthy" or sync ~= "Synced" then
    print("⚠ " .. app.metadata.name .. " — health: " .. health .. ", sync: " .. sync)
  else
    print("✓ " .. app.metadata.name .. " — OK")
  end
end
```

### Create and Monitor a New Application

```lua
-- 1. Create the application
local app = app.integrations.argocd.create_application({
  name = "new-service",
  project = "default",
  repo_url = "https://github.com/my-org/manifests.git",
  path = "services/new-service",
  dest_namespace = "staging",
  sync_policy = "automated",
})

print("Created application: " .. app.metadata.name)

-- 2. Check its status
local status = app.integrations.argocd.get_application({
  name = "new-service",
  refresh = "true",
})

print("Health: " .. status.status.health.status)
print("Sync:   " .. status.status.sync.status)
```

### Audit Repository Connections

```lua
local repos = app.integrations.argocd.list_repositories({})

for _, repo in ipairs(repos.items or repos or {}) do
  local state = repo.connectionState
  if state and state.status == "Failed" then
    print("❌ " .. repo.repo .. " — connection failed: " .. (state.message or ""))
  else
    print("✓ " .. repo.repo)
  end
end
```

Metadata-Derived Lua Example

local result = app.integrations.argocd.argocd_list_applications({
  project = "example_project",
  selector = "example_selector",
  repo = "example_repo"
})
print(result)

Functions

argocd_list_applications

List all Argo CD applications. Optionally filter by project or label selector.

Operation
Read read
Full name
argocd.argocd_list_applications
ParameterTypeRequiredDescription
project string no Filter applications by project name.
selector string no Label selector to filter applications (e.g. "env=production").
repo string no Filter by source repository URL.

argocd_get_application

Get details for a specific Argo CD application, including sync status, health, source, and destination.

Operation
Read read
Full name
argocd.argocd_get_application
ParameterTypeRequiredDescription
name string yes The name of the Argo CD application.
project string no The project the application belongs to (optional, used for disambiguation).
refresh string no Force a refresh of the application state. Set to "true" or "hard" to refresh before returning.

argocd_create_application

Create a new Argo CD application. Requires application name, project, source repository with path and revision, and destination cluster/namespace.

Operation
Write write
Full name
argocd.argocd_create_application
ParameterTypeRequiredDescription
name string yes The name of the application.
project string yes The Argo CD project this application belongs to.
repo_url string yes The Git repository URL for the application source.
path string yes The path within the repository containing the Kubernetes manifests or Kustomize/Helm config.
revision string no The Git revision (branch, tag, or commit SHA) to track. Defaults to HEAD.
dest_server string no The destination Kubernetes cluster API URL. Defaults to "https://kubernetes.default.svc".
dest_namespace string yes The destination Kubernetes namespace.
sync_policy string no Sync policy: "automated" for auto-sync, "manual" or empty for manual sync.
sync_options string no Comma-separated sync options (e.g. "CreateNamespace=true,PrunePropagationPolicy=foreground").
labels object no Key-value labels to apply to the application (e.g. {"env": "production"}).
description string no A human-readable description of the application.

argocd_list_projects

List all Argo CD projects.

Operation
Read read
Full name
argocd.argocd_list_projects
ParameterTypeRequiredDescription
No parameters.

argocd_get_project

Get details for a specific Argo CD project, including source/destination rules and cluster configurations.

Operation
Read read
Full name
argocd.argocd_get_project
ParameterTypeRequiredDescription
name string yes The name of the Argo CD project.

argocd_list_repositories

List all configured Git repositories in Argo CD, including connection status.

Operation
Read read
Full name
argocd.argocd_list_repositories
ParameterTypeRequiredDescription
repo string no Filter by repository URL.

argocd_get_current_user

Get the authenticated Argo CD user's profile information.

Operation
Read read
Full name
argocd.argocd_get_current_user
ParameterTypeRequiredDescription
No parameters.