Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ if status["status"] == "verified":
# for an existing operator credential.
client.create_session(address="0x...")
client.create_session(operator_token="opc_...") # KYC refresh
client.create_session(kind="sign_in") # registration-only: account sign-in, no identity documents
```

### Wallet resolution
Expand Down
20 changes: 17 additions & 3 deletions agentscore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import time
from importlib.metadata import version as _pkg_version
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

import httpx

Expand Down Expand Up @@ -308,12 +308,17 @@ def create_session(
product_name: str | None = None,
address: str | None = None,
operator_token: str | None = None,
kind: Literal["kyc", "sign_in"] | None = None,
) -> SessionCreateResponse:
"""Create an assessment session for deferred scoring.

``address`` pre-associates the session with a known wallet (EVM ``0x...`` or
Solana base58). ``operator_token`` pre-associates with an existing ``opc_...`` —
e.g. refresh KYC for a credential.
e.g. refresh KYC for a credential. ``kind`` selects the session kind: ``"kyc"``
(the API default) runs identity verification; ``"sign_in"`` is registration-only
(the buyer signs in with an AgentScore account, no identity documents) and mints a
``sign_in``-scoped credential, for merchants that key durable state on the account
without any compliance policy.
"""
body: dict[str, Any] = {}
if context is not None:
Expand All @@ -324,6 +329,8 @@ def create_session(
body["address"] = address
if operator_token is not None:
body["operator_token"] = operator_token
if kind is not None:
body["kind"] = kind
client = self._get_sync_client()
return self._send_sync(lambda: client.post("/v1/sessions", json=body))

Expand Down Expand Up @@ -451,12 +458,17 @@ async def acreate_session(
product_name: str | None = None,
address: str | None = None,
operator_token: str | None = None,
kind: Literal["kyc", "sign_in"] | None = None,
) -> SessionCreateResponse:
"""Create an assessment session for deferred scoring.

``address`` pre-associates the session with a known wallet (EVM ``0x...`` or
Solana base58). ``operator_token`` pre-associates with an existing ``opc_...`` —
e.g. refresh KYC for a credential.
e.g. refresh KYC for a credential. ``kind`` selects the session kind: ``"kyc"``
(the API default) runs identity verification; ``"sign_in"`` is registration-only
(the buyer signs in with an AgentScore account, no identity documents) and mints a
``sign_in``-scoped credential, for merchants that key durable state on the account
without any compliance policy.
"""
body: dict[str, Any] = {}
if context is not None:
Expand All @@ -467,6 +479,8 @@ async def acreate_session(
body["address"] = address
if operator_token is not None:
body["operator_token"] = operator_token
if kind is not None:
body["kind"] = kind
client = self._get_async_client()
return await self._send_async(lambda: client.post("/v1/sessions", json=body))

Expand Down
2 changes: 2 additions & 0 deletions agentscore/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ class _SessionCreateResponseRequired(TypedDict):


class SessionCreateResponse(_SessionCreateResponseRequired, total=False):
# The kind the session was minted with; absent on older API responses.
kind: Literal["kyc", "sign_in"]
# Structured next_steps with action=deliver_verify_url_and_poll.
next_steps: SessionCreateNextSteps
# Cross-merchant memory hint on first session creation.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "agentscore-py"
version = "2.6.8"
version = "2.6.9"
description = "Python client for the AgentScore APIs"
readme = "README.md"
license = "MIT"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,12 @@ def test_create_session_with_first_class_fields():
client.create_session(
context="wine purchase verification",
product_name="Cabernet Reserve 2022",
kind="sign_in",
)
body = json.loads(route.calls.last.request.content)
assert body["context"] == "wine purchase verification"
assert body["product_name"] == "Cabernet Reserve 2022"
assert body["kind"] == "sign_in"


@respx.mock
Expand All @@ -1037,6 +1039,7 @@ def test_create_session_omits_none_fields():
body = json.loads(route.calls.last.request.content)
assert "context" not in body
assert "product_name" not in body
assert "kind" not in body


@respx.mock
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.