MCP / OpenAPI

LLM・AIエージェントから、同じ OEE を。

工場長診断も What-if も、REST と同じ計算です。チャットに数字を貼る代わりに、ツールとして呼んでください。 外部 LLM に計算を任せる実装ではありません。 人が仕様を読むほか、チートシートを AI エージェントに渡してコードや運用手順を書かせる使い方も想定しています。

デモで試す

AI Agent チートシート

下の契約(チートシート)をコピーしてエージェントに渡し、「やりたいこと」を自然文で依頼します。キー文字列は含めないでください。

  1. チートシートをコピー アコーディオンを開き「コピー」で全文を取得します(または /llms-api.txt)。
  2. エージェントに読み込ませる IDE や AIエージェントのルール・プロンプト・会話に貼ります。
  3. やりたいことを伝える 例: 「ショット OEE を取る Python を書いて」「不良ゼロの What-if を curl で」。
  4. キーは見せない 環境変数 LONGHORN_API_KEY 等で渡し、チャット・ログ・コミットに平文キーを出さない。
エージェント向けチートシートを開く/閉じる

英語ベース(エージェントが解釈しやすい形)。正式版は /llms-api.txt

# Longhorn OEE Analysis Web API — LLM / Agent cheat sheet

> For coding assistants and ops agents (Cursor, OpenClaw-style runners, ChatGPT Actions, etc.).
> Human docs: https://longhorn.956.jp/mcp
> OpenAPI 3: https://longhorn.956.jp/openapi.yaml
> Product overview: https://longhorn.956.jp/llms.txt

## What this API is

- **Base URL:** `https://longhorn.956.jp`
- **Style:** HTTPS JSON REST + MCP JSON-RPC (`POST /mcp`)
- **Auth:** `Authorization: Bearer <LONGHORN_API_KEY>`, or `X-API-KEY`, or JSON/query `api_key`
- **Demo key:** `956-LONGHORN-DEMO-xyz-abc` — calculates only; does **not** persist history
- **Computes on Longhorn:** OEE + 工場長診断 (`diagnosis.engine: foreman`). Do **not** re-derive OEE in the LLM.
- **Not this API:** Studio UI login, personal kiosk tokens (`/kiosk/TOKEN`), billing

Do **not** invent endpoints beyond `openapi.yaml`. Do **not** print/commit/share real API keys.

## Issue a key (human step)

1. Sign up / sign in → Studio → API key (or use the demo key for calculate-only trials)
2. Store secret in the agent/runtime vault; never paste plaintext keys into chats or commits

## Endpoints (copy-paste ready)

### Shot (live OEE) — 1 API call
```http
POST /api/v1/oee/oee_shot
Content-Type: application/json
Authorization: Bearer LONGHORN_API_KEY

{
  "keyword": "鋳造ライン",
  "oee_parameters": {
    "planned_production_time_sec": 36000,
    "planned_downtime_sec": 1800,
    "loss_time_sec": 30,
    "ideal_cycle_time_sec": 30,
    "total_count": 1000,
    "defect_count": 20
  }
}
```

### Set (period OEE) — API calls = number of days
```http
POST /api/v1/oee/oee_set
Content-Type: application/json
Authorization: Bearer LONGHORN_API_KEY

{
  "keyword": "鋳造ライン",
  "daily_data": [
    {
      "date": "2026-09-01",
      "planned_production_time_sec": 36000,
      "planned_downtime_sec": 1800,
      "loss_time_sec": 30,
      "ideal_cycle_time_sec": 30,
      "total_count": 1000,
      "defect_count": 20
    }
  ]
}
```

### What-if (no history) — max 8 scenarios
```http
POST /api/v1/oee/oee_whatif
Content-Type: application/json
Authorization: Bearer LONGHORN_API_KEY

{
  "oee_parameters": {
    "planned_production_time_sec": 36000,
    "planned_downtime_sec": 1800,
    "loss_time_sec": 30,
    "ideal_cycle_time_sec": 30,
    "total_count": 1000,
    "defect_count": 20
  },
  "scenarios": [
    { "preset": "zero_defects" },
    { "preset": "zero_stops" },
    { "preset": "cut_defects_10pct" },
    { "preset": "cycle_minus_5pct" }
  ]
}
```
Presets: `zero_defects`, `zero_stops` (zero stop time **and** recover units), `cut_defects_10pct`, `cycle_minus_5pct`.
Omitting `scenarios` uses those four defaults.

### Retrieve shot history (not for demo key)
```http
GET /api/v1/oee/retrieve_shot?count=50
Authorization: Bearer LONGHORN_API_KEY
```

### MCP tool call (same math as REST)
```http
POST /mcp
Content-Type: application/json
Authorization: Bearer LONGHORN_API_KEY

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "oee_shot",
    "arguments": {
      "keyword": "鋳造ライン",
      "planned_production_time_sec": 36000,
      "planned_downtime_sec": 1800,
      "loss_time_sec": 30,
      "ideal_cycle_time_sec": 30,
      "total_count": 1000,
      "defect_count": 20
    }
  }
}
```
MCP tools: `oee_shot`, `oee_set`, `oee_whatif`, `oee_retrieve_shot`.

## curl examples

```bash
export LONGHORN_API_KEY='956-LONGHORN-DEMO-xyz-abc'
export LONGHORN_BASE='https://longhorn.956.jp'

curl -sS -H "Authorization: Bearer $LONGHORN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"oee_parameters":{"planned_production_time_sec":36000,"planned_downtime_sec":1800,"loss_time_sec":30,"ideal_cycle_time_sec":30,"total_count":1000,"defect_count":20}}' \
  "$LONGHORN_BASE/api/v1/oee/oee_shot"
```

## Response fields agents should use

- **OEE:** `oee_result.oee`, `.availability`, `.performance`, `.quality` (or equivalent nested keys in set aggregates)
- **診断:** `diagnosis` — deterministic 工場長診断; treat `primary_loss` / levers as authoritative; expand in Japanese, do not contradict
- **What-if:** `baseline` + `scenarios[]` with assumed OEE
- **Billing:** shot = 1 call; set = 1 call per day in `daily_data`

## Agent playbooks

### Live line OEE now
1. `POST /api/v1/oee/oee_shot` with current counters
2. Read `oee_result` + `diagnosis`
3. Optionally open kiosk scoreboard for humans (`/kiosk` demo)

### Period review / weekly report
1. Build `daily_data[]` with `date`
2. `POST /api/v1/oee/oee_set`
3. Use aggregate + per-day trends; Studio 「ChatGPTに評価を依頼」 is optional interpretation only

### “What if defects/stops improve?”
1. Same shot inputs → `POST /api/v1/oee/oee_whatif`
2. Prefer presets; for `zero_stops` explain recovered units are added (stops alone without units hurts Performance)

### Wire Claude / Cursor as tools
1. Register remote MCP URL `https://longhorn.956.jp/mcp` with Bearer header
2. Or paste this cheat sheet / OpenAPI into the agent and generate REST clients

### Health check
1. Shot with demo key → expect 200 + `success` / OEE numbers
2. 401 → bad key; demo key must not be used for retrieve/history

## Safety rules for agents

- Never invent write/admin endpoints
- Never claim the LLM calculated OEE — Longhorn did
- Redact keys in logs; prefer env `LONGHORN_API_KEY`
- Demo key: calculate only, no retrieve history
- Do not treat `/studio` or `/kiosk/<token>` as public API docs

## Related URLs

- OpenAPI: https://longhorn.956.jp/openapi.yaml
- MCP docs: https://longhorn.956.jp/mcp
- Overview: https://longhorn.956.jp/llms.txt
- Demo simulator: https://longhorn.956.jp/pages/simulator
- Sign-up: https://longhorn.956.jp/users/sign_up

正式URL: http://longhorn.956.jp/llms-api.txt ·

💡 詳細は下の「やりたいこと」も参照してください。機械可読仕様は /openapi.yaml、 エージェント全文は /llms-api.txt です。

やりたいこと一覧

できること(提供中)を一覧にしています。項目を選ぶと呼び出し方までジャンプします。

算出・連携(提供中)

接続の基本

ベースURL: https://longhorn.956.jp

認証: Authorization: Bearer YOUR_API_KEY、 X-API-KEY、または JSON / クエリの api_key

デモキー 956-LONGHORN-DEMO-xyz-abc は算出のみで履歴に残りません。

  1. サインアップ後、Studio で API キーを発行する(またはデモキーで試算)
  2. キーを安全な場所に保存する
  3. リクエストに Bearer / X-API-KEY を付ける
📄 仕様ファイル: OpenAPI 3 · エージェント全文: llms-api.txt

ライブ OEE(ショット)を取る 提供中

こんなときに — 今のラインの OEE と工場長診断をすぐ知りたい。

呼び出し

POST /api/v1/oee/oee_shot
Authorization: Bearer $LONGHORN_API_KEY
Content-Type: application/json

{ "oee_parameters": { "planned_production_time_sec": 36000, "planned_downtime_sec": 1800, "loss_time_sec": 30, "ideal_cycle_time_sec": 30, "total_count": 1000, "defect_count": 20 } }
Steps

手順

  1. 現在のカウンタを oee_parameters に入れる
  2. oee_result と diagnosis を読む(1 API コール)
  3. 必要ならライン横スコアボード(デモ /kiosk)で人向け表示

期間 OEE(セット)を取る 提供中

こんなときに — 週次・月次の推移と工場長診断で改善評価したい。

呼び出し

POST /api/v1/oee/oee_set
Authorization: Bearer $LONGHORN_API_KEY

{ "daily_data": [ { "date": "2026-09-01", "planned_production_time_sec": 36000, "…": "…" } ] }
💡 API コール数は daily_data の日数分。Studio の評価依頼ボタンは解釈用で、計算は Longhorn 側です。

改善仮定(What-if)を試す 提供中

こんなときに — 不良ゼロやサイクル短縮で OEE が何 pt 動くか知りたい。

呼び出し

POST /api/v1/oee/oee_whatif
Authorization: Bearer $LONGHORN_API_KEY

{ "oee_parameters": { … }, "scenarios": [ { "preset": "zero_defects" }, { "preset": "zero_stops" } ] }
💡 履歴非保存。最大 8 シナリオ。プリセット: zero_defects / zero_stops(停止ゼロ+回収生産)/ cut_defects_10pct / cycle_minus_5pct。

LLM / AIエージェントからツールとして呼ぶ 提供中

こんなときに — チャットやエージェントから同じ OEE 計算をツール呼び出ししたい。

リモート MCP(Streamable HTTP)として URL を登録します。

{
  "mcpServers": {
    "longhorn": {
      "type": "http",
      "url": "https://longhorn.956.jp/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

または上のチートシート/OpenAPI をエージェントに貼り、REST クライアントを生成させます。

ツール

  • oee_shot 1回の生産データからライブOEE(稼働率×性能×品質)と工場長診断を算出する。1コール。
  • oee_set 複数日の生産データから期間OEEと日次推移、工場長診断を算出する。対象日数分がAPIコール。
  • oee_whatif ショット入力に改善仮定(不良ゼロ、停止ゼロ+回収生産、不良10%減、サイクル5%短縮など)を載せて新しいOEEを返す。履歴非保存。最大8シナリオ。
  • oee_retrieve_shot 保存済みショット分析の履歴を新しい順で取得する。デモキーでは不可。

JSON-RPC 例

curl -s https://longhorn.956.jp/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer 956-LONGHORN-DEMO-xyz-abc" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "oee_shot",
      "arguments": {
        "keyword": "鋳造ライン",
        "planned_production_time_sec": 36000,
        "planned_downtime_sec": 1800,
        "loss_time_sec": 30,
        "ideal_cycle_time_sec": 30,
        "total_count": 1000,
        "defect_count": 20
      }
    }
  }'

保存済みショット履歴を取る 提供中

こんなときに — 契約キーで保存したショットを新しい順に引きたい(デモキーでは不可)。

GET /api/v1/oee/retrieve_shot?count=50
Authorization: Bearer $LONGHORN_API_KEY

OpenAPI

機械可読の正式仕様です。コード生成や Actions 登録に使います。エージェント運用の入口は上のチートシートです。

OpenAPI を開く/閉じる

正式版は /openapi.yaml

openapi: 3.0.3
info:
  title: Longhorn OEE Analysis Web API
  description: |
    製造業向け OEE(総合設備効率)Web API。
    ショット分析・セット分析・What-if に、工場長診断(`diagnosis.engine: foreman`)を同梱します。

    認証は JSON の `api_key`、または `Authorization: Bearer` / `X-API-KEY`。
    デモキー `956-LONGHORN-DEMO-xyz-abc` は算出のみ(履歴非保存)。
    Usher 等の Capability ブローカー経由で呼ぶ場合、api_key はブローカー側が付与します。

    MCP: https://longhorn.956.jp/mcp
  version: "1.0.0"
  contact:
    name: 956 Inc.
    url: https://www.956.jp/contact
servers:
  - url: https://longhorn.956.jp
security:
  - ApiKeyHeader: []
  - ApiKeyBearer: []
  - ApiKeyBody: []
tags:
  - name: oee
    description: OEE 算出・試算・履歴取得
paths:
  /api/v1/oee/oee_shot:
    post:
      tags: [oee]
      operationId: oeeShot
      summary: ショット分析(ライブOEE)
      description: |
        1回分(ショット)の生産実績から、ライブOEEを算出する。

        使う場面:
        - 「今このラインのOEEはいくつか」を即時に知りたいとき
        - ライン横スコアボードや現場チャットで単発診断したいとき

        入力は `oee_parameters` に時間(秒)と個数を入れる。
        出力の `oee_result` に稼働率・性能・品質・OEE、`diagnosis` に工場長診断
        (主因ロス、改善レバー、推奨アクション)が同梱される。1 APIコール。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ShotRequest"
            example:
              keyword: 鋳造ライン
              oee_parameters:
                planned_production_time_sec: 36000
                planned_downtime_sec: 1800
                loss_time_sec: 30
                total_count: 1000
                defect_count: 20
                ideal_cycle_time_sec: 30
      responses:
        "200":
          description: ショットOEE算出成功。工場長診断を同梱。
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShotResponse"
        "401":
          description: APIキー不正または未指定
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "422":
          description: 入力値不正(ゼロ除算になる組み合わせ等)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /api/v1/oee/oee_set:
    post:
      tags: [oee]
      operationId: oeeSet
      summary: セット分析(期間OEE)
      description: |
        複数日の生産実績配列から、期間OEE(セット)と日次推移を算出する。

        使う場面:
        - 「先週/今月のラインOEE推移」を見たいとき
        - 日次の悪化ポイントを工場長診断で説明したいとき

        入力は `daily_data`(各要素に `date` とショットと同じ時間・個数フィールド)。
        出力は `aggregated_oee_result`(期間集計)、`daily_results`(日次)、
        `diagnosis`(期間向け工場長診断)。APIコール消費は日数分。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SetRequest"
            example:
              keyword: 鋳造ライン
              daily_data:
                - date: "2026-09-01"
                  planned_production_time_sec: 36000
                  planned_downtime_sec: 1800
                  loss_time_sec: 600
                  total_count: 1000
                  defect_count: 20
                  ideal_cycle_time_sec: 30
                - date: "2026-09-02"
                  planned_production_time_sec: 36000
                  planned_downtime_sec: 1800
                  loss_time_sec: 900
                  total_count: 980
                  defect_count: 35
                  ideal_cycle_time_sec: 30
      responses:
        "200":
          description: 期間OEEと日次推移、工場長診断。
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SetResponse"
        "401":
          description: APIキー不正または未指定
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "422":
          description: 入力エラー
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /api/v1/oee/oee_whatif:
    post:
      tags: [oee]
      operationId: oeeWhatIf
      summary: What-if(改善仮定のOEE試算)
      description: |
        ショット入力を基準に、改善仮定シナリオごとの新しいOEEを試算する(履歴非保存)。

        使う場面:
        - 「不良をゼロにしたら何pt上がるか」を先に試したいとき
        - 改善施策の優先順位を数値で比較したいとき

        `scenarios` 省略時は次のプリセットを最大4本実行する:
        zero_defects / zero_stops / cut_defects_10pct / cycle_minus_5pct。
        `zero_stops` は停止時間をゼロにし、回収生産を上乗せする。最大8シナリオ。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WhatIfRequest"
      responses:
        "200":
          description: baseline と scenarios の試算結果。
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WhatIfResponse"
        "401":
          description: APIキー不正または未指定
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "422":
          description: 入力エラー
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /api/v1/oee/retrieve_shot:
    get:
      tags: [oee]
      operationId: retrieveShot
      summary: ショット履歴取得
      description: |
        保存済みショット分析を新しい順で取得する。

        使う場面:
        - 過去に保存したライブOEEを振り返るとき
        - キーワード(ライン名)で絞って履歴を見せたいとき

        デモキーでは履歴非保存のため取得できない。
        `from_time` 以前のレコードを最大 `count` 件返す。
      parameters:
        - name: keyword
          in: query
          description: ライン名など保存時キーワードで絞り込み(部分一致ではなく保存値と照合)
          schema: { type: string }
        - name: from_time
          in: query
          description: この日時以前(ISO8601)。省略時は現在時刻。
          schema: { type: string, format: date-time }
        - name: count
          in: query
          description: 取得件数。省略時 50。
          schema: { type: integer, default: 50, minimum: 1, maximum: 200 }
      responses:
        "200":
          description: ショット履歴一覧。
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RetrieveShotResponse"
        "401":
          description: APIキー不正または未指定
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

  /api/v1/oee/retrieve_set:
    get:
      tags: [oee]
      operationId: retrieveSet
      summary: セット履歴取得
      description: |
        保存済みセット(期間)分析を取得する。

        使う場面:
        - 過去の期間OEEレポートを再表示したいとき
        - 日付範囲でセット履歴を絞りたいとき

        デモキーでは履歴非保存のため取得できない。
      parameters:
        - name: keyword
          in: query
          description: ライン名など保存時キーワード
          schema: { type: string }
        - name: from_date
          in: query
          description: 期間開始日(YYYY-MM-DD)
          schema: { type: string, format: date }
        - name: until_date
          in: query
          description: 期間終了日(YYYY-MM-DD)
          schema: { type: string, format: date }
      responses:
        "200":
          description: セット履歴一覧。
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RetrieveSetResponse"
        "401":
          description: APIキー不正または未指定
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

components:
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY
    ApiKeyBearer:
      type: http
      scheme: bearer
    ApiKeyBody:
      type: apiKey
      in: query
      name: api_key
  schemas:
    OeeParameters:
      type: object
      description: ショット1回分の生産実績入力。時間は秒、個数は整数。
      required:
        - planned_production_time_sec
        - ideal_cycle_time_sec
        - total_count
        - defect_count
      properties:
        planned_production_time_sec:
          type: number
          description: "計画稼働時間(秒)。例: 8時間なら 28800、10時間なら 36000。"
          example: 36000
        planned_downtime_sec:
          type: number
          description: 計画停止時間(秒)。昼休み・段取りなど計画内の停止。
          example: 1800
        loss_time_sec:
          type: number
          description: 非計画停止・ロス時間(秒)。故障・チョコ停など。
          example: 30
        ideal_cycle_time_sec:
          type: number
          description: 理想サイクルタイム(秒)。1個あたりの理想加工時間。
          example: 30
        total_count:
          type: integer
          description: 生産数(総数)。
          example: 1000
        defect_count:
          type: integer
          description: 不良数。良品数 = total_count - defect_count。
          example: 20
        keyword:
          type: string
          description: "ライン名など任意ラベル(例: 鋳造ライン)。診断文や履歴絞り込みに使う。"

    DailyOeeParameters:
      type: object
      description: セット分析の1日分。OeeParameters に対象日 date を必須追加。
      required:
        - date
        - planned_production_time_sec
        - ideal_cycle_time_sec
        - total_count
        - defect_count
      properties:
        date:
          type: string
          format: date
          description: 対象日(YYYY-MM-DD)
          example: "2026-09-01"
        planned_production_time_sec:
          type: number
          description: 計画稼働時間(秒)
        planned_downtime_sec:
          type: number
          description: 計画停止時間(秒)
        loss_time_sec:
          type: number
          description: 非計画停止・ロス時間(秒)
        ideal_cycle_time_sec:
          type: number
          description: 理想サイクルタイム(秒)
        total_count:
          type: integer
          description: 生産数
        defect_count:
          type: integer
          description: 不良数
        keyword:
          type: string
          description: 日次の任意ラベル(省略可)

    ShotRequest:
      type: object
      description: ショット分析リクエスト。業務パラメータは oee_parameters に入れる。
      required: [oee_parameters]
      properties:
        keyword:
          type: string
          description: ライン名など任意ラベル。oee_parameters.keyword より優先して診断に使える。
        oee_parameters:
          $ref: "#/components/schemas/OeeParameters"

    SetRequest:
      type: object
      description: セット分析リクエスト。daily_data に日次配列を入れる。
      required: [daily_data]
      properties:
        keyword:
          type: string
          description: 期間全体のライン名など任意ラベル
        daily_data:
          type: array
          description: 日次のショット入力配列。各要素に date と時間・個数フィールドが必要。
          minItems: 1
          items:
            $ref: "#/components/schemas/DailyOeeParameters"

    WhatIfScenario:
      type: object
      description: |
        改善仮定。`preset` を使うか、`label` + `changes` でカスタム変更を指定する。
      properties:
        preset:
          type: string
          description: 組み込み改善プリセット
          enum: [zero_defects, zero_stops, cut_defects_10pct, cycle_minus_5pct]
        label:
          type: string
          description: カスタムシナリオ表示名(preset 未使用時)
        changes:
          $ref: "#/components/schemas/OeeParameters"

    WhatIfRequest:
      type: object
      description: What-if リクエスト。ショット基準値 + 任意シナリオ配列。
      required: [oee_parameters]
      properties:
        keyword:
          type: string
          description: ライン名など任意ラベル
        oee_parameters:
          $ref: "#/components/schemas/OeeParameters"
        scenarios:
          type: array
          description: |
            試算シナリオ(最大8)。省略時は zero_defects / zero_stops /
            cut_defects_10pct / cycle_minus_5pct。
          maxItems: 8
          items:
            $ref: "#/components/schemas/WhatIfScenario"

    ScoreEntry:
      type: object
      description: 工場長診断のスコア1項目
      properties:
        value:
          type: number
          description: 0.0〜1.0 の比率、または百分率換算前の値
        grade:
          type: string
          description: "評価ラベル(例: good / warn / bad)"
        label:
          type: string
          description: 日本語表示名

    Diagnosis:
      type: object
      description: 工場長診断。なぜ悪化したか、何pt効く改善レバーかを返す。
      properties:
        engine:
          type: string
          description: 常に foreman
          example: foreman
        engine_label:
          type: string
          example: 工場長診断
        headline:
          type: string
          description: 一行の診断見出し
        summary:
          type: string
          description: 診断サマリー(人間向け短文)
        primary_loss:
          type: string
          description: 主因ロス。availability / performance / quality のいずれか
          enum: [availability, performance, quality]
        scores:
          type: object
          description: OEE・稼働・性能・品質のスコア
          additionalProperties:
            $ref: "#/components/schemas/ScoreEntry"
        levers:
          type: array
          description: 改善レバー(何を直すと何pt効くか)
          items:
            type: object
            properties:
              key: { type: string }
              label: { type: string }
              impact_pt: { type: number, description: "改善見込みポイント" }
              note: { type: string }
        actions:
          type: array
          description: 推奨アクション(現場向け)
          items:
            type: object
            properties:
              priority: { type: integer }
              title: { type: string }
              detail: { type: string }
        trend:
          type: object
          description: 期間分析時の傾向メモ(ショットでは空や簡易)
          additionalProperties: true

    OeeResult:
      type: object
      description: OEE算出結果のコア指標
      properties:
        oee:
          type: number
          description: 総合設備効率(0.0〜1.0)。稼働率×性能×品質
        availability:
          type: number
          description: 稼働率(0.0〜1.0)
        performance:
          type: number
          description: 性能(0.0〜1.0)
        quality:
          type: number
          description: 品質/良品率(0.0〜1.0)
        metrics:
          type: object
          description: 計算過程の時間・個数内訳
          additionalProperties: true
        keyword:
          type: string

    ShotResponse:
      type: object
      description: ショット分析の成功レスポンス
      properties:
        success:
          type: boolean
          description: 成功時 true
        oee_result:
          $ref: "#/components/schemas/OeeResult"
        diagnosis:
          $ref: "#/components/schemas/Diagnosis"
        keyword:
          type: string
          description: 適用されたキーワード
        message:
          type: string
          description: 処理メッセージ

    SetResponse:
      type: object
      description: セット分析の成功レスポンス
      properties:
        success:
          type: boolean
        aggregated_oee_result:
          $ref: "#/components/schemas/OeeResult"
        daily_results:
          type: array
          description: 日次OEE結果の配列
          items:
            type: object
            properties:
              date: { type: string, format: date }
              oee: { type: number }
              availability: { type: number }
              performance: { type: number }
              quality: { type: number }
              metrics: { type: object, additionalProperties: true }
        diagnosis:
          $ref: "#/components/schemas/Diagnosis"
        keyword:
          type: string

    WhatIfScenarioResult:
      type: object
      description: What-if 1シナリオの結果
      properties:
        label:
          type: string
          description: シナリオ名
        preset:
          type: string
          description: 使用したプリセット(カスタム時は空)
        oee_result:
          $ref: "#/components/schemas/OeeResult"
        delta_oee_pt:
          type: number
          description: baseline からのOEE差分(ポイント)

    WhatIfResponse:
      type: object
      description: What-if 成功レスポンス
      properties:
        success:
          type: boolean
        keyword:
          type: string
        baseline:
          $ref: "#/components/schemas/OeeResult"
        scenarios:
          type: array
          items:
            $ref: "#/components/schemas/WhatIfScenarioResult"
        message:
          type: string

    RetrieveShotResponse:
      type: object
      description: ショット履歴取得レスポンス
      properties:
        success:
          type: boolean
        oee_metrics:
          type: array
          description: 新しい順のショット履歴
          items:
            type: object
            properties:
              id: { type: integer }
              keyword: { type: string }
              oee: { type: number }
              availability: { type: number }
              performance: { type: number }
              quality: { type: number }
              created_at: { type: string, format: date-time }
              diagnosis:
                $ref: "#/components/schemas/Diagnosis"

    RetrieveSetResponse:
      type: object
      description: セット履歴取得レスポンス
      properties:
        success:
          type: boolean
        oee_metrics:
          type: array
          description: セット履歴(期間集計を含む)
          items:
            type: object
            properties:
              id: { type: integer }
              keyword: { type: string }
              oee: { type: number }
              availability: { type: number }
              performance: { type: number }
              quality: { type: number }
              from_date: { type: string, format: date }
              until_date: { type: string, format: date }
              created_at: { type: string, format: date-time }
              diagnosis:
                $ref: "#/components/schemas/Diagnosis"

    ErrorResponse:
      type: object
      description: エラーレスポンス
      properties:
        success:
          type: boolean
          example: false
        errors:
          type: array
          items: { type: string }
          description: エラーメッセージ配列
        message:
          type: string

正式URL: http://longhorn.956.jp/openapi.yaml ·