diff --git a/index.js b/index.js
index a710c09..2b8de62 100644
--- a/index.js
+++ b/index.js
@@ -1,28 +1,30 @@
-import { chat_metadata, callPopup, saveSettingsDebounced, is_send_press } from '../../../../script.js';
+import { chat_metadata, saveSettingsDebounced, is_send_press, extension_prompt_types } from '../../../../script.js';
import { getContext, extension_settings, saveMetadataDebounced, renderExtensionTemplateAsync } from '../../../extensions.js';
import {
substituteParams,
eventSource,
event_types,
generateQuietPrompt,
- animation_duration
+ animation_duration,
} from '../../../../script.js';
-import { registerSlashCommand } from '../../../slash-commands.js';
import { waitUntilCondition } from '../../../utils.js';
import { is_group_generating, selected_group } from '../../../group-chats.js';
import { dragElement } from '../../../../scripts/RossAscends-mods.js';
import { loadMovingUIState } from '../../../../scripts/power-user.js';
+import { callGenericPopup, Popup, POPUP_TYPE } from '../../../popup.js';
+import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
+import { SlashCommand } from '../../../slash-commands/SlashCommand.js';
const MODULE_NAME = 'Objective';
let taskTree = null;
-let globalTasks = [];
let currentChatId = '';
let currentObjective = null;
let currentTask = null;
let checkCounter = 0;
let lastMessageWasSwipe = false;
+let selectedCustomPrompt = 'default';
const defaultPrompts = {
@@ -74,7 +76,7 @@ async function generateTasks() {
const prompt = substituteParamsPrompts(objectivePrompts.createTask, false);
console.log('Generating tasks for objective with prompt');
toastr.info('Generating tasks for objective', 'Please wait...');
- const taskResponse = await generateQuietPrompt(prompt);
+ const taskResponse = await generateQuietPrompt(prompt, false, false);
// Clear all existing objective tasks when generating
currentObjective.children = [];
@@ -101,7 +103,8 @@ async function markTaskCompleted() {
async function checkTaskCompleted() {
// Make sure there are tasks
if (jQuery.isEmptyObject(currentTask)) {
- return;
+ console.warn('No current task to check');
+ return String(false);
}
try {
@@ -113,24 +116,27 @@ async function checkTaskCompleted() {
await waitUntilCondition(() => is_send_press === false, 30000, 10);
} catch {
console.debug('Failed to wait for group to finish generating');
- return;
+ return String(false);
}
- checkCounter = $('#objective-check-frequency').val();
+ checkCounter = Number($('#objective-check-frequency').val());
toastr.info('Checking for task completion.');
const prompt = substituteParamsPrompts(objectivePrompts.checkTaskCompleted, false);
- const taskResponse = (await generateQuietPrompt(prompt)).toLowerCase();
+ const taskResponse = (await generateQuietPrompt(prompt, false, false)).toLowerCase();
// Check response if task complete
if (taskResponse.includes('true')) {
console.info(`Character determined task '${currentTask.description} is completed.`);
currentTask.completeTask();
+ return String(true);
} else if (!(taskResponse.includes('false'))) {
console.warn(`checkTaskCompleted response did not contain true or false. taskResponse: ${taskResponse}`);
} else {
console.debug(`Checked task completion. taskResponse: ${taskResponse}`);
}
+
+ return String(false);
}
function getNextIncompleteTaskRecurse(task) {
@@ -184,10 +190,10 @@ function setCurrentTask(taskId = null, skipSave = false) {
}
// Update the extension prompt
- context.setExtensionPrompt(MODULE_NAME, extensionPromptText, 1, $('#objective-chat-depth').val());
+ context.setExtensionPrompt(MODULE_NAME, extensionPromptText, extension_prompt_types.IN_CHAT, Number($('#objective-chat-depth').val()));
console.info(`Current task in context.extensionPrompts.Objective is ${JSON.stringify(context.extensionPrompts.Objective)}`);
} else {
- context.setExtensionPrompt(MODULE_NAME, '');
+ context.setExtensionPrompt(MODULE_NAME, '', extension_prompt_types.NONE, 0);
console.info('No current task');
}
@@ -447,28 +453,29 @@ function onEditPromptClick() {
let popupText = '';
popupText += `
+
+
+
+
+
+
+
+
+
Edit prompts used by Objective for this session. You can use {{objective}} or {{task}} plus any other standard template variables. Save template to persist changes.
-
+