kimicode

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package kimicode provides complete typed views over native Kimi Code CLI hook payloads. The unified layer in the root package is convenience; this typed native layer is the fidelity guarantee: every struct captures unrecognized JSON keys in Extra, so provider drift never drops data.

Structs are maintained against the Kimi Code hooks documentation with golden fixtures (DESIGN.md §10).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	SessionID     string `json:"session_id"`
	CWD           string `json:"cwd"`
	HookEventName string `json:"hook_event_name"`
}

Base carries the fields every Kimi hook payload includes.

type InterruptInput

type InterruptInput struct {
	Base
	Extra map[string]json.RawMessage `json:"-"`
}

InterruptInput is the native Interrupt payload (user Esc, not timeouts).

func Interrupt

func Interrupt(e *agenthooks.Event) (*InterruptInput, bool)

type NotificationInput

type NotificationInput struct {
	Base
	Sink             string                     `json:"sink"`
	NotificationType string                     `json:"notification_type"` // e.g. "task.completed"
	Title            string                     `json:"title"`
	Body             string                     `json:"body"`
	Severity         string                     `json:"severity"`
	Extra            map[string]json.RawMessage `json:"-"`
}

NotificationInput is the native Notification payload.

func Notification

func Notification(e *agenthooks.Event) (*NotificationInput, bool)

type PermissionInput

type PermissionInput struct {
	Base
	ToolName  string                     `json:"tool_name"`
	ToolInput json.RawMessage            `json:"tool_input"`
	Extra     map[string]json.RawMessage `json:"-"`
}

PermissionInput is the native PermissionRequest / PermissionResult payload. Both are observation-only on Kimi.

func PermissionRequest

func PermissionRequest(e *agenthooks.Event) (*PermissionInput, bool)

func PermissionResult

func PermissionResult(e *agenthooks.Event) (*PermissionInput, bool)

type PostCompactInput

type PostCompactInput struct {
	Base
	Trigger             string                     `json:"trigger"`
	EstimatedTokenCount int64                      `json:"estimated_token_count"`
	Extra               map[string]json.RawMessage `json:"-"`
}

PostCompactInput is the native PostCompact payload.

func PostCompact

func PostCompact(e *agenthooks.Event) (*PostCompactInput, bool)

type PostToolUseFailureInput

type PostToolUseFailureInput struct {
	Base
	ToolName   string                     `json:"tool_name"`
	ToolInput  json.RawMessage            `json:"tool_input"`
	Error      string                     `json:"error"`
	ToolCallID string                     `json:"tool_call_id"` // absent on hook-blocked calls (kimi-code 0.22.2)
	Extra      map[string]json.RawMessage `json:"-"`
}

PostToolUseFailureInput is the native PostToolUseFailure payload.

func PostToolUseFailure

func PostToolUseFailure(e *agenthooks.Event) (*PostToolUseFailureInput, bool)

type PostToolUseInput

type PostToolUseInput struct {
	Base
	ToolName   string                     `json:"tool_name"`
	ToolInput  json.RawMessage            `json:"tool_input"`
	ToolOutput json.RawMessage            `json:"tool_output"`
	ToolCallID string                     `json:"tool_call_id"` // observed on kimi-code 0.22.2 (undocumented)
	Extra      map[string]json.RawMessage `json:"-"`
}

PostToolUseInput is the native PostToolUse payload.

func PostToolUse

func PostToolUse(e *agenthooks.Event) (*PostToolUseInput, bool)

type PreCompactInput

type PreCompactInput struct {
	Base
	Trigger    string                     `json:"trigger"` // "manual" | "auto"
	TokenCount int64                      `json:"token_count"`
	Extra      map[string]json.RawMessage `json:"-"`
}

PreCompactInput is the native PreCompact payload.

func PreCompact

func PreCompact(e *agenthooks.Event) (*PreCompactInput, bool)

type PreToolUseInput

type PreToolUseInput struct {
	Base
	ToolName   string                     `json:"tool_name"`
	ToolInput  json.RawMessage            `json:"tool_input"`
	ToolCallID string                     `json:"tool_call_id"`
	Extra      map[string]json.RawMessage `json:"-"`
}

PreToolUseInput is the native PreToolUse payload.

func PreToolUse

func PreToolUse(e *agenthooks.Event) (*PreToolUseInput, bool)

type SessionEndInput

type SessionEndInput struct {
	Base
	Reason string                     `json:"reason"`
	Extra  map[string]json.RawMessage `json:"-"`
}

SessionEndInput is the native SessionEnd payload.

func SessionEnd

func SessionEnd(e *agenthooks.Event) (*SessionEndInput, bool)

type SessionStartInput

type SessionStartInput struct {
	Base
	Source string                     `json:"source"` // "startup" | "resume"
	Extra  map[string]json.RawMessage `json:"-"`
}

SessionStartInput is the native SessionStart payload.

func SessionStart

func SessionStart(e *agenthooks.Event) (*SessionStartInput, bool)

type StopFailureInput

type StopFailureInput struct {
	Base
	ErrorType    string                     `json:"error_type"`
	ErrorMessage string                     `json:"error_message"`
	Extra        map[string]json.RawMessage `json:"-"`
}

StopFailureInput is the native StopFailure payload.

func StopFailure

func StopFailure(e *agenthooks.Event) (*StopFailureInput, bool)

type StopInput

type StopInput struct {
	Base
	StopHookActive bool                       `json:"stop_hook_active"`
	Extra          map[string]json.RawMessage `json:"-"`
}

StopInput is the native Stop payload.

func Stop

func Stop(e *agenthooks.Event) (*StopInput, bool)

type SubagentStartInput

type SubagentStartInput struct {
	Base
	AgentName string                     `json:"agent_name"`
	Prompt    string                     `json:"prompt"`
	Extra     map[string]json.RawMessage `json:"-"`
}

SubagentStartInput is the native SubagentStart payload.

func SubagentStart

func SubagentStart(e *agenthooks.Event) (*SubagentStartInput, bool)

type SubagentStopInput

type SubagentStopInput struct {
	Base
	AgentName string                     `json:"agent_name"`
	Response  string                     `json:"response"`
	Extra     map[string]json.RawMessage `json:"-"`
}

SubagentStopInput is the native SubagentStop payload.

func SubagentStop

func SubagentStop(e *agenthooks.Event) (*SubagentStopInput, bool)

type UserPromptSubmitInput

type UserPromptSubmitInput struct {
	Base
	Prompt string                     `json:"prompt"`
	Extra  map[string]json.RawMessage `json:"-"`
}

UserPromptSubmitInput is the native UserPromptSubmit payload.

func UserPromptSubmit

func UserPromptSubmit(e *agenthooks.Event) (*UserPromptSubmitInput, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL