tools: add scope column for capability model
Add a 'scope' TEXT column (default 'homelab') to the tools table so tools can be namespaced by scope (e.g. "homelab:restart", "datacenter:reboot"). Backward-compat: bare name defaults to "homelab" scope. Changes: - Migration #1: ALTER TABLE tools ADD COLUMN scope - store.Tool: add Scope field, update all SQL and scanTool() - ipc.Tool DTO and request types: add Scope field - CoreAPI interface: pass scope in ProposeTool/EnableTool - storeAPI adapters: forward scope - cmd/mavend/voice: pass scope (empty → homelab) - cmd/mavweb/tools: show scope column in UI tables, hidden fields - All tests updated for scope field - Migration test made dynamic (startVer = len(migrations))
This commit is contained in:
@@ -39,7 +39,7 @@ import (
|
||||
type API interface {
|
||||
LookupTool(ctx context.Context, name string) (ipc.Tool, error)
|
||||
ListTools(ctx context.Context, status string) ([]ipc.Tool, error)
|
||||
ProposeTool(ctx context.Context, name, utterance string, ts time.Time) (bool, error)
|
||||
ProposeTool(ctx context.Context, name, utterance, scope string, ts time.Time) (bool, error)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -29,7 +29,7 @@ func (f fakeAPI) ListTools(_ context.Context, status string) ([]ipc.Tool, error)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
func (f fakeAPI) ProposeTool(_ context.Context, _, _ string, _ time.Time) (bool, error) {
|
||||
func (f fakeAPI) ProposeTool(_ context.Context, _, _, _ string, _ time.Time) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ func (f fakeAPI) ProposeTool(_ context.Context, _, _ string, _ time.Time) (bool,
|
||||
// destructive needs confirm, and args land as argv (no shell) after the prefix.
|
||||
func TestExec(t *testing.T) {
|
||||
api := fakeAPI{tools: map[string]ipc.Tool{
|
||||
"restart": {Name: "restart", Cmd: []string{"systemctl", "restart"}, Status: "enabled"},
|
||||
"drop": {Name: "drop", Cmd: []string{"dropdb"}, Destructive: true, Status: "enabled"},
|
||||
"draft": {Name: "draft", Cmd: []string{"x"}, Status: "proposed"},
|
||||
"restart": {Name: "restart", Scope: "homelab", Cmd: []string{"systemctl", "restart"}, Status: "enabled"},
|
||||
"drop": {Name: "drop", Scope: "homelab", Cmd: []string{"dropdb"}, Destructive: true, Status: "enabled"},
|
||||
"draft": {Name: "draft", Scope: "homelab", Cmd: []string{"x"}, Status: "proposed"},
|
||||
}}
|
||||
|
||||
var gotArgv []string
|
||||
|
||||
Reference in New Issue
Block a user