WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package im
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
// CommandAction represents a service-level side effect that a command requests.
|
||||
// Using an enum keeps commands free of service/DB dependencies—they declare intent,
|
||||
// the Service executes it.
|
||||
type CommandAction int
|
||||
|
||||
const (
|
||||
// ActionNone means no side effect beyond sending the reply.
|
||||
ActionNone CommandAction = iota
|
||||
// ActionClear soft-deletes the current ChannelSession and clears the LLM
|
||||
// context so the next message creates a completely fresh conversation.
|
||||
ActionClear
|
||||
// ActionStop cancels the in-flight QA request for this user+chat.
|
||||
ActionStop
|
||||
)
|
||||
|
||||
// CommandResult is the output produced by a Command.Execute call.
|
||||
type CommandResult struct {
|
||||
// Content is the Markdown reply sent back to the user.
|
||||
Content string
|
||||
// Action requests a service-level side effect (reset, clear, …).
|
||||
Action CommandAction
|
||||
}
|
||||
|
||||
// CommandContext carries all runtime data a command needs during execution.
|
||||
// Services are NOT here; inject them into command structs at construction time.
|
||||
type CommandContext struct {
|
||||
// Incoming is the raw IM message that triggered the command.
|
||||
Incoming *IncomingMessage
|
||||
// Session is the IM channel session for this user×chat combination.
|
||||
Session *ChannelSession
|
||||
// TenantID is the tenant that owns this bot deployment.
|
||||
TenantID uint64
|
||||
// AgentName is the display name of the bound agent (empty if none).
|
||||
AgentName string
|
||||
// CustomAgent is the bound agent configuration. Commands that need to
|
||||
// inspect agent-level settings (e.g. /search reading KBSelectionMode)
|
||||
// can access it directly. May be nil when no agent is bound.
|
||||
CustomAgent *types.CustomAgent
|
||||
// ChannelOutputMode is the channel-level output mode configured by the admin
|
||||
// ("stream" or "full").
|
||||
ChannelOutputMode string
|
||||
}
|
||||
|
||||
// Command is the interface every IM slash-command must implement.
|
||||
//
|
||||
// Design rules:
|
||||
// - Dependencies (DB, services) are injected at construction time.
|
||||
// - Validation errors (bad args, entity not found) are returned as a
|
||||
// CommandResult with a helpful message, NOT as an error.
|
||||
// - error is reserved for infrastructure failures (DB errors, network, …).
|
||||
type Command interface {
|
||||
// Name is the primary token used after "/" (e.g. "kb", "mode").
|
||||
Name() string
|
||||
// Description is the one-line summary shown in /help output.
|
||||
Description() string
|
||||
// Execute runs the command and returns a reply to send to the user.
|
||||
Execute(ctx context.Context, cmdCtx *CommandContext, args []string) (*CommandResult, error)
|
||||
}
|
||||
Reference in New Issue
Block a user