u-foo 3.1.7 → 4.0.1
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/OBSERVABILITY.md +65 -0
- package/README.md +238 -21
- package/README.zh-CN.md +165 -20
- package/SKILLS/ufoo/SKILL.md +40 -4
- package/SKILLS/ufoo-bus/SKILL.md +46 -3
- package/bin/uclaude.js +4 -0
- package/bin/ucodex.js +4 -0
- package/bin/ufoo.js +6 -4
- package/dist/tui/darwin-arm64/ufoo-tui +0 -0
- package/dist/tui/darwin-x64/ufoo-tui +0 -0
- package/dist/tui/linux-arm64/ufoo-tui +0 -0
- package/dist/tui/linux-x64/ufoo-tui +0 -0
- package/package.json +14 -7
- package/scripts/postinstall-skills.js +53 -0
- package/scripts/postinstall.js +11 -16
- package/scripts/smoke-native-messages.js +214 -0
- package/src/agents/activity/activityDetector.js +1 -1
- package/src/agents/activity/activityStateWriter.js +37 -38
- package/src/agents/capabilities/agentManagement/index.js +4 -0
- package/src/agents/capabilities/agentManagement/service.js +140 -0
- package/src/agents/capabilities/agentRouting/index.js +4 -0
- package/src/agents/capabilities/coding/index.js +32 -0
- package/src/agents/capabilities/coordination/index.js +37 -0
- package/src/agents/capabilities/globalRouting/index.js +5 -0
- package/src/agents/capabilities/groups/index.js +3 -0
- package/src/agents/capabilities/index.js +25 -0
- package/src/agents/capabilities/planning/index.js +123 -0
- package/src/agents/capabilities/planning/main.js +28 -0
- package/src/agents/capabilities/projectDiscovery/index.js +3 -0
- package/src/agents/capabilities/scheduling/index.js +3 -0
- package/src/agents/capabilities/sharedMemory/index.js +4 -0
- package/src/agents/capabilities/skills/index.js +12 -0
- package/src/agents/capabilities/taskExecution/index.js +3 -0
- package/src/agents/capabilities/taskReports/index.js +6 -0
- package/src/agents/controller/controllerToolExecutor.js +40 -22
- package/src/agents/controller/index.js +1 -6
- package/src/agents/internal/internalRunner.js +181 -76
- package/src/agents/launch/index.js +0 -1
- package/src/agents/launch/launcher.js +96 -14
- package/src/agents/launch/nativeCapabilities.js +40 -0
- package/src/agents/launch/nativeMessages.js +362 -0
- package/src/agents/launch/notifier.js +15 -20
- package/src/agents/launch/readyDetector.js +28 -14
- package/src/agents/profiles/coding.js +6 -0
- package/src/agents/profiles/globalRouter.js +2 -0
- package/src/agents/profiles/main.js +5 -0
- package/src/agents/prompts/cooperation.js +14 -0
- package/src/agents/prompts/defaultBootstrap.js +1 -1
- package/src/agents/prompts/groupBootstrap.js +32 -6
- package/src/agents/prompts/mainAgent.js +48 -0
- package/src/agents/prompts/native/system.js +4 -1
- package/src/agents/prompts/native/tasks.js +2 -2
- package/src/agents/prompts/native/ufoo.js +14 -3
- package/src/agents/prompts/promptProfiles.js +2 -0
- package/src/agents/prompts/reporting.js +16 -0
- package/src/agents/providers/claudeEventTranslator.js +9 -1
- package/src/agents/providers/claudeThreadProvider.js +47 -4
- package/src/agents/providers/clientIdentity.js +75 -0
- package/src/agents/providers/codexEventTranslator.js +68 -7
- package/src/agents/providers/codexThreadProvider.js +18 -8
- package/src/agents/providers/credentials/claude.js +10 -3
- package/src/agents/providers/credentials/index.js +2 -0
- package/src/agents/providers/directAuthStatus.js +1 -1
- package/src/agents/providers/index.js +1 -1
- package/src/agents/providers/modelSettings.js +34 -0
- package/src/agents/providers/modelsCatalog.js +379 -0
- package/src/agents/providers/nativeTransport.js +1146 -0
- package/src/agents/providers/runtimeConfig.js +188 -0
- package/src/agents/providers/thinkingLevels.js +106 -0
- package/src/agents/providers/transports/anthropicMessagesTransport.js +121 -0
- package/src/agents/providers/transports/index.js +10 -0
- package/src/agents/providers/transports/openaiChatTransport.js +117 -0
- package/src/agents/providers/transports/openaiResponsesTransport.js +120 -0
- package/src/agents/providers/transports/responsesProtocol.js +504 -0
- package/src/agents/providers/transports/systemBlocks.js +16 -0
- package/src/agents/providers/transports/transportContract.js +50 -0
- package/src/agents/providers/transports/visionBlocks.js +151 -0
- package/src/agents/providers/upstreamRuntime.js +135 -0
- package/src/agents/runtime/composeCapabilities.js +89 -0
- package/src/agents/runtime/context/checkpointStore.js +38 -0
- package/src/agents/runtime/context/commandStore.js +43 -0
- package/src/agents/runtime/context/compaction.js +151 -0
- package/src/agents/runtime/context/contextBudget.js +93 -0
- package/src/agents/runtime/context/contextWindow.js +119 -0
- package/src/agents/runtime/context/fileLock.js +36 -0
- package/src/agents/runtime/context/replayHistory.js +28 -0
- package/src/agents/runtime/context/runtimeStore.js +127 -0
- package/src/agents/runtime/context/sessionJournal.js +360 -0
- package/src/agents/runtime/context/sessionStore.js +57 -0
- package/src/agents/runtime/core/agentLoop.js +351 -0
- package/src/agents/runtime/core/executionBudget.js +36 -0
- package/src/agents/runtime/core/stableJson.js +29 -0
- package/src/agents/runtime/core/toolLoopGuard.js +55 -0
- package/src/agents/runtime/createAgentRuntime.js +259 -0
- package/src/agents/runtime/index.js +14 -0
- package/src/agents/runtime/prompts/responseLanguage.js +12 -0
- package/src/agents/runtime/protocol/faultHarness.js +90 -0
- package/src/agents/runtime/protocol/materialize.js +107 -0
- package/src/agents/runtime/protocol/runObservation.js +24 -0
- package/src/agents/runtime/protocol/toolCallLedger.js +221 -0
- package/src/agents/runtime/protocol/traceContext.js +9 -0
- package/src/agents/runtime/tasks/resourceLease.js +66 -0
- package/src/agents/runtime/tasks/scheduler.js +73 -0
- package/src/agents/runtime/tools/registry.js +57 -0
- package/src/app/chat/ChatController.js +29 -45
- package/src/app/chat/agentDirectory.js +9 -18
- package/src/app/chat/bootstrap.js +1 -2
- package/src/app/chat/commandExecutor.js +111 -313
- package/src/app/chat/commands.js +39 -45
- package/src/app/chat/daemonConnection.js +58 -5
- package/src/app/chat/daemonMessageRouter.js +61 -48
- package/src/app/chat/historyStore.js +12 -48
- package/src/app/chat/inputSubmitHandler.js +21 -35
- package/src/app/chat/internalAgentLogHistory.js +19 -60
- package/src/app/chat/launchRequestContext.js +42 -0
- package/src/app/chat/multiWindow/paneManager.js +91 -164
- package/src/app/chat/streamState.js +3 -7
- package/src/app/chat/transport.js +1 -1
- package/src/app/cli/busCoreCommands.js +9 -0
- package/src/app/cli/features/doctor.js +33 -0
- package/src/app/cli/features/init.js +5 -5
- package/src/app/cli/features/skills.js +16 -4
- package/src/app/cli/metricsCommands.js +68 -0
- package/src/app/cli/reportCoreCommands.js +37 -0
- package/src/app/cli/run.js +82 -42
- package/src/app/cli/traceCommands.js +36 -0
- package/src/code/agent.js +34 -17
- package/src/code/busConsumer.js +1 -3
- package/src/code/commands.js +1 -1
- package/src/code/context/artifacts.js +12 -11
- package/src/code/context/assembler.js +9 -9
- package/src/code/context/promptLayers.js +1 -13
- package/src/code/context/stableJson.js +2 -27
- package/src/code/context/stateCommit.js +2 -1
- package/src/code/contextWindow.js +2 -117
- package/src/code/conversation/sessionJournal.js +3 -349
- package/src/code/internalThread.js +107 -0
- package/src/code/launcher/ucode.js +1 -1
- package/src/code/launcher/ucodeBootstrap.js +1 -1
- package/src/code/modelCommand.js +11 -35
- package/src/code/nativeRunner.js +104 -2697
- package/src/code/protocol/faultHarness.js +2 -88
- package/src/code/protocol/materialize.js +2 -105
- package/src/code/protocol/toolCallLedger.js +5 -215
- package/src/code/providers/anthropicMessagesTransport.js +2 -118
- package/src/code/providers/modelsCatalog.js +1 -317
- package/src/code/providers/openaiChatTransport.js +2 -114
- package/src/code/providers/openaiResponsesTransport.js +2 -117
- package/src/code/providers/responsesProtocol.js +2 -497
- package/src/code/providers/transportContract.js +2 -48
- package/src/code/providers/visionBlocks.js +2 -149
- package/src/code/repl.js +2 -11
- package/src/code/sessionStore.js +27 -99
- package/src/code/taskDecomposer.js +18 -0
- package/src/code/thinkingLevels.js +1 -130
- package/src/code/toolBudget.js +1 -17
- package/src/code/toolLoopGuard.js +3 -49
- package/src/code/tools/artifactRead.js +1 -1
- package/src/code/tools/executor.js +373 -0
- package/src/code/tools/specs.js +312 -0
- package/src/config.js +95 -131
- package/src/coordination/bus/deliveryQueue.js +16 -2
- package/src/coordination/bus/index.js +14 -9
- package/src/coordination/bus/inject.js +15 -7
- package/src/coordination/bus/message.js +15 -1
- package/src/coordination/bus/nativeReceipts.js +100 -0
- package/src/coordination/bus/nickname.js +1 -1
- package/src/coordination/bus/queue.js +1 -3
- package/src/coordination/bus/subscriber.js +3 -2
- package/src/coordination/bus/utils.js +8 -4
- package/src/coordination/history/agentPerformance.js +279 -0
- package/src/coordination/history/agentSurface.js +142 -0
- package/src/coordination/history/agentTrace.js +249 -0
- package/src/coordination/memory/index.js +5 -21
- package/src/coordination/report/store.js +103 -83
- package/src/coordination/state/agentsStore.js +57 -3
- package/src/coordination/state/fileLock.js +2 -0
- package/src/coordination/state/workspaceAccess.js +36 -0
- package/src/orchestration/controller/index.js +1 -8
- package/src/orchestration/controller/launchRouting.js +1 -1
- package/src/orchestration/solo/commands.js +3 -1
- package/src/runtime/contracts/agentMode.js +26 -0
- package/src/runtime/contracts/eventContract.js +3 -0
- package/src/runtime/contracts/uiProtocol.js +20 -17
- package/src/runtime/daemon/agentHost.js +407 -0
- package/src/runtime/daemon/agentRecoveryGroups.js +70 -0
- package/src/runtime/daemon/busBridge.js +396 -0
- package/src/runtime/daemon/claudeChannel.js +159 -0
- package/src/runtime/daemon/controlPlaneService.js +28 -18
- package/src/runtime/daemon/cronOps.js +25 -17
- package/src/runtime/daemon/deliveryScheduler.js +32 -5
- package/src/runtime/daemon/globalDaemon.js +28 -1
- package/src/runtime/daemon/groupOrchestrator.js +21 -5
- package/src/runtime/daemon/groupStatus.js +20 -0
- package/src/runtime/daemon/index.js +120 -375
- package/src/runtime/daemon/ipcServer.js +32 -10
- package/src/runtime/daemon/mcpConfigure.js +113 -20
- package/src/runtime/daemon/mcpHttpServer.js +27 -5
- package/src/runtime/daemon/mcpServer.js +8 -5
- package/src/runtime/daemon/mcpStdioProxy.js +127 -10
- package/src/runtime/daemon/nicknameScope.js +1 -1
- package/src/runtime/daemon/ops.js +68 -40
- package/src/runtime/daemon/projectRuntimeGateway.js +2 -0
- package/src/runtime/daemon/promptRequest.js +92 -570
- package/src/runtime/daemon/providerSessions.js +67 -33
- package/src/runtime/daemon/reportControlBus.js +59 -25
- package/src/runtime/daemon/status.js +9 -6
- package/src/runtime/privacy/redactor.js +2 -2
- package/src/runtime/projects/identity.js +2 -1
- package/src/runtime/projects/registry.js +98 -38
- package/src/tools/controllerSchemas.js +28 -0
- package/src/tools/handlers/dispatchMessage.js +5 -2
- package/src/tools/handlers/listAgents.js +3 -1
- package/src/tools/handlers/readBusSummary.js +3 -1
- package/src/tools/handlers/readProjectRegistry.js +29 -2
- package/src/tools/handlers/routeAgent.js +35 -0
- package/src/tools/handlers/tier2.js +4 -2
- package/src/tools/index.js +1 -0
- package/src/tools/registry.js +6 -0
- package/src/tools/schemaFixtures.js +42 -5
- package/src/tools/tier0/readAgentMetrics.js +14 -0
- package/src/tools/tier0/readAgentTrace.js +12 -0
- package/src/tools/tier1/routeAgent.js +2 -2
- package/src/tools/tier2/runtimeCoordination.js +38 -0
- package/src/tools/types.js +2 -0
- package/src/ui/agentPresentation.js +109 -0
- package/src/ui/agentSettingsController.js +107 -0
- package/src/ui/agentSurface.js +270 -0
- package/src/ui/dashboardBridge.js +1 -1
- package/src/ui/format/banner.js +9 -15
- package/src/ui/format/index.js +14 -10
- package/src/ui/format/loopSummary.js +50 -0
- package/src/ui/format/markdownRenderer.js +3 -4
- package/src/ui/format/startupBanner.js +50 -0
- package/src/ui/multiPaneBusMirror.js +29 -3
- package/src/ui/rustChatHost.js +316 -599
- package/src/ui/rustMultiSession.js +288 -73
- package/src/ui/rustUcodeHost.js +21 -88
- package/src/ui/settingsBridge.js +34 -14
- package/src/ui/toolMergeBridge.js +0 -4
- package/src/ui/uiHostServer.js +5 -8
- package/src/agents/controller/loopObservability.js +0 -200
- package/src/agents/controller/loopRuntime.js +0 -472
- package/src/agents/controller/ufooAgent.js +0 -829
- package/src/agents/launch/ptyRunner.js +0 -1135
- package/src/agents/providers/upstreamTransport.js +0 -689
- package/src/app/chat/agentBar.js +0 -135
- package/src/app/chat/agentEnter.js +0 -70
- package/src/app/chat/agentSockets.js +0 -225
- package/src/app/chat/dashboardView.js +0 -405
- package/src/app/chat/multiWindow/index.js +0 -310
- package/src/app/chat/multiWindow/paneLayout.js +0 -84
- package/src/app/chat/multiWindow/renderer.js +0 -420
- package/src/app/chat/multiWindow/virtualTerminal.js +0 -327
- package/src/app/chat/multiWindow/vtFrame.js +0 -93
- package/src/app/chat/rawKeyMap.js +0 -42
- package/src/app/chat/settingsController.js +0 -111
- package/src/orchestration/controller/flags.js +0 -167
- package/src/orchestration/controller/gateRouter.js +0 -211
- package/src/orchestration/controller/routerFastPath.js +0 -22
- package/src/orchestration/controller/routerFinalize.js +0 -222
- package/src/orchestration/controller/shadowGuard.js +0 -280
- package/src/runtime/daemon/promptLoop.js +0 -136
- package/src/runtime/privacy/shadowDiff.js +0 -174
- package/src/ui/multiWindowHandoff.js +0 -232
- package/src/ui/ptyHandoff.js +0 -23
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Embedded host for the same native coding runner used by standalone ucode.
|
|
4
|
+
const { randomUUID } = require("crypto");
|
|
5
|
+
const agent = require("./agent");
|
|
6
|
+
const { buildPlanSetPayload } = require("../ui/agentPresentation");
|
|
7
|
+
|
|
8
|
+
function createInternalCodingThread(options = {}) {
|
|
9
|
+
const workspaceRoot = options.workspaceRoot || process.cwd();
|
|
10
|
+
const resolved = agent.resolveUcodeProviderModel({ workspaceRoot, model: options.model || "" });
|
|
11
|
+
const state = {
|
|
12
|
+
workspaceRoot, ...resolved, engine: "ufoo-core",
|
|
13
|
+
context: agent.buildNlContext({ workspaceRoot, ...resolved }),
|
|
14
|
+
nlMessages: [], sessionId: options.sessionId || `ucode-${randomUUID()}`,
|
|
15
|
+
};
|
|
16
|
+
if (options.sessionId) {
|
|
17
|
+
const restored = agent.resumeSessionState(state, options.sessionId, workspaceRoot);
|
|
18
|
+
if (restored?.ok === false) throw new Error(restored.error || `Could not resume session: ${options.sessionId}`);
|
|
19
|
+
}
|
|
20
|
+
let abort = null;
|
|
21
|
+
|
|
22
|
+
async function* runStreamed(input, runOptions = {}) {
|
|
23
|
+
if (abort) throw new Error("internal coding thread is already running");
|
|
24
|
+
abort = new AbortController();
|
|
25
|
+
const controller = abort;
|
|
26
|
+
const queue = [];
|
|
27
|
+
let wake = null;
|
|
28
|
+
let done = false;
|
|
29
|
+
let failure = null;
|
|
30
|
+
const push = (event) => { queue.push(event); if (wake) { wake(); wake = null; } };
|
|
31
|
+
const cancelled = () => controller.abort(runOptions.signal?.reason);
|
|
32
|
+
if (runOptions.signal?.aborted) cancelled();
|
|
33
|
+
runOptions.signal?.addEventListener("abort", cancelled, { once: true });
|
|
34
|
+
const activeTools = new Map();
|
|
35
|
+
let toolSequence = 0;
|
|
36
|
+
const publishPlan = () => push({ type: "plan", ...buildPlanSetPayload(state.executionState) });
|
|
37
|
+
const callbacks = {
|
|
38
|
+
signal: controller.signal,
|
|
39
|
+
runtimeContext: runOptions.runtimeContext || {},
|
|
40
|
+
onRuntimeEvent: event => push({ type: "runtime_event", event }),
|
|
41
|
+
onDelta: (delta) => push({ type: "text_delta", delta }),
|
|
42
|
+
onThinkingDelta: (delta) => push({ type: "thinking_delta", delta }),
|
|
43
|
+
onPhase: (phase) => push({ type: "phase", phase }),
|
|
44
|
+
onContextUsage: (meter) => push({ type: "context_usage", meter }),
|
|
45
|
+
onToolEvent: (event) => {
|
|
46
|
+
const key = JSON.stringify([event.tool, event.args || {}, event.origin || null]);
|
|
47
|
+
const stack = activeTools.get(key) || [];
|
|
48
|
+
if (event.phase === "start") {
|
|
49
|
+
const id = String(event.callId || event.toolCallId || event.id || `native-tool-${randomUUID()}`);
|
|
50
|
+
stack.push(id); activeTools.set(key, stack);
|
|
51
|
+
push({ type: "tool_call", toolCallId: id, name: event.tool, args: event.args });
|
|
52
|
+
} else if (event.phase === "end" || event.phase === "error") {
|
|
53
|
+
const id = stack.pop() || String(event.callId || event.toolCallId || event.id || `native-tool-${++toolSequence}`);
|
|
54
|
+
if (!stack.length) activeTools.delete(key);
|
|
55
|
+
push({ type: "tool_result", toolCallId: id, output: event.result || event.error || "", is_error: event.phase === "error" });
|
|
56
|
+
publishPlan();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const runTask = options.runTask || agent.runNaturalLanguageTask;
|
|
61
|
+
const work = Promise.resolve().then(async () => {
|
|
62
|
+
push({ type: "turn_started" });
|
|
63
|
+
const { hasPendingUserInteraction, formatInteractionPromptLines } = require("./context/userInteraction");
|
|
64
|
+
const pending = hasPendingUserInteraction(state.executionState);
|
|
65
|
+
let result;
|
|
66
|
+
if (pending && !options.runTask) {
|
|
67
|
+
push({ type: "phase", phase: { type: "applying_reply" } });
|
|
68
|
+
result = await agent.resumeAfterUserInteraction(runOptions.userInput ?? input, state, callbacks);
|
|
69
|
+
} else result = await runTask(input, state, callbacks);
|
|
70
|
+
if (result?.ok === false) {
|
|
71
|
+
const error = new Error(result.error || "native coding task failed");
|
|
72
|
+
if (result.cancelled || controller.signal.aborted) error.code = "cancelled";
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
if (!result?.streamed && result?.summary) push({ type: "text_delta", delta: result.summary });
|
|
76
|
+
if (hasPendingUserInteraction(state.executionState)) {
|
|
77
|
+
const { getPendingUserInteraction } = require("./context/userInteraction");
|
|
78
|
+
push({ type: "interaction", lines: formatInteractionPromptLines(getPendingUserInteraction(state.executionState), { cols: 80 }) });
|
|
79
|
+
}
|
|
80
|
+
if (!options.runTask) agent.persistSessionState(state);
|
|
81
|
+
publishPlan();
|
|
82
|
+
if (result?.contextMeter || state.contextMeter) push({ type: "context_usage", meter: result?.contextMeter || state.contextMeter });
|
|
83
|
+
const finalText = result?.finalText ?? result?.summary;
|
|
84
|
+
push({ type: "turn_completed", usage: result?.usage || result?.metrics || null,
|
|
85
|
+
...(typeof finalText === "string" ? { finalText } : {}) });
|
|
86
|
+
}).catch((error) => { failure = error; }).finally(() => {
|
|
87
|
+
done = true;
|
|
88
|
+
if (wake) { wake(); wake = null; }
|
|
89
|
+
});
|
|
90
|
+
try {
|
|
91
|
+
while (!done || queue.length) {
|
|
92
|
+
if (queue.length) yield queue.shift();
|
|
93
|
+
else await new Promise((resolve) => { wake = resolve; });
|
|
94
|
+
}
|
|
95
|
+
if (failure) throw failure;
|
|
96
|
+
} finally {
|
|
97
|
+
controller.abort();
|
|
98
|
+
await work;
|
|
99
|
+
runOptions.signal?.removeEventListener("abort", cancelled);
|
|
100
|
+
abort = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return { id: state.sessionId, runStreamed, close: async () => { if (abort) abort.abort(); } };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
module.exports = { createInternalCodingThread };
|
|
@@ -80,7 +80,7 @@ function mergeDefaultUfooProtocolPrompt(projectRoot = "", promptText = "") {
|
|
|
80
80
|
const currentPrompt = String(promptText || "").trim();
|
|
81
81
|
if (hasSharedUfooProtocolPrompt(currentPrompt)) return currentPrompt;
|
|
82
82
|
const defaultPrompt = buildDefaultStartupBootstrapPrompt({
|
|
83
|
-
agentType: "
|
|
83
|
+
agentType: "ucode",
|
|
84
84
|
projectRoot,
|
|
85
85
|
}).trim();
|
|
86
86
|
return [defaultPrompt, currentPrompt].filter(Boolean).join("\n\n");
|
package/src/code/modelCommand.js
CHANGED
|
@@ -13,17 +13,6 @@ const {
|
|
|
13
13
|
DEFAULT_THINKING_LEVEL,
|
|
14
14
|
} = require("./thinkingLevels");
|
|
15
15
|
|
|
16
|
-
function fallbackModelSuggestions(provider = "") {
|
|
17
|
-
const text = String(provider || "").trim().toLowerCase();
|
|
18
|
-
if (text.includes("anthropic") || text.includes("claude")) {
|
|
19
|
-
return ["claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5"];
|
|
20
|
-
}
|
|
21
|
-
if (text.includes("kimi") || text.includes("moonshot")) {
|
|
22
|
-
return ["k3", "kimi-k2.5", "moonshot-v1-128k"];
|
|
23
|
-
}
|
|
24
|
-
return ["gpt-5.4", "gpt-5.3", "o3", "o4-mini"];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
16
|
function resolveModelRuntime(state = {}, options = {}) {
|
|
28
17
|
// Lazy require: nativeRunner pulls agent/repl paths that can load modelCommand.
|
|
29
18
|
const { resolveRuntimeConfig } = require("./nativeRunner");
|
|
@@ -46,17 +35,7 @@ function currentThinkingLevel(state = {}) {
|
|
|
46
35
|
env: process.env,
|
|
47
36
|
configLevel: fromState || configLevel,
|
|
48
37
|
});
|
|
49
|
-
|
|
50
|
-
if (resolved.source === "env-budget") {
|
|
51
|
-
// Approximate a named level for the secondary menu highlight.
|
|
52
|
-
const budget = Number(resolved.budgetTokens) || 0;
|
|
53
|
-
if (budget <= 0) return "off";
|
|
54
|
-
if (budget <= 3000) return "low";
|
|
55
|
-
if (budget <= 16000) return "medium";
|
|
56
|
-
if (budget <= 40000) return "high";
|
|
57
|
-
return "max";
|
|
58
|
-
}
|
|
59
|
-
return DEFAULT_THINKING_LEVEL;
|
|
38
|
+
return resolved.level || DEFAULT_THINKING_LEVEL;
|
|
60
39
|
}
|
|
61
40
|
|
|
62
41
|
function persistThinkingLevel(state = {}, level = "") {
|
|
@@ -110,7 +89,7 @@ async function applyUcodeModelCommand(state = {}, result = {}, options = {}) {
|
|
|
110
89
|
`model: ${model}`,
|
|
111
90
|
`provider: ${provider}`,
|
|
112
91
|
`thinking: ${thinking}`,
|
|
113
|
-
"usage: /model <model-id> [off|low|medium|high|max]",
|
|
92
|
+
"usage: /model <model-id> [off|low|medium|high|xhigh|max]",
|
|
114
93
|
];
|
|
115
94
|
try {
|
|
116
95
|
const listed = await listUcodeModels(state, options);
|
|
@@ -139,15 +118,15 @@ async function applyUcodeModelCommand(state = {}, result = {}, options = {}) {
|
|
|
139
118
|
if (!next) {
|
|
140
119
|
return {
|
|
141
120
|
ok: false,
|
|
142
|
-
error: "usage: /model [model-id] [off|low|medium|high|max]",
|
|
143
|
-
output: "usage: /model [model-id] [off|low|medium|high|max]",
|
|
121
|
+
error: "usage: /model [model-id] [off|low|medium|high|xhigh|max]",
|
|
122
|
+
output: "usage: /model [model-id] [off|low|medium|high|xhigh|max]",
|
|
144
123
|
};
|
|
145
124
|
}
|
|
146
125
|
if (thinkingRaw && !thinkingNext) {
|
|
147
126
|
return {
|
|
148
127
|
ok: false,
|
|
149
|
-
error: `unknown thinking level "${thinkingRaw}" (use off|low|medium|high|max)`,
|
|
150
|
-
output: `unknown thinking level "${thinkingRaw}" (use off|low|medium|high|max)`,
|
|
128
|
+
error: `unknown thinking level "${thinkingRaw}" (use off|low|medium|high|xhigh|max)`,
|
|
129
|
+
output: `unknown thinking level "${thinkingRaw}" (use off|low|medium|high|xhigh|max)`,
|
|
151
130
|
};
|
|
152
131
|
}
|
|
153
132
|
|
|
@@ -216,30 +195,28 @@ async function applyUcodeModelCommand(state = {}, result = {}, options = {}) {
|
|
|
216
195
|
}
|
|
217
196
|
return {
|
|
218
197
|
ok: false,
|
|
219
|
-
error: "usage: /model [model-id] [off|low|medium|high|max]",
|
|
220
|
-
output: "usage: /model [model-id] [off|low|medium|high|max]",
|
|
198
|
+
error: "usage: /model [model-id] [off|low|medium|high|xhigh|max]",
|
|
199
|
+
output: "usage: /model [model-id] [off|low|medium|high|xhigh|max]",
|
|
221
200
|
};
|
|
222
201
|
}
|
|
223
202
|
|
|
224
203
|
/**
|
|
225
204
|
* Build /model completion rows. Prefer a live models-route catalog when
|
|
226
|
-
* provided; otherwise
|
|
205
|
+
* provided; otherwise retain only the current model for manual selection.
|
|
227
206
|
* Models are marked hasChildren so the TUI opens a thinking-intensity
|
|
228
207
|
* secondary menu after the id is chosen.
|
|
229
208
|
*/
|
|
230
209
|
function suggestUcodeModels(state = {}, options = {}) {
|
|
231
210
|
const current = String((state && state.model) || "").trim();
|
|
232
|
-
const provider = String((state && state.provider) || "").trim().toLowerCase();
|
|
233
211
|
const remote = Array.isArray(options.models)
|
|
234
212
|
? options.models.map((item) => String(item || "").trim()).filter(Boolean)
|
|
235
213
|
: [];
|
|
236
|
-
const defaults = remote.length > 0 ? remote : fallbackModelSuggestions(provider);
|
|
237
214
|
const ids = [];
|
|
238
215
|
if (current) ids.push(current);
|
|
239
|
-
for (const id of
|
|
216
|
+
for (const id of remote) {
|
|
240
217
|
if (id && !ids.includes(id)) ids.push(id);
|
|
241
218
|
}
|
|
242
|
-
return ids.
|
|
219
|
+
return ids.map((id) => ({
|
|
243
220
|
id,
|
|
244
221
|
desc: id === current
|
|
245
222
|
? "current · pick thinking next"
|
|
@@ -257,7 +234,6 @@ module.exports = {
|
|
|
257
234
|
suggestUcodeModels,
|
|
258
235
|
suggestUcodeThinkingLevels,
|
|
259
236
|
listUcodeModels,
|
|
260
|
-
fallbackModelSuggestions,
|
|
261
237
|
currentThinkingLevel,
|
|
262
238
|
persistThinkingLevel,
|
|
263
239
|
};
|