@rogeriq/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +166 -0
- package/README.md +136 -0
- package/dist/index.mjs +2326 -0
- package/package.json +37 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Using `rogeriq` from AI agents
|
|
2
|
+
|
|
3
|
+
This document describes how to drive the RogerIQ CLI from an AI agent
|
|
4
|
+
(Claude, GPT, Codex, internal tooling). The CLI is built for headless use:
|
|
5
|
+
no interactive prompts when env vars are set, machine-readable output,
|
|
6
|
+
structured error codes, and an MCP transport for direct LLM tool calls.
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
export RIQ_API_KEY=riq_xxx # required
|
|
12
|
+
export RIQ_PROJECT_ID=prj_xxx # default project (per-command --project overrides)
|
|
13
|
+
export RIQ_ORG_ID=org_xxx # for org-level commands (orgs, projects, keys)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The CLI never prompts when these are set. No interactive `--browser` flow.
|
|
17
|
+
|
|
18
|
+
## Output contract
|
|
19
|
+
|
|
20
|
+
- Stdout = data. Stderr = logs and errors.
|
|
21
|
+
- JSON output is auto-enabled when stdout is not a TTY (most subprocess
|
|
22
|
+
invocations), so agents always get JSON by default. Pass `--json` to
|
|
23
|
+
force it explicitly.
|
|
24
|
+
- Errors print to stderr as JSON when in JSON mode:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{ "error": "Conversation not found",
|
|
28
|
+
"code": "RESOURCE_NOT_FOUND",
|
|
29
|
+
"request_id": "req_abc123",
|
|
30
|
+
"status_code": 404 }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Exit codes:
|
|
34
|
+
|
|
35
|
+
| Code | Meaning |
|
|
36
|
+
|------|----------------------|
|
|
37
|
+
| 0 | Success |
|
|
38
|
+
| 1 | User / usage error |
|
|
39
|
+
| 2 | API error |
|
|
40
|
+
| 3 | Auth error |
|
|
41
|
+
| 4 | Rate-limited (after retry exhausted) |
|
|
42
|
+
|
|
43
|
+
Branch on `code` for fine-grained behavior; on exit code for
|
|
44
|
+
retry/abort decisions.
|
|
45
|
+
|
|
46
|
+
- Rate limits: the API returns `X-RateLimit-Remaining` headers and on 429
|
|
47
|
+
the CLI auto-retries once after the server-suggested delay. Agents
|
|
48
|
+
don't need to handle 429 manually for short waits.
|
|
49
|
+
|
|
50
|
+
## Two ways to use it
|
|
51
|
+
|
|
52
|
+
### 1) Shell out to `rogeriq`
|
|
53
|
+
|
|
54
|
+
Best for any agent harness that can invoke commands and read stdout:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# List open tickets, then pick high-priority ones
|
|
58
|
+
rogeriq conversations list --status open --priority high --json \
|
|
59
|
+
| jq '.[] | { id, subject, contact_id }'
|
|
60
|
+
|
|
61
|
+
# Reply on a conversation
|
|
62
|
+
rogeriq conversations reply con_xxx "On it — checking now."
|
|
63
|
+
|
|
64
|
+
# Trigger AI to draft + send a response
|
|
65
|
+
rogeriq agent respond con_xxx
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2) MCP (recommended for Claude)
|
|
69
|
+
|
|
70
|
+
Run `rogeriq mcp` as an MCP server (stdio). Tools are exposed natively
|
|
71
|
+
and the LLM doesn't have to know shell syntax.
|
|
72
|
+
|
|
73
|
+
**Claude Desktop / Claude Code config:**
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"rogeriq": {
|
|
79
|
+
"command": "rogeriq",
|
|
80
|
+
"args": ["mcp"],
|
|
81
|
+
"env": {
|
|
82
|
+
"RIQ_API_KEY": "riq_xxx",
|
|
83
|
+
"RIQ_PROJECT_ID": "prj_xxx",
|
|
84
|
+
"RIQ_ORG_ID": "org_xxx"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Then the model can call tools like `list_conversations`,
|
|
92
|
+
`reply_to_conversation`, `update_conversation`, `search_knowledge_base`,
|
|
93
|
+
`agent_respond`, `update_widget_config`, etc.
|
|
94
|
+
|
|
95
|
+
Run `rogeriq mcp list-tools` for the full schema.
|
|
96
|
+
|
|
97
|
+
## Common workflows
|
|
98
|
+
|
|
99
|
+
### Triage queue
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Get oldest open tickets
|
|
103
|
+
rogeriq conversations list --status open --json \
|
|
104
|
+
| jq -r '.[] | .id'
|
|
105
|
+
|
|
106
|
+
# For each, classify + tag
|
|
107
|
+
for id in $(rogeriq conversations list --status open --quiet); do
|
|
108
|
+
rogeriq agent classify "$id"
|
|
109
|
+
done
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Auto-respond high-confidence tickets
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
for id in $(rogeriq conversations list --status open --quiet); do
|
|
116
|
+
rogeriq agent respond "$id" # respects agent_mode (autopilot/copilot)
|
|
117
|
+
done
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Ingest a docs site into KB
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
rogeriq kb crawl https://docs.example.com
|
|
124
|
+
# Poll status
|
|
125
|
+
rogeriq kb crawl status crawl_xxx
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Wire a webhook to your own system
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
rogeriq webhooks create \
|
|
132
|
+
--url https://yourapp.com/rogeriq-hook \
|
|
133
|
+
--events 'conversation.*,message.created'
|
|
134
|
+
rogeriq webhooks test wh_xxx # immediate sample event
|
|
135
|
+
rogeriq webhooks deliveries wh_xxx
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Project switching
|
|
139
|
+
|
|
140
|
+
Many agents work across multiple projects. Either:
|
|
141
|
+
|
|
142
|
+
- Set `RIQ_PROJECT_ID` per shell command:
|
|
143
|
+
```bash
|
|
144
|
+
RIQ_PROJECT_ID=prj_a rogeriq conversations list
|
|
145
|
+
RIQ_PROJECT_ID=prj_b rogeriq conversations list
|
|
146
|
+
```
|
|
147
|
+
- Or pass `--project prj_xxx`:
|
|
148
|
+
```bash
|
|
149
|
+
rogeriq conversations list --project prj_a
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Safety
|
|
153
|
+
|
|
154
|
+
- Destructive commands (`projects delete`, `keys revoke`, `kb delete`)
|
|
155
|
+
do **not** prompt. Build confirmation into your agent if needed.
|
|
156
|
+
- API keys are scoped (`read` / `write` / `admin`). Give agents a
|
|
157
|
+
least-privilege key.
|
|
158
|
+
- All actions are audited server-side (audit log) with the API key id.
|
|
159
|
+
|
|
160
|
+
## Discoverability
|
|
161
|
+
|
|
162
|
+
- `rogeriq --help` lists commands.
|
|
163
|
+
- `rogeriq <group>` lists subcommands.
|
|
164
|
+
- `rogeriq <group> <cmd> --help` shows flags + examples.
|
|
165
|
+
- OpenAPI spec: `GET /api/v1/openapi.json` (use for codegen, agent
|
|
166
|
+
function-call schemas, etc).
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# `@rogeriq/cli`
|
|
2
|
+
|
|
3
|
+
Command-line interface for [RogerIQ](https://rogeriq.com). Manage tickets,
|
|
4
|
+
projects, knowledge base, widget, integrations, and webhooks from your
|
|
5
|
+
terminal or AI agent.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @rogeriq/cli
|
|
11
|
+
# or via npx:
|
|
12
|
+
npx @rogeriq/cli --help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Auth
|
|
16
|
+
|
|
17
|
+
Create an API key in the dashboard or via the CLI (after one-time browser
|
|
18
|
+
login from `app.rogeriq.com`):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
rogeriq auth login --api-key riq_xxx
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For CI / agents, prefer env vars (no config file needed):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
export RIQ_API_KEY=riq_xxx
|
|
28
|
+
export RIQ_PROJECT_ID=prj_xxx # default project for commands
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
rogeriq auth whoami
|
|
35
|
+
rogeriq projects list
|
|
36
|
+
rogeriq projects use prj_xxx
|
|
37
|
+
rogeriq conversations list --status open
|
|
38
|
+
rogeriq conversations reply con_xxx "Thanks, looking into it now."
|
|
39
|
+
rogeriq conversations resolve con_xxx
|
|
40
|
+
|
|
41
|
+
rogeriq kb search "refund policy"
|
|
42
|
+
rogeriq agent respond con_xxx # let AI draft + send reply
|
|
43
|
+
|
|
44
|
+
rogeriq widget config
|
|
45
|
+
rogeriq widget set --theme dark --primary-color '#5b21b6'
|
|
46
|
+
|
|
47
|
+
rogeriq webhooks create \
|
|
48
|
+
--url https://example.com/hook \
|
|
49
|
+
--events 'conversation.*,message.created'
|
|
50
|
+
rogeriq webhooks test wh_xxx # fire sample event
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Output
|
|
54
|
+
|
|
55
|
+
- Default: human-readable tables.
|
|
56
|
+
- Auto-JSON when stdout is piped (clean for agents and `jq`).
|
|
57
|
+
- `--json` forces JSON. `--quiet` prints only IDs.
|
|
58
|
+
- Stderr for logs/errors. Stdout is always data.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Pipe to jq
|
|
62
|
+
rogeriq conversations list --status open | jq '.[].id'
|
|
63
|
+
|
|
64
|
+
# Use IDs in a shell loop
|
|
65
|
+
for id in $(rogeriq conversations list --status open --quiet); do
|
|
66
|
+
rogeriq conversations resolve "$id"
|
|
67
|
+
done
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
auth login | logout | whoami
|
|
74
|
+
config get | set | path
|
|
75
|
+
orgs list | get | create | use | members
|
|
76
|
+
projects list | get | create | update | delete | use
|
|
77
|
+
keys list | create | revoke
|
|
78
|
+
|
|
79
|
+
conversations list | get | create | update | reply | resolve | snooze | assign
|
|
80
|
+
messages list | send
|
|
81
|
+
contacts list | get | upsert | update
|
|
82
|
+
|
|
83
|
+
agent status | config | models | respond | classify | suggest | knowledge-map
|
|
84
|
+
kb list | get | create | update | delete | publish | search | ingest | crawl | categories
|
|
85
|
+
|
|
86
|
+
widget config | set | snippet | custom-fields
|
|
87
|
+
integrations list | get | connect | configure | disconnect
|
|
88
|
+
forms list | get | create | update | archive | submissions
|
|
89
|
+
beacons list | get | create | update | archive
|
|
90
|
+
|
|
91
|
+
webhooks list | get | create | update | delete | test | deliveries | rotate-secret
|
|
92
|
+
analytics overview | report-views
|
|
93
|
+
status (project status overview)
|
|
94
|
+
|
|
95
|
+
mcp Run as an MCP server (stdio) — for Claude Desktop / Claude Code
|
|
96
|
+
mcp list-tools
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Run `rogeriq <group>` to see all subcommands, or `rogeriq <group> <sub> --help`
|
|
100
|
+
for command-specific flags.
|
|
101
|
+
|
|
102
|
+
## Config
|
|
103
|
+
|
|
104
|
+
`~/.rogeriq/config.json` (mode 0600). Overridden by env vars:
|
|
105
|
+
|
|
106
|
+
| Key | Env var |
|
|
107
|
+
|-------------|------------------|
|
|
108
|
+
| apiKey | `RIQ_API_KEY` |
|
|
109
|
+
| apiBase | `RIQ_API_BASE` |
|
|
110
|
+
| orgId | `RIQ_ORG_ID` |
|
|
111
|
+
| projectId | `RIQ_PROJECT_ID` |
|
|
112
|
+
|
|
113
|
+
## Exit codes
|
|
114
|
+
|
|
115
|
+
| Code | Meaning |
|
|
116
|
+
|------|----------------------|
|
|
117
|
+
| 0 | Success |
|
|
118
|
+
| 1 | User error / usage |
|
|
119
|
+
| 2 | API error |
|
|
120
|
+
| 3 | Auth error |
|
|
121
|
+
| 4 | Rate-limited (after retry exhausted) |
|
|
122
|
+
|
|
123
|
+
## AI agents
|
|
124
|
+
|
|
125
|
+
See `AGENTS.md`. TL;DR: pass `RIQ_API_KEY` and `RIQ_PROJECT_ID` as env, use
|
|
126
|
+
`--json`, branch on `code` from stderr error JSON, or run `rogeriq mcp`
|
|
127
|
+
and let Claude call tools directly over MCP.
|
|
128
|
+
|
|
129
|
+
## Develop
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm install
|
|
133
|
+
npm run build # bundle to dist/index.mjs
|
|
134
|
+
npm run typecheck
|
|
135
|
+
./dist/index.mjs --help
|
|
136
|
+
```
|