@sendora/mcp 1.3.3 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/errors.js CHANGED
@@ -17,8 +17,13 @@ const capOwner = {
17
17
  */
18
18
  const hints = {
19
19
  invalid_request: null,
20
- unauthorized: () => `The key was revoked or mistyped. A server key is made under its server in the dashboard, ${KEYS_PAGE}, and an account key by an administrator under Account › API keys (Konto › API-nycklar), ${ACCOUNT_KEYS_PAGE}; restart the connection with the new one.`,
20
+ unauthorized: (_error, connection) => connection.kind === 'grant'
21
+ ? `This connection has ended, or the person who approved it may no longer open this server. They see their connections under Account › Connected apps (Konto › Anslutna appar), ${DASHBOARD}/account/apps, and can connect the app again.`
22
+ : `The key was revoked or mistyped. A server key is made under its server in the dashboard, ${KEYS_PAGE}, and an account key by an administrator under Account › API keys (Konto › API-nycklar), ${ACCOUNT_KEYS_PAGE}; restart the connection with the new one.`,
21
23
  wrong_token_kind: null,
24
+ not_for_connections: null,
25
+ read_only_connection: () => 'The person approved this connection without changes on live servers, and the account is read only through a connection. They can connect again and tick "Tillåt ändringar på liveservrar" on the approval page, or the change can be made on a test server.',
26
+ test_server_only: () => 'Through a connected app, keys, webhooks and what cannot be undone happen on test servers only. Make the change on a test server, or in the dashboard.',
22
27
  payment_required: null,
23
28
  account_paused: null,
24
29
  account_not_active: null,
@@ -41,7 +46,9 @@ const hints = {
41
46
  server_reserved: null,
42
47
  server_in_flight: null,
43
48
  request_too_large: null,
44
- from_domain_not_verified: () => `The from address's domain must be one of the account's sending domains that get_server lists as sendingDomains. To add one, which is the account's and not a server's: with the account key, add_domain adds it and answers the DNS records to publish, and check_domain looks them up; or an administrator adds it under Domains (Domäner) in the dashboard, ${DASHBOARD}/domains.`,
49
+ from_domain_not_verified: (_error, connection) => connection.kind === 'grant'
50
+ ? `The from address's domain must be one of the account's sending domains that get_server lists as sendingDomains. An administrator adds one, which is the account's and not a server's, under Domains (Domäner) in the dashboard, ${DASHBOARD}/domains.`
51
+ : `The from address's domain must be one of the account's sending domains that get_server lists as sendingDomains. To add one, which is the account's and not a server's: with the account key, add_domain adds it and answers the DNS records to publish, and check_domain looks them up; or an administrator adds it under Domains (Domäner) in the dashboard, ${DASHBOARD}/domains.`,
45
52
  stream_not_found: null,
46
53
  stream_archived: null,
47
54
  stream_paused: null,
@@ -54,7 +61,9 @@ const hints = {
54
61
  content_expired: null,
55
62
  content_unreadable: null,
56
63
  recipient_suppressed: (error) => `${error.suppressed.map(({ address, reason }) => `${address} (${reason})`).join(', ')} ${error.suppressed.length === 1 ? 'is' : 'are'} on the stream's suppression list, which list_suppressions reads. A hard bounce or a manual suppression can be lifted with remove_suppression, or under the stream's Suppressions (Spärrlista) in the dashboard; a spam complaint or an unsubscribe cannot, since the recipient asked.`,
57
- test_address_on_live_server: () => 'The addresses at simulator.sendora.se act out outcomes on a test server only, and a live server refuses them: send to them with a test server key (sk_test_).',
64
+ test_address_on_live_server: (_error, connection) => connection.kind === 'grant'
65
+ ? 'The addresses at simulator.sendora.se act out outcomes on a test server only, and a live server refuses them: send to them from a test server this connection reaches, named in server.'
66
+ : 'The addresses at simulator.sendora.se act out outcomes on a test server only, and a live server refuses them: send to them with a test server key (sk_test_).',
58
67
  mode_immutable: null,
59
68
  stream_kind_not_allowed: null,
60
69
  idempotency_key_mismatch: null,
@@ -68,22 +77,23 @@ const hints = {
68
77
  invalid_signature: null,
69
78
  stale_signature: null,
70
79
  };
71
- /** The hint for a refusal, or undefined when the API's message says all there is. */
72
- export function hintFor(error) {
80
+ /** The hint for a refusal on this connection, or undefined when the API's message says all there is. */
81
+ export function hintFor(error, connection) {
73
82
  const hint = hints[error.code];
74
- return hint === null ? undefined : hint(error);
83
+ return hint === null ? undefined : hint(error, connection);
75
84
  }
76
85
  /**
77
86
  * A refusal from the API as a tool's error (docs/design/mcp.md §7), which
78
87
  * the model reads and can act on: the code, the API's message and the next
79
- * step, with the error's fields as the SDK has them. Anything that is not a
80
- * `SendoraError` is the server's own fault and is thrown.
88
+ * step on this connection, with the error's fields as the SDK has them.
89
+ * Anything that is not a `SendoraError` is the server's own fault and is
90
+ * thrown.
81
91
  */
82
- export function toolError(error) {
92
+ export function toolError(error, connection) {
83
93
  if (!(error instanceof SendoraError)) {
84
94
  throw error;
85
95
  }
86
- const hint = hintFor(error);
96
+ const hint = hintFor(error, connection);
87
97
  return {
88
98
  content: [
89
99
  {