diff --git a/.gitignore b/.gitignore index 9c94e80..f9aadef 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ external/* *.tsbuildinfo coverage/ *.tgz +.wrangler/ .env .env.* !.env.example +.dev.vars +.dev.vars.* diff --git a/README.md b/README.md index f737007..886ace5 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,24 @@ # codex-js -`codex-js` is an unofficial TypeScript port of the Codex runtime for building -Codex-backed web apps and interfaces. +Unofficial TypeScript packages for building Codex-backed web applications. -The workspace publishes two npm packages: +This workspace publishes: -- `@jrkropp/codex-js`: core client, server, runtime, and testing utilities. -- `@jrkropp/codex-js-react`: React chat UI, shadcn-compatible primitives, and CSS. - -Examples show how a host application supplies credentials, storage, prompts, -tools, and routes. +- `@jrkropp/codex-js`: browser client, server app-server helpers, runtime contracts, stores, model transport, and testing utilities. +- `@jrkropp/codex-js-react`: React chat UI, hooks, shadcn-compatible primitives, and generated CSS. This project is not affiliated with, endorsed by, or sponsored by OpenAI. ## Install -```bash -pnpm add @jrkropp/codex-js +```sh +npm install @jrkropp/codex-js ``` -For React UI: +For the packaged React UI: -```bash -pnpm add @jrkropp/codex-js @jrkropp/codex-js-react react react-dom +```sh +npm install @jrkropp/codex-js @jrkropp/codex-js-react react react-dom ``` ```tsx @@ -31,7 +27,11 @@ import { CodexChat } from "@jrkropp/codex-js-react"; import "@jrkropp/codex-js-react/styles.css"; const appServer = createCodexAppServerClient({ - url: async () => getCodexAppServerWebSocketUrl(), + url: async () => { + const response = await fetch("/api/codex/session", { method: "POST" }); + const { webSocketUrl } = await response.json(); + return webSocketUrl; + }, }); export function Chat({ threadId }: { threadId: string }) { @@ -41,52 +41,97 @@ export function Chat({ threadId }: { threadId: string }) { ## Public Surfaces -- `@jrkropp/codex-js`: small root client conveniences. -- `@jrkropp/codex-js/client`: browser app-server WebSocket client and protocol event helpers. -- `@jrkropp/codex-js/server`: Codex runtime, app-server processors, stores, model transport, and server helpers. -- `@jrkropp/codex-js/testing`: test stores and package test helpers. -- `@jrkropp/codex-js-react`: React chat components, hooks, render state, and composer helpers. -- `@jrkropp/codex-js-react/shadcn`: optional shadcn primitives for chat layout composition. -- `@jrkropp/codex-js-react/styles.css`: generated package CSS. +Core package: + +- `@jrkropp/codex-js` +- `@jrkropp/codex-js/client` +- `@jrkropp/codex-js/server` +- `@jrkropp/codex-js/testing` + +React package: + +- `@jrkropp/codex-js-react` +- `@jrkropp/codex-js-react/shadcn` +- `@jrkropp/codex-js-react/styles.css` + +There are no public upstream mirror or unstable imports. + +## Server Shape + +```ts +import { + createCodexAppServer, + createModelClient, + defineDynamicTool, + dynamicToolResponse, +} from "@jrkropp/codex-js/server"; +import { InMemoryThreadStore } from "@jrkropp/codex-js/testing"; + +const lookupDeployment = defineDynamicTool({ + name: "lookup_deployment", + description: "Look up deployment status.", + inputSchema: { type: "object", properties: {}, additionalProperties: false }, + async execute() { + return dynamicToolResponse.text("Deployment is healthy."); + }, +}); + +const appServer = createCodexAppServer({ + threadStore: new InMemoryThreadStore(), + dynamicTools: [lookupDeployment], + defaults: { + cwd: "/workspace", + model: "gpt-5-mini", + modelProvider: "openai", + }, + createModelClient({ session, threadId }) { + return createModelClient({ + apiKey: process.env.OPENAI_API_KEY!, + installationId: "my-app", + sessionId: session.id, + threadId, + }); + }, +}); +``` + +Host applications own HTTP routing, authentication, persistence, credentials, and platform bindings. `codex-js` owns the Codex app-server protocol, connection processing, runtime contracts, and dynamic tool mapping. -## Development +## Examples -```bash +```sh pnpm install -pnpm external:sync --codex /path/to/codex --t3 /path/to/t3-chat +pnpm dev:node-local +pnpm dev:cloudflare-example +``` + +`examples/node-local` is the smallest full-stack local path: Vite, a Node WebSocket endpoint, `createCodexAppServer`, `createCodexAppServerConnection`, in-memory threads, and example dynamic tools. + +`examples/cloudflare` is the deployable production-style path: plain Vite React, Worker API, Durable Object SQLite storage, one-time WebSocket tickets, hibernating Durable Object WebSockets, and server-executed dynamic tools. + +## Checks + +```sh pnpm typecheck +pnpm lint +pnpm build pnpm test pnpm test:pack -pnpm build pnpm publint pnpm pack:dry-run -pnpm dev:minimal +pnpm build:examples ``` -Upstream reference source should stay local and unchecked-in under -`external/`. The recommended setup is to sync local Codex and T3 source trees -into `external/codex` and `external/t3code` with `pnpm external:sync`, then keep -publishable package code inside the tracked `packages/*/src` trees. - ## Releases This repo uses Changesets. Add a changeset for user-visible changes: -```bash +```sh pnpm changeset ``` -Merging the Changesets release PR updates `CHANGELOG.md`, bumps package -versions, publishes to npm, and creates the GitHub release. - -Releases use npm trusted publishing. Existing package names can publish through -OIDC from `.github/workflows/release.yml`; brand-new package names must be -bootstrapped once with an npm token or a manual first publish before trusted -publishing can be configured for them. Run `pnpm release:preflight` to catch -that state before a release can partially publish. +Merging the Changesets release PR updates changelogs, publishes to npm, and creates the GitHub release. Releases use npm trusted publishing through GitHub Actions. ## License And Attribution -`codex-js` is licensed under Apache-2.0. Portions are modified TypeScript ports -of OpenAI Codex, which is also Apache-2.0. T3-derived UI code is used under the -T3 Tools MIT license. See `LICENSE` and `NOTICE`. +`codex-js` is licensed under Apache-2.0. Portions are modified TypeScript ports of OpenAI Codex, which is also Apache-2.0. T3-derived UI code is used under the T3 Tools MIT license. See `LICENSE` and `NOTICE`. diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 7d7fd8b..acb8751 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -8,11 +8,11 @@ This documentation describes the intended production design of `@jrkropp/codex-j - Establish durable primitives before implementation details. - Keep the public model small, standard, and composable. -- Treat `src/upstream/codex-rs` as a Codex-shaped upstream source and `src/upstream/t3code` as a T3-shaped upstream source. Codex and T3 are proven source references; follow their folder structure, naming, concepts, classes, contracts, and lifecycle patterns as closely as practical. -- Keep package-owned abstractions outside the upstream trees. +- Treat `external/codex` as the Codex terminology and lifecycle source of truth. +- Keep publishable package code semantic and boring: `client`, `server`, `testing`, `internal`, `generated`, `components`, `hooks`, and `shadcn`. - `ThreadStore` is the storage boundary. Product grouping, account boundaries, workspace selection, and deployment placement are not package primitives. - Runtime delivery follows Codex's server names: `OutgoingMessageSender`, `ThreadScopedOutgoingMessageSender`, `ThreadState`, and `ThreadStateManager`. -- Examples use the public doorways: `CodexChat`, `createCodexAppServerClient`, `CodexAppServerMessageProcessor`, `createCodexAppServerRuntime`, `ThreadStore`, `createModelClient`, and `sendOutgoingMessage`. +- Examples use the public doorways: `CodexChat`, `createCodexAppServerClient`, `createCodexAppServer`, `ThreadStore`, `createModelClient`, and dynamic tool helpers. - When behavior is wrong or unclear, compare against Codex or T3 first. If local code differs, realign it with the source reference instead of inventing a custom fix. - Prefer precise names over broad abstractions. - Separate accepted docs from staged thinking. @@ -20,10 +20,8 @@ This documentation describes the intended production design of `@jrkropp/codex-j ## Source References -- Codex source reference: `/Users/justinkropp/Github/host-app/external/codex` -- T3 source reference: `/Users/justinkropp/Github/host-app/external/t3code` -- Package Codex upstream source: `/Users/justinkropp/Github/host-app/packages/codex-js/src/upstream/codex-rs` -- Package T3 upstream source: `/Users/justinkropp/Github/host-app/packages/codex-js/src/upstream/t3code` +- Codex source reference: `/Users/justinkropp/Github/codex-js/external/codex` +- T3 source reference: `/Users/justinkropp/Github/codex-js/external/t3code` The `external/` directories are read-only. Do not import from them, edit them, or treat them as package source. @@ -38,12 +36,14 @@ The `external/` directories are read-only. Do not import from them, edit them, o ## Folder Structure -- `src/upstream/codex-rs/`: Codex-shaped upstream source tree. -- `src/upstream/t3code/`: T3-shaped upstream source tree. -- `src/runtime/`: platform-neutral Codex lifecycle code and contracts. -- `src/components/`: stable public React component surface. -- `src/hooks/`: stable public React hooks. -- `src/testing/`: package and consumer testing utilities. +- `packages/codex-js/src/client/`: browser app-server client facade. +- `packages/codex-js/src/server/`: platform-neutral app-server helpers. +- `packages/codex-js/src/testing/`: package and consumer testing utilities. +- `packages/codex-js/src/internal/`: implemented Codex ports and package internals. +- `packages/codex-js/src/generated/`: generated protocol surfaces. +- `packages/codex-js-react/src/components/`: stable public React component surface. +- `packages/codex-js-react/src/hooks/`: stable public React hooks. +- `packages/codex-js-react/src/shadcn/`: shadcn-compatible primitives. - `start-here/`: short onboarding path for the package model, philosophy, and primitives. - `architecture/`: accepted architecture notes and deeper system explanations. - `design/decisions/`: accepted ADR-style decisions. diff --git a/docs/README.md b/docs/README.md index 7e8ffcb..91a03f9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,18 +9,27 @@ Exploratory proposals live in [Staging](./staging/README.md) until their termino ## Package Source ```text -src/ - upstream/ - codex-rs/ - t3code/ - - runtime/ - components/ - hooks/ - testing/ +packages/ + codex-js/ + src/client/ + src/server/ + src/testing/ + src/internal/ + src/generated/ + + codex-js-react/ + src/components/ + src/hooks/ + src/shadcn/ + src/styles.css + +external/ + codex/ + t3code/ ``` -The source structure is accepted in [ADR 0001](./design/decisions/0001-package-source-structure.md). +Publishable source lives in `packages/*/src`. Source reference material lives in +`external/` or `docs/internal/` and is not part of the npm package surface. ## Documentation Areas diff --git a/docs/design/decisions/0001-package-source-structure.md b/docs/design/decisions/0001-package-source-structure.md index 1fab786..39eb189 100644 --- a/docs/design/decisions/0001-package-source-structure.md +++ b/docs/design/decisions/0001-package-source-structure.md @@ -4,44 +4,52 @@ Status: accepted ## Context -`@jrkropp/codex-js` is a Codex runtime and UI kit. The package needs a source layout that makes upstream source trees obvious, keeps package-owned runtime code separate, and lets consuming applications extend behavior without editing package source. +The workspace publishes a core Codex SDK and a separate React UI package. The +source layout should look like a conventional npm workspace, not like an +extracted application or a public mirror of reference repositories. -Codex and T3 are source references. Their folder structure, naming, concepts, classes, contracts, and lifecycle boundaries are preserved as closely as practical so updates can be ported by comparing the corresponding source files. +Codex remains the terminology and runtime source of truth, but reference +material belongs outside publishable package source. ## Decision -The package source is organized around upstream source trees, a package-owned runtime, React components, React hooks, and testing utilities. +The workspace uses two packages: ```text -src/ - upstream/ - codex-rs/ - t3code/ - - runtime/ - components/ - hooks/ - testing/ +packages/ + codex-js/ + src/client/ + src/server/ + src/testing/ + src/internal/ + src/generated/ + + codex-js-react/ + src/components/ + src/hooks/ + src/shadcn/ + src/styles.css ``` -`src/upstream/codex-rs` is the Codex-shaped runtime upstream source. `src/upstream/t3code` is the T3-shaped chat UI upstream source. Code in these trees follows upstream names, file boundaries, contracts, and lifecycle patterns. +`packages/codex-js` is dependency-light and non-React. It owns browser client +helpers, platform-neutral app-server helpers, runtime contracts, store +contracts, model-client creation, dynamic tool mapping, and testing utilities. -`src/runtime` contains package-owned, platform-neutral Codex lifecycle code and contracts. It does not depend on React, routing, Cloudflare, Durable Objects, host application projects, or host-app business behavior. +`packages/codex-js-react` owns React components, hooks, shadcn-compatible +primitives, generated CSS, and React-only dependencies. -`src/components` contains the stable public React component surface built from the T3 upstream source. Developers import application-facing chat components from `components` rather than from the upstream tree. - -`src/hooks` contains the stable public React hooks that bind a configured runtime to React applications. Hooks stay separate from components so developers can use the runtime with their own UI. - -`src/testing` contains test utilities and lightweight helpers for package consumers and package tests. - -Platform-specific implementation details are not source primitives. Cloudflare Workers, Durable Objects, browser storage, routing, credentials, tools, prompts, and product-specific renderers live in consuming applications or documentation guides. +Reference and parity material lives in `external/`, `reference/`, or +`docs/internal/`. It is not exposed through package exports or included in npm +tarballs. ## Consequences -Upstream-shaped code is visually isolated from package-owned code. Package-owned abstractions stay outside the upstream trees. - -The package remains replaceable. Consuming applications extend behavior through composition, contracts, slots, renderers, tools, prompts, storage, and app-server boundaries instead of modifying package source. +Public imports are boring and semantic. Consumers use `/client`, `/server`, +`/testing`, the React package root, `/shadcn`, and `/styles.css`. -A Durable Object is one possible implementation of a Codex store and app-server boundary. It is not a primitive of the Codex assistant package. +Cloudflare Workers, Durable Objects, local files, databases, credentials, auth, +prompts, and product-specific tools remain host application concerns. -When behavior is wrong or unclear, the first step is to compare against Codex or T3 and realign the package with the corresponding source reference. +When behavior is wrong or unclear, compare against Codex terminology and +lifecycle concepts, then implement the package-facing API in the conventional +package folders. diff --git a/docs/design/decisions/0002-core-runtime-boundary.md b/docs/design/decisions/0002-core-runtime-boundary.md index f3356e3..fc7ee82 100644 --- a/docs/design/decisions/0002-core-runtime-boundary.md +++ b/docs/design/decisions/0002-core-runtime-boundary.md @@ -26,7 +26,10 @@ Core `EventMsg` values are runtime and storage internals. App-server implementat React chat state reduces generated app-server protocol events into `ThreadEventStore`. Hooks and components render `ThreadEventSnapshot` state derived from generated `Thread`, `Turn`, `ThreadItem`, `ServerNotification`, and `ServerRequest` values. Core events remain below the app-server boundary. -Protocol state belongs in `src/runtime`; T3 projection belongs at the component boundary. The runtime reducer does not import T3 timeline types. Components create `CodexChatRenderState` from protocol snapshots and lifecycle UI state before rendering the T3-derived timeline, composer, banners, and pending-request slots. +Protocol state belongs in the core package runtime internals. React projection +belongs in `@jrkropp/codex-js-react`. Components create +`CodexChatRenderState` from protocol snapshots and lifecycle UI state before +rendering the timeline, composer, banners, and pending-request slots. The package model uses Codex-shaped terms: @@ -57,10 +60,11 @@ Product grouping, account boundaries, workspace selection, and deployment placem The package layers remain explicit: -- `src/upstream/codex-rs` is the faithful Codex runtime upstream source. -- `src/runtime` contains platform-neutral lifecycle contracts around Codex concepts. -- `src/components` contains the stable T3-derived React component surface. -- `src/hooks` contains React hooks around a configured runtime. +- `packages/codex-js/src/client` contains browser app-server client helpers. +- `packages/codex-js/src/server` contains platform-neutral app-server helpers. +- `packages/codex-js/src/internal` contains implemented Codex ports and internals. +- `packages/codex-js-react/src/components` contains the stable React component surface. +- `packages/codex-js-react/src/hooks` contains React hooks around a configured app-server client. - The consuming app owns storage, routing, auth, tools, prompts, product renderers, and deployment. The app server runs Codex. The store remembers Codex. The UI renders Codex as generated app-server snapshots and live events. diff --git a/docs/design/decisions/0003-public-runtime-contract.md b/docs/design/decisions/0003-public-runtime-contract.md index 4517ffc..8204d45 100644 --- a/docs/design/decisions/0003-public-runtime-contract.md +++ b/docs/design/decisions/0003-public-runtime-contract.md @@ -4,7 +4,10 @@ Status: accepted ## Context -`@jrkropp/codex-js` exposes a public package surface on top of two upstream source trees: Codex for runtime semantics and T3 for chat interaction ownership. The public contract must stay small enough to understand quickly while remaining faithful to those source systems. +`@jrkropp/codex-js` exposes a public package surface for Codex runtime semantics. +`@jrkropp/codex-js-react` exposes the React presentation surface. The public +contract must stay small enough to understand quickly while remaining faithful +to Codex terminology. The package surface contains ergonomic concepts only where they clarify usage without creating a second runtime model. The pressure test compares the public surface against Codex primitives, T3 lifecycle ownership, and common consuming application shapes. @@ -37,49 +40,52 @@ T3 terms define the React chat lifecycle boundary. Optimistic rows, local dispat The canonical public import paths are: +- `@jrkropp/codex-js` +- `@jrkropp/codex-js/client` - `@jrkropp/codex-js/server` -- `@jrkropp/codex-js/react` -- `@jrkropp/codex-js/react` +- `@jrkropp/codex-js/testing` +- `@jrkropp/codex-js-react` +- `@jrkropp/codex-js-react/shadcn` +- `@jrkropp/codex-js-react/styles.css` -The package root is a small plug-and-play chat entrypoint. It does not flatten -runtime, hook, component, Codex mirror, or T3 mirror exports into one namespace. - -The Codex and T3 upstream source import paths remain available for advanced use, but app-facing code should prefer the canonical package surfaces. +The package roots are small. They do not flatten runtime, hook, component, or +reference-source exports into one namespace. Reference-source paths are not +public imports. ## Public Surface Classification -| Concept | Classification | Decision | -| --- | --- | --- | -| `ThreadStore` | Codex-native | Use the Codex-shaped store contract as the storage boundary. | -| `ThreadReader` | Codex store read view | Use for store-only and headless hydration when hooks need only `readThread` and `loadHistory`. | -| `LiveThread` | Codex-native | Use for live thread lifecycle and store-backed thread operations. | -| `ClientRequest` | Codex app-server protocol | Use for typed client-to-server app-server method calls. | -| `ServerNotification` | Codex app-server protocol | Use for typed server-to-client notification flow. | -| `ServerRequest` | Codex app-server protocol | Use for server-to-client requests that require request-id resolution. | -| `RequestId` | Codex app-server protocol | Use to resolve or reject server requests. | -| `AppServerSession` | Codex app-server client helper | Own request-id lifecycle and typed lifecycle helpers over generated `ClientRequest` values. | -| `PendingAppServerRequests` | Codex app-server request state | Own pending UI state keyed by `RequestId`. | -| `ThreadEventStore` | Codex app-server protocol state | Own generated `Thread`, `Turn`, `ThreadItem`, pending server request, warning, error, active-turn, and connection state for chat UI. | -| `ThreadEventSnapshot` | Codex app-server protocol state | Expose immutable protocol-native state to hooks and components. | -| `Submission` | Codex-native | Use inside Codex runtime/session internals, not as the public UI response contract. | -| `Event` and `EventMsg` | Codex-native | Use for core runtime event flow inside runtime and storage internals. | -| `ThreadHistoryBuilder` | Codex-native | Use for low-level history projection. | -| `RenderedThreadState` | Codex-native projection | Keep as a low-level core projection, not the primary app-facing chat state. | -| `CodexChatRuntimeOptions` | Component ergonomic facade | Configure an app-server-backed chat runtime with optional thread and optional store reader fallback. | -| `CodexAppServer` | Codex app-server boundary | Shape around Codex generated `ClientRequest`, `ServerNotification`, `ServerRequest`, `RequestId`, event streaming, and request-id resolution; hide route, credential, WebSocket, and platform details in the host adapter. | -| Component and hook props | React ergonomics | Keep package-name-neutral and store-centered. | -| Draft helpers | T3 lifecycle/app routing | Keep in `hooks` or host-app glue unless they operate only on Codex data. | -| Local dispatch helpers | T3 lifecycle | Keep with chat lifecycle code, close to `ChatView` and composer ownership. | +| Concept | Classification | Decision | +| -------------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ThreadStore` | Codex-native | Use the Codex-shaped store contract as the storage boundary. | +| `ThreadReader` | Codex store read view | Use for store-only and headless hydration when hooks need only `readThread` and `loadHistory`. | +| `LiveThread` | Codex-native | Use for live thread lifecycle and store-backed thread operations. | +| `ClientRequest` | Codex app-server protocol | Use for typed client-to-server app-server method calls. | +| `ServerNotification` | Codex app-server protocol | Use for typed server-to-client notification flow. | +| `ServerRequest` | Codex app-server protocol | Use for server-to-client requests that require request-id resolution. | +| `RequestId` | Codex app-server protocol | Use to resolve or reject server requests. | +| `AppServerSession` | Codex app-server client helper | Own request-id lifecycle and typed lifecycle helpers over generated `ClientRequest` values. | +| `PendingAppServerRequests` | Codex app-server request state | Own pending UI state keyed by `RequestId`. | +| `ThreadEventStore` | Codex app-server protocol state | Own generated `Thread`, `Turn`, `ThreadItem`, pending server request, warning, error, active-turn, and connection state for chat UI. | +| `ThreadEventSnapshot` | Codex app-server protocol state | Expose immutable protocol-native state to hooks and components. | +| `Submission` | Codex-native | Use inside Codex runtime/session internals, not as the public UI response contract. | +| `Event` and `EventMsg` | Codex-native | Use for core runtime event flow inside runtime and storage internals. | +| `ThreadHistoryBuilder` | Codex-native | Use for low-level history projection. | +| `RenderedThreadState` | Codex-native projection | Keep as a low-level core projection, not the primary app-facing chat state. | +| `CodexChatRuntimeOptions` | Component ergonomic facade | Configure an app-server-backed chat runtime with optional thread and optional store reader fallback. | +| `CodexAppServer` | Codex app-server boundary | Shape around Codex generated `ClientRequest`, `ServerNotification`, `ServerRequest`, `RequestId`, event streaming, and request-id resolution; hide route, credential, WebSocket, and platform details in the host adapter. | +| Component and hook props | React ergonomics | Keep package-name-neutral and store-centered. | +| Draft helpers | T3 lifecycle/app routing | Keep in `hooks` or host-app glue unless they operate only on Codex data. | +| Local dispatch helpers | T3 lifecycle | Keep with chat lifecycle code, close to `ChatView` and composer ownership. | ## Pressure Test Findings -| Scenario | Required package concepts | Host-owned concepts | Result | -| --- | --- | --- | --- | -| Local file-backed app | `ThreadStore`, `LiveThread`, `Submission`, `ThreadEventStore`, hooks or components | Local file paths, user identity, persistence location | Passes when the store is configured before entering runtime. | -| Cloudflare Durable Object app | Same runtime concepts plus an app-server implementation | Durable Object naming, bindings, auth, routing, deployment | Passes when Durable Object placement is hidden behind store and app-server boundaries. | -| Custom product app | Runtime plus renderer/tool/prompt extension points | Product prompts, tools, auth, renderers, route paths | Passes when extensions enter through composition rather than package source edits. | -| Headless app | `runtime` and `hooks` | Entire UI | Passes when hooks expose state/actions without requiring package components. | -| Plug-and-play app | `components` with configured reader and app server | Store, reader, and app-server construction | Passes when the component API does not expose routes, Cloudflare, deployment placement, or T3 internals. | +| Scenario | Required package concepts | Host-owned concepts | Result | +| ----------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| Local file-backed app | `ThreadStore`, `LiveThread`, `Submission`, `ThreadEventStore`, hooks or components | Local file paths, user identity, persistence location | Passes when the store is configured before entering runtime. | +| Cloudflare Durable Object app | Same runtime concepts plus an app-server implementation | Durable Object naming, bindings, auth, routing, deployment | Passes when Durable Object placement is hidden behind store and app-server boundaries. | +| Custom product app | Runtime plus renderer/tool/prompt extension points | Product prompts, tools, auth, renderers, route paths | Passes when extensions enter through composition rather than package source edits. | +| Headless app | `runtime` and `hooks` | Entire UI | Passes when hooks expose state/actions without requiring package components. | +| Plug-and-play app | `components` with configured reader and app server | Store, reader, and app-server construction | Passes when the component API does not expose routes, Cloudflare, deployment placement, or T3 internals. | ## Consequences diff --git a/packages/codex-js/CODEX_PARITY_LEDGER.json b/docs/internal/CODEX_PARITY_LEDGER.json similarity index 99% rename from packages/codex-js/CODEX_PARITY_LEDGER.json rename to docs/internal/CODEX_PARITY_LEDGER.json index 007bee7..a4e264d 100644 --- a/packages/codex-js/CODEX_PARITY_LEDGER.json +++ b/docs/internal/CODEX_PARITY_LEDGER.json @@ -1,13 +1,13 @@ { "schema": "codex-rs-typescript-parity-ledger.v1", - "referenceRoot": ".reference/codex/codex-rs", + "referenceRoot": "external/codex/codex-rs", "mirrorRoot": "packages/codex-js/src/upstream/codex-rs", "totals": { "referenceCrates": 89, "referenceRustFiles": 1818, - "implemented": 139, + "implemented": 150, "platform_adaptation": 0, - "stubbed": 1679, + "stubbed": 1668, "missing": 0 }, "crates": [ @@ -204,14 +204,14 @@ "crate": "app-server-client", "referencePath": "app-server-client/src/lib.rs", "mirrorPath": "app-server-client/src/lib.ts", - "reason": "shared app-server client facade and typed request helpers ported to TypeScript", + "reason": "not ported yet", "status": "implemented" }, { "crate": "app-server-client", "referencePath": "app-server-client/src/remote.rs", "mirrorPath": "app-server-client/src/remote.ts", - "reason": "websocket-backed remote app-server client ported to TypeScript", + "reason": "not ported yet", "status": "implemented" }, { @@ -540,7 +540,7 @@ "crate": "app-server-transport", "referencePath": "app-server-transport/src/outgoing_message.rs", "mirrorPath": "app-server-transport/src/outgoing_message.ts", - "reason": "transport-level outgoing message types ported to TypeScript", + "reason": "not ported yet", "status": "implemented" }, { @@ -554,7 +554,7 @@ "crate": "app-server-transport", "referencePath": "app-server-transport/src/transport/mod.rs", "mirrorPath": "app-server-transport/src/transport/mod.ts", - "reason": "JSON-RPC transport parsing and serialization ported to TypeScript", + "reason": "not ported yet", "status": "implemented" }, { @@ -657,8 +657,8 @@ }, { "crate": "app-server", - "referencePath": "app-server/src/bespoke_event_handling.rs", - "mirrorPath": "app-server/src/bespoke_event_handling.ts", + "referencePath": "app-server/src/app_server_event_mapping.rs", + "mirrorPath": "app-server/src/app_server_event_mapping.ts", "reason": "not ported yet", "status": "implemented" }, @@ -827,7 +827,7 @@ "crate": "app-server", "referencePath": "app-server/src/request_processors.rs", "mirrorPath": "app-server/src/request_processors.ts", - "reason": "ported TypeScript app-server request processor", + "reason": "native process", "status": "implemented" }, { @@ -939,7 +939,7 @@ "crate": "app-server", "referencePath": "app-server/src/request_processors/mcp_processor.rs", "mirrorPath": "app-server/src/request_processors/mcp_processor.ts", - "reason": "ported TypeScript app-server request processor", + "reason": "native process", "status": "implemented" }, { @@ -960,7 +960,7 @@ "crate": "app-server", "referencePath": "app-server/src/request_processors/request_errors.rs", "mirrorPath": "app-server/src/request_processors/request_errors.ts", - "reason": "ported TypeScript app-server request processor", + "reason": "native process", "status": "implemented" }, { @@ -995,7 +995,7 @@ "crate": "app-server", "referencePath": "app-server/src/request_processors/thread_processor.rs", "mirrorPath": "app-server/src/request_processors/thread_processor.ts", - "reason": "ported TypeScript app-server request processor", + "reason": "native process", "status": "implemented" }, { @@ -1023,7 +1023,7 @@ "crate": "app-server", "referencePath": "app-server/src/request_processors/turn_processor.rs", "mirrorPath": "app-server/src/request_processors/turn_processor.ts", - "reason": "ported TypeScript app-server request processor", + "reason": "native process", "status": "implemented" }, { @@ -1058,7 +1058,7 @@ "crate": "app-server", "referencePath": "app-server/src/thread_state.rs", "mirrorPath": "app-server/src/thread_state.ts", - "reason": "Thread subscription and connection state manager ported to TypeScript", + "reason": "not ported yet", "status": "implemented" }, { @@ -1079,7 +1079,7 @@ "crate": "app-server", "referencePath": "app-server/src/transport.rs", "mirrorPath": "app-server/src/transport.ts", - "reason": "App-server transport facade points at app-server-transport mirror", + "reason": "not ported yet", "status": "implemented" }, { @@ -2682,15 +2682,15 @@ "crate": "codex-mcp", "referencePath": "codex-mcp/src/auth_elicitation.rs", "mirrorPath": "codex-mcp/src/auth_elicitation.ts", - "reason": "Codex Apps connector auth failure parsing, auth elicitation planning, completed-result shaping, and elicitation messages are ported.", + "reason": "not ported yet", "status": "implemented" }, { "crate": "codex-mcp", "referencePath": "codex-mcp/src/codex_apps.rs", "mirrorPath": "codex-mcp/src/codex_apps.ts", - "reason": "Codex Apps catalog cache and connector normalization are ported; filesystem cache storage is adapted behind a package storage interface.", - "status": "platform_adaptation" + "reason": "not ported yet", + "status": "implemented" }, { "crate": "codex-mcp", @@ -2703,29 +2703,29 @@ "crate": "codex-mcp", "referencePath": "codex-mcp/src/connection_manager.rs", "mirrorPath": "codex-mcp/src/connection_manager.ts", - "reason": "Live MCP manager aggregation, startup snapshot behavior, raw tool routing, resource delegation, transport-origin helpers, and startup error display are ported; native server startup is provided through platform RmcpClientLike adapters.", - "status": "platform_adaptation" + "reason": "not ported yet", + "status": "implemented" }, { "crate": "codex-mcp", "referencePath": "codex-mcp/src/elicitation.rs", "mirrorPath": "codex-mcp/src/elicitation.ts", - "reason": "Elicitation request tracking, policy rejection, auto-deny, empty-form auto-accept, reviewer short-circuiting, event emission, and response resolution are ported.", + "reason": "not ported yet", "status": "implemented" }, { "crate": "codex-mcp", "referencePath": "codex-mcp/src/lib.rs", "mirrorPath": "codex-mcp/src/lib.ts", - "reason": "Crate-level TypeScript exports mirror the ported codex-mcp modules.", + "reason": "not ported yet", "status": "implemented" }, { "crate": "codex-mcp", "referencePath": "codex-mcp/src/mcp/auth.rs", "mirrorPath": "codex-mcp/src/mcp/auth.ts", - "reason": "OAuth support detection, auth status calculation, scope resolution precedence, and retry-without-scopes checks are ported; discovery uses Web fetch as a platform adaptation.", - "status": "platform_adaptation" + "reason": "not ported yet", + "status": "implemented" }, { "crate": "codex-mcp", @@ -2738,15 +2738,15 @@ "crate": "codex-mcp", "referencePath": "codex-mcp/src/mcp/mod.rs", "mirrorPath": "codex-mcp/src/mcp/mod.ts", - "reason": "MCP tool name constants and Responses tool-name sanitization helpers are ported.", + "reason": "not ported yet", "status": "implemented" }, { "crate": "codex-mcp", "referencePath": "codex-mcp/src/rmcp_client.rs", "mirrorPath": "codex-mcp/src/rmcp_client.ts", - "reason": "ManagedClient, AsyncManagedClient, startup snapshots, tool listing, Codex Apps cache use, plugin provenance annotation, and basic client delegation are ported; native process/HTTP construction is a platform adapter.", - "status": "platform_adaptation" + "reason": "not ported yet", + "status": "implemented" }, { "crate": "codex-mcp", @@ -2759,7 +2759,7 @@ "crate": "codex-mcp", "referencePath": "codex-mcp/src/tools.rs", "mirrorPath": "codex-mcp/src/tools.ts", - "reason": "MCP tool filtering, file-parameter schema masking, qualification, collision handling, and callable-name length guards are ported.", + "reason": "not ported yet", "status": "implemented" }, { @@ -4664,7 +4664,7 @@ "referencePath": "core/src/state/session.rs", "mirrorPath": "core/src/state/session.ts", "reason": "not ported yet", - "status": "stubbed" + "status": "implemented" }, { "crate": "core", @@ -4685,7 +4685,7 @@ "referencePath": "core/src/stream_events_utils.rs", "mirrorPath": "core/src/stream_events_utils.ts", "reason": "not ported yet", - "status": "stubbed" + "status": "implemented" }, { "crate": "core", diff --git a/docs/internal/CODEX_PARITY_LEDGER.md b/docs/internal/CODEX_PARITY_LEDGER.md new file mode 100644 index 0000000..7d7a88b --- /dev/null +++ b/docs/internal/CODEX_PARITY_LEDGER.md @@ -0,0 +1,66 @@ +# Codex Runtime Parity Ledger + +This package contains modified TypeScript ports and platform adaptations of +OpenAI Codex source files. OpenAI Codex is licensed under Apache-2.0; attribution +is retained in `NOTICE`. + +This ledger records the package subsystems that intentionally mirror Codex. It +is the working checklist for keeping the TypeScript runtime aligned with +`external/codex/codex-rs` while keeping host application behavior outside the +package. + +The ownership model stays explicit: Codex owns runtime truth, T3 owns +interaction quality, and host apps own product meaning. + +The whole-workspace structural inventory is generated by +`npm --workspace @jrkropp/codex-js run codex:mirror` and stored +in `CODEX_PARITY_LEDGER.json`. The current mirror covers 89 reference crates and +1,818 Rust source files with no `missing` rows: implemented files remain +functional TypeScript ports, unsupported native/CLI/TUI surfaces compile as +shared `UnsupportedCodexFeatureError` stubs, and future ports move rows from +`stubbed` to `implemented` or `platform_adaptation`. + +| Subsystem | Package Path | Codex Reference | Status | Notes | +| --- | --- | --- | --- | --- | +| Model client | `src/upstream/codex-rs/core/src/client.ts` | `external/codex/codex-rs/core/src/client.rs` | Mirrored with platform adaptation | Session-scoped `ModelClient`, turn-scoped `ModelClientSession`, WebSocket-first streaming, HTTP/SSE sticky fallback, prewarm, incremental `previous_response_id`, and best-effort `response.processed` follow Codex. Fetch/WebSocket primitives are Worker-compatible TypeScript adaptations. | +| Responses transport | `src/upstream/codex-rs/codex-api/src/endpoint/responses.ts` and `responses_websocket.ts` | `external/codex/codex-rs/codex-api/src/endpoint/responses.rs` and `responses_websocket.rs` | Mirrored with platform adaptation | The package preserves Codex endpoint split: Responses HTTP/SSE fallback and Responses-over-WebSocket primary transport. Cloudflare `fetch` upgrade replaces Rust client plumbing. | +| Request wire shape | `src/upstream/codex-rs/codex-api/src/common.ts` and `requests/responses.ts` | `external/codex/codex-rs/codex-api/src/common.rs` and `requests/responses.rs` | Mirrored | Optional request fields are omitted from wire payloads like Rust `skip_serializing_if`. `prompt_cache_key` is thread id for normal and compaction requests. | +| Token usage | `src/upstream/codex-rs/codex-api/src/sse/responses.ts` and `src/upstream/codex-rs/core/src/session/session.ts` | `external/codex/codex-rs/codex-api/src/sse/responses.rs` and `core/src/session/session.rs` | Mirrored | Cached tokens come only from `usage.input_tokens_details.cached_tokens`; reasoning tokens come only from `usage.output_tokens_details.reasoning_tokens`; accumulation uses `TokenUsageInfo`. | +| Context updates | `src/upstream/codex-rs/core/src/context` and `src/upstream/codex-rs/core/src/session/session.ts` | `external/codex/codex-rs/core/src/context` and `core/src/session/session.rs` | Mirrored with known gaps | Runtime order matches Codex: context updates are recorded before the user message, and prompts are built from persisted history. Additional Codex context sections are tracked as explicit expansion work. | +| Context manager | `src/upstream/codex-rs/core/src/context_manager` | `external/codex/codex-rs/core/src/context_manager` | Mirrored | `ContextManager.record_items` truncates `function_call_output` and `custom_tool_call_output` before history storage; `for_prompt` normalizes missing/orphan call outputs and strips image content for text-only models; `replace` is an exact rewrite used by compaction and rollback. | +| Session state | `src/upstream/codex-rs/core/src/state/session.ts` | `external/codex/codex-rs/core/src/state/session.rs` | Mirrored with platform adaptation | `SessionState` owns live `ContextManager`, previous turn settings, reference context, token info, rate limits, and server-reasoning accounting while rollout remains the durable cold-start source. | +| Compaction | `src/upstream/codex-rs/core/src/compact-task-runner.ts`, `tasks/compact.ts`, and `compact.ts` | `external/codex/codex-rs/core/src/compact*` and `tasks/compact.rs` | Mirrored with known gaps | Compaction replaces history and advances the model-client window generation. Remaining work is tighter parity for Codex’s full compaction prompt surface. | +| Stream events | `src/upstream/codex-rs/core/src/stream_events_utils.ts` | `external/codex/codex-rs/core/src/stream_events_utils.rs` | Mirrored with platform adaptation | Completed model items, tool-call recording, tool-output recording, follow-up detection, Plan Mode stream parsing, and missing local-shell id responses live in `stream_events_utils`. `session/turn.ts` drives streaming and rebuilds follow-up prompts from live `SessionState.history`. | +| Tool search and spec planning | `src/upstream/codex-rs/core/src/tools/spec.ts`, `spec_plan.ts`, `handlers/tool_search.ts`, and `tools/tool_search_entry.ts` | `external/codex/codex-rs/core/src/tools/spec.rs`, `spec_plan.rs`, `handlers/tool_search.rs`, and `tool_search_entry.rs` | Mirrored with platform adaptation | Deferred dynamic and MCP tools use Codex namespace gating, BM25 search, source info, bucket limits, and history-based follow-up. Deferred MCP handlers are registered for discovered tools, and unavailable previously-called tools get Codex-style placeholder specs. | +| MCP catalog and resources | `src/upstream/codex-rs/core/src/mcp`, `tools/handlers/mcp.ts`, and `tools/handlers/mcp_resource*` | `external/codex/codex-rs/codex-mcp/src/tools.rs`, `codex-mcp/src/codex_apps.rs`, `core/src/tools/handlers/mcp.rs`, and `core/src/tools/handlers/mcp_resource*` | Mirrored with platform adaptation | MCP metadata separates raw server/tool routing from model-visible qualified callable names, carries connector and plugin provenance for search, exposes Codex resource list/read tools when MCP tools are present, caches Codex Apps catalogs by user key, filters disallowed connectors, and emits MCP tool-call lifecycle events for resource operations. | +| MCP connection manager | `src/upstream/codex-rs/codex-mcp/src/connection_manager.ts`, `rmcp_client.ts`, and `core/src/mcp/manager.ts` | `external/codex/codex-rs/codex-mcp/src/connection_manager.rs` and `rmcp_client.rs` | Mirrored with platform adaptation | The package now has Codex-shaped per-server managed clients, startup snapshot reads, live catalog aggregation, hard Codex Apps refresh, raw tool-call routing, resource aggregation, startup error helpers, transport-origin helpers, and a core adapter. Native stdio/HTTP process startup remains host/platform-provided through `RmcpClientLike`. | +| MCP auth and elicitation | `src/upstream/codex-rs/codex-mcp/src/mcp/auth.ts`, `elicitation.ts`, and `auth_elicitation.ts` | `external/codex/codex-rs/codex-mcp/src/mcp/auth.rs`, `elicitation.rs`, and `auth_elicitation.rs` | Mirrored with platform adaptation | OAuth support/status helpers, scope source precedence, retry-without-scopes checks, elicitation request tracking, auto-deny/auto-accept policy behavior, reviewer/event resolution, and Codex Apps auth failure URL elicitations are ported. OAuth discovery uses Web `fetch` instead of Rust reqwest. | +| Tool runtime | `src/upstream/codex-rs/core/src/tools/context.ts`, `tools/parallel.ts`, and `tools/handlers/mcp.ts` | `external/codex/codex-rs/core/src/tools/context.rs`, `tools/parallel.rs`, and `tools/handlers/mcp.rs` | Mirrored with platform adaptation | Tool execution uses Codex read/write ordering: parallel tools overlap, nonparallel tools wait for active parallel work and block later parallel work. TypeScript `CancellationToken` adapts Rust `tokio_util::sync::CancellationToken`. MCP outputs include wall-time model-facing text and preserve raw results for hook/code-mode consumers. | +| App server | `src/upstream/codex-rs/app-server/src` | `external/codex/codex-rs/app-server/src` | Mirrored with platform adaptation | Runtime composition, message processing, request processors, request serialization, connection gating, outgoing messages, initialize state, server-request response routing, and request context follow Codex. Worker WebSocket acceptance remains host code. | +| App server session orchestration | `src/upstream/codex-rs/app-server/src/session_factory.ts` and `session_task_runner.ts` | `external/codex/codex-rs/core/src/thread_manager.rs`, `core/src/tasks`, and `core/src/session/turn.rs` | Mirrored with platform adaptation | Thread/session creation and regular/compact task execution now live inside the upstream mirror so request processors do not depend on package runtime facades. Host callbacks still provide model clients, stores, credentials, and background scheduling. | +| App server transport | `src/upstream/codex-rs/app-server-transport/src/outgoing_message.ts` and `transport/mod.ts` | `external/codex/codex-rs/app-server-transport/src/outgoing_message.rs` and `transport/mod.rs` | Mirrored with platform adaptation | Transport-level outgoing message types plus JSON-RPC request, notification, response, and error parsing/serialization live under the Codex transport crate mirror. Worker socket acceptance remains host code. | +| App server client | `src/upstream/codex-rs/app-server-client/src/lib.ts`, `remote.ts`, `session.ts`, `pending_requests.ts`, and `thread_event_store.ts` | `external/codex/codex-rs/app-server-client/src/lib.rs` and `remote.rs` | Mirrored with platform adaptation | Browser WebSocket client lifecycle, initialize handshake, JSON-RPC request/response routing, server-request resolution, typed request helpers, pending request tracking, and thread notification projection now live under the Codex client crate mirror. Browser ticket URL creation remains host code. | +| Thread state | `src/upstream/codex-rs/app-server/src/thread_state.ts` | `external/codex/codex-rs/app-server/src/thread_state.rs` | Mirrored with platform adaptation | Live connections, thread subscriptions, active turn snapshots, and close cleanup are package-owned. Durable Object socket persistence remains host code. | + +## Platform Adaptations + +- TypeScript mirrors Rust module names and contracts, but uses `.ts` files, + structural types, `fetch`, WebSocket, and Cloudflare-compatible streams. +- Tool cancellation uses a TypeScript `CancellationToken` wrapper around + `AbortSignal` as the platform adaptation for Rust's cancellation token. +- Cloudflare Worker socket acceptance, Durable Object persistence, credentials, + prompts, product tools, project scope, and route paths stay outside the + package. +- Browser app-server WebSocket and OpenAI Responses WebSocket are separate + transports. The former connects UI to the app-server control plane; the latter + connects the runtime to OpenAI. + +## Guarded Rules + +- Package upstream mirrors do not import host application `app`, `src/domain`, + `src/browser`, or `src/worker` modules. +- The removed HTTP-primary `responses_client.ts` surface stays deleted. +- The package does not expose desktop-mediated model transport. +- Parser compatibility aliases for `cached_input_tokens` and + `reasoning_output_tokens` are not accepted. +- Request fixtures and serializers do not encode `prompt_cache_key: null`. diff --git a/packages/codex-js/CUSTOM_TOOLS.md b/docs/internal/CUSTOM_TOOLS.md similarity index 100% rename from packages/codex-js/CUSTOM_TOOLS.md rename to docs/internal/CUSTOM_TOOLS.md diff --git a/packages/codex-js/MIRROR_MAP.md b/docs/internal/MIRROR_MAP.md similarity index 50% rename from packages/codex-js/MIRROR_MAP.md rename to docs/internal/MIRROR_MAP.md index d46bfab..392ea47 100644 --- a/packages/codex-js/MIRROR_MAP.md +++ b/docs/internal/MIRROR_MAP.md @@ -7,74 +7,74 @@ Use it when updating from a newer Codex or T3Chat source drop. | Package Path | Upstream Reference | | --- | --- | -| `src/upstream/codex-rs/core/src/session/session.ts` | `.reference/codex/codex-rs/core/src/session/session.rs` | -| `src/upstream/codex-rs/core/src/session/turn-context.ts` | `.reference/codex/codex-rs/core/src/session/turn_context.rs` | -| `src/upstream/codex-rs/core/src/session/rollout-reconstruction.ts` | `.reference/codex/codex-rs/core/src/session/rollout_reconstruction.rs` | -| `src/upstream/codex-rs/core/src/client.ts` | `.reference/codex/codex-rs/core/src/client.rs` | -| `src/upstream/codex-rs/core/src/agent` | `.reference/codex/codex-rs/core/src/agent` | -| `src/upstream/codex-rs/core/src/tools/handlers/multi_agents.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/multi_agents.rs` | -| `src/upstream/codex-rs/core/src/tools/handlers/agent_jobs*` | `.reference/codex/codex-rs/core/src/tools/handlers/agent_jobs*` | -| `src/upstream/codex-rs/core/src/tasks/mod.ts` | `.reference/codex/codex-rs/core/src/tasks/mod.rs` | -| `src/upstream/codex-rs/core/src/tasks/regular.ts` | `.reference/codex/codex-rs/core/src/tasks/regular.rs` | -| `src/upstream/codex-rs/core/src/tasks/compact.ts` | `.reference/codex/codex-rs/core/src/tasks/compact.rs` | -| `src/upstream/codex-rs/core/src/context` | `.reference/codex/codex-rs/core/src/context` | -| `src/upstream/codex-rs/core/src/context-manager` | `.reference/codex/codex-rs/core/src/context_manager` | -| `src/upstream/codex-rs/config/src/config_toml.ts` | `.reference/codex/codex-rs/config/src/config_toml.rs` | -| `src/upstream/codex-rs/config/src/profile_toml.ts` | `.reference/codex/codex-rs/config/src/profile_toml.rs` | -| `src/upstream/codex-rs/config/src/thread_config.ts` | `.reference/codex/codex-rs/config/src/thread_config.rs` | -| `src/upstream/codex-rs/config/src/merge.ts` | `.reference/codex/codex-rs/config/src/merge.rs` | -| `src/upstream/codex-rs/protocol/src/prompts/base_instructions/default.md` | `.reference/codex/codex-rs/protocol/src/prompts/base_instructions/default.md` | -| `src/upstream/codex-rs/core/src/config/mod.ts` | `.reference/codex/codex-rs/core/src/config/mod.rs` | -| `src/upstream/codex-rs/core/src/config/permissions.ts` | `.reference/codex/codex-rs/core/src/config/permissions.rs` | -| `src/upstream/codex-rs/core/templates` | `.reference/codex/codex-rs/core/templates` | -| `src/upstream/codex-rs/core/templates/model_instructions` | `.reference/codex/codex-rs/core/templates/model_instructions` | -| `src/upstream/codex-rs/core/src/tools` | `.reference/codex/codex-rs/core/src/tools` | -| `src/upstream/codex-rs/core/src/tools/spec.ts` | `.reference/codex/codex-rs/core/src/tools/spec.rs` | -| `src/upstream/codex-rs/core/src/tools/spec_plan.ts` | `.reference/codex/codex-rs/core/src/tools/spec_plan.rs` | -| `src/upstream/codex-rs/core/src/tools/spec_plan_types.ts` | `.reference/codex/codex-rs/core/src/tools/spec_plan_types.rs` | -| `src/upstream/codex-rs/core/src/tools/tool_search_entry.ts` | `.reference/codex/codex-rs/core/src/tools/tool_search_entry.rs` | -| `src/upstream/codex-rs/core/src/tools/tool_dispatch_trace.ts` | `.reference/codex/codex-rs/core/src/tools/tool_dispatch_trace.rs` | -| `src/upstream/codex-rs/core/src/tools/network_approval.ts` | `.reference/codex/codex-rs/core/src/tools/network_approval.rs` | -| `src/upstream/codex-rs/core/src/tools/runtimes` | `.reference/codex/codex-rs/core/src/tools/runtimes` | -| `src/upstream/codex-rs/core/src/tools/handlers/dynamic.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/dynamic.rs` | -| `src/upstream/codex-rs/core/src/tools/handlers/tool_search.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/tool_search.rs` | -| `src/upstream/codex-rs/core/src/tools/handlers/tool_search_spec.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/tool_search_spec.rs` | -| `src/upstream/codex-rs/core/src/tools/handlers/apply_patch.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/apply_patch.rs` | -| `src/upstream/codex-rs/core/src/tools/handlers/apply_patch_spec.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/apply_patch_spec.rs` | -| `src/upstream/codex-rs/core/src/tools/handlers/unified_exec` | `.reference/codex/codex-rs/core/src/tools/handlers/unified_exec` | -| `src/upstream/codex-rs/core/src/tools/handlers/mcp_resource*` | `.reference/codex/codex-rs/core/src/tools/handlers/mcp_resource*` | -| `src/upstream/codex-rs/core/src/tools/handlers/plan*` | `.reference/codex/codex-rs/core/src/tools/handlers/plan*` | -| `src/upstream/codex-rs/core/src/tools/handlers/view_image*` | `.reference/codex/codex-rs/core/src/tools/handlers/view_image*` | -| `src/upstream/codex-rs/core/src/tools/handlers/request_plugin_install*` | `.reference/codex/codex-rs/core/src/tools/handlers/request_plugin_install*` | -| `src/upstream/codex-rs/core/src/tools/code_mode` | `.reference/codex/codex-rs/core/src/tools/code_mode` | -| `src/upstream/codex-rs/core/src/tools/handlers/goal_spec.ts` | `.reference/codex/codex-rs/core/src/tools/handlers/goal_spec.rs` | -| `src/upstream/codex-rs/core/src/event-mapping.ts` | `.reference/codex/codex-rs/core/src/event_mapping.rs` | -| `src/upstream/codex-rs/core/src/thread-history-builder.ts` | `.reference/codex/codex-rs/app-server/src/thread_state.rs` and thread history projection code | -| `src/upstream/codex-rs/thread-store/src` | `.reference/codex/codex-rs/thread-store/src` | -| `src/upstream/codex-rs/codex-api/src/endpoint/responses.ts` | `.reference/codex/codex-rs/codex-api/src/endpoint/responses.rs` | -| `src/upstream/codex-rs/codex-api/src/endpoint/responses_websocket.ts` | `.reference/codex/codex-rs/codex-api/src/endpoint/responses_websocket.rs` | -| `src/upstream/codex-rs/codex-api/src/requests/responses.ts` | `.reference/codex/codex-rs/codex-api/src/requests/responses.rs` | -| `src/upstream/codex-rs/codex-api/src/sse/responses.ts` | `.reference/codex/codex-rs/codex-api/src/sse/responses.rs` | -| `src/upstream/codex-rs/codex-api/src/provider.ts` | `.reference/codex/codex-rs/codex-api/src/provider.rs` | -| `src/upstream/codex-rs/codex-api/src/rate_limits.ts` | `.reference/codex/codex-rs/codex-api/src/rate_limits.rs` | -| `src/upstream/codex-rs/model-provider/src` | `.reference/codex/codex-rs/model-provider/src` | -| `src/upstream/codex-rs/models-manager/src` | `.reference/codex/codex-rs/models-manager/src` | -| `src/upstream/codex-rs/app-server-protocol/schema/typescript` | `.reference/codex/codex-rs/app-server-protocol/schema/typescript` | -| `src/upstream/codex-rs/app-server-protocol/src/protocol/common.ts` | `.reference/codex/codex-rs/app-server-protocol/src/protocol/common.rs` | -| `src/upstream/codex-rs/app-server-protocol/src/protocol/event-mapping.ts` | `.reference/codex/codex-rs/app-server-protocol/src/protocol/event_mapping.rs` | -| `src/upstream/codex-rs/app-server/src/connection_rpc_gate.ts` | `.reference/codex/codex-rs/app-server/src/connection_rpc_gate.rs` | -| `src/upstream/codex-rs/app-server/src/message_processor.ts` | `.reference/codex/codex-rs/app-server/src/message_processor.rs` | -| `src/upstream/codex-rs/app-server/src/request_serialization.ts` | `.reference/codex/codex-rs/app-server/src/request_serialization.rs` | +| `src/upstream/codex-rs/core/src/session/session.ts` | `external/codex/codex-rs/core/src/session/session.rs` | +| `src/upstream/codex-rs/core/src/session/turn-context.ts` | `external/codex/codex-rs/core/src/session/turn_context.rs` | +| `src/upstream/codex-rs/core/src/session/rollout-reconstruction.ts` | `external/codex/codex-rs/core/src/session/rollout_reconstruction.rs` | +| `src/upstream/codex-rs/core/src/client.ts` | `external/codex/codex-rs/core/src/client.rs` | +| `src/upstream/codex-rs/core/src/agent` | `external/codex/codex-rs/core/src/agent` | +| `src/upstream/codex-rs/core/src/tools/handlers/multi_agents.ts` | `external/codex/codex-rs/core/src/tools/handlers/multi_agents.rs` | +| `src/upstream/codex-rs/core/src/tools/handlers/agent_jobs*` | `external/codex/codex-rs/core/src/tools/handlers/agent_jobs*` | +| `src/upstream/codex-rs/core/src/tasks/mod.ts` | `external/codex/codex-rs/core/src/tasks/mod.rs` | +| `src/upstream/codex-rs/core/src/tasks/regular.ts` | `external/codex/codex-rs/core/src/tasks/regular.rs` | +| `src/upstream/codex-rs/core/src/tasks/compact.ts` | `external/codex/codex-rs/core/src/tasks/compact.rs` | +| `src/upstream/codex-rs/core/src/context` | `external/codex/codex-rs/core/src/context` | +| `src/upstream/codex-rs/core/src/context-manager` | `external/codex/codex-rs/core/src/context_manager` | +| `src/upstream/codex-rs/config/src/config_toml.ts` | `external/codex/codex-rs/config/src/config_toml.rs` | +| `src/upstream/codex-rs/config/src/profile_toml.ts` | `external/codex/codex-rs/config/src/profile_toml.rs` | +| `src/upstream/codex-rs/config/src/thread_config.ts` | `external/codex/codex-rs/config/src/thread_config.rs` | +| `src/upstream/codex-rs/config/src/merge.ts` | `external/codex/codex-rs/config/src/merge.rs` | +| `src/upstream/codex-rs/protocol/src/prompts/base_instructions/default.md` | `external/codex/codex-rs/protocol/src/prompts/base_instructions/default.md` | +| `src/upstream/codex-rs/core/src/config/mod.ts` | `external/codex/codex-rs/core/src/config/mod.rs` | +| `src/upstream/codex-rs/core/src/config/permissions.ts` | `external/codex/codex-rs/core/src/config/permissions.rs` | +| `src/upstream/codex-rs/core/templates` | `external/codex/codex-rs/core/templates` | +| `src/upstream/codex-rs/core/templates/model_instructions` | `external/codex/codex-rs/core/templates/model_instructions` | +| `src/upstream/codex-rs/core/src/tools` | `external/codex/codex-rs/core/src/tools` | +| `src/upstream/codex-rs/core/src/tools/spec.ts` | `external/codex/codex-rs/core/src/tools/spec.rs` | +| `src/upstream/codex-rs/core/src/tools/spec_plan.ts` | `external/codex/codex-rs/core/src/tools/spec_plan.rs` | +| `src/upstream/codex-rs/core/src/tools/spec_plan_types.ts` | `external/codex/codex-rs/core/src/tools/spec_plan_types.rs` | +| `src/upstream/codex-rs/core/src/tools/tool_search_entry.ts` | `external/codex/codex-rs/core/src/tools/tool_search_entry.rs` | +| `src/upstream/codex-rs/core/src/tools/tool_dispatch_trace.ts` | `external/codex/codex-rs/core/src/tools/tool_dispatch_trace.rs` | +| `src/upstream/codex-rs/core/src/tools/network_approval.ts` | `external/codex/codex-rs/core/src/tools/network_approval.rs` | +| `src/upstream/codex-rs/core/src/tools/runtimes` | `external/codex/codex-rs/core/src/tools/runtimes` | +| `src/upstream/codex-rs/core/src/tools/handlers/dynamic.ts` | `external/codex/codex-rs/core/src/tools/handlers/dynamic.rs` | +| `src/upstream/codex-rs/core/src/tools/handlers/tool_search.ts` | `external/codex/codex-rs/core/src/tools/handlers/tool_search.rs` | +| `src/upstream/codex-rs/core/src/tools/handlers/tool_search_spec.ts` | `external/codex/codex-rs/core/src/tools/handlers/tool_search_spec.rs` | +| `src/upstream/codex-rs/core/src/tools/handlers/apply_patch.ts` | `external/codex/codex-rs/core/src/tools/handlers/apply_patch.rs` | +| `src/upstream/codex-rs/core/src/tools/handlers/apply_patch_spec.ts` | `external/codex/codex-rs/core/src/tools/handlers/apply_patch_spec.rs` | +| `src/upstream/codex-rs/core/src/tools/handlers/unified_exec` | `external/codex/codex-rs/core/src/tools/handlers/unified_exec` | +| `src/upstream/codex-rs/core/src/tools/handlers/mcp_resource*` | `external/codex/codex-rs/core/src/tools/handlers/mcp_resource*` | +| `src/upstream/codex-rs/core/src/tools/handlers/plan*` | `external/codex/codex-rs/core/src/tools/handlers/plan*` | +| `src/upstream/codex-rs/core/src/tools/handlers/view_image*` | `external/codex/codex-rs/core/src/tools/handlers/view_image*` | +| `src/upstream/codex-rs/core/src/tools/handlers/request_plugin_install*` | `external/codex/codex-rs/core/src/tools/handlers/request_plugin_install*` | +| `src/upstream/codex-rs/core/src/tools/code_mode` | `external/codex/codex-rs/core/src/tools/code_mode` | +| `src/upstream/codex-rs/core/src/tools/handlers/goal_spec.ts` | `external/codex/codex-rs/core/src/tools/handlers/goal_spec.rs` | +| `src/upstream/codex-rs/core/src/event-mapping.ts` | `external/codex/codex-rs/core/src/event_mapping.rs` | +| `src/upstream/codex-rs/core/src/thread-history-builder.ts` | `external/codex/codex-rs/app-server/src/thread_state.rs` and thread history projection code | +| `src/upstream/codex-rs/thread-store/src` | `external/codex/codex-rs/thread-store/src` | +| `src/upstream/codex-rs/codex-api/src/endpoint/responses.ts` | `external/codex/codex-rs/codex-api/src/endpoint/responses.rs` | +| `src/upstream/codex-rs/codex-api/src/endpoint/responses_websocket.ts` | `external/codex/codex-rs/codex-api/src/endpoint/responses_websocket.rs` | +| `src/upstream/codex-rs/codex-api/src/requests/responses.ts` | `external/codex/codex-rs/codex-api/src/requests/responses.rs` | +| `src/upstream/codex-rs/codex-api/src/sse/responses.ts` | `external/codex/codex-rs/codex-api/src/sse/responses.rs` | +| `src/upstream/codex-rs/codex-api/src/provider.ts` | `external/codex/codex-rs/codex-api/src/provider.rs` | +| `src/upstream/codex-rs/codex-api/src/rate_limits.ts` | `external/codex/codex-rs/codex-api/src/rate_limits.rs` | +| `src/upstream/codex-rs/model-provider/src` | `external/codex/codex-rs/model-provider/src` | +| `src/upstream/codex-rs/models-manager/src` | `external/codex/codex-rs/models-manager/src` | +| `src/upstream/codex-rs/app-server-protocol/schema/typescript` | `external/codex/codex-rs/app-server-protocol/schema/typescript` | +| `src/upstream/codex-rs/app-server-protocol/src/protocol/common.ts` | `external/codex/codex-rs/app-server-protocol/src/protocol/common.rs` | +| `src/upstream/codex-rs/app-server-protocol/src/protocol/event-mapping.ts` | `external/codex/codex-rs/app-server-protocol/src/protocol/event_mapping.rs` | +| `src/upstream/codex-rs/app-server/src/connection_rpc_gate.ts` | `external/codex/codex-rs/app-server/src/connection_rpc_gate.rs` | +| `src/upstream/codex-rs/app-server/src/message_processor.ts` | `external/codex/codex-rs/app-server/src/message_processor.rs` | +| `src/upstream/codex-rs/app-server/src/request_serialization.ts` | `external/codex/codex-rs/app-server/src/request_serialization.rs` | | `src/upstream/codex-rs/app-server/src/runtime.ts` | TypeScript app-server runtime composition over Codex message processor, request processors, thread state, and session/task orchestration | | `src/upstream/codex-rs/app-server/src/server_request_response.ts` | TypeScript server-request response translation helper for Codex submissions | -| `src/upstream/codex-rs/app-server/src/session_factory.ts` | TypeScript adaptation of Codex thread/session creation boundaries from `.reference/codex/codex-rs/core/src/thread_manager.rs` and `core/src/session/session.rs` | -| `src/upstream/codex-rs/app-server/src/session_task_runner.ts` | TypeScript adaptation of Codex task execution boundaries from `.reference/codex/codex-rs/core/src/tasks` and `core/src/session/turn.rs` | -| `src/upstream/codex-rs/app-server/src/thread_state.ts` | `.reference/codex/codex-rs/app-server/src/thread_state.rs` | -| `src/upstream/codex-rs/app-server/src/transport.ts` | `.reference/codex/codex-rs/app-server/src/transport.rs` | -| `src/upstream/codex-rs/app-server-transport/src/outgoing_message.ts` | `.reference/codex/codex-rs/app-server-transport/src/outgoing_message.rs` | -| `src/upstream/codex-rs/app-server-transport/src/transport/mod.ts` | `.reference/codex/codex-rs/app-server-transport/src/transport/mod.rs` | -| `src/upstream/codex-rs/app-server-client/src/lib.ts` | `.reference/codex/codex-rs/app-server-client/src/lib.rs` | -| `src/upstream/codex-rs/app-server-client/src/remote.ts` | `.reference/codex/codex-rs/app-server-client/src/remote.rs` | +| `src/upstream/codex-rs/app-server/src/session_factory.ts` | TypeScript adaptation of Codex thread/session creation boundaries from `external/codex/codex-rs/core/src/thread_manager.rs` and `core/src/session/session.rs` | +| `src/upstream/codex-rs/app-server/src/session_task_runner.ts` | TypeScript adaptation of Codex task execution boundaries from `external/codex/codex-rs/core/src/tasks` and `core/src/session/turn.rs` | +| `src/upstream/codex-rs/app-server/src/thread_state.ts` | `external/codex/codex-rs/app-server/src/thread_state.rs` | +| `src/upstream/codex-rs/app-server/src/transport.ts` | `external/codex/codex-rs/app-server/src/transport.rs` | +| `src/upstream/codex-rs/app-server-transport/src/outgoing_message.ts` | `external/codex/codex-rs/app-server-transport/src/outgoing_message.rs` | +| `src/upstream/codex-rs/app-server-transport/src/transport/mod.ts` | `external/codex/codex-rs/app-server-transport/src/transport/mod.rs` | +| `src/upstream/codex-rs/app-server-client/src/lib.ts` | `external/codex/codex-rs/app-server-client/src/lib.rs` | +| `src/upstream/codex-rs/app-server-client/src/remote.ts` | `external/codex/codex-rs/app-server-client/src/remote.rs` | | `src/upstream/codex-rs/app-server-client/src/session.ts` | TypeScript typed session helper for generated app-server requests | | `src/upstream/codex-rs/app-server-client/src/pending_requests.ts` | TypeScript app-server server-request tracking helper | | `src/upstream/codex-rs/app-server-client/src/thread_event_store.ts` | TypeScript app-server notification/request thread projection helper | @@ -83,14 +83,14 @@ Use it when updating from a newer Codex or T3Chat source drop. | Package Path | Upstream Reference | | --- | --- | -| `src/upstream/t3code/apps/web/src/components/chat/ChatComposer.tsx` | `.reference/t3code/apps/web/src/components/chat/ChatComposer.tsx` | -| `src/upstream/t3code/apps/web/src/components/ComposerPromptEditor.tsx` | `.reference/t3code/apps/web/src/components/ComposerPromptEditor.tsx` | -| `src/upstream/t3code/apps/web/src/components/chat/MessagesTimeline.tsx` | `.reference/t3code/apps/web/src/components/chat/MessagesTimeline.tsx` | -| `src/upstream/t3code/apps/web/src/components/chat/ChangedFilesTree.tsx` | `.reference/t3code/apps/web/src/components/chat/ChangedFilesTree.tsx` | -| `src/upstream/t3code/apps/web/src/components/chat/ProviderModelPicker.tsx` | `.reference/t3code/apps/web/src/components/chat/ProviderModelPicker.tsx` | -| `src/upstream/t3code/apps/web/src/components/ui` | `.reference/t3code/apps/web/src/components/ui` or the closest current T3Chat UI primitive source | -| `src/upstream/t3code/apps/web/src/hooks` | `.reference/t3code/apps/web/src/hooks` | -| `src/upstream/t3code/apps/web/src/lib` | `.reference/t3code/apps/web/src/lib` | +| `src/upstream/t3code/apps/web/src/components/chat/ChatComposer.tsx` | `external/t3code/apps/web/src/components/chat/ChatComposer.tsx` | +| `src/upstream/t3code/apps/web/src/components/ComposerPromptEditor.tsx` | `external/t3code/apps/web/src/components/ComposerPromptEditor.tsx` | +| `src/upstream/t3code/apps/web/src/components/chat/MessagesTimeline.tsx` | `external/t3code/apps/web/src/components/chat/MessagesTimeline.tsx` | +| `src/upstream/t3code/apps/web/src/components/chat/ChangedFilesTree.tsx` | `external/t3code/apps/web/src/components/chat/ChangedFilesTree.tsx` | +| `src/upstream/t3code/apps/web/src/components/chat/ProviderModelPicker.tsx` | `external/t3code/apps/web/src/components/chat/ProviderModelPicker.tsx` | +| `src/upstream/t3code/apps/web/src/components/ui` | `external/t3code/apps/web/src/components/ui` or the closest current T3Chat UI primitive source | +| `src/upstream/t3code/apps/web/src/hooks` | `external/t3code/apps/web/src/hooks` | +| `src/upstream/t3code/apps/web/src/lib` | `external/t3code/apps/web/src/lib` | ## Package Shadcn Primitives diff --git a/packages/codex-js/PACKAGE_BOUNDARY.md b/docs/internal/PACKAGE_BOUNDARY.md similarity index 100% rename from packages/codex-js/PACKAGE_BOUNDARY.md rename to docs/internal/PACKAGE_BOUNDARY.md diff --git a/packages/codex-js/AGENTS.md b/docs/internal/codex-js-package-agents.md similarity index 100% rename from packages/codex-js/AGENTS.md rename to docs/internal/codex-js-package-agents.md diff --git a/docs/staging/core-realizations.md b/docs/staging/core-realizations.md index 1c58b91..fb8245b 100644 --- a/docs/staging/core-realizations.md +++ b/docs/staging/core-realizations.md @@ -112,7 +112,7 @@ The model should stay Codex-shaped, not host application-shaped. host applicatio Friendly `sendMessage` APIs belong at the component edge. Runtime dispatch is Codex-shaped app-server lifecycle flow. -Codex App Server is maintained by processor boundaries: thread requests, turn requests, thread state, outgoing messages, and bespoke event handling. +Codex App Server is maintained by processor boundaries: thread requests, turn requests, thread state, outgoing messages, and app-server event mapping. Session creation is a runtime boundary: it attaches ThreadStore history, LiveThread persistence, SessionConfiguration, and app-owned overrides before processors run turns. diff --git a/docs/start-here/00-system-tour.md b/docs/start-here/00-system-tour.md index 5513a4a..0e511cb 100644 --- a/docs/start-here/00-system-tour.md +++ b/docs/start-here/00-system-tour.md @@ -1,24 +1,23 @@ # System Tour -`@jrkropp/codex-js` is a portable Codex runtime and T3-shaped -chat UI kit. It is not a host application package, a Cloudflare package, or a React -Router package. host application is one consuming application that proves the -package boundary. +`@jrkropp/codex-js` is a portable Codex runtime SDK. +`@jrkropp/codex-js-react` is the React UI package. Neither package is a host +application, a Cloudflare package, or a React Router package. ## Layers -The package has four layers: +The workspace has four layers: -| Layer | Responsibility | -| --- | --- | -| `src/upstream/codex-rs` | Codex runtime, thread store, protocol, tools, model transport, and app-server protocol primitives. | -| `src/upstream/t3code` | T3Chat composer, timeline, model picker, image previews, command menus, and chat interaction helpers. | -| `src/runtime` | Package-owned Codex lifecycle contracts, app-server boundary, store boundary, and route-neutral protocol state. | -| `src/components` and `src/hooks` | Stable React surfaces that bind Codex protocol state to T3-derived chat presentation. | +| Layer | Responsibility | +| -------------------------------- | ------------------------------------------------------------------------------------------------- | +| `packages/codex-js/src/client` | Browser app-server WebSocket client and protocol event helpers. | +| `packages/codex-js/src/server` | App-server runtime helpers, connection bridge, stores, model transport, and dynamic tool helpers. | +| `packages/codex-js/src/internal` | Implemented Codex ports and package internals. | +| `packages/codex-js-react/src` | Stable React components, hooks, shadcn primitives, and CSS. | -Codex source defines runtime semantics. T3 source defines browser interaction -ownership. The package facades connect the two without letting product behavior -leak into either upstream-shaped tree. +Codex source defines runtime semantics. The package facades expose those +semantics without leaking product behavior or reference-source layout into npm +imports. ## Runtime Flow @@ -49,7 +48,7 @@ A consuming app provides product policy and platform placement: - prompts, developer instructions, dynamic tools, and scopes - routes, auth, deployment, WebSocket delivery, and product renderers -host application supplies those pieces from its app folders. The package never +The host application supplies those pieces from its app folders. The package never imports host application routes, domains, Worker bindings, storage keys, prompts, or branding. @@ -58,14 +57,11 @@ branding. Most integrations should enter through the public surfaces: - `@jrkropp/codex-js/server` -- `@jrkropp/codex-js/react` -- `@jrkropp/codex-js/react` - -The package root is intentionally small and only exposes the plug-and-play chat -component entrypoint. Runtime, hook, component, Codex mirror, and T3 mirror APIs -stay on their explicit subpaths. - -The upstream-shaped Codex and T3 import paths remain available for low-level -adapter work, tests, and source-parity updates. Product UI should prefer the -public facades unless it is intentionally bridging into a specific upstream -primitive. +- `@jrkropp/codex-js/client` +- `@jrkropp/codex-js/testing` +- `@jrkropp/codex-js-react` +- `@jrkropp/codex-js-react/shadcn` +- `@jrkropp/codex-js-react/styles.css` + +The package roots are intentionally small. Reference-source and mirror material +is not a public import surface. diff --git a/docs/start-here/01-design-philosophy.md b/docs/start-here/01-design-philosophy.md index 642f0d2..9ebab22 100644 --- a/docs/start-here/01-design-philosophy.md +++ b/docs/start-here/01-design-philosophy.md @@ -12,15 +12,15 @@ This avoids a custom product-specific chat runtime. The package preserves Codex concepts for execution and persistence while using T3-shaped components for the browser chat experience. -## Upstream First +## Codex First -The upstream source trees are the maintenance strategy. File names, folder -boundaries, protocol names, and lifecycle concepts stay close to Codex and T3 so -future source drops can be compared and ported directly. +The Codex source tree is the maintenance strategy for runtime behavior. Protocol +names and lifecycle concepts stay close to Codex so future source drops can be +compared and ported directly. -Package-owned abstractions live outside the upstream trees. If a behavior is +Package-owned abstractions live outside reference material. If a behavior is product-specific, expose a contract, prop, renderer, tool, prompt, or adapter -slot instead of editing upstream-shaped package code. +slot instead of editing internal package code. ## Boundaries Over Abstractions @@ -46,7 +46,7 @@ Host applications own the parts that make an assistant product-specific: - product actions, banners, mentions, and custom renderers Those choices enter through stable package contracts. They do not belong in -`src/upstream/codex-rs`, `src/upstream/t3code`, or package runtime internals. +reference material or package runtime internals. ## Current Truth diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..003d62d --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,61 @@ +import js from "@eslint/js"; +import reactHooks from "eslint-plugin-react-hooks"; +import globals from "globals"; +import tseslint from "typescript-eslint"; + +export default tseslint.config( + { + ignores: [ + ".changeset/**", + "external/**", + "node_modules/**", + "packages/*/dist/**", + "examples/*/dist/**", + "examples/cloudflare/worker-configuration.d.ts", + "docs/internal/**", + "pnpm-lock.yaml", + ], + }, + js.configs.recommended, + ...tseslint.configs.recommended, + { + languageOptions: { + ecmaVersion: 2022, + globals: { + ...globals.browser, + ...globals.node, + DurableObjectNamespace: "readonly", + DurableObjectState: "readonly", + DurableObjectStorage: "readonly", + Env: "readonly", + WebSocketPair: "readonly", + }, + sourceType: "module", + }, + rules: { + "no-console": "off", + "no-undef": "off", + "preserve-caught-error": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-this-alias": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + caughtErrorsIgnorePattern: "^_", + varsIgnorePattern: "^_", + }, + ], + }, + }, + { + files: ["**/*.tsx"], + plugins: { + "react-hooks": reactHooks, + }, + rules: { + "react-hooks/exhaustive-deps": "error", + "react-hooks/rules-of-hooks": "error", + }, + }, +); diff --git a/examples/cloudflare/README.md b/examples/cloudflare/README.md new file mode 100644 index 0000000..4618e9e --- /dev/null +++ b/examples/cloudflare/README.md @@ -0,0 +1,88 @@ +# codex-js Cloudflare Example + +Deployable Vite React + Cloudflare Worker + Durable Object example for `@jrkropp/codex-js`. + +The browser never receives an OpenAI API key. It creates a Codex session through the Worker, receives a short-lived one-time WebSocket ticket, and then connects to a Durable Object app-server session. + +## Architecture + +```mermaid +sequenceDiagram + participant Browser + participant Worker + participant Session as CodexSessionObject + Browser->>Worker: POST /api/codex/session + Worker->>Session: createTicket(ticket, threadId) + Worker-->>Browser: { threadId, webSocketUrl } + Browser->>Worker: GET /api/codex/app-server?ticket=... + Worker->>Session: fetch(upgrade) + Session-->>Browser: WebSocket 101 + Browser->>Session: app-server JSON-RPC + Session->>Session: createCodexAppServerConnection() + Session->>Session: persist thread, pending requests, snapshots +``` + +## Install + +From the repository root: + +```sh +pnpm install +``` + +For deployed Workers, set the secret with Wrangler: + +```sh +pnpm --filter @jrkropp/codex-js-cloudflare-example exec wrangler secret put OPENAI_API_KEY +``` + +For local development, create `examples/cloudflare/.dev.vars`: + +```env +OPENAI_API_KEY=sk-... +``` + +`wrangler.jsonc` declares `OPENAI_API_KEY` in `secrets.required`. Wrangler uses that declaration for type generation and deploy validation. The Cloudflare Vite plugin may copy `.dev.vars` into `dist` for `vite preview`; Cloudflare documents that this file is for local preview only and is not deployed with the Worker. Do not commit `.dev.vars` or build output. + +## Run + +```sh +pnpm dev:cloudflare-example +``` + +## Deploy Dry Run + +```sh +pnpm --filter @jrkropp/codex-js-cloudflare-example cf:types:check +pnpm --filter @jrkropp/codex-js-cloudflare-example deploy:dry-run +``` + +## Routes + +- `POST /api/codex/session`: creates a session id, thread id, and one-time WebSocket ticket. +- `GET /api/codex/app-server?ticket=...`: validates and consumes the ticket, then upgrades to a Durable Object WebSocket. + +Static assets are served by Workers assets with SPA fallback. Worker-first routing is limited to `/api/*`. + +## Durable Object Responsibilities + +`CodexSessionObject` owns: + +- one app-server runtime per Durable Object instance +- one app-server connection per WebSocket +- Durable Object SQLite thread storage +- pending app-server request storage +- one-time WebSocket ticket validation +- connection session snapshots for hibernation restore +- server-side dynamic tool registration + +It uses `ctx.acceptWebSocket(server)` and stores a small socket attachment so the Durable Object can reconstruct the app-server connection after hibernation. Larger connection state is stored in SQLite. + +## Dynamic Tools + +The example registers two tools in `src/worker/tools.ts`: + +- `lookup_deployment`: visible server-executed tool. +- `billing/lookup_invoice`: deferred namespaced server-executed tool. + +Application tools belong in the Worker or Durable Object, not in the browser. Tools that omit `execute` are still valid escape hatches; they surface as app-server requests for a client to resolve. diff --git a/examples/minimal-app-server/index.html b/examples/cloudflare/index.html similarity index 65% rename from examples/minimal-app-server/index.html rename to examples/cloudflare/index.html index 47d45ae..2ac36ff 100644 --- a/examples/minimal-app-server/index.html +++ b/examples/cloudflare/index.html @@ -3,10 +3,10 @@ - Minimal Codex App Server + codex-js Cloudflare Example
- + diff --git a/examples/cloudflare/package.json b/examples/cloudflare/package.json new file mode 100644 index 0000000..4796fcb --- /dev/null +++ b/examples/cloudflare/package.json @@ -0,0 +1,35 @@ +{ + "name": "@jrkropp/codex-js-cloudflare-example", + "private": true, + "type": "module", + "scripts": { + "build": "pnpm typecheck && vite build", + "cf:types": "wrangler types", + "cf:types:check": "wrangler types --check", + "deploy": "pnpm build && wrangler deploy", + "deploy:dry-run": "pnpm build && wrangler deploy --dry-run", + "dev": "vite --host localhost --port 1468", + "test": "vitest run", + "typecheck": "tsc -b tsconfig.client.json tsconfig.worker.json tsconfig.test.json --pretty false" + }, + "dependencies": { + "@cloudflare/vite-plugin": "^1.14.6", + "@fontsource-variable/geist": "^5.2.8", + "@jrkropp/codex-js": "workspace:*", + "@jrkropp/codex-js-react": "workspace:*", + "@tailwindcss/vite": "^4.1.17", + "@vitejs/plugin-react": "^5.1.1", + "react": "19.2.1", + "react-dom": "19.2.1", + "tailwindcss": "^4.1.17", + "tw-animate-css": "^1.4.0", + "vite": "^6.4.2", + "wrangler": "^4.51.0" + }, + "devDependencies": { + "@cloudflare/vitest-pool-workers": "^0.10.2", + "@vitest/runner": "3.2.4", + "@vitest/snapshot": "3.2.4", + "vitest": "3.2.4" + } +} diff --git a/examples/cloudflare/src/client/main.tsx b/examples/cloudflare/src/client/main.tsx new file mode 100644 index 0000000..a8083d0 --- /dev/null +++ b/examples/cloudflare/src/client/main.tsx @@ -0,0 +1,103 @@ +import { useEffect, useMemo, useState } from "react"; +import { createRoot } from "react-dom/client"; +import { createCodexAppServerClient } from "@jrkropp/codex-js/client"; +import { CodexChat } from "@jrkropp/codex-js-react"; +import "./styles.css"; + +type CodexSessionResponse = { + expiresAt: number; + sessionId: string; + threadId: string; + webSocketUrl: string; +}; + +function App() { + const [session, setSession] = useState(null); + const [error, setError] = useState(null); + + useEffect(() => { + let cancelled = false; + void createSession() + .then((nextSession) => { + if (!cancelled) { + setSession(nextSession); + } + }) + .catch((sessionError: unknown) => { + if (!cancelled) { + setError( + sessionError instanceof Error + ? sessionError.message + : "Unable to create a Codex session.", + ); + } + }); + return () => { + cancelled = true; + }; + }, []); + + const appServer = useMemo( + () => + session + ? createCodexAppServerClient({ + initializeParams: { + capabilities: { + experimentalApi: true, + optOutNotificationMethods: [], + }, + clientInfo: { + name: "codex-js-cloudflare-example", + title: "codex-js Cloudflare Example", + version: "0.3.0", + }, + }, + url: session.webSocketUrl, + }) + : null, + [session], + ); + + if (error) { + return
{error}
; + } + + if (!session || !appServer) { + return ( +
Starting Codex session...
+ ); + } + + return ( +
+
+

codex-js on Cloudflare

+
Durable Object session
+
+ ({ + cwd: "/cloudflare-codex-example", + model: "gpt-5-mini", + modelProvider: "openai", + threadId, + })} + threadId={session.threadId} + title="Cloudflare Codex" + subtitle="Worker, Durable Object, hibernating WebSocket, and server tools" + /> +
+ ); +} + +async function createSession(): Promise { + const response = await fetch("/api/codex/session", { + method: "POST", + }); + if (!response.ok) { + throw new Error(await response.text()); + } + return response.json() as Promise; +} + +createRoot(document.getElementById("root")!).render(); diff --git a/examples/cloudflare/src/client/styles.css b/examples/cloudflare/src/client/styles.css new file mode 100644 index 0000000..d09ebc6 --- /dev/null +++ b/examples/cloudflare/src/client/styles.css @@ -0,0 +1,56 @@ +@import "@fontsource-variable/geist"; +@import "@jrkropp/codex-js-react/styles.css"; + +@import "tailwindcss"; +@import "tw-animate-css"; + +@source "./"; + +:root { + font-family: "Geist Variable", system-ui, sans-serif; +} + +body { + min-height: 100vh; + margin: 0; + background: var(--color-background); + color: var(--color-foreground); +} + +#root { + min-height: 100vh; +} + +.codex-shell { + min-height: 100vh; + display: grid; + grid-template-rows: auto 1fr; +} + +.codex-shell__bar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + border-bottom: 1px solid var(--color-border); + padding: 0.75rem 1rem; +} + +.codex-shell__title { + margin: 0; + font-size: 0.95rem; + font-weight: 650; +} + +.codex-shell__status { + color: var(--color-muted-foreground); + font-size: 0.8rem; +} + +.codex-shell__loading { + display: grid; + min-height: 100vh; + place-items: center; + color: var(--color-muted-foreground); + font-size: 0.9rem; +} diff --git a/examples/cloudflare/src/shared/routes.ts b/examples/cloudflare/src/shared/routes.ts new file mode 100644 index 0000000..452952e --- /dev/null +++ b/examples/cloudflare/src/shared/routes.ts @@ -0,0 +1,12 @@ +export const CODEX_SESSION_PATH = "/api/codex/session"; +export const CODEX_APP_SERVER_PATH = "/api/codex/app-server"; + +export function webSocketUrlFromTicket( + request: Request, + ticket: string, +): string { + const url = new URL(CODEX_APP_SERVER_PATH, request.url); + url.protocol = url.protocol === "https:" ? "wss:" : "ws:"; + url.searchParams.set("ticket", ticket); + return url.toString(); +} diff --git a/examples/cloudflare/src/worker/codex-session-object.ts b/examples/cloudflare/src/worker/codex-session-object.ts new file mode 100644 index 0000000..16bc062 --- /dev/null +++ b/examples/cloudflare/src/worker/codex-session-object.ts @@ -0,0 +1,385 @@ +import { DurableObject } from "cloudflare:workers"; +import { + CodexAppServerRequestError, + createCodexAppServer, + createModelClient, + jsonRpcErrorFromUnknown, + type CodexAppServerConnection, + type CodexAppServerConnectionSnapshot, + type CreatedCodexAppServer, + type ThreadId, +} from "@jrkropp/codex-js/server"; +import { cloudflareExampleTools } from "./tools"; +import { DurableObjectPendingServerRequestStore } from "./pending-store"; +import { DurableObjectThreadStore } from "./thread-store"; + +const TICKET_TTL_MS = 60_000; +const DEFAULT_MODEL = "gpt-5-mini"; +const DEFAULT_CWD = "/cloudflare-codex-example"; + +type SqlStorage = DurableObjectStorage["sql"]; + +type ConnectionContext = { + env: Env; + sessionId: string; + threadId: ThreadId; +}; + +type SocketAttachment = { + connectionId: number; + sessionId: string; + threadId: ThreadId; +}; + +type TicketRecord = { + expires_at: number; + session_id: string; + thread_id: string; + ticket_hash: string; +}; + +type SnapshotRecord = { + connection_id: number; + snapshot_json: string; + updated_at: number; +}; + +export type CreateCodexTicketInput = { + expiresAt: number; + sessionId: string; + threadId: string; + ticket: string; +}; + +export class CodexSessionObject extends DurableObject { + private readonly pendingServerRequests: DurableObjectPendingServerRequestStore; + private readonly threadStore: DurableObjectThreadStore; + private appServer: CreatedCodexAppServer | null = null; + private readonly connections = new Map< + WebSocket, + CodexAppServerConnection + >(); + + constructor(ctx: DurableObjectState, env: Env) { + super(ctx, env); + this.threadStore = new DurableObjectThreadStore(ctx.storage.sql); + this.pendingServerRequests = new DurableObjectPendingServerRequestStore( + ctx.storage.sql, + ); + ctx.blockConcurrencyWhile(async () => { + this.createSchema(ctx.storage.sql); + this.threadStore.createSchema(); + this.pendingServerRequests.createSchema(); + this.restoreHibernatedSockets(); + }); + } + + async createTicket(input: CreateCodexTicketInput): Promise { + const expiresAt = Math.min(input.expiresAt, Date.now() + TICKET_TTL_MS); + this.ctx.storage.sql.exec( + "INSERT OR REPLACE INTO websocket_tickets (ticket_hash, session_id, thread_id, expires_at) VALUES (?, ?, ?, ?)", + await ticketHash(input.ticket), + input.sessionId, + input.threadId, + expiresAt, + ); + this.deleteExpiredTickets(); + } + + async fetch(request: Request): Promise { + if (request.headers.get("Upgrade")?.toLowerCase() !== "websocket") { + return new Response("Expected WebSocket upgrade.", { status: 426 }); + } + const url = new URL(request.url); + const ticket = url.searchParams.get("ticket"); + if (!ticket) { + return new Response("Missing WebSocket ticket.", { status: 401 }); + } + const consumedTicket = await this.consumeTicket(ticket); + if (!consumedTicket) { + return new Response("Invalid or expired WebSocket ticket.", { + status: 401, + }); + } + + const webSocketPair = new WebSocketPair(); + const [client, server] = Object.values(webSocketPair) as [ + WebSocket, + WebSocket, + ]; + const attachment: SocketAttachment = { + connectionId: randomConnectionId(), + sessionId: consumedTicket.session_id, + threadId: consumedTicket.thread_id as ThreadId, + }; + this.ctx.acceptWebSocket(server); + this.attachSocket(server, attachment, null); + + return new Response(null, { status: 101, webSocket: client }); + } + + async webSocketMessage( + socket: WebSocket, + message: string | ArrayBuffer, + ): Promise { + if (typeof message !== "string") { + socket.send( + JSON.stringify({ + error: { + code: -32600, + message: "Codex app-server transport expects string JSON frames.", + }, + id: null, + jsonrpc: "2.0", + }), + ); + return; + } + const connection = this.connectionForSocket(socket); + await connection.accept(message); + } + + async webSocketClose( + socket: WebSocket, + _code: number, + _reason: string, + _wasClean: boolean, + ): Promise { + const attachment = readAttachment(socket); + const connection = this.connections.get(socket); + this.connections.delete(socket); + if (attachment) { + this.deleteConnectionSnapshot(attachment.connectionId); + } + await connection?.close(); + } + + async webSocketError(socket: WebSocket, error: unknown): Promise { + const connection = this.connections.get(socket); + this.connections.delete(socket); + await connection?.close(); + try { + socket.close( + 1011, + error instanceof Error ? error.message : "Socket error.", + ); + } catch { + // The runtime may already have closed the socket. + } + } + + private codexAppServer(): CreatedCodexAppServer { + if (this.appServer) { + return this.appServer; + } + this.appServer = createCodexAppServer({ + createModelClient: ({ context, threadId }) => { + if (!this.env.OPENAI_API_KEY) { + throw new CodexAppServerRequestError({ + code: -32000, + message: + "OPENAI_API_KEY is not configured. Run `wrangler secret put OPENAI_API_KEY`.", + }); + } + return createModelClient({ + apiKey: this.env.OPENAI_API_KEY, + baseUrl: this.env.OPENAI_BASE_URL, + fetch: fetch.bind(globalThis), + installationId: "codex-js-cloudflare-example", + sessionId: context?.sessionId ?? String(threadId), + threadId, + }); + }, + defaults: { + cwd: DEFAULT_CWD, + model: DEFAULT_MODEL, + modelProvider: "openai", + source: "appServer", + threadSource: "cloudflare", + }, + dynamicTools: cloudflareExampleTools, + onRuntimeError: (error) => { + console.error( + JSON.stringify({ error: jsonRpcErrorFromUnknown(error) }), + ); + }, + pendingServerRequests: this.pendingServerRequests, + runConnectionBackground: (promise) => { + this.ctx.waitUntil(promise); + }, + runInBackground: (promise) => { + this.ctx.waitUntil(promise); + }, + threadStore: this.threadStore, + }); + return this.appServer; + } + + private attachSocket( + socket: WebSocket, + attachment: SocketAttachment, + snapshot: CodexAppServerConnectionSnapshot | null, + ): CodexAppServerConnection { + socket.serializeAttachment(attachment); + const connection = this.codexAppServer().createConnection({ + connectionId: attachment.connectionId, + context: { + env: this.env, + sessionId: attachment.sessionId, + threadId: attachment.threadId, + }, + onSnapshot: (nextSnapshot) => { + this.writeConnectionSnapshot(attachment.connectionId, nextSnapshot); + socket.serializeAttachment(attachment); + }, + send: (payload) => { + socket.send(payload); + }, + snapshot, + }); + this.connections.set(socket, connection); + return connection; + } + + private connectionForSocket( + socket: WebSocket, + ): CodexAppServerConnection { + const existing = this.connections.get(socket); + if (existing) { + return existing; + } + const attachment = readAttachment(socket); + if (!attachment) { + throw new Error("WebSocket is missing a Codex app-server attachment."); + } + return this.attachSocket( + socket, + attachment, + this.readConnectionSnapshot(attachment.connectionId), + ); + } + + private restoreHibernatedSockets(): void { + for (const socket of this.ctx.getWebSockets()) { + const attachment = readAttachment(socket); + if (!attachment) { + continue; + } + this.attachSocket( + socket, + attachment, + this.readConnectionSnapshot(attachment.connectionId), + ); + } + } + + private createSchema(sql: SqlStorage): void { + sql.exec(` + CREATE TABLE IF NOT EXISTS websocket_tickets ( + ticket_hash TEXT PRIMARY KEY, + session_id TEXT NOT NULL, + thread_id TEXT NOT NULL, + expires_at INTEGER NOT NULL + ) + `); + sql.exec(` + CREATE TABLE IF NOT EXISTS connection_snapshots ( + connection_id INTEGER PRIMARY KEY, + snapshot_json TEXT NOT NULL, + updated_at INTEGER NOT NULL + ) + `); + } + + private async consumeTicket(ticket: string): Promise { + const hash = await ticketHash(ticket); + const rows = this.ctx.storage.sql + .exec( + "SELECT ticket_hash, session_id, thread_id, expires_at FROM websocket_tickets WHERE ticket_hash = ?", + hash, + ) + .toArray(); + this.ctx.storage.sql.exec( + "DELETE FROM websocket_tickets WHERE ticket_hash = ?", + hash, + ); + const row = rows[0] ?? null; + if (!row || row.expires_at < Date.now()) { + return null; + } + return row; + } + + private deleteExpiredTickets(): void { + this.ctx.storage.sql.exec( + "DELETE FROM websocket_tickets WHERE expires_at < ?", + Date.now(), + ); + } + + private readConnectionSnapshot( + connectionId: number, + ): CodexAppServerConnectionSnapshot | null { + const rows = this.ctx.storage.sql + .exec( + "SELECT connection_id, snapshot_json, updated_at FROM connection_snapshots WHERE connection_id = ?", + connectionId, + ) + .toArray(); + const row = rows[0]; + return row + ? (JSON.parse(row.snapshot_json) as CodexAppServerConnectionSnapshot) + : null; + } + + private writeConnectionSnapshot( + connectionId: number, + snapshot: CodexAppServerConnectionSnapshot, + ): void { + this.ctx.storage.sql.exec( + "INSERT OR REPLACE INTO connection_snapshots (connection_id, snapshot_json, updated_at) VALUES (?, ?, ?)", + connectionId, + JSON.stringify(snapshot), + Date.now(), + ); + } + + private deleteConnectionSnapshot(connectionId: number): void { + this.ctx.storage.sql.exec( + "DELETE FROM connection_snapshots WHERE connection_id = ?", + connectionId, + ); + } +} + +function readAttachment(socket: WebSocket): SocketAttachment | null { + const attachment = socket.deserializeAttachment(); + if ( + typeof attachment !== "object" || + attachment === null || + !Number.isInteger( + (attachment as { connectionId?: unknown }).connectionId, + ) || + typeof (attachment as { sessionId?: unknown }).sessionId !== "string" || + typeof (attachment as { threadId?: unknown }).threadId !== "string" + ) { + return null; + } + return attachment as SocketAttachment; +} + +function randomConnectionId(): number { + const bytes = new Uint32Array(1); + crypto.getRandomValues(bytes); + return bytes[0] || 1; +} + +async function ticketHash(ticket: string): Promise { + const digest = await crypto.subtle.digest( + "SHA-256", + new TextEncoder().encode(ticket), + ); + return Array.from(new Uint8Array(digest)) + .map((byte) => byte.toString(16).padStart(2, "0")) + .join(""); +} diff --git a/examples/cloudflare/src/worker/index.ts b/examples/cloudflare/src/worker/index.ts new file mode 100644 index 0000000..9128963 --- /dev/null +++ b/examples/cloudflare/src/worker/index.ts @@ -0,0 +1,87 @@ +import { CodexSessionObject } from "./codex-session-object"; +import { + CODEX_APP_SERVER_PATH, + CODEX_SESSION_PATH, + webSocketUrlFromTicket, +} from "../shared/routes"; + +const SESSION_TICKET_TTL_MS = 60_000; + +export { CodexSessionObject }; + +type CodexSessionResponse = { + expiresAt: number; + sessionId: string; + threadId: string; + webSocketUrl: string; +}; + +export default { + async fetch(request: Request, env: Env): Promise { + const url = new URL(request.url); + if (request.method === "POST" && url.pathname === CODEX_SESSION_PATH) { + return createSession(request, env); + } + if (url.pathname === CODEX_APP_SERVER_PATH) { + const ticket = url.searchParams.get("ticket"); + const sessionId = sessionIdFromTicket(ticket); + if (!ticket || !sessionId) { + return new Response("Missing or malformed WebSocket ticket.", { + status: 401, + }); + } + return env.CODEX_SESSIONS.getByName(sessionId).fetch(request); + } + return new Response("Not found.", { status: 404 }); + }, +}; + +async function createSession(request: Request, env: Env): Promise { + const sessionId = `session_${crypto.randomUUID()}`; + const threadId = crypto.randomUUID(); + const ticketSecret = randomToken(); + const ticket = `${sessionId}.${ticketSecret}`; + const expiresAt = Date.now() + SESSION_TICKET_TTL_MS; + + await env.CODEX_SESSIONS.getByName(sessionId).createTicket({ + expiresAt, + sessionId, + threadId, + ticket, + }); + + return Response.json( + { + expiresAt, + sessionId, + threadId, + webSocketUrl: webSocketUrlFromTicket(request, ticket), + } satisfies CodexSessionResponse, + { + headers: { + "Cache-Control": "no-store", + }, + }, + ); +} + +function sessionIdFromTicket(ticket: string | null): string | null { + const [sessionId, secret, ...rest] = ticket?.split(".") ?? []; + if (!sessionId || !secret || rest.length > 0) { + return null; + } + return sessionId; +} + +function randomToken(): string { + const bytes = new Uint8Array(32); + crypto.getRandomValues(bytes); + let binary = ""; + for (const byte of bytes) { + binary += String.fromCharCode(byte); + } + return btoa(binary) + .replaceAll("+", "-") + .replaceAll("/", "_") + .replace(/=+$/u, ""); +} diff --git a/examples/cloudflare/src/worker/pending-store.ts b/examples/cloudflare/src/worker/pending-store.ts new file mode 100644 index 0000000..8ff94f9 --- /dev/null +++ b/examples/cloudflare/src/worker/pending-store.ts @@ -0,0 +1,74 @@ +import type { + PendingServerRequestRecord, + PendingServerRequestStore, + RequestId, +} from "@jrkropp/codex-js/server"; + +type SqlStorage = DurableObjectStorage["sql"]; + +type PendingServerRequestRow = { + record_json: string; + request_key: string; +}; + +export class DurableObjectPendingServerRequestStore implements PendingServerRequestStore { + constructor(private readonly sql: SqlStorage) {} + + createSchema(): void { + this.sql.exec(` + CREATE TABLE IF NOT EXISTS pending_server_requests ( + request_key TEXT PRIMARY KEY, + record_json TEXT NOT NULL + ) + `); + } + + delete(requestId: RequestId): void { + this.sql.exec( + "DELETE FROM pending_server_requests WHERE request_key = ?", + requestKey(requestId), + ); + } + + get(requestId: RequestId): PendingServerRequestRecord | null { + const rows = this.sql + .exec( + "SELECT request_key, record_json FROM pending_server_requests WHERE request_key = ?", + requestKey(requestId), + ) + .toArray(); + const row = rows[0]; + return row ? parseRecord(row.record_json) : null; + } + + list(): PendingServerRequestRecord[] { + return this.sql + .exec( + "SELECT request_key, record_json FROM pending_server_requests", + ) + .toArray() + .map((row) => parseRecord(row.record_json)); + } + + put(record: PendingServerRequestRecord): void { + this.sql.exec( + "INSERT OR REPLACE INTO pending_server_requests (request_key, record_json) VALUES (?, ?)", + requestKey(record.requestId), + JSON.stringify(record), + ); + } + + take(requestId: RequestId): PendingServerRequestRecord | null { + const record = this.get(requestId); + this.delete(requestId); + return record; + } +} + +function parseRecord(value: string): PendingServerRequestRecord { + return JSON.parse(value) as PendingServerRequestRecord; +} + +function requestKey(requestId: RequestId): string { + return `${typeof requestId}:${String(requestId)}`; +} diff --git a/examples/cloudflare/src/worker/thread-store.ts b/examples/cloudflare/src/worker/thread-store.ts new file mode 100644 index 0000000..dc89f82 --- /dev/null +++ b/examples/cloudflare/src/worker/thread-store.ts @@ -0,0 +1,334 @@ +import { + ThreadMemoryMode, + type AppendThreadItemsParams, + type ArchiveThreadParams, + type CreateThreadParams, + type ListThreadsParams, + type LoadThreadHistoryParams, + type ReadThreadByRolloutPathParams, + type ReadThreadParams, + type ResumeThreadParams, + type RolloutItem, + type StoredThread, + type StoredThreadHistory, + type ThreadId, + type ThreadPage, + type ThreadStore, + type UpdateThreadMetadataParams, +} from "@jrkropp/codex-js/server"; + +type SqlStorage = DurableObjectStorage["sql"]; + +type ThreadRow = { + history_json: string; + thread_id: string; + thread_json: string; +}; + +export class DurableObjectThreadStore implements ThreadStore { + constructor(private readonly sql: SqlStorage) {} + + createSchema(): void { + this.sql.exec(` + CREATE TABLE IF NOT EXISTS threads ( + thread_id TEXT PRIMARY KEY, + thread_json TEXT NOT NULL, + history_json TEXT NOT NULL + ) + `); + this.sql.exec(` + CREATE TABLE IF NOT EXISTS rollout_paths ( + rollout_path TEXT PRIMARY KEY, + thread_id TEXT NOT NULL + ) + `); + } + + async createThread(params: CreateThreadParams): Promise { + const now = new Date().toISOString(); + const thread: StoredThread = { + archived_at: null, + created_at: now, + cwd: String(params.metadata.cwd ?? "/"), + forked_from_id: params.forked_from_id ?? null, + history: null, + model: stringOrNull(params.metadata.model), + model_provider: params.metadata.model_provider, + name: null, + preview: "", + reasoning_effort: stringOrNull(params.metadata.reasoning_effort), + source: params.source, + thread_id: params.thread_id, + thread_source: params.thread_source ?? null, + token_usage: null, + updated_at: now, + }; + this.writeThread(thread, []); + } + + async resumeThread(params: ResumeThreadParams): Promise { + const existing = this.readThreadRow(params.thread_id); + if (!existing) { + const now = new Date().toISOString(); + this.writeThread( + { + archived_at: null, + created_at: now, + cwd: String(params.metadata.cwd ?? "/"), + history: null, + model: stringOrNull(params.metadata.model), + model_provider: params.metadata.model_provider, + preview: "", + source: "appServer", + thread_id: params.thread_id, + token_usage: lastTokenInfoFromRolloutItems(params.history ?? []), + updated_at: now, + }, + params.history ?? [], + ); + } else if (params.history) { + const thread = parseThread(existing.thread_json); + this.writeThread( + { + ...thread, + token_usage: lastTokenInfoFromRolloutItems(params.history), + updated_at: new Date().toISOString(), + }, + params.history, + ); + } + if (params.rollout_path) { + this.sql.exec( + "INSERT OR REPLACE INTO rollout_paths (rollout_path, thread_id) VALUES (?, ?)", + params.rollout_path, + params.thread_id, + ); + } + } + + async appendItems(params: AppendThreadItemsParams): Promise { + const row = this.requireThreadRow(params.thread_id); + const thread = parseThread(row.thread_json); + const history = parseHistory(row.history_json); + history.push(...params.items); + this.writeThread( + { + ...thread, + preview: + thread.preview || firstUserPreview(params.items) || thread.preview, + token_usage: + lastTokenInfoFromRolloutItems(params.items) ?? thread.token_usage, + updated_at: new Date().toISOString(), + }, + history, + ); + } + + async persistThread(threadId: ThreadId): Promise { + void threadId; + } + + async flushThread(threadId: ThreadId): Promise { + void threadId; + } + + async shutdownThread(threadId: ThreadId): Promise { + void threadId; + } + + async discardThread(threadId: ThreadId): Promise { + void threadId; + } + + async loadHistory( + params: LoadThreadHistoryParams, + ): Promise { + const row = this.requireReadableThreadRow( + params.thread_id, + params.include_archived, + ); + return { + items: parseHistory(row.history_json), + thread_id: params.thread_id, + }; + } + + async readThread(params: ReadThreadParams): Promise { + return this.storedThread( + params.thread_id, + params.include_archived, + params.include_history, + ); + } + + async readThreadByRolloutPath( + params: ReadThreadByRolloutPathParams, + ): Promise { + const row = this.sql + .exec<{ + thread_id: string; + }>("SELECT thread_id FROM rollout_paths WHERE rollout_path = ?", params.rollout_path) + .one(); + if (!row) { + throw new Error(`Unknown rollout path: ${params.rollout_path}`); + } + return this.storedThread( + row.thread_id as ThreadId, + params.include_archived, + params.include_history, + ); + } + + async listThreads(params: ListThreadsParams): Promise { + const rows = this.sql + .exec( + "SELECT thread_id, thread_json, history_json FROM threads", + ) + .toArray(); + const items = rows + .map((row) => parseThread(row.thread_json)) + .filter((thread) => params.archived || !thread.archived_at) + .sort((left, right) => + params.sort_direction === "Asc" + ? left.created_at.localeCompare(right.created_at) + : right.created_at.localeCompare(left.created_at), + ) + .slice(0, params.page_size) + .map((thread) => ({ ...thread, history: null })); + return { items, next_cursor: null }; + } + + async updateThreadMetadata( + params: UpdateThreadMetadataParams, + ): Promise { + const row = this.requireReadableThreadRow( + params.thread_id, + params.include_archived, + ); + const thread = parseThread(row.thread_json); + const history = parseHistory(row.history_json); + const next: StoredThread = { + ...thread, + git_info: params.patch.git_info ?? thread.git_info, + name: params.patch.name ?? thread.name, + updated_at: new Date().toISOString(), + }; + if (params.patch.memory_mode === ThreadMemoryMode.Enabled) { + next.preview = thread.preview; + } + this.writeThread(next, history); + return { ...next }; + } + + async archiveThread(params: ArchiveThreadParams): Promise { + const row = this.requireThreadRow(params.thread_id); + const thread = parseThread(row.thread_json); + this.writeThread( + { ...thread, archived_at: new Date().toISOString() }, + parseHistory(row.history_json), + ); + } + + async unarchiveThread(params: ArchiveThreadParams): Promise { + const row = this.requireThreadRow(params.thread_id); + const thread = parseThread(row.thread_json); + const next = { ...thread, archived_at: null }; + this.writeThread(next, parseHistory(row.history_json)); + return next; + } + + private storedThread( + threadId: ThreadId, + includeArchived: boolean, + includeHistory: boolean, + ): StoredThread { + const row = this.requireReadableThreadRow(threadId, includeArchived); + const thread = parseThread(row.thread_json); + return { + ...thread, + history: includeHistory + ? { items: parseHistory(row.history_json), thread_id: threadId } + : null, + }; + } + + private readThreadRow(threadId: ThreadId): ThreadRow | null { + const rows = this.sql + .exec( + "SELECT thread_id, thread_json, history_json FROM threads WHERE thread_id = ?", + threadId, + ) + .toArray(); + return rows[0] ?? null; + } + + private requireThreadRow(threadId: ThreadId): ThreadRow { + const row = this.readThreadRow(threadId); + if (!row) { + throw new Error(`Thread not found: ${threadId}`); + } + return row; + } + + private requireReadableThreadRow( + threadId: ThreadId, + includeArchived: boolean, + ): ThreadRow { + const row = this.requireThreadRow(threadId); + const thread = parseThread(row.thread_json); + if (thread.archived_at && !includeArchived) { + throw new Error(`Thread is archived: ${threadId}`); + } + return row; + } + + private writeThread(thread: StoredThread, history: RolloutItem[]): void { + this.sql.exec( + "INSERT OR REPLACE INTO threads (thread_id, thread_json, history_json) VALUES (?, ?, ?)", + thread.thread_id, + JSON.stringify({ ...thread, history: null }), + JSON.stringify(history), + ); + } +} + +function parseThread(value: string): StoredThread { + return JSON.parse(value) as StoredThread; +} + +function parseHistory(value: string): RolloutItem[] { + return JSON.parse(value) as RolloutItem[]; +} + +function stringOrNull(value: unknown): string | null { + return typeof value === "string" ? value : null; +} + +function lastTokenInfoFromRolloutItems( + items: readonly RolloutItem[], +): unknown | null { + for (let index = items.length - 1; index >= 0; index -= 1) { + const item = items[index]; + if ( + item?.type === "event_msg" && + item.payload.type === "token_count" && + item.payload.info + ) { + return item.payload.info; + } + } + return null; +} + +function firstUserPreview(items: readonly RolloutItem[]): string | null { + for (const item of items) { + if (item?.type !== "event_msg" || item.payload.type !== "user_message") { + continue; + } + const text = item.payload.message.trim(); + if (text) { + return text.slice(0, 160); + } + } + return null; +} diff --git a/examples/cloudflare/src/worker/tools.ts b/examples/cloudflare/src/worker/tools.ts new file mode 100644 index 0000000..e5e71d6 --- /dev/null +++ b/examples/cloudflare/src/worker/tools.ts @@ -0,0 +1,54 @@ +import { + defineDynamicTool, + defineDynamicToolset, + dynamicToolResponse, +} from "@jrkropp/codex-js/server"; + +export const cloudflareExampleTools = defineDynamicToolset([ + defineDynamicTool({ + name: "lookup_deployment", + description: "Look up the current Cloudflare deployment target.", + inputSchema: { + type: "object", + properties: { + name: { type: "string" }, + }, + required: ["name"], + additionalProperties: false, + }, + async execute(args) { + const deploymentName = readString(args, "name") ?? "codex-js"; + return dynamicToolResponse.text( + `${deploymentName} is running in a Cloudflare Worker with a Durable Object app-server session.`, + ); + }, + }), + defineDynamicTool({ + namespace: "billing", + name: "lookup_invoice", + description: "Look up a demo invoice by id.", + deferLoading: true, + inputSchema: { + type: "object", + properties: { + invoiceId: { type: "string" }, + }, + required: ["invoiceId"], + additionalProperties: false, + }, + async execute(args) { + const invoiceId = readString(args, "invoiceId") ?? "demo"; + return dynamicToolResponse.text( + `Invoice ${invoiceId} is paid. This result came from a deferred namespaced dynamic tool.`, + ); + }, + }), +]); + +function readString(value: unknown, key: string): string | null { + if (typeof value !== "object" || value === null || Array.isArray(value)) { + return null; + } + const field = (value as Record)[key]; + return typeof field === "string" ? field : null; +} diff --git a/examples/cloudflare/test/cloudflare-test.d.ts b/examples/cloudflare/test/cloudflare-test.d.ts new file mode 100644 index 0000000..dd8723d --- /dev/null +++ b/examples/cloudflare/test/cloudflare-test.d.ts @@ -0,0 +1,5 @@ +declare module "cloudflare:test" { + // The Workers test package intentionally asks users to merge their generated Env. + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface ProvidedEnv extends Env {} +} diff --git a/examples/cloudflare/test/worker.test.ts b/examples/cloudflare/test/worker.test.ts new file mode 100644 index 0000000..48f4ba8 --- /dev/null +++ b/examples/cloudflare/test/worker.test.ts @@ -0,0 +1,141 @@ +import { env, SELF } from "cloudflare:test"; +import { describe, expect, it } from "vitest"; +import { + CODEX_APP_SERVER_PATH, + CODEX_SESSION_PATH, + webSocketUrlFromTicket, +} from "../src/shared/routes"; + +describe("Cloudflare Codex Worker", () => { + it("creates one-time WebSocket tickets", async () => { + const sessionResponse = await SELF.fetch( + `https://example.test${CODEX_SESSION_PATH}`, + { method: "POST" }, + ); + expect(sessionResponse.status).toBe(200); + const session = (await sessionResponse.json()) as { + threadId: string; + webSocketUrl: string; + }; + expect(session.threadId).toMatch( + /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu, + ); + + const upgrade = await SELF.fetch( + fetchUrlFromWebSocketUrl(session.webSocketUrl), + { + headers: { Upgrade: "websocket" }, + }, + ); + expect(upgrade.status).toBe(101); + expect(upgrade.webSocket).toBeTruthy(); + upgrade.webSocket?.accept(); + upgrade.webSocket?.close(); + + const reused = await SELF.fetch( + fetchUrlFromWebSocketUrl(session.webSocketUrl), + { + headers: { Upgrade: "websocket" }, + }, + ); + expect(reused.status).toBe(401); + }); + + it("rejects missing and expired WebSocket tickets", async () => { + const missing = await SELF.fetch( + `https://example.test${CODEX_APP_SERVER_PATH}`, + { headers: { Upgrade: "websocket" } }, + ); + expect(missing.status).toBe(401); + + const sessionId = "session_expired"; + const threadId = "00000000-0000-4000-8000-000000000000"; + const ticket = `${sessionId}.expired`; + await env.CODEX_SESSIONS.getByName(sessionId).createTicket({ + expiresAt: Date.now() - 1, + sessionId, + threadId, + ticket, + }); + + const expired = await SELF.fetch( + fetchUrlFromWebSocketUrl( + webSocketUrlFromTicket(new Request("https://example.test/"), ticket), + ), + { headers: { Upgrade: "websocket" } }, + ); + expect(expired.status).toBe(401); + }); + + it("accepts app-server initialize over the Durable Object WebSocket", async () => { + const sessionResponse = await SELF.fetch( + `https://example.test${CODEX_SESSION_PATH}`, + { method: "POST" }, + ); + const session = (await sessionResponse.json()) as { webSocketUrl: string }; + const upgrade = await SELF.fetch( + fetchUrlFromWebSocketUrl(session.webSocketUrl), + { + headers: { Upgrade: "websocket" }, + }, + ); + expect(upgrade.status).toBe(101); + const socket = upgrade.webSocket; + expect(socket).toBeTruthy(); + socket?.accept(); + + const message = nextSocketMessage(socket!); + socket?.send( + JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "initialize", + params: { + capabilities: { + experimentalApi: true, + optOutNotificationMethods: [], + }, + clientInfo: { + name: "cloudflare-example-test", + title: "Cloudflare Example Test", + version: "0.0.0", + }, + }, + }), + ); + + await expect(message).resolves.toMatchObject({ + id: 1, + result: expect.any(Object), + }); + socket?.close(); + }); +}); + +function nextSocketMessage(socket: WebSocket): Promise { + return new Promise((resolve, reject) => { + const timeout = setTimeout(() => reject(new Error("Timed out.")), 5_000); + socket.addEventListener( + "message", + (event) => { + clearTimeout(timeout); + resolve(JSON.parse(String(event.data))); + }, + { once: true }, + ); + socket.addEventListener( + "error", + () => { + clearTimeout(timeout); + reject(new Error("WebSocket error.")); + }, + { once: true }, + ); + }); +} + +function fetchUrlFromWebSocketUrl(webSocketUrl: string): string { + const url = new URL(webSocketUrl); + url.protocol = url.protocol === "wss:" ? "https:" : "http:"; + return url.toString(); +} diff --git a/examples/vite-react/tsconfig.json b/examples/cloudflare/tsconfig.client.json similarity index 66% rename from examples/vite-react/tsconfig.json rename to examples/cloudflare/tsconfig.client.json index df93902..fbace77 100644 --- a/examples/vite-react/tsconfig.json +++ b/examples/cloudflare/tsconfig.client.json @@ -1,8 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-vite-react-example.tsbuildinfo", + "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-cloudflare-example.client.tsbuildinfo", "types": ["vite/client"] }, - "include": ["src", "vite.config.ts"] + "include": ["src/client", "src/shared"] } diff --git a/examples/cloudflare/tsconfig.json b/examples/cloudflare/tsconfig.json new file mode 100644 index 0000000..0e3713f --- /dev/null +++ b/examples/cloudflare/tsconfig.json @@ -0,0 +1,8 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.client.json" }, + { "path": "./tsconfig.worker.json" }, + { "path": "./tsconfig.test.json" } + ] +} diff --git a/examples/cloudflare/tsconfig.test.json b/examples/cloudflare/tsconfig.test.json new file mode 100644 index 0000000..1446f6e --- /dev/null +++ b/examples/cloudflare/tsconfig.test.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.worker.json", + "compilerOptions": { + "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-cloudflare-example.test.tsbuildinfo", + "types": ["./worker-configuration.d.ts", "@cloudflare/vitest-pool-workers"] + }, + "include": [ + "src/worker", + "src/shared", + "test", + "vitest.config.ts", + "worker-configuration.d.ts" + ] +} diff --git a/examples/cloudflare/tsconfig.worker.json b/examples/cloudflare/tsconfig.worker.json new file mode 100644 index 0000000..945d419 --- /dev/null +++ b/examples/cloudflare/tsconfig.worker.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "lib": ["ES2022"], + "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-cloudflare-example.worker.tsbuildinfo", + "types": ["./worker-configuration.d.ts"] + }, + "include": ["src/worker", "src/shared", "worker-configuration.d.ts"] +} diff --git a/examples/vite-react/vite.config.ts b/examples/cloudflare/vite.config.ts similarity index 58% rename from examples/vite-react/vite.config.ts rename to examples/cloudflare/vite.config.ts index 33981a3..a9ca8d9 100644 --- a/examples/vite-react/vite.config.ts +++ b/examples/cloudflare/vite.config.ts @@ -1,11 +1,16 @@ +import { cloudflare } from "@cloudflare/vite-plugin"; import tailwindcss from "@tailwindcss/vite"; +import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; import { codexJsAliases } from "../codex-js-vite-aliases"; export default defineConfig({ + build: { + outDir: "dist", + }, + plugins: [react(), tailwindcss(), cloudflare()], resolve: { alias: codexJsAliases, dedupe: ["react", "react-dom"], }, - plugins: [tailwindcss()], }); diff --git a/examples/cloudflare/vitest.config.ts b/examples/cloudflare/vitest.config.ts new file mode 100644 index 0000000..45fe550 --- /dev/null +++ b/examples/cloudflare/vitest.config.ts @@ -0,0 +1,20 @@ +import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config"; +import { codexJsAliases } from "../codex-js-vite-aliases"; + +export default defineWorkersConfig({ + resolve: { + alias: codexJsAliases, + }, + test: { + include: ["test/**/*.test.ts"], + poolOptions: { + workers: { + isolatedStorage: false, + main: "./src/worker/index.ts", + wrangler: { + configPath: "./wrangler.test.jsonc", + }, + }, + }, + }, +}); diff --git a/examples/cloudflare/worker-configuration.d.ts b/examples/cloudflare/worker-configuration.d.ts new file mode 100644 index 0000000..93bfc15 --- /dev/null +++ b/examples/cloudflare/worker-configuration.d.ts @@ -0,0 +1,13577 @@ +/* eslint-disable */ +// Generated by Wrangler by running `wrangler types` (hash: 6a520b56927e60583b3ad495c2b639e6) +// Runtime types generated with workerd@1.20260508.1 2026-05-12 +declare namespace Cloudflare { + interface GlobalProps { + mainModule: typeof import("./src/worker/index"); + durableNamespaces: "CodexSessionObject"; + } + interface Env { + OPENAI_BASE_URL: "https://api.openai.com/v1"; + OPENAI_API_KEY: string; + CODEX_SESSIONS: DurableObjectNamespace; + } +} +interface Env extends Cloudflare.Env {} + +// Begin runtime types +/*! ***************************************************************************** +Copyright (c) Cloudflare. All rights reserved. +Copyright (c) Microsoft Corporation. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* eslint-disable */ +// noinspection JSUnusedGlobalSymbols +declare var onmessage: never; +/** + * The **`DOMException`** interface represents an abnormal event (called an **exception**) that occurs as a result of calling a method or accessing a property of a web API. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException) + */ +declare class DOMException extends Error { + constructor(message?: string, name?: string); + /** + * The **`message`** read-only property of the a message or description associated with the given error name. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) + */ + readonly message: string; + /** + * The **`name`** read-only property of the one of the strings associated with an error name. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) + */ + readonly name: string; + /** + * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match. + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code) + */ + readonly code: number; + static readonly INDEX_SIZE_ERR: number; + static readonly DOMSTRING_SIZE_ERR: number; + static readonly HIERARCHY_REQUEST_ERR: number; + static readonly WRONG_DOCUMENT_ERR: number; + static readonly INVALID_CHARACTER_ERR: number; + static readonly NO_DATA_ALLOWED_ERR: number; + static readonly NO_MODIFICATION_ALLOWED_ERR: number; + static readonly NOT_FOUND_ERR: number; + static readonly NOT_SUPPORTED_ERR: number; + static readonly INUSE_ATTRIBUTE_ERR: number; + static readonly INVALID_STATE_ERR: number; + static readonly SYNTAX_ERR: number; + static readonly INVALID_MODIFICATION_ERR: number; + static readonly NAMESPACE_ERR: number; + static readonly INVALID_ACCESS_ERR: number; + static readonly VALIDATION_ERR: number; + static readonly TYPE_MISMATCH_ERR: number; + static readonly SECURITY_ERR: number; + static readonly NETWORK_ERR: number; + static readonly ABORT_ERR: number; + static readonly URL_MISMATCH_ERR: number; + static readonly QUOTA_EXCEEDED_ERR: number; + static readonly TIMEOUT_ERR: number; + static readonly INVALID_NODE_TYPE_ERR: number; + static readonly DATA_CLONE_ERR: number; + get stack(): any; + set stack(value: any); +} +type WorkerGlobalScopeEventMap = { + fetch: FetchEvent; + scheduled: ScheduledEvent; + queue: QueueEvent; + unhandledrejection: PromiseRejectionEvent; + rejectionhandled: PromiseRejectionEvent; +}; +declare abstract class WorkerGlobalScope extends EventTarget { + EventTarget: typeof EventTarget; +} +/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). * + * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) + */ +interface Console { + "assert"(condition?: boolean, ...data: any[]): void; + /** + * The **`console.clear()`** static method clears the console if possible. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) + */ + clear(): void; + /** + * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) + */ + count(label?: string): void; + /** + * The **`console.countReset()`** static method resets counter used with console/count_static. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) + */ + countReset(label?: string): void; + /** + * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) + */ + debug(...data: any[]): void; + /** + * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) + */ + dir(item?: any, options?: any): void; + /** + * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) + */ + dirxml(...data: any[]): void; + /** + * The **`console.error()`** static method outputs a message to the console at the 'error' log level. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) + */ + error(...data: any[]): void; + /** + * The **`console.group()`** static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console/groupEnd_static is called. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) + */ + group(...data: any[]): void; + /** + * The **`console.groupCollapsed()`** static method creates a new inline group in the console. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) + */ + groupCollapsed(...data: any[]): void; + /** + * The **`console.groupEnd()`** static method exits the current inline group in the console. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) + */ + groupEnd(): void; + /** + * The **`console.info()`** static method outputs a message to the console at the 'info' log level. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) + */ + info(...data: any[]): void; + /** + * The **`console.log()`** static method outputs a message to the console. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) + */ + log(...data: any[]): void; + /** + * The **`console.table()`** static method displays tabular data as a table. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) + */ + table(tabularData?: any, properties?: string[]): void; + /** + * The **`console.time()`** static method starts a timer you can use to track how long an operation takes. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) + */ + time(label?: string): void; + /** + * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) + */ + timeEnd(label?: string): void; + /** + * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) + */ + timeLog(label?: string, ...data: any[]): void; + timeStamp(label?: string): void; + /** + * The **`console.trace()`** static method outputs a stack trace to the console. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) + */ + trace(...data: any[]): void; + /** + * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) + */ + warn(...data: any[]): void; +} +declare const console: Console; +type BufferSource = ArrayBufferView | ArrayBuffer; +type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; +declare namespace WebAssembly { + class CompileError extends Error { + constructor(message?: string); + } + class RuntimeError extends Error { + constructor(message?: string); + } + type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128"; + interface GlobalDescriptor { + value: ValueType; + mutable?: boolean; + } + class Global { + constructor(descriptor: GlobalDescriptor, value?: any); + value: any; + valueOf(): any; + } + type ImportValue = ExportValue | number; + type ModuleImports = Record; + type Imports = Record; + type ExportValue = Function | Global | Memory | Table; + type Exports = Record; + class Instance { + constructor(module: Module, imports?: Imports); + readonly exports: Exports; + } + interface MemoryDescriptor { + initial: number; + maximum?: number; + shared?: boolean; + } + class Memory { + constructor(descriptor: MemoryDescriptor); + readonly buffer: ArrayBuffer; + grow(delta: number): number; + } + type ImportExportKind = "function" | "global" | "memory" | "table"; + interface ModuleExportDescriptor { + kind: ImportExportKind; + name: string; + } + interface ModuleImportDescriptor { + kind: ImportExportKind; + module: string; + name: string; + } + abstract class Module { + static customSections(module: Module, sectionName: string): ArrayBuffer[]; + static exports(module: Module): ModuleExportDescriptor[]; + static imports(module: Module): ModuleImportDescriptor[]; + } + type TableKind = "anyfunc" | "externref"; + interface TableDescriptor { + element: TableKind; + initial: number; + maximum?: number; + } + class Table { + constructor(descriptor: TableDescriptor, value?: any); + readonly length: number; + get(index: number): any; + grow(delta: number, value?: any): number; + set(index: number, value?: any): void; + } + function instantiate(module: Module, imports?: Imports): Promise; + function validate(bytes: BufferSource): boolean; +} +/** + * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker. + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope) + */ +interface ServiceWorkerGlobalScope extends WorkerGlobalScope { + DOMException: typeof DOMException; + WorkerGlobalScope: typeof WorkerGlobalScope; + btoa(data: string): string; + atob(data: string): string; + setTimeout(callback: (...args: any[]) => void, msDelay?: number): number; + setTimeout(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; + clearTimeout(timeoutId: number | null): void; + setInterval(callback: (...args: any[]) => void, msDelay?: number): number; + setInterval(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; + clearInterval(timeoutId: number | null): void; + queueMicrotask(task: Function): void; + structuredClone(value: T, options?: StructuredSerializeOptions): T; + reportError(error: any): void; + fetch(input: RequestInfo | URL, init?: RequestInit): Promise; + self: ServiceWorkerGlobalScope; + crypto: Crypto; + caches: CacheStorage; + scheduler: Scheduler; + performance: Performance; + Cloudflare: Cloudflare; + readonly origin: string; + Event: typeof Event; + ExtendableEvent: typeof ExtendableEvent; + CustomEvent: typeof CustomEvent; + PromiseRejectionEvent: typeof PromiseRejectionEvent; + FetchEvent: typeof FetchEvent; + TailEvent: typeof TailEvent; + TraceEvent: typeof TailEvent; + ScheduledEvent: typeof ScheduledEvent; + MessageEvent: typeof MessageEvent; + CloseEvent: typeof CloseEvent; + ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader; + ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader; + ReadableStream: typeof ReadableStream; + WritableStream: typeof WritableStream; + WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter; + TransformStream: typeof TransformStream; + ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy; + CountQueuingStrategy: typeof CountQueuingStrategy; + ErrorEvent: typeof ErrorEvent; + MessageChannel: typeof MessageChannel; + MessagePort: typeof MessagePort; + EventSource: typeof EventSource; + ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest; + ReadableStreamDefaultController: typeof ReadableStreamDefaultController; + ReadableByteStreamController: typeof ReadableByteStreamController; + WritableStreamDefaultController: typeof WritableStreamDefaultController; + TransformStreamDefaultController: typeof TransformStreamDefaultController; + CompressionStream: typeof CompressionStream; + DecompressionStream: typeof DecompressionStream; + TextEncoderStream: typeof TextEncoderStream; + TextDecoderStream: typeof TextDecoderStream; + Headers: typeof Headers; + Body: typeof Body; + Request: typeof Request; + Response: typeof Response; + WebSocket: typeof WebSocket; + WebSocketPair: typeof WebSocketPair; + WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair; + AbortController: typeof AbortController; + AbortSignal: typeof AbortSignal; + TextDecoder: typeof TextDecoder; + TextEncoder: typeof TextEncoder; + navigator: Navigator; + Navigator: typeof Navigator; + URL: typeof URL; + URLSearchParams: typeof URLSearchParams; + URLPattern: typeof URLPattern; + Blob: typeof Blob; + File: typeof File; + FormData: typeof FormData; + Crypto: typeof Crypto; + SubtleCrypto: typeof SubtleCrypto; + CryptoKey: typeof CryptoKey; + CacheStorage: typeof CacheStorage; + Cache: typeof Cache; + FixedLengthStream: typeof FixedLengthStream; + IdentityTransformStream: typeof IdentityTransformStream; + HTMLRewriter: typeof HTMLRewriter; +} +declare function addEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetAddEventListenerOptions | boolean): void; +declare function removeEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetEventListenerOptions | boolean): void; +/** + * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) + */ +declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */ +declare function btoa(data: string): string; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */ +declare function atob(data: string): string; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ +declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ +declare function setTimeout(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */ +declare function clearTimeout(timeoutId: number | null): void; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */ +declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */ +declare function setInterval(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */ +declare function clearInterval(timeoutId: number | null): void; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */ +declare function queueMicrotask(task: Function): void; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */ +declare function structuredClone(value: T, options?: StructuredSerializeOptions): T; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */ +declare function reportError(error: any): void; +/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ +declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise; +declare const self: ServiceWorkerGlobalScope; +/** +* The Web Crypto API provides a set of low-level functions for common cryptographic tasks. +* The Workers runtime implements the full surface of this API, but with some differences in +* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms) +* compared to those implemented in most browsers. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/) +*/ +declare const crypto: Crypto; +/** +* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) +*/ +declare const caches: CacheStorage; +declare const scheduler: Scheduler; +/** +* The Workers runtime supports a subset of the Performance API, used to measure timing and performance, +* as well as timing of subrequests and other operations. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/) +*/ +declare const performance: Performance; +declare const Cloudflare: Cloudflare; +declare const origin: string; +declare const navigator: Navigator; +interface TestController { +} +interface ExecutionContext { + waitUntil(promise: Promise): void; + passThroughOnException(): void; + readonly exports: Cloudflare.Exports; + readonly props: Props; + cache?: CacheContext; + tracing?: Tracing; +} +type ExportedHandlerFetchHandler = (request: Request>, env: Env, ctx: ExecutionContext) => Response | Promise; +type ExportedHandlerConnectHandler = (socket: Socket, env: Env, ctx: ExecutionContext) => void | Promise; +type ExportedHandlerTailHandler = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise; +type ExportedHandlerTraceHandler = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise; +type ExportedHandlerTailStreamHandler = (event: TailStream.TailEvent, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise; +type ExportedHandlerScheduledHandler = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise; +type ExportedHandlerQueueHandler = (batch: MessageBatch, env: Env, ctx: ExecutionContext) => void | Promise; +type ExportedHandlerTestHandler = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise; +interface ExportedHandler { + fetch?: ExportedHandlerFetchHandler; + connect?: ExportedHandlerConnectHandler; + tail?: ExportedHandlerTailHandler; + trace?: ExportedHandlerTraceHandler; + tailStream?: ExportedHandlerTailStreamHandler; + scheduled?: ExportedHandlerScheduledHandler; + test?: ExportedHandlerTestHandler; + email?: EmailExportedHandler; + queue?: ExportedHandlerQueueHandler; +} +interface StructuredSerializeOptions { + transfer?: any[]; +} +declare abstract class Navigator { + sendBeacon(url: string, body?: BodyInit): boolean; + readonly userAgent: string; + readonly hardwareConcurrency: number; + readonly platform: string; + readonly language: string; + readonly languages: string[]; +} +interface AlarmInvocationInfo { + readonly isRetry: boolean; + readonly retryCount: number; + readonly scheduledTime: number; +} +interface Cloudflare { + readonly compatibilityFlags: Record; +} +interface CachePurgeError { + code: number; + message: string; +} +interface CachePurgeResult { + success: boolean; + errors: CachePurgeError[]; +} +interface CachePurgeOptions { + tags?: string[]; + pathPrefixes?: string[]; + purgeEverything?: boolean; +} +interface CacheContext { + purge(options: CachePurgeOptions): Promise; +} +declare abstract class ColoLocalActorNamespace { + get(actorId: string): Fetcher; +} +interface DurableObject { + fetch(request: Request): Response | Promise; + connect?(socket: Socket): void | Promise; + alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise; + webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise; + webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise; + webSocketError?(ws: WebSocket, error: unknown): void | Promise; +} +type DurableObjectStub = Fetcher & { + readonly id: DurableObjectId; + readonly name?: string; +}; +interface DurableObjectId { + toString(): string; + equals(other: DurableObjectId): boolean; + readonly name?: string; + readonly jurisdiction?: string; +} +declare abstract class DurableObjectNamespace { + newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId; + idFromName(name: string): DurableObjectId; + idFromString(id: string): DurableObjectId; + get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub; + getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub; + jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace; +} +type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high"; +interface DurableObjectNamespaceNewUniqueIdOptions { + jurisdiction?: DurableObjectJurisdiction; +} +type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me"; +type DurableObjectRoutingMode = "primary-only"; +interface DurableObjectNamespaceGetDurableObjectOptions { + locationHint?: DurableObjectLocationHint; + routingMode?: DurableObjectRoutingMode; +} +interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> { +} +interface DurableObjectState { + waitUntil(promise: Promise): void; + readonly exports: Cloudflare.Exports; + readonly props: Props; + readonly id: DurableObjectId; + readonly storage: DurableObjectStorage; + container?: Container; + facets: DurableObjectFacets; + blockConcurrencyWhile(callback: () => Promise): Promise; + acceptWebSocket(ws: WebSocket, tags?: string[]): void; + getWebSockets(tag?: string): WebSocket[]; + setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void; + getWebSocketAutoResponse(): WebSocketRequestResponsePair | null; + getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null; + setHibernatableWebSocketEventTimeout(timeoutMs?: number): void; + getHibernatableWebSocketEventTimeout(): number | null; + getTags(ws: WebSocket): string[]; + abort(reason?: string): void; +} +interface DurableObjectTransaction { + get(key: string, options?: DurableObjectGetOptions): Promise; + get(keys: string[], options?: DurableObjectGetOptions): Promise>; + list(options?: DurableObjectListOptions): Promise>; + put(key: string, value: T, options?: DurableObjectPutOptions): Promise; + put(entries: Record, options?: DurableObjectPutOptions): Promise; + delete(key: string, options?: DurableObjectPutOptions): Promise; + delete(keys: string[], options?: DurableObjectPutOptions): Promise; + rollback(): void; + getAlarm(options?: DurableObjectGetAlarmOptions): Promise; + setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise; + deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise; +} +interface DurableObjectStorage { + get(key: string, options?: DurableObjectGetOptions): Promise; + get(keys: string[], options?: DurableObjectGetOptions): Promise>; + list(options?: DurableObjectListOptions): Promise>; + put(key: string, value: T, options?: DurableObjectPutOptions): Promise; + put(entries: Record, options?: DurableObjectPutOptions): Promise; + delete(key: string, options?: DurableObjectPutOptions): Promise; + delete(keys: string[], options?: DurableObjectPutOptions): Promise; + deleteAll(options?: DurableObjectPutOptions): Promise; + transaction(closure: (txn: DurableObjectTransaction) => Promise): Promise; + getAlarm(options?: DurableObjectGetAlarmOptions): Promise; + setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise; + deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise; + sync(): Promise; + sql: SqlStorage; + kv: SyncKvStorage; + transactionSync(closure: () => T): T; + getCurrentBookmark(): Promise; + getBookmarkForTime(timestamp: number | Date): Promise; + onNextSessionRestoreBookmark(bookmark: string): Promise; +} +interface DurableObjectListOptions { + start?: string; + startAfter?: string; + end?: string; + prefix?: string; + reverse?: boolean; + limit?: number; + allowConcurrency?: boolean; + noCache?: boolean; +} +interface DurableObjectGetOptions { + allowConcurrency?: boolean; + noCache?: boolean; +} +interface DurableObjectGetAlarmOptions { + allowConcurrency?: boolean; +} +interface DurableObjectPutOptions { + allowConcurrency?: boolean; + allowUnconfirmed?: boolean; + noCache?: boolean; +} +interface DurableObjectSetAlarmOptions { + allowConcurrency?: boolean; + allowUnconfirmed?: boolean; +} +declare class WebSocketRequestResponsePair { + constructor(request: string, response: string); + get request(): string; + get response(): string; +} +interface DurableObjectFacets { + get(name: string, getStartupOptions: () => FacetStartupOptions | Promise>): Fetcher; + abort(name: string, reason: any): void; + delete(name: string): void; +} +interface FacetStartupOptions { + id?: DurableObjectId | string; + class: DurableObjectClass; +} +interface AnalyticsEngineDataset { + writeDataPoint(event?: AnalyticsEngineDataPoint): void; +} +interface AnalyticsEngineDataPoint { + indexes?: ((ArrayBuffer | string) | null)[]; + doubles?: number[]; + blobs?: ((ArrayBuffer | string) | null)[]; +} +/** + * The **`Event`** interface represents an event which takes place on an `EventTarget`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event) + */ +declare class Event { + constructor(type: string, init?: EventInit); + /** + * The **`type`** read-only property of the Event interface returns a string containing the event's type. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type) + */ + get type(): string; + /** + * The **`eventPhase`** read-only property of the being evaluated. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase) + */ + get eventPhase(): number; + /** + * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed) + */ + get composed(): boolean; + /** + * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles) + */ + get bubbles(): boolean; + /** + * The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable) + */ + get cancelable(): boolean; + /** + * The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented) + */ + get defaultPrevented(): boolean; + /** + * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not. + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue) + */ + get returnValue(): boolean; + /** + * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget) + */ + get currentTarget(): EventTarget | undefined; + /** + * The read-only **`target`** property of the dispatched. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target) + */ + get target(): EventTarget | undefined; + /** + * The deprecated **`Event.srcElement`** is an alias for the Event.target property. + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement) + */ + get srcElement(): EventTarget | undefined; + /** + * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp) + */ + get timeStamp(): number; + /** + * The **`isTrusted`** read-only property of the when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and `false` when the event was dispatched via The only exception is the `click` event, which initializes the `isTrusted` property to `false` in user agents. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted) + */ + get isTrusted(): boolean; + /** + * The **`cancelBubble`** property of the Event interface is deprecated. + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) + */ + get cancelBubble(): boolean; + /** + * The **`cancelBubble`** property of the Event interface is deprecated. + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) + */ + set cancelBubble(value: boolean); + /** + * The **`stopImmediatePropagation()`** method of the If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation) + */ + stopImmediatePropagation(): void; + /** + * The **`preventDefault()`** method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault) + */ + preventDefault(): void; + /** + * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation) + */ + stopPropagation(): void; + /** + * The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath) + */ + composedPath(): EventTarget[]; + static readonly NONE: number; + static readonly CAPTURING_PHASE: number; + static readonly AT_TARGET: number; + static readonly BUBBLING_PHASE: number; +} +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; + composed?: boolean; +} +type EventListener = (event: EventType) => void; +interface EventListenerObject { + handleEvent(event: EventType): void; +} +type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +/** + * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget) + */ +declare class EventTarget = Record> { + constructor(); + /** + * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) + */ + addEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetAddEventListenerOptions | boolean): void; + /** + * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) + */ + removeEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetEventListenerOptions | boolean): void; + /** + * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) + */ + dispatchEvent(event: EventMap[keyof EventMap]): boolean; +} +interface EventTargetEventListenerOptions { + capture?: boolean; +} +interface EventTargetAddEventListenerOptions { + capture?: boolean; + passive?: boolean; + once?: boolean; + signal?: AbortSignal; +} +interface EventTargetHandlerObject { + handleEvent: (event: Event) => any | undefined; +} +/** + * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController) + */ +declare class AbortController { + constructor(); + /** + * The **`signal`** read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal) + */ + get signal(): AbortSignal; + /** + * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort) + */ + abort(reason?: any): void; +} +/** + * The **`AbortSignal`** interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal) + */ +declare abstract class AbortSignal extends EventTarget { + /** + * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) + */ + static abort(reason?: any): AbortSignal; + /** + * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) + */ + static timeout(delay: number): AbortSignal; + /** + * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) + */ + static any(signals: AbortSignal[]): AbortSignal; + /** + * The **`aborted`** read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (`true`) or not (`false`). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted) + */ + get aborted(): boolean; + /** + * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) + */ + get reason(): any; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ + get onabort(): any | null; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ + set onabort(value: any | null); + /** + * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) + */ + throwIfAborted(): void; +} +interface Scheduler { + wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise; +} +interface SchedulerWaitOptions { + signal?: AbortSignal; +} +/** + * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent) + */ +declare abstract class ExtendableEvent extends Event { + /** + * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) + */ + waitUntil(promise: Promise): void; +} +/** + * The **`CustomEvent`** interface represents events initialized by an application for any purpose. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) + */ +declare class CustomEvent extends Event { + constructor(type: string, init?: CustomEventCustomEventInit); + /** + * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail) + */ + get detail(): T; +} +interface CustomEventCustomEventInit { + bubbles?: boolean; + cancelable?: boolean; + composed?: boolean; + detail?: any; +} +/** + * The **`Blob`** interface represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob) + */ +declare class Blob { + constructor(bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions); + /** + * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) + */ + get size(): number; + /** + * The **`type`** read-only property of the Blob interface returns the MIME type of the file. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) + */ + get type(): string; + /** + * The **`slice()`** method of the Blob interface creates and returns a new `Blob` object which contains data from a subset of the blob on which it's called. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) + */ + slice(start?: number, end?: number, type?: string): Blob; + /** + * The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) + */ + arrayBuffer(): Promise; + /** + * The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) + */ + bytes(): Promise; + /** + * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) + */ + text(): Promise; + /** + * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) + */ + stream(): ReadableStream; +} +interface BlobOptions { + type?: string; +} +/** + * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File) + */ +declare class File extends Blob { + constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions); + /** + * The **`name`** read-only property of the File interface returns the name of the file represented by a File object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) + */ + get name(): string; + /** + * The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) + */ + get lastModified(): number; +} +interface FileOptions { + type?: string; + lastModified?: number; +} +/** +* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) +*/ +declare abstract class CacheStorage { + /** + * The **`open()`** method of the the Cache object matching the `cacheName`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) + */ + open(cacheName: string): Promise; + readonly default: Cache; +} +/** +* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) +*/ +declare abstract class Cache { + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */ + delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise; + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */ + match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise; + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */ + put(request: RequestInfo | URL, response: Response): Promise; +} +interface CacheQueryOptions { + ignoreMethod?: boolean; +} +/** +* The Web Crypto API provides a set of low-level functions for common cryptographic tasks. +* The Workers runtime implements the full surface of this API, but with some differences in +* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms) +* compared to those implemented in most browsers. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/) +*/ +declare abstract class Crypto { + /** + * The **`Crypto.subtle`** read-only property returns a cryptographic operations. + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle) + */ + get subtle(): SubtleCrypto; + /** + * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) + */ + getRandomValues(buffer: T): T; + /** + * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator. + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) + */ + randomUUID(): string; + DigestStream: typeof DigestStream; +} +/** + * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions. + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto) + */ +declare abstract class SubtleCrypto { + /** + * The **`encrypt()`** method of the SubtleCrypto interface encrypts data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) + */ + encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise; + /** + * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) + */ + decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise; + /** + * The **`sign()`** method of the SubtleCrypto interface generates a digital signature. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) + */ + sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise; + /** + * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) + */ + verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise; + /** + * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) + */ + digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise; + /** + * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) + */ + generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise; + /** + * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) + */ + deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise; + /** + * The **`deriveBits()`** method of the key. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) + */ + deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise; + /** + * The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) + */ + importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise; + /** + * The **`exportKey()`** method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) + */ + exportKey(format: string, key: CryptoKey): Promise; + /** + * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) + */ + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise; + /** + * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) + */ + unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise; + timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean; +} +/** + * The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods SubtleCrypto.generateKey, SubtleCrypto.deriveKey, SubtleCrypto.importKey, or SubtleCrypto.unwrapKey. + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey) + */ +declare abstract class CryptoKey { + /** + * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) + */ + readonly type: string; + /** + * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) + */ + readonly extractable: boolean; + /** + * The read-only **`algorithm`** property of the CryptoKey interface returns an object describing the algorithm for which this key can be used, and any associated extra parameters. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) + */ + readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm; + /** + * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) + */ + readonly usages: string[]; +} +interface CryptoKeyPair { + publicKey: CryptoKey; + privateKey: CryptoKey; +} +interface JsonWebKey { + kty: string; + use?: string; + key_ops?: string[]; + alg?: string; + ext?: boolean; + crv?: string; + x?: string; + y?: string; + d?: string; + n?: string; + e?: string; + p?: string; + q?: string; + dp?: string; + dq?: string; + qi?: string; + oth?: RsaOtherPrimesInfo[]; + k?: string; +} +interface RsaOtherPrimesInfo { + r?: string; + d?: string; + t?: string; +} +interface SubtleCryptoDeriveKeyAlgorithm { + name: string; + salt?: (ArrayBuffer | ArrayBufferView); + iterations?: number; + hash?: (string | SubtleCryptoHashAlgorithm); + $public?: CryptoKey; + info?: (ArrayBuffer | ArrayBufferView); +} +interface SubtleCryptoEncryptAlgorithm { + name: string; + iv?: (ArrayBuffer | ArrayBufferView); + additionalData?: (ArrayBuffer | ArrayBufferView); + tagLength?: number; + counter?: (ArrayBuffer | ArrayBufferView); + length?: number; + label?: (ArrayBuffer | ArrayBufferView); +} +interface SubtleCryptoGenerateKeyAlgorithm { + name: string; + hash?: (string | SubtleCryptoHashAlgorithm); + modulusLength?: number; + publicExponent?: (ArrayBuffer | ArrayBufferView); + length?: number; + namedCurve?: string; +} +interface SubtleCryptoHashAlgorithm { + name: string; +} +interface SubtleCryptoImportKeyAlgorithm { + name: string; + hash?: (string | SubtleCryptoHashAlgorithm); + length?: number; + namedCurve?: string; + compressed?: boolean; +} +interface SubtleCryptoSignAlgorithm { + name: string; + hash?: (string | SubtleCryptoHashAlgorithm); + dataLength?: number; + saltLength?: number; +} +interface CryptoKeyKeyAlgorithm { + name: string; +} +interface CryptoKeyAesKeyAlgorithm { + name: string; + length: number; +} +interface CryptoKeyHmacKeyAlgorithm { + name: string; + hash: CryptoKeyKeyAlgorithm; + length: number; +} +interface CryptoKeyRsaKeyAlgorithm { + name: string; + modulusLength: number; + publicExponent: ArrayBuffer | ArrayBufferView; + hash?: CryptoKeyKeyAlgorithm; +} +interface CryptoKeyEllipticKeyAlgorithm { + name: string; + namedCurve: string; +} +interface CryptoKeyArbitraryKeyAlgorithm { + name: string; + hash?: CryptoKeyKeyAlgorithm; + namedCurve?: string; + length?: number; +} +declare class DigestStream extends WritableStream { + constructor(algorithm: string | SubtleCryptoHashAlgorithm); + readonly digest: Promise; + get bytesWritten(): number | bigint; +} +/** + * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder) + */ +declare class TextDecoder { + constructor(label?: string, options?: TextDecoderConstructorOptions); + /** + * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode) + */ + decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string; + get encoding(): string; + get fatal(): boolean; + get ignoreBOM(): boolean; +} +/** + * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder) + */ +declare class TextEncoder { + constructor(); + /** + * The **`TextEncoder.encode()`** method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode) + */ + encode(input?: string): Uint8Array; + /** + * The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto) + */ + encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult; + get encoding(): string; +} +interface TextDecoderConstructorOptions { + fatal: boolean; + ignoreBOM: boolean; +} +interface TextDecoderDecodeOptions { + stream: boolean; +} +interface TextEncoderEncodeIntoResult { + read: number; + written: number; +} +/** + * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent) + */ +declare class ErrorEvent extends Event { + constructor(type: string, init?: ErrorEventErrorEventInit); + /** + * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) + */ + get filename(): string; + /** + * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) + */ + get message(): string; + /** + * The **`lineno`** read-only property of the ErrorEvent interface returns an integer containing the line number of the script file on which the error occurred. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) + */ + get lineno(): number; + /** + * The **`colno`** read-only property of the ErrorEvent interface returns an integer containing the column number of the script file on which the error occurred. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) + */ + get colno(): number; + /** + * The **`error`** read-only property of the ErrorEvent interface returns a JavaScript value, such as an Error or DOMException, representing the error associated with this event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) + */ + get error(): any; +} +interface ErrorEventErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} +/** + * The **`MessageEvent`** interface represents a message received by a target object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent) + */ +declare class MessageEvent extends Event { + constructor(type: string, initializer: MessageEventInit); + /** + * The **`data`** read-only property of the The data sent by the message emitter; this can be any data type, depending on what originated this event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data) + */ + readonly data: any; + /** + * The **`origin`** read-only property of the origin of the message emitter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin) + */ + readonly origin: string | null; + /** + * The **`lastEventId`** read-only property of the unique ID for the event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId) + */ + readonly lastEventId: string; + /** + * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source) + */ + readonly source: MessagePort | null; + /** + * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports) + */ + readonly ports: MessagePort[]; +} +interface MessageEventInit { + data: ArrayBuffer | string; +} +/** + * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent) + */ +declare abstract class PromiseRejectionEvent extends Event { + /** + * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) + */ + readonly promise: Promise; + /** + * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject(). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) + */ + readonly reason: any; +} +/** + * The **`FormData`** interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the Window/fetch, XMLHttpRequest.send() or navigator.sendBeacon() methods. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData) + */ +declare class FormData { + constructor(); + /** + * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) + */ + append(name: string, value: string | Blob): void; + /** + * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) + */ + append(name: string, value: string): void; + /** + * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) + */ + append(name: string, value: Blob, filename?: string): void; + /** + * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) + */ + delete(name: string): void; + /** + * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) + */ + get(name: string): (File | string) | null; + /** + * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) + */ + getAll(name: string): (File | string)[]; + /** + * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) + */ + has(name: string): boolean; + /** + * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) + */ + set(name: string, value: string | Blob): void; + /** + * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) + */ + set(name: string, value: string): void; + /** + * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) + */ + set(name: string, value: Blob, filename?: string): void; + /* Returns an array of key, value pairs for every entry in the list. */ + entries(): IterableIterator<[ + key: string, + value: File | string + ]>; + /* Returns a list of keys in the list. */ + keys(): IterableIterator; + /* Returns a list of values in the list. */ + values(): IterableIterator<(File | string)>; + forEach(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void; + [Symbol.iterator](): IterableIterator<[ + key: string, + value: File | string + ]>; +} +interface ContentOptions { + html?: boolean; +} +declare class HTMLRewriter { + constructor(); + on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter; + onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter; + transform(response: Response): Response; +} +interface HTMLRewriterElementContentHandlers { + element?(element: Element): void | Promise; + comments?(comment: Comment): void | Promise; + text?(element: Text): void | Promise; +} +interface HTMLRewriterDocumentContentHandlers { + doctype?(doctype: Doctype): void | Promise; + comments?(comment: Comment): void | Promise; + text?(text: Text): void | Promise; + end?(end: DocumentEnd): void | Promise; +} +interface Doctype { + readonly name: string | null; + readonly publicId: string | null; + readonly systemId: string | null; +} +interface Element { + tagName: string; + readonly attributes: IterableIterator; + readonly removed: boolean; + readonly namespaceURI: string; + getAttribute(name: string): string | null; + hasAttribute(name: string): boolean; + setAttribute(name: string, value: string): Element; + removeAttribute(name: string): Element; + before(content: string | ReadableStream | Response, options?: ContentOptions): Element; + after(content: string | ReadableStream | Response, options?: ContentOptions): Element; + prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element; + append(content: string | ReadableStream | Response, options?: ContentOptions): Element; + replace(content: string | ReadableStream | Response, options?: ContentOptions): Element; + remove(): Element; + removeAndKeepContent(): Element; + setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element; + onEndTag(handler: (tag: EndTag) => void | Promise): void; +} +interface EndTag { + name: string; + before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag; + after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag; + remove(): EndTag; +} +interface Comment { + text: string; + readonly removed: boolean; + before(content: string, options?: ContentOptions): Comment; + after(content: string, options?: ContentOptions): Comment; + replace(content: string, options?: ContentOptions): Comment; + remove(): Comment; +} +interface Text { + readonly text: string; + readonly lastInTextNode: boolean; + readonly removed: boolean; + before(content: string | ReadableStream | Response, options?: ContentOptions): Text; + after(content: string | ReadableStream | Response, options?: ContentOptions): Text; + replace(content: string | ReadableStream | Response, options?: ContentOptions): Text; + remove(): Text; +} +interface DocumentEnd { + append(content: string, options?: ContentOptions): DocumentEnd; +} +/** + * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent) + */ +declare abstract class FetchEvent extends ExtendableEvent { + /** + * The **`request`** read-only property of the the event handler. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) + */ + readonly request: Request; + /** + * The **`respondWith()`** method of allows you to provide a promise for a Response yourself. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) + */ + respondWith(promise: Response | Promise): void; + passThroughOnException(): void; +} +type HeadersInit = Headers | Iterable> | Record; +/** + * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers) + */ +declare class Headers { + constructor(init?: HeadersInit); + /** + * The **`get()`** method of the Headers interface returns a byte string of all the values of a header within a `Headers` object with a given name. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) + */ + get(name: string): string | null; + getAll(name: string): string[]; + /** + * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) + */ + getSetCookie(): string[]; + /** + * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) + */ + has(name: string): boolean; + /** + * The **`set()`** method of the Headers interface sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) + */ + set(name: string, value: string): void; + /** + * The **`append()`** method of the Headers interface appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) + */ + append(name: string, value: string): void; + /** + * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) + */ + delete(name: string): void; + forEach(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void; + /* Returns an iterator allowing to go through all key/value pairs contained in this object. */ + entries(): IterableIterator<[ + key: string, + value: string + ]>; + /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */ + keys(): IterableIterator; + /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator<[ + key: string, + value: string + ]>; +} +type BodyInit = ReadableStream | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData | Iterable | AsyncIterable; +declare abstract class Body { + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */ + get body(): ReadableStream | null; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */ + get bodyUsed(): boolean; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */ + arrayBuffer(): Promise; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */ + bytes(): Promise; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */ + text(): Promise; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */ + json(): Promise; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */ + formData(): Promise; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */ + blob(): Promise; +} +/** + * The **`Response`** interface of the Fetch API represents the response to a request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response) + */ +declare var Response: { + prototype: Response; + new (body?: BodyInit | null, init?: ResponseInit): Response; + error(): Response; + redirect(url: string, status?: number): Response; + json(any: any, maybeInit?: (ResponseInit | Response)): Response; +}; +/** + * The **`Response`** interface of the Fetch API represents the response to a request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response) + */ +interface Response extends Body { + /** + * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) + */ + clone(): Response; + /** + * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) + */ + status: number; + /** + * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) + */ + statusText: string; + /** + * The **`headers`** read-only property of the with the response. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) + */ + headers: Headers; + /** + * The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) + */ + ok: boolean; + /** + * The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) + */ + redirected: boolean; + /** + * The **`url`** read-only property of the Response interface contains the URL of the response. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) + */ + url: string; + webSocket: WebSocket | null; + cf: any | undefined; + /** + * The **`type`** read-only property of the Response interface contains the type of the response. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type) + */ + type: "default" | "error"; +} +interface ResponseInit { + status?: number; + statusText?: string; + headers?: HeadersInit; + cf?: any; + webSocket?: (WebSocket | null); + encodeBody?: "automatic" | "manual"; +} +type RequestInfo> = Request | string; +/** + * The **`Request`** interface of the Fetch API represents a resource request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request) + */ +declare var Request: { + prototype: Request; + new >(input: RequestInfo | URL, init?: RequestInit): Request; +}; +/** + * The **`Request`** interface of the Fetch API represents a resource request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request) + */ +interface Request> extends Body { + /** + * The **`clone()`** method of the Request interface creates a copy of the current `Request` object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) + */ + clone(): Request; + /** + * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method) + */ + method: string; + /** + * The **`url`** read-only property of the Request interface contains the URL of the request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url) + */ + url: string; + /** + * The **`headers`** read-only property of the with the request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers) + */ + headers: Headers; + /** + * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect) + */ + redirect: string; + fetcher: Fetcher | null; + /** + * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal) + */ + signal: AbortSignal; + cf?: Cf; + /** + * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity) + */ + integrity: string; + /** + * The **`keepalive`** read-only property of the Request interface contains the request's `keepalive` setting (`true` or `false`), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive) + */ + keepalive: boolean; + /** + * The **`cache`** read-only property of the Request interface contains the cache mode of the request. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache) + */ + cache?: "no-store" | "no-cache"; +} +interface RequestInit { + /* A string to set request's method. */ + method?: string; + /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */ + headers?: HeadersInit; + /* A BodyInit object or null to set request's body. */ + body?: BodyInit | null; + /* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */ + redirect?: string; + fetcher?: (Fetcher | null); + cf?: Cf; + /* A string indicating how the request will interact with the browser's cache to set request's cache. */ + cache?: "no-store" | "no-cache"; + /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */ + integrity?: string; + /* An AbortSignal to set request's signal. */ + signal?: (AbortSignal | null); + encodeResponseBody?: "automatic" | "manual"; +} +type Service Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher> : T extends Rpc.WorkerEntrypointBranded ? Fetcher : T extends Exclude ? never : Fetcher; +type Fetcher = (T extends Rpc.EntrypointBranded ? Rpc.Provider : unknown) & { + fetch(input: RequestInfo | URL, init?: RequestInit): Promise; + connect(address: SocketAddress | string, options?: SocketOptions): Socket; +}; +interface KVNamespaceListKey { + name: Key; + expiration?: number; + metadata?: Metadata; +} +type KVNamespaceListResult = { + list_complete: false; + keys: KVNamespaceListKey[]; + cursor: string; + cacheStatus: string | null; +} | { + list_complete: true; + keys: KVNamespaceListKey[]; + cacheStatus: string | null; +}; +interface KVNamespace { + get(key: Key, options?: Partial>): Promise; + get(key: Key, type: "text"): Promise; + get(key: Key, type: "json"): Promise; + get(key: Key, type: "arrayBuffer"): Promise; + get(key: Key, type: "stream"): Promise; + get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise; + get(key: Key, options?: KVNamespaceGetOptions<"json">): Promise; + get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise; + get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise; + get(key: Array, type: "text"): Promise>; + get(key: Array, type: "json"): Promise>; + get(key: Array, options?: Partial>): Promise>; + get(key: Array, options?: KVNamespaceGetOptions<"text">): Promise>; + get(key: Array, options?: KVNamespaceGetOptions<"json">): Promise>; + list(options?: KVNamespaceListOptions): Promise>; + put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise; + getWithMetadata(key: Key, options?: Partial>): Promise>; + getWithMetadata(key: Key, type: "text"): Promise>; + getWithMetadata(key: Key, type: "json"): Promise>; + getWithMetadata(key: Key, type: "arrayBuffer"): Promise>; + getWithMetadata(key: Key, type: "stream"): Promise>; + getWithMetadata(key: Key, options: KVNamespaceGetOptions<"text">): Promise>; + getWithMetadata(key: Key, options: KVNamespaceGetOptions<"json">): Promise>; + getWithMetadata(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise>; + getWithMetadata(key: Key, options: KVNamespaceGetOptions<"stream">): Promise>; + getWithMetadata(key: Array, type: "text"): Promise>>; + getWithMetadata(key: Array, type: "json"): Promise>>; + getWithMetadata(key: Array, options?: Partial>): Promise>>; + getWithMetadata(key: Array, options?: KVNamespaceGetOptions<"text">): Promise>>; + getWithMetadata(key: Array, options?: KVNamespaceGetOptions<"json">): Promise>>; + delete(key: Key): Promise; +} +interface KVNamespaceListOptions { + limit?: number; + prefix?: (string | null); + cursor?: (string | null); +} +interface KVNamespaceGetOptions { + type: Type; + cacheTtl?: number; +} +interface KVNamespacePutOptions { + expiration?: number; + expirationTtl?: number; + metadata?: (any | null); +} +interface KVNamespaceGetWithMetadataResult { + value: Value | null; + metadata: Metadata | null; + cacheStatus: string | null; +} +type QueueContentType = "text" | "bytes" | "json" | "v8"; +interface Queue { + metrics(): Promise; + send(message: Body, options?: QueueSendOptions): Promise; + sendBatch(messages: Iterable>, options?: QueueSendBatchOptions): Promise; +} +interface QueueSendMetrics { + backlogCount: number; + backlogBytes: number; + oldestMessageTimestamp?: Date; +} +interface QueueSendMetadata { + metrics: QueueSendMetrics; +} +interface QueueSendResponse { + metadata: QueueSendMetadata; +} +interface QueueSendBatchMetrics { + backlogCount: number; + backlogBytes: number; + oldestMessageTimestamp?: Date; +} +interface QueueSendBatchMetadata { + metrics: QueueSendBatchMetrics; +} +interface QueueSendBatchResponse { + metadata: QueueSendBatchMetadata; +} +interface QueueSendOptions { + contentType?: QueueContentType; + delaySeconds?: number; +} +interface QueueSendBatchOptions { + delaySeconds?: number; +} +interface MessageSendRequest { + body: Body; + contentType?: QueueContentType; + delaySeconds?: number; +} +interface QueueMetrics { + backlogCount: number; + backlogBytes: number; + oldestMessageTimestamp?: Date; +} +interface MessageBatchMetrics { + backlogCount: number; + backlogBytes: number; + oldestMessageTimestamp?: Date; +} +interface MessageBatchMetadata { + metrics: MessageBatchMetrics; +} +interface QueueRetryOptions { + delaySeconds?: number; +} +interface Message { + readonly id: string; + readonly timestamp: Date; + readonly body: Body; + readonly attempts: number; + retry(options?: QueueRetryOptions): void; + ack(): void; +} +interface QueueEvent extends ExtendableEvent { + readonly messages: readonly Message[]; + readonly queue: string; + readonly metadata: MessageBatchMetadata; + retryAll(options?: QueueRetryOptions): void; + ackAll(): void; +} +interface MessageBatch { + readonly messages: readonly Message[]; + readonly queue: string; + readonly metadata: MessageBatchMetadata; + retryAll(options?: QueueRetryOptions): void; + ackAll(): void; +} +interface R2Error extends Error { + readonly name: string; + readonly code: number; + readonly message: string; + readonly action: string; + readonly stack: any; +} +interface R2ListOptions { + limit?: number; + prefix?: string; + cursor?: string; + delimiter?: string; + startAfter?: string; + include?: ("httpMetadata" | "customMetadata")[]; +} +interface R2Bucket { + head(key: string): Promise; + get(key: string, options: R2GetOptions & { + onlyIf: R2Conditional | Headers; + }): Promise; + get(key: string, options?: R2GetOptions): Promise; + put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & { + onlyIf: R2Conditional | Headers; + }): Promise; + put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise; + createMultipartUpload(key: string, options?: R2MultipartOptions): Promise; + resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload; + delete(keys: string | string[]): Promise; + list(options?: R2ListOptions): Promise; +} +interface R2MultipartUpload { + readonly key: string; + readonly uploadId: string; + uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise; + abort(): Promise; + complete(uploadedParts: R2UploadedPart[]): Promise; +} +interface R2UploadedPart { + partNumber: number; + etag: string; +} +declare abstract class R2Object { + readonly key: string; + readonly version: string; + readonly size: number; + readonly etag: string; + readonly httpEtag: string; + readonly checksums: R2Checksums; + readonly uploaded: Date; + readonly httpMetadata?: R2HTTPMetadata; + readonly customMetadata?: Record; + readonly range?: R2Range; + readonly storageClass: string; + readonly ssecKeyMd5?: string; + writeHttpMetadata(headers: Headers): void; +} +interface R2ObjectBody extends R2Object { + get body(): ReadableStream; + get bodyUsed(): boolean; + arrayBuffer(): Promise; + bytes(): Promise; + text(): Promise; + json(): Promise; + blob(): Promise; +} +type R2Range = { + offset: number; + length?: number; +} | { + offset?: number; + length: number; +} | { + suffix: number; +}; +interface R2Conditional { + etagMatches?: string; + etagDoesNotMatch?: string; + uploadedBefore?: Date; + uploadedAfter?: Date; + secondsGranularity?: boolean; +} +interface R2GetOptions { + onlyIf?: (R2Conditional | Headers); + range?: (R2Range | Headers); + ssecKey?: (ArrayBuffer | string); +} +interface R2PutOptions { + onlyIf?: (R2Conditional | Headers); + httpMetadata?: (R2HTTPMetadata | Headers); + customMetadata?: Record; + md5?: ((ArrayBuffer | ArrayBufferView) | string); + sha1?: ((ArrayBuffer | ArrayBufferView) | string); + sha256?: ((ArrayBuffer | ArrayBufferView) | string); + sha384?: ((ArrayBuffer | ArrayBufferView) | string); + sha512?: ((ArrayBuffer | ArrayBufferView) | string); + storageClass?: string; + ssecKey?: (ArrayBuffer | string); +} +interface R2MultipartOptions { + httpMetadata?: (R2HTTPMetadata | Headers); + customMetadata?: Record; + storageClass?: string; + ssecKey?: (ArrayBuffer | string); +} +interface R2Checksums { + readonly md5?: ArrayBuffer; + readonly sha1?: ArrayBuffer; + readonly sha256?: ArrayBuffer; + readonly sha384?: ArrayBuffer; + readonly sha512?: ArrayBuffer; + toJSON(): R2StringChecksums; +} +interface R2StringChecksums { + md5?: string; + sha1?: string; + sha256?: string; + sha384?: string; + sha512?: string; +} +interface R2HTTPMetadata { + contentType?: string; + contentLanguage?: string; + contentDisposition?: string; + contentEncoding?: string; + cacheControl?: string; + cacheExpiry?: Date; +} +type R2Objects = { + objects: R2Object[]; + delimitedPrefixes: string[]; +} & ({ + truncated: true; + cursor: string; +} | { + truncated: false; +}); +interface R2UploadPartOptions { + ssecKey?: (ArrayBuffer | string); +} +declare abstract class ScheduledEvent extends ExtendableEvent { + readonly scheduledTime: number; + readonly cron: string; + noRetry(): void; +} +interface ScheduledController { + readonly scheduledTime: number; + readonly cron: string; + noRetry(): void; +} +interface QueuingStrategy { + highWaterMark?: (number | bigint); + size?: (chunk: T) => number | bigint; +} +interface UnderlyingSink { + type?: string; + start?: (controller: WritableStreamDefaultController) => void | Promise; + write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise; + abort?: (reason: any) => void | Promise; + close?: () => void | Promise; +} +interface UnderlyingByteSource { + type: "bytes"; + autoAllocateChunkSize?: number; + start?: (controller: ReadableByteStreamController) => void | Promise; + pull?: (controller: ReadableByteStreamController) => void | Promise; + cancel?: (reason: any) => void | Promise; +} +interface UnderlyingSource { + type?: "" | undefined; + start?: (controller: ReadableStreamDefaultController) => void | Promise; + pull?: (controller: ReadableStreamDefaultController) => void | Promise; + cancel?: (reason: any) => void | Promise; + expectedLength?: (number | bigint); +} +interface Transformer { + readableType?: string; + writableType?: string; + start?: (controller: TransformStreamDefaultController) => void | Promise; + transform?: (chunk: I, controller: TransformStreamDefaultController) => void | Promise; + flush?: (controller: TransformStreamDefaultController) => void | Promise; + cancel?: (reason: any) => void | Promise; + expectedLength?: number; +} +interface StreamPipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + /** + * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. + * + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. + * + * Errors and closures of the source and destination streams propagate as follows: + * + * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. + * + * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. + * + * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. + * + * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. + * + * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. + */ + preventClose?: boolean; + signal?: AbortSignal; +} +type ReadableStreamReadResult = { + done: false; + value: R; +} | { + done: true; + value?: undefined; +}; +/** + * The `ReadableStream` interface of the Streams API represents a readable stream of byte data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream) + */ +interface ReadableStream { + /** + * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) + */ + get locked(): boolean; + /** + * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) + */ + cancel(reason?: any): Promise; + /** + * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) + */ + getReader(): ReadableStreamDefaultReader; + /** + * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) + */ + getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader; + /** + * The **`pipeThrough()`** method of the ReadableStream interface provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) + */ + pipeThrough(transform: ReadableWritablePair, options?: StreamPipeOptions): ReadableStream; + /** + * The **`pipeTo()`** method of the ReadableStream interface pipes the current `ReadableStream` to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) + */ + pipeTo(destination: WritableStream, options?: StreamPipeOptions): Promise; + /** + * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) + */ + tee(): [ + ReadableStream, + ReadableStream + ]; + values(options?: ReadableStreamValuesOptions): AsyncIterableIterator; + [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator; +} +/** + * The `ReadableStream` interface of the Streams API represents a readable stream of byte data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream) + */ +declare const ReadableStream: { + prototype: ReadableStream; + new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy): ReadableStream; + new (underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; +}; +/** + * The **`ReadableStreamDefaultReader`** interface of the Streams API represents a default reader that can be used to read stream data supplied from a network (such as a fetch request). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader) + */ +declare class ReadableStreamDefaultReader { + constructor(stream: ReadableStream); + get closed(): Promise; + cancel(reason?: any): Promise; + /** + * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) + */ + read(): Promise>; + /** + * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) + */ + releaseLock(): void; +} +/** + * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) + */ +declare class ReadableStreamBYOBReader { + constructor(stream: ReadableStream); + get closed(): Promise; + cancel(reason?: any): Promise; + /** + * The **`read()`** method of the ReadableStreamBYOBReader interface is used to read data into a view on a user-supplied buffer from an associated readable byte stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) + */ + read(view: T): Promise>; + /** + * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) + */ + releaseLock(): void; + readAtLeast(minElements: number, view: T): Promise>; +} +interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions { + min?: number; +} +interface ReadableStreamGetReaderOptions { + /** + * Creates a ReadableStreamBYOBReader and locks the stream to the new reader. + * + * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation. + */ + mode: "byob"; +} +/** + * The **`ReadableStreamBYOBRequest`** interface of the Streams API represents a 'pull request' for data from an underlying source that will made as a zero-copy transfer to a consumer (bypassing the stream's internal queues). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) + */ +declare abstract class ReadableStreamBYOBRequest { + /** + * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) + */ + get view(): Uint8Array | null; + /** + * The **`respond()`** method of the ReadableStreamBYOBRequest interface is used to signal to the associated readable byte stream that the specified number of bytes were written into the ReadableStreamBYOBRequest.view. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) + */ + respond(bytesWritten: number): void; + /** + * The **`respondWithNewView()`** method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) + */ + respondWithNewView(view: ArrayBuffer | ArrayBufferView): void; + get atLeast(): number | null; +} +/** + * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController) + */ +declare abstract class ReadableStreamDefaultController { + /** + * The **`desiredSize`** read-only property of the required to fill the stream's internal queue. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) + */ + get desiredSize(): number | null; + /** + * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) + */ + close(): void; + /** + * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) + */ + enqueue(chunk?: R): void; + /** + * The **`error()`** method of the with the associated stream to error. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) + */ + error(reason: any): void; +} +/** + * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController) + */ +declare abstract class ReadableByteStreamController { + /** + * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) + */ + get byobRequest(): ReadableStreamBYOBRequest | null; + /** + * The **`desiredSize`** read-only property of the ReadableByteStreamController interface returns the number of bytes required to fill the stream's internal queue to its 'desired size'. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) + */ + get desiredSize(): number | null; + /** + * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) + */ + close(): void; + /** + * The **`enqueue()`** method of the ReadableByteStreamController interface enqueues a given chunk on the associated readable byte stream (the chunk is copied into the stream's internal queues). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) + */ + enqueue(chunk: ArrayBuffer | ArrayBufferView): void; + /** + * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) + */ + error(reason: any): void; +} +/** + * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController) + */ +declare abstract class WritableStreamDefaultController { + /** + * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) + */ + get signal(): AbortSignal; + /** + * The **`error()`** method of the with the associated stream to error. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) + */ + error(reason?: any): void; +} +/** + * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController) + */ +declare abstract class TransformStreamDefaultController { + /** + * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) + */ + get desiredSize(): number | null; + /** + * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) + */ + enqueue(chunk?: O): void; + /** + * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) + */ + error(reason: any): void; + /** + * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) + */ + terminate(): void; +} +interface ReadableWritablePair { + readable: ReadableStream; + /** + * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. + * + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. + */ + writable: WritableStream; +} +/** + * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream) + */ +declare class WritableStream { + constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy); + /** + * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) + */ + get locked(): boolean; + /** + * The **`abort()`** method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) + */ + abort(reason?: any): Promise; + /** + * The **`close()`** method of the WritableStream interface closes the associated stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) + */ + close(): Promise; + /** + * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) + */ + getWriter(): WritableStreamDefaultWriter; +} +/** + * The **`WritableStreamDefaultWriter`** interface of the Streams API is the object returned by WritableStream.getWriter() and once created locks the writer to the `WritableStream` ensuring that no other streams can write to the underlying sink. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter) + */ +declare class WritableStreamDefaultWriter { + constructor(stream: WritableStream); + /** + * The **`closed`** read-only property of the the stream errors or the writer's lock is released. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) + */ + get closed(): Promise; + /** + * The **`ready`** read-only property of the that resolves when the desired size of the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) + */ + get ready(): Promise; + /** + * The **`desiredSize`** read-only property of the to fill the stream's internal queue. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) + */ + get desiredSize(): number | null; + /** + * The **`abort()`** method of the the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) + */ + abort(reason?: any): Promise; + /** + * The **`close()`** method of the stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) + */ + close(): Promise; + /** + * The **`write()`** method of the operation. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) + */ + write(chunk?: W): Promise; + /** + * The **`releaseLock()`** method of the corresponding stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) + */ + releaseLock(): void; +} +/** + * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream) + */ +declare class TransformStream { + constructor(transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy); + /** + * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) + */ + get readable(): ReadableStream; + /** + * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) + */ + get writable(): WritableStream; +} +declare class FixedLengthStream extends IdentityTransformStream { + constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy); +} +declare class IdentityTransformStream extends TransformStream { + constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy); +} +interface IdentityTransformStreamQueuingStrategy { + highWaterMark?: (number | bigint); +} +interface ReadableStreamValuesOptions { + preventCancel?: boolean; +} +/** + * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) + */ +declare class CompressionStream extends TransformStream { + constructor(format: "gzip" | "deflate" | "deflate-raw"); +} +/** + * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) + */ +declare class DecompressionStream extends TransformStream { + constructor(format: "gzip" | "deflate" | "deflate-raw"); +} +/** + * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) + */ +declare class TextEncoderStream extends TransformStream { + constructor(); + get encoding(): string; +} +/** + * The **`TextDecoderStream`** interface of the Encoding API converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream) + */ +declare class TextDecoderStream extends TransformStream { + constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit); + get encoding(): string; + get fatal(): boolean; + get ignoreBOM(): boolean; +} +interface TextDecoderStreamTextDecoderStreamInit { + fatal?: boolean; + ignoreBOM?: boolean; +} +/** + * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy) + */ +declare class ByteLengthQueuingStrategy implements QueuingStrategy { + constructor(init: QueuingStrategyInit); + /** + * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) + */ + get highWaterMark(): number; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */ + get size(): (chunk?: any) => number; +} +/** + * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy) + */ +declare class CountQueuingStrategy implements QueuingStrategy { + constructor(init: QueuingStrategyInit); + /** + * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) + */ + get highWaterMark(): number; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */ + get size(): (chunk?: any) => number; +} +interface QueuingStrategyInit { + /** + * Creates a new ByteLengthQueuingStrategy with the provided high water mark. + * + * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. + */ + highWaterMark: number; +} +interface TracePreviewInfo { + id: string; + slug: string; + name: string; +} +interface ScriptVersion { + id?: string; + tag?: string; + message?: string; +} +declare abstract class TailEvent extends ExtendableEvent { + readonly events: TraceItem[]; + readonly traces: TraceItem[]; +} +interface TraceItem { + readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemConnectEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null; + readonly eventTimestamp: number | null; + readonly logs: TraceLog[]; + readonly exceptions: TraceException[]; + readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[]; + readonly scriptName: string | null; + readonly entrypoint?: string; + readonly scriptVersion?: ScriptVersion; + readonly dispatchNamespace?: string; + readonly scriptTags?: string[]; + readonly tailAttributes?: Record; + readonly preview?: TracePreviewInfo; + readonly durableObjectId?: string; + readonly outcome: string; + readonly executionModel: string; + readonly truncated: boolean; + readonly cpuTime: number; + readonly wallTime: number; +} +interface TraceItemAlarmEventInfo { + readonly scheduledTime: Date; +} +interface TraceItemConnectEventInfo { +} +interface TraceItemCustomEventInfo { +} +interface TraceItemScheduledEventInfo { + readonly scheduledTime: number; + readonly cron: string; +} +interface TraceItemQueueEventInfo { + readonly queue: string; + readonly batchSize: number; +} +interface TraceItemEmailEventInfo { + readonly mailFrom: string; + readonly rcptTo: string; + readonly rawSize: number; +} +interface TraceItemTailEventInfo { + readonly consumedEvents: TraceItemTailEventInfoTailItem[]; +} +interface TraceItemTailEventInfoTailItem { + readonly scriptName: string | null; +} +interface TraceItemFetchEventInfo { + readonly response?: TraceItemFetchEventInfoResponse; + readonly request: TraceItemFetchEventInfoRequest; +} +interface TraceItemFetchEventInfoRequest { + readonly cf?: any; + readonly headers: Record; + readonly method: string; + readonly url: string; + getUnredacted(): TraceItemFetchEventInfoRequest; +} +interface TraceItemFetchEventInfoResponse { + readonly status: number; +} +interface TraceItemJsRpcEventInfo { + readonly rpcMethod: string; +} +interface TraceItemHibernatableWebSocketEventInfo { + readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError; +} +interface TraceItemHibernatableWebSocketEventInfoMessage { + readonly webSocketEventType: string; +} +interface TraceItemHibernatableWebSocketEventInfoClose { + readonly webSocketEventType: string; + readonly code: number; + readonly wasClean: boolean; +} +interface TraceItemHibernatableWebSocketEventInfoError { + readonly webSocketEventType: string; +} +interface TraceLog { + readonly timestamp: number; + readonly level: string; + readonly message: any; +} +interface TraceException { + readonly timestamp: number; + readonly message: string; + readonly name: string; + readonly stack?: string; +} +interface TraceDiagnosticChannelEvent { + readonly timestamp: number; + readonly channel: string; + readonly message: any; +} +interface TraceMetrics { + readonly cpuTime: number; + readonly wallTime: number; +} +interface UnsafeTraceMetrics { + fromTrace(item: TraceItem): TraceMetrics; +} +/** + * The **`URL`** interface is used to parse, construct, normalize, and encode URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL) + */ +declare class URL { + constructor(url: string | URL, base?: string | URL); + /** + * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) + */ + get origin(): string; + /** + * The **`href`** property of the URL interface is a string containing the whole URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) + */ + get href(): string; + /** + * The **`href`** property of the URL interface is a string containing the whole URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) + */ + set href(value: string); + /** + * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) + */ + get protocol(): string; + /** + * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) + */ + set protocol(value: string); + /** + * The **`username`** property of the URL interface is a string containing the username component of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) + */ + get username(): string; + /** + * The **`username`** property of the URL interface is a string containing the username component of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) + */ + set username(value: string); + /** + * The **`password`** property of the URL interface is a string containing the password component of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) + */ + get password(): string; + /** + * The **`password`** property of the URL interface is a string containing the password component of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) + */ + set password(value: string); + /** + * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) + */ + get host(): string; + /** + * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) + */ + set host(value: string); + /** + * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) + */ + get hostname(): string; + /** + * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) + */ + set hostname(value: string); + /** + * The **`port`** property of the URL interface is a string containing the port number of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) + */ + get port(): string; + /** + * The **`port`** property of the URL interface is a string containing the port number of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) + */ + set port(value: string); + /** + * The **`pathname`** property of the URL interface represents a location in a hierarchical structure. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) + */ + get pathname(): string; + /** + * The **`pathname`** property of the URL interface represents a location in a hierarchical structure. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) + */ + set pathname(value: string); + /** + * The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) + */ + get search(): string; + /** + * The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) + */ + set search(value: string); + /** + * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) + */ + get hash(): string; + /** + * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) + */ + set hash(value: string); + /** + * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) + */ + get searchParams(): URLSearchParams; + /** + * The **`toJSON()`** method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as ```js-nolint toJSON() ``` None. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) + */ + toJSON(): string; + /*function toString() { [native code] }*/ + toString(): string; + /** + * The **`URL.canParse()`** static method of the URL interface returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) + */ + static canParse(url: string, base?: string): boolean; + /** + * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) + */ + static parse(url: string, base?: string): URL | null; + /** + * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) + */ + static createObjectURL(object: File | Blob): string; + /** + * The **`revokeObjectURL()`** static method of the URL interface releases an existing object URL which was previously created by calling Call this method when you've finished using an object URL to let the browser know not to keep the reference to the file any longer. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) + */ + static revokeObjectURL(object_url: string): void; +} +/** + * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) + */ +declare class URLSearchParams { + constructor(init?: (Iterable> | Record | string)); + /** + * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) + */ + get size(): number; + /** + * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append) + */ + append(name: string, value: string): void; + /** + * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete) + */ + delete(name: string, value?: string): void; + /** + * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get) + */ + get(name: string): string | null; + /** + * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll) + */ + getAll(name: string): string[]; + /** + * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has) + */ + has(name: string, value?: string): boolean; + /** + * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set) + */ + set(name: string, value: string): void; + /** + * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) + */ + sort(): void; + /* Returns an array of key, value pairs for every entry in the search params. */ + entries(): IterableIterator<[ + key: string, + value: string + ]>; + /* Returns a list of keys in the search params. */ + keys(): IterableIterator; + /* Returns a list of values in the search params. */ + values(): IterableIterator; + forEach(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void; + /*function toString() { [native code] }*/ + toString(): string; + [Symbol.iterator](): IterableIterator<[ + key: string, + value: string + ]>; +} +declare class URLPattern { + constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions); + get protocol(): string; + get username(): string; + get password(): string; + get hostname(): string; + get port(): string; + get pathname(): string; + get search(): string; + get hash(): string; + get hasRegExpGroups(): boolean; + test(input?: (string | URLPatternInit), baseURL?: string): boolean; + exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null; +} +interface URLPatternInit { + protocol?: string; + username?: string; + password?: string; + hostname?: string; + port?: string; + pathname?: string; + search?: string; + hash?: string; + baseURL?: string; +} +interface URLPatternComponentResult { + input: string; + groups: Record; +} +interface URLPatternResult { + inputs: (string | URLPatternInit)[]; + protocol: URLPatternComponentResult; + username: URLPatternComponentResult; + password: URLPatternComponentResult; + hostname: URLPatternComponentResult; + port: URLPatternComponentResult; + pathname: URLPatternComponentResult; + search: URLPatternComponentResult; + hash: URLPatternComponentResult; +} +interface URLPatternOptions { + ignoreCase?: boolean; +} +/** + * A `CloseEvent` is sent to clients using WebSockets when the connection is closed. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent) + */ +declare class CloseEvent extends Event { + constructor(type: string, initializer?: CloseEventInit); + /** + * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code) + */ + readonly code: number; + /** + * The **`reason`** read-only property of the CloseEvent interface returns the WebSocket connection close reason the server gave for closing the connection; that is, a concise human-readable prose explanation for the closure. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason) + */ + readonly reason: string; + /** + * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean) + */ + readonly wasClean: boolean; +} +interface CloseEventInit { + code?: number; + reason?: string; + wasClean?: boolean; +} +type WebSocketEventMap = { + close: CloseEvent; + message: MessageEvent; + open: Event; + error: ErrorEvent; +}; +/** + * The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) + */ +declare var WebSocket: { + prototype: WebSocket; + new (url: string, protocols?: (string[] | string)): WebSocket; + readonly READY_STATE_CONNECTING: number; + readonly CONNECTING: number; + readonly READY_STATE_OPEN: number; + readonly OPEN: number; + readonly READY_STATE_CLOSING: number; + readonly CLOSING: number; + readonly READY_STATE_CLOSED: number; + readonly CLOSED: number; +}; +/** + * The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) + */ +interface WebSocket extends EventTarget { + accept(options?: WebSocketAcceptOptions): void; + /** + * The **`WebSocket.send()`** method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of `bufferedAmount` by the number of bytes needed to contain the data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send) + */ + send(message: (ArrayBuffer | ArrayBufferView) | string): void; + /** + * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close) + */ + close(code?: number, reason?: string): void; + serializeAttachment(attachment: any): void; + deserializeAttachment(): any | null; + /** + * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState) + */ + readyState: number; + /** + * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url) + */ + url: string | null; + /** + * The **`WebSocket.protocol`** read-only property returns the name of the sub-protocol the server selected; this will be one of the strings specified in the `protocols` parameter when creating the WebSocket object, or the empty string if no connection is established. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol) + */ + protocol: string | null; + /** + * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions) + */ + extensions: string | null; + /** + * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) + */ + binaryType: "blob" | "arraybuffer"; +} +interface WebSocketAcceptOptions { + /** + * When set to `true`, receiving a server-initiated WebSocket Close frame will not + * automatically send a reciprocal Close frame, leaving the connection in a half-open + * state. This is useful for proxying scenarios where you need to coordinate closing + * both sides independently. Defaults to `false` when the + * `no_web_socket_half_open_by_default` compatibility flag is enabled. + */ + allowHalfOpen?: boolean; +} +declare const WebSocketPair: { + new (): { + 0: WebSocket; + 1: WebSocket; + }; +}; +interface SqlStorage { + exec>(query: string, ...bindings: any[]): SqlStorageCursor; + get databaseSize(): number; + Cursor: typeof SqlStorageCursor; + Statement: typeof SqlStorageStatement; +} +declare abstract class SqlStorageStatement { +} +type SqlStorageValue = ArrayBuffer | string | number | null; +declare abstract class SqlStorageCursor> { + next(): { + done?: false; + value: T; + } | { + done: true; + value?: never; + }; + toArray(): T[]; + one(): T; + raw(): IterableIterator; + columnNames: string[]; + get rowsRead(): number; + get rowsWritten(): number; + [Symbol.iterator](): IterableIterator; +} +interface Socket { + get readable(): ReadableStream; + get writable(): WritableStream; + get closed(): Promise; + get opened(): Promise; + get upgraded(): boolean; + get secureTransport(): "on" | "off" | "starttls"; + close(): Promise; + startTls(options?: TlsOptions): Socket; +} +interface SocketOptions { + secureTransport?: string; + allowHalfOpen: boolean; + highWaterMark?: (number | bigint); +} +interface SocketAddress { + hostname: string; + port: number; +} +interface TlsOptions { + expectedServerHostname?: string; +} +interface SocketInfo { + remoteAddress?: string; + localAddress?: string; +} +/** + * The **`EventSource`** interface is web content's interface to server-sent events. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) + */ +declare class EventSource extends EventTarget { + constructor(url: string, init?: EventSourceEventSourceInit); + /** + * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close) + */ + close(): void; + /** + * The **`url`** read-only property of the URL of the source. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url) + */ + get url(): string; + /** + * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials) + */ + get withCredentials(): boolean; + /** + * The **`readyState`** read-only property of the connection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState) + */ + get readyState(): number; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ + get onopen(): any | null; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ + set onopen(value: any | null); + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ + get onmessage(): any | null; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ + set onmessage(value: any | null); + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ + get onerror(): any | null; + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ + set onerror(value: any | null); + static readonly CONNECTING: number; + static readonly OPEN: number; + static readonly CLOSED: number; + static from(stream: ReadableStream): EventSource; +} +interface EventSourceEventSourceInit { + withCredentials?: boolean; + fetcher?: Fetcher; +} +interface Container { + get running(): boolean; + start(options?: ContainerStartupOptions): void; + monitor(): Promise; + destroy(error?: any): Promise; + signal(signo: number): void; + getTcpPort(port: number): Fetcher; + setInactivityTimeout(durationMs: number | bigint): Promise; + interceptOutboundHttp(addr: string, binding: Fetcher): Promise; + interceptAllOutboundHttp(binding: Fetcher): Promise; + snapshotDirectory(options: ContainerDirectorySnapshotOptions): Promise; + snapshotContainer(options: ContainerSnapshotOptions): Promise; + interceptOutboundHttps(addr: string, binding: Fetcher): Promise; +} +interface ContainerDirectorySnapshot { + id: string; + size: number; + dir: string; + name?: string; +} +interface ContainerDirectorySnapshotOptions { + dir: string; + name?: string; +} +interface ContainerDirectorySnapshotRestoreParams { + snapshot: ContainerDirectorySnapshot; + mountPoint?: string; +} +interface ContainerSnapshot { + id: string; + size: number; + name?: string; +} +interface ContainerSnapshotOptions { + name?: string; +} +interface ContainerStartupOptions { + entrypoint?: string[]; + enableInternet: boolean; + env?: Record; + labels?: Record; + directorySnapshots?: ContainerDirectorySnapshotRestoreParams[]; + containerSnapshot?: ContainerSnapshot; +} +/** + * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort) + */ +declare abstract class MessagePort extends EventTarget { + /** + * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage) + */ + postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void; + /** + * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close) + */ + close(): void; + /** + * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start) + */ + start(): void; + get onmessage(): any | null; + set onmessage(value: any | null); +} +/** + * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel) + */ +declare class MessageChannel { + constructor(); + /** + * The **`port1`** read-only property of the the port attached to the context that originated the channel. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1) + */ + readonly port1: MessagePort; + /** + * The **`port2`** read-only property of the the port attached to the context at the other end of the channel, which the message is initially sent to. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2) + */ + readonly port2: MessagePort; +} +interface MessagePortPostMessageOptions { + transfer?: any[]; +} +type LoopbackForExport Rpc.EntrypointBranded) | ExportedHandler | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? LoopbackServiceStub> : T extends new (...args: any[]) => Rpc.DurableObjectBranded ? LoopbackDurableObjectClass> : T extends ExportedHandler ? LoopbackServiceStub : undefined; +type LoopbackServiceStub = Fetcher & (T extends CloudflareWorkersModule.WorkerEntrypoint ? (opts: { + props?: Props; +}) => Fetcher : (opts: { + props?: any; +}) => Fetcher); +type LoopbackDurableObjectClass = DurableObjectClass & (T extends CloudflareWorkersModule.DurableObject ? (opts: { + props?: Props; +}) => DurableObjectClass : (opts: { + props?: any; +}) => DurableObjectClass); +interface LoopbackDurableObjectNamespace extends DurableObjectNamespace { +} +interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace { +} +interface SyncKvStorage { + get(key: string): T | undefined; + list(options?: SyncKvListOptions): Iterable<[ + string, + T + ]>; + put(key: string, value: T): void; + delete(key: string): boolean; +} +interface SyncKvListOptions { + start?: string; + startAfter?: string; + end?: string; + prefix?: string; + reverse?: boolean; + limit?: number; +} +interface WorkerStub { + getEntrypoint(name?: string, options?: WorkerStubEntrypointOptions): Fetcher; + getDurableObjectClass(name?: string, options?: WorkerStubEntrypointOptions): DurableObjectClass; +} +interface WorkerStubEntrypointOptions { + props?: any; + limits?: workerdResourceLimits; +} +interface WorkerLoader { + get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise): WorkerStub; + load(code: WorkerLoaderWorkerCode): WorkerStub; +} +interface WorkerLoaderModule { + js?: string; + cjs?: string; + text?: string; + data?: ArrayBuffer; + json?: any; + py?: string; + wasm?: ArrayBuffer; +} +interface WorkerLoaderWorkerCode { + compatibilityDate: string; + compatibilityFlags?: string[]; + allowExperimental?: boolean; + limits?: workerdResourceLimits; + mainModule: string; + modules: Record; + env?: any; + globalOutbound?: (Fetcher | null); + tails?: Fetcher[]; + streamingTails?: Fetcher[]; +} +interface workerdResourceLimits { + cpuMs?: number; + subRequests?: number; +} +/** +* The Workers runtime supports a subset of the Performance API, used to measure timing and performance, +* as well as timing of subrequests and other operations. +* +* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/) +*/ +declare abstract class Performance { + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */ + get timeOrigin(): number; + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */ + now(): number; + /** + * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON) + */ + toJSON(): object; +} +interface Tracing { + enterSpan(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T; + Span: typeof Span; +} +declare abstract class Span { + get isTraced(): boolean; + setAttribute(key: string, value?: (boolean | number | string)): void; +} +// ============ AI Search Error Interfaces ============ +interface AiSearchInternalError extends Error { +} +interface AiSearchNotFoundError extends Error { +} +// ============ AI Search Common Types ============ +/** A single message in a conversation-style search or chat request. */ +type AiSearchMessage = { + role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; + content: string | null; +}; +/** + * Common shape for `ai_search_options` used by both single-instance and multi-instance requests. + * Contains retrieval, query rewrite, reranking, and cache sub-options. + */ +type AiSearchOptions = { + retrieval?: { + /** Which retrieval backend to use. Defaults to the instance's configured index_method. */ + retrieval_type?: 'vector' | 'keyword' | 'hybrid'; + /** Fusion method for combining vector + keyword results. */ + fusion_method?: 'max' | 'rrf'; + /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */ + keyword_match_mode?: 'and' | 'or'; + /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */ + match_threshold?: number; + /** Maximum number of results to return (1-50). Default 10. */ + max_num_results?: number; + /** Vectorize metadata filters applied to the search. */ + filters?: VectorizeVectorMetadataFilter; + /** Number of surrounding chunks to include for context (0-3). Default 0. */ + context_expansion?: number; + /** If true, return only item metadata without chunk text. */ + metadata_only?: boolean; + /** If true (default), return empty results on retrieval failure instead of throwing. */ + return_on_failure?: boolean; + /** Boost results by metadata field values. Max 3 entries. */ + boost_by?: Array<{ + field: string; + direction?: 'asc' | 'desc' | 'exists' | 'not_exists'; + }>; + [key: string]: unknown; + }; + query_rewrite?: { + enabled?: boolean; + model?: string; + rewrite_prompt?: string; + [key: string]: unknown; + }; + reranking?: { + enabled?: boolean; + model?: string; + /** Match threshold (0-1, default 0.4) */ + match_threshold?: number; + [key: string]: unknown; + }; + cache?: { + enabled?: boolean; + cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes'; + }; + [key: string]: unknown; +}; +// ============ AI Search Request Types ============ +/** + * Request body for single-instance search. + * Exactly one of `query` or `messages` must be provided. + */ +type AiSearchSearchRequest = { + /** Simple query string. */ + query: string; + messages?: never; + ai_search_options?: AiSearchOptions; +} | { + query?: never; + /** Conversation-style input. At least one user message with non-empty content is required. */ + messages: AiSearchMessage[]; + ai_search_options?: AiSearchOptions; +}; +type AiSearchChatCompletionsRequest = { + messages: AiSearchMessage[]; + model?: string; + stream?: boolean; + ai_search_options?: AiSearchOptions; + [key: string]: unknown; +}; +// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============ +/** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */ +type AiSearchMultiSearchOptions = AiSearchOptions & { + /** Instance IDs to search across (1-10). */ + instance_ids: string[]; +}; +/** + * Request for searching across multiple instances within a namespace. + * `ai_search_options` is required and must include `instance_ids`. + * Exactly one of `query` or `messages` must be provided. + */ +type AiSearchMultiSearchRequest = { + /** Simple query string. */ + query: string; + messages?: never; + ai_search_options: AiSearchMultiSearchOptions; +} | { + query?: never; + /** Conversation-style input. */ + messages: AiSearchMessage[]; + ai_search_options: AiSearchMultiSearchOptions; +}; +/** A search result chunk tagged with the instance it originated from. */ +type AiSearchMultiSearchChunk = AiSearchSearchResponse['chunks'][number] & { + instance_id: string; +}; +/** Describes a per-instance error during a multi-instance operation. */ +type AiSearchMultiSearchError = { + instance_id: string; + message: string; +}; +/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */ +type AiSearchMultiSearchResponse = { + search_query: string; + chunks: AiSearchMultiSearchChunk[]; + errors?: AiSearchMultiSearchError[]; +}; +/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */ +type AiSearchMultiChatCompletionsRequest = Omit & { + ai_search_options: AiSearchMultiSearchOptions; +}; +/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */ +type AiSearchMultiChatCompletionsResponse = Omit & { + chunks: AiSearchMultiSearchChunk[]; + errors?: AiSearchMultiSearchError[]; +}; +// ============ AI Search Response Types ============ +type AiSearchSearchResponse = { + search_query: string; + chunks: Array<{ + id: string; + type: string; + /** Match score (0-1) */ + score: number; + text: string; + item: { + timestamp?: number; + key: string; + metadata?: Record; + }; + scoring_details?: { + /** Keyword match score (0-1) */ + keyword_score?: number; + /** Vector similarity score (0-1) */ + vector_score?: number; + /** Keyword rank position */ + keyword_rank?: number; + /** Vector rank position */ + vector_rank?: number; + /** Reranking model score */ + reranking_score?: number; + /** Fusion method used to combine results */ + fusion_method?: 'rrf' | 'max'; + [key: string]: unknown; + }; + }>; +}; +type AiSearchChatCompletionsResponse = { + id?: string; + object?: string; + model?: string; + choices: Array<{ + index?: number; + message: { + role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; + content: string | null; + [key: string]: unknown; + }; + [key: string]: unknown; + }>; + chunks: AiSearchSearchResponse['chunks']; + [key: string]: unknown; +}; +type AiSearchStatsResponse = { + queued?: number; + running?: number; + completed?: number; + error?: number; + skipped?: number; + outdated?: number; + last_activity?: string; + /** Storage engine statistics. */ + engine?: { + vectorize?: { + vectorsCount: number; + dimensions: number; + }; + r2?: { + payloadSizeBytes: number; + metadataSizeBytes: number; + objectCount: number; + }; + }; +}; +// ============ AI Search Instance Info Types ============ +type AiSearchInstanceInfo = { + id: string; + type?: 'r2' | 'web-crawler' | string; + source?: string; + source_params?: unknown; + paused?: boolean; + status?: string; + namespace?: string; + created_at?: string; + modified_at?: string; + token_id?: string; + ai_gateway_id?: string; + rewrite_query?: boolean; + reranking?: boolean; + embedding_model?: string; + ai_search_model?: string; + rewrite_model?: string; + reranking_model?: string; + /** @deprecated Use index_method instead. */ + hybrid_search_enabled?: boolean; + /** Controls which storage backends are active. */ + index_method?: { + vector?: boolean; + keyword?: boolean; + }; + /** Fusion method for combining vector and keyword results. */ + fusion_method?: 'max' | 'rrf'; + indexing_options?: { + keyword_tokenizer?: 'porter' | 'trigram'; + } | null; + retrieval_options?: { + keyword_match_mode?: 'and' | 'or'; + boost_by?: Array<{ + field: string; + direction?: 'asc' | 'desc' | 'exists' | 'not_exists'; + }>; + } | null; + chunk?: boolean; + chunk_size?: number; + chunk_overlap?: number; + score_threshold?: number; + max_num_results?: number; + cache?: boolean; + cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes'; + custom_metadata?: Array<{ + field_name: string; + data_type: 'text' | 'number' | 'boolean' | 'datetime'; + }>; + /** Sync interval in seconds. */ + sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400; + metadata?: Record; + [key: string]: unknown; +}; +/** Pagination, search, and ordering parameters for listing instances within a namespace. */ +type AiSearchListInstancesParams = { + page?: number; + per_page?: number; + /** Search instances by ID. */ + search?: string; + /** Field to sort by. */ + order_by?: 'created_at'; + /** Sort direction. */ + order_by_direction?: 'asc' | 'desc'; +}; +type AiSearchListResponse = { + result: AiSearchInstanceInfo[]; + result_info?: { + count: number; + page: number; + per_page: number; + total_count: number; + }; +}; +// ============ AI Search Config Types ============ +type AiSearchConfig = { + /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */ + id: string; + /** Instance type. Omit to create with built-in storage. */ + type?: 'r2' | 'web-crawler' | string; + /** Source URL (required for web-crawler type). */ + source?: string; + source_params?: unknown; + /** Token ID (UUID format) */ + token_id?: string; + ai_gateway_id?: string; + /** Enable query rewriting (default false) */ + rewrite_query?: boolean; + /** Enable reranking (default false) */ + reranking?: boolean; + embedding_model?: string; + ai_search_model?: string; + rewrite_model?: string; + reranking_model?: string; + /** @deprecated Use index_method instead. */ + hybrid_search_enabled?: boolean; + /** Controls which storage backends are used during indexing. Defaults to vector-only. */ + index_method?: { + vector?: boolean; + keyword?: boolean; + }; + /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */ + fusion_method?: 'max' | 'rrf'; + indexing_options?: { + keyword_tokenizer?: 'porter' | 'trigram'; + } | null; + retrieval_options?: { + keyword_match_mode?: 'and' | 'or'; + boost_by?: Array<{ + field: string; + direction?: 'asc' | 'desc' | 'exists' | 'not_exists'; + }>; + } | null; + chunk?: boolean; + chunk_size?: number; + chunk_overlap?: number; + /** Minimum similarity score (0-1) for a result to be included. */ + score_threshold?: number; + max_num_results?: number; + cache?: boolean; + /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */ + cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes'; + custom_metadata?: Array<{ + field_name: string; + data_type: 'text' | 'number' | 'boolean' | 'datetime'; + }>; + namespace?: string; + /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */ + sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400; + metadata?: Record; + [key: string]: unknown; +}; +// ============ AI Search Item Types ============ +type AiSearchItemInfo = { + id: string; + key: string; + status: 'completed' | 'error' | 'skipped' | 'queued' | 'running' | 'outdated'; + next_action?: 'INDEX' | 'DELETE' | null; + error?: string; + checksum?: string; + namespace?: string; + chunks_count?: number | null; + file_size?: number | null; + source_id?: string | null; + last_seen_at?: string; + created_at?: string; + metadata?: Record; + [key: string]: unknown; +}; +type AiSearchItemContentResult = { + body: ReadableStream; + contentType: string; + filename: string; + size: number; +}; +type AiSearchUploadItemOptions = { + metadata?: Record; +}; +type AiSearchListItemsParams = { + page?: number; + per_page?: number; + /** Search items by key name. */ + search?: string; + /** Sort order for results. */ + sort_by?: 'status' | 'modified_at'; + /** Filter items by processing status. */ + status?: 'queued' | 'running' | 'completed' | 'error' | 'skipped' | 'outdated'; + /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */ + source?: string; + /** JSON-encoded Vectorize filter for metadata filtering. */ + metadata_filter?: string; +}; +type AiSearchListItemsResponse = { + result: AiSearchItemInfo[]; + result_info?: { + count: number; + page: number; + per_page: number; + total_count: number; + }; +}; +// ============ AI Search Item Logs Types ============ +type AiSearchItemLogsParams = { + /** Maximum number of log entries to return (1-100, default 50). */ + limit?: number; + /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */ + cursor?: string; +}; +type AiSearchItemLog = { + timestamp: string; + action: string; + message: string; + fileKey?: string; + chunkCount?: number; + processingTimeMs?: number; + errorType?: string; +}; +/** Paginated response for item processing logs (cursor-based). */ +type AiSearchItemLogsResponse = { + result: AiSearchItemLog[]; + result_info: { + count: number; + per_page: number; + cursor: string | null; + truncated: boolean; + }; +}; +// ============ AI Search Item Chunks Types ============ +type AiSearchItemChunksParams = { + /** Maximum number of chunks to return (1-100, default 20). */ + limit?: number; + /** Offset into the chunks list (default 0). */ + offset?: number; +}; +/** A single indexed chunk belonging to an item, including its text content and byte range. */ +type AiSearchItemChunk = { + id: string; + text: string; + start_byte: number; + end_byte: number; + item?: { + timestamp?: number; + key: string; + metadata?: Record; + }; +}; +/** Paginated response for item chunks (offset-based). */ +type AiSearchItemChunksResponse = { + result: AiSearchItemChunk[]; + result_info: { + count: number; + total: number; + limit: number; + offset: number; + }; +}; +// ============ AI Search Job Types ============ +type AiSearchJobInfo = { + id: string; + source: 'user' | 'schedule'; + description?: string; + last_seen_at?: string; + started_at?: string; + ended_at?: string; + end_reason?: string; +}; +type AiSearchJobLog = { + id: number; + message: string; + message_type: number; + created_at: number; +}; +type AiSearchCreateJobParams = { + description?: string; +}; +type AiSearchListJobsParams = { + page?: number; + per_page?: number; +}; +type AiSearchListJobsResponse = { + result: AiSearchJobInfo[]; + result_info?: { + count: number; + page: number; + per_page: number; + total_count: number; + }; +}; +type AiSearchJobLogsParams = { + page?: number; + per_page?: number; +}; +type AiSearchJobLogsResponse = { + result: AiSearchJobLog[]; + result_info?: { + count: number; + page: number; + per_page: number; + total_count: number; + }; +}; +// ============ AI Search Sub-Service Classes ============ +/** + * Single item service for an AI Search instance. + * Provides info, download, sync, logs, and chunks operations on a specific item. + */ +declare abstract class AiSearchItem { + /** Get metadata about this item. */ + info(): Promise; + /** + * Download the item's content. + * @returns Object with body stream, content type, filename, and size. + */ + download(): Promise; + /** + * Trigger re-indexing of this item. + * @returns The updated item info. + */ + sync(): Promise; + /** + * Retrieve processing logs for this item (cursor-based pagination). + * @param params Optional pagination parameters (limit, cursor). + * @returns Paginated log entries for this item. + */ + logs(params?: AiSearchItemLogsParams): Promise; + /** + * List indexed chunks for this item (offset-based pagination). + * @param params Optional pagination parameters (limit, offset). + * @returns Paginated chunk entries for this item. + */ + chunks(params?: AiSearchItemChunksParams): Promise; +} +/** + * Items collection service for an AI Search instance. + * Provides list, upload, and access to individual items. + */ +declare abstract class AiSearchItems { + /** List items in this instance. */ + list(params?: AiSearchListItemsParams): Promise; + /** + * Upload a file as an item. Behaves as an upsert: if an item with the same + * filename already exists, it is overwritten and re-indexed. + * @param name Filename for the uploaded item. + * @param content File content as a ReadableStream, Blob, or string. + * @param options Optional metadata to attach to the item. + * @returns The created item info. + */ + upload(name: string, content: ReadableStream | Blob | string, options?: AiSearchUploadItemOptions): Promise; + /** + * Upload a file and poll until processing completes. + * Behaves as an upsert: if an item with the same filename already exists, + * it is overwritten and re-indexed. + * @param name Filename for the uploaded item. + * @param content File content as a ReadableStream, Blob, or string. + * @param options Optional metadata and polling configuration. + * @returns The item info after processing completes (or timeout). + */ + uploadAndPoll(name: string, content: ReadableStream | Blob | string, options?: AiSearchUploadItemOptions & { + /** Polling interval in milliseconds (default 1000). */ + pollIntervalMs?: number; + /** Maximum time to wait in milliseconds (default 30000). */ + timeoutMs?: number; + }): Promise; + /** + * Get an item by ID. + * @param itemId The item identifier. + * @returns Item service for info, download, sync, logs, and chunks operations. + */ + get(itemId: string): AiSearchItem; + /** + * Delete an item from the instance. + * @param itemId The item identifier. + */ + delete(itemId: string): Promise; +} +/** + * Single job service for an AI Search instance. + * Provides info, logs, and cancel operations for a specific job. + */ +declare abstract class AiSearchJob { + /** Get metadata about this job. */ + info(): Promise; + /** Get logs for this job. */ + logs(params?: AiSearchJobLogsParams): Promise; + /** + * Cancel a running job. + * @returns The updated job info. + * @throws AiSearchNotFoundError if the job does not exist. + */ + cancel(): Promise; +} +/** + * Jobs collection service for an AI Search instance. + * Provides list, create, and access to individual jobs. + */ +declare abstract class AiSearchJobs { + /** List jobs for this instance. */ + list(params?: AiSearchListJobsParams): Promise; + /** + * Create a new indexing job. + * @param params Optional job parameters. + * @returns The created job info. + */ + create(params?: AiSearchCreateJobParams): Promise; + /** + * Get a job by ID. + * @param jobId The job identifier. + * @returns Job service for info, logs, and cancel operations. + */ + get(jobId: string): AiSearchJob; +} +// ============ AI Search Binding Classes ============ +/** + * Instance-level AI Search service. + * + * Used as: + * - The return type of `AiSearchNamespace.get(name)` (namespace binding) + * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`) + * + * Provides search, chat, update, stats, items, and jobs operations. + * + * @example + * ```ts + * // Via namespace binding + * const instance = env.AI_SEARCH.get("blog"); + * const results = await instance.search({ + * query: "How does caching work?", + * }); + * + * // Via single instance binding + * const results = await env.BLOG_SEARCH.search({ + * messages: [{ role: "user", content: "How does caching work?" }], + * }); + * ``` + */ +declare abstract class AiSearchInstance { + /** + * Search the AI Search instance for relevant chunks. + * @param params Search request with query or messages and optional AI search options. + * @returns Search response with matching chunks and search query. + */ + search(params: AiSearchSearchRequest): Promise; + /** + * Generate chat completions with AI Search context (streaming). + * @param params Chat completions request with stream: true. + * @returns ReadableStream of server-sent events. + */ + chatCompletions(params: AiSearchChatCompletionsRequest & { + stream: true; + }): Promise; + /** + * Generate chat completions with AI Search context. + * @param params Chat completions request. + * @returns Chat completion response with choices and RAG chunks. + */ + chatCompletions(params: AiSearchChatCompletionsRequest): Promise; + /** + * Update the instance configuration. + * @param config Partial configuration to update. + * @returns Updated instance info. + */ + update(config: Partial): Promise; + /** Get metadata about this instance. */ + info(): Promise; + /** + * Get instance statistics (item count, indexing status, etc.). + * @returns Statistics with counts per status, last activity time, and engine details. + */ + stats(): Promise; + /** Items collection — list, upload, and manage items in this instance. */ + get items(): AiSearchItems; + /** Jobs collection — list, create, and inspect indexing jobs. */ + get jobs(): AiSearchJobs; +} +/** + * Namespace-level AI Search service. + * + * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`). + * Scoped to a single namespace. Provides dynamic instance access, creation, deletion, + * and multi-instance search/chat operations. + * + * @example + * ```ts + * // Access an instance within the namespace + * const blog = env.AI_SEARCH.get("blog"); + * const results = await blog.search({ query: "How does caching work?" }); + * + * // List all instances in the namespace + * const instances = await env.AI_SEARCH.list(); + * + * // Create a new instance with built-in storage + * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" }); + * + * // Upload items into the instance + * await tenant.items.upload("doc.pdf", fileContent); + * + * // Search across multiple instances + * const multi = await env.AI_SEARCH.search({ + * query: "caching", + * ai_search_options: { instance_ids: ["blog", "docs"] }, + * }); + * + * // Delete an instance + * await env.AI_SEARCH.delete("tenant-123"); + * ``` + */ +declare abstract class AiSearchNamespace { + /** + * Get an instance by name within the bound namespace. + * @param name Instance name. + * @returns Instance service for search, chat, update, stats, items, and jobs. + */ + get(name: string): AiSearchInstance; + /** + * List instances in the bound namespace. + * @param params Optional pagination, search, and ordering parameters. + * @returns Array of instance metadata with pagination info. + */ + list(params?: AiSearchListInstancesParams): Promise; + /** + * Create a new instance within the bound namespace. + * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage. + * @returns Instance service for the newly created instance. + * + * @example + * ```ts + * // Create with built-in storage (upload items manually) + * const instance = await env.AI_SEARCH.create({ id: "my-search" }); + * + * // Create with web crawler source + * const instance = await env.AI_SEARCH.create({ + * id: "docs-search", + * type: "web-crawler", + * source: "https://developers.cloudflare.com", + * }); + * ``` + */ + create(config: AiSearchConfig): Promise; + /** + * Delete an instance from the bound namespace. + * @param name Instance name to delete. + */ + delete(name: string): Promise; + /** + * Search across multiple instances within the bound namespace. + * Fans out to the specified instance_ids and merges results. + * @param params Search request with required `ai_search_options.instance_ids`. + * @returns Search response with chunks tagged by instance_id and optional partial-failure errors. + */ + search(params: AiSearchMultiSearchRequest): Promise; + /** + * Generate chat completions across multiple instances within the bound namespace (streaming). + * Fans out to the specified instance_ids, merges context, and generates a response. + * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`. + * @returns ReadableStream of server-sent events. + */ + chatCompletions(params: AiSearchMultiChatCompletionsRequest & { + stream: true; + }): Promise; + /** + * Generate chat completions across multiple instances within the bound namespace. + * Fans out to the specified instance_ids, merges context, and generates a response. + * @param params Chat completions request with required `ai_search_options.instance_ids`. + * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors. + */ + chatCompletions(params: AiSearchMultiChatCompletionsRequest): Promise; +} +type AiImageClassificationInput = { + image: number[]; +}; +type AiImageClassificationOutput = { + score?: number; + label?: string; +}[]; +declare abstract class BaseAiImageClassification { + inputs: AiImageClassificationInput; + postProcessedOutputs: AiImageClassificationOutput; +} +type AiImageToTextInput = { + image: number[]; + prompt?: string; + max_tokens?: number; + temperature?: number; + top_p?: number; + top_k?: number; + seed?: number; + repetition_penalty?: number; + frequency_penalty?: number; + presence_penalty?: number; + raw?: boolean; + messages?: RoleScopedChatInput[]; +}; +type AiImageToTextOutput = { + description: string; +}; +declare abstract class BaseAiImageToText { + inputs: AiImageToTextInput; + postProcessedOutputs: AiImageToTextOutput; +} +type AiImageTextToTextInput = { + image: string; + prompt?: string; + max_tokens?: number; + temperature?: number; + ignore_eos?: boolean; + top_p?: number; + top_k?: number; + seed?: number; + repetition_penalty?: number; + frequency_penalty?: number; + presence_penalty?: number; + raw?: boolean; + messages?: RoleScopedChatInput[]; +}; +type AiImageTextToTextOutput = { + description: string; +}; +declare abstract class BaseAiImageTextToText { + inputs: AiImageTextToTextInput; + postProcessedOutputs: AiImageTextToTextOutput; +} +type AiMultimodalEmbeddingsInput = { + image: string; + text: string[]; +}; +type AiIMultimodalEmbeddingsOutput = { + data: number[][]; + shape: number[]; +}; +declare abstract class BaseAiMultimodalEmbeddings { + inputs: AiImageTextToTextInput; + postProcessedOutputs: AiImageTextToTextOutput; +} +type AiObjectDetectionInput = { + image: number[]; +}; +type AiObjectDetectionOutput = { + score?: number; + label?: string; +}[]; +declare abstract class BaseAiObjectDetection { + inputs: AiObjectDetectionInput; + postProcessedOutputs: AiObjectDetectionOutput; +} +type AiSentenceSimilarityInput = { + source: string; + sentences: string[]; +}; +type AiSentenceSimilarityOutput = number[]; +declare abstract class BaseAiSentenceSimilarity { + inputs: AiSentenceSimilarityInput; + postProcessedOutputs: AiSentenceSimilarityOutput; +} +type AiAutomaticSpeechRecognitionInput = { + audio: number[]; +}; +type AiAutomaticSpeechRecognitionOutput = { + text?: string; + words?: { + word: string; + start: number; + end: number; + }[]; + vtt?: string; +}; +declare abstract class BaseAiAutomaticSpeechRecognition { + inputs: AiAutomaticSpeechRecognitionInput; + postProcessedOutputs: AiAutomaticSpeechRecognitionOutput; +} +type AiSummarizationInput = { + input_text: string; + max_length?: number; +}; +type AiSummarizationOutput = { + summary: string; +}; +declare abstract class BaseAiSummarization { + inputs: AiSummarizationInput; + postProcessedOutputs: AiSummarizationOutput; +} +type AiTextClassificationInput = { + text: string; +}; +type AiTextClassificationOutput = { + score?: number; + label?: string; +}[]; +declare abstract class BaseAiTextClassification { + inputs: AiTextClassificationInput; + postProcessedOutputs: AiTextClassificationOutput; +} +type AiTextEmbeddingsInput = { + text: string | string[]; +}; +type AiTextEmbeddingsOutput = { + shape: number[]; + data: number[][]; +}; +declare abstract class BaseAiTextEmbeddings { + inputs: AiTextEmbeddingsInput; + postProcessedOutputs: AiTextEmbeddingsOutput; +} +type RoleScopedChatInput = { + role: "user" | "assistant" | "system" | "tool" | (string & NonNullable); + content: string; + name?: string; +}; +type AiTextGenerationToolLegacyInput = { + name: string; + description: string; + parameters?: { + type: "object" | (string & NonNullable); + properties: { + [key: string]: { + type: string; + description?: string; + }; + }; + required: string[]; + }; +}; +type AiTextGenerationToolInput = { + type: "function" | (string & NonNullable); + function: { + name: string; + description: string; + parameters?: { + type: "object" | (string & NonNullable); + properties: { + [key: string]: { + type: string; + description?: string; + }; + }; + required: string[]; + }; + }; +}; +type AiTextGenerationFunctionsInput = { + name: string; + code: string; +}; +type AiTextGenerationResponseFormat = { + type: string; + json_schema?: any; +}; +type AiTextGenerationInput = { + prompt?: string; + raw?: boolean; + stream?: boolean; + max_tokens?: number; + temperature?: number; + top_p?: number; + top_k?: number; + seed?: number; + repetition_penalty?: number; + frequency_penalty?: number; + presence_penalty?: number; + messages?: RoleScopedChatInput[]; + response_format?: AiTextGenerationResponseFormat; + tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable); + functions?: AiTextGenerationFunctionsInput[]; +}; +type AiTextGenerationToolLegacyOutput = { + name: string; + arguments: unknown; +}; +type AiTextGenerationToolOutput = { + id: string; + type: "function"; + function: { + name: string; + arguments: string; + }; +}; +type UsageTags = { + prompt_tokens: number; + completion_tokens: number; + total_tokens: number; +}; +type AiTextGenerationOutput = { + response?: string; + tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[]; + usage?: UsageTags; +}; +declare abstract class BaseAiTextGeneration { + inputs: AiTextGenerationInput; + postProcessedOutputs: AiTextGenerationOutput; +} +type AiTextToSpeechInput = { + prompt: string; + lang?: string; +}; +type AiTextToSpeechOutput = Uint8Array | { + audio: string; +}; +declare abstract class BaseAiTextToSpeech { + inputs: AiTextToSpeechInput; + postProcessedOutputs: AiTextToSpeechOutput; +} +type AiTextToImageInput = { + prompt: string; + negative_prompt?: string; + height?: number; + width?: number; + image?: number[]; + image_b64?: string; + mask?: number[]; + num_steps?: number; + strength?: number; + guidance?: number; + seed?: number; +}; +type AiTextToImageOutput = ReadableStream; +declare abstract class BaseAiTextToImage { + inputs: AiTextToImageInput; + postProcessedOutputs: AiTextToImageOutput; +} +type AiTranslationInput = { + text: string; + target_lang: string; + source_lang?: string; +}; +type AiTranslationOutput = { + translated_text?: string; +}; +declare abstract class BaseAiTranslation { + inputs: AiTranslationInput; + postProcessedOutputs: AiTranslationOutput; +} +/** + * Workers AI support for OpenAI's Chat Completions API + */ +type ChatCompletionContentPartText = { + type: "text"; + text: string; +}; +type ChatCompletionContentPartImage = { + type: "image_url"; + image_url: { + url: string; + detail?: "auto" | "low" | "high"; + }; +}; +type ChatCompletionContentPartInputAudio = { + type: "input_audio"; + input_audio: { + /** Base64 encoded audio data. */ + data: string; + format: "wav" | "mp3"; + }; +}; +type ChatCompletionContentPartFile = { + type: "file"; + file: { + /** Base64 encoded file data. */ + file_data?: string; + /** The ID of an uploaded file. */ + file_id?: string; + filename?: string; + }; +}; +type ChatCompletionContentPartRefusal = { + type: "refusal"; + refusal: string; +}; +type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartInputAudio | ChatCompletionContentPartFile; +type FunctionDefinition = { + name: string; + description?: string; + parameters?: Record; + strict?: boolean | null; +}; +type ChatCompletionFunctionTool = { + type: "function"; + function: FunctionDefinition; +}; +type ChatCompletionCustomToolGrammarFormat = { + type: "grammar"; + grammar: { + definition: string; + syntax: "lark" | "regex"; + }; +}; +type ChatCompletionCustomToolTextFormat = { + type: "text"; +}; +type ChatCompletionCustomToolFormat = ChatCompletionCustomToolTextFormat | ChatCompletionCustomToolGrammarFormat; +type ChatCompletionCustomTool = { + type: "custom"; + custom: { + name: string; + description?: string; + format?: ChatCompletionCustomToolFormat; + }; +}; +type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool; +type ChatCompletionMessageFunctionToolCall = { + id: string; + type: "function"; + function: { + name: string; + /** JSON-encoded arguments string. */ + arguments: string; + }; +}; +type ChatCompletionMessageCustomToolCall = { + id: string; + type: "custom"; + custom: { + name: string; + input: string; + }; +}; +type ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall; +type ChatCompletionToolChoiceFunction = { + type: "function"; + function: { + name: string; + }; +}; +type ChatCompletionToolChoiceCustom = { + type: "custom"; + custom: { + name: string; + }; +}; +type ChatCompletionToolChoiceAllowedTools = { + type: "allowed_tools"; + allowed_tools: { + mode: "auto" | "required"; + tools: Array>; + }; +}; +type ChatCompletionToolChoiceOption = "none" | "auto" | "required" | ChatCompletionToolChoiceFunction | ChatCompletionToolChoiceCustom | ChatCompletionToolChoiceAllowedTools; +type DeveloperMessage = { + role: "developer"; + content: string | Array<{ + type: "text"; + text: string; + }>; + name?: string; +}; +type SystemMessage = { + role: "system"; + content: string | Array<{ + type: "text"; + text: string; + }>; + name?: string; +}; +/** + * Permissive merged content part used inside UserMessage arrays. + * + * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination + * inside nested array items does not correctly match different branches for + * different array elements, so the schema uses a single merged object. + */ +type UserMessageContentPart = { + type: "text" | "image_url" | "input_audio" | "file"; + text?: string; + image_url?: { + url?: string; + detail?: "auto" | "low" | "high"; + }; + input_audio?: { + data?: string; + format?: "wav" | "mp3"; + }; + file?: { + file_data?: string; + file_id?: string; + filename?: string; + }; +}; +type UserMessage = { + role: "user"; + content: string | Array; + name?: string; +}; +type AssistantMessageContentPart = { + type: "text" | "refusal"; + text?: string; + refusal?: string; +}; +type AssistantMessage = { + role: "assistant"; + content?: string | null | Array; + refusal?: string | null; + name?: string; + audio?: { + id: string; + }; + tool_calls?: Array; + function_call?: { + name: string; + arguments: string; + }; +}; +type ToolMessage = { + role: "tool"; + content: string | Array<{ + type: "text"; + text: string; + }>; + tool_call_id: string; +}; +type FunctionMessage = { + role: "function"; + content: string; + name: string; +}; +type ChatCompletionMessageParam = DeveloperMessage | SystemMessage | UserMessage | AssistantMessage | ToolMessage | FunctionMessage; +type ChatCompletionsResponseFormatText = { + type: "text"; +}; +type ChatCompletionsResponseFormatJSONObject = { + type: "json_object"; +}; +type ResponseFormatJSONSchema = { + type: "json_schema"; + json_schema: { + name: string; + description?: string; + schema?: Record; + strict?: boolean | null; + }; +}; +type ResponseFormat = ChatCompletionsResponseFormatText | ChatCompletionsResponseFormatJSONObject | ResponseFormatJSONSchema; +type ChatCompletionsStreamOptions = { + include_usage?: boolean; + include_obfuscation?: boolean; +}; +type PredictionContent = { + type: "content"; + content: string | Array<{ + type: "text"; + text: string; + }>; +}; +type AudioParams = { + voice: string | { + id: string; + }; + format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16"; +}; +type WebSearchUserLocation = { + type: "approximate"; + approximate: { + city?: string; + country?: string; + region?: string; + timezone?: string; + }; +}; +type WebSearchOptions = { + search_context_size?: "low" | "medium" | "high"; + user_location?: WebSearchUserLocation; +}; +type ChatTemplateKwargs = { + /** Whether to enable reasoning, enabled by default. */ + enable_thinking?: boolean; + /** If false, preserves reasoning context between turns. */ + clear_thinking?: boolean; +}; +/** Shared optional properties used by both Prompt and Messages input branches. */ +type ChatCompletionsCommonOptions = { + model?: string; + audio?: AudioParams; + frequency_penalty?: number | null; + logit_bias?: Record | null; + logprobs?: boolean | null; + top_logprobs?: number | null; + max_tokens?: number | null; + max_completion_tokens?: number | null; + metadata?: Record | null; + modalities?: Array<"text" | "audio"> | null; + n?: number | null; + parallel_tool_calls?: boolean; + prediction?: PredictionContent; + presence_penalty?: number | null; + reasoning_effort?: "low" | "medium" | "high" | null; + chat_template_kwargs?: ChatTemplateKwargs; + response_format?: ResponseFormat; + seed?: number | null; + service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; + stop?: string | Array | null; + store?: boolean | null; + stream?: boolean | null; + stream_options?: ChatCompletionsStreamOptions; + temperature?: number | null; + tool_choice?: ChatCompletionToolChoiceOption; + tools?: Array; + top_p?: number | null; + user?: string; + web_search_options?: WebSearchOptions; + function_call?: "none" | "auto" | { + name: string; + }; + functions?: Array; +}; +type PromptTokensDetails = { + cached_tokens?: number; + audio_tokens?: number; +}; +type CompletionTokensDetails = { + reasoning_tokens?: number; + audio_tokens?: number; + accepted_prediction_tokens?: number; + rejected_prediction_tokens?: number; +}; +type CompletionUsage = { + prompt_tokens: number; + completion_tokens: number; + total_tokens: number; + prompt_tokens_details?: PromptTokensDetails; + completion_tokens_details?: CompletionTokensDetails; +}; +type ChatCompletionTopLogprob = { + token: string; + logprob: number; + bytes: Array | null; +}; +type ChatCompletionTokenLogprob = { + token: string; + logprob: number; + bytes: Array | null; + top_logprobs: Array; +}; +type ChatCompletionAudio = { + id: string; + /** Base64 encoded audio bytes. */ + data: string; + expires_at: number; + transcript: string; +}; +type ChatCompletionUrlCitation = { + type: "url_citation"; + url_citation: { + url: string; + title: string; + start_index: number; + end_index: number; + }; +}; +type ChatCompletionResponseMessage = { + role: "assistant"; + content: string | null; + refusal: string | null; + annotations?: Array; + audio?: ChatCompletionAudio; + tool_calls?: Array; + function_call?: { + name: string; + arguments: string; + } | null; +}; +type ChatCompletionLogprobs = { + content: Array | null; + refusal?: Array | null; +}; +type ChatCompletionChoice = { + index: number; + message: ChatCompletionResponseMessage; + finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"; + logprobs: ChatCompletionLogprobs | null; +}; +type ChatCompletionsPromptInput = { + prompt: string; +} & ChatCompletionsCommonOptions; +type ChatCompletionsMessagesInput = { + messages: Array; +} & ChatCompletionsCommonOptions; +type ChatCompletionsOutput = { + id: string; + object: string; + created: number; + model: string; + choices: Array; + usage?: CompletionUsage; + system_fingerprint?: string | null; + service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; +}; +/** + * Workers AI support for OpenAI's Responses API + * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts + * + * It's a stripped down version from its source. + * It currently supports basic function calling, json mode and accepts images as input. + * + * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools. + * We plan to add those incrementally as model + platform capabilities evolve. + */ +type ResponsesInput = { + background?: boolean | null; + conversation?: string | ResponseConversationParam | null; + include?: Array | null; + input?: string | ResponseInput; + instructions?: string | null; + max_output_tokens?: number | null; + parallel_tool_calls?: boolean | null; + previous_response_id?: string | null; + prompt_cache_key?: string; + reasoning?: Reasoning | null; + safety_identifier?: string; + service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; + stream?: boolean | null; + stream_options?: StreamOptions | null; + temperature?: number | null; + text?: ResponseTextConfig; + tool_choice?: ToolChoiceOptions | ToolChoiceFunction; + tools?: Array; + top_p?: number | null; + truncation?: "auto" | "disabled" | null; +}; +type ResponsesOutput = { + id?: string; + created_at?: number; + output_text?: string; + error?: ResponseError | null; + incomplete_details?: ResponseIncompleteDetails | null; + instructions?: string | Array | null; + object?: "response"; + output?: Array; + parallel_tool_calls?: boolean; + temperature?: number | null; + tool_choice?: ToolChoiceOptions | ToolChoiceFunction; + tools?: Array; + top_p?: number | null; + max_output_tokens?: number | null; + previous_response_id?: string | null; + prompt?: ResponsePrompt | null; + reasoning?: Reasoning | null; + safety_identifier?: string; + service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; + status?: ResponseStatus; + text?: ResponseTextConfig; + truncation?: "auto" | "disabled" | null; + usage?: ResponseUsage; +}; +type EasyInputMessage = { + content: string | ResponseInputMessageContentList; + role: "user" | "assistant" | "system" | "developer"; + type?: "message"; +}; +type ResponsesFunctionTool = { + name: string; + parameters: { + [key: string]: unknown; + } | null; + strict: boolean | null; + type: "function"; + description?: string | null; +}; +type ResponseIncompleteDetails = { + reason?: "max_output_tokens" | "content_filter"; +}; +type ResponsePrompt = { + id: string; + variables?: { + [key: string]: string | ResponseInputText | ResponseInputImage; + } | null; + version?: string | null; +}; +type Reasoning = { + effort?: ReasoningEffort | null; + generate_summary?: "auto" | "concise" | "detailed" | null; + summary?: "auto" | "concise" | "detailed" | null; +}; +type ResponseContent = ResponseInputText | ResponseInputImage | ResponseOutputText | ResponseOutputRefusal | ResponseContentReasoningText; +type ResponseContentReasoningText = { + text: string; + type: "reasoning_text"; +}; +type ResponseConversationParam = { + id: string; +}; +type ResponseCreatedEvent = { + response: Response; + sequence_number: number; + type: "response.created"; +}; +type ResponseCustomToolCallOutput = { + call_id: string; + output: string | Array; + type: "custom_tool_call_output"; + id?: string; +}; +type ResponseError = { + code: "server_error" | "rate_limit_exceeded" | "invalid_prompt" | "vector_store_timeout" | "invalid_image" | "invalid_image_format" | "invalid_base64_image" | "invalid_image_url" | "image_too_large" | "image_too_small" | "image_parse_error" | "image_content_policy_violation" | "invalid_image_mode" | "image_file_too_large" | "unsupported_image_media_type" | "empty_image_file" | "failed_to_download_image" | "image_file_not_found"; + message: string; +}; +type ResponseErrorEvent = { + code: string | null; + message: string; + param: string | null; + sequence_number: number; + type: "error"; +}; +type ResponseFailedEvent = { + response: Response; + sequence_number: number; + type: "response.failed"; +}; +type ResponseFormatText = { + type: "text"; +}; +type ResponseFormatJSONObject = { + type: "json_object"; +}; +type ResponseFormatTextConfig = ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject; +type ResponseFormatTextJSONSchemaConfig = { + name: string; + schema: { + [key: string]: unknown; + }; + type: "json_schema"; + description?: string; + strict?: boolean | null; +}; +type ResponseFunctionCallArgumentsDeltaEvent = { + delta: string; + item_id: string; + output_index: number; + sequence_number: number; + type: "response.function_call_arguments.delta"; +}; +type ResponseFunctionCallArgumentsDoneEvent = { + arguments: string; + item_id: string; + name: string; + output_index: number; + sequence_number: number; + type: "response.function_call_arguments.done"; +}; +type ResponseFunctionCallOutputItem = ResponseInputTextContent | ResponseInputImageContent; +type ResponseFunctionCallOutputItemList = Array; +type ResponseFunctionToolCall = { + arguments: string; + call_id: string; + name: string; + type: "function_call"; + id?: string; + status?: "in_progress" | "completed" | "incomplete"; +}; +interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall { + id: string; +} +type ResponseFunctionToolCallOutputItem = { + id: string; + call_id: string; + output: string | Array; + type: "function_call_output"; + status?: "in_progress" | "completed" | "incomplete"; +}; +type ResponseIncludable = "message.input_image.image_url" | "message.output_text.logprobs"; +type ResponseIncompleteEvent = { + response: Response; + sequence_number: number; + type: "response.incomplete"; +}; +type ResponseInput = Array; +type ResponseInputContent = ResponseInputText | ResponseInputImage; +type ResponseInputImage = { + detail: "low" | "high" | "auto"; + type: "input_image"; + /** + * Base64 encoded image + */ + image_url?: string | null; +}; +type ResponseInputImageContent = { + type: "input_image"; + detail?: "low" | "high" | "auto" | null; + /** + * Base64 encoded image + */ + image_url?: string | null; +}; +type ResponseInputItem = EasyInputMessage | ResponseInputItemMessage | ResponseOutputMessage | ResponseFunctionToolCall | ResponseInputItemFunctionCallOutput | ResponseReasoningItem; +type ResponseInputItemFunctionCallOutput = { + call_id: string; + output: string | ResponseFunctionCallOutputItemList; + type: "function_call_output"; + id?: string | null; + status?: "in_progress" | "completed" | "incomplete" | null; +}; +type ResponseInputItemMessage = { + content: ResponseInputMessageContentList; + role: "user" | "system" | "developer"; + status?: "in_progress" | "completed" | "incomplete"; + type?: "message"; +}; +type ResponseInputMessageContentList = Array; +type ResponseInputMessageItem = { + id: string; + content: ResponseInputMessageContentList; + role: "user" | "system" | "developer"; + status?: "in_progress" | "completed" | "incomplete"; + type?: "message"; +}; +type ResponseInputText = { + text: string; + type: "input_text"; +}; +type ResponseInputTextContent = { + text: string; + type: "input_text"; +}; +type ResponseItem = ResponseInputMessageItem | ResponseOutputMessage | ResponseFunctionToolCallItem | ResponseFunctionToolCallOutputItem; +type ResponseOutputItem = ResponseOutputMessage | ResponseFunctionToolCall | ResponseReasoningItem; +type ResponseOutputItemAddedEvent = { + item: ResponseOutputItem; + output_index: number; + sequence_number: number; + type: "response.output_item.added"; +}; +type ResponseOutputItemDoneEvent = { + item: ResponseOutputItem; + output_index: number; + sequence_number: number; + type: "response.output_item.done"; +}; +type ResponseOutputMessage = { + id: string; + content: Array; + role: "assistant"; + status: "in_progress" | "completed" | "incomplete"; + type: "message"; +}; +type ResponseOutputRefusal = { + refusal: string; + type: "refusal"; +}; +type ResponseOutputText = { + text: string; + type: "output_text"; + logprobs?: Array; +}; +type ResponseReasoningItem = { + id: string; + summary: Array; + type: "reasoning"; + content?: Array; + encrypted_content?: string | null; + status?: "in_progress" | "completed" | "incomplete"; +}; +type ResponseReasoningSummaryItem = { + text: string; + type: "summary_text"; +}; +type ResponseReasoningContentItem = { + text: string; + type: "reasoning_text"; +}; +type ResponseReasoningTextDeltaEvent = { + content_index: number; + delta: string; + item_id: string; + output_index: number; + sequence_number: number; + type: "response.reasoning_text.delta"; +}; +type ResponseReasoningTextDoneEvent = { + content_index: number; + item_id: string; + output_index: number; + sequence_number: number; + text: string; + type: "response.reasoning_text.done"; +}; +type ResponseRefusalDeltaEvent = { + content_index: number; + delta: string; + item_id: string; + output_index: number; + sequence_number: number; + type: "response.refusal.delta"; +}; +type ResponseRefusalDoneEvent = { + content_index: number; + item_id: string; + output_index: number; + refusal: string; + sequence_number: number; + type: "response.refusal.done"; +}; +type ResponseStatus = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete"; +type ResponseStreamEvent = ResponseCompletedEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseReasoningTextDeltaEvent | ResponseReasoningTextDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent; +type ResponseCompletedEvent = { + response: Response; + sequence_number: number; + type: "response.completed"; +}; +type ResponseTextConfig = { + format?: ResponseFormatTextConfig; + verbosity?: "low" | "medium" | "high" | null; +}; +type ResponseTextDeltaEvent = { + content_index: number; + delta: string; + item_id: string; + logprobs: Array; + output_index: number; + sequence_number: number; + type: "response.output_text.delta"; +}; +type ResponseTextDoneEvent = { + content_index: number; + item_id: string; + logprobs: Array; + output_index: number; + sequence_number: number; + text: string; + type: "response.output_text.done"; +}; +type Logprob = { + token: string; + logprob: number; + top_logprobs?: Array; +}; +type TopLogprob = { + token?: string; + logprob?: number; +}; +type ResponseUsage = { + input_tokens: number; + output_tokens: number; + total_tokens: number; +}; +type Tool = ResponsesFunctionTool; +type ToolChoiceFunction = { + name: string; + type: "function"; +}; +type ToolChoiceOptions = "none"; +type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null; +type StreamOptions = { + include_obfuscation?: boolean; +}; +/** Marks keys from T that aren't in U as optional never */ +type Without = { + [P in Exclude]?: never; +}; +/** Either T or U, but not both (mutually exclusive) */ +type XOR = (T & Without) | (U & Without); +type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = { + text: string | string[]; + /** + * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. + */ + pooling?: "mean" | "cls"; +} | { + /** + * Batch of the embeddings requests to run using async-queue + */ + requests: { + text: string | string[]; + /** + * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. + */ + pooling?: "mean" | "cls"; + }[]; +}; +type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = { + shape?: number[]; + /** + * Embeddings of the requested text values + */ + data?: number[][]; + /** + * The pooling method used in the embedding process. + */ + pooling?: "mean" | "cls"; +} | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse; +interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 { + inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input; + postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output; +} +type Ai_Cf_Openai_Whisper_Input = string | { + /** + * An array of integers that represent the audio data constrained to 8-bit unsigned integer values + */ + audio: number[]; +}; +interface Ai_Cf_Openai_Whisper_Output { + /** + * The transcription + */ + text: string; + word_count?: number; + words?: { + word?: string; + /** + * The second this word begins in the recording + */ + start?: number; + /** + * The ending second when the word completes + */ + end?: number; + }[]; + vtt?: string; +} +declare abstract class Base_Ai_Cf_Openai_Whisper { + inputs: Ai_Cf_Openai_Whisper_Input; + postProcessedOutputs: Ai_Cf_Openai_Whisper_Output; +} +type Ai_Cf_Meta_M2M100_1_2B_Input = { + /** + * The text to be translated + */ + text: string; + /** + * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified + */ + source_lang?: string; + /** + * The language code to translate the text into (e.g., 'es' for Spanish) + */ + target_lang: string; +} | { + /** + * Batch of the embeddings requests to run using async-queue + */ + requests: { + /** + * The text to be translated + */ + text: string; + /** + * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified + */ + source_lang?: string; + /** + * The language code to translate the text into (e.g., 'es' for Spanish) + */ + target_lang: string; + }[]; +}; +type Ai_Cf_Meta_M2M100_1_2B_Output = { + /** + * The translated text in the target language + */ + translated_text?: string; +} | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse; +interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B { + inputs: Ai_Cf_Meta_M2M100_1_2B_Input; + postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output; +} +type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = { + text: string | string[]; + /** + * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. + */ + pooling?: "mean" | "cls"; +} | { + /** + * Batch of the embeddings requests to run using async-queue + */ + requests: { + text: string | string[]; + /** + * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. + */ + pooling?: "mean" | "cls"; + }[]; +}; +type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = { + shape?: number[]; + /** + * Embeddings of the requested text values + */ + data?: number[][]; + /** + * The pooling method used in the embedding process. + */ + pooling?: "mean" | "cls"; +} | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse; +interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 { + inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input; + postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output; +} +type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = { + text: string | string[]; + /** + * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. + */ + pooling?: "mean" | "cls"; +} | { + /** + * Batch of the embeddings requests to run using async-queue + */ + requests: { + text: string | string[]; + /** + * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. + */ + pooling?: "mean" | "cls"; + }[]; +}; +type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = { + shape?: number[]; + /** + * Embeddings of the requested text values + */ + data?: number[][]; + /** + * The pooling method used in the embedding process. + */ + pooling?: "mean" | "cls"; +} | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse; +interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 { + inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input; + postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output; +} +type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | { + /** + * The input text prompt for the model to generate a response. + */ + prompt?: string; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; + image: number[] | (string & NonNullable); + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; +}; +interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output { + description?: string; +} +declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M { + inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input; + postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output; +} +type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | { + /** + * An array of integers that represent the audio data constrained to 8-bit unsigned integer values + */ + audio: number[]; +}; +interface Ai_Cf_Openai_Whisper_Tiny_En_Output { + /** + * The transcription + */ + text: string; + word_count?: number; + words?: { + word?: string; + /** + * The second this word begins in the recording + */ + start?: number; + /** + * The ending second when the word completes + */ + end?: number; + }[]; + vtt?: string; +} +declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En { + inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input; + postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output; +} +interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input { + audio: string | { + body?: object; + contentType?: string; + }; + /** + * Supported tasks are 'translate' or 'transcribe'. + */ + task?: string; + /** + * The language of the audio being transcribed or translated. + */ + language?: string; + /** + * Preprocess the audio with a voice activity detection model. + */ + vad_filter?: boolean; + /** + * A text prompt to help provide context to the model on the contents of the audio. + */ + initial_prompt?: string; + /** + * The prefix appended to the beginning of the output of the transcription and can guide the transcription result. + */ + prefix?: string; + /** + * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed. + */ + beam_size?: number; + /** + * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops. + */ + condition_on_previous_text?: boolean; + /** + * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped. + */ + no_speech_threshold?: number; + /** + * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text. + */ + compression_ratio_threshold?: number; + /** + * Threshold for filtering out segments with low average log probability, indicating low confidence. + */ + log_prob_threshold?: number; + /** + * Optional threshold (in seconds) to skip silent periods that may cause hallucinations. + */ + hallucination_silence_threshold?: number; +} +interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output { + transcription_info?: { + /** + * The language of the audio being transcribed or translated. + */ + language?: string; + /** + * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1. + */ + language_probability?: number; + /** + * The total duration of the original audio file, in seconds. + */ + duration?: number; + /** + * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds. + */ + duration_after_vad?: number; + }; + /** + * The complete transcription of the audio. + */ + text: string; + /** + * The total number of words in the transcription. + */ + word_count?: number; + segments?: { + /** + * The starting time of the segment within the audio, in seconds. + */ + start?: number; + /** + * The ending time of the segment within the audio, in seconds. + */ + end?: number; + /** + * The transcription of the segment. + */ + text?: string; + /** + * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs. + */ + temperature?: number; + /** + * The average log probability of the predictions for the words in this segment, indicating overall confidence. + */ + avg_logprob?: number; + /** + * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process. + */ + compression_ratio?: number; + /** + * The probability that the segment contains no speech, represented as a decimal between 0 and 1. + */ + no_speech_prob?: number; + words?: { + /** + * The individual word transcribed from the audio. + */ + word?: string; + /** + * The starting time of the word within the audio, in seconds. + */ + start?: number; + /** + * The ending time of the word within the audio, in seconds. + */ + end?: number; + }[]; + }[]; + /** + * The transcription in WebVTT format, which includes timing and text information for use in subtitles. + */ + vtt?: string; +} +declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo { + inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input; + postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output; +} +type Ai_Cf_Baai_Bge_M3_Input = Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts | Ai_Cf_Baai_Bge_M3_Input_Embedding | { + /** + * Batch of the embeddings requests to run using async-queue + */ + requests: (Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1)[]; +}; +interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts { + /** + * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts + */ + query?: string; + /** + * List of provided contexts. Note that the index in this array is important, as the response will refer to it. + */ + contexts: { + /** + * One of the provided context content + */ + text?: string; + }[]; + /** + * When provided with too long context should the model error out or truncate the context to fit? + */ + truncate_inputs?: boolean; +} +interface Ai_Cf_Baai_Bge_M3_Input_Embedding { + text: string | string[]; + /** + * When provided with too long context should the model error out or truncate the context to fit? + */ + truncate_inputs?: boolean; +} +interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 { + /** + * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts + */ + query?: string; + /** + * List of provided contexts. Note that the index in this array is important, as the response will refer to it. + */ + contexts: { + /** + * One of the provided context content + */ + text?: string; + }[]; + /** + * When provided with too long context should the model error out or truncate the context to fit? + */ + truncate_inputs?: boolean; +} +interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 { + text: string | string[]; + /** + * When provided with too long context should the model error out or truncate the context to fit? + */ + truncate_inputs?: boolean; +} +type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Output_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Output_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse; +interface Ai_Cf_Baai_Bge_M3_Output_Query { + response?: { + /** + * Index of the context in the request + */ + id?: number; + /** + * Score of the context under the index. + */ + score?: number; + }[]; +} +interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts { + response?: number[][]; + shape?: number[]; + /** + * The pooling method used in the embedding process. + */ + pooling?: "mean" | "cls"; +} +interface Ai_Cf_Baai_Bge_M3_Output_Embedding { + shape?: number[]; + /** + * Embeddings of the requested text values + */ + data?: number[][]; + /** + * The pooling method used in the embedding process. + */ + pooling?: "mean" | "cls"; +} +interface Ai_Cf_Baai_Bge_M3_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Baai_Bge_M3 { + inputs: Ai_Cf_Baai_Bge_M3_Input; + postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output; +} +interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input { + /** + * A text description of the image you want to generate. + */ + prompt: string; + /** + * The number of diffusion steps; higher values can improve quality but take longer. + */ + steps?: number; +} +interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output { + /** + * The generated image in Base64 format. + */ + image?: string; +} +declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell { + inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input; + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output; +} +type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages; +interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + image?: number[] | (string & NonNullable); + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; +} +interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role?: string; + /** + * The tool call id. If you don't know what to put here you can fall back to 000000001 + */ + tool_call_id?: string; + content?: string | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }[] | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }; + }[]; + image?: number[] | (string & NonNullable); + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + /** + * If true, the response will be streamed back incrementally. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = { + /** + * The generated text response from the model + */ + response?: string; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + /** + * The name of the tool to be called + */ + name?: string; + }[]; +}; +declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct { + inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input; + postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output; +} +type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input = Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch; +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; + response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role: string; + content: string | { + /** + * Type of the content (text) + */ + type?: string; + /** + * Text content + */ + text?: string; + }[]; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch { + requests?: { + /** + * User-supplied reference. This field will be present in the response as well it can be used to reference the request and response. It's NOT validated to be unique. + */ + external_reference?: string; + /** + * Prompt for the text generation model + */ + prompt?: string; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; + response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2; + }[]; +} +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = { + /** + * The generated text response from the model + */ + response: string; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + /** + * The name of the tool to be called + */ + name?: string; + }[]; +} | string | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse; +interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast { + inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input; + postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output; +} +interface Ai_Cf_Meta_Llama_Guard_3_8B_Input { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender must alternate between 'user' and 'assistant'. + */ + role: "user" | "assistant"; + /** + * The content of the message as a string. + */ + content: string; + }[]; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Dictate the output format of the generated response. + */ + response_format?: { + /** + * Set to json_object to process and output generated text as JSON. + */ + type?: string; + }; +} +interface Ai_Cf_Meta_Llama_Guard_3_8B_Output { + response?: string | { + /** + * Whether the conversation is safe or not. + */ + safe?: boolean; + /** + * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe. + */ + categories?: string[]; + }; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; +} +declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B { + inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input; + postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output; +} +interface Ai_Cf_Baai_Bge_Reranker_Base_Input { + /** + * A query you wish to perform against the provided contexts. + */ + /** + * Number of returned results starting with the best score. + */ + top_k?: number; + /** + * List of provided contexts. Note that the index in this array is important, as the response will refer to it. + */ + contexts: { + /** + * One of the provided context content + */ + text?: string; + }[]; +} +interface Ai_Cf_Baai_Bge_Reranker_Base_Output { + response?: { + /** + * Index of the context in the request + */ + id?: number; + /** + * Score of the context under the index. + */ + score?: number; + }[]; +} +declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base { + inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input; + postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output; +} +type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages; +interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; + response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role: string; + /** + * The content of the message as a string. + */ + content: string; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = { + /** + * The generated text response from the model + */ + response: string; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + /** + * The name of the tool to be called + */ + name?: string; + }[]; +}; +declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct { + inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input; + postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output; +} +type Ai_Cf_Qwen_Qwq_32B_Input = Ai_Cf_Qwen_Qwq_32B_Prompt | Ai_Cf_Qwen_Qwq_32B_Messages; +interface Ai_Cf_Qwen_Qwq_32B_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * JSON schema that should be fulfilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwq_32B_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role?: string; + /** + * The tool call id. If you don't know what to put here you can fall back to 000000001 + */ + tool_call_id?: string; + content?: string | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }[] | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + /** + * JSON schema that should be fufilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +type Ai_Cf_Qwen_Qwq_32B_Output = { + /** + * The generated text response from the model + */ + response: string; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + /** + * The name of the tool to be called + */ + name?: string; + }[]; +}; +declare abstract class Base_Ai_Cf_Qwen_Qwq_32B { + inputs: Ai_Cf_Qwen_Qwq_32B_Input; + postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output; +} +type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages; +interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * JSON schema that should be fulfilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role?: string; + /** + * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001 + */ + tool_call_id?: string; + content?: string | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }[] | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + /** + * JSON schema that should be fufilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = { + /** + * The generated text response from the model + */ + response: string; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + /** + * The name of the tool to be called + */ + name?: string; + }[]; +}; +declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct { + inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input; + postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output; +} +type Ai_Cf_Google_Gemma_3_12B_It_Input = Ai_Cf_Google_Gemma_3_12B_It_Prompt | Ai_Cf_Google_Gemma_3_12B_It_Messages; +interface Ai_Cf_Google_Gemma_3_12B_It_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * JSON schema that should be fufilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Google_Gemma_3_12B_It_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role?: string; + content?: string | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }[]; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + /** + * JSON schema that should be fufilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +type Ai_Cf_Google_Gemma_3_12B_It_Output = { + /** + * The generated text response from the model + */ + response: string; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + /** + * The name of the tool to be called + */ + name?: string; + }[]; +}; +declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It { + inputs: Ai_Cf_Google_Gemma_3_12B_It_Input; + postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output; +} +type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch; +interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * JSON schema that should be fulfilled for the response. + */ + guided_json?: object; + response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role?: string; + /** + * The tool call id. If you don't know what to put here you can fall back to 000000001 + */ + tool_call_id?: string; + content?: string | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }[] | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; + /** + * JSON schema that should be fufilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch { + requests: (Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner)[]; +} +interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * JSON schema that should be fulfilled for the response. + */ + guided_json?: object; + response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role?: string; + /** + * The tool call id. If you don't know what to put here you can fall back to 000000001 + */ + tool_call_id?: string; + content?: string | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }[] | { + /** + * Type of the content provided + */ + type?: string; + text?: string; + image_url?: { + /** + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted + */ + url?: string; + }; + }; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; + /** + * JSON schema that should be fufilled for the response. + */ + guided_json?: object; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = { + /** + * The generated text response from the model + */ + response: string; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * An array of tool calls requests made during the response generation + */ + tool_calls?: { + /** + * The tool call id. + */ + id?: string; + /** + * Specifies the type of tool (e.g., 'function'). + */ + type?: string; + /** + * Details of the function tool. + */ + function?: { + /** + * The name of the tool to be called + */ + name?: string; + /** + * The arguments passed to be passed to the tool call request + */ + arguments?: object; + }; + }[]; +}; +declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct { + inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input; + postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output; +} +type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch; +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; + response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role: string; + content: string | { + /** + * Type of the content (text) + */ + type?: string; + /** + * Text content + */ + text?: string; + }[]; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch { + requests: (Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1)[]; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; + response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role: string; + content: string | { + /** + * Type of the content (text) + */ + type?: string; + /** + * Text content + */ + text?: string; + }[]; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response | string | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse; +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response { + /** + * Unique identifier for the completion + */ + id?: string; + /** + * Object type identifier + */ + object?: "chat.completion"; + /** + * Unix timestamp of when the completion was created + */ + created?: number; + /** + * Model used for the completion + */ + model?: string; + /** + * List of completion choices + */ + choices?: { + /** + * Index of the choice in the list + */ + index?: number; + /** + * The message generated by the model + */ + message?: { + /** + * Role of the message author + */ + role: string; + /** + * The content of the message + */ + content: string; + /** + * Internal reasoning content (if available) + */ + reasoning_content?: string; + /** + * Tool calls made by the assistant + */ + tool_calls?: { + /** + * Unique identifier for the tool call + */ + id: string; + /** + * Type of tool call + */ + type: "function"; + function: { + /** + * Name of the function to call + */ + name: string; + /** + * JSON string of arguments for the function + */ + arguments: string; + }; + }[]; + }; + /** + * Reason why the model stopped generating + */ + finish_reason?: string; + /** + * Stop reason (may be null) + */ + stop_reason?: string | null; + /** + * Log probabilities (if requested) + */ + logprobs?: {} | null; + }[]; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * Log probabilities for the prompt (if requested) + */ + prompt_logprobs?: {} | null; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response { + /** + * Unique identifier for the completion + */ + id?: string; + /** + * Object type identifier + */ + object?: "text_completion"; + /** + * Unix timestamp of when the completion was created + */ + created?: number; + /** + * Model used for the completion + */ + model?: string; + /** + * List of completion choices + */ + choices?: { + /** + * Index of the choice in the list + */ + index: number; + /** + * The generated text completion + */ + text: string; + /** + * Reason why the model stopped generating + */ + finish_reason: string; + /** + * Stop reason (may be null) + */ + stop_reason?: string | null; + /** + * Log probabilities (if requested) + */ + logprobs?: {} | null; + /** + * Log probabilities for the prompt (if requested) + */ + prompt_logprobs?: {} | null; + }[]; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; +} +interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 { + inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input; + postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output; +} +interface Ai_Cf_Deepgram_Nova_3_Input { + audio: { + body: object; + contentType: string; + }; + /** + * Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param. + */ + custom_topic_mode?: "extended" | "strict"; + /** + * Custom topics you want the model to detect within your input audio or text if present Submit up to 100 + */ + custom_topic?: string; + /** + * Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom_intents param + */ + custom_intent_mode?: "extended" | "strict"; + /** + * Custom intents you want the model to detect within your input audio if present + */ + custom_intent?: string; + /** + * Identifies and extracts key entities from content in submitted audio + */ + detect_entities?: boolean; + /** + * Identifies the dominant language spoken in submitted audio + */ + detect_language?: boolean; + /** + * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0 + */ + diarize?: boolean; + /** + * Identify and extract key entities from content in submitted audio + */ + dictation?: boolean; + /** + * Specify the expected encoding of your submitted audio + */ + encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729"; + /** + * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing + */ + extra?: string; + /** + * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um' + */ + filler_words?: boolean; + /** + * Key term prompting can boost or suppress specialized terminology and brands. + */ + keyterm?: string; + /** + * Keywords can boost or suppress specialized terminology and brands. + */ + keywords?: string; + /** + * The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available. + */ + language?: string; + /** + * Spoken measurements will be converted to their corresponding abbreviations. + */ + measurements?: boolean; + /** + * Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip. + */ + mip_opt_out?: boolean; + /** + * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio + */ + mode?: "general" | "medical" | "finance"; + /** + * Transcribe each audio channel independently. + */ + multichannel?: boolean; + /** + * Numerals converts numbers from written format to numerical format. + */ + numerals?: boolean; + /** + * Splits audio into paragraphs to improve transcript readability. + */ + paragraphs?: boolean; + /** + * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely. + */ + profanity_filter?: boolean; + /** + * Add punctuation and capitalization to the transcript. + */ + punctuate?: boolean; + /** + * Redaction removes sensitive information from your transcripts. + */ + redact?: string; + /** + * Search for terms or phrases in submitted audio and replaces them. + */ + replace?: string; + /** + * Search for terms or phrases in submitted audio. + */ + search?: string; + /** + * Recognizes the sentiment throughout a transcript or text. + */ + sentiment?: boolean; + /** + * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability. + */ + smart_format?: boolean; + /** + * Detect topics throughout a transcript or text. + */ + topics?: boolean; + /** + * Segments speech into meaningful semantic units. + */ + utterances?: boolean; + /** + * Seconds to wait before detecting a pause between words in submitted audio. + */ + utt_split?: number; + /** + * The number of channels in the submitted audio + */ + channels?: number; + /** + * Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets. + */ + interim_results?: boolean; + /** + * Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing + */ + endpointing?: string; + /** + * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets. + */ + vad_events?: boolean; + /** + * Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results. Note: Supported only for webosockets. + */ + utterance_end_ms?: boolean; +} +interface Ai_Cf_Deepgram_Nova_3_Output { + results?: { + channels?: { + alternatives?: { + confidence?: number; + transcript?: string; + words?: { + confidence?: number; + end?: number; + start?: number; + word?: string; + }[]; + }[]; + }[]; + summary?: { + result?: string; + short?: string; + }; + sentiments?: { + segments?: { + text?: string; + start_word?: number; + end_word?: number; + sentiment?: string; + sentiment_score?: number; + }[]; + average?: { + sentiment?: string; + sentiment_score?: number; + }; + }; + }; +} +declare abstract class Base_Ai_Cf_Deepgram_Nova_3 { + inputs: Ai_Cf_Deepgram_Nova_3_Input; + postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output; +} +interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input { + queries?: string | string[]; + /** + * Optional instruction for the task + */ + instruction?: string; + documents?: string | string[]; + text?: string | string[]; +} +interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output { + data?: number[][]; + shape?: number[]; +} +declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B { + inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input; + postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output; +} +type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = { + /** + * readable stream with audio data and content-type specified for that data + */ + audio: { + body: object; + contentType: string; + }; + /** + * type of data PCM data that's sent to the inference server as raw array + */ + dtype?: "uint8" | "float32" | "float64"; +} | { + /** + * base64 encoded audio data + */ + audio: string; + /** + * type of data PCM data that's sent to the inference server as raw array + */ + dtype?: "uint8" | "float32" | "float64"; +}; +interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output { + /** + * if true, end-of-turn was detected + */ + is_complete?: boolean; + /** + * probability of the end-of-turn detection + */ + probability?: number; +} +declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 { + inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input; + postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output; +} +declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B { + inputs: XOR; + postProcessedOutputs: XOR; +} +declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B { + inputs: XOR; + postProcessedOutputs: XOR; +} +interface Ai_Cf_Leonardo_Phoenix_1_0_Input { + /** + * A text description of the image you want to generate. + */ + prompt: string; + /** + * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt + */ + guidance?: number; + /** + * Random seed for reproducibility of the image generation + */ + seed?: number; + /** + * The height of the generated image in pixels + */ + height?: number; + /** + * The width of the generated image in pixels + */ + width?: number; + /** + * The number of diffusion steps; higher values can improve quality but take longer + */ + num_steps?: number; + /** + * Specify what to exclude from the generated images + */ + negative_prompt?: string; +} +/** + * The generated image in JPEG format + */ +type Ai_Cf_Leonardo_Phoenix_1_0_Output = string; +declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 { + inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input; + postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output; +} +interface Ai_Cf_Leonardo_Lucid_Origin_Input { + /** + * A text description of the image you want to generate. + */ + prompt: string; + /** + * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt + */ + guidance?: number; + /** + * Random seed for reproducibility of the image generation + */ + seed?: number; + /** + * The height of the generated image in pixels + */ + height?: number; + /** + * The width of the generated image in pixels + */ + width?: number; + /** + * The number of diffusion steps; higher values can improve quality but take longer + */ + num_steps?: number; + /** + * The number of diffusion steps; higher values can improve quality but take longer + */ + steps?: number; +} +interface Ai_Cf_Leonardo_Lucid_Origin_Output { + /** + * The generated image in Base64 format. + */ + image?: string; +} +declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin { + inputs: Ai_Cf_Leonardo_Lucid_Origin_Input; + postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output; +} +interface Ai_Cf_Deepgram_Aura_1_Input { + /** + * Speaker used to produce the audio. + */ + speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella"; + /** + * Encoding of the output audio. + */ + encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac"; + /** + * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.. + */ + container?: "none" | "wav" | "ogg"; + /** + * The text content to be converted to speech + */ + text: string; + /** + * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable + */ + sample_rate?: number; + /** + * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type. + */ + bit_rate?: number; +} +/** + * The generated audio in MP3 format + */ +type Ai_Cf_Deepgram_Aura_1_Output = string; +declare abstract class Base_Ai_Cf_Deepgram_Aura_1 { + inputs: Ai_Cf_Deepgram_Aura_1_Input; + postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output; +} +interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input { + /** + * Input text to translate. Can be a single string or a list of strings. + */ + text: string | string[]; + /** + * Target langauge to translate to + */ + target_language: "asm_Beng" | "awa_Deva" | "ben_Beng" | "bho_Deva" | "brx_Deva" | "doi_Deva" | "eng_Latn" | "gom_Deva" | "gon_Deva" | "guj_Gujr" | "hin_Deva" | "hne_Deva" | "kan_Knda" | "kas_Arab" | "kas_Deva" | "kha_Latn" | "lus_Latn" | "mag_Deva" | "mai_Deva" | "mal_Mlym" | "mar_Deva" | "mni_Beng" | "mni_Mtei" | "npi_Deva" | "ory_Orya" | "pan_Guru" | "san_Deva" | "sat_Olck" | "snd_Arab" | "snd_Deva" | "tam_Taml" | "tel_Telu" | "urd_Arab" | "unr_Deva"; +} +interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output { + /** + * Translated texts + */ + translations: string[]; +} +declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B { + inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input; + postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output; +} +type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch; +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; + response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role: string; + content: string | { + /** + * Type of the content (text) + */ + type?: string; + /** + * Text content + */ + text?: string; + }[]; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch { + requests: (Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1)[]; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 { + /** + * The input text prompt for the model to generate a response. + */ + prompt: string; + /** + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + */ + lora?: string; + response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 { + /** + * An array of message objects representing the conversation history. + */ + messages: { + /** + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). + */ + role: string; + content: string | { + /** + * Type of the content (text) + */ + type?: string; + /** + * Text content + */ + text?: string; + }[]; + }[]; + functions?: { + name: string; + code: string; + }[]; + /** + * A list of tools available for the assistant to use. + */ + tools?: ({ + /** + * The name of the tool. More descriptive the better. + */ + name: string; + /** + * A brief description of what the tool does. + */ + description: string; + /** + * Schema defining the parameters accepted by the tool. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + } | { + /** + * Specifies the type of tool (e.g., 'function'). + */ + type: string; + /** + * Details of the function tool. + */ + function: { + /** + * The name of the function. + */ + name: string; + /** + * A brief description of what the function does. + */ + description: string; + /** + * Schema defining the parameters accepted by the function. + */ + parameters: { + /** + * The type of the parameters object (usually 'object'). + */ + type: string; + /** + * List of required parameter names. + */ + required?: string[]; + /** + * Definitions of each parameter. + */ + properties: { + [k: string]: { + /** + * The data type of the parameter. + */ + type: string; + /** + * A description of the expected parameter. + */ + description: string; + }; + }; + }; + }; + })[]; + response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3; + /** + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. + */ + raw?: boolean; + /** + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. + */ + stream?: boolean; + /** + * The maximum number of tokens to generate in the response. + */ + max_tokens?: number; + /** + * Controls the randomness of the output; higher values produce more random results. + */ + temperature?: number; + /** + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. + */ + top_p?: number; + /** + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. + */ + top_k?: number; + /** + * Random seed for reproducibility of the generation. + */ + seed?: number; + /** + * Penalty for repeated tokens; higher values discourage repetition. + */ + repetition_penalty?: number; + /** + * Decreases the likelihood of the model repeating the same lines verbatim. + */ + frequency_penalty?: number; + /** + * Increases the likelihood of the model introducing new topics. + */ + presence_penalty?: number; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 { + type?: "json_object" | "json_schema"; + json_schema?: unknown; +} +type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response | string | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse; +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response { + /** + * Unique identifier for the completion + */ + id?: string; + /** + * Object type identifier + */ + object?: "chat.completion"; + /** + * Unix timestamp of when the completion was created + */ + created?: number; + /** + * Model used for the completion + */ + model?: string; + /** + * List of completion choices + */ + choices?: { + /** + * Index of the choice in the list + */ + index?: number; + /** + * The message generated by the model + */ + message?: { + /** + * Role of the message author + */ + role: string; + /** + * The content of the message + */ + content: string; + /** + * Internal reasoning content (if available) + */ + reasoning_content?: string; + /** + * Tool calls made by the assistant + */ + tool_calls?: { + /** + * Unique identifier for the tool call + */ + id: string; + /** + * Type of tool call + */ + type: "function"; + function: { + /** + * Name of the function to call + */ + name: string; + /** + * JSON string of arguments for the function + */ + arguments: string; + }; + }[]; + }; + /** + * Reason why the model stopped generating + */ + finish_reason?: string; + /** + * Stop reason (may be null) + */ + stop_reason?: string | null; + /** + * Log probabilities (if requested) + */ + logprobs?: {} | null; + }[]; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; + /** + * Log probabilities for the prompt (if requested) + */ + prompt_logprobs?: {} | null; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response { + /** + * Unique identifier for the completion + */ + id?: string; + /** + * Object type identifier + */ + object?: "text_completion"; + /** + * Unix timestamp of when the completion was created + */ + created?: number; + /** + * Model used for the completion + */ + model?: string; + /** + * List of completion choices + */ + choices?: { + /** + * Index of the choice in the list + */ + index: number; + /** + * The generated text completion + */ + text: string; + /** + * Reason why the model stopped generating + */ + finish_reason: string; + /** + * Stop reason (may be null) + */ + stop_reason?: string | null; + /** + * Log probabilities (if requested) + */ + logprobs?: {} | null; + /** + * Log probabilities for the prompt (if requested) + */ + prompt_logprobs?: {} | null; + }[]; + /** + * Usage statistics for the inference request + */ + usage?: { + /** + * Total number of tokens in input + */ + prompt_tokens?: number; + /** + * Total number of tokens in output + */ + completion_tokens?: number; + /** + * Total number of input and output tokens + */ + total_tokens?: number; + }; +} +interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse { + /** + * The async request id that can be used to obtain the results. + */ + request_id?: string; +} +declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It { + inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input; + postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output; +} +interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input { + /** + * Input text to embed. Can be a single string or a list of strings. + */ + text: string | string[]; +} +interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output { + /** + * Embedding vectors, where each vector is a list of floats. + */ + data: number[][]; + /** + * Shape of the embedding data as [number_of_embeddings, embedding_dimension]. + * + * @minItems 2 + * @maxItems 2 + */ + shape: [ + number, + number + ]; +} +declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B { + inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input; + postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output; +} +interface Ai_Cf_Deepgram_Flux_Input { + /** + * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM. + */ + encoding: "linear16"; + /** + * Sample rate of the audio stream in Hz. + */ + sample_rate: string; + /** + * End-of-turn confidence required to fire an eager end-of-turn event. When set, enables EagerEndOfTurn and TurnResumed events. Valid Values 0.3 - 0.9. + */ + eager_eot_threshold?: string; + /** + * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9. + */ + eot_threshold?: string; + /** + * A turn will be finished when this much time has passed after speech, regardless of EOT confidence. + */ + eot_timeout_ms?: string; + /** + * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms. + */ + keyterm?: string; + /** + * Opts out requests from the Deepgram Model Improvement Program. Refer to Deepgram Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ + mip_opt_out?: "true" | "false"; + /** + * Label your requests for the purpose of identification during usage reporting + */ + tag?: string; +} +/** + * Output will be returned as websocket messages. + */ +interface Ai_Cf_Deepgram_Flux_Output { + /** + * The unique identifier of the request (uuid) + */ + request_id?: string; + /** + * Starts at 0 and increments for each message the server sends to the client. + */ + sequence_id?: number; + /** + * The type of event being reported. + */ + event?: "Update" | "StartOfTurn" | "EagerEndOfTurn" | "TurnResumed" | "EndOfTurn"; + /** + * The index of the current turn + */ + turn_index?: number; + /** + * Start time in seconds of the audio range that was transcribed + */ + audio_window_start?: number; + /** + * End time in seconds of the audio range that was transcribed + */ + audio_window_end?: number; + /** + * Text that was said over the course of the current turn + */ + transcript?: string; + /** + * The words in the transcript + */ + words?: { + /** + * The individual punctuated, properly-cased word from the transcript + */ + word: string; + /** + * Confidence that this word was transcribed correctly + */ + confidence: number; + }[]; + /** + * Confidence that no more speech is coming in this turn + */ + end_of_turn_confidence?: number; +} +declare abstract class Base_Ai_Cf_Deepgram_Flux { + inputs: Ai_Cf_Deepgram_Flux_Input; + postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output; +} +interface Ai_Cf_Deepgram_Aura_2_En_Input { + /** + * Speaker used to produce the audio. + */ + speaker?: "amalthea" | "andromeda" | "apollo" | "arcas" | "aries" | "asteria" | "athena" | "atlas" | "aurora" | "callista" | "cora" | "cordelia" | "delia" | "draco" | "electra" | "harmonia" | "helena" | "hera" | "hermes" | "hyperion" | "iris" | "janus" | "juno" | "jupiter" | "luna" | "mars" | "minerva" | "neptune" | "odysseus" | "ophelia" | "orion" | "orpheus" | "pandora" | "phoebe" | "pluto" | "saturn" | "thalia" | "theia" | "vesta" | "zeus"; + /** + * Encoding of the output audio. + */ + encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac"; + /** + * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.. + */ + container?: "none" | "wav" | "ogg"; + /** + * The text content to be converted to speech + */ + text: string; + /** + * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable + */ + sample_rate?: number; + /** + * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type. + */ + bit_rate?: number; +} +/** + * The generated audio in MP3 format + */ +type Ai_Cf_Deepgram_Aura_2_En_Output = string; +declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En { + inputs: Ai_Cf_Deepgram_Aura_2_En_Input; + postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output; +} +interface Ai_Cf_Deepgram_Aura_2_Es_Input { + /** + * Speaker used to produce the audio. + */ + speaker?: "sirio" | "nestor" | "carina" | "celeste" | "alvaro" | "diana" | "aquila" | "selena" | "estrella" | "javier"; + /** + * Encoding of the output audio. + */ + encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac"; + /** + * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.. + */ + container?: "none" | "wav" | "ogg"; + /** + * The text content to be converted to speech + */ + text: string; + /** + * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable + */ + sample_rate?: number; + /** + * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type. + */ + bit_rate?: number; +} +/** + * The generated audio in MP3 format + */ +type Ai_Cf_Deepgram_Aura_2_Es_Output = string; +declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es { + inputs: Ai_Cf_Deepgram_Aura_2_Es_Input; + postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output; +} +interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input { + multipart: { + body?: object; + contentType?: string; + }; +} +interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output { + /** + * Generated image as Base64 string. + */ + image?: string; +} +declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev { + inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input; + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output; +} +interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input { + multipart: { + body?: object; + contentType?: string; + }; +} +interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output { + /** + * Generated image as Base64 string. + */ + image?: string; +} +declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B { + inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input; + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output; +} +interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input { + multipart: { + body?: object; + contentType?: string; + }; +} +interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output { + /** + * Generated image as Base64 string. + */ + image?: string; +} +declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B { + inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input; + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output; +} +declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash { + inputs: ChatCompletionsInput; + postProcessedOutputs: ChatCompletionsOutput; +} +declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 { + inputs: ChatCompletionsInput; + postProcessedOutputs: ChatCompletionsOutput; +} +declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B { + inputs: ChatCompletionsInput; + postProcessedOutputs: ChatCompletionsOutput; +} +declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT { + inputs: ChatCompletionsInput; + postProcessedOutputs: ChatCompletionsOutput; +} +interface AiModels { + "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification; + "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage; + "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage; + "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage; + "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage; + "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage; + "@cf/myshell-ai/melotts": BaseAiTextToSpeech; + "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings; + "@cf/microsoft/resnet-50": BaseAiImageClassification; + "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration; + "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration; + "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration; + "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration; + "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration; + "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration; + "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration; + "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration; + "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration; + "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration; + "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration; + "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration; + "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration; + "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration; + "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration; + "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration; + "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration; + "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration; + "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration; + "@cf/microsoft/phi-2": BaseAiTextGeneration; + "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration; + "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration; + "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration; + "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration; + "@hf/google/gemma-7b-it": BaseAiTextGeneration; + "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration; + "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration; + "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration; + "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration; + "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration; + "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration; + "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration; + "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration; + "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration; + "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration; + "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration; + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration; + "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration; + "@cf/facebook/bart-large-cnn": BaseAiSummarization; + "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; + "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5; + "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper; + "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B; + "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5; + "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5; + "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M; + "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En; + "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo; + "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3; + "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell; + "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct; + "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast; + "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B; + "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base; + "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct; + "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B; + "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct; + "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It; + "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct; + "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8; + "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3; + "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B; + "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2; + "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B; + "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B; + "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0; + "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin; + "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1; + "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B; + "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It; + "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B; + "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux; + "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En; + "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es; + "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev; + "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B; + "@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/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B; +} +type AiOptions = { + /** + * Send requests as an asynchronous batch job, only works for supported models + * https://developers.cloudflare.com/workers-ai/features/batch-api + */ + queueRequest?: boolean; + /** + * Establish websocket connections, only works for supported models + */ + websocket?: boolean; + /** + * Tag your requests to group and view them in Cloudflare dashboard. + * + * Rules: + * Tags must only contain letters, numbers, and the symbols: : - . / @ + * Each tag can have maximum 50 characters. + * Maximum 5 tags are allowed each request. + * Duplicate tags will removed. + */ + tags?: string[]; + gateway?: GatewayOptions; + returnRawResponse?: boolean; + prefix?: string; + extraHeaders?: object; + signal?: AbortSignal; +}; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +type ChatCompletionsBase = XOR; +type ChatCompletionsInput = XOR; +interface InferenceUpstreamError extends Error { +} +interface AiInternalError extends Error { +} +type AiModelListType = Record; +type AiAsyncBatchResponse = { + request_id: string; +}; +declare abstract class Ai { + aiGatewayLogId: string | null; + gateway(gatewayId: string): AiGateway; + /** + * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ + aiSearch(): AiSearchNamespace; + /** + * @deprecated AutoRAG has been replaced by AI Search. + * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + * + * @param autoragId Instance ID + */ + autorag(autoragId: string): AutoRAG; + // Batch request + run(model: Name, inputs: { + requests: AiModelList[Name]['inputs'][]; + }, options: AiOptions & { + queueRequest: true; + }): Promise; + // Raw response + run(model: Name, inputs: AiModelList[Name]['inputs'], options: AiOptions & { + returnRawResponse: true; + }): Promise; + // WebSocket + run(model: Name, inputs: AiModelList[Name]['inputs'], options: AiOptions & { + websocket: true; + }): Promise; + // Streaming + run(model: Name, inputs: AiModelList[Name]['inputs'] & { + stream: true; + }, 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>; + models(params?: AiModelsSearchParams): Promise; + toMarkdown(): ToMarkdownService; + toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise; + toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise; +} +type GatewayRetries = { + maxAttempts?: 1 | 2 | 3 | 4 | 5; + retryDelayMs?: number; + backoff?: 'constant' | 'linear' | 'exponential'; +}; +type GatewayOptions = { + id: string; + cacheKey?: string; + cacheTtl?: number; + skipCache?: boolean; + metadata?: Record; + collectLog?: boolean; + eventId?: string; + requestTimeoutMs?: number; + retries?: GatewayRetries; +}; +type UniversalGatewayOptions = Exclude & { + /** + ** @deprecated + */ + id?: string; +}; +type AiGatewayPatchLog = { + score?: number | null; + feedback?: -1 | 1 | null; + metadata?: Record | null; +}; +type AiGatewayLog = { + id: string; + provider: string; + model: string; + model_type?: string; + path: string; + duration: number; + request_type?: string; + request_content_type?: string; + status_code: number; + response_content_type?: string; + success: boolean; + cached: boolean; + tokens_in?: number; + tokens_out?: number; + metadata?: Record; + step?: number; + cost?: number; + custom_cost?: boolean; + request_size: number; + request_head?: string; + request_head_complete: boolean; + response_size: number; + response_head?: string; + response_head_complete: boolean; + created_at: Date; +}; +type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly'; +type AIGatewayHeaders = { + 'cf-aig-metadata': Record | string; + 'cf-aig-custom-cost': { + per_token_in?: number; + per_token_out?: number; + } | { + total_cost?: number; + } | string; + 'cf-aig-cache-ttl': number | string; + 'cf-aig-skip-cache': boolean | string; + 'cf-aig-cache-key': string; + 'cf-aig-event-id': string; + 'cf-aig-request-timeout': number | string; + 'cf-aig-max-attempts': number | string; + 'cf-aig-retry-delay': number | string; + 'cf-aig-backoff': string; + 'cf-aig-collect-log': boolean | string; + Authorization: string; + 'Content-Type': string; + [key: string]: string | number | boolean | object; +}; +type AIGatewayUniversalRequest = { + provider: AIGatewayProviders | string; // eslint-disable-line + endpoint: string; + headers: Partial; + query: unknown; +}; +interface AiGatewayInternalError extends Error { +} +interface AiGatewayLogNotFound extends Error { +} +declare abstract class AiGateway { + patchLog(logId: string, data: AiGatewayPatchLog): Promise; + getLog(logId: string): Promise; + run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: { + gateway?: UniversalGatewayOptions; + extraHeaders?: object; + signal?: AbortSignal; + }): Promise; + getUrl(provider?: AIGatewayProviders | string): Promise; // eslint-disable-line +} +// Copyright (c) 2022-2025 Cloudflare, Inc. +// Licensed under the Apache 2.0 license found in the LICENSE file or at: +// https://opensource.org/licenses/Apache-2.0 +/** + * Artifacts — Git-compatible file storage on Cloudflare Workers. + * + * Provides programmatic access to create, manage, and fork repositories, + * and to issue and revoke scoped access tokens. + */ +/** Information about a repository. */ +interface ArtifactsRepoInfo { + /** Unique repository ID. */ + id: string; + /** Repository name. */ + name: string; + /** Repository description, or null if not set. */ + description: string | null; + /** Default branch name (e.g. "main"). */ + defaultBranch: string; + /** ISO 8601 creation timestamp. */ + createdAt: string; + /** ISO 8601 last-updated timestamp. */ + updatedAt: string; + /** ISO 8601 timestamp of the last push, or null if never pushed. */ + lastPushAt: string | null; + /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */ + source: string | null; + /** Whether the repository is read-only. */ + readOnly: boolean; + /** HTTPS git remote URL. */ + remote: string; +} +/** Result of creating a repository — includes the initial access token. */ +interface ArtifactsCreateRepoResult { + /** Unique repository ID. */ + id: string; + /** Repository name. */ + name: string; + /** Repository description, or null if not set. */ + description: string | null; + /** Default branch name. */ + defaultBranch: string; + /** HTTPS git remote URL. */ + remote: string; + /** Plaintext access token (only returned at creation time). */ + token: string; + /** ISO 8601 token expiry timestamp. */ + tokenExpiresAt: string; +} +/** Paginated list of repositories. */ +interface ArtifactsRepoListResult { + /** Repositories in this page (without the `remote` field). */ + repos: Omit[]; + /** Total number of repositories in the namespace. */ + total: number; + /** Cursor for the next page, if there are more results. */ + cursor?: string; +} +/** Result of creating an access token. */ +interface ArtifactsCreateTokenResult { + /** Unique token ID. */ + id: string; + /** Plaintext token (only returned at creation time). */ + plaintext: string; + /** Token scope: "read" or "write". */ + scope: 'read' | 'write'; + /** ISO 8601 token expiry timestamp. */ + expiresAt: string; +} +/** Token metadata (no plaintext). */ +interface ArtifactsTokenInfo { + /** Unique token ID. */ + id: string; + /** Token scope: "read" or "write". */ + scope: 'read' | 'write'; + /** Token state: "active", "expired", or "revoked". */ + state: 'active' | 'expired' | 'revoked'; + /** ISO 8601 creation timestamp. */ + createdAt: string; + /** ISO 8601 expiry timestamp. */ + expiresAt: string; +} +/** Paginated list of tokens for a repository. */ +interface ArtifactsTokenListResult { + /** Tokens in this page. */ + tokens: ArtifactsTokenInfo[]; + /** Total number of tokens for the repository. */ + total: number; +} +/** Handle for a single repository. Returned by Artifacts.get(). */ +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). + */ + createToken(scope?: 'write' | 'read', ttl?: number): Promise; + /** List tokens for this repo (metadata only, no plaintext). */ + listTokens(): Promise; + /** + * Revoke a token by plaintext or ID. + * @param tokenOrId Plaintext token or token ID. + * @returns true if revoked, false if not found. + */ + revokeToken(tokenOrId: string): Promise; + // ── Fork ── + /** + * Fork this repo to a new repo. + * @param name Target repository name. + * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true). + */ + fork(name: string, opts?: { + description?: string; + readOnly?: boolean; + defaultBranchOnly?: boolean; + }): Promise; +} +/** Artifacts binding — namespace-level operations. */ +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. + */ + create(name: string, opts?: { + readOnly?: boolean; + description?: string; + setDefaultBranch?: string; + }): Promise; + /** + * Get a handle to an existing repository. + * @param name Repository name. + * @returns Repo handle. + */ + 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. + */ + import(params: { + source: { + url: string; + branch?: string; + depth?: number; + }; + target: { + name: string; + opts?: { + description?: string; + readOnly?: boolean; + }; + }; + }): Promise; + /** + * List repositories with cursor-based pagination. + * @param opts Optional: limit (1–200, default 50), cursor for next page. + */ + list(opts?: { + limit?: number; + cursor?: string; + }): Promise; + /** + * Delete a repository and all associated tokens. + * @param name Repository name. + * @returns true if deleted, false if not found. + */ + delete(name: string): Promise; +} +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +interface AutoRAGInternalError extends Error { +} +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +interface AutoRAGNotFoundError extends Error { +} +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +interface AutoRAGUnauthorizedError extends Error { +} +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +interface AutoRAGNameNotSetError extends Error { +} +type ComparisonFilter = { + key: string; + type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'; + value: string | number | boolean; +}; +type CompoundFilter = { + type: 'and' | 'or'; + filters: ComparisonFilter[]; +}; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +type AutoRagSearchRequest = { + query: string; + filters?: CompoundFilter | ComparisonFilter; + max_num_results?: number; + ranking_options?: { + ranker?: string; + score_threshold?: number; + }; + reranking?: { + enabled?: boolean; + model?: string; + }; + rewrite_query?: boolean; +}; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +type AutoRagAiSearchRequest = AutoRagSearchRequest & { + stream?: boolean; + system_prompt?: string; +}; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +type AutoRagAiSearchRequestStreaming = Omit & { + stream: true; +}; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +type AutoRagSearchResponse = { + object: 'vector_store.search_results.page'; + search_query: string; + data: { + file_id: string; + filename: string; + score: number; + attributes: Record; + content: { + type: 'text'; + text: string; + }[]; + }[]; + has_more: boolean; + next_page: string | null; +}; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +type AutoRagListResponse = { + id: string; + enable: boolean; + type: string; + source: string; + vectorize_name: string; + paused: boolean; + status: string; +}[]; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +type AutoRagAiSearchResponse = AutoRagSearchResponse & { + response: string; +}; +/** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ +declare abstract class AutoRAG { + /** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ + list(): Promise; + /** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ + search(params: AutoRagSearchRequest): Promise; + /** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ + aiSearch(params: AutoRagAiSearchRequestStreaming): Promise; + /** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ + aiSearch(params: AutoRagAiSearchRequest): Promise; + /** + * @deprecated Use the standalone AI Search Workers binding instead. + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ + */ + aiSearch(params: AutoRagAiSearchRequest): Promise; +} +interface BasicImageTransformations { + /** + * Maximum width in image pixels. The value must be an integer. + */ + width?: number; + /** + * Maximum height in image pixels. The value must be an integer. + */ + height?: number; + /** + * Resizing mode as a string. It affects interpretation of width and height + * options: + * - scale-down: Similar to contain, but the image is never enlarged. If + * the image is larger than given width or height, it will be resized. + * Otherwise its original size will be kept. + * - contain: Resizes to maximum size that fits within the given width and + * height. If only a single dimension is given (e.g. only width), the + * image will be shrunk or enlarged to exactly match that dimension. + * Aspect ratio is always preserved. + * - cover: Resizes (shrinks or enlarges) to fill the entire area of width + * and height. If the image has an aspect ratio different from the ratio + * of width and height, it will be cropped to fit. + * - crop: The image will be shrunk and cropped to fit within the area + * specified by width and height. The image will not be enlarged. For images + * smaller than the given dimensions it's the same as scale-down. For + * images larger than the given dimensions, it's the same as cover. + * See also trim. + * - pad: Resizes to the maximum size that fits within the given width and + * height, and then fills the remaining area with a background color + * (white by default). Use of this mode is not recommended, as the same + * effect can be more efficiently achieved with the contain mode and the + * CSS object-fit: contain property. + * - squeeze: Stretches and deforms to the width and height given, even if it + * breaks aspect ratio + */ + fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze"; + /** + * Image segmentation using artificial intelligence models. Sets pixels not + * within selected segment area to transparent e.g "foreground" sets every + * background pixel as transparent. + */ + segment?: "foreground"; + /** + * When cropping with fit: "cover", this defines the side or point that should + * be left uncropped. The value is either a string + * "left", "right", "top", "bottom", "auto", or "center" (the default), + * or an object {x, y} containing focal point coordinates in the original + * image expressed as fractions ranging from 0.0 (top or left) to 1.0 + * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will + * crop bottom or left and right sides as necessary, but won’t crop anything + * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to + * preserve as much as possible around a point at 20% of the height of the + * source image. + */ + gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates; + /** + * Background color to add underneath the image. Applies only to images with + * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…), + * hsl(…), etc.) + */ + background?: string; + /** + * Number of degrees (90, 180, 270) to rotate the image by. width and height + * options refer to axes after rotation. + */ + rotate?: 0 | 90 | 180 | 270 | 360; +} +interface BasicImageTransformationsGravityCoordinates { + x?: number; + y?: number; + mode?: 'remainder' | 'box-center'; +} +/** + * In addition to the properties you can set in the RequestInit dict + * that you pass as an argument to the Request constructor, you can + * set certain properties of a `cf` object to control how Cloudflare + * features are applied to that new Request. + * + * Note: Currently, these properties cannot be tested in the + * playground. + */ +interface RequestInitCfProperties extends Record { + cacheEverything?: boolean; + /** + * A request's cache key is what determines if two requests are + * "the same" for caching purposes. If a request has the same cache key + * as some previous request, then we can serve the same cached response for + * both. (e.g. 'some-key') + * + * Only available for Enterprise customers. + */ + cacheKey?: string; + /** + * This allows you to append additional Cache-Tag response headers + * to the origin response without modifications to the origin server. + * This will allow for greater control over the Purge by Cache Tag feature + * utilizing changes only in the Workers process. + * + * Only available for Enterprise customers. + */ + cacheTags?: string[]; + /** + * Force response to be cached for a given number of seconds. (e.g. 300) + */ + cacheTtl?: number; + /** + * Force response to be cached for a given number of seconds based on the Origin status code. + * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 }) + */ + cacheTtlByStatus?: Record; + /** + * Explicit Cache-Control header value to set on the response stored in cache. + * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400'). + * + * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`), + * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError. + * + * Can be used together with `cacheTtlByStatus`. + */ + cacheControl?: string; + /** + * Whether the response should be eligible for Cache Reserve storage. + */ + cacheReserveEligible?: boolean; + /** + * Whether to respect strong ETags (as opposed to weak ETags) from the origin. + */ + respectStrongEtag?: boolean; + /** + * Whether to strip ETag headers from the origin response before caching. + */ + stripEtags?: boolean; + /** + * Whether to strip Last-Modified headers from the origin response before caching. + */ + stripLastModified?: boolean; + /** + * Whether to enable Cache Deception Armor, which protects against web cache + * deception attacks by verifying the Content-Type matches the URL extension. + */ + cacheDeceptionArmor?: boolean; + /** + * Minimum file size in bytes for a response to be eligible for Cache Reserve storage. + */ + cacheReserveMinimumFileSize?: number; + scrapeShield?: boolean; + apps?: boolean; + image?: RequestInitCfPropertiesImage; + minify?: RequestInitCfPropertiesImageMinify; + mirage?: boolean; + polish?: "lossy" | "lossless" | "off"; + r2?: RequestInitCfPropertiesR2; + /** + * Redirects the request to an alternate origin server. You can use this, + * for example, to implement load balancing across several origins. + * (e.g.us-east.example.com) + * + * Note - For security reasons, the hostname set in resolveOverride must + * be proxied on the same Cloudflare zone of the incoming request. + * Otherwise, the setting is ignored. CNAME hosts are allowed, so to + * resolve to a host under a different domain or a DNS only domain first + * declare a CNAME record within your own zone’s DNS mapping to the + * external hostname, set proxy on Cloudflare, then set resolveOverride + * to point to that CNAME record. + */ + resolveOverride?: string; +} +interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations { + /** + * Absolute URL of the image file to use for the drawing. It can be any of + * the supported file formats. For drawing of watermarks or non-rectangular + * overlays we recommend using PNG or WebP images. + */ + url: string; + /** + * Floating-point number between 0 (transparent) and 1 (opaque). + * For example, opacity: 0.5 makes overlay semitransparent. + */ + opacity?: number; + /** + * - If set to true, the overlay image will be tiled to cover the entire + * area. This is useful for stock-photo-like watermarks. + * - If set to "x", the overlay image will be tiled horizontally only + * (form a line). + * - If set to "y", the overlay image will be tiled vertically only + * (form a line). + */ + repeat?: true | "x" | "y"; + /** + * Position of the overlay image relative to a given edge. Each property is + * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10 + * positions left side of the overlay 10 pixels from the left edge of the + * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom + * of the background image. + * + * Setting both left & right, or both top & bottom is an error. + * + * If no position is specified, the image will be centered. + */ + top?: number; + left?: number; + bottom?: number; + right?: number; +} +interface RequestInitCfPropertiesImage extends BasicImageTransformations { + /** + * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it + * easier to specify higher-DPI sizes in . + */ + dpr?: number; + /** + * Allows you to trim your image. Takes dpr into account and is performed before + * resizing or rotation. + * + * It can be used as: + * - left, top, right, bottom - it will specify the number of pixels to cut + * off each side + * - width, height - the width/height you'd like to end up with - can be used + * in combination with the properties above + * - border - this will automatically trim the surroundings of an image based on + * it's color. It consists of three properties: + * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit) + * - tolerance: difference from color to treat as color + * - keep: the number of pixels of border to keep + */ + trim?: "border" | { + top?: number; + bottom?: number; + left?: number; + right?: number; + width?: number; + height?: number; + border?: boolean | { + color?: string; + tolerance?: number; + keep?: number; + }; + }; + /** + * Quality setting from 1-100 (useful values are in 60-90 range). Lower values + * make images look worse, but load faster. The default is 85. It applies only + * to JPEG and WebP images. It doesn’t have any effect on PNG. + */ + quality?: number | "low" | "medium-low" | "medium-high" | "high"; + /** + * Output format to generate. It can be: + * - avif: generate images in AVIF format. + * - webp: generate images in Google WebP format. Set quality to 100 to get + * the WebP-lossless format. + * - json: instead of generating an image, outputs information about the + * image, in JSON format. The JSON object will contain image size + * (before and after resizing), source image’s MIME type, file size, etc. + * - jpeg: generate images in JPEG format. + * - png: generate images in PNG format. + */ + format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg"; + /** + * Whether to preserve animation frames from input files. Default is true. + * Setting it to false reduces animations to still images. This setting is + * recommended when enlarging images or processing arbitrary user content, + * because large GIF animations can weigh tens or even hundreds of megabytes. + * It is also useful to set anim:false when using format:"json" to get the + * response quicker without the number of frames. + */ + anim?: boolean; + /** + * What EXIF data should be preserved in the output image. Note that EXIF + * rotation and embedded color profiles are always applied ("baked in" into + * the image), and aren't affected by this option. Note that if the Polish + * feature is enabled, all metadata may have been removed already and this + * option may have no effect. + * - keep: Preserve most of EXIF metadata, including GPS location if there's + * any. + * - copyright: Only keep the copyright tag, and discard everything else. + * This is the default behavior for JPEG files. + * - none: Discard all invisible EXIF metadata. Currently WebP and PNG + * output formats always discard metadata. + */ + metadata?: "keep" | "copyright" | "none"; + /** + * Strength of sharpening filter to apply to the image. Floating-point + * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a + * recommended value for downscaled images. + */ + sharpen?: number; + /** + * Radius of a blur filter (approximate gaussian). Maximum supported radius + * is 250. + */ + blur?: number; + /** + * Overlays are drawn in the order they appear in the array (last array + * entry is the topmost layer). + */ + draw?: RequestInitCfPropertiesImageDraw[]; + /** + * Fetching image from authenticated origin. Setting this property will + * pass authentication headers (Authorization, Cookie, etc.) through to + * the origin. + */ + "origin-auth"?: "share-publicly"; + /** + * Adds a border around the image. The border is added after resizing. Border + * width takes dpr into account, and can be specified either using a single + * width property, or individually for each side. + */ + border?: { + color: string; + width: number; + } | { + color: string; + top: number; + right: number; + bottom: number; + left: number; + }; + /** + * Increase brightness by a factor. A value of 1.0 equals no change, a value + * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright. + * 0 is ignored. + */ + brightness?: number; + /** + * Increase contrast by a factor. A value of 1.0 equals no change, a value of + * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is + * ignored. + */ + contrast?: number; + /** + * Increase exposure by a factor. A value of 1.0 equals no change, a value of + * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored. + */ + gamma?: number; + /** + * Increase contrast by a factor. A value of 1.0 equals no change, a value of + * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is + * ignored. + */ + saturation?: number; + /** + * Flips the images horizontally, vertically, or both. Flipping is applied before + * rotation, so if you apply flip=h,rotate=90 then the image will be flipped + * horizontally, then rotated by 90 degrees. + */ + flip?: 'h' | 'v' | 'hv'; + /** + * Slightly reduces latency on a cache miss by selecting a + * quickest-to-compress file format, at a cost of increased file size and + * lower image quality. It will usually override the format option and choose + * JPEG over WebP or AVIF. We do not recommend using this option, except in + * unusual circumstances like resizing uncacheable dynamically-generated + * images. + */ + compression?: "fast"; +} +interface RequestInitCfPropertiesImageMinify { + javascript?: boolean; + css?: boolean; + html?: boolean; +} +interface RequestInitCfPropertiesR2 { + /** + * Colo id of bucket that an object is stored in + */ + bucketColoId?: number; +} +/** + * Request metadata provided by Cloudflare's edge. + */ +type IncomingRequestCfProperties = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield; +interface IncomingRequestCfPropertiesBase extends Record { + /** + * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request. + * + * @example 395747 + */ + asn?: number; + /** + * The organization which owns the ASN of the incoming request. + * + * @example "Google Cloud" + */ + asOrganization?: string; + /** + * The original value of the `Accept-Encoding` header if Cloudflare modified it. + * + * @example "gzip, deflate, br" + */ + clientAcceptEncoding?: string; + /** + * The number of milliseconds it took for the request to reach your worker. + * + * @example 22 + */ + clientTcpRtt?: number; + /** + * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code) + * airport code of the data center that the request hit. + * + * @example "DFW" + */ + colo: string; + /** + * Represents the upstream's response to a + * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html) + * from cloudflare. + * + * For workers with no upstream, this will always be `1`. + * + * @example 3 + */ + edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus; + /** + * The HTTP Protocol the request used. + * + * @example "HTTP/2" + */ + httpProtocol: string; + /** + * The browser-requested prioritization information in the request object. + * + * If no information was set, defaults to the empty string `""` + * + * @example "weight=192;exclusive=0;group=3;group-weight=127" + * @default "" + */ + requestPriority: string; + /** + * The TLS version of the connection to Cloudflare. + * In requests served over plaintext (without TLS), this property is the empty string `""`. + * + * @example "TLSv1.3" + */ + tlsVersion: string; + /** + * The cipher for the connection to Cloudflare. + * In requests served over plaintext (without TLS), this property is the empty string `""`. + * + * @example "AEAD-AES128-GCM-SHA256" + */ + tlsCipher: string; + /** + * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake. + * + * If the incoming request was served over plaintext (without TLS) this field is undefined. + */ + tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata; +} +interface IncomingRequestCfPropertiesBotManagementBase { + /** + * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot, + * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human). + * + * @example 54 + */ + score: number; + /** + * A boolean value that is true if the request comes from a good bot, like Google or Bing. + * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots). + */ + verifiedBot: boolean; + /** + * A boolean value that is true if the request originates from a + * Cloudflare-verified proxy service. + */ + corporateProxy: boolean; + /** + * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources. + */ + staticResource: boolean; + /** + * List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request). + */ + detectionIds: number[]; +} +interface IncomingRequestCfPropertiesBotManagement { + /** + * Results of Cloudflare's Bot Management analysis + */ + botManagement: IncomingRequestCfPropertiesBotManagementBase; + /** + * Duplicate of `botManagement.score`. + * + * @deprecated + */ + clientTrustScore: number; +} +interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement { + /** + * Results of Cloudflare's Bot Management analysis + */ + botManagement: IncomingRequestCfPropertiesBotManagementBase & { + /** + * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients + * across different destination IPs, Ports, and X509 certificates. + */ + ja3Hash: string; + }; +} +interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise { + /** + * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/). + * + * This field is only present if you have Cloudflare for SaaS enabled on your account + * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)). + */ + hostMetadata?: HostMetadata; +} +interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield { + /** + * Information about the client certificate presented to Cloudflare. + * + * This is populated when the incoming request is served over TLS using + * either Cloudflare Access or API Shield (mTLS) + * and the presented SSL certificate has a valid + * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number) + * (i.e., not `null` or `""`). + * + * Otherwise, a set of placeholder values are used. + * + * The property `certPresented` will be set to `"1"` when + * the object is populated (i.e. the above conditions were met). + */ + tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder; +} +/** + * Metadata about the request's TLS handshake + */ +interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata { + /** + * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal + * + * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d" + */ + clientHandshake: string; + /** + * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal + * + * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d" + */ + serverHandshake: string; + /** + * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal + * + * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b" + */ + clientFinished: string; + /** + * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal + * + * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b" + */ + serverFinished: string; +} +/** + * Geographic data about the request's origin. + */ +interface IncomingRequestCfPropertiesGeographicInformation { + /** + * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from. + * + * If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR. + * + * If Cloudflare is unable to determine where the request originated this property is omitted. + * + * The country code `"T1"` is used for requests originating on TOR. + * + * @example "GB" + */ + country?: Iso3166Alpha2Code | "T1"; + /** + * If present, this property indicates that the request originated in the EU + * + * @example "1" + */ + isEUCountry?: "1"; + /** + * A two-letter code indicating the continent the request originated from. + * + * @example "AN" + */ + continent?: ContinentCode; + /** + * The city the request originated from + * + * @example "Austin" + */ + city?: string; + /** + * Postal code of the incoming request + * + * @example "78701" + */ + postalCode?: string; + /** + * Latitude of the incoming request + * + * @example "30.27130" + */ + latitude?: string; + /** + * Longitude of the incoming request + * + * @example "-97.74260" + */ + longitude?: string; + /** + * Timezone of the incoming request + * + * @example "America/Chicago" + */ + timezone?: string; + /** + * If known, the ISO 3166-2 name for the first level region associated with + * the IP address of the incoming request + * + * @example "Texas" + */ + region?: string; + /** + * If known, the ISO 3166-2 code for the first-level region associated with + * the IP address of the incoming request + * + * @example "TX" + */ + regionCode?: string; + /** + * Metro code (DMA) of the incoming request + * + * @example "635" + */ + metroCode?: string; +} +/** Data about the incoming request's TLS certificate */ +interface IncomingRequestCfPropertiesTLSClientAuth { + /** Always `"1"`, indicating that the certificate was presented */ + certPresented: "1"; + /** + * Result of certificate verification. + * + * @example "FAILED:self signed certificate" + */ + certVerified: Exclude; + /** The presented certificate's revokation status. + * + * - A value of `"1"` indicates the certificate has been revoked + * - A value of `"0"` indicates the certificate has not been revoked + */ + certRevoked: "1" | "0"; + /** + * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) + * + * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" + */ + certIssuerDN: string; + /** + * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) + * + * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" + */ + certSubjectDN: string; + /** + * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted) + * + * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" + */ + certIssuerDNRFC2253: string; + /** + * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted) + * + * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" + */ + certSubjectDNRFC2253: string; + /** The certificate issuer's distinguished name (legacy policies) */ + certIssuerDNLegacy: string; + /** The certificate subject's distinguished name (legacy policies) */ + certSubjectDNLegacy: string; + /** + * The certificate's serial number + * + * @example "00936EACBE07F201DF" + */ + certSerial: string; + /** + * The certificate issuer's serial number + * + * @example "2489002934BDFEA34" + */ + certIssuerSerial: string; + /** + * The certificate's Subject Key Identifier + * + * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4" + */ + certSKI: string; + /** + * The certificate issuer's Subject Key Identifier + * + * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4" + */ + certIssuerSKI: string; + /** + * The certificate's SHA-1 fingerprint + * + * @example "6b9109f323999e52259cda7373ff0b4d26bd232e" + */ + certFingerprintSHA1: string; + /** + * The certificate's SHA-256 fingerprint + * + * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea" + */ + certFingerprintSHA256: string; + /** + * The effective starting date of the certificate + * + * @example "Dec 22 19:39:00 2018 GMT" + */ + certNotBefore: string; + /** + * The effective expiration date of the certificate + * + * @example "Dec 22 19:39:00 2018 GMT" + */ + certNotAfter: string; +} +/** Placeholder values for TLS Client Authorization */ +interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder { + certPresented: "0"; + certVerified: "NONE"; + certRevoked: "0"; + certIssuerDN: ""; + certSubjectDN: ""; + certIssuerDNRFC2253: ""; + certSubjectDNRFC2253: ""; + certIssuerDNLegacy: ""; + certSubjectDNLegacy: ""; + certSerial: ""; + certIssuerSerial: ""; + certSKI: ""; + certIssuerSKI: ""; + certFingerprintSHA1: ""; + certFingerprintSHA256: ""; + certNotBefore: ""; + certNotAfter: ""; +} +/** Possible outcomes of TLS verification */ +declare type CertVerificationStatus = +/** Authentication succeeded */ +"SUCCESS" +/** No certificate was presented */ + | "NONE" +/** Failed because the certificate was self-signed */ + | "FAILED:self signed certificate" +/** Failed because the certificate failed a trust chain check */ + | "FAILED:unable to verify the first certificate" +/** Failed because the certificate not yet valid */ + | "FAILED:certificate is not yet valid" +/** Failed because the certificate is expired */ + | "FAILED:certificate has expired" +/** Failed for another unspecified reason */ + | "FAILED"; +/** + * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare. + */ +declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */ +/** ISO 3166-1 Alpha-2 codes */ +declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW"; +/** The 2-letter continent codes Cloudflare uses */ +declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA"; +type CfProperties = IncomingRequestCfProperties | RequestInitCfProperties; +interface D1Meta { + duration: number; + size_after: number; + rows_read: number; + rows_written: number; + last_row_id: number; + changed_db: boolean; + changes: number; + /** + * The region of the database instance that executed the query. + */ + served_by_region?: string; + /** + * The three letters airport code of the colo that executed the query. + */ + served_by_colo?: string; + /** + * True if-and-only-if the database instance that executed the query was the primary. + */ + served_by_primary?: boolean; + timings?: { + /** + * The duration of the SQL query execution by the database instance. It doesn't include any network time. + */ + sql_duration_ms: number; + }; + /** + * Number of total attempts to execute the query, due to automatic retries. + * Note: All other fields in the response like `timings` only apply to the last attempt. + */ + total_attempts?: number; +} +interface D1Response { + success: true; + meta: D1Meta & Record; + error?: never; +} +type D1Result = D1Response & { + results: T[]; +}; +interface D1ExecResult { + count: number; + duration: number; +} +type D1SessionConstraint = +// Indicates that the first query should go to the primary, and the rest queries +// using the same D1DatabaseSession will go to any replica that is consistent with +// the bookmark maintained by the session (returned by the first query). +'first-primary' +// Indicates that the first query can go anywhere (primary or replica), and the rest queries +// using the same D1DatabaseSession will go to any replica that is consistent with +// the bookmark maintained by the session (returned by the first query). + | 'first-unconstrained'; +type D1SessionBookmark = string; +declare abstract class D1Database { + prepare(query: string): D1PreparedStatement; + batch(statements: D1PreparedStatement[]): Promise[]>; + exec(query: string): Promise; + /** + * Creates a new D1 Session anchored at the given constraint or the bookmark. + * All queries executed using the created session will have sequential consistency, + * meaning that all writes done through the session will be visible in subsequent reads. + * + * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session. + */ + withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession; + /** + * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases. + */ + dump(): Promise; +} +declare abstract class D1DatabaseSession { + prepare(query: string): D1PreparedStatement; + batch(statements: D1PreparedStatement[]): Promise[]>; + /** + * @returns The latest session bookmark across all executed queries on the session. + * If no query has been executed yet, `null` is returned. + */ + getBookmark(): D1SessionBookmark | null; +} +declare abstract class D1PreparedStatement { + bind(...values: unknown[]): D1PreparedStatement; + first(colName: string): Promise; + first>(): Promise; + run>(): Promise>; + all>(): Promise>; + raw(options: { + columnNames: true; + }): Promise<[ + string[], + ...T[] + ]>; + raw(options?: { + columnNames?: false; + }): Promise; +} +// `Disposable` was added to TypeScript's standard lib types in version 5.2. +// To support older TypeScript versions, define an empty `Disposable` interface. +// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2, +// but this will ensure type checking on older versions still passes. +// TypeScript's interface merging will ensure our empty interface is effectively +// ignored when `Disposable` is included in the standard lib. +interface Disposable { +} +/** + * The returned data after sending an email + */ +interface EmailSendResult { + /** + * The Email Message ID + */ + messageId: string; +} +/** + * An email message that can be sent from a Worker. + */ +interface EmailMessage { + /** + * Envelope From attribute of the email message. + */ + readonly from: string; + /** + * Envelope To attribute of the email message. + */ + readonly to: string; +} +/** + * An email message that is sent to a consumer Worker and can be rejected/forwarded. + */ +interface ForwardableEmailMessage extends EmailMessage { + /** + * Stream of the email message content. + */ + readonly raw: ReadableStream; + /** + * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers). + */ + readonly headers: Headers; + /** + * Size of the email message content. + */ + readonly rawSize: number; + /** + * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason. + * @param reason The reject reason. + * @returns void + */ + setReject(reason: string): void; + /** + * Forward this email message to a verified destination address of the account. + * @param rcptTo Verified destination address. + * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers). + * @returns A promise that resolves when the email message is forwarded. + */ + forward(rcptTo: string, headers?: Headers): Promise; + /** + * Reply to the sender of this email message with a new EmailMessage object. + * @param message The reply message. + * @returns A promise that resolves when the email message is replied. + */ + reply(message: EmailMessage): Promise; +} +/** A file attachment for an email message */ +type EmailAttachment = { + disposition: 'inline'; + contentId: string; + filename: string; + type: string; + content: string | ArrayBuffer | ArrayBufferView; +} | { + disposition: 'attachment'; + contentId?: undefined; + filename: string; + type: string; + content: string | ArrayBuffer | ArrayBufferView; +}; +/** An Email Address */ +interface EmailAddress { + name: string; + email: string; +} +/** + * A binding that allows a Worker to send email messages. + */ +interface SendEmail { + send(message: EmailMessage): Promise; + send(builder: { + from: string | EmailAddress; + to: string | string[]; + subject: string; + replyTo?: string | EmailAddress; + cc?: string | string[]; + bcc?: string | string[]; + headers?: Record; + text?: string; + html?: string; + attachments?: EmailAttachment[]; + }): Promise; +} +declare abstract class EmailEvent extends ExtendableEvent { + readonly message: ForwardableEmailMessage; +} +declare type EmailExportedHandler = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise; +declare module "cloudflare:email" { + let _EmailMessage: { + prototype: EmailMessage; + new (from: string, to: string, raw: ReadableStream | string): EmailMessage; + }; + export { _EmailMessage as EmailMessage }; +} +/** + * Evaluation context for targeting rules. + * Keys are attribute names (e.g. "userId", "country"), values are the attribute values. + */ +type FlagshipEvaluationContext = Record; +interface FlagshipEvaluationDetails { + flagKey: string; + value: T; + variant?: string | undefined; + reason?: string | undefined; + errorCode?: string | undefined; + errorMessage?: string | undefined; +} +interface FlagshipEvaluationError extends Error { +} +/** + * Feature flags binding for evaluating feature flags from a Cloudflare Workers script. + * + * @example + * ```typescript + * // Get a boolean flag value with a default + * const enabled = await env.FLAGS.getBooleanValue('my-feature', false); + * + * // Get a flag value with evaluation context for targeting + * const variant = await env.FLAGS.getStringValue('experiment', 'control', { + * userId: 'user-123', + * country: 'US', + * }); + * + * // Get full evaluation details including variant and reason + * const details = await env.FLAGS.getBooleanDetails('my-feature', false); + * console.log(details.variant, details.reason); + * ``` + */ +declare abstract class Flagship { + /** + * Get a flag value without type checking. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Optional default value returned when evaluation fails. + * @param context Optional evaluation context for targeting rules. + */ + get(flagKey: string, defaultValue?: unknown, context?: FlagshipEvaluationContext): Promise; + /** + * Get a boolean flag value. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getBooleanValue(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise; + /** + * Get a string flag value. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getStringValue(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise; + /** + * Get a number flag value. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getNumberValue(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise; + /** + * Get an object flag value. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getObjectValue(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise; + /** + * Get a boolean flag value with full evaluation details. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getBooleanDetails(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise>; + /** + * Get a string flag value with full evaluation details. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getStringDetails(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise>; + /** + * Get a number flag value with full evaluation details. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getNumberDetails(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise>; + /** + * Get an object flag value with full evaluation details. + * @param flagKey The key of the flag to evaluate. + * @param defaultValue Default value returned when evaluation fails or the flag type does not match. + * @param context Optional evaluation context for targeting rules. + */ + getObjectDetails(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise>; +} +/** + * Hello World binding to serve as an explanatory example. DO NOT USE + */ +interface HelloWorldBinding { + /** + * Retrieve the current stored value + */ + get(): Promise<{ + value: string; + ms?: number; + }>; + /** + * Set a new stored value + */ + set(value: string): Promise; +} +interface Hyperdrive { + /** + * Connect directly to Hyperdrive as if it's your database, returning a TCP socket. + * + * Calling this method returns an identical socket to if you call + * `connect("host:port")` using the `host` and `port` fields from this object. + * Pick whichever approach works better with your preferred DB client library. + * + * Note that this socket is not yet authenticated -- it's expected that your + * code (or preferably, the client library of your choice) will authenticate + * using the information in this class's readonly fields. + */ + connect(): Socket; + /** + * A valid DB connection string that can be passed straight into the typical + * client library/driver/ORM. This will typically be the easiest way to use + * Hyperdrive. + */ + readonly connectionString: string; + /* + * A randomly generated hostname that is only valid within the context of the + * currently running Worker which, when passed into `connect()` function from + * the "cloudflare:sockets" module, will connect to the Hyperdrive instance + * for your database. + */ + readonly host: string; + /* + * The port that must be paired the the host field when connecting. + */ + readonly port: number; + /* + * The username to use when authenticating to your database via Hyperdrive. + * Unlike the host and password, this will be the same every time + */ + readonly user: string; + /* + * The randomly generated password to use when authenticating to your + * database via Hyperdrive. Like the host field, this password is only valid + * within the context of the currently running Worker instance from which + * it's read. + */ + readonly password: string; + /* + * The name of the database to connect to. + */ + readonly database: string; +} +// Copyright (c) 2024 Cloudflare, Inc. +// Licensed under the Apache 2.0 license found in the LICENSE file or at: +// https://opensource.org/licenses/Apache-2.0 +type ImageInfoResponse = { + format: 'image/svg+xml'; +} | { + format: string; + fileSize: number; + width: number; + height: number; +}; +type ImageTransform = { + width?: number; + height?: number; + background?: string; + blur?: number; + border?: { + color?: string; + width?: number; + } | { + top?: number; + bottom?: number; + left?: number; + right?: number; + }; + brightness?: number; + contrast?: number; + fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop'; + flip?: 'h' | 'v' | 'hv'; + gamma?: number; + segment?: 'foreground'; + gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | { + x?: number; + y?: number; + mode: 'remainder' | 'box-center'; + }; + rotate?: 0 | 90 | 180 | 270; + saturation?: number; + sharpen?: number; + trim?: 'border' | { + top?: number; + bottom?: number; + left?: number; + right?: number; + width?: number; + height?: number; + border?: boolean | { + color?: string; + tolerance?: number; + keep?: number; + }; + }; +}; +type ImageDrawOptions = { + opacity?: number; + repeat?: boolean | string; + top?: number; + left?: number; + bottom?: number; + right?: number; +}; +type ImageInputOptions = { + encoding?: 'base64'; +}; +type ImageOutputOptions = { + format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba'; + quality?: number; + background?: string; + anim?: boolean; +}; +interface ImageMetadata { + id: string; + filename?: string; + uploaded?: string; + requireSignedURLs: boolean; + meta?: Record; + variants: string[]; + draft?: boolean; + creator?: string; +} +interface ImageUploadOptions { + id?: string; + filename?: string; + requireSignedURLs?: boolean; + metadata?: Record; + creator?: string; + encoding?: 'base64'; +} +interface ImageUpdateOptions { + requireSignedURLs?: boolean; + metadata?: Record; + creator?: string; +} +interface ImageListOptions { + limit?: number; + cursor?: string; + sortOrder?: 'asc' | 'desc'; + creator?: string; +} +interface ImageList { + images: ImageMetadata[]; + cursor?: string; + listComplete: boolean; +} +interface ImageHandle { + /** + * Get metadata for a hosted image + * @returns Image metadata, or null if not found + */ + details(): Promise; + /** + * Get the raw image data for a hosted image + * @returns ReadableStream of image bytes, or null if not found + */ + bytes(): Promise | null>; + /** + * Update hosted image metadata + * @param options Properties to update + * @returns Updated image metadata + * @throws {@link ImagesError} if update fails + */ + update(options: ImageUpdateOptions): Promise; + /** + * Delete a hosted image + * @returns True if deleted, false if not found + */ + delete(): Promise; +} +interface HostedImagesBinding { + /** + * Get a handle for a hosted image + * @param imageId The ID of the image (UUID or custom ID) + * @returns A handle for per-image operations + */ + image(imageId: string): ImageHandle; + /** + * Upload a new hosted image + * @param image The image file to upload + * @param options Upload configuration + * @returns Metadata for the uploaded image + * @throws {@link ImagesError} if upload fails + */ + upload(image: ReadableStream | ArrayBuffer, options?: ImageUploadOptions): Promise; + /** + * List hosted images with pagination + * @param options List configuration + * @returns List of images with pagination info + * @throws {@link ImagesError} if list fails + */ + list(options?: ImageListOptions): Promise; +} +interface ImagesBinding { + /** + * Get image metadata (type, width and height) + * @throws {@link ImagesError} with code 9412 if input is not an image + * @param stream The image bytes + */ + info(stream: ReadableStream, options?: ImageInputOptions): Promise; + /** + * Begin applying a series of transformations to an image + * @param stream The image bytes + * @returns A transform handle + */ + input(stream: ReadableStream, options?: ImageInputOptions): ImageTransformer; + /** + * Access hosted images CRUD operations + */ + readonly hosted: HostedImagesBinding; +} +interface ImageTransformer { + /** + * Apply transform next, returning a transform handle. + * You can then apply more transformations, draw, or retrieve the output. + * @param transform + */ + transform(transform: ImageTransform): ImageTransformer; + /** + * Draw an image on this transformer, returning a transform handle. + * You can then apply more transformations, draw, or retrieve the output. + * @param image The image (or transformer that will give the image) to draw + * @param options The options configuring how to draw the image + */ + draw(image: ReadableStream | ImageTransformer, options?: ImageDrawOptions): ImageTransformer; + /** + * Retrieve the image that results from applying the transforms to the + * provided input + * @param options Options that apply to the output e.g. output format + */ + output(options: ImageOutputOptions): Promise; +} +type ImageTransformationOutputOptions = { + encoding?: 'base64'; +}; +interface ImageTransformationResult { + /** + * The image as a response, ready to store in cache or return to users + */ + response(): Response; + /** + * The content type of the returned image + */ + contentType(): string; + /** + * The bytes of the response + */ + image(options?: ImageTransformationOutputOptions): ReadableStream; +} +interface ImagesError extends Error { + readonly code: number; + readonly message: string; + readonly stack?: string; +} +/** + * Media binding for transforming media streams. + * Provides the entry point for media transformation operations. + */ +interface MediaBinding { + /** + * Creates a media transformer from an input stream. + * @param media - The input media bytes + * @returns A MediaTransformer instance for applying transformations + */ + input(media: ReadableStream): MediaTransformer; +} +/** + * Media transformer for applying transformation operations to media content. + * Handles sizing, fitting, and other input transformation parameters. + */ +interface MediaTransformer { + /** + * Applies transformation options to the media content. + * @param transform - Configuration for how the media should be transformed + * @returns A generator for producing the transformed media output + */ + transform(transform?: MediaTransformationInputOptions): MediaTransformationGenerator; + /** + * Generates the final media output with specified options. + * @param output - Configuration for the output format and parameters + * @returns The final transformation result containing the transformed media + */ + output(output?: MediaTransformationOutputOptions): MediaTransformationResult; +} +/** + * Generator for producing media transformation results. + * Configures the output format and parameters for the transformed media. + */ +interface MediaTransformationGenerator { + /** + * Generates the final media output with specified options. + * @param output - Configuration for the output format and parameters + * @returns The final transformation result containing the transformed media + */ + output(output?: MediaTransformationOutputOptions): MediaTransformationResult; +} +/** + * Result of a media transformation operation. + * Provides multiple ways to access the transformed media content. + */ +interface MediaTransformationResult { + /** + * Returns the transformed media as a readable stream of bytes. + * @returns A promise containing a readable stream with the transformed media + */ + media(): Promise>; + /** + * Returns the transformed media as an HTTP response object. + * @returns The transformed media as a Promise, ready to store in cache or return to users + */ + response(): Promise; + /** + * Returns the MIME type of the transformed media. + * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4') + */ + contentType(): Promise; +} +/** + * Configuration options for transforming media input. + * Controls how the media should be resized and fitted. + */ +type MediaTransformationInputOptions = { + /** How the media should be resized to fit the specified dimensions */ + fit?: 'contain' | 'cover' | 'scale-down'; + /** Target width in pixels */ + width?: number; + /** Target height in pixels */ + height?: number; +}; +/** + * Configuration options for Media Transformations output. + * Controls the format, timing, and type of the generated output. + */ +type MediaTransformationOutputOptions = { + /** + * Output mode determining the type of media to generate + */ + mode?: 'video' | 'spritesheet' | 'frame' | 'audio'; + /** Whether to include audio in the output */ + audio?: boolean; + /** + * Starting timestamp for frame extraction or start time for clips. (e.g. '2s'). + */ + time?: string; + /** + * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s'). + */ + duration?: string; + /** + * Number of frames in the spritesheet. + */ + imageCount?: number; + /** + * Output format for the generated media. + */ + format?: 'jpg' | 'png' | 'm4a'; +}; +/** + * Error object for media transformation operations. + * Extends the standard Error interface with additional media-specific information. + */ +interface MediaError extends Error { + readonly code: number; + readonly message: string; + readonly stack?: string; +} +declare module 'cloudflare:node' { + interface NodeStyleServer { + listen(...args: unknown[]): this; + address(): { + port?: number | null | undefined; + }; + } + export function httpServerHandler(port: number): ExportedHandler; + export function httpServerHandler(options: { + port: number; + }): ExportedHandler; + export function httpServerHandler(server: NodeStyleServer): ExportedHandler; +} +type Params

= Record; +type EventContext = { + request: Request>; + functionPath: string; + waitUntil: (promise: Promise) => void; + passThroughOnException: () => void; + next: (input?: Request | string, init?: RequestInit) => Promise; + env: Env & { + ASSETS: { + fetch: typeof fetch; + }; + }; + params: Params

; + data: Data; +}; +type PagesFunction = Record> = (context: EventContext) => Response | Promise; +type EventPluginContext = { + request: Request>; + functionPath: string; + waitUntil: (promise: Promise) => void; + passThroughOnException: () => void; + next: (input?: Request | string, init?: RequestInit) => Promise; + env: Env & { + ASSETS: { + fetch: typeof fetch; + }; + }; + params: Params

; + data: Data; + pluginArgs: PluginArgs; +}; +type PagesPluginFunction = Record, PluginArgs = unknown> = (context: EventPluginContext) => Response | Promise; +declare module "assets:*" { + export const onRequest: PagesFunction; +} +// Copyright (c) 2022-2023 Cloudflare, Inc. +// Licensed under the Apache 2.0 license found in the LICENSE file or at: +// https://opensource.org/licenses/Apache-2.0 +declare module "cloudflare:pipelines" { + export abstract class PipelineTransformationEntrypoint { + protected env: Env; + protected ctx: ExecutionContext; + constructor(ctx: ExecutionContext, env: Env); + /** + * run receives an array of PipelineRecord which can be + * transformed and returned to the pipeline + * @param records Incoming records from the pipeline to be transformed + * @param metadata Information about the specific pipeline calling the transformation entrypoint + * @returns A promise containing the transformed PipelineRecord array + */ + public run(records: I[], metadata: PipelineBatchMetadata): Promise; + } + export type PipelineRecord = Record; + export type PipelineBatchMetadata = { + pipelineId: string; + pipelineName: string; + }; + export interface Pipeline { + /** + * The Pipeline interface represents the type of a binding to a Pipeline + * + * @param records The records to send to the pipeline + */ + send(records: T[]): Promise; + } +} +// PubSubMessage represents an incoming PubSub message. +// The message includes metadata about the broker, the client, and the payload +// itself. +// https://developers.cloudflare.com/pub-sub/ +interface PubSubMessage { + // Message ID + readonly mid: number; + // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT + readonly broker: string; + // The MQTT topic the message was sent on. + readonly topic: string; + // The client ID of the client that published this message. + readonly clientId: string; + // The unique identifier (JWT ID) used by the client to authenticate, if token + // auth was used. + readonly jti?: string; + // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker + // received the message from the client. + readonly receivedAt: number; + // An (optional) string with the MIME type of the payload, if set by the + // client. + readonly contentType: string; + // Set to 1 when the payload is a UTF-8 string + // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063 + readonly payloadFormatIndicator: number; + // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays. + // You can use payloadFormatIndicator to inspect this before decoding. + payload: string | Uint8Array; +} +// JsonWebKey extended by kid parameter +interface JsonWebKeyWithKid extends JsonWebKey { + // Key Identifier of the JWK + readonly kid: string; +} +interface RateLimitOptions { + key: string; +} +interface RateLimitOutcome { + success: boolean; +} +interface RateLimit { + /** + * Rate limit a request based on the provided options. + * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/ + * @returns A promise that resolves with the outcome of the rate limit. + */ + limit(options: RateLimitOptions): Promise; +} +// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need +// to referenced by `Fetcher`. This is included in the "importable" version of the types which +// strips all `module` blocks. +declare namespace Rpc { + // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. + // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. + // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to + // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) + export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; + export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; + export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND'; + export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND'; + export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND'; + export interface RpcTargetBranded { + [__RPC_TARGET_BRAND]: never; + } + export interface WorkerEntrypointBranded { + [__WORKER_ENTRYPOINT_BRAND]: never; + } + export interface DurableObjectBranded { + [__DURABLE_OBJECT_BRAND]: never; + } + export interface WorkflowEntrypointBranded { + [__WORKFLOW_ENTRYPOINT_BRAND]: never; + } + export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded; + // Types that can be used through `Stub`s + export type Stubable = RpcTargetBranded | ((...args: any[]) => any); + // Types that can be passed over RPC + // The reason for using a generic type here is to build a serializable subset of structured + // cloneable composite types. This allows types defined with the "interface" keyword to pass the + // serializable check as well. Otherwise, only types defined with the "type" keyword would pass. + type Serializable = + // Structured cloneables + BaseType + // Structured cloneable composites + | Map ? Serializable : never, T extends Map ? Serializable : never> | Set ? Serializable : never> | ReadonlyArray ? Serializable : never> | { + [K in keyof T]: K extends number | string ? Serializable : never; + } + // Special types + | Stub + // Serialized as stubs, see `Stubify` + | Stubable; + // Base type for all RPC stubs, including common memory management methods. + // `T` is used as a marker type for unwrapping `Stub`s later. + interface StubBase extends Disposable { + [__RPC_STUB_BRAND]: T; + dup(): this; + } + export type Stub = Provider & StubBase; + // This represents all the types that can be sent as-is over an RPC boundary + type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream | WritableStream | Request | Response | Headers; + // Recursively rewrite all `Stubable` types with `Stub`s + // prettier-ignore + type Stubify = T extends Stubable ? Stub : T extends Map ? Map, Stubify> : T extends Set ? Set> : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { + [key: string | number]: any; + } ? { + [K in keyof T]: Stubify; + } : T; + // Recursively rewrite all `Stub`s with the corresponding `T`s. + // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: + // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. + // prettier-ignore + type Unstubify = T extends StubBase ? V : T extends Map ? Map, Unstubify> : T extends Set ? Set> : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { + [key: string | number]: unknown; + } ? { + [K in keyof T]: Unstubify; + } : T; + type UnstubifyAll = { + [I in keyof A]: Unstubify; + }; + // Utility type for adding `Provider`/`Disposable`s to `object` types only. + // Note `unknown & T` is equivalent to `T`. + type MaybeProvider = T extends object ? Provider : unknown; + type MaybeDisposable = T extends object ? Disposable : unknown; + // Type for method return or property on an RPC interface. + // - Stubable types are replaced by stubs. + // - Serializable types are passed by value, with stubable types replaced by stubs + // and a top-level `Disposer`. + // Everything else can't be passed over PRC. + // Technically, we use custom thenables here, but they quack like `Promise`s. + // Intersecting with `(Maybe)Provider` allows pipelining. + // prettier-ignore + type Result = R extends Stubable ? Promise> & Provider : R extends Serializable ? Promise & MaybeDisposable> & MaybeProvider : never; + // Type for method or property on an RPC interface. + // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. + // Unwrapping `Stub`s allows calling with `Stubable` arguments. + // For properties, rewrite types to be `Result`s. + // In each case, unwrap `Promise`s. + type MethodOrProperty = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll

) => Result> : Result>; + // Type for the callable part of an `Provider` if `T` is callable. + // This is intersected with methods/properties. + type MaybeCallableProvider = T extends (...args: any[]) => any ? MethodOrProperty : unknown; + // Base type for all other types providing RPC-like interfaces. + // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. + // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC. + export type Provider = MaybeCallableProvider & Pick<{ + [K in keyof T]: MethodOrProperty; + }, Exclude>>; +} +declare namespace Cloudflare { + // Type of `env`. + // + // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript + // will merge all declarations. + // + // You can use `wrangler types` to generate the `Env` type automatically. + interface Env { + } + // Project-specific parameters used to inform types. + // + // This interface is, again, intended to be declared in project-specific files, and then that + // declaration will be merged with this one. + // + // A project should have a declaration like this: + // + // interface GlobalProps { + // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type + // // of `ctx.exports`. + // mainModule: typeof import("my-main-module"); + // + // // Declares which of the main module's exports are configured with durable storage, and + // // thus should behave as Durable Object namsepace bindings. + // durableNamespaces: "MyDurableObject" | "AnotherDurableObject"; + // } + // + // You can use `wrangler types` to generate `GlobalProps` automatically. + interface GlobalProps { + } + // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not + // present. + type GlobalProp = K extends keyof GlobalProps ? GlobalProps[K] : Default; + // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the + // `mainModule` property. + type MainModule = GlobalProp<"mainModule", {}>; + // The type of ctx.exports, which contains loopback bindings for all top-level exports. + type Exports = { + [K in keyof MainModule]: LoopbackForExport + // If the export is listed in `durableNamespaces`, then it is also a + // DurableObjectNamespace. + & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace : DurableObjectNamespace : DurableObjectNamespace : {}); + }; +} +declare namespace CloudflareWorkersModule { + export type RpcStub = Rpc.Stub; + export const RpcStub: { + new (value: T): Rpc.Stub; + }; + export abstract class RpcTarget implements Rpc.RpcTargetBranded { + [Rpc.__RPC_TARGET_BRAND]: never; + } + // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC + export abstract class WorkerEntrypoint implements Rpc.WorkerEntrypointBranded { + [Rpc.__WORKER_ENTRYPOINT_BRAND]: never; + protected ctx: ExecutionContext; + protected env: Env; + constructor(ctx: ExecutionContext, env: Env); + email?(message: ForwardableEmailMessage): void | Promise; + fetch?(request: Request): Response | Promise; + connect?(socket: Socket): void | Promise; + queue?(batch: MessageBatch): void | Promise; + scheduled?(controller: ScheduledController): void | Promise; + tail?(events: TraceItem[]): void | Promise; + tailStream?(event: TailStream.TailEvent): TailStream.TailEventHandlerType | Promise; + test?(controller: TestController): void | Promise; + trace?(traces: TraceItem[]): void | Promise; + } + export abstract class DurableObject implements Rpc.DurableObjectBranded { + [Rpc.__DURABLE_OBJECT_BRAND]: never; + protected ctx: DurableObjectState; + protected env: Env; + constructor(ctx: DurableObjectState, env: Env); + alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise; + fetch?(request: Request): Response | Promise; + connect?(socket: Socket): void | Promise; + webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise; + webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise; + webSocketError?(ws: WebSocket, error: unknown): void | Promise; + } + export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; + export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; + export type WorkflowDelayDuration = WorkflowSleepDuration; + export type WorkflowTimeoutDuration = WorkflowSleepDuration; + export type WorkflowRetentionDuration = WorkflowSleepDuration; + export type WorkflowBackoff = 'constant' | 'linear' | 'exponential'; + export type WorkflowStepConfig = { + retries?: { + limit: number; + delay: WorkflowDelayDuration | number; + backoff?: WorkflowBackoff; + }; + timeout?: WorkflowTimeoutDuration | number; + }; + export type WorkflowEvent = { + payload: Readonly; + timestamp: Date; + instanceId: string; + }; + export type WorkflowStepEvent = { + payload: Readonly; + timestamp: Date; + type: string; + }; + export type WorkflowStepContext = { + step: { + name: string; + count: number; + }; + attempt: number; + config: WorkflowStepConfig; + }; + export abstract class WorkflowStep { + do>(name: string, callback: (ctx: WorkflowStepContext) => Promise): Promise; + do>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise): Promise; + sleep: (name: string, duration: WorkflowSleepDuration) => Promise; + sleepUntil: (name: string, timestamp: Date | number) => Promise; + waitForEvent>(name: string, options: { + type: string; + timeout?: WorkflowTimeoutDuration | number; + }): Promise>; + } + export type WorkflowInstanceStatus = 'queued' | 'running' | 'paused' | 'errored' | 'terminated' | 'complete' | 'waiting' | 'waitingForPause' | 'unknown'; + export abstract class WorkflowEntrypoint | unknown = unknown> implements Rpc.WorkflowEntrypointBranded { + [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never; + protected ctx: ExecutionContext; + protected env: Env; + constructor(ctx: ExecutionContext, env: Env); + run(event: Readonly>, step: WorkflowStep): Promise; + } + export function waitUntil(promise: Promise): void; + export function withEnv(newEnv: unknown, fn: () => unknown): unknown; + export function withExports(newExports: unknown, fn: () => unknown): unknown; + export function withEnvAndExports(newEnv: unknown, newExports: unknown, fn: () => unknown): unknown; + export const env: Cloudflare.Env; + export const exports: Cloudflare.Exports; + export const cache: CacheContext; + export const tracing: Tracing; +} +declare module 'cloudflare:workers' { + export = CloudflareWorkersModule; +} +interface SecretsStoreSecret { + /** + * Get a secret from the Secrets Store, returning a string of the secret value + * if it exists, or throws an error if it does not exist + */ + get(): Promise; +} +declare module "cloudflare:sockets" { + function _connect(address: string | SocketAddress, options?: SocketOptions): Socket; + export { _connect as connect }; +} +/** + * Binding entrypoint for Cloudflare Stream. + * + * Usage: + * - Binding-level operations: + * `await env.STREAM.videos.upload` + * `await env.STREAM.videos.createDirectUpload` + * `await env.STREAM.videos.*` + * `await env.STREAM.watermarks.*` + * - Per-video operations: + * `await env.STREAM.video(id).downloads.*` + * `await env.STREAM.video(id).captions.*` + * + * Example usage: + * ```ts + * await env.STREAM.video(id).downloads.generate(); + * + * const video = env.STREAM.video(id) + * const captions = video.captions.list(); + * const videoDetails = video.details() + * ``` + */ +interface StreamBinding { + /** + * Returns a handle scoped to a single video for per-video operations. + * @param id The unique identifier for the video. + * @returns A handle for per-video operations. + */ + video(id: string): StreamVideoHandle; + /** + * Uploads a new video from a provided URL. + * @param url The URL to upload from. + * @param params Optional upload parameters. + * @returns The uploaded video details. + * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid + * @throws {QuotaReachedError} if the account storage capacity is exceeded + * @throws {MaxFileSizeError} if the file size is too large + * @throws {RateLimitedError} if the server received too many requests + * @throws {AlreadyUploadedError} if a video was already uploaded to this URL + * @throws {InternalError} if an unexpected error occurs + */ + upload(url: string, params?: StreamUrlUploadParams): Promise; + /** + * Creates a direct upload that allows video uploads without an API key. + * @param params Parameters for the direct upload + * @returns The direct upload details. + * @throws {BadRequestError} if the parameters are invalid + * @throws {RateLimitedError} if the server received too many requests + * @throws {InternalError} if an unexpected error occurs + */ + createDirectUpload(params: StreamDirectUploadCreateParams): Promise; + videos: StreamVideos; + watermarks: StreamWatermarks; +} +/** + * Handle for operations scoped to a single Stream video. + */ +interface StreamVideoHandle { + /** + * The unique identifier for the video. + */ + id: string; + /** + * Get a full videos details + * @returns The full video details. + * @throws {NotFoundError} if the video is not found + * @throws {InternalError} if an unexpected error occurs + */ + details(): Promise; + /** + * Update details for a single video. + * @param params The fields to update for the video. + * @returns The updated video details. + * @throws {NotFoundError} if the video is not found + * @throws {BadRequestError} if the parameters are invalid + * @throws {InternalError} if an unexpected error occurs + */ + update(params: StreamUpdateVideoParams): Promise; + /** + * Deletes a video and its copies from Cloudflare Stream. + * @returns A promise that resolves when deletion completes. + * @throws {NotFoundError} if the video is not found + * @throws {InternalError} if an unexpected error occurs + */ + delete(): Promise; + /** + * Creates a signed URL token for a video. + * @returns The signed token that was created. + * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed + */ + generateToken(): Promise; + downloads: StreamScopedDownloads; + captions: StreamScopedCaptions; +} +interface StreamVideo { + /** + * The unique identifier for the video. + */ + id: string; + /** + * A user-defined identifier for the media creator. + */ + creator: string | null; + /** + * The thumbnail URL for the video. + */ + thumbnail: string; + /** + * The thumbnail timestamp percentage. + */ + thumbnailTimestampPct: number; + /** + * Indicates whether the video is ready to stream. + */ + readyToStream: boolean; + /** + * The date and time the video became ready to stream. + */ + readyToStreamAt: string | null; + /** + * Processing status information. + */ + status: StreamVideoStatus; + /** + * A user modifiable key-value store. + */ + meta: Record; + /** + * The date and time the video was created. + */ + created: string; + /** + * The date and time the video was last modified. + */ + modified: string; + /** + * The date and time at which the video will be deleted. + */ + scheduledDeletion: string | null; + /** + * The size of the video in bytes. + */ + size: number; + /** + * The preview URL for the video. + */ + preview?: string; + /** + * Origins allowed to display the video. + */ + allowedOrigins: Array; + /** + * Indicates whether signed URLs are required. + */ + requireSignedURLs: boolean | null; + /** + * The date and time the video was uploaded. + */ + uploaded: string | null; + /** + * The date and time when the upload URL expires. + */ + uploadExpiry: string | null; + /** + * The maximum size in bytes for direct uploads. + */ + maxSizeBytes: number | null; + /** + * The maximum duration in seconds for direct uploads. + */ + maxDurationSeconds: number | null; + /** + * The video duration in seconds. -1 indicates unknown. + */ + duration: number; + /** + * Input metadata for the original upload. + */ + input: StreamVideoInput; + /** + * Playback URLs for the video. + */ + hlsPlaybackUrl: string; + dashPlaybackUrl: string; + /** + * The watermark applied to the video, if any. + */ + watermark: StreamWatermark | null; + /** + * The live input id associated with the video, if any. + */ + liveInputId?: string | null; + /** + * The source video id if this is a clip. + */ + clippedFromId: string | null; + /** + * Public details associated with the video. + */ + publicDetails: StreamPublicDetails | null; +} +type StreamVideoStatus = { + /** + * The current processing state. + */ + state: string; + /** + * The current processing step. + */ + step?: string; + /** + * The percent complete as a string. + */ + pctComplete?: string; + /** + * An error reason code, if applicable. + */ + errorReasonCode: string; + /** + * An error reason text, if applicable. + */ + errorReasonText: string; +}; +type StreamVideoInput = { + /** + * The input width in pixels. + */ + width: number; + /** + * The input height in pixels. + */ + height: number; +}; +type StreamPublicDetails = { + /** + * The public title for the video. + */ + title: string | null; + /** + * The public share link. + */ + share_link: string | null; + /** + * The public channel link. + */ + channel_link: string | null; + /** + * The public logo URL. + */ + logo: string | null; +}; +type StreamDirectUpload = { + /** + * The URL an unauthenticated upload can use for a single multipart request. + */ + uploadURL: string; + /** + * A Cloudflare-generated unique identifier for a media item. + */ + id: string; + /** + * The watermark profile applied to the upload. + */ + watermark: StreamWatermark | null; + /** + * The scheduled deletion time, if any. + */ + scheduledDeletion: string | null; +}; +type StreamDirectUploadCreateParams = { + /** + * The maximum duration in seconds for a video upload. + */ + maxDurationSeconds: number; + /** + * The date and time after upload when videos will not be accepted. + */ + expiry?: string; + /** + * A user-defined identifier for the media creator. + */ + creator?: string; + /** + * A user modifiable key-value store used to reference other systems of record for + * managing videos. + */ + meta?: Record; + /** + * Lists the origins allowed to display the video. + */ + allowedOrigins?: Array; + /** + * Indicates whether the video can be accessed using the id. When set to `true`, + * a signed token must be generated with a signing key to view the video. + */ + requireSignedURLs?: boolean; + /** + * The thumbnail timestamp percentage. + */ + thumbnailTimestampPct?: number; + /** + * The date and time at which the video will be deleted. Include `null` to remove + * a scheduled deletion. + */ + scheduledDeletion?: string | null; + /** + * The watermark profile to apply. + */ + watermark?: StreamDirectUploadWatermark; +}; +type StreamDirectUploadWatermark = { + /** + * The unique identifier for the watermark profile. + */ + id: string; +}; +type StreamUrlUploadParams = { + /** + * Lists the origins allowed to display the video. Enter allowed origin + * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the + * video to be viewed on any origin. + */ + allowedOrigins?: Array; + /** + * A user-defined identifier for the media creator. + */ + creator?: string; + /** + * A user modifiable key-value store used to reference other systems of + * record for managing videos. + */ + meta?: Record; + /** + * Indicates whether the video can be a accessed using the id. When + * set to `true`, a signed token must be generated with a signing key to view the + * video. + */ + requireSignedURLs?: boolean; + /** + * Indicates the date and time at which the video will be deleted. Omit + * the field to indicate no change, or include with a `null` value to remove an + * existing scheduled deletion. If specified, must be at least 30 days from upload + * time. + */ + scheduledDeletion?: string | null; + /** + * The timestamp for a thumbnail image calculated as a percentage value + * of the video's duration. To convert from a second-wise timestamp to a + * percentage, divide the desired timestamp by the total duration of the video. If + * this value is not set, the default thumbnail image is taken from 0s of the + * video. + */ + thumbnailTimestampPct?: number; + /** + * The identifier for the watermark profile + */ + watermarkId?: string; +}; +interface StreamScopedCaptions { + /** + * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language. + * One caption or subtitle file per language is allowed. + * @param language The BCP 47 language tag for the caption or subtitle. + * @param input The caption or subtitle stream to upload. + * @returns The created caption entry. + * @throws {NotFoundError} if the video is not found + * @throws {BadRequestError} if the language or file is invalid + * @throws {InternalError} if an unexpected error occurs + */ + upload(language: string, input: ReadableStream): Promise; + /** + * Generate captions or subtitles for the provided language via AI. + * @param language The BCP 47 language tag to generate. + * @returns The generated caption entry. + * @throws {NotFoundError} if the video is not found + * @throws {BadRequestError} if the language is invalid + * @throws {StreamError} if a generated caption already exists + * @throws {StreamError} if the video duration is too long + * @throws {StreamError} if the video is missing audio + * @throws {StreamError} if the requested language is not supported + * @throws {InternalError} if an unexpected error occurs + */ + generate(language: string): Promise; + /** + * Lists the captions or subtitles. + * Use the language parameter to filter by a specific language. + * @param language The optional BCP 47 language tag to filter by. + * @returns The list of captions or subtitles. + * @throws {NotFoundError} if the video or caption is not found + * @throws {InternalError} if an unexpected error occurs + */ + list(language?: string): Promise; + /** + * Removes the captions or subtitles from a video. + * @param language The BCP 47 language tag to remove. + * @returns A promise that resolves when deletion completes. + * @throws {NotFoundError} if the video or caption is not found + * @throws {InternalError} if an unexpected error occurs + */ + delete(language: string): Promise; +} +interface StreamScopedDownloads { + /** + * Generates a download for a video when a video is ready to view. Available + * types are `default` and `audio`. Defaults to `default` when omitted. + * @param downloadType The download type to create. + * @returns The current downloads for the video. + * @throws {NotFoundError} if the video is not found + * @throws {BadRequestError} if the download type is invalid + * @throws {StreamError} if the video duration is too long to generate a download + * @throws {StreamError} if the video is not ready to stream + * @throws {InternalError} if an unexpected error occurs + */ + generate(downloadType?: StreamDownloadType): Promise; + /** + * Lists the downloads created for a video. + * @returns The current downloads for the video. + * @throws {NotFoundError} if the video or downloads are not found + * @throws {InternalError} if an unexpected error occurs + */ + get(): Promise; + /** + * Delete the downloads for a video. Available types are `default` and `audio`. + * Defaults to `default` when omitted. + * @param downloadType The download type to delete. + * @returns A promise that resolves when deletion completes. + * @throws {NotFoundError} if the video or downloads are not found + * @throws {InternalError} if an unexpected error occurs + */ + delete(downloadType?: StreamDownloadType): Promise; +} +interface StreamVideos { + /** + * Lists all videos in a users account. + * @returns The list of videos. + * @throws {BadRequestError} if the parameters are invalid + * @throws {InternalError} if an unexpected error occurs + */ + list(params?: StreamVideosListParams): Promise; +} +interface StreamWatermarks { + /** + * Generate a new watermark profile + * @param input The image stream to upload + * @param params The watermark creation parameters. + * @returns The created watermark profile. + * @throws {BadRequestError} if the parameters are invalid + * @throws {InvalidURLError} if the URL is invalid + * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached + * @throws {InternalError} if an unexpected error occurs + */ + generate(input: ReadableStream, params: StreamWatermarkCreateParams): Promise; + /** + * Generate a new watermark profile + * @param url The image url to upload + * @param params The watermark creation parameters. + * @returns The created watermark profile. + * @throws {BadRequestError} if the parameters are invalid + * @throws {InvalidURLError} if the URL is invalid + * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached + * @throws {InternalError} if an unexpected error occurs + */ + generate(url: string, params: StreamWatermarkCreateParams): Promise; + /** + * Lists all watermark profiles for an account. + * @returns The list of watermark profiles. + * @throws {InternalError} if an unexpected error occurs + */ + list(): Promise; + /** + * Retrieves details for a single watermark profile. + * @param watermarkId The watermark profile identifier. + * @returns The watermark profile details. + * @throws {NotFoundError} if the watermark is not found + * @throws {InternalError} if an unexpected error occurs + */ + get(watermarkId: string): Promise; + /** + * Deletes a watermark profile. + * @param watermarkId The watermark profile identifier. + * @returns A promise that resolves when deletion completes. + * @throws {NotFoundError} if the watermark is not found + * @throws {InternalError} if an unexpected error occurs + */ + delete(watermarkId: string): Promise; +} +type StreamUpdateVideoParams = { + /** + * Lists the origins allowed to display the video. Enter allowed origin + * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the + * video to be viewed on any origin. + */ + allowedOrigins?: Array; + /** + * A user-defined identifier for the media creator. + */ + creator?: string; + /** + * The maximum duration in seconds for a video upload. Can be set for a + * video that is not yet uploaded to limit its duration. Uploads that exceed the + * specified duration will fail during processing. A value of `-1` means the value + * is unknown. + */ + maxDurationSeconds?: number; + /** + * A user modifiable key-value store used to reference other systems of + * record for managing videos. + */ + meta?: Record; + /** + * Indicates whether the video can be a accessed using the id. When + * set to `true`, a signed token must be generated with a signing key to view the + * video. + */ + requireSignedURLs?: boolean; + /** + * Indicates the date and time at which the video will be deleted. Omit + * the field to indicate no change, or include with a `null` value to remove an + * existing scheduled deletion. If specified, must be at least 30 days from upload + * time. + */ + scheduledDeletion?: string | null; + /** + * The timestamp for a thumbnail image calculated as a percentage value + * of the video's duration. To convert from a second-wise timestamp to a + * percentage, divide the desired timestamp by the total duration of the video. If + * this value is not set, the default thumbnail image is taken from 0s of the + * video. + */ + thumbnailTimestampPct?: number; +}; +type StreamCaption = { + /** + * Whether the caption was generated via AI. + */ + generated?: boolean; + /** + * The language label displayed in the native language to users. + */ + label: string; + /** + * The language tag in BCP 47 format. + */ + language: string; + /** + * The status of a generated caption. + */ + status?: 'ready' | 'inprogress' | 'error'; +}; +type StreamDownloadStatus = 'ready' | 'inprogress' | 'error'; +type StreamDownloadType = 'default' | 'audio'; +type StreamDownload = { + /** + * Indicates the progress as a percentage between 0 and 100. + */ + percentComplete: number; + /** + * The status of a generated download. + */ + status: StreamDownloadStatus; + /** + * The URL to access the generated download. + */ + url?: string; +}; +/** + * An object with download type keys. Each key is optional and only present if that + * download type has been created. + */ +type StreamDownloadGetResponse = { + /** + * The audio-only download. Only present if this download type has been created. + */ + audio?: StreamDownload; + /** + * The default video download. Only present if this download type has been created. + */ + default?: StreamDownload; +}; +type StreamWatermarkPosition = 'upperRight' | 'upperLeft' | 'lowerLeft' | 'lowerRight' | 'center'; +type StreamWatermark = { + /** + * The unique identifier for a watermark profile. + */ + id: string; + /** + * The size of the image in bytes. + */ + size: number; + /** + * The height of the image in pixels. + */ + height: number; + /** + * The width of the image in pixels. + */ + width: number; + /** + * The date and a time a watermark profile was created. + */ + created: string; + /** + * The source URL for a downloaded image. If the watermark profile was created via + * direct upload, this field is null. + */ + downloadedFrom: string | null; + /** + * A short description of the watermark profile. + */ + name: string; + /** + * The translucency of the image. A value of `0.0` makes the image completely + * transparent, and `1.0` makes the image completely opaque. Note that if the image + * is already semi-transparent, setting this to `1.0` will not make the image + * completely opaque. + */ + opacity: number; + /** + * The whitespace between the adjacent edges (determined by position) of the video + * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded + * video width or length, as determined by the algorithm. + */ + padding: number; + /** + * The size of the image relative to the overall size of the video. This parameter + * will adapt to horizontal and vertical videos automatically. `0.0` indicates no + * scaling (use the size of the image as-is), and `1.0 `fills the entire video. + */ + scale: number; + /** + * The location of the image. Valid positions are: `upperRight`, `upperLeft`, + * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the + * `padding` parameter. + */ + position: StreamWatermarkPosition; +}; +type StreamWatermarkCreateParams = { + /** + * A short description of the watermark profile. + */ + name?: string; + /** + * The translucency of the image. A value of `0.0` makes the image completely + * transparent, and `1.0` makes the image completely opaque. Note that if the + * image is already semi-transparent, setting this to `1.0` will not make the + * image completely opaque. + */ + opacity?: number; + /** + * The whitespace between the adjacent edges (determined by position) of the + * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully + * padded video width or length, as determined by the algorithm. + */ + padding?: number; + /** + * The size of the image relative to the overall size of the video. This + * parameter will adapt to horizontal and vertical videos automatically. `0.0` + * indicates no scaling (use the size of the image as-is), and `1.0 `fills the + * entire video. + */ + scale?: number; + /** + * The location of the image. + */ + position?: StreamWatermarkPosition; +}; +type StreamVideosListParams = { + /** + * The maximum number of videos to return. + */ + limit?: number; + /** + * Return videos created before this timestamp. + * (RFC3339/RFC3339Nano) + */ + before?: string; + /** + * Comparison operator for the `before` field. + * @default 'lt' + */ + beforeComp?: StreamPaginationComparison; + /** + * Return videos created after this timestamp. + * (RFC3339/RFC3339Nano) + */ + after?: string; + /** + * Comparison operator for the `after` field. + * @default 'gte' + */ + afterComp?: StreamPaginationComparison; +}; +type StreamPaginationComparison = 'eq' | 'gt' | 'gte' | 'lt' | 'lte'; +/** + * Error object for Stream binding operations. + */ +interface StreamError extends Error { + readonly code: number; + readonly statusCode: number; + readonly message: string; + readonly stack?: string; +} +interface InternalError extends StreamError { + name: 'InternalError'; +} +interface BadRequestError extends StreamError { + name: 'BadRequestError'; +} +interface NotFoundError extends StreamError { + name: 'NotFoundError'; +} +interface ForbiddenError extends StreamError { + name: 'ForbiddenError'; +} +interface RateLimitedError extends StreamError { + name: 'RateLimitedError'; +} +interface QuotaReachedError extends StreamError { + name: 'QuotaReachedError'; +} +interface MaxFileSizeError extends StreamError { + name: 'MaxFileSizeError'; +} +interface InvalidURLError extends StreamError { + name: 'InvalidURLError'; +} +interface AlreadyUploadedError extends StreamError { + name: 'AlreadyUploadedError'; +} +interface TooManyWatermarksError extends StreamError { + name: 'TooManyWatermarksError'; +} +type MarkdownDocument = { + name: string; + blob: Blob; +}; +type ConversionResponse = { + id: string; + name: string; + mimeType: string; + format: 'markdown'; + tokens: number; + data: string; +} | { + id: string; + name: string; + mimeType: string; + format: 'error'; + error: string; +}; +type ImageConversionOptions = { + descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de'; +}; +type EmbeddedImageConversionOptions = ImageConversionOptions & { + convert?: boolean; + maxConvertedImages?: number; +}; +type ConversionOptions = { + html?: { + images?: EmbeddedImageConversionOptions & { + convertOGImage?: boolean; + }; + hostname?: string; + cssSelector?: string; + }; + docx?: { + images?: EmbeddedImageConversionOptions; + }; + image?: ImageConversionOptions; + pdf?: { + images?: EmbeddedImageConversionOptions; + metadata?: boolean; + }; +}; +type ConversionRequestOptions = { + gateway?: GatewayOptions; + extraHeaders?: object; + conversionOptions?: ConversionOptions; +}; +type SupportedFileFormat = { + mimeType: string; + extension: string; +}; +declare abstract class ToMarkdownService { + transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise; + transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise; + supported(): Promise; +} +declare namespace TailStream { + interface Header { + readonly name: string; + readonly value: string; + } + interface FetchEventInfo { + readonly type: "fetch"; + readonly method: string; + readonly url: string; + readonly cfJson?: object; + readonly headers: Header[]; + } + interface JsRpcEventInfo { + readonly type: "jsrpc"; + } + interface ScheduledEventInfo { + readonly type: "scheduled"; + readonly scheduledTime: Date; + readonly cron: string; + } + interface AlarmEventInfo { + readonly type: "alarm"; + readonly scheduledTime: Date; + } + interface QueueEventInfo { + readonly type: "queue"; + readonly queueName: string; + readonly batchSize: number; + } + interface EmailEventInfo { + readonly type: "email"; + readonly mailFrom: string; + readonly rcptTo: string; + readonly rawSize: number; + } + interface TraceEventInfo { + readonly type: "trace"; + readonly traces: (string | null)[]; + } + interface HibernatableWebSocketEventInfoMessage { + readonly type: "message"; + } + interface HibernatableWebSocketEventInfoError { + readonly type: "error"; + } + interface HibernatableWebSocketEventInfoClose { + readonly type: "close"; + readonly code: number; + readonly wasClean: boolean; + } + interface HibernatableWebSocketEventInfo { + readonly type: "hibernatableWebSocket"; + readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage; + } + interface CustomEventInfo { + readonly type: "custom"; + } + interface FetchResponseInfo { + readonly type: "fetch"; + readonly statusCode: number; + } + interface ConnectEventInfo { + readonly type: "connect"; + } + type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound" | "internalError"; + interface ScriptVersion { + readonly id: string; + readonly tag?: string; + readonly message?: string; + } + interface TracePreviewInfo { + readonly id: string; + readonly slug: string; + readonly name: string; + } + interface Onset { + readonly type: "onset"; + readonly attributes: Attribute[]; + // id for the span being opened by this Onset event. + readonly spanId: string; + readonly dispatchNamespace?: string; + readonly entrypoint?: string; + readonly executionModel: string; + readonly scriptName?: string; + readonly scriptTags?: string[]; + readonly scriptVersion?: ScriptVersion; + readonly preview?: TracePreviewInfo; + readonly info: FetchEventInfo | ConnectEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo; + } + interface Outcome { + readonly type: "outcome"; + readonly outcome: EventOutcome; + readonly cpuTime: number; + readonly wallTime: number; + } + interface SpanOpen { + readonly type: "spanOpen"; + readonly name: string; + // id for the span being opened by this SpanOpen event. + readonly spanId: string; + readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes; + } + interface SpanClose { + readonly type: "spanClose"; + readonly outcome: EventOutcome; + } + interface DiagnosticChannelEvent { + readonly type: "diagnosticChannel"; + readonly channel: string; + readonly message: any; + } + interface Exception { + readonly type: "exception"; + readonly name: string; + readonly message: string; + readonly stack?: string; + } + interface Log { + readonly type: "log"; + readonly level: "debug" | "error" | "info" | "log" | "warn"; + readonly message: object; + } + interface DroppedEventsDiagnostic { + readonly diagnosticsType: "droppedEvents"; + readonly count: number; + } + interface StreamDiagnostic { + readonly type: 'streamDiagnostic'; + // To add new diagnostic types, define a new interface and add it to this union type. + readonly diagnostic: DroppedEventsDiagnostic; + } + // This marks the worker handler return information. + // This is separate from Outcome because the worker invocation can live for a long time after + // returning. For example - Websockets that return an http upgrade response but then continue + // streaming information or SSE http connections. + interface Return { + readonly type: "return"; + readonly info?: FetchResponseInfo; + } + interface Attribute { + readonly name: string; + readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[]; + } + interface Attributes { + readonly type: "attributes"; + readonly info: Attribute[]; + } + type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | StreamDiagnostic | Return | Attributes; + // Context in which this trace event lives. + interface SpanContext { + // Single id for the entire top-level invocation + // This should be a new traceId for the first worker stage invoked in the eyeball request and then + // same-account service-bindings should reuse the same traceId but cross-account service-bindings + // should use a new traceId. + readonly traceId: string; + // spanId in which this event is handled + // for Onset and SpanOpen events this would be the parent span id + // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events + // For Hibernate and Mark this would be the span under which they were emitted. + // spanId is not set ONLY if: + // 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; + } + interface TailEvent { + // invocation id of the currently invoked worker stage. + // invocation id will always be unique to every Onset event and will be the same until the Outcome event. + readonly invocationId: string; + // Inherited spanContext for this event. + readonly spanContext: SpanContext; + readonly timestamp: Date; + readonly sequence: number; + readonly event: Event; + } + type TailEventHandler = (event: TailEvent) => void | Promise; + type TailEventHandlerObject = { + outcome?: TailEventHandler; + spanOpen?: TailEventHandler; + spanClose?: TailEventHandler; + diagnosticChannel?: TailEventHandler; + exception?: TailEventHandler; + log?: TailEventHandler; + return?: TailEventHandler; + attributes?: TailEventHandler; + }; + type TailEventHandlerType = TailEventHandler | TailEventHandlerObject; +} +// Copyright (c) 2022-2023 Cloudflare, Inc. +// Licensed under the Apache 2.0 license found in the LICENSE file or at: +// https://opensource.org/licenses/Apache-2.0 +/** + * Data types supported for holding vector metadata. + */ +type VectorizeVectorMetadataValue = string | number | boolean | string[]; +/** + * Additional information to associate with a vector. + */ +type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record; +type VectorFloatArray = Float32Array | Float64Array; +interface VectorizeError { + code?: number; + error: string; +} +/** + * Comparison logic/operation to use for metadata filtering. + * + * This list is expected to grow as support for more operations are released. + */ +type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte'; +type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin'; +/** + * Filter criteria for vector metadata used to limit the retrieved query result set. + */ +type VectorizeVectorMetadataFilter = { + [field: string]: Exclude | null | { + [Op in VectorizeVectorMetadataFilterOp]?: Exclude | null; + } | { + [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude[]; + }; +}; +/** + * Supported distance metrics for an index. + * Distance metrics determine how other "similar" vectors are determined. + */ +type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product"; +/** + * Metadata return levels for a Vectorize query. + * + * Default to "none". + * + * @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data. + * @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings). + * @property none No indexed metadata will be returned. + */ +type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none"; +interface VectorizeQueryOptions { + topK?: number; + namespace?: string; + returnValues?: boolean; + returnMetadata?: boolean | VectorizeMetadataRetrievalLevel; + filter?: VectorizeVectorMetadataFilter; +} +/** + * Information about the configuration of an index. + */ +type VectorizeIndexConfig = { + dimensions: number; + metric: VectorizeDistanceMetric; +} | { + preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity +}; +/** + * Metadata about an existing index. + * + * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. + * See {@link VectorizeIndexInfo} for its post-beta equivalent. + */ +interface VectorizeIndexDetails { + /** The unique ID of the index */ + readonly id: string; + /** The name of the index. */ + name: string; + /** (optional) A human readable description for the index. */ + description?: string; + /** The index configuration, including the dimension size and distance metric. */ + config: VectorizeIndexConfig; + /** The number of records containing vectors within the index. */ + vectorsCount: number; +} +/** + * Metadata about an existing index. + */ +interface VectorizeIndexInfo { + /** The number of records containing vectors within the index. */ + vectorCount: number; + /** Number of dimensions the index has been configured for. */ + dimensions: number; + /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */ + processedUpToDatetime: number; + /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */ + processedUpToMutation: number; +} +/** + * Represents a single vector value set along with its associated metadata. + */ +interface VectorizeVector { + /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */ + id: string; + /** The vector values */ + values: VectorFloatArray | number[]; + /** The namespace this vector belongs to. */ + namespace?: string; + /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */ + metadata?: Record; +} +/** + * Represents a matched vector for a query along with its score and (if specified) the matching vector information. + */ +type VectorizeMatch = Pick, "values"> & Omit & { + /** The score or rank for similarity, when returned as a result */ + score: number; +}; +/** + * A set of matching {@link VectorizeMatch} for a particular query. + */ +interface VectorizeMatches { + matches: VectorizeMatch[]; + count: number; +} +/** + * Results of an operation that performed a mutation on a set of vectors. + * Here, `ids` is a list of vectors that were successfully processed. + * + * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. + * See {@link VectorizeAsyncMutation} for its post-beta equivalent. + */ +interface VectorizeVectorMutation { + /* List of ids of vectors that were successfully processed. */ + ids: string[]; + /* Total count of the number of processed vectors. */ + count: number; +} +/** + * Result type indicating a mutation on the Vectorize Index. + * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation. + */ +interface VectorizeAsyncMutation { + /** The unique identifier for the async mutation operation containing the changeset. */ + mutationId: string; +} +/** + * A Vectorize Vector Search Index for querying vectors/embeddings. + * + * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. + * See {@link Vectorize} for its new implementation. + */ +declare abstract class VectorizeIndex { + /** + * Get information about the currently bound index. + * @returns A promise that resolves with information about the current index. + */ + public describe(): Promise; + /** + * Use the provided vector to perform a similarity search across the index. + * @param vector Input vector that will be used to drive the similarity search. + * @param options Configuration options to massage the returned data. + * @returns A promise that resolves with matched and scored vectors. + */ + public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise; + /** + * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown. + * @param vectors List of vectors that will be inserted. + * @returns A promise that resolves with the ids & count of records that were successfully processed. + */ + public insert(vectors: VectorizeVector[]): Promise; + /** + * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values. + * @param vectors List of vectors that will be upserted. + * @returns A promise that resolves with the ids & count of records that were successfully processed. + */ + public upsert(vectors: VectorizeVector[]): Promise; + /** + * Delete a list of vectors with a matching id. + * @param ids List of vector ids that should be deleted. + * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted). + */ + public deleteByIds(ids: string[]): Promise; + /** + * Get a list of vectors with a matching id. + * @param ids List of vector ids that should be returned. + * @returns A promise that resolves with the raw unscored vectors matching the id set. + */ + public getByIds(ids: string[]): Promise; +} +/** + * A Vectorize Vector Search Index for querying vectors/embeddings. + * + * Mutations in this version are async, returning a mutation id. + */ +declare abstract class Vectorize { + /** + * Get information about the currently bound index. + * @returns A promise that resolves with information about the current index. + */ + public describe(): Promise; + /** + * Use the provided vector to perform a similarity search across the index. + * @param vector Input vector that will be used to drive the similarity search. + * @param options Configuration options to massage the returned data. + * @returns A promise that resolves with matched and scored vectors. + */ + public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise; + /** + * Use the provided vector-id to perform a similarity search across the index. + * @param vectorId Id for a vector in the index against which the index should be queried. + * @param options Configuration options to massage the returned data. + * @returns A promise that resolves with matched and scored vectors. + */ + public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise; + /** + * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown. + * @param vectors List of vectors that will be inserted. + * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset. + */ + public insert(vectors: VectorizeVector[]): Promise; + /** + * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values. + * @param vectors List of vectors that will be upserted. + * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset. + */ + public upsert(vectors: VectorizeVector[]): Promise; + /** + * Delete a list of vectors with a matching id. + * @param ids List of vector ids that should be deleted. + * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset. + */ + public deleteByIds(ids: string[]): Promise; + /** + * Get a list of vectors with a matching id. + * @param ids List of vector ids that should be returned. + * @returns A promise that resolves with the raw unscored vectors matching the id set. + */ + public getByIds(ids: string[]): Promise; +} +/** + * The interface for "version_metadata" binding + * providing metadata about the Worker Version using this binding. + */ +type WorkerVersionMetadata = { + /** The ID of the Worker Version using this binding */ + id: string; + /** The tag of the Worker Version using this binding */ + tag: string; + /** The timestamp of when the Worker Version was uploaded */ + timestamp: string; +}; +interface DynamicDispatchLimits { + /** + * Limit CPU time in milliseconds. + */ + cpuMs?: number; + /** + * Limit number of subrequests. + */ + subRequests?: number; +} +interface DynamicDispatchOptions { + /** + * Limit resources of invoked Worker script. + */ + limits?: DynamicDispatchLimits; + /** + * Arguments for outbound Worker script, if configured. + */ + outbound?: { + [key: string]: any; + }; +} +interface DispatchNamespace { + /** + * @param name Name of the Worker script. + * @param args Arguments to Worker script. + * @param options Options for Dynamic Dispatch invocation. + * @returns A Fetcher object that allows you to send requests to the Worker script. + * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown. + */ + get(name: string, args?: { + [key: string]: any; + }, options?: DynamicDispatchOptions): Fetcher; +} +declare module 'cloudflare:workflows' { + /** + * NonRetryableError allows for a user to throw a fatal error + * that makes a Workflow instance fail immediately without triggering a retry + */ + export class NonRetryableError extends Error { + public constructor(message: string, name?: string); + } +} +declare abstract class Workflow { + /** + * Get a handle to an existing instance of the Workflow. + * @param id Id for the instance of this Workflow + * @returns A promise that resolves with a handle for the Instance + */ + public get(id: string): Promise; + /** + * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown. + * @param options Options when creating an instance including id and params + * @returns A promise that resolves with a handle for the Instance + */ + public create(options?: WorkflowInstanceCreateOptions): Promise; + /** + * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown. + * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached. + * @param batch List of Options when creating an instance including name and params + * @returns A promise that resolves with a list of handles for the created instances. + */ + public createBatch(batch: WorkflowInstanceCreateOptions[]): Promise; +} +type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; +type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; +type WorkflowRetentionDuration = WorkflowSleepDuration; +interface WorkflowInstanceCreateOptions { + /** + * An id for your Workflow instance. Must be unique within the Workflow. + */ + id?: string; + /** + * The event payload the Workflow instance is triggered with + */ + params?: PARAMS; + /** + * The retention policy for Workflow instance. + * Defaults to the maximum retention period available for the owner's account. + */ + retention?: { + successRetention?: WorkflowRetentionDuration; + errorRetention?: WorkflowRetentionDuration; + }; +} +type InstanceStatus = { + status: 'queued' // means that instance is waiting to be started (see concurrency limits) + | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running + | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish + | 'waitingForPause' // instance is finishing the current work to pause + | 'unknown'; + error?: { + name: string; + message: string; + }; + output?: unknown; +}; +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; + /** + * Pause the instance. + */ + public pause(): Promise; + /** + * Resume the instance. If it is already running, an error will be thrown. + */ + public resume(): Promise; + /** + * Terminate the instance. If it is errored, terminated or complete, an error will be thrown. + */ + public terminate(): Promise; + /** + * 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(options?: WorkflowInstanceRestartOptions): Promise; + /** + * Returns the current status of the instance. + */ + public status(): Promise; + /** + * Send an event to this instance. + */ + public sendEvent({ type, payload, }: { + type: string; + payload: unknown; + }): Promise; +} diff --git a/examples/cloudflare/wrangler.jsonc b/examples/cloudflare/wrangler.jsonc new file mode 100644 index 0000000..f1b1ae0 --- /dev/null +++ b/examples/cloudflare/wrangler.jsonc @@ -0,0 +1,35 @@ +{ + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "codex-js-cloudflare-example", + "main": "./src/worker/index.ts", + "compatibility_date": "2026-05-12", + "assets": { + "directory": "./dist", + "not_found_handling": "single-page-application", + "run_worker_first": ["/api/*"], + }, + "durable_objects": { + "bindings": [ + { + "name": "CODEX_SESSIONS", + "class_name": "CodexSessionObject", + }, + ], + }, + "migrations": [ + { + "tag": "v1", + "new_sqlite_classes": ["CodexSessionObject"], + }, + ], + "observability": { + "enabled": true, + "head_sampling_rate": 1, + }, + "secrets": { + "required": ["OPENAI_API_KEY"], + }, + "vars": { + "OPENAI_BASE_URL": "https://api.openai.com/v1", + }, +} diff --git a/examples/cloudflare/wrangler.test.jsonc b/examples/cloudflare/wrangler.test.jsonc new file mode 100644 index 0000000..1370955 --- /dev/null +++ b/examples/cloudflare/wrangler.test.jsonc @@ -0,0 +1,23 @@ +{ + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "codex-js-cloudflare-example-test", + "main": "./src/worker/index.ts", + "compatibility_date": "2026-05-12", + "durable_objects": { + "bindings": [ + { + "name": "CODEX_SESSIONS", + "class_name": "CodexSessionObject", + }, + ], + }, + "migrations": [ + { + "tag": "v1", + "new_sqlite_classes": ["CodexSessionObject"], + }, + ], + "vars": { + "OPENAI_BASE_URL": "https://api.openai.com/v1", + }, +} diff --git a/examples/minimal-app-server/README.md b/examples/minimal-app-server/README.md deleted file mode 100644 index 830a321..0000000 --- a/examples/minimal-app-server/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Minimal Codex App Server - -This example is the smallest runnable integration of the public package doorways: - -```txt -CodexChat - -> createCodexAppServerClient - -> createCodexAppServerRuntime - -> createMessageProcessor - -> InMemoryThreadStore + createModelClient + sendOutgoingMessage -``` - -Run it with: - -```bash -pnpm dev:minimal -``` - -The app prompts for an OpenAI API key and stores it in `sessionStorage` for the -current browser session. The local Vite app-server endpoint passes that key into -`createCodexAppServerRuntime`, uses `InMemoryThreadStore` for thread state, and -delivers generated `AppServerEvent` values over the example WebSocket. - -The example also includes app-owned dynamic tools: - -- `billing.lookup_invoice` is visible to the model immediately and resolves - automatically from sample invoice data. -- `billing.refund_invoice` is deferred behind `tool_search` and renders a small - approval panel before the app resolves the generated `RequestId`. -- `request_user_input` is available in Plan mode so the default T3 composer can - render Codex's structured user-feedback prompt and resolve it by `RequestId`. -- The Build/Plan toggle demonstrates Codex collaboration mode. Plan responses - can include `` blocks, which render as T3 proposed-plan cards - and can be sent back as `PLEASE IMPLEMENT THIS PLAN:` follow-ups. - -The example intentionally avoids product-specific host code, Cloudflare, -Durable Objects, React Router, unstable T3 imports, unstable Codex imports, and -package-internal paths. Codex behavior enters through the stable `/server` -surface; UI rendering enters through the stable `/react` surface. diff --git a/examples/minimal-app-server/src/minimal-app-server.ts b/examples/minimal-app-server/src/minimal-app-server.ts deleted file mode 100644 index 1bf6bd7..0000000 --- a/examples/minimal-app-server/src/minimal-app-server.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { - CodexAppServerRequestError, - InMemoryThreadStore, - ThreadEventPersistenceMode, - ThreadMemoryMode, - CodexAppServerMessageProcessor, - createCodexAppServerRuntime, - createModelClient, - type AppServerEvent, - type ClientRequest, - type JSONRPCErrorError, - type ModelClient, - type RequestId, - type Result, -} from "@jrkropp/codex-js/server"; -import { billingDynamicTools } from "./billing-tools"; - -export type MinimalCodexEventSocket = { - close?: () => void; - send(event: AppServerEvent): void; -}; - -export type MinimalCodexAppServerContext = { - apiKey?: string | null; -}; - -export type MinimalCodexAppServerOptions = { - createModelClient?: (input: { - context?: MinimalCodexAppServerContext; - threadId: string; - }) => ModelClient; - fetch?: typeof fetch; -}; - -export type MinimalCodexAppServer = { - createProcessor(input?: { - connectionId?: number; - }): CodexAppServerMessageProcessor; - eventsForThread(threadId: string): readonly AppServerEvent[]; - handle( - request: ClientRequest, - context?: MinimalCodexAppServerContext, - ): Promise; - handleWithProcessor( - processor: CodexAppServerMessageProcessor, - request: ClientRequest, - context?: MinimalCodexAppServerContext, - ): Promise; - processor: CodexAppServerMessageProcessor; - rejectServerRequest( - threadId: string, - requestId: RequestId, - error: JSONRPCErrorError, - context?: MinimalCodexAppServerContext, - ): Promise; - resolveServerRequest( - threadId: string, - requestId: RequestId, - response: Result, - context?: MinimalCodexAppServerContext, - ): Promise; - subscribe(threadId: string, socket: MinimalCodexEventSocket): () => void; -}; - -export function createMinimalCodexAppServer( - options: MinimalCodexAppServerOptions = {}, -): MinimalCodexAppServer { - const store = new InMemoryThreadStore(); - const eventLog = new Map(); - const subscribers = new Map>(); - const runtime = createCodexAppServerRuntime({ - store, - createModelClient({ context, threadId }) { - if (options.createModelClient) { - return options.createModelClient({ context, threadId: String(threadId) }); - } - const apiKey = context?.apiKey?.trim(); - if (!apiKey) { - throw new CodexAppServerRequestError( - { - code: -32001, - message: "Enter an OpenAI API key to send a message.", - }, - 401, - ); - } - return createModelClient({ - apiKey, - fetch: options.fetch, - installationId: "minimal-app-server", - sessionId: String(threadId), - threadId, - }); - }, - modelClientCacheKey: ({ context, threadId }) => - `${threadId}:${context?.apiKey ? "api-key" : "missing-key"}`, - sendOutgoingMessage(event, { threadId }) { - const key = String(threadId); - const events = eventLog.get(key) ?? []; - events.push(event); - eventLog.set(key, events); - for (const socket of subscribers.get(key) ?? []) { - socket.send(event); - } - }, - buildCreateThreadParams({ params, threadId }) { - return { - base_instructions: { - text: - params.baseInstructions ?? - "You are Codex running inside the minimal codex-js example. Be concise and helpful. Use the billing tools when the user asks about sample invoices or refunds. In Plan mode, ask focused questions with request_user_input when more direction is needed, and place final proposed plans inside and tags.", - }, - dynamic_tools: [...billingDynamicTools], - event_persistence_mode: ThreadEventPersistenceMode.Limited, - metadata: { - cwd: params.cwd ?? "/minimal-codex-example", - memory_mode: ThreadMemoryMode.Disabled, - model: params.model ?? "gpt-5-mini", - model_provider: params.modelProvider ?? "openai", - }, - source: "appServer", - thread_id: threadId, - thread_source: - typeof params.threadSource === "string" ? params.threadSource : null, - }; - }, - buildSessionConfiguration() { - return { - collaboration_mode: { - mode: "default", - settings: { - developer_instructions: null, - model: "gpt-5-mini", - reasoning_effort: null, - }, - }, - dynamic_tools: [...billingDynamicTools], - }; - }, - }); - const processor = runtime.createMessageProcessor({ connectionId: 0 }); - - return { - createProcessor(input = {}) { - return runtime.createMessageProcessor({ - connectionId: - input.connectionId ?? Math.floor(Math.random() * Number.MAX_SAFE_INTEGER), - }); - }, - eventsForThread(threadId) { - return eventLog.get(threadId) ?? []; - }, - handle(request, context) { - return processor.processClientRequest(request, context); - }, - handleWithProcessor(processor, request, context) { - return processor.processClientRequest(request, context); - }, - processor, - rejectServerRequest(threadId, requestId, error, context) { - return runtime.rejectServerRequest({ error, requestId, threadId }, context); - }, - resolveServerRequest(threadId, requestId, response, context) { - return runtime.resolveServerRequest( - { requestId, result: response, threadId }, - context, - ); - }, - subscribe(threadId, socket) { - const sockets = subscribers.get(threadId) ?? new Set(); - sockets.add(socket); - subscribers.set(threadId, sockets); - for (const event of eventLog.get(threadId) ?? []) { - socket.send(event); - } - return () => { - sockets.delete(socket); - if (sockets.size === 0) { - subscribers.delete(threadId); - } - }; - }, - }; -} diff --git a/examples/minimal-app-server/vite.config.ts b/examples/minimal-app-server/vite.config.ts deleted file mode 100644 index f814f10..0000000 --- a/examples/minimal-app-server/vite.config.ts +++ /dev/null @@ -1,296 +0,0 @@ -import type { Socket } from "node:net"; -import tailwindcss from "@tailwindcss/vite"; -import { defineConfig, type ViteDevServer } from "vite"; -import { WebSocketServer } from "ws"; -import { codexJsAliases } from "../codex-js-vite-aliases"; - -type MinimalCodexAppServer = ReturnType< - (typeof import("./src/minimal-app-server"))["createMinimalCodexAppServer"] ->; - -type TicketRecord = { - apiKey: string | null; - expiresAt: number; -}; - -export default defineConfig({ - resolve: { - alias: codexJsAliases, - dedupe: ["react", "react-dom"], - }, - server: { - host: "localhost", - port: 1466, - }, - plugins: [ - tailwindcss(), - { - name: "minimal-codex-app-server", - configureServer(server) { - const wsServer = new WebSocketServer({ noServer: true }); - const appServer = createAppServerLoader(server); - const tickets = new Map(); - - server.middlewares.use((request, response, next) => { - if ( - request.method !== "POST" || - !request.url?.startsWith("/api/codex/app-server/ticket") - ) { - next(); - return; - } - const ticket = crypto.randomUUID(); - const expiresAt = Date.now() + 60_000; - tickets.set(ticket, { - apiKey: request.headers["x-openai-api-key"]?.toString() ?? null, - expiresAt, - }); - response.setHeader("content-type", "application/json"); - response.end(JSON.stringify({ expires_at: expiresAt, ticket })); - }); - - server.httpServer?.on("upgrade", (request, socket, head) => { - const url = request.url - ? new URL(request.url, "http://localhost") - : null; - if (url?.pathname !== "/api/codex/app-server") { - return; - } - const ticket = url.searchParams.get("ticket"); - const ticketRecord = ticket ? tickets.get(ticket) : null; - if ( - !ticket || - !ticketRecord || - ticketRecord.expiresAt <= Date.now() - ) { - socket.destroy(); - return; - } - tickets.delete(ticket); - void appServer().then((minimalAppServer) => { - wsServer.handleUpgrade( - request, - socket as Socket, - head, - (webSocket) => { - const codexSocket = webSocket as unknown as MinimalWebSocket; - const processor = minimalAppServer.createProcessor(); - const pendingServerRequestThreads = new Map< - string | number, - string - >(); - const subscriptions = new Map void>(); - const subscribeThread = (threadId: string) => { - if (subscriptions.has(threadId)) { - return; - } - subscriptions.set( - threadId, - minimalAppServer.subscribe(threadId, { - send(event) { - const message = outgoingMessageFromEvent(event); - if (!message) { - return; - } - if (event.type === "server_request") { - pendingServerRequestThreads.set( - event.request.id, - threadId, - ); - } - codexSocket.send(JSON.stringify(message)); - }, - }), - ); - }; - - codexSocket.on("message", (message) => { - const parsed = parseJsonMessage(message); - if (!isJsonObject(parsed)) { - return; - } - const id = parsed.id; - if ( - (typeof id === "string" || typeof id === "number") && - "result" in parsed - ) { - const threadId = pendingServerRequestThreads.get(id); - if (threadId) { - void minimalAppServer.resolveServerRequest( - threadId, - id, - parsed.result, - ); - } - return; - } - if ( - (typeof id === "string" || typeof id === "number") && - isJsonObject(parsed.error) - ) { - const threadId = pendingServerRequestThreads.get(id); - if (threadId) { - void minimalAppServer.rejectServerRequest(threadId, id, { - code: - typeof parsed.error.code === "number" - ? parsed.error.code - : -32000, - message: - typeof parsed.error.message === "string" - ? parsed.error.message - : "Request failed.", - }); - } - return; - } - if ( - typeof parsed.method !== "string" || - (typeof id !== "string" && typeof id !== "number") - ) { - return; - } - const threadId = threadIdFromClientRequest(parsed); - if (threadId) { - subscribeThread(threadId); - } - void minimalAppServer - .handleWithProcessor(processor, parsed as never, { - apiKey: ticketRecord.apiKey, - }) - .then((result) => { - const responseThreadId = threadIdFromResponse(result); - if (responseThreadId) { - subscribeThread(responseThreadId); - } - codexSocket.send(JSON.stringify({ id, result })); - }) - .catch((error) => { - codexSocket.send( - JSON.stringify({ error: jsonRpcError(error), id }), - ); - }); - }); - codexSocket.on("close", () => { - for (const unsubscribe of subscriptions.values()) { - unsubscribe(); - } - void processor.connectionClosed(); - }); - }, - ); - }); - }); - }, - }, - ], -}); - -function createAppServerLoader( - server: ViteDevServer, -): () => Promise { - let appServer: MinimalCodexAppServer | null = null; - return async () => { - if (appServer) { - return appServer; - } - const module = await server.ssrLoadModule("/src/minimal-app-server.ts"); - appServer = module.createMinimalCodexAppServer() as MinimalCodexAppServer; - return appServer; - }; -} - -type MinimalWebSocket = { - on(event: "close", listener: () => void): void; - on(event: "message", listener: (message: unknown) => void): void; - send(message: string): void; -}; - -function outgoingMessageFromEvent(event: { - notification?: unknown; - request?: { id: string | number }; - type: string; -}): unknown | null { - if (event.type === "server_notification") { - return event.notification ?? null; - } - if (event.type === "server_request") { - return event.request ?? null; - } - return null; -} - -function threadIdFromClientRequest(request: { - params?: unknown; -}): string | null { - const params = request.params as - | { threadId?: unknown; thread_id?: unknown } - | undefined; - if (typeof params?.threadId === "string") { - return params.threadId; - } - if (typeof params?.thread_id === "string") { - return params.thread_id; - } - return null; -} - -function threadIdFromResponse(response: unknown): string | null { - const threadId = (response as { thread?: { id?: unknown } } | undefined) - ?.thread?.id; - return typeof threadId === "string" ? threadId : null; -} - -function jsonRpcError(error: unknown) { - if ( - isJsonObject(error) && - typeof error.code === "number" && - typeof error.message === "string" - ) { - return error; - } - const nested = (error as { error?: unknown } | undefined)?.error; - if ( - isJsonObject(nested) && - typeof nested.code === "number" && - typeof nested.message === "string" - ) { - return nested; - } - return { - code: -32000, - message: error instanceof Error ? error.message : "Codex request failed.", - }; -} - -function parseJsonMessage(message: unknown): unknown { - const text = messageToString(message); - try { - return JSON.parse(text) as unknown; - } catch { - return null; - } -} - -function messageToString(message: unknown): string { - if (Buffer.isBuffer(message)) { - return message.toString("utf8"); - } - if (message instanceof ArrayBuffer) { - return Buffer.from(message).toString("utf8"); - } - if (ArrayBuffer.isView(message)) { - return Buffer.from( - message.buffer, - message.byteOffset, - message.byteLength, - ).toString("utf8"); - } - if (Array.isArray(message)) { - return Buffer.concat(message).toString("utf8"); - } - return String(message); -} - -function isJsonObject(value: unknown): value is Record { - return typeof value === "object" && value !== null && !Array.isArray(value); -} diff --git a/examples/node-local/README.md b/examples/node-local/README.md new file mode 100644 index 0000000..4e1556a --- /dev/null +++ b/examples/node-local/README.md @@ -0,0 +1,41 @@ +# codex-js Node Local Example + +Small local integration of the public package surfaces: + +```txt +CodexChat + -> createCodexAppServerClient + -> Vite WebSocket endpoint + -> createCodexAppServerConnection + -> createCodexAppServer + -> InMemoryThreadStore + createModelClient + dynamic tools +``` + +## Run + +Create `examples/node-local/.env.local`: + +```env +OPENAI_API_KEY=sk-... +OPENAI_MODEL=gpt-5-mini +``` + +Then run from the repository root: + +```sh +pnpm dev:node-local +``` + +Open `http://localhost:1466`. + +## What This Example Shows + +- A local Node/Vite app-server endpoint that keeps `OPENAI_API_KEY` server-side. +- One-time WebSocket tickets from `POST /api/codex/session`. +- `createCodexAppServer` as the high-level server entrypoint. +- `createCodexAppServerConnection` as the platform-neutral WebSocket bridge. +- `threadStore` with `InMemoryThreadStore`. +- A server-executed dynamic tool: `billing.lookup_invoice`. +- A visible client-resolved dynamic tool: `billing.refund_invoice`, rendered as an approval panel. + +This example avoids Cloudflare, Durable Objects, package-internal imports, and browser-provided API keys. Use `examples/cloudflare` for the deployable Worker + Durable Object version. diff --git a/examples/node-local/index.html b/examples/node-local/index.html new file mode 100644 index 0000000..0081219 --- /dev/null +++ b/examples/node-local/index.html @@ -0,0 +1,16 @@ + + + + + + + codex-js Node Local Example + + +

+ + + diff --git a/examples/minimal-app-server/package.json b/examples/node-local/package.json similarity index 83% rename from examples/minimal-app-server/package.json rename to examples/node-local/package.json index 72df238..d91574f 100644 --- a/examples/minimal-app-server/package.json +++ b/examples/node-local/package.json @@ -1,10 +1,10 @@ { - "name": "@jrkropp/codex-js-minimal-app-server-example", + "name": "@jrkropp/codex-js-node-local-example", "private": true, "type": "module", "scripts": { "dev": "vite --host localhost --port 1466", - "build": "npm run typecheck && vite build", + "build": "pnpm typecheck && vite build", "typecheck": "tsc -p tsconfig.json --pretty false" }, "dependencies": { diff --git a/examples/minimal-app-server/src/main.tsx b/examples/node-local/src/client/main.tsx similarity index 53% rename from examples/minimal-app-server/src/main.tsx rename to examples/node-local/src/client/main.tsx index 7ad8c0c..f2b24fd 100644 --- a/examples/minimal-app-server/src/main.tsx +++ b/examples/node-local/src/client/main.tsx @@ -1,78 +1,58 @@ -import React from "react"; -import { useCallback, useMemo, useRef, useState } from "react"; +import { + StrictMode, + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from "react"; import { createRoot } from "react-dom/client"; import { createCodexAppServerClient, - type ServerRequest, type CodexAppServer, } from "@jrkropp/codex-js/client"; import { CodexChat, + createDefaultTurnStartParams, type ChatComposerHandle, type CodexChatComposerCommand, type CodexChatComposerSkill, type CodexChatInteractionMode, type CodexChatPendingRequestRenderContext, } from "@jrkropp/codex-js-react"; -import { createDefaultTurnStartParams } from "@jrkropp/codex-js-react"; import { billingInvoiceById, billingSuggestedPrompts, isBillingDynamicToolRequest, objectArguments, - resolveBillingDynamicToolRequest, -} from "./billing-tools"; + resolveRefundInvoiceRequest, +} from "../shared/billing"; +import { + CODEX_SESSION_PATH, + CODEX_STATUS_PATH, + type CodexSessionResponse, + type CodexStatusResponse, +} from "../shared/routes"; import "./styles.css"; -const threadId = "00000000-0000-4000-8000-000000000146"; -const apiKeyStorageKey = "codex-js:minimal-openai-api-key"; -const modelStorageKey = "codex-js:minimal-openai-model"; -const defaultModel = "gpt-5-mini"; - -function appServerWebSocketUrl(path: string): string { - const url = new URL(path, window.location.origin); - url.protocol = url.protocol === "https:" ? "wss:" : "ws:"; - return url.toString(); -} +type AppStatus = + | { kind: "loading" } + | { kind: "ready"; model: string; threadId: string } + | { kind: "missing-key"; model: string; threadId: string } + | { kind: "error"; message: string }; -function MinimalApp() { - const [apiKey, setApiKey] = useState(() => sessionStorage.getItem(apiKeyStorageKey) ?? ""); - const [draftApiKey, setDraftApiKey] = useState(apiKey); - const [model, setModel] = useState(() => sessionStorage.getItem(modelStorageKey) ?? defaultModel); +function NodeLocalApp() { + const [status, setStatus] = useState({ kind: "loading" }); const [interactionMode, setInteractionMode] = useState("default"); const [commandNotice, setCommandNotice] = useState(null); const composerRef = useRef(null); - const hasApiKey = apiKey.trim().length > 0; const appServer: CodexAppServer = useMemo( () => createCodexAppServerClient({ - url: async () => { - const response = await fetch("/api/codex/app-server/ticket", { - method: "POST", - headers: { - "x-openai-api-key": apiKey, - }, - }); - const { ticket } = (await response.json()) as { ticket: string }; - return appServerWebSocketUrl(`/api/codex/app-server?ticket=${encodeURIComponent(ticket)}`); - }, + url: createSessionWebSocketUrl, }), - [apiKey], - ); - const handleServerRequest = useCallback( - (request: ServerRequest) => { - if ( - isBillingDynamicToolRequest(request) && - request.params.tool === "lookup_invoice" - ) { - void appServer.resolveServerRequest( - request.id, - resolveBillingDynamicToolRequest(request), - ); - } - }, - [appServer], + [], ); const renderPendingRequest = useCallback( (context: CodexChatPendingRequestRenderContext) => { @@ -104,14 +84,7 @@ function MinimalApp() { label: "/new", description: "Start a separate chat in a host app", disabled: true, - unavailableReason: "This minimal example uses one fixed thread.", - }, - { - name: "realtime", - label: "/realtime", - description: "Start realtime voice when a host provides it", - disabled: true, - unavailableReason: "Realtime voice is not configured in this example.", + unavailableReason: "This local example uses one fixed thread.", }, ], [], @@ -130,24 +103,48 @@ function MinimalApp() { [], ); - function saveApiKey(event: React.FormEvent) { - event.preventDefault(); - const nextApiKey = draftApiKey.trim(); - if (nextApiKey) { - sessionStorage.setItem(apiKeyStorageKey, nextApiKey); - } else { - sessionStorage.removeItem(apiKeyStorageKey); - } - sessionStorage.setItem(modelStorageKey, model.trim() || defaultModel); - setApiKey(nextApiKey); - setModel(model.trim() || defaultModel); - } - - function clearApiKey() { - sessionStorage.removeItem(apiKeyStorageKey); - setApiKey(""); - setDraftApiKey(""); - } + useEffect(() => { + let cancelled = false; + void fetch(CODEX_STATUS_PATH) + .then(async (response) => { + if (!response.ok) { + throw new Error(`Status request failed with ${response.status}.`); + } + return (await response.json()) as CodexStatusResponse; + }) + .then((nextStatus) => { + if (cancelled) { + return; + } + setStatus( + nextStatus.configured + ? { + kind: "ready", + model: nextStatus.model, + threadId: nextStatus.threadId, + } + : { + kind: "missing-key", + model: nextStatus.model, + threadId: nextStatus.threadId, + }, + ); + }) + .catch((error) => { + if (!cancelled) { + setStatus({ + kind: "error", + message: + error instanceof Error + ? error.message + : "Unable to load the local app-server status.", + }); + } + }); + return () => { + cancelled = true; + }; + }, []); function applySuggestedPrompt(prompt: string) { if (prompt.toLowerCase().includes("plan")) { @@ -159,30 +156,29 @@ function MinimalApp() { function handleComposerCommand(command: string) { if (command === "billing") { - applySuggestedPrompt("Use the billing tools to look up invoice INV-1001."); + applySuggestedPrompt( + "Use the billing tools to look up invoice INV-1001.", + ); setCommandNotice("Inserted a billing-tool prompt from /billing."); return; } - setCommandNotice(`/${command} is handled by the package or unavailable here.`); + setCommandNotice( + `/${command} is handled by the package or unavailable here.`, + ); } return (
-

Minimal Codex App Server

-

CodexChat + createCodexAppServerClient + createMessageProcessor

+

codex-js Node Local

+

Vite dev server + app-server connection + server-side tools

-
{hasApiKey ? `OpenAI ${model}` : "Enter API key"}
- {hasApiKey ? ( - - ) : null} +
{statusLabel(status)}
- {hasApiKey ? ( + {status.kind === "ready" ? (
@@ -200,22 +196,21 @@ function MinimalApp() { ({ threadId })} buildTurnStartParams={(input) => ({ ...createDefaultTurnStartParams(input), - model, + model: status.model, })} - onServerRequest={handleServerRequest} renderPendingRequest={renderPendingRequest} onCommand={handleComposerCommand} renderBannerItems={() => @@ -236,48 +231,75 @@ function MinimalApp() {
) : (
-
-
-

Local demo setup

-

Connect OpenAI

-

- Enter an OpenAI API key to run the example against the Responses API. - The key is kept in this browser session and sent only to the local Vite - app-server endpoint. -

-
- - - -
+
+

Local demo setup

+

{setupTitle(status)}

+

{setupMessage(status)}

+ {status.kind === "missing-key" ? ( +
+								OPENAI_API_KEY=sk-...
+							
+ ) : null} +
)}
); } +async function createSessionWebSocketUrl(): Promise { + const response = await fetch(CODEX_SESSION_PATH, { method: "POST" }); + const body = (await response.json()) as + | CodexSessionResponse + | { error?: string }; + if (!response.ok) { + throw new Error( + "error" in body && body.error + ? body.error + : `Session request failed with ${response.status}.`, + ); + } + if (!("webSocketUrl" in body)) { + throw new Error("Session response did not include a WebSocket URL."); + } + return body.webSocketUrl; +} + +function statusLabel(status: AppStatus): string { + switch (status.kind) { + case "ready": + return `OpenAI ${status.model}`; + case "missing-key": + return "Missing OPENAI_API_KEY"; + case "error": + return "App-server error"; + case "loading": + return "Loading"; + } +} + +function setupTitle(status: AppStatus): string { + switch (status.kind) { + case "missing-key": + return "Set the server-side OpenAI key"; + case "error": + return "App-server unavailable"; + case "loading": + case "ready": + return "Starting app-server"; + } +} + +function setupMessage(status: AppStatus): string { + if (status.kind === "missing-key") { + return "Create examples/node-local/.env.local with the key below, then restart pnpm dev:node-local. The browser never receives the key."; + } + if (status.kind === "error") { + return status.message; + } + return "Checking the local app-server configuration."; +} + function BillingRefundPanel({ context, }: { @@ -296,11 +318,11 @@ function BillingRefundPanel({ return (
-

App-owned dynamic tool

+

Client-resolved dynamic tool

Approve refund

- Codex requested billing.refund_invoice. The package owns the - protocol request; this example app owns the business decision. + Codex requested billing.refund_invoice. The app-server + keeps the request pending until this UI resolves it.

@@ -325,7 +347,9 @@ function BillingRefundPanel({ @@ -334,7 +358,7 @@ function BillingRefundPanel({ type="button" disabled={!invoice} onClick={() => - void context.resolve(resolveBillingDynamicToolRequest(request)) + void context.resolve(resolveRefundInvoiceRequest(request)) } > Approve refund @@ -345,7 +369,7 @@ function BillingRefundPanel({ } createRoot(document.getElementById("root")!).render( - - - , + + + , ); diff --git a/examples/minimal-app-server/src/styles.css b/examples/node-local/src/client/styles.css similarity index 96% rename from examples/minimal-app-server/src/styles.css rename to examples/node-local/src/client/styles.css index 369f994..e9a95e6 100644 --- a/examples/minimal-app-server/src/styles.css +++ b/examples/node-local/src/client/styles.css @@ -317,6 +317,17 @@ body { margin: 10px 0 0; } +.setup-code { + background: color-mix(in oklch, var(--foreground) 6%, var(--background)); + border: 1px solid color-mix(in oklch, var(--border) 82%, transparent); + border-radius: 8px; + color: var(--foreground); + font-size: 13px; + margin: 0; + overflow-x: auto; + padding: 12px; +} + .field { display: grid; gap: 8px; diff --git a/examples/node-local/src/server/app-server.ts b/examples/node-local/src/server/app-server.ts new file mode 100644 index 0000000..24fc4b6 --- /dev/null +++ b/examples/node-local/src/server/app-server.ts @@ -0,0 +1,109 @@ +import { + CodexAppServerRequestError, + InMemoryThreadStore, + createCodexAppServer, + createCodexAppServerConnection, + createModelClient, + jsonRpcErrorFromUnknown, + type CodexAppServerConnection, + type CreatedCodexAppServer, + type ModelClient, +} from "@jrkropp/codex-js/server"; +import { billingDynamicTools } from "./billing-tools"; + +const DEFAULT_CWD = "/node-local-codex-example"; +const DEFAULT_MODEL = "gpt-5-mini"; + +export type LocalCodexAppServerOptions = { + apiKey?: string | null; + createModelClient?: (input: { threadId: string }) => ModelClient; + fetch?: typeof fetch; + model?: string | null; +}; + +export type LocalCodexAppServer = CreatedCodexAppServer; + +export type LocalCodexWebSocket = { + close(): void; + on(event: "close", listener: () => void): void; + on(event: "error", listener: (error: unknown) => void): void; + on(event: "message", listener: (message: unknown) => void): void; + send(message: string): void; +}; + +export function createLocalCodexAppServer( + options: LocalCodexAppServerOptions = {}, +): LocalCodexAppServer { + const threadStore = new InMemoryThreadStore(); + const apiKey = options.apiKey?.trim() ?? ""; + const model = options.model?.trim() || DEFAULT_MODEL; + + return createCodexAppServer({ + threadStore, + createModelClient({ threadId }) { + if (options.createModelClient) { + return options.createModelClient({ threadId: String(threadId) }); + } + if (!apiKey) { + throw new CodexAppServerRequestError( + { + code: -32001, + message: + "Set OPENAI_API_KEY in examples/node-local/.env.local and restart the dev server.", + }, + 401, + ); + } + return createModelClient({ + apiKey, + fetch: options.fetch, + installationId: "codex-js-node-local-example", + sessionId: String(threadId), + threadId, + }); + }, + modelClientCacheKey: ({ threadId }) => + `${String(threadId)}:${apiKey ? "configured" : "missing"}`, + dynamicTools: billingDynamicTools, + defaults: { + baseInstructions: + "You are Codex running inside the local Node codex-js example. Be concise and helpful. Use the billing tools when the user asks about sample invoices or refunds. In Plan mode, ask focused questions with request_user_input when more direction is needed, and place final proposed plans inside and tags.", + cwd: DEFAULT_CWD, + model, + modelProvider: "openai", + source: "appServer", + threadSource: "node-local", + }, + }); +} + +export function connectLocalCodexWebSocket(input: { + appServer: LocalCodexAppServer; + socket: LocalCodexWebSocket; +}): CodexAppServerConnection { + const connection = createCodexAppServerConnection(input.appServer, { + send(message) { + input.socket.send(message); + }, + }); + + input.socket.on("message", (message) => { + void connection.accept(message).catch((error) => { + input.socket.send( + JSON.stringify({ + error: jsonRpcErrorFromUnknown(error), + id: null, + jsonrpc: "2.0", + }), + ); + }); + }); + input.socket.on("close", () => { + void connection.close(); + }); + input.socket.on("error", () => { + void connection.close(); + }); + + return connection; +} diff --git a/examples/node-local/src/server/billing-tools.ts b/examples/node-local/src/server/billing-tools.ts new file mode 100644 index 0000000..79bb059 --- /dev/null +++ b/examples/node-local/src/server/billing-tools.ts @@ -0,0 +1,54 @@ +import { + defineDynamicTool, + defineDynamicToolset, + dynamicToolResponse, +} from "@jrkropp/codex-js/server"; +import { billingInvoiceById, objectArguments } from "../shared/billing"; + +export const billingDynamicTools = defineDynamicToolset([ + defineDynamicTool({ + namespace: "billing", + name: "lookup_invoice", + description: "Look up a sample invoice by invoice id.", + inputSchema: { + type: "object", + properties: { + invoiceId: { + type: "string", + description: "Invoice id such as INV-1001.", + }, + }, + required: ["invoiceId"], + additionalProperties: false, + }, + async execute(args) { + const invoice = billingInvoiceById(objectArguments(args).invoiceId); + if (!invoice) { + return dynamicToolResponse.error( + "No matching sample invoice was found.", + ); + } + return dynamicToolResponse.text(JSON.stringify({ invoice }, null, 2)); + }, + }), + defineDynamicTool({ + namespace: "billing", + name: "refund_invoice", + description: "Refund a sample invoice after the user confirms the action.", + inputSchema: { + type: "object", + properties: { + invoiceId: { + type: "string", + description: "Invoice id such as INV-1001.", + }, + reason: { + type: "string", + description: "The reason for the refund.", + }, + }, + required: ["invoiceId", "reason"], + additionalProperties: false, + }, + }), +]); diff --git a/examples/minimal-app-server/src/billing-tools.ts b/examples/node-local/src/shared/billing.ts similarity index 51% rename from examples/minimal-app-server/src/billing-tools.ts rename to examples/node-local/src/shared/billing.ts index 6a0dcc0..49d8014 100644 --- a/examples/minimal-app-server/src/billing-tools.ts +++ b/examples/node-local/src/shared/billing.ts @@ -3,62 +3,21 @@ import type { ServerRequest, } from "@jrkropp/codex-js/server"; -export const billingDynamicTools = [ - { - namespace: "billing", - name: "lookup_invoice", - description: "Look up a sample invoice by invoice id.", - input_schema: { - type: "object", - properties: { - invoiceId: { - type: "string", - description: "Invoice id such as INV-1001.", - }, - }, - required: ["invoiceId"], - additionalProperties: false, - }, - defer_loading: false, - }, - { - namespace: "billing", - name: "refund_invoice", - description: "Refund a sample invoice after the user confirms the action.", - input_schema: { - type: "object", - properties: { - invoiceId: { - type: "string", - description: "Invoice id such as INV-1001.", - }, - reason: { - type: "string", - description: "The reason for the refund.", - }, - }, - required: ["invoiceId", "reason"], - additionalProperties: false, - }, - defer_loading: true, - }, -]; - export const billingSuggestedPrompts = [ "Look up invoice INV-1001.", "Can you refund invoice INV-1001 because the customer was double charged?", - "Find the right billing tool and refund invoice INV-1002 for a duplicate purchase.", + "Refund invoice INV-1002 for a duplicate purchase.", "Plan a safer refund workflow. First ask me two short questions with request_user_input, then return the final plan inside tags.", ]; -type BillingInvoice = { +export type BillingInvoice = { amount: string; customer: string; id: string; status: "open" | "paid" | "refunded"; }; -const billingInvoices: BillingInvoice[] = [ +export const billingInvoices: BillingInvoice[] = [ { amount: "$42.00", customer: "Ada Lovelace", @@ -91,7 +50,7 @@ export function isBillingDynamicToolRequest( ); } -export function resolveBillingDynamicToolRequest( +export function resolveRefundInvoiceRequest( request: Extract, ): DynamicToolCallResponse { const args = objectArguments(request.params.arguments); @@ -103,39 +62,28 @@ export function resolveBillingDynamicToolRequest( ); } - if (request.params.tool === "lookup_invoice") { - return textToolResponse(JSON.stringify({ invoice }, null, 2), true); - } - - if (request.params.tool === "refund_invoice") { - const reason = String(args.reason ?? "No reason provided."); - return textToolResponse( - JSON.stringify( - { - refund: { - amount: invoice.amount, - customer: invoice.customer, - invoiceId: invoice.id, - reason, - refundId: `rf_${invoice.id.toLowerCase().replaceAll("-", "_")}`, - status: "approved", - }, - }, - null, - 2, - ), - true, - ); - } - + const reason = String(args.reason ?? "No reason provided."); return textToolResponse( - `Unsupported billing tool: ${request.params.tool}`, - false, + JSON.stringify( + { + refund: { + amount: invoice.amount, + customer: invoice.customer, + invoiceId: invoice.id, + reason, + refundId: `rf_${invoice.id.toLowerCase().replaceAll("-", "_")}`, + status: "approved", + }, + }, + null, + 2, + ), + true, ); } export function objectArguments(value: unknown): Record { - return value && typeof value === "object" + return value && typeof value === "object" && !Array.isArray(value) ? (value as Record) : {}; } diff --git a/examples/node-local/src/shared/routes.ts b/examples/node-local/src/shared/routes.ts new file mode 100644 index 0000000..bde6b2a --- /dev/null +++ b/examples/node-local/src/shared/routes.ts @@ -0,0 +1,23 @@ +export const CODEX_APP_SERVER_PATH = "/api/codex/app-server"; +export const CODEX_SESSION_PATH = "/api/codex/session"; +export const CODEX_STATUS_PATH = "/api/codex/status"; +export const NODE_LOCAL_THREAD_ID = "00000000-0000-4000-8000-000000000146"; + +export type CodexSessionResponse = { + expiresAt: number; + threadId: string; + webSocketUrl: string; +}; + +export type CodexStatusResponse = { + configured: boolean; + model: string; + threadId: string; +}; + +export function webSocketUrlFromTicket(origin: string, ticket: string): string { + const url = new URL(CODEX_APP_SERVER_PATH, origin); + url.protocol = url.protocol === "https:" ? "wss:" : "ws:"; + url.searchParams.set("ticket", ticket); + return url.toString(); +} diff --git a/examples/minimal-app-server/src/vite-env.d.ts b/examples/node-local/src/vite-env.d.ts similarity index 100% rename from examples/minimal-app-server/src/vite-env.d.ts rename to examples/node-local/src/vite-env.d.ts diff --git a/examples/minimal-app-server/tsconfig.json b/examples/node-local/tsconfig.json similarity index 86% rename from examples/minimal-app-server/tsconfig.json rename to examples/node-local/tsconfig.json index 0dd61fc..e691ad3 100644 --- a/examples/minimal-app-server/tsconfig.json +++ b/examples/node-local/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-minimal-example.tsbuildinfo", + "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-node-local-example.tsbuildinfo", "types": ["node", "vite/client"] }, "include": ["src", "vite.config.ts"] diff --git a/examples/node-local/vite.config.ts b/examples/node-local/vite.config.ts new file mode 100644 index 0000000..f43b01b --- /dev/null +++ b/examples/node-local/vite.config.ts @@ -0,0 +1,184 @@ +import type { Socket } from "node:net"; +import tailwindcss from "@tailwindcss/vite"; +import { defineConfig, loadEnv, type ViteDevServer } from "vite"; +import { WebSocketServer } from "ws"; +import { codexJsAliases } from "../codex-js-vite-aliases"; +import { + CODEX_APP_SERVER_PATH, + CODEX_SESSION_PATH, + CODEX_STATUS_PATH, + NODE_LOCAL_THREAD_ID, + webSocketUrlFromTicket, + type CodexSessionResponse, + type CodexStatusResponse, +} from "./src/shared/routes"; + +const DEFAULT_MODEL = "gpt-5-mini"; +const SESSION_TICKET_TTL_MS = 60_000; + +type AppServerModule = typeof import("./src/server/app-server"); +type LocalCodexAppServer = ReturnType< + AppServerModule["createLocalCodexAppServer"] +>; + +type TicketRecord = { + expiresAt: number; +}; + +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ""); + const openAiApiKey = env.OPENAI_API_KEY ?? process.env.OPENAI_API_KEY ?? ""; + const model = env.OPENAI_MODEL ?? process.env.OPENAI_MODEL ?? DEFAULT_MODEL; + + return { + resolve: { + alias: codexJsAliases, + dedupe: ["react", "react-dom"], + }, + server: { + host: "localhost", + port: 1466, + }, + plugins: [ + tailwindcss(), + { + name: "node-local-codex-app-server", + configureServer(server) { + const wsServer = new WebSocketServer({ noServer: true }); + const loadAppServer = createAppServerLoader(server, { + apiKey: openAiApiKey, + model, + }); + const tickets = new Map(); + + server.middlewares.use((request, response, next) => { + const url = request.url + ? new URL(request.url, "http://localhost") + : null; + if ( + request.method === "GET" && + url?.pathname === CODEX_STATUS_PATH + ) { + sendJson(response, { + configured: Boolean(openAiApiKey.trim()), + model, + threadId: NODE_LOCAL_THREAD_ID, + } satisfies CodexStatusResponse); + return; + } + if ( + request.method === "POST" && + url?.pathname === CODEX_SESSION_PATH + ) { + if (!openAiApiKey.trim()) { + sendJson( + response, + { + error: + "Set OPENAI_API_KEY in examples/node-local/.env.local and restart the dev server.", + }, + 500, + ); + return; + } + const ticket = crypto.randomUUID(); + const expiresAt = Date.now() + SESSION_TICKET_TTL_MS; + tickets.set(ticket, { expiresAt }); + sendJson(response, { + expiresAt, + threadId: NODE_LOCAL_THREAD_ID, + webSocketUrl: webSocketUrlFromTicket( + `http://${request.headers.host ?? "localhost:1466"}`, + ticket, + ), + } satisfies CodexSessionResponse); + return; + } + next(); + }); + + server.httpServer?.on("upgrade", (request, socket, head) => { + const url = request.url + ? new URL(request.url, "http://localhost") + : null; + if (url?.pathname !== CODEX_APP_SERVER_PATH) { + return; + } + const ticket = url.searchParams.get("ticket"); + const ticketRecord = ticket ? tickets.get(ticket) : null; + if ( + !ticket || + !ticketRecord || + ticketRecord.expiresAt <= Date.now() + ) { + rejectUpgrade(socket as Socket); + return; + } + tickets.delete(ticket); + void loadAppServer().then((loaded) => { + wsServer.handleUpgrade( + request, + socket as Socket, + head, + (webSocket) => { + loaded.connectWebSocket({ + appServer: loaded.appServer, + socket: webSocket as unknown as Parameters< + AppServerModule["connectLocalCodexWebSocket"] + >[0]["socket"], + }); + }, + ); + }); + }); + }, + }, + ], + }; +}); + +function createAppServerLoader( + server: ViteDevServer, + options: { apiKey: string; model: string }, +): () => Promise<{ + appServer: LocalCodexAppServer; + connectWebSocket: AppServerModule["connectLocalCodexWebSocket"]; +}> { + let loaded: { + appServer: LocalCodexAppServer; + connectWebSocket: AppServerModule["connectLocalCodexWebSocket"]; + } | null = null; + return async () => { + if (loaded) { + return loaded; + } + const module = (await server.ssrLoadModule( + "/src/server/app-server.ts", + )) as AppServerModule; + loaded = { + appServer: module.createLocalCodexAppServer(options), + connectWebSocket: module.connectLocalCodexWebSocket, + }; + return loaded; + }; +} + +function sendJson( + response: { + end(body: string): void; + setHeader(name: string, value: string): void; + statusCode: number; + }, + value: unknown, + status = 200, +): void { + response.statusCode = status; + response.setHeader("cache-control", "no-store"); + response.setHeader("content-type", "application/json"); + response.end(JSON.stringify(value)); +} + +function rejectUpgrade(socket: Socket): void { + socket.write("HTTP/1.1 401 Unauthorized\r\nConnection: close\r\n\r\n"); + socket.destroy(); +} diff --git a/examples/react-router-cloudflare/index.html b/examples/react-router-cloudflare/index.html deleted file mode 100644 index c58a134..0000000 --- a/examples/react-router-cloudflare/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - codex-js React Router Cloudflare Example - - -
- - - diff --git a/examples/react-router-cloudflare/package.json b/examples/react-router-cloudflare/package.json deleted file mode 100644 index 114e7a4..0000000 --- a/examples/react-router-cloudflare/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@jrkropp/codex-js-react-router-cloudflare-example", - "private": true, - "type": "module", - "scripts": { - "dev": "vite --host localhost --port 1468", - "build": "pnpm typecheck && vite build", - "typecheck": "tsc -p tsconfig.json --pretty false" - }, - "dependencies": { - "@fontsource-variable/geist": "^5.2.8", - "@jrkropp/codex-js": "workspace:*", - "@jrkropp/codex-js-react": "workspace:*", - "@tailwindcss/vite": "^4.1.17", - "react": "19.2.1", - "react-dom": "19.2.1", - "tailwindcss": "^4.1.17", - "tw-animate-css": "^1.4.0", - "vite": "^6.4.2" - } -} diff --git a/examples/react-router-cloudflare/src/main.tsx b/examples/react-router-cloudflare/src/main.tsx deleted file mode 100644 index 6558a9e..0000000 --- a/examples/react-router-cloudflare/src/main.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { createRoot } from "react-dom/client"; -import { createCodexAppServerClient } from "@jrkropp/codex-js/client"; -import { CodexChat } from "@jrkropp/codex-js-react"; -import "./styles.css"; - -function appServerUrl() { - const url = new URL("/api/codex/app-server", window.location.origin); - url.protocol = url.protocol === "https:" ? "wss:" : "ws:"; - return url.toString(); -} - -const appServer = createCodexAppServerClient({ - url: appServerUrl, -}); - -function App() { - return ( - - ); -} - -createRoot(document.getElementById("root")!).render(); diff --git a/examples/react-router-cloudflare/src/styles.css b/examples/react-router-cloudflare/src/styles.css deleted file mode 100644 index db66157..0000000 --- a/examples/react-router-cloudflare/src/styles.css +++ /dev/null @@ -1,14 +0,0 @@ -@import "@jrkropp/codex-js-react/styles.css"; -@import "@fontsource-variable/geist"; - -:root { - --background: oklch(0.976 0.003 240); - --foreground: oklch(0.18 0.012 235); - font-family: "Geist Variable", Inter, ui-sans-serif, system-ui, sans-serif; -} - -body { - background: var(--background); - color: var(--foreground); - margin: 0; -} diff --git a/examples/react-router-cloudflare/tsconfig.json b/examples/react-router-cloudflare/tsconfig.json deleted file mode 100644 index 044284b..0000000 --- a/examples/react-router-cloudflare/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "tsBuildInfoFile": "../../node_modules/.tmp/tsconfig.codex-js-react-router-cloudflare-example.tsbuildinfo", - "types": ["vite/client"] - }, - "include": ["src", "vite.config.ts"] -} diff --git a/examples/react-router-cloudflare/vite.config.ts b/examples/react-router-cloudflare/vite.config.ts deleted file mode 100644 index 33981a3..0000000 --- a/examples/react-router-cloudflare/vite.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import tailwindcss from "@tailwindcss/vite"; -import { defineConfig } from "vite"; -import { codexJsAliases } from "../codex-js-vite-aliases"; - -export default defineConfig({ - resolve: { - alias: codexJsAliases, - dedupe: ["react", "react-dom"], - }, - plugins: [tailwindcss()], -}); diff --git a/examples/vite-react/index.html b/examples/vite-react/index.html deleted file mode 100644 index f3d5bed..0000000 --- a/examples/vite-react/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - codex-js Vite Example - - -
- - - diff --git a/examples/vite-react/package.json b/examples/vite-react/package.json deleted file mode 100644 index 7e3ea5e..0000000 --- a/examples/vite-react/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@jrkropp/codex-js-vite-react-example", - "private": true, - "type": "module", - "scripts": { - "dev": "vite --host localhost --port 1467", - "build": "pnpm typecheck && vite build", - "typecheck": "tsc -p tsconfig.json --pretty false" - }, - "dependencies": { - "@fontsource-variable/geist": "^5.2.8", - "@jrkropp/codex-js": "workspace:*", - "@jrkropp/codex-js-react": "workspace:*", - "@tailwindcss/vite": "^4.1.17", - "react": "19.2.1", - "react-dom": "19.2.1", - "tailwindcss": "^4.1.17", - "tw-animate-css": "^1.4.0", - "vite": "^6.4.2" - } -} diff --git a/examples/vite-react/src/main.tsx b/examples/vite-react/src/main.tsx deleted file mode 100644 index 230ea4c..0000000 --- a/examples/vite-react/src/main.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { createRoot } from "react-dom/client"; -import type { CodexAppServer } from "@jrkropp/codex-js/client"; -import { CodexChat, CodexChatLayout } from "@jrkropp/codex-js-react"; -import { - SidebarContent, - SidebarGroup, - SidebarGroupContent, - SidebarGroupLabel, -} from "@jrkropp/codex-js-react/shadcn"; -import "./styles.css"; - -const appServer: CodexAppServer = { - async rejectServerRequest() {}, - async request() { - throw new Error("Connect this example to a Codex app server."); - }, - async requestTyped() { - throw new Error("Connect this example to a Codex app server."); - }, - async resolveServerRequest() {}, -}; - -function App() { - return ( - - - Workspace - App-owned sidebar content - - - } - > - - - ); -} - -createRoot(document.getElementById("root")!).render(); diff --git a/examples/vite-react/src/styles.css b/examples/vite-react/src/styles.css deleted file mode 100644 index 4fa5d73..0000000 --- a/examples/vite-react/src/styles.css +++ /dev/null @@ -1,32 +0,0 @@ -@import "@jrkropp/codex-js-react/styles.css"; -@import "@fontsource-variable/geist"; - -:root { - --background: oklch(0.976 0.003 240); - --foreground: oklch(0.18 0.012 235); - --card: oklch(0.998 0.001 240); - --card-foreground: var(--foreground); - --popover: oklch(0.998 0.001 240); - --popover-foreground: var(--foreground); - --primary: oklch(0.39 0.058 190); - --primary-foreground: oklch(0.99 0.006 170); - --secondary: oklch(0.946 0.004 245); - --secondary-foreground: oklch(0.22 0.014 235); - --muted: oklch(0.943 0.004 245); - --muted-foreground: oklch(0.46 0.011 235); - --accent: oklch(0.94 0.005 235); - --accent-foreground: oklch(0.22 0.014 235); - --destructive: oklch(0.59 0.185 28); - --border: oklch(0.858 0.006 240); - --input: oklch(0.858 0.006 240); - --ring: oklch(0.49 0.062 190); - --radius: 0.5rem; - font-family: "Geist Variable", Inter, ui-sans-serif, system-ui, sans-serif; - color-scheme: light; -} - -body { - background: var(--background); - color: var(--foreground); - margin: 0; -} diff --git a/package.json b/package.json index 49a5579..76daec9 100644 --- a/package.json +++ b/package.json @@ -5,20 +5,22 @@ "packageManager": "pnpm@10.30.1", "scripts": { "build": "pnpm --filter @jrkropp/codex-js --filter @jrkropp/codex-js-react build", - "build:examples": "pnpm --filter @jrkropp/codex-js-minimal-app-server-example build && pnpm --filter @jrkropp/codex-js-vite-react-example build && pnpm --filter @jrkropp/codex-js-react-router-cloudflare-example build", + "build:examples": "pnpm --filter @jrkropp/codex-js-node-local-example build && pnpm --filter @jrkropp/codex-js-cloudflare-example build", "changeset": "changeset", "check": "pnpm lint && pnpm type-package && pnpm build && pnpm test && pnpm test:pack && pnpm publint && pnpm pack:dry-run && pnpm build:examples", - "dev:cloudflare-example": "pnpm --filter @jrkropp/codex-js-react-router-cloudflare-example dev", - "dev:minimal": "pnpm --filter @jrkropp/codex-js-minimal-app-server-example dev", - "dev:vite-react": "pnpm --filter @jrkropp/codex-js-vite-react-example dev", + "deploy:cloudflare-example:dry-run": "pnpm --filter @jrkropp/codex-js-cloudflare-example deploy:dry-run", + "dev:cloudflare-example": "pnpm --filter @jrkropp/codex-js-cloudflare-example dev", + "dev:node-local": "pnpm --filter @jrkropp/codex-js-node-local-example dev", "external:sync": "node scripts/sync-external.mjs", - "format:check": "prettier --check README.md package.json .changeset packages/*/package.json packages/*/README.md packages/*/tsconfig*.json packages/*/tsup.config.ts examples/*/package.json examples/*/tsconfig.json examples/*/vite.config.ts examples/codex-js-vite-aliases.ts scripts/*.mjs tests/**/*.ts", - "lint": "pnpm format:check && pnpm typecheck", + "format:check": "prettier --check README.md package.json eslint.config.js .changeset packages/*/package.json packages/*/README.md packages/*/tsconfig*.json packages/*/tsup.config.ts examples/*/package.json examples/*/tsconfig*.json examples/*/vite.config.ts examples/*/vitest.config.ts examples/*/wrangler*.jsonc examples/codex-js-vite-aliases.ts scripts/*.mjs tests/**/*.ts", + "lint": "pnpm format:check && pnpm lint:static && pnpm typecheck", + "lint:static": "eslint . --max-warnings=0", "pack:dry-run": "pnpm --filter @jrkropp/codex-js --filter @jrkropp/codex-js-react pack:dry-run", "publint": "pnpm --filter @jrkropp/codex-js --filter @jrkropp/codex-js-react publint", "release": "pnpm check && changeset publish", "release:preflight": "node scripts/check-release-publish-config.mjs", "test": "vitest run --exclude tests/package.test.ts --passWithNoTests", + "test:cloudflare-example": "pnpm --filter @jrkropp/codex-js-cloudflare-example test", "test:pack": "vitest run tests/package.test.ts", "type-package": "pnpm --filter @jrkropp/codex-js typecheck && pnpm --filter @jrkropp/codex-js-react typecheck", "typecheck": "pnpm -r --if-present typecheck", @@ -27,6 +29,7 @@ "devDependencies": { "@changesets/changelog-github": "^0.5.1", "@changesets/cli": "^2.29.7", + "@eslint/js": "^10.0.1", "@fontsource-variable/geist": "^5.2.8", "@tailwindcss/cli": "^4.1.17", "@tailwindcss/vite": "^4.1.17", @@ -34,11 +37,15 @@ "@types/react": "19.2.7", "@types/react-dom": "19.2.3", "@types/ws": "^8.18.1", + "eslint": "^10.3.0", + "eslint-plugin-react-hooks": "^7.1.1", + "globals": "^17.6.0", "prettier": "^3.7.4", "publint": "^0.3.18", "tailwindcss": "^4.1.17", "tsup": "^8.5.1", "typescript": "5.8.3", + "typescript-eslint": "^8.59.3", "vite": "^6.4.2", "vitest": "^4.1.5", "ws": "^8.18.3" diff --git a/packages/codex-js-react/CHANGELOG.md b/packages/codex-js-react/CHANGELOG.md index 9da2758..17a7efc 100644 --- a/packages/codex-js-react/CHANGELOG.md +++ b/packages/codex-js-react/CHANGELOG.md @@ -1,5 +1,17 @@ # @jrkropp/codex-js-react +## 0.3.0 + +### Minor Changes + +- Update the React package docs and examples around the split package model, + generated stylesheet import, and Cloudflare example integration path. + +### Patch Changes + +- Updated dependencies: + - @jrkropp/codex-js@0.3.0 + ## 0.2.1 ### Patch Changes diff --git a/packages/codex-js-react/README.md b/packages/codex-js-react/README.md index 19d4aab..f4b9019 100644 --- a/packages/codex-js-react/README.md +++ b/packages/codex-js-react/README.md @@ -1,19 +1,19 @@ # @jrkropp/codex-js-react -React UI for `@jrkropp/codex-js`, including `CodexChat`, hooks, shadcn-compatible primitives, and a generated stylesheet. +React UI package for `@jrkropp/codex-js`. It includes `CodexChat`, React hooks, shadcn-compatible primitives, and generated CSS. ## Install ```sh -pnpm add @jrkropp/codex-js @jrkropp/codex-js-react react react-dom +npm install @jrkropp/codex-js @jrkropp/codex-js-react react react-dom ``` Requirements: - Node.js 20 or newer. -- ESM projects only. This package does not ship CommonJS. +- ESM only. CommonJS output is not shipped. - React 18.3 or React 19. -- A browser bundler that can import CSS. +- A bundler that supports CSS imports. ## Usage @@ -23,7 +23,11 @@ import { CodexChat } from "@jrkropp/codex-js-react"; import "@jrkropp/codex-js-react/styles.css"; const appServer = createCodexAppServerClient({ - url: () => "ws://localhost:1466/api/codex/app-server", + url: async () => { + const session = await fetch("/api/codex/session", { method: "POST" }); + const { webSocketUrl } = await session.json(); + return webSocketUrl; + }, }); export function App() { @@ -32,13 +36,12 @@ export function App() { appServer={appServer} threadId="00000000-0000-4000-8000-000000000001" title="Codex" - subtitle="React package consumer" /> ); } ``` -## Stable Imports +## Public Imports ```ts import { CodexChat } from "@jrkropp/codex-js-react"; @@ -52,4 +55,4 @@ The React package exposes only: - `@jrkropp/codex-js-react/shadcn` - `@jrkropp/codex-js-react/styles.css` -Runtime and server APIs remain in `@jrkropp/codex-js`. +Runtime, server, and testing APIs live in `@jrkropp/codex-js`. diff --git a/packages/codex-js-react/package.json b/packages/codex-js-react/package.json index d62270f..7e10477 100644 --- a/packages/codex-js-react/package.json +++ b/packages/codex-js-react/package.json @@ -1,6 +1,6 @@ { "name": "@jrkropp/codex-js-react", - "version": "0.2.1", + "version": "0.3.0", "description": "React components and shadcn-compatible UI for codex-js.", "license": "Apache-2.0", "type": "module", @@ -36,7 +36,7 @@ "typecheck": "tsc -p tsconfig.json --pretty false" }, "dependencies": { - "@jrkropp/codex-js": "^0.2.0", + "@jrkropp/codex-js": "^0.3.0", "@legendapp/list": "^3.0.0-beta.44", "@lexical/react": "^0.44.0", "class-variance-authority": "^0.7.1", diff --git a/packages/codex-js-react/src/internal/chat-ui/components/chat/MessagesTimeline.tsx b/packages/codex-js-react/src/internal/chat-ui/components/chat/MessagesTimeline.tsx index 9b1d579..68ffd73 100644 --- a/packages/codex-js-react/src/internal/chat-ui/components/chat/MessagesTimeline.tsx +++ b/packages/codex-js-react/src/internal/chat-ui/components/chat/MessagesTimeline.tsx @@ -24,11 +24,7 @@ import { } from "react"; import { Button } from "../ui/button"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "../ui/tooltip"; +import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; import { cn } from "../../lib/utils"; import type { CoreTurnItem as TurnItem, @@ -72,7 +68,10 @@ type TimelineRowContextValue = { const TimelineRowContext = createContext(null); -type MessageTimelineRowModel = Extract; +type MessageTimelineRowModel = Extract< + MessagesTimelineRow, + { kind: "message" } +>; type UserMessageTimelineRowModel = MessageTimelineRowModel & { item: Extract; }; @@ -105,7 +104,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({ warnings, errors, runtimeError, - }), + }), [ activeTurnStartedAt, errors, @@ -195,7 +194,6 @@ function useStableRows(rows: MessagesTimelineRow[]): MessagesTimelineRow[] { result: [], }); - /* eslint-disable react-hooks/refs */ return useMemo(() => { // This mirrors T3's structural-sharing hook; the ref is a render cache // for stable virtualized row identity, not UI state. @@ -206,7 +204,6 @@ function useStableRows(rows: MessagesTimelineRow[]): MessagesTimelineRow[] { previousState.current = nextState; return nextState.result; }, [rows]); - /* eslint-enable react-hooks/refs */ } const TimelineRowContent = memo(function TimelineRowContent({ @@ -234,7 +231,9 @@ const TimelineRowContent = memo(function TimelineRowContent({ ) : null} {row.kind === "work" ? : null} {row.kind === "working" ? : null} - {row.kind === "warning" ? : null} + {row.kind === "warning" ? ( + + ) : null} {row.kind === "error" ? : null}
); @@ -248,22 +247,14 @@ function useTimelineRowContext() { return context; } -function MessageTimelineRow({ - row, -}: { - row: MessageTimelineRowModel; -}) { +function MessageTimelineRow({ row }: { row: MessageTimelineRowModel }) { if (row.item.type === "UserMessage") { return ; } return ; } -function UserTimelineRow({ - row, -}: { - row: UserMessageTimelineRowModel; -}) { +function UserTimelineRow({ row }: { row: UserMessageTimelineRowModel }) { const copyText = userInputTextForCopy(row.item.content); return (
@@ -304,7 +295,10 @@ function AssistantTimelineRow({ {row.showCompletionDivider ? ( ) : null} - + visible.entries.length; - const onlyToolEntries = row.groupedEntries.every((entry) => entry.tone === "tool"); + const onlyToolEntries = row.groupedEntries.every( + (entry) => entry.tone === "tool", + ); const showHeader = hasOverflow || !onlyToolEntries; const groupLabel = onlyToolEntries ? "Tool calls" : "Work log"; @@ -735,7 +731,9 @@ function WorkingTimer({ createdAt }: { createdAt: string }) { return () => window.clearInterval(intervalId); }, [createdAt]); - return <>{formatWorkingTimer(createdAt, new Date(nowMs).toISOString()) ?? "0s"}; + return ( + <>{formatWorkingTimer(createdAt, new Date(nowMs).toISOString()) ?? "0s"} + ); } function formatWorkingTimer(startIso: string, endIso: string): string | null { @@ -745,7 +743,10 @@ function formatWorkingTimer(startIso: string, endIso: string): string | null { return null; } - const elapsedSeconds = Math.max(0, Math.floor((endedAtMs - startedAtMs) / 1000)); + const elapsedSeconds = Math.max( + 0, + Math.floor((endedAtMs - startedAtMs) / 1000), + ); if (elapsedSeconds < 60) { return `${elapsedSeconds}s`; } diff --git a/packages/codex-js/CHANGELOG.md b/packages/codex-js/CHANGELOG.md index 946b118..82baa45 100644 --- a/packages/codex-js/CHANGELOG.md +++ b/packages/codex-js/CHANGELOG.md @@ -1,5 +1,16 @@ # @jrkropp/codex-js +## 0.3.0 + +### Minor Changes + +- Add high-level app-server helpers, dynamic tool definition helpers, connection + snapshot support, and pending server-request persistence contracts. +- Align public server terminology around app-server, connection, thread, turn, + dynamic tool, server request, server notification, and transport concepts. +- Replace the placeholder Cloudflare example with a deployable Worker + Durable + Object + Vite React example. + ## 0.2.0 ### Minor Changes diff --git a/packages/codex-js/CODEX_PARITY_LEDGER.md b/packages/codex-js/CODEX_PARITY_LEDGER.md deleted file mode 100644 index a013800..0000000 --- a/packages/codex-js/CODEX_PARITY_LEDGER.md +++ /dev/null @@ -1,66 +0,0 @@ -# Codex Runtime Parity Ledger - -This package contains modified TypeScript ports and platform adaptations of -OpenAI Codex source files. OpenAI Codex is licensed under Apache-2.0; attribution -is retained in `NOTICE`. - -This ledger records the package subsystems that intentionally mirror Codex. It -is the working checklist for keeping the TypeScript runtime aligned with -`.reference/codex/codex-rs` while keeping host application behavior outside the -package. - -The ownership model stays explicit: Codex owns runtime truth, T3 owns -interaction quality, and host apps own product meaning. - -The whole-workspace structural inventory is generated by -`npm --workspace @jrkropp/codex-js run codex:mirror` and stored -in `CODEX_PARITY_LEDGER.json`. The current mirror covers 89 reference crates and -1,818 Rust source files with no `missing` rows: implemented files remain -functional TypeScript ports, unsupported native/CLI/TUI surfaces compile as -shared `UnsupportedCodexFeatureError` stubs, and future ports move rows from -`stubbed` to `implemented` or `platform_adaptation`. - -| Subsystem | Package Path | Codex Reference | Status | Notes | -| --- | --- | --- | --- | --- | -| Model client | `src/upstream/codex-rs/core/src/client.ts` | `.reference/codex/codex-rs/core/src/client.rs` | Mirrored with platform adaptation | Session-scoped `ModelClient`, turn-scoped `ModelClientSession`, WebSocket-first streaming, HTTP/SSE sticky fallback, prewarm, incremental `previous_response_id`, and best-effort `response.processed` follow Codex. Fetch/WebSocket primitives are Worker-compatible TypeScript adaptations. | -| Responses transport | `src/upstream/codex-rs/codex-api/src/endpoint/responses.ts` and `responses_websocket.ts` | `.reference/codex/codex-rs/codex-api/src/endpoint/responses.rs` and `responses_websocket.rs` | Mirrored with platform adaptation | The package preserves Codex endpoint split: Responses HTTP/SSE fallback and Responses-over-WebSocket primary transport. Cloudflare `fetch` upgrade replaces Rust client plumbing. | -| Request wire shape | `src/upstream/codex-rs/codex-api/src/common.ts` and `requests/responses.ts` | `.reference/codex/codex-rs/codex-api/src/common.rs` and `requests/responses.rs` | Mirrored | Optional request fields are omitted from wire payloads like Rust `skip_serializing_if`. `prompt_cache_key` is thread id for normal and compaction requests. | -| Token usage | `src/upstream/codex-rs/codex-api/src/sse/responses.ts` and `src/upstream/codex-rs/core/src/session/session.ts` | `.reference/codex/codex-rs/codex-api/src/sse/responses.rs` and `core/src/session/session.rs` | Mirrored | Cached tokens come only from `usage.input_tokens_details.cached_tokens`; reasoning tokens come only from `usage.output_tokens_details.reasoning_tokens`; accumulation uses `TokenUsageInfo`. | -| Context updates | `src/upstream/codex-rs/core/src/context` and `src/upstream/codex-rs/core/src/session/session.ts` | `.reference/codex/codex-rs/core/src/context` and `core/src/session/session.rs` | Mirrored with known gaps | Runtime order matches Codex: context updates are recorded before the user message, and prompts are built from persisted history. Additional Codex context sections are tracked as explicit expansion work. | -| Context manager | `src/upstream/codex-rs/core/src/context_manager` | `.reference/codex/codex-rs/core/src/context_manager` | Mirrored | `ContextManager.record_items` truncates `function_call_output` and `custom_tool_call_output` before history storage; `for_prompt` normalizes missing/orphan call outputs and strips image content for text-only models; `replace` is an exact rewrite used by compaction and rollback. | -| Session state | `src/upstream/codex-rs/core/src/state/session.ts` | `.reference/codex/codex-rs/core/src/state/session.rs` | Mirrored with platform adaptation | `SessionState` owns live `ContextManager`, previous turn settings, reference context, token info, rate limits, and server-reasoning accounting while rollout remains the durable cold-start source. | -| Compaction | `src/upstream/codex-rs/core/src/compact-task-runner.ts`, `tasks/compact.ts`, and `compact.ts` | `.reference/codex/codex-rs/core/src/compact*` and `tasks/compact.rs` | Mirrored with known gaps | Compaction replaces history and advances the model-client window generation. Remaining work is tighter parity for Codex’s full compaction prompt surface. | -| Stream events | `src/upstream/codex-rs/core/src/stream_events_utils.ts` | `.reference/codex/codex-rs/core/src/stream_events_utils.rs` | Mirrored with platform adaptation | Completed model items, tool-call recording, tool-output recording, follow-up detection, Plan Mode stream parsing, and missing local-shell id responses live in `stream_events_utils`. `session/turn.ts` drives streaming and rebuilds follow-up prompts from live `SessionState.history`. | -| Tool search and spec planning | `src/upstream/codex-rs/core/src/tools/spec.ts`, `spec_plan.ts`, `handlers/tool_search.ts`, and `tools/tool_search_entry.ts` | `.reference/codex/codex-rs/core/src/tools/spec.rs`, `spec_plan.rs`, `handlers/tool_search.rs`, and `tool_search_entry.rs` | Mirrored with platform adaptation | Deferred dynamic and MCP tools use Codex namespace gating, BM25 search, source info, bucket limits, and history-based follow-up. Deferred MCP handlers are registered for discovered tools, and unavailable previously-called tools get Codex-style placeholder specs. | -| MCP catalog and resources | `src/upstream/codex-rs/core/src/mcp`, `tools/handlers/mcp.ts`, and `tools/handlers/mcp_resource*` | `.reference/codex/codex-rs/codex-mcp/src/tools.rs`, `codex-mcp/src/codex_apps.rs`, `core/src/tools/handlers/mcp.rs`, and `core/src/tools/handlers/mcp_resource*` | Mirrored with platform adaptation | MCP metadata separates raw server/tool routing from model-visible qualified callable names, carries connector and plugin provenance for search, exposes Codex resource list/read tools when MCP tools are present, caches Codex Apps catalogs by user key, filters disallowed connectors, and emits MCP tool-call lifecycle events for resource operations. | -| MCP connection manager | `src/upstream/codex-rs/codex-mcp/src/connection_manager.ts`, `rmcp_client.ts`, and `core/src/mcp/manager.ts` | `.reference/codex/codex-rs/codex-mcp/src/connection_manager.rs` and `rmcp_client.rs` | Mirrored with platform adaptation | The package now has Codex-shaped per-server managed clients, startup snapshot reads, live catalog aggregation, hard Codex Apps refresh, raw tool-call routing, resource aggregation, startup error helpers, transport-origin helpers, and a core adapter. Native stdio/HTTP process startup remains host/platform-provided through `RmcpClientLike`. | -| MCP auth and elicitation | `src/upstream/codex-rs/codex-mcp/src/mcp/auth.ts`, `elicitation.ts`, and `auth_elicitation.ts` | `.reference/codex/codex-rs/codex-mcp/src/mcp/auth.rs`, `elicitation.rs`, and `auth_elicitation.rs` | Mirrored with platform adaptation | OAuth support/status helpers, scope source precedence, retry-without-scopes checks, elicitation request tracking, auto-deny/auto-accept policy behavior, reviewer/event resolution, and Codex Apps auth failure URL elicitations are ported. OAuth discovery uses Web `fetch` instead of Rust reqwest. | -| Tool runtime | `src/upstream/codex-rs/core/src/tools/context.ts`, `tools/parallel.ts`, and `tools/handlers/mcp.ts` | `.reference/codex/codex-rs/core/src/tools/context.rs`, `tools/parallel.rs`, and `tools/handlers/mcp.rs` | Mirrored with platform adaptation | Tool execution uses Codex read/write ordering: parallel tools overlap, nonparallel tools wait for active parallel work and block later parallel work. TypeScript `CancellationToken` adapts Rust `tokio_util::sync::CancellationToken`. MCP outputs include wall-time model-facing text and preserve raw results for hook/code-mode consumers. | -| App server | `src/upstream/codex-rs/app-server/src` | `.reference/codex/codex-rs/app-server/src` | Mirrored with platform adaptation | Runtime composition, message processing, request processors, request serialization, connection gating, outgoing messages, initialize state, server-request response routing, and request context follow Codex. Worker WebSocket acceptance remains host code. | -| App server session orchestration | `src/upstream/codex-rs/app-server/src/session_factory.ts` and `session_task_runner.ts` | `.reference/codex/codex-rs/core/src/thread_manager.rs`, `core/src/tasks`, and `core/src/session/turn.rs` | Mirrored with platform adaptation | Thread/session creation and regular/compact task execution now live inside the upstream mirror so request processors do not depend on package runtime facades. Host callbacks still provide model clients, stores, credentials, and background scheduling. | -| App server transport | `src/upstream/codex-rs/app-server-transport/src/outgoing_message.ts` and `transport/mod.ts` | `.reference/codex/codex-rs/app-server-transport/src/outgoing_message.rs` and `transport/mod.rs` | Mirrored with platform adaptation | Transport-level outgoing message types plus JSON-RPC request, notification, response, and error parsing/serialization live under the Codex transport crate mirror. Worker socket acceptance remains host code. | -| App server client | `src/upstream/codex-rs/app-server-client/src/lib.ts`, `remote.ts`, `session.ts`, `pending_requests.ts`, and `thread_event_store.ts` | `.reference/codex/codex-rs/app-server-client/src/lib.rs` and `remote.rs` | Mirrored with platform adaptation | Browser WebSocket client lifecycle, initialize handshake, JSON-RPC request/response routing, server-request resolution, typed request helpers, pending request tracking, and thread notification projection now live under the Codex client crate mirror. Browser ticket URL creation remains host code. | -| Thread state | `src/upstream/codex-rs/app-server/src/thread_state.ts` | `.reference/codex/codex-rs/app-server/src/thread_state.rs` | Mirrored with platform adaptation | Live connections, thread subscriptions, active turn snapshots, and close cleanup are package-owned. Durable Object socket persistence remains host code. | - -## Platform Adaptations - -- TypeScript mirrors Rust module names and contracts, but uses `.ts` files, - structural types, `fetch`, WebSocket, and Cloudflare-compatible streams. -- Tool cancellation uses a TypeScript `CancellationToken` wrapper around - `AbortSignal` as the platform adaptation for Rust's cancellation token. -- Cloudflare Worker socket acceptance, Durable Object persistence, credentials, - prompts, product tools, project scope, and route paths stay outside the - package. -- Browser app-server WebSocket and OpenAI Responses WebSocket are separate - transports. The former connects UI to the app-server control plane; the latter - connects the runtime to OpenAI. - -## Guarded Rules - -- Package upstream mirrors do not import host application `app`, `src/domain`, - `src/browser`, or `src/worker` modules. -- The removed HTTP-primary `responses_client.ts` surface stays deleted. -- The package does not expose desktop-mediated model transport. -- Parser compatibility aliases for `cached_input_tokens` and - `reasoning_output_tokens` are not accepted. -- Request fixtures and serializers do not encode `prompt_cache_key: null`. diff --git a/packages/codex-js/README.md b/packages/codex-js/README.md index b6adf4a..998aeff 100644 --- a/packages/codex-js/README.md +++ b/packages/codex-js/README.md @@ -1,99 +1,148 @@ # @jrkropp/codex-js -Core TypeScript runtime, browser client, server adapters, and test utilities for building Codex-backed apps. +Core TypeScript SDK for building Codex-backed applications. It includes the browser app-server client, platform-neutral server helpers, Codex-aligned runtime contracts, stores, model transport, and test utilities. ## Install ```sh -pnpm add @jrkropp/codex-js +npm install @jrkropp/codex-js ``` Requirements: - Node.js 20 or newer. -- ESM projects only. This package does not ship CommonJS. -- React is not a dependency of this package. Install `@jrkropp/codex-js-react` only when you need the packaged UI. +- ESM only. CommonJS output is not shipped. +- React is not a dependency. Install `@jrkropp/codex-js-react` only when you need packaged UI components. -## Stable Imports +## Public Imports ```ts import { createCodexAppServerClient } from "@jrkropp/codex-js/client"; -import { createCodexAppServerRuntime } from "@jrkropp/codex-js/server"; +import { createCodexAppServer } from "@jrkropp/codex-js/server"; import { InMemoryThreadStore } from "@jrkropp/codex-js/testing"; ``` -The published core package exposes only: +The core package exposes only: - `@jrkropp/codex-js` - `@jrkropp/codex-js/client` - `@jrkropp/codex-js/server` - `@jrkropp/codex-js/testing` -There are no public upstream mirror or unstable import paths. +There are no public mirror or unstable imports. -## Browser Client +## Server Quick Start ```ts -import { createCodexAppServerClient } from "@jrkropp/codex-js/client"; +import { + createCodexAppServer, + createModelClient, + defineDynamicTool, + dynamicToolResponse, +} from "@jrkropp/codex-js/server"; +import { InMemoryThreadStore } from "@jrkropp/codex-js/testing"; -const appServer = createCodexAppServerClient({ - url: () => "ws://localhost:1466/api/codex/app-server", +const lookupStatus = defineDynamicTool({ + name: "lookup_status", + description: "Look up the current deployment status.", + inputSchema: { + type: "object", + properties: { name: { type: "string" } }, + required: ["name"], + additionalProperties: false, + }, + async execute(args) { + return dynamicToolResponse.text(`${args.name} is healthy.`); + }, }); -await appServer.requestTyped("thread/start", { - threadId: "00000000-0000-4000-8000-000000000001", +const appServer = createCodexAppServer({ + threadStore: new InMemoryThreadStore(), + dynamicTools: [lookupStatus], + defaults: { + cwd: "/workspace", + model: "gpt-5-mini", + modelProvider: "openai", + }, + createModelClient({ session, threadId }) { + return createModelClient({ + apiKey: process.env.OPENAI_API_KEY!, + installationId: "my-app", + sessionId: session.id, + threadId, + }); + }, }); ``` -## Server Runtime +Create one app-server connection per WebSocket: ```ts -import { - CodexAppServerMessageProcessor, - createCodexAppServerRuntime, -} from "@jrkropp/codex-js/server"; -import { InMemoryThreadStore } from "@jrkropp/codex-js/testing"; +const connection = appServer.createConnection({ + send(message) { + webSocket.send(message); + }, +}); -const runtime = createCodexAppServerRuntime({ - threadStore: new InMemoryThreadStore(), +webSocket.addEventListener("message", (event) => { + void connection.accept(event.data); }); -const processor = new CodexAppServerMessageProcessor({ - runtime, - send: (message) => { - // Write the serialized app-server event to your WebSocket. - console.log(message); - }, +webSocket.addEventListener("close", () => { + void connection.close(); }); ``` -Create one message processor per WebSocket connection. The package does not own your HTTP server, credential handling, persistence backend, or product-specific tools. +`createCodexAppServerRuntime` is still exported for advanced hosts that need to own message processing directly, but most applications should start with `createCodexAppServer`. -## React UI +## Dynamic Tools -The UI package is separate: +Use `defineDynamicTool` for server-executed tools. Use a namespace when a tool is deferred and loaded through Codex tool search. -```sh -pnpm add @jrkropp/codex-js @jrkropp/codex-js-react react react-dom +```ts +const lookupInvoice = defineDynamicTool({ + namespace: "billing", + name: "lookup_invoice", + description: "Look up an invoice by id.", + deferLoading: true, + inputSchema: { + type: "object", + properties: { invoiceId: { type: "string" } }, + required: ["invoiceId"], + additionalProperties: false, + }, + async execute(args) { + return dynamicToolResponse.text(`Invoice ${args.invoiceId} is paid.`); + }, +}); ``` -```tsx -import { CodexChat } from "@jrkropp/codex-js-react"; -import "@jrkropp/codex-js-react/styles.css"; +Tools with `execute` are resolved by the server. Tools without `execute` are surfaced as app-server requests so the client can resolve them. + +## Browser Client + +```ts +import { createCodexAppServerClient } from "@jrkropp/codex-js/client"; + +const appServer = createCodexAppServerClient({ + url: async () => { + const session = await fetch("/api/codex/session", { method: "POST" }); + const { webSocketUrl } = await session.json(); + return webSocketUrl; + }, +}); ``` -## Examples +The browser never needs an OpenAI API key. Host applications should issue a short-lived app-server WebSocket URL from their backend. + +## Cloudflare -From the repository root: +The repository includes a deployable Cloudflare Worker + Durable Object + Vite React example: ```sh -pnpm dev:minimal -pnpm dev:vite-react +pnpm dev:node-local pnpm dev:cloudflare-example +pnpm --filter @jrkropp/codex-js-cloudflare-example deploy:dry-run ``` -The examples use local source aliases during development and packed-package tests verify the npm tarballs. - -## Architecture - -`@jrkropp/codex-js` is the non-React package. It owns the transport protocol, app-server client, server runtime helpers, stores, serializers, and testing primitives. UI components, shadcn exports, Tailwind output, and React-only dependencies live in `@jrkropp/codex-js-react`. +Use `examples/node-local` for the smallest local Node/Vite integration. Use `examples/cloudflare` for a deployable Worker + Durable Object integration with one-time WebSocket tickets, Durable Object SQLite storage, hibernating WebSockets, server-executed dynamic tools, and a deferred namespaced tool. diff --git a/packages/codex-js/docs/AGENTS.md b/packages/codex-js/docs/AGENTS.md deleted file mode 100644 index 7d7fd8b..0000000 --- a/packages/codex-js/docs/AGENTS.md +++ /dev/null @@ -1,60 +0,0 @@ -# codex-js Documentation Guide - -The package favors small durable primitives over broad abstractions. A primitive earns its place only when it owns durable state, a clear lifecycle, or a boundary that protects the rest of the system. Useful concepts that do not meet that bar stay as projections, adapters, implementation details, or host-app concerns. - -This documentation describes the intended production design of `@jrkropp/codex-js` as a polished Codex runtime and UI kit. - -## Core Principles - -- Establish durable primitives before implementation details. -- Keep the public model small, standard, and composable. -- Treat `src/upstream/codex-rs` as a Codex-shaped upstream source and `src/upstream/t3code` as a T3-shaped upstream source. Codex and T3 are proven source references; follow their folder structure, naming, concepts, classes, contracts, and lifecycle patterns as closely as practical. -- Keep package-owned abstractions outside the upstream trees. -- `ThreadStore` is the storage boundary. Product grouping, account boundaries, workspace selection, and deployment placement are not package primitives. -- Runtime delivery follows Codex's server names: `OutgoingMessageSender`, `ThreadScopedOutgoingMessageSender`, `ThreadState`, and `ThreadStateManager`. -- Examples use the public doorways: `CodexChat`, `createCodexAppServerClient`, `CodexAppServerMessageProcessor`, `createCodexAppServerRuntime`, `ThreadStore`, `createModelClient`, and `sendOutgoingMessage`. -- When behavior is wrong or unclear, compare against Codex or T3 first. If local code differs, realign it with the source reference instead of inventing a custom fix. -- Prefer precise names over broad abstractions. -- Separate accepted docs from staged thinking. -- Keep implementation and refactor plans in `plans/`, not in accepted architecture docs. - -## Source References - -- Codex source reference: `/Users/justinkropp/Github/host-app/external/codex` -- T3 source reference: `/Users/justinkropp/Github/host-app/external/t3code` -- Package Codex upstream source: `/Users/justinkropp/Github/host-app/packages/codex-js/src/upstream/codex-rs` -- Package T3 upstream source: `/Users/justinkropp/Github/host-app/packages/codex-js/src/upstream/t3code` - -The `external/` directories are read-only. Do not import from them, edit them, or treat them as package source. - -## Writing Style - -- Write as if the package already exists in its final production form. -- Accepted docs describe the intended production design, not transient implementation state. -- Use clear, direct, polished prose. -- Avoid TODOs, roadmap placeholders, scaffolding notes, and speculative language. -- Keep implementation sequencing, migration steps, and work breakdowns in `plans/`. -- Keep docs concise enough to guide implementation without becoming design debris. - -## Folder Structure - -- `src/upstream/codex-rs/`: Codex-shaped upstream source tree. -- `src/upstream/t3code/`: T3-shaped upstream source tree. -- `src/runtime/`: platform-neutral Codex lifecycle code and contracts. -- `src/components/`: stable public React component surface. -- `src/hooks/`: stable public React hooks. -- `src/testing/`: package and consumer testing utilities. -- `start-here/`: short onboarding path for the package model, philosophy, and primitives. -- `architecture/`: accepted architecture notes and deeper system explanations. -- `design/decisions/`: accepted ADR-style decisions. -- `plans/`: implementation plans, refactor plans, audit plans, and execution notes. -- `reference/`: audits, source comparisons, and supporting research. -- `staging/`: exploratory proposals before they become accepted documentation. - -## Documentation Process - -- Put early thinking in `staging/`. -- Write staged material in the same production-ready style expected of accepted docs. -- Promote staged material only after terminology, primitives, boundaries, and implementation direction are settled. -- When promoting staged material, move it to the proper resting place and make only the edits needed for fit and polish. -- Do not leave half-formed ideas in the permanent docs. diff --git a/packages/codex-js/docs/README.md b/packages/codex-js/docs/README.md deleted file mode 100644 index 7e8ffcb..0000000 --- a/packages/codex-js/docs/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# codex-js Docs - -This directory records the package model, architecture, integration surface, accepted design decisions, and engineering plans for `@jrkropp/codex-js`. - -Start with [Start Here](./start-here/README.md). - -Exploratory proposals live in [Staging](./staging/README.md) until their terminology, primitives, boundaries, and implementation direction are settled. - -## Package Source - -```text -src/ - upstream/ - codex-rs/ - t3code/ - - runtime/ - components/ - hooks/ - testing/ -``` - -The source structure is accepted in [ADR 0001](./design/decisions/0001-package-source-structure.md). - -## Documentation Areas - -- [Architecture](./architecture/README.md): production architecture explanations. -- [Design Decisions](./design/decisions/README.md): accepted ADR-style decisions. -- [Plans](./plans/README.md): implementation and refactor plans. -- [Reference](./reference/README.md): audits, source comparisons, and research. -- [Staging](./staging/README.md): exploratory thinking before acceptance. diff --git a/packages/codex-js/docs/architecture/README.md b/packages/codex-js/docs/architecture/README.md deleted file mode 100644 index c2d9ee9..0000000 --- a/packages/codex-js/docs/architecture/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Architecture - -Architecture docs describe the intended production design of the package. diff --git a/packages/codex-js/docs/design/decisions/0001-package-source-structure.md b/packages/codex-js/docs/design/decisions/0001-package-source-structure.md deleted file mode 100644 index 1fab786..0000000 --- a/packages/codex-js/docs/design/decisions/0001-package-source-structure.md +++ /dev/null @@ -1,47 +0,0 @@ -# 0001 Package Source Structure - -Status: accepted - -## Context - -`@jrkropp/codex-js` is a Codex runtime and UI kit. The package needs a source layout that makes upstream source trees obvious, keeps package-owned runtime code separate, and lets consuming applications extend behavior without editing package source. - -Codex and T3 are source references. Their folder structure, naming, concepts, classes, contracts, and lifecycle boundaries are preserved as closely as practical so updates can be ported by comparing the corresponding source files. - -## Decision - -The package source is organized around upstream source trees, a package-owned runtime, React components, React hooks, and testing utilities. - -```text -src/ - upstream/ - codex-rs/ - t3code/ - - runtime/ - components/ - hooks/ - testing/ -``` - -`src/upstream/codex-rs` is the Codex-shaped runtime upstream source. `src/upstream/t3code` is the T3-shaped chat UI upstream source. Code in these trees follows upstream names, file boundaries, contracts, and lifecycle patterns. - -`src/runtime` contains package-owned, platform-neutral Codex lifecycle code and contracts. It does not depend on React, routing, Cloudflare, Durable Objects, host application projects, or host-app business behavior. - -`src/components` contains the stable public React component surface built from the T3 upstream source. Developers import application-facing chat components from `components` rather than from the upstream tree. - -`src/hooks` contains the stable public React hooks that bind a configured runtime to React applications. Hooks stay separate from components so developers can use the runtime with their own UI. - -`src/testing` contains test utilities and lightweight helpers for package consumers and package tests. - -Platform-specific implementation details are not source primitives. Cloudflare Workers, Durable Objects, browser storage, routing, credentials, tools, prompts, and product-specific renderers live in consuming applications or documentation guides. - -## Consequences - -Upstream-shaped code is visually isolated from package-owned code. Package-owned abstractions stay outside the upstream trees. - -The package remains replaceable. Consuming applications extend behavior through composition, contracts, slots, renderers, tools, prompts, storage, and app-server boundaries instead of modifying package source. - -A Durable Object is one possible implementation of a Codex store and app-server boundary. It is not a primitive of the Codex assistant package. - -When behavior is wrong or unclear, the first step is to compare against Codex or T3 and realign the package with the corresponding source reference. diff --git a/packages/codex-js/docs/design/decisions/0002-core-runtime-boundary.md b/packages/codex-js/docs/design/decisions/0002-core-runtime-boundary.md deleted file mode 100644 index f3356e3..0000000 --- a/packages/codex-js/docs/design/decisions/0002-core-runtime-boundary.md +++ /dev/null @@ -1,74 +0,0 @@ -# 0002 Core Runtime Boundary - -Status: accepted - -## Context - -`@jrkropp/codex-js` follows Codex's runtime model and T3's chat interaction model. The package needs a runtime boundary that stays faithful to Codex while allowing consuming applications to choose their own storage, app-server implementation, routing, tools, prompts, auth, deployment, and product grouping. - -Codex already defines the storage-neutral persistence boundary through `ThreadStore`. A thread store can be backed by local files, memory, a remote service, a database, a Durable Object, or another host-owned implementation without changing the Codex runtime model. - -React chat surfaces use `CodexAppServer.threadResume` for protocol-shaped hydration. `ThreadReader` remains the narrow `readThread` plus `loadHistory` view for store-only and headless integrations; it is a read view over the Codex store boundary, not a competing storage primitive. - -Codex App Server is the execution role for Codex. It owns credentials, tools, prompts, model execution, persistence writes, and event emission. The package exposes this role to UI through `CodexAppServer`, matching Codex's upstream terminology. - -## Decision - -`ThreadStore` is the Codex storage boundary. A configured store represents the consuming application's storage scope, such as a local folder, database, remote service, or Durable Object. - -`ThreadReader` is the hook-level read boundary for integrations that hydrate directly from storage. Plug-and-play chat components hydrate from `CodexAppServer.threadResume`, which presents stored Codex history as a generated app-server `Thread` snapshot. - -`CodexAppServer` is the package UI boundary for Codex App Server communication. It mirrors Codex's generated typed request, response, notification, and server-request protocol with `ClientRequest`, `ServerNotification`, `ServerRequest`, and `RequestId`. `AppServerSession` owns request-id lifecycle and typed lifecycle helpers such as `threadStart`, `threadResume`, `turnStart`, `turnSteer`, `turnInterrupt`, and `threadCompactStart`. `PendingAppServerRequests` owns request-id pending UI state. App-server implementations hide platform details such as HTTP routes, WebSocket tickets, credentials, Durable Objects, and hosted service URLs. - -Core `EventMsg` values are runtime and storage internals. App-server implementations use a listener boundary to emit generated `ServerNotification` and `ServerRequest` shapes as the external event stream, track request ids, and order `serverRequest/resolved` notifications with the requests they resolve. - -`thread/resume` is protocol snapshot hydration. Resume responses and live event streams use the same generated app-server model; stored rollout history is source material for that model, not the browser contract. - -React chat state reduces generated app-server protocol events into `ThreadEventStore`. Hooks and components render `ThreadEventSnapshot` state derived from generated `Thread`, `Turn`, `ThreadItem`, `ServerNotification`, and `ServerRequest` values. Core events remain below the app-server boundary. - -Protocol state belongs in `src/runtime`; T3 projection belongs at the component boundary. The runtime reducer does not import T3 timeline types. Components create `CodexChatRenderState` from protocol snapshots and lifecycle UI state before rendering the T3-derived timeline, composer, banners, and pending-request slots. - -The package model uses Codex-shaped terms: - -- `Thread` -- `Turn` -- `ThreadStore` -- `ThreadReader` -- `LiveThread` -- `Submission` -- `Op` -- `Event` -- `EventMsg` -- `RolloutItem` -- `UserInput` -- `ThreadHistoryBuilder` -- `RenderedThreadState` -- `CodexAppServer` -- `ClientRequest` -- `ServerNotification` -- `ServerRequest` -- `RequestId` -- `AppServerSession` -- `PendingAppServerRequests` -- `ThreadEventStore` -- `ThreadEventSnapshot` - -Product grouping, account boundaries, workspace selection, and deployment placement are host-app or store implementation strategies. They are not core runtime primitives. - -The package layers remain explicit: - -- `src/upstream/codex-rs` is the faithful Codex runtime upstream source. -- `src/runtime` contains platform-neutral lifecycle contracts around Codex concepts. -- `src/components` contains the stable T3-derived React component surface. -- `src/hooks` contains React hooks around a configured runtime. -- The consuming app owns storage, routing, auth, tools, prompts, product renderers, and deployment. - -The app server runs Codex. The store remembers Codex. The UI renders Codex as generated app-server snapshots and live events. - -## Consequences - -Runtime APIs prefer Codex terminology over generic chat terminology. Ergonomic React components and hooks may expose friendlier APIs, but they build on the Codex-shaped runtime model. - -Applications extend the package through composition and stable extension points instead of modifying package source. Product-specific tools, prompts, auth, storage, renderers, and routes live in the consuming application. - -A Durable Object is one possible implementation of a Codex store and app-server boundary. It is not a primitive of the Codex assistant package. diff --git a/packages/codex-js/docs/design/decisions/0003-public-runtime-contract.md b/packages/codex-js/docs/design/decisions/0003-public-runtime-contract.md deleted file mode 100644 index 4517ffc..0000000 --- a/packages/codex-js/docs/design/decisions/0003-public-runtime-contract.md +++ /dev/null @@ -1,96 +0,0 @@ -# 0003 Public Runtime Contract - -Status: accepted - -## Context - -`@jrkropp/codex-js` exposes a public package surface on top of two upstream source trees: Codex for runtime semantics and T3 for chat interaction ownership. The public contract must stay small enough to understand quickly while remaining faithful to those source systems. - -The package surface contains ergonomic concepts only where they clarify usage without creating a second runtime model. The pressure test compares the public surface against Codex primitives, T3 lifecycle ownership, and common consuming application shapes. - -## Decision - -Codex terms define the runtime contract. The durable runtime concepts are: - -- `Thread` -- `Turn` -- `ThreadStore` -- `LiveThread` -- `Submission` -- `Op` -- `Event` -- `EventMsg` -- `RolloutItem` -- `UserInput` -- `ThreadHistoryBuilder` -- `RenderedThreadState` - -The public package surface is organized around a configured `ThreadStore`, its narrow hook-level `ThreadReader` read view, `CodexAppServer`, generated app-server protocol snapshots, and protocol-native chat state. A configured store represents the host application's storage scope. Product grouping is not a runtime primitive. - -`CodexAppServer` is the UI-facing boundary to Codex App Server. Its protocol types come from Codex's generated TypeScript schema. `AppServerSession` owns request-id lifecycle and typed lifecycle helpers. `PendingAppServerRequests` owns request-id pending UI state. The boundary can be implemented by a local process, Worker, Durable Object, or hosted service without changing package APIs. - -Core runtime events remain inside Codex history and projection code. `thread/resume` returns generated `ThreadResumeResponse` snapshots for initial hydration, and the app-server listener emits generated `ServerNotification` and `ServerRequest` values as the external stream. React chat state reduces those protocol values into `ThreadEventStore`; it does not reconstruct core events after the app-server boundary. - -Protocol state belongs in `runtime`. T3 projection belongs at the component boundary, where `ThreadEventSnapshot` and lifecycle UI state become `CodexChatRenderState` for the T3-derived timeline, composer, banners, and pending-request slots. Apps extend that presentation boundary through composition, not package source edits. - -T3 terms define the React chat lifecycle boundary. Optimistic rows, local dispatch snapshots, send-in-flight guards, composer handoff, draft promotion timing, scroll pinning, and route-friendly draft state belong to `components` and `hooks`, not to the Codex runtime upstream source. - -The canonical public import paths are: - -- `@jrkropp/codex-js/server` -- `@jrkropp/codex-js/react` -- `@jrkropp/codex-js/react` - -The package root is a small plug-and-play chat entrypoint. It does not flatten -runtime, hook, component, Codex mirror, or T3 mirror exports into one namespace. - -The Codex and T3 upstream source import paths remain available for advanced use, but app-facing code should prefer the canonical package surfaces. - -## Public Surface Classification - -| Concept | Classification | Decision | -| --- | --- | --- | -| `ThreadStore` | Codex-native | Use the Codex-shaped store contract as the storage boundary. | -| `ThreadReader` | Codex store read view | Use for store-only and headless hydration when hooks need only `readThread` and `loadHistory`. | -| `LiveThread` | Codex-native | Use for live thread lifecycle and store-backed thread operations. | -| `ClientRequest` | Codex app-server protocol | Use for typed client-to-server app-server method calls. | -| `ServerNotification` | Codex app-server protocol | Use for typed server-to-client notification flow. | -| `ServerRequest` | Codex app-server protocol | Use for server-to-client requests that require request-id resolution. | -| `RequestId` | Codex app-server protocol | Use to resolve or reject server requests. | -| `AppServerSession` | Codex app-server client helper | Own request-id lifecycle and typed lifecycle helpers over generated `ClientRequest` values. | -| `PendingAppServerRequests` | Codex app-server request state | Own pending UI state keyed by `RequestId`. | -| `ThreadEventStore` | Codex app-server protocol state | Own generated `Thread`, `Turn`, `ThreadItem`, pending server request, warning, error, active-turn, and connection state for chat UI. | -| `ThreadEventSnapshot` | Codex app-server protocol state | Expose immutable protocol-native state to hooks and components. | -| `Submission` | Codex-native | Use inside Codex runtime/session internals, not as the public UI response contract. | -| `Event` and `EventMsg` | Codex-native | Use for core runtime event flow inside runtime and storage internals. | -| `ThreadHistoryBuilder` | Codex-native | Use for low-level history projection. | -| `RenderedThreadState` | Codex-native projection | Keep as a low-level core projection, not the primary app-facing chat state. | -| `CodexChatRuntimeOptions` | Component ergonomic facade | Configure an app-server-backed chat runtime with optional thread and optional store reader fallback. | -| `CodexAppServer` | Codex app-server boundary | Shape around Codex generated `ClientRequest`, `ServerNotification`, `ServerRequest`, `RequestId`, event streaming, and request-id resolution; hide route, credential, WebSocket, and platform details in the host adapter. | -| Component and hook props | React ergonomics | Keep package-name-neutral and store-centered. | -| Draft helpers | T3 lifecycle/app routing | Keep in `hooks` or host-app glue unless they operate only on Codex data. | -| Local dispatch helpers | T3 lifecycle | Keep with chat lifecycle code, close to `ChatView` and composer ownership. | - -## Pressure Test Findings - -| Scenario | Required package concepts | Host-owned concepts | Result | -| --- | --- | --- | --- | -| Local file-backed app | `ThreadStore`, `LiveThread`, `Submission`, `ThreadEventStore`, hooks or components | Local file paths, user identity, persistence location | Passes when the store is configured before entering runtime. | -| Cloudflare Durable Object app | Same runtime concepts plus an app-server implementation | Durable Object naming, bindings, auth, routing, deployment | Passes when Durable Object placement is hidden behind store and app-server boundaries. | -| Custom product app | Runtime plus renderer/tool/prompt extension points | Product prompts, tools, auth, renderers, route paths | Passes when extensions enter through composition rather than package source edits. | -| Headless app | `runtime` and `hooks` | Entire UI | Passes when hooks expose state/actions without requiring package components. | -| Plug-and-play app | `components` with configured reader and app server | Store, reader, and app-server construction | Passes when the component API does not expose routes, Cloudflare, deployment placement, or T3 internals. | - -## Consequences - -Runtime APIs stay Codex-shaped. React APIs stay approachable, but they do not introduce a second runtime model. - -Cloudflare Durable Objects, local directories, databases, and remote services are all store configuration strategies. - -The app server runs Codex. The store remembers Codex. The UI renders Codex as generated app-server snapshots and live events. - -`CodexAppServer` is how UI reaches the app server. It sends typed client requests over the app-server JSON-RPC connection, receives typed notifications and server requests on that same connection, resolves or rejects server requests by `RequestId`, and keeps delivery details out of the package contract. The app-server implementation is provided by the consuming application and is not exported as a separate package subpath. - -Drafts are treated as chat lifecycle state coordinated by T3-shaped hooks and components. Host apps may reflect draft state in routes, but routing is not part of the package runtime contract. - -When the public API is unclear, compare against Codex first for runtime semantics and T3 first for chat lifecycle ownership. diff --git a/packages/codex-js/docs/design/decisions/README.md b/packages/codex-js/docs/design/decisions/README.md deleted file mode 100644 index 8520b0b..0000000 --- a/packages/codex-js/docs/design/decisions/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Design Decisions - -Accepted architecture decisions live here. - -- [0001 Package Source Structure](./0001-package-source-structure.md) -- [0002 Core Runtime Boundary](./0002-core-runtime-boundary.md) -- [0003 Public Runtime Contract](./0003-public-runtime-contract.md) diff --git a/packages/codex-js/docs/plans/README.md b/packages/codex-js/docs/plans/README.md deleted file mode 100644 index ad9f847..0000000 --- a/packages/codex-js/docs/plans/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Plans - -Implementation plans, refactor plans, audit plans, and execution notes live here. - -Plans are actionable engineering documents. They describe how work is carried out. Accepted docs describe the intended production design as if it already exists. diff --git a/packages/codex-js/docs/plans/runtime-contract-refactor.md b/packages/codex-js/docs/plans/runtime-contract-refactor.md deleted file mode 100644 index 2515921..0000000 --- a/packages/codex-js/docs/plans/runtime-contract-refactor.md +++ /dev/null @@ -1,48 +0,0 @@ -# Runtime Contract Refactor Plan - -This plan aligns the package implementation with the accepted public runtime contract. - -## Summary - -The runtime layer uses Codex primitives directly. The React layer provides ergonomic components and hooks without becoming a second runtime model. Host applications configure stores, transports, prompts, tools, auth, routing, product renderers, and deployment outside the package. - -## Runtime - -- Make `@jrkropp/codex-js/server` the canonical runtime import surface. -- Re-export Codex-native types from runtime: `ThreadStore`, `LiveThread`, `Submission`, `Event`, `EventMsg`, `Op`, `RolloutItem`, `UserInput`, `ThreadHistoryBuilder`, and `RenderedThreadState`. -- Replace store-addressing runtime options with configured store and transport options. Product grouping is represented by the store instance supplied by the consuming app. -- Rename `CodexAssistantOptions` to package-name-neutral runtime and React option types. - -## Transport - -- Shape transport around Codex dispatch semantics: `submit`, `subscribe`, and `stop`. -- Keep friendly `sendMessage` helpers in hooks or components where text input is converted into a Codex `Submission`. -- Keep Cloudflare, Durable Object, browser storage, and local file examples outside the runtime primitive set. - -## Components And Hooks - -- Keep T3-shaped lifecycle ownership in `components` and `hooks`: optimistic user rows, local dispatch snapshots, send guard, draft promotion timing, composer draft handoff, scroll pinning, and rendered timeline coordination. -- Ensure `` works without React Router, Cloudflare, Durable Object terminology, host application project terminology, or T3 upstream source imports. -- Ensure `useCodexChat` supports headless custom UI while still returning Codex-shaped thread state and ergonomic send/stop actions. - -## Documentation - -- Present plug-and-play, headless, local file-backed, and Cloudflare Durable Object examples as consumer integrations. -- Describe Cloudflare as one implementation of store and transport boundaries. -- Keep docs explicit that package source is replaceable and consuming apps extend through composition, not package source edits. - -## Test Plan - -- Update package boundary tests so canonical exports include `/runtime`, `/components`, and `/hooks`. -- Add runtime tests showing configured stores work without React Router, Cloudflare, or host application product concepts. -- Add hook/component tests showing friendly message input becomes a Codex `Submission`. -- Add examples or tests for local, Cloudflare, headless, and plug-and-play usage that import only canonical public surfaces. -- Keep boundary tests proving Codex and T3 upstream-shaped paths remain available for advanced use. - -## Acceptance Criteria - -- A developer can understand the package through three import paths: `runtime`, `components`, and `hooks`. -- Runtime docs use Codex terms for durable lifecycle concepts. -- React docs use T3-shaped lifecycle language for chat interaction ownership. -- No core runtime API requires product grouping, routes, Durable Objects, or host application-specific concepts. -- Product-specific tools, prompts, auth, storage, routing, renderers, and deployment remain outside package source. diff --git a/packages/codex-js/docs/reference/README.md b/packages/codex-js/docs/reference/README.md deleted file mode 100644 index e797979..0000000 --- a/packages/codex-js/docs/reference/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Reference - -Reference material, audits, source comparisons, and supporting research live here. - -Unchecked upstream source trees do not belong in this docs folder. Keep them in -the repo-root `external/` directory instead, ideally synced by: - -```bash -pnpm external:sync --codex /path/to/codex --t3 /path/to/t3-chat -``` - -That keeps the reference source available for parity work without checking -vendor copies into git history. diff --git a/packages/codex-js/docs/staging/README.md b/packages/codex-js/docs/staging/README.md deleted file mode 100644 index ed8306f..0000000 --- a/packages/codex-js/docs/staging/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Staging - -This directory holds exploratory proposals before they become accepted package documentation. - -Staged documents are still written in production-ready prose. The ideas may be unsettled; the writing should not be. - -Promote a staged document only after its terminology, primitives, boundaries, and implementation direction are settled. diff --git a/packages/codex-js/docs/staging/core-realizations.md b/packages/codex-js/docs/staging/core-realizations.md deleted file mode 100644 index 1c58b91..0000000 --- a/packages/codex-js/docs/staging/core-realizations.md +++ /dev/null @@ -1,169 +0,0 @@ -# Core Realizations - -The package is a Codex runtime and UI kit, not a Cloudflare, Durable Object, React Router, or host application package. - -Do not make app grouping the primitive. Make the store the boundary. - -A configured `ThreadStore` represents the host app's storage scope. - -`ThreadReader` is the narrow read view over `ThreadStore`; store-only and headless hooks should not require full store lifecycle methods when they only read metadata and history. - -`thread/resume` is protocol snapshot hydration. Plug-and-play chat should hydrate from `CodexAppServer.threadResume`; `ThreadReader` is the store-only fallback. - -Codex is a thread runtime over an event log, not a chat-message store. - -`ThreadStore` stores Codex history. App-server resume translates that history into a generated `Thread` snapshot for UI. - -Codex App Server is the adapter boundary between UI and runtime. - -The app server runs Codex. The store remembers Codex. The UI renders Codex. - -`CodexAppServer` is how UI reaches the app server; the name mirrors Codex's upstream app-server terminology. - -Codex App Server is not just lifecycle verbs; it is the protocol shape: `ClientRequest`, `ServerNotification`, `ServerRequest`, and `RequestId`. - -Codex App Server protocol types come from Codex's generated TypeScript schema. Package-owned code wraps the generated protocol; it does not redefine it. - -Core events are internal. App-server notifications are the wire contract. - -The app-server listener is the live delivery boundary. It translates core events, tracks request ids, and orders server-request resolution without changing stored history. - -Resume snapshot and live stream are the same app-server model; stored history is only the source material. - -After the app-server boundary, React should reduce protocol events, not reconstruct core events. - -`ThreadEventStore` is the protocol-native UI state store. It owns generated `Thread`, `Turn`, `ThreadItem`, pending `ServerRequest`, warning, error, active-turn, and connection state. - -Protocol state belongs in runtime; T3 projection belongs at the component boundary. - -The T3 adapter is the presentation boundary; apps extend it by composition, not by editing package source. - -The package owns defaults; apps extend presentation through slots, not source edits. - -Architecture is not complete until the integration path is obvious. - -`CodexChat` is the UI doorway. `createCodexAppServerClient` is the app-server doorway. - -`CodexAppServerMessageProcessor` is the server doorway. The package dispatches Codex protocol; the app implements Codex behavior. - -`createCodexAppServerRuntime` is the runtime doorway. The package can run Codex without owning deployment: runtime is Codex; storage, credentials, tools, and transport are app choices. - -The runtime boundary is complete when the production app no longer reimplements Codex session lifecycle. - -Once the runtime doorway works, delete the parallel lifecycle doorway. - -Codex server delivery is not a generic event bus. `OutgoingMessageSender`, -`ThreadScopedOutgoingMessageSender`, `ThreadState`, and `ThreadStateManager` -carry ordering, request-id callbacks, listener lifecycle, and active-turn state. - -Public runtime exports are integration doorways. Codex app-server machinery stays -inside the runtime unless an application boundary needs it directly. - -The production app proves the package by being boring. host application consumes -runtime doorways, while protocol mapping and resume snapshot construction stay -inside the package runtime. - -Examples are architecture. If the example hand-rolls lifecycle, consumers will -too. - -Server-request responses belong in the runtime. The app resolves or rejects by -generated `RequestId`; the package turns that into the internal Codex session -response path. - -A public API is not obvious until a minimal app can use it without private knowledge. - -`AppServerSession` owns request-id lifecycle. UI code should not assemble app-server request ids ad hoc. - -`PendingAppServerRequests` owns request-id pending UI state. Server requests are resolved or rejected by `RequestId`. - -Codex starts and resumes threads explicitly through app-server requests. `ensure` is listener and runtime attachment semantics, not public thread creation semantics. - -Once the app-server boundary is Codex-shaped, HTTP, WebSocket, Durable Object RPC, local process, and hosted service are delivery mechanisms. - -A Durable Object is one possible implementation of a Codex store and app-server boundary. It is not a primitive of the Codex assistant package. - -Local files, IndexedDB, SQL, and Durable Objects are storage implementations of the same Codex store boundary. - -The package should follow Codex's conversation model and lifecycle while leaving storage, routing, deployment, and host-app grouping decisions to adapters. - -Runtime uses Codex terms. Ergonomic components and hooks can expose friendlier APIs. - -When Codex already has the right concept, preserve Codex's vocabulary. Names like `CodexAppServer` carry architecture and make upstream changes easier to map. - -The package should be easy at the edge and faithful at the core. Developers get simple APIs and components, while the internals stay close to Codex and T3 naming, structure, and lifecycle. - -Upstream-shaped source should be visually obvious in the folder structure. Codex and T3 upstream sources are source references; package-owned primitives and public APIs live outside those upstream trees. - -The public React surface should be named for what developers use, not where the implementation came from. T3 remains the upstream source tree; `components` and `hooks` are the stable React surfaces. - -Developers should extend by composition, not by editing package source. Business tools, prompts, auth, storage, custom rendering, and product-specific interactions live in the consuming app. - -Apps extend through composition, not package source edits. - -The package should be replaceable. A consuming app should be able to update the package without overwriting its business-specific customizations. - -Adapters are not primitives. The package exposes contracts; platform-specific implementations belong in host apps, examples, or documentation guides. - -Extension points should be intentional. The package exposes stable boundaries such as store, app server, tools, prompts, renderers, slots, and runtime configuration without turning every internal mechanism into public API. - -The model should stay Codex-shaped, not host application-shaped. host application projects, routes, prompts, tools, and Durable Object layout are host-app choices, not package primitives. - -`ChatRuntime` is an ergonomic component-surface facade, not a second runtime. It reads from the same protocol-native lifecycle as `CodexChatView`. - -Friendly `sendMessage` APIs belong at the component edge. Runtime dispatch is Codex-shaped app-server lifecycle flow. - -Codex App Server is maintained by processor boundaries: thread requests, turn requests, thread state, outgoing messages, and bespoke event handling. - -Session creation is a runtime boundary: it attaches ThreadStore history, LiveThread persistence, SessionConfiguration, and app-owned overrides before processors run turns. - -Task execution is a runtime boundary: request processors choose app-server verbs, -`CodexSessionTaskRunner` starts `RegularTask` or `CompactTask`, and -`ModelClientSession` stays turn-scoped inside Codex execution. - -Codex execution helpers live in upstream core; package runtime composes them -through app-server processors. - -Tool calls are core turn-loop work; app-server requests are the outside-input boundary. - -Tool definitions are runtime affordances. Tool calls and tool results become -thread history, but tool availability comes from the tool registry for each -turn. - -Web search is a hosted Responses API tool. Top-level `web_search` selects -disabled, cached, or live mode; `[tools.web_search]` only configures context, -domain filters, and approximate location. - -Cached web search is the effective Codex default. Live search is a configured -mode or a no-sandbox turn fallback, not an app-owned dynamic tool. - -App-owned dynamic tools let the application teach Codex what capabilities exist -without letting the package own product execution. - -`tool_search` is BM25 over deferred tool metadata. The model chooses the query; -Codex deterministically ranks tool names, namespaces, descriptions, and schema -property names. - -`RequestId` is app-server correlation. `call_id` is model and tool correlation. - -One core tool event may emit multiple app-server protocol messages. - -User feedback is a Codex tool request. T3 renders it as composer state, and apps -customize presentation without changing the generated protocol. - -`RequestId` is the app-server request identity. `itemId` and core `call_id` are -model/tool item identities. - -Plan Mode is Codex collaboration state rendered through T3, not a separate chat -product. - -Proposed plans are protocol thread items. T3 renders `Plan` items as plan cards -and applications customize plan actions at the component boundary. - -The composer is a T3 presentation primitive. Codex protocol state enters through -package adapters; app commands, skills, realtime controls, model choices, and -unavailable host actions enter as typed component props. - -Composer shortcuts are interaction contracts, not incidental UI. `/`, `@`, `$`, -arrow navigation, Enter/Tab selection, and Shift+Tab mode switching should stay -aligned with T3 so developers get the expected chat workflow without importing -T3 internals. diff --git a/packages/codex-js/docs/start-here/00-system-tour.md b/packages/codex-js/docs/start-here/00-system-tour.md deleted file mode 100644 index 5513a4a..0000000 --- a/packages/codex-js/docs/start-here/00-system-tour.md +++ /dev/null @@ -1,71 +0,0 @@ -# System Tour - -`@jrkropp/codex-js` is a portable Codex runtime and T3-shaped -chat UI kit. It is not a host application package, a Cloudflare package, or a React -Router package. host application is one consuming application that proves the -package boundary. - -## Layers - -The package has four layers: - -| Layer | Responsibility | -| --- | --- | -| `src/upstream/codex-rs` | Codex runtime, thread store, protocol, tools, model transport, and app-server protocol primitives. | -| `src/upstream/t3code` | T3Chat composer, timeline, model picker, image previews, command menus, and chat interaction helpers. | -| `src/runtime` | Package-owned Codex lifecycle contracts, app-server boundary, store boundary, and route-neutral protocol state. | -| `src/components` and `src/hooks` | Stable React surfaces that bind Codex protocol state to T3-derived chat presentation. | - -Codex source defines runtime semantics. T3 source defines browser interaction -ownership. The package facades connect the two without letting product behavior -leak into either upstream-shaped tree. - -## Runtime Flow - -The app server runs Codex. The store remembers Codex. The UI renders Codex. - -```text -host app - -> CodexAppServer JSON-RPC WebSocket ClientRequest - -> package runtime request processors - -> Codex Session and ThreadStore - -> generated ServerNotification or ServerRequest - -> ThreadEventStore - -> CodexChatRenderState - -> T3 timeline and composer -``` - -Core `EventMsg` values stay inside Codex runtime and stored history. Browser UI -uses generated app-server protocol values over one app-server connection: -`ClientRequest`, typed responses, `Thread`, `Turn`, `ThreadItem`, -`ServerNotification`, `ServerRequest`, and `RequestId`. - -## Host Integration - -A consuming app provides product policy and platform placement: - -- storage implementation for `ThreadStore` or a remote app-server WebSocket -- credentials and model-client creation -- prompts, developer instructions, dynamic tools, and scopes -- routes, auth, deployment, WebSocket delivery, and product renderers - -host application supplies those pieces from its app folders. The package never -imports host application routes, domains, Worker bindings, storage keys, prompts, or -branding. - -## Public Doorways - -Most integrations should enter through the public surfaces: - -- `@jrkropp/codex-js/server` -- `@jrkropp/codex-js/react` -- `@jrkropp/codex-js/react` - -The package root is intentionally small and only exposes the plug-and-play chat -component entrypoint. Runtime, hook, component, Codex mirror, and T3 mirror APIs -stay on their explicit subpaths. - -The upstream-shaped Codex and T3 import paths remain available for low-level -adapter work, tests, and source-parity updates. Product UI should prefer the -public facades unless it is intentionally bridging into a specific upstream -primitive. diff --git a/packages/codex-js/docs/start-here/01-design-philosophy.md b/packages/codex-js/docs/start-here/01-design-philosophy.md deleted file mode 100644 index 642f0d2..0000000 --- a/packages/codex-js/docs/start-here/01-design-philosophy.md +++ /dev/null @@ -1,56 +0,0 @@ -# Design Philosophy - -The core design rule is simple: - -```text -Codex owns runtime truth. -T3 owns interaction quality. -The host app owns product meaning. -``` - -This avoids a custom product-specific chat runtime. The package preserves Codex -concepts for execution and persistence while using T3-shaped components for the -browser chat experience. - -## Upstream First - -The upstream source trees are the maintenance strategy. File names, folder -boundaries, protocol names, and lifecycle concepts stay close to Codex and T3 so -future source drops can be compared and ported directly. - -Package-owned abstractions live outside the upstream trees. If a behavior is -product-specific, expose a contract, prop, renderer, tool, prompt, or adapter -slot instead of editing upstream-shaped package code. - -## Boundaries Over Abstractions - -The package avoids generic "chat" abstractions where Codex already has precise -terms. `ThreadStore`, `LiveThread`, `Session`, `Submission`, `EventMsg`, -`RolloutItem`, `CodexAppServer`, `ServerRequest`, and `RequestId` carry -runtime meaning and make upstream parity easier to preserve. - -React ergonomics are allowed at the component edge. `CodexChat`, -`CodexChatView`, and `useCodexChat` provide approachable APIs, but they all -reduce the same protocol-native lifecycle state. They do not create a second -runtime model. - -## Product Isolation - -Host applications own the parts that make an assistant product-specific: - -- prompts and developer instructions -- dynamic tool specs and execution -- account and credential policy -- route paths and draft routing -- storage placement and deployment -- product actions, banners, mentions, and custom renderers - -Those choices enter through stable package contracts. They do not belong in -`src/upstream/codex-rs`, `src/upstream/t3code`, or package runtime internals. - -## Current Truth - -The browser-facing chat contract is generated Codex app-server protocol. -`EventMsg` remains a core runtime and storage primitive; it is not the React UI -wire contract. `ThreadEventStore` reduces generated protocol snapshots, -notifications, and server requests before T3 presentation code renders them. diff --git a/packages/codex-js/docs/start-here/02-primitives-and-boundaries.md b/packages/codex-js/docs/start-here/02-primitives-and-boundaries.md deleted file mode 100644 index d90fab2..0000000 --- a/packages/codex-js/docs/start-here/02-primitives-and-boundaries.md +++ /dev/null @@ -1,101 +0,0 @@ -# Primitives And Boundaries - -This page names the package primitives and where application behavior attaches. - -## Runtime Primitives - -| Primitive | Boundary | -| --- | --- | -| `ThreadStore` | Full Codex persistence boundary for thread metadata and ordered rollout history. | -| `ThreadReader` | Narrow read view over `ThreadStore` for store-only or headless integrations. | -| `LiveThread` | Active store-backed handle used by Codex sessions. | -| `CodexAppServer` | UI-facing boundary for generated Codex app-server requests, responses, notifications, and server requests. | -| `AppServerSession` | Client helper that owns request ids and typed lifecycle calls such as `threadStart`, `threadResume`, and `turnStart`. | -| `CodexAppServerMessageProcessor` | Connection-scoped control plane that handles initialize, experimental capability checks, request serialization, and method dispatch. | -| `RequestSerializationQueues` | Codex-style keyed FIFO queue for same-scope requests such as one thread, one config domain, or one process. | -| `ConnectionRpcGate` | Connection lifecycle gate that accepts work while open and rejects late work after shutdown. | -| `ModelClient` | Session-scoped model transport boundary that owns provider config, auth material, WebSocket fallback state, and cached turn WebSocket state. | -| `ModelClientSession` | Turn-scoped model streaming boundary that prewarms Responses WebSocket, replays `x-codex-turn-state`, streams model events, and releases cached transport state back to `ModelClient`. | -| `PendingAppServerRequests` | Request-id indexed pending state for server requests that need a client or app response. | -| `ThreadEventStore` | Protocol-native React state store for generated `Thread`, `Turn`, `ThreadItem`, `ServerNotification`, and `ServerRequest` values. | -| `CodexChatRenderState` | Component-layer adapter from protocol state to T3 timeline, composer, banners, and pending request slots. | - -`Submission`, `Op`, `Event`, `EventMsg`, `RolloutItem`, and -`RenderedThreadState` remain Codex runtime and storage concepts. They are useful -inside the runtime and tests, but app-facing React code should usually work with -`CodexAppServer`, `ThreadEventSnapshot`, and package components or hooks. - -## App Server Boundary - -`CodexAppServer` is the browser doorway to Codex App Server. It accepts generated -`ClientRequest` values, returns typed method responses, streams generated -`ServerNotification` and `ServerRequest` values, and resolves or rejects server -requests by `RequestId`. - -Each app-server connection starts with `initialize`. After that, the message -processor reads generated protocol metadata to decide whether a request is -experimental, whether it must serialize with another request, and which -processor owns it. Browser chat is therefore a generated app-server protocol -client, not a raw `Submission` or `EventMsg` transport. - -The production browser delivery mechanism is one Codex app-server WebSocket. -That socket carries generated JSON-RPC requests, responses, notifications, and -server requests. Route paths, WebSocket tickets, credential headers, Durable -Object names, and deployment details remain host-owned. - -## Model Transport Boundary - -The OpenAI model transport is separate from the browser app-server WebSocket. -Codex runtime creates a session-scoped `ModelClient`; each turn creates a -`ModelClientSession`. The session prefers OpenAI Responses WebSocket, -prewarms with `generate: false`, captures sticky turn state, sends -`response.processed`, and falls back to HTTP/SSE for the rest of the session -when the WebSocket path is unavailable. - -The package owns the Codex-shaped transport classes and request serialization. -The host app owns credentials, provider policy, project prompts, tools, and -where the runtime is allowed to make outbound OpenAI requests. - -## Tool Boundary - -Dynamic tools are app-owned capabilities registered with Codex. The package owns -tool discovery, model-facing specs, generated server requests, and reinjecting -results into the Codex turn loop. The app owns business execution, credentials, -permissions, and product data. - -`request_user_input` follows the same separation. Codex exposes the tool, emits -a generated server request, and T3 renders pending questions. The app resolves -the request by `RequestId`. - -## Presentation Boundary - -The T3-derived composer and timeline own interaction mechanics: optimistic -rows, scroll pinning, image attachments, draft restoration, command menus, -pending input, and proposed-plan cards. - -Applications customize presentation through component props and render slots: - -- `composerCommands` and `composerSkills` -- `mentionRefs` -- `renderPendingRequest` -- `renderPendingUserInput` -- `renderBannerItems` -- `renderTimelineExtras` -- `onImplementProposedPlan` - -These extension points keep product behavior outside package internals while -allowing each host app to make the chat surface feel native. - -## Host-App Boundary - -The consuming app owns everything that changes by product or deployment: - -- prompts and developer instructions -- dynamic tool specs and resolvers -- storage placement and `ThreadStore` implementation -- model credential policy and model-client construction -- route paths, draft promotion, and thread list placement -- branded UI actions and product-specific rendering - -If a new behavior depends on any of those concerns, add or use a host extension -point instead of changing Codex or T3 upstream-shaped source. diff --git a/packages/codex-js/docs/start-here/03-tool-calling.md b/packages/codex-js/docs/start-here/03-tool-calling.md deleted file mode 100644 index 5513449..0000000 --- a/packages/codex-js/docs/start-here/03-tool-calling.md +++ /dev/null @@ -1,309 +0,0 @@ -# Tool Calling - -Codex treats tools as runtime affordances. A tool definition tells the model what -capability exists. A tool call is the model choosing that capability during a -turn. A tool result is the runtime feeding the outside-world result back into -the next model step. - -The package keeps those responsibilities separate: - -```text -App-owned tool specs - -> ToolRouter - -> visible tools or tool_search - -> model tool call - -> ServerRequest item/tool/call - -> app-owned execution - -> RequestId resolution - -> function_call_output for the model -``` - -## Dynamic Tools - -Dynamic tools are app-owned capabilities. The package owns discovery, protocol, -request identity, and model-loop reinjection. The application owns business -execution, credentials, policy, permissions, and product data. - -```ts -const billingTools = [ - { - namespace: "billing", - name: "lookup_invoice", - description: "Look up an invoice by invoice id.", - input_schema: { - type: "object", - properties: { - invoiceId: { type: "string" }, - }, - required: ["invoiceId"], - additionalProperties: false, - }, - defer_loading: false, - }, - { - namespace: "billing", - name: "refund_invoice", - description: "Refund an invoice after checking policy constraints.", - input_schema: { - type: "object", - properties: { - invoiceId: { type: "string" }, - reason: { type: "string" }, - }, - required: ["invoiceId", "reason"], - additionalProperties: false, - }, - defer_loading: true, - }, -]; -``` - -Visible tools use `defer_loading: false`. Codex includes their definitions in -the model request's `tools` list. - -Deferred tools use `defer_loading: true`. Codex keeps them registered in the -runtime, excludes them from the ordinary model-facing tool list, and makes them -discoverable through `tool_search`. - -## Tool Search - -`tool_search` is a client-executed Codex tool. Codex exposes it when deferred -dynamic or MCP tools are available. The model supplies a query; Codex searches -tool metadata with BM25 and returns matching loadable tool specs. - -Codex indexes metadata, not embeddings: - -```text -tool name -tool name with underscores expanded -namespace -description -input schema property names -``` - -For example, `billing.refund_invoice` is searchable by `billing`, `refund`, -`invoice`, `reason`, and any meaningful words in the description. - -## Hosted Web Search - -Web search is a hosted Responses API tool. Codex controls it with top-level -`web_search` config and refines it with `[tools.web_search]`. - -```toml -web_search = "cached" - -[tools.web_search] -context_size = "high" -allowed_domains = ["openai.com", "platform.openai.com"] - -[tools.web_search.location] -country = "US" -region = "CA" -city = "San Francisco" -timezone = "America/Los_Angeles" -``` - -The effective default is `cached`. Cached search sends `web_search` with -`external_web_access: false`; live search sends it with -`external_web_access: true`; disabled search omits the hosted tool. Boolean -`[tools].web_search` values are accepted as legacy no-op payloads and do not -enable or disable the tool. - -Web search is not a dynamic tool. It does not emit `ServerRequest`, does not use -`RequestId`, and does not ask for per-call approval. Search activity appears as -normal generated thread items such as `ThreadItem.webSearch`, which T3 renders -as passive work-log activity. - -## App-Owned Execution - -When the model calls an app-owned dynamic tool, Codex emits a generated -app-server request: - -```ts -{ - id: "req_17", - method: "item/tool/call", - params: { - threadId: "thread_123", - turnId: "turn_abc", - callId: "call_refund_1", - namespace: "billing", - tool: "refund_invoice", - arguments: { - invoiceId: "INV-1001", - reason: "Customer was double charged", - }, - }, -} -``` - -The app handles the business action and resolves the request by `RequestId`: - -```ts -async function handleServerRequest(request: ServerRequest) { - if ( - request.method === "item/tool/call" && - request.params.namespace === "billing" && - request.params.tool === "refund_invoice" - ) { - const refund = await billing.refundInvoice(request.params.arguments); - - await appServer.resolveServerRequest(request.id, { - contentItems: [ - { - type: "inputText", - text: JSON.stringify(refund), - }, - ], - success: true, - }); - } -} -``` - -`RequestId` and `call_id` have different jobs: - -```text -RequestId: app-server request correlation -call_id: model/tool-loop correlation -``` - -The browser, server, and UI resolve or reject `ServerRequest` values by -`RequestId`. Codex uses `call_id` internally to attach the tool result to the -model's original function call. - -## User Feedback Requests - -`request_user_input` is a Codex tool. The model calls it during a turn when it -needs the user to answer a small set of structured questions. Codex emits the -request through the app-server protocol, and T3 renders it as composer state: - -```text -request_user_input tool - -> EventMsg::RequestUserInput - -> ServerRequest item/tool/requestUserInput - -> pending composer input - -> resolveServerRequest(RequestId, ToolRequestUserInputResponse) -``` - -The app-server request keeps protocol identity and tool identity separate: - -```ts -{ - id: "req_21", - method: "item/tool/requestUserInput", - params: { - threadId: "thread_123", - turnId: "turn_abc", - itemId: "call_plan_questions", - questions: [ - { - id: "direction", - header: "Direction", - question: "Which direction should Codex explore first?", - options: [ - { - label: "Small patch (Recommended)", - description: "Keep the change narrowly scoped.", - }, - { - label: "Full refactor", - description: "Rework the full module now.", - }, - ], - isOther: true, - isSecret: false, - }, - ], - }, -} -``` - -The UI resolves by `RequestId`. `params.itemId` is the model/tool item id and is -not used as the app-server request identity. - -```tsx - { - if (request.pendingUserInput.questions[0]?.id === "direction") { - return ( - resolve(response)} - /> - ); - } - return defaultNode; - }} -/> -``` - -The default package UI renders `request_user_input` inside the composer. Apps -customize presentation through `renderPendingUserInput`; they do not create a -custom protocol or resolve by tool `call_id`. - -## Plan Mode - -Plan Mode uses the same tool and protocol boundaries. Codex injects Plan Mode -collaboration instructions into the turn context, the model can call -`request_user_input` to collect structured feedback, and final plan content is -emitted inside `` blocks. The Codex turn loop strips those blocks -from normal assistant text and emits generated `Plan` item notifications. - -```text -Plan collaboration mode - -> request_user_input when more direction is needed - -> final plan markdown - -> item/plan/delta and completed ThreadItem.Plan - -> T3 ProposedPlanCard -``` - -`CodexChat` can expose the T3-shaped Build/Plan toggle: - -```tsx - -``` - -Applications keep product behavior at the component edge. A custom app can -listen for proposed-plan actions, route implementation into a product workflow, -or keep the default T3 behavior that sends `PLEASE IMPLEMENT THIS PLAN:` back to -Codex. - -## UI Extension - -Applications customize tool UX through component slots. The default chat surface -can render a product-specific confirmation panel for mutating tools without -editing package source. - -```tsx - { - if ( - request.kind === "dynamicToolCall" && - request.request.params.namespace === "billing" && - request.request.params.tool === "refund_invoice" - ) { - return ( - resolve(result)} - onReject={() => reject("Refund rejected by the application.")} - /> - ); - } - return defaultNode; - }} -/> -``` - -This is the core extension model: Codex owns the turn loop and protocol; the app -owns product meaning. diff --git a/packages/codex-js/docs/start-here/README.md b/packages/codex-js/docs/start-here/README.md deleted file mode 100644 index 614840c..0000000 --- a/packages/codex-js/docs/start-here/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Start Here - -- [System Tour](./00-system-tour.md) -- [Design Philosophy](./01-design-philosophy.md) -- [Primitives And Boundaries](./02-primitives-and-boundaries.md) -- [Tool Calling](./03-tool-calling.md) diff --git a/packages/codex-js/package.json b/packages/codex-js/package.json index 10cf480..50b76ff 100644 --- a/packages/codex-js/package.json +++ b/packages/codex-js/package.json @@ -1,6 +1,6 @@ { "name": "@jrkropp/codex-js", - "version": "0.2.0", + "version": "0.3.0", "description": "Unofficial TypeScript Codex runtime for building Codex-backed web apps.", "license": "Apache-2.0", "type": "module", diff --git a/packages/codex-js/src/internal/codex/app-server/src/bespoke_event_handling.ts b/packages/codex-js/src/internal/codex/app-server/src/app_server_event_mapping.ts similarity index 92% rename from packages/codex-js/src/internal/codex/app-server/src/bespoke_event_handling.ts rename to packages/codex-js/src/internal/codex/app-server/src/app_server_event_mapping.ts index 61e16b8..7c7c75a 100644 --- a/packages/codex-js/src/internal/codex/app-server/src/bespoke_event_handling.ts +++ b/packages/codex-js/src/internal/codex/app-server/src/app_server_event_mapping.ts @@ -13,7 +13,7 @@ export type { ServerRequestCoreTarget, }; -export function apply_bespoke_event_handling( +export function mapCoreEventToAppServerEvents( msg: EventMsg, context: EventMappingContext, ): AppServerProtocolEvent[] { diff --git a/packages/codex-js/src/internal/codex/app-server/src/message_processor.ts b/packages/codex-js/src/internal/codex/app-server/src/message_processor.ts index 95c22a1..53b31b5 100644 --- a/packages/codex-js/src/internal/codex/app-server/src/message_processor.ts +++ b/packages/codex-js/src/internal/codex/app-server/src/message_processor.ts @@ -165,6 +165,17 @@ export type InitializedConnectionSessionState = { optedOutNotificationMethods: ReadonlySet; }; +export type CodexAppServerConnectionSnapshot = { + initialized: InitializedConnectionSessionSnapshot | null; +}; + +export type InitializedConnectionSessionSnapshot = { + appServerClientName: string; + clientVersion: string; + experimentalApiEnabled: boolean; + optedOutNotificationMethods: string[]; +}; + export class CodexAppServerConnectionSessionState { readonly rpcGate = new ConnectionRpcGate(); private initializedState: InitializedConnectionSessionState | null = null; @@ -199,6 +210,38 @@ export class CodexAppServerConnectionSessionState { clientVersion(): string | null { return this.initializedState?.clientVersion ?? null; } + + snapshot(): CodexAppServerConnectionSnapshot { + return { + initialized: this.initializedState + ? { + appServerClientName: this.initializedState.appServerClientName, + clientVersion: this.initializedState.clientVersion, + experimentalApiEnabled: + this.initializedState.experimentalApiEnabled, + optedOutNotificationMethods: Array.from( + this.initializedState.optedOutNotificationMethods, + ), + } + : null, + }; + } + + static fromSnapshot( + snapshot?: CodexAppServerConnectionSnapshot | null, + ): CodexAppServerConnectionSessionState { + if (!snapshot?.initialized) { + return new CodexAppServerConnectionSessionState(); + } + return new CodexAppServerConnectionSessionState({ + appServerClientName: snapshot.initialized.appServerClientName, + clientVersion: snapshot.initialized.clientVersion, + experimentalApiEnabled: snapshot.initialized.experimentalApiEnabled, + optedOutNotificationMethods: new Set( + snapshot.initialized.optedOutNotificationMethods, + ), + }); + } } export type CodexAppServerMessageProcessorOptions = { @@ -245,7 +288,8 @@ export class CodexAppServerMessageProcessor { this.outgoing = options.outgoing; this.requestSerializationQueues = options.requestSerializationQueues ?? new RequestSerializationQueues(); - this.session = options.session ?? new CodexAppServerConnectionSessionState(); + this.session = + options.session ?? new CodexAppServerConnectionSessionState(); } async processClientRequest( @@ -320,7 +364,7 @@ export class CodexAppServerMessageProcessor { error instanceof Error ? error.message : "Codex App Server request failed.", - }; + }; await this.outgoing.sendError(requestId, responseError); return { error: responseError, type: "error" }; } @@ -477,7 +521,9 @@ export class CodexAppServerMessageProcessor { }; } - private requestContext(requestId: RequestId): CodexAppServerRequestContext | undefined { + private requestContext( + requestId: RequestId, + ): CodexAppServerRequestContext | undefined { if (!this.outgoing) { return undefined; } @@ -525,8 +571,9 @@ function defaultConnectionId(): number { } function platformFamily(): string { - const navigatorPlatform = (globalThis as { navigator?: { platform?: string } }) - .navigator?.platform; + const navigatorPlatform = ( + globalThis as { navigator?: { platform?: string } } + ).navigator?.platform; if (navigatorPlatform?.toLowerCase().includes("win")) { return "windows"; } @@ -534,8 +581,9 @@ function platformFamily(): string { } function platformOs(): string { - const navigatorPlatform = (globalThis as { navigator?: { platform?: string } }) - .navigator?.platform?.toLowerCase(); + const navigatorPlatform = ( + globalThis as { navigator?: { platform?: string } } + ).navigator?.platform?.toLowerCase(); if (navigatorPlatform?.includes("mac")) { return "macos"; } diff --git a/packages/codex-js/src/internal/codex/app-server/src/runtime.ts b/packages/codex-js/src/internal/codex/app-server/src/runtime.ts index 3a1174a..3ebe5a4 100644 --- a/packages/codex-js/src/internal/codex/app-server/src/runtime.ts +++ b/packages/codex-js/src/internal/codex/app-server/src/runtime.ts @@ -39,11 +39,11 @@ import { CodexSessionTaskRunner } from "./session_task_runner"; import { ThreadStateManager } from "./thread_state"; import { RequestSerializationQueues } from "./request_serialization"; import { - apply_bespoke_event_handling, + mapCoreEventToAppServerEvents, serverRequestResolvedNotification, type AppServerProtocolEvent, type ServerRequestCoreTarget, -} from "./bespoke_event_handling"; +} from "./app_server_event_mapping"; import type { ThreadCompactStartParams, McpServerOauthLoginParams, @@ -72,16 +72,19 @@ export type CodexAppServerEventSink = ( }, ) => Promise | void; -export type CodexAppServerOutgoingSink = ( - message: OutgoingMessage, - context: { - connectionIds?: ConnectionId[]; - context?: Context; - threadId?: ThreadId; - }, -) => Promise | void; +export type CodexAppServerOutgoingSink = + ( + message: OutgoingMessage, + context: { + connectionIds?: ConnectionId[]; + context?: Context; + threadId?: ThreadId; + }, + ) => Promise | void; -export type CodexAppServerRuntimeOptions = { +export type CodexAppServerRuntimeOptions< + Context = CodexAppServerRuntimeContext, +> = { buildCreateThreadParams?: (input: { context?: Context; params: ThreadStartParams; @@ -89,7 +92,11 @@ export type CodexAppServerRuntimeOptions }) => CreateThreadParams | Promise; buildSessionConfiguration?: (input: { context?: Context; - params: ThreadStartParams | ThreadResumeParams | TurnStartParams | ThreadCompactStartParams; + params: + | ThreadStartParams + | ThreadResumeParams + | TurnStartParams + | ThreadCompactStartParams; thread: Awaited>; }) => Partial | Promise>; createModelClient: (input: { @@ -111,14 +118,27 @@ export type CodexAppServerRuntimeOptions createSession?: (input: { context?: Context; eventSink: (event: Event) => void; - params: ThreadStartParams | ThreadResumeParams | TurnStartParams | ThreadCompactStartParams; + params: + | ThreadStartParams + | ThreadResumeParams + | TurnStartParams + | ThreadCompactStartParams; submission?: Submission; threadId: ThreadId; }) => Session | Promise; eventSink?: CodexAppServerEventSink; - onRuntimeError?: (error: unknown, context: { context?: Context; threadId?: ThreadId }) => void; - runInBackground?: (promise: Promise, context: { context?: Context; threadId: ThreadId }) => void; - runConnectionBackground?: (promise: Promise, context: { context?: Context }) => void; + onRuntimeError?: ( + error: unknown, + context: { context?: Context; threadId?: ThreadId }, + ) => void; + runInBackground?: ( + promise: Promise, + context: { context?: Context; threadId: ThreadId }, + ) => void; + runConnectionBackground?: ( + promise: Promise, + context: { context?: Context }, + ) => void; sendOutgoingMessage?: CodexAppServerEventSink; sendOutgoingTransportMessage?: CodexAppServerOutgoingSink; resolveDynamicTools?: (input: { @@ -144,16 +164,26 @@ export type CodexAppServerRuntime = { }): CodexAppServerMessageProcessor; methodHandlers: CodexAppServerMethodHandlers; rejectServerRequest( - params: { error: JSONRPCErrorError; requestId: string | number; threadId: ThreadId | string }, + params: { + error: JSONRPCErrorError; + requestId: string | number; + threadId: ThreadId | string; + }, context?: Context, ): Promise; resolveServerRequest( - params: { requestId: string | number; result: Result; threadId: ThreadId | string }, + params: { + requestId: string | number; + result: Result; + threadId: ThreadId | string; + }, context?: Context, ): Promise; }; -export function createCodexAppServerRuntime( +export function createCodexAppServerRuntime< + Context = CodexAppServerRuntimeContext, +>( options: CodexAppServerRuntimeOptions, ): CodexAppServerRuntime { const sessions = new Map(); @@ -175,7 +205,8 @@ export function createCodexAppServerRuntime { if (event.type === "server_notification") { - await outgoing.sendServerNotification(event.notification, context, threadId); + await outgoing.sendServerNotification( + event.notification, + context, + threadId, + ); return; } if (event.type === "server_request") { @@ -211,13 +246,17 @@ export function createCodexAppServerRuntime => @@ -287,8 +330,10 @@ export function createCodexAppServerRuntime mcpProcessor.mcpServerToolCall(params, context, request), - threadStart: (params, context) => threadProcessor.threadStart(params, context), - threadResume: (params, context) => threadProcessor.threadResume(params, context), + threadStart: (params, context) => + threadProcessor.threadStart(params, context), + threadResume: (params, context) => + threadProcessor.threadResume(params, context), threadList: (params) => threadProcessor.threadList(params), threadRead: (params) => threadProcessor.threadRead(params), threadNameSet: (params, context) => @@ -328,14 +373,17 @@ export function createCodexAppServerRuntime { + async function resolveServerRequest(params: { + requestId: string | number; + result: Result; + threadId: ThreadId | string; + }): Promise { const threadId = asThreadId(String(params.threadId)); const targetKey = serverRequestTargetKey(threadId, params.requestId); - const request = outgoing.pendingRequestsForThread(threadId).find( - (candidate) => candidate.id === params.requestId, - ) ?? null; + const request = + outgoing + .pendingRequestsForThread(threadId) + .find((candidate) => candidate.id === params.requestId) ?? null; if (!request) { serverRequestTargets.delete(targetKey); } @@ -351,10 +399,13 @@ export function createCodexAppServerRuntime { @@ -369,14 +420,17 @@ export function createCodexAppServerRuntime { + async function rejectServerRequest(params: { + error: JSONRPCErrorError; + requestId: string | number; + threadId: ThreadId | string; + }): Promise { const threadId = asThreadId(String(params.threadId)); const targetKey = serverRequestTargetKey(threadId, params.requestId); - const request = outgoing.pendingRequestsForThread(threadId).find( - (candidate) => candidate.id === params.requestId, - ) ?? null; + const request = + outgoing + .pendingRequestsForThread(threadId) + .find((candidate) => candidate.id === params.requestId) ?? null; if (!request) { serverRequestTargets.delete(targetKey); } @@ -392,10 +446,13 @@ export function createCodexAppServerRuntime { if (!isServerRequestResponseSubmission(submission)) { - throw new Error("Only server-request response submissions can be routed through CodexAppServerRuntime."); + throw new Error( + "Only server-request response submissions can be routed through CodexAppServerRuntime.", + ); } const runtimeSession = sessions.get(threadId); if (!runtimeSession) { - throw new Error("Codex thread has no active turn for this server request response."); + throw new Error( + "Codex thread has no active turn for this server request response.", + ); } await runtimeSession.session.submit_with_id(submission); } @@ -422,7 +483,10 @@ export function createCodexAppServerRuntime Promise; +type FetchLike = ( + input: RequestInfo | URL, + init?: RequestInit, +) => Promise; type WorkerWebSocket = WebSocket & { accept?: (options?: unknown) => void; - binaryType?: BinaryType; + binaryType?: "arraybuffer" | "blob"; }; type WebSocketUpgradeResponse = Response & { webSocket?: WorkerWebSocket | null; @@ -64,9 +64,7 @@ export class WsStream { } is_closed(): boolean { - const closedState = - typeof WebSocket !== "undefined" ? WebSocket.CLOSED : this.socket.CLOSED; - return this.closed || this.socket.readyState === (closedState ?? 3); + return this.closed || this.socket.readyState === 3; } send(message: string): void { @@ -85,7 +83,9 @@ export class WsStream { } } - async next(timeoutMs?: number | null): Promise { + async next( + timeoutMs?: number | null, + ): Promise { const queued = this.queued.shift(); if (queued) { return queued; @@ -97,13 +97,16 @@ export class WsStream { let timeout: ReturnType | null = null; try { return await Promise.race([ - new Promise((resolve, reject) => { - this.waiters.push({ resolve, reject }); - }), + new Promise( + (resolve, reject) => { + this.waiters.push({ resolve, reject }); + }, + ), new Promise((_, reject) => { if (timeoutMs && timeoutMs > 0) { timeout = setTimeout( - () => reject(ApiError.stream("idle timeout waiting for websocket")), + () => + reject(ApiError.stream("idle timeout waiting for websocket")), timeoutMs, ); } @@ -161,7 +164,7 @@ export class ResponsesWebsocketConnection { const connection = this; const stream = new WebsocketResponseStream(async function* () { yield* connection.initialEvents(); - yield* await connection.withExclusiveStream(async function* () { + yield* await connection.withExclusiveStream(async function* () { sendWebsocketRequest( connection.input.stream, request, @@ -321,7 +324,9 @@ class WebsocketResponseStream implements ResponseStream { } } -async function apiErrorFromWebsocketHandshake(response: Response): Promise { +async function apiErrorFromWebsocketHandshake( + response: Response, +): Promise { const body = await response.text().catch(() => ""); return ApiError.api( response.status, @@ -364,19 +369,18 @@ function mapWrappedWebsocketErrorEvent(payload: string): ApiError | null { if (typeof event.status === "number" && event.status >= 400) { return ApiError.api( event.status, - event.error?.message || `OpenAI Responses websocket error ${event.status}.`, + event.error?.message || + `OpenAI Responses websocket error ${event.status}.`, ); } return null; } -function parseWrappedWebsocketErrorEvent(payload: string): - | { - type?: unknown; - status?: number; - error?: { code?: string | null; message?: string | null }; - } - | null { +function parseWrappedWebsocketErrorEvent(payload: string): { + type?: unknown; + status?: number; + error?: { code?: string | null; message?: string | null }; +} | null { try { const parsed = JSON.parse(payload); if (!isRecord(parsed) || parsed.type !== "error") { @@ -412,7 +416,11 @@ function closeLikeEvent(): CloseEvent { reason: "websocket closed", }); } - return { type: "close", code: 1006, reason: "websocket closed" } as CloseEvent; + return { + type: "close", + code: 1006, + reason: "websocket closed", + } as CloseEvent; } function isCloseEvent( @@ -429,8 +437,6 @@ function isErrorEvent( function isAsyncIterable(value: unknown): value is AsyncIterable { return ( - typeof value === "object" && - value !== null && - Symbol.asyncIterator in value + typeof value === "object" && value !== null && Symbol.asyncIterator in value ); } diff --git a/packages/codex-js/src/runtime/index.ts b/packages/codex-js/src/runtime/index.ts index 6f54a4e..b0aa88e 100644 --- a/packages/codex-js/src/runtime/index.ts +++ b/packages/codex-js/src/runtime/index.ts @@ -181,8 +181,10 @@ export { type CodexAppServerMethodHandlers, type CodexAppServerRequestContext, type CodexAppServerDeferredResponse, + type CodexAppServerConnectionSnapshot, type CodexAppServerConnectionRequestOutcome, type CodexAppServerMessageProcessorOptions, + type InitializedConnectionSessionSnapshot, type InitializedConnectionSessionState, } from "../internal/codex/app-server/src/message_processor"; export { @@ -208,7 +210,10 @@ export { type CodexAppServerRuntimeContext, type CodexAppServerRuntimeOptions, } from "../internal/codex/app-server/src/runtime"; -export { AppServerSession, type CodexAppServer } from "../internal/codex/app-server-client/src/session"; +export { + AppServerSession, + type CodexAppServer, +} from "../internal/codex/app-server-client/src/session"; export { serverNotificationThreadTarget, serverRequestThreadId, @@ -275,7 +280,10 @@ export type { TurnItem as CoreTurnItem, UserMessageTurnItem as CoreUserMessageTurnItem, } from "../internal/codex/core/src/items"; -export type { Model, ModelPreset } from "../internal/codex/core/src/model-provider"; +export type { + Model, + ModelPreset, +} from "../internal/codex/core/src/model-provider"; export { createModelClient, defaultModelsManager, diff --git a/packages/codex-js/src/server/app-server.ts b/packages/codex-js/src/server/app-server.ts new file mode 100644 index 0000000..7a68737 --- /dev/null +++ b/packages/codex-js/src/server/app-server.ts @@ -0,0 +1,527 @@ +import { + BaseInstructions, + CodexAppServerConnectionSessionState, + CodexAppServerRequestError, + ThreadEventPersistenceMode, + ThreadMemoryMode, + createCodexAppServerRuntime, + parseServerTransportPayload, + serializeJsonRpcError, + serializeOutgoingMessage, + serverRequestThreadId, + type ClientRequest, + type CodexAppServerRuntime, + type CodexAppServerRuntimeContext, + type CodexAppServerRuntimeOptions, + type CodexAppServerConnectionSnapshot, + type ConnectionId, + type DynamicToolCallParams, + type JSONRPCErrorError, + type OutgoingMessage, + type RequestId, + type ServerRequest, + type ThreadId, + type ThreadStore, +} from "../runtime"; +import { + dynamicToolResponse, + dynamicToolSpecFromDefinition, + findDynamicTool, + type DefinedDynamicTool, +} from "./dynamic-tools"; + +let nextConnectionId = 1; + +export type PendingServerRequestRecord = { + createdAt: number; + request: ServerRequest; + requestId: RequestId; + threadId: string; +}; + +export type PendingServerRequestStore = { + delete(requestId: RequestId): Promise | void; + get( + requestId: RequestId, + ): + | Promise + | PendingServerRequestRecord + | null; + list(): Promise | PendingServerRequestRecord[]; + put(record: PendingServerRequestRecord): Promise | void; + take( + requestId: RequestId, + ): + | Promise + | PendingServerRequestRecord + | null; +}; + +export type CodexAppServerDefaults = { + baseInstructions?: string; + cwd?: string; + model?: string; + modelProvider?: string; + source?: string; + threadSource?: string | null; +}; + +export type CreateCodexAppServerOptions< + Context = CodexAppServerRuntimeContext, +> = Omit< + CodexAppServerRuntimeOptions, + "sendOutgoingTransportMessage" | "store" +> & { + defaults?: CodexAppServerDefaults; + dynamicTools?: readonly DefinedDynamicTool[]; + pendingServerRequests?: PendingServerRequestStore; + /** @deprecated Use threadStore. */ + store?: ThreadStore; + threadStore?: ThreadStore; +}; + +export type CodexAppServerConnection = { + accept(message: unknown): Promise; + close(): Promise; + connectionId: ConnectionId; + processor: ReturnType< + CodexAppServerRuntime["createMessageProcessor"] + >; + snapshot(): CodexAppServerConnectionSnapshot; +}; + +export type CreateCodexAppServerConnectionOptions< + Context = CodexAppServerRuntimeContext, +> = { + connectionId?: ConnectionId; + context?: Context; + onSnapshot?: ( + snapshot: CodexAppServerConnectionSnapshot, + ) => void | Promise; + send(message: string): void | Promise; + snapshot?: CodexAppServerConnectionSnapshot | null; +}; + +export type CreatedCodexAppServer = + CodexAppServerRuntime & { + createConnection( + options: CreateCodexAppServerConnectionOptions, + ): CodexAppServerConnection; + pendingServerRequests: PendingServerRequestStore; + }; + +export class InMemoryPendingServerRequestStore implements PendingServerRequestStore { + private readonly records = new Map(); + + delete(requestId: RequestId): void { + this.records.delete(requestId); + } + + get(requestId: RequestId): PendingServerRequestRecord | null { + return this.records.get(requestId) ?? null; + } + + list(): PendingServerRequestRecord[] { + return Array.from(this.records.values()); + } + + put(record: PendingServerRequestRecord): void { + this.records.set(record.requestId, record); + } + + take(requestId: RequestId): PendingServerRequestRecord | null { + const record = this.get(requestId); + this.delete(requestId); + return record; + } +} + +export function createCodexAppServer( + options: CreateCodexAppServerOptions, +): CreatedCodexAppServer { + const threadStore = options.threadStore ?? options.store; + if (!threadStore) { + throw new Error("createCodexAppServer requires threadStore."); + } + const dynamicTools = [...(options.dynamicTools ?? [])]; + const pendingServerRequests = + options.pendingServerRequests ?? new InMemoryPendingServerRequestStore(); + const connections = new Map< + ConnectionId, + { context?: Context; send(message: string): void | Promise } + >(); + const subscriptions = new Map>(); + const runtime = createCodexAppServerRuntime({ + ...options, + store: threadStore, + buildCreateThreadParams: async (input) => { + const base = options.buildCreateThreadParams + ? await options.buildCreateThreadParams(input) + : { + base_instructions: { + text: + input.params.baseInstructions ?? + options.defaults?.baseInstructions ?? + BaseInstructions.default().text, + }, + dynamic_tools: [], + event_persistence_mode: ThreadEventPersistenceMode.Limited, + metadata: { + cwd: input.params.cwd ?? options.defaults?.cwd ?? "/", + memory_mode: ThreadMemoryMode.Disabled, + model: + input.params.model ?? options.defaults?.model ?? "gpt-5-mini", + model_provider: + input.params.modelProvider ?? + options.defaults?.modelProvider ?? + "openai", + }, + source: options.defaults?.source ?? "appServer", + thread_id: input.threadId, + thread_source: + typeof input.params.threadSource === "string" + ? input.params.threadSource + : (options.defaults?.threadSource ?? null), + }; + const resolvedTools = + (await options.resolveDynamicTools?.(input))?.map((tool) => tool) ?? []; + return { + ...base, + dynamic_tools: [ + ...(base.dynamic_tools ?? []), + ...resolvedTools, + ...dynamicTools.map(dynamicToolSpecFromDefinition), + ], + }; + }, + buildSessionConfiguration: async (input) => { + const config = (await options.buildSessionConfiguration?.(input)) ?? {}; + return { + ...config, + dynamic_tools: [ + ...(config.dynamic_tools ?? []), + ...dynamicTools.map(dynamicToolSpecFromDefinition), + ], + }; + }, + sendOutgoingTransportMessage: async (message, messageContext) => { + const handled = await maybeExecuteDynamicTool({ + context: messageContext.context as Context | undefined, + dynamicTools, + message, + runtime, + threadId: messageContext.threadId, + }); + if (handled) { + return; + } + if (isServerRequest(message)) { + const threadId = + messageContext.threadId ?? serverRequestThreadId(message); + if (threadId) { + await pendingServerRequests.put({ + createdAt: Date.now(), + request: message, + requestId: message.id, + threadId: String(threadId), + }); + } + } + await sendToConnections({ + connectionIds: messageContext.connectionIds, + connections, + message, + subscriptions, + threadId: messageContext.threadId, + }); + }, + }); + + function createConnection( + connectionOptions: CreateCodexAppServerConnectionOptions, + ): CodexAppServerConnection { + const connectionId = connectionOptions.connectionId ?? nextConnectionId++; + const session = CodexAppServerConnectionSessionState.fromSnapshot( + connectionOptions.snapshot, + ); + const processor = runtime.createMessageProcessor({ + connectionId, + session, + }); + connections.set(connectionId, { + context: connectionOptions.context, + send: connectionOptions.send, + }); + if (session.initialized()) { + runtime.connectionInitialized(connectionId); + } + + async function persistSnapshot(): Promise { + await connectionOptions.onSnapshot?.(processor.session.snapshot()); + } + + return { + async accept(message) { + const parsed = parseServerTransportPayload(message); + if (parsed.type === "invalid") { + await connectionOptions.send( + serializeJsonRpcError(parsed.id, parsed.error), + ); + return; + } + switch (parsed.message.type) { + case "client_request": { + subscribeFromClientRequest( + subscriptions, + connectionId, + parsed.message.request, + ); + const outcome = await processor.processConnectionRequest( + parsed.message.request, + connectionOptions.context, + ); + if (parsed.message.request.method === "initialize") { + runtime.connectionInitialized(connectionId); + } + if (outcome.type === "response") { + subscribeFromResult(subscriptions, connectionId, outcome.result); + } + await persistSnapshot(); + return; + } + case "response": { + const pending = await pendingServerRequests.take( + parsed.message.response.id, + ); + if (pending) { + await runtime.resolveServerRequest( + { + requestId: parsed.message.response.id, + result: parsed.message.response.result, + threadId: pending.threadId, + }, + connectionOptions.context, + ); + } + await persistSnapshot(); + return; + } + case "error": { + if (parsed.message.error.id !== null) { + const pending = await pendingServerRequests.take( + parsed.message.error.id, + ); + if (pending) { + await runtime.rejectServerRequest( + { + error: parsed.message.error.error, + requestId: parsed.message.error.id, + threadId: pending.threadId, + }, + connectionOptions.context, + ); + } + } + await persistSnapshot(); + return; + } + case "client_notification": + await persistSnapshot(); + return; + } + }, + async close() { + connections.delete(connectionId); + for (const connectionIds of subscriptions.values()) { + connectionIds.delete(connectionId); + } + await processor.connectionClosed(); + await runtime.connectionClosed(connectionId); + }, + connectionId, + processor, + snapshot() { + return processor.session.snapshot(); + }, + }; + } + + return Object.assign(runtime, { + createConnection, + pendingServerRequests, + }); +} + +export function createCodexAppServerConnection< + Context = CodexAppServerRuntimeContext, +>( + appServer: CreatedCodexAppServer, + options: CreateCodexAppServerConnectionOptions, +): CodexAppServerConnection { + return appServer.createConnection(options); +} + +async function maybeExecuteDynamicTool(input: { + context?: Context; + dynamicTools: readonly DefinedDynamicTool[]; + message: OutgoingMessage; + runtime: CodexAppServerRuntime; + threadId?: ThreadId; +}): Promise { + if (!isDynamicToolCallRequest(input.message) || !input.threadId) { + return false; + } + const params = input.message.params; + const tool = findDynamicTool(input.dynamicTools, params); + if (!tool?.execute) { + return false; + } + try { + const result = await tool.execute(params.arguments, { + callId: params.callId, + context: input.context, + namespace: params.namespace ?? null, + params, + threadId: params.threadId, + tool: params.tool, + turnId: params.turnId, + }); + await input.runtime.resolveServerRequest( + { + requestId: input.message.id, + result, + threadId: input.threadId, + }, + input.context, + ); + } catch (error) { + await input.runtime.resolveServerRequest( + { + requestId: input.message.id, + result: dynamicToolResponse.error( + error instanceof Error ? error.message : "Dynamic tool failed.", + ), + threadId: input.threadId, + }, + input.context, + ); + } + return true; +} + +async function sendToConnections(input: { + connectionIds?: ConnectionId[]; + connections: Map< + ConnectionId, + { context?: unknown; send(message: string): void | Promise } + >; + message: OutgoingMessage; + subscriptions: Map>; + threadId?: ThreadId; +}): Promise { + const payload = serializeOutgoingMessage(input.message); + const recipients = recipientConnectionIds(input); + await Promise.all( + recipients.map(async (connectionId) => { + const connection = input.connections.get(connectionId); + if (connection) { + await connection.send(payload); + } + }), + ); +} + +function recipientConnectionIds(input: { + connectionIds?: ConnectionId[]; + connections: Map; + subscriptions: Map>; + threadId?: ThreadId; +}): ConnectionId[] { + if (input.connectionIds?.length) { + return input.connectionIds; + } + if (input.threadId) { + return Array.from(input.subscriptions.get(String(input.threadId)) ?? []); + } + return Array.from(input.connections.keys()); +} + +function subscribeFromClientRequest( + subscriptions: Map>, + connectionId: ConnectionId, + request: ClientRequest, +): void { + const params = request.params as + | { threadId?: unknown; thread_id?: unknown } + | undefined; + const threadId = + typeof params?.threadId === "string" + ? params.threadId + : typeof params?.thread_id === "string" + ? params.thread_id + : null; + if (threadId) { + subscribe(subscriptions, connectionId, threadId); + } +} + +function subscribeFromResult( + subscriptions: Map>, + connectionId: ConnectionId, + result: unknown, +): void { + const threadId = (result as { thread?: { id?: unknown } } | undefined)?.thread + ?.id; + if (typeof threadId === "string") { + subscribe(subscriptions, connectionId, threadId); + } +} + +function subscribe( + subscriptions: Map>, + connectionId: ConnectionId, + threadId: string, +): void { + const connectionIds = subscriptions.get(threadId) ?? new Set(); + connectionIds.add(connectionId); + subscriptions.set(threadId, connectionIds); +} + +function isServerRequest(message: OutgoingMessage): message is ServerRequest { + return "method" in message && "id" in message; +} + +function isDynamicToolCallRequest( + message: OutgoingMessage, +): message is ServerRequest & { params: DynamicToolCallParams } { + return isServerRequest(message) && message.method === "item/tool/call"; +} + +export function jsonRpcErrorFromUnknown(error: unknown): JSONRPCErrorError { + if ( + typeof error === "object" && + error !== null && + "code" in error && + "message" in error && + typeof (error as { code?: unknown }).code === "number" && + typeof (error as { message?: unknown }).message === "string" + ) { + return error as JSONRPCErrorError; + } + const nested = (error as { error?: unknown } | undefined)?.error; + if ( + typeof nested === "object" && + nested !== null && + "code" in nested && + "message" in nested && + typeof (nested as { code?: unknown }).code === "number" && + typeof (nested as { message?: unknown }).message === "string" + ) { + return nested as JSONRPCErrorError; + } + return { + code: + error instanceof CodexAppServerRequestError ? error.error.code : -32000, + message: error instanceof Error ? error.message : "Codex request failed.", + }; +} diff --git a/packages/codex-js/src/server/dynamic-tools.ts b/packages/codex-js/src/server/dynamic-tools.ts new file mode 100644 index 0000000..6fa0dfb --- /dev/null +++ b/packages/codex-js/src/server/dynamic-tools.ts @@ -0,0 +1,198 @@ +import type { + DynamicToolCallParams, + DynamicToolCallResponse, + DynamicToolSpec, +} from "../runtime"; + +export type DynamicToolExecutionContext = { + callId: string; + context?: Context; + namespace: string | null; + params: DynamicToolCallParams; + threadId: string; + tool: string; + turnId: string; +}; + +export type DynamicToolExecute = ( + args: Args, + context: DynamicToolExecutionContext, +) => DynamicToolCallResponse | Promise; + +export type DynamicToolDefinition = { + deferLoading?: boolean; + description: string; + execute?: DynamicToolExecute; + inputSchema: unknown; + name: string; + namespace?: string | null; +}; + +export type DefinedDynamicTool = Readonly< + DynamicToolDefinition +>; + +export type DefinedDynamicToolset = + readonly DefinedDynamicTool[]; + +type DynamicToolDefinitionForValidation = { + deferLoading?: boolean; + description: string; + inputSchema: unknown; + name: string; + namespace?: string | null; +}; + +const RESPONSES_API_TOOL_NAME = /^[A-Za-z0-9_-]+$/u; +const RESPONSES_API_TOOL_NAME_MAX_LENGTH = 64; + +export const dynamicToolResponse = { + text(text: string): DynamicToolCallResponse { + return { + contentItems: [{ text, type: "inputText" }], + success: true, + }; + }, + image(imageUrl: string): DynamicToolCallResponse { + return { + contentItems: [{ imageUrl, type: "inputImage" }], + success: true, + }; + }, + error(message: string): DynamicToolCallResponse { + return { + contentItems: [{ text: message, type: "inputText" }], + success: false, + }; + }, +}; + +export function defineDynamicTool( + definition: DynamicToolDefinition, +): DefinedDynamicTool { + const tool = Object.freeze({ + ...definition, + deferLoading: definition.deferLoading ?? false, + namespace: definition.namespace ?? null, + }); + validateDynamicToolDefinitions([tool]); + return tool; +} + +export function defineDynamicToolset( + definitions: readonly DynamicToolDefinition[], +): DefinedDynamicToolset { + const tools = definitions.map((definition) => + Object.freeze({ + ...definition, + deferLoading: definition.deferLoading ?? false, + namespace: definition.namespace ?? null, + }), + ); + validateDynamicToolDefinitions(tools); + return Object.freeze(tools); +} + +export function dynamicToolSpecFromDefinition( + tool: DynamicToolDefinitionForValidation, +): DynamicToolSpec { + return { + defer_loading: tool.deferLoading ?? false, + description: tool.description, + input_schema: tool.inputSchema, + name: tool.name, + namespace: tool.namespace ?? null, + }; +} + +export function dynamicToolSpecsFromDefinitions( + tools: readonly DefinedDynamicTool[], +): DynamicToolSpec[] { + return tools.map(dynamicToolSpecFromDefinition); +} + +export function findDynamicTool( + tools: readonly DefinedDynamicTool[], + params: DynamicToolCallParams, +): DefinedDynamicTool | null { + const namespace = params.namespace ?? null; + return ( + tools.find( + (tool) => + (tool.namespace ?? null) === namespace && tool.name === params.tool, + ) ?? null + ); +} + +export function validateDynamicToolDefinitions( + tools: readonly DynamicToolDefinitionForValidation[], +): void { + const names = new Set(); + for (const tool of tools) { + validateResponsesApiName(tool.name, "name"); + if (tool.namespace) { + validateResponsesApiName(tool.namespace, "namespace"); + } + if ((tool.deferLoading ?? false) && !tool.namespace) { + throw new Error( + `Dynamic tool ${tool.name} uses deferLoading and must include a namespace.`, + ); + } + validateInputSchema(tool.name, tool.inputSchema); + const key = `${tool.namespace ?? ""}:${tool.name}`; + if (names.has(key)) { + throw new Error( + `Duplicate dynamic tool registration for ${tool.namespace ? `${tool.namespace}/` : ""}${tool.name}.`, + ); + } + names.add(key); + } +} + +function validateResponsesApiName( + value: string, + label: "name" | "namespace", +): void { + if ( + value.length === 0 || + value.length > RESPONSES_API_TOOL_NAME_MAX_LENGTH || + !RESPONSES_API_TOOL_NAME.test(value) + ) { + throw new Error( + `Dynamic tool ${label} ${value} is not supported by the Responses API. Tool names and namespaces may only contain letters, numbers, underscores, and hyphens.`, + ); + } +} + +function validateInputSchema(toolName: string, schema: unknown): void { + if (!isRecord(schema)) { + throw new Error( + `Dynamic tool ${toolName} inputSchema must be a JSON Schema object.`, + ); + } + if (schema.type !== "object") { + throw new Error( + `Dynamic tool ${toolName} inputSchema must use type "object".`, + ); + } + if ("properties" in schema && !isRecord(schema.properties)) { + throw new Error( + `Dynamic tool ${toolName} inputSchema.properties must be an object when present.`, + ); + } + if ("required" in schema && !isStringArray(schema.required)) { + throw new Error( + `Dynamic tool ${toolName} inputSchema.required must be a string array when present.`, + ); + } +} + +function isRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} + +function isStringArray(value: unknown): value is string[] { + return ( + Array.isArray(value) && value.every((item) => typeof item === "string") + ); +} diff --git a/packages/codex-js/src/server/index.ts b/packages/codex-js/src/server/index.ts index 492ee4a..17fef1a 100644 --- a/packages/codex-js/src/server/index.ts +++ b/packages/codex-js/src/server/index.ts @@ -58,11 +58,32 @@ export { ThreadSortKey, TurnRequestProcessor, } from "../runtime"; +export { + createCodexAppServer, + createCodexAppServerConnection, + InMemoryPendingServerRequestStore, + jsonRpcErrorFromUnknown, +} from "./app-server"; +export { + dynamicToolResponse, + defineDynamicTool, + defineDynamicToolset, + dynamicToolSpecFromDefinition, + dynamicToolSpecsFromDefinitions, + findDynamicTool, + validateDynamicToolDefinitions, +} from "./dynamic-tools"; +export { + dynamicToolResponse as codexDynamicToolResponse, + defineDynamicTool as defineCodexDynamicTool, + defineDynamicToolset as defineCodexDynamicToolset, +} from "./dynamic-tools"; export type { AppendThreadItemsParams, AppServerEvent, AppServerRequestHandle, + ArchiveThreadParams, ClientRequest, ClientRequestSerializationScope, CodexAppServer, @@ -76,6 +97,7 @@ export type { CodexAppServerRuntime, CodexAppServerRuntimeContext, CodexAppServerRuntimeOptions, + CodexAppServerConnectionSnapshot, CodexAppServerRuntimeOptions as CreateCodexAppServerRuntimeOptions, CodexAppServerRuntime as CreatedCodexAppServerRuntime, CollaborationMode, @@ -102,7 +124,9 @@ export type { JSONRPCResponse, ListMcpServerStatusParams, ListMcpServerStatusResponse, + ListThreadsParams, LocalThreadStoreConfig, + LoadThreadHistoryParams, McpConnectionManager, McpResourceInfo, McpResourceReadParams, @@ -135,6 +159,9 @@ export type { RequestContext, RequestId, RequestSerializationQueueKey, + ReadThreadByRolloutPathParams, + ReadThreadParams, + ResumeThreadParams, ResponseCreateWsRequest, ResponseEvent, ResponseProcessedWsRequest, @@ -143,6 +170,7 @@ export type { ResponsesClientInput, ResponsesWsRequest, Result, + RolloutItem, RuntimeSession, SandboxPolicy, ServerNotification, @@ -166,6 +194,7 @@ export type { ThreadMetadataUpdateResponse, ThreadPage, ThreadPersistenceMetadata, + UpdateThreadMetadataParams, ThreadReadParams, ThreadReadResponse, ThreadResumeParams, @@ -190,3 +219,19 @@ export type { TypedRequestError, UserInput, } from "../runtime"; +export type { + CodexAppServerConnection, + CodexAppServerDefaults, + CreateCodexAppServerConnectionOptions, + CreateCodexAppServerOptions, + CreatedCodexAppServer, + PendingServerRequestRecord, + PendingServerRequestStore, +} from "./app-server"; +export type { + DefinedDynamicTool, + DefinedDynamicToolset, + DynamicToolDefinition, + DynamicToolExecute, + DynamicToolExecutionContext, +} from "./dynamic-tools"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1f9fcb8..6c82e90 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@changesets/cli': specifier: ^2.29.7 version: 2.31.0(@types/node@24.12.3) + '@eslint/js': + specifier: ^10.0.1 + version: 10.0.1(eslint@10.3.0(jiti@2.7.0)) '@fontsource-variable/geist': specifier: ^5.2.8 version: 5.2.8 @@ -35,6 +38,15 @@ importers: '@types/ws': specifier: ^8.18.1 version: 8.18.1 + eslint: + specifier: ^10.3.0 + version: 10.3.0(jiti@2.7.0) + eslint-plugin-react-hooks: + specifier: ^7.1.1 + version: 7.1.1(eslint@10.3.0(jiti@2.7.0)) + globals: + specifier: ^17.6.0 + version: 17.6.0 prettier: specifier: ^3.7.4 version: 3.8.3 @@ -50,6 +62,9 @@ importers: typescript: specifier: 5.8.3 version: 5.8.3 + typescript-eslint: + specifier: ^8.59.3 + version: 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) vite: specifier: ^6.4.2 version: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) @@ -60,41 +75,11 @@ importers: specifier: ^8.18.3 version: 8.20.0 - examples/minimal-app-server: - dependencies: - '@fontsource-variable/geist': - specifier: ^5.2.8 - version: 5.2.8 - '@jrkropp/codex-js': - specifier: workspace:* - version: link:../../packages/codex-js - '@jrkropp/codex-js-react': - specifier: workspace:* - version: link:../../packages/codex-js-react - '@tailwindcss/vite': - specifier: ^4.1.17 - version: 4.3.0(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)) - react: - specifier: 19.2.1 - version: 19.2.1 - react-dom: - specifier: 19.2.1 - version: 19.2.1(react@19.2.1) - tailwindcss: - specifier: ^4.1.17 - version: 4.3.0 - tw-animate-css: - specifier: ^1.4.0 - version: 1.4.0 - typescript: - specifier: 5.8.3 - version: 5.8.3 - vite: - specifier: ^6.4.2 - version: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) - - examples/react-router-cloudflare: + examples/cloudflare: dependencies: + '@cloudflare/vite-plugin': + specifier: ^1.14.6 + version: 1.36.4(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0))(workerd@1.20260508.1)(wrangler@4.90.1) '@fontsource-variable/geist': specifier: ^5.2.8 version: 5.2.8 @@ -107,6 +92,9 @@ importers: '@tailwindcss/vite': specifier: ^4.1.17 version: 4.3.0(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)) + '@vitejs/plugin-react': + specifier: ^5.1.1 + version: 5.2.0(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)) react: specifier: 19.2.1 version: 19.2.1 @@ -122,8 +110,24 @@ importers: vite: specifier: ^6.4.2 version: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + wrangler: + specifier: ^4.51.0 + version: 4.90.1 + devDependencies: + '@cloudflare/vitest-pool-workers': + specifier: ^0.10.2 + version: 0.10.15(@vitest/runner@3.2.4)(@vitest/snapshot@3.2.4)(vitest@3.2.4(@types/debug@4.1.13)(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3))) + '@vitest/runner': + specifier: 3.2.4 + version: 3.2.4 + '@vitest/snapshot': + specifier: 3.2.4 + version: 3.2.4 + vitest: + specifier: 3.2.4 + version: 3.2.4(@types/debug@4.1.13)(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3)) - examples/vite-react: + examples/node-local: dependencies: '@fontsource-variable/geist': specifier: ^5.2.8 @@ -149,6 +153,9 @@ importers: tw-animate-css: specifier: ^1.4.0 version: 1.4.0 + typescript: + specifier: 5.8.3 + version: 5.8.3 vite: specifier: ^6.4.2 version: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) @@ -166,7 +173,7 @@ importers: packages/codex-js-react: dependencies: '@jrkropp/codex-js': - specifier: ^0.2.0 + specifier: ^0.3.0 version: link:../codex-js '@legendapp/list': specifier: ^3.0.0-beta.44 @@ -229,10 +236,93 @@ importers: packages: + '@babel/code-frame@7.29.0': + resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==} + engines: {node: '>=6.9.0'} + + '@babel/compat-data@7.29.3': + resolution: {integrity: sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg==} + engines: {node: '>=6.9.0'} + + '@babel/core@7.29.0': + resolution: {integrity: sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==} + engines: {node: '>=6.9.0'} + + '@babel/generator@7.29.1': + resolution: {integrity: sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==} + engines: {node: '>=6.9.0'} + + '@babel/helper-compilation-targets@7.28.6': + resolution: {integrity: sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-globals@7.28.0': + resolution: {integrity: sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-imports@7.28.6': + resolution: {integrity: sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-transforms@7.28.6': + resolution: {integrity: sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + + '@babel/helper-plugin-utils@7.28.6': + resolution: {integrity: sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==} + engines: {node: '>=6.9.0'} + + '@babel/helper-string-parser@7.27.1': + resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.28.5': + resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-option@7.27.1': + resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==} + engines: {node: '>=6.9.0'} + + '@babel/helpers@7.29.2': + resolution: {integrity: sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw==} + engines: {node: '>=6.9.0'} + + '@babel/parser@7.29.3': + resolution: {integrity: sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA==} + engines: {node: '>=6.0.0'} + hasBin: true + + '@babel/plugin-transform-react-jsx-self@7.27.1': + resolution: {integrity: sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-react-jsx-source@7.27.1': + resolution: {integrity: sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/runtime@7.29.2': resolution: {integrity: sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==} engines: {node: '>=6.9.0'} + '@babel/template@7.28.6': + resolution: {integrity: sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==} + engines: {node: '>=6.9.0'} + + '@babel/traverse@7.29.0': + resolution: {integrity: sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==} + engines: {node: '>=6.9.0'} + + '@babel/types@7.29.0': + resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==} + engines: {node: '>=6.9.0'} + '@changesets/apply-release-plan@7.1.1': resolution: {integrity: sha512-9qPCm/rLx/xoOFXIHGB229+4GOL76S4MC+7tyOuTsR6+1jYlfFDQORdvwR5hDA6y4FL2BPt3qpbcQIS+dW85LA==} @@ -294,12 +384,130 @@ packages: '@changesets/write@0.4.0': resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==} + '@cloudflare/kv-asset-handler@0.4.1': + resolution: {integrity: sha512-Nu8ahitGFFJztxUml9oD/DLb7Z28C8cd8F46IVQ7y5Btz575pvMY8AqZsXkX7Gds29eCKdMgIHjIvzskHgPSFg==} + engines: {node: '>=18.0.0'} + + '@cloudflare/kv-asset-handler@0.5.0': + resolution: {integrity: sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==} + engines: {node: '>=22.0.0'} + + '@cloudflare/unenv-preset@2.16.1': + resolution: {integrity: sha512-ECxObrMfyTl5bhQf/lZCXwo5G6xX9IAUo+nDMKK4SZ8m4Jvvxp52vilxyySSWh2YTZz8+HQ07qGH/2rEom1vDw==} + peerDependencies: + unenv: 2.0.0-rc.24 + workerd: '>1.20260305.0 <2.0.0-0' + peerDependenciesMeta: + workerd: + optional: true + + '@cloudflare/unenv-preset@2.7.13': + resolution: {integrity: sha512-NulO1H8R/DzsJguLC0ndMuk4Ufv0KSlN+E54ay9rn9ZCQo0kpAPwwh3LhgpZ96a3Dr6L9LqW57M4CqC34iLOvw==} + peerDependencies: + unenv: 2.0.0-rc.24 + workerd: ^1.20251202.0 + peerDependenciesMeta: + workerd: + optional: true + + '@cloudflare/vite-plugin@1.36.4': + resolution: {integrity: sha512-/nMlXSOB58eg2CiU5efg33RYswMj54sxolfw49sYlZF8JiYdlBxkHE9+iOAerXTFyYZpKPYMGdApMyZgtgGhmg==} + peerDependencies: + vite: ^6.1.0 || ^7.0.0 || ^8.0.0 + wrangler: ^4.90.1 + + '@cloudflare/vitest-pool-workers@0.10.15': + resolution: {integrity: sha512-eISef+JvqC5xr6WBv2+kc6WEjxuKSrZ1MdMuIwdb4vsh8olqw7WHW5pLBL/UzAhbLVlXaAL1uH9UyxIlFkJe7w==} + peerDependencies: + '@vitest/runner': 2.0.x - 3.2.x + '@vitest/snapshot': 2.0.x - 3.2.x + vitest: 2.0.x - 3.2.x + + '@cloudflare/workerd-darwin-64@1.20251210.0': + resolution: {integrity: sha512-Nn9X1moUDERA9xtFdCQ2XpQXgAS9pOjiCxvOT8sVx9UJLAiBLkfSCGbpsYdarODGybXCpjRlc77Yppuolvt7oQ==} + engines: {node: '>=16'} + cpu: [x64] + os: [darwin] + + '@cloudflare/workerd-darwin-64@1.20260508.1': + resolution: {integrity: sha512-IT3r6VgiSwIesL4AJbxjgxvIxwWZqM7BKkhYAzOKHl4GF2M0TxeOahUIXd+CYXVZgHX8ceEg+MXbEehPelJyNg==} + engines: {node: '>=16'} + cpu: [x64] + os: [darwin] + + '@cloudflare/workerd-darwin-arm64@1.20251210.0': + resolution: {integrity: sha512-Mg8iYIZQFnbevq/ls9eW/eneWTk/EE13Pej1MwfkY5et0jVpdHnvOLywy/o+QtMJFef1AjsqXGULwAneYyBfHw==} + engines: {node: '>=16'} + cpu: [arm64] + os: [darwin] + + '@cloudflare/workerd-darwin-arm64@1.20260508.1': + resolution: {integrity: sha512-JTVsisOJPcNKw0qovPjqyBWYahfdhUh7/9NICiG5wxaEQ45PYKdoqNq0hOAAIqvqoxsKZBvTgcPTJREPqk7avA==} + engines: {node: '>=16'} + cpu: [arm64] + os: [darwin] + + '@cloudflare/workerd-linux-64@1.20251210.0': + resolution: {integrity: sha512-kjC2fCZhZ2Gkm1biwk2qByAYpGguK5Gf5ic8owzSCUw0FOUfQxTZUT9Lp3gApxsfTLbbnLBrX/xzWjywH9QR4g==} + engines: {node: '>=16'} + cpu: [x64] + os: [linux] + + '@cloudflare/workerd-linux-64@1.20260508.1': + resolution: {integrity: sha512-zO38pCc27YlsZiPYcaZnosy0/t7abXrRU3VEO1oKfUvnaCpHgphDG+VsrmHL+kntda6hrtNwg2jLeMAqqIjnjw==} + engines: {node: '>=16'} + cpu: [x64] + os: [linux] + + '@cloudflare/workerd-linux-arm64@1.20251210.0': + resolution: {integrity: sha512-2IB37nXi7PZVQLa1OCuO7/6pNxqisRSO8DmCQ5x/3sezI5op1vwOxAcb1osAnuVsVN9bbvpw70HJvhKruFJTuA==} + engines: {node: '>=16'} + cpu: [arm64] + os: [linux] + + '@cloudflare/workerd-linux-arm64@1.20260508.1': + resolution: {integrity: sha512-XhJa780Ia6MNIrtxn/ruZHS79b9pu5EKPfRNReaUqxy8erPT2fs93axMfFoS9kIkcaRRj/1TOUKcTeAMoywY7w==} + engines: {node: '>=16'} + cpu: [arm64] + os: [linux] + + '@cloudflare/workerd-windows-64@1.20251210.0': + resolution: {integrity: sha512-Uaz6/9XE+D6E7pCY4OvkCuJHu7HcSDzeGcCGY1HLhojXhHd7yL52c3yfiyJdS8hPatiAa0nn5qSI/42+aTdDSw==} + engines: {node: '>=16'} + cpu: [x64] + os: [win32] + + '@cloudflare/workerd-windows-64@1.20260508.1': + resolution: {integrity: sha512-QdDOK3B/Ul1s3QmIwDrFyx9230to6LsNmWcVR8w+TYjNZuRPzqQBgusp78LO7MlqCoEl9dvIcN00jkJnLtBSfw==} + engines: {node: '>=16'} + cpu: [x64] + os: [win32] + + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + + '@emnapi/runtime@1.10.0': + resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==} + '@esbuild/aix-ppc64@0.25.12': resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.27.0': + resolution: {integrity: sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/aix-ppc64@0.27.3': + resolution: {integrity: sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/aix-ppc64@0.27.7': resolution: {integrity: sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==} engines: {node: '>=18'} @@ -312,6 +520,18 @@ packages: cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.27.0': + resolution: {integrity: sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm64@0.27.3': + resolution: {integrity: sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm64@0.27.7': resolution: {integrity: sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==} engines: {node: '>=18'} @@ -324,6 +544,18 @@ packages: cpu: [arm] os: [android] + '@esbuild/android-arm@0.27.0': + resolution: {integrity: sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-arm@0.27.3': + resolution: {integrity: sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-arm@0.27.7': resolution: {integrity: sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==} engines: {node: '>=18'} @@ -336,6 +568,18 @@ packages: cpu: [x64] os: [android] + '@esbuild/android-x64@0.27.0': + resolution: {integrity: sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/android-x64@0.27.3': + resolution: {integrity: sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/android-x64@0.27.7': resolution: {integrity: sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==} engines: {node: '>=18'} @@ -348,6 +592,18 @@ packages: cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.27.0': + resolution: {integrity: sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-arm64@0.27.3': + resolution: {integrity: sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-arm64@0.27.7': resolution: {integrity: sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==} engines: {node: '>=18'} @@ -360,6 +616,18 @@ packages: cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.27.0': + resolution: {integrity: sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/darwin-x64@0.27.3': + resolution: {integrity: sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/darwin-x64@0.27.7': resolution: {integrity: sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==} engines: {node: '>=18'} @@ -372,6 +640,18 @@ packages: cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.27.0': + resolution: {integrity: sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-arm64@0.27.3': + resolution: {integrity: sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-arm64@0.27.7': resolution: {integrity: sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==} engines: {node: '>=18'} @@ -384,6 +664,18 @@ packages: cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.27.0': + resolution: {integrity: sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.27.3': + resolution: {integrity: sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/freebsd-x64@0.27.7': resolution: {integrity: sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==} engines: {node: '>=18'} @@ -396,6 +688,18 @@ packages: cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.27.0': + resolution: {integrity: sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm64@0.27.3': + resolution: {integrity: sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm64@0.27.7': resolution: {integrity: sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==} engines: {node: '>=18'} @@ -408,6 +712,18 @@ packages: cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.27.0': + resolution: {integrity: sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-arm@0.27.3': + resolution: {integrity: sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-arm@0.27.7': resolution: {integrity: sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==} engines: {node: '>=18'} @@ -420,6 +736,18 @@ packages: cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.27.0': + resolution: {integrity: sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-ia32@0.27.3': + resolution: {integrity: sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-ia32@0.27.7': resolution: {integrity: sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==} engines: {node: '>=18'} @@ -432,6 +760,18 @@ packages: cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.27.0': + resolution: {integrity: sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-loong64@0.27.3': + resolution: {integrity: sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-loong64@0.27.7': resolution: {integrity: sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==} engines: {node: '>=18'} @@ -444,6 +784,18 @@ packages: cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.27.0': + resolution: {integrity: sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-mips64el@0.27.3': + resolution: {integrity: sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-mips64el@0.27.7': resolution: {integrity: sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==} engines: {node: '>=18'} @@ -456,6 +808,18 @@ packages: cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.27.0': + resolution: {integrity: sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-ppc64@0.27.3': + resolution: {integrity: sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-ppc64@0.27.7': resolution: {integrity: sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==} engines: {node: '>=18'} @@ -468,6 +832,18 @@ packages: cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.27.0': + resolution: {integrity: sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-riscv64@0.27.3': + resolution: {integrity: sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-riscv64@0.27.7': resolution: {integrity: sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==} engines: {node: '>=18'} @@ -480,6 +856,18 @@ packages: cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.27.0': + resolution: {integrity: sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-s390x@0.27.3': + resolution: {integrity: sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-s390x@0.27.7': resolution: {integrity: sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==} engines: {node: '>=18'} @@ -492,6 +880,18 @@ packages: cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.27.0': + resolution: {integrity: sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/linux-x64@0.27.3': + resolution: {integrity: sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + '@esbuild/linux-x64@0.27.7': resolution: {integrity: sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==} engines: {node: '>=18'} @@ -504,6 +904,18 @@ packages: cpu: [arm64] os: [netbsd] + '@esbuild/netbsd-arm64@0.27.0': + resolution: {integrity: sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-arm64@0.27.3': + resolution: {integrity: sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + '@esbuild/netbsd-arm64@0.27.7': resolution: {integrity: sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==} engines: {node: '>=18'} @@ -516,6 +928,18 @@ packages: cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.27.0': + resolution: {integrity: sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.27.3': + resolution: {integrity: sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + '@esbuild/netbsd-x64@0.27.7': resolution: {integrity: sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==} engines: {node: '>=18'} @@ -528,6 +952,18 @@ packages: cpu: [arm64] os: [openbsd] + '@esbuild/openbsd-arm64@0.27.0': + resolution: {integrity: sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-arm64@0.27.3': + resolution: {integrity: sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-arm64@0.27.7': resolution: {integrity: sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==} engines: {node: '>=18'} @@ -540,6 +976,18 @@ packages: cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.27.0': + resolution: {integrity: sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.27.3': + resolution: {integrity: sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + '@esbuild/openbsd-x64@0.27.7': resolution: {integrity: sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==} engines: {node: '>=18'} @@ -552,6 +1000,18 @@ packages: cpu: [arm64] os: [openharmony] + '@esbuild/openharmony-arm64@0.27.0': + resolution: {integrity: sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/openharmony-arm64@0.27.3': + resolution: {integrity: sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + '@esbuild/openharmony-arm64@0.27.7': resolution: {integrity: sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==} engines: {node: '>=18'} @@ -564,6 +1024,18 @@ packages: cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.27.0': + resolution: {integrity: sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/sunos-x64@0.27.3': + resolution: {integrity: sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/sunos-x64@0.27.7': resolution: {integrity: sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==} engines: {node: '>=18'} @@ -576,6 +1048,18 @@ packages: cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.27.0': + resolution: {integrity: sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-arm64@0.27.3': + resolution: {integrity: sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-arm64@0.27.7': resolution: {integrity: sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==} engines: {node: '>=18'} @@ -588,6 +1072,18 @@ packages: cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.27.0': + resolution: {integrity: sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-ia32@0.27.3': + resolution: {integrity: sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-ia32@0.27.7': resolution: {integrity: sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==} engines: {node: '>=18'} @@ -600,12 +1096,63 @@ packages: cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.27.0': + resolution: {integrity: sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@esbuild/win32-x64@0.27.3': + resolution: {integrity: sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@esbuild/win32-x64@0.27.7': resolution: {integrity: sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==} engines: {node: '>=18'} cpu: [x64] os: [win32] + '@eslint-community/eslint-utils@4.9.1': + resolution: {integrity: sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + + '@eslint-community/regexpp@4.12.2': + resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + '@eslint/config-array@0.23.5': + resolution: {integrity: sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/config-helpers@0.5.5': + resolution: {integrity: sha512-eIJYKTCECbP/nsKaaruF6LW967mtbQbsw4JTtSVkUQc9MneSkbrgPJAbKl9nWr0ZeowV8BfsarBmPpBzGelA2w==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/core@1.2.1': + resolution: {integrity: sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/js@10.0.1': + resolution: {integrity: sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + peerDependencies: + eslint: ^10.0.0 + peerDependenciesMeta: + eslint: + optional: true + + '@eslint/object-schema@3.0.5': + resolution: {integrity: sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/plugin-kit@0.7.1': + resolution: {integrity: sha512-rZAP3aVgB9ds9KOeUSL+zZ21hPmo8dh6fnIFwRQj5EAZl9gzR7wxYbYXYysAM8CTqGmUGyp2S4kUdV17MnGuWQ==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + '@floating-ui/core@1.7.5': resolution: {integrity: sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ==} @@ -630,132 +1177,425 @@ packages: '@fontsource-variable/geist@5.2.8': resolution: {integrity: sha512-cJ6m9e+8MQ5dCYJsLylfZrgBh6KkG4bOLckB35Tr9J/EqdkEM6QllH5PxqP1dhTvFup+HtMRPuz9xOjxXJggxw==} - '@inquirer/ansi@2.0.5': - resolution: {integrity: sha512-doc2sWgJpbFQ64UflSVd17ibMGDuxO1yKgOgLMwavzESnXjFWJqUeG8saYosqKpHp4kWiM5x1nXvEjbpx90gzw==} - engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + '@humanfs/core@0.19.2': + resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==} + engines: {node: '>=18.18.0'} - '@inquirer/confirm@6.0.13': - resolution: {integrity: sha512-wkGPC7yJ5WJk1DJ5SX7fzk+gfj4BM8cf5dDDi71B/551xHrdsZVRJOC0WyikXd0pEsb/9cLniuE4atbsMqmFkw==} - engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true + '@humanfs/node@0.16.8': + resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==} + engines: {node: '>=18.18.0'} - '@inquirer/core@11.1.10': - resolution: {integrity: sha512-a4Q5BXHQAHa9eO202sTaFCHFYVB3x5fauDuThEAdZ9gfn76pSxiKU7wWcEH0N1O0XmQvNfQNU6QXpiRxmYQx+A==} - engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true + '@humanfs/types@0.15.0': + resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==} + engines: {node: '>=18.18.0'} - '@inquirer/external-editor@1.0.3': - resolution: {integrity: sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA==} - engines: {node: '>=18'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true + '@humanwhocodes/module-importer@1.0.1': + resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} + engines: {node: '>=12.22'} - '@inquirer/figures@2.0.5': - resolution: {integrity: sha512-NsSs4kzfm12lNetHwAn3GEuH317IzpwrMCbOuMIVytpjnJ90YYHNwdRgYGuKmVxwuIqSgqk3M5qqQt1cDk0tGQ==} - engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + '@humanwhocodes/retry@0.4.3': + resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} + engines: {node: '>=18.18'} - '@inquirer/type@4.0.5': - resolution: {integrity: sha512-aetVUNeKNc/VriqXlw1NRSW0zhMBB0W4bNbWRJgzRl/3d0QNDQFfk0GO5SDdtjMZVg6o8ZKEiadd7SCCzoOn5Q==} - engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true + '@img/colour@1.1.0': + resolution: {integrity: sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==} + engines: {node: '>=18'} - '@jridgewell/gen-mapping@0.3.13': - resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + '@img/sharp-darwin-arm64@0.33.5': + resolution: {integrity: sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [darwin] - '@jridgewell/remapping@2.3.5': - resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + '@img/sharp-darwin-arm64@0.34.5': + resolution: {integrity: sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [darwin] - '@jridgewell/resolve-uri@3.1.2': - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} + '@img/sharp-darwin-x64@0.33.5': + resolution: {integrity: sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [darwin] - '@jridgewell/sourcemap-codec@1.5.5': - resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + '@img/sharp-darwin-x64@0.34.5': + resolution: {integrity: sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [darwin] - '@jridgewell/trace-mapping@0.3.31': - resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + '@img/sharp-libvips-darwin-arm64@1.0.4': + resolution: {integrity: sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==} + cpu: [arm64] + os: [darwin] - '@legendapp/list@3.0.0-beta.54': - resolution: {integrity: sha512-70Cs0oE2cHd6mgHkKfFrCSb8n5Ew7+f1mdO2cm9ICBuSabK5ufqjUhEg9ixpRha6OrzuArOtRX+7iCf3HEaj3g==} - peerDependencies: - react: '*' - react-dom: '*' - react-native: '*' - peerDependenciesMeta: - react-dom: - optional: true - react-native: - optional: true + '@img/sharp-libvips-darwin-arm64@1.2.4': + resolution: {integrity: sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==} + cpu: [arm64] + os: [darwin] - '@lexical/clipboard@0.44.0': - resolution: {integrity: sha512-nfmNIs7uENqlDI7cm2E4I1Yp8mDJGMhEQIrIV2rNWnL1oeHVXQ7yuYdyoPdcY1zuj/9nvkYBQYUEh0QiGwpETA==} + '@img/sharp-libvips-darwin-x64@1.0.4': + resolution: {integrity: sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==} + cpu: [x64] + os: [darwin] - '@lexical/code-core@0.44.0': - resolution: {integrity: sha512-m57JyXTIvW1tsqw/Vuogk8jqWCZZIeFQbWybRc46ytR8ReDgzPRODpN8+dacIIeRH5yC5UC3lAa743mtdNkxqg==} + '@img/sharp-libvips-darwin-x64@1.2.4': + resolution: {integrity: sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==} + cpu: [x64] + os: [darwin] - '@lexical/devtools-core@0.44.0': - resolution: {integrity: sha512-X3uNG3P1vOsdzmEcy+7m9DxAcIVtVUZnvskmLqqLs6VluVVwH9xy7h1bPsvlDKvj1Nj73tWJ3TW0qXQWDTo5tw==} - peerDependencies: - react: '>=17.x' - react-dom: '>=17.x' + '@img/sharp-libvips-linux-arm64@1.0.4': + resolution: {integrity: sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==} + cpu: [arm64] + os: [linux] + libc: [glibc] - '@lexical/dragon@0.44.0': - resolution: {integrity: sha512-RhlsjVDket9k1+YFEkDE0/7Qyrh2BI0vxBMzrWwPJTXX/4YFanYN9su8RSabkIukBBJ3QiNOOoC8FKK4Lkr4qg==} + '@img/sharp-libvips-linux-arm64@1.2.4': + resolution: {integrity: sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==} + cpu: [arm64] + os: [linux] + libc: [glibc] - '@lexical/extension@0.44.0': - resolution: {integrity: sha512-BsYtoc+0EU0pqcOpf/lIUDU6LQVO6zX2AawZoUWJzT3Wzfov23qsqZWvl2WGM9dnRTN5iISJL3Fl53bQVxiXxw==} + '@img/sharp-libvips-linux-arm@1.0.5': + resolution: {integrity: sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==} + cpu: [arm] + os: [linux] + libc: [glibc] - '@lexical/hashtag@0.44.0': - resolution: {integrity: sha512-0WATahDSqYKVTudQv3KpFbLeCpmrCpRptPFbjxOMckAX2MRpYlrExlqKfgfpri5BSQPtG49EPSGeNfSx/Faavw==} + '@img/sharp-libvips-linux-arm@1.2.4': + resolution: {integrity: sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==} + cpu: [arm] + os: [linux] + libc: [glibc] - '@lexical/history@0.44.0': - resolution: {integrity: sha512-RGXcbFTgYL1GIWaReBI26mNSsJTfiA9EAtDY4LBeZ14NrIQhYNokKgNiOxq5Bn8xXrl2+mawQEqoMfgpWp/5YA==} + '@img/sharp-libvips-linux-ppc64@1.2.4': + resolution: {integrity: sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==} + cpu: [ppc64] + os: [linux] + libc: [glibc] - '@lexical/html@0.44.0': - resolution: {integrity: sha512-5X6eGsgwtqPxABsuShUxF7ZfyB/U4GwSEyeonvwH1Vc/5Q2uQVjlB+FAYd+MNwWMHMh4d4+yZ3l70AtIuhr5eg==} + '@img/sharp-libvips-linux-riscv64@1.2.4': + resolution: {integrity: sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==} + cpu: [riscv64] + os: [linux] + libc: [glibc] - '@lexical/link@0.44.0': - resolution: {integrity: sha512-uvEqEol/mLEzGVQd8Rok9I48RgYPKokM/nsclI9nYcEdccVOM2Nri4ntoRwodhbccFLtjMPl8OBldwXbfc77tQ==} + '@img/sharp-libvips-linux-s390x@1.0.4': + resolution: {integrity: sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==} + cpu: [s390x] + os: [linux] + libc: [glibc] - '@lexical/list@0.44.0': - resolution: {integrity: sha512-ZTCWxDz1okPrC9FBXi1yV3W5fbQQeMUlFIcSVF9HibcVPmCsPa900IxthuiQbGiTycUyXDTOB3IUYRtlJNtpjw==} + '@img/sharp-libvips-linux-s390x@1.2.4': + resolution: {integrity: sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==} + cpu: [s390x] + os: [linux] + libc: [glibc] - '@lexical/mark@0.44.0': - resolution: {integrity: sha512-bWMowllwe6BcgYMAkrsZx6Z+CX/72qCQpFKhlkR4ael92yOWSBkz68xp1wxxkSnQX9zoI1gYTeWBofVsSDKcsQ==} + '@img/sharp-libvips-linux-x64@1.0.4': + resolution: {integrity: sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==} + cpu: [x64] + os: [linux] + libc: [glibc] - '@lexical/markdown@0.44.0': - resolution: {integrity: sha512-DwlXdp85pYMo3exDF6W3iz8plpuP+RQ4Me4Iljm7O5aPDp0SSrIoZxyX4zS668mVAoz5HHj1Ka0kQkft8mq26Q==} + '@img/sharp-libvips-linux-x64@1.2.4': + resolution: {integrity: sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==} + cpu: [x64] + os: [linux] + libc: [glibc] - '@lexical/overflow@0.44.0': - resolution: {integrity: sha512-5GYaYjSxn27pqHRfU+tQ2STF10wgJvI+MUnwTnUFSzy3dko1b+oV94K/Yx0TuEewPbwDibfoFA8CwqUvOLHAyw==} + '@img/sharp-libvips-linuxmusl-arm64@1.0.4': + resolution: {integrity: sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==} + cpu: [arm64] + os: [linux] + libc: [musl] - '@lexical/plain-text@0.44.0': - resolution: {integrity: sha512-bIV4Lljk0x70zFhkZIwzSPK5q3m9FpDisjGm2/3Q/chb+5BW3Tv8QJmqnpCiSO6S2KXO7gfSy81ZfkQ1dcd4EQ==} + '@img/sharp-libvips-linuxmusl-arm64@1.2.4': + resolution: {integrity: sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==} + cpu: [arm64] + os: [linux] + libc: [musl] - '@lexical/react@0.44.0': - resolution: {integrity: sha512-p/NQd/fMh3pXb1XqegE2ruvWDcUmfB12OidQ9nwtMtj5VfcUjQu2I+trUhgGRIADxSYxMWmw+8PPj5YSf4m5oA==} - peerDependencies: - react: '>=17.x' - react-dom: '>=17.x' - yjs: '>=13.5.22' - peerDependenciesMeta: - yjs: - optional: true + '@img/sharp-libvips-linuxmusl-x64@1.0.4': + resolution: {integrity: sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-libvips-linuxmusl-x64@1.2.4': + resolution: {integrity: sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-linux-arm64@0.33.5': + resolution: {integrity: sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-arm64@0.34.5': + resolution: {integrity: sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-arm@0.33.5': + resolution: {integrity: sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-arm@0.34.5': + resolution: {integrity: sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-ppc64@0.34.5': + resolution: {integrity: sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-riscv64@0.34.5': + resolution: {integrity: sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-s390x@0.33.5': + resolution: {integrity: sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-s390x@0.34.5': + resolution: {integrity: sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-x64@0.33.5': + resolution: {integrity: sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-x64@0.34.5': + resolution: {integrity: sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@img/sharp-linuxmusl-arm64@0.33.5': + resolution: {integrity: sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@img/sharp-linuxmusl-arm64@0.34.5': + resolution: {integrity: sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@img/sharp-linuxmusl-x64@0.33.5': + resolution: {integrity: sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-linuxmusl-x64@0.34.5': + resolution: {integrity: sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-wasm32@0.33.5': + resolution: {integrity: sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [wasm32] + + '@img/sharp-wasm32@0.34.5': + resolution: {integrity: sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [wasm32] + + '@img/sharp-win32-arm64@0.34.5': + resolution: {integrity: sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [win32] + + '@img/sharp-win32-ia32@0.33.5': + resolution: {integrity: sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [ia32] + os: [win32] + + '@img/sharp-win32-ia32@0.34.5': + resolution: {integrity: sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [ia32] + os: [win32] + + '@img/sharp-win32-x64@0.33.5': + resolution: {integrity: sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [win32] + + '@img/sharp-win32-x64@0.34.5': + resolution: {integrity: sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [win32] + + '@inquirer/ansi@2.0.5': + resolution: {integrity: sha512-doc2sWgJpbFQ64UflSVd17ibMGDuxO1yKgOgLMwavzESnXjFWJqUeG8saYosqKpHp4kWiM5x1nXvEjbpx90gzw==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + + '@inquirer/confirm@6.0.13': + resolution: {integrity: sha512-wkGPC7yJ5WJk1DJ5SX7fzk+gfj4BM8cf5dDDi71B/551xHrdsZVRJOC0WyikXd0pEsb/9cLniuE4atbsMqmFkw==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@inquirer/core@11.1.10': + resolution: {integrity: sha512-a4Q5BXHQAHa9eO202sTaFCHFYVB3x5fauDuThEAdZ9gfn76pSxiKU7wWcEH0N1O0XmQvNfQNU6QXpiRxmYQx+A==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@inquirer/external-editor@1.0.3': + resolution: {integrity: sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@inquirer/figures@2.0.5': + resolution: {integrity: sha512-NsSs4kzfm12lNetHwAn3GEuH317IzpwrMCbOuMIVytpjnJ90YYHNwdRgYGuKmVxwuIqSgqk3M5qqQt1cDk0tGQ==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + + '@inquirer/type@4.0.5': + resolution: {integrity: sha512-aetVUNeKNc/VriqXlw1NRSW0zhMBB0W4bNbWRJgzRl/3d0QNDQFfk0GO5SDdtjMZVg6o8ZKEiadd7SCCzoOn5Q==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + + '@jridgewell/remapping@2.3.5': + resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + + '@legendapp/list@3.0.0-beta.54': + resolution: {integrity: sha512-70Cs0oE2cHd6mgHkKfFrCSb8n5Ew7+f1mdO2cm9ICBuSabK5ufqjUhEg9ixpRha6OrzuArOtRX+7iCf3HEaj3g==} + peerDependencies: + react: '*' + react-dom: '*' + react-native: '*' + peerDependenciesMeta: + react-dom: + optional: true + react-native: + optional: true + + '@lexical/clipboard@0.44.0': + resolution: {integrity: sha512-nfmNIs7uENqlDI7cm2E4I1Yp8mDJGMhEQIrIV2rNWnL1oeHVXQ7yuYdyoPdcY1zuj/9nvkYBQYUEh0QiGwpETA==} + + '@lexical/code-core@0.44.0': + resolution: {integrity: sha512-m57JyXTIvW1tsqw/Vuogk8jqWCZZIeFQbWybRc46ytR8ReDgzPRODpN8+dacIIeRH5yC5UC3lAa743mtdNkxqg==} + + '@lexical/devtools-core@0.44.0': + resolution: {integrity: sha512-X3uNG3P1vOsdzmEcy+7m9DxAcIVtVUZnvskmLqqLs6VluVVwH9xy7h1bPsvlDKvj1Nj73tWJ3TW0qXQWDTo5tw==} + peerDependencies: + react: '>=17.x' + react-dom: '>=17.x' + + '@lexical/dragon@0.44.0': + resolution: {integrity: sha512-RhlsjVDket9k1+YFEkDE0/7Qyrh2BI0vxBMzrWwPJTXX/4YFanYN9su8RSabkIukBBJ3QiNOOoC8FKK4Lkr4qg==} + + '@lexical/extension@0.44.0': + resolution: {integrity: sha512-BsYtoc+0EU0pqcOpf/lIUDU6LQVO6zX2AawZoUWJzT3Wzfov23qsqZWvl2WGM9dnRTN5iISJL3Fl53bQVxiXxw==} + + '@lexical/hashtag@0.44.0': + resolution: {integrity: sha512-0WATahDSqYKVTudQv3KpFbLeCpmrCpRptPFbjxOMckAX2MRpYlrExlqKfgfpri5BSQPtG49EPSGeNfSx/Faavw==} + + '@lexical/history@0.44.0': + resolution: {integrity: sha512-RGXcbFTgYL1GIWaReBI26mNSsJTfiA9EAtDY4LBeZ14NrIQhYNokKgNiOxq5Bn8xXrl2+mawQEqoMfgpWp/5YA==} + + '@lexical/html@0.44.0': + resolution: {integrity: sha512-5X6eGsgwtqPxABsuShUxF7ZfyB/U4GwSEyeonvwH1Vc/5Q2uQVjlB+FAYd+MNwWMHMh4d4+yZ3l70AtIuhr5eg==} + + '@lexical/link@0.44.0': + resolution: {integrity: sha512-uvEqEol/mLEzGVQd8Rok9I48RgYPKokM/nsclI9nYcEdccVOM2Nri4ntoRwodhbccFLtjMPl8OBldwXbfc77tQ==} + + '@lexical/list@0.44.0': + resolution: {integrity: sha512-ZTCWxDz1okPrC9FBXi1yV3W5fbQQeMUlFIcSVF9HibcVPmCsPa900IxthuiQbGiTycUyXDTOB3IUYRtlJNtpjw==} + + '@lexical/mark@0.44.0': + resolution: {integrity: sha512-bWMowllwe6BcgYMAkrsZx6Z+CX/72qCQpFKhlkR4ael92yOWSBkz68xp1wxxkSnQX9zoI1gYTeWBofVsSDKcsQ==} + + '@lexical/markdown@0.44.0': + resolution: {integrity: sha512-DwlXdp85pYMo3exDF6W3iz8plpuP+RQ4Me4Iljm7O5aPDp0SSrIoZxyX4zS668mVAoz5HHj1Ka0kQkft8mq26Q==} + + '@lexical/overflow@0.44.0': + resolution: {integrity: sha512-5GYaYjSxn27pqHRfU+tQ2STF10wgJvI+MUnwTnUFSzy3dko1b+oV94K/Yx0TuEewPbwDibfoFA8CwqUvOLHAyw==} + + '@lexical/plain-text@0.44.0': + resolution: {integrity: sha512-bIV4Lljk0x70zFhkZIwzSPK5q3m9FpDisjGm2/3Q/chb+5BW3Tv8QJmqnpCiSO6S2KXO7gfSy81ZfkQ1dcd4EQ==} + + '@lexical/react@0.44.0': + resolution: {integrity: sha512-p/NQd/fMh3pXb1XqegE2ruvWDcUmfB12OidQ9nwtMtj5VfcUjQu2I+trUhgGRIADxSYxMWmw+8PPj5YSf4m5oA==} + peerDependencies: + react: '>=17.x' + react-dom: '>=17.x' + yjs: '>=13.5.22' + peerDependenciesMeta: + yjs: + optional: true '@lexical/rich-text@0.44.0': resolution: {integrity: sha512-IIdrutK5GY47ITjPlZB7KzUi9dBDwygsyFOwolnrYSL7m6TtGhAqrYiFg/YNOTT/nBzK3KQeCJRbnxpjJAVZtQ==} @@ -899,6 +1739,15 @@ packages: resolution: {integrity: sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==} engines: {node: '>= 10.0.0'} + '@poppinss/colors@4.1.6': + resolution: {integrity: sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==} + + '@poppinss/dumper@0.6.5': + resolution: {integrity: sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==} + + '@poppinss/exception@1.2.3': + resolution: {integrity: sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==} + '@preact/signals-core@1.14.2': resolution: {integrity: sha512-RZHdBj9ZF4n40Rp4jS052EHHjBWf96P9oNdXPfhQTovCuWY9iQn3Gq+gOTJSgBO9A/JBuPfMOWsSX/lIU9Pc/A==} @@ -1618,6 +2467,9 @@ packages: '@radix-ui/rect@1.1.1': resolution: {integrity: sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw==} + '@rolldown/pluginutils@1.0.0-rc.3': + resolution: {integrity: sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q==} + '@rollup/rollup-android-arm-eabi@4.60.3': resolution: {integrity: sha512-x35CNW/ANXG3hE/EZpRU8MXX1JDN86hBb2wMGAtltkz7pc6cxgjpy1OMMfDosOQ+2hWqIkag/fGok1Yady9nGw==} cpu: [arm] @@ -1756,6 +2608,13 @@ packages: cpu: [x64] os: [win32] + '@sindresorhus/is@7.2.0': + resolution: {integrity: sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==} + engines: {node: '>=18'} + + '@speed-highlight/core@1.2.15': + resolution: {integrity: sha512-BMq1K3DsElxDWawkX6eLg9+CKJrTVGCBAWVuHXVUV2u0s2711qiChLSId6ikYPfxhdYocLNt3wWwSvDiTvFabw==} + '@standard-schema/spec@1.1.0': resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} @@ -1857,6 +2716,18 @@ packages: peerDependencies: vite: ^5.2.0 || ^6 || ^7 || ^8 + '@types/babel__core@7.20.5': + resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} + + '@types/babel__generator@7.27.0': + resolution: {integrity: sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==} + + '@types/babel__template@7.4.4': + resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} + + '@types/babel__traverse@7.28.0': + resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} + '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} @@ -1866,6 +2737,9 @@ packages: '@types/deep-eql@4.0.2': resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + '@types/esrecurse@4.3.1': + resolution: {integrity: sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==} + '@types/estree-jsx@1.0.5': resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==} @@ -1878,6 +2752,9 @@ packages: '@types/hast@3.0.4': resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + '@types/mdast@4.0.4': resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} @@ -1916,12 +2793,91 @@ packages: '@types/ws@8.18.1': resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} + '@typescript-eslint/eslint-plugin@8.59.3': + resolution: {integrity: sha512-PwFvSKsXGShKGW6n5bZOhGHEcCZXM8HofLK9fNsEwZXzFRjoY+XT1Vsf1zgyXdwTr0ZYz1/2tkZ0DBTT9jZjhw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/parser': ^8.59.3 + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/parser@8.59.3': + resolution: {integrity: sha512-HPwA+hVkfcriajbNvTmZv4VRauibay+cWArYUYq7u7W7PmGShMxbPxLvrwDme55a6d5alG3nrYfhyJ/G28XlLg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/project-service@8.59.3': + resolution: {integrity: sha512-ECiUWa/KYRGDFUqTNehaRgzDshnJfkTABJxVemHk4ko22gcr0ukloKjWvyQ64g8YCV/UI47kN1dbmjf/GaQYng==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/scope-manager@8.59.3': + resolution: {integrity: sha512-t2LvZnoEfzKtnPjgeEu41xw5gxq9mQVfYy4OoZ4Vlt0sk3JwxmhCca/AR7DwOiHrjWgjAj6as4AhRLKSDfvZIA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/tsconfig-utils@8.59.3': + resolution: {integrity: sha512-PcIJHjmaREXLgIAIzLnSY9VucEzz8FKXsRgFa1DmdGCK/5tJpW03TKJF01Q6VZd1lLdz2sIKPWaDUZN9dp//dw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/type-utils@8.59.3': + resolution: {integrity: sha512-g71d8QD8UaiHGvrJwyIS1hCX5r63w6Jll+4VEYhEAHXTDIqX1JgxhTAbEHtKntL9kuc4jRo7/GWw5xfCepSccQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/types@8.59.3': + resolution: {integrity: sha512-ePFoH0g4ludssdRFqqDxQePCxU4WQyRa9+XVwjm7yLn0FKhMeoetC+qBEEI1Eyb1pGSDveTIT09Bvw2WhlGayg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/typescript-estree@8.59.3': + resolution: {integrity: sha512-CbRjVRAf7Lr9Kr8RopKcbY45p2VfmmHrm0ygOCYFi7oU8q19m0Fs/6iHS7kNOmwpp+ob07ZVcAqlxUod9lYdmg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/utils@8.59.3': + resolution: {integrity: sha512-JAvT14goBzRzzzZyqq3P9BLArIxTtQURUtFgQ/V7FO+eU+Gg6ES+5ymOPP1wRxXcxAYeivCk4uS3jCKWI1K8Zg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/visitor-keys@8.59.3': + resolution: {integrity: sha512-f1UQF7ggd42YiwI5wGrRaPsa+P0CINBlrkLPmGfpq/u/I/oVtecoEIfFR9ag/oa1sLOsRNZ6xehf6qMZhQGBDg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@ungap/structured-clone@1.3.1': resolution: {integrity: sha512-mUFwbeTqrVgDQxFveS+df2yfap6iuP20NAKAsBt5jDEoOTDew+zwLAOilHCeQJOVSvmgCX4ogqIrA0mnyr08yQ==} + '@vitejs/plugin-react@5.2.0': + resolution: {integrity: sha512-YmKkfhOAi3wsB1PhJq5Scj3GXMn3WvtQ/JC0xoopuHoXSdmtdStOpFrYaT1kie2YgFBcIe64ROzMYRjCrYOdYw==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + vite: ^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 + + '@vitest/expect@3.2.4': + resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==} + '@vitest/expect@4.1.6': resolution: {integrity: sha512-7EHDquPthALSV0jhhjgEW8FXaviMx7rSqu8W6oqCoAuOhKov814P99QDV1pxMA3QPv21YudvJngIhjrNI4opLg==} + '@vitest/mocker@3.2.4': + resolution: {integrity: sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==} + peerDependencies: + msw: ^2.4.9 + vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + '@vitest/mocker@4.1.6': resolution: {integrity: sha512-MCFc63czMjEInOlcY2cpQCvCN+KgbAn+60xu9cMgP4sKaLC5JNAKw7JH8QdAnoAC88hW1IiSNZ+GgVXlN1UcMQ==} peerDependencies: @@ -1933,26 +2889,58 @@ packages: vite: optional: true + '@vitest/pretty-format@3.2.4': + resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==} + '@vitest/pretty-format@4.1.6': resolution: {integrity: sha512-h5SxD/IzNhZYnrSZRsUZQIC+vD0GY8cUvq0iwsmkFKixRCKLLWqCXa/FIQ4S1R+sI+PGoojkHsdNrbZiM9Qpgw==} + '@vitest/runner@3.2.4': + resolution: {integrity: sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==} + '@vitest/runner@4.1.6': resolution: {integrity: sha512-nOPCmn2+yD0ZNmKdsXGv/UxMMWbMuKeD6GyYncNwdkYDxpQvrPSKYj2rWuDjC2Y4b6w6hjip5dBKFzEUuZe3vA==} + '@vitest/snapshot@3.2.4': + resolution: {integrity: sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==} + '@vitest/snapshot@4.1.6': resolution: {integrity: sha512-YhsdE6xAVfTDmzjxL2ZDUvjj+ZsgyOKe+TdQzqkD72wIOmHka8NuGQ6NpTNZv9D2Z63fbwWKJPeVpEw4EQgYxw==} + '@vitest/spy@3.2.4': + resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==} + '@vitest/spy@4.1.6': resolution: {integrity: sha512-JFKxMx6udhwKh/Ldo270e17QX710vgunMkuPAvXjHSvC6oqLWAHhVhjg/I71q0u0CBSErIODV1Kjv0FQNSWjdg==} + '@vitest/utils@3.2.4': + resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==} + '@vitest/utils@4.1.6': resolution: {integrity: sha512-FxIY+U81R3LGKCxaHHFRQ5+g6/iRgGLmeHWdp2Amj4ljQRrEIWHmZyDfDYBRZlpyqA7qKxtS9DD1dhk8RnRIVQ==} - acorn@8.16.0: - resolution: {integrity: sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==} - engines: {node: '>=0.4.0'} + acorn-jsx@5.3.2: + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + + acorn-walk@8.3.2: + resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} + engines: {node: '>=0.4.0'} + + acorn@8.14.0: + resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} + engines: {node: '>=0.4.0'} + hasBin: true + + acorn@8.16.0: + resolution: {integrity: sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==} + engines: {node: '>=0.4.0'} hasBin: true + ajv@6.15.0: + resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==} + ansi-colors@4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} @@ -1989,14 +2977,38 @@ packages: bail@2.0.2: resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==} + balanced-match@4.0.4: + resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} + engines: {node: 18 || 20 || >=22} + + baseline-browser-mapping@2.10.29: + resolution: {integrity: sha512-Asa2krT+XTPZINCS+2QcyS8WTkObE77RwkydwF7h6DmnKqbvlalz93m/dnphUyCa6SWSP51VgtEUf2FN+gelFQ==} + engines: {node: '>=6.0.0'} + hasBin: true + better-path-resolve@1.0.0: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} + birpc@0.2.14: + resolution: {integrity: sha512-37FHE8rqsYM5JEKCnXFyHpBCzvgHEExwVVTq+nUmloInU7l8ezD1TpOhKpS8oe1DTYFqEK27rFZVKG43oTqXRA==} + + blake3-wasm@2.1.5: + resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==} + + brace-expansion@5.0.6: + resolution: {integrity: sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==} + engines: {node: 18 || 20 || >=22} + braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} + browserslist@4.28.2: + resolution: {integrity: sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + bundle-require@5.1.0: resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2007,9 +3019,16 @@ packages: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} + caniuse-lite@1.0.30001792: + resolution: {integrity: sha512-hVLMUZFgR4JJ6ACt1uEESvQN1/dBVqPAKY0hgrV70eN3391K6juAfTjKZLKvOMsx8PxA7gsY1/tLMMTcfFLLpw==} + ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} + chai@5.3.3: + resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==} + engines: {node: '>=18'} + chai@6.2.2: resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} engines: {node: '>=18'} @@ -2029,10 +3048,17 @@ packages: chardet@2.1.1: resolution: {integrity: sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==} + check-error@2.1.3: + resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==} + engines: {node: '>= 16'} + chokidar@4.0.3: resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} engines: {node: '>= 14.16.0'} + cjs-module-lexer@1.4.3: + resolution: {integrity: sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==} + class-variance-authority@0.7.1: resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==} @@ -2061,6 +3087,13 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + color-string@1.9.1: + resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} + + color@4.2.3: + resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} + engines: {node: '>=12.5.0'} + comma-separated-tokens@2.0.3: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} @@ -2104,6 +3137,13 @@ packages: decode-named-character-reference@1.3.0: resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==} + deep-eql@5.0.2: + resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} + engines: {node: '>=6'} + + deep-is@0.1.4: + resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -2119,6 +3159,9 @@ packages: detect-node-es@1.1.0: resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==} + devalue@5.8.0: + resolution: {integrity: sha512-2zA9pFEsnp7vWBZbXF5JAgAq0fsUIt/1XPbRiAmRV3lp/2C3upzH+sADiyy66aFCihoLEsrQHxNM5w1gIDfsBg==} + devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} @@ -2130,6 +3173,9 @@ packages: resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==} engines: {node: '>=10'} + electron-to-chromium@1.5.353: + resolution: {integrity: sha512-kOrWphBi8TOZyiJZqsgqIle0lw+tzmnQK83pV9dZUd01Nm2POECSyFQMAuarzZdYqQW7FH9RaYOuaRo3h+bQ3w==} + emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -2141,6 +3187,12 @@ packages: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} + error-stack-parser-es@1.0.5: + resolution: {integrity: sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==} + + es-module-lexer@1.7.0: + resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} + es-module-lexer@2.1.0: resolution: {integrity: sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==} @@ -2149,6 +3201,16 @@ packages: engines: {node: '>=18'} hasBin: true + esbuild@0.27.0: + resolution: {integrity: sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==} + engines: {node: '>=18'} + hasBin: true + + esbuild@0.27.3: + resolution: {integrity: sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==} + engines: {node: '>=18'} + hasBin: true + esbuild@0.27.7: resolution: {integrity: sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==} engines: {node: '>=18'} @@ -2158,21 +3220,77 @@ packages: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} + escape-string-regexp@4.0.0: + resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} + engines: {node: '>=10'} + escape-string-regexp@5.0.0: resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} engines: {node: '>=12'} + eslint-plugin-react-hooks@7.1.1: + resolution: {integrity: sha512-f2I7Gw6JbvCexzIInuSbZpfdQ44D7iqdWX01FKLvrPgqxoE7oMj8clOfto8U6vYiz4yd5oKu39rRSVOe1zRu0g==} + engines: {node: '>=18'} + peerDependencies: + eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0 + + eslint-scope@9.1.2: + resolution: {integrity: sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + eslint-visitor-keys@5.0.1: + resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + eslint@10.3.0: + resolution: {integrity: sha512-XbEXaRva5cF0ZQB8w6MluHA0kZZfV2DuCMJ3ozyEOHLwDpZX2Lmm/7Pp0xdJmI0GL1W05VH5VwIFHEm1Vcw2gw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + hasBin: true + peerDependencies: + jiti: '*' + peerDependenciesMeta: + jiti: + optional: true + + espree@11.2.0: + resolution: {integrity: sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + esprima@4.0.1: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} hasBin: true + esquery@1.7.0: + resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==} + engines: {node: '>=0.10'} + + esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + + estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + estree-util-is-identifier-name@3.0.0: resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==} estree-walker@3.0.3: resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + esutils@2.0.3: + resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} + engines: {node: '>=0.10.0'} + + exit-hook@2.2.1: + resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} + engines: {node: '>=6'} + expect-type@1.3.0: resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==} engines: {node: '>=12.0.0'} @@ -2183,10 +3301,19 @@ packages: extendable-error@0.1.7: resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fast-glob@3.3.3: resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} engines: {node: '>=8.6.0'} + fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + + fast-levenshtein@2.0.6: + resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + fast-string-truncated-width@3.0.3: resolution: {integrity: sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==} @@ -2208,6 +3335,10 @@ packages: picomatch: optional: true + file-entry-cache@8.0.0: + resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} + engines: {node: '>=16.0.0'} + fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} @@ -2216,9 +3347,20 @@ packages: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} + find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + fix-dts-default-cjs-exports@1.0.1: resolution: {integrity: sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==} + flat-cache@4.0.1: + resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} + engines: {node: '>=16'} + + flatted@3.4.2: + resolution: {integrity: sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==} + fs-extra@7.0.1: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} @@ -2232,6 +3374,10 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + gensync@1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + get-caller-file@2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} @@ -2244,6 +3390,17 @@ packages: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} + glob-parent@6.0.2: + resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} + engines: {node: '>=10.13.0'} + + glob-to-regexp@0.4.1: + resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} + + globals@17.6.0: + resolution: {integrity: sha512-sepffkT8stwnIYbsMBpoCHJuJM5l98FUF2AnE07hfvE0m/qp3R586hw4jF4uadbhvg1ooIdzuu7CsfD2jzCaNA==} + engines: {node: '>=18'} + globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} @@ -2264,6 +3421,12 @@ packages: headers-polyfill@5.0.1: resolution: {integrity: sha512-1TJ6Fih/b8h5TIcv+1+Hw0PDQWJTKDKzFZzcKOiW1wJza3XoAQlkCuXLbymPYB8+ZQyw8mHvdw560e8zVFIWyA==} + hermes-estree@0.25.1: + resolution: {integrity: sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==} + + hermes-parser@0.25.1: + resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==} + html-url-attributes@3.0.1: resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==} @@ -2279,6 +3442,14 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.5: + resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} + engines: {node: '>= 4'} + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + inline-style-parser@0.2.7: resolution: {integrity: sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==} @@ -2288,6 +3459,9 @@ packages: is-alphanumerical@2.0.1: resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==} + is-arrayish@0.3.4: + resolution: {integrity: sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==} + is-decimal@2.0.1: resolution: {integrity: sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==} @@ -2339,6 +3513,12 @@ packages: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + js-tokens@9.0.1: + resolution: {integrity: sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==} + js-yaml@3.14.2: resolution: {integrity: sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==} hasBin: true @@ -2347,9 +3527,39 @@ packages: resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==} hasBin: true + jsesc@3.1.0: + resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} + engines: {node: '>=6'} + hasBin: true + + json-buffer@3.0.1: + resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + + json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + + json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + keyv@4.5.4: + resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + + kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + + levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + lexical@0.44.0: resolution: {integrity: sha512-ReDUjRlFgkGoPWzvdjr7s16PUVpHATN+2NH2NiZs+PLlISTaIFFgKil2P467oP3Vg+XgmpDsUgmWZsFJTztYjg==} @@ -2447,12 +3657,22 @@ packages: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} longest-streak@3.1.0: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} + loupe@3.2.1: + resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==} + + lru-cache@5.1.1: + resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + lucide-react@1.14.0: resolution: {integrity: sha512-+1mdWcfSJVUsaTIjN9zoezmUhfXo5l0vP7ekBMPo3jcS/aIkxHnXqAPsByszMZx/Y8oQBRJxJx5xg+RH3urzxA==} peerDependencies: @@ -2601,6 +3821,25 @@ packages: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} + mime@3.0.0: + resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} + engines: {node: '>=10.0.0'} + hasBin: true + + miniflare@4.20251210.0: + resolution: {integrity: sha512-k6kIoXwGVqlPZb0hcn+X7BmnK+8BjIIkusQPY22kCo2RaQJ/LzAjtxHQdGXerlHSnJyQivDQsL6BJHMpQfUFyw==} + engines: {node: '>=18.0.0'} + hasBin: true + + miniflare@4.20260508.0: + resolution: {integrity: sha512-h3aG+PA8jEH76V4ZtBAbs3g7kjMfHJUF8hPvxeeajLTKwir+G+dqfBODg5yF9MT29LqrZKCRQRqzfHPWX4kCIg==} + engines: {node: '>=22.0.0'} + hasBin: true + + minimatch@10.2.5: + resolution: {integrity: sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==} + engines: {node: 18 || 20 || >=22} + mlly@1.8.2: resolution: {integrity: sha512-d+ObxMQFmbt10sretNDytwt85VrbkhhUA/JBGm1MPaWJ65Cl4wOgLaB1NYvJSZ0Ef03MMEU/0xpPMXUIQ29UfA==} @@ -2633,6 +3872,9 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + node-addon-api@7.1.1: resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} @@ -2645,6 +3887,9 @@ packages: encoding: optional: true + node-releases@2.0.44: + resolution: {integrity: sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ==} + object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -2652,6 +3897,10 @@ packages: obug@2.1.1: resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} + optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + outdent@0.5.0: resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} @@ -2666,10 +3915,18 @@ packages: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + p-map@2.1.0: resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} engines: {node: '>=6'} @@ -2705,6 +3962,10 @@ packages: pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + pathval@2.0.1: + resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==} + engines: {node: '>= 14.16'} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -2749,6 +4010,10 @@ packages: resolution: {integrity: sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg==} engines: {node: ^10 || ^12 || >=14} + prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} @@ -2767,6 +4032,10 @@ packages: engines: {node: '>=18'} hasBin: true + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + quansync@0.2.11: resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==} @@ -2802,6 +4071,10 @@ packages: '@types/react': '>=18' react: '>=18' + react-refresh@0.18.0: + resolution: {integrity: sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==} + engines: {node: '>=0.10.0'} + react-remove-scroll-bar@2.3.8: resolution: {integrity: sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==} engines: {node: '>=10'} @@ -2889,6 +4162,10 @@ packages: scheduler@0.27.0: resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==} + semver@6.3.1: + resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} + hasBin: true + semver@7.8.0: resolution: {integrity: sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==} engines: {node: '>=10'} @@ -2897,6 +4174,14 @@ packages: set-cookie-parser@3.1.0: resolution: {integrity: sha512-kjnC1DXBHcxaOaOXBHBeRtltsDG2nUiUni+jP92M9gYdW12rsmx92UsfpH7o5tDRs7I1ZZPSQJQGv3UaRfCiuw==} + sharp@0.33.5: + resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + + sharp@0.34.5: + resolution: {integrity: sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -2912,6 +4197,9 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + simple-swizzle@0.2.4: + resolution: {integrity: sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==} + slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -2944,9 +4232,16 @@ packages: resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==} engines: {node: '>= 0.8'} + std-env@3.10.0: + resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} + std-env@4.1.0: resolution: {integrity: sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==} + stoppable@1.1.0: + resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} + engines: {node: '>=4', npm: '>=6'} + strict-event-emitter@0.5.1: resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==} @@ -2965,6 +4260,9 @@ packages: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} + strip-literal@3.1.0: + resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==} + style-to-js@1.1.21: resolution: {integrity: sha512-RjQetxJrrUJLQPHbLku6U/ocGtzyjbJMP9lCNK7Ag0CNh690nSH8woqWH9u16nMjYBAok+i7JO1NP2pOy8IsPQ==} @@ -2976,6 +4274,10 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true + supports-color@10.2.2: + resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==} + engines: {node: '>=18'} + tabbable@6.4.0: resolution: {integrity: sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==} @@ -3018,10 +4320,22 @@ packages: resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==} engines: {node: '>=12.0.0'} + tinypool@1.1.1: + resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==} + engines: {node: ^18.0.0 || >=20.0.0} + + tinyrainbow@2.0.0: + resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==} + engines: {node: '>=14.0.0'} + tinyrainbow@3.1.0: resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==} engines: {node: '>=14.0.0'} + tinyspy@4.0.4: + resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==} + engines: {node: '>=14.0.0'} + tldts-core@7.0.30: resolution: {integrity: sha512-uiHN8PIB1VmWyS98eZYja4xzlYqeFZVjb4OuYlJQnZAuJhMw4PbKQOKgHKhBdJR3FE/t5mUQ1Kd80++B+qhD1Q==} @@ -3050,6 +4364,12 @@ packages: trough@2.2.0: resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==} + ts-api-utils@2.5.0: + resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} @@ -3078,10 +4398,21 @@ packages: tw-animate-css@1.4.0: resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==} + type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + type-fest@5.6.0: resolution: {integrity: sha512-8ZiHFm91orbSAe2PSAiSVBVko18pbhbiB3U9GglSzF/zCGkR+rxpHx6sEMCUm4kxY4LjDIUGgCfUMtwfZfjfUA==} engines: {node: '>=20'} + typescript-eslint@8.59.3: + resolution: {integrity: sha512-KgusgyDgG4LI8Ih/sWaCtZ06tckLAS5CvT5A4D1Q7bYVoAAyzwiZvE4BmwDHkhRVkvhRBepKeASoFzQetha7Fg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + typescript@5.8.3: resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} engines: {node: '>=14.17'} @@ -3093,6 +4424,17 @@ packages: undici-types@7.16.0: resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==} + undici@7.14.0: + resolution: {integrity: sha512-Vqs8HTzjpQXZeXdpsfChQTlafcMQaaIwnGwLam1wudSSjlJeQ3bw1j+TLPePgrCnCpUXx7Ba5Pdpf5OBih62NQ==} + engines: {node: '>=20.18.1'} + + undici@7.24.8: + resolution: {integrity: sha512-6KQ/+QxK49Z/p3HO6E5ZCZWNnCasyZLa5ExaVYyvPxUwKtbCPMKELJOqh7EqOle0t9cH/7d2TaaTRRa6Nhs4YQ==} + engines: {node: '>=20.18.1'} + + unenv@2.0.0-rc.24: + resolution: {integrity: sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==} + unified@11.0.5: resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==} @@ -3118,6 +4460,15 @@ packages: until-async@3.0.2: resolution: {integrity: sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw==} + update-browserslist-db@1.2.3: + resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + use-callback-ref@1.3.3: resolution: {integrity: sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==} engines: {node: '>=10'} @@ -3149,6 +4500,11 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} + vite-node@3.2.4: + resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + hasBin: true + vite@6.4.2: resolution: {integrity: sha512-2N/55r4JDJ4gdrCvGgINMy+HH3iRpNIz8K6SFwVsA+JbQScLiC+clmAxBgwiSPgcG9U15QmvqCGWzMbqda5zGQ==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} @@ -3189,6 +4545,34 @@ packages: yaml: optional: true + vitest@3.2.4: + resolution: {integrity: sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/debug': ^4.1.12 + '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 + '@vitest/browser': 3.2.4 + '@vitest/ui': 3.2.4 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/debug': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + vitest@4.1.6: resolution: {integrity: sha512-6lvjbS3p9b4CrdCmguzbh2/4uoXhGE2q71R4OX5sqF9R1bo9Xd6fGrMAfvp5wnCzlBnFVdCOp6onuTQVbo8iUQ==} engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -3246,10 +4630,56 @@ packages: engines: {node: '>=8'} hasBin: true + word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + + workerd@1.20251210.0: + resolution: {integrity: sha512-9MUUneP1BnRE9XAYi94FXxHmiLGbO75EHQZsgWqSiOXjoXSqJCw8aQbIEPxCy19TclEl/kHUFYce8ST2W+Qpjw==} + engines: {node: '>=16'} + hasBin: true + + workerd@1.20260508.1: + resolution: {integrity: sha512-VlnjyH3AjVddpSK7J54nsCVgf8i2733pl8GjKttfNi7vN/hEjjAk20d2b1nDToOLKvRQpTewRnVkqaaeGHCaAw==} + engines: {node: '>=16'} + hasBin: true + + wrangler@4.54.0: + resolution: {integrity: sha512-bANFsjDwJLbprYoBK+hUDZsVbUv2SqJd8QvArLIcZk+fPq4h/Ohtj5vkKXD3k0s2bD1DXLk08D+hYmeNH+xC6A==} + engines: {node: '>=20.0.0'} + hasBin: true + peerDependencies: + '@cloudflare/workers-types': ^4.20251210.0 + peerDependenciesMeta: + '@cloudflare/workers-types': + optional: true + + wrangler@4.90.1: + resolution: {integrity: sha512-u2KrieKSMfRM0toTst/CfDtcRraeoVjmcExcMWgILM/ytq3qcDhuOAULoZSyPHzma43lfLJy1BC544drFyqe1A==} + engines: {node: '>=22.0.0'} + hasBin: true + peerDependencies: + '@cloudflare/workers-types': ^4.20260508.1 + peerDependenciesMeta: + '@cloudflare/workers-types': + optional: true + wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} + ws@8.18.0: + resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + ws@8.20.0: resolution: {integrity: sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==} engines: {node: '>=10.0.0'} @@ -3266,6 +4696,9 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} + yallist@3.1.1: + resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -3278,6 +4711,31 @@ packages: resolution: {integrity: sha512-vv/9h42eCMC81ZHDFswuu/MKzkl/vyq1BhaNGfHyOonwlG4CJbQF4oiBBJPvfdeCt/PlVDWh7Nov9D34YY09uQ==} engines: {node: '>=16.0.0', npm: '>=8.0.0'} + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + + youch-core@0.3.3: + resolution: {integrity: sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==} + + youch@4.1.0-beta.10: + resolution: {integrity: sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==} + + zod-validation-error@4.0.2: + resolution: {integrity: sha512-Q6/nZLe6jxuU80qb/4uJ4t5v2VEZ44lzQjPDhYJNztRQ4wyWc6VF3D3Kb/fAuPetZQnhS3hnajCf9CsWesghLQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + zod: ^3.25.0 || ^4.0.0 + + zod@3.22.3: + resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==} + + zod@3.25.76: + resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==} + + zod@4.4.3: + resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==} + zustand@5.0.13: resolution: {integrity: sha512-efI2tVaVQPqtOh114loML/Z80Y4NP3yc+Ff0fYiZJPauNeWZeIp/bRFD7I9bfmCOYBh/PHxlglQ9+wvlwnPikQ==} engines: {node: '>=12.20.0'} @@ -3301,48 +4759,160 @@ packages: snapshots: - '@babel/runtime@7.29.2': {} + '@babel/code-frame@7.29.0': + dependencies: + '@babel/helper-validator-identifier': 7.28.5 + js-tokens: 4.0.0 + picocolors: 1.1.1 - '@changesets/apply-release-plan@7.1.1': + '@babel/compat-data@7.29.3': {} + + '@babel/core@7.29.0': dependencies: - '@changesets/config': 3.1.4 - '@changesets/get-version-range-type': 0.4.0 - '@changesets/git': 3.0.4 - '@changesets/should-skip-package': 0.1.2 - '@changesets/types': 6.1.0 - '@manypkg/get-packages': 1.1.3 - detect-indent: 6.1.0 - fs-extra: 7.0.1 - lodash.startcase: 4.4.0 - outdent: 0.5.0 - prettier: 2.8.8 - resolve-from: 5.0.0 - semver: 7.8.0 + '@babel/code-frame': 7.29.0 + '@babel/generator': 7.29.1 + '@babel/helper-compilation-targets': 7.28.6 + '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0) + '@babel/helpers': 7.29.2 + '@babel/parser': 7.29.3 + '@babel/template': 7.28.6 + '@babel/traverse': 7.29.0 + '@babel/types': 7.29.0 + '@jridgewell/remapping': 2.3.5 + convert-source-map: 2.0.0 + debug: 4.4.3 + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color - '@changesets/assemble-release-plan@6.0.10': + '@babel/generator@7.29.1': dependencies: - '@changesets/errors': 0.2.0 - '@changesets/get-dependents-graph': 2.1.4 - '@changesets/should-skip-package': 0.1.2 - '@changesets/types': 6.1.0 - '@manypkg/get-packages': 1.1.3 - semver: 7.8.0 + '@babel/parser': 7.29.3 + '@babel/types': 7.29.0 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + jsesc: 3.1.0 - '@changesets/changelog-git@0.2.1': + '@babel/helper-compilation-targets@7.28.6': dependencies: - '@changesets/types': 6.1.0 + '@babel/compat-data': 7.29.3 + '@babel/helper-validator-option': 7.27.1 + browserslist: 4.28.2 + lru-cache: 5.1.1 + semver: 6.3.1 - '@changesets/changelog-github@0.5.2': + '@babel/helper-globals@7.28.0': {} + + '@babel/helper-module-imports@7.28.6': dependencies: - '@changesets/get-github-info': 0.7.0 - '@changesets/types': 6.1.0 - dotenv: 8.6.0 + '@babel/traverse': 7.29.0 + '@babel/types': 7.29.0 transitivePeerDependencies: - - encoding + - supports-color - '@changesets/cli@2.31.0(@types/node@24.12.3)': + '@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0)': dependencies: - '@changesets/apply-release-plan': 7.1.1 + '@babel/core': 7.29.0 + '@babel/helper-module-imports': 7.28.6 + '@babel/helper-validator-identifier': 7.28.5 + '@babel/traverse': 7.29.0 + transitivePeerDependencies: + - supports-color + + '@babel/helper-plugin-utils@7.28.6': {} + + '@babel/helper-string-parser@7.27.1': {} + + '@babel/helper-validator-identifier@7.28.5': {} + + '@babel/helper-validator-option@7.27.1': {} + + '@babel/helpers@7.29.2': + dependencies: + '@babel/template': 7.28.6 + '@babel/types': 7.29.0 + + '@babel/parser@7.29.3': + dependencies: + '@babel/types': 7.29.0 + + '@babel/plugin-transform-react-jsx-self@7.27.1(@babel/core@7.29.0)': + dependencies: + '@babel/core': 7.29.0 + '@babel/helper-plugin-utils': 7.28.6 + + '@babel/plugin-transform-react-jsx-source@7.27.1(@babel/core@7.29.0)': + dependencies: + '@babel/core': 7.29.0 + '@babel/helper-plugin-utils': 7.28.6 + + '@babel/runtime@7.29.2': {} + + '@babel/template@7.28.6': + dependencies: + '@babel/code-frame': 7.29.0 + '@babel/parser': 7.29.3 + '@babel/types': 7.29.0 + + '@babel/traverse@7.29.0': + dependencies: + '@babel/code-frame': 7.29.0 + '@babel/generator': 7.29.1 + '@babel/helper-globals': 7.28.0 + '@babel/parser': 7.29.3 + '@babel/template': 7.28.6 + '@babel/types': 7.29.0 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + '@babel/types@7.29.0': + dependencies: + '@babel/helper-string-parser': 7.27.1 + '@babel/helper-validator-identifier': 7.28.5 + + '@changesets/apply-release-plan@7.1.1': + dependencies: + '@changesets/config': 3.1.4 + '@changesets/get-version-range-type': 0.4.0 + '@changesets/git': 3.0.4 + '@changesets/should-skip-package': 0.1.2 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + detect-indent: 6.1.0 + fs-extra: 7.0.1 + lodash.startcase: 4.4.0 + outdent: 0.5.0 + prettier: 2.8.8 + resolve-from: 5.0.0 + semver: 7.8.0 + + '@changesets/assemble-release-plan@6.0.10': + dependencies: + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.4 + '@changesets/should-skip-package': 0.1.2 + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + semver: 7.8.0 + + '@changesets/changelog-git@0.2.1': + dependencies: + '@changesets/types': 6.1.0 + + '@changesets/changelog-github@0.5.2': + dependencies: + '@changesets/get-github-info': 0.7.0 + '@changesets/types': 6.1.0 + dotenv: 8.6.0 + transitivePeerDependencies: + - encoding + + '@changesets/cli@2.31.0(@types/node@24.12.3)': + dependencies: + '@changesets/apply-release-plan': 7.1.1 '@changesets/assemble-release-plan': 6.0.10 '@changesets/changelog-git': 0.2.1 '@changesets/config': 3.1.4 @@ -3445,204 +5015,668 @@ snapshots: p-filter: 2.1.0 picocolors: 1.1.1 - '@changesets/should-skip-package@0.1.2': - dependencies: - '@changesets/types': 6.1.0 - '@manypkg/get-packages': 1.1.3 + '@changesets/should-skip-package@0.1.2': + dependencies: + '@changesets/types': 6.1.0 + '@manypkg/get-packages': 1.1.3 + + '@changesets/types@4.1.0': {} + + '@changesets/types@6.1.0': {} + + '@changesets/write@0.4.0': + dependencies: + '@changesets/types': 6.1.0 + fs-extra: 7.0.1 + human-id: 4.1.3 + prettier: 2.8.8 + + '@cloudflare/kv-asset-handler@0.4.1': + dependencies: + mime: 3.0.0 + + '@cloudflare/kv-asset-handler@0.5.0': {} + + '@cloudflare/unenv-preset@2.16.1(unenv@2.0.0-rc.24)(workerd@1.20260508.1)': + dependencies: + unenv: 2.0.0-rc.24 + optionalDependencies: + workerd: 1.20260508.1 + + '@cloudflare/unenv-preset@2.7.13(unenv@2.0.0-rc.24)(workerd@1.20251210.0)': + dependencies: + unenv: 2.0.0-rc.24 + optionalDependencies: + workerd: 1.20251210.0 + + '@cloudflare/vite-plugin@1.36.4(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0))(workerd@1.20260508.1)(wrangler@4.90.1)': + dependencies: + '@cloudflare/unenv-preset': 2.16.1(unenv@2.0.0-rc.24)(workerd@1.20260508.1) + miniflare: 4.20260508.0 + unenv: 2.0.0-rc.24 + vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + wrangler: 4.90.1 + ws: 8.18.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + - workerd + + '@cloudflare/vitest-pool-workers@0.10.15(@vitest/runner@3.2.4)(@vitest/snapshot@3.2.4)(vitest@3.2.4(@types/debug@4.1.13)(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3)))': + dependencies: + '@vitest/runner': 3.2.4 + '@vitest/snapshot': 3.2.4 + birpc: 0.2.14 + cjs-module-lexer: 1.4.3 + devalue: 5.8.0 + miniflare: 4.20251210.0 + semver: 7.8.0 + vitest: 3.2.4(@types/debug@4.1.13)(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3)) + wrangler: 4.54.0 + zod: 3.25.76 + transitivePeerDependencies: + - '@cloudflare/workers-types' + - bufferutil + - utf-8-validate + + '@cloudflare/workerd-darwin-64@1.20251210.0': + optional: true + + '@cloudflare/workerd-darwin-64@1.20260508.1': + optional: true + + '@cloudflare/workerd-darwin-arm64@1.20251210.0': + optional: true + + '@cloudflare/workerd-darwin-arm64@1.20260508.1': + optional: true + + '@cloudflare/workerd-linux-64@1.20251210.0': + optional: true + + '@cloudflare/workerd-linux-64@1.20260508.1': + optional: true + + '@cloudflare/workerd-linux-arm64@1.20251210.0': + optional: true + + '@cloudflare/workerd-linux-arm64@1.20260508.1': + optional: true + + '@cloudflare/workerd-windows-64@1.20251210.0': + optional: true + + '@cloudflare/workerd-windows-64@1.20260508.1': + optional: true + + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + + '@emnapi/runtime@1.10.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@esbuild/aix-ppc64@0.25.12': + optional: true + + '@esbuild/aix-ppc64@0.27.0': + optional: true + + '@esbuild/aix-ppc64@0.27.3': + optional: true + + '@esbuild/aix-ppc64@0.27.7': + optional: true + + '@esbuild/android-arm64@0.25.12': + optional: true + + '@esbuild/android-arm64@0.27.0': + optional: true + + '@esbuild/android-arm64@0.27.3': + optional: true + + '@esbuild/android-arm64@0.27.7': + optional: true + + '@esbuild/android-arm@0.25.12': + optional: true + + '@esbuild/android-arm@0.27.0': + optional: true + + '@esbuild/android-arm@0.27.3': + optional: true + + '@esbuild/android-arm@0.27.7': + optional: true + + '@esbuild/android-x64@0.25.12': + optional: true + + '@esbuild/android-x64@0.27.0': + optional: true + + '@esbuild/android-x64@0.27.3': + optional: true + + '@esbuild/android-x64@0.27.7': + optional: true + + '@esbuild/darwin-arm64@0.25.12': + optional: true + + '@esbuild/darwin-arm64@0.27.0': + optional: true + + '@esbuild/darwin-arm64@0.27.3': + optional: true + + '@esbuild/darwin-arm64@0.27.7': + optional: true + + '@esbuild/darwin-x64@0.25.12': + optional: true + + '@esbuild/darwin-x64@0.27.0': + optional: true + + '@esbuild/darwin-x64@0.27.3': + optional: true + + '@esbuild/darwin-x64@0.27.7': + optional: true + + '@esbuild/freebsd-arm64@0.25.12': + optional: true + + '@esbuild/freebsd-arm64@0.27.0': + optional: true + + '@esbuild/freebsd-arm64@0.27.3': + optional: true + + '@esbuild/freebsd-arm64@0.27.7': + optional: true + + '@esbuild/freebsd-x64@0.25.12': + optional: true + + '@esbuild/freebsd-x64@0.27.0': + optional: true + + '@esbuild/freebsd-x64@0.27.3': + optional: true + + '@esbuild/freebsd-x64@0.27.7': + optional: true + + '@esbuild/linux-arm64@0.25.12': + optional: true + + '@esbuild/linux-arm64@0.27.0': + optional: true + + '@esbuild/linux-arm64@0.27.3': + optional: true + + '@esbuild/linux-arm64@0.27.7': + optional: true + + '@esbuild/linux-arm@0.25.12': + optional: true + + '@esbuild/linux-arm@0.27.0': + optional: true + + '@esbuild/linux-arm@0.27.3': + optional: true + + '@esbuild/linux-arm@0.27.7': + optional: true + + '@esbuild/linux-ia32@0.25.12': + optional: true + + '@esbuild/linux-ia32@0.27.0': + optional: true + + '@esbuild/linux-ia32@0.27.3': + optional: true + + '@esbuild/linux-ia32@0.27.7': + optional: true + + '@esbuild/linux-loong64@0.25.12': + optional: true + + '@esbuild/linux-loong64@0.27.0': + optional: true + + '@esbuild/linux-loong64@0.27.3': + optional: true + + '@esbuild/linux-loong64@0.27.7': + optional: true + + '@esbuild/linux-mips64el@0.25.12': + optional: true + + '@esbuild/linux-mips64el@0.27.0': + optional: true + + '@esbuild/linux-mips64el@0.27.3': + optional: true + + '@esbuild/linux-mips64el@0.27.7': + optional: true + + '@esbuild/linux-ppc64@0.25.12': + optional: true + + '@esbuild/linux-ppc64@0.27.0': + optional: true + + '@esbuild/linux-ppc64@0.27.3': + optional: true + + '@esbuild/linux-ppc64@0.27.7': + optional: true + + '@esbuild/linux-riscv64@0.25.12': + optional: true + + '@esbuild/linux-riscv64@0.27.0': + optional: true + + '@esbuild/linux-riscv64@0.27.3': + optional: true + + '@esbuild/linux-riscv64@0.27.7': + optional: true + + '@esbuild/linux-s390x@0.25.12': + optional: true + + '@esbuild/linux-s390x@0.27.0': + optional: true + + '@esbuild/linux-s390x@0.27.3': + optional: true + + '@esbuild/linux-s390x@0.27.7': + optional: true + + '@esbuild/linux-x64@0.25.12': + optional: true + + '@esbuild/linux-x64@0.27.0': + optional: true + + '@esbuild/linux-x64@0.27.3': + optional: true + + '@esbuild/linux-x64@0.27.7': + optional: true + + '@esbuild/netbsd-arm64@0.25.12': + optional: true + + '@esbuild/netbsd-arm64@0.27.0': + optional: true + + '@esbuild/netbsd-arm64@0.27.3': + optional: true + + '@esbuild/netbsd-arm64@0.27.7': + optional: true + + '@esbuild/netbsd-x64@0.25.12': + optional: true + + '@esbuild/netbsd-x64@0.27.0': + optional: true + + '@esbuild/netbsd-x64@0.27.3': + optional: true + + '@esbuild/netbsd-x64@0.27.7': + optional: true + + '@esbuild/openbsd-arm64@0.25.12': + optional: true + + '@esbuild/openbsd-arm64@0.27.0': + optional: true + + '@esbuild/openbsd-arm64@0.27.3': + optional: true + + '@esbuild/openbsd-arm64@0.27.7': + optional: true + + '@esbuild/openbsd-x64@0.25.12': + optional: true + + '@esbuild/openbsd-x64@0.27.0': + optional: true - '@changesets/types@4.1.0': {} + '@esbuild/openbsd-x64@0.27.3': + optional: true - '@changesets/types@6.1.0': {} + '@esbuild/openbsd-x64@0.27.7': + optional: true - '@changesets/write@0.4.0': - dependencies: - '@changesets/types': 6.1.0 - fs-extra: 7.0.1 - human-id: 4.1.3 - prettier: 2.8.8 + '@esbuild/openharmony-arm64@0.25.12': + optional: true - '@esbuild/aix-ppc64@0.25.12': + '@esbuild/openharmony-arm64@0.27.0': optional: true - '@esbuild/aix-ppc64@0.27.7': + '@esbuild/openharmony-arm64@0.27.3': optional: true - '@esbuild/android-arm64@0.25.12': + '@esbuild/openharmony-arm64@0.27.7': optional: true - '@esbuild/android-arm64@0.27.7': + '@esbuild/sunos-x64@0.25.12': optional: true - '@esbuild/android-arm@0.25.12': + '@esbuild/sunos-x64@0.27.0': optional: true - '@esbuild/android-arm@0.27.7': + '@esbuild/sunos-x64@0.27.3': optional: true - '@esbuild/android-x64@0.25.12': + '@esbuild/sunos-x64@0.27.7': optional: true - '@esbuild/android-x64@0.27.7': + '@esbuild/win32-arm64@0.25.12': optional: true - '@esbuild/darwin-arm64@0.25.12': + '@esbuild/win32-arm64@0.27.0': optional: true - '@esbuild/darwin-arm64@0.27.7': + '@esbuild/win32-arm64@0.27.3': optional: true - '@esbuild/darwin-x64@0.25.12': + '@esbuild/win32-arm64@0.27.7': optional: true - '@esbuild/darwin-x64@0.27.7': + '@esbuild/win32-ia32@0.25.12': optional: true - '@esbuild/freebsd-arm64@0.25.12': + '@esbuild/win32-ia32@0.27.0': optional: true - '@esbuild/freebsd-arm64@0.27.7': + '@esbuild/win32-ia32@0.27.3': optional: true - '@esbuild/freebsd-x64@0.25.12': + '@esbuild/win32-ia32@0.27.7': optional: true - '@esbuild/freebsd-x64@0.27.7': + '@esbuild/win32-x64@0.25.12': optional: true - '@esbuild/linux-arm64@0.25.12': + '@esbuild/win32-x64@0.27.0': optional: true - '@esbuild/linux-arm64@0.27.7': + '@esbuild/win32-x64@0.27.3': optional: true - '@esbuild/linux-arm@0.25.12': + '@esbuild/win32-x64@0.27.7': optional: true - '@esbuild/linux-arm@0.27.7': + '@eslint-community/eslint-utils@4.9.1(eslint@10.3.0(jiti@2.7.0))': + dependencies: + eslint: 10.3.0(jiti@2.7.0) + eslint-visitor-keys: 3.4.3 + + '@eslint-community/regexpp@4.12.2': {} + + '@eslint/config-array@0.23.5': + dependencies: + '@eslint/object-schema': 3.0.5 + debug: 4.4.3 + minimatch: 10.2.5 + transitivePeerDependencies: + - supports-color + + '@eslint/config-helpers@0.5.5': + dependencies: + '@eslint/core': 1.2.1 + + '@eslint/core@1.2.1': + dependencies: + '@types/json-schema': 7.0.15 + + '@eslint/js@10.0.1(eslint@10.3.0(jiti@2.7.0))': + optionalDependencies: + eslint: 10.3.0(jiti@2.7.0) + + '@eslint/object-schema@3.0.5': {} + + '@eslint/plugin-kit@0.7.1': + dependencies: + '@eslint/core': 1.2.1 + levn: 0.4.1 + + '@floating-ui/core@1.7.5': + dependencies: + '@floating-ui/utils': 0.2.11 + + '@floating-ui/dom@1.7.6': + dependencies: + '@floating-ui/core': 1.7.5 + '@floating-ui/utils': 0.2.11 + + '@floating-ui/react-dom@2.1.8(react-dom@19.2.1(react@19.2.1))(react@19.2.1)': + dependencies: + '@floating-ui/dom': 1.7.6 + react: 19.2.1 + react-dom: 19.2.1(react@19.2.1) + + '@floating-ui/react@0.27.19(react-dom@19.2.1(react@19.2.1))(react@19.2.1)': + dependencies: + '@floating-ui/react-dom': 2.1.8(react-dom@19.2.1(react@19.2.1))(react@19.2.1) + '@floating-ui/utils': 0.2.11 + react: 19.2.1 + react-dom: 19.2.1(react@19.2.1) + tabbable: 6.4.0 + + '@floating-ui/utils@0.2.11': {} + + '@fontsource-variable/geist@5.2.8': {} + + '@humanfs/core@0.19.2': + dependencies: + '@humanfs/types': 0.15.0 + + '@humanfs/node@0.16.8': + dependencies: + '@humanfs/core': 0.19.2 + '@humanfs/types': 0.15.0 + '@humanwhocodes/retry': 0.4.3 + + '@humanfs/types@0.15.0': {} + + '@humanwhocodes/module-importer@1.0.1': {} + + '@humanwhocodes/retry@0.4.3': {} + + '@img/colour@1.1.0': {} + + '@img/sharp-darwin-arm64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.0.4 optional: true - '@esbuild/linux-ia32@0.25.12': + '@img/sharp-darwin-arm64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.2.4 optional: true - '@esbuild/linux-ia32@0.27.7': + '@img/sharp-darwin-x64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.0.4 optional: true - '@esbuild/linux-loong64@0.25.12': + '@img/sharp-darwin-x64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.2.4 optional: true - '@esbuild/linux-loong64@0.27.7': + '@img/sharp-libvips-darwin-arm64@1.0.4': optional: true - '@esbuild/linux-mips64el@0.25.12': + '@img/sharp-libvips-darwin-arm64@1.2.4': optional: true - '@esbuild/linux-mips64el@0.27.7': + '@img/sharp-libvips-darwin-x64@1.0.4': optional: true - '@esbuild/linux-ppc64@0.25.12': + '@img/sharp-libvips-darwin-x64@1.2.4': optional: true - '@esbuild/linux-ppc64@0.27.7': + '@img/sharp-libvips-linux-arm64@1.0.4': optional: true - '@esbuild/linux-riscv64@0.25.12': + '@img/sharp-libvips-linux-arm64@1.2.4': optional: true - '@esbuild/linux-riscv64@0.27.7': + '@img/sharp-libvips-linux-arm@1.0.5': optional: true - '@esbuild/linux-s390x@0.25.12': + '@img/sharp-libvips-linux-arm@1.2.4': optional: true - '@esbuild/linux-s390x@0.27.7': + '@img/sharp-libvips-linux-ppc64@1.2.4': optional: true - '@esbuild/linux-x64@0.25.12': + '@img/sharp-libvips-linux-riscv64@1.2.4': optional: true - '@esbuild/linux-x64@0.27.7': + '@img/sharp-libvips-linux-s390x@1.0.4': optional: true - '@esbuild/netbsd-arm64@0.25.12': + '@img/sharp-libvips-linux-s390x@1.2.4': optional: true - '@esbuild/netbsd-arm64@0.27.7': + '@img/sharp-libvips-linux-x64@1.0.4': optional: true - '@esbuild/netbsd-x64@0.25.12': + '@img/sharp-libvips-linux-x64@1.2.4': optional: true - '@esbuild/netbsd-x64@0.27.7': + '@img/sharp-libvips-linuxmusl-arm64@1.0.4': optional: true - '@esbuild/openbsd-arm64@0.25.12': + '@img/sharp-libvips-linuxmusl-arm64@1.2.4': optional: true - '@esbuild/openbsd-arm64@0.27.7': + '@img/sharp-libvips-linuxmusl-x64@1.0.4': optional: true - '@esbuild/openbsd-x64@0.25.12': + '@img/sharp-libvips-linuxmusl-x64@1.2.4': optional: true - '@esbuild/openbsd-x64@0.27.7': + '@img/sharp-linux-arm64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.0.4 optional: true - '@esbuild/openharmony-arm64@0.25.12': + '@img/sharp-linux-arm64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.2.4 optional: true - '@esbuild/openharmony-arm64@0.27.7': + '@img/sharp-linux-arm@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.0.5 optional: true - '@esbuild/sunos-x64@0.25.12': + '@img/sharp-linux-arm@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.2.4 optional: true - '@esbuild/sunos-x64@0.27.7': + '@img/sharp-linux-ppc64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linux-ppc64': 1.2.4 optional: true - '@esbuild/win32-arm64@0.25.12': + '@img/sharp-linux-riscv64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linux-riscv64': 1.2.4 optional: true - '@esbuild/win32-arm64@0.27.7': + '@img/sharp-linux-s390x@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.0.4 optional: true - '@esbuild/win32-ia32@0.25.12': + '@img/sharp-linux-s390x@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.2.4 optional: true - '@esbuild/win32-ia32@0.27.7': + '@img/sharp-linux-x64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.0.4 optional: true - '@esbuild/win32-x64@0.25.12': + '@img/sharp-linux-x64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.2.4 optional: true - '@esbuild/win32-x64@0.27.7': + '@img/sharp-linuxmusl-arm64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.0.4 optional: true - '@floating-ui/core@1.7.5': - dependencies: - '@floating-ui/utils': 0.2.11 + '@img/sharp-linuxmusl-arm64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.2.4 + optional: true - '@floating-ui/dom@1.7.6': - dependencies: - '@floating-ui/core': 1.7.5 - '@floating-ui/utils': 0.2.11 + '@img/sharp-linuxmusl-x64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.0.4 + optional: true - '@floating-ui/react-dom@2.1.8(react-dom@19.2.1(react@19.2.1))(react@19.2.1)': + '@img/sharp-linuxmusl-x64@0.34.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.2.4 + optional: true + + '@img/sharp-wasm32@0.33.5': dependencies: - '@floating-ui/dom': 1.7.6 - react: 19.2.1 - react-dom: 19.2.1(react@19.2.1) + '@emnapi/runtime': 1.10.0 + optional: true - '@floating-ui/react@0.27.19(react-dom@19.2.1(react@19.2.1))(react@19.2.1)': + '@img/sharp-wasm32@0.34.5': dependencies: - '@floating-ui/react-dom': 2.1.8(react-dom@19.2.1(react@19.2.1))(react@19.2.1) - '@floating-ui/utils': 0.2.11 - react: 19.2.1 - react-dom: 19.2.1(react@19.2.1) - tabbable: 6.4.0 + '@emnapi/runtime': 1.10.0 + optional: true - '@floating-ui/utils@0.2.11': {} + '@img/sharp-win32-arm64@0.34.5': + optional: true - '@fontsource-variable/geist@5.2.8': {} + '@img/sharp-win32-ia32@0.33.5': + optional: true + + '@img/sharp-win32-ia32@0.34.5': + optional: true + + '@img/sharp-win32-x64@0.33.5': + optional: true + + '@img/sharp-win32-x64@0.34.5': + optional: true '@inquirer/ansi@2.0.5': optional: true @@ -3702,6 +5736,11 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.5 + '@legendapp/list@3.0.0-beta.54(react-dom@19.2.1(react@19.2.1))(react@19.2.1)': dependencies: react: 19.2.1 @@ -3977,6 +6016,18 @@ snapshots: '@parcel/watcher-win32-ia32': 2.5.6 '@parcel/watcher-win32-x64': 2.5.6 + '@poppinss/colors@4.1.6': + dependencies: + kleur: 4.1.5 + + '@poppinss/dumper@0.6.5': + dependencies: + '@poppinss/colors': 4.1.6 + '@sindresorhus/is': 7.2.0 + supports-color: 10.2.2 + + '@poppinss/exception@1.2.3': {} + '@preact/signals-core@1.14.2': {} '@publint/pack@0.1.4': {} @@ -4744,6 +6795,8 @@ snapshots: '@radix-ui/rect@1.1.1': {} + '@rolldown/pluginutils@1.0.0-rc.3': {} + '@rollup/rollup-android-arm-eabi@4.60.3': optional: true @@ -4819,6 +6872,10 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.60.3': optional: true + '@sindresorhus/is@7.2.0': {} + + '@speed-highlight/core@1.2.15': {} + '@standard-schema/spec@1.1.0': {} '@tailwindcss/cli@4.3.0': @@ -4899,6 +6956,27 @@ snapshots: tailwindcss: 4.3.0 vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + '@types/babel__core@7.20.5': + dependencies: + '@babel/parser': 7.29.3 + '@babel/types': 7.29.0 + '@types/babel__generator': 7.27.0 + '@types/babel__template': 7.4.4 + '@types/babel__traverse': 7.28.0 + + '@types/babel__generator@7.27.0': + dependencies: + '@babel/types': 7.29.0 + + '@types/babel__template@7.4.4': + dependencies: + '@babel/parser': 7.29.3 + '@babel/types': 7.29.0 + + '@types/babel__traverse@7.28.0': + dependencies: + '@babel/types': 7.29.0 + '@types/chai@5.2.3': dependencies: '@types/deep-eql': 4.0.2 @@ -4910,6 +6988,8 @@ snapshots: '@types/deep-eql@4.0.2': {} + '@types/esrecurse@4.3.1': {} + '@types/estree-jsx@1.0.5': dependencies: '@types/estree': 1.0.9 @@ -4922,6 +7002,8 @@ snapshots: dependencies: '@types/unist': 3.0.3 + '@types/json-schema@7.0.15': {} + '@types/mdast@4.0.4': dependencies: '@types/unist': 3.0.3 @@ -4960,8 +7042,119 @@ snapshots: dependencies: '@types/node': 24.12.3 + '@typescript-eslint/eslint-plugin@8.59.3(@typescript-eslint/parser@8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3))(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3)': + dependencies: + '@eslint-community/regexpp': 4.12.2 + '@typescript-eslint/parser': 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + '@typescript-eslint/scope-manager': 8.59.3 + '@typescript-eslint/type-utils': 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + '@typescript-eslint/utils': 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.59.3 + eslint: 10.3.0(jiti@2.7.0) + ignore: 7.0.5 + natural-compare: 1.4.0 + ts-api-utils: 2.5.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/parser@8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3)': + dependencies: + '@typescript-eslint/scope-manager': 8.59.3 + '@typescript-eslint/types': 8.59.3 + '@typescript-eslint/typescript-estree': 8.59.3(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.59.3 + debug: 4.4.3 + eslint: 10.3.0(jiti@2.7.0) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/project-service@8.59.3(typescript@5.8.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.59.3(typescript@5.8.3) + '@typescript-eslint/types': 8.59.3 + debug: 4.4.3 + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/scope-manager@8.59.3': + dependencies: + '@typescript-eslint/types': 8.59.3 + '@typescript-eslint/visitor-keys': 8.59.3 + + '@typescript-eslint/tsconfig-utils@8.59.3(typescript@5.8.3)': + dependencies: + typescript: 5.8.3 + + '@typescript-eslint/type-utils@8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3)': + dependencies: + '@typescript-eslint/types': 8.59.3 + '@typescript-eslint/typescript-estree': 8.59.3(typescript@5.8.3) + '@typescript-eslint/utils': 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + debug: 4.4.3 + eslint: 10.3.0(jiti@2.7.0) + ts-api-utils: 2.5.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/types@8.59.3': {} + + '@typescript-eslint/typescript-estree@8.59.3(typescript@5.8.3)': + dependencies: + '@typescript-eslint/project-service': 8.59.3(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.59.3(typescript@5.8.3) + '@typescript-eslint/types': 8.59.3 + '@typescript-eslint/visitor-keys': 8.59.3 + debug: 4.4.3 + minimatch: 10.2.5 + semver: 7.8.0 + tinyglobby: 0.2.16 + ts-api-utils: 2.5.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3)': + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@10.3.0(jiti@2.7.0)) + '@typescript-eslint/scope-manager': 8.59.3 + '@typescript-eslint/types': 8.59.3 + '@typescript-eslint/typescript-estree': 8.59.3(typescript@5.8.3) + eslint: 10.3.0(jiti@2.7.0) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/visitor-keys@8.59.3': + dependencies: + '@typescript-eslint/types': 8.59.3 + eslint-visitor-keys: 5.0.1 + '@ungap/structured-clone@1.3.1': {} + '@vitejs/plugin-react@5.2.0(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0))': + dependencies: + '@babel/core': 7.29.0 + '@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/core@7.29.0) + '@babel/plugin-transform-react-jsx-source': 7.27.1(@babel/core@7.29.0) + '@rolldown/pluginutils': 1.0.0-rc.3 + '@types/babel__core': 7.20.5 + react-refresh: 0.18.0 + vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + transitivePeerDependencies: + - supports-color + + '@vitest/expect@3.2.4': + dependencies: + '@types/chai': 5.2.3 + '@vitest/spy': 3.2.4 + '@vitest/utils': 3.2.4 + chai: 5.3.3 + tinyrainbow: 2.0.0 + '@vitest/expect@4.1.6': dependencies: '@standard-schema/spec': 1.1.0 @@ -4971,6 +7164,15 @@ snapshots: chai: 6.2.2 tinyrainbow: 3.1.0 + '@vitest/mocker@3.2.4(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3))(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0))': + dependencies: + '@vitest/spy': 3.2.4 + estree-walker: 3.0.3 + magic-string: 0.30.21 + optionalDependencies: + msw: 2.14.6(@types/node@24.12.3)(typescript@5.8.3) + vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + '@vitest/mocker@4.1.6(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3))(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0))': dependencies: '@vitest/spy': 4.1.6 @@ -4980,15 +7182,31 @@ snapshots: msw: 2.14.6(@types/node@24.12.3)(typescript@5.8.3) vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + '@vitest/pretty-format@3.2.4': + dependencies: + tinyrainbow: 2.0.0 + '@vitest/pretty-format@4.1.6': dependencies: tinyrainbow: 3.1.0 + '@vitest/runner@3.2.4': + dependencies: + '@vitest/utils': 3.2.4 + pathe: 2.0.3 + strip-literal: 3.1.0 + '@vitest/runner@4.1.6': dependencies: '@vitest/utils': 4.1.6 pathe: 2.0.3 + '@vitest/snapshot@3.2.4': + dependencies: + '@vitest/pretty-format': 3.2.4 + magic-string: 0.30.21 + pathe: 2.0.3 + '@vitest/snapshot@4.1.6': dependencies: '@vitest/pretty-format': 4.1.6 @@ -4996,16 +7214,41 @@ snapshots: magic-string: 0.30.21 pathe: 2.0.3 + '@vitest/spy@3.2.4': + dependencies: + tinyspy: 4.0.4 + '@vitest/spy@4.1.6': {} + '@vitest/utils@3.2.4': + dependencies: + '@vitest/pretty-format': 3.2.4 + loupe: 3.2.1 + tinyrainbow: 2.0.0 + '@vitest/utils@4.1.6': dependencies: '@vitest/pretty-format': 4.1.6 convert-source-map: 2.0.0 tinyrainbow: 3.1.0 + acorn-jsx@5.3.2(acorn@8.16.0): + dependencies: + acorn: 8.16.0 + + acorn-walk@8.3.2: {} + + acorn@8.14.0: {} + acorn@8.16.0: {} + ajv@6.15.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + ansi-colors@4.1.3: {} ansi-regex@5.0.1: {} @@ -5033,14 +7276,34 @@ snapshots: bail@2.0.2: {} + balanced-match@4.0.4: {} + + baseline-browser-mapping@2.10.29: {} + better-path-resolve@1.0.0: dependencies: is-windows: 1.0.2 + birpc@0.2.14: {} + + blake3-wasm@2.1.5: {} + + brace-expansion@5.0.6: + dependencies: + balanced-match: 4.0.4 + braces@3.0.3: dependencies: fill-range: 7.1.1 + browserslist@4.28.2: + dependencies: + baseline-browser-mapping: 2.10.29 + caniuse-lite: 1.0.30001792 + electron-to-chromium: 1.5.353 + node-releases: 2.0.44 + update-browserslist-db: 1.2.3(browserslist@4.28.2) + bundle-require@5.1.0(esbuild@0.27.7): dependencies: esbuild: 0.27.7 @@ -5048,8 +7311,18 @@ snapshots: cac@6.7.14: {} + caniuse-lite@1.0.30001792: {} + ccount@2.0.1: {} + chai@5.3.3: + dependencies: + assertion-error: 2.0.1 + check-error: 2.1.3 + deep-eql: 5.0.2 + loupe: 3.2.1 + pathval: 2.0.1 + chai@6.2.2: {} character-entities-html4@2.1.0: {} @@ -5062,10 +7335,14 @@ snapshots: chardet@2.1.1: {} + check-error@2.1.3: {} + chokidar@4.0.3: dependencies: readdirp: 4.1.2 + cjs-module-lexer@1.4.3: {} + class-variance-authority@0.7.1: dependencies: clsx: 2.1.1 @@ -5097,10 +7374,18 @@ snapshots: color-convert@2.0.1: dependencies: color-name: 1.1.4 - optional: true - color-name@1.1.4: - optional: true + color-name@1.1.4: {} + + color-string@1.9.1: + dependencies: + color-name: 1.1.4 + simple-swizzle: 0.2.4 + + color@4.2.3: + dependencies: + color-convert: 2.0.1 + color-string: 1.9.1 comma-separated-tokens@2.0.3: {} @@ -5112,8 +7397,7 @@ snapshots: convert-source-map@2.0.0: {} - cookie@1.1.1: - optional: true + cookie@1.1.1: {} cross-spawn@7.0.6: dependencies: @@ -5133,6 +7417,10 @@ snapshots: dependencies: character-entities: 2.0.2 + deep-eql@5.0.2: {} + + deep-is@0.1.4: {} + dequal@2.0.3: {} detect-indent@6.1.0: {} @@ -5141,6 +7429,8 @@ snapshots: detect-node-es@1.1.0: {} + devalue@5.8.0: {} + devlop@1.1.0: dependencies: dequal: 2.0.3 @@ -5151,6 +7441,8 @@ snapshots: dotenv@8.6.0: {} + electron-to-chromium@1.5.353: {} + emoji-regex@8.0.0: optional: true @@ -5164,6 +7456,10 @@ snapshots: ansi-colors: 4.1.3 strip-ansi: 6.0.1 + error-stack-parser-es@1.0.5: {} + + es-module-lexer@1.7.0: {} + es-module-lexer@2.1.0: {} esbuild@0.25.12: @@ -5195,6 +7491,64 @@ snapshots: '@esbuild/win32-ia32': 0.25.12 '@esbuild/win32-x64': 0.25.12 + esbuild@0.27.0: + optionalDependencies: + '@esbuild/aix-ppc64': 0.27.0 + '@esbuild/android-arm': 0.27.0 + '@esbuild/android-arm64': 0.27.0 + '@esbuild/android-x64': 0.27.0 + '@esbuild/darwin-arm64': 0.27.0 + '@esbuild/darwin-x64': 0.27.0 + '@esbuild/freebsd-arm64': 0.27.0 + '@esbuild/freebsd-x64': 0.27.0 + '@esbuild/linux-arm': 0.27.0 + '@esbuild/linux-arm64': 0.27.0 + '@esbuild/linux-ia32': 0.27.0 + '@esbuild/linux-loong64': 0.27.0 + '@esbuild/linux-mips64el': 0.27.0 + '@esbuild/linux-ppc64': 0.27.0 + '@esbuild/linux-riscv64': 0.27.0 + '@esbuild/linux-s390x': 0.27.0 + '@esbuild/linux-x64': 0.27.0 + '@esbuild/netbsd-arm64': 0.27.0 + '@esbuild/netbsd-x64': 0.27.0 + '@esbuild/openbsd-arm64': 0.27.0 + '@esbuild/openbsd-x64': 0.27.0 + '@esbuild/openharmony-arm64': 0.27.0 + '@esbuild/sunos-x64': 0.27.0 + '@esbuild/win32-arm64': 0.27.0 + '@esbuild/win32-ia32': 0.27.0 + '@esbuild/win32-x64': 0.27.0 + + esbuild@0.27.3: + optionalDependencies: + '@esbuild/aix-ppc64': 0.27.3 + '@esbuild/android-arm': 0.27.3 + '@esbuild/android-arm64': 0.27.3 + '@esbuild/android-x64': 0.27.3 + '@esbuild/darwin-arm64': 0.27.3 + '@esbuild/darwin-x64': 0.27.3 + '@esbuild/freebsd-arm64': 0.27.3 + '@esbuild/freebsd-x64': 0.27.3 + '@esbuild/linux-arm': 0.27.3 + '@esbuild/linux-arm64': 0.27.3 + '@esbuild/linux-ia32': 0.27.3 + '@esbuild/linux-loong64': 0.27.3 + '@esbuild/linux-mips64el': 0.27.3 + '@esbuild/linux-ppc64': 0.27.3 + '@esbuild/linux-riscv64': 0.27.3 + '@esbuild/linux-s390x': 0.27.3 + '@esbuild/linux-x64': 0.27.3 + '@esbuild/netbsd-arm64': 0.27.3 + '@esbuild/netbsd-x64': 0.27.3 + '@esbuild/openbsd-arm64': 0.27.3 + '@esbuild/openbsd-x64': 0.27.3 + '@esbuild/openharmony-arm64': 0.27.3 + '@esbuild/sunos-x64': 0.27.3 + '@esbuild/win32-arm64': 0.27.3 + '@esbuild/win32-ia32': 0.27.3 + '@esbuild/win32-x64': 0.27.3 + esbuild@0.27.7: optionalDependencies: '@esbuild/aix-ppc64': 0.27.7 @@ -5224,25 +7578,107 @@ snapshots: '@esbuild/win32-ia32': 0.27.7 '@esbuild/win32-x64': 0.27.7 - escalade@3.2.0: - optional: true + escalade@3.2.0: {} + + escape-string-regexp@4.0.0: {} escape-string-regexp@5.0.0: {} + eslint-plugin-react-hooks@7.1.1(eslint@10.3.0(jiti@2.7.0)): + dependencies: + '@babel/core': 7.29.0 + '@babel/parser': 7.29.3 + eslint: 10.3.0(jiti@2.7.0) + hermes-parser: 0.25.1 + zod: 4.4.3 + zod-validation-error: 4.0.2(zod@4.4.3) + transitivePeerDependencies: + - supports-color + + eslint-scope@9.1.2: + dependencies: + '@types/esrecurse': 4.3.1 + '@types/estree': 1.0.9 + esrecurse: 4.3.0 + estraverse: 5.3.0 + + eslint-visitor-keys@3.4.3: {} + + eslint-visitor-keys@5.0.1: {} + + eslint@10.3.0(jiti@2.7.0): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@10.3.0(jiti@2.7.0)) + '@eslint-community/regexpp': 4.12.2 + '@eslint/config-array': 0.23.5 + '@eslint/config-helpers': 0.5.5 + '@eslint/core': 1.2.1 + '@eslint/plugin-kit': 0.7.1 + '@humanfs/node': 0.16.8 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.4.3 + '@types/estree': 1.0.9 + ajv: 6.15.0 + cross-spawn: 7.0.6 + debug: 4.4.3 + escape-string-regexp: 4.0.0 + eslint-scope: 9.1.2 + eslint-visitor-keys: 5.0.1 + espree: 11.2.0 + esquery: 1.7.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 8.0.0 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + minimatch: 10.2.5 + natural-compare: 1.4.0 + optionator: 0.9.4 + optionalDependencies: + jiti: 2.7.0 + transitivePeerDependencies: + - supports-color + + espree@11.2.0: + dependencies: + acorn: 8.16.0 + acorn-jsx: 5.3.2(acorn@8.16.0) + eslint-visitor-keys: 5.0.1 + esprima@4.0.1: {} + esquery@1.7.0: + dependencies: + estraverse: 5.3.0 + + esrecurse@4.3.0: + dependencies: + estraverse: 5.3.0 + + estraverse@5.3.0: {} + estree-util-is-identifier-name@3.0.0: {} estree-walker@3.0.3: dependencies: '@types/estree': 1.0.9 + esutils@2.0.3: {} + + exit-hook@2.2.1: {} + expect-type@1.3.0: {} extend@3.0.2: {} extendable-error@0.1.7: {} + fast-deep-equal@3.1.3: {} + fast-glob@3.3.3: dependencies: '@nodelib/fs.stat': 2.0.5 @@ -5251,6 +7687,10 @@ snapshots: merge2: 1.4.1 micromatch: 4.0.8 + fast-json-stable-stringify@2.1.0: {} + + fast-levenshtein@2.0.6: {} + fast-string-truncated-width@3.0.3: optional: true @@ -5272,6 +7712,10 @@ snapshots: optionalDependencies: picomatch: 4.0.4 + file-entry-cache@8.0.0: + dependencies: + flat-cache: 4.0.1 + fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 @@ -5281,12 +7725,24 @@ snapshots: locate-path: 5.0.0 path-exists: 4.0.0 + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + fix-dts-default-cjs-exports@1.0.1: dependencies: magic-string: 0.30.21 mlly: 1.8.2 rollup: 4.60.3 + flat-cache@4.0.1: + dependencies: + flatted: 3.4.2 + keyv: 4.5.4 + + flatted@3.4.2: {} + fs-extra@7.0.1: dependencies: graceful-fs: 4.2.11 @@ -5302,6 +7758,8 @@ snapshots: fsevents@2.3.3: optional: true + gensync@1.0.0-beta.2: {} + get-caller-file@2.0.5: optional: true @@ -5311,6 +7769,14 @@ snapshots: dependencies: is-glob: 4.0.3 + glob-parent@6.0.2: + dependencies: + is-glob: 4.0.3 + + glob-to-regexp@0.4.1: {} + + globals@17.6.0: {} + globby@11.1.0: dependencies: array-union: 2.1.0 @@ -5355,6 +7821,12 @@ snapshots: set-cookie-parser: 3.1.0 optional: true + hermes-estree@0.25.1: {} + + hermes-parser@0.25.1: + dependencies: + hermes-estree: 0.25.1 + html-url-attributes@3.0.1: {} human-id@4.1.3: {} @@ -5365,6 +7837,10 @@ snapshots: ignore@5.3.2: {} + ignore@7.0.5: {} + + imurmurhash@0.1.4: {} + inline-style-parser@0.2.7: {} is-alphabetical@2.0.1: {} @@ -5374,6 +7850,8 @@ snapshots: is-alphabetical: 2.0.1 is-decimal: 2.0.1 + is-arrayish@0.3.4: {} + is-decimal@2.0.1: {} is-extglob@2.1.1: {} @@ -5408,6 +7886,10 @@ snapshots: joycon@3.1.1: {} + js-tokens@4.0.0: {} + + js-tokens@9.0.1: {} + js-yaml@3.14.2: dependencies: argparse: 1.0.10 @@ -5417,10 +7899,31 @@ snapshots: dependencies: argparse: 2.0.1 + jsesc@3.1.0: {} + + json-buffer@3.0.1: {} + + json-schema-traverse@0.4.1: {} + + json-stable-stringify-without-jsonify@1.0.1: {} + + json5@2.2.3: {} + jsonfile@4.0.0: optionalDependencies: graceful-fs: 4.2.11 + keyv@4.5.4: + dependencies: + json-buffer: 3.0.1 + + kleur@4.1.5: {} + + levn@0.4.1: + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + lexical@0.44.0: {} lib0@0.2.117: @@ -5486,10 +7989,20 @@ snapshots: dependencies: p-locate: 4.1.0 + locate-path@6.0.0: + dependencies: + p-locate: 5.0.0 + lodash.startcase@4.4.0: {} longest-streak@3.1.0: {} + loupe@3.2.1: {} + + lru-cache@5.1.1: + dependencies: + yallist: 3.1.1 + lucide-react@1.14.0(react@19.2.1): dependencies: react: 19.2.1 @@ -5851,6 +8364,42 @@ snapshots: braces: 3.0.3 picomatch: 2.3.2 + mime@3.0.0: {} + + miniflare@4.20251210.0: + dependencies: + '@cspotcode/source-map-support': 0.8.1 + acorn: 8.14.0 + acorn-walk: 8.3.2 + exit-hook: 2.2.1 + glob-to-regexp: 0.4.1 + sharp: 0.33.5 + stoppable: 1.1.0 + undici: 7.14.0 + workerd: 1.20251210.0 + ws: 8.18.0 + youch: 4.1.0-beta.10 + zod: 3.22.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + miniflare@4.20260508.0: + dependencies: + '@cspotcode/source-map-support': 0.8.1 + sharp: 0.34.5 + undici: 7.24.8 + workerd: 1.20260508.1 + ws: 8.18.0 + youch: 4.1.0-beta.10 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + minimatch@10.2.5: + dependencies: + brace-expansion: 5.0.6 + mlly@1.8.2: dependencies: acorn: 8.16.0 @@ -5899,16 +8448,29 @@ snapshots: nanoid@3.3.12: {} + natural-compare@1.4.0: {} + node-addon-api@7.1.1: {} node-fetch@2.7.0: dependencies: whatwg-url: 5.0.0 + node-releases@2.0.44: {} + object-assign@4.1.1: {} obug@2.1.1: {} + optionator@0.9.4: + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.5 + outdent@0.5.0: {} outvariant@1.4.3: @@ -5922,10 +8484,18 @@ snapshots: dependencies: p-try: 2.2.0 + p-limit@3.1.0: + dependencies: + yocto-queue: 0.1.0 + p-locate@4.1.0: dependencies: p-limit: 2.3.0 + p-locate@5.0.0: + dependencies: + p-limit: 3.1.0 + p-map@2.1.0: {} p-try@2.2.0: {} @@ -5950,13 +8520,14 @@ snapshots: path-key@3.1.1: {} - path-to-regexp@6.3.0: - optional: true + path-to-regexp@6.3.0: {} path-type@4.0.0: {} pathe@2.0.3: {} + pathval@2.0.1: {} + picocolors@1.1.1: {} picomatch@2.3.2: {} @@ -5986,6 +8557,8 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + prelude-ls@1.2.1: {} + prettier@2.8.8: {} prettier@3.8.3: {} @@ -5999,6 +8572,8 @@ snapshots: picocolors: 1.1.1 sade: 1.8.1 + punycode@2.3.1: {} + quansync@0.2.11: {} queue-microtask@1.2.3: {} @@ -6093,6 +8668,8 @@ snapshots: transitivePeerDependencies: - supports-color + react-refresh@0.18.0: {} + react-remove-scroll-bar@2.3.8(@types/react@19.2.7)(react@19.2.1): dependencies: react: 19.2.1 @@ -6218,11 +8795,70 @@ snapshots: scheduler@0.27.0: {} + semver@6.3.1: {} + semver@7.8.0: {} set-cookie-parser@3.1.0: optional: true + sharp@0.33.5: + dependencies: + color: 4.2.3 + detect-libc: 2.1.2 + semver: 7.8.0 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.33.5 + '@img/sharp-darwin-x64': 0.33.5 + '@img/sharp-libvips-darwin-arm64': 1.0.4 + '@img/sharp-libvips-darwin-x64': 1.0.4 + '@img/sharp-libvips-linux-arm': 1.0.5 + '@img/sharp-libvips-linux-arm64': 1.0.4 + '@img/sharp-libvips-linux-s390x': 1.0.4 + '@img/sharp-libvips-linux-x64': 1.0.4 + '@img/sharp-libvips-linuxmusl-arm64': 1.0.4 + '@img/sharp-libvips-linuxmusl-x64': 1.0.4 + '@img/sharp-linux-arm': 0.33.5 + '@img/sharp-linux-arm64': 0.33.5 + '@img/sharp-linux-s390x': 0.33.5 + '@img/sharp-linux-x64': 0.33.5 + '@img/sharp-linuxmusl-arm64': 0.33.5 + '@img/sharp-linuxmusl-x64': 0.33.5 + '@img/sharp-wasm32': 0.33.5 + '@img/sharp-win32-ia32': 0.33.5 + '@img/sharp-win32-x64': 0.33.5 + + sharp@0.34.5: + dependencies: + '@img/colour': 1.1.0 + detect-libc: 2.1.2 + semver: 7.8.0 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.34.5 + '@img/sharp-darwin-x64': 0.34.5 + '@img/sharp-libvips-darwin-arm64': 1.2.4 + '@img/sharp-libvips-darwin-x64': 1.2.4 + '@img/sharp-libvips-linux-arm': 1.2.4 + '@img/sharp-libvips-linux-arm64': 1.2.4 + '@img/sharp-libvips-linux-ppc64': 1.2.4 + '@img/sharp-libvips-linux-riscv64': 1.2.4 + '@img/sharp-libvips-linux-s390x': 1.2.4 + '@img/sharp-libvips-linux-x64': 1.2.4 + '@img/sharp-libvips-linuxmusl-arm64': 1.2.4 + '@img/sharp-libvips-linuxmusl-x64': 1.2.4 + '@img/sharp-linux-arm': 0.34.5 + '@img/sharp-linux-arm64': 0.34.5 + '@img/sharp-linux-ppc64': 0.34.5 + '@img/sharp-linux-riscv64': 0.34.5 + '@img/sharp-linux-s390x': 0.34.5 + '@img/sharp-linux-x64': 0.34.5 + '@img/sharp-linuxmusl-arm64': 0.34.5 + '@img/sharp-linuxmusl-x64': 0.34.5 + '@img/sharp-wasm32': 0.34.5 + '@img/sharp-win32-arm64': 0.34.5 + '@img/sharp-win32-ia32': 0.34.5 + '@img/sharp-win32-x64': 0.34.5 + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 @@ -6233,6 +8869,10 @@ snapshots: signal-exit@4.1.0: {} + simple-swizzle@0.2.4: + dependencies: + is-arrayish: 0.3.4 + slash@3.0.0: {} smol-toml@1.6.1: {} @@ -6255,8 +8895,12 @@ snapshots: statuses@2.0.2: optional: true + std-env@3.10.0: {} + std-env@4.1.0: {} + stoppable@1.1.0: {} + strict-event-emitter@0.5.1: optional: true @@ -6278,6 +8922,10 @@ snapshots: strip-bom@3.0.0: {} + strip-literal@3.1.0: + dependencies: + js-tokens: 9.0.1 + style-to-js@1.1.21: dependencies: style-to-object: 1.0.14 @@ -6296,6 +8944,8 @@ snapshots: tinyglobby: 0.2.16 ts-interface-checker: 0.1.13 + supports-color@10.2.2: {} + tabbable@6.4.0: {} tagged-tag@1.0.0: @@ -6328,8 +8978,14 @@ snapshots: fdir: 6.5.0(picomatch@4.0.4) picomatch: 4.0.4 + tinypool@1.1.1: {} + + tinyrainbow@2.0.0: {} + tinyrainbow@3.1.0: {} + tinyspy@4.0.4: {} + tldts-core@7.0.30: optional: true @@ -6355,6 +9011,10 @@ snapshots: trough@2.2.0: {} + ts-api-utils@2.5.0(typescript@5.8.3): + dependencies: + typescript: 5.8.3 + ts-interface-checker@0.1.13: {} tslib@2.8.1: {} @@ -6389,17 +9049,40 @@ snapshots: tw-animate-css@1.4.0: {} + type-check@0.4.0: + dependencies: + prelude-ls: 1.2.1 + type-fest@5.6.0: dependencies: tagged-tag: 1.0.0 optional: true + typescript-eslint@8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3): + dependencies: + '@typescript-eslint/eslint-plugin': 8.59.3(@typescript-eslint/parser@8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3))(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + '@typescript-eslint/parser': 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.59.3(typescript@5.8.3) + '@typescript-eslint/utils': 8.59.3(eslint@10.3.0(jiti@2.7.0))(typescript@5.8.3) + eslint: 10.3.0(jiti@2.7.0) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + typescript@5.8.3: {} ufo@1.6.4: {} undici-types@7.16.0: {} + undici@7.14.0: {} + + undici@7.24.8: {} + + unenv@2.0.0-rc.24: + dependencies: + pathe: 2.0.3 + unified@11.0.5: dependencies: '@types/unist': 3.0.3 @@ -6438,6 +9121,16 @@ snapshots: until-async@3.0.2: optional: true + update-browserslist-db@1.2.3(browserslist@4.28.2): + dependencies: + browserslist: 4.28.2 + escalade: 3.2.0 + picocolors: 1.1.1 + + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 + use-callback-ref@1.3.3(@types/react@19.2.7)(react@19.2.1): dependencies: react: 19.2.1 @@ -6467,6 +9160,27 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 + vite-node@3.2.4(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0): + dependencies: + cac: 6.7.14 + debug: 4.4.3 + es-module-lexer: 1.7.0 + pathe: 2.0.3 + vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + transitivePeerDependencies: + - '@types/node' + - jiti + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0): dependencies: esbuild: 0.25.12 @@ -6481,6 +9195,48 @@ snapshots: jiti: 2.7.0 lightningcss: 1.32.0 + vitest@3.2.4(@types/debug@4.1.13)(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3)): + dependencies: + '@types/chai': 5.2.3 + '@vitest/expect': 3.2.4 + '@vitest/mocker': 3.2.4(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3))(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)) + '@vitest/pretty-format': 3.2.4 + '@vitest/runner': 3.2.4 + '@vitest/snapshot': 3.2.4 + '@vitest/spy': 3.2.4 + '@vitest/utils': 3.2.4 + chai: 5.3.3 + debug: 4.4.3 + expect-type: 1.3.0 + magic-string: 0.30.21 + pathe: 2.0.3 + picomatch: 4.0.4 + std-env: 3.10.0 + tinybench: 2.9.0 + tinyexec: 0.3.2 + tinyglobby: 0.2.16 + tinypool: 1.1.1 + tinyrainbow: 2.0.0 + vite: 6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + vite-node: 3.2.4(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/debug': 4.1.13 + '@types/node': 24.12.3 + transitivePeerDependencies: + - jiti + - less + - lightningcss + - msw + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + vitest@4.1.6(@types/node@24.12.3)(msw@2.14.6(@types/node@24.12.3)(typescript@5.8.3))(vite@6.4.2(@types/node@24.12.3)(jiti@2.7.0)(lightningcss@1.32.0)): dependencies: '@vitest/expect': 4.1.6 @@ -6524,6 +9280,56 @@ snapshots: siginfo: 2.0.0 stackback: 0.0.2 + word-wrap@1.2.5: {} + + workerd@1.20251210.0: + optionalDependencies: + '@cloudflare/workerd-darwin-64': 1.20251210.0 + '@cloudflare/workerd-darwin-arm64': 1.20251210.0 + '@cloudflare/workerd-linux-64': 1.20251210.0 + '@cloudflare/workerd-linux-arm64': 1.20251210.0 + '@cloudflare/workerd-windows-64': 1.20251210.0 + + workerd@1.20260508.1: + optionalDependencies: + '@cloudflare/workerd-darwin-64': 1.20260508.1 + '@cloudflare/workerd-darwin-arm64': 1.20260508.1 + '@cloudflare/workerd-linux-64': 1.20260508.1 + '@cloudflare/workerd-linux-arm64': 1.20260508.1 + '@cloudflare/workerd-windows-64': 1.20260508.1 + + wrangler@4.54.0: + dependencies: + '@cloudflare/kv-asset-handler': 0.4.1 + '@cloudflare/unenv-preset': 2.7.13(unenv@2.0.0-rc.24)(workerd@1.20251210.0) + blake3-wasm: 2.1.5 + esbuild: 0.27.0 + miniflare: 4.20251210.0 + path-to-regexp: 6.3.0 + unenv: 2.0.0-rc.24 + workerd: 1.20251210.0 + optionalDependencies: + fsevents: 2.3.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + wrangler@4.90.1: + dependencies: + '@cloudflare/kv-asset-handler': 0.5.0 + '@cloudflare/unenv-preset': 2.16.1(unenv@2.0.0-rc.24)(workerd@1.20260508.1) + blake3-wasm: 2.1.5 + esbuild: 0.27.3 + miniflare: 4.20260508.0 + path-to-regexp: 6.3.0 + unenv: 2.0.0-rc.24 + workerd: 1.20260508.1 + optionalDependencies: + fsevents: 2.3.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + wrap-ansi@7.0.0: dependencies: ansi-styles: 4.3.0 @@ -6531,11 +9337,15 @@ snapshots: strip-ansi: 6.0.1 optional: true + ws@8.18.0: {} + ws@8.20.0: {} y18n@5.0.8: optional: true + yallist@3.1.1: {} + yargs-parser@21.1.1: optional: true @@ -6554,6 +9364,31 @@ snapshots: dependencies: lib0: 0.2.117 + yocto-queue@0.1.0: {} + + youch-core@0.3.3: + dependencies: + '@poppinss/exception': 1.2.3 + error-stack-parser-es: 1.0.5 + + youch@4.1.0-beta.10: + dependencies: + '@poppinss/colors': 4.1.6 + '@poppinss/dumper': 0.6.5 + '@speed-highlight/core': 1.2.15 + cookie: 1.1.1 + youch-core: 0.3.3 + + zod-validation-error@4.0.2(zod@4.4.3): + dependencies: + zod: 4.4.3 + + zod@3.22.3: {} + + zod@3.25.76: {} + + zod@4.4.3: {} + zustand@5.0.13(@types/react@19.2.7)(react@19.2.1)(use-sync-external-store@1.6.0(react@19.2.1)): optionalDependencies: '@types/react': 19.2.7 diff --git a/tests/package.test.ts b/tests/package.test.ts index d7a9823..43582ac 100644 --- a/tests/package.test.ts +++ b/tests/package.test.ts @@ -404,20 +404,26 @@ function writeServerConsumer(directory: string, coreTarballPath: string): void { writeFileSync( join(directory, "index.ts"), [ - 'import { InMemoryThreadStore, serializeJsonRpcResponse } from "@jrkropp/codex-js/server";', - 'import type { ThreadStore } from "@jrkropp/codex-js/server";', + 'import { InMemoryThreadStore, createCodexAppServer, defineDynamicTool, dynamicToolResponse, serializeJsonRpcResponse } from "@jrkropp/codex-js/server";', + 'import type { PendingServerRequestStore, ThreadStore } from "@jrkropp/codex-js/server";', "const store: ThreadStore = new InMemoryThreadStore();", + "const pending: PendingServerRequestStore = { delete() {}, get() { return null; }, list() { return []; }, put() {}, take() { return null; } };", + "const tool = defineDynamicTool({ name: 'ping', description: 'Ping.', inputSchema: { type: 'object' }, execute() { return dynamicToolResponse.text('pong'); } });", + "const appServer = createCodexAppServer({ threadStore: store, pendingServerRequests: pending, dynamicTools: [tool], createModelClient() { throw new Error('not used'); } });", "serializeJsonRpcResponse(1, { ok: true });", - "void store;", + "void appServer;", ].join("\n"), ); writeFileSync( join(directory, "index.mjs"), [ - 'import { InMemoryThreadStore, serializeJsonRpcResponse } from "@jrkropp/codex-js/server";', + 'import { InMemoryThreadStore, createCodexAppServer, defineDynamicTool, dynamicToolResponse, serializeJsonRpcResponse } from "@jrkropp/codex-js/server";', "const store = new InMemoryThreadStore();", + "const tool = defineDynamicTool({ name: 'ping', description: 'Ping.', inputSchema: { type: 'object' }, execute() { return dynamicToolResponse.text('pong'); } });", + "const appServer = createCodexAppServer({ threadStore: store, dynamicTools: [tool], createModelClient() { throw new Error('not used'); } });", "if (typeof serializeJsonRpcResponse(1, {}) !== 'string') throw new Error('bad transport export');", "if (!store) throw new Error('bad store export');", + "if (!appServer.pendingServerRequests) throw new Error('bad app-server export');", ].join("\n"), ); } diff --git a/tests/server-helpers.test.ts b/tests/server-helpers.test.ts new file mode 100644 index 0000000..a720061 --- /dev/null +++ b/tests/server-helpers.test.ts @@ -0,0 +1,135 @@ +import { describe, expect, it } from "vitest"; +import { CodexAppServerConnectionSessionState } from "../packages/codex-js/src/runtime/index"; +import { + defineDynamicTool, + defineDynamicToolset, + dynamicToolResponse, + dynamicToolSpecFromDefinition, +} from "../packages/codex-js/src/server/dynamic-tools"; + +describe("dynamic tool helpers", () => { + it("maps public camelCase definitions to Codex dynamic tool specs", () => { + const tool = defineDynamicTool({ + namespace: "billing", + name: "lookup_invoice", + description: "Look up an invoice.", + deferLoading: true, + inputSchema: { + type: "object", + properties: { invoiceId: { type: "string" } }, + required: ["invoiceId"], + additionalProperties: false, + }, + }); + + expect(dynamicToolSpecFromDefinition(tool)).toEqual({ + namespace: "billing", + name: "lookup_invoice", + description: "Look up an invoice.", + defer_loading: true, + input_schema: { + type: "object", + properties: { invoiceId: { type: "string" } }, + required: ["invoiceId"], + additionalProperties: false, + }, + }); + }); + + it("uses Codex-compatible response shapes", () => { + expect(dynamicToolResponse.text("ok")).toEqual({ + contentItems: [{ text: "ok", type: "inputText" }], + success: true, + }); + expect(dynamicToolResponse.image("https://example.com/image.png")).toEqual({ + contentItems: [ + { imageUrl: "https://example.com/image.png", type: "inputImage" }, + ], + success: true, + }); + expect(dynamicToolResponse.error("failed")).toEqual({ + contentItems: [{ text: "failed", type: "inputText" }], + success: false, + }); + }); + + it("rejects invalid names, deferred tools without namespaces, and duplicates", () => { + const schema = { type: "object", properties: {} }; + + expect(() => + defineDynamicTool({ + name: "bad name", + description: "Invalid.", + inputSchema: schema, + }), + ).toThrow(/Responses API/u); + + expect(() => + defineDynamicTool({ + name: "deferred_tool", + description: "Invalid.", + deferLoading: true, + inputSchema: schema, + }), + ).toThrow(/namespace/u); + + expect(() => + defineDynamicToolset([ + { + namespace: "billing", + name: "lookup_invoice", + description: "First.", + inputSchema: schema, + }, + { + namespace: "billing", + name: "lookup_invoice", + description: "Duplicate.", + inputSchema: schema, + }, + ]), + ).toThrow(/Duplicate dynamic tool/u); + }); + + it("rejects unsupported JSON schema shapes early", () => { + expect(() => + defineDynamicTool({ + name: "bad_schema", + description: "Invalid.", + inputSchema: { type: "string" }, + }), + ).toThrow(/type "object"/u); + + expect(() => + defineDynamicTool({ + name: "bad_required", + description: "Invalid.", + inputSchema: { type: "object", required: "id" }, + }), + ).toThrow(/required/u); + }); +}); + +describe("connection session snapshots", () => { + it("restores initialized app-server connection state without reinitializing", () => { + const session = new CodexAppServerConnectionSessionState(); + session.initialize({ + appServerClientName: "test-client", + clientVersion: "1.2.3", + experimentalApiEnabled: true, + optedOutNotificationMethods: new Set(["thread/event"]), + }); + + const restored = CodexAppServerConnectionSessionState.fromSnapshot( + session.snapshot(), + ); + + expect(restored.initialized()).toBe(true); + expect(restored.appServerClientName()).toBe("test-client"); + expect(restored.clientVersion()).toBe("1.2.3"); + expect(restored.experimentalApiEnabled()).toBe(true); + expect(Array.from(restored.optedOutNotificationMethods())).toEqual([ + "thread/event", + ]); + }); +});