@probelabs/probe 0.6.0-rc125 → 0.6.0-rc127

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.
@@ -0,0 +1,49 @@
1
+ import { StorageAdapter } from './StorageAdapter.js';
2
+
3
+ /**
4
+ * Default in-memory storage adapter
5
+ * This is the default behavior - stores history in a Map in memory
6
+ */
7
+ export class InMemoryStorageAdapter extends StorageAdapter {
8
+ constructor() {
9
+ super();
10
+ this.sessions = new Map(); // sessionId -> {messages: [], metadata: {}}
11
+ }
12
+
13
+ async loadHistory(sessionId) {
14
+ const session = this.sessions.get(sessionId);
15
+ return session ? session.messages : [];
16
+ }
17
+
18
+ async saveMessage(sessionId, message) {
19
+ if (!this.sessions.has(sessionId)) {
20
+ this.sessions.set(sessionId, {
21
+ messages: [],
22
+ metadata: {
23
+ createdAt: new Date().toISOString(),
24
+ lastActivity: new Date().toISOString()
25
+ }
26
+ });
27
+ }
28
+
29
+ const session = this.sessions.get(sessionId);
30
+ session.messages.push(message);
31
+ session.metadata.lastActivity = new Date().toISOString();
32
+ }
33
+
34
+ async clearHistory(sessionId) {
35
+ this.sessions.delete(sessionId);
36
+ }
37
+
38
+ async getSessionMetadata(sessionId) {
39
+ const session = this.sessions.get(sessionId);
40
+ return session ? session.metadata : null;
41
+ }
42
+
43
+ async updateSessionActivity(sessionId) {
44
+ const session = this.sessions.get(sessionId);
45
+ if (session) {
46
+ session.metadata.lastActivity = new Date().toISOString();
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Base class for storage adapters
3
+ * Implement this interface to provide custom storage backends for ProbeAgent history
4
+ */
5
+ export class StorageAdapter {
6
+ /**
7
+ * Load conversation history for a session
8
+ * @param {string} sessionId - Session identifier
9
+ * @returns {Promise<Array<Object>>} Array of message objects with {role, content, ...}
10
+ */
11
+ async loadHistory(sessionId) {
12
+ throw new Error('StorageAdapter.loadHistory() must be implemented by subclass');
13
+ }
14
+
15
+ /**
16
+ * Save a message to storage
17
+ * @param {string} sessionId - Session identifier
18
+ * @param {Object} message - Message object { role, content, ... }
19
+ * @returns {Promise<void>}
20
+ */
21
+ async saveMessage(sessionId, message) {
22
+ throw new Error('StorageAdapter.saveMessage() must be implemented by subclass');
23
+ }
24
+
25
+ /**
26
+ * Clear history for a session
27
+ * @param {string} sessionId - Session identifier
28
+ * @returns {Promise<void>}
29
+ */
30
+ async clearHistory(sessionId) {
31
+ throw new Error('StorageAdapter.clearHistory() must be implemented by subclass');
32
+ }
33
+
34
+ /**
35
+ * Get session metadata (optional)
36
+ * @param {string} sessionId - Session identifier
37
+ * @returns {Promise<Object|null>} Session metadata or null
38
+ */
39
+ async getSessionMetadata(sessionId) {
40
+ return null;
41
+ }
42
+
43
+ /**
44
+ * Update session activity timestamp (optional)
45
+ * @param {string} sessionId - Session identifier
46
+ * @returns {Promise<void>}
47
+ */
48
+ async updateSessionActivity(sessionId) {
49
+ // Optional - implement if you want to track session activity
50
+ }
51
+ }
@@ -0,0 +1,2 @@
1
+ export { StorageAdapter } from './StorageAdapter.js';
2
+ export { InMemoryStorageAdapter } from './InMemoryStorageAdapter.js';
package/build/index.js CHANGED
@@ -36,6 +36,8 @@ import { bashTool } from './tools/bash.js';
36
36
  import { ProbeAgent } from './agent/ProbeAgent.js';
37
37
  import { SimpleTelemetry, SimpleAppTracer, initializeSimpleTelemetryFromOptions } from './agent/simpleTelemetry.js';
38
38
  import { listFilesToolInstance, searchFilesToolInstance } from './agent/probeTool.js';
39
+ import { StorageAdapter, InMemoryStorageAdapter } from './agent/storage/index.js';
40
+ import { HookManager, HOOK_TYPES } from './agent/hooks/index.js';
39
41
 
40
42
  export {
41
43
  search,
@@ -50,6 +52,12 @@ export {
50
52
  DEFAULT_SYSTEM_MESSAGE,
51
53
  // Export AI Agent (NEW!)
52
54
  ProbeAgent,
55
+ // Export storage adapters
56
+ StorageAdapter,
57
+ InMemoryStorageAdapter,
58
+ // Export hooks
59
+ HookManager,
60
+ HOOK_TYPES,
53
61
  // Export telemetry classes
54
62
  SimpleTelemetry,
55
63
  SimpleAppTracer,