Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

21.1 KB
Raw Blame
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "model-hub/agent-supply.schema.json",
  "title": "AgentSupply",
  "description": "Per-backend Gateway configuration and live supply projection. It exposes explicit Source order, menu metadata, model-supply state, and enabled named-Agent attribution from the shared effective route planner.",
  "type": "object",
  "required": ["backend", "mode", "menu_kind"],
  "additionalProperties": false,
  "properties": {
    "backend": { "enum": ["claude", "codex", "opencode", "vibey"] },
    "cli_present": {
      "type": "boolean",
      "description": "Server-authoritative fact that this backend's configured CLI executable is present on the Avibe host. It does not prove login, process readiness, or Source health. OPTIONAL in the reusable schema and REQUIRED on AgentSupply API payloads."
    },
    "mode": {
      "enum": ["hub", "direct"],
      "description": "Gateway or Direct. Existing installations start Direct until the user switches; fresh installations default Gateway. A native_cli Source is one configured Gateway hop and is distinct from Direct mode."
    },
    "menu_kind": { "enum": ["fixed", "open"] },
    "catalog_models": {
      "type": "array",
      "description": "The ordered backend Agent model catalog. It controls the Agent menu and capability metadata only; Route configuration remains in routes.",
      "items": { "$ref": "backend-model.schema.json" }
    },
    "selected_by_agent": {
      "type": ["string", "null"],
      "description": "The Vibe Agent whose explicit `model` produced `selected_model_id`, by name. Model selection does not live at the backend grain: several enabled Vibe Agents can share one backend and each carry a different model. Derived, never persisted; null while mode=direct or when no routed Agent is projected.",
      "examples": ["pm", "evm-contract-audit"]
    },
    "selected_model_id": {
      "type": ["string", "null"],
      "description": "The selected model of the route named by `selected_by_agent`, in the caller-facing menu identifier namespace. It is the routed Vibe Agent's explicit model, never a backend-wide fallback. A different Agent on the same backend may request a different model on its next turn. null in direct mode or when no routed Agent is projected. OPTIONAL here and required at the API boundary.",
      "examples": ["claude-opus-4-6", "zhipuai/glm-5.2"]
    },
    "selected_model_explicit": { "type": "boolean", "description": "TRUE iff `selected_model_id` originates from the user's explicit configuration request; FALSE means no explicit model selection, including a resolver-picked value or no selected model." },
    "sources": {
      "type": ["object", "null"],
      "description": "This backend's default Gateway Source membership and priority. The shared planner uses this order only when a model has no manual override. No second persisted policy discriminator exists. It is non-null in Gateway mode and null in Direct mode.",
      "required": ["order"],
      "additionalProperties": false,
      "properties": {
        "order": {
          "type": "array",
          "description": "Configured Source ids, position 0 first. A subset, not a permutation: configuration-ineligible Sources or Sources the user removed are absent. The server re-echoes the full canonical order after mutation; clients never compute a partial reorder. Source creation appends eligible defaults once; effective routing consumes the latest saved order. Manual overrides may reference eligible Sources outside this subset.",
          "items": { "type": "string", "pattern": "^src_[a-z0-9]{8,}$" },
          "uniqueItems": true
        },
        "eligibility": {
          "type": ["array", "null"],
          "description": "Server-authoritative configuration eligibility, one row per existing Source. It makes UI eligibility a projection rather than a second compatibility matrix. `in_current_model_chain` reports whether the selected model's effective Route references the Source; `process_availability_reason` reports native CLI readiness independently of Source health. Required and non-null whenever sources is an object.",
          "items": {
            "type": "object",
            "required": ["source_id", "eligible"],
            "additionalProperties": false,
            "allOf": [
              {
                "$comment": "Final v5: `eligible: false` implies the sole non-null reason key and `eligible: true` implies null. The only configuration-ineligible case is a native subscription outside its sanctioned backend. The converse prevents an unavailable label on an eligible Source.",
                "if": {
                  "properties": { "eligible": { "const": false } },
                  "required": ["eligible"]
                },
                "then": {
                  "required": ["reason_key"],
                  "properties": {
                    "reason_key": {
                      "enum": [
                        "models.eligibility.subscription_wrong_client"
                      ]
                    }
                  }
                }
              },
              {
                "if": {
                  "properties": { "eligible": { "const": true } },
                  "required": ["eligible"]
                },
                "then": {
                  "properties": {
                    "reason_key": { "type": "null" }
                  }
                }
              }
            ],
            "properties": {
              "source_id": { "type": "string", "pattern": "^src_[a-z0-9]{8,}$" },
              "eligible": { "type": "boolean" },
              "reason_key": {
                "enum": [
                  "models.eligibility.subscription_wrong_client",
                  null
                ],
                "description": "Closed i18n-key vocabulary explaining native subscription use outside its sanctioned backend. Required and non-null when `eligible` is false, null when it is true. Hub-held Sources are cross-backend eligible. A new cause requires the authority registry, contract, and locale consumers to change together."
              },
              "in_current_model_chain": {
                "type": ["boolean", "null"],
                "description": "Whether the selected model's effective Route references this Source. true includes blocked hops because availability does not rewrite configuration; false keeps non-members visible; null exactly when selected_model_id is null."
              },
              "process_availability_reason": {
                "enum": ["native_cli_unavailable", null],
                "$comment": "Owner-approved channel class pass, evidence at master 05f72ae5: core/handlers/model_hub/service.py:469-483 computes the per-backend unavailable native source set independently of source health, and service.py:1843-1891 already computes that set beside the complete eligibility inventory but emits neither fact. This bare token is the AgentSupply spelling of mirror row M8. It is legal only for a native_cli Source at the API assembly boundary; hub is definitionally process-available and therefore null.",
                "description": "Resolve-time serving-process availability for this source on this backend. `native_cli_unavailable` means this process cannot launch the sanctioned CLI under its own login right now; null means no process blocker. This does not restate source-global health. OPTIONAL here and REQUIRED at the API boundary with the serializer."
              }
            }
          }
        }
      }
    },
    "routes": {
      "type": ["object", "null"],
      "description": "Canonical sparse manual overrides keyed by caller-facing canonical menu ids. Output contains only nonempty arrays, preserving exact stale and dormant overrides. Valid empty configuration/input values normalize to key absence and inherited routing; validate supported raw config before normalization, not against this output-only minimum. Nonempty equal-to-automatic saves remain manual. Restore or empty PUT deletes the key. New catalog rows receive no key; normalization never removes catalog identities.",
      "additionalProperties": {
        "type": "object",
        "required": ["hops"],
        "additionalProperties": false,
        "properties": {
          "cache_ttl": {
            "enum": ["5m", "30m", "1h", null],
            "description": "Optional route-wide C-9 cache lifetime override; unset uses the built-in estimate."
          },
          "hops": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": ["source_id", "model_id"],
              "additionalProperties": false,
              "properties": {
                "source_id": { "type": "string", "pattern": "^src_[a-z0-9]{8,}$" },
                "model_id": { "type": "string", "minLength": 1 }
              }
            }
          }
        }
      }
    },
    "supply_status": {
      "type": ["string", "null"],
      "enum": ["ok", "degraded", "waiting", "interrupted", null],
      "$comment": "This rollup is process-aware, not health-only. A process-unavailable native hop makes a no-runnable chain interrupted rather than waiting.",
      "description": "Derived supply rollup (spec §4.5), computed per request and never persisted, for the model of the route named by `selected_by_agent`. It reads the same complete runnability predicate as AgentChain: source-global health permits AND no live connection backoff applies AND this process can serve the channel. ok = serving from the intended head; degraded = serving through fallback and/or with blocked members; waiting = no runnable member and every member is a Source cooldown or live connection backoff that is process-available; interrupted = no runnable member and at least one blocker needs action — including a native CLI unavailable in this process at any health — or the capability chain is empty. null when mode=direct or when Hub has no pinned selection."
    },
    "menu": {
      "type": ["object", "null"],
      "description": "open-menu backends only (frame V4 05r).",
      "required": ["view", "checked"],
      "additionalProperties": false,
      "properties": {
        "view": { "enum": ["featured", "full"] },
        "checked": {
          "type": "array",
          "description": "Bare canonical model identifiers, stored exactly as the backend emits them.",
          "items": { "type": "string", "minLength": 1, "pattern": "^\\S(?:[\\s\\S]*\\S)?$" },
          "uniqueItems": true
        }
      }
    },
    "model_supply": {
      "type": ["array", "null"],
      "description": "Per-menu-item effective Route summary so the model menu can flag an empty chain without one chain query per row. Read-only projection; the authoritative chain is GET /api/models/agents/<backend>/chain.",
      "items": {
        "type": "object",
        "required": ["model_id", "chain_length", "route_origin"],
        "additionalProperties": false,
        "properties": {
          "model_id": {
            "type": "string",
            "description": "The exact canonical identifier this backend's menu uses."
          },
          "route_origin": {
            "enum": ["automatic", "manual", "passthrough", null],
            "description": "Shared planner origin, independent of transient health. Passthrough uses Hub API-key defaults only; subscriptions remain subject to known-model admission. Null exactly when chain_length is zero."
          },
          "chain_length": {
            "type": "integer",
            "minimum": 0,
            "$comment": "Configuration visibility is not candidate availability. Every effective hop remains counted regardless of live runnability.",
            "description": "Length of the effective Route chain, including cooling, live-connection-backoff, and process-unavailable native CLI hops. It is not a count of currently runnable candidates. Zero marks a structurally empty Route; live blockers appear through supply_status."
          },
          "has_runnable_hop": {
            "type": "boolean",
            "description": "True exactly when at least one exact effective hop is runnable under the same source-health AND process-availability axiom as AgentChain. False distinguishes an all-stale or empty Route from a Route with live supply without changing chain_length. OPTIONAL in the reusable schema and REQUIRED on AgentSupply API payloads."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": { "chain_length": { "const": 0 } },
              "required": ["chain_length"]
            },
            "then": {
              "properties": { "has_runnable_hop": { "const": false }, "route_origin": { "type": "null" } }
            },
            "else": {
              "properties": { "route_origin": { "enum": ["automatic", "manual", "passthrough"] } }
            }
          }
        ]
      }
    },
    "named_agents": {
      "type": "array",
      "description": "Read-only projection of every enabled named Vibe Agent on this backend, derived live from each Agent's explicit model. The distinct name avoids collision with SupplyGap.agents, whose items are bare names inside a mutation-refusal payload.",
      "items": {
        "type": "object",
        "required": ["name", "effective_model_id", "supply_status", "route_reason"],
        "additionalProperties": false,
        "properties": {
          "name": { "type": "string", "minLength": 1 },
          "effective_model_id": {
            "type": ["string", "null"],
            "description": "The Agent's explicit model in the caller-facing menu identifier namespace. null means the Agent has no explicit model."
          },
          "supply_status": {
            "enum": ["ok", "degraded", "waiting", "interrupted", null],
            "description": "This named Agent's own live rollup for effective_model_id. null in Direct mode or when effective_model_id is null."
          },
          "route_reason": {
            "enum": ["route_unconfigured", null],
            "description": "Why this Agent has no usable route before Source health is considered. route_unconfigured means the selected model has no configured hops; null covers configured routes, Direct mode, and Agents without an explicit model."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": { "effective_model_id": { "type": "null" } },
              "required": ["effective_model_id"]
            },
            "then": {
              "required": ["supply_status"],
              "properties": { "supply_status": { "type": "null" } }
            }
          }
        ]
      }
    },
    "builtin_models": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Compatibility projection for older clients. New clients consume catalog_models." }
  },
  "allOf": [
    {
      "$comment": "Direct mode has no Gateway execution projection. Menu metadata remains available so switching modes is reversible, while Source order, supply state, and chain summaries are null.",
      "if": { "properties": { "mode": { "const": "direct" } }, "required": ["mode"] },
      "then": {
        "properties": {
          "selected_model_id": { "type": "null" },
          "selected_by_agent": { "type": "null" },
          "sources": { "type": "null" },
          "routes": { "type": "null" },
          "supply_status": { "type": "null" },
          "model_supply": { "type": "null" },
          "named_agents": {
            "items": {
              "required": ["supply_status", "route_reason"],
              "properties": {
                "supply_status": { "type": "null" },
                "route_reason": { "type": "null" }
              }
            }
          }
        }
      }
    },
    {
      "$comment": "Gateway mode exposes non-null Source, model-supply, and named-Agent projections. Selection fields may remain null when no routed Agent is projected.",
      "if": { "properties": { "mode": { "const": "hub" } }, "required": ["mode"] },
      "then": {
        "properties": {
          "sources": { "type": "object" },
          "routes": { "type": "object" },
          "model_supply": { "type": "array" },
          "named_agents": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "if": {
                    "properties": { "effective_model_id": { "type": "string" } },
                    "required": ["effective_model_id"]
                  },
                  "then": {
                    "required": ["supply_status"],
                    "properties": {
                      "supply_status": {
                        "enum": ["ok", "degraded", "waiting", "interrupted"]
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      }
    },
    {
      "$comment": "v3 D-1: a missing Hub selection is honest absence, never a projected builtin_models[0]. The route remains usable because a turn carries its own requested model.",
      "if": {
        "properties": { "selected_model_id": { "type": "null" } },
        "required": ["selected_model_id"]
      },
      "then": {
        "required": ["selected_by_agent", "supply_status"],
        "properties": {
          "selected_by_agent": { "type": "null" },
          "supply_status": { "type": "null" }
        }
      }
    },
    {
      "if": {
        "properties": { "selected_model_explicit": { "const": true } },
        "required": ["selected_model_explicit"]
      },
      "then": {
        "required": ["mode", "selected_model_id"],
        "properties": {
          "mode": { "const": "hub" },
          "selected_model_id": { "type": "string" }
        }
      }
    },
    {
      "if": {
        "properties": { "selected_model_id": { "type": "string" } },
        "required": ["selected_model_id"]
      },
      "then": {
        "required": ["supply_status"],
        "properties": {
          "mode": { "const": "hub" },
          "supply_status": {
            "enum": ["ok", "degraded", "waiting", "interrupted"]
          }
        }
      }
    },
    {
      "$comment": "Fixed-menu backends expose their built-in model catalog; open-menu state is null.",
      "if": { "properties": { "menu_kind": { "const": "fixed" } }, "required": ["menu_kind"] },
      "then": {
        "properties": {
          "menu": { "type": "null" }
        }
      }
    },
    {
      "if": { "properties": { "menu_kind": { "const": "open" } }, "required": ["menu_kind"] },
      "then": {
        "properties": {
          "builtin_models": { "type": "null" }
        }
      }
    },
    {
      "$comment": "v2 (07-29, review round 4): menu shape is a property of the BACKEND, not a free choice — spec §4.2 names them one by one (open menus i.e. OpenCode; fixed menus i.e. Claude Code and Codex). Pinned so the pairing cannot drift per payload; a new backend joining the enum is a contract change that comes here to declare which kind it is.",
      "if": { "properties": { "backend": { "const": "opencode" } }, "required": ["backend"] },
      "then": { "properties": { "menu_kind": { "const": "open" } } }
    },
    {
      "if": { "properties": { "backend": { "enum": ["claude", "codex", "vibey"] } }, "required": ["backend"] },
      "then": { "properties": { "menu_kind": { "const": "fixed" } } }
    },
    {
      "if": { "properties": { "backend": { "const": "vibey" } }, "required": ["backend"] },
      "then": { "properties": { "mode": { "const": "hub" }, "cli_present": { "const": false } } }
    },
    {
      "$comment": "BackendModel has no discriminator, so the containing catalog owns native_protocol presence.",
      "if": { "properties": { "backend": { "const": "opencode" } }, "required": ["backend"] },
      "then": {
        "properties": {
          "catalog_models": {
            "items": {
              "allOf": [
                { "$ref": "backend-model.schema.json" },
                { "required": ["native_protocol"] }
              ]
            }
          }
        }
      },
      "else": {
        "properties": {
          "catalog_models": {
            "items": {
              "allOf": [
                { "$ref": "backend-model.schema.json" },
                { "not": { "required": ["native_protocol"] } }
              ]
            }
          }
        }
      }
    },
    {
      "$comment": "A non-null sources object always carries a real eligibility array. The API guard enforces one row per existing Source and requires every id in order to have eligible=true; draft-07 cannot compare the two arrays directly.",
      "if": { "properties": { "sources": { "type": "object" } }, "required": ["sources"] },
      "then": {
        "properties": {
          "sources": {
            "required": ["eligibility"],
            "properties": {
              "eligibility": { "type": "array" }
            }
          }
        }
      }
    }
  ],
  "examples": [
    {
      "backend": "claude",
      "mode": "hub",
      "menu_kind": "fixed",
      "menu": null,
      "builtin_models": ["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5"]
    },
    {
      "backend": "opencode",
      "mode": "hub",
      "menu_kind": "open",
      "menu": { "view": "featured", "checked": ["claude-opus-4-6", "gpt-5.6", "glm-5.2", "glm-5.2-air"] },
      "builtin_models": null
    }
  ]
}