cc-memory 2.0.0
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 +369 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +35 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +83 -0
- package/dist/cli.js.map +1 -0
- package/dist/search.d.ts +11 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +40 -0
- package/dist/search.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +40 -0
- package/dist/server.js.map +1 -0
- package/dist/storage.d.ts +20 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +185 -0
- package/dist/storage.js.map +1 -0
- package/dist/tools.d.ts +341 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +259 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +36 -0
package/dist/storage.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// cc-memory v2 storage - SQLite via better-sqlite3
|
|
2
|
+
import Database from "better-sqlite3";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
const SCHEMA = `
|
|
5
|
+
CREATE TABLE IF NOT EXISTS projects (
|
|
6
|
+
id TEXT PRIMARY KEY,
|
|
7
|
+
description TEXT,
|
|
8
|
+
created_at TEXT NOT NULL
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
CREATE TABLE IF NOT EXISTS agents (
|
|
12
|
+
project_id TEXT NOT NULL,
|
|
13
|
+
agent_id TEXT NOT NULL,
|
|
14
|
+
role TEXT NOT NULL CHECK(role IN ('manager', 'worker')),
|
|
15
|
+
created_at TEXT NOT NULL,
|
|
16
|
+
PRIMARY KEY (project_id, agent_id)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE IF NOT EXISTS memories (
|
|
20
|
+
id TEXT PRIMARY KEY,
|
|
21
|
+
project_id TEXT NOT NULL,
|
|
22
|
+
scope TEXT NOT NULL CHECK(scope IN ('shared', 'personal')),
|
|
23
|
+
agent_id TEXT,
|
|
24
|
+
content TEXT NOT NULL,
|
|
25
|
+
tags TEXT,
|
|
26
|
+
created_by TEXT,
|
|
27
|
+
created_at TEXT NOT NULL,
|
|
28
|
+
updated_at TEXT NOT NULL
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
CREATE INDEX IF NOT EXISTS idx_memories_project ON memories(project_id);
|
|
32
|
+
CREATE INDEX IF NOT EXISTS idx_memories_scope ON memories(scope);
|
|
33
|
+
CREATE INDEX IF NOT EXISTS idx_memories_agent ON memories(agent_id);
|
|
34
|
+
`;
|
|
35
|
+
export class Storage {
|
|
36
|
+
db;
|
|
37
|
+
constructor(dbPath = "cc-memory.db") {
|
|
38
|
+
this.db = new Database(dbPath);
|
|
39
|
+
this.db.pragma("journal_mode = WAL");
|
|
40
|
+
this.db.pragma("foreign_keys = ON");
|
|
41
|
+
this.db.exec(SCHEMA);
|
|
42
|
+
// Add created_by column if missing (migration)
|
|
43
|
+
this.migrateCreatedBy();
|
|
44
|
+
// Ensure default project exists
|
|
45
|
+
this.ensureDefaultProject();
|
|
46
|
+
}
|
|
47
|
+
migrateCreatedBy() {
|
|
48
|
+
const cols = this.db.prepare("PRAGMA table_info(memories)").all();
|
|
49
|
+
if (!cols.some((c) => c.name === "created_by")) {
|
|
50
|
+
this.db.exec("ALTER TABLE memories ADD COLUMN created_by TEXT");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
ensureDefaultProject() {
|
|
54
|
+
const existing = this.db.prepare("SELECT id FROM projects WHERE id = ?").get("default");
|
|
55
|
+
if (!existing) {
|
|
56
|
+
const now = new Date().toISOString();
|
|
57
|
+
this.db.prepare("INSERT INTO projects (id, description, created_at) VALUES (?, ?, ?)").run("default", "Default project", now);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Projects
|
|
61
|
+
createProject(id, description) {
|
|
62
|
+
const now = new Date().toISOString();
|
|
63
|
+
this.db
|
|
64
|
+
.prepare("INSERT INTO projects (id, description, created_at) VALUES (?, ?, ?)")
|
|
65
|
+
.run(id, description, now);
|
|
66
|
+
return { id, description, created_at: now };
|
|
67
|
+
}
|
|
68
|
+
listProjects() {
|
|
69
|
+
return this.db.prepare("SELECT * FROM projects ORDER BY created_at").all();
|
|
70
|
+
}
|
|
71
|
+
getProject(id) {
|
|
72
|
+
return this.db.prepare("SELECT * FROM projects WHERE id = ?").get(id);
|
|
73
|
+
}
|
|
74
|
+
// Agents
|
|
75
|
+
registerAgent(projectId, agentId, role) {
|
|
76
|
+
const now = new Date().toISOString();
|
|
77
|
+
this.db
|
|
78
|
+
.prepare("INSERT OR REPLACE INTO agents (project_id, agent_id, role, created_at) VALUES (?, ?, ?, ?)")
|
|
79
|
+
.run(projectId, agentId, role, now);
|
|
80
|
+
return { project_id: projectId, agent_id: agentId, role, created_at: now };
|
|
81
|
+
}
|
|
82
|
+
listAgents(projectId) {
|
|
83
|
+
return this.db
|
|
84
|
+
.prepare("SELECT * FROM agents WHERE project_id = ? ORDER BY created_at")
|
|
85
|
+
.all(projectId);
|
|
86
|
+
}
|
|
87
|
+
getAgent(projectId, agentId) {
|
|
88
|
+
return this.db
|
|
89
|
+
.prepare("SELECT * FROM agents WHERE project_id = ? AND agent_id = ?")
|
|
90
|
+
.get(projectId, agentId);
|
|
91
|
+
}
|
|
92
|
+
// Memories
|
|
93
|
+
storeMemory(projectId, scope, agentId, content, tags, createdBy = null) {
|
|
94
|
+
const id = randomUUID();
|
|
95
|
+
const now = new Date().toISOString();
|
|
96
|
+
const tagsJson = tags ? JSON.stringify(tags) : null;
|
|
97
|
+
this.db
|
|
98
|
+
.prepare("INSERT INTO memories (id, project_id, scope, agent_id, content, tags, created_by, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
|
99
|
+
.run(id, projectId, scope, agentId, content, tagsJson, createdBy, now, now);
|
|
100
|
+
return { id, project_id: projectId, scope, agent_id: agentId, content, tags, created_by: createdBy, created_at: now, updated_at: now };
|
|
101
|
+
}
|
|
102
|
+
listMemories(scope, projectId, agentId) {
|
|
103
|
+
let sql = "SELECT * FROM memories WHERE scope = ?";
|
|
104
|
+
const params = [scope];
|
|
105
|
+
if (projectId) {
|
|
106
|
+
sql += " AND project_id = ?";
|
|
107
|
+
params.push(projectId);
|
|
108
|
+
}
|
|
109
|
+
if (agentId) {
|
|
110
|
+
sql += " AND agent_id = ?";
|
|
111
|
+
params.push(agentId);
|
|
112
|
+
}
|
|
113
|
+
sql += " ORDER BY created_at DESC";
|
|
114
|
+
return this.db.prepare(sql).all(...params).map(parseMemoryRow);
|
|
115
|
+
}
|
|
116
|
+
searchMemories(query, scope, projectId, agentId, limit = 10) {
|
|
117
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
118
|
+
if (terms.length === 0)
|
|
119
|
+
return [];
|
|
120
|
+
let sql = "SELECT * FROM memories WHERE 1=1";
|
|
121
|
+
const params = [];
|
|
122
|
+
if (scope !== "all") {
|
|
123
|
+
sql += " AND scope = ?";
|
|
124
|
+
params.push(scope);
|
|
125
|
+
}
|
|
126
|
+
if (projectId) {
|
|
127
|
+
sql += " AND project_id = ?";
|
|
128
|
+
params.push(projectId);
|
|
129
|
+
}
|
|
130
|
+
if (agentId) {
|
|
131
|
+
sql += " AND agent_id = ?";
|
|
132
|
+
params.push(agentId);
|
|
133
|
+
}
|
|
134
|
+
// SQL LIKE filter: at least one term must match
|
|
135
|
+
const likeClauses = terms.map(() => "(content LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\')");
|
|
136
|
+
sql += " AND (" + likeClauses.join(" OR ") + ")";
|
|
137
|
+
for (const term of terms) {
|
|
138
|
+
const escaped = term.replace(/%/g, "\\%").replace(/_/g, "\\_");
|
|
139
|
+
const pattern = `%${escaped}%`;
|
|
140
|
+
params.push(pattern, pattern);
|
|
141
|
+
}
|
|
142
|
+
sql += " ORDER BY created_at DESC";
|
|
143
|
+
const rows = this.db.prepare(sql).all(...params).map(parseMemoryRow);
|
|
144
|
+
// Score and rank in memory
|
|
145
|
+
return searchAndRank(rows, query, limit);
|
|
146
|
+
}
|
|
147
|
+
getMemory(id) {
|
|
148
|
+
const row = this.db.prepare("SELECT * FROM memories WHERE id = ?").get(id);
|
|
149
|
+
return row ? parseMemoryRow(row) : undefined;
|
|
150
|
+
}
|
|
151
|
+
deleteMemory(id) {
|
|
152
|
+
const result = this.db.prepare("DELETE FROM memories WHERE id = ?").run(id);
|
|
153
|
+
return result.changes > 0;
|
|
154
|
+
}
|
|
155
|
+
close() {
|
|
156
|
+
this.db.close();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function parseMemoryRow(row) {
|
|
160
|
+
return {
|
|
161
|
+
...row,
|
|
162
|
+
scope: row.scope,
|
|
163
|
+
tags: row.tags ? JSON.parse(row.tags) : null,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function searchAndRank(memories, query, limit) {
|
|
167
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
168
|
+
if (terms.length === 0)
|
|
169
|
+
return memories.slice(0, limit);
|
|
170
|
+
const scored = memories.map((m) => {
|
|
171
|
+
const text = (m.content + " " + (m.tags?.join(" ") ?? "")).toLowerCase();
|
|
172
|
+
let score = 0;
|
|
173
|
+
for (const term of terms) {
|
|
174
|
+
if (text.includes(term))
|
|
175
|
+
score++;
|
|
176
|
+
}
|
|
177
|
+
return { memory: m, score };
|
|
178
|
+
});
|
|
179
|
+
return scored
|
|
180
|
+
.filter((s) => s.score > 0)
|
|
181
|
+
.sort((a, b) => b.score - a.score)
|
|
182
|
+
.slice(0, limit)
|
|
183
|
+
.map((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{ z } from "zod";
|
|
2
|
+
import type { Storage } from "./storage.js";
|
|
3
|
+
export declare const schemas: {
|
|
4
|
+
memory_store: z.ZodObject<{
|
|
5
|
+
scope: z.ZodEnum<["shared", "personal"]>;
|
|
6
|
+
agent_id: z.ZodString;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
project_id: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
scope: "shared" | "personal";
|
|
12
|
+
agent_id: string;
|
|
13
|
+
content: string;
|
|
14
|
+
tags?: string[] | undefined;
|
|
15
|
+
project_id?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
scope: "shared" | "personal";
|
|
18
|
+
agent_id: string;
|
|
19
|
+
content: string;
|
|
20
|
+
tags?: string[] | undefined;
|
|
21
|
+
project_id?: string | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
memory_recall: z.ZodObject<{
|
|
24
|
+
scope: z.ZodEnum<["shared", "personal", "all"]>;
|
|
25
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
26
|
+
caller_id: z.ZodOptional<z.ZodString>;
|
|
27
|
+
query: z.ZodString;
|
|
28
|
+
project_id: z.ZodOptional<z.ZodString>;
|
|
29
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
scope: "shared" | "personal" | "all";
|
|
32
|
+
query: string;
|
|
33
|
+
agent_id?: string | undefined;
|
|
34
|
+
project_id?: string | undefined;
|
|
35
|
+
caller_id?: string | undefined;
|
|
36
|
+
limit?: number | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
scope: "shared" | "personal" | "all";
|
|
39
|
+
query: string;
|
|
40
|
+
agent_id?: string | undefined;
|
|
41
|
+
project_id?: string | undefined;
|
|
42
|
+
caller_id?: string | undefined;
|
|
43
|
+
limit?: number | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
memory_list: z.ZodObject<{
|
|
46
|
+
scope: z.ZodEnum<["shared", "personal"]>;
|
|
47
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
48
|
+
project_id: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
scope: "shared" | "personal";
|
|
51
|
+
agent_id?: string | undefined;
|
|
52
|
+
project_id?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
scope: "shared" | "personal";
|
|
55
|
+
agent_id?: string | undefined;
|
|
56
|
+
project_id?: string | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
memory_delete: z.ZodObject<{
|
|
59
|
+
memory_id: z.ZodString;
|
|
60
|
+
caller_id: z.ZodOptional<z.ZodString>;
|
|
61
|
+
project_id: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
memory_id: string;
|
|
64
|
+
project_id?: string | undefined;
|
|
65
|
+
caller_id?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
memory_id: string;
|
|
68
|
+
project_id?: string | undefined;
|
|
69
|
+
caller_id?: string | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
project_create: z.ZodObject<{
|
|
72
|
+
project_id: z.ZodString;
|
|
73
|
+
description: z.ZodString;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
project_id: string;
|
|
76
|
+
description: string;
|
|
77
|
+
}, {
|
|
78
|
+
project_id: string;
|
|
79
|
+
description: string;
|
|
80
|
+
}>;
|
|
81
|
+
project_list: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
82
|
+
agent_register: z.ZodObject<{
|
|
83
|
+
project_id: z.ZodString;
|
|
84
|
+
agent_id: z.ZodString;
|
|
85
|
+
role: z.ZodEnum<["manager", "worker"]>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
agent_id: string;
|
|
88
|
+
project_id: string;
|
|
89
|
+
role: "manager" | "worker";
|
|
90
|
+
}, {
|
|
91
|
+
agent_id: string;
|
|
92
|
+
project_id: string;
|
|
93
|
+
role: "manager" | "worker";
|
|
94
|
+
}>;
|
|
95
|
+
agent_list: z.ZodObject<{
|
|
96
|
+
project_id: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
project_id: string;
|
|
99
|
+
}, {
|
|
100
|
+
project_id: string;
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
export declare const toolDefinitions: ({
|
|
104
|
+
name: string;
|
|
105
|
+
description: string;
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: "object";
|
|
108
|
+
properties: {
|
|
109
|
+
scope: {
|
|
110
|
+
type: string;
|
|
111
|
+
enum: string[];
|
|
112
|
+
description: string;
|
|
113
|
+
};
|
|
114
|
+
agent_id: {
|
|
115
|
+
type: string;
|
|
116
|
+
description: string;
|
|
117
|
+
};
|
|
118
|
+
content: {
|
|
119
|
+
type: string;
|
|
120
|
+
description: string;
|
|
121
|
+
};
|
|
122
|
+
tags: {
|
|
123
|
+
type: string;
|
|
124
|
+
items: {
|
|
125
|
+
type: string;
|
|
126
|
+
};
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
project_id: {
|
|
130
|
+
type: string;
|
|
131
|
+
description: string;
|
|
132
|
+
};
|
|
133
|
+
caller_id?: undefined;
|
|
134
|
+
query?: undefined;
|
|
135
|
+
limit?: undefined;
|
|
136
|
+
memory_id?: undefined;
|
|
137
|
+
description?: undefined;
|
|
138
|
+
role?: undefined;
|
|
139
|
+
};
|
|
140
|
+
required: string[];
|
|
141
|
+
};
|
|
142
|
+
} | {
|
|
143
|
+
name: string;
|
|
144
|
+
description: string;
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: "object";
|
|
147
|
+
properties: {
|
|
148
|
+
scope: {
|
|
149
|
+
type: string;
|
|
150
|
+
enum: string[];
|
|
151
|
+
description: string;
|
|
152
|
+
};
|
|
153
|
+
agent_id: {
|
|
154
|
+
type: string;
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
caller_id: {
|
|
158
|
+
type: string;
|
|
159
|
+
description: string;
|
|
160
|
+
};
|
|
161
|
+
query: {
|
|
162
|
+
type: string;
|
|
163
|
+
description: string;
|
|
164
|
+
};
|
|
165
|
+
project_id: {
|
|
166
|
+
type: string;
|
|
167
|
+
description: string;
|
|
168
|
+
};
|
|
169
|
+
limit: {
|
|
170
|
+
type: string;
|
|
171
|
+
description: string;
|
|
172
|
+
};
|
|
173
|
+
content?: undefined;
|
|
174
|
+
tags?: undefined;
|
|
175
|
+
memory_id?: undefined;
|
|
176
|
+
description?: undefined;
|
|
177
|
+
role?: undefined;
|
|
178
|
+
};
|
|
179
|
+
required: string[];
|
|
180
|
+
};
|
|
181
|
+
} | {
|
|
182
|
+
name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
inputSchema: {
|
|
185
|
+
type: "object";
|
|
186
|
+
properties: {
|
|
187
|
+
scope: {
|
|
188
|
+
type: string;
|
|
189
|
+
enum: string[];
|
|
190
|
+
description: string;
|
|
191
|
+
};
|
|
192
|
+
agent_id: {
|
|
193
|
+
type: string;
|
|
194
|
+
description: string;
|
|
195
|
+
};
|
|
196
|
+
project_id: {
|
|
197
|
+
type: string;
|
|
198
|
+
description: string;
|
|
199
|
+
};
|
|
200
|
+
content?: undefined;
|
|
201
|
+
tags?: undefined;
|
|
202
|
+
caller_id?: undefined;
|
|
203
|
+
query?: undefined;
|
|
204
|
+
limit?: undefined;
|
|
205
|
+
memory_id?: undefined;
|
|
206
|
+
description?: undefined;
|
|
207
|
+
role?: undefined;
|
|
208
|
+
};
|
|
209
|
+
required: string[];
|
|
210
|
+
};
|
|
211
|
+
} | {
|
|
212
|
+
name: string;
|
|
213
|
+
description: string;
|
|
214
|
+
inputSchema: {
|
|
215
|
+
type: "object";
|
|
216
|
+
properties: {
|
|
217
|
+
memory_id: {
|
|
218
|
+
type: string;
|
|
219
|
+
description: string;
|
|
220
|
+
};
|
|
221
|
+
caller_id: {
|
|
222
|
+
type: string;
|
|
223
|
+
description: string;
|
|
224
|
+
};
|
|
225
|
+
project_id: {
|
|
226
|
+
type: string;
|
|
227
|
+
description: string;
|
|
228
|
+
};
|
|
229
|
+
scope?: undefined;
|
|
230
|
+
agent_id?: undefined;
|
|
231
|
+
content?: undefined;
|
|
232
|
+
tags?: undefined;
|
|
233
|
+
query?: undefined;
|
|
234
|
+
limit?: undefined;
|
|
235
|
+
description?: undefined;
|
|
236
|
+
role?: undefined;
|
|
237
|
+
};
|
|
238
|
+
required: string[];
|
|
239
|
+
};
|
|
240
|
+
} | {
|
|
241
|
+
name: string;
|
|
242
|
+
description: string;
|
|
243
|
+
inputSchema: {
|
|
244
|
+
type: "object";
|
|
245
|
+
properties: {
|
|
246
|
+
project_id: {
|
|
247
|
+
type: string;
|
|
248
|
+
description: string;
|
|
249
|
+
};
|
|
250
|
+
description: {
|
|
251
|
+
type: string;
|
|
252
|
+
description: string;
|
|
253
|
+
};
|
|
254
|
+
scope?: undefined;
|
|
255
|
+
agent_id?: undefined;
|
|
256
|
+
content?: undefined;
|
|
257
|
+
tags?: undefined;
|
|
258
|
+
caller_id?: undefined;
|
|
259
|
+
query?: undefined;
|
|
260
|
+
limit?: undefined;
|
|
261
|
+
memory_id?: undefined;
|
|
262
|
+
role?: undefined;
|
|
263
|
+
};
|
|
264
|
+
required: string[];
|
|
265
|
+
};
|
|
266
|
+
} | {
|
|
267
|
+
name: string;
|
|
268
|
+
description: string;
|
|
269
|
+
inputSchema: {
|
|
270
|
+
type: "object";
|
|
271
|
+
properties: {
|
|
272
|
+
scope?: undefined;
|
|
273
|
+
agent_id?: undefined;
|
|
274
|
+
content?: undefined;
|
|
275
|
+
tags?: undefined;
|
|
276
|
+
project_id?: undefined;
|
|
277
|
+
caller_id?: undefined;
|
|
278
|
+
query?: undefined;
|
|
279
|
+
limit?: undefined;
|
|
280
|
+
memory_id?: undefined;
|
|
281
|
+
description?: undefined;
|
|
282
|
+
role?: undefined;
|
|
283
|
+
};
|
|
284
|
+
required?: undefined;
|
|
285
|
+
};
|
|
286
|
+
} | {
|
|
287
|
+
name: string;
|
|
288
|
+
description: string;
|
|
289
|
+
inputSchema: {
|
|
290
|
+
type: "object";
|
|
291
|
+
properties: {
|
|
292
|
+
project_id: {
|
|
293
|
+
type: string;
|
|
294
|
+
description: string;
|
|
295
|
+
};
|
|
296
|
+
agent_id: {
|
|
297
|
+
type: string;
|
|
298
|
+
description: string;
|
|
299
|
+
};
|
|
300
|
+
role: {
|
|
301
|
+
type: string;
|
|
302
|
+
enum: string[];
|
|
303
|
+
description: string;
|
|
304
|
+
};
|
|
305
|
+
scope?: undefined;
|
|
306
|
+
content?: undefined;
|
|
307
|
+
tags?: undefined;
|
|
308
|
+
caller_id?: undefined;
|
|
309
|
+
query?: undefined;
|
|
310
|
+
limit?: undefined;
|
|
311
|
+
memory_id?: undefined;
|
|
312
|
+
description?: undefined;
|
|
313
|
+
};
|
|
314
|
+
required: string[];
|
|
315
|
+
};
|
|
316
|
+
} | {
|
|
317
|
+
name: string;
|
|
318
|
+
description: string;
|
|
319
|
+
inputSchema: {
|
|
320
|
+
type: "object";
|
|
321
|
+
properties: {
|
|
322
|
+
project_id: {
|
|
323
|
+
type: string;
|
|
324
|
+
description: string;
|
|
325
|
+
};
|
|
326
|
+
scope?: undefined;
|
|
327
|
+
agent_id?: undefined;
|
|
328
|
+
content?: undefined;
|
|
329
|
+
tags?: undefined;
|
|
330
|
+
caller_id?: undefined;
|
|
331
|
+
query?: undefined;
|
|
332
|
+
limit?: undefined;
|
|
333
|
+
memory_id?: undefined;
|
|
334
|
+
description?: undefined;
|
|
335
|
+
role?: undefined;
|
|
336
|
+
};
|
|
337
|
+
required: string[];
|
|
338
|
+
};
|
|
339
|
+
})[];
|
|
340
|
+
export declare function createToolHandler(storage: Storage): (name: string, args: Record<string, unknown>) => Promise<string>;
|
|
341
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCnB,CAAC;AAGF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoG3B,CAAC;AAGF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,IAClC,MAAM,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC,CA6H5E"}
|