mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
feat(kimi): Kimi K3 provider on the official kimi-code CLI (#713)
* feat(kimi): Kimi K3 provider on the official kimi-code CLI (Wave 1) ModelProvider.KIMI routes through KimiCliProvider driving Moonshot's kimi CLI on a Kimi subscription (OAuth device-code, no metered key). One-shot delivery roles only (V1), interactive ban wired in both guard lists. Auth: one shared RW auth mount; containers symlink credentials/ and oauth/ (the CLI's cross-process refresh-lock dir) into a container-local KIMI_CODE_HOME so every container and the host redeem the SAME rotating refresh chain - live-verified that per-copy chains cross-invalidate after the reuse-grace window. No orchestrator refresh daemon; an expires_at preflight exits 78. Config renderer mirrors the login-managed provider/model blocks field-for-field (live-captured; the model value is the CLI-side name, never the raw API id), plus per-role deny rules and the bash-guard as a PreToolUse hook via a wrapper script (an env key on a hooks entry makes the CLI silently drop ALL hooks - live-verified). Usage capture sums wire.jsonl usage.record 4-bucket events; sniff classifies rate-limit/auth from structured error text only, mapped to the shared 75/78 park contract. Image installs the CLI latest-at-build (no version pin, by policy) with the resolved version stamped as provenance, binary split to /usr/local away from mutable state. Migrations 090 (enum) + 091 (provider seed); catalog, pricing, routing mode, and orchestrator park/usage wiring mirror the codex integration. * feat(kimi): surface sweep + fleet-wide pin drop (Wave 2) Compose x3 gain the agent-kimi-image service and the orchestrator's read-write ~/.kimi-code mount + kimi-usage dir; .env.example documents the Kimi block. Panel mirrors ModelProvider.KIMI and adds the kimi routing mode (catalog filter, mode button, mix-picker group, badge) with tests; provider routes gain the kimi remediation entry. CLAUDE.md and docs/map document the runtime. Per the no-pins policy, agent-grok/ gemini/codex Dockerfiles drop their version pins for latest-at-build with resolved-version provenance stamps (grok resolves 0.2.112 vs the old 0.2.56 pin - verified by real builds of all four images). --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Add 'kimi' to the postgres modelprovider enum.
|
||||
|
||||
Kimi (``ModelProvider.KIMI`` — Moonshot's subscription-authenticated
|
||||
``kimi``/kimi-code CLI) is a new agent backend. Seeding its provider row
|
||||
(migration 091) and routing agents to it requires the postgres
|
||||
``modelprovider`` enum to carry the value. Mirrors the enum-add pattern of
|
||||
migration 084 (gemini); the row seed is split into 091 because a newly added
|
||||
enum value cannot be used in the same transaction that adds it.
|
||||
|
||||
Revision ID: 090_modelprovider_kimi
|
||||
Revises: 089_board_cycle_ntp_reason
|
||||
Create Date: 2026-07-28
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision = "090_modelprovider_kimi"
|
||||
down_revision = "089_board_cycle_ntp_reason"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# The new value must be COMMITTED before migration 091 inserts a row using
|
||||
# it: alembic runs the whole upgrade in a single transaction, and Postgres
|
||||
# forbids using a freshly added enum value in the same transaction that
|
||||
# added it (UnsafeNewEnumValueUsageError). autocommit_block commits the
|
||||
# ALTER on its own so 'kimi' is usable downstream. Still renders the ALTER
|
||||
# TYPE in offline --sql, so the enum-migration-parity test sees it.
|
||||
# Idempotent via IF NOT EXISTS.
|
||||
with op.get_context().autocommit_block():
|
||||
op.execute("ALTER TYPE modelprovider ADD VALUE IF NOT EXISTS 'kimi'")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Postgres does not support removing enum values without a destructive
|
||||
# type recreation. Forward-only by design (see migration 037).
|
||||
pass
|
||||
@@ -0,0 +1,66 @@
|
||||
"""Idempotently seed the Kimi (Moonshot) provider row.
|
||||
|
||||
The ``modelprovider`` enum carries ``'kimi'`` as of migration 090. This
|
||||
migration seeds the corresponding ``provider_configs`` row so the Settings UI
|
||||
can list it for role/agent model assignment.
|
||||
|
||||
Like Codex (migration 083), seeded ``enabled=true`` directly: the
|
||||
KimiCliProvider authenticates from a mounted subscription credential
|
||||
(``~/.kimi-code/credentials/kimi-code.json``, from a `kimi login` device-code
|
||||
flow), never a stored API key, so there is no secret to withhold behind a
|
||||
disabled row — ``base_url``/``auth_token_encrypted`` stay NULL permanently
|
||||
(mirroring Gemini's row). Unlike Gemini's row (seeded disabled, flipped by a
|
||||
follow-up migration), there is no reason to gate this one behind a second
|
||||
migration since there's no key-collection step it needs to wait on.
|
||||
ON CONFLICT (name) DO NOTHING keeps this safe to re-run.
|
||||
|
||||
Revision ID: 091_seed_kimi_provider
|
||||
Revises: 090_modelprovider_kimi
|
||||
Create Date: 2026-07-28
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "091_seed_kimi_provider"
|
||||
down_revision = "090_modelprovider_kimi"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
sa.text(
|
||||
"""
|
||||
INSERT INTO provider_configs
|
||||
(id, name, type, base_url, auth_token_encrypted, enabled, created_at)
|
||||
VALUES
|
||||
(
|
||||
gen_random_uuid(),
|
||||
'Kimi (Moonshot)',
|
||||
'kimi',
|
||||
NULL,
|
||||
NULL,
|
||||
true,
|
||||
now()
|
||||
)
|
||||
ON CONFLICT (name) DO NOTHING
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Drop model_assignments pointing at the Kimi row first to avoid a FK
|
||||
# RESTRICT violation on provider_configs.id.
|
||||
op.execute(
|
||||
sa.text(
|
||||
"DELETE FROM model_assignments "
|
||||
"WHERE provider_config_id IN ("
|
||||
" SELECT id FROM provider_configs WHERE name = 'Kimi (Moonshot)'"
|
||||
")"
|
||||
)
|
||||
)
|
||||
op.execute(sa.text("DELETE FROM provider_configs WHERE name = 'Kimi (Moonshot)'"))
|
||||
Reference in New Issue
Block a user