zettcode-sdk 0.4.0__tar.gz → 0.4.1__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 (31) hide show
  1. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/PKG-INFO +1 -1
  2. zettcode_sdk-0.4.1/pyproject.toml +71 -0
  3. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/builtins.py +46 -8
  4. zettcode_sdk-0.4.0/pyproject.toml +0 -45
  5. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/.gitignore +0 -0
  6. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/__init__.py +0 -0
  7. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/__main__.py +0 -0
  8. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/cli.py +0 -0
  9. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/companions.py +0 -0
  10. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/process.py +0 -0
  11. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/run.py +0 -0
  12. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/daemon/state.py +0 -0
  13. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/doctor.py +0 -0
  14. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/mentions.py +0 -0
  15. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/__init__.py +0 -0
  16. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/client.py +0 -0
  17. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/commands.py +0 -0
  18. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/daemons.py +0 -0
  19. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/errors.py +0 -0
  20. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/events.py +0 -0
  21. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/extensions/__init__.py +0 -0
  22. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/extensions/mcp.py +0 -0
  23. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/extensions/messaging.py +0 -0
  24. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/handlers.py +0 -0
  25. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/messenger.py +0 -0
  26. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/models.py +0 -0
  27. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/py.typed +0 -0
  28. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/session.py +0 -0
  29. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/translation.py +0 -0
  30. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/sdk/types.py +0 -0
  31. {zettcode_sdk-0.4.0 → zettcode_sdk-0.4.1}/src/zettcode/table.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: zettcode-sdk
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: The documented, stable Python surface over ZettCode: sessions, runs, models, daemons
5
5
  Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
6
6
  Author: Chang-LeHung
@@ -0,0 +1,71 @@
1
+ [project]
2
+ name = "zettcode-sdk"
3
+ description = "The documented, stable Python surface over ZettCode: sessions, runs, models, daemons"
4
+ requires-python = ">=3.10"
5
+ dynamic = ["version"]
6
+ license = "MIT"
7
+ authors = [{name = "Chang-LeHung"}]
8
+ keywords = ["zettcode", "sdk", "agent"]
9
+ classifiers = [
10
+ "Development Status :: 5 - Production/Stable",
11
+ "Programming Language :: Python :: 3.10",
12
+ "Programming Language :: Python :: 3.11",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Programming Language :: Python :: 3.15",
17
+ "Typing :: Typed",
18
+ ]
19
+ dependencies = [
20
+ "zettcode-engine",
21
+ "zettcode-broker",
22
+ "zett-agent>=0.2.7,<0.3",
23
+ "httpx>=0.27,<1",
24
+ ]
25
+
26
+ # The plugins that compose the agent. A part of the program, not a plugin: the `zettcode.plugins` group is what the
27
+ # plugin release line looks for. They are activated by the rank `builtins.py` gives them, then by their `deps`.
28
+ [project.entry-points."zettcode.agent"]
29
+ skills = "zettcode.sdk.builtins:SkillResources"
30
+ files = "zettcode.sdk.builtins:FileResources"
31
+ coding = "zettcode.sdk.builtins:CodingTools"
32
+ tool-output = "zettcode.sdk.builtins:ToolOutput"
33
+ long-output = "zettcode.sdk.builtins:LongOutput"
34
+ capabilities = "zettcode.sdk.builtins:Capabilities"
35
+ subagents = "zettcode.sdk.builtins:Subagents"
36
+ messaging = "zettcode.sdk.builtins:Messaging"
37
+ shell-permission = "zettcode.sdk.builtins:ShellPermission"
38
+ harness = "zettcode.sdk.builtins:Harness"
39
+ session-log = "zettcode.sdk.builtins:SessionLog"
40
+ todos = "zettcode.sdk.builtins:TodoPlan"
41
+ usage-tracking = "zettcode.sdk.builtins:UsageTracking"
42
+ context-tracking = "zettcode.sdk.builtins:ContextTracking"
43
+ side-questions = "zettcode.sdk.builtins:SideQuestionBoundary"
44
+ tool-guidelines = "zettcode.sdk.builtins:ToolGuidance"
45
+ ask-user = "zettcode.sdk.builtins:AskUser"
46
+ project-instructions = "zettcode.sdk.builtins:ProjectInstructions"
47
+ skill-tool = "zettcode.sdk.builtins:SkillTool"
48
+ mcp = "zettcode.sdk.builtins:McpTools"
49
+ self-compaction = "zettcode.sdk.builtins:SelfCompaction"
50
+ compaction = "zettcode.sdk.builtins:Compaction"
51
+
52
+ [project.urls]
53
+ Repository = "https://github.com/Chang-LeHung/zettcode"
54
+
55
+ [build-system]
56
+ requires = ["hatchling"]
57
+ build-backend = "hatchling.build"
58
+
59
+ [tool.hatch.version]
60
+ # One version for the whole repository: the engine ships the file.
61
+ path = "../zettcode-engine/src/zettcode/version.py"
62
+
63
+ [tool.hatch.build.targets.wheel]
64
+ packages = ["src/zettcode"]
65
+
66
+ [tool.hatch.build.targets.sdist]
67
+ include = ["/src", "/pyproject.toml"]
68
+
69
+ [tool.pytest.ini_options]
70
+ testpaths = ["tests"]
71
+ asyncio_mode = "auto"
@@ -16,15 +16,17 @@ Two rules decide how one registers:
16
16
  as a service by name, and the runtime reads it from there instead of keeping a field for it.
17
17
 
18
18
  The order of :data:`AGENT_PLUGINS` is the order the agent receives the extensions in; extensions that share a
19
- priority keep it, so it is the order they were listed in when the runtime did the listing. What a plugin
20
- builds on (the session store, the permission policy) is handed over by the runtime by name, see
19
+ priority keep it. The loader finds the plugins through the ``zettcode.agent`` entry-point group this package
20
+ publishes and activates them by the rank that list gives them (``Plugin.rank``), then by their ``deps``: what one
21
+ reads from another, such as the capabilities the subagents are sized by, is a ``deps`` entry and not a position. What
22
+ a plugin builds on (the session store, the permission policy) is handed over by the runtime by name, see
21
23
  :mod:`zettcode.engine.plugins.services`.
22
24
  """
23
25
 
24
26
  from __future__ import annotations
25
27
 
26
28
  from collections.abc import Callable
27
- from typing import TYPE_CHECKING
29
+ from typing import TYPE_CHECKING, TypeVar
28
30
 
29
31
  from zettcode.config import ModelConfig
30
32
  from zettcode.engine.dialogue.side import SideQuestions
@@ -70,6 +72,8 @@ if TYPE_CHECKING: # pragma: no cover - annotations only
70
72
  from zettcode.engine.plugins import Plugins
71
73
  from zettcode.engine.plugins.state import AgentBuild
72
74
 
75
+ _P = TypeVar("_P", bound="Plugins")
76
+
73
77
 
74
78
  class SkillResources(Plugin):
75
79
  """The builtin ``@`` resource provider: the skills on this machine.
@@ -167,6 +171,8 @@ class Subagents(Plugin):
167
171
 
168
172
  name = "subagents"
169
173
  description = "The task tool and its profiles"
174
+ # Reads the capabilities the plugin below provides, so it is activated after it whatever their ranks say.
175
+ deps = ("capabilities",)
170
176
  setting = PluginSetting("subagent_enabled", "harness", "subagent")
171
177
 
172
178
  def activate(self, ctx: PluginContext) -> None:
@@ -569,7 +575,10 @@ class Compaction(Plugin):
569
575
  ctx.agent.register_extension(compaction)
570
576
 
571
577
 
572
- #: The agent-side plugins in the order the agent receives their extensions.
578
+ #: The agent-side plugins in the order the agent receives their extensions. The distribution publishes the same list as
579
+ #: entry points (``zettcode.agent`` in this package's ``pyproject.toml``) and the loader reads it from there; this tuple
580
+ #: is what gives each its rank, and what a caller that loads without discovering (a test, a checkout with no installed
581
+ #: distribution) passes as ``builtins=``. ``test_agent_parts.py`` holds the two lists together.
573
582
  AGENT_PLUGINS: tuple[Plugin[PluginContext], ...] = (
574
583
  SkillResources(),
575
584
  FileResources(),
@@ -595,14 +604,43 @@ AGENT_PLUGINS: tuple[Plugin[PluginContext], ...] = (
595
604
  Compaction(),
596
605
  )
597
606
 
607
+ for _rank, _plugin in enumerate(AGENT_PLUGINS):
608
+ # One list is the order; the rank is read from it, so there is no second number to keep in step by hand.
609
+ type(_plugin).rank = _rank
610
+ # The rank lives on the class, so a class listed twice would take the last index for both.
611
+ assert len({type(plugin) for plugin in AGENT_PLUGINS}) == len(AGENT_PLUGINS), "AGENT_PLUGINS lists a class twice"
612
+
613
+ #: The names of those plugins, which the program cannot run without.
614
+ AGENT_PLUGIN_NAMES: tuple[str, ...] = tuple(plugin.name for plugin in AGENT_PLUGINS)
615
+
616
+
617
+ def require_agent_parts(plugins: _P) -> _P:
618
+ """Return ``plugins``, or raise when the plugins that compose the agent were not found at all.
619
+
620
+ A failure to activate one is recorded in ``failed`` as it always was; what is refused here is an installation that
621
+ has none of them to activate, which would start an agent with no tools, no session log and no compaction.
622
+
623
+ Raises:
624
+ RequiredPluginError: One of :data:`AGENT_PLUGIN_NAMES` neither loaded nor failed.
625
+ """
626
+ from zettcode.engine.plugins.loader import RequiredPluginError
627
+
628
+ # Keyed on where a plugin came from and not on what it calls itself: ``builtins`` holds the origin of every plugin
629
+ # the program published, loaded or not, and a stranger that names itself ``mcp`` is not among them.
630
+ seen = set(plugins.builtins)
631
+ missing = {name: "not installed" for name in AGENT_PLUGIN_NAMES if name not in seen}
632
+ if missing:
633
+ raise RequiredPluginError(missing)
634
+ return plugins
635
+
598
636
 
599
637
  def load_agent_plugins(config: ZettCodeConfig, shared: Mapping[str, object]) -> Plugins:
600
- """Load these builtins, plus the distributions a reader enabled: the loader a runtime is built with.
638
+ """Load the agent's plugins and the distributions a reader enabled: the loader a runtime is built with.
601
639
 
602
- The engine's own default loads the installed plugins and no built-in at all, because the engine does not ship
603
- this list. Whoever builds the runtime says which agent it wants: the SDK passes this, and the terminal passes
640
+ The engine's own default loads the installed plugins and none of the agent's, because the engine does not ship
641
+ them. Whoever builds the runtime says which agent it wants: the SDK passes this, and the terminal passes
604
642
  :func:`zettcode.app.plugins.loader.terminal_plugins`, which adds the plugins only a screen can hold.
605
643
  """
606
644
  from zettcode.engine.plugins import load_plugins
607
645
 
608
- return load_plugins(config, builtins=AGENT_PLUGINS, shared=shared)
646
+ return require_agent_parts(load_plugins(config, builtins=(), shared=shared))
@@ -1,45 +0,0 @@
1
- [project]
2
- name = "zettcode-sdk"
3
- description = "The documented, stable Python surface over ZettCode: sessions, runs, models, daemons"
4
- requires-python = ">=3.10"
5
- dynamic = ["version"]
6
- license = "MIT"
7
- authors = [{name = "Chang-LeHung"}]
8
- keywords = ["zettcode", "sdk", "agent"]
9
- classifiers = [
10
- "Development Status :: 5 - Production/Stable",
11
- "Programming Language :: Python :: 3.10",
12
- "Programming Language :: Python :: 3.11",
13
- "Programming Language :: Python :: 3.12",
14
- "Programming Language :: Python :: 3.13",
15
- "Programming Language :: Python :: 3.14",
16
- "Programming Language :: Python :: 3.15",
17
- "Typing :: Typed",
18
- ]
19
- dependencies = [
20
- "zettcode-engine",
21
- "zettcode-broker",
22
- "zett-agent>=0.2.7,<0.3",
23
- "httpx>=0.27,<1",
24
- ]
25
-
26
- [project.urls]
27
- Repository = "https://github.com/Chang-LeHung/zettcode"
28
-
29
- [build-system]
30
- requires = ["hatchling"]
31
- build-backend = "hatchling.build"
32
-
33
- [tool.hatch.version]
34
- # One version for the whole repository: the engine ships the file.
35
- path = "../zettcode-engine/src/zettcode/version.py"
36
-
37
- [tool.hatch.build.targets.wheel]
38
- packages = ["src/zettcode"]
39
-
40
- [tool.hatch.build.targets.sdist]
41
- include = ["/src", "/pyproject.toml"]
42
-
43
- [tool.pytest.ini_options]
44
- testpaths = ["tests"]
45
- asyncio_mode = "auto"
File without changes