runbios-sdk 0.2.17-rc.269 → 0.2.18-dev.271

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.
@@ -1,12 +1,18 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { LoopTrace, LoopTraceListResponse, LoopTraceListParams, LoopCaptureParams, LoopCaptureResult, LoopImportParams, LoopImportResult, LoopSignal, LoopSignalParams, LoopCandidate, LoopCandidateParams, LoopGrader, LoopGraderParams, LoopLabel, LoopLabelCount, LoopGradeResult, LoopDataset, LoopDatasetListParams, LoopDatasetItem, LoopDatasetCreateParams, LoopConfig, LoopConfigParams, LoopBuildRule, LoopBuildRuleParams, LoopBuildRuleUpdateParams, LoopStats, LoopJudge, LoopJudgeParams, LoopAgentCredential, LoopAgentStatus, LoopSampleRun, LoopSampleRunParams, LoopJudgeRun, LoopJudgeRunItems, LoopJudgeRunItemStatus, LoopJudgeWork, LoopJudgeVerdict, LoopJudgeVerdictResult, TrainingRule, TrainingRulePreflight, TrainingRulePreflightRequest, TrainingRuleCreateRequest, TrainingRuleUpdateRequest, TrainingRuleConsentRequest, TrainingRuleListParams, TrainingRuleListResponse, TrainingRuleResponse, TrainingRuleMutationResponse, TrainingRuleDeleteResponse, TrainingRun, TrainingRunListParams, TrainingRunListResponse, TrainingRunResponse, TrainingRunActionResponse, TrainingRunPromoteRequest, TrainingRunRejectRequest, TrainingRunRollbackRequest, TrainingRunCancelRequest, Evaluation, EvaluationItemListParams, EvaluationItemsResponse, JudgeAgreement, JudgeAgreementParams, Benchmark, BenchmarkCreateParams, BenchmarkHistoryParams, BenchmarkHistoryResponse, BenchmarkItemListParams, BenchmarkItemsResponse, BenchmarkListParams, BenchmarkListResponse, BenchmarkRetireParams, BenchmarkRun, TrainingRuleBenchmarkRequest, AgentSettings, AgentSettingsRequest, Pipeline, PipelineListResponse } from '../types.js';
2
+ import type { LoopTrace, LoopTraceListResponse, LoopTraceListParams, LoopCaptureParams, LoopCaptureResult, LoopImportParams, LoopImportResult, LoopSignal, LoopSignalParams, LoopLabel, LoopLabelCount, LoopConfig, LoopConfigParams, LoopStats, LoopTracePipelinesResponse, LoopMetricsHistory, LoopMetricsHistoryParams, TrainingRuleDeleteResponse, TrainingRunListParams, TrainingRunListResponse, TrainingRunResponse, TrainingRunActionResponse, TrainingRunPromoteRequest, TrainingRunRejectRequest, TrainingRunRollbackRequest, TrainingRunCancelRequest, Evaluation, EvaluationItemListParams, EvaluationItemsResponse, Benchmark, BenchmarkCreateParams, BenchmarkHistoryParams, BenchmarkHistoryResponse, BenchmarkItemListParams, BenchmarkItemsResponse, BenchmarkListParams, BenchmarkListResponse, BenchmarkRetireParams, BenchmarkRun, Pipeline, PipelineListParams, PipelineListResponse, PipelineWriteRequest, PipelineMutationResponse, LoopModelsResponse, PipelineImportParams, PipelineBenchmarksResponse, PipelineBenchmarkAttachParams, PipelineBenchmarkMoveParams, VersionCompareResponse, VersionCompareParams } from '../types.js';
3
3
  /**
4
- * The Conscious Loop -- capture what your model was asked and answered, record
5
- * whether it was right, and turn those judgements into training data.
4
+ * The Conscious Loop -- pipelines that keep improving a model from the
5
+ * conversations you send them.
6
6
  *
7
- * Nothing is captured until you turn it on for a source, and you can turn it
8
- * off again at any time. Anything that looks like a credential or a personal
9
- * detail is removed before the record is written, never afterwards.
7
+ * A pipeline is one use case: a model, the tags whose samples train it, when
8
+ * to train, and how a new version is promoted. Every time it trains it makes
9
+ * an attempt; an attempt that beats the live model becomes the next version.
10
+ *
11
+ * Nothing is captured until a source is switched on, and you can switch it
12
+ * off again at any time. Creating a pipeline switches on the source named by
13
+ * its own tag (`own_tag`), stamping that tag, and deleting it switches that
14
+ * source off again. Anything that looks like a credential or a personal detail
15
+ * is removed before the record is written, never afterwards.
10
16
  *
11
17
  * Requires an API key carrying `loop:read` and/or `loop:write`. Those scopes are
12
18
  * deliberately absent from the Read Only preset, because what they return is
@@ -19,28 +25,30 @@ import type { LoopTrace, LoopTraceListResponse, LoopTraceListParams, LoopCapture
19
25
  *
20
26
  * @example
21
27
  * ```ts
22
- * // 1. Decide that this source is recorded.
23
- * await client.loop.setConfig('my-agent', { enabled: true, retention_days: 30 });
28
+ * // 1. A pipeline: a model it can train, and its own tag.
29
+ * const { models } = await client.loop.listModels();
30
+ * const { pipeline } = await client.loop.createPipeline({
31
+ * name: 'Support replies',
32
+ * model: { id: models[0].id },
33
+ * });
24
34
  *
25
- * // 2. Send what your model was asked and what it answered. Works whoever
26
- * // served it -- us, another provider, or your own servers.
27
- * const { trace_id } = await client.loop.capture({
28
- * deployment_id: 'my-agent',
35
+ * // 2. Send samples from your app to the pipeline's own source: its create
36
+ * // switched that source on, and it tags everything it records.
37
+ * const sent = await client.loop.capture({
38
+ * deployment_id: pipeline.own_tag!,
29
39
  * model: 'gpt-4o',
30
40
  * messages: [{ role: 'user', content: 'what is our refund window' }],
31
41
  * completion: 'thirty days',
32
42
  * });
33
43
  *
34
- * // 3. Say whether it was right. A rewrite is the most valuable answer here:
35
- * // the model learns your version AND learns to avoid its own.
36
- * await client.loop.signal(trace_id, {
37
- * verdict: 'edited',
38
- * correction: 'Thirty days from delivery, no questions asked.',
39
- * });
44
+ * // 3. Say whether it was right, on the trace_id the capture answered with.
45
+ * // A correction is the most valuable answer.
46
+ * if (sent.trace_id) {
47
+ * await client.loop.correct(sent.trace_id, 'Thirty days from delivery, no questions asked.');
48
+ * }
40
49
  *
41
- * // 4. Turn the judgements into a training set and take the file.
42
- * const ds = await client.loop.createDataset({ name: 'support', method: 'sft' });
43
- * const jsonl = await client.loop.downloadDataset(ds.id);
50
+ * // 4. Once it has its minimum, it trains; versions appear on the pipeline.
51
+ * const p = await client.loop.getPipeline(pipeline.rule_id);
44
52
  * ```
45
53
  */
46
54
  export declare class Loop {
@@ -57,19 +65,25 @@ export declare class Loop {
57
65
  *
58
66
  * The returned `trace_id` is OURS. If you pass your own `request_id` it is
59
67
  * kept as an idempotency handle: sending the same one again returns the same
60
- * trace rather than storing a second copy, so a retry is safe.
68
+ * trace rather than storing a second copy, so a retry is safe. Send feedback
69
+ * on that `trace_id`.
70
+ *
71
+ * `deployment_id` is the source. A pipeline's `own_tag` is a source its
72
+ * create switched on, and it stamps that tag on everything it records;
73
+ * `labels` add tags of your own, so the same conversation can feed other
74
+ * pipelines too.
61
75
  *
62
- * When the source is not enabled this resolves with `captured: false` and a
63
- * reason instead of throwing -- capture must never be the thing that breaks
64
- * your application.
76
+ * When the source is not switched on this resolves with `captured: false`
77
+ * and a reason instead of throwing -- capture must never be the thing that
78
+ * breaks your application.
65
79
  */
66
80
  capture(params: LoopCaptureParams): Promise<LoopCaptureResult>;
67
81
  /**
68
82
  * Bring data you already have into the loop.
69
83
  *
70
- * This does NOT create a training set. It creates conversations, in the same
71
- * place captured ones live and subject to the same review, rules, judges and
72
- * labels. A row becomes trainable when something says it is good, never
84
+ * This does NOT create a training set. It creates conversations (samples),
85
+ * in the same place captured ones live and subject to the same feedback and
86
+ * tags. A row becomes trainable when something says it is good, never
73
87
  * because it arrived in a file -- which is the one guarantee that separates
74
88
  * a corpus from a pile.
75
89
  *
@@ -190,36 +204,15 @@ export declare class Loop {
190
204
  /** Every verdict on one conversation, oldest first. */
191
205
  listSignals(traceId: string): Promise<LoopSignal[]>;
192
206
  /**
193
- * Submit an alternative answer to a prompt already captured.
194
- *
195
- * This is what makes preference learning scale. A human rewrite is the best
196
- * signal there is and the least available -- somebody has to sit down and
197
- * write it. Sample the model several times for the same prompt, score the
198
- * samples, and a DPO pair falls out automatically: best becomes chosen,
199
- * worst becomes rejected. Point a stronger model at the prompt instead and
200
- * the same machinery does distillation.
201
- *
202
- * Score them, or they cannot pair: an unscored alternative says nothing about
203
- * which answer anybody prefers. `score_source` is required alongside a score,
204
- * because precedence between a verifier, a judge and a person is the whole
205
- * reason we record who judged.
206
- *
207
- * A human correction always outranks any score.
208
- *
209
- * @example
210
- * ```ts
211
- * for (const sample of await sampleMyModel(prompt, 4)) {
212
- * await client.loop.addCandidate(traceId, {
213
- * completion: sample.text,
214
- * score: await myVerifier(sample.text),
215
- * score_source: 'verifier',
216
- * });
217
- * }
218
- * ```
219
- */
220
- addCandidate(traceId: string, params: LoopCandidateParams): Promise<LoopCandidate>;
221
- /** Every alternative answer recorded for one prompt, oldest first. */
222
- listCandidates(traceId: string): Promise<LoopCandidate[]>;
207
+ * The pipelines one conversation feeds: every live pipeline whose tags
208
+ * select it, and whether each is switched on.
209
+ *
210
+ * Being listed means the pipeline would select it, not that it will be
211
+ * trained on -- a set still drops answers it cannot use and duplicates, and
212
+ * holds some back to judge by; `note` says so. An empty list is a real
213
+ * answer: the conversation trains nothing until it carries a pipeline's tag.
214
+ */
215
+ getTracePipelines(traceId: string): Promise<LoopTracePipelinesResponse>;
223
216
  /**
224
217
  * Label a conversation, so it can be selected later.
225
218
  *
@@ -273,139 +266,6 @@ export declare class Loop {
273
266
  * conversations in it that nobody had put there.
274
267
  */
275
268
  listLabels(): Promise<LoopLabelCount[]>;
276
- /**
277
- * Build a training set from the feedback recorded so far.
278
- *
279
- * The three methods need genuinely different things, so one set cannot be
280
- * reshaped into another afterwards:
281
- *
282
- * - `sft` -- answers you marked right, and answers you rewrote.
283
- * - `dpo` -- answers you REWROTE, so a better and a worse version of the same
284
- * reply exist. Nothing else produces a pair.
285
- * - `grpo` -- answers with a value or fact they can be checked against, or
286
- * a judge rubric, which scores answers the run has not written yet.
287
- * - `kto` -- anything carrying a yes or a no, INCLUDING a thumbs-down with
288
- * nothing written. That row trains nothing under the other three methods,
289
- * which is why this one exists: it is the feedback people actually give.
290
- *
291
- * `holdout_percent` holds back your most recent work rather than a random
292
- * slice, so the evaluation measures whether the model generalised instead of
293
- * memorised the same week.
294
- *
295
- * The result always reports `rejected_counts`: why rows were left out. A
296
- * small set with a reason is useful; a small set without one is just alarming.
297
- */
298
- createDataset(params: LoopDatasetCreateParams): Promise<LoopDataset>;
299
- /** List training sets, newest first. */
300
- /**
301
- * Stand up a rule that builds a set whenever enough new work exists.
302
- *
303
- * The manual path asks somebody to notice that enough conversations have
304
- * been reviewed, remember which filters describe the slice they want, and
305
- * press build — every time. A rule is that instruction, stored.
306
- *
307
- * `spec` is the same selection `createDataset` takes and is replayed
308
- * verbatim, so an automatic set is identical to a hand-made one.
309
- *
310
- * `min_new_rows` counts only work reviewed SINCE THE LAST BUILD. Counting
311
- * the whole corpus would fire the rule every interval forever, because a
312
- * total that has crossed a threshold stays across it. It is at least 100,
313
- * and 100 when absent: a set built from fewer is too small to learn from.
314
- */
315
- createBuildRule(params: LoopBuildRuleParams): Promise<LoopBuildRule>;
316
- /**
317
- * Every build rule, with what each one last did and why.
318
- *
319
- * `last_reason` is the field worth reading: a rule quiet because it is
320
- * waiting looks exactly like one quiet because it is broken.
321
- */
322
- listBuildRules(): Promise<LoopBuildRule[]>;
323
- /** Stop a standing build rule. Sets it already produced are untouched. */
324
- deleteBuildRule(id: string): Promise<{
325
- deleted: boolean;
326
- }>;
327
- listDatasets(params?: LoopDatasetListParams): Promise<LoopDataset[]>;
328
- /** Read one training set and its curation report. */
329
- getDataset(id: string): Promise<LoopDataset>;
330
- /**
331
- * Page through the rows a training set actually contains.
332
- *
333
- * Worth reading before you spend money on a run: each row carries the address
334
- * of the conversation it was built from.
335
- */
336
- listDatasetItems(id: string, params?: {
337
- limit?: number;
338
- offset?: number;
339
- }): Promise<LoopDatasetItem[]>;
340
- /**
341
- * Download a training set as JSONL -- one training row per line, the format
342
- * every trainer in this space reads.
343
- *
344
- * `split` defaults to the training rows; pass `holdout` for the slice held
345
- * back, or `all` for both.
346
- */
347
- downloadDataset(id: string, split?: 'train' | 'holdout' | 'all'): Promise<string>;
348
- /**
349
- * Delete a training set.
350
- *
351
- * The conversations it was built from are untouched -- a set is a selection,
352
- * and discarding the selection must not discard the evidence. A set a
353
- * training run was trained on is refused `409 DATASET_IN_USE` and kept, as
354
- * the record of what that run learned from. See
355
- * `LoopDatasetDeleteRefusalCode`.
356
- */
357
- deleteDataset(id: string): Promise<{
358
- deleted: boolean;
359
- dataset_id: string;
360
- }>;
361
- /**
362
- * Write a rule that scores answers without a person.
363
- *
364
- * Human review is the most trustworthy feedback and the least available. A
365
- * grader is written once and applied to every answer afterwards: did it
366
- * contain the required phrase, did it parse as the schema you asked for, is
367
- * the number within tolerance of the known answer, did it call the function
368
- * it should have.
369
- *
370
- * Every kind here is DETERMINISTIC -- no model call, no network. That is why
371
- * a verifier outranks a judge when they disagree: it cannot be flattered and
372
- * it cannot drift between runs.
373
- *
374
- * `weight` is the multiplier: a criterion that matters twice as much gets
375
- * twice the weight, and the combined score is the weighted mean over the
376
- * rules that actually applied.
377
- *
378
- * `matches_gold` needs no `expected`: it compares each answer to the gold
379
- * answer recorded on that same conversation, or the human correction when
380
- * there is no gold, and scores sampled alternatives against the same gold.
381
- * A conversation with neither is skipped, not failed, so one rule checks
382
- * every labelled question without punishing the unlabelled ones. An
383
- * optional `tolerance` widens the match when both sides are bare numbers.
384
- *
385
- * A caution worth knowing before you write a set: a rule made only of
386
- * `forbidden` phrases is satisfied VACUOUSLY by an answer that says nothing.
387
- * Pair it with a `required` phrase, or you are rewarding silence.
388
- */
389
- createGrader(params: LoopGraderParams): Promise<LoopGrader>;
390
- /** Every rule this workspace has written. */
391
- listGraders(): Promise<LoopGrader[]>;
392
- deleteGrader(id: string): Promise<{
393
- deleted: boolean;
394
- grader_id: string;
395
- }>;
396
- /**
397
- * Apply this workspace's rules to one captured answer AND to every
398
- * alternative sampled for it.
399
- *
400
- * Grading both in one pass is the point: scoring only the original gives a
401
- * verdict, while scoring the samples as well gives the preference pair. Sample
402
- * your model, call this, and you have DPO data with nobody reading anything.
403
- *
404
- * A run where no rule could apply writes NOTHING -- no verdict, no scores.
405
- * Recording a zero that no rule produced would poison curation with a
406
- * judgement nobody reached, so `applied: 0` is reported instead.
407
- */
408
- grade(traceId: string): Promise<LoopGradeResult>;
409
269
  /** Every source this workspace has configured. */
410
270
  listConfigs(): Promise<LoopConfig[]>;
411
271
  /**
@@ -425,299 +285,23 @@ export declare class Loop {
425
285
  */
426
286
  setConfig(source: string, params: LoopConfigParams): Promise<LoopConfig>;
427
287
  /**
428
- * How much there is, and how much of it each method could actually use.
288
+ * How much there is, and how many samples a pipeline could train on now
289
+ * (`ready.sft`: the ones marked good or corrected).
429
290
  *
430
- * The `ready` numbers are upper bounds: duplicate questions are folded into
431
- * one row while a set is built, so the finished count can be lower.
291
+ * `ready.sft` is an upper bound: duplicates, the held-back set and
292
+ * conversations too long to train on come out of it when an attempt trains.
432
293
  */
433
294
  stats(): Promise<LoopStats>;
434
- /** Write a rubric: what makes an answer good here, and what to score. */
435
- createJudge(params: LoopJudgeParams): Promise<LoopJudge>;
436
- listJudges(): Promise<LoopJudge[]>;
437
295
  /**
438
- * Rewrite a rubric. Runs already recorded keep the instructions they used:
439
- * a verdict has to keep meaning what it meant when it was given.
296
+ * How the loop moved over time: every attempt as a point, oldest first --
297
+ * its attempt number, the version it became (null when it did not), its
298
+ * base model, its win rate, what it cost -- and each day's feedback counted
299
+ * by verdict. `rule_id` narrows the attempts to one pipeline; the feedback
300
+ * counts are the workspace's. `truncated` says older attempts exist beyond
301
+ * `limit`.
440
302
  */
441
- updateJudge(judgeId: string, params: LoopJudgeParams): Promise<LoopJudge>;
442
- /**
443
- * Retire a rubric. Its runs go with it; the verdicts they wrote stay. A score
444
- * is evidence about an answer, and it does not stop being true because the
445
- * rubric was retired.
446
- */
447
- deleteJudge(judgeId: string): Promise<void>;
448
- /**
449
- * Open a run: select the conversations now, and freeze the rubric onto them.
450
- *
451
- * The selection is fixed at this moment on purpose. A run whose selection is
452
- * a live query silently grows as conversations arrive, so "we scored the
453
- * refunds slice" becomes a claim about a set that no longer exists.
454
- */
455
- startRun(judgeId: string, limit?: number): Promise<LoopJudgeRun>;
456
- listRuns(judgeId?: string): Promise<LoopJudgeRun[]>;
457
- getRun(runId: string): Promise<LoopJudgeRun>;
458
- /**
459
- * Take the next conversations to score, each rendered into a ready-to-send
460
- * prompt. Nothing is marked taken, so a caller that dies half way loses
461
- * nothing: ask again and the same items come back.
462
- */
463
- takeWork(runId: string, limit?: number): Promise<LoopJudgeWork>;
464
- /**
465
- * What happened to each conversation in a run, and why.
466
- *
467
- * `takeWork` hands out what is still PENDING, so a finished run answers it
468
- * with an empty list. This answers with every item and the outcome on it:
469
- * `status`, `scored_at`, and `error` — the reason the caller gave for an
470
- * item it could not score, which is where a wrong model slug or a refused
471
- * key actually shows up. A run that ends "scored 0, failed 3" is otherwise a
472
- * number with no detail behind it.
473
- *
474
- * Pass `status: 'failed'` for the usual question. At most 500 items come
475
- * back at a time; when `has_more` is true, call again with the `next_offset`
476
- * from the reply.
477
- */
478
- listRunItems(runId: string, opts?: {
479
- status?: LoopJudgeRunItemStatus;
480
- limit?: number;
481
- offset?: number;
482
- }): Promise<LoopJudgeRunItems>;
483
- /**
484
- * Hand the scores back. A verdict for a conversation outside this run, or
485
- * scoring something the rubric never asked for, is refused and reported in
486
- * `rejected` rather than silently dropped.
487
- *
488
- * Pass `finish` to close the run in the same call once you have nothing left
489
- * to send. To close a run WITHOUT scores, call `stopRun`: an empty verdict
490
- * list with `finish` does the same thing and reads like a mistake.
491
- */
492
- postVerdicts(runId: string, verdicts: LoopJudgeVerdict[], finish?: boolean): Promise<LoopJudgeVerdictResult>;
493
- /**
494
- * Close a run that has not finished.
495
- *
496
- * A judge may have one open run of its own at a time, so an open run BLOCKS
497
- * the next one, and the runs that most need closing are the ones nobody can
498
- * wait out: a run the agent has parked on an empty balance or a refused key
499
- * stays open until the reason is fixed or somebody stops it.
500
- *
501
- * Nothing is deleted. Every verdict already recorded stays recorded, the
502
- * counters keep saying how much of the selection was covered, and the
503
- * conversations the run was holding are free for the next one. The run ends
504
- * as `stopped` rather than `done`, so an interrupted pass and a completed
505
- * one do not read alike.
506
- *
507
- * A run that finished on its own is not rewritten: stopping one answers 409.
508
- *
509
- * Returns the stopped run itself, like `startRun` and `getRun`, not the
510
- * `{run}` envelope the service sends. Every other single-run method in this
511
- * class unwraps, and `Loop.stop_run` in the Python SDK does too, so a
512
- * caller who wrote `(await loop.stopRun(id)).status` against one of its
513
- * siblings is right here as well.
514
- */
515
- stopRun(runId: string): Promise<LoopJudgeRun>;
516
- /**
517
- * Can an agent run here, is one running, and is it on for this workspace.
518
- * `available` is about the environment; `online` about the worker;
519
- * `credential` about this workspace.
520
- */
521
- agentStatus(): Promise<LoopAgentStatus>;
522
- /**
523
- * Turn the agent on: mints the workspace's managed serverless key and
524
- * resumes the automatic judges a previous turn-off paused. After this,
525
- * automatic judges and sample runs make model calls billed to the
526
- * workspace. Idempotent.
527
- *
528
- * A judge whose model the serving gateway will not route is NOT resumed:
529
- * making it automatic would buy a run that fails every conversation. It
530
- * stays paused, `judges_still_paused` counts those, and each one carries
531
- * `auto_pause_reason` saying so. Point it at a model that is served and
532
- * turn the agent on again.
533
- *
534
- * `monthly_spend_cap_cents` caps what that key may spend on model calls in
535
- * a calendar month. Omitted = no cap on a fresh key, and an existing cap is
536
- * left as it is; sent while the agent is already on, it moves the cap on
537
- * the existing key without minting a new one. When the cap is reached the
538
- * agent's model calls are refused until next month and its runs pause with
539
- * that reason.
540
- */
541
- enableAgent(opts?: {
542
- monthly_spend_cap_cents?: number;
543
- }): Promise<LoopAgentCredential>;
544
- /**
545
- * Turn the agent off: revokes its key and pauses every automatic judge in
546
- * the workspace (`judges_paused`; each judge shows `auto_paused`). Turning
547
- * it back on resumes exactly those judges. Open runs stop where they are
548
- * and continue if it is turned back on. Nothing already scored or written
549
- * is removed.
550
- */
551
- disableAgent(): Promise<{
552
- revoked: boolean;
553
- judges_paused: number;
554
- message: string;
555
- }>;
556
- /**
557
- * Ask the agent to write `n` alternative answers to each conversation in a
558
- * slice with `model`, score each with `judge_id`, and store them as
559
- * candidates. This is how preference pairs are made without a person
560
- * writing each one: the curation pass pairs the best sample against the
561
- * worst wherever the gap is real.
562
- *
563
- * Cost: up to `n` calls to write plus `n` to judge, per conversation, at the
564
- * workspace's serverless rate; `selection.sample` caps the conversations
565
- * (max 200) and `n` is capped at 8. Opening a run turns the agent on if it
566
- * is off.
567
- */
568
- createSampleRun(params: LoopSampleRunParams): Promise<LoopSampleRun>;
569
- listSampleRuns(): Promise<LoopSampleRun[]>;
570
- getSampleRun(runId: string): Promise<LoopSampleRun>;
571
- /**
572
- * Price a training rule before anyone agrees to it. Writes nothing.
573
- *
574
- * Takes the create body without `accept_terms` and answers with the estimate
575
- * a member has to see first: the pinned model revision, the worst hourly
576
- * price each GPU ladder can reach, how many hours each ceiling buys, any
577
- * refusals that would stop a create, the API keys that cannot follow a
578
- * cutover because they lack `deployments:read`, and `terms_text` -- the
579
- * exact sentence to show, with real figures in it.
580
- *
581
- * Send the `terms_version` it returns back in `createTrainingRule`. Read the
582
- * figures out of this response rather than inventing ceilings of your own.
583
- *
584
- * `valid: false` with an EMPTY `refusals` list is not nothing: check
585
- * `unreachable`, which names every peer the platform could not reach. The
586
- * rule is savable in that state and would be paused, but the estimate around
587
- * it is not trustworthy -- both `worst_hourly_*` are `0`, and so are both
588
- * `max_*_hours` beside them -- so do not quote those figures to anyone.
589
- * `model_revision` is empty unless training-service actually pinned a
590
- * commit; test `unreachable.length > 0` to tell a degraded pass from a
591
- * refusal.
592
- *
593
- * A `TRAINING_NOT_ENABLED` refusal is neither: training is in beta and this
594
- * organisation does not hold the grant. It is in `refusals`, never in
595
- * `unreachable`, and nothing in the request can lift it.
596
- */
597
- preflightTrainingRule(params: TrainingRulePreflightRequest): Promise<TrainingRulePreflight>;
598
- /**
599
- * Create a training rule and record the consent that pays for it.
600
- *
601
- * ACCEPTING THE TERMS AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT
602
- * PRESENT. From here on the platform may, on its own schedule and without
603
- * asking again, build a training set, run a training job on rented GPUs,
604
- * book a second deployment to compare against the one serving your traffic,
605
- * and pay for the model calls that judge the two. Those charges come out of
606
- * the wallet of the member whose credentials make this call, up to the
607
- * ceilings in `money`, and they keep recurring for as long as the rule is
608
- * enabled. If `promotion.auto_promote` is set, the platform will also
609
- * re-point your public handle at the new model with nobody reviewing it.
610
- *
611
- * `accept_terms` is therefore required, and this method refuses to send the
612
- * request without it rather than letting the server decide. Call
613
- * {@link preflightTrainingRule} first, show the person whose wallet pays the
614
- * `terms_text` and the figures it returns, get an explicit yes, and send the
615
- * `terms_version` they were shown. Do not invent ceilings or price caps on
616
- * their behalf.
617
- *
618
- * Refused `409 TRAINING_NOT_ENABLED`, with nothing saved, while training is
619
- * in beta and this organisation does not hold the grant: do not retry, ask
620
- * the platform team to enable it. See `TrainingRuleSaveRefusalCode`.
621
- *
622
- * @example
623
- * ```ts
624
- * const estimate = await client.loop.preflightTrainingRule(draft);
625
- * // show estimate.terms_text and the ceilings to the member, get a yes
626
- * const rule = await client.loop.createTrainingRule({
627
- * ...draft,
628
- * accept_terms: { terms_version: estimate.terms_version },
629
- * });
630
- * ```
631
- */
632
- createTrainingRule(params: TrainingRuleCreateRequest): Promise<TrainingRule>;
633
- /**
634
- * Every training rule in the workspace, with what each one last did and why.
635
- *
636
- * `last_reason` and `paused_reason` are the fields worth reading: a rule
637
- * quiet because it is waiting looks exactly like one quiet because its
638
- * consent went stale.
639
- */
640
- listTrainingRules(params?: TrainingRuleListParams): Promise<TrainingRuleListResponse>;
641
- /**
642
- * Read one rule with its recent runs, what its runs this month have cost at
643
- * most, and how far its judge agrees with your own reviewers.
644
- *
645
- * Returned whole rather than unwrapped to the rule: `month_spent_cents` is
646
- * the number that says whether the monthly ceiling is about to stop it. It
647
- * is an upper bound, not an exact spend: see `Pipeline.month_spent_cents`.
648
- */
649
- getTrainingRule(id: string): Promise<TrainingRuleResponse>;
650
- /**
651
- * Edit or pause a rule. Absent means unchanged; a null clears the fields
652
- * that can be cleared.
653
- *
654
- * A money-bearing change -- a ceiling, a model, a GPU ladder, the promotion
655
- * policy, or changing `explore_recipes` in EITHER direction -- bumps
656
- * `revision`, clears the recorded consent and STOPS the rule firing until
657
- * someone accepts the new amounts. Turning recipe variants OFF does this
658
- * too: the pipeline then makes no version at all, variant or not, until the
659
- * terms are accepted again. The reply says so in
660
- * `consent_required`, and carries a fresh `preflight` with the new figures.
661
- * Pass `expected_revision` to be refused with `REVISION_MISMATCH` rather
662
- * than overwrite an edit somebody else made in the meantime.
663
- *
664
- * Switching a rule on, switching it into preference training or carrying
665
- * `accept_terms` re-runs the preflight, and can be refused
666
- * `409 TRAINING_NOT_ENABLED` like a create. A rule paused
667
- * `training_not_enabled` is started again by a save of it once the
668
- * organisation has been enabled.
669
- */
670
- updateTrainingRule(id: string, params: TrainingRuleUpdateRequest): Promise<TrainingRuleMutationResponse>;
671
- /**
672
- * Accept the rule's current terms, so it may fire again.
673
- *
674
- * ACCEPTING THE TERMS AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT
675
- * PRESENT, on the amounts as they stand right now. This is the same
676
- * authorisation {@link createTrainingRule} records, given again because a
677
- * money-bearing edit cleared the old one: training, a candidate deployment
678
- * and the judge's model calls are charged to the wallet of the member making
679
- * this call, up to the rule's ceilings, every time it fires.
680
- *
681
- * Show the member the current `terms_text` from a fresh
682
- * {@link preflightTrainingRule} or from the `preflight` on the update reply,
683
- * and send the `revision` those figures belong to. A stale revision is
684
- * refused with `409`, which is the point: it means the amounts moved again
685
- * after they were read. `409 TRAINING_NOT_ENABLED` means training is in beta
686
- * and this organisation does not hold the grant.
687
- */
688
- consentTrainingRule(id: string, params: TrainingRuleConsentRequest): Promise<TrainingRule>;
689
- /**
690
- * Fire a rule now, without waiting for its cadence.
691
- *
692
- * Bypasses the schedule and `min_new_rows` only. The row floors, the money
693
- * ceilings, the consent, the version limit and the monthly limit all still
694
- * apply, so this can answer `409 CONSENT_REQUIRED`, `409 RULE_PAUSED`,
695
- * `409 RUN_ACTIVE`, `409 VERSION_LIMIT_REACHED` (the pipeline has made
696
- * `max_versions` versions), `409 MONTHLY_LIMIT_REACHED` (the most this
697
- * month's runs can have cost plus the most one run may cost would pass the
698
- * monthly limit; the error
699
- * body carries `month_spent_cents`, `monthly_ceiling_cents`, `run_max_cents`
700
- * and `resumes_at`), `409 AGENT_OFF` (the workspace's Conscious Loop agent
701
- * is not turned on, so a trained model could not be compared) or
702
- * `422 NOT_ENOUGH_ROWS` with the counts it needed. See
703
- * `TrainingRuleRunRefusalCode`.
704
- */
705
- runTrainingRule(id: string): Promise<TrainingRun>;
706
- /**
707
- * Delete a rule. An active run is cancelled; runs that already finished, and
708
- * anything already promoted, are kept.
709
- */
710
- deleteTrainingRule(id: string): Promise<TrainingRuleDeleteResponse>;
711
- /**
712
- * Edit or pause a build rule -- the standing instruction that assembles the
713
- * training set a training rule then trains on.
714
- *
715
- * Changing `spec.deployment_id` while an enabled training rule owns this
716
- * build rule is refused with `409`: it would silently retrain the next model
717
- * on a different source's conversations.
718
- */
719
- updateBuildRule(id: string, params: LoopBuildRuleUpdateParams): Promise<LoopBuildRule>;
720
- /** Firings, newest first. Filter by rule or by the state they are sitting in. */
303
+ getMetricsHistory(params?: LoopMetricsHistoryParams): Promise<LoopMetricsHistory>;
304
+ /** Attempts, newest first. Filter by pipeline (`rule_id`) or by the state they are sitting in. */
721
305
  listTrainingRuns(params?: TrainingRunListParams): Promise<TrainingRunListResponse>;
722
306
  /**
723
307
  * One run with its timeline, the addresses of everything it created, and
@@ -756,24 +340,19 @@ export declare class Loop {
756
340
  */
757
341
  cancelTrainingRun(id: string, params?: TrainingRunCancelRequest): Promise<TrainingRunActionResponse>;
758
342
  /**
759
- * Every training rule in the workspace, seen as the series of versions it
760
- * produced: which exist, which one serves (`champion_version`), how each did
761
- * against the champion of its day and on the standing benchmark, the run in
762
- * flight and which version it will be, and what the pipeline is waiting for.
763
- *
764
- * Read-only. Every decision stays on the route that owns it -- promote,
765
- * reject and roll back on the run, the version limit and `explore_recipes`
766
- * on the rule.
343
+ * Every pipeline in the workspace: its versions (the attempts that became
344
+ * the live model), every attempt, which version is live, the attempt in
345
+ * flight, and what the pipeline is waiting for.
767
346
  *
768
347
  * RETURNED WITH ITS ENVELOPE, because the list is not always all of them:
769
- * the service returns the newest 100, `total` is every pipeline in the
770
- * workspace and `truncated` is true when more exist than were returned. A
771
- * caller that shows `pipelines` alone presents a short list as the whole of
772
- * it. The rest are reached through `listTrainingRules`, which pages.
348
+ * the service returns a page of 100, newest first, `total` is every
349
+ * pipeline in the workspace and `truncated` is true when more exist after
350
+ * this page. A caller that shows `pipelines` alone presents a short list as
351
+ * the whole of it; the next page is `{ offset: offset + pipelines.length }`.
773
352
  */
774
- listPipelines(): Promise<PipelineListResponse>;
353
+ listPipelines(params?: PipelineListParams): Promise<PipelineListResponse>;
775
354
  /**
776
- * One pipeline, by its training rule's id.
355
+ * One pipeline, by its id.
777
356
  *
778
357
  * `status` says whether it is the platform working (`running`), the member
779
358
  * who has to act (`needs_review`, `needs_funds`), or nothing at all until
@@ -783,9 +362,71 @@ export declare class Loop {
783
362
  * at most, not an exact spend.
784
363
  */
785
364
  getPipeline(id: string): Promise<Pipeline>;
365
+ /**
366
+ * The base models a pipeline can train: only those the engine trains with
367
+ * LoRA SFT and the platform can serve for the comparison, recommended first.
368
+ * The one list {@link createPipeline} accepts a `model.id` from, with the
369
+ * `floors` a new pipeline is held to: the samples its first attempt needs and
370
+ * the smallest `train_when.min_samples`.
371
+ */
372
+ listModels(): Promise<LoopModelsResponse>;
373
+ /**
374
+ * Create a pipeline -- one use case.
375
+ *
376
+ * SAVING IT AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT PRESENT:
377
+ * whenever its data has grown enough (and at its schedule, when it has one),
378
+ * the platform trains a new version on GPUs it chooses, compares it with what
379
+ * serves your traffic, and promotes it by the pipeline's promotion policy.
380
+ * What is charged is the GPU time the runs actually use; the platform's own
381
+ * per-run and monthly limits stop a run that goes wrong.
382
+ */
383
+ createPipeline(params: PipelineWriteRequest): Promise<PipelineMutationResponse>;
384
+ /**
385
+ * Edit a pipeline. Only the fields sent change; `max_versions: null` removes
386
+ * the limit and `challenger_model: null` removes the challenger. `promotion`
387
+ * is how the promotion policy is set. Saving is the authorization, as on a
388
+ * create.
389
+ */
390
+ updatePipeline(id: string, params: PipelineWriteRequest): Promise<PipelineMutationResponse>;
391
+ /**
392
+ * Delete a pipeline: an attempt still running is cancelled; the versions it
393
+ * made, what serves your app, and its samples and tags are kept. Recording
394
+ * to its own tag stops.
395
+ */
396
+ deletePipeline(id: string): Promise<TrainingRuleDeleteResponse>;
397
+ /**
398
+ * Train now: skips the schedule, never the minimum. A pipeline short of its
399
+ * samples is refused 422 `NOT_ENOUGH_SAMPLES` with `have` and `need` -- the
400
+ * numbers `minimums` shows. 503 `AGENT_COULD_NOT_START` means the key the
401
+ * attempt would be scored with could not be renewed just then: nothing was
402
+ * started, so press train now again in a minute. Every refusal is a
403
+ * `TrainingRuleRunRefusalCode`.
404
+ */
405
+ runPipeline(id: string): Promise<PipelineMutationResponse>;
406
+ /**
407
+ * {@link importRows}, with every row given the pipeline's own tag. `source`
408
+ * defaults to that tag; the rows, the answer and the retry rules are the
409
+ * import door's own. `default_feedback: 'good'` records every answered row
410
+ * that brought no verdict of its own as a good example to learn from.
411
+ */
412
+ importIntoPipeline(id: string, params: PipelineImportParams): Promise<LoopImportResult>;
413
+ /** The pipeline's benchmarks in priority order (1 is the primary), the ones it stopped using, and its promotion policy. */
414
+ listPipelineBenchmarks(id: string): Promise<PipelineBenchmarksResponse>;
415
+ /** Add a benchmark to a pipeline, last unless `priority` says where. Every version from now on is replayed on it. */
416
+ attachPipelineBenchmark(id: string, params: PipelineBenchmarkAttachParams): Promise<PipelineBenchmarksResponse>;
417
+ /** Move a benchmark on a pipeline's list; priority 1 makes it the primary. */
418
+ movePipelineBenchmark(id: string, benchmarkId: string, params: PipelineBenchmarkMoveParams): Promise<PipelineBenchmarksResponse>;
419
+ /** Stop using a benchmark. Every score it produced is kept. */
420
+ removePipelineBenchmark(id: string, benchmarkId: string): Promise<PipelineBenchmarksResponse>;
421
+ /**
422
+ * Every version's scores side by side: its head-to-head and every benchmark,
423
+ * `not_measured` where a benchmark was added after it. `a` and `b` are
424
+ * VERSION numbers; with both, `differences` says b minus a per benchmark.
425
+ */
426
+ compareVersions(id: string, params?: VersionCompareParams): Promise<VersionCompareResponse>;
786
427
  /**
787
428
  * The comparison behind a verdict: both models on the same held-out rows,
788
- * with identical decoding, judge and grader names resolved.
429
+ * with identical decoding, scored by the same judge.
789
430
  *
790
431
  * Read `warnings` before you read `win_rate`. A win rate over a holdout too
791
432
  * small to mean anything, or one measured by a judge that disagrees with
@@ -799,20 +440,12 @@ export declare class Loop {
799
440
  * The paired conversations behind the numbers: one prompt, both answers, the
800
441
  * scores each earned, and which won.
801
442
  *
802
- * Filter by `winner` to read the losses first, which is where a verdict is
803
- * actually checked. `limit` is capped at 100 by the service.
443
+ * Filter by `winner` -- `candidate` (the attempt won), `serving` (the version
444
+ * serving today won; the item itself says `incumbent`) or `tie` -- and read
445
+ * `serving` first: the pairs the attempt lost are where a verdict is actually
446
+ * checked. `limit` is 50 when absent and at most 200.
804
447
  */
805
448
  listEvaluationItems(id: string, params?: EvaluationItemListParams): Promise<EvaluationItemsResponse>;
806
- /**
807
- * How far a judge agrees with your own reviewers, over the conversations
808
- * both have scored.
809
- *
810
- * This is a gate, not a badge: a rule's `min_judge_agreement` refuses to
811
- * promote on the word of a judge that does not agree with the people whose
812
- * product it is. `enough_pairs` is the field to read first -- "not enough
813
- * reviewer overlap yet" is an answer, and 100% of two pairs is not.
814
- */
815
- getJudgeAgreement(judgeId: string, params?: JudgeAgreementParams): Promise<JudgeAgreement>;
816
449
  /**
817
450
  * Pin a fixed set of conversations, with a judge frozen beside them, and
818
451
  * measure every future run against it.
@@ -828,9 +461,10 @@ export declare class Loop {
828
461
  * is refused rather than skipped, because pinning 47 of the 50 you chose is
829
462
  * the set being wrong from the first day and you would never find out.
830
463
  *
831
- * It raises no amount you have already agreed to. The replay's calls come
832
- * out of the rule's existing `eval_ceiling_cents`, and
833
- * `per_run_ceiling_cents` can only lower what is spent inside that.
464
+ * The platform freezes the judge and the model it scores on (the ones every
465
+ * pipeline comparison uses), gives both models the comparison's own answer
466
+ * length, and sets what one replay may spend, inside the attempt's own
467
+ * scoring limit; none of that is sent.
834
468
  */
835
469
  createBenchmark(params: BenchmarkCreateParams): Promise<Benchmark>;
836
470
  /** Your benchmarks, newest first. Filter by `status` to hide retired ones. */
@@ -845,7 +479,7 @@ export declare class Loop {
845
479
  */
846
480
  getBenchmark(id: string): Promise<Benchmark>;
847
481
  /**
848
- * The pinned conversations, paged. `limit` is capped at 100 by the service.
482
+ * The pinned conversations, paged. `limit` is 50 when absent and at most 200.
849
483
  *
850
484
  * `source_trace_id` and `source_trace_url` come back null once the
851
485
  * conversation a row was copied from has been deleted. The row itself stays
@@ -864,7 +498,7 @@ export declare class Loop {
864
498
  */
865
499
  getBenchmarkHistory(id: string, params?: BenchmarkHistoryParams): Promise<BenchmarkHistoryResponse>;
866
500
  /**
867
- * Stop replaying a benchmark, and detach it from every rule that names it.
501
+ * Stop replaying a benchmark, and detach it from every pipeline using it.
868
502
  *
869
503
  * Nothing measured is removed. There is no delete and no update on purpose:
870
504
  * the series of numbers measured against a set is what a benchmark is for,
@@ -888,36 +522,4 @@ export declare class Loop {
888
522
  * different set, which is the exact defect a standing benchmark removes.
889
523
  */
890
524
  getBenchmarkRun(id: string): Promise<BenchmarkRun>;
891
- /**
892
- * Attach a benchmark to a rule, or send `{ benchmark_id: null }` to detach
893
- * it.
894
- *
895
- * Its own route rather than a field on the rule body, because it is a
896
- * decision to replay a fixed set on every future run of this rule for as
897
- * long as it stands, and its refusals -- retired, or belonging to another
898
- * workspace -- are about the benchmark rather than about the rule.
899
- *
900
- * It does not invalidate consent and the reply says so: attaching raises
901
- * neither the amount set aside for judge calls nor the amount set aside for
902
- * keeping the new model available, so nobody is asked to read the same
903
- * sentence again. A retired benchmark is refused with `BENCHMARK_RETIRED`,
904
- * because a rule pointed at one would report no number on every run and say
905
- * nothing about why.
906
- */
907
- setTrainingRuleBenchmark(id: string, params: TrainingRuleBenchmarkRequest): Promise<TrainingRuleMutationResponse>;
908
- /**
909
- * The workspace's agent options: which model it defaults to, the system
910
- * prompts it judges and samples with, and the monthly cap on what its model
911
- * calls may spend.
912
- */
913
- getAgentSettings(): Promise<AgentSettings>;
914
- /**
915
- * Change them. An absent key leaves that setting exactly where it is; a
916
- * present null returns it to the platform default. Those are three
917
- * instructions, not two, so `{}` changes nothing.
918
- *
919
- * `eval_monthly_cap_cents` is pushed to the workspace's managed key, so it
920
- * caps what the agent can spend even if a rule's own ceilings are higher.
921
- */
922
- updateAgentSettings(params: AgentSettingsRequest): Promise<AgentSettings>;
923
525
  }