mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-11-28 12:53:30 +08:00
Negotiate the scheduler protocol from Home config and use it to gate Codex continuity through Home instead of a local plugin scheduler. Send transport-safe scheduler context with auth dispatch and propagate the returned selection ID through execution metadata and usage reporting, preserving scheduler completion feedback even when local statistics are disabled. Run pre-admission and pre-output 429 continuity gates with bounded cooldown waits for Home streaming and non-streaming execution, handle scheduler_rejected as a terminal pick failure preferring the last upstream error, and preserve the upstream attempt provider across retry-round errors.
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package pluginhost
|
|
|
|
import (
|
|
"context"
|
|
|
|
internalpluginhost "github.com/router-for-me/CLIProxyAPI/v8/internal/pluginhost"
|
|
"github.com/router-for-me/CLIProxyAPI/v8/sdk/pluginapi"
|
|
)
|
|
|
|
// ErrUsageDeliveryPending requires sender retry without relinquishing ownership.
|
|
var ErrUsageDeliveryPending = internalpluginhost.ErrUsageDeliveryPending
|
|
|
|
// ErrUsageDeliveryUnavailable reports that a selected usage consumer failed.
|
|
var ErrUsageDeliveryUnavailable = internalpluginhost.ErrUsageDeliveryUnavailable
|
|
|
|
// HasUsagePlugins reports an advertised usage consumer, even if currently fused.
|
|
func (h *Host) HasUsagePlugins() bool {
|
|
return h != nil && h.inner != nil && h.inner.HasUsagePlugins()
|
|
}
|
|
|
|
// HandleUsage returns nil only after synchronous callbacks complete (or no usage
|
|
// consumers exist). Pending replacement/replay and callback failures return errors;
|
|
// the external sender retains ownership and must retry. No record is queued here.
|
|
func (h *Host) HandleUsage(ctx context.Context, record pluginapi.UsageRecord) error {
|
|
if h == nil || h.inner == nil {
|
|
return nil
|
|
}
|
|
return h.inner.HandleUsage(ctx, record)
|
|
}
|