nutria-plugin 0.4.1__tar.gz → 0.5.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.
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/CHANGELOG.md +14 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/PKG-INFO +6 -5
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/README.md +5 -4
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/index.md +3 -3
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/manifest.md +4 -4
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/python-api.md +2 -2
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/quickstart.md +4 -3
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/reviewable-actions.md +2 -2
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/examples/my-first-plugin/plugin.json +1 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/pyproject.toml +1 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/__init__.py +6 -2
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/bundle.py +0 -4
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/capabilities.py +18 -2
- nutria_plugin-0.5.0/src/nutria_plugin/domains.py +44 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/manifest.py +1 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/packaging.py +2 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_bundle.py +2 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_capability_contracts.py +83 -17
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_manifest.py +12 -5
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_reviewable_actions.py +3 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_signing.py +1 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/uv.lock +1 -1
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/.github/workflows/publish.yml +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/.gitignore +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/admin-extensions.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/admin-flows.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/cli.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/connection-types.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/security.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/docs/skill-format.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/examples/my-first-plugin/README.md +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/examples/my-first-plugin/hooks/hooks.json +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/examples/my-first-plugin/settings.schema.json +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/cli.py +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/mcp_results.py +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/src/nutria_plugin/signing.py +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_cli.py +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_mcp_results.py +0 -0
- {nutria_plugin-0.4.1 → nutria_plugin-0.5.0}/tests/test_packaging.py +0 -0
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- Replace manifest schema 4.0 with schema 5.0.
|
|
6
|
+
- Require every capability to declare one or more stable `CapabilityDomain`
|
|
7
|
+
identifiers.
|
|
8
|
+
- Export the shared domain registry and reject unknown or duplicate domains.
|
|
9
|
+
|
|
10
|
+
## 0.4.2
|
|
11
|
+
|
|
12
|
+
- Add the generic `requires_provenance` input-binding semantic while keeping
|
|
13
|
+
manifest schema version 4.0.
|
|
14
|
+
- Keep personal-data sensitivity independent from accepted provenance origins;
|
|
15
|
+
personal inputs no longer implicitly require `current_user` authority.
|
|
16
|
+
|
|
3
17
|
## 0.4.1
|
|
4
18
|
|
|
5
19
|
- Allow a reviewable action's optional preparation helper to expose the actual
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: nutria-plugin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: SDK for building, validating, signing, and packaging Nutria plugins
|
|
5
5
|
Project-URL: Homepage, https://github.com/AlRos14/nutria-plugin-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/AlRos14/nutria-plugin-sdk
|
|
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
|
|
|
21
21
|
|
|
22
22
|
SDK for building, validating, signing, and packaging Nutria plugins.
|
|
23
23
|
|
|
24
|
-
Release `0.
|
|
24
|
+
Release `0.5.0` accepts only manifest schema `5.0`. Capabilities use their real
|
|
25
25
|
business effect (`read`, `write`, or `external_write`); preparation is expressed
|
|
26
26
|
by producing `prepared_action`, not by a workflow-phase effect. Every parsed
|
|
27
27
|
requirement resolves `task_context` to `required`, `optional`, or `forbidden`,
|
|
@@ -34,7 +34,7 @@ and exact delivery of an approved snapshot.
|
|
|
34
34
|
## Install
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
uv add nutria-plugin==0.
|
|
37
|
+
uv add nutria-plugin==0.5.0
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Scaffold and validate
|
|
@@ -49,11 +49,11 @@ The generated directory contains `plugin.json`, component directories for
|
|
|
49
49
|
connections, skills, context documents, specs and hooks, plus an optional
|
|
50
50
|
settings schema and assets.
|
|
51
51
|
|
|
52
|
-
## Minimal schema
|
|
52
|
+
## Minimal schema 5.0 manifest
|
|
53
53
|
|
|
54
54
|
```json
|
|
55
55
|
{
|
|
56
|
-
"schema_version": "
|
|
56
|
+
"schema_version": "5.0",
|
|
57
57
|
"id": "my-workspace-plugin",
|
|
58
58
|
"name": "My Workspace Plugin",
|
|
59
59
|
"version": "0.1.0",
|
|
@@ -66,6 +66,7 @@ settings schema and assets.
|
|
|
66
66
|
"id": "workspace.search",
|
|
67
67
|
"title": "Search workspace",
|
|
68
68
|
"description": "Read matching workspace resources.",
|
|
69
|
+
"domains": ["products"],
|
|
69
70
|
"effect": "read",
|
|
70
71
|
"tool": "search_workspace",
|
|
71
72
|
"connection_id": "workspace",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
SDK for building, validating, signing, and packaging Nutria plugins.
|
|
4
4
|
|
|
5
|
-
Release `0.
|
|
5
|
+
Release `0.5.0` accepts only manifest schema `5.0`. Capabilities use their real
|
|
6
6
|
business effect (`read`, `write`, or `external_write`); preparation is expressed
|
|
7
7
|
by producing `prepared_action`, not by a workflow-phase effect. Every parsed
|
|
8
8
|
requirement resolves `task_context` to `required`, `optional`, or `forbidden`,
|
|
@@ -15,7 +15,7 @@ and exact delivery of an approved snapshot.
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
uv add nutria-plugin==0.
|
|
18
|
+
uv add nutria-plugin==0.5.0
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Scaffold and validate
|
|
@@ -30,11 +30,11 @@ The generated directory contains `plugin.json`, component directories for
|
|
|
30
30
|
connections, skills, context documents, specs and hooks, plus an optional
|
|
31
31
|
settings schema and assets.
|
|
32
32
|
|
|
33
|
-
## Minimal schema
|
|
33
|
+
## Minimal schema 5.0 manifest
|
|
34
34
|
|
|
35
35
|
```json
|
|
36
36
|
{
|
|
37
|
-
"schema_version": "
|
|
37
|
+
"schema_version": "5.0",
|
|
38
38
|
"id": "my-workspace-plugin",
|
|
39
39
|
"name": "My Workspace Plugin",
|
|
40
40
|
"version": "0.1.0",
|
|
@@ -47,6 +47,7 @@ settings schema and assets.
|
|
|
47
47
|
"id": "workspace.search",
|
|
48
48
|
"title": "Search workspace",
|
|
49
49
|
"description": "Read matching workspace resources.",
|
|
50
|
+
"domains": ["products"],
|
|
50
51
|
"effect": "read",
|
|
51
52
|
"tool": "search_workspace",
|
|
52
53
|
"connection_id": "workspace",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# nutria-plugin SDK documentation
|
|
2
2
|
|
|
3
|
-
Developer reference for SDK `0.
|
|
3
|
+
Developer reference for SDK `0.5.0` and manifest schema `5.0`.
|
|
4
4
|
|
|
5
5
|
| Document | Purpose |
|
|
6
6
|
|---|---|
|
|
7
|
-
| [quickstart.md](quickstart.md) | Build a strict schema
|
|
7
|
+
| [quickstart.md](quickstart.md) | Build a strict schema 5.0 plugin |
|
|
8
8
|
| [manifest.md](manifest.md) | Manifest, capability, and provider contracts |
|
|
9
9
|
| [reviewable-actions.md](reviewable-actions.md) | Host-owned drafts and external delivery |
|
|
10
10
|
| [python-api.md](python-api.md) | Public Python API |
|
|
@@ -16,6 +16,6 @@ Developer reference for SDK `0.4.1` and manifest schema `4.0`.
|
|
|
16
16
|
| [cli.md](cli.md) | CLI commands |
|
|
17
17
|
|
|
18
18
|
A plugin bundle can contain connections, skills, context documents, hooks,
|
|
19
|
-
settings, specs, and declarative admin assets. Its schema
|
|
19
|
+
settings, specs, and declarative admin assets. Its schema 5.0 manifest must also
|
|
20
20
|
declare at least one typed capability and world provider. Older schemas are not
|
|
21
21
|
loaded or migrated.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# plugin.json manifest reference
|
|
2
2
|
|
|
3
3
|
`plugin.json` is the single source of truth for plugin identity, runtime,
|
|
4
|
-
capability authority, and provider topology. SDK 0.
|
|
5
|
-
`
|
|
4
|
+
capability authority, and provider topology. SDK 0.5.0 accepts exactly schema
|
|
5
|
+
`5.0`; older schemas and unknown fields fail validation.
|
|
6
6
|
|
|
7
7
|
## Required top-level fields
|
|
8
8
|
|
|
9
9
|
| Field | Contract |
|
|
10
10
|
|---|---|
|
|
11
|
-
| `schema_version` | Literal `"
|
|
11
|
+
| `schema_version` | Literal `"5.0"` |
|
|
12
12
|
| `id` | Lowercase plugin slug |
|
|
13
13
|
| `name`, `description`, `author` | Non-empty display metadata |
|
|
14
14
|
| `version` | Semantic version |
|
|
@@ -19,7 +19,7 @@ capability authority, and provider topology. SDK 0.4.1 accepts exactly schema
|
|
|
19
19
|
Optional fields include `default_scope`, `paths`, `required_secrets`,
|
|
20
20
|
`optional_secrets`, `remote_endpoints`, `tags`, `reviewable_actions`,
|
|
21
21
|
`admin_extensions`, `admin_flows`, `mcp_server_entry`, `homepage`, `license`,
|
|
22
|
-
and `signature`. A `compatibility` field is not part of schema
|
|
22
|
+
and `signature`. A `compatibility` field is not part of schema 5.0.
|
|
23
23
|
|
|
24
24
|
## Capability descriptor
|
|
25
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Python API reference
|
|
2
2
|
|
|
3
|
-
SDK 0.
|
|
3
|
+
SDK 0.5.0 exposes the strict schema 5.0 API.
|
|
4
4
|
|
|
5
5
|
```python
|
|
6
6
|
from nutria_plugin import (
|
|
@@ -39,7 +39,7 @@ manifest.to_file(Path("plugin.json"))
|
|
|
39
39
|
payload = manifest.model_dump(mode="json", exclude_none=True)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Validation is strict: schema version must be `
|
|
42
|
+
Validation is strict: schema version must be `5.0`, top-level extras are
|
|
43
43
|
rejected, and capability/provider/action references are checked together.
|
|
44
44
|
|
|
45
45
|
## Bundles and packaging
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Quickstart: a schema
|
|
1
|
+
# Quickstart: a schema 5.0 plugin
|
|
2
2
|
|
|
3
3
|
## Install and scaffold
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
uv add nutria-plugin==0.
|
|
6
|
+
uv add nutria-plugin==0.5.0
|
|
7
7
|
nutria-plugin new inventory-lookup --name "Inventory Lookup"
|
|
8
8
|
```
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ nutria-plugin new inventory-lookup --name "Inventory Lookup"
|
|
|
11
11
|
|
|
12
12
|
```json
|
|
13
13
|
{
|
|
14
|
-
"schema_version": "
|
|
14
|
+
"schema_version": "5.0",
|
|
15
15
|
"id": "inventory-lookup",
|
|
16
16
|
"name": "Inventory Lookup",
|
|
17
17
|
"version": "0.1.0",
|
|
@@ -24,6 +24,7 @@ nutria-plugin new inventory-lookup --name "Inventory Lookup"
|
|
|
24
24
|
"id": "warehouse.stock.read",
|
|
25
25
|
"title": "Read stock",
|
|
26
26
|
"description": "Read current stock for one SKU.",
|
|
27
|
+
"domains": ["products"],
|
|
27
28
|
"effect": "read",
|
|
28
29
|
"tool": "get_stock",
|
|
29
30
|
"connection_id": "warehouse",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Reviewable actions and external writes
|
|
2
2
|
|
|
3
|
-
SDK 0.
|
|
3
|
+
SDK 0.5.0 schema 5.0 defines one reviewable-action architecture:
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
6
|
ChatBotNutralia -> task context, encrypted draft, revision, approval, idempotency, receipts
|
|
@@ -36,7 +36,7 @@ requirements, input bindings, and `reviewable_action_id`:
|
|
|
36
36
|
},
|
|
37
37
|
"reviewable_action_id": "whatsapp-text",
|
|
38
38
|
"inputs": [
|
|
39
|
-
{"kind": "value", "semantic_field": "recipient", "argument_name": "recipient", "sensitivity": "personal", "accepted_origins": ["current_user", "world_resource"]},
|
|
39
|
+
{"kind": "value", "semantic_field": "recipient", "argument_name": "recipient", "sensitivity": "personal", "requires_provenance": true, "accepted_origins": ["current_user", "world_resource"]},
|
|
40
40
|
{"kind": "value", "semantic_field": "body", "argument_name": "body", "sensitivity": "personal", "accepted_origins": ["current_user"]},
|
|
41
41
|
{"kind": "value", "semantic_field": "idempotency_key", "argument_name": "idempotency_key", "sensitivity": "safe", "accepted_origins": ["current_user"]}
|
|
42
42
|
]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Public API
|
|
4
4
|
----------
|
|
5
5
|
Models:
|
|
6
|
-
PluginManifest, PluginPaths, PluginScope, PluginRuntimeType
|
|
6
|
+
PluginManifest, PluginPaths, PluginScope, PluginRuntimeType, CapabilityDomain
|
|
7
7
|
|
|
8
8
|
Bundle operations:
|
|
9
9
|
load_plugin_bundle, extract_plugin_bundle, validate_zip
|
|
@@ -15,7 +15,7 @@ Signing:
|
|
|
15
15
|
generate_keypair, sign_manifest, verify_manifest, SignatureStatus
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
__version__ = "0.
|
|
18
|
+
__version__ = "0.5.0"
|
|
19
19
|
|
|
20
20
|
from .capabilities import (
|
|
21
21
|
CapabilityDescriptor,
|
|
@@ -34,6 +34,7 @@ from .capabilities import (
|
|
|
34
34
|
WorldProjectionDescriptor,
|
|
35
35
|
WorldProviderDescriptor,
|
|
36
36
|
)
|
|
37
|
+
from .domains import CapabilityDomain, CAPABILITY_DOMAIN_IDS, DOMAIN_LABELS
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
from .manifest import (
|
|
@@ -70,6 +71,9 @@ __all__ = [
|
|
|
70
71
|
"PluginPaths",
|
|
71
72
|
"PluginScope",
|
|
72
73
|
"PluginRuntimeType",
|
|
74
|
+
"CapabilityDomain",
|
|
75
|
+
"CAPABILITY_DOMAIN_IDS",
|
|
76
|
+
"DOMAIN_LABELS",
|
|
73
77
|
"PluginAdminExtension",
|
|
74
78
|
"PluginAdminExtensionKind",
|
|
75
79
|
"PluginAdminExtensionPlacement",
|
|
@@ -40,10 +40,6 @@ ALLOWED_EXTENSIONS = {
|
|
|
40
40
|
".yml",
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
# Kept for backwards-compatible imports; no longer used in core validation.
|
|
44
|
-
BLOCKED_PATTERNS = {".py", ".js", ".ts", ".sh", ".exe", ".dll", ".so", ".whl", ".tar"}
|
|
45
|
-
|
|
46
|
-
|
|
47
43
|
class PluginBundleError(Exception):
|
|
48
44
|
"""Raised when a plugin ZIP is invalid, corrupt, or unsafe."""
|
|
49
45
|
|
|
@@ -7,6 +7,8 @@ from typing import Any, Literal
|
|
|
7
7
|
|
|
8
8
|
from pydantic import BaseModel, Field, field_validator, model_validator
|
|
9
9
|
|
|
10
|
+
from .domains import CAPABILITY_DOMAIN_IDS, normalize_domains
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
_RESOURCE_TYPE_PATTERN = r"^[a-z][a-z0-9_.-]{0,127}$"
|
|
12
14
|
|
|
@@ -155,6 +157,7 @@ class CapabilityInputBinding(BaseModel):
|
|
|
155
157
|
resource_type: ResourceType | str | None = None
|
|
156
158
|
required: bool = True
|
|
157
159
|
sensitivity: Literal["safe", "personal"] = "safe"
|
|
160
|
+
requires_provenance: bool = False
|
|
158
161
|
accepted_origins: list[Literal["current_user", "world_resource"]] = Field(min_length=1)
|
|
159
162
|
|
|
160
163
|
model_config = {"extra": "forbid"}
|
|
@@ -172,8 +175,10 @@ class CapabilityInputBinding(BaseModel):
|
|
|
172
175
|
raise ValueError("resource inputs require resource_type")
|
|
173
176
|
if self.kind == "value" and self.resource_type is not None:
|
|
174
177
|
raise ValueError("value inputs must not declare resource_type")
|
|
175
|
-
if self.
|
|
176
|
-
raise ValueError("
|
|
178
|
+
if self.kind == "resource" and self.requires_provenance:
|
|
179
|
+
raise ValueError("resource inputs already carry world_resource provenance")
|
|
180
|
+
if self.kind == "resource" and "world_resource" not in self.accepted_origins:
|
|
181
|
+
raise ValueError("resource inputs must accept world_resource evidence")
|
|
177
182
|
return self
|
|
178
183
|
|
|
179
184
|
|
|
@@ -273,6 +278,7 @@ class CapabilityDescriptor(BaseModel):
|
|
|
273
278
|
id: str = Field(..., pattern=r"^[a-z][a-z0-9_.-]{0,127}$")
|
|
274
279
|
title: str = Field(..., min_length=1, max_length=160)
|
|
275
280
|
description: str = Field(..., min_length=1, max_length=2_000)
|
|
281
|
+
domains: list[str] = Field(..., min_length=1)
|
|
276
282
|
effect: CapabilityEffect
|
|
277
283
|
tool: str = Field(..., pattern=r"^[a-zA-Z][a-zA-Z0-9_-]{0,127}$")
|
|
278
284
|
connection_id: str | None = Field(
|
|
@@ -293,6 +299,16 @@ class CapabilityDescriptor(BaseModel):
|
|
|
293
299
|
|
|
294
300
|
model_config = {"extra": "forbid"}
|
|
295
301
|
|
|
302
|
+
@field_validator("domains")
|
|
303
|
+
@classmethod
|
|
304
|
+
def _validate_domains(cls, value: list[str]) -> list[str]:
|
|
305
|
+
normalized = normalize_domains(value)
|
|
306
|
+
if len(normalized) != len(value):
|
|
307
|
+
raise ValueError("capability domains must not contain duplicates")
|
|
308
|
+
if any(domain not in CAPABILITY_DOMAIN_IDS for domain in normalized):
|
|
309
|
+
raise ValueError("capability domains must use the stable domain registry")
|
|
310
|
+
return list(normalized)
|
|
311
|
+
|
|
296
312
|
@model_validator(mode="after")
|
|
297
313
|
def _validate_contract(self) -> "CapabilityDescriptor":
|
|
298
314
|
if self.exposure == CapabilityExposure.MODEL and self.non_callable_reason is not None:
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Stable capability-domain vocabulary shared by plugin manifests and hosts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from enum import Enum
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CapabilityDomain(str, Enum):
|
|
9
|
+
"""Business context domains used for progressive context disclosure."""
|
|
10
|
+
|
|
11
|
+
PRODUCTS = "products"
|
|
12
|
+
ORDERS = "orders"
|
|
13
|
+
WHATSAPP = "whatsapp"
|
|
14
|
+
EMAIL = "email"
|
|
15
|
+
MRW = "mrw"
|
|
16
|
+
TRELLO = "trello"
|
|
17
|
+
TASKS = "tasks"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
DOMAIN_LABELS: dict[CapabilityDomain, str] = {
|
|
21
|
+
CapabilityDomain.PRODUCTS: "Productos",
|
|
22
|
+
CapabilityDomain.ORDERS: "Pedidos",
|
|
23
|
+
CapabilityDomain.WHATSAPP: "WhatsApp",
|
|
24
|
+
CapabilityDomain.EMAIL: "Email",
|
|
25
|
+
CapabilityDomain.MRW: "MRW",
|
|
26
|
+
CapabilityDomain.TRELLO: "Trello",
|
|
27
|
+
CapabilityDomain.TASKS: "Tareas",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
CAPABILITY_DOMAIN_IDS = frozenset(domain.value for domain in CapabilityDomain)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def normalize_domains(values: list[str | CapabilityDomain]) -> tuple[str, ...]:
|
|
34
|
+
"""Return a stable, duplicate-free tuple of valid domain IDs."""
|
|
35
|
+
|
|
36
|
+
normalized = tuple(
|
|
37
|
+
dict.fromkeys(
|
|
38
|
+
value.value if isinstance(value, CapabilityDomain) else str(value).strip()
|
|
39
|
+
for value in values
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
if not normalized or any(value not in CAPABILITY_DOMAIN_IDS for value in normalized):
|
|
43
|
+
raise ValueError("capabilities must declare one or more known domains")
|
|
44
|
+
return normalized
|
|
@@ -315,7 +315,7 @@ class PluginAdminFlow(BaseModel):
|
|
|
315
315
|
class PluginManifest(BaseModel):
|
|
316
316
|
"""Manifest stored in plugin.json — the single source of truth for plugin metadata."""
|
|
317
317
|
|
|
318
|
-
schema_version: Literal["
|
|
318
|
+
schema_version: Literal["5.0"]
|
|
319
319
|
id: str = Field(..., pattern=r"^[a-z][a-z0-9\-]*$", max_length=64)
|
|
320
320
|
name: str = Field(..., min_length=1, max_length=128)
|
|
321
321
|
version: str = Field(..., min_length=5, max_length=64)
|
|
@@ -25,7 +25,7 @@ class PackagingError(Exception):
|
|
|
25
25
|
SCAFFOLD_TEMPLATE = {
|
|
26
26
|
"plugin.json": lambda plugin_id, name: json.dumps(
|
|
27
27
|
{
|
|
28
|
-
"schema_version": "
|
|
28
|
+
"schema_version": "5.0",
|
|
29
29
|
"id": plugin_id,
|
|
30
30
|
"name": name,
|
|
31
31
|
"version": "0.1.0",
|
|
@@ -40,6 +40,7 @@ SCAFFOLD_TEMPLATE = {
|
|
|
40
40
|
"id": f"{plugin_id}.health.read",
|
|
41
41
|
"title": "Read plugin health",
|
|
42
42
|
"description": "Read the current plugin connection health.",
|
|
43
|
+
"domains": ["products"],
|
|
43
44
|
"effect": "read",
|
|
44
45
|
"tool": "get_health",
|
|
45
46
|
"connection_id": plugin_id,
|
|
@@ -28,7 +28,7 @@ def _make_zip(files: dict[str, str]) -> bytes:
|
|
|
28
28
|
|
|
29
29
|
VALID_MANIFEST = json.dumps(
|
|
30
30
|
{
|
|
31
|
-
"schema_version": "
|
|
31
|
+
"schema_version": "5.0",
|
|
32
32
|
"id": "test-plugin",
|
|
33
33
|
"name": "Test",
|
|
34
34
|
"version": "1.0.0",
|
|
@@ -40,6 +40,7 @@ VALID_MANIFEST = json.dumps(
|
|
|
40
40
|
"id": "test.health.read",
|
|
41
41
|
"title": "Read health",
|
|
42
42
|
"description": "Read plugin health.",
|
|
43
|
+
"domains": ["products"],
|
|
43
44
|
"effect": "read",
|
|
44
45
|
"tool": "get_health",
|
|
45
46
|
"connection_id": "test",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"""Strict world-graph capability contracts for SDK schema
|
|
1
|
+
"""Strict world-graph capability contracts for SDK schema 5.0."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
6
|
from pydantic import ValidationError
|
|
7
7
|
|
|
8
|
-
from nutria_plugin import CapabilityDescriptor, CapabilityExposure
|
|
8
|
+
from nutria_plugin import CapabilityDescriptor, CapabilityExposure, CapabilityInputBinding
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def _capability(**overrides):
|
|
@@ -13,6 +13,7 @@ def _capability(**overrides):
|
|
|
13
13
|
"id": "shipping.create",
|
|
14
14
|
"title": "Create shipment",
|
|
15
15
|
"description": "Create one shipment after an exact preview.",
|
|
16
|
+
"domains": ["mrw"],
|
|
16
17
|
"effect": "external_write",
|
|
17
18
|
"tool": "create_shipment",
|
|
18
19
|
"requirements": {
|
|
@@ -84,6 +85,21 @@ def test_missing_exposure_is_rejected():
|
|
|
84
85
|
CapabilityDescriptor.model_validate(payload)
|
|
85
86
|
|
|
86
87
|
|
|
88
|
+
def test_domains_are_required_and_registry_bound():
|
|
89
|
+
payload = _capability(effect="read", produces=[{"result_path": ".shipment", "resource_type": "mrw.shipment", "output_name": "shipment"}])
|
|
90
|
+
payload.pop("domains")
|
|
91
|
+
with pytest.raises(ValidationError, match="domains"):
|
|
92
|
+
CapabilityDescriptor.model_validate(payload)
|
|
93
|
+
|
|
94
|
+
with pytest.raises(ValidationError, match="domain"):
|
|
95
|
+
CapabilityDescriptor.model_validate(_capability(domains=["shipping"]))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_domains_must_not_repeat():
|
|
99
|
+
with pytest.raises(ValidationError, match="duplicates"):
|
|
100
|
+
CapabilityDescriptor.model_validate(_capability(domains=["mrw", "mrw"]))
|
|
101
|
+
|
|
102
|
+
|
|
87
103
|
@pytest.mark.parametrize("exposure", ["host", "admin"])
|
|
88
104
|
def test_non_model_exposure_requires_reason(exposure):
|
|
89
105
|
with pytest.raises(ValidationError, match="non_callable_reason"):
|
|
@@ -200,19 +216,69 @@ def test_unknown_prepared_action_adapter_is_rejected():
|
|
|
200
216
|
CapabilityDescriptor.model_validate(_capability(**contracts))
|
|
201
217
|
|
|
202
218
|
|
|
203
|
-
def
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
219
|
+
def test_personal_input_provenance_is_independent_from_sensitivity():
|
|
220
|
+
descriptor = CapabilityDescriptor.model_validate(
|
|
221
|
+
_capability(
|
|
222
|
+
inputs=[
|
|
223
|
+
{
|
|
224
|
+
"kind": "value",
|
|
225
|
+
"semantic_field": "recipient",
|
|
226
|
+
"argument_name": "recipient",
|
|
227
|
+
"sensitivity": "personal",
|
|
228
|
+
"requires_provenance": True,
|
|
229
|
+
"accepted_origins": ["world_resource"],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"kind": "value",
|
|
233
|
+
"semantic_field": "body",
|
|
234
|
+
"argument_name": "body",
|
|
235
|
+
"sensitivity": "personal",
|
|
236
|
+
"requires_provenance": False,
|
|
237
|
+
"accepted_origins": ["current_user", "world_resource"],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
**_safety_contracts(),
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
assert descriptor.inputs[0].requires_provenance is True
|
|
245
|
+
assert descriptor.inputs[1].requires_provenance is False
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def test_resource_input_rejects_redundant_requires_provenance():
|
|
249
|
+
payload = _capability(
|
|
250
|
+
effect="read",
|
|
251
|
+
inputs=[
|
|
252
|
+
{
|
|
253
|
+
"kind": "resource",
|
|
254
|
+
"semantic_field": "source_ref",
|
|
255
|
+
"argument_name": "source_ref",
|
|
256
|
+
"resource_type": "email_message",
|
|
257
|
+
"requires_provenance": True,
|
|
258
|
+
"accepted_origins": ["world_resource"],
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
produces=[
|
|
262
|
+
{
|
|
263
|
+
"result_path": ".message",
|
|
264
|
+
"resource_type": "email_message",
|
|
265
|
+
"output_name": "message",
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
with pytest.raises(ValidationError, match="already carry world_resource provenance"):
|
|
271
|
+
CapabilityDescriptor.model_validate(payload)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def test_resource_input_requires_world_resource_origin():
|
|
275
|
+
with pytest.raises(ValidationError, match="world_resource"):
|
|
276
|
+
CapabilityInputBinding.model_validate(
|
|
277
|
+
{
|
|
278
|
+
"kind": "resource",
|
|
279
|
+
"semantic_field": "source_ref",
|
|
280
|
+
"argument_name": "source_ref",
|
|
281
|
+
"resource_type": "email_message",
|
|
282
|
+
"accepted_origins": ["current_user"],
|
|
283
|
+
}
|
|
218
284
|
)
|
|
@@ -18,7 +18,7 @@ from nutria_plugin.manifest import (
|
|
|
18
18
|
|
|
19
19
|
def _minimal_manifest(**overrides) -> dict:
|
|
20
20
|
base = {
|
|
21
|
-
"schema_version": "
|
|
21
|
+
"schema_version": "5.0",
|
|
22
22
|
"id": "test-plugin",
|
|
23
23
|
"name": "Test Plugin",
|
|
24
24
|
"version": "1.0.0",
|
|
@@ -30,6 +30,7 @@ def _minimal_manifest(**overrides) -> dict:
|
|
|
30
30
|
"id": "test.health.read",
|
|
31
31
|
"title": "Read health",
|
|
32
32
|
"description": "Read current plugin health.",
|
|
33
|
+
"domains": ["products"],
|
|
33
34
|
"effect": "read",
|
|
34
35
|
"tool": "get_health",
|
|
35
36
|
"connection_id": "test",
|
|
@@ -104,11 +105,16 @@ def test_version_must_be_semver():
|
|
|
104
105
|
PluginManifest.model_validate(_minimal_manifest(version="1.0"))
|
|
105
106
|
|
|
106
107
|
|
|
107
|
-
def
|
|
108
|
+
def test_schema_version_must_be_5_0():
|
|
108
109
|
with pytest.raises(ValidationError):
|
|
109
110
|
PluginManifest.model_validate(_minimal_manifest(schema_version="1.1"))
|
|
110
111
|
|
|
111
112
|
|
|
113
|
+
def test_schema_4_is_rejected():
|
|
114
|
+
with pytest.raises(ValidationError):
|
|
115
|
+
PluginManifest.model_validate(_minimal_manifest(schema_version="4.0"))
|
|
116
|
+
|
|
117
|
+
|
|
112
118
|
@pytest.mark.parametrize("version", ["1.0", "2.0", "2.1", "2.2", "2.3"])
|
|
113
119
|
def test_other_schema_versions_are_rejected(version):
|
|
114
120
|
with pytest.raises(ValidationError):
|
|
@@ -118,12 +124,13 @@ def test_other_schema_versions_are_rejected(version):
|
|
|
118
124
|
def test_schema_3_0_world_provider_accepts_custom_resource_type():
|
|
119
125
|
manifest = PluginManifest.model_validate(
|
|
120
126
|
_minimal_manifest(
|
|
121
|
-
schema_version="
|
|
127
|
+
schema_version="5.0",
|
|
122
128
|
capabilities=[
|
|
123
129
|
{
|
|
124
130
|
"id": "workspace.search",
|
|
125
131
|
"title": "Search workspace",
|
|
126
132
|
"description": "Find authoritative workspace items.",
|
|
133
|
+
"domains": ["products"],
|
|
127
134
|
"effect": "read",
|
|
128
135
|
"tool": "search_workspace",
|
|
129
136
|
"connection_id": "workspace",
|
|
@@ -166,7 +173,7 @@ def test_schema_3_0_world_provider_accepts_custom_resource_type():
|
|
|
166
173
|
)
|
|
167
174
|
)
|
|
168
175
|
|
|
169
|
-
assert manifest.schema_version == "
|
|
176
|
+
assert manifest.schema_version == "5.0"
|
|
170
177
|
assert manifest.world_providers[0].resource_types[0].id == "workspace.item"
|
|
171
178
|
|
|
172
179
|
|
|
@@ -174,7 +181,7 @@ def test_world_provider_rejects_unknown_capability_reference():
|
|
|
174
181
|
with pytest.raises(ValidationError, match="unknown capability"):
|
|
175
182
|
PluginManifest.model_validate(
|
|
176
183
|
_minimal_manifest(
|
|
177
|
-
schema_version="
|
|
184
|
+
schema_version="5.0",
|
|
178
185
|
world_providers=[
|
|
179
186
|
{
|
|
180
187
|
"id": "workspace",
|
|
@@ -39,6 +39,7 @@ def _capabilities():
|
|
|
39
39
|
"id": "email.reply.prepare",
|
|
40
40
|
"title": "Prepare email reply",
|
|
41
41
|
"description": "Resolve the source email envelope without writing.",
|
|
42
|
+
"domains": ["email"],
|
|
42
43
|
"effect": "read",
|
|
43
44
|
"tool": "prepare_email_reply",
|
|
44
45
|
"connection_id": "email",
|
|
@@ -60,6 +61,7 @@ def _capabilities():
|
|
|
60
61
|
"id": "email.send.reply",
|
|
61
62
|
"title": "Send email reply",
|
|
62
63
|
"description": "Deliver the exact approved email reply.",
|
|
64
|
+
"domains": ["email"],
|
|
63
65
|
"effect": "external_write",
|
|
64
66
|
"tool": "send_resolved_email_reply",
|
|
65
67
|
"connection_id": "email",
|
|
@@ -132,7 +134,7 @@ def _capabilities():
|
|
|
132
134
|
|
|
133
135
|
def _manifest(**overrides):
|
|
134
136
|
data = {
|
|
135
|
-
"schema_version": "
|
|
137
|
+
"schema_version": "5.0",
|
|
136
138
|
"id": "email-plugin",
|
|
137
139
|
"name": "Email",
|
|
138
140
|
"version": "1.0.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|