@dudamel/mcp-memory 2026.1008.1 → 2026.1016.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/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +533 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/stdio-server.js +563 -16
- package/dist/tools/conversations.d.ts +1 -1
- package/dist/tools/conversations.d.ts.map +1 -1
- package/dist/tools/files.d.ts +2 -2
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/memories.d.ts +1 -1
- package/dist/tools/memories.d.ts.map +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/util.d.ts +1 -14
- package/dist/util.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/http-client.d.ts +0 -18
- package/dist/http-client.d.ts.map +0 -1
- package/dist/http-client.js +0 -72
- package/dist/http-client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/server.js +0 -29
- package/dist/server.js.map +0 -1
- package/dist/stdio-server.js.map +0 -1
- package/dist/tools/conversations.js +0 -36
- package/dist/tools/conversations.js.map +0 -1
- package/dist/tools/files.js +0 -127
- package/dist/tools/files.js.map +0 -1
- package/dist/tools/memories.js +0 -195
- package/dist/tools/memories.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/util.js +0 -59
- package/dist/util.js.map +0 -1
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,QAAA,MAAM,gBAAgB,4BAOnB,CAAC;AAEJ;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,gBAAgB,CAAA;CAAE,CAExF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGxF;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAGtF;AAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudamel/mcp-memory",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1016.1",
|
|
4
4
|
"description": "Dudamel Memory MCP — stdio client for an org's Dudamel memory (agent/user knowledge) over its REST API.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "module",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"zod": "^3.24.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"
|
|
34
|
+
"esbuild": "^0.25.0",
|
|
35
|
+
"@dudamel/mcp-common": "0.1.0",
|
|
35
36
|
"@dudamel/mcp-tool-contract": "0.1.0"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|
|
38
|
-
"build": "tsc",
|
|
39
|
+
"build": "esbuild src/stdio-server.ts src/index.ts --bundle --platform=node --target=node22 --format=esm --outdir=dist --external:@modelcontextprotocol/sdk --external:zod && tsc --emitDeclarationOnly",
|
|
39
40
|
"lint": "eslint src/",
|
|
40
41
|
"lint:fix": "eslint src/ --fix",
|
|
41
42
|
"test": "vitest run --passWithNoTests",
|
package/dist/http-client.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare class DudamelApiError extends Error {
|
|
2
|
-
readonly status: number;
|
|
3
|
-
readonly statusText: string;
|
|
4
|
-
readonly body: string;
|
|
5
|
-
constructor(status: number, statusText: string, body: string);
|
|
6
|
-
}
|
|
7
|
-
export declare class DudamelApiClient {
|
|
8
|
-
private readonly baseUrl;
|
|
9
|
-
private readonly headers;
|
|
10
|
-
constructor(baseUrl: string, apiKey: string, authScheme?: 'ApiKey' | 'Bearer');
|
|
11
|
-
get<T = unknown>(path: string, params?: Record<string, string>): Promise<T>;
|
|
12
|
-
post<T = unknown>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
|
|
13
|
-
put<T = unknown>(path: string, body?: unknown, params?: Record<string, string>): Promise<T>;
|
|
14
|
-
delete<T = unknown>(path: string, params?: Record<string, string>): Promise<T>;
|
|
15
|
-
private buildUrl;
|
|
16
|
-
private request;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;aAEtB,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,IAAI,EAAE,MAAM;gBAFZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM;CAK/B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAQvE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAK3E,IAAI,CAAC,CAAC,GAAG,OAAO,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC;IAQP,GAAG,CAAC,CAAC,GAAG,OAAO,EACnB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC;IAQP,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKpF,OAAO,CAAC,QAAQ;YAYF,OAAO;CAiBtB"}
|
package/dist/http-client.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export class DudamelApiError extends Error {
|
|
2
|
-
status;
|
|
3
|
-
statusText;
|
|
4
|
-
body;
|
|
5
|
-
constructor(status, statusText, body) {
|
|
6
|
-
super(`Dudamel API error ${status} ${statusText}: ${body}`);
|
|
7
|
-
this.status = status;
|
|
8
|
-
this.statusText = statusText;
|
|
9
|
-
this.body = body;
|
|
10
|
-
this.name = 'DudamelApiError';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export class DudamelApiClient {
|
|
14
|
-
baseUrl;
|
|
15
|
-
headers;
|
|
16
|
-
constructor(baseUrl, apiKey, authScheme) {
|
|
17
|
-
this.baseUrl = baseUrl.replace(/\/+$/, '');
|
|
18
|
-
this.headers = {
|
|
19
|
-
Authorization: `${authScheme ?? 'ApiKey'} ${apiKey}`,
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
async get(path, params) {
|
|
24
|
-
const url = this.buildUrl(path, params);
|
|
25
|
-
return this.request(url, { method: 'GET' });
|
|
26
|
-
}
|
|
27
|
-
async post(path, body, params) {
|
|
28
|
-
const url = this.buildUrl(path, params);
|
|
29
|
-
return this.request(url, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async put(path, body, params) {
|
|
35
|
-
const url = this.buildUrl(path, params);
|
|
36
|
-
return this.request(url, {
|
|
37
|
-
method: 'PUT',
|
|
38
|
-
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async delete(path, params) {
|
|
42
|
-
const url = this.buildUrl(path, params);
|
|
43
|
-
return this.request(url, { method: 'DELETE' });
|
|
44
|
-
}
|
|
45
|
-
buildUrl(path, params) {
|
|
46
|
-
const url = new URL(path, this.baseUrl);
|
|
47
|
-
if (params) {
|
|
48
|
-
for (const [key, value] of Object.entries(params)) {
|
|
49
|
-
if (value !== undefined && value !== '') {
|
|
50
|
-
url.searchParams.set(key, value);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return url.toString();
|
|
55
|
-
}
|
|
56
|
-
async request(url, init) {
|
|
57
|
-
const response = await fetch(url, {
|
|
58
|
-
...init,
|
|
59
|
-
headers: this.headers,
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const body = await response.text();
|
|
63
|
-
throw new DudamelApiError(response.status, response.statusText, body);
|
|
64
|
-
}
|
|
65
|
-
const text = await response.text();
|
|
66
|
-
if (!text) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
return JSON.parse(text);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=http-client.js.map
|
package/dist/http-client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAEtB;IACA;IACA;IAHlB,YACkB,MAAc,EACd,UAAkB,EAClB,IAAY;QAE5B,KAAK,CAAC,qBAAqB,MAAM,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC,CAAC;QAJ5C,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IACV,OAAO,CAAS;IAChB,OAAO,CAAyB;IAEjD,YAAY,OAAe,EAAE,MAAc,EAAE,UAAgC;QAC3E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG;YACb,aAAa,EAAE,GAAG,UAAU,IAAI,QAAQ,IAAI,MAAM,EAAE;YACpD,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAc,IAAY,EAAE,MAA+B;QAClE,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAI,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,IAAI,CACR,IAAY,EACZ,IAAc,EACd,MAA+B;QAE/B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IA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,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,GAAW,EAAE,IAAiB;QACrD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,GAAG,IAAI;YACP,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,MAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,SAAc,CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/server.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { DudamelApiClient } from './http-client.js';
|
|
3
|
-
import { registerMemoryTools } from './tools/memories.js';
|
|
4
|
-
import { registerConversationTools } from './tools/conversations.js';
|
|
5
|
-
import { registerFileTools } from './tools/files.js';
|
|
6
|
-
export function createMemoryServer(config) {
|
|
7
|
-
const server = new McpServer({ name: 'dudamel-memory', version: '0.1.0' }, {
|
|
8
|
-
capabilities: { tools: {} },
|
|
9
|
-
instructions: 'Dudamel Memory MCP — query and manage your memories and past conversations. ' +
|
|
10
|
-
'Always search before creating or updating a memory to avoid duplicates. ' +
|
|
11
|
-
'Write tools require a prior search in the same session. ' +
|
|
12
|
-
'Files: the turn workspace is wiped when the turn ends, so use save-file for ' +
|
|
13
|
-
'anything that must outlive it.',
|
|
14
|
-
});
|
|
15
|
-
const client = new DudamelApiClient(config.apiUrl, config.apiKey, config.authScheme);
|
|
16
|
-
const ctx = {
|
|
17
|
-
userId: config.userId,
|
|
18
|
-
agentName: config.agentName,
|
|
19
|
-
seenIds: new Set(),
|
|
20
|
-
fetchedIds: new Set(),
|
|
21
|
-
hasListed: false,
|
|
22
|
-
conversationId: config.conversationId,
|
|
23
|
-
};
|
|
24
|
-
registerMemoryTools(server, client, ctx);
|
|
25
|
-
registerConversationTools(server, client, ctx);
|
|
26
|
-
registerFileTools(server, client, ctx);
|
|
27
|
-
return server;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,UAAU,kBAAkB,CAAC,MAAuB;IACxD,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC5C;QACE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;Q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G,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC;AACpE,mFAAmF;AACnF,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE9D,IAAI,CAAC,MAAM,EAAE,CAAC;IACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;AACzF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { agentNameInput, agentParams, errorResult, jsonResult } from '../util.js';
|
|
3
|
-
export function registerConversationTools(server, client, ctx) {
|
|
4
|
-
server.registerTool('list-conversations', {
|
|
5
|
-
description: 'List your past conversations. Scoped to the current agent when one is in context; ' +
|
|
6
|
-
'otherwise every conversation you have had, with any agent. Returns conversation ' +
|
|
7
|
-
'metadata including ids, timestamps, and summaries.',
|
|
8
|
-
inputSchema: { ...agentNameInput(ctx) },
|
|
9
|
-
annotations: { readOnlyHint: true },
|
|
10
|
-
}, async ({ agentName }) => {
|
|
11
|
-
try {
|
|
12
|
-
const result = await client.get('/api/chat/conversations', agentParams(ctx, agentName));
|
|
13
|
-
return jsonResult(result);
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
return errorResult(err);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
server.registerTool('get-conversation-messages', {
|
|
20
|
-
description: 'Get the full message history for a specific conversation. Returns all messages ' +
|
|
21
|
-
'in chronological order.',
|
|
22
|
-
inputSchema: {
|
|
23
|
-
conversationId: z.string().describe('The conversation ID to retrieve messages for'),
|
|
24
|
-
},
|
|
25
|
-
annotations: { readOnlyHint: true },
|
|
26
|
-
}, async ({ conversationId }) => {
|
|
27
|
-
try {
|
|
28
|
-
const result = await client.get(`/api/chat/conversations/${conversationId}/messages`);
|
|
29
|
-
return jsonResult(result);
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
return errorResult(err);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=conversations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/tools/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElF,MAAM,UAAU,yBAAyB,CACvC,MAAiB,EACjB,MAAwB,EACxB,GAAgB;IAEhB,MAAM,CAAC,YAAY,CACjB,oBAAoB,EACpB;QACE,WAAW,EACT,oFAAoF;YACpF,kFAAkF;YAClF,oDAAoD;QACtD,WAAW,EAAE,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE;QACvC,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;KACpC,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QACtB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;YACxF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,2BAA2B,EAC3B;QACE,WAAW,EACT,iFAAiF;YACjF,yBAAyB;QAC3B,WAAW,EAAE;YACX,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;SACpF;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;KACpC,EACD,KAAK,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,2BAA2B,cAAc,WAAW,CAAC,CAAC;YACtF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/files.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { agentBody, agentNameInput, agentParams, errorResult, jsonResult } from '../util.js';
|
|
3
|
-
/**
|
|
4
|
-
* File tools (Plan 43 Etapa 5, Decisión 3).
|
|
5
|
-
*
|
|
6
|
-
* The registry exists so an agent can hand something back and pick it up later: files live
|
|
7
|
-
* outside the turn's workspace, which is still wiped after every turn. Saving is explicit —
|
|
8
|
-
* the agent keeps what it decided matters, instead of the runtime sweeping a directory into
|
|
9
|
-
* object storage and producing garbage nobody asked for.
|
|
10
|
-
*/
|
|
11
|
-
export function registerFileTools(server, client, ctx) {
|
|
12
|
-
const agentInput = agentNameInput(ctx);
|
|
13
|
-
server.registerTool('save-file', {
|
|
14
|
-
description: 'Store a file so it survives this turn. The turn workspace is wiped when the turn ' +
|
|
15
|
-
'ends, so anything you want to keep — a report, a diff, a generated CSV — has to be ' +
|
|
16
|
-
'saved here. Returns an id you can hand back to the user or use in a later turn. ' +
|
|
17
|
-
'Content goes base64-encoded.',
|
|
18
|
-
inputSchema: {
|
|
19
|
-
fileName: z.string().describe('Name for the file, e.g. "informe-q3.csv"'),
|
|
20
|
-
mimeType: z.string().describe('MIME type, e.g. "text/csv" or "application/pdf"'),
|
|
21
|
-
contentBase64: z.string().describe('File content, base64-encoded'),
|
|
22
|
-
conversationId: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe('Conversation this belongs to. Defaults to the current one.'),
|
|
26
|
-
...agentInput,
|
|
27
|
-
},
|
|
28
|
-
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
29
|
-
}, async ({ fileName, mimeType, contentBase64, conversationId, agentName }) => {
|
|
30
|
-
try {
|
|
31
|
-
return jsonResult(await client.post('/api/chat/files', {
|
|
32
|
-
fileName,
|
|
33
|
-
mimeType,
|
|
34
|
-
contentBase64,
|
|
35
|
-
// The current conversation unless told otherwise, so the common case needs no
|
|
36
|
-
// argument and the file is findable where it was produced.
|
|
37
|
-
conversationId: conversationId ?? ctx.conversationId,
|
|
38
|
-
...agentBody(ctx, agentName),
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
return errorResult(err);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
server.registerTool('list-files', {
|
|
46
|
-
description: 'List stored files for this conversation (default) or for this agent across ' +
|
|
47
|
-
'conversations. Returns metadata only — ids, names, types, sizes — not content.',
|
|
48
|
-
inputSchema: {
|
|
49
|
-
conversationId: z
|
|
50
|
-
.string()
|
|
51
|
-
.optional()
|
|
52
|
-
.describe('Conversation to list. Defaults to the current one.'),
|
|
53
|
-
allConversations: z
|
|
54
|
-
.boolean()
|
|
55
|
-
.optional()
|
|
56
|
-
.describe("List everything this agent saved, not just this conversation's"),
|
|
57
|
-
limit: z.number().optional().describe('Max files to return (default 50)'),
|
|
58
|
-
...agentInput,
|
|
59
|
-
},
|
|
60
|
-
annotations: { readOnlyHint: true },
|
|
61
|
-
}, async ({ conversationId, allConversations, limit, agentName }) => {
|
|
62
|
-
try {
|
|
63
|
-
const params = agentParams(ctx, agentName);
|
|
64
|
-
if (!allConversations) {
|
|
65
|
-
const target = conversationId ?? ctx.conversationId;
|
|
66
|
-
if (target)
|
|
67
|
-
params.conversationId = target;
|
|
68
|
-
}
|
|
69
|
-
if (limit)
|
|
70
|
-
params.limit = String(limit);
|
|
71
|
-
return jsonResult(await client.get('/api/chat/files', params));
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
return errorResult(err);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
server.registerTool('get-file', {
|
|
78
|
-
description: 'Read a stored file by id. Small text files come back with their content inline; ' +
|
|
79
|
-
'anything large or binary returns metadata only, and you should pass the id along ' +
|
|
80
|
-
'rather than trying to read the bytes — they would not fit in your context anyway.',
|
|
81
|
-
inputSchema: {
|
|
82
|
-
id: z.string().describe('File id from save-file or list-files'),
|
|
83
|
-
},
|
|
84
|
-
annotations: { readOnlyHint: true },
|
|
85
|
-
}, async ({ id }) => {
|
|
86
|
-
try {
|
|
87
|
-
return jsonResult(await client.get(`/api/chat/files/${encodeURIComponent(id)}`));
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
return errorResult(err);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
server.registerTool('send-file', {
|
|
94
|
-
description: 'Hand a stored file to the user in this conversation. Use it after save-file when ' +
|
|
95
|
-
'the user should actually receive the file — saving alone only keeps it. It is ' +
|
|
96
|
-
'delivered right after your reply, through whatever channel you are talking on; you ' +
|
|
97
|
-
'do not need to know which.',
|
|
98
|
-
inputSchema: {
|
|
99
|
-
id: z.string().describe('File id from save-file or list-files'),
|
|
100
|
-
},
|
|
101
|
-
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
102
|
-
}, async ({ id }) => {
|
|
103
|
-
try {
|
|
104
|
-
return jsonResult(await client.post(`/api/chat/files/${encodeURIComponent(id)}/send`, {}));
|
|
105
|
-
}
|
|
106
|
-
catch (err) {
|
|
107
|
-
return errorResult(err);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
server.registerTool('delete-file', {
|
|
111
|
-
description: 'Delete a stored file permanently. Use it for things you produced and no longer ' +
|
|
112
|
-
'need — not for files a user uploaded, unless they asked.',
|
|
113
|
-
inputSchema: {
|
|
114
|
-
id: z.string().describe('File id from save-file or list-files'),
|
|
115
|
-
},
|
|
116
|
-
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
117
|
-
}, async ({ id }) => {
|
|
118
|
-
try {
|
|
119
|
-
await client.delete(`/api/chat/files/${encodeURIComponent(id)}`);
|
|
120
|
-
return jsonResult({ deleted: true, id });
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
return errorResult(err);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=files.js.map
|
package/dist/tools/files.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/tools/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7F;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAiB,EACjB,MAAwB,EACxB,GAAgB;IAEhB,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAEvC,MAAM,CAAC,YAAY,CACjB,WAAW,EACX;QACE,WAAW,EACT,mFAAmF;YACnF,qFAAqF;YACrF,kFAAkF;YAClF,8BAA8B;QAChC,WAAW,EAAE;YACX,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;YACzE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;Y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2
|
-
import { agentBody, agentNameInput, agentParams, effectiveAgent, errorResult, jsonResult, } from '../util.js';
|
|
3
|
-
// The 4 memory scopes (2×2). The server maps each to (agent_name, user_id) columns.
|
|
4
|
-
//
|
|
5
|
-
// Each line states WHO WILL READ IT, not just what it means. The scopes are not equally
|
|
6
|
-
// consequential — 'org' is visible to every agent and every person in the organisation — and
|
|
7
|
-
// an LLM choosing between four abstract labels has no way to know that unless the description
|
|
8
|
-
// says so. Every scope stays writable: the risk here is an ACCIDENTAL over-share, not a
|
|
9
|
-
// malicious one, and the fix for an accident is a description that names the blast radius.
|
|
10
|
-
const SCOPE_HEADER = 'Scope of the memory — this is WHO WILL BE ABLE TO READ IT. Pick the NARROWEST that fits:\n';
|
|
11
|
-
const RELATIONAL_LINE = "- 'relational': you (this agent) + this one user. Nobody else. The default for a " +
|
|
12
|
-
'preference or fact about the person you are talking to.\n';
|
|
13
|
-
const PROFILE_LINE = "- 'profile': this one user, across ALL agents — every agent they talk to sees it. For " +
|
|
14
|
-
'facts about them that any agent should know (their role, timezone, how to reach them).\n';
|
|
15
|
-
const AGENT_LINE = "- 'agent': you (this agent), across ALL users — everyone who talks to you sees it. For " +
|
|
16
|
-
'your own working knowledge; never for something about a particular person.\n';
|
|
17
|
-
const ORG_LINE = "- 'org': EVERY agent and EVERY user in the organisation. The widest reach there is — only " +
|
|
18
|
-
'for a fact true of the whole organisation that you would be comfortable showing anyone ' +
|
|
19
|
-
'in it.\n';
|
|
20
|
-
function scopeDescription(unbound) {
|
|
21
|
-
return (SCOPE_HEADER +
|
|
22
|
-
RELATIONAL_LINE +
|
|
23
|
-
PROFILE_LINE +
|
|
24
|
-
AGENT_LINE +
|
|
25
|
-
ORG_LINE +
|
|
26
|
-
(unbound
|
|
27
|
-
? "'relational' and 'agent' need agentName — without an agent they have no one to " +
|
|
28
|
-
'belong to. '
|
|
29
|
-
: '') +
|
|
30
|
-
'Ask, in order: is this about ONE person (relational/profile) or about nobody in ' +
|
|
31
|
-
'particular (agent/org)? Then: does it really need to be visible beyond this ' +
|
|
32
|
-
'conversation?');
|
|
33
|
-
}
|
|
34
|
-
/** The quadrants that carry an agent column — impossible without one. */
|
|
35
|
-
const AGENT_SCOPES = new Set(['relational', 'agent']);
|
|
36
|
-
export function registerMemoryTools(server, client, ctx) {
|
|
37
|
-
// Unbound (no DUDAMEL_AGENT_NAME: a shared copy on a laptop, or a user's own terminal) the
|
|
38
|
-
// agent comes per call, as `agentName`. The four quadrants are all on the menu; the two that
|
|
39
|
-
// need an agent are refused locally when none was named, before the server says the same
|
|
40
|
-
// (MEMORY_AGENT_REQUIRED) — a schema is a hint, not an enforcement point.
|
|
41
|
-
const unbound = ctx.agentName === null;
|
|
42
|
-
const scopes = z.enum(['relational', 'profile', 'agent', 'org']);
|
|
43
|
-
const agentInput = agentNameInput(ctx);
|
|
44
|
-
// ── Read: list (summaries) ─────────────────────────────────────────────────
|
|
45
|
-
server.registerTool('list-memories', {
|
|
46
|
-
description: 'List memories relevant to the current user (summaries only, NOT full content). ' +
|
|
47
|
-
'Returns the union of everything you know that applies here: your notes on this ' +
|
|
48
|
-
'user, their profile, and your/org general knowledge' +
|
|
49
|
-
(unbound ? ' (without agentName: only their profile and org knowledge). ' : '. ') +
|
|
50
|
-
'Call this at the start of an interaction. ' +
|
|
51
|
-
'You MUST call this before creating a memory. Use get-memory to read a full entry.',
|
|
52
|
-
inputSchema: {
|
|
53
|
-
q: z
|
|
54
|
-
.string()
|
|
55
|
-
.optional()
|
|
56
|
-
.describe('Keyword filter over summary + content (omit to list all)'),
|
|
57
|
-
scope: scopes.optional().describe('Filter to a single scope'),
|
|
58
|
-
...agentInput,
|
|
59
|
-
},
|
|
60
|
-
annotations: { readOnlyHint: true },
|
|
61
|
-
}, async ({ q, scope, agentName }) => {
|
|
62
|
-
try {
|
|
63
|
-
const params = agentParams(ctx, agentName);
|
|
64
|
-
if (q)
|
|
65
|
-
params['q'] = q;
|
|
66
|
-
if (scope)
|
|
67
|
-
params['scope'] = scope;
|
|
68
|
-
const rows = await client.get('/api/chat/memories', params);
|
|
69
|
-
if (Array.isArray(rows)) {
|
|
70
|
-
for (const r of rows)
|
|
71
|
-
if (r.id)
|
|
72
|
-
ctx.seenIds.add(r.id);
|
|
73
|
-
}
|
|
74
|
-
ctx.hasListed = true;
|
|
75
|
-
return jsonResult(rows);
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
return errorResult(err);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
// ── Read: get one (full content) ──────────────────────────────────────────
|
|
82
|
-
server.registerTool('get-memory', {
|
|
83
|
-
description: 'Get the full content of a single memory by id. You MUST call this before updating a ' +
|
|
84
|
-
'memory (so you edit its real content, not blindly). Ids come from list-memories.',
|
|
85
|
-
inputSchema: { id: z.string().describe('Memory id (from list-memories)'), ...agentInput },
|
|
86
|
-
annotations: { readOnlyHint: true },
|
|
87
|
-
}, async ({ id, agentName }) => {
|
|
88
|
-
try {
|
|
89
|
-
const memory = await client.get(`/api/chat/memories/${id}`, agentParams(ctx, agentName));
|
|
90
|
-
if (memory?.id) {
|
|
91
|
-
ctx.fetchedIds.add(memory.id);
|
|
92
|
-
ctx.seenIds.add(memory.id);
|
|
93
|
-
}
|
|
94
|
-
return jsonResult(memory);
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
return errorResult(err);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
// ── Write: create ──────────────────────────────────────────────────────────
|
|
101
|
-
server.registerTool('create-memory', {
|
|
102
|
-
description: 'Create a NEW memory. Requires a prior list-memories call this session (to avoid ' +
|
|
103
|
-
'duplicates — if a similar memory exists, use update-memory instead). Content can be ' +
|
|
104
|
-
'multi-line markdown. A one-line summary is generated automatically; if the summary ' +
|
|
105
|
-
'service is unavailable the memory is NOT saved and you should retry later.',
|
|
106
|
-
inputSchema: {
|
|
107
|
-
scope: scopes.describe(scopeDescription(unbound)),
|
|
108
|
-
content: z.string().describe('Full memory text (multi-line markdown allowed)'),
|
|
109
|
-
...agentInput,
|
|
110
|
-
},
|
|
111
|
-
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
112
|
-
}, async ({ scope, content, agentName }) => {
|
|
113
|
-
if (!ctx.hasListed) {
|
|
114
|
-
return errorResult(new Error('Call list-memories first (to check for an existing memory to update instead of duplicating).'));
|
|
115
|
-
}
|
|
116
|
-
if (AGENT_SCOPES.has(scope) && !effectiveAgent(ctx, agentName)) {
|
|
117
|
-
return errorResult(new Error(`Scope '${scope}' belongs to an agent: pass agentName (the agent you are acting as), ` +
|
|
118
|
-
"or use 'profile' / 'org'."));
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
const result = await client.post('/api/chat/memories', {
|
|
122
|
-
...agentBody(ctx, agentName),
|
|
123
|
-
scope,
|
|
124
|
-
content,
|
|
125
|
-
});
|
|
126
|
-
if (result?.id)
|
|
127
|
-
ctx.seenIds.add(result.id);
|
|
128
|
-
return jsonResult(result);
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
return errorResult(err);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
// ── Write: update ──────────────────────────────────────────────────────────
|
|
135
|
-
server.registerTool('update-memory', {
|
|
136
|
-
description: "Update an existing memory's content (its summary is regenerated). You MUST call " +
|
|
137
|
-
'get-memory on this id first, so you edit its real content. If the summary service is ' +
|
|
138
|
-
'unavailable the memory is NOT updated and you should retry later.',
|
|
139
|
-
inputSchema: {
|
|
140
|
-
id: z.string().describe('Memory id to update'),
|
|
141
|
-
content: z.string().describe('New full memory text (replaces the old content)'),
|
|
142
|
-
...agentInput,
|
|
143
|
-
},
|
|
144
|
-
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
145
|
-
}, async ({ id, content, agentName }) => {
|
|
146
|
-
if (!ctx.fetchedIds.has(id)) {
|
|
147
|
-
return errorResult(new Error(`Call get-memory("${id}") first so you update its real content, not a guess.`));
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
const result = await client.put(`/api/chat/memories/${id}`, { content }, agentParams(ctx, agentName));
|
|
151
|
-
return jsonResult(result);
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
return errorResult(err);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
// ── Write: delete ──────────────────────────────────────────────────────────
|
|
158
|
-
server.registerTool('delete-memory', {
|
|
159
|
-
description: 'Delete a memory by id. Requires the id to have been seen via list-memories or get-memory.',
|
|
160
|
-
inputSchema: { id: z.string().describe('Memory id to delete'), ...agentInput },
|
|
161
|
-
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
162
|
-
}, async ({ id, agentName }) => {
|
|
163
|
-
if (!ctx.seenIds.has(id)) {
|
|
164
|
-
return errorResult(new Error(`Cannot delete ${id}: not seen in a prior list/get. Call list-memories first.`));
|
|
165
|
-
}
|
|
166
|
-
try {
|
|
167
|
-
await client.delete(`/api/chat/memories/${id}`, agentParams(ctx, agentName));
|
|
168
|
-
ctx.seenIds.delete(id);
|
|
169
|
-
ctx.fetchedIds.delete(id);
|
|
170
|
-
return jsonResult({ deleted: true, id });
|
|
171
|
-
}
|
|
172
|
-
catch (err) {
|
|
173
|
-
return errorResult(err);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
// ── Write: mark useful ─────────────────────────────────────────────────────
|
|
177
|
-
server.registerTool('mark-memory-useful', {
|
|
178
|
-
description: 'Mark a memory as useful now (bumps its recency ranking). Requires the id to have been ' +
|
|
179
|
-
'seen via list-memories or get-memory.',
|
|
180
|
-
inputSchema: { id: z.string().describe('Memory id to mark as useful'), ...agentInput },
|
|
181
|
-
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
182
|
-
}, async ({ id, agentName }) => {
|
|
183
|
-
if (!ctx.seenIds.has(id)) {
|
|
184
|
-
return errorResult(new Error(`Cannot mark ${id}: not seen in a prior list/get. Call list-memories first.`));
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
const result = await client.post(`/api/chat/memories/${id}/useful`, undefined, agentParams(ctx, agentName));
|
|
188
|
-
return jsonResult(result);
|
|
189
|
-
}
|
|
190
|
-
catch (err) {
|
|
191
|
-
return errorResult(err);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
//# sourceMappingURL=memories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memories.js","sourceRoot":"","sources":["../../src/tools/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,oFAAoF;AACpF,EAAE;AACF,wFAAwF;AACxF,6FAA6F;AAC7F,8FAA8F;AAC9F,wFAAwF;AACxF,2FAA2F;AAC3F,MAAM,YAAY,GAChB,4FAA4F,CAAC;AAE/F,MAAM,eAAe,GACnB,mFAAmF;IACnF,2DAA2D,CAAC;AAC9D,MAAM,YAAY,GAChB,wFAAwF;IACxF,0FAA0F,CAAC;AAC7F,MAAM,UAAU,GACd,yFAAyF;IACzF,8EAA8E,CAAC;AACjF,MAAM,QAAQ,GACZ,4FAA4F;IAC5F,yFAAyF;IACzF,UAAU,CAAC;AAEb,SAAS,gBAAgB,CAAC,OAAgB;IACxC,OAAO,CACL,YAAY;QACZ,eAAe;QACf,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,CAAC,OAAO;YACN,CAAC,CAAC,iFAAiF;gBACjF,aAAa;YACf,CAAC,CAAC,EAAE,CAAC;QACP,kFAAkF;QAClF,8EAA8E;QAC9E,eAAe,CAChB,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;AAQtD,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,MAAwB,EACx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AM,CAAC,IAAI,CAC9B,sBAAsB,EAAE,SAAS,EACjC,SAAS,EACT,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAC5B,CAAC;YACF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/util.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { DudamelApiError } from './http-client.js';
|
|
3
|
-
const AGENT_NAME_FIELD = z
|
|
4
|
-
.string()
|
|
5
|
-
.optional()
|
|
6
|
-
.describe('The Dudamel agent you are acting as (e.g. "dudamel-expert"). Pass it on every call when ' +
|
|
7
|
-
'you are one — it is what scopes memories, files and conversations to that agent. Omit ' +
|
|
8
|
-
'it only when you are not acting as any Dudamel agent.');
|
|
9
|
-
/**
|
|
10
|
-
* The `agentName` tool argument — offered ONLY when no agent is bound to this process.
|
|
11
|
-
*
|
|
12
|
-
* A bound process (`DUDAMEL_AGENT_NAME`, set by the runtime for its own agents) already knows
|
|
13
|
-
* whose memory it serves, so the argument would be noise at best and a contradiction at worst.
|
|
14
|
-
* An unbound one is the shared copy a marketplace tools plugin installs on a laptop: several
|
|
15
|
-
* agents talk to the same process, so each one names itself per call.
|
|
16
|
-
*/
|
|
17
|
-
export function agentNameInput(ctx) {
|
|
18
|
-
return ctx.agentName === null ? { agentName: AGENT_NAME_FIELD } : {};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The agent a call acts for: the bound one when there is one — an argument can never override
|
|
22
|
-
* it — otherwise whatever the caller named. null is the legitimate agent-less principal.
|
|
23
|
-
*/
|
|
24
|
-
export function effectiveAgent(ctx, requested) {
|
|
25
|
-
return ctx.agentName ?? (requested?.trim() || null);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The `?agent=` query param — PRESENT only when an agent is really in context.
|
|
29
|
-
*
|
|
30
|
-
* Sending `agent=` empty is not the same as omitting it: the server reads an empty name as a
|
|
31
|
-
* request it cannot honour, while an absent one is the legitimate agent-less principal. Every
|
|
32
|
-
* tool goes through here so the distinction cannot be lost at one site.
|
|
33
|
-
*/
|
|
34
|
-
export function agentParams(ctx, requested) {
|
|
35
|
-
const agent = effectiveAgent(ctx, requested);
|
|
36
|
-
return agent ? { agent } : {};
|
|
37
|
-
}
|
|
38
|
-
/** The `agentName` body field, under the same rule as {@link agentParams}. */
|
|
39
|
-
export function agentBody(ctx, requested) {
|
|
40
|
-
const agent = effectiveAgent(ctx, requested);
|
|
41
|
-
return agent ? { agentName: agent } : {};
|
|
42
|
-
}
|
|
43
|
-
export function jsonResult(data) {
|
|
44
|
-
return {
|
|
45
|
-
content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function errorResult(error) {
|
|
49
|
-
const message = error instanceof DudamelApiError
|
|
50
|
-
? `API error ${error.status}: ${error.body}`
|
|
51
|
-
: error instanceof Error
|
|
52
|
-
? error.message
|
|
53
|
-
: String(error);
|
|
54
|
-
return {
|
|
55
|
-
content: [{ type: 'text', text: message }],
|
|
56
|
-
isError: true,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,MAAM,gBA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