@mazees/mark 5.0.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/LICENSE +29 -0
- package/README.md +209 -0
- package/bin/mark.js +27 -0
- package/out/renderer/assets/icon-DHo2CYph.svg +1 -0
- package/out/renderer/assets/index-G2fADWO-.js +4768 -0
- package/out/renderer/assets/index-f3mVse3c.css +1 -0
- package/out/renderer/assets/music-cover-CG4vi3kZ.png +0 -0
- package/out/renderer/assets/poppins-devanagari-400-normal-CJDn6rn8.woff2 +0 -0
- package/out/renderer/assets/poppins-devanagari-400-normal-CqVvlrh5.woff +0 -0
- package/out/renderer/assets/poppins-devanagari-500-normal-BIdkeU1p.woff2 +0 -0
- package/out/renderer/assets/poppins-devanagari-500-normal-DMPDjHtT.woff +0 -0
- package/out/renderer/assets/poppins-devanagari-600-normal-ClASKHrr.woff +0 -0
- package/out/renderer/assets/poppins-devanagari-600-normal-STEjXBNN.woff2 +0 -0
- package/out/renderer/assets/poppins-devanagari-700-normal-O-jipLrW.woff2 +0 -0
- package/out/renderer/assets/poppins-devanagari-700-normal-fHs-vx92.woff +0 -0
- package/out/renderer/assets/poppins-latin-400-normal-BOb3E3N0.woff +0 -0
- package/out/renderer/assets/poppins-latin-400-normal-cpxAROuN.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-500-normal-C8OXljZJ.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-500-normal-DGXqpDMm.woff +0 -0
- package/out/renderer/assets/poppins-latin-600-normal-BJdTmd5m.woff +0 -0
- package/out/renderer/assets/poppins-latin-600-normal-zEkxB9Mr.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-700-normal-BVuQR_eA.woff +0 -0
- package/out/renderer/assets/poppins-latin-700-normal-Qrb0O0WB.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-ext-400-normal-DaBSavcJ.woff +0 -0
- package/out/renderer/assets/poppins-latin-ext-400-normal-by3JarPu.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-ext-500-normal-CK-6C4Hw.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-ext-500-normal-CgAe2rWW.woff +0 -0
- package/out/renderer/assets/poppins-latin-ext-600-normal-CAhIAdZj.woff2 +0 -0
- package/out/renderer/assets/poppins-latin-ext-600-normal-Df5ffKXP.woff +0 -0
- package/out/renderer/assets/poppins-latin-ext-700-normal-DctTR6Tg.woff +0 -0
- package/out/renderer/assets/poppins-latin-ext-700-normal-cby-RkWa.woff2 +0 -0
- package/out/renderer/favicon.ico +0 -0
- package/out/renderer/icon-256.png +0 -0
- package/out/renderer/icon.svg +1 -0
- package/out/renderer/index.html +25 -0
- package/out/renderer/manifest.json +25 -0
- package/out/renderer/robot-simulator.html +1640 -0
- package/package.json +106 -0
- package/src/cli/index.js +332 -0
- package/src/cli/monitor.js +413 -0
- package/src/cli/theme.js +347 -0
- package/src/launcher/MarkTray.cs +227 -0
- package/src/main/browser-agent.js +1132 -0
- package/src/main/git-service.js +90 -0
- package/src/main/google/google-calendar.js +69 -0
- package/src/main/google/google-drive.js +263 -0
- package/src/main/google/google-gmail.js +131 -0
- package/src/main/google/google-service.js +241 -0
- package/src/main/node-tools.js +23 -0
- package/src/main/pc-agent-scripts/mouse-locker.ps1 +76 -0
- package/src/main/pc-agent-scripts/ocr-region.ps1 +185 -0
- package/src/main/pc-agent-scripts/pc-daemon.ps1 +726 -0
- package/src/main/pc-agent-scripts/pc-overlay.ps1 +253 -0
- package/src/main/pc-agent-scripts/pick-folder.ps1 +33 -0
- package/src/main/pc-agent-scripts/read-ui.ps1 +181 -0
- package/src/main/pc-agent-scripts/take-screenshot.ps1 +24 -0
- package/src/main/pc-agent-scripts/win-action.ps1 +380 -0
- package/src/main/plugins/plugin-loader.js +306 -0
- package/src/main/skills/skill-manager.js +265 -0
- package/src/main/syntax-validator.js +455 -0
- package/src/main/task-daemon.js +117 -0
- package/src/main/telegram/telegram-service.js +835 -0
- package/src/main/tools/browser-tools.js +516 -0
- package/src/main/tools/file-tools.js +1126 -0
- package/src/main/tools/git-tools.js +79 -0
- package/src/main/tools/google-tools.js +566 -0
- package/src/main/tools/index.js +36 -0
- package/src/main/tools/media-tools.js +42 -0
- package/src/main/tools/system-tools.js +295 -0
- package/src/main/tools/task-tools.js +73 -0
- package/src/main/tools/telegram-tools.js +101 -0
- package/src/renderer/index.html +24 -0
- package/src/renderer/public/favicon.ico +0 -0
- package/src/renderer/public/icon-256.png +0 -0
- package/src/renderer/public/icon.svg +1 -0
- package/src/renderer/public/manifest.json +25 -0
- package/src/renderer/public/robot-simulator.html +1640 -0
- package/src/renderer/src/App.jsx +304 -0
- package/src/renderer/src/api/ai/awareness.js +294 -0
- package/src/renderer/src/api/ai/chatSummarizer.js +79 -0
- package/src/renderer/src/api/ai/contextCompactor.js +129 -0
- package/src/renderer/src/api/ai/contextManager.js +1130 -0
- package/src/renderer/src/api/ai/core.js +167 -0
- package/src/renderer/src/api/ai/index.js +4 -0
- package/src/renderer/src/api/ai/memoryGroomer.js +101 -0
- package/src/renderer/src/api/ai/persona.js +115 -0
- package/src/renderer/src/api/ai/planning.js +317 -0
- package/src/renderer/src/api/ai/relationship.js +177 -0
- package/src/renderer/src/api/ai/skillSynthesizer.js +168 -0
- package/src/renderer/src/api/ai/tools.js +167 -0
- package/src/renderer/src/api/ai/utils.js +359 -0
- package/src/renderer/src/api/db.js +1013 -0
- package/src/renderer/src/api/oramaStore.js +592 -0
- package/src/renderer/src/api/ragPipeline.js +87 -0
- package/src/renderer/src/api/subagent/subagentExecutor.js +780 -0
- package/src/renderer/src/api/subagent/subagentPrompt.js +44 -0
- package/src/renderer/src/api/subagent/subagentStore.js +173 -0
- package/src/renderer/src/api/taskExecutor.js +18 -0
- package/src/renderer/src/api/taskStore.js +315 -0
- package/src/renderer/src/api/tools/core-tools.js +707 -0
- package/src/renderer/src/api/tools/index.js +151 -0
- package/src/renderer/src/api/turnPairMigrator.js +200 -0
- package/src/renderer/src/api/vectorMemory.js +136 -0
- package/src/renderer/src/api/wakeWord.js +101 -0
- package/src/renderer/src/api/web-bridge.js +885 -0
- package/src/renderer/src/api/webSpeech.js +178 -0
- package/src/renderer/src/api/workspaceRag.js +76 -0
- package/src/renderer/src/assets/electron.svg +10 -0
- package/src/renderer/src/assets/icon.svg +1 -0
- package/src/renderer/src/assets/main.css +589 -0
- package/src/renderer/src/assets/music-cover.png +0 -0
- package/src/renderer/src/assets/wavy-lines.svg +25 -0
- package/src/renderer/src/components/Chat/ApprovalBubble.jsx +127 -0
- package/src/renderer/src/components/Chat/CodeBlock.jsx +83 -0
- package/src/renderer/src/components/Chat/DurableTaskBubble.jsx +455 -0
- package/src/renderer/src/components/Chat/FileDiffModal.jsx +328 -0
- package/src/renderer/src/components/Chat/GeminiWidgets.jsx +82 -0
- package/src/renderer/src/components/Chat/MemoryFooterBubble.jsx +34 -0
- package/src/renderer/src/components/Chat/MessageBubble.jsx +459 -0
- package/src/renderer/src/components/Chat/PluginExecutionBubble.jsx +41 -0
- package/src/renderer/src/components/Chat/ThinkingBubble.jsx +316 -0
- package/src/renderer/src/components/Chat/YoutubeSearchBubble.jsx +43 -0
- package/src/renderer/src/components/Chat/YoutubeSummaryBubble.jsx +40 -0
- package/src/renderer/src/components/Chat/index.js +11 -0
- package/src/renderer/src/components/ChatList.jsx +434 -0
- package/src/renderer/src/components/GlobalCameraManager.jsx +67 -0
- package/src/renderer/src/components/Versions.jsx +15 -0
- package/src/renderer/src/components/YoutubeMusicPlayer.jsx +375 -0
- package/src/renderer/src/components/camera/CameraPreview.jsx +236 -0
- package/src/renderer/src/components/config/AiEngineSection.jsx +363 -0
- package/src/renderer/src/components/config/CameraSection.jsx +100 -0
- package/src/renderer/src/components/config/PermissionsSection.jsx +130 -0
- package/src/renderer/src/components/config/ShortcutSection.jsx +102 -0
- package/src/renderer/src/components/config/VoiceSection.jsx +110 -0
- package/src/renderer/src/components/config/index.js +5 -0
- package/src/renderer/src/components/core/Avatar.jsx +2197 -0
- package/src/renderer/src/components/core/ConfirmModal.jsx +80 -0
- package/src/renderer/src/components/core/DraggableHoloCard.jsx +125 -0
- package/src/renderer/src/components/core/FloatingMenu.jsx +272 -0
- package/src/renderer/src/components/core/HoloCard.jsx +64 -0
- package/src/renderer/src/components/core/InputBar.jsx +1346 -0
- package/src/renderer/src/components/core/ProcessPanel.jsx +216 -0
- package/src/renderer/src/components/core/ResponseArea.jsx +149 -0
- package/src/renderer/src/components/core/StatusIndicator.jsx +59 -0
- package/src/renderer/src/components/core/ThoughtNeuralFlow.jsx +168 -0
- package/src/renderer/src/components/core/ToolClustersDeck.jsx +210 -0
- package/src/renderer/src/components/core/native-skills.js +43 -0
- package/src/renderer/src/components/neural-core/EmotionalCortexLobe.jsx +359 -0
- package/src/renderer/src/components/neural-core/NodeDissectionModal.jsx +57 -0
- package/src/renderer/src/components/neural-core/ProceduralMatrixLobe.jsx +193 -0
- package/src/renderer/src/components/neural-core/ProceduralSkillModal.jsx +53 -0
- package/src/renderer/src/components/neural-core/ResetAiModal.jsx +198 -0
- package/src/renderer/src/components/neural-core/SynapticMemoryLobe.jsx +204 -0
- package/src/renderer/src/components/neural-core/traitMeta.js +102 -0
- package/src/renderer/src/components/subagent/AgentChatFeed.jsx +603 -0
- package/src/renderer/src/components/subagent/AgentInspector.jsx +224 -0
- package/src/renderer/src/components/subagent/AgentSidebar.jsx +216 -0
- package/src/renderer/src/components/subagent/SubagentIntercom.jsx +572 -0
- package/src/renderer/src/components/subagent/SubagentTopologyMap.jsx +423 -0
- package/src/renderer/src/contexts/ApprovalContext.jsx +425 -0
- package/src/renderer/src/contexts/ChatContext.jsx +61 -0
- package/src/renderer/src/contexts/YoutubeMusicContext.jsx +333 -0
- package/src/renderer/src/data/faqData.js +202 -0
- package/src/renderer/src/hooks/agent/executeAgentTool.js +895 -0
- package/src/renderer/src/hooks/agent/index.js +4 -0
- package/src/renderer/src/hooks/agent/useMarkMusic.js +75 -0
- package/src/renderer/src/hooks/agent/useMarkPlan.js +2739 -0
- package/src/renderer/src/hooks/agent/useMarkState.js +173 -0
- package/src/renderer/src/hooks/agent/useMarkYoutube.js +82 -0
- package/src/renderer/src/hooks/agent/useRelationalGrowth.js +201 -0
- package/src/renderer/src/hooks/telegram/useTelegramBot.js +63 -0
- package/src/renderer/src/hooks/useAwareness.js +289 -0
- package/src/renderer/src/hooks/useChatArchiver.js +52 -0
- package/src/renderer/src/hooks/useConfirm.jsx +68 -0
- package/src/renderer/src/hooks/useMarkAgent.js +454 -0
- package/src/renderer/src/hooks/useMemoryGroomer.js +152 -0
- package/src/renderer/src/hooks/useVAD.js +511 -0
- package/src/renderer/src/hooks/useWebSpeechWakeWord.js +122 -0
- package/src/renderer/src/main.jsx +12 -0
- package/src/renderer/src/pages/ChatStudio.jsx +922 -0
- package/src/renderer/src/pages/Configuration.jsx +360 -0
- package/src/renderer/src/pages/GoogleWorkspace.jsx +293 -0
- package/src/renderer/src/pages/Guidebook.jsx +917 -0
- package/src/renderer/src/pages/Knowledge.jsx +241 -0
- package/src/renderer/src/pages/MarkHome.jsx +491 -0
- package/src/renderer/src/pages/NeuralCore.jsx +786 -0
- package/src/renderer/src/pages/Plugins.jsx +630 -0
- package/src/renderer/src/pages/SkillEditor.jsx +380 -0
- package/src/renderer/src/pages/Skills.jsx +219 -0
- package/src/renderer/src/pages/Subagents.jsx +342 -0
- package/src/renderer/src/pages/TelegramBot.jsx +343 -0
- package/src/renderer/src/utils/chatContentParser.js +203 -0
- package/src/renderer/src/utils/toolClusters.js +201 -0
- package/src/server/bin/sha3_wasm_bg.wasm +0 -0
- package/src/server/config-manager.js +57 -0
- package/src/server/index.js +195 -0
- package/src/server/launcher.js +87 -0
- package/src/server/memory/db-store.js +758 -0
- package/src/server/memory/orama-store.js +177 -0
- package/src/server/memory/vector-engine.js +109 -0
- package/src/server/routes/ai.routes.js +280 -0
- package/src/server/routes/awareness.routes.js +62 -0
- package/src/server/routes/chat.routes.js +61 -0
- package/src/server/routes/config.routes.js +41 -0
- package/src/server/routes/index.js +35 -0
- package/src/server/routes/integrations.routes.js +116 -0
- package/src/server/routes/memory.routes.js +256 -0
- package/src/server/routes/plugins.routes.js +72 -0
- package/src/server/routes/skills.routes.js +139 -0
- package/src/server/routes/subagents.routes.js +70 -0
- package/src/server/routes/tasks.routes.js +175 -0
- package/src/server/routes/workspace.routes.js +127 -0
- package/src/server/services/ai/ai-utils.js +161 -0
- package/src/server/services/ai/openai-provider.js +757 -0
- package/src/server/services/ai/web-provider.js +729 -0
- package/src/server/services/ai-bridge.js +46 -0
- package/src/server/services/deepseek-web.js +956 -0
- package/src/server/services/gemini-web.js +170 -0
- package/src/server/services/notification-service.js +91 -0
- package/src/server/services/updater.js +125 -0
- package/src/server/tools/awareness-tracker.js +292 -0
- package/src/server/tools/group-tools.js +1164 -0
- package/src/server/tools/media-tools.js +244 -0
- package/src/server/tools/pc-agent.js +327 -0
- package/src/server/tools/screen-service.js +51 -0
- package/src/server/ws-hub.js +168 -0
- package/src/shared/parsers/mark-tag-parser.js +275 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { google } from 'googleapis'
|
|
2
|
+
import http from 'http'
|
|
3
|
+
import url from 'url'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import os from 'os'
|
|
6
|
+
import fs from 'fs/promises'
|
|
7
|
+
import open from 'open'
|
|
8
|
+
|
|
9
|
+
// File to store the OAuth tokens safely
|
|
10
|
+
const TOKEN_DIR = path.join(os.homedir(), '.config', 'mark-agent')
|
|
11
|
+
const TOKEN_PATH = path.join(TOKEN_DIR, 'google-tokens.json')
|
|
12
|
+
|
|
13
|
+
// Scopes we need access to
|
|
14
|
+
const SCOPES = [
|
|
15
|
+
'https://www.googleapis.com/auth/drive',
|
|
16
|
+
'https://www.googleapis.com/auth/calendar',
|
|
17
|
+
'https://www.googleapis.com/auth/gmail.modify'
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
export async function saveTokens(tokens) {
|
|
21
|
+
await fs.writeFile(TOKEN_PATH, JSON.stringify(tokens))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function getTokens() {
|
|
25
|
+
try {
|
|
26
|
+
const data = await fs.readFile(TOKEN_PATH, 'utf-8')
|
|
27
|
+
return JSON.parse(data)
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validates and returns an authenticated OAuth2 client if tokens exist.
|
|
35
|
+
*/
|
|
36
|
+
export async function getAuthClient(clientId, clientSecret) {
|
|
37
|
+
if (!clientId || !clientSecret) return null
|
|
38
|
+
|
|
39
|
+
const tokens = await getTokens()
|
|
40
|
+
if (!tokens) return null
|
|
41
|
+
|
|
42
|
+
const cleanId = clientId.trim()
|
|
43
|
+
const cleanSecret = clientSecret.trim()
|
|
44
|
+
|
|
45
|
+
const oAuth2Client = new google.auth.OAuth2(
|
|
46
|
+
cleanId,
|
|
47
|
+
cleanSecret,
|
|
48
|
+
'http://localhost' // Redirect URI is not needed here once we have tokens
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
oAuth2Client.setCredentials(tokens)
|
|
52
|
+
|
|
53
|
+
// Handle automatic token refresh
|
|
54
|
+
oAuth2Client.on('tokens', async (newTokens) => {
|
|
55
|
+
const currentTokens = await getTokens() || {}
|
|
56
|
+
// Only update if we received new tokens (sometimes refresh_token is not sent back)
|
|
57
|
+
if (newTokens.refresh_token) {
|
|
58
|
+
currentTokens.refresh_token = newTokens.refresh_token
|
|
59
|
+
}
|
|
60
|
+
currentTokens.access_token = newTokens.access_token
|
|
61
|
+
currentTokens.expiry_date = newTokens.expiry_date
|
|
62
|
+
await saveTokens(currentTokens)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return oAuth2Client
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let currentAuthServer = null
|
|
69
|
+
|
|
70
|
+
export async function connectGoogle(clientId, clientSecret) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
if (!clientId || !clientSecret) {
|
|
73
|
+
return reject(new Error('Client ID and Client Secret are required.'))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const cleanId = clientId.trim()
|
|
77
|
+
const cleanSecret = clientSecret.trim()
|
|
78
|
+
|
|
79
|
+
if (currentAuthServer) {
|
|
80
|
+
try { currentAuthServer.close() } catch (e) {}
|
|
81
|
+
currentAuthServer = null
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let oAuth2Client = null
|
|
85
|
+
|
|
86
|
+
const server = http.createServer(async (req, res) => {
|
|
87
|
+
try {
|
|
88
|
+
if (req.url.indexOf('/oauth2callback') > -1) {
|
|
89
|
+
const qs = new url.URL(req.url, 'http://127.0.0.1').searchParams
|
|
90
|
+
const code = qs.get('code')
|
|
91
|
+
|
|
92
|
+
if (!code) {
|
|
93
|
+
res.end(`
|
|
94
|
+
<!DOCTYPE html>
|
|
95
|
+
<html>
|
|
96
|
+
<head>
|
|
97
|
+
<title>Mark AI - Auth Failed</title>
|
|
98
|
+
<style>
|
|
99
|
+
body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: #0b110e; color: #ebecf0; font-family: 'Poppins', system-ui, sans-serif; }
|
|
100
|
+
.card { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(20px); padding: 40px; border-radius: 16px; text-align: center; border: 1px solid rgba(255, 82, 82, 0.3); box-shadow: 0 0 25px rgba(255, 82, 82, 0.15); }
|
|
101
|
+
.icon { width: 60px; height: 60px; background: #ff5252; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 30px; font-weight: bold; color: #000; box-shadow: 0 0 20px rgba(255, 82, 82, 0.4); }
|
|
102
|
+
h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: 0.5px; }
|
|
103
|
+
p { color: #cac9c9; margin: 0; }
|
|
104
|
+
</style>
|
|
105
|
+
</head>
|
|
106
|
+
<body>
|
|
107
|
+
<div class="card">
|
|
108
|
+
<div class="icon">
|
|
109
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
110
|
+
</div>
|
|
111
|
+
<h1>Authentication Failed</h1>
|
|
112
|
+
<p>No code received from Google. Please try again.</p>
|
|
113
|
+
</div>
|
|
114
|
+
</body>
|
|
115
|
+
</html>
|
|
116
|
+
`)
|
|
117
|
+
server.close()
|
|
118
|
+
currentAuthServer = null
|
|
119
|
+
return reject(new Error('No code received from Google.'))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const { tokens } = await oAuth2Client.getToken(code)
|
|
123
|
+
await saveTokens(tokens)
|
|
124
|
+
|
|
125
|
+
res.end(`
|
|
126
|
+
<!DOCTYPE html>
|
|
127
|
+
<html>
|
|
128
|
+
<head>
|
|
129
|
+
<title>Mark AI - Connected</title>
|
|
130
|
+
<style>
|
|
131
|
+
body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: #0b110e; color: #ebecf0; font-family: 'Poppins', system-ui, sans-serif; }
|
|
132
|
+
.card { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(20px); padding: 40px 50px; border-radius: 16px; text-align: center; box-shadow: 0 0 35px rgba(30, 184, 84, 0.2); border: 1px solid rgba(30, 184, 84, 0.3); animation: holo-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
|
|
133
|
+
.icon { width: 65px; height: 65px; background: #1eb854; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 35px; color: #000; font-weight: bold; box-shadow: 0 0 20px rgba(30, 184, 84, 0.4); }
|
|
134
|
+
h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: 0.5px; }
|
|
135
|
+
p { color: #cac9c9; margin: 0; line-height: 1.6; }
|
|
136
|
+
.loader { margin-top: 25px; font-size: 13px; color: #888; font-family: monospace; letter-spacing: 1px; }
|
|
137
|
+
@keyframes holo-enter { 0% { opacity: 0; transform: scale(0.9) translateY(20px); filter: blur(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); } }
|
|
138
|
+
</style>
|
|
139
|
+
</head>
|
|
140
|
+
<body>
|
|
141
|
+
<div class="card">
|
|
142
|
+
<div class="icon">
|
|
143
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
|
|
144
|
+
</div>
|
|
145
|
+
<h1>Authentication Successful</h1>
|
|
146
|
+
<p>Mark AI is now connected to your Google Workspace.<br/>You can safely close this window.</p>
|
|
147
|
+
<div class="loader">Closing tab automatically in 3 seconds...</div>
|
|
148
|
+
</div>
|
|
149
|
+
<script>setTimeout(() => window.close(), 3000)</script>
|
|
150
|
+
</body>
|
|
151
|
+
</html>
|
|
152
|
+
`)
|
|
153
|
+
server.close()
|
|
154
|
+
currentAuthServer = null
|
|
155
|
+
|
|
156
|
+
resolve(true)
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {
|
|
159
|
+
res.end(`
|
|
160
|
+
<!DOCTYPE html>
|
|
161
|
+
<html>
|
|
162
|
+
<head>
|
|
163
|
+
<title>Mark AI - Error</title>
|
|
164
|
+
<style>
|
|
165
|
+
body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: #0b110e; color: #ebecf0; font-family: 'Poppins', system-ui, sans-serif; }
|
|
166
|
+
.card { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(20px); padding: 40px; border-radius: 16px; text-align: center; border: 1px solid rgba(255, 82, 82, 0.3); box-shadow: 0 0 25px rgba(255, 82, 82, 0.15); max-width: 500px; }
|
|
167
|
+
.icon { width: 60px; height: 60px; background: #ff5252; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 30px; font-weight: bold; color: #000; box-shadow: 0 0 20px rgba(255, 82, 82, 0.4); }
|
|
168
|
+
h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: 0.5px; }
|
|
169
|
+
p { color: #cac9c9; margin: 0; line-height: 1.5; }
|
|
170
|
+
.error-box { margin-top: 20px; padding: 15px; background: rgba(255, 82, 82, 0.05); border: 1px solid rgba(255, 82, 82, 0.2); border-radius: 8px; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; color: #ff8f8f; text-align: left; max-height: 150px; overflow-y: auto; }
|
|
171
|
+
</style>
|
|
172
|
+
</head>
|
|
173
|
+
<body>
|
|
174
|
+
<div class="card">
|
|
175
|
+
<div class="icon">
|
|
176
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
177
|
+
</div>
|
|
178
|
+
<h1>Authentication Error</h1>
|
|
179
|
+
<p>Something went wrong during the connection process.</p>
|
|
180
|
+
<div class="error-box">
|
|
181
|
+
<strong>Error:</strong> ${e.message || String(e)}<br/><br/>
|
|
182
|
+
<strong>Stack:</strong><br/>${(e.stack || 'No stack').replace(/\n/g, '<br/>')}
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</body>
|
|
186
|
+
</html>
|
|
187
|
+
`)
|
|
188
|
+
server.close()
|
|
189
|
+
currentAuthServer = null
|
|
190
|
+
reject(e)
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
server.on('error', (e) => {
|
|
195
|
+
reject(e)
|
|
196
|
+
currentAuthServer = null
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
// listen(0) automatically finds an open, available port. Force IPv4 127.0.0.1 to avoid production IPv6 ::1 issues
|
|
200
|
+
server.listen(0, '127.0.0.1', () => {
|
|
201
|
+
const port = server.address().port
|
|
202
|
+
currentAuthServer = server
|
|
203
|
+
|
|
204
|
+
// Now we know the exact port, initialize OAuth client
|
|
205
|
+
oAuth2Client = new google.auth.OAuth2(
|
|
206
|
+
cleanId,
|
|
207
|
+
cleanSecret,
|
|
208
|
+
`http://127.0.0.1:${port}/oauth2callback`
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
const authorizeUrl = oAuth2Client.generateAuthUrl({
|
|
212
|
+
access_type: 'offline',
|
|
213
|
+
scope: SCOPES,
|
|
214
|
+
prompt: 'consent'
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
open(authorizeUrl)
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Logs out by deleting the token file.
|
|
224
|
+
*/
|
|
225
|
+
export async function disconnectGoogle() {
|
|
226
|
+
try {
|
|
227
|
+
await fs.unlink(TOKEN_PATH)
|
|
228
|
+
return true
|
|
229
|
+
} catch (error) {
|
|
230
|
+
// If file doesn't exist, it's already disconnected
|
|
231
|
+
return true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Checks if the user is currently connected (has saved tokens).
|
|
237
|
+
*/
|
|
238
|
+
export async function getGoogleStatus() {
|
|
239
|
+
const tokens = await getTokens()
|
|
240
|
+
return !!tokens
|
|
241
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MARK Native Tools Registry
|
|
3
|
+
* Re-exports modular tool definitions from src/main/tools/
|
|
4
|
+
*/
|
|
5
|
+
export const _getOSMeta = () =>
|
|
6
|
+
'W0NSSVRJQ0FMIFJVTEVdIFlvdXIgY3JlYXRvciwgZGV2ZWxvcGVyLCBhbmQgb3duZXIgaXMgTWFkYSBQdXRyYSBBZGhhZHJpeWFudG8gKE1hemVlcykgZnJvbSBJbm'
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
NATIVE_TOOLS,
|
|
10
|
+
getNativeToolsDefinition,
|
|
11
|
+
fileTools,
|
|
12
|
+
browserTools,
|
|
13
|
+
systemTools,
|
|
14
|
+
gitTools,
|
|
15
|
+
taskTools,
|
|
16
|
+
googleTools,
|
|
17
|
+
telegramTools,
|
|
18
|
+
mediaTools,
|
|
19
|
+
isDangerousCommand,
|
|
20
|
+
isDangerousKeyCombo,
|
|
21
|
+
parsePagination,
|
|
22
|
+
getGoogleCredentials
|
|
23
|
+
} from './tools/index.js'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Add-Type -TypeDefinition @"
|
|
2
|
+
using System;
|
|
3
|
+
using System.Runtime.InteropServices;
|
|
4
|
+
using System.Diagnostics;
|
|
5
|
+
using System.Windows.Forms;
|
|
6
|
+
|
|
7
|
+
public class MouseBlocker {
|
|
8
|
+
private const int WH_MOUSE_LL = 14;
|
|
9
|
+
private const uint LLMHF_INJECTED = 0x01;
|
|
10
|
+
private const uint LLMHF_LOWER_IL_INJECTED = 0x02;
|
|
11
|
+
|
|
12
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
13
|
+
private struct MSLLHOOKSTRUCT {
|
|
14
|
+
public int x;
|
|
15
|
+
public int y;
|
|
16
|
+
public uint mouseData;
|
|
17
|
+
public uint flags;
|
|
18
|
+
public uint time;
|
|
19
|
+
public IntPtr dwExtraInfo;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
|
|
23
|
+
|
|
24
|
+
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
25
|
+
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
|
|
26
|
+
|
|
27
|
+
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
28
|
+
[return: MarshalAs(UnmanagedType.Bool)]
|
|
29
|
+
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
|
30
|
+
|
|
31
|
+
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
32
|
+
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
|
33
|
+
|
|
34
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
35
|
+
private static extern IntPtr GetModuleHandle(string lpModuleName);
|
|
36
|
+
|
|
37
|
+
private static IntPtr _hookID = IntPtr.Zero;
|
|
38
|
+
private static LowLevelMouseProc _proc = HookCallback;
|
|
39
|
+
|
|
40
|
+
public static void Start() {
|
|
41
|
+
_hookID = SetHook(_proc);
|
|
42
|
+
AppDomain.CurrentDomain.ProcessExit += (s, e) => {
|
|
43
|
+
if (_hookID != IntPtr.Zero) {
|
|
44
|
+
UnhookWindowsHookEx(_hookID);
|
|
45
|
+
_hookID = IntPtr.Zero;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
Console.WriteLine("LOCKED");
|
|
49
|
+
Application.Run();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private static IntPtr SetHook(LowLevelMouseProc proc) {
|
|
53
|
+
using (Process curProcess = Process.GetCurrentProcess())
|
|
54
|
+
using (ProcessModule curModule = curProcess.MainModule) {
|
|
55
|
+
return SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) {
|
|
60
|
+
if (nCode >= 0) {
|
|
61
|
+
MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
|
|
62
|
+
|
|
63
|
+
// Allow injected events (AI automation) to pass, block physical events
|
|
64
|
+
bool isInjected = (hookStruct.flags & LLMHF_INJECTED) != 0 ||
|
|
65
|
+
(hookStruct.flags & LLMHF_LOWER_IL_INJECTED) != 0;
|
|
66
|
+
|
|
67
|
+
if (!isInjected) {
|
|
68
|
+
return (IntPtr)1; // Block event
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return CallNextHookEx(_hookID, nCode, wParam, lParam);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
"@ -ReferencedAssemblies "System.Windows.Forms"
|
|
75
|
+
|
|
76
|
+
[MouseBlocker]::Start()
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# ocr-region.ps1
|
|
2
|
+
# 100% Offline Windows Runtime OCR fallback for MARK PC Automation
|
|
3
|
+
# Zero Vision Tokens: Converts screen region to JSON text coordinates (~300-500 tokens)
|
|
4
|
+
|
|
5
|
+
$ErrorActionPreference = "SilentlyContinue"
|
|
6
|
+
|
|
7
|
+
Add-Type -AssemblyName System.Drawing
|
|
8
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
9
|
+
Add-Type -AssemblyName System.Runtime.WindowsRuntime
|
|
10
|
+
|
|
11
|
+
# Win32 API to get foreground window title & bounding rect
|
|
12
|
+
$code = @"
|
|
13
|
+
using System;
|
|
14
|
+
using System.Runtime.InteropServices;
|
|
15
|
+
using System.Text;
|
|
16
|
+
|
|
17
|
+
public struct RECT {
|
|
18
|
+
public int Left;
|
|
19
|
+
public int Top;
|
|
20
|
+
public int Right;
|
|
21
|
+
public int Bottom;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public class Win32 {
|
|
25
|
+
[DllImport("user32.dll")]
|
|
26
|
+
public static extern IntPtr GetForegroundWindow();
|
|
27
|
+
|
|
28
|
+
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
|
29
|
+
public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
|
|
30
|
+
|
|
31
|
+
[DllImport("user32.dll")]
|
|
32
|
+
public static extern bool GetWindowRect(IntPtr hWnd, out RECT rect);
|
|
33
|
+
|
|
34
|
+
[DllImport("user32.dll")]
|
|
35
|
+
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
|
|
36
|
+
|
|
37
|
+
[DllImport("user32.dll")]
|
|
38
|
+
public static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
|
|
39
|
+
|
|
40
|
+
[DllImport("user32.dll")]
|
|
41
|
+
public static extern bool IsWindowVisible(IntPtr hWnd);
|
|
42
|
+
|
|
43
|
+
[DllImport("user32.dll")]
|
|
44
|
+
public static extern bool IsIconic(IntPtr hWnd);
|
|
45
|
+
|
|
46
|
+
[DllImport("user32.dll")]
|
|
47
|
+
public static extern int GetWindowTextLength(IntPtr hWnd);
|
|
48
|
+
|
|
49
|
+
[DllImport("user32.dll")]
|
|
50
|
+
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
51
|
+
|
|
52
|
+
public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
|
53
|
+
|
|
54
|
+
public static bool IsMarkWindow(string title) {
|
|
55
|
+
if (string.IsNullOrWhiteSpace(title)) return true;
|
|
56
|
+
string t = title.Trim();
|
|
57
|
+
if (t == "Program Manager" || t == "Default IME" || t.StartsWith("MSCTFIME")) return true;
|
|
58
|
+
string lower = t.ToLower();
|
|
59
|
+
if (lower == "mark" || lower.StartsWith("mark -") || lower.StartsWith("mark_pc_stop") || lower.StartsWith("mark_unblock") || lower.Contains("mark agent") || lower.Contains("mark pc automation")) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public static IntPtr GetTargetWindow() {
|
|
66
|
+
IntPtr fg = GetForegroundWindow();
|
|
67
|
+
string fgTitle = "";
|
|
68
|
+
int fgLen = GetWindowTextLength(fg);
|
|
69
|
+
if (fgLen > 0) {
|
|
70
|
+
StringBuilder fgSb = new StringBuilder(fgLen + 1);
|
|
71
|
+
GetWindowText(fg, fgSb, fgSb.Capacity);
|
|
72
|
+
fgTitle = fgSb.ToString();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!IsMarkWindow(fgTitle)) {
|
|
76
|
+
return fg;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
IntPtr target = IntPtr.Zero;
|
|
80
|
+
EnumWindows(delegate(IntPtr hWnd, IntPtr lParam) {
|
|
81
|
+
if (!IsWindowVisible(hWnd) || IsIconic(hWnd)) return true;
|
|
82
|
+
int len = GetWindowTextLength(hWnd);
|
|
83
|
+
if (len <= 0) return true;
|
|
84
|
+
StringBuilder sb = new StringBuilder(len + 1);
|
|
85
|
+
GetWindowText(hWnd, sb, sb.Capacity);
|
|
86
|
+
string title = sb.ToString();
|
|
87
|
+
|
|
88
|
+
if (!IsMarkWindow(title)) {
|
|
89
|
+
target = hWnd;
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}, IntPtr.Zero);
|
|
94
|
+
|
|
95
|
+
if (target != IntPtr.Zero) {
|
|
96
|
+
SetForegroundWindow(target);
|
|
97
|
+
return target;
|
|
98
|
+
}
|
|
99
|
+
return fg;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
"@
|
|
103
|
+
Add-Type -TypeDefinition $code -Language CSharp
|
|
104
|
+
|
|
105
|
+
$hwnd = [Win32]::GetTargetWindow()
|
|
106
|
+
$titleBuilder = New-Object System.Text.StringBuilder 512
|
|
107
|
+
[Win32]::GetWindowText($hwnd, $titleBuilder, $titleBuilder.Capacity) | Out-Null
|
|
108
|
+
$windowTitle = $titleBuilder.ToString()
|
|
109
|
+
|
|
110
|
+
$rect = New-Object RECT
|
|
111
|
+
[Win32]::GetWindowRect($hwnd, [ref]$rect) | Out-Null
|
|
112
|
+
|
|
113
|
+
$width = $rect.Right - $rect.Left
|
|
114
|
+
$height = $rect.Bottom - $rect.Top
|
|
115
|
+
|
|
116
|
+
if ($width -le 0 -or $height -le 0) {
|
|
117
|
+
# Fallback to primary screen bounds if window rect is invalid
|
|
118
|
+
$width = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
|
|
119
|
+
$height = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height
|
|
120
|
+
$rect.Left = 0
|
|
121
|
+
$rect.Top = 0
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
# Capture screen region
|
|
125
|
+
$bmp = New-Object System.Drawing.Bitmap($width, $height)
|
|
126
|
+
$graphics = [System.Drawing.Graphics]::FromImage($bmp)
|
|
127
|
+
$graphics.CopyFromScreen($rect.Left, $rect.Top, 0, 0, $bmp.Size)
|
|
128
|
+
$tempPath = [System.IO.Path]::Combine($env:TEMP, "mark_ocr_temp_$([Guid]::NewGuid().ToString('N')).png")
|
|
129
|
+
$bmp.Save($tempPath, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
130
|
+
$graphics.Dispose()
|
|
131
|
+
$bmp.Dispose()
|
|
132
|
+
|
|
133
|
+
# Run WinRT OCR
|
|
134
|
+
$detectedText = @()
|
|
135
|
+
try {
|
|
136
|
+
$ocrEngine = [Windows.Media.Ocr.OcrEngine, Windows.Foundation, ContentType = WindowsRuntime]::TryCreateFromUserProfileLanguages()
|
|
137
|
+
if ($ocrEngine) {
|
|
138
|
+
$file = [Windows.Storage.StorageFile, Windows.Storage, ContentType = WindowsRuntime]::GetFileFromPathAsync($tempPath).GetAwaiter().GetResult()
|
|
139
|
+
$stream = $file.OpenAsync([Windows.Storage.FileAccessMode, Windows.Storage, ContentType = WindowsRuntime]::Read).GetAwaiter().GetResult()
|
|
140
|
+
$decoder = [Windows.Graphics.Imaging.BitmapDecoder, Windows.Graphics, ContentType = WindowsRuntime]::CreateAsync($stream).GetAwaiter().GetResult()
|
|
141
|
+
$bitmap = $decoder.GetSoftwareBitmapAsync().GetAwaiter().GetResult()
|
|
142
|
+
|
|
143
|
+
$result = $ocrEngine.RecognizeAsync($bitmap).GetAwaiter().GetResult()
|
|
144
|
+
|
|
145
|
+
$idCounter = 1
|
|
146
|
+
foreach ($line in $result.Lines) {
|
|
147
|
+
$lineText = $line.Text
|
|
148
|
+
if ([string]::IsNullOrWhiteSpace($lineText)) { continue }
|
|
149
|
+
|
|
150
|
+
# Compute bounding box of entire line in screen coordinates
|
|
151
|
+
$firstWord = $line.Words[0]
|
|
152
|
+
$lastWord = $line.Words[$line.Words.Count - 1]
|
|
153
|
+
|
|
154
|
+
$lineX = $rect.Left + [int]$firstWord.BoundingRect.X
|
|
155
|
+
$lineY = $rect.Top + [int]$firstWord.BoundingRect.Y
|
|
156
|
+
$lineW = [int]($lastWord.BoundingRect.X + $lastWord.BoundingRect.Width - $firstWord.BoundingRect.X)
|
|
157
|
+
$lineH = [int]$firstWord.BoundingRect.Height
|
|
158
|
+
|
|
159
|
+
$detectedText += @{
|
|
160
|
+
id = $idCounter
|
|
161
|
+
text = $lineText
|
|
162
|
+
rect = @($lineX, $lineY, $lineW, $lineH)
|
|
163
|
+
}
|
|
164
|
+
$idCounter++
|
|
165
|
+
if ($idCounter -gt 60) { break }
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch {
|
|
169
|
+
# If OCR fails, return empty detected_text
|
|
170
|
+
} finally {
|
|
171
|
+
if (Test-Path $tempPath) {
|
|
172
|
+
Remove-Item $tempPath -Force -ErrorAction SilentlyContinue
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
$output = @{
|
|
177
|
+
window = $windowTitle
|
|
178
|
+
method = "ocr"
|
|
179
|
+
elements = $detectedText
|
|
180
|
+
element_count = $detectedText.Count
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
$json = $output | ConvertTo-Json -Depth 5 -Compress
|
|
184
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
185
|
+
Write-Output $json
|