@oh-my-pi/pi-ai 15.1.1 → 15.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -0
- package/README.md +3 -6
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +46 -0
- package/dist/types/auth-broker/index.d.ts +5 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +71 -0
- package/dist/types/auth-broker/server.d.ts +26 -0
- package/dist/types/auth-broker/types.d.ts +69 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +264 -0
- package/dist/types/auth-gateway/http.d.ts +39 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +17 -0
- package/dist/types/auth-gateway/types.d.ts +115 -0
- package/dist/types/auth-storage.d.ts +522 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/model-cache.d.ts +17 -0
- package/dist/types/model-manager.d.ts +62 -0
- package/dist/types/model-thinking.d.ts +71 -0
- package/dist/types/models.d.ts +12 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/provider-models/bundled-references.d.ts +4 -0
- package/dist/types/provider-models/descriptors.d.ts +48 -0
- package/dist/types/provider-models/google.d.ts +19 -0
- package/dist/types/provider-models/index.d.ts +5 -0
- package/dist/types/provider-models/ollama.d.ts +7 -0
- package/dist/types/provider-models/openai-compat.d.ts +225 -0
- package/dist/types/provider-models/special.d.ts +16 -0
- package/dist/types/providers/amazon-bedrock.d.ts +22 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +450 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic.d.ts +169 -0
- package/dist/types/providers/aws-credentials.d.ts +32 -0
- package/dist/types/providers/aws-eventstream.d.ts +38 -0
- package/dist/types/providers/aws-sigv4.d.ts +55 -0
- package/dist/types/providers/azure-openai-responses.d.ts +15 -0
- package/dist/types/providers/cursor/gen/agent_pb.d.ts +13022 -0
- package/dist/types/providers/cursor.d.ts +36 -0
- package/dist/types/providers/error-message.d.ts +27 -0
- package/dist/types/providers/github-copilot-headers.d.ts +40 -0
- package/dist/types/providers/gitlab-duo.d.ts +27 -0
- package/dist/types/providers/google-auth.d.ts +24 -0
- package/dist/types/providers/google-gemini-cli.d.ts +72 -0
- package/dist/types/providers/google-gemini-headers.d.ts +18 -0
- package/dist/types/providers/google-shared.d.ts +163 -0
- package/dist/types/providers/google-types.d.ts +138 -0
- package/dist/types/providers/google-vertex.d.ts +7 -0
- package/dist/types/providers/google.d.ts +4 -0
- package/dist/types/providers/grammar.d.ts +1 -0
- package/dist/types/providers/kimi.d.ts +27 -0
- package/dist/types/providers/mock.d.ts +175 -0
- package/dist/types/providers/ollama.d.ts +6 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +814 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-codex/constants.d.ts +26 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +49 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +17 -0
- package/dist/types/providers/openai-codex-responses.d.ts +67 -0
- package/dist/types/providers/openai-completions-compat.d.ts +25 -0
- package/dist/types/providers/openai-completions.d.ts +33 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +392 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-shared.d.ts +65 -0
- package/dist/types/providers/openai-responses.d.ts +32 -0
- package/dist/types/providers/pi-native-client.d.ts +13 -0
- package/dist/types/providers/pi-native-server.d.ts +68 -0
- package/dist/types/providers/register-builtins.d.ts +31 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +12 -0
- package/dist/types/providers/vision-guard.d.ts +8 -0
- package/dist/types/rate-limit-utils.d.ts +19 -0
- package/dist/types/stream.d.ts +24 -0
- package/dist/types/types.d.ts +706 -0
- package/dist/types/usage/claude.d.ts +3 -0
- package/dist/types/usage/gemini.d.ts +2 -0
- package/dist/types/usage/github-copilot.d.ts +7 -0
- package/dist/types/usage/google-antigravity.d.ts +2 -0
- package/dist/types/usage/kimi.d.ts +2 -0
- package/dist/types/usage/minimax-code.d.ts +2 -0
- package/dist/types/usage/openai-codex.d.ts +3 -0
- package/dist/types/usage/shared.d.ts +1 -0
- package/dist/types/usage/zai.d.ts +2 -0
- package/dist/types/usage.d.ts +258 -0
- package/dist/types/utils/abort.d.ts +19 -0
- package/dist/types/utils/anthropic-auth.d.ts +44 -0
- package/dist/types/utils/discovery/antigravity.d.ts +61 -0
- package/dist/types/utils/discovery/codex.d.ts +38 -0
- package/dist/types/utils/discovery/cursor.d.ts +23 -0
- package/dist/types/utils/discovery/gemini.d.ts +25 -0
- package/dist/types/utils/discovery/index.d.ts +4 -0
- package/dist/types/utils/discovery/openai-compatible.d.ts +72 -0
- package/dist/types/utils/event-stream.d.ts +28 -0
- package/dist/types/utils/fireworks-model-id.d.ts +2 -0
- package/dist/types/utils/foundry.d.ts +1 -0
- package/dist/types/utils/h2-fetch.d.ts +22 -0
- package/dist/types/utils/http-inspector.d.ts +31 -0
- package/dist/types/utils/idle-iterator.d.ts +58 -0
- package/dist/types/utils/json-parse.d.ts +10 -0
- package/dist/types/utils/oauth/alibaba-coding-plan.d.ts +18 -0
- package/dist/types/utils/oauth/anthropic.d.ts +22 -0
- package/dist/types/utils/oauth/api-key-login.d.ts +35 -0
- package/dist/types/utils/oauth/api-key-validation.d.ts +27 -0
- package/dist/types/utils/oauth/callback-server.d.ts +57 -0
- package/dist/types/utils/oauth/cerebras.d.ts +1 -0
- package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +18 -0
- package/dist/types/utils/oauth/cursor.d.ts +15 -0
- package/dist/types/utils/oauth/fireworks.d.ts +1 -0
- package/dist/types/utils/oauth/github-copilot.d.ts +38 -0
- package/dist/types/utils/oauth/gitlab-duo.d.ts +3 -0
- package/dist/types/utils/oauth/google-antigravity.d.ts +11 -0
- package/dist/types/utils/oauth/google-gemini-cli.d.ts +10 -0
- package/dist/types/utils/oauth/google-oauth-shared.d.ts +28 -0
- package/dist/types/utils/oauth/huggingface.d.ts +19 -0
- package/dist/types/utils/oauth/index.d.ts +35 -0
- package/dist/types/utils/oauth/kagi.d.ts +17 -0
- package/dist/types/utils/oauth/kilo.d.ts +5 -0
- package/dist/types/utils/oauth/kimi.d.ts +21 -0
- package/dist/types/utils/oauth/litellm.d.ts +18 -0
- package/dist/types/utils/oauth/lm-studio.d.ts +17 -0
- package/dist/types/utils/oauth/minimax-code.d.ts +28 -0
- package/dist/types/utils/oauth/moonshot.d.ts +1 -0
- package/dist/types/utils/oauth/nanogpt.d.ts +1 -0
- package/dist/types/utils/oauth/nvidia.d.ts +18 -0
- package/dist/types/utils/oauth/ollama-cloud.d.ts +2 -0
- package/dist/types/utils/oauth/ollama.d.ts +18 -0
- package/dist/types/utils/oauth/openai-codex.d.ts +14 -0
- package/dist/types/utils/oauth/opencode.d.ts +18 -0
- package/dist/types/utils/oauth/parallel.d.ts +17 -0
- package/dist/types/utils/oauth/perplexity.d.ts +9 -0
- package/dist/types/utils/oauth/pkce.d.ts +8 -0
- package/dist/types/utils/oauth/qianfan.d.ts +17 -0
- package/dist/types/utils/oauth/qwen-portal.d.ts +19 -0
- package/dist/types/utils/oauth/synthetic.d.ts +1 -0
- package/dist/types/utils/oauth/tavily.d.ts +17 -0
- package/dist/types/utils/oauth/together.d.ts +1 -0
- package/dist/types/utils/oauth/types.d.ts +44 -0
- package/dist/types/utils/oauth/venice.d.ts +18 -0
- package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +18 -0
- package/dist/types/utils/oauth/vllm.d.ts +16 -0
- package/dist/types/utils/oauth/xiaomi.d.ts +19 -0
- package/dist/types/utils/oauth/zai.d.ts +18 -0
- package/dist/types/utils/oauth/zenmux.d.ts +1 -0
- package/dist/types/utils/overflow.d.ts +54 -0
- package/dist/types/utils/parse-bind.d.ts +23 -0
- package/dist/types/utils/provider-response.d.ts +3 -0
- package/dist/types/utils/retry-after.d.ts +3 -0
- package/dist/types/utils/retry.d.ts +26 -0
- package/dist/types/utils/schema/adapt.d.ts +24 -0
- package/dist/types/utils/schema/compatibility.d.ts +30 -0
- package/dist/types/utils/schema/dereference.d.ts +11 -0
- package/dist/types/utils/schema/draft.d.ts +10 -0
- package/dist/types/utils/schema/equality.d.ts +4 -0
- package/dist/types/utils/schema/fields.d.ts +49 -0
- package/dist/types/utils/schema/index.d.ts +12 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +12 -0
- package/dist/types/utils/schema/meta-validator.d.ts +2 -0
- package/dist/types/utils/schema/normalize.d.ts +92 -0
- package/dist/types/utils/schema/spill.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +25 -0
- package/dist/types/utils/schema/types.d.ts +2 -0
- package/dist/types/utils/schema/wire.d.ts +24 -0
- package/dist/types/utils/sse-debug.d.ts +10 -0
- package/dist/types/utils/tool-call-healing.d.ts +71 -0
- package/dist/types/utils/tool-choice.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +17 -0
- package/dist/types/utils.d.ts +28 -0
- package/package.json +37 -26
- package/src/auth-broker/client.ts +261 -0
- package/src/auth-broker/index.ts +5 -0
- package/src/auth-broker/refresher.ts +127 -0
- package/src/auth-broker/remote-store.ts +409 -0
- package/src/auth-broker/server.ts +454 -0
- package/src/auth-broker/types.ts +84 -0
- package/src/auth-broker/wire-schemas.ts +162 -0
- package/src/auth-gateway/http.ts +194 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +651 -0
- package/src/auth-gateway/types.ts +134 -0
- package/src/auth-storage.ts +819 -57
- package/src/cli.ts +4 -4
- package/src/index.ts +10 -0
- package/src/model-cache.ts +22 -4
- package/src/model-manager.ts +128 -27
- package/src/model-thinking.ts +27 -10
- package/src/provider-details.ts +9 -0
- package/src/provider-models/special.ts +6 -45
- package/src/providers/amazon-bedrock.ts +278 -254
- package/src/providers/anthropic-messages-server-schema.ts +229 -0
- package/src/providers/anthropic-messages-server.ts +677 -0
- package/src/providers/anthropic.ts +202 -39
- package/src/providers/aws-credentials.ts +334 -0
- package/src/providers/aws-eventstream.ts +185 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.ts +2 -3
- package/src/providers/cursor.ts +1 -2
- package/src/providers/{shared/error-message.ts → error-message.ts} +1 -1
- package/src/providers/gitlab-duo.ts +1 -1
- package/src/providers/google-auth.ts +252 -0
- package/src/providers/google-gemini-cli.ts +3 -3
- package/src/providers/google-shared.ts +138 -42
- package/src/providers/google-types.ts +167 -0
- package/src/providers/google-vertex.ts +33 -54
- package/src/providers/google.ts +23 -31
- package/src/providers/mock.ts +110 -79
- package/src/providers/openai-anthropic-shim.ts +1 -1
- package/src/providers/openai-chat-server-schema.ts +243 -0
- package/src/providers/openai-chat-server.ts +628 -0
- package/src/providers/openai-completions.ts +7 -0
- package/src/providers/openai-responses-server-schema.ts +290 -0
- package/src/providers/openai-responses-server.ts +1183 -0
- package/src/providers/openai-responses.ts +6 -0
- package/src/providers/pi-native-client.ts +228 -0
- package/src/providers/pi-native-server.ts +210 -0
- package/src/stream.ts +67 -3
- package/src/types.ts +36 -0
- package/src/usage/claude.ts +130 -36
- package/src/usage/openai-codex.ts +132 -6
- package/src/usage.ts +54 -1
- package/src/utils/anthropic-auth.ts +9 -7
- package/src/utils/discovery/index.ts +0 -1
- package/src/utils/oauth/github-copilot.ts +10 -2
- package/src/utils/parse-bind.ts +54 -0
- package/src/utils/retry.ts +3 -2
- package/src/utils/schema/CONSTRAINTS.md +23 -20
- package/src/utils/schema/adapt.ts +20 -53
- package/src/utils/schema/compatibility.ts +70 -15
- package/src/utils/schema/dereference.ts +11 -6
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.ts +18 -14
- package/src/utils/schema/fields.ts +151 -116
- package/src/utils/schema/index.ts +3 -3
- package/src/utils/schema/json-schema-validator.ts +64 -51
- package/src/utils/schema/meta-validator.ts +41 -45
- package/src/utils/schema/normalize.ts +1494 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.ts +97 -0
- package/src/utils/schema/wire.ts +24 -20
- package/src/utils/sse-debug.ts +239 -20
- package/src/utils/validation.ts +34 -10
- package/src/utils/schema/normalize-cca.ts +0 -457
- package/src/utils/schema/sanitize-google.ts +0 -212
- package/src/utils/schema/strict-mode.ts +0 -408
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,116 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [15.1.3] - 2026-05-17
|
|
6
|
+
### Breaking Changes
|
|
7
|
+
|
|
8
|
+
- Changed `AuthBrokerClient.fetchSnapshot()` to return status-based results (`200` or `304`) instead of always returning a raw snapshot body, so callers now need to branch on `status`
|
|
9
|
+
- Renamed public schema utilities in `@oh-my-pi/pi-ai/utils/schema` by replacing `sanitizeSchemaForGoogle`, `sanitizeSchemaForCCA`, `prepareSchemaForCCA`, and `sanitizeSchemaForMCP` with `normalizeSchemaForGoogle`, `normalizeSchemaForCCA`, and `normalizeSchemaForMCP`
|
|
10
|
+
- Added MCP schema normalization via `normalizeSchemaForMCP` for compatibility checks
|
|
11
|
+
- Removed the `StringEnum` helper from `@oh-my-pi/pi-ai/utils/schema`. Use `z.enum([...])` directly; Zod's emitted JSON Schema is already wire-compatible with Google and other providers.
|
|
12
|
+
- Renamed the concrete SQLite credential store class from `AuthCredentialStore` to `SqliteAuthCredentialStore`. `AuthCredentialStore` is now the persistence interface implemented by both the SQLite store and the new `RemoteAuthCredentialStore`. Update `new AuthCredentialStore(db)` / `AuthCredentialStore.open(...)` call-sites to `SqliteAuthCredentialStore`; type-position uses (`store: AuthCredentialStore`) continue to work unchanged.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Added `onAuthError` to `StreamOptions` and wired `streamSimple()` to retry once with a replacement API key when the first provider response is a 401 before any assistant events are emitted
|
|
17
|
+
- Added generation-aware snapshot metadata (`generation`, `serverNowMs`, `refresher`, and `rotatesInMs`) to auth-broker snapshot responses to support client-side credential-rotation planning
|
|
18
|
+
- Added `transport: "pi-native"` on `Model` and the matching `streamPiNative` client. When `model.transport === "pi-native"`, `streamSimple` short-circuits the per-provider dispatch and POSTs the canonical `Context` to the auth-gateway's `POST /v1/pi/stream` endpoint. The response is SSE-framed `AssistantMessageEvent`s parsed by `readSseJson` and pushed verbatim into the local `AssistantMessageEventStream` — no wire-format translation, no partial-stripping reconstruction. Used by containerized omp installs (robomp slots, swarm extension, etc.) to route every LLM call through a credential-holding sidecar; the slot itself never sees the real provider tokens. Server-controlled fields (`apiKey`, `signal`, `fetch`, lifecycle callbacks, the provider-session map) are stripped from the wire body — `apiKey` rides in the `Authorization` header as the gateway bearer.
|
|
19
|
+
- Added `POST /v1/pi/stream` to the auth-gateway. Same auth + abort + model-resolution + codex-compat + prefix-cache plumbing as the foreign-wire routes; only the wire-format translation is skipped. Request body is `{ modelId, context, options?, stream? }` where `context` is the canonical pi-ai `Context` and `options` is `SimpleStreamOptions` with non-serializable fields stripped. Response is SSE-framed `AssistantMessageEvent` (terminated by `data: [DONE]`) when streaming, or `{ message: AssistantMessage }` JSON when `stream: false`.
|
|
20
|
+
- Added Vertex AI authentication via Google Application Default Credentials from `GOOGLE_APPLICATION_CREDENTIALS`, `~/.config/gcloud/application_default_credentials.json`, or metadata server tokens, with token caching and refresh skew control via `GOOGLE_VERTEX_REFRESH_SKEW_MS`
|
|
21
|
+
- Added support for Anthropic image message parts with `type: "url"` and `type: "file"` sources
|
|
22
|
+
- Added `stopSequences` and `frequencyPenalty` to shared stream options and wired them through to OpenAI request translation
|
|
23
|
+
- Added optional request cancellation support to auth-broker interactions by propagating `AbortSignal` into health, snapshot, usage, and refresh calls
|
|
24
|
+
- Added `AuthStorage.setConfigApiKey` / `removeConfigApiKey` / `clearConfigApiKeys` for config-sourced per-provider bearers (e.g. `models.yml` `providers.<name>.apiKey`). The new tier sits between runtime `--api-key` and stored credentials in `getApiKey`/`peekApiKey` resolution, so a bearer pinned in config now beats the broker's OAuth access token. Also suppresses OAuth `account_uuid` attribution when active, since outbound auth is the explicit config bearer, not OAuth. `describeCredentialSource` reports `"config override (models.yml)"` for visibility.
|
|
25
|
+
- Added per-model `additional_rate_limits` parsing to `openaiCodexUsageProvider`. The Codex `wham/usage` endpoint surfaces a separate `GPT-5.3-Codex-Spark` rate limit (`metered_feature: codex_bengalfox`) on Pro accounts; these now emit dedicated `openai-codex:spark:{primary,secondary}` `UsageLimit` entries with `scope.tier = "spark"`, mirroring how Anthropic exposes `anthropic:7d:sonnet` separately from the umbrella `anthropic:7d` bucket. The osx-widgets client already keyed spark detection off `limit.id.includes("spark")`; this populates that contract end-to-end.
|
|
26
|
+
- Added `GET /v1/usage` to the auth-broker API to expose aggregated usage reports from `AuthStorage.fetchUsageReports`
|
|
27
|
+
- Added auth-broker usage polling response handling that returns normalized usage reports plus generation timestamp for clients (5-min per-credential cache via `AuthStorage`)
|
|
28
|
+
- Added the auth-broker subsystem (`@oh-my-pi/pi-ai/auth-broker`) for sharing OAuth credentials across machines without leaking refresh tokens.
|
|
29
|
+
- `startAuthBroker(...)` boots a `Bun.serve` HTTP server exposing `GET /v1/healthz`, `GET /v1/snapshot`, `POST /v1/credential` (upsert), `POST /v1/credential/:id/refresh`, and `POST /v1/credential/:id/disable`.
|
|
30
|
+
- `AuthBrokerClient` is the matching HTTP client used by remote clients.
|
|
31
|
+
- `RemoteAuthCredentialStore` is a client-side `AuthCredentialStore` that mirrors a broker snapshot in memory; mutating methods (`replace*`, `upsert*`, `delete*ForProvider`) throw because writes are server-side only.
|
|
32
|
+
- `AuthBrokerRefresher` is the background refresh loop that pre-refreshes credentials within `refreshSkewMs` and disables on definitive failure (`invalid_grant` / non-network 401-403).
|
|
33
|
+
- Added `AuthStorage.exportSnapshot()`, `AuthStorage.upsertCredential(provider, credential)`, `AuthStorage.forceRefreshCredentialById(id)`, and `AuthStorage.disableCredentialById(id, cause)` public methods consumed by the auth-broker server.
|
|
34
|
+
- Added `AuthStorageOptions.refreshOAuthCredential` override so a remote-store client can route every OAuth refresh through the broker instead of the local OAuth endpoint.
|
|
35
|
+
- Added `REMOTE_REFRESH_SENTINEL` (`"__remote__"`) — the wire placeholder substituted for OAuth refresh tokens in broker snapshots; clients never see the real refresh token.
|
|
36
|
+
- Exposed the OAuth provider catalog (`getOAuthProviders`, `OAuthProvider`, `OAuthProviderInfo`) and `refreshOAuthToken` through the package barrel so the coding-agent CLI can target them without reaching into `utils/oauth`.
|
|
37
|
+
- Added the auth-gateway subsystem (`@oh-my-pi/pi-ai/auth-gateway`) — a forward-proxy that sits between unauthenticated clients (the macOS usage widget, llm-git, robomp containers, …) and the broker. Clients send standard provider-format requests; the gateway parses them into omp's canonical `Context`, dispatches through pi-ai's `streamSimple()`, and translates the canonical event stream back to the matching wire format. `Authorization` is injected server-side so access tokens never leave the gateway host. Wire surface:
|
|
38
|
+
- `GET /healthz` — unauth liveness.
|
|
39
|
+
- `GET /v1/usage` — aggregated provider usage; 5-min per-credential cache via `AuthStorage.fetchUsageReports`.
|
|
40
|
+
- `GET /v1/models` — model catalog (scoped to providers with credentials).
|
|
41
|
+
- `POST /v1/chat/completions` — OpenAI chat-completions in/out.
|
|
42
|
+
- `POST /v1/messages` — Anthropic messages in/out (text + thinking + tool_use blocks, SSE event taxonomy preserved).
|
|
43
|
+
- `POST /v1/responses` — OpenAI Responses in/out (reasoning items + function_call output items, SSE pass-through).
|
|
44
|
+
- Added exports from `@oh-my-pi/pi-ai/auth-gateway`: `startAuthGateway`, `AuthGatewayServerOptions`, `AuthGatewayBootOptions`, `AuthGatewayServerHandle`, `ModelResolver`, `DEFAULT_AUTH_GATEWAY_BIND`. Per-format `parseRequest` / `encodeResponse` / `encodeStream` triples are reachable via the `./providers/*` subpath as `openai-chat-server`, `anthropic-messages-server`, and `openai-responses-server`.
|
|
45
|
+
- Added `listProvidersWithEnvKey()` to enumerate every provider with an env-var fallback (used by the new migrate command in coding-agent).
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Changed `GET /v1/snapshot` to support generation-based polling with `If-None-Match` and `wait` for long-poll updates and to return `304` when no snapshot changes are available
|
|
50
|
+
- Changed Bedrock credential resolution for streaming calls to prefer environment keys, AWS profile/SSO credentials, and IMDSv2 fallback when available
|
|
51
|
+
- Changed auth-gateway parsing for OpenAI chat-completions and Responses to ignore unsupported SDK-only fields instead of rejecting requests
|
|
52
|
+
- Changed auth-gateway protocol handling to include CORS headers on responses and support browser-origin requests
|
|
53
|
+
- Changed prompt-cache handling to resolve cache keys from request metadata and headers and preserve them through protocol translation
|
|
54
|
+
- Changed Anthropic messages parsing to forward request `metadata` through to downstream execution
|
|
55
|
+
- Changed usage report caching to use a 5-minute per-credential TTL with jittered refresh timing to reduce usage endpoint rate-limit collisions
|
|
56
|
+
- Changed usage polling failure handling so transient errors continue serving the last known report instead of returning null and dropping the credential from usage aggregates after cache expiry
|
|
57
|
+
- Changed `sanitizeSchemaForGoogle` to normalize snake_case schema keys (such as `any_of` and `additional_properties`) to camelCase and auto-generate `propertyOrdering` for multi-property objects
|
|
58
|
+
- Changed strict-mode sanitization to resolve `$ref` nodes with sibling keys by inlining and merging referenced local definitions
|
|
59
|
+
- Changed strict-mode sanitization to flatten single-entry `allOf` nodes and remove the `allOf` wrapper
|
|
60
|
+
- Changed Anthropic tool schema normalization to preserve supported metadata keywords such as `$ref`, `$defs`, `$schema`, `enum`, `const`, `default`, `title`, and `nullable` instead of stripping them
|
|
61
|
+
- Changed string schema processing to retain only supported `format` values (`date-time`, `time`, `date`, `duration`, `email`, `hostname`, `uri`, `ipv4`, `ipv6`, `uuid`) and demote unsupported `format` values to `description` hints
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
|
|
65
|
+
- Fixed OAuth credential refresh flow so concurrent manual and background refreshes now share one in-flight attempt per credential, and `RemoteAuthCredentialStore` now re-synchronizes before using near-expiring OAuth credentials
|
|
66
|
+
- Fixed stale-credential handling after auth failures by waiting for updated broker snapshots and refreshing suspect credentials through broker endpoints before continuing
|
|
67
|
+
- Fixed Google Generative AI startup behavior to throw a clear API-key-required error when no key is configured
|
|
68
|
+
- Fixed AWS Bedrock image message serialization to preserve base64 `source.bytes` payloads instead of decoding and rebuilding them
|
|
69
|
+
- Fixed Google provider error handling to extract the API-reported `error.message` from JSON response bodies when available
|
|
70
|
+
- Fixed `RemoteAuthCredentialStore.getUsageReport` to return the matching credential-specific usage report and coalesce parallel callers into one broker `/v1/usage` fetch
|
|
71
|
+
- Fixed auth-broker credential upload validation to reject the remote refresh-token sentinel and prevent storing a non-refresh value
|
|
72
|
+
- Fixed OpenAI Responses streaming output to emit `reasoning_summary_text` events and parse/send `summary_text` reasoning payloads
|
|
73
|
+
- Fixed Anthropic stop-sequence handling by trimming requests to the API limit of four entries before forwarding
|
|
74
|
+
- Fixed prompt caching behavior across protocol translations so cached-token usage is preserved when Anthropic and OpenAI requests are routed through each other
|
|
75
|
+
- Fixed Claude usage fetching to retry transient `429` and `5xx` responses with exponential backoff, respecting `Retry-After` before returning failure
|
|
76
|
+
- Fixed auth-gateway request translation to preserve OpenAI Responses string/system message content, reasoning replay payloads, completed item text in stream item-done events, Anthropic tool-result ordering, and OpenAI Chat/Responses cached-token usage totals
|
|
77
|
+
- Fixed auth-gateway failure handling so unsupported request controls, upstream terminal errors, non-streaming aborts, and already-aborted client requests fail explicitly instead of being accepted, ignored, or encoded as successful HTTP 200 responses
|
|
78
|
+
- Fixed Gemini CLI / Antigravity tool schema normalization to run the full Cloud Code Assist pipeline, matching shared Google schema handling for union/object merging and nullable extraction
|
|
79
|
+
- Fixed stripped validation hints to be preserved as description spill text (`{key: value}` blocks) when `normalizeSchemaForGoogle` and `normalizeSchemaForCCA` drop unsupported schema keywords
|
|
80
|
+
- Fixed `sanitizeSchemaForGoogle` to collapse nullability forms (`type:'null'` and null-bearing `anyOf` variants) into `nullable` while preserving remaining variants
|
|
81
|
+
- Fixed `sanitizeSchemaForGoogle` to inline local `$defs` references instead of dropping `$ref`/`$defs` structure during Google schema sanitization
|
|
82
|
+
- Fixed `normalizeAnthropicToolSchema` to handle self-referential schemas without infinite recursion
|
|
83
|
+
- Fixed object schema normalization so explicit open-map declarations (`additionalProperties: true` and schema-valued `additionalProperties`) are preserved instead of being converted to closed objects
|
|
84
|
+
- Fixed unsupported schema constraints on arrays and strings (`maxItems`, `uniqueItems`, `pattern`, `minLength`, `maxLength`, and `minItems` when greater than 1) by demoting them into `description` rather than dropping them
|
|
85
|
+
|
|
86
|
+
### Security
|
|
87
|
+
|
|
88
|
+
- Hardened auth-gateway bearer-token checks with constant-time comparison to avoid timing-side-channel leaks
|
|
89
|
+
|
|
90
|
+
## [15.1.2] - 2026-05-15
|
|
91
|
+
### Breaking Changes
|
|
92
|
+
|
|
93
|
+
- Rejected draft-07 tuple and dependency keywords (`items` arrays, `dependencies`, `additionalItems`) in JSON Schema validation
|
|
94
|
+
|
|
95
|
+
### Added
|
|
96
|
+
|
|
97
|
+
- Added `responseHeaders`, `responseStatus`, and `responseRequestId` fields to `MockResponse` so mock providers can provide synthetic `ProviderResponseMetadata`
|
|
98
|
+
- Added `onResponse` metadata emission for mocks that sends lowercased headers and a default status of 200 before streaming when response headers are configured
|
|
99
|
+
- Added recursive strict-mode sanitization for array `prefixItems` entries so tuple schemas now enforce object constraints per item
|
|
100
|
+
|
|
101
|
+
### Changed
|
|
102
|
+
|
|
103
|
+
- Normalized legacy draft-07 JSON Schema constructs used in tool parameters (`items` arrays, `additionalItems`, `definitions`, `dependencies`) to draft 2020-12 before OpenAI/Google/CCA sanitization, wire conversion, and argument validation
|
|
104
|
+
- Reworked OpenAI response schema adaptation to rewrite `oneOf` into `anyOf` while preserving existing `anyOf` branches
|
|
105
|
+
- Changed tuple array validation to validate per-index schemas from `prefixItems` and apply `items` only to remaining elements
|
|
106
|
+
|
|
107
|
+
### Fixed
|
|
108
|
+
|
|
109
|
+
- Fixed validation of plain JSON Schema tool arguments that omitted a `$schema` URI so draft-07-shaped schemas now pass validation instead of being rejected
|
|
110
|
+
- Fixed tuple-array validation for legacy JSON Schema tool schemas to enforce `additionalItems: false` and per-position constraints after automatic draft upgrade
|
|
111
|
+
- Fixed Anthropic tool schema normalization to recurse into `prefixItems` so unsupported constraints inside tuple items are stripped in the generated input schema
|
|
112
|
+
- Fixed Anthropic tool-schema normalization stripping the body of explicit open `additionalProperties` (e.g. Zod's `z.record(z.string(), z.unknown())` compiling to `additionalProperties: {}`) by unconditionally overwriting it with `false`, which closed record-style fields and prevented models from supplying any key. The coding-agent's `resolve` tool exposes plan-approval titles via such a field, so Kimi K2 (and any other Anthropic-shaped provider) could not pass `extra: { title }`, blocking plan mode entirely ([#1104](https://github.com/can1357/oh-my-pi/issues/1104))
|
|
113
|
+
- Fixed Anthropic strict tool planning to leave tools with open `additionalProperties` maps non-strict instead of sending schemas Anthropic rejects.
|
|
114
|
+
|
|
5
115
|
## [15.1.0] - 2026-05-15
|
|
6
116
|
|
|
7
117
|
### Breaking Changes
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ npm install @oh-my-pi/pi-ai
|
|
|
89
89
|
## Quick Start
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
|
-
import { z, getModel, stream, complete, Context, Tool
|
|
92
|
+
import { z, getModel, stream, complete, Context, Tool } from "@oh-my-pi/pi-ai";
|
|
93
93
|
|
|
94
94
|
// Fully typed with auto-complete support for both providers and models
|
|
95
95
|
const model = getModel("openai", "gpt-4o-mini");
|
|
@@ -221,7 +221,7 @@ Tools enable LLMs to interact with external systems. This library uses **Zod** s
|
|
|
221
221
|
### Defining Tools
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
|
-
import { z, Tool
|
|
224
|
+
import { z, Tool } from "@oh-my-pi/pi-ai";
|
|
225
225
|
|
|
226
226
|
// Define tool parameters with Zod
|
|
227
227
|
const weatherTool: Tool = {
|
|
@@ -229,13 +229,10 @@ const weatherTool: Tool = {
|
|
|
229
229
|
description: "Get current weather for a location",
|
|
230
230
|
parameters: z.object({
|
|
231
231
|
location: z.string().describe("City name or coordinates"),
|
|
232
|
-
units:
|
|
232
|
+
units: z.enum(["celsius", "fahrenheit"]).default("celsius"),
|
|
233
233
|
}),
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
// Note: For Google API compatibility, use the StringEnum helper instead of z.enum alone
|
|
237
|
-
// when you need wire-compatible { type: "string", enum: [...] } shapes.
|
|
238
|
-
|
|
239
236
|
const bookMeetingTool: Tool = {
|
|
240
237
|
name: "book_meeting",
|
|
241
238
|
description: "Schedule a meeting",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom API provider registry.
|
|
3
|
+
*
|
|
4
|
+
* Allows extensions to register streaming functions for custom API types
|
|
5
|
+
* (e.g., "vertex-claude-api") that are not built into stream.ts.
|
|
6
|
+
*/
|
|
7
|
+
import type { Api, AssistantMessageEventStream, Context, Model, SimpleStreamOptions, StreamOptions } from "./types";
|
|
8
|
+
export type CustomStreamFn = (model: Model<Api>, context: Context, options?: StreamOptions) => AssistantMessageEventStream;
|
|
9
|
+
export type CustomStreamSimpleFn = (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;
|
|
10
|
+
export interface RegisteredCustomApi {
|
|
11
|
+
stream: CustomStreamFn;
|
|
12
|
+
streamSimple: CustomStreamSimpleFn;
|
|
13
|
+
sourceId?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Register a custom API streaming function.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerCustomApi(api: string, streamSimple: CustomStreamSimpleFn, sourceId?: string, stream?: CustomStreamFn): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get a custom API provider by API identifier.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCustomApi(api: string): RegisteredCustomApi | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Remove all custom APIs registered by a specific source (e.g., extension path).
|
|
25
|
+
*/
|
|
26
|
+
export declare function unregisterCustomApis(sourceId: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Clear all custom API registrations.
|
|
29
|
+
*/
|
|
30
|
+
export declare function clearCustomApis(): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AuthCredential } from "../auth-storage";
|
|
2
|
+
import type { CredentialDisableResponse, CredentialRefreshResponse, CredentialUploadResponse, HealthzResponse, SnapshotResponse, UsageResponse } from "./types";
|
|
3
|
+
export interface AuthBrokerClientOptions {
|
|
4
|
+
/** Base URL (e.g. `https://broker.tailnet:8765`). Trailing slashes are trimmed. */
|
|
5
|
+
url: string;
|
|
6
|
+
/** Bearer token used for everything except `healthz`. */
|
|
7
|
+
token: string;
|
|
8
|
+
/** Per-request timeout in milliseconds. Default 10s. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Retry connection errors this many times. Default 1. */
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
/** Override fetch (used in tests). Default global `fetch`. */
|
|
13
|
+
fetchImpl?: typeof fetch;
|
|
14
|
+
}
|
|
15
|
+
export declare class AuthBrokerError extends Error {
|
|
16
|
+
readonly status: number | undefined;
|
|
17
|
+
readonly body: string | undefined;
|
|
18
|
+
constructor(message: string, opts?: {
|
|
19
|
+
status?: number;
|
|
20
|
+
body?: string;
|
|
21
|
+
cause?: unknown;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export interface FetchSnapshotOptions {
|
|
25
|
+
ifGenerationGt?: number;
|
|
26
|
+
waitMs?: number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
export type FetchSnapshotResult = {
|
|
30
|
+
status: 200;
|
|
31
|
+
snapshot: SnapshotResponse;
|
|
32
|
+
generation: number;
|
|
33
|
+
} | {
|
|
34
|
+
status: 304;
|
|
35
|
+
generation: number;
|
|
36
|
+
};
|
|
37
|
+
export declare class AuthBrokerClient {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(opts: AuthBrokerClientOptions);
|
|
40
|
+
healthz(signal?: AbortSignal): Promise<HealthzResponse>;
|
|
41
|
+
fetchSnapshot(opts?: FetchSnapshotOptions): Promise<FetchSnapshotResult>;
|
|
42
|
+
fetchUsage(signal?: AbortSignal): Promise<UsageResponse>;
|
|
43
|
+
refreshCredential(id: number, signal?: AbortSignal): Promise<CredentialRefreshResponse>;
|
|
44
|
+
disableCredential(id: number, cause: string, signal?: AbortSignal): Promise<CredentialDisableResponse>;
|
|
45
|
+
uploadCredential(provider: string, credential: AuthCredential, signal?: AbortSignal): Promise<CredentialUploadResponse>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AuthStorage } from "../auth-storage";
|
|
2
|
+
export interface AuthBrokerRefresherOptions {
|
|
3
|
+
storage: AuthStorage;
|
|
4
|
+
/** Refresh credentials expiring within this window. Default 5 min. */
|
|
5
|
+
refreshSkewMs?: number;
|
|
6
|
+
/** Loop cadence. Default 60s. */
|
|
7
|
+
refreshIntervalMs?: number;
|
|
8
|
+
/** Override clock (tests). */
|
|
9
|
+
now?: () => number;
|
|
10
|
+
}
|
|
11
|
+
export interface AuthBrokerRefresherSchedule {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
intervalMs: number;
|
|
14
|
+
skewMs: number;
|
|
15
|
+
nextSweepAt: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class AuthBrokerRefresher {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(opts: AuthBrokerRefresherOptions);
|
|
20
|
+
start(): void;
|
|
21
|
+
stop(): void;
|
|
22
|
+
getSchedule(): AuthBrokerRefresherSchedule;
|
|
23
|
+
/** Run one sweep. Exposed for tests. */
|
|
24
|
+
tick(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type AuthCredential, type AuthCredentialStore, type OAuthCredential, type StoredAuthCredential } from "../auth-storage";
|
|
2
|
+
import type { Provider } from "../types";
|
|
3
|
+
import type { UsageReport } from "../usage";
|
|
4
|
+
import type { OAuthCredentials } from "../utils/oauth/types";
|
|
5
|
+
import type { AuthBrokerClient } from "./client";
|
|
6
|
+
import type { SnapshotResponse } from "./types";
|
|
7
|
+
export interface RemoteAuthCredentialStoreOptions {
|
|
8
|
+
client: AuthBrokerClient;
|
|
9
|
+
/**
|
|
10
|
+
* Initial snapshot. When omitted, callers must call
|
|
11
|
+
* {@link RemoteAuthCredentialStore.refreshSnapshot} before the first read.
|
|
12
|
+
*/
|
|
13
|
+
initialSnapshot?: SnapshotResponse;
|
|
14
|
+
}
|
|
15
|
+
export declare class RemoteAuthCredentialStore implements AuthCredentialStore {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(opts: RemoteAuthCredentialStoreOptions);
|
|
18
|
+
get client(): AuthBrokerClient;
|
|
19
|
+
get snapshot(): SnapshotResponse;
|
|
20
|
+
/** Re-hydrate the in-memory snapshot from the broker. */
|
|
21
|
+
refreshSnapshot(): Promise<SnapshotResponse>;
|
|
22
|
+
listAuthCredentials(provider?: string): StoredAuthCredential[];
|
|
23
|
+
/**
|
|
24
|
+
* In-memory update from a successful refresh through the broker. AuthStorage
|
|
25
|
+
* calls this after `#replaceCredentialAt`; the broker already persisted the
|
|
26
|
+
* authoritative row, so we just mirror it.
|
|
27
|
+
*/
|
|
28
|
+
updateAuthCredential(id: number, credential: AuthCredential): void;
|
|
29
|
+
deleteAuthCredential(id: number, disabledCause: string): void;
|
|
30
|
+
tryDisableAuthCredentialIfMatches(id: number, _expectedData: string, disabledCause: string): boolean;
|
|
31
|
+
waitForFreshSnapshot(maxWaitMs: number, opts?: {
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}): Promise<boolean>;
|
|
34
|
+
prepareForRequest(credentialId: number, opts?: {
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
}): Promise<boolean>;
|
|
37
|
+
markCredentialSuspect(credentialId: number, opts?: {
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
replaceAuthCredentialsForProvider(_provider: string, _credentials: AuthCredential[]): StoredAuthCredential[];
|
|
41
|
+
upsertAuthCredentialForProvider(_provider: string, _credential: AuthCredential): StoredAuthCredential[];
|
|
42
|
+
deleteAuthCredentialsForProvider(_provider: string, _disabledCause: string): void;
|
|
43
|
+
getCache(key: string): string | null;
|
|
44
|
+
setCache(key: string, value: string, expiresAtSec: number): void;
|
|
45
|
+
cleanExpiredCache(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Store-level hook consumed by `AuthStorage` — routes refresh through the
|
|
48
|
+
* broker so the actual refresh token never leaves the broker host. Returns
|
|
49
|
+
* the broker-redacted credential with {@link REMOTE_REFRESH_SENTINEL} in
|
|
50
|
+
* the `refresh` slot.
|
|
51
|
+
*/
|
|
52
|
+
refreshOAuthCredential(_provider: Provider, credentialId: number, _credential: OAuthCredential, signal?: AbortSignal): Promise<OAuthCredentials>;
|
|
53
|
+
/**
|
|
54
|
+
* Store-level hook consumed by `AuthStorage.fetchUsageReports()` — proxies
|
|
55
|
+
* to the broker's `/v1/usage` endpoint. The broker's egress IP isn't
|
|
56
|
+
* rate-limited by Anthropic's per-IP `/usage` cap the way a heavy
|
|
57
|
+
* residential laptop is, so all credentials surface every cycle.
|
|
58
|
+
*/
|
|
59
|
+
fetchUsageReports(signal?: AbortSignal): Promise<UsageReport[] | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Per-credential usage hook consumed by `AuthStorage.#getUsageReport`. Pulls
|
|
62
|
+
* the aggregate broker `/v1/usage` once and serves all callers from the
|
|
63
|
+
* same response (coalesced + cached), then matches the credential to a
|
|
64
|
+
* report by provider + identity (accountId / email / projectId).
|
|
65
|
+
*
|
|
66
|
+
* The broker already aggregates with its own 30s TTL on the server side; our
|
|
67
|
+
* 15s client TTL is below that so we usually re-use the broker's cache too.
|
|
68
|
+
*/
|
|
69
|
+
getUsageReport(provider: Provider, credential: OAuthCredential, signal?: AbortSignal): Promise<UsageReport | null>;
|
|
70
|
+
close(): void;
|
|
71
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AuthStorage } from "../auth-storage";
|
|
2
|
+
export interface AuthBrokerServerOptions {
|
|
3
|
+
/** Underlying credential storage (wraps the local SQLite store on the broker). */
|
|
4
|
+
storage: AuthStorage;
|
|
5
|
+
/** Listen address; accepts `host:port` or just `port`. */
|
|
6
|
+
bind?: string;
|
|
7
|
+
/** Accept any of these bearer tokens. Empty disables auth (loopback only). */
|
|
8
|
+
bearerTokens: string[];
|
|
9
|
+
/** Broker version string surfaced on `/v1/healthz`. */
|
|
10
|
+
version?: string;
|
|
11
|
+
/** Refresh credentials expiring within this window. Default 5 min. */
|
|
12
|
+
refreshSkewMs?: number;
|
|
13
|
+
/** Background refresh cadence. Default 60s. */
|
|
14
|
+
refreshIntervalMs?: number;
|
|
15
|
+
/** Disable the background refresher (e.g. for tests). */
|
|
16
|
+
disableRefresher?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface AuthBrokerServerHandle {
|
|
19
|
+
/** Bound URL (`http://host:port`). */
|
|
20
|
+
url: string;
|
|
21
|
+
port: number;
|
|
22
|
+
hostname: string;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/** Boot the broker. Caller owns lifecycle; `handle.close()` to stop. */
|
|
26
|
+
export declare function startAuthBroker(opts: AuthBrokerServerOptions): AuthBrokerServerHandle;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types shared between the auth-broker server and clients.
|
|
3
|
+
*
|
|
4
|
+
* The broker holds OAuth refresh tokens and exposes a redacted snapshot;
|
|
5
|
+
* clients use `access` tokens directly and call back to the broker when a
|
|
6
|
+
* credential expires or a 401 surfaces on a supposedly-fresh credential.
|
|
7
|
+
*/
|
|
8
|
+
import type { AuthCredential, AuthCredentialSnapshot, AuthCredentialSnapshotEntry } from "../auth-storage";
|
|
9
|
+
import type { UsageReport } from "../usage";
|
|
10
|
+
/** GET /v1/healthz response body. */
|
|
11
|
+
export interface HealthzResponse {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
version?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RefresherSchedule {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
intervalMs: number;
|
|
18
|
+
skewMs: number;
|
|
19
|
+
nextSweepInMs: number;
|
|
20
|
+
}
|
|
21
|
+
export type SnapshotEntry = AuthCredentialSnapshotEntry & {
|
|
22
|
+
rotatesInMs: number | null;
|
|
23
|
+
};
|
|
24
|
+
/** GET /v1/snapshot response body. */
|
|
25
|
+
export interface SnapshotResponse extends Omit<AuthCredentialSnapshot, "credentials"> {
|
|
26
|
+
serverNowMs: number;
|
|
27
|
+
refresher: RefresherSchedule;
|
|
28
|
+
credentials: SnapshotEntry[];
|
|
29
|
+
}
|
|
30
|
+
/** GET /v1/usage response body — matches the local `AuthStorage.fetchUsageReports` shape. */
|
|
31
|
+
export interface UsageResponse {
|
|
32
|
+
generatedAt: number;
|
|
33
|
+
reports: UsageReport[];
|
|
34
|
+
}
|
|
35
|
+
/** POST /v1/credential/:id/refresh response body. */
|
|
36
|
+
export interface CredentialRefreshResponse {
|
|
37
|
+
entry: AuthCredentialSnapshotEntry;
|
|
38
|
+
}
|
|
39
|
+
/** POST /v1/credential/:id/disable request body. */
|
|
40
|
+
export interface CredentialDisableRequest {
|
|
41
|
+
cause: string;
|
|
42
|
+
}
|
|
43
|
+
/** POST /v1/credential/:id/disable response body. */
|
|
44
|
+
export interface CredentialDisableResponse {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* POST /v1/credential request body. The OAuth `refresh` must be the *real*
|
|
49
|
+
* refresh token (not the sentinel) — the broker is the canonical writer.
|
|
50
|
+
*/
|
|
51
|
+
export interface CredentialUploadRequest {
|
|
52
|
+
provider: string;
|
|
53
|
+
credential: AuthCredential;
|
|
54
|
+
}
|
|
55
|
+
/** POST /v1/credential response body — redacted snapshot of the provider's rows after upsert. */
|
|
56
|
+
export interface CredentialUploadResponse {
|
|
57
|
+
entries: AuthCredentialSnapshotEntry[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Default bearer-protected route prefix. The broker exposes `/v1/healthz`
|
|
61
|
+
* unauthenticated for liveness probes; everything else requires a bearer.
|
|
62
|
+
*/
|
|
63
|
+
export declare const AUTH_BROKER_API_PREFIX = "/v1";
|
|
64
|
+
/** Default port when none is configured. Loopback-only, no external exposure. */
|
|
65
|
+
export declare const DEFAULT_AUTH_BROKER_BIND = "127.0.0.1:8765";
|
|
66
|
+
/** Default broker→provider refresh skew. Refresh credentials this close to expiry. */
|
|
67
|
+
export declare const DEFAULT_REFRESH_SKEW_MS: number;
|
|
68
|
+
/** Default broker refresh-loop cadence. */
|
|
69
|
+
export declare const DEFAULT_REFRESH_INTERVAL_MS = 60000;
|