@chrysb/alphaclaw 0.3.5-beta.1 → 0.4.1-beta.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/bin/alphaclaw.js +1 -31
- package/lib/public/assets/icons/google_icon.svg +8 -0
- package/lib/public/css/explorer.css +53 -0
- package/lib/public/css/shell.css +21 -19
- package/lib/public/css/theme.css +17 -0
- package/lib/public/js/app.js +205 -109
- package/lib/public/js/components/credentials-modal.js +36 -8
- package/lib/public/js/components/file-tree.js +212 -22
- package/lib/public/js/components/file-viewer/editor-surface.js +5 -0
- package/lib/public/js/components/file-viewer/index.js +47 -6
- package/lib/public/js/components/file-viewer/markdown-split-view.js +2 -0
- package/lib/public/js/components/file-viewer/status-banners.js +11 -6
- package/lib/public/js/components/file-viewer/toolbar.js +56 -1
- package/lib/public/js/components/file-viewer/use-editor-selection-restore.js +6 -0
- package/lib/public/js/components/file-viewer/use-file-diff.js +11 -0
- package/lib/public/js/components/file-viewer/use-file-loader.js +12 -2
- package/lib/public/js/components/file-viewer/use-file-viewer.js +142 -15
- package/lib/public/js/components/google/account-row.js +131 -0
- package/lib/public/js/components/google/add-account-modal.js +93 -0
- package/lib/public/js/components/google/gmail-setup-wizard.js +450 -0
- package/lib/public/js/components/google/gmail-watch-toggle.js +81 -0
- package/lib/public/js/components/google/index.js +553 -0
- package/lib/public/js/components/google/use-gmail-watch.js +140 -0
- package/lib/public/js/components/google/use-google-accounts.js +41 -0
- package/lib/public/js/components/icons.js +26 -0
- package/lib/public/js/components/scope-picker.js +1 -1
- package/lib/public/js/components/sidebar-git-panel.js +48 -20
- package/lib/public/js/components/sidebar.js +93 -75
- package/lib/public/js/components/toast.js +11 -7
- package/lib/public/js/components/usage-tab/constants.js +31 -0
- package/lib/public/js/components/usage-tab/formatters.js +24 -0
- package/lib/public/js/components/usage-tab/index.js +72 -0
- package/lib/public/js/components/usage-tab/overview-section.js +147 -0
- package/lib/public/js/components/usage-tab/sessions-section.js +175 -0
- package/lib/public/js/components/usage-tab/use-usage-tab.js +241 -0
- package/lib/public/js/components/webhooks.js +182 -129
- package/lib/public/js/lib/api.js +178 -9
- package/lib/public/js/lib/browse-file-policies.js +29 -11
- package/lib/public/js/lib/format.js +71 -0
- package/lib/public/js/lib/syntax-highlighters/index.js +6 -5
- package/lib/public/shared/browse-file-policies.json +13 -0
- package/lib/server/constants.js +47 -7
- package/lib/server/gmail-push.js +109 -0
- package/lib/server/gmail-serve.js +254 -0
- package/lib/server/gmail-watch.js +725 -0
- package/lib/server/google-state.js +317 -0
- package/lib/server/helpers.js +17 -11
- package/lib/server/internal-files-migration.js +31 -3
- package/lib/server/onboarding/github.js +21 -2
- package/lib/server/onboarding/index.js +1 -3
- package/lib/server/onboarding/openclaw.js +3 -0
- package/lib/server/onboarding/workspace.js +40 -0
- package/lib/server/routes/browse/index.js +90 -2
- package/lib/server/routes/gmail.js +128 -0
- package/lib/server/routes/google.js +433 -213
- package/lib/server/routes/system.js +107 -0
- package/lib/server/routes/usage.js +29 -2
- package/lib/server/routes/webhooks.js +52 -17
- package/lib/server/usage-db.js +283 -15
- package/lib/server/watchdog.js +66 -0
- package/lib/server/webhook-middleware.js +99 -1
- package/lib/server/webhooks.js +214 -65
- package/lib/server.js +27 -0
- package/lib/setup/gitignore +6 -0
- package/lib/setup/hourly-git-sync.sh +29 -2
- package/package.json +1 -1
- package/lib/public/js/components/google.js +0 -228
- package/lib/public/js/components/usage-tab.js +0 -531
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const { createGmailWatchService } = require("../gmail-watch");
|
|
2
|
+
const { createGmailPushHandler } = require("../gmail-push");
|
|
3
|
+
|
|
4
|
+
const registerGmailRoutes = ({
|
|
5
|
+
app,
|
|
6
|
+
fs,
|
|
7
|
+
constants,
|
|
8
|
+
gogCmd,
|
|
9
|
+
getBaseUrl,
|
|
10
|
+
readGoogleCredentials,
|
|
11
|
+
readEnvFile,
|
|
12
|
+
writeEnvFile,
|
|
13
|
+
reloadEnv,
|
|
14
|
+
restartRequiredState,
|
|
15
|
+
}) => {
|
|
16
|
+
const getRestartSnapshot = async () => {
|
|
17
|
+
try {
|
|
18
|
+
return (await restartRequiredState?.getSnapshot?.()) || {
|
|
19
|
+
restartRequired: false,
|
|
20
|
+
};
|
|
21
|
+
} catch {
|
|
22
|
+
return { restartRequired: false };
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const gmailWatchService = createGmailWatchService({
|
|
27
|
+
fs,
|
|
28
|
+
constants,
|
|
29
|
+
gogCmd,
|
|
30
|
+
getBaseUrl,
|
|
31
|
+
readGoogleCredentials,
|
|
32
|
+
readEnvFile,
|
|
33
|
+
writeEnvFile,
|
|
34
|
+
reloadEnv,
|
|
35
|
+
restartRequiredState,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
app.get("/api/gmail/config", (req, res) => {
|
|
39
|
+
try {
|
|
40
|
+
const data = gmailWatchService.getConfig({ req });
|
|
41
|
+
res.json(data);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
res.status(400).json({ ok: false, error: err.message });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
app.post("/api/gmail/config", (req, res) => {
|
|
48
|
+
try {
|
|
49
|
+
const data = gmailWatchService.saveClientConfig({
|
|
50
|
+
req,
|
|
51
|
+
body: req.body || {},
|
|
52
|
+
});
|
|
53
|
+
res.json(data);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
res.status(400).json({ ok: false, error: err.message });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
app.post("/api/gmail/watch/start", async (req, res) => {
|
|
60
|
+
try {
|
|
61
|
+
const accountId = String(req.body?.accountId || "").trim();
|
|
62
|
+
if (!accountId) return res.status(400).json({ ok: false, error: "accountId is required" });
|
|
63
|
+
const result = await gmailWatchService.startWatch({ accountId, req });
|
|
64
|
+
const snapshot = await getRestartSnapshot();
|
|
65
|
+
return res.json({
|
|
66
|
+
...result,
|
|
67
|
+
restartRequired: Boolean(snapshot?.restartRequired),
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return res.status(400).json({ ok: false, error: err.message });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
app.post("/api/gmail/watch/stop", async (req, res) => {
|
|
75
|
+
try {
|
|
76
|
+
const accountId = String(req.body?.accountId || "").trim();
|
|
77
|
+
if (!accountId) return res.status(400).json({ ok: false, error: "accountId is required" });
|
|
78
|
+
const result = await gmailWatchService.stopWatch({ accountId });
|
|
79
|
+
return res.json(result);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
return res.status(400).json({ ok: false, error: err.message });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
app.post("/api/gmail/watch/renew", async (req, res) => {
|
|
86
|
+
try {
|
|
87
|
+
const accountId = String(req.body?.accountId || "").trim();
|
|
88
|
+
const force = Boolean(req.body?.force ?? true);
|
|
89
|
+
const result = await gmailWatchService.renewWatch({ accountId, force });
|
|
90
|
+
return res.json(result);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
return res.status(400).json({ ok: false, error: err.message });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
app.get("/api/gmail/watch/status", (req, res) => {
|
|
97
|
+
try {
|
|
98
|
+
const accountId = String(req.query?.accountId || "").trim();
|
|
99
|
+
const config = gmailWatchService.getConfig({ req });
|
|
100
|
+
const accountStatus = accountId
|
|
101
|
+
? config.accounts.find((account) => account.accountId === accountId) || null
|
|
102
|
+
: null;
|
|
103
|
+
if (accountId && !accountStatus) {
|
|
104
|
+
return res.status(404).json({ ok: false, error: "Account status not found" });
|
|
105
|
+
}
|
|
106
|
+
return res.json({
|
|
107
|
+
ok: true,
|
|
108
|
+
account: accountStatus,
|
|
109
|
+
accounts: accountId ? undefined : config.accounts,
|
|
110
|
+
});
|
|
111
|
+
} catch (err) {
|
|
112
|
+
return res.status(400).json({ ok: false, error: err.message });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const pushHandler = createGmailPushHandler({
|
|
117
|
+
resolvePushToken: () => gmailWatchService.resolvePushToken(),
|
|
118
|
+
resolveTargetByEmail: (email) => gmailWatchService.getTargetByEmail(email),
|
|
119
|
+
markPushReceived: (payload) => gmailWatchService.markPushReceived(payload),
|
|
120
|
+
});
|
|
121
|
+
app.post("/gmail-pubsub", pushHandler);
|
|
122
|
+
|
|
123
|
+
return gmailWatchService;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
registerGmailRoutes,
|
|
128
|
+
};
|