@claudetools/tools 0.3.6 → 0.3.8
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/helpers/api-client.d.ts +6 -6
- package/dist/helpers/api-client.js +14 -15
- package/dist/helpers/config.js +12 -4
- package/package.json +1 -1
|
@@ -21,18 +21,18 @@ export declare function apiRequest<T>(endpoint: string, method?: 'GET' | 'POST',
|
|
|
21
21
|
export declare function addMemory(projectId: string, sessionId: string, messages: {
|
|
22
22
|
role: string;
|
|
23
23
|
content: string;
|
|
24
|
-
}[], extractFacts?: boolean): Promise<{
|
|
24
|
+
}[], extractFacts?: boolean, userId?: string): Promise<{
|
|
25
25
|
success: boolean;
|
|
26
26
|
episode_ids: string[];
|
|
27
27
|
}>;
|
|
28
|
-
export declare function searchMemory(projectId: string, query: string, limit?: number): Promise<MemoryContext>;
|
|
29
|
-
export declare function storeFact(projectId: string, entity1: string, relationship: string, entity2: string, context: string): Promise<{
|
|
28
|
+
export declare function searchMemory(projectId: string, query: string, limit?: number, userId?: string): Promise<MemoryContext>;
|
|
29
|
+
export declare function storeFact(projectId: string, entity1: string, relationship: string, entity2: string, context: string, userId?: string): Promise<{
|
|
30
30
|
success: boolean;
|
|
31
31
|
fact_id: string;
|
|
32
32
|
}>;
|
|
33
|
-
export declare function getContext(projectId: string, query?: string): Promise<MemoryContext>;
|
|
34
|
-
export declare function getSummary(projectId: string): Promise<string>;
|
|
35
|
-
export declare function getEntities(projectId: string): Promise<{
|
|
33
|
+
export declare function getContext(projectId: string, query?: string, userId?: string): Promise<MemoryContext>;
|
|
34
|
+
export declare function getSummary(projectId: string, userId?: string): Promise<string>;
|
|
35
|
+
export declare function getEntities(projectId: string, userId?: string): Promise<{
|
|
36
36
|
name: string;
|
|
37
37
|
labels: string[];
|
|
38
38
|
entity_id: string;
|
|
@@ -19,42 +19,41 @@ export async function apiRequest(endpoint, method = 'GET', body) {
|
|
|
19
19
|
}
|
|
20
20
|
return response.json();
|
|
21
21
|
}
|
|
22
|
-
export async function addMemory(projectId, sessionId, messages, extractFacts = true) {
|
|
23
|
-
return apiRequest(`/api/v1/memory/${projectId}/add`, 'POST', {
|
|
22
|
+
export async function addMemory(projectId, sessionId, messages, extractFacts = true, userId = DEFAULT_USER_ID) {
|
|
23
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/add`, 'POST', {
|
|
24
24
|
session_id: sessionId,
|
|
25
25
|
messages,
|
|
26
26
|
extract_facts: extractFacts,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
export async function searchMemory(projectId, query, limit = 10) {
|
|
30
|
-
return apiRequest(`/api/v1/memory/${projectId}/search`, 'POST', {
|
|
29
|
+
export async function searchMemory(projectId, query, limit = 10, userId = DEFAULT_USER_ID) {
|
|
30
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/search`, 'POST', {
|
|
31
31
|
query,
|
|
32
32
|
limit,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
export async function storeFact(projectId, entity1, relationship, entity2, context) {
|
|
36
|
-
return apiRequest(`/api/v1/memory/${projectId}/fact`, 'POST', {
|
|
35
|
+
export async function storeFact(projectId, entity1, relationship, entity2, context, userId = DEFAULT_USER_ID) {
|
|
36
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/fact`, 'POST', {
|
|
37
37
|
entity1,
|
|
38
38
|
relationship,
|
|
39
39
|
entity2,
|
|
40
40
|
context,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
export async function getContext(projectId, query) {
|
|
43
|
+
export async function getContext(projectId, query, userId = DEFAULT_USER_ID) {
|
|
44
44
|
const params = query ? `?query=${encodeURIComponent(query)}` : '';
|
|
45
|
-
return apiRequest(`/api/v1/memory/${projectId}/context${params}`);
|
|
45
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/context${params}`);
|
|
46
46
|
}
|
|
47
|
-
export async function getSummary(projectId) {
|
|
48
|
-
const response = await fetch(`${API_BASE_URL}/api/v1/memory/${projectId}/summary`);
|
|
47
|
+
export async function getSummary(projectId, userId = DEFAULT_USER_ID) {
|
|
48
|
+
const response = await fetch(`${API_BASE_URL}/api/v1/memory/${userId}/${projectId}/summary`);
|
|
49
49
|
return response.text();
|
|
50
50
|
}
|
|
51
|
-
export async function getEntities(projectId) {
|
|
52
|
-
return apiRequest(`/api/v1/memory/${projectId}/entities`);
|
|
51
|
+
export async function getEntities(projectId, userId = DEFAULT_USER_ID) {
|
|
52
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/entities`);
|
|
53
53
|
}
|
|
54
|
-
export async function injectContext(projectId, query, userId) {
|
|
55
|
-
const response = await apiRequest(`/api/v1/memory/${projectId}/inject`, 'POST', {
|
|
54
|
+
export async function injectContext(projectId, query, userId = DEFAULT_USER_ID) {
|
|
55
|
+
const response = await apiRequest(`/api/v1/memory/${userId}/${projectId}/inject`, 'POST', {
|
|
56
56
|
query,
|
|
57
|
-
userId: userId || DEFAULT_USER_ID,
|
|
58
57
|
});
|
|
59
58
|
return response.data;
|
|
60
59
|
}
|
package/dist/helpers/config.js
CHANGED
|
@@ -143,8 +143,12 @@ export function getDefaultProjectId() {
|
|
|
143
143
|
// Try config first
|
|
144
144
|
if (config.defaultProjectId) {
|
|
145
145
|
if (!isValidProjectId(config.defaultProjectId)) {
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
// Legacy format - convert to local_ format instead of throwing
|
|
147
|
+
const sanitized = config.defaultProjectId.toLowerCase().replace(/[^a-z0-9]/g, '_');
|
|
148
|
+
_defaultProjectId = `local_${sanitized}`;
|
|
149
|
+
console.error(`[claudetools] Warning: Legacy project ID "${config.defaultProjectId}" ` +
|
|
150
|
+
`converted to "${_defaultProjectId}". Run "claudetools cleanup" to fix config.`);
|
|
151
|
+
return _defaultProjectId;
|
|
148
152
|
}
|
|
149
153
|
_defaultProjectId = config.defaultProjectId;
|
|
150
154
|
return _defaultProjectId;
|
|
@@ -163,8 +167,12 @@ export async function getDefaultProjectIdAsync() {
|
|
|
163
167
|
// Try config first
|
|
164
168
|
if (config.defaultProjectId) {
|
|
165
169
|
if (!isValidProjectId(config.defaultProjectId)) {
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
// Legacy format - convert to local_ format instead of throwing
|
|
171
|
+
const sanitized = config.defaultProjectId.toLowerCase().replace(/[^a-z0-9]/g, '_');
|
|
172
|
+
_defaultProjectId = `local_${sanitized}`;
|
|
173
|
+
console.error(`[claudetools] Warning: Legacy project ID "${config.defaultProjectId}" ` +
|
|
174
|
+
`converted to "${_defaultProjectId}". Run "claudetools cleanup" to fix config.`);
|
|
175
|
+
return _defaultProjectId;
|
|
168
176
|
}
|
|
169
177
|
_defaultProjectId = config.defaultProjectId;
|
|
170
178
|
return _defaultProjectId;
|