mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 13:44:03 +00:00
refactor(openai): move native transport policy into extension
This commit is contained in:
@@ -270,6 +270,28 @@ API key auth, and dynamic model resolution.
|
||||
},
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Native transport identity">
|
||||
For providers that need native request/session headers or metadata on
|
||||
generic HTTP or WebSocket transports:
|
||||
|
||||
```typescript
|
||||
resolveTransportTurnState: (ctx) => ({
|
||||
headers: {
|
||||
"x-request-id": ctx.turnId,
|
||||
},
|
||||
metadata: {
|
||||
session_id: ctx.sessionId ?? "",
|
||||
turn_id: ctx.turnId,
|
||||
},
|
||||
}),
|
||||
resolveWebSocketSessionPolicy: (ctx) => ({
|
||||
headers: {
|
||||
"x-session-id": ctx.sessionId ?? "",
|
||||
},
|
||||
degradeCooldownMs: 60_000,
|
||||
}),
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Usage and billing">
|
||||
For providers that expose usage/billing data:
|
||||
|
||||
@@ -297,24 +319,26 @@ API key auth, and dynamic model resolution.
|
||||
| 5 | `capabilities` | Transcript/tooling metadata (data, not callable) |
|
||||
| 6 | `prepareExtraParams` | Default request params |
|
||||
| 7 | `wrapStreamFn` | Custom headers/body wrappers |
|
||||
| 8 | `formatApiKey` | Custom runtime token shape |
|
||||
| 9 | `refreshOAuth` | Custom OAuth refresh |
|
||||
| 10 | `buildAuthDoctorHint` | Auth repair guidance |
|
||||
| 11 | `isCacheTtlEligible` | Prompt cache TTL gating |
|
||||
| 12 | `buildMissingAuthMessage` | Custom missing-auth hint |
|
||||
| 13 | `suppressBuiltInModel` | Hide stale upstream rows |
|
||||
| 14 | `augmentModelCatalog` | Synthetic forward-compat rows |
|
||||
| 15 | `isBinaryThinking` | Binary thinking on/off |
|
||||
| 16 | `supportsXHighThinking` | `xhigh` reasoning support |
|
||||
| 17 | `resolveDefaultThinkingLevel` | Default `/think` policy |
|
||||
| 18 | `isModernModelRef` | Live/smoke model matching |
|
||||
| 19 | `prepareRuntimeAuth` | Token exchange before inference |
|
||||
| 20 | `resolveUsageAuth` | Custom usage credential parsing |
|
||||
| 21 | `fetchUsageSnapshot` | Custom usage endpoint |
|
||||
| 22 | `onModelSelected` | Post-selection callback (e.g. telemetry) |
|
||||
| 23 | `buildReplayPolicy` | Custom transcript policy (e.g. thinking-block stripping) |
|
||||
| 24 | `sanitizeReplayHistory` | Provider-specific replay rewrites after generic cleanup |
|
||||
| 25 | `validateReplayTurns` | Strict replay-turn validation before the embedded runner |
|
||||
| 8 | `resolveTransportTurnState` | Native per-turn headers/metadata |
|
||||
| 9 | `resolveWebSocketSessionPolicy` | Native WS session headers/cool-down |
|
||||
| 10 | `formatApiKey` | Custom runtime token shape |
|
||||
| 11 | `refreshOAuth` | Custom OAuth refresh |
|
||||
| 12 | `buildAuthDoctorHint` | Auth repair guidance |
|
||||
| 13 | `isCacheTtlEligible` | Prompt cache TTL gating |
|
||||
| 14 | `buildMissingAuthMessage` | Custom missing-auth hint |
|
||||
| 15 | `suppressBuiltInModel` | Hide stale upstream rows |
|
||||
| 16 | `augmentModelCatalog` | Synthetic forward-compat rows |
|
||||
| 17 | `isBinaryThinking` | Binary thinking on/off |
|
||||
| 18 | `supportsXHighThinking` | `xhigh` reasoning support |
|
||||
| 19 | `resolveDefaultThinkingLevel` | Default `/think` policy |
|
||||
| 20 | `isModernModelRef` | Live/smoke model matching |
|
||||
| 21 | `prepareRuntimeAuth` | Token exchange before inference |
|
||||
| 22 | `resolveUsageAuth` | Custom usage credential parsing |
|
||||
| 23 | `fetchUsageSnapshot` | Custom usage endpoint |
|
||||
| 24 | `onModelSelected` | Post-selection callback (e.g. telemetry) |
|
||||
| 25 | `buildReplayPolicy` | Custom transcript policy (e.g. thinking-block stripping) |
|
||||
| 26 | `sanitizeReplayHistory` | Provider-specific replay rewrites after generic cleanup |
|
||||
| 27 | `validateReplayTurns` | Strict replay-turn validation before the embedded runner |
|
||||
|
||||
For detailed descriptions and real-world examples, see
|
||||
[Internals: Provider Runtime Hooks](/plugins/architecture#provider-runtime-hooks).
|
||||
|
||||
Reference in New Issue
Block a user