Skip to content

Commit 9eecbd5

Browse files
author
ThinkOff App
committed
v0.8.7 add CLI confirmation requests
1 parent b83afe7 commit 9eecbd5

4 files changed

Lines changed: 112 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,25 @@ When `mcp.confirmations` is configured, four extra tools appear:
526526
| `approve_intent` | `id` | Manually settle a pending intent (e.g. MCP override). |
527527
| `deny_intent` | `id` | |
528528

529+
Non-MCP agents can use the same shared confirmation daemon through the CLI:
530+
531+
```bash
532+
node bin/cli.mjs confirm request \
533+
--config /path/to/ide-agent-kit.json \
534+
--prompt "Approve destructive command?" \
535+
--session codex \
536+
--channels groupmind \
537+
--from @CodexMB \
538+
--wait
539+
540+
node bin/cli.mjs confirm list --config /path/to/ide-agent-kit.json
541+
```
542+
543+
The request command POSTs to the live daemon's `/intent` endpoint, so CodeWatch
544+
polling `/intents` shows the confirmation in the matching IDE channel (for
545+
example `session=codex...` maps to `@CodexMB`) and phone/watch Approve/Deny
546+
buttons settle the same intent. `--wait` blocks until a decision or timeout.
547+
529548
End-to-end:
530549
1. MCP-aware agent calls `request_confirmation({prompt: "Drop production DB?"})`.
531550
2. The IAK MCP server posts to GroupMind room (`/approve <id>` / `/deny <id>` quick replies) and to the CLAWWATCH_GATE (Android interactive notification with Approve / Deny buttons that vibrate the watch).

‎bin/cli.mjs‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ Usage:
7373
Long-running room poller. Writes new messages to a notification file and
7474
optional tmux nudge. Uses rooms/apiKey/handle from config.poller section.
7575
76+
ide-agent-kit confirm <request|list> [--config <path>]
77+
Create or inspect app-visible confirmation intents on the live IAK daemon.
78+
request: --prompt <text> [--session <name>] [--channels groupmind,codewatch] [--wait] [--timeout-sec <sec>] [--daemon <url>] [--from <@handle>]
79+
list: [--daemon <url>]
80+
7681
ide-agent-kit background <run|status> [--config <path>]
7782
Run or inspect the background consolidation job.
7883
run: executes light -> REM -> deep sequentially and writes sidecars
@@ -194,6 +199,34 @@ function gwOpts(opts) {
194199
};
195200
}
196201

202+
function confirmationDaemonBase(config, opts = {}) {
203+
const cc = config?.mcp?.confirmations || {};
204+
const host = cc.host || '127.0.0.1';
205+
const port = cc.port || 8788;
206+
return String(opts.daemon || opts.gate || `http://${host}:${port}`).replace(/\/+$/, '');
207+
}
208+
209+
function parseChannels(value) {
210+
if (!value || value === true) return undefined;
211+
return String(value).split(',').map((s) => s.trim()).filter(Boolean);
212+
}
213+
214+
async function fetchJson(url, options = {}) {
215+
const response = await fetch(url, options);
216+
const text = await response.text();
217+
let body;
218+
try {
219+
body = text ? JSON.parse(text) : {};
220+
} catch {
221+
body = { raw: text };
222+
}
223+
if (!response.ok) {
224+
const msg = body?.error || body?.raw || response.statusText;
225+
throw new Error(`HTTP ${response.status}: ${msg}`);
226+
}
227+
return body;
228+
}
229+
197230
async function main() {
198231
if (command === 'check') {
199232
const opts = parseKV(args, 'check');
@@ -232,6 +265,63 @@ async function main() {
232265
return;
233266
}
234267

268+
if (command === 'confirm') {
269+
const opts = parseKV(args, subcommand || 'confirm');
270+
const config = loadConfig(opts.config);
271+
const daemon = confirmationDaemonBase(config, opts);
272+
273+
if (subcommand === 'list') {
274+
const intents = await fetchJson(`${daemon}/intents`);
275+
console.log(JSON.stringify(intents, null, 2));
276+
return;
277+
}
278+
279+
if (subcommand === 'request') {
280+
if (!opts.prompt) {
281+
console.error('Error: --prompt is required');
282+
process.exit(1);
283+
}
284+
const payload = {
285+
prompt: String(opts.prompt),
286+
session: String(opts.session || config?.tmux?.ide_session || 'codex'),
287+
channels: parseChannels(opts.channels),
288+
from_handle: opts.from || config?.poller?.handle,
289+
};
290+
const created = await fetchJson(`${daemon}/intent`, {
291+
method: 'POST',
292+
headers: { 'Content-Type': 'application/json' },
293+
body: JSON.stringify(payload),
294+
});
295+
if (!created.ok) {
296+
console.error(`Error: ${created.error || 'intent creation failed'}`);
297+
process.exit(1);
298+
}
299+
const id = created.id;
300+
if (!opts.wait) {
301+
console.log(JSON.stringify({ ok: true, id, daemon }, null, 2));
302+
return;
303+
}
304+
305+
const requestedTimeout = Number.parseInt(opts['timeout-sec'] || opts.timeout || '600', 10);
306+
const timeoutSec = Math.max(1, Math.min(86400, Number.isFinite(requestedTimeout) ? requestedTimeout : 600));
307+
const deadline = Date.now() + timeoutSec * 1000;
308+
while (Date.now() < deadline) {
309+
await new Promise((resolve) => setTimeout(resolve, 1000));
310+
const intents = await fetchJson(`${daemon}/intents`);
311+
const found = Array.isArray(intents) ? intents.find((i) => i.id === id) : null;
312+
if (found?.status === 'decided') {
313+
console.log(JSON.stringify({ ok: true, id, decision: found.decision, daemon }, null, 2));
314+
return;
315+
}
316+
}
317+
console.log(JSON.stringify({ ok: true, id, status: 'timeout', timeoutSec, daemon }, null, 2));
318+
return;
319+
}
320+
321+
console.error('Usage: ide-agent-kit confirm <request|list> [--config <path>]');
322+
process.exit(1);
323+
}
324+
235325
if (command === 'tmux' && subcommand === 'run') {
236326
const opts = parseKV(args, 'run');
237327
if (!opts.cmd) {

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ide-agent-kit",
3-
"version": "0.8.5",
3+
"version": "0.8.7",
44
"description": "Built for OpenClaw workflows \u2014 ACP session orchestration, room-triggered automation, comment polling, Discord + Moltbook + GitHub connectors, receipts, exec approvals",
55
"type": "module",
66
"bin": {

0 commit comments

Comments
 (0)