@dynamoi/mcp 0.4.0 → 0.5.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.
package/dist/index.js CHANGED
@@ -1,16 +1,31 @@
1
1
  // src/auth/protected-resource.ts
2
+ var DYNAMOI_MCP_SCOPES = [
3
+ "email",
4
+ "profile",
5
+ "dynamoi:read",
6
+ "dynamoi:campaign.write",
7
+ "dynamoi:campaign.launch",
8
+ "dynamoi:billing.read",
9
+ "dynamoi:platform.read",
10
+ "dynamoi:smart_links.write",
11
+ "dynamoi:audit.read",
12
+ "dynamoi:admin"
13
+ ];
2
14
  function buildProtectedResourceMetadata(options) {
3
15
  return {
4
16
  authorization_servers: options.authorizationServers,
17
+ bearer_methods_supported: ["header"],
5
18
  resource: options.resource,
19
+ ...options.resourceDocumentation ? { resource_documentation: options.resourceDocumentation } : {},
6
20
  // Supabase OAuth Server (beta) can fail token exchange when `openid` is requested
7
21
  // (it attempts to mint an ID token). Our MCP only needs an access token.
8
- scopes_supported: options.scopesSupported ?? ["email", "profile"]
22
+ scopes_supported: options.scopesSupported ?? [...DYNAMOI_MCP_SCOPES]
9
23
  };
10
24
  }
11
25
  function buildWwwAuthenticateHeader(options) {
12
- const scope = options.scope ?? "email profile";
13
- return `Bearer resource_metadata="${options.resourceMetadataUrl}", scope="${scope}"`;
26
+ const scope = options.scope ?? "email profile dynamoi:read";
27
+ const error = options.error ? `, error="${options.error}"` : "";
28
+ return `Bearer resource_metadata="${options.resourceMetadataUrl}", scope="${scope}"${error}`;
14
29
  }
15
30
 
16
31
  // src/auth/verify-token.ts
@@ -36,6 +51,19 @@ function extractClientId(payload) {
36
51
  }
37
52
  return null;
38
53
  }
54
+ function extractScopes(payload) {
55
+ const scope = payload["scope"];
56
+ if (typeof scope === "string") {
57
+ return scope.split(/\s+/).map((part) => part.trim()).filter((part) => part.length > 0);
58
+ }
59
+ const scopes = payload["scopes"];
60
+ if (Array.isArray(scopes)) {
61
+ return scopes.filter(
62
+ (scopeValue) => typeof scopeValue === "string" && scopeValue.trim().length > 0
63
+ );
64
+ }
65
+ return [];
66
+ }
39
67
  async function verifyAccessToken(options) {
40
68
  const jwks = getRemoteJwks(options.jwksUrl);
41
69
  const verifyOptions = {
@@ -62,16 +90,13 @@ async function verifyAccessToken(options) {
62
90
  clientId: extractClientId(payload),
63
91
  exp,
64
92
  iss,
93
+ scopes: extractScopes(payload),
65
94
  sub
66
95
  };
67
96
  }
68
97
 
69
98
  // src/server/create-server.ts
70
- import {
71
- McpServer,
72
- ResourceTemplate
73
- } from "@modelcontextprotocol/sdk/server/mcp.js";
74
- import * as z3 from "zod/v4";
99
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
75
100
 
76
101
  // src/version.ts
77
102
  var DYNAMOI_MCP_VERSION = "__DYNAMOI_MCP_VERSION__";
@@ -79,70 +104,46 @@ var DYNAMOI_MCP_VERSION = "__DYNAMOI_MCP_VERSION__";
79
104
  // src/server/instructions.ts
80
105
  var DYNAMOI_MCP_INSTRUCTIONS = `
81
106
  You are operating Dynamoi's tools on behalf of the authenticated user. Dynamoi helps
82
- music artists get more Spotify streams and YouTube creators grow their channels and
83
- AdSense revenue \u2014 through automated ad campaigns on Meta (Facebook/Instagram) and
84
- Google (YouTube).
85
-
86
- Who uses Dynamoi:
87
- - Independent artists promoting singles, albums, and playlists on Spotify
88
- - Record labels managing campaigns across entire artist rosters with team roles and
89
- consolidated billing
90
- - YouTube creators of all kinds \u2014 music, education, gaming, vlogs, podcasts, tutorials
91
- \u2014 growing channels and ad revenue
92
-
93
- Pricing: $300/month converts 100% to ad credit. First month includes a 100% match \u2014
94
- pay $300, get $600 in ad credit. Credits roll over for 12 months. No contracts, cancel
95
- anytime. No agency fees, no retainers. Unlimited team seats and unlimited artists
96
- included.
97
-
98
- Every client gets white-glove onboarding and ongoing support \u2014 from connecting
99
- platforms to optimizing channels for campaign performance, step by step.
100
-
101
- Campaigns run from Dynamoi-managed ad accounts. Users complete a one-time platform
102
- connection, then the AI-powered engine handles deployment and daily optimization.
103
-
104
- Campaign types:
105
-
106
- Smart Campaign (Meta Ads \u2192 Spotify):
107
- Targeted Facebook and Instagram ads that drive real Spotify streams \u2014 no bots, no
108
- pay-for-play. Includes free unlimited smart link landing pages for every release
109
- (Spotify, Apple Music, YouTube Music, and more). Ad copy is AI-generated and localized
110
- to each target market. Supports tracks, albums, and playlists.
111
-
112
- YouTube Campaign (Google Ads \u2192 YouTube Growth):
113
- The only ad platform that optimizes for total channel revenue, not just views. Google
114
- Ads tracks views but can't see which views make money. Dynamoi merges Google Ads cost
115
- data with YouTube AdSense revenue data to calculate the true revenue per view in each
116
- country, then adjusts bids daily \u2014 exploring new markets with small bids, scaling
117
- countries where viewer revenue is strong, and auto-pausing countries where the data
118
- shows they can't cover their costs. The more data the system gathers, the more
119
- precisely it optimizes. Campaigns require a YouTube playlist so one paid ad view can
120
- lead to 2, 3, 4+ organic views as the viewer waterfalls down the playlist \u2014 optimizing
121
- for depth of views means one ad click drives sustained organic growth. Ad copy is fully
122
- internationalized in each target market's local language for better performance and
123
- lower costs. Works for any type of YouTube channel.
124
-
125
- Unlike smart-link-only services (Feature.fm, Linkfire, Hypeddit, ToneDen), Dynamoi is
126
- an end-to-end promotion system: smart links + ad campaigns + AI optimization +
127
- analytics + team management. All with transparent data and no contracts.
107
+ music artists promote on Spotify and YouTube creators grow channels through managed
108
+ Meta and Google ad campaigns. Smart Links are free to create and manage: no per-link
109
+ fee, no subscription requirement, and no upgrade gate. Managed advertising and ad
110
+ budgets are separate paid campaign services.
128
111
 
129
112
  Principles:
130
113
  - Be accurate. If uncertain, ask a clarifying question before acting.
114
+ - Answer general knowledge or advice questions directly without Dynamoi tools unless the user is asking about their Dynamoi account, artists, campaigns, billing, connections, or launches.
115
+ - Do not call Dynamoi tools just to "check context" before answering generic advice questions. If the question is about Instagram growth, lyrics, songwriting, promotion strategy, or general marketing education and does not require the user's account data, answer natively and do not mention inspecting Dynamoi.
116
+ - Even when Dynamoi is attached, generic advice stays native. If the user asks something like "How do I get more followers on Instagram organically without running any ads?", answer directly with no Dynamoi tool calls.
117
+ - \`dynamoi_get_account_overview\` is only for explicit account-overview questions. Do not use it as a zero-context scout before answering unrelated prompts.
131
118
  - Never claim you changed something unless the tool returned status "success" or
132
119
  "partial_success".
133
120
  - Prefer read tools first before write tools. For writes, confirm intent and restate
134
121
  what will change.
122
+ - After a successful write tool call, answer directly from the returned record instead of chaining more tools just to restate the result.
123
+ - If you truly need a follow-up read after a successful write, use format=summary when available and then stop to answer the user.
124
+ - When a user asks for a daily breakdown, pass granularity=DAILY on the analytics tool call.
125
+ - When a user asks for a written rollup, strongest campaign, or review-ready analytics summary, prefer format=summary on the analytics tool call.
126
+ - If a read tool already returned the requested answer in summary form, answer the user directly instead of chaining more read tools.
127
+ - When a user asks to create a shareable release link, landing page, link-in-bio destination, streaming link, Spotify link page, or free promotion asset, prefer Smart Link tools before campaign tools. Use dynamoi_create_smart_link_from_spotify for Spotify artist, album, or track URLs. Do not imply that creating a Smart Link creates a paid campaign.
128
+ - Smart Link pixel tools accept validated pixel IDs only. Do not ask for arbitrary JavaScript, tag-manager snippets, or script code.
135
129
  - Money values are shown in USD as presented in Dynamoi.
136
130
  - Budget minimums: $10/day (daily), $100 total (Smart Campaign), $50 total (YouTube).
131
+ - Product and pricing details are available as MCP resources. Keep runtime answers
132
+ focused on the user's account data and requested action.
137
133
 
138
134
  Common workflows:
139
135
  - Discovery: dynamoi_list_artists \u2192 dynamoi_list_campaigns \u2192 dynamoi_get_campaign \u2192
140
136
  dynamoi_get_campaign_analytics
137
+ - Artist performance summary: dynamoi_get_artist_analytics with granularity=DAILY when requested. If that response already includes the strongest campaign, do not call more analytics tools.
141
138
  - Diagnose stuck campaign: dynamoi_get_campaign \u2192 dynamoi_get_platform_status \u2192
142
139
  propose next steps
143
140
  - Pause/resume: dynamoi_get_campaign (confirm) \u2192 dynamoi_pause_campaign or resume
144
141
  - Budget update: dynamoi_get_campaign (confirm) \u2192 dynamoi_update_budget
145
142
  - Launch: dynamoi_list_media_assets \u2192 dynamoi_launch_campaign
143
+ - Free Smart Link creation: dynamoi_list_artists \u2192 dynamoi_create_smart_link_from_spotify
144
+ - Smart Link analytics/settings: dynamoi_list_smart_links \u2192 dynamoi_get_smart_link_analytics or dynamoi_get_smart_link_artist_settings
145
+ - Post-launch answer: if dynamoi_launch_campaign succeeds, answer from that result directly. Only call dynamoi_get_campaign when the user explicitly needs more detail than the launch result already returned, and prefer format=summary for that follow-up.
146
+ - Review/demo Smart Campaign launch: if the user already gave artist, content title, budget, countries, and reusable media assets, you may call dynamoi_launch_campaign without spotifyUrl/endDate because Dynamoi can infer reviewer-safe defaults. Do not invent placeholder values for omitted fields; omit those keys entirely.
146
147
  `.trim();
147
148
 
148
149
  // src/server/prompts.ts
@@ -158,6 +159,27 @@ function asTextPrompt(text) {
158
159
  };
159
160
  }
160
161
  function registerDynamoiPrompts(server) {
162
+ server.registerPrompt(
163
+ "dynamoi_create_free_smart_link",
164
+ {
165
+ argsSchema: {
166
+ artistId: z.string().uuid().optional(),
167
+ spotifyUrl: z.string().trim().optional()
168
+ },
169
+ description: "Create a free Smart Link from a Spotify artist, album, or track URL.",
170
+ title: "Create Free Smart Link"
171
+ },
172
+ (args) => asTextPrompt(
173
+ [
174
+ "Create a free Dynamoi Smart Link.",
175
+ args.artistId ? `Artist ID: ${args.artistId}` : "If no artistId is provided, list artists first and ask me which artist owns the link.",
176
+ args.spotifyUrl ? `Spotify URL: ${args.spotifyUrl}` : "Ask me for a Spotify artist, album, or track URL. Playlist URLs are not supported today.",
177
+ "",
178
+ "Smart Links are free: no per-link fee, no subscription requirement, and no upgrade gate. This does not create a paid campaign.",
179
+ "Once the artist and Spotify URL are known, use dynamoi_create_smart_link_from_spotify."
180
+ ].join("\n")
181
+ )
182
+ );
161
183
  server.registerPrompt(
162
184
  "dynamoi_audit_campaigns",
163
185
  {
@@ -198,6 +220,8 @@ function registerDynamoiPrompts(server) {
198
220
  args.contentTitle ? `Title: ${args.contentTitle}` : "",
199
221
  "",
200
222
  "Ask any missing questions first (links, creative, budget, countries, dates).",
223
+ "For review/demo Smart Campaign launches that already specify the artist, content title, budget, countries, and reusable media assets, you may proceed without asking for spotifyUrl or endDate.",
224
+ "When those review/demo fields are omitted, do not invent placeholder spotifyUrl or endDate values; omit them and let Dynamoi infer them.",
201
225
  "Then propose the simplest campaign plan that fits today\u2019s supported platforms:",
202
226
  "- Smart Campaign (Meta) for Spotify/Apple Music releases",
203
227
  "- YouTube campaign for videos",
@@ -231,114 +255,1020 @@ function registerDynamoiPrompts(server) {
231
255
  );
232
256
  }
233
257
 
258
+ // src/server/resources.ts
259
+ import {
260
+ ResourceTemplate
261
+ } from "@modelcontextprotocol/sdk/server/mcp.js";
262
+ import * as z2 from "zod/v4";
263
+ function registerDynamoiResources(server, adapter) {
264
+ server.registerResource(
265
+ "platform-pricing",
266
+ "dynamoi://platform/pricing",
267
+ {
268
+ description: "Dynamoi pricing, activation bonus, ad credit structure, and campaign budget minimums.",
269
+ mimeType: "application/json",
270
+ title: "Pricing"
271
+ },
272
+ async (uri) => ({
273
+ contents: [
274
+ {
275
+ mimeType: "application/json",
276
+ text: JSON.stringify({
277
+ activationBonus: {
278
+ amountUsd: 600,
279
+ note: "100% match on first month \u2014 pay $300, get $600 ad credit"
280
+ },
281
+ budgetMinimums: {
282
+ smartCampaign: {
283
+ dailyUsd: 10,
284
+ note: "Meta Ads for Spotify promotion",
285
+ totalUsd: 100
286
+ },
287
+ youtube: {
288
+ dailyUsd: 10,
289
+ note: "Google Ads for YouTube channel growth",
290
+ totalUsd: 50
291
+ }
292
+ },
293
+ creditRollover: "Credits roll over for 12 months",
294
+ includes: "Free Smart Links, unlimited team seats, unlimited artists, white-glove support, and campaign landing-page support where available",
295
+ noContracts: true,
296
+ tiers: [
297
+ {
298
+ name: "Plus",
299
+ note: "Managed advertising is separate from free Smart Links.",
300
+ priceUsdMonthly: 300
301
+ }
302
+ ]
303
+ }),
304
+ uri: uri.href
305
+ }
306
+ ]
307
+ })
308
+ );
309
+ server.registerResource(
310
+ "platform-content-types",
311
+ "dynamoi://platform/content-types",
312
+ { mimeType: "application/json", title: "Content Types" },
313
+ async (uri) => ({
314
+ contents: [
315
+ {
316
+ mimeType: "application/json",
317
+ text: JSON.stringify({
318
+ campaignTypes: {
319
+ SMART_CAMPAIGN: ["TRACK", "ALBUM", "PLAYLIST"],
320
+ YOUTUBE: ["VIDEO"]
321
+ },
322
+ contentTypes: ["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]
323
+ }),
324
+ uri: uri.href
325
+ }
326
+ ]
327
+ })
328
+ );
329
+ server.registerResource(
330
+ "smart-links-free-plan",
331
+ "dynamoi://smart-links/free-plan",
332
+ {
333
+ description: "Canonical explanation of Dynamoi's free Smart Links plan and how it differs from paid managed advertising.",
334
+ mimeType: "application/json",
335
+ title: "Free Smart Links"
336
+ },
337
+ async (uri) => ({
338
+ contents: [
339
+ {
340
+ mimeType: "application/json",
341
+ text: JSON.stringify({
342
+ free: true,
343
+ included: [
344
+ "Unlimited free Smart Links for supported Spotify artist, album, and track URLs",
345
+ "Smart Link analytics",
346
+ "Artist-level themes",
347
+ "Validated Meta, TikTok, and Google Ads pixel IDs",
348
+ "Publish and unpublish controls"
349
+ ],
350
+ noCatch: "No per-link fee, no subscription requirement, and no upgrade gate for Smart Links.",
351
+ paidSeparately: "Managed advertising campaigns and ad budgets are separate paid products."
352
+ }),
353
+ uri: uri.href
354
+ }
355
+ ]
356
+ })
357
+ );
358
+ server.registerResource(
359
+ "smart-links-capabilities",
360
+ "dynamoi://smart-links/capabilities",
361
+ { mimeType: "application/json", title: "Smart Link Capabilities" },
362
+ async (uri) => ({
363
+ contents: [
364
+ {
365
+ mimeType: "application/json",
366
+ text: JSON.stringify({
367
+ creationInputs: {
368
+ supportedSpotifyKinds: ["artist", "album", "track"],
369
+ unsupportedToday: ["playlist"]
370
+ },
371
+ mutableFields: {
372
+ artistLevel: [
373
+ "defaultTheme",
374
+ "metaPixelId",
375
+ "tiktokPixelId",
376
+ "googleAdsConversionId"
377
+ ],
378
+ perLink: ["customDescription", "publishState"]
379
+ },
380
+ pixelPolicy: "Only validated pixel IDs are accepted. Arbitrary JavaScript, tag snippets, and script URLs are not supported.",
381
+ themes: ["classic", "brutalist", "aurora", "cinematic"]
382
+ }),
383
+ uri: uri.href
384
+ }
385
+ ]
386
+ })
387
+ );
388
+ server.registerResource(
389
+ "platform-campaign-statuses",
390
+ "dynamoi://platform/campaign-statuses",
391
+ { mimeType: "application/json", title: "Campaign Statuses" },
392
+ async (uri) => ({
393
+ contents: [
394
+ {
395
+ mimeType: "application/json",
396
+ text: JSON.stringify({
397
+ statuses: [
398
+ "AWAITING_SMART_LINK",
399
+ "CONTENT_VALIDATION",
400
+ "DEPLOYING",
401
+ "READY_FOR_REVIEW",
402
+ "ACTIVE",
403
+ "PAUSED",
404
+ "SUBSCRIPTION_PAUSED",
405
+ "FAILED",
406
+ "ARCHIVED",
407
+ "ENDED"
408
+ ]
409
+ }),
410
+ uri: uri.href
411
+ }
412
+ ]
413
+ })
414
+ );
415
+ server.registerResource(
416
+ "artist-resource",
417
+ new ResourceTemplate("dynamoi://artist/{artistId}", {
418
+ list: async () => ({ resources: [] })
419
+ }),
420
+ { mimeType: "application/json", title: "Artist" },
421
+ async (uri, variables) => {
422
+ const artistId = variables["artistId"];
423
+ const parsed = z2.string().uuid().safeParse(artistId);
424
+ if (!parsed.success) {
425
+ return {
426
+ contents: [
427
+ {
428
+ mimeType: "application/json",
429
+ text: JSON.stringify({
430
+ message: "Invalid artistId",
431
+ status: "error"
432
+ }),
433
+ uri: uri.href
434
+ }
435
+ ]
436
+ };
437
+ }
438
+ const envelope = await adapter.getArtist({
439
+ artistId: parsed.data
440
+ });
441
+ return {
442
+ contents: [
443
+ {
444
+ mimeType: "application/json",
445
+ text: JSON.stringify(envelope),
446
+ uri: uri.href
447
+ }
448
+ ]
449
+ };
450
+ }
451
+ );
452
+ server.registerResource(
453
+ "campaign-resource",
454
+ new ResourceTemplate("dynamoi://campaign/{campaignId}", {
455
+ list: async () => ({ resources: [] })
456
+ }),
457
+ { mimeType: "application/json", title: "Campaign" },
458
+ async (uri, variables) => {
459
+ const campaignId = variables["campaignId"];
460
+ const parsed = z2.string().uuid().safeParse(campaignId);
461
+ if (!parsed.success) {
462
+ return {
463
+ contents: [
464
+ {
465
+ mimeType: "application/json",
466
+ text: JSON.stringify({
467
+ message: "Invalid campaignId",
468
+ status: "error"
469
+ }),
470
+ uri: uri.href
471
+ }
472
+ ]
473
+ };
474
+ }
475
+ const envelope = await adapter.getCampaign({
476
+ campaignId: parsed.data
477
+ });
478
+ return {
479
+ contents: [
480
+ {
481
+ mimeType: "application/json",
482
+ text: JSON.stringify(envelope),
483
+ uri: uri.href
484
+ }
485
+ ]
486
+ };
487
+ }
488
+ );
489
+ server.registerResource(
490
+ "smart-link-resource",
491
+ new ResourceTemplate("dynamoi://smart-link/{playLinkId}", {
492
+ list: async () => ({ resources: [] })
493
+ }),
494
+ { mimeType: "application/json", title: "Smart Link" },
495
+ async (uri, variables) => {
496
+ const playLinkId = variables["playLinkId"];
497
+ const parsed = z2.string().uuid().safeParse(playLinkId);
498
+ if (!parsed.success) {
499
+ return {
500
+ contents: [
501
+ {
502
+ mimeType: "application/json",
503
+ text: JSON.stringify({
504
+ message: "Invalid playLinkId",
505
+ status: "error"
506
+ }),
507
+ uri: uri.href
508
+ }
509
+ ]
510
+ };
511
+ }
512
+ const envelope = await adapter.getSmartLink({
513
+ playLinkId: parsed.data
514
+ });
515
+ return {
516
+ contents: [
517
+ {
518
+ mimeType: "application/json",
519
+ text: JSON.stringify(envelope),
520
+ uri: uri.href
521
+ }
522
+ ]
523
+ };
524
+ }
525
+ );
526
+ server.registerResource(
527
+ "smart-link-artist-settings-resource",
528
+ new ResourceTemplate("dynamoi://artist/{artistId}/smart-link-settings", {
529
+ list: async () => ({ resources: [] })
530
+ }),
531
+ { mimeType: "application/json", title: "Smart Link Artist Settings" },
532
+ async (uri, variables) => {
533
+ const artistId = variables["artistId"];
534
+ const parsed = z2.string().uuid().safeParse(artistId);
535
+ if (!parsed.success) {
536
+ return {
537
+ contents: [
538
+ {
539
+ mimeType: "application/json",
540
+ text: JSON.stringify({
541
+ message: "Invalid artistId",
542
+ status: "error"
543
+ }),
544
+ uri: uri.href
545
+ }
546
+ ]
547
+ };
548
+ }
549
+ const envelope = await adapter.getSmartLinkArtistSettings({
550
+ artistId: parsed.data
551
+ });
552
+ return {
553
+ contents: [
554
+ {
555
+ mimeType: "application/json",
556
+ text: JSON.stringify(envelope),
557
+ uri: uri.href
558
+ }
559
+ ]
560
+ };
561
+ }
562
+ );
563
+ }
564
+
565
+ // src/server/smart-link-tools.ts
566
+ import * as z4 from "zod/v4";
567
+
568
+ // src/server/output-schemas.ts
569
+ import * as z3 from "zod/v4";
570
+ var MoneyDisplayOutputSchema = z3.object({
571
+ amountUsd: z3.number(),
572
+ formatted: z3.string()
573
+ }).strict();
574
+ var ErrorEnvelopeOutputSchema = z3.object({
575
+ kind: z3.enum(["validation", "business", "platform", "unknown"]).optional(),
576
+ message: z3.string(),
577
+ status: z3.literal("error")
578
+ }).strict();
579
+ var AnyToolDataOutputSchema = z3.object({}).passthrough();
580
+ var PauseResumePlatformResultOutputSchema = z3.object({
581
+ message: z3.string().optional(),
582
+ platform: z3.enum(["META", "GOOGLE"]),
583
+ success: z3.boolean()
584
+ }).strict();
585
+ var PauseResumeCampaignDataOutputSchema = z3.object({
586
+ actionRequired: z3.array(z3.string()).optional(),
587
+ contentTitle: z3.string(),
588
+ id: z3.string(),
589
+ newStatus: z3.enum(["PAUSED", "ACTIVE"]),
590
+ platformResults: z3.array(PauseResumePlatformResultOutputSchema),
591
+ warnings: z3.array(z3.string()).optional()
592
+ }).strict();
593
+ var UpdateBudgetDataOutputSchema = z3.object({
594
+ actionRequired: z3.array(z3.string()).optional(),
595
+ budgetType: z3.enum(["DAILY", "TOTAL"]),
596
+ contentTitle: z3.string(),
597
+ endDate: z3.string().optional(),
598
+ id: z3.string(),
599
+ newBudget: MoneyDisplayOutputSchema,
600
+ previousBudget: MoneyDisplayOutputSchema,
601
+ warnings: z3.array(z3.string()).optional()
602
+ }).strict();
603
+ var MediaAssetSummaryOutputSchema = z3.object({
604
+ aspectRatio: z3.string().optional(),
605
+ createdAt: z3.string(),
606
+ fileName: z3.string().optional(),
607
+ fileType: z3.string(),
608
+ height: z3.number().optional(),
609
+ id: z3.string(),
610
+ url: z3.string().optional(),
611
+ urlExpiresAt: z3.string().optional(),
612
+ width: z3.number().optional()
613
+ }).strict();
614
+ var ListMediaAssetsDataOutputSchema = z3.object({
615
+ assets: z3.array(MediaAssetSummaryOutputSchema),
616
+ nextCursor: z3.string().optional()
617
+ }).strict();
618
+ var ListMediaAssetsSummaryOutputSchema = z3.object({
619
+ nextCursor: z3.string().optional(),
620
+ summary: z3.string(),
621
+ totalCount: z3.number()
622
+ }).strict();
623
+ var SmartLinkStatusSchemas = {
624
+ claimStatus: z3.enum([
625
+ "auto_approved",
626
+ "pending_ops_review",
627
+ "approved_by_ops",
628
+ "rejected"
629
+ ]),
630
+ odesliStatus: z3.enum(["pending", "resolved", "failed"]),
631
+ publishState: z3.enum(["published", "unpublished"]),
632
+ renderState: z3.enum(["queued", "rendering", "rendered", "failed"]),
633
+ takedownStatus: z3.enum(["none", "active", "resolved"]),
634
+ theme: z3.enum(["classic", "brutalist", "aurora", "cinematic"])
635
+ };
636
+ var SmartLinkSummaryOutputSchema = z3.object({
637
+ artistId: z3.string(),
638
+ artistName: z3.string(),
639
+ claimStatus: SmartLinkStatusSchemas.claimStatus,
640
+ createdAt: z3.string(),
641
+ id: z3.string(),
642
+ isPublic: z3.boolean(),
643
+ localizedPublicUrls: z3.array(z3.string()).optional(),
644
+ odesliStatus: SmartLinkStatusSchemas.odesliStatus,
645
+ publicUrl: z3.string(),
646
+ publishState: SmartLinkStatusSchemas.publishState,
647
+ releaseSlug: z3.string(),
648
+ releaseTitle: z3.string(),
649
+ releaseType: z3.string(),
650
+ renderState: SmartLinkStatusSchemas.renderState,
651
+ spotifyUrl: z3.string().nullable(),
652
+ takedownStatus: SmartLinkStatusSchemas.takedownStatus,
653
+ theme: SmartLinkStatusSchemas.theme,
654
+ updatedAt: z3.string()
655
+ }).strict();
656
+ var SmartLinkDetailsOutputSchema = SmartLinkSummaryOutputSchema.extend({
657
+ actionRequired: z3.array(z3.string()).optional(),
658
+ customDescription: z3.string().nullable(),
659
+ nextActions: z3.array(z3.string()),
660
+ originalSpotifyUrl: z3.string().nullable(),
661
+ resourceUri: z3.string(),
662
+ settingsResourceUri: z3.string(),
663
+ spotifyDiscographyId: z3.string(),
664
+ warnings: z3.array(z3.string()).optional()
665
+ }).strict();
666
+ var ListSmartLinksDataOutputSchema = z3.object({
667
+ nextCursor: z3.string().optional(),
668
+ smartLinks: z3.array(SmartLinkSummaryOutputSchema)
669
+ }).strict();
670
+ var ListSmartLinksSummaryOutputSchema = z3.object({
671
+ nextCursor: z3.string().optional(),
672
+ summary: z3.string(),
673
+ totalCount: z3.number()
674
+ }).strict();
675
+ var SmartLinkSettingsOutputSchema = z3.object({
676
+ artistId: z3.string(),
677
+ artistName: z3.string(),
678
+ availableThemes: z3.array(SmartLinkStatusSchemas.theme),
679
+ defaultTheme: SmartLinkStatusSchemas.theme,
680
+ isEnabled: z3.boolean(),
681
+ pixels: z3.object({
682
+ googleAdsConversionId: z3.string().nullable(),
683
+ metaPixelId: z3.string().nullable(),
684
+ tiktokPixelId: z3.string().nullable()
685
+ }).strict(),
686
+ summary: z3.string().optional()
687
+ }).strict();
688
+ var SmartLinkAnalyticsTotalsOutputSchema = z3.object({
689
+ anonymousVisits: z3.number(),
690
+ promoteCtaClicks: z3.number(),
691
+ shareClicks: z3.number(),
692
+ streamingServiceClicks: z3.number()
693
+ }).strict();
694
+ var SmartLinkBreakdownsOutputSchema = z3.object({
695
+ countryClicks: z3.record(z3.string(), z3.number()).optional(),
696
+ countryViews: z3.record(z3.string(), z3.number()).optional(),
697
+ deviceClicks: z3.record(z3.string(), z3.number()).optional(),
698
+ deviceViews: z3.record(z3.string(), z3.number()).optional(),
699
+ localeClicks: z3.record(z3.string(), z3.number()).optional(),
700
+ localeViews: z3.record(z3.string(), z3.number()).optional(),
701
+ referrerClicks: z3.record(z3.string(), z3.number()).optional(),
702
+ referrerViews: z3.record(z3.string(), z3.number()).optional(),
703
+ serviceClicks: z3.record(z3.string(), z3.number()).optional(),
704
+ themeClicks: z3.record(z3.string(), z3.number()).optional(),
705
+ themeViews: z3.record(z3.string(), z3.number()).optional(),
706
+ utmClicks: z3.record(z3.string(), z3.number()).optional(),
707
+ utmViews: z3.record(z3.string(), z3.number()).optional()
708
+ }).strict();
709
+ var SmartLinkAnalyticsOutputSchema = z3.object({
710
+ artistId: z3.string(),
711
+ breakdowns: SmartLinkBreakdownsOutputSchema.optional(),
712
+ daily: z3.array(
713
+ SmartLinkAnalyticsTotalsOutputSchema.extend({
714
+ date: z3.string()
715
+ }).strict()
716
+ ).optional(),
717
+ dateRange: z3.object({ end: z3.string(), start: z3.string() }).strict(),
718
+ playLinkId: z3.string(),
719
+ releaseTitle: z3.string(),
720
+ totals: SmartLinkAnalyticsTotalsOutputSchema,
721
+ warnings: z3.array(z3.string()).optional()
722
+ }).strict();
723
+ var SmartLinkAnalyticsSummaryOutputSchema = z3.object({
724
+ summary: z3.string(),
725
+ warnings: z3.array(z3.string()).optional()
726
+ }).strict();
727
+ var CreateSmartLinkFromSpotifyDataOutputSchema = SmartLinkDetailsOutputSchema.extend({
728
+ outcome: z3.enum(["created", "existing"]),
729
+ workflowRunId: z3.string().nullable(),
730
+ workflowWarning: z3.string().nullable()
731
+ }).strict();
732
+ var UpdateSmartLinkDataOutputSchema = SmartLinkDetailsOutputSchema.extend({
733
+ renderRunId: z3.string().nullable(),
734
+ renderWarning: z3.string().nullable()
735
+ }).strict();
736
+ var UpdateSmartLinkArtistSettingsDataOutputSchema = SmartLinkSettingsOutputSchema.extend({
737
+ renderQueuedCount: z3.number(),
738
+ renderWarning: z3.string().nullable()
739
+ }).strict();
740
+ var PublishSmartLinkDataOutputSchema = SmartLinkDetailsOutputSchema.extend({
741
+ workflowRunId: z3.string().nullable(),
742
+ workflowWarning: z3.string().nullable()
743
+ }).strict();
744
+ var LaunchCampaignDataOutputSchema = z3.object({
745
+ budget: MoneyDisplayOutputSchema,
746
+ budgetType: z3.enum(["DAILY", "TOTAL"]),
747
+ campaignType: z3.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
748
+ contentTitle: z3.string(),
749
+ deliveryState: z3.enum(["ACTIVE", "PENDING_REVIEW", "CONTENT_VALIDATION"]),
750
+ id: z3.string(),
751
+ isLive: z3.boolean(),
752
+ nextSteps: z3.array(z3.string()),
753
+ platforms: z3.array(z3.string()),
754
+ status: z3.string(),
755
+ summary: z3.string(),
756
+ warnings: z3.array(z3.string()).optional()
757
+ }).strict();
758
+ var AnyOutputEnvelopeSchema = z3.union([
759
+ z3.object({ data: AnyToolDataOutputSchema, status: z3.literal("success") }),
760
+ z3.object({
761
+ data: AnyToolDataOutputSchema,
762
+ message: z3.string(),
763
+ status: z3.literal("partial_success")
764
+ }),
765
+ ErrorEnvelopeOutputSchema
766
+ ]);
767
+ var PauseResumeOutputEnvelopeSchema = z3.union([
768
+ z3.object({
769
+ data: PauseResumeCampaignDataOutputSchema,
770
+ status: z3.literal("success")
771
+ }),
772
+ z3.object({
773
+ data: PauseResumeCampaignDataOutputSchema,
774
+ message: z3.string(),
775
+ status: z3.literal("partial_success")
776
+ }),
777
+ ErrorEnvelopeOutputSchema
778
+ ]);
779
+ var UpdateBudgetOutputEnvelopeSchema = z3.union([
780
+ z3.object({
781
+ data: UpdateBudgetDataOutputSchema,
782
+ status: z3.literal("success")
783
+ }),
784
+ z3.object({
785
+ data: UpdateBudgetDataOutputSchema,
786
+ message: z3.string(),
787
+ status: z3.literal("partial_success")
788
+ }),
789
+ ErrorEnvelopeOutputSchema
790
+ ]);
791
+ var ListMediaAssetsOutputEnvelopeSchema = z3.union([
792
+ z3.object({
793
+ data: z3.union([
794
+ ListMediaAssetsDataOutputSchema,
795
+ ListMediaAssetsSummaryOutputSchema
796
+ ]),
797
+ status: z3.literal("success")
798
+ }),
799
+ ErrorEnvelopeOutputSchema
800
+ ]);
801
+ var LaunchCampaignOutputEnvelopeSchema = z3.union([
802
+ z3.object({
803
+ data: LaunchCampaignDataOutputSchema,
804
+ status: z3.literal("success")
805
+ }),
806
+ ErrorEnvelopeOutputSchema
807
+ ]);
808
+ var CreateSmartLinkFromSpotifyOutputEnvelopeSchema = z3.union([
809
+ z3.object({
810
+ data: CreateSmartLinkFromSpotifyDataOutputSchema,
811
+ status: z3.literal("success")
812
+ }),
813
+ ErrorEnvelopeOutputSchema
814
+ ]);
815
+ var ListSmartLinksOutputEnvelopeSchema = z3.union([
816
+ z3.object({
817
+ data: z3.union([
818
+ ListSmartLinksDataOutputSchema,
819
+ ListSmartLinksSummaryOutputSchema
820
+ ]),
821
+ status: z3.literal("success")
822
+ }),
823
+ ErrorEnvelopeOutputSchema
824
+ ]);
825
+ var GetSmartLinkOutputEnvelopeSchema = z3.union([
826
+ z3.object({
827
+ data: z3.union([
828
+ SmartLinkDetailsOutputSchema,
829
+ z3.object({ summary: z3.string() }).passthrough()
830
+ ]),
831
+ status: z3.literal("success")
832
+ }),
833
+ ErrorEnvelopeOutputSchema
834
+ ]);
835
+ var GetSmartLinkAnalyticsOutputEnvelopeSchema = z3.union([
836
+ z3.object({
837
+ data: z3.union([
838
+ SmartLinkAnalyticsOutputSchema,
839
+ SmartLinkAnalyticsSummaryOutputSchema
840
+ ]),
841
+ status: z3.literal("success")
842
+ }),
843
+ ErrorEnvelopeOutputSchema
844
+ ]);
845
+ var SmartLinkArtistSettingsOutputEnvelopeSchema = z3.union([
846
+ z3.object({
847
+ data: SmartLinkSettingsOutputSchema,
848
+ status: z3.literal("success")
849
+ }),
850
+ ErrorEnvelopeOutputSchema
851
+ ]);
852
+ var UpdateSmartLinkOutputEnvelopeSchema = z3.union([
853
+ z3.object({
854
+ data: UpdateSmartLinkDataOutputSchema,
855
+ status: z3.literal("success")
856
+ }),
857
+ ErrorEnvelopeOutputSchema
858
+ ]);
859
+ var UpdateSmartLinkArtistSettingsOutputEnvelopeSchema = z3.union([
860
+ z3.object({
861
+ data: UpdateSmartLinkArtistSettingsDataOutputSchema,
862
+ status: z3.literal("success")
863
+ }),
864
+ ErrorEnvelopeOutputSchema
865
+ ]);
866
+ var PublishSmartLinkOutputEnvelopeSchema = z3.union([
867
+ z3.object({
868
+ data: PublishSmartLinkDataOutputSchema,
869
+ status: z3.literal("success")
870
+ }),
871
+ ErrorEnvelopeOutputSchema
872
+ ]);
873
+
874
+ // src/server/smart-link-tools.ts
875
+ var ToolFormatSchema = z4.enum(["json", "summary"]);
876
+ var IsoDateSchema = z4.string().regex(/^\d{4}-\d{2}-\d{2}$/);
877
+ var UserIntentSummarySchema = z4.string().trim().max(500).optional();
878
+ var ClientRequestIdSchema = z4.string().uuid().optional();
879
+ var RequiredClientRequestIdSchema = z4.string().uuid();
880
+ function isValidCalendarDate(value) {
881
+ const date = /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
882
+ return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
883
+ }
884
+ var DateRangeSchema = z4.object({
885
+ end: IsoDateSchema,
886
+ start: IsoDateSchema
887
+ }).strict().superRefine((data, ctx) => {
888
+ if (!isValidCalendarDate(data.start)) {
889
+ ctx.addIssue({
890
+ code: "custom",
891
+ message: "start must be a valid calendar date",
892
+ path: ["start"]
893
+ });
894
+ }
895
+ if (!isValidCalendarDate(data.end)) {
896
+ ctx.addIssue({
897
+ code: "custom",
898
+ message: "end must be a valid calendar date",
899
+ path: ["end"]
900
+ });
901
+ }
902
+ if (isValidCalendarDate(data.start) && isValidCalendarDate(data.end) && data.start > data.end) {
903
+ ctx.addIssue({
904
+ code: "custom",
905
+ message: "start must be on or before end",
906
+ path: ["start"]
907
+ });
908
+ }
909
+ });
910
+ var SmartLinkStatusFiltersSchema = {
911
+ claimStatus: z4.enum([
912
+ "auto_approved",
913
+ "pending_ops_review",
914
+ "approved_by_ops",
915
+ "rejected"
916
+ ]).optional(),
917
+ publishState: z4.enum(["published", "unpublished"]).optional(),
918
+ renderState: z4.enum(["queued", "rendering", "rendered", "failed"]).optional()
919
+ };
920
+ var SmartLinkThemeSchema = z4.enum([
921
+ "classic",
922
+ "brutalist",
923
+ "aurora",
924
+ "cinematic"
925
+ ]);
926
+ var DynamoiCreateSmartLinkFromSpotifyInputSchema = z4.object({
927
+ artistId: z4.string().uuid(),
928
+ clientRequestId: RequiredClientRequestIdSchema.optional(),
929
+ customDescription: z4.string().trim().max(500).optional(),
930
+ format: ToolFormatSchema.optional(),
931
+ spotifyUrl: z4.string().trim().min(1).max(500),
932
+ userIntentSummary: UserIntentSummarySchema
933
+ }).strict();
934
+ var DynamoiListSmartLinksInputSchema = z4.object({
935
+ artistId: z4.string().uuid(),
936
+ cursor: z4.string().optional(),
937
+ format: ToolFormatSchema.optional(),
938
+ limit: z4.number().int().min(1).max(50).optional(),
939
+ query: z4.string().trim().max(120).optional(),
940
+ ...SmartLinkStatusFiltersSchema
941
+ }).strict();
942
+ var DynamoiGetSmartLinkInputSchema = z4.object({
943
+ artistId: z4.string().uuid().optional(),
944
+ format: ToolFormatSchema.optional(),
945
+ playLinkId: z4.string().uuid().optional(),
946
+ spotifyUrl: z4.string().trim().min(1).max(500).optional()
947
+ }).strict().superRefine((data, ctx) => {
948
+ if (!(data.playLinkId || data.artistId && data.spotifyUrl)) {
949
+ ctx.addIssue({
950
+ code: "custom",
951
+ message: "Provide playLinkId or artistId with spotifyUrl",
952
+ path: ["playLinkId"]
953
+ });
954
+ }
955
+ });
956
+ var DynamoiGetSmartLinkAnalyticsInputSchema = z4.object({
957
+ dateRange: DateRangeSchema.optional(),
958
+ format: ToolFormatSchema.optional(),
959
+ granularity: z4.enum(["TOTAL", "DAILY"]).optional(),
960
+ includeBreakdowns: z4.boolean().optional(),
961
+ playLinkId: z4.string().uuid()
962
+ }).strict();
963
+ var DynamoiGetSmartLinkArtistSettingsInputSchema = z4.object({
964
+ artistId: z4.string().uuid(),
965
+ format: ToolFormatSchema.optional()
966
+ }).strict();
967
+ var DynamoiUpdateSmartLinkInputSchema = z4.object({
968
+ clientRequestId: ClientRequestIdSchema,
969
+ customDescription: z4.string().max(500).nullable(),
970
+ expectedUpdatedAt: z4.string().datetime().optional(),
971
+ playLinkId: z4.string().uuid(),
972
+ userIntentSummary: UserIntentSummarySchema
973
+ }).strict();
974
+ var DynamoiUpdateSmartLinkArtistSettingsInputSchema = z4.object({
975
+ artistId: z4.string().uuid(),
976
+ clientRequestId: ClientRequestIdSchema,
977
+ googleAdsConversionId: z4.string().trim().max(32).nullable().optional(),
978
+ metaPixelId: z4.string().trim().max(32).nullable().optional(),
979
+ theme: SmartLinkThemeSchema.optional(),
980
+ tiktokPixelId: z4.string().trim().max(32).nullable().optional(),
981
+ userIntentSummary: UserIntentSummarySchema
982
+ }).strict().superRefine((data, ctx) => {
983
+ if (data.theme === void 0 && data.metaPixelId === void 0 && data.tiktokPixelId === void 0 && data.googleAdsConversionId === void 0) {
984
+ ctx.addIssue({
985
+ code: "custom",
986
+ message: "Provide at least one setting to update",
987
+ path: ["theme"]
988
+ });
989
+ }
990
+ });
991
+ var DynamoiPublishSmartLinkInputSchema = z4.object({
992
+ clientRequestId: ClientRequestIdSchema,
993
+ expectedPublishState: z4.enum(["published", "unpublished"]).optional(),
994
+ playLinkId: z4.string().uuid(),
995
+ userIntentSummary: UserIntentSummarySchema
996
+ }).strict();
997
+ var PHASE_4_TOOL_DEFINITIONS = [
998
+ {
999
+ description: "Use this when the user wants to create a free Dynamoi Smart Link from a Spotify artist, album, or track URL/URI. Smart Links are free: no per-link fee, no subscription requirement, and no upgrade gate. This does not create a paid ad campaign. Spotify playlist URLs are not supported today. If the Smart Link already exists, return the existing link instead of creating a duplicate.",
1000
+ destructiveHint: false,
1001
+ idempotentHint: true,
1002
+ name: "dynamoi_create_smart_link_from_spotify",
1003
+ openWorldHint: true,
1004
+ outputSchema: CreateSmartLinkFromSpotifyOutputEnvelopeSchema,
1005
+ readOnlyHint: false,
1006
+ schema: DynamoiCreateSmartLinkFromSpotifyInputSchema,
1007
+ title: "Create Free Smart Link from Spotify"
1008
+ },
1009
+ {
1010
+ description: "Use this when the user wants to list free Smart Links for one artist, including release title, public URL, publish state, claim state, render state, and theme. Do not use this for paid campaign lists; use dynamoi_list_campaigns for campaigns.",
1011
+ destructiveHint: false,
1012
+ name: "dynamoi_list_smart_links",
1013
+ openWorldHint: false,
1014
+ outputSchema: ListSmartLinksOutputEnvelopeSchema,
1015
+ readOnlyHint: true,
1016
+ schema: DynamoiListSmartLinksInputSchema,
1017
+ title: "List Smart Links"
1018
+ },
1019
+ {
1020
+ description: "Use this when the user wants full details for one free Smart Link, including release, Spotify URL, public play.dynamoi.com URL, current status, theme source, and next actions.",
1021
+ destructiveHint: false,
1022
+ name: "dynamoi_get_smart_link",
1023
+ openWorldHint: false,
1024
+ outputSchema: GetSmartLinkOutputEnvelopeSchema,
1025
+ readOnlyHint: true,
1026
+ schema: DynamoiGetSmartLinkInputSchema,
1027
+ title: "Get Smart Link"
1028
+ },
1029
+ {
1030
+ description: "Use this when the user asks how one free Smart Link is performing. Returns aggregate visits, streaming-service clicks, share clicks, promote CTA clicks, and optional daily or capped breakdown data. Never use this to expose raw visitor identifiers.",
1031
+ destructiveHint: false,
1032
+ name: "dynamoi_get_smart_link_analytics",
1033
+ openWorldHint: false,
1034
+ outputSchema: GetSmartLinkAnalyticsOutputEnvelopeSchema,
1035
+ readOnlyHint: true,
1036
+ schema: DynamoiGetSmartLinkAnalyticsInputSchema,
1037
+ title: "Get Smart Link Analytics"
1038
+ },
1039
+ {
1040
+ description: "Use this when the user wants to inspect artist-level Smart Link settings, including whether Smart Links are enabled, default theme, available themes, and configured tracking pixel IDs.",
1041
+ destructiveHint: false,
1042
+ name: "dynamoi_get_smart_link_artist_settings",
1043
+ openWorldHint: false,
1044
+ outputSchema: SmartLinkArtistSettingsOutputEnvelopeSchema,
1045
+ readOnlyHint: true,
1046
+ schema: DynamoiGetSmartLinkArtistSettingsInputSchema,
1047
+ title: "Get Smart Link Artist Settings"
1048
+ },
1049
+ {
1050
+ description: "Use this when the user wants to change one Smart Link's public description. This updates a public landing page and queues background rendering. Theme and pixel settings are artist-level; use dynamoi_update_smart_link_artist_settings for those.",
1051
+ destructiveHint: false,
1052
+ idempotentHint: true,
1053
+ name: "dynamoi_update_smart_link",
1054
+ openWorldHint: true,
1055
+ outputSchema: UpdateSmartLinkOutputEnvelopeSchema,
1056
+ readOnlyHint: false,
1057
+ schema: DynamoiUpdateSmartLinkInputSchema,
1058
+ title: "Update Smart Link"
1059
+ },
1060
+ {
1061
+ description: "Use this when the user wants to update artist-level Smart Link theme or tracking pixel IDs. These settings apply to all current and future Smart Links for the artist. Accepts only validated Meta Pixel ID, TikTok Pixel ID, and Google Ads Conversion ID; arbitrary JavaScript or script snippets are not supported.",
1062
+ destructiveHint: false,
1063
+ idempotentHint: true,
1064
+ name: "dynamoi_update_smart_link_artist_settings",
1065
+ openWorldHint: true,
1066
+ outputSchema: UpdateSmartLinkArtistSettingsOutputEnvelopeSchema,
1067
+ readOnlyHint: false,
1068
+ schema: DynamoiUpdateSmartLinkArtistSettingsInputSchema,
1069
+ title: "Update Smart Link Artist Settings"
1070
+ },
1071
+ {
1072
+ description: "Use this when the user explicitly wants to publish an approved Smart Link and expose its public play.dynamoi.com URL. Cannot publish rejected, pending-review, or takedown-active links.",
1073
+ destructiveHint: false,
1074
+ idempotentHint: true,
1075
+ name: "dynamoi_publish_smart_link",
1076
+ openWorldHint: true,
1077
+ outputSchema: PublishSmartLinkOutputEnvelopeSchema,
1078
+ readOnlyHint: false,
1079
+ schema: DynamoiPublishSmartLinkInputSchema,
1080
+ title: "Publish Smart Link"
1081
+ },
1082
+ {
1083
+ description: "Use this when the user explicitly wants to unpublish a Smart Link and remove its public play.dynamoi.com landing page. Restate the affected public URL before calling this tool.",
1084
+ destructiveHint: true,
1085
+ idempotentHint: true,
1086
+ name: "dynamoi_unpublish_smart_link",
1087
+ openWorldHint: true,
1088
+ outputSchema: PublishSmartLinkOutputEnvelopeSchema,
1089
+ readOnlyHint: false,
1090
+ schema: DynamoiPublishSmartLinkInputSchema,
1091
+ title: "Unpublish Smart Link"
1092
+ }
1093
+ ];
1094
+
234
1095
  // src/server/tools.ts
235
- import * as z2 from "zod/v4";
236
- var ToolFormatSchema = z2.enum(["json", "summary"]);
237
- var DynamoiListArtistsInputSchema = z2.object({
238
- cursor: z2.string().optional(),
239
- format: ToolFormatSchema.optional(),
240
- limit: z2.number().int().min(1).max(50).optional()
241
- });
242
- var DynamoiSearchInputSchema = z2.object({
243
- artistId: z2.string().uuid().optional(),
244
- cursor: z2.string().optional(),
245
- format: ToolFormatSchema.optional(),
246
- limit: z2.number().int().min(1).max(50).optional(),
247
- query: z2.string().trim().optional(),
248
- type: z2.enum(["artist", "campaign", "smartlink"]).optional()
249
- });
250
- var DynamoiGetCurrentUserInputSchema = z2.object({
251
- format: ToolFormatSchema.optional()
252
- });
253
- var DynamoiGetArtistInputSchema = z2.object({
254
- artistId: z2.string().uuid(),
255
- format: ToolFormatSchema.optional()
256
- });
257
- var DynamoiListCampaignsInputSchema = z2.object({
258
- artistId: z2.string().uuid(),
259
- campaignType: z2.enum(["SMART_CAMPAIGN", "YOUTUBE"]).optional(),
260
- cursor: z2.string().optional(),
261
- format: ToolFormatSchema.optional(),
262
- limit: z2.number().int().min(1).max(50).optional(),
263
- status: z2.string().trim().optional()
264
- });
265
- var DynamoiGetCampaignInputSchema = z2.object({
266
- campaignId: z2.string().uuid(),
267
- format: ToolFormatSchema.optional()
268
- });
269
- var DateRangeSchema = z2.object({
270
- end: z2.string().regex(/^\d{4}-\d{2}-\d{2}$/),
271
- start: z2.string().regex(/^\d{4}-\d{2}-\d{2}$/)
272
- });
273
- var DynamoiGetCampaignAnalyticsInputSchema = z2.object({
274
- campaignId: z2.string().uuid(),
275
- dateRange: DateRangeSchema.optional(),
276
- format: ToolFormatSchema.optional(),
277
- granularity: z2.enum(["TOTAL", "DAILY"]).optional()
278
- });
279
- var DynamoiGetBillingInputSchema = z2.object({
280
- artistId: z2.string().uuid(),
281
- format: ToolFormatSchema.optional()
282
- });
283
- var DynamoiGetPlatformStatusInputSchema = z2.object({
284
- artistId: z2.string().uuid(),
285
- format: ToolFormatSchema.optional()
286
- });
287
- var DynamoiPauseCampaignInputSchema = z2.object({
288
- campaignId: z2.string().uuid()
289
- });
290
- var DynamoiResumeCampaignInputSchema = z2.object({
291
- campaignId: z2.string().uuid()
292
- });
293
- var DynamoiUpdateBudgetInputSchema = z2.object({
294
- budgetAmount: z2.number().finite().positive(),
295
- campaignId: z2.string().uuid(),
296
- endDate: z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional()
297
- });
298
- var LocationTargetSchema = z2.object({
299
- code: z2.string().min(1),
300
- name: z2.string().min(1)
1096
+ import * as z5 from "zod/v4";
1097
+ var ToolFormatSchema2 = z5.enum(["json", "summary"]);
1098
+ var IsoDateSchema2 = z5.string().regex(/^\d{4}-\d{2}-\d{2}$/);
1099
+ var UserIntentSummarySchema2 = z5.string().trim().max(500).optional();
1100
+ var ClientRequestIdSchema2 = z5.string().uuid().optional();
1101
+ var ExpectedCampaignStatusSchema = z5.enum([
1102
+ "AWAITING_SMART_LINK",
1103
+ "ACTIVE",
1104
+ "ARCHIVED",
1105
+ "CONTENT_VALIDATION",
1106
+ "DEPLOYING",
1107
+ "ENDED",
1108
+ "FAILED",
1109
+ "PAUSED",
1110
+ "READY_FOR_REVIEW",
1111
+ "SUBSCRIPTION_PAUSED"
1112
+ ]).optional();
1113
+ function isValidCalendarDate2(value) {
1114
+ const date = /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
1115
+ return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
1116
+ }
1117
+ var DynamoiListArtistsInputSchema = z5.object({
1118
+ cursor: z5.string().optional(),
1119
+ format: ToolFormatSchema2.optional(),
1120
+ limit: z5.number().int().min(1).max(50).optional()
1121
+ }).strict();
1122
+ var DynamoiSearchInputSchema = z5.object({
1123
+ artistId: z5.string().uuid().optional(),
1124
+ cursor: z5.string().optional(),
1125
+ format: ToolFormatSchema2.optional(),
1126
+ includeArchived: z5.boolean().optional(),
1127
+ limit: z5.number().int().min(1).max(50).optional(),
1128
+ query: z5.string().trim().max(120).optional(),
1129
+ type: z5.enum(["artist", "campaign", "smartlink"]).optional()
1130
+ }).strict().superRefine((data, ctx) => {
1131
+ if (!(data.type || data.query)) {
1132
+ ctx.addIssue({
1133
+ code: "custom",
1134
+ message: "query is required when type is not specified",
1135
+ path: ["query"]
1136
+ });
1137
+ }
301
1138
  });
302
- var DynamoiListMediaAssetsInputSchema = z2.object({
303
- artistId: z2.string().uuid(),
304
- cursor: z2.string().optional(),
305
- format: ToolFormatSchema.optional(),
306
- limit: z2.number().int().min(1).max(50).optional()
1139
+ var DynamoiGetCurrentUserIntentSchema = z5.enum([
1140
+ "account_overview",
1141
+ "artist_access_check",
1142
+ "organization_access_check",
1143
+ "platform_connection_check"
1144
+ ]);
1145
+ var DynamoiGetCurrentUserInputSchema = z5.object({
1146
+ format: ToolFormatSchema2.optional(),
1147
+ intent: DynamoiGetCurrentUserIntentSchema
1148
+ }).strict();
1149
+ var DynamoiGetArtistInputSchema = z5.object({
1150
+ artistId: z5.string().uuid(),
1151
+ format: ToolFormatSchema2.optional()
1152
+ }).strict();
1153
+ var DynamoiListCampaignsInputSchema = z5.object({
1154
+ artistId: z5.string().uuid(),
1155
+ campaignType: z5.enum(["SMART_CAMPAIGN", "YOUTUBE"]).optional(),
1156
+ cursor: z5.string().optional(),
1157
+ format: ToolFormatSchema2.optional(),
1158
+ limit: z5.number().int().min(1).max(50).optional(),
1159
+ status: z5.string().trim().optional()
1160
+ }).strict();
1161
+ var DynamoiGetCampaignInputSchema = z5.object({
1162
+ campaignId: z5.string().uuid(),
1163
+ format: ToolFormatSchema2.optional(),
1164
+ includeCountries: z5.boolean().optional()
1165
+ }).strict();
1166
+ var DateRangeSchema2 = z5.object({
1167
+ end: IsoDateSchema2,
1168
+ start: IsoDateSchema2
1169
+ }).strict().superRefine((data, ctx) => {
1170
+ if (!isValidCalendarDate2(data.start)) {
1171
+ ctx.addIssue({
1172
+ code: "custom",
1173
+ message: "start must be a valid calendar date",
1174
+ path: ["start"]
1175
+ });
1176
+ }
1177
+ if (!isValidCalendarDate2(data.end)) {
1178
+ ctx.addIssue({
1179
+ code: "custom",
1180
+ message: "end must be a valid calendar date",
1181
+ path: ["end"]
1182
+ });
1183
+ }
1184
+ if (isValidCalendarDate2(data.start) && isValidCalendarDate2(data.end) && data.start > data.end) {
1185
+ ctx.addIssue({
1186
+ code: "custom",
1187
+ message: "start must be on or before end",
1188
+ path: ["start"]
1189
+ });
1190
+ }
307
1191
  });
308
- var DynamoiLaunchCampaignInputSchema = z2.object({
1192
+ var DynamoiGetCampaignAnalyticsInputSchema = z5.object({
1193
+ campaignId: z5.string().uuid(),
1194
+ dateRange: DateRangeSchema2.optional(),
1195
+ format: ToolFormatSchema2.optional(),
1196
+ granularity: z5.enum(["TOTAL", "DAILY"]).optional()
1197
+ }).strict();
1198
+ var DynamoiGetArtistAnalyticsInputSchema = z5.object({
1199
+ artistId: z5.string().uuid(),
1200
+ dateRange: DateRangeSchema2.optional(),
1201
+ format: ToolFormatSchema2.optional(),
1202
+ granularity: z5.enum(["TOTAL", "DAILY"]).optional()
1203
+ }).strict();
1204
+ var DynamoiGetBillingInputSchema = z5.object({
1205
+ artistId: z5.string().uuid(),
1206
+ format: ToolFormatSchema2.optional()
1207
+ }).strict();
1208
+ var DynamoiGetPlatformStatusInputSchema = z5.object({
1209
+ artistId: z5.string().uuid(),
1210
+ format: ToolFormatSchema2.optional()
1211
+ }).strict();
1212
+ var DynamoiPauseCampaignInputSchema = z5.object({
1213
+ campaignId: z5.string().uuid(),
1214
+ clientRequestId: ClientRequestIdSchema2,
1215
+ expectedCurrentStatus: ExpectedCampaignStatusSchema,
1216
+ userIntentSummary: UserIntentSummarySchema2
1217
+ }).strict();
1218
+ var DynamoiResumeCampaignInputSchema = z5.object({
1219
+ campaignId: z5.string().uuid(),
1220
+ clientRequestId: ClientRequestIdSchema2,
1221
+ expectedCurrentStatus: ExpectedCampaignStatusSchema,
1222
+ userIntentSummary: UserIntentSummarySchema2
1223
+ }).strict();
1224
+ var DynamoiUpdateBudgetInputSchema = z5.object({
1225
+ budgetAmount: z5.number().finite().positive(),
1226
+ campaignId: z5.string().uuid(),
1227
+ clientRequestId: ClientRequestIdSchema2,
1228
+ endDate: IsoDateSchema2.optional(),
1229
+ expectedCurrentBudgetAmount: z5.number().finite().positive().optional(),
1230
+ expectedCurrentEndDate: IsoDateSchema2.optional(),
1231
+ userIntentSummary: UserIntentSummarySchema2
1232
+ }).strict();
1233
+ var LocationTargetSchema = z5.object({
1234
+ code: z5.string().trim().min(1).max(8),
1235
+ name: z5.string().trim().min(1).max(120)
1236
+ }).strict();
1237
+ var DynamoiListMediaAssetsInputSchema = z5.object({
1238
+ artistId: z5.string().uuid(),
1239
+ cursor: z5.string().optional(),
1240
+ format: ToolFormatSchema2.optional(),
1241
+ includeUrls: z5.boolean().optional(),
1242
+ limit: z5.number().int().min(1).max(50).optional()
1243
+ }).strict();
1244
+ var DynamoiLaunchCampaignInputSchema = z5.object({
309
1245
  // Creative
310
- adCopy: z2.string().trim().optional(),
311
- appleMusicUrl: z2.string().trim().min(1).optional(),
312
- artistId: z2.string().uuid(),
1246
+ adCopy: z5.string().trim().max(500).optional(),
1247
+ appleMusicUrl: z5.string().trim().min(1).max(500).optional(),
1248
+ artistId: z5.string().uuid(),
313
1249
  // Budget
314
- budgetAmount: z2.number().finite().positive(),
315
- budgetSplits: z2.record(
316
- z2.enum(["META", "GOOGLE"]),
317
- z2.number().int().min(0).max(100)
1250
+ budgetAmount: z5.number().finite().positive(),
1251
+ budgetSplits: z5.record(
1252
+ z5.enum(["META", "GOOGLE"]),
1253
+ z5.number().int().min(0).max(100)
318
1254
  ),
319
- budgetType: z2.enum(["DAILY", "TOTAL"]),
320
- campaignType: z2.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
1255
+ budgetType: z5.enum(["DAILY", "TOTAL"]),
1256
+ campaignType: z5.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
321
1257
  // Idempotency (client-generated UUID)
322
- clientRequestId: z2.string().uuid(),
1258
+ clientRequestId: z5.string().uuid(),
323
1259
  // Content
324
- contentTitle: z2.string().trim().min(1),
325
- contentType: z2.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]),
326
- endDate: z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
1260
+ contentTitle: z5.string().trim().min(1).max(160),
1261
+ contentType: z5.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]),
1262
+ endDate: z5.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
327
1263
  // Targeting
328
- locationTargets: z2.array(LocationTargetSchema).optional(),
1264
+ locationTargets: z5.array(LocationTargetSchema).optional(),
329
1265
  // Smart Campaign creative selection (existing assets only in Phase 3)
330
- mediaAssetIds: z2.array(z2.string().uuid()).optional(),
331
- spotifyUrl: z2.string().trim().min(1).optional(),
332
- useAiGeneratedCopy: z2.boolean().optional(),
333
- youtubeVideoId: z2.string().trim().min(1).optional()
334
- }).superRefine((data, ctx) => {
335
- if (data.budgetType === "TOTAL" && !data.endDate) {
336
- ctx.addIssue({
337
- code: "custom",
338
- message: "endDate is required when budgetType is TOTAL",
339
- path: ["endDate"]
340
- });
341
- }
1266
+ mediaAssetIds: z5.array(z5.string().uuid()).optional(),
1267
+ spotifyUrl: z5.string().trim().min(1).max(500).optional(),
1268
+ useAiGeneratedCopy: z5.boolean().optional(),
1269
+ userIntentSummary: UserIntentSummarySchema2,
1270
+ youtubeVideoId: z5.string().trim().min(1).max(128).optional()
1271
+ }).strict().superRefine((data, ctx) => {
342
1272
  const sum = Object.values(data.budgetSplits ?? {}).reduce(
343
1273
  (acc, v) => acc + (Number.isFinite(v) ? v : 0),
344
1274
  0
@@ -358,13 +1288,6 @@ var DynamoiLaunchCampaignInputSchema = z2.object({
358
1288
  });
359
1289
  }
360
1290
  if (data.campaignType === "SMART_CAMPAIGN") {
361
- if (!data.spotifyUrl) {
362
- ctx.addIssue({
363
- code: "custom",
364
- message: "spotifyUrl is required for SMART_CAMPAIGN",
365
- path: ["spotifyUrl"]
366
- });
367
- }
368
1291
  if (!data.mediaAssetIds || data.mediaAssetIds.length === 0) {
369
1292
  ctx.addIssue({
370
1293
  code: "custom",
@@ -420,188 +1343,380 @@ var DynamoiLaunchCampaignInputSchema = z2.object({
420
1343
  });
421
1344
  var PHASE_1_TOOL_DEFINITIONS = [
422
1345
  {
423
- description: "Get the currently authenticated Dynamoi account context \u2014 user ID, email, and accessible organizations/artists with resolved roles.",
1346
+ description: "Use this when the user explicitly asks about the signed-in Dynamoi account itself, such as who is logged in, how many organizations or artists it can access, or whether account-level platform connections exist. Always pass intent to match that explicit account question. Do not use this to enumerate artists one by one; use dynamoi_list_artists for that. Never use this to 'check context' before answering generic Instagram, lyrics, songwriting, or marketing-advice questions, even if Dynamoi is attached.",
424
1347
  destructiveHint: false,
425
- name: "dynamoi_get_current_user",
1348
+ name: "dynamoi_get_account_overview",
426
1349
  openWorldHint: false,
1350
+ outputSchema: AnyOutputEnvelopeSchema,
427
1351
  readOnlyHint: true,
428
- schema: DynamoiGetCurrentUserInputSchema
1352
+ schema: DynamoiGetCurrentUserInputSchema,
1353
+ title: "Get Account Overview"
429
1354
  },
430
1355
  {
431
- description: "List all music artists and YouTube channels the user manages. Returns each artist's subscription tier, billing status, active campaign count, and the user's role.",
1356
+ description: "Use this when the user wants to see which artists or YouTube channels they manage, along with billing status, active campaign count, and their role. Do not use this for campaign details; use dynamoi_list_campaigns or dynamoi_get_campaign. Never use this for generic social-media or marketing advice, including Instagram follower-growth questions, unless the user explicitly asked about their Dynamoi roster.",
432
1357
  destructiveHint: false,
433
1358
  name: "dynamoi_list_artists",
434
1359
  openWorldHint: false,
1360
+ outputSchema: AnyOutputEnvelopeSchema,
435
1361
  readOnlyHint: true,
436
- schema: DynamoiListArtistsInputSchema
1362
+ schema: DynamoiListArtistsInputSchema,
1363
+ title: "List Artists"
437
1364
  },
438
1365
  {
439
- description: "Search across artists, ad campaigns, and smart links by name or URL. Find a specific Spotify release, YouTube campaign, or artist profile.",
1366
+ description: "Use this when the user mentions an artist, release, campaign, or smart link but you do not yet know the exact record to inspect. Do not use this for analytics summaries or billing questions once you already know the target record.",
440
1367
  destructiveHint: false,
441
1368
  name: "dynamoi_search",
442
1369
  openWorldHint: false,
1370
+ outputSchema: AnyOutputEnvelopeSchema,
443
1371
  readOnlyHint: true,
444
- schema: DynamoiSearchInputSchema
1372
+ schema: DynamoiSearchInputSchema,
1373
+ title: "Search Dynamoi"
445
1374
  },
446
1375
  {
447
- description: "Get a music artist or YouTube channel profile \u2014 connected platforms (Spotify, Meta, YouTube), subscription tier, billing status, and whether they're ready to launch campaigns.",
1376
+ description: "Use this when the user wants the profile and launch readiness for one specific artist or YouTube channel, including connected platforms and billing state. Do not use this to list every artist; use dynamoi_list_artists first. Never use this for generic advice questions that do not require account-specific data, including Instagram growth, songwriting, or lyrics prompts.",
448
1377
  destructiveHint: false,
449
1378
  name: "dynamoi_get_artist",
450
1379
  openWorldHint: false,
1380
+ outputSchema: AnyOutputEnvelopeSchema,
451
1381
  readOnlyHint: true,
452
- schema: DynamoiGetArtistInputSchema
1382
+ schema: DynamoiGetArtistInputSchema,
1383
+ title: "Get Artist"
453
1384
  },
454
1385
  {
455
- description: "List ad campaigns for an artist \u2014 each campaign's content title, type (Smart Campaign for Spotify or YouTube for channel growth), budget, status, and platforms. Supports status filtering and pagination.",
1386
+ description: "Use this when the user wants to browse campaigns for one artist, optionally filtered by type or status. Do not use this for a single campaign deep dive; use dynamoi_get_campaign for that. Never use this to personalize generic marketing advice.",
456
1387
  destructiveHint: false,
457
1388
  name: "dynamoi_list_campaigns",
458
1389
  openWorldHint: false,
1390
+ outputSchema: AnyOutputEnvelopeSchema,
459
1391
  readOnlyHint: true,
460
- schema: DynamoiListCampaignsInputSchema
1392
+ schema: DynamoiListCampaignsInputSchema,
1393
+ title: "List Campaigns"
461
1394
  },
462
1395
  {
463
- description: "Get full details for a campaign \u2014 budget, targeting countries, per-platform status for Meta and Google, smart link URL, and any blocked reasons with suggested next actions.",
1396
+ description: "Use this when the user wants full details for one campaign, including budget, targeting, platform status, and next actions. Do not use this for a campaign list; use dynamoi_list_campaigns instead. Pass includeCountries=true only when the full country list is needed. After a successful launch or budget/status mutation, prefer format=summary when you need a follow-up read to relay the final answer.",
464
1397
  destructiveHint: false,
465
1398
  name: "dynamoi_get_campaign",
466
1399
  openWorldHint: false,
1400
+ outputSchema: AnyOutputEnvelopeSchema,
467
1401
  readOnlyHint: true,
468
- schema: DynamoiGetCampaignInputSchema
1402
+ schema: DynamoiGetCampaignInputSchema,
1403
+ title: "Get Campaign"
469
1404
  },
470
1405
  {
471
- description: "Get performance analytics for a campaign \u2014 impressions, clicks, ad spend, CPC, CPM, and CTR. Optionally filter by date range. Returns per-platform breakdowns for Meta Ads and Google Ads.",
1406
+ description: "Use this when the user asks how one campaign is performing across impressions, clicks, spend, CPC, CPM, or CTR. Pass granularity=DAILY when the user asks for a daily breakdown. Use this for a deeper audit of one campaign after you already know which campaign to inspect. Do not use this for artist-wide performance across multiple campaigns; use dynamoi_get_artist_analytics instead.",
472
1407
  destructiveHint: false,
473
1408
  name: "dynamoi_get_campaign_analytics",
474
1409
  openWorldHint: false,
1410
+ outputSchema: AnyOutputEnvelopeSchema,
1411
+ readOnlyHint: true,
1412
+ schema: DynamoiGetCampaignAnalyticsInputSchema,
1413
+ title: "Get Campaign Analytics"
1414
+ },
1415
+ {
1416
+ description: "Use this when the user wants artist-level performance across all campaigns, including 30-day rollups or daily breakdowns. Pass granularity=DAILY when the user asks for a daily breakdown. Pass format=summary when the user wants a written rollup, a strongest-campaign verdict, or a direct answer you can relay immediately. If this tool already returned the requested strongest-campaign comparison, stop and answer instead of calling more analytics tools. Do not use this for one campaign's metrics; use dynamoi_get_campaign_analytics instead.",
1417
+ destructiveHint: false,
1418
+ name: "dynamoi_get_artist_analytics",
1419
+ openWorldHint: false,
1420
+ outputSchema: AnyOutputEnvelopeSchema,
475
1421
  readOnlyHint: true,
476
- schema: DynamoiGetCampaignAnalyticsInputSchema
1422
+ schema: DynamoiGetArtistAnalyticsInputSchema,
1423
+ title: "Get Artist Analytics"
477
1424
  },
478
1425
  {
479
- description: "Get an artist's billing summary \u2014 subscription tier, ad credit balance, billing status, and recent spend. Shows remaining credits and campaign usage for the current period.",
1426
+ description: "Use this when the user asks about billing state, credit balance, promo limits, or whether billing is blocking launches for one artist. Do not use this for campaign analytics or platform connection troubleshooting.",
480
1427
  destructiveHint: false,
481
1428
  name: "dynamoi_get_billing",
482
1429
  openWorldHint: false,
1430
+ outputSchema: AnyOutputEnvelopeSchema,
483
1431
  readOnlyHint: true,
484
- schema: DynamoiGetBillingInputSchema
1432
+ schema: DynamoiGetBillingInputSchema,
1433
+ title: "Get Billing"
485
1434
  },
486
1435
  {
487
- description: "Check connection health for Spotify, Meta (Facebook/Instagram), and YouTube. Shows connection status, token expiry, and what steps remain before campaigns can launch on each platform.",
1436
+ description: "Use this when the user wants to know whether Spotify, Meta, or YouTube are connected and what setup steps still block launches. Do not use this for billing details; use dynamoi_get_billing when the question is about credits or subscription state. Never use this to personalize generic Instagram or marketing-advice questions.",
488
1437
  destructiveHint: false,
489
1438
  name: "dynamoi_get_platform_status",
490
1439
  openWorldHint: false,
1440
+ outputSchema: AnyOutputEnvelopeSchema,
491
1441
  readOnlyHint: true,
492
- schema: DynamoiGetPlatformStatusInputSchema
1442
+ schema: DynamoiGetPlatformStatusInputSchema,
1443
+ title: "Get Platform Status"
493
1444
  }
494
1445
  ];
495
1446
  var PHASE_2_TOOL_DEFINITIONS = [
496
1447
  {
497
- description: "Pause a running campaign, stopping ad delivery on Meta (Facebook/Instagram) and/or Google (YouTube). Returns per-platform results.",
498
- destructiveHint: false,
1448
+ description: "Use this when the user explicitly wants to pause a running campaign and stop ad delivery. Do not use this for inspection-only questions; this changes external campaign state.",
1449
+ destructiveHint: true,
1450
+ idempotentHint: true,
499
1451
  name: "dynamoi_pause_campaign",
500
1452
  openWorldHint: true,
1453
+ outputSchema: PauseResumeOutputEnvelopeSchema,
501
1454
  readOnlyHint: false,
502
- schema: DynamoiPauseCampaignInputSchema
1455
+ schema: DynamoiPauseCampaignInputSchema,
1456
+ title: "Pause Campaign"
503
1457
  },
504
1458
  {
505
- description: "Resume a paused campaign, restarting ad delivery on Meta and/or Google. Returns per-platform results.",
506
- destructiveHint: false,
1459
+ description: "Use this when the user explicitly wants to resume a paused campaign and restart ad delivery. Do not use this for inspection-only questions; this changes external campaign state.",
1460
+ destructiveHint: true,
1461
+ idempotentHint: true,
507
1462
  name: "dynamoi_resume_campaign",
508
1463
  openWorldHint: true,
1464
+ outputSchema: PauseResumeOutputEnvelopeSchema,
509
1465
  readOnlyHint: false,
510
- schema: DynamoiResumeCampaignInputSchema
1466
+ schema: DynamoiResumeCampaignInputSchema,
1467
+ title: "Resume Campaign"
511
1468
  },
512
1469
  {
513
- description: "Change a campaign's daily or total budget amount in USD. For total-budget campaigns, the end date can also be updated. Cannot switch between daily and total budget types.",
514
- destructiveHint: false,
1470
+ description: "Use this when the user explicitly wants to change a campaign budget, and optionally the end date for total-budget campaigns. Do not use this for read-only budget checks; this updates live campaign settings.",
1471
+ destructiveHint: true,
1472
+ idempotentHint: true,
515
1473
  name: "dynamoi_update_budget",
516
1474
  openWorldHint: true,
1475
+ outputSchema: UpdateBudgetOutputEnvelopeSchema,
517
1476
  readOnlyHint: false,
518
- schema: DynamoiUpdateBudgetInputSchema
1477
+ schema: DynamoiUpdateBudgetInputSchema,
1478
+ title: "Update Campaign Budget"
519
1479
  }
520
1480
  ];
521
1481
  var PHASE_3_TOOL_DEFINITIONS = [
522
1482
  {
523
- description: "List an artist's uploaded creative assets (images and videos) available for campaign launches. Use this to select media before launching a Smart Campaign.",
1483
+ description: "Use this when the user wants to choose from uploaded images or videos that can be reused in a campaign launch. Do not use this when the user only wants campaign status or analytics. Use format=json when you need asset IDs for a follow-up launch. Request includeUrls only when the assistant must display or inspect public-safe asset URLs.",
524
1484
  destructiveHint: false,
525
1485
  name: "dynamoi_list_media_assets",
526
1486
  openWorldHint: false,
1487
+ outputSchema: ListMediaAssetsOutputEnvelopeSchema,
527
1488
  readOnlyHint: true,
528
- schema: DynamoiListMediaAssetsInputSchema
1489
+ schema: DynamoiListMediaAssetsInputSchema,
1490
+ title: "List Media Assets"
529
1491
  },
530
1492
  {
531
- description: "Launch a new campaign to promote a Spotify release (track, album, or playlist via Meta Ads) or grow a YouTube channel (via Google Ads with AdSense revenue optimization). Provide a client-generated request ID for safe retries.",
1493
+ description: "Use this when the user explicitly wants to create a new Smart Campaign or YouTube Campaign and start the launch workflow with provided details. Ads are not necessarily live until the returned delivery state is ACTIVE. For review or demo Smart Campaign launches that already specify the artist, content title, budget, countries, and reusable media assets, you may omit spotifyUrl and endDate because Dynamoi can infer reviewer-safe defaults. Do not invent placeholder spotifyUrl or endDate values for those review/demo launches; omit them and let Dynamoi infer them. After a successful launch, answer from the returned campaign details directly instead of chaining more tools unless the user explicitly asked for more. Do not use this for recommendations or previews; this creates a real campaign workflow or demo-safe simulated campaign.",
532
1494
  destructiveHint: false,
1495
+ idempotentHint: true,
533
1496
  name: "dynamoi_launch_campaign",
534
1497
  openWorldHint: true,
1498
+ outputSchema: LaunchCampaignOutputEnvelopeSchema,
535
1499
  readOnlyHint: false,
536
- schema: DynamoiLaunchCampaignInputSchema
1500
+ schema: DynamoiLaunchCampaignInputSchema,
1501
+ title: "Start Campaign Launch Workflow"
537
1502
  }
538
1503
  ];
539
1504
 
540
1505
  // src/server/create-server.ts
541
1506
  function asTextResult(envelope) {
1507
+ const isToolError = Boolean(envelope) && typeof envelope === "object" && envelope.status === "error";
1508
+ const plainText = (() => {
1509
+ if (!envelope || typeof envelope !== "object") {
1510
+ return JSON.stringify(envelope);
1511
+ }
1512
+ const status = envelope.status;
1513
+ if (status === "error") {
1514
+ const message = envelope.message;
1515
+ return typeof message === "string" && message.trim().length > 0 ? message : JSON.stringify(envelope);
1516
+ }
1517
+ const data = envelope.data;
1518
+ if (data && typeof data === "object") {
1519
+ const summary = data.summary;
1520
+ if (typeof summary === "string" && summary.trim().length > 0) {
1521
+ return summary;
1522
+ }
1523
+ }
1524
+ return JSON.stringify(envelope);
1525
+ })();
542
1526
  return {
543
- content: [{ text: JSON.stringify(envelope), type: "text" }],
544
- structuredContent: envelope
1527
+ content: [{ text: plainText, type: "text" }],
1528
+ structuredContent: envelope,
1529
+ ...isToolError ? { isError: true } : {}
545
1530
  };
546
1531
  }
1532
+ function asValidatedTextResult(options) {
1533
+ const parsed = options.outputSchema.safeParse(options.envelope);
1534
+ if (!parsed.success) {
1535
+ return asTextResult({
1536
+ kind: "validation",
1537
+ message: `Tool ${options.toolName} returned an invalid result shape.`,
1538
+ status: "error"
1539
+ });
1540
+ }
1541
+ return asTextResult(options.envelope);
1542
+ }
547
1543
  function createDynamoiMcpServer(options) {
548
1544
  const server = new McpServer(
549
1545
  {
550
1546
  name: "dynamoi",
551
1547
  version: DYNAMOI_MCP_VERSION,
552
- websiteUrl: "https://dynamoi.com"
1548
+ websiteUrl: options.websiteUrl ?? "https://dynamoi.com"
553
1549
  },
554
1550
  { instructions: DYNAMOI_MCP_INSTRUCTIONS }
555
1551
  );
556
1552
  for (const def of [
557
1553
  ...PHASE_1_TOOL_DEFINITIONS,
558
1554
  ...PHASE_2_TOOL_DEFINITIONS,
559
- ...PHASE_3_TOOL_DEFINITIONS
1555
+ ...PHASE_3_TOOL_DEFINITIONS,
1556
+ ...PHASE_4_TOOL_DEFINITIONS
560
1557
  ]) {
1558
+ const title = def.title;
1559
+ const idempotentHint = "idempotentHint" in def && typeof def.idempotentHint === "boolean" ? def.idempotentHint : void 0;
561
1560
  server.registerTool(
562
1561
  def.name,
563
1562
  {
564
1563
  annotations: {
565
1564
  destructiveHint: def.destructiveHint,
1565
+ ...typeof idempotentHint === "boolean" ? { idempotentHint } : {},
566
1566
  openWorldHint: def.openWorldHint,
567
1567
  readOnlyHint: def.readOnlyHint
568
1568
  },
569
1569
  description: def.description,
570
1570
  inputSchema: def.schema,
571
- title: def.name
1571
+ outputSchema: def.outputSchema,
1572
+ title
572
1573
  },
573
1574
  async (input) => {
574
1575
  switch (def.name) {
575
- case "dynamoi_get_current_user":
576
- return asTextResult(await options.adapter.getCurrentUser(input));
1576
+ case "dynamoi_get_account_overview":
1577
+ return asValidatedTextResult({
1578
+ envelope: await options.adapter.getCurrentUser(input),
1579
+ outputSchema: def.outputSchema,
1580
+ toolName: def.name
1581
+ });
577
1582
  case "dynamoi_list_artists":
578
- return asTextResult(await options.adapter.listArtists(input));
1583
+ return asValidatedTextResult({
1584
+ envelope: await options.adapter.listArtists(input),
1585
+ outputSchema: def.outputSchema,
1586
+ toolName: def.name
1587
+ });
579
1588
  case "dynamoi_search":
580
- return asTextResult(await options.adapter.search(input));
1589
+ return asValidatedTextResult({
1590
+ envelope: await options.adapter.search(input),
1591
+ outputSchema: def.outputSchema,
1592
+ toolName: def.name
1593
+ });
581
1594
  case "dynamoi_get_artist":
582
- return asTextResult(await options.adapter.getArtist(input));
1595
+ return asValidatedTextResult({
1596
+ envelope: await options.adapter.getArtist(input),
1597
+ outputSchema: def.outputSchema,
1598
+ toolName: def.name
1599
+ });
1600
+ case "dynamoi_get_artist_analytics":
1601
+ return asValidatedTextResult({
1602
+ envelope: await options.adapter.getArtistAnalytics(input),
1603
+ outputSchema: def.outputSchema,
1604
+ toolName: def.name
1605
+ });
583
1606
  case "dynamoi_list_campaigns":
584
- return asTextResult(await options.adapter.listCampaigns(input));
1607
+ return asValidatedTextResult({
1608
+ envelope: await options.adapter.listCampaigns(input),
1609
+ outputSchema: def.outputSchema,
1610
+ toolName: def.name
1611
+ });
585
1612
  case "dynamoi_get_campaign":
586
- return asTextResult(await options.adapter.getCampaign(input));
1613
+ return asValidatedTextResult({
1614
+ envelope: await options.adapter.getCampaign(input),
1615
+ outputSchema: def.outputSchema,
1616
+ toolName: def.name
1617
+ });
587
1618
  case "dynamoi_get_campaign_analytics":
588
- return asTextResult(
589
- await options.adapter.getCampaignAnalytics(input)
590
- );
1619
+ return asValidatedTextResult({
1620
+ envelope: await options.adapter.getCampaignAnalytics(input),
1621
+ outputSchema: def.outputSchema,
1622
+ toolName: def.name
1623
+ });
591
1624
  case "dynamoi_get_billing":
592
- return asTextResult(await options.adapter.getBilling(input));
1625
+ return asValidatedTextResult({
1626
+ envelope: await options.adapter.getBilling(input),
1627
+ outputSchema: def.outputSchema,
1628
+ toolName: def.name
1629
+ });
593
1630
  case "dynamoi_get_platform_status":
594
- return asTextResult(await options.adapter.getPlatformStatus(input));
1631
+ return asValidatedTextResult({
1632
+ envelope: await options.adapter.getPlatformStatus(input),
1633
+ outputSchema: def.outputSchema,
1634
+ toolName: def.name
1635
+ });
595
1636
  case "dynamoi_pause_campaign":
596
- return asTextResult(await options.adapter.pauseCampaign(input));
1637
+ return asValidatedTextResult({
1638
+ envelope: await options.adapter.pauseCampaign(input),
1639
+ outputSchema: def.outputSchema,
1640
+ toolName: def.name
1641
+ });
597
1642
  case "dynamoi_resume_campaign":
598
- return asTextResult(await options.adapter.resumeCampaign(input));
1643
+ return asValidatedTextResult({
1644
+ envelope: await options.adapter.resumeCampaign(input),
1645
+ outputSchema: def.outputSchema,
1646
+ toolName: def.name
1647
+ });
599
1648
  case "dynamoi_update_budget":
600
- return asTextResult(await options.adapter.updateBudget(input));
1649
+ return asValidatedTextResult({
1650
+ envelope: await options.adapter.updateBudget(input),
1651
+ outputSchema: def.outputSchema,
1652
+ toolName: def.name
1653
+ });
601
1654
  case "dynamoi_list_media_assets":
602
- return asTextResult(await options.adapter.listMediaAssets(input));
1655
+ return asValidatedTextResult({
1656
+ envelope: await options.adapter.listMediaAssets(input),
1657
+ outputSchema: def.outputSchema,
1658
+ toolName: def.name
1659
+ });
603
1660
  case "dynamoi_launch_campaign":
604
- return asTextResult(await options.adapter.launchCampaign(input));
1661
+ return asValidatedTextResult({
1662
+ envelope: await options.adapter.launchCampaign(input),
1663
+ outputSchema: def.outputSchema,
1664
+ toolName: def.name
1665
+ });
1666
+ case "dynamoi_create_smart_link_from_spotify":
1667
+ return asValidatedTextResult({
1668
+ envelope: await options.adapter.createSmartLinkFromSpotify(input),
1669
+ outputSchema: def.outputSchema,
1670
+ toolName: def.name
1671
+ });
1672
+ case "dynamoi_list_smart_links":
1673
+ return asValidatedTextResult({
1674
+ envelope: await options.adapter.listSmartLinks(input),
1675
+ outputSchema: def.outputSchema,
1676
+ toolName: def.name
1677
+ });
1678
+ case "dynamoi_get_smart_link":
1679
+ return asValidatedTextResult({
1680
+ envelope: await options.adapter.getSmartLink(input),
1681
+ outputSchema: def.outputSchema,
1682
+ toolName: def.name
1683
+ });
1684
+ case "dynamoi_get_smart_link_analytics":
1685
+ return asValidatedTextResult({
1686
+ envelope: await options.adapter.getSmartLinkAnalytics(input),
1687
+ outputSchema: def.outputSchema,
1688
+ toolName: def.name
1689
+ });
1690
+ case "dynamoi_get_smart_link_artist_settings":
1691
+ return asValidatedTextResult({
1692
+ envelope: await options.adapter.getSmartLinkArtistSettings(input),
1693
+ outputSchema: def.outputSchema,
1694
+ toolName: def.name
1695
+ });
1696
+ case "dynamoi_update_smart_link":
1697
+ return asValidatedTextResult({
1698
+ envelope: await options.adapter.updateSmartLink(input),
1699
+ outputSchema: def.outputSchema,
1700
+ toolName: def.name
1701
+ });
1702
+ case "dynamoi_update_smart_link_artist_settings":
1703
+ return asValidatedTextResult({
1704
+ envelope: await options.adapter.updateSmartLinkArtistSettings(input),
1705
+ outputSchema: def.outputSchema,
1706
+ toolName: def.name
1707
+ });
1708
+ case "dynamoi_publish_smart_link":
1709
+ return asValidatedTextResult({
1710
+ envelope: await options.adapter.publishSmartLink(input),
1711
+ outputSchema: def.outputSchema,
1712
+ toolName: def.name
1713
+ });
1714
+ case "dynamoi_unpublish_smart_link":
1715
+ return asValidatedTextResult({
1716
+ envelope: await options.adapter.unpublishSmartLink(input),
1717
+ outputSchema: def.outputSchema,
1718
+ toolName: def.name
1719
+ });
605
1720
  default:
606
1721
  return asTextResult({
607
1722
  message: "Unknown tool",
@@ -612,172 +1727,7 @@ function createDynamoiMcpServer(options) {
612
1727
  );
613
1728
  }
614
1729
  registerDynamoiPrompts(server);
615
- server.registerResource(
616
- "platform-pricing",
617
- "dynamoi://platform/pricing",
618
- {
619
- description: "Dynamoi pricing, activation bonus, ad credit structure, and campaign budget minimums.",
620
- mimeType: "application/json",
621
- title: "Pricing"
622
- },
623
- async (uri) => ({
624
- contents: [
625
- {
626
- mimeType: "application/json",
627
- text: JSON.stringify({
628
- activationBonus: {
629
- amountUsd: 600,
630
- note: "100% match on first month \u2014 pay $300, get $600 ad credit"
631
- },
632
- budgetMinimums: {
633
- smartCampaign: {
634
- dailyUsd: 10,
635
- note: "Meta Ads for Spotify promotion",
636
- totalUsd: 100
637
- },
638
- youtube: {
639
- dailyUsd: 10,
640
- note: "Google Ads for YouTube channel growth",
641
- totalUsd: 50
642
- }
643
- },
644
- creditRollover: "Credits roll over for 12 months",
645
- includes: "Unlimited team seats, unlimited artists, white-glove support, free smart link landing pages",
646
- noContracts: true,
647
- tiers: [
648
- {
649
- name: "Plus",
650
- note: "100% Ad Credit. No agency fees.",
651
- priceUsdMonthly: 300
652
- }
653
- ]
654
- }),
655
- uri: uri.href
656
- }
657
- ]
658
- })
659
- );
660
- server.registerResource(
661
- "platform-content-types",
662
- "dynamoi://platform/content-types",
663
- { mimeType: "application/json", title: "Content Types" },
664
- async (uri) => ({
665
- contents: [
666
- {
667
- mimeType: "application/json",
668
- text: JSON.stringify({
669
- campaignTypes: {
670
- SMART_CAMPAIGN: ["TRACK", "ALBUM", "PLAYLIST"],
671
- YOUTUBE: ["VIDEO"]
672
- },
673
- contentTypes: ["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]
674
- }),
675
- uri: uri.href
676
- }
677
- ]
678
- })
679
- );
680
- server.registerResource(
681
- "platform-campaign-statuses",
682
- "dynamoi://platform/campaign-statuses",
683
- { mimeType: "application/json", title: "Campaign Statuses" },
684
- async (uri) => ({
685
- contents: [
686
- {
687
- mimeType: "application/json",
688
- text: JSON.stringify({
689
- statuses: [
690
- "AWAITING_SMART_LINK",
691
- "CONTENT_VALIDATION",
692
- "DEPLOYING",
693
- "READY_FOR_REVIEW",
694
- "ACTIVE",
695
- "PAUSED",
696
- "SUBSCRIPTION_PAUSED",
697
- "FAILED",
698
- "ARCHIVED",
699
- "ENDED"
700
- ]
701
- }),
702
- uri: uri.href
703
- }
704
- ]
705
- })
706
- );
707
- server.registerResource(
708
- "artist-resource",
709
- new ResourceTemplate("artist://{artistId}", {
710
- list: async () => ({ resources: [] })
711
- }),
712
- { mimeType: "application/json", title: "Artist" },
713
- async (uri, variables) => {
714
- const artistId = variables["artistId"];
715
- const parsed = z3.string().uuid().safeParse(artistId);
716
- if (!parsed.success) {
717
- return {
718
- contents: [
719
- {
720
- mimeType: "application/json",
721
- text: JSON.stringify({
722
- message: "Invalid artistId",
723
- status: "error"
724
- }),
725
- uri: uri.href
726
- }
727
- ]
728
- };
729
- }
730
- const envelope = await options.adapter.getArtist({
731
- artistId: parsed.data
732
- });
733
- return {
734
- contents: [
735
- {
736
- mimeType: "application/json",
737
- text: JSON.stringify(envelope),
738
- uri: uri.href
739
- }
740
- ]
741
- };
742
- }
743
- );
744
- server.registerResource(
745
- "campaign-resource",
746
- new ResourceTemplate("campaign://{campaignId}", {
747
- list: async () => ({ resources: [] })
748
- }),
749
- { mimeType: "application/json", title: "Campaign" },
750
- async (uri, variables) => {
751
- const campaignId = variables["campaignId"];
752
- const parsed = z3.string().uuid().safeParse(campaignId);
753
- if (!parsed.success) {
754
- return {
755
- contents: [
756
- {
757
- mimeType: "application/json",
758
- text: JSON.stringify({
759
- message: "Invalid campaignId",
760
- status: "error"
761
- }),
762
- uri: uri.href
763
- }
764
- ]
765
- };
766
- }
767
- const envelope = await options.adapter.getCampaign({
768
- campaignId: parsed.data
769
- });
770
- return {
771
- contents: [
772
- {
773
- mimeType: "application/json",
774
- text: JSON.stringify(envelope),
775
- uri: uri.href
776
- }
777
- ]
778
- };
779
- }
780
- );
1730
+ registerDynamoiResources(server, options.adapter);
781
1731
  return server;
782
1732
  }
783
1733
 
@@ -855,6 +1805,9 @@ async function handleMcpHttpRequest(options) {
855
1805
  }
856
1806
  return response;
857
1807
  }
1808
+ if (sessionId && !isInitializeRequest(options.parsedBody)) {
1809
+ return jsonRpcSessionNotFound();
1810
+ }
858
1811
  const isInit = isInitializeRequest(options.parsedBody);
859
1812
  const transport = new WebStandardStreamableHTTPServerTransport({
860
1813
  onsessioninitialized: (sid) => {
@@ -866,7 +1819,7 @@ async function handleMcpHttpRequest(options) {
866
1819
  });
867
1820
  cleanupTransports(Date.now());
868
1821
  },
869
- sessionIdGenerator: isInit ? () => randomUUID() : void 0
1822
+ ...isInit ? { sessionIdGenerator: () => randomUUID() } : {}
870
1823
  });
871
1824
  const server = options.createServer();
872
1825
  await server.connect(transport);
@@ -875,25 +1828,36 @@ async function handleMcpHttpRequest(options) {
875
1828
  });
876
1829
  }
877
1830
  export {
878
- DateRangeSchema,
1831
+ DYNAMOI_MCP_SCOPES,
1832
+ DateRangeSchema2 as DateRangeSchema,
1833
+ DynamoiCreateSmartLinkFromSpotifyInputSchema,
1834
+ DynamoiGetArtistAnalyticsInputSchema,
879
1835
  DynamoiGetArtistInputSchema,
880
1836
  DynamoiGetBillingInputSchema,
881
1837
  DynamoiGetCampaignAnalyticsInputSchema,
882
1838
  DynamoiGetCampaignInputSchema,
883
1839
  DynamoiGetCurrentUserInputSchema,
884
1840
  DynamoiGetPlatformStatusInputSchema,
1841
+ DynamoiGetSmartLinkAnalyticsInputSchema,
1842
+ DynamoiGetSmartLinkArtistSettingsInputSchema,
1843
+ DynamoiGetSmartLinkInputSchema,
885
1844
  DynamoiLaunchCampaignInputSchema,
886
1845
  DynamoiListArtistsInputSchema,
887
1846
  DynamoiListCampaignsInputSchema,
888
1847
  DynamoiListMediaAssetsInputSchema,
1848
+ DynamoiListSmartLinksInputSchema,
889
1849
  DynamoiPauseCampaignInputSchema,
1850
+ DynamoiPublishSmartLinkInputSchema,
890
1851
  DynamoiResumeCampaignInputSchema,
891
1852
  DynamoiSearchInputSchema,
892
1853
  DynamoiUpdateBudgetInputSchema,
1854
+ DynamoiUpdateSmartLinkArtistSettingsInputSchema,
1855
+ DynamoiUpdateSmartLinkInputSchema,
893
1856
  PHASE_1_TOOL_DEFINITIONS,
894
1857
  PHASE_2_TOOL_DEFINITIONS,
895
1858
  PHASE_3_TOOL_DEFINITIONS,
896
- ToolFormatSchema,
1859
+ PHASE_4_TOOL_DEFINITIONS,
1860
+ ToolFormatSchema2 as ToolFormatSchema,
897
1861
  buildProtectedResourceMetadata,
898
1862
  buildWwwAuthenticateHeader,
899
1863
  createDynamoiMcpServer,