@copilotkit/runtime 0.0.0-fix-debug-infosys-20251107151227 → 0.0.0-fix-restore-handle-method-node-http-20251222114321
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +259 -3
- package/dist/index.d.ts +1493 -28
- package/dist/index.js +2568 -5467
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5429 -99
- package/dist/index.mjs.map +1 -1
- package/dist/{lib/index.d.ts → langgraph.d.ts} +104 -32
- package/dist/langgraph.js +211 -0
- package/dist/langgraph.js.map +1 -0
- package/dist/{chunk-XPALJ76U.mjs → langgraph.mjs} +57 -26
- package/dist/langgraph.mjs.map +1 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +22 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +5 -0
- package/dist/v2/index.mjs.map +1 -0
- package/package.json +64 -20
- package/src/graphql/message-conversion/agui-to-gql.test.ts +1263 -0
- package/src/graphql/message-conversion/agui-to-gql.ts +333 -0
- package/src/graphql/message-conversion/gql-to-agui.test.ts +1580 -0
- package/src/graphql/message-conversion/gql-to-agui.ts +278 -0
- package/src/graphql/message-conversion/index.ts +2 -0
- package/src/graphql/message-conversion/roundtrip-conversion.test.ts +526 -0
- package/src/graphql/resolvers/copilot.resolver.ts +3 -51
- package/src/graphql/resolvers/state.resolver.ts +3 -2
- package/src/graphql/types/converted/index.ts +32 -6
- package/src/graphql/types/enums.ts +2 -2
- package/src/graphql/types/message-status.type.ts +3 -1
- package/src/langgraph.ts +1 -0
- package/src/lib/index.ts +42 -1
- package/src/lib/integrations/nextjs/app-router.ts +12 -11
- package/src/lib/integrations/nextjs/pages-router.ts +4 -11
- package/src/lib/integrations/node-http/index.ts +10 -5
- package/src/lib/integrations/shared.ts +1 -1
- package/src/lib/observability.ts +87 -0
- package/src/lib/runtime/{langgraph/langgraph-agent.ts → agent-integrations/langgraph/agent.ts} +10 -30
- package/src/lib/runtime/agent-integrations/langgraph/consts.ts +34 -0
- package/src/lib/runtime/agent-integrations/langgraph/index.ts +2 -0
- package/src/lib/runtime/copilot-runtime.ts +387 -1360
- package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
- package/src/lib/runtime/types.ts +49 -0
- package/src/lib/runtime/utils.ts +87 -0
- package/src/lib/telemetry-client.ts +6 -5
- package/src/service-adapters/anthropic/anthropic-adapter.ts +21 -4
- package/src/service-adapters/bedrock/bedrock-adapter.ts +10 -2
- package/src/service-adapters/empty/empty-adapter.ts +3 -0
- package/src/service-adapters/events.ts +0 -254
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +7 -2
- package/src/service-adapters/google/google-genai-adapter.ts +33 -7
- package/src/service-adapters/groq/groq-adapter.ts +21 -4
- package/src/service-adapters/langchain/langchain-adapter.ts +8 -3
- package/src/service-adapters/langchain/langserve.ts +2 -1
- package/src/service-adapters/openai/openai-adapter.ts +22 -4
- package/src/service-adapters/openai/openai-assistant-adapter.ts +30 -11
- package/src/service-adapters/service-adapter.ts +3 -0
- package/src/service-adapters/unify/unify-adapter.ts +9 -2
- package/src/v2/index.ts +3 -0
- package/tsup.config.ts +6 -2
- package/dist/chunk-27JKTS6P.mjs +0 -1704
- package/dist/chunk-27JKTS6P.mjs.map +0 -1
- package/dist/chunk-2DHC2YFK.mjs +0 -6026
- package/dist/chunk-2DHC2YFK.mjs.map +0 -1
- package/dist/chunk-2OZAGFV3.mjs +0 -43
- package/dist/chunk-2OZAGFV3.mjs.map +0 -1
- package/dist/chunk-5HHH4SZ3.mjs +0 -25
- package/dist/chunk-5HHH4SZ3.mjs.map +0 -1
- package/dist/chunk-AMUJQ6IR.mjs +0 -50
- package/dist/chunk-AMUJQ6IR.mjs.map +0 -1
- package/dist/chunk-FHD4JECV.mjs +0 -33
- package/dist/chunk-FHD4JECV.mjs.map +0 -1
- package/dist/chunk-FVG3IQG7.mjs +0 -25
- package/dist/chunk-FVG3IQG7.mjs.map +0 -1
- package/dist/chunk-QU2FLIQB.mjs +0 -80
- package/dist/chunk-QU2FLIQB.mjs.map +0 -1
- package/dist/chunk-SHBDMA63.mjs +0 -141
- package/dist/chunk-SHBDMA63.mjs.map +0 -1
- package/dist/chunk-XPALJ76U.mjs.map +0 -1
- package/dist/chunk-XWBDEXDA.mjs +0 -153
- package/dist/chunk-XWBDEXDA.mjs.map +0 -1
- package/dist/graphql/types/base/index.d.ts +0 -6
- package/dist/graphql/types/base/index.js +0 -63
- package/dist/graphql/types/base/index.js.map +0 -1
- package/dist/graphql/types/base/index.mjs +0 -8
- package/dist/graphql/types/base/index.mjs.map +0 -1
- package/dist/graphql/types/converted/index.d.ts +0 -2
- package/dist/graphql/types/converted/index.js +0 -200
- package/dist/graphql/types/converted/index.js.map +0 -1
- package/dist/graphql/types/converted/index.mjs +0 -19
- package/dist/graphql/types/converted/index.mjs.map +0 -1
- package/dist/groq-adapter-c8aec5c5.d.ts +0 -321
- package/dist/index-96b330da.d.ts +0 -119
- package/dist/langserve-0c6100e3.d.ts +0 -257
- package/dist/lib/cloud/index.d.ts +0 -6
- package/dist/lib/cloud/index.js +0 -18
- package/dist/lib/cloud/index.js.map +0 -1
- package/dist/lib/cloud/index.mjs +0 -1
- package/dist/lib/cloud/index.mjs.map +0 -1
- package/dist/lib/index.js +0 -7849
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/index.mjs +0 -76
- package/dist/lib/index.mjs.map +0 -1
- package/dist/lib/integrations/index.d.ts +0 -34
- package/dist/lib/integrations/index.js +0 -3055
- package/dist/lib/integrations/index.js.map +0 -1
- package/dist/lib/integrations/index.mjs +0 -37
- package/dist/lib/integrations/index.mjs.map +0 -1
- package/dist/lib/integrations/nest/index.d.ts +0 -15
- package/dist/lib/integrations/nest/index.js +0 -2962
- package/dist/lib/integrations/nest/index.js.map +0 -1
- package/dist/lib/integrations/nest/index.mjs +0 -14
- package/dist/lib/integrations/nest/index.mjs.map +0 -1
- package/dist/lib/integrations/node-express/index.d.ts +0 -15
- package/dist/lib/integrations/node-express/index.js +0 -2962
- package/dist/lib/integrations/node-express/index.js.map +0 -1
- package/dist/lib/integrations/node-express/index.mjs +0 -14
- package/dist/lib/integrations/node-express/index.mjs.map +0 -1
- package/dist/lib/integrations/node-http/index.d.ts +0 -15
- package/dist/lib/integrations/node-http/index.js +0 -2948
- package/dist/lib/integrations/node-http/index.js.map +0 -1
- package/dist/lib/integrations/node-http/index.mjs +0 -13
- package/dist/lib/integrations/node-http/index.mjs.map +0 -1
- package/dist/service-adapters/index.d.ts +0 -162
- package/dist/service-adapters/index.js +0 -1787
- package/dist/service-adapters/index.js.map +0 -1
- package/dist/service-adapters/index.mjs +0 -34
- package/dist/service-adapters/index.mjs.map +0 -1
- package/dist/service-adapters/shared/index.d.ts +0 -9
- package/dist/service-adapters/shared/index.js +0 -72
- package/dist/service-adapters/shared/index.js.map +0 -1
- package/dist/service-adapters/shared/index.mjs +0 -8
- package/dist/service-adapters/shared/index.mjs.map +0 -1
- package/dist/shared-0a7346ce.d.ts +0 -466
- package/dist/utils/index.d.ts +0 -65
- package/dist/utils/index.js +0 -175
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -12
- package/dist/utils/index.mjs.map +0 -1
- package/src/lib/runtime/__tests__/remote-action-constructors.test.ts +0 -246
- package/src/lib/runtime/agui-action.ts +0 -180
- package/src/lib/runtime/remote-action-constructors.ts +0 -331
- package/src/lib/runtime/remote-actions.ts +0 -217
- package/src/lib/runtime/remote-lg-action.ts +0 -1006
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { registerEnumType } from "type-graphql";
|
|
2
2
|
|
|
3
3
|
export enum MessageRole {
|
|
4
|
-
user = "user",
|
|
5
4
|
assistant = "assistant",
|
|
5
|
+
developer = "developer",
|
|
6
6
|
system = "system",
|
|
7
7
|
tool = "tool",
|
|
8
|
-
|
|
8
|
+
user = "user",
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export enum CopilotRequestType {
|
|
@@ -11,7 +11,7 @@ registerEnumType(MessageStatusCode, {
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
@ObjectType()
|
|
14
|
-
class BaseMessageStatus {
|
|
14
|
+
export class BaseMessageStatus {
|
|
15
15
|
@Field(() => MessageStatusCode)
|
|
16
16
|
code: MessageStatusCode;
|
|
17
17
|
}
|
|
@@ -38,3 +38,5 @@ export const MessageStatusUnion = createUnionType({
|
|
|
38
38
|
name: "MessageStatus",
|
|
39
39
|
types: () => [PendingMessageStatus, SuccessMessageStatus, FailedMessageStatus] as const,
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
export type MessageStatus = typeof MessageStatusUnion;
|
package/src/langgraph.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./lib/runtime/agent-integrations/langgraph";
|
package/src/lib/index.ts
CHANGED
|
@@ -8,4 +8,45 @@ export * from "./integrations";
|
|
|
8
8
|
export * from "./logger";
|
|
9
9
|
export * from "./runtime/copilot-runtime";
|
|
10
10
|
export * from "./runtime/mcp-tools-utils";
|
|
11
|
-
export * from "./runtime/
|
|
11
|
+
export * from "./runtime/telemetry-agent-runner";
|
|
12
|
+
|
|
13
|
+
// The below re-exports "dummy" classes and types, to get a deprecation warning redirecting the users to import these from the correct, new route
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
|
|
17
|
+
*/
|
|
18
|
+
export class LangGraphAgent {
|
|
19
|
+
constructor() {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead",
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
|
|
28
|
+
*/
|
|
29
|
+
export class LangGraphHttpAgent {
|
|
30
|
+
constructor() {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead",
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
|
|
39
|
+
*/
|
|
40
|
+
export type TextMessageEvents = any;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
|
|
43
|
+
*/
|
|
44
|
+
export type ToolCallEvents = any;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
|
|
47
|
+
*/
|
|
48
|
+
export type CustomEventNames = any;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
|
|
51
|
+
*/
|
|
52
|
+
export type PredictStateTool = any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCopilotEndpointSingleRoute } from "@copilotkitnext/runtime";
|
|
2
2
|
import { CreateCopilotRuntimeServerOptions, getCommonConfig } from "../shared";
|
|
3
3
|
import telemetry, { getRuntimeInstanceTelemetryInfo } from "../../telemetry-client";
|
|
4
|
+
import { handle } from "hono/vercel";
|
|
4
5
|
|
|
5
6
|
export function copilotRuntimeNextJSAppRouterEndpoint(options: CreateCopilotRuntimeServerOptions) {
|
|
6
7
|
const commonConfig = getCommonConfig(options);
|
|
@@ -22,16 +23,16 @@ export function copilotRuntimeNextJSAppRouterEndpoint(options: CreateCopilotRunt
|
|
|
22
23
|
const logger = commonConfig.logging;
|
|
23
24
|
logger.debug("Creating NextJS App Router endpoint");
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const serviceAdapter = options.serviceAdapter;
|
|
27
|
+
if (serviceAdapter) {
|
|
28
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const copilotRoute = createCopilotEndpointSingleRoute({
|
|
32
|
+
runtime: options.runtime.instance,
|
|
33
|
+
basePath: options.baseUrl ?? options.endpoint,
|
|
29
34
|
});
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
GET: yoga as any,
|
|
34
|
-
POST: yoga as any,
|
|
35
|
-
OPTIONS: yoga as any,
|
|
36
|
-
};
|
|
36
|
+
const handleRequest = handle(copilotRoute as any);
|
|
37
|
+
return { handleRequest };
|
|
37
38
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CreateCopilotRuntimeServerOptions, GraphQLContext, getCommonConfig } from "../shared";
|
|
1
|
+
import { CreateCopilotRuntimeServerOptions, getCommonConfig } from "../shared";
|
|
3
2
|
import telemetry, { getRuntimeInstanceTelemetryInfo } from "../../telemetry-client";
|
|
3
|
+
import { copilotRuntimeNodeHttpEndpoint } from "../node-http";
|
|
4
4
|
|
|
5
5
|
export const config = {
|
|
6
6
|
api: {
|
|
@@ -8,8 +8,6 @@ export const config = {
|
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export type CopilotRuntimeServerInstance<T> = YogaServerInstance<T, Partial<GraphQLContext>>;
|
|
12
|
-
|
|
13
11
|
// This import is needed to fix the type error
|
|
14
12
|
// Fix is currently in TypeScript 5.5 beta, waiting for stable version
|
|
15
13
|
// https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2066874644
|
|
@@ -17,7 +15,7 @@ export type {} from "@whatwg-node/server";
|
|
|
17
15
|
|
|
18
16
|
export function copilotRuntimeNextJSPagesRouterEndpoint(
|
|
19
17
|
options: CreateCopilotRuntimeServerOptions,
|
|
20
|
-
)
|
|
18
|
+
) {
|
|
21
19
|
const commonConfig = getCommonConfig(options);
|
|
22
20
|
|
|
23
21
|
telemetry.setGlobalProperties({
|
|
@@ -37,10 +35,5 @@ export function copilotRuntimeNextJSPagesRouterEndpoint(
|
|
|
37
35
|
const logger = commonConfig.logging;
|
|
38
36
|
logger.debug("Creating NextJS Pages Router endpoint");
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
...commonConfig,
|
|
42
|
-
graphqlEndpoint: options.endpoint,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return yoga;
|
|
38
|
+
return copilotRuntimeNodeHttpEndpoint(options);
|
|
46
39
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createYoga } from "graphql-yoga";
|
|
2
1
|
import { CreateCopilotRuntimeServerOptions, getCommonConfig } from "../shared";
|
|
3
2
|
import telemetry, { getRuntimeInstanceTelemetryInfo } from "../../telemetry-client";
|
|
3
|
+
import { createCopilotEndpointSingleRoute } from "@copilotkitnext/runtime";
|
|
4
4
|
|
|
5
5
|
export function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions) {
|
|
6
6
|
const commonConfig = getCommonConfig(options);
|
|
@@ -22,10 +22,15 @@ export function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServ
|
|
|
22
22
|
const logger = commonConfig.logging;
|
|
23
23
|
logger.debug("Creating Node HTTP endpoint");
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const serviceAdapter = options.serviceAdapter;
|
|
26
|
+
if (serviceAdapter) {
|
|
27
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const honoApp = createCopilotEndpointSingleRoute({
|
|
31
|
+
runtime: options.runtime.instance,
|
|
32
|
+
basePath: options.baseUrl ?? options.endpoint,
|
|
28
33
|
});
|
|
29
34
|
|
|
30
|
-
return
|
|
35
|
+
return honoApp.fetch;
|
|
31
36
|
}
|
|
@@ -35,7 +35,7 @@ export type GraphQLContext = YogaInitialContext & {
|
|
|
35
35
|
|
|
36
36
|
export interface CreateCopilotRuntimeServerOptions {
|
|
37
37
|
runtime: CopilotRuntime<any>;
|
|
38
|
-
serviceAdapter
|
|
38
|
+
serviceAdapter?: CopilotServiceAdapter;
|
|
39
39
|
endpoint: string;
|
|
40
40
|
baseUrl?: string;
|
|
41
41
|
cloud?: CopilotCloudOptions;
|
package/src/lib/observability.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RuntimeEventSource, RuntimeEventTypes } from "../service-adapters/events";
|
|
2
|
+
|
|
1
3
|
export interface LLMRequestData {
|
|
2
4
|
threadId?: string;
|
|
3
5
|
runId?: string;
|
|
@@ -71,3 +73,88 @@ export interface CopilotObservabilityConfig {
|
|
|
71
73
|
*/
|
|
72
74
|
hooks: CopilotObservabilityHooks;
|
|
73
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Setup progressive logging by wrapping the event stream
|
|
79
|
+
*/
|
|
80
|
+
function setupProgressiveLogging(
|
|
81
|
+
eventSource: RuntimeEventSource,
|
|
82
|
+
streamedChunks: any[],
|
|
83
|
+
requestStartTime: number,
|
|
84
|
+
context: {
|
|
85
|
+
threadId?: string;
|
|
86
|
+
runId?: string;
|
|
87
|
+
model?: string;
|
|
88
|
+
provider?: string;
|
|
89
|
+
agentName?: string;
|
|
90
|
+
nodeName?: string;
|
|
91
|
+
},
|
|
92
|
+
publicApiKey?: string,
|
|
93
|
+
): void {
|
|
94
|
+
if (this.observability?.enabled && this.observability.progressive && publicApiKey) {
|
|
95
|
+
// Keep reference to original stream function
|
|
96
|
+
const originalStream = eventSource.stream.bind(eventSource);
|
|
97
|
+
|
|
98
|
+
// Wrap the stream function to intercept events
|
|
99
|
+
eventSource.stream = async (callback) => {
|
|
100
|
+
await originalStream(async (eventStream$) => {
|
|
101
|
+
// Create subscription to capture streaming events
|
|
102
|
+
eventStream$.subscribe({
|
|
103
|
+
next: (event) => {
|
|
104
|
+
// Only log content chunks
|
|
105
|
+
if (event.type === RuntimeEventTypes.TextMessageContent) {
|
|
106
|
+
// Store the chunk
|
|
107
|
+
streamedChunks.push(event.content);
|
|
108
|
+
|
|
109
|
+
// Log each chunk separately for progressive mode
|
|
110
|
+
try {
|
|
111
|
+
const progressiveData: LLMResponseData = {
|
|
112
|
+
threadId: context.threadId || "",
|
|
113
|
+
runId: context.runId,
|
|
114
|
+
model: context.model,
|
|
115
|
+
output: event.content,
|
|
116
|
+
latency: Date.now() - requestStartTime,
|
|
117
|
+
timestamp: Date.now(),
|
|
118
|
+
provider: context.provider,
|
|
119
|
+
isProgressiveChunk: true,
|
|
120
|
+
agentName: context.agentName,
|
|
121
|
+
nodeName: context.nodeName,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Use Promise to handle async logger without awaiting
|
|
125
|
+
Promise.resolve()
|
|
126
|
+
.then(() => {
|
|
127
|
+
this.observability.hooks.handleResponse(progressiveData);
|
|
128
|
+
})
|
|
129
|
+
.catch((error) => {
|
|
130
|
+
console.error("Error in progressive logging:", error);
|
|
131
|
+
});
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error("Error preparing progressive log data:", error);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Call the original callback with the event stream
|
|
140
|
+
await callback(eventStream$);
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Log error if observability is enabled
|
|
148
|
+
*/
|
|
149
|
+
async function logObservabilityError(
|
|
150
|
+
errorData: LLMErrorData,
|
|
151
|
+
publicApiKey?: string,
|
|
152
|
+
): Promise<void> {
|
|
153
|
+
if (this.observability?.enabled && publicApiKey) {
|
|
154
|
+
try {
|
|
155
|
+
await this.observability.hooks.handleError(errorData);
|
|
156
|
+
} catch (logError) {
|
|
157
|
+
console.error("Error logging LLM error:", logError);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
package/src/lib/runtime/{langgraph/langgraph-agent.ts → agent-integrations/langgraph/agent.ts}
RENAMED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RunAgentInput,
|
|
3
|
-
EventType,
|
|
4
|
-
CustomEvent,
|
|
5
|
-
TextMessageStartEvent,
|
|
6
|
-
TextMessageContentEvent,
|
|
7
|
-
TextMessageEndEvent,
|
|
8
|
-
ToolCallStartEvent,
|
|
9
|
-
ToolCallArgsEvent,
|
|
10
|
-
ToolCallEndEvent,
|
|
11
|
-
} from "@ag-ui/client";
|
|
12
1
|
import { map } from "rxjs";
|
|
13
|
-
import { LangGraphEventTypes } from "
|
|
2
|
+
import { LangGraphEventTypes } from "../../../../agents/langgraph/events";
|
|
14
3
|
import { RawEvent } from "@ag-ui/core";
|
|
15
4
|
import {
|
|
16
5
|
LangGraphAgent as AGUILangGraphAgent,
|
|
@@ -31,31 +20,22 @@ interface CopilotKitStateEnrichment {
|
|
|
31
20
|
};
|
|
32
21
|
}
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
tool: string;
|
|
36
|
-
state_key: string;
|
|
37
|
-
tool_argument: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type TextMessageEvents =
|
|
41
|
-
| TextMessageStartEvent
|
|
42
|
-
| TextMessageContentEvent
|
|
43
|
-
| TextMessageEndEvent;
|
|
44
|
-
|
|
45
|
-
export type ToolCallEvents = ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent;
|
|
23
|
+
import { RunAgentInput, EventType, CustomEvent } from "@ag-ui/client";
|
|
46
24
|
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
CopilotKitManuallyEmitIntermediateState = "copilotkit_manually_emit_intermediate_state",
|
|
51
|
-
CopilotKitExit = "copilotkit_exit",
|
|
52
|
-
}
|
|
25
|
+
// Import and re-export from separate file to maintain API compatibility
|
|
26
|
+
import { CustomEventNames, TextMessageEvents, ToolCallEvents, PredictStateTool } from "./consts";
|
|
27
|
+
export { CustomEventNames };
|
|
53
28
|
|
|
54
29
|
export class LangGraphAgent extends AGUILangGraphAgent {
|
|
55
30
|
constructor(config: LangGraphAgentConfig) {
|
|
56
31
|
super(config);
|
|
57
32
|
}
|
|
58
33
|
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
public clone() {
|
|
36
|
+
return new LangGraphAgent(this.config);
|
|
37
|
+
}
|
|
38
|
+
|
|
59
39
|
dispatchEvent(event: ProcessedEvents) {
|
|
60
40
|
if (event.type === EventType.CUSTOM) {
|
|
61
41
|
// const event = processedEvent as unknown as CustomEvent;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for LangGraph integration.
|
|
3
|
+
* This file is separate from langgraph.agent.ts to avoid pulling in @ag-ui/langgraph
|
|
4
|
+
* when only these constants are needed.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
TextMessageStartEvent,
|
|
9
|
+
TextMessageContentEvent,
|
|
10
|
+
TextMessageEndEvent,
|
|
11
|
+
ToolCallStartEvent,
|
|
12
|
+
ToolCallArgsEvent,
|
|
13
|
+
ToolCallEndEvent,
|
|
14
|
+
} from "@ag-ui/client";
|
|
15
|
+
|
|
16
|
+
export type TextMessageEvents =
|
|
17
|
+
| TextMessageStartEvent
|
|
18
|
+
| TextMessageContentEvent
|
|
19
|
+
| TextMessageEndEvent;
|
|
20
|
+
|
|
21
|
+
export type ToolCallEvents = ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent;
|
|
22
|
+
|
|
23
|
+
export enum CustomEventNames {
|
|
24
|
+
CopilotKitManuallyEmitMessage = "copilotkit_manually_emit_message",
|
|
25
|
+
CopilotKitManuallyEmitToolCall = "copilotkit_manually_emit_tool_call",
|
|
26
|
+
CopilotKitManuallyEmitIntermediateState = "copilotkit_manually_emit_intermediate_state",
|
|
27
|
+
CopilotKitExit = "copilotkit_exit",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface PredictStateTool {
|
|
31
|
+
tool: string;
|
|
32
|
+
state_key: string;
|
|
33
|
+
tool_argument: string;
|
|
34
|
+
}
|