Skip to content

Expose requestHeartbeatNow in plugin runtime API #31564

@haynzz

Description

@haynzz

Problem

Plugins (like Hermes event bridge) need to trigger a heartbeat on a specific session after enqueuing a system event. The function requestHeartbeatNow exists in core (src/infra/heartbeat-wake.ts) and already accepts { reason, sessionKey, agentId, coalesceMs }, but it is not exposed in the plugin runtime API (PluginRuntime.system).

Current Workaround

Plugins must POST to /hooks/wake via HTTP loopback, which:

  • Only wakes the main session (no sessionKey support)
  • Adds unnecessary HTTP round-trip for an in-process call
  • Cannot target a specific session

Proposed Change

Add requestHeartbeatNow to createRuntimeSystem() in src/plugins/runtime/index.ts:

function createRuntimeSystem(): PluginRuntime["system"] {
  return {
    enqueueSystemEvent,
    runCommandWithTimeout,
    formatNativeDependencyHint,
    requestHeartbeatNow,  // <-- add this
  };
}

And add the type to PluginRuntime in src/plugins/runtime/types.ts:

system: {
  enqueueSystemEvent: EnqueueSystemEvent;
  runCommandWithTimeout: RunCommandWithTimeout;
  formatNativeDependencyHint: FormatNativeDependencyHint;
  requestHeartbeatNow: typeof import("../../infra/heartbeat-wake.js").requestHeartbeatNow;
};

Use Case

Hermes event bridge plugin receives webhooks (Hive task completion, CI results) and needs to wake a specific agent session to process the event. The flow:

  1. enqueueSystemEvent(text, { sessionKey }) — already works via plugin API
  2. requestHeartbeatNow({ reason: "hook:hermes", sessionKey }) — needs this addition
  3. Heartbeat runner routes to the correct session, agent processes the event with full context

Without this, plugins either create orphan sessions (via hooks action: agent) or can only wake the main session (via /hooks/wake).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions