meta-agent-bridge 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- meta_agent_bridge-0.1.0/.github/FUNDING.yml +1 -0
- meta_agent_bridge-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +55 -0
- meta_agent_bridge-0.1.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- meta_agent_bridge-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +40 -0
- meta_agent_bridge-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- meta_agent_bridge-0.1.0/.github/dependabot.yml +13 -0
- meta_agent_bridge-0.1.0/.github/workflows/ci.yml +41 -0
- meta_agent_bridge-0.1.0/.github/workflows/release.yml +39 -0
- meta_agent_bridge-0.1.0/.gitignore +14 -0
- meta_agent_bridge-0.1.0/CONTRIBUTING.md +79 -0
- meta_agent_bridge-0.1.0/LICENSE +21 -0
- meta_agent_bridge-0.1.0/PKG-INFO +463 -0
- meta_agent_bridge-0.1.0/README.md +442 -0
- meta_agent_bridge-0.1.0/SECURITY.md +53 -0
- meta_agent_bridge-0.1.0/assets/banner-dark.svg +111 -0
- meta_agent_bridge-0.1.0/assets/banner-light.svg +111 -0
- meta_agent_bridge-0.1.0/pyproject.toml +68 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/__init__.py +127 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/bridge.py +297 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/__init__.py +114 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/capabilities.py +122 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/compiler.py +322 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/credentials.py +118 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/crypto.py +126 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/enums.py +31 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/errors.py +334 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/core/models.py +346 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/drivers/__init__.py +23 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/drivers/base.py +44 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/drivers/meta_messaging.py +529 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/drivers/whatsapp.py +582 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/py.typed +1 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/testing/__init__.py +20 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/testing/factories.py +139 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/testing/fake_transport.py +73 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/transport/__init__.py +27 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/transport/http.py +240 -0
- meta_agent_bridge-0.1.0/src/meta_agent_bridge/transport/media.py +262 -0
- meta_agent_bridge-0.1.0/tests/core/test_compiler.py +129 -0
- meta_agent_bridge-0.1.0/tests/core/test_crypto.py +75 -0
- meta_agent_bridge-0.1.0/tests/core/test_errors.py +75 -0
- meta_agent_bridge-0.1.0/tests/core/test_models.py +161 -0
- meta_agent_bridge-0.1.0/tests/drivers/test_meta_messaging.py +168 -0
- meta_agent_bridge-0.1.0/tests/drivers/test_whatsapp.py +160 -0
- meta_agent_bridge-0.1.0/tests/fixtures/instagram/ig_messaging.json +52 -0
- meta_agent_bridge-0.1.0/tests/fixtures/messenger/messaging_batch.json +50 -0
- meta_agent_bridge-0.1.0/tests/fixtures/whatsapp/bsuid_interactive.json +44 -0
- meta_agent_bridge-0.1.0/tests/fixtures/whatsapp/media_status_unknown.json +58 -0
- meta_agent_bridge-0.1.0/tests/fixtures/whatsapp/text_message.json +39 -0
- meta_agent_bridge-0.1.0/tests/test_bridge.py +184 -0
- meta_agent_bridge-0.1.0/tests/transport/test_media.py +88 -0
- meta_agent_bridge-0.1.0/tests/transport/test_transport.py +133 -0
- meta_agent_bridge-0.1.0/uv.lock +599 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
buy_me_a_coffee: Umar4880
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug or Meta Graph API mismatch in meta-agent-bridge
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: ["bug"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thank you for reporting an issue!
|
|
10
|
+
**Security reminder:** Never paste live Meta access tokens, App Secrets, phone numbers, or customer PII.
|
|
11
|
+
If this is a security vulnerability, please report it privately using the **Security** tab instead.
|
|
12
|
+
|
|
13
|
+
- type: dropdown
|
|
14
|
+
id: surface
|
|
15
|
+
attributes:
|
|
16
|
+
label: Meta Surface / Module
|
|
17
|
+
options:
|
|
18
|
+
- WhatsApp Cloud API
|
|
19
|
+
- Messenger
|
|
20
|
+
- Instagram (FB Login)
|
|
21
|
+
- Instagram (IG Direct)
|
|
22
|
+
- Core / Compiler / Crypto
|
|
23
|
+
- Transport / MediaDownloader
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
- type: input
|
|
28
|
+
id: versions
|
|
29
|
+
attributes:
|
|
30
|
+
label: Python & Package Version
|
|
31
|
+
placeholder: "e.g. Python 3.12.4, meta-agent-bridge 0.1.0"
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
|
|
35
|
+
- type: textarea
|
|
36
|
+
id: description
|
|
37
|
+
attributes:
|
|
38
|
+
label: What happened?
|
|
39
|
+
description: Describe the expected vs. actual behavior (or Meta API payload mismatch).
|
|
40
|
+
validations:
|
|
41
|
+
required: true
|
|
42
|
+
|
|
43
|
+
- type: textarea
|
|
44
|
+
id: reproduction
|
|
45
|
+
attributes:
|
|
46
|
+
label: Sanitized Reproduction
|
|
47
|
+
description: Minimal code or sanitized webhook JSON (with tokens/PII removed).
|
|
48
|
+
render: python
|
|
49
|
+
|
|
50
|
+
- type: textarea
|
|
51
|
+
id: error_details
|
|
52
|
+
attributes:
|
|
53
|
+
label: MetaError / Traceback
|
|
54
|
+
description: Include `category`, `code`, `subcode`, and `fbtrace_id` if applicable.
|
|
55
|
+
render: text
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Propose a new capability, surface feature, or driver enhancement
|
|
3
|
+
title: "[Feature]: "
|
|
4
|
+
labels: ["enhancement"]
|
|
5
|
+
body:
|
|
6
|
+
- type: textarea
|
|
7
|
+
id: summary
|
|
8
|
+
attributes:
|
|
9
|
+
label: Problem / Use Case
|
|
10
|
+
description: What agentic or omnichannel messaging workflow does this unlock?
|
|
11
|
+
validations:
|
|
12
|
+
required: true
|
|
13
|
+
|
|
14
|
+
- type: dropdown
|
|
15
|
+
id: surface
|
|
16
|
+
attributes:
|
|
17
|
+
label: Target Surface(s)
|
|
18
|
+
multiple: true
|
|
19
|
+
options:
|
|
20
|
+
- All Surfaces (Canonical)
|
|
21
|
+
- WhatsApp Cloud API
|
|
22
|
+
- Messenger
|
|
23
|
+
- Instagram (FB Login)
|
|
24
|
+
- Instagram (IG Direct)
|
|
25
|
+
- Testing Utilities
|
|
26
|
+
validations:
|
|
27
|
+
required: true
|
|
28
|
+
|
|
29
|
+
- type: textarea
|
|
30
|
+
id: meta_reference
|
|
31
|
+
attributes:
|
|
32
|
+
label: Meta Graph API Reference / Constraints
|
|
33
|
+
description: Link to Meta Graph API v27+ docs or note payload/limit constraints across surfaces.
|
|
34
|
+
|
|
35
|
+
- type: textarea
|
|
36
|
+
id: api_design
|
|
37
|
+
attributes:
|
|
38
|
+
label: Proposed Canonical API
|
|
39
|
+
description: How should this look on `AgentEvent`, `AgentResponse`, `CompiledPlan`, or `SocialBridge`?
|
|
40
|
+
render: python
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- Briefly describe what this PR changes and why. -->
|
|
4
|
+
|
|
5
|
+
## Architectural & Quality Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] `core/` remains pure sync sans-I/O (zero `httpx` or driver imports)
|
|
8
|
+
- [ ] All new/updated models use frozen Pydantic v2 and round-trip through JSON
|
|
9
|
+
- [ ] Unrecognized webhook shapes emit `UnknownEvent` instead of raising `ValidationError`
|
|
10
|
+
- [ ] No live network calls in tests (`httpx.MockTransport` or `FakeMetaTransport` only)
|
|
11
|
+
- [ ] Any new webhook fixtures in `tests/fixtures/` are fully sanitized (no tokens, phone numbers, or PII)
|
|
12
|
+
- [ ] `uv run ruff check .` passes
|
|
13
|
+
- [ ] `uv run mypy src tests` passes (`strict = true`)
|
|
14
|
+
- [ ] `uv run pytest -v` passes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "uv"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
open-pull-requests-limit: 5
|
|
8
|
+
|
|
9
|
+
- package-ecosystem: "github-actions"
|
|
10
|
+
directory: "/"
|
|
11
|
+
schedule:
|
|
12
|
+
interval: "weekly"
|
|
13
|
+
open-pull-requests-limit: 5
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
verify:
|
|
14
|
+
name: Python ${{ matrix.python-version }}
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python-version: ["3.12", "3.13"]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Check out repository
|
|
23
|
+
uses: actions/checkout@v7
|
|
24
|
+
|
|
25
|
+
- name: Set up uv
|
|
26
|
+
uses: astral-sh/setup-uv@v7
|
|
27
|
+
with:
|
|
28
|
+
enable-cache: true
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: uv sync
|
|
33
|
+
|
|
34
|
+
- name: Lint with ruff
|
|
35
|
+
run: uv run ruff check .
|
|
36
|
+
|
|
37
|
+
- name: Type-check with mypy (strict)
|
|
38
|
+
run: uv run mypy src tests
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: uv run pytest -v
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build-and-publish:
|
|
15
|
+
name: Build & Publish to PyPI
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
environment: pypi
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Check out repository
|
|
21
|
+
uses: actions/checkout@v7
|
|
22
|
+
|
|
23
|
+
- name: Set up uv
|
|
24
|
+
uses: astral-sh/setup-uv@v7
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.12"
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies & verify
|
|
29
|
+
run: |
|
|
30
|
+
uv sync
|
|
31
|
+
uv run ruff check .
|
|
32
|
+
uv run mypy src tests
|
|
33
|
+
uv run pytest -v
|
|
34
|
+
|
|
35
|
+
- name: Build distributions
|
|
36
|
+
run: uv build
|
|
37
|
+
|
|
38
|
+
- name: Publish to PyPI
|
|
39
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Contributing to `meta-agent-bridge`
|
|
2
|
+
|
|
3
|
+
Thank you for contributing to `meta-agent-bridge`! This project is built around strict architectural boundaries, verified Meta Graph API constraints, and high-signal test coverage.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Local Development Setup
|
|
8
|
+
|
|
9
|
+
Requires **Python 3.12+** and [`uv`](https://docs.astral.sh/uv/).
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv sync
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Run the full verification suite before and after your changes:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
uv run ruff check .
|
|
19
|
+
uv run mypy src tests
|
|
20
|
+
uv run pytest -v
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
All three checks (`ruff`, `mypy --strict`, and `pytest`) must pass with zero warnings or errors before opening a PR.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. Architectural Invariants (Non-Negotiable)
|
|
28
|
+
|
|
29
|
+
All contributions must preserve these core design invariants:
|
|
30
|
+
|
|
31
|
+
1. **Strict Dependency Direction:**
|
|
32
|
+
```text
|
|
33
|
+
bridge.py ──▶ drivers/ & transport/ ──▶ core/
|
|
34
|
+
```
|
|
35
|
+
- `core/` is **100% pure sync sans-I/O**: it must never import `httpx`, `drivers/`, or `transport/`.
|
|
36
|
+
- `drivers/` may depend only on `core/`.
|
|
37
|
+
- Keep `SocialBridge` lazily exported in `src/meta_agent_bridge/__init__.py` so importing `meta_agent_bridge.core` never triggers `httpx` imports.
|
|
38
|
+
|
|
39
|
+
2. **Immutable, Pure-Data Models:**
|
|
40
|
+
- All models use Pydantic v2 with `ConfigDict(frozen=True, extra="ignore")` (or `"forbid"` on credentials).
|
|
41
|
+
- Never attach bound HTTP clients or `.reply()` methods to `AgentEvent` or `CompiledPlan`; every event and plan must round-trip cleanly through JSON.
|
|
42
|
+
|
|
43
|
+
3. **Never Crash on Unknown Webhooks:**
|
|
44
|
+
- Unrecognized Meta webhook fields, new attachment types, or malformed items must return `UnknownEvent` rather than raising `ValidationError`.
|
|
45
|
+
|
|
46
|
+
4. **Flat Error Taxonomy:**
|
|
47
|
+
- Do **not** add per-error-code exception subclasses. Map `(surface, code, subcode)` declaratively in `ERROR_MAP` inside `src/meta_agent_bridge/core/errors.py`.
|
|
48
|
+
|
|
49
|
+
5. **Verified Meta Platform Constraints:**
|
|
50
|
+
- Update `CapabilityProfile` (`verified_on: date`) when adding or changing platform limits.
|
|
51
|
+
- Respect WhatsApp BSUID (`recipient` vs. `to`) and coupled `typing` + `mark_read` rules.
|
|
52
|
+
- Never emit deprecated Messenger tags (`CONFIRMED_EVENT_UPDATE`, `POST_PURCHASE_UPDATE`, `ACCOUNT_UPDATE`) or automatic `HUMAN_AGENT` tags.
|
|
53
|
+
- Honor Instagram's `(media + quick_replies)` separation in `core/compiler.py`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 3. Coding Standards
|
|
58
|
+
|
|
59
|
+
- **Python 3.12+ syntax:** Use `from __future__ import annotations`, `X | Y` unions, `type` aliases, and `StrEnum`.
|
|
60
|
+
- **Strict typing:** Complete type annotations on all public functions, methods, and tests; zero `Any` leaks in public APIs (except `raw: dict[str, Any]` and JSON body payloads).
|
|
61
|
+
- **Formatting & Linting:** `ruff` with `line-length = 100` and rules `E, F, I, UP, B, SIM, ASYNC, RUF`.
|
|
62
|
+
- **Docstrings:** Concise Google-style docstrings on all public classes, functions, methods, and protocols.
|
|
63
|
+
- **No PII Logging:** Library loggers (`meta_agent_bridge.*`) must never log message text, phone numbers, BSUIDs, tokens, or user names at `INFO` or `WARNING`.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 4. Testing Requirements
|
|
68
|
+
|
|
69
|
+
- **Zero live network calls:** Use `httpx.MockTransport` for HTTP/transport tests and `FakeMetaTransport` from `meta_agent_bridge.testing` for integration tests.
|
|
70
|
+
- **Sanitized fixtures:** Store webhook parser test payloads under `tests/fixtures/{whatsapp,messenger,instagram}/`. Always scrub real phone numbers, access tokens, app secrets, and personal user names/IDs before committing fixtures.
|
|
71
|
+
- **Boundary & round-trip tests:** New event types, steps, or error categories must include JSON round-trip serialization tests in `tests/core/`.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 5. Pull Request Checklist
|
|
76
|
+
|
|
77
|
+
1. Follow the phased build order when implementing multi-layer features (`core/` → `transport/` → `drivers/` → `bridge.py` & `testing/`).
|
|
78
|
+
2. Keep changes focused and update `README.md` if public APIs or capability matrices change.
|
|
79
|
+
3. Confirm `uv run ruff check .`, `uv run mypy src tests`, and `uv run pytest -v` all pass.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rana Muhammad Umar Javed
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|