zettcode-engine 0.3.4__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.
- zettcode_engine-0.3.4/.gitignore +37 -0
- zettcode_engine-0.3.4/PKG-INFO +23 -0
- zettcode_engine-0.3.4/pyproject.toml +56 -0
- zettcode_engine-0.3.4/src/zettcode/_compat.py +35 -0
- zettcode_engine-0.3.4/src/zettcode/budget.py +24 -0
- zettcode_engine-0.3.4/src/zettcode/config.py +1088 -0
- zettcode_engine-0.3.4/src/zettcode/config_edit.py +457 -0
- zettcode_engine-0.3.4/src/zettcode/engine/__init__.py +39 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/__init__.py +81 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/base.py +60 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/context.py +166 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/exports.py +73 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/interaction.py +54 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/sessions.py +218 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/settings.py +269 -0
- zettcode_engine-0.3.4/src/zettcode/engine/agent/turns.py +308 -0
- zettcode_engine-0.3.4/src/zettcode/engine/core.py +819 -0
- zettcode_engine-0.3.4/src/zettcode/engine/dialogue/__init__.py +6 -0
- zettcode_engine-0.3.4/src/zettcode/engine/dialogue/ask.py +113 -0
- zettcode_engine-0.3.4/src/zettcode/engine/dialogue/side.py +197 -0
- zettcode_engine-0.3.4/src/zettcode/engine/dialogue/title.py +80 -0
- zettcode_engine-0.3.4/src/zettcode/engine/export/__init__.py +421 -0
- zettcode_engine-0.3.4/src/zettcode/engine/export/trace/script.js +18 -0
- zettcode_engine-0.3.4/src/zettcode/engine/export/trace/style.css +136 -0
- zettcode_engine-0.3.4/src/zettcode/engine/export/trace/template.html +31 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/__init__.py +8 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/capabilities.py +68 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/compaction.py +259 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/context.py +521 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/files.py +101 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/guidance.py +17 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/harness.py +208 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/harness_switch.py +18 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/mcp_notice.py +49 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/relay.py +93 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/subagents.py +391 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/tool_output.py +153 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/truncation.py +156 -0
- zettcode_engine-0.3.4/src/zettcode/engine/extensions/usage.py +304 -0
- zettcode_engine-0.3.4/src/zettcode/engine/harness_paths.py +74 -0
- zettcode_engine-0.3.4/src/zettcode/engine/permission/__init__.py +197 -0
- zettcode_engine-0.3.4/src/zettcode/engine/permission/approval.py +66 -0
- zettcode_engine-0.3.4/src/zettcode/engine/permission/readonly.py +435 -0
- zettcode_engine-0.3.4/src/zettcode/engine/permission/sandbox.py +140 -0
- zettcode_engine-0.3.4/src/zettcode/engine/pipeline.py +191 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/__init__.py +72 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/commands.py +152 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/context.py +251 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/extension.py +183 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/groups.py +74 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/loader.py +367 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/mixins.py +156 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/plugin.py +190 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/services.py +68 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/settings.py +117 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/state.py +64 -0
- zettcode_engine-0.3.4/src/zettcode/engine/plugins/switches.py +553 -0
- zettcode_engine-0.3.4/src/zettcode/engine/py.typed +0 -0
- zettcode_engine-0.3.4/src/zettcode/engine/server_tools.py +179 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/__init__.py +51 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/layout.py +161 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/ledger.py +659 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/locks.py +182 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/metadata.py +278 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/records.py +373 -0
- zettcode_engine-0.3.4/src/zettcode/engine/storage/store.py +1056 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/__init__.py +7 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/boundary.py +56 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/files.py +262 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/images.py +32 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/output.py +81 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/shell.py +181 -0
- zettcode_engine-0.3.4/src/zettcode/engine/tools/workspace.py +271 -0
- zettcode_engine-0.3.4/src/zettcode/error_text.py +217 -0
- zettcode_engine-0.3.4/src/zettcode/filelock.py +125 -0
- zettcode_engine-0.3.4/src/zettcode/logging_setup.py +196 -0
- zettcode_engine-0.3.4/src/zettcode/mention.py +124 -0
- zettcode_engine-0.3.4/src/zettcode/modes.py +18 -0
- zettcode_engine-0.3.4/src/zettcode/paths.py +113 -0
- zettcode_engine-0.3.4/src/zettcode/plugin_tui.py +133 -0
- zettcode_engine-0.3.4/src/zettcode/processes.py +126 -0
- zettcode_engine-0.3.4/src/zettcode/prompt.py +94 -0
- zettcode_engine-0.3.4/src/zettcode/providers.py +215 -0
- zettcode_engine-0.3.4/src/zettcode/py.typed +0 -0
- zettcode_engine-0.3.4/src/zettcode/registry.py +63 -0
- zettcode_engine-0.3.4/src/zettcode/relay.py +267 -0
- zettcode_engine-0.3.4/src/zettcode/statusline_parts.py +84 -0
- zettcode_engine-0.3.4/src/zettcode/version.py +11 -0
- zettcode_engine-0.3.4/src/zettcode/wire.py +30 -0
- zettcode_engine-0.3.4/src/zettcode/wording.py +11 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
**/.venv/
|
|
2
|
+
**/__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.smoke/
|
|
8
|
+
.coverage
|
|
9
|
+
**/.pytest_cache/
|
|
10
|
+
**/.ruff_cache/
|
|
11
|
+
.zett-tool-output/
|
|
12
|
+
.env
|
|
13
|
+
.DS_Store
|
|
14
|
+
|
|
15
|
+
# viztracer writes its trace here by default.
|
|
16
|
+
/result.json
|
|
17
|
+
|
|
18
|
+
# The docs site: dependencies, build output, and VitePress' cache.
|
|
19
|
+
node_modules/
|
|
20
|
+
docs/.vitepress/dist/
|
|
21
|
+
docs/.vitepress/cache/
|
|
22
|
+
docs/.vitepress/.temp/
|
|
23
|
+
|
|
24
|
+
# The TypeScript client is built from its sources; only dist/ is published.
|
|
25
|
+
clients/typescript/dist/
|
|
26
|
+
|
|
27
|
+
# The gateway's page is built from clients/gateway into the package when a distribution is made (`make gateway-ui`);
|
|
28
|
+
# the build output is not kept in the repository. pyproject's `artifacts` puts it in the wheel all the same.
|
|
29
|
+
packages/zettcode-gateway/src/zettcode/gateway/static/
|
|
30
|
+
|
|
31
|
+
# The palette gallery is generated by `make palettes`: every widget painted in
|
|
32
|
+
# every palette, written by docs/scripts/palette_gallery.py. Regenerate it
|
|
33
|
+
# rather than committing a 2 MB copy that goes stale the moment a colour moves.
|
|
34
|
+
docs/internal/palettes.html
|
|
35
|
+
|
|
36
|
+
# The release order is generated from the pyproject.toml files (`make order`); it is not kept in git.
|
|
37
|
+
packages/order.txt
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zettcode-engine
|
|
3
|
+
Version: 0.3.4
|
|
4
|
+
Summary: The agent core of ZettCode: the runtime over zett-agent, and the leaf types it is written on
|
|
5
|
+
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
|
|
6
|
+
Author: Chang-LeHung
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: agent,llm,runtime,zettcode
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: exceptiongroup<2,>=1.2; python_version < '3.11'
|
|
19
|
+
Requires-Dist: pydantic<3,>=2
|
|
20
|
+
Requires-Dist: tomli<3,>=2; python_version < '3.11'
|
|
21
|
+
Requires-Dist: zett-agent<0.3,>=0.2.7
|
|
22
|
+
Provides-Extra: tiktoken
|
|
23
|
+
Requires-Dist: tiktoken<1,>=0.12; extra == 'tiktoken'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "zettcode-engine"
|
|
3
|
+
description = "The agent core of ZettCode: the runtime over zett-agent, and the leaf types it is written on"
|
|
4
|
+
requires-python = ">=3.10"
|
|
5
|
+
dynamic = ["version"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [{name = "Chang-LeHung"}]
|
|
8
|
+
keywords = ["zettcode", "agent", "llm", "runtime"]
|
|
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
|
+
# The runtime this is a core over. Imported directly: the agent, the message types, the approval mode.
|
|
21
|
+
"zett-agent>=0.2.7,<0.3",
|
|
22
|
+
# The session store's records are pydantic models.
|
|
23
|
+
"pydantic>=2,<3",
|
|
24
|
+
# The stdlib gained both of these in 3.11; older runtimes take the backports.
|
|
25
|
+
"exceptiongroup>=1.2,<2; python_version < '3.11'",
|
|
26
|
+
"tomli>=2,<3; python_version < '3.11'",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
# Counting the context with the provider's own tokenizer. Without it the runtime estimates by characters, which is
|
|
31
|
+
# what a plugin that only needs the engine gets; the program installs this extra.
|
|
32
|
+
tiktoken = ["tiktoken>=0.12,<1"]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Repository = "https://github.com/Chang-LeHung/zettcode"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["hatchling"]
|
|
39
|
+
build-backend = "hatchling.build"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.version]
|
|
42
|
+
# Every other distribution reads this file (`../zettcode-engine/src/zettcode/version.py`). A wheel built from an
|
|
43
|
+
# sdist takes the version from the sdist's `PKG-INFO` instead, so a builder never needs this tree beside it.
|
|
44
|
+
path = "src/zettcode/version.py"
|
|
45
|
+
|
|
46
|
+
# `zettcode/` is a PEP 420 namespace: the wheel ships `zettcode/engine/**` and the leaves beside it, and no
|
|
47
|
+
# `zettcode/__init__.py`, so the namespace is the union of what is installed.
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/zettcode"]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
include = ["/src", "/pyproject.toml"]
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
testpaths = ["tests"]
|
|
56
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Small shims for the language versions this project supports.
|
|
2
|
+
|
|
3
|
+
ZettCode runs on Python 3.10 through 3.15, so the few things the standard
|
|
4
|
+
library grew in between live here instead of behind version checks at each use.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
from enum import Enum
|
|
11
|
+
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from builtins import BaseExceptionGroup, ExceptionGroup
|
|
14
|
+
|
|
15
|
+
import tomllib
|
|
16
|
+
else: # pragma: no cover - the branch only the 3.10 runtime takes
|
|
17
|
+
import tomli as tomllib
|
|
18
|
+
from exceptiongroup import BaseExceptionGroup, ExceptionGroup
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
__all__ = ["BaseExceptionGroup", "ExceptionGroup", "StrEnum", "tomllib"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class StrEnum(str, Enum):
|
|
25
|
+
"""A string-valued enum, for the versions before ``enum.StrEnum``.
|
|
26
|
+
|
|
27
|
+
The standard library's version formats as its value, so ``f"{member}"`` is
|
|
28
|
+
``"ready"`` rather than ``"Activity.READY"``; the status line and the stored
|
|
29
|
+
metadata rely on that, so every interpreter uses this class instead of the
|
|
30
|
+
standard one and the wording cannot drift with the version.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __str__(self) -> str:
|
|
34
|
+
"""Return the member's value, as ``enum.StrEnum`` does."""
|
|
35
|
+
return str(self.value)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""What a context budget is made of: the vocabulary the engine measures with and the views draw with.
|
|
2
|
+
|
|
3
|
+
A leaf with no imports, shared like :mod:`zettcode.statusline` and :mod:`zettcode.providers`, so the engine that counts
|
|
4
|
+
the request and the page that shows the count agree on the names without either importing the other.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
__all__ = ["CHARS_PER_TOKEN", "SOURCES"]
|
|
10
|
+
|
|
11
|
+
#: Characters per token when no tokenizer is available. The rule of thumb is close for English prose and low for CJK,
|
|
12
|
+
#: which is why a report names the estimate it used instead of presenting it as exact.
|
|
13
|
+
CHARS_PER_TOKEN = 4
|
|
14
|
+
|
|
15
|
+
#: One row per source, in the order the request is assembled.
|
|
16
|
+
SOURCES = (
|
|
17
|
+
"System prompt",
|
|
18
|
+
"Environment notes",
|
|
19
|
+
"Tool schemas",
|
|
20
|
+
"User messages",
|
|
21
|
+
"Assistant messages",
|
|
22
|
+
"Tool output",
|
|
23
|
+
"Compaction summary",
|
|
24
|
+
)
|