@mugwork/mug 0.1.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.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +251 -0
  3. package/dist/explorer.js +3 -0
  4. package/dist/packages/email-template/src/email-template.d.ts +18 -0
  5. package/dist/packages/email-template/src/email-template.js +74 -0
  6. package/dist/packages/email-template/src/index.d.ts +1 -0
  7. package/dist/packages/email-template/src/index.js +1 -0
  8. package/dist/packages/surface-renderer/src/form-renderer.d.ts +117 -0
  9. package/dist/packages/surface-renderer/src/form-renderer.js +719 -0
  10. package/dist/packages/surface-renderer/src/index.d.ts +4 -0
  11. package/dist/packages/surface-renderer/src/index.js +2 -0
  12. package/dist/packages/surface-renderer/src/portal-renderer.d.ts +177 -0
  13. package/dist/packages/surface-renderer/src/portal-renderer.js +1089 -0
  14. package/dist/packages/surface-renderer/src/workspace-home.d.ts +46 -0
  15. package/dist/packages/surface-renderer/src/workspace-home.js +345 -0
  16. package/dist/runtime/agent-types.d.ts +48 -0
  17. package/dist/runtime/agent-types.js +3 -0
  18. package/dist/runtime/ai-router.d.ts +32 -0
  19. package/dist/runtime/ai-router.js +112 -0
  20. package/dist/runtime/app.d.ts +6 -0
  21. package/dist/runtime/app.js +399 -0
  22. package/dist/runtime/chunker.d.ts +6 -0
  23. package/dist/runtime/chunker.js +30 -0
  24. package/dist/runtime/context.d.ts +115 -0
  25. package/dist/runtime/context.js +440 -0
  26. package/dist/runtime/do/workspace-database.d.ts +10 -0
  27. package/dist/runtime/do/workspace-database.js +199 -0
  28. package/dist/runtime/form-types.d.ts +143 -0
  29. package/dist/runtime/form-types.js +1 -0
  30. package/dist/runtime/runtime.d.ts +9 -0
  31. package/dist/runtime/runtime.js +7 -0
  32. package/dist/runtime/source-types.d.ts +15 -0
  33. package/dist/runtime/source-types.js +1 -0
  34. package/dist/runtime/source.d.ts +70 -0
  35. package/dist/runtime/source.js +21 -0
  36. package/dist/runtime/sync-runtime.d.ts +10 -0
  37. package/dist/runtime/sync-runtime.js +185 -0
  38. package/dist/runtime/types.d.ts +21 -0
  39. package/dist/runtime/types.js +1 -0
  40. package/dist/runtime/workflow-entrypoint.d.ts +31 -0
  41. package/dist/runtime/workflow-entrypoint.js +1297 -0
  42. package/dist/runtime/workflow.d.ts +285 -0
  43. package/dist/runtime/workflow.js +1008 -0
  44. package/dist/src/cli.d.ts +2 -0
  45. package/dist/src/cli.js +44116 -0
  46. package/dist/src/commands/ai-gateway-route.d.ts +24 -0
  47. package/dist/src/commands/ai-gateway-route.js +192 -0
  48. package/dist/src/commands/auth.d.ts +1 -0
  49. package/dist/src/commands/auth.js +42 -0
  50. package/dist/src/commands/billing.d.ts +6 -0
  51. package/dist/src/commands/billing.js +76 -0
  52. package/dist/src/commands/brain.d.ts +1 -0
  53. package/dist/src/commands/brain.js +194 -0
  54. package/dist/src/commands/demo.d.ts +12 -0
  55. package/dist/src/commands/demo.js +147 -0
  56. package/dist/src/commands/deploy.d.ts +1 -0
  57. package/dist/src/commands/deploy.js +1052 -0
  58. package/dist/src/commands/dev.d.ts +14 -0
  59. package/dist/src/commands/dev.js +2818 -0
  60. package/dist/src/commands/form.d.ts +8 -0
  61. package/dist/src/commands/form.js +396 -0
  62. package/dist/src/commands/init.d.ts +1 -0
  63. package/dist/src/commands/init.js +139 -0
  64. package/dist/src/commands/issue.d.ts +7 -0
  65. package/dist/src/commands/issue.js +191 -0
  66. package/dist/src/commands/login.d.ts +9 -0
  67. package/dist/src/commands/login.js +163 -0
  68. package/dist/src/commands/logs.d.ts +8 -0
  69. package/dist/src/commands/logs.js +113 -0
  70. package/dist/src/commands/portal.d.ts +2 -0
  71. package/dist/src/commands/portal.js +111 -0
  72. package/dist/src/commands/pull.d.ts +3 -0
  73. package/dist/src/commands/pull.js +184 -0
  74. package/dist/src/commands/push.d.ts +4 -0
  75. package/dist/src/commands/push.js +183 -0
  76. package/dist/src/commands/run.d.ts +6 -0
  77. package/dist/src/commands/run.js +91 -0
  78. package/dist/src/commands/secret.d.ts +7 -0
  79. package/dist/src/commands/secret.js +105 -0
  80. package/dist/src/commands/shutdown.d.ts +1 -0
  81. package/dist/src/commands/shutdown.js +46 -0
  82. package/dist/src/commands/sql.d.ts +8 -0
  83. package/dist/src/commands/sql.js +142 -0
  84. package/dist/src/commands/status.d.ts +5 -0
  85. package/dist/src/commands/status.js +39 -0
  86. package/dist/src/commands/sync.d.ts +7 -0
  87. package/dist/src/commands/sync.js +991 -0
  88. package/dist/src/commands/usage.d.ts +6 -0
  89. package/dist/src/commands/usage.js +78 -0
  90. package/dist/src/commands/webhooks.d.ts +1 -0
  91. package/dist/src/commands/webhooks.js +102 -0
  92. package/dist/src/commands/workspace.d.ts +23 -0
  93. package/dist/src/commands/workspace.js +590 -0
  94. package/dist/src/connector-migration.d.ts +20 -0
  95. package/dist/src/connector-migration.js +43 -0
  96. package/dist/src/connector-parser.d.ts +14 -0
  97. package/dist/src/connector-parser.js +94 -0
  98. package/dist/src/connector-service/discover.d.ts +37 -0
  99. package/dist/src/connector-service/discover.js +79 -0
  100. package/dist/src/connector-service/gather.d.ts +22 -0
  101. package/dist/src/connector-service/gather.js +89 -0
  102. package/dist/src/connector-service/init.d.ts +14 -0
  103. package/dist/src/connector-service/init.js +109 -0
  104. package/dist/src/connector-service/scaffold.d.ts +17 -0
  105. package/dist/src/connector-service/scaffold.js +194 -0
  106. package/dist/src/connector-service/spec-storage.d.ts +8 -0
  107. package/dist/src/connector-service/spec-storage.js +48 -0
  108. package/dist/src/connector-service/types.d.ts +57 -0
  109. package/dist/src/connector-service/types.js +2 -0
  110. package/dist/src/connector-service/verify.d.ts +24 -0
  111. package/dist/src/connector-service/verify.js +575 -0
  112. package/dist/src/email-template.d.ts +2 -0
  113. package/dist/src/email-template.js +1 -0
  114. package/dist/src/manifest.d.ts +31 -0
  115. package/dist/src/manifest.js +25 -0
  116. package/dist/src/mug-icon.d.ts +1 -0
  117. package/dist/src/mug-icon.js +12 -0
  118. package/dist/src/slack-manifest.d.ts +119 -0
  119. package/dist/src/slack-manifest.js +163 -0
  120. package/dist/src/source-migration.d.ts +20 -0
  121. package/dist/src/source-migration.js +43 -0
  122. package/dist/src/surface-renderer.d.ts +5 -0
  123. package/dist/src/surface-renderer.js +3 -0
  124. package/dist/src/templates.d.ts +3 -0
  125. package/dist/src/templates.js +48 -0
  126. package/dist/src/version-check.d.ts +1 -0
  127. package/dist/src/version-check.js +28 -0
  128. package/dist/src/workflow-parser.d.ts +95 -0
  129. package/dist/src/workflow-parser.js +526 -0
  130. package/dist/worker/src/agent-types.d.ts +27 -0
  131. package/dist/worker/src/agent-types.js +3 -0
  132. package/dist/worker/src/source-types.d.ts +14 -0
  133. package/dist/worker/src/source-types.js +1 -0
  134. package/package.json +90 -0
  135. package/src/data/model-capabilities.json +171 -0
@@ -0,0 +1,74 @@
1
+ export function markdownToHtml(text) {
2
+ return text
3
+ .replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
4
+ .replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
5
+ .replace(/\*(.+?)\*/g, "<em>$1</em>")
6
+ .replace(/^### (.+)$/gm, "<h3>$1</h3>")
7
+ .replace(/^## (.+)$/gm, "<h2>$1</h2>")
8
+ .replace(/^# (.+)$/gm, "<h1>$1</h1>")
9
+ .replace(/^- (.+)$/gm, "<li>$1</li>")
10
+ .replace(/(<li>.*<\/li>\n?)+/g, (m) => `<ul>${m}</ul>`)
11
+ .replace(/\n\n/g, "</p><p>")
12
+ .replace(/\n/g, "<br>")
13
+ .replace(/^/, "<p>").replace(/$/, "</p>")
14
+ .replace(/<p><(h[123]|ul)>/g, "<$1>")
15
+ .replace(/<\/(h[123]|ul)><\/p>/g, "</$1>");
16
+ }
17
+ export function renderEmailHtml(options) {
18
+ const { subject, bodyHtml, cta, fromName, branding } = options;
19
+ const accent = branding?.accentColor ?? "#111827";
20
+ const displayName = fromName ?? "Mug";
21
+ const logoHtml = branding?.logo
22
+ ? `<img src="${escapeAttr(branding.logo)}" alt="${escapeHtml(displayName)}" style="max-height:40px;max-width:200px;margin-bottom:8px;" />`
23
+ : `<span style="font-size:18px;font-weight:700;color:${accent};">${escapeHtml(displayName)}</span>`;
24
+ const ctaHtml = cta
25
+ ? `<table role="presentation" cellpadding="0" cellspacing="0" style="margin:24px auto 0;">
26
+ <tr>
27
+ <td style="background:${accent};border-radius:6px;">
28
+ <a href="${escapeAttr(cta.url)}" target="_blank" style="display:inline-block;padding:12px 28px;color:#ffffff;font-size:15px;font-weight:600;text-decoration:none;border-radius:6px;">${escapeHtml(cta.label)}</a>
29
+ </td>
30
+ </tr>
31
+ </table>`
32
+ : "";
33
+ const footerText = branding?.logo ? displayName : "Powered by Mug";
34
+ return `<!DOCTYPE html>
35
+ <html lang="en">
36
+ <head>
37
+ <meta charset="utf-8">
38
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
39
+ <title>${escapeHtml(subject)}</title>
40
+ </head>
41
+ <body style="margin:0;padding:0;background:#f4f4f5;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;">
42
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:32px 16px;">
43
+ <tr>
44
+ <td align="center">
45
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="max-width:560px;background:#ffffff;border-radius:8px;overflow:hidden;">
46
+ <tr>
47
+ <td style="padding:28px 32px 16px;text-align:center;border-bottom:1px solid #f0f0f0;">
48
+ ${logoHtml}
49
+ </td>
50
+ </tr>
51
+ <tr>
52
+ <td style="padding:28px 32px;font-size:15px;line-height:1.6;color:#1f2937;">
53
+ ${bodyHtml}
54
+ ${ctaHtml}
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <td style="padding:16px 32px 24px;text-align:center;font-size:12px;color:#9ca3af;border-top:1px solid #f0f0f0;">
59
+ ${escapeHtml(footerText)}
60
+ </td>
61
+ </tr>
62
+ </table>
63
+ </td>
64
+ </tr>
65
+ </table>
66
+ </body>
67
+ </html>`;
68
+ }
69
+ function escapeHtml(s) {
70
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
71
+ }
72
+ function escapeAttr(s) {
73
+ return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
74
+ }
@@ -0,0 +1 @@
1
+ export { renderEmailHtml, markdownToHtml } from "./email-template.js";
@@ -0,0 +1 @@
1
+ export { renderEmailHtml, markdownToHtml } from "./email-template.js";
@@ -0,0 +1,117 @@
1
+ export interface BrandingConfig {
2
+ logo?: string;
3
+ logoSquare?: string;
4
+ accentColor?: string;
5
+ ogImage?: string;
6
+ }
7
+ export interface Breadcrumb {
8
+ label: string;
9
+ href: string;
10
+ }
11
+ export interface Condition {
12
+ field: string;
13
+ op: "eq" | "neq" | "in" | "gt" | "lt" | "filled" | "empty";
14
+ value?: string | number | string[];
15
+ }
16
+ interface ValidationRule {
17
+ rule: "min" | "max" | "minLength" | "maxLength" | "pattern";
18
+ value: number | string;
19
+ message: string;
20
+ }
21
+ interface FormField {
22
+ name: string;
23
+ type: string;
24
+ label: string;
25
+ required?: boolean;
26
+ placeholder?: string;
27
+ showWhen?: Condition[];
28
+ options?: {
29
+ label: string;
30
+ value: string;
31
+ }[];
32
+ min?: number | string;
33
+ max?: number | string;
34
+ step?: number;
35
+ rows?: number;
36
+ maxLength?: number;
37
+ pattern?: string;
38
+ accept?: string;
39
+ maxSizeMb?: number;
40
+ expression?: string;
41
+ format?: "number" | "currency" | "percent";
42
+ default?: string | number | boolean;
43
+ prefill?: {
44
+ source: string;
45
+ column?: string;
46
+ param?: string;
47
+ table?: string;
48
+ match?: {
49
+ column: string;
50
+ field?: string;
51
+ param?: string;
52
+ };
53
+ };
54
+ locked?: boolean;
55
+ helpText?: string;
56
+ validate?: ValidationRule[];
57
+ }
58
+ interface PageBranch {
59
+ when: Condition[];
60
+ goto: string;
61
+ }
62
+ interface FormPage {
63
+ id: string;
64
+ title?: string;
65
+ description?: string;
66
+ fields: FormField[];
67
+ showWhen?: Condition[];
68
+ nextPage?: string | {
69
+ conditions: PageBranch[];
70
+ default: string;
71
+ };
72
+ }
73
+ export interface FormAccess {
74
+ mode: "public" | "identify" | "auth";
75
+ method?: "email" | "phone";
76
+ sessionDuration?: string;
77
+ table?: string;
78
+ matchColumn?: string;
79
+ query?: string;
80
+ }
81
+ interface SurfaceConfig {
82
+ workspace: string;
83
+ surfaceId: string;
84
+ title: string;
85
+ description?: string;
86
+ submitText?: string;
87
+ pages: FormPage[];
88
+ access: FormAccess;
89
+ workflow: string;
90
+ branding?: BrandingConfig;
91
+ }
92
+ export interface SessionData {
93
+ email?: string;
94
+ phone?: string;
95
+ verifiedAt: string;
96
+ authRow?: Record<string, unknown>;
97
+ isDemo?: boolean;
98
+ }
99
+ export declare function renderPwaTags(opts: {
100
+ surfaceId: string;
101
+ accentColor?: string;
102
+ }): string;
103
+ export declare function renderInstallBanner(opts: {
104
+ surfaceId: string;
105
+ title: string;
106
+ accentColor?: string;
107
+ }): string;
108
+ export declare function renderMetaTags(opts: {
109
+ title: string;
110
+ description?: string;
111
+ ogImageUrl: string;
112
+ canonicalUrl?: string;
113
+ siteName?: string;
114
+ }): string;
115
+ export declare function renderForm(config: SurfaceConfig, session: SessionData | null, editRecord?: Record<string, unknown> | null, basePath?: string, prefillValues?: Record<string, unknown>, breadcrumb?: Breadcrumb, embed?: boolean): string;
116
+ export declare function esc(s: string): string;
117
+ export {};