feat: discover codex app-server capabilities
This commit is contained in:
@@ -86,6 +86,7 @@ export async function POST(request: NextRequest) {
|
||||
connected?: boolean;
|
||||
lastSeenAt?: string;
|
||||
lastActiveProjectId?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
};
|
||||
};
|
||||
preferredExecutionMode?: "gui" | "cli";
|
||||
|
||||
@@ -67,9 +67,22 @@ function boundDeviceIdFromDom() {
|
||||
return document.body.dataset.boundDeviceId || "mac-studio";
|
||||
}
|
||||
|
||||
function arrayLength(value: unknown) {
|
||||
return Array.isArray(value) ? value.length : 0;
|
||||
}
|
||||
|
||||
function textFromMetadata(value: unknown) {
|
||||
return typeof value === "string" && value.trim() ? value.trim() : "未发现";
|
||||
}
|
||||
|
||||
export function buildDeviceWorkspaceDetailCards(workspace: DeviceWorkspaceView) {
|
||||
const selectedDevice = workspace.selectedDevice;
|
||||
const primaryPolicy = workspace.projectExecutionPolicies?.[0];
|
||||
const codexAppServerMetadata = selectedDevice?.capabilities?.codexAppServer?.metadata ?? {};
|
||||
const codexModelsCount = arrayLength(codexAppServerMetadata.models);
|
||||
const codexSkillCount = arrayLength(codexAppServerMetadata.skills);
|
||||
const codexPluginCount = arrayLength(codexAppServerMetadata.plugins);
|
||||
const codexAppCount = arrayLength(codexAppServerMetadata.apps);
|
||||
|
||||
return {
|
||||
capabilities: {
|
||||
@@ -83,6 +96,18 @@ export function buildDeviceWorkspaceDetailCards(workspace: DeviceWorkspaceView)
|
||||
computerUse: `桌面控制:${
|
||||
selectedDevice?.capabilities?.computerUse?.connected ? "已连接" : "未连接"
|
||||
}`,
|
||||
codexAppServer: `Codex App Server:${
|
||||
selectedDevice?.capabilities?.codexAppServer?.connected ? "已连接" : "未连接"
|
||||
}`,
|
||||
codexModels:
|
||||
codexModelsCount > 0
|
||||
? `模型:${codexModelsCount} 个 · 默认 ${textFromMetadata(
|
||||
codexAppServerMetadata.defaultModelId,
|
||||
)} · 快速 ${textFromMetadata(codexAppServerMetadata.fastModelId)} · 深度 ${textFromMetadata(
|
||||
codexAppServerMetadata.deepModelId,
|
||||
)}`
|
||||
: "模型:未发现",
|
||||
codexExtensions: `扩展:Skill ${codexSkillCount} 个 · Plugin ${codexPluginCount} 个 · App ${codexAppCount} 个`,
|
||||
preferredExecutionMode: `默认执行模式:${
|
||||
selectedDevice?.preferredExecutionMode === "gui"
|
||||
? "GUI"
|
||||
@@ -705,6 +730,15 @@ export function DeviceEditorCard({
|
||||
<div className="rounded-2xl bg-[#F7F8FA] px-3 py-2">
|
||||
{detailCards.capabilities.items.computerUse}
|
||||
</div>
|
||||
<div className="rounded-2xl bg-[#F7F8FA] px-3 py-2">
|
||||
{detailCards.capabilities.items.codexAppServer}
|
||||
</div>
|
||||
<div className="rounded-2xl bg-[#F7F8FA] px-3 py-2">
|
||||
{detailCards.capabilities.items.codexModels}
|
||||
</div>
|
||||
<div className="rounded-2xl bg-[#F7F8FA] px-3 py-2">
|
||||
{detailCards.capabilities.items.codexExtensions}
|
||||
</div>
|
||||
<div className="rounded-2xl bg-[#F7F8FA] px-3 py-2">
|
||||
{detailCards.capabilities.items.preferredExecutionMode}
|
||||
</div>
|
||||
|
||||
@@ -610,6 +610,7 @@ export interface DeviceCapabilityState {
|
||||
connected: boolean;
|
||||
lastSeenAt?: string;
|
||||
lastActiveProjectId?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface DeviceCapabilities {
|
||||
@@ -2297,6 +2298,7 @@ function normalizeDeviceCapabilityState(
|
||||
connected: Boolean(raw?.connected),
|
||||
lastSeenAt: trimToDefined(raw?.lastSeenAt) ?? fallbackLastSeenAt,
|
||||
lastActiveProjectId: trimToDefined(raw?.lastActiveProjectId) ?? "",
|
||||
metadata: raw?.metadata && typeof raw.metadata === "object" ? JSON.parse(JSON.stringify(raw.metadata)) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user