feat(server): native safe fetch (#14931)

This commit is contained in:
DarkSky
2026-05-09 02:40:25 +08:00
committed by GitHub
parent 32a94d68dc
commit bcbde16c04
30 changed files with 1370 additions and 526 deletions
+21
View File
@@ -1,6 +1,7 @@
import serverNativeModule, {
type ActionEvent as NativeActionEventContract,
type ActionRuntimeInput as NativeActionRuntimeInputContract,
type AssertSafeUrlRequest,
type BuiltInPromptRenderContract,
type BuiltInPromptSessionContract,
type BuiltInPromptSpec,
@@ -8,6 +9,8 @@ import serverNativeModule, {
type CanonicalStructuredRequestContract,
type CapabilityAttachmentContract,
type CapabilityModelCapability,
type ImageInspection,
type ImageInspectionOptions,
type LlmCoreMessage,
type LlmEmbeddingRequestContract,
type LlmImageRequestContract,
@@ -27,16 +30,29 @@ import serverNativeModule, {
type PromptStructuredResponseContract,
type PromptTokenCountContract,
type PromptTokenCountResult,
type RemoteAttachmentFetchRequest,
type RemoteAttachmentFetchResponse,
type RemoteMimeTypeRequest,
type RequestedModelMatchResponse,
type SafeFetchRequest,
type SafeFetchResponse,
type Tokenizer,
} from '@affine/server-native';
export type {
AssertSafeUrlRequest,
CapabilityAttachmentContract,
CapabilityModelCapability,
ImageInspection,
ImageInspectionOptions,
ModelConditionsContract,
PromptMessageContract,
PromptStructuredResponseContract,
RemoteAttachmentFetchRequest,
RemoteAttachmentFetchResponse,
RemoteMimeTypeRequest,
SafeFetchRequest,
SafeFetchResponse,
};
export type ActionEventType =
@@ -118,6 +134,11 @@ export function getTokenEncoder(model?: string | null): Tokenizer | null {
}
export const getMime = serverNativeModule.getMime;
export const inspectImageForProxy = serverNativeModule.inspectImageForProxy;
export const fetchRemoteAttachment = serverNativeModule.fetchRemoteAttachment;
export const inferRemoteMimeType = serverNativeModule.inferRemoteMimeType;
export const assertSafeUrl = serverNativeModule.assertSafeUrl;
export const safeFetch = serverNativeModule.safeFetch;
export const parseDoc = serverNativeModule.parseDoc;
export const htmlSanitize = serverNativeModule.htmlSanitize;
export const processImage = serverNativeModule.processImage;