@yahyahammad/venastine 0.2.0 → 0.3.8

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 (129) hide show
  1. package/.env.example +19 -14
  2. package/CONFIG_ARCHITECTURE.md +2002 -0
  3. package/NOTICE +1 -1
  4. package/README.md +233 -94
  5. package/agents/builtin/build.md +73 -0
  6. package/agents/builtin/general.md +80 -0
  7. package/agents/builtin/plan.md +23 -5
  8. package/agents/builtin/test.md +65 -0
  9. package/agents/builtin/writer.md +67 -0
  10. package/agents/manager.py +261 -195
  11. package/agents/subagent_tool.py +277 -43
  12. package/agents/tui_commands.py +7 -12
  13. package/bin/venastine.mjs +528 -382
  14. package/bin/venastine.py +71 -0
  15. package/cli_commands.py +835 -0
  16. package/config.py +95 -1198
  17. package/config.yaml +1090 -0
  18. package/config_edit.py +1301 -0
  19. package/config_schema.py +966 -0
  20. package/config_update.py +749 -0
  21. package/core/agent_activity.py +158 -20
  22. package/core/ansi.py +452 -0
  23. package/core/approval.py +27 -5
  24. package/core/call_view.py +364 -0
  25. package/core/cancel.py +121 -0
  26. package/core/chatgpt_auth.py +747 -0
  27. package/core/claims_view.py +107 -0
  28. package/core/client.py +1238 -82
  29. package/core/commands.py +454 -0
  30. package/core/compaction.py +830 -66
  31. package/core/config_loader.py +516 -97
  32. package/core/connect.py +686 -0
  33. package/core/events.py +68 -6
  34. package/core/file_mentions.py +280 -0
  35. package/core/interaction.py +87 -4
  36. package/core/line_pattern.py +128 -0
  37. package/core/loop.py +1516 -440
  38. package/core/memory.py +120 -8
  39. package/core/pipeline_models.py +23 -9
  40. package/core/provider_errors.py +234 -0
  41. package/core/reasoning/confidence_scoring.py +70 -54
  42. package/core/reasoning/json_retry.py +19 -1
  43. package/core/reasoning/orchestrator.py +232 -53
  44. package/core/reasoning/output_writer.py +90 -31
  45. package/core/reasoning/payload_validation.py +133 -7
  46. package/core/reasoning/pipeline_storage.py +427 -361
  47. package/core/reasoning/review.py +659 -615
  48. package/core/reasoning/scholar.py +38 -14
  49. package/core/reasoning/source_corpus.py +110 -4
  50. package/core/replay.py +158 -26
  51. package/core/session.py +36 -12
  52. package/core/session_view.py +259 -0
  53. package/core/session_wake.py +259 -0
  54. package/core/shell_sessions.py +1553 -0
  55. package/core/workspace_trust.py +1 -1
  56. package/credentials.py +308 -180
  57. package/database.py +82 -1
  58. package/{PRIVACY.md → docs/PRIVACY.md} +19 -7
  59. package/docs/SECURITY.md +108 -0
  60. package/docs/THIRD_PARTY_NOTICES.md +148 -0
  61. package/env_secrets.py +118 -77
  62. package/json_store.py +236 -16
  63. package/logging_setup.py +121 -11
  64. package/main.py +1671 -199
  65. package/mcp_client/client.py +257 -23
  66. package/mcp_client/config.py +484 -379
  67. package/mcp_client/registration.py +163 -2
  68. package/memories/manager.py +15 -0
  69. package/memories/tui_commands.py +7 -12
  70. package/package.json +234 -4
  71. package/project_init/config_files.py +4 -0
  72. package/project_init/generator.py +201 -37
  73. package/project_init/manifest.py +418 -406
  74. package/project_init/tui_commands.py +7 -4
  75. package/prompts/revalidate.md +1 -1
  76. package/prompts/revise.md +17 -15
  77. package/prompts/system_prompts.py +64 -10
  78. package/providers.json.example +94 -92
  79. package/pyproject.toml +51 -2
  80. package/requirements.txt +252 -29
  81. package/safety/policy_enforcement.py +353 -17
  82. package/security/askpass.py +419 -0
  83. package/security/capability.py +37 -7
  84. package/security/confine.py +484 -0
  85. package/security/hosted.py +182 -0
  86. package/security/permissions.py +54 -7
  87. package/security/posture.py +124 -12
  88. package/security/protected_paths.py +198 -6
  89. package/security/sandbox.py +3262 -139
  90. package/security/secrets.py +855 -0
  91. package/skills/tui_commands.py +3 -4
  92. package/storage.py +368 -35
  93. package/tools/base.py +465 -305
  94. package/tools/builtin/_math_common.py +306 -16
  95. package/tools/builtin/_net_common.py +267 -61
  96. package/tools/builtin/arxiv.py +681 -223
  97. package/tools/builtin/ask_user.py +231 -213
  98. package/tools/builtin/discrete_math.py +35 -4
  99. package/tools/builtin/fetch_url.py +239 -21
  100. package/tools/builtin/file_ops.py +341 -33
  101. package/tools/builtin/geometry.py +184 -148
  102. package/tools/builtin/get_time.py +2 -2
  103. package/tools/builtin/linear_algebra.py +66 -23
  104. package/tools/builtin/load_skill.py +10 -0
  105. package/tools/builtin/logic.py +171 -12
  106. package/tools/builtin/pin.py +46 -12
  107. package/tools/builtin/probability_stats.py +224 -228
  108. package/tools/builtin/project_docs.py +80 -21
  109. package/tools/builtin/remember.py +21 -4
  110. package/tools/builtin/shell.py +586 -67
  111. package/tools/builtin/shell_sessions.py +613 -0
  112. package/tools/builtin/symbolic_math.py +80 -10
  113. package/tools/builtin/todo.py +5 -3
  114. package/tools/builtin/web_search.py +329 -151
  115. package/tools/context.py +23 -0
  116. package/tools/isolation.py +387 -314
  117. package/tools/registry.py +347 -30
  118. package/tui/app.py +4645 -438
  119. package/tui/app.tcss +185 -2
  120. package/tui/commands.py +10 -154
  121. package/tui/diffs.py +286 -265
  122. package/tui/hosted_driver.py +102 -0
  123. package/tui/markdown.py +60 -10
  124. package/tui/meters.py +103 -7
  125. package/tui/screens.py +346 -92
  126. package/tui/themes.py +59 -19
  127. package/tui/widgets.py +1575 -111
  128. package/SECURITY.md +0 -88
  129. package/THIRD_PARTY_NOTICES.md +0 -100
@@ -13,6 +13,13 @@ Rev. 1 sketch's `depth: int` parameter and `allowed_tools=` kwarg are
13
13
  both gone: depth lives on ToolContext.subagent_depth, and §15 replaced
14
14
  allowed_tools with context= everywhere.
15
15
 
16
+ §47 added two more declared names, `memory` and `call_id`, and they are
17
+ what the child's thread records as its PARENT. The spawn already returned
18
+ `subagent_thread_id` to the model, so the edge existed -- as a repr
19
+ inside a JSON blob in one message row, which nothing could query and
20
+ replay skips. Stored on the child's own row, it survives the process and
21
+ lets a `▸ spawn_subagent` line still open its run tomorrow.
22
+
16
23
  core.loop is imported INSIDE run(), not at module top: tools/registry.py
17
24
  imports this module to register it, and core.loop imports tools.registry
18
25
  -- a top-level import here would close that cycle at import time.
@@ -50,6 +57,38 @@ TOOL_SCHEMA = {
50
57
  }
51
58
 
52
59
 
60
+ def has_agents() -> bool:
61
+ """ToolSpec.available_check (TECHNICAL_DEBT 13, batch 110).
62
+
63
+ The schema above tells the model to name an "Agent name exactly as
64
+ listed in the Available agents catalog". With no SPAWNABLE agent
65
+ discovered there is no such catalog, so the tool's only possible
66
+ answer is `Unknown agent` -- a schema the model can see, choose, and
67
+ never get value from, which is the fetch_url damage class §15 exists
68
+ to fix. `load_skill.has_skills` is the same declaration for the same
69
+ reason, and `pin`, `unpin` and `remember` each carry one.
70
+
71
+ Reads the SAME function prompt assembly uses (agent_catalog_text, via
72
+ prompts/system_prompts.with_catalogs) rather than a parallel check, so
73
+ "advertised" and "catalogued" cannot drift apart. That is the whole
74
+ point of the choice: batch 51 shipped two spawnable agents, so the
75
+ live instance of this was gone and only the asymmetry remained.
76
+
77
+ ROSTER-WIDE, NOT PER-RUN, because `available_check` takes no context.
78
+ It answers "is there any spawnable agent at all". A run whose
79
+ `spawn_targets` empties the list is still the business of
80
+ `refusal_reason` and of `agent_catalog_text(targets)`, which read the
81
+ same restriction from the two sides it has.
82
+
83
+ Imported inside the function for the reason the module docstring
84
+ gives about core.loop: tools/registry.py imports this module, and
85
+ prompts/system_prompts.py imports the registry.
86
+ """
87
+ from prompts import system_prompts
88
+
89
+ return bool(system_prompts.agent_catalog_text())
90
+
91
+
53
92
  def refusal_reason(params: dict, context=None):
54
93
  """Why this spawn would be refused, or None (§32 A7, #70).
55
94
 
@@ -73,6 +112,12 @@ def refusal_reason(params: dict, context=None):
73
112
  if parent.subagent_depth >= config.SUBAGENT_MAX_DEPTH:
74
113
  return (f"Maximum subagent nesting depth "
75
114
  f"({config.SUBAGENT_MAX_DEPTH}) reached")
115
+ # Depth first, which is the order the docstring above pins; then
116
+ # whether there are arguments to read at all (batch 146). A refusal
117
+ # rather than a raise, because this runs above dispatch()'s
118
+ # containment -- tools/base.py carries the one copy of what that costs.
119
+ if not isinstance(params, dict):
120
+ return "spawn_subagent requires an object of arguments."
76
121
  name = params.get("agent_name")
77
122
  task = params.get("task")
78
123
  if not name or not task:
@@ -80,9 +125,58 @@ def refusal_reason(params: dict, context=None):
80
125
  "'task'.")
81
126
  from agents.manager import manager
82
127
 
83
- if manager.get(name) is None:
84
- return (f"Unknown agent: {name!r} is not "
85
- f"in the available agents catalog.")
128
+ agent = manager.get(name)
129
+ if agent is None:
130
+ # "the roster", not "the catalog", and the distinction is the one
131
+ # A16 turns on: `manager.get` reads the ROSTER (every agent the
132
+ # loader discovered) while `agent_catalog_text()` is the CATALOG
133
+ # (the spawnable subset). This message claimed the catalog was the
134
+ # membership test for as long as it was not -- so for an agent that
135
+ # was in the roster and off the catalog, the catalog's answer was
136
+ # "absent" and this function's was "spawn it", and the one string a
137
+ # model ever sees about membership described a test that was not
138
+ # being run. Defect shape 9 inside the function that owns the
139
+ # contract. The wording was wrong whichever way A16 had gone.
140
+ return (f"Unknown agent: {name!r} is not one of this harness's "
141
+ f"agents.")
142
+ # A16 (ROADMAP_v3 §62), which REVERSES §32 A3/A4's "advertisement
143
+ # only". Before this, `refusal_reason` never read `spawnable`, so
144
+ # `spawn_subagent` would spawn any agent the loader had discovered, by
145
+ # name -- including one that A3's asymmetry had deliberately left OFF
146
+ # the catalog. A3 argued that a stranger's silence must get the safe
147
+ # answer, and the measured consequence of "reads as false" was that the
148
+ # agent became INVISIBLE rather than unreachable: a project-tier agent
149
+ # omitting the field was absent from the prompt a user might read and
150
+ # callable by any text that named it. For the careless author the
151
+ # default was safe; for the adversarial one it was the quieter option,
152
+ # which is the opposite ranking from the one A3 argues.
153
+ #
154
+ # BEFORE spawn_targets and after the unknown-agent check: an unknown
155
+ # name must still report that it is unknown rather than that it is not
156
+ # permitted, and this is a property of the agent being spawned where
157
+ # spawn_targets is a property of the parent.
158
+ #
159
+ # `is not True` rather than `not`, because `None` means undeclared at
160
+ # the user and project tiers and A3's reading of silence is unchanged --
161
+ # only its consequence is.
162
+ if getattr(agent, "spawnable", None) is not True:
163
+ return (f"{name!r} is not a spawnable agent. It can be used by hand "
164
+ f"with /agent, which is unaffected.")
165
+ # LAST, because the checks above are the live contract this
166
+ # docstring describes and an unknown name must still report that it
167
+ # is unknown rather than that it is not permitted.
168
+ #
169
+ # A REFUSAL RATHER THAN A NARROWING, which is the whole point of the
170
+ # field. C6 caps the child's tools at the parent's, so without this
171
+ # a parent that should not be delegating the work at all gets a
172
+ # child that runs anyway with pieces missing -- `plan` spawning
173
+ # `build` came back unable to `write` or `edit`, and neither side
174
+ # could tell. Refusing says so in a sentence the model can act on,
175
+ # and A7 means it says so BEFORE a human is asked to sign anything.
176
+ if parent.spawn_targets is not None and name not in parent.spawn_targets:
177
+ return (f"{name!r} is not an agent this one may spawn. "
178
+ f"Available here: "
179
+ f"{', '.join(sorted(parent.spawn_targets)) or 'none'}.")
86
180
  return None
87
181
 
88
182
 
@@ -132,12 +226,49 @@ def request_payload(params: dict, context=None) -> dict:
132
226
  "candidates": manager.candidate_approvals(child)}
133
227
 
134
228
 
229
+ def _child_pair(agent, parent_run) -> tuple:
230
+ """`(model, provider)` a spawned child runs on.
231
+
232
+ THREE TIERS, read top to bottom (ROADMAP_v3 §57, SM2):
233
+
234
+ * The agent's OWN pin, which is its identity: an agent that names a
235
+ model for being a different model must get it. A HALF pin keeps
236
+ today's rule exactly -- the named half, the other from the parent
237
+ run -- and opts the agent out of `/submodel` WHOLE (SM6), because
238
+ a pinned model name against the submodel's provider is a pair
239
+ nobody chose.
240
+ * `/submodel`'s pair, for an agent that pins neither half. It beats
241
+ the parent run's pair at every depth (SM7): it is the model for
242
+ subagents as a class, and a parent's pin is that parent's identity
243
+ rather than its children's. Read at SPAWN time, so a choice made
244
+ between turns reaches the next spawn without a restart.
245
+ * The parent run's pair, then the harness default -- what every
246
+ spawn got before §57, and still what one gets with nothing set.
247
+ """
248
+ from core import pipeline_models
249
+ from core.loop import DEFAULT_PROVIDER
250
+
251
+ if not agent.pins_model:
252
+ chosen = pipeline_models.resolve("subagent")
253
+ if chosen is not None:
254
+ return chosen["model"], chosen["provider_name"]
255
+ model = agent.model or (parent_run.model if parent_run else None) \
256
+ or config.MODEL_NAME
257
+ provider = agent.provider \
258
+ or (parent_run.provider_name if parent_run else None) \
259
+ or DEFAULT_PROVIDER
260
+ return model, provider
261
+
262
+
135
263
  def run(params: dict, parent_context=None, parent_run=None,
136
- response_channel=None, signoff=None, activity=None) -> dict:
264
+ response_channel=None, signoff=None, activity=None,
265
+ memory=None, call_id=None, cancel=None) -> dict:
266
+ from agents.manager import manager
137
267
  from core.loop import (
138
- RunAgentLoop, DEFAULT_PROVIDER, DEFAULT_SYSTEM_PROMPT,
268
+ DEFAULT_SYSTEM_PROMPT,
269
+ RunAgentLoop,
270
+ with_persona,
139
271
  )
140
- from agents.manager import manager
141
272
 
142
273
  parent = parent_context or ToolContext()
143
274
  # §32 A7. The SAME function the loop consulted before deciding
@@ -176,13 +307,12 @@ def run(params: dict, parent_context=None, parent_run=None,
176
307
  # asked -- a headless run, where the child gets no grant anyway.
177
308
  granted = set(signoff) if signoff else set()
178
309
 
179
- # Inherit the parent run's identity only where the agent definition
180
- # is silent -- an agent's declared model/provider is its identity.
181
- model = agent.model or (parent_run.model if parent_run else None) \
182
- or config.MODEL_NAME
183
- provider = agent.provider \
184
- or (parent_run.provider_name if parent_run else None) \
185
- or DEFAULT_PROVIDER
310
+ model, provider = _child_pair(agent, parent_run)
311
+ # The parent's level, unvalidated here on purpose: a child on its own
312
+ # pin or on the /submodel pair may be a model that refuses it, and
313
+ # core.client.effort_for drops a level the receiving model does not
314
+ # list at the send, with a warning. One validator at the wire rather
315
+ # than a guess at each site that can change the model.
186
316
  effort = parent_run.effort if parent_run else None
187
317
 
188
318
  # Batch 59. THE SPAN AND THE PASS-DOWN ARE ONE CHANGE, and the
@@ -201,38 +331,142 @@ def run(params: dict, parent_context=None, parent_run=None,
201
331
  #
202
332
  # `child.subagent_depth` and not a local count: C3 already maintains
203
333
  # that number and a second one would be free to disagree with it.
204
- with agent_activity.span(activity, agent.name, child.subagent_depth):
205
- response = RunAgentLoop.run_agent_conversation(
206
- user_goal=task,
207
- model=model,
208
- provider_name=provider,
209
- max_steps=agent.max_steps or config.MAX_ITERATIONS,
334
+ from core import shell_sessions
335
+
336
+ # ROADMAP_v3 §49 (SS9). Everything the child's first turn and any wake
337
+ # turn after it share. A wake IS that run continuing -- the same
338
+ # prompt, context, channel, grant and sink -- so the two calls take one
339
+ # dict rather than two argument lists that could drift apart.
340
+ common = dict(
341
+ model=model,
342
+ provider_name=provider,
343
+ max_steps=agent.max_steps or config.MAX_ITERATIONS,
344
+ context=child,
345
+ effort=effort,
346
+ # `child`, not the agent's own context: C6 intersects with
347
+ # the parent, so a parent that excluded spawn_subagent must not
348
+ # have the catalog re-invite its child to spawn one (review
349
+ # f19).
350
+ # #68: the child's own facts, not the parent's. A subagent
351
+ # spawned from a headless run inherits no channel, so its
352
+ # catalogs must be decided by what IT can call -- the same
353
+ # values handed to run_agent_conversation below.
354
+ system_prompt=manager.system_prompt_for(
355
+ agent, with_persona(DEFAULT_SYSTEM_PROMPT, model, provider),
210
356
  context=child,
211
- effort=effort,
212
- # `child`, not the agent's own context: C6 intersects with
213
- # the parent, so a parent that excluded spawn_subagent must not
214
- # have the catalog re-invite its child to spawn one (review
215
- # f19).
216
- # #68: the child's own facts, not the parent's. A subagent
217
- # spawned from a headless run inherits no channel, so its
218
- # catalogs must be decided by what IT can call -- the same
219
- # values handed to run_agent_conversation two lines below.
220
- system_prompt=manager.system_prompt_for(
221
- agent, DEFAULT_SYSTEM_PROMPT, context=child,
222
- callable_only=response_channel is None,
223
- granted=granted),
224
- response_channel=response_channel,
225
- granted_tools=granted if (response_channel is not None
226
- and granted) else None,
227
- # §27 AC1. A spawned agent's thread is not a conversation
228
- # anyone will resume, and one goal-mode turn can spawn several.
229
- thread_kind=THREAD_KIND_SUBAGENT,
230
- # The recursion. Inherited exactly as response_channel is, and
231
- # for the same reason: the child is a run in its own right and
232
- # whatever is watching this stack is watching that one too.
233
- activity=activity,
234
- )
357
+ callable_only=response_channel is None,
358
+ granted=granted),
359
+ response_channel=response_channel,
360
+ granted_tools=granted if (response_channel is not None
361
+ and granted) else None,
362
+ # The recursion. Inherited exactly as response_channel is, and
363
+ # for the same reason: the child is a run in its own right and
364
+ # whatever is watching this stack is watching that one too.
365
+ activity=activity,
366
+ # ROADMAP_v3 §61 (CN7). Inherited exactly as `activity` above is,
367
+ # and for a sharper version of the same reason: the child is a
368
+ # run in its own right, and a stop aimed at the turn that spawned
369
+ # it has to reach it, or the parent waits out a child it has
370
+ # already asked to end.
371
+ cancel=cancel,
372
+ )
373
+ with agent_activity.span(activity, agent.name, child.subagent_depth,
374
+ call_id) as span:
375
+ # ROADMAP_v3 §49 (SS17). The child is a wake CONSUMER: a session it
376
+ # starts is reported inside this call and nowhere else, which is
377
+ # what makes starting one allowed at all in this run.
378
+ with shell_sessions.consuming():
379
+ try:
380
+ response = RunAgentLoop.run_agent_conversation(
381
+ user_goal=task,
382
+ # §27 AC1. A spawned agent's thread is not a
383
+ # conversation anyone will resume, and one goal-mode
384
+ # turn can spawn several.
385
+ thread_kind=THREAD_KIND_SUBAGENT,
386
+ # §47. WHO spawned this thread, stored on the child's
387
+ # own row.
388
+ #
389
+ # `memory` and `call_id` are injected by dispatch() the
390
+ # same way the values in `common` are -- the parent's
391
+ # live ConversationMemory, and the model's id for THIS
392
+ # call. Both are None on a path that reaches run()
393
+ # directly (every test that calls it by hand), and the
394
+ # child is then simply a thread with no recorded
395
+ # parent, which is what it was before that batch.
396
+ #
397
+ # THE CALL ID IS WHAT MAKES THE EDGE SPECIFIC. One turn
398
+ # can spawn `explore` three times, so the agent name
399
+ # identifies the roster entry and not the run; the call
400
+ # id is the only thing that ties one child to one
401
+ # `▸ spawn_subagent` line.
402
+ thread_parent=getattr(memory, "thread_id", None),
403
+ thread_parent_call=call_id,
404
+ thread_agent=agent.name,
405
+ **common,
406
+ )
407
+ # SS9. The child does not answer its parent while its own
408
+ # background sessions are still running: it sleeps HERE, is
409
+ # woken here, and returns once there is nothing left to
410
+ # report. D6 is untouched -- what crosses back is still one
411
+ # distilled answer.
412
+ response = _sleep_for_sessions(response, common)
413
+ except BaseException:
414
+ # A child that RAISED has no thread to report to, and its
415
+ # sessions would outlive the run that started them --
416
+ # holding slots against the process-wide cap for as long
417
+ # as their timeouts. The SPAN is the handle: it is frozen
418
+ # and carries no address, so the child's thread id may
419
+ # never have reached this frame, while every session
420
+ # records the span it was started inside.
421
+ shell_sessions.sessions.kill_by_span(
422
+ span.id, shell_sessions.KILL_OWNER_FAILED)
423
+ raise
235
424
  return {
236
425
  "result": response.text,
237
426
  "subagent_thread_id": str(response.thread_id),
238
427
  }
428
+
429
+
430
+ def _sleep_for_sessions(response, common: dict):
431
+ """Stay inside the spawn while the child's sessions report (SS9, SS20).
432
+
433
+ Returns the response the child ends on: its first answer when it
434
+ started no sessions, or the answer to the last wake it was given.
435
+
436
+ THE LIMIT IS WHY THIS TERMINATES. A subagent has no user to type a
437
+ message, so the consecutive-wake count it shares with every other
438
+ owner can never be reset from outside -- past it the manager stops
439
+ handing out batches and holds them instead. SS20 makes that the end of
440
+ the run rather than a wait for something that cannot happen: the
441
+ remaining sessions are stopped, and the results of stopping them are
442
+ what the one final wake carries.
443
+ """
444
+ from core import shell_sessions
445
+
446
+ sessions = shell_sessions.sessions
447
+ thread_id = response.thread_id
448
+ while True:
449
+ batch = sessions.wait_for_wake(thread_id)
450
+ if batch:
451
+ response = _wake(response, thread_id, batch, common)
452
+ continue
453
+ if not sessions.suspended(thread_id):
454
+ return response
455
+ sessions.kill_owned(thread_id, shell_sessions.KILL_WAKE_LIMIT)
456
+ held = sessions.take_held(thread_id)
457
+ if held:
458
+ response = _wake(response, thread_id, held, common)
459
+ # Anything that last turn started has nobody left to report to,
460
+ # and nothing after this point will ever wake this thread again.
461
+ sessions.kill_owned(thread_id, shell_sessions.KILL_WAKE_LIMIT)
462
+ return response
463
+
464
+
465
+ def _wake(response, thread_id, events, common: dict):
466
+ """One wake turn in the child's own thread, under its own run."""
467
+ from core.loop import RunAgentLoop
468
+ from core.session_wake import build_wake
469
+
470
+ text, record = build_wake(events)
471
+ return RunAgentLoop.wake_conversation(
472
+ thread_id=thread_id, text=text, harness=record, **common)
@@ -13,8 +13,9 @@ deliberately does NOT import tui.app, so app.py can import it without a
13
13
  cycle.
14
14
  """
15
15
 
16
- from tui.commands import SlashCommand, registry as commands
17
- from agents.manager import manager
16
+ from agents.manager import GRILL_ME_TASK, manager
17
+ from tui.commands import bind
18
+ from tui.commands import registry as commands
18
19
 
19
20
 
20
21
  def _cmd_agent(app, args: str) -> None:
@@ -131,21 +132,15 @@ def _cmd_grill(app, args: str) -> None:
131
132
  # decided here. (Review f19's "no context, deliberately" answered a
132
133
  # question §25 R15 replaced -- what matters now is not which policy
133
134
  # governs but whether anything can answer, and only the run knows.)
134
- app.run_one_shot(
135
- agent,
136
- "Grill this thread: surface what still needs a decision.",
137
- )
135
+ app.run_one_shot(agent, GRILL_ME_TASK)
138
136
 
139
137
 
140
138
  def register_agent_commands() -> None:
141
139
  """Idempotent — registering by name overwrites, matching §16's
142
140
  register_builtin_commands()."""
143
141
  for command in (
144
- SlashCommand("agent", "switch the active agent", _cmd_agent,
145
- "[name|default]"),
146
- SlashCommand("goal", "set the thread's persistent objective",
147
- _cmd_goal, "[text|clear]"),
148
- SlashCommand("grill-me", "surface what still needs a decision",
149
- _cmd_grill),
142
+ bind("agent", _cmd_agent),
143
+ bind("goal", _cmd_goal),
144
+ bind("grill-me", _cmd_grill),
150
145
  ):
151
146
  commands.register(command)