@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,147 @@
1
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { getAccountToken, readCredentials } from "./login.js";
4
+ const API_URL = "https://api.mug.work";
5
+ function getWorkspaceName() {
6
+ const cwd = process.cwd();
7
+ const mugJsonPath = join(cwd, "mug.json");
8
+ if (!existsSync(mugJsonPath)) {
9
+ console.error("No mug.json found. Run `mug init` first.");
10
+ process.exit(1);
11
+ }
12
+ return JSON.parse(readFileSync(mugJsonPath, "utf-8")).name;
13
+ }
14
+ function loadSurfaceConfig(surfaceId) {
15
+ const cwd = process.cwd();
16
+ const filePath = join(cwd, "src", "surfaces", `${surfaceId}.json`);
17
+ if (!existsSync(filePath))
18
+ return null;
19
+ return JSON.parse(readFileSync(filePath, "utf-8"));
20
+ }
21
+ export async function demoEnable(surfaceId, opts) {
22
+ const workspace = getWorkspaceName();
23
+ const token = getAccountToken();
24
+ const identity = opts.as;
25
+ const expiresIn = opts.expires ?? "7d";
26
+ const notifyMode = opts.notify ?? "demo-user";
27
+ if (notifyMode !== "demo-user" && notifyMode !== "dev" && notifyMode !== "off") {
28
+ console.error(`Invalid --notify mode "${notifyMode}". Must be: demo-user, dev, or off`);
29
+ process.exit(1);
30
+ }
31
+ let devEmail;
32
+ if (notifyMode === "dev") {
33
+ const creds = readCredentials();
34
+ if (!creds?.email) {
35
+ console.error("Cannot use --notify dev: no account email found. Run `mug login` first.");
36
+ process.exit(1);
37
+ }
38
+ devEmail = creds.email;
39
+ }
40
+ const notifyOverrides = {};
41
+ if (opts.emailTo)
42
+ notifyOverrides.email = opts.emailTo;
43
+ if (opts.smsTo)
44
+ notifyOverrides.sms = opts.smsTo;
45
+ if (opts.slackTo)
46
+ notifyOverrides.slack = opts.slackTo;
47
+ if (surfaceId !== "_home") {
48
+ const config = loadSurfaceConfig(surfaceId);
49
+ if (!config) {
50
+ console.error(`Surface "${surfaceId}" not found in src/surfaces/. Available surfaces:`);
51
+ const surfacesDir = join(process.cwd(), "src", "surfaces");
52
+ if (existsSync(surfacesDir)) {
53
+ for (const f of readdirSync(surfacesDir).filter(f => f.endsWith(".json"))) {
54
+ if (f === "_home.json")
55
+ continue;
56
+ console.error(` ${f.replace(".json", "")}`);
57
+ }
58
+ }
59
+ console.error(` _home (workspace home screen)`);
60
+ process.exit(1);
61
+ }
62
+ const access = config.access;
63
+ if (!access || access.mode === "public") {
64
+ console.error(`Surface "${surfaceId}" is public — demo mode is not needed.`);
65
+ process.exit(1);
66
+ }
67
+ if (access.mode === "auth" && access.table && access.matchColumn) {
68
+ console.log(`Checking if ${identity} exists in ${access.table}.${access.matchColumn}...`);
69
+ }
70
+ }
71
+ const res = await fetch(`${API_URL}/demo-config`, {
72
+ method: "POST",
73
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
74
+ body: JSON.stringify({
75
+ workspace,
76
+ surfaceId,
77
+ identity,
78
+ expiresIn,
79
+ notifyMode,
80
+ notifyOverrides: Object.keys(notifyOverrides).length > 0 ? notifyOverrides : undefined,
81
+ devEmail,
82
+ workflows: opts.noWorkflows ? false : true,
83
+ }),
84
+ });
85
+ if (!res.ok) {
86
+ const err = await res.json().catch(() => ({ error: res.statusText }));
87
+ console.error(`Failed: ${err.error}`);
88
+ process.exit(1);
89
+ }
90
+ const data = await res.json();
91
+ const expires = new Date(data.demo.expiresAt);
92
+ console.log(`\nDemo enabled on ${surfaceId}`);
93
+ console.log(` Identity: ${identity}`);
94
+ console.log(` Expires: ${expires.toLocaleDateString()} ${expires.toLocaleTimeString()}`);
95
+ console.log(` Notifications: ${notifyMode}${Object.keys(notifyOverrides).length > 0 ? " + overrides" : ""}`);
96
+ if (notifyOverrides.email)
97
+ console.log(` email → ${notifyOverrides.email}`);
98
+ if (notifyOverrides.sms)
99
+ console.log(` sms → ${notifyOverrides.sms}`);
100
+ if (notifyOverrides.slack)
101
+ console.log(` slack → ${notifyOverrides.slack}`);
102
+ console.log(` Workflows: ${opts.noWorkflows ? "disabled" : "enabled"}`);
103
+ }
104
+ export async function demoDisable(surfaceId) {
105
+ const workspace = getWorkspaceName();
106
+ const token = getAccountToken();
107
+ const res = await fetch(`${API_URL}/demo-config`, {
108
+ method: "POST",
109
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
110
+ body: JSON.stringify({ workspace, surfaceId, action: "disable" }),
111
+ });
112
+ if (!res.ok) {
113
+ const err = await res.json().catch(() => ({ error: res.statusText }));
114
+ console.error(`Failed: ${err.error}`);
115
+ process.exit(1);
116
+ }
117
+ console.log(`Demo disabled on ${surfaceId}`);
118
+ }
119
+ export async function demoStatus() {
120
+ const workspace = getWorkspaceName();
121
+ const token = getAccountToken();
122
+ const res = await fetch(`${API_URL}/demo-config`, {
123
+ method: "POST",
124
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
125
+ body: JSON.stringify({ workspace, action: "status" }),
126
+ });
127
+ if (!res.ok) {
128
+ const err = await res.json().catch(() => ({ error: res.statusText }));
129
+ console.error(`Failed: ${err.error}`);
130
+ process.exit(1);
131
+ }
132
+ const data = await res.json();
133
+ if (data.demos.length === 0) {
134
+ console.log("No active demos.");
135
+ return;
136
+ }
137
+ console.log(`Active demos for ${workspace}:\n`);
138
+ for (const d of data.demos) {
139
+ const expires = new Date(d.expiresAt);
140
+ const remaining = expires.getTime() - Date.now();
141
+ const status = remaining > 0 ? `expires ${expires.toLocaleDateString()}` : "expired";
142
+ console.log(` ${d.surfaceId}`);
143
+ console.log(` Identity: ${d.identity}`);
144
+ console.log(` Status: ${status}`);
145
+ console.log();
146
+ }
147
+ }
@@ -0,0 +1 @@
1
+ export declare function deploy(): Promise<void>;