runbios-sdk 0.2.1-dev.106 → 0.2.1-dev.107

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/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ import { Loop } from './resources/loop.js';
35
35
  * SDK version. Sent as part of the User-Agent header.
36
36
  * Must match package.json "version" -- enforced by a contract test.
37
37
  */
38
- export declare const VERSION = "0.2.1-dev.106";
38
+ export declare const VERSION = "0.2.1-dev.107";
39
39
  export declare class RunBiOS {
40
40
  /** Search models, fetch configs, check adapter compatibility. */
41
41
  readonly models: Models;
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ import { Loop } from './resources/loop.js';
35
35
  * SDK version. Sent as part of the User-Agent header.
36
36
  * Must match package.json "version" -- enforced by a contract test.
37
37
  */
38
- export const VERSION = '0.2.1-dev.106';
38
+ export const VERSION = '0.2.1-dev.107';
39
39
  export class RunBiOS {
40
40
  /** Search models, fetch configs, check adapter compatibility. */
41
41
  models;
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { LoopTrace, LoopTraceListResponse, LoopTraceListParams, LoopCaptureParams, LoopCaptureResult, LoopSignal, LoopSignalParams, LoopCandidate, LoopCandidateParams, LoopDataset, LoopDatasetListParams, LoopDatasetItem, LoopDatasetCreateParams, LoopConfig, LoopConfigParams, LoopStats } from '../types.js';
2
+ import type { LoopTrace, LoopTraceListResponse, LoopTraceListParams, LoopCaptureParams, LoopCaptureResult, LoopSignal, LoopSignalParams, LoopCandidate, LoopCandidateParams, LoopGrader, LoopGraderParams, LoopGradeResult, LoopDataset, LoopDatasetListParams, LoopDatasetItem, LoopDatasetCreateParams, LoopConfig, LoopConfigParams, LoopStats } from '../types.js';
3
3
  /**
4
4
  * The Conscious Loop -- capture what your model was asked and answered, record
5
5
  * whether it was right, and turn those judgements into training data.
@@ -172,6 +172,47 @@ export declare class Loop {
172
172
  deleted: boolean;
173
173
  dataset_id: string;
174
174
  }>;
175
+ /**
176
+ * Write a rule that scores answers without a person.
177
+ *
178
+ * Human review is the most trustworthy feedback and the least available. A
179
+ * grader is written once and applied to every answer afterwards: did it
180
+ * contain the required phrase, did it parse as the schema you asked for, is
181
+ * the number within tolerance of the known answer, did it call the function
182
+ * it should have.
183
+ *
184
+ * Every kind here is DETERMINISTIC -- no model call, no network. That is why
185
+ * a verifier outranks a judge when they disagree: it cannot be flattered and
186
+ * it cannot drift between runs.
187
+ *
188
+ * `weight` is the multiplier: a criterion that matters twice as much gets
189
+ * twice the weight, and the combined score is the weighted mean over the
190
+ * rules that actually applied.
191
+ *
192
+ * A caution worth knowing before you write a set: a rule made only of
193
+ * `forbidden` phrases is satisfied VACUOUSLY by an answer that says nothing.
194
+ * Pair it with a `required` phrase, or you are rewarding silence.
195
+ */
196
+ createGrader(params: LoopGraderParams): Promise<LoopGrader>;
197
+ /** Every rule this workspace has written. */
198
+ listGraders(): Promise<LoopGrader[]>;
199
+ deleteGrader(id: string): Promise<{
200
+ deleted: boolean;
201
+ grader_id: string;
202
+ }>;
203
+ /**
204
+ * Apply this workspace's rules to one captured answer AND to every
205
+ * alternative sampled for it.
206
+ *
207
+ * Grading both in one pass is the point: scoring only the original gives a
208
+ * verdict, while scoring the samples as well gives the preference pair. Sample
209
+ * your model, call this, and you have DPO data with nobody reading anything.
210
+ *
211
+ * A run where no rule could apply writes NOTHING -- no verdict, no scores.
212
+ * Recording a zero that no rule produced would poison curation with a
213
+ * judgement nobody reached, so `applied: 0` is reported instead.
214
+ */
215
+ grade(traceId: string): Promise<LoopGradeResult>;
175
216
  /** Every source this workspace has configured. */
176
217
  listConfigs(): Promise<LoopConfig[]>;
177
218
  /**
@@ -236,6 +236,55 @@ export class Loop {
236
236
  async deleteDataset(id) {
237
237
  return this._http.fetchDelete(`/api/loop/datasets/${encodeURIComponent(id)}`);
238
238
  }
239
+ // ── graders ───────────────────────────────────────────────────────────
240
+ /**
241
+ * Write a rule that scores answers without a person.
242
+ *
243
+ * Human review is the most trustworthy feedback and the least available. A
244
+ * grader is written once and applied to every answer afterwards: did it
245
+ * contain the required phrase, did it parse as the schema you asked for, is
246
+ * the number within tolerance of the known answer, did it call the function
247
+ * it should have.
248
+ *
249
+ * Every kind here is DETERMINISTIC -- no model call, no network. That is why
250
+ * a verifier outranks a judge when they disagree: it cannot be flattered and
251
+ * it cannot drift between runs.
252
+ *
253
+ * `weight` is the multiplier: a criterion that matters twice as much gets
254
+ * twice the weight, and the combined score is the weighted mean over the
255
+ * rules that actually applied.
256
+ *
257
+ * A caution worth knowing before you write a set: a rule made only of
258
+ * `forbidden` phrases is satisfied VACUOUSLY by an answer that says nothing.
259
+ * Pair it with a `required` phrase, or you are rewarding silence.
260
+ */
261
+ async createGrader(params) {
262
+ const res = await this._http.fetchPost('/api/loop/graders', params);
263
+ return res.grader;
264
+ }
265
+ /** Every rule this workspace has written. */
266
+ async listGraders() {
267
+ const res = await this._http.fetchGet('/api/loop/graders');
268
+ return res.graders;
269
+ }
270
+ async deleteGrader(id) {
271
+ return this._http.fetchDelete(`/api/loop/graders/${encodeURIComponent(id)}`);
272
+ }
273
+ /**
274
+ * Apply this workspace's rules to one captured answer AND to every
275
+ * alternative sampled for it.
276
+ *
277
+ * Grading both in one pass is the point: scoring only the original gives a
278
+ * verdict, while scoring the samples as well gives the preference pair. Sample
279
+ * your model, call this, and you have DPO data with nobody reading anything.
280
+ *
281
+ * A run where no rule could apply writes NOTHING -- no verdict, no scores.
282
+ * Recording a zero that no rule produced would poison curation with a
283
+ * judgement nobody reached, so `applied: 0` is reported instead.
284
+ */
285
+ async grade(traceId) {
286
+ return this._http.fetchPost(`/api/loop/traces/${encodeURIComponent(traceId)}/grade`);
287
+ }
239
288
  // ── capture settings ──────────────────────────────────────────────────
240
289
  /** Every source this workspace has configured. */
241
290
  async listConfigs() {
package/dist/types.d.ts CHANGED
@@ -2167,3 +2167,65 @@ export interface LoopCandidate {
2167
2167
  metadata: Record<string, unknown>;
2168
2168
  created_at: string;
2169
2169
  }
2170
+ /** The deterministic checks a grader can perform. */
2171
+ export type LoopGraderKind = 'exact_match' | 'contains' | 'regex' | 'json_valid' | 'numeric' | 'tool_called';
2172
+ export interface LoopGraderConfig {
2173
+ expected?: string;
2174
+ /** Every phrase that must appear. */
2175
+ required?: string[];
2176
+ /** Phrases that must not. On their own these are passed by silence. */
2177
+ forbidden?: string[];
2178
+ pattern?: string;
2179
+ /** Keys the answer must carry, for `json_valid`. */
2180
+ keys?: string[];
2181
+ /** How far from `expected` still counts, for `numeric`. */
2182
+ tolerance?: number;
2183
+ /** The function that must have been called, for `tool_called`. */
2184
+ function?: string;
2185
+ case_sensitive?: boolean;
2186
+ }
2187
+ export interface LoopGraderParams {
2188
+ name: string;
2189
+ kind: LoopGraderKind;
2190
+ config: LoopGraderConfig;
2191
+ /** The multiplier. Twice as important, twice the weight. Must exceed zero. */
2192
+ weight?: number;
2193
+ enabled?: boolean;
2194
+ /** Limit the rule to one capture source. Omit to apply it everywhere. */
2195
+ deployment_id?: string;
2196
+ }
2197
+ export interface LoopGrader extends LoopGraderParams {
2198
+ id: string;
2199
+ workspace_id: string;
2200
+ weight: number;
2201
+ enabled: boolean;
2202
+ created_by: string | null;
2203
+ created_at: string;
2204
+ updated_at: string;
2205
+ }
2206
+ export interface LoopGraderResult {
2207
+ grader_id: string;
2208
+ name: string;
2209
+ kind: string;
2210
+ weight: number;
2211
+ passed: boolean;
2212
+ score: number;
2213
+ /** What happened, in words -- "failed" alone sends you to read the rule. */
2214
+ detail: string;
2215
+ /** The rule had no opinion. Excluded from the score rather than counted 0. */
2216
+ skipped: boolean;
2217
+ }
2218
+ export interface LoopGradeReport {
2219
+ /** Weighted mean over the rules that applied, 0 to 1. */
2220
+ score: number;
2221
+ results: LoopGraderResult[];
2222
+ /** The denominator. 1.0 from one rule is not 1.0 from six. */
2223
+ applied: number;
2224
+ skipped: number;
2225
+ }
2226
+ export interface LoopGradeResult {
2227
+ report: LoopGradeReport;
2228
+ /** Null when no rule applied, because no verdict was invented. */
2229
+ signal_id: string | null;
2230
+ candidates_graded: number;
2231
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runbios-sdk",
3
- "version": "0.2.1-dev.106",
3
+ "version": "0.2.1-dev.107",
4
4
  "description": "Official TypeScript SDK for the Run BiOS training and deployment platform API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",