zettcode-engine 0.4.7__tar.gz → 0.5.0__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 (89) hide show
  1. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/PKG-INFO +2 -2
  2. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/pyproject.toml +1 -1
  3. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/config.py +5 -4
  4. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/plugin.py +3 -1
  5. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/switches.py +49 -6
  6. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/service_contracts.py +10 -0
  7. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/version.py +1 -1
  8. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/.gitignore +0 -0
  9. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/_compat.py +0 -0
  10. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/budget.py +0 -0
  11. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/config_edit.py +0 -0
  12. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/__init__.py +0 -0
  13. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/__init__.py +0 -0
  14. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/base.py +0 -0
  15. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/context.py +0 -0
  16. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/exports.py +0 -0
  17. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/interaction.py +0 -0
  18. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/sessions.py +0 -0
  19. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/settings.py +0 -0
  20. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/agent/turns.py +0 -0
  21. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/core.py +0 -0
  22. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/delivery.py +0 -0
  23. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/delivery_runtime.py +0 -0
  24. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/dialogue/__init__.py +0 -0
  25. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/dialogue/ask.py +0 -0
  26. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/dialogue/side.py +0 -0
  27. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/dialogue/title.py +0 -0
  28. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/export/__init__.py +0 -0
  29. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/export/trace/script.js +0 -0
  30. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/export/trace/style.css +0 -0
  31. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/export/trace/template.html +0 -0
  32. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/__init__.py +0 -0
  33. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/capabilities.py +0 -0
  34. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/compaction.py +0 -0
  35. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/context.py +0 -0
  36. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/files.py +0 -0
  37. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/guidance.py +0 -0
  38. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/harness_switch.py +0 -0
  39. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/mcp_notice.py +0 -0
  40. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/relay.py +0 -0
  41. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/subagents.py +0 -0
  42. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/extensions/usage.py +0 -0
  43. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/harness_paths.py +0 -0
  44. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/inbox.py +0 -0
  45. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/permission/__init__.py +0 -0
  46. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/permission/approval.py +0 -0
  47. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/permission/readonly.py +0 -0
  48. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/permission/sandbox.py +0 -0
  49. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/pipeline.py +0 -0
  50. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/__init__.py +0 -0
  51. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/cli.py +0 -0
  52. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/commands.py +0 -0
  53. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/context.py +0 -0
  54. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/extension.py +0 -0
  55. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/graph.py +0 -0
  56. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/groups.py +0 -0
  57. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/llm.py +0 -0
  58. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/loader.py +0 -0
  59. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/mixins.py +0 -0
  60. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/services.py +0 -0
  61. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/settings.py +0 -0
  62. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/state.py +0 -0
  63. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/plugins/triggers.py +0 -0
  64. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/provided.py +0 -0
  65. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/py.typed +0 -0
  66. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/server_tools.py +0 -0
  67. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/__init__.py +0 -0
  68. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/layout.py +0 -0
  69. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/ledger.py +0 -0
  70. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/locks.py +0 -0
  71. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/metadata.py +0 -0
  72. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/records.py +0 -0
  73. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/engine/storage/store.py +0 -0
  74. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/error_text.py +0 -0
  75. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/filelock.py +0 -0
  76. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/logging_setup.py +0 -0
  77. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/mention.py +0 -0
  78. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/modes.py +0 -0
  79. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/paths.py +0 -0
  80. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/plugin_tui.py +0 -0
  81. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/processes.py +0 -0
  82. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/prompt.py +0 -0
  83. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/providers.py +0 -0
  84. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/py.typed +0 -0
  85. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/registry.py +0 -0
  86. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/relay.py +0 -0
  87. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/statusline_parts.py +0 -0
  88. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/wire.py +0 -0
  89. {zettcode_engine-0.4.7 → zettcode_engine-0.5.0}/src/zettcode/wording.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: zettcode-engine
3
- Version: 0.4.7
3
+ Version: 0.5.0
4
4
  Summary: The agent core of ZettCode: the runtime over zett-agent, and the leaf types it is written on
5
5
  Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
6
6
  Author: Chang-LeHung
@@ -19,6 +19,6 @@ Requires-Dist: exceptiongroup<2,>=1.2; python_version < '3.11'
19
19
  Requires-Dist: pydantic<3,>=2
20
20
  Requires-Dist: tomli<3,>=2; python_version < '3.11'
21
21
  Requires-Dist: zett-agent<0.3,>=0.2.10
22
- Requires-Dist: zettcode-tools<0.5,>=0.4.7
22
+ Requires-Dist: zettcode-tools<0.6,>=0.5.0
23
23
  Provides-Extra: tiktoken
24
24
  Requires-Dist: tiktoken<1,>=0.12; extra == 'tiktoken'
@@ -18,7 +18,7 @@ classifiers = [
18
18
  ]
19
19
  dependencies = [
20
20
  # The coding tools the runtime hands the model, a leaf of its own beneath the engine.
21
- "zettcode-tools>=0.4.7,<0.5",
21
+ "zettcode-tools>=0.5.0,<0.6",
22
22
  # The runtime this is a core over. Imported directly: the agent, the message types, the approval mode.
23
23
  "zett-agent>=0.2.10,<0.3",
24
24
  # The session store's records are pydantic models.
@@ -504,8 +504,9 @@ class ZettCodeConfig:
504
504
  shows in its plan panel. Off by default: a plan is a turn spent
505
505
  updating it, and not every session wants one.
506
506
  jit_harness: Start with the just-in-time harness on: the model may write small Python tools of its own
507
- and run them. Off by default, because what it writes runs in this process, outside the shell's
508
- permission; the terminal's ``/plugins`` switch writes it for the next start.
507
+ and run them. On by default; what it writes runs in a child process of its own, and inside the shell's
508
+ sandbox at every level below ``full``. ``[harness] jit = false`` (or the terminal's ``/plugins`` switch)
509
+ turns it off for the next start.
509
510
  shell_network: Let a command that runs in the ``safe`` sandbox use the network. Off by default; ``[shell]
510
511
  network = true`` turns it on. ``full`` always has the network, and so does a machine with no sandbox.
511
512
  sessions_enabled: Register with the background session broker, so this session can be
@@ -558,7 +559,7 @@ class ZettCodeConfig:
558
559
  subagent_max_iterations: int = DEFAULT_SUBAGENT_MAX_ITERATIONS
559
560
  subagent_messaging: bool = False
560
561
  todowrite_enabled: bool = False
561
- jit_harness: bool = False
562
+ jit_harness: bool = True
562
563
  shell_network: bool = False
563
564
  sessions_enabled: bool = True
564
565
  update_enabled: bool = True
@@ -1132,7 +1133,7 @@ def load_config(
1132
1133
  ),
1133
1134
  subagent_messaging=bool(_setting(harness, "subagent_messaging", bool, False)),
1134
1135
  todowrite_enabled=bool(_setting(harness, "todowrite", bool, False)),
1135
- jit_harness=bool(_setting(harness, "jit", bool, False)),
1136
+ jit_harness=bool(_setting(harness, "jit", bool, True)),
1136
1137
  shell_network=bool(_setting(shell, "network", bool, False)),
1137
1138
  sessions_enabled=bool(_setting(sessions, "enabled", bool, True)),
1138
1139
  update_enabled=bool(_setting(update, "enabled", bool, True)),
@@ -84,7 +84,9 @@ class Plugin(PluginAgentMixin, Generic[_C], ABC):
84
84
  when the entry-point name is not the label you want in
85
85
  diagnostics. When it is empty the entry-point name is used, and a
86
86
  plugin that declares neither falls back to the class name.
87
- description: One-line summary of what the plugin adds, for diagnostics.
87
+ description: One-line summary of what the plugin adds, shown beside its switch on ``/plugins`` and used in
88
+ diagnostics. A plugin a reader can switch should say something here: a listed row with nothing to say
89
+ costs the reader the one line that tells the two plugins called alike apart.
88
90
  priority: Hook order against every other extension: lower runs first,
89
91
  and equal priorities keep registration order.
90
92
  setting: The configuration key that turns its work off, for a plugin compiled into the program; ``None`` when
@@ -57,6 +57,10 @@ class PluginEntry:
57
57
  why: Why it cannot be switched, when it cannot; empty otherwise.
58
58
  note: What else a list should say about the row — a plugin that lost its name to one loaded before it has no
59
59
  switch and is not a failure, and this says so.
60
+ description: What the plugin adds, in one line. It is derived, not stored: the plugin's own
61
+ :attr:`~zettcode.engine.plugins.plugin.Plugin.description` once it has loaded, and otherwise the summary
62
+ its distribution declares — which is a sentence about the distribution the row's second column names,
63
+ not about one plugin inside it. Empty when neither says anything.
60
64
  """
61
65
 
62
66
  name: str
@@ -68,6 +72,7 @@ class PluginEntry:
68
72
  switchable: bool = True
69
73
  why: str = ""
70
74
  note: str = ""
75
+ description: str = ""
71
76
 
72
77
 
73
78
  @dataclass(frozen=True, slots=True)
@@ -120,10 +125,11 @@ def catalog(
120
125
  builtin=True,
121
126
  enabled=bool(getattr(config, setting.field)),
122
127
  setting=setting.path,
128
+ description=plugin.description,
123
129
  )
124
130
  )
125
131
  continue
126
- installed.append(_installed(plugin.name, origin, config, off=off))
132
+ installed.append(_installed(plugin.name, origin, config, off=off, description=plugin.description))
127
133
  points = tuple(entry_points) if entry_points is not None else loader.installed_entry_points()
128
134
  seen = {entry.origin for entry in installed} | {origin for origin, _why in bundle.failed}
129
135
  for point in points:
@@ -136,7 +142,9 @@ def catalog(
136
142
  if loader.part_group(point) is not None:
137
143
  if point.name not in off:
138
144
  continue
139
- installed.append(_installed(point.name, point.name, config, off=off))
145
+ # This one never loaded, so there is no object to ask: its distribution's summary is what it has to say. The
146
+ # metadata is read here and not for every entry point, because a row that loaded speaks for itself.
147
+ installed.append(_installed(point.name, point.name, config, off=off, description=_summary(point)))
140
148
  # A single-file plugin that is switched off is not in the bundle (the loader never imported it), so the folder is
141
149
  # what says it exists: it stays on the page, off, where it can be switched back on.
142
150
  for path in loader.installed_files(config.plugins_dir):
@@ -159,8 +167,17 @@ def catalog(
159
167
  for origin, why in bundle.failed:
160
168
  if origin in builtins or origin not in loaded_origins:
161
169
  failures.setdefault(origin, []).append(why)
170
+ by_name = {point.name: point for point in points}
162
171
  failed = [
163
- _failed(origin, "; ".join(whys), config, builtin=origin in builtins, off=off)
172
+ _failed(
173
+ origin,
174
+ "; ".join(whys),
175
+ config,
176
+ builtin=origin in builtins,
177
+ off=off,
178
+ # A row that failed has no object either: the summary of the point it came from is all there is.
179
+ description=_summary(by_name[origin]) if origin in by_name else "",
180
+ )
164
181
  for origin, whys in failures.items()
165
182
  ]
166
183
  lost = [PluginEntry(name, name, enabled=False, switchable=False, note=note) for name, note in bundle.taken]
@@ -176,7 +193,7 @@ def catalog(
176
193
  )
177
194
 
178
195
 
179
- def _installed(name: str, origin: str, config: ZettCodeConfig, *, off: set[str]) -> PluginEntry:
196
+ def _installed(name: str, origin: str, config: ZettCodeConfig, *, off: set[str], description: str = "") -> PluginEntry:
180
197
  """Return one installed plugin's row: whether the next start loads it, and whether its switch can move."""
181
198
  why = (
182
199
  "installed plugins are off entirely: [plugins] enabled = false in the configuration file"
@@ -189,10 +206,13 @@ def _installed(name: str, origin: str, config: ZettCodeConfig, *, off: set[str])
189
206
  enabled=config.plugins_enabled and origin not in off,
190
207
  switchable=why == "",
191
208
  why=why,
209
+ description=description,
192
210
  )
193
211
 
194
212
 
195
- def _failed(origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off: set[str]) -> PluginEntry:
213
+ def _failed(
214
+ origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off: set[str], description: str = ""
215
+ ) -> PluginEntry:
196
216
  """Return the row of a plugin that could not load.
197
217
 
198
218
  A compiled-in one has no switch here: the object that declares its setting never loaded. An installed one keeps
@@ -207,8 +227,9 @@ def _failed(origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off
207
227
  failure=why,
208
228
  switchable=False,
209
229
  why="it could not load, so there is no switch to move",
230
+ description=description,
210
231
  )
211
- row = _installed(origin, origin, config, off=off)
232
+ row = _installed(origin, origin, config, off=off, description=description)
212
233
  return PluginEntry(
213
234
  row.name,
214
235
  row.origin,
@@ -216,9 +237,31 @@ def _failed(origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off
216
237
  failure=why,
217
238
  switchable=row.switchable,
218
239
  why=row.why,
240
+ description=row.description,
219
241
  )
220
242
 
221
243
 
244
+ def _summary(point: EntryPoint) -> str:
245
+ """Return the one-line summary the distribution behind an entry point declares, or ``""`` when it declares none.
246
+
247
+ The plugin says what it does itself once it loads (:attr:`~zettcode.engine.plugins.plugin.Plugin.description`);
248
+ this is for the rows where it never got that far — the distribution switched off, or a part this process does not
249
+ load — and for those the package metadata is all there is. The summary describes the *distribution*, which is what
250
+ the row's second column names; for a distribution carrying several plugins it is one sentence about all of them.
251
+ A stand-in entry point that has no distribution beside it (a test's own) says nothing rather than failing the page,
252
+ and so does a metadata file that cannot be opened or parsed: a nicety costs its cell, never the page.
253
+ """
254
+ try:
255
+ # `getattr` for the same reason the loader asks a point for its distribution that way: a stand-in that has
256
+ # none is a point with nothing to say, not a page that cannot open.
257
+ dist = getattr(point, "dist", None)
258
+ metadata = getattr(dist, "metadata", None)
259
+ summary = metadata["Summary"] if metadata is not None else ""
260
+ except (OSError, TypeError, ValueError):
261
+ return ""
262
+ return " ".join(str(summary or "").split())
263
+
264
+
222
265
  def _config_disabled(path: Path) -> list[str]:
223
266
  """Return the names ``[plugins] disable`` holds in the configuration file, validating the shape."""
224
267
  from zettcode._compat import tomllib
@@ -12,6 +12,8 @@ from dataclasses import dataclass
12
12
  from typing import TYPE_CHECKING, ClassVar
13
13
 
14
14
  if TYPE_CHECKING: # pragma: no cover - annotations only
15
+ from pathlib import Path
16
+
15
17
  from zettcode.engine.extensions.context import ContextReport
16
18
  from zettcode.engine.storage.ledger import Ledger
17
19
  from zettcode.engine.storage.metadata import SessionInfo
@@ -31,6 +33,14 @@ class SessionStoreService(ABC):
31
33
  async def list_sessions(self, *, limit: int = 100, offset: int = 0) -> list[SessionInfo]:
32
34
  """Return the workspace's sessions, newest first."""
33
35
 
36
+ @abstractmethod
37
+ def session_path(self, session_id: str) -> Path:
38
+ """Return the file one session's conversation is stored in; it may not exist yet.
39
+
40
+ Raises:
41
+ ValueError: For an id that would leave the store.
42
+ """
43
+
34
44
 
35
45
  class UsageLedgerService(ABC):
36
46
  """The workspace's usage ledger, read from the stored conversations."""
@@ -8,4 +8,4 @@ of the dependency graph: everything else may import `zettcode.version`, nothing
8
8
  from __future__ import annotations
9
9
 
10
10
  #: The version of the program and of every distribution built beside it.
11
- __version__ = "0.4.7"
11
+ __version__ = "0.5.0"