@usecortex_ai/openclaw-cortex-ai 0.0.1
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/README.md +90 -0
- package/client.ts +206 -0
- package/commands/cli.ts +93 -0
- package/commands/slash.ts +138 -0
- package/config.ts +95 -0
- package/context.ts +191 -0
- package/hooks/capture.ts +85 -0
- package/hooks/recall.ts +40 -0
- package/index.ts +57 -0
- package/log.ts +25 -0
- package/openclaw.plugin.json +68 -0
- package/package.json +24 -0
- package/session.ts +3 -0
- package/tools/search.ts +64 -0
- package/tools/store.ts +62 -0
- package/tsconfig.json +23 -0
- package/types/cortex.ts +164 -0
- package/types/openclaw.d.ts +19 -0
package/types/cortex.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export type ConversationTurn = {
|
|
2
|
+
user: string
|
|
3
|
+
assistant: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type MemoryPayload = {
|
|
7
|
+
text?: string
|
|
8
|
+
user_assistant_pairs?: ConversationTurn[]
|
|
9
|
+
is_markdown?: boolean
|
|
10
|
+
infer?: boolean
|
|
11
|
+
custom_instructions?: string
|
|
12
|
+
user_name?: string
|
|
13
|
+
source_id?: string
|
|
14
|
+
title?: string
|
|
15
|
+
expiry_time?: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type AddMemoryRequest = {
|
|
19
|
+
memories: MemoryPayload[]
|
|
20
|
+
tenant_id: string
|
|
21
|
+
sub_tenant_id?: string
|
|
22
|
+
upsert?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type MemoryResultItem = {
|
|
26
|
+
source_id: string
|
|
27
|
+
title?: string | null
|
|
28
|
+
status: string
|
|
29
|
+
infer: boolean
|
|
30
|
+
error?: string | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type AddMemoryResponse = {
|
|
34
|
+
success: boolean
|
|
35
|
+
message: string
|
|
36
|
+
results: MemoryResultItem[]
|
|
37
|
+
success_count: number
|
|
38
|
+
failed_count: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type RecallRequest = {
|
|
42
|
+
tenant_id: string
|
|
43
|
+
sub_tenant_id?: string
|
|
44
|
+
query: string
|
|
45
|
+
max_results?: number
|
|
46
|
+
mode?: "fast" | "thinking"
|
|
47
|
+
alpha?: number | string
|
|
48
|
+
recency_bias?: number
|
|
49
|
+
graph_context?: boolean
|
|
50
|
+
additional_context?: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type VectorChunk = {
|
|
54
|
+
chunk_uuid: string
|
|
55
|
+
source_id: string
|
|
56
|
+
chunk_content: string
|
|
57
|
+
source_type?: string
|
|
58
|
+
source_upload_time?: string
|
|
59
|
+
source_title?: string
|
|
60
|
+
source_last_updated_time?: string
|
|
61
|
+
relevancy_score?: number | null
|
|
62
|
+
document_metadata?: Record<string, unknown> | null
|
|
63
|
+
tenant_metadata?: Record<string, unknown> | null
|
|
64
|
+
extra_context_ids?: string[] | null
|
|
65
|
+
layout?: string | null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type PathTriplet = {
|
|
69
|
+
source: { name: string; type: string; entity_id: string }
|
|
70
|
+
relation: {
|
|
71
|
+
canonical_predicate: string
|
|
72
|
+
raw_predicate: string
|
|
73
|
+
context: string
|
|
74
|
+
confidence?: number
|
|
75
|
+
chunk_id?: string | null
|
|
76
|
+
relationship_id: string
|
|
77
|
+
}
|
|
78
|
+
target: { name: string; type: string; entity_id: string }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type ScoredPath = {
|
|
82
|
+
triplets: PathTriplet[]
|
|
83
|
+
relevancy_score: number
|
|
84
|
+
combined_context?: string | null
|
|
85
|
+
group_id?: string | null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type GraphContext = {
|
|
89
|
+
query_paths: ScoredPath[]
|
|
90
|
+
chunk_relations: ScoredPath[]
|
|
91
|
+
chunk_id_to_group_ids: Record<string, string[]>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type RecallResponse = {
|
|
95
|
+
chunks: VectorChunk[]
|
|
96
|
+
graph_context?: GraphContext
|
|
97
|
+
additional_context?: Record<string, VectorChunk>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// --- List API ---
|
|
101
|
+
|
|
102
|
+
export type ListDataRequest = {
|
|
103
|
+
tenant_id: string
|
|
104
|
+
sub_tenant_id?: string
|
|
105
|
+
kind?: "knowledge" | "memories"
|
|
106
|
+
source_ids?: string[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type UserMemory = {
|
|
110
|
+
memory_id: string
|
|
111
|
+
memory_content: string
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type ListMemoriesResponse = {
|
|
115
|
+
success: boolean
|
|
116
|
+
user_memories: UserMemory[]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type SourceItem = {
|
|
120
|
+
id: string
|
|
121
|
+
tenant_id: string
|
|
122
|
+
sub_tenant_id: string
|
|
123
|
+
title?: string
|
|
124
|
+
type?: string
|
|
125
|
+
description?: string
|
|
126
|
+
timestamp?: string
|
|
127
|
+
url?: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type ListSourcesResponse = {
|
|
131
|
+
success: boolean
|
|
132
|
+
message?: string
|
|
133
|
+
sources: SourceItem[]
|
|
134
|
+
total: number
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --- Delete API ---
|
|
138
|
+
|
|
139
|
+
export type DeleteMemoryResponse = {
|
|
140
|
+
success: boolean
|
|
141
|
+
user_memory_deleted: boolean
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// --- Fetch Content API ---
|
|
145
|
+
|
|
146
|
+
export type FetchContentRequest = {
|
|
147
|
+
tenant_id: string
|
|
148
|
+
sub_tenant_id?: string
|
|
149
|
+
source_id: string
|
|
150
|
+
mode?: "content" | "url" | "both"
|
|
151
|
+
expiry_seconds?: number
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type FetchContentResponse = {
|
|
155
|
+
success: boolean
|
|
156
|
+
source_id: string
|
|
157
|
+
content?: string | null
|
|
158
|
+
content_base64?: string | null
|
|
159
|
+
presigned_url?: string | null
|
|
160
|
+
content_type?: string | null
|
|
161
|
+
size_bytes?: number | null
|
|
162
|
+
message?: string
|
|
163
|
+
error?: string | null
|
|
164
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare module "openclaw/plugin-sdk" {
|
|
2
|
+
export interface OpenClawPluginApi {
|
|
3
|
+
pluginConfig: unknown
|
|
4
|
+
logger: {
|
|
5
|
+
info: (msg: string) => void
|
|
6
|
+
warn: (msg: string) => void
|
|
7
|
+
error: (msg: string, ...args: unknown[]) => void
|
|
8
|
+
debug: (msg: string) => void
|
|
9
|
+
}
|
|
10
|
+
config: unknown
|
|
11
|
+
registerTool(tool: any, options: any): void
|
|
12
|
+
registerCommand(command: any): void
|
|
13
|
+
registerCli(handler: any, options?: any): void
|
|
14
|
+
registerService(service: any): void
|
|
15
|
+
on(event: string, handler: (...args: any[]) => any): void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function stringEnum(values: readonly string[]): any
|
|
19
|
+
}
|