cbrowser 8.2.4 → 8.3.0
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/cli.js +179 -1
- package/dist/cli.js.map +1 -1
- package/dist/cognitive/index.d.ts +71 -0
- package/dist/cognitive/index.d.ts.map +1 -0
- package/dist/cognitive/index.js +468 -0
- package/dist/cognitive/index.js.map +1 -0
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +277 -0
- package/dist/mcp-server.js.map +1 -1
- package/dist/personas.d.ts +18 -1
- package/dist/personas.d.ts.map +1 -1
- package/dist/personas.js +247 -0
- package/dist/personas.js.map +1 -1
- package/dist/types.d.ts +176 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Journey API Module
|
|
3
|
+
*
|
|
4
|
+
* Provides autonomous cognitive user simulation using Claude API directly.
|
|
5
|
+
* This allows CBrowser to run cognitive journeys standalone without Claude Code.
|
|
6
|
+
*
|
|
7
|
+
* @module cognitive
|
|
8
|
+
*/
|
|
9
|
+
import type { CognitiveState, CognitiveJourneyResult, CognitiveTraits } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Get the Anthropic API key from environment or config file.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAnthropicApiKey(): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Get the Claude model to use for cognitive journeys.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAnthropicModel(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Set the Anthropic API key in the config file.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setAnthropicApiKey(apiKey: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Remove the Anthropic API key from the config file.
|
|
24
|
+
*/
|
|
25
|
+
export declare function removeAnthropicApiKey(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Check if API key is configured and valid format.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isApiKeyConfigured(): boolean;
|
|
30
|
+
export interface CognitiveJourneyOptions {
|
|
31
|
+
/** Persona name or description */
|
|
32
|
+
persona: string;
|
|
33
|
+
/** Goal statement for the journey */
|
|
34
|
+
goal: string;
|
|
35
|
+
/** Starting URL */
|
|
36
|
+
startUrl: string;
|
|
37
|
+
/** Custom cognitive trait overrides */
|
|
38
|
+
customTraits?: Partial<CognitiveTraits>;
|
|
39
|
+
/** Maximum steps before timeout */
|
|
40
|
+
maxSteps?: number;
|
|
41
|
+
/** Maximum time in seconds */
|
|
42
|
+
maxTime?: number;
|
|
43
|
+
/** Verbose output */
|
|
44
|
+
verbose?: boolean;
|
|
45
|
+
/** Run in headless mode (default: false for live viewing, auto-detects server) */
|
|
46
|
+
headless?: boolean;
|
|
47
|
+
/** Callback for step updates */
|
|
48
|
+
onStep?: (step: CognitiveStep) => void;
|
|
49
|
+
}
|
|
50
|
+
export interface CognitiveStep {
|
|
51
|
+
step: number;
|
|
52
|
+
phase: "perceive" | "comprehend" | "decide" | "execute" | "evaluate";
|
|
53
|
+
monologue: string;
|
|
54
|
+
action?: string;
|
|
55
|
+
state: CognitiveState;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Run an autonomous cognitive journey using the Claude API.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const result = await runCognitiveJourney({
|
|
63
|
+
* persona: "first-timer",
|
|
64
|
+
* goal: "Sign up for an account",
|
|
65
|
+
* startUrl: "https://example.com",
|
|
66
|
+
* });
|
|
67
|
+
* console.log(result.goalAchieved ? "Success!" : `Abandoned: ${result.abandonmentReason}`);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function runCognitiveJourney(options: CognitiveJourneyOptions): Promise<CognitiveJourneyResult>;
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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AED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAkQjC"}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cognitive Journey API Module
|
|
4
|
+
*
|
|
5
|
+
* Provides autonomous cognitive user simulation using Claude API directly.
|
|
6
|
+
* This allows CBrowser to run cognitive journeys standalone without Claude Code.
|
|
7
|
+
*
|
|
8
|
+
* @module cognitive
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getAnthropicApiKey = getAnthropicApiKey;
|
|
15
|
+
exports.getAnthropicModel = getAnthropicModel;
|
|
16
|
+
exports.setAnthropicApiKey = setAnthropicApiKey;
|
|
17
|
+
exports.removeAnthropicApiKey = removeAnthropicApiKey;
|
|
18
|
+
exports.isApiKeyConfigured = isApiKeyConfigured;
|
|
19
|
+
exports.runCognitiveJourney = runCognitiveJourney;
|
|
20
|
+
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
21
|
+
const fs_1 = require("fs");
|
|
22
|
+
const path_1 = require("path");
|
|
23
|
+
const browser_js_1 = require("../browser.js");
|
|
24
|
+
const personas_js_1 = require("../personas.js");
|
|
25
|
+
const config_js_1 = require("../config.js");
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// API Key Management
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Get the Anthropic API key from environment or config file.
|
|
31
|
+
*/
|
|
32
|
+
function getAnthropicApiKey() {
|
|
33
|
+
// 1. Environment variable (highest priority)
|
|
34
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
35
|
+
return process.env.ANTHROPIC_API_KEY;
|
|
36
|
+
}
|
|
37
|
+
// 2. Config file
|
|
38
|
+
const config = (0, config_js_1.loadConfigFile)();
|
|
39
|
+
if (config?.anthropicApiKey) {
|
|
40
|
+
return config.anthropicApiKey;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the Claude model to use for cognitive journeys.
|
|
46
|
+
*/
|
|
47
|
+
function getAnthropicModel() {
|
|
48
|
+
const config = (0, config_js_1.loadConfigFile)();
|
|
49
|
+
return (process.env.ANTHROPIC_MODEL ||
|
|
50
|
+
config?.anthropicModel ||
|
|
51
|
+
"claude-sonnet-4-20250514");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set the Anthropic API key in the config file.
|
|
55
|
+
*/
|
|
56
|
+
function setAnthropicApiKey(apiKey) {
|
|
57
|
+
const configPath = (0, path_1.join)((0, config_js_1.getDataDir)(), "config.json");
|
|
58
|
+
let config = {};
|
|
59
|
+
if ((0, fs_1.existsSync)(configPath)) {
|
|
60
|
+
try {
|
|
61
|
+
config = JSON.parse((0, fs_1.readFileSync)(configPath, "utf-8"));
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Start fresh if corrupted
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
config.anthropicApiKey = apiKey;
|
|
68
|
+
(0, fs_1.writeFileSync)(configPath, JSON.stringify(config, null, 2));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Remove the Anthropic API key from the config file.
|
|
72
|
+
*/
|
|
73
|
+
function removeAnthropicApiKey() {
|
|
74
|
+
const configPath = (0, path_1.join)((0, config_js_1.getDataDir)(), "config.json");
|
|
75
|
+
if (!(0, fs_1.existsSync)(configPath))
|
|
76
|
+
return;
|
|
77
|
+
try {
|
|
78
|
+
const config = JSON.parse((0, fs_1.readFileSync)(configPath, "utf-8"));
|
|
79
|
+
delete config.anthropicApiKey;
|
|
80
|
+
(0, fs_1.writeFileSync)(configPath, JSON.stringify(config, null, 2));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Ignore errors
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if API key is configured and valid format.
|
|
88
|
+
*/
|
|
89
|
+
function isApiKeyConfigured() {
|
|
90
|
+
const key = getAnthropicApiKey();
|
|
91
|
+
return !!key && key.startsWith("sk-ant-");
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Run an autonomous cognitive journey using the Claude API.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const result = await runCognitiveJourney({
|
|
99
|
+
* persona: "first-timer",
|
|
100
|
+
* goal: "Sign up for an account",
|
|
101
|
+
* startUrl: "https://example.com",
|
|
102
|
+
* });
|
|
103
|
+
* console.log(result.goalAchieved ? "Success!" : `Abandoned: ${result.abandonmentReason}`);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
async function runCognitiveJourney(options) {
|
|
107
|
+
const apiKey = getAnthropicApiKey();
|
|
108
|
+
if (!apiKey) {
|
|
109
|
+
throw new Error("Anthropic API key not configured. Run: npx cbrowser config set-api-key YOUR_KEY");
|
|
110
|
+
}
|
|
111
|
+
const anthropic = new sdk_1.default({ apiKey });
|
|
112
|
+
const model = getAnthropicModel();
|
|
113
|
+
// Get or create persona
|
|
114
|
+
const existingPersona = (0, personas_js_1.getPersona)(options.persona);
|
|
115
|
+
let personaObj;
|
|
116
|
+
if (!existingPersona) {
|
|
117
|
+
personaObj = (0, personas_js_1.createCognitivePersona)(options.persona, options.persona, options.customTraits || {});
|
|
118
|
+
}
|
|
119
|
+
else if (options.customTraits) {
|
|
120
|
+
const defaultTraits = {
|
|
121
|
+
patience: 0.5,
|
|
122
|
+
riskTolerance: 0.5,
|
|
123
|
+
comprehension: 0.5,
|
|
124
|
+
persistence: 0.5,
|
|
125
|
+
curiosity: 0.5,
|
|
126
|
+
workingMemory: 0.5,
|
|
127
|
+
readingTendency: 0.5,
|
|
128
|
+
};
|
|
129
|
+
personaObj = {
|
|
130
|
+
...existingPersona,
|
|
131
|
+
cognitiveTraits: {
|
|
132
|
+
...defaultTraits,
|
|
133
|
+
...(existingPersona.cognitiveTraits || {}),
|
|
134
|
+
...options.customTraits,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
personaObj = existingPersona;
|
|
140
|
+
}
|
|
141
|
+
const profile = (0, personas_js_1.getCognitiveProfile)(personaObj);
|
|
142
|
+
const traits = profile.traits;
|
|
143
|
+
// Calculate abandonment thresholds
|
|
144
|
+
const thresholds = {
|
|
145
|
+
patienceMin: 0.1,
|
|
146
|
+
confusionMax: traits.comprehension < 0.4 ? 0.6 : 0.8,
|
|
147
|
+
frustrationMax: traits.patience < 0.3 ? 0.7 : 0.85,
|
|
148
|
+
maxStepsWithoutProgress: traits.persistence > 0.7 ? 15 : 10,
|
|
149
|
+
loopDetectionThreshold: 3,
|
|
150
|
+
timeLimit: options.maxTime ||
|
|
151
|
+
(traits.patience > 0.7 ? 180 : traits.patience < 0.3 ? 60 : 120),
|
|
152
|
+
};
|
|
153
|
+
// Initialize state
|
|
154
|
+
const state = {
|
|
155
|
+
patienceRemaining: 1.0,
|
|
156
|
+
confusionLevel: 0.0,
|
|
157
|
+
frustrationLevel: 0.0,
|
|
158
|
+
goalProgress: 0.0,
|
|
159
|
+
confidenceLevel: 0.5,
|
|
160
|
+
currentMood: "neutral",
|
|
161
|
+
memory: {
|
|
162
|
+
pagesVisited: [options.startUrl],
|
|
163
|
+
actionsAttempted: [],
|
|
164
|
+
errorsEncountered: [],
|
|
165
|
+
backtrackCount: 0,
|
|
166
|
+
},
|
|
167
|
+
timeElapsed: 0,
|
|
168
|
+
stepCount: 0,
|
|
169
|
+
};
|
|
170
|
+
// Initialize browser (auto-detect headless for servers without display)
|
|
171
|
+
const headless = options.headless ?? !process.env.DISPLAY;
|
|
172
|
+
const browser = new browser_js_1.CBrowser({ headless, persistent: true });
|
|
173
|
+
await browser.navigate(options.startUrl);
|
|
174
|
+
const fullMonologue = [];
|
|
175
|
+
const frictionPoints = [];
|
|
176
|
+
const startTime = Date.now();
|
|
177
|
+
const maxSteps = options.maxSteps || 50;
|
|
178
|
+
// Build system prompt
|
|
179
|
+
const systemPrompt = buildCognitiveSystemPrompt(personaObj, profile, options.goal, thresholds);
|
|
180
|
+
// Conversation history for Claude
|
|
181
|
+
const messages = [];
|
|
182
|
+
let goalAchieved = false;
|
|
183
|
+
let abandonmentReason;
|
|
184
|
+
let abandonmentMessage;
|
|
185
|
+
let currentUrl = options.startUrl;
|
|
186
|
+
// Main cognitive loop
|
|
187
|
+
for (let step = 1; step <= maxSteps; step++) {
|
|
188
|
+
state.stepCount = step;
|
|
189
|
+
state.timeElapsed = (Date.now() - startTime) / 1000;
|
|
190
|
+
// Check time limit
|
|
191
|
+
if (state.timeElapsed > thresholds.timeLimit) {
|
|
192
|
+
abandonmentReason = "timeout";
|
|
193
|
+
abandonmentMessage = `I've spent too long on this (${Math.round(state.timeElapsed)}s). Giving up.`;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
// Get page state via screenshot
|
|
197
|
+
const screenshotPath = await browser.screenshot();
|
|
198
|
+
const pageTitle = "Current Page"; // Simplified - CBrowser doesn't expose title directly
|
|
199
|
+
// Build step prompt
|
|
200
|
+
const stepPrompt = buildStepPrompt(state, currentUrl, pageTitle, step);
|
|
201
|
+
messages.push({ role: "user", content: stepPrompt });
|
|
202
|
+
// Call Claude for cognitive reasoning
|
|
203
|
+
const response = await anthropic.messages.create({
|
|
204
|
+
model,
|
|
205
|
+
max_tokens: 2000,
|
|
206
|
+
system: systemPrompt,
|
|
207
|
+
messages: messages.map((m) => ({ role: m.role, content: m.content })),
|
|
208
|
+
});
|
|
209
|
+
const assistantMessage = response.content[0].type === "text" ? response.content[0].text : "";
|
|
210
|
+
messages.push({ role: "assistant", content: assistantMessage });
|
|
211
|
+
// Parse Claude's response
|
|
212
|
+
const parsed = parseCognitiveResponse(assistantMessage);
|
|
213
|
+
// Update state with Claude's assessment
|
|
214
|
+
state.confusionLevel = parsed.newConfusion ?? state.confusionLevel;
|
|
215
|
+
state.frustrationLevel = parsed.newFrustration ?? state.frustrationLevel;
|
|
216
|
+
state.goalProgress = parsed.goalProgress ?? state.goalProgress;
|
|
217
|
+
state.currentMood = parsed.mood ?? state.currentMood;
|
|
218
|
+
// Deplete patience
|
|
219
|
+
state.patienceRemaining -= 0.02 + state.frustrationLevel * 0.05;
|
|
220
|
+
// Record monologue
|
|
221
|
+
if (parsed.monologue) {
|
|
222
|
+
fullMonologue.push(parsed.monologue);
|
|
223
|
+
}
|
|
224
|
+
// Record friction point if confusion/frustration spiked
|
|
225
|
+
if (parsed.frictionDescription && (state.confusionLevel > 0.4 || state.frustrationLevel > 0.4)) {
|
|
226
|
+
frictionPoints.push({
|
|
227
|
+
step,
|
|
228
|
+
url: currentUrl,
|
|
229
|
+
element: parsed.frictionElement,
|
|
230
|
+
type: "confusing_ui",
|
|
231
|
+
frustrationIncrease: parsed.newFrustration ? parsed.newFrustration - state.frustrationLevel : 0.1,
|
|
232
|
+
monologue: parsed.monologue || "",
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// Callback
|
|
236
|
+
if (options.onStep) {
|
|
237
|
+
options.onStep({
|
|
238
|
+
step,
|
|
239
|
+
phase: parsed.phase || "evaluate",
|
|
240
|
+
monologue: parsed.monologue || "",
|
|
241
|
+
action: parsed.action,
|
|
242
|
+
state: { ...state },
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// Verbose output
|
|
246
|
+
if (options.verbose) {
|
|
247
|
+
console.log(`\n━━━ Step ${step} ━━━`);
|
|
248
|
+
console.log(`Mood: ${state.currentMood}`);
|
|
249
|
+
console.log(`Patience: ${(state.patienceRemaining * 100).toFixed(0)}% | Confusion: ${(state.confusionLevel * 100).toFixed(0)}% | Frustration: ${(state.frustrationLevel * 100).toFixed(0)}%`);
|
|
250
|
+
if (parsed.monologue)
|
|
251
|
+
console.log(`💭 "${parsed.monologue}"`);
|
|
252
|
+
if (parsed.action)
|
|
253
|
+
console.log(`🎯 Action: ${parsed.action}`);
|
|
254
|
+
}
|
|
255
|
+
// Check for goal completion
|
|
256
|
+
if (parsed.goalAchieved) {
|
|
257
|
+
goalAchieved = true;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
// Check abandonment triggers
|
|
261
|
+
const abandonment = checkAbandonmentTriggers(state, thresholds);
|
|
262
|
+
if (abandonment) {
|
|
263
|
+
abandonmentReason = abandonment.reason;
|
|
264
|
+
abandonmentMessage = abandonment.message;
|
|
265
|
+
fullMonologue.push(abandonment.message);
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
// Execute action if provided
|
|
269
|
+
if (parsed.action) {
|
|
270
|
+
try {
|
|
271
|
+
const result = await executeAction(browser, parsed.action);
|
|
272
|
+
state.memory.actionsAttempted.push({
|
|
273
|
+
action: parsed.action,
|
|
274
|
+
target: parsed.actionTarget,
|
|
275
|
+
success: result.success,
|
|
276
|
+
});
|
|
277
|
+
// Track page visits if URL changed
|
|
278
|
+
if (result.newUrl && !state.memory.pagesVisited.includes(result.newUrl)) {
|
|
279
|
+
state.memory.pagesVisited.push(result.newUrl);
|
|
280
|
+
currentUrl = result.newUrl;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
state.memory.errorsEncountered.push({
|
|
285
|
+
error: error instanceof Error ? error.message : String(error),
|
|
286
|
+
context: `Step ${step}: ${parsed.action}`,
|
|
287
|
+
});
|
|
288
|
+
state.frustrationLevel = Math.min(1, state.frustrationLevel + 0.15);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// Small delay between steps
|
|
292
|
+
await sleep(500);
|
|
293
|
+
}
|
|
294
|
+
// Close browser
|
|
295
|
+
await browser.close();
|
|
296
|
+
// Calculate summary stats
|
|
297
|
+
const avgConfusion = frictionPoints.length > 0
|
|
298
|
+
? frictionPoints.reduce((sum, fp) => sum + (state.confusionLevel), 0) / frictionPoints.length
|
|
299
|
+
: state.confusionLevel;
|
|
300
|
+
// Build result
|
|
301
|
+
return {
|
|
302
|
+
persona: personaObj.name,
|
|
303
|
+
goal: options.goal,
|
|
304
|
+
goalAchieved,
|
|
305
|
+
abandonmentReason,
|
|
306
|
+
abandonmentMessage,
|
|
307
|
+
totalTime: (Date.now() - startTime) / 1000,
|
|
308
|
+
stepCount: state.stepCount,
|
|
309
|
+
frictionPoints,
|
|
310
|
+
fullMonologue,
|
|
311
|
+
finalState: state,
|
|
312
|
+
summary: {
|
|
313
|
+
avgConfusionLevel: avgConfusion,
|
|
314
|
+
maxFrustrationLevel: state.frustrationLevel,
|
|
315
|
+
backtrackCount: state.memory.backtrackCount,
|
|
316
|
+
timeInConfusion: frictionPoints.length * 2, // Estimate
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// ============================================================================
|
|
321
|
+
// Helper Functions
|
|
322
|
+
// ============================================================================
|
|
323
|
+
function buildCognitiveSystemPrompt(persona, profile, goal, thresholds) {
|
|
324
|
+
const traits = profile.traits;
|
|
325
|
+
return `You are simulating a "${persona.name}" user navigating a website.
|
|
326
|
+
|
|
327
|
+
PERSONA DESCRIPTION: ${persona.description}
|
|
328
|
+
|
|
329
|
+
COGNITIVE TRAITS:
|
|
330
|
+
- Patience: ${traits.patience.toFixed(2)} ${traits.patience < 0.3 ? "(impatient)" : traits.patience > 0.7 ? "(patient)" : "(moderate)"}
|
|
331
|
+
- Risk Tolerance: ${traits.riskTolerance.toFixed(2)} ${traits.riskTolerance < 0.3 ? "(cautious)" : traits.riskTolerance > 0.7 ? "(bold)" : "(moderate)"}
|
|
332
|
+
- Comprehension: ${traits.comprehension.toFixed(2)} ${traits.comprehension < 0.4 ? "(struggles with UI)" : traits.comprehension > 0.7 ? "(expert)" : "(moderate)"}
|
|
333
|
+
- Persistence: ${traits.persistence.toFixed(2)}
|
|
334
|
+
- Curiosity: ${traits.curiosity.toFixed(2)}
|
|
335
|
+
- Reading Tendency: ${traits.readingTendency.toFixed(2)} ${traits.readingTendency < 0.3 ? "(scans only)" : traits.readingTendency > 0.7 ? "(reads everything)" : "(selective reader)"}
|
|
336
|
+
|
|
337
|
+
ATTENTION PATTERN: ${profile.attentionPattern}
|
|
338
|
+
DECISION STYLE: ${profile.decisionStyle}
|
|
339
|
+
|
|
340
|
+
GOAL: "${goal}"
|
|
341
|
+
|
|
342
|
+
RESPONSE FORMAT (JSON):
|
|
343
|
+
{
|
|
344
|
+
"phase": "perceive|comprehend|decide|execute|evaluate",
|
|
345
|
+
"monologue": "Internal thought as this persona (first person)",
|
|
346
|
+
"action": "click:selector|fill:selector:value|navigate:url|null",
|
|
347
|
+
"actionTarget": "description of what you're clicking/filling",
|
|
348
|
+
"goalAchieved": boolean,
|
|
349
|
+
"goalProgress": 0.0-1.0,
|
|
350
|
+
"newConfusion": 0.0-1.0,
|
|
351
|
+
"newFrustration": 0.0-1.0,
|
|
352
|
+
"mood": "neutral|hopeful|confused|frustrated|defeated|relieved",
|
|
353
|
+
"frictionDescription": "what caused confusion/frustration (if any)" | null,
|
|
354
|
+
"frictionElement": "element that caused friction" | null
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
ABANDONMENT THRESHOLDS:
|
|
358
|
+
- If patience drops below ${thresholds.patienceMin}, give up
|
|
359
|
+
- If confusion exceeds ${thresholds.confusionMax}, give up
|
|
360
|
+
- If frustration exceeds ${thresholds.frustrationMax}, give up
|
|
361
|
+
|
|
362
|
+
BEHAVIOR GUIDELINES:
|
|
363
|
+
1. PERCEIVE: Describe what you see on the page
|
|
364
|
+
2. COMPREHEND: Interpret UI based on your comprehension level (low = more confusion)
|
|
365
|
+
3. DECIDE: Choose action based on risk tolerance and goal relevance
|
|
366
|
+
4. For click actions, use descriptive selectors like "login button", "email input", etc.
|
|
367
|
+
5. If comprehension is low, misinterpret ambiguous elements
|
|
368
|
+
6. If patience is low, get frustrated quickly with delays
|
|
369
|
+
7. Generate authentic inner monologue matching persona voice
|
|
370
|
+
|
|
371
|
+
Always respond with valid JSON.`;
|
|
372
|
+
}
|
|
373
|
+
function buildStepPrompt(state, currentUrl, pageTitle, step) {
|
|
374
|
+
return `STEP ${step}
|
|
375
|
+
|
|
376
|
+
CURRENT PAGE:
|
|
377
|
+
- URL: ${currentUrl}
|
|
378
|
+
- Title: ${pageTitle}
|
|
379
|
+
|
|
380
|
+
CURRENT STATE:
|
|
381
|
+
- Patience: ${(state.patienceRemaining * 100).toFixed(0)}%
|
|
382
|
+
- Confusion: ${(state.confusionLevel * 100).toFixed(0)}%
|
|
383
|
+
- Frustration: ${(state.frustrationLevel * 100).toFixed(0)}%
|
|
384
|
+
- Goal Progress: ${(state.goalProgress * 100).toFixed(0)}%
|
|
385
|
+
- Mood: ${state.currentMood}
|
|
386
|
+
- Pages Visited: ${state.memory.pagesVisited.length}
|
|
387
|
+
- Actions Attempted: ${state.memory.actionsAttempted.length}
|
|
388
|
+
|
|
389
|
+
Based on this information, what do you perceive, comprehend, and decide to do?
|
|
390
|
+
Describe what you would expect to see on a page at this URL, then choose an action.
|
|
391
|
+
Respond in JSON format.`;
|
|
392
|
+
}
|
|
393
|
+
function parseCognitiveResponse(response) {
|
|
394
|
+
try {
|
|
395
|
+
// Extract JSON from response (may have markdown code blocks)
|
|
396
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
397
|
+
if (jsonMatch) {
|
|
398
|
+
return JSON.parse(jsonMatch[0]);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
catch {
|
|
402
|
+
// Parsing failed
|
|
403
|
+
}
|
|
404
|
+
return {};
|
|
405
|
+
}
|
|
406
|
+
function checkAbandonmentTriggers(state, thresholds) {
|
|
407
|
+
if (state.patienceRemaining < thresholds.patienceMin) {
|
|
408
|
+
return { reason: "patience", message: "This is taking too long. I give up." };
|
|
409
|
+
}
|
|
410
|
+
if (state.confusionLevel > thresholds.confusionMax) {
|
|
411
|
+
return {
|
|
412
|
+
reason: "confusion",
|
|
413
|
+
message: "I have no idea what to do. This is too confusing.",
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
if (state.frustrationLevel > thresholds.frustrationMax) {
|
|
417
|
+
return {
|
|
418
|
+
reason: "frustration",
|
|
419
|
+
message: "This is so frustrating! I'm done.",
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
// Loop detection
|
|
423
|
+
const recentPages = state.memory.pagesVisited.slice(-5);
|
|
424
|
+
const uniqueRecent = new Set(recentPages).size;
|
|
425
|
+
if (recentPages.length >= 5 &&
|
|
426
|
+
uniqueRecent <= thresholds.loopDetectionThreshold) {
|
|
427
|
+
return {
|
|
428
|
+
reason: "loop",
|
|
429
|
+
message: "I keep ending up on the same pages. Something is wrong.",
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
// No progress
|
|
433
|
+
if (state.stepCount > thresholds.maxStepsWithoutProgress &&
|
|
434
|
+
state.goalProgress < 0.1) {
|
|
435
|
+
return {
|
|
436
|
+
reason: "no_progress",
|
|
437
|
+
message: "I'm not making any progress. This isn't working.",
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
return null;
|
|
441
|
+
}
|
|
442
|
+
async function executeAction(browser, action) {
|
|
443
|
+
const [type, ...args] = action.split(":");
|
|
444
|
+
switch (type) {
|
|
445
|
+
case "click": {
|
|
446
|
+
const selector = args.join(":");
|
|
447
|
+
await browser.click(selector);
|
|
448
|
+
return { success: true };
|
|
449
|
+
}
|
|
450
|
+
case "fill": {
|
|
451
|
+
const [selector, ...valueParts] = args;
|
|
452
|
+
await browser.fill(selector, valueParts.join(":"));
|
|
453
|
+
return { success: true };
|
|
454
|
+
}
|
|
455
|
+
case "navigate": {
|
|
456
|
+
const url = args.join(":");
|
|
457
|
+
const result = await browser.navigate(url);
|
|
458
|
+
return { success: true, newUrl: result.url };
|
|
459
|
+
}
|
|
460
|
+
default:
|
|
461
|
+
// Unknown action type, skip
|
|
462
|
+
return { success: false };
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function sleep(ms) {
|
|
466
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
467
|
+
}
|
|
468
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cognitive/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;AA6BH,gDAaC;AAKD,8CAOC;AAKD,gDAcC;AAKD,sDAWC;AAKD,gDAGC;AAgDD,kDAoQC;AAnZD,4DAA0C;AAC1C,2BAA6D;AAC7D,+BAA4B;AAC5B,8CAAyC;AACzC,gDAIwB;AAUxB,4CAA0D;AAE1D,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH,SAAgB,kBAAkB;IAChC,6CAA6C;IAC7C,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACvC,CAAC;IAED,iBAAiB;IACjB,MAAM,MAAM,GAAG,IAAA,0BAAc,GAAE,CAAC;IAChC,IAAI,MAAM,EAAE,eAAe,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,MAAM,GAAG,IAAA,0BAAc,GAAE,CAAC;IAChC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,eAAe;QAC3B,MAAM,EAAE,cAAc;QACtB,0BAA0B,CAC3B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,IAAA,sBAAU,GAAE,EAAE,aAAa,CAAC,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/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AA0EH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAwxCpD"}
|