Skip to content

nanocoai/nanoclaw / .claude/skills/slack-agent-flow

slack-agent-flow

Flagged

Let an existing Slack agent create new agents that arrive as their own Slack bots — provisioned app, operator DM, and a shared three-way room, hot-started without a host restart.

src/modules/slack-agent-flow/guard.ts

View on GitHub
/**
 * Slack-agent-flow guard adapter — the module's catalog entries for the
 * agent-facing room actions, composed at the module edge (imported
 * by ./index.ts), mirroring agent-to-agent/guard.ts.
 *
 * rooms.create / rooms.add_agent — same trust split as agents.create:
 * `global` cli_scope acts directly (room wiring is the intended primitive for
 * trusted owner agent groups); anything else — the default `group` scope, and
 * unknown/missing config, fail-closed — holds for the requesting group's
 * admin chain. Both actions write central-DB state (messaging groups,
 * wirings, a2a destinations) and open Slack conversations with the operator,
 * so a confined container must never reach the handler unheld.
 */
import { getContainerConfig } from '../../db/container-configs.js';
import { ALLOW, DENY, HOLD, defineGuardedAction, type GuardedAction } from '../../guard/index.js';
import type { GuardDecision, GuardInput } from '../../guard/index.js';

/** The agents.create trust split, reused verbatim for the room actions. */
async function decideByCliScope(input: GuardInput, action: string): Promise<GuardDecision> {
  if (input.actor.kind !== 'agent') return DENY(`${action} is a container-originated action.`);
  const cliScope = (await getContainerConfig(input.actor.agentGroupId))?.cli_scope ?? 'group';
  if (cliScope === 'global') {
    // Trusted owner agent group — an approval tap on every room change would
    // be needless friction.
    return ALLOW('trusted global-scope agent group');
  }
  // The realistic prompt-injection victim (default `group` scope) — and any
  // unknown config value, fail-closed — requires an admin before any
  // central-DB write or MPIM open.
  return HOLD(`agent-initiated ${action} requires admin approval`);
}

export const roomsCreate: GuardedAction = defineGuardedAction({
  action: 'rooms.create',
  grantActionName: 'create_room',
  // Bind a create_room grant to the room name that was approved.
  grantCoversRequest: (grant, input) => {
    try {
      return (JSON.parse(grant.payload) as { name?: string }).name === input.payload.name;
    } catch {
      return false;
    }
  },
  decide: (input) => decideByCliScope(input, 'create_room'),
});

export const roomsAddAgent: GuardedAction = defineGuardedAction({
  action: 'rooms.add_agent',
  grantActionName: 'add_to_room',
  // Bind an add_to_room grant to the exact (room, agent) pair approved.
  grantCoversRequest: (grant, input) => {
    try {
      const p = JSON.parse(grant.payload) as { room?: string; agent?: string };
      return p.room === input.payload.room && p.agent === input.payload.agent;
    } catch {
      return false;
    }
  },
  decide: (input) => decideByCliScope(input, 'add_to_room'),
});
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall