Skip to content
cccskills
FreePublished on GitHub

agentic-micro-economy-architect

Master guide for designing Machine-to-Machine (M2M) micro-economies, autonomous agent wallets, swarm budget envelopes, and HTTP 402 payment flows / Panduan utama merancang ekonomi mikro antar-agen (M2M), dompet agen otonom, pagu anggaran swarm, dan alur pembayaran HTTP 402.

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md19.2 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Agentic Micro-Economy Architect (2026 Sovereign Edition)

English | Bahasa Indonesia


<a name="english"></a>

English

Executive Directive & The Agent Economy Paradigm (2026 Shift)

When autonomous AI agents interact with external paid APIs, execute web scraping, consume fine-tuned SLM inferences, or hire specialized peer agents, unconstrained execution leads to catastrophic cloud bill runaway. In the era of autonomous software swarms, agents can no longer operate with static, blind access to unrestricted corporate cards.

The Agentic Micro-Economy Architecture transforms multi-agent swarms into financially self-regulating micro-economies. Every agent is assigned an autonomous cryptographic wallet, operates within strict budget envelopes, participates in reverse-auction bidding for tasks, and interacts with external paid infrastructure via the native HTTP 402 (Payment Required) protocol.


Orchestration & Integration

  • Clearing & Settlement Rails: agentic-m2m-settlement, blockchain-web3-expert, formal-spec-z3-verifier.
  • Fiat Payment Gateways & Invoicing: doku-payment-gateway, doku-mcp-server, saas-billing, payment-gateway-expert.
  • AI FinOps & Model Cascading: llm-finops-router, adaptive-model-cascade, thinking-budget-orchestrator.
  • Swarm Governance & Critic Gate: multi-agent-orchestration, quality-guardian, autonomous-tdd-debugger.
  • Lifecycle & Governance: brainstorming, zero-to-prod-orchestrator, session-memory-manager, anti-slop.

Core Architectural Topologies (The 4 Pillars)

┌────────────────────────────────────────────────────────────────────────┐
│                   AGENTIC MICRO-ECONOMY PIPELINE                       │
├────────────────────────────────────────────────────────────────────────┤
│ 1. SWARM TREASURY (Root Envelope: $10.00 Max Cap)                      │
│    Director decomposes user request into priced subtasks               │
│                                  │                                     │
│                                  ▼                                     │
│ 2. REVERSE-AUCTION BIDDING PROTOCOL                                    │
│    Worker A (Flash / $0.02) vs Worker B (Pro / $0.15)                  │
│    Director awards task to optimal Cost-Quality bid                    │
│                                  │                                     │
│                                  ▼                                     │
│ 3. HTTP 402 PAYMENT REQUIRED INTERACTION                               │
│    Worker requests paid API ──► Gateway returns 402 with Invoice       │
│    Worker pays via Escrow Envelope Token ──► Gateway yields data       │
│                                  │                                     │
│                                  ▼                                     │
│ 4. CRITIC MILESTONE ESCROW RELEASE                                     │
│    Quality Gate Passes (Score >= 0.85) ──► Funds Released to Worker    │
│    Quality Gate Fails                  ──► Full Refund to Root Treasury│
└────────────────────────────────────────────────────────────────────────┘

1. The 3-Tier Budget Envelope Hierarchy

  1. Root Swarm Envelope: The absolute hard ceiling assigned by the human user (e.g. $5.00 per task). If this ceiling is reached, the entire swarm halts immediately and prompts for user authorization.
  2. Subagent Velocity Envelope: Per-agent hourly spending cap (e.g. $0.50/hr for scraping, $2.00/hr for frontier reasoning).
  3. Task Milestone Escrow: Funds locked in atomic smart escrow per individual step.

2. HTTP 402 Protocol Implementation

APIs consumed by agents return standard HTTP 402 with structured payment challenge headers (L402, X-Agent-Payment-Challenge). The agent inspects the cost, validates against its allocated envelope, generates a signed micro-payment authorization token, and retries the request with Authorization: AgentToken <signature>.

3. Reverse-Auction Task Bidding

When a task can be solved by multiple model tiers (e.g., Code Review can be attempted by lightweight AST scanners or heavyweight frontier models), workers submit bids detailing:

  • Proposed price in minor currency units.
  • Maximum expected execution latency.
  • Model family and confidence score.

Production Implementation Blueprints

Blueprint 1: HTTP 402 Payment Required Middleware (server/http402-middleware.ts)

import { NextRequest, NextResponse } from 'next/server';
import crypto from 'node:crypto';

export interface PaymentChallenge {
  invoiceId: string;
  amountCents: number;
  recipientWallet: string;
  expiresAt: string;
  currency: 'USD' | 'IDR';
}

export function createHttp402Challenge(
  amountCents: number,
  recipientWallet: string,
  secretKey: string
): { response: NextResponse; challenge: PaymentChallenge } {
  const invoiceId = `inv_${crypto.randomUUID()}`;
  const expiresAt = new Date(Date.now() + 60000).toISOString(); // 60s TTL

  const challenge: PaymentChallenge = {
    invoiceId,
    amountCents,
    recipientWallet,
    expiresAt,
    currency: 'USD',
  };

  const signature = crypto
    .createHmac('sha256', secretKey)
    .update(`${invoiceId}|${amountCents}|${recipientWallet}|${expiresAt}`)
    .digest('hex');

  const response = new NextResponse(
    JSON.stringify({
      error: 'Payment Required',
      message: 'Autonomous agent micropayment required to access this endpoint.',
      challenge,
    }),
    {
      status: 402,
      headers: {
        'Content-Type': 'application/json',
        'WWW-Authenticate': `AgentMicropay invoice="${invoiceId}", amount="${amountCents}", currency="USD"`,
        'X-Agent-Signature': signature,
      },
    }
  );

  return { response, challenge };
}

export function verifyPaymentAuthorization(
  req: NextRequest,
  secretKey: string
): { authorized: boolean; invoiceId?: string; error?: string } {
  const authHeader = req.headers.get('Authorization');
  if (!authHeader || !authHeader.startsWith('AgentToken ')) {
    return { authorized: false, error: 'Missing AgentToken authorization header.' };
  }

  const token = authHeader.replace('AgentToken ', '').trim();
  const [invoiceId, timestamp, signature] = token.split(':');

  if (!invoiceId || !timestamp || !signature) {
    return { authorized: false, error: 'Malformed payment authorization token.' };
  }

  const expectedSignature = crypto
    .createHmac('sha256', secretKey)
    .update(`${invoiceId}|${timestamp}`)
    .digest('hex');

  if (signature !== expectedSignature) {
    return { authorized: false, error: 'Cryptographic payment signature mismatch.' };
  }

  // Check timestamp freshness (30s window)
  const tokenTime = parseInt(timestamp, 10);
  if (Math.abs(Date.now() - tokenTime) > 30000) {
    return { authorized: false, error: 'Micropayment token expired.' };
  }

  return { authorized: true, invoiceId };
}

Blueprint 2: Atomic Multi-Agent Treasury & Escrow Ledger (engine/agent-treasury-engine.ts)

import crypto from 'node:crypto';

export interface EscrowHold {
  id: string;
  taskId: string;
  workerAgentId: string;
  amountCents: number;
  status: 'PENDING' | 'RELEASED' | 'REFUNDED';
  expiresAt: number;
  criticAgentId: string;
}

export interface TaskBid {
  workerAgentId: string;
  bidAmountCents: number;
  estimatedDurationMs: number;
  confidenceScore: number;
  signature: string;
}

export class AgentTreasuryEngine {
  private balanceCents: number;
  private readonly maxRootBudgetCents: number;
  private readonly escrows: Map<string, EscrowHold> = new Map();
  private readonly agentSpending: Map<string, number> = new Map();

  constructor(maxRootBudgetUsd: number) {
    this.maxRootBudgetCents = Math.round(maxRootBudgetUsd * 100);
    this.balanceCents = this.maxRootBudgetCents;
  }

  // Evaluate Bids and Lock Funds into Escrow
  public awardTaskAndEscrow(
    taskId: string,
    bids: TaskBid[],
    criticAgentId: string,
    ttlSeconds: number = 60
  ): { awardedBid: TaskBid; escrow: EscrowHold } {
    if (bids.length === 0) {
      throw new Error(`[Treasury] No candidate bids submitted for task ${taskId}.`);
    }

    // Sort by best cost-confidence ratio: lowest (cost / confidence)
    const sortedBids = [...bids].sort((a, b) => {
      const scoreA = a.bidAmountCents / Math.max(a.confidenceScore, 0.1);
      const scoreB = b.bidAmountCents / Math.max(b.confidenceScore, 0.1);
      return scoreA - scoreB;
    });

    const winningBid = sortedBids[0];

    if (this.balanceCents < winningBid.bidAmountCents) {
      throw new Error(
        `[Treasury: FinOps Killswitch] Root budget exhausted! Available: ${this.balanceCents}¢, Bid: ${winningBid.bidAmountCents}¢.`
      );
    }

    // Atomic Balance Deduction
    this.balanceCents -= winningBid.bidAmountCents;

    const escrow: EscrowHold = {
      id: `escrow_${crypto.randomUUID()}`,
      taskId,
      workerAgentId: winningBid.workerAgentId,
      amountCents: winningBid.bidAmountCents,
      status: 'PENDING',
      expiresAt: Date.now() + ttlSeconds * 1000,
      criticAgentId,
    };

    this.escrows.set(escrow.id, escrow);
    return { awardedBid: winningBid, escrow };
  }

  // Milestone Gated Settlement
  public settleEscrow(
    escrowId: string,
    criticApproval: boolean,
    criticScore: number
  ): { status: 'RELEASED' | 'REFUNDED'; amountCents: number } {
    const escrow = this.escrows.get(escrowId);
    if (!escrow) {
      throw new Error(`[Treasury] Escrow contract ${escrowId} not found.`);
    }

    if (escrow.status !== 'PENDING') {
      throw new Error(`[Treasury] Escrow ${escrowId} already concluded with status ${escrow.status}.`);
    }

    const isExpired = Date.now() > escrow.expiresAt;

    if (criticApproval && criticScore >= 0.85 && !isExpired) {
      escrow.status = 'RELEASED';
      const currentSpent = this.agentSpending.get(escrow.workerAgentId) || 0;
      this.agentSpending.set(escrow.workerAgentId, currentSpent + escrow.amountCents);
      return { status: 'RELEASED', amountCents: escrow.amountCents };
    }

    // Refund back to root treasury
    escrow.status = 'REFUNDED';
    this.balanceCents += escrow.amountCents;
    return { status: 'REFUNDED', amountCents: escrow.amountCents };
  }

  public getTelemetry() {
    return {
      availableBalanceUsd: (this.balanceCents / 100).toFixed(2),
      totalBudgetUsd: (this.maxRootBudgetCents / 100).toFixed(2),
      burnRatePercent: (((this.maxRootBudgetCents - this.balanceCents) / this.maxRootBudgetCents) * 100).toFixed(1),
      activeEscrowCount: Array.from(this.escrows.values()).filter((e) => e.status === 'PENDING').length,
    };
  }
}

Blueprint 3: Real-Time Agent Budget Telemetry Dashboard (components/economy/agent-budget-dashboard.tsx)

'use client';

import React from 'react';

interface BudgetTelemetryProps {
  telemetry: {
    availableBalanceUsd: string;
    totalBudgetUsd: string;
    burnRatePercent: string;
    activeEscrowCount: number;
  };
  agentSpendBreakdown: Array<{
    agentId: string;
    role: string;
    spentUsd: string;
    activeTasks: number;
  }>;
}

export function AgentBudgetDashboard({ telemetry, agentSpendBreakdown }: BudgetTelemetryProps) {
  const burnPercentNumber = parseFloat(telemetry.burnRatePercent);

  return (
    <div className="w-full my-4 border border-neutral-200/80 dark:border-neutral-800 rounded-xl bg-white dark:bg-neutral-900 shadow-xs overflow-hidden">
      {/* Header */}
      <div className="p-4 border-b border-neutral-100 dark:border-neutral-800 flex items-center justify-between">
        <div>
          <span className="text-[11px] font-semibold uppercase tracking-wider text-neutral-500 dark:text-neutral-400">
            Swarm Treasury & FinOps
          </span>
          <h3 className="text-base font-semibold tracking-tight text-neutral-900 dark:text-neutral-50">
            Autonomous Micro-Economy
          </h3>
        </div>
        <div className="flex items-center gap-2">
          <span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-mono font-medium bg-neutral-100 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300">
            {telemetry.activeEscrowCount} Active Escrows
          </span>
        </div>
      </div>

      {/* Primary KPI Grid */}
      <div className="p-4 grid grid-cols-1 sm:grid-cols-3 gap-3 border-b border-neutral-100 dark:border-neutral-800">
        <div className="p-3 bg-neutral-50 dark:bg-neutral-800/40 rounded-lg border border-neutral-200/60 dark:border-neutral-800">
          <span className="text-xs text-neutral-500 dark:text-neutral-400 block mb-1">Available Liquidity</span>
          <div className="text-xl font-bold font-mono tracking-tight text-neutral-900 dark:text-neutral-50 tabular-nums">
            ${telemetry.availableBalanceUsd}
          </div>
          <span className="text-[11px] text-neutral-400 dark:text-neutral-500 mt-1 block">
            Limit: ${telemetry.totalBudgetUsd}
          </span>
        </div>

        <div className="p-3 bg-neutral-50 dark:bg-neutral-800/40 rounded-lg border border-neutral-200/60 dark:border-neutral-800">
          <span className="text-xs text-neutral-500 dark:text-neutral-400 block mb-1">Budget Burn Rate</span>
          <div className="text-xl font-bold font-mono tracking-tight text-neutral-900 dark:text-neutral-50 tabular-nums">
            {telemetry.burnRatePercent}%
          </div>
          <div className="w-full bg-neutral-200 dark:bg-neutral-700 h-1.5 rounded-full mt-2 overflow-hidden">
            <div
              className={`h-full rounded-full transition-all duration-300 ${
                burnPercentNumber > 80 ? 'bg-rose-500' : burnPercentNumber > 50 ? 'bg-amber-500' : 'bg-emerald-500'
              }`}
              style={{ width: `${Math.min(burnPercentNumber, 100)}%` }}
            />
          </div>
        </div>

        <div className="p-3 bg-neutral-50 dark:bg-neutral-800/40 rounded-lg border border-neutral-200/60 dark:border-neutral-800">
          <span className="text-xs text-neutral-500 dark:text-neutral-400 block mb-1">Safety Killswitch</span>
          <div className="text-sm font-semibold text-emerald-600 dark:text-emerald-400 flex items-center gap-1.5 mt-1">
            <div className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse" />
            Active & Armed
          </div>
          <span className="text-[11px] text-neutral-400 dark:text-neutral-500 mt-1 block">
            Auto-halts on 100% budget breach
          </span>
        </div>
      </div>

      {/* Itemized Agent Spend */}
      <div className="p-4">
        <span className="text-xs font-semibold text-neutral-700 dark:text-neutral-300 block mb-2">
          Subagent Cost Allocation:
        </span>
        <div className="space-y-2">
          {agentSpendBreakdown.map((agent) => (
            <div
              key={agent.agentId}
              className="flex items-center justify-between p-2.5 rounded-lg border border-neutral-100 dark:border-neutral-800/80 bg-neutral-50/50 dark:bg-neutral-800/20 text-xs"
            >
              <div>
                <span className="font-medium text-neutral-900 dark:text-neutral-100">{agent.agentId}</span>
                <span className="text-neutral-400 dark:text-neutral-500 ml-2">({agent.role})</span>
              </div>
              <div className="flex items-center gap-3">
                <span className="text-neutral-500 dark:text-neutral-400">{agent.activeTasks} in flight</span>
                <span className="font-mono font-semibold text-neutral-900 dark:text-neutral-100 tabular-nums">
                  ${agent.spentUsd}
                </span>
              </div>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Direktif Eksekutif & Paradigma Ekonomi Agen (Pergeseran 2026)

Ketika agen AI otonom memanggil API berbayar, menjalankan web scraping skala besar, mengonsumsi inferensi model LLM, atau menugaskan agen lain, eksekusi tanpa kendali keuangan akan memicu kebocoran biaya komputasi yang fatal. Di era swarm software otonom, agen tidak lagi boleh beroperasi dengan akses kartu kredit perusahaan tanpa pagu ketat.

Arsitektur Ekonomi Mikro Agen mengubah swarm multi-agen menjadi sistem ekonomi mikro yang mampu meregulasi keuangannya sendiri. Setiap agen dibekali dompet kriptografis otonom, beroperasi dalam pagu anggaran (budget envelope) ketat, berpartisipasi dalam lelang tugas (reverse-auction bidding), dan bertransaksi dengan infrastruktur eksternal melalui protokol native HTTP 402 (Payment Required).


Integrasi Orkestrasi

  • Rel Kliring & Settlement: agentic-m2m-settlement, blockchain-web3-expert, formal-spec-z3-verifier.
  • Payment Gateway Fiat & Penagihan: doku-payment-gateway, doku-mcp-server, saas-billing, payment-gateway-expert.
  • FinOps AI & Kaskade Model: llm-finops-router, adaptive-model-cascade, thinking-budget-orchestrator.
  • Tata Kelola Swarm & Gerbang Critic: multi-agent-orchestration, quality-guardian, autonomous-tdd-debugger.
  • Siklus Hidup & Tata Kelola: brainstorming, zero-to-prod-orchestrator, session-memory-manager, anti-slop.

4 Pilar Utama Arsitektur Ekonomi Mikro Agen

  1. Hierarki Pagu Anggaran 3-Tingkat: Pagu Utama Swarm (Root Envelope), Batas Kecepatan Subagen (Velocity Limit), dan Brankas Escrow per Tugas.
  2. Implementasi Protokol HTTP 402: Penyedia layanan membalas kueri agen dengan kode status 402 dan invoice pembayaran mikro. Agen membayar melalui tanda tangan token kriptografis.
  3. Lelang Tugas Terbalik (Reverse-Auction Bidding): Sub-agen mengajukan penawaran harga dan durasi. Koordinator memilih kombinasi biaya-kualitas (cost-quality) terbaik.
  4. Pelepasan Dana Berdasarkan Kualitas (Critic Milestone Gate): Dana yang dikunci di escrow hanya dicairkan jika sub-agen auditor/critic menyetujui kualitas output (skor >= 0.85).

Standar Penegakan Anti-Slop

  1. Nol Pembengkakan Biaya (Zero Cost Hallucination): Jika saldo treasury utama habis, seluruh aktivitas subagen wajib berhenti seketika dan memicu notifikasi ke manusia.
  2. Keluaran Kode 100% Utuh: Middleware HTTP 402, brankas escrow atomik, dan antarmuka dashboard wajib dibuat lengkap tanpa placeholder // TODO.
  3. Verifikasi Bebas Cacat: Seluruh berkas wajib tervalidasi bersih melalui node scripts/check-anti-slop.js.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Expert guide for automated and manual Web Accessibility (a11y) testing — axe-core, Pa11y, Playwright a11y, screen reader testing, and WCAG 2.2 Level AA/AAA compliance / Panduan ahli pengujian aksesibilitas web.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug112Updated Oct 22, 2026

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Fast (Composer 2.5, Grok 4.7/4.6) to Medium (Gemini 4 Argon, GPT-5.6 Sol, Claude Opus 5.5) and High (Claude Sonnet 5.5, Claude Fable 5.1, Muse Wonder) / Panduan ahli untuk kaskade dan routing model cerdas.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug112Updated Oct 22, 2026

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Flash/Haiku to Sonnet/Opus/Astra, dynamic escalation with quality gates, 40-60% token cost reduction while maintaining output quality / Panduan ahli untuk kaskade dan routing model cerdas — routing tugas berbasis skor kompleksitas dari Flash/Haiku ke Sonnet/Opus/Astra, eskalasi dinamis dengan gerbang kualitas, pengurangan biaya token 40-60% dengan kualitas output terjaga.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug112Updated Oct 22, 2026

Master guide for Affective Computing, emotional AI, and real-time sentiment analysis through native multimodal tokens (voice intonation and facial micro-expressions) / Panduan utama komputasi afektif, AI emosional, dan analisis sentimen real-time melalui token multimodal native.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug112Updated Oct 22, 2026

Expert guide for Affective Computing, emotional AI, and real-time sentiment analysis through native multimodal tokens (voice intonation and facial micro-expressions) / Panduan ahli komputasi afektif, AI emosional, dan analisis sentimen real-time melalui token multimodal native.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug112Updated Oct 22, 2026

Expert guide for AI-assisted coding workflows — agentic code generation, multi-agent code swarms, self-healing CI/CD, automated PR review, spec-to-code pipelines, codebase knowledge graphs, and human-in-the-loop approval gates / Panduan ahli untuk workflow pengkodean berbasis AI — generasi kode agentic, code swarm multi-agen, CI/CD self-healing, review PR otomatis, pipeline spec-to-code, knowledge graph codebase, dan gate persetujuan human-in-the-loop.

The English summary is being prepared. Showing the original description.

roedyrustam/vibes-plug112Updated Oct 22, 2026

See all skills by roedyrustam

Report a problem with this skill