INNER CODE UNIT · TypeScript

slackAwareCreateAgent

nanocoai/nanoclaw · .claude/skills/slack-agent-flow/src/modules/slack-agent-flow/index.ts:171

async function slackAwareCreateAgent(content: Record<string, unknown>, session: Session): Promise<void> {
  const name = typeof content.name === 'string' ? content.name : '';
  const localName = normalizeName(name);
  const before = await getDestinationByName(session.agent_group_id, localName);
  const slackOrigin = await isSlackOriginSession(session);

  // Resume, not collide: the agent group exists and its Slack app exists, but
  // the workspace never approved the install, so the flow parked. Asking for
  // the same agent again is how a user says "finish that" — take them back to
  // waiting on the app they already have rather than reporting a name clash
  // (upstream's answer) or provisioning a second one.
  if (slackOrigin && before?.target_type === 'agent' && name) {
    const slug = await dedupeSlug(deriveInstanceSlug(name), before.target_id);
    if (pendingInstall(process.cwd(), slug)) {
      await runSlackLeg(content, session, { name, localName, newAgentGroupId: before.target_id, slug });
      return;
    }
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…