From 2efe0d9336961e5ca6da4b0b8482d6ee5f9170c6 Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Sat, 30 May 2026 16:39:04 +0800 Subject: [PATCH] chore(deps): regenerate worker types --- worker-configuration.d.ts | 271 ++++++++++++++++++++++++++++++++------ 1 file changed, 231 insertions(+), 40 deletions(-) diff --git a/worker-configuration.d.ts b/worker-configuration.d.ts index 67a77ed..a0ce1d7 100644 --- a/worker-configuration.d.ts +++ b/worker-configuration.d.ts @@ -1,30 +1,31 @@ /* eslint-disable */ -// Generated by Wrangler by running `wrangler types` (hash: 66ec2d07ecff4cba477f98430a977e7f) -// Runtime types generated with workerd@1.20260507.1 2026-03-19 nodejs_compat +// Generated by Wrangler by running `wrangler types` (hash: 0c6962cb0ba4ddc8c608c52059e64907) +// Runtime types generated with workerd@1.20260526.1 2026-03-19 nodejs_compat +interface __BaseEnv_Env { + PASTES_BUCKET: R2Bucket; + DB: D1Database; + GC_QUEUE: Queue; + ASSETS: Fetcher; + XBIN_APP_NAME: "Xbin"; + XBIN_APP_VERSION: "1.0.0"; + XBIN_PROJECT_PAGE_URL: "https://github.com/xixu-me/xbin"; + XBIN_BASE_PATH: "/"; + XBIN_MAX_PASTE_BYTES: "10000000"; + XBIN_DEFAULT_EXPIRATION: "1hour"; + XBIN_SUPPORTED_EXPIRATIONS: "5min,10min,30min,1hour,3hour,6hour,12hour,1day,3day,1week"; + XBIN_ENABLE_LEGACY_API: "true"; + XBIN_REQUIRE_TURNSTILE: "false"; + XBIN_BURN_CLAIM_TTL_SECONDS: "120"; + PASTE_COORDINATOR: DurableObjectNamespace; +} declare namespace Cloudflare { interface GlobalProps { mainModule: typeof import("./src/index"); durableNamespaces: "PasteCoordinator"; } - interface Env { - PASTES_BUCKET: R2Bucket; - DB: D1Database; - GC_QUEUE: Queue; - ASSETS: Fetcher; - XBIN_APP_NAME: "Xbin"; - XBIN_APP_VERSION: "1.0.0"; - XBIN_PROJECT_PAGE_URL: "https://github.com/xixu-me/xbin"; - XBIN_BASE_PATH: "/"; - XBIN_MAX_PASTE_BYTES: "10000000"; - XBIN_DEFAULT_EXPIRATION: "1hour"; - XBIN_SUPPORTED_EXPIRATIONS: "5min,10min,30min,1hour,3hour,6hour,12hour,1day,3day,1week"; - XBIN_ENABLE_LEGACY_API: "true"; - XBIN_REQUIRE_TURNSTILE: "false"; - XBIN_BURN_CLAIM_TTL_SECONDS: "120"; - PASTE_COORDINATOR: DurableObjectNamespace; - } + interface Env extends __BaseEnv_Env {} } -interface Env extends Cloudflare.Env {} +interface Env extends __BaseEnv_Env {} type StringifyValues> = { [Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string; }; @@ -4849,9 +4850,6 @@ type ChatCompletionChoice = { finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"; logprobs: ChatCompletionLogprobs | null; }; -type ChatCompletionsPromptInput = { - prompt: string; -} & ChatCompletionsCommonOptions; type ChatCompletionsMessagesInput = { messages: Array; } & ChatCompletionsCommonOptions; @@ -8781,11 +8779,11 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 { postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output; } declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B { - inputs: XOR; + inputs: XOR; postProcessedOutputs: XOR; } declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B { - inputs: XOR; + inputs: XOR; postProcessedOutputs: XOR; } interface Ai_Cf_Leonardo_Phoenix_1_0_Input { @@ -9761,6 +9759,10 @@ declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 { inputs: ChatCompletionsInput; postProcessedOutputs: ChatCompletionsOutput; } +declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 { + inputs: ChatCompletionsInput; + postProcessedOutputs: ChatCompletionsOutput; +} declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B { inputs: ChatCompletionsInput; postProcessedOutputs: ChatCompletionsOutput; @@ -9858,7 +9860,9 @@ interface AiModels { "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B; "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash; "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5; + "@cf/moonshotai/kimi-k2.6": Base_Ai_Cf_Moonshotai_Kimi_K2_6; "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B; + "@cf/google/gemma-4-26b-a4b-it": Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT; } type AiOptions = { /** @@ -9911,10 +9915,8 @@ type AiModelsSearchObject = { value: string; }[]; }; -type ChatCompletionsBase = XOR; -type ChatCompletionsInput = XOR; +type ChatCompletionsBase = ChatCompletionsMessagesInput; +type ChatCompletionsInput = ChatCompletionsMessagesInput; interface InferenceUpstreamError extends Error { } interface AiInternalError extends Error { @@ -9959,8 +9961,15 @@ declare abstract class Ai { }, options?: AiOptions): Promise; // Normal (default) - known model run(model: Name, inputs: AiModelList[Name]['inputs'], options?: AiOptions): Promise; - // Unknown model (gateway fallback) - run(model: string & {}, inputs: Record, options?: AiOptions): Promise>; + // Unknown model (fallback). + // + // The `Exclude<..., keyof AiModelList>` constraint forces TypeScript to + // route any model name that is a literal key of `AiModelList` to one of + // the known-model overloads above (so input/output mismatches surface as + // type errors rather than silently falling back to `Record`). + // Names that aren't in `AiModelList` — e.g. third-party gateway models + // like `"google/nano-banana"` — still hit this overload. + run(model: Model extends keyof AiModelList ? never : Model, inputs: Record, options?: AiOptions): Promise>; models(params?: AiModelsSearchParams): Promise; toMarkdown(): ToMarkdownService; toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise; @@ -10151,12 +10160,17 @@ interface ArtifactsTokenListResult { /** Total number of tokens for the repository. */ total: number; } -/** Handle for a single repository. Returned by Artifacts.get(). */ +/** + * Handle for a single repository. Returned by Artifacts.get(). + * + * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs. + */ interface ArtifactsRepo extends ArtifactsRepoInfo { /** * Create an access token for this repo. * @param scope Token scope: "write" (default) or "read". * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000). + * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range. */ createToken(scope?: 'write' | 'read', ttl?: number): Promise; /** List tokens for this repo (metadata only, no plaintext). */ @@ -10165,6 +10179,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo { * Revoke a token by plaintext or ID. * @param tokenOrId Plaintext token or token ID. * @returns true if revoked, false if not found. + * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty. */ revokeToken(tokenOrId: string): Promise; // ── Fork ── @@ -10172,6 +10187,9 @@ interface ArtifactsRepo extends ArtifactsRepoInfo { * Fork this repo to a new repo. * @param name Target repository name. * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true). + * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid. + * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists. + * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running. */ fork(name: string, opts?: { description?: string; @@ -10179,13 +10197,41 @@ interface ArtifactsRepo extends ArtifactsRepoInfo { defaultBranchOnly?: boolean; }): Promise; } -/** Artifacts binding — namespace-level operations. */ +// ── Error types ────────────────────────────────────────────────────────────── +/** + * Error codes returned by Artifacts binding operations. + * + * Each code maps to a numeric code available on `ArtifactsError.numericCode`. + */ +type ArtifactsErrorCode = 'ALREADY_EXISTS' | 'NOT_FOUND' | 'IMPORT_IN_PROGRESS' | 'FORK_IN_PROGRESS' | 'INVALID_INPUT' | 'INVALID_REPO_NAME' | 'INVALID_TTL' | 'INVALID_URL' | 'REMOTE_AUTH_REQUIRED' | 'UPSTREAM_UNAVAILABLE' | 'MEMORY_LIMIT' | 'INTERNAL_ERROR'; +/** + * Error thrown by Artifacts binding operations. + * + * Uses a string `.code` discriminator following the Cloudflare platform + * convention (StreamError, ImagesError, etc.). The `.numericCode` matches + * the REST API `errors[].code` values. + */ +interface ArtifactsError extends Error { + readonly name: 'ArtifactsError'; + /** String error code for programmatic matching. */ + readonly code: ArtifactsErrorCode; + /** Numeric error code matching the REST API. */ + readonly numericCode: number; +} +// ── Binding ────────────────────────────────────────────────────────────────── +/** + * Artifacts binding — namespace-level operations. + * + * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs. + */ interface Artifacts { /** * Create a new repository with an initial access token. * @param name Repository name (alphanumeric, dots, hyphens, underscores). * @param opts Optional: readOnly flag, description, default branch name. * @returns Repo metadata with initial token. + * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid. + * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists. */ create(name: string, opts?: { readOnly?: boolean; @@ -10196,12 +10242,23 @@ interface Artifacts { * Get a handle to an existing repository. * @param name Repository name. * @returns Repo handle. + * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. + * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. + * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. */ get(name: string): Promise; /** * Import a repository from an external git remote. * @param params Source URL and optional branch/depth, plus target name and options. * @returns Repo metadata with initial token. + * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid. + * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS. + * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository. + * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication. + * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist. + * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached. + * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits. + * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists. */ import(params: { source: { @@ -10229,6 +10286,7 @@ interface Artifacts { * Delete a repository and all associated tokens. * @param name Repository name. * @returns true if deleted, false if not found. + * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid. */ delete(name: string): Promise; } @@ -11328,11 +11386,11 @@ interface SendEmail { send(message: EmailMessage): Promise; send(builder: { from: string | EmailAddress; - to: string | string[]; + to: string | EmailAddress | (string | EmailAddress)[]; subject: string; replyTo?: string | EmailAddress; - cc?: string | string[]; - bcc?: string | string[]; + cc?: string | EmailAddress | (string | EmailAddress)[]; + bcc?: string | EmailAddress | (string | EmailAddress)[]; headers?: Record; text?: string; html?: string; @@ -12174,9 +12232,19 @@ declare namespace CloudflareWorkersModule { attempt: number; config: WorkflowStepConfig; }; + export type WorkflowRollbackContext = { + error: Error; + output: T | undefined; + stepName: string; + }; + export type WorkflowRollbackHandler = (ctx: WorkflowRollbackContext) => Promise; + export type WorkflowStepRollbackOptions = { + rollback?: WorkflowRollbackHandler; + rollbackConfig?: WorkflowStepConfig; + }; export abstract class WorkflowStep { - do>(name: string, callback: (ctx: WorkflowStepContext) => Promise): Promise; - do>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise): Promise; + do>(name: string, callback: (ctx: WorkflowStepContext) => Promise, rollbackOptions?: WorkflowStepRollbackOptions): Promise; + do>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise, rollbackOptions?: WorkflowStepRollbackOptions): Promise; sleep: (name: string, duration: WorkflowSleepDuration) => Promise; sleepUntil: (name: string, timestamp: Date | number) => Promise; waitForEvent>(name: string, options: { @@ -13166,6 +13234,9 @@ declare namespace TailStream { // 1. This is an Onset event // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation) readonly spanId?: string; + // W3C trace flags from an upstream traceparent. Absent when no upstream + // sampling decision was made. + readonly traceFlags?: number; } interface TailEvent { // invocation id of the currently invoked worker stage. @@ -13439,6 +13510,103 @@ type WorkerVersionMetadata = { /** The timestamp of when the Worker Version was uploaded */ timestamp: string; }; +// ============ Web Search Request Types ============ +/** + * Options for a Web Search query. + */ +type WebSearchSearchOptions = { + /** The search query. */ + query: string; + /** + * Maximum number of results to return. Defaults to 10, capped at 20. + * The actual count may be lower if fewer matches exist. + */ + limit?: number; +}; +// ============ Web Search Response Types ============ +/** + * A single Web Search result. + * + * Web Search is discovery-only -- results carry catalog metadata about a page + * but never the page body. To read a result's content the caller invokes the + * global `fetch()` API against the result's `url`, at which point the + * destination's own access controls apply (including Cloudflare Pay-per-Crawl). + */ +type WebSearchResult = { + /** Canonical URL. */ + url: string; + /** Page title. */ + title: string; + /** Page-level description. May be absent. */ + description?: string; + /** + * Last-modified date for the page, when known. Naive (no timezone) + * ISO-8601 datetime, e.g. `"2025-11-30T04:39:48"`. + */ + lastModifiedDate?: string; + /** + * Page meta image URL (typically the `og:image`). May be absent. + */ + imageUrl?: string; + /** Optional favicon URL for UI hints. */ + faviconUrl?: string; +}; +/** + * Per-response metadata for a Web Search query. Carries operational + * fields useful for support and debugging. + */ +type WebSearchResponseMetadata = { + /** The query that was executed. */ + query: string; + /** Opaque request identifier used for support and debugging. */ + requestId: string; + /** End-to-end latency for this search request, in milliseconds. */ + latencyMs: number; +}; +/** + * Response from a Web Search query. + */ +type WebSearchSearchResponse = { + items: WebSearchResult[]; + metadata: WebSearchResponseMetadata; +}; +// ============ Web Search Binding Class ============ +/** + * Cloudflare Web Search binding. + * + * Discovery-only primitive for agents and Workers. Returns URLs and catalog + * metadata for a query; never returns page content or excerpts. To read a + * result's body, fetch the URL with the global `fetch()` API. + * + * Declared in wrangler with a single object (there is exactly one corpus, the + * public web, so there is no name, namespace, or instance to specify): + * + * ```jsonc + * { "web_search": { "binding": "WEBSEARCH" } } + * ``` + * + * @example + * ```ts + * const { items, metadata } = await env.WEBSEARCH.search({ + * query: "Cloudflare Workers", + * }); + * + * const top = items[0]; + * console.log(top.url, top.title, metadata.latencyMs); + * + * // Read content yourself; pay-per-crawl and other publisher + * // controls apply at the fetch site, not at search time. + * const page = await fetch(top.url); + * ``` + */ +declare abstract class WebSearch { + /** + * Run a Web Search query. + * @param options Search options. Only `query` is required. + * @returns The matching results plus per-response metadata. + */ + search(options: WebSearchSearchOptions): Promise; +} interface DynamicDispatchLimits { /** * Limit CPU time in milliseconds. @@ -13540,6 +13708,27 @@ interface WorkflowError { code?: number; message: string; } +interface WorkflowInstanceRestartOptions { + /** + * Restart from a specific step. If omitted, the instance restarts from the beginning. + * The step must exist in the instance's execution history. + */ + from?: { + /** + * The step name as defined in your workflow code. + */ + name: string; + /** + * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop). + * @default 1 + */ + count?: number; + /** + * Step type filter. Use when different step types share the same name. + */ + type?: 'do' | 'sleep' | 'waitForEvent'; + }; +} declare abstract class WorkflowInstance { public id: string; /** @@ -13555,9 +13744,11 @@ declare abstract class WorkflowInstance { */ public terminate(): Promise; /** - * Restart the instance. + * Restart the instance. Optionally restart from a specific step, preserving + * cached results for all steps before it. + * @param options Options for the restart, including an optional step to restart from. */ - public restart(): Promise; + public restart(options?: WorkflowInstanceRestartOptions): Promise; /** * Returns the current status of the instance. */