@mastra/deployer 1.22.0 → 1.23.0-alpha.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.
@@ -3871,111 +3871,422 @@ async function rootHandler(c) {
3871
3871
  }
3872
3872
 
3873
3873
  // src/server/welcome.ts
3874
- var html2 = `
3874
+ function welcomeHtml(apiPrefix = "/api") {
3875
+ const prefix = "/" + apiPrefix.replace(/^\/+|\/+$/g, "");
3876
+ const prefixNoSlash = prefix.slice(1);
3877
+ return `
3875
3878
  <!doctype html>
3876
3879
  <html lang="en">
3877
3880
  <head>
3878
3881
  <meta charset="UTF-8" />
3879
3882
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3880
- <title>Welcome to Mastra</title>
3881
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/inter-ui/3.19.3/inter.min.css" />
3883
+ <title>Mastra Server</title>
3882
3884
  <style>
3885
+ * { box-sizing: border-box; }
3886
+
3883
3887
  body {
3884
3888
  margin: 0;
3885
3889
  padding: 0;
3886
- background-color: #0d0d0d;
3887
- color: #ffffff;
3888
- font-family:
3889
- 'Inter',
3890
- -apple-system,
3891
- BlinkMacSystemFont,
3892
- system-ui,
3893
- sans-serif;
3890
+ background-color: #0a0a0a;
3891
+ color: #e4e4e7;
3892
+ font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
3894
3893
  min-height: 100vh;
3894
+ line-height: 1.6;
3895
+ }
3896
+
3897
+ .page {
3898
+ max-width: 720px;
3899
+ margin: 0 auto;
3900
+ padding: 3rem 1.5rem 4rem;
3901
+ }
3902
+
3903
+ header {
3904
+ margin-bottom: 2.5rem;
3905
+ }
3906
+
3907
+ header h1 {
3908
+ font-size: 1.75rem;
3909
+ font-weight: 600;
3910
+ margin: 0 0 0.25rem;
3911
+ color: #fff;
3912
+ }
3913
+
3914
+ header p {
3915
+ color: #71717a;
3916
+ font-size: 0.9rem;
3917
+ margin: 0;
3918
+ }
3919
+
3920
+ .status-bar {
3895
3921
  display: flex;
3896
- flex-direction: column;
3922
+ align-items: center;
3923
+ gap: 0.5rem;
3924
+ margin-top: 1rem;
3925
+ font-size: 0.8rem;
3926
+ color: #a1a1aa;
3897
3927
  }
3898
3928
 
3899
- main {
3900
- flex: 1;
3929
+ .status-dot {
3930
+ width: 8px;
3931
+ height: 8px;
3932
+ border-radius: 50%;
3933
+ background: #22c55e;
3934
+ flex-shrink: 0;
3935
+ }
3936
+
3937
+ section {
3938
+ margin-bottom: 2rem;
3939
+ }
3940
+
3941
+ section h2 {
3942
+ font-size: 0.75rem;
3943
+ font-weight: 600;
3944
+ text-transform: uppercase;
3945
+ letter-spacing: 0.05em;
3946
+ color: #71717a;
3947
+ margin: 0 0 0.75rem;
3948
+ }
3949
+
3950
+ .card {
3951
+ background: #18181b;
3952
+ border: 1px solid #27272a;
3953
+ border-radius: 8px;
3954
+ overflow: hidden;
3955
+ }
3956
+
3957
+ .card + .card {
3958
+ margin-top: 0.75rem;
3959
+ }
3960
+
3961
+ .card-row {
3962
+ display: flex;
3963
+ align-items: center;
3964
+ justify-content: space-between;
3965
+ padding: 0.75rem 1rem;
3966
+ gap: 0.75rem;
3967
+ }
3968
+
3969
+ .card-row + .card-row {
3970
+ border-top: 1px solid #27272a;
3971
+ }
3972
+
3973
+ .card-row-left {
3901
3974
  display: flex;
3902
- flex-direction: column;
3903
3975
  align-items: center;
3904
- justify-content: center;
3905
- padding: 2rem;
3906
- text-align: center;
3976
+ gap: 0.75rem;
3977
+ min-width: 0;
3907
3978
  }
3908
3979
 
3909
- h1 {
3910
- font-size: 4rem;
3980
+ .method {
3981
+ font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
3982
+ font-size: 0.7rem;
3911
3983
  font-weight: 600;
3912
- margin: 0 0 1rem 0;
3913
- background: linear-gradient(to right, #fff, #ccc);
3914
- -webkit-background-clip: text;
3915
- -webkit-text-fill-color: transparent;
3916
- line-height: 1.2;
3984
+ padding: 2px 6px;
3985
+ border-radius: 4px;
3986
+ flex-shrink: 0;
3917
3987
  }
3918
3988
 
3919
- .subtitle {
3920
- color: #9ca3af;
3921
- font-size: 1.25rem;
3922
- max-width: 600px;
3923
- margin: 0 auto 3rem auto;
3924
- line-height: 1.6;
3989
+ .method-get { background: #052e16; color: #4ade80; }
3990
+ .method-post { background: #172554; color: #60a5fa; }
3991
+
3992
+ .endpoint-path {
3993
+ font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
3994
+ font-size: 0.8rem;
3995
+ color: #d4d4d8;
3996
+ white-space: nowrap;
3997
+ overflow: hidden;
3998
+ text-overflow: ellipsis;
3999
+ }
4000
+
4001
+ .endpoint-desc {
4002
+ font-size: 0.75rem;
4003
+ color: #71717a;
4004
+ flex-shrink: 0;
4005
+ }
4006
+
4007
+ .curl-block {
4008
+ position: relative;
4009
+ background: #111113;
4010
+ border: 1px solid #27272a;
4011
+ border-radius: 8px;
4012
+ overflow: hidden;
4013
+ }
4014
+
4015
+ .curl-block + .curl-block {
4016
+ margin-top: 0.75rem;
3925
4017
  }
3926
4018
 
3927
- .docs-link {
3928
- background-color: #1a1a1a;
3929
- padding: 1rem 2rem;
3930
- border-radius: 0.5rem;
4019
+ .curl-label {
3931
4020
  display: flex;
3932
4021
  align-items: center;
3933
- gap: 1rem;
3934
- font-family: monospace;
3935
- font-size: 1rem;
3936
- color: #ffffff;
4022
+ justify-content: space-between;
4023
+ padding: 0.5rem 1rem;
4024
+ border-bottom: 1px solid #27272a;
4025
+ font-size: 0.75rem;
4026
+ color: #a1a1aa;
4027
+ }
4028
+
4029
+ .copy-btn {
4030
+ background: none;
4031
+ border: 1px solid #3f3f46;
4032
+ border-radius: 4px;
4033
+ color: #a1a1aa;
4034
+ font-size: 0.7rem;
4035
+ padding: 2px 8px;
4036
+ cursor: pointer;
4037
+ font-family: inherit;
4038
+ transition: all 0.15s;
4039
+ }
4040
+
4041
+ .copy-btn:hover {
4042
+ background: #27272a;
4043
+ color: #e4e4e7;
4044
+ }
4045
+
4046
+ .curl-code {
4047
+ padding: 0.75rem 1rem;
4048
+ font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
4049
+ font-size: 0.8rem;
4050
+ line-height: 1.5;
4051
+ color: #d4d4d8;
4052
+ overflow-x: auto;
4053
+ white-space: pre;
4054
+ margin: 0;
4055
+ }
4056
+
4057
+ .curl-code .c-cmd { color: #a78bfa; }
4058
+ .curl-code .c-flag { color: #60a5fa; }
4059
+ .curl-code .c-url { color: #fbbf24; }
4060
+ .curl-code .c-str { color: #4ade80; }
4061
+
4062
+ .links-grid {
4063
+ display: grid;
4064
+ grid-template-columns: 1fr 1fr;
4065
+ gap: 0.75rem;
4066
+ }
4067
+
4068
+ .link-card {
4069
+ display: flex;
4070
+ align-items: center;
4071
+ gap: 0.75rem;
4072
+ padding: 0.875rem 1rem;
4073
+ background: #18181b;
4074
+ border: 1px solid #27272a;
4075
+ border-radius: 8px;
4076
+ color: #d4d4d8;
3937
4077
  text-decoration: none;
3938
- transition: background-color 0.2s;
4078
+ font-size: 0.85rem;
4079
+ transition: all 0.15s;
4080
+ }
4081
+
4082
+ .link-card:hover {
4083
+ background: #1f1f23;
4084
+ border-color: #3f3f46;
4085
+ color: #fff;
3939
4086
  }
3940
4087
 
3941
- .docs-link:hover {
3942
- background-color: #252525;
4088
+ .link-icon {
4089
+ flex-shrink: 0;
4090
+ width: 18px;
4091
+ height: 18px;
4092
+ color: #71717a;
3943
4093
  }
3944
4094
 
3945
- .arrow-icon {
3946
- transition: transform 0.2s;
4095
+ .link-card:hover .link-icon { color: #a1a1aa; }
4096
+
4097
+ footer {
4098
+ margin-top: 3rem;
4099
+ padding-top: 1.5rem;
4100
+ border-top: 1px solid #1c1c1f;
4101
+ font-size: 0.75rem;
4102
+ color: #52525b;
3947
4103
  }
3948
4104
 
3949
- .docs-link:hover .arrow-icon {
3950
- transform: translateX(4px);
4105
+ @media (max-width: 480px) {
4106
+ .page { padding: 2rem 1rem 3rem; }
4107
+ header h1 { font-size: 1.5rem; }
4108
+ .links-grid { grid-template-columns: 1fr; }
4109
+ .endpoint-desc { display: none; }
3951
4110
  }
3952
4111
  </style>
3953
4112
  </head>
3954
4113
  <body>
3955
- <main>
3956
- <h1>Welcome to Mastra</h1>
3957
- <p class="subtitle">
3958
- Prototype and productionize AI features with a modern JS/TS stack.
3959
- </p>
4114
+ <div class="page">
4115
+ <header>
4116
+ <h1>Mastra Server</h1>
4117
+ <p>Your server is running. Use the endpoints below to get started.</p>
4118
+ <div class="status-bar">
4119
+ <span class="status-dot"></span>
4120
+ <span id="base-url"></span>
4121
+ </div>
4122
+ </header>
4123
+
4124
+ <section>
4125
+ <h2>Quick Start</h2>
4126
+
4127
+ <div class="curl-block">
4128
+ <div class="curl-label">
4129
+ <span>Check server health</span>
4130
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
4131
+ </div>
4132
+ <pre class="curl-code" data-tpl="curl <base>/health"><span class="c-cmd">curl</span> <span class="c-url" data-url="health"></span></pre>
4133
+ </div>
4134
+
4135
+ <div class="curl-block">
4136
+ <div class="curl-label">
4137
+ <span>List your agents</span>
4138
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
4139
+ </div>
4140
+ <pre class="curl-code" data-tpl="curl <base>${prefix}/agents"><span class="c-cmd">curl</span> <span class="c-url" data-url="${prefixNoSlash}/agents"></span></pre>
4141
+ </div>
3960
4142
 
3961
- <a href="https://mastra.ai/docs" class="docs-link">
3962
- Browse the docs
3963
- <svg
3964
- class="arrow-icon"
3965
- width="20"
3966
- height="20"
3967
- viewBox="0 0 24 24"
3968
- fill="none"
3969
- stroke="currentColor"
3970
- strokeWidth="2"
3971
- >
3972
- <path d="M5 12h14M12 5l7 7-7 7" />
3973
- </svg>
3974
- </a>
3975
- </main>
4143
+ <div class="curl-block">
4144
+ <div class="curl-label">
4145
+ <span>Chat with an agent</span>
4146
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
4147
+ </div>
4148
+ <pre class="curl-code" data-tpl="curl -X POST <base>${prefix}/agents/:agent-id/generate -H 'Content-Type: application/json' -d '{&quot;messages&quot;:[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Hello&quot;}]}'"><span class="c-cmd">curl</span> <span class="c-flag">-X POST</span> <span class="c-url" data-url="${prefixNoSlash}/agents/:agent-id/generate"></span> \\
4149
+ <span class="c-flag">-H</span> <span class="c-str">'Content-Type: application/json'</span> \\
4150
+ <span class="c-flag">-d</span> <span class="c-str">'{"messages":[{"role":"user","content":"Hello"}]}'</span></pre>
4151
+ </div>
4152
+
4153
+ <div class="curl-block">
4154
+ <div class="curl-label">
4155
+ <span>Stream an agent response</span>
4156
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
4157
+ </div>
4158
+ <pre class="curl-code" data-tpl="curl -N -X POST <base>${prefix}/agents/:agent-id/stream -H 'Content-Type: application/json' -d '{&quot;messages&quot;:[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Hello&quot;}]}'"><span class="c-cmd">curl</span> <span class="c-flag">-N -X POST</span> <span class="c-url" data-url="${prefixNoSlash}/agents/:agent-id/stream"></span> \\
4159
+ <span class="c-flag">-H</span> <span class="c-str">'Content-Type: application/json'</span> \\
4160
+ <span class="c-flag">-d</span> <span class="c-str">'{"messages":[{"role":"user","content":"Hello"}]}'</span></pre>
4161
+ </div>
4162
+ </section>
4163
+
4164
+ <section>
4165
+ <h2>API Endpoints</h2>
4166
+ <div class="card">
4167
+ <div class="card-row">
4168
+ <div class="card-row-left">
4169
+ <span class="method method-get">GET</span>
4170
+ <span class="endpoint-path">${prefix}/agents</span>
4171
+ </div>
4172
+ <span class="endpoint-desc">List all agents</span>
4173
+ </div>
4174
+ <div class="card-row">
4175
+ <div class="card-row-left">
4176
+ <span class="method method-post">POST</span>
4177
+ <span class="endpoint-path">${prefix}/agents/:id/generate</span>
4178
+ </div>
4179
+ <span class="endpoint-desc">Generate a response</span>
4180
+ </div>
4181
+ <div class="card-row">
4182
+ <div class="card-row-left">
4183
+ <span class="method method-post">POST</span>
4184
+ <span class="endpoint-path">${prefix}/agents/:id/stream</span>
4185
+ </div>
4186
+ <span class="endpoint-desc">Stream a response</span>
4187
+ </div>
4188
+ <div class="card-row">
4189
+ <div class="card-row-left">
4190
+ <span class="method method-get">GET</span>
4191
+ <span class="endpoint-path">${prefix}/workflows</span>
4192
+ </div>
4193
+ <span class="endpoint-desc">List all workflows</span>
4194
+ </div>
4195
+ <div class="card-row">
4196
+ <div class="card-row-left">
4197
+ <span class="method method-post">POST</span>
4198
+ <span class="endpoint-path">${prefix}/workflows/:id/start</span>
4199
+ </div>
4200
+ <span class="endpoint-desc">Run a workflow</span>
4201
+ </div>
4202
+ <div class="card-row">
4203
+ <div class="card-row-left">
4204
+ <span class="method method-get">GET</span>
4205
+ <span class="endpoint-path">${prefix}/tools</span>
4206
+ </div>
4207
+ <span class="endpoint-desc">List all tools</span>
4208
+ </div>
4209
+ <div class="card-row">
4210
+ <div class="card-row-left">
4211
+ <span class="method method-post">POST</span>
4212
+ <span class="endpoint-path">${prefix}/tools/:id/execute</span>
4213
+ </div>
4214
+ <span class="endpoint-desc">Execute a tool</span>
4215
+ </div>
4216
+ <div class="card-row">
4217
+ <div class="card-row-left">
4218
+ <span class="method method-get">GET</span>
4219
+ <span class="endpoint-path">${prefix}/memory/threads</span>
4220
+ </div>
4221
+ <span class="endpoint-desc">List memory threads</span>
4222
+ </div>
4223
+ </div>
4224
+ </section>
4225
+
4226
+ <section>
4227
+ <h2>Resources</h2>
4228
+ <div class="links-grid">
4229
+ <a href="https://mastra.ai/docs" target="_blank" rel="noopener noreferrer" class="link-card">
4230
+ <svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/></svg>
4231
+ Documentation
4232
+ </a>
4233
+ <a href="https://mastra.ai/docs/server-db/custom-api-routes" target="_blank" rel="noopener noreferrer" class="link-card">
4234
+ <svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 18l6-6-6-6"/><path d="M8 6l-6 6 6 6"/></svg>
4235
+ Custom API Routes
4236
+ </a>
4237
+ <a href="https://mastra.ai/docs/agents/overview" target="_blank" rel="noopener noreferrer" class="link-card">
4238
+ <svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v4m0 14v4m-7.8-15.4 2.8 2.8m9.6 9.6 2.8 2.8M1 12h4m14 0h4M4.2 19.8l2.8-2.8m9.6-9.6 2.8-2.8"/></svg>
4239
+ Agents Guide
4240
+ </a>
4241
+ <a href="https://mastra.ai/docs/workflows/overview" target="_blank" rel="noopener noreferrer" class="link-card">
4242
+ <svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 3 21 3 21 8"/><line x1="4" y1="20" x2="21" y2="3"/><polyline points="21 16 21 21 16 21"/><line x1="15" y1="15" x2="21" y2="21"/><line x1="4" y1="4" x2="9" y2="9"/></svg>
4243
+ Workflows Guide
4244
+ </a>
4245
+ </div>
4246
+ </section>
4247
+
4248
+ <footer>
4249
+ Powered by <a href="https://mastra.ai" target="_blank" rel="noopener noreferrer" style="color:#71717a;">Mastra</a>
4250
+ </footer>
4251
+ </div>
4252
+
4253
+ <script>
4254
+ (function() {
4255
+ var base = location.origin;
4256
+ document.getElementById('base-url').textContent = base;
4257
+
4258
+ var els = document.querySelectorAll('[data-url]');
4259
+ for (var i = 0; i < els.length; i++) {
4260
+ els[i].textContent = base + '/' + els[i].getAttribute('data-url');
4261
+ }
4262
+
4263
+ var tpls = document.querySelectorAll('[data-tpl]');
4264
+ for (var i = 0; i < tpls.length; i++) {
4265
+ tpls[i].setAttribute('data-tpl', tpls[i].getAttribute('data-tpl').replace(/<base>/g, base));
4266
+ }
4267
+ })();
4268
+
4269
+ function copyCode(btn) {
4270
+ var pre = btn.closest('.curl-block').querySelector('.curl-code');
4271
+ var text = pre.getAttribute('data-tpl');
4272
+ if (!navigator.clipboard || !navigator.clipboard.writeText) {
4273
+ btn.textContent = 'Unavailable';
4274
+ setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
4275
+ return;
4276
+ }
4277
+ navigator.clipboard.writeText(text).then(function() {
4278
+ btn.textContent = 'Copied!';
4279
+ setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
4280
+ }).catch(function() {
4281
+ btn.textContent = 'Failed';
4282
+ setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
4283
+ });
4284
+ }
4285
+ </script>
3976
4286
  </body>
3977
4287
  </html>
3978
4288
  `;
4289
+ }
3979
4290
 
3980
4291
  // src/server/index.ts
3981
4292
  var getStudioPath = () => {
@@ -4278,7 +4589,7 @@ async function createHonoServer(mastra, options = {
4278
4589
  });
4279
4590
  return c.newResponse(indexHtml, 200, { "Content-Type": "text/html" });
4280
4591
  }
4281
- return c.newResponse(html2, 200, { "Content-Type": "text/html" });
4592
+ return c.newResponse(welcomeHtml(apiPrefix), 200, { "Content-Type": "text/html" });
4282
4593
  });
4283
4594
  if (options?.studio) {
4284
4595
  const studioRootPath = getStudioPath();