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
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:
contents: read

env:
CORE_REF: 403482c27d5f88d3f070a01ecd1cb103ebfc97f9
CORE_REF: 3f6c785fab4a4a7140637fbb21039f1d65d0274b

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ permissions:
env:
# Bootstrap the registry-shaped lockfiles from the reviewed Core commit
# while the matching prerelease is unpublished.
CORE_REF: 403482c27d5f88d3f070a01ecd1cb103ebfc97f9
CORE_REF: 3f6c785fab4a4a7140637fbb21039f1d65d0274b
CORE_CRATE_VERSION: 1.0.0-beta.1
CORE_CRATE_SHA256: 19dc73726e9aac784e05bb9e99ee3de032b720cde10e2fefa0b5b4a93017d96c
CORE_CRATE_SHA256: 49109b2f64808f66f3663d5ac713ae4c3ed7008a812f302244042ab13125b494

jobs:
source:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:
contents: read

env:
CORE_REF: 403482c27d5f88d3f070a01ecd1cb103ebfc97f9
CORE_REF: 3f6c785fab4a4a7140637fbb21039f1d65d0274b

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

11 changes: 6 additions & 5 deletions a2a/python/src/apcore_a2a/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
# Pilot support is limited to direct declarations. These schema applicators
# can place a second annotation on the same instance path.
_SCHEMA_APPLICATORS = frozenset(
{"$ref", "$dynamicRef", "allOf", "anyOf", "oneOf", "if", "then", "else", "dependentSchemas", "patternProperties"}
{
"$ref", "$dynamicRef", "$recursiveRef", "allOf", "anyOf", "oneOf", "if", "then", "else",
"dependentSchemas", "dependencies", "patternProperties",
}
)
_REFERENCE_ASSERTIONS = frozenset({"x-artifact-ref", "x-media-types", "x-max-bytes"})
_REFERENCE_FIELDS = frozenset({"type", "title", "description"})
Expand Down Expand Up @@ -190,20 +193,18 @@ def _link_fields(schema: Any) -> tuple[tuple[str, dict[str, Any] | None], ...]:
for name, declaration in properties.items():
if not isinstance(declaration, dict) or declaration.get("x-a2a-artifact") is not True:
continue
if declaration.get("x-sensitive"):
if declaration.get("x-sensitive") or not _SCHEMA_APPLICATORS.isdisjoint(declaration):
continue
if not _REFERENCE_ASSERTIONS.isdisjoint(declaration):
if (
ArtifactRef is not None
and "$recursiveRef" not in schema
and "dependencies" not in schema
and declaration.get("type") in (None, "object")
and all(
key in _REFERENCE_FIELDS or (isinstance(key, str) and key.startswith("x-")) for key in declaration
)
):
fields.append((name, declaration))
elif declaration.get("type") == "string" and _SCHEMA_APPLICATORS.isdisjoint(declaration):
elif declaration.get("type") == "string":
fields.append((name, None))
return tuple(fields)

Expand Down
4 changes: 2 additions & 2 deletions a2a/rust/Cargo.lock

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

4 changes: 2 additions & 2 deletions a2a/typescript/pnpm-lock.yaml

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

9 changes: 8 additions & 1 deletion a2a/typescript/src/artifact-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@ export function captureArtifactDeclaration(registry: unknown, executor: unknown,
for (const { name, canonical } of fields) {
if (!Object.hasOwn(output, name)) continue;
const value = output[name];
const reference = canonical ? apcore.parseArtifactRef(value) : null;
let reference: ArtifactRef | null = null;
if (canonical) {
try {
reference = apcore.parseArtifactRef(value);
} catch {
continue;
}
}
const id = reference?.id ?? value;
if (typeof id !== "string" || !ARTIFACT_ID.test(id)) continue;
const declarations = found.get(id);
Expand Down
22 changes: 22 additions & 0 deletions a2a/typescript/tests/server/artifact-links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Type } from "@sinclair/typebox";
import request from "supertest";
import { describe, expect, it, vi } from "vitest";
import { ArtifactLinkPolicy, asyncServe, type HostedArtifact } from "../../src/index.js";
import { captureArtifactDeclaration } from "../../src/artifact-links.js";
import type { AsyncServeOptions } from "../../src/serve.js";

const skill = "test.download";
Expand Down Expand Up @@ -45,6 +46,27 @@ async function send(executor: Executor, options: AsyncServeOptions) {
}

describe("hosted artifact links", () => {
it("keeps other valid candidates when an individual reference cannot be parsed", async () => {
const registry = new Registry();
const field = { type: "object", "x-artifact-ref": true, "x-a2a-artifact": true };
class Reference {
id = "initial";
media_type = "text/plain";
size_bytes = 4;
}
const data = {
primary: new Reference(),
secondary: { id: "secondary", media_type: "text/plain", size_bytes: 4 },
};
await registry.register(skill, {
...downloadModule(),
outputSchema: { type: "object", properties: { primary: field, secondary: field } },
execute: () => data,
});
const capture = captureArtifactDeclaration(registry, new Executor({ registry }), skill, new Identity("alice", "user"));
expect(capture?.candidates(data)).toEqual(new Map([["secondary", [data.secondary]]]));
});

it("uses authenticated identity and final validated output, deduplicates and preserves structured data", async () => {
const registry = new Registry();
await registry.register(skill, downloadModule());
Expand Down
4 changes: 2 additions & 2 deletions cli/rust/Cargo.lock

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

4 changes: 2 additions & 2 deletions cli/typescript/pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions mcp/docs/features/error-mapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Only errors derived from `ModuleError` (which are designed to be user-facing) ar
- On success: dict with keys `isError: True`, `errorType: str` (from error.code), `message: str`, `details: dict|None`
- CALL_DEPTH_EXCEEDED, CIRCULAR_CALL, CALL_FREQUENCY_EXCEEDED → sanitized "Internal error occurred" message
- ACL_DENIED → sanitized "Access denied", details: null
- POLICY_DENIED → "Access denied" with a fixed recovery hint, `retryable: false`, `userFixable: true`, and `details: null`
- POLICY_EVALUATION_ERROR → "Policy evaluation failed" with `retryable: true`, `userFixable: false`, and `details: null`
- SCHEMA_VALIDATION_ERROR → multi-line bulleted message with field-level errors; details preserved
- APPROVAL_PENDING → safe status text. The initiating holder receives any private resume token through the [Phase B result metadata](approval-phase-b.md#complete-flow).
- APPROVAL_TIMEOUT → `retryable: true`
Expand Down
2 changes: 1 addition & 1 deletion mcp/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
# a runtime dependency — this is the extra the "install 'apcore-mcp[markdown]'"
# WARN logs point at.
markdown = [
"apcore-toolkit>=0.14.2",
"apcore-toolkit==0.16.0b1",
]

# The OpenAPI backend. `[http-proxy]` resolves httpx, which both `load_spec`
Expand Down
20 changes: 20 additions & 0 deletions mcp/python/src/apcore_mcp/adapters/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ def _handle_apcore_error(self, error: Exception) -> dict[str, Any]:
# declared type once here instead of guarding each call site.
details: dict[str, Any] | None = raw_details if isinstance(raw_details, dict) else None

if code == ERROR_CODES["POLICY_DENIED"]:
return {
"isError": True,
"errorType": code,
"message": "Access denied",
"details": None,
"retryable": False,
"userFixable": True,
"aiGuidance": "Review the request against the host's policy before trying again.",
}
if code == ERROR_CODES["POLICY_EVALUATION_ERROR"]:
return {
"isError": True,
"errorType": code,
"message": "Policy evaluation failed",
"details": None,
"retryable": True,
"userFixable": False,
}

# Convert internal errors to generic message
if code in self._INTERNAL_ERROR_CODES:
return {
Expand Down
4 changes: 2 additions & 2 deletions mcp/python/src/apcore_mcp/apcore_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def serve(
allow_execute: bool = False,
explorer_title: str = "APCore MCP Explorer",
explorer_project_name: str | None = "apcore-mcp",
explorer_project_url: str | None = "https://github.com/aiperceivable/apcore-mcp-python",
explorer_project_url: str | None = "https://github.com/aiperceivable/apcore-surfaces/tree/main/mcp/python",
output_format: str | None = None,
) -> None:
"""Launch the MCP server (blocking).
Expand Down Expand Up @@ -1072,7 +1072,7 @@ async def async_serve(
allow_execute: bool = False,
explorer_title: str = "APCore MCP Explorer",
explorer_project_name: str | None = "apcore-mcp",
explorer_project_url: str | None = "https://github.com/aiperceivable/apcore-mcp-python",
explorer_project_url: str | None = "https://github.com/aiperceivable/apcore-surfaces/tree/main/mcp/python",
output_format: str | None = None,
) -> AsyncIterator[Starlette]:
"""Build an MCP Starlette ASGI app for embedding into a larger service.
Expand Down
2 changes: 2 additions & 0 deletions mcp/python/src/apcore_mcp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"MODULE_DISABLED": "MODULE_DISABLED",
"SCHEMA_VALIDATION_ERROR": "SCHEMA_VALIDATION_ERROR",
"ACL_DENIED": "ACL_DENIED",
"POLICY_DENIED": "POLICY_DENIED",
"POLICY_EVALUATION_ERROR": "POLICY_EVALUATION_ERROR",
"CALL_DEPTH_EXCEEDED": "CALL_DEPTH_EXCEEDED",
"CIRCULAR_CALL": "CIRCULAR_CALL",
"CALL_FREQUENCY_EXCEEDED": "CALL_FREQUENCY_EXCEEDED",
Expand Down
15 changes: 7 additions & 8 deletions mcp/python/src/apcore_mcp/server/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,24 +1041,23 @@ def _attach_artifact_links(
properties = schema.get("properties")
if not isinstance(properties, dict):
return
direct_reference_root = (
schema.get("type") == "object"
and not schema.get("x-sensitive")
and _ARTIFACT_ROOT_APPLICATORS.isdisjoint(schema)
)
if (
schema.get("type") != "object"
or schema.get("x-sensitive")
or not _ARTIFACT_ROOT_APPLICATORS.isdisjoint(schema)
):
return
emitted: set[str] = set()
for name, definition in properties.items():
if not isinstance(definition, dict) or definition.get("x-mcp-artifact") is not True:
continue
if definition.get("x-sensitive") is True:
if definition.get("x-sensitive") or not _ARTIFACT_ROOT_APPLICATORS.isdisjoint(definition):
continue
value = result.structuredContent.get(name)
reference = None
if not _ARTIFACT_REFERENCE_ASSERTIONS.isdisjoint(definition):
if (
ArtifactRef is None
or not direct_reference_root
or definition.get("x-sensitive")
or not isinstance(value, dict)
or definition.get("type") not in (None, "object")
or any(
Expand Down
28 changes: 28 additions & 0 deletions mcp/python/tests/adapters/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@

from apcore_mcp.adapters.errors import CIRCUIT_BREAKER_RECOVERY_GUIDANCE, ErrorMapper


@pytest.mark.parametrize(
("code", "message", "retryable"),
[("POLICY_DENIED", "Access denied", False), ("POLICY_EVALUATION_ERROR", "Policy evaluation failed", True)],
)
def test_policy_errors_use_public_diagnostics(code, message, retryable):
from apcore.errors import ModuleError

error = ModuleError(
code=code,
message="private message",
details={"rule": "private rule"},
ai_guidance="private guidance",
suggestion="private suggestion",
)
expected = {
"isError": True,
"errorType": code,
"message": message,
"details": None,
"retryable": retryable,
"userFixable": not retryable,
}
if code == "POLICY_DENIED":
expected["aiGuidance"] = "Review the request against the host's policy before trying again."
assert ErrorMapper().to_mcp_error(error) == expected


# Declarative user_fixable policy, mirroring apcore 0.24.0 _USER_FIXABLE_BY_CODE.
_USER_FIXABLE_BY_CODE: dict[str, bool] = {
"SCHEMA_VALIDATION_ERROR": True,
Expand Down
4 changes: 2 additions & 2 deletions mcp/rust/Cargo.lock

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

Loading
Loading