@sparkleideas/browser 3.0.0-alpha.2-patch.16 → 3.0.0-alpha.2-patch.18
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/package.json +3 -3
- package/dist/agent/index.d.ts +0 -25
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js +0 -33
- package/dist/agent/index.js.map +0 -1
- package/dist/application/browser-service.d.ts +0 -228
- package/dist/application/browser-service.d.ts.map +0 -1
- package/dist/application/browser-service.js +0 -470
- package/dist/application/browser-service.js.map +0 -1
- package/dist/domain/types.d.ts +0 -428
- package/dist/domain/types.d.ts.map +0 -1
- package/dist/domain/types.js +0 -95
- package/dist/domain/types.js.map +0 -1
- package/dist/index.d.ts +0 -131
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -84
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/agent-browser-adapter.d.ts +0 -134
- package/dist/infrastructure/agent-browser-adapter.d.ts.map +0 -1
- package/dist/infrastructure/agent-browser-adapter.js +0 -551
- package/dist/infrastructure/agent-browser-adapter.js.map +0 -1
- package/dist/infrastructure/hooks-integration.d.ts +0 -109
- package/dist/infrastructure/hooks-integration.d.ts.map +0 -1
- package/dist/infrastructure/hooks-integration.js +0 -111
- package/dist/infrastructure/hooks-integration.js.map +0 -1
- package/dist/infrastructure/memory-integration.d.ts +0 -149
- package/dist/infrastructure/memory-integration.d.ts.map +0 -1
- package/dist/infrastructure/memory-integration.js +0 -335
- package/dist/infrastructure/memory-integration.js.map +0 -1
- package/dist/infrastructure/reasoningbank-adapter.d.ts +0 -90
- package/dist/infrastructure/reasoningbank-adapter.d.ts.map +0 -1
- package/dist/infrastructure/reasoningbank-adapter.js +0 -224
- package/dist/infrastructure/reasoningbank-adapter.js.map +0 -1
- package/dist/infrastructure/security-integration.d.ts +0 -80
- package/dist/infrastructure/security-integration.d.ts.map +0 -1
- package/dist/infrastructure/security-integration.js +0 -404
- package/dist/infrastructure/security-integration.js.map +0 -1
- package/dist/infrastructure/workflow-templates.d.ts +0 -95
- package/dist/infrastructure/workflow-templates.d.ts.map +0 -1
- package/dist/infrastructure/workflow-templates.js +0 -366
- package/dist/infrastructure/workflow-templates.js.map +0 -1
- package/dist/mcp-tools/browser-tools.d.ts +0 -18
- package/dist/mcp-tools/browser-tools.d.ts.map +0 -1
- package/dist/mcp-tools/browser-tools.js +0 -1163
- package/dist/mcp-tools/browser-tools.js.map +0 -1
- package/dist/mcp-tools/index.d.ts +0 -6
- package/dist/mcp-tools/index.d.ts.map +0 -1
- package/dist/mcp-tools/index.js +0 -6
- package/dist/mcp-tools/index.js.map +0 -1
- package/dist/skill/index.d.ts +0 -15
- package/dist/skill/index.d.ts.map +0 -1
- package/dist/skill/index.js +0 -23
- package/dist/skill/index.js.map +0 -1
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @sparkleideas/browser - Hooks Integration
|
|
3
|
-
* pre-browse and post-browse hooks for claude-flow
|
|
4
|
-
*/
|
|
5
|
-
export interface PreBrowseInput {
|
|
6
|
-
goal: string;
|
|
7
|
-
url?: string;
|
|
8
|
-
context?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface PreBrowseResult {
|
|
11
|
-
recommendedSteps: Array<{
|
|
12
|
-
action: string;
|
|
13
|
-
selector?: string;
|
|
14
|
-
value?: string;
|
|
15
|
-
}>;
|
|
16
|
-
similarPatterns: number;
|
|
17
|
-
suggestedModel: 'haiku' | 'sonnet' | 'opus';
|
|
18
|
-
estimatedDuration: number;
|
|
19
|
-
warnings: string[];
|
|
20
|
-
}
|
|
21
|
-
export interface PostBrowseInput {
|
|
22
|
-
trajectoryId: string;
|
|
23
|
-
success: boolean;
|
|
24
|
-
verdict?: string;
|
|
25
|
-
duration: number;
|
|
26
|
-
stepsCompleted: number;
|
|
27
|
-
errors?: string[];
|
|
28
|
-
}
|
|
29
|
-
export interface PostBrowseResult {
|
|
30
|
-
patternStored: boolean;
|
|
31
|
-
patternId?: string;
|
|
32
|
-
learnedFrom: boolean;
|
|
33
|
-
statsUpdated: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Pre-browse hook - called before starting browser automation
|
|
37
|
-
* Returns recommendations based on learned patterns
|
|
38
|
-
*/
|
|
39
|
-
export declare function preBrowseHook(input: PreBrowseInput): Promise<PreBrowseResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Post-browse hook - called after browser automation completes
|
|
42
|
-
* Stores patterns and records learning feedback
|
|
43
|
-
*/
|
|
44
|
-
export declare function postBrowseHook(input: PostBrowseInput): Promise<PostBrowseResult>;
|
|
45
|
-
export declare const browserHooks: {
|
|
46
|
-
'pre-browse': {
|
|
47
|
-
name: string;
|
|
48
|
-
description: string;
|
|
49
|
-
handler: typeof preBrowseHook;
|
|
50
|
-
inputSchema: {
|
|
51
|
-
type: string;
|
|
52
|
-
properties: {
|
|
53
|
-
goal: {
|
|
54
|
-
type: string;
|
|
55
|
-
description: string;
|
|
56
|
-
};
|
|
57
|
-
url: {
|
|
58
|
-
type: string;
|
|
59
|
-
description: string;
|
|
60
|
-
};
|
|
61
|
-
context: {
|
|
62
|
-
type: string;
|
|
63
|
-
description: string;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
required: string[];
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
'post-browse': {
|
|
70
|
-
name: string;
|
|
71
|
-
description: string;
|
|
72
|
-
handler: typeof postBrowseHook;
|
|
73
|
-
inputSchema: {
|
|
74
|
-
type: string;
|
|
75
|
-
properties: {
|
|
76
|
-
trajectoryId: {
|
|
77
|
-
type: string;
|
|
78
|
-
description: string;
|
|
79
|
-
};
|
|
80
|
-
success: {
|
|
81
|
-
type: string;
|
|
82
|
-
description: string;
|
|
83
|
-
};
|
|
84
|
-
verdict: {
|
|
85
|
-
type: string;
|
|
86
|
-
description: string;
|
|
87
|
-
};
|
|
88
|
-
duration: {
|
|
89
|
-
type: string;
|
|
90
|
-
description: string;
|
|
91
|
-
};
|
|
92
|
-
stepsCompleted: {
|
|
93
|
-
type: string;
|
|
94
|
-
description: string;
|
|
95
|
-
};
|
|
96
|
-
errors: {
|
|
97
|
-
type: string;
|
|
98
|
-
items: {
|
|
99
|
-
type: string;
|
|
100
|
-
};
|
|
101
|
-
description: string;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
required: string[];
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
export default browserHooks;
|
|
109
|
-
//# sourceMappingURL=hooks-integration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-integration.d.ts","sourceRoot":"","sources":["../../src/infrastructure/hooks-integration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,KAAK,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC5C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;CACvB;AAMD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CA8CnF;AAMD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmBtF;AAMD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @sparkleideas/browser - Hooks Integration
|
|
3
|
-
* pre-browse and post-browse hooks for claude-flow
|
|
4
|
-
*/
|
|
5
|
-
import { getReasoningBank } from './reasoningbank-adapter.js';
|
|
6
|
-
// ============================================================================
|
|
7
|
-
// Pre-Browse Hook
|
|
8
|
-
// ============================================================================
|
|
9
|
-
/**
|
|
10
|
-
* Pre-browse hook - called before starting browser automation
|
|
11
|
-
* Returns recommendations based on learned patterns
|
|
12
|
-
*/
|
|
13
|
-
export async function preBrowseHook(input) {
|
|
14
|
-
const reasoningBank = getReasoningBank();
|
|
15
|
-
const warnings = [];
|
|
16
|
-
// Find similar patterns
|
|
17
|
-
const similarPatterns = await reasoningBank.findSimilarPatterns(input.goal);
|
|
18
|
-
// Get recommended steps
|
|
19
|
-
const recommendedSteps = await reasoningBank.getRecommendedSteps(input.goal);
|
|
20
|
-
// Suggest model based on complexity
|
|
21
|
-
let suggestedModel = 'sonnet';
|
|
22
|
-
if (recommendedSteps.length <= 3) {
|
|
23
|
-
suggestedModel = 'haiku';
|
|
24
|
-
}
|
|
25
|
-
else if (recommendedSteps.length > 10 || input.goal.toLowerCase().includes('complex')) {
|
|
26
|
-
suggestedModel = 'opus';
|
|
27
|
-
}
|
|
28
|
-
// Estimate duration based on patterns
|
|
29
|
-
let estimatedDuration = 5000; // Default 5s
|
|
30
|
-
if (similarPatterns.length > 0) {
|
|
31
|
-
estimatedDuration = Math.round(similarPatterns.reduce((sum, p) => sum + p.avgDuration * p.steps.length, 0) / similarPatterns.length);
|
|
32
|
-
}
|
|
33
|
-
// Generate warnings
|
|
34
|
-
if (input.url && !input.url.startsWith('https://')) {
|
|
35
|
-
warnings.push('URL is not HTTPS - authentication data may be at risk');
|
|
36
|
-
}
|
|
37
|
-
if (input.goal.toLowerCase().includes('login') && !input.goal.toLowerCase().includes('test')) {
|
|
38
|
-
warnings.push('Login detected - consider using state-save/state-load for session persistence');
|
|
39
|
-
}
|
|
40
|
-
if (similarPatterns.length === 0) {
|
|
41
|
-
warnings.push('No similar patterns found - this is a new workflow');
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
recommendedSteps,
|
|
45
|
-
similarPatterns: similarPatterns.length,
|
|
46
|
-
suggestedModel,
|
|
47
|
-
estimatedDuration,
|
|
48
|
-
warnings,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// ============================================================================
|
|
52
|
-
// Post-Browse Hook
|
|
53
|
-
// ============================================================================
|
|
54
|
-
/**
|
|
55
|
-
* Post-browse hook - called after browser automation completes
|
|
56
|
-
* Stores patterns and records learning feedback
|
|
57
|
-
*/
|
|
58
|
-
export async function postBrowseHook(input) {
|
|
59
|
-
const reasoningBank = getReasoningBank();
|
|
60
|
-
// Record verdict for learning
|
|
61
|
-
await reasoningBank.recordVerdict(input.trajectoryId, input.success, input.verdict);
|
|
62
|
-
// If there were errors, analyze them
|
|
63
|
-
if (input.errors && input.errors.length > 0) {
|
|
64
|
-
console.log(`[post-browse] Errors to learn from: ${input.errors.join(', ')}`);
|
|
65
|
-
}
|
|
66
|
-
const stats = reasoningBank.getStats();
|
|
67
|
-
return {
|
|
68
|
-
patternStored: input.success,
|
|
69
|
-
patternId: input.success ? `pattern-${input.trajectoryId}` : undefined,
|
|
70
|
-
learnedFrom: true,
|
|
71
|
-
statsUpdated: true,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
// ============================================================================
|
|
75
|
-
// Hook Registration for CLI
|
|
76
|
-
// ============================================================================
|
|
77
|
-
export const browserHooks = {
|
|
78
|
-
'pre-browse': {
|
|
79
|
-
name: 'pre-browse',
|
|
80
|
-
description: 'Get recommendations before browser automation',
|
|
81
|
-
handler: preBrowseHook,
|
|
82
|
-
inputSchema: {
|
|
83
|
-
type: 'object',
|
|
84
|
-
properties: {
|
|
85
|
-
goal: { type: 'string', description: 'What you want to accomplish' },
|
|
86
|
-
url: { type: 'string', description: 'Target URL (optional)' },
|
|
87
|
-
context: { type: 'string', description: 'Additional context' },
|
|
88
|
-
},
|
|
89
|
-
required: ['goal'],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
'post-browse': {
|
|
93
|
-
name: 'post-browse',
|
|
94
|
-
description: 'Record browser automation outcome for learning',
|
|
95
|
-
handler: postBrowseHook,
|
|
96
|
-
inputSchema: {
|
|
97
|
-
type: 'object',
|
|
98
|
-
properties: {
|
|
99
|
-
trajectoryId: { type: 'string', description: 'Trajectory ID from browser service' },
|
|
100
|
-
success: { type: 'boolean', description: 'Whether the automation succeeded' },
|
|
101
|
-
verdict: { type: 'string', description: 'Human feedback on quality' },
|
|
102
|
-
duration: { type: 'number', description: 'Total duration in ms' },
|
|
103
|
-
stepsCompleted: { type: 'number', description: 'Number of steps completed' },
|
|
104
|
-
errors: { type: 'array', items: { type: 'string' }, description: 'Error messages if any' },
|
|
105
|
-
},
|
|
106
|
-
required: ['trajectoryId', 'success', 'duration', 'stepsCompleted'],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
export default browserHooks;
|
|
111
|
-
//# sourceMappingURL=hooks-integration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-integration.js","source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BAA2B,EAAE;gBAC5E,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE;aAC3F;YACD,QAAQ,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,CAAC;SACpE;KACF;CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @sparkleideas/browser - Memory Integration
|
|
3
|
-
* Persistent memory storage with HNSW semantic search for browser patterns
|
|
4
|
-
*/
|
|
5
|
-
import type { BrowserTrajectory, Snapshot } from '../domain/types.js';
|
|
6
|
-
export interface BrowserMemoryEntry {
|
|
7
|
-
id: string;
|
|
8
|
-
type: 'trajectory' | 'pattern' | 'snapshot' | 'session' | 'error';
|
|
9
|
-
key: string;
|
|
10
|
-
value: Record<string, unknown>;
|
|
11
|
-
metadata: {
|
|
12
|
-
sessionId: string;
|
|
13
|
-
url?: string;
|
|
14
|
-
goal?: string;
|
|
15
|
-
success?: boolean;
|
|
16
|
-
duration?: number;
|
|
17
|
-
timestamp: string;
|
|
18
|
-
embedding?: number[];
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export interface MemorySearchResult {
|
|
22
|
-
entry: BrowserMemoryEntry;
|
|
23
|
-
score: number;
|
|
24
|
-
distance: number;
|
|
25
|
-
}
|
|
26
|
-
export interface MemoryStats {
|
|
27
|
-
totalEntries: number;
|
|
28
|
-
byType: Record<string, number>;
|
|
29
|
-
bySession: Record<string, number>;
|
|
30
|
-
avgEmbeddingDim: number;
|
|
31
|
-
indexSize: number;
|
|
32
|
-
}
|
|
33
|
-
export interface IMemoryAdapter {
|
|
34
|
-
store(entry: BrowserMemoryEntry): Promise<void>;
|
|
35
|
-
retrieve(key: string): Promise<BrowserMemoryEntry | null>;
|
|
36
|
-
search(query: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
|
|
37
|
-
delete(key: string): Promise<boolean>;
|
|
38
|
-
list(filter?: MemoryFilter): Promise<BrowserMemoryEntry[]>;
|
|
39
|
-
getStats(): Promise<MemoryStats>;
|
|
40
|
-
}
|
|
41
|
-
export interface MemorySearchOptions {
|
|
42
|
-
topK?: number;
|
|
43
|
-
minScore?: number;
|
|
44
|
-
type?: BrowserMemoryEntry['type'];
|
|
45
|
-
sessionId?: string;
|
|
46
|
-
namespace?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface MemoryFilter {
|
|
49
|
-
type?: BrowserMemoryEntry['type'];
|
|
50
|
-
sessionId?: string;
|
|
51
|
-
startTime?: string;
|
|
52
|
-
endTime?: string;
|
|
53
|
-
success?: boolean;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Adapter for claude-flow memory system with HNSW indexing
|
|
57
|
-
*/
|
|
58
|
-
export declare class ClaudeFlowMemoryAdapter implements IMemoryAdapter {
|
|
59
|
-
private namespace;
|
|
60
|
-
private cache;
|
|
61
|
-
private embeddingCache;
|
|
62
|
-
constructor(namespace?: string);
|
|
63
|
-
/**
|
|
64
|
-
* Store a browser memory entry with optional embedding
|
|
65
|
-
*/
|
|
66
|
-
store(entry: BrowserMemoryEntry): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Retrieve a specific memory entry
|
|
69
|
-
*/
|
|
70
|
-
retrieve(key: string): Promise<BrowserMemoryEntry | null>;
|
|
71
|
-
/**
|
|
72
|
-
* Semantic search using HNSW index (falls back to keyword search)
|
|
73
|
-
*/
|
|
74
|
-
search(query: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
|
|
75
|
-
/**
|
|
76
|
-
* Delete a memory entry
|
|
77
|
-
*/
|
|
78
|
-
delete(key: string): Promise<boolean>;
|
|
79
|
-
/**
|
|
80
|
-
* List entries with optional filters
|
|
81
|
-
*/
|
|
82
|
-
list(filter?: MemoryFilter): Promise<BrowserMemoryEntry[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Get memory statistics
|
|
85
|
-
*/
|
|
86
|
-
getStats(): Promise<MemoryStats>;
|
|
87
|
-
/**
|
|
88
|
-
* Generate text for embedding from entry
|
|
89
|
-
*/
|
|
90
|
-
private generateEmbeddingText;
|
|
91
|
-
/**
|
|
92
|
-
* Simple hash for embedding placeholder (real implementation would use ONNX)
|
|
93
|
-
*/
|
|
94
|
-
private simpleHash;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* High-level memory manager for browser automation
|
|
98
|
-
*/
|
|
99
|
-
export declare class BrowserMemoryManager {
|
|
100
|
-
private adapter;
|
|
101
|
-
private sessionId;
|
|
102
|
-
constructor(sessionId: string, adapter?: IMemoryAdapter);
|
|
103
|
-
/**
|
|
104
|
-
* Store a completed trajectory
|
|
105
|
-
*/
|
|
106
|
-
storeTrajectory(trajectory: BrowserTrajectory): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Store a learned pattern
|
|
109
|
-
*/
|
|
110
|
-
storePattern(patternId: string, goal: string, steps: Array<{
|
|
111
|
-
action: string;
|
|
112
|
-
selector?: string;
|
|
113
|
-
value?: string;
|
|
114
|
-
}>, success: boolean): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* Store a snapshot for later retrieval
|
|
117
|
-
*/
|
|
118
|
-
storeSnapshot(snapshotId: string, snapshot: Snapshot): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* Store an error for learning
|
|
121
|
-
*/
|
|
122
|
-
storeError(errorId: string, error: Error, context: {
|
|
123
|
-
action?: string;
|
|
124
|
-
selector?: string;
|
|
125
|
-
url?: string;
|
|
126
|
-
}): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Find similar trajectories for a given goal
|
|
129
|
-
*/
|
|
130
|
-
findSimilarTrajectories(goal: string, topK?: number): Promise<BrowserTrajectory[]>;
|
|
131
|
-
/**
|
|
132
|
-
* Find patterns for a given goal
|
|
133
|
-
*/
|
|
134
|
-
findPatterns(goal: string, successfulOnly?: boolean): Promise<MemorySearchResult[]>;
|
|
135
|
-
/**
|
|
136
|
-
* Get session memory stats
|
|
137
|
-
*/
|
|
138
|
-
getSessionStats(): Promise<{
|
|
139
|
-
trajectories: number;
|
|
140
|
-
patterns: number;
|
|
141
|
-
snapshots: number;
|
|
142
|
-
errors: number;
|
|
143
|
-
successRate: number;
|
|
144
|
-
}>;
|
|
145
|
-
private calculateDuration;
|
|
146
|
-
}
|
|
147
|
-
export declare function getMemoryAdapter(): IMemoryAdapter;
|
|
148
|
-
export declare function createMemoryManager(sessionId: string): BrowserMemoryManager;
|
|
149
|
-
//# sourceMappingURL=memory-integration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-integration.d.ts","sourceRoot":"","sources":["../../src/infrastructure/memory-integration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAyB,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAM3G,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,M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