Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Align Docker host query schema and executor

rcourtmane008343b7a3c
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 08b0f07ac5..570eb559ec 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5699,6 +5699,12 @@ and the independently declared expected-finding resource as separate resolved
identities; an expected resource may differ only when the manifest declared it
as related before execution. V1 replay artifacts retain target-as-expected
semantics.
+The canonical `pulse_query` schema and executor must admit the same resource
+types. In particular, `action=get` accepts `docker-host`, returns a governed
+read-only host response when the identity resolves, and returns a successful
+typed `not_found` result when it does not; a model following the advertised
+schema must not incur a failed tool call because the executor used a narrower
+legacy type switch.
Persisted Patrol tool inputs must retain complete structured finding calls up
to the bounded 16 KiB record limit so normal evidence-rich findings remain
deterministically replayable. If any captured input is nevertheless incomplete
diff --git a/internal/ai/tools/data_types.go b/internal/ai/tools/data_types.go
index fd311eec6f..ffb9fdf8df 100644
--- a/internal/ai/tools/data_types.go
+++ b/internal/ai/tools/data_types.go
@@ -659,7 +659,7 @@ type TopologySummary struct {
// ResourceResponse is returned by pulse_get_resource
type ResourceResponse struct {
GovernedResourceMetadata
- Type string `json:"type"` // "agent", "vm", "system-container", "app-container", "storage"
+ Type string `json:"type"` // "agent", "vm", "system-container", "app-container", "docker-host", "storage"
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
diff --git a/internal/ai/tools/tools_query.go b/internal/ai/tools/tools_query.go
index 7950e960d4..bfe3204700 100644
--- a/internal/ai/tools/tools_query.go
+++ b/internal/ai/tools/tools_query.go
@@ -4826,6 +4826,51 @@ func (e *PulseToolExecutor) executeGetResource(_ context.Context, args map[strin
"type": "agent",
}), nil
+ case "docker-host":
+ for _, host := range rs.DockerHosts() {
+ if host == nil || !matchesCanonicalResourceReference(
+ unifiedresources.Resource{}, resourceID, host.ID(), host.HostSourceID(), host.Hostname(), host.Name(), host.DisplayName(),
+ ) {
+ continue
+ }
+ hostID := firstNonEmptyString(host.HostSourceID(), host.ID())
+ hostName := firstNonEmptyString(host.Hostname(), host.Name(), host.DisplayName())
+ displayName := firstNonEmptyString(host.Name(), host.DisplayName(), hostName)
+ response := EmptyResourceResponse()
+ response.GovernedResourceMetadata = governance.Resolve(host.Hostname(), host.Name(), host.DisplayName(), host.HostSourceID(), host.ID())
+ response.Type = "docker-host"
+ response.ID = hostID
+ response.Name = displayName
+ response.Status = string(host.Status())
+ response.Platform = "docker"
+ response.Host = hostName
+ response.OS = strings.TrimSpace(host.OS())
+ response.CPU = ResourceCPU{Percent: host.CPUPercent(), Cores: host.CPUs()}
+ response.Memory = ResourceMemory{
+ Percent: host.MemoryPercent(),
+ UsedGB: float64(host.MemoryUsed()) / (1024 * 1024 * 1024),
+ TotalGB: float64(host.MemoryTotal()) / (1024 * 1024 * 1024),
+ }
+ response.Tags = host.Tags()
+ e.registerResolvedResourceWithExplicitAccess(ResourceRegistration{
+ Kind: "docker-host",
+ ProviderUID: hostID,
+ Name: displayName,
+ Aliases: appendUniqueStrings(nil, displayName, hostID, hostName, host.ID()),
+ HostUID: hostID,
+ HostName: hostName,
+ LocationChain: []string{"docker-host:" + hostName},
+ Executors: []ExecutorRegistration{{
+ ExecutorID: hostName,
+ Adapter: "direct",
+ Actions: readOnlyResourceActions(),
+ Priority: 10,
+ }},
+ })
+ return NewJSONResult(response.NormalizeCollections()), nil
+ }
+ return notFoundResourceResult("docker-host", resourceID), nil
+
case "storage":
if e.unifiedResourceProvider != nil {
for _, resource := range canonicalStoragePoolResources(e.unifiedResourceProvider) {
@@ -5078,7 +5123,7 @@ func (e *PulseToolExecutor) executeGetResource(_ context.Context, args map[strin
}), nil
default:
- return NewErrorResult(fmt.Errorf("invalid resource_type: %s. Use 'agent', 'vm', 'system-container', 'app-container', or 'storage' (compatibility aliases 'system' and 'storage-pool' are also accepted)", resourceTypeRaw)), nil
+ return NewErrorResult(fmt.Errorf("invalid resource_type: %s. Use 'agent', 'vm', 'system-container', 'app-container', 'docker-host', or 'storage' (compatibility aliases 'system' and 'storage-pool' are also accepted)", resourceTypeRaw)), nil
}
}
diff --git a/internal/ai/tools/tools_query_test.go b/internal/ai/tools/tools_query_test.go
index 9b9d0dec5f..75d4410a51 100644
--- a/internal/ai/tools/tools_query_test.go
+++ b/internal/ai/tools/tools_query_test.go
@@ -1803,6 +1803,9 @@ func TestExecuteGetResourceErrorsAndContainer(t *testing.T) {
Containers: []models.Container{
{ID: "ct1", VMID: 200, Name: "ct1", Status: "running", Node: "node1"},
},
+ DockerHosts: []models.DockerHost{
+ {ID: "docker-source-1", Hostname: "docker-1", DisplayName: "Docker 1", Status: "online", OS: "linux", CPUs: 4},
+ },
}}
result, _ = executor.executeGetResource(context.Background(), map[string]interface{}{
@@ -1817,6 +1820,26 @@ func TestExecuteGetResourceErrorsAndContainer(t *testing.T) {
t.Fatalf("unexpected container response: %+v", res)
}
+ result, _ = executor.executeGetResource(context.Background(), map[string]interface{}{
+ "resource_type": "docker-host",
+ "resource_id": "docker-1",
+ })
+ res = ResourceResponse{}
+ if err := json.Unmarshal([]byte(result.Content[0].Text), &res); err != nil {
+ t.Fatalf("decode Docker host response: %v", err)
+ }
+ if result.IsError || res.Type != "docker-host" || res.ID != "docker-source-1" || res.Name != "Docker 1" || res.Host != "docker-1" {
+ t.Fatalf("unexpected Docker host response: error=%v response=%+v", result.IsError, res)
+ }
+
+ result, _ = executor.executeGetResource(context.Background(), map[string]interface{}{
+ "resource_type": "docker-host",
+ "resource_id": "missing",
+ })
+ if result.IsError || !strings.Contains(result.Content[0].Text, `"error":"not_found"`) {
+ t.Fatalf("missing Docker host must be a successful not-found query: %+v", result)
+ }
+
result, _ = executor.executeGetResource(context.Background(), map[string]interface{}{
"resource_type": "vm",
"resource_id": "999",