@yanickxia/agent-vision 0.1.0 → 0.3.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.
@@ -1,64 +1,91 @@
1
1
  ---
2
2
  name: agent-vision
3
- description: Analyze images, screenshots, diagrams, and videos with the agent-vision MCP tools. Use for image questions, OCR, UI inspection, visual debugging, screen recordings, video summaries, and timeline analysis.
3
+ description: Generate images from text using configured image APIs; analyze videos through sampled frames; provide fallback image understanding when native vision is unavailable or failed. For image analysis only, if you can see the image natively, look directly instead of using this skill. Native vision does not replace image generation.
4
4
  license: MIT
5
- compatibility: Requires the agent-vision MCP server or Node.js 20+ for the npx fallback, plus an OpenAI-compatible vision API.
5
+ compatibility: Node.js 20+ for the CLI; the MCP server is optional.
6
6
  ---
7
7
 
8
8
  # agent-vision
9
9
 
10
- Use this skill when the user asks you to inspect an image or video. The MCP
11
- server is the execution layer; this skill explains when and how to call it.
10
+ The Skill runs the standalone CLI; no MCP server is required. CLI and MCP read
11
+ the same `agent-vision/settings.json` (`AGENT_VISION_CONFIG` can override its
12
+ location) and use the same provider adapters, including Volcengine Ark.
12
13
 
13
- ## Choose the tool
14
+ ## Choose the capability
14
15
 
15
- | Input | Tool |
16
- |---|---|
17
- | Screenshot, photo, diagram, UI, scanned text | `analyze_image` |
18
- | Screen recording, demo, clip, animation timeline | `analyze_video` |
16
+ For **image generation**, skip the vision gate and use `generate` below.
17
+ This creates a new bitmap from text; it does not edit an existing image.
19
18
 
20
- Do not call a vision tool for a text-only task.
19
+ For **image analysis**, apply the following gate:
21
20
 
22
- ## Calling rules
21
+ If you can read images natively (for example the Read tool in Claude Code or
22
+ built-in multimodal input), look at the image yourself and answer directly.
23
+ Do not load or run anything from this skill for an image you can already see.
24
+ Image analysis through this skill is a fallback for agents without native
25
+ vision or when native image reading failed.
23
26
 
24
- 1. Pass the user's original question as `prompt`. A focused question is better
25
- than a generic request for a description.
27
+ Videos are the exception: no agent can watch a video natively. Video analysis
28
+ always goes through the CLI below.
29
+
30
+ ## Analyze with the CLI
31
+
32
+ When you cannot see the input yourself (or it is a video), run the analysis
33
+ directly and read the plain-text output:
34
+
35
+ ```bash
36
+ npx -y @yanickxia/agent-vision image "/absolute/path/to/error.png" --prompt "Read the error message and identify the likely cause."
37
+ npx -y @yanickxia/agent-vision video "/absolute/path/to/demo.mp4" --prompt "Summarize the UI flow in chronological order." --frames 8
38
+ ```
39
+
40
+ If the package is installed locally, run `agent-vision image ...` instead of
41
+ `npx -y @yanickxia/agent-vision ...`.
42
+ For a source checkout, run `npm run build` in that checkout once, then use
43
+ `node /absolute/path/to/agent-vision/dist/cli.js ...` for any CLI command.
44
+ This uses the checkout's implementation rather than an older published package.
45
+
46
+ ## Analysis calling rules
47
+
48
+ 1. Pass the user's original question as `--prompt`. A focused question is
49
+ better than a generic request for a description.
26
50
  2. Prefer an absolute local path. HTTP(S) URLs are also supported. Images may
27
51
  additionally be supplied as a `data:image/...;base64,...` URI.
28
- 3. For videos, keep the default `max_frames=8` unless the user needs a faster
52
+ 3. For videos, keep the default `--frames 8` unless the user needs a faster
29
53
  result or a denser timeline. The allowed range is 1–16.
30
54
  4. If the result is uncertain, say so. Never invent visual details after a
31
- failed tool call.
55
+ failed run.
32
56
  5. Retry at most once for a transient API or timeout error. Configuration,
33
57
  unsupported-format, and missing-file errors require correction, not retries.
34
58
 
35
- ## Examples
36
-
37
- ```json
38
- analyze_image({
39
- "source": "/absolute/path/to/error.png",
40
- "prompt": "Read the error message and identify the likely cause."
41
- })
42
- ```
59
+ ## Generate an image
43
60
 
44
- ```json
45
- analyze_video({
46
- "source": "/absolute/path/to/demo.mp4",
47
- "prompt": "Summarize the UI flow in chronological order.",
48
- "max_frames": 8
49
- })
61
+ ```bash
62
+ npx -y @yanickxia/agent-vision generate --prompt "A watercolor orange cat sitting by a window" --output "/absolute/path/to/cat.png"
50
63
  ```
51
64
 
52
- ## npx fallback
53
-
54
- If the MCP tools are not available but shell execution is allowed, run:
65
+ With a configured Volcengine Ark provider:
55
66
 
56
67
  ```bash
57
- npx -y @yanickxia/agent-vision image "/absolute/path/to/image.png" --prompt "user question"
58
- npx -y @yanickxia/agent-vision video "/absolute/path/to/video.mp4" --prompt "user question" --frames 8
68
+ npx -y @yanickxia/agent-vision generate --prompt "A watercolor orange cat sitting by a window" --output "/absolute/path/to/cat.jpg" --size 2K
59
69
  ```
60
70
 
61
- Before the npm package is available, replace the package name with
62
- `github:yanickxia/agent-vision`.
71
+ - Pass the requested image description as `--prompt` (or `-p`).
72
+ - Choose a new local file via `--output` (or `-o`); its parent directory must
73
+ exist. Existing files are never overwritten. Successful stdout is the saved
74
+ absolute path. The file keeps the provider's actual image format; the filename
75
+ extension does not convert it.
76
+ - `--size` and `--quality` are optional provider-specific values. Omit them
77
+ unless the task or model requires them.
78
+ - For Volcengine Ark Seedream, configure `type: "volcengine-ark"`; omit
79
+ `--quality` (unsupported). Use a supported size such as `2K`, or omit size.
80
+ See the configuration reference for its endpoint and `ARK_API_KEY` fallback.
81
+ - Generation providers are independent from vision providers and are tried
82
+ sequentially, stopping after the first success. Do not blindly repeat a
83
+ failed generation: a timeout may still incur a charge, and configured
84
+ fallback targets may already have been attempted.
85
+ - If using MCP instead, call `generate_image` with `prompt`, optional
86
+ `output_path`, `size`, and `quality`. It returns image content and metadata;
87
+ without `output_path` it does not save a local file.
63
88
 
64
- Configuration details are in `references/configuration.md`.
89
+ Read [references/configuration.md](references/configuration.md) when configuring
90
+ providers or diagnosing a configuration error. Run `agent-vision doctor` to
91
+ inspect configured vision and generation targets without calling either API.
@@ -1,6 +1,119 @@
1
1
  # Configuration
2
2
 
3
- Required for normal use:
3
+ agent-vision reads its configuration from a JSON settings file. Environment
4
+ variables still work as a fallback.
5
+
6
+ ## Settings file
7
+
8
+ The first location that exists wins:
9
+
10
+ 1. `$AGENT_VISION_CONFIG` — an explicit file path (an error if it is missing)
11
+ 2. `$XDG_CONFIG_HOME/agent-vision/settings.json`
12
+ (default: `~/.config/agent-vision/settings.json`)
13
+
14
+ ```json
15
+ {
16
+ "providers": [
17
+ {
18
+ "name": "dashscope",
19
+ "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
20
+ "apiKey": "sk-...",
21
+ "models": ["qwen-vl-max", "qwen-vl-plus"]
22
+ },
23
+ {
24
+ "name": "openai",
25
+ "baseUrl": "https://api.openai.com/v1",
26
+ "apiKey": "sk-...",
27
+ "models": ["gpt-4o"]
28
+ }
29
+ ],
30
+ "generationProviders": [
31
+ {
32
+ "name": "image-api",
33
+ "baseUrl": "https://your-image-api.example/v1",
34
+ "apiKey": "sk-...",
35
+ "models": ["your-image-generation-model"]
36
+ }
37
+ ],
38
+ "maxTokens": 4096,
39
+ "timeoutMs": 120000
40
+ }
41
+ ```
42
+
43
+ - Each vision provider (`providers`) × model combination is a target. With several targets, all
44
+ of them are requested **concurrently** and the first successful answer
45
+ wins; the remaining requests are aborted. Note the cost: N targets means
46
+ up to N paid completions per analysis.
47
+ - `name` is optional and only used in error messages; it defaults to the
48
+ baseUrl host.
49
+ - `apiKey` is optional per provider (for local endpoints without auth) and
50
+ falls back to the environment key.
51
+ - `headers` per provider merges over the top-level `headers`.
52
+ - Top-level knobs (all optional): `maxTokens`, `timeoutMs`, `headers`,
53
+ `maxImageMb`, `maxVideoMb`, `allowPrivateUrls`, `ffmpegPath`.
54
+ - Fields defined in the file take precedence over environment variables.
55
+ - The file may contain API keys: keep it out of version control and run
56
+ `chmod 600` on it.
57
+
58
+ ## Image generation
59
+
60
+ `generationProviders` uses the same connection fields as `providers`:
61
+ required `baseUrl` and non-empty `models`, optional `name`, `apiKey`, and
62
+ `headers`, plus a generation-only `type`: `openai-images` (default for old
63
+ configs) or `volcengine-ark`. Unknown types are rejected; protocol selection
64
+ is explicit, not inferred from the hostname or model name. You may configure
65
+ either capability alone or both in one file. Both adapters use synchronous
66
+ `POST /images/generations` responses with `data[0].b64_json` or `data[0].url`.
67
+
68
+ Generation targets are tried **sequentially in file order**, stopping at the
69
+ first valid image. They are not raced because multiple successful generations
70
+ would waste money. Failure fallback can still incur multiple charges, especially
71
+ after timeouts. Configure one target to avoid automatic fallback.
72
+
73
+ Each call requests one image. `size` is optional; `quality` is optional and
74
+ only supported by `openai-images`. Omitting them keeps provider defaults.
75
+ The OpenAI adapter omits `response_format`, because some models reject it.
76
+ This supports text-to-image, not image edits or async jobs.
77
+
78
+ Generation shares `timeoutMs`, `maxImageMb`, `headers`, and `allowPrivateUrls`
79
+ with analysis. Increase `timeoutMs` for slower generation models. API-returned
80
+ image URLs and redirects are subject to the same private-URL restrictions as
81
+ input images; API credentials are not forwarded to the download host.
82
+
83
+ ### Volcengine Ark (Seedream)
84
+
85
+ ```json
86
+ {
87
+ "generationProviders": [
88
+ {
89
+ "type": "volcengine-ark",
90
+ "name": "volcengine",
91
+ "baseUrl": "https://ark.cn-beijing.volces.com/api/v3",
92
+ "models": ["doubao-seedream-5-0-lite-260128"]
93
+ }
94
+ ]
95
+ }
96
+ ```
97
+
98
+ Supply a provider `apiKey`, or set `ARK_API_KEY`; an explicit
99
+ `AGENT_VISION_GENERATION_API_KEY` overrides the latter. Model IDs must be
100
+ enabled for the account; `ep-...` IDs pointing to image models also work.
101
+
102
+ The Ark adapter requests `response_format: "b64_json"` (still accepts URL
103
+ responses), never sends OpenAI's `n` or `quality`, and uses the server's
104
+ single-image/non-streaming defaults. It omits model-specific group/stream flags
105
+ so the same payload also works for opaque endpoint IDs. Watermark and output
106
+ format remain at provider defaults. `--quality` is rejected before the request;
107
+ use a supported `--size`, such as `2K`, or leave it unset. Images commonly use
108
+ JPEG; choosing a `.png` filename does not convert the bytes.
109
+
110
+ This is the [Ark Seedream API](https://ark.volcengine.com/region:cn-beijing/docs/image-generation-api.md),
111
+ not the separate Volcengine Visual Intelligence/Jimeng AK/SK-signed API.
112
+ Image editing, image groups and layer decomposition are not implemented.
113
+
114
+ ## Environment variables (fallback)
115
+
116
+ For image/video understanding when no settings file providers are used:
4
117
 
5
118
  ```bash
6
119
  export AGENT_VISION_BASE_URL="https://your-openai-compatible-endpoint/v1"
@@ -12,15 +125,53 @@ export AGENT_VISION_MODEL="your-vision-model"
12
125
  not require authentication. The server also recognizes `VISION_*` and
13
126
  `OPENAI_*` aliases.
14
127
 
15
- Useful optional variables:
128
+ For generation when no `generationProviders` are defined:
129
+
130
+ ```bash
131
+ export AGENT_VISION_GENERATION_BASE_URL="https://your-image-api.example/v1"
132
+ export AGENT_VISION_GENERATION_API_KEY="your-key"
133
+ export AGENT_VISION_GENERATION_MODEL="your-image-generation-model"
134
+ ```
135
+
136
+ `AGENT_VISION_GENERATION_TYPE` defaults to `openai-images`. In that mode, the
137
+ generation URL and key fall back to the corresponding `AGENT_VISION_*` values
138
+ and their aliases. With `volcengine-ark`, the URL defaults to
139
+ `https://ark.cn-beijing.volces.com/api/v3` and the key falls back to `ARK_API_KEY`;
140
+ neither inherits the vision/OpenAI URL or key, to avoid sending another
141
+ provider's credentials to Ark. Explicit `AGENT_VISION_GENERATION_BASE_URL` and
142
+ `AGENT_VISION_GENERATION_API_KEY` override these defaults.
143
+
144
+ For an environment-only Ark setup:
145
+
146
+ ```bash
147
+ export AGENT_VISION_GENERATION_TYPE="volcengine-ark"
148
+ export AGENT_VISION_GENERATION_MODEL="doubao-seedream-5-0-lite-260128"
149
+ export ARK_API_KEY="your-ark-key"
150
+ ```
151
+
152
+ The generation model must be explicit: it never falls back to a vision/chat
153
+ model. File provider keys use their own type's fallback; an explicit
154
+ `"apiKey": ""` disables key fallback for an unauthenticated local provider.
155
+ File providers default to `openai-images` independently of the environment's
156
+ generation type.
157
+
158
+ `AGENT_VISION_GENERATION_HEADERS` adds generation-only headers. Header precedence
159
+ (last wins): `AGENT_VISION_HEADERS` → `AGENT_VISION_GENERATION_HEADERS` →
160
+ file top-level `headers` → provider `headers`. File `generationProviders` take
161
+ precedence over the environment's generation target.
162
+
163
+ Optional variables:
16
164
 
17
165
  - `AGENT_VISION_MAX_TOKENS` (default `4096`)
18
166
  - `AGENT_VISION_TIMEOUT_MS` (default `120000`)
19
- - `AGENT_VISION_MAX_IMAGE_MB` (default `20`)
167
+ - `AGENT_VISION_MAX_IMAGE_MB` (default `20`, also applies to generated images)
20
168
  - `AGENT_VISION_MAX_VIDEO_MB` (default `200`)
21
169
  - `AGENT_VISION_HEADERS` (JSON object of extra HTTP headers)
22
- - `AGENT_VISION_ALLOW_PRIVATE_URLS=true` (allow private image/video source URLs)
170
+ - `AGENT_VISION_ALLOW_PRIVATE_URLS=true` (allow private input and generated-image URLs)
23
171
  - `AGENT_VISION_FFMPEG_PATH` (override ffmpeg; otherwise PATH, then bundled binary)
24
172
 
25
173
  The configured API endpoint itself may be private; the private-URL guard only
26
- applies to user-provided image and video source URLs.
174
+ applies to image/video source URLs and API-returned generated-image URLs.
175
+
176
+ `agent-vision doctor` lists both capabilities without sending API requests.
177
+ Generation-only setups do not need a vision target or ffmpeg.