Skip to content

Commit 8bf62e7

Browse files
authored
refactor(ui): derive gateway types from protocol and consolidate navigation/error helpers (#120348)
* refactor(protocol): derive shared gateway types * refactor(ui): consolidate navigation click handling * refactor(ui): centralize UI state and error helpers
1 parent fb0812c commit 8bf62e7

84 files changed

Lines changed: 447 additions & 562 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.

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ aa8a411ad37c1d1143b67376bf2d20255b9eedff61d80815f42e4f8ed7bd8e58 module/secret-
122122
57dcb1462d4c4f9a98d934c4ca975b163d704758af9821a64001ff3ac05637c3 module/secret-input-runtime
123123
dc0ee07d392a85c218939000b28c0138f139215da00f5592b34a68ba8e29a25d module/secret-ref-runtime
124124
f97549081955e412d8eb64070c64bb5921bb1324744d824db05767d3adcce403 module/security-runtime
125-
1d4a6e7e97a21c95c47be75e0e1745daa42d6ea37d956dce3c114277f42c9906 module/session-catalog
125+
4bfa843c91a04a4cff0496ed89d9b9481c07b8dbdce6de784e2743f4f66afc1d module/session-catalog
126126
50f5e344f98c27570b7a30e32a906b612e2383d21f102e88cd93e1d5425a6de9 module/session-discussion
127127
f112bdabc51ba8659b37d0a6f6a32a2b1d471e5b49b56e108bf750ec55a7ea71 module/session-store-runtime
128128
36affbe151431a6141664b6838e20f2d121ff210d57a3c1b4b41a8818b5c81d8 module/setup

‎packages/gateway-protocol/src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export {
2929
SessionToolOverridesSchema,
3030
type SessionCreatedActor,
3131
type SessionRow,
32+
type SessionRunStatus,
3233
type SessionToolOverrides,
3334
} from "./schema/sessions-row.js";
3435
export * from "./schema/session-classification.js";

‎packages/gateway-protocol/src/schema/logs-chat.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ const RunToolBindingsSchema = Type.Record(
109109
{ maxProperties: 16 },
110110
);
111111

112+
const QUEUE_MODES = ["steer", "followup", "collect", "interrupt"] as const;
113+
export type QueueMode = (typeof QUEUE_MODES)[number];
114+
112115
/** User-to-agent send request; idempotency key lets clients safely retry transport failures. */
113116
export const ChatSendParamsSchema = closedObject({
114117
sessionKey: ChatSendSessionKeyString,
@@ -120,7 +123,7 @@ export const ChatSendParamsSchema = closedObject({
120123
// One-turn override for auto fast-mode cutoff seconds.
121124
fastAutoOnSeconds: Type.Optional(Type.Integer({ minimum: 1 })),
122125
// One-turn override for active-run queue admission.
123-
queueMode: Type.Optional(Type.String({ enum: ["steer", "followup", "collect", "interrupt"] })),
126+
queueMode: Type.Optional(Type.String({ enum: [...QUEUE_MODES] })),
124127
deliver: Type.Optional(Type.Boolean()),
125128
originatingChannel: Type.Optional(Type.String()),
126129
originatingTo: Type.Optional(Type.String()),

‎packages/gateway-protocol/src/schema/sessions-row.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,4 @@ export const SessionRowSchema = Type.Object(
135135
export type SessionCreatedActor = Static<typeof SessionCreatedActorSchema>;
136136
export type SessionToolOverrides = Static<typeof SessionToolOverridesSchema>;
137137
export type SessionRow = Static<typeof SessionRowSchema>;
138+
export type SessionRunStatus = NonNullable<SessionRow["status"]>;

‎packages/gateway-protocol/src/schema/sessions.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
SessionToolOverridesSchema,
1818
type SessionCreatedActor,
1919
type SessionRow,
20+
type SessionRunStatus,
2021
type SessionToolOverrides,
2122
} from "./sessions-row.js";
2223

‎src/agents/openclaw-tools.subagents.sessions-spawn.test-harness.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Shared sessions_spawn test harness for gateway, registry, and lifecycle mocks.
22
import { vi, type Mock } from "vitest";
3+
import type { SessionRunStatus } from "../../packages/gateway-protocol/src/schema/sessions-row.js";
34
import type { SubagentLifecycleHookRunner } from "../plugins/hooks.js";
45
import { resolveRequesterStoreKey } from "./subagent-requester-store-key.js";
56

@@ -22,7 +23,7 @@ type TestSessionEntry = {
2223
updatedAt: number;
2324
startedAt?: number;
2425
endedAt?: number;
25-
status?: "running" | "done" | "failed" | "killed" | "timeout";
26+
status?: SessionRunStatus;
2627
};
2728
type SessionsSpawnGatewayMockOptions = {
2829
includeSessionsList?: boolean;

‎src/agents/tools/sessions-helpers.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export {
2121
shouldResolveSessionIdInput,
2222
} from "./sessions-resolution.js";
2323
import { normalizeOptionalString, type FastMode } from "@openclaw/normalization-core/string-coerce";
24+
import type { SessionRunStatus } from "../../../packages/gateway-protocol/src/schema/sessions-row.js";
2425
import { getRuntimeConfig } from "../../config/config.js";
2526
import type { OpenClawConfig } from "../../config/types.openclaw.js";
2627
import { parseRawSessionConversationRef } from "../../sessions/session-key-utils.js";
@@ -37,9 +38,6 @@ type SessionListDeliveryContext = {
3738
threadId?: string | number;
3839
};
3940

40-
/** Compact run status shown by session tools. */
41-
export type SessionRunStatus = "running" | "done" | "failed" | "killed" | "timeout";
42-
4341
/** Full Gateway session row consumed by session orchestration internals. */
4442
export type GatewaySessionListRow = {
4543
key: string;

‎src/agents/tools/sessions-list-tool.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "@openclaw/normalization-core/string-coerce";
1010
import pMap from "p-map";
1111
import { Type } from "typebox";
12+
import type { SessionRunStatus } from "../../../packages/gateway-protocol/src/schema/sessions-row.js";
1213
import { getRuntimeConfig } from "../../config/config.js";
1314
import type { SessionEntry } from "../../config/sessions/types.js";
1415
import type { OpenClawConfig } from "../../config/types.openclaw.js";
@@ -47,7 +48,6 @@ import {
4748
resolveSandboxedSessionToolContext,
4849
type GatewaySessionListRow,
4950
type SessionListRow,
50-
type SessionRunStatus,
5151
} from "./sessions-helpers.js";
5252

5353
const SessionsListToolSchema = Type.Object({

‎src/auto-reply/reply/directive-handling.parse.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { FastMode } from "@openclaw/normalization-core/string-coerce";
22
// Parses inline reply directives into typed execution and routing options.
3+
import type { QueueMode } from "../../../packages/gateway-protocol/src/schema/logs-chat.js";
34
import type { ExecAsk, ExecSecurity, ExecTarget } from "../../infra/exec-approvals.js";
45
import { extractModelDirective } from "../model.js";
56
import { isSessionDefaultDirectiveValue } from "../thinking.js";
@@ -21,7 +22,7 @@ import {
2122
extractVerboseDirective,
2223
} from "./directives.js";
2324
import { extractQueueDirective } from "./queue/directive.js";
24-
import type { QueueDropPolicy, QueueMode } from "./queue/types.js";
25+
import type { QueueDropPolicy } from "./queue/types.js";
2526

2627
const NATIVE_REPLY_DIRECTIVE_COMMANDS = {
2728
think: true,

‎src/auto-reply/reply/get-reply.types.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import type { QueueMode } from "../../../packages/gateway-protocol/src/schema/logs-chat.js";
12
import type { SessionToolOverrides } from "../../config/sessions/types.js";
23
// Shared get-reply type contracts for command, directive, and runtime layers.
34
import type { OpenClawConfig } from "../../config/types.openclaw.js";
45
import type { ReplyOptionsWithHeartbeatRunScope } from "../../infra/heartbeat-run-scope.js";
56
import type { GetReplyOptions } from "../get-reply-options.types.js";
67
import type { ReplyPayload } from "../reply-payload.js";
78
import type { MsgContext } from "../templating.js";
8-
import type { FollowupQueueDisposition, QueueMode } from "./queue/types.js";
9+
import type { FollowupQueueDisposition } from "./queue/types.js";
910
import type { ReplyOptionsWithOperationRunState } from "./reply-operation-run-state.js";
1011
import type { ReplyOperation } from "./reply-run-registry.js";
1112

0 commit comments

Comments
 (0)