This commit is contained in:
a2a-platform
2026-06-28 17:07:34 +00:00
parent 416af50961
commit 5b97a01efc
2 changed files with 29 additions and 1 deletions

View File

@@ -22,6 +22,8 @@ from a2a_pack import (
Pricing,
Resources,
RunContext,
WorkspaceAccess,
WorkspaceMode,
skill,
)
@@ -52,6 +54,7 @@ class Learnhouse(A2AAgent):
version = "1.2.7"
consumer_setup = ConsumerSetup.from_fields(
ConsumerSetupField.config("OPENAPI_BASE_URL", label="API base URL", description="Override the default API server (https://learnhouse.a2acloud.io).", required=False, input_type="url"),
ConsumerSetupField.secret("LEARNHOUSE_API_KEY", label="LearnHouse API key", description="Bearer token or API key for LearnHouse requests.", required=True),
)
llm_provisioning = LLMProvisioning.PLATFORM
pricing = Pricing(
@@ -60,6 +63,11 @@ class Learnhouse(A2AAgent):
notes="Uses the caller's saved LLM credential through ctx.llm.",
)
resources = Resources(cpu="200m", memory="512Mi")
workspace_access = WorkspaceAccess.dynamic(
max_files=50,
allowed_modes=(WorkspaceMode.READ_ONLY, WorkspaceMode.READ_WRITE_OVERLAY),
require_reason=False,
)
egress = EgressPolicy(
allow_hosts=('learnhouse.a2acloud.io',),
deny_internet_by_default=True,
@@ -336,7 +344,12 @@ class Learnhouse(A2AAgent):
if requirements is None:
requirements = ROOT_SECURITY
if requirements == []:
return {}, {}
token = _consumer_secret_optional(ctx, "LEARNHOUSE_API_KEY")
if not token:
raise ConsumerSetupMissing(
"operation requires consumer setup secret(s): LEARNHOUSE_API_KEY"
)
return {"authorization": _learnhouse_auth_header(token)}, {}
missing: list[str] = []
for requirement in requirements or []:
if not isinstance(requirement, dict) or not requirement:
@@ -380,6 +393,13 @@ class Learnhouse(A2AAgent):
return {}, {}
def _learnhouse_auth_header(value: str) -> str:
token = value.strip()
if token.lower().startswith(("bearer ", "basic ", "token ")):
return token
return f"Bearer {token}"
def _consumer_secret_optional(ctx: RunContext, name: str | None) -> str:
if not name:
return ""