@kalera/munin-gemini 1.2.5 → 1.2.7
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/.turbo/turbo-build.log +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +44 -38
- package/package.json +3 -3
- package/src/index.ts +76 -65
package/.turbo/turbo-build.log
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function createGeminiCliMuninAdapter(config: {
|
|
|
7
7
|
capabilities: () => Promise<import("@kalera/munin-sdk").MuninCapabilities>;
|
|
8
8
|
beforeAgent: (systemPrompt: string) => Promise<string>;
|
|
9
9
|
};
|
|
10
|
-
export declare
|
|
10
|
+
export declare function beforeAgent(systemPrompt: string): Promise<string>;
|
|
11
11
|
export declare const tools: ({
|
|
12
12
|
name: string;
|
|
13
13
|
description: string;
|
|
@@ -43,7 +43,7 @@ export declare const tools: ({
|
|
|
43
43
|
};
|
|
44
44
|
required: string[];
|
|
45
45
|
};
|
|
46
|
-
execute: (args:
|
|
46
|
+
execute: (args: Record<string, unknown>) => Promise<import("@kalera/munin-sdk").MuninResponse<unknown>>;
|
|
47
47
|
} | {
|
|
48
48
|
name: string;
|
|
49
49
|
description: string;
|
|
@@ -67,7 +67,7 @@ export declare const tools: ({
|
|
|
67
67
|
};
|
|
68
68
|
required: string[];
|
|
69
69
|
};
|
|
70
|
-
execute: (args:
|
|
70
|
+
execute: (args: Record<string, unknown>) => Promise<import("@kalera/munin-sdk").MuninResponse<unknown>>;
|
|
71
71
|
} | {
|
|
72
72
|
name: string;
|
|
73
73
|
description: string;
|
|
@@ -100,7 +100,7 @@ export declare const tools: ({
|
|
|
100
100
|
};
|
|
101
101
|
required: string[];
|
|
102
102
|
};
|
|
103
|
-
execute: (args:
|
|
103
|
+
execute: (args: Record<string, unknown>) => Promise<import("@kalera/munin-sdk").MuninResponse<unknown>>;
|
|
104
104
|
} | {
|
|
105
105
|
name: string;
|
|
106
106
|
description: string;
|
|
@@ -126,7 +126,7 @@ export declare const tools: ({
|
|
|
126
126
|
};
|
|
127
127
|
required: string[];
|
|
128
128
|
};
|
|
129
|
-
execute: (args:
|
|
129
|
+
execute: (args: Record<string, unknown>) => Promise<import("@kalera/munin-sdk").MuninResponse<unknown>>;
|
|
130
130
|
} | {
|
|
131
131
|
name: string;
|
|
132
132
|
description: string;
|
|
@@ -150,5 +150,5 @@ export declare const tools: ({
|
|
|
150
150
|
};
|
|
151
151
|
required: string[];
|
|
152
152
|
};
|
|
153
|
-
execute: (args:
|
|
153
|
+
execute: (args: Record<string, unknown>) => Promise<import("@kalera/munin-sdk").MuninResponse<unknown>>;
|
|
154
154
|
})[];
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,75 @@
|
|
|
1
1
|
import { MuninClient } from "@kalera/munin-sdk";
|
|
2
2
|
export function createGeminiCliMuninAdapter(config) {
|
|
3
|
-
const client = new MuninClient(config);
|
|
4
3
|
const baseUrl = (config.baseUrl || "https://munin.kalera.dev").replace(/\/$/, "");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const client = new MuninClient(config);
|
|
5
|
+
async function fetchPinnedMemories(systemPrompt) {
|
|
6
|
+
if (!config.apiKey)
|
|
7
|
+
return systemPrompt;
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetch(`${baseUrl}/api/memories/pinned`, {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
console.warn(`[Munin] Failed to fetch pinned memories: ${response.statusText}`);
|
|
11
17
|
return systemPrompt;
|
|
12
|
-
try {
|
|
13
|
-
const response = await fetch(`${baseUrl}/api/memories/pinned`, {
|
|
14
|
-
headers: {
|
|
15
|
-
"Authorization": `Bearer ${apiKey}`,
|
|
16
|
-
"Content-Type": "application/json"
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
console.warn(`[Munin] Failed to fetch pinned memories: ${response.statusText}`);
|
|
21
|
-
return systemPrompt;
|
|
22
|
-
}
|
|
23
|
-
const memories = await response.json();
|
|
24
|
-
if (!Array.isArray(memories) || memories.length === 0) {
|
|
25
|
-
return systemPrompt;
|
|
26
|
-
}
|
|
27
|
-
const pinnedContext = memories.slice(0, 5).map((m) => `[${m.key}] ${m.title ? m.title + ': ' : ''}${m.content}`).join('\n\n');
|
|
28
|
-
return `${systemPrompt}\n\n### 📌 PINNED CONTEXT (MANDATORY):\n${pinnedContext}`;
|
|
29
18
|
}
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
const memories = (await response.json());
|
|
20
|
+
if (!Array.isArray(memories) || memories.length === 0) {
|
|
32
21
|
return systemPrompt;
|
|
33
22
|
}
|
|
23
|
+
const pinnedContext = memories
|
|
24
|
+
.slice(0, 5)
|
|
25
|
+
.map((m) => `[${m.key}] ${m.title ? m.title + ": " : ""}${m.content}`)
|
|
26
|
+
.join("\n\n");
|
|
27
|
+
return `${systemPrompt}\n\n### 📌 PINNED CONTEXT (MANDATORY):\n${pinnedContext}`;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.warn(`[Munin] Error fetching pinned memories:`, error);
|
|
31
|
+
return systemPrompt;
|
|
34
32
|
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
callTool: async (projectId, name, args) => client.invoke(projectId, name, args, { ensureCapability: true }),
|
|
36
|
+
capabilities: () => client.capabilities(),
|
|
37
|
+
beforeAgent: fetchPinnedMemories,
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
|
-
//
|
|
40
|
+
// Standalone extension exports — uses process.env directly
|
|
38
41
|
const baseUrl = process.env.MUNIN_BASE_URL || "https://munin.kalera.dev";
|
|
39
42
|
const apiKey = process.env.MUNIN_API_KEY;
|
|
40
43
|
const extensionClient = new MuninClient({ baseUrl, apiKey });
|
|
41
|
-
export
|
|
44
|
+
export async function beforeAgent(systemPrompt) {
|
|
42
45
|
if (!apiKey)
|
|
43
46
|
return systemPrompt;
|
|
44
47
|
try {
|
|
45
48
|
const response = await fetch(`${baseUrl.replace(/\/$/, "")}/api/memories/pinned`, {
|
|
46
49
|
headers: {
|
|
47
|
-
|
|
48
|
-
"Content-Type": "application/json"
|
|
49
|
-
}
|
|
50
|
+
Authorization: `Bearer ${apiKey}`,
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
},
|
|
50
53
|
});
|
|
51
54
|
if (!response.ok) {
|
|
52
55
|
console.warn(`[Munin] Failed to fetch pinned memories: ${response.statusText}`);
|
|
53
56
|
return systemPrompt;
|
|
54
57
|
}
|
|
55
|
-
const memories = await response.json();
|
|
58
|
+
const memories = (await response.json());
|
|
56
59
|
if (!Array.isArray(memories) || memories.length === 0) {
|
|
57
60
|
return systemPrompt;
|
|
58
61
|
}
|
|
59
|
-
const pinnedContext = memories
|
|
62
|
+
const pinnedContext = memories
|
|
63
|
+
.slice(0, 5)
|
|
64
|
+
.map((m) => `[${m.key}] ${m.title ? m.title + ": " : ""}${m.content}`)
|
|
65
|
+
.join("\n\n");
|
|
60
66
|
return `${systemPrompt}\n\n### 📌 PINNED CONTEXT (MANDATORY):\n${pinnedContext}`;
|
|
61
67
|
}
|
|
62
68
|
catch (error) {
|
|
63
69
|
console.warn(`[Munin] Error fetching pinned memories:`, error);
|
|
64
70
|
return systemPrompt;
|
|
65
71
|
}
|
|
66
|
-
}
|
|
72
|
+
}
|
|
67
73
|
export const tools = [
|
|
68
74
|
{
|
|
69
75
|
name: "munin_store_memory",
|
|
@@ -78,8 +84,8 @@ export const tools = [
|
|
|
78
84
|
tags: {
|
|
79
85
|
type: "array",
|
|
80
86
|
items: { type: "string" },
|
|
81
|
-
description: "List of tags, e.g. ['planning', 'frontend']"
|
|
82
|
-
}
|
|
87
|
+
description: "List of tags, e.g. ['planning', 'frontend']",
|
|
88
|
+
},
|
|
83
89
|
},
|
|
84
90
|
required: ["projectId", "key", "content"],
|
|
85
91
|
},
|
|
@@ -138,7 +144,7 @@ export const tools = [
|
|
|
138
144
|
limit: { type: "number" },
|
|
139
145
|
offset: { type: "number" },
|
|
140
146
|
},
|
|
141
|
-
required: ["projectId"]
|
|
147
|
+
required: ["projectId"],
|
|
142
148
|
},
|
|
143
149
|
execute: async (args) => {
|
|
144
150
|
const { projectId, ...payload } = args;
|
|
@@ -156,7 +162,7 @@ export const tools = [
|
|
|
156
162
|
projectId: { type: "string", description: "The Munin Project ID" },
|
|
157
163
|
limit: { type: "number" },
|
|
158
164
|
},
|
|
159
|
-
required: ["projectId"]
|
|
165
|
+
required: ["projectId"],
|
|
160
166
|
},
|
|
161
167
|
execute: async (args) => {
|
|
162
168
|
const { projectId, ...payload } = args;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kalera/munin-gemini",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"munin-gemini": "dist/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@kalera/munin-sdk": "1.2.
|
|
10
|
-
"@kalera/munin-runtime": "1.2.
|
|
9
|
+
"@kalera/munin-sdk": "1.2.6",
|
|
10
|
+
"@kalera/munin-runtime": "1.2.6"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"typescript": "^5.9.2"
|
package/src/index.ts
CHANGED
|
@@ -1,87 +1,98 @@
|
|
|
1
1
|
import { MuninClient } from "@kalera/munin-sdk";
|
|
2
|
+
import type { MuninAction } from "@kalera/munin-sdk";
|
|
2
3
|
|
|
3
4
|
export function createGeminiCliMuninAdapter(config: {
|
|
4
5
|
baseUrl?: string;
|
|
5
6
|
apiKey?: string;
|
|
6
7
|
timeoutMs?: number;
|
|
7
8
|
}) {
|
|
8
|
-
const client = new MuninClient(config);
|
|
9
9
|
const baseUrl = (config.baseUrl || "https://munin.kalera.dev").replace(/\/$/, "");
|
|
10
|
-
const
|
|
10
|
+
const client = new MuninClient(config);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
console.warn(`[Munin] Failed to fetch pinned memories: ${response.statusText}`);
|
|
28
|
-
return systemPrompt;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const memories = await response.json();
|
|
32
|
-
if (!Array.isArray(memories) || memories.length === 0) {
|
|
33
|
-
return systemPrompt;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const pinnedContext = memories.slice(0, 5).map((m: any) =>
|
|
37
|
-
`[${m.key}] ${m.title ? m.title + ': ' : ''}${m.content}`
|
|
38
|
-
).join('\n\n');
|
|
39
|
-
|
|
40
|
-
return `${systemPrompt}\n\n### 📌 PINNED CONTEXT (MANDATORY):\n${pinnedContext}`;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.warn(`[Munin] Error fetching pinned memories:`, error);
|
|
12
|
+
async function fetchPinnedMemories(systemPrompt: string): Promise<string> {
|
|
13
|
+
if (!config.apiKey) return systemPrompt;
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${baseUrl}/api/memories/pinned`, {
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
console.warn(`[Munin] Failed to fetch pinned memories: ${response.statusText}`);
|
|
43
24
|
return systemPrompt;
|
|
44
25
|
}
|
|
26
|
+
|
|
27
|
+
const memories = (await response.json()) as Array<{
|
|
28
|
+
key: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
content: string;
|
|
31
|
+
}>;
|
|
32
|
+
if (!Array.isArray(memories) || memories.length === 0) {
|
|
33
|
+
return systemPrompt;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const pinnedContext = memories
|
|
37
|
+
.slice(0, 5)
|
|
38
|
+
.map((m) => `[${m.key}] ${m.title ? m.title + ": " : ""}${m.content}`)
|
|
39
|
+
.join("\n\n");
|
|
40
|
+
|
|
41
|
+
return `${systemPrompt}\n\n### 📌 PINNED CONTEXT (MANDATORY):\n${pinnedContext}`;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.warn(`[Munin] Error fetching pinned memories:`, error);
|
|
44
|
+
return systemPrompt;
|
|
45
45
|
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
callTool: async (projectId: string, name: string, args: Record<string, unknown>) =>
|
|
50
|
+
client.invoke(projectId, name as MuninAction, args, { ensureCapability: true }),
|
|
51
|
+
capabilities: () => client.capabilities(),
|
|
52
|
+
beforeAgent: fetchPinnedMemories,
|
|
46
53
|
};
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
//
|
|
56
|
+
// Standalone extension exports — uses process.env directly
|
|
50
57
|
const baseUrl = process.env.MUNIN_BASE_URL || "https://munin.kalera.dev";
|
|
51
58
|
const apiKey = process.env.MUNIN_API_KEY;
|
|
52
|
-
|
|
53
59
|
const extensionClient = new MuninClient({ baseUrl, apiKey });
|
|
54
60
|
|
|
55
|
-
export
|
|
61
|
+
export async function beforeAgent(systemPrompt: string): Promise<string> {
|
|
56
62
|
if (!apiKey) return systemPrompt;
|
|
57
63
|
try {
|
|
58
64
|
const response = await fetch(`${baseUrl.replace(/\/$/, "")}/api/memories/pinned`, {
|
|
59
65
|
headers: {
|
|
60
|
-
|
|
61
|
-
"Content-Type": "application/json"
|
|
62
|
-
}
|
|
66
|
+
Authorization: `Bearer ${apiKey}`,
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
},
|
|
63
69
|
});
|
|
64
|
-
|
|
70
|
+
|
|
65
71
|
if (!response.ok) {
|
|
66
72
|
console.warn(`[Munin] Failed to fetch pinned memories: ${response.statusText}`);
|
|
67
73
|
return systemPrompt;
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
const memories = await response.json()
|
|
75
|
+
|
|
76
|
+
const memories = (await response.json()) as Array<{
|
|
77
|
+
key: string;
|
|
78
|
+
title?: string;
|
|
79
|
+
content: string;
|
|
80
|
+
}>;
|
|
71
81
|
if (!Array.isArray(memories) || memories.length === 0) {
|
|
72
82
|
return systemPrompt;
|
|
73
83
|
}
|
|
74
|
-
|
|
75
|
-
const pinnedContext = memories
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
|
|
85
|
+
const pinnedContext = memories
|
|
86
|
+
.slice(0, 5)
|
|
87
|
+
.map((m) => `[${m.key}] ${m.title ? m.title + ": " : ""}${m.content}`)
|
|
88
|
+
.join("\n\n");
|
|
89
|
+
|
|
79
90
|
return `${systemPrompt}\n\n### 📌 PINNED CONTEXT (MANDATORY):\n${pinnedContext}`;
|
|
80
91
|
} catch (error) {
|
|
81
92
|
console.warn(`[Munin] Error fetching pinned memories:`, error);
|
|
82
93
|
return systemPrompt;
|
|
83
94
|
}
|
|
84
|
-
}
|
|
95
|
+
}
|
|
85
96
|
|
|
86
97
|
export const tools = [
|
|
87
98
|
{
|
|
@@ -94,18 +105,18 @@ export const tools = [
|
|
|
94
105
|
key: { type: "string", description: "Unique identifier for this memory" },
|
|
95
106
|
content: { type: "string", description: "The content to remember" },
|
|
96
107
|
title: { type: "string", description: "Optional title" },
|
|
97
|
-
tags: {
|
|
98
|
-
type: "array",
|
|
99
|
-
items: { type: "string" },
|
|
100
|
-
description: "List of tags, e.g. ['planning', 'frontend']"
|
|
101
|
-
}
|
|
108
|
+
tags: {
|
|
109
|
+
type: "array",
|
|
110
|
+
items: { type: "string" },
|
|
111
|
+
description: "List of tags, e.g. ['planning', 'frontend']",
|
|
112
|
+
},
|
|
102
113
|
},
|
|
103
114
|
required: ["projectId", "key", "content"],
|
|
104
115
|
},
|
|
105
|
-
execute: async (args:
|
|
116
|
+
execute: async (args: Record<string, unknown>) => {
|
|
106
117
|
const { projectId, ...payload } = args;
|
|
107
118
|
if (!projectId) throw new Error("projectId is required");
|
|
108
|
-
return await extensionClient.store(projectId, payload);
|
|
119
|
+
return await extensionClient.store(projectId as string, payload);
|
|
109
120
|
},
|
|
110
121
|
},
|
|
111
122
|
{
|
|
@@ -119,10 +130,10 @@ export const tools = [
|
|
|
119
130
|
},
|
|
120
131
|
required: ["projectId", "key"],
|
|
121
132
|
},
|
|
122
|
-
execute: async (args:
|
|
133
|
+
execute: async (args: Record<string, unknown>) => {
|
|
123
134
|
const { projectId, ...payload } = args;
|
|
124
135
|
if (!projectId) throw new Error("projectId is required");
|
|
125
|
-
return await extensionClient.retrieve(projectId, payload);
|
|
136
|
+
return await extensionClient.retrieve(projectId as string, payload);
|
|
126
137
|
},
|
|
127
138
|
},
|
|
128
139
|
{
|
|
@@ -138,10 +149,10 @@ export const tools = [
|
|
|
138
149
|
},
|
|
139
150
|
required: ["projectId", "query"],
|
|
140
151
|
},
|
|
141
|
-
execute: async (args:
|
|
152
|
+
execute: async (args: Record<string, unknown>) => {
|
|
142
153
|
const { projectId, ...payload } = args;
|
|
143
154
|
if (!projectId) throw new Error("projectId is required");
|
|
144
|
-
return await extensionClient.search(projectId, payload);
|
|
155
|
+
return await extensionClient.search(projectId as string, payload);
|
|
145
156
|
},
|
|
146
157
|
},
|
|
147
158
|
{
|
|
@@ -154,12 +165,12 @@ export const tools = [
|
|
|
154
165
|
limit: { type: "number" },
|
|
155
166
|
offset: { type: "number" },
|
|
156
167
|
},
|
|
157
|
-
required: ["projectId"]
|
|
168
|
+
required: ["projectId"],
|
|
158
169
|
},
|
|
159
|
-
execute: async (args:
|
|
170
|
+
execute: async (args: Record<string, unknown>) => {
|
|
160
171
|
const { projectId, ...payload } = args;
|
|
161
172
|
if (!projectId) throw new Error("projectId is required");
|
|
162
|
-
return await extensionClient.list(projectId, payload);
|
|
173
|
+
return await extensionClient.list(projectId as string, payload);
|
|
163
174
|
},
|
|
164
175
|
},
|
|
165
176
|
{
|
|
@@ -171,12 +182,12 @@ export const tools = [
|
|
|
171
182
|
projectId: { type: "string", description: "The Munin Project ID" },
|
|
172
183
|
limit: { type: "number" },
|
|
173
184
|
},
|
|
174
|
-
required: ["projectId"]
|
|
185
|
+
required: ["projectId"],
|
|
175
186
|
},
|
|
176
|
-
execute: async (args:
|
|
187
|
+
execute: async (args: Record<string, unknown>) => {
|
|
177
188
|
const { projectId, ...payload } = args;
|
|
178
189
|
if (!projectId) throw new Error("projectId is required");
|
|
179
|
-
return await extensionClient.recent(projectId, payload);
|
|
190
|
+
return await extensionClient.recent(projectId as string, payload);
|
|
180
191
|
},
|
|
181
192
|
},
|
|
182
193
|
];
|