runbios-sdk 0.2.1-dev.126 → 0.2.1-dev.131

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
@@ -36,7 +36,7 @@ import { Loop } from './resources/loop.js';
36
36
  * SDK version. Sent as part of the User-Agent header.
37
37
  * Must match package.json "version" -- enforced by a contract test.
38
38
  */
39
- export declare const VERSION = "0.2.1-dev.126";
39
+ export declare const VERSION = "0.2.1-dev.131";
40
40
  export declare class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  readonly models: Models;
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import { Loop } from './resources/loop.js';
36
36
  * SDK version. Sent as part of the User-Agent header.
37
37
  * Must match package.json "version" -- enforced by a contract test.
38
38
  */
39
- export const VERSION = '0.2.1-dev.126';
39
+ export const VERSION = '0.2.1-dev.131';
40
40
  export class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  models;
@@ -1,5 +1,5 @@
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, LoopStats, LoopJudge, LoopJudgeParams, LoopJudgeRun, LoopJudgeWork, LoopJudgeVerdict, LoopJudgeVerdictResult } from '../types.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, LoopStats, LoopJudge, LoopJudgeParams, LoopAgentCredential, LoopAgentStatus, LoopSampleRun, LoopSampleRunParams, LoopJudgeRun, LoopJudgeWork, LoopJudgeVerdict, LoopJudgeVerdictResult } 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.
@@ -401,4 +401,41 @@ export declare class Loop {
401
401
  * abandoned rather than completed.
402
402
  */
403
403
  postVerdicts(runId: string, verdicts: LoopJudgeVerdict[], finish?: boolean): Promise<LoopJudgeVerdictResult>;
404
+ /**
405
+ * Can an agent run here, is one running, and is it on for this workspace.
406
+ * `available` is about the environment; `online` about the worker;
407
+ * `credential` about this workspace.
408
+ */
409
+ agentStatus(): Promise<LoopAgentStatus>;
410
+ /**
411
+ * Turn the agent on: mints the workspace's managed serverless key. After
412
+ * this, automatic judges and sample runs make model calls billed to the
413
+ * workspace. Idempotent.
414
+ */
415
+ enableAgent(): Promise<LoopAgentCredential>;
416
+ /**
417
+ * Turn the agent off: revokes its key and sets every automatic judge back to
418
+ * manual. Open runs stop where they are and continue if it is turned back
419
+ * on. Nothing already scored or written is removed.
420
+ */
421
+ disableAgent(): Promise<{
422
+ revoked: boolean;
423
+ judges_paused: number;
424
+ message: string;
425
+ }>;
426
+ /**
427
+ * Ask the agent to write `n` alternative answers to each conversation in a
428
+ * slice with `model`, score each with `judge_id`, and store them as
429
+ * candidates. This is how preference pairs are made without a person
430
+ * writing each one: the curation pass pairs the best sample against the
431
+ * worst wherever the gap is real.
432
+ *
433
+ * Cost: up to `n` calls to write plus `n` to judge, per conversation, at the
434
+ * workspace's serverless rate; `selection.sample` caps the conversations
435
+ * (max 200) and `n` is capped at 8. Opening a run turns the agent on if it
436
+ * is off.
437
+ */
438
+ createSampleRun(params: LoopSampleRunParams): Promise<LoopSampleRun>;
439
+ listSampleRuns(): Promise<LoopSampleRun[]>;
440
+ getSampleRun(runId: string): Promise<LoopSampleRun>;
404
441
  }
@@ -564,4 +564,59 @@ export class Loop {
564
564
  async postVerdicts(runId, verdicts, finish = false) {
565
565
  return this._http.fetchPost(`/api/loop/runs/${encodeURIComponent(runId)}/verdicts`, { verdicts, finish });
566
566
  }
567
+ // ── the agent ─────────────────────────────────────────────────────────
568
+ //
569
+ // The worker that calls a model on the workspace's behalf: it applies
570
+ // automatic judges and writes sample answers. It spends through a managed
571
+ // serverless key OF THIS WORKSPACE, so every call is billed exactly like
572
+ // one of your own, and turning it off revokes that key.
573
+ /**
574
+ * Can an agent run here, is one running, and is it on for this workspace.
575
+ * `available` is about the environment; `online` about the worker;
576
+ * `credential` about this workspace.
577
+ */
578
+ async agentStatus() {
579
+ return this._http.fetchGet('/api/loop/agent');
580
+ }
581
+ /**
582
+ * Turn the agent on: mints the workspace's managed serverless key. After
583
+ * this, automatic judges and sample runs make model calls billed to the
584
+ * workspace. Idempotent.
585
+ */
586
+ async enableAgent() {
587
+ const res = await this._http.fetchPost('/api/loop/agent', {});
588
+ return res.credential;
589
+ }
590
+ /**
591
+ * Turn the agent off: revokes its key and sets every automatic judge back to
592
+ * manual. Open runs stop where they are and continue if it is turned back
593
+ * on. Nothing already scored or written is removed.
594
+ */
595
+ async disableAgent() {
596
+ return this._http.fetchDelete('/api/loop/agent');
597
+ }
598
+ /**
599
+ * Ask the agent to write `n` alternative answers to each conversation in a
600
+ * slice with `model`, score each with `judge_id`, and store them as
601
+ * candidates. This is how preference pairs are made without a person
602
+ * writing each one: the curation pass pairs the best sample against the
603
+ * worst wherever the gap is real.
604
+ *
605
+ * Cost: up to `n` calls to write plus `n` to judge, per conversation, at the
606
+ * workspace's serverless rate; `selection.sample` caps the conversations
607
+ * (max 200) and `n` is capped at 8. Opening a run turns the agent on if it
608
+ * is off.
609
+ */
610
+ async createSampleRun(params) {
611
+ const res = await this._http.fetchPost('/api/loop/sample-runs', params);
612
+ return res.run;
613
+ }
614
+ async listSampleRuns() {
615
+ const res = await this._http.fetchGet('/api/loop/sample-runs');
616
+ return res.runs;
617
+ }
618
+ async getSampleRun(runId) {
619
+ const res = await this._http.fetchGet(`/api/loop/sample-runs/${encodeURIComponent(runId)}`);
620
+ return res.run;
621
+ }
567
622
  }
package/dist/types.d.ts CHANGED
@@ -701,6 +701,13 @@ export interface TrainingJob {
701
701
  status: TrainingJobStatus;
702
702
  error_message?: string | null;
703
703
  error_code?: string | null;
704
+ /**
705
+ * Who ended a `stopped` run: `user` (Stop button, API, queue cancel) or
706
+ * `platform` (wallet exhausted, account block). Empty when the run is not
707
+ * stopped, or was stopped before this was recorded. A `failed` run is a
708
+ * different fact and never carries a stop origin.
709
+ */
710
+ stop_origin?: 'user' | 'platform' | '';
704
711
  current_step?: number;
705
712
  total_steps?: number;
706
713
  current_loss?: number | null;
@@ -2460,6 +2467,8 @@ export interface LoopJudge {
2460
2467
  model: string | null;
2461
2468
  write_gold: boolean;
2462
2469
  enabled: boolean;
2470
+ /** The platform's agent runs this judge, on the workspace's own serverless account. */
2471
+ auto: boolean;
2463
2472
  created_by: string | null;
2464
2473
  created_at: string;
2465
2474
  updated_at: string;
@@ -2477,6 +2486,14 @@ export interface LoopJudgeParams {
2477
2486
  */
2478
2487
  write_gold?: boolean;
2479
2488
  enabled?: boolean;
2489
+ /**
2490
+ * Hand the running of this judge to the platform's agent: new conversations
2491
+ * in its slice are scored as they arrive, one model call each, on THIS
2492
+ * WORKSPACE'S OWN serverless account (the agent spends through a managed key
2493
+ * of yours, "Conscious Loop" in your key list). Requires `model`. Off, you
2494
+ * run the model yourself with startRun / takeWork / postVerdicts.
2495
+ */
2496
+ auto?: boolean;
2480
2497
  }
2481
2498
  /** One pass of one rubric over one slice. */
2482
2499
  export interface LoopJudgeRun {
@@ -2490,6 +2507,80 @@ export interface LoopJudgeRun {
2490
2507
  selected: number;
2491
2508
  scored: number;
2492
2509
  failed: number;
2510
+ /** Who drains it: your own code ('caller') or the platform's agent ('platform'). */
2511
+ runner: 'caller' | 'platform';
2512
+ /** The agent's last complaint about this run, or null while it is working. */
2513
+ last_error: string | null;
2514
+ last_activity_at: string | null;
2515
+ created_by: string | null;
2516
+ created_at: string;
2517
+ finished_at: string | null;
2518
+ }
2519
+ /** The workspace's managed serverless key the agent spends through. Never the secret. */
2520
+ export interface LoopAgentCredential {
2521
+ workspace_id: string;
2522
+ key_id: string;
2523
+ key_prefix: string;
2524
+ created_by: string | null;
2525
+ created_at: string;
2526
+ updated_at: string;
2527
+ last_used_at: string | null;
2528
+ last_error: string | null;
2529
+ revoked_at: string | null;
2530
+ }
2531
+ export interface LoopAgentStatus {
2532
+ /** An agent can exist in this environment at all. */
2533
+ available: boolean;
2534
+ /** Which piece is missing when it cannot. */
2535
+ reason: string;
2536
+ /** A worker has checked in within the last minute. */
2537
+ online: boolean;
2538
+ agent: {
2539
+ seen_at: string;
2540
+ passes: number;
2541
+ judge_items: number;
2542
+ samples: number;
2543
+ } | null;
2544
+ credential: LoopAgentCredential | null;
2545
+ open_judge_runs: number;
2546
+ open_sample_runs: number;
2547
+ auto_judges: number;
2548
+ }
2549
+ export interface LoopSampleSelection extends LoopJudgeSelection {
2550
+ /** Skip conversations that already have alternatives. */
2551
+ only_unsampled?: boolean;
2552
+ }
2553
+ export interface LoopSampleRunParams {
2554
+ /** The model that writes the alternatives. For distillation, the teacher. */
2555
+ model: string;
2556
+ /** Alternatives per conversation, 1-8. Default 4. */
2557
+ n?: number;
2558
+ /** 0-2. Default 0.8; 0 makes every sample the same answer. */
2559
+ temperature?: number;
2560
+ /** 16-8192. Default 1024. */
2561
+ max_tokens?: number;
2562
+ /** Score each sample with this judge as it is written. */
2563
+ judge_id?: string;
2564
+ selection?: LoopSampleSelection;
2565
+ }
2566
+ /** "Write N alternatives to each conversation in this slice, and score them." */
2567
+ export interface LoopSampleRun {
2568
+ id: string;
2569
+ workspace_id: string;
2570
+ model: string;
2571
+ n: number;
2572
+ temperature: number;
2573
+ max_tokens: number;
2574
+ judge_id: string | null;
2575
+ judge_name: string | null;
2576
+ selection: LoopSampleSelection;
2577
+ status: 'open' | 'done';
2578
+ selected: number;
2579
+ done: number;
2580
+ failed: number;
2581
+ samples: number;
2582
+ last_error: string | null;
2583
+ last_activity_at: string | null;
2493
2584
  created_by: string | null;
2494
2585
  created_at: string;
2495
2586
  finished_at: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runbios-sdk",
3
- "version": "0.2.1-dev.126",
3
+ "version": "0.2.1-dev.131",
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",