Documentation
¶
Overview ¶
Package registry holds two cross-cutting reference data sets used by daemon, consume, and the cobra command layer:
CatchAll: the default event_type list passed to `consume`'s Hello when --event-types is omitted. v1 (P4) ships an empty list so the consumer falls back to bus-wide catch-all; P7 fills in the curated DingTalk default set after P0 SDK verification confirms the exact event_type string values.
CompactProcessors: per-event_type formatters that flatten the SDK RawEvent into an agent-friendly map[string]any. A generic processor handles unknown types by surfacing the top-level header fields plus a parsed payload; specialised processors (im.message.* etc.) extract semantically meaningful fields.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchAllEventTypes ¶
func CatchAllEventTypes() []string
CatchAllEventTypes returns the default event-type wildcards passed in the Hello frame when `dws event consume` is invoked without --event-types.
v1 returns nil = "bus-wide catch-all" — the bus already subscribes upstream to everything the open-platform UI ticks. The Hub's matcher treats nil/empty as match-everything, so the consumer gets every event the open platform pushes without needing an explicit list.
Why we don't ship a curated default (yet): the exact event_type strings DingTalk emits over Stream are not yet confirmed by a P0 run against a real app (escape-hatch row #3). Shipping a curated list that differs by one character from what DingTalk actually sends would silently filter out events users expect to see. The bus-wide catch-all behaviour is conservative — too inclusive rather than too exclusive — and avoids that failure mode.
Known/expected event type strings (from open-platform docs; pending P0 SDK confirmation — DO NOT enable until verified):
im.message.receive_v1 receive any IM message im.message.read_v1 message read receipt im.message.reaction.created_v1 reaction added im.message.reaction.deleted_v1 reaction removed im.chat.member.bot.added_v1 bot added to a chat im.chat.member.bot.deleted_v1 bot removed from a chat im.chat.member.user.added_v1 user added to a chat im.chat.disbanded_v1 chat disbanded contact.user.created_v3 / updated / deleted contact.department.created_v3 / updated / deleted cal.event.created_v1 / updated / deleted approval.instance.status_changed approval.task.created attendance.check_v1
Once verified, switch CatchAllEventTypes to return the slice above (and document the change so users can override with --event-types '*' to regain literal "everything the open platform sends").
Types ¶
type CompactView ¶
type CompactView struct {
// Type echoes EventType for routing/filtering at the agent layer.
Type string `json:"type"`
// EventID is the SDK-assigned identifier (DataFrameHeader "eventId").
EventID string `json:"event_id,omitempty"`
// Timestamp is the event-born-time milliseconds value, surfaced under a
// shorter name agents typically expect.
Timestamp int64 `json:"timestamp,omitempty"`
// CorpID propagates the SDK's eventCorpId when present.
CorpID string `json:"corp_id,omitempty"`
// AppID propagates eventUnifiedAppId when present.
AppID string `json:"app_id,omitempty"`
// Extra holds the event-type-specific flattened fields (e.g.
// chat_id/sender_id for IM messages). Marshalled inline.
Extra map[string]any `json:"-"`
}
CompactView is the JSON-encoded shape `dws event consume --compact` writes per event. Implementations populate the common header fields then layer event-type-specific semantic fields on top via "extra".
func GenericProcessor ¶
func GenericProcessor(ev transport.Event) CompactView
GenericProcessor is the fallback used when no specialised processor is registered for the event type. It surfaces the 5 SDK header fields and tries to parse the JSON payload — on parse failure it embeds the raw payload string under "data" so nothing is lost.
func (CompactView) MarshalJSON ¶
func (v CompactView) MarshalJSON() ([]byte, error)
MarshalJSON serialises CompactView with the Extra fields lifted to the top level, dropping the wrapping "extra" key. This produces the flat map output that agents prefer.
type Processor ¶
type Processor func(ev transport.Event) CompactView
Processor transforms one Event frame into a CompactView. Implementations MUST NOT modify the input. Returning a zero CompactView is allowed and falls back to the generic processor at the caller's discretion.
func LookupProcessor ¶
LookupProcessor returns the registered processor for eventType, or GenericProcessor when no specialised one exists.