Skip to content

Commit 589b1f6

Browse files
committed
docs: document subagent helpers
1 parent 600a57e commit 589b1f6

24 files changed

Lines changed: 120 additions & 20 deletions

src/agents/shell-snapshot.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Login-shell environment snapshot capture.
3+
*
4+
* Caches safe shell-derived environment variables while filtering secrets and stale snapshots.
5+
*/
16
import { spawn } from "node:child_process";
27
import { createHash } from "node:crypto";
38
import { statSync } from "node:fs";

src/agents/shell-utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Shell execution helpers.
3+
*
4+
* Resolves platform shell commands, sanitizes binary output, and exposes process-tree cleanup.
5+
*/
16
import { spawnSync } from "node:child_process";
27
import fs from "node:fs";
38
import path from "node:path";

src/agents/simple-completion-runtime.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Simple completion runtime preparation.
3+
*
4+
* Resolves agent model selection, auth, runtime policy, and missing-auth errors before simple completions run.
5+
*/
16
import type { ThinkLevel } from "../auto-reply/thinking.js";
27
import type { OpenClawConfig } from "../config/types.openclaw.js";
38
import { formatErrorMessage } from "../infra/errors.js";

src/agents/simple-completion-transport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Simple completion transport preparation.
3+
*
4+
* Registers provider-specific stream functions and rewrites models that need OpenClaw-managed transport semantics.
5+
*/
16
import type { OpenClawConfig } from "../config/types.openclaw.js";
27
import { getApiProvider } from "../llm/api-registry.js";
38
import type { Api, Model } from "../llm/types.js";

src/agents/spawn-requester-origin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Spawn requester origin resolver.
3+
*
4+
* Normalizes delivery targets and route bindings so spawned runs can attribute the requesting account/channel.
5+
*/
16
import type { ChatType } from "../channels/chat-type.js";
27
import type { OpenClawConfig } from "../config/types.openclaw.js";
38
import { resolveFirstBoundAccountId } from "../routing/bound-account-read.js";

src/agents/spawned-context.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
/**
2+
* Spawned run metadata helpers.
3+
*
4+
* Projects tool runtime context into persisted lineage, group routing, workspace, and inherited policy metadata.
5+
*/
16
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
27
import type { OpenClawConfig } from "../config/types.openclaw.js";
38
import { normalizeAgentId, parseAgentSessionKey } from "../routing/session-key.js";
49
import { resolveAgentWorkspaceDir } from "./agent-scope.js";
510

6-
// Normalized metadata passed from session-spawn tools into child run records.
7-
// It captures lineage, group routing, workspace inheritance, and inherited tool
8-
// policy without exposing the broader tool context object.
911
export type SpawnedRunMetadata = {
1012
spawnedBy?: string | null;
1113
groupId?: string | null;

src/agents/stream-compat.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
/**
2+
* Mutable assistant stream compatibility types.
3+
*
4+
* Shared by wrappers that decorate async iteration and final result resolution without changing providers.
5+
*/
16
import type { AssistantMessage, AssistantMessageEvent } from "../llm/types.js";
27

3-
// Mutable stream shape used by compatibility wrappers that decorate result()
4-
// and async iteration without changing provider stream implementations.
58
export interface MutableAssistantMessageEventStream extends AsyncIterable<AssistantMessageEvent> {
69
result: () => Promise<AssistantMessage>;
710
}

src/agents/stream-iterator-wrapper.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Async stream iterator wrapper.
3+
*
4+
* Lets stream decorators override next/return/throw while preserving the underlying iterator contract.
5+
*/
16
type StreamIterator<T> = AsyncIterator<T, unknown, unknown>;
27

38
// Optional return/throw handlers let stream wrappers observe cleanup and errors

src/agents/stream-message-shared.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Assistant stream message builders.
3+
*
4+
* Centralizes zero-cost usage records and assistant message construction for simple stream transports.
5+
*/
16
import type { AssistantMessage, StopReason, Usage } from "../llm/types.js";
27

38
type StreamModelDescriptor = {

src/agents/subagent-active-context.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Active subagent prompt context builder.
3+
*
4+
* Renders sanitized runtime-owned subagent state into system prompt additions.
5+
*/
16
import type { OpenClawConfig } from "../config/types.openclaw.js";
27
import { sanitizeForPromptLiteral } from "./sanitize-for-prompt.js";
38
import { listControlledSubagentRuns } from "./subagent-control.js";

0 commit comments

Comments
 (0)