Compare commits

...
5 Commits
Author SHA1 Message Date
雷电芽衣 c56660fe07 chore(legal): regenerate THIRD-PARTY-NOTICES for the 0.1.19 workspace version
Release / build (x86_64-unknown-linux-gnu) (push) Failing after 6s
Release / build (aarch64-apple-darwin) (push) Canceled after 0s
Release / build (aarch64-unknown-linux-gnu) (push) Canceled after 0s
Release / build (x86_64-apple-darwin) (push) Canceled after 0s
Release / build (x86_64-pc-windows-msvc) (push) Canceled after 0s
Release / publish GitHub Release (push) Canceled after 0s
2026-09-29 16:54:21 -04:00
雷电芽衣 3bde7fe851 chore(release): bump workspace version to 0.1.19 2026-09-29 16:53:53 -04:00
雷电芽衣 793b93b74d test(subagent): the auth-scheme test joins the existing tests module 2026-09-29 16:53:07 -04:00
雷电芽衣 c9855c4bb6 fix(review): custom provider login comments, doc placement, subagent scheme test
The subagent auth-scheme lookup is now a function with a test. The failed-login
span carries the same method id as the successful one. README order matches the
code: the provider is saved, then the key is checked.
2026-09-29 16:50:03 -04:00
雷电芽衣 c4ef8a3779 docs+test: custom providers in README and AGENTS.md, provider-only startup PTY test
Also records the codex catalog at eight models and the 0.159.0 User-Agent.
2026-09-29 16:37:56 -04:00
19 changed files with 288 additions and 179 deletions

No files matched your search

+39 -4
View File
@@ -415,15 +415,17 @@ client-side, no backend surface.
carries the thinking level. NO websocket, NO base_instructions. carries the thinking level. NO websocket, NO base_instructions.
CATALOG is HARDCODED (`PlatformId::hardcoded_catalog` → CATALOG is HARDCODED (`PlatformId::hardcoded_catalog` →
`openai_codex_wire_models`, mapped through the SAME `openai_codex_wire_models`, mapped through the SAME
`platform_wire_model_to_entry` output): the 7 `visibility=list` && `platform_wire_model_to_entry` output): the 8 `visibility=list` &&
`supported_in_api=true` models the backend served on 2026-09-22 `supported_in_api=true` models the backend served on 2026-09-29
(`gpt-6-astra/sol/luna`, `gpt-5.6-sol/terra/luna`, `gpt-5.5`, ctx 272000, (`gpt-6.1-sol`, `gpt-6-astra/sol/luna`, `gpt-5.6-sol/terra/luna`,
per-model efforts) — NO live `/models` fetch, NO codex-CLI / `~/.codex` `gpt-5.5`, ctx 272000, per-model efforts) — NO live `/models` fetch, NO codex-CLI / `~/.codex`
dependency; the hidden `gpt-reserve` and `codex-auto-review` are dependency; the hidden `gpt-reserve` and `codex-auto-review` are
EXCLUDED. Refresh the table by reading EXCLUDED. Refresh the table by reading
`GET {base}/models?client_version=<a current codex release>` with a `GET {base}/models?client_version=<a current codex release>` with a
ChatGPT bearer: an old `client_version` is answered with a truncated ChatGPT bearer: an old `client_version` is answered with a truncated
list, so a stale version reads as "the model does not exist". list, so a stale version reads as "the model does not exist".
`CODEX_USER_AGENT` (`codex_cli_rs/0.159.0`) moves with the release used
for that read.
- `OAuthFlow::GithubDeviceCopilot` → `auth::github_copilot` (TWO-STAGE). - `OAuthFlow::GithubDeviceCopilot` → `auth::github_copilot` (TWO-STAGE).
Provider: `github-copilot` (`scope_key oauth/github-copilot`, base Provider: `github-copilot` (`scope_key oauth/github-copilot`, base
`api.individual.githubcopilot.com`, ChatCompletions wire). Stage 1 is an `api.individual.githubcopilot.com`, ChatCompletions wire). Stage 1 is an
@@ -457,6 +459,39 @@ client-side, no backend surface.
token (`resolve_generic_oauth_tokens`, refreshed on expiry) and routes token (`resolve_generic_oauth_tokens`, refreshed on expiry) and routes
`platform.oauth().is_some()` → `platform.base_url()` (kimi-code alone → `platform.oauth().is_some()` → `platform.base_url()` (kimi-code alone →
`proxy_url()`). Tokens/codes/verifiers are NEVER logged. `proxy_url()`). Tokens/codes/verifiers are NEVER logged.
- CUSTOM PROVIDERS (0.1.19): `[platforms.<name>]` with `base_url` and `api =
"openai" | "anthropic"` declares a provider outside the closed registry.
`kigi-models/src/custom.rs` owns the validated type (name `[a-z0-9][a-z0-9_-]{0,31}`,
never a registry id; base URL `http(s)://host[/path]`, no userinfo, query or
fragment); `kigi-shell/src/agent/custom_providers/` owns the rest. Key order:
auth.json scope `<name>`, then the table's `api_key`; a key is REQUIRED (a
keyless declaration is inert). Wires: openai = `/chat/completions`, Bearer,
`GET {base}/models`; anthropic = `/messages`, `x-api-key`,
`GET {base}/models?limit=1000`. Catalog keys are `<name>/<model>`; the entry's
`description` carries the provider name for the picker. Entries reach the disk
cache without a key; `stamp_credentials` stamps `api_key` in memory, only onto
entries still on the provider's own host, and `drop_orphans` removes fetched
entries of a provider that is gone or keyless BEFORE the prefetched map replaces
the catalog (a stale unkeyed entry would fall through to the house key).
CREDENTIAL RULE: `EndpointsConfig.custom_provider_bases` (derived from
`[platforms.*]` in `Config::new_from_toml_cfg` and `from_config_value`, never
serialized) makes `CredentialAuthority::is_session_coding_endpoint` false for a
declared base, loopback included — without it an Ollama-style provider on
localhost classifies `Primary` and the Kimi bearer replaces its key. Every
authority is built from the models manager's config, so the field reaches all of
them. Turns and subagents read `auth_scheme` and BYOK status from the LIVE
catalog entry (`auth_facts_of`), not from a disk reload: fetched entries never
live on disk, and the reload sent fetched Messages models out with `Bearer`
instead of `x-api-key` (this also repaired `anthropic` and `minimax`).
Login: picker rows `custom-openai` / `custom-anthropic` are not loginable
(`AuthMethodKind::Unknown`); the TUI asks base URL, name (default from the
host), key, then `save_custom_provider` writes config.toml (through
`config_write_dest`) and auth.json, and `authenticate("custom:<name>")`
validates `GET {base}/models` (401/403 = rejected key, other non-2xx and network
errors surface). Limits: context window 256K unless the listing serves
`context_length` (Anthropic: `max_input_tokens`); no models.dev enrichment; a
failed key check leaves the saved definition (login again with the same name to
overwrite); no delete UI, edit config.toml and auth.json.
- A stored subscription-OAuth session IS a catalog fetch source. Every - A stored subscription-OAuth session IS a catalog fetch source. Every
fetch-PLAN decision that cannot afford real token resolution — the startup fetch-PLAN decision that cannot afford real token resolution — the startup
prefetch arming gate, `on_auth_changed`'s wipe guard prefetch arming gate, `on_auth_changed`'s wipe guard
Generated
+62 -62
View File
@@ -5442,7 +5442,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-acp-lib" name = "kigi-acp-lib"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"async-trait", "async-trait",
@@ -5456,7 +5456,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-agent" name = "kigi-agent"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"chrono", "chrono",
"dirs 6.0.0", "dirs 6.0.0",
@@ -5486,7 +5486,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-agent-lifecycle" name = "kigi-agent-lifecycle"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"tokio", "tokio",
@@ -5495,7 +5495,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-auth" name = "kigi-auth"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"http 1.4.2", "http 1.4.2",
@@ -5508,7 +5508,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-bin" name = "kigi-bin"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@@ -5543,7 +5543,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-chat-state" name = "kigi-chat-state"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"kigi-compaction", "kigi-compaction",
@@ -5560,7 +5560,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-codebase-graph" name = "kigi-codebase-graph"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"ahash", "ahash",
"clap", "clap",
@@ -5596,7 +5596,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-compaction" name = "kigi-compaction"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -5609,7 +5609,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-config" name = "kigi-config"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"base64", "base64",
"blake3", "blake3",
@@ -5632,7 +5632,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-config-types" name = "kigi-config-types"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"indexmap", "indexmap",
@@ -5646,7 +5646,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-crash-handler" name = "kigi-crash-handler"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"libc", "libc",
@@ -5657,7 +5657,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-env" name = "kigi-env"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"tracing", "tracing",
"url", "url",
@@ -5665,7 +5665,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-fast-worktree" name = "kigi-fast-worktree"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@@ -5697,7 +5697,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-file-utils" name = "kigi-file-utils"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"aws-config", "aws-config",
@@ -5721,7 +5721,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-fsnotify" name = "kigi-fsnotify"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"criterion", "criterion",
"dunce", "dunce",
@@ -5742,7 +5742,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-gix-status" name = "kigi-gix-status"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"gix", "gix",
"kigi-test-utils", "kigi-test-utils",
@@ -5752,7 +5752,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-hooks" name = "kigi-hooks"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"fastrand", "fastrand",
"kigi-config", "kigi-config",
@@ -5771,7 +5771,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-hooks-plugins-types" name = "kigi-hooks-plugins-types"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@@ -5779,7 +5779,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-http" name = "kigi-http"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"kigi-auth", "kigi-auth",
"kigi-log", "kigi-log",
@@ -5794,7 +5794,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-hunk-tracker" name = "kigi-hunk-tracker"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"chrono", "chrono",
"dunce", "dunce",
@@ -5815,14 +5815,14 @@ dependencies = [
[[package]] [[package]]
name = "kigi-interjection-core" name = "kigi-interjection-core"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "kigi-log" name = "kigi-log"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -5840,7 +5840,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-markdown" name = "kigi-markdown"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"anstyle-lossy", "anstyle-lossy",
@@ -5864,14 +5864,14 @@ dependencies = [
[[package]] [[package]]
name = "kigi-markdown-core" name = "kigi-markdown-core"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"pulldown-cmark", "pulldown-cmark",
] ]
[[package]] [[package]]
name = "kigi-mcp" name = "kigi-mcp"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"async-trait", "async-trait",
@@ -5908,7 +5908,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-memory" name = "kigi-memory"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@@ -5942,7 +5942,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-mermaid" name = "kigi-mermaid"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"fontdb", "fontdb",
"image", "image",
@@ -5960,7 +5960,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-models" name = "kigi-models"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"kigi-env", "kigi-env",
"serde", "serde",
@@ -5970,7 +5970,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-pager-minimal" name = "kigi-pager-minimal"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"chrono", "chrono",
"crossterm", "crossterm",
@@ -5987,7 +5987,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-pager-pty-harness" name = "kigi-pager-pty-harness"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"alacritty_terminal", "alacritty_terminal",
"anyhow", "anyhow",
@@ -6012,7 +6012,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-pager-render" name = "kigi-pager-render"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"anstyle", "anstyle",
@@ -6064,7 +6064,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-paths" name = "kigi-paths"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"camino", "camino",
"serde", "serde",
@@ -6074,7 +6074,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-prompt-queue" name = "kigi-prompt-queue"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@@ -6082,7 +6082,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-proto-build" name = "kigi-proto-build"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"pbjson-build", "pbjson-build",
@@ -6093,7 +6093,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-ratatui-inline" name = "kigi-ratatui-inline"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"ansi-width", "ansi-width",
"anstyle-parse 0.2.7", "anstyle-parse 0.2.7",
@@ -6110,7 +6110,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-ratatui-textarea" name = "kigi-ratatui-textarea"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"arboard", "arboard",
"chrono", "chrono",
@@ -6131,7 +6131,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-sampler" name = "kigi-sampler"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"async-openai", "async-openai",
"async-stream", "async-stream",
@@ -6155,7 +6155,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-sampling-types" name = "kigi-sampling-types"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"async-openai", "async-openai",
@@ -6172,7 +6172,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-sandbox" name = "kigi-sandbox"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -6194,7 +6194,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-secrets" name = "kigi-secrets"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"regex", "regex",
"serde_json", "serde_json",
@@ -6232,7 +6232,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-shell" name = "kigi-shell"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"anyhow", "anyhow",
@@ -6370,7 +6370,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-shell-base" name = "kigi-shell-base"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -6395,7 +6395,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-sqlite-journal" name = "kigi-sqlite-journal"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"libc", "libc",
"rusqlite", "rusqlite",
@@ -6406,7 +6406,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-subagent-resolution" name = "kigi-subagent-resolution"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"kigi-sampling-types", "kigi-sampling-types",
"kigi-tool-types", "kigi-tool-types",
@@ -6421,7 +6421,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-system-power" name = "kigi-system-power"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"windows-sys 0.59.0", "windows-sys 0.59.0",
"zbus", "zbus",
@@ -6429,7 +6429,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-test-support" name = "kigi-test-support"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"anyhow", "anyhow",
@@ -6451,7 +6451,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-test-utils" name = "kigi-test-utils"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"runfiles", "runfiles",
"tracing", "tracing",
@@ -6460,11 +6460,11 @@ dependencies = [
[[package]] [[package]]
name = "kigi-token-estimation" name = "kigi-token-estimation"
version = "0.1.18" version = "0.1.19"
[[package]] [[package]]
name = "kigi-tool-protocol" name = "kigi-tool-protocol"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"kigi-tool-types", "kigi-tool-types",
"serde", "serde",
@@ -6475,7 +6475,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-tool-runtime" name = "kigi-tool-runtime"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -6493,7 +6493,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-tool-types" name = "kigi-tool-types"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"minijinja", "minijinja",
"schemars 1.2.1", "schemars 1.2.1",
@@ -6503,7 +6503,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-tools" name = "kigi-tools"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@@ -6580,7 +6580,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-tools-api" name = "kigi-tools-api"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"kigi-proto-build", "kigi-proto-build",
"kigi-tool-protocol", "kigi-tool-protocol",
@@ -6593,11 +6593,11 @@ dependencies = [
[[package]] [[package]]
name = "kigi-tracing-macros" name = "kigi-tracing-macros"
version = "0.1.18" version = "0.1.19"
[[package]] [[package]]
name = "kigi-tty-utils" name = "kigi-tty-utils"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"libc", "libc",
"nix 0.30.1", "nix 0.30.1",
@@ -6607,7 +6607,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-tui" name = "kigi-tui"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"ansi-to-tui", "ansi-to-tui",
@@ -6694,7 +6694,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-update" name = "kigi-update"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dunce", "dunce",
@@ -6723,14 +6723,14 @@ dependencies = [
[[package]] [[package]]
name = "kigi-version" name = "kigi-version"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"semver", "semver",
] ]
[[package]] [[package]]
name = "kigi-workspace" name = "kigi-workspace"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"agent-client-protocol", "agent-client-protocol",
"anyhow", "anyhow",
@@ -6809,7 +6809,7 @@ dependencies = [
[[package]] [[package]]
name = "kigi-workspace-types" name = "kigi-workspace-types"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"base64", "base64",
"chrono", "chrono",
@@ -8843,7 +8843,7 @@ dependencies = [
[[package]] [[package]]
name = "ptyctl" name = "ptyctl"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"alacritty_terminal", "alacritty_terminal",
"anyhow", "anyhow",
@@ -8861,7 +8861,7 @@ dependencies = [
[[package]] [[package]]
name = "ptyctl-cli" name = "ptyctl-cli"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
+1 -1
View File
@@ -76,7 +76,7 @@ members = [
] ]
[workspace.package] [workspace.package]
version = "0.1.18" version = "0.1.19"
edition = "2024" edition = "2024"
license = "Apache-2.0" license = "Apache-2.0"
+24 -2
View File
@@ -86,8 +86,8 @@ On by default. `KIGI_GRAPH=0` turns it off; `KIGI_GRAPH_CONCURRENCY` (default
## Providers and API keys ## Providers and API keys
29 platforms ship compiled in: 5 you sign into, 24 you hand a key. Nothing is 29 platforms ship compiled in: 5 you sign into, 24 you hand a key. Anything
registered at runtime — if it's not in this list, it's not there. else is an endpoint you declare yourself ([your own endpoint](#your-own-endpoint)).
**Sign in with a subscription you already pay for.** Run `kigi login` and pick. **Sign in with a subscription you already pay for.** Run `kigi login` and pick.
Each provider's token is stored under its own key, and one provider's Each provider's token is stored under its own key, and one provider's
@@ -149,6 +149,28 @@ api_key = "sk-..."
api_key = "xai-..." api_key = "xai-..."
``` ```
### Your own endpoint
Anything that speaks the OpenAI Chat Completions API or the Anthropic Messages
API works: a gateway, a proxy, Ollama, LM Studio, vLLM. In `kigi`, open `/login`
(or the welcome login screen) and pick **Custom provider (OpenAI compatible)**
or **(Anthropic compatible)**, then enter a base URL, a name, and an API key.
Kigi saves the provider,
checks the key against `GET {base}/models`, and `/model` lists what the endpoint
serves as `name/model`.
```toml
# ~/.kigi/config.toml
[platforms.my-gateway]
base_url = "https://gateway.example.com/v1" # include /v1 when the API lives there
api = "openai" # or "anthropic"
api_key = "sk-..." # or store it in ~/.kigi/auth.json under "my-gateway"
```
A key is required. A local server that ignores auth takes any value. The
context window is 256K unless the endpoint reports one. To remove a provider,
delete its table and its `auth.json` entry.
Model lists sync on startup. Pick one with `/model`, set its thinking level Model lists sync on startup. Pick one with `/model`, set its thinking level
with `/effort`. with `/effort`.
+62 -62
View File
@@ -16436,68 +16436,68 @@ limitations under the License.
Applies to: Applies to:
- [kigi-proto-build 0.1.18](https://crates.io/crates/kigi-proto-build) - [kigi-proto-build 0.1.19](https://crates.io/crates/kigi-proto-build)
- [kigi-acp-lib 0.1.18](https://crates.io/crates/kigi-acp-lib) - [kigi-acp-lib 0.1.19](https://crates.io/crates/kigi-acp-lib)
- [kigi-agent 0.1.18](https://crates.io/crates/kigi-agent) - [kigi-agent 0.1.19](https://crates.io/crates/kigi-agent)
- [kigi-agent-lifecycle 0.1.18](https://crates.io/crates/kigi-agent-lifecycle) - [kigi-agent-lifecycle 0.1.19](https://crates.io/crates/kigi-agent-lifecycle)
- [kigi-auth 0.1.18](https://crates.io/crates/kigi-auth) - [kigi-auth 0.1.19](https://crates.io/crates/kigi-auth)
- [kigi-bin 0.1.18](https://crates.io/crates/kigi-bin) - [kigi-bin 0.1.19](https://crates.io/crates/kigi-bin)
- [kigi-chat-state 0.1.18](https://crates.io/crates/kigi-chat-state) - [kigi-chat-state 0.1.19](https://crates.io/crates/kigi-chat-state)
- [kigi-codebase-graph 0.1.18](https://crates.io/crates/kigi-codebase-graph) - [kigi-codebase-graph 0.1.19](https://crates.io/crates/kigi-codebase-graph)
- [kigi-config 0.1.18](https://crates.io/crates/kigi-config) - [kigi-config 0.1.19](https://crates.io/crates/kigi-config)
- [kigi-config-types 0.1.18](https://crates.io/crates/kigi-config-types) - [kigi-config-types 0.1.19](https://crates.io/crates/kigi-config-types)
- [kigi-crash-handler 0.1.18](https://crates.io/crates/kigi-crash-handler) - [kigi-crash-handler 0.1.19](https://crates.io/crates/kigi-crash-handler)
- [kigi-env 0.1.18](https://crates.io/crates/kigi-env) - [kigi-env 0.1.19](https://crates.io/crates/kigi-env)
- [kigi-fast-worktree 0.1.18](https://crates.io/crates/kigi-fast-worktree) - [kigi-fast-worktree 0.1.19](https://crates.io/crates/kigi-fast-worktree)
- [kigi-file-utils 0.1.18](https://crates.io/crates/kigi-file-utils) - [kigi-file-utils 0.1.19](https://crates.io/crates/kigi-file-utils)
- [kigi-fsnotify 0.1.18](https://crates.io/crates/kigi-fsnotify) - [kigi-fsnotify 0.1.19](https://crates.io/crates/kigi-fsnotify)
- [kigi-gix-status 0.1.18](https://crates.io/crates/kigi-gix-status) - [kigi-gix-status 0.1.19](https://crates.io/crates/kigi-gix-status)
- [kigi-hooks 0.1.18](https://crates.io/crates/kigi-hooks) - [kigi-hooks 0.1.19](https://crates.io/crates/kigi-hooks)
- [kigi-hooks-plugins-types 0.1.18](https://crates.io/crates/kigi-hooks-plugins-types) - [kigi-hooks-plugins-types 0.1.19](https://crates.io/crates/kigi-hooks-plugins-types)
- [kigi-http 0.1.18](https://crates.io/crates/kigi-http) - [kigi-http 0.1.19](https://crates.io/crates/kigi-http)
- [kigi-hunk-tracker 0.1.18](https://crates.io/crates/kigi-hunk-tracker) - [kigi-hunk-tracker 0.1.19](https://crates.io/crates/kigi-hunk-tracker)
- [kigi-log 0.1.18](https://crates.io/crates/kigi-log) - [kigi-log 0.1.19](https://crates.io/crates/kigi-log)
- [kigi-markdown 0.1.18](https://crates.io/crates/kigi-markdown) - [kigi-markdown 0.1.19](https://crates.io/crates/kigi-markdown)
- [kigi-markdown-core 0.1.18](https://crates.io/crates/kigi-markdown-core) - [kigi-markdown-core 0.1.19](https://crates.io/crates/kigi-markdown-core)
- [kigi-mcp 0.1.18](https://crates.io/crates/kigi-mcp) - [kigi-mcp 0.1.19](https://crates.io/crates/kigi-mcp)
- [kigi-memory 0.1.18](https://crates.io/crates/kigi-memory) - [kigi-memory 0.1.19](https://crates.io/crates/kigi-memory)
- [kigi-models 0.1.18](https://crates.io/crates/kigi-models) - [kigi-models 0.1.19](https://crates.io/crates/kigi-models)
- [kigi-pager-minimal 0.1.18](https://crates.io/crates/kigi-pager-minimal) - [kigi-pager-minimal 0.1.19](https://crates.io/crates/kigi-pager-minimal)
- [kigi-pager-pty-harness 0.1.18](https://crates.io/crates/kigi-pager-pty-harness) - [kigi-pager-pty-harness 0.1.19](https://crates.io/crates/kigi-pager-pty-harness)
- [kigi-pager-render 0.1.18](https://crates.io/crates/kigi-pager-render) - [kigi-pager-render 0.1.19](https://crates.io/crates/kigi-pager-render)
- [kigi-paths 0.1.18](https://crates.io/crates/kigi-paths) - [kigi-paths 0.1.19](https://crates.io/crates/kigi-paths)
- [kigi-prompt-queue 0.1.18](https://crates.io/crates/kigi-prompt-queue) - [kigi-prompt-queue 0.1.19](https://crates.io/crates/kigi-prompt-queue)
- [kigi-ratatui-inline 0.1.18](https://crates.io/crates/kigi-ratatui-inline) - [kigi-ratatui-inline 0.1.19](https://crates.io/crates/kigi-ratatui-inline)
- [kigi-ratatui-textarea 0.1.18](https://crates.io/crates/kigi-ratatui-textarea) - [kigi-ratatui-textarea 0.1.19](https://crates.io/crates/kigi-ratatui-textarea)
- [kigi-sampler 0.1.18](https://crates.io/crates/kigi-sampler) - [kigi-sampler 0.1.19](https://crates.io/crates/kigi-sampler)
- [kigi-sampling-types 0.1.18](https://crates.io/crates/kigi-sampling-types) - [kigi-sampling-types 0.1.19](https://crates.io/crates/kigi-sampling-types)
- [kigi-sandbox 0.1.18](https://crates.io/crates/kigi-sandbox) - [kigi-sandbox 0.1.19](https://crates.io/crates/kigi-sandbox)
- [kigi-secrets 0.1.18](https://crates.io/crates/kigi-secrets) - [kigi-secrets 0.1.19](https://crates.io/crates/kigi-secrets)
- [kigi-shared 0.0.0](https://crates.io/crates/kigi-shared) - [kigi-shared 0.0.0](https://crates.io/crates/kigi-shared)
- [kigi-shell 0.1.18](https://crates.io/crates/kigi-shell) - [kigi-shell 0.1.19](https://crates.io/crates/kigi-shell)
- [kigi-shell-base 0.1.18](https://crates.io/crates/kigi-shell-base) - [kigi-shell-base 0.1.19](https://crates.io/crates/kigi-shell-base)
- [kigi-sqlite-journal 0.1.18](https://crates.io/crates/kigi-sqlite-journal) - [kigi-sqlite-journal 0.1.19](https://crates.io/crates/kigi-sqlite-journal)
- [kigi-subagent-resolution 0.1.18](https://crates.io/crates/kigi-subagent-resolution) - [kigi-subagent-resolution 0.1.19](https://crates.io/crates/kigi-subagent-resolution)
- [kigi-system-power 0.1.18](https://crates.io/crates/kigi-system-power) - [kigi-system-power 0.1.19](https://crates.io/crates/kigi-system-power)
- [kigi-test-support 0.1.18](https://crates.io/crates/kigi-test-support) - [kigi-test-support 0.1.19](https://crates.io/crates/kigi-test-support)
- [kigi-token-estimation 0.1.18](https://crates.io/crates/kigi-token-estimation) - [kigi-token-estimation 0.1.19](https://crates.io/crates/kigi-token-estimation)
- [kigi-tools 0.1.18](https://crates.io/crates/kigi-tools) - [kigi-tools 0.1.19](https://crates.io/crates/kigi-tools)
- [kigi-tools-api 0.1.18](https://crates.io/crates/kigi-tools-api) - [kigi-tools-api 0.1.19](https://crates.io/crates/kigi-tools-api)
- [kigi-tracing-macros 0.1.18](https://crates.io/crates/kigi-tracing-macros) - [kigi-tracing-macros 0.1.19](https://crates.io/crates/kigi-tracing-macros)
- [kigi-tty-utils 0.1.18](https://crates.io/crates/kigi-tty-utils) - [kigi-tty-utils 0.1.19](https://crates.io/crates/kigi-tty-utils)
- [kigi-tui 0.1.18](https://crates.io/crates/kigi-tui) - [kigi-tui 0.1.19](https://crates.io/crates/kigi-tui)
- [kigi-update 0.1.18](https://crates.io/crates/kigi-update) - [kigi-update 0.1.19](https://crates.io/crates/kigi-update)
- [kigi-version 0.1.18](https://crates.io/crates/kigi-version) - [kigi-version 0.1.19](https://crates.io/crates/kigi-version)
- [kigi-workspace 0.1.18](https://crates.io/crates/kigi-workspace) - [kigi-workspace 0.1.19](https://crates.io/crates/kigi-workspace)
- [kigi-workspace-types 0.1.18](https://crates.io/crates/kigi-workspace-types) - [kigi-workspace-types 0.1.19](https://crates.io/crates/kigi-workspace-types)
- [ptyctl 0.1.18](https://crates.io/crates/ptyctl) - [ptyctl 0.1.19](https://crates.io/crates/ptyctl)
- [ptyctl-cli 0.1.18](https://crates.io/crates/ptyctl-cli) - [ptyctl-cli 0.1.19](https://crates.io/crates/ptyctl-cli)
- [kigi-compaction 0.1.18](https://crates.io/crates/kigi-compaction) - [kigi-compaction 0.1.19](https://crates.io/crates/kigi-compaction)
- [kigi-interjection-core 0.1.18](https://crates.io/crates/kigi-interjection-core) - [kigi-interjection-core 0.1.19](https://crates.io/crates/kigi-interjection-core)
- [kigi-test-utils 0.1.18](https://crates.io/crates/kigi-test-utils) - [kigi-test-utils 0.1.19](https://crates.io/crates/kigi-test-utils)
- [kigi-tool-protocol 0.1.18](https://crates.io/crates/kigi-tool-protocol) - [kigi-tool-protocol 0.1.19](https://crates.io/crates/kigi-tool-protocol)
- [kigi-tool-runtime 0.1.18](https://crates.io/crates/kigi-tool-runtime) - [kigi-tool-runtime 0.1.19](https://crates.io/crates/kigi-tool-runtime)
- [kigi-tool-types 0.1.18](https://crates.io/crates/kigi-tool-types) - [kigi-tool-types 0.1.19](https://crates.io/crates/kigi-tool-types)
- [agent-client-protocol 0.10.4](https://github.com/agentclientprotocol/rust-sdk) - [agent-client-protocol 0.10.4](https://github.com/agentclientprotocol/rust-sdk)
- [allocator-api2 0.2.21](https://github.com/zakarumych/allocator-api2) - [allocator-api2 0.2.21](https://github.com/zakarumych/allocator-api2)
- [anes 0.1.6](https://github.com/zrzka/anes-rs) - [anes 0.1.6](https://github.com/zrzka/anes-rs)
@@ -16772,7 +16772,7 @@ limitations under the License.
Applies to: Applies to:
- [kigi-mermaid 0.1.18](https://crates.io/crates/kigi-mermaid) - [kigi-mermaid 0.1.19](https://crates.io/crates/kigi-mermaid)
``` ```
Roboto-Regular.ttf Roboto-Regular.ttf
+1 -1
View File
@@ -165,7 +165,7 @@ pub fn normalize_base_url(raw: &str) -> Result<String, CustomProviderError> {
Ok(url.to_owned()) Ok(url.to_owned())
} }
/// A valid provider name from a base URL's host, for a login default. /// A valid provider name derived from a host.
pub fn default_name(base_url: &str) -> String { pub fn default_name(base_url: &str) -> String {
let host = base_url let host = base_url
.split("://") .split("://")
@@ -599,7 +599,7 @@ mod tests {
); );
} }
/// `custom:<name>` is an API-key login; the picker rows are not loginable. /// `custom:<name>` logs in; picker rows cannot.
#[test] #[test]
fn custom_provider_method_ids_classify_as_api_key() { fn custom_provider_method_ids_classify_as_api_key() {
let kind = AuthMethodKind::from_id(&acp::AuthMethodId::new("custom:my-proxy")); let kind = AuthMethodKind::from_id(&acp::AuthMethodId::new("custom:my-proxy"));
@@ -3960,8 +3960,7 @@ pub fn resolve_model_auth_facts(model_id: &str) -> ModelAuthFacts {
}, },
}) })
} }
/// Auth facts of a catalog entry the caller already holds. A fetched entry /// Auth facts of a held live-catalog entry.
/// exists only in the live catalog, never in a disk reload.
pub(crate) fn auth_facts_of(entry: &ModelEntry) -> ModelAuthFacts { pub(crate) fn auth_facts_of(entry: &ModelEntry) -> ModelAuthFacts {
ModelAuthFacts { ModelAuthFacts {
byok: if entry.has_own_credentials() { byok: if entry.has_own_credentials() {
@@ -5286,7 +5285,7 @@ reasoning_effort = "low"
auth_scheme: Default::default(), auth_scheme: Default::default(),
} }
} }
/// A fetched entry's scheme and BYOK status come from the entry itself. /// Scheme and BYOK status come from the entry.
#[test] #[test]
fn auth_facts_come_from_the_held_entry() { fn auth_facts_come_from_the_held_entry() {
let mut model = test_model_entry("claude-x", "https://gw.example/v1", None, None, None); let mut model = test_model_entry("claude-x", "https://gw.example/v1", None, None, None);
@@ -9,7 +9,7 @@ const PICKER_PREFIX: &str = "custom-";
const LOGIN_PREFIX: &str = "custom:"; const LOGIN_PREFIX: &str = "custom:";
const ALL_APIS: [CustomApi; 2] = [CustomApi::OpenAi, CustomApi::Anthropic]; const ALL_APIS: [CustomApi; 2] = [CustomApi::OpenAi, CustomApi::Anthropic];
/// The picker row that starts the custom provider flow for one wire. /// The picker row for one wire.
pub fn picker_method(api: CustomApi) -> acp::AuthMethod { pub fn picker_method(api: CustomApi) -> acp::AuthMethod {
acp::AuthMethod::Agent( acp::AuthMethod::Agent(
acp::AuthMethodAgent::new( acp::AuthMethodAgent::new(
@@ -41,7 +41,7 @@ pub fn login_provider_name(id: &str) -> Option<&str> {
id.strip_prefix(LOGIN_PREFIX) id.strip_prefix(LOGIN_PREFIX)
} }
/// Probes the listing endpoint with the key; the error text never holds the key. /// Probes the listing endpoint; errors never hold the key.
pub(crate) async fn validate_key(credentialed: &CredentialedProvider) -> Result<(), String> { pub(crate) async fn validate_key(credentialed: &CredentialedProvider) -> Result<(), String> {
let provider = &credentialed.provider; let provider = &credentialed.provider;
let url = provider.models_url(); let url = provider.models_url();
@@ -553,7 +553,7 @@ impl MvpAgent {
tracing::warn!(provider = name, %message, "custom provider login failed"); tracing::warn!(provider = name, %message, "custom provider login failed");
emit_login_span( emit_login_span(
false, false,
"custom-provider", method_id.0.as_ref(),
None, None,
Some("custom_provider_invalid_or_missing"), Some("custom_provider_invalid_or_missing"),
); );
@@ -561,7 +561,7 @@ impl MvpAgent {
} }
Ok(self.finish_api_key_login(method_id).await) Ok(self.finish_api_key_login(method_id).await)
} }
/// Shared tail of an API-key login: reload config, refresh the catalog. /// Shared tail of an API-key login.
async fn finish_api_key_login(&self, method_id: acp::AuthMethodId) -> AuthenticateResponse { async fn finish_api_key_login(&self, method_id: acp::AuthMethodId) -> AuthenticateResponse {
// Rebuild the catalog from the on-disk config: the rebuild freshly // Rebuild the catalog from the on-disk config: the rebuild freshly
// resolves platform keys (env > auth.json > config), so the key just // resolves platform keys (env > auth.json > config), so the key just
@@ -879,6 +879,20 @@ fn log_subagent_model_resolution(
)), )),
); );
} }
/// The parent model's auth scheme from the live catalog.
fn parent_auth_scheme(
available: &indexmap::IndexMap<String, crate::agent::config::ModelEntry>,
catalog_id: &acp::ModelId,
slug: &str,
) -> kigi_sampler::AuthScheme {
crate::agent::models::entry_for_slug(available, Some(catalog_id.0.as_ref()), slug)
.map(|entry| crate::agent::config::auth_facts_of(entry).auth_scheme)
.or_else(|| {
crate::agent::config::try_resolve_model_credentials(slug, None).map(|r| r.auth_scheme)
})
.unwrap_or_default()
}
/// Read the parent session's actual current sampling config. /// Read the parent session's actual current sampling config.
/// ///
/// Prefers the live state from `ChatStateHandle` (authoritative). Falls back /// Prefers the live state from `ChatStateHandle` (authoritative). Falls back
@@ -897,17 +911,7 @@ async fn read_parent_sampling_config(
creds.alpha_test_key.as_deref(), creds.alpha_test_key.as_deref(),
&cfg.base_url, &cfg.base_url,
); );
let auth_scheme = crate::agent::models::entry_for_slug( let auth_scheme = parent_auth_scheme(&ctx.available_models, &ctx.model_id, &cfg.model);
&ctx.available_models,
Some(ctx.model_id.0.as_ref()),
&cfg.model,
)
.map(|entry| crate::agent::config::auth_facts_of(entry).auth_scheme)
.or_else(|| {
crate::agent::config::try_resolve_model_credentials(&cfg.model, None)
.map(|r| r.auth_scheme)
})
.unwrap_or_default();
// Claude Pro/Max OAuth Messages adaptation inherits from the parent // Claude Pro/Max OAuth Messages adaptation inherits from the parent
// model's platform (claude-pro-max → true); every other platform, // model's platform (claude-pro-max → true); every other platform,
// and BYOK, → false, so the API-key paths stay byte-identical. // and BYOK, → false, so the API-key paths stay byte-identical.
@@ -3322,3 +3322,24 @@ async fn parent_ack_is_bounded_when_the_parent_never_answers() {
.expect("parent acks must complete in bounded time"); .expect("parent acks must complete in bounded time");
assert!(!acked, "an unanswered ack must report a miss"); assert!(!acked, "an unanswered ack must report a miss");
} }
/// A fetched Messages model exists only in the live catalog.
#[test]
fn a_fetched_entry_gives_its_own_scheme_to_the_child() {
let wire: kigi_models::WireModel =
serde_json::from_value(serde_json::json!({ "id": "claude-x" })).unwrap();
let cfg = crate::agent::models_fetch::wire_model_to_entry(
"gw/claude-x".into(),
kigi_models::PlatformWireApi::Messages,
kigi_models::PlatformKeyHeader::XApiKey,
None,
true,
wire,
"https://gw.example/v1",
);
let available = indexmap::IndexMap::from([(
"gw/claude-x".to_owned(),
crate::agent::config::ModelEntry::from_config_entry(&cfg),
)]);
let scheme = parent_auth_scheme(&available, &acp::ModelId::new("gw/claude-x"), "claude-x");
assert_eq!(scheme, kigi_sampler::AuthScheme::XApiKey);
}
+3 -4
View File
@@ -570,9 +570,9 @@ pub enum Action {
/// under the platform-id scope, then authenticate with the platform's /// under the platform-id scope, then authenticate with the platform's
/// method id. The key must never be logged. /// method id. The key must never be logged.
SubmitPlatformApiKey(String), SubmitPlatformApiKey(String),
/// A custom provider row was picked: start the URL, name, key steps. /// Custom provider row picked: open the URL step.
BeginCustomProviderEntry(kigi_shell::models::custom::CustomApi), BeginCustomProviderEntry(kigi_shell::models::custom::CustomApi),
/// Enter in a custom provider step, with the trimmed input. /// Enter in a custom provider step.
SubmitCustomProviderInput(String), SubmitCustomProviderInput(String),
/// Copy the auth URL to the clipboard during authentication. /// Copy the auth URL to the clipboard during authentication.
CopyAuthUrl, CopyAuthUrl,
@@ -1618,8 +1618,7 @@ pub enum Effect {
target: crate::app::app_view::PlatformLogin, target: crate::app::app_view::PlatformLogin,
key: String, key: String,
}, },
/// Save a custom provider (config.toml and auth.json), then send /// Saves the provider, then authenticates; never log the key.
/// AuthenticateRequest with `custom:<name>`. SECURITY: never log the key.
PersistCustomProviderAndAuthenticate { PersistCustomProviderAndAuthenticate {
request_seq: u64, request_seq: u64,
provider: kigi_shell::models::custom::CustomProvider, provider: kigi_shell::models::custom::CustomProvider,
+1 -1
View File
@@ -262,7 +262,7 @@ pub enum AuthMode {
/// Open-platform API-key entry: paste box for a Moonshot key selected /// Open-platform API-key entry: paste box for a Moonshot key selected
/// from the welcome login picker. Esc returns to the picker (no quit). /// from the welcome login picker. Esc returns to the picker (no quit).
ApiKeyEntry(PlatformLogin), ApiKeyEntry(PlatformLogin),
/// Custom provider login: one field per step; Esc returns to the picker. /// Custom provider login, one field per step.
CustomProviderEntry(crate::app::custom_entry::CustomEntryStep), CustomProviderEntry(crate::app::custom_entry::CustomEntryStep),
} }
/// API-key platform login target, selected from the welcome picker. Wraps a /// API-key platform login target, selected from the welcome picker. Wraps a
@@ -1,4 +1,4 @@
//! The base URL, name, and key steps of the custom provider login. //! Custom provider login steps: base URL, name, key.
use kigi_shell::models::custom::{ use kigi_shell::models::custom::{
CustomApi, CustomProvider, default_name, normalize_base_url, validate_name, CustomApi, CustomProvider, default_name, normalize_base_url, validate_name,
@@ -26,7 +26,7 @@ impl CustomEntryStep {
} }
} }
/// Only the key is a secret; URL and name show as typed. /// Only the key is masked.
pub fn masks_input(self) -> bool { pub fn masks_input(self) -> bool {
self.field == CustomEntryField::Key self.field == CustomEntryField::Key
} }
@@ -43,9 +43,9 @@ impl CustomEntryStep {
/// What one Enter press did. /// What one Enter press did.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum CustomEntryOutcome { pub enum CustomEntryOutcome {
/// The input stays; `CustomEntryDraft::error` says why, if it does. /// The input stays; the draft error says why.
Stay, Stay,
/// Move to the next field with this text in the box. /// Next field, with this text in the box.
Next { Next {
field: CustomEntryField, field: CustomEntryField,
prefill: String, prefill: String,
@@ -326,7 +326,7 @@ pub(super) fn dispatch_begin_platform_key_entry(
vec![] vec![]
} }
/// A custom provider row was selected: open the first step (base URL). /// Custom provider row selected: open the URL step.
pub(super) fn dispatch_begin_custom_provider_entry( pub(super) fn dispatch_begin_custom_provider_entry(
app: &mut AppView, app: &mut AppView,
api: kigi_shell::models::custom::CustomApi, api: kigi_shell::models::custom::CustomApi,
@@ -344,7 +344,7 @@ pub(super) fn dispatch_begin_custom_provider_entry(
vec![] vec![]
} }
/// Enter in a custom provider step: advance, stay with a reason, or save. /// Enter in a custom provider step.
pub(super) fn dispatch_submit_custom_provider_input( pub(super) fn dispatch_submit_custom_provider_input(
app: &mut AppView, app: &mut AppView,
input: String, input: String,
@@ -582,8 +582,7 @@ fn custom_field(app: &AppView) -> crate::app::custom_entry::CustomEntryField {
} }
} }
/// The custom provider flow: URL, then name (prefilled from the host), then /// URL, name, key; the last Enter emits one persist effect.
/// key; the last Enter emits ONE persist+authenticate effect for the provider.
#[test] #[test]
fn custom_provider_steps_end_in_one_persist_effect() { fn custom_provider_steps_end_in_one_persist_effect() {
use crate::app::custom_entry::CustomEntryField; use crate::app::custom_entry::CustomEntryField;
@@ -649,7 +648,7 @@ fn custom_provider_steps_end_in_one_persist_effect() {
assert!(app.auth_code_input.is_empty()); assert!(app.auth_code_input.is_empty());
} }
/// A refused field keeps the user on it and does not emit an effect. /// A refused field keeps the user on it.
#[test] #[test]
fn custom_provider_refusals_stay_on_the_field() { fn custom_provider_refusals_stay_on_the_field() {
use crate::app::custom_entry::CustomEntryField; use crate::app::custom_entry::CustomEntryField;
@@ -687,7 +686,7 @@ fn custom_provider_refusals_stay_on_the_field() {
assert!(app.custom_entry.error.is_some()); assert!(app.custom_entry.error.is_some());
} }
/// Esc at any step returns to the picker and drops the draft. /// Esc returns to the picker and drops the draft.
#[test] #[test]
fn cancel_custom_provider_entry_returns_to_picker() { fn cancel_custom_provider_entry_returns_to_picker() {
use kigi_shell::models::custom::CustomApi; use kigi_shell::models::custom::CustomApi;
@@ -1294,7 +1294,7 @@ fn render_welcome_authenticating(
} }
AuthMode::ApiKeyEntry(target) => { AuthMode::ApiKeyEntry(target) => {
// Platform API-key paste box: the key comes from the platform console. // Platform API-key paste box.
let instruction = format!( let instruction = format!(
"Paste your {} API key (from {})", "Paste your {} API key (from {})",
target.vendor(), target.vendor(),
@@ -1938,8 +1938,7 @@ pub(crate) fn render_session_picker(
) )
} }
/// Render the auth token input box (loopback mode). /// One text field under the logo.
/// One text field under the logo: instruction, optional error, input box, hints.
struct EntryBox<'a> { struct EntryBox<'a> {
instruction: &'a str, instruction: &'a str,
error: Option<&'a str>, error: Option<&'a str>,
@@ -2035,6 +2034,7 @@ fn render_entry_box(
Paragraph::new(hints).render(hint_area, buf); Paragraph::new(hints).render(hint_area, buf);
} }
/// Render the auth token input box (loopback mode).
fn render_auth_input_box( fn render_auth_input_box(
area: Rect, area: Rect,
buf: &mut Buffer, buf: &mut Buffer,
@@ -2393,8 +2393,6 @@ mod tests {
assert!(!text.contains("Moonshot"), "{text}"); assert!(!text.contains("Moonshot"), "{text}");
} }
/// The Moonshot API-key entry arm renders the platform copy, the paste
/// box, and the esc-back hint — and no OAuth-URL affordances.
fn render_custom_entry( fn render_custom_entry(
step: crate::app::custom_entry::CustomEntryStep, step: crate::app::custom_entry::CustomEntryStep,
draft: &crate::app::custom_entry::CustomEntryDraft, draft: &crate::app::custom_entry::CustomEntryDraft,
@@ -2417,7 +2415,7 @@ mod tests {
buffer_text(&buf) buffer_text(&buf)
} }
/// The URL and name steps show typed text; only the key step masks it. /// Only the key step masks its input.
#[test] #[test]
fn custom_entry_arm_masks_only_the_key() { fn custom_entry_arm_masks_only_the_key() {
use crate::app::custom_entry::{CustomEntryDraft, CustomEntryField, CustomEntryStep}; use crate::app::custom_entry::{CustomEntryDraft, CustomEntryField, CustomEntryStep};
@@ -2447,7 +2445,7 @@ mod tests {
assert!(empty.contains("provider name"), "{empty}"); assert!(empty.contains("provider name"), "{empty}");
} }
/// A refusal shows under the instruction so the user sees what to fix. /// A refusal shows under the instruction.
#[test] #[test]
fn custom_entry_arm_shows_the_refusal() { fn custom_entry_arm_shows_the_refusal() {
use crate::app::custom_entry::{CustomEntryDraft, CustomEntryStep}; use crate::app::custom_entry::{CustomEntryDraft, CustomEntryStep};
@@ -2460,6 +2458,8 @@ mod tests {
assert!(text.contains("must start with http"), "{text}"); assert!(text.contains("must start with http"), "{text}");
} }
/// The Moonshot API-key entry arm renders the platform copy, the paste
/// box, and the esc-back hint — and no OAuth-URL affordances.
#[test] #[test]
fn api_key_entry_arm_shows_platform_copy_and_paste_box() { fn api_key_entry_arm_shows_platform_copy_and_paste_box() {
let area = Rect::new(0, 0, 80, 40); let area = Rect::new(0, 0, 80, 40);
@@ -57,10 +57,7 @@ async fn run_turn(content: &ContentController) -> PtyHarness {
harness harness
} }
/// A declared OpenAI-compatible provider supplies the catalog and the turn: /// An OpenAI provider lists models and uses its own key.
/// the request goes to `/chat/completions` for the fetched model with the
/// provider's own key. The house key, which is set in this environment on the
/// same loopback URL as the session's coding endpoint, never rides it.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore] #[ignore]
async fn custom_openai_provider_lists_models_and_uses_its_own_key() { async fn custom_openai_provider_lists_models_and_uses_its_own_key() {
@@ -94,8 +91,7 @@ async fn custom_openai_provider_lists_models_and_uses_its_own_key() {
harness.quit().expect("clean quit"); harness.quit().expect("clean quit");
} }
/// An Anthropic-compatible provider is reached on `/messages` with /// An Anthropic provider uses `/messages` with `x-api-key`.
/// `x-api-key` and `anthropic-version`, and no Bearer header.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore] #[ignore]
async fn custom_anthropic_provider_uses_messages_and_x_api_key() { async fn custom_anthropic_provider_uses_messages_and_x_api_key() {
@@ -127,3 +123,37 @@ async fn custom_anthropic_provider_uses_messages_and_x_api_key() {
} }
harness.quit().expect("clean quit"); harness.quit().expect("clean quit");
} }
/// A saved provider alone is a complete login.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore]
async fn custom_provider_alone_authenticates_at_startup() {
let content = ContentController::start_with_models(vec![MockModel::new("custom-m1")])
.await
.expect("start content");
declare_provider(&content, "openai");
content.set_response(format!(
"{MOCK_RESPONSE_SENTINEL} from the custom provider."
));
let env: Vec<(String, String)> = content
.env_for_pager()
.into_iter()
.filter(|(name, _)| name != "KIGI_API_KEY")
.collect();
let env_refs: Vec<(&str, &str)> = env.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
let binary = pager_binary().expect("resolve pager binary");
let mut harness =
PtyHarness::new_in_dir(&binary, DEFAULT_ROWS, DEFAULT_COLS, &[], &env_refs, None)
.expect("spawn pager without a house key");
harness
.wait_for_text(WELCOME_SCREEN_SENTINEL, WELCOME_TIMEOUT)
.expect("welcome text");
harness
.inject_keys(format!("{PROMPT}\r").as_bytes())
.expect("submit prompt");
harness
.wait_for_text(MOCK_RESPONSE_SENTINEL, Duration::from_secs(30))
.expect("the turn reaches the custom provider without a login screen");
harness.quit().expect("clean quit");
}