anymous 1.2.0 → 1.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymous",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "AI-powered reverse engineering platform",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -171,7 +171,7 @@ function draw(
171
171
  }
172
172
  }
173
173
 
174
- const VERSION = "1.2.0"
174
+ const VERSION = "1.2.2"
175
175
 
176
176
  function build(input: SplashWriterInput, kind: "entry" | "exit", ctx: ScrollbackRenderContext): ScrollbackSnapshot {
177
177
  const width = Math.max(1, ctx.width)
package/src/cli/ui.ts CHANGED
@@ -54,7 +54,7 @@ export function logo(pad?: string) {
54
54
  result.push(row)
55
55
  result.push(EOL)
56
56
  }
57
- result.push("AI-Powered Reverse Engineering & Pentest Platform v1.2.0")
57
+ result.push("AI-Powered Reverse Engineering & Pentest Platform v1.2.2")
58
58
  return result.join("")
59
59
  }
60
60
 
@@ -103,7 +103,7 @@ export function logo(pad?: string) {
103
103
  result.push(EOL)
104
104
  })
105
105
  result.push(Style.TEXT_NORMAL, "─".repeat(45), EOL)
106
- result.push(Style.TEXT_INFO, "▸", Style.TEXT_NORMAL, " AI-Powered Reverse Engineering & Pentest Platform ", Style.TEXT_DIM, "v1.2.0", EOL)
106
+ result.push(Style.TEXT_INFO, "▸", Style.TEXT_NORMAL, " AI-Powered Reverse Engineering & Pentest Platform ", Style.TEXT_DIM, "v1.2.1", EOL)
107
107
  result.push(Style.TEXT_NORMAL, "─".repeat(45))
108
108
  return result.join("").trimEnd()
109
109
  }
@@ -5,15 +5,16 @@ import DESCRIPTION from "./computer.txt"
5
5
 
6
6
  const platform = process.platform
7
7
 
8
- const poweshellScript = (script: string) =>
8
+ const powershellScript = (script: string) =>
9
9
  Effect.promise<string>(
10
10
  () =>
11
11
  new Promise((resolve, reject) => {
12
+ const enc = Buffer.from(script, "utf16le").toString("base64")
12
13
  const proc = spawn("powershell", [
13
14
  "-NoProfile",
14
15
  "-NonInteractive",
15
- "-Command",
16
- script,
16
+ "-EncodedCommand",
17
+ enc,
17
18
  ])
18
19
  let stdout = ""
19
20
  let stderr = ""
@@ -23,13 +24,13 @@ const poweshellScript = (script: string) =>
23
24
  if (code === 0) resolve(stdout.trim())
24
25
  else reject(new Error(stderr.trim() || `exit code ${code}`))
25
26
  })
26
- proc.on("error", reject)
27
+ proc.on("error", (e) => reject(e))
27
28
  }),
28
29
  )
29
30
 
30
31
  const captureScreenshot = Effect.fn("Computer.screenshot")(function* () {
31
32
  if (platform === "win32") {
32
- const base64 = yield* poweshellScript(`
33
+ const base64 = yield* powershellScript(`
33
34
  Add-Type -AssemblyName System.Drawing
34
35
  Add-Type -AssemblyName System.Windows.Forms
35
36
  $bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
@@ -83,7 +84,7 @@ $ms.Dispose()
83
84
 
84
85
  const moveMouse = Effect.fn("Computer.moveMouse")(function* (x: number, y: number) {
85
86
  if (platform === "win32") {
86
- yield* poweshellScript(`
87
+ yield* powershellScript(`
87
88
  Add-Type -AssemblyName System.Windows.Forms
88
89
  [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(${Math.round(x)}, ${Math.round(y)})
89
90
  `)
@@ -111,30 +112,38 @@ Add-Type -AssemblyName System.Windows.Forms
111
112
 
112
113
  const clickMouse = Effect.fn("Computer.clickMouse")(function* (button: "left" | "right" | "middle") {
113
114
  if (platform === "win32") {
114
- const btn = button === "left" ? "[MouseButtons]::Left" : button === "right" ? "[MouseButtons]::Right" : "[MouseButtons]::Middle"
115
- const down = button === "left" ? "0x2" : button === "right" ? "0x8" : "0x20"
116
- const up = button === "left" ? "0x4" : button === "right" ? "0x10" : "0x40"
117
- yield* poweshellScript(`
115
+ const down = button === "left" ? "LEFTDOWN" : button === "right" ? "RIGHTDOWN" : "MIDDLEDOWN"
116
+ const up = button === "left" ? "LEFTUP" : button === "right" ? "RIGHTUP" : "MIDDLEUP"
117
+ yield* powershellScript(`
118
118
  Add-Type -AssemblyName System.Windows.Forms
119
- [System.Windows.Forms.Cursor]::Click()
119
+ $c = Add-Type -TypeDefinition @'
120
+ using System;
121
+ using System.Runtime.InteropServices;
122
+ public class W32 {
123
+ [DllImport("user32.dll")] public static extern void mouse_event(uint f, uint x, uint y, uint d, int i);
124
+ public const uint L=0x02,R=0x08,M=0x20,LU=0x04,RU=0x10,MU=0x40;
125
+ }
126
+ '@
127
+ [W32]::mouse_event([W32]::${down}, 0, 0, 0, 0); Start-Sleep -Milliseconds 50
128
+ [W32]::mouse_event([W32]::${up}, 0, 0, 0, 0); Write-Output OK
120
129
  `)
121
130
  } else if (platform === "darwin") {
122
- const btn = button === "left" ? "click" : button === "right" ? "click at (get position of mouse) using {button 2}" : "click at (get position of mouse) using {button 3}"
131
+ const action = button === "left" ? "click" : button === "right" ? "click at (get position of mouse) using {button 2}" : "click at (get position of mouse) using {button 3}"
123
132
  yield* Effect.promise(() =>
124
133
  new Promise<void>((resolve, reject) => {
125
134
  const proc = spawn("osascript", [
126
135
  "-e",
127
- `tell application "System Events" to ${btn}`,
136
+ `tell application "System Events" to ${action}`,
128
137
  ])
129
138
  proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
130
139
  proc.on("error", reject)
131
140
  }),
132
141
  )
133
142
  } else if (platform === "linux") {
134
- const btn = button === "left" ? "1" : button === "right" ? "3" : "2"
143
+ const b = button === "left" ? "1" : button === "right" ? "3" : "2"
135
144
  yield* Effect.promise(() =>
136
145
  new Promise<void>((resolve, reject) => {
137
- const proc = spawn("xdotool", ["click", btn])
146
+ const proc = spawn("xdotool", ["click", b])
138
147
  proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
139
148
  proc.on("error", reject)
140
149
  }),
@@ -142,32 +151,73 @@ Add-Type -AssemblyName System.Windows.Forms
142
151
  }
143
152
  })
144
153
 
145
- const typeText = Effect.fn("Computer.typeText")(function* (text: string) {
146
- if (platform === "win32") {
147
- const escaped = text.replace(/"/g, '`"').replace(/\$/g, "`$").replace(/\n/g, "`n").replace(/\r/g, "`r").replace(/\t/g, "`t")
148
- yield* poweshellScript(`
149
- Add-Type -AssemblyName System.Windows.Forms
150
- [System.Windows.Forms.SendKeys]::SendWait("${escaped}")
151
- `)
152
- } else if (platform === "darwin") {
153
- yield* Effect.promise(() =>
154
- new Promise<void>((resolve, reject) => {
155
- const proc = spawn("osascript", [
156
- "-e",
157
- `tell application "System Events" to keystroke "${text.replace(/"/g, '\\"')}"`,
158
- ])
159
- proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
160
- proc.on("error", reject)
161
- }),
162
- )
163
- } else if (platform === "linux") {
164
- yield* Effect.promise(() =>
165
- new Promise<void>((resolve, reject) => {
166
- const proc = spawn("xdotool", ["type", text])
167
- proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
168
- proc.on("error", reject)
169
- }),
170
- )
154
+ const escapeSendKeys = (s: string) =>
155
+ s
156
+ .replace(/{/g, "{{}")
157
+ .replace(/}/g, "{}}")
158
+ .replace(/\+/g, "{+}")
159
+ .replace(/\^/g, "{^}")
160
+ .replace(/%/g, "{%}")
161
+ .replace(/~/g, "{~}")
162
+ .replace(/\(/g, "{(}")
163
+ .replace(/\)/g, "{)}")
164
+ .replace(/\[/g, "{[}")
165
+ .replace(/\]/g, "{]}")
166
+ .replace(/"/g, '`"')
167
+ .replace(/\$/g, "`$")
168
+ .replace(/\n/g, "`n")
169
+ .replace(/\r/g, "`r")
170
+ .replace(/\t/g, "`t")
171
+
172
+ const typeText = Effect.fn("Computer.typeText")(function* (text: string, delayMs: number = 0) {
173
+ const typeChar = (char: string) => {
174
+ if (platform === "win32") {
175
+ const esc = escapeSendKeys(char)
176
+ return powershellScript(`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait("${esc}")`)
177
+ } else if (platform === "darwin") {
178
+ return Effect.promise<void>(() =>
179
+ new Promise((resolve, reject) => {
180
+ const proc = spawn("osascript", ["-e", `tell application "System Events" to keystroke "${char.replace(/"/g, '\\"')}"`])
181
+ proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
182
+ proc.on("error", reject)
183
+ }),
184
+ )
185
+ } else {
186
+ return Effect.promise<void>(() =>
187
+ new Promise((resolve, reject) => {
188
+ const proc = spawn("xdotool", ["type", char])
189
+ proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
190
+ proc.on("error", reject)
191
+ }),
192
+ )
193
+ }
194
+ }
195
+ if (delayMs <= 0) {
196
+ if (platform === "win32") {
197
+ const escaped = escapeSendKeys(text)
198
+ yield* powershellScript(`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait("${escaped}")`)
199
+ } else if (platform === "darwin") {
200
+ yield* Effect.promise<void>(() =>
201
+ new Promise((resolve, reject) => {
202
+ const proc = spawn("osascript", ["-e", `tell application "System Events" to keystroke "${text.replace(/"/g, '\\"')}"`])
203
+ proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
204
+ proc.on("error", reject)
205
+ }),
206
+ )
207
+ } else {
208
+ yield* Effect.promise<void>(() =>
209
+ new Promise((resolve, reject) => {
210
+ const proc = spawn("xdotool", ["type", text])
211
+ proc.on("close", (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))))
212
+ proc.on("error", reject)
213
+ }),
214
+ )
215
+ }
216
+ } else {
217
+ for (const char of text) {
218
+ yield* typeChar(char)
219
+ if (delayMs > 0) yield* Effect.promise<void>((resolve) => setTimeout(resolve, delayMs))
220
+ }
171
221
  }
172
222
  })
173
223
 
@@ -181,7 +231,7 @@ const keyPress = Effect.fn("Computer.keyPress")(function* (keys: string[]) {
181
231
  home: "{HOME}", end: "{END}", pageup: "{PGUP}", pagedown: "{PGDN}",
182
232
  }
183
233
  const translated = keys.map((k) => mapping[k.toLowerCase()] ?? k.toUpperCase())
184
- yield* poweshellScript(`
234
+ yield* powershellScript(`
185
235
  Add-Type -AssemblyName System.Windows.Forms
186
236
  [System.Windows.Forms.SendKeys]::SendWait("${translated.join("")}")
187
237
  `)
@@ -214,9 +264,17 @@ Add-Type -AssemblyName System.Windows.Forms
214
264
 
215
265
  const scrollMouse = Effect.fn("Computer.scrollMouse")(function* (clicks: number) {
216
266
  if (platform === "win32") {
217
- yield* poweshellScript(`
267
+ yield* powershellScript(`
218
268
  Add-Type -AssemblyName System.Windows.Forms
219
- [System.Windows.Forms.SendKeys]::SendWait("{${clicks > 0 ? "UP" : "DOWN"} ${Math.abs(clicks)}}")
269
+ Add-Type -TypeDefinition @'
270
+ using System;
271
+ using System.Runtime.InteropServices;
272
+ public class W32 {
273
+ [DllImport("user32.dll")] public static extern void mouse_event(uint f, uint x, uint y, uint d, int i);
274
+ public const uint W=0x0800;
275
+ }
276
+ '@
277
+ [W32]::mouse_event([W32]::W, 0, 0, ${Math.round(clicks) * 120}, 0); Write-Output OK
220
278
  `)
221
279
  } else if (platform === "darwin") {
222
280
  yield* Effect.promise(() =>
@@ -244,7 +302,7 @@ Add-Type -AssemblyName System.Windows.Forms
244
302
 
245
303
  const getScreenSize = Effect.fn("Computer.screenSize")(function* () {
246
304
  if (platform === "win32") {
247
- const raw = yield* poweshellScript(`
305
+ const raw = yield* powershellScript(`
248
306
  Add-Type -AssemblyName System.Windows.Forms
249
307
  $s = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
250
308
  Write-Output "$($s.Width) $($s.Height)"
@@ -291,6 +349,7 @@ export const Action = Schema.Struct({
291
349
  x: Schema.optional(Schema.Number).annotate({ description: "X coordinate for click/move actions" }),
292
350
  y: Schema.optional(Schema.Number).annotate({ description: "Y coordinate for click/move actions" }),
293
351
  text: Schema.optional(Schema.String).annotate({ description: "Text to type (for type action)" }),
352
+ delayMs: Schema.optional(Schema.Number).annotate({ description: "Delay in ms between keystrokes (for type action, default: 0)" }),
294
353
  keys: Schema.optional(Schema.Array(Schema.String)).annotate({ description: "Keys to press (for keypress action), e.g. ['ctrl', 'c']" }),
295
354
  button: Schema.optional(Schema.Literal("left", "right", "middle")).annotate({ description: "Mouse button (default: left)" }),
296
355
  clicks: Schema.optional(Schema.Number).annotate({ description: "Scroll clicks (positive=up, negative=down)" }),
@@ -350,7 +409,7 @@ export const ComputerTool = Tool.define<typeof Action, {}, Question.Service>(
350
409
  }
351
410
 
352
411
  if (action === "type") {
353
- yield* typeText(params.text!)
412
+ yield* typeText(params.text!, params.delayMs ?? 0)
354
413
  const dataUrl = yield* captureScreenshot
355
414
  return {
356
415
  title: `Typed text`,
@@ -2,15 +2,17 @@ Control the computer screen — capture screenshots, move mouse, click, type tex
2
2
 
3
3
  Available actions:
4
4
  - screenshot: Capture current screen (returns image, no side effects)
5
- - move (x, y): Move mouse to coordinates
6
- - click (x?, y?, button?): Click at position (default: left button)
7
- - doubleclick (x?, y?): Double-click at position
8
- - rightclick (x?, y?): Right-click at position
9
- - type (text): Type text at current cursor position
10
- - keypress (keys): Press key combination (e.g. ["ctrl", "c"], ["alt", "tab"], ["enter"])
11
- - scroll (clicks): Scroll up (positive) or down (negative)
5
+ - move (x, y): Move mouse to absolute pixel coordinates
6
+ - click (x?, y?, button?): Click at position (default: left button). Move first if x/y provided
7
+ - doubleclick (x?, y?): Double-click at position (moves first if x/y provided)
8
+ - rightclick (x?, y?): Right-click at position (moves first if x/y provided)
9
+ - type (text, delayMs?): Type text at current cursor position. Use delayMs (ms) to add a pause between each keystroke — useful for visible/animating typing or to let UI elements load
10
+ - keypress (keys): Press key combination, e.g. ["ctrl","l"] for address bar, ["ctrl","c"] copy, ["ctrl","v"] paste, ["enter"], ["tab"], ["alt","tab"] switch window, ["escape"], ["backspace"]
11
+ - scroll (clicks): Scroll up (positive number) or down (negative number)
12
12
  - screensize: Get screen dimensions
13
13
 
14
- Coordinate system: (0,0) is top-left corner of primary screen. Get screen dimensions via screensize action.
14
+ Tip: To open a URL: keypress ["ctrl","l"] type the URL (use delayMs if page is slow) keypress ["enter"].
15
15
 
16
- Platform support: Windows (native), macOS (via screencapture + osascript), Linux (via ImageMagick + xdotool).
16
+ Coordinate system: (0,0) is top-left corner of primary screen. Always get screen dimensions via screensize action first to know the available area.
17
+
18
+ Platform support: Windows (native PowerShell + user32), macOS (via screencapture + osascript), Linux (via ImageMagick + xdotool).