@raytio/mcp-server 10.1.0 → 10.3.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 (127) hide show
  1. package/contracts/persist/mcp_resource_contract.json +4 -4
  2. package/dist/authorization.d.ts.map +1 -1
  3. package/dist/authorization.js +4 -0
  4. package/dist/authorization.js.map +1 -1
  5. package/dist/generated-reads/guardrails.js +1 -1
  6. package/dist/generated-reads/guardrails.js.map +1 -1
  7. package/dist/generated-reads/resource-tools.d.ts.map +1 -1
  8. package/dist/generated-reads/resource-tools.js +8 -5
  9. package/dist/generated-reads/resource-tools.js.map +1 -1
  10. package/dist/tools/_shared/side-effect.js +2 -2
  11. package/dist/tools/_shared/side-effect.js.map +1 -1
  12. package/dist/tools/_shared/soft-deactivate.d.ts +2 -0
  13. package/dist/tools/_shared/soft-deactivate.d.ts.map +1 -1
  14. package/dist/tools/_shared/soft-deactivate.js +3 -0
  15. package/dist/tools/_shared/soft-deactivate.js.map +1 -1
  16. package/dist/tools/domains.d.ts.map +1 -1
  17. package/dist/tools/domains.js +36 -0
  18. package/dist/tools/domains.js.map +1 -1
  19. package/dist/tools/imports/index.d.ts +6 -6
  20. package/dist/tools/ixn/generated-reads.d.ts +5 -0
  21. package/dist/tools/ixn/generated-reads.d.ts.map +1 -0
  22. package/dist/tools/ixn/generated-reads.js +29 -0
  23. package/dist/tools/ixn/generated-reads.js.map +1 -0
  24. package/dist/tools/ixn/index.d.ts +5 -0
  25. package/dist/tools/ixn/index.d.ts.map +1 -0
  26. package/dist/tools/ixn/index.js +8 -0
  27. package/dist/tools/ixn/index.js.map +1 -0
  28. package/dist/tools/ixn/ixn-conversation-start.d.ts +22 -0
  29. package/dist/tools/ixn/ixn-conversation-start.d.ts.map +1 -0
  30. package/dist/tools/ixn/ixn-conversation-start.js +98 -0
  31. package/dist/tools/ixn/ixn-conversation-start.js.map +1 -0
  32. package/dist/tools/ixn/ixn-message-send.d.ts +28 -0
  33. package/dist/tools/ixn/ixn-message-send.d.ts.map +1 -0
  34. package/dist/tools/ixn/ixn-message-send.js +92 -0
  35. package/dist/tools/ixn/ixn-message-send.js.map +1 -0
  36. package/dist/tools/pbm/generated-reads.d.ts +5 -0
  37. package/dist/tools/pbm/generated-reads.d.ts.map +1 -0
  38. package/dist/tools/pbm/generated-reads.js +32 -0
  39. package/dist/tools/pbm/generated-reads.js.map +1 -0
  40. package/dist/tools/pbm/index.d.ts +5 -0
  41. package/dist/tools/pbm/index.d.ts.map +1 -0
  42. package/dist/tools/pbm/index.js +17 -0
  43. package/dist/tools/pbm/index.js.map +1 -0
  44. package/dist/tools/pbm/pbm-customer-entitlement-override-set.d.ts +26 -0
  45. package/dist/tools/pbm/pbm-customer-entitlement-override-set.d.ts.map +1 -0
  46. package/dist/tools/pbm/pbm-customer-entitlement-override-set.js +78 -0
  47. package/dist/tools/pbm/pbm-customer-entitlement-override-set.js.map +1 -0
  48. package/dist/tools/pbm/pbm-subscription-cancel.d.ts +21 -0
  49. package/dist/tools/pbm/pbm-subscription-cancel.d.ts.map +1 -0
  50. package/dist/tools/pbm/pbm-subscription-cancel.js +86 -0
  51. package/dist/tools/pbm/pbm-subscription-cancel.js.map +1 -0
  52. package/dist/tools/pbm/pbm-subscription-create.d.ts +20 -0
  53. package/dist/tools/pbm/pbm-subscription-create.d.ts.map +1 -0
  54. package/dist/tools/pbm/pbm-subscription-create.js +90 -0
  55. package/dist/tools/pbm/pbm-subscription-create.js.map +1 -0
  56. package/dist/tools/pbm/pbm-subscription-line-add.d.ts +13 -0
  57. package/dist/tools/pbm/pbm-subscription-line-add.d.ts.map +1 -0
  58. package/dist/tools/pbm/pbm-subscription-line-add.js +65 -0
  59. package/dist/tools/pbm/pbm-subscription-line-add.js.map +1 -0
  60. package/dist/tools/pbm/pbm-subscription-line-end.d.ts +12 -0
  61. package/dist/tools/pbm/pbm-subscription-line-end.d.ts.map +1 -0
  62. package/dist/tools/pbm/pbm-subscription-line-end.js +49 -0
  63. package/dist/tools/pbm/pbm-subscription-line-end.js.map +1 -0
  64. package/dist/tools/qom/generated-reads.d.ts +5 -0
  65. package/dist/tools/qom/generated-reads.d.ts.map +1 -0
  66. package/dist/tools/qom/generated-reads.js +22 -0
  67. package/dist/tools/qom/generated-reads.js.map +1 -0
  68. package/dist/tools/qom/index.d.ts +5 -0
  69. package/dist/tools/qom/index.d.ts.map +1 -0
  70. package/dist/tools/qom/index.js +23 -0
  71. package/dist/tools/qom/index.js.map +1 -0
  72. package/dist/tools/qom/qom-order-cancel.d.ts +16 -0
  73. package/dist/tools/qom/qom-order-cancel.d.ts.map +1 -0
  74. package/dist/tools/qom/qom-order-cancel.js +56 -0
  75. package/dist/tools/qom/qom-order-cancel.js.map +1 -0
  76. package/dist/tools/qom/qom-order-create.d.ts +24 -0
  77. package/dist/tools/qom/qom-order-create.d.ts.map +1 -0
  78. package/dist/tools/qom/qom-order-create.js +133 -0
  79. package/dist/tools/qom/qom-order-create.js.map +1 -0
  80. package/dist/tools/qom/qom-order-hold-place.d.ts +11 -0
  81. package/dist/tools/qom/qom-order-hold-place.d.ts.map +1 -0
  82. package/dist/tools/qom/qom-order-hold-place.js +50 -0
  83. package/dist/tools/qom/qom-order-hold-place.js.map +1 -0
  84. package/dist/tools/qom/qom-order-hold-release.d.ts +8 -0
  85. package/dist/tools/qom/qom-order-hold-release.d.ts.map +1 -0
  86. package/dist/tools/qom/qom-order-hold-release.js +42 -0
  87. package/dist/tools/qom/qom-order-hold-release.js.map +1 -0
  88. package/dist/tools/qom/qom-order-line-add.d.ts +18 -0
  89. package/dist/tools/qom/qom-order-line-add.d.ts.map +1 -0
  90. package/dist/tools/qom/qom-order-line-add.js +101 -0
  91. package/dist/tools/qom/qom-order-line-add.js.map +1 -0
  92. package/dist/tools/qom/qom-quote-create.d.ts +20 -0
  93. package/dist/tools/qom/qom-quote-create.d.ts.map +1 -0
  94. package/dist/tools/qom/qom-quote-create.js +142 -0
  95. package/dist/tools/qom/qom-quote-create.js.map +1 -0
  96. package/dist/tools/qom/qom-quote-line-add.d.ts +13 -0
  97. package/dist/tools/qom/qom-quote-line-add.d.ts.map +1 -0
  98. package/dist/tools/qom/qom-quote-line-add.js +92 -0
  99. package/dist/tools/qom/qom-quote-line-add.js.map +1 -0
  100. package/dist/tools/qom/qom-quote-version-create.d.ts +10 -0
  101. package/dist/tools/qom/qom-quote-version-create.d.ts.map +1 -0
  102. package/dist/tools/qom/qom-quote-version-create.js +69 -0
  103. package/dist/tools/qom/qom-quote-version-create.js.map +1 -0
  104. package/dist/tools/role-mapping.d.ts.map +1 -1
  105. package/dist/tools/role-mapping.js +21 -8
  106. package/dist/tools/role-mapping.js.map +1 -1
  107. package/dist/tools/xrm/generated-reads.d.ts +5 -0
  108. package/dist/tools/xrm/generated-reads.d.ts.map +1 -0
  109. package/dist/tools/xrm/generated-reads.js +37 -0
  110. package/dist/tools/xrm/generated-reads.js.map +1 -0
  111. package/dist/tools/xrm/index.d.ts +5 -0
  112. package/dist/tools/xrm/index.d.ts.map +1 -0
  113. package/dist/tools/xrm/index.js +13 -0
  114. package/dist/tools/xrm/index.js.map +1 -0
  115. package/dist/tools/xrm/xrm-inbound-email-rule-create.d.ts +21 -0
  116. package/dist/tools/xrm/xrm-inbound-email-rule-create.d.ts.map +1 -0
  117. package/dist/tools/xrm/xrm-inbound-email-rule-create.js +85 -0
  118. package/dist/tools/xrm/xrm-inbound-email-rule-create.js.map +1 -0
  119. package/dist/tools/xrm/xrm-merchant-create.d.ts +22 -0
  120. package/dist/tools/xrm/xrm-merchant-create.d.ts.map +1 -0
  121. package/dist/tools/xrm/xrm-merchant-create.js +85 -0
  122. package/dist/tools/xrm/xrm-merchant-create.js.map +1 -0
  123. package/dist/tools/xrm/xrm-merchant-update.d.ts +14 -0
  124. package/dist/tools/xrm/xrm-merchant-update.d.ts.map +1 -0
  125. package/dist/tools/xrm/xrm-merchant-update.js +61 -0
  126. package/dist/tools/xrm/xrm-merchant-update.js.map +1 -0
  127. package/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ import { z } from 'zod';
2
+ import { API_ERROR, errorResponse, successResponse } from '../types.js';
3
+ import { cap } from '../../capabilities/tool-capability.js';
4
+ import { confirmFlagSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * State-change semantic tool: open a new interaction conversation
7
+ * (`ixn_conversations`). Starting a conversation binds a channel
8
+ * endpoint / queue to a work-item, lead, or deal, so the tool
9
+ * requires:
10
+ *
11
+ * - `confirm: true` to prevent accidental invocation;
12
+ * - a `channel_endpoint_id` (the outbound / inbound channel this
13
+ * thread is being opened on) — required by the pinned contract.
14
+ *
15
+ * Only `thread_id` protects a retry: (channel_endpoint_id, thread_id,
16
+ * tenant_id) is unique, so a repeat fails with a duplicate-key error.
17
+ * Without it each call opens another conversation, so the tool is not
18
+ * idempotent by default.
19
+ *
20
+ * `ixn_queues` is EXCLUDED from the MCP surface by the queue
21
+ * guardrail; queue routing is a persist-side concern and callers
22
+ * reference the queue by id only.
23
+ */
24
+ export const ixnConversationStartTool = {
25
+ name: 'ixn_conversation_start',
26
+ description: 'Start a new interaction conversation (ixn_conversations) on a channel endpoint. ' +
27
+ 'Requires confirm=true and a channel_endpoint_id. With thread_id, a retry on the same ' +
28
+ 'channel endpoint fails with a duplicate-key error. Without it, calling again opens another ' +
29
+ 'conversation, so check ixn_conversations_list before retrying.',
30
+ inputSchema: z.object({
31
+ channel_endpoint_id: z
32
+ .string()
33
+ .min(1)
34
+ .describe('UUID of the ixn_channel_endpoints row this conversation runs on'),
35
+ queue_id: z
36
+ .string()
37
+ .min(1)
38
+ .optional()
39
+ .describe('UUID of the ixn_queues row that routes this conversation'),
40
+ thread_id: z
41
+ .string()
42
+ .max(512)
43
+ .optional()
44
+ .describe('External channel-side thread identifier. Unique per channel endpoint.'),
45
+ conversation_status: z
46
+ .string()
47
+ .max(32)
48
+ .optional()
49
+ .describe('Initial status from the IXN_CONVERSATIONS_CONVERSATION_STATUS lookup (OPEN, CLOSED)'),
50
+ lead_id: z.string().min(1).optional().describe('UUID of the sfa_leads row this conversation is scoped to'),
51
+ deal_id: z.string().min(1).optional().describe('UUID of the sfa_deals row this conversation is scoped to'),
52
+ org_id: z.string().min(1).optional().describe('UUID of the hrm_organizations_c row this conversation is scoped to'),
53
+ work_item_id: z
54
+ .string()
55
+ .min(1)
56
+ .optional()
57
+ .describe('UUID of the ppm_work_items row this conversation is scoped to'),
58
+ resource_url: z
59
+ .string()
60
+ .optional()
61
+ .describe('Optional URL of the external resource this conversation is anchored on'),
62
+ metadata: z.record(z.unknown()).optional(),
63
+ confirm: confirmFlagSchema,
64
+ idempotency_key: unenforcedIdempotencyKeySchema,
65
+ }),
66
+ capabilities: [cap('ixn_conversations', 'INSERT')],
67
+ sideEffect: 'state_change',
68
+ confirmation: 'caller_confirms',
69
+ idempotency: 'not_idempotent',
70
+ handler: async (args, ctx) => {
71
+ const input = args;
72
+ const body = {
73
+ channel_endpoint_id: input.channel_endpoint_id,
74
+ };
75
+ for (const field of [
76
+ 'queue_id',
77
+ 'thread_id',
78
+ 'conversation_status',
79
+ 'lead_id',
80
+ 'deal_id',
81
+ 'org_id',
82
+ 'work_item_id',
83
+ 'resource_url',
84
+ 'metadata',
85
+ ]) {
86
+ if (input[field] !== undefined)
87
+ body[field] = input[field];
88
+ }
89
+ try {
90
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/ixn_conversations?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
91
+ return successResponse(rows[0]);
92
+ }
93
+ catch (error) {
94
+ return errorResponse(API_ERROR, `Failed to start IXN conversation: ${error.message}`);
95
+ }
96
+ },
97
+ };
98
+ //# sourceMappingURL=ixn-conversation-start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ixn-conversation-start.js","sourceRoot":"","sources":["../../../src/tools/ixn/ixn-conversation-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,M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AAC,EAAE,CAChE,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,qCAAqC,KAAK,CAAC,OAAO,EAAE,CACrD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Communication semantic tool: dispatch an outbound message on an
4
+ * existing conversation (`ixn_messages`). The row this creates is
5
+ * picked up by the channel delivery worker and sent to the customer,
6
+ * so the tool requires:
7
+ *
8
+ * - `confirm: true` to prevent accidental invocation.
9
+ *
10
+ * Not deduplicated: Persist ignores the `Idempotency-Key` header and
11
+ * `ixn_messages` has no idempotent create path yet, so a repeat call
12
+ * sends a second message. The description tells callers to check first.
13
+ *
14
+ * `direction` is force-set to `OUTBOUND`, the exact value the
15
+ * `IXN_MESSAGES_DIRECTION` lookup holds and the only value the delivery
16
+ * trigger fires on — inbound messages arrive
17
+ * via the channel delivery worker, never via MCP; a caller wanting
18
+ * to log an inbound message should use the read tools plus the
19
+ * dedicated inbound-processing endpoints. `delivery_status` is
20
+ * server-assigned and returned on the created row for status
21
+ * polling via `ixn_messages_get`.
22
+ *
23
+ * Provider credentials (`ixn_channel_endpoints.outbound_credential_ssm_names`)
24
+ * are never read or set from this tool — the delivery worker
25
+ * resolves them server-side.
26
+ */
27
+ export declare const ixnMessageSendTool: Tool;
28
+ //# sourceMappingURL=ixn-message-send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ixn-message-send.d.ts","sourceRoot":"","sources":["../../../src/tools/ixn/ixn-message-send.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kBAAkB,EAAE,IAmEhC,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+ import { API_ERROR, errorResponse, successResponse } from '../types.js';
3
+ import { cap } from '../../capabilities/tool-capability.js';
4
+ import { confirmFlagSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * Communication semantic tool: dispatch an outbound message on an
7
+ * existing conversation (`ixn_messages`). The row this creates is
8
+ * picked up by the channel delivery worker and sent to the customer,
9
+ * so the tool requires:
10
+ *
11
+ * - `confirm: true` to prevent accidental invocation.
12
+ *
13
+ * Not deduplicated: Persist ignores the `Idempotency-Key` header and
14
+ * `ixn_messages` has no idempotent create path yet, so a repeat call
15
+ * sends a second message. The description tells callers to check first.
16
+ *
17
+ * `direction` is force-set to `OUTBOUND`, the exact value the
18
+ * `IXN_MESSAGES_DIRECTION` lookup holds and the only value the delivery
19
+ * trigger fires on — inbound messages arrive
20
+ * via the channel delivery worker, never via MCP; a caller wanting
21
+ * to log an inbound message should use the read tools plus the
22
+ * dedicated inbound-processing endpoints. `delivery_status` is
23
+ * server-assigned and returned on the created row for status
24
+ * polling via `ixn_messages_get`.
25
+ *
26
+ * Provider credentials (`ixn_channel_endpoints.outbound_credential_ssm_names`)
27
+ * are never read or set from this tool — the delivery worker
28
+ * resolves them server-side.
29
+ */
30
+ export const ixnMessageSendTool = {
31
+ name: 'ixn_message_send',
32
+ description: 'Dispatch an outbound message on an existing IXN conversation (ixn_messages). ' +
33
+ 'Requires confirm=true, conversation_id, sender_identity and body_text. direction is ' +
34
+ 'forced to OUTBOUND. delivery_status is server-assigned; poll status via ixn_messages_get ' +
35
+ 'on the returned row id. Not deduplicated: calling it again sends the message again, so ' +
36
+ 'check ixn_messages_list filtered on conversation_id before retrying.',
37
+ inputSchema: z.object({
38
+ conversation_id: z
39
+ .string()
40
+ .min(1)
41
+ .describe('UUID of the ixn_conversations row this message is posted to'),
42
+ sender_identity: z
43
+ .string()
44
+ .min(1)
45
+ .max(256)
46
+ .describe('The sender recorded on the message. Email is sent from the channel endpoint address, not this value.'),
47
+ body_text: z.string().min(1).describe('The plain-text message body to dispatch'),
48
+ channel_msg_id: z
49
+ .string()
50
+ .max(256)
51
+ .optional()
52
+ .describe('Optional caller-supplied channel-side message identifier'),
53
+ sent_by_worker_id: z
54
+ .string()
55
+ .min(1)
56
+ .optional()
57
+ .describe('Optional UUID of the wrm_workers row this send is attributed to'),
58
+ org_id: z
59
+ .string()
60
+ .min(1)
61
+ .optional()
62
+ .describe('UUID of the hrm_organizations_c row this send is scoped to'),
63
+ metadata: z.record(z.unknown()).optional(),
64
+ confirm: confirmFlagSchema,
65
+ idempotency_key: unenforcedIdempotencyKeySchema,
66
+ }),
67
+ capabilities: [cap('ixn_messages', 'INSERT')],
68
+ sideEffect: 'communication',
69
+ confirmation: 'caller_confirms',
70
+ idempotency: 'not_idempotent',
71
+ handler: async (args, ctx) => {
72
+ const input = args;
73
+ const body = {
74
+ conversation_id: input.conversation_id,
75
+ sender_identity: input.sender_identity,
76
+ body_text: input.body_text,
77
+ direction: 'OUTBOUND',
78
+ };
79
+ for (const field of ['channel_msg_id', 'sent_by_worker_id', 'org_id', 'metadata']) {
80
+ if (input[field] !== undefined)
81
+ body[field] = input[field];
82
+ }
83
+ try {
84
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/ixn_messages?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
85
+ return successResponse(rows[0]);
86
+ }
87
+ catch (error) {
88
+ return errorResponse(API_ERROR, `Failed to send IXN outbound message: ${error.message}`);
89
+ }
90
+ },
91
+ };
92
+ //# sourceMappingURL=ixn-message-send.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ixn-message-send.js","sourceRoot":"","sources":["../../../src/tools/ixn/ixn-message-send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,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D,CAAC;IACF,YAAY,EAAE,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC7C,UAAU,EAAE,eAAe;IAC3B,YAAY,EAAE,iBAAiB;IAC/B,WAAW,EAAE,gBAAgB;IAC7B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,IAA2B,CAAC;QAC1C,MAAM,IAAI,GAAwB;YAChC,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,SAAS,EAAE,UAAU;SACtB,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;YAClF,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CACnC,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,wBAAwB,EACnD,IAAI,EACJ,EAAE,OAAO,EAAE,2BAA2B,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,wCAAwC,KAAK,CAAC,OAAO,EAAE,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Tool } from '../registry.js';
2
+ import { CatalogueReport } from '../../generated-reads/index.js';
3
+ export declare const pbmGeneratedReadReport: CatalogueReport;
4
+ export declare const pbmGeneratedReadTools: Tool[];
5
+ //# sourceMappingURL=generated-reads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-reads.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/generated-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAGL,eAAe,EAChB,MAAM,gCAAgC,CAAC;AA6BxC,eAAO,MAAM,sBAAsB,EAAE,eAIjC,CAAC;AAEL,eAAO,MAAM,qBAAqB,EAAE,IAAI,EAGvC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { buildGeneratedReadCatalogue, buildGeneratedReadCatalogueReport, } from '../../generated-reads/index.js';
2
+ import { loadPersistResourceContract } from '../../contracts/persist-resource-contract.js';
3
+ /**
4
+ * Bounded read tools for the PBM module (WI-0003507).
5
+ *
6
+ * The schema-driven catalogue (WI-0003500) emits describe/list/get for
7
+ * every PBM resource that declares a read operation and has no side
8
+ * effects. The billing profile / subscription resources are classified
9
+ * `sensitive`; they carry customer billing state (billing cycle,
10
+ * cancellation dates, subscribed price lines) that operators
11
+ * legitimately need to see to answer subscription/billing questions,
12
+ * so we opt them in via `includeSensitive: true`. The credential /
13
+ * secrets guardrail still applies — the redactor drops any column
14
+ * matching credential-shaped patterns — but the sensitive-flag opt-in
15
+ * is what makes the billing surface visible on reads at all.
16
+ *
17
+ * Provider credentials for billing gateways (fxm_payment_processor_*
18
+ * tables) live in a separate FXM module and are excluded from the
19
+ * pinned contract entirely; no read from this module can reach them.
20
+ *
21
+ * Every write on a billing / subscription / entitlement row lives in
22
+ * a dedicated hand-written tool with explicit confirmation and
23
+ * idempotency semantics (see `pbm-subscription-*`,
24
+ * `pbm-*-entitlement-override-*`).
25
+ */
26
+ const contract = loadPersistResourceContract();
27
+ export const pbmGeneratedReadReport = buildGeneratedReadCatalogueReport(contract, {
28
+ modules: ['pbm'],
29
+ includeSensitive: true,
30
+ });
31
+ export const pbmGeneratedReadTools = buildGeneratedReadCatalogue(contract, { modules: ['pbm'], includeSensitive: true });
32
+ //# sourceMappingURL=generated-reads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-reads.js","sourceRoot":"","sources":["../../../src/tools/pbm/generated-reads.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,GAElC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,sBAAsB,GACjC,iCAAiC,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,gBAAgB,EAAE,IAAI;CACvB,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,qBAAqB,GAAW,2BAA2B,CACtE,QAAQ,EACR,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC7C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Tool } from '../registry.js';
2
+ export declare const pbmTools: Tool[];
3
+ /** Read-only slice used by the `pbm-readonly` selectable sub-domain. */
4
+ export declare const pbmReadOnlyTools: Tool[];
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAgBtC,eAAO,MAAM,QAAQ,EAAE,IAAI,EAAiD,CAAC;AAE7E,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAA0B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { pbmGeneratedReadTools } from './generated-reads.js';
2
+ import { pbmSubscriptionCreateTool } from './pbm-subscription-create.js';
3
+ import { pbmSubscriptionCancelTool } from './pbm-subscription-cancel.js';
4
+ import { pbmSubscriptionLineAddTool } from './pbm-subscription-line-add.js';
5
+ import { pbmSubscriptionLineEndTool } from './pbm-subscription-line-end.js';
6
+ import { pbmCustomerEntitlementOverrideSetTool } from './pbm-customer-entitlement-override-set.js';
7
+ const pbmWriteTools = [
8
+ pbmSubscriptionCreateTool,
9
+ pbmSubscriptionCancelTool,
10
+ pbmSubscriptionLineAddTool,
11
+ pbmSubscriptionLineEndTool,
12
+ pbmCustomerEntitlementOverrideSetTool,
13
+ ];
14
+ export const pbmTools = [...pbmGeneratedReadTools, ...pbmWriteTools];
15
+ /** Read-only slice used by the `pbm-readonly` selectable sub-domain. */
16
+ export const pbmReadOnlyTools = pbmGeneratedReadTools;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/pbm/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,qCAAqC,EAAE,MAAM,4CAA4C,CAAC;AAEnG,MAAM,aAAa,GAAW;IAC5B,yBAAyB;IACzB,yBAAyB;IACzB,0BAA0B;IAC1B,0BAA0B;IAC1B,qCAAqC;CACtC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAW,CAAC,GAAG,qBAAqB,EAAE,GAAG,aAAa,CAAC,CAAC;AAE7E,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAW,qBAAqB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Entitlement-management semantic tool: create a customer-scoped
4
+ * entitlement override (`pbm_customer_entitlement_overrides`).
5
+ *
6
+ * Overrides bypass the tenant / platform entitlement defaults for a
7
+ * specific customer, so they can quietly expand or contract what the
8
+ * customer sees or can consume — cutting a customer off from a
9
+ * feature, or granting a promo tier ahead of billing. The tool
10
+ * therefore requires:
11
+ *
12
+ * - `confirm: true` to prevent accidental invocation;
13
+ * - a caller-supplied `reason` (this maps to the `reason` column on
14
+ * the row, which the pinned contract marks as REQUIRED).
15
+ *
16
+ * `granted_by` is read-only in the pinned contract — persist assigns
17
+ * it from the authenticated caller. `value` is a JSON object per PBM
18
+ * schema (typically `{ "enabled": true }` or a quota override).
19
+ *
20
+ * Create only, despite the name. The primary key
21
+ * (customer_id, feature_id, tenant_id) allows one override per customer
22
+ * and feature, so a retry, or a call with a new value, fails with a
23
+ * duplicate-key error.
24
+ */
25
+ export declare const pbmCustomerEntitlementOverrideSetTool: Tool;
26
+ //# sourceMappingURL=pbm-customer-entitlement-override-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-customer-entitlement-override-set.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-customer-entitlement-override-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAUtC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qCAAqC,EAAE,IA2DnD,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { z } from 'zod';
2
+ import { API_ERROR, errorResponse, successResponse } from '../types.js';
3
+ import { cap } from '../../capabilities/tool-capability.js';
4
+ import { confirmFlagSchema, reasonSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * Entitlement-management semantic tool: create a customer-scoped
7
+ * entitlement override (`pbm_customer_entitlement_overrides`).
8
+ *
9
+ * Overrides bypass the tenant / platform entitlement defaults for a
10
+ * specific customer, so they can quietly expand or contract what the
11
+ * customer sees or can consume — cutting a customer off from a
12
+ * feature, or granting a promo tier ahead of billing. The tool
13
+ * therefore requires:
14
+ *
15
+ * - `confirm: true` to prevent accidental invocation;
16
+ * - a caller-supplied `reason` (this maps to the `reason` column on
17
+ * the row, which the pinned contract marks as REQUIRED).
18
+ *
19
+ * `granted_by` is read-only in the pinned contract — persist assigns
20
+ * it from the authenticated caller. `value` is a JSON object per PBM
21
+ * schema (typically `{ "enabled": true }` or a quota override).
22
+ *
23
+ * Create only, despite the name. The primary key
24
+ * (customer_id, feature_id, tenant_id) allows one override per customer
25
+ * and feature, so a retry, or a call with a new value, fails with a
26
+ * duplicate-key error.
27
+ */
28
+ export const pbmCustomerEntitlementOverrideSetTool = {
29
+ name: 'pbm_customer_entitlement_override_set',
30
+ description: 'Create a customer-scoped entitlement override (pbm_customer_entitlement_overrides) ' +
31
+ 'that bypasses tenant / platform defaults. Requires confirm=true and a reason ' +
32
+ '(recorded in the row). granted_by is server-assigned. One override per customer and ' +
33
+ 'feature: a retry, or a call with a new value, fails with a duplicate-key error.',
34
+ inputSchema: z.object({
35
+ customer_id: z
36
+ .string()
37
+ .min(1)
38
+ .describe('UUID of the far_customers row this override applies to (required)'),
39
+ feature_id: z
40
+ .string()
41
+ .min(1)
42
+ .describe('UUID of the pbm_features row being overridden (required)'),
43
+ value: z
44
+ .record(z.unknown())
45
+ .describe('JSON object describing the override (e.g. {"enabled": true} or a quota override)'),
46
+ reason: reasonSchema.describe('Human-readable justification recorded on the row and audit trail'),
47
+ start_date: z.string().min(1).optional().describe('ISO 8601 override start'),
48
+ end_date: z.string().min(1).optional().describe('ISO 8601 override end'),
49
+ metadata: z.record(z.unknown()).optional(),
50
+ confirm: confirmFlagSchema,
51
+ idempotency_key: unenforcedIdempotencyKeySchema,
52
+ }),
53
+ capabilities: [cap('pbm_customer_entitlement_overrides', 'INSERT')],
54
+ sideEffect: 'state_change',
55
+ confirmation: 'caller_confirms',
56
+ idempotency: 'natural_key',
57
+ handler: async (args, ctx) => {
58
+ const input = args;
59
+ const body = {
60
+ customer_id: input.customer_id,
61
+ feature_id: input.feature_id,
62
+ value: input.value,
63
+ reason: input.reason,
64
+ };
65
+ for (const field of ['start_date', 'end_date', 'metadata']) {
66
+ if (input[field] !== undefined)
67
+ body[field] = input[field];
68
+ }
69
+ try {
70
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/pbm_customer_entitlement_overrides?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
71
+ return successResponse(rows[0]);
72
+ }
73
+ catch (error) {
74
+ return errorResponse(API_ERROR, `Failed to set PBM customer entitlement override: ${error.message}`);
75
+ }
76
+ },
77
+ };
78
+ //# sourceMappingURL=pbm-customer-entitlement-override-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-customer-entitlement-override-set.js","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-customer-entitlement-override-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAS;IACzD,IAAI,EAAE,uCAAuC;IAC7C,WAAW,EACT,qFAAqF;QACrF,+EAA+E;QAC/E,sFAAsF;QACtF,iFAAiF;IACnF,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,CAAC;aACX,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,mEAAmE,CAAC;QAChF,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN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QAC7D,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CACnC,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,8CAA8C,EACzE,IAAI,EACJ,EAAE,OAAO,EAAE,2BAA2B,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,oDAAoD,KAAK,CAAC,OAAO,EAAE,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Cancellation semantic tool for a PBM billing subscription.
4
+ *
5
+ * Writes the cancellation columns through the
6
+ * `pbm_billing_subscriptions_u` update view. Persist's
7
+ * `call_generate_billing_invoices_cancellation_update` trigger then
8
+ * schedules the final invoice job, but only for an active BILLABLE
9
+ * subscription: on any other status the columns would be stored and
10
+ * nothing would happen. The tool reads the row first and refuses those.
11
+ *
12
+ * It also returns a subscription that already has a cancellation date
13
+ * unchanged. Persist resets `cancellation_request_date` to now on every
14
+ * update of such a row, and a changed reason or action could schedule
15
+ * another job, so a retry must not write.
16
+ *
17
+ * `cancellation_request_date` is not an input because that trigger
18
+ * overwrites whatever is supplied.
19
+ */
20
+ export declare const pbmSubscriptionCancelTool: Tool;
21
+ //# sourceMappingURL=pbm-subscription-cancel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-cancel.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-cancel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAUtC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,EAAE,IAmFvC,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ import { API_ERROR, errorResponse, successResponse } from '../types.js';
3
+ import { cap } from '../../capabilities/tool-capability.js';
4
+ import { confirmFlagSchema, reasonSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * Cancellation semantic tool for a PBM billing subscription.
7
+ *
8
+ * Writes the cancellation columns through the
9
+ * `pbm_billing_subscriptions_u` update view. Persist's
10
+ * `call_generate_billing_invoices_cancellation_update` trigger then
11
+ * schedules the final invoice job, but only for an active BILLABLE
12
+ * subscription: on any other status the columns would be stored and
13
+ * nothing would happen. The tool reads the row first and refuses those.
14
+ *
15
+ * It also returns a subscription that already has a cancellation date
16
+ * unchanged. Persist resets `cancellation_request_date` to now on every
17
+ * update of such a row, and a changed reason or action could schedule
18
+ * another job, so a retry must not write.
19
+ *
20
+ * `cancellation_request_date` is not an input because that trigger
21
+ * overwrites whatever is supplied.
22
+ */
23
+ export const pbmSubscriptionCancelTool = {
24
+ name: 'pbm_subscription_cancel',
25
+ description: 'Cancel a BILLABLE PBM billing subscription: records the cancellation and Persist schedules ' +
26
+ 'the final invoice job. The subscription closes when that job runs, so subscription_status ' +
27
+ 'stays BILLABLE until then. Any other status is refused, because no job would be scheduled. ' +
28
+ 'Requires confirm=true and a reason. A subscription already cancelled is returned unchanged, ' +
29
+ 'so retries are safe.',
30
+ inputSchema: z.object({
31
+ id: z
32
+ .string()
33
+ .min(1)
34
+ .describe('UUID of the pbm_billing_subscriptions row to cancel'),
35
+ cancellation_effective_date: z
36
+ .string()
37
+ .min(1)
38
+ .describe('ISO 8601 date cancellation takes effect (required). Persist rejects a date before ' +
39
+ 'the current billing period start.'),
40
+ cancellation_final_invoice_action: z
41
+ .enum(['CYCLE_END', 'PRORATE_CYCLE_END', 'IMMEDIATE', 'PRORATE_IMMEDIATE'])
42
+ .optional()
43
+ .describe('Final invoice policy. Defaults to the value on the subscription, normally CYCLE_END.'),
44
+ reason: reasonSchema.describe('Human-readable reason, stored in cancellation_request_reason'),
45
+ confirm: confirmFlagSchema,
46
+ idempotency_key: unenforcedIdempotencyKeySchema,
47
+ }),
48
+ capabilities: [
49
+ cap('pbm_billing_subscriptions', 'SELECT'),
50
+ cap('pbm_billing_subscriptions_u', 'UPDATE'),
51
+ ],
52
+ sideEffect: 'state_change',
53
+ confirmation: 'caller_confirms',
54
+ idempotency: 'natural_key',
55
+ handler: async (args, ctx) => {
56
+ const input = args;
57
+ const notFound = () => errorResponse(API_ERROR, `PBM billing subscription ${input.id} not found or not accessible`);
58
+ const body = {
59
+ cancellation_effective_date: input.cancellation_effective_date,
60
+ cancellation_request_reason: input.reason,
61
+ };
62
+ if (input.cancellation_final_invoice_action !== undefined) {
63
+ body.cancellation_final_invoice_action = input.cancellation_final_invoice_action;
64
+ }
65
+ try {
66
+ const current = await ctx.apiClient.get(`${ctx.apiClient.dbBasePath}/pbm_billing_subscriptions?id=eq.${input.id}&select=*`);
67
+ if (!current || current.length === 0)
68
+ return notFound();
69
+ const row = current[0];
70
+ if (row.cancellation_effective_date)
71
+ return successResponse(row);
72
+ if (row.subscription_status !== 'BILLABLE' || row.active === false) {
73
+ return errorResponse(API_ERROR, `PBM billing subscription ${input.id} is ${row.subscription_status}: ` +
74
+ 'only an active BILLABLE subscription can be cancelled');
75
+ }
76
+ const rows = await ctx.apiClient.patch(`${ctx.apiClient.dbBasePath}/pbm_billing_subscriptions_u?id=eq.${input.id}&select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
77
+ if (!rows || rows.length === 0)
78
+ return notFound();
79
+ return successResponse(rows[0]);
80
+ }
81
+ catch (error) {
82
+ return errorResponse(API_ERROR, `Failed to cancel PBM billing subscription: ${error.message}`);
83
+ }
84
+ },
85
+ };
86
+ //# sourceMappingURL=pbm-subscription-cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-cancel.js","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-sub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BAA2B,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAChE,CAAC;YACF,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,QAAQ,EAAE,CAAC;YAClD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,8CAA8C,KAAK,CAAC,OAAO,EAAE,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Provisioning semantic tool: create a PBM billing subscription
4
+ * (`pbm_billing_subscriptions`). Requires `confirm: true`.
5
+ *
6
+ * The subscription starts PENDING, and billing starts when it becomes
7
+ * BILLABLE. MCP has no tool for that step. Persist has no unique key
8
+ * here, so a retry creates a second subscription.
9
+ *
10
+ * Cancellation columns (`cancellation_effective_date`,
11
+ * `cancellation_request_date`, `cancellation_request_reason`,
12
+ * `cancellation_final_invoice_action`) are intentionally NOT writable
13
+ * through this tool — cancellation is a lifecycle event handled by
14
+ * `pbm_subscription_cancel`. `subscription_status` is not an input.
15
+ *
16
+ * Payment method / gateway credentials live in an excluded FXM table
17
+ * (fxm_payment_processor_credentials) and cannot be set through MCP.
18
+ */
19
+ export declare const pbmSubscriptionCreateTool: Tool;
20
+ //# sourceMappingURL=pbm-subscription-create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-create.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,EAAE,IA0EvC,CAAC"}