Skip to content

Commit 3502994

Browse files
committed
fix(cycles): continue shared seam extraction
1 parent 81235fd commit 3502994

17 files changed

Lines changed: 275 additions & 117 deletions

‎extensions/qa-lab/src/suite.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ export type QaSuiteRunParams = {
8686
concurrency?: number;
8787
};
8888

89-
async function startQaLabServerRuntime(
90-
params?: QaLabServerStartParams,
91-
): Promise<QaLabServerHandle> {
92-
const { startQaLabServer } = await import("./lab-server.js");
93-
return await startQaLabServer(params);
89+
function requireQaSuiteStartLab(startLab: QaSuiteStartLabFn | undefined): QaSuiteStartLabFn {
90+
if (startLab) {
91+
return startLab;
92+
}
93+
throw new Error(
94+
"QA suite requires startLab when no lab handle is provided; use the runtime launcher or pass startLab explicitly.",
95+
);
9496
}
9597

9698
const _QA_IMAGE_UNDERSTANDING_PNG_BASE64 =
@@ -1402,7 +1404,7 @@ export async function runQaSuite(params?: QaSuiteRunParams): Promise<QaSuiteResu
14021404

14031405
if (concurrency > 1 && selectedCatalogScenarios.length > 1) {
14041406
const ownsLab = !params?.lab;
1405-
const startLab = params?.startLab ?? startQaLabServerRuntime;
1407+
const startLab = requireQaSuiteStartLab(params?.startLab);
14061408
const lab =
14071409
params?.lab ??
14081410
(await startLab({
@@ -1452,6 +1454,7 @@ export async function runQaSuite(params?: QaSuiteRunParams): Promise<QaSuiteResu
14521454
claudeCliAuthMode: params?.claudeCliAuthMode,
14531455
scenarioIds: [scenario.id],
14541456
concurrency: 1,
1457+
startLab,
14551458
});
14561459
const scenarioResult: QaSuiteScenarioResult =
14571460
result.scenarios[0] ??
@@ -1547,10 +1550,10 @@ export async function runQaSuite(params?: QaSuiteRunParams): Promise<QaSuiteResu
15471550
}
15481551

15491552
const ownsLab = !params?.lab;
1550-
const startLab = params?.startLab ?? startQaLabServerRuntime;
1553+
const startLab = params?.startLab;
15511554
const lab =
15521555
params?.lab ??
1553-
(await startLab({
1556+
(await requireQaSuiteStartLab(startLab)({
15541557
repoRoot,
15551558
host: "127.0.0.1",
15561559
port: 0,

‎src/agents/harness/selection.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AgentEmbeddedHarnessConfig } from "../../config/types.agents-share
33
import { createSubsystemLogger } from "../../logging/subsystem.js";
44
import { normalizeAgentId } from "../../routing/session-key.js";
55
import { listAgentEntries, resolveSessionAgentIds } from "../agent-scope.js";
6-
import type { CompactEmbeddedPiSessionParams } from "../pi-embedded-runner/compact.js";
6+
import type { CompactEmbeddedPiSessionParams } from "../pi-embedded-runner/compact.types.js";
77
import type {
88
EmbeddedRunAttemptParams,
99
EmbeddedRunAttemptResult,

‎src/agents/harness/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CompactEmbeddedPiSessionParams } from "../pi-embedded-runner/compact.js";
1+
import type { CompactEmbeddedPiSessionParams } from "../pi-embedded-runner/compact.types.js";
22
import type {
33
EmbeddedRunAttemptParams,
44
EmbeddedRunAttemptResult,

‎src/agents/pi-embedded-runner/compact.ts‎

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
estimateTokens,
88
SessionManager,
99
} from "@mariozechner/pi-coding-agent";
10-
import type { ReasoningLevel, ThinkLevel } from "../../auto-reply/thinking.js";
10+
import type { ThinkLevel } from "../../auto-reply/thinking.js";
1111
import { resolveChannelCapabilities } from "../../config/channel-capabilities.js";
1212
import type { OpenClawConfig } from "../../config/config.js";
1313
import {
@@ -33,7 +33,7 @@ import {
3333
transformProviderSystemPrompt,
3434
} from "../../plugins/provider-runtime.js";
3535
import type { ProviderRuntimeModel } from "../../plugins/types.js";
36-
import { type enqueueCommand, enqueueCommandInLane } from "../../process/command-queue.js";
36+
import { enqueueCommandInLane } from "../../process/command-queue.js";
3737
import { isCronSessionKey, isSubagentSessionKey } from "../../routing/session-key.js";
3838
import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js";
3939
import { buildTtsSystemPromptHint } from "../../tts/tts.js";
@@ -42,7 +42,6 @@ import { normalizeMessageChannel } from "../../utils/message-channel.js";
4242
import { isReasoningTagProvider } from "../../utils/provider-utils.js";
4343
import { resolveOpenClawAgentDir } from "../agent-paths.js";
4444
import { resolveSessionAgentIds } from "../agent-scope.js";
45-
import type { ExecElevatedDefaults } from "../bash-tools.js";
4645
import { makeBootstrapWarn, resolveBootstrapContextForRun } from "../bootstrap-files.js";
4746
import {
4847
listChannelSupportedActions,
@@ -95,11 +94,11 @@ import {
9594
applySkillEnvOverrides,
9695
applySkillEnvOverridesFromSnapshot,
9796
resolveSkillsPromptForRun,
98-
type SkillSnapshot,
9997
} from "../skills.js";
10098
import { resolveSystemPromptOverride } from "../system-prompt-override.js";
10199
import { resolveTranscriptPolicy } from "../transcript-policy.js";
102100
import { classifyCompactionReason, resolveCompactionFailureReason } from "./compact-reasons.js";
101+
import type { CompactEmbeddedPiSessionParams, CompactionMessageMetrics } from "./compact.types.js";
103102
import {
104103
asCompactionHookRunner,
105104
buildBeforeCompactionHookMetrics,
@@ -151,68 +150,7 @@ import { splitSdkTools } from "./tool-split.js";
151150
import type { EmbeddedPiCompactResult } from "./types.js";
152151
import { mapThinkingLevel } from "./utils.js";
153152
import { flushPendingToolResultsAfterIdle } from "./wait-for-idle-before-flush.js";
154-
155-
export type CompactEmbeddedPiSessionParams = {
156-
sessionId: string;
157-
runId?: string;
158-
sessionKey?: string;
159-
messageChannel?: string;
160-
messageProvider?: string;
161-
agentAccountId?: string;
162-
currentChannelId?: string;
163-
currentThreadTs?: string;
164-
currentMessageId?: string | number;
165-
/** Trusted sender id from inbound context for scoped message-tool discovery. */
166-
senderId?: string;
167-
senderName?: string;
168-
senderUsername?: string;
169-
senderE164?: string;
170-
authProfileId?: string;
171-
/** Group id for channel-level tool policy resolution. */
172-
groupId?: string | null;
173-
/** Group channel label (e.g. #general) for channel-level tool policy resolution. */
174-
groupChannel?: string | null;
175-
/** Group space label (e.g. guild/team id) for channel-level tool policy resolution. */
176-
groupSpace?: string | null;
177-
/** Parent session key for subagent policy inheritance. */
178-
spawnedBy?: string | null;
179-
/** Whether the sender is an owner (required for owner-only tools). */
180-
senderIsOwner?: boolean;
181-
sessionFile: string;
182-
/** Optional caller-observed live prompt tokens used for compaction diagnostics. */
183-
currentTokenCount?: number;
184-
workspaceDir: string;
185-
agentDir?: string;
186-
config?: OpenClawConfig;
187-
skillsSnapshot?: SkillSnapshot;
188-
provider?: string;
189-
model?: string;
190-
thinkLevel?: ThinkLevel;
191-
reasoningLevel?: ReasoningLevel;
192-
bashElevated?: ExecElevatedDefaults;
193-
customInstructions?: string;
194-
tokenBudget?: number;
195-
force?: boolean;
196-
trigger?: "budget" | "overflow" | "manual";
197-
diagId?: string;
198-
attempt?: number;
199-
maxAttempts?: number;
200-
lane?: string;
201-
enqueue?: typeof enqueueCommand;
202-
extraSystemPrompt?: string;
203-
ownerNumbers?: string[];
204-
abortSignal?: AbortSignal;
205-
/** Allow runtime plugins for this compaction to late-bind the gateway subagent. */
206-
allowGatewaySubagentBinding?: boolean;
207-
};
208-
209-
type CompactionMessageMetrics = {
210-
messages: number;
211-
historyTextChars: number;
212-
toolResultChars: number;
213-
estTokens?: number;
214-
contributors: Array<{ role: string; chars: number; tool?: string }>;
215-
};
153+
export type { CompactEmbeddedPiSessionParams } from "./compact.types.js";
216154

217155
function hasRealConversationContent(
218156
msg: AgentMessage,
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import type { ReasoningLevel, ThinkLevel } from "../../auto-reply/thinking.js";
2+
import type { OpenClawConfig } from "../../config/config.js";
3+
import type { enqueueCommand } from "../../process/command-queue.js";
4+
import type { ExecElevatedDefaults } from "../bash-tools.js";
5+
import type { SkillSnapshot } from "../skills.js";
6+
7+
export type CompactEmbeddedPiSessionParams = {
8+
sessionId: string;
9+
runId?: string;
10+
sessionKey?: string;
11+
messageChannel?: string;
12+
messageProvider?: string;
13+
agentAccountId?: string;
14+
currentChannelId?: string;
15+
currentThreadTs?: string;
16+
currentMessageId?: string | number;
17+
/** Trusted sender id from inbound context for scoped message-tool discovery. */
18+
senderId?: string;
19+
senderName?: string;
20+
senderUsername?: string;
21+
senderE164?: string;
22+
authProfileId?: string;
23+
/** Group id for channel-level tool policy resolution. */
24+
groupId?: string | null;
25+
/** Group channel label (e.g. #general) for channel-level tool policy resolution. */
26+
groupChannel?: string | null;
27+
/** Group space label (e.g. guild/team id) for channel-level tool policy resolution. */
28+
groupSpace?: string | null;
29+
/** Parent session key for subagent policy inheritance. */
30+
spawnedBy?: string | null;
31+
/** Whether the sender is an owner (required for owner-only tools). */
32+
senderIsOwner?: boolean;
33+
sessionFile: string;
34+
/** Optional caller-observed live prompt tokens used for compaction diagnostics. */
35+
currentTokenCount?: number;
36+
workspaceDir: string;
37+
agentDir?: string;
38+
config?: OpenClawConfig;
39+
skillsSnapshot?: SkillSnapshot;
40+
provider?: string;
41+
model?: string;
42+
thinkLevel?: ThinkLevel;
43+
reasoningLevel?: ReasoningLevel;
44+
bashElevated?: ExecElevatedDefaults;
45+
customInstructions?: string;
46+
tokenBudget?: number;
47+
force?: boolean;
48+
trigger?: "budget" | "overflow" | "manual";
49+
diagId?: string;
50+
attempt?: number;
51+
maxAttempts?: number;
52+
lane?: string;
53+
enqueue?: typeof enqueueCommand;
54+
extraSystemPrompt?: string;
55+
ownerNumbers?: string[];
56+
abortSignal?: AbortSignal;
57+
/** Allow runtime plugins for this compaction to late-bind the gateway subagent. */
58+
allowGatewaySubagentBinding?: boolean;
59+
};
60+
61+
export type CompactionMessageMetrics = {
62+
messages: number;
63+
historyTextChars: number;
64+
toolResultChars: number;
65+
estTokens?: number;
66+
contributors: Array<{ role: string; chars: number; tool?: string }>;
67+
};

‎src/agents/pi-embedded-runner/run/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
44
import type { ThinkLevel } from "../../../auto-reply/thinking.js";
55
import type { SessionSystemPromptReport } from "../../../config/sessions/types.js";
66
import type { ContextEngine, ContextEnginePromptCacheInfo } from "../../../context-engine/types.js";
7-
import type { PluginHookBeforeAgentStartResult } from "../../../plugins/types.js";
7+
import type { PluginHookBeforeAgentStartResult } from "../../../plugins/hook-before-agent-start.types.js";
88
import type { MessagingToolSend } from "../../pi-embedded-messaging.js";
99
import type { ToolErrorSummary } from "../../tool-error-summary.js";
1010
import type { NormalizedUsage } from "../../usage.js";
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type { OpenClawConfig } from "../../config/config.js";
2+
import type { SandboxBackendHandle, SandboxBackendId } from "./backend-handle.types.js";
3+
import type { SandboxRegistryEntry } from "./registry.js";
4+
import type { SandboxConfig } from "./types.js";
5+
6+
export type SandboxBackendRuntimeInfo = {
7+
running: boolean;
8+
actualConfigLabel?: string;
9+
configLabelMatch: boolean;
10+
};
11+
12+
export type SandboxBackendManager = {
13+
describeRuntime(params: {
14+
entry: SandboxRegistryEntry;
15+
config: OpenClawConfig;
16+
agentId?: string;
17+
}): Promise<SandboxBackendRuntimeInfo>;
18+
removeRuntime(params: {
19+
entry: SandboxRegistryEntry;
20+
config: OpenClawConfig;
21+
agentId?: string;
22+
}): Promise<void>;
23+
};
24+
25+
export type CreateSandboxBackendParams = {
26+
sessionKey: string;
27+
scopeKey: string;
28+
workspaceDir: string;
29+
agentWorkspaceDir: string;
30+
cfg: SandboxConfig;
31+
};
32+
33+
export type SandboxBackendFactory = (
34+
params: CreateSandboxBackendParams,
35+
) => Promise<SandboxBackendHandle>;
36+
37+
export type SandboxBackendRegistration =
38+
| SandboxBackendFactory
39+
| {
40+
factory: SandboxBackendFactory;
41+
manager?: SandboxBackendManager;
42+
};
43+
44+
export type RegisteredSandboxBackend = {
45+
factory: SandboxBackendFactory;
46+
manager?: SandboxBackendManager;
47+
};
48+
49+
export type { SandboxBackendHandle, SandboxBackendId } from "./backend-handle.types.js";

‎src/agents/sandbox/ssh-backend.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
SandboxBackendCommandResult,
77
SandboxBackendHandle,
88
SandboxBackendManager,
9-
} from "./backend.js";
9+
} from "./backend.types.js";
1010
import { resolveSandboxConfigForAgent } from "./config.js";
1111
import {
1212
createRemoteShellSandboxFsBridge,

‎src/agents/subagent-announce-delivery.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { resolveAnnounceOrigin, type DeliveryContext } from "./subagent-announce
3838
import { type AnnounceQueueItem, enqueueAnnounce } from "./subagent-announce-queue.js";
3939
import { getSubagentDepthFromSessionStore } from "./subagent-depth.js";
4040
import { resolveRequesterStoreKey } from "./subagent-requester-store-key.js";
41-
import type { SpawnSubagentMode } from "./subagent-spawn.js";
41+
import type { SpawnSubagentMode } from "./subagent-spawn.types.js";
4242

4343
export { resolveAnnounceOrigin } from "./subagent-announce-origin.js";
4444

‎src/agents/subagent-announce.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
waitForEmbeddedPiRunEnd,
3737
} from "./subagent-announce.runtime.js";
3838
import { getSubagentDepthFromSessionStore } from "./subagent-depth.js";
39-
import type { SpawnSubagentMode } from "./subagent-spawn.js";
39+
import type { SpawnSubagentMode } from "./subagent-spawn.types.js";
4040
import { isAnnounceSkip } from "./tools/sessions-send-tokens.js";
4141

4242
type SubagentAnnounceDeps = {

0 commit comments

Comments
 (0)