@open-loyalty/mcp-server 1.3.7 → 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.
Files changed (39) hide show
  1. package/dist/instructions.d.ts +1 -1
  2. package/dist/instructions.js +18 -5
  3. package/dist/tools/reward/handlers.d.ts +2 -0
  4. package/dist/tools/reward/handlers.js +52 -6
  5. package/dist/tools/reward/index.d.ts +2 -0
  6. package/dist/tools/reward/index.js +13 -7
  7. package/dist/tools/reward/schemas.d.ts +2 -0
  8. package/dist/tools/reward/schemas.js +15 -5
  9. package/dist/tools/tierset.d.ts +1 -1
  10. package/dist/tools/tierset.js +49 -25
  11. package/dist/tools/transaction.js +5 -2
  12. package/dist/tools/wallet-type.js +26 -17
  13. package/dist/types/schemas/admin.d.ts +6 -6
  14. package/dist/types/schemas/role.d.ts +4 -4
  15. package/package.json +1 -1
  16. package/dist/prompts/fan-engagement-setup.d.ts +0 -107
  17. package/dist/prompts/fan-engagement-setup.js +0 -492
  18. package/dist/tools/achievement.d.ts +0 -1017
  19. package/dist/tools/achievement.js +0 -354
  20. package/dist/tools/campaign.d.ts +0 -1800
  21. package/dist/tools/campaign.js +0 -737
  22. package/dist/tools/member.d.ts +0 -366
  23. package/dist/tools/member.js +0 -352
  24. package/dist/tools/reward.d.ts +0 -279
  25. package/dist/tools/reward.js +0 -361
  26. package/dist/tools/segment.d.ts +0 -816
  27. package/dist/tools/segment.js +0 -333
  28. package/dist/workflows/app-login-streak.d.ts +0 -39
  29. package/dist/workflows/app-login-streak.js +0 -298
  30. package/dist/workflows/early-arrival.d.ts +0 -33
  31. package/dist/workflows/early-arrival.js +0 -148
  32. package/dist/workflows/index.d.ts +0 -101
  33. package/dist/workflows/index.js +0 -208
  34. package/dist/workflows/match-attendance.d.ts +0 -45
  35. package/dist/workflows/match-attendance.js +0 -308
  36. package/dist/workflows/sportsbar-visit.d.ts +0 -41
  37. package/dist/workflows/sportsbar-visit.js +0 -284
  38. package/dist/workflows/vod-watching.d.ts +0 -43
  39. package/dist/workflows/vod-watching.js +0 -326
@@ -1,492 +0,0 @@
1
- /**
2
- * Fan Engagement Setup Prompts
3
- *
4
- * MCP prompt templates for guided campaign setup.
5
- * These define conversational flows and default values for AI agents
6
- * to help program admins create fan engagement campaigns.
7
- */
8
- // ============================================================================
9
- // Default Values
10
- // ============================================================================
11
- export const DEFAULTS = {
12
- // Match Attendance
13
- matchAttendance: {
14
- coinsPerMatch: 50,
15
- milestones: [6, 12],
16
- milestoneBonuses: { 6: 500, 12: 1000, "80%": 2000 },
17
- limitPerDay: 1,
18
- badges: { 6: "Silver", 12: "Gold", "80%": "Platinum" },
19
- },
20
- // Early Arrival
21
- earlyArrival: {
22
- minutesBefore: 60,
23
- coinsPerArrival: 25,
24
- limitPerMatch: 1,
25
- },
26
- // Sports Bar
27
- sportsbarVisit: {
28
- coinsPerVisit: 50,
29
- visitMilestone: 5,
30
- milestoneBonus: 500,
31
- limitPerDay: 1,
32
- },
33
- // VOD Watching
34
- vodWatching: {
35
- trackBy: "minutes",
36
- coinsPerUnit: 10,
37
- unitSize: 10, // coins per X minutes
38
- achievementMinutes: 300,
39
- achievementBonus: 200,
40
- },
41
- // App Login Streak
42
- appLoginStreak: {
43
- coinsPerLogin: 5,
44
- streakDays: 7,
45
- streakBonus: 50,
46
- limitPerDay: 1,
47
- },
48
- // General
49
- seasonDates: {
50
- start: new Date().toISOString().split("T")[0],
51
- end: new Date(new Date().setFullYear(new Date().getFullYear() + 1)).toISOString().split("T")[0],
52
- },
53
- };
54
- // ============================================================================
55
- // Workflow Definitions
56
- // ============================================================================
57
- export const MATCH_ATTENDANCE_WORKFLOW = {
58
- id: "match-attendance",
59
- name: "Match Attendance Campaign",
60
- description: "Reward fans for attending matches with coins and achievements",
61
- triggerPhrases: [
62
- "set up a campaign to reward fans for attending matches",
63
- "create match attendance rewards",
64
- "reward match attendance",
65
- "attendance campaign",
66
- "match attendance",
67
- ],
68
- questions: [
69
- {
70
- id: "coinsPerMatch",
71
- question: "How many coins should fans receive per match attendance?",
72
- type: "number",
73
- default: DEFAULTS.matchAttendance.coinsPerMatch,
74
- hint: "Common values: 50, 100, 200",
75
- },
76
- {
77
- id: "createAchievements",
78
- question: "Set up achievements for attending multiple matches?",
79
- type: "boolean",
80
- default: true,
81
- hint: "Creates milestone achievements (e.g., 6 matches, 12 matches)",
82
- },
83
- {
84
- id: "milestones",
85
- question: "What attendance milestones should earn achievements?",
86
- type: "string",
87
- default: "6,12",
88
- hint: "Comma-separated numbers (e.g., '6,12' or '6,12,80%')",
89
- },
90
- {
91
- id: "badgeNames",
92
- question: "What badge names for each milestone?",
93
- type: "string",
94
- default: "Silver,Gold",
95
- hint: "Comma-separated names matching milestones (e.g., 'Silver,Gold,Platinum')",
96
- },
97
- {
98
- id: "milestoneBonuses",
99
- question: "Bonus coins for each milestone?",
100
- type: "string",
101
- default: "500,1000",
102
- hint: "Comma-separated values matching milestones",
103
- },
104
- {
105
- id: "limitPerDay",
106
- question: "Maximum attendances per day (anti-fraud)?",
107
- type: "number",
108
- default: DEFAULTS.matchAttendance.limitPerDay,
109
- hint: "Usually 1 to prevent multiple scans per match",
110
- },
111
- {
112
- id: "seasonStart",
113
- question: "Season start date?",
114
- type: "string",
115
- default: DEFAULTS.seasonDates.start,
116
- hint: "ISO format: YYYY-MM-DD",
117
- },
118
- {
119
- id: "seasonEnd",
120
- question: "Season end date?",
121
- type: "string",
122
- default: DEFAULTS.seasonDates.end,
123
- hint: "ISO format: YYYY-MM-DD",
124
- },
125
- ],
126
- steps: [
127
- {
128
- id: "create-base-campaign",
129
- action: "Create base match attendance campaign",
130
- tool: "openloyalty_campaign_create",
131
- description: "Creates campaign with custom_event trigger for match_attendance event",
132
- },
133
- {
134
- id: "create-achievements",
135
- action: "Create milestone achievements",
136
- tool: "openloyalty_achievement_create",
137
- description: "Creates achievements for each attendance milestone with badges",
138
- },
139
- {
140
- id: "create-achievement-campaigns",
141
- action: "Create achievement bonus campaigns",
142
- tool: "openloyalty_campaign_create",
143
- description: "Creates campaigns triggered by achievement completion for bonus coins",
144
- },
145
- {
146
- id: "verify",
147
- action: "Verify all campaigns and achievements",
148
- tool: "openloyalty_campaign_list",
149
- description: "Lists created campaigns to confirm setup",
150
- },
151
- ],
152
- };
153
- export const EARLY_ARRIVAL_WORKFLOW = {
154
- id: "early-arrival",
155
- name: "Early Arrival Campaign",
156
- description: "Reward fans who arrive early to matches",
157
- triggerPhrases: [
158
- "reward fans who arrive early",
159
- "early arrival rewards",
160
- "early arrival campaign",
161
- "reward early arrival",
162
- ],
163
- questions: [
164
- {
165
- id: "minutesBefore",
166
- question: "How early (in minutes) counts as 'early arrival'?",
167
- type: "number",
168
- default: DEFAULTS.earlyArrival.minutesBefore,
169
- hint: "Common values: 30, 45, 60 minutes before kickoff",
170
- },
171
- {
172
- id: "coinsPerArrival",
173
- question: "How many coins for early arrival?",
174
- type: "number",
175
- default: DEFAULTS.earlyArrival.coinsPerArrival,
176
- hint: "Usually less than match attendance reward",
177
- },
178
- {
179
- id: "limitPerMatch",
180
- question: "Limit early arrival bonus per match?",
181
- type: "number",
182
- default: DEFAULTS.earlyArrival.limitPerMatch,
183
- hint: "1 = one bonus per match day",
184
- },
185
- ],
186
- steps: [
187
- {
188
- id: "create-campaign",
189
- action: "Create early arrival campaign",
190
- tool: "openloyalty_campaign_create",
191
- description: "Creates campaign with custom_event trigger and minutes_before condition",
192
- },
193
- ],
194
- };
195
- export const SPORTSBAR_VISIT_WORKFLOW = {
196
- id: "sportsbar-visit",
197
- name: "Sports Bar Visit Campaign",
198
- description: "Reward fans for visiting the sports bar",
199
- triggerPhrases: [
200
- "set up rewards for visiting the sports bar",
201
- "sports bar visit rewards",
202
- "sportsbar visit campaign",
203
- "reward bar visits",
204
- ],
205
- questions: [
206
- {
207
- id: "coinsPerVisit",
208
- question: "How many coins per sports bar visit?",
209
- type: "number",
210
- default: DEFAULTS.sportsbarVisit.coinsPerVisit,
211
- hint: "Common values: 25, 50, 100",
212
- },
213
- {
214
- id: "createAchievement",
215
- question: "Set up achievement for multiple visits?",
216
- type: "boolean",
217
- default: true,
218
- hint: "Creates milestone achievement for visiting X times",
219
- },
220
- {
221
- id: "visitMilestone",
222
- question: "How many visits for the achievement?",
223
- type: "number",
224
- default: DEFAULTS.sportsbarVisit.visitMilestone,
225
- hint: "Common values: 5, 10, 20",
226
- },
227
- {
228
- id: "milestoneBonus",
229
- question: "Bonus coins for completing the achievement?",
230
- type: "number",
231
- default: DEFAULTS.sportsbarVisit.milestoneBonus,
232
- hint: "Bonus awarded when milestone is reached",
233
- },
234
- {
235
- id: "limitPerDay",
236
- question: "Maximum visits counted per day?",
237
- type: "number",
238
- default: DEFAULTS.sportsbarVisit.limitPerDay,
239
- hint: "Prevents abuse from multiple scans",
240
- },
241
- ],
242
- steps: [
243
- {
244
- id: "create-visit-campaign",
245
- action: "Create visit campaign",
246
- tool: "openloyalty_campaign_create",
247
- description: "Creates campaign with custom_event trigger for sportsbar_visit",
248
- },
249
- {
250
- id: "create-achievement",
251
- action: "Create visit milestone achievement",
252
- tool: "openloyalty_achievement_create",
253
- description: "Creates achievement for visiting X times",
254
- },
255
- {
256
- id: "create-achievement-campaign",
257
- action: "Create achievement bonus campaign",
258
- tool: "openloyalty_campaign_create",
259
- description: "Creates campaign triggered by achievement completion",
260
- },
261
- ],
262
- };
263
- export const VOD_WATCHING_WORKFLOW = {
264
- id: "vod-watching",
265
- name: "VOD Watching Campaign",
266
- description: "Reward fans for watching video content",
267
- triggerPhrases: [
268
- "reward fans for watching video content",
269
- "vod watching rewards",
270
- "video content rewards",
271
- "reward watching videos",
272
- ],
273
- questions: [
274
- {
275
- id: "trackBy",
276
- question: "Track by views or minutes watched?",
277
- type: "select",
278
- options: ["views", "minutes"],
279
- default: DEFAULTS.vodWatching.trackBy,
280
- hint: "Minutes watched is more engagement-focused",
281
- },
282
- {
283
- id: "coinsPerUnit",
284
- question: "How many coins per unit (view or X minutes)?",
285
- type: "number",
286
- default: DEFAULTS.vodWatching.coinsPerUnit,
287
- hint: "For minutes: coins per unitSize minutes",
288
- },
289
- {
290
- id: "unitSize",
291
- question: "If tracking minutes, how many minutes per reward?",
292
- type: "number",
293
- default: DEFAULTS.vodWatching.unitSize,
294
- hint: "e.g., 10 = earn coins every 10 minutes watched",
295
- },
296
- {
297
- id: "createAchievement",
298
- question: "Set up achievement for total minutes/views?",
299
- type: "boolean",
300
- default: true,
301
- hint: "Creates milestone achievement for watching X total",
302
- },
303
- {
304
- id: "achievementTarget",
305
- question: "Target for achievement (minutes or views)?",
306
- type: "number",
307
- default: DEFAULTS.vodWatching.achievementMinutes,
308
- hint: "Total minutes or views to earn achievement",
309
- },
310
- {
311
- id: "achievementBonus",
312
- question: "Bonus coins for completing the achievement?",
313
- type: "number",
314
- default: DEFAULTS.vodWatching.achievementBonus,
315
- hint: "Bonus awarded when target is reached",
316
- },
317
- ],
318
- steps: [
319
- {
320
- id: "create-watch-campaign",
321
- action: "Create VOD watching campaign",
322
- tool: "openloyalty_campaign_create",
323
- description: "Creates campaign with custom_event trigger for vod_watch",
324
- },
325
- {
326
- id: "create-achievement",
327
- action: "Create watching achievement",
328
- tool: "openloyalty_achievement_create",
329
- description: "Creates achievement tracking total minutes/views with attribute sum",
330
- },
331
- {
332
- id: "create-achievement-campaign",
333
- action: "Create achievement bonus campaign",
334
- tool: "openloyalty_campaign_create",
335
- description: "Creates campaign triggered by achievement completion",
336
- },
337
- ],
338
- };
339
- export const APP_LOGIN_STREAK_WORKFLOW = {
340
- id: "app-login-streak",
341
- name: "App Login Streak Campaign",
342
- description: "Reward fans for daily login streaks",
343
- triggerPhrases: [
344
- "set up daily login rewards",
345
- "daily login streak",
346
- "app login rewards",
347
- "login streak campaign",
348
- ],
349
- questions: [
350
- {
351
- id: "coinsPerLogin",
352
- question: "How many coins per daily login?",
353
- type: "number",
354
- default: DEFAULTS.appLoginStreak.coinsPerLogin,
355
- hint: "Usually a small amount (5-20)",
356
- },
357
- {
358
- id: "createStreakBonus",
359
- question: "Set up streak bonus?",
360
- type: "boolean",
361
- default: true,
362
- hint: "Extra reward for consecutive daily logins",
363
- },
364
- {
365
- id: "streakDays",
366
- question: "How many consecutive days for streak bonus?",
367
- type: "number",
368
- default: DEFAULTS.appLoginStreak.streakDays,
369
- hint: "Common values: 7, 14, 30 days",
370
- },
371
- {
372
- id: "streakBonus",
373
- question: "Bonus coins for completing the streak?",
374
- type: "number",
375
- default: DEFAULTS.appLoginStreak.streakBonus,
376
- hint: "Bonus awarded when streak is achieved",
377
- },
378
- ],
379
- steps: [
380
- {
381
- id: "create-login-campaign",
382
- action: "Create daily login campaign",
383
- tool: "openloyalty_campaign_create",
384
- description: "Creates campaign with custom_event trigger for app_login, limited to 1/day",
385
- },
386
- {
387
- id: "create-streak-achievement",
388
- action: "Create login streak achievement",
389
- tool: "openloyalty_achievement_create",
390
- description: "Creates achievement for X consecutive daily logins",
391
- },
392
- {
393
- id: "create-streak-campaign",
394
- action: "Create streak bonus campaign",
395
- tool: "openloyalty_campaign_create",
396
- description: "Creates campaign triggered by streak achievement completion",
397
- },
398
- ],
399
- };
400
- // ============================================================================
401
- // All Workflows
402
- // ============================================================================
403
- export const ALL_WORKFLOWS = [
404
- MATCH_ATTENDANCE_WORKFLOW,
405
- EARLY_ARRIVAL_WORKFLOW,
406
- SPORTSBAR_VISIT_WORKFLOW,
407
- VOD_WATCHING_WORKFLOW,
408
- APP_LOGIN_STREAK_WORKFLOW,
409
- ];
410
- // ============================================================================
411
- // Helper Functions
412
- // ============================================================================
413
- /**
414
- * Find matching workflow based on user input
415
- */
416
- export function findMatchingWorkflow(userInput) {
417
- const input = userInput.toLowerCase();
418
- return ALL_WORKFLOWS.find((workflow) => workflow.triggerPhrases.some((phrase) => input.includes(phrase.toLowerCase())));
419
- }
420
- /**
421
- * Get workflow by ID
422
- */
423
- export function getWorkflowById(id) {
424
- return ALL_WORKFLOWS.find((workflow) => workflow.id === id);
425
- }
426
- /**
427
- * Parse comma-separated values to array
428
- */
429
- export function parseCommaSeparated(value) {
430
- return value.split(",").map((v) => v.trim()).filter(Boolean);
431
- }
432
- /**
433
- * Parse milestones (handles both numbers and percentages like "80%")
434
- */
435
- export function parseMilestones(value) {
436
- return parseCommaSeparated(value).map((v) => {
437
- if (v.includes("%"))
438
- return v;
439
- const num = parseInt(v, 10);
440
- return isNaN(num) ? v : num;
441
- });
442
- }
443
- /**
444
- * Format ISO date for Open Loyalty (YYYY-MM-DD HH:mm+TZ)
445
- */
446
- export function formatOLDate(date) {
447
- const d = typeof date === "string" ? new Date(date) : date;
448
- const pad = (n) => n.toString().padStart(2, "0");
449
- const offset = -d.getTimezoneOffset();
450
- const offsetHours = Math.floor(Math.abs(offset) / 60);
451
- const offsetSign = offset >= 0 ? "+" : "-";
452
- return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} 00:00${offsetSign}${pad(offsetHours)}:00`;
453
- }
454
- // ============================================================================
455
- // Prompt Templates for AI Agents
456
- // ============================================================================
457
- export const AGENT_PROMPTS = {
458
- /**
459
- * System prompt for fan engagement setup
460
- */
461
- systemPrompt: `You are helping a program admin set up fan engagement campaigns in Open Loyalty.
462
- For each campaign type, guide the user through the setup questions step by step.
463
- Use the default values when the user doesn't have a preference.
464
- After collecting all information, execute the workflow to create the campaigns and achievements.
465
-
466
- Available campaign types:
467
- 1. Match Attendance - Reward fans for attending matches with coins and milestone achievements
468
- 2. Early Arrival - Bonus for arriving early to matches
469
- 3. Sports Bar Visits - Reward visits to the sports bar
470
- 4. VOD Watching - Reward watching video content
471
- 5. App Login Streak - Daily login rewards with streak bonuses
472
-
473
- When creating campaigns:
474
- - Always use custom_event trigger for fan engagement events
475
- - Custom events are defined inline (no separate create step needed)
476
- - Use achievement trigger for bonus campaigns on milestones
477
- - Set appropriate execution limits to prevent abuse
478
- - Create achievements with badges for milestone rewards`,
479
- /**
480
- * Workflow completion template
481
- */
482
- completionTemplate: (results) => `Your fan engagement program is now set up!
483
-
484
- Created campaigns:
485
- ${results.campaignIds.map((id) => `- Campaign ID: ${id}`).join("\n")}
486
-
487
- Created achievements:
488
- ${results.achievementIds.map((id) => `- Achievement ID: ${id}`).join("\n")}
489
-
490
- Summary:
491
- ${results.summary}`,
492
- };