mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Clarify app-server protocol boundary mappings
This commit is contained in:
parent
6bfc6828ae
commit
629f6df984
2 changed files with 48 additions and 11 deletions
|
|
@ -36,14 +36,16 @@ export interface CatalogHookMetadata {
|
|||
enabled: boolean;
|
||||
isManaged: boolean;
|
||||
currentHash: string;
|
||||
trustStatus: HookItem["trustStatus"];
|
||||
trustStatus: AppServerHookTrustStatus;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
type AppServerHookTrustStatus = "managed" | "untrusted" | "trusted" | "modified";
|
||||
|
||||
export interface AppServerHookOperation {
|
||||
key: string;
|
||||
currentHash: string;
|
||||
trustStatus: HookItem["trustStatus"];
|
||||
trustStatus: AppServerHookTrustStatus;
|
||||
}
|
||||
|
||||
function modelMetadataFromCatalogModel(model: CatalogModel): ModelMetadata {
|
||||
|
|
@ -93,7 +95,7 @@ function hookItemFromCatalogHook(hook: CatalogHookMetadata): HookItem {
|
|||
enabled: hook.enabled,
|
||||
isManaged: hook.isManaged,
|
||||
currentHash: hook.currentHash,
|
||||
trustStatus: hook.trustStatus,
|
||||
trustStatus: hookTrustStatusFromCatalogTrustStatus(hook.trustStatus),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +107,14 @@ export function appServerHookOperationFromHookItem(hook: HookItem): AppServerHoo
|
|||
return {
|
||||
key: hook.key,
|
||||
currentHash: hook.currentHash,
|
||||
trustStatus: hook.trustStatus,
|
||||
trustStatus: appServerHookTrustStatus(hook.trustStatus),
|
||||
};
|
||||
}
|
||||
|
||||
function hookTrustStatusFromCatalogTrustStatus(status: AppServerHookTrustStatus): HookItem["trustStatus"] {
|
||||
return status;
|
||||
}
|
||||
|
||||
function appServerHookTrustStatus(status: HookItem["trustStatus"]): AppServerHookTrustStatus {
|
||||
return status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import type { CodexInputItem } from "../../domain/chat/input";
|
||||
|
||||
type AppServerUserInputImageDetail = "auto" | "low" | "high" | "original";
|
||||
|
||||
type AppServerUserInput =
|
||||
| { type: "text"; text: string; text_elements: [] }
|
||||
| { type: "image"; detail?: "auto" | "low" | "high" | "original"; url: string }
|
||||
| { type: "localImage"; detail?: "auto" | "low" | "high" | "original"; path: string }
|
||||
| { type: "image"; detail?: AppServerUserInputImageDetail; url: string }
|
||||
| { type: "localImage"; detail?: AppServerUserInputImageDetail; path: string }
|
||||
| { type: "skill"; name: string; path: string }
|
||||
| { type: "mention"; name: string; path: string };
|
||||
|
||||
|
|
@ -13,11 +15,7 @@ interface AppServerAdditionalContextEntry {
|
|||
}
|
||||
|
||||
export function toAppServerUserInput(input: readonly CodexInputItem[]): AppServerUserInput[] {
|
||||
return input.flatMap((item) => {
|
||||
if (item.type === "text") return { type: "text", text: item.text, text_elements: [] };
|
||||
if (item.type === "additionalContext") return [];
|
||||
return { ...item };
|
||||
});
|
||||
return input.flatMap((item) => appServerUserInputItemFromCodexInputItem(item));
|
||||
}
|
||||
|
||||
export function additionalContextFromCodexInput(
|
||||
|
|
@ -31,3 +29,32 @@ export function additionalContextFromCodexInput(
|
|||
}
|
||||
return Object.keys(additionalContext).length > 0 ? additionalContext : undefined;
|
||||
}
|
||||
|
||||
function appServerUserInputItemFromCodexInputItem(item: CodexInputItem): AppServerUserInput[] {
|
||||
switch (item.type) {
|
||||
case "text":
|
||||
return [{ type: "text", text: item.text, text_elements: [] }];
|
||||
case "image":
|
||||
return [{ type: "image", url: item.url, ...appServerImageDetailProp(item.detail) }];
|
||||
case "localImage":
|
||||
return [{ type: "localImage", path: item.path, ...appServerImageDetailProp(item.detail) }];
|
||||
case "skill":
|
||||
return [{ type: "skill", name: item.name, path: item.path }];
|
||||
case "mention":
|
||||
return [{ type: "mention", name: item.name, path: item.path }];
|
||||
case "additionalContext":
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function appServerImageDetailProp(detail: Extract<CodexInputItem, { type: "image" | "localImage" }>["detail"]): {
|
||||
detail?: AppServerUserInputImageDetail;
|
||||
} {
|
||||
return detail === undefined ? {} : { detail: appServerUserInputImageDetail(detail) };
|
||||
}
|
||||
|
||||
function appServerUserInputImageDetail(
|
||||
detail: NonNullable<Extract<CodexInputItem, { type: "image" | "localImage" }>["detail"]>,
|
||||
): AppServerUserInputImageDetail {
|
||||
return detail;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue