Files
cobble/src/harness/harness-error.ts
T
tbenandClaude Opus 5.5 6a2665dae9 Add the harness, envs, per-bot models and chat attachments
- Harness: providers, model catalog synced hourly, automatic free picks,
  cooldowns, tool loop with context trimming, MCP computer tools
- Bots queue runs replies and tasks through the harness; jobs wait
  (attempt refunded) while every model is resting
- Envs: Settings > Environment, scoped general/workspace/computer,
  written to computers and redacted from tool output
- Models: Settings > Models, per-harness provider select defaulting to
  OpenRouter, and a models modal on each bot's chat (the coordinator's
  edits the defaults)
- Chat: thinking row while a reply runs, file attachments (upload,
  paste, drop) that replies read as images, audio and document text
- Fix media uploads failing after a user's first file, and private
  files being served from the public media path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 03:38:38 +01:00

67 lines
1.7 KiB
TypeScript

/**
* - `provider`: the provider refused or failed the call
* - `unavailable`: no model is set up (or left) for the harness
* - `aborted`: the caller cancelled
*/
export type HarnessErrorCode = "provider" | "unavailable" | "aborted";
type Params = {
message: string;
code?: HarnessErrorCode;
status?: number;
retryable?: boolean;
retry_at?: number;
provider_wide?: boolean;
candidate_key?: string;
resting?: boolean;
};
/**
* A failed harness call. Its message is safe to show the user.
*/
export default class HarnessError extends Error {
code: HarnessErrorCode;
status?: number;
/**
* Worth trying again later (rate limit, outage, timeout). False when
* only a different model or setting can help.
*/
retryable: boolean;
/**
* Unix ms before which the failed candidate shouldn't be tried again.
*/
retry_at?: number;
/**
* The provider's key or account is the problem, so every model on it
* fails the same way.
*/
provider_wide: boolean;
candidate_key?: string;
/**
* No model was tried: every one is cooling down until `retry_at`. A
* queued job waits instead of using up an attempt.
*/
resting: boolean;
constructor({
message,
code = "provider",
status,
retryable = false,
retry_at,
provider_wide = false,
candidate_key,
resting = false,
}: Params) {
super(message);
this.name = "HarnessError";
this.code = code;
this.status = status;
this.retryable = retryable;
this.retry_at = retry_at;
this.provider_wide = provider_wide;
this.candidate_key = candidate_key;
this.resting = resting;
}
}