@oneciel-ai/ciel-runtime 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ciel_runtime.py +2553 -9635
- package/ciel_runtime_support/advisor_request_builder.py +8 -21
- package/ciel_runtime_support/anthropic_tool_turns.py +13 -8
- package/ciel_runtime_support/architecture.py +68 -0
- package/ciel_runtime_support/architecture_budget.py +1 -1
- package/ciel_runtime_support/channel_connection_context.py +233 -0
- package/ciel_runtime_support/channel_delivery_context.py +332 -0
- package/ciel_runtime_support/channel_mcp_context.py +313 -0
- package/ciel_runtime_support/channel_mcp_discovery.py +47 -0
- package/ciel_runtime_support/channel_mcp_transport.py +5 -1
- package/ciel_runtime_support/channel_message_context.py +212 -0
- package/ciel_runtime_support/channel_message_repository.py +14 -3
- package/ciel_runtime_support/channel_pending_injection.py +9 -0
- package/ciel_runtime_support/channel_probe_launch_context.py +213 -0
- package/ciel_runtime_support/channel_replay_policy.py +38 -0
- package/ciel_runtime_support/channel_runtime_environment.py +8 -0
- package/ciel_runtime_support/channel_session_context.py +236 -0
- package/ciel_runtime_support/channel_terminal_context.py +350 -0
- package/ciel_runtime_support/channel_wake_context.py +532 -0
- package/ciel_runtime_support/claude_environment.py +60 -0
- package/ciel_runtime_support/claude_launch_assembly.py +249 -0
- package/ciel_runtime_support/claude_router.py +62 -12
- package/ciel_runtime_support/cli_application_context.py +132 -0
- package/ciel_runtime_support/cli_assembly.py +50 -0
- package/ciel_runtime_support/codex_backend_context.py +363 -0
- package/ciel_runtime_support/codex_config.py +13 -1
- package/ciel_runtime_support/codex_launch_assembly.py +213 -0
- package/ciel_runtime_support/codex_launch_configuration.py +30 -1
- package/ciel_runtime_support/codex_mcp_integration.py +90 -8
- package/ciel_runtime_support/codex_model_catalog.py +4 -1
- package/ciel_runtime_support/codex_reasoning_rejects.py +225 -0
- package/ciel_runtime_support/codex_router.py +38 -8
- package/ciel_runtime_support/codex_turn_recovery.py +154 -0
- package/ciel_runtime_support/config_migrations.py +103 -0
- package/ciel_runtime_support/configuration_cli.py +38 -0
- package/ciel_runtime_support/context_compaction.py +9 -4
- package/ciel_runtime_support/credential_management.py +12 -0
- package/ciel_runtime_support/credentials.py +12 -0
- package/ciel_runtime_support/github_copilot_oauth.py +2 -2
- package/ciel_runtime_support/hosted_formula_tools.py +216 -0
- package/ciel_runtime_support/kimi_runtime_context.py +208 -0
- package/ciel_runtime_support/llm_preset_context.py +338 -0
- package/ciel_runtime_support/managed_mcp_config.py +8 -4
- package/ciel_runtime_support/mcp_configuration_context.py +291 -0
- package/ciel_runtime_support/mcp_http_proxy.py +14 -8
- package/ciel_runtime_support/mcp_probe_transport.py +47 -15
- package/ciel_runtime_support/mcp_transport.py +14 -1
- package/ciel_runtime_support/native_context_recovery.py +72 -0
- package/ciel_runtime_support/ollama_catalog_context.py +213 -0
- package/ciel_runtime_support/ollama_stream_collection.py +103 -0
- package/ciel_runtime_support/ollama_thinking.py +6 -1
- package/ciel_runtime_support/ollama_wire_projection.py +157 -0
- package/ciel_runtime_support/openai_forwarding.py +32 -10
- package/ciel_runtime_support/openai_responses_router.py +12 -0
- package/ciel_runtime_support/package_lifecycle.py +39 -0
- package/ciel_runtime_support/prelaunch_assembly.py +37 -0
- package/ciel_runtime_support/prelaunch_panel_context.py +418 -0
- package/ciel_runtime_support/prelaunch_shell_context.py +394 -0
- package/ciel_runtime_support/prompt_compaction.py +144 -0
- package/ciel_runtime_support/prompt_injection.py +45 -0
- package/ciel_runtime_support/protocols/anthropic_thinking_policy.py +1 -1
- package/ciel_runtime_support/protocols/chat_projection.py +85 -5
- package/ciel_runtime_support/protocols/conversation_turn_policy.py +43 -0
- package/ciel_runtime_support/protocols/ollama_chat.py +31 -0
- package/ciel_runtime_support/protocols/ollama_response.py +57 -5
- package/ciel_runtime_support/protocols/openai_reasoning.py +5 -2
- package/ciel_runtime_support/protocols/openai_responses.py +61 -15
- package/ciel_runtime_support/provider_adapters.py +26 -0
- package/ciel_runtime_support/provider_administration_context.py +207 -0
- package/ciel_runtime_support/provider_config_mutations.py +3 -0
- package/ciel_runtime_support/provider_model_catalog_context.py +137 -0
- package/ciel_runtime_support/provider_model_context.py +107 -0
- package/ciel_runtime_support/provider_model_metadata_context.py +197 -0
- package/ciel_runtime_support/provider_model_selection.py +10 -3
- package/ciel_runtime_support/provider_models.py +45 -2
- package/ciel_runtime_support/provider_option_cli.py +19 -0
- package/ciel_runtime_support/provider_policy.py +1 -1
- package/ciel_runtime_support/provider_readiness_context.py +189 -0
- package/ciel_runtime_support/provider_request_builder.py +64 -28
- package/ciel_runtime_support/provider_responses_passthrough.py +21 -2
- package/ciel_runtime_support/provider_timeout_policy.py +54 -0
- package/ciel_runtime_support/provider_tool_policy.py +9 -1
- package/ciel_runtime_support/providers/__init__.py +6 -0
- package/ciel_runtime_support/providers/alibaba.py +634 -0
- package/ciel_runtime_support/providers/catalog.py +24 -16
- package/ciel_runtime_support/providers/deepseek.py +73 -0
- package/ciel_runtime_support/providers/github_copilot_oauth.py +22 -1
- package/ciel_runtime_support/providers/kimi.py +69 -9
- package/ciel_runtime_support/providers/ollama.py +8 -0
- package/ciel_runtime_support/providers/ollama_context.py +21 -2
- package/ciel_runtime_support/providers/vllm.py +7 -1
- package/ciel_runtime_support/response_collection.py +68 -18
- package/ciel_runtime_support/response_collection_context.py +391 -0
- package/ciel_runtime_support/response_stream_context.py +555 -0
- package/ciel_runtime_support/responses_input_compatibility.py +121 -0
- package/ciel_runtime_support/responses_usage_observer.py +83 -0
- package/ciel_runtime_support/router_client_lifecycle.py +1 -0
- package/ciel_runtime_support/router_http.py +239 -3
- package/ciel_runtime_support/router_observability_context.py +251 -0
- package/ciel_runtime_support/router_process_context.py +200 -0
- package/ciel_runtime_support/router_process_lifecycle.py +2 -0
- package/ciel_runtime_support/router_request_assembly.py +399 -0
- package/ciel_runtime_support/router_request_context.py +215 -0
- package/ciel_runtime_support/router_server_context.py +82 -0
- package/ciel_runtime_support/runaway_output_guard.py +488 -0
- package/ciel_runtime_support/runtime_asset_assembly.py +147 -0
- package/ciel_runtime_support/runtime_asset_context.py +297 -0
- package/ciel_runtime_support/runtime_constants.py +16 -1
- package/ciel_runtime_support/runtime_launch.py +9 -5
- package/ciel_runtime_support/runtime_launch_context.py +130 -0
- package/ciel_runtime_support/runtime_maintenance_assembly.py +60 -0
- package/ciel_runtime_support/runtime_maintenance_context.py +309 -0
- package/ciel_runtime_support/runtime_maintenance_services.py +265 -0
- package/ciel_runtime_support/runtime_paths.py +60 -40
- package/ciel_runtime_support/runtime_primitives.py +78 -0
- package/ciel_runtime_support/sse_stream_collection.py +236 -0
- package/ciel_runtime_support/statusline_script.py +57 -8
- package/ciel_runtime_support/streaming_anthropic.py +361 -24
- package/ciel_runtime_support/tool_schema.py +40 -2
- package/ciel_runtime_support/tool_side_effect_dedupe.py +117 -12
- package/ciel_runtime_support/upstream_dump.py +68 -0
- package/ciel_runtime_support/upstream_retry_context.py +259 -0
- package/ciel_runtime_support/workspace_router_selection.py +86 -0
- package/docs/Configuration.md +50 -0
- package/docs/Test-Suite.md +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"""Prelaunch menu panel composition bounded context."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any, Callable, Mapping, Sequence
|
|
7
|
+
|
|
8
|
+
from .architecture import ProviderUiPolicy
|
|
9
|
+
from .channel_panel import (
|
|
10
|
+
ChannelPanelPolicy,
|
|
11
|
+
channel_delivery_panel_rows as project_channel_delivery_panel_rows,
|
|
12
|
+
channel_panel_rows as project_channel_panel_rows,
|
|
13
|
+
)
|
|
14
|
+
from .model_panel import (
|
|
15
|
+
ModelPanelCatalog,
|
|
16
|
+
ModelPanelPresentation,
|
|
17
|
+
ModelPanelServices,
|
|
18
|
+
advisor_model_panel_rows as project_advisor_model_panel_rows,
|
|
19
|
+
model_panel_rows as project_model_panel_rows,
|
|
20
|
+
)
|
|
21
|
+
from .prelaunch_panel_projection import (
|
|
22
|
+
ConfigurationPanelPorts,
|
|
23
|
+
ConfigurationPanelProjection,
|
|
24
|
+
MainMenuProjection,
|
|
25
|
+
MainMenuProjectionPorts,
|
|
26
|
+
ProviderPanelConstants,
|
|
27
|
+
ProviderPanelPorts,
|
|
28
|
+
ProviderPanelProjection,
|
|
29
|
+
)
|
|
30
|
+
from .web_endpoints import (
|
|
31
|
+
update_web_backend_config,
|
|
32
|
+
web_backend_panel_rows as project_web_backend_panel_rows,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
PanelRows = tuple[list[str], list[str]]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True, slots=True)
|
|
39
|
+
class MainMenuPanelPorts:
|
|
40
|
+
languages: Mapping[str, str]
|
|
41
|
+
ui_text: Callable[..., str]
|
|
42
|
+
compact_text: Callable[[Any, int], str]
|
|
43
|
+
provider_label: Callable[[str, dict[str, Any]], str]
|
|
44
|
+
stored_api_key_mask: Callable[[dict[str, Any]], str]
|
|
45
|
+
llm_options_status: Callable[[str, dict[str, Any]], str]
|
|
46
|
+
log_level_status: Callable[[dict[str, Any]], str]
|
|
47
|
+
supports_runtime: Callable[[str, str], bool]
|
|
48
|
+
provider_family: Callable[[str], str]
|
|
49
|
+
provider_ui_policy: Callable[[str, dict[str, Any]], ProviderUiPolicy]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass(frozen=True, slots=True)
|
|
53
|
+
class WebBackendPanelPorts:
|
|
54
|
+
router_port: int
|
|
55
|
+
load_config: Callable[[], dict[str, Any]]
|
|
56
|
+
save_config: Callable[[dict[str, Any]], None]
|
|
57
|
+
clear_model_cache: Callable[[], None]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass(frozen=True, slots=True)
|
|
61
|
+
class ProviderChoicePanelPorts:
|
|
62
|
+
constants: ProviderPanelConstants
|
|
63
|
+
anthropic_routed: Callable[..., bool]
|
|
64
|
+
agy_routed: Callable[..., bool]
|
|
65
|
+
codex_routed: Callable[..., bool]
|
|
66
|
+
has_api_key: Callable[[str, dict[str, Any]], bool]
|
|
67
|
+
compact_text: Callable[[Any, int], str]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass(frozen=True, slots=True)
|
|
71
|
+
class ConfigurationPanelContextPorts:
|
|
72
|
+
languages: Mapping[str, str]
|
|
73
|
+
log_level_names: Sequence[str]
|
|
74
|
+
log_level_name: Callable[[dict[str, Any]], str]
|
|
75
|
+
log_level_status: Callable[[dict[str, Any]], str]
|
|
76
|
+
ui_text: Callable[..., str]
|
|
77
|
+
compact_text: Callable[[Any, int], str]
|
|
78
|
+
default_base_url: Callable[[str], str]
|
|
79
|
+
api_key_count: Callable[[dict[str, Any]], int]
|
|
80
|
+
platform_name: str
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass(frozen=True, slots=True)
|
|
84
|
+
class ModelPanelCatalogPorts:
|
|
85
|
+
alias_for: Callable[..., str]
|
|
86
|
+
cached_or_configured_model_ids: Callable[..., list[str]]
|
|
87
|
+
read_model_info_cache: Callable[..., dict[str, Any]]
|
|
88
|
+
read_model_list_cache: Callable[..., Any]
|
|
89
|
+
unique_model_ids: Callable[..., list[str]]
|
|
90
|
+
upstream_model_ids: Callable[..., list[str]]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(frozen=True, slots=True)
|
|
94
|
+
class ModelPanelPresentationPorts:
|
|
95
|
+
advisor_model_badge: Callable[..., str]
|
|
96
|
+
advisor_panel_notice: Callable[..., str]
|
|
97
|
+
format_context_tokens: Callable[[int | None], str]
|
|
98
|
+
format_parameter_count: Callable[[Any], str]
|
|
99
|
+
model_panel_badge: Callable[..., str]
|
|
100
|
+
normalize_model_id: Callable[..., str]
|
|
101
|
+
positive_int: Callable[[Any], int | None]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@dataclass(frozen=True, slots=True)
|
|
105
|
+
class ChannelPanelContextPorts:
|
|
106
|
+
builtin_router_probe_record: Callable[..., Any]
|
|
107
|
+
channel_specs: Callable[..., Any]
|
|
108
|
+
delivery_mode: Callable[..., str]
|
|
109
|
+
official_plugins: Mapping[str, Any]
|
|
110
|
+
probe_record_bucket: Callable[..., Any]
|
|
111
|
+
read_probe_cache: Callable[..., Any]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass(frozen=True, slots=True)
|
|
115
|
+
class AuthPanelPorts:
|
|
116
|
+
kimi_oauth_configured: Callable[[], bool]
|
|
117
|
+
copilot_panel_rows: Callable[[str], PanelRows | None]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@dataclass(frozen=True, slots=True)
|
|
121
|
+
class PrelaunchPanelContext:
|
|
122
|
+
main: MainMenuPanelPorts
|
|
123
|
+
web: WebBackendPanelPorts
|
|
124
|
+
provider: ProviderChoicePanelPorts
|
|
125
|
+
configuration: ConfigurationPanelContextPorts
|
|
126
|
+
model_catalog: ModelPanelCatalogPorts
|
|
127
|
+
model_presentation: ModelPanelPresentationPorts
|
|
128
|
+
channel: ChannelPanelContextPorts
|
|
129
|
+
auth: AuthPanelPorts
|
|
130
|
+
|
|
131
|
+
def main_menu_projection(self) -> MainMenuProjection:
|
|
132
|
+
ports = self.main
|
|
133
|
+
return MainMenuProjection(
|
|
134
|
+
MainMenuProjectionPorts(
|
|
135
|
+
languages=ports.languages,
|
|
136
|
+
ui_text=ports.ui_text,
|
|
137
|
+
compact_text=ports.compact_text,
|
|
138
|
+
provider_label=ports.provider_label,
|
|
139
|
+
stored_api_key_mask=ports.stored_api_key_mask,
|
|
140
|
+
llm_options_status=ports.llm_options_status,
|
|
141
|
+
log_level_status=ports.log_level_status,
|
|
142
|
+
supports_runtime=ports.supports_runtime,
|
|
143
|
+
provider_family=ports.provider_family,
|
|
144
|
+
provider_ui_policy=ports.provider_ui_policy,
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
def main_menu_rows(
|
|
149
|
+
self,
|
|
150
|
+
config: dict[str, Any],
|
|
151
|
+
provider: str,
|
|
152
|
+
provider_config: dict[str, Any],
|
|
153
|
+
language: str,
|
|
154
|
+
) -> list[str]:
|
|
155
|
+
projected = dict(config)
|
|
156
|
+
projected["_effective_web_port"] = self.web.router_port
|
|
157
|
+
return self.main_menu_projection().rows(
|
|
158
|
+
projected, provider, provider_config, language
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
def web_backend_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
162
|
+
return project_web_backend_panel_rows(config, self.web.router_port)
|
|
163
|
+
|
|
164
|
+
def set_web_backend_config(self, key: str, value: Any) -> list[str]:
|
|
165
|
+
config = self.web.load_config()
|
|
166
|
+
lines = update_web_backend_config(
|
|
167
|
+
config, key, value, self.web.router_port
|
|
168
|
+
)
|
|
169
|
+
self.web.save_config(config)
|
|
170
|
+
self.web.clear_model_cache()
|
|
171
|
+
return lines
|
|
172
|
+
|
|
173
|
+
def provider_panel_projection(self) -> ProviderPanelProjection:
|
|
174
|
+
return ProviderPanelProjection(
|
|
175
|
+
self.provider.constants,
|
|
176
|
+
ProviderPanelPorts(
|
|
177
|
+
anthropic_routed=self.provider.anthropic_routed,
|
|
178
|
+
agy_routed=self.provider.agy_routed,
|
|
179
|
+
codex_routed=self.provider.codex_routed,
|
|
180
|
+
has_api_key=self.provider.has_api_key,
|
|
181
|
+
compact_text=self.provider.compact_text,
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
def provider_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
186
|
+
return self.provider_panel_projection().rows(config)
|
|
187
|
+
|
|
188
|
+
def configuration_panel_projection(self) -> ConfigurationPanelProjection:
|
|
189
|
+
ports = self.configuration
|
|
190
|
+
return ConfigurationPanelProjection(
|
|
191
|
+
ConfigurationPanelPorts(
|
|
192
|
+
languages=ports.languages,
|
|
193
|
+
log_level_names=ports.log_level_names,
|
|
194
|
+
log_level_name=ports.log_level_name,
|
|
195
|
+
log_level_status=ports.log_level_status,
|
|
196
|
+
ui_text=ports.ui_text,
|
|
197
|
+
compact_text=ports.compact_text,
|
|
198
|
+
default_base_url=ports.default_base_url,
|
|
199
|
+
api_key_count=ports.api_key_count,
|
|
200
|
+
platform_name=ports.platform_name,
|
|
201
|
+
)
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
def language_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
205
|
+
return self.configuration_panel_projection().language_rows(config)
|
|
206
|
+
|
|
207
|
+
def log_level_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
208
|
+
return self.configuration_panel_projection().log_level_rows(config)
|
|
209
|
+
|
|
210
|
+
def model_panel_services(self) -> ModelPanelServices:
|
|
211
|
+
catalog = self.model_catalog
|
|
212
|
+
presentation = self.model_presentation
|
|
213
|
+
return ModelPanelServices(
|
|
214
|
+
catalog=ModelPanelCatalog(
|
|
215
|
+
alias_for=catalog.alias_for,
|
|
216
|
+
cached_or_configured_model_ids=catalog.cached_or_configured_model_ids,
|
|
217
|
+
read_model_info_cache=catalog.read_model_info_cache,
|
|
218
|
+
read_model_list_cache=catalog.read_model_list_cache,
|
|
219
|
+
unique_model_ids=catalog.unique_model_ids,
|
|
220
|
+
upstream_model_ids=catalog.upstream_model_ids,
|
|
221
|
+
),
|
|
222
|
+
presentation=ModelPanelPresentation(
|
|
223
|
+
advisor_model_badge=presentation.advisor_model_badge,
|
|
224
|
+
advisor_panel_notice=presentation.advisor_panel_notice,
|
|
225
|
+
format_context_tokens=presentation.format_context_tokens,
|
|
226
|
+
format_parameter_count=presentation.format_parameter_count,
|
|
227
|
+
model_panel_badge=presentation.model_panel_badge,
|
|
228
|
+
normalize_model_id=presentation.normalize_model_id,
|
|
229
|
+
positive_int=presentation.positive_int,
|
|
230
|
+
),
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
def model_panel_rows(
|
|
234
|
+
self,
|
|
235
|
+
provider: str,
|
|
236
|
+
provider_config: dict[str, Any],
|
|
237
|
+
fetch: bool = True,
|
|
238
|
+
force_refresh: bool = False,
|
|
239
|
+
) -> PanelRows:
|
|
240
|
+
return project_model_panel_rows(
|
|
241
|
+
provider,
|
|
242
|
+
provider_config,
|
|
243
|
+
fetch,
|
|
244
|
+
force_refresh,
|
|
245
|
+
services=self.model_panel_services(),
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
def advisor_model_panel_rows(
|
|
249
|
+
self,
|
|
250
|
+
provider: str,
|
|
251
|
+
provider_config: dict[str, Any],
|
|
252
|
+
fetch: bool = True,
|
|
253
|
+
force_refresh: bool = False,
|
|
254
|
+
) -> PanelRows:
|
|
255
|
+
return project_advisor_model_panel_rows(
|
|
256
|
+
provider,
|
|
257
|
+
provider_config,
|
|
258
|
+
fetch,
|
|
259
|
+
force_refresh,
|
|
260
|
+
services=self.model_panel_services(),
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
def channel_panel_policy(self) -> ChannelPanelPolicy:
|
|
264
|
+
ports = self.channel
|
|
265
|
+
return ChannelPanelPolicy(
|
|
266
|
+
builtin_router_probe_record=ports.builtin_router_probe_record,
|
|
267
|
+
channel_specs=ports.channel_specs,
|
|
268
|
+
delivery_mode=ports.delivery_mode,
|
|
269
|
+
official_plugins=ports.official_plugins,
|
|
270
|
+
probe_record_bucket=ports.probe_record_bucket,
|
|
271
|
+
read_probe_cache=ports.read_probe_cache,
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
def channel_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
275
|
+
return project_channel_panel_rows(
|
|
276
|
+
config, policy=self.channel_panel_policy()
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
def channel_delivery_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
280
|
+
return project_channel_delivery_panel_rows(
|
|
281
|
+
config, policy=self.channel_panel_policy()
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
def api_key_panel_rows(
|
|
285
|
+
self, provider: str, provider_config: dict[str, Any] | None = None
|
|
286
|
+
) -> PanelRows:
|
|
287
|
+
if provider == "kimi":
|
|
288
|
+
status = (
|
|
289
|
+
"managed profile detected"
|
|
290
|
+
if self.auth.kimi_oauth_configured()
|
|
291
|
+
else "login required"
|
|
292
|
+
)
|
|
293
|
+
mode = (
|
|
294
|
+
"Routed"
|
|
295
|
+
if bool((provider_config or {}).get("route_through_router"))
|
|
296
|
+
else "Native"
|
|
297
|
+
)
|
|
298
|
+
return (
|
|
299
|
+
[
|
|
300
|
+
f"Kimi OAuth ({mode}): {status}",
|
|
301
|
+
"Login with Kimi Code OAuth (clears API key)",
|
|
302
|
+
"Set routed API key",
|
|
303
|
+
"Clear routed API key",
|
|
304
|
+
"Back",
|
|
305
|
+
],
|
|
306
|
+
["__info__", "kimi-oauth-login", "input", "clear", "back"],
|
|
307
|
+
)
|
|
308
|
+
oauth_rows = self.auth.copilot_panel_rows(provider)
|
|
309
|
+
if oauth_rows is not None:
|
|
310
|
+
return oauth_rows
|
|
311
|
+
return self.configuration_panel_projection().api_key_rows(
|
|
312
|
+
provider, provider_config
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
def base_url_panel_rows(
|
|
316
|
+
self, provider: str, provider_config: dict[str, Any]
|
|
317
|
+
) -> PanelRows:
|
|
318
|
+
return self.configuration_panel_projection().base_url_rows(
|
|
319
|
+
provider, provider_config
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@dataclass(frozen=True, slots=True)
|
|
324
|
+
class PrelaunchPanelCompatibilityApi:
|
|
325
|
+
context: Callable[[], PrelaunchPanelContext]
|
|
326
|
+
|
|
327
|
+
def main_menu_projection(self) -> MainMenuProjection:
|
|
328
|
+
return self.context().main_menu_projection()
|
|
329
|
+
|
|
330
|
+
def main_menu_rows(
|
|
331
|
+
self,
|
|
332
|
+
config: dict[str, Any],
|
|
333
|
+
provider: str,
|
|
334
|
+
provider_config: dict[str, Any],
|
|
335
|
+
language: str,
|
|
336
|
+
) -> list[str]:
|
|
337
|
+
return self.context().main_menu_rows(
|
|
338
|
+
config, provider, provider_config, language
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
def web_backend_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
342
|
+
return self.context().web_backend_panel_rows(config)
|
|
343
|
+
|
|
344
|
+
def set_web_backend_config(self, key: str, value: Any) -> list[str]:
|
|
345
|
+
return self.context().set_web_backend_config(key, value)
|
|
346
|
+
|
|
347
|
+
def provider_panel_projection(self) -> ProviderPanelProjection:
|
|
348
|
+
return self.context().provider_panel_projection()
|
|
349
|
+
|
|
350
|
+
def provider_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
351
|
+
return self.context().provider_panel_rows(config)
|
|
352
|
+
|
|
353
|
+
def configuration_panel_projection(self) -> ConfigurationPanelProjection:
|
|
354
|
+
return self.context().configuration_panel_projection()
|
|
355
|
+
|
|
356
|
+
def language_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
357
|
+
return self.context().language_panel_rows(config)
|
|
358
|
+
|
|
359
|
+
def log_level_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
360
|
+
return self.context().log_level_panel_rows(config)
|
|
361
|
+
|
|
362
|
+
def model_panel_services(self) -> ModelPanelServices:
|
|
363
|
+
return self.context().model_panel_services()
|
|
364
|
+
|
|
365
|
+
def model_panel_rows(
|
|
366
|
+
self,
|
|
367
|
+
provider: str,
|
|
368
|
+
provider_config: dict[str, Any],
|
|
369
|
+
fetch: bool = True,
|
|
370
|
+
force_refresh: bool = False,
|
|
371
|
+
) -> PanelRows:
|
|
372
|
+
return self.context().model_panel_rows(
|
|
373
|
+
provider, provider_config, fetch, force_refresh
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
def advisor_model_panel_rows(
|
|
377
|
+
self,
|
|
378
|
+
provider: str,
|
|
379
|
+
provider_config: dict[str, Any],
|
|
380
|
+
fetch: bool = True,
|
|
381
|
+
force_refresh: bool = False,
|
|
382
|
+
) -> PanelRows:
|
|
383
|
+
return self.context().advisor_model_panel_rows(
|
|
384
|
+
provider, provider_config, fetch, force_refresh
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
def channel_panel_policy(self) -> ChannelPanelPolicy:
|
|
388
|
+
return self.context().channel_panel_policy()
|
|
389
|
+
|
|
390
|
+
def channel_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
391
|
+
return self.context().channel_panel_rows(config)
|
|
392
|
+
|
|
393
|
+
def channel_delivery_panel_rows(self, config: dict[str, Any]) -> PanelRows:
|
|
394
|
+
return self.context().channel_delivery_panel_rows(config)
|
|
395
|
+
|
|
396
|
+
def api_key_panel_rows(
|
|
397
|
+
self, provider: str, provider_config: dict[str, Any] | None = None
|
|
398
|
+
) -> PanelRows:
|
|
399
|
+
return self.context().api_key_panel_rows(provider, provider_config)
|
|
400
|
+
|
|
401
|
+
def base_url_panel_rows(
|
|
402
|
+
self, provider: str, provider_config: dict[str, Any]
|
|
403
|
+
) -> PanelRows:
|
|
404
|
+
return self.context().base_url_panel_rows(provider, provider_config)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
__all__ = [
|
|
408
|
+
"AuthPanelPorts",
|
|
409
|
+
"ChannelPanelContextPorts",
|
|
410
|
+
"ConfigurationPanelContextPorts",
|
|
411
|
+
"MainMenuPanelPorts",
|
|
412
|
+
"ModelPanelCatalogPorts",
|
|
413
|
+
"ModelPanelPresentationPorts",
|
|
414
|
+
"PrelaunchPanelCompatibilityApi",
|
|
415
|
+
"PrelaunchPanelContext",
|
|
416
|
+
"ProviderChoicePanelPorts",
|
|
417
|
+
"WebBackendPanelPorts",
|
|
418
|
+
]
|