@daileyos/mcp-server 1.12.0 → 1.13.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 +1 -1
- package/dist/tools/buddy.d.ts.map +1 -1
- package/dist/tools/buddy.js +312 -2
- package/dist/tools/buddy.js.map +1 -1
- package/dist/tools/credentials-reveal.js +1 -1
- package/dist/tools/credentials-reveal.js.map +1 -1
- package/dist/tools/storage.d.ts.map +1 -1
- package/dist/tools/storage.js +30 -0
- package/dist/tools/storage.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/tools/buddy.ts +316 -2
- package/src/tools/credentials-reveal.ts +1 -1
- package/src/tools/storage.ts +42 -0
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buddy.d.ts","sourceRoot":"","sources":["../../src/tools/buddy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"buddy.d.ts","sourceRoot":"","sources":["../../src/tools/buddy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoWpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAuVnD"}
|
package/dist/tools/buddy.js
CHANGED
|
@@ -150,6 +150,185 @@ Common issues and what they actually mean:
|
|
|
150
150
|
- 520 error when running long exec commands → Cloudflare has a body size limit; write the script to /tmp/script.js first, then run node /tmp/script.js as a separate exec call.
|
|
151
151
|
- "Migrations not applied" on first deploy → DOS doesn't auto-run migrations; use dailey run <app> -- node scripts/migrate.js
|
|
152
152
|
|
|
153
|
+
## Core Auth — For Apps With End Users
|
|
154
|
+
|
|
155
|
+
Dailey Core is a multi-tenant identity platform at core.dailey.cloud. Use it when your app has its own end-users (players, customers, team members) — not just a single admin account. It handles registration, login, password reset, and JWT issuance so you don't have to build auth from scratch.
|
|
156
|
+
|
|
157
|
+
### How Core JWTs work
|
|
158
|
+
|
|
159
|
+
Core issues RS256 JWTs. Your Express server verifies them using the public JWKS at:
|
|
160
|
+
https://core.dailey.cloud/.well-known/jwks.json
|
|
161
|
+
|
|
162
|
+
JWT claims: sub (Core user UUID), email, name, tenant, tenants, roles, app_slug
|
|
163
|
+
KID: dailey-core-20251223-01 | Issuer: https://core.dailey.cloud
|
|
164
|
+
|
|
165
|
+
### Express auth middleware (copy-paste ready)
|
|
166
|
+
|
|
167
|
+
npm install jwks-rsa jsonwebtoken
|
|
168
|
+
|
|
169
|
+
const jwksRsa = require('jwks-rsa');
|
|
170
|
+
const jwt = require('jsonwebtoken');
|
|
171
|
+
|
|
172
|
+
const jwksClient = jwksRsa({
|
|
173
|
+
jwksUri: 'https://core.dailey.cloud/.well-known/jwks.json',
|
|
174
|
+
cache: true,
|
|
175
|
+
cacheMaxAge: 300_000, // 5 min — don't hammer Core
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
function requireAuth(req, res, next) {
|
|
179
|
+
const token = req.headers.authorization?.split(' ')[1];
|
|
180
|
+
if (!token) return res.status(401).json({ error: 'No token' });
|
|
181
|
+
const { header } = jwt.decode(token, { complete: true });
|
|
182
|
+
jwksClient.getSigningKey(header.kid, (err, key) => {
|
|
183
|
+
if (err) return res.status(401).json({ error: 'Invalid token' });
|
|
184
|
+
try {
|
|
185
|
+
req.user = jwt.verify(token, key.getPublicKey(), { algorithms: ['RS256'] });
|
|
186
|
+
next();
|
|
187
|
+
} catch { return res.status(401).json({ error: 'Token expired' }); }
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
### Upsert local user on first request (ensureUser pattern)
|
|
192
|
+
|
|
193
|
+
After verifying the JWT, create a local user row if it doesn't exist yet.
|
|
194
|
+
This way your DB uses your own UUIDs while Core handles credentials:
|
|
195
|
+
|
|
196
|
+
async function ensureUser(req, res, next) {
|
|
197
|
+
const { sub: core_user_id, email, name } = req.user;
|
|
198
|
+
// MySQL:
|
|
199
|
+
await pool.query(
|
|
200
|
+
\`INSERT INTO users (id, core_user_id, email, full_name)
|
|
201
|
+
VALUES (UUID(), ?, ?, ?)
|
|
202
|
+
ON DUPLICATE KEY UPDATE email = VALUES(email), full_name = VALUES(full_name)\`,
|
|
203
|
+
[core_user_id, email, name]
|
|
204
|
+
);
|
|
205
|
+
// PostgreSQL:
|
|
206
|
+
await pool.query(
|
|
207
|
+
\`INSERT INTO users (id, core_user_id, email, full_name)
|
|
208
|
+
VALUES (gen_random_uuid(), $1, $2, $3)
|
|
209
|
+
ON CONFLICT (core_user_id) DO UPDATE SET email = EXCLUDED.email, full_name = EXCLUDED.full_name\`,
|
|
210
|
+
[core_user_id, email, name]
|
|
211
|
+
);
|
|
212
|
+
const [rows] = await pool.query('SELECT * FROM users WHERE core_user_id = ?', [core_user_id]);
|
|
213
|
+
req.dbUser = rows[0];
|
|
214
|
+
next();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Use both as: router.get('/me', requireAuth, ensureUser, handler)
|
|
218
|
+
|
|
219
|
+
### Client-side: store and use the JWT
|
|
220
|
+
|
|
221
|
+
// On login:
|
|
222
|
+
const res = await fetch('/api/auth/login', { method: 'POST', body: JSON.stringify({ email, password }) });
|
|
223
|
+
const { access_token, refresh_token } = await res.json();
|
|
224
|
+
await AsyncStorage.setItem('access_token', access_token);
|
|
225
|
+
|
|
226
|
+
// On every API call:
|
|
227
|
+
const token = await AsyncStorage.getItem('access_token');
|
|
228
|
+
fetch('/api/teams', { headers: { Authorization: 'Bearer ' + token } });
|
|
229
|
+
|
|
230
|
+
// On 401, try refresh:
|
|
231
|
+
const res = await fetch('/api/auth/refresh', { method: 'POST', body: JSON.stringify({ refresh_token }) });
|
|
232
|
+
|
|
233
|
+
Your Express server proxies /api/auth/login and /api/auth/refresh to Core, then returns tokens to the client.
|
|
234
|
+
|
|
235
|
+
## Storage Proxy Pattern — Uploads From Browser / Mobile
|
|
236
|
+
|
|
237
|
+
Browser clients and React Native apps can't upload directly to R2 (CORS issues). Route uploads through your Express server instead:
|
|
238
|
+
|
|
239
|
+
### Server-side proxy route
|
|
240
|
+
|
|
241
|
+
import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
|
|
242
|
+
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
243
|
+
|
|
244
|
+
const s3 = new S3Client({
|
|
245
|
+
endpoint: process.env.S3_ENDPOINT,
|
|
246
|
+
region: process.env.S3_REGION || 'auto',
|
|
247
|
+
credentials: {
|
|
248
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
249
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
250
|
+
},
|
|
251
|
+
forcePathStyle: true,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Upload: browser/mobile → your server → R2
|
|
255
|
+
app.put('/api/upload', requireAuth, async (req, res) => {
|
|
256
|
+
const key = req.query.key; // e.g. "videos/team123/clip.mp4"
|
|
257
|
+
const contentType = req.headers['content-type'] || 'application/octet-stream';
|
|
258
|
+
await s3.send(new PutObjectCommand({
|
|
259
|
+
Bucket: process.env.S3_BUCKET_NAME,
|
|
260
|
+
Key: \`\${process.env.S3_PREFIX}/\${key}\`,
|
|
261
|
+
Body: req, // stream the request body directly
|
|
262
|
+
ContentType: contentType,
|
|
263
|
+
}));
|
|
264
|
+
res.json({ ok: true });
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Download: return presigned URL so client fetches directly from R2
|
|
268
|
+
app.get('/api/storage/sign', requireAuth, async (req, res) => {
|
|
269
|
+
const url = await getSignedUrl(s3, new GetObjectCommand({
|
|
270
|
+
Bucket: process.env.S3_BUCKET_NAME,
|
|
271
|
+
Key: \`\${process.env.S3_PREFIX}/\${req.query.path}\`,
|
|
272
|
+
}), { expiresIn: 3600 });
|
|
273
|
+
res.json({ signedUrl: url });
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
### Client-side (browser or React Native)
|
|
277
|
+
|
|
278
|
+
// Upload a video blob:
|
|
279
|
+
const blob = await fetch(localUri).then(r => r.blob());
|
|
280
|
+
await fetch(\`/api/upload?key=videos/\${teamId}/\${videoId}.webm\`, {
|
|
281
|
+
method: 'PUT',
|
|
282
|
+
body: blob,
|
|
283
|
+
headers: { 'Content-Type': blob.type, Authorization: 'Bearer ' + token },
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Get a playback URL:
|
|
287
|
+
const { signedUrl } = await fetch(\`/api/storage/sign?path=videos/\${teamId}/\${videoId}.webm\`,
|
|
288
|
+
{ headers: { Authorization: 'Bearer ' + token } }
|
|
289
|
+
).then(r => r.json());
|
|
290
|
+
|
|
291
|
+
This pattern avoids CORS entirely. The S3_* env vars are auto-injected by DOS — you never set them.
|
|
292
|
+
|
|
293
|
+
## Migrating From Supabase to DOS
|
|
294
|
+
|
|
295
|
+
Full migration covers four areas. None of them require downtime if done in the right order.
|
|
296
|
+
|
|
297
|
+
### 1. Auth (Supabase Auth → Core JWTs)
|
|
298
|
+
|
|
299
|
+
Replace supabase.auth.signIn() with a fetch to your Express /api/auth/login that proxies to Core.
|
|
300
|
+
Replace supabase.auth.getUser() with a GET to /api/auth/me using your Bearer token.
|
|
301
|
+
Store access_token + refresh_token in AsyncStorage (React Native) or localStorage (browser).
|
|
302
|
+
Your Express middleware handles JWT verification — clients never call Core directly.
|
|
303
|
+
|
|
304
|
+
### 2. Database (Supabase Postgres → DOS Postgres)
|
|
305
|
+
|
|
306
|
+
1. Dump: pg_dump -h <supabase-host> -U postgres <db> > dump.sql
|
|
307
|
+
2. DOS tunnel: dailey db connect <project> (opens 127.0.0.1:15432)
|
|
308
|
+
3. Restore: PGPASSWORD='...' psql -h 127.0.0.1 -p 15432 -U <user> -d <db> < dump.sql
|
|
309
|
+
|
|
310
|
+
Replace all supabase.from('table').select() calls with fetch('/api/table') calls to your Express API.
|
|
311
|
+
Express talks directly to DOS Postgres via DATABASE_URL — never expose the DB to the client.
|
|
312
|
+
|
|
313
|
+
### 3. Storage (Supabase Storage → R2 via proxy)
|
|
314
|
+
|
|
315
|
+
Replace supabase.storage.from('bucket').upload() with PUT /api/upload (see Storage Proxy above).
|
|
316
|
+
Replace supabase.storage.from('bucket').createSignedUrl() with GET /api/storage/sign.
|
|
317
|
+
R2 paths: videos/\${teamId}/\${itemId}/original.mp4 — organize under your entity hierarchy.
|
|
318
|
+
|
|
319
|
+
### 4. Realtime (if used)
|
|
320
|
+
|
|
321
|
+
DOS doesn't have Supabase realtime. Options:
|
|
322
|
+
- Poll: setInterval(() => fetch('/api/data'), 5000)
|
|
323
|
+
- Add WebSocket: const wss = new WebSocketServer({ server }) in your Express server
|
|
324
|
+
- Skip: many "realtime" uses are fine with polling at 5–30s intervals
|
|
325
|
+
|
|
326
|
+
### Reference implementation
|
|
327
|
+
|
|
328
|
+
gridiron-vision (React Native / Expo app) is the canonical Supabase→DOS migration.
|
|
329
|
+
Full Express server + Core auth + R2 proxy + Postgres + 19/19 e2e tests passing.
|
|
330
|
+
Auth: Core RS256 JWTs | DB: DOS Postgres (cust_cloud_gridiron_vision) | Storage: R2 proxy upload
|
|
331
|
+
|
|
153
332
|
## What You Don't Talk About
|
|
154
333
|
|
|
155
334
|
You are the user's assistant, not a window into the platform's internals. Do not discuss or reveal:
|
|
@@ -344,6 +523,136 @@ export function registerBuddyTools(server) {
|
|
|
344
523
|
`Set the secret: dailey env set <app> CRON_SECRET=$(openssl rand -hex 32)`,
|
|
345
524
|
].join('\n'));
|
|
346
525
|
}
|
|
526
|
+
if (t.includes('core') || t.includes('jwt') || t.includes('auth') || t.includes('login') || t.includes('user')) {
|
|
527
|
+
return textResult([
|
|
528
|
+
`Dailey Core is a multi-tenant identity platform at core.dailey.cloud.`,
|
|
529
|
+
`Use it when your app has its own end-users — it handles registration, login,`,
|
|
530
|
+
`password reset, and JWT issuance so you don't build auth from scratch.`,
|
|
531
|
+
``,
|
|
532
|
+
`Core issues RS256 JWTs verified via JWKS at:`,
|
|
533
|
+
` https://core.dailey.cloud/.well-known/jwks.json`,
|
|
534
|
+
``,
|
|
535
|
+
`JWT claims: sub (Core UUID), email, name, tenant, roles, app_slug`,
|
|
536
|
+
``,
|
|
537
|
+
`Express middleware pattern (npm install jwks-rsa jsonwebtoken):`,
|
|
538
|
+
` const jwksClient = jwksRsa({ jwksUri: 'https://core.dailey.cloud/.well-known/jwks.json', cache: true });`,
|
|
539
|
+
` function requireAuth(req, res, next) {`,
|
|
540
|
+
` const token = req.headers.authorization?.split(' ')[1];`,
|
|
541
|
+
` const { header } = jwt.decode(token, { complete: true });`,
|
|
542
|
+
` jwksClient.getSigningKey(header.kid, (err, key) => {`,
|
|
543
|
+
` req.user = jwt.verify(token, key.getPublicKey(), { algorithms: ['RS256'] });`,
|
|
544
|
+
` next();`,
|
|
545
|
+
` });`,
|
|
546
|
+
` }`,
|
|
547
|
+
``,
|
|
548
|
+
`After verifying the JWT, upsert a local user row (ensureUser pattern):`,
|
|
549
|
+
` INSERT INTO users (id, core_user_id, email, full_name) VALUES (UUID(), ?, ?, ?)`,
|
|
550
|
+
` ON DUPLICATE KEY UPDATE email = VALUES(email), full_name = VALUES(full_name)`,
|
|
551
|
+
``,
|
|
552
|
+
`Client stores access_token + refresh_token in AsyncStorage / localStorage.`,
|
|
553
|
+
`Your Express server proxies /api/auth/login and /api/auth/refresh to Core.`,
|
|
554
|
+
`Clients never call Core directly — they only talk to your Express API.`,
|
|
555
|
+
].join('\n'));
|
|
556
|
+
}
|
|
557
|
+
if (t.includes('supabase') || t.includes('migrat') || t.includes('switch') || t.includes('firebase')) {
|
|
558
|
+
return textResult([
|
|
559
|
+
`Migrating from Supabase (or Firebase) to DOS covers four areas:`,
|
|
560
|
+
``,
|
|
561
|
+
`1. Auth — Replace supabase.auth with Core JWTs`,
|
|
562
|
+
` • Add Express /api/auth/login + /api/auth/refresh routes that proxy to Core`,
|
|
563
|
+
` • Verify RS256 JWTs in Express with jwks-rsa (see "auth" topic)`,
|
|
564
|
+
` • Client stores tokens in AsyncStorage/localStorage — never calls Core directly`,
|
|
565
|
+
``,
|
|
566
|
+
`2. Database — Replace supabase.from() with fetch() to your Express API`,
|
|
567
|
+
` • Dump: pg_dump -h <supabase-host> -U postgres <db> > dump.sql`,
|
|
568
|
+
` • Restore via DOS tunnel: dailey db connect <project> (opens 127.0.0.1:15432)`,
|
|
569
|
+
` • PGPASSWORD='...' psql -h 127.0.0.1 -p 15432 -U <user> -d <db> < dump.sql`,
|
|
570
|
+
` • Express talks to DATABASE_URL (auto-injected) — DB never exposed to client`,
|
|
571
|
+
``,
|
|
572
|
+
`3. Storage — Replace supabase.storage with R2 proxy pattern`,
|
|
573
|
+
` • Add PUT /api/upload that streams the request body to R2 (via AWS SDK)`,
|
|
574
|
+
` • Add GET /api/storage/sign that returns a presigned R2 URL`,
|
|
575
|
+
` • S3_* env vars are auto-injected by DOS — you never set them`,
|
|
576
|
+
` • Avoids CORS entirely — browser/mobile → Express → R2`,
|
|
577
|
+
``,
|
|
578
|
+
`4. Realtime — DOS doesn't have Supabase realtime`,
|
|
579
|
+
` • Poll at 5–30s intervals (most use cases are fine with this)`,
|
|
580
|
+
` • Or add WebSocket via ws package in your Express server`,
|
|
581
|
+
``,
|
|
582
|
+
`Reference: gridiron-vision (React Native/Expo) is the canonical migration.`,
|
|
583
|
+
`Full Express + Core auth + R2 proxy + Postgres. 19/19 e2e tests passing.`,
|
|
584
|
+
].join('\n'));
|
|
585
|
+
}
|
|
586
|
+
if (t.includes('mobile') || t.includes('react native') || t.includes('expo') || t.includes('ios') || t.includes('android')) {
|
|
587
|
+
return textResult([
|
|
588
|
+
`DOS works well as the backend for React Native / Expo mobile apps.`,
|
|
589
|
+
`The frontend lives in Expo; all data access goes through your Express API on DOS.`,
|
|
590
|
+
``,
|
|
591
|
+
`Key differences from a web app:`,
|
|
592
|
+
``,
|
|
593
|
+
` • Base URL: use absolute URL for native, relative for web:`,
|
|
594
|
+
` const BASE = Platform.OS === 'web' ? '' : 'https://yourapp.dailey.cloud';`,
|
|
595
|
+
``,
|
|
596
|
+
` • Token storage: AsyncStorage (not cookies or localStorage)`,
|
|
597
|
+
` import AsyncStorage from '@react-native-async-storage/async-storage';`,
|
|
598
|
+
` await AsyncStorage.setItem('access_token', token);`,
|
|
599
|
+
``,
|
|
600
|
+
` • Uploads: fetch the local file URI as a blob, then PUT to /api/upload`,
|
|
601
|
+
` const blob = await fetch(localUri).then(r => r.blob());`,
|
|
602
|
+
` await fetch('/api/upload?key=videos/...', { method: 'PUT', body: blob });`,
|
|
603
|
+
``,
|
|
604
|
+
` • Auth: store access_token + refresh_token, auto-refresh on 401`,
|
|
605
|
+
` On 401: POST /api/auth/refresh with refresh_token → get new access_token`,
|
|
606
|
+
``,
|
|
607
|
+
` • CORS: not an issue for native. Still use the R2 proxy pattern for uploads`,
|
|
608
|
+
` (the proxy also enforces auth, which direct-to-R2 can't do).`,
|
|
609
|
+
``,
|
|
610
|
+
` • Video playback: use presigned URLs from GET /api/storage/sign`,
|
|
611
|
+
` Presigned URLs are time-limited (1h default) — fetch fresh on play.`,
|
|
612
|
+
``,
|
|
613
|
+
`Reference: gridiron-vision is a full Expo + DOS app (React Native + TypeScript).`,
|
|
614
|
+
`Auth via Core JWTs → Zustand stores → Express API → DOS Postgres + R2.`,
|
|
615
|
+
].join('\n'));
|
|
616
|
+
}
|
|
617
|
+
if (t.includes('proxy') || t.includes('upload') || t.includes('cors') || (t.includes('storage') && (t.includes('browser') || t.includes('mobile') || t.includes('upload')))) {
|
|
618
|
+
return textResult([
|
|
619
|
+
`Browser and mobile clients can't upload directly to R2 (CORS issues).`,
|
|
620
|
+
`Route uploads through your Express server as a proxy:`,
|
|
621
|
+
``,
|
|
622
|
+
` // npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner`,
|
|
623
|
+
` const s3 = new S3Client({`,
|
|
624
|
+
` endpoint: process.env.S3_ENDPOINT,`,
|
|
625
|
+
` region: process.env.S3_REGION || 'auto',`,
|
|
626
|
+
` credentials: { accessKeyId: process.env.S3_ACCESS_KEY_ID, secretAccessKey: process.env.S3_SECRET_ACCESS_KEY },`,
|
|
627
|
+
` forcePathStyle: true,`,
|
|
628
|
+
` });`,
|
|
629
|
+
``,
|
|
630
|
+
` // Upload route — streams client body directly to R2`,
|
|
631
|
+
` app.put('/api/upload', requireAuth, async (req, res) => {`,
|
|
632
|
+
` await s3.send(new PutObjectCommand({`,
|
|
633
|
+
` Bucket: process.env.S3_BUCKET_NAME,`,
|
|
634
|
+
` Key: \`\${process.env.S3_PREFIX}/\${req.query.key}\`,`,
|
|
635
|
+
` Body: req, ContentType: req.headers['content-type'],`,
|
|
636
|
+
` }));`,
|
|
637
|
+
` res.json({ ok: true });`,
|
|
638
|
+
` });`,
|
|
639
|
+
``,
|
|
640
|
+
` // Presigned download URL — client fetches directly from R2`,
|
|
641
|
+
` app.get('/api/storage/sign', requireAuth, async (req, res) => {`,
|
|
642
|
+
` const url = await getSignedUrl(s3, new GetObjectCommand({`,
|
|
643
|
+
` Bucket: process.env.S3_BUCKET_NAME,`,
|
|
644
|
+
` Key: \`\${process.env.S3_PREFIX}/\${req.query.path}\`,`,
|
|
645
|
+
` }), { expiresIn: 3600 });`,
|
|
646
|
+
` res.json({ signedUrl: url });`,
|
|
647
|
+
` });`,
|
|
648
|
+
``,
|
|
649
|
+
`Client upload (browser or React Native):`,
|
|
650
|
+
` const blob = await fetch(localUri).then(r => r.blob());`,
|
|
651
|
+
` await fetch('/api/upload?key=videos/team/clip.mp4', { method: 'PUT', body: blob });`,
|
|
652
|
+
``,
|
|
653
|
+
`S3_* env vars are auto-injected by DOS — don't set them manually.`,
|
|
654
|
+
].join('\n'));
|
|
655
|
+
}
|
|
347
656
|
// Generic fallback — the LLM has full context from the prompt resource
|
|
348
657
|
return textResult([
|
|
349
658
|
`I'm DOS Buddy — ask me anything about Dailey OS.`,
|
|
@@ -351,8 +660,9 @@ export function registerBuddyTools(server) {
|
|
|
351
660
|
`You asked about: ${topic}`,
|
|
352
661
|
``,
|
|
353
662
|
`I have full context on deployments, databases, storage, secrets, cron,`,
|
|
354
|
-
`marketplace, CLI commands,
|
|
355
|
-
`
|
|
663
|
+
`marketplace, CLI commands, Core auth, storage proxy pattern, Supabase`,
|
|
664
|
+
`migration, mobile/React Native patterns, and common errors.`,
|
|
665
|
+
`Just ask naturally and I'll walk you through it.`,
|
|
356
666
|
].join('\n'));
|
|
357
667
|
});
|
|
358
668
|
}
|
package/dist/tools/buddy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buddy.js","sourceRoot":"","sources":["../../src/tools/buddy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,gFAAgF;AAChF,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,gBAAgB,GAAG
|
|
1
|
+
{"version":3,"file":"buddy.js","sourceRoot":"","sources":["../../src/tools/buddy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,gFAAgF;AAChF,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,wCAAwC;gBACxC,8CAA8C;gBAC9C,oHAAoH;gBACpH,2BAA2B;gBAC3B,OAAO;gBACP,EAAE;gBACF,wDAAwD;gBACxD,6DAA6D;gBAC7D,0CAA0C;gBAC1C,2CAA2C;gBAC3C,6DAA6D;gBAC7D,4DAA4D;gBAC5D,UAAU;gBACV,6BAA6B;gBAC7B,OAAO;gBACP,EAAE;gBACF,+DAA+D;gBAC/D,mEAAmE;gBACnE,+DAA+D;gBAC/D,2CAA2C;gBAC3C,8DAA8D;gBAC9D,+BAA+B;gBAC/B,mCAAmC;gBACnC,OAAO;gBACP,EAAE;gBACF,0CAA0C;gBAC1C,2DAA2D;gBAC3D,uFAAuF;gBACvF,EAAE;gBACF,mEAAmE;aACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChB,CAAC;QAED,uEAAuE;QACvE,OAAO,UAAU,CAAC;YAChB,kDAAkD;YAClD,EAAE;YACF,oBAAoB,KAAK,EAAE;YAC3B,EAAE;YACF,wEAAwE;YACxE,uEAAuE;YACvE,6DAA6D;YAC7D,kDAAkD;SACnD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -14,7 +14,7 @@ function maskValue(v) {
|
|
|
14
14
|
return '•'.repeat(Math.min(v.length - 3, 12)) + tail + ` (${v.length} chars)`;
|
|
15
15
|
}
|
|
16
16
|
export function registerCredentialRevealTools(server) {
|
|
17
|
-
server.tool('dailey_reveal_credential', 'Reveal a project credential
|
|
17
|
+
server.tool('dailey_reveal_credential', 'Reveal a project credential after re-auth. Supports DB credentials (DB_PASSWORD, DB_USER, DB_HOST, DB_PORT, DB_NAME) and storage credentials (S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME, S3_KEY_PREFIX). Every reveal is audited. BY DEFAULT returns a masked preview (last 3 chars + length) so the value never enters chat transcripts. Pass emit_plaintext=true to see the full value — only do this when you understand the chat-log exposure. Better workflow for S3 vars: use dailey_storage_enable to fix missing injection; use dailey_db_tunnel for DB creds.', {
|
|
18
18
|
project_id: z.string().describe('The project ID'),
|
|
19
19
|
key: z.string().describe('Credential key (e.g., DB_PASSWORD, WORDPRESS_ADMIN_PASSWORD)'),
|
|
20
20
|
password: z.string().optional().describe('Account password for re-auth (falls back to DAILEY_PASSWORD env var)'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials-reveal.js","sourceRoot":"","sources":["../../src/tools/credentials-reveal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEhE;;;;GAIG;AACH,SAAS,SAAS,CAAC,CAAS;IAC1B,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,SAAS,CAAC;IACxE,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzB,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,SAAS,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,MAAiB;IAC7D,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"credentials-reveal.js","sourceRoot":"","sources":["../../src/tools/credentials-reveal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EA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|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/tools/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA+DpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/tools/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA+DpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,QAyNrD"}
|
package/dist/tools/storage.js
CHANGED
|
@@ -22,6 +22,12 @@ export function registerStorageTools(server) {
|
|
|
22
22
|
`Max Upload: ${data.binding.limits.max_single_upload_mb} MB`,
|
|
23
23
|
`URL TTL: ${data.binding.limits.signed_url_ttl_seconds}s`,
|
|
24
24
|
];
|
|
25
|
+
// Surface credential-missing warning before anything else so the LLM
|
|
26
|
+
// sees it immediately and can call dailey_storage_enable to fix it.
|
|
27
|
+
if (data.secret_warning) {
|
|
28
|
+
lines.push('');
|
|
29
|
+
lines.push(`⚠ WARNING: ${data.secret_warning}`);
|
|
30
|
+
}
|
|
25
31
|
// Render the new integration_paths block when the API surfaces it.
|
|
26
32
|
// Older customer-api responses still set next_step; fall back to that
|
|
27
33
|
// verbatim so this tool keeps working during the rolling deploy.
|
|
@@ -124,6 +130,30 @@ export function registerStorageTools(server) {
|
|
|
124
130
|
lines.push(data.upload_url);
|
|
125
131
|
return textResult(lines.join('\n'));
|
|
126
132
|
});
|
|
133
|
+
server.tool('dailey_storage_enable', 'Enable object storage on an existing project that was created without it, OR fix a project where storage was enabled but S3_* env vars are missing from the pod (secret_injected=false from dailey_storage_info). Provisions R2 credentials, creates the k8s secret, and patches the running deployment so pods pick up S3_* vars immediately. A redeploy is not required after calling this.', { project_id: z.string().describe('The project ID') }, async ({ project_id }) => {
|
|
134
|
+
const res = await apiRequest('POST', `/projects/${project_id}/storage/enable`);
|
|
135
|
+
if (!res.ok) {
|
|
136
|
+
// 409 means already enabled — check if the secret is actually present
|
|
137
|
+
if (res.status === 409) {
|
|
138
|
+
return textResult(`Storage is already enabled for this project.\n\nIf S3_* vars are still missing from your pod, the credentials secret may not have been created correctly.\nCheck: dailey_storage_info to see secret_injected status.\nFix: redeploy the project (dailey_deploy) to re-mount the secret.`);
|
|
139
|
+
}
|
|
140
|
+
return textResult(formatError(res));
|
|
141
|
+
}
|
|
142
|
+
return textResult([
|
|
143
|
+
`Storage enabled.`,
|
|
144
|
+
``,
|
|
145
|
+
`Prefix: ${res.data.prefix}`,
|
|
146
|
+
``,
|
|
147
|
+
res.data.message,
|
|
148
|
+
``,
|
|
149
|
+
`S3_* env vars now available in your pod:`,
|
|
150
|
+
` S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME`,
|
|
151
|
+
` S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_KEY_PREFIX`,
|
|
152
|
+
``,
|
|
153
|
+
`Pods are restarting to pick up the new secret (~30s). No rebuild needed.`,
|
|
154
|
+
`If vars are still missing after 60s, call dailey_deploy to trigger a fresh rollout.`,
|
|
155
|
+
].join('\n'));
|
|
156
|
+
});
|
|
127
157
|
server.tool('dailey_storage_presign_download', 'For BROWSER-side flows. Server-side apps deployed on Dailey should instead use the S3 SDK with the auto-injected S3_* env vars (see dailey_storage_info). Creates a presigned download URL for an object in a project bucket.', {
|
|
128
158
|
project_id: z.string().describe('The project ID'),
|
|
129
159
|
key: z.string().describe('The object key to download'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/tools/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA6DhE,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IAC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CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,MAAM,KAAK,GAAG;YACZ,oBAAoB;YACpB,YAAY,IAAI,CAAC,MAAM,EAAE;YACzB,YAAY,IAAI,CAAC,GAAG,EAAE;YACtB,YAAY,IAAI,CAAC,UAAU,EAAE;SAC9B,CAAC;QACF,IAAI,IAAI,CAAC,YAAY;YAAE,KAAK,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACnE,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,QAAQ,CAAC,CAAC;QAC9E,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/tools/buddy.ts
CHANGED
|
@@ -152,6 +152,185 @@ Common issues and what they actually mean:
|
|
|
152
152
|
- 520 error when running long exec commands → Cloudflare has a body size limit; write the script to /tmp/script.js first, then run node /tmp/script.js as a separate exec call.
|
|
153
153
|
- "Migrations not applied" on first deploy → DOS doesn't auto-run migrations; use dailey run <app> -- node scripts/migrate.js
|
|
154
154
|
|
|
155
|
+
## Core Auth — For Apps With End Users
|
|
156
|
+
|
|
157
|
+
Dailey Core is a multi-tenant identity platform at core.dailey.cloud. Use it when your app has its own end-users (players, customers, team members) — not just a single admin account. It handles registration, login, password reset, and JWT issuance so you don't have to build auth from scratch.
|
|
158
|
+
|
|
159
|
+
### How Core JWTs work
|
|
160
|
+
|
|
161
|
+
Core issues RS256 JWTs. Your Express server verifies them using the public JWKS at:
|
|
162
|
+
https://core.dailey.cloud/.well-known/jwks.json
|
|
163
|
+
|
|
164
|
+
JWT claims: sub (Core user UUID), email, name, tenant, tenants, roles, app_slug
|
|
165
|
+
KID: dailey-core-20251223-01 | Issuer: https://core.dailey.cloud
|
|
166
|
+
|
|
167
|
+
### Express auth middleware (copy-paste ready)
|
|
168
|
+
|
|
169
|
+
npm install jwks-rsa jsonwebtoken
|
|
170
|
+
|
|
171
|
+
const jwksRsa = require('jwks-rsa');
|
|
172
|
+
const jwt = require('jsonwebtoken');
|
|
173
|
+
|
|
174
|
+
const jwksClient = jwksRsa({
|
|
175
|
+
jwksUri: 'https://core.dailey.cloud/.well-known/jwks.json',
|
|
176
|
+
cache: true,
|
|
177
|
+
cacheMaxAge: 300_000, // 5 min — don't hammer Core
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
function requireAuth(req, res, next) {
|
|
181
|
+
const token = req.headers.authorization?.split(' ')[1];
|
|
182
|
+
if (!token) return res.status(401).json({ error: 'No token' });
|
|
183
|
+
const { header } = jwt.decode(token, { complete: true });
|
|
184
|
+
jwksClient.getSigningKey(header.kid, (err, key) => {
|
|
185
|
+
if (err) return res.status(401).json({ error: 'Invalid token' });
|
|
186
|
+
try {
|
|
187
|
+
req.user = jwt.verify(token, key.getPublicKey(), { algorithms: ['RS256'] });
|
|
188
|
+
next();
|
|
189
|
+
} catch { return res.status(401).json({ error: 'Token expired' }); }
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
### Upsert local user on first request (ensureUser pattern)
|
|
194
|
+
|
|
195
|
+
After verifying the JWT, create a local user row if it doesn't exist yet.
|
|
196
|
+
This way your DB uses your own UUIDs while Core handles credentials:
|
|
197
|
+
|
|
198
|
+
async function ensureUser(req, res, next) {
|
|
199
|
+
const { sub: core_user_id, email, name } = req.user;
|
|
200
|
+
// MySQL:
|
|
201
|
+
await pool.query(
|
|
202
|
+
\`INSERT INTO users (id, core_user_id, email, full_name)
|
|
203
|
+
VALUES (UUID(), ?, ?, ?)
|
|
204
|
+
ON DUPLICATE KEY UPDATE email = VALUES(email), full_name = VALUES(full_name)\`,
|
|
205
|
+
[core_user_id, email, name]
|
|
206
|
+
);
|
|
207
|
+
// PostgreSQL:
|
|
208
|
+
await pool.query(
|
|
209
|
+
\`INSERT INTO users (id, core_user_id, email, full_name)
|
|
210
|
+
VALUES (gen_random_uuid(), $1, $2, $3)
|
|
211
|
+
ON CONFLICT (core_user_id) DO UPDATE SET email = EXCLUDED.email, full_name = EXCLUDED.full_name\`,
|
|
212
|
+
[core_user_id, email, name]
|
|
213
|
+
);
|
|
214
|
+
const [rows] = await pool.query('SELECT * FROM users WHERE core_user_id = ?', [core_user_id]);
|
|
215
|
+
req.dbUser = rows[0];
|
|
216
|
+
next();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
Use both as: router.get('/me', requireAuth, ensureUser, handler)
|
|
220
|
+
|
|
221
|
+
### Client-side: store and use the JWT
|
|
222
|
+
|
|
223
|
+
// On login:
|
|
224
|
+
const res = await fetch('/api/auth/login', { method: 'POST', body: JSON.stringify({ email, password }) });
|
|
225
|
+
const { access_token, refresh_token } = await res.json();
|
|
226
|
+
await AsyncStorage.setItem('access_token', access_token);
|
|
227
|
+
|
|
228
|
+
// On every API call:
|
|
229
|
+
const token = await AsyncStorage.getItem('access_token');
|
|
230
|
+
fetch('/api/teams', { headers: { Authorization: 'Bearer ' + token } });
|
|
231
|
+
|
|
232
|
+
// On 401, try refresh:
|
|
233
|
+
const res = await fetch('/api/auth/refresh', { method: 'POST', body: JSON.stringify({ refresh_token }) });
|
|
234
|
+
|
|
235
|
+
Your Express server proxies /api/auth/login and /api/auth/refresh to Core, then returns tokens to the client.
|
|
236
|
+
|
|
237
|
+
## Storage Proxy Pattern — Uploads From Browser / Mobile
|
|
238
|
+
|
|
239
|
+
Browser clients and React Native apps can't upload directly to R2 (CORS issues). Route uploads through your Express server instead:
|
|
240
|
+
|
|
241
|
+
### Server-side proxy route
|
|
242
|
+
|
|
243
|
+
import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
|
|
244
|
+
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
245
|
+
|
|
246
|
+
const s3 = new S3Client({
|
|
247
|
+
endpoint: process.env.S3_ENDPOINT,
|
|
248
|
+
region: process.env.S3_REGION || 'auto',
|
|
249
|
+
credentials: {
|
|
250
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
251
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
252
|
+
},
|
|
253
|
+
forcePathStyle: true,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// Upload: browser/mobile → your server → R2
|
|
257
|
+
app.put('/api/upload', requireAuth, async (req, res) => {
|
|
258
|
+
const key = req.query.key; // e.g. "videos/team123/clip.mp4"
|
|
259
|
+
const contentType = req.headers['content-type'] || 'application/octet-stream';
|
|
260
|
+
await s3.send(new PutObjectCommand({
|
|
261
|
+
Bucket: process.env.S3_BUCKET_NAME,
|
|
262
|
+
Key: \`\${process.env.S3_PREFIX}/\${key}\`,
|
|
263
|
+
Body: req, // stream the request body directly
|
|
264
|
+
ContentType: contentType,
|
|
265
|
+
}));
|
|
266
|
+
res.json({ ok: true });
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Download: return presigned URL so client fetches directly from R2
|
|
270
|
+
app.get('/api/storage/sign', requireAuth, async (req, res) => {
|
|
271
|
+
const url = await getSignedUrl(s3, new GetObjectCommand({
|
|
272
|
+
Bucket: process.env.S3_BUCKET_NAME,
|
|
273
|
+
Key: \`\${process.env.S3_PREFIX}/\${req.query.path}\`,
|
|
274
|
+
}), { expiresIn: 3600 });
|
|
275
|
+
res.json({ signedUrl: url });
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
### Client-side (browser or React Native)
|
|
279
|
+
|
|
280
|
+
// Upload a video blob:
|
|
281
|
+
const blob = await fetch(localUri).then(r => r.blob());
|
|
282
|
+
await fetch(\`/api/upload?key=videos/\${teamId}/\${videoId}.webm\`, {
|
|
283
|
+
method: 'PUT',
|
|
284
|
+
body: blob,
|
|
285
|
+
headers: { 'Content-Type': blob.type, Authorization: 'Bearer ' + token },
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Get a playback URL:
|
|
289
|
+
const { signedUrl } = await fetch(\`/api/storage/sign?path=videos/\${teamId}/\${videoId}.webm\`,
|
|
290
|
+
{ headers: { Authorization: 'Bearer ' + token } }
|
|
291
|
+
).then(r => r.json());
|
|
292
|
+
|
|
293
|
+
This pattern avoids CORS entirely. The S3_* env vars are auto-injected by DOS — you never set them.
|
|
294
|
+
|
|
295
|
+
## Migrating From Supabase to DOS
|
|
296
|
+
|
|
297
|
+
Full migration covers four areas. None of them require downtime if done in the right order.
|
|
298
|
+
|
|
299
|
+
### 1. Auth (Supabase Auth → Core JWTs)
|
|
300
|
+
|
|
301
|
+
Replace supabase.auth.signIn() with a fetch to your Express /api/auth/login that proxies to Core.
|
|
302
|
+
Replace supabase.auth.getUser() with a GET to /api/auth/me using your Bearer token.
|
|
303
|
+
Store access_token + refresh_token in AsyncStorage (React Native) or localStorage (browser).
|
|
304
|
+
Your Express middleware handles JWT verification — clients never call Core directly.
|
|
305
|
+
|
|
306
|
+
### 2. Database (Supabase Postgres → DOS Postgres)
|
|
307
|
+
|
|
308
|
+
1. Dump: pg_dump -h <supabase-host> -U postgres <db> > dump.sql
|
|
309
|
+
2. DOS tunnel: dailey db connect <project> (opens 127.0.0.1:15432)
|
|
310
|
+
3. Restore: PGPASSWORD='...' psql -h 127.0.0.1 -p 15432 -U <user> -d <db> < dump.sql
|
|
311
|
+
|
|
312
|
+
Replace all supabase.from('table').select() calls with fetch('/api/table') calls to your Express API.
|
|
313
|
+
Express talks directly to DOS Postgres via DATABASE_URL — never expose the DB to the client.
|
|
314
|
+
|
|
315
|
+
### 3. Storage (Supabase Storage → R2 via proxy)
|
|
316
|
+
|
|
317
|
+
Replace supabase.storage.from('bucket').upload() with PUT /api/upload (see Storage Proxy above).
|
|
318
|
+
Replace supabase.storage.from('bucket').createSignedUrl() with GET /api/storage/sign.
|
|
319
|
+
R2 paths: videos/\${teamId}/\${itemId}/original.mp4 — organize under your entity hierarchy.
|
|
320
|
+
|
|
321
|
+
### 4. Realtime (if used)
|
|
322
|
+
|
|
323
|
+
DOS doesn't have Supabase realtime. Options:
|
|
324
|
+
- Poll: setInterval(() => fetch('/api/data'), 5000)
|
|
325
|
+
- Add WebSocket: const wss = new WebSocketServer({ server }) in your Express server
|
|
326
|
+
- Skip: many "realtime" uses are fine with polling at 5–30s intervals
|
|
327
|
+
|
|
328
|
+
### Reference implementation
|
|
329
|
+
|
|
330
|
+
gridiron-vision (React Native / Expo app) is the canonical Supabase→DOS migration.
|
|
331
|
+
Full Express server + Core auth + R2 proxy + Postgres + 19/19 e2e tests passing.
|
|
332
|
+
Auth: Core RS256 JWTs | DB: DOS Postgres (cust_cloud_gridiron_vision) | Storage: R2 proxy upload
|
|
333
|
+
|
|
155
334
|
## What You Don't Talk About
|
|
156
335
|
|
|
157
336
|
You are the user's assistant, not a window into the platform's internals. Do not discuss or reveal:
|
|
@@ -371,6 +550,140 @@ export function registerBuddyTools(server: McpServer) {
|
|
|
371
550
|
].join('\n'));
|
|
372
551
|
}
|
|
373
552
|
|
|
553
|
+
if (t.includes('core') || t.includes('jwt') || t.includes('auth') || t.includes('login') || t.includes('user')) {
|
|
554
|
+
return textResult([
|
|
555
|
+
`Dailey Core is a multi-tenant identity platform at core.dailey.cloud.`,
|
|
556
|
+
`Use it when your app has its own end-users — it handles registration, login,`,
|
|
557
|
+
`password reset, and JWT issuance so you don't build auth from scratch.`,
|
|
558
|
+
``,
|
|
559
|
+
`Core issues RS256 JWTs verified via JWKS at:`,
|
|
560
|
+
` https://core.dailey.cloud/.well-known/jwks.json`,
|
|
561
|
+
``,
|
|
562
|
+
`JWT claims: sub (Core UUID), email, name, tenant, roles, app_slug`,
|
|
563
|
+
``,
|
|
564
|
+
`Express middleware pattern (npm install jwks-rsa jsonwebtoken):`,
|
|
565
|
+
` const jwksClient = jwksRsa({ jwksUri: 'https://core.dailey.cloud/.well-known/jwks.json', cache: true });`,
|
|
566
|
+
` function requireAuth(req, res, next) {`,
|
|
567
|
+
` const token = req.headers.authorization?.split(' ')[1];`,
|
|
568
|
+
` const { header } = jwt.decode(token, { complete: true });`,
|
|
569
|
+
` jwksClient.getSigningKey(header.kid, (err, key) => {`,
|
|
570
|
+
` req.user = jwt.verify(token, key.getPublicKey(), { algorithms: ['RS256'] });`,
|
|
571
|
+
` next();`,
|
|
572
|
+
` });`,
|
|
573
|
+
` }`,
|
|
574
|
+
``,
|
|
575
|
+
`After verifying the JWT, upsert a local user row (ensureUser pattern):`,
|
|
576
|
+
` INSERT INTO users (id, core_user_id, email, full_name) VALUES (UUID(), ?, ?, ?)`,
|
|
577
|
+
` ON DUPLICATE KEY UPDATE email = VALUES(email), full_name = VALUES(full_name)`,
|
|
578
|
+
``,
|
|
579
|
+
`Client stores access_token + refresh_token in AsyncStorage / localStorage.`,
|
|
580
|
+
`Your Express server proxies /api/auth/login and /api/auth/refresh to Core.`,
|
|
581
|
+
`Clients never call Core directly — they only talk to your Express API.`,
|
|
582
|
+
].join('\n'));
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (t.includes('supabase') || t.includes('migrat') || t.includes('switch') || t.includes('firebase')) {
|
|
586
|
+
return textResult([
|
|
587
|
+
`Migrating from Supabase (or Firebase) to DOS covers four areas:`,
|
|
588
|
+
``,
|
|
589
|
+
`1. Auth — Replace supabase.auth with Core JWTs`,
|
|
590
|
+
` • Add Express /api/auth/login + /api/auth/refresh routes that proxy to Core`,
|
|
591
|
+
` • Verify RS256 JWTs in Express with jwks-rsa (see "auth" topic)`,
|
|
592
|
+
` • Client stores tokens in AsyncStorage/localStorage — never calls Core directly`,
|
|
593
|
+
``,
|
|
594
|
+
`2. Database — Replace supabase.from() with fetch() to your Express API`,
|
|
595
|
+
` • Dump: pg_dump -h <supabase-host> -U postgres <db> > dump.sql`,
|
|
596
|
+
` • Restore via DOS tunnel: dailey db connect <project> (opens 127.0.0.1:15432)`,
|
|
597
|
+
` • PGPASSWORD='...' psql -h 127.0.0.1 -p 15432 -U <user> -d <db> < dump.sql`,
|
|
598
|
+
` • Express talks to DATABASE_URL (auto-injected) — DB never exposed to client`,
|
|
599
|
+
``,
|
|
600
|
+
`3. Storage — Replace supabase.storage with R2 proxy pattern`,
|
|
601
|
+
` • Add PUT /api/upload that streams the request body to R2 (via AWS SDK)`,
|
|
602
|
+
` • Add GET /api/storage/sign that returns a presigned R2 URL`,
|
|
603
|
+
` • S3_* env vars are auto-injected by DOS — you never set them`,
|
|
604
|
+
` • Avoids CORS entirely — browser/mobile → Express → R2`,
|
|
605
|
+
``,
|
|
606
|
+
`4. Realtime — DOS doesn't have Supabase realtime`,
|
|
607
|
+
` • Poll at 5–30s intervals (most use cases are fine with this)`,
|
|
608
|
+
` • Or add WebSocket via ws package in your Express server`,
|
|
609
|
+
``,
|
|
610
|
+
`Reference: gridiron-vision (React Native/Expo) is the canonical migration.`,
|
|
611
|
+
`Full Express + Core auth + R2 proxy + Postgres. 19/19 e2e tests passing.`,
|
|
612
|
+
].join('\n'));
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (t.includes('mobile') || t.includes('react native') || t.includes('expo') || t.includes('ios') || t.includes('android')) {
|
|
616
|
+
return textResult([
|
|
617
|
+
`DOS works well as the backend for React Native / Expo mobile apps.`,
|
|
618
|
+
`The frontend lives in Expo; all data access goes through your Express API on DOS.`,
|
|
619
|
+
``,
|
|
620
|
+
`Key differences from a web app:`,
|
|
621
|
+
``,
|
|
622
|
+
` • Base URL: use absolute URL for native, relative for web:`,
|
|
623
|
+
` const BASE = Platform.OS === 'web' ? '' : 'https://yourapp.dailey.cloud';`,
|
|
624
|
+
``,
|
|
625
|
+
` • Token storage: AsyncStorage (not cookies or localStorage)`,
|
|
626
|
+
` import AsyncStorage from '@react-native-async-storage/async-storage';`,
|
|
627
|
+
` await AsyncStorage.setItem('access_token', token);`,
|
|
628
|
+
``,
|
|
629
|
+
` • Uploads: fetch the local file URI as a blob, then PUT to /api/upload`,
|
|
630
|
+
` const blob = await fetch(localUri).then(r => r.blob());`,
|
|
631
|
+
` await fetch('/api/upload?key=videos/...', { method: 'PUT', body: blob });`,
|
|
632
|
+
``,
|
|
633
|
+
` • Auth: store access_token + refresh_token, auto-refresh on 401`,
|
|
634
|
+
` On 401: POST /api/auth/refresh with refresh_token → get new access_token`,
|
|
635
|
+
``,
|
|
636
|
+
` • CORS: not an issue for native. Still use the R2 proxy pattern for uploads`,
|
|
637
|
+
` (the proxy also enforces auth, which direct-to-R2 can't do).`,
|
|
638
|
+
``,
|
|
639
|
+
` • Video playback: use presigned URLs from GET /api/storage/sign`,
|
|
640
|
+
` Presigned URLs are time-limited (1h default) — fetch fresh on play.`,
|
|
641
|
+
``,
|
|
642
|
+
`Reference: gridiron-vision is a full Expo + DOS app (React Native + TypeScript).`,
|
|
643
|
+
`Auth via Core JWTs → Zustand stores → Express API → DOS Postgres + R2.`,
|
|
644
|
+
].join('\n'));
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (t.includes('proxy') || t.includes('upload') || t.includes('cors') || (t.includes('storage') && (t.includes('browser') || t.includes('mobile') || t.includes('upload')))) {
|
|
648
|
+
return textResult([
|
|
649
|
+
`Browser and mobile clients can't upload directly to R2 (CORS issues).`,
|
|
650
|
+
`Route uploads through your Express server as a proxy:`,
|
|
651
|
+
``,
|
|
652
|
+
` // npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner`,
|
|
653
|
+
` const s3 = new S3Client({`,
|
|
654
|
+
` endpoint: process.env.S3_ENDPOINT,`,
|
|
655
|
+
` region: process.env.S3_REGION || 'auto',`,
|
|
656
|
+
` credentials: { accessKeyId: process.env.S3_ACCESS_KEY_ID, secretAccessKey: process.env.S3_SECRET_ACCESS_KEY },`,
|
|
657
|
+
` forcePathStyle: true,`,
|
|
658
|
+
` });`,
|
|
659
|
+
``,
|
|
660
|
+
` // Upload route — streams client body directly to R2`,
|
|
661
|
+
` app.put('/api/upload', requireAuth, async (req, res) => {`,
|
|
662
|
+
` await s3.send(new PutObjectCommand({`,
|
|
663
|
+
` Bucket: process.env.S3_BUCKET_NAME,`,
|
|
664
|
+
` Key: \`\${process.env.S3_PREFIX}/\${req.query.key}\`,`,
|
|
665
|
+
` Body: req, ContentType: req.headers['content-type'],`,
|
|
666
|
+
` }));`,
|
|
667
|
+
` res.json({ ok: true });`,
|
|
668
|
+
` });`,
|
|
669
|
+
``,
|
|
670
|
+
` // Presigned download URL — client fetches directly from R2`,
|
|
671
|
+
` app.get('/api/storage/sign', requireAuth, async (req, res) => {`,
|
|
672
|
+
` const url = await getSignedUrl(s3, new GetObjectCommand({`,
|
|
673
|
+
` Bucket: process.env.S3_BUCKET_NAME,`,
|
|
674
|
+
` Key: \`\${process.env.S3_PREFIX}/\${req.query.path}\`,`,
|
|
675
|
+
` }), { expiresIn: 3600 });`,
|
|
676
|
+
` res.json({ signedUrl: url });`,
|
|
677
|
+
` });`,
|
|
678
|
+
``,
|
|
679
|
+
`Client upload (browser or React Native):`,
|
|
680
|
+
` const blob = await fetch(localUri).then(r => r.blob());`,
|
|
681
|
+
` await fetch('/api/upload?key=videos/team/clip.mp4', { method: 'PUT', body: blob });`,
|
|
682
|
+
``,
|
|
683
|
+
`S3_* env vars are auto-injected by DOS — don't set them manually.`,
|
|
684
|
+
].join('\n'));
|
|
685
|
+
}
|
|
686
|
+
|
|
374
687
|
// Generic fallback — the LLM has full context from the prompt resource
|
|
375
688
|
return textResult([
|
|
376
689
|
`I'm DOS Buddy — ask me anything about Dailey OS.`,
|
|
@@ -378,8 +691,9 @@ export function registerBuddyTools(server: McpServer) {
|
|
|
378
691
|
`You asked about: ${topic}`,
|
|
379
692
|
``,
|
|
380
693
|
`I have full context on deployments, databases, storage, secrets, cron,`,
|
|
381
|
-
`marketplace, CLI commands,
|
|
382
|
-
`
|
|
694
|
+
`marketplace, CLI commands, Core auth, storage proxy pattern, Supabase`,
|
|
695
|
+
`migration, mobile/React Native patterns, and common errors.`,
|
|
696
|
+
`Just ask naturally and I'll walk you through it.`,
|
|
383
697
|
].join('\n'));
|
|
384
698
|
},
|
|
385
699
|
);
|
|
@@ -17,7 +17,7 @@ function maskValue(v: string): string {
|
|
|
17
17
|
export function registerCredentialRevealTools(server: McpServer) {
|
|
18
18
|
server.tool(
|
|
19
19
|
'dailey_reveal_credential',
|
|
20
|
-
'Reveal a project credential
|
|
20
|
+
'Reveal a project credential after re-auth. Supports DB credentials (DB_PASSWORD, DB_USER, DB_HOST, DB_PORT, DB_NAME) and storage credentials (S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME, S3_KEY_PREFIX). Every reveal is audited. BY DEFAULT returns a masked preview (last 3 chars + length) so the value never enters chat transcripts. Pass emit_plaintext=true to see the full value — only do this when you understand the chat-log exposure. Better workflow for S3 vars: use dailey_storage_enable to fix missing injection; use dailey_db_tunnel for DB creds.',
|
|
21
21
|
{
|
|
22
22
|
project_id: z.string().describe('The project ID'),
|
|
23
23
|
key: z.string().describe('Credential key (e.g., DB_PASSWORD, WORDPRESS_ADMIN_PASSWORD)'),
|
package/src/tools/storage.ts
CHANGED
|
@@ -88,6 +88,13 @@ export function registerStorageTools(server: McpServer) {
|
|
|
88
88
|
`URL TTL: ${data.binding.limits.signed_url_ttl_seconds}s`,
|
|
89
89
|
];
|
|
90
90
|
|
|
91
|
+
// Surface credential-missing warning before anything else so the LLM
|
|
92
|
+
// sees it immediately and can call dailey_storage_enable to fix it.
|
|
93
|
+
if ((data as any).secret_warning) {
|
|
94
|
+
lines.push('');
|
|
95
|
+
lines.push(`⚠ WARNING: ${(data as any).secret_warning}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
// Render the new integration_paths block when the API surfaces it.
|
|
92
99
|
// Older customer-api responses still set next_step; fall back to that
|
|
93
100
|
// verbatim so this tool keeps working during the rolling deploy.
|
|
@@ -205,6 +212,41 @@ export function registerStorageTools(server: McpServer) {
|
|
|
205
212
|
},
|
|
206
213
|
);
|
|
207
214
|
|
|
215
|
+
server.tool(
|
|
216
|
+
'dailey_storage_enable',
|
|
217
|
+
'Enable object storage on an existing project that was created without it, OR fix a project where storage was enabled but S3_* env vars are missing from the pod (secret_injected=false from dailey_storage_info). Provisions R2 credentials, creates the k8s secret, and patches the running deployment so pods pick up S3_* vars immediately. A redeploy is not required after calling this.',
|
|
218
|
+
{ project_id: z.string().describe('The project ID') },
|
|
219
|
+
async ({ project_id }) => {
|
|
220
|
+
const res = await apiRequest<{ ok: boolean; message: string; prefix: string }>(
|
|
221
|
+
'POST',
|
|
222
|
+
`/projects/${project_id}/storage/enable`,
|
|
223
|
+
);
|
|
224
|
+
if (!res.ok) {
|
|
225
|
+
// 409 means already enabled — check if the secret is actually present
|
|
226
|
+
if (res.status === 409) {
|
|
227
|
+
return textResult(
|
|
228
|
+
`Storage is already enabled for this project.\n\nIf S3_* vars are still missing from your pod, the credentials secret may not have been created correctly.\nCheck: dailey_storage_info to see secret_injected status.\nFix: redeploy the project (dailey_deploy) to re-mount the secret.`,
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return textResult(formatError(res));
|
|
232
|
+
}
|
|
233
|
+
return textResult([
|
|
234
|
+
`Storage enabled.`,
|
|
235
|
+
``,
|
|
236
|
+
`Prefix: ${res.data.prefix}`,
|
|
237
|
+
``,
|
|
238
|
+
res.data.message,
|
|
239
|
+
``,
|
|
240
|
+
`S3_* env vars now available in your pod:`,
|
|
241
|
+
` S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME`,
|
|
242
|
+
` S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_KEY_PREFIX`,
|
|
243
|
+
``,
|
|
244
|
+
`Pods are restarting to pick up the new secret (~30s). No rebuild needed.`,
|
|
245
|
+
`If vars are still missing after 60s, call dailey_deploy to trigger a fresh rollout.`,
|
|
246
|
+
].join('\n'));
|
|
247
|
+
},
|
|
248
|
+
);
|
|
249
|
+
|
|
208
250
|
server.tool(
|
|
209
251
|
'dailey_storage_presign_download',
|
|
210
252
|
'For BROWSER-side flows. Server-side apps deployed on Dailey should instead use the S3 SDK with the auto-injected S3_* env vars (see dailey_storage_info). Creates a presigned download URL for an object in a project bucket.',
|