Metadata-Version: 2.5
Name: datalayer_skills
Version: 0.7.1
Project-URL: Home, https://github.com/datalayer/skills
Author-email: Datalayer <info@datalayer.io>
License: BSD 3-Clause License
        
        Copyright (c) 2025-2026, Datalayer, Inc.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: AI,Agents,Datalayer,Skills
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: agent-skills>=1.5.0
Requires-Dist: datalayer-core
Provides-Extra: lint
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: skills
Requires-Dist: beautifulsoup4>=4.12; extra == 'skills'
Requires-Dist: httpx>=0.27; extra == 'skills'
Requires-Dist: imageio-ffmpeg>=0.5; extra == 'skills'
Requires-Dist: pandas>=2.0; extra == 'skills'
Requires-Dist: pdf2image>=1.17; extra == 'skills'
Requires-Dist: pillow>=10.0; extra == 'skills'
Requires-Dist: playwright>=1.45; extra == 'skills'
Requires-Dist: pypdf>=4.0; extra == 'skills'
Provides-Extra: skills-accounting
Requires-Dist: pandas>=2.0; extra == 'skills-accounting'
Provides-Extra: skills-crawl
Requires-Dist: beautifulsoup4>=4.12; extra == 'skills-crawl'
Requires-Dist: httpx>=0.27; extra == 'skills-crawl'
Provides-Extra: skills-github
Requires-Dist: httpx>=0.27; extra == 'skills-github'
Provides-Extra: skills-image
Requires-Dist: pillow>=10.0; extra == 'skills-image'
Requires-Dist: playwright>=1.45; extra == 'skills-image'
Provides-Extra: skills-pdf
Requires-Dist: pdf2image>=1.17; extra == 'skills-pdf'
Requires-Dist: pillow>=10.0; extra == 'skills-pdf'
Requires-Dist: pypdf>=4.0; extra == 'skills-pdf'
Provides-Extra: skills-video
Requires-Dist: imageio-ffmpeg>=0.5; extra == 'skills-video'
Requires-Dist: playwright>=1.45; extra == 'skills-video'
Provides-Extra: test
Requires-Dist: imageio-ffmpeg>=0.5; extra == 'test'
Requires-Dist: pandas>=2.0; extra == 'test'
Requires-Dist: pytest-asyncio>=0.21; extra == 'test'
Requires-Dist: pytest>=7.0; extra == 'test'
Description-Content-Type: text/markdown

<!--
  ~ Copyright (c) 2025-2026 Datalayer, Inc.
  ~
  ~ BSD 3-Clause License
-->

[![Datalayer](https://images.datalayer.io/legacy/datalayer-25.svg)](https://datalayer.ai)

[![Become a Sponsor](https://img.shields.io/static/v1?label=Become%20a%20Sponsor&message=%E2%9D%A4&logo=GitHub&style=flat&color=1ABC9C)](https://github.com/sponsors/datalayer)

# ☰ 🧰 Datalayer Skills

Agent skills for the [Datalayer](https://datalayer.ai) platform, discovered by
[agent-skills](https://github.com/datalayer/agent-skills) through Python entry
points: install the package, and the skills are there.

## Installation

```bash
pip install datalayer-skills
```

The skills' scripts run where the agent's sandbox runs. What a skill's scripts
import is in an extra of its own, and `skills` brings them all:

```bash
pip install "datalayer-skills[skills]"            # every skill's dependencies
pip install "datalayer-skills[skills-video]"      # one skill's
python -m playwright install chromium             # once, for page snapshots and recordings
```

| Extra | Brings |
|-------|--------|
| `skills-accounting` | pandas |
| `skills-crawl` | httpx, beautifulsoup4 |
| `skills-github` | httpx |
| `skills-pdf` | pypdf, pdf2image, Pillow |
| `skills-image` | Pillow, Playwright |
| `skills-video` | imageio-ffmpeg (an ffmpeg binary; the system's is used when present), Playwright |

The Datalayer agent runtime image installs it, so an agent spec names these
skills by their names (for example `datalayer-memory-add`) and the runtime
loads them from the entry points, with no skill spec of their own.

## Available Skills

| Skill | Scripts | What it does |
|-------|---------|--------------|
| `datalayer-whoami` | `whoami` | The authenticated user's profile from Datalayer IAM |
| `datalayer-memory-add` | `add` | Keep one thing in the person's memory of the agent, in their words |
| `datalayer-memory-search` | `search` | The memories closest to a query |
| `datalayer-memory-list` | `list_memories` | Every memory, newest first, with its id |
| `datalayer-memory-delete` | `delete`, `delete_all` | Forget one memory by id, or everything once the person confirmed how many |
| `datalayer-email` | `send_email` | One email to the person whose agent this is, through Datalayer's mailer: never another address, a few a day, no mail credential |
| `accounting` | `reconcile`, `variance`, `aging`, `close_summary` | Two ledgers reconciled, two periods compared, open invoices aged, a trial balance closed, over CSV exports |
| `crawl` | `fetch_page`, `fetch_js_page`, `extract_links`, `extract_tables`, `crawl_site`, `check_robots` | Pages fetched (rendered when they need JavaScript), their links and tables, a site walked within its robots.txt |
| `events` | `event` | Events of an agent created, read, listed and updated |
| `github` | `list_repos`, `get_repo`, `list_issues`, `list_prs`, `search_repos` | Repositories, issues and pull requests read from GitHub (needs a token) |
| `image` | `image_info`, `resize_image`, `crop_image`, `convert_image`, `optimize_image`, `thumbnail_image`, `snapshot_page`, `snapshot_video_frame` | Snapshots of pages and video frames; images read, resized, cropped, converted, optimized and thumbnailed |
| `image-stock` | `list_providers`, `search_images`, `image_attribution`, `download_image` | Stock photos searched on Unsplash, Pexels, Pixabay and Freepik (the ones a key is set for), the credit line each asks for, a photo downloaded into the workspace |
| `pdf` | `check_fillable_fields`, `extract_form_field_info`, `fill_fillable_fields`, `fill_pdf_form_with_annotations`, `convert_pdf_to_images`, `check_bounding_boxes`, `create_validation_image` | PDF forms checked, their fields read and filled, pages turned to images |
| `text-summarizer` | `summarize` | A text shortened to its key sentences or points |
| `video` | `record_and_zoom`, `save_to_space`, `video_info`, `record_page`, `trim_video`, `zoom_video`, `transcode_video`, `optimize_video`, `video_thumbnail`, `video_to_gif`, `concat_videos` | Pages recorded and zoomed as an MP4 to share, kept in the person's Space; videos read, trimmed, zoomed in and out, transcoded, optimized, framed, turned to GIF and joined |

`accounting`, `crawl`, `events`, `github`, `image`, `pdf`, `text-summarizer`
and `video` were bundled with agent-skills until its 1.3.0, as
`agent_skills.skills.<name>`. They are `datalayer_skills.skills.<name>` now,
under the same skill names, and agent-skills is the framework alone.

## The environment a skill needs

A skill says in its `SKILL.md` frontmatter (`env`) which environment variables
it reads, and agent-skills (1.5.0 and later) offers it to an agent only when it
has what it needs: `github` needs `GITHUB_TOKEN`, `events` and
`datalayer-whoami` need `DATALAYER_API_KEY`, and `image-stock` needs one key at
least among its providers'. A skill without its environment is not listed and
cannot be run.

## Stock images

`image-stock` searches stock photos on the providers a key is set for. Every
variable is optional, and one key is enough:

| Variable | What it is |
|----------|------------|
| `UNSPLASH_ACCESS_KEY` | An Unsplash application's access key ([unsplash.com/developers](https://unsplash.com/developers)) |
| `PEXELS_API_KEY` | A Pexels API key ([pexels.com/api](https://www.pexels.com/api/)) |
| `PIXABAY_API_KEY` | A Pixabay API key ([pixabay.com/api/docs](https://pixabay.com/api/docs/)) |
| `FREEPIK_API_KEY` | A Freepik API key, now issued as a Magnific one ([magnific.com/api](https://www.magnific.com/api)) |
| `UNSPLASH_TIER` | `production` once Unsplash approved the application (1000 requests an hour instead of 50) |
| `UNSPLASH_APP_NAME` | The application's name at Unsplash, written in the links back to it |
| `FREEPIK_REQUESTS_PER_MINUTE` | The limit kept for Freepik (30 unless set) |
| `IMAGE_STOCK_DEFAULT_PROVIDER` | The provider searched when none is named and it is configured |
| `IMAGE_STOCK_DOWNLOAD_DIR` | The folder downloads go to, under the working directory (`images`) |
| `IMAGE_STOCK_TIMEOUT_SECONDS` | The wait for a provider, 1 to 25 (10) |

With no key the skill is not activated. With some, only those providers are
offered, and a search of all providers covers exactly those:

```bash
export PEXELS_API_KEY=...
python datalayer_skills/skills/image_stock/scripts/list_providers.py
python datalayer_skills/skills/image_stock/scripts/search_images.py "mountain lake" --per-page 3
python datalayer_skills/skills/image_stock/scripts/image_attribution.py --provider pexels \
  --author "Jane Doe" --page-url https://www.pexels.com/photo/lake-123/
python datalayer_skills/skills/image_stock/scripts/download_image.py --provider pexels --id 123 \
  --url https://images.pexels.com/photos/123/lake.jpeg
```

Results have one shape whatever the provider (`id`, `provider`, `title`,
`author`, `author_url`, `page_url`, `preview_url`, `full_url`, `width`,
`height`, `license`, `credit_required`, `credit`). The scripts keep to each
provider's terms: its published rate limit, counted between runs; the credit
line in the form it asks for (Unsplash's and Pexels' are required, Freepik's
for a free resource, Pixabay's appreciated); an Unsplash download reported to
Unsplash; a Pixabay answer kept for a day, and its images downloaded rather
than linked. A download is fetched over https from the provider's own image
hosts and written under the working directory. The scripts use the standard
library alone and never print a key.

## Recording a page, zoomed, to share

`record_and_zoom` records a page with a headless Chromium (from the moment it
has loaded), zooms in and out on it with eased moves, and writes an MP4 anyone
can play — H.264, yuv420p, `+faststart`, 30 frames a second:

```bash
python datalayer_skills/skills/video/scripts/record_and_zoom.py https://datalayer.ai hero.mp4 \
  --seconds 8 --zoom "2-3-5-6-2-0.25-0.75"
```

With no `--zoom`, one zoom on the centre to 1.5x over the middle half of the
recording; `--zoom none` keeps the page whole. The zooms are written as for
`zoom_video` (below), their seconds counted from the page loaded.

With `--save` (or `save_to_space <file>` for any file the skill made), the file
is kept in the person's Datalayer Space: the script sends it to the agent
runtime on the pod's loopback (`POST /api/v1/spaces/files`, agent-runtimes),
which keeps it, with the identity it holds for the runtime's owner, in a Dataset
of their default Space (`Videos` when unsaid; `--space`, `--folder`, `--name`,
`--collection` choose others), listed under the Space's Contents. No token is
asked for or sent. When no Space can be reached, the script says why and the
local file stays.

## Zooming a video

`zoom_video` zooms in on a point of a video and back out, once or several
times, and keeps the video's size:

```bash
python datalayer_skills/skills/video/scripts/zoom_video.py demo.mp4 demo_zoom.mp4 \
  "2-3-6-7-1.8-0.5-0.5|10-11-14-15-2.2-0.8-0.25" --ease smooth
```

A zoom is `s1-s2-s3-s4-f-x-y`: the zoom-in runs from `s1` to `s2` seconds, the
picture stays zoomed until `s3`, the zoom-out is complete at `s4`; `f` is the
factor (`2` doubles the picture), and `x`, `y` the point zoomed on, each from 0
to 1 from the bottom-left corner. Several zooms are separated by `|`.

| Option | What it does |
|--------|--------------|
| `--ease linear` | The zoom moves at a constant speed (when unsaid) |
| `--ease smooth` | Each move starts and ends slowly |
| `--trim START-END` | Cuts the video to those seconds first; the zooms' times then count from the trim's start |
| `--crf N` | The quality, 18 when unsaid (lower is better and larger) |
| `--preset NAME` | H.264's preset, `medium` when unsaid |

Each frame is scaled by the factor of its time, then cropped back to the
video's size around the point; near an edge the picture stops at the edge. An
`.mp4` is H.264 with the audio copied, a `.webm` VP9 with Opus. Through an
agent: `run_skill_script` with `skill_name` `video`, `script_name`
`zoom_video`, and the same values in `args`.

## The memory skills

An agent whose spec says `memory: mem0` keeps a durable memory of the person
whose runtime it is: mem0, in PostgreSQL (pgvector) on a Datalayer runtime,
embedded through ai-inference with the runtime's token. The memory skills let
the person keep, read, list and delete it on request.

**How the scripts reach the memory.** A skill script runs in the agent's
sandbox, the Jupyter container beside the agent runtime in the same pod. It
calls the runtime's memory routes on the pod's loopback (by default
`http://127.0.0.1:8765`), with the Python standard library only:

| Script | Route |
|--------|-------|
| `add` | `POST /api/v1/agents/{agent}/memory` with `{"content", "metadata"}` |
| `search` | `POST /api/v1/agents/{agent}/memory/search` with `{"query"}` |
| `list_memories` | `GET /api/v1/agents/{agent}/memory` |
| `delete` | `DELETE /api/v1/agents/{agent}/memory/{id}` |
| `delete_all` | `DELETE /api/v1/agents/{agent}/memory?count=N` |

The scripts do not use mem0's client directly. That would need the PostgreSQL
password and the ai-inference token in the sandbox, which holds neither, and
it would let the script choose whose memory it opens. Going through the
runtime needs no egress (the call stays in the pod) and no secret, and keeps
the scope where agent-runtimes keeps it.

**Scope.** The runtime keeps the memory under the composite key (user, agent):
the user is the runtime owner's personal account, read from the runtime's
trusted environment (`DATALAYER_USER_UID`), and the agent is the agent's own
id. The scripts send neither. An id that is not one of this agent's memories
of the person is not found, and `delete_all` forgets nothing when the agent
remembers more than the `count` the person confirmed.

**Which agent.** `--agent` (the agent's name on the runtime), else
`AGENT_RUNTIMES_AGENT_ID`, else the runtime's only agent. When several agents
run on the runtime, the script asks for `--agent`.

**Optional environment.** `AGENT_RUNTIMES_URL` (another runtime),
`AGENT_RUNTIMES_PORT` (its port on the loopback).

## How It Works

The package declares each skill in the `agent_skills.skills` entry-point group
of `pyproject.toml`:

```toml
[project.entry-points."agent_skills.skills"]
datalayer-whoami = "datalayer_skills.skills.whoami"
datalayer-memory-add = "datalayer_skills.skills.memory_add"
datalayer-memory-search = "datalayer_skills.skills.memory_search"
datalayer-memory-list = "datalayer_skills.skills.memory_list"
datalayer-memory-delete = "datalayer_skills.skills.memory_delete"
video = "datalayer_skills.skills.video"
# … and one line per other skill
```

Each value is a module that holds a `SKILL.md` and a `scripts/` directory.
`agent_skills.discover_entrypoint_skills()` loads them, and
`AgentSkillsToolset(discover_entrypoints=True)` offers them to an agent.
An agent runtime loads the ones its agent spec names.

## Development

```bash
pip install -e ".[test]"
pytest
```

The tests run each memory script against a fake agent runtime on the
loopback, and through agent-skills' toolset with an eval sandbox; the
accounting scripts on small books; the video zoom's filter and arguments, and
a zoom on a small generated clip where ffmpeg is installed; `record_and_zoom`'s
encode of a generated recording, a real page recorded where Playwright's
Chromium is installed, and `save_to_space` against a fake agent runtime.

## Release

Set the version in `datalayer_skills/__version__.py`, say what changed in
`CHANGELOG.md`, merge to `main`, then
push the tag `v<version>`. The Release workflow runs the tests, builds, and
publishes to PyPI through trusted publishing (the `pypi` environment).
