mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-12-01 22:52:55 +08:00
Authorize acp/ models via Home local-plugin-dispatch and run the selected plugin executor without upstream credentials. Validate plugin version, config digest, host/Home fences, and the authorized model across execute, stream, and count paths, while falling back to credential dispatch for legacy Home. Preserve before-auth interception, usage attribution, payload finalization, and router exclusions for delegated requests. Expose static executor models and avoid reusing resident shadow plugin images on reload.
28 lines
628 B
Go
28 lines
628 B
Go
package homeplugins
|
|
|
|
import "context"
|
|
|
|
const ACPModelPrefix = "acp/"
|
|
|
|
type LocalExecutorGrant struct {
|
|
Plugin string
|
|
Version string
|
|
ConfigDigest string
|
|
Model string
|
|
Valid func() bool
|
|
}
|
|
|
|
type localExecutorGrantKey struct{}
|
|
|
|
func WithLocalExecutorGrant(ctx context.Context, grant LocalExecutorGrant) context.Context {
|
|
return context.WithValue(ctx, localExecutorGrantKey{}, grant)
|
|
}
|
|
|
|
func ExecutorGrant(ctx context.Context) (LocalExecutorGrant, bool) {
|
|
if ctx == nil {
|
|
return LocalExecutorGrant{}, false
|
|
}
|
|
grant, ok := ctx.Value(localExecutorGrantKey{}).(LocalExecutorGrant)
|
|
return grant, ok
|
|
}
|