@redplanethq/sdk 0.1.2 → 0.1.4
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/LICENSE +1 -1
- package/README.md +43 -18
- package/dist/index.d.mts +321 -14
- package/dist/index.d.ts +321 -14
- package/dist/index.js +120 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Core SDK
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Core SDK provides tools and utilities for building integrations with the Core platform.
|
|
4
4
|
|
|
5
5
|
## Integration System
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The Core integration system uses a CLI-based approach where each integration is a command-line tool that responds to specific events. This makes integrations portable, testable, and easy to debug.
|
|
8
8
|
|
|
9
9
|
### Integration Event Types
|
|
10
10
|
|
|
11
11
|
Each integration CLI handles 5 core event types:
|
|
12
12
|
|
|
13
13
|
#### 1. `spec`
|
|
14
|
+
|
|
14
15
|
Returns the integration's metadata and configuration.
|
|
15
16
|
|
|
16
17
|
**Usage:**
|
|
18
|
+
|
|
17
19
|
```bash
|
|
18
20
|
my-integration spec
|
|
19
21
|
```
|
|
@@ -21,9 +23,11 @@ my-integration spec
|
|
|
21
23
|
**Returns:** Integration specification including name, description, auth config, etc.
|
|
22
24
|
|
|
23
25
|
#### 2. `setup`
|
|
26
|
+
|
|
24
27
|
Processes authentication data and returns tokens/credentials to be saved.
|
|
25
28
|
|
|
26
29
|
**Usage:**
|
|
30
|
+
|
|
27
31
|
```bash
|
|
28
32
|
my-integration setup --event-body '{"code":"oauth_code","state":"state"}' --integration-definition '{}'
|
|
29
33
|
```
|
|
@@ -31,9 +35,11 @@ my-integration setup --event-body '{"code":"oauth_code","state":"state"}' --inte
|
|
|
31
35
|
**Returns:** Configuration data (tokens, credentials) to be stored for the account.
|
|
32
36
|
|
|
33
37
|
#### 3. `identify`
|
|
38
|
+
|
|
34
39
|
Extracts accountId from webhook data to route webhooks to the correct account.
|
|
35
40
|
|
|
36
41
|
**Usage:**
|
|
42
|
+
|
|
37
43
|
```bash
|
|
38
44
|
my-integration identify --webhook-data '{"team_id":"T123","event":{}}'
|
|
39
45
|
```
|
|
@@ -41,9 +47,11 @@ my-integration identify --webhook-data '{"team_id":"T123","event":{}}'
|
|
|
41
47
|
**Returns:** Account identifier for webhook routing.
|
|
42
48
|
|
|
43
49
|
#### 4. `process`
|
|
50
|
+
|
|
44
51
|
Handles webhook events and returns activity data.
|
|
45
52
|
|
|
46
53
|
**Usage:**
|
|
54
|
+
|
|
47
55
|
```bash
|
|
48
56
|
my-integration process --event-data '{"type":"reaction_added","reaction":"=M"}' --config '{"access_token":"token"}'
|
|
49
57
|
```
|
|
@@ -51,9 +59,11 @@ my-integration process --event-data '{"type":"reaction_added","reaction":"=M"}'
|
|
|
51
59
|
**Returns:** Activity messages representing user actions.
|
|
52
60
|
|
|
53
61
|
#### 5. `sync`
|
|
62
|
+
|
|
54
63
|
Performs scheduled data synchronization for integrations that don't support webhooks.
|
|
55
64
|
|
|
56
65
|
**Usage:**
|
|
66
|
+
|
|
57
67
|
```bash
|
|
58
68
|
my-integration sync --config '{"access_token":"token","last_sync":"2023-01-01T00:00:00Z"}'
|
|
59
69
|
```
|
|
@@ -72,20 +82,24 @@ All integration responses are wrapped in a `Message` object with a `type` field:
|
|
|
72
82
|
### Building an Integration
|
|
73
83
|
|
|
74
84
|
1. **Install the SDK:**
|
|
85
|
+
|
|
75
86
|
```bash
|
|
76
|
-
npm install @
|
|
87
|
+
npm install @Core/core-sdk
|
|
77
88
|
```
|
|
78
89
|
|
|
79
90
|
2. **Create your integration class:**
|
|
91
|
+
|
|
80
92
|
```typescript
|
|
81
|
-
import { IntegrationCLI } from '@
|
|
93
|
+
import { IntegrationCLI } from '@Core/core-sdk';
|
|
82
94
|
|
|
83
95
|
class MyIntegration extends IntegrationCLI {
|
|
84
96
|
constructor() {
|
|
85
97
|
super('my-integration', '1.0.0');
|
|
86
98
|
}
|
|
87
99
|
|
|
88
|
-
protected async handleEvent(
|
|
100
|
+
protected async handleEvent(
|
|
101
|
+
eventPayload: IntegrationEventPayload,
|
|
102
|
+
): Promise<any> {
|
|
89
103
|
switch (eventPayload.event) {
|
|
90
104
|
case 'SETUP':
|
|
91
105
|
return this.handleSetup(eventPayload);
|
|
@@ -110,24 +124,28 @@ class MyIntegration extends IntegrationCLI {
|
|
|
110
124
|
OAuth2: {
|
|
111
125
|
token_url: 'https://api.example.com/oauth/token',
|
|
112
126
|
authorization_url: 'https://api.example.com/oauth/authorize',
|
|
113
|
-
scopes: ['read', 'write']
|
|
114
|
-
}
|
|
115
|
-
}
|
|
127
|
+
scopes: ['read', 'write'],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
116
130
|
};
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
private async handleSetup(
|
|
133
|
+
private async handleSetup(
|
|
134
|
+
eventPayload: IntegrationEventPayload,
|
|
135
|
+
): Promise<any> {
|
|
120
136
|
// Process OAuth response and return tokens to save
|
|
121
137
|
const { code } = eventPayload.eventBody;
|
|
122
138
|
// Exchange code for tokens...
|
|
123
139
|
return {
|
|
124
140
|
access_token: 'token',
|
|
125
141
|
refresh_token: 'refresh_token',
|
|
126
|
-
expires_at: Date.now() + 3600000
|
|
142
|
+
expires_at: Date.now() + 3600000,
|
|
127
143
|
};
|
|
128
144
|
}
|
|
129
145
|
|
|
130
|
-
private async handleProcess(
|
|
146
|
+
private async handleProcess(
|
|
147
|
+
eventPayload: IntegrationEventPayload,
|
|
148
|
+
): Promise<any> {
|
|
131
149
|
// Handle webhook events
|
|
132
150
|
const { eventData } = eventPayload.eventBody;
|
|
133
151
|
// Process event and return activity...
|
|
@@ -135,23 +153,29 @@ class MyIntegration extends IntegrationCLI {
|
|
|
135
153
|
type: 'message',
|
|
136
154
|
user: 'user123',
|
|
137
155
|
content: 'Hello world',
|
|
138
|
-
timestamp: new Date()
|
|
156
|
+
timestamp: new Date(),
|
|
139
157
|
};
|
|
140
158
|
}
|
|
141
159
|
|
|
142
|
-
private async handleIdentify(
|
|
160
|
+
private async handleIdentify(
|
|
161
|
+
eventPayload: IntegrationEventPayload,
|
|
162
|
+
): Promise<any> {
|
|
143
163
|
// Extract account ID from webhook
|
|
144
164
|
const { team_id } = eventPayload.eventBody;
|
|
145
165
|
return { id: team_id };
|
|
146
166
|
}
|
|
147
167
|
|
|
148
|
-
private async handleSync(
|
|
168
|
+
private async handleSync(
|
|
169
|
+
eventPayload: IntegrationEventPayload,
|
|
170
|
+
): Promise<any> {
|
|
149
171
|
// Perform scheduled sync
|
|
150
172
|
const { config } = eventPayload;
|
|
151
173
|
// Fetch data since last sync...
|
|
152
174
|
return {
|
|
153
|
-
activities: [
|
|
154
|
-
|
|
175
|
+
activities: [
|
|
176
|
+
/* activity data */
|
|
177
|
+
],
|
|
178
|
+
state: { last_sync: new Date().toISOString() },
|
|
155
179
|
};
|
|
156
180
|
}
|
|
157
181
|
}
|
|
@@ -162,6 +186,7 @@ integration.parse();
|
|
|
162
186
|
```
|
|
163
187
|
|
|
164
188
|
3. **Build and package your integration:**
|
|
189
|
+
|
|
165
190
|
```bash
|
|
166
191
|
npm run build
|
|
167
192
|
npm pack
|
|
@@ -200,4 +225,4 @@ node dist/index.js process --event-data '{"type":"test"}' --config '{"token":"te
|
|
|
200
225
|
5. **Store minimal state** for sync operations
|
|
201
226
|
6. **Test all event types** thoroughly
|
|
202
227
|
|
|
203
|
-
For more examples, see the integrations in the `integrations/` directory.
|
|
228
|
+
For more examples, see the integrations in the `integrations/` directory.
|
package/dist/index.d.mts
CHANGED
|
@@ -53,9 +53,25 @@ declare const LLMModelType: {
|
|
|
53
53
|
};
|
|
54
54
|
type LLMModelType = (typeof LLMModelType)[keyof typeof LLMModelType];
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Interface for document node in the reified knowledge graph
|
|
58
|
+
* Documents are parent containers for episodic chunks
|
|
59
|
+
*/
|
|
60
|
+
interface DocumentNode {
|
|
61
|
+
uuid: string;
|
|
62
|
+
title: string;
|
|
63
|
+
originalContent: string;
|
|
64
|
+
metadata: Record<string, any>;
|
|
65
|
+
source: string;
|
|
66
|
+
userId: string;
|
|
67
|
+
createdAt: Date;
|
|
68
|
+
validAt: Date;
|
|
69
|
+
totalChunks: number;
|
|
70
|
+
sessionId?: string;
|
|
71
|
+
version: number;
|
|
72
|
+
contentHash: string;
|
|
73
|
+
previousVersionUuid?: string;
|
|
74
|
+
chunkHashes?: string[];
|
|
59
75
|
}
|
|
60
76
|
/**
|
|
61
77
|
* Interface for episodic node in the reified knowledge graph
|
|
@@ -74,7 +90,23 @@ interface EpisodicNode {
|
|
|
74
90
|
userId: string;
|
|
75
91
|
space?: string;
|
|
76
92
|
sessionId?: string;
|
|
93
|
+
recallCount?: number;
|
|
94
|
+
chunkIndex?: number;
|
|
95
|
+
labelIds?: string[];
|
|
77
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Episodic node without embeddings for query responses
|
|
99
|
+
* Use this type when returning episodes from Cypher queries to avoid loading large embedding arrays
|
|
100
|
+
*/
|
|
101
|
+
type EpisodicNodeWithoutEmbeddings = Omit<EpisodicNode, "contentEmbedding">;
|
|
102
|
+
/**
|
|
103
|
+
* Helper to get episodic node properties for Cypher RETURN clause (excludes embeddings)
|
|
104
|
+
* Usage in Cypher: RETURN ${EPISODIC_NODE_PROPERTIES} as episode
|
|
105
|
+
*/
|
|
106
|
+
declare const EPISODIC_NODE_PROPERTIES = "{\n uuid: e.uuid,\n content: e.content,\n originalContent: e.originalContent,\n createdAt: e.createdAt,\n userId: e.userId,\n sessionId: e.sessionId,\n labelIds: e.labelIds,\n validAt: e.validAt,\n recallCount: e.recallCount,\n chunkIndex: e.chunkIndex\n}";
|
|
107
|
+
declare const STATEMENT_NODE_PROPERTIES = "{\n uuid: s.uuid,\n fact: s.fact,\n createdAt: s.createdAt,\n userId: s.userId,\n validAt: s.validAt,\n invalidAt: s.invalidAt,\n invalidatedBy: s.invalidatedBy,\n attributes: s.attributes,\n recallCount: s.recallCount,\n provenanceCount: s.provenanceCount\n}";
|
|
108
|
+
declare const ENTITY_NODE_PROPERTIES = "{\n uuid: ent.uuid,\n name: ent.name,\n createdAt: ent.createdAt,\n userId: ent.userId,\n attributes: ent.attributes\n}";
|
|
109
|
+
declare const COMPACTED_SESSION_NODE_PROPERTIES = "{\n uuid: cs.uuid,\n sessionId: cs.sessionId,\n summary: cs.summary,\n episodeCount: cs.episodeCount,\n startTime: cs.startTime,\n endTime: cs.endTime,\n createdAt: cs.createdAt,\n updatedAt: cs.updatedAt,\n confidence: cs.confidence,\n userId: cs.userId,\n source: cs.source,\n compressionRatio: cs.compressionRatio,\n metadata: cs.metadata\n}";
|
|
78
110
|
/**
|
|
79
111
|
* Interface for entity node in the reified knowledge graph
|
|
80
112
|
* Entities represent subjects, objects, or predicates in statements
|
|
@@ -82,13 +114,11 @@ interface EpisodicNode {
|
|
|
82
114
|
interface EntityNode {
|
|
83
115
|
uuid: string;
|
|
84
116
|
name: string;
|
|
85
|
-
type
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
typeEmbedding: number[];
|
|
117
|
+
type?: string;
|
|
118
|
+
nameEmbedding?: number[];
|
|
119
|
+
attributes?: Record<string, any>;
|
|
89
120
|
createdAt: Date;
|
|
90
121
|
userId: string;
|
|
91
|
-
space?: string;
|
|
92
122
|
}
|
|
93
123
|
/**
|
|
94
124
|
* Interface for statement node in the reified knowledge graph
|
|
@@ -101,9 +131,16 @@ interface StatementNode {
|
|
|
101
131
|
createdAt: Date;
|
|
102
132
|
validAt: Date;
|
|
103
133
|
invalidAt: Date | null;
|
|
134
|
+
invalidatedBy?: string;
|
|
104
135
|
attributes: Record<string, any>;
|
|
105
136
|
userId: string;
|
|
106
137
|
space?: string;
|
|
138
|
+
labelIds?: string[];
|
|
139
|
+
recallCount?: {
|
|
140
|
+
low: number;
|
|
141
|
+
high: number;
|
|
142
|
+
};
|
|
143
|
+
provenanceCount?: number;
|
|
107
144
|
}
|
|
108
145
|
/**
|
|
109
146
|
* Interface for a triple in the reified knowledge graph
|
|
@@ -117,14 +154,25 @@ interface Triple {
|
|
|
117
154
|
object: EntityNode;
|
|
118
155
|
provenance: EpisodicNode;
|
|
119
156
|
}
|
|
157
|
+
declare enum EpisodeTypeEnum {
|
|
158
|
+
CONVERSATION = "CONVERSATION",
|
|
159
|
+
DOCUMENT = "DOCUMENT"
|
|
160
|
+
}
|
|
161
|
+
declare const EpisodeType: {
|
|
162
|
+
CONVERSATION: string;
|
|
163
|
+
DOCUMENT: string;
|
|
164
|
+
IMAGE: string;
|
|
165
|
+
};
|
|
166
|
+
type EpisodeType = (typeof EpisodeType)[keyof typeof EpisodeType];
|
|
120
167
|
type AddEpisodeParams = {
|
|
121
168
|
episodeBody: string;
|
|
122
169
|
referenceTime: Date;
|
|
123
|
-
metadata
|
|
170
|
+
metadata?: Record<string, any>;
|
|
124
171
|
source: string;
|
|
125
172
|
userId: string;
|
|
126
173
|
spaceId?: string;
|
|
127
174
|
sessionId?: string;
|
|
175
|
+
type?: EpisodeType;
|
|
128
176
|
};
|
|
129
177
|
type AddEpisodeResult = {
|
|
130
178
|
episodeUuid: string;
|
|
@@ -134,13 +182,29 @@ type AddEpisodeResult = {
|
|
|
134
182
|
};
|
|
135
183
|
interface ExtractedTripleData {
|
|
136
184
|
source: string;
|
|
137
|
-
sourceType
|
|
185
|
+
sourceType?: string;
|
|
138
186
|
predicate: string;
|
|
139
187
|
target: string;
|
|
140
|
-
targetType
|
|
188
|
+
targetType?: string;
|
|
141
189
|
fact: string;
|
|
142
190
|
attributes?: Record<string, any>;
|
|
143
191
|
}
|
|
192
|
+
interface CompactedSessionNode {
|
|
193
|
+
uuid: string;
|
|
194
|
+
sessionId: string;
|
|
195
|
+
summary: string;
|
|
196
|
+
summaryEmbedding?: number[];
|
|
197
|
+
episodeCount: number;
|
|
198
|
+
startTime: Date;
|
|
199
|
+
endTime: Date;
|
|
200
|
+
createdAt: Date;
|
|
201
|
+
updatedAt?: Date;
|
|
202
|
+
confidence: number;
|
|
203
|
+
userId: string;
|
|
204
|
+
source: string;
|
|
205
|
+
compressionRatio?: number;
|
|
206
|
+
metadata?: Record<string, any>;
|
|
207
|
+
}
|
|
144
208
|
|
|
145
209
|
declare enum ActionStatusEnum {
|
|
146
210
|
ACCEPT = "ACCEPT",
|
|
@@ -199,10 +263,23 @@ declare enum IntegrationEventType {
|
|
|
199
263
|
/**
|
|
200
264
|
* For returning integration metadata/config
|
|
201
265
|
*/
|
|
202
|
-
SPEC = "spec"
|
|
266
|
+
SPEC = "spec",
|
|
267
|
+
/**
|
|
268
|
+
* For to start mcp
|
|
269
|
+
*/
|
|
270
|
+
MCP = "mcp"
|
|
271
|
+
}
|
|
272
|
+
interface IntegrationDefinition {
|
|
273
|
+
name: string;
|
|
274
|
+
version: string;
|
|
275
|
+
description: string;
|
|
203
276
|
}
|
|
204
277
|
interface IntegrationEventPayload {
|
|
205
278
|
event: IntegrationEventType;
|
|
279
|
+
integrationDefinition?: IntegrationDefinition;
|
|
280
|
+
eventBody: any;
|
|
281
|
+
config?: Config;
|
|
282
|
+
state?: Record<string, string>;
|
|
206
283
|
[x: string]: any;
|
|
207
284
|
}
|
|
208
285
|
declare class Spec {
|
|
@@ -220,7 +297,7 @@ declare class Spec {
|
|
|
220
297
|
}
|
|
221
298
|
interface Config {
|
|
222
299
|
access_token: string;
|
|
223
|
-
[key: string]:
|
|
300
|
+
[key: string]: string;
|
|
224
301
|
}
|
|
225
302
|
interface Identifier {
|
|
226
303
|
id: string;
|
|
@@ -238,6 +315,235 @@ declare enum UserTypeEnum {
|
|
|
238
315
|
System = "System"
|
|
239
316
|
}
|
|
240
317
|
|
|
318
|
+
interface SpaceNode {
|
|
319
|
+
uuid: string;
|
|
320
|
+
name: string;
|
|
321
|
+
description?: string;
|
|
322
|
+
userId: string;
|
|
323
|
+
createdAt: Date;
|
|
324
|
+
updatedAt: Date;
|
|
325
|
+
isActive: boolean;
|
|
326
|
+
contextCount?: number;
|
|
327
|
+
embedding?: number[];
|
|
328
|
+
}
|
|
329
|
+
interface CreateSpaceParams {
|
|
330
|
+
name: string;
|
|
331
|
+
description?: string;
|
|
332
|
+
userId: string;
|
|
333
|
+
workspaceId: string;
|
|
334
|
+
}
|
|
335
|
+
interface UpdateSpaceParams {
|
|
336
|
+
name?: string;
|
|
337
|
+
description?: string;
|
|
338
|
+
icon?: string;
|
|
339
|
+
status?: string;
|
|
340
|
+
}
|
|
341
|
+
interface SpaceWithStatements extends SpaceNode {
|
|
342
|
+
statements: any[];
|
|
343
|
+
}
|
|
344
|
+
interface AssignStatementsParams {
|
|
345
|
+
statementIds: string[];
|
|
346
|
+
spaceId: string;
|
|
347
|
+
userId: string;
|
|
348
|
+
}
|
|
349
|
+
interface SpaceAssignmentResult {
|
|
350
|
+
success: boolean;
|
|
351
|
+
statementsUpdated: number;
|
|
352
|
+
error?: string;
|
|
353
|
+
}
|
|
354
|
+
interface SpaceDeletionResult {
|
|
355
|
+
deleted: boolean;
|
|
356
|
+
statementsUpdated: number;
|
|
357
|
+
error?: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
type UserConfirmationStatus = "pending" | "accepted" | "rejected" | "edited";
|
|
361
|
+
interface SpacePattern {
|
|
362
|
+
id: string;
|
|
363
|
+
name: string;
|
|
364
|
+
source: "explicit" | "implicit";
|
|
365
|
+
type: string;
|
|
366
|
+
summary: string;
|
|
367
|
+
editedSummary?: string;
|
|
368
|
+
evidence: string[];
|
|
369
|
+
confidence: number;
|
|
370
|
+
userConfirmed: UserConfirmationStatus;
|
|
371
|
+
spaceId: string;
|
|
372
|
+
createdAt: Date;
|
|
373
|
+
updatedAt: Date;
|
|
374
|
+
}
|
|
375
|
+
interface CreatePatternParams {
|
|
376
|
+
name: string;
|
|
377
|
+
source: "explicit" | "implicit";
|
|
378
|
+
type: string;
|
|
379
|
+
summary: string;
|
|
380
|
+
editedSummary?: string;
|
|
381
|
+
evidence: string[];
|
|
382
|
+
confidence: number;
|
|
383
|
+
userConfirmed?: UserConfirmationStatus;
|
|
384
|
+
spaceId: string;
|
|
385
|
+
}
|
|
386
|
+
interface PatternDetectionResult {
|
|
387
|
+
explicitPatterns: Omit<SpacePattern, "id" | "createdAt" | "updatedAt" | "spaceId">[];
|
|
388
|
+
implicitPatterns: Omit<SpacePattern, "id" | "createdAt" | "updatedAt" | "spaceId">[];
|
|
389
|
+
totalPatternsFound: number;
|
|
390
|
+
processingStats: {
|
|
391
|
+
statementsAnalyzed: number;
|
|
392
|
+
themesProcessed: number;
|
|
393
|
+
implicitPatternsExtracted: number;
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
interface PatternConfirmationParams {
|
|
397
|
+
patternId: string;
|
|
398
|
+
confirmed: boolean;
|
|
399
|
+
}
|
|
400
|
+
declare const EXPLICIT_PATTERN_TYPES: {
|
|
401
|
+
readonly THEME: "theme";
|
|
402
|
+
readonly TOPIC: "topic";
|
|
403
|
+
readonly DOMAIN: "domain";
|
|
404
|
+
readonly INTEREST_AREA: "interest_area";
|
|
405
|
+
};
|
|
406
|
+
declare const IMPLICIT_PATTERN_TYPES: {
|
|
407
|
+
readonly PREFERENCE: "preference";
|
|
408
|
+
readonly HABIT: "habit";
|
|
409
|
+
readonly WORKFLOW: "workflow";
|
|
410
|
+
readonly COMMUNICATION_STYLE: "communication_style";
|
|
411
|
+
readonly DECISION_PATTERN: "decision_pattern";
|
|
412
|
+
readonly TEMPORAL_PATTERN: "temporal_pattern";
|
|
413
|
+
readonly BEHAVIORAL_PATTERN: "behavioral_pattern";
|
|
414
|
+
readonly LEARNING_STYLE: "learning_style";
|
|
415
|
+
readonly COLLABORATION_STYLE: "collaboration_style";
|
|
416
|
+
};
|
|
417
|
+
declare const PATTERN_TYPES: {
|
|
418
|
+
readonly PREFERENCE: "preference";
|
|
419
|
+
readonly HABIT: "habit";
|
|
420
|
+
readonly WORKFLOW: "workflow";
|
|
421
|
+
readonly COMMUNICATION_STYLE: "communication_style";
|
|
422
|
+
readonly DECISION_PATTERN: "decision_pattern";
|
|
423
|
+
readonly TEMPORAL_PATTERN: "temporal_pattern";
|
|
424
|
+
readonly BEHAVIORAL_PATTERN: "behavioral_pattern";
|
|
425
|
+
readonly LEARNING_STYLE: "learning_style";
|
|
426
|
+
readonly COLLABORATION_STYLE: "collaboration_style";
|
|
427
|
+
readonly THEME: "theme";
|
|
428
|
+
readonly TOPIC: "topic";
|
|
429
|
+
readonly DOMAIN: "domain";
|
|
430
|
+
readonly INTEREST_AREA: "interest_area";
|
|
431
|
+
};
|
|
432
|
+
type ExplicitPatternType = (typeof EXPLICIT_PATTERN_TYPES)[keyof typeof EXPLICIT_PATTERN_TYPES];
|
|
433
|
+
type ImplicitPatternType = (typeof IMPLICIT_PATTERN_TYPES)[keyof typeof IMPLICIT_PATTERN_TYPES];
|
|
434
|
+
type PatternType = (typeof PATTERN_TYPES)[keyof typeof PATTERN_TYPES];
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Search options interface
|
|
438
|
+
*/
|
|
439
|
+
interface SearchOptions {
|
|
440
|
+
limit?: number;
|
|
441
|
+
maxBfsDepth?: number;
|
|
442
|
+
validAt?: Date;
|
|
443
|
+
startTime?: Date | null;
|
|
444
|
+
endTime?: Date;
|
|
445
|
+
includeInvalidated?: boolean;
|
|
446
|
+
entityTypes?: string[];
|
|
447
|
+
predicateTypes?: string[];
|
|
448
|
+
scoreThreshold?: number;
|
|
449
|
+
minResults?: number;
|
|
450
|
+
labelIds?: string[];
|
|
451
|
+
adaptiveFiltering?: boolean;
|
|
452
|
+
structured?: boolean;
|
|
453
|
+
useLLMValidation?: boolean;
|
|
454
|
+
qualityThreshold?: number;
|
|
455
|
+
maxEpisodesForLLM?: number;
|
|
456
|
+
sortBy?: "relevance" | "recency";
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Statement with source provenance tracking
|
|
460
|
+
*/
|
|
461
|
+
interface StatementWithSource {
|
|
462
|
+
statement: StatementNode;
|
|
463
|
+
sources: {
|
|
464
|
+
episodeGraph?: {
|
|
465
|
+
score: number;
|
|
466
|
+
entityMatches: number;
|
|
467
|
+
};
|
|
468
|
+
bfs?: {
|
|
469
|
+
score: number;
|
|
470
|
+
hopDistance: number;
|
|
471
|
+
relevance: number;
|
|
472
|
+
};
|
|
473
|
+
vector?: {
|
|
474
|
+
score: number;
|
|
475
|
+
similarity: number;
|
|
476
|
+
};
|
|
477
|
+
bm25?: {
|
|
478
|
+
score: number;
|
|
479
|
+
rank: number;
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
primarySource: "episodeGraph" | "bfs" | "vector" | "bm25";
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Episode with provenance tracking from multiple sources
|
|
486
|
+
*/
|
|
487
|
+
interface EpisodeWithProvenance {
|
|
488
|
+
episode: EpisodicNode;
|
|
489
|
+
statements: StatementWithSource[];
|
|
490
|
+
episodeGraphScore: number;
|
|
491
|
+
bfsScore: number;
|
|
492
|
+
vectorScore: number;
|
|
493
|
+
bm25Score: number;
|
|
494
|
+
sourceBreakdown: {
|
|
495
|
+
fromEpisodeGraph: number;
|
|
496
|
+
fromBFS: number;
|
|
497
|
+
fromVector: number;
|
|
498
|
+
fromBM25: number;
|
|
499
|
+
};
|
|
500
|
+
entityMatchCount?: number;
|
|
501
|
+
firstLevelScore?: number;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Quality filtering result
|
|
505
|
+
*/
|
|
506
|
+
interface QualityFilterResult {
|
|
507
|
+
episodes: EpisodeWithProvenance[];
|
|
508
|
+
confidence: number;
|
|
509
|
+
message: string;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Quality thresholds for filtering
|
|
513
|
+
*/
|
|
514
|
+
declare const QUALITY_THRESHOLDS: {
|
|
515
|
+
HIGH_QUALITY_EPISODE: number;
|
|
516
|
+
MEDIUM_QUALITY_EPISODE: number;
|
|
517
|
+
LOW_QUALITY_EPISODE: number;
|
|
518
|
+
CONFIDENT_RESULT: number;
|
|
519
|
+
UNCERTAIN_RESULT: number;
|
|
520
|
+
NO_RESULT: number;
|
|
521
|
+
MINIMUM_GAP_RATIO: number;
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* Episode search result with aggregated scores and sample statements
|
|
525
|
+
* Returned by BM25, Vector, and BFS searches
|
|
526
|
+
*/
|
|
527
|
+
interface EpisodeSearchResult {
|
|
528
|
+
episode: EpisodicNode;
|
|
529
|
+
score: number;
|
|
530
|
+
statementCount: number;
|
|
531
|
+
topStatements: StatementNode[];
|
|
532
|
+
invalidatedStatements: StatementNode[];
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Configuration for reranking
|
|
536
|
+
*/
|
|
537
|
+
interface RerankConfig {
|
|
538
|
+
provider: "cohere" | "ollama" | "none";
|
|
539
|
+
limit?: number;
|
|
540
|
+
threshold: number;
|
|
541
|
+
cohereApiKey?: string;
|
|
542
|
+
cohereModel?: string;
|
|
543
|
+
ollamaUrl?: string;
|
|
544
|
+
ollamaModel?: string;
|
|
545
|
+
}
|
|
546
|
+
|
|
241
547
|
declare abstract class IntegrationCLI {
|
|
242
548
|
protected program: Command;
|
|
243
549
|
protected integrationName: string;
|
|
@@ -248,10 +554,11 @@ declare abstract class IntegrationCLI {
|
|
|
248
554
|
private setupDataCommands;
|
|
249
555
|
private setupSpecCommand;
|
|
250
556
|
private setupSyncCommand;
|
|
557
|
+
private setupMCPCommand;
|
|
251
558
|
protected abstract handleEvent(eventPayload: IntegrationEventPayload): Promise<Message[]>;
|
|
252
559
|
protected abstract getSpec(): Promise<Spec>;
|
|
253
560
|
parse(): void;
|
|
254
561
|
getProgram(): Command;
|
|
255
562
|
}
|
|
256
563
|
|
|
257
|
-
export { APIKeyParams, ActionStatus, ActionStatusEnum, type AddEpisodeParams, type AddEpisodeResult, type AuthType, ClaudeModels, type Config, type EntityNode, EpisodeType, type EpisodicNode, type ExtractedTripleData, GeminiModels, type Identifier, IntegrationCLI, type IntegrationEventPayload, IntegrationEventType, LLMMappings, LLMModelEnum, LLMModelType, type Message, type MessageType, OAuth2Params, OpenAIModels, Spec, type StatementNode, type Triple, UserTypeEnum };
|
|
564
|
+
export { APIKeyParams, ActionStatus, ActionStatusEnum, type AddEpisodeParams, type AddEpisodeResult, type AssignStatementsParams, type AuthType, COMPACTED_SESSION_NODE_PROPERTIES, ClaudeModels, type CompactedSessionNode, type Config, type CreatePatternParams, type CreateSpaceParams, type DocumentNode, ENTITY_NODE_PROPERTIES, EPISODIC_NODE_PROPERTIES, EXPLICIT_PATTERN_TYPES, type EntityNode, type EpisodeSearchResult, EpisodeType, EpisodeTypeEnum, type EpisodeWithProvenance, type EpisodicNode, type EpisodicNodeWithoutEmbeddings, type ExplicitPatternType, type ExtractedTripleData, GeminiModels, IMPLICIT_PATTERN_TYPES, type Identifier, type ImplicitPatternType, IntegrationCLI, type IntegrationEventPayload, IntegrationEventType, LLMMappings, LLMModelEnum, LLMModelType, type Message, type MessageType, OAuth2Params, OpenAIModels, PATTERN_TYPES, type PatternConfirmationParams, type PatternDetectionResult, type PatternType, QUALITY_THRESHOLDS, type QualityFilterResult, type RerankConfig, STATEMENT_NODE_PROPERTIES, type SearchOptions, type SpaceAssignmentResult, type SpaceDeletionResult, type SpaceNode, type SpacePattern, type SpaceWithStatements, Spec, type StatementNode, type StatementWithSource, type Triple, type UpdateSpaceParams, type UserConfirmationStatus, UserTypeEnum };
|