Skip to content

Commit 74b8401

Browse files
committed
Merge branch 'shaw/more-cache-toolcalling' into develop
# Conflicts: # packages/agent/src/actions/trigger.ts # plugins/plugin-workflow/src/index.ts # plugins/plugin-workflow/src/services/workflow-dispatch.ts
2 parents 679af4b + 60293fa commit 74b8401

1,122 files changed

Lines changed: 14480 additions & 30050 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.

action-benchmark-report.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

biome.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@
6060
}
6161
}
6262
},
63+
{
64+
"includes": ["packages/ui/src/styles/styles.css"],
65+
"linter": {
66+
"rules": {
67+
"complexity": {
68+
"noImportantStyles": "off"
69+
},
70+
"style": {
71+
"noDescendingSpecificity": "off"
72+
}
73+
}
74+
}
75+
},
6376
{
6477
"includes": [
6578
"packages/training/src/benchmark/BenchmarkRunner.ts",

cloud/apps/api/agents/[id]/a2a/route.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { CORS_ALLOW_HEADERS, CORS_ALLOW_METHODS } from "@/lib/cors-constants";
1919
import { RateLimitPresets, rateLimit } from "@/lib/middleware/rate-limit-hono-cloudflare";
2020
import { calculateCost, estimateRequestCost, getProviderFromModel } from "@/lib/pricing";
2121
import {
22+
type AnthropicCotEnv,
2223
mergeAnthropicCotProviderOptions,
2324
parseThinkingBudgetFromCharacterSettings,
2425
resolveAnthropicThinkingBudgetTokens,
@@ -97,6 +98,17 @@ function generateAgentCard(character: UserCharacter, baseUrl: string) {
9798

9899
const app = new Hono<AppEnv>();
99100

101+
function getAnthropicCotEnv(env: AppEnv["Bindings"]): AnthropicCotEnv {
102+
return {
103+
ANTHROPIC_COT_BUDGET:
104+
typeof env.ANTHROPIC_COT_BUDGET === "string" ? env.ANTHROPIC_COT_BUDGET : undefined,
105+
ANTHROPIC_COT_BUDGET_MAX:
106+
typeof env.ANTHROPIC_COT_BUDGET_MAX === "string"
107+
? env.ANTHROPIC_COT_BUDGET_MAX
108+
: undefined,
109+
};
110+
}
111+
100112
app.get("/", rateLimit(RateLimitPresets.STANDARD), async (c) => {
101113
const id = c.req.param("id");
102114
if (!id) return c.json({ error: "Missing id" }, 400);
@@ -244,7 +256,7 @@ async function handleChat(
244256

245257
const provider = getProviderFromModel(model);
246258
const agentThinkingBudget = parseThinkingBudgetFromCharacterSettings(character.settings);
247-
const envForThinking = c.env as unknown as Record<string, string | undefined>;
259+
const envForThinking = getAnthropicCotEnv(c.env);
248260
const effectiveThinkingBudget = resolveAnthropicThinkingBudgetTokens(
249261
model,
250262
envForThinking,

cloud/apps/api/agents/[id]/mcp/route.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { CORS_ALLOW_HEADERS, CORS_ALLOW_METHODS } from "@/lib/cors-constants";
1717
import { RateLimitPresets, rateLimit } from "@/lib/middleware/rate-limit-hono-cloudflare";
1818
import { calculateCost, estimateTokens, getProviderFromModel } from "@/lib/pricing";
1919
import {
20+
type AnthropicCotEnv,
2021
mergeAnthropicCotProviderOptions,
2122
parseThinkingBudgetFromCharacterSettings,
2223
resolveAnthropicThinkingBudgetTokens,
@@ -39,6 +40,17 @@ const MCPRequestSchema = z.object({
3940

4041
const app = new Hono<AppEnv>();
4142

43+
function getAnthropicCotEnv(env: AppEnv["Bindings"]): AnthropicCotEnv {
44+
return {
45+
ANTHROPIC_COT_BUDGET:
46+
typeof env.ANTHROPIC_COT_BUDGET === "string" ? env.ANTHROPIC_COT_BUDGET : undefined,
47+
ANTHROPIC_COT_BUDGET_MAX:
48+
typeof env.ANTHROPIC_COT_BUDGET_MAX === "string"
49+
? env.ANTHROPIC_COT_BUDGET_MAX
50+
: undefined,
51+
};
52+
}
53+
4254
app.get("/", rateLimit(RateLimitPresets.STANDARD), async (c) => {
4355
const id = c.req.param("id");
4456
if (!id) return c.json({ error: "Missing id" }, 400);
@@ -273,7 +285,7 @@ async function handleToolCall(
273285

274286
const provider = getProviderFromModel(model);
275287
const markupPct = Number(character.inference_markup_percentage || 0);
276-
const envForThinking = c.env as unknown as Record<string, string | undefined>;
288+
const envForThinking = getAnthropicCotEnv(c.env);
277289
const agentThinkingBudget = parseThinkingBudgetFromCharacterSettings(character.settings);
278290
const effectiveThinkingBudget = resolveAnthropicThinkingBudgetTokens(
279291
model,

cloud/apps/api/auth/steward-debug/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const app = new Hono<AppEnv>();
1515
// without leaking its value. Returns first/last 2 chars + length, plus
1616
// where the value is sourced from. Remove after the auth flow is verified.
1717
app.get("/", (c) => {
18-
const fromProcess = (process as unknown as { env: Record<string, string | undefined> })?.env;
18+
const fromProcess = process.env;
1919
const pSecret = fromProcess?.STEWARD_SESSION_SECRET ?? "";
2020
const cSecret = c.env.STEWARD_SESSION_SECRET ?? "";
2121
const fingerprint = (s: string) =>

cloud/apps/api/compat/availability/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function canViewNodeTopology(c: AppContext): Promise<boolean> {
2020
// The legacy helpers expect a Request. They only read headers, so
2121
// pass through the underlying Request — Hono's `c.req.raw` is a Fetch
2222
// Request which both helpers accept.
23-
const req = c.req.raw as unknown as Parameters<typeof validateServiceKey>[0];
23+
const req = c.req.raw;
2424
if (validateServiceKey(req)) return true;
2525
if (await authenticateWaifuBridge(req)) return true;
2626
return false;

cloud/apps/api/src/stubs/elizaos-core.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ function sha1Bytes(message: string): Uint8Array {
4949
const dataView = new DataView(padded.buffer);
5050
const bitLength = messageLength * 8;
5151
dataView.setUint32(padded.length - 4, bitLength >>> 0, false);
52-
dataView.setUint32(
53-
padded.length - 8,
54-
Math.floor(bitLength / 2 ** 32) >>> 0,
55-
false,
56-
);
52+
dataView.setUint32(padded.length - 8, Math.floor(bitLength / 2 ** 32) >>> 0, false);
5753

5854
let h0 = 0x67452301;
5955
let h1 = 0xefcdab89;
@@ -67,11 +63,7 @@ function sha1Bytes(message: string): Uint8Array {
6763
words[index] = dataView.getUint32(offset + index * 4, false);
6864
}
6965
for (let index = 16; index < 80; index += 1) {
70-
const value =
71-
words[index - 3] ^
72-
words[index - 8] ^
73-
words[index - 14] ^
74-
words[index - 16];
66+
const value = words[index - 3] ^ words[index - 8] ^ words[index - 14] ^ words[index - 16];
7567
words[index] = (value << 1) | (value >>> 31);
7668
}
7769

@@ -262,7 +254,7 @@ export const documentsPluginCore = {
262254

263255
export const addHeader = (header: string, body: string) => (body ? `${header}\n${body}` : "");
264256

265-
export const UUID = asUUID as unknown as (value?: string) => string;
257+
export const UUID = (value?: string): string => asUUID(value ?? "");
266258
export const composeActionExamples = throwingExport("composeActionExamples");
267259
export const formatActions = throwingExport("formatActions");
268260
export const formatActionNames = throwingExport("formatActionNames");
@@ -319,11 +311,7 @@ export function buildCanonicalSystemPrompt(args: {
319311
? character.name.trim()
320312
: "the agent";
321313
const role = typeof args.userRole === "string" ? args.userRole.trim().toUpperCase() : "";
322-
return [
323-
system,
324-
bio ? `# About ${name}\n${bio}` : "",
325-
role ? `user_role: ${role}` : "",
326-
]
314+
return [system, bio ? `# About ${name}\n${bio}` : "", role ? `user_role: ${role}` : ""]
327315
.filter(Boolean)
328316
.join("\n\n")
329317
.trim();

cloud/apps/api/src/worker-polyfills.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ class FinalizationRegistryPolyfill {
3434
unregister(_unregisterToken: object): void {}
3535
}
3636

37-
const root = globalThis as unknown as Record<string, unknown>;
37+
const root: typeof globalThis & {
38+
MessagePort?: unknown;
39+
MessageChannel?: unknown;
40+
FinalizationRegistry?: unknown;
41+
} = globalThis;
3842

3943
if (root.MessagePort === undefined) {
4044
root.MessagePort = MessagePortPolyfill;

cloud/apps/api/training/vertex/assignments/route.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import { Hono } from "hono";
22
import { requireAdmin, requireAuthOrApiKeyWithOrg } from "@/lib/auth";
33
import { vertexModelRegistryService } from "@/lib/services/vertex-model-registry";
4+
import type { VertexTuningSlot } from "@/lib/services/vertex-tuning";
45
import type { AppEnv } from "@/types/cloud-worker-env";
56

7+
const VERTEX_TUNING_SLOTS = [
8+
"should_respond",
9+
"response_handler",
10+
"action_planner",
11+
"planner",
12+
"response",
13+
"media_description",
14+
] as const satisfies readonly VertexTuningSlot[];
15+
616
function parseScope(value: unknown): "global" | "organization" | "user" {
717
return value === "global" || value === "organization" || value === "user"
818
? value
919
: "organization";
1020
}
1121

22+
function parseSlot(value: unknown): VertexTuningSlot | undefined {
23+
return typeof value === "string" ? VERTEX_TUNING_SLOTS.find((slot) => slot === value) : undefined;
24+
}
25+
1226
async function ensureGlobalAccess(request: Request): Promise<void> {
1327
const admin = await requireAdmin(request);
1428
if (admin.role !== "super_admin") {
@@ -21,17 +35,22 @@ async function __hono_GET(request: Request) {
2135
const { user } = await requireAuthOrApiKeyWithOrg(request);
2236
const { searchParams } = new URL(request.url);
2337
const scope = parseScope(searchParams.get("scope"));
24-
const slot = searchParams.get("slot") || undefined;
38+
const rawSlot = searchParams.get("slot");
39+
const slot = parseSlot(rawSlot);
2540
const activeOnly = searchParams.get("active") !== "false";
2641

42+
if (rawSlot && !slot) {
43+
return Response.json({ error: "Invalid slot." }, { status: 400 });
44+
}
45+
2746
const assignments = await vertexModelRegistryService.listVisibleAssignments(
2847
{
2948
organizationId: user.organization_id,
3049
userId: user.id,
3150
},
3251
{
3352
scope: searchParams.get("scope") ? scope : undefined,
34-
slot: slot as any,
53+
slot,
3554
activeOnly,
3655
},
3756
);
@@ -57,9 +76,13 @@ async function __hono_POST(request: Request) {
5776
await ensureGlobalAccess(request);
5877
}
5978

60-
const slot = typeof body.slot === "string" ? body.slot : undefined;
79+
const slot = parseSlot(body.slot);
6180
const tunedModelId = typeof body.tunedModelId === "string" ? body.tunedModelId : undefined;
6281

82+
if (typeof body.slot === "string" && !slot) {
83+
return Response.json({ error: "Invalid slot." }, { status: 400 });
84+
}
85+
6386
if (!slot || !tunedModelId) {
6487
return Response.json(
6588
{
@@ -71,7 +94,7 @@ async function __hono_POST(request: Request) {
7194

7295
const assignment = await vertexModelRegistryService.activateAssignment({
7396
scope,
74-
slot: slot as any,
97+
slot,
7598
tunedModelId,
7699
organizationId: scope === "global" ? undefined : user.organization_id,
77100
userId: scope === "user" ? user.id : undefined,
@@ -105,7 +128,11 @@ async function __hono_DELETE(request: Request) {
105128
await ensureGlobalAccess(request);
106129
}
107130

108-
const slot = typeof body.slot === "string" ? body.slot : undefined;
131+
const slot = parseSlot(body.slot);
132+
if (typeof body.slot === "string" && !slot) {
133+
return Response.json({ error: "Invalid slot." }, { status: 400 });
134+
}
135+
109136
if (!slot) {
110137
return Response.json(
111138
{
@@ -117,7 +144,7 @@ async function __hono_DELETE(request: Request) {
117144

118145
const deactivatedCount = await vertexModelRegistryService.deactivateAssignment({
119146
scope,
120-
slot: slot as any,
147+
slot,
121148
organizationId: scope === "global" ? undefined : user.organization_id,
122149
userId: scope === "user" ? user.id : undefined,
123150
});

0 commit comments

Comments
 (0)