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]>
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
import { z } from "zod";
|
||||
import { AppData } from "@/src/data/app-data";
|
||||
|
||||
export const SendBotMessageRequestSchema = z.object({
|
||||
bot_id: z.coerce.number().int().positive("Pick a bot to message"),
|
||||
text: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, "Write a message first")
|
||||
.max(4000, "Keep messages under 4000 characters"),
|
||||
});
|
||||
text: z.string().trim().max(4000, "Keep messages under 4000 characters").default(""),
|
||||
media_ids: z
|
||||
.array(z.coerce.number().int().positive())
|
||||
.max(AppData.BotAttachmentMaxFiles, `Attach up to ${AppData.BotAttachmentMaxFiles} files`)
|
||||
.default([]),
|
||||
}).refine((body) => body.text || body.media_ids.length, "Write a message or attach a file first");
|
||||
|
||||
export type SendBotMessageRequest = z.infer<typeof SendBotMessageRequestSchema>;
|
||||
|
||||
export const BotIdRequestSchema = z.object({
|
||||
bot_id: z.coerce.number().int().positive("Pick a bot"),
|
||||
});
|
||||
|
||||
export type BotIdRequest = z.infer<typeof BotIdRequestSchema>;
|
||||
|
||||
export const UploadBotAttachmentRequestSchema = z.object({
|
||||
/**
|
||||
* The file as a base64 data URL.
|
||||
*/
|
||||
data_url: z.string().startsWith("data:", "Send the file as a data URL"),
|
||||
name: z.string().trim().min(1, "The file needs a name").max(255),
|
||||
});
|
||||
|
||||
export type UploadBotAttachmentRequest = z.infer<typeof UploadBotAttachmentRequestSchema>;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { z } from "zod";
|
||||
import { EnvParadigms, type EnvParadigm } from "@/src/dict/env-dict";
|
||||
|
||||
export const SaveEnvRequestSchema = z.object({
|
||||
env_id: z.coerce.number().int().positive().optional(),
|
||||
key: z.string().trim().min(1, "Enter a key").max(128),
|
||||
/**
|
||||
* Left out when editing keeps the saved value.
|
||||
*/
|
||||
value: z.string().max(20000, "Keep values under 20,000 characters").optional(),
|
||||
description: z.string().trim().max(500).optional(),
|
||||
paradigm: z.enum(EnvParadigms.map((p) => p.value) as [EnvParadigm, ...EnvParadigm[]]),
|
||||
workspace_id: z.coerce.number().int().positive().nullable().optional(),
|
||||
computer_id: z.coerce.number().int().positive().nullable().optional(),
|
||||
secret: z.boolean(),
|
||||
expose_to_computers: z.boolean(),
|
||||
});
|
||||
|
||||
export const EnvIdRequestSchema = z.object({
|
||||
env_id: z.coerce.number().int().positive(),
|
||||
});
|
||||
|
||||
export type SaveEnvRequest = z.infer<typeof SaveEnvRequestSchema>;
|
||||
export type EnvIdRequest = z.infer<typeof EnvIdRequestSchema>;
|
||||
@@ -0,0 +1,78 @@
|
||||
import { z } from "zod";
|
||||
import { Harnesses, type HarnessKind } from "@/src/dict/harness-dict";
|
||||
import {
|
||||
HarnessProviderKinds,
|
||||
type HarnessProviderKind,
|
||||
} from "@/src/dict/harness-provider-dict";
|
||||
|
||||
const ProviderIdSchema = z.coerce
|
||||
.number()
|
||||
.int()
|
||||
.positive("Pick a provider");
|
||||
|
||||
export const SaveHarnessProviderRequestSchema = z.object({
|
||||
provider_id: ProviderIdSchema.optional(),
|
||||
kind: z.enum(
|
||||
HarnessProviderKinds.map((kind) => kind.value) as [
|
||||
HarnessProviderKind,
|
||||
...HarnessProviderKind[],
|
||||
],
|
||||
"Pick a provider type",
|
||||
),
|
||||
name: z.string().trim().max(80, "Keep the name under 80 characters").optional(),
|
||||
base_url: z.string().trim().max(500, "That address is too long").optional(),
|
||||
api_key: z.string().trim().max(1000, "That key is too long").optional(),
|
||||
clear_key: z.boolean().optional(),
|
||||
enabled: z.boolean(),
|
||||
});
|
||||
|
||||
export const HarnessProviderIdRequestSchema = z.object({
|
||||
provider_id: ProviderIdSchema,
|
||||
});
|
||||
|
||||
export const SaveHarnessSettingsRequestSchema = z.object({
|
||||
settings: z
|
||||
.array(
|
||||
z.object({
|
||||
harness: z.enum(
|
||||
Harnesses.map((harness) => harness.value) as [
|
||||
HarnessKind,
|
||||
...HarnessKind[],
|
||||
],
|
||||
),
|
||||
model_id: z.coerce.number().int().positive().nullable(),
|
||||
provider_id: z.coerce.number().int().positive().nullable().optional(),
|
||||
fallback: z.boolean(),
|
||||
enabled: z.boolean(),
|
||||
voice: z.string().trim().max(200).optional(),
|
||||
}),
|
||||
)
|
||||
.min(1, "Nothing to save")
|
||||
.max(Harnesses.length),
|
||||
});
|
||||
|
||||
/**
|
||||
* A worker bot's own model settings. `inherit` drops the bot's setting
|
||||
* for that harness so it uses the default again.
|
||||
*/
|
||||
export const SaveBotHarnessSettingsRequestSchema = z.object({
|
||||
bot_id: z.coerce.number().int().positive(),
|
||||
settings: z
|
||||
.array(
|
||||
SaveHarnessSettingsRequestSchema.shape.settings.element.extend({
|
||||
inherit: z.boolean().default(false),
|
||||
}),
|
||||
)
|
||||
.min(1, "Nothing to save")
|
||||
.max(Harnesses.length),
|
||||
});
|
||||
|
||||
export type SaveHarnessProviderRequest = z.infer<
|
||||
typeof SaveHarnessProviderRequestSchema
|
||||
>;
|
||||
export type SaveHarnessSettingsRequest = z.infer<
|
||||
typeof SaveHarnessSettingsRequestSchema
|
||||
>;
|
||||
export type SaveBotHarnessSettingsRequest = z.infer<
|
||||
typeof SaveBotHarnessSettingsRequestSchema
|
||||
>;
|
||||
Reference in New Issue
Block a user