@proof-holdings/mcp-server 1.0.0 → 1.2.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.
Files changed (113) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +220 -217
  3. package/dist/authBoundary.d.ts +193 -0
  4. package/dist/authBoundary.d.ts.map +1 -0
  5. package/dist/authBoundary.js +341 -0
  6. package/dist/authBoundary.js.map +1 -0
  7. package/dist/factory.d.ts +35 -0
  8. package/dist/factory.d.ts.map +1 -0
  9. package/dist/factory.js +130 -0
  10. package/dist/factory.js.map +1 -0
  11. package/dist/http.d.ts +78 -3
  12. package/dist/http.d.ts.map +1 -1
  13. package/dist/http.js +251 -6
  14. package/dist/http.js.map +1 -1
  15. package/dist/remote.d.ts +111 -0
  16. package/dist/remote.d.ts.map +1 -0
  17. package/dist/remote.js +789 -0
  18. package/dist/remote.js.map +1 -0
  19. package/dist/server.js +11 -57
  20. package/dist/server.js.map +1 -1
  21. package/dist/toolAnnotations.d.ts +27 -0
  22. package/dist/toolAnnotations.d.ts.map +1 -0
  23. package/dist/toolAnnotations.js +158 -0
  24. package/dist/toolAnnotations.js.map +1 -0
  25. package/dist/tools/{projects.d.ts → accounts.d.ts} +1 -1
  26. package/dist/tools/accounts.d.ts.map +1 -0
  27. package/dist/tools/accounts.js +70 -0
  28. package/dist/tools/accounts.js.map +1 -0
  29. package/dist/tools/api-keys.d.ts.map +1 -1
  30. package/dist/tools/api-keys.js +14 -5
  31. package/dist/tools/api-keys.js.map +1 -1
  32. package/dist/tools/auth-flows.d.ts +4 -0
  33. package/dist/tools/auth-flows.d.ts.map +1 -0
  34. package/dist/tools/auth-flows.js +34 -0
  35. package/dist/tools/auth-flows.js.map +1 -0
  36. package/dist/tools/auth.js +1 -1
  37. package/dist/tools/auth.js.map +1 -1
  38. package/dist/tools/authorizations.d.ts +4 -0
  39. package/dist/tools/authorizations.d.ts.map +1 -0
  40. package/dist/tools/authorizations.js +111 -0
  41. package/dist/tools/authorizations.js.map +1 -0
  42. package/dist/tools/circles.d.ts +4 -0
  43. package/dist/tools/circles.d.ts.map +1 -0
  44. package/dist/tools/circles.js +215 -0
  45. package/dist/tools/circles.js.map +1 -0
  46. package/dist/tools/confirmations.d.ts +4 -0
  47. package/dist/tools/confirmations.d.ts.map +1 -0
  48. package/dist/tools/confirmations.js +86 -0
  49. package/dist/tools/confirmations.js.map +1 -0
  50. package/dist/tools/delegation-verify-outcomes.d.ts +23 -0
  51. package/dist/tools/delegation-verify-outcomes.d.ts.map +1 -0
  52. package/dist/tools/delegation-verify-outcomes.js +51 -0
  53. package/dist/tools/delegation-verify-outcomes.js.map +1 -0
  54. package/dist/tools/delegation-verify.d.ts +24 -0
  55. package/dist/tools/delegation-verify.d.ts.map +1 -0
  56. package/dist/tools/delegation-verify.js +192 -0
  57. package/dist/tools/delegation-verify.js.map +1 -0
  58. package/dist/tools/delegations.d.ts +4 -0
  59. package/dist/tools/delegations.d.ts.map +1 -0
  60. package/dist/tools/delegations.js +84 -0
  61. package/dist/tools/delegations.js.map +1 -0
  62. package/dist/tools/domains.d.ts.map +1 -1
  63. package/dist/tools/domains.js +1 -2
  64. package/dist/tools/domains.js.map +1 -1
  65. package/dist/tools/hitl-keys.d.ts +4 -0
  66. package/dist/tools/hitl-keys.d.ts.map +1 -0
  67. package/dist/tools/hitl-keys.js +52 -0
  68. package/dist/tools/hitl-keys.js.map +1 -0
  69. package/dist/tools/hitl.d.ts +4 -0
  70. package/dist/tools/hitl.d.ts.map +1 -0
  71. package/dist/tools/hitl.js +151 -0
  72. package/dist/tools/hitl.js.map +1 -0
  73. package/dist/tools/phones.js +1 -1
  74. package/dist/tools/phones.js.map +1 -1
  75. package/dist/tools/profiles.d.ts.map +1 -1
  76. package/dist/tools/profiles.js +73 -0
  77. package/dist/tools/profiles.js.map +1 -1
  78. package/dist/tools/proof-me.d.ts +4 -0
  79. package/dist/tools/proof-me.d.ts.map +1 -0
  80. package/dist/tools/proof-me.js +36 -0
  81. package/dist/tools/proof-me.js.map +1 -0
  82. package/dist/tools/proofs.d.ts.map +1 -1
  83. package/dist/tools/proofs.js +9 -6
  84. package/dist/tools/proofs.js.map +1 -1
  85. package/dist/tools/render-auth-link.d.ts +3 -0
  86. package/dist/tools/render-auth-link.d.ts.map +1 -0
  87. package/dist/tools/render-auth-link.js +30 -0
  88. package/dist/tools/render-auth-link.js.map +1 -0
  89. package/dist/tools/sessions.js +5 -5
  90. package/dist/tools/sessions.js.map +1 -1
  91. package/dist/tools/settings.d.ts.map +1 -1
  92. package/dist/tools/settings.js +77 -2
  93. package/dist/tools/settings.js.map +1 -1
  94. package/dist/tools/twofa.d.ts.map +1 -1
  95. package/dist/tools/twofa.js +16 -3
  96. package/dist/tools/twofa.js.map +1 -1
  97. package/dist/tools/user-requests.d.ts.map +1 -1
  98. package/dist/tools/user-requests.js +1 -2
  99. package/dist/tools/user-requests.js.map +1 -1
  100. package/dist/tools/verification-requests.d.ts.map +1 -1
  101. package/dist/tools/verification-requests.js +40 -13
  102. package/dist/tools/verification-requests.js.map +1 -1
  103. package/dist/tools/verifications.d.ts.map +1 -1
  104. package/dist/tools/verifications.js +59 -12
  105. package/dist/tools/verifications.js.map +1 -1
  106. package/dist/types.d.ts +18 -0
  107. package/dist/types.d.ts.map +1 -1
  108. package/dist/types.js +114 -5
  109. package/dist/types.js.map +1 -1
  110. package/package.json +11 -5
  111. package/dist/tools/projects.d.ts.map +0 -1
  112. package/dist/tools/projects.js +0 -159
  113. package/dist/tools/projects.js.map +0 -1
@@ -0,0 +1,111 @@
1
+ import { z } from 'zod';
2
+ import { jsonResult, errorResult, BSUID_REGEX } from '../types.js';
3
+ import { ApiError } from '../http.js';
4
+ const authorizationChannelEnum = z.enum(['whatsapp', 'telegram', 'sms', 'email']);
5
+ const authorizationScopeEnum = z.enum(['confirmations']);
6
+ const authorizationStatusEnum = z.enum(['pending', 'active', 'expired', 'revoked', 'denied']);
7
+ export function registerTools(tool, http) {
8
+ tool('create_authorization', 'Create a new authorization request. Authorizations grant permission to send confirmations to a user via a specific channel. The user must approve the authorization before confirmations can be sent.', {
9
+ hitl_id: z.string().regex(/^[0-9a-fA-F]{24}$/).describe('HITL configuration ID to link this authorization to'),
10
+ recipient: z.string().min(1).max(255).describe('Channel-specific recipient identifier (chat_id for Telegram, phone/BSUID for WhatsApp)'),
11
+ phone: z.string().regex(/^\+[1-9]\d{1,14}$/).describe('Target phone number in E.164 format (e.g., +15551234567)'),
12
+ bsuid: z.string().regex(BSUID_REGEX).optional().describe('WhatsApp Business-Scoped User ID (alternative to phone for WhatsApp channel)'),
13
+ channel: authorizationChannelEnum.describe('Channel for sending confirmations'),
14
+ scope: authorizationScopeEnum.optional().describe('Authorization scope (default: confirmations)'),
15
+ business_name: z.string().min(1).max(200).describe('Business name displayed to user during authorization'),
16
+ business_profile_id: z.string().regex(/^[0-9a-fA-F]{24}$/).optional().describe('Public profile ID for branding'),
17
+ expires_in: z.number().int().positive().max(7776000).optional().describe('Expiry in seconds (max 90 days, default 90 days)'),
18
+ }, async (args) => {
19
+ try {
20
+ const result = await http.post('/api/v1/authorizations', args);
21
+ return jsonResult(result);
22
+ }
23
+ catch (e) {
24
+ if (e instanceof ApiError)
25
+ return errorResult(`${e.code}: ${e.message}`);
26
+ throw e;
27
+ }
28
+ });
29
+ tool('get_authorization', 'Get an authorization by ID. Returns the current state of the authorization including status and usage statistics.', {
30
+ id: z.string().describe('Authorization ID'),
31
+ }, async ({ id }) => {
32
+ try {
33
+ const result = await http.get(`/api/v1/authorizations/${encodeURIComponent(id)}`);
34
+ return jsonResult(result);
35
+ }
36
+ catch (e) {
37
+ if (e instanceof ApiError)
38
+ return errorResult(`${e.code}: ${e.message}`);
39
+ throw e;
40
+ }
41
+ });
42
+ tool('list_authorizations', 'List authorizations with optional filters. Returns paginated results.', {
43
+ status: authorizationStatusEnum.optional().describe('Filter by authorization status'),
44
+ phone: z.string().optional().describe('Filter by phone number'),
45
+ channel: authorizationChannelEnum.optional().describe('Filter by channel'),
46
+ page: z.number().int().positive().optional().describe('Page number'),
47
+ limit: z.number().int().min(1).max(100).optional().describe('Items per page'),
48
+ }, async (args) => {
49
+ try {
50
+ const query = {};
51
+ if (args.status !== undefined)
52
+ query.status = args.status;
53
+ if (args.phone !== undefined)
54
+ query.phone = args.phone;
55
+ if (args.channel !== undefined)
56
+ query.channel = args.channel;
57
+ if (args.page !== undefined)
58
+ query.page = args.page;
59
+ if (args.limit !== undefined)
60
+ query.limit = args.limit;
61
+ const result = await http.get('/api/v1/authorizations', query);
62
+ return jsonResult(result);
63
+ }
64
+ catch (e) {
65
+ if (e instanceof ApiError)
66
+ return errorResult(`${e.code}: ${e.message}`);
67
+ throw e;
68
+ }
69
+ });
70
+ tool('revoke_authorization', 'Revoke an active or pending authorization. Only authorizations with status "active" or "pending" can be revoked.', {
71
+ id: z.string().describe('Authorization ID to revoke'),
72
+ reason: z.string().min(1).max(500).optional().describe('Reason for revocation'),
73
+ }, async ({ id, reason }) => {
74
+ try {
75
+ const body = reason !== undefined ? { reason } : undefined;
76
+ const result = await http.del(`/api/v1/authorizations/${encodeURIComponent(id)}`, body);
77
+ return jsonResult(result);
78
+ }
79
+ catch (e) {
80
+ if (e instanceof ApiError)
81
+ return errorResult(`${e.code}: ${e.message}`);
82
+ throw e;
83
+ }
84
+ });
85
+ tool('export_authorizations', 'Export authorizations as CSV or JSON. Supports date range and status filtering. Maximum 10,000 records.', {
86
+ format: z.enum(['csv', 'json']).optional().describe('Export format (default: json)'),
87
+ from: z.string().optional().describe('Start date filter (ISO 8601)'),
88
+ to: z.string().optional().describe('End date filter (ISO 8601)'),
89
+ status: authorizationStatusEnum.optional().describe('Filter by status'),
90
+ }, async (args) => {
91
+ try {
92
+ const query = {};
93
+ if (args.format !== undefined)
94
+ query.format = args.format;
95
+ if (args.from !== undefined)
96
+ query.from = args.from;
97
+ if (args.to !== undefined)
98
+ query.to = args.to;
99
+ if (args.status !== undefined)
100
+ query.status = args.status;
101
+ const result = await http.get('/api/v1/authorizations/export', query);
102
+ return jsonResult(result);
103
+ }
104
+ catch (e) {
105
+ if (e instanceof ApiError)
106
+ return errorResult(`${e.code}: ${e.message}`);
107
+ throw e;
108
+ }
109
+ });
110
+ }
111
+ //# sourceMappingURL=authorizations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorizations.js","sourceRoot":"","sources":["../../src/tools/authorizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAClF,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AACzD,MAAM,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE9F,MAAM,UAAU,aAAa,CAAC,IAAmB,EAAE,IAAgB;IACjE,IAAI,CACF,sBAAsB,EACtB,uMAAuM,EACvM;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,qDAAqD,CAAC;QAC9G,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,wFAAwF,CAAC;QACxI,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,0DAA0D,CAAC;QACjH,KAAK,EAA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CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtE,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,QAAQ;gBAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACzE,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { HttpClient } from '../http.js';
2
+ import type { ToolRegistrar } from '../types.js';
3
+ export declare function registerTools(tool: ToolRegistrar, http: HttpClient): void;
4
+ //# sourceMappingURL=circles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circles.d.ts","sourceRoot":"","sources":["../../src/tools/circles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgBjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QAiQlE"}
@@ -0,0 +1,215 @@
1
+ import { z } from 'zod';
2
+ import { jsonResult, errorResult } from '../types.js';
3
+ import { ApiError } from '../http.js';
4
+ const objectId = z.string().regex(/^[0-9a-fA-F]{24}$/);
5
+ const circleChannel = z.enum(['telegram', 'whatsapp']);
6
+ const e164 = z.string().regex(/^\+[1-9]\d{7,14}$/, 'must be E.164 with a leading +');
7
+ // A contact at create time: name + OPTIONAL flat channel identifiers (mirrors the backend
8
+ // circleMemberInputSchema). A member may be added by name only and enrolled later.
9
+ const circleMemberInput = z.object({
10
+ name: z.string().min(1).max(100).describe('Display name of the member'),
11
+ telegram_chat_id: z.string().max(50).optional().describe('Telegram chat id (declared; usually captured at enrollment instead)'),
12
+ whatsapp_phone: e164.optional().describe('E.164 WhatsApp phone with a leading + (declared)'),
13
+ });
14
+ export function registerTools(tool, http) {
15
+ tool('create_circle', 'Create a Circle — a named group of trusted contacts (the people-primitive powering Proof-Me and Approvals-on-Circle). Optionally seed initial members; each member\'s declared channels are stored so they can be invited to enroll.\n\nAgent usage: after creating a Circle, add members with add_circle_member (or seed them here), then invite_circle_member to mint the enrollment deep link each contact taps to bind their messenger identity.', {
16
+ name: z.string().min(1).max(200).describe('Human-readable name for the Circle'),
17
+ profile_id: objectId.optional().describe('Public profile (sub-account) to bind for branded messages — create-only'),
18
+ proof_me_enabled: z.boolean().optional().describe('Enable Proof-Me drills for this Circle'),
19
+ members: z.array(circleMemberInput).max(100).optional().describe('Initial members (name + optional declared channels)'),
20
+ }, async (args) => {
21
+ try {
22
+ const result = await http.post('/api/v1/circles', args);
23
+ return jsonResult(result);
24
+ }
25
+ catch (e) {
26
+ if (e instanceof ApiError)
27
+ return errorResult(`${e.code}: ${e.message}`);
28
+ throw e;
29
+ }
30
+ });
31
+ tool('list_circles', 'List Circles with optional filters. Archived Circles are excluded by default; pass status="archived" to surface them. Returns paginated results.', {
32
+ status: z.enum(['active', 'archived']).optional().describe('Filter by status (archived excluded unless requested)'),
33
+ environment: z.enum(['production', 'test']).optional().describe('Filter by environment (production or test)'),
34
+ profile_id: objectId.optional().describe('Filter by bound public profile (sub-account)'),
35
+ page: z.number().int().positive().max(10000).optional().describe('Page number (default 1)'),
36
+ limit: z.number().int().positive().max(100).optional().describe('Items per page (default 20, max 100)'),
37
+ }, async (args) => {
38
+ try {
39
+ const query = {};
40
+ if (args.status !== undefined)
41
+ query.status = args.status;
42
+ if (args.environment !== undefined)
43
+ query.environment = args.environment;
44
+ if (args.profile_id !== undefined)
45
+ query.profile_id = args.profile_id;
46
+ if (args.page !== undefined)
47
+ query.page = args.page;
48
+ if (args.limit !== undefined)
49
+ query.limit = args.limit;
50
+ const result = await http.get('/api/v1/circles', query);
51
+ return jsonResult(result);
52
+ }
53
+ catch (e) {
54
+ if (e instanceof ApiError)
55
+ return errorResult(`${e.code}: ${e.message}`);
56
+ throw e;
57
+ }
58
+ });
59
+ tool('get_circle', 'Get a Circle by ID. Returns the Circle including its members and per-member channel presence booleans (an identifier is NEVER returned — SEC-PM-006).', {
60
+ id: objectId.describe('Circle ID'),
61
+ }, async ({ id }) => {
62
+ try {
63
+ const result = await http.get(`/api/v1/circles/${encodeURIComponent(id)}`);
64
+ return jsonResult(result);
65
+ }
66
+ catch (e) {
67
+ if (e instanceof ApiError)
68
+ return errorResult(`${e.code}: ${e.message}`);
69
+ throw e;
70
+ }
71
+ });
72
+ tool('update_circle', 'Update a Circle\'s name. Only the display name is mutable — the profile/identity binding is create-only.', {
73
+ id: objectId.describe('Circle ID'),
74
+ name: z.string().min(1).max(200).optional().describe('New name for the Circle'),
75
+ }, async ({ id, ...body }) => {
76
+ try {
77
+ const result = await http.patch(`/api/v1/circles/${encodeURIComponent(id)}`, body);
78
+ return jsonResult(result);
79
+ }
80
+ catch (e) {
81
+ if (e instanceof ApiError)
82
+ return errorResult(`${e.code}: ${e.message}`);
83
+ throw e;
84
+ }
85
+ });
86
+ tool('delete_circle', 'Archive a Circle (soft delete — sets status to archived). It stops appearing in the default list but is recoverable via list_circles with status="archived".', {
87
+ id: objectId.describe('Circle ID to archive'),
88
+ }, async ({ id }) => {
89
+ try {
90
+ const result = await http.del(`/api/v1/circles/${encodeURIComponent(id)}`);
91
+ return jsonResult(result);
92
+ }
93
+ catch (e) {
94
+ if (e instanceof ApiError)
95
+ return errorResult(`${e.code}: ${e.message}`);
96
+ throw e;
97
+ }
98
+ });
99
+ tool('add_circle_member', 'Add a pending member to a Circle by name, with an optional pre-declared WhatsApp phone. The Telegram chat id is captured later when the member taps the enrollment deep link.\n\nAgent usage: after adding a member, call invite_circle_member to mint the single-use enrollment link the member taps to bind their messenger identity.', {
100
+ id: objectId.describe('Circle ID to add the member to'),
101
+ name: z.string().min(1).max(100).describe('Display name of the member'),
102
+ whatsapp_phone: e164.optional().describe('E.164 WhatsApp phone with a leading + (optional, declared)'),
103
+ }, async ({ id, ...body }) => {
104
+ try {
105
+ const result = await http.post(`/api/v1/circles/${encodeURIComponent(id)}/members`, body);
106
+ return jsonResult(result);
107
+ }
108
+ catch (e) {
109
+ if (e instanceof ApiError)
110
+ return errorResult(`${e.code}: ${e.message}`);
111
+ throw e;
112
+ }
113
+ });
114
+ tool('list_circle_members', 'List a Circle\'s members. Each member carries channel-presence booleans only (has_telegram / has_whatsapp) — an identifier is NEVER returned (SEC-PM-006).', {
115
+ id: objectId.describe('Circle ID'),
116
+ }, async ({ id }) => {
117
+ try {
118
+ const result = await http.get(`/api/v1/circles/${encodeURIComponent(id)}/members`);
119
+ return jsonResult(result);
120
+ }
121
+ catch (e) {
122
+ if (e instanceof ApiError)
123
+ return errorResult(`${e.code}: ${e.message}`);
124
+ throw e;
125
+ }
126
+ });
127
+ tool('invite_circle_member', 'Mint a single-use enrollment invite for a Circle member. Returns Telegram + WhatsApp deep links and a QR code; the member taps the channel-matched link to bind their messenger identity to the Circle.', {
128
+ id: objectId.describe('Circle ID'),
129
+ member_id: objectId.describe('Member ID to invite'),
130
+ }, async ({ id, member_id }) => {
131
+ try {
132
+ const result = await http.post(`/api/v1/circles/${encodeURIComponent(id)}/members/invite`, { member_id });
133
+ return jsonResult(result);
134
+ }
135
+ catch (e) {
136
+ if (e instanceof ApiError)
137
+ return errorResult(`${e.code}: ${e.message}`);
138
+ throw e;
139
+ }
140
+ });
141
+ tool('create_circle_member_drill', 'Fire an on-demand Proof-Me drill against one enrolled member — a real cross-channel identity challenge carrying the scheduled-safety-check label (the account owner practices confirming). Complements the automated daily drill + monthly reinforcement sweeps.', {
142
+ id: objectId.describe('Circle ID'),
143
+ member_id: objectId.describe('Member ID to drill'),
144
+ }, async ({ id, member_id }) => {
145
+ try {
146
+ const result = await http.post(`/api/v1/circles/${encodeURIComponent(id)}/members/${encodeURIComponent(member_id)}/drill`);
147
+ return jsonResult(result);
148
+ }
149
+ catch (e) {
150
+ if (e instanceof ApiError)
151
+ return errorResult(`${e.code}: ${e.message}`);
152
+ throw e;
153
+ }
154
+ });
155
+ tool('remove_circle_member', 'Remove a member from a Circle. Deletes the member\'s channels and revokes any live authorizations that routed through them.', {
156
+ id: objectId.describe('Circle ID'),
157
+ member_id: objectId.describe('Member ID to remove'),
158
+ }, async ({ id, member_id }) => {
159
+ try {
160
+ const result = await http.del(`/api/v1/circles/${encodeURIComponent(id)}/members/${encodeURIComponent(member_id)}`);
161
+ return jsonResult(result);
162
+ }
163
+ catch (e) {
164
+ if (e instanceof ApiError)
165
+ return errorResult(`${e.code}: ${e.message}`);
166
+ throw e;
167
+ }
168
+ });
169
+ tool('add_circle_member_channel', 'Declare a channel for a Circle member. Returns 409 if that channel type already exists on the member. The identifier is a Telegram chat id or an E.164 WhatsApp phone (per-channel format validated server-side).', {
170
+ id: objectId.describe('Circle ID'),
171
+ member_id: objectId.describe('Member ID to add the channel to'),
172
+ channel: circleChannel.describe('Channel type (telegram or whatsapp)'),
173
+ identifier: z.string().min(1).max(100).describe('Telegram chat id, or E.164 WhatsApp phone with a leading +'),
174
+ }, async ({ id, member_id, ...body }) => {
175
+ try {
176
+ const result = await http.post(`/api/v1/circles/${encodeURIComponent(id)}/members/${encodeURIComponent(member_id)}/channels`, body);
177
+ return jsonResult(result);
178
+ }
179
+ catch (e) {
180
+ if (e instanceof ApiError)
181
+ return errorResult(`${e.code}: ${e.message}`);
182
+ throw e;
183
+ }
184
+ });
185
+ tool('list_circle_member_channels', 'List a Circle member\'s channels. Returns channel metadata only (channel, status, verified_at) — an identifier is NEVER returned (SEC-PM-006).', {
186
+ id: objectId.describe('Circle ID'),
187
+ member_id: objectId.describe('Member ID'),
188
+ }, async ({ id, member_id }) => {
189
+ try {
190
+ const result = await http.get(`/api/v1/circles/${encodeURIComponent(id)}/members/${encodeURIComponent(member_id)}/channels`);
191
+ return jsonResult(result);
192
+ }
193
+ catch (e) {
194
+ if (e instanceof ApiError)
195
+ return errorResult(`${e.code}: ${e.message}`);
196
+ throw e;
197
+ }
198
+ });
199
+ tool('remove_circle_member_channel', 'Remove a channel from a Circle member. Removing the last channel is allowed (the member simply becomes unreachable).', {
200
+ id: objectId.describe('Circle ID'),
201
+ member_id: objectId.describe('Member ID'),
202
+ channel_id: objectId.describe('Channel ID to remove'),
203
+ }, async ({ id, member_id, channel_id }) => {
204
+ try {
205
+ const result = await http.del(`/api/v1/circles/${encodeURIComponent(id)}/members/${encodeURIComponent(member_id)}/channels/${encodeURIComponent(channel_id)}`);
206
+ return jsonResult(result);
207
+ }
208
+ catch (e) {
209
+ if (e instanceof ApiError)
210
+ return errorResult(`${e.code}: ${e.message}`);
211
+ throw e;
212
+ }
213
+ });
214
+ }
215
+ //# sourceMappingURL=circles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circles.js","sourceRoot":"","sources":["../../src/tools/circles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACvD,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AACvD,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,CAAC;AAErF,0FAA0F;AAC1F,mFAAmF;AACnF,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC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kBAAkB,CAAC,EAAE,CAAC,YAAY,kBAAkB,CAAC,SAAS,CAAC,aAAa,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAChI,CAAC;YACF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,QAAQ;gBAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACzE,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { HttpClient } from '../http.js';
2
+ import type { ToolRegistrar } from '../types.js';
3
+ export declare function registerTools(tool: ToolRegistrar, http: HttpClient): void;
4
+ //# sourceMappingURL=confirmations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmations.d.ts","sourceRoot":"","sources":["../../src/tools/confirmations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QAoGlE"}
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ import { jsonResult, errorResult, pollUntilTerminal, WAIT_DEFAULT_SECONDS } from '../types.js';
3
+ import { ApiError } from '../http.js';
4
+ const confirmationStatusEnum = z.enum(['pending', 'approved', 'denied']);
5
+ export function registerTools(tool, http) {
6
+ tool('create_confirmation', 'Create a HITL confirmation request. Sends an approval request to the channels configured on the referenced HITL config. First response wins.\n\nAgent usage: The HITL config referenced by hitl_id must be authorized before you can create confirmations. If this returns a 403 or "not authorized" error, call request_hitl_authorization on the HITL config first, then wait for the user to approve via the messaging channel. After creating a confirmation, poll get_confirmation to check for approval/denial, or use get_confirmation_approval_link to generate a fresh link for the user.\n\nEncryption is NOT optional: a HITL config cannot send confirmations without a keypair, the human approves by decrypting in their browser, and `message` must be a JSON ciphertext envelope. Plaintext is refused with 400 `message_not_encrypted`; an envelope sealed to another key with 400 `message_key_mismatch`. Choose the version by who must be able to decrypt:\n- v1 (single-recipient): wraps the content key for the config owner only. Use ONLY when there are no enrolled non-owner approvers — with approvers enrolled it is refused with 400 `envelope_missing_approvers`.\n- v2 (multi-recipient): additionally wraps the content key for each enrolled approver via an `approver_ek` map, so every approver can decrypt. Build it with the SDK `encryptMessageV2(plaintext, ownerPublicKey, hitlId, approverKeys)` after fetching the approvers via the SDK `getApproverKeys(hitlId)` (`GET /api/v1/hitl/:id/approver-keys`). AAD is the `hitlId`.', {
7
+ hitl_id: z.string().regex(/^[0-9a-fA-F]{24}$/).describe('HITL config ID whose channels will receive the approval request'),
8
+ message: z.string().min(1).max(10000).describe('The client-encrypted ciphertext envelope as a JSON string (v1 or v2) — NOT the human-readable text. Encrypt the sentence the approver should read; passing it directly is refused with 400 `message_not_encrypted`, because the approval page can only decrypt an envelope.'),
9
+ proof_expiry_days: z.number().int().optional().describe('Per-request proof expiry override in days (7, 30, 90, or 365)'),
10
+ }, async (args) => {
11
+ try {
12
+ const result = await http.post('/api/v1/confirmations', args);
13
+ return jsonResult(result);
14
+ }
15
+ catch (e) {
16
+ if (e instanceof ApiError)
17
+ return errorResult(`${e.code}: ${e.message}`);
18
+ throw e;
19
+ }
20
+ });
21
+ tool('get_confirmation', 'Get a confirmation by ID. Returns the full confirmation including status, response, and proof token.', {
22
+ id: z.string().describe('Confirmation ID'),
23
+ }, async ({ id }) => {
24
+ try {
25
+ const result = await http.get(`/api/v1/confirmations/${encodeURIComponent(id)}`);
26
+ return jsonResult(result);
27
+ }
28
+ catch (e) {
29
+ if (e instanceof ApiError)
30
+ return errorResult(`${e.code}: ${e.message}`);
31
+ throw e;
32
+ }
33
+ });
34
+ tool('list_confirmations', 'List confirmations with optional filters. Returns paginated results with status and HITL config filtering.', {
35
+ status: confirmationStatusEnum.optional().describe('Filter by confirmation status'),
36
+ hitl_id: z.string().regex(/^[0-9a-fA-F]{24}$/).optional().describe('Filter by HITL config ID'),
37
+ page: z.number().int().positive().optional().describe('Page number'),
38
+ limit: z.number().int().min(1).max(100).optional().describe('Items per page'),
39
+ }, async (args) => {
40
+ try {
41
+ const query = {};
42
+ if (args.status !== undefined)
43
+ query.status = args.status;
44
+ if (args.hitl_id !== undefined)
45
+ query.hitl_id = args.hitl_id;
46
+ if (args.page !== undefined)
47
+ query.page = args.page;
48
+ if (args.limit !== undefined)
49
+ query.limit = args.limit;
50
+ const result = await http.get('/api/v1/confirmations', query);
51
+ return jsonResult(result);
52
+ }
53
+ catch (e) {
54
+ if (e instanceof ApiError)
55
+ return errorResult(`${e.code}: ${e.message}`);
56
+ throw e;
57
+ }
58
+ });
59
+ tool('get_confirmation_approval_link', 'Generate a fresh approval link for a pending confirmation. The link expiry inherits the confirmation timeout. Only works for pending confirmations.', {
60
+ id: z.string().regex(/^[0-9a-fA-F]{24}$/).describe('Confirmation ID'),
61
+ }, async ({ id }) => {
62
+ try {
63
+ const result = await http.post(`/api/v1/confirmations/${encodeURIComponent(id)}/approval-link`);
64
+ return jsonResult(result);
65
+ }
66
+ catch (e) {
67
+ if (e instanceof ApiError)
68
+ return errorResult(`${e.code}: ${e.message}`);
69
+ throw e;
70
+ }
71
+ });
72
+ tool('wait_for_confirmation', 'Poll a confirmation until the approver responds. Uses exponential backoff (2s initial, 1.5x, 30s max) with jitter.\n\nAgent usage: Call this after create_confirmation with the returned confirmation ID. Terminal states: "approved" (action authorized — check the proof_token), "denied" (action rejected). While "pending", the approver has not yet responded. This poll returns no link — the approval request is delivered to the approver\'s own channel. If the approver needs one anyway, call get_confirmation_approval_link for a fresh `approval_url`; it needs the confirmation to be still pending — the state this tool waits in — and also refuses once `timeout_at` has passed, so a long wait can outlive the link even while the status has not moved.', {
73
+ id: z.string().describe('Confirmation ID from create_confirmation'),
74
+ timeout_seconds: z.number().int().min(1).max(600).optional().describe(`Maximum wait time in seconds (default: ${WAIT_DEFAULT_SECONDS}, max: 600). Keep it under your MCP client's request timeout (the SDK default is 60 s) — a longer wait is cut off by the client while the server is still polling. On timeout the tool answers status "pending"; call it again with the same identifier.`),
75
+ }, async ({ id, timeout_seconds }) => {
76
+ try {
77
+ return await pollUntilTerminal(() => http.get(`/api/v1/confirmations/${encodeURIComponent(id)}`), ['approved', 'denied'], timeout_seconds ?? WAIT_DEFAULT_SECONDS, `confirmation ${id}`);
78
+ }
79
+ catch (e) {
80
+ if (e instanceof ApiError)
81
+ return errorResult(`${e.code}: ${e.message}`);
82
+ throw e;
83
+ }
84
+ });
85
+ }
86
+ //# sourceMappingURL=confirmations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmations.js","sourceRoot":"","sources":["../../src/tools/confirmations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEzE,MAAM,UAAU,aAAa,CAAC,IAAmB,EAAE,IAAgB;IACjE,IAAI,CACF,qBAAqB,EACrB,4+CAA4+C,EAC5+C;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,iEAAiE,CAAC;QAC1H,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,6QAA6Q,CAAC;QAC7T,iBAAiB,EAAE,CAAC,CAAC,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,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,QAAQ;gBAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACzE,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type FailureReason } from '@proof-holdings/delegation-verifier';
2
+ /**
3
+ * The batch checker's outcome vocabulary (h-proof-checker-mcp).
4
+ *
5
+ * `confirmed_valid` is not a key of this map — it comes from `VerificationSuccess.valid: true`,
6
+ * never from a `FailureReason`. The three keys below are the only buckets a FAILED verification
7
+ * may land in, and the distinction is the whole point of the task: a checker that renders
8
+ * "could not reach the issuer" the same as "revoked" silently breaks tools belonging to people
9
+ * who have never heard of us.
10
+ *
11
+ * This is a LOCAL map, scoped to this MCP tool. `h-delegation-verifier-status-fallthrough-gate`
12
+ * added the official upstream field this map anticipated (`VerificationFailure.outcome` via
13
+ * `classifyFailureReason`), but that field is BINARY (`invalid` | `unconfirmed`) while this
14
+ * tool's vocabulary is three buckets — `no_claim_found` has no upstream equivalent (the package
15
+ * has no concept of "nothing to check", only "checked and bad" vs "could not check"), and two
16
+ * more reasons (`multiple_publications`, and the two unreachable-in-practice call-shape errors)
17
+ * read differently at this tool's altitude than the package's binary split would give them by
18
+ * default. So the map is not deleted, only DERIVED: every reason not named in `LOCAL_OVERRIDE`
19
+ * below takes its bucket straight from `classifyFailureReason`.
20
+ */
21
+ export type FailureOutcome = 'confirmed_invalid' | 'no_claim_found' | 'unconfirmed';
22
+ export declare const FAILURE_REASON_OUTCOME: Record<FailureReason, FailureOutcome>;
23
+ //# sourceMappingURL=delegation-verify-outcomes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation-verify-outcomes.d.ts","sourceRoot":"","sources":["../../src/tools/delegation-verify-outcomes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEhG;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAiDpF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,aAAa,EAAE,cAAc,CAK/B,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { classifyFailureReason } from '@proof-holdings/delegation-verifier';
2
+ /** Every `FailureReason` the shared package declares today. Kept as an explicit value list
3
+ * (not derived from the type, which is erased at runtime) — the exhaustiveness test in
4
+ * `delegation-verify-outcomes.test.ts` fails loudly if this list drifts from the package. */
5
+ const ALL_FAILURE_REASONS = [
6
+ 'invalid_options',
7
+ 'no_trust_policy',
8
+ 'malformed_token',
9
+ 'untrusted_issuer',
10
+ 'unsupported_algorithm',
11
+ 'unknown_key',
12
+ 'bad_signature',
13
+ 'jwks_unavailable',
14
+ 'not_a_delegation',
15
+ 'unsupported_schema',
16
+ 'expired',
17
+ 'not_yet_valid',
18
+ 'malformed_claims',
19
+ 'principal_mismatch',
20
+ 'delegate_mismatch',
21
+ 'scope_not_granted',
22
+ 'status_uri_untrusted',
23
+ 'status_unavailable',
24
+ 'revoked',
25
+ 'suspended',
26
+ 'unknown_delegation',
27
+ 'no_publication',
28
+ 'multiple_publications',
29
+ ];
30
+ /**
31
+ * The reasons whose LOCAL 3-bucket meaning differs from the package's binary
32
+ * `classifyFailureReason` — everything else in `ALL_FAILURE_REASONS` derives straight from it.
33
+ */
34
+ const LOCAL_OVERRIDE = {
35
+ // The card carries no delegation publication at all — an absence, never an accusation. The
36
+ // package's binary field has no third bucket for this; it isn't a "check" at all.
37
+ no_publication: 'no_claim_found',
38
+ // Ambiguous input (the card names two different publications), not a confirmed-bad artifact —
39
+ // the package's binary split would otherwise bucket it `invalid`, which overstates it.
40
+ multiple_publications: 'unconfirmed',
41
+ // Errors in the CALL itself, not a statement about the artifact. This tool always supplies a
42
+ // well-formed VerifyOptions (non-empty trustedIssuers, delegate required by the Zod schema),
43
+ // so these are unreachable in practice — mapped for exhaustiveness, not because they occur.
44
+ invalid_options: 'unconfirmed',
45
+ no_trust_policy: 'unconfirmed',
46
+ };
47
+ export const FAILURE_REASON_OUTCOME = Object.fromEntries(ALL_FAILURE_REASONS.map((reason) => [
48
+ reason,
49
+ LOCAL_OVERRIDE[reason] ?? (classifyFailureReason(reason) === 'unconfirmed' ? 'unconfirmed' : 'confirmed_invalid'),
50
+ ]));
51
+ //# sourceMappingURL=delegation-verify-outcomes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation-verify-outcomes.js","sourceRoot":"","sources":["../../src/tools/delegation-verify-outcomes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAsB,MAAM,qCAAqC,CAAC;AAuBhG;;6FAE6F;AAC7F,MAAM,mBAAmB,GAAoB;IAC3C,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,uBAAuB;IACvB,aAAa;IACb,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,SAAS;IACT,eAAe;IACf,kBAAkB;IAClB,oBAAoB;IACpB,mBAAmB;IACnB,mBAAmB;IACnB,sBAAsB;IACtB,oBAAoB;IACpB,SAAS;IACT,WAAW;IACX,oBAAoB;IACpB,gBAAgB;IAChB,uBAAuB;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,cAAc,GAAmD;IACrE,2FAA2F;IAC3F,kFAAkF;IAClF,cAAc,EAAE,gBAAgB;IAChC,8FAA8F;IAC9F,uFAAuF;IACvF,qBAAqB,EAAE,aAAa;IACpC,6FAA6F;IAC7F,6FAA6F;IAC7F,4FAA4F;IAC5F,eAAe,EAAE,aAAa;IAC9B,eAAe,EAAE,aAAa;CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAA0C,MAAM,CAAC,WAAW,CAC7F,mBAAmB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IAClC,MAAM;IACN,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,mBAAmB,CAAC;CAClH,CAAC,CACsC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { VerificationResult } from '@proof-holdings/delegation-verifier';
2
+ import type { ToolRegistrar } from '../types.js';
3
+ export interface DelegationVerifyItem {
4
+ card?: Record<string, unknown>;
5
+ token?: string;
6
+ delegate: {
7
+ type: 'url' | 'purl';
8
+ value: string;
9
+ };
10
+ expected_principal: string;
11
+ required_scopes?: string[];
12
+ check_status?: boolean;
13
+ }
14
+ /**
15
+ * The single-artifact verification core, factored out so `verify_delegation` (one item) and
16
+ * `verify_delegations` (a batch of up to 50, h-proof-checker-mcp) share exactly one call into
17
+ * the reference verifier. Callers must already have checked `card` XOR `token` — this function
18
+ * does not, so it stays usable per-item inside a batch loop without duplicating that guard.
19
+ */
20
+ export declare function verifyOneDelegation(item: DelegationVerifyItem, baseUrl: string): Promise<VerificationResult>;
21
+ export declare function registerTools(tool: ToolRegistrar, options: {
22
+ baseUrl: string;
23
+ }): void;
24
+ //# sourceMappingURL=delegation-verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation-verify.d.ts","sourceRoot":"","sources":["../../src/tools/delegation-verify.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgC,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA8CjD,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAY5G;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,QA4J9E"}