gomcp/internal/application/tools/intent_service.go
DmitrL-dev 694e32be26 refactor: rename identity to syntrex, add root orchestration and CI/CD
- Rename Go module: sentinel-community/gomcp -> syntrex/gomcp (50+ files)
- Rename npm package: sentinel-dashboard -> syntrex-dashboard
- Update Cargo.toml repository URL to syntrex/syntrex
- Update all doc references from DmitrL-dev/AISecurity to syntrex
- Add root Makefile (build-all, test-all, lint-all, clean-all)
- Add MIT LICENSE
- Add .editorconfig (Go/Rust/TS/C cross-language)
- Add .github/workflows/ci.yml (Go + Rust + Dashboard)
- Add dashboard next.config.ts and .env.example
- Clean ARCHITECTURE.md: remove brain/immune/strike/micro-swarm, fix 61->67 engines
2026-03-11 15:30:49 +10:00

52 lines
1.5 KiB
Go

// Package tools provides application-level tool services.
// This file adds the Intent Distiller MCP tool integration (DIP H0.2).
package tools
import (
"context"
"fmt"
"github.com/syntrex/gomcp/internal/domain/intent"
"github.com/syntrex/gomcp/internal/domain/vectorstore"
)
// IntentService provides MCP tool logic for intent distillation.
type IntentService struct {
distiller *intent.Distiller
embedder vectorstore.Embedder
}
// NewIntentService creates a new IntentService.
// If embedder is nil, the service will be unavailable.
func NewIntentService(embedder vectorstore.Embedder) *IntentService {
if embedder == nil {
return &IntentService{}
}
embedFn := func(ctx context.Context, text string) ([]float64, error) {
return embedder.Embed(ctx, text)
}
return &IntentService{
distiller: intent.NewDistiller(embedFn, nil),
embedder: embedder,
}
}
// IsAvailable returns true if the intent distiller is ready.
func (s *IntentService) IsAvailable() bool {
return s.distiller != nil && s.embedder != nil
}
// DistillIntentParams holds parameters for the distill_intent tool.
type DistillIntentParams struct {
Text string `json:"text"`
}
// DistillIntent performs recursive intent distillation on user text.
func (s *IntentService) DistillIntent(ctx context.Context, params DistillIntentParams) (*intent.DistillResult, error) {
if !s.IsAvailable() {
return nil, fmt.Errorf("intent distiller not available (no embedder configured)")
}
return s.distiller.Distill(ctx, params.Text)
}