@copilotkit/runtime 1.69.3 → 1.70.0
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/dist/agent/index.cjs +1 -1
- package/dist/agent/index.d.mts +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/graphql/resolvers/copilot.resolver.cjs +1 -2
- package/dist/graphql/resolvers/copilot.resolver.cjs.map +1 -1
- package/dist/graphql/resolvers/copilot.resolver.mjs +1 -2
- package/dist/graphql/resolvers/copilot.resolver.mjs.map +1 -1
- package/dist/lib/integrations/nest/index.cjs +1 -1
- package/dist/lib/integrations/nest/index.cjs.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +1 -1
- package/dist/lib/integrations/nest/index.mjs.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.cjs +1 -1
- package/dist/lib/integrations/nextjs/app-router.cjs.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.d.cts.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.d.mts.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.mjs +1 -1
- package/dist/lib/integrations/nextjs/app-router.mjs.map +1 -1
- package/dist/lib/integrations/nextjs/pages-router.cjs +1 -1
- package/dist/lib/integrations/nextjs/pages-router.cjs.map +1 -1
- package/dist/lib/integrations/nextjs/pages-router.mjs +1 -1
- package/dist/lib/integrations/nextjs/pages-router.mjs.map +1 -1
- package/dist/lib/integrations/node-express/index.cjs +1 -1
- package/dist/lib/integrations/node-express/index.cjs.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +1 -1
- package/dist/lib/integrations/node-express/index.mjs.map +1 -1
- package/dist/lib/integrations/node-http/index.cjs +1 -1
- package/dist/lib/integrations/node-http/index.cjs.map +1 -1
- package/dist/lib/integrations/node-http/index.d.cts.map +1 -1
- package/dist/lib/integrations/node-http/index.d.mts.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/lib/integrations/node-http/index.mjs.map +1 -1
- package/dist/lib/integrations/shared.cjs +1 -1
- package/dist/lib/integrations/shared.mjs +1 -1
- package/dist/lib/runtime/copilot-runtime.cjs +13 -5
- package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts +5 -1
- package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.mts +5 -1
- package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.mjs +13 -5
- package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.cjs +4 -3
- package/dist/lib/runtime/telemetry-agent-runner.cjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.cts +4 -0
- package/dist/lib/runtime/telemetry-agent-runner.d.cts.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.mts +4 -0
- package/dist/lib/runtime/telemetry-agent-runner.d.mts.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.mjs +4 -3
- package/dist/lib/runtime/telemetry-agent-runner.mjs.map +1 -1
- package/dist/lib/telemetry-disclosure.cjs +4 -4
- package/dist/lib/telemetry-disclosure.cjs.map +1 -1
- package/dist/lib/telemetry-disclosure.mjs +4 -4
- package/dist/lib/telemetry-disclosure.mjs.map +1 -1
- package/dist/package.cjs +4 -4
- package/dist/package.mjs +4 -4
- package/dist/v2/index.d.cts +3 -3
- package/dist/v2/index.d.mts +3 -3
- package/dist/v2/runtime/core/channel-manager.cjs +24 -8
- package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
- package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -1
- package/dist/v2/runtime/core/channel-manager.d.mts +1 -1
- package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
- package/dist/v2/runtime/core/channel-manager.mjs +25 -9
- package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.cjs +1 -0
- package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.mjs +1 -0
- package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
- package/dist/v2/runtime/core/learning.cjs +7 -0
- package/dist/v2/runtime/core/learning.cjs.map +1 -1
- package/dist/v2/runtime/core/learning.d.cts +21 -1
- package/dist/v2/runtime/core/learning.d.cts.map +1 -1
- package/dist/v2/runtime/core/learning.d.mts +21 -1
- package/dist/v2/runtime/core/learning.d.mts.map +1 -1
- package/dist/v2/runtime/core/learning.mjs +7 -1
- package/dist/v2/runtime/core/learning.mjs.map +1 -1
- package/dist/v2/runtime/core/runtime.cjs +10 -4
- package/dist/v2/runtime/core/runtime.cjs.map +1 -1
- package/dist/v2/runtime/core/runtime.d.cts +17 -7
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
- package/dist/v2/runtime/core/runtime.d.mts +17 -7
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
- package/dist/v2/runtime/core/runtime.mjs +10 -4
- package/dist/v2/runtime/core/runtime.mjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.cjs +53 -2
- package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.mjs +53 -2
- package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-connect.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-connect.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.cjs +11 -4
- package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.mjs +12 -5
- package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/sse-response.cjs +4 -4
- package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/sse-response.mjs +4 -4
- package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.cjs +1 -0
- package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.mjs +1 -0
- package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.cjs +1 -0
- package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.mjs +1 -0
- package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
- package/dist/v2/runtime/index.d.cts +2 -2
- package/dist/v2/runtime/index.d.mts +2 -2
- package/dist/v2/runtime/intelligence-platform/client.cjs +170 -3
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts +22 -3
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts +22 -3
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +170 -3
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/v2/runtime/telemetry/events.d.cts +55 -0
- package/dist/v2/runtime/telemetry/events.d.cts.map +1 -0
- package/dist/v2/runtime/telemetry/events.d.mts +55 -0
- package/dist/v2/runtime/telemetry/events.d.mts.map +1 -0
- package/dist/v2/runtime/telemetry/instance-created.cjs +4 -2
- package/dist/v2/runtime/telemetry/instance-created.cjs.map +1 -1
- package/dist/v2/runtime/telemetry/instance-created.mjs +4 -2
- package/dist/v2/runtime/telemetry/instance-created.mjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.cjs +48 -6
- package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.d.cts +11 -0
- package/dist/v2/runtime/telemetry/telemetry-client.d.cts.map +1 -0
- package/dist/v2/runtime/telemetry/telemetry-client.d.mts +11 -0
- package/dist/v2/runtime/telemetry/telemetry-client.d.mts.map +1 -0
- package/dist/v2/runtime/telemetry/telemetry-client.mjs +50 -7
- package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-identity.cjs +13 -0
- package/dist/v2/runtime/telemetry/telemetry-identity.cjs.map +1 -0
- package/dist/v2/runtime/telemetry/telemetry-identity.mjs +12 -0
- package/dist/v2/runtime/telemetry/telemetry-identity.mjs.map +1 -0
- package/package.json +7 -7
- package/skills/runtime/SKILL.md +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { GetLearningContainerId } from "../core/learning.cjs";
|
|
3
|
+
import { InspectorMetadataV1, RuntimeEntitlementResponse } from "@copilotkit/shared";
|
|
3
4
|
|
|
4
5
|
//#region src/v2/runtime/intelligence-platform/client.d.ts
|
|
5
6
|
interface RuntimeMemoryGrant {
|
|
@@ -53,6 +54,14 @@ interface CopilotKitIntelligenceConfig {
|
|
|
53
54
|
wsUrl?: string;
|
|
54
55
|
/** API key for authenticating with CopilotKit Intelligence */
|
|
55
56
|
apiKey: string;
|
|
57
|
+
/**
|
|
58
|
+
* Chooses the stable Learning Container ID for each Intelligence run.
|
|
59
|
+
* The callback receives the resolved application user and AG-UI run input.
|
|
60
|
+
* It must return the same ID for every run on one Thread because a Thread
|
|
61
|
+
* cannot move between Learning Containers after its first assignment.
|
|
62
|
+
* Return `null` or `undefined` to leave the Thread unassigned.
|
|
63
|
+
*/
|
|
64
|
+
getLearningContainerId?: GetLearningContainerId;
|
|
56
65
|
/**
|
|
57
66
|
* Enable Enterprise Learning — expose CopilotKit Intelligence's
|
|
58
67
|
* built-in tools (bash + thread/memory tools) to agent runs on an
|
|
@@ -379,7 +388,7 @@ interface ThreadLockInfo {
|
|
|
379
388
|
* import { CopilotKitIntelligence, CopilotRuntime } from "@copilotkit/runtime";
|
|
380
389
|
*
|
|
381
390
|
* const intelligence = new CopilotKitIntelligence({
|
|
382
|
-
* apiKey: process.env.
|
|
391
|
+
* apiKey: process.env.CPK_INTELLIGENCE_API_KEY!,
|
|
383
392
|
* });
|
|
384
393
|
*
|
|
385
394
|
* const runtime = new CopilotRuntime({
|
|
@@ -400,7 +409,7 @@ interface ThreadLockInfo {
|
|
|
400
409
|
* const intelligence = new CopilotKitIntelligence({
|
|
401
410
|
* apiUrl: "https://api.intelligence.example.com",
|
|
402
411
|
* wsUrl: "wss://realtime.intelligence.example.com",
|
|
403
|
-
* apiKey: process.env.
|
|
412
|
+
* apiKey: process.env.CPK_INTELLIGENCE_API_KEY!,
|
|
404
413
|
* });
|
|
405
414
|
* ```
|
|
406
415
|
*/
|
|
@@ -454,6 +463,8 @@ declare class CopilotKitIntelligence {
|
|
|
454
463
|
ɵgetRunnerAuthToken(): string;
|
|
455
464
|
/** @internal Used by `attachIntelligenceEnterpriseLearning` to populate `Authorization`. */
|
|
456
465
|
ɵgetApiKey(): string;
|
|
466
|
+
/** @internal Used by the Intelligence runtime to assign Learning Containers. */
|
|
467
|
+
ɵgetLearningContainerId(): GetLearningContainerId | undefined;
|
|
457
468
|
/** @internal Used by `attachIntelligenceEnterpriseLearning` to gate MCP attachment. */
|
|
458
469
|
ɵisEnterpriseLearningEnabled(): boolean;
|
|
459
470
|
/**
|
|
@@ -468,6 +479,14 @@ declare class CopilotKitIntelligence {
|
|
|
468
479
|
* @throws {@link PlatformRequestError} for provider failures other than 404.
|
|
469
480
|
*/
|
|
470
481
|
getInspectorMetadata(): Promise<InspectorMetadataV1 | undefined>;
|
|
482
|
+
/**
|
|
483
|
+
* Resolve the Runtime entitlement projection for this project.
|
|
484
|
+
*
|
|
485
|
+
* Concurrent calls share one request. Active grants cache for 30 seconds;
|
|
486
|
+
* inactive results and failures cache for 5 seconds. Callers receive copies
|
|
487
|
+
* so they cannot mutate cached authority.
|
|
488
|
+
*/
|
|
489
|
+
getRuntimeEntitlements(): Promise<RuntimeEntitlementResponse>;
|
|
471
490
|
/**
|
|
472
491
|
* List all non-archived threads for a given user and agent.
|
|
473
492
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/client.ts"],"mappings":";;;;;UAiIU,kBAAA;EAAA,SACC,IAAA;EAAA,SACA,OAAA;AAAA;;;;;;;;;;;;;;;;;;;UA+FM,oBAAA;EACf,QAAA;EACA,MAAA;EACA,OAAA;AAAA;AAAA,UAGe,4BAAA;EAqFf;;;;;;AAUF;EAvFE,MAAA;;;;;;;;;;AAsGF;;;EAzFE,KAAA;EA2FA;EAzFA,MAAA;EA6FA;;;;;;;EArFA,sBAAA,GAAyB,sBAAA;EAiGU;;;;AAKrC;;;;;AASA;;;;;EAhGE,wBAAA;EAoGA;;;AASF;EAxGE,eAAA,IAAmB,MAAA,EAAQ,aAAA;;;;AA+G7B;EA1GE,eAAA,IAAmB,MAAA,EAAQ,aAAA;;;;;EAK3B,eAAA,IAAmB,MAAA,EAAQ,oBAAA;AAAA;;;;AAmH7B;;;;UAzGiB,aAAA;EA6Gf;EA3GA,EAAA;EA+GA;EA7GA,IAAA;EA6GqB;EA3GrB,SAAA;EA8Ge;EA5Gf,aAAA;;EAEA,SAAA;EA2GM;EAzGN,SAAA;EA4GyC;EA1GzC,QAAA;EA2GA;EAzGA,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BAAA;EAwBL,kBAAA,CAAmB,MAAA,EAAQ,wBAAA,GAA2B,OAAA;EAUtD,gBAAA,CACJ,MAAA,EAAQ,sBAAA,GACP,OAAA,CAAQ,uBAAA;EAcL,kBAAA,CAAmB,MAAA;IACvB,QAAA;IACA,MAAA;EAAA,IACE,OAAA,CAAQ,wBAAA;EAQN,cAAA,CAAe,MAAA;IACnB,QAAA;IACA,MAAA;IACA,OAAA;EAAA,IACE,OAAA,CAAQ,qBAAA;AAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { GetLearningContainerId } from "../core/learning.mjs";
|
|
3
|
+
import { InspectorMetadataV1, RuntimeEntitlementResponse } from "@copilotkit/shared";
|
|
3
4
|
|
|
4
5
|
//#region src/v2/runtime/intelligence-platform/client.d.ts
|
|
5
6
|
interface RuntimeMemoryGrant {
|
|
@@ -53,6 +54,14 @@ interface CopilotKitIntelligenceConfig {
|
|
|
53
54
|
wsUrl?: string;
|
|
54
55
|
/** API key for authenticating with CopilotKit Intelligence */
|
|
55
56
|
apiKey: string;
|
|
57
|
+
/**
|
|
58
|
+
* Chooses the stable Learning Container ID for each Intelligence run.
|
|
59
|
+
* The callback receives the resolved application user and AG-UI run input.
|
|
60
|
+
* It must return the same ID for every run on one Thread because a Thread
|
|
61
|
+
* cannot move between Learning Containers after its first assignment.
|
|
62
|
+
* Return `null` or `undefined` to leave the Thread unassigned.
|
|
63
|
+
*/
|
|
64
|
+
getLearningContainerId?: GetLearningContainerId;
|
|
56
65
|
/**
|
|
57
66
|
* Enable Enterprise Learning — expose CopilotKit Intelligence's
|
|
58
67
|
* built-in tools (bash + thread/memory tools) to agent runs on an
|
|
@@ -379,7 +388,7 @@ interface ThreadLockInfo {
|
|
|
379
388
|
* import { CopilotKitIntelligence, CopilotRuntime } from "@copilotkit/runtime";
|
|
380
389
|
*
|
|
381
390
|
* const intelligence = new CopilotKitIntelligence({
|
|
382
|
-
* apiKey: process.env.
|
|
391
|
+
* apiKey: process.env.CPK_INTELLIGENCE_API_KEY!,
|
|
383
392
|
* });
|
|
384
393
|
*
|
|
385
394
|
* const runtime = new CopilotRuntime({
|
|
@@ -400,7 +409,7 @@ interface ThreadLockInfo {
|
|
|
400
409
|
* const intelligence = new CopilotKitIntelligence({
|
|
401
410
|
* apiUrl: "https://api.intelligence.example.com",
|
|
402
411
|
* wsUrl: "wss://realtime.intelligence.example.com",
|
|
403
|
-
* apiKey: process.env.
|
|
412
|
+
* apiKey: process.env.CPK_INTELLIGENCE_API_KEY!,
|
|
404
413
|
* });
|
|
405
414
|
* ```
|
|
406
415
|
*/
|
|
@@ -454,6 +463,8 @@ declare class CopilotKitIntelligence {
|
|
|
454
463
|
ɵgetRunnerAuthToken(): string;
|
|
455
464
|
/** @internal Used by `attachIntelligenceEnterpriseLearning` to populate `Authorization`. */
|
|
456
465
|
ɵgetApiKey(): string;
|
|
466
|
+
/** @internal Used by the Intelligence runtime to assign Learning Containers. */
|
|
467
|
+
ɵgetLearningContainerId(): GetLearningContainerId | undefined;
|
|
457
468
|
/** @internal Used by `attachIntelligenceEnterpriseLearning` to gate MCP attachment. */
|
|
458
469
|
ɵisEnterpriseLearningEnabled(): boolean;
|
|
459
470
|
/**
|
|
@@ -468,6 +479,14 @@ declare class CopilotKitIntelligence {
|
|
|
468
479
|
* @throws {@link PlatformRequestError} for provider failures other than 404.
|
|
469
480
|
*/
|
|
470
481
|
getInspectorMetadata(): Promise<InspectorMetadataV1 | undefined>;
|
|
482
|
+
/**
|
|
483
|
+
* Resolve the Runtime entitlement projection for this project.
|
|
484
|
+
*
|
|
485
|
+
* Concurrent calls share one request. Active grants cache for 30 seconds;
|
|
486
|
+
* inactive results and failures cache for 5 seconds. Callers receive copies
|
|
487
|
+
* so they cannot mutate cached authority.
|
|
488
|
+
*/
|
|
489
|
+
getRuntimeEntitlements(): Promise<RuntimeEntitlementResponse>;
|
|
471
490
|
/**
|
|
472
491
|
* List all non-archived threads for a given user and agent.
|
|
473
492
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/client.ts"],"mappings":";;;;;UAiIU,kBAAA;EAAA,SACC,IAAA;EAAA,SACA,OAAA;AAAA;;;;;;;;;;;;;;;;;;;UA+FM,oBAAA;EACf,QAAA;EACA,MAAA;EACA,OAAA;AAAA;AAAA,UAGe,4BAAA;EAqFf;;;;;;AAUF;EAvFE,MAAA;;;;;;;;;;AAsGF;;;EAzFE,KAAA;EA2FA;EAzFA,MAAA;EA6FA;;;;;;;EArFA,sBAAA,GAAyB,sBAAA;EAiGU;;;;AAKrC;;;;;AASA;;;;;EAhGE,wBAAA;EAoGA;;;AASF;EAxGE,eAAA,IAAmB,MAAA,EAAQ,aAAA;;;;AA+G7B;EA1GE,eAAA,IAAmB,MAAA,EAAQ,aAAA;;;;;EAK3B,eAAA,IAAmB,MAAA,EAAQ,oBAAA;AAAA;;;;AAmH7B;;;;UAzGiB,aAAA;EA6Gf;EA3GA,EAAA;EA+GA;EA7GA,IAAA;EA6GqB;EA3GrB,SAAA;EA8Ge;EA5Gf,aAAA;;EAEA,SAAA;EA2GM;EAzGN,SAAA;EA4GyC;EA1GzC,QAAA;EA2GA;EAzGA,OAAA;EA4Ge;EA1Gf,WAAA;;EAEA,cAAA;AAAA;;UAIe,mBAAA;EAsGiB;EApGhC,OAAA,EAAS,aAAA;EA6GM;EA3Gf,QAAA;;EAEA,SAAA;EA0GA;EAxGA,UAAA;AAAA;;;;AAqHF;UA9GiB,aAAA;;EAEf,EAAA;EA4G0D;EA1G1D,IAAA;EA4GyC;EA1GzC,KAAA;EA0GiD;EAxGjD,OAAA;EAwHe;EAtHf,eAAA;;EAEA,aAAA;EAsHA;EApHA,KAAA;AAAA;;UAIe,oBAAA;EACf,QAAA,EA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metadata";
|
|
2
2
|
import { logger, parseInspectorMetadataV1 } from "@copilotkit/shared";
|
|
3
3
|
import { randomUUID as randomUUID$1 } from "crypto";
|
|
4
|
+
import { z } from "zod";
|
|
4
5
|
|
|
5
6
|
//#region src/v2/runtime/intelligence-platform/client.ts
|
|
7
|
+
const RUNTIME_ENTITLEMENTS_REQUEST_TIMEOUT_MS = 1500;
|
|
8
|
+
const RUNTIME_ENTITLEMENTS_SUCCESS_TTL_MS = 3e4;
|
|
9
|
+
const RUNTIME_ENTITLEMENTS_NEGATIVE_TTL_MS = 5e3;
|
|
10
|
+
/** Whether a response grants Runtime access and therefore cannot be served stale. */
|
|
11
|
+
function grantsRuntimeAccess(response) {
|
|
12
|
+
return response.status === "ready" && response.entitlement.active;
|
|
13
|
+
}
|
|
14
|
+
/** Whether an HTTP status can recover without changing Runtime configuration. */
|
|
15
|
+
function isRetryableRuntimeEntitlementStatus(status) {
|
|
16
|
+
return status === 408 || status === 425 || status === 429 || status >= 500;
|
|
17
|
+
}
|
|
18
|
+
const runtimeEntitlementSchema = z.object({
|
|
19
|
+
active: z.boolean(),
|
|
20
|
+
source: z.enum(["managedOrgSubscription", "selfHostedDeploymentLicense"]),
|
|
21
|
+
features: z.record(z.string(), z.boolean()),
|
|
22
|
+
limits: z.record(z.string(), z.number()),
|
|
23
|
+
planCode: z.string().optional(),
|
|
24
|
+
entitlementSource: z.string().optional()
|
|
25
|
+
}).strict();
|
|
26
|
+
const runtimeEntitlementResponseSchema = z.discriminatedUnion("status", [z.object({
|
|
27
|
+
status: z.literal("ready"),
|
|
28
|
+
entitlement: runtimeEntitlementSchema
|
|
29
|
+
}).strict(), z.object({
|
|
30
|
+
status: z.enum([
|
|
31
|
+
"degraded",
|
|
32
|
+
"misconfigured",
|
|
33
|
+
"unavailable"
|
|
34
|
+
]),
|
|
35
|
+
error: z.object({
|
|
36
|
+
code: z.string(),
|
|
37
|
+
message: z.string(),
|
|
38
|
+
retryable: z.boolean(),
|
|
39
|
+
requestId: z.string().optional(),
|
|
40
|
+
traceId: z.string().optional()
|
|
41
|
+
}).strict()
|
|
42
|
+
}).strict()]);
|
|
43
|
+
const legacyRuntimeEntitlementTransportSchema = runtimeEntitlementSchema.extend({ organizationId: z.string() });
|
|
44
|
+
/** Check the published App API response union without widening its type. */
|
|
45
|
+
function isPublishedRuntimeEntitlementResponse(value) {
|
|
46
|
+
return runtimeEntitlementResponseSchema.safeParse(value).success;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate the published App API response union, with flat-response support
|
|
50
|
+
* during mixed-version rollouts.
|
|
51
|
+
*/
|
|
52
|
+
function normalizeRuntimeEntitlementTransport(value) {
|
|
53
|
+
if (isPublishedRuntimeEntitlementResponse(value)) return value;
|
|
54
|
+
const legacyResponse = legacyRuntimeEntitlementTransportSchema.safeParse(value);
|
|
55
|
+
if (!legacyResponse.success) return;
|
|
56
|
+
const transport = legacyResponse.data;
|
|
57
|
+
return {
|
|
58
|
+
status: "ready",
|
|
59
|
+
entitlement: {
|
|
60
|
+
active: transport.active,
|
|
61
|
+
source: transport.source,
|
|
62
|
+
features: transport.features,
|
|
63
|
+
limits: transport.limits,
|
|
64
|
+
...transport.planCode !== void 0 ? { planCode: transport.planCode } : {},
|
|
65
|
+
...transport.entitlementSource !== void 0 ? { entitlementSource: transport.entitlementSource } : {}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
6
69
|
/**
|
|
7
70
|
* Header name carrying the per-call end-user identity that the CopilotKit
|
|
8
71
|
* Intelligence `/mcp` endpoint requires. Internal CopilotKit machinery —
|
|
@@ -53,12 +116,33 @@ const INSPECTOR_METADATA_REQUEST_TIMEOUT_MS = 5e3;
|
|
|
53
116
|
* ```
|
|
54
117
|
*/
|
|
55
118
|
var PlatformRequestError = class extends Error {
|
|
56
|
-
constructor(message, status) {
|
|
119
|
+
constructor(message, status, retryable) {
|
|
57
120
|
super(message);
|
|
58
121
|
this.status = status;
|
|
122
|
+
this.retryable = retryable;
|
|
59
123
|
this.name = "PlatformRequestError";
|
|
60
124
|
}
|
|
61
125
|
};
|
|
126
|
+
/** Copy a public Runtime entitlement so callers cannot mutate cached authority. */
|
|
127
|
+
function cloneRuntimeEntitlementResponse(response) {
|
|
128
|
+
if (response.status === "ready") return {
|
|
129
|
+
status: "ready",
|
|
130
|
+
entitlement: {
|
|
131
|
+
...response.entitlement,
|
|
132
|
+
features: { ...response.entitlement.features },
|
|
133
|
+
limits: { ...response.entitlement.limits }
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
status: response.status,
|
|
138
|
+
error: { ...response.error }
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** Copy a cached Error while preserving its concrete type and own fields. */
|
|
142
|
+
function cloneRuntimeEntitlementError(error) {
|
|
143
|
+
if (!(error instanceof Error)) return error;
|
|
144
|
+
return Object.create(Object.getPrototypeOf(error), Object.getOwnPropertyDescriptors(error));
|
|
145
|
+
}
|
|
62
146
|
/**
|
|
63
147
|
* Client for the CopilotKit Intelligence REST API.
|
|
64
148
|
*
|
|
@@ -69,7 +153,7 @@ var PlatformRequestError = class extends Error {
|
|
|
69
153
|
* import { CopilotKitIntelligence, CopilotRuntime } from "@copilotkit/runtime";
|
|
70
154
|
*
|
|
71
155
|
* const intelligence = new CopilotKitIntelligence({
|
|
72
|
-
* apiKey: process.env.
|
|
156
|
+
* apiKey: process.env.CPK_INTELLIGENCE_API_KEY!,
|
|
73
157
|
* });
|
|
74
158
|
*
|
|
75
159
|
* const runtime = new CopilotRuntime({
|
|
@@ -90,7 +174,7 @@ var PlatformRequestError = class extends Error {
|
|
|
90
174
|
* const intelligence = new CopilotKitIntelligence({
|
|
91
175
|
* apiUrl: "https://api.intelligence.example.com",
|
|
92
176
|
* wsUrl: "wss://realtime.intelligence.example.com",
|
|
93
|
-
* apiKey: process.env.
|
|
177
|
+
* apiKey: process.env.CPK_INTELLIGENCE_API_KEY!,
|
|
94
178
|
* });
|
|
95
179
|
* ```
|
|
96
180
|
*/
|
|
@@ -101,10 +185,15 @@ var CopilotKitIntelligence = class {
|
|
|
101
185
|
#channelsWsUrl;
|
|
102
186
|
#apiKey;
|
|
103
187
|
#enterpriseLearningEnabled;
|
|
188
|
+
#getLearningContainerId;
|
|
189
|
+
#runtimeEntitlementsCache;
|
|
190
|
+
#runtimeEntitlementsFailure;
|
|
191
|
+
#runtimeEntitlementsInFlight;
|
|
104
192
|
#threadCreatedListeners = /* @__PURE__ */ new Set();
|
|
105
193
|
#threadUpdatedListeners = /* @__PURE__ */ new Set();
|
|
106
194
|
#threadDeletedListeners = /* @__PURE__ */ new Set();
|
|
107
195
|
constructor(config) {
|
|
196
|
+
if (config.getLearningContainerId !== void 0 && typeof config.getLearningContainerId !== "function") throw new Error("CopilotKitIntelligence `getLearningContainerId` must be a callback");
|
|
108
197
|
const configuredApiUrl = configuredUrl(config.apiUrl);
|
|
109
198
|
const configuredWsUrl = configuredUrl(config.wsUrl);
|
|
110
199
|
warnOnPartialHostOverride(configuredApiUrl, configuredWsUrl);
|
|
@@ -115,6 +204,7 @@ var CopilotKitIntelligence = class {
|
|
|
115
204
|
this.#channelsWsUrl = deriveChannelsWsUrl(intelligenceWsUrl);
|
|
116
205
|
this.#apiKey = config.apiKey;
|
|
117
206
|
this.#enterpriseLearningEnabled = config.enableEnterpriseLearning ?? false;
|
|
207
|
+
this.#getLearningContainerId = config.getLearningContainerId;
|
|
118
208
|
if (config.onThreadCreated) this.onThreadCreated(config.onThreadCreated);
|
|
119
209
|
if (config.onThreadUpdated) this.onThreadUpdated(config.onThreadUpdated);
|
|
120
210
|
if (config.onThreadDeleted) this.onThreadDeleted(config.onThreadDeleted);
|
|
@@ -193,6 +283,10 @@ var CopilotKitIntelligence = class {
|
|
|
193
283
|
ɵgetApiKey() {
|
|
194
284
|
return this.#apiKey;
|
|
195
285
|
}
|
|
286
|
+
/** @internal Used by the Intelligence runtime to assign Learning Containers. */
|
|
287
|
+
ɵgetLearningContainerId() {
|
|
288
|
+
return this.#getLearningContainerId;
|
|
289
|
+
}
|
|
196
290
|
/** @internal Used by `attachIntelligenceEnterpriseLearning` to gate MCP attachment. */
|
|
197
291
|
ɵisEnterpriseLearningEnabled() {
|
|
198
292
|
return this.#enterpriseLearningEnabled;
|
|
@@ -245,6 +339,79 @@ var CopilotKitIntelligence = class {
|
|
|
245
339
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
246
340
|
}
|
|
247
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Resolve the Runtime entitlement projection for this project.
|
|
344
|
+
*
|
|
345
|
+
* Concurrent calls share one request. Active grants cache for 30 seconds;
|
|
346
|
+
* inactive results and failures cache for 5 seconds. Callers receive copies
|
|
347
|
+
* so they cannot mutate cached authority.
|
|
348
|
+
*/
|
|
349
|
+
async getRuntimeEntitlements() {
|
|
350
|
+
const now = Date.now();
|
|
351
|
+
if (this.#runtimeEntitlementsCache && now < this.#runtimeEntitlementsCache.expiresAt) return cloneRuntimeEntitlementResponse(this.#runtimeEntitlementsCache.response);
|
|
352
|
+
if (this.#runtimeEntitlementsFailure && now < this.#runtimeEntitlementsFailure.expiresAt) throw cloneRuntimeEntitlementError(this.#runtimeEntitlementsFailure.error);
|
|
353
|
+
const request = this.#runtimeEntitlementsInFlight ?? this.#fetchRuntimeEntitlements().then((response) => {
|
|
354
|
+
this.#runtimeEntitlementsFailure = void 0;
|
|
355
|
+
this.#runtimeEntitlementsCache = {
|
|
356
|
+
response,
|
|
357
|
+
expiresAt: Date.now() + (grantsRuntimeAccess(response) ? RUNTIME_ENTITLEMENTS_SUCCESS_TTL_MS : RUNTIME_ENTITLEMENTS_NEGATIVE_TTL_MS)
|
|
358
|
+
};
|
|
359
|
+
return response;
|
|
360
|
+
}).catch((error) => {
|
|
361
|
+
this.#runtimeEntitlementsFailure = {
|
|
362
|
+
error,
|
|
363
|
+
expiresAt: Date.now() + RUNTIME_ENTITLEMENTS_NEGATIVE_TTL_MS
|
|
364
|
+
};
|
|
365
|
+
throw error;
|
|
366
|
+
});
|
|
367
|
+
this.#runtimeEntitlementsInFlight = request;
|
|
368
|
+
try {
|
|
369
|
+
return cloneRuntimeEntitlementResponse(await request);
|
|
370
|
+
} catch (error) {
|
|
371
|
+
throw cloneRuntimeEntitlementError(error);
|
|
372
|
+
} finally {
|
|
373
|
+
if (this.#runtimeEntitlementsInFlight === request) this.#runtimeEntitlementsInFlight = void 0;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/** Perform one bounded Runtime entitlement request without caching. */
|
|
377
|
+
async #fetchRuntimeEntitlements() {
|
|
378
|
+
const path = "/api/entitlements/runtime";
|
|
379
|
+
const controller = new AbortController();
|
|
380
|
+
const timeout = setTimeout(() => controller.abort(), RUNTIME_ENTITLEMENTS_REQUEST_TIMEOUT_MS);
|
|
381
|
+
try {
|
|
382
|
+
const response = await fetch(`${this.#apiUrl}${path}`, {
|
|
383
|
+
method: "GET",
|
|
384
|
+
headers: {
|
|
385
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
386
|
+
"Content-Type": "application/json"
|
|
387
|
+
},
|
|
388
|
+
signal: controller.signal
|
|
389
|
+
});
|
|
390
|
+
if (!response.ok) {
|
|
391
|
+
await response.body?.cancel();
|
|
392
|
+
logger.error({
|
|
393
|
+
status: response.status,
|
|
394
|
+
path
|
|
395
|
+
}, "Runtime entitlement request failed");
|
|
396
|
+
throw new PlatformRequestError(`Runtime entitlement request failed with status ${response.status}`, response.status, isRetryableRuntimeEntitlementStatus(response.status));
|
|
397
|
+
}
|
|
398
|
+
let payload;
|
|
399
|
+
try {
|
|
400
|
+
payload = await response.json();
|
|
401
|
+
} catch {
|
|
402
|
+
throw new PlatformRequestError("Runtime entitlement response was malformed", 502, false);
|
|
403
|
+
}
|
|
404
|
+
const normalized = normalizeRuntimeEntitlementTransport(payload);
|
|
405
|
+
if (!normalized) throw new PlatformRequestError("Runtime entitlement response was malformed", 502, false);
|
|
406
|
+
return normalized;
|
|
407
|
+
} catch (error) {
|
|
408
|
+
if (error instanceof PlatformRequestError) throw error;
|
|
409
|
+
if (controller.signal.aborted || error instanceof DOMException && error.name === "AbortError") throw new PlatformRequestError("Runtime entitlement request timed out", 504, true);
|
|
410
|
+
throw new PlatformRequestError("Runtime entitlement request failed", 502, true);
|
|
411
|
+
} finally {
|
|
412
|
+
clearTimeout(timeout);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
248
415
|
async #request(method, path, body, extraHeaders) {
|
|
249
416
|
const url = `${this.#apiUrl}${path}`;
|
|
250
417
|
const headers = {
|