Sign inSign up

tmsmr/tmsbx-bifrost-config:0.0.1

Manifest digest

sha256:27294481c503c04eb9b801efc8bae8d1e22df4575afd2b1d64f55d3cbbb48e60

Last pushed

5 days by tmsmr

Type

Sandbox Kit

Manifest digest

sha256:27294481c503c04eb9b801efc8bae8d1e22df4575afd2b1d64f55d3cbbb48e60

yaml
schemaVersion: "3"
displayName: TMSBX Bifrost OpenCode configuration
kind: mixin
capabilities:
    - type: com.docker.sandbox/lifecycle@1
      config:
        files:
            - content: |
                {
                  "$schema": "https://opencode.ai/config.json",
                  "enabled_providers": [
                    "bifrost"
                  ],
                  "permission": {
                    "*": "allow"
                  },
                  "provider": {
                    "bifrost": {
                      "npm": "@ai-sdk/openai-compatible",
                      "name": "TMSBX Bifrost",
                      "options": {
                        "baseURL": "https://${{ kit.args.bifrost_fqdn }}/openai"
                      },
                      "models": {}
                    }
                  },
                  "mcp": {}
                }
              path: /home/agent/.config/opencode/opencode.json
            - content: |
                #!/usr/bin/env python3

                import json
                import os
                import re

                OPENCODE_CONFIG_PATH = os.path.expanduser(os.getenv("OPENCODE_CONFIG_PATH"))
                OPENCODE_BIFROST_MODELS = os.getenv("OPENCODE_BIFROST_MODELS")

                with open(OPENCODE_CONFIG_PATH, "r", encoding="utf-8") as f:
                  content = json.load(f)
                  content["provider"]["bifrost"]["models"] = {}

                for model in OPENCODE_BIFROST_MODELS.split(";"):
                  model = model.strip()
                  content["provider"]["bifrost"]["models"][re.sub('[^0-9a-zA-Z]', '-', model.lower())] = {"name": model}

                with open(OPENCODE_CONFIG_PATH, "w", encoding="utf-8") as f:
                  json.dump(content, f, indent=4)
              path: /home/agent/utils/write-models.py
        startup:
            - command: |
                OPENCODE_CONFIG_PATH="~/.config/opencode/opencode.json" \
                OPENCODE_BIFROST_MODELS="${{ kit.args.bifrost_models }}" \
                python3 ~/utils/write-models.py
              user: agent
    - type: com.docker.sandbox/network-policy@2
      config:
        runtime:
            allow:
                - ${{ kit.args.bifrost_fqdn }}:443
    - type: com.docker.sandbox/credential@1
      config:
        apiKey:
            inject:
                - domain: ${{ kit.args.bifrost_fqdn }}
                  format: '%s'
                  header: x-bf-vk
            name: bifrost-virtual-key
            proxyManaged: true
        phase: runtime
        service: bifrost-virtual-key
    - type: com.docker.sandbox/credential@1
      config:
        apiKey:
            inject:
                - domain: ${{ kit.args.bifrost_fqdn }}
                  format: Basic %s
                  header: Authorization
            name: bifrost-basic-auth
            proxyManaged: true
        phase: runtime
        service: bifrost-basic-auth
args:
    bifrost_fqdn:
        required: true
    bifrost_models:
        required: true