Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/mobile/src/components/ProviderIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ export function ProviderIcon(props: ProviderIconProps) {
);
}

if (props.provider === "muse") {
return (
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
<Path
fill="#0467DF"
d="M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z"
/>
</Svg>
);
}

// codex (and unknown drivers)
return (
<Svg width={size} height={size} viewBox="0 0 256 260" fill="none">
Expand Down
12 changes: 10 additions & 2 deletions apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
} from "../../native/StackHeader";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { serverEnvironment } from "../../state/server";
import { useEnvironmentServerConfig } from "../../state/entities";
import { useAtomCommand } from "../../state/use-atom-command";
import { useNewTaskFlow } from "./new-task-flow-provider";
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
Expand Down Expand Up @@ -510,7 +511,7 @@ function ThreadSettingsSessionProvider(
const value = useMemo<ThreadSettingsSessionValue>(
() => ({
environmentId: props.environmentId,
providerInstanceId: props.providerInstanceId,
providerInstanceId: props.selectedModel?.instanceId ?? props.providerInstanceId,
providerGroups: props.providerGroups,
runtimeMode: props.runtimeMode,
onUpdateRuntimeMode: props.onUpdateRuntimeMode,
Expand Down Expand Up @@ -541,6 +542,7 @@ function ThreadSettingsSessionProvider(
isDisplayed,
props.environmentId,
props.providerInstanceId,
props.selectedModel?.instanceId,
pendingModel,
pressModel,
providerFilter,
Expand Down Expand Up @@ -937,6 +939,12 @@ function ThreadSettingsChoiceContent(props: {
}) {
const insets = useSafeAreaInsets();
const session = useThreadSettingsSession();
const serverConfig = useEnvironmentServerConfig(session.environmentId);
const runtimeModeDescriptions = serverConfig?.providers.find(
(provider) =>
provider.instanceId ===
(session.pendingModel?.selection.instanceId ?? session.providerInstanceId),
)?.runtimeModeDescriptions;
const descriptorId = props.submenu.kind === "descriptor" ? props.submenu.id : null;

const activeDescriptor =
Expand All @@ -952,7 +960,7 @@ function ThreadSettingsChoiceContent(props: {
rows: RUNTIME_MODE_CHOICES.map((choice) => ({
id: choice.mode,
label: choice.label,
description: choice.description,
description: runtimeModeDescriptions?.[choice.mode] ?? choice.description,
selected: choice.mode === session.runtimeMode,
onPress: () => {
void Haptics.selectionAsync();
Expand Down
14 changes: 12 additions & 2 deletions apps/mobile/src/features/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import { environmentPresentations } from "../../state/presentation";
import { ResetCredits } from "./UsageLimitsSection";
import { useProviderColors } from "./usageProviders";

const DRIVER_LABEL: Partial<Record<string, string>> = { codex: "Codex", claudeAgent: "Claude" };
const DRIVER_LABEL: Partial<Record<string, string>> = {
codex: "Codex",
claudeAgent: "Claude",
muse: "Muse Code",
};
const PACE_LABEL = { ahead: "Ahead of pace", on: "On pace", under: "Under pace" } as const;

function accountName(account: LimitAccount) {
Expand Down Expand Up @@ -230,7 +234,13 @@ export function UsageLimitsSection({
<PoolWindowCard
key={`${window.kind}:${window.id}`}
pool={window}
color={pool.driver === "claudeAgent" ? colors.claude : colors.codex}
color={
pool.driver === "claudeAgent"
? colors.claude
: pool.driver === "muse"
? colors.muse
: colors.codex
}
now={now}
environmentIds={selectedEnvironmentIds === null ? null : [...selectedEnvironmentIds]}
/>
Expand Down
8 changes: 7 additions & 1 deletion apps/mobile/src/features/usage/UsageLimitsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ type Driver = ServerProvider["driver"];
function useBarColor(driver: Driver): string | null {
const colors = useProviderColors();
const kind: UsageProviderKind | null =
driver === "codex" ? "codex" : driver === "claudeAgent" ? "claude" : null;
driver === "codex"
? "codex"
: driver === "claudeAgent"
? "claude"
: driver === "muse"
? "muse"
: null;
return kind ? colors[kind] : null;
}

Expand Down
21 changes: 14 additions & 7 deletions apps/mobile/src/features/usage/UsageRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,17 @@ function ChartCard(props: {
{metric === "cost" ? "Raw token cost" : "Processed tokens"}
</Text>
<Text className="text-4xl font-t3-bold tabular-nums text-foreground">
{metric === "cost" ? `${formatUsd(merged.costUsd)}*` : formatTokens(merged.totalTokens)}
{metric === "cost"
? merged.costQuality.unpricedShare === 1
? "Unpriced"
: `${formatUsd(merged.costUsd)}*`
: formatTokens(merged.totalTokens)}
</Text>
<Text className="text-sm text-foreground-muted">
{metric === "cost"
? "* if billed at full API rate"
? merged.costQuality.unpricedShare === 1
? "API pricing unavailable"
: "* if billed at full API rate"
: `Across ${formatCount(merged.sessions)} sessions`}
</Text>
</View>
Expand Down Expand Up @@ -415,6 +421,9 @@ function ProviderSection(props: {
<SettingsSection title="Providers" card>
{ordered.map((provider, index) => {
const share = metric === "cost" ? provider.costShare : provider.tokenShare;
const models = merged.models.filter((entry) => entry.provider === provider.provider);
const costUnknown = models.length > 0 && models.every(isModelCostUnknown);
const costLabel = costUnknown ? "Unpriced" : formatUsd(provider.costUsd);
return (
<View
key={provider.provider}
Expand All @@ -429,9 +438,7 @@ function ProviderSection(props: {
<Text className="text-lg text-foreground">{PROVIDER_LABEL[provider.provider]}</Text>
</View>
<Text className="text-lg tabular-nums text-foreground">
{metric === "cost"
? formatUsd(provider.costUsd)
: formatTokens(provider.totalTokens)}
{metric === "cost" ? costLabel : formatTokens(provider.totalTokens)}
</Text>
</View>
<View className="h-1 flex-row overflow-hidden rounded-full bg-subtle">
Expand All @@ -443,8 +450,8 @@ function ProviderSection(props: {
</View>
<Text className="text-sm text-foreground-muted">
{metric === "cost"
? `${formatPercent(share)} of cost · ${formatTokens(provider.totalTokens)} tokens`
: `${formatPercent(share)} of tokens · ${formatUsd(provider.costUsd)}`}
? `${costUnknown ? "Unpriced" : `${formatPercent(share)} of cost`} · ${formatTokens(provider.totalTokens)} tokens`
: `${formatPercent(share)} of tokens · ${costLabel}`}
</Text>
</View>
);
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/features/usage/usageProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefe
* Series and table order. The chart stacks providers from the bottom in this
* order, so it also fixes which band sits on top of the bars.
*/
export const PROVIDER_ORDER: readonly UsageProviderKind[] = ["codex", "claude", "grok"];
export const PROVIDER_ORDER: readonly UsageProviderKind[] = ["codex", "claude", "grok", "muse"];

export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
claude: "Claude Code",
codex: "Codex",
grok: "Grok Build",
muse: "Muse Code",
};

/**
Expand All @@ -23,5 +24,6 @@ export function useProviderColors(): Record<UsageProviderKind, string> {
claude: "#d97757",
codex: scheme === "dark" ? "#e6e6e6" : "#3c3c43",
grok: scheme === "dark" ? "#a1a1aa" : "#52525b",
muse: "#6088d9",
};
}
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@effect/platform-node": "catalog:",
"@effect/platform-node-shared": "catalog:",
"@ff-labs/fff-node": "0.9.4",
"@muse-code/sdk": "0.1.1",
"@opencode-ai/sdk": "^1.3.15",
"effect": "catalog:",
"msgpackr-extract": "3.0.4",
Expand Down
150 changes: 150 additions & 0 deletions apps/server/src/provider/Drivers/MuseDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { MuseSettings, ProviderDriverKind, TextGenerationError } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import * as Schema from "effect/Schema";
import { ChildProcessSpawner } from "effect/unstable/process";
Comment thread
maria-rcks marked this conversation as resolved.
Resolved

import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
import * as ServerConfig from "../../config.ts";
import * as ServerSettings from "../../serverSettings.ts";
import { ProviderDriverError } from "../Errors.ts";
import * as MuseAdapter from "../Layers/MuseAdapter.ts";
import {
buildInitialMuseProviderSnapshot,
checkMuseProviderStatus,
} from "../Layers/MuseProvider.ts";
import { makeManagedServerProvider } from "../makeManagedServerProvider.ts";
import {
defaultProviderContinuationIdentity,
type ProviderDriver,
type ProviderInstance,
} from "../ProviderDriver.ts";
import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts";
import { makeManualOnlyProviderMaintenanceCapabilities } from "../providerMaintenance.ts";
import {
haveProviderSnapshotSettingsChanged,
makeProviderSnapshotSettingsSource,
} from "../providerUpdateSettings.ts";
import type { ServerProviderDraft } from "../providerSnapshot.ts";
import { withInstanceIdentity } from "./instanceIdentity.ts";
import { discoverMuseSkills } from "./MuseSkills.ts";

const DRIVER_KIND = ProviderDriverKind.make("muse");
const decodeSettings = Schema.decodeSync(MuseSettings);
const isProviderDriverError = Schema.is(ProviderDriverError);
const MAINTENANCE = makeManualOnlyProviderMaintenanceCapabilities({
provider: DRIVER_KIND,
packageName: null,
});
const unavailableTextGeneration = (operation: string) =>
Effect.fail(
new TextGenerationError({
operation,
detail:
"Muse Code does not yet support tool-free background text generation. Select another provider for generated titles and source control text.",
}),
);

export type MuseDriverEnv =
| BackgroundPolicy.BackgroundPolicy
| ChildProcessSpawner.ChildProcessSpawner
| FileSystem.FileSystem
| Path.Path
| ServerConfig.ServerConfig
| ServerSettings.ServerSettingsService;

export const MuseDriver: ProviderDriver<MuseSettings, MuseDriverEnv> = {
driverKind: DRIVER_KIND,
Comment thread
maria-rcks marked this conversation as resolved.
Resolved
Comment thread
maria-rcks marked this conversation as resolved.
Resolved
metadata: { displayName: "Muse Code", supportsMultipleInstances: true },
configSchema: MuseSettings,
defaultConfig: () => decodeSettings({}),
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
Effect.gen(function* () {
const { cwd } = yield* ServerConfig.ServerConfig;
const serverSettings = yield* ServerSettings.ServerSettingsService;
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const path = yield* Path.Path;
const processEnv = mergeProviderInstanceEnvironment(environment);
const effectiveConfig = { ...config, enabled };
const continuationIdentity = defaultProviderContinuationIdentity({
driverKind: DRIVER_KIND,
instanceId,
});
const stampInstance = withInstanceIdentity({
instanceId,
driverKind: DRIVER_KIND,
displayName,
accentColor,
continuationGroupKey: continuationIdentity.continuationKey,
});
const stampIdentity = (snapshot: ServerProviderDraft) => ({
...stampInstance(snapshot),
supportsTextGeneration: false,
});
const adapter = yield* MuseAdapter.make(effectiveConfig, {
environment: processEnv,
instanceId,
});
const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
const snapshot = yield* makeManagedServerProvider({
resolveMaintenance: () => Effect.succeed(MAINTENANCE),
getSettings: snapshotSettings.getSettings,
streamSettings: snapshotSettings.streamSettings,
haveSettingsChanged: haveProviderSnapshotSettingsChanged,
initialSnapshot: (settings) =>
buildInitialMuseProviderSnapshot(settings.provider).pipe(Effect.map(stampIdentity)),
checkProvider: checkMuseProviderStatus(effectiveConfig, processEnv, cwd).pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Effect.map(stampIdentity),
),
});
const snapshotForCwd = (workspaceCwd: string) =>
!effectiveConfig.enabled
? snapshot.getSnapshot
: Effect.all([
snapshot.getSnapshot,
discoverMuseSkills(effectiveConfig, processEnv, workspaceCwd).pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Effect.provideService(Path.Path, path),
Effect.mapError(
(cause) =>
new ProviderDriverError({
driver: DRIVER_KIND,
instanceId,
detail: "Failed to discover Muse skills for this workspace.",
cause,
}),
Comment thread
maria-rcks marked this conversation as resolved.
Resolved
Comment thread
maria-rcks marked this conversation as resolved.
Resolved
Comment thread
maria-rcks marked this conversation as resolved.
Resolved
),
),
]).pipe(Effect.map(([machineSnapshot, skills]) => ({ ...machineSnapshot, skills })));
return {
instanceId,
driverKind: DRIVER_KIND,
continuationIdentity,
displayName,
accentColor,
enabled,
snapshot,
snapshotForCwd,
adapter,
textGeneration: {
generateCommitMessage: () => unavailableTextGeneration("generateCommitMessage"),
generatePrContent: () => unavailableTextGeneration("generatePrContent"),
generateBranchName: () => unavailableTextGeneration("generateBranchName"),
generateThreadTitle: () => unavailableTextGeneration("generateThreadTitle"),
},
} satisfies ProviderInstance;
}).pipe(
Effect.mapError((cause) =>
isProviderDriverError(cause)
? cause
: new ProviderDriverError({
driver: DRIVER_KIND,
instanceId,
detail: "Failed to initialize the Muse Code provider.",
cause,
}),
),
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved
),
};
Loading
Loading