ubume 0.1.0
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/README.md +88 -0
- package/bin/codexa-local-harness-bridge.js +3 -0
- package/bin/codexa.js +28 -0
- package/bin/ubume-local-harness-bridge.js +325 -0
- package/bin/ubume.js +398 -0
- package/package.json +66 -0
- package/src/app.tsx +5759 -0
- package/src/commands/handler.ts +889 -0
- package/src/config/appVersion.ts +69 -0
- package/src/config/buildInfo.ts +3 -0
- package/src/config/launchArgs.ts +196 -0
- package/src/config/layeredConfig.ts +853 -0
- package/src/config/legacyEnv.ts +16 -0
- package/src/config/persistence.ts +377 -0
- package/src/config/runtimeConfig.ts +558 -0
- package/src/config/settings.ts +405 -0
- package/src/config/toml-serialize.ts +109 -0
- package/src/config/trustStore.ts +84 -0
- package/src/config/updateCheckCache.ts +85 -0
- package/src/core/README.md +55 -0
- package/src/core/agent/loop.ts +464 -0
- package/src/core/agent/protocol.ts +345 -0
- package/src/core/agent/tools.ts +423 -0
- package/src/core/auth/codexAuth.ts +359 -0
- package/src/core/codex/codexExecArgs.ts +166 -0
- package/src/core/codex/codexLaunch.ts +163 -0
- package/src/core/codex/codexPrompt.ts +429 -0
- package/src/core/debug/inputDebug.ts +51 -0
- package/src/core/debug/localStreamDebug.ts +50 -0
- package/src/core/debug/modelStateDebug.ts +35 -0
- package/src/core/executables/antigravityExecutable.ts +48 -0
- package/src/core/executables/claudeExecutable.ts +63 -0
- package/src/core/executables/codexExecutable.ts +160 -0
- package/src/core/executables/executableResolver.ts +164 -0
- package/src/core/executables/geminiExecutable.ts +78 -0
- package/src/core/models/codexCapabilities.ts +97 -0
- package/src/core/models/codexModelCapabilities.ts +624 -0
- package/src/core/models/codexModelsCacheSeed.ts +153 -0
- package/src/core/models/modelSpecs.ts +303 -0
- package/src/core/models/providerModelCache.ts +94 -0
- package/src/core/perf/profiler.ts +125 -0
- package/src/core/perf/renderDebug.ts +398 -0
- package/src/core/process/CommandRunner.ts +280 -0
- package/src/core/process/processValidation.ts +111 -0
- package/src/core/providerLauncher/launcher.ts +220 -0
- package/src/core/providerLauncher/registry.ts +354 -0
- package/src/core/providerLauncher/types.ts +95 -0
- package/src/core/providerLauncher/workspaceConfig.ts +487 -0
- package/src/core/providerRuntime/anthropic.ts +580 -0
- package/src/core/providerRuntime/antigravity.ts +500 -0
- package/src/core/providerRuntime/capabilityProfile.ts +383 -0
- package/src/core/providerRuntime/claudeCodeDiscovery.ts +724 -0
- package/src/core/providerRuntime/claudeCodeDiscoveryDebug.ts +55 -0
- package/src/core/providerRuntime/codexaCupy.ts +97 -0
- package/src/core/providerRuntime/codexaNative.ts +425 -0
- package/src/core/providerRuntime/contextMetadata.ts +397 -0
- package/src/core/providerRuntime/gemini.ts +789 -0
- package/src/core/providerRuntime/lmstudio.ts +118 -0
- package/src/core/providerRuntime/local.ts +770 -0
- package/src/core/providerRuntime/localHarness/runtime.ts +1090 -0
- package/src/core/providerRuntime/localOutputBudget.ts +17 -0
- package/src/core/providerRuntime/mistralVibe.ts +667 -0
- package/src/core/providerRuntime/models.ts +175 -0
- package/src/core/providerRuntime/reasoning.ts +20 -0
- package/src/core/providerRuntime/registry.ts +286 -0
- package/src/core/providerRuntime/types.ts +142 -0
- package/src/core/providerRuntime/unsloth.ts +216 -0
- package/src/core/providers/codexJsonStream.ts +305 -0
- package/src/core/providers/codexSubprocess.ts +378 -0
- package/src/core/providers/codexTranscript.ts +695 -0
- package/src/core/providers/openaiNative.ts +13 -0
- package/src/core/providers/registry.ts +21 -0
- package/src/core/providers/types.ts +91 -0
- package/src/core/shared/attachments.ts +101 -0
- package/src/core/shared/cleanupFastFail.ts +67 -0
- package/src/core/shared/clipboard.ts +24 -0
- package/src/core/shared/clipboardImage.ts +111 -0
- package/src/core/shared/githubDiagnostics.ts +222 -0
- package/src/core/shared/hollowResponseFormat.ts +39 -0
- package/src/core/terminal/clearFrameBoundary.ts +852 -0
- package/src/core/terminal/frameLock.ts +110 -0
- package/src/core/terminal/inkRenderReset.ts +123 -0
- package/src/core/terminal/startupClear.ts +20 -0
- package/src/core/terminal/terminalCapabilities.ts +100 -0
- package/src/core/terminal/terminalControl.ts +169 -0
- package/src/core/terminal/terminalSanitize.ts +147 -0
- package/src/core/terminal/terminalTitle.ts +400 -0
- package/src/core/version/channel.ts +27 -0
- package/src/core/version/packageManager.ts +119 -0
- package/src/core/version/updateCheck.ts +203 -0
- package/src/core/workspace/appData.ts +107 -0
- package/src/core/workspace/conversationStore.ts +335 -0
- package/src/core/workspace/launchContext.ts +259 -0
- package/src/core/workspace/planStorage.ts +135 -0
- package/src/core/workspace/projectInstructions.ts +54 -0
- package/src/core/workspace/scratchDir.ts +64 -0
- package/src/core/workspace/workspaceActivity.ts +384 -0
- package/src/core/workspace/workspaceGuard.ts +377 -0
- package/src/core/workspace/workspaceRoot.ts +47 -0
- package/src/exec.ts +73 -0
- package/src/headless/execArgs.ts +296 -0
- package/src/headless/execRunner.ts +304 -0
- package/src/index.tsx +270 -0
- package/src/legacyEnvBootstrap.ts +5 -0
- package/src/session/appSession.ts +771 -0
- package/src/session/chatLifecycle.ts +994 -0
- package/src/session/conversation.ts +107 -0
- package/src/session/liveRenderScheduler.ts +214 -0
- package/src/session/persistedResponse.ts +93 -0
- package/src/session/planFlow.ts +159 -0
- package/src/session/planTranscript.ts +19 -0
- package/src/session/promptRunSchedule.ts +26 -0
- package/src/session/types.ts +234 -0
- package/src/test/runtimeTestUtils.ts +14 -0
- package/src/types/react-dom.d.ts +3 -0
- package/src/ui/chrome/ActivityBars.tsx +68 -0
- package/src/ui/chrome/ActivityIndicator.tsx +58 -0
- package/src/ui/chrome/AnimatedStatusText.tsx +69 -0
- package/src/ui/chrome/AppShell.tsx +474 -0
- package/src/ui/chrome/BottomComposer.tsx +1135 -0
- package/src/ui/chrome/DashCard.tsx +82 -0
- package/src/ui/chrome/RunFooter.tsx +65 -0
- package/src/ui/chrome/RuntimeStatusBar.tsx +108 -0
- package/src/ui/chrome/Spinner.tsx +25 -0
- package/src/ui/chrome/TopHeader.tsx +439 -0
- package/src/ui/chrome/UpdateAvailableCard.tsx +42 -0
- package/src/ui/chrome/busyStatusAnimation.ts +11 -0
- package/src/ui/input/commandNormalize.ts +66 -0
- package/src/ui/input/focus.ts +73 -0
- package/src/ui/input/imageAttachments.ts +18 -0
- package/src/ui/input/inputBuffer.ts +203 -0
- package/src/ui/input/pastedContent.ts +75 -0
- package/src/ui/input/rawArrowKeys.ts +28 -0
- package/src/ui/input/slashCommands.ts +43 -0
- package/src/ui/input/useStdinRawModeLease.ts +23 -0
- package/src/ui/layout.ts +560 -0
- package/src/ui/panels/AttachmentImportPanel.tsx +131 -0
- package/src/ui/panels/AuthPanel.tsx +149 -0
- package/src/ui/panels/BackendPicker.tsx +28 -0
- package/src/ui/panels/ModePicker.tsx +31 -0
- package/src/ui/panels/ModelPicker.tsx +31 -0
- package/src/ui/panels/ModelPickerScreen.tsx +761 -0
- package/src/ui/panels/ModelReasoningPicker.tsx +458 -0
- package/src/ui/panels/Panel.tsx +51 -0
- package/src/ui/panels/PermissionsPanel.tsx +78 -0
- package/src/ui/panels/PlanActionPicker.tsx +187 -0
- package/src/ui/panels/ProviderPicker.tsx +753 -0
- package/src/ui/panels/ProviderSetupPrompt.tsx +52 -0
- package/src/ui/panels/ReasoningPicker.tsx +46 -0
- package/src/ui/panels/ResumePicker.tsx +90 -0
- package/src/ui/panels/SelectionPanel.tsx +138 -0
- package/src/ui/panels/SettingsPanel.tsx +156 -0
- package/src/ui/panels/TextEntryPanel.tsx +139 -0
- package/src/ui/panels/ThemePicker.tsx +32 -0
- package/src/ui/panels/ToolApprovalPanel.tsx +46 -0
- package/src/ui/panels/UpdatePromptPanel.tsx +236 -0
- package/src/ui/panels/responsivePickerViewport.ts +64 -0
- package/src/ui/render/Markdown.tsx +331 -0
- package/src/ui/render/diffRenderer.ts +116 -0
- package/src/ui/render/logoVariants.ts +113 -0
- package/src/ui/render/modeDisplay.ts +52 -0
- package/src/ui/render/outputPipeline.ts +64 -0
- package/src/ui/render/runtimeDisplay.ts +128 -0
- package/src/ui/render/terminalAnswerFormat.ts +128 -0
- package/src/ui/render/textLayout.ts +392 -0
- package/src/ui/theme.tsx +274 -0
- package/src/ui/themeFlow.ts +41 -0
- package/src/ui/timeline/ActionRequiredBlock.tsx +38 -0
- package/src/ui/timeline/AgentBlock.tsx +130 -0
- package/src/ui/timeline/StaticIntroItem.tsx +54 -0
- package/src/ui/timeline/ThinkingBlock.tsx +100 -0
- package/src/ui/timeline/Timeline.tsx +1410 -0
- package/src/ui/timeline/TranscriptShell.tsx +302 -0
- package/src/ui/timeline/TurnGroup.tsx +673 -0
- package/src/ui/timeline/layoutListWindow.ts +145 -0
- package/src/ui/timeline/liveViewportWindow.ts +68 -0
- package/src/ui/timeline/progressEntries.ts +156 -0
- package/src/ui/timeline/runActivityView.ts +37 -0
- package/src/ui/timeline/staticTranscriptCache.ts +174 -0
- package/src/ui/timeline/streamCoalesce.ts +53 -0
- package/src/ui/timeline/timelineMeasure.ts +3273 -0
- package/src/ui/useThrottledValue.ts +31 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { Box, Text, useFocus, useInput } from "ink";
|
|
3
|
+
import {
|
|
4
|
+
type CodexModelCapability,
|
|
5
|
+
type ReasoningEffortCapability,
|
|
6
|
+
normalizeReasoningForModelCapabilities,
|
|
7
|
+
} from "../../core/models/codexModelCapabilities.js";
|
|
8
|
+
import { formatReasoningLabel } from "../../config/settings.js";
|
|
9
|
+
import { traceInputDebug } from "../../core/debug/inputDebug.js";
|
|
10
|
+
import { FOCUS_IDS } from "../input/focus.js";
|
|
11
|
+
import { useTheme } from "../theme.js";
|
|
12
|
+
|
|
13
|
+
// ─── Types & helpers ─────────────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
type ModelPickerCloseReason = "escape" | "empty-selection";
|
|
16
|
+
|
|
17
|
+
interface ModelReasoningPickerProps {
|
|
18
|
+
models: readonly CodexModelCapability[];
|
|
19
|
+
currentModel: string;
|
|
20
|
+
currentReasoning: string;
|
|
21
|
+
isLoading?: boolean;
|
|
22
|
+
onSelect: (model: string, reasoning: string) => void;
|
|
23
|
+
onCancel: (reason?: ModelPickerCloseReason) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getModelReasoningLevels(model: CodexModelCapability): readonly ReasoningEffortCapability[] {
|
|
27
|
+
return model.supportedReasoningLevels ?? [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getInitialReasoning(model: CodexModelCapability, currentReasoning: string): string {
|
|
31
|
+
return normalizeReasoningForModelCapabilities(
|
|
32
|
+
model.model,
|
|
33
|
+
currentReasoning,
|
|
34
|
+
{
|
|
35
|
+
status: "ready",
|
|
36
|
+
source: model.source,
|
|
37
|
+
models: [model],
|
|
38
|
+
discoveredAt: Date.now(),
|
|
39
|
+
executable: null,
|
|
40
|
+
error: null,
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getInitialCursor(models: readonly CodexModelCapability[], currentModel: string): number {
|
|
46
|
+
return Math.max(0, models.findIndex((model) => model.model === currentModel || model.id === currentModel));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function buildPendingReasoning(
|
|
50
|
+
models: readonly CodexModelCapability[],
|
|
51
|
+
currentReasoning: string,
|
|
52
|
+
): Record<string, string> {
|
|
53
|
+
const next: Record<string, string> = {};
|
|
54
|
+
for (const model of models) {
|
|
55
|
+
next[model.model] = getInitialReasoning(model, currentReasoning);
|
|
56
|
+
}
|
|
57
|
+
return next;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function describeInputKey(
|
|
61
|
+
input: string,
|
|
62
|
+
key: {
|
|
63
|
+
escape?: boolean;
|
|
64
|
+
return?: boolean;
|
|
65
|
+
upArrow?: boolean;
|
|
66
|
+
downArrow?: boolean;
|
|
67
|
+
leftArrow?: boolean;
|
|
68
|
+
rightArrow?: boolean;
|
|
69
|
+
ctrl?: boolean;
|
|
70
|
+
meta?: boolean;
|
|
71
|
+
},
|
|
72
|
+
) {
|
|
73
|
+
return {
|
|
74
|
+
input,
|
|
75
|
+
escape: Boolean(key.escape),
|
|
76
|
+
return: Boolean(key.return),
|
|
77
|
+
upArrow: Boolean(key.upArrow),
|
|
78
|
+
downArrow: Boolean(key.downArrow),
|
|
79
|
+
leftArrow: Boolean(key.leftArrow),
|
|
80
|
+
rightArrow: Boolean(key.rightArrow),
|
|
81
|
+
ctrl: Boolean(key.ctrl),
|
|
82
|
+
meta: Boolean(key.meta),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ─── Component ────────────────────────────────────────────────────────────────
|
|
87
|
+
|
|
88
|
+
export function ModelReasoningPicker({
|
|
89
|
+
models,
|
|
90
|
+
currentModel,
|
|
91
|
+
currentReasoning,
|
|
92
|
+
isLoading = false,
|
|
93
|
+
onSelect,
|
|
94
|
+
onCancel,
|
|
95
|
+
}: ModelReasoningPickerProps) {
|
|
96
|
+
const theme = useTheme();
|
|
97
|
+
const { isFocused } = useFocus({ id: FOCUS_IDS.modelPicker, autoFocus: true });
|
|
98
|
+
const visibleModels = models;
|
|
99
|
+
const initializedModelsRef = useRef(false);
|
|
100
|
+
|
|
101
|
+
const [cursor, setCursor] = useState(() =>
|
|
102
|
+
getInitialCursor(visibleModels, currentModel),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const [pendingReasoning, setPendingReasoning] = useState<Record<string, string>>(() =>
|
|
106
|
+
buildPendingReasoning(visibleModels, currentReasoning)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
traceInputDebug("model_picker_mounted", {
|
|
111
|
+
focusTarget: FOCUS_IDS.modelPicker,
|
|
112
|
+
modelCount: visibleModels.length,
|
|
113
|
+
isLoading,
|
|
114
|
+
});
|
|
115
|
+
return () => {
|
|
116
|
+
traceInputDebug("model_picker_unmounted", {
|
|
117
|
+
focusTarget: FOCUS_IDS.modelPicker,
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
traceInputDebug("model_picker_focus", {
|
|
124
|
+
isFocused,
|
|
125
|
+
focusTarget: FOCUS_IDS.modelPicker,
|
|
126
|
+
modelCount: visibleModels.length,
|
|
127
|
+
isLoading,
|
|
128
|
+
});
|
|
129
|
+
}, [isFocused, isLoading, visibleModels.length]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
traceInputDebug("model_picker_models_state", {
|
|
133
|
+
isLoading,
|
|
134
|
+
modelCount: visibleModels.length,
|
|
135
|
+
currentModel,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (visibleModels.length === 0) {
|
|
139
|
+
initializedModelsRef.current = false;
|
|
140
|
+
setCursor(0);
|
|
141
|
+
setPendingReasoning({});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setCursor((currentCursor) => {
|
|
146
|
+
const maxCursor = Math.max(0, visibleModels.length - 1);
|
|
147
|
+
if (!initializedModelsRef.current) {
|
|
148
|
+
initializedModelsRef.current = true;
|
|
149
|
+
return Math.min(getInitialCursor(visibleModels, currentModel), maxCursor);
|
|
150
|
+
}
|
|
151
|
+
return Math.min(Math.max(0, currentCursor), maxCursor);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
setPendingReasoning((prev) => {
|
|
155
|
+
const next: Record<string, string> = {};
|
|
156
|
+
let changed = Object.keys(prev).length !== visibleModels.length;
|
|
157
|
+
|
|
158
|
+
for (const model of visibleModels) {
|
|
159
|
+
const value = prev[model.model] ?? getInitialReasoning(model, currentReasoning);
|
|
160
|
+
next[model.model] = value;
|
|
161
|
+
if (prev[model.model] !== value) {
|
|
162
|
+
changed = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return changed ? next : prev;
|
|
167
|
+
});
|
|
168
|
+
}, [currentModel, currentReasoning, isLoading, visibleModels]);
|
|
169
|
+
|
|
170
|
+
const highlightedModel = visibleModels[Math.min(cursor, Math.max(0, visibleModels.length - 1))];
|
|
171
|
+
|
|
172
|
+
const moveReasoning = useCallback(
|
|
173
|
+
(direction: -1 | 1) => {
|
|
174
|
+
const model = visibleModels[cursor];
|
|
175
|
+
if (!model) return;
|
|
176
|
+
|
|
177
|
+
const available = getModelReasoningLevels(model);
|
|
178
|
+
if (available.length <= 1) return;
|
|
179
|
+
|
|
180
|
+
setPendingReasoning((prev) => {
|
|
181
|
+
const currentValue = prev[model.model] ?? getInitialReasoning(model, currentReasoning);
|
|
182
|
+
const currentIdx = Math.max(0, available.findIndex((level) => level.id === currentValue));
|
|
183
|
+
const nextIdx = Math.max(0, Math.min(available.length - 1, currentIdx + direction));
|
|
184
|
+
if (nextIdx === currentIdx) return prev;
|
|
185
|
+
return { ...prev, [model.model]: available[nextIdx]!.id };
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
[currentReasoning, cursor, visibleModels],
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
useInput(
|
|
192
|
+
(input, key) => {
|
|
193
|
+
traceInputDebug("model_picker_input", {
|
|
194
|
+
handler: "ModelReasoningPicker.useInput",
|
|
195
|
+
key: describeInputKey(input, key),
|
|
196
|
+
isFocused,
|
|
197
|
+
isLoading,
|
|
198
|
+
modelCount: visibleModels.length,
|
|
199
|
+
cursor,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
if (key.escape) {
|
|
203
|
+
traceInputDebug("model_picker_close_request", {
|
|
204
|
+
reason: "escape",
|
|
205
|
+
handler: "ModelReasoningPicker.useInput",
|
|
206
|
+
modelCount: visibleModels.length,
|
|
207
|
+
});
|
|
208
|
+
onCancel("escape");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (key.return) {
|
|
212
|
+
const model = visibleModels[cursor];
|
|
213
|
+
if (!model) {
|
|
214
|
+
traceInputDebug("model_picker_close_request", {
|
|
215
|
+
reason: "empty-selection",
|
|
216
|
+
handler: "ModelReasoningPicker.useInput",
|
|
217
|
+
modelCount: visibleModels.length,
|
|
218
|
+
});
|
|
219
|
+
onCancel("empty-selection");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const reasoning = pendingReasoning[model.model] ?? getInitialReasoning(model, currentReasoning);
|
|
223
|
+
traceInputDebug("model_selection_start", {
|
|
224
|
+
handler: "ModelReasoningPicker.useInput",
|
|
225
|
+
model: model.model,
|
|
226
|
+
reasoning,
|
|
227
|
+
});
|
|
228
|
+
onSelect(model.model, reasoning);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (key.upArrow) {
|
|
232
|
+
setCursor((c) => Math.max(0, c - 1));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (key.downArrow) {
|
|
236
|
+
setCursor((c) => Math.min(visibleModels.length - 1, c + 1));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (key.leftArrow) {
|
|
240
|
+
moveReasoning(-1);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (key.rightArrow) {
|
|
244
|
+
moveReasoning(1);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{ isActive: isFocused },
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const rows = useMemo(
|
|
251
|
+
() =>
|
|
252
|
+
visibleModels.map((model) => {
|
|
253
|
+
const available = getModelReasoningLevels(model);
|
|
254
|
+
return {
|
|
255
|
+
model,
|
|
256
|
+
available,
|
|
257
|
+
interactive: available.length > 1,
|
|
258
|
+
};
|
|
259
|
+
}),
|
|
260
|
+
[visibleModels],
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
if (visibleModels.length === 0) {
|
|
264
|
+
return <LoadingPickerView theme={theme} isLoading={isLoading} />;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<InteractivePickerView
|
|
269
|
+
rows={rows}
|
|
270
|
+
cursor={cursor}
|
|
271
|
+
currentModel={currentModel}
|
|
272
|
+
currentReasoning={currentReasoning}
|
|
273
|
+
pendingReasoning={pendingReasoning}
|
|
274
|
+
highlightedModel={highlightedModel}
|
|
275
|
+
theme={theme}
|
|
276
|
+
/>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ─── Subcomponents ───────────────────────────────────────────────────────────
|
|
281
|
+
|
|
282
|
+
function LoadingPickerView({
|
|
283
|
+
theme,
|
|
284
|
+
isLoading,
|
|
285
|
+
}: {
|
|
286
|
+
theme: ReturnType<typeof useTheme>;
|
|
287
|
+
isLoading: boolean;
|
|
288
|
+
}) {
|
|
289
|
+
return (
|
|
290
|
+
<Box flexDirection="column" width="100%">
|
|
291
|
+
<Box
|
|
292
|
+
borderStyle="round"
|
|
293
|
+
borderColor={theme.border}
|
|
294
|
+
paddingX={2}
|
|
295
|
+
paddingY={0}
|
|
296
|
+
width="100%"
|
|
297
|
+
>
|
|
298
|
+
<Box flexDirection="column" width="100%">
|
|
299
|
+
<Box>
|
|
300
|
+
<Text color={theme.accent} bold>Select model </Text>
|
|
301
|
+
<Text color={theme.textMuted}>Esc cancel</Text>
|
|
302
|
+
</Box>
|
|
303
|
+
<Box marginTop={0}>
|
|
304
|
+
<Text color={theme.textDim}>
|
|
305
|
+
{isLoading
|
|
306
|
+
? "Discovering models from the Codex runtime…"
|
|
307
|
+
: "No models available yet."}
|
|
308
|
+
</Text>
|
|
309
|
+
</Box>
|
|
310
|
+
</Box>
|
|
311
|
+
</Box>
|
|
312
|
+
</Box>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
interface InteractivePickerViewProps {
|
|
317
|
+
rows: Array<{
|
|
318
|
+
model: CodexModelCapability;
|
|
319
|
+
available: readonly ReasoningEffortCapability[];
|
|
320
|
+
interactive: boolean;
|
|
321
|
+
}>;
|
|
322
|
+
cursor: number;
|
|
323
|
+
currentModel: string;
|
|
324
|
+
currentReasoning: string;
|
|
325
|
+
pendingReasoning: Record<string, string>;
|
|
326
|
+
highlightedModel: CodexModelCapability | undefined;
|
|
327
|
+
theme: ReturnType<typeof useTheme>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function InteractivePickerView({
|
|
331
|
+
rows,
|
|
332
|
+
cursor,
|
|
333
|
+
currentModel,
|
|
334
|
+
currentReasoning,
|
|
335
|
+
pendingReasoning,
|
|
336
|
+
highlightedModel,
|
|
337
|
+
theme,
|
|
338
|
+
}: InteractivePickerViewProps) {
|
|
339
|
+
const subtitleParts: string[] = ["↑↓ model"];
|
|
340
|
+
if (highlightedModel && getModelReasoningLevels(highlightedModel).length > 1) {
|
|
341
|
+
subtitleParts.push("←→ reasoning");
|
|
342
|
+
}
|
|
343
|
+
subtitleParts.push("Enter select", "Esc cancel");
|
|
344
|
+
const subtitle = subtitleParts.join(" · ");
|
|
345
|
+
|
|
346
|
+
const highlightedPending = highlightedModel
|
|
347
|
+
? pendingReasoning[highlightedModel.model] ?? getInitialReasoning(highlightedModel, currentReasoning)
|
|
348
|
+
: currentReasoning;
|
|
349
|
+
const reasoningHint = highlightedModel?.supportedReasoningLevels
|
|
350
|
+
? `Reasoning: ${formatReasoningLabel(highlightedPending)}`
|
|
351
|
+
: "Reasoning metadata unavailable";
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<Box
|
|
355
|
+
borderStyle="round"
|
|
356
|
+
borderColor={theme.borderFocused}
|
|
357
|
+
paddingX={2}
|
|
358
|
+
paddingY={0}
|
|
359
|
+
width="100%"
|
|
360
|
+
flexDirection="column"
|
|
361
|
+
>
|
|
362
|
+
<Box>
|
|
363
|
+
<Text color={theme.accent} bold>Select model </Text>
|
|
364
|
+
<Text color={theme.textMuted}>{subtitle}</Text>
|
|
365
|
+
</Box>
|
|
366
|
+
<Box marginTop={0}>
|
|
367
|
+
<Text color={theme.textDim}>{reasoningHint}</Text>
|
|
368
|
+
</Box>
|
|
369
|
+
|
|
370
|
+
<Box
|
|
371
|
+
marginTop={0}
|
|
372
|
+
width="100%"
|
|
373
|
+
flexDirection="column"
|
|
374
|
+
>
|
|
375
|
+
{rows.map((row, idx) => {
|
|
376
|
+
const isHighlighted = idx === cursor;
|
|
377
|
+
const isCommitted = row.model.model === currentModel || row.model.id === currentModel;
|
|
378
|
+
const pending = pendingReasoning[row.model.model] ?? getInitialReasoning(row.model, currentReasoning);
|
|
379
|
+
|
|
380
|
+
return (
|
|
381
|
+
<ModelRow
|
|
382
|
+
key={row.model.id}
|
|
383
|
+
model={row.model}
|
|
384
|
+
availableLevels={row.available}
|
|
385
|
+
interactive={row.interactive}
|
|
386
|
+
isHighlighted={isHighlighted}
|
|
387
|
+
isCommitted={isCommitted}
|
|
388
|
+
selectedReasoning={pending}
|
|
389
|
+
theme={theme}
|
|
390
|
+
/>
|
|
391
|
+
);
|
|
392
|
+
})}
|
|
393
|
+
</Box>
|
|
394
|
+
</Box>
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
interface ModelRowProps {
|
|
399
|
+
model: CodexModelCapability;
|
|
400
|
+
availableLevels: readonly ReasoningEffortCapability[];
|
|
401
|
+
interactive: boolean;
|
|
402
|
+
isHighlighted: boolean;
|
|
403
|
+
isCommitted: boolean;
|
|
404
|
+
selectedReasoning: string;
|
|
405
|
+
theme: ReturnType<typeof useTheme>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function ModelRow({
|
|
409
|
+
model,
|
|
410
|
+
availableLevels,
|
|
411
|
+
interactive,
|
|
412
|
+
isHighlighted,
|
|
413
|
+
isCommitted,
|
|
414
|
+
selectedReasoning,
|
|
415
|
+
theme,
|
|
416
|
+
}: ModelRowProps) {
|
|
417
|
+
const cursorGlyph = isHighlighted ? "▸ " : " ";
|
|
418
|
+
const nameColor = isHighlighted ? theme.text : theme.textMuted;
|
|
419
|
+
const commitMark = isCommitted ? " ✓" : "";
|
|
420
|
+
const selectedIndex = availableLevels.findIndex((level) => level.id === selectedReasoning);
|
|
421
|
+
const name = model.label === model.model ? model.model : `${model.label} (${model.model})`;
|
|
422
|
+
|
|
423
|
+
const bars = availableLevels.map((level, i) => {
|
|
424
|
+
const isActive = i === selectedIndex;
|
|
425
|
+
const color = !interactive
|
|
426
|
+
? theme.textDim
|
|
427
|
+
: isActive
|
|
428
|
+
? isHighlighted ? theme.accent : theme.text
|
|
429
|
+
: theme.textDim;
|
|
430
|
+
|
|
431
|
+
return (
|
|
432
|
+
<Text key={level.id} color={color} bold={isActive && isHighlighted && interactive}>
|
|
433
|
+
■
|
|
434
|
+
</Text>
|
|
435
|
+
);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
return (
|
|
439
|
+
<Box flexDirection="row" width="100%">
|
|
440
|
+
<Box width={3} flexShrink={0}>
|
|
441
|
+
<Text color={isHighlighted ? theme.accent : theme.textDim}>{cursorGlyph}</Text>
|
|
442
|
+
</Box>
|
|
443
|
+
<Box flexGrow={1} flexDirection="row" paddingRight={1}>
|
|
444
|
+
<Box flexShrink={1}>
|
|
445
|
+
<Text color={nameColor} bold={isHighlighted} wrap="truncate-end">
|
|
446
|
+
{name}
|
|
447
|
+
</Text>
|
|
448
|
+
</Box>
|
|
449
|
+
<Box flexShrink={0} paddingLeft={1}>
|
|
450
|
+
<Text color={theme.textDim}>{commitMark}</Text>
|
|
451
|
+
</Box>
|
|
452
|
+
</Box>
|
|
453
|
+
<Box flexDirection="row" gap={1} flexShrink={0}>
|
|
454
|
+
{isHighlighted && bars}
|
|
455
|
+
</Box>
|
|
456
|
+
</Box>
|
|
457
|
+
);
|
|
458
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import { useTheme } from "../theme.js";
|
|
4
|
+
|
|
5
|
+
interface PanelProps {
|
|
6
|
+
cols: number;
|
|
7
|
+
title: string;
|
|
8
|
+
rightTitle?: string;
|
|
9
|
+
borderColor?: string;
|
|
10
|
+
titleColor?: string;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function Panel({ cols, title, rightTitle, borderColor, titleColor, children }: PanelProps) {
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
const cBorder = borderColor || theme.borderFocused;
|
|
17
|
+
const cTitle = titleColor || theme.text;
|
|
18
|
+
|
|
19
|
+
const leftLabel = ` ${title} `;
|
|
20
|
+
const rightLabel = rightTitle ? ` ${rightTitle} ` : "";
|
|
21
|
+
|
|
22
|
+
// ╭─ TITLE ─── RIGHTTITLE ╮
|
|
23
|
+
// Calculate remaining dashes
|
|
24
|
+
// total length = 2 (╭─) + leftLabel + dashes + rightLabel + 1 (╮) = cols
|
|
25
|
+
// dashes = cols - 3 - leftLabel.length - rightLabel.length
|
|
26
|
+
const maxDashes = cols - 3 - leftLabel.length - rightLabel.length;
|
|
27
|
+
const dashCount = Math.max(0, maxDashes);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Box flexDirection="column" width={cols} overflow="hidden">
|
|
31
|
+
<Text color={cBorder}>
|
|
32
|
+
{"╭─"}
|
|
33
|
+
<Text color={cTitle}>{leftLabel}</Text>
|
|
34
|
+
{"─".repeat(dashCount)}
|
|
35
|
+
{rightTitle && <Text color={theme.textDim}>{rightLabel}</Text>}
|
|
36
|
+
{"╮"}
|
|
37
|
+
</Text>
|
|
38
|
+
<Box
|
|
39
|
+
flexDirection="column"
|
|
40
|
+
borderStyle="round"
|
|
41
|
+
borderTop={false}
|
|
42
|
+
borderColor={cBorder}
|
|
43
|
+
width={cols}
|
|
44
|
+
paddingX={1}
|
|
45
|
+
paddingY={0}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</Box>
|
|
49
|
+
</Box>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ResolvedRuntimeConfig, RuntimeConfig } from "../../config/runtimeConfig.js";
|
|
2
|
+
import {
|
|
3
|
+
formatApprovalPolicyLabel,
|
|
4
|
+
formatNetworkAccessLabel,
|
|
5
|
+
formatSandboxModeLabel,
|
|
6
|
+
} from "../../config/runtimeConfig.js";
|
|
7
|
+
import { FOCUS_IDS } from "../input/focus.js";
|
|
8
|
+
import { SelectionPanel } from "./SelectionPanel.js";
|
|
9
|
+
|
|
10
|
+
export type PermissionsPanelAction =
|
|
11
|
+
| "approval-policy"
|
|
12
|
+
| "sandbox"
|
|
13
|
+
| "network"
|
|
14
|
+
| "writable-roots-summary"
|
|
15
|
+
| "writable-roots-add"
|
|
16
|
+
| "writable-roots-remove"
|
|
17
|
+
| "writable-roots-clear";
|
|
18
|
+
|
|
19
|
+
interface PermissionsPanelProps {
|
|
20
|
+
runtime: RuntimeConfig;
|
|
21
|
+
resolvedRuntime: ResolvedRuntimeConfig;
|
|
22
|
+
onSelect: (action: PermissionsPanelAction) => void;
|
|
23
|
+
onCancel: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function formatRootsSummary(count: number): string {
|
|
27
|
+
return count === 1 ? "1 configured" : `${count} configured`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function PermissionsPanel({
|
|
31
|
+
runtime,
|
|
32
|
+
resolvedRuntime,
|
|
33
|
+
onSelect,
|
|
34
|
+
onCancel,
|
|
35
|
+
}: PermissionsPanelProps) {
|
|
36
|
+
const items = [
|
|
37
|
+
{
|
|
38
|
+
label: `Approval policy ${formatApprovalPolicyLabel(resolvedRuntime.policy.approvalPolicy)} (configured: ${formatApprovalPolicyLabel(runtime.policy.approvalPolicy)})`,
|
|
39
|
+
value: "approval-policy",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: `Sandbox mode ${formatSandboxModeLabel(resolvedRuntime.policy.sandboxMode)} (configured: ${formatSandboxModeLabel(runtime.policy.sandboxMode)})`,
|
|
43
|
+
value: "sandbox",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: `Network access ${formatNetworkAccessLabel(resolvedRuntime.policy.networkAccess)} (configured: ${formatNetworkAccessLabel(runtime.policy.networkAccess)})`,
|
|
47
|
+
value: "network",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: `Writable roots ${formatRootsSummary(runtime.policy.writableRoots.length)}`,
|
|
51
|
+
value: "writable-roots-summary",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: "Add writable root",
|
|
55
|
+
value: "writable-roots-add",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "Remove writable root",
|
|
59
|
+
value: "writable-roots-remove",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: "Clear writable roots",
|
|
63
|
+
value: "writable-roots-clear",
|
|
64
|
+
},
|
|
65
|
+
] satisfies Array<{ label: string; value: PermissionsPanelAction }>;
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<SelectionPanel
|
|
69
|
+
focusId={FOCUS_IDS.permissionsPanel}
|
|
70
|
+
title="Permissions"
|
|
71
|
+
subtitle="Ubume policy guards. Recommended for local coding: On request + Workspace write."
|
|
72
|
+
items={items}
|
|
73
|
+
limit={items.length}
|
|
74
|
+
onSelect={(value) => onSelect(value as PermissionsPanelAction)}
|
|
75
|
+
onCancel={onCancel}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|