style(cli): apply prettier formatting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-05-06 00:42:33 +03:00
parent a597b42648
commit 8771e259a8
9 changed files with 40 additions and 27 deletions

View File

@@ -99,9 +99,7 @@ function genericGet(def: ResourceDef) {
return async (args: Record<string, unknown>) => { return async (args: Record<string, unknown>) => {
const id = args.id as string; const id = args.id as string;
if (!id) throw new Error(`${def.name} id is required`); if (!id) throw new Error(`${def.name} id is required`);
const row = getDb() const row = getDb().prepare(`SELECT ${cols} FROM ${def.table} WHERE ${def.idColumn} = ?`).get(id);
.prepare(`SELECT ${cols} FROM ${def.table} WHERE ${def.idColumn} = ?`)
.get(id);
if (!row) throw new Error(`${def.name} not found: ${id}`); if (!row) throw new Error(`${def.name} not found: ${id}`);
return row; return row;
}; };
@@ -160,7 +158,9 @@ function genericUpdate(def: ResourceDef) {
} }
} }
if (Object.keys(updates).length === 0) { if (Object.keys(updates).length === 0) {
throw new Error(`nothing to update — provide at least one of: ${updatableCols.map((c) => '--' + c.name.replace(/_/g, '-')).join(', ')}`); throw new Error(
`nothing to update — provide at least one of: ${updatableCols.map((c) => '--' + c.name.replace(/_/g, '-')).join(', ')}`,
);
} }
const setClause = Object.keys(updates) const setClause = Object.keys(updates)
@@ -172,9 +172,7 @@ function genericUpdate(def: ResourceDef) {
if (result.changes === 0) throw new Error(`${def.name} not found: ${id}`); if (result.changes === 0) throw new Error(`${def.name} not found: ${id}`);
const cols = visibleColumns(def).join(', '); const cols = visibleColumns(def).join(', ');
return getDb() return getDb().prepare(`SELECT ${cols} FROM ${def.table} WHERE ${def.idColumn} = ?`).get(id);
.prepare(`SELECT ${cols} FROM ${def.table} WHERE ${def.idColumn} = ?`)
.get(id);
}; };
} }
@@ -182,9 +180,7 @@ function genericDelete(def: ResourceDef) {
return async (args: Record<string, unknown>) => { return async (args: Record<string, unknown>) => {
const id = args.id as string; const id = args.id as string;
if (!id) throw new Error(`${def.name} id is required`); if (!id) throw new Error(`${def.name} id is required`);
const result = getDb() const result = getDb().prepare(`DELETE FROM ${def.table} WHERE ${def.idColumn} = ?`).run(id);
.prepare(`DELETE FROM ${def.table} WHERE ${def.idColumn} = ?`)
.run(id);
if (result.changes === 0) throw new Error(`${def.name} not found: ${id}`); if (result.changes === 0) throw new Error(`${def.name} not found: ${id}`);
return { deleted: id }; return { deleted: id };
}; };

View File

@@ -18,11 +18,7 @@ export async function dispatch(req: RequestFrame, ctx: CallerContext): Promise<R
// Agent + approval-gated → approval flow. Wired alongside the first // Agent + approval-gated → approval flow. Wired alongside the first
// approval-requiring command; until then, return a clear error. // approval-requiring command; until then, return a clear error.
if (ctx.caller !== 'host' && cmd.access === 'approval') { if (ctx.caller !== 'host' && cmd.access === 'approval') {
return err( return err(req.id, 'approval-pending', 'This command requires approval. (Approval flow not yet wired.)');
req.id,
'approval-pending',
'This command requires approval. (Approval flow not yet wired.)',
);
} }
let parsed: unknown; let parsed: unknown;

View File

@@ -8,20 +8,37 @@ registerResource({
'Pending approval — in-flight approval cards waiting for an admin response. Created by requestApproval() (self-mod install_packages/add_mcp_server) and OneCLI credential approval flow. Rows are deleted after the admin approves/rejects or the request expires.', 'Pending approval — in-flight approval cards waiting for an admin response. Created by requestApproval() (self-mod install_packages/add_mcp_server) and OneCLI credential approval flow. Rows are deleted after the admin approves/rejects or the request expires.',
idColumn: 'approval_id', idColumn: 'approval_id',
columns: [ columns: [
{ name: 'approval_id', type: 'string', description: 'Unique approval identifier (also used as the card questionId).' }, {
{ name: 'session_id', type: 'string', description: 'Session that requested the approval. Null for OneCLI credential approvals.' }, name: 'approval_id',
{ name: 'request_id', type: 'string', description: 'Original request identifier (OneCLI request UUID or same as approval_id).' }, type: 'string',
description: 'Unique approval identifier (also used as the card questionId).',
},
{
name: 'session_id',
type: 'string',
description: 'Session that requested the approval. Null for OneCLI credential approvals.',
},
{
name: 'request_id',
type: 'string',
description: 'Original request identifier (OneCLI request UUID or same as approval_id).',
},
{ {
name: 'action', name: 'action',
type: 'string', type: 'string',
description: 'Action type — matches the registered approval handler (e.g. install_packages, add_mcp_server, onecli_credential).', description:
'Action type — matches the registered approval handler (e.g. install_packages, add_mcp_server, onecli_credential).',
}, },
{ name: 'payload', type: 'json', description: 'JSON payload carried through to the approval handler.' }, { name: 'payload', type: 'json', description: 'JSON payload carried through to the approval handler.' },
{ name: 'created_at', type: 'string', description: 'Auto-set.' }, { name: 'created_at', type: 'string', description: 'Auto-set.' },
{ name: 'agent_group_id', type: 'string', description: 'Originating agent group.' }, { name: 'agent_group_id', type: 'string', description: 'Originating agent group.' },
{ name: 'channel_type', type: 'string', description: 'Channel the approval card was delivered on.' }, { name: 'channel_type', type: 'string', description: 'Channel the approval card was delivered on.' },
{ name: 'platform_id', type: 'string', description: 'Platform chat ID the card was delivered to.' }, { name: 'platform_id', type: 'string', description: 'Platform chat ID the card was delivered to.' },
{ name: 'platform_message_id', type: 'string', description: 'Platform message ID of the delivered card (for editing on expiry).' }, {
name: 'platform_message_id',
type: 'string',
description: 'Platform message ID of the delivered card (for editing on expiry).',
},
{ name: 'expires_at', type: 'string', description: 'When this approval expires (OneCLI gateway TTL).' }, { name: 'expires_at', type: 'string', description: 'When this approval expires (OneCLI gateway TTL).' },
{ {
name: 'status', name: 'status',

View File

@@ -29,7 +29,7 @@ registerResource({
{ {
name: 'target_id', name: 'target_id',
type: 'string', type: 'string',
description: 'The target\'s ID — messaging_groups.id for channels, agent_groups.id for agents.', description: "The target's ID — messaging_groups.id for channels, agent_groups.id for agents.",
}, },
{ name: 'created_at', type: 'string', description: 'Auto-set.' }, { name: 'created_at', type: 'string', description: 'Auto-set.' },
], ],

View File

@@ -5,7 +5,7 @@ registerResource({
plural: 'dropped-messages', plural: 'dropped-messages',
table: 'unregistered_senders', table: 'unregistered_senders',
description: description:
'Dropped message log — tracks messages that were dropped by the router or access gate. Aggregates by (channel_type, platform_id) with a running count. Reasons include: no_agent_wired (no wiring exists), no_agent_engaged (wiring exists but engage rules didn\'t fire), unknown_sender_strict (sender not recognized, strict policy), unknown_sender_request_approval (sender not recognized, approval requested).', "Dropped message log — tracks messages that were dropped by the router or access gate. Aggregates by (channel_type, platform_id) with a running count. Reasons include: no_agent_wired (no wiring exists), no_agent_engaged (wiring exists but engage rules didn't fire), unknown_sender_strict (sender not recognized, strict policy), unknown_sender_request_approval (sender not recognized, approval requested).",
idColumn: 'channel_type', idColumn: 'channel_type',
columns: [ columns: [
{ name: 'channel_type', type: 'string', description: 'Channel adapter type of the dropped message.' }, { name: 'channel_type', type: 'string', description: 'Channel adapter type of the dropped message.' },

View File

@@ -26,7 +26,8 @@ registerResource({
{ {
name: 'agent_provider', name: 'agent_provider',
type: 'string', type: 'string',
description: 'LLM provider. Null means the default (claude). Skill-installed providers (e.g. opencode) register via /add-<provider>.', description:
'LLM provider. Null means the default (claude). Skill-installed providers (e.g. opencode) register via /add-<provider>.',
updatable: true, updatable: true,
default: null, default: null,
}, },

View File

@@ -19,7 +19,8 @@ registerResource({
{ {
name: 'agent_group_id', name: 'agent_group_id',
type: 'string', type: 'string',
description: 'Null = global (all groups). A specific ID limits the role to that group. Owner must always be null.', description:
'Null = global (all groups). A specific ID limits the role to that group. Owner must always be null.',
}, },
{ name: 'granted_by', type: 'string', description: 'Who granted this role. Informational.' }, { name: 'granted_by', type: 'string', description: 'Who granted this role. Informational.' },
{ name: 'granted_at', type: 'string', description: 'Auto-set.' }, { name: 'granted_at', type: 'string', description: 'Auto-set.' },

View File

@@ -5,7 +5,7 @@ registerResource({
plural: 'user-dms', plural: 'user-dms',
table: 'user_dms', table: 'user_dms',
description: description:
'User DM cache — maps (user, channel_type) to the messaging group used for DM delivery. Populated lazily by ensureUserDm() when the host needs to cold-DM a user (approvals, pairing). For direct-addressable channels (Telegram, WhatsApp) the handle IS the DM chat ID. For resolution-required channels (Discord, Slack) the adapter\'s openDM resolves it.', "User DM cache — maps (user, channel_type) to the messaging group used for DM delivery. Populated lazily by ensureUserDm() when the host needs to cold-DM a user (approvals, pairing). For direct-addressable channels (Telegram, WhatsApp) the handle IS the DM chat ID. For resolution-required channels (Discord, Slack) the adapter's openDM resolves it.",
idColumn: 'user_id', idColumn: 'user_id',
columns: [ columns: [
{ name: 'user_id', type: 'string', description: 'User this DM route is for.' }, { name: 'user_id', type: 'string', description: 'User this DM route is for.' },

View File

@@ -11,7 +11,8 @@ registerResource({
{ {
name: 'id', name: 'id',
type: 'string', type: 'string',
description: 'Namespaced "channel_type:handle" — e.g. "tg:6037840640", "discord:123456789", "email:user@example.com". Must be provided on create.', description:
'Namespaced "channel_type:handle" — e.g. "tg:6037840640", "discord:123456789", "email:user@example.com". Must be provided on create.',
required: true, required: true,
}, },
{ {
@@ -24,7 +25,8 @@ registerResource({
{ {
name: 'display_name', name: 'display_name',
type: 'string', type: 'string',
description: 'Human-readable name. Shown in approval cards and logs. Often auto-populated from the channel adapter.', description:
'Human-readable name. Shown in approval cards and logs. Often auto-populated from the channel adapter.',
updatable: true, updatable: true,
}, },
{ name: 'created_at', type: 'string', description: 'Auto-set.', generated: true }, { name: 'created_at', type: 'string', description: 'Auto-set.', generated: true },