@dgxo/mashadevcli 1.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.
- package/LICENSE +202 -0
- package/README.md +393 -0
- package/bundle/builtin/skill-creator/SKILL.md +382 -0
- package/bundle/builtin/skill-creator/scripts/init_skill.cjs +239 -0
- package/bundle/builtin/skill-creator/scripts/package_skill.cjs +131 -0
- package/bundle/builtin/skill-creator/scripts/validate_skill.cjs +131 -0
- package/bundle/docs/CONTRIBUTING.md +1 -0
- package/bundle/docs/admin/enterprise-controls.md +115 -0
- package/bundle/docs/assets/connected_devtools.png +0 -0
- package/bundle/docs/assets/gemini-screenshot.png +0 -0
- package/bundle/docs/assets/monitoring-dashboard-logs.png +0 -0
- package/bundle/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/bundle/docs/assets/monitoring-dashboard-overview.png +0 -0
- package/bundle/docs/assets/release_patch.png +0 -0
- package/bundle/docs/assets/theme-ansi-light.png +0 -0
- package/bundle/docs/assets/theme-ansi.png +0 -0
- package/bundle/docs/assets/theme-atom-one.png +0 -0
- package/bundle/docs/assets/theme-ayu-light.png +0 -0
- package/bundle/docs/assets/theme-ayu.png +0 -0
- package/bundle/docs/assets/theme-custom.png +0 -0
- package/bundle/docs/assets/theme-default-light.png +0 -0
- package/bundle/docs/assets/theme-default.png +0 -0
- package/bundle/docs/assets/theme-dracula.png +0 -0
- package/bundle/docs/assets/theme-github-light.png +0 -0
- package/bundle/docs/assets/theme-github.png +0 -0
- package/bundle/docs/assets/theme-google-light.png +0 -0
- package/bundle/docs/assets/theme-xcode-light.png +0 -0
- package/bundle/docs/changelogs/index.md +867 -0
- package/bundle/docs/changelogs/latest.md +208 -0
- package/bundle/docs/changelogs/preview.md +187 -0
- package/bundle/docs/cli/checkpointing.md +93 -0
- package/bundle/docs/cli/cli-reference.md +115 -0
- package/bundle/docs/cli/creating-skills.md +80 -0
- package/bundle/docs/cli/custom-commands.md +327 -0
- package/bundle/docs/cli/enterprise.md +604 -0
- package/bundle/docs/cli/gemini-ignore.md +71 -0
- package/bundle/docs/cli/gemini-md.md +116 -0
- package/bundle/docs/cli/generation-settings.md +210 -0
- package/bundle/docs/cli/headless.md +50 -0
- package/bundle/docs/cli/model-routing.md +42 -0
- package/bundle/docs/cli/model.md +53 -0
- package/bundle/docs/cli/plan-mode.md +375 -0
- package/bundle/docs/cli/rewind.md +51 -0
- package/bundle/docs/cli/sandbox.md +257 -0
- package/bundle/docs/cli/session-management.md +184 -0
- package/bundle/docs/cli/settings.md +165 -0
- package/bundle/docs/cli/skills.md +134 -0
- package/bundle/docs/cli/system-prompt.md +125 -0
- package/bundle/docs/cli/telemetry.md +922 -0
- package/bundle/docs/cli/themes.md +269 -0
- package/bundle/docs/cli/token-caching.md +20 -0
- package/bundle/docs/cli/trusted-folders.md +126 -0
- package/bundle/docs/cli/tutorials/automation.md +283 -0
- package/bundle/docs/cli/tutorials/file-management.md +142 -0
- package/bundle/docs/cli/tutorials/mcp-setup.md +113 -0
- package/bundle/docs/cli/tutorials/memory-management.md +126 -0
- package/bundle/docs/cli/tutorials/session-management.md +105 -0
- package/bundle/docs/cli/tutorials/shell-commands.md +107 -0
- package/bundle/docs/cli/tutorials/skills-getting-started.md +110 -0
- package/bundle/docs/cli/tutorials/task-planning.md +93 -0
- package/bundle/docs/cli/tutorials/web-tools.md +78 -0
- package/bundle/docs/core/index.md +107 -0
- package/bundle/docs/core/remote-agents.md +84 -0
- package/bundle/docs/core/subagents.md +307 -0
- package/bundle/docs/examples/proxy-script.md +83 -0
- package/bundle/docs/extensions/best-practices.md +188 -0
- package/bundle/docs/extensions/index.md +61 -0
- package/bundle/docs/extensions/reference.md +333 -0
- package/bundle/docs/extensions/releasing.md +154 -0
- package/bundle/docs/extensions/writing-extensions.md +308 -0
- package/bundle/docs/get-started/authentication.md +402 -0
- package/bundle/docs/get-started/examples.md +139 -0
- package/bundle/docs/get-started/gemini-3.md +115 -0
- package/bundle/docs/get-started/index.md +82 -0
- package/bundle/docs/get-started/installation.md +174 -0
- package/bundle/docs/hooks/best-practices.md +709 -0
- package/bundle/docs/hooks/index.md +164 -0
- package/bundle/docs/hooks/reference.md +330 -0
- package/bundle/docs/hooks/writing-hooks.md +474 -0
- package/bundle/docs/ide-integration/ide-companion-spec.md +267 -0
- package/bundle/docs/ide-integration/index.md +224 -0
- package/bundle/docs/index.md +141 -0
- package/bundle/docs/integration-tests.md +211 -0
- package/bundle/docs/issue-and-pr-automation.md +172 -0
- package/bundle/docs/local-development.md +134 -0
- package/bundle/docs/mermaid/context.mmd +103 -0
- package/bundle/docs/mermaid/render-path.mmd +64 -0
- package/bundle/docs/npm.md +62 -0
- package/bundle/docs/redirects.json +20 -0
- package/bundle/docs/reference/commands.md +526 -0
- package/bundle/docs/reference/configuration.md +1786 -0
- package/bundle/docs/reference/keyboard-shortcuts.md +164 -0
- package/bundle/docs/reference/memport.md +246 -0
- package/bundle/docs/reference/policy-engine.md +364 -0
- package/bundle/docs/reference/tools.md +106 -0
- package/bundle/docs/release-confidence.md +164 -0
- package/bundle/docs/releases.md +540 -0
- package/bundle/docs/resources/faq.md +175 -0
- package/bundle/docs/resources/quota-and-pricing.md +165 -0
- package/bundle/docs/resources/tos-privacy.md +102 -0
- package/bundle/docs/resources/troubleshooting.md +176 -0
- package/bundle/docs/resources/uninstall.md +56 -0
- package/bundle/docs/sidebar.json +233 -0
- package/bundle/docs/tools/activate-skill.md +43 -0
- package/bundle/docs/tools/ask-user.md +95 -0
- package/bundle/docs/tools/file-system.md +129 -0
- package/bundle/docs/tools/internal-docs.md +46 -0
- package/bundle/docs/tools/mcp-server.md +1150 -0
- package/bundle/docs/tools/memory.md +35 -0
- package/bundle/docs/tools/planning.md +58 -0
- package/bundle/docs/tools/shell.md +216 -0
- package/bundle/docs/tools/todos.md +35 -0
- package/bundle/docs/tools/web-fetch.md +35 -0
- package/bundle/docs/tools/web-search.md +32 -0
- package/bundle/docs/update/update-guide.md +111 -0
- package/bundle/masha.js +563471 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/client/main.js +89 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.d.ts +7 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js +9 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js.map +1 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.d.ts +48 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js +299 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js.map +1 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.d.ts +36 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js +7 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js.map +1 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/package.json +32 -0
- package/bundle/policies/conseca.toml +6 -0
- package/bundle/policies/discovered.toml +8 -0
- package/bundle/policies/plan.toml +109 -0
- package/bundle/policies/read-only.toml +53 -0
- package/bundle/policies/write.toml +80 -0
- package/bundle/policies/yolo.toml +54 -0
- package/bundle/sandbox-macos-permissive-open.sb +27 -0
- package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
- package/bundle/sandbox-macos-restrictive-open.sb +96 -0
- package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
- package/bundle/sandbox-macos-strict-open.sb +131 -0
- package/bundle/sandbox-macos-strict-proxied.sb +133 -0
- package/package.json +169 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_client-assets.js","sourceRoot":"","sources":["../../src/_client-assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,ynBAAynB,CAAC;AACppB,MAAM,CAAC,MAAM,SAAS,GAAG,i45NAAi45N,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventEmitter } from 'node:events';
|
|
7
|
+
import { type WebSocket } from 'ws';
|
|
8
|
+
import type { NetworkLog, ConsoleLogPayload } from './types.js';
|
|
9
|
+
export type { NetworkLog, ConsoleLogPayload, InspectorConsoleLog, } from './types.js';
|
|
10
|
+
interface IncomingNetworkPayload extends Partial<NetworkLog> {
|
|
11
|
+
chunk?: {
|
|
12
|
+
index: number;
|
|
13
|
+
data: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface SessionInfo {
|
|
18
|
+
sessionId: string;
|
|
19
|
+
ws: WebSocket;
|
|
20
|
+
lastPing: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* DevTools Viewer
|
|
24
|
+
*
|
|
25
|
+
* Receives logs via WebSocket from CLI sessions.
|
|
26
|
+
*/
|
|
27
|
+
export declare class DevTools extends EventEmitter {
|
|
28
|
+
private static instance;
|
|
29
|
+
private logs;
|
|
30
|
+
private consoleLogs;
|
|
31
|
+
private server;
|
|
32
|
+
private wss;
|
|
33
|
+
private sessions;
|
|
34
|
+
private heartbeatTimer;
|
|
35
|
+
private port;
|
|
36
|
+
private static readonly DEFAULT_PORT;
|
|
37
|
+
private static readonly MAX_PORT_RETRIES;
|
|
38
|
+
private constructor();
|
|
39
|
+
static getInstance(): DevTools;
|
|
40
|
+
addInternalConsoleLog(payload: ConsoleLogPayload, sessionId?: string, timestamp?: number): void;
|
|
41
|
+
addInternalNetworkLog(payload: IncomingNetworkPayload, sessionId?: string, timestamp?: number): void;
|
|
42
|
+
getUrl(): string;
|
|
43
|
+
getPort(): number;
|
|
44
|
+
stop(): Promise<void>;
|
|
45
|
+
start(): Promise<string>;
|
|
46
|
+
private setupWebSocketServer;
|
|
47
|
+
private handleWebSocketMessage;
|
|
48
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import http from 'node:http';
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { EventEmitter } from 'node:events';
|
|
9
|
+
import { WebSocketServer } from 'ws';
|
|
10
|
+
import { INDEX_HTML, CLIENT_JS } from './_client-assets.js';
|
|
11
|
+
/**
|
|
12
|
+
* DevTools Viewer
|
|
13
|
+
*
|
|
14
|
+
* Receives logs via WebSocket from CLI sessions.
|
|
15
|
+
*/
|
|
16
|
+
export class DevTools extends EventEmitter {
|
|
17
|
+
static instance;
|
|
18
|
+
logs = [];
|
|
19
|
+
consoleLogs = [];
|
|
20
|
+
server = null;
|
|
21
|
+
wss = null;
|
|
22
|
+
sessions = new Map();
|
|
23
|
+
heartbeatTimer = null;
|
|
24
|
+
port = 25417;
|
|
25
|
+
static DEFAULT_PORT = 25417;
|
|
26
|
+
static MAX_PORT_RETRIES = 10;
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
// Each SSE client adds 3 listeners; raise the limit to avoid warnings
|
|
30
|
+
this.setMaxListeners(50);
|
|
31
|
+
}
|
|
32
|
+
static getInstance() {
|
|
33
|
+
if (!DevTools.instance) {
|
|
34
|
+
DevTools.instance = new DevTools();
|
|
35
|
+
}
|
|
36
|
+
return DevTools.instance;
|
|
37
|
+
}
|
|
38
|
+
addInternalConsoleLog(payload, sessionId, timestamp) {
|
|
39
|
+
const entry = {
|
|
40
|
+
...payload,
|
|
41
|
+
id: randomUUID(),
|
|
42
|
+
sessionId,
|
|
43
|
+
timestamp: timestamp || Date.now(),
|
|
44
|
+
};
|
|
45
|
+
this.consoleLogs.push(entry);
|
|
46
|
+
if (this.consoleLogs.length > 5000)
|
|
47
|
+
this.consoleLogs.shift();
|
|
48
|
+
this.emit('console-update', entry);
|
|
49
|
+
}
|
|
50
|
+
addInternalNetworkLog(payload, sessionId, timestamp) {
|
|
51
|
+
if (!payload.id)
|
|
52
|
+
return;
|
|
53
|
+
const existingIndex = this.logs.findIndex((l) => l.id === payload.id);
|
|
54
|
+
if (existingIndex > -1) {
|
|
55
|
+
const existing = this.logs[existingIndex];
|
|
56
|
+
// Handle chunk accumulation
|
|
57
|
+
if (payload.chunk) {
|
|
58
|
+
const chunks = existing.chunks || [];
|
|
59
|
+
chunks.push(payload.chunk);
|
|
60
|
+
this.logs[existingIndex] = {
|
|
61
|
+
...existing,
|
|
62
|
+
chunks,
|
|
63
|
+
sessionId: sessionId || existing.sessionId,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.logs[existingIndex] = {
|
|
68
|
+
...existing,
|
|
69
|
+
...payload,
|
|
70
|
+
sessionId: sessionId || existing.sessionId,
|
|
71
|
+
// Drop chunks once we have the full response body — the data
|
|
72
|
+
// is redundant and keeping both can blow past V8's string limit
|
|
73
|
+
// when serializing the snapshot.
|
|
74
|
+
chunks: payload.response?.body ? undefined : existing.chunks,
|
|
75
|
+
response: payload.response
|
|
76
|
+
? { ...existing.response, ...payload.response }
|
|
77
|
+
: existing.response,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
this.emit('update', this.logs[existingIndex]);
|
|
81
|
+
}
|
|
82
|
+
else if (payload.url) {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
84
|
+
const entry = {
|
|
85
|
+
...payload,
|
|
86
|
+
sessionId,
|
|
87
|
+
timestamp: timestamp || Date.now(),
|
|
88
|
+
chunks: payload.chunk ? [payload.chunk] : undefined,
|
|
89
|
+
};
|
|
90
|
+
this.logs.push(entry);
|
|
91
|
+
if (this.logs.length > 2000)
|
|
92
|
+
this.logs.shift();
|
|
93
|
+
this.emit('update', entry);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
getUrl() {
|
|
97
|
+
return `http://127.0.0.1:${this.port}`;
|
|
98
|
+
}
|
|
99
|
+
getPort() {
|
|
100
|
+
return this.port;
|
|
101
|
+
}
|
|
102
|
+
stop() {
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
if (this.heartbeatTimer) {
|
|
105
|
+
clearInterval(this.heartbeatTimer);
|
|
106
|
+
this.heartbeatTimer = null;
|
|
107
|
+
}
|
|
108
|
+
if (this.wss) {
|
|
109
|
+
this.wss.close();
|
|
110
|
+
this.wss = null;
|
|
111
|
+
}
|
|
112
|
+
if (this.server) {
|
|
113
|
+
this.server.close(() => resolve());
|
|
114
|
+
this.server = null;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
resolve();
|
|
118
|
+
}
|
|
119
|
+
// Reset singleton so a fresh start() is possible
|
|
120
|
+
DevTools.instance = undefined;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
start() {
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
if (this.server) {
|
|
126
|
+
resolve(this.getUrl());
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.server = http.createServer((req, res) => {
|
|
130
|
+
// Only allow same-origin requests — the client is served from this
|
|
131
|
+
// server so cross-origin access is unnecessary and would let arbitrary
|
|
132
|
+
// websites exfiltrate logs (which may contain API keys/headers).
|
|
133
|
+
const origin = req.headers.origin;
|
|
134
|
+
if (origin) {
|
|
135
|
+
const allowed = `http://127.0.0.1:${this.port}`;
|
|
136
|
+
if (origin === allowed) {
|
|
137
|
+
res.setHeader('Access-Control-Allow-Origin', allowed);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// API routes
|
|
141
|
+
if (req.url === '/events') {
|
|
142
|
+
res.writeHead(200, {
|
|
143
|
+
'Content-Type': 'text/event-stream',
|
|
144
|
+
'Cache-Control': 'no-cache',
|
|
145
|
+
Connection: 'keep-alive',
|
|
146
|
+
});
|
|
147
|
+
// Send full snapshot on connect
|
|
148
|
+
const snapshot = JSON.stringify({
|
|
149
|
+
networkLogs: this.logs,
|
|
150
|
+
consoleLogs: this.consoleLogs,
|
|
151
|
+
sessions: Array.from(this.sessions.keys()),
|
|
152
|
+
});
|
|
153
|
+
res.write(`event: snapshot\ndata: ${snapshot}\n\n`);
|
|
154
|
+
// Incremental updates
|
|
155
|
+
const onNetwork = (log) => {
|
|
156
|
+
res.write(`event: network\ndata: ${JSON.stringify(log)}\n\n`);
|
|
157
|
+
};
|
|
158
|
+
const onConsole = (log) => {
|
|
159
|
+
res.write(`event: console\ndata: ${JSON.stringify(log)}\n\n`);
|
|
160
|
+
};
|
|
161
|
+
const onSession = () => {
|
|
162
|
+
const sessions = Array.from(this.sessions.keys());
|
|
163
|
+
res.write(`event: session\ndata: ${JSON.stringify(sessions)}\n\n`);
|
|
164
|
+
};
|
|
165
|
+
this.on('update', onNetwork);
|
|
166
|
+
this.on('console-update', onConsole);
|
|
167
|
+
this.on('session-update', onSession);
|
|
168
|
+
req.on('close', () => {
|
|
169
|
+
this.off('update', onNetwork);
|
|
170
|
+
this.off('console-update', onConsole);
|
|
171
|
+
this.off('session-update', onSession);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
else if (req.url === '/' || req.url === '/index.html') {
|
|
175
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
176
|
+
res.end(INDEX_HTML);
|
|
177
|
+
}
|
|
178
|
+
else if (req.url === '/assets/main.js') {
|
|
179
|
+
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
|
180
|
+
res.end(CLIENT_JS);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
res.writeHead(404);
|
|
184
|
+
res.end('Not Found');
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
this.server.on('error', (e) => {
|
|
188
|
+
if (typeof e === 'object' &&
|
|
189
|
+
e !== null &&
|
|
190
|
+
'code' in e &&
|
|
191
|
+
e.code === 'EADDRINUSE') {
|
|
192
|
+
if (this.port - DevTools.DEFAULT_PORT >= DevTools.MAX_PORT_RETRIES) {
|
|
193
|
+
reject(new Error(`DevTools: all ports ${DevTools.DEFAULT_PORT}–${this.port} in use`));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.port++;
|
|
197
|
+
this.server?.listen(this.port, '127.0.0.1');
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
this.server.listen(this.port, '127.0.0.1', () => {
|
|
204
|
+
this.setupWebSocketServer();
|
|
205
|
+
resolve(this.getUrl());
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
setupWebSocketServer() {
|
|
210
|
+
if (!this.server)
|
|
211
|
+
return;
|
|
212
|
+
this.wss = new WebSocketServer({ server: this.server, path: '/ws' });
|
|
213
|
+
this.wss.on('connection', (ws) => {
|
|
214
|
+
let sessionId = null;
|
|
215
|
+
ws.on('message', (data) => {
|
|
216
|
+
try {
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
218
|
+
const message = JSON.parse(data.toString());
|
|
219
|
+
// Handle registration first
|
|
220
|
+
if (message.type === 'register') {
|
|
221
|
+
sessionId = String(message.sessionId);
|
|
222
|
+
if (!sessionId)
|
|
223
|
+
return;
|
|
224
|
+
this.sessions.set(sessionId, {
|
|
225
|
+
sessionId,
|
|
226
|
+
ws,
|
|
227
|
+
lastPing: Date.now(),
|
|
228
|
+
});
|
|
229
|
+
// Notify session update
|
|
230
|
+
this.emit('session-update');
|
|
231
|
+
// Send registration acknowledgement
|
|
232
|
+
ws.send(JSON.stringify({
|
|
233
|
+
type: 'registered',
|
|
234
|
+
sessionId,
|
|
235
|
+
timestamp: Date.now(),
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
else if (sessionId) {
|
|
239
|
+
this.handleWebSocketMessage(sessionId, message);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
// Invalid WebSocket message
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
ws.on('close', () => {
|
|
247
|
+
if (sessionId) {
|
|
248
|
+
this.sessions.delete(sessionId);
|
|
249
|
+
this.emit('session-update');
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
ws.on('error', () => {
|
|
253
|
+
// WebSocket error — no action needed
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
// Heartbeat mechanism
|
|
257
|
+
this.heartbeatTimer = setInterval(() => {
|
|
258
|
+
const now = Date.now();
|
|
259
|
+
this.sessions.forEach((session, sessionId) => {
|
|
260
|
+
if (now - session.lastPing > 30000) {
|
|
261
|
+
session.ws.close();
|
|
262
|
+
this.sessions.delete(sessionId);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
// Send ping
|
|
266
|
+
session.ws.send(JSON.stringify({ type: 'ping', timestamp: now }));
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}, 10000);
|
|
270
|
+
this.heartbeatTimer.unref();
|
|
271
|
+
}
|
|
272
|
+
handleWebSocketMessage(sessionId, message) {
|
|
273
|
+
const session = this.sessions.get(sessionId);
|
|
274
|
+
if (!session)
|
|
275
|
+
return;
|
|
276
|
+
switch (message['type']) {
|
|
277
|
+
case 'pong':
|
|
278
|
+
session.lastPing = Date.now();
|
|
279
|
+
break;
|
|
280
|
+
case 'console':
|
|
281
|
+
this.addInternalConsoleLog(
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
283
|
+
message['payload'], sessionId,
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
285
|
+
message['timestamp']);
|
|
286
|
+
break;
|
|
287
|
+
case 'network':
|
|
288
|
+
this.addInternalNetworkLog(
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
290
|
+
message['payload'], sessionId,
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
292
|
+
message['timestamp']);
|
|
293
|
+
break;
|
|
294
|
+
default:
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAkB,MAAM,IAAI,CAAC;AAMrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAsB5D;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAChC,MAAM,CAAC,QAAQ,CAAuB;IACtC,IAAI,GAAiB,EAAE,CAAC;IACxB,WAAW,GAA0B,EAAE,CAAC;IACxC,MAAM,GAAuB,IAAI,CAAC;IAClC,GAAG,GAA2B,IAAI,CAAC;IACnC,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC1C,cAAc,GAA0B,IAAI,CAAC;IAC7C,IAAI,GAAG,KAAK,CAAC;IACb,MAAM,CAAU,YAAY,GAAG,KAAK,CAAC;IACrC,MAAM,CAAU,gBAAgB,GAAG,EAAE,CAAC;IAE9C;QACE,KAAK,EAAE,CAAC;QACR,sEAAsE;QACtE,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvB,QAAQ,CAAC,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;Q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A2B,EAC5C,SAAS;gBACT,uEAAuE;gBACvE,OAAO,CAAC,WAAW,CAAW,CAC/B,CAAC;gBACF,MAAM;YAER;gBACE,MAAM;QACV,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export interface NetworkLog {
|
|
7
|
+
id: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
method: string;
|
|
11
|
+
url: string;
|
|
12
|
+
headers: Record<string, string | string[] | undefined>;
|
|
13
|
+
body?: string;
|
|
14
|
+
pending?: boolean;
|
|
15
|
+
chunks?: Array<{
|
|
16
|
+
index: number;
|
|
17
|
+
data: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
}>;
|
|
20
|
+
response?: {
|
|
21
|
+
status: number;
|
|
22
|
+
headers: Record<string, string | string[] | undefined>;
|
|
23
|
+
body?: string;
|
|
24
|
+
durationMs: number;
|
|
25
|
+
};
|
|
26
|
+
error?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ConsoleLogPayload {
|
|
29
|
+
type: 'log' | 'warn' | 'error' | 'debug' | 'info';
|
|
30
|
+
content: string;
|
|
31
|
+
}
|
|
32
|
+
export interface InspectorConsoleLog extends ConsoleLogPayload {
|
|
33
|
+
id: string;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dgxo/mashadevcli-devtools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"default": "./dist/src/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npm run build:client && tsc -p tsconfig.build.json",
|
|
16
|
+
"build:client": "node esbuild.client.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"client/index.html"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"react": "^19.2.0",
|
|
27
|
+
"react-dom": "^19.2.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"ws": "^8.16.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Default policy for tools discovered via toolDiscoveryCommand.
|
|
2
|
+
# These tools are potentially dangerous as they are arbitrary scripts.
|
|
3
|
+
# We default them to ASK_USER for safety.
|
|
4
|
+
|
|
5
|
+
[[rule]]
|
|
6
|
+
toolName = "discovered_tool_*"
|
|
7
|
+
decision = "ask_user"
|
|
8
|
+
priority = 10
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Priority system for policy rules:
|
|
2
|
+
# - Higher priority numbers win over lower priority numbers
|
|
3
|
+
# - When multiple rules match, the highest priority rule is applied
|
|
4
|
+
# - Rules are evaluated in order of priority (highest first)
|
|
5
|
+
#
|
|
6
|
+
# Priority bands (tiers):
|
|
7
|
+
# - Default policies (TOML): 1 + priority/1000 (e.g., priority 100 → 1.100)
|
|
8
|
+
# - Extension policies (TOML): 2 + priority/1000 (e.g., priority 100 → 2.100)
|
|
9
|
+
# - Workspace policies (TOML): 3 + priority/1000 (e.g., priority 100 → 3.100)
|
|
10
|
+
# - User policies (TOML): 4 + priority/1000 (e.g., priority 100 → 4.100)
|
|
11
|
+
# - Admin policies (TOML): 5 + priority/1000 (e.g., priority 100 → 5.100)
|
|
12
|
+
#
|
|
13
|
+
# This ensures Admin > User > Workspace > Extension > Default hierarchy is always preserved,
|
|
14
|
+
# while allowing user-specified priorities to work within each tier.
|
|
15
|
+
#
|
|
16
|
+
# Settings-based and dynamic rules (all in user tier 4.x):
|
|
17
|
+
# 4.95: Tools that the user has selected as "Always Allow" in the interactive UI
|
|
18
|
+
# 4.9: MCP servers excluded list (security: persistent server blocks)
|
|
19
|
+
# 4.4: Command line flag --exclude-tools (explicit temporary blocks)
|
|
20
|
+
# 4.3: Command line flag --allowed-tools (explicit temporary allows)
|
|
21
|
+
# 4.2: MCP servers with trust=true (persistent trusted servers)
|
|
22
|
+
# 4.1: MCP servers allowed list (persistent general server allows)
|
|
23
|
+
#
|
|
24
|
+
# TOML policy priorities (before transformation):
|
|
25
|
+
# 10: Write tools default to ASK_USER (becomes 1.010 in default tier)
|
|
26
|
+
# 60: Plan mode catch-all DENY override (becomes 1.060 in default tier)
|
|
27
|
+
# 70: Plan mode explicit ALLOW override (becomes 1.070 in default tier)
|
|
28
|
+
# 999: YOLO mode allow-all (becomes 1.999 in default tier)
|
|
29
|
+
|
|
30
|
+
# Mode Transitions (into/out of Plan Mode)
|
|
31
|
+
|
|
32
|
+
[[rule]]
|
|
33
|
+
toolName = "enter_plan_mode"
|
|
34
|
+
decision = "ask_user"
|
|
35
|
+
priority = 50
|
|
36
|
+
|
|
37
|
+
[[rule]]
|
|
38
|
+
toolName = "enter_plan_mode"
|
|
39
|
+
decision = "deny"
|
|
40
|
+
priority = 70
|
|
41
|
+
modes = ["plan"]
|
|
42
|
+
deny_message = "You are already in Plan Mode."
|
|
43
|
+
|
|
44
|
+
[[rule]]
|
|
45
|
+
toolName = "exit_plan_mode"
|
|
46
|
+
decision = "ask_user"
|
|
47
|
+
priority = 70
|
|
48
|
+
modes = ["plan"]
|
|
49
|
+
|
|
50
|
+
[[rule]]
|
|
51
|
+
toolName = "exit_plan_mode"
|
|
52
|
+
decision = "deny"
|
|
53
|
+
priority = 50
|
|
54
|
+
deny_message = "You are not currently in Plan Mode. Use enter_plan_mode first to design a plan."
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Catch-All: Deny everything by default in Plan mode.
|
|
58
|
+
|
|
59
|
+
[[rule]]
|
|
60
|
+
decision = "deny"
|
|
61
|
+
priority = 60
|
|
62
|
+
modes = ["plan"]
|
|
63
|
+
deny_message = "You are in Plan Mode with access to read-only tools. Execution of scripts (including those from skills) is blocked."
|
|
64
|
+
|
|
65
|
+
# Explicitly Allow Read-Only Tools in Plan mode.
|
|
66
|
+
|
|
67
|
+
[[rule]]
|
|
68
|
+
mcpName = "*"
|
|
69
|
+
toolAnnotations = { readOnlyHint = true }
|
|
70
|
+
decision = "ask_user"
|
|
71
|
+
priority = 70
|
|
72
|
+
modes = ["plan"]
|
|
73
|
+
|
|
74
|
+
[[rule]]
|
|
75
|
+
toolName = [
|
|
76
|
+
"glob",
|
|
77
|
+
"grep_search",
|
|
78
|
+
"list_directory",
|
|
79
|
+
"read_file",
|
|
80
|
+
"google_web_search",
|
|
81
|
+
"activate_skill",
|
|
82
|
+
"codebase_investigator",
|
|
83
|
+
"cli_help"
|
|
84
|
+
]
|
|
85
|
+
decision = "allow"
|
|
86
|
+
priority = 70
|
|
87
|
+
modes = ["plan"]
|
|
88
|
+
|
|
89
|
+
[[rule]]
|
|
90
|
+
toolName = ["ask_user", "save_memory"]
|
|
91
|
+
decision = "ask_user"
|
|
92
|
+
priority = 70
|
|
93
|
+
modes = ["plan"]
|
|
94
|
+
|
|
95
|
+
# Allow write_file and replace for .md files in the plans directory (cross-platform)
|
|
96
|
+
[[rule]]
|
|
97
|
+
toolName = ["write_file", "replace"]
|
|
98
|
+
decision = "allow"
|
|
99
|
+
priority = 70
|
|
100
|
+
modes = ["plan"]
|
|
101
|
+
argsPattern = "\"file_path\":\"[^\"]+[\\\\/]+\\.gemini[\\\\/]+tmp[\\\\/]+[\\w-]+[\\\\/]+[\\w-]+[\\\\/]+plans[\\\\/]+[\\w-]+\\.md\""
|
|
102
|
+
|
|
103
|
+
# Explicitly Deny other write operations in Plan mode with a clear message.
|
|
104
|
+
[[rule]]
|
|
105
|
+
toolName = ["write_file", "replace"]
|
|
106
|
+
decision = "deny"
|
|
107
|
+
priority = 65
|
|
108
|
+
modes = ["plan"]
|
|
109
|
+
deny_message = "You are in Plan Mode and cannot modify source code. You may ONLY use write_file or replace to save plans to the designated plans directory as .md files."
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Priority system for policy rules:
|
|
2
|
+
# - Higher priority numbers win over lower priority numbers
|
|
3
|
+
# - When multiple rules match, the highest priority rule is applied
|
|
4
|
+
# - Rules are evaluated in order of priority (highest first)
|
|
5
|
+
#
|
|
6
|
+
# Priority bands (tiers):
|
|
7
|
+
# - Default policies (TOML): 1 + priority/1000 (e.g., priority 100 → 1.100)
|
|
8
|
+
# - Extension policies (TOML): 2 + priority/1000 (e.g., priority 100 → 2.100)
|
|
9
|
+
# - Workspace policies (TOML): 3 + priority/1000 (e.g., priority 100 → 3.100)
|
|
10
|
+
# - User policies (TOML): 4 + priority/1000 (e.g., priority 100 → 4.100)
|
|
11
|
+
# - Admin policies (TOML): 5 + priority/1000 (e.g., priority 100 → 5.100)
|
|
12
|
+
#
|
|
13
|
+
# This ensures Admin > User > Workspace > Extension > Default hierarchy is always preserved,
|
|
14
|
+
# while allowing user-specified priorities to work within each tier.
|
|
15
|
+
#
|
|
16
|
+
# Settings-based and dynamic rules (all in user tier 4.x):
|
|
17
|
+
# 4.95: Tools that the user has selected as "Always Allow" in the interactive UI
|
|
18
|
+
# 4.9: MCP servers excluded list (security: persistent server blocks)
|
|
19
|
+
# 4.4: Command line flag --exclude-tools (explicit temporary blocks)
|
|
20
|
+
# 4.3: Command line flag --allowed-tools (explicit temporary allows)
|
|
21
|
+
# 4.2: MCP servers with trust=true (persistent trusted servers)
|
|
22
|
+
# 4.1: MCP servers allowed list (persistent general server allows)
|
|
23
|
+
#
|
|
24
|
+
# TOML policy priorities (before transformation):
|
|
25
|
+
# 10: Write tools default to ASK_USER (becomes 1.010 in default tier)
|
|
26
|
+
# 15: Auto-edit tool override (becomes 1.015 in default tier)
|
|
27
|
+
# 50: Read-only tools (becomes 1.050 in default tier)
|
|
28
|
+
# 999: YOLO mode allow-all (becomes 1.999 in default tier)
|
|
29
|
+
|
|
30
|
+
[[rule]]
|
|
31
|
+
toolName = "glob"
|
|
32
|
+
decision = "allow"
|
|
33
|
+
priority = 50
|
|
34
|
+
|
|
35
|
+
[[rule]]
|
|
36
|
+
toolName = "grep_search"
|
|
37
|
+
decision = "allow"
|
|
38
|
+
priority = 50
|
|
39
|
+
|
|
40
|
+
[[rule]]
|
|
41
|
+
toolName = "list_directory"
|
|
42
|
+
decision = "allow"
|
|
43
|
+
priority = 50
|
|
44
|
+
|
|
45
|
+
[[rule]]
|
|
46
|
+
toolName = "read_file"
|
|
47
|
+
decision = "allow"
|
|
48
|
+
priority = 50
|
|
49
|
+
|
|
50
|
+
[[rule]]
|
|
51
|
+
toolName = "google_web_search"
|
|
52
|
+
decision = "allow"
|
|
53
|
+
priority = 50
|