mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 12:52:11 +03:00
* feat(sse): add Microsoft Designer as image provider (#6672) Adds `microsoft-designer-web` — an unofficial, reverse-engineered Bearer-token web-session image provider, modeled on the existing `chatgpt-web`/`copilot-m365-web` "-web" provider category. - Registers the provider in WEB_COOKIE_PROVIDERS (src/shared/constants/ providers/web-cookie.ts) and IMAGE_PROVIDERS (open-sse/config/ imageRegistry.ts, new "designer-web" format). - New handler open-sse/handlers/imageGeneration/providers/designerWeb.ts implements the submit-then-poll DallE.ashx flow (Bearer access_token + ClientId/SessionId/UserId headers -> form POST -> poll for image_urls_thumbnail), wired into handleImageGeneration()'s dispatch. - The upstream ClientId header is a fixed, publicly-shared value (not a secret) — routed through resolvePublicCred() per Hard Rule #11, never as a string literal. - Registers the token-based credential requirement in webSessionCredentials.ts so the provider-connect UI asks for the right field; connection validation falls back to the existing generic web-cookie session-ping validator (no dedicated validator needed). - Extracted the KIE image-model catalog into a co-located open-sse/config/providers/registry/kie/models.ts module (mirrors the existing lmarena/directModels.ts pattern) to keep imageRegistry.ts under the file-size cap while adding the new provider entry. - Regenerated docs/reference/PROVIDER_REFERENCE.md (250 -> 251 providers) and updated the plain-text counts in README.md, AGENTS.md, CLAUDE.md. Tests (tests/unit/microsoft-designer-web-6672.test.ts, 16 cases): registry-entry shape assertions, the resolvePublicCred() shape assertion (Hard Rule #11), and the pure header/form-body/response- parsing helpers plus the handler's submit/poll/error/timeout paths against a mocked fetch — no live Designer session required. Reverse-engineered from the g4f MicrosoftDesigner.py provider reference (researched during #6672 triage); the exact upstream response shape has not been validated against a live Designer session, so the poll-loop implementation follows the documented g4f contract as closely as possible without a live capture. * fix(providers): satisfy web-cookie executor contract + document designer-web env vars (#6672)
52 lines
2.4 KiB
TypeScript
52 lines
2.4 KiB
TypeScript
// MicrosoftDesignerWebExecutor — chat-completions guard for the
|
|
// microsoft-designer-web web-cookie provider (#6672).
|
|
//
|
|
// Microsoft Designer (designerapp.officeapps.live.com/DallE.ashx) is an
|
|
// image-generation-only upstream: it has no chat/completions surface at all.
|
|
// The real request/response flow lives entirely in the image-generation
|
|
// handler (open-sse/handlers/imageGeneration/providers/designerWeb.ts),
|
|
// dispatched from open-sse/handlers/imageGeneration.ts by
|
|
// providerConfig.format === "designer-web" — NOT through getExecutor().
|
|
//
|
|
// microsoft-designer-web is still listed in WEB_COOKIE_PROVIDERS (it uses
|
|
// the same unofficial, DevTools-sourced bearer-token credential UX and
|
|
// subscription-risk notice as the other web-cookie providers — see
|
|
// tests/unit/microsoft-designer-web-6672.test.ts). Without a registered
|
|
// executor here, getExecutor("microsoft-designer-web") silently falls
|
|
// through to DefaultExecutor's `PROVIDERS[provider] || PROVIDERS.openai`
|
|
// fallback (open-sse/executors/index.ts:176 comment, #6699) — which would
|
|
// send the user's real Designer bearer token to api.openai.com, mislabeled
|
|
// as an OpenAI request, if anything ever mis-routes a chat/completions call
|
|
// to this provider.
|
|
//
|
|
// This executor closes that gap cheaply: it never calls the network. Any
|
|
// chat/completions attempt against microsoft-designer-web is rejected
|
|
// immediately with a clean, sanitized 400 telling the caller to use
|
|
// /v1/images/generations instead — satisfying the executor wrapper
|
|
// contract (tests/unit/executor-web-cookie-sweep.test.ts) without ever
|
|
// forwarding credentials anywhere.
|
|
import { BaseExecutor, type ExecuteInput } from "./base.ts";
|
|
import { makeExecutorErrorResult } from "../utils/error.ts";
|
|
|
|
const DESIGNER_WEB_BASE_URL =
|
|
"https://designerapp.officeapps.live.com/designerapp/DallE.ashx?action=GetDallEImagesCogSci";
|
|
|
|
export class MicrosoftDesignerWebExecutor extends BaseExecutor {
|
|
constructor() {
|
|
super("microsoft-designer-web", { id: "microsoft-designer-web", baseUrl: DESIGNER_WEB_BASE_URL });
|
|
}
|
|
|
|
async execute(_input: ExecuteInput) {
|
|
return makeExecutorErrorResult(
|
|
400,
|
|
"microsoft-designer-web is an image-generation-only provider and does not support " +
|
|
"chat completions. Use POST /v1/images/generations with model " +
|
|
'"microsoft-designer-web/dall-e-3" instead.',
|
|
_input.body,
|
|
DESIGNER_WEB_BASE_URL
|
|
);
|
|
}
|
|
}
|
|
|
|
export default MicrosoftDesignerWebExecutor;
|