@copilotkit/runtime 1.50.0-beta.10 → 1.50.0-beta.11
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 +11 -0
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/lib/runtime/copilot-runtime.ts +38 -4
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.50.0-beta.
|
|
12
|
+
"version": "1.50.0-beta.11",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"rxjs": "7.8.1",
|
|
72
72
|
"type-graphql": "2.0.0-rc.1",
|
|
73
73
|
"zod": "^3.23.3",
|
|
74
|
-
"@copilotkit/shared": "1.50.0-beta.
|
|
74
|
+
"@copilotkit/shared": "1.50.0-beta.11"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@anthropic-ai/sdk": "^0.57.0",
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
readBody,
|
|
23
23
|
getZodParameters,
|
|
24
24
|
type PartialBy,
|
|
25
|
+
isTelemetryDisabled,
|
|
25
26
|
} from "@copilotkit/shared";
|
|
26
27
|
import type { RunAgentInput } from "@ag-ui/core";
|
|
27
28
|
import { aguiToGQL } from "../../graphql/message-conversion/agui-to-gql";
|
|
@@ -30,8 +31,10 @@ import {
|
|
|
30
31
|
CopilotRuntime as CopilotRuntimeVNext,
|
|
31
32
|
type CopilotRuntimeOptions,
|
|
32
33
|
type CopilotRuntimeOptions as CopilotRuntimeOptionsVNext,
|
|
34
|
+
InMemoryAgentRunner,
|
|
33
35
|
} from "@copilotkitnext/runtime";
|
|
34
36
|
import { TelemetryAgentRunner } from "./telemetry-agent-runner";
|
|
37
|
+
import telemetry from "../telemetry-client";
|
|
35
38
|
|
|
36
39
|
import type { MessageInput } from "../../graphql/inputs/message.input";
|
|
37
40
|
import type { Message } from "../../graphql/types/converted";
|
|
@@ -308,11 +311,19 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
308
311
|
const agents = params?.agents ?? {};
|
|
309
312
|
const endpointAgents = this.assignEndpointsToAgents(params?.remoteEndpoints ?? []);
|
|
310
313
|
|
|
314
|
+
// Determine the base runner (user-provided or default)
|
|
315
|
+
const baseRunner = params?.runner ?? new InMemoryAgentRunner();
|
|
316
|
+
|
|
317
|
+
// Wrap with TelemetryAgentRunner unless telemetry is disabled
|
|
318
|
+
// This ensures we always capture agent execution telemetry when enabled,
|
|
319
|
+
// even if the user provides their own custom runner
|
|
320
|
+
const runner = isTelemetryDisabled()
|
|
321
|
+
? baseRunner
|
|
322
|
+
: new TelemetryAgentRunner({ runner: baseRunner });
|
|
323
|
+
|
|
311
324
|
this.runtimeArgs = {
|
|
312
325
|
agents: { ...endpointAgents, ...agents },
|
|
313
|
-
|
|
314
|
-
// Users can pass their own runner which will be wrapped for telemetry
|
|
315
|
-
runner: params?.runner ?? new TelemetryAgentRunner(),
|
|
326
|
+
runner,
|
|
316
327
|
// TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
|
|
317
328
|
// transcriptionService: params?.transcriptionService,
|
|
318
329
|
|
|
@@ -439,6 +450,30 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
439
450
|
params?: CopilotRuntimeConstructorParams<T> & PartialBy<CopilotRuntimeOptions, "agents">,
|
|
440
451
|
) {
|
|
441
452
|
return async (hookParams: BeforeRequestMiddlewareFnParameters[0]) => {
|
|
453
|
+
const { request } = hookParams;
|
|
454
|
+
|
|
455
|
+
// Capture telemetry for copilot request creation
|
|
456
|
+
const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
|
|
457
|
+
const body = (await readBody(request)) as RunAgentInput;
|
|
458
|
+
const forwardedProps = body.forwardedProps as
|
|
459
|
+
| {
|
|
460
|
+
cloud?: { guardrails?: unknown };
|
|
461
|
+
metadata?: { requestType?: string };
|
|
462
|
+
}
|
|
463
|
+
| undefined;
|
|
464
|
+
|
|
465
|
+
// Get cloud base URL from environment or default
|
|
466
|
+
const cloudBaseUrl =
|
|
467
|
+
process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
|
|
468
|
+
|
|
469
|
+
telemetry.capture("oss.runtime.copilot_request_created", {
|
|
470
|
+
"cloud.guardrails.enabled": forwardedProps?.cloud?.guardrails !== undefined,
|
|
471
|
+
requestType: forwardedProps?.metadata?.requestType ?? "unknown",
|
|
472
|
+
"cloud.api_key_provided": !!publicApiKey,
|
|
473
|
+
...(publicApiKey ? { "cloud.public_api_key": publicApiKey } : {}),
|
|
474
|
+
"cloud.base_url": cloudBaseUrl,
|
|
475
|
+
});
|
|
476
|
+
|
|
442
477
|
// TODO: get public api key and run with expected data
|
|
443
478
|
// if (this.observability?.enabled && this.params.publicApiKey) {
|
|
444
479
|
// this.logObservabilityBeforeRequest()
|
|
@@ -449,7 +484,6 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
449
484
|
|
|
450
485
|
if (params?.middleware?.onBeforeRequest) {
|
|
451
486
|
const { request, runtime, path } = hookParams;
|
|
452
|
-
const body = (await readBody(request)) as RunAgentInput;
|
|
453
487
|
const gqlMessages = (aguiToGQL(body.messages) as Message[]).reduce(
|
|
454
488
|
(acc, msg) => {
|
|
455
489
|
if ("role" in msg && msg.role === "user") {
|