Skip to content

Commit 1ced744

Browse files
authored
refactor(agents): move announce, completion, recovery, and registry families into concept directories (#121553)
* refactor(agents): move announce family into subagents/announce/ * refactor(agents): move completion and main-session recovery families * refactor(agents): move registry family into subagents/registry * refactor(agents): update registry state type imports * style(agents): format moved subagent imports * test(agents): preserve isolated registry test routing * fix(scripts): recognize relocated subagent announce seams
1 parent 2132c15 commit 1ced744

356 files changed

Lines changed: 1410 additions & 1290 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎config/knip.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ const rootEntries = [
156156
// Loaded by URL from setup-inference-detection.ts; no static import edge exists.
157157
"src/system-agent/setup-inference-detection.worker.ts!",
158158
// Split runtime loaded through a path assembled in subagent-registry.ts.
159-
"src/agents/subagent-registry.runtime.ts!",
159+
"src/agents/subagents/registry/subagent-registry.runtime.ts!",
160160
// Loaded lazily by the sweeper only when a receipt-bearing or interrupted row is found.
161-
"src/agents/subagent-registry-restart-recovery.ts!",
161+
"src/agents/subagents/registry/subagent-registry-restart-recovery.ts!",
162162
// Task cancellation loads this control facade by string path to avoid a registry cycle.
163163
"src/tasks/task-registry-control.runtime.ts!",
164164
// Human plugin listing lazily loads its formatter to keep JSON startup lean.

‎config/max-lines-baseline.txt‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ src/agents/failover-error.ts
409409
src/agents/harness/native-hook-relay.test.ts
410410
src/agents/harness/selection.test.ts
411411
src/agents/harness/selection.ts
412-
src/agents/main-session-restart-recovery.test.ts
412+
src/agents/main-session-recovery/main-session-restart-recovery.test.ts
413413
src/agents/model-auth-availability.ts
414414
src/agents/model-auth.profiles.test.ts
415415
src/agents/model-auth.test.ts
@@ -441,15 +441,15 @@ src/agents/sessions/model-registry.ts
441441
src/agents/sessions/package-manager.ts
442442
src/agents/sessions/resource-loader.ts
443443
src/agents/sessions/settings-manager.ts
444-
src/agents/subagent-announce-delivery.test.ts
445-
src/agents/subagent-announce-delivery.ts
446-
src/agents/subagent-announce.format.e2e.test.ts
447-
src/agents/subagent-control.test.ts
448-
src/agents/subagent-control.ts
449-
src/agents/subagent-registry-lifecycle.test.ts
450-
src/agents/subagent-registry-run-manager.ts
451-
src/agents/subagent-registry.steer-restart.test.ts
452-
src/agents/subagent-registry.test.ts
444+
src/agents/subagents/announce/subagent-announce-delivery.test.ts
445+
src/agents/subagents/announce/subagent-announce-delivery.ts
446+
src/agents/subagents/announce/subagent-announce.format.e2e.test.ts
447+
src/agents/subagents/registry/subagent-control.test.ts
448+
src/agents/subagents/registry/subagent-control.ts
449+
src/agents/subagents/registry/subagent-registry-lifecycle.test.ts
450+
src/agents/subagents/registry/subagent-registry-run-manager.ts
451+
src/agents/subagents/registry/subagent-registry.steer-restart.test.ts
452+
src/agents/subagents/registry/subagent-registry.test.ts
453453
src/agents/subagents/spawn/subagent-spawn.test.ts
454454
src/agents/system-prompt.test.ts
455455
src/agents/system-prompt.ts

‎docs/refactor/operator-approvals.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ This table records the implementation state when #103505 was opened. The rollout
5050
| Portable actions | `src/interactive/payload.ts`, `src/plugin-sdk/interactive-runtime.ts`, `src/plugin-sdk/approval-reply-runtime.ts` | Approval buttons are command actions containing `/approve ...`; URL and Web App targets are untyped button fields. |
5151
| Telegram | `extensions/telegram/src/approval-handler.runtime.ts`, `extensions/telegram/src/button-types.ts` | The renderer parses command text to recognize approval semantics before producing private callback data. |
5252
| Control UI | `ui/src/app/exec-approval.ts`, `ui/src/app/overlays.ts`, `ui/src/components/exec-approval.ts` | Approval UI is a global modal. `ui/src/app-route-paths.ts` and `ui/src/app-routes.ts` use exact routes and rewrite unknown paths to Chat. |
53-
| Session ownership | `src/agents/subagent-registry.types.ts`, `src/agents/subagent-registry-read.ts`, `src/config/sessions/types.ts` | Controller, requester, explicit parent, and legacy spawn ownership exist, but approval events are not projected to those session streams. |
53+
| Session ownership | `src/agents/subagents/registry/subagent-registry.types.ts`, `src/agents/subagents/registry/subagent-registry-read.ts`, `src/config/sessions/types.ts` | Controller, requester, explicit parent, and legacy spawn ownership exist, but approval events are not projected to those session streams. |
5454
| Shared state | `src/state/openclaw-state-schema.sql`, `src/state/openclaw-state-db.ts` | Existing immediate transactions and Kysely conditional updates support durable compare-and-set in `state/openclaw.sqlite`. |
5555

5656
Representative current tests include `src/gateway/exec-approval-manager.test.ts`, `src/gateway/server-methods/approval-shared.test.ts`, `src/agents/bash-tools.exec-gateway-approval.e2e.test.ts`, `extensions/telegram/src/approval-handler.runtime.test.ts`, and `ui/src/e2e/approval-flow.e2e.test.ts`.
@@ -294,7 +294,7 @@ Use a deterministic breadth-first walk:
294294
4. Normalize and de-duplicate on enqueue so the first, shortest path wins.
295295
5. Stop at 64 unique keys; this audience-size cap also bounds traversal depth.
296296

297-
The registry source is `src/agents/subagent-registry-read.ts`; ownership fields are defined in `src/agents/subagent-registry.types.ts`. Session fallback fields are defined in `src/config/sessions/types.ts`.
297+
The registry source is `src/agents/subagents/registry/subagent-registry-read.ts`; ownership fields are defined in `src/agents/subagents/registry/subagent-registry.types.ts`. Session fallback fields are defined in `src/config/sessions/types.ts`.
298298

299299
Requested and terminal projections use the same persisted audience even if focus/controller ownership changes while the approval is pending. This guarantees terminal cleanup for every audience session stream that received the request projection. Resolution always targets the source approval ID; audience sessions never receive cloned approval state. Forwarded channel-message cleanup remains the separate delivery-locator follow-up below.
300300

‎qa/scenarios/agents/issue-109025-completion-policy-live.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ scenario:
3737
- docs/help/testing.md
3838
codeRefs:
3939
- src/agents/requester-tool-policy.ts
40-
- src/agents/subagent-announce-delivery.ts
41-
- src/agents/subagent-capabilities.ts
40+
- src/agents/subagents/announce/subagent-announce-delivery.ts
41+
- src/agents/subagents/spawn/subagent-capabilities.ts
4242
- src/agents/tools/sessions-yield-tool.ts
4343
execution:
4444
kind: flow

‎qa/scenarios/agents/issue-109025-sender-policy-live.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ scenario:
3030
- src/agents/conversation-capability-profile.ts
3131
- src/agents/requester-tool-policy.ts
3232
- src/agents/sender-tool-policy.ts
33-
- src/agents/subagent-capabilities.ts
33+
- src/agents/subagents/spawn/subagent-capabilities.ts
3434
execution:
3535
kind: flow
3636
suiteIsolation: isolated

‎qa/scenarios/agents/subagent-completion-direct-fallback.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ scenario:
3232
- docs/channels/qa-channel.md
3333
codeRefs:
3434
- src/agents/agent-run-terminal-reply.ts
35-
- src/agents/subagent-announce-delivery.ts
36-
- src/agents/subagent-registry-lifecycle.ts
35+
- src/agents/subagents/announce/subagent-announce-delivery.ts
36+
- src/agents/subagents/registry/subagent-registry-lifecycle.ts
3737
- extensions/qa-lab/src/providers/mock-openai/server.ts
3838
execution:
3939
kind: flow

‎qa/scenarios/agents/subagent-stale-child-links.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ scenario:
2020
- docs/help/testing.md
2121
codeRefs:
2222
- src/gateway/session-utils.ts
23-
- src/agents/subagent-run-liveness.ts
23+
- src/agents/subagents/registry/subagent-run-liveness.ts
2424
- extensions/qa-lab/src/gateway-child.ts
2525
execution:
2626
kind: flow

‎qa/scenarios/runtime/gateway-restart-multi-live.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ scenario:
3131
codeRefs:
3232
- extensions/qa-lab/src/suite-runtime-agent-session.ts
3333
- extensions/qa-lab/src/suite-runtime-gateway.ts
34-
- src/agents/main-session-restart-recovery.ts
34+
- src/agents/main-session-recovery/main-session-restart-recovery.ts
3535
execution:
3636
kind: flow
3737
summary: Run a fixture-backed audit with GPT-5.4 while replacing the Gateway child three times at durable wait checkpoints.

‎scripts/audit-seams.mts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ function describeSubagentSeamKinds(relativePath: string, source: string) {
686686

687687
const seamKinds = [];
688688
const isAnnounceDispatchPath =
689-
relativePath === "src/agents/subagent-announce.ts" ||
690-
relativePath === "src/agents/subagent-announce-dispatch.ts";
689+
relativePath === "src/agents/subagents/announce/subagent-announce.ts" ||
690+
relativePath === "src/agents/subagents/announce/subagent-announce-dispatch.ts";
691691
const importsSpawnRuntime = hasAnyImportSource(source, [
692692
"./subagent-spawn.js",
693693
"./acp-spawn.js",
@@ -718,6 +718,8 @@ function describeSubagentSeamKinds(relativePath: string, source: string) {
718718
const importsAnnounceDelivery = hasAnyImportSource(source, [
719719
"./subagent-announce.js",
720720
"./subagent-announce-dispatch.js",
721+
"../announce/subagent-announce.js",
722+
"../announce/subagent-announce-dispatch.js",
721723
"./subagent-announce-queue.js",
722724
"../infra/outbound/bound-delivery-router.js",
723725
"../utils/delivery-context.shared.js",

‎scripts/bench-agent-concurrency-worker.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import os from "node:os";
33
import path from "node:path";
44
import { performance } from "node:perf_hooks";
55
import { pathToFileURL } from "node:url";
6-
import type { SubagentRunRecord } from "../src/agents/subagent-registry.types.js";
6+
import type { SubagentRunRecord } from "../src/agents/subagents/registry/subagent-registry.types.js";
77
import type { DB as OpenClawStateKyselyDatabase } from "../src/state/openclaw-state-db.generated.js";
88
import {
99
WORKER_RESULT_SENTINEL,
@@ -102,7 +102,7 @@ async function drainSpawnSampleRootWork(
102102

103103
async function resetRuntime(persist: boolean): Promise<void> {
104104
const [subagents, tasks, stateDb, agentDb] = await Promise.all([
105-
import("../src/agents/subagent-registry.test-helpers.js"),
105+
import("../src/agents/subagents/registry/subagent-registry.test-helpers.js"),
106106
import("../src/tasks/task-runtime.test-helpers.js"),
107107
import("../src/state/openclaw-state-db.js"),
108108
import("../src/state/openclaw-agent-db.js"),
@@ -184,8 +184,8 @@ async function configureSpawnRuntime(
184184
callGateway: typeof import("../src/gateway/call.js").callGateway,
185185
): Promise<void> {
186186
const [subagents, registry, taskStore, flowStore] = await Promise.all([
187-
import("../src/agents/subagent-registry.test-helpers.js"),
188-
import("../src/agents/subagent-registry-memory.js"),
187+
import("../src/agents/subagents/registry/subagent-registry.test-helpers.js"),
188+
import("../src/agents/subagents/registry/subagent-registry-memory.js"),
189189
import("../src/tasks/task-registry.store.js"),
190190
import("../src/tasks/task-flow-registry.store.test-support.js"),
191191
]);
@@ -315,7 +315,7 @@ async function runSpawnSample(
315315
): Promise<Sample> {
316316
const [pipeline, registry] = await Promise.all([
317317
import("../src/agents/spawn-pipeline.js"),
318-
import("../src/agents/subagent-registry-memory.js"),
318+
import("../src/agents/subagents/registry/subagent-registry-memory.js"),
319319
]);
320320
await resetRuntime(mode === "durable");
321321
const barrier = createTerminalWaitBarrier();
@@ -595,8 +595,8 @@ async function runSweepSample(childCount: number): Promise<Sample> {
595595
{ getSubagentRunsForChildSession, subagentRuns: runs },
596596
{ createSubagentRegistrySweeper },
597597
] = await Promise.all([
598-
import("../src/agents/subagent-registry-memory.js"),
599-
import("../src/agents/subagent-registry-sweeper.js"),
598+
import("../src/agents/subagents/registry/subagent-registry-memory.js"),
599+
import("../src/agents/subagents/registry/subagent-registry-sweeper.js"),
600600
]);
601601
const now = Date.now();
602602
runs.clear();
@@ -694,7 +694,7 @@ async function runSweepSample(childCount: number): Promise<Sample> {
694694

695695
async function runDedupeSample(childCount: number): Promise<Sample> {
696696
const { dedupeLatestChildCompletionRows } =
697-
await import("../src/agents/subagent-announce-output.js");
697+
await import("../src/agents/subagents/announce/subagent-announce-output.js");
698698
const rowsForOrder = (generations: number[]) =>
699699
Array.from({ length: childCount }, (_, child) =>
700700
generations.map((generation) => ({

0 commit comments

Comments
 (0)