@geekity/cms 0.42.2 → 0.44.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/admin/pages/federation/followers.njk +1 -1
- package/admin/pages/users/activity.njk +3 -1
- package/admin/pages/users/apps.njk +55 -19
- package/admin/static/admin.css +9 -1
- package/admin/static/editor.js +22 -21
- package/dist/admin/app-activity.d.ts +8 -3
- package/dist/admin/app-activity.d.ts.map +1 -1
- package/dist/admin/app-activity.js +10 -3
- package/dist/admin/app-activity.js.map +1 -1
- package/dist/admin/connected-apps.d.ts +1 -1
- package/dist/admin/connected-apps.d.ts.map +1 -1
- package/dist/admin/connected-apps.js +99 -28
- package/dist/admin/connected-apps.js.map +1 -1
- package/dist/admin/indieauth-consent.d.ts.map +1 -1
- package/dist/admin/indieauth-consent.js +20 -2
- package/dist/admin/indieauth-consent.js.map +1 -1
- package/dist/admin/list-indent.d.ts +19 -0
- package/dist/admin/list-indent.d.ts.map +1 -0
- package/dist/admin/list-indent.js +73 -0
- package/dist/admin/list-indent.js.map +1 -0
- package/dist/admin/widget-health.d.ts.map +1 -1
- package/dist/admin/widget-health.js +2 -0
- package/dist/admin/widget-health.js.map +1 -1
- package/dist/cms/app.d.ts.map +1 -1
- package/dist/cms/app.js +3 -0
- package/dist/cms/app.js.map +1 -1
- package/dist/cms/services.d.ts.map +1 -1
- package/dist/cms/services.js +21 -2
- package/dist/cms/services.js.map +1 -1
- package/dist/{micropub/create.d.ts → content/micropub-create.d.ts} +5 -5
- package/dist/content/micropub-create.d.ts.map +1 -0
- package/dist/{micropub/create.js → content/micropub-create.js} +8 -8
- package/dist/content/micropub-create.js.map +1 -0
- package/dist/{micropub/update.d.ts → content/micropub-update.d.ts} +9 -9
- package/dist/content/micropub-update.d.ts.map +1 -0
- package/dist/{micropub/update.js → content/micropub-update.js} +8 -8
- package/dist/content/micropub-update.js.map +1 -0
- package/dist/federation/delivery.d.ts +20 -2
- package/dist/federation/delivery.d.ts.map +1 -1
- package/dist/federation/delivery.js +37 -23
- package/dist/federation/delivery.js.map +1 -1
- package/dist/federation/federation.d.ts.map +1 -1
- package/dist/federation/federation.js +2 -8
- package/dist/federation/federation.js.map +1 -1
- package/dist/federation/inbox.d.ts +5 -2
- package/dist/federation/inbox.d.ts.map +1 -1
- package/dist/federation/inbox.js +3 -3
- package/dist/federation/inbox.js.map +1 -1
- package/dist/federation/keys.d.ts +10 -0
- package/dist/federation/keys.d.ts.map +1 -1
- package/dist/federation/keys.js +13 -8
- package/dist/federation/keys.js.map +1 -1
- package/dist/federation/outbox-observer.d.ts +17 -0
- package/dist/federation/outbox-observer.d.ts.map +1 -0
- package/dist/federation/outbox-observer.js +98 -0
- package/dist/federation/outbox-observer.js.map +1 -0
- package/dist/federation/relays.d.ts.map +1 -1
- package/dist/federation/relays.js +32 -7
- package/dist/federation/relays.js.map +1 -1
- package/dist/federation/resend-job.d.ts +2 -1
- package/dist/federation/resend-job.d.ts.map +1 -1
- package/dist/federation/resend-job.js +11 -10
- package/dist/federation/resend-job.js.map +1 -1
- package/dist/federation/retry-job.d.ts +44 -0
- package/dist/federation/retry-job.d.ts.map +1 -0
- package/dist/federation/retry-job.js +102 -0
- package/dist/federation/retry-job.js.map +1 -0
- package/dist/files/data-files.d.ts +1 -0
- package/dist/files/data-files.d.ts.map +1 -1
- package/dist/files/data-files.js +6 -0
- package/dist/files/data-files.js.map +1 -1
- package/dist/indieauth/request.d.ts +4 -3
- package/dist/indieauth/request.d.ts.map +1 -1
- package/dist/indieauth/request.js +21 -3
- package/dist/indieauth/request.js.map +1 -1
- package/dist/mcp/audit.d.ts +3 -0
- package/dist/mcp/audit.d.ts.map +1 -0
- package/dist/mcp/audit.js +35 -0
- package/dist/mcp/audit.js.map +1 -0
- package/dist/mcp/authoring/create.d.ts +2 -0
- package/dist/mcp/authoring/create.d.ts.map +1 -0
- package/dist/mcp/authoring/create.js +79 -0
- package/dist/mcp/authoring/create.js.map +1 -0
- package/dist/mcp/authoring/publish.d.ts +2 -0
- package/dist/mcp/authoring/publish.d.ts.map +1 -0
- package/dist/mcp/authoring/publish.js +75 -0
- package/dist/mcp/authoring/publish.js.map +1 -0
- package/dist/mcp/authoring/shared.d.ts +23 -0
- package/dist/mcp/authoring/shared.d.ts.map +1 -0
- package/dist/mcp/authoring/shared.js +35 -0
- package/dist/mcp/authoring/shared.js.map +1 -0
- package/dist/mcp/authoring/source.d.ts +2 -0
- package/dist/mcp/authoring/source.d.ts.map +1 -0
- package/dist/mcp/authoring/source.js +48 -0
- package/dist/mcp/authoring/source.js.map +1 -0
- package/dist/mcp/authoring/update.d.ts +2 -0
- package/dist/mcp/authoring/update.d.ts.map +1 -0
- package/dist/mcp/authoring/update.js +97 -0
- package/dist/mcp/authoring/update.js.map +1 -0
- package/dist/mcp/authoring/upload.d.ts +3 -0
- package/dist/mcp/authoring/upload.d.ts.map +1 -0
- package/dist/mcp/authoring/upload.js +71 -0
- package/dist/mcp/authoring/upload.js.map +1 -0
- package/dist/mcp/call-limit.d.ts +18 -0
- package/dist/mcp/call-limit.d.ts.map +1 -0
- package/dist/mcp/call-limit.js +24 -0
- package/dist/mcp/call-limit.js.map +1 -0
- package/dist/mcp/endpoint.d.ts +7 -0
- package/dist/mcp/endpoint.d.ts.map +1 -0
- package/dist/mcp/endpoint.js +161 -0
- package/dist/mcp/endpoint.js.map +1 -0
- package/dist/mcp/inspect/inbox.d.ts +2 -0
- package/dist/mcp/inspect/inbox.d.ts.map +1 -0
- package/dist/mcp/inspect/inbox.js +123 -0
- package/dist/mcp/inspect/inbox.js.map +1 -0
- package/dist/mcp/inspect/paging.d.ts +71 -0
- package/dist/mcp/inspect/paging.d.ts.map +1 -0
- package/dist/mcp/inspect/paging.js +59 -0
- package/dist/mcp/inspect/paging.js.map +1 -0
- package/dist/mcp/inspect/post.d.ts +9 -0
- package/dist/mcp/inspect/post.d.ts.map +1 -0
- package/dist/mcp/inspect/post.js +161 -0
- package/dist/mcp/inspect/post.js.map +1 -0
- package/dist/mcp/inspect/records.d.ts +4 -0
- package/dist/mcp/inspect/records.d.ts.map +1 -0
- package/dist/mcp/inspect/records.js +213 -0
- package/dist/mcp/inspect/records.js.map +1 -0
- package/dist/mcp/inspect/remote.d.ts +85 -0
- package/dist/mcp/inspect/remote.d.ts.map +1 -0
- package/dist/mcp/inspect/remote.js +274 -0
- package/dist/mcp/inspect/remote.js.map +1 -0
- package/dist/mcp/inspect/schemas.d.ts +70 -0
- package/dist/mcp/inspect/schemas.d.ts.map +1 -0
- package/dist/mcp/inspect/schemas.js +46 -0
- package/dist/mcp/inspect/schemas.js.map +1 -0
- package/dist/mcp/inspect/status.d.ts +2 -0
- package/dist/mcp/inspect/status.d.ts.map +1 -0
- package/dist/mcp/inspect/status.js +194 -0
- package/dist/mcp/inspect/status.js.map +1 -0
- package/dist/mcp/inspect/webmentions.d.ts +2 -0
- package/dist/mcp/inspect/webmentions.d.ts.map +1 -0
- package/dist/mcp/inspect/webmentions.js +130 -0
- package/dist/mcp/inspect/webmentions.js.map +1 -0
- package/dist/mcp/plugin-tools.d.ts +4 -0
- package/dist/mcp/plugin-tools.d.ts.map +1 -0
- package/dist/mcp/plugin-tools.js +29 -0
- package/dist/mcp/plugin-tools.js.map +1 -0
- package/dist/mcp/protocol.d.ts +67 -0
- package/dist/mcp/protocol.d.ts.map +1 -0
- package/dist/mcp/protocol.js +130 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/repair/refresh.d.ts +2 -0
- package/dist/mcp/repair/refresh.d.ts.map +1 -0
- package/dist/mcp/repair/refresh.js +111 -0
- package/dist/mcp/repair/refresh.js.map +1 -0
- package/dist/mcp/repair/resend.d.ts +2 -0
- package/dist/mcp/repair/resend.d.ts.map +1 -0
- package/dist/mcp/repair/resend.js +46 -0
- package/dist/mcp/repair/resend.js.map +1 -0
- package/dist/mcp/repair/retry.d.ts +2 -0
- package/dist/mcp/repair/retry.d.ts.map +1 -0
- package/dist/mcp/repair/retry.js +91 -0
- package/dist/mcp/repair/retry.js.map +1 -0
- package/dist/mcp/repair/schemas.d.ts +30 -0
- package/dist/mcp/repair/schemas.d.ts.map +1 -0
- package/dist/mcp/repair/schemas.js +26 -0
- package/dist/mcp/repair/schemas.js.map +1 -0
- package/dist/mcp/tools.d.ts +84 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +102 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/whoami.d.ts +2 -0
- package/dist/mcp/whoami.d.ts.map +1 -0
- package/dist/mcp/whoami.js +40 -0
- package/dist/mcp/whoami.js.map +1 -0
- package/dist/micropub/endpoint.d.ts.map +1 -1
- package/dist/micropub/endpoint.js +2 -2
- package/dist/micropub/endpoint.js.map +1 -1
- package/dist/plugin.d.ts +77 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +16 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins/registry.d.ts +7 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +23 -5
- package/dist/plugins/registry.js.map +1 -1
- package/dist/store/admin-store.d.ts +3 -3
- package/dist/store/admin-store.d.ts.map +1 -1
- package/dist/store/admin-store.js.map +1 -1
- package/dist/store/deliveries.d.ts +35 -4
- package/dist/store/deliveries.d.ts.map +1 -1
- package/dist/store/deliveries.js +64 -2
- package/dist/store/deliveries.js.map +1 -1
- package/dist/store/inbox.d.ts +17 -1
- package/dist/store/inbox.d.ts.map +1 -1
- package/dist/store/inbox.js +35 -0
- package/dist/store/inbox.js.map +1 -1
- package/dist/store/rows.d.ts +5 -0
- package/dist/store/rows.d.ts.map +1 -1
- package/dist/store/rows.js.map +1 -1
- package/dist/util/json-schema.d.ts +68 -0
- package/dist/util/json-schema.d.ts.map +1 -0
- package/dist/util/json-schema.js +60 -0
- package/dist/util/json-schema.js.map +1 -0
- package/dist/util/package-version.d.ts +2 -0
- package/dist/util/package-version.d.ts.map +1 -0
- package/dist/util/package-version.js +3 -0
- package/dist/util/package-version.js.map +1 -0
- package/dist/web/env.d.ts +2 -0
- package/dist/web/env.d.ts.map +1 -1
- package/dist/web/federation-routes.d.ts +1 -0
- package/dist/web/federation-routes.d.ts.map +1 -1
- package/dist/web/federation-routes.js +10 -7
- package/dist/web/federation-routes.js.map +1 -1
- package/dist/web/indieauth-activity-log.d.ts +23 -5
- package/dist/web/indieauth-activity-log.d.ts.map +1 -1
- package/dist/web/indieauth-activity-log.js +62 -23
- package/dist/web/indieauth-activity-log.js.map +1 -1
- package/dist/web/indieauth-bearer.d.ts +8 -1
- package/dist/web/indieauth-bearer.d.ts.map +1 -1
- package/dist/web/indieauth-bearer.js +24 -18
- package/dist/web/indieauth-bearer.js.map +1 -1
- package/dist/web/indieauth-discovery.d.ts +11 -2
- package/dist/web/indieauth-discovery.d.ts.map +1 -1
- package/dist/web/indieauth-discovery.js +22 -4
- package/dist/web/indieauth-discovery.js.map +1 -1
- package/dist/web/llms.d.ts.map +1 -1
- package/dist/web/llms.js +2 -0
- package/dist/web/llms.js.map +1 -1
- package/dist/web/routes.d.ts.map +1 -1
- package/dist/web/routes.js +4 -3
- package/dist/web/routes.js.map +1 -1
- package/dist/webmention/fetch-public.d.ts +9 -0
- package/dist/webmention/fetch-public.d.ts.map +1 -1
- package/dist/webmention/fetch-public.js +6 -4
- package/dist/webmention/fetch-public.js.map +1 -1
- package/package.json +3 -1
- package/dist/micropub/create.d.ts.map +0 -1
- package/dist/micropub/create.js.map +0 -1
- package/dist/micropub/update.d.ts.map +0 -1
- package/dist/micropub/update.js.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { isRecord } from '../util/guards.js';
|
|
2
|
+
import { listedTool } from './tools.js';
|
|
3
|
+
export const PROTOCOL_VERSIONS = ['2025-11-25', '2025-06-18', '2025-03-26'];
|
|
4
|
+
export const LATEST_PROTOCOL_VERSION = PROTOCOL_VERSIONS[0];
|
|
5
|
+
/**
|
|
6
|
+
* What the server can do: list and call tools. The list changes when a
|
|
7
|
+
* plugin is enabled or disabled, but a stateless server holds no stream to
|
|
8
|
+
* announce that on, so a client finds out when it lists again.
|
|
9
|
+
*/
|
|
10
|
+
export const SERVER_CAPABILITIES = { tools: { listChanged: false } };
|
|
11
|
+
export const JSON_RPC_ERRORS = {
|
|
12
|
+
parseError: -32700,
|
|
13
|
+
invalidRequest: -32600,
|
|
14
|
+
methodNotFound: -32601,
|
|
15
|
+
invalidParams: -32602,
|
|
16
|
+
/** In the range JSON-RPC leaves to servers. */
|
|
17
|
+
insufficientScope: -32001,
|
|
18
|
+
rateLimited: -32002,
|
|
19
|
+
};
|
|
20
|
+
export function failure(id, error) {
|
|
21
|
+
return { jsonrpc: '2.0', id, error };
|
|
22
|
+
}
|
|
23
|
+
export async function reply(message, server) {
|
|
24
|
+
if (!isRecord(message) || message['jsonrpc'] !== '2.0') {
|
|
25
|
+
return malformed('The body must be one JSON-RPC 2.0 message.');
|
|
26
|
+
}
|
|
27
|
+
const { id, method } = message;
|
|
28
|
+
if (typeof method !== 'string') {
|
|
29
|
+
const isResponse = isRequestId(id) && ('result' in message || 'error' in message);
|
|
30
|
+
return isResponse ? { kind: 'accepted' } : malformed('The message names no method.');
|
|
31
|
+
}
|
|
32
|
+
if (id === undefined)
|
|
33
|
+
return { kind: 'accepted' };
|
|
34
|
+
if (!isRequestId(id))
|
|
35
|
+
return malformed('The id must be a string or a number.');
|
|
36
|
+
const params = isRecord(message['params']) ? message['params'] : {};
|
|
37
|
+
const answer = (result) => ({
|
|
38
|
+
kind: 'answer',
|
|
39
|
+
message: { jsonrpc: '2.0', id, result },
|
|
40
|
+
});
|
|
41
|
+
switch (method) {
|
|
42
|
+
case 'initialize':
|
|
43
|
+
return answer({
|
|
44
|
+
protocolVersion: negotiatedVersion(params['protocolVersion']),
|
|
45
|
+
capabilities: SERVER_CAPABILITIES,
|
|
46
|
+
serverInfo: server.info,
|
|
47
|
+
});
|
|
48
|
+
case 'ping':
|
|
49
|
+
return answer({});
|
|
50
|
+
case 'tools/list':
|
|
51
|
+
return answer({ tools: server.registry.list().map(listedTool) });
|
|
52
|
+
case 'tools/call':
|
|
53
|
+
return await callTool(id, params, server);
|
|
54
|
+
default:
|
|
55
|
+
return {
|
|
56
|
+
kind: 'answer',
|
|
57
|
+
message: failure(id, {
|
|
58
|
+
code: JSON_RPC_ERRORS.methodNotFound,
|
|
59
|
+
message: `This server does not offer ${method}.`,
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function callTool(id, params, server) {
|
|
65
|
+
const name = params['name'];
|
|
66
|
+
const invalid = (text) => ({
|
|
67
|
+
kind: 'answer',
|
|
68
|
+
message: failure(id, { code: JSON_RPC_ERRORS.invalidParams, message: text }),
|
|
69
|
+
});
|
|
70
|
+
if (typeof name !== 'string')
|
|
71
|
+
return invalid('tools/call needs the name of a tool.');
|
|
72
|
+
const result = await server.registry.call(name, params['arguments'], server.call);
|
|
73
|
+
switch (result.kind) {
|
|
74
|
+
case 'unknown-tool':
|
|
75
|
+
return invalid(`There is no tool named ${name}.`);
|
|
76
|
+
case 'insufficient-scope':
|
|
77
|
+
return {
|
|
78
|
+
kind: 'insufficient-scope',
|
|
79
|
+
scope: result.scope,
|
|
80
|
+
message: failure(id, {
|
|
81
|
+
code: JSON_RPC_ERRORS.insufficientScope,
|
|
82
|
+
message: `${name} needs the ${result.scope} scope, which this connection was not granted. Sign in again and approve it.`,
|
|
83
|
+
data: { scope: result.scope },
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
case 'rate-limited':
|
|
87
|
+
return {
|
|
88
|
+
kind: 'answer',
|
|
89
|
+
message: failure(id, {
|
|
90
|
+
code: JSON_RPC_ERRORS.rateLimited,
|
|
91
|
+
message: `Too many tool calls through this connection. Try again in ${String(result.retryAfter)} seconds.`,
|
|
92
|
+
data: { retryAfter: result.retryAfter },
|
|
93
|
+
}),
|
|
94
|
+
};
|
|
95
|
+
case 'ran':
|
|
96
|
+
return {
|
|
97
|
+
kind: 'answer',
|
|
98
|
+
message: { jsonrpc: '2.0', id, result: toolResult(result.outcome) },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** MCP asks that structured content also be sent as text, for clients that read only text. */
|
|
103
|
+
function toolResult(outcome) {
|
|
104
|
+
if (!outcome.ok)
|
|
105
|
+
return { content: [{ type: 'text', text: outcome.message }], isError: true };
|
|
106
|
+
return {
|
|
107
|
+
content: [
|
|
108
|
+
{ type: 'text', text: outcome.summary },
|
|
109
|
+
{ type: 'text', text: JSON.stringify(outcome.structured) },
|
|
110
|
+
],
|
|
111
|
+
structuredContent: outcome.structured,
|
|
112
|
+
isError: false,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function negotiatedVersion(asked) {
|
|
116
|
+
return isSupportedVersion(asked) ? asked : LATEST_PROTOCOL_VERSION;
|
|
117
|
+
}
|
|
118
|
+
export function isSupportedVersion(version) {
|
|
119
|
+
return PROTOCOL_VERSIONS.includes(version);
|
|
120
|
+
}
|
|
121
|
+
function malformed(text) {
|
|
122
|
+
return {
|
|
123
|
+
kind: 'malformed',
|
|
124
|
+
message: failure(null, { code: JSON_RPC_ERRORS.invalidRequest, message: text }),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function isRequestId(value) {
|
|
128
|
+
return typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value));
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/mcp/protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAIrF,MAAM,CAAC,MAAM,uB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K,CAAC,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/mcp/repair/refresh.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,YAAY,+BAyGvB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { isActor } from '@fedify/vocab';
|
|
2
|
+
import { followerFrom } from '../../federation/inbox.js';
|
|
3
|
+
import { addFollower } from '../../federation/records.js';
|
|
4
|
+
import { siteLoaders } from '../../federation/site-loaders.js';
|
|
5
|
+
import { messageOf } from '../../util/errors.js';
|
|
6
|
+
import { nullable } from '../../util/json-schema.js';
|
|
7
|
+
import { federationContextData } from '../../web/federation-routes.js';
|
|
8
|
+
import { webUrl } from '../../webmention/fetch-public.js';
|
|
9
|
+
import { defineTool } from '../tools.js';
|
|
10
|
+
import { REPAIR } from './schemas.js';
|
|
11
|
+
const INBOXES = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: { inbox: { type: 'string' }, sharedInbox: nullable({ type: 'string' }) },
|
|
14
|
+
required: ['inbox', 'sharedInbox'],
|
|
15
|
+
};
|
|
16
|
+
export const refreshActor = defineTool({
|
|
17
|
+
name: 'refresh_actor',
|
|
18
|
+
title: 'Refresh a remote actor',
|
|
19
|
+
description: 'Fetch a remote actor’s document again, signed as the site, and rewrite every follower record of that actor with the inbox, shared inbox, name and avatar it publishes now, keeping when it followed. Updates the stored profile of an actor that is not a follower too. Use it when deliveries fail because an actor moved its inbox. Returns what the actor publishes and each follower record’s inboxes before the refresh.',
|
|
20
|
+
scope: 'repair',
|
|
21
|
+
annotations: REPAIR,
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
actor: { type: 'string', description: 'The actor’s id, an http or https URL.' },
|
|
26
|
+
},
|
|
27
|
+
required: ['actor'],
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
},
|
|
30
|
+
outputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
actorId: { type: 'string' },
|
|
34
|
+
handle: nullable({ type: 'string' }),
|
|
35
|
+
name: nullable({ type: 'string' }),
|
|
36
|
+
inbox: { type: 'string', description: 'The inbox the actor publishes now.' },
|
|
37
|
+
sharedInbox: nullable({ type: 'string', description: 'Its shared inbox now, if any.' }),
|
|
38
|
+
followers: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
description: 'Each follower record rewritten: the local user followed, and the inboxes it held.',
|
|
41
|
+
items: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: { username: { type: 'string' }, before: INBOXES },
|
|
44
|
+
required: ['username', 'before'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
profileUpdated: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
description: 'Whether a stored profile of the actor, kept for one who is not a follower, was rewritten.',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['actorId', 'handle', 'name', 'inbox', 'sharedInbox', 'followers', 'profileUpdated'],
|
|
53
|
+
},
|
|
54
|
+
run: async (args, { site, signal }) => {
|
|
55
|
+
const { admin, config } = site;
|
|
56
|
+
const actorId = args.actor;
|
|
57
|
+
if (webUrl(actorId) === undefined) {
|
|
58
|
+
return { ok: false, message: 'actor must be an http or https URL.' };
|
|
59
|
+
}
|
|
60
|
+
const context = site.federation.createContext(new Request(config.baseUrl), federationContextData(site));
|
|
61
|
+
const loaders = await siteLoaders(context, signal);
|
|
62
|
+
let fetched;
|
|
63
|
+
try {
|
|
64
|
+
const found = await context.lookupObject(actorId, loaders);
|
|
65
|
+
fetched = isActor(found) ? await followerFrom(found, loaders) : undefined;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return { ok: false, message: `Could not read the actor at ${actorId}: ${messageOf(error)}` };
|
|
69
|
+
}
|
|
70
|
+
if (fetched === undefined) {
|
|
71
|
+
return { ok: false, message: `${actorId} did not answer with an actor that has an inbox.` };
|
|
72
|
+
}
|
|
73
|
+
const refetchedUnderStoredId = { ...fetched, actorId };
|
|
74
|
+
const held = admin.listFollowers().filter((follower) => follower.actorId === actorId);
|
|
75
|
+
const records = { admin, contentDir: config.contentDir, dataDir: config.dataDir };
|
|
76
|
+
for (const follower of held) {
|
|
77
|
+
await addFollower(records, follower.username, refetchedUnderStoredId);
|
|
78
|
+
}
|
|
79
|
+
const profileUpdated = admin.getActorProfile(actorId) !== undefined;
|
|
80
|
+
if (profileUpdated) {
|
|
81
|
+
const { handle, name, iconUrl, url } = refetchedUnderStoredId;
|
|
82
|
+
admin.putActorProfile({
|
|
83
|
+
actorId,
|
|
84
|
+
handle,
|
|
85
|
+
name,
|
|
86
|
+
iconUrl,
|
|
87
|
+
url,
|
|
88
|
+
fetchedAt: config.now().toISOString(),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const moved = held.filter((follower) => follower.inboxId !== refetchedUnderStoredId.inboxId ||
|
|
92
|
+
follower.sharedInboxId !== refetchedUnderStoredId.sharedInboxId).length;
|
|
93
|
+
return {
|
|
94
|
+
ok: true,
|
|
95
|
+
summary: `${actorId} publishes inbox ${refetchedUnderStoredId.sharedInboxId ?? refetchedUnderStoredId.inboxId}; rewrote ${String(held.length)} follower ${held.length === 1 ? 'record' : 'records'}, ${String(moved)} of them with a new inbox.`,
|
|
96
|
+
structured: {
|
|
97
|
+
actorId,
|
|
98
|
+
handle: refetchedUnderStoredId.handle,
|
|
99
|
+
name: refetchedUnderStoredId.name,
|
|
100
|
+
inbox: refetchedUnderStoredId.inboxId,
|
|
101
|
+
sharedInbox: refetchedUnderStoredId.sharedInboxId,
|
|
102
|
+
followers: held.map((follower) => ({
|
|
103
|
+
username: follower.username,
|
|
104
|
+
before: { inbox: follower.inboxId, sharedInbox: follower.sharedInboxId },
|
|
105
|
+
})),
|
|
106
|
+
profileUpdated,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
},
|
|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C,QAAQ,EAAE,QAAQ,CAAC,QAAQ;oBAC3B,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,aAAa,EAAE;iBACzE,CAAC,CAAC;gBACH,cAAc;aACf;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resend.d.ts","sourceRoot":"","sources":["../../../src/mcp/repair/resend.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,+BA0CrB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RESEND_JOB } from '../../federation/resend-job.js';
|
|
2
|
+
import { defineTool, isRefused } from '../tools.js';
|
|
3
|
+
import { findPost, POST_INPUT } from '../inspect/post.js';
|
|
4
|
+
import { JOB, QUEUED, queuedJob, REPAIR } from './schemas.js';
|
|
5
|
+
export const resendPost = defineTool({
|
|
6
|
+
name: 'resend_post',
|
|
7
|
+
title: 'Resend a post',
|
|
8
|
+
description: 'Queue a resend of one post to every follower and accepted relay, as the Resend button on the admin federation screen does. The post goes out as it reads now: an Update when followers hold it, a Create when it was never announced, a Delete when it is a draft or in the trash. Returns the queued job; delivery outcomes appear in post_federation as the queue settles them.',
|
|
9
|
+
scope: 'repair',
|
|
10
|
+
annotations: REPAIR,
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
post: POST_INPUT,
|
|
15
|
+
webmentions: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
description: 'Whether to send the post’s webmentions again too. true unless given.',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ['post'],
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
},
|
|
23
|
+
outputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: { slug: { type: 'string' }, queued: QUEUED, job: JOB },
|
|
26
|
+
required: ['slug', 'queued', 'job'],
|
|
27
|
+
},
|
|
28
|
+
run: async (args, { site }) => {
|
|
29
|
+
const document = findPost(site, args.post);
|
|
30
|
+
if (isRefused(document))
|
|
31
|
+
return document;
|
|
32
|
+
const { slug } = document;
|
|
33
|
+
const outcome = queuedJob(await site.jobs.enqueueUnlessActive(RESEND_JOB, {
|
|
34
|
+
slugs: [slug],
|
|
35
|
+
webmentions: args.webmentions ?? true,
|
|
36
|
+
}));
|
|
37
|
+
return {
|
|
38
|
+
ok: true,
|
|
39
|
+
summary: outcome.queued
|
|
40
|
+
? `Queued a resend of ${slug} as job ${outcome.job.id}.`
|
|
41
|
+
: `A resend is already ${outcome.job.state} as job ${outcome.job.id}; nothing new was queued.`,
|
|
42
|
+
structured: { slug, ...outcome },
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=resend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resend.js","sourceRoot":"","sources":["../../../src/mcp/repair/resend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;IACnC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,eAAe;IACtB,WAAW,EACT,mXAAmX;IACrX,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,sEAAsE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"AAOA,eAAO,MAAM,eAAe,+BAoF1B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { failedRetries, RETRY_DELIVERIES_JOB } from '../../federation/retry-job.js';
|
|
2
|
+
import { nullable } from '../../util/json-schema.js';
|
|
3
|
+
import { defineTool, isRefused } from '../tools.js';
|
|
4
|
+
import { findPost, POST_INPUT } from '../inspect/post.js';
|
|
5
|
+
import { JOB, QUEUED, queuedJob, REPAIR } from './schemas.js';
|
|
6
|
+
export const retryDeliveries = defineTool({
|
|
7
|
+
name: 'retry_deliveries',
|
|
8
|
+
title: 'Retry failed deliveries',
|
|
9
|
+
description: 'Find the recipients whose newest delivery of a post failed, for one post, for one inbox, or both, and queue a job that sends each post again, as it reads now, to those recipients alone, at the inbox each uses now. A recipient whose Create failed is sent the Create; the rest are sent an Update. Posts go one at a time with a pause between. Returns what will be retried and the queued job; outcomes appear in post_federation as the queue settles them.',
|
|
10
|
+
scope: 'repair',
|
|
11
|
+
annotations: REPAIR,
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
post: { ...POST_INPUT, description: `${POST_INPUT.description} Give this, inbox, or both.` },
|
|
16
|
+
inbox: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Only deliveries that failed at this inbox, often a shared one.',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
},
|
|
23
|
+
outputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
retries: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
description: 'Each post to send again and the recipients it failed for.',
|
|
29
|
+
items: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
slug: { type: 'string' },
|
|
33
|
+
recipients: {
|
|
34
|
+
type: 'array',
|
|
35
|
+
items: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
actorId: { type: 'string' },
|
|
39
|
+
inboxId: { type: 'string', description: 'The inbox the failed delivery used.' },
|
|
40
|
+
error: nullable({ type: 'string' }),
|
|
41
|
+
missedAnnouncement: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
description: 'True when the newest Create this recipient was sent failed, so the retry sends the Create rather than an Update.',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ['actorId', 'inboxId', 'error', 'missedAnnouncement'],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ['slug', 'recipients'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
queued: QUEUED,
|
|
54
|
+
job: nullable({ ...JOB, description: 'The job, or null when there was nothing to retry.' }),
|
|
55
|
+
},
|
|
56
|
+
required: ['retries', 'queued', 'job'],
|
|
57
|
+
},
|
|
58
|
+
run: async (args, { site }) => {
|
|
59
|
+
let filter;
|
|
60
|
+
if (args.post !== undefined) {
|
|
61
|
+
const document = findPost(site, args.post);
|
|
62
|
+
if (isRefused(document))
|
|
63
|
+
return document;
|
|
64
|
+
filter = { slug: document.slug, inbox: args.inbox ?? null };
|
|
65
|
+
}
|
|
66
|
+
else if (args.inbox !== undefined) {
|
|
67
|
+
filter = { slug: null, inbox: args.inbox };
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return { ok: false, message: 'Name a post, an inbox, or both.' };
|
|
71
|
+
}
|
|
72
|
+
const retries = failedRetries(site, filter);
|
|
73
|
+
if (retries.length === 0) {
|
|
74
|
+
return {
|
|
75
|
+
ok: true,
|
|
76
|
+
summary: 'No delivery that matches failed, so nothing was queued.',
|
|
77
|
+
structured: { retries, queued: false, job: null },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const outcome = queuedJob(await site.jobs.enqueueUnlessActive(RETRY_DELIVERIES_JOB, filter));
|
|
81
|
+
const recipients = retries.reduce((sum, retry) => sum + retry.recipients.length, 0);
|
|
82
|
+
return {
|
|
83
|
+
ok: true,
|
|
84
|
+
summary: outcome.queued
|
|
85
|
+
? `Queued job ${outcome.job.id} to retry ${String(recipients)} failed ${recipients === 1 ? 'delivery' : 'deliveries'} across ${String(retries.length)} ${retries.length === 1 ? 'post' : 'posts'}.`
|
|
86
|
+
: `A retry is already ${outcome.job.state} as job ${outcome.job.id}; nothing new was queued. Call again once it finishes.`,
|
|
87
|
+
structured: { retries, ...outcome },
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/mcp/repair/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACxC,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,yBAAyB;IAChC,WAAW,EACT,ocAAoc;IACtc,KAAK,EAAE,QAAQ;IACf,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,WAAW,6BAA6B,EAAE;YAC5F,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gEAAgE;aAC9E;SACF;QACD,oBAAoB,EAAE,KAAK;KAC5B;IACD,YAAY,EAAE;QACZ,IAAI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,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG;gBACnM,CAAC,CAAC,sBAAsB,OAAO,CAAC,GAAG,CAAC,KAAK,WAAW,OAAO,CAAC,GAAG,CAAC,EAAE,wDAAwD;YAC5H,UAAU,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;SACpC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { JOB_STATES } from '../../jobs/types.ts';
|
|
2
|
+
import type { Enqueued } from '../../jobs/types.ts';
|
|
3
|
+
import type { McpToolAnnotations } from '../../plugin.ts';
|
|
4
|
+
export declare const REPAIR: McpToolAnnotations;
|
|
5
|
+
export declare const JOB: {
|
|
6
|
+
readonly type: 'object';
|
|
7
|
+
readonly description: 'The job on the jobs queue that does the work.';
|
|
8
|
+
readonly properties: {
|
|
9
|
+
readonly id: {
|
|
10
|
+
readonly type: 'string';
|
|
11
|
+
};
|
|
12
|
+
readonly state: {
|
|
13
|
+
readonly type: 'string';
|
|
14
|
+
readonly enum: readonly ["queued", "running", "finished", "failed", "interrupted"];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly required: readonly ['id', 'state'];
|
|
18
|
+
};
|
|
19
|
+
export declare const QUEUED: {
|
|
20
|
+
readonly type: 'boolean';
|
|
21
|
+
readonly description: 'Whether this call queued the job. false means a job of the same kind was already waiting or running, and job names it.';
|
|
22
|
+
};
|
|
23
|
+
export declare function queuedJob(enqueued: Enqueued): {
|
|
24
|
+
queued: boolean;
|
|
25
|
+
job: {
|
|
26
|
+
id: string;
|
|
27
|
+
state: (typeof JOB_STATES)[number];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/repair/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,eAAO,MAAM,MAAM,EAAE,kBAKpB,CAAC;AAEF,eAAO,MAAM,GAAG;aACd,IAAI,EAAE,QAAQ;aACd,WAAW,EAAE,+CAA+C;aAC5D,UAAU;iBACR,EAAE;qBAAI,IAAI,EAAE,QAAQ;;iBACpB,KAAK;qBAAI,IAAI,EAAE,QAAQ;qBAAE,IAAI;;;aAE/B,QAAQ,YAAG,IAAI,EAAE,OAAO;CAChB,CAAC;AAEX,eAAO,MAAM,MAAM;aACjB,IAAI,EAAE,SAAS;aACf,WAAW,EACT,wHAAwH;CAClH,CAAC;AAEX,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;CACzD,CAIA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JOB_STATES } from '../../jobs/types.js';
|
|
2
|
+
export const REPAIR = {
|
|
3
|
+
readOnlyHint: false,
|
|
4
|
+
destructiveHint: false,
|
|
5
|
+
idempotentHint: true,
|
|
6
|
+
openWorldHint: true,
|
|
7
|
+
};
|
|
8
|
+
export const JOB = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
description: 'The job on the jobs queue that does the work.',
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string' },
|
|
13
|
+
state: { type: 'string', enum: JOB_STATES },
|
|
14
|
+
},
|
|
15
|
+
required: ['id', 'state'],
|
|
16
|
+
};
|
|
17
|
+
export const QUEUED = {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
description: 'Whether this call queued the job. false means a job of the same kind was already waiting or running, and job names it.',
|
|
20
|
+
};
|
|
21
|
+
export function queuedJob(enqueued) {
|
|
22
|
+
return enqueued.queued
|
|
23
|
+
? { queued: true, job: { id: enqueued.id, state: 'queued' } }
|
|
24
|
+
: { queued: false, job: { id: enqueued.active.id, state: enqueued.active.state } };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/mcp/repair/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,MAAM,CAAC,MAAM,MAAM,GAAuB;IACxC,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,+CAA+C;IAC5D,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;KAC5C;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;CACjB,CAAC;AAEX,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,SAAS;IACf,WAAW,EACT,wHAAwH;CAClH,CAAC;AAEX,MAAM,UAAU,SAAS,CAAC,QAAkB;IAI1C,OAAO,QAAQ,CAAC,MAAM;QACpB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC7D,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { McpScope, McpToolAnnotations, McpToolOutcome } from '../plugin.ts';
|
|
2
|
+
import type { StoredToken } from '../indieauth/tokens.ts';
|
|
3
|
+
import type { User } from '../site/users.ts';
|
|
4
|
+
import type { GeekityEnv } from '../web/env.ts';
|
|
5
|
+
import type { CallLimit } from './call-limit.ts';
|
|
6
|
+
import type { FromSchema, ObjectSchema } from '../util/json-schema.ts';
|
|
7
|
+
export type ToolSite = Readonly<Pick<GeekityEnv['Variables'], 'admin' | 'store' | 'config' | 'settings' | 'jobs' | 'conversation' | 'replyContexts' | 'actorProfiles' | 'siteAtRequestStart' | 'federation' | 'siteRecords' | 'announce' | 'learnHandles'>>;
|
|
8
|
+
export interface ToolCall {
|
|
9
|
+
readonly user: User;
|
|
10
|
+
readonly token: StoredToken;
|
|
11
|
+
readonly signal: AbortSignal;
|
|
12
|
+
readonly site: ToolSite;
|
|
13
|
+
}
|
|
14
|
+
export interface ScopeShortfall {
|
|
15
|
+
readonly needsScope: McpScope;
|
|
16
|
+
}
|
|
17
|
+
type ToolAnswer<O> = McpToolOutcome<O> | ScopeShortfall;
|
|
18
|
+
export type Refused = Extract<McpToolOutcome<never>, {
|
|
19
|
+
ok: false;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function refused(message: string): Refused;
|
|
22
|
+
export declare function isRefused<T extends object>(found: T | Refused): found is Refused;
|
|
23
|
+
interface ToolSpec<I extends ObjectSchema, O extends ObjectSchema> {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly title: string;
|
|
26
|
+
readonly description: string;
|
|
27
|
+
readonly scope: McpScope;
|
|
28
|
+
readonly annotations: McpToolAnnotations;
|
|
29
|
+
readonly inputSchema: I;
|
|
30
|
+
readonly outputSchema: O;
|
|
31
|
+
readonly run: (args: FromSchema<I>, call: ToolCall) => Promise<ToolAnswer<FromSchema<O>>>;
|
|
32
|
+
}
|
|
33
|
+
export interface McpTool extends Omit<ToolSpec<ObjectSchema, ObjectSchema>, 'run'> {
|
|
34
|
+
readonly run: (args: unknown, call: ToolCall) => Promise<ToolAnswer<unknown>>;
|
|
35
|
+
}
|
|
36
|
+
export declare function callingClient(token: StoredToken): {
|
|
37
|
+
readonly client: string;
|
|
38
|
+
readonly clientName: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
export declare function defineTool<const I extends ObjectSchema, const O extends ObjectSchema>(spec: ToolSpec<I, O>): McpTool;
|
|
41
|
+
export declare function listedTool(tool: McpTool): {
|
|
42
|
+
name: string;
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputSchema: ObjectSchema;
|
|
46
|
+
outputSchema: ObjectSchema;
|
|
47
|
+
annotations: McpToolAnnotations;
|
|
48
|
+
};
|
|
49
|
+
export type ToolCallResult = {
|
|
50
|
+
readonly kind: 'unknown-tool';
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: 'insufficient-scope';
|
|
53
|
+
readonly scope: McpScope;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: 'rate-limited';
|
|
56
|
+
readonly retryAfter: number;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: 'ran';
|
|
59
|
+
readonly outcome: McpToolOutcome<unknown>;
|
|
60
|
+
};
|
|
61
|
+
export interface ToolCallRecord {
|
|
62
|
+
readonly tool: string;
|
|
63
|
+
readonly args: unknown;
|
|
64
|
+
readonly call: ToolCall;
|
|
65
|
+
readonly outcome: ToolCallResult | {
|
|
66
|
+
readonly kind: 'crashed';
|
|
67
|
+
readonly reason: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface ToolGuards {
|
|
71
|
+
readonly limit: CallLimit;
|
|
72
|
+
readonly record: (record: ToolCallRecord) => void;
|
|
73
|
+
}
|
|
74
|
+
export interface ToolRegistry {
|
|
75
|
+
list(): readonly McpTool[];
|
|
76
|
+
call(name: string, args: unknown, call: ToolCall): Promise<ToolCallResult>;
|
|
77
|
+
}
|
|
78
|
+
export interface RegisteredTools {
|
|
79
|
+
readonly core: readonly McpTool[];
|
|
80
|
+
readonly plugin?: readonly McpTool[];
|
|
81
|
+
}
|
|
82
|
+
export declare function createToolRegistry({ core, plugin }: RegisteredTools, guards: ToolGuards): ToolRegistry;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAC7B,IAAI,CACF,UAAU,CAAC,WAAW,CAAC,EACrB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,UAAU,GACV,MAAM,GACN,cAAc,GACd,eAAe,GACf,eAAe,GACf,oBAAoB,GACpB,YAAY,GACZ,aAAa,GACb,UAAU,GACV,cAAc,CACjB,CACF,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CA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