Skip to content

Commit b9db953

Browse files
vvillait88claude
andcommitted
feat(types): describe both gate-default and merchant-override denial shapes
Mirror of node-sdk fix. WalletSignerMismatchBody and WalletAuthRequiresSigningBody required next_steps with a locked-literal action, which only covered the merchant-override shape. Gate-default merchants emit agent_instructions (JSON string) instead. Update both: - next_steps no longer required; action broadened from Literal to NextStepsAction. - Add optional agent_instructions: str. Also add SessionCreateNextSteps TypedDict and thread it through SessionCreateResponse so POST /v1/sessions' structured next_steps (action=deliver_verify_url_and_poll, poll_interval_seconds, steps) is visible in the typed response. Tighten SessionPollNextSteps.action from str to NextStepsAction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d2a1d96 commit b9db953

1 file changed

Lines changed: 43 additions & 9 deletions

File tree

agentscore/types.py

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ class SessionCreateRequest(TypedDict, total=False):
203203
product_name: str
204204

205205

206+
class SessionCreateNextSteps(TypedDict, total=False):
207+
"""Structured action guidance on POST /v1/sessions success.
208+
209+
action is always ``deliver_verify_url_and_poll`` — tells the agent to share verify_url
210+
with the user and poll poll_url with X-Poll-Secret until an operator_token is issued.
211+
"""
212+
213+
action: NextStepsAction
214+
poll_interval_seconds: int
215+
poll_secret_header: str
216+
steps: list[str]
217+
user_message: str
218+
219+
206220
class _SessionCreateResponseRequired(TypedDict):
207221
session_id: str
208222
poll_secret: str
@@ -212,12 +226,14 @@ class _SessionCreateResponseRequired(TypedDict):
212226

213227

214228
class SessionCreateResponse(_SessionCreateResponseRequired, total=False):
229+
# Structured next_steps with action=deliver_verify_url_and_poll.
230+
next_steps: SessionCreateNextSteps
215231
# Cross-merchant memory hint on first session creation.
216232
agent_memory: AgentMemoryHint
217233

218234

219235
class SessionPollNextSteps(TypedDict, total=False):
220-
action: str
236+
action: NextStepsAction
221237
user_message: str
222238
header_name: str
223239
poll_interval_seconds: int
@@ -367,11 +383,11 @@ class AgentMemoryHint(TypedDict):
367383
persist_in_credential_store: list[str]
368384

369385

370-
class _WalletSignerMismatchNextSteps(TypedDict):
371-
action: Literal["regenerate_payment_from_linked_wallet"]
386+
class _WalletSignerMismatchNextStepsRequired(TypedDict):
387+
action: NextStepsAction
372388

373389

374-
class WalletSignerMismatchNextSteps(_WalletSignerMismatchNextSteps, total=False):
390+
class WalletSignerMismatchNextSteps(_WalletSignerMismatchNextStepsRequired, total=False):
375391
user_message: str
376392
learn_more_url: str
377393

@@ -381,41 +397,59 @@ class _WalletSignerMismatchBodyRequired(TypedDict):
381397
claimed_operator: str
382398
actual_signer_operator: str | None
383399
linked_wallets: list[str]
384-
next_steps: WalletSignerMismatchNextSteps
385400

386401

387402
class WalletSignerMismatchBody(_WalletSignerMismatchBodyRequired, total=False):
388403
"""403 body for X-Wallet-Address + mismatched-signer rejections.
389404
390405
Returned when the claimed wallet's operator doesn't match the payment signer's operator.
391406
actual_signer_operator is None if the signer isn't linked to any operator.
407+
408+
Action copy surfaces via one of two paths:
409+
- ``agent_instructions``: JSON-encoded ``{action, steps, user_message}`` set by the
410+
gate's default marshaller (action is typically ``resign_or_switch_to_operator_token``).
411+
- ``next_steps``: structured object set by merchants who override the gate default
412+
(action may be ``regenerate_payment_from_linked_wallet`` or any NextStepsAction).
413+
414+
Agents should check for whichever is present.
392415
"""
393416

394417
expected_signer: str
395418
actual_signer: str
419+
agent_instructions: str
420+
next_steps: WalletSignerMismatchNextSteps
396421
agent_memory: AgentMemoryHint
397422

398423

399-
class _WalletAuthRequiresSigningNextSteps(TypedDict):
400-
action: Literal["use_operator_token"]
424+
class _WalletAuthRequiresSigningNextStepsRequired(TypedDict):
425+
action: NextStepsAction
401426

402427

403-
class WalletAuthRequiresSigningNextSteps(_WalletAuthRequiresSigningNextSteps, total=False):
428+
class WalletAuthRequiresSigningNextSteps(
429+
_WalletAuthRequiresSigningNextStepsRequired, total=False
430+
):
404431
user_message: str
405432
signer_capable_rails: list[str]
406433
learn_more_url: str
407434

408435

409436
class _WalletAuthRequiresSigningBodyRequired(TypedDict):
410437
error: dict # {"code": "wallet_auth_requires_wallet_signing", "message": str}
411-
next_steps: WalletAuthRequiresSigningNextSteps
412438

413439

414440
class WalletAuthRequiresSigningBody(_WalletAuthRequiresSigningBodyRequired, total=False):
415441
"""403 body for X-Wallet-Address + signer-less rail rejections.
416442
417443
Returned when X-Wallet-Address is used with a payment rail that has no wallet signer
418444
(SPT, card). Agent should switch to X-Operator-Token for those rails.
445+
446+
Action copy surfaces via one of two paths:
447+
- ``agent_instructions``: JSON-encoded ``{action, steps, user_message}`` set by the
448+
gate's default marshaller (action is typically ``switch_to_operator_token``).
449+
- ``next_steps``: structured object set by merchants who override the gate default
450+
(action may be ``use_operator_token`` or any NextStepsAction).
419451
"""
420452

453+
agent_instructions: str
454+
next_steps: WalletAuthRequiresSigningNextSteps
421455
agent_memory: AgentMemoryHint

0 commit comments

Comments
 (0)