Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-18549-meetings-more-backends.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Meetings agent-backend mode now answers through `copilot` and `omp` (one tool-less CLI per call with the agents' sign-in, usage charged to the meeting), through `vllm`, `llm-d` and every named model gateway on the OpenAI-compatible path, and on hives that sign Claude in only with `HIVE_CLAUDE_OAUTH_TOKEN`; `codex`, `gemini`, watsonx and the other CLIs are refused at validation and in the Settings picker with the specific reason.
14 changes: 14 additions & 0 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,13 @@
"type": "string"
}
},
"refused_backends": {
"type": "object",
"description": "Why each known backend that cannot answer for meetings is refused",
"additionalProperties": {
"type": "string"
}
},
"agent_backends": {
"type": "array",
"items": {
Expand Down Expand Up @@ -1645,6 +1652,13 @@
"type": "string"
}
},
"refused_backends": {
"type": "object",
"description": "Why each known backend that cannot answer for meetings is refused",
"additionalProperties": {
"type": "string"
}
},
"agent_backends": {
"type": "array",
"items": {
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/hive/llmd_endpoint.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import "github.com/hivecommons/hive/pkg/config"

// defaultLLMDEndpoint is the in-cluster llm-d endpoint picker Service used when
// HIVE_LLMD_ENDPOINT is unset. The shipped Kubernetes base
// (src/deploy/k8s/deployment.yaml) sets the same value, so keep the two in
// step (llmd_endpoint_test.go).
const defaultLLMDEndpoint = "http://hive-llm-d-epp.hive-inference.svc.cluster.local:8000"
const defaultLLMDEndpoint = config.DefaultLLMDEndpoint
95 changes: 88 additions & 7 deletions src/cmd/hive/meetingswire.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"time"

"github.com/hivecommons/hive/crux"
"github.com/hivecommons/hive/crux/claude"
"github.com/hivecommons/hive/crux/keystore"
"github.com/hivecommons/hive/pkg/beads"
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/knowledge"
Expand Down Expand Up @@ -268,6 +272,13 @@ func meetingPersonaFactory(cfg *config.Config, persona config.ResolvedMeetingsPe
if persona.SearxngURL != "" {
retrievers = append(retrievers, betty.WebRetriever{BaseURL: persona.SearxngURL, Client: client})
}
// A model gateway with a private CA (its ca_bundle) gets its own client;
// one that cannot be built leaves the persona model-less, never
// unverified.
modelClient, clientErr := meetllm.HTTPClient(llm.CABundle)
if clientErr != nil && logger != nil && llm.Backend == config.MeetingsLLMModeOpenAI {
logger.Error("[meetings] persona model client not built; the persona answers without a model", "backend", llm.AgentBackend, "error", clientErr)
}
return func(mt meetings.Meeting) *betty.Engine {
var model betty.LLM
mc := meetllm.Config{
Expand All @@ -280,7 +291,9 @@ func meetingPersonaFactory(cfg *config.Config, persona config.ResolvedMeetingsPe
switch llm.Backend {
case config.MeetingsLLMModeOpenAI:
mc.Endpoint, mc.Model, mc.APIKey = llm.Endpoint, llm.Model, llm.APIKey
model = betty.MeetLLM{Client: client, Config: mc}
if clientErr == nil {
model = betty.MeetLLM{Client: modelClient, Config: mc}
}
case config.MeetingsLLMModeAnthropic:
mc.Provider, mc.Model, mc.APIKey = meetllm.ProviderAnthropic, llm.Model, llm.AnthropicKey
model = betty.MeetLLM{Client: client, Config: mc}
Expand All @@ -297,13 +310,25 @@ func meetingPersonaFactory(cfg *config.Config, persona config.ResolvedMeetingsPe
}

// meetingCLIModel is the persona's model on an agent backend
// (hivecommons/hive#18517): one warm CLI for the meeting, in the backend's
// no-tools completion profile, started now so the first question finds it
// ready. It reports false when the backend has no profile.
// (hivecommons/hive#18517, #18549), in the backend's no-tools completion
// profile with the agents' sign-in: one warm CLI for the meeting, started
// now so the first question finds it ready, on a backend with a warm mode;
// one CLI per call otherwise. It reports false when the backend has no
// profile.
func meetingCLIModel(llm config.ResolvedMeetingsLLM, mc meetllm.Config, meetingID string, logger *slog.Logger) (betty.MeetLLM, bool) {
mc.Provider, mc.Backend, mc.Model = meetllm.ProviderAgentBackend, llm.AgentBackend, llm.Model
mc.CLIBinary, mc.CLIHome, mc.RecycleTurns = llm.CLI.Binary, llm.CLI.Home, llm.CLI.RecycleTurns
mc.Timeout = time.Duration(llm.CLI.AddressedTimeoutMS) * time.Millisecond
mc.Getenv = meetingCLIGetenv(os.Getenv)
if !meetllm.SupportsWarm(llm.AgentBackend) {
if !meetllm.HasCompletionProfile(llm.AgentBackend) {
if logger != nil {
logger.Error("[meetings] persona model not started; the backend has no completion profile", "meeting", meetingID, "backend", llm.AgentBackend)
}
return betty.MeetLLM{}, false
}
return betty.MeetLLM{Config: mc}, true
}
sess, err := meetllm.NewCLISession(mc)
if err != nil {
if logger != nil {
Expand Down Expand Up @@ -334,6 +359,55 @@ func applyMeetingCLITimeouts(s *betty.Settings, cli config.ResolvedMeetingsCLI)
}
}

// meetingClaudeOperatorToken is the operator's long-lived Claude token
// (HIVE_CLAUDE_OAUTH_TOKEN), the seam tests replace.
var meetingClaudeOperatorToken = claude.OperatorToken

// meetingCopilotTokenFile is the dashboard Copilot sign-in the agents fall
// back to (a var so tests can point it elsewhere).
var meetingCopilotTokenFile = crux.CopilotUserTokenPath

// meetingCopilotToken is the Copilot sign-in the agents get:
// COPILOT_GITHUB_TOKEN, else the dashboard device-flow token read through
// the keystore.
func meetingCopilotToken(getenv func(string) string) string {
if v := strings.TrimSpace(getenv(meetllm.EnvCopilotToken)); v != "" {
return v
}
data, err := keystore.ReadFile(context.Background(), meetingCopilotTokenFile)
if err != nil {
return ""
}
return strings.TrimSpace(string(data))
}

// meetingCLIGetenv is the environment a meetings CLI reads its sign-in
// from: base, with the sign-in variables set the way the agent launcher
// sets them for agents. CLAUDE_CODE_OAUTH_TOKEN is the operator's
// long-lived token only (a hive signed in with the credentials file needs
// none), and COPILOT_GITHUB_TOKEN is the agents' Copilot token. The values
// go to the CLI's environment only: hive never logs them or writes them to
// disk.
func meetingCLIGetenv(base func(string) string) func(string) string {
return func(k string) string {
switch k {
case meetllm.EnvClaudeOAuthToken:
return meetingClaudeOperatorToken()
case meetllm.EnvCopilotToken:
return meetingCopilotToken(base)
}
return base(k)
}
}

// meetingCLISignInEnv are, per backend, the sign-in variables `hive
// meeting-llm` needs in the Spek child's environment to hand to the CLI.
var meetingCLISignInEnv = map[string][]string{
meetllm.BackendClaude: {"CLAUDE_CONFIG_DIR", meetllm.EnvClaudeOAuthToken},
meetllm.BackendCopilot: {meetllm.EnvCopilotToken, "COPILOT_GH_HOST", "GH_HOST"},
meetllm.BackendOMP: {"OMP_AUTH_BROKER_URL", "OMP_AUTH_BROKER_TOKEN"},
}

// meetingLLMSlotsDir holds the in-flight slot locks `hive meeting-llm`
// shares across meetings; the leading dot keeps it out of the meeting list.
const meetingLLMSlotsDir = ".llm-slots"
Expand Down Expand Up @@ -381,6 +455,9 @@ func meetingSpekEnv(getenv func(string) string, llm config.ResolvedMeetingsLLM,
if llm.APIKey != "" {
env = append(env, meetllm.EnvAPIKey+"="+llm.APIKey)
}
if llm.CABundle != "" {
env = append(env, meetllm.EnvCABundle+"="+llm.CABundle)
}
case config.MeetingsLLMModeAgentBackend:
// One CLI per prompt through `hive meeting-llm`, in the backend's
// completion profile, with the cold-start timeout (#18517).
Expand All @@ -402,9 +479,13 @@ func meetingSpekEnv(getenv func(string) string, llm config.ResolvedMeetingsLLM,
if llm.CLI.Home != "" {
env = append(env, meetllm.EnvCLIHome+"="+llm.CLI.Home)
}
// The CLI's config-dir override is a path, not a credential.
if v := getenv("CLAUDE_CONFIG_DIR"); v != "" {
env = append(env, "CLAUDE_CONFIG_DIR="+v)
// The CLI's sign-in, as the agents get it: a config-dir path, or a
// token, kept off argv like the API keys above.
signIn := meetingCLIGetenv(getenv)
for _, k := range meetingCLISignInEnv[llm.AgentBackend] {
if v := signIn(k); v != "" {
env = append(env, k+"="+v)
}
}
case config.MeetingsLLMModeAnthropic:
env = append(env, "SPEK_MEETING_LLM=anthropic", "ANTHROPIC_API_KEY="+llm.AnthropicKey,
Expand Down
132 changes: 132 additions & 0 deletions src/cmd/hive/meetingswire_signin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package main

import (
"log/slog"
"os"
"path/filepath"
"strings"
"testing"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/meetings"
"github.com/hivecommons/hive/pkg/meetings/meetllm"
)

// withMeetingSignIn stubs the operator Claude token and the dashboard
// Copilot token file for one test.
func withMeetingSignIn(t *testing.T, claudeToken, copilotFile string) {
t.Helper()
prevClaude, prevFile := meetingClaudeOperatorToken, meetingCopilotTokenFile
meetingClaudeOperatorToken = func() string { return claudeToken }
meetingCopilotTokenFile = copilotFile
t.Cleanup(func() { meetingClaudeOperatorToken, meetingCopilotTokenFile = prevClaude, prevFile })
}

func mapEnv(m map[string]string) func(string) string { return func(k string) string { return m[k] } }

// The meetings CLI gets the agents' sign-in: the operator's Claude token
// (never a stray CLAUDE_CODE_OAUTH_TOKEN of the hive's own), and the
// Copilot token from the environment or the dashboard sign-in file.
func TestMeetingCLIGetenv(t *testing.T) {
dir := t.TempDir()
file := filepath.Join(dir, "copilot-user-token")
if err := os.WriteFile(file, []byte("gho_file\n"), 0o600); err != nil {
t.Fatal(err)
}
withMeetingSignIn(t, "sk-ant-oat-operator", file)
get := meetingCLIGetenv(mapEnv(map[string]string{meetllm.EnvClaudeOAuthToken: "stale", "PATH": "/bin"}))
if get(meetllm.EnvClaudeOAuthToken) != "sk-ant-oat-operator" || get(meetllm.EnvCopilotToken) != "gho_file" || get("PATH") != "/bin" {
t.Fatal("sign-in overlay")
}
if got := meetingCLIGetenv(mapEnv(map[string]string{meetllm.EnvCopilotToken: " gho_env "}))(meetllm.EnvCopilotToken); got != "gho_env" {
t.Fatalf("env copilot token %q", got)
}
withMeetingSignIn(t, "", filepath.Join(dir, "absent"))
get = meetingCLIGetenv(mapEnv(map[string]string{meetllm.EnvClaudeOAuthToken: "stale"}))
if get(meetllm.EnvClaudeOAuthToken) != "" || get(meetllm.EnvCopilotToken) != "" {
t.Fatal("no sign-in configured, yet one was passed")
}
}

// Spek's `hive meeting-llm` child gets each backend's sign-in variables,
// a gateway's CA bundle, and never the hive's GitHub tokens.
func TestMeetingSpekEnvSignIn(t *testing.T) {
withMeetingSignIn(t, "sk-ant-oat-operator", filepath.Join(t.TempDir(), "absent"))
base := mapEnv(map[string]string{
"PATH": "/bin", "GH_TOKEN": "ghp_hive", "HIVE_GITHUB_TOKEN": "x", meetllm.EnvCopilotToken: "gho_x",
"OMP_AUTH_BROKER_URL": "https://broker", "OMP_AUTH_BROKER_TOKEN": "obt",
})
envOf := func(llm config.ResolvedMeetingsLLM) map[string]string {
out := map[string]string{}
for _, kv := range meetingSpekEnv(base, llm, "/hive", "/u", "/s", 0) {
k, v, _ := strings.Cut(kv, "=")
out[k] = v
}
if out["GH_TOKEN"] != "" || out["HIVE_GITHUB_TOKEN"] != "" {
t.Fatalf("hive tokens reached spek: %v", out)
}
return out
}
claudeLLM := cliLLM("", "")
if env := envOf(claudeLLM); env[meetllm.EnvClaudeOAuthToken] != "sk-ant-oat-operator" || env[meetllm.EnvCopilotToken] != "" {
t.Fatalf("claude env %v", env)
}
copilotLLM := cliLLM("", "")
copilotLLM.AgentBackend = meetllm.BackendCopilot
if env := envOf(copilotLLM); env[meetllm.EnvCopilotToken] != "gho_x" || env[meetllm.EnvClaudeOAuthToken] != "" {
t.Fatalf("copilot env %v", env)
}
ompLLM := cliLLM("", "")
ompLLM.AgentBackend = meetllm.BackendOMP
if env := envOf(ompLLM); env["OMP_AUTH_BROKER_URL"] != "https://broker" || env["OMP_AUTH_BROKER_TOKEN"] != "obt" {
t.Fatalf("omp env %v", env)
}
gw := config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeOpenAI, Endpoint: "https://gw", Model: "m", CABundle: "/ca.pem", AgentBackend: "corp-gw"}
if env := envOf(gw); env[meetllm.EnvCABundle] != "/ca.pem" || env[meetllm.EnvEndpoint] != "https://gw" {
t.Fatalf("gateway env %v", env)
}
gw.CABundle = ""
if _, ok := envOf(gw)[meetllm.EnvCABundle]; ok {
t.Fatal("empty CA bundle exported")
}
}

// On a backend with no warm mode the persona runs one CLI per call, with
// the agents' sign-in and the cold timeouts; no process starts up front.
func TestMeetingCLIModelCold(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
llm := cliLLM(filepath.Join(t.TempDir(), "copilot"), "")
llm.AgentBackend = meetllm.BackendCopilot
llm.CLI.AddressedTimeoutMS = config.DefaultMeetingsColdCLIAddressedTimeoutMS
m, ok := meetingCLIModel(llm, meetllm.Config{MaxInFlight: 1}, "m1", logger)
if !ok || m.Config.Session != nil || m.Config.Backend != meetllm.BackendCopilot || m.Config.Getenv == nil ||
m.Config.Timeout.Milliseconds() != config.DefaultMeetingsColdCLIAddressedTimeoutMS {
t.Fatalf("cold model %+v %v", m.Config, ok)
}
llm.AgentBackend = "codex"
if _, ok := meetingCLIModel(llm, meetllm.Config{}, "m2", logger); ok {
t.Fatal("codex has no profile")
}
if _, ok := meetingCLIModel(llm, meetllm.Config{}, "m3", nil); ok {
t.Fatal("codex has no profile (no logger)")
}
}

// A gateway CA bundle that cannot be read leaves the persona without a
// model instead of an unverified client.
func TestMeetingPersonaFactoryBadCABundle(t *testing.T) {
store, err := meetings.NewStore(t.TempDir())
if err != nil {
t.Fatal(err)
}
cfg := &config.Config{}
persona := cfg.Meetings.Persona.Resolve()
persona.Enabled = true
llm := config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeOpenAI, Endpoint: "https://gw", Model: "m", AgentBackend: "corp-gw",
CABundle: filepath.Join(t.TempDir(), "absent.pem"), MaxInFlight: 1}
e := meetingPersonaFactory(cfg, persona, llm, store, nil, nil, "", 0, false, slog.New(slog.DiscardHandler))(meetings.Meeting{ID: "m1"})
if e == nil {
t.Fatal("want an engine")
}
e.Close()
}
4 changes: 2 additions & 2 deletions src/docs/api-reference/knowledge.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `GET` | `/api/meetings/actions` | Owner or read-write | Drafts from meetings: `{drafts, pending}`, newest first. Each draft carries `id`, `meeting_id`, `meeting_title`, `meeting_link`, `type` (`issue`, `rfc`, `spek`, `knowledge`), `title`, `body`, `repo`, `excerpt`, `requested_by` (a meeting display name), `request`, `spoken`, `status` (`pending`, `approving`, `done`, `failed`, `rejected`), `auto_approved`, `result_url`, `result_note`, `error`, `announced` (`chat` or `notes`), `edited_by`, `decided_by`, `decided_at`, `created_at`, `updated_at`. See [Asking Betty to do things](../meetings.md#asking-betty-to-do-things) | `pkg/dashboard/api_meetings_actions.go:69` |
| `GET` | `/api/meetings/actions/settings` | Owner or read-write | `meetings.persona.actions` as set and in effect: `enabled`, `types`, `all_types`, `default_repo`, `effective_default_repo`, `repos` (the monitored repos a draft may target), `auto_approve` (per type), `auto_approvable` (`knowledge`) and `env_overrides` | `pkg/dashboard/api_meetings_actions.go:70` |
| `PUT` | `/api/meetings/actions/settings` | Owner only | Save `{enabled?, types?, default_repo?, auto_approve?}` into `meetings.persona.actions`; applies at once. 400 for an unknown type, a repo that is not `owner/repo`, or auto-approve on anything but `knowledge`. Audited as `meetings_actions_settings` | `pkg/dashboard/api_meetings_actions.go:71` |
| `GET` | `/api/meetings/model` | Owner or read-write | The meetings model as set and in effect: `mode`, `backend`, `model`, `label` (what the meeting panel shows), `modes`, `supported_backends` (backends that can answer for meetings), `agent_backends` (backends the hive's agents use), `default_backend`, `default_model`, `default_models` and `env_overrides`. See [Agent backends](../meetings.md#agent-backends) | `pkg/dashboard/api_meetings_model.go:58` |
| `PUT` | `/api/meetings/model` | Owner only | Save `{mode?, backend?, model?}` into `meetings.llm`; applies after a restart (`restart_required`). 400 for an unknown mode or a backend with no meetings completion profile. Audited as `meetings_model_settings` | `pkg/dashboard/api_meetings_model.go:59` |
| `GET` | `/api/meetings/model` | Owner or read-write | The meetings model as set and in effect: `mode`, `backend`, `model`, `label` (what the meeting panel shows), `modes`, `supported_backends` (backends that can answer for meetings, named model gateways included), `refused_backends` (why each other known backend cannot), `agent_backends` (backends the hive's agents use), `default_backend`, `default_model`, `default_models` and `env_overrides`. See [Agent backends](../meetings.md#agent-backends) | `pkg/dashboard/api_meetings_model.go:63` |
| `PUT` | `/api/meetings/model` | Owner only | Save `{mode?, backend?, model?}` into `meetings.llm`; applies after a restart (`restart_required`). 400 for an unknown mode or a backend that cannot answer for meetings, with the reason. Audited as `meetings_model_settings` | `pkg/dashboard/api_meetings_model.go:64` |
| `POST` | `/api/meetings/actions/{aid}/edit` | Owner or read-write | Change a pending or failed draft: `{type?, title?, body?, repo?}`; the repo must be a monitored one. 404 unknown, 409 already decided. Audited as `meeting_action_edit` | `pkg/dashboard/api_meetings_actions.go:72` |
| `POST` | `/api/meetings/actions/{aid}/approve` | Owner or read-write | Create the draft (issue or RFC on GitHub, Spek session through the Inbox `spek_rfc` destination, knowledge note in the `meetings` vault) and report the result to the meeting. Returns the draft, `done` with `result_url` or `failed` with `error`. 409 when it is not pending or failed, or action requests are off. Audited as `meeting_action_approve` | `pkg/dashboard/api_meetings_actions.go:73` |
| `POST` | `/api/meetings/actions/{aid}/reject` | Owner or read-write | Reject a pending or failed draft; nothing is created. Audited as `meeting_action_reject` | `pkg/dashboard/api_meetings_actions.go:74` |
Expand Down
Loading
Loading