@proof-holdings/mcp-server 1.0.0 → 1.1.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 (107) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +223 -216
  3. package/dist/authBoundary.d.ts +182 -0
  4. package/dist/authBoundary.d.ts.map +1 -0
  5. package/dist/authBoundary.js +328 -0
  6. package/dist/authBoundary.js.map +1 -0
  7. package/dist/factory.d.ts +33 -0
  8. package/dist/factory.d.ts.map +1 -0
  9. package/dist/factory.js +123 -0
  10. package/dist/factory.js.map +1 -0
  11. package/dist/http.d.ts +63 -3
  12. package/dist/http.d.ts.map +1 -1
  13. package/dist/http.js +183 -4
  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 +787 -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/tools/{projects.d.ts → accounts.d.ts} +1 -1
  22. package/dist/tools/accounts.d.ts.map +1 -0
  23. package/dist/tools/accounts.js +70 -0
  24. package/dist/tools/accounts.js.map +1 -0
  25. package/dist/tools/api-keys.d.ts.map +1 -1
  26. package/dist/tools/api-keys.js +14 -5
  27. package/dist/tools/api-keys.js.map +1 -1
  28. package/dist/tools/auth-flows.d.ts +4 -0
  29. package/dist/tools/auth-flows.d.ts.map +1 -0
  30. package/dist/tools/auth-flows.js +34 -0
  31. package/dist/tools/auth-flows.js.map +1 -0
  32. package/dist/tools/authorizations.d.ts +4 -0
  33. package/dist/tools/authorizations.d.ts.map +1 -0
  34. package/dist/tools/authorizations.js +111 -0
  35. package/dist/tools/authorizations.js.map +1 -0
  36. package/dist/tools/circles.d.ts +4 -0
  37. package/dist/tools/circles.d.ts.map +1 -0
  38. package/dist/tools/circles.js +215 -0
  39. package/dist/tools/circles.js.map +1 -0
  40. package/dist/tools/confirmations.d.ts +4 -0
  41. package/dist/tools/confirmations.d.ts.map +1 -0
  42. package/dist/tools/confirmations.js +86 -0
  43. package/dist/tools/confirmations.js.map +1 -0
  44. package/dist/tools/delegation-verify-outcomes.d.ts +23 -0
  45. package/dist/tools/delegation-verify-outcomes.d.ts.map +1 -0
  46. package/dist/tools/delegation-verify-outcomes.js +51 -0
  47. package/dist/tools/delegation-verify-outcomes.js.map +1 -0
  48. package/dist/tools/delegation-verify.d.ts +24 -0
  49. package/dist/tools/delegation-verify.d.ts.map +1 -0
  50. package/dist/tools/delegation-verify.js +192 -0
  51. package/dist/tools/delegation-verify.js.map +1 -0
  52. package/dist/tools/delegations.d.ts +4 -0
  53. package/dist/tools/delegations.d.ts.map +1 -0
  54. package/dist/tools/delegations.js +84 -0
  55. package/dist/tools/delegations.js.map +1 -0
  56. package/dist/tools/domains.d.ts.map +1 -1
  57. package/dist/tools/domains.js +1 -2
  58. package/dist/tools/domains.js.map +1 -1
  59. package/dist/tools/hitl-keys.d.ts +4 -0
  60. package/dist/tools/hitl-keys.d.ts.map +1 -0
  61. package/dist/tools/hitl-keys.js +52 -0
  62. package/dist/tools/hitl-keys.js.map +1 -0
  63. package/dist/tools/hitl.d.ts +4 -0
  64. package/dist/tools/hitl.d.ts.map +1 -0
  65. package/dist/tools/hitl.js +151 -0
  66. package/dist/tools/hitl.js.map +1 -0
  67. package/dist/tools/phones.js +1 -1
  68. package/dist/tools/phones.js.map +1 -1
  69. package/dist/tools/profiles.d.ts.map +1 -1
  70. package/dist/tools/profiles.js +73 -0
  71. package/dist/tools/profiles.js.map +1 -1
  72. package/dist/tools/proof-me.d.ts +4 -0
  73. package/dist/tools/proof-me.d.ts.map +1 -0
  74. package/dist/tools/proof-me.js +107 -0
  75. package/dist/tools/proof-me.js.map +1 -0
  76. package/dist/tools/proofs.d.ts.map +1 -1
  77. package/dist/tools/proofs.js +9 -6
  78. package/dist/tools/proofs.js.map +1 -1
  79. package/dist/tools/render-auth-link.d.ts +3 -0
  80. package/dist/tools/render-auth-link.d.ts.map +1 -0
  81. package/dist/tools/render-auth-link.js +30 -0
  82. package/dist/tools/render-auth-link.js.map +1 -0
  83. package/dist/tools/sessions.js +5 -5
  84. package/dist/tools/sessions.js.map +1 -1
  85. package/dist/tools/settings.d.ts.map +1 -1
  86. package/dist/tools/settings.js +69 -0
  87. package/dist/tools/settings.js.map +1 -1
  88. package/dist/tools/twofa.d.ts.map +1 -1
  89. package/dist/tools/twofa.js +16 -3
  90. package/dist/tools/twofa.js.map +1 -1
  91. package/dist/tools/user-requests.d.ts.map +1 -1
  92. package/dist/tools/user-requests.js +1 -2
  93. package/dist/tools/user-requests.js.map +1 -1
  94. package/dist/tools/verification-requests.d.ts.map +1 -1
  95. package/dist/tools/verification-requests.js +40 -13
  96. package/dist/tools/verification-requests.js.map +1 -1
  97. package/dist/tools/verifications.d.ts.map +1 -1
  98. package/dist/tools/verifications.js +59 -12
  99. package/dist/tools/verifications.js.map +1 -1
  100. package/dist/types.d.ts +18 -0
  101. package/dist/types.d.ts.map +1 -1
  102. package/dist/types.js +114 -5
  103. package/dist/types.js.map +1 -1
  104. package/package.json +11 -5
  105. package/dist/tools/projects.d.ts.map +0 -1
  106. package/dist/tools/projects.js +0 -159
  107. package/dist/tools/projects.js.map +0 -1
@@ -0,0 +1,192 @@
1
+ import { z } from 'zod';
2
+ import { verifyDelegation, verifyPublishedDelegation } from '@proof-holdings/delegation-verifier';
3
+ import { jsonResult, errorResult } from '../types.js';
4
+ import { FAILURE_REASON_OUTCOME } from './delegation-verify-outcomes.js';
5
+ /**
6
+ * The FIRST CONSUMER of the issuer-agnostic reference verifier (m-delegation-verifier-ref).
7
+ *
8
+ * Two things make this tool different from every other tool in this server:
9
+ *
10
+ * 1. It needs no API key. Verifying someone else's delegation is not a customer operation —
11
+ * it runs entirely against public surfaces (the issuer's JWKS, its status list and its
12
+ * public token-status endpoint). An agent evaluating a third-party MCP server can call
13
+ * this before it has an account with anyone.
14
+ * 2. `delegate` AND `expected_principal` are both REQUIRED, and they close two different
15
+ * attacks. `delegate` is the artifact identity the CALLER resolved — the npm package it
16
+ * is about to install, the endpoint it is about to call — never a field copied out of the
17
+ * ARTIFACT being checked, because a published token is a bearer artifact anyone can paste
18
+ * into their own card, and a name in that artifact's own package.json or manifest is just
19
+ * as self-declared as one in its card. The comment used to say "the card" alone; a live
20
+ * agent read `package.json` instead, matched the artifact against itself, and accused a
21
+ * real publisher of acting without authority. The rule now lives in both tool descriptions
22
+ * where an agent can actually read it, not only here.
23
+ *
24
+ * `expected_principal` is the domain the caller expects to stand behind it: an issuer binds
25
+ * `delegate` to nothing, so ANY domain owner can mint a genuine, signature-valid delegation
26
+ * naming someone else's package. Without both pins, a `verified: true` here would mean only
27
+ * "some domain said something about some artifact" — which is what an agent would then act on.
28
+ *
29
+ * The trust policy is stated HERE, explicitly, rather than defaulted inside the library — the
30
+ * library ships with no trust list at all, which is what makes it a verifier rather than a
31
+ * client. This server trusts proof.holdings because it is proof.holdings' own server.
32
+ */
33
+ const delegateTypeEnum = z.enum(['url', 'purl']);
34
+ function proofHoldingsTrust(baseUrl) {
35
+ const origin = baseUrl.replace(/\/+$/, '');
36
+ return {
37
+ issuer: 'proof.holdings',
38
+ jwksUri: `${origin}/.well-known/jwks.json`,
39
+ // The only PUBLIC surface that resolves the control-proof cascade: a delegation is worth
40
+ // no more than the domain proof under it, and the status list carries each row's own bit.
41
+ statusEndpoint: `${origin}/api/v1/proofs/validate`,
42
+ };
43
+ }
44
+ /**
45
+ * The single-artifact verification core, factored out so `verify_delegation` (one item) and
46
+ * `verify_delegations` (a batch of up to 50, h-proof-checker-mcp) share exactly one call into
47
+ * the reference verifier. Callers must already have checked `card` XOR `token` — this function
48
+ * does not, so it stays usable per-item inside a batch loop without duplicating that guard.
49
+ */
50
+ export function verifyOneDelegation(item, baseUrl) {
51
+ const verifyOptions = {
52
+ trustedIssuers: [proofHoldingsTrust(baseUrl)],
53
+ delegate: item.delegate,
54
+ expectedPrincipal: item.expected_principal,
55
+ ...(item.required_scopes ? { requiredScopes: item.required_scopes } : {}),
56
+ statusCheck: item.check_status === false ? 'skip' : 'required',
57
+ };
58
+ return item.card !== undefined
59
+ ? verifyPublishedDelegation(item.card, verifyOptions)
60
+ : verifyDelegation(item.token, verifyOptions);
61
+ }
62
+ export function registerTools(tool, options) {
63
+ tool('verify_delegation', "Verify a Proof of Delegation — the attestation that a domain authorized a specific agent artifact. Pass either the artifact's card (MCP server.json / A2A agent card) or a raw delegation token, PLUS two facts you established yourself: the artifact identity you resolved (the package you are installing, the endpoint you are calling) and the domain you expect to stand behind it. Both are required — a token can be copied into someone else's card, and any domain owner can mint a valid delegation naming someone else's package, so a verdict without both pins would mean 'some domain said something about some artifact'. WHERE THE IDENTITY MAY COME FROM: it is the artifact you are acting on, and never a value read from inside the artifact you are checking. A name in the artifact's own package.json, card or manifest is self-declared and editable by whoever ships it, so checking it against the delegation compares the artifact with itself. Resolve it afresh at call time instead of reusing a value from earlier in this conversation, which may already be stale. When no independently resolvable identity exists — a local or unpublished artifact — you have nothing to compare against, and that is the honest answer: report it rather than a mismatch, because a mismatch here reads as an accusation against the domain named in the delegation. The verifier walks signature → principal → delegate → revocation status, including the cascade down to the domain control proof. Requires no API key. What a verified result means: the expected domain's controller authorized this artifact for these scopes — NOT that the artifact is safe, audited or endorsed.", {
64
+ card: z
65
+ .record(z.unknown())
66
+ .optional()
67
+ .describe('The MCP server card or A2A agent card to read the delegation from'),
68
+ token: z.string().optional().describe('A raw delegation token, when you already have it instead of a card'),
69
+ delegate: z
70
+ .object({
71
+ type: delegateTypeEnum.describe('Identifier type: https URL or package URL (purl)'),
72
+ value: z.string().min(1).max(2048).describe('The artifact identifier YOU resolved — never a value read from inside the artifact you are checking, and resolved afresh rather than carried over from earlier in the conversation'),
73
+ })
74
+ .describe('The artifact identity you resolved independently. Required: this comparison is what defeats a copied token.'),
75
+ expected_principal: z
76
+ .string()
77
+ .min(1)
78
+ .max(253)
79
+ .describe('Required. The domain you expect to have authorized this artifact (e.g. postmarkapp.com) — an issuer binds the artifact to nothing, so any domain owner can mint a valid delegation for someone else\'s package. Without this pin the answer is only "some domain claims this".'),
80
+ required_scopes: z
81
+ .array(z.string().min(1).max(64))
82
+ .min(1)
83
+ .max(32)
84
+ .optional()
85
+ .describe('Capability scopes the delegation must grant'),
86
+ check_status: z
87
+ .boolean()
88
+ .optional()
89
+ .describe('Default true. When false the signature and claims are checked but revocation is NOT — treat the result as "not revoked-checked", never as "not revoked".'),
90
+ }, async (args) => {
91
+ const { card, token, delegate, expected_principal, required_scopes, check_status } = args;
92
+ if ((card === undefined) === (token === undefined)) {
93
+ return errorResult('invalid_arguments: supply exactly one of `card` or `token`');
94
+ }
95
+ try {
96
+ const result = await verifyOneDelegation({ card, token, delegate, expected_principal, required_scopes, check_status }, options.baseUrl);
97
+ if (!result.valid) {
98
+ // A verdict, not a transport failure — returned as data so an agent can branch on
99
+ // the reason instead of parsing an error string.
100
+ return jsonResult({
101
+ verified: false,
102
+ reason: result.reason,
103
+ outcome: result.outcome,
104
+ message: result.message,
105
+ });
106
+ }
107
+ return jsonResult({
108
+ verified: true,
109
+ status_checked: result.statusChecked,
110
+ principal_checked: result.principalChecked,
111
+ attests: `${result.delegation.principal} authorized ${result.delegation.delegate} for: ${result.delegation.scope.join(', ')}`,
112
+ delegation: {
113
+ issuer: result.delegation.issuer,
114
+ principal: result.delegation.principal,
115
+ delegate: result.delegation.delegate,
116
+ scope: result.delegation.scope,
117
+ control_proof: result.delegation.controlProof,
118
+ delegation_id: result.delegation.delegationId,
119
+ issued_at: result.delegation.issuedAt.toISOString(),
120
+ expires_at: result.delegation.expiresAt.toISOString(),
121
+ },
122
+ disclaimer: 'This attests domain authorization of the artifact only. It is not a statement that the artifact is safe, audited or endorsed.',
123
+ });
124
+ }
125
+ catch (e) {
126
+ return errorResult(`verification_failed: ${e instanceof Error ? e.message : String(e)}`);
127
+ }
128
+ });
129
+ const verifyItemSchema = z
130
+ .object({
131
+ card: z
132
+ .record(z.unknown())
133
+ .optional()
134
+ .describe('The MCP server card or A2A agent card to read the delegation from'),
135
+ token: z.string().optional().describe('A raw delegation token, when you already have it instead of a card'),
136
+ delegate: z
137
+ .object({
138
+ type: delegateTypeEnum.describe('Identifier type: https URL or package URL (purl)'),
139
+ value: z.string().min(1).max(2048).describe('The artifact identifier YOU resolved — never a value read from inside the artifact you are checking, and resolved afresh rather than carried over from earlier in the conversation'),
140
+ })
141
+ .describe('The artifact identity you resolved independently. Required: this comparison is what defeats a copied token.'),
142
+ expected_principal: z
143
+ .string()
144
+ .min(1)
145
+ .max(253)
146
+ .describe('Required. The domain you expect to have authorized this artifact (e.g. postmarkapp.com) — an issuer binds the artifact to nothing, so any domain owner can mint a valid delegation for someone else\'s package. Without this pin the answer is only "some domain claims this".'),
147
+ required_scopes: z
148
+ .array(z.string().min(1).max(64))
149
+ .min(1)
150
+ .max(32)
151
+ .optional()
152
+ .describe('Capability scopes the delegation must grant'),
153
+ })
154
+ .refine((item) => (item.card === undefined) !== (item.token === undefined), {
155
+ message: 'each item must supply exactly one of `card` or `token`',
156
+ });
157
+ tool('verify_delegations', 'Batch-verify up to 50 Proof of Delegation artifacts in one call — the inventory half of the checker (h-proof-checker-mcp): re-check everything you already trust instead of one verify_delegation call per artifact. Each item takes the same shape verify_delegation requires (card XOR token, delegate, expected_principal, optional required_scopes) and follows the same rule about where identity comes from: each `delegate` is the artifact you are acting on, never a value read from inside the artifact you are checking, and resolved afresh at call time. Items are verified INDEPENDENTLY — no cross-item state, nothing persisted, one item failing never affects another item\'s result. This tool does NOT discover what you have installed and does NOT fetch anything on your behalf: it verifies material you already hold, the same trust boundary verify_delegation draws. Revocation is always checked (there is no check_status:false here — the point of a batch re-check is to see what changed since you last looked). Each result carries an `outcome`: confirmed_valid (verified), confirmed_invalid (a genuine negative verdict — revoked, expired, mismatched, malformed, and similar), no_claim_found (the artifact publishes no delegation at all — an absence, never an accusation), or unconfirmed (we could not reach the issuer or otherwise get a confident answer right now — NEVER treat this as a bad verdict). Requires no API key. `checked_at` on each result is the moment THAT item\'s own check completed, not one timestamp shared across the call.', {
158
+ items: z.array(verifyItemSchema).min(1).max(50).describe('1-50 artifacts to verify in this call, each shaped like a verify_delegation call'),
159
+ }, async (args) => {
160
+ const results = await Promise.all(args.items.map(async (item) => {
161
+ try {
162
+ const result = await verifyOneDelegation(item, options.baseUrl);
163
+ const checked_at = new Date().toISOString();
164
+ if (result.valid) {
165
+ return {
166
+ outcome: 'confirmed_valid',
167
+ verified: true,
168
+ status_checked: result.statusChecked,
169
+ checked_at,
170
+ };
171
+ }
172
+ return {
173
+ outcome: FAILURE_REASON_OUTCOME[result.reason],
174
+ reason: result.reason,
175
+ message: result.message,
176
+ verified: false,
177
+ checked_at,
178
+ };
179
+ }
180
+ catch (e) {
181
+ return {
182
+ outcome: 'unconfirmed',
183
+ message: `verification_failed: ${e instanceof Error ? e.message : String(e)}`,
184
+ verified: false,
185
+ checked_at: new Date().toISOString(),
186
+ };
187
+ }
188
+ }));
189
+ return jsonResult({ results });
190
+ });
191
+ }
192
+ //# sourceMappingURL=delegation-verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation-verify.js","sourceRoot":"","sources":["../../src/tools/delegation-verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAGlG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjD,SAAS,kBAAkB,CAAC,OAAe;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,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ACJ,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=delegations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegations.d.ts","sourceRoot":"","sources":["../../src/tools/delegations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAajD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QAsFlE"}
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ import { jsonResult, errorResult } from '../types.js';
3
+ import { ApiError } from '../http.js';
4
+ // Mongo ObjectId OR the public ph_dlg_* handle — mirrors delegationIdParamSchema
5
+ // in the backend validators (this package cannot import backend src/).
6
+ const DELEGATION_ID_REGEX = /^([0-9a-fA-F]{24}|ph_dlg_[a-f0-9]{32})$/;
7
+ const CONTROL_PROOF_REGEX = /^ph_ctl_[a-f0-9]{32}$/;
8
+ const delegateTypeEnum = z.enum(['url', 'purl']);
9
+ const delegationStatusEnum = z.enum(['active', 'revoked']);
10
+ const revokeReasonEnum = z.enum(['user_request', 'fraud', 'key_compromise', 'other']);
11
+ export function registerTools(tool, http) {
12
+ tool('create_delegation', 'Create a delegation (Proof of Delegation): a control-proven domain authorizes a typed url/purl artifact for a set of capability scopes and receives a publishable signed token. The attestation is that the domain\'s controller authorized this artifact — nothing more; it says nothing about the artifact or the business behind it. Each mint is a billable proof. A requested lifetime longer than the control proof\'s remainder is rejected, never truncated. The result carries the publishable token AND the DERIVED effective_status/is_valid — the same pair the list and get tools return, so the shape does not depend on which verb produced it.', {
13
+ control_proof: z.string().regex(CONTROL_PROOF_REGEX).describe('Public handle (ph_ctl_<32 hex>) of YOUR active domain control proof'),
14
+ delegate: z.object({
15
+ type: delegateTypeEnum.describe('Identifier type: https URL or package URL (purl)'),
16
+ value: z.string().min(1).max(2048).describe('The artifact identifier (canonicalized server-side)'),
17
+ }).describe('The typed artifact being authorized'),
18
+ scope: z.array(z.string().min(1).max(64)).min(1).max(32).describe('1-32 capability scopes: lowercase kebab-case tokens, at most 64 characters each (e.g. send-email). NOT API scopes — an API-style resource:action such as payments:read is rejected with invalid_scope.'),
19
+ expires_in: z.number().int().positive().max(10 * 365 * 24 * 3600).optional().describe('Lifetime in seconds (must not exceed the control proof\'s remainder)'),
20
+ }, async (args) => {
21
+ try {
22
+ const result = await http.post('/api/v1/delegations', 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_delegations', 'List your own delegations with optional filters. Each item carries the DERIVED effective_status/is_valid beside its stored status — read effective_status, since status records only whether the owner revoked the delegation themselves, so a delegation still reads active there after its domain control proof was revoked, suspended or expired, and after its OWN lifetime ran out. effective_status accounts for all of those: it reports expired once either lifetime has passed, whichever is earlier. Tokens are not included in the list — use get_delegation for the stored token. There is no public enumeration of third-party delegations.', {
32
+ status: delegationStatusEnum
33
+ .optional()
34
+ .describe("Filter by the delegation's OWN stored status (active|revoked). Does NOT filter the derived effective_status — status=active still returns delegations whose control proof died, and ones that simply ran out."),
35
+ page: z.number().int().positive().optional().describe('Page number'),
36
+ limit: z.number().int().min(1).max(100).optional().describe('Items per page'),
37
+ }, async (args) => {
38
+ try {
39
+ const query = {};
40
+ if (args.status !== undefined)
41
+ query.status = args.status;
42
+ if (args.page !== undefined)
43
+ query.page = args.page;
44
+ if (args.limit !== undefined)
45
+ query.limit = args.limit;
46
+ const result = await http.get('/api/v1/delegations', query);
47
+ return jsonResult(result);
48
+ }
49
+ catch (e) {
50
+ if (e instanceof ApiError)
51
+ return errorResult(`${e.code}: ${e.message}`);
52
+ throw e;
53
+ }
54
+ });
55
+ tool('get_delegation', 'Get one of your delegations by Mongo id or ph_dlg_* handle. Returns the stored publishable token plus the DERIVED effective_status/is_valid — the delegation is only as live as the control proof it stands on (a revoked, suspended or expired domain proof invalidates it) and never outlives its own expires_at, whichever comes first.', {
56
+ id: z.string().regex(DELEGATION_ID_REGEX).describe('Delegation ID (24-hex Mongo id or ph_dlg_<32 hex> handle)'),
57
+ }, async ({ id }) => {
58
+ try {
59
+ const result = await http.get(`/api/v1/delegations/${encodeURIComponent(id)}`);
60
+ return jsonResult(result);
61
+ }
62
+ catch (e) {
63
+ if (e instanceof ApiError)
64
+ return errorResult(`${e.code}: ${e.message}`);
65
+ throw e;
66
+ }
67
+ });
68
+ tool('revoke_delegation', 'Revoke ONE delegation. The domain control proof and sibling delegations stay valid; the revocation is mirrored into the proof registry so the CRL, status list and public status lookup all see it. Idempotent: a repeat revoke answers success with the same body, both here and through revoke_proof with the ph_dlg_ handle — unlike a PROOF, where a repeat answers already_revoked. The result carries the DERIVED effective_status/is_valid beside the stored status.', {
69
+ id: z.string().regex(DELEGATION_ID_REGEX).describe('Delegation ID (24-hex Mongo id or ph_dlg_<32 hex> handle)'),
70
+ reason: revokeReasonEnum.optional().describe('Reason for revocation'),
71
+ }, async ({ id, reason }) => {
72
+ try {
73
+ const body = reason !== undefined ? { reason } : undefined;
74
+ const result = await http.post(`/api/v1/delegations/${encodeURIComponent(id)}/revoke`, body);
75
+ return jsonResult(result);
76
+ }
77
+ catch (e) {
78
+ if (e instanceof ApiError)
79
+ return errorResult(`${e.code}: ${e.message}`);
80
+ throw e;
81
+ }
82
+ });
83
+ }
84
+ //# sourceMappingURL=delegations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegations.js","sourceRoot":"","sources":["../../src/tools/delegations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC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,2DAA2D,CAAC;QAC/G,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;KACtE,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC3D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,uBAAuB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC7F,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../src/tools/domains.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAYjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QAmSlE"}
1
+ {"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../src/tools/domains.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAYjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QAkSlE"}
@@ -19,9 +19,8 @@ export function registerTools(tool, http) {
19
19
  throw e;
20
20
  }
21
21
  });
22
- tool('add_domain', 'Add a new domain to verify ownership. Optionally specify a project, email sending intent, and verification method.', {
22
+ tool('add_domain', 'Add a new domain to verify ownership. Optionally specify email sending intent and verification method.', {
23
23
  domain: z.string().min(1).max(255).describe('Domain name to add (e.g. example.com)'),
24
- project_id: z.string().optional().describe('Project ID to associate the domain with'),
25
24
  for_email_sending: z.boolean().optional().describe('Whether this domain is for email sending'),
26
25
  verification_method: z.enum(['auto_dns', 'manual_dns', 'http_file', 'email']).optional().describe('Preferred verification method'),
27
26
  }, async (args) => {
@@ -1 +1 @@
1
- {"version":3,"file":"domains.js","sourceRoot":"","sources":["../../src/tools/domains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAEpG,MAAM,iBAAiB,GAAG;IACxB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;IACpC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IACvE,WAAW,EAAE,iBAAiB;CAC/B,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAmB,EAAE,IAAgB;IACjE,IAAI,CACF,cAAc,EACd,wGAAwG,EACxG,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACp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AAC,cAAc,EAAE,IAAI,CAAC,CAAC;YACjG,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;IAEF,IAAI,CACF,2BAA2B,EAC3B,iGAAiG,EACjG;QACE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;KACrC,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QACf,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,sBAAsB,kBAAkB,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;YAC3F,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=hitl-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hitl-keys.d.ts","sourceRoot":"","sources":["../../src/tools/hitl-keys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QA0DlE"}
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import { jsonResult, errorResult } from '../types.js';
3
+ import { ApiError } from '../http.js';
4
+ export function registerTools(tool, http) {
5
+ tool('get_hitl_keys', 'Get the encryption keypair for a HITL config. Returns public key, encrypted private key, KDF salt, and key ID (kid).', {
6
+ hitl_id: z.string().describe('HITL config ID'),
7
+ }, async ({ hitl_id }) => {
8
+ try {
9
+ const result = await http.get(`/api/v1/hitl/${encodeURIComponent(hitl_id)}/keys`);
10
+ return jsonResult(result);
11
+ }
12
+ catch (e) {
13
+ if (e instanceof ApiError)
14
+ return errorResult(`${e.code}: ${e.message}`);
15
+ throw e;
16
+ }
17
+ });
18
+ tool('upload_hitl_keys', 'Upload an encryption keypair for a HITL config. The server validates the RSA-4096 public key and computes the key ID. Note: the encrypted_private_key is already encrypted client-side with the user\'s password — the server never sees the password.', {
19
+ hitl_id: z.string().describe('HITL config ID'),
20
+ public_key: z.string().describe('PEM-encoded RSA-4096 SPKI public key'),
21
+ encrypted_private_key: z.string().describe('JSON-serialized encrypted private key envelope (PBKDF2-SHA256+AES-256-GCM)'),
22
+ kdf_salt: z.string().describe('Base64url-encoded PBKDF2 salt'),
23
+ }, async ({ hitl_id, public_key, encrypted_private_key, kdf_salt }) => {
24
+ try {
25
+ const result = await http.put(`/api/v1/hitl/${encodeURIComponent(hitl_id)}/keys`, {
26
+ public_key,
27
+ encrypted_private_key,
28
+ kdf_salt,
29
+ });
30
+ return jsonResult(result);
31
+ }
32
+ catch (e) {
33
+ if (e instanceof ApiError)
34
+ return errorResult(`${e.code}: ${e.message}`);
35
+ throw e;
36
+ }
37
+ });
38
+ tool('delete_hitl_keys', 'Delete the encryption keypair from a HITL config. WARNING: Existing ciphertexts will become permanently unreadable.', {
39
+ hitl_id: z.string().describe('HITL config ID'),
40
+ }, async ({ hitl_id }) => {
41
+ try {
42
+ const result = await http.del(`/api/v1/hitl/${encodeURIComponent(hitl_id)}/keys`);
43
+ return jsonResult(result);
44
+ }
45
+ catch (e) {
46
+ if (e instanceof ApiError)
47
+ return errorResult(`${e.code}: ${e.message}`);
48
+ throw e;
49
+ }
50
+ });
51
+ }
52
+ //# sourceMappingURL=hitl-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hitl-keys.js","sourceRoot":"","sources":["../../src/tools/hitl-keys.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,UAAU,aAAa,CAAC,IAAmB,EAAE,IAAgB;IACjE,IAAI,CACF,eAAe,EACf,sHAAsH,EACtH;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;KAC/C,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACpB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,gBAAgB,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAClF,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;IAEF,IAAI,CACF,kBAAkB,EAClB,wPAAwP,EACxP;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC9C,UAAU,EAAE,CAAC,CAAC,MAAM,EA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ACzE,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=hitl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hitl.d.ts","sourceRoot":"","sources":["../../src/tools/hitl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwBjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,QAyKlE"}
@@ -0,0 +1,151 @@
1
+ import { z } from 'zod';
2
+ import { jsonResult, errorResult, pollUntilTerminal, BSUID_REGEX, WAIT_DEFAULT_SECONDS } from '../types.js';
3
+ import { ApiError } from '../http.js';
4
+ const hitlStatusEnum = z.enum(['active', 'archived']);
5
+ const telegramChannelConfig = z.object({
6
+ type: z.literal('telegram'),
7
+ config: z.object({ chat_id: z.string().min(1).max(50) }),
8
+ });
9
+ const whatsappChannelConfig = z.object({
10
+ type: z.literal('whatsapp'),
11
+ config: z.object({
12
+ phone_number: z.string().regex(/^\+?[1-9]\d{6,14}$/).optional().describe('Phone number in E.164 format'),
13
+ bsuid: z.string().regex(BSUID_REGEX).optional().describe('WhatsApp Business-Scoped User ID (e.g. US.abc123...)'),
14
+ }).refine((data) => data.phone_number || data.bsuid, { message: 'At least one of phone_number or bsuid is required' }),
15
+ });
16
+ const hitlChannelSchema = z.discriminatedUnion('type', [telegramChannelConfig, whatsappChannelConfig]);
17
+ export function registerTools(tool, http) {
18
+ tool('create_hitl', 'Create a HITL (Human-in-the-Loop) config. Defines which messaging channels receive approval requests and the default timeout.\n\nAgent usage: After creating a HITL config, you must call request_hitl_authorization before it can be used with create_confirmation. For Telegram channels, use create_chat_id_discovery first to discover the user\'s chat ID, then include it in the channel config.', {
19
+ name: z.string().min(1).max(200).describe('Human-readable name for this HITL config'),
20
+ channels: z.array(hitlChannelSchema).min(1).describe('Messaging channels for approval requests (telegram or whatsapp)'),
21
+ timeout_seconds: z.number().int().min(60).max(86400).optional().describe('Default timeout in seconds (60–86400, default: 3600)'),
22
+ }, async (args) => {
23
+ try {
24
+ const result = await http.post('/api/v1/hitl', args);
25
+ return jsonResult(result);
26
+ }
27
+ catch (e) {
28
+ if (e instanceof ApiError)
29
+ return errorResult(`${e.code}: ${e.message}`);
30
+ throw e;
31
+ }
32
+ });
33
+ tool('get_hitl', 'Get a HITL config by ID. Returns the config including channels, timeout, and status.', {
34
+ id: z.string().describe('HITL config ID'),
35
+ }, async ({ id }) => {
36
+ try {
37
+ const result = await http.get(`/api/v1/hitl/${encodeURIComponent(id)}`);
38
+ return jsonResult(result);
39
+ }
40
+ catch (e) {
41
+ if (e instanceof ApiError)
42
+ return errorResult(`${e.code}: ${e.message}`);
43
+ throw e;
44
+ }
45
+ });
46
+ tool('list_hitls', 'List HITL configs with optional filters. Returns paginated results.', {
47
+ status: hitlStatusEnum.optional().describe('Filter by status (active or archived)'),
48
+ environment: z.enum(['production', 'test']).optional().describe('Filter by environment (production or test)'),
49
+ page: z.number().int().positive().optional().describe('Page number'),
50
+ limit: z.number().int().min(1).max(100).optional().describe('Items per page'),
51
+ }, async (args) => {
52
+ try {
53
+ const query = {};
54
+ if (args.status !== undefined)
55
+ query.status = args.status;
56
+ if (args.environment !== undefined)
57
+ query.environment = args.environment;
58
+ if (args.page !== undefined)
59
+ query.page = args.page;
60
+ if (args.limit !== undefined)
61
+ query.limit = args.limit;
62
+ const result = await http.get('/api/v1/hitl', query);
63
+ return jsonResult(result);
64
+ }
65
+ catch (e) {
66
+ if (e instanceof ApiError)
67
+ return errorResult(`${e.code}: ${e.message}`);
68
+ throw e;
69
+ }
70
+ });
71
+ tool('update_hitl', 'Update a HITL config. Can change name, channels, or timeout.', {
72
+ id: z.string().describe('HITL config ID'),
73
+ name: z.string().min(1).max(200).nullable().optional().describe('New name (null to clear)'),
74
+ channels: z.array(hitlChannelSchema).min(1).optional().describe('Updated channels'),
75
+ timeout_seconds: z.number().int().min(60).max(86400).optional().describe('Updated timeout in seconds (60–86400)'),
76
+ }, async ({ id, ...body }) => {
77
+ try {
78
+ const result = await http.patch(`/api/v1/hitl/${encodeURIComponent(id)}`, body);
79
+ return jsonResult(result);
80
+ }
81
+ catch (e) {
82
+ if (e instanceof ApiError)
83
+ return errorResult(`${e.code}: ${e.message}`);
84
+ throw e;
85
+ }
86
+ });
87
+ tool('delete_hitl', 'Delete (archive) a HITL config. Sets status to archived. Cannot be used for new confirmations after deletion.', {
88
+ id: z.string().describe('HITL config ID to delete'),
89
+ }, async ({ id }) => {
90
+ try {
91
+ const result = await http.del(`/api/v1/hitl/${encodeURIComponent(id)}`);
92
+ return jsonResult(result);
93
+ }
94
+ catch (e) {
95
+ if (e instanceof ApiError)
96
+ return errorResult(`${e.code}: ${e.message}`);
97
+ throw e;
98
+ }
99
+ });
100
+ tool('request_hitl_authorization', 'Request authorization for a HITL config. Sends consent requests to all configured channels (Telegram/WhatsApp). Users must approve before confirmations can be sent.\n\nAgent usage: This must be completed before create_confirmation will work for this HITL config. The consent request is DELIVERED to each channel — the response carries no link to show. It returns `authorizations` — one entry per resolved recipient, each with its `channel`, `recipient`, `authorization_id` and `status` — plus a `message`. Read the entries rather than assuming: `status: \'pending\'` means consent was just sent and the user must approve in Telegram/WhatsApp itself, while `status: \'active\'` means that recipient had already authorized and nothing was sent to them. An EMPTY array does not mean everyone is authorized — it means no recipient could be resolved at all (usually a HITL config bound to a missing or inactive circle, or channels whose recipient is blank), so nobody was asked and waiting for an approval would hang forever. Do not relay `message` on that branch: it reads \'All channels already have active or pending authorizations\', which is exactly the wrong conclusion. Read the array. After requesting, you can proceed once the user confirms they have approved.', {
101
+ id: z.string().describe('HITL config ID to request authorization for'),
102
+ }, async ({ id }) => {
103
+ try {
104
+ const result = await http.post(`/api/v1/hitl/${encodeURIComponent(id)}/authorize`, {});
105
+ return jsonResult(result);
106
+ }
107
+ catch (e) {
108
+ if (e instanceof ApiError)
109
+ return errorResult(`${e.code}: ${e.message}`);
110
+ throw e;
111
+ }
112
+ });
113
+ tool('create_chat_id_discovery', 'Create a Telegram chat ID discovery token. Returns a deep_link, qr_code (base64 PNG), and qr_text (UTF-8 text QR for terminal display). The user opens the link in Telegram, which reveals their chat ID for HITL config setup.\n\nAgent usage: pass the response\'s `deep_link` to render_auth_link so the user can click or scan it. Never hand `qr_text` to a link renderer — it is that same link already rendered as QR art. Print it verbatim inside a fenced code block only when a real terminal needs the QR. Then poll poll_chat_id_discovery with the returned token until the chat_id appears. Use the discovered chat_id when creating a HITL config with a Telegram channel.', {}, async () => {
114
+ try {
115
+ const result = await http.post('/api/v1/hitl/chat-id-discovery', {});
116
+ return jsonResult(result);
117
+ }
118
+ catch (e) {
119
+ if (e instanceof ApiError)
120
+ return errorResult(`${e.code}: ${e.message}`);
121
+ throw e;
122
+ }
123
+ });
124
+ tool('poll_chat_id_discovery', 'Poll a chat ID discovery token. Returns the discovered Telegram chat ID, user ID, and username once the user interacts with the bot.', {
125
+ token: z.string().describe('Discovery token from create_chat_id_discovery'),
126
+ }, async ({ token }) => {
127
+ try {
128
+ const result = await http.get(`/api/v1/hitl/chat-id-discovery/${encodeURIComponent(token)}`);
129
+ return jsonResult(result);
130
+ }
131
+ catch (e) {
132
+ if (e instanceof ApiError)
133
+ return errorResult(`${e.code}: ${e.message}`);
134
+ throw e;
135
+ }
136
+ });
137
+ tool('wait_for_chat_id_discovery', 'Poll a chat ID discovery token until the user interacts with the Telegram bot. Uses exponential backoff (2s initial, 1.5x, 30s max) with jitter.\n\nAgent usage: Call this after create_chat_id_discovery. Present the discovery response\'s `deep_link` with render_auth_link first, then poll with the returned token. Terminal states: "completed" (chat_id discovered — use it when creating a HITL config with a Telegram channel), "expired". While "pending", the user has not yet opened the Telegram link.', {
138
+ token: z.string().describe('Discovery token from create_chat_id_discovery'),
139
+ 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.`),
140
+ }, async ({ token, timeout_seconds }) => {
141
+ try {
142
+ return await pollUntilTerminal(() => http.get(`/api/v1/hitl/chat-id-discovery/${encodeURIComponent(token)}`), ['completed', 'expired'], timeout_seconds ?? WAIT_DEFAULT_SECONDS, `chat ID discovery ${token}`);
143
+ }
144
+ catch (e) {
145
+ if (e instanceof ApiError)
146
+ return errorResult(`${e.code}: ${e.message}`);
147
+ throw e;
148
+ }
149
+ });
150
+ }
151
+ //# sourceMappingURL=hitl.js.map