nutria-plugin 0.6.1__tar.gz → 0.6.3__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.
Files changed (54) hide show
  1. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/CHANGELOG.md +16 -0
  2. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/PKG-INFO +3 -3
  3. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/README.md +2 -2
  4. nutria_plugin-0.6.3/docs/conversation-ownership.md +29 -0
  5. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/index.md +1 -1
  6. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/manifest.md +1 -1
  7. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/python-api.md +1 -1
  8. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/quickstart.md +1 -1
  9. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/pyproject.toml +1 -1
  10. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/__init__.py +12 -1
  11. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/domains.py +2 -0
  12. nutria_plugin-0.6.3/src/nutria_plugin/ownership.py +95 -0
  13. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_capability_contracts.py +10 -0
  14. nutria_plugin-0.6.3/tests/test_ownership.py +47 -0
  15. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/uv.lock +1 -1
  16. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/.github/workflows/publish.yml +0 -0
  17. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/.gitignore +0 -0
  18. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/admin-extensions.md +0 -0
  19. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/admin-flows.md +0 -0
  20. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/capability-authoring.md +0 -0
  21. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/cli.md +0 -0
  22. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/connection-types.md +0 -0
  23. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/migration-6.0.md +0 -0
  24. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/reviewable-actions.md +0 -0
  25. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/security.md +0 -0
  26. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/docs/skill-format.md +0 -0
  27. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/examples/my-first-plugin/README.md +0 -0
  28. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/examples/my-first-plugin/hooks/hooks.json +0 -0
  29. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/examples/my-first-plugin/plugin.json +0 -0
  30. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/examples/my-first-plugin/settings.schema.json +0 -0
  31. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/bundle.py +0 -0
  32. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/capabilities.py +0 -0
  33. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/cli.py +0 -0
  34. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/hierarchy.py +0 -0
  35. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/manifest.py +0 -0
  36. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/mcp_results.py +0 -0
  37. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/migrate.py +0 -0
  38. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/operation_facts.py +0 -0
  39. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/packaging.py +0 -0
  40. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/prepared_preview.py +0 -0
  41. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/signing.py +0 -0
  42. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/src/nutria_plugin/skills.py +0 -0
  43. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/__init__.py +0 -0
  44. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_bundle.py +0 -0
  45. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_cli.py +0 -0
  46. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_contract_vnext.py +0 -0
  47. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_hierarchy.py +0 -0
  48. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_manifest.py +0 -0
  49. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_mcp_results.py +0 -0
  50. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_packaging.py +0 -0
  51. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_prepared_preview.py +0 -0
  52. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_reviewable_actions.py +0 -0
  53. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_signing.py +0 -0
  54. {nutria_plugin-0.6.1 → nutria_plugin-0.6.3}/tests/test_skill_format_docs.py +0 -0
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.3
4
+
5
+ Additive.
6
+
7
+ - Add `nutria_plugin.ownership`: `OwnerKind` (`human`, `agent`, `customer_service`), `ConversationOwnership` and
8
+ `ownership_from_event_payload`. One definition of who answers an outside person (priority human > agent > customer service,
9
+ a person's lock holds against every agent). Channel plugins report it as `conversation_ownership` in each inbound event;
10
+ the keys older plugins send (`ownership_state`, `human_owned`, `reply_blocked`) are still read. See `docs/conversation-ownership.md`.
11
+
12
+ ## 0.6.2
13
+
14
+ Additive.
15
+
16
+ - Add the `external` capability domain (label "Servicios externos") for capabilities generated from client-connected
17
+ MCP servers that no plugin describes.
18
+
3
19
  ## 0.6.1
4
20
 
5
21
  Additive; manifests that do not use the new field are unchanged.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: nutria-plugin
3
- Version: 0.6.1
3
+ Version: 0.6.3
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
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
22
22
 
23
23
  SDK for building, validating, signing, and packaging Nutria plugins.
24
24
 
25
- Release `0.6.1` accepts only manifest schema `6.0`. Capabilities use their real
25
+ Release `0.6.2` accepts only manifest schema `6.0`. Capabilities use their real
26
26
  business effect (`read`, `write`, or `external_write`); preparation is expressed
27
27
  by producing `prepared_action`, not by a workflow-phase effect. Every parsed
28
28
  requirement resolves `task_context` to `required`, `optional`, or `forbidden`,
@@ -35,7 +35,7 @@ and exact delivery of an approved snapshot.
35
35
  ## Install
36
36
 
37
37
  ```bash
38
- uv add nutria-plugin==0.6.1
38
+ uv add nutria-plugin==0.6.2
39
39
  ```
40
40
 
41
41
  ## Scaffold and validate
@@ -2,7 +2,7 @@
2
2
 
3
3
  SDK for building, validating, signing, and packaging Nutria plugins.
4
4
 
5
- Release `0.6.1` accepts only manifest schema `6.0`. Capabilities use their real
5
+ Release `0.6.2` accepts only manifest schema `6.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.6.1
18
+ uv add nutria-plugin==0.6.2
19
19
  ```
20
20
 
21
21
  ## Scaffold and validate
@@ -0,0 +1,29 @@
1
+ # Conversation ownership
2
+
3
+ A conversation with an outside person has one owner at a time. A channel plugin reports it in every inbound event; the host
4
+ decides which agent answers. The words are defined once, in `nutria_plugin.ownership`.
5
+
6
+ | Owner kind | Meaning | Answers |
7
+ | --- | --- | --- |
8
+ | `human` | A team member took the conversation | Nobody else. Agents may draft and open cases. |
9
+ | `agent` | An agent started it or was handed it (`owner_ref` is the agent id) | That agent, with its own identity and rules |
10
+ | `customer_service` | Nobody above owns it (the default) | The customer-service agent |
11
+
12
+ A weaker owner never takes a conversation from a stronger one. `locked: true` (set by a person) holds it against every agent,
13
+ including the owning one.
14
+
15
+ ## In the event payload
16
+ ```json
17
+ {"conversation_ownership": {"owner_kind": "human", "owner_ref": "alejandro", "locked": false, "reason": "manual_takeover"}}
18
+ ```
19
+ A plugin that knows only who is a human (as the WhatsApp plugin did with `ownership_state`, `human_owned`, `reply_blocked`) keeps working:
20
+ `ownership_from_event_payload` maps those keys to the same model. A plugin that does not send ownership leaves the choice to the host.
21
+
22
+ ## What a plugin must do
23
+ - Report the human state it can observe (a person answered from the phone or the web client, a manual lock) as `owner_kind: human`.
24
+ - Never decide which agent answers; that is the host's job (it also records agent ownership from its own deliveries).
25
+ - Refuse to deliver an agent message to a conversation the plugin knows is human-owned and locked.
26
+
27
+ ## What a host must do
28
+ Resolve the answering agent from the plugin's report and its own ownership record, with the priority above; release agent ownership when the agent closes the
29
+ conversation, the contact asks to stop, a person takes over, or the conversation has been idle for the host's configured time.
@@ -1,6 +1,6 @@
1
1
  # nutria-plugin SDK documentation
2
2
 
3
- Developer reference for SDK `0.6.1` and manifest schema `6.0`.
3
+ Developer reference for SDK `0.6.2` and manifest schema `6.0`.
4
4
 
5
5
  | Document | Purpose |
6
6
  |---|---|
@@ -1,7 +1,7 @@
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, prepared-action provider defaults, and provider topology. SDK 0.6.1 accepts exactly schema
4
+ capability authority, prepared-action provider defaults, and provider topology. SDK 0.6.2 accepts exactly schema
5
5
  `6.0`; older schemas and unknown fields fail validation.
6
6
 
7
7
  ## Required top-level fields
@@ -1,6 +1,6 @@
1
1
  # Python API reference
2
2
 
3
- SDK 0.6.1 exposes the strict schema 6.0 API.
3
+ SDK 0.6.2 exposes the strict schema 6.0 API.
4
4
 
5
5
  ```python
6
6
  from nutria_plugin import (
@@ -3,7 +3,7 @@
3
3
  ## Install and scaffold
4
4
 
5
5
  ```bash
6
- uv add nutria-plugin==0.6.1
6
+ uv add nutria-plugin==0.6.2
7
7
  nutria-plugin new inventory-lookup --name "Inventory Lookup"
8
8
  ```
9
9
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nutria-plugin"
7
- version = "0.6.1"
7
+ version = "0.6.3"
8
8
  description = "SDK for building, validating, signing, and packaging Nutria plugins"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -15,7 +15,7 @@ Signing:
15
15
  generate_keypair, sign_manifest, verify_manifest, SignatureStatus
16
16
  """
17
17
 
18
- __version__ = "0.6.1"
18
+ __version__ = "0.6.3"
19
19
 
20
20
  from .capabilities import (
21
21
  CapabilityDescriptor,
@@ -37,6 +37,12 @@ from .capabilities import (
37
37
  WorldProjectionDescriptor,
38
38
  WorldProviderDescriptor,
39
39
  )
40
+ from .ownership import (
41
+ OWNER_PRIORITY,
42
+ ConversationOwnership,
43
+ OwnerKind,
44
+ ownership_from_event_payload,
45
+ )
40
46
  from .prepared_preview import (
41
47
  PREVIEW_CONFORMANCE_VECTORS,
42
48
  check_prepared_preview,
@@ -84,6 +90,11 @@ from .skills import SkillFrontmatter, parse_skill_frontmatter
84
90
 
85
91
  __all__ = [
86
92
  "__version__",
93
+ # Conversation ownership
94
+ "OWNER_PRIORITY",
95
+ "ConversationOwnership",
96
+ "OwnerKind",
97
+ "ownership_from_event_payload",
87
98
  # Manifest
88
99
  "PluginManifest",
89
100
  "PluginPaths",
@@ -15,6 +15,7 @@ class CapabilityDomain(str, Enum):
15
15
  MRW = "mrw"
16
16
  TRELLO = "trello"
17
17
  TASKS = "tasks"
18
+ EXTERNAL = "external"
18
19
 
19
20
 
20
21
  DOMAIN_LABELS: dict[CapabilityDomain, str] = {
@@ -25,6 +26,7 @@ DOMAIN_LABELS: dict[CapabilityDomain, str] = {
25
26
  CapabilityDomain.MRW: "MRW",
26
27
  CapabilityDomain.TRELLO: "Trello",
27
28
  CapabilityDomain.TASKS: "Tareas",
29
+ CapabilityDomain.EXTERNAL: "Servicios externos",
28
30
  }
29
31
 
30
32
  CAPABILITY_DOMAIN_IDS = frozenset(domain.value for domain in CapabilityDomain)
@@ -0,0 +1,95 @@
1
+ """Conversation ownership: who answers an outside person right now.
2
+
3
+ A channel plugin that talks to outside people (WhatsApp, email, chat widgets) reports, with each inbound
4
+ event, who owns the conversation. A host resolves the answering agent from it. One definition, so every
5
+ plugin and every host agree on the words.
6
+
7
+ Priority, strongest first: ``human`` > ``agent`` > ``customer_service``. A weaker owner never takes a
8
+ conversation from a stronger one. A lock (set by a person) holds the conversation against every agent.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from collections.abc import Mapping
14
+ from enum import Enum
15
+ from typing import Any
16
+
17
+ from pydantic import BaseModel, ConfigDict, Field
18
+
19
+
20
+ class OwnerKind(str, Enum):
21
+ HUMAN = "human"
22
+ AGENT = "agent"
23
+ CUSTOMER_SERVICE = "customer_service"
24
+
25
+
26
+ OWNER_PRIORITY: dict[OwnerKind, int] = {
27
+ OwnerKind.HUMAN: 3,
28
+ OwnerKind.AGENT: 2,
29
+ OwnerKind.CUSTOMER_SERVICE: 1,
30
+ }
31
+
32
+ # States older plugins already send in the event payload (``owner_state`` / ``ownership_state``).
33
+ _LEGACY_HUMAN_STATES = frozenset({"human_owned", "locked", "human"})
34
+
35
+
36
+ class ConversationOwnership(BaseModel):
37
+ """Who owns one conversation with one contact on one channel."""
38
+
39
+ model_config = ConfigDict(extra="forbid", frozen=True)
40
+
41
+ owner_kind: OwnerKind = OwnerKind.CUSTOMER_SERVICE
42
+ owner_ref: str | None = Field(
43
+ default=None,
44
+ description="Agent id when owner_kind is 'agent'; the person's id when 'human'; empty otherwise.",
45
+ )
46
+ locked: bool = Field(
47
+ default=False,
48
+ description="A person locked the conversation: no agent replies, whatever the owner kind.",
49
+ )
50
+ reason: str | None = None
51
+
52
+ @property
53
+ def priority(self) -> int:
54
+ return OWNER_PRIORITY[self.owner_kind] + (10 if self.locked else 0)
55
+
56
+ @property
57
+ def agents_may_reply(self) -> bool:
58
+ return self.owner_kind != OwnerKind.HUMAN and not self.locked
59
+
60
+ def may_be_taken_by(self, kind: OwnerKind, *, ref: str | None = None) -> bool:
61
+ """Whether a new owner of ``kind`` may take this conversation.
62
+
63
+ Equal rank may only re-take its own conversation (same ``ref``); a locked conversation is taken
64
+ only by a human.
65
+ """
66
+ if self.locked:
67
+ return kind == OwnerKind.HUMAN
68
+ if OWNER_PRIORITY[kind] > OWNER_PRIORITY[self.owner_kind]:
69
+ return True
70
+ return kind == self.owner_kind and (ref or None) == (self.owner_ref or None)
71
+
72
+
73
+ def ownership_from_event_payload(payload: Mapping[str, Any] | None) -> ConversationOwnership | None:
74
+ """Read ownership from an external-channel event payload.
75
+
76
+ Prefers the structured ``conversation_ownership`` object. Falls back to the keys older plugins send
77
+ (``ownership_state`` / ``owner_state`` / ``human_owned`` / ``reply_blocked``) so they keep working.
78
+ Returns ``None`` when the payload says nothing about ownership.
79
+ """
80
+ if not isinstance(payload, Mapping):
81
+ return None
82
+ structured = payload.get("conversation_ownership")
83
+ if isinstance(structured, Mapping):
84
+ return ConversationOwnership.model_validate(dict(structured))
85
+ state = str(payload.get("ownership_state") or payload.get("owner_state") or "").strip().lower()
86
+ human = bool(payload.get("human_owned")) or state in _LEGACY_HUMAN_STATES
87
+ if human:
88
+ return ConversationOwnership(
89
+ owner_kind=OwnerKind.HUMAN,
90
+ locked=state == "locked",
91
+ reason=str(payload.get("block_reason") or "") or None,
92
+ )
93
+ if state or "reply_blocked" in payload:
94
+ return ConversationOwnership(owner_kind=OwnerKind.CUSTOMER_SERVICE)
95
+ return None
@@ -284,3 +284,13 @@ def test_resource_input_requires_world_resource_origin():
284
284
  "accepted_origins": ["current_user"],
285
285
  }
286
286
  )
287
+
288
+
289
+ def test_external_domain_is_part_of_the_stable_registry() -> None:
290
+ from nutria_plugin import CAPABILITY_DOMAIN_IDS, DOMAIN_LABELS
291
+
292
+ assert "external" in CAPABILITY_DOMAIN_IDS
293
+ assert DOMAIN_LABELS["external"] == "Servicios externos"
294
+ assert CapabilityDescriptor.model_validate(_capability(domains=["external"], **_safety_contracts())).domains == [
295
+ "external"
296
+ ]
@@ -0,0 +1,47 @@
1
+ import pytest
2
+
3
+ from nutria_plugin import ConversationOwnership, OwnerKind, ownership_from_event_payload
4
+
5
+
6
+ def test_structured_payload_is_read():
7
+ owner = ownership_from_event_payload(
8
+ {"conversation_ownership": {"owner_kind": "agent", "owner_ref": "lia", "locked": False}}
9
+ )
10
+ assert owner.owner_kind is OwnerKind.AGENT and owner.owner_ref == "lia"
11
+
12
+
13
+ @pytest.mark.parametrize(
14
+ "payload,locked",
15
+ [
16
+ ({"ownership_state": "human_owned", "reply_blocked": True}, False),
17
+ ({"owner_state": "locked"}, True),
18
+ ({"human_owned": True}, False),
19
+ ],
20
+ )
21
+ def test_legacy_keys_map_to_human(payload, locked):
22
+ owner = ownership_from_event_payload(payload)
23
+ assert owner.owner_kind is OwnerKind.HUMAN
24
+ assert owner.locked is locked
25
+
26
+
27
+ def test_unknown_or_silent_payloads():
28
+ assert ownership_from_event_payload(None) is None
29
+ assert ownership_from_event_payload({"preview": "hola"}) is None
30
+ assert ownership_from_event_payload({"ownership_state": "agent_owned"}).owner_kind is OwnerKind.CUSTOMER_SERVICE
31
+
32
+
33
+ def test_priority_and_locks():
34
+ customer_service = ConversationOwnership()
35
+ agent = ConversationOwnership(owner_kind=OwnerKind.AGENT, owner_ref="lia")
36
+ human = ConversationOwnership(owner_kind=OwnerKind.HUMAN, owner_ref="ana")
37
+ locked_agent = ConversationOwnership(owner_kind=OwnerKind.AGENT, owner_ref="lia", locked=True)
38
+
39
+ assert customer_service.may_be_taken_by(OwnerKind.AGENT, ref="lia")
40
+ assert not agent.may_be_taken_by(OwnerKind.CUSTOMER_SERVICE)
41
+ assert agent.may_be_taken_by(OwnerKind.AGENT, ref="lia")
42
+ assert not agent.may_be_taken_by(OwnerKind.AGENT, ref="marcos")
43
+ assert agent.may_be_taken_by(OwnerKind.HUMAN)
44
+ assert not human.may_be_taken_by(OwnerKind.AGENT, ref="lia")
45
+ assert not locked_agent.may_be_taken_by(OwnerKind.AGENT, ref="lia")
46
+ assert locked_agent.may_be_taken_by(OwnerKind.HUMAN)
47
+ assert not human.agents_may_reply and not locked_agent.agents_may_reply and agent.agents_may_reply
@@ -262,7 +262,7 @@ wheels = [
262
262
 
263
263
  [[package]]
264
264
  name = "nutria-plugin"
265
- version = "0.6.0"
265
+ version = "0.6.3"
266
266
  source = { editable = "." }
267
267
  dependencies = [
268
268
  { name = "cryptography" },
File without changes
File without changes