Skip to content

feat(events): SDK methods for event-emit primitive (PR-1b)#38

Merged
mikemolinet merged 1 commit into
mainfrom
feat/events-and-subscriptions-sdk
May 11, 2026
Merged

feat(events): SDK methods for event-emit primitive (PR-1b)#38
mikemolinet merged 1 commit into
mainfrom
feat/events-and-subscriptions-sdk

Conversation

@mikemolinet
Copy link
Copy Markdown
Collaborator

Summary

Adds 4 SDK methods to AgentsResource for the new event-emit primitive endpoints (cueapi-core PR #71, merged 03:53Z, OSS sibling of cueapi/cueapi#731). All 4 endpoints are rooted under /v1/agents/{ref}/, so they fit the existing AgentsResource sub-resource shape (.inbox, .sent, .webhook_secret_get are also agent-scoped sub-resource methods).

Closes Backlog row cmp0h2mbg000104l8jgnzvgnu.

New methods

Method Endpoint
subscriptions_create(ref, *, event_type, delivery_target, webhook_url=None) POST /v1/agents/{ref}/subscriptions
subscriptions_list(ref) GET /v1/agents/{ref}/subscriptions
subscriptions_delete(ref, subscription_id) DELETE /v1/agents/{ref}/subscriptions/{id}
events_pull(ref, *, since=None, limit=100, event_type=None) GET /v1/agents/{ref}/events

Wire format pinned

  • subscriptions_create: POST body {event_type, delivery_target, webhook_url?}. webhook_url is default-omitted when None (matches server's extra="forbid" for pull-subscription bodies).
  • subscriptions_list: GET (no params).
  • subscriptions_delete: DELETE on /subscriptions/{id}. Idempotent per server contract — re-DELETE returns 200.
  • events_pull: GET with limit (default 100, server caps at 1000) + optional since (cursor, BIGSERIAL id) + optional event_type filter.

Tests

11 new tests in tests/test_agents_resource.py:

  • TestSubscriptionsCreate: pull-minimal, webhook-with-url, webhook_url-omitted-when-None
  • TestSubscriptionsList: GET path (opaque id + slug-form)
  • TestSubscriptionsDelete: DELETE path
  • TestEventsPull: defaults, since-cursor, event_type filter, all-params combined, explicit since=0 (not collapsed to default)
11 passed, 20 deselected in 0.01s

Full local suite: 118 passed + 19 pre-existing errors in test_cues.py (api_key is required — environment-specific, NOT from this PR). Zero regressions.

Depends on cueapi-core PR #71 (now merged)

Endpoints these SDK methods call live in cueapi-core via PR #71 — merged 2026-05-11 03:53Z, commit 50d2b2c2. Self-hosters running cueapi-core ≥ that revision get the endpoints; older revisions would return 404 (acceptable behavior for a server that hasn't picked up the substrate yet).

Test plan

  • 11 new tests pass locally
  • Verified server contract via app/routers/events.py body schemas + app/services/events_service.py query semantics
  • Wire format pinned (body field for create, query params for pull)
  • Default-omit webhook_url when None
  • cueapi-core PR #71 merged (50d2b2c2)
  • CI green
  • Admin-merge per agents-merge-own-PRs directive

🤖 Generated with Claude Code

Adds 4 SDK methods to AgentsResource (since all 4 endpoints are
rooted under /v1/agents/{ref}/):

- subscriptions_create(ref, *, event_type, delivery_target, webhook_url=None)
- subscriptions_list(ref)
- subscriptions_delete(ref, subscription_id)
- events_pull(ref, *, since=None, limit=100, event_type=None)

Mirrors the existing AgentsResource shape (.inbox, .sent,
.webhook_secret_get etc are also sub-resource methods on agents).

## Wire format pinned

- subscriptions_create: POST body with event_type + delivery_target +
  optional webhook_url (default-omit when None to match server's
  extra="forbid" expectation for pull subs)
- subscriptions_list: GET (no params)
- subscriptions_delete: DELETE on /subscriptions/{id} (idempotent
  per server contract — re-DELETE returns 200)
- events_pull: GET with limit (default 100, server caps at 1000) +
  optional since (cursor) + optional event_type filter. Server
  endpoint takes since/event_type as query params.

## Tests

11 new tests in tests/test_agents_resource.py covering:
- pull-subscription minimal body
- webhook-subscription with URL
- webhook_url omitted when None (default-omit discipline)
- subscriptions_list GET path (opaque id + slug-form)
- subscriptions_delete DELETE path
- events_pull defaults
- events_pull with since cursor
- events_pull with event_type filter
- events_pull with all params combined
- events_pull explicit since=0 passed (not collapsed to default)

11/11 pass locally. Full local suite: 118 passed + 19 pre-existing
errors (test_cues.py "api_key is required" — env-specific, not from
this PR).

## Depends on cueapi-core PR-1b

The endpoints these SDK methods call land via cueapi/cueapi-core
PR #71 (in flight). This SDK PR will sit on the branch until #71
merges + cueapi-core deploys; safe to merge afterward (SDK methods
return 404 against a server that doesn't have the endpoints yet,
which is acceptable for a parity port).

Closes Backlog row: cmp0h2mbg000104l8jgnzvgnu
@govindkavaturi-art govindkavaturi-art enabled auto-merge (squash) May 11, 2026 03:55
@mikemolinet mikemolinet merged commit 72fb628 into main May 11, 2026
4 checks passed
@mikemolinet mikemolinet deleted the feat/events-and-subscriptions-sdk branch May 11, 2026 03:55
mikemolinet added a commit that referenced this pull request May 12, 2026
…dy coverage, bump audit to 2026-05-12 (#43)

Manifest was dated 2026-05-07 and missing the PR-1b event-emit endpoint
coverage (4 endpoints) plus the body-verify Phase 2 + inline_body
extensions that shipped 2026-05-09 → 2026-05-12. Brings the manifest
back in sync with SDK head.

Endpoints added to `endpoints_covered`:
- POST /v1/agents/{ref}/subscriptions (subscriptions_create, PR #38;
  inline_body kwarg in PR #42 / cueapi #791 Item 1)
- GET /v1/agents/{ref}/subscriptions (subscriptions_list, PR #38)
- DELETE /v1/agents/{ref}/subscriptions/{sub_id} (subscriptions_delete,
  PR #38)
- GET /v1/agents/{ref}/events (events_pull, PR #38)

Updates to existing entries:
- POST /v1/messages — added auto_verify body-verify Phase 2 (PR #39 +
  #40, cueapi/cueapi #795 + #798 parity)
- POST /v1/cues/{id}/fire — note that #33 shipped (was "in-flight")
- GET /v1/agents/roster — note that #35 shipped (was "in-flight")
- GET /v1/agents/{ref}/presence — note that #35 shipped (was "in-flight")

Replaced `in_flight_ports_2026_05_07` section with
`ports_shipped_2026_05_08_to_2026_05_12` (now-resolved entries) plus a
near-empty `ports_in_flight_2026_05_12` placeholder for future ports.

Backlog row: cmp1vukmc.

Out of scope:
- `model_drift` section walk-through (Cue/Execution/Worker missing
  fields) — PR #31 just landed the Execution + Worker + Agent +
  Message additive models; a fuller `model_drift` refresh deserves a
  separate audit pass against the now-shipped models to figure out
  what's still drifting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant