iii-observe
하는 일
원본 함수를 고치지 않고, 한 함수가 다른 함수의 이벤트에 반응하게 만드는 방법을 보여 줍니다. 기존 iii 함수에 알림, 로그 기록, 후속 작업을 추가하려는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓다른 함수가 성공하거나 실패한 뒤 후속 작업을 실행하고 싶을 때.
- ✓기존 함수를 수정하지 않고 알림이나 로그 기록을 추가하고 싶을 때.
- ✓예전 트리거 코드를 새 옵저버 방식으로 옮기는 중일 때.
스킬 링크
https://github.com/iii-hq/iii/blob/main/skills/iii-observe/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“orders::validate 함수가 실패할 때마다 알려 주세요. 그 함수의 코드는 바꾸지 마세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 옵저버로 원본 함수를 대상 함수에 연결하고, 필요하면 필터를 추가합니다. 필터를 통과한 이벤트마다 대상이 호출됩니다. 옵저버는 대상이 등록될 때까지 기다리며, 예전 트리거 방식도 당분간은 계속 동작합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
원본 함수를 바꿔야 하나요?
아니요. 옵저버는 원본 함수의 코드를 고치지 않고 바깥에서 연결합니다.
옵저버가 실행될 호출을 걸러낼 수 있나요?
네. 필터가 어떤 이벤트로 대상을 호출할지 정합니다.
예전 트리거 방식도 여전히 지원되나요?
네. 이 버전에서도 동작하지만, 새 방식은 옵저버입니다.
상세 정보
작성자의 원본 설명
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
인기도
- GitHub 스타
- 19k
- 순위
- #10496
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
iii-sandbox
19k에이전트가 신뢰할 수 없거나 AI가 만든 코드를 임시 격리 가상 머신 안에서 안전하게 실행하고, 끝나면 버리도록 돕습니다.
configuration
19k에이전트가 스키마로 검사하는 이름 있는 설정 값의 공유 레지스트리를 만들도록 돕습니다. 워커가 변경을 읽고 반응할 수 있습니다.
iii
19k에이전트가 iii 워커의 작동 방식을 익혀, 먼저 이미 있는 기능을 확인한 뒤 워커를 만들어 기능을 추가하도록 가르칩니다.
iii-observability
19k에이전트가 iii 엔진에 추적, 구조화된 로그, 지표, 알림을 추가하도록 돕습니다. OpenTelemetry를 써서 시스템에서 무슨 일이 일어나는지 볼 수 있습니다.