Skip to content

Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.

14.2 KB
Raw Blame
{
  "openapi": "3.1.0",
  "info": {
    "title": "HiRoute Decision API",
    "version": "1.0.0",
    "description": "Current v1: extension-owned category/group decisions and optional observation-only assessment of a preceding actual stage."
  },
  "servers": [
    {
      "url": "https://classifier.example",
      "description": "Example only; HiRoute posts to the configured complete endpoint."
    }
  ],
  "paths": {
    "/v1/decisions": {
      "post": {
        "operationId": "decideAgentTurn",
        "summary": "Decide the current task and optionally assess a preceding stage",
        "description": "Every new user turn decides again. Tool continuations inherit only while same-turn history is continuous and the frozen decision remains reusable. Custom branches require a published category; a dual-group scope requires regular or primary. A single-group category ignores group. No model IDs, judgment prompts, rubric or routing thresholds cross this boundary. Missing/invalid group preserves a valid category and uses primary; invalid optional assessment is discarded independently, as is assessment when the new category differs from preceding_stage.category. Return strict JSON, no duplicate or unknown fields, at most 64 KiB.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClassifierRequest"
              },
              "examples": {
                "smart_saving": {
                  "value": {
                    "latest_user": [
                      {
                        "kind": "text",
                        "text": "把这段说明改成三条清晰的要点。"
                      }
                    ],
                    "visible_conversation": [],
                    "history_partial": false,
                    "route": {
                      "kind": "smart_saving",
                      "groups": [
                        "regular",
                        "primary"
                      ]
                    },
                    "preceding_stage": null
                  }
                },
                "writing_review": {
                  "value": {
                    "latest_user": [
                      {
                        "kind": "text",
                        "text": "请逐项核对这篇稿件的来源与因果论断,给出审稿意见。"
                      }
                    ],
                    "visible_conversation": [
                      {
                        "user": [
                          {
                            "kind": "text",
                            "text": "检查这篇文章的事实和因果论断。"
                          }
                        ],
                        "status": "completed",
                        "steps": [
                          [
                            {
                              "kind": "text",
                              "text": "已完成审稿,但遗漏了没有证据支持的因果断言。"
                            }
                          ]
                        ]
                      }
                    ],
                    "history_partial": false,
                    "route": {
                      "kind": "branches",
                      "categories": [
                        {
                          "id": "writing",
                          "condition": "撰写、续写或改写文章,包括根据反馈修稿。",
                          "groups": [
                            "regular",
                            "primary"
                          ]
                        },
                        {
                          "id": "review",
                          "condition": "审阅、核实文章并提出意见,不直接重写全文。",
                          "groups": [
                            "regular",
                            "primary"
                          ]
                        }
                      ],
                      "default_category": "writing"
                    },
                    "preceding_stage": {
                      "from": 0,
                      "category": "review",
                      "group": "regular",
                      "complete": true
                    }
                  }
                },
                "single_group_category": {
                  "value": {
                    "latest_user": [
                      {
                        "kind": "text",
                        "text": "请逐项核对这篇稿件的来源与因果论断,给出审稿意见。"
                      }
                    ],
                    "visible_conversation": [],
                    "history_partial": false,
                    "route": {
                      "kind": "branches",
                      "categories": [
                        {
                          "id": "writing",
                          "condition": "撰写、续写或改写文章,包括根据反馈修稿。",
                          "groups": [
                            "regular",
                            "primary"
                          ]
                        },
                        {
                          "id": "review",
                          "condition": "审阅、核实文章并提出意见,不直接重写全文。",
                          "groups": [
                            "regular"
                          ]
                        }
                      ],
                      "default_category": "writing"
                    },
                    "preceding_stage": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision with optional prior-stage assessment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClassifierResponse"
                },
                "examples": {
                  "smart_saving": {
                    "value": {
                      "group": "regular"
                    }
                  },
                  "writing_review": {
                    "value": {
                      "group": "primary",
                      "category": "review",
                      "assessment": {
                        "score": 0.35,
                        "partial": false
                      },
                      "reason": "Previous review stage needs primary protection"
                    }
                  },
                  "single_group_category": {
                    "value": {
                      "group": "regular",
                      "category": "review"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Route": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "groups"
            ],
            "properties": {
              "kind": {
                "const": "smart_saving"
              },
              "groups": {
                "const": [
                  "regular",
                  "primary"
                ]
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "categories",
              "default_category"
            ],
            "properties": {
              "kind": {
                "const": "branches"
              },
              "categories": {
                "type": "array",
                "minItems": 2,
                "maxItems": 16,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "condition",
                    "groups"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "condition": {
                      "type": "string",
                      "minLength": 1
                    },
                    "groups": {
                      "enum": [
                        [
                          "regular"
                        ],
                        [
                          "regular",
                          "primary"
                        ]
                      ]
                    }
                  }
                }
              },
              "default_category": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              }
            }
          }
        ]
      },
      "ContentPart": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "text"
            ],
            "properties": {
              "kind": {
                "const": "text"
              },
              "text": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "source_kind"
            ],
            "properties": {
              "kind": {
                "const": "unavailable"
              },
              "source_kind": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              }
            }
          }
        ]
      },
      "StepPart": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ContentPart"
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "tool",
              "status"
            ],
            "properties": {
              "kind": {
                "const": "tool_activity"
              },
              "tool": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "status": {
                "enum": [
                  "completed",
                  "failed",
                  "unknown"
                ]
              }
            }
          }
        ]
      },
      "VisibleTurn": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "user",
          "status",
          "steps"
        ],
        "properties": {
          "user": {
            "type": "array",
            "minItems": 0,
            "items": {
              "$ref": "#/components/schemas/ContentPart"
            }
          },
          "status": {
            "enum": [
              "completed",
              "failed",
              "interrupted",
              "unknown"
            ]
          },
          "steps": {
            "type": "array",
            "minItems": 0,
            "items": {
              "type": "array",
              "minItems": 0,
              "items": {
                "$ref": "#/components/schemas/StepPart"
              }
            }
          }
        }
      },
      "PrecedingStage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "from",
          "category",
          "group",
          "complete"
        ],
        "properties": {
          "from": {
            "type": "integer",
            "minimum": 0,
            "description": "Index in visible_conversation; the suffix is one actual preceding stage."
          },
          "category": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "group": {
            "enum": [
              "regular",
              "primary"
            ]
          },
          "complete": {
            "type": "boolean"
          }
        }
      },
      "Assessment": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "score",
          "partial"
        ],
        "properties": {
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "partial": {
            "type": "boolean"
          }
        }
      },
      "ClassifierRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "route",
          "latest_user",
          "visible_conversation",
          "history_partial",
          "preceding_stage"
        ],
        "properties": {
          "route": {
            "$ref": "#/components/schemas/Route"
          },
          "latest_user": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/ContentPart"
            }
          },
          "visible_conversation": {
            "type": "array",
            "minItems": 0,
            "items": {
              "$ref": "#/components/schemas/VisibleTurn"
            }
          },
          "history_partial": {
            "type": "boolean"
          },
          "preceding_stage": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/PrecedingStage"
              }
            ]
          }
        }
      },
      "ClassifierResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {
          "category": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "group": {
            "enum": [
              "regular",
              "primary"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1024
          },
          "assessment": {
            "$ref": "#/components/schemas/Assessment"
          }
        }
      }
    }
  }
}