runbios-sdk 0.2.1-rc.138 → 0.2.1-rc.147

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BiOSConfig, ApiErrorBody, AvailableGpuAlternative, CapacityMinimumRequirement } from './types.js';
1
+ import type { BiOSConfig, ApiErrorBody, AvailableGpuAlternative, CapacityMinimumRequirement, LoopImportResult } from './types.js';
2
2
  /**
3
3
  * Typed error thrown by every SDK method when the API returns a non-2xx status.
4
4
  *
@@ -135,6 +135,53 @@ export declare const COMING_SOON_CODES: readonly ["TRAINING_COMING_SOON", "DATAS
135
135
  export declare class ComingSoonError extends ApiError {
136
136
  constructor(status: number, body: ApiErrorBody);
137
137
  }
138
+ /** The code an import answers with when some rows were understood and then could not be stored. */
139
+ export declare const IMPORT_INCOMPLETE_CODE = "IMPORT_INCOMPLETE";
140
+ /**
141
+ * An import that did not finish: some rows could not be stored, or some
142
+ * verdicts that arrived with them could not be written.
143
+ *
144
+ * The rows it names were read and understood, so there is nothing to fix in
145
+ * the file: this is a storage failure, not a shape one. The full outcome is on
146
+ * {@link LoopImportIncompleteError.outcome} — what landed, which conversations
147
+ * it became, and which row positions did not — because a failure that reports
148
+ * only "it failed" leaves the caller with no move except sending everything
149
+ * again.
150
+ *
151
+ * HOW TO RECOVER. Send the same rows again with `importId`, the token this
152
+ * call was filed under. That is what makes the second call a RETRY: rows that
153
+ * already arrived come back under `already_present` instead of being stored
154
+ * twice, and a verdict that failed to write is attempted again. Repeat it
155
+ * exactly; a call that repeats nothing is a second import, on purpose, because
156
+ * a repeat is otherwise indistinguishable from the next page of a longer file.
157
+ *
158
+ * THE WHOLE FILE, not the rows this names, unless you sent `row_ids`. Without
159
+ * them a row is identified by its place in the call, so a shorter list moves
160
+ * every row after the gap and each is imported again.
161
+ */
162
+ export declare class LoopImportIncompleteError extends ApiError {
163
+ /** Counts, notes and ids for the import, in the same shape a success returns. */
164
+ readonly outcome: LoopImportResult;
165
+ constructor(status: number, body: ApiErrorBody);
166
+ /**
167
+ * The token to repeat as `import_id` to retry this call. Without it the retry
168
+ * is a second import rather than a retry, and what already landed is stored
169
+ * again.
170
+ */
171
+ get importId(): string | undefined;
172
+ /**
173
+ * Row positions that were not stored, counting from 1 in the order you sent
174
+ * them. They say what is missing; they are a smaller file to send back only
175
+ * if you sent `row_ids`.
176
+ */
177
+ get notSavedRows(): number[];
178
+ /**
179
+ * Row positions whose conversation stored and whose verdict did not. Those
180
+ * conversations are in the loop waiting for review; retrying records the
181
+ * verdict.
182
+ */
183
+ get verdictsNotSavedRows(): number[];
184
+ }
138
185
  /** Whether a machine code is one of the permanent GPU rejections. */
139
186
  export declare function isPermanentGpuCode(code: string | undefined): boolean;
140
187
  /**
package/dist/client.js CHANGED
@@ -191,6 +191,63 @@ export class ComingSoonError extends ApiError {
191
191
  this.name = 'ComingSoonError';
192
192
  }
193
193
  }
194
+ /** The code an import answers with when some rows were understood and then could not be stored. */
195
+ export const IMPORT_INCOMPLETE_CODE = 'IMPORT_INCOMPLETE';
196
+ /**
197
+ * An import that did not finish: some rows could not be stored, or some
198
+ * verdicts that arrived with them could not be written.
199
+ *
200
+ * The rows it names were read and understood, so there is nothing to fix in
201
+ * the file: this is a storage failure, not a shape one. The full outcome is on
202
+ * {@link LoopImportIncompleteError.outcome} — what landed, which conversations
203
+ * it became, and which row positions did not — because a failure that reports
204
+ * only "it failed" leaves the caller with no move except sending everything
205
+ * again.
206
+ *
207
+ * HOW TO RECOVER. Send the same rows again with `importId`, the token this
208
+ * call was filed under. That is what makes the second call a RETRY: rows that
209
+ * already arrived come back under `already_present` instead of being stored
210
+ * twice, and a verdict that failed to write is attempted again. Repeat it
211
+ * exactly; a call that repeats nothing is a second import, on purpose, because
212
+ * a repeat is otherwise indistinguishable from the next page of a longer file.
213
+ *
214
+ * THE WHOLE FILE, not the rows this names, unless you sent `row_ids`. Without
215
+ * them a row is identified by its place in the call, so a shorter list moves
216
+ * every row after the gap and each is imported again.
217
+ */
218
+ export class LoopImportIncompleteError extends ApiError {
219
+ /** Counts, notes and ids for the import, in the same shape a success returns. */
220
+ outcome;
221
+ constructor(status, body) {
222
+ super(status, body);
223
+ this.name = 'LoopImportIncompleteError';
224
+ this.outcome = body;
225
+ }
226
+ /**
227
+ * The token to repeat as `import_id` to retry this call. Without it the retry
228
+ * is a second import rather than a retry, and what already landed is stored
229
+ * again.
230
+ */
231
+ get importId() {
232
+ return this.outcome.import_id;
233
+ }
234
+ /**
235
+ * Row positions that were not stored, counting from 1 in the order you sent
236
+ * them. They say what is missing; they are a smaller file to send back only
237
+ * if you sent `row_ids`.
238
+ */
239
+ get notSavedRows() {
240
+ return this.outcome.not_saved_rows ?? [];
241
+ }
242
+ /**
243
+ * Row positions whose conversation stored and whose verdict did not. Those
244
+ * conversations are in the loop waiting for review; retrying records the
245
+ * verdict.
246
+ */
247
+ get verdictsNotSavedRows() {
248
+ return this.outcome.verdicts_not_saved_rows ?? [];
249
+ }
250
+ }
194
251
  /** Whether a machine code is one of the permanent GPU rejections. */
195
252
  export function isPermanentGpuCode(code) {
196
253
  return typeof code === 'string' && PERMANENT_GPU_CODES.includes(code);
@@ -225,6 +282,12 @@ export function buildApiError(status, body) {
225
282
  if (code && COMING_SOON_CODES.includes(code)) {
226
283
  return new ComingSoonError(status, body);
227
284
  }
285
+ // A half-finished import carries its whole outcome in the body. Leaving it as
286
+ // a plain ApiError makes the counts reachable only by casting `.body`, which
287
+ // is the same as not publishing them.
288
+ if (code === IMPORT_INCOMPLETE_CODE) {
289
+ return new LoopImportIncompleteError(status, body);
290
+ }
228
291
  return new ApiError(status, body);
229
292
  }
230
293
  // ============================================================================
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-rc.138";
39
+ export declare const VERSION = "0.2.1-rc.147";
40
40
  export declare class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  readonly models: Models;
@@ -67,7 +67,7 @@ export declare class RunBiOS {
67
67
  }
68
68
  /** @deprecated Use {@link RunBiOS}. */
69
69
  export { RunBiOS as BiOS };
70
- export { ApiError, GpuRejectionError, CapacityUnavailableError, ComingSoonError, CAPACITY_UNAVAILABLE_CODE, COMING_SOON_CODES, PERMANENT_GPU_CODES, isPermanentGpuCode, gpuRejectionCodeForReason, } from './client.js';
70
+ export { ApiError, GpuRejectionError, CapacityUnavailableError, ComingSoonError, LoopImportIncompleteError, CAPACITY_UNAVAILABLE_CODE, COMING_SOON_CODES, IMPORT_INCOMPLETE_CODE, PERMANENT_GPU_CODES, isPermanentGpuCode, gpuRejectionCodeForReason, } from './client.js';
71
71
  export { Models } from './resources/models.js';
72
72
  export { Datasets } from './resources/datasets.js';
73
73
  export { Integrations, type HuggingFaceIntegration, type IntegrationBrowseParams } from './resources/integrations.js';
@@ -75,4 +75,6 @@ export { Training } from './resources/training.js';
75
75
  export { Wallet } from './resources/wallet.js';
76
76
  export { GPU, type GPURecommendation } from './resources/gpu.js';
77
77
  export { Inference, validateChatRequest, parseSSE, buildInferenceRequest, contextSizingBasis, type ContextSizingBasis, CONTEXT_DEFAULT_CEILING, CONTEXT_EDITABLE_FLOOR, type ChatMessage, type FunctionTool, type ChatCompletionParams, type ChatCompletionResponse, type ChatCompletionChunk, } from './resources/inference.js';
78
- export type { BiOSConfig, PaginatedResponse, ApiErrorBody, AvailableGpuAlternative, CapacityMinimumRequirement, InferenceBookingAccepted, Model, ModelSearchParams, ModelSearchResponse, ModelDetailResponse, ModelConfig, Dataset, DatasetListParams, DatasetListResponse, DatasetUploadParams, DatasetPreview, DatasetPreviewParams, DatasetImportHFParams, DatasetRegisterHFParams, DatasetHubSearchParams, DatasetHubPreviewParams, DatasetValidation, DatasetFormatVariant, DatasetFormatSpec, DatasetFormatSpecs, DatasetStorageUsage, TrainingMethod, RLHFAlgorithm, AdapterType, TrainingJobStatus, TrainingStatusFilter, TrainingCreateParams, TrainingListParams, TrainingListResponse, TrainingJob, TrainingMetrics, TrainingResourceMetrics, TrainingDeviceMetrics, MetricPoint, MetricGraphConfig, TrainingCheckpoint, TrainingLogs, TrainingLogEntry, TrainingStopResponse, TrainingResumeResponse, CanonicalTrainingRequest, TrainingPreflightDataset, TrainingPreflightWarning, TrainingPreflightResponse, TrainingCapabilityChoice, TrainingConfigFieldCapability, TrainingCapabilities, GPUChoice, WalletBalance, Transaction, TransactionListResponse, TransactionListParams, GPUInfo, GPUPricingResponse, GPUOptionsParams, TrainingRecommendParams, TrainingAdvisorVerdict, TrainingAdvisorRecommendation, TrainingAdvisorUserShape, TrainingAdvisorJustification, TrainingAdvisorBasis, GPUOption, GPUOptionSuggestion, GPUOptionsResponse, InferenceStatus, InferenceCreateParams, InferenceUpdateParams, InferenceDeployment, InferenceDeploymentSummary, InferenceCreateResponse, InferenceListResponse, InferenceUpdateResponse, InferenceLifecycleResponse, InferenceDeleteResponse, InferenceGPUOptionMarket, InferenceGPUOption, InferenceGPUAlternative, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceCanonicalRequest, InferencePreflightWarning, InferencePreflightResponse, AdapterCompatibility, AdapterCompatibilityResponse, AdapterCompatibilityParams, SupportedArchitecture, ArchitectureScope, SupportedArchitecturesResponse, ApiKey, ApiKeyScope, ApiKeyIntrospection, Organization, OrgMember, OrgInvite, Workspace, Integration, IntegrationCreateParams, StorageUsage, StorageObject, PromptTokensDetails, ChatCompletionUsage, } from './types.js';
78
+ export type { BiOSConfig, PaginatedResponse, ApiErrorBody, AvailableGpuAlternative, CapacityMinimumRequirement, InferenceBookingAccepted, Model, ModelSearchParams, ModelSearchResponse, ModelDetailResponse, ModelConfig, Dataset, DatasetListParams, DatasetListResponse, DatasetUploadParams, DatasetPreview, DatasetPreviewParams, DatasetImportHFParams, DatasetRegisterHFParams, DatasetHubSearchParams, DatasetHubPreviewParams, DatasetValidation, DatasetFormatVariant, DatasetFormatSpec, DatasetFormatSpecs, DatasetStorageUsage, TrainingMethod, RLHFAlgorithm, AdapterType, TrainingJobStatus, TrainingStatusFilter, TrainingCreateParams, TrainingListParams, TrainingListResponse, TrainingJob, TrainingMetrics, TrainingResourceMetrics, TrainingDeviceMetrics, MetricPoint, MetricGraphConfig, TrainingCheckpoint, TrainingLogs, TrainingLogEntry, TrainingStopResponse, TrainingResumeResponse, CanonicalTrainingRequest, TrainingPreflightDataset, TrainingPreflightWarning, TrainingPreflightResponse, TrainingCapabilityChoice, TrainingConfigFieldCapability, TrainingCapabilities, GPUChoice, WalletBalance, Transaction, TransactionListResponse, TransactionListParams, GPUInfo, GPUPricingResponse, GPUOptionsParams, TrainingRecommendParams, TrainingAdvisorVerdict, TrainingAdvisorRecommendation, TrainingAdvisorUserShape, TrainingAdvisorJustification, TrainingAdvisorBasis, GPUOption, GPUOptionSuggestion, GPUOptionsResponse, InferenceStatus, InferenceCreateParams, InferenceUpdateParams, InferenceDeployment, InferenceDeploymentSummary, InferenceCreateResponse, InferenceListResponse, InferenceUpdateResponse, InferenceLifecycleResponse, InferenceDeleteResponse, InferenceGPUOptionMarket, InferenceGPUOption, InferenceGPUAlternative, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceCanonicalRequest, InferencePreflightWarning, InferencePreflightResponse, AdapterCompatibility, AdapterCompatibilityResponse, AdapterCompatibilityParams, SupportedArchitecture, ArchitectureScope, SupportedArchitecturesResponse, ApiKey, ApiKeyScope, ApiKeyIntrospection, Organization, OrgMember, OrgInvite, Workspace, Integration, IntegrationCreateParams, StorageUsage, StorageObject, PromptTokensDetails, ChatCompletionUsage, TrainingCadence, TrainingCombinator, ServingKind, TrainingRulePausedReason, LoopTrainingMethod, TrainType, GradersScope, TrainingTrigger, TrainingRunState, TrainingVerdict, TrainingDecision, NotifyState, EvaluationStatus, EvaluationItemStatus, EvaluationWinner, EvaluationWarningCode, ConsentVia, TrainingToolCall, TrainingMessage, TrainingRuleServing, TrainingGPURung, TrainingRule, TrainingRuleConsent, TrainingRulePreflightRefusal, TrainingRuleKeyRef, TrainingRuleKeyCheck, TrainingRulePreflight, TrainingRuleBuildSpec, TrainingRuleTriggerInput, TrainingRuleTrainingInput, TrainingRuleDeployInput, TrainingRuleMoneyInput, TrainingRuleEvaluationInput, TrainingRulePromotionInput, TrainingRuleAcceptTerms, TrainingRulePreflightRequest, TrainingRuleCreateRequest, TrainingRuleUpdateRequest, TrainingRuleConsentRequest, TrainingRuleListParams, TrainingRunPromoteRequest, TrainingRunRejectRequest, TrainingRunRollbackRequest, TrainingRunCancelRequest, TrainingRunListParams, TrainingRun, TrainingRunSummary, TrainingRunEvent, TrainingRunLinks, TrainingRunActions, EvaluationRef, EvaluationDecoding, EvaluationJudgeDimension, EvaluationDimensionScore, EvaluationGraderScore, EvaluationWarning, EvaluationMargin, JudgeAgreementDimension, JudgeAgreement, Evaluation, EvaluationItemSide, EvaluationItem, EvaluationItemListParams, JudgeAgreementParams, AgentSettings, AgentSettingsRequest, InferenceAlias, InferenceAliasRequest, TrainingRuleListResponse, TrainingRuleResponse, TrainingRuleMutationResponse, TrainingRuleDeleteResponse, TrainingRunListResponse, TrainingRunResponse, TrainingRunActionResponse, EvaluationItemsResponse, AgentSettingsResponse, InferenceAliasListResponse, InferenceAliasResponse, InferenceAliasDeleteResponse, } from './types.js';
79
+ /** The closed set of run states a training run never leaves. */
80
+ export { TERMINAL_RUN_STATES } from './types.js';
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-rc.138';
39
+ export const VERSION = '0.2.1-rc.147';
40
40
  export class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  models;
@@ -95,7 +95,7 @@ export { RunBiOS as BiOS };
95
95
  // ---------------------------------------------------------------------------
96
96
  // Re-exports
97
97
  // ---------------------------------------------------------------------------
98
- export { ApiError, GpuRejectionError, CapacityUnavailableError, ComingSoonError, CAPACITY_UNAVAILABLE_CODE, COMING_SOON_CODES, PERMANENT_GPU_CODES, isPermanentGpuCode, gpuRejectionCodeForReason, } from './client.js';
98
+ export { ApiError, GpuRejectionError, CapacityUnavailableError, ComingSoonError, LoopImportIncompleteError, CAPACITY_UNAVAILABLE_CODE, COMING_SOON_CODES, IMPORT_INCOMPLETE_CODE, PERMANENT_GPU_CODES, isPermanentGpuCode, gpuRejectionCodeForReason, } from './client.js';
99
99
  export { Models } from './resources/models.js';
100
100
  export { Datasets } from './resources/datasets.js';
101
101
  export { Integrations } from './resources/integrations.js';
@@ -103,3 +103,5 @@ export { Training } from './resources/training.js';
103
103
  export { Wallet } from './resources/wallet.js';
104
104
  export { GPU } from './resources/gpu.js';
105
105
  export { Inference, validateChatRequest, parseSSE, buildInferenceRequest, contextSizingBasis, CONTEXT_DEFAULT_CEILING, CONTEXT_EDITABLE_FLOOR, } from './resources/inference.js';
106
+ /** The closed set of run states a training run never leaves. */
107
+ export { TERMINAL_RUN_STATES } from './types.js';
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { InferenceDeployment, InferenceDeploymentSummary, InferenceBookingAccepted, InferenceCreateParams, InferenceCreateResponse, InferenceDeleteResponse, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceLifecycleResponse, InferenceListParams, InferenceListResponse, InferenceNotificationListResponse, InferencePreflightResponse, InferenceUpdateResponse, InferenceUpdateParams } from '../types.js';
2
+ import type { InferenceDeployment, InferenceDeploymentSummary, InferenceBookingAccepted, InferenceCreateParams, InferenceCreateResponse, InferenceDeleteResponse, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceLifecycleResponse, InferenceListParams, InferenceListResponse, InferenceNotificationListResponse, InferencePreflightResponse, InferenceUpdateResponse, InferenceUpdateParams, InferenceAlias, InferenceAliasRequest, InferenceAliasDeleteResponse } from '../types.js';
3
3
  /**
4
4
  * Serving context-length policy, owned and enforced by the server. Mirrored
5
5
  * here for documentation only -- never to pre-empt a server verdict.
@@ -213,6 +213,31 @@ export declare class Inference {
213
213
  restart(id: string): Promise<InferenceLifecycleResponse>;
214
214
  update(id: string, params: InferenceUpdateParams): Promise<InferenceUpdateResponse>;
215
215
  delete(id: string): Promise<InferenceDeleteResponse>;
216
+ /**
217
+ * Point a name at a deployment, creating the alias or moving an existing one.
218
+ *
219
+ * THIS CHANGES WHAT ANSWERS YOUR TRAFFIC the moment it returns. The reply
220
+ * carries `previous_target_inference_id`, which is what to put back if the
221
+ * new target turns out to be wrong.
222
+ *
223
+ * `origin` records why the handle moved -- a run id, a person, a script --
224
+ * and is worth setting: an alias that changed with no reason recorded is an
225
+ * incident nobody can reconstruct.
226
+ *
227
+ * Refused when the name already belongs to a live deployment
228
+ * (`ALIAS_NAME_IS_A_DEPLOYMENT`), when the target is not running, degraded or
229
+ * provisioning (`TARGET_NOT_SERVABLE`), and with `404` when the target is not
230
+ * in this workspace.
231
+ */
232
+ setAlias(name: string, params: InferenceAliasRequest): Promise<InferenceAlias>;
233
+ /** Every alias in the workspace, with what each one points at today. */
234
+ listAliases(): Promise<InferenceAlias[]>;
235
+ /**
236
+ * Remove an alias. The name goes back to the deployment that owns it, if one
237
+ * does; callers still using the alias stop resolving, so move it rather than
238
+ * delete it when something is still calling it.
239
+ */
240
+ deleteAlias(name: string): Promise<InferenceAliasDeleteResponse>;
216
241
  /**
217
242
  * Model-fit GPU choices joined to the authoritative deployment market
218
243
  * snapshot. MODEL-ADDRESSED (recommended, book-first §2): pass `model` (or
@@ -629,6 +629,51 @@ export class Inference {
629
629
  delete(id) {
630
630
  return this.http.fetchDelete(`/api/inference/${encodeURIComponent(id)}`);
631
631
  }
632
+ // --------------------------------------------------------------------------
633
+ // Aliases -- re-pointable public handles
634
+ // --------------------------------------------------------------------------
635
+ //
636
+ // An alias is a name your callers use that you can move to a different
637
+ // deployment without them changing anything. It is what the automatic
638
+ // training loop re-points when it promotes a candidate, and it is what makes
639
+ // a rollback one row write rather than a redeployment.
640
+ //
641
+ // Reads carry `deployments:read` and writes `deployments:write`: an alias
642
+ // decides which model answers a customer's traffic, so it is fenced like the
643
+ // deployment it points at rather than like a label.
644
+ /**
645
+ * Point a name at a deployment, creating the alias or moving an existing one.
646
+ *
647
+ * THIS CHANGES WHAT ANSWERS YOUR TRAFFIC the moment it returns. The reply
648
+ * carries `previous_target_inference_id`, which is what to put back if the
649
+ * new target turns out to be wrong.
650
+ *
651
+ * `origin` records why the handle moved -- a run id, a person, a script --
652
+ * and is worth setting: an alias that changed with no reason recorded is an
653
+ * incident nobody can reconstruct.
654
+ *
655
+ * Refused when the name already belongs to a live deployment
656
+ * (`ALIAS_NAME_IS_A_DEPLOYMENT`), when the target is not running, degraded or
657
+ * provisioning (`TARGET_NOT_SERVABLE`), and with `404` when the target is not
658
+ * in this workspace.
659
+ */
660
+ async setAlias(name, params) {
661
+ const res = await this.http.fetchPut(`/api/inference/aliases/${encodeURIComponent(name)}`, params);
662
+ return res.alias;
663
+ }
664
+ /** Every alias in the workspace, with what each one points at today. */
665
+ async listAliases() {
666
+ const res = await this.http.fetchGet('/api/inference/aliases');
667
+ return res.aliases || [];
668
+ }
669
+ /**
670
+ * Remove an alias. The name goes back to the deployment that owns it, if one
671
+ * does; callers still using the alias stop resolving, so move it rather than
672
+ * delete it when something is still calling it.
673
+ */
674
+ async deleteAlias(name) {
675
+ return this.http.fetchDelete(`/api/inference/aliases/${encodeURIComponent(name)}`);
676
+ }
632
677
  /**
633
678
  * Model-fit GPU choices joined to the authoritative deployment market
634
679
  * snapshot. MODEL-ADDRESSED (recommended, book-first §2): pass `model` (or
@@ -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, LoopAgentCredential, LoopAgentStatus, LoopSampleRun, LoopSampleRunParams, 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, 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, AgentSettings, AgentSettingsRequest } 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.
@@ -84,6 +84,37 @@ export declare class Loop {
84
84
  * filed under: "everything in one bucket called import" is a corpus nobody
85
85
  * can slice afterwards. At most 5000 rows per call, because the call is
86
86
  * synchronous and somebody is waiting on it.
87
+ *
88
+ * WHAT COMES BACK. `imported` is what this call created and `trace_ids` names
89
+ * the conversations from the file that are now in the loop, so a caller can
90
+ * label, review or delete them. `by_shape`, `reviewed` and `needs_review`
91
+ * count what THIS CALL created, not what was merely recognised and not rows
92
+ * an earlier import already had, and the sentences in `notes` are written
93
+ * from those counts, so the numbers and the prose describe the same call and
94
+ * a re-send cannot report a reviewed conversation as waiting for review.
95
+ * `refused` is rows whose shape could not be read, which the file fixes;
96
+ * `not_saved` is rows that were understood and then could not be stored,
97
+ * which the file cannot fix.
98
+ *
99
+ * A call with any `not_saved`, or any `verdicts_not_saved` (the conversation
100
+ * stored and the judgement that came with it did not), REJECTS with
101
+ * `LoopImportIncompleteError`, whose `outcome` carries all of the above and
102
+ * whose `notSavedRows` and `verdictsNotSavedRows` name the positions.
103
+ *
104
+ * HOW A RETRY IS SAFE. Every response carries `import_id`, the token this
105
+ * call was filed under. Send the same rows again with it, and rows that
106
+ * already arrived come back on `already_present` instead of being stored
107
+ * twice, while a verdict that failed to write is attempted again. A call that
108
+ * repeats no token is its own import, deliberately: two calls carrying the
109
+ * same rows are as likely to be two pages of one export as one call twice,
110
+ * and guessing "retry" silently drops the second copy of every conversation a
111
+ * file lists more than once.
112
+ *
113
+ * SENDING A FILE IN PAGES. Either give each row its own `row_ids` entry, and
114
+ * then chunking, ordering and subsets all stop mattering; or send one
115
+ * `import_id` with the `row_offset` each page starts at. Do not send back
116
+ * only the rows `notSavedRows` names unless you used `row_ids`: without them
117
+ * a shorter list moves every row after the gap and imports it again.
87
118
  */
88
119
  importRows(params: LoopImportParams): Promise<LoopImportResult>;
89
120
  /** List captured conversations, newest first. */
@@ -398,6 +429,25 @@ export declare class Loop {
398
429
  * nothing: ask again and the same items come back.
399
430
  */
400
431
  takeWork(runId: string, limit?: number): Promise<LoopJudgeWork>;
432
+ /**
433
+ * What happened to each conversation in a run, and why.
434
+ *
435
+ * `takeWork` hands out what is still PENDING, so a finished run answers it
436
+ * with an empty list. This answers with every item and the outcome on it:
437
+ * `status`, `scored_at`, and `error` — the reason the caller gave for an
438
+ * item it could not score, which is where a wrong model slug or a refused
439
+ * key actually shows up. A run that ends "scored 0, failed 3" is otherwise a
440
+ * number with no detail behind it.
441
+ *
442
+ * Pass `status: 'failed'` for the usual question. At most 500 items come
443
+ * back at a time; when `has_more` is true, call again with the `next_offset`
444
+ * from the reply.
445
+ */
446
+ listRunItems(runId: string, opts?: {
447
+ status?: LoopJudgeRunItemStatus;
448
+ limit?: number;
449
+ offset?: number;
450
+ }): Promise<LoopJudgeRunItems>;
401
451
  /**
402
452
  * Hand the scores back. A verdict for a conversation outside this run, or
403
453
  * scoring something the rubric never asked for, is refused and reported in
@@ -420,6 +470,12 @@ export declare class Loop {
420
470
  * automatic judges and sample runs make model calls billed to the
421
471
  * workspace. Idempotent.
422
472
  *
473
+ * A judge whose model the serving gateway will not route is NOT resumed:
474
+ * making it automatic would buy a run that fails every conversation. It
475
+ * stays paused, `judges_still_paused` counts those, and each one carries
476
+ * `auto_pause_reason` saying so. Point it at a model that is served and
477
+ * turn the agent on again.
478
+ *
423
479
  * `monthly_spend_cap_cents` caps what that key may spend on model calls in
424
480
  * a calendar month. Omitted = no cap on a fresh key, and an existing cap is
425
481
  * left as it is; sent while the agent is already on, it moves the cap on
@@ -457,4 +513,199 @@ export declare class Loop {
457
513
  createSampleRun(params: LoopSampleRunParams): Promise<LoopSampleRun>;
458
514
  listSampleRuns(): Promise<LoopSampleRun[]>;
459
515
  getSampleRun(runId: string): Promise<LoopSampleRun>;
516
+ /**
517
+ * Price a training rule before anyone agrees to it. Writes nothing.
518
+ *
519
+ * Takes the create body without `accept_terms` and answers with the estimate
520
+ * a member has to see first: the pinned model revision, the worst hourly
521
+ * price each GPU ladder can reach, how many hours each ceiling buys, any
522
+ * refusals that would stop a create, the API keys that cannot follow a
523
+ * cutover because they lack `deployments:read`, and `terms_text` -- the
524
+ * exact sentence to show, with real figures in it.
525
+ *
526
+ * Send the `terms_version` it returns back in `createTrainingRule`. Read the
527
+ * figures out of this response rather than inventing ceilings of your own.
528
+ */
529
+ preflightTrainingRule(params: TrainingRulePreflightRequest): Promise<TrainingRulePreflight>;
530
+ /**
531
+ * Create a training rule and record the consent that pays for it.
532
+ *
533
+ * ACCEPTING THE TERMS AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT
534
+ * PRESENT. From here on the platform may, on its own schedule and without
535
+ * asking again, build a training set, run a training job on rented GPUs,
536
+ * book a second deployment to compare against the one serving your traffic,
537
+ * and pay for the model calls that judge the two. Those charges come out of
538
+ * the wallet of the member whose credentials make this call, up to the
539
+ * ceilings in `money`, and they keep recurring for as long as the rule is
540
+ * enabled. If `promotion.auto_promote` is set, the platform will also
541
+ * re-point your public handle at the new model with nobody reviewing it.
542
+ *
543
+ * `accept_terms` is therefore required, and this method refuses to send the
544
+ * request without it rather than letting the server decide. Call
545
+ * {@link preflightTrainingRule} first, show the person whose wallet pays the
546
+ * `terms_text` and the figures it returns, get an explicit yes, and send the
547
+ * `terms_version` they were shown. Do not invent ceilings or price caps on
548
+ * their behalf.
549
+ *
550
+ * @example
551
+ * ```ts
552
+ * const estimate = await client.loop.preflightTrainingRule(draft);
553
+ * // show estimate.terms_text and the ceilings to the member, get a yes
554
+ * const rule = await client.loop.createTrainingRule({
555
+ * ...draft,
556
+ * accept_terms: { terms_version: estimate.terms_version },
557
+ * });
558
+ * ```
559
+ */
560
+ createTrainingRule(params: TrainingRuleCreateRequest): Promise<TrainingRule>;
561
+ /**
562
+ * Every training rule in the workspace, with what each one last did and why.
563
+ *
564
+ * `last_reason` and `paused_reason` are the fields worth reading: a rule
565
+ * quiet because it is waiting looks exactly like one quiet because its
566
+ * consent went stale.
567
+ */
568
+ listTrainingRules(params?: TrainingRuleListParams): Promise<TrainingRuleListResponse>;
569
+ /**
570
+ * Read one rule with its recent runs, what it has spent this month, and how
571
+ * far its judge agrees with your own reviewers.
572
+ *
573
+ * Returned whole rather than unwrapped to the rule: `month_spent_cents` is
574
+ * the number that says whether the monthly ceiling is about to stop it.
575
+ */
576
+ getTrainingRule(id: string): Promise<TrainingRuleResponse>;
577
+ /**
578
+ * Edit or pause a rule. Absent means unchanged; a null clears the fields
579
+ * that can be cleared.
580
+ *
581
+ * A money-bearing change -- a ceiling, a model, a GPU ladder, the promotion
582
+ * policy -- bumps `revision`, clears the recorded consent and STOPS the rule
583
+ * firing until someone accepts the new amounts. The reply says so in
584
+ * `consent_required`, and carries a fresh `preflight` with the new figures.
585
+ * Pass `expected_revision` to be refused with `REVISION_MISMATCH` rather
586
+ * than overwrite an edit somebody else made in the meantime.
587
+ */
588
+ updateTrainingRule(id: string, params: TrainingRuleUpdateRequest): Promise<TrainingRuleMutationResponse>;
589
+ /**
590
+ * Accept the rule's current terms, so it may fire again.
591
+ *
592
+ * ACCEPTING THE TERMS AUTHORISES SPENDING FROM YOUR WALLET WHILE YOU ARE NOT
593
+ * PRESENT, on the amounts as they stand right now. This is the same
594
+ * authorisation {@link createTrainingRule} records, given again because a
595
+ * money-bearing edit cleared the old one: training, a candidate deployment
596
+ * and the judge's model calls are charged to the wallet of the member making
597
+ * this call, up to the rule's ceilings, every time it fires.
598
+ *
599
+ * Show the member the current `terms_text` from a fresh
600
+ * {@link preflightTrainingRule} or from the `preflight` on the update reply,
601
+ * and send the `revision` those figures belong to. A stale revision is
602
+ * refused with `409`, which is the point: it means the amounts moved again
603
+ * after they were read.
604
+ */
605
+ consentTrainingRule(id: string, params: TrainingRuleConsentRequest): Promise<TrainingRule>;
606
+ /**
607
+ * Fire a rule now, without waiting for its cadence.
608
+ *
609
+ * Bypasses the schedule and `min_new_rows` only. The row floors, the money
610
+ * ceilings and the consent all still apply, so this can answer `409
611
+ * CONSENT_REQUIRED` or `422 NOT_ENOUGH_ROWS` with the counts it needed.
612
+ */
613
+ runTrainingRule(id: string): Promise<TrainingRun>;
614
+ /**
615
+ * Delete a rule. An active run is cancelled; runs that already finished, and
616
+ * anything already promoted, are kept.
617
+ */
618
+ deleteTrainingRule(id: string): Promise<TrainingRuleDeleteResponse>;
619
+ /**
620
+ * Edit or pause a build rule -- the standing instruction that assembles the
621
+ * training set a training rule then trains on.
622
+ *
623
+ * Changing `spec.deployment_id` while an enabled training rule owns this
624
+ * build rule is refused with `409`: it would silently retrain the next model
625
+ * on a different source's conversations.
626
+ */
627
+ updateBuildRule(id: string, params: LoopBuildRuleUpdateParams): Promise<LoopBuildRule>;
628
+ /** Firings, newest first. Filter by rule or by the state they are sitting in. */
629
+ listTrainingRuns(params?: TrainingRunListParams): Promise<TrainingRunListResponse>;
630
+ /**
631
+ * One run with its timeline, the addresses of everything it created, and
632
+ * what you may do with it right now.
633
+ *
634
+ * `timeline` is written in the same transaction as each state change, so it
635
+ * is the record of what actually happened rather than a reconstruction.
636
+ * `available_actions` is the honest answer to "can I promote this": a button
637
+ * that cannot work should never be offered.
638
+ */
639
+ getTrainingRun(id: string): Promise<TrainingRunResponse>;
640
+ /**
641
+ * Promote the candidate by hand: re-point the public handle at the new model.
642
+ *
643
+ * This changes what answers your customers. Pass `expected_revision` to be
644
+ * refused rather than promote against a consent that moved underneath the
645
+ * decision, and `force` only to promote a comparison the evaluation called
646
+ * inconclusive -- without it that case is refused with
647
+ * `INCONCLUSIVE_REQUIRES_FORCE`.
648
+ */
649
+ promoteTrainingRun(id: string, params?: TrainingRunPromoteRequest): Promise<TrainingRunActionResponse>;
650
+ /** Retire the candidate. What serves your traffic does not change. */
651
+ rejectTrainingRun(id: string, params?: TrainingRunRejectRequest): Promise<TrainingRunActionResponse>;
652
+ /**
653
+ * Undo a promotion, inside the rollback window the run reports in
654
+ * `rollback_available_until` (30 days).
655
+ *
656
+ * The reply carries `serving`: this is the one action besides promotion that
657
+ * changes what answers your traffic, so what it was put back to is returned
658
+ * rather than left to be looked up.
659
+ */
660
+ rollbackTrainingRun(id: string, params?: TrainingRunRollbackRequest): Promise<TrainingRunActionResponse>;
661
+ /**
662
+ * Stop a run that is still moving. Work already paid for is still billed --
663
+ * cancelling a training job does not refund the hours it burned.
664
+ */
665
+ cancelTrainingRun(id: string, params?: TrainingRunCancelRequest): Promise<TrainingRunActionResponse>;
666
+ /**
667
+ * The comparison behind a verdict: both models on the same held-out rows,
668
+ * with identical decoding, judge and grader names resolved.
669
+ *
670
+ * Read `warnings` before you read `win_rate`. A win rate over a holdout too
671
+ * small to mean anything, or one measured by a judge that disagrees with
672
+ * your own reviewers, is reported with the warning that says so rather than
673
+ * withheld. `margin_used` is the thresholds this verdict was measured
674
+ * against, frozen with the report, so a later policy change cannot rewrite
675
+ * what a past decision meant.
676
+ */
677
+ getEvaluation(id: string): Promise<Evaluation>;
678
+ /**
679
+ * The paired conversations behind the numbers: one prompt, both answers, the
680
+ * scores each earned, and which won.
681
+ *
682
+ * Filter by `winner` to read the losses first, which is where a verdict is
683
+ * actually checked. `limit` is capped at 100 by the service.
684
+ */
685
+ listEvaluationItems(id: string, params?: EvaluationItemListParams): Promise<EvaluationItemsResponse>;
686
+ /**
687
+ * How far a judge agrees with your own reviewers, over the conversations
688
+ * both have scored.
689
+ *
690
+ * This is a gate, not a badge: a rule's `min_judge_agreement` refuses to
691
+ * promote on the word of a judge that does not agree with the people whose
692
+ * product it is. `enough_pairs` is the field to read first -- "not enough
693
+ * reviewer overlap yet" is an answer, and 100% of two pairs is not.
694
+ */
695
+ getJudgeAgreement(judgeId: string, params?: JudgeAgreementParams): Promise<JudgeAgreement>;
696
+ /**
697
+ * The workspace's agent options: which model it defaults to, the system
698
+ * prompts it judges and samples with, and the monthly cap on what its model
699
+ * calls may spend.
700
+ */
701
+ getAgentSettings(): Promise<AgentSettings>;
702
+ /**
703
+ * Change them. An absent key leaves that setting exactly where it is; a
704
+ * present null returns it to the platform default. Those are three
705
+ * instructions, not two, so `{}` changes nothing.
706
+ *
707
+ * `eval_monthly_cap_cents` is pushed to the workspace's managed key, so it
708
+ * caps what the agent can spend even if a rule's own ceilings are higher.
709
+ */
710
+ updateAgentSettings(params: AgentSettingsRequest): Promise<AgentSettings>;
460
711
  }