pi-agnes-tools 0.1.0 → 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/README.md CHANGED
@@ -1,62 +1,104 @@
1
1
  # pi-agnes-tools
2
2
 
3
- Pi extension that exposes **Agnes AI** image/video generation as callable tools — no model switch required. Pairs with [`pi-agnes`](https://pi.dev/packages/pi-agnes) for model registration / auth.
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.
4
6
 
5
- ## Install
7
+ [![npm version](https://img.shields.io/npm/v/pi-agnes-tools)](https://www.npmjs.com/package/pi-agnes-tools)
8
+ [![license: MIT](https://img.shields.io/badge/license-MIT)](./LICENSE)
9
+
10
+ ## Quick start
11
+
12
+ ```bash
13
+ pi install npm:pi-agnes-tools
14
+ ```
15
+
16
+ Export an API key, then use it:
6
17
 
7
18
  ```bash
8
- pi install path:/path/to/pi-agnes-tools
19
+ export AGNES_API_KEY=sk-... # international endpoint
20
+ export AGNES_CN_API_KEY=cn-sk-... # China endpoint (optional)
21
+ ```
22
+
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"
9
30
  ```
10
31
 
32
+ Or run `/login` once and pi stores the key in `~/.pi/agent/auth.json` for you.
33
+
11
34
  ## What it registers
12
35
 
13
- | Tool | Endpoint | What it does |
14
- |---|---|---|
15
- | `agnes_image` | `POST /v1/images/generations` | Generate an image. Saves to `.pi/generated-images/`. Returns the local path and (possibly expiring) remote URL. |
16
- | `agnes_video` | `POST /v1/videos` + poll | Generate a video. Polls every 5s (up to 30 min). Saves `.mp4` to `.pi/generated-videos/`. Supports image-to-video (1 ref image) and keyframes (>1 image). |
36
+ ### 1. Text models (in `/model`)
17
37
 
18
- ## Parameters
38
+ Only **text/LLM** models are registered. Image/video are **not** selectable
39
+ models — they live in the tools + skill. Both regions:
19
40
 
20
- ### `agnes_image`
21
- - `prompt` (required): text prompt
22
- - `model` (default `agnes-image-2.1-flash`): any `agnes-image-*` id
23
- - `endpoint` (`agnes` | `agnes-cn`, default `agnes`): which Agnes region
24
- - `images` (optional): array of base64 data URIs for reference/conditioning
25
- - `response_format` (default `png`)
41
+ | Provider | Region | Base URL | Auth |
42
+ |---|---|---|---|
43
+ | `agnes` | International | `https://apihub.agnes-ai.com/v1` | `AGNES_API_KEY` |
44
+ | `agnes-cn` | China | `https://api.agnes-ai.cn/v1` | `AGNES_CN_API_KEY` |
26
45
 
27
- ### `agnes_video`
28
- - `prompt` (required): text prompt
29
- - `model` (default `agnes-video-2.5-flash`): any `agnes-video-*` id
30
- - `endpoint` (default `agnes`)
31
- - `images` (optional): 1 image → image-to-video, >1 → keyframes mode
32
- - `num_frames` (default 121), `frame_rate` (default 24)
46
+ Seed text models: `agnes-2.0-flash`, `agnes-2.5-flash`, `agnes-2.5-pro`,
47
+ `agnes-2.5-pro-alpha`, `agnes-3.0-flash`. Live `/v1/models` discovery adds
48
+ newer text models automatically (image/video entries are filtered out).
33
49
 
34
- ## Auth
50
+ `agnes-cn` only appears once a CN key is configured (env var or a key stored
51
+ under `agnes-cn` in `auth.json`).
35
52
 
36
- Key resolution order:
53
+ ### 2. Media tools + skill (any chat model)
37
54
 
38
- 1. `AGNES_API_KEY` / `AGNES_CN_API_KEY` env vars (same as `pi-agnes`)
39
- 2. `/login`-stored key from `~/.pi/agent/auth.json` (`agnes` provider)
55
+ Two ways to generate media — no `/model` switch:
40
56
 
41
- | Provider | Endpoint | Env var |
42
- |---|---|---|
43
- | `agnes` | `https://apihub.agnes-ai.com/v1` | `AGNES_API_KEY` |
44
- | `agnes-cn` | `https://api.agnes-ai.cn/v1` | `AGNES_CN_API_KEY` |
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.
45
60
 
46
- ## Example (what the LLM sees / can call)
61
+ Defaults: image `agnes-image-2.5-flash`, video `agnes-video-2.5-flash`.
62
+ Output: `.pi/generated-images/`, `.pi/generated-videos/` (project-relative).
47
63
 
48
- ```jsonc
49
- // Text-to-image
50
- {"name": "agnes_image", "arguments": {"prompt": "a watercolor painting of a fox in a misty pine forest"}}
64
+ | Tool | Key params |
65
+ |---|---|
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` |
51
68
 
52
- // Image-to-video
53
- {"name": "agnes_video", "arguments": {"prompt": "the fox slowly turns its head", "images": ["data:image/png;base64,..."]}}
69
+ ## Install sources
54
70
 
55
- // Multi-frame keyframes
56
- {"name": "agnes_video", "arguments": {"prompt": "fly through a canyon", "images": ["data:...frame1", "data:...frame2"], "model": "agnes-video-2.5"}}
71
+ ```bash
72
+ pi install npm:pi-agnes-tools
73
+ pi install git:github.com/DraconDev/pi-agnes-tools
57
74
  ```
58
75
 
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.
80
+
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.
84
+
85
+ ## Auth
86
+
87
+ Resolution order: `AGNES_API_KEY` / `AGNES_CN_API_KEY` env vars →
88
+ `/login`-stored key in `~/.pi/agent/auth.json`.
89
+
59
90
  ## Notes
60
91
 
61
- - Output paths are project-relative (`.pi/generated-images/`, `.pi/generated-videos/`) — matches where `pi-agnes` model-based generation saves.
62
- - `executionMode: parallel` for image (fast, stateless), `sequential` for video (long-running task, poll loop).
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).