From 9d17023d16814d207cc78558e9f39b958860487a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Aug 2026 16:02:31 +0000 Subject: [PATCH] docs: document status-dependent action attempt values Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 7a2c1372..fd573ac1 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,31 @@ When the `waitForActionAttempt` option is enabled, the SDK: - Rejects with a `SeamActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached. - Both errors expose an `actionAttempt` property. +The `ActionAttempt` type is a union discriminated by `action_type` and `status`. +The `error` and `result` properties are typed as `null` +except for the status that populates them, +so narrow on the `status` before reading them: + +```ts +const actionAttempt = await seam.locks.unlockDoor( + { device_id }, + { waitForActionAttempt: false }, +) + +if (actionAttempt.status === 'success') { + console.log(actionAttempt.result) // The result is non-null here. +} + +if (actionAttempt.status === 'error') { + console.log(actionAttempt.error.message) // The error is non-null here. +} +``` + +Waiting for an action attempt resolves with the successful action attempt, +so after checking `status === 'success'` the `result` is immediately usable. +Use the `SucceededActionAttempt` and `FailedActionAttempt` types +to extract the success and error members from any action attempt type. + If you already have an action attempt ID and want to wait for it to resolve, simply use