bridge

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package bridge wraps a core.Provider to expose the common.Provider surface that attack modules consume.

The two interfaces have different shapes:

core.Provider    — full LLM-API surface: ChatCompletion takes
                   *ChatCompletionRequest with token / temperature /
                   tool / metadata fields, returns *ChatCompletionResponse
                   with id / created / model / choices / usage.
common.Provider  — minimal surface attack modules need: Query takes
                   []Message + options map, returns plain string.

The bridge translates between them: build a minimal request, call through, extract the first choice's content. Modules that need more (token counts for fitness, etc.) call the wrapper's GetTokenCount.

This is the v0.10.0 issue #167 deliverable. Without this, the attack-module ecosystem (consuming common.Provider) was unreachable from the OpenAI/Anthropic adapters (returning core.Provider). After this lands, `attack run --provider=openai` flows from operator invocation through the factory → core.Provider → bridge.WrapCore → common.Provider → module.Execute.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapCore

func WrapCore(p core.Provider) common.Provider

WrapCore returns a common.Provider backed by the given core.Provider. The returned value also implements common.ImageProvider and/or common.ReasoningProvider when the wrapped provider implements the corresponding core capability interface (v0.10.0 #166).

The 2x2 capability matrix is realized by four concrete wrapper types (coreAdapter, imageAdapter, reasoningAdapter, imageReasoningAdapter) rather than one struct with always-present methods. The reason: Go's type assertion is structural at compile time — a single struct with QueryWithImages would always satisfy common.ImageProvider, defeating the type-assertion gate that attack modules use to detect capability presence. Modules need OK to mean "this provider really does images," not "the wrapper has the method."

Returns the inner provider wrapped in a coreAdapter (or capability extension thereof). Caller retains ownership of the inner provider — the adapter does not call Close() on it; that's the caller's responsibility.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL