@nightowlsdev/engine-trigger-chat
EngineAdapter, reduced governanceThe Trigger.dev chat.agent remote adapter engine, renders a deployed chat.agent Session as a Night Owls agent. Adapter tier: reduced governance, tier-2 events (tool calls visible, no delegation); durable park/resume on the Trigger runtime.
What it does
@nightowlsdev/engine-trigger-chat is a protocol ADAPTER over a deployed Trigger.dev `chat.agent`, the `chat.agent` loop runs inside the CUSTOMER'S OWN Trigger.dev task, so it renders that remote Session as a single Night Owls agent rather than executing in-process. `triggerChatEngine({ taskId, secretKey?, baseURL?, triggerConfig?, modelId? })` starts/resumes a Session over `@trigger.dev/sdk` and maps its wire, which IS the AI-SDK `UIMessageChunk` stream, onto `SwarmEvent`s, so unlike the opaque `engine-a2a` (tier 1), tool_call/tool_result ARE visible here: `events.tier: 2`. Its capability descriptor is honest about the reduced-governance adapter tier: `kind: 'adapter'`, `governance` all `false`/`'none'` (our pre-generation reserve, fail-closed tool gate, and cost kill-switch physically cannot reach a loop running inside someone else's deployed task), and `hitl.approval` relays the REMOTE's own per-tool `needsApproval` rather than enforcing our own gate. `hitl.durableResume` is STATICALLY `true`, a Trigger Session/run is durable and resumable by `externalId`/`runId` on Trigger's own runtime (parked across process death/redeploys), independent of our storage. `swarm.usage` fires zero-or-more times per segment (best-effort, only when the host's wire attaches `messageMetadata` on its `finish` chunk); `swarm.turn_usage` still fires exactly once, aggregating whatever usage events were seen. Requires Node >= 22. Reads `TRIGGER_SECRET_KEY` from the environment by default. Ships a `nightOwlsPlugin` manifest so `owl install engine-trigger-chat` wires `defineSwarm({ engine: triggerChatEngine({ taskId: 'my-chat-agent' }) })`.
Install
pnpm add @nightowlsdev/engine-trigger-chatKey exports
- triggerChatEngine
- TriggerChatEngine
- TRIGGER_CHAT_ENGINE_CAPABILITIES
- createTriggerSessionTransport
- createChunkMapper / extractUsageFromMessageMetadata / mapControlEvent
- nightOwlsPlugin
Usage
import { defineSwarm } from "@nightowlsdev/core";
import { triggerChatEngine, TRIGGER_CHAT_ENGINE_CAPABILITIES } from "@nightowlsdev/engine-trigger-chat";
// An ADAPTER over a deployed Trigger.dev chat.agent Session, the loop runs on YOUR Trigger task;
// this renders it as one Night Owls agent. Reads TRIGGER_SECRET_KEY from the env by default.
const swarm = defineSwarm({ agents, engine: triggerChatEngine({ taskId: "my-chat-agent" }) });
// Durable by the REMOTE (Trigger's own runtime), not by our storage, always true, no `durable` flag.
console.log(TRIGGER_CHAT_ENGINE_CAPABILITIES.hitl.durableResume); // true (static)