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
17 changes: 10 additions & 7 deletions .github/workflows/core-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
text = manifest.read_text()
if text.count("1.0.0a5") != 1:
raise ValueError(f"Unexpected Core dependency in {manifest}")
manifest.write_text(text.replace("1.0.0a5", "1.0.0a6"))
manifest.write_text(text.replace("1.0.0a5", "1.0.0b1"))
PY
fi
args=(-e '.[dev]')
Expand All @@ -204,7 +204,7 @@ jobs:

import apcore
import apcore_toolkit
from apcore import APCore, Executor
from apcore import APCore, Context, Executor
from apcore.events import CircuitBreakerWrapper

installed = distribution("apcore")
Expand All @@ -216,12 +216,13 @@ jobs:
assert core_path == installed.locate_file("apcore/__init__.py").resolve()
assert toolkit_path == toolkit_expected.resolve()
if os.environ["CORE_MODE"] == "candidate":
assert installed.version == "1.0.0a6"
assert installed.version == "1.0.0b1"
origin = json.loads(installed.read_text("direct_url.json") or "{}")
assert origin.get("url") == Path(os.environ["CORE_INSTALL"]).resolve().as_uri()
assert callable(getattr(Executor, "stream_with_completion", None))
assert callable(getattr(APCore, "stream_with_completion", None))
assert hasattr(CircuitBreakerWrapper, "retry")
assert callable(Context.report_progress) and callable(Context.elicit)
else:
assert installed.version == "0.33.0"
PY
Expand Down Expand Up @@ -342,7 +343,7 @@ jobs:
import { readFileSync, realpathSync } from 'node:fs';
import { resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
import { APCore, Executor } from 'apcore-js';
import { APCore, Context, Executor } from 'apcore-js';

const core = realpathSync('./node_modules/apcore-js');
const coreEntry = realpathSync(fileURLToPath(import.meta.resolve('apcore-js')));
Expand All @@ -355,9 +356,11 @@ jobs:
assert.ok(coreEntry.startsWith(core + sep));
assert.equal(toolkitEntry, realpathSync(resolve(process.env.TOOLKIT_ROOT, 'dist/index.js')));
if (process.env.CORE_MODE === 'candidate') {
assert.equal(coreVersion, '1.0.0-alpha.6');
assert.equal(coreVersion, '1.0.0-beta.1');
assert.equal(typeof Executor.prototype.streamWithCompletion, 'function');
assert.equal(typeof APCore.prototype.streamWithCompletion, 'function');
assert.equal(typeof Context.prototype.reportProgress, 'function');
assert.equal(typeof Context.prototype.elicit, 'function');
} else {
assert.equal(coreVersion, '0.33.0');
}
Expand Down Expand Up @@ -446,8 +449,8 @@ jobs:
crate="${crates[0]}"
version="${crate##*/apcore-}"
version="${version%.crate}"
if [[ "$version" != 1.0.0-alpha.6 ]]; then
echo "Expected the alpha.6 Core crate." >&2
if [[ "$version" != 1.0.0-beta.1 ]]; then
echo "Expected the beta.1 Core crate." >&2
exit 1
fi
if [[ "$CORE_MODE" == candidate && -n "$EXPECTED_SHA256" ]]; then
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ env:
CORE_REF: e4e2329de4ce8fa45669572ef9bd81c48da0d746
CORE_CRATE_VERSION: 1.0.0-alpha.5
CORE_CRATE_SHA256: 1d19939071ba2c589815c061dfb1ff827862e5f1f52251e88297d49eec500a90
# MCP uses the native Context interactions from the paired Core candidate.
MCP_CORE_REF: a3fe0245eecf65bb57c7cca324a7a7b29c6ff553
MCP_CORE_CRATE_VERSION: 1.0.0-beta.1
MCP_CORE_CRATE_SHA256: 3b92d75b37a1a8349d47c8aa32b452c67e92171e85391d6c24ce8b3e2bef22d4

jobs:
source:
Expand All @@ -48,7 +52,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: aiperceivable/apcore
ref: ${{ env.CORE_REF }}
ref: ${{ matrix.component == 'mcp' && env.MCP_CORE_REF || env.CORE_REF }}
path: .ci-apcore-core
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
Expand Down Expand Up @@ -91,7 +95,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: aiperceivable/apcore
ref: ${{ env.CORE_REF }}
ref: ${{ matrix.component == 'mcp' && env.MCP_CORE_REF || env.CORE_REF }}
path: .ci-apcore-core
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
Expand All @@ -103,13 +107,20 @@ jobs:
shell: bash
env:
CARGO_TARGET_DIR: ${{ runner.temp }}/core-dependency-target
PINNED_CORE_VERSION: ${{ matrix.component == 'mcp' && env.MCP_CORE_CRATE_VERSION || env.CORE_CRATE_VERSION }}
PINNED_CORE_SHA256: ${{ matrix.component == 'mcp' && env.MCP_CORE_CRATE_SHA256 || env.CORE_CRATE_SHA256 }}
run: |
git rev-parse HEAD
rustup toolchain install 1.86.0 --profile minimal
# Core was already verified upstream. Reproduce the same archive.
cargo +1.86.0 package --locked --all-features --no-verify
archive="$CARGO_TARGET_DIR/package/apcore-$CORE_CRATE_VERSION.crate"
printf '%s %s\n' "$CORE_CRATE_SHA256" "$archive" | sha256sum --check
if [[ -f apcore-macros/Cargo.toml ]]; then
cargo +1.86.0 --config "patch.crates-io.apcore-macros.path='$PWD/apcore-macros'" \
package --locked -p apcore --all-features --no-verify
else
cargo +1.86.0 package --locked --all-features --no-verify
fi
archive="$CARGO_TARGET_DIR/package/apcore-$PINNED_CORE_VERSION.crate"
printf '%s %s\n' "$PINNED_CORE_SHA256" "$archive" | sha256sum --check
mkdir "$RUNNER_TEMP/core-dependency"
tar -xzf "$archive" --strip-components=1 -C "$RUNNER_TEMP/core-dependency"
- name: Package and verify the Surface crate
Expand Down
15 changes: 14 additions & 1 deletion a2a/docs/features/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,20 @@ Bidirectional converter between A2A Parts and apcore module inputs/outputs.
> discriminator. Reading inspects the active oneof case (Python:
> `part.WhichOneof("content")`; TypeScript: `part.content.$case`; Rust: the
> `Part` enum variant). A "FilePart" corresponds to the `raw` (bytes) or `url`
> oneof case and is rejected as unsupported.
> oneof case and is rejected as unsupported on input.

#### Hosted artifact links pilot

Python hosts enable this pilot by passing `artifact_links=ArtifactLinkPolicy(resolve, {"downloads.example.com"})`
to `async_serve`, `serve`, or `A2AServerFactory.create`. Declare a direct, non-sensitive string property with
`x-a2a-artifact: true` in a unary module's output schema and return an opaque ID. The trusted asynchronous
resolver receives that ID and a snapshot of the authenticated `Identity`. It returns `HostedArtifact`
metadata for a download the caller is authorized to access, or `None` to omit the link.

The adapter checks the exact HTTPS host allowlist, expiry in Unix seconds, and the link's size before
adding an A2A URL `Part` with filename and media type alongside the final validated data part. The size
cap defaults to 8 MiB and is configurable with `max_bytes`. The download host serves the bytes and
enforces the caller's authorization, expiry, and byte limit, including access from previously stored tasks.

## File Structure

Expand Down
6 changes: 6 additions & 0 deletions a2a/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,9 @@ pytest
## License

Apache 2.0 — see [LICENSE](LICENSE).


### Hosted artifact links

Python hosts can add authorized downloads to unary A2A results.
See [Hosted artifact links pilot](../docs/features/adapters.md#hosted-artifact-links-pilot).
4 changes: 4 additions & 0 deletions a2a/python/src/apcore_a2a/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from apcore_a2a._serve import async_serve, serve
from apcore_a2a.adapters import AgentCardBuilder, ErrorMapper, PartConverter, SchemaConverter, SkillMapper
from apcore_a2a.artifacts import ArtifactLinkPolicy, ArtifactResolver, HostedArtifact
from apcore_a2a.auth import (
Authenticator,
AuthMiddleware,
Expand Down Expand Up @@ -42,6 +43,9 @@
"SchemaConverter",
"ErrorMapper",
"PartConverter",
"ArtifactLinkPolicy",
"ArtifactResolver",
"HostedArtifact",
# Server
"A2AServerFactory",
"ApCoreAgentExecutor",
Expand Down
5 changes: 5 additions & 0 deletions a2a/python/src/apcore_a2a/_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from starlette.applications import Starlette

from apcore_a2a._config import resolve_execution_timeout
from apcore_a2a.artifacts import ArtifactLinkPolicy
from apcore_a2a.server.factory import A2AServerFactory

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -100,6 +101,7 @@ async def async_serve(
metrics: bool = False,
sys_modules: bool = False,
disclose_refusal_reason: bool = False,
artifact_links: ArtifactLinkPolicy | None = None,
) -> Starlette:
"""Build and return a Starlette ASGI app for an A2A agent.

Expand Down Expand Up @@ -188,6 +190,7 @@ async def async_serve(
metrics=metrics,
sys_modules=sys_modules,
disclose_refusal_reason=disclose_refusal_reason,
artifact_links=artifact_links,
)

# Step 7: Return the Starlette app
Expand Down Expand Up @@ -216,6 +219,7 @@ def serve(
metrics: bool = False,
sys_modules: bool = False,
disclose_refusal_reason: bool = False,
artifact_links: ArtifactLinkPolicy | None = None,
) -> None:
"""Launch an A2A agent server (blocking).

Expand Down Expand Up @@ -284,6 +288,7 @@ async def _main() -> None:
metrics=metrics,
sys_modules=sys_modules,
disclose_refusal_reason=disclose_refusal_reason,
artifact_links=artifact_links,
)
config = uvicorn.Config(
app,
Expand Down
14 changes: 14 additions & 0 deletions a2a/python/src/apcore_a2a/adapters/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from google.protobuf.json_format import MessageToDict, ParseDict

from apcore_a2a.adapters.schema import SchemaConverter
from apcore_a2a.artifacts import ArtifactLinkPolicy, _ArtifactDeclaration


class PartConverter:
Expand Down Expand Up @@ -59,6 +60,19 @@ def parts_to_input(self, parts: list[Part], descriptor: Any) -> dict | str:

raise ValueError("Empty or unknown part content")

async def add_artifact_links(
self,
artifact: Artifact,
output: Any,
declaration: _ArtifactDeclaration,
policy: ArtifactLinkPolicy,
) -> None:
"""Add authorized URL parts to an existing finalized data artifact."""
if isinstance(output, dict) and declaration.is_current() and declaration.validates_output(output):
parts = await policy._resolve_parts(output, declaration.fields, declaration.identity)
if declaration.is_current():
artifact.parts.extend(parts)

def output_to_parts(self, output: Any, task_id: str = "") -> Artifact:
"""Convert apcore module output to a2a.types.Artifact.

Expand Down
Loading
Loading