Skip to content

Gateway

Gateway हे Triggerfish चे central control plane आहे -- एक long-running local service जे sessions, channels, tools, events आणि agent processes एकाच WebSocket endpoint द्वारे coordinate करते. Triggerfish मध्ये जे काही होते ते Gateway द्वारे वाहते.

आर्किटेक्चर

Gateway architecture: channels on the left connect through the central Gateway to services on the right

Gateway configurable port (default 18789) वर listen करते आणि channel adapters, CLI commands, companion apps आणि internal services कडून connections स्वीकारते. सर्व communication WebSocket वर JSON-RPC वापरते.

Gateway Services

Gateway आपल्या WebSocket आणि HTTP endpoints द्वारे हे services प्रदान करते:

Serviceवर्णनSecurity Integration
Sessionsतयार करा, यादी करा, history retrieve करा, sessions मध्ये पाठवा, background tasks spawn कराSession taint per-session tracked
ChannelsMessages route करा, connections व्यवस्थापित करा, failed deliveries retry करासर्व output वर Classification checks
Cronआवर्ती tasks schedule करा आणि TRIGGER.md मधून trigger wakeupsCron actions policy hooks मधून जातात
WebhooksPOST /webhooks/:sourceId द्वारे बाह्य services कडून येणारे events स्वीकाराInbound data ingestion वर classified
RippleChannels मध्ये online status आणि typing indicators track कराकोणताही संवेदनशील data exposed नाही
ConfigRestart शिवाय settings hot-reload कराEnterprise मध्ये Admin-only
Control UIGateway health आणि management साठी Web dashboardToken-authenticated
Tide PoolAgent-driven A2UI visual workspace host कराContent output hooks च्या अधीन
NotificationsPriority routing सह cross-channel notification deliveryClassification rules लागू होतात

WebSocket JSON-RPC Protocol

Clients WebSocket वर Gateway शी connect होतात आणि JSON-RPC 2.0 messages exchange करतात.

typescript
// Client sends:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sessions.list",
  "params": { "filter": "active" }
}

// Gateway responds:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    { "id": "sess_abc", "taint": "CONFIDENTIAL", "channel": "telegram" },
    { "id": "sess_def", "taint": "PUBLIC", "channel": "cli" }
  ]
}

Authentication

Gateway connections token सह authenticated आहेत. Token setup (triggerfish dive) दरम्यान तयार केला जातो आणि स्थानिकरित्या संग्रहित केला जातो.

SECURITY Gateway default वर 127.0.0.1 ला bind होते आणि network ला

exposed नाही. Remote access साठी explicit tunnel configuration आवश्यक आहे. कधीही Gateway WebSocket authentication शिवाय public internet ला expose करू नका. :::

Session व्यवस्थापन

Gateway sessions चे पूर्ण lifecycle व्यवस्थापित करते. Sessions हे conversation state चे fundamental unit आहेत, प्रत्येकात स्वतंत्र taint tracking आहे.

Session Types

TypeKey Patternवर्णन
MainmainOwner सह primary direct conversation. Restarts मध्ये persist होते.
Channelchannel:<type>:<id>प्रत्येक connected channel साठी एक. Channel नुसार isolated taint.
Backgroundbg:<task_id>Cron jobs आणि webhook-triggered tasks साठी spawned. PUBLIC taint ने सुरू.
Agentagent:<agent_id>Multi-agent routing साठी per-agent sessions.
Groupgroup:<channel>:<group_id>Group chat sessions.

Session Tools

एजंट Gateway द्वारे routed सर्व, या tools द्वारे sessions शी संवाद साधतो:

Toolवर्णनTaint Implications
sessions_listऐच्छिक filters सह active sessions यादी कराTaint बदल नाही
sessions_historySession साठी transcript retrieve कराReferenced session मधून Taint inherit होते
sessions_sendदुसऱ्या session ला message पाठवाWrite-down check च्या अधीन
sessions_spawnBackground task session तयार करानवीन session PUBLIC taint ने सुरू होते
session_statusवर्तमान session state, model, cost तपासाTaint बदल नाही

Channel Routing

Gateway channel router द्वारे channels आणि sessions मध्ये messages route करते:

  • Classification gate: प्रत्येक outbound message delivery पूर्वी PRE_OUTPUT मधून जातो
  • Retry with backoff: Failed deliveries sendWithRetry() द्वारे exponential backoff सह retry केल्या जातात
  • Message chunking: मोठे messages platform-appropriate chunks मध्ये split केले जातात
  • Streaming: Responses channels ला stream होतात जे ते support करतात

Notification Service

Gateway प्लॅटफॉर्मवर ad-hoc "notify owner" patterns replace करणारी first-class notification service integrate करते.

Priority Routing

Priorityवर्तन
CRITICALQuiet hours bypass करा, लगेच सर्व connected channels ला deliver करा
HIGHPreferred channel ला लगेच deliver करा, offline असल्यास queue करा
NORMALActive session ला deliver करा, किंवा next session start साठी queue
LOWQueue करा, active sessions दरम्यान batches मध्ये deliver करा

Notification Sources

SourceCategoryDefault Priority
Policy violationssecurityCRITICAL
Threat intelligence alertssecurityCRITICAL
Skill approval requestsapprovalHIGH
Cron job failuressystemHIGH
System health warningssystemHIGH
Webhook event triggersinfoNORMAL
The Reef updates availableinfoLOW

Delivery Preferences

वापरकर्ते per-channel notification preferences configure करतात:

yaml
notifications:
  preferred_channel: telegram
  quiet_hours:
    start: "22:00"
    end: "07:00"
    timezone: "America/Chicago"
  overrides:
    security: all_channels
    approval: preferred_channel
    info: active_session

Scheduler Integration

Gateway scheduler service host करते, जे व्यवस्थापित करते:

  • Cron tick loop: Scheduled tasks चे periodic evaluation
  • Trigger wakeups: TRIGGER.md मध्ये defined agent wakeups
  • Webhook HTTP endpoints: येणाऱ्या events साठी POST /webhooks/:sourceId

Cron-triggered आणि webhook-triggered tasks fresh PUBLIC taint सह

background sessions spawn करतात. ते कोणत्याही existing session चे taint inherit करत नाहीत. :::

Health आणि Diagnostics

triggerfish patrol कमांड Gateway शी connect होते आणि diagnostic health checks चालवते, verify करते:

  • Gateway चालू आहे आणि responsive आहे
  • सर्व configured channels connected आहेत
  • Storage accessible आहे
  • Scheduled tasks वेळेत execute होत आहेत
  • Queue मध्ये कोणत्याही undelivered critical notifications stuck नाहीत