@commandgarden/cli 2.2.0 → 2.4.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/dist/main.js +1 -0
- package/node_modules/@commandgarden/app/dist/client/assets/index--IDuJWmP.js +397 -0
- package/node_modules/@commandgarden/app/dist/client/assets/index-qunCIeG9.css +1 -0
- package/node_modules/@commandgarden/app/dist/client/index.html +19 -19
- package/node_modules/@commandgarden/app/dist/server/daemon-client.test.js +47 -0
- package/node_modules/@commandgarden/app/dist/server/routes/index.js +2 -0
- package/node_modules/@commandgarden/app/dist/server/routes/routes.test.js +137 -0
- package/node_modules/@commandgarden/app/dist/server/routes/trusted-peers-cache.d.ts +3 -0
- package/node_modules/@commandgarden/app/dist/server/routes/trusted-peers-cache.js +17 -0
- package/node_modules/@commandgarden/app/dist/server/store.d.ts +5 -0
- package/node_modules/@commandgarden/app/dist/server/store.js +50 -31
- package/node_modules/@commandgarden/app/dist/server/store.test.js +59 -0
- package/node_modules/@commandgarden/app/package.json +42 -42
- package/node_modules/@commandgarden/chrome/dist/content-script.js.map +1 -1
- package/node_modules/@commandgarden/chrome/dist/fetch-interceptor.js +44 -0
- package/node_modules/@commandgarden/chrome/dist/manifest.json +16 -16
- package/node_modules/@commandgarden/chrome/dist/popup.html +218 -218
- package/node_modules/@commandgarden/chrome/dist/popup.js.map +1 -1
- package/node_modules/@commandgarden/chrome/dist/service-worker.js +2 -1
- package/node_modules/@commandgarden/chrome/dist/service-worker.js.map +2 -2
- package/node_modules/@commandgarden/chrome/package.json +25 -25
- package/node_modules/@commandgarden/daemon/connectors/ado-git-commits.eval.js +143 -143
- package/node_modules/@commandgarden/daemon/connectors/ado-git-commits.yaml +70 -70
- package/node_modules/@commandgarden/daemon/connectors/gcs-kb-content.yaml +58 -58
- package/node_modules/@commandgarden/daemon/connectors/gcs-kb-pages.yaml +47 -47
- package/node_modules/@commandgarden/daemon/connectors/jira-my-tickets.eval.js +115 -115
- package/node_modules/@commandgarden/daemon/connectors/jira-my-tickets.yaml +54 -54
- package/node_modules/@commandgarden/daemon/connectors/lib/msal-token.js +20 -20
- package/node_modules/@commandgarden/daemon/connectors/outlook-my-meetings.eval.js +186 -186
- package/node_modules/@commandgarden/daemon/connectors/outlook-my-meetings.yaml +41 -41
- package/node_modules/@commandgarden/daemon/connectors/saba-pending-training.eval.js +94 -94
- package/node_modules/@commandgarden/daemon/connectors/saba-pending-training.yaml +34 -34
- package/node_modules/@commandgarden/daemon/connectors/socket-security-news.yaml +63 -63
- package/node_modules/@commandgarden/daemon/connectors/teams-room-availability.eval.js +342 -341
- package/node_modules/@commandgarden/daemon/connectors/teams-room-availability.yaml +47 -46
- package/node_modules/@commandgarden/daemon/connectors/teams-rooms-availability.eval.js +439 -0
- package/node_modules/@commandgarden/daemon/connectors/teams-rooms-availability.yaml +48 -0
- package/node_modules/@commandgarden/daemon/connectors/timetracking-projects.eval.js +52 -52
- package/node_modules/@commandgarden/daemon/connectors/timetracking-projects.yaml +42 -42
- package/node_modules/@commandgarden/daemon/connectors/timetracking-report.eval.js +81 -81
- package/node_modules/@commandgarden/daemon/connectors/timetracking-report.yaml +52 -52
- package/node_modules/@commandgarden/daemon/connectors/tldrsec-newsletter.eval.js +27 -27
- package/node_modules/@commandgarden/daemon/connectors/tldrsec-newsletter.yaml +38 -38
- package/node_modules/@commandgarden/daemon/connectors/tokenmaster-clients-list.yaml +55 -55
- package/node_modules/@commandgarden/daemon/dist/audit-store.js +8 -8
- package/node_modules/@commandgarden/daemon/dist/cdp-client.d.ts +24 -0
- package/node_modules/@commandgarden/daemon/dist/cdp-client.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/cdp-client.js +150 -0
- package/node_modules/@commandgarden/daemon/dist/cdp-client.js.map +1 -0
- package/node_modules/@commandgarden/daemon/package.json +32 -32
- package/node_modules/@commandgarden/shared/dist/connector.d.ts +3 -0
- package/node_modules/@commandgarden/shared/dist/connector.d.ts.map +1 -1
- package/node_modules/@commandgarden/shared/dist/connector.js +1 -0
- package/node_modules/@commandgarden/shared/dist/connector.js.map +1 -1
- package/node_modules/@commandgarden/shared/package.json +32 -32
- package/package.json +58 -58
- package/node_modules/@commandgarden/app/dist/client/assets/index-Cglxej9D.css +0 -1
- package/node_modules/@commandgarden/app/dist/client/assets/index-Cju0_G1Y.js +0 -397
|
@@ -49,16 +49,16 @@ export class AppStore {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
migrate() {
|
|
52
|
-
this.db.run(`CREATE TABLE IF NOT EXISTS preferences (
|
|
53
|
-
key TEXT PRIMARY KEY,
|
|
54
|
-
value TEXT NOT NULL
|
|
52
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS preferences (
|
|
53
|
+
key TEXT PRIMARY KEY,
|
|
54
|
+
value TEXT NOT NULL
|
|
55
55
|
)`);
|
|
56
|
-
this.db.run(`CREATE TABLE IF NOT EXISTS saved_views (
|
|
57
|
-
id TEXT PRIMARY KEY,
|
|
58
|
-
app TEXT NOT NULL,
|
|
59
|
-
name TEXT NOT NULL,
|
|
60
|
-
config TEXT NOT NULL,
|
|
61
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
56
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS saved_views (
|
|
57
|
+
id TEXT PRIMARY KEY,
|
|
58
|
+
app TEXT NOT NULL,
|
|
59
|
+
name TEXT NOT NULL,
|
|
60
|
+
config TEXT NOT NULL,
|
|
61
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
62
62
|
)`);
|
|
63
63
|
// Drop legacy goals table (had category column) and recreate with activity
|
|
64
64
|
try {
|
|
@@ -76,31 +76,36 @@ export class AppStore {
|
|
|
76
76
|
}
|
|
77
77
|
catch { /* ignore */ }
|
|
78
78
|
}
|
|
79
|
-
this.db.run(`CREATE TABLE IF NOT EXISTS goals (
|
|
80
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
81
|
-
month TEXT NOT NULL,
|
|
82
|
-
project_id TEXT NOT NULL,
|
|
83
|
-
activity TEXT NOT NULL DEFAULT '',
|
|
84
|
-
target_days REAL NOT NULL,
|
|
85
|
-
target_hours REAL NOT NULL,
|
|
86
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
87
|
-
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
88
|
-
UNIQUE(month, project_id, activity)
|
|
79
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS goals (
|
|
80
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
81
|
+
month TEXT NOT NULL,
|
|
82
|
+
project_id TEXT NOT NULL,
|
|
83
|
+
activity TEXT NOT NULL DEFAULT '',
|
|
84
|
+
target_days REAL NOT NULL,
|
|
85
|
+
target_hours REAL NOT NULL,
|
|
86
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
87
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
88
|
+
UNIQUE(month, project_id, activity)
|
|
89
89
|
)`);
|
|
90
|
-
this.db.run(`CREATE TABLE IF NOT EXISTS report_cache (
|
|
91
|
-
month TEXT PRIMARY KEY,
|
|
92
|
-
data TEXT NOT NULL,
|
|
93
|
-
fetched_at TEXT NOT NULL
|
|
90
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS report_cache (
|
|
91
|
+
month TEXT PRIMARY KEY,
|
|
92
|
+
data TEXT NOT NULL,
|
|
93
|
+
fetched_at TEXT NOT NULL
|
|
94
94
|
)`);
|
|
95
|
-
this.db.run(`CREATE TABLE IF NOT EXISTS projects_cache (
|
|
96
|
-
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
97
|
-
data TEXT NOT NULL,
|
|
98
|
-
fetched_at TEXT NOT NULL
|
|
95
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS projects_cache (
|
|
96
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
97
|
+
data TEXT NOT NULL,
|
|
98
|
+
fetched_at TEXT NOT NULL
|
|
99
99
|
)`);
|
|
100
|
-
this.db.run(`CREATE TABLE IF NOT EXISTS security_news_cache (
|
|
101
|
-
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
102
|
-
data TEXT NOT NULL,
|
|
103
|
-
fetched_at TEXT NOT NULL
|
|
100
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS security_news_cache (
|
|
101
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
102
|
+
data TEXT NOT NULL,
|
|
103
|
+
fetched_at TEXT NOT NULL
|
|
104
|
+
)`);
|
|
105
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS trusted_peers_cache (
|
|
106
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
107
|
+
data TEXT NOT NULL,
|
|
108
|
+
fetched_at TEXT NOT NULL
|
|
104
109
|
)`);
|
|
105
110
|
}
|
|
106
111
|
getPreference(key) {
|
|
@@ -200,6 +205,20 @@ export class AppStore {
|
|
|
200
205
|
fetchedAt: rows[0].fetched_at,
|
|
201
206
|
};
|
|
202
207
|
}
|
|
208
|
+
cacheTrustedPeers(data) {
|
|
209
|
+
const now = new Date().toISOString();
|
|
210
|
+
this.db.run('INSERT OR REPLACE INTO trusted_peers_cache (id, data, fetched_at) VALUES (1, ?, ?)', [JSON.stringify(data), now]);
|
|
211
|
+
this.persist();
|
|
212
|
+
}
|
|
213
|
+
getCachedTrustedPeers() {
|
|
214
|
+
const rows = this.query('SELECT data, fetched_at FROM trusted_peers_cache WHERE id = 1');
|
|
215
|
+
if (rows.length === 0)
|
|
216
|
+
return null;
|
|
217
|
+
return {
|
|
218
|
+
data: JSON.parse(rows[0].data),
|
|
219
|
+
fetchedAt: rows[0].fetched_at,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
203
222
|
cacheSecurityNews(data) {
|
|
204
223
|
const now = new Date().toISOString();
|
|
205
224
|
this.db.run('INSERT OR REPLACE INTO security_news_cache (id, data, fetched_at) VALUES (1, ?, ?)', [JSON.stringify(data), now]);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { AppStore } from './store.js';
|
|
3
|
+
describe('AppStore', () => {
|
|
4
|
+
let store;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
store = new AppStore(':memory:');
|
|
7
|
+
});
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
store.close();
|
|
10
|
+
});
|
|
11
|
+
describe('preferences', () => {
|
|
12
|
+
it('returns undefined for missing key', () => {
|
|
13
|
+
expect(store.getPreference('missing')).toBeUndefined();
|
|
14
|
+
});
|
|
15
|
+
it('sets and gets a preference', () => {
|
|
16
|
+
store.setPreference('theme', 'light');
|
|
17
|
+
expect(store.getPreference('theme')).toBe('light');
|
|
18
|
+
});
|
|
19
|
+
it('overwrites existing preference', () => {
|
|
20
|
+
store.setPreference('theme', 'light');
|
|
21
|
+
store.setPreference('theme', 'dark');
|
|
22
|
+
expect(store.getPreference('theme')).toBe('dark');
|
|
23
|
+
});
|
|
24
|
+
it('returns all preferences', () => {
|
|
25
|
+
store.setPreference('a', '1');
|
|
26
|
+
store.setPreference('b', '2');
|
|
27
|
+
expect(store.getAllPreferences()).toEqual({ a: '1', b: '2' });
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe('saved views', () => {
|
|
31
|
+
it('returns empty array when no views', () => {
|
|
32
|
+
expect(store.listViews('timetracking')).toEqual([]);
|
|
33
|
+
});
|
|
34
|
+
it('creates and lists a view', () => {
|
|
35
|
+
const view = store.createView('timetracking', 'June report', '{"month":"2026-06"}');
|
|
36
|
+
expect(view.id).toBeDefined();
|
|
37
|
+
expect(view.app).toBe('timetracking');
|
|
38
|
+
expect(view.name).toBe('June report');
|
|
39
|
+
expect(view.config).toBe('{"month":"2026-06"}');
|
|
40
|
+
const views = store.listViews('timetracking');
|
|
41
|
+
expect(views).toHaveLength(1);
|
|
42
|
+
expect(views[0].name).toBe('June report');
|
|
43
|
+
});
|
|
44
|
+
it('filters views by app', () => {
|
|
45
|
+
store.createView('timetracking', 'View A', '{}');
|
|
46
|
+
store.createView('rooms', 'View B', '{}');
|
|
47
|
+
expect(store.listViews('timetracking')).toHaveLength(1);
|
|
48
|
+
expect(store.listViews('rooms')).toHaveLength(1);
|
|
49
|
+
});
|
|
50
|
+
it('deletes a view', () => {
|
|
51
|
+
const view = store.createView('timetracking', 'To delete', '{}');
|
|
52
|
+
expect(store.deleteView(view.id)).toBe(true);
|
|
53
|
+
expect(store.listViews('timetracking')).toHaveLength(0);
|
|
54
|
+
});
|
|
55
|
+
it('returns false when deleting non-existent view', () => {
|
|
56
|
+
expect(store.deleteView('nonexistent')).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@commandgarden/app",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "vite build && tsc -p tsconfig.server.json",
|
|
11
|
-
"dev": "concurrently \"vite\" \"tsx watch src/server/main.ts\"",
|
|
12
|
-
"start": "node dist/server/main.js",
|
|
13
|
-
"test": "vitest run",
|
|
14
|
-
"test:watch": "vitest"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@commandgarden/shared": "*",
|
|
18
|
-
"@fastify/static": "^8.0.0",
|
|
19
|
-
"fastify": "^5.0.0",
|
|
20
|
-
"lucide-react": "^1.23.0",
|
|
21
|
-
"react": "^18.3.0",
|
|
22
|
-
"react-dom": "^18.3.0",
|
|
23
|
-
"react-router-dom": "^6.23.0",
|
|
24
|
-
"sql.js": "^1.11.0",
|
|
25
|
-
"yaml": "^2.4.0"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/node": "^22.0.0",
|
|
29
|
-
"@types/react": "^18.3.0",
|
|
30
|
-
"@types/react-dom": "^18.3.0",
|
|
31
|
-
"@vitejs/plugin-react": "^4.3.0",
|
|
32
|
-
"autoprefixer": "^10.4.0",
|
|
33
|
-
"concurrently": "^9.0.0",
|
|
34
|
-
"daisyui": "^4.12.0",
|
|
35
|
-
"postcss": "^8.4.0",
|
|
36
|
-
"tailwindcss": "^3.4.0",
|
|
37
|
-
"tsx": "^4.0.0",
|
|
38
|
-
"typescript": "^5.4.0",
|
|
39
|
-
"vite": "^5.4.0",
|
|
40
|
-
"vitest": "^2.0.0"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@commandgarden/app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "vite build && tsc -p tsconfig.server.json",
|
|
11
|
+
"dev": "concurrently \"vite\" \"tsx watch src/server/main.ts\"",
|
|
12
|
+
"start": "node dist/server/main.js",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@commandgarden/shared": "*",
|
|
18
|
+
"@fastify/static": "^8.0.0",
|
|
19
|
+
"fastify": "^5.0.0",
|
|
20
|
+
"lucide-react": "^1.23.0",
|
|
21
|
+
"react": "^18.3.0",
|
|
22
|
+
"react-dom": "^18.3.0",
|
|
23
|
+
"react-router-dom": "^6.23.0",
|
|
24
|
+
"sql.js": "^1.11.0",
|
|
25
|
+
"yaml": "^2.4.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.0.0",
|
|
29
|
+
"@types/react": "^18.3.0",
|
|
30
|
+
"@types/react-dom": "^18.3.0",
|
|
31
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
32
|
+
"autoprefixer": "^10.4.0",
|
|
33
|
+
"concurrently": "^9.0.0",
|
|
34
|
+
"daisyui": "^4.12.0",
|
|
35
|
+
"postcss": "^8.4.0",
|
|
36
|
+
"tailwindcss": "^3.4.0",
|
|
37
|
+
"tsx": "^4.0.0",
|
|
38
|
+
"typescript": "^5.4.0",
|
|
39
|
+
"vite": "^5.4.0",
|
|
40
|
+
"vitest": "^2.0.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/messages.ts", "../src/content/dom-executor.ts", "../src/content/content-script.ts"],
|
|
4
|
-
"sourcesContent": ["// src/messages.ts\
|
|
4
|
+
"sourcesContent": ["// src/messages.ts\nconst randomUUID = () => crypto.randomUUID();\n\nexport type DomAction = 'wait' | 'extract' | 'extract_tree' | 'extract_html' | 'click' | 'click_all' | 'type' | 'fetch';\n\nexport interface DomRequest {\n id: string;\n action: DomAction;\n params: Record<string, unknown>;\n}\n\nexport interface DomResponse {\n requestId: string;\n ok: boolean;\n data?: unknown;\n error?: string;\n}\n\nexport function createDomRequest(action: DomAction, params: Record<string, unknown>): DomRequest {\n return { id: randomUUID(), action, params };\n}\n\nexport function createDomResponse(\n requestId: string, ok: boolean, data?: unknown, error?: string,\n): DomResponse {\n return { requestId, ok, data, error };\n}\n\nexport function isDomRequest(value: unknown): value is DomRequest {\n if (value == null || typeof value !== 'object') return false;\n const obj = value as Record<string, unknown>;\n return typeof obj.id === 'string' && typeof obj.action === 'string' && typeof obj.params === 'object';\n}\n\nexport function isDomResponse(value: unknown): value is DomResponse {\n if (value == null || typeof value !== 'object') return false;\n const obj = value as Record<string, unknown>;\n return typeof obj.requestId === 'string' && typeof obj.ok === 'boolean';\n}\n", "// src/content/dom-executor.ts\n\nexport function waitForSelector(selector: string, timeout: number): Promise<void> {\n return new Promise((resolve, reject) => {\n if (document.querySelector(selector)) { resolve(); return; }\n const interval = 100;\n let elapsed = 0;\n const timer = setInterval(() => {\n if (document.querySelector(selector)) { clearInterval(timer); resolve(); return; }\n elapsed += interval;\n if (elapsed >= timeout) {\n clearInterval(timer);\n reject(new Error(`Selector \"${selector}\" timed out after ${timeout}ms`));\n }\n }, interval);\n });\n}\n\nexport function extractData(\n rowSelector: string,\n fields: Record<string, string>,\n): Record<string, string>[] {\n const rows = document.querySelectorAll(rowSelector);\n return Array.from(rows).map(row => {\n const record: Record<string, string> = {};\n for (const [name, selector] of Object.entries(fields)) {\n record[name] = row.querySelector(selector)?.textContent?.trim() ?? '';\n }\n return record;\n });\n}\n\nexport function extractHtml(selector: string): string {\n const el = document.querySelector(selector);\n if (!el) throw new Error(`Element \"${selector}\" not found`);\n return el.innerHTML;\n}\n\nexport function extractTree(\n rootSelector: string,\n group: { match: string; title: string; children: string },\n leaf: { match: string; fields: Record<string, string> },\n pathSeparator: string,\n): Record<string, unknown>[] {\n const root = document.querySelector(rootSelector);\n if (!root) throw new Error(`Root \"${rootSelector}\" not found`);\n\n function extractField(el: Element, spec: string): string {\n if (spec === 'textContent') return el.textContent?.trim().replace(/\\s+/g, ' ') ?? '';\n if (spec === 'href') return el.getAttribute('href') ?? '';\n if (spec.startsWith('attr:')) return el.getAttribute(spec.slice(5)) ?? '';\n return el.textContent?.trim() ?? '';\n }\n\n function walk(container: Element, ancestors: string[], depth: number): Record<string, unknown>[] {\n const results: Record<string, unknown>[] = [];\n for (const child of Array.from(container.children)) {\n if (child.matches(leaf.match)) {\n const row: Record<string, unknown> = {};\n for (const [name, spec] of Object.entries(leaf.fields)) {\n row[name] = extractField(child, spec);\n }\n const title = (row.title as string) || child.textContent?.trim() || '';\n const section = ancestors.length > 0 ? ancestors[0] : title;\n const pathParts = [...ancestors, title];\n row.section = section;\n row.path = pathParts.join(pathSeparator);\n row.depth = depth;\n results.push(row);\n } else if (child.matches(group.match)) {\n const titleEl = child.querySelector(group.title);\n const groupTitle = titleEl?.textContent?.trim().replace(/\\s+/g, ' ') ?? '';\n const childContainer = child.querySelector(group.children);\n if (childContainer) {\n results.push(...walk(childContainer, [...ancestors, groupTitle], depth + 1));\n }\n } else {\n results.push(...walk(child, ancestors, depth));\n }\n }\n return results;\n }\n\n return walk(root, [], 0);\n}\n\nexport async function clickAll(\n selector: string, pause: number, maxRounds: number, settle: number,\n): Promise<void> {\n for (let round = 0; round < maxRounds; round++) {\n const elements = document.querySelectorAll(selector);\n if (elements.length === 0) break;\n for (const el of Array.from(elements)) {\n (el as HTMLElement).click();\n if (pause > 0) await new Promise(r => setTimeout(r, pause));\n }\n }\n if (settle > 0) await new Promise(r => setTimeout(r, settle));\n}\n\nexport async function clickElement(selector: string): Promise<void> {\n const el = document.querySelector(selector);\n if (!el) throw new Error(`Element \"${selector}\" not found`);\n (el as HTMLElement).click();\n}\n\nexport async function typeIntoElement(selector: string, value: string): Promise<void> {\n const el = document.querySelector(selector) as HTMLInputElement | null;\n if (!el) throw new Error(`Element \"${selector}\" not found`);\n el.focus();\n el.value = value;\n el.dispatchEvent(new Event('input', { bubbles: true }));\n el.dispatchEvent(new Event('change', { bubbles: true }));\n}\n\nexport async function fetchFromPage(\n url: string, method = 'GET', headers?: Record<string, string>, body?: string,\n): Promise<unknown> {\n const resp = await fetch(url, {\n method, headers, body, credentials: 'include',\n });\n const contentType = resp.headers.get('content-type') ?? '';\n if (contentType.includes('application/json')) return resp.json();\n return resp.text();\n}\n", "// src/content/content-script.ts\nimport { isDomRequest, createDomResponse, type DomRequest } from '../messages.js';\nimport { waitForSelector, extractData, extractHtml, extractTree, clickElement, clickAll, typeIntoElement, fetchFromPage } from './dom-executor.js';\n\nchrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {\n if (!isDomRequest(message)) return false;\n const req = message as DomRequest;\n handleRequest(req).then(\n (data) => sendResponse(createDomResponse(req.id, true, data)),\n (err) => sendResponse(createDomResponse(req.id, false, undefined, err.message)),\n );\n return true; // Keep channel open for async response\n});\n\nasync function handleRequest(req: DomRequest): Promise<unknown> {\n const p = req.params;\n switch (req.action) {\n case 'wait':\n await waitForSelector(p.selector as string, (p.timeout as number) ?? 10000);\n return undefined;\n case 'extract':\n return extractData(p.selector as string, p.fields as Record<string, string>);\n case 'extract_html':\n return extractHtml(p.selector as string);\n case 'extract_tree':\n return extractTree(\n p.root as string,\n p.group as { match: string; title: string; children: string },\n p.leaf as { match: string; fields: Record<string, string> },\n (p.pathSeparator as string) ?? ' / ',\n );\n case 'click':\n await clickElement(p.selector as string);\n return undefined;\n case 'click_all':\n await clickAll(\n p.selector as string,\n (p.pause as number) ?? 200,\n (p.maxRounds as number) ?? 10,\n (p.settle as number) ?? 300,\n );\n return undefined;\n case 'type':\n await typeIntoElement(p.selector as string, p.value as string);\n return undefined;\n case 'fetch': {\n const result = await fetchFromPage(\n p.url as string, p.method as string,\n p.headers as Record<string, string>, p.body as string,\n );\n if (p.dataPath && result != null && typeof result === 'object' && !Array.isArray(result)) {\n let nested: unknown = result;\n for (const key of (p.dataPath as string).split('.')) {\n if (nested == null || typeof nested !== 'object') return [];\n nested = (nested as Record<string, unknown>)[key];\n }\n return Array.isArray(nested) ? nested : [];\n }\n return result;\n }\n default:\n throw new Error(`Unknown action: ${req.action}`);\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;AAsBO,WAAS,kBACd,WAAmB,IAAa,MAAgB,OACnC;AACb,WAAO,EAAE,WAAW,IAAI,MAAM,MAAM;AAAA,EACtC;AAEO,WAAS,aAAa,OAAqC;AAChE,QAAI,SAAS,QAAQ,OAAO,UAAU,SAAU,QAAO;AACvD,UAAM,MAAM;AACZ,WAAO,OAAO,IAAI,OAAO,YAAY,OAAO,IAAI,WAAW,YAAY,OAAO,IAAI,WAAW;AAAA,EAC/F;;;AC9BO,WAAS,gBAAgB,UAAkB,SAAgC;AAChF,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAI,SAAS,cAAc,QAAQ,GAAG;AAAE,gBAAQ;AAAG;AAAA,MAAQ;AAC3D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AAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC;AAAA,QAC3C;AACA,eAAO;AAAA,MACT;AAAA,MACA;AACE,cAAM,IAAI,MAAM,mBAAmB,IAAI,MAAM,EAAE;AAAA,IACnD;AAAA,EACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// fetch-interceptor.js — injected at document_start in MAIN world.
|
|
2
|
+
// Patches window.fetch BEFORE OWA's modules capture a reference to it.
|
|
3
|
+
// Minimal — only the fetch patch, nothing else.
|
|
4
|
+
(function () {
|
|
5
|
+
if (window.__rfb) return;
|
|
6
|
+
window.__rfb = [];
|
|
7
|
+
window.__rfb_urls = [];
|
|
8
|
+
|
|
9
|
+
// Intercept Service Worker messages — OWA sends getSchedule data
|
|
10
|
+
// from the SW to the page via postMessage, bypassing window.fetch.
|
|
11
|
+
if (navigator.serviceWorker) {
|
|
12
|
+
navigator.serviceWorker.addEventListener('message', function (e) {
|
|
13
|
+
try {
|
|
14
|
+
var str = typeof e.data === 'string' ? e.data : JSON.stringify(e.data);
|
|
15
|
+
if (str.indexOf('getSchedule') > -1 && str.indexOf('availabilityView') > -1) {
|
|
16
|
+
window.__rfb.push({ req: '', body: str });
|
|
17
|
+
}
|
|
18
|
+
} catch (_e) { /* ignore */ }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var origFetch = window.fetch;
|
|
23
|
+
window.fetch = function () {
|
|
24
|
+
var a = arguments;
|
|
25
|
+
var u = (a[0] && a[0].url) || a[0] || '';
|
|
26
|
+
var rb = (a[1] && a[1].body) || '';
|
|
27
|
+
var uStr = String(u);
|
|
28
|
+
if (window.__rfb_urls.length < 100) {
|
|
29
|
+
window.__rfb_urls.push(uStr.slice(0, 120));
|
|
30
|
+
}
|
|
31
|
+
return origFetch.apply(this, a).then(function (r) {
|
|
32
|
+
try {
|
|
33
|
+
if (uStr.indexOf('graphql') > -1) {
|
|
34
|
+
r.clone().text().then(function (t) {
|
|
35
|
+
if (t.indexOf('getSchedule') > -1 && t.indexOf('availabilityView') > -1) {
|
|
36
|
+
window.__rfb.push({ req: String(rb || ''), body: t });
|
|
37
|
+
}
|
|
38
|
+
}).catch(function () {});
|
|
39
|
+
}
|
|
40
|
+
} catch (_e) { /* ignore */ }
|
|
41
|
+
return r;
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"manifest_version": 3,
|
|
3
|
-
"name": "commandGarden",
|
|
4
|
-
"version": "0.1.0",
|
|
5
|
-
"description": "Enterprise browser automation — secure, auditable CLI commands for websites",
|
|
6
|
-
"minimum_chrome_version": "116",
|
|
7
|
-
"permissions": ["alarms", "cookies", "debugger", "idle", "tabs", "scripting", "webRequest", "storage"],
|
|
8
|
-
"host_permissions": ["<all_urls>"],
|
|
9
|
-
"background": {
|
|
10
|
-
"service_worker": "service-worker.js",
|
|
11
|
-
"type": "module"
|
|
12
|
-
},
|
|
13
|
-
"action": {
|
|
14
|
-
"default_popup": "popup.html"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "commandGarden",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Enterprise browser automation — secure, auditable CLI commands for websites",
|
|
6
|
+
"minimum_chrome_version": "116",
|
|
7
|
+
"permissions": ["alarms", "cookies", "debugger", "idle", "tabs", "scripting", "webRequest", "storage"],
|
|
8
|
+
"host_permissions": ["<all_urls>"],
|
|
9
|
+
"background": {
|
|
10
|
+
"service_worker": "service-worker.js",
|
|
11
|
+
"type": "module"
|
|
12
|
+
},
|
|
13
|
+
"action": {
|
|
14
|
+
"default_popup": "popup.html"
|
|
15
|
+
}
|
|
16
|
+
}
|