Move to threads based system.
This commit is contained in:
@@ -11,6 +11,7 @@ type ClaimedJob = {
|
||||
job: Doc<'agentJobs'>;
|
||||
spoon: Doc<'spoons'> | null;
|
||||
aiSettings: Doc<'userAiSettings'> | null;
|
||||
aiProviderProfile: Doc<'aiProviderProfiles'> | null;
|
||||
agentSettings: Doc<'spoonAgentSettings'> | null;
|
||||
secrets: Doc<'spoonSecrets'>[];
|
||||
};
|
||||
@@ -19,10 +20,20 @@ type WorkerClaim = {
|
||||
job: Doc<'agentJobs'>;
|
||||
spoon: Doc<'spoons'>;
|
||||
openai: {
|
||||
apiKey: string;
|
||||
apiKey?: string;
|
||||
model: string;
|
||||
reasoningEffort: Doc<'agentJobs'>['reasoningEffort'];
|
||||
};
|
||||
aiProviderProfile?: {
|
||||
id: string;
|
||||
name: string;
|
||||
provider: Doc<'aiProviderProfiles'>['provider'];
|
||||
authType: Doc<'aiProviderProfiles'>['authType'];
|
||||
secret?: string;
|
||||
baseUrl?: string;
|
||||
model: string;
|
||||
reasoningEffort: Doc<'aiProviderProfiles'>['reasoningEffort'];
|
||||
};
|
||||
agentSettings: Doc<'spoonAgentSettings'> | null;
|
||||
github: {
|
||||
installationId?: string;
|
||||
@@ -53,18 +64,36 @@ export const claimNextForWorker = action({
|
||||
if (!claimed.spoon) {
|
||||
throw new ConvexError('Claimed job points at a missing Spoon.');
|
||||
}
|
||||
if (!claimed.aiSettings?.encryptedApiKey) {
|
||||
if (!claimed.aiProviderProfile) {
|
||||
throw new ConvexError(
|
||||
'OpenAI is not configured for this user. Add an OpenAI API key in settings.',
|
||||
'AI is not configured for this user. Add an AI provider in settings.',
|
||||
);
|
||||
}
|
||||
if (
|
||||
claimed.aiProviderProfile.authType !== 'none' &&
|
||||
!claimed.aiProviderProfile.encryptedSecret
|
||||
) {
|
||||
throw new ConvexError('Selected AI provider is missing credentials.');
|
||||
}
|
||||
const profile = claimed.aiProviderProfile;
|
||||
return {
|
||||
job: claimed.job,
|
||||
spoon: claimed.spoon,
|
||||
openai: {
|
||||
apiKey: decryptSecret(claimed.aiSettings.encryptedApiKey),
|
||||
model: claimed.job.model,
|
||||
reasoningEffort: claimed.job.reasoningEffort,
|
||||
model: profile.defaultModel,
|
||||
reasoningEffort: profile.reasoningEffort,
|
||||
},
|
||||
aiProviderProfile: {
|
||||
id: profile._id,
|
||||
name: profile.name,
|
||||
provider: profile.provider,
|
||||
authType: profile.authType,
|
||||
secret: profile.encryptedSecret
|
||||
? decryptSecret(profile.encryptedSecret)
|
||||
: undefined,
|
||||
baseUrl: profile.baseUrl,
|
||||
model: profile.defaultModel,
|
||||
reasoningEffort: profile.reasoningEffort,
|
||||
},
|
||||
agentSettings: claimed.agentSettings,
|
||||
github: {
|
||||
|
||||
Reference in New Issue
Block a user