Loops
Loop definitions and their runs: list, upsert, generate from a description, toggle, run, pause, resume and abort, plus the run history.
Send these requests to your own running server. Values stay in this browser.
How this works
Start a server with nikcli serve --hostname 127.0.0.1 --port 4096. Requests go
straight from this page to that address — the browser allows it because loopback counts as a
secure origin, and the server allows it because nikcli-ai.dev is in its CORS
allowlist.
To try things without touching your real sessions or config, start the server with
NIKCLI_TEST_HOME pointed at a throwaway directory — see
the guided tour.
Operations
14 endpoints, generated from the
server's own OpenAPI document. Every path also accepts the
directory and workspace query parameters that select which instance
handles the request.
| get | /loop | loop.list |
| put | /loop | loop.upsert |
| get | /loop/templates | loop.templates |
| post | /loop/generate | loop.generate |
| get | /loop/runs/recent | loop.recentRuns |
| get | /loop/{id} | loop.get |
| post | /loop/{id} | loop.update |
| delete | /loop/{id} | loop.delete |
| post | /loop/{id}/toggle | loop.toggle |
| post | /loop/{id}/run | loop.run |
| post | /loop/{id}/abort | loop.abort |
| post | /loop/{id}/pause | loop.pause |
| post | /loop/{id}/resume | loop.resume |
| get | /loop/{id}/runs | loop.runs |
Loop
loop.list | Name | In | Type | Required |
|---|---|---|---|
| directory | query | string | optional |
| workspace | query | string | optional |
{ loops: LoopDefinition[] runtimes: LoopRuntime[] }
Example response captured
{
"loops": [],
"runtimes": []
} SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.list({
...
}) Try it
loop.upsert | Name | In | Type | Required |
|---|---|---|---|
| directory | query | string | optional |
| workspace | query | string | optional |
{ name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled?: boolean }
{ id: string name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ name: "ValidationError" data: { [key: string]: unknown } }
Example response from schema
{
"id": "",
"name": "",
"stages": [
{
"name": "",
"agent": "",
"model": "",
"objective": "",
"tokenBudget": 0
}
],
"trigger": {
"kind": "manual"
},
"maxRuns": 0,
"timeoutMs": 0,
"createPR": false,
"sandbox": false,
"worktree": {
"name": "",
"branch": "",
"directory": ""
},
"paused": false,
"enabled": false,
"createdAt": 0
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.upsert({
...
}) Try it
Templates
loop.templates | Name | In | Type | Required |
|---|---|---|---|
| directory | query | string | optional |
| workspace | query | string | optional |
{ templates: LoopTemplate[] }
Example response from schema
{
"templates": [
{
"id": "",
"title": "",
"description": "",
"draft": {
"name": null,
"stages": null,
"intervalMs": null,
"maxRuns": null
}
}
]
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.templates({
...
}) Try it
Generate
loop.generate | Name | In | Type | Required |
|---|---|---|---|
| directory | query | string | optional |
| workspace | query | string | optional |
{ description: string model?: string agent?: string sessionID?: string }
{ id: string name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ name: "ValidationError" data: { [key: string]: unknown } }
Example response from schema
{
"id": "",
"name": "",
"stages": [
{
"name": "",
"agent": "",
"model": "",
"objective": "",
"tokenBudget": 0
}
],
"trigger": {
"kind": "manual"
},
"maxRuns": 0,
"timeoutMs": 0,
"createPR": false,
"sandbox": false,
"worktree": {
"name": "",
"branch": "",
"directory": ""
},
"paused": false,
"enabled": false,
"createdAt": 0
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.generate({
...
}) Try it
Runs
loop.recentRuns | Name | In | Type | Required |
|---|---|---|---|
| limit | query | string | optional |
| directory | query | string | optional |
| workspace | query | string | optional |
{ runs: LoopRun[] }
Example response from schema
{
"runs": [
{
"id": "",
"loopID": "",
"startedAt": 0,
"endedAt": 0,
"status": "running",
"heartbeatAt": 0,
"sessionID": "",
"error": "",
"ok": false,
"pullRequest": {
"number": null,
"url": null,
"branch": null,
"base": null,
"title": null,
"action": null
}
}
]
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.recentRuns({
...
}) Try it
{Id}
loop.get | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
{ loop: LoopDefinition runtime: LoopRuntime }
{ name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
{
"loop": {
"id": "",
"name": "",
"stages": [
{
"name": null,
"agent": null,
"model": null,
"objective": null,
"tokenBudget": null
}
],
"trigger": {
"kind": "manual"
},
"maxRuns": 0,
"timeoutMs": 0,
"createPR": false,
"sandbox": false,
"worktree": {
"name": "",
"branch": "",
"directory": ""
},
"paused": false,
"enabled": false,
"createdAt": 0
},
"runtime": {
"loopID": "",
"status": "idle",
"runs": 0,
"lastRunAt": 0,
"lastError": "",
"sessionID": ""
}
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.get({
...
}) Try it
loop.update | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
{ name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ id: string name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ name: "ValidationError" data: { [key: string]: unknown } }
{ name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
{
"id": "",
"name": "",
"stages": [
{
"name": "",
"agent": "",
"model": "",
"objective": "",
"tokenBudget": 0
}
],
"trigger": {
"kind": "manual"
},
"maxRuns": 0,
"timeoutMs": 0,
"createPR": false,
"sandbox": false,
"worktree": {
"name": "",
"branch": "",
"directory": ""
},
"paused": false,
"enabled": false,
"createdAt": 0
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.update({
...
}) Try it
loop.delete | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
boolean { name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
false
Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.delete({
...
}) Try it
This changes or removes server state, against whatever base URL is set above.
loop.toggle | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
{ enabled: boolean }
{ id: string name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
{
"id": "",
"name": "",
"stages": [
{
"name": "",
"agent": "",
"model": "",
"objective": "",
"tokenBudget": 0
}
],
"trigger": {
"kind": "manual"
},
"maxRuns": 0,
"timeoutMs": 0,
"createPR": false,
"sandbox": false,
"worktree": {
"name": "",
"branch": "",
"directory": ""
},
"paused": false,
"enabled": false,
"createdAt": 0
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.toggle({
...
}) Try it
loop.run | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
{ sessionID?: string }
boolean { name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
false
Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.run({
...
}) Try it
loop.abort | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
boolean { name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
false
Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.abort({
...
}) Try it
loop.pause | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
boolean { name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
false
Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.pause({
...
}) Try it
loop.resume | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| directory | query | string | optional |
| workspace | query | string | optional |
boolean { name: "NotFound" data: { [key: string]: unknown } }
Example response from schema
false
Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.resume({
...
}) Try it
loop.runs | Name | In | Type | Required |
|---|---|---|---|
| id | path | string | required |
| limit | query | string | optional |
| directory | query | string | optional |
| workspace | query | string | optional |
{ runs: LoopRun[] }
Example response from schema
{
"runs": [
{
"id": "",
"loopID": "",
"startedAt": 0,
"endedAt": 0,
"status": "running",
"heartbeatAt": 0,
"sessionID": "",
"error": "",
"ok": false,
"pullRequest": {
"number": null,
"url": null,
"branch": null,
"base": null,
"title": null,
"action": null
}
}
]
} Generated from the response schema — field values are placeholders, the shape is real.
SDK example
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"
const client = createNikcliClient()
await client.loop.runs({
...
}) Try it
Schemas
The 20 schemas reachable from these endpoints. Each is shown one level
deep; nested types link to their own entry below.
Names ending in _2, _3 and so on are the OpenAPI emitter
disambiguating same-named schemas declared by different HttpApi groups — they are distinct
shapes, not duplicates.
boolean { name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled?: boolean }
{ id: string name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ description: string model?: string agent?: string sessionID?: string }
{ loop: LoopDefinition runtime: LoopRuntime }
{ loops: LoopDefinition[] runtimes: LoopRuntime[] }
{ name: "NotFound" data: { [key: string]: unknown } }
{ number: | number | "Infinity" | "-Infinity" | "NaN" url: string branch: string base: string title?: string action: "created" | "updated" }
{ id: string loopID: string startedAt: | number | "Infinity" | "-Infinity" | "NaN" endedAt?: | number | "Infinity" | "-Infinity" | "NaN" status: | "running" | "complete" | "error" | "timeout" | "cancelled" | "orphaned" heartbeatAt?: | number | "Infinity" | "-Infinity" | "NaN" sessionID?: string error?: string ok: boolean pullRequest?: LoopPullRequestRef }
{ sessionID?: string }
{ runs: LoopRun[] }
{ loopID: string status: | "idle" | "running" | "paused" | "error" | "cancelling" runs: | number | "Infinity" | "-Infinity" | "NaN" lastRunAt?: | number | "Infinity" | "-Infinity" | "NaN" lastError?: string sessionID?: string }
{ name: string agent: string model?: string objective: string tokenBudget?: | number | "Infinity" | "-Infinity" | "NaN" }
{ id: string title: string description: string draft: { name?: string stages: ({ name?: string agent?: string model?: string objective: string tokenBudget?: | number | "Infinity" | "-Infinity" | "NaN" })[] intervalMs?: | number | "Infinity" | "-Infinity" | "NaN" maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" } }
{ templates: LoopTemplate[] }
{ enabled: boolean }
| { kind: "manual" } | { kind: "interval" everyMs: | number | "Infinity" | "-Infinity" | "NaN" }
{ name: string stages: LoopStage[] trigger: LoopTrigger maxRuns?: | number | "Infinity" | "-Infinity" | "NaN" timeoutMs?: | number | "Infinity" | "-Infinity" | "NaN" createPR?: boolean sandbox?: boolean worktree?: LoopWorktree paused?: boolean enabled: boolean createdAt: | number | "Infinity" | "-Infinity" | "NaN" }
{ name: "ValidationError" data: { [key: string]: unknown } }
{ name: string branch?: string directory: string }