kimi-agent-module-api 1.0.0__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.
@@ -0,0 +1,63 @@
1
+ """The LLM-tool surface: what a module registers at load and what a handler receives."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable, Coroutine, Mapping
6
+ from dataclasses import dataclass, field
7
+ from typing import Any, Protocol
8
+
9
+ from kimi_agent_module_api.trust import TrustTier
10
+
11
+
12
+ @dataclass(frozen=True, slots=True)
13
+ class ModuleToolContext:
14
+ """Who is calling a module tool, and from where.
15
+
16
+ Ids are Discord snowflakes as ``int``, matching every other SDK type.
17
+ ``guild_id`` is ``None`` only for a tool registered with
18
+ ``guild_only=False`` and called from a DM or personal chat; the host hides
19
+ guild-only tools there. When ``guild_id`` is set, the host has already
20
+ confirmed the module is active in that guild. ``channel_id`` is ``None``
21
+ in personal chat, which is a slash interaction rather than a channel.
22
+ """
23
+
24
+ user_id: int
25
+ user_name: str
26
+ guild_id: int | None
27
+ channel_id: int | None
28
+ thread_id: int | None
29
+ trust_tier: TrustTier
30
+ # Operator per-tool configuration from ``<CONFIG_DIR>/tools/<tool>.md``.
31
+ tool_configs: Mapping[str, Mapping[str, Any]] = field(default_factory=dict)
32
+
33
+
34
+ type ModuleToolHandler = Callable[[dict[str, Any], ModuleToolContext], Coroutine[Any, Any, str]]
35
+
36
+
37
+ class ModuleToolRegistry(Protocol):
38
+ """Tool registration supported by every compatible host.
39
+
40
+ Valid only inside ``ModuleSpec.create``; the host seals it afterwards.
41
+ ``searchable`` tools stay hidden until the model activates them with
42
+ ``browse_tools``. A tool is visible only where its module is active; with
43
+ ``guild_only`` (the default) it is also hidden from DMs and personal chat,
44
+ so its handler always sees a guild. ``guild_ids`` further scopes a tool to
45
+ specific guilds (``None`` is everywhere; an empty set is nowhere).
46
+ """
47
+
48
+ def register(
49
+ self,
50
+ name: str,
51
+ description: str,
52
+ parameters: dict[str, Any],
53
+ handler: ModuleToolHandler,
54
+ *,
55
+ min_tier: TrustTier = TrustTier.MEMBER,
56
+ searchable: bool = False,
57
+ owner_only: bool = False,
58
+ guild_only: bool = True,
59
+ guild_ids: frozenset[int] | None = None,
60
+ ) -> None: ...
61
+
62
+
63
+ __all__ = ["ModuleToolContext", "ModuleToolHandler", "ModuleToolRegistry"]
@@ -0,0 +1,36 @@
1
+ """Trust tiers shared by module declarations and the host runtime."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import Enum
6
+
7
+ _TIER_ORDER = {"member": 0, "regular": 1, "staff": 2}
8
+
9
+
10
+ class TrustTier(Enum):
11
+ STAFF = "staff"
12
+ REGULAR = "regular"
13
+ MEMBER = "member"
14
+
15
+ def __ge__(self, other: object) -> bool:
16
+ if not isinstance(other, TrustTier):
17
+ return NotImplemented
18
+ return _TIER_ORDER[self.value] >= _TIER_ORDER[other.value]
19
+
20
+ def __gt__(self, other: object) -> bool:
21
+ if not isinstance(other, TrustTier):
22
+ return NotImplemented
23
+ return _TIER_ORDER[self.value] > _TIER_ORDER[other.value]
24
+
25
+ def __le__(self, other: object) -> bool:
26
+ if not isinstance(other, TrustTier):
27
+ return NotImplemented
28
+ return _TIER_ORDER[self.value] <= _TIER_ORDER[other.value]
29
+
30
+ def __lt__(self, other: object) -> bool:
31
+ if not isinstance(other, TrustTier):
32
+ return NotImplemented
33
+ return _TIER_ORDER[self.value] < _TIER_ORDER[other.value]
34
+
35
+
36
+ __all__ = ["TrustTier"]
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: kimi-agent-module-api
3
+ Version: 1.0.0
4
+ Summary: Stable contracts for community-built assistant modules
5
+ Author: Webhead
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://github.com/webhead2oo9/kimi-agent/blob/main/docs/modules.md
8
+ Project-URL: Issues, https://github.com/webhead2oo9/kimi-agent/issues
9
+ Project-URL: Repository, https://github.com/webhead2oo9/kimi-agent
10
+ Requires-Python: >=3.14
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pydantic-settings>=2.14.2
14
+ Provides-Extra: testing
15
+ Requires-Dist: aiosqlite; extra == "testing"
16
+ Dynamic: license-file
17
+
18
+ # Kimi Agent Module API
19
+
20
+ The stable, host-independent contracts for building Kimi application modules:
21
+ separately installed packages that add commands, LLM tools, background jobs,
22
+ event handlers, per-guild settings, and durable data to a Kimi deployment.
23
+
24
+ This package contains no bot runtime, Discord client, database
25
+ implementation, or module loader. It exports:
26
+
27
+ - `ModuleSpec`, `ModuleLoadContext`, `ModuleRuntimeContext`: the declaration a
28
+ module publishes and the two contexts the host hands it.
29
+ - `kimi_agent_module_api.contracts`: every runtime port as a `typing.Protocol`
30
+ (storage, scheduler, events, Discord actions, interactions, HTTP, services,
31
+ trust, proposals, health) plus the validators the host runs at preflight.
32
+ - `kimi_agent_module_api.events`: the normalized `discord.*` event payloads.
33
+ - `kimi_agent_module_api.testing`: a fake for every port, `load_context()` for
34
+ exercising `create()`, and `MemoryStorage` (install the `testing` extra) so a
35
+ module can unit test itself with only this package installed.
36
+
37
+ A module exposes a `ModuleSpec` through the `kimi_agent.modules` entry-point
38
+ group:
39
+
40
+ ```toml
41
+ [project]
42
+ dependencies = ["kimi-agent-module-api>=1,<2"]
43
+
44
+ [project.entry-points."kimi_agent.modules"]
45
+ my_module = "my_module_package:SPEC"
46
+ ```
47
+
48
+ The [module guide](https://github.com/webhead2oo9/kimi-agent/blob/main/docs/modules.md)
49
+ documents installation, declarations, lifecycle, and every runtime port. The
50
+ [reference module](https://github.com/webhead2oo9/kimi-agent/tree/main/bot/modules/example)
51
+ is a complete, commented example that exercises every port; start there.
@@ -0,0 +1,14 @@
1
+ kimi_agent_module_api/__init__.py,sha256=SnlPlbkJGhLInzqnTZGO-j-WfI8GCHo1fDviNZAnd5o,5435
2
+ kimi_agent_module_api/contracts.py,sha256=y-Epb_IivNO7DbCQuAoenjK59y5rkzQNVch3P5hQ7DI,36247
3
+ kimi_agent_module_api/events.py,sha256=0O6KyXgO3Pt-lLczySnfH7Oz0NS-wcD73UIQItgYUWk,3835
4
+ kimi_agent_module_api/images.py,sha256=eC-HYBxL-3oTSQFtCY9suaacCMdKeY0SIhIjXviXJmU,1256
5
+ kimi_agent_module_api/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
6
+ kimi_agent_module_api/settings.py,sha256=B_C8erjC3xiVAt-Dsa_pzJup0sdH6crukRPoI0Dy3AA,784
7
+ kimi_agent_module_api/testing.py,sha256=3xm71UNapomQcnl7yoeWCrO5n5CcbdnwzAdJG6WoqTQ,34142
8
+ kimi_agent_module_api/tools.py,sha256=IrhxJCY1G78-82Rqr45m2GypdDy_yFNlaUUR4yKRQ0I,2288
9
+ kimi_agent_module_api/trust.py,sha256=JbIwBy6c1osBkdLT0si3hjsjfnLfhaZwlacsI_-xuS8,1067
10
+ kimi_agent_module_api-1.0.0.dist-info/licenses/LICENSE,sha256=uYrNYbmEjOZrEU64qvFgrljmosb1-bUKnE9fa9pMuSY,1064
11
+ kimi_agent_module_api-1.0.0.dist-info/METADATA,sha256=-X5pYh8Tro6Hg36XfcOQyywCR09U4CiBIdKo48On9yo,2226
12
+ kimi_agent_module_api-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
13
+ kimi_agent_module_api-1.0.0.dist-info/top_level.txt,sha256=kOf2Pv96Xa3yE4NUlKxGvvEVKw_-b_ARe9e7OVk-_j0,22
14
+ kimi_agent_module_api-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Webhead
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.
@@ -0,0 +1 @@
1
+ kimi_agent_module_api