roberty-code
SDK oficial para Code Projects da Roberty em Python. Leia argumentos, escreva o resultado e descubra o gatilho da execução sem lidar com variáveis de ambiente.
pip install roberty-code
Python ≥ 3.9. Sem dependências. Tipado.
Uso
from datetime import datetime, timezone
import roberty_code as roberty
print(f"Iniciando ({roberty.environment}, gatilho: {roberty.trigger})")
cpf = roberty.input("cpf") # um argumento
args = roberty.inputs() # todos os argumentos (ou None)
# ... lógica do robô ...
roberty.output({"status": "ok", "processedAt": datetime.now(timezone.utc).isoformat()})
Fora da Roberty o mesmo código roda: inputs() devolve None, output() avisa uma vez e devolve False.
API
| Membro | Retorno | Descrição |
|---|---|---|
roberty.trigger |
str | None |
manual, schedule, webhook ou evaluation |
roberty.environment |
str | None |
production ou preview |
roberty.is_roberty |
bool |
True quando roda na Roberty |
roberty.inputs() |
Any | None |
Todos os argumentos (webhook/evaluation) |
roberty.input(name, default=None) |
Any |
Um argumento específico |
roberty.output(value) |
bool |
Grava o resultado (JSON) lido pela plataforma |
roberty.exception() |
ExceptionDetails | None |
{"message", "stack", "exitCode"} dentro do exceptionHandler |
roberty.run(handler, exit_on_complete=True) |
Any |
Opcional: executa handler(roberty), grava o retorno e encerra com exit code 0/1. Aceita async def |
roberty.ENV_VARS |
dict |
Nomes das variáveis roberty-* |
Erros: RobertyArgsError (arquivo de argumentos com JSON inválido) e RobertyOutputError (valor não serializável; converta datetime com .isoformat()).
exceptionHandler
# on_error.py — declarado em roberty.json como "exceptionHandler": "on_error.py"
import roberty_code as roberty
error = roberty.exception()
print(f"Robô falhou (exit code {error['exitCode']}): {error['message']}")
Atalho run
roberty.run(lambda r: {"status": "ok", "cpf": r.input("cpf")})
Encerra o processo ao terminar; passe exit_on_complete=False para embutir em testes.
Documentação
Guia de Code Projects: contrato de execução, roberty.json, gatilhos e webhook.
Licença
MIT. Copyright © Roberty Automation. Todos os direitos reservados.
Metadata
Release files for roberty-code 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| roberty_code-0.1.0.tar.gz | 6.6 kB | Without provenance | Details for roberty_code-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| roberty_code-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for roberty_code-0.1.0-py3-none-any.whl |
Total release size: 14.7 kB
Release files / roberty_code-0.1.0.tar.gz
| Download URL | roberty_code-0.1.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a439c7e3631b0d107a9b82ced154714fa4c6a2dd79accb1d8cbda29105a9a8b0
|
|
BLAKE2b-256 checksum How to use checksums |
a9233da4907c2d1c39fa84166f7358f13a5b177067c472e82aaf3e29bb229627
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / roberty_code-0.1.0-py3-none-any.whl
| Download URL | roberty_code-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70e94718c9914999d7a216412a02fd10c335edd1215239c77b6f60f0e5a7cf01
|
|
BLAKE2b-256 checksum How to use checksums |
2065557254b571c685092876a893b6b922c00e9bdc0ca983a37d1b5b412e69d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for roberty-code 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.