{{ message }}
Repository navigation
feat(events): Type agent blueprint, instance and registration events - #1729
Merged
Merged
Conversation
Agent Registration is GA, and the API, the OpenAPI spec, and every other WorkOS SDK have carried the nine agent.registration.* events since July. Node never picked them up. Their payloads fell through deserializeEvent as raw snake_case data, and none of the names could be used in a listEvents filter or a webhook endpoint subscription without a cast. A customer building on agent registration hit this with the expired, revoked and deleted events. The webhook endpoint event constants are oagen output. The values are hand-added in spec order under the names the emitter produces, so the next regeneration leaves them unchanged (the same approach as #1686).
Contributor
The agents module already exposes the blueprint and instance APIs, and the API has emitted their seven lifecycle events since August, but a consumer could not name or receive any of them with types. Covering them here types the whole agent.* event family in one release instead of leaving Node a family behind the other SDKs again. The payload files are renamed from agent-registration-event.* to agent-event.* because they now hold every agent.* payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds types and deserialization for all 16
agent.*events: blueprint (3), instance and instance session (4), and registration (9). The API emits all of them, the OpenAPI spec defines them, and the Go, Python, Ruby, PHP and .NET SDKs already type them. Node had none:defaultbranch ofdeserializeEventand came back as raw snake_casedata.EventNamerejected the names inlistEventsat compile time.CreateWebhookEndpointEventsandUpdateWebhookEndpointEventsrejected them increateEndpointandupdateEndpoint.A customer building on agent registration reported
agent.registration.expired,.revokedand.deletedas missing. The blueprint and instance events have the same gap, and the agents module already exposes those APIs.src/agents/interfaces/agent-event.interface.ts. They follow the vault-event pattern (*EventData/*EventResponseData). The shapes match theapi-json-models-zodevent schemas that the spec'sEventSchemavariants are generated from. Where an event payload matches an existing REST model exactly, the REST model is reused.agent.blueprint.createdand.updateduseAgentBlueprintEventData, which isAgentBlueprintplusinvocableAs: { instanceTypes }. The REST model doesn't type that field yet (see Not changed).agent.blueprint.deletedis the slim{ object, id, name, createdAt, updatedAt }.agent.instance.createdand.deletedreuseAgentInstanceanddeserializeAgentInstanceas they are.agent.instance.session.createdand.revokeduseAgentInstanceSessionEventData. It differs from the RESTAgentInstanceSession: it carriesorganizationIdand has nostatus..createdaddspermissionSlugs, the grant computed at mint time, which no other payload reports.agent.registration.createdis the registration with a newAgentRegistrationMethod. This is the event shape, not the RESTAgentRegistration. It has noclaim, it addsmethod, and itsagentIdentitycarriesobjectbut no timestamps.agent.registration.claim.attempt.createdand.claim.completedcarry the claim attempt and the claim (claimedBy: { userId, organizationId }).agent.registration.credential.issued: itsdetailis a discriminated union onkind:{ kind: 'api_key', apiKeyId }or{ kind: 'access_token', jti, expiresAt }.agent.registration.organization.switchedis{ agentRegistrationId, fromOrganizationId, toOrganizationId }.agent.registration.refreshed,.expired,.revokedand.deletedare{ agentRegistrationId }. All four shareAgentRegistrationLifecycleEventData.Agent*Event/*EventResponseinterfaces are added to theEvent/EventResponseunions, soEventNamepicks them up, with matching cases indeserializeEvent. They sit at the top of each union and of the switch, in spec order, away from the feature-flag entries that feat(feature-flags): Handle all feature flag lifecycle events #1721 edits in the same lists.CreateWebhookEndpointEventsandUpdateWebhookEndpointEvents. Both files carry the oagen header. The values are hand-added in spec enum order under the member names the emitter produces, which PHP and Go already use, so the next regeneration produces no diff for them. This is the same approach as fix(events): Type Pipes connected account events #1686.events.spec.tscases, one for blueprint/instance and one for registration, filter on every event and check theeventsquery parameter. They then deserialize each payload. Both delegated and autonomous instances are covered, as are both credentialdetailvariants and events withoutcontext.The blueprint and instance REST endpoints are behind the
agent-blueprints-public-apifeature flag in the API, so only environments with that API enabled emit those seven events. The registration endpoints are no longer gated: #71300 removed the GA'd agent-auth flags.Not changed
AgentBlueprintlacksinvocableAs. The RESTAgentBlueprintreturned bygetAgentBlueprintandlistAgentBlueprintsstill doesn't typeinvocableAs, even though the spec marksinvocable_asas required. The same goes for the create/update options. That's an API-surface change to the agents module, so it's left out here. The blueprint event type adds the field on top ofAgentBlueprint, so it stays correct once the REST model catches up.radar.challenge_created,authentication.reauthentication_succeeded,api_key.updatedand fivepipes.account_connection.*. A full Node regeneration should bring those in, not this PR.deserializeEventunchanged.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
This PR needs no docs change. Separately, the events reference lists six of the nine agent registration events and omits
expired,revokedanddeleted. That's an existing gap in the docs, not in this repo.🤖 Generated with Claude Code