Skip to content

Commit a6b8ff1

Browse files
author
Erick Kinnee
committed
fix(ui): expose runtime models in New Session
1 parent 5c295af commit a6b8ff1

72 files changed

Lines changed: 3197 additions & 691 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.

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6239,6 +6239,10 @@ public struct SessionRow: Codable, Sendable {
62396239
public let estimatedcostusd: Double?
62406240
public let model: String?
62416241
public let modelprovider: String?
6242+
public let thinkinglevel: String?
6243+
public let thinkinglevels: [[String: AnyCodable]]?
6244+
public let thinkingoptions: [String]?
6245+
public let thinkingdefault: String?
62426246
public let tooloverrides: [String: AnyCodable]?
62436247

62446248
public init(
@@ -6310,6 +6314,10 @@ public struct SessionRow: Codable, Sendable {
63106314
estimatedcostusd: Double? = nil,
63116315
model: String? = nil,
63126316
modelprovider: String? = nil,
6317+
thinkinglevel: String? = nil,
6318+
thinkinglevels: [[String: AnyCodable]]? = nil,
6319+
thinkingoptions: [String]? = nil,
6320+
thinkingdefault: String? = nil,
63136321
tooloverrides: [String: AnyCodable]? = nil)
63146322
{
63156323
self.key = key
@@ -6380,6 +6388,10 @@ public struct SessionRow: Codable, Sendable {
63806388
self.estimatedcostusd = estimatedcostusd
63816389
self.model = model
63826390
self.modelprovider = modelprovider
6391+
self.thinkinglevel = thinkinglevel
6392+
self.thinkinglevels = thinkinglevels
6393+
self.thinkingoptions = thinkingoptions
6394+
self.thinkingdefault = thinkingdefault
63836395
self.tooloverrides = tooloverrides
63846396
}
63856397

@@ -6452,6 +6464,10 @@ public struct SessionRow: Codable, Sendable {
64526464
case estimatedcostusd = "estimatedCostUsd"
64536465
case model
64546466
case modelprovider = "modelProvider"
6467+
case thinkinglevel = "thinkingLevel"
6468+
case thinkinglevels = "thinkingLevels"
6469+
case thinkingoptions = "thinkingOptions"
6470+
case thinkingdefault = "thinkingDefault"
64556471
case tooloverrides = "toolOverrides"
64566472
}
64576473
}
@@ -9122,6 +9138,7 @@ public struct SessionsCreateResult: Codable, Sendable {
91229138
public let key: String
91239139
public let sessionid: String?
91249140
public let entry: [String: AnyCodable]?
9141+
public let session: SessionRow?
91259142
public let runstarted: Bool?
91269143
public let runid: String?
91279144
public let messageseq: Int?
@@ -9133,6 +9150,7 @@ public struct SessionsCreateResult: Codable, Sendable {
91339150
key: String,
91349151
sessionid: String? = nil,
91359152
entry: [String: AnyCodable]? = nil,
9153+
session: SessionRow? = nil,
91369154
runstarted: Bool? = nil,
91379155
runid: String? = nil,
91389156
messageseq: Int? = nil,
@@ -9143,6 +9161,7 @@ public struct SessionsCreateResult: Codable, Sendable {
91439161
self.key = key
91449162
self.sessionid = sessionid
91459163
self.entry = entry
9164+
self.session = session
91469165
self.runstarted = runstarted
91479166
self.runid = runid
91489167
self.messageseq = messageseq
@@ -9155,6 +9174,7 @@ public struct SessionsCreateResult: Codable, Sendable {
91559174
case key
91569175
case sessionid = "sessionId"
91579176
case entry
9177+
case session
91589178
case runstarted = "runStarted"
91599179
case runid = "runId"
91609180
case messageseq = "messageSeq"
@@ -14437,19 +14457,22 @@ public struct ModelsListParams: Codable, Sendable {
1443714457
public let agentid: String?
1443814458
public let includeprovidercapabilities: Bool?
1443914459
public let preparedonly: Bool?
14460+
public let waitforruntimediscovery: Bool?
1444014461
public let refresh: Bool?
1444114462
public let view: AnyCodable?
1444214463

1444314464
public init(
1444414465
agentid: String? = nil,
1444514466
includeprovidercapabilities: Bool? = nil,
1444614467
preparedonly: Bool? = nil,
14468+
waitforruntimediscovery: Bool? = nil,
1444714469
refresh: Bool? = nil,
1444814470
view: AnyCodable? = nil)
1444914471
{
1445014472
self.agentid = agentid
1445114473
self.includeprovidercapabilities = includeprovidercapabilities
1445214474
self.preparedonly = preparedonly
14475+
self.waitforruntimediscovery = waitforruntimediscovery
1445314476
self.refresh = refresh
1445414477
self.view = view
1445514478
}
@@ -14458,6 +14481,7 @@ public struct ModelsListParams: Codable, Sendable {
1445814481
case agentid = "agentId"
1445914482
case includeprovidercapabilities = "includeProviderCapabilities"
1446014483
case preparedonly = "preparedOnly"
14484+
case waitforruntimediscovery = "waitForRuntimeDiscovery"
1446114485
case refresh
1446214486
case view
1446314487
}

‎packages/gateway-protocol/src/schema/agents-models-skills.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ describe("ModelsListParamsSchema", () => {
224224
{
225225
preparedOnly: true,
226226
},
227+
{
228+
preparedOnly: true,
229+
waitForRuntimeDiscovery: true,
230+
},
231+
{
232+
waitForRuntimeDiscovery: false,
233+
},
227234
{
228235
refresh: true,
229236
view: "all",
@@ -234,6 +241,8 @@ describe("ModelsListParamsSchema", () => {
234241
{ view: "provider-route" },
235242
{ agentId: "" },
236243
{ preparedOnly: true, refresh: true },
244+
{ waitForRuntimeDiscovery: true },
245+
{ preparedOnly: false, waitForRuntimeDiscovery: true },
237246
);
238247
});
239248
});

‎packages/gateway-protocol/src/schema/agents-models-skills.ts‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const GatewayAgentRuntimeSchema = closedObject({
4343
]),
4444
});
4545

46-
const GatewayThinkingLevelOptionSchema = closedObject({
46+
export const GatewayThinkingLevelOptionSchema = closedObject({
4747
id: NonEmptyString,
4848
label: NonEmptyString,
4949
});
@@ -266,6 +266,8 @@ export const ModelsListParamsSchema = Type.Object(
266266
includeProviderCapabilities: Type.Optional(Type.Boolean()),
267267
/** Reuse prepared/cached facts without starting provider discovery. */
268268
preparedOnly: Type.Optional(Type.Boolean()),
269+
/** Return retryable unavailable until post-ready runtime discovery publishes. */
270+
waitForRuntimeDiscovery: Type.Optional(Type.Boolean()),
269271
/** Force replacement of a completed full-catalog generation. */
270272
refresh: Type.Optional(Type.Boolean()),
271273
view: Type.Optional(
@@ -279,10 +281,28 @@ export const ModelsListParamsSchema = Type.Object(
279281
},
280282
{
281283
additionalProperties: false,
282-
not: {
283-
properties: { preparedOnly: { const: true }, refresh: { const: true } },
284-
required: ["preparedOnly", "refresh"],
285-
},
284+
allOf: [
285+
{
286+
not: {
287+
properties: { preparedOnly: { const: true }, refresh: { const: true } },
288+
required: ["preparedOnly", "refresh"],
289+
},
290+
},
291+
{
292+
anyOf: [
293+
{
294+
not: {
295+
properties: { waitForRuntimeDiscovery: { const: true } },
296+
required: ["waitForRuntimeDiscovery"],
297+
},
298+
},
299+
{
300+
properties: { preparedOnly: { const: true } },
301+
required: ["preparedOnly"],
302+
},
303+
],
304+
},
305+
],
286306
},
287307
);
288308

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { describe, expect, it } from "vitest";
22
import {
33
SESSION_CREATE_IDEMPOTENCY_RETENTION_MS,
44
SESSION_CREATE_RETRY_WINDOW_MS,
5+
SessionRowSchema,
6+
SessionsCreateResultSchema,
57
validateSessionsCreateParams,
68
} from "../index.js";
79

@@ -60,4 +62,14 @@ describe("sessions.create schema", () => {
6062
expect(validateSessionsCreateParams({ agentId: "main", toolOverrides })).toBe(false);
6163
},
6264
);
65+
66+
it("declares model-control fields on the canonical session row", () => {
67+
expect(SessionRowSchema.properties).toMatchObject({
68+
thinkingLevel: expect.any(Object),
69+
thinkingLevels: expect.any(Object),
70+
thinkingOptions: expect.any(Object),
71+
thinkingDefault: expect.any(Object),
72+
});
73+
expect(SessionsCreateResultSchema.properties.session).toBeDefined();
74+
});
6375
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Static } from "typebox";
22
import { Type } from "typebox";
3+
import { GatewayThinkingLevelOptionSchema } from "./agents-models-skills.js";
34
import { closedObject } from "./closed-object.js";
45
import { NonEmptyString } from "./primitives.js";
56
import { SessionClassificationSchema, SessionPeerKindSchema } from "./session-classification.js";
@@ -151,6 +152,10 @@ export const SessionRowSchema = Type.Object(
151152
estimatedCostUsd: Type.Optional(Type.Number()),
152153
model: Type.Optional(Type.String()),
153154
modelProvider: Type.Optional(Type.String()),
155+
thinkingLevel: Type.Optional(NonEmptyString),
156+
thinkingLevels: Type.Optional(Type.Array(GatewayThinkingLevelOptionSchema)),
157+
thinkingOptions: Type.Optional(Type.Array(NonEmptyString)),
158+
thinkingDefault: Type.Optional(NonEmptyString),
154159
toolOverrides: Type.Optional(SessionToolOverridesSchema),
155160
},
156161
{ additionalProperties: true },

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PluginJsonValueSchema } from "./plugins.js";
88
import { NonEmptyString, SessionLabelString } from "./primitives.js";
99
import { SessionsCreateParamsSchema } from "./sessions-create.js";
1010
import { SessionsRecoverParamsSchema, SessionsRecoverResultSchema } from "./sessions-recover.js";
11-
import { SessionOwnerSchema } from "./sessions-row.js";
11+
import { SessionOwnerSchema, SessionRowSchema } from "./sessions-row.js";
1212

1313
export { SessionsCreateParamsSchema };
1414
export { SessionsRecoverParamsSchema, SessionsRecoverResultSchema };
@@ -493,6 +493,7 @@ export const SessionsCreateResultSchema = Type.Object(
493493
key: NonEmptyString,
494494
sessionId: Type.Optional(NonEmptyString),
495495
entry: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
496+
session: Type.Optional(SessionRowSchema),
496497
runStarted: Type.Optional(Type.Boolean()),
497498
runId: Type.Optional(NonEmptyString),
498499
messageSeq: Type.Optional(Type.Integer({ minimum: 1 })),

‎scripts/test-projects.test-support.mts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,30 @@ const CODEX_VERSION_CONTRACT_TEST_TARGETS = [
640640
"extensions/openai/openai-provider.test.ts",
641641
"test/scripts/codex-client-version-contract.test.ts",
642642
];
643+
const RUNTIME_PROVIDER_CATALOG_CONTRACT_TEST_TARGET =
644+
"src/plugins/bundled-runtime-provider-catalog.contract.test.ts";
645+
const RUNTIME_PROVIDER_CATALOG_OWNER_TEST_TARGETS = (
646+
[
647+
["extensions/arcee/index.ts", ["extensions/arcee/index.test.ts"]],
648+
[
649+
"extensions/google/provider-registration.ts",
650+
["extensions/google/provider-registration.test.ts"],
651+
],
652+
["extensions/litellm/index.ts", ["extensions/litellm/index.test.ts"]],
653+
["extensions/minimax/provider-registration.ts", ["extensions/minimax/index.test.ts"]],
654+
["extensions/openai/openai-provider.ts", ["extensions/openai/openai-provider.test.ts"]],
655+
["extensions/opencode/index.ts", ["extensions/opencode/index.test.ts"]],
656+
["extensions/opencode-go/index.ts", ["extensions/opencode-go/index.test.ts"]],
657+
["extensions/openrouter/index.ts", ["extensions/openrouter/index.test.ts"]],
658+
["extensions/qwen/index.ts", ["extensions/qwen/index.test.ts"]],
659+
] satisfies Array<[string, string[]]>
660+
).map(([source, targets]): [string, string[]] => [
661+
source,
662+
[...targets, RUNTIME_PROVIDER_CATALOG_CONTRACT_TEST_TARGET],
663+
]);
643664
const SOURCE_TEST_TARGETS = new Map([
644665
...PRECISE_SOURCE_TEST_TARGETS,
666+
...RUNTIME_PROVIDER_CATALOG_OWNER_TEST_TARGETS,
645667
["extensions/codex/package.json", CODEX_VERSION_CONTRACT_TEST_TARGETS],
646668
["extensions/codex/src/app-server/version.ts", CODEX_VERSION_CONTRACT_TEST_TARGETS],
647669
["src/test-utils/openclaw-test-state.ts", ["src/test-utils/openclaw-test-state.test.ts"]],

‎src/agents/model-catalog-provider-alias.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ function resolvePreparedModelCatalogProvider(
2020
return normalizedProvider;
2121
}
2222

23+
/** Canonicalizes a provider alias against the metadata captured with a prepared catalog. */
24+
export function canonicalizePreparedModelCatalogProvider(
25+
provider: string,
26+
metadataSnapshot: Pick<PluginMetadataSnapshot, "manifestRegistry">,
27+
): string {
28+
return resolvePreparedModelCatalogProvider(provider, metadataSnapshot, () => true);
29+
}
30+
2331
/** Runtime discovery follows identity aliases, not aliases that change the request route. */
2432
export function canonicalizePreparedModelRuntimeDiscoveryProvider(
2533
provider: string,

‎src/agents/model-catalog-route.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const platformEntry: ModelCatalogEntry = {
3939
contextWindow: 1_000_000,
4040
contextTokens: 272_000,
4141
reasoning: true,
42+
thinkingLevelMap: { off: "none", minimal: null, xhigh: "xhigh" },
4243
input: ["text", "image"],
4344
params: { platformOnly: true },
4445
compat: { supportsTools: false },
@@ -53,6 +54,7 @@ const chatGPTEntry: ModelCatalogEntry = {
5354
contextWindow: 400_000,
5455
contextTokens: 300_000,
5556
reasoning: true,
57+
thinkingLevelMap: { off: "none", minimal: null, xhigh: null },
5658
input: ["text"],
5759
params: { chatGPTOnly: true },
5860
compat: { supportsTools: true },
@@ -103,6 +105,7 @@ describe("projectModelCatalogEntryForRoute", () => {
103105
contextWindow: 1_000_000,
104106
contextTokens: 272_000,
105107
reasoning: true,
108+
thinkingLevelMap: { off: "none", minimal: null, xhigh: "xhigh" },
106109
input: ["text", "image"],
107110
});
108111

@@ -121,6 +124,7 @@ describe("projectModelCatalogEntryForRoute", () => {
121124
contextWindow: 400_000,
122125
contextTokens: 300_000,
123126
reasoning: true,
127+
thinkingLevelMap: { off: "none", minimal: null, xhigh: null },
124128
input: ["text"],
125129
});
126130
});

‎src/agents/model-catalog-route.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ export type ModelCatalogRouteProjection =
3636
type ModelCatalogLogicalOverrides = Partial<
3737
Pick<
3838
ModelCatalogEntry,
39-
"name" | "contextWindow" | "contextTokens" | "reasoning" | "configuredReasoning" | "input"
39+
| "name"
40+
| "contextWindow"
41+
| "contextTokens"
42+
| "reasoning"
43+
| "configuredReasoning"
44+
| "thinkingLevelMap"
45+
| "input"
4046
>
4147
>;
4248

@@ -69,6 +75,7 @@ export function resolveConfiguredModelCatalogOverrides(params: {
6975
...(model?.contextTokens !== undefined ? { contextTokens: model.contextTokens } : {}),
7076
...(model?.reasoning !== undefined ? { reasoning: model.reasoning } : {}),
7177
...(model?.reasoning !== undefined ? { configuredReasoning: model.reasoning } : {}),
78+
...(model?.thinkingLevelMap !== undefined ? { thinkingLevelMap: model.thinkingLevelMap } : {}),
7279
...(model?.input !== undefined ? { input: model.input } : {}),
7380
};
7481
return Object.keys(overrides).length > 0 ? overrides : undefined;
@@ -180,6 +187,9 @@ export function projectModelCatalogEntryForRoute(params: {
180187
...(donor?.contextWindow !== undefined ? { contextWindow: donor.contextWindow } : {}),
181188
...(donor?.contextTokens !== undefined ? { contextTokens: donor.contextTokens } : {}),
182189
...(donor?.reasoning !== undefined ? { reasoning: donor.reasoning } : {}),
190+
...(donor?.thinkingLevelMap !== undefined
191+
? { thinkingLevelMap: donor.thinkingLevelMap }
192+
: {}),
183193
...(donor?.input !== undefined ? { input: donor.input } : {}),
184194
},
185195
params.overrides,

0 commit comments

Comments
 (0)