@geekity/cms 0.43.0 → 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/users/activity.njk +3 -1
- package/admin/pages/users/apps.njk +55 -19
- package/admin/static/admin.css +9 -1
- 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/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 +2 -0
- 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 +23 -20
- 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/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 +23 -0
- package/dist/store/deliveries.d.ts.map +1 -1
- package/dist/store/deliveries.js +56 -1
- 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 +1 -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 { COMMENT_KINDS, COMMENT_STATUSES } from '../../store/comments.js';
|
|
2
|
+
import { WEBMENTION_SEND_STATUSES } from '../../store/webmentions.js';
|
|
3
|
+
import { nullable } from '../../util/json-schema.js';
|
|
4
|
+
import { defineTool, isRefused } from '../tools.js';
|
|
5
|
+
import { instants, PAGE_INPUT, PAGE_OUTPUT, PAGE_REQUIRED, pageAt, pageFields, pageOfList, TIME_INPUT, within, } from './paging.js';
|
|
6
|
+
import { findPost, POST_INPUT } from './post.js';
|
|
7
|
+
import { READ_ONLY } from './schemas.js';
|
|
8
|
+
const STATUSES = { sent: WEBMENTION_SEND_STATUSES, received: COMMENT_STATUSES };
|
|
9
|
+
export const webmentions = defineTool({
|
|
10
|
+
name: 'webmentions',
|
|
11
|
+
title: 'Webmentions of a post',
|
|
12
|
+
description: 'For one post, newest first: the webmentions it sent to the pages it links to, with each endpoint, outcome and error; or the webmentions it received, with their moderation status.',
|
|
13
|
+
scope: 'inspect',
|
|
14
|
+
annotations: READ_ONLY,
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
post: POST_INPUT,
|
|
19
|
+
direction: { type: 'string', enum: ['sent', 'received'] },
|
|
20
|
+
status: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: `Only this status: ${WEBMENTION_SEND_STATUSES.join(', ')} for sent; ${COMMENT_STATUSES.join(', ')} for received.`,
|
|
23
|
+
},
|
|
24
|
+
...TIME_INPUT,
|
|
25
|
+
...PAGE_INPUT,
|
|
26
|
+
},
|
|
27
|
+
required: ['post', 'direction'],
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
},
|
|
30
|
+
outputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
...PAGE_OUTPUT,
|
|
34
|
+
sent: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
description: 'With direction sent.',
|
|
37
|
+
items: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
source: { type: 'string' },
|
|
41
|
+
target: { type: 'string' },
|
|
42
|
+
endpoint: nullable({
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'null when the target advertised none.',
|
|
45
|
+
}),
|
|
46
|
+
status: { type: 'string', enum: WEBMENTION_SEND_STATUSES },
|
|
47
|
+
error: nullable({ type: 'string' }),
|
|
48
|
+
attemptedAt: { type: 'string' },
|
|
49
|
+
},
|
|
50
|
+
required: ['source', 'target', 'endpoint', 'status', 'error', 'attemptedAt'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
received: {
|
|
54
|
+
type: 'array',
|
|
55
|
+
description: 'With direction received.',
|
|
56
|
+
items: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
id: { type: 'string' },
|
|
60
|
+
source: nullable({ type: 'string', description: 'The page that mentioned the post.' }),
|
|
61
|
+
kind: { type: 'string', enum: COMMENT_KINDS },
|
|
62
|
+
status: { type: 'string', enum: COMMENT_STATUSES },
|
|
63
|
+
authorName: { type: 'string' },
|
|
64
|
+
authorUrl: nullable({ type: 'string' }),
|
|
65
|
+
submitted: { type: 'string' },
|
|
66
|
+
},
|
|
67
|
+
required: ['id', 'source', 'kind', 'status', 'authorName', 'authorUrl', 'submitted'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
required: [...PAGE_REQUIRED],
|
|
72
|
+
},
|
|
73
|
+
run: (args, { site }) => {
|
|
74
|
+
const range = instants(args);
|
|
75
|
+
if (!range.ok)
|
|
76
|
+
return Promise.resolve(range);
|
|
77
|
+
const allowed = STATUSES[args.direction];
|
|
78
|
+
if (args.status !== undefined && !allowed.includes(args.status)) {
|
|
79
|
+
return Promise.resolve({
|
|
80
|
+
ok: false,
|
|
81
|
+
message: `status must be one of ${allowed.join(', ')} for ${args.direction} webmentions.`,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const document = findPost(site, args.post);
|
|
85
|
+
if (isRefused(document))
|
|
86
|
+
return Promise.resolve(document);
|
|
87
|
+
const at = pageAt(args);
|
|
88
|
+
const wanted = (status, time) => (args.status === undefined || status === args.status) && within(time, range);
|
|
89
|
+
if (args.direction === 'sent') {
|
|
90
|
+
const page = pageOfList(site.admin
|
|
91
|
+
.listSentWebmentions(document.slug)
|
|
92
|
+
.filter((sent) => wanted(sent.status, sent.attemptedAt))
|
|
93
|
+
.toSorted((a, b) => b.attemptedAt.localeCompare(a.attemptedAt))
|
|
94
|
+
.map(({ source, target, endpoint, status, error, attemptedAt }) => ({
|
|
95
|
+
source,
|
|
96
|
+
target,
|
|
97
|
+
endpoint,
|
|
98
|
+
status,
|
|
99
|
+
error,
|
|
100
|
+
attemptedAt,
|
|
101
|
+
})), at);
|
|
102
|
+
const failed = page.items.filter((sent) => sent.status === 'failed').length;
|
|
103
|
+
return Promise.resolve({
|
|
104
|
+
ok: true,
|
|
105
|
+
summary: `${document.slug} sent ${String(page.total)} matching ${page.total === 1 ? 'webmention' : 'webmentions'}; ${String(failed)} failed on this page.`,
|
|
106
|
+
structured: { ...pageFields(page, at), sent: page.items },
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const page = pageOfList(site.admin
|
|
110
|
+
.listCommentsFor(document.slug)
|
|
111
|
+
.filter((comment) => comment.source === 'webmention')
|
|
112
|
+
.filter((comment) => wanted(comment.status, comment.submitted))
|
|
113
|
+
.toSorted((a, b) => b.submitted.localeCompare(a.submitted))
|
|
114
|
+
.map((comment) => ({
|
|
115
|
+
id: comment.id,
|
|
116
|
+
source: comment.url,
|
|
117
|
+
kind: comment.kind,
|
|
118
|
+
status: comment.status,
|
|
119
|
+
authorName: comment.author.name,
|
|
120
|
+
authorUrl: comment.author.url,
|
|
121
|
+
submitted: comment.submitted,
|
|
122
|
+
})), at);
|
|
123
|
+
return Promise.resolve({
|
|
124
|
+
ok: true,
|
|
125
|
+
summary: `${document.slug} received ${String(page.total)} matching ${page.total === 1 ? 'webmention' : 'webmentions'}.`,
|
|
126
|
+
structured: { ...pageFields(page, at), received: page.items },
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=webmentions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webmentions.js","sourceRoot":"","sources":["../../../src/mcp/inspect/webmentions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,aAAa,EACb,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,aAAa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.js';
|
|
2
|
+
import { callingClient, defineTool } from './tools.js';
|
|
3
|
+
export function activePluginTools(vars) {
|
|
4
|
+
const declared = [...vars.activePlugins].flatMap((name) => vars.plugins.find(name)?.tools ?? []);
|
|
5
|
+
if (declared.length === 0)
|
|
6
|
+
return [];
|
|
7
|
+
const site = pluginSite({ admin: vars.admin, config: vars.config });
|
|
8
|
+
const timezone = vars.siteAtRequestStart.timezone;
|
|
9
|
+
return declared.map(({ name, tool }) => defineTool({
|
|
10
|
+
name,
|
|
11
|
+
title: tool.title,
|
|
12
|
+
description: tool.description,
|
|
13
|
+
scope: tool.scope,
|
|
14
|
+
annotations: tool.annotations,
|
|
15
|
+
inputSchema: tool.inputSchema,
|
|
16
|
+
outputSchema: tool.outputSchema,
|
|
17
|
+
run: (args, { user, token, signal }) => tool.run(args, {
|
|
18
|
+
user: {
|
|
19
|
+
username: user.username,
|
|
20
|
+
...(user.actorId === undefined ? {} : { actorId: user.actorId }),
|
|
21
|
+
},
|
|
22
|
+
...callingClient(token),
|
|
23
|
+
signal,
|
|
24
|
+
site,
|
|
25
|
+
timezone,
|
|
26
|
+
}),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=plugin-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-tools.js","sourceRoot":"","sources":["../../src/mcp/plugin-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvD,MAAM,UAAU,iBAAiB,CAAC,IAAuC;IACvE,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IACjG,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC;IAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CACrC,UAAU,CAAC;QACT,IAAI;QACJ,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CACrC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;YACb,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;aACjE;YACD,GAAG,aAAa,CAAC,KAAK,CAAC;YACvB,MAAM;YACN,IAAI;YACJ,QAAQ;SACT,CAAC;KACL,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { McpScope } from '../plugin.ts';
|
|
2
|
+
import type { ToolCall, ToolRegistry } from './tools.ts';
|
|
3
|
+
export declare const PROTOCOL_VERSIONS: readonly ['2025-11-25', '2025-06-18', '2025-03-26'];
|
|
4
|
+
export type ProtocolVersion = (typeof PROTOCOL_VERSIONS)[number];
|
|
5
|
+
export declare const LATEST_PROTOCOL_VERSION: "2025-11-25";
|
|
6
|
+
/**
|
|
7
|
+
* What the server can do: list and call tools. The list changes when a
|
|
8
|
+
* plugin is enabled or disabled, but a stateless server holds no stream to
|
|
9
|
+
* announce that on, so a client finds out when it lists again.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SERVER_CAPABILITIES: {
|
|
12
|
+
readonly tools: {
|
|
13
|
+
readonly listChanged: false;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const JSON_RPC_ERRORS: {
|
|
17
|
+
readonly parseError: -32700;
|
|
18
|
+
readonly invalidRequest: -32600;
|
|
19
|
+
readonly methodNotFound: -32601;
|
|
20
|
+
readonly invalidParams: -32602;
|
|
21
|
+
/** In the range JSON-RPC leaves to servers. */
|
|
22
|
+
readonly insufficientScope: -32001;
|
|
23
|
+
readonly rateLimited: -32002;
|
|
24
|
+
};
|
|
25
|
+
type RequestId = string | number;
|
|
26
|
+
interface JsonRpcError {
|
|
27
|
+
readonly code: number;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly data?: unknown;
|
|
30
|
+
}
|
|
31
|
+
export type JsonRpcResponse = {
|
|
32
|
+
readonly jsonrpc: '2.0';
|
|
33
|
+
readonly id: RequestId;
|
|
34
|
+
readonly result: unknown;
|
|
35
|
+
} | {
|
|
36
|
+
readonly jsonrpc: '2.0';
|
|
37
|
+
readonly id: RequestId | null;
|
|
38
|
+
readonly error: JsonRpcError;
|
|
39
|
+
};
|
|
40
|
+
export interface ServerInfo {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly title: string;
|
|
43
|
+
readonly version: string;
|
|
44
|
+
}
|
|
45
|
+
export type McpReply = {
|
|
46
|
+
readonly kind: 'accepted';
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'answer';
|
|
49
|
+
readonly message: JsonRpcResponse;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: 'malformed';
|
|
52
|
+
readonly message: JsonRpcResponse;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: 'insufficient-scope';
|
|
55
|
+
readonly scope: McpScope;
|
|
56
|
+
readonly message: JsonRpcResponse;
|
|
57
|
+
};
|
|
58
|
+
export interface McpServer {
|
|
59
|
+
readonly registry: ToolRegistry;
|
|
60
|
+
readonly info: ServerInfo;
|
|
61
|
+
readonly call: ToolCall;
|
|
62
|
+
}
|
|
63
|
+
export declare function failure(id: RequestId | null, error: JsonRpcError): JsonRpcResponse;
|
|
64
|
+
export declare function reply(message: unknown, server: McpServer): Promise<McpReply>;
|
|
65
|
+
export declare function isSupportedVersion(version: unknown): version is ProtocolVersion;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/mcp/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAG7D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD,eAAO,MAAM,iBAAiB,YAAI,YAAY,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAErF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,eAAO,MAAM,uBAAuB,cAAuB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;aAAK,KAAK;iBAAI,WAAW;;CAAoB,CAAC;AAE9E,eAAO,MAAM,eAAe;aAC1B,UAAU,EAAE,CAAC,KAAK;aAClB,cAAc,EAAE,CAAC,KAAK;aACtB,cAAc,EAAE,CAAC,KAAK;aACtB,aAAa,EAAE,CAAC,KAAK;IACrB,+CAA+C;aAC/C,iBAAiB,EAAE,CAAC,KAAK;aACzB,WAAW,EAAE,CAAC,KAAK;C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EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,eAAe,CAElF;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuClF;AA8DD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,eAAe,CAE/E"}
|
|
@@ -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,uBAAuB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAW,CAAC;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,+CAA+C;IAC/C,iBAAiB,EAAE,CAAC,KAAK;IACzB,WAAW,EAAE,CAAC,KAAK;CACX,CAAC;AAoCX,MAAM,UAAU,OAAO,CAAC,EAAoB,EAAE,KAAmB;IAC/D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAgB,EAAE,MAAi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AAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,OAAQ,iBAAwC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,CAAC,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAChF,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,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
|
+
},
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../../src/mcp/repair/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAA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D,QAAQ,CAAC,aAAa,KAAK,sBAAsB,CAAC,aAAa,CAClE,CAAC,MAAM,CAAC;QACT,OAAO;YACL,EAAE,EAAE,IAAI;YACR,OAAO,EAAE,GAAG,OAAO,oBAAoB,sBAAsB,CAAC,aAAa,IAAI,sBAAsB,CAAC,OAAO,aAAa,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,KAAK,MAAM,CAAC,KAAK,CAAC,4BAA4B;YAChP,UAAU,EAAE;gBACV,OAAO;gBACP,MAAM,EAAE,sBAAsB,CAAC,MAAM;gBACrC,IAAI,EAAE,sBAAsB,CAAC,IAAI;gBACjC,KAAK,EAAE,sBAAsB,CAAC,OAAO;gBACrC,WAAW,EAAE,sBAAsB,CAAC,aAAa;gBACjD,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBACjC,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","source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