@agent-native/core 0.7.23 → 0.7.24
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/README.md +2 -2
- package/dist/a2a/client.d.ts +10 -4
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +16 -1
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/handlers.d.ts.map +1 -1
- package/dist/a2a/handlers.js +20 -17
- package/dist/a2a/handlers.js.map +1 -1
- package/dist/cli/create.d.ts +2 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +13 -19
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +23 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/workspace-dev.d.ts +3 -0
- package/dist/cli/workspace-dev.d.ts.map +1 -0
- package/dist/cli/workspace-dev.js +323 -0
- package/dist/cli/workspace-dev.js.map +1 -0
- package/dist/cli/workspacify.d.ts +3 -3
- package/dist/cli/workspacify.js +4 -4
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +10 -9
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +2 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +2 -1
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/components/ui/tooltip.d.ts +8 -0
- package/dist/client/components/ui/tooltip.d.ts.map +1 -0
- package/dist/client/components/ui/tooltip.js +11 -0
- package/dist/client/components/ui/tooltip.js.map +1 -0
- package/dist/client/resources/ResourceTree.d.ts.map +1 -1
- package/dist/client/resources/ResourceTree.js +21 -17
- package/dist/client/resources/ResourceTree.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +13 -11
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/deploy/workspace-core.d.ts +1 -1
- package/dist/deploy/workspace-core.d.ts.map +1 -1
- package/dist/deploy/workspace-core.js +14 -11
- package/dist/deploy/workspace-core.js.map +1 -1
- package/dist/integrations/a2a-continuation-processor.d.ts +10 -0
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -0
- package/dist/integrations/a2a-continuation-processor.js +150 -0
- package/dist/integrations/a2a-continuation-processor.js.map +1 -0
- package/dist/integrations/a2a-continuations-store.d.ts +41 -0
- package/dist/integrations/a2a-continuations-store.d.ts.map +1 -0
- package/dist/integrations/a2a-continuations-store.js +214 -0
- package/dist/integrations/a2a-continuations-store.js.map +1 -0
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +52 -0
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/types.d.ts +5 -0
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts +6 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +69 -15
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/org/handlers.d.ts.map +1 -1
- package/dist/org/handlers.js +22 -16
- package/dist/org/handlers.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +91 -30
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/server/agent-discovery.d.ts.map +1 -1
- package/dist/server/agent-discovery.js +17 -105
- package/dist/server/agent-discovery.js.map +1 -1
- package/dist/server/agents-bundle.js +1 -1
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +29 -120
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +1 -0
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +7 -5
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/framework-request-handler.js +1 -1
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/onboarding-html.d.ts +1 -8
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +321 -152
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/request-context.d.ts +14 -3
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +3 -0
- package/dist/server/request-context.js.map +1 -1
- package/dist/templates/default/_gitignore +2 -0
- package/dist/templates/workspace-core/AGENTS.md +18 -71
- package/dist/templates/workspace-core/package.json +2 -20
- package/dist/templates/workspace-core/src/client/index.ts +2 -26
- package/dist/templates/workspace-core/src/index.ts +1 -21
- package/dist/templates/workspace-core/src/server/index.ts +3 -22
- package/dist/templates/workspace-root/README.md +17 -20
- package/dist/templates/workspace-root/_gitignore +3 -0
- package/dist/templates/workspace-root/package.json +6 -13
- package/dist/templates/workspace-root/pnpm-workspace.yaml +4 -2
- package/dist/vite/agents-bundle-plugin.js +2 -2
- package/dist/vite/agents-bundle-plugin.js.map +1 -1
- package/docs/content/authentication.md +3 -5
- package/docs/content/multi-app-workspace.md +38 -50
- package/package.json +1 -1
- package/src/templates/default/_gitignore +2 -0
- package/src/templates/workspace-core/AGENTS.md +18 -71
- package/src/templates/workspace-core/package.json +2 -20
- package/src/templates/workspace-core/src/client/index.ts +2 -26
- package/src/templates/workspace-core/src/index.ts +1 -21
- package/src/templates/workspace-core/src/server/index.ts +3 -22
- package/src/templates/workspace-root/README.md +17 -20
- package/src/templates/workspace-root/_gitignore +3 -0
- package/src/templates/workspace-root/package.json +6 -13
- package/src/templates/workspace-root/pnpm-workspace.yaml +4 -2
- package/dist/templates/default/.claude/settings.json +0 -100
- package/dist/templates/workspace-core/.agents/skills/company-policies/SKILL.md +0 -42
- package/dist/templates/workspace-core/actions/company-directory.ts +0 -38
- package/dist/templates/workspace-core/src/client/AuthenticatedLayout.tsx +0 -37
- package/dist/templates/workspace-core/src/credentials.ts +0 -67
- package/dist/templates/workspace-core/src/server/agent-chat-plugin.ts +0 -30
- package/dist/templates/workspace-core/src/server/auth-plugin.ts +0 -35
- package/dist/templates/workspace-core/styles/tokens.css +0 -22
- package/dist/templates/workspace-root/.github/workflows/ci.yml +0 -32
- package/dist/templates/workspace-root/scripts/workspace-dev.ts +0 -377
- package/src/templates/default/.claude/settings.json +0 -100
- package/src/templates/workspace-core/.agents/skills/company-policies/SKILL.md +0 -42
- package/src/templates/workspace-core/actions/company-directory.ts +0 -38
- package/src/templates/workspace-core/src/client/AuthenticatedLayout.tsx +0 -37
- package/src/templates/workspace-core/src/credentials.ts +0 -67
- package/src/templates/workspace-core/src/server/agent-chat-plugin.ts +0 -30
- package/src/templates/workspace-core/src/server/auth-plugin.ts +0 -35
- package/src/templates/workspace-core/styles/tokens.css +0 -22
- package/src/templates/workspace-root/.github/workflows/ci.yml +0 -32
- package/src/templates/workspace-root/scripts/workspace-dev.ts +0 -377
|
@@ -2,22 +2,10 @@
|
|
|
2
2
|
* First-run onboarding page for agent-native apps.
|
|
3
3
|
*
|
|
4
4
|
* Shown when Better Auth is active and the user isn't signed in.
|
|
5
|
-
* Provides
|
|
6
|
-
* 1. Create account (email/password) — real identity from day one
|
|
7
|
-
* 2. Use locally — sets AUTH_MODE=local for offline/solo dev (dev only)
|
|
5
|
+
* Provides a path to create or sign into an account from day one.
|
|
8
6
|
*
|
|
9
7
|
* After first account exists, this page acts as a normal login page.
|
|
10
|
-
* The "Use locally" escape hatch is hidden in production to ensure
|
|
11
|
-
* real accounts are used (needed for per-user usage tracking/limits).
|
|
12
|
-
* It's also hidden when DATABASE_URL points at a non-local DB (Postgres,
|
|
13
|
-
* Turso, D1) — local@localhost has no per-user scoping, so enabling it
|
|
14
|
-
* against a shared DB would silently fail server-side.
|
|
15
8
|
*/
|
|
16
|
-
import { isLocalDatabase } from "../db/client.js";
|
|
17
|
-
function isProductionEnv() {
|
|
18
|
-
const env = process.env.NODE_ENV;
|
|
19
|
-
return env !== "development" && env !== "test";
|
|
20
|
-
}
|
|
21
9
|
function hasGoogleOAuth() {
|
|
22
10
|
return !!(process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET);
|
|
23
11
|
}
|
|
@@ -38,49 +26,9 @@ function getConnectionLabel() {
|
|
|
38
26
|
return "Turso";
|
|
39
27
|
return "SQL database";
|
|
40
28
|
}
|
|
41
|
-
const MIGRATE_FLAG_KEY = "an_migrate_from_local";
|
|
42
29
|
export function getOnboardingHtml(opts = {}) {
|
|
43
|
-
const showLocalMode = !isProductionEnv() && !opts.googleOnly && isLocalDatabase();
|
|
44
30
|
const showGoogle = hasGoogleOAuth();
|
|
45
31
|
const googleOnly = !!opts.googleOnly;
|
|
46
|
-
const localModeBlock = showLocalMode
|
|
47
|
-
? `
|
|
48
|
-
<div class="divider" id="local-divider">or</div>
|
|
49
|
-
|
|
50
|
-
<button class="btn-secondary" id="local-btn" onclick="useLocally()">Use locally without an account</button>
|
|
51
|
-
<p class="local-info" id="local-info">Skip auth for solo local development. You can create an account later.</p>`
|
|
52
|
-
: "";
|
|
53
|
-
const localModeScript = showLocalMode
|
|
54
|
-
? `
|
|
55
|
-
async function useLocally() {
|
|
56
|
-
var btn = document.getElementById('local-btn');
|
|
57
|
-
btn.disabled = true;
|
|
58
|
-
btn.textContent = 'Setting up...';
|
|
59
|
-
try {
|
|
60
|
-
try {
|
|
61
|
-
if (localStorage.getItem('${MIGRATE_FLAG_KEY}')) {
|
|
62
|
-
localStorage.removeItem('${MIGRATE_FLAG_KEY}');
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {}
|
|
65
|
-
var res = await fetch(__anPath('/_agent-native/auth/local-mode'), { method: 'POST' });
|
|
66
|
-
if (res.ok) {
|
|
67
|
-
window.location.reload();
|
|
68
|
-
} else {
|
|
69
|
-
var data = await res.json().catch(function() { return {}; });
|
|
70
|
-
var info = document.getElementById('local-info');
|
|
71
|
-
if (info && data && data.error) {
|
|
72
|
-
info.textContent = data.error;
|
|
73
|
-
info.style.color = '#f87171';
|
|
74
|
-
}
|
|
75
|
-
btn.textContent = 'Not available';
|
|
76
|
-
btn.disabled = true;
|
|
77
|
-
}
|
|
78
|
-
} catch(e) {
|
|
79
|
-
btn.textContent = 'Failed — try again';
|
|
80
|
-
btn.disabled = false;
|
|
81
|
-
}
|
|
82
|
-
}`
|
|
83
|
-
: "";
|
|
84
32
|
const marketing = opts.marketing;
|
|
85
33
|
const hasMarketing = !!marketing;
|
|
86
34
|
const esc = (s) => s
|
|
@@ -375,6 +323,13 @@ ${hasMarketing
|
|
|
375
323
|
.tab:hover:not(.active) { color: #bbb; }
|
|
376
324
|
.form { display: none; }
|
|
377
325
|
.form.active { display: block; }
|
|
326
|
+
.card.verifying .tabs,
|
|
327
|
+
.card.verifying #google-btn,
|
|
328
|
+
.card.verifying #google-err,
|
|
329
|
+
.card.verifying #auth-divider,
|
|
330
|
+
.card.verifying #upgrade-note {
|
|
331
|
+
display: none;
|
|
332
|
+
}
|
|
378
333
|
label { display: block; font-size: 0.8125rem; color: #888; margin-bottom: 0.375rem; }
|
|
379
334
|
input {
|
|
380
335
|
width: 100%;
|
|
@@ -419,6 +374,108 @@ ${hasMarketing
|
|
|
419
374
|
.msg.error { color: #f87171; }
|
|
420
375
|
.msg.success { color: #4ade80; }
|
|
421
376
|
.msg.show { display: block; }
|
|
377
|
+
.step-progress {
|
|
378
|
+
display: grid;
|
|
379
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
380
|
+
gap: 0.5rem;
|
|
381
|
+
margin-bottom: 1.25rem;
|
|
382
|
+
}
|
|
383
|
+
.progress-step {
|
|
384
|
+
position: relative;
|
|
385
|
+
display: flex;
|
|
386
|
+
flex-direction: column;
|
|
387
|
+
align-items: center;
|
|
388
|
+
gap: 0.375rem;
|
|
389
|
+
color: #666;
|
|
390
|
+
font-size: 0.6875rem;
|
|
391
|
+
line-height: 1.2;
|
|
392
|
+
text-align: center;
|
|
393
|
+
}
|
|
394
|
+
.progress-step::before {
|
|
395
|
+
content: '';
|
|
396
|
+
position: absolute;
|
|
397
|
+
top: 11px;
|
|
398
|
+
left: calc(-50% + 16px);
|
|
399
|
+
width: calc(100% - 32px);
|
|
400
|
+
height: 1px;
|
|
401
|
+
background: rgba(255,255,255,0.1);
|
|
402
|
+
}
|
|
403
|
+
.progress-step:first-child::before { display: none; }
|
|
404
|
+
.progress-step span {
|
|
405
|
+
display: inline-flex;
|
|
406
|
+
align-items: center;
|
|
407
|
+
justify-content: center;
|
|
408
|
+
width: 22px;
|
|
409
|
+
height: 22px;
|
|
410
|
+
border-radius: 999px;
|
|
411
|
+
border: 1px solid rgba(255,255,255,0.14);
|
|
412
|
+
background: #151515;
|
|
413
|
+
color: #777;
|
|
414
|
+
font-size: 0.6875rem;
|
|
415
|
+
font-weight: 600;
|
|
416
|
+
}
|
|
417
|
+
.progress-step strong { font-weight: 500; }
|
|
418
|
+
.progress-step.complete,
|
|
419
|
+
.progress-step.current { color: #e5e5e5; }
|
|
420
|
+
.progress-step.complete span {
|
|
421
|
+
background: #d9f99d;
|
|
422
|
+
border-color: #d9f99d;
|
|
423
|
+
color: #111;
|
|
424
|
+
}
|
|
425
|
+
.progress-step.current span {
|
|
426
|
+
background: #fff;
|
|
427
|
+
border-color: #fff;
|
|
428
|
+
color: #000;
|
|
429
|
+
box-shadow: 0 0 0 4px rgba(255,255,255,0.08);
|
|
430
|
+
}
|
|
431
|
+
.verification-panel {
|
|
432
|
+
padding: 1rem;
|
|
433
|
+
margin-bottom: 0.875rem;
|
|
434
|
+
background: rgba(255,255,255,0.04);
|
|
435
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
436
|
+
border-radius: 8px;
|
|
437
|
+
}
|
|
438
|
+
.verification-kicker {
|
|
439
|
+
margin-bottom: 0.5rem;
|
|
440
|
+
color: #bef264;
|
|
441
|
+
font-size: 0.75rem;
|
|
442
|
+
font-weight: 500;
|
|
443
|
+
}
|
|
444
|
+
.verification-copy {
|
|
445
|
+
color: #d4d4d8;
|
|
446
|
+
font-size: 0.875rem;
|
|
447
|
+
line-height: 1.55;
|
|
448
|
+
}
|
|
449
|
+
.verification-copy strong {
|
|
450
|
+
color: #fff;
|
|
451
|
+
font-weight: 600;
|
|
452
|
+
word-break: break-word;
|
|
453
|
+
}
|
|
454
|
+
.verification-note {
|
|
455
|
+
margin-top: 0.75rem;
|
|
456
|
+
color: #71717a;
|
|
457
|
+
font-size: 0.75rem;
|
|
458
|
+
line-height: 1.45;
|
|
459
|
+
}
|
|
460
|
+
.inline-actions {
|
|
461
|
+
display: flex;
|
|
462
|
+
align-items: center;
|
|
463
|
+
justify-content: space-between;
|
|
464
|
+
gap: 0.75rem;
|
|
465
|
+
margin-top: 0.75rem;
|
|
466
|
+
}
|
|
467
|
+
.link-button {
|
|
468
|
+
padding: 0.25rem 0;
|
|
469
|
+
background: none;
|
|
470
|
+
border: none;
|
|
471
|
+
color: #888;
|
|
472
|
+
cursor: pointer;
|
|
473
|
+
font-size: 0.75rem;
|
|
474
|
+
text-decoration: underline;
|
|
475
|
+
text-underline-offset: 2px;
|
|
476
|
+
}
|
|
477
|
+
.link-button:hover { color: #bbb; }
|
|
478
|
+
.link-button:disabled { cursor: wait; opacity: 0.5; }
|
|
422
479
|
.divider {
|
|
423
480
|
display: flex;
|
|
424
481
|
align-items: center;
|
|
@@ -433,12 +490,6 @@ ${hasMarketing
|
|
|
433
490
|
height: 1px;
|
|
434
491
|
background: rgba(255,255,255,0.08);
|
|
435
492
|
}
|
|
436
|
-
.local-info {
|
|
437
|
-
font-size: 0.75rem;
|
|
438
|
-
color: #666;
|
|
439
|
-
margin-top: 0.5rem;
|
|
440
|
-
line-height: 1.4;
|
|
441
|
-
}
|
|
442
493
|
.upgrade-note {
|
|
443
494
|
margin-bottom: 1rem;
|
|
444
495
|
padding: 0.75rem;
|
|
@@ -507,7 +558,7 @@ ${showGoogle
|
|
|
507
558
|
Sign in with Google
|
|
508
559
|
</button>
|
|
509
560
|
<p class="google-error" id="google-err"></p>
|
|
510
|
-
${googleOnly ? "" : `\n <div class="divider">or</div>\n`}
|
|
561
|
+
${googleOnly ? "" : `\n <div class="divider" id="auth-divider">or</div>\n`}
|
|
511
562
|
`
|
|
512
563
|
: googleOnly
|
|
513
564
|
? `
|
|
@@ -524,18 +575,37 @@ ${googleOnly
|
|
|
524
575
|
<button class="tab" data-tab="login">Sign in</button>
|
|
525
576
|
</div>
|
|
526
577
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
578
|
+
<form id="signup-form" class="form">
|
|
579
|
+
<label for="s-email">Email</label>
|
|
580
|
+
<input id="s-email" type="email" autocomplete="email" autofocus placeholder="you@example.com" required />
|
|
530
581
|
<label for="s-pass">Password</label>
|
|
531
582
|
<input id="s-pass" type="password" autocomplete="new-password" placeholder="At least 8 characters" required minlength="8" />
|
|
532
583
|
<label for="s-pass2">Confirm password</label>
|
|
533
584
|
<input id="s-pass2" type="password" autocomplete="new-password" placeholder="Confirm password" required minlength="8" />
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
585
|
+
<button type="submit">Create account</button>
|
|
586
|
+
<p class="msg" id="s-msg"></p>
|
|
587
|
+
</form>
|
|
588
|
+
|
|
589
|
+
<div id="verification-step" class="form verification-step" aria-live="polite">
|
|
590
|
+
<div class="step-progress" aria-label="Signup progress">
|
|
591
|
+
<div class="progress-step complete"><span>1</span><strong>Account</strong></div>
|
|
592
|
+
<div class="progress-step current"><span>2</span><strong>Verify</strong></div>
|
|
593
|
+
<div class="progress-step"><span>3</span><strong>Start</strong></div>
|
|
594
|
+
</div>
|
|
595
|
+
<div class="verification-panel">
|
|
596
|
+
<p class="verification-kicker">Verification email sent</p>
|
|
597
|
+
<p class="verification-copy">We sent a secure link to <strong id="verify-email"></strong>. When you click it, this app will finish signing you in automatically.</p>
|
|
598
|
+
<p class="verification-note">You can keep this tab open. After verifying, use Continue if the app has not refreshed yet.</p>
|
|
599
|
+
</div>
|
|
600
|
+
<button type="button" class="btn-primary" id="verify-continue">Continue</button>
|
|
601
|
+
<div class="inline-actions">
|
|
602
|
+
<button type="button" class="link-button" id="resend-verification">Resend email</button>
|
|
603
|
+
<button type="button" class="link-button" id="back-to-signup">Back</button>
|
|
604
|
+
</div>
|
|
605
|
+
<p class="msg" id="verify-msg"></p>
|
|
606
|
+
</div>
|
|
537
607
|
|
|
538
|
-
|
|
608
|
+
<form id="login-form" class="form">
|
|
539
609
|
<label for="l-email">Email</label>
|
|
540
610
|
<input id="l-email" type="email" autocomplete="email" placeholder="you@example.com" required />
|
|
541
611
|
<label for="l-pass">Password</label>
|
|
@@ -556,7 +626,6 @@ ${googleOnly
|
|
|
556
626
|
<a href="#" id="back-to-login" style="color:#888;text-decoration:underline;text-underline-offset:2px">Back to sign in</a>
|
|
557
627
|
</p>
|
|
558
628
|
</form>`}
|
|
559
|
-
${localModeBlock}
|
|
560
629
|
</div>
|
|
561
630
|
<p class="local-note" id="local-note">
|
|
562
631
|
Your account is stored in this app's own DB (<strong>${getConnectionLabel()}</strong>), not a third-party service.
|
|
@@ -567,10 +636,17 @@ ${localModeBlock}
|
|
|
567
636
|
var idx = window.location.pathname.indexOf(marker);
|
|
568
637
|
return idx > 0 ? window.location.pathname.slice(0, idx) : '';
|
|
569
638
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
639
|
+
function __anPath(path) {
|
|
640
|
+
return __anBasePath() + path;
|
|
641
|
+
}
|
|
642
|
+
function __anGetReturnPath() {
|
|
643
|
+
try {
|
|
644
|
+
var inner = new URLSearchParams(window.location.search).get('return');
|
|
645
|
+
if (inner) return inner;
|
|
646
|
+
} catch(e) {}
|
|
647
|
+
return window.location.pathname + window.location.search;
|
|
648
|
+
}
|
|
649
|
+
(function revealLocalNote() {
|
|
574
650
|
var h = location.hostname;
|
|
575
651
|
if (h === 'localhost' || h === '127.0.0.1' || h === '::1' || h.endsWith('.local')) {
|
|
576
652
|
var n = document.getElementById('local-note');
|
|
@@ -580,16 +656,19 @@ ${localModeBlock}
|
|
|
580
656
|
${googleOnly
|
|
581
657
|
? ""
|
|
582
658
|
: ` var TAB_STORAGE_KEY = 'an.onboarding.tab';
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
659
|
+
var tabs = document.querySelectorAll('.tab');
|
|
660
|
+
var forms = document.querySelectorAll('.form');
|
|
661
|
+
var subtitles = { signup: 'Create an account to get started', login: 'Sign in to your account' };
|
|
662
|
+
var headings = { signup: 'Welcome', login: 'Welcome back' };
|
|
663
|
+
var pendingSignupEmail = '';
|
|
664
|
+
function setActiveTab(name, opts) {
|
|
665
|
+
if (name !== 'signup' && name !== 'login') return;
|
|
666
|
+
var form = document.getElementById(name + '-form');
|
|
667
|
+
if (!form) return;
|
|
668
|
+
var card = document.querySelector('.card');
|
|
669
|
+
if (card) card.classList.remove('verifying');
|
|
670
|
+
tabs.forEach(function(x) { x.classList.remove('active'); });
|
|
671
|
+
forms.forEach(function(x) { x.classList.remove('active'); });
|
|
593
672
|
var btn = document.querySelector('.tab[data-tab="' + name + '"]');
|
|
594
673
|
if (btn) btn.classList.add('active');
|
|
595
674
|
form.classList.add('active');
|
|
@@ -597,11 +676,119 @@ ${googleOnly
|
|
|
597
676
|
if (sub && subtitles[name]) sub.textContent = subtitles[name];
|
|
598
677
|
var heading = document.getElementById('heading');
|
|
599
678
|
if (heading && headings[name]) heading.textContent = headings[name];
|
|
600
|
-
|
|
601
|
-
|
|
679
|
+
if (opts && opts.persist) {
|
|
680
|
+
try { localStorage.setItem(TAB_STORAGE_KEY, name); } catch (e) {}
|
|
681
|
+
}
|
|
602
682
|
}
|
|
603
|
-
|
|
604
|
-
|
|
683
|
+
function showVerificationStep(email) {
|
|
684
|
+
pendingSignupEmail = email || '';
|
|
685
|
+
tabs.forEach(function(x) { x.classList.remove('active'); });
|
|
686
|
+
forms.forEach(function(x) { x.classList.remove('active'); });
|
|
687
|
+
var card = document.querySelector('.card');
|
|
688
|
+
if (card) card.classList.add('verifying');
|
|
689
|
+
var step = document.getElementById('verification-step');
|
|
690
|
+
if (step) step.classList.add('active');
|
|
691
|
+
var emailNode = document.getElementById('verify-email');
|
|
692
|
+
if (emailNode) emailNode.textContent = pendingSignupEmail;
|
|
693
|
+
var heading = document.getElementById('heading');
|
|
694
|
+
if (heading) heading.textContent = 'Check your email';
|
|
695
|
+
var sub = document.getElementById('subtitle');
|
|
696
|
+
if (sub) sub.textContent = 'Finish creating your account';
|
|
697
|
+
var msg = document.getElementById('verify-msg');
|
|
698
|
+
if (msg) {
|
|
699
|
+
msg.classList.remove('show', 'error', 'success');
|
|
700
|
+
msg.textContent = '';
|
|
701
|
+
}
|
|
702
|
+
try { localStorage.setItem(TAB_STORAGE_KEY, 'signup'); } catch (e) {}
|
|
703
|
+
}
|
|
704
|
+
function getVerificationMessageNode() {
|
|
705
|
+
var verifyStep = document.getElementById('verification-step');
|
|
706
|
+
if (verifyStep && verifyStep.classList.contains('active')) {
|
|
707
|
+
return document.getElementById('verify-msg');
|
|
708
|
+
}
|
|
709
|
+
return document.getElementById('l-msg') || document.getElementById('verify-msg');
|
|
710
|
+
}
|
|
711
|
+
async function checkVerificationSession(fallbackText) {
|
|
712
|
+
var msg = getVerificationMessageNode();
|
|
713
|
+
if (msg) {
|
|
714
|
+
msg.textContent = 'Checking your verification...';
|
|
715
|
+
msg.classList.remove('error');
|
|
716
|
+
msg.classList.add('show', 'success');
|
|
717
|
+
}
|
|
718
|
+
try {
|
|
719
|
+
var res = await fetch(__anPath('/_agent-native/auth/session'), {
|
|
720
|
+
headers: { 'Accept': 'application/json' },
|
|
721
|
+
});
|
|
722
|
+
var data = await res.json().catch(function() { return {}; });
|
|
723
|
+
if (res.ok && data && data.email && !data.error) {
|
|
724
|
+
window.location.reload();
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (msg) {
|
|
728
|
+
msg.textContent = fallbackText || 'Still waiting on verification. Click the link in your email, then try Continue again.';
|
|
729
|
+
msg.classList.remove('success');
|
|
730
|
+
msg.classList.add('show', 'error');
|
|
731
|
+
}
|
|
732
|
+
} catch (err) {
|
|
733
|
+
if (msg) {
|
|
734
|
+
msg.textContent = 'Could not check verification. Please try again.';
|
|
735
|
+
msg.classList.remove('success');
|
|
736
|
+
msg.classList.add('show', 'error');
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
async function resendVerificationEmail() {
|
|
741
|
+
var btn = document.getElementById('resend-verification');
|
|
742
|
+
var msg = document.getElementById('verify-msg');
|
|
743
|
+
var email = pendingSignupEmail || document.getElementById('s-email').value;
|
|
744
|
+
if (!email) return;
|
|
745
|
+
var original = btn ? btn.textContent : '';
|
|
746
|
+
if (btn) {
|
|
747
|
+
btn.disabled = true;
|
|
748
|
+
btn.textContent = 'Sending...';
|
|
749
|
+
}
|
|
750
|
+
if (msg) msg.classList.remove('show', 'error', 'success');
|
|
751
|
+
try {
|
|
752
|
+
var res = await fetch(__anPath('/_agent-native/auth/ba/send-verification-email'), {
|
|
753
|
+
method: 'POST',
|
|
754
|
+
headers: { 'Content-Type': 'application/json' },
|
|
755
|
+
body: JSON.stringify({ email: email, callbackURL: __anGetReturnPath() }),
|
|
756
|
+
});
|
|
757
|
+
if (res.ok) {
|
|
758
|
+
if (msg) {
|
|
759
|
+
msg.textContent = 'Sent a fresh verification link.';
|
|
760
|
+
msg.classList.add('show', 'success');
|
|
761
|
+
}
|
|
762
|
+
if (btn) btn.textContent = 'Sent';
|
|
763
|
+
setTimeout(function() {
|
|
764
|
+
if (btn) {
|
|
765
|
+
btn.disabled = false;
|
|
766
|
+
btn.textContent = original;
|
|
767
|
+
}
|
|
768
|
+
}, 1600);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
var data = await res.json().catch(function() { return {}; });
|
|
772
|
+
if (msg) {
|
|
773
|
+
msg.textContent = (data && (data.message || data.error)) || 'Could not resend the verification email.';
|
|
774
|
+
msg.classList.add('show', 'error');
|
|
775
|
+
}
|
|
776
|
+
if (btn) {
|
|
777
|
+
btn.disabled = false;
|
|
778
|
+
btn.textContent = original;
|
|
779
|
+
}
|
|
780
|
+
} catch (err) {
|
|
781
|
+
if (msg) {
|
|
782
|
+
msg.textContent = 'Network error. Please try again.';
|
|
783
|
+
msg.classList.add('show', 'error');
|
|
784
|
+
}
|
|
785
|
+
if (btn) {
|
|
786
|
+
btn.disabled = false;
|
|
787
|
+
btn.textContent = original;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
(function initActiveTab() {
|
|
605
792
|
var initial = 'signup';
|
|
606
793
|
try {
|
|
607
794
|
var params = new URLSearchParams(location.search);
|
|
@@ -616,17 +803,18 @@ ${googleOnly
|
|
|
616
803
|
}
|
|
617
804
|
} catch (e) {}
|
|
618
805
|
setActiveTab(initial, { persist: false });
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
806
|
+
try {
|
|
807
|
+
if (new URLSearchParams(location.search).has('verified')) {
|
|
808
|
+
var msg = document.getElementById('l-msg');
|
|
809
|
+
if (msg) {
|
|
810
|
+
msg.textContent = 'Email verified. Finishing sign-in...';
|
|
811
|
+
msg.classList.remove('error');
|
|
812
|
+
msg.classList.add('show', 'success');
|
|
813
|
+
}
|
|
814
|
+
checkVerificationSession('Email verified. Sign in to continue.');
|
|
626
815
|
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
})();
|
|
816
|
+
} catch (e) {}
|
|
817
|
+
})();
|
|
630
818
|
tabs.forEach(function(t) { t.addEventListener('click', function() {
|
|
631
819
|
setActiveTab(t.dataset.tab, { persist: true });
|
|
632
820
|
}); });
|
|
@@ -652,8 +840,12 @@ ${googleOnly
|
|
|
652
840
|
var res = await fetch(__anPath('/_agent-native/auth/register'), {
|
|
653
841
|
method: 'POST',
|
|
654
842
|
headers: { 'Content-Type': 'application/json' },
|
|
655
|
-
|
|
656
|
-
|
|
843
|
+
body: JSON.stringify({
|
|
844
|
+
email: email,
|
|
845
|
+
password: pass,
|
|
846
|
+
callbackURL: __anGetReturnPath(),
|
|
847
|
+
}),
|
|
848
|
+
});
|
|
657
849
|
var data = await res.json().catch(function() { return {}; });
|
|
658
850
|
if (res.ok) {
|
|
659
851
|
// If email verification is required, the server won't return a session.
|
|
@@ -669,20 +861,11 @@ ${googleOnly
|
|
|
669
861
|
window.location.reload();
|
|
670
862
|
return;
|
|
671
863
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
btn.textContent = originalLabel;
|
|
677
|
-
setActiveTab('login', { persist: true });
|
|
678
|
-
var loginMsg = document.getElementById('l-msg');
|
|
679
|
-
if (loginMsg) {
|
|
680
|
-
loginMsg.textContent = 'Account created! Check your email to verify, then sign in.';
|
|
681
|
-
loginMsg.classList.remove('error');
|
|
682
|
-
loginMsg.classList.add('show', 'success');
|
|
864
|
+
btn.disabled = false;
|
|
865
|
+
btn.textContent = originalLabel;
|
|
866
|
+
showVerificationStep(email);
|
|
867
|
+
return;
|
|
683
868
|
}
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
869
|
msg.textContent = data.error || 'Registration failed';
|
|
687
870
|
msg.classList.add('show', 'error');
|
|
688
871
|
btn.disabled = false;
|
|
@@ -693,9 +876,27 @@ ${googleOnly
|
|
|
693
876
|
btn.disabled = false;
|
|
694
877
|
btn.textContent = originalLabel;
|
|
695
878
|
}
|
|
696
|
-
|
|
879
|
+
});
|
|
880
|
+
|
|
881
|
+
var verifyContinue = document.getElementById('verify-continue');
|
|
882
|
+
if (verifyContinue) verifyContinue.addEventListener('click', function(e) {
|
|
883
|
+
e.preventDefault();
|
|
884
|
+
checkVerificationSession();
|
|
885
|
+
});
|
|
886
|
+
var resendBtn = document.getElementById('resend-verification');
|
|
887
|
+
if (resendBtn) resendBtn.addEventListener('click', function(e) {
|
|
888
|
+
e.preventDefault();
|
|
889
|
+
resendVerificationEmail();
|
|
890
|
+
});
|
|
891
|
+
var backToSignup = document.getElementById('back-to-signup');
|
|
892
|
+
if (backToSignup) backToSignup.addEventListener('click', function(e) {
|
|
893
|
+
e.preventDefault();
|
|
894
|
+
setActiveTab('signup', { persist: true });
|
|
895
|
+
var email = document.getElementById('s-email');
|
|
896
|
+
setTimeout(function() { if (email) email.focus(); }, 0);
|
|
897
|
+
});
|
|
697
898
|
|
|
698
|
-
|
|
899
|
+
var forgotLink = document.getElementById('forgot-link');
|
|
699
900
|
var backToLogin = document.getElementById('back-to-login');
|
|
700
901
|
if (forgotLink) forgotLink.addEventListener('click', function(e) {
|
|
701
902
|
e.preventDefault();
|
|
@@ -755,12 +956,13 @@ ${googleOnly
|
|
|
755
956
|
}
|
|
756
957
|
});
|
|
757
958
|
|
|
758
|
-
|
|
959
|
+
document.getElementById('login-form').addEventListener('submit', async function(e) {
|
|
759
960
|
e.preventDefault();
|
|
760
961
|
var form = e.currentTarget;
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
962
|
+
var btn = form.querySelector('button[type="submit"]');
|
|
963
|
+
var msg = document.getElementById('l-msg');
|
|
964
|
+
msg.classList.remove('show', 'success');
|
|
965
|
+
msg.classList.add('error');
|
|
764
966
|
var originalLabel = btn.textContent;
|
|
765
967
|
btn.disabled = true;
|
|
766
968
|
btn.textContent = 'Signing in…';
|
|
@@ -789,43 +991,10 @@ ${googleOnly
|
|
|
789
991
|
btn.textContent = originalLabel;
|
|
790
992
|
}
|
|
791
993
|
});
|
|
792
|
-
`}
|
|
793
|
-
${showLocalMode
|
|
794
|
-
? `
|
|
795
|
-
(function syncUpgradeFromLocalUi() {
|
|
796
|
-
var subtitle = document.querySelector('.subtitle');
|
|
797
|
-
var note = document.getElementById('upgrade-note');
|
|
798
|
-
var localBtn = document.getElementById('local-btn');
|
|
799
|
-
var localInfo = document.getElementById('local-info');
|
|
800
|
-
var divider = document.getElementById('local-divider');
|
|
801
|
-
if (!subtitle || !note || !localBtn || !localInfo || !divider) return;
|
|
802
|
-
try {
|
|
803
|
-
if (!localStorage.getItem('${MIGRATE_FLAG_KEY}')) return;
|
|
804
|
-
} catch (e) {
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
subtitle.textContent = 'Sign in to upgrade your local workspace';
|
|
808
|
-
note.classList.add('show');
|
|
809
|
-
localBtn.textContent = 'Stay in local mode';
|
|
810
|
-
localInfo.textContent = 'Use this if you want to cancel the upgrade and go back to local@localhost on this device.';
|
|
811
|
-
divider.textContent = 'or stay local';
|
|
812
|
-
})();
|
|
813
|
-
`
|
|
814
|
-
: ""}
|
|
994
|
+
`}
|
|
815
995
|
${showGoogle
|
|
816
996
|
? `
|
|
817
|
-
|
|
818
|
-
// If we landed here via /_agent-native/sign-in?return=X (force-sign-in
|
|
819
|
-
// entrypoint from a public page), prefer the inner return URL.
|
|
820
|
-
// Otherwise the loginHtml is being served at the URL the user actually
|
|
821
|
-
// wanted to reach (a bookmarked / deep-linked private path), so use it.
|
|
822
|
-
try {
|
|
823
|
-
var inner = new URLSearchParams(window.location.search).get('return');
|
|
824
|
-
if (inner) return inner;
|
|
825
|
-
} catch(e) {}
|
|
826
|
-
return window.location.pathname + window.location.search;
|
|
827
|
-
}
|
|
828
|
-
async function signInWithGoogle() {
|
|
997
|
+
async function signInWithGoogle() {
|
|
829
998
|
var btn = document.getElementById('google-btn');
|
|
830
999
|
var err = document.getElementById('google-err');
|
|
831
1000
|
btn.disabled = true;
|