remove worked example, refactor calendar create_event seed

This commit is contained in:
gabby committed 2026-10-03 07:14:46 +00:00
1 parent 18f3d6fee5
commit f21baa7ebd
8 files changed
+971 -72

No files matched your search

-66
View File
@@ -362,69 +362,3 @@ A generated skill is accepted only if:
13. If it is a messaging skill, it uses a bridge service over HTTP (never a
service's native protocol), resolves recipients with a SemIf sub-decision,
and sends only on explicit user intent.
## Worked example
A skill that tracks a parcel over HTTP — for real. It reads the tracking number
out of the query (a per-request argument), uses the endpoint and token supplied
by the runner, performs the real lookup, and returns the service's real result:
```python
import json
import re
import urllib.error
import urllib.request
from semif_agent.skills import ActionResult
INTEGRATION = {
"service": "parcel_tracking",
"transport": "http",
"config_vars": ["tracking_api_url", "tracking_api_token"],
}
CONTRACT = {
"tracking_api_url": "Base URL of the parcel-tracking API, e.g. https://api.example.org.",
"tracking_api_token": "Bearer token for the tracking API, if it requires one.",
}
def act(ctx, request):
# A per-request argument: the tracking number comes from the query, not config.
match = re.search(r"\b[A-Z]{2}\d{9}[A-Z]{2}\b", request.text or "")
if match is None:
return ActionResult(
action_log="parcel_tracking: no tracking number found in the request",
new_state=request.text,
needs_input="What is the tracking number?",
)
tracking_id = match.group(0)
base = ctx.config["tracking_api_url"].rstrip("/")
token = ctx.config.get("tracking_api_token", "")
headers = {"Authorization": f"Bearer {token}"} if token else {}
url = f"{base}/track/{tracking_id}"
try:
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req, timeout=15) as response:
payload = json.loads(response.read().decode("utf-8"))
except urllib.error.HTTPError as exc:
return ActionResult(
action_log=f"parcel_tracking: {tracking_id} lookup returned HTTP {exc.code}: {exc.reason}",
new_state=request.text,
)
except (urllib.error.URLError, TimeoutError, ValueError) as exc:
return ActionResult(
action_log=f"parcel_tracking: could not reach {url}: {exc}",
new_state=request.text,
)
status = payload.get("status", "unknown")
report = f"Parcel {tracking_id}: {status}"
if payload.get("location"):
report += f" ({payload['location']})"
return ActionResult(action_log=report, new_state=report)
```
Write skill bodies in this shape: read the request and derive the action's
arguments, declare `INTEGRATION` and `CONTRACT`, perform the real operation in
`act`, keep both stdlib-only, read operational data from `ctx.config`, SemIf any
candidate set, and return the real result in `action_log` / `new_state`.