iii-observe
Qué hace
Muestra cómo hacer que una función reaccione a los eventos de otra sin cambiar la original. Es para desarrolladores que quieren añadir alertas, registros o trabajo posterior a una función de iii existente.
Cuándo usarla
- ✓Cuando quieres ejecutar trabajo posterior después de que otra función tenga éxito o falle.
- ✓Cuando quieres añadir alertas o registros a una función existente sin editarla.
- ✓Cuando estás pasando código de disparadores antiguos al enfoque más nuevo de observadores.
Link de la skill
https://github.com/iii-hq/iii/blob/main/skills/iii-observe/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Avísame cada vez que falle la función orders::validate, sin cambiar su código.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La skill conecta una función de origen con un objetivo mediante un observador, añadiendo filtros si hace falta. Cada evento que pasa los filtros invoca el objetivo. El observador espera hasta que el objetivo está registrado, y el enfoque antiguo de disparadores sigue funcionando por ahora.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Observe
Since iii 0.25 every function is observable. iii.observe(source, target, options?) connects a
source function to a target function: each event of the source that passes the observer's filters
invokes the target. It replaces registerTrigger, and an observe descriptor on
registerFunction replaces registerTriggerType. Both old APIs still work in 0.25 (see
Migrating from triggers).
| Part | Fields | Notes |
|---|---|---|
source (left side) |
function_id, namespace?, args?, filters?, on?, capture?, deliver? |
args only for owner-delivered functions. on (auto only): success (default), error, complete. capture (auto and obs.emit): default ['input', 'output', 'caller'], [] allowed. deliver: envelope (default), input, output |
target (right side) |
a registered function id (or { function_id, namespace }) |
No inline handler. The observer stays pending until the target is registered |
options |
id?, max_fires?, expires_in_ms?, max_in_flight?, metadata? |
id defaults to a UUID kept across replays. metadata is the sidecar of every activation |
The source namespace resolves like trigger(): the worker's namespace, except engine::* and
configuration::*, which resolve in default.
Observe a function
Register the target first, then observe. This alerts on failed charges of 500 or more:
import { registerWorker, type Observed } from "iii-sdk";
const iii = registerWorker(process.env.III_URL ?? "ws://localhost:49134");
iii.registerFunction("alerts::payment-failed", async (event: Observed<{ amount: number }>) => {
console.log(event.function_id, event.error?.code, event.input?.amount, event.caller?.worker_name);
return null; // ignored for auto delivery
});
const failures = iii.observe(
{
function_id: "payments::charge",
on: "error",
filters: { "input.amount": { $gte: 500 } },
capture: ["input", "error", "caller"],
},
"alerts::payment-failed",
{ max_in_flight: 4 },
);
await failures.ready(); // rejects with ObserveRejection (error.code) on error or disposed
// later: await failures.dispose()
iii.register_function("alerts::payment-failed", lambda event: print(event["error"]["code"]))
failures = iii.observe(
{"function_id": "payments::charge", "on": "error",
"filters": {"input.amount": {"$gte": 500}}, "capture": ["input", "error", "caller"]},
"alerts::payment-failed",
{"max_in_flight": 4},
)
failures.ready() # blocks; in async code: await failures.ready_async()
use iii_sdk::{Capture, Error, ObserverOptions, Observed, On, RegisterFunction, Source};
use serde_json::{json, Value};
iii.register_function(
"alerts::payment-failed",
RegisterFunction::new(|event: Observed<Value>| {
println!("{} failed: {:?}", event.function_id, event.error);
Ok::<_, Error>(())
}),
);
let failures = iii.observe_with(
Source::function("payments::charge")
.on(On::Error)
.filters(json!({ "input.amount": { "$gte": 500 } }))
.capture([Capture::Input, Capture::Error, Capture::Caller]),
"alerts::payment-failed",
ObserverOptions::default().max_in_flight(4),
);
failures.ready().await?;
client.RegisterFunction("alerts::payment-failed", func(ctx context.Context, data json.RawMessage) (any, error) {
var ev iii.Observed
if err := json.Unmarshal(data, &ev); err != nil {
return nil, err
}
log.Printf("%s failed: %s", ev.FunctionID, ev.Error.Code)
return nil, nil
})
failures, err := client.Observe(iii.Source{
FunctionID: "payments::charge",
On: iii.OnError,
Filters: iii.Filters{"input.amount": iii.Op{"$gte": 500}},
Capture: []iii.Capture{iii.CaptureInput, iii.CaptureError, iii.CaptureCaller},
}, "alerts::payment-failed", iii.ObserverOptions{MaxInFlight: 4})
if err == nil {
err = failures.Ready(ctx) // *iii.ObserveRejectionError carries the code
}
The browser SDK (iii-browser-sdk) has the same observe API as Node.
What the target receives
- Envelope (default
deliver):{ observer_id, activation_id, function_id, namespace, invocation_id, status, input?, output?, error?, caller?, metadata?, started_at_ms, duration_ms }. Only captured fields are present.deliver: 'input'or'output'sends that value alone. - The observer's
options.metadataarrives as the handler's metadata argument (Node and browser second argument, Python `met
Preguntas frecuentes
¿La función de origen necesita cambios?
No. Un observador se conecta a ella desde fuera, sin editar su código.
¿Puedo filtrar qué llamadas ejecutan el observador?
Sí. Los filtros deciden qué eventos invocan el objetivo.
¿Sigue soportado el enfoque antiguo de disparadores?
Sí. Sigue funcionando en esta versión, aunque el enfoque de observadores es el más nuevo.
Detalles
Descripción original del autor
Use when observing iii functions with iii.observe, writing filters, reacting to engine events, writing observable functions with owner delivery (onObserverAdded, obs.emit, obs.call), tuning local dispatch, or migrating from the deprecated registerTrigger / registerTriggerType across TypeScript, browser, Python, Rust, and Go.
repo: iii-hq/iii
Popularidad
- Estrellas en GitHub
- 19 mil
- Posición en el ranking
- #10496
- Licencia
- —
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
iii-sandbox
19 milAyuda a tu agente a ejecutar código no fiable o generado por IA de forma segura dentro de una máquina virtual aislada y temporal, y descartarla al terminar.
configuration
19 milPermite que tu agente configure un registro compartido de valores de configuración con nombre, validados contra un esquema, para que los workers puedan leer los cambios y reaccionar a ellos.
iii
19 milEnseña a tu agente cómo funcionan los workers de iii, para que pueda añadir una capacidad comprobando primero lo que ya existe y después construyendo un worker.
iii-observability
19 milAyuda a tu agente a añadir trazado, registros estructurados, métricas y alertas a un motor iii, usando OpenTelemetry para que puedas ver lo que está pasando.
Skills parecidas
diffs
394 milPermite que tu agente genere un diff real y compartible de los cambios, como enlace de visualización o archivo de imagen, en lugar de un resumen escrito a mano.
coding-agent
394 milAyuda a tu agente a pasar un trabajo de programación grande a Codex, Claude Code u OpenCode como trabajador en segundo plano, y después revisar su progreso.
gh-issues
394 milAyuda a tu agente a encontrar incidencias de GitHub, elegir cuáles trabajar y abrir pull requests con correcciones, incluido el seguimiento de los comentarios de revisión.