pi-agnes-tools 0.3.1 → 0.3.4
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/.github/banner.png +0 -0
- package/README.md +65 -49
- package/extensions/agnes-tools.ts +13 -4
- package/package.json +8 -5
- package/skills/agnes-media/SKILL.md +8 -1
|
Binary file
|
package/README.md
CHANGED
|
@@ -1,88 +1,104 @@
|
|
|
1
1
|
# pi-agnes-tools
|
|
2
2
|
|
|
3
|
-
The single Agnes AI plugin for pi: text model catalog
|
|
4
|
-
plus image/video generation as custom tools + skill
|
|
5
|
-
for media.
|
|
3
|
+
The single Agnes AI plugin for [pi](https://pi.dev): **text model catalog**
|
|
4
|
+
(selectable via `/model`) plus **image/video generation as custom tools + skill**.
|
|
5
|
+
No model switch needed for media — the agent just calls a tool.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/pi-agnes-tools)
|
|
8
|
+
[](./LICENSE)
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
13
|
pi install npm:pi-agnes-tools
|
|
11
14
|
```
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
Export an API key, then use it:
|
|
14
17
|
|
|
15
18
|
```bash
|
|
16
|
-
|
|
19
|
+
export AGNES_API_KEY=sk-... # international endpoint
|
|
20
|
+
export AGNES_CN_API_KEY=cn-sk-... # China endpoint (optional)
|
|
17
21
|
```
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
```bash
|
|
24
|
+
# Text chat via the Agnes model catalog
|
|
25
|
+
pi --model agnes/agnes-2.5-flash "hello"
|
|
26
|
+
|
|
27
|
+
# Image / video: just ask in any pi session — the agnes-media skill teaches
|
|
28
|
+
# the model to call the agnes_image / agnes_video tools.
|
|
29
|
+
pi "Generate a 2-second video of a red apple falling off a wooden table, photorealistic"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or run `/login` once and pi stores the key in `~/.pi/agent/auth.json` for you.
|
|
22
33
|
|
|
23
34
|
## What it registers
|
|
24
35
|
|
|
25
|
-
###
|
|
36
|
+
### 1. Text models (in `/model`)
|
|
26
37
|
|
|
27
|
-
Only **text/LLM** models are registered
|
|
28
|
-
|
|
38
|
+
Only **text/LLM** models are registered. Image/video are **not** selectable
|
|
39
|
+
models — they live in the tools + skill. Both regions:
|
|
29
40
|
|
|
30
41
|
| Provider | Region | Base URL | Auth |
|
|
31
42
|
|---|---|---|---|
|
|
32
43
|
| `agnes` | International | `https://apihub.agnes-ai.com/v1` | `AGNES_API_KEY` |
|
|
33
44
|
| `agnes-cn` | China | `https://api.agnes-ai.cn/v1` | `AGNES_CN_API_KEY` |
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
Seed text models: `agnes-2.0-flash`, `agnes-2.5-flash`, `agnes-2.5-pro`,
|
|
36
47
|
`agnes-2.5-pro-alpha`, `agnes-3.0-flash`. Live `/v1/models` discovery adds
|
|
37
|
-
newer text models automatically (image/video are filtered out).
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
pi --model agnes/agnes-2.5-flash "hello"
|
|
41
|
-
pi --model agnes-cn/agnes-2.5-flash "你好"
|
|
42
|
-
```
|
|
48
|
+
newer text models automatically (image/video entries are filtered out).
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
`agnes-cn` only appears once a CN key is configured (env var or a key stored
|
|
51
|
+
under `agnes-cn` in `auth.json`).
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
### 2. Media tools + skill (any chat model)
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
2. **Skill** — `agnes-media` (auto-loaded with this package) tells the agent
|
|
50
|
-
exactly how to call the tools: prompt shaping, reference-image handling,
|
|
51
|
-
endpoint selection, defaults.
|
|
55
|
+
Two ways to generate media — no `/model` switch:
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
`agnes-
|
|
57
|
+
- **Tools** — `agnes_image`, `agnes_video` callable by any model.
|
|
58
|
+
- **Skill** — `agnes-media` (auto-loaded) teaches the model how to call the
|
|
59
|
+
tools: prompt shaping, reference-image handling, endpoint choice, defaults.
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
Defaults: image `agnes-image-2.5-flash`, video `agnes-video-2.5-flash`.
|
|
62
|
+
Output: `.pi/generated-images/`, `.pi/generated-videos/` (project-relative).
|
|
57
63
|
|
|
58
|
-
|
|
|
64
|
+
| Tool | Key params |
|
|
59
65
|
|---|---|
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `endpoint` | `agnes` (default) or `agnes-cn` |
|
|
63
|
-
| `images` | optional base64 data URIs for reference/conditioning |
|
|
64
|
-
| `response_format` | default `png` |
|
|
66
|
+
| `agnes_image` | `prompt`, `model`, `endpoint`, `images` (base64 data URIs), `response_format` |
|
|
67
|
+
| `agnes_video` | `prompt`, `model`, `endpoint`, `images` (1 = img2vid, >1 = keyframes), `num_frames`, `frame_rate` |
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
## Install sources
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
| `endpoint` | `agnes` (default) or `agnes-cn` |
|
|
73
|
-
| `images` | 1 image = image-to-video; >1 = keyframes mode |
|
|
74
|
-
| `num_frames` / `frame_rate` | defaults 121 / 24 |
|
|
71
|
+
```bash
|
|
72
|
+
pi install npm:pi-agnes-tools
|
|
73
|
+
pi install git:github.com/DraconDev/pi-agnes-tools
|
|
74
|
+
```
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
Listed in the [pi.dev/packages gallery](https://pi.dev/packages) — it auto-indexes
|
|
77
|
+
npm packages tagged with the `pi-package` keyword (this package has it, plus
|
|
78
|
+
`pi-extension` / `pi-skill`), and carries an `image` field in its `pi` manifest
|
|
79
|
+
for a visual preview card.
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
> **Replaces `pi-agnes`.** This plugin owns the `agnes` / `agnes-cn` providers
|
|
82
|
+
> outright. Uninstall `pi-agnes` if you have it — two registrations would
|
|
83
|
+
> overwrite each other.
|
|
79
84
|
|
|
80
|
-
|
|
85
|
+
## Auth
|
|
81
86
|
|
|
82
|
-
`
|
|
83
|
-
|
|
87
|
+
Resolution order: `AGNES_API_KEY` / `AGNES_CN_API_KEY` env vars →
|
|
88
|
+
`/login`-stored key in `~/.pi/agent/auth.json`.
|
|
84
89
|
|
|
85
90
|
## Notes
|
|
86
91
|
|
|
87
|
-
- `executionMode: parallel` for image (fast, stateless)
|
|
88
|
-
-
|
|
92
|
+
- `executionMode: parallel` for image (fast, stateless); `sequential` for
|
|
93
|
+
video (long-running poll, up to 30 min).
|
|
94
|
+
- **Video model availability is per-distributor.** In practice
|
|
95
|
+
`agnes-video-v2.0` is the reliable text-to-video model (5s / 720p clip,
|
|
96
|
+
completed payload carries the video at a top-level `url` — with
|
|
97
|
+
`metadata.url` as a fallback; the tool handles both). `agnes-video-2.5-flash`
|
|
98
|
+
may require a `mode` field this tool does not send, and `agnes-video-2.5`
|
|
99
|
+
can be unavailable under some plans ("No available channel"). If the
|
|
100
|
+
default `2.5-flash` fails, call the tool with `model: "agnes-video-v2.0"`.
|
|
101
|
+
- `num_frames` / `frame_rate` are only sent when explicitly provided — some
|
|
102
|
+
video routes reject those request fields and apply their own defaults.
|
|
103
|
+
- Debug: `PI_AGNES_TOOLS_DEBUG=1` logs registration + request decisions to stderr.
|
|
104
|
+
- MIT licensed. Source: [github.com/DraconDev/pi-agnes-tools](https://github.com/DraconDev/pi-agnes-tools).
|
|
@@ -183,6 +183,10 @@ async function pollVideo(baseUrl, videoId, apiKey, signal) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
async function requestVideo(baseUrl, apiKey, opts) {
|
|
186
|
+
// NOTE: the API accepts different fields per model. The flash/2.5 routes
|
|
187
|
+
// reject `num_frames` / `frame_rate` as request fields; v2.0 accepts the
|
|
188
|
+
// request with defaults. So we only send them when the caller explicitly
|
|
189
|
+
// provides them — never as hard-coded defaults.
|
|
186
190
|
const body = { model: opts.model, prompt: opts.prompt };
|
|
187
191
|
if (opts.num_frames) body.num_frames = opts.num_frames;
|
|
188
192
|
if (opts.frame_rate) body.frame_rate = opts.frame_rate;
|
|
@@ -204,8 +208,10 @@ async function requestVideo(baseUrl, apiKey, opts) {
|
|
|
204
208
|
if (!videoId) throw new Error("Agnes video API returned no video_id");
|
|
205
209
|
|
|
206
210
|
const result = task.status === "completed" ? task : await pollVideo(baseUrl, videoId, apiKey, opts.signal);
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
// The completed payload carries the video URL at top-level `url` (v2.0 and
|
|
212
|
+
// friends). Some routes nest it under `metadata.url`, so check both.
|
|
213
|
+
const url = (result && (result.url || (result.metadata && result.metadata.url))) || null;
|
|
214
|
+
if (!url) throw new Error("Agnes video API returned no video url");
|
|
209
215
|
|
|
210
216
|
const directory = join(process.cwd(), ".pi", "generated-videos");
|
|
211
217
|
await mkdir(directory, { recursive: true });
|
|
@@ -298,8 +304,10 @@ async function executeVideo(_toolCallId, params, signal) {
|
|
|
298
304
|
model: rawModel,
|
|
299
305
|
prompt,
|
|
300
306
|
images: params.images || [],
|
|
301
|
-
|
|
302
|
-
|
|
307
|
+
// Only forward when explicitly provided — some Agnes video routes reject
|
|
308
|
+
// num_frames/frame_rate as request fields and use their own defaults.
|
|
309
|
+
num_frames: params.num_frames,
|
|
310
|
+
frame_rate: params.frame_rate,
|
|
303
311
|
signal,
|
|
304
312
|
});
|
|
305
313
|
|
|
@@ -463,6 +471,7 @@ function streamStandaloneVideo(model, context, options) {
|
|
|
463
471
|
signal: options && options.signal,
|
|
464
472
|
});
|
|
465
473
|
pushDone(stream, output, "Generated video saved to: " + fileLink(saved.filePath) + "\n\nVideo URL: " + saved.remoteUrl);
|
|
474
|
+
pushDone(stream, output, "Generated video saved to: " + fileLink(saved.filePath) + "\n\nVideo URL: " + saved.remoteUrl);
|
|
466
475
|
} catch (error) {
|
|
467
476
|
pushError(stream, output, error, options && options.signal);
|
|
468
477
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agnes-tools",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "Agnes AI for pi: /model text model catalog (intl + CN) plus image/video generation as callable tools + auto-loaded skill. No model switch needed for media.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pi",
|
|
8
|
-
"extension",
|
|
9
8
|
"pi-package",
|
|
9
|
+
"pi-extension",
|
|
10
|
+
"pi-skill",
|
|
10
11
|
"agnes",
|
|
11
12
|
"agnes-ai",
|
|
12
13
|
"image-generation",
|
|
@@ -21,7 +22,8 @@
|
|
|
21
22
|
"files": [
|
|
22
23
|
"extensions",
|
|
23
24
|
"skills",
|
|
24
|
-
"README.md"
|
|
25
|
+
"README.md",
|
|
26
|
+
".github/banner.png"
|
|
25
27
|
],
|
|
26
28
|
"scripts": {
|
|
27
29
|
"test": "node --test"
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
],
|
|
38
40
|
"skills": [
|
|
39
41
|
"./skills"
|
|
40
|
-
]
|
|
42
|
+
],
|
|
43
|
+
"image": "https://raw.githubusercontent.com/DraconDev/pi-agnes-tools/main/.github/banner.png"
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -28,7 +28,14 @@ directly — do NOT switch to an Agnes model.
|
|
|
28
28
|
| `model` | default `agnes-video-2.5-flash`; others: `agnes-video-2.5`, `agnes-video-v2.0` |
|
|
29
29
|
| `endpoint` | `agnes` (default) or `agnes-cn` |
|
|
30
30
|
| `images` | 1 image = image-to-video; >1 = keyframes mode (base64 data URIs) |
|
|
31
|
-
| `num_frames` / `frame_rate` |
|
|
31
|
+
| `num_frames` / `frame_rate` | only sent when you pass them; some routes reject these fields |
|
|
32
|
+
|
|
33
|
+
**Model availability is per-distributor:** `agnes-video-v2.0` is the reliable
|
|
34
|
+
text-to-video model (returns a top-level `url`). `agnes-video-2.5-flash`
|
|
35
|
+
(sometimes the default) may require a `mode` field this tool does not send,
|
|
36
|
+
and `agnes-video-2.5` can be unavailable under some plans. If a video call
|
|
37
|
+
fails with `mode is required` or `No available channel`, retry with
|
|
38
|
+
`model: "agnes-video-v2.0"`.
|
|
32
39
|
|
|
33
40
|
## Notes
|
|
34
41
|
|