Schedules leave the schedules control-plane resource for State Store tables behind a ScheduleService contract. A run is claimed per schedule slot, missed slots fire once, the next run stays on the schedule's grid, cron is read in the schedule-settings time zone, and failed runs are recorded and advance. Three failures in a row raise a schedule.failing alert. A fired run records a schedule-fired capture. Run history is pruned by age and count. Removes the chat and spawn-task runners, the dangerous-payload guard and the old schedules settings page.
137 lines
7.0 KiB
Go
137 lines
7.0 KiB
Go
package gateway
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/samcharles93/archie-core/internal/tools"
|
|
)
|
|
|
|
// DashboardPage describes one dashboard surface so the chat agent can both
|
|
// understand what each place is for and point the operator there.
|
|
type DashboardPage struct {
|
|
// Path is the route (e.g. "/tasks"). It is what the browser hash becomes.
|
|
Path string
|
|
// Label is the human name shown in navigation (e.g. "Tasks").
|
|
Label string
|
|
// Description is a one-line plain-language explanation of what the page
|
|
// shows, so the agent can answer "where do I go for that?" correctly.
|
|
Description string
|
|
}
|
|
|
|
// dashboardPages lists the dashboard pages the prompt and the
|
|
// dashboard_navigate tool can name.
|
|
var dashboardPages = []DashboardPage{
|
|
{Path: "/", Label: "Dashboard", Description: "Running work, work needing attention, token spend."},
|
|
{Path: "/tasks", Label: "Tasks", Description: "Picked-up issues and their status."},
|
|
{Path: "/account", Label: "Your account", Description: "Password, recovery code, passkeys and personal API tokens."},
|
|
{Path: "/org", Label: "Organisation", Description: "Members, identities, connections, models and automation."},
|
|
{Path: "/org/members", Label: "Members", Description: "People in the organisation and their roles."},
|
|
{Path: "/org/agents", Label: "Agents", Description: "Execution identities, their permissions and commit author."},
|
|
{Path: "/org/workspaces", Label: "Workspaces", Description: "Groups of organisation work and resources."},
|
|
{Path: "/org/policies", Label: "Policies", Description: "Access rules for the organisation."},
|
|
{Path: "/org/connections", Label: "Connections", Description: "Forge hosts, credentials and permitted operations."},
|
|
{Path: "/org/credential-bindings", Label: "Credential bindings", Description: "Service credentials granted to agent identities."},
|
|
{Path: "/org/models", Label: "Models", Description: "Organisation providers and model aliases."},
|
|
{Path: "/org/instructions", Label: "Instructions", Description: "Archie's identity, tone and standing instructions for the organisation."},
|
|
{Path: "/org/playbooks", Label: "Playbooks", Description: "Edit event-driven automation rules."},
|
|
{Path: "/settings/authentication", Label: "Authentication", Description: "Instance URL and OIDC sign-in."},
|
|
{Path: "/workflows", Label: "Workflows", Description: "Workflows and run history."},
|
|
{Path: "/settings/skills", Label: "Skills", Description: "Skills Archie can activate."},
|
|
{Path: "/settings/curators", Label: "Curators", Description: "Scheduled memory and capture curation."},
|
|
{Path: "/events", Label: "Events", Description: "Captured events, field mappings, workflow bindings."},
|
|
{Path: "/logs", Label: "Logs", Description: "Daemon log by level and component."},
|
|
{Path: "/settings/channels", Label: "Channels", Description: "Chat and notification channels."},
|
|
{Path: "/settings/status", Label: "Status", Description: "Update state, config sources, listen address."},
|
|
{Path: "/settings/appearance", Label: "Appearance", Description: "Theme, density, motion."},
|
|
{Path: "/settings/task-execution", Label: "Task execution", Description: "Statuses, operator actions, budgets."},
|
|
{Path: "/settings/models", Label: "Models", Description: "Instance model aliases and providers."},
|
|
{Path: "/org/repositories", Label: "Repositories", Description: "Watched repositories and gate overrides."},
|
|
{Path: "/settings/scheduling-policy", Label: "Scheduling policy", Description: "Work discovery and forge labels."},
|
|
{Path: "/settings/tools", Label: "Tools & MCP", Description: "Agent tools and MCP servers."},
|
|
{Path: "/settings/audit", Label: "Audit", Description: "Settings, access, identity and runtime events."},
|
|
{Path: "/settings/plugins", Label: "Plugins", Description: "Extension directories loaded at startup."},
|
|
{Path: "/settings/secret-engines", Label: "Secret engines"},
|
|
{Path: "/settings/container-runtime", Label: "Container runtime"},
|
|
{Path: "/settings/harness", Label: "Harness", Description: "OAuth credential bindings and setup terminal."},
|
|
}
|
|
|
|
// DashboardPages returns a copy of the dashboard page registry.
|
|
func DashboardPages() []DashboardPage {
|
|
out := make([]DashboardPage, len(dashboardPages))
|
|
copy(out, dashboardPages)
|
|
return out
|
|
}
|
|
|
|
// PageIndexResult is what page_index returns: the full list of dashboard pages
|
|
// and what each one shows, so the agent can answer where to go.
|
|
type PageIndexResult struct {
|
|
Pages []DashboardPage `json:"pages"`
|
|
ProductGuide string `json:"product_guide"`
|
|
}
|
|
|
|
// pageIndexTool returns the tool that lists every dashboard page. It is only
|
|
// registered for the web channel (see PageIndexTools), because pointing a
|
|
// non-web operator at an internal dashboard route is meaningless.
|
|
func pageIndexTool() (tools.ToolEntry, bool) {
|
|
entry := tools.ToolEntry{
|
|
Name: "page_index",
|
|
Toolset: "dashboard",
|
|
Description: "List every dashboard page, what it shows, and built-in guidance for creating workflows and using Archie. Use it to tell the operator where to go for something rather than guessing.",
|
|
Classification: tools.ClassIdempotent,
|
|
Handler: func(_ context.Context, _ map[string]any) (any, error) {
|
|
return PageIndexResult{Pages: DashboardPages(), ProductGuide: productGuide}, nil
|
|
},
|
|
}
|
|
return entry, true
|
|
}
|
|
|
|
// dashboardNavigateTool resolves a page path and returns the navigation the UI
|
|
// can follow. It validates against the registry and refuses an unknown route
|
|
// rather than guessing, so a chip is only ever produced for a real page.
|
|
func dashboardNavigateTool() (tools.ToolEntry, bool) {
|
|
entry := tools.ToolEntry{
|
|
Name: "dashboard_navigate",
|
|
Toolset: "dashboard",
|
|
Description: "Point the operator at a dashboard page. Pass the page path (e.g. /tasks). Returns the page to navigate to; the web chat renders it as a clickable chip. Never guess a path, look it up with page_index first.",
|
|
Classification: tools.ClassIdempotent,
|
|
Schema: tools.JSONSchema{
|
|
"type": "object",
|
|
"properties": map[string]any{
|
|
"path": map[string]any{
|
|
"type": "string",
|
|
"description": "The dashboard route to navigate to, e.g. /tasks. Must match a page_index entry.",
|
|
},
|
|
},
|
|
"required": []any{"path"},
|
|
},
|
|
Handler: func(_ context.Context, input map[string]any) (any, error) {
|
|
path := strings.TrimSpace(asString(input["path"]))
|
|
if path == "" {
|
|
return nil, errors.New("dashboard_navigate: path is required")
|
|
}
|
|
for _, p := range dashboardPages {
|
|
if p.Path == path {
|
|
return DashboardNavigateResult{Path: p.Path, Label: p.Label}, nil
|
|
}
|
|
}
|
|
return nil, fmt.Errorf("dashboard_navigate: unknown page %s", path)
|
|
},
|
|
}
|
|
return entry, true
|
|
}
|
|
|
|
// PageIndexTools returns the dashboard tools for a channel. Only the web UI
|
|
// has a dashboard (and only the web chat sends a Current page), so a non-web
|
|
// channel (e.g. telegram) gets none.
|
|
func PageIndexTools(channel string) []tools.ToolEntry {
|
|
if !strings.EqualFold(channel, "web") {
|
|
return nil
|
|
}
|
|
pageIndex, _ := pageIndexTool()
|
|
navigate, _ := dashboardNavigateTool()
|
|
return []tools.ToolEntry{pageIndex, navigate}
|
|
}
|