agentvault-hermes-plugin 0.9.34__py3-none-any.whl

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 (100) hide show
  1. agentvault_hermes/__init__.py +34 -0
  2. agentvault_hermes/_constants.py +76 -0
  3. agentvault_hermes/_dist.py +73 -0
  4. agentvault_hermes/_spike/__init__.py +1 -0
  5. agentvault_hermes/channel/__init__.py +59 -0
  6. agentvault_hermes/channel/a2a_founder.py +751 -0
  7. agentvault_hermes/channel/a2a_lifecycle.py +350 -0
  8. agentvault_hermes/channel/a2a_registry.py +419 -0
  9. agentvault_hermes/channel/abstention.py +176 -0
  10. agentvault_hermes/channel/attachment.py +329 -0
  11. agentvault_hermes/channel/context_refs.py +69 -0
  12. agentvault_hermes/channel/delivery_cadence.py +58 -0
  13. agentvault_hermes/channel/event_registry.py +134 -0
  14. agentvault_hermes/channel/file_send.py +406 -0
  15. agentvault_hermes/channel/file_send_failure.py +394 -0
  16. agentvault_hermes/channel/file_send_policy.py +1010 -0
  17. agentvault_hermes/channel/gateway_replies.py +226 -0
  18. agentvault_hermes/channel/inbox.py +1514 -0
  19. agentvault_hermes/channel/lifecycle.py +45 -0
  20. agentvault_hermes/channel/limited_chat.py +55 -0
  21. agentvault_hermes/channel/lock_file.py +134 -0
  22. agentvault_hermes/channel/loop_prevention.py +119 -0
  23. agentvault_hermes/channel/mention.py +391 -0
  24. agentvault_hermes/channel/one_to_one_welcome.py +1016 -0
  25. agentvault_hermes/channel/outbox.py +195 -0
  26. agentvault_hermes/channel/replay_holds.py +154 -0
  27. agentvault_hermes/channel/room_directory.py +306 -0
  28. agentvault_hermes/channel/secure_channel.py +7078 -0
  29. agentvault_hermes/channel/telemetry.py +98 -0
  30. agentvault_hermes/channel/turn_failure.py +725 -0
  31. agentvault_hermes/channel/turn_token.py +134 -0
  32. agentvault_hermes/channel/welcome_kp_backoff.py +203 -0
  33. agentvault_hermes/cli/__init__.py +1 -0
  34. agentvault_hermes/cli/__main__.py +215 -0
  35. agentvault_hermes/cli/doctor.py +641 -0
  36. agentvault_hermes/cli/preflight.py +83 -0
  37. agentvault_hermes/cli/setup.py +836 -0
  38. agentvault_hermes/core/__init__.py +1 -0
  39. agentvault_hermes/core/config/__init__.py +25 -0
  40. agentvault_hermes/core/config/account.py +62 -0
  41. agentvault_hermes/core/config/data_dir.py +79 -0
  42. agentvault_hermes/core/config/migration.py +87 -0
  43. agentvault_hermes/core/detection/__init__.py +17 -0
  44. agentvault_hermes/core/detection/hermes.py +73 -0
  45. agentvault_hermes/core/detection/openclaw.py +61 -0
  46. agentvault_hermes/core/gateway_venv.py +374 -0
  47. agentvault_hermes/core/hermes_core.py +156 -0
  48. agentvault_hermes/core/identity/__init__.py +25 -0
  49. agentvault_hermes/core/identity/activation_proof.py +45 -0
  50. agentvault_hermes/core/identity/credentials.py +138 -0
  51. agentvault_hermes/core/identity/device.py +45 -0
  52. agentvault_hermes/core/identity/enrollment_payload.py +87 -0
  53. agentvault_hermes/core/install_check.py +146 -0
  54. agentvault_hermes/core/service_path_health.py +122 -0
  55. agentvault_hermes/core/transport/__init__.py +19 -0
  56. agentvault_hermes/core/transport/client_version.py +92 -0
  57. agentvault_hermes/core/transport/relay.py +274 -0
  58. agentvault_hermes/core/transport/rest_client.py +764 -0
  59. agentvault_hermes/core/transport/ws_client.py +270 -0
  60. agentvault_hermes/crypto/__init__.py +38 -0
  61. agentvault_hermes/crypto/mls_group.py +1386 -0
  62. agentvault_hermes/crypto/persistence.py +225 -0
  63. agentvault_hermes/crypto/primitives.py +112 -0
  64. agentvault_hermes/crypto/ratchet.py +1044 -0
  65. agentvault_hermes/crypto/x3dh.py +99 -0
  66. agentvault_hermes/history/__init__.py +30 -0
  67. agentvault_hermes/history/client.py +486 -0
  68. agentvault_hermes/history/crypto.py +251 -0
  69. agentvault_hermes/history/models.py +172 -0
  70. agentvault_hermes/history/recovery_file.py +57 -0
  71. agentvault_hermes/history/scheduler.py +140 -0
  72. agentvault_hermes/history/store.py +668 -0
  73. agentvault_hermes/plugins/__init__.py +0 -0
  74. agentvault_hermes/plugins/agentvault/__init__.py +530 -0
  75. agentvault_hermes/plugins/agentvault/adapter.py +2386 -0
  76. agentvault_hermes/plugins/agentvault/limited_turns.py +275 -0
  77. agentvault_hermes/plugins/agentvault/plugin.yaml +7 -0
  78. agentvault_hermes/plugins/agentvault/shutdown_notice.py +198 -0
  79. agentvault_hermes/plugins/agentvault/tools/__init__.py +26 -0
  80. agentvault_hermes/plugins/agentvault/tools/_messages.py +108 -0
  81. agentvault_hermes/plugins/agentvault/tools/_register.py +505 -0
  82. agentvault_hermes/plugins/agentvault/tools/discover.py +87 -0
  83. agentvault_hermes/plugins/agentvault/tools/initiate.py +144 -0
  84. agentvault_hermes/plugins/agentvault/tools/message.py +65 -0
  85. agentvault_hermes/plugins/agentvault/tools/send_file.py +29 -0
  86. agentvault_hermes/telemetry/__init__.py +0 -0
  87. agentvault_hermes/telemetry/cost/LICENSE.vendor +21 -0
  88. agentvault_hermes/telemetry/cost/VENDOR.md +20 -0
  89. agentvault_hermes/telemetry/cost/__init__.py +46 -0
  90. agentvault_hermes/telemetry/cost/db.py +736 -0
  91. agentvault_hermes/telemetry/cost/emitter.py +77 -0
  92. agentvault_hermes/telemetry/cost/flusher.py +143 -0
  93. agentvault_hermes/telemetry/cost/hooks.py +292 -0
  94. agentvault_hermes/telemetry/cost/pricing.py +398 -0
  95. agentvault_hermes/telemetry/cost/pricing_refresh.py +408 -0
  96. agentvault_hermes/telemetry/tool_spans.py +270 -0
  97. agentvault_hermes_plugin-0.9.34.dist-info/METADATA +288 -0
  98. agentvault_hermes_plugin-0.9.34.dist-info/RECORD +100 -0
  99. agentvault_hermes_plugin-0.9.34.dist-info/WHEEL +4 -0
  100. agentvault_hermes_plugin-0.9.34.dist-info/entry_points.txt +5 -0
@@ -0,0 +1,34 @@
1
+ """agentvault-hermes — native AgentVault plugin for Hermes."""
2
+
3
+ from importlib.metadata import PackageNotFoundError
4
+
5
+ from agentvault_hermes._dist import installed_version as _installed_version
6
+
7
+ # #781: DERIVED, never typed. This was a string literal that last moved at
8
+ # v0.7.9 while pyproject.toml went on to 0.9.6 — twelve releases of silent
9
+ # drift, silent because only one of the two was ever read.
10
+ #
11
+ # It is not a display value. `gateway_pip_target()` builds
12
+ # `agentvault-hermes-plugin[mls]=={__version__}`, and `cli/preflight.py` runs that
13
+ # before EVERY subcommand — so the stale literal made the self-heal downgrade
14
+ # each Hermes gateway venv twelve releases on every invocation. It also went
15
+ # out as the HTTP User-Agent (`rest_client.py`), so server-side telemetry and
16
+ # support both saw a build nobody was running.
17
+ #
18
+ # Reading it from installed metadata makes pyproject.toml the single source and
19
+ # removes the step a human has to remember at release time. Editable installs
20
+ # (`pip install -e`) carry metadata too, which is how the gateway venvs run.
21
+ #
22
+ # The distribution was renamed `agentvault-hermes` -> `agentvault-hermes-plugin`
23
+ # at 0.9.34. `_dist.installed_version()` asks for the new name, then the old
24
+ # one, so an install made before the rename still reports its real version.
25
+ try:
26
+ __version__ = _installed_version()
27
+ except PackageNotFoundError: # pragma: no cover - not installed (bare source tree)
28
+ # Deliberately NOT a plausible-looking version. This value flows into a pip
29
+ # pin, and an invalid one fails loudly at install time — which is strictly
30
+ # better than a real-looking number silently pinning the wrong release,
31
+ # the exact failure this constant already caused once.
32
+ __version__ = "0.0.0+unknown"
33
+
34
+ __all__ = ["__version__"]
@@ -0,0 +1,76 @@
1
+ """Package-level constants — leaf module with no transitive imports.
2
+
3
+ Importing this file MUST NOT trigger any chain that reaches Hermes runtime
4
+ modules (gateway.*, plugin __init__ adapters, etc.). That's the whole point:
5
+ the CLI (which doesn't have gateway available) and the plugin (which does)
6
+ both import from here without dragging the runtime in.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import os
11
+ from collections.abc import Mapping
12
+
13
+ # Toolset key registered with Hermes' ToolRegistry. Single source of truth.
14
+ # Consumed by:
15
+ # * agentvault_hermes/plugins/agentvault/tools/_register.py — registration
16
+ # * agentvault_hermes/cli/setup.py — _modify_hermes_global_config writes
17
+ # this value into ~/.hermes/config.yaml's platform_toolsets list
18
+ AV_TOOLSET_NAME = "hermes-agentvault"
19
+
20
+ # Canonical names of every AV tool the plugin DEFINES, in registration order.
21
+ # Not every one is OFFERED to the model by default — see
22
+ # ``AV_A2A_CHANNEL_TOOL_NAMES`` / ``offered_av_tool_names`` below. Lives in this
23
+ # gateway-free leaf so ``agentvault-hermes doctor`` can verify the tool surface
24
+ # from the CLI-only ``uv tool install`` venv — which has no Hermes ``gateway``
25
+ # runtime — without importing the gateway-dependent ``_register`` module.
26
+ # ``_register.py`` re-exports this and its ``_TOOLS`` table must match it
27
+ # (checked at gateway load); ``register_av_tools`` registers the subset that
28
+ # ``offered_av_tool_names`` returns.
29
+ AV_TOOL_NAMES: list[str] = [
30
+ "list_peers",
31
+ "find_agent",
32
+ "start_a2a_channel",
33
+ "send_a2a_message",
34
+ "invite_agent_to_channel",
35
+ # #1762 PR-H: send one file to the person in this 1:1 (never a room).
36
+ "agentvault_send_file",
37
+ ]
38
+
39
+
40
+ # Opt-in switch for the agent-to-agent CHANNEL tools.
41
+ #
42
+ # Why they are hidden by default (2026-10-26, live room "007"): at launch,
43
+ # agents talk to each other in ROOMS (1:1 or multi-party) and answer there with
44
+ # their normal reply. A2A channels are a separate, later feature. While the
45
+ # channel tools were offered, smartcode — asked a question in a room — called
46
+ # ``send_a2a_message`` with the ROOM's id, got ``mls_state_missing`` back, and
47
+ # then told the room so in its reply. Owners must never see internal codes, and
48
+ # a tool the agent should never use in a room is a tool it will eventually use
49
+ # in a room. So the code stays (it is the A2A feature, and resurrecting it is
50
+ # one env var), but the model is not offered it unless an operator opts in.
51
+ #
52
+ # The value is read once, when the Hermes gateway loads the plugin: changing it
53
+ # takes effect on the next gateway restart.
54
+ A2A_CHANNELS_ENV = "AGENTVAULT_A2A_CHANNELS"
55
+
56
+ #: The tools that exist only to open, invite into, or post on an A2A channel.
57
+ #: Hidden unless ``A2A_CHANNELS_ENV`` is truthy. ``list_peers`` / ``find_agent``
58
+ #: are discovery, not channel tools, and stay offered.
59
+ AV_A2A_CHANNEL_TOOL_NAMES: frozenset[str] = frozenset(
60
+ {"start_a2a_channel", "send_a2a_message", "invite_agent_to_channel"}
61
+ )
62
+
63
+ _TRUTHY = frozenset({"1", "true", "yes", "on"})
64
+
65
+
66
+ def a2a_channels_enabled(environ: Mapping[str, str] | None = None) -> bool:
67
+ """True only when the operator explicitly opted in to the A2A channel tools."""
68
+ env = os.environ if environ is None else environ
69
+ return env.get(A2A_CHANNELS_ENV, "").strip().lower() in _TRUTHY
70
+
71
+
72
+ def offered_av_tool_names(environ: Mapping[str, str] | None = None) -> list[str]:
73
+ """The AV tools offered to the model, in registration order."""
74
+ if a2a_channels_enabled(environ):
75
+ return list(AV_TOOL_NAMES)
76
+ return [name for name in AV_TOOL_NAMES if name not in AV_A2A_CHANNEL_TOOL_NAMES]
@@ -0,0 +1,73 @@
1
+ """This package's distribution name on PyPI, and the name it used to have.
2
+
3
+ The import package (``agentvault_hermes``) and the ``agentvault-hermes`` command
4
+ never changed. The *distribution* did: from 0.9.34 it is published as
5
+ ``agentvault-hermes-plugin``, because the PyPI project ``agentvault-hermes``
6
+ (last release 0.9.29) is stuck on an account nobody can sign in to.
7
+
8
+ An install made before the rename still carries ``agentvault-hermes`` metadata,
9
+ so every metadata lookup asks for the new name first and falls back to the old
10
+ one. Without the fallback an un-migrated install reads as "not installed":
11
+ ``__version__`` would become ``0.0.0+unknown`` and the pre-flight would treat
12
+ the CLI as a dev checkout and stop syncing the gateway venv.
13
+
14
+ Leaf module: imports nothing from this package, so ``agentvault_hermes/__init__``
15
+ can use it.
16
+ """
17
+ from __future__ import annotations
18
+
19
+ from importlib import metadata
20
+
21
+ #: The name new releases are published under (0.9.34 onward).
22
+ DIST_NAME = "agentvault-hermes-plugin"
23
+ #: The pre-rename name. Still on PyPI at 0.9.29; never published to again by us.
24
+ LEGACY_DIST_NAME = "agentvault-hermes"
25
+ #: Lookup order: the new name wins when both are installed.
26
+ DIST_NAMES = (DIST_NAME, LEGACY_DIST_NAME)
27
+
28
+ #: The upgrade step for a machine that still has the old distribution. Both
29
+ #: ship the same ``agentvault_hermes`` files, so they must not sit side by side:
30
+ #: uninstalling one deletes files the other needs, which is why the install
31
+ #: forces a reinstall rather than trusting "already satisfied".
32
+ MIGRATION_HINT = (
33
+ f"pip uninstall -y {LEGACY_DIST_NAME} && "
34
+ f'pip install --force-reinstall "{DIST_NAME}[mls]"'
35
+ )
36
+
37
+
38
+ def distribution() -> metadata.Distribution:
39
+ """The installed distribution, new name first. Raises
40
+ ``PackageNotFoundError`` when neither name is installed."""
41
+ for name in DIST_NAMES:
42
+ try:
43
+ return metadata.distribution(name)
44
+ except metadata.PackageNotFoundError:
45
+ continue
46
+ raise metadata.PackageNotFoundError(DIST_NAME)
47
+
48
+
49
+ def installed_version() -> str:
50
+ """The installed version, new name first. Raises ``PackageNotFoundError``
51
+ when neither name is installed."""
52
+ return str(distribution().version)
53
+
54
+
55
+ def legacy_installed() -> bool:
56
+ """True when the pre-rename ``agentvault-hermes`` distribution is visible
57
+ to this interpreter (alone or beside the new one)."""
58
+ try:
59
+ metadata.distribution(LEGACY_DIST_NAME)
60
+ except metadata.PackageNotFoundError:
61
+ return False
62
+ return True
63
+
64
+
65
+ __all__ = [
66
+ "DIST_NAME",
67
+ "DIST_NAMES",
68
+ "LEGACY_DIST_NAME",
69
+ "MIGRATION_HINT",
70
+ "distribution",
71
+ "installed_version",
72
+ "legacy_installed",
73
+ ]
@@ -0,0 +1 @@
1
+ """Spike sandbox for Phase 0 mls-rs validation. Removed at Phase 1 start."""
@@ -0,0 +1,59 @@
1
+ """``agentvault_hermes.channel`` — channel orchestrator + wire envelope.
2
+
3
+ Phase 3 (WS-28..WS-35) lives here. WS-33 landed the outbound wire envelope
4
+ (``outbox`` module). WS-28a added the verbatim-from-OC primitives:
5
+ ``loop_prevention`` (per-key reply rate limiter) and ``lock_file`` (A2A
6
+ sync lock). WS-28b added ``secure_channel`` (the SecureChannel
7
+ orchestrator + ``InboundMessage`` dataclass). WS-30 lands ``inbox``
8
+ (inbound dispatch + decrypt) and ``mention`` (room-message routing
9
+ helpers).
10
+ """
11
+ from agentvault_hermes.channel.abstention import (
12
+ INSTRUCTION as ABSTENTION_INSTRUCTION,
13
+ )
14
+ from agentvault_hermes.channel.abstention import (
15
+ SENTINEL as ABSTENTION_SENTINEL,
16
+ )
17
+ from agentvault_hermes.channel.abstention import (
18
+ is_abstention,
19
+ )
20
+ from agentvault_hermes.channel.inbox import (
21
+ handle_message_dr,
22
+ handle_message_mls,
23
+ )
24
+ from agentvault_hermes.channel.lock_file import (
25
+ acquire_a2a_sync_lock,
26
+ release_a2a_sync_lock,
27
+ )
28
+ from agentvault_hermes.channel.loop_prevention import LoopPreventer
29
+ from agentvault_hermes.channel.mention import (
30
+ owes_room_reply,
31
+ parse_mentions,
32
+ strip_mentions,
33
+ )
34
+ from agentvault_hermes.channel.outbox import (
35
+ WireEnvelope,
36
+ make_outbound_mls_envelope,
37
+ )
38
+ from agentvault_hermes.channel.secure_channel import (
39
+ InboundMessage,
40
+ SecureChannel,
41
+ )
42
+
43
+ __all__ = [
44
+ "ABSTENTION_INSTRUCTION",
45
+ "ABSTENTION_SENTINEL",
46
+ "InboundMessage",
47
+ "LoopPreventer",
48
+ "SecureChannel",
49
+ "WireEnvelope",
50
+ "acquire_a2a_sync_lock",
51
+ "handle_message_dr",
52
+ "handle_message_mls",
53
+ "is_abstention",
54
+ "make_outbound_mls_envelope",
55
+ "owes_room_reply",
56
+ "parse_mentions",
57
+ "release_a2a_sync_lock",
58
+ "strip_mentions",
59
+ ]