99 lines
3.2 KiB
Go
99 lines
3.2 KiB
Go
package chat
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"chat-agent-system/internal/ctxmgr"
|
|
"chat-agent-system/internal/taskrun"
|
|
)
|
|
|
|
// ChatMemory is the chat-owned port for authorized memory recall.
|
|
// Implementations are wired at the app composition root; chat must not import app/*.
|
|
type ChatMemory interface {
|
|
SearchMemory(ctx context.Context, userID int64, q MemoryQuery) ([]ctxmgr.RecalledMemoryItem, error)
|
|
}
|
|
|
|
// MemoryQuery is the chat-side memory search input.
|
|
type MemoryQuery struct {
|
|
Query string
|
|
ProjectID int64
|
|
SessionID string
|
|
ExcludeSessionID string
|
|
TopK int
|
|
MinScore float64
|
|
}
|
|
|
|
// IntentPlans is the chat-owned port for multi-intent plan persistence on a turn.
|
|
type IntentPlans interface {
|
|
HandleTurn(ctx context.Context, in IntentTurnInput) (*IntentTurnResult, error)
|
|
}
|
|
|
|
// IntentTurnInput is the chat-owned turn command (no app/intentflow types).
|
|
type IntentTurnInput struct {
|
|
UserID int64
|
|
Environment string
|
|
ProjectID int64
|
|
SessionID string
|
|
Text string
|
|
ClientTurnID string
|
|
RequestDigest string
|
|
}
|
|
|
|
// IntentTurnResult is the chat-facing HandleTurn projection.
|
|
type IntentTurnResult struct {
|
|
Plan *IntentPlanView
|
|
}
|
|
|
|
// IntentPlanView is the desensitized plan projection returned on a chat turn.
|
|
// JSON field names match the prior intentflow.PlanView envelope.
|
|
type IntentPlanView struct {
|
|
PlanID string `json:"plan_id"`
|
|
Revision int64 `json:"revision"`
|
|
Status string `json:"status"`
|
|
ExecutionMode string `json:"execution_mode"`
|
|
ExpiresAt time.Time `json:"expires_at,omitempty"`
|
|
Steps []IntentStepView `json:"steps,omitempty"`
|
|
SafeSummary string `json:"safe_summary,omitempty"`
|
|
}
|
|
|
|
// IntentStepView is one desensitized step in IntentPlanView.
|
|
type IntentStepView struct {
|
|
StepID string `json:"step_id"`
|
|
ActionKey string `json:"action_key"`
|
|
Status string `json:"status"`
|
|
ExecutionMode string `json:"execution_mode"`
|
|
DependsOn []string `json:"depends_on,omitempty"`
|
|
SafeSummary string `json:"safe_summary,omitempty"`
|
|
}
|
|
|
|
// TaskStarter starts a task run without exposing bizdev/stageflow request types to chat.
|
|
type TaskStarter interface {
|
|
CreateAndStart(ctx context.Context, runID string, record *taskrun.RunRecord, start TaskStartRequest, resumeDir string) (*taskrun.RunRecord, error)
|
|
BindAssistantMsgID(ctx context.Context, runID string, assistantMsgID int64) error
|
|
}
|
|
|
|
// TaskStartRequest carries the chat-owned fields needed to start or resume a run.
|
|
type TaskStartRequest struct {
|
|
TaskKey string
|
|
ProjectName string
|
|
UserID int64
|
|
ProjectID int64
|
|
SessionID string
|
|
}
|
|
|
|
// ReopenRequestView is the chat-facing projection of a stage reopen request.
|
|
type ReopenRequestView struct {
|
|
ID int64
|
|
DocTasks []string
|
|
Reason string
|
|
Status string
|
|
}
|
|
|
|
// ReopenService is the chat port for Approver-first document reopen.
|
|
type ReopenService interface {
|
|
ListPendingReopens(ctx context.Context, projectID int64) ([]ReopenRequestView, error)
|
|
RequestReopenByDoc(ctx context.Context, projectID int64, taskKey, reason string, userID int64) (ReopenRequestView, error)
|
|
ApproveReopenByID(ctx context.Context, projectID, requestID, userID int64) (ReopenRequestView, error)
|
|
}
|