@fayegram-ai/decision-bridge 0.1.2 → 0.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 +19 -0
- package/CONTRIBUTING.md +5 -3
- package/README.md +24 -8
- package/SECURITY.md +18 -11
- package/docs/README.md +17 -4
- package/docs/development/ARCHITECTURE.md +32 -5
- package/docs/development/DESIGN.md +21 -3
- package/docs/development/RELEASING.md +7 -3
- package/docs/development/REPOSITORY_LAYOUT.md +2 -0
- package/docs/development/TESTING.md +31 -3
- package/docs/guides/BROWSER.md +5 -0
- package/docs/guides/CLOUDFLARE_DECISIONS.md +24 -46
- package/docs/guides/CUSTOMIZATION.md +8 -2
- package/docs/guides/CUSTOM_GENERATIVE.md +5 -3
- package/docs/guides/CUSTOM_PROVIDERS.md +5 -3
- package/docs/guides/EXTRACTION.md +125 -0
- package/docs/guides/GETTING_STARTED.md +8 -4
- package/docs/guides/JEV.md +13 -20
- package/docs/guides/LIVE_DECISIONS.md +163 -0
- package/docs/guides/OPENAI_DECISIONS.md +52 -24
- package/docs/guides/PLATFORMS.md +3 -3
- package/docs/guides/SWITCHING_MODELS.md +6 -2
- package/docs/guides/TROUBLESHOOTING.md +25 -0
- package/docs/reference/CLI.md +48 -10
- package/docs/reference/CONFIGURATION.md +31 -8
- package/docs/reference/ERRORS.md +41 -12
- package/docs/reference/PROVIDERS.md +19 -6
- package/docs/reference/SDK.md +62 -24
- package/docs/reference/SOURCES.md +7 -0
- package/examples/extraction.mjs +16 -0
- package/examples/live-decisions.mjs +24 -0
- package/package.json +11 -1
- package/schemas/decision.config.schema.json +88 -11
- package/src/bridge.mjs +9 -6
- package/src/capabilities.mjs +28 -4
- package/src/cli/config-validation.mjs +4 -4
- package/src/cli/config.mjs +4 -2
- package/src/cli/initialize.mjs +8 -4
- package/src/cli/live.mjs +63 -0
- package/src/cli/main.mjs +35 -12
- package/src/cli/provider-loader.mjs +3 -2
- package/src/cloudflare-decisions.d.mts +12 -5
- package/src/decisions.d.mts +28 -4
- package/src/errors.mjs +7 -1
- package/src/extraction/index.d.mts +66 -0
- package/src/extraction/index.mjs +78 -0
- package/src/extraction/validation.mjs +105 -0
- package/src/index.d.mts +18 -4
- package/src/input.mjs +21 -3
- package/src/live/index.d.mts +73 -0
- package/src/live/index.mjs +170 -0
- package/src/live/state.mjs +125 -0
- package/src/live/validation.mjs +122 -0
- package/src/providers/cloudflare-images.mjs +3 -9
- package/src/providers/cloudflare-media.mjs +5 -10
- package/src/providers/cloudflare-preflight.mjs +4 -3
- package/src/providers/cloudflare-profile.mjs +10 -14
- package/src/providers/cloudflare-transport.mjs +12 -5
- package/src/providers/cloudflare-validation.mjs +3 -1
- package/src/providers/decisions-codec.mjs +10 -5
- package/src/providers/decisions-input.mjs +120 -0
- package/src/providers/decisions-validation.mjs +37 -69
- package/src/providers/jev-images.mjs +2 -8
- package/src/providers/jev-preflight.mjs +1 -0
- package/src/providers/jev-profile.mjs +2 -2
- package/src/providers/media-binary.mjs +0 -7
- package/src/providers/openai-decisions.mjs +2 -1
- package/src/providers/openai-errors.mjs +23 -0
- package/src/providers/openai-profile.mjs +2 -1
- package/src/response-transport.mjs +84 -17
- package/src/validation.mjs +26 -14
- package/src/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Notable user-facing changes by version.
|
|
4
4
|
|
|
5
|
+
## 0.1.3
|
|
6
|
+
|
|
7
|
+
- Expand OpenAI Decisions with conversation/tool history, remote images and
|
|
8
|
+
prompt caching, including common input, extensions and schema version 5.
|
|
9
|
+
- Add Clairic extraction over REST and Workers bindings, with nine field types,
|
|
10
|
+
native predictive metadata and extraction CLI commands.
|
|
11
|
+
- Add an existing-connection Live Decisions controller and offline protocol
|
|
12
|
+
validation/replay tools through a dedicated package export.
|
|
13
|
+
- Leave service quotas and admission ceilings upstream; preserve explicit client
|
|
14
|
+
resource budgets and improve safe errors and error-aware retries.
|
|
15
|
+
- Preserve requested Clairic model aliases in batch diagnostics and parse valid
|
|
16
|
+
retry hints without losing HTTP status or safe IDs when an error body fails.
|
|
17
|
+
- Harden Live configuration/history correlation, transcript ordering, item
|
|
18
|
+
acknowledgements, observer isolation, cancellation and connection cleanup.
|
|
19
|
+
Offline event validation and replay retain their respective input/server error
|
|
20
|
+
contracts.
|
|
21
|
+
- Document the expanded SDK and CLI APIs, extraction and Live operations, and
|
|
22
|
+
client resource controls.
|
|
23
|
+
|
|
5
24
|
## 0.1.2
|
|
6
25
|
|
|
7
26
|
- Add opt-in Jev images, typed bounding boxes, native JSON assets, and long context
|
package/CONTRIBUTING.md
CHANGED
|
@@ -20,9 +20,11 @@ configuration-schema validator from the lockfile. See the
|
|
|
20
20
|
Start with the [architecture](docs/development/ARCHITECTURE.md),
|
|
21
21
|
[design rationale](docs/development/DESIGN.md), and
|
|
22
22
|
[repository layout](docs/development/REPOSITORY_LAYOUT.md).
|
|
23
|
-
Preserve the provider-independent contract of
|
|
24
|
-
`questions`, and explicit probability provenance.
|
|
25
|
-
|
|
23
|
+
Preserve the provider-independent contract of exactly one of `state`, ordered
|
|
24
|
+
`input` or `conversation`, plus `questions`, and explicit probability provenance.
|
|
25
|
+
Extraction and Live use dedicated operation contracts. Keep service admission
|
|
26
|
+
limits upstream and client resource controls explicit. Add focused regression
|
|
27
|
+
tests for bug fixes and wire-level tests for protocol changes. Fixtures must not contain credentials or live-account
|
|
26
28
|
data; label synthetic responses as synthetic.
|
|
27
29
|
|
|
28
30
|
## Make and verify a change
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A JavaScript SDK that turns supplied information into structured decisions insid
|
|
|
7
7
|
your application. An optional Node command runner is included for evaluating files.
|
|
8
8
|
Give it a `state` (text or JSON to assess) and one or more `questions`; it returns
|
|
9
9
|
validated choices, probabilities for yes/no (`noul`) questions, or rubric-based
|
|
10
|
-
scores.
|
|
10
|
+
scores. Capable providers also accept ordered media input or conversation history.
|
|
11
11
|
For example, pass a failed test log to classify the failure and estimate whether
|
|
12
12
|
a missing dependency caused it. Your application decides what to do with the result.
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ OpenRouter, and Anthropic presets. The bridge handles the shared request and res
|
|
|
21
21
|
contract; each provider handles its API protocol and model capabilities.
|
|
22
22
|
|
|
23
23
|
[OpenAI Decisions](docs/guides/OPENAI_DECISIONS.md) also supports ordered text/image
|
|
24
|
-
input, typed string/boolean choices, labelled scores, and dedicated native access.
|
|
24
|
+
input, typed string/boolean choices, labelled scores, conversation/tool history, remote images, prompt caching, and dedicated native access.
|
|
25
25
|
[Cloudflare Clef, Clef-flash, and Clef-omni](docs/guides/CLOUDFLARE_DECISIONS.md) provide
|
|
26
26
|
common/native access, embedded images, typed choices, labelled scores, REST,
|
|
27
27
|
Workers AI bindings, and optional AI Gateway routing. Omni additionally supports
|
|
@@ -29,7 +29,12 @@ embedded WAV/MP3 audio and MP4/WebM video, ordered images → audio → videos
|
|
|
29
29
|
The common API checks provider/model capabilities before dispatch; refusals are
|
|
30
30
|
errors.
|
|
31
31
|
|
|
32
|
-
**Version 0.1.
|
|
32
|
+
**Version 0.1.3 · Node.js 22.16+ or modern browsers (SDK) · ESM · zero runtime dependencies**
|
|
33
|
+
|
|
34
|
+
These docs cover 0.1.3. For supported features by version, see
|
|
35
|
+
[version availability](docs/README.md#version-availability) and the
|
|
36
|
+
[changelog](CHANGELOG.md). Start with the
|
|
37
|
+
[installation options](docs/guides/GETTING_STARTED.md#install-into-your-application).
|
|
33
38
|
|
|
34
39
|
The npm package is
|
|
35
40
|
[@fayegram-ai/decision-bridge](https://www.npmjs.com/package/@fayegram-ai/decision-bridge).
|
|
@@ -64,7 +69,7 @@ Decision Bridge release. Explicit supported model IDs can also be selected; see
|
|
|
64
69
|
the [OpenAI model selection guide](docs/guides/OPENAI_DECISIONS.md#model-selection)
|
|
65
70
|
for details. Results retain the selected value in `meta.requestedModel`,
|
|
66
71
|
the outgoing ID in `meta.resolvedModel`, and the service-reported model in `model`.
|
|
67
|
-
Cloudflare accepts
|
|
72
|
+
The Cloudflare decision provider accepts the three decision models above, in short or full form.
|
|
68
73
|
Model discovery is unsupported for OpenAI Decisions and Cloudflare.
|
|
69
74
|
|
|
70
75
|
Additional decision protocols use [custom decision providers](docs/guides/CUSTOM_DECISION.md).
|
|
@@ -73,6 +78,16 @@ entry point, with `openai-compatible`, `openrouter`, or `anthropic` presets, or
|
|
|
73
78
|
an explicit provider module. Those presets require a model ID supported by your
|
|
74
79
|
configured service and have no default model or fixed model catalog.
|
|
75
80
|
|
|
81
|
+
Clairic uses the dedicated [extraction API](docs/guides/EXTRACTION.md), with
|
|
82
|
+
selectors `clairic` and `@cf/cloudflare/clairic` (default `clairic`). It returns
|
|
83
|
+
typed values, estimates and forecasts through REST or Workers bindings.
|
|
84
|
+
[Live Decisions](docs/guides/LIVE_DECISIONS.md) attaches to an application-owned
|
|
85
|
+
GPT-Live connection for delegation, transcript triggers and Decision events.
|
|
86
|
+
These operations have dedicated `/extraction` and `/live` package exports.
|
|
87
|
+
|
|
88
|
+
Service quotas and admission limits are handled upstream. The SDK validates its
|
|
89
|
+
contracts and configurable client resource budgets and returns structured errors.
|
|
90
|
+
|
|
76
91
|
## Choose a provider
|
|
77
92
|
|
|
78
93
|
All native providers support shared state and the common `choice`, `noul`, and
|
|
@@ -81,7 +96,7 @@ All native providers support shared state and the common `choice`, `noul`, and
|
|
|
81
96
|
| Provider | Additional supported features | Guide |
|
|
82
97
|
| --- | --- | --- |
|
|
83
98
|
| Jev | Native decisions, opt-in images, boxes, and long context through TypeSafe | [Jev guide](docs/guides/JEV.md) |
|
|
84
|
-
| OpenAI Decisions | Ordered text/images, typed choices, labelled scores, safety identifiers, native access | [OpenAI Decisions](docs/guides/OPENAI_DECISIONS.md) |
|
|
99
|
+
| OpenAI Decisions | Ordered text/images, conversation/tool history, remote images, prompt caching, typed choices, labelled scores, safety identifiers, native access | [OpenAI Decisions](docs/guides/OPENAI_DECISIONS.md) |
|
|
85
100
|
| Cloudflare Clef / Clef-flash | Embedded images before text, typed choices, labelled scores, native access, Workers AI binding, optional Gateway | [Cloudflare decisions](docs/guides/CLOUDFLARE_DECISIONS.md) |
|
|
86
101
|
| Cloudflare Clef-omni | The same decision and transport features, plus embedded audio/video | [Omni media and limits](docs/guides/CLOUDFLARE_DECISIONS.md#omni-audio-and-video) |
|
|
87
102
|
| Custom decision service | Explicit decision provider contract | [Custom decision providers](docs/guides/CUSTOM_DECISION.md) |
|
|
@@ -254,12 +269,13 @@ test suite and development scripts.
|
|
|
254
269
|
|
|
255
270
|
| Area | Implementation |
|
|
256
271
|
| --- | --- |
|
|
257
|
-
| Stable contract | Runtime-defined [questions](docs/reference/SDK.md#question-builders),
|
|
272
|
+
| Stable contract | Runtime-defined [questions](docs/reference/SDK.md#question-builders), state, ordered input or conversation according to capabilities, typed answers, immutable results |
|
|
258
273
|
| Native providers | Jev, OpenAI Decisions, Cloudflare Clef/Clef-flash/Clef-omni |
|
|
259
274
|
| Custom providers | Separate decision and generative contracts; opt-in Chat Completions, OpenRouter, and Anthropic presets |
|
|
260
275
|
| SDK | Provider factory, [capability preflight](docs/reference/SDK.md#bridgegetcapabilitiesmodel-and-bridgevalidaterequest), [cancellation](docs/reference/SDK.md#cancellation-and-deadlines), and [ordered batch evaluation](docs/reference/SDK.md#sdk-batch-evaluation) |
|
|
261
|
-
|
|
|
262
|
-
|
|
|
276
|
+
| Dedicated operations | [Clairic extraction](docs/guides/EXTRACTION.md) and [Live Decisions](docs/guides/LIVE_DECISIONS.md), with separate exports and native results |
|
|
277
|
+
| Application extensions | [State/input/conversation preparation and result observation](docs/guides/CUSTOMIZATION.md), plus [choice thresholds and abstention policies](docs/guides/CUSTOMIZATION.md#application-policy-is-a-separate-stage) |
|
|
278
|
+
| Node command | [Decision/extraction commands and offline Live validation/replay](docs/reference/CLI.md#commands), with [explicit JSON profiles](docs/reference/CONFIGURATION.md) |
|
|
263
279
|
| Reliability | [Transport byte limits and fetch injection](docs/reference/SDK.md#provider-transport-options), deadlines, [limited retries and safe errors](docs/reference/ERRORS.md), strict response validation, atomic output |
|
|
264
280
|
| Development | Functional tests, coverage, TypeScript and Workers binding contracts, offline tarball-install checks, cross-platform CI configuration |
|
|
265
281
|
|
package/SECURITY.md
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
Keep keys in the process environment or an explicitly loaded local environment
|
|
6
6
|
file. Never place them in request JSON, committed profiles, command-line arguments,
|
|
7
7
|
or shared logs. The package contains no key, telemetry client, or background job.
|
|
8
|
-
|
|
9
|
-
provider when
|
|
8
|
+
It sends supplied decision evidence/question definitions or extraction evidence/
|
|
9
|
+
fields to the selected provider when the operation is explicitly requested.
|
|
10
|
+
Conversation/tool history is also request data. Remote HTTP(S) image references
|
|
11
|
+
are forwarded to OpenAI without being fetched by the SDK; the provider handles
|
|
12
|
+
their retrieval. Review data-sharing requirements
|
|
10
13
|
before sending private repository content or documents.
|
|
11
14
|
Optional Cloudflare Gateway routing can cache requests/responses or collect logs
|
|
12
15
|
according to explicit options and the Gateway's configuration. Review that
|
|
@@ -32,8 +35,9 @@ verbose HTTP logger that prints Authorization or x-api-key headers.
|
|
|
32
35
|
## Input and output
|
|
33
36
|
|
|
34
37
|
Strict plain-JSON checks reject accessors, cycles, non-finite numbers, lossy objects,
|
|
35
|
-
and unknown fields.
|
|
36
|
-
|
|
38
|
+
and unknown request fields. Clairic additionally preserves safe native response
|
|
39
|
+
fields, including predictive JSON and truncation. Bytes, nesting, nodes, retries,
|
|
40
|
+
concurrency, and waiting time are bounded. These checks do not establish decision accuracy or resist every
|
|
37
41
|
adversarial semantic input. Question instructions are trusted configuration;
|
|
38
42
|
state is untrusted evidence. Prompt separation is a mitigation, not a guarantee.
|
|
39
43
|
|
|
@@ -51,6 +55,13 @@ the bridge can stop awaiting a non-cooperative promise, not terminate arbitrary
|
|
|
51
55
|
code or undo side effects. A provider timeout or cancellation does not prove remote
|
|
52
56
|
inference stopped before billing.
|
|
53
57
|
|
|
58
|
+
The Live controller attaches to a connection supplied by the application. That
|
|
59
|
+
application owns authentication, audio, connection setup and reconnection. The
|
|
60
|
+
controller sends Decisions commands and consumes parsed notifications; disposing
|
|
61
|
+
it releases its listeners/waits without closing the application connection or
|
|
62
|
+
undoing actions. Decisions with unmatched or stale correlation require application
|
|
63
|
+
policy; receipt of a decision is not proof that an action completed.
|
|
64
|
+
|
|
54
65
|
## Dependencies and CI
|
|
55
66
|
|
|
56
67
|
There are zero runtime dependencies. This reduces dependency surface but is not a
|
|
@@ -63,13 +74,9 @@ commits under your organization's policy before using CI in a privileged setting
|
|
|
63
74
|
|
|
64
75
|
## Reporting
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
announcing the release; this source tree has no dedicated security inbox or other
|
|
70
|
-
private contact channel. If the reporting button is absent, ask the maintainer
|
|
71
|
-
for a private contact method without
|
|
72
|
-
including vulnerability details in a public issue.
|
|
77
|
+
Use the repository's **Security** tab and **Report a vulnerability** to submit a
|
|
78
|
+
private report. If the reporting button is unavailable, ask the maintainer for a
|
|
79
|
+
private contact method without including vulnerability details in a public issue.
|
|
73
80
|
|
|
74
81
|
Include the affected version, impact, and a minimal redacted reproduction. Do
|
|
75
82
|
not publish credentials, confidential inputs, or exploit details in an issue.
|
package/docs/README.md
CHANGED
|
@@ -11,14 +11,25 @@ See [model selectors and provider defaults](../README.md#model-selectors) for
|
|
|
11
11
|
built-in decision models and the separate custom generative presets.
|
|
12
12
|
|
|
13
13
|
Decision Bridge is a JavaScript SDK with an optional command runner. It evaluates
|
|
14
|
-
|
|
15
|
-
provider and returns
|
|
16
|
-
|
|
14
|
+
exactly one of `state`, ordered `input` or `conversation`, plus `questions`, with
|
|
15
|
+
an explicitly selected capable provider and returns validated, structured decisions.
|
|
16
|
+
Dedicated extraction and Live APIs have their own operation contracts.
|
|
17
17
|
For provider-specific input forms, consult the
|
|
18
18
|
[capability comparison](reference/PROVIDERS.md#common-request-capabilities).
|
|
19
19
|
The common bridge API and dedicated native APIs have separate request shapes;
|
|
20
20
|
the Jev, OpenAI and Cloudflare guides cover both.
|
|
21
21
|
|
|
22
|
+
## Version availability
|
|
23
|
+
|
|
24
|
+
These guides cover **0.1.3**. Use the documentation bundled with your installed
|
|
25
|
+
package. For version 0.1.2, see the
|
|
26
|
+
[0.1.2 documentation](https://github.com/Fayegram-AI/decision-bridge/tree/decision-bridge-v0.1.2/docs).
|
|
27
|
+
|
|
28
|
+
OpenAI conversation/tool history, remote images and prompt caching, plus Clairic
|
|
29
|
+
extraction and Live Decisions, require 0.1.3 or later. See
|
|
30
|
+
[installation](guides/GETTING_STARTED.md#install-into-your-application).
|
|
31
|
+
See the [changelog](../CHANGELOG.md) for version history.
|
|
32
|
+
|
|
22
33
|
## Use the bridge
|
|
23
34
|
|
|
24
35
|
| Guide | Purpose |
|
|
@@ -28,8 +39,10 @@ the Jev, OpenAI and Cloudflare guides cover both.
|
|
|
28
39
|
| [Platforms](guides/PLATFORMS.md) | Windows, macOS, and Linux setup |
|
|
29
40
|
| [Switching models](guides/SWITCHING_MODELS.md) | Backend and model selection |
|
|
30
41
|
| [Jev](guides/JEV.md) | Common/native images, boxes, experimental long context, model selection, and CLI opt-ins |
|
|
31
|
-
| [OpenAI Decisions](guides/OPENAI_DECISIONS.md) | Model selectors
|
|
42
|
+
| [OpenAI Decisions](guides/OPENAI_DECISIONS.md) | Model selectors, common/native access, conversation/tool history, remote images, cache controls and typed values |
|
|
32
43
|
| [Cloudflare Clef / Clef-flash / Clef-omni](guides/CLOUDFLARE_DECISIONS.md) | Common/native decisions, embedded images and Omni audio/video, REST and Workers AI binding, busy-mode compatibility, and optional Gateway |
|
|
44
|
+
| [Clairic extraction](guides/EXTRACTION.md) | Nine extraction/prediction types, REST/binding, native results and extraction CLI |
|
|
45
|
+
| [Live Decisions](guides/LIVE_DECISIONS.md) | Existing-connection controller, acknowledgements, correlation and offline replay |
|
|
33
46
|
| [Customization](guides/CUSTOMIZATION.md) | Questions, templates, extensions, and policies |
|
|
34
47
|
| [Custom providers](guides/CUSTOM_PROVIDERS.md) | Common classified contract and explicit CLI module loading |
|
|
35
48
|
| [Custom decision](guides/CUSTOM_DECISION.md) | Extend a native decision model protocol |
|
|
@@ -17,12 +17,12 @@ and Jev default before constructing the SDK bridge.
|
|
|
17
17
|
|
|
18
18
|
```text
|
|
19
19
|
Application / CLI
|
|
20
|
-
state
|
|
20
|
+
state, ordered input or conversation + question definitions + optional model
|
|
21
21
|
|
|
|
22
22
|
v
|
|
23
23
|
request snapshot, common validation, capabilities, provider preflight
|
|
24
24
|
|
|
|
25
|
-
ordered prepareState or
|
|
25
|
+
ordered prepareState, prepareInput or prepareConversation extensions + revalidation
|
|
26
26
|
|
|
|
27
27
|
Provider.evaluate (explicit decision/generative kind)
|
|
28
28
|
+-- Jev: native systemone
|
|
@@ -83,6 +83,10 @@ See [OpenAI model selection](../guides/OPENAI_DECISIONS.md#model-selection).
|
|
|
83
83
|
| `src/providers/` | API orchestration, model profiles, preflight, codecs, bounded image/audio/video inspection, and transports |
|
|
84
84
|
| `src/providers/openai-profile.mjs`, `src/providers/decisions-preflight.mjs` | Release-owned OpenAI selection, capabilities, and preparation of selected and outgoing requests |
|
|
85
85
|
| `src/providers/jev-profile.mjs`, `src/providers/jev-preflight.mjs`, `src/providers/jev-images.mjs` | Jev experimental policy, common/native assets, and image preflight |
|
|
86
|
+
| `src/providers/decisions-input.mjs`, `src/providers/decisions-codec.mjs` | Decisions item/cache validation and lossless common/native encoding |
|
|
87
|
+
| `src/providers/cloudflare-transport.mjs` | Shared decision/extraction REST and binding authentication, dispatch and diagnostics |
|
|
88
|
+
| `src/extraction/` | Clairic native field/request/response validation, provider, ordered batches and declarations |
|
|
89
|
+
| `src/live/` | Live protocol validation, bounded correlation state, supplied-connection controller and declarations |
|
|
86
90
|
| `src/embedded.mjs` | Shared embedded data URL and canonical base64 checks |
|
|
87
91
|
| `src/transport.mjs`, `src/response-transport.mjs` | Credential destinations, bounded bodies, safe errors, retries |
|
|
88
92
|
| `src/async.mjs` | Deadlines and cancellation races |
|
|
@@ -110,14 +114,24 @@ policy helper does not infer it from the answer or its metadata.
|
|
|
110
114
|
|
|
111
115
|
## Reliability and configuration
|
|
112
116
|
|
|
117
|
+
Built-in validators check structure, representation, adapter capabilities and
|
|
118
|
+
response integrity. They leave service-owned question/media counts, text/context
|
|
119
|
+
ceilings, quotas and RPM/TPM upstream. Custom quantitative capability limits remain
|
|
120
|
+
part of those providers' contracts. Client byte budgets, JSON safeguards,
|
|
121
|
+
cancellation and deadlines remain local controls.
|
|
122
|
+
|
|
113
123
|
Provider deadlines include dispatch, configured retries, backoff, and bounded body
|
|
114
124
|
reading. The bridge deadline additionally covers validation, preparation, provider
|
|
115
125
|
waiting, and result processing. Expired synchronous work cannot dispatch a call.
|
|
116
126
|
Cancellation bounds waiting for custom promises; custom code must honor signals
|
|
117
127
|
to release its own resources. Observations use a separate bounded budget.
|
|
118
128
|
|
|
119
|
-
Retries cover selected explicit transient responses
|
|
120
|
-
|
|
129
|
+
Retries cover selected explicit transient responses, with machine-code
|
|
130
|
+
classification preventing billing/allocation retries. OpenAI Decisions and
|
|
131
|
+
Clairic default to zero retries. Valid Retry-After hints share the total deadline;
|
|
132
|
+
attempt counts describe adapter dispatches, not hidden Gateway retries.
|
|
133
|
+
Malformed rejection bodies retain known safe HTTP diagnostics. Ambiguous failures
|
|
134
|
+
and failed observers do not trigger another inference. CLI atomic files protect previous
|
|
121
135
|
output but cannot undo remote work or emitted stdout.
|
|
122
136
|
|
|
123
137
|
JSON configuration is explicit. Custom ESM executes only when selected. Custom
|
|
@@ -135,7 +149,20 @@ mutable request limit or response identifiers. Header/container inspection is
|
|
|
135
149
|
bounded and does not perform full media decoding.
|
|
136
150
|
|
|
137
151
|
The SDK does not host models or provide a server API, persistent state, autonomous
|
|
138
|
-
actions, streaming, transcription, transcoding, frame extraction,
|
|
152
|
+
actions, HTTP decision streaming, audio transcription, transcoding, frame extraction,
|
|
139
153
|
provider-side asynchronous batch jobs, platform
|
|
140
154
|
management, automatic model search, or automatic provider failover. SDK arrays and
|
|
141
155
|
CLI JSONL batches provide bounded client-side concurrency.
|
|
156
|
+
|
|
157
|
+
Extraction owns its request/result contract and uses shared Cloudflare dispatch.
|
|
158
|
+
Its inference options remain in model input; binding execution options use the
|
|
159
|
+
third `ai.run` argument. Native nulls, empty lists, predictive JSON and truncation
|
|
160
|
+
are preserved in an immutable `{ extraction, meta }` envelope.
|
|
161
|
+
Live owns protocol validation, a bounded pure correlation reducer and a supplied-
|
|
162
|
+
connection controller. Offline replay uses that same reducer. Their dedicated
|
|
163
|
+
exports do not widen the existing decision/generative provider contract.
|
|
164
|
+
Live configuration changes activate on acknowledgement. Source snapshots and
|
|
165
|
+
observed per-direction transcript order support correlation; unavailable evidence
|
|
166
|
+
stays unmatched. Manual evaluation and commentary return submission receipts;
|
|
167
|
+
completed decisions arrive through subscriptions, preserving native refusals.
|
|
168
|
+
The application owns authentication, audio, connection setup and reconnection.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Native decisions as the application contract
|
|
4
4
|
|
|
5
|
-
Use shared state
|
|
5
|
+
Use shared state, ordered input or conversation and independent typed questions as the public
|
|
6
6
|
contract. The bridge owns orchestration; providers own their model API protocols.
|
|
7
7
|
This gives applications a stable decision interface and makes customization
|
|
8
8
|
explicit at each call. Native decision models are the main package scope;
|
|
@@ -10,6 +10,11 @@ generative protocols are opt-in custom strategies with their own public subpath.
|
|
|
10
10
|
Every provider declares its decision/generative kind. Consequence: not every model can satisfy this contract
|
|
11
11
|
reliably; compatibility and quality must be tested separately.
|
|
12
12
|
|
|
13
|
+
Extraction and Live are dedicated operations. Clairic keeps its native fields
|
|
14
|
+
and predictive response envelope; Live attaches commands and events to an
|
|
15
|
+
application-owned connection. Each has its own API and result contract, separate
|
|
16
|
+
from the bridge's `evaluate` interface.
|
|
17
|
+
|
|
13
18
|
## ESM JavaScript with declarations and no runtime dependencies
|
|
14
19
|
|
|
15
20
|
Use standard fetch, streams, and JSON in the SDK; keep Node's test runner,
|
|
@@ -30,13 +35,26 @@ calibration or correctness.
|
|
|
30
35
|
|
|
31
36
|
## Fail explicitly instead of silently repairing or falling back
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
precision allowance,
|
|
38
|
+
Decision calls reject invalid JSON, unsupported request fields, wrong labels,
|
|
39
|
+
distributions outside the provider precision allowance, malformed results and
|
|
40
|
+
refusals; generative paths also reject explicit output truncation. Require explicit
|
|
35
41
|
output modes and models. Services may truncate input without reporting it; local
|
|
36
42
|
byte limits do not guarantee token fit. Consequence:
|
|
37
43
|
some calls fail that a permissive wrapper might guess at, but failures remain
|
|
38
44
|
observable and cannot silently change budgets or decision policies.
|
|
39
45
|
|
|
46
|
+
Clairic preserves additional safe native JSON and its truncation flag. Live
|
|
47
|
+
preserves native refusal events and marks ambiguous correlation as unmatched.
|
|
48
|
+
Those operation contracts avoid inventing success or discarding native evidence.
|
|
49
|
+
|
|
50
|
+
## Service admission and client resources
|
|
51
|
+
|
|
52
|
+
The server owns quotas, rate limits, service counts, context admission and media
|
|
53
|
+
ceilings. Report rejection through safe structured errors; do not estimate tokens,
|
|
54
|
+
track account allocations, split requests or schedule service capacity. Local
|
|
55
|
+
byte/JSON safeguards, cancellation, deadlines and caller-selected concurrency
|
|
56
|
+
bound client resources. Custom-provider quantitative contracts remain explicit.
|
|
57
|
+
|
|
40
58
|
## Trusted extensions and explicit configuration
|
|
41
59
|
|
|
42
60
|
Read JSON config only when named. Load custom ESM only when explicitly selected.
|
|
@@ -30,8 +30,10 @@ node scripts/package-smoke.mjs --tarball release/fayegram-ai-decision-bridge-VER
|
|
|
30
30
|
Check public documentation against the implementation, including supported API
|
|
31
31
|
shapes, examples, limits, errors, and service compatibility notes. Inspect the MIT
|
|
32
32
|
copyright notice and package contents. Complete hosted checks relevant to changed
|
|
33
|
-
features
|
|
34
|
-
|
|
33
|
+
features only when needed to resolve a specific wire-contract uncertainty, using
|
|
34
|
+
an explicitly authorized account/runtime. Offline fixtures are sufficient for
|
|
35
|
+
routine development and CI; fixture and declaration checks do not establish
|
|
36
|
+
hosted binding/Gateway/Live behavior. Report the actual verification scope.
|
|
35
37
|
Keep completed verification evidence separate from maintained consumer guidance.
|
|
36
38
|
These content and verification checks do not depend on publication account setup.
|
|
37
39
|
|
|
@@ -49,7 +51,9 @@ name and registry are `@fayegram-ai/decision-bridge` and the public npm registry
|
|
|
49
51
|
Coordinate the GitHub source release and publication of the verified tarball to
|
|
50
52
|
npm as one release. The source release commit and archive must contain the same
|
|
51
53
|
intended files, including README and documentation. A packed or uploaded archive
|
|
52
|
-
is a snapshot: subsequent source edits do not change its contents.
|
|
54
|
+
is a snapshot: subsequent source edits do not change its contents. Finalize the
|
|
55
|
+
changelog and version-availability notices before building. If packaged files
|
|
56
|
+
change afterward, rebuild and verify the archive before publication.
|
|
53
57
|
|
|
54
58
|
The tracked `.npmrc` routes this scope to npm in this checkout without changing
|
|
55
59
|
the user's npm configuration. Keep credentials in the user configuration, never
|
|
@@ -15,6 +15,8 @@ package-lock.json Pinned development dependency metadata
|
|
|
15
15
|
.env.example Provider credential placeholders
|
|
16
16
|
src/ Common SDK, native providers, CLI, declarations
|
|
17
17
|
src/custom/ Explicit decision definitions and generative presets
|
|
18
|
+
src/extraction/ Dedicated Clairic provider, validation, batches and types
|
|
19
|
+
src/live/ Supplied-connection Live controller, protocol state and types
|
|
18
20
|
bin/ Node.js CLI entry point
|
|
19
21
|
examples/ Native SDK examples and request profiles
|
|
20
22
|
examples/custom/ Opt-in generative and native delegation examples
|
|
@@ -16,7 +16,7 @@ Source and installed-consumer type checks use the same local compiler.
|
|
|
16
16
|
| `npm test` | SDK, CLI, provider, and file/transport behavior using fixtures and loopback servers |
|
|
17
17
|
| `npm run test:coverage` | The functional suite with production source/bin coverage floors |
|
|
18
18
|
| `npm run typecheck` | Positive and expected-negative TypeScript API contracts |
|
|
19
|
-
| `npm run test:package` | Pack, offline install, root/custom exports and types, browser-safe imports, presets/modules, contents and docs |
|
|
19
|
+
| `npm run test:package` | Pack, offline install, root/custom/extraction/Live exports and types, browser-safe imports, presets/modules, contents and docs |
|
|
20
20
|
| `npm run build` | Retain a versioned npm tarball after checking its offline installation |
|
|
21
21
|
| `npm run verify` | Source checks, tests, type contracts, and package smoke check |
|
|
22
22
|
|
|
@@ -44,6 +44,11 @@ as evidence that every environment passed.
|
|
|
44
44
|
- `result-validation.test.mjs`: provider-selected precision and policy-hook boundaries.
|
|
45
45
|
- `decisions*.test.mjs`: native/common OpenAI codecs, selectors and model identities, boundaries, preflight, CLI, and smoke-helper fixtures.
|
|
46
46
|
- `cloudflare*.test.mjs`: models, images, codecs, REST/binding/Gateway arguments, errors, and CLI limits.
|
|
47
|
+
- `jev*.test.mjs`: native/common assets, reference substitution, boxes, opt-ins, nullable usage and CLI behavior.
|
|
48
|
+
- `capability-expansion.test.mjs`: conversation/tool history, remote images, cache controls, extension revalidation, service-limit ownership and safe rejection diagnostics.
|
|
49
|
+
- `extraction.test.mjs`: all nine Clairic field families, native JSON preservation, REST/binding options, batch preflight and model-selection diagnostics.
|
|
50
|
+
- `live.test.mjs`: commands/acknowledgements, configuration history, transcript ordering, unmatched/stale/duplicate results, observer isolation and lifecycle cleanup.
|
|
51
|
+
- `expansion-cli.test.mjs`: extraction commands/configuration, offline Live validation/replay, per-row errors and provider-switch isolation.
|
|
47
52
|
- `custom-providers.test.mjs`, `custom-config.test.mjs`: classified SDK paths, provenance, presets/modules, schema and initialization.
|
|
48
53
|
- `generative-helpers.test.mjs`: exported prompt/normalization helper contracts and unsupported input rejection.
|
|
49
54
|
- `config.test.mjs`: file/environment/flag precedence and provider transitions.
|
|
@@ -54,6 +59,7 @@ as evidence that every environment passed.
|
|
|
54
59
|
- `types.mts`, `providers.types.mts`, `custom.types.mts`: public type inference and rejected API usage.
|
|
55
60
|
- `decisions.types.mts`, `cloudflare.types.mts`: richer questions, native APIs, and precision settings.
|
|
56
61
|
- `cloudflare-worker.types.mts`: compatibility with official Workers binding declarations.
|
|
62
|
+
- `expansion.types.mts`: conversation/cache inputs, extraction value inference, unions, batches and Live transport/notification contracts.
|
|
57
63
|
|
|
58
64
|
Node's reported test count includes each row of a parameterized input table. It
|
|
59
65
|
is not a count of independent features; retain separate rows when they protect
|
|
@@ -85,6 +91,23 @@ the complete integration check. A selector mapping change must be verified again
|
|
|
85
91
|
the target model's protocol and capabilities; local fixtures alone do not establish
|
|
86
92
|
compatibility with a newly selected upstream model.
|
|
87
93
|
|
|
94
|
+
### Capability expansion coverage
|
|
95
|
+
|
|
96
|
+
For changes across expanded OpenAI input, Clairic or Live, use the existing
|
|
97
|
+
functional fixtures and declaration checks. A focused source-root command is:
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
node --test test/capability-expansion.test.mjs test/extraction.test.mjs test/live.test.mjs test/expansion-cli.test.mjs
|
|
101
|
+
npm run typecheck
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
REST doubles and binding doubles verify inference/execution option separation and
|
|
105
|
+
safe upstream errors. Live uses a supplied in-memory connection adapter and the
|
|
106
|
+
same state reducer as offline replay. No test intentionally exhausts service
|
|
107
|
+
quotas or treats accepted local structure as hosted admission. Installed-package
|
|
108
|
+
checks exercise the dedicated exports, CLI tools, declarations and SDK imports
|
|
109
|
+
without Node globals.
|
|
110
|
+
|
|
88
111
|
## Optional authenticated provider smoke check
|
|
89
112
|
|
|
90
113
|
Live inference is explicitly opted in and can incur charges. Configure credentials
|
|
@@ -132,13 +155,18 @@ Header/dimension preflight does not fully decode images, so live image fixtures
|
|
|
132
155
|
must also contain valid encoded image data.
|
|
133
156
|
Omni fixtures must contain genuinely decodable WAV/MP3 and MP4/WebM media for
|
|
134
157
|
hosted tests. Local authored container fixtures verify inspection and protocol
|
|
135
|
-
behavior without claiming codec validity.
|
|
136
|
-
|
|
158
|
+
behavior without claiming codec validity. Cover grouped modalities, container
|
|
159
|
+
validity, configured client byte budgets, effective-model overrides, request bodies above 13 MiB,
|
|
137
160
|
and explicit smaller ceilings. Gateway caching/logging should be disabled for
|
|
138
161
|
test payloads, and each bounded run should have a request and total time budget.
|
|
139
162
|
|
|
140
163
|
The SDK, CLI, and ordinary checks do not create Workers or Gateways. Provisioning
|
|
141
164
|
and cleanup belong to the application's separately authorized environment setup.
|
|
165
|
+
The smoke helper does not qualify Clairic or a GPT-Live connection. When a specific
|
|
166
|
+
wire-contract uncertainty requires hosted verification, use the intended
|
|
167
|
+
application-owned runtime/connection and a bounded, explicitly authorized case.
|
|
168
|
+
Offline fixtures remain sufficient for routine development and CI; record hosted
|
|
169
|
+
behavior only when that exact path was exercised.
|
|
142
170
|
|
|
143
171
|
## Package verification
|
|
144
172
|
|
package/docs/guides/BROWSER.md
CHANGED
|
@@ -6,6 +6,11 @@ The SDK exports browser-compatible ESM. Follow the
|
|
|
6
6
|
optional `decision-bridge` command still requires Node.js.
|
|
7
7
|
Omni's embedded audio/video validation is browser-safe and adds no runtime media
|
|
8
8
|
library. Build data URLs in the application; the SDK does not fetch remote media.
|
|
9
|
+
The dedicated [extraction](EXTRACTION.md) and [Live](LIVE_DECISIONS.md) exports
|
|
10
|
+
also use browser-compatible APIs. Clairic REST still requires provider CORS and
|
|
11
|
+
explicit credentials. Live attaches to an already established application-owned
|
|
12
|
+
connection; it does not create or authenticate one. OpenAI remote-image URLs are
|
|
13
|
+
forwarded to the provider without a browser-side SDK fetch.
|
|
9
14
|
|
|
10
15
|
Built-in REST providers need explicitly supplied credentials in browser code;
|
|
11
16
|
Node environment-variable defaults and `.env` files are not available. Cloudflare
|
|
@@ -16,8 +16,7 @@ short selectors and full forms.
|
|
|
16
16
|
Questions and media consume context before text state; the service truncates
|
|
17
17
|
remaining text state to fit. Requests whose questions/media exhaust context can
|
|
18
18
|
fail. Byte checks cannot guarantee token fit or detect remote truncation.
|
|
19
|
-
|
|
20
|
-
client configuration. Consult the official [model pages](#official-references)
|
|
19
|
+
Consult the official [model pages](#official-references)
|
|
21
20
|
for current pricing and availability; the bridge does not discover account access.
|
|
22
21
|
|
|
23
22
|
## Supported inference paths
|
|
@@ -108,7 +107,7 @@ extensions and the bridge's separate total deadline.
|
|
|
108
107
|
|
|
109
108
|
## Embedded images and limits
|
|
110
109
|
|
|
111
|
-
Clef accepts
|
|
110
|
+
Clef accepts embedded PNG, JPEG, or WebP images; the service owns count admission. Native `images` entries
|
|
112
111
|
can be base64 data URLs or `{ content_type, base64 }` objects. Remote URLs are
|
|
113
112
|
rejected. Common ordered input places all images before all text:
|
|
114
113
|
|
|
@@ -130,24 +129,15 @@ Text parts concatenate exactly, without inserted separators. Image detail can be
|
|
|
130
129
|
omitted, `null`, or `auto`; explicit `low`, `high`, and `original` are unsupported.
|
|
131
130
|
Safety identifiers are unsupported by this provider.
|
|
132
131
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
| Serialized request | Clef/Clef-flash: at most 13 MiB; Omni: 36 MiB by default, configurable through 64 MiB |
|
|
143
|
-
|
|
144
|
-
Preflight checks supported formats, base64 syntax, headers, dimensions, and size.
|
|
145
|
-
Header inspection is not full image decoding; the service can reject corrupt image data.
|
|
146
|
-
Limits include execution options and binding envelope overhead. Omni's 36 MiB
|
|
147
|
-
default is a bridge policy allowing base64 expansion of the permitted decoded
|
|
148
|
-
media; its published schema specifies no whole-request byte ceiling. The effective
|
|
149
|
-
request model selects the budget, including per-call overrides. An explicit
|
|
150
|
-
`maxRequestBytes` remains a caller ceiling and is never enlarged by selecting Omni.
|
|
132
|
+
Preflight validates supported representations, canonical base64, positive image
|
|
133
|
+
dimensions and container structure. Service question/media counts, decoded sizes,
|
|
134
|
+
dimensions, duration and context ceilings are not enforced locally. Header
|
|
135
|
+
inspection is not full decoding; upstream admission and decoding remain authoritative.
|
|
136
|
+
|
|
137
|
+
Client request budgets default to 13 MiB for Clef/Clef-flash and 36 MiB for Omni.
|
|
138
|
+
An explicit `maxRequestBytes` overrides either default through the shared 64 MiB
|
|
139
|
+
client ceiling. Binding envelope overhead counts toward that budget. Response
|
|
140
|
+
budgets remain separate. No automatic resizing, splitting or truncation occurs.
|
|
151
141
|
|
|
152
142
|
Cloudflare's four-decimal probability precision receives a count-aware sum
|
|
153
143
|
allowance: the larger of 0.001 and half a decimal unit per option, plus floating-point
|
|
@@ -204,19 +194,10 @@ audio/video parts accept only `type` and `dataUrl`; remote URLs, paths, image
|
|
|
204
194
|
detail, and caller-provided durations are rejected. Other providers and the older
|
|
205
195
|
Clef models reject audio/video before dispatch.
|
|
206
196
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Audio and video together are limited to 16 MiB decoded. Image limits above remain
|
|
213
|
-
separate. Bounded inspectors validate canonical base64, MIME/header consistency,
|
|
214
|
-
and container structure, and reject excessive duration when PCM/float WAV,
|
|
215
|
-
ordinary MP3 frames, MP4 metadata, or WebM metadata establishes it reliably.
|
|
216
|
-
Full decoding, codec validity, and duration that cannot be established locally
|
|
217
|
-
(including compressed WAV, free-format MP3, or missing container duration) remain
|
|
218
|
-
service validation. The bridge performs no transcription, transcoding, frame
|
|
219
|
-
extraction, or streaming, and adds no runtime media dependency.
|
|
197
|
+
Inspectors validate canonical base64, MIME/header consistency and supported
|
|
198
|
+
container structure. Service count, decoded-size and duration limits are handled
|
|
199
|
+
as upstream errors. The bridge performs no transcription, transcoding, frame
|
|
200
|
+
extraction or streaming, and adds no runtime media dependency.
|
|
220
201
|
|
|
221
202
|
Cloudflare samples video at two frames per second. Video soundtracks are processed
|
|
222
203
|
only when **every supplied video has a soundtrack**. Common results use
|
|
@@ -302,23 +283,20 @@ binding sends Gateway settings in the third `ai.run()` argument.
|
|
|
302
283
|
|
|
303
284
|
| Setting | Accepted value |
|
|
304
285
|
| --- | --- |
|
|
305
|
-
| `id` | Required nonblank printable ASCII string
|
|
306
|
-
| `cacheKey` | Optional nonblank printable ASCII string
|
|
307
|
-
| `cacheTtl` |
|
|
286
|
+
| `id` | Required nonblank printable ASCII string |
|
|
287
|
+
| `cacheKey` | Optional nonblank printable ASCII string |
|
|
288
|
+
| `cacheTtl` | Nonnegative integer seconds; service cache policy applies upstream |
|
|
308
289
|
| `skipCache`, `collectLog` | Optional booleans |
|
|
309
|
-
| `metadata` |
|
|
290
|
+
| `metadata` | JSON primitive values; caller-supplied `cf.*` keys are reserved |
|
|
310
291
|
| `requestTimeoutMs` | Positive integer milliseconds, up to 2,147,483,647 |
|
|
311
|
-
| `retries.maxAttempts` |
|
|
312
|
-
| `retries.retryDelayMs` |
|
|
292
|
+
| `retries.maxAttempts` | Positive integer; defaults to 1 when Gateway is configured |
|
|
293
|
+
| `retries.retryDelayMs` | Nonnegative integer milliseconds |
|
|
313
294
|
| `retries.backoff` | `constant`, `linear`, or `exponential` |
|
|
314
295
|
|
|
315
296
|
The shared validator rejects invalid Gateway settings with `CONFIGURATION_ERROR`
|
|
316
|
-
before dispatch. Metadata is preserved unchanged
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
describes the upper limit as one month; its [official numeric reference](https://github.com/cloudflare/skills/blob/0cb6116228ad153126f474dce1dfbd05f7944604/skills/cloudflare/references/ai-gateway/README.md)
|
|
320
|
-
specifies 2,592,000 seconds (30 days). Cache TTL and first-response timeout have
|
|
321
|
-
separate validation bounds.
|
|
297
|
+
before dispatch. Metadata is preserved unchanged. Reserved `cf.*` keys and
|
|
298
|
+
non-primitive values are rejected; service entry-count and cache admission
|
|
299
|
+
limits remain upstream. The adapter does not infer Gateway acceptance.
|
|
322
300
|
|
|
323
301
|
Gateway timeout covers time to the first response; the bridge's total deadline
|
|
324
302
|
continues to bound the call. Gateway logging/caching follows the explicit options
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Customizing decisions and extending the bridge
|
|
2
2
|
|
|
3
|
-
Customization is **per request**. You supply context in `state`,
|
|
3
|
+
Customization is **per request**. You supply context in `state`, ordered `input`
|
|
4
|
+
or `conversation` according to provider capabilities, the judgment in
|
|
4
5
|
`instructions`, and the allowed categories/rubric in `criteria`. The same bridge
|
|
5
6
|
instance can evaluate unrelated tasks on successive calls. This changes the
|
|
6
7
|
question sent to the existing model, not its weights or account configuration.
|
|
@@ -79,6 +80,10 @@ const bridge = createBridge({
|
|
|
79
80
|
Extensions run in registration order. They receive immutable snapshots and must
|
|
80
81
|
return replacements rather than mutate input. Async retrieval can use the supplied
|
|
81
82
|
context signal. No content is persisted unless your extension explicitly saves it.
|
|
83
|
+
Use `prepareInput(parts, context)` for ordered input and
|
|
84
|
+
`prepareConversation(items, context)` for conversation history. A preparation
|
|
85
|
+
extension must implement the selected form's hook; transformed content is
|
|
86
|
+
revalidated before dispatch. Observer-only extensions work with every form.
|
|
82
87
|
|
|
83
88
|
## Observe without changing decisions
|
|
84
89
|
|
|
@@ -133,7 +138,8 @@ and [SDK validation contract](../reference/SDK.md#additional-exports).
|
|
|
133
138
|
|
|
134
139
|
## Develop additions without changing the public call
|
|
135
140
|
|
|
136
|
-
Add retrieval/redaction through `prepareState
|
|
141
|
+
Add retrieval/redaction through `prepareState`, `prepareInput` or
|
|
142
|
+
`prepareConversation`, metrics through
|
|
137
143
|
`onResult`, and another protocol through the explicit [custom decision](CUSTOM_DECISION.md)
|
|
138
144
|
or [custom generative](CUSTOM_GENERATIVE.md) contract. Keep routing/threshold policies
|
|
139
145
|
outside the provider and cover additions with relevant regression tests. Persisted templates,
|