Skip to content

An AI-powered search engine with a generative UI

chore(deps): migrate to AI SDK 7 (#972)

Yoshiki Miura0ec2ca733c8c
diff --git a/bun.lock b/bun.lock
index 84a1b590..e6013db9 100644
--- a/bun.lock
+++ b/bun.lock
@@ -5,19 +5,21 @@
"": {
"name": "morphic",
"dependencies": {
- "@ai-sdk/anthropic": "^3.0.77",
- "@ai-sdk/gateway": "^3.0.114",
- "@ai-sdk/google": "^3.0.73",
- "@ai-sdk/openai": "^3.0.63",
- "@ai-sdk/openai-compatible": "^2.0.47",
- "@ai-sdk/react": "^3.0.182",
+ "@ai-sdk/anthropic": "^4.0.39",
+ "@ai-sdk/gateway": "^4.0.52",
+ "@ai-sdk/google": "^4.0.44",
+ "@ai-sdk/openai": "^4.0.42",
+ "@ai-sdk/openai-compatible": "^3.0.31",
+ "@ai-sdk/react": "^4.0.69",
"@aws-sdk/client-s3": "3.859.0",
"@aws-sdk/s3-request-presigner": "3.859.0",
"@json-render/core": "^0.16.0",
"@json-render/react": "^0.16.0",
- "@langfuse/client": "^5.9.1",
- "@langfuse/otel": "^5.9.1",
- "@langfuse/tracing": "^5.9.1",
+ "@langfuse/client": "^5.10.1",
+ "@langfuse/otel": "^5.10.1",
+ "@langfuse/tracing": "^5.10.1",
+ "@langfuse/vercel-ai-sdk": "^5.10.1",
+ "@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "0.220.0",
"@opentelemetry/core": "^2.9.0",
"@opentelemetry/instrumentation": "0.220.0",
@@ -52,8 +54,8 @@
"@upstash/redis": "^1.35.5",
"@vercel/analytics": "^1.5.0",
"@vercel/otel": "^2.1.3",
- "ai": "^6.0.180",
- "ai-sdk-ollama": "^3.8.4",
+ "ai": "^7.0.66",
+ "ai-sdk-ollama": "^4.1.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.0",
"cmdk": "1.0.0",
@@ -104,21 +106,25 @@
"packages": {
"@adobe/css-tools": ["@adobe/[email protected]", "", {}, "sha512-VQKMkwriZbaOgVCby1UDY/LDk5fIjhQicCvVPFqfe+69fWaPWydbWJ3wRt59/YzIwda1I81loas3oCoHxnqvdA=="],
- "@ai-sdk/anthropic": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ML8C2M1YvPA1ulEx4TiyF0k1xvC2ikEiPBIC1PPQ0a5xELUGrO2lAaEzsTEoJ+eCeDd8PSBuFJjs+r+9yIwQXA=="],
+ "@ai-sdk/anthropic": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-JAMGtYeEuaBzqbsPO4fkho6vQyNoVhsHASM4o59wmJRU6Vh7prjOp490Kmc7YQTY+ioU1/xYzXvWOtxZBup0Xw=="],
- "@ai-sdk/gateway": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27", "@vercel/oidc": "3.2.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-MqkZ5sd+qiq6RgIxELkoFQXg2/JwK+WCMaot7U+rtrZpWJl3fSyYvc28SC03b256o4F7OXjQtdjTqs81B2w+dA=="],
+ "@ai-sdk/gateway": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27", "@vercel/oidc": "3.2.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-SXUM8jzzuTUJRq+EOgPd5to6DSx0EKslVn+IVZHbUEX6k/3vCPNrvjckbK26HnNxHU/STxm+zTSJteqrO+7Z0w=="],
- "@ai-sdk/google": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-o2MuIeyvZrFIeIbnbA8Thrr63irdyUBh0uWBZ2lY6yFeXuE/tcwyXF74bDKS4KvTu84uFpQfpbS/LXHGKKXz+g=="],
+ "@ai-sdk/google": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-bmRTDg06jQD+eX8nf214pET9+Oe8O1+lUIRGbWsGXj9IN2UJkpl1O1x7cvtiboyTtKSLvSRdVtItUfSl8sQ2GA=="],
- "@ai-sdk/openai": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-4yY/m8a57MNNVoJCsXuNblKf6BO4yuAuLKRX4tzSNffBEBSp1FlcWdPE0Z4FkqUeS0AJhYSSqp0GIiA/cIcDNA=="],
+ "@ai-sdk/mcp": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27", "pkce-challenge": "^5.0.1" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-NkXUnIEUmOmjD42LGpXGdHPULYvAV4SYUojutqw5YVNmQA7g64YRv3NLOaST21b2vIScUAah4qWchi62iUpQdA=="],
- "@ai-sdk/openai-compatible": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-Enm5UlL0zUCrW3792opk5h7hRWxZOZzDe6eQYVFqX9LUOGGCe1h8MZWAGim765nwzgnjlpeYOsuzZmLtRsTPlg=="],
+ "@ai-sdk/openai": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ZxDca6jJalYuXrIGVrw6dnkpz1Io9AWy+/b/wVWIbjigHCbd+zWLpPi8NnK0OFU+U3YCpP+KWfUvEnG5pFhltA=="],
- "@ai-sdk/provider": ["@ai-sdk/[email protected]", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-Q3BZ27qfpYqnCYGvE3vt+Qi6LGOF9R5Nmzn+9JoM1lCRsD9mYaIhfJLkSunN48nfGXJ6n+XNV0J/XVpqGQl7Dw=="],
+ "@ai-sdk/openai-compatible": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-g6kbWJzI1mfHoZp2vXPyb/fiMrK8pNRU2dbum8rBHxemx+ryBJWFAwTndBaVefm+gx9A6fK7J/hSrdfRdVJlQQ=="],
- "@ai-sdk/provider-utils": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "3.0.10", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.8" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ubkAJ+xODouwtmN1tYlvTPphH1hPOBfZaEQe8U7skGvFAnIRs9PPpsq57bC2+Ky/MB4yzhd6YOsxTAx9sGpazw=="],
+ "@ai-sdk/otel": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@opentelemetry/api": "1.9.1", "ai": "7.0.66" } }, "sha512-SGGESPSJZ3lN04H4vh3HaCcfp1p1RUVYSqszJK1iqkBZVZdI0bpno3CB8NI6h5v5eTiiAmum5S8pBzupjGZpvQ=="],
- "@ai-sdk/react": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider-utils": "4.0.27", "ai": "6.0.180", "swr": "^2.2.5", "throttleit": "2.1.0" }, "peerDependencies": { "react": "^18 || ~19.0.1 || ~19.1.2 || ^19.2.1" } }, "sha512-cnfF5N6XRsQ29VsSSoFqFpYQJx1y4sSCL3lGMIwgE0034aqn8i3+joRe52O9xV+EaJ7fziI7xn6ql7qjrf+Blw=="],
+ "@ai-sdk/provider": ["@ai-sdk/[email protected]", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-6or44XprPzKbr8zkmzosowSE0pxkvJcoojBL+mCZvPUt3kvXp3XSNqeVun9golb1acEfSo6yaEBRT18h2VU+1Q=="],
+
+ "@ai-sdk/provider-utils": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "4.0.7", "@standard-schema/spec": "^1.1.0", "@workflow/serde": "4.1.0", "eventsource-parser": "^3.0.8", "undici": "^7.28.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-EzAn4pdgG5g0xXtH6lE2zyNmfjDQIDjATkfqzuidEI35g++hh4+07vnjzkT/RmGmIClPZiRj/Q2GMPV2V7mkHw=="],
+
+ "@ai-sdk/react": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/mcp": "2.0.32", "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27", "ai": "7.0.66", "swr": "^2.4.1", "throttleit": "2.1.0" }, "peerDependencies": { "react": "^18 || ~19.0.1 || ~19.1.2 || ^19.2.1" } }, "sha512-AvwDHRXg0md72BOzclcZzlCkjwT8xQefEaVX8e78WZgd0F635+7iWJyCRRq7x2z5zOCK7/wiEpAUoWpGobQyXg=="],
"@alloc/quick-lru": ["@alloc/[email protected]", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
@@ -432,13 +438,15 @@
"@json-render/react": ["@json-render/[email protected]", "", { "dependencies": { "@json-render/core": "0.16.0" }, "peerDependencies": { "react": "^19.2.3" } }, "sha512-PJQjLftGYZ5LNlA1IFww+yNOAJZRW2feEcH/L10u/8M/b/zImr9wfqQVMDyC87myoEzhyucpkQ6joISeZdKxsw=="],
- "@langfuse/client": ["@langfuse/[email protected]", "", { "dependencies": { "@langfuse/core": "^5.9.1", "@langfuse/tracing": "^5.9.1", "mustache": "^4.2.0" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-v9lb9GXc7ujmY2k97830MfIg+m1LQWkQNzXP+u2F3KwHVaEvD8zy4v1gLhbTkvemTggAx/tR+tv8BC9CeojTrA=="],
+ "@langfuse/client": ["@langfuse/[email protected]", "", { "dependencies": { "@langfuse/core": "^5.10.1", "@langfuse/tracing": "^5.10.1", "mustache": "^4.2.0" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-isfMUbb55mXnp5EjIKnKmdB6aVxy+jPYK65RkaLdi2xveUbifVeov9kAwHQN6lWtzkR/ssSk6+JwvTCLaPcvTQ=="],
- "@langfuse/core": ["@langfuse/[email protected]", "", { "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-KvyAskAO+2ixJwr9wy148ttR/Zn3oapvOJ2Br4Xcp6zhDpjSIIGB4jW/jkp53/KU9MyEHj0RSFPK/yKoxLC4KA=="],
+ "@langfuse/core": ["@langfuse/[email protected]", "", { "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-W8UArizWSy1DdeLGTsTwJwl7bkA7OQQcGZW8RtoopXyJZ93O0rwG7wzzeiZjhjpj5OtWOUTEaJuNkwOrF31UDw=="],
- "@langfuse/otel": ["@langfuse/[email protected]", "", { "dependencies": { "@langfuse/core": "^5.9.1" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0", "@opentelemetry/core": "^2.0.1", "@opentelemetry/exporter-trace-otlp-http": ">=0.202.0 <1.0.0", "@opentelemetry/sdk-trace-base": "^2.0.1" } }, "sha512-viM5Qq/AIPZPXfO7YdSmDHxEDSrNU/MyGzuE9zKA6hGBII1iLowU+qL99O+TjnXqxoADqlNibhY2pg1/WTIPcw=="],
+ "@langfuse/otel": ["@langfuse/[email protected]", "", { "dependencies": { "@langfuse/core": "^5.10.1" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0", "@opentelemetry/core": "^2.0.1", "@opentelemetry/exporter-trace-otlp-http": ">=0.202.0 <1.0.0", "@opentelemetry/sdk-trace-base": "^2.0.1" } }, "sha512-F2153e4PoJ1cN+5tM/xnsS44aQCQwK3p0nPk4NEpITV5pMTqiQVyvpkAvly8GKQ5Qjjr7heJ1dFtghW43ysyPQ=="],
- "@langfuse/tracing": ["@langfuse/[email protected]", "", { "dependencies": { "@langfuse/core": "^5.9.1" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-tJRyVAv1JkuOPh4Uz5eWUNH8U4jcJVtK2F5QNy5cZUzXCSrXobCSHusPbxY6VFZcLcFgtpDtSaxL7ev1tV2JNQ=="],
+ "@langfuse/tracing": ["@langfuse/[email protected]", "", { "dependencies": { "@langfuse/core": "^5.10.1" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0" } }, "sha512-m2kK4D0MsH8g4Og6KpnlYk8NLdQTYe0JR5M4KKpfNj99XXLlbdpXE/g3uJSqkcrWFhpiIb+3cyS9+uV6wQ6WtA=="],
+
+ "@langfuse/vercel-ai-sdk": ["@langfuse/[email protected]", "", { "dependencies": { "@ai-sdk/otel": "^1.0.44", "@langfuse/core": "^5.10.1" }, "peerDependencies": { "@opentelemetry/api": "^1.9.0", "ai": ">=7.0.0 <8" } }, "sha512-F+y5sLpeOEEO0uCLcZUHS5qvt0vF07SCnOu4oD7c1N5y9NwMADx0dbNh4804HGnEqqDDQAABtP9p9w+HHE6REQ=="],
"@mermaid-js/parser": ["@mermaid-js/[email protected]", "", { "dependencies": { "langium": "^4.0.0" } }, "sha512-opmV19kN1JsK0T6HhhokHpcVkqKpF+x2pPDKKM2ThHtZAB5F4PROopk0amuVYK5qMrIA4erzpNm8gmPNJgMDxQ=="],
@@ -1030,15 +1038,17 @@
"@vitest/utils": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/pretty-format": "4.1.8", "convert-source-map": "^2.0.0", "tinyrainbow": "^3.1.0" } }, "sha512-uOJamYALNhfJ6iolExyQM40yIQwDqYnkKtQ5VCiSe17E33H0aQ/u+1GlRuz4LZBk6Mm3sg90G9hEbmEt37C1Zg=="],
+ "@workflow/serde": ["@workflow/[email protected]", "", {}, "sha512-pav4F2BoirECWR7Nf1TKt+2eETcBj7jj4cBefQ8VXQCA6NPkaKeLfj/zMgi+3zYV5ZIBT4GuUiphsj0/b9hPQQ=="],
+
"acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="],
"acorn-jsx": ["[email protected]", "", { "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ=="],
"agent-base": ["[email protected]", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="],
- "ai": ["[email protected]", "", { "dependencies": { "@ai-sdk/gateway": "3.0.114", "@ai-sdk/provider": "3.0.10", "@ai-sdk/provider-utils": "4.0.27", "@opentelemetry/api": "^1.9.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-tOyRbwD0PEjMZKGvYQcTsv95K2zktwwNhQ49QOUAh0g8MNprO7ELIO1SgANMuPc0BFtkP6Ny6OAdjq3TtxLCbQ=="],
+ "ai": ["[email protected]", "", { "dependencies": { "@ai-sdk/gateway": "4.0.52", "@ai-sdk/provider": "4.0.7", "@ai-sdk/provider-utils": "5.0.27" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-wBUyoCYF3GVr+62nelBgR8YbpTSsMZrzFyOOjiwijylNSM2TFCW35C+Pml2vc59/WLMpyhS/LWZ55M+B9DAcSg=="],
- "ai-sdk-ollama": ["[email protected]", "", { "dependencies": { "@ai-sdk/provider": "^3.0.10", "@ai-sdk/provider-utils": "^4.0.27", "jsonrepair": "^3.14.0", "ollama": "^0.6.3" }, "peerDependencies": { "ai": "^6.0.177" } }, "sha512-vvhLHo9MrOhDxsxRWfOGqBmQsnbDPKQHqDG5vSYMkdu6q8RPxJIYag001jQIAKA2MO37Nf96gCAPWM+dufvglw=="],
+ "ai-sdk-ollama": ["[email protected]", "", { "dependencies": { "@ai-sdk/provider": "^4.0.3", "@ai-sdk/provider-utils": "^5.0.11", "jsonrepair": "^3.15.0", "ollama": "^0.6.3" }, "peerDependencies": { "ai": "^7.0.31" } }, "sha512-WBucDWhYVpahhoY5wAsPy4vbEYc34D7xRJOtfpE5VWkD/cRKG4eY1y3pkyP3pCK/Zmp3cHBuiHWu1vHZ81ljEA=="],
"ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw=="],
@@ -1622,7 +1632,7 @@
"json5": ["[email protected]", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="],
- "jsonrepair": ["[email protected]", "", { "bin": { "jsonrepair": "bin/cli.js" } }, "sha512-tWPGKMZf/8UPim+fcW2EfcQ/d/7aKUrP6IECz9G3Tu6Q5dX0orSleqJ9z6sSw7qrQkjF8/Edo4DvsWBZ8H+HNg=="],
+ "jsonrepair": ["[email protected]", "", { "bin": { "jsonrepair": "bin/cli.js" } }, "sha512-wy8OTjwsJwQRnQJkKnMJJ9vcytRdBPAgIF/Hy6+s1dAj42BHMKiyL8JzEieIl3JY7idt8eyHwBWTO8mh/+mtwA=="],
"jsx-ast-utils": ["[email protected]", "", { "dependencies": { "array-includes": "^3.1.6", "array.prototype.flat": "^1.3.1", "object.assign": "^4.1.4", "object.values": "^1.1.6" } }, "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ=="],
@@ -1878,6 +1888,8 @@
"picomatch": ["[email protected]", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
+ "pkce-challenge": ["[email protected]", "", {}, "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ=="],
+
"pkg-types": ["[email protected]", "", { "dependencies": { "confbox": "^0.1.8", "mlly": "^1.7.4", "pathe": "^2.0.1" } }, "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ=="],
"points-on-curve": ["[email protected]", "", {}, "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A=="],
@@ -2072,7 +2084,7 @@
"supports-preserve-symlinks-flag": ["[email protected]", "", {}, "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="],
- "swr": ["[email protected]", "", { "dependencies": { "dequal": "^2.0.3", "use-sync-external-store": "^1.4.0" }, "peerDependencies": { "react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-bYd2lrhc+VarcpkgWclcUi92wYCpOgMws9Sd1hG1ntAu0NEy+14CbotuFjshBU2kt9rYj9TSmDcybpxpeTU1fg=="],
+ "swr": ["[email protected]", "", { "dependencies": { "dequal": "^2.0.3", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-BRw55e8r0B7SpDN20CAzoQAHl7y1yP7/Zt7oqUjMv0vSt2u2Xnkm88Ws+VypbV9BXHQVuSuyVq7zMjO16wSExw=="],
"symbol-tree": ["[email protected]", "", {}, "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="],
@@ -2138,6 +2150,8 @@
"uncrypto": ["[email protected]", "", {}, "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q=="],
+ "undici": ["[email protected]", "", {}, "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw=="],
+
"undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
"unified": ["[email protected]", "", { "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", "devlop": "^1.0.0", "extend": "^3.0.0", "is-plain-obj": "^4.0.0", "trough": "^2.0.0", "vfile": "^6.0.0" } }, "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA=="],
@@ -2172,7 +2186,7 @@
"use-sidecar": ["[email protected]", "", { "dependencies": { "detect-node-es": "^1.1.0", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ=="],
- "use-sync-external-store": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A=="],
+ "use-sync-external-store": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="],
"util-deprecate": ["[email protected]", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
@@ -2252,6 +2266,8 @@
"zwitch": ["[email protected]", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
+ "@ai-sdk/otel/@opentelemetry/api": ["@opentelemetry/[email protected]", "", {}, "sha512-gLyJlPHPZYdAk1JENA9LeHejZe1Ti77/pTeFm/nMXmQH/HFZlcS/O2XJB+L8fkbrNSqhdtlvjBVjxwUYanNH5Q=="],
+
"@antfu/install-pkg/tinyexec": ["[email protected]", "", {}, "sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw=="],
"@asamuzakjp/css-color/lru-cache": ["[email protected]", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
@@ -2308,6 +2324,8 @@
"@radix-ui/react-tooltip/@radix-ui/react-popper": ["@radix-ui/[email protected]", "", { "dependencies": { "@floating-ui/react-dom": "^2.0.0", "@radix-ui/react-arrow": "1.1.7", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-layout-effect": "1.1.1", "@radix-ui/react-use-rect": "1.1.1", "@radix-ui/react-use-size": "1.1.1", "@radix-ui/rect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-IUFAccz1JyKcf/RjB552PlWwxjeCJB8/4KxT7EhBHOJM+mN7LdW+B3kacJXILm32xawcMMjb2i0cIZpo+f9kiQ=="],
+ "@radix-ui/react-use-is-hydrated/use-sync-external-store": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A=="],
+
"@streamdown/math/katex": ["[email protected]", "", { "dependencies": { "commander": "^8.3.0" }, "bin": { "katex": "cli.js" } }, "sha512-EkxoDTk8ufHqHlf9QxGwcxeLkWRR3iOuYfRpfORgYfqc8s13bgb+YtRY59NK5ZpRaCwq1kqA6a5lpX8C/eLphQ=="],
"@supabase/auth-ui-react/react": ["[email protected]", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ=="],
diff --git a/components/chat.tsx b/components/chat.tsx
index fe5722b2..b277406f 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -209,7 +209,7 @@ export function Chat({
toast.error(publicError.error)
}
},
- experimental_throttle: 100,
+ throttle: 100,
generateId
})
diff --git a/instrumentation.test.ts b/instrumentation.test.ts
index 500f2a31..60868767 100644
--- a/instrumentation.test.ts
+++ b/instrumentation.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it, vi } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
// Mock the modules before any imports
vi.mock('@langfuse/otel', () => ({
@@ -7,14 +7,33 @@ vi.mock('@langfuse/otel', () => ({
vi.mock('@vercel/otel', () => ({
registerOTel: vi.fn()
}))
+vi.mock('@langfuse/vercel-ai-sdk', () => ({
+ LangfuseVercelAiSdkIntegration: vi.fn()
+}))
+vi.mock('ai', async importOriginal => ({
+ ...(await importOriginal<typeof import('ai')>()),
+ registerTelemetry: vi.fn()
+}))
// Import after mocking
import { LangfuseSpanProcessor } from '@langfuse/otel'
+import { LangfuseVercelAiSdkIntegration } from '@langfuse/vercel-ai-sdk'
import { registerOTel } from '@vercel/otel'
+import { registerTelemetry } from 'ai'
import { langfuseSpanProcessor, register } from './instrumentation'
+const originalTracingFlag = process.env.ENABLE_LANGFUSE_TRACING
+
describe('instrumentation', () => {
+ afterEach(() => {
+ if (originalTracingFlag === undefined) {
+ delete process.env.ENABLE_LANGFUSE_TRACING
+ } else {
+ process.env.ENABLE_LANGFUSE_TRACING = originalTracingFlag
+ }
+ })
+
it('exports a shared LangfuseSpanProcessor instance for force-flushing', () => {
expect(LangfuseSpanProcessor).toHaveBeenCalledTimes(1)
expect(langfuseSpanProcessor).toBeInstanceOf(LangfuseSpanProcessor)
@@ -30,4 +49,32 @@ describe('instrumentation', () => {
spanProcessors: [langfuseSpanProcessor]
})
})
+
+ it('registers the AI SDK telemetry integration once when tracing is enabled', async () => {
+ delete process.env.OLLAMA_BASE_URL
+ process.env.ENABLE_LANGFUSE_TRACING = 'true'
+ vi.mocked(LangfuseVercelAiSdkIntegration).mockClear()
+ vi.mocked(registerTelemetry).mockClear()
+ vi.resetModules()
+
+ // Fresh module so the registered-once guard starts from its initial state
+ const instrumentation = await import('./instrumentation')
+ await instrumentation.register()
+ await instrumentation.register()
+
+ expect(LangfuseVercelAiSdkIntegration).toHaveBeenCalledTimes(1)
+ expect(registerTelemetry).toHaveBeenCalledTimes(1)
+ })
+
+ it('skips the telemetry integration when tracing is disabled', async () => {
+ delete process.env.OLLAMA_BASE_URL
+ delete process.env.ENABLE_LANGFUSE_TRACING
+ vi.mocked(registerTelemetry).mockClear()
+ vi.resetModules()
+
+ const instrumentation = await import('./instrumentation')
+ await instrumentation.register()
+
+ expect(registerTelemetry).not.toHaveBeenCalled()
+ })
})
diff --git a/instrumentation.ts b/instrumentation.ts
index 04e4b72a..0b26647e 100644
--- a/instrumentation.ts
+++ b/instrumentation.ts
@@ -1,16 +1,31 @@
import { LangfuseSpanProcessor } from '@langfuse/otel'
+import { LangfuseVercelAiSdkIntegration } from '@langfuse/vercel-ai-sdk'
import { registerOTel } from '@vercel/otel'
+import { registerTelemetry } from 'ai'
+
+import { isTracingEnabled } from '@/lib/utils/telemetry'
// Exported so request handlers can force-flush pending spans before the
// serverless function exits
export const langfuseSpanProcessor = new LangfuseSpanProcessor()
+// registerTelemetry appends without deduping, so a second register() would
+// double every span.
+let telemetryRegistered = false
+
export async function register() {
registerOTel({
serviceName: 'morphic-ai-search',
spanProcessors: [langfuseSpanProcessor]
})
+ // The AI SDK emits no spans until a telemetry integration is registered.
+ // The integration creates the spans, the processor above exports them.
+ if (isTracingEnabled() && !telemetryRegistered) {
+ registerTelemetry(new LangfuseVercelAiSdkIntegration())
+ telemetryRegistered = true
+ }
+
// Initialize Ollama validation on server startup (only when configured)
if (process.env.OLLAMA_BASE_URL) {
const { initializeOllamaValidation } = await import(
diff --git a/lib/agents/__tests__/researcher.test.ts b/lib/agents/__tests__/researcher.test.ts
index 5e2c5981..7f56b754 100644
--- a/lib/agents/__tests__/researcher.test.ts
+++ b/lib/agents/__tests__/researcher.test.ts
@@ -7,7 +7,7 @@ const mocks = vi.hoisted(() => ({
}))
vi.mock('ai', () => ({
- stepCountIs: vi.fn(),
+ isStepCount: vi.fn(),
tool: vi.fn(options => options),
ToolLoopAgent: vi.fn(function (
this: { tools: unknown },
diff --git a/lib/agents/researcher.ts b/lib/agents/researcher.ts
index ef1f549f..b8fb526c 100644
--- a/lib/agents/researcher.ts
+++ b/lib/agents/researcher.ts
@@ -1,6 +1,9 @@
-import { stepCountIs, tool, ToolLoopAgent } from 'ai'
+import { isStepCount, tool, ToolLoopAgent } from 'ai'
-import type { ResearcherTools } from '@/lib/types/agent'
+import type {
+ ResearcherRuntimeContext,
+ ResearcherTools
+} from '@/lib/types/agent'
import { type Model } from '@/lib/types/models'
import { fetchTool } from '../tools/fetch'
@@ -142,16 +145,21 @@ export function createResearcher({
instructions: `${systemPrompt}\nCurrent date: ${currentDate}`,
tools,
activeTools: activeToolsList,
- stopWhen: stepCountIs(maxSteps),
+ stopWhen: isStepCount(maxSteps),
...(providerOptions && { providerOptions }),
+ runtimeContext: {
+ modelId: model,
+ agentType: 'researcher',
+ searchMode
+ } satisfies ResearcherRuntimeContext,
// Spans join the parent Langfuse trace via OTel context propagation
- experimental_telemetry: {
+ telemetry: {
isEnabled: isTracingEnabled(),
functionId: 'research-agent',
- metadata: {
- modelId: model,
- agentType: 'researcher',
- searchMode
+ includeRuntimeContext: {
+ modelId: true,
+ agentType: true,
+ searchMode: true
}
}
})
@@ -165,7 +173,7 @@ export function createResearcher({
// Helper function to access agent tools
export function getResearcherTools(
- agent: ToolLoopAgent<never, ResearcherTools, never>
+ agent: ToolLoopAgent<never, ResearcherTools, ResearcherRuntimeContext>
): ResearcherTools {
return agent.tools
}
diff --git a/lib/agents/title-generator.ts b/lib/agents/title-generator.ts
index c7640157..ef6c123c 100644
--- a/lib/agents/title-generator.ts
+++ b/lib/agents/title-generator.ts
@@ -40,18 +40,23 @@ export async function generateChatTitle({
const { text: generatedTitle } = await generateText({
model: getModel(modelId),
- system: systemPrompt,
+ instructions: systemPrompt,
prompt: userMessageContent,
abortSignal,
providerOptions: getTitleProviderOptions(modelId),
+ runtimeContext: {
+ modelId,
+ agentType: 'title-generator',
+ promptLength: userMessageContent.length
+ },
// Spans join the parent Langfuse trace via OTel context propagation
- experimental_telemetry: {
+ telemetry: {
isEnabled: isTracingEnabled(),
functionId: 'title-generation',
- metadata: {
- modelId: modelId,
- agentType: 'title-generator',
- promptLength: userMessageContent.length
+ includeRuntimeContext: {
+ modelId: true,
+ agentType: true,
+ promptLength: true
}
}
})
diff --git a/lib/render/__tests__/llm-image-output.e2e.test.ts b/lib/render/__tests__/llm-image-output.e2e.test.ts
index de039ea5..e2fe8edb 100644
--- a/lib/render/__tests__/llm-image-output.e2e.test.ts
+++ b/lib/render/__tests__/llm-image-output.e2e.test.ts
@@ -9,7 +9,7 @@
*
* RUN_LLM_E2E=1 OPENAI_API_KEY=sk-... bun run test llm-image-output.e2e
*/
-import { generateText, stepCountIs, tool } from 'ai'
+import { generateText, isStepCount, tool } from 'ai'
import { describe, expect, test } from 'vitest'
import { z } from 'zod'
@@ -86,11 +86,11 @@ describe.skipIf(!RUN)('LLM inline image output (E2E)', () => {
test('LLM emits inline image spec block using search tool images', async () => {
const { text } = await generateText({
model: getModel(MODEL),
- system: getAdaptiveModePrompt(),
+ instructions: getAdaptiveModePrompt(),
tools: {
search: createMockSearchTool()
},
- stopWhen: stepCountIs(6),
+ stopWhen: isStepCount(6),
prompt:
'Show me photos of Mount Fuji and a brief description. Please include relevant images inline.'
})
diff --git a/lib/render/__tests__/llm-related-questions.e2e.test.ts b/lib/render/__tests__/llm-related-questions.e2e.test.ts
index 419ea3bd..6505ca85 100644
--- a/lib/render/__tests__/llm-related-questions.e2e.test.ts
+++ b/lib/render/__tests__/llm-related-questions.e2e.test.ts
@@ -8,7 +8,7 @@
*
* RUN_LLM_E2E=1 OPENAI_API_KEY=sk-... bun run test llm-related-questions.e2e
*/
-import { generateText, stepCountIs, tool } from 'ai'
+import { generateText, isStepCount, tool } from 'ai'
import { describe, expect, test } from 'vitest'
import { z } from 'zod'
@@ -100,11 +100,11 @@ function findRelatedBlocks(markdown: string): SpecElement[][] {
async function generateAnswer(prompt: string): Promise<string> {
const { text } = await generateText({
model: getModel(MODEL),
- system: getAdaptiveModePrompt(),
+ instructions: getAdaptiveModePrompt(),
tools: {
search: createMockSearchTool()
},
- stopWhen: stepCountIs(6),
+ stopWhen: isStepCount(6),
providerOptions: PROVIDER_OPTIONS,
prompt
})
diff --git a/lib/streaming/__tests__/create-chat-stream-response.test.ts b/lib/streaming/__tests__/create-chat-stream-response.test.ts
index 2bf56f6a..bb9bb11a 100644
--- a/lib/streaming/__tests__/create-chat-stream-response.test.ts
+++ b/lib/streaming/__tests__/create-chat-stream-response.test.ts
@@ -76,7 +76,7 @@ type StreamOptions = {
}
type UIMessageStreamResponseOptions = {
- onFinish: (event: {
+ onEnd: (event: {
responseMessage: {
id: string
role: 'assistant'
@@ -91,7 +91,7 @@ function createFakeResult(isAborted = false) {
consumeStream: vi.fn(),
toUIMessageStreamResponse: vi.fn(
(options: UIMessageStreamResponseOptions) => {
- mocks.finishPromise = options.onFinish({
+ mocks.finishPromise = options.onEnd({
responseMessage: {
id: 'response-id',
role: 'assistant',
diff --git a/lib/streaming/__tests__/create-ephemeral-chat-stream-response.test.ts b/lib/streaming/__tests__/create-ephemeral-chat-stream-response.test.ts
index 52ce09f0..0fd958db 100644
--- a/lib/streaming/__tests__/create-ephemeral-chat-stream-response.test.ts
+++ b/lib/streaming/__tests__/create-ephemeral-chat-stream-response.test.ts
@@ -59,7 +59,7 @@ type StreamOptions = {
type UIMessageStreamResponseOptions = {
onError: (error: unknown) => string
- onFinish: (event: {
+ onEnd: (event: {
responseMessage: {
id: string
role: 'assistant'
@@ -85,7 +85,7 @@ function createFakeResult({
if (toolError) {
mocks.serializedError = options.onError(toolError)
}
- mocks.finishPromise = options.onFinish({
+ mocks.finishPromise = options.onEnd({
responseMessage: {
id: 'response-id',
role: 'assistant',
diff --git a/lib/streaming/create-chat-stream-response.ts b/lib/streaming/create-chat-stream-response.ts
index f3f5ad0e..21ca2aec 100644
--- a/lib/streaming/create-chat-stream-response.ts
+++ b/lib/streaming/create-chat-stream-response.ts
@@ -219,7 +219,7 @@ export async function createChatStreamResponse(
},
experimental_transform: smoothStream({ chunking: 'word' }),
...(isUsageLogging() && {
- onStepFinish: step => {
+ onStepEnd: step => {
logUsage(
{ scope: 'step', modelId: context.modelId },
step.usage,
@@ -235,7 +235,7 @@ export async function createChatStreamResponse(
// Log the session-total usage once the stream settles (does not block the
// response; consumeStream above already drives it to completion).
if (isUsageLogging()) {
- Promise.resolve(result.totalUsage)
+ Promise.resolve(result.usage)
.then(usage =>
logUsage({ scope: 'total', modelId: context.modelId }, usage)
)
@@ -252,7 +252,7 @@ export async function createChatStreamResponse(
}
}
},
- onFinish: async ({ responseMessage, isAborted }) => {
+ onEnd: async ({ responseMessage, isAborted }) => {
try {
perfTime('researchAgent.stream completed', llmStart)
if (isAborted || !responseMessage) return
diff --git a/lib/streaming/create-ephemeral-chat-stream-response.ts b/lib/streaming/create-ephemeral-chat-stream-response.ts
index 013151a2..8e744ead 100644
--- a/lib/streaming/create-ephemeral-chat-stream-response.ts
+++ b/lib/streaming/create-ephemeral-chat-stream-response.ts
@@ -131,7 +131,7 @@ export async function createEphemeralChatStreamResponse(
},
experimental_transform: smoothStream({ chunking: 'word' }),
...(isUsageLogging() && {
- onStepFinish: step => {
+ onStepEnd: step => {
logUsage(
{ scope: 'step', modelId },
step.usage,
@@ -145,7 +145,7 @@ export async function createEphemeralChatStreamResponse(
result.consumeStream()
if (isUsageLogging()) {
- Promise.resolve(result.totalUsage)
+ Promise.resolve(result.usage)
.then(usage => logUsage({ scope: 'total', modelId }, usage))
.catch(() => {})
}
@@ -160,7 +160,7 @@ export async function createEphemeralChatStreamResponse(
}
}
},
- onFinish: async ({ responseMessage, isAborted }) => {
+ onEnd: async ({ responseMessage, isAborted }) => {
if (!isAborted && responseMessage) {
hasEmptyResponse = isEmptyResponse(responseMessage)
}
diff --git a/lib/tools/__tests__/fetch-error.test.ts b/lib/tools/__tests__/fetch-error.test.ts
index c5efc568..0e289d91 100644
--- a/lib/tools/__tests__/fetch-error.test.ts
+++ b/lib/tools/__tests__/fetch-error.test.ts
@@ -20,7 +20,7 @@ describe('fetch tool errors', () => {
const result = fetchTool.execute?.(
{ url: 'https://example.com/private', type: 'regular' },
- { toolCallId: 'fetch', messages: [] }
+ { toolCallId: 'fetch', messages: [], context: {} }
)
expect(result).toBeDefined()
@@ -52,7 +52,7 @@ describe('fetch tool errors', () => {
const result = fetchTool.execute?.(
{ url, type: 'regular' },
- { toolCallId: 'fetch', messages: [] }
+ { toolCallId: 'fetch', messages: [], context: {} }
)
expect(result).toBeDefined()
@@ -88,7 +88,7 @@ describe('fetch tool errors', () => {
const result = fetchTool.execute?.(
{ url, type: 'regular' },
- { toolCallId: 'fetch', messages: [] }
+ { toolCallId: 'fetch', messages: [], context: {} }
)
expect(result).toBeDefined()
diff --git a/lib/tools/search.ts b/lib/tools/search.ts
index c2b6b6c7..e3098727 100644
--- a/lib/tools/search.ts
+++ b/lib/tools/search.ts
@@ -211,7 +211,8 @@ export async function search(
},
{
toolCallId: 'search',
- messages: []
+ messages: [],
+ context: {}
}
)
diff --git a/lib/types/agent.ts b/lib/types/agent.ts
index 70e23369..413e1a23 100644
--- a/lib/types/agent.ts
+++ b/lib/types/agent.ts
@@ -11,6 +11,8 @@ import type { createQuestionTool } from '../tools/question'
import type { createSearchTool } from '../tools/search'
import type { createTodoTools } from '../tools/todo'
+import type { SearchMode } from './search'
+
// Define the tools type for researcher agent
export type ResearcherTools = {
search: ReturnType<typeof createSearchTool>
@@ -18,9 +20,22 @@ export type ResearcherTools = {
askQuestion: ReturnType<typeof createQuestionTool>
} & ReturnType<typeof createTodoTools>
+// Runtime context carried through the generation lifecycle. Included in
+// telemetry so each observation keeps the metadata v6 attached via
+// telemetry.metadata.
+export type ResearcherRuntimeContext = {
+ modelId: string
+ agentType: string
+ searchMode: SearchMode
+}
+
// Type alias for the researcher agent using ToolLoopAgent
-// ToolLoopAgent generic signature is <CALL_OPTIONS, TOOLS, OUTPUT>
-export type ResearcherAgent = ToolLoopAgent<never, ResearcherTools, never>
+// ToolLoopAgent generic signature is <CALL_OPTIONS, TOOLS, RUNTIME_CONTEXT, OUTPUT>
+export type ResearcherAgent = ToolLoopAgent<
+ never,
+ ResearcherTools,
+ ResearcherRuntimeContext
+>
// Infer UI message type for researcher agent
export type ResearcherUIMessage = InferAgentUIMessage<ResearcherAgent>
diff --git a/package.json b/package.json
index ce4cdf68..807eef38 100644
--- a/package.json
+++ b/package.json
@@ -18,19 +18,21 @@
"chat": "bun run scripts/chat-cli.ts"
},
"dependencies": {
- "@ai-sdk/anthropic": "^3.0.77",
- "@ai-sdk/gateway": "^3.0.114",
- "@ai-sdk/google": "^3.0.73",
- "@ai-sdk/openai": "^3.0.63",
- "@ai-sdk/openai-compatible": "^2.0.47",
- "@ai-sdk/react": "^3.0.182",
+ "@ai-sdk/anthropic": "^4.0.39",
+ "@ai-sdk/gateway": "^4.0.52",
+ "@ai-sdk/google": "^4.0.44",
+ "@ai-sdk/openai": "^4.0.42",
+ "@ai-sdk/openai-compatible": "^3.0.31",
+ "@ai-sdk/react": "^4.0.69",
"@aws-sdk/client-s3": "3.859.0",
"@aws-sdk/s3-request-presigner": "3.859.0",
"@json-render/core": "^0.16.0",
"@json-render/react": "^0.16.0",
- "@langfuse/client": "^5.9.1",
- "@langfuse/otel": "^5.9.1",
- "@langfuse/tracing": "^5.9.1",
+ "@langfuse/client": "^5.10.1",
+ "@langfuse/otel": "^5.10.1",
+ "@langfuse/tracing": "^5.10.1",
+ "@langfuse/vercel-ai-sdk": "^5.10.1",
+ "@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "0.220.0",
"@opentelemetry/core": "^2.9.0",
"@opentelemetry/instrumentation": "0.220.0",
@@ -65,8 +67,8 @@
"@upstash/redis": "^1.35.5",
"@vercel/analytics": "^1.5.0",
"@vercel/otel": "^2.1.3",
- "ai": "^6.0.180",
- "ai-sdk-ollama": "^3.8.4",
+ "ai": "^7.0.66",
+ "ai-sdk-ollama": "^4.1.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.0",
"cmdk": "1.0.0",