HUB
Sign inSign up

richardaubin/billion-context-kit:latest

Manifest digest

sha256:8a402df58f20beed545ef61a5fba5654076ae844b69324da79acea7ed1067782

Last pushed

14 days by richardaubin

Type

Sandbox Kit

Manifest digest

sha256:8a402df58f20beed545ef61a5fba5654076ae844b69324da79acea7ed1067782

yaml
schemaVersion: "3"
displayName: billion-context compression proxy
description: Vendored billion-context (`bili`) plus the loopback relay its tunnel needs for a host-gateway model endpoint. A startup hook starts the relay and registers upstream's own pi extension with pi's installer, after which compression runs in-process inside pi. long-running@1 is declared because that relay carries every model call; no egress is declared.
sourceUrl: https://github.com/ranxianglei/billion-context
version: 0.1.215
licenses:
    - MIT
kind: mixin
provides:
    - [email protected]
requires:
    - pi >= 1.5.2, < 2.0.0
capabilities:
    - type: com.docker.sandbox/long-running@1
    - type: com.docker.sandbox/lifecycle@1
      config:
        startup:
            - command:
                - sh
                - -c
                - |
                  set -u
                  exec /usr/local/bin/bili-kit-start
              description: Start the loopback relay onto the host model gateway, then register upstream's pi extension with pi's own installer (idempotent, every boot)
              env:
                - PATH
                - HOME
                - ACP_AUTO_UPDATE
                - BILI_ADVISORY_CHECK
                - BILI_KIT_FORWARD_PORT
                - BILI_KIT_GATEWAY_HOST
                - BILI_KIT_GATEWAY_PORT
    - type: com.docker.sandbox/agent-context@2
      optional: true
      config:
        content: 'Context compression for the model lane comes from billion-context (`bili`), vendored at /opt/billion-context with shims at /usr/local/bin/bili, bili-proxy, bili-kit-start and bili-kit-check. The lane is: pi (with upstream''s own extension loaded) compresses IN PROCESS, then sends the model call to a relay at 127.0.0.1:18080 -> the host gateway at host.docker.internal:8989. Upstream''s pi lane defaults to that in-process engine (`pi.inline`, BILI_PI_ INLINE), which is why no proxy process is started at boot; a listener is available on demand with `bili --host 127.0.0.1 --port 8787` if a client that cannot compress in process is added. The relay is load-bearing: bili''s tunnel always refuses link-local and metadata destinations, and a sandbox''s host-gateway name is link-local, so pointing a provider baseUrl straight at host.docker.internal:8989 gets 403 "link-local / metadata destinations are blocked from the bili tunnel" — measured, including with both documented opt-ins set. Do not "simplify" the endpoint away from the relay. Upstream''s own pi extension is registered by this kit at every boot with pi''s installer (`pi install /opt/billion-context/lib/node_modules/billion-context`), because pi cannot install the npm: spec upstream''s installer writes — this image has node but no npm. Never hand-edit that `packages` entry, never add an extension file under ~/.pi/agent/extensions, and do not run `pi install npm:billion-context`, which cannot succeed here and whose removal pi also cannot perform. Ask for `bili-kit-check` whenever compression looks absent: it reports the payload, node, the relay and what it can reach, the wiring entry, the sessions in bili''s store and whether pi''s provider baseUrl still names this lane''s port. If the relay is dead, run `bili-kit-start` — it is idempotent and leaves anything already listening alone. A long-lived pi process keeps the extension code it loaded at process start (billion-context #1603), so after a wiring or payload change restart pi (or /reload); self-update and the advisory watcher are off here, so the only code change path is a kit rebuild plus a sandbox recreate. bili keeps its state under ~/.local/share/billion-context and ~/.config/billion-context; no volume is declared, so that state lives and dies with the sandbox (stop/start keeps it, `sbx env rm` removes it) — losing it costs compression history, not model access. billion-context is MIT plus an attribution term; its README and LICENSE ship inside /opt/billion-context/lib/node_modules/billion-context.'
args:
    forward_port:
        default: "18080"
        description: sandbox loopback port of the relay onto the host model gateway; this is the port pi's provider baseUrl names (kits/pi-strata)
        pattern: ^[1-9][0-9]{0,4}$
        buildArg: BILI_FORWARD_PORT
    gateway_host:
        default: host.docker.internal
        description: name the relay dials for the host model gateway; Docker's host-gateway name, never its link-local address (a sandbox policy denies the literal 169.254.1.1 and bili denies it too)
        pattern: ^[A-Za-z0-9._-]+$
        buildArg: BILI_GATEWAY_HOST
    gateway_port:
        default: "8989"
        description: TCP port of the host model gateway (the strata gateway listens on the host's loopback only, which is what the host-gateway name reaches)
        pattern: ^[1-9][0-9]{0,4}$
        buildArg: BILI_GATEWAY_PORT
    version:
        default: 0.1.215
        description: 'billion-context (npm) release this kit vendors as pkg/billion-context-<version>.tgz with its sha512 recorded in checksums.txt. A published kit takes no version arg: change the tag.'
        pattern: ^[0-9]+\.[0-9]+\.[0-9]+$
        buildArg: BILI_VERSION