@swissspidy/belay-core 0.1.0 → 0.1.1

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.
@@ -0,0 +1,396 @@
1
+ /**
2
+ * Public types for @swissspidy/belay-core. See docs/adr/0001-public-api-confidence-and-calibration.md.
3
+ */
4
+ /** An option of a categorical or ordinal task. Plain strings are shorthand for `{ label }`. */
5
+ export interface OptionSpec {
6
+ /** Stable identifier returned as the task value. */
7
+ label: string;
8
+ /** Optional natural-language hint for the model(s). */
9
+ description?: string;
10
+ }
11
+ export type OptionInput = string | OptionSpec;
12
+ export interface BinarySchema {
13
+ type: 'binary';
14
+ /** The yes/no question, e.g. "Does this comment contain a personal attack?" */
15
+ prompt: string;
16
+ }
17
+ export interface CategoricalSchema<L extends string = string> {
18
+ type: 'categorical';
19
+ options: readonly (L | (OptionSpec & {
20
+ label: L;
21
+ }))[];
22
+ /** Optional question, e.g. "Which department should handle this ticket?" */
23
+ prompt?: string;
24
+ }
25
+ export interface OrdinalSchema<L extends string = string> {
26
+ type: 'ordinal';
27
+ /** Ordered from lowest to highest. */
28
+ options: readonly (L | (OptionSpec & {
29
+ label: L;
30
+ }))[];
31
+ prompt?: string;
32
+ }
33
+ export type ValidationResult = true | {
34
+ valid: false;
35
+ errors: string[];
36
+ };
37
+ export interface StructuredSchema<T = unknown> {
38
+ type: 'structured';
39
+ /** JSON Schema handed to the Prompt API (`responseConstraint`) and to the cloud adapter. */
40
+ jsonSchema: Record<string, unknown>;
41
+ /**
42
+ * Validates a parsed candidate. @swissspidy/belay-core has no runtime dependencies and therefore
43
+ * no JSON Schema validator; plug in your own (Ajv, Zod, a hand-written guard, ...).
44
+ */
45
+ validate: (value: unknown) => value is T;
46
+ prompt?: string;
47
+ }
48
+ export type TaskSchema = BinarySchema | CategoricalSchema | OrdinalSchema | StructuredSchema<any>;
49
+ /** The value type a schema produces. */
50
+ export type ValueOf<S extends TaskSchema> = S extends BinarySchema ? boolean : S extends CategoricalSchema<infer L> ? L : S extends OrdinalSchema<infer L> ? L : S extends StructuredSchema<infer T> ? T : never;
51
+ /** Mirrors the availability states used by Chrome's built-in AI APIs. */
52
+ export type Availability = 'available' | 'downloadable' | 'downloading' | 'unavailable';
53
+ export interface ProbabilityEntry {
54
+ label: string;
55
+ probability: number;
56
+ }
57
+ export interface RunnerContext<S extends TaskSchema = TaskSchema> {
58
+ task: string;
59
+ schema: S;
60
+ /** Optional task-level context shared by local and cloud runners. */
61
+ context?: string;
62
+ signal?: AbortSignal;
63
+ }
64
+ export interface LocalOutput<V = unknown> {
65
+ value: V;
66
+ /**
67
+ * Confidence in [0, 1]. Classifier runners report the calibrated probability of the
68
+ * top option. Generation runners may omit it and let the task's `judge` compute it.
69
+ */
70
+ confidence?: number;
71
+ /** Full distribution when the runner has one (classifier tasks). */
72
+ probabilities?: ProbabilityEntry[];
73
+ /** Runner-specific diagnostics; never sent to telemetry. */
74
+ raw?: unknown;
75
+ }
76
+ export interface LocalRunner<S extends TaskSchema = TaskSchema> {
77
+ /** Short identifier used in telemetry and calibration files, e.g. "classifier-api". */
78
+ readonly id: string;
79
+ /** Must never trigger a model download. */
80
+ availability(ctx: RunnerContext<S>): Promise<Availability>;
81
+ /**
82
+ * Called only when `availability()` resolved to "available". Must never trigger a model download.
83
+ * May throw {@link LocalUnavailableError} if the model became unavailable meanwhile.
84
+ */
85
+ run(input: string, ctx: RunnerContext<S>): Promise<LocalOutput<ValueOf<S>>>;
86
+ /**
87
+ * Download / warm up the model. Call from a user gesture (click handler).
88
+ * Optional: runners without a download step may omit it.
89
+ */
90
+ prepare?(ctx: RunnerContext<S>, options?: PrepareOptions): Promise<void>;
91
+ /** Release resources. */
92
+ destroy?(): void;
93
+ }
94
+ export interface PrepareOptions {
95
+ /** Download progress in [0, 1]. */
96
+ onProgress?: (loaded: number) => void;
97
+ signal?: AbortSignal;
98
+ }
99
+ export interface CloudRequest<S extends TaskSchema = TaskSchema> {
100
+ task: string;
101
+ schema: S;
102
+ /** JSON Schema of the expected output, for providers with structured output. */
103
+ jsonSchema: Record<string, unknown>;
104
+ /** A ready-to-use instruction describing the task and the output format. */
105
+ instruction: string;
106
+ /** Input after redaction. */
107
+ input: string;
108
+ context?: string;
109
+ /** The local attempt, when there was one. Lets a cloud prompt say "a small model guessed X". */
110
+ local?: {
111
+ value: unknown;
112
+ confidence: number | null;
113
+ };
114
+ }
115
+ /**
116
+ * Token usage of one cloud call, as the provider reported it. A call that several models served
117
+ * (e.g. a refusal fallback) reports one part per model.
118
+ */
119
+ export interface CloudUsage {
120
+ /** The model id that served this part, as the provider reports it (keys a `PriceTable`). */
121
+ model?: string;
122
+ inputTokens: number;
123
+ outputTokens: number;
124
+ cacheReadInputTokens?: number;
125
+ cacheWriteInputTokens?: number;
126
+ }
127
+ /** Prices per million tokens. Cache prices default to the input price. */
128
+ export interface TokenPrices {
129
+ input: number;
130
+ output: number;
131
+ cacheRead?: number;
132
+ cacheWrite?: number;
133
+ }
134
+ /** Token prices keyed by the model id the provider reports. */
135
+ export type PriceTable = Record<string, TokenPrices>;
136
+ export interface CloudOutput<V = unknown> {
137
+ value: V;
138
+ /** Optional confidence if the provider exposes one (e.g. from logprobs). */
139
+ confidence?: number;
140
+ /** Token usage, when the provider reports it. Used to measure what calls cost. */
141
+ usage?: CloudUsage | CloudUsage[];
142
+ raw?: unknown;
143
+ }
144
+ export interface CloudRunner<S extends TaskSchema = TaskSchema> {
145
+ readonly id: string;
146
+ /** The returned `value` is validated against the schema by the task (see `parseValue()`). */
147
+ run(request: CloudRequest<S>, options: {
148
+ signal?: AbortSignal;
149
+ }): Promise<CloudOutput>;
150
+ }
151
+ /** Judges a generated output: resolves to P(output is correct and complete) in [0, 1]. */
152
+ export type Judge<V = unknown> = ((args: {
153
+ input: string;
154
+ value: V;
155
+ task: string;
156
+ signal?: AbortSignal;
157
+ }) => Promise<number>) & {
158
+ /** Judges backed by an on-device model can report its state and download it (from a user gesture). */
159
+ availability?(): Promise<Availability>;
160
+ prepare?(options?: PrepareOptions): Promise<void>;
161
+ destroy?(): void;
162
+ };
163
+ /**
164
+ * - `auto`: escalate whenever the cascade decides to (default).
165
+ * - `never`: never send anything to the cloud runner.
166
+ * - `consent`: ask the `consent` callback before every escalation.
167
+ */
168
+ export type EscalationPolicy = 'auto' | 'never' | 'consent';
169
+ export interface ConsentRequest {
170
+ task: string;
171
+ reason: EscalationReason;
172
+ /** The redacted input that would be sent. */
173
+ input: string;
174
+ local: {
175
+ value: unknown;
176
+ confidence: number | null;
177
+ } | null;
178
+ }
179
+ export interface PrivacyOptions {
180
+ escalation?: EscalationPolicy;
181
+ /** Required when `escalation` is `consent`. */
182
+ consent?: (request: ConsentRequest) => boolean | Promise<boolean>;
183
+ /** Applied to the input before any cloud call (and before `consent`). */
184
+ redact?: (input: string) => string | Promise<string>;
185
+ }
186
+ export type EscalationReason =
187
+ /** Local confidence was below the threshold. */
188
+ 'low-confidence'
189
+ /** The local runner reported the model is not ready (unavailable / not downloaded). */
190
+ | 'local-unavailable'
191
+ /** The local runner threw. */
192
+ | 'local-error'
193
+ /** The local runner exceeded `localTimeoutMs`. */
194
+ | 'local-timeout'
195
+ /** The local output failed schema validation. */
196
+ | 'invalid-output';
197
+ /**
198
+ * Why a wanted escalation did not produce the result:
199
+ * - `policy`: escalation is disabled (`never`, no cloud runner, or the redact hook failed);
200
+ * - `consent-denied`: the consent callback returned false (or threw);
201
+ * - `cloud-error`: the cloud runner failed; the local result is returned instead.
202
+ */
203
+ export type EscalationBlock = 'policy' | 'consent-denied' | 'cloud-error';
204
+ export interface BelayResult<V = unknown> {
205
+ value: V;
206
+ /**
207
+ * Confidence of the returned value: the local confidence when `source` is "local";
208
+ * the cloud's own confidence (if its adapter reports one) or `null` when `source` is "cloud".
209
+ */
210
+ confidence: number | null;
211
+ source: 'local' | 'cloud';
212
+ /** Total wall-clock time of `run()`. */
213
+ latencyMs: number;
214
+ /** Why the cascade wanted to escalate; `null` if the local result was accepted. */
215
+ escalationReason: EscalationReason | null;
216
+ /** Set when the cascade wanted to escalate but returned the local result instead. */
217
+ escalationBlocked: EscalationBlock | null;
218
+ /** Threshold in effect for this run. */
219
+ threshold: number;
220
+ /** The local attempt, if the local runner produced an output. */
221
+ local: {
222
+ value: V;
223
+ confidence: number;
224
+ latencyMs: number;
225
+ probabilities?: ProbabilityEntry[];
226
+ } | null;
227
+ }
228
+ export interface RunOptions {
229
+ signal?: AbortSignal;
230
+ /** Per-run override of the task's escalation policy (can only be stricter: see ADR). */
231
+ escalation?: EscalationPolicy;
232
+ /** Per-run context appended to the task context. */
233
+ context?: string;
234
+ }
235
+ export interface TaskOptions<S extends TaskSchema> {
236
+ name: string;
237
+ schema: S;
238
+ local: LocalRunner<NoInfer<S>>;
239
+ /** Optional: without a cloud runner the task behaves as `escalation: 'never'`. */
240
+ cloud?: CloudRunner<NoInfer<S>>;
241
+ /** Fixed threshold. Also used as the fallback when a calibration fails to load. */
242
+ threshold?: number;
243
+ /** A calibration file object, a URL to fetch it from, or a loader. */
244
+ calibration?: CalibrationFile | string | URL | (() => Promise<CalibrationFile>);
245
+ /** Context shared by local and cloud runners, e.g. "Support tickets for a SaaS billing product". */
246
+ context?: string;
247
+ /** For generation tasks: estimates P(correct). Combined with schema validation. */
248
+ judge?: Judge<ValueOf<NoInfer<S>>>;
249
+ privacy?: PrivacyOptions;
250
+ /** Escalate if the local runner takes longer than this. */
251
+ localTimeoutMs?: number;
252
+ onEvent?: (event: BelayEvent) => void;
253
+ }
254
+ export interface Task<S extends TaskSchema> {
255
+ readonly name: string;
256
+ readonly schema: S;
257
+ run(input: string, options?: RunOptions): Promise<BelayResult<ValueOf<S>>>;
258
+ availability(): Promise<Availability>;
259
+ /** Downloads the local model. Call from a user gesture. */
260
+ prepare(options?: PrepareOptions): Promise<void>;
261
+ /** Resolves the threshold (loading the calibration if needed). */
262
+ threshold(): Promise<number>;
263
+ destroy(): void;
264
+ }
265
+ /** Emitted once per run. Never contains the input or the output text of structured tasks. */
266
+ export interface RunEvent {
267
+ type: 'run';
268
+ task: string;
269
+ timestamp: number;
270
+ source: 'local' | 'cloud';
271
+ /** Categorical/ordinal/binary label of the returned value (omitted for structured tasks). */
272
+ label?: string;
273
+ confidence: number | null;
274
+ localConfidence: number | null;
275
+ threshold: number;
276
+ thresholdSource: 'calibration' | 'manual';
277
+ /** `createdAt` of the calibration file in use, to correlate metrics with calibrations. */
278
+ calibratedAt: string | null;
279
+ escalationReason: EscalationReason | null;
280
+ escalationBlocked: EscalationBlock | null;
281
+ latencyMs: number;
282
+ localLatencyMs: number | null;
283
+ cloudLatencyMs: number | null;
284
+ localRunner: string;
285
+ cloudRunner: string | null;
286
+ /** Token usage of the cloud call, when its runner reported it (see `savingsMeter()`). */
287
+ cloudUsage?: CloudUsage[];
288
+ }
289
+ export interface ErrorEvent {
290
+ type: 'error';
291
+ task: string;
292
+ timestamp: number;
293
+ stage: 'local' | 'cloud' | 'calibration' | 'consent' | 'redact';
294
+ message: string;
295
+ }
296
+ export type BelayEvent = RunEvent | ErrorEvent;
297
+ export interface CalibrationCurvePoint {
298
+ threshold: number;
299
+ /** Accuracy of the whole cascade at this threshold. */
300
+ accuracy: number;
301
+ /** Fraction of examples answered locally. */
302
+ localShare: number;
303
+ /** Accuracy on the examples answered locally. */
304
+ localAccuracy: number | null;
305
+ /** Cloud cost per 1,000 runs (in `cost.currency`), when cost data was supplied. */
306
+ costPer1k?: number;
307
+ }
308
+ /**
309
+ * - `fixed`: `value` was given as a number.
310
+ * - `cloud`: the cascade must be at least as accurate as sending everything to the cloud;
311
+ * `value` is the cloud-only accuracy measured on the dataset.
312
+ * - `max`: the most accurate threshold (ties go to the most local share); `value` is that accuracy.
313
+ */
314
+ export type TargetMode = 'fixed' | 'cloud' | 'max';
315
+ export interface CalibrationFile {
316
+ version: 1;
317
+ task: string;
318
+ /** Fingerprint of the task schema (see `schemaFingerprint()`); used to detect stale files. */
319
+ schemaFingerprint: string;
320
+ createdAt: string;
321
+ local: {
322
+ runner: string;
323
+ model?: string;
324
+ userAgent?: string;
325
+ };
326
+ cloud: {
327
+ runner: string;
328
+ model?: string;
329
+ } | null;
330
+ dataset: {
331
+ size: number;
332
+ fingerprint: string;
333
+ };
334
+ target: {
335
+ metric: 'accuracy';
336
+ value: number;
337
+ mode?: TargetMode;
338
+ };
339
+ /** Recommended global threshold. */
340
+ threshold: number;
341
+ /** Optional per-label overrides, keyed by the local top label. */
342
+ thresholds?: Record<string, number>;
343
+ expected: {
344
+ accuracy: number;
345
+ localShare: number;
346
+ localAccuracy: number | null;
347
+ cloudAccuracy: number | null;
348
+ /** Cloud cost per 1,000 runs at the recommended threshold(s). */
349
+ costPer1k?: number;
350
+ /** Cloud cost per 1,000 runs when every run goes to the cloud. */
351
+ cloudOnlyCostPer1k?: number;
352
+ /** `cloudOnlyCostPer1k - costPer1k`. */
353
+ savingsPer1k?: number;
354
+ /**
355
+ * K-fold cross-validated estimate: thresholds fitted on K-1 folds, scored on the held-out
356
+ * fold. The numbers above are fitted and scored on the same data; these are not.
357
+ */
358
+ heldOut?: {
359
+ folds: number;
360
+ accuracy: number;
361
+ localShare: number;
362
+ cloudAccuracy: number;
363
+ costPer1k?: number;
364
+ };
365
+ };
366
+ cost?: {
367
+ currency: string;
368
+ /** Mean cost of one cloud call: measured from token usage, or the configured estimate. */
369
+ cloudPerRun: number;
370
+ /** `measured`: priced from the token usage of every cloud call. `estimate`: a configured flat price. */
371
+ basis?: 'measured' | 'estimate';
372
+ /** The prices used for `measured` costs, per million tokens. */
373
+ prices?: PriceTable;
374
+ /** Mean tokens per cloud call (`measured` only). */
375
+ tokensPerRun?: {
376
+ input: number;
377
+ output: number;
378
+ cacheRead: number;
379
+ cacheWrite: number;
380
+ };
381
+ /** Volume for the savings projection in the report. */
382
+ runsPerMonth?: number;
383
+ };
384
+ curve: CalibrationCurvePoint[];
385
+ /** Histogram of local confidences over the dataset, for drift detection. */
386
+ confidenceHistogram: {
387
+ edges: number[];
388
+ counts: number[];
389
+ };
390
+ confusion?: {
391
+ labels: string[];
392
+ /** `matrix[i][j]`: examples with true label i that the local runner predicted as j. */
393
+ local: number[][];
394
+ };
395
+ }
396
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,+FAA+F;AAC/F,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAE9C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC1D,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,EAAE,CAAC;IACtD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACtD,IAAI,EAAE,SAAS,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,EAAE,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEzE,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C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AAS,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC;QACxF,uDAAuD;QACvD,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,4EAA4E;IAC5E,mBAAmB,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC3D,SAAS,CAAC,EAAE;QACV,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,uFAAuF;QACvF,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;KACnB,CAAC;CACH"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Public types for @swissspidy/belay-core. See docs/adr/0001-public-api-confidence-and-calibration.md.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swissspidy/belay-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Confidence-based escalation from on-device to cloud AI: tasks, cascade logic, confidence, calibration types.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Pascal Birchler",
@@ -36,7 +36,8 @@
36
36
  "src"
37
37
  ],
38
38
  "scripts": {
39
- "build": "tsc -b"
39
+ "build": "tsc -b",
40
+ "prepack": "tsc -b --force"
40
41
  },
41
42
  "publishConfig": {
42
43
  "access": "public"