The repository or configuration that created this release differ from a previous release. View details.
strands-stash-plugin
Write a Stash source plugin in Python. The SDK speaks the plugin protocol for you: you write one function for each thing that your store can do.
It needs Python 3.9 or later, and nothing else.
A plugin
This plugin searches the web:
import hashlib
import json
import socket
import urllib.error
import urllib.request
from datetime import datetime, timezone
from stash_plugin import Failure, Plugin, Record
plugin = Plugin("perplexity", description="The web, through the Perplexity Search API.")
@plugin.initialize
def start(settings, env):
key = env.get("PERPLEXITY_API_KEY", "").strip()
if not key:
raise Failure.validation("set env.PERPLEXITY_API_KEY")
return key
@plugin.search
def search(key, query, limit):
body = json.dumps({"query": query, "max_results": min(limit, 20)}).encode()
request = urllib.request.Request(
"https://api.perplexity.ai/search", data=body,
headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"})
try:
with urllib.request.urlopen(request, timeout=20) as answer:
results = json.load(answer)["results"]
except urllib.error.HTTPError as error:
if error.code in (408, 425):
raise Failure.timeout("Perplexity did not finish the search") from None
if error.code == 429:
raise Failure.throttled("Perplexity throttled the search") from None
if error.code >= 500:
raise Failure.unavailable("Perplexity is unavailable") from None
if error.code in (401, 403):
raise Failure.access_denied("Perplexity refused the API key") from None
raise Failure.other(f"Perplexity answered HTTP {error.code}") from None
except urllib.error.URLError as error:
if isinstance(error.reason, socket.timeout):
raise Failure.timeout("Perplexity did not answer") from None
raise Failure.unavailable("Perplexity is unavailable") from None
except socket.timeout:
raise Failure.timeout("Perplexity did not answer") from None
found = datetime.now(timezone.utc)
return [to_record(result, found) for result in results if result.get("url")]
def to_record(result, found):
url, snippet = result["url"], result.get("snippet") or ""
record_id = hashlib.sha256(f"{url}\0{snippet}".encode()).hexdigest()[:32]
return Record(
# The same passage of the same page keeps its file in each search.
id=record_id,
name=f"{record_id}.md",
body=f"{snippet}\n\nSource: {url}\n",
preview=snippet[:1000],
created_at=found,
)
main = plugin.run
initializegets thesettingstable of the source and the environment of the plugin. It returns thestatethat each other function gets first.- The plugin declares each method that has a function. Leave out the others.
listandsearchget a folder and filters only if the function has the parametersscopeandfilters. Otherwise the SDK refuses such a request withunsupported.@plugin.planreturns what Stash loads when the mount starts. With no plan, the mount loads nothing until a search or get request.listreturns a page and the cursor of the next page (Noneat the end), or the records alone for the last page.searchreturns records, or(record, score)pairs, best first.ingestcan get the same batch again, with the sametoken: write it once. Return an id of the write, orNoneto use the token.- Raise a
Failure(not_found,access_denied,throttled,unavailable,timeout,validation,malformed, orunsupported). Any other exception isother, and its traceback goes to the daemon log, asprintdoes. - After
initialize, functions run on up to 8 threads at the same time. Keep the state thread-safe, for example asqlite3connection behind athreading.Lock. - Do not sleep for a rate limit. Raise
Failure.throttled, and Stash retries. examples/notes.pyuses@plugin.list,@plugin.get, and@plugin.ingest.
A Record
| Field | Description |
|---|---|
id |
The same for the same record in each call. |
body |
The text of the file. |
dir |
The folder below the source, such as team/runbooks. The SDK removes a / at the start or the end. |
name |
The whole file name, such as deploy.md or menu.csv. With none, the file is <date of created_at>__<words of the body>.md. |
preview |
The line that a search shows. With none, the body. |
created_at, updated_at |
A datetime (a naive one is UTC) or RFC 3339 text. |
The file is <dir>/<name>. A .md file is the body, then the time of the
fetch in a YAML block. Any other file is the body alone.
Follow the protocol's
path rules
when a store supplies dir or name.
Publish it
Name the package and its program stash-source-<plugin>. For a source with
no command, Stash runs that program from the PATH of the daemon.
[project]
name = "stash-source-perplexity"
dependencies = ["strands-stash-plugin"]
[project.scripts]
stash-source-perplexity = "stash_source_perplexity:main"
A user installs it with pipx install stash-source-perplexity, and adds a
source with no command:
[sources.web]
kind = "plugin"
plugin = "perplexity"
env = { PERPLEXITY_API_KEY = { command = ["op", "read", "op://me/perplexity/api-key"] } }
A source that writes the trajectory of the agent back sets
write.trajectory = {}, and the plugin must serve ingest. The plugin gets
only a few variables of the daemon, such as PATH and HOME, and the
variables in env.
Try it
examples/notes.py
serves the Markdown files of one folder. It needs no other package:
[sources.notes]
kind = "plugin"
plugin = "notes"
command = ["python3", "/path/to/examples/notes.py"]
settings = { root = "~/notes" }
env = { PYTHONPATH = "/path/to/integrations/plugin-sdk/python/src" }
Run the tests with python3 -m unittest discover -s tests.
Metadata
Release files for strands-stash-plugin 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strands_stash_plugin-0.1.0.tar.gz | 21.3 kB | With provenance | Details for strands_stash_plugin-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strands_stash_plugin-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for strands_stash_plugin-0.1.0-py3-none-any.whl |
Total release size: 34.6 kB
Release files / strands_stash_plugin-0.1.0.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | strands_stash_plugin-0.1.0.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b716952996ee432ec90a07217f4b02659211bf7b9117dbfd40d75eb163e42eec
|
|
BLAKE2b-256 checksum How to use checksums |
eb93346353ccee5027e370c6c8289b5bd6364c2fae898edc6ebcb9cb63cd6df2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / strands_stash_plugin-0.1.0-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | strands_stash_plugin-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14148f3c61edd3bf457be16fc9429992cc38215d615845976d585d38e86f02e3
|
|
BLAKE2b-256 checksum How to use checksums |
8f694e8ee7bba70c328fc95cc7ed7e0dedac7a603ea77040d0102967cfbcbab0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for strands-stash-plugin 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Change of provenance
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.0.0 github.com/mkmeral/harness-sdk
- Added 0.1.0 github.com/strands-agents/stash
Attestation for strands_stash_plugin-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.