@copilotkit/shared 1.72.0 → 1.73.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/LICENSE +21 -0
- package/dist/finalize-events.cjs +92 -71
- package/dist/finalize-events.cjs.map +1 -1
- package/dist/finalize-events.d.cts +20 -1
- package/dist/finalize-events.d.cts.map +1 -1
- package/dist/finalize-events.d.mts +20 -1
- package/dist/finalize-events.d.mts.map +1 -1
- package/dist/finalize-events.mjs +92 -72
- package/dist/finalize-events.mjs.map +1 -1
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +218 -72
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/telemetry/events.d.cts +33 -0
- package/dist/telemetry/events.d.cts.map +1 -1
- package/dist/telemetry/events.d.mts +33 -0
- package/dist/telemetry/events.d.mts.map +1 -1
- package/dist/telemetry/index.cjs +3 -0
- package/dist/telemetry/index.d.cts +2 -2
- package/dist/telemetry/index.d.mts +2 -2
- package/dist/telemetry/index.mjs +2 -2
- package/dist/telemetry/model-host.cjs +104 -0
- package/dist/telemetry/model-host.cjs.map +1 -0
- package/dist/telemetry/model-host.d.cts +26 -0
- package/dist/telemetry/model-host.d.cts.map +1 -0
- package/dist/telemetry/model-host.d.mts +26 -0
- package/dist/telemetry/model-host.d.mts.map +1 -0
- package/dist/telemetry/model-host.mjs +102 -0
- package/dist/telemetry/model-host.mjs.map +1 -0
- package/dist/telemetry/sampling.cjs +22 -0
- package/dist/telemetry/sampling.cjs.map +1 -1
- package/dist/telemetry/sampling.d.cts +22 -2
- package/dist/telemetry/sampling.d.cts.map +1 -1
- package/dist/telemetry/sampling.d.mts +22 -2
- package/dist/telemetry/sampling.d.mts.map +1 -1
- package/dist/telemetry/sampling.mjs +20 -1
- package/dist/telemetry/sampling.mjs.map +1 -1
- package/dist/telemetry/telemetry-client.cjs +18 -11
- package/dist/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/telemetry/telemetry-client.d.cts +3 -3
- package/dist/telemetry/telemetry-client.d.cts.map +1 -1
- package/dist/telemetry/telemetry-client.d.mts +3 -3
- package/dist/telemetry/telemetry-client.d.mts.map +1 -1
- package/dist/telemetry/telemetry-client.mjs +19 -12
- package/dist/telemetry/telemetry-client.mjs.map +1 -1
- package/package.json +1 -1
- package/src/finalize-events.test.ts +146 -0
- package/src/finalize-events.ts +124 -124
- package/src/index.ts +9 -1
- package/src/telemetry/events.ts +33 -0
- package/src/telemetry/model-host.test.ts +145 -0
- package/src/telemetry/model-host.ts +155 -0
- package/src/telemetry/sampling.ts +39 -6
- package/src/telemetry/telemetry-blank-license-identity.test.ts +11 -4
- package/src/telemetry/telemetry-client.test.ts +107 -39
- package/src/telemetry/telemetry-client.ts +48 -27
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\n// Telemetry is split deliberately. `TelemetryClient` imports\n// `@segment/analytics-node`, which imports `node-fetch`, which imports the\n// Node built-ins `stream`, `http`, `https` and `zlib`. Browser bundlers\n// resolve the whole module graph before they tree-shake, so re-exporting\n// that module here made every browser build of a dependent package print\n// \"Module ... has been externalized for browser compatibility\" warnings,\n// even when the consumer never touched telemetry (#4151). Only the\n// browser-safe telemetry surface is re-exported from this entry. Server\n// code that needs the client imports it from `@copilotkit/shared/telemetry`.\n// This mirrors the license-verifier note below.\nexport { isTelemetryDisabled } from \"./telemetry/telemetry-disabled\";\nexport * from \"./telemetry/sampling\";\nexport {\n firstNonBlankTelemetryId,\n lambdaClient,\n parseTelemetryIdFromLicense,\n parseAndWarnTelemetryId,\n} from \"./telemetry/lambda-client\";\nexport type { LambdaSendOptions } from \"./telemetry/lambda-client\";\n// Types only: erased at build time, so they add no runtime edge to\n// `telemetry-client.ts` and therefore none to @segment/analytics-node.\nexport type {\n TelemetryCapture,\n TelemetryIdentity,\n} from \"./telemetry/telemetry-client\";\nexport * from \"./debug\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport {
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\n// Telemetry is split deliberately. `TelemetryClient` imports\n// `@segment/analytics-node`, which imports `node-fetch`, which imports the\n// Node built-ins `stream`, `http`, `https` and `zlib`. Browser bundlers\n// resolve the whole module graph before they tree-shake, so re-exporting\n// that module here made every browser build of a dependent package print\n// \"Module ... has been externalized for browser compatibility\" warnings,\n// even when the consumer never touched telemetry (#4151). Only the\n// browser-safe telemetry surface is re-exported from this entry. Server\n// code that needs the client imports it from `@copilotkit/shared/telemetry`.\n// This mirrors the license-verifier note below.\nexport { isTelemetryDisabled } from \"./telemetry/telemetry-disabled\";\nexport * from \"./telemetry/sampling\";\n// Pure string classification with no imports, so it carries no runtime edge\n// into browser builds — same reasoning as `sampling` above.\nexport * from \"./telemetry/model-host\";\nexport {\n firstNonBlankTelemetryId,\n lambdaClient,\n parseTelemetryIdFromLicense,\n parseAndWarnTelemetryId,\n} from \"./telemetry/lambda-client\";\nexport type { LambdaSendOptions } from \"./telemetry/lambda-client\";\n// Types only: erased at build time, so they add no runtime edge to\n// `telemetry-client.ts` and therefore none to @segment/analytics-node.\nexport type {\n TelemetryCapture,\n TelemetryIdentity,\n} from \"./telemetry/telemetry-client\";\nexport * from \"./debug\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport {\n createRunEventFinalizer,\n finalizeRunEvents,\n type FinalizeRunOptions,\n type RunEventFinalizer,\n} from \"./finalize-events\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n} from \"@copilotkit/license-verifier\";\n\nimport type { LicensePayload } from \"@copilotkit/license-verifier\";\nimport type {\n RuntimeEntitlementResponse,\n RuntimeLicenseStatus,\n} from \"./utils/types\";\n\n// LicenseContextValue was dropped from license-verifier's public API in\n// 0.3.0, so it is defined here. The context shape is owned by this package\n// anyway via createLicenseContextValue below.\n\n/**\n * License context value exposed to child components.\n * Frontend providers create their own context using this shape.\n */\nexport interface LicenseContextValue {\n /** Effective license status after structured entitlement precedence. Null until known. */\n status: RuntimeLicenseStatus | null;\n /** The license payload if available. Always null on the client; the payload stays server-side. */\n license: LicensePayload | null;\n /** Whether a feature is licensed. Ready entitlements override legacy status behavior. */\n checkFeature: (feature: string) => boolean;\n /** Get a numeric feature limit. Zero means unlimited; null means not applicable. */\n getLimit: (feature: string) => number | null;\n}\n\n/** Read a record value without traversing its prototype chain. */\nfunction getOwnRecordValue<Value>(\n record: Readonly<Record<string, Value>>,\n key: string,\n): Value | undefined {\n return Object.prototype.hasOwnProperty.call(record, key)\n ? record[key]\n : undefined;\n}\n\n/** Legacy UI surfaces that remain available for every active entitlement. */\nfunction isLegacyUiFeature(feature: string): boolean {\n return feature === \"chat\" || feature === \"popup\" || feature === \"sidebar\";\n}\n\n/**\n * Client-safe license context factory, driven by the license authority the\n * runtime reports via /info.\n *\n * A ready managed entitlement is authoritative in both directions. A ready\n * active self-hosted entitlement is also authoritative, while an inactive\n * self-hosted response preserves the legacy signed-license fallback. Active\n * entitlements supply feature grants and limits; authoritative inactive\n * entitlements deny every feature and limit. Older runtimes that report only a\n * status retain the legacy behavior: features are enabled unless the status is\n * \"expired\" or \"invalid\", and no limits are reported. This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on Node's\n * `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(\n status: RuntimeLicenseStatus | null | undefined,\n runtimeEntitlements?: RuntimeEntitlementResponse,\n): LicenseContextValue {\n const readyEntitlement =\n runtimeEntitlements?.status === \"ready\"\n ? runtimeEntitlements.entitlement\n : null;\n const hasUsableSelfHostedLegacyFallback =\n readyEntitlement &&\n !readyEntitlement.active &&\n readyEntitlement.source === \"selfHostedDeploymentLicense\" &&\n (status === \"valid\" || status === \"expiring\");\n const featureAuthority =\n readyEntitlement && !hasUsableSelfHostedLegacyFallback\n ? readyEntitlement\n : null;\n const activeEntitlement = featureAuthority?.active ? featureAuthority : null;\n const resolvedStatus = activeEntitlement\n ? \"valid\"\n : readyEntitlement?.source === \"managedOrgSubscription\" ||\n readyEntitlement?.source === \"awsMarketplaceDeploymentLicense\"\n ? \"none\"\n : featureAuthority\n ? (status ?? \"none\")\n : (status ?? null);\n const featuresEnabled =\n resolvedStatus !== \"expired\" && resolvedStatus !== \"invalid\";\n\n return {\n status: resolvedStatus,\n license: null,\n checkFeature: (feature) =>\n featureAuthority\n ? activeEntitlement\n ? feature === \"threads\" &&\n Object.prototype.hasOwnProperty.call(\n activeEntitlement.limits,\n \"threads.max_count\",\n )\n ? true\n : (getOwnRecordValue(activeEntitlement.features, feature) ??\n isLegacyUiFeature(feature))\n : false\n : featuresEnabled,\n getLimit: (feature) =>\n activeEntitlement\n ? (getOwnRecordValue(activeEntitlement.limits, feature) ?? null)\n : null,\n };\n}\n\nexport {\n A2UI_DEFAULT_GENERATION_GUIDELINES,\n A2UI_DEFAULT_DESIGN_GUIDELINES,\n} from \"./a2ui-prompts\";\n\nexport type { DebugEventEnvelope } from \"./debug-event-envelope\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAa;;AA0Cb,SAAS,kBACP,QACA,KACmB;AACnB,QAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI,GACpD,OAAO,OACP;;;AAIN,SAAS,kBAAkB,SAA0B;AACnD,QAAO,YAAY,UAAU,YAAY,WAAW,YAAY;;;;;;;;;;;;;;;;AAiBlE,SAAgB,0BACd,QACA,qBACqB;CACrB,MAAM,mBACJ,qBAAqB,WAAW,UAC5B,oBAAoB,cACpB;CACN,MAAM,oCACJ,oBACA,CAAC,iBAAiB,UAClB,iBAAiB,WAAW,kCAC3B,WAAW,WAAW,WAAW;CACpC,MAAM,mBACJ,oBAAoB,CAAC,oCACjB,mBACA;CACN,MAAM,oBAAoB,kBAAkB,SAAS,mBAAmB;CACxE,MAAM,iBAAiB,oBACnB,UACA,kBAAkB,WAAW,4BAC3B,kBAAkB,WAAW,oCAC7B,SACA,mBACG,UAAU,SACV,UAAU;CACnB,MAAM,kBACJ,mBAAmB,aAAa,mBAAmB;AAErD,QAAO;EACL,QAAQ;EACR,SAAS;EACT,eAAe,YACb,mBACI,oBACE,YAAY,aACZ,OAAO,UAAU,eAAe,KAC9B,kBAAkB,QAClB,oBACD,GACC,OACC,kBAAkB,kBAAkB,UAAU,QAAQ,IACvD,kBAAkB,QAAQ,GAC5B,QACF;EACN,WAAW,YACT,oBACK,kBAAkB,kBAAkB,QAAQ,QAAQ,IAAI,OACzD;EACP"}
|
package/dist/index.d.cts
CHANGED
|
@@ -18,7 +18,8 @@ import { readBody } from "./utils/requests.cjs";
|
|
|
18
18
|
import { isMacOS, parseJson, partialJSONParse, phoenixExponentialBackoff, safeParseToolArgs, tryMap } from "./utils/index.cjs";
|
|
19
19
|
import { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID } from "./constants/index.cjs";
|
|
20
20
|
import { isTelemetryDisabled } from "./telemetry/telemetry-disabled.cjs";
|
|
21
|
-
import { SamplingMeta, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TelemetryEmitter, TelemetryTransport, computeSamplingMeta } from "./telemetry/sampling.cjs";
|
|
21
|
+
import { SamplingMeta, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, TelemetryEmitter, TelemetrySurface, TelemetryTransport, UNSAMPLED_RATE, computeSamplingMeta } from "./telemetry/sampling.cjs";
|
|
22
|
+
import { MODEL_HOST_CLASSES, ModelHostClass, classifyModelHost } from "./telemetry/model-host.cjs";
|
|
22
23
|
import { LambdaSendOptions, firstNonBlankTelemetryId, lambdaClient, parseAndWarnTelemetryId, parseTelemetryIdFromLicense } from "./telemetry/lambda-client.cjs";
|
|
23
24
|
import { TelemetryCapture, TelemetryIdentity } from "./telemetry/telemetry-client.cjs";
|
|
24
25
|
import { DebugConfig, ResolvedDebugConfig, resolveDebugConfig } from "./debug.cjs";
|
|
@@ -26,7 +27,7 @@ import { InferSchemaOutput, SchemaToJsonSchemaOptions, StandardJSONSchemaV1, Sta
|
|
|
26
27
|
import { Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig } from "./attachments/types.cjs";
|
|
27
28
|
import { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 } from "./attachments/utils.cjs";
|
|
28
29
|
import { logger } from "./logger.cjs";
|
|
29
|
-
import { finalizeRunEvents } from "./finalize-events.cjs";
|
|
30
|
+
import { FinalizeRunOptions, RunEventFinalizer, createRunEventFinalizer, finalizeRunEvents } from "./finalize-events.cjs";
|
|
30
31
|
import { TranscriptionErrorCode, TranscriptionErrorResponse, TranscriptionErrors } from "./transcription-errors.cjs";
|
|
31
32
|
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES } from "./a2ui-prompts.cjs";
|
|
32
33
|
import { DebugEventEnvelope } from "./debug-event-envelope.cjs";
|
|
@@ -64,5 +65,5 @@ interface LicenseContextValue {
|
|
|
64
65
|
*/
|
|
65
66
|
declare function createLicenseContextValue(status: RuntimeLicenseStatus | null | undefined, runtimeEntitlements?: RuntimeEntitlementResponse): LicenseContextValue;
|
|
66
67
|
//#endregion
|
|
67
|
-
export { A2UIRuntimeInfo, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, type DebugEventEnvelope, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorMetadataV1, InspectorVisibilityOptions, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LambdaSendOptions, type LicenseChecker, LicenseContextValue, type LicenseFeatures, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, Rule, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SamplingMeta, SchemaToJsonSchemaOptions, Severity, SingleRouteRuntimeInfo, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, type TelemetryCapture, TelemetryEmitter, type TelemetryIdentity, TelemetryTransport, TextInputPart, ThreadEndpointRuntimeInfo, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, computeSamplingMeta, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, lambdaClient, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, shouldEnableInspector, styledConsole, tryMap };
|
|
68
|
+
export { A2UIRuntimeInfo, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, type DebugEventEnvelope, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, type FinalizeRunOptions, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorMetadataV1, InspectorVisibilityOptions, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LambdaSendOptions, type LicenseChecker, LicenseContextValue, type LicenseFeatures, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MODEL_HOST_CLASSES, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, ModelHostClass, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, Rule, type RunEventFinalizer, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SamplingMeta, SchemaToJsonSchemaOptions, Severity, SingleRouteRuntimeInfo, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, type TelemetryCapture, TelemetryEmitter, type TelemetryIdentity, TelemetrySurface, TelemetryTransport, TextInputPart, ThreadEndpointRuntimeInfo, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UNSAMPLED_RATE, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, classifyModelHost, computeSamplingMeta, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, createRunEventFinalizer, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, lambdaClient, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, shouldEnableInspector, styledConsole, tryMap };
|
|
68
69
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkDa,kBAAA;;;;;UA8BI,mBAAA;;EAEf,MAAA,EAAQ,oBAAA;;EAER,OAAA,EAAS,gBAAA;;EAET,YAAA,GAAe,OAAA;;EAEf,QAAA,GAAW,OAAA;AAAA;;;;AAtCb;;;;;AA8BA;;;;;;iBAwCgB,yBAAA,CACd,MAAA,EAAQ,oBAAA,qBACR,mBAAA,GAAsB,0BAAA,GACrB,mBAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -18,7 +18,8 @@ import { readBody } from "./utils/requests.mjs";
|
|
|
18
18
|
import { isMacOS, parseJson, partialJSONParse, phoenixExponentialBackoff, safeParseToolArgs, tryMap } from "./utils/index.mjs";
|
|
19
19
|
import { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID } from "./constants/index.mjs";
|
|
20
20
|
import { isTelemetryDisabled } from "./telemetry/telemetry-disabled.mjs";
|
|
21
|
-
import { SamplingMeta, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TelemetryEmitter, TelemetryTransport, computeSamplingMeta } from "./telemetry/sampling.mjs";
|
|
21
|
+
import { SamplingMeta, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, TelemetryEmitter, TelemetrySurface, TelemetryTransport, UNSAMPLED_RATE, computeSamplingMeta } from "./telemetry/sampling.mjs";
|
|
22
|
+
import { MODEL_HOST_CLASSES, ModelHostClass, classifyModelHost } from "./telemetry/model-host.mjs";
|
|
22
23
|
import { LambdaSendOptions, firstNonBlankTelemetryId, lambdaClient, parseAndWarnTelemetryId, parseTelemetryIdFromLicense } from "./telemetry/lambda-client.mjs";
|
|
23
24
|
import { TelemetryCapture, TelemetryIdentity } from "./telemetry/telemetry-client.mjs";
|
|
24
25
|
import { DebugConfig, ResolvedDebugConfig, resolveDebugConfig } from "./debug.mjs";
|
|
@@ -26,7 +27,7 @@ import { InferSchemaOutput, SchemaToJsonSchemaOptions, StandardJSONSchemaV1, Sta
|
|
|
26
27
|
import { Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig } from "./attachments/types.mjs";
|
|
27
28
|
import { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 } from "./attachments/utils.mjs";
|
|
28
29
|
import { logger } from "./logger.mjs";
|
|
29
|
-
import { finalizeRunEvents } from "./finalize-events.mjs";
|
|
30
|
+
import { FinalizeRunOptions, RunEventFinalizer, createRunEventFinalizer, finalizeRunEvents } from "./finalize-events.mjs";
|
|
30
31
|
import { TranscriptionErrorCode, TranscriptionErrorResponse, TranscriptionErrors } from "./transcription-errors.mjs";
|
|
31
32
|
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES } from "./a2ui-prompts.mjs";
|
|
32
33
|
import { DebugEventEnvelope } from "./debug-event-envelope.mjs";
|
|
@@ -64,5 +65,5 @@ interface LicenseContextValue {
|
|
|
64
65
|
*/
|
|
65
66
|
declare function createLicenseContextValue(status: RuntimeLicenseStatus | null | undefined, runtimeEntitlements?: RuntimeEntitlementResponse): LicenseContextValue;
|
|
66
67
|
//#endregion
|
|
67
|
-
export { A2UIRuntimeInfo, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, type DebugEventEnvelope, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorMetadataV1, InspectorVisibilityOptions, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LambdaSendOptions, type LicenseChecker, LicenseContextValue, type LicenseFeatures, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, Rule, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SamplingMeta, SchemaToJsonSchemaOptions, Severity, SingleRouteRuntimeInfo, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, type TelemetryCapture, TelemetryEmitter, type TelemetryIdentity, TelemetryTransport, TextInputPart, ThreadEndpointRuntimeInfo, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, computeSamplingMeta, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, lambdaClient, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, shouldEnableInspector, styledConsole, tryMap };
|
|
68
|
+
export { A2UIRuntimeInfo, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, type DebugEventEnvelope, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, type FinalizeRunOptions, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorMetadataV1, InspectorVisibilityOptions, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LambdaSendOptions, type LicenseChecker, LicenseContextValue, type LicenseFeatures, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MODEL_HOST_CLASSES, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, ModelHostClass, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, Rule, type RunEventFinalizer, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SamplingMeta, SchemaToJsonSchemaOptions, Severity, SingleRouteRuntimeInfo, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, type TelemetryCapture, TelemetryEmitter, type TelemetryIdentity, TelemetrySurface, TelemetryTransport, TextInputPart, ThreadEndpointRuntimeInfo, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UNSAMPLED_RATE, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, classifyModelHost, computeSamplingMeta, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, createRunEventFinalizer, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, lambdaClient, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, shouldEnableInspector, styledConsole, tryMap };
|
|
68
69
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkDa,kBAAA;;;;;UA8BI,mBAAA;;EAEf,MAAA,EAAQ,oBAAA;;EAER,OAAA,EAAS,gBAAA;;EAET,YAAA,GAAe,OAAA;;EAEf,QAAA,GAAW,OAAA;AAAA;;;;AAtCb;;;;;AA8BA;;;;;;iBAwCgB,yBAAA,CACd,MAAA,EAAQ,oBAAA,qBACR,mBAAA,GAAsB,0BAAA,GACrB,mBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -12,13 +12,14 @@ import { readBody } from "./utils/requests.mjs";
|
|
|
12
12
|
import { isMacOS, parseJson, partialJSONParse, phoenixExponentialBackoff, safeParseToolArgs, tryMap } from "./utils/index.mjs";
|
|
13
13
|
import { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID } from "./constants/index.mjs";
|
|
14
14
|
import { isTelemetryDisabled } from "./telemetry/telemetry-disabled.mjs";
|
|
15
|
-
import { TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, computeSamplingMeta } from "./telemetry/sampling.mjs";
|
|
15
|
+
import { TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, UNSAMPLED_RATE, computeSamplingMeta } from "./telemetry/sampling.mjs";
|
|
16
|
+
import { MODEL_HOST_CLASSES, classifyModelHost } from "./telemetry/model-host.mjs";
|
|
16
17
|
import { firstNonBlankTelemetryId, lambdaClient, parseAndWarnTelemetryId, parseTelemetryIdFromLicense } from "./telemetry/lambda-client.mjs";
|
|
17
18
|
import { resolveDebugConfig } from "./debug.mjs";
|
|
18
19
|
import { schemaToJsonSchema } from "./standard-schema.mjs";
|
|
19
20
|
import { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 } from "./attachments/utils.mjs";
|
|
20
21
|
import { logger } from "./logger.mjs";
|
|
21
|
-
import { finalizeRunEvents } from "./finalize-events.mjs";
|
|
22
|
+
import { createRunEventFinalizer, finalizeRunEvents } from "./finalize-events.mjs";
|
|
22
23
|
import { TranscriptionErrorCode, TranscriptionErrors } from "./transcription-errors.mjs";
|
|
23
24
|
import { version } from "./package.mjs";
|
|
24
25
|
import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES } from "./a2ui-prompts.mjs";
|
|
@@ -63,5 +64,5 @@ function createLicenseContextValue(status, runtimeEntitlements) {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
//#endregion
|
|
66
|
-
export { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, BANNER_ERROR_NAMES, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, DEFAULT_AGENT_ID, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ResolvedCopilotKitError, Severity, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TranscriptionErrorCode, TranscriptionErrors, UpgradeRequiredError, actionParametersToJsonSchema, computeSamplingMeta, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, lambdaClient, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, shouldEnableInspector, styledConsole, tryMap };
|
|
67
|
+
export { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, BANNER_ERROR_NAMES, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, DEFAULT_AGENT_ID, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MODEL_HOST_CLASSES, MissingPublicApiKeyError, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ResolvedCopilotKitError, Severity, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, TranscriptionErrorCode, TranscriptionErrors, UNSAMPLED_RATE, UpgradeRequiredError, actionParametersToJsonSchema, classifyModelHost, computeSamplingMeta, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, createRunEventFinalizer, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, lambdaClient, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, shouldEnableInspector, styledConsole, tryMap };
|
|
67
68
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["packageJson.version"],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\n// Telemetry is split deliberately. `TelemetryClient` imports\n// `@segment/analytics-node`, which imports `node-fetch`, which imports the\n// Node built-ins `stream`, `http`, `https` and `zlib`. Browser bundlers\n// resolve the whole module graph before they tree-shake, so re-exporting\n// that module here made every browser build of a dependent package print\n// \"Module ... has been externalized for browser compatibility\" warnings,\n// even when the consumer never touched telemetry (#4151). Only the\n// browser-safe telemetry surface is re-exported from this entry. Server\n// code that needs the client imports it from `@copilotkit/shared/telemetry`.\n// This mirrors the license-verifier note below.\nexport { isTelemetryDisabled } from \"./telemetry/telemetry-disabled\";\nexport * from \"./telemetry/sampling\";\nexport {\n firstNonBlankTelemetryId,\n lambdaClient,\n parseTelemetryIdFromLicense,\n parseAndWarnTelemetryId,\n} from \"./telemetry/lambda-client\";\nexport type { LambdaSendOptions } from \"./telemetry/lambda-client\";\n// Types only: erased at build time, so they add no runtime edge to\n// `telemetry-client.ts` and therefore none to @segment/analytics-node.\nexport type {\n TelemetryCapture,\n TelemetryIdentity,\n} from \"./telemetry/telemetry-client\";\nexport * from \"./debug\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["packageJson.version"],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\n// Telemetry is split deliberately. `TelemetryClient` imports\n// `@segment/analytics-node`, which imports `node-fetch`, which imports the\n// Node built-ins `stream`, `http`, `https` and `zlib`. Browser bundlers\n// resolve the whole module graph before they tree-shake, so re-exporting\n// that module here made every browser build of a dependent package print\n// \"Module ... has been externalized for browser compatibility\" warnings,\n// even when the consumer never touched telemetry (#4151). Only the\n// browser-safe telemetry surface is re-exported from this entry. Server\n// code that needs the client imports it from `@copilotkit/shared/telemetry`.\n// This mirrors the license-verifier note below.\nexport { isTelemetryDisabled } from \"./telemetry/telemetry-disabled\";\nexport * from \"./telemetry/sampling\";\n// Pure string classification with no imports, so it carries no runtime edge\n// into browser builds — same reasoning as `sampling` above.\nexport * from \"./telemetry/model-host\";\nexport {\n firstNonBlankTelemetryId,\n lambdaClient,\n parseTelemetryIdFromLicense,\n parseAndWarnTelemetryId,\n} from \"./telemetry/lambda-client\";\nexport type { LambdaSendOptions } from \"./telemetry/lambda-client\";\n// Types only: erased at build time, so they add no runtime edge to\n// `telemetry-client.ts` and therefore none to @segment/analytics-node.\nexport type {\n TelemetryCapture,\n TelemetryIdentity,\n} from \"./telemetry/telemetry-client\";\nexport * from \"./debug\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport {\n createRunEventFinalizer,\n finalizeRunEvents,\n type FinalizeRunOptions,\n type RunEventFinalizer,\n} from \"./finalize-events\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n} from \"@copilotkit/license-verifier\";\n\nimport type { LicensePayload } from \"@copilotkit/license-verifier\";\nimport type {\n RuntimeEntitlementResponse,\n RuntimeLicenseStatus,\n} from \"./utils/types\";\n\n// LicenseContextValue was dropped from license-verifier's public API in\n// 0.3.0, so it is defined here. The context shape is owned by this package\n// anyway via createLicenseContextValue below.\n\n/**\n * License context value exposed to child components.\n * Frontend providers create their own context using this shape.\n */\nexport interface LicenseContextValue {\n /** Effective license status after structured entitlement precedence. Null until known. */\n status: RuntimeLicenseStatus | null;\n /** The license payload if available. Always null on the client; the payload stays server-side. */\n license: LicensePayload | null;\n /** Whether a feature is licensed. Ready entitlements override legacy status behavior. */\n checkFeature: (feature: string) => boolean;\n /** Get a numeric feature limit. Zero means unlimited; null means not applicable. */\n getLimit: (feature: string) => number | null;\n}\n\n/** Read a record value without traversing its prototype chain. */\nfunction getOwnRecordValue<Value>(\n record: Readonly<Record<string, Value>>,\n key: string,\n): Value | undefined {\n return Object.prototype.hasOwnProperty.call(record, key)\n ? record[key]\n : undefined;\n}\n\n/** Legacy UI surfaces that remain available for every active entitlement. */\nfunction isLegacyUiFeature(feature: string): boolean {\n return feature === \"chat\" || feature === \"popup\" || feature === \"sidebar\";\n}\n\n/**\n * Client-safe license context factory, driven by the license authority the\n * runtime reports via /info.\n *\n * A ready managed entitlement is authoritative in both directions. A ready\n * active self-hosted entitlement is also authoritative, while an inactive\n * self-hosted response preserves the legacy signed-license fallback. Active\n * entitlements supply feature grants and limits; authoritative inactive\n * entitlements deny every feature and limit. Older runtimes that report only a\n * status retain the legacy behavior: features are enabled unless the status is\n * \"expired\" or \"invalid\", and no limits are reported. This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on Node's\n * `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(\n status: RuntimeLicenseStatus | null | undefined,\n runtimeEntitlements?: RuntimeEntitlementResponse,\n): LicenseContextValue {\n const readyEntitlement =\n runtimeEntitlements?.status === \"ready\"\n ? runtimeEntitlements.entitlement\n : null;\n const hasUsableSelfHostedLegacyFallback =\n readyEntitlement &&\n !readyEntitlement.active &&\n readyEntitlement.source === \"selfHostedDeploymentLicense\" &&\n (status === \"valid\" || status === \"expiring\");\n const featureAuthority =\n readyEntitlement && !hasUsableSelfHostedLegacyFallback\n ? readyEntitlement\n : null;\n const activeEntitlement = featureAuthority?.active ? featureAuthority : null;\n const resolvedStatus = activeEntitlement\n ? \"valid\"\n : readyEntitlement?.source === \"managedOrgSubscription\" ||\n readyEntitlement?.source === \"awsMarketplaceDeploymentLicense\"\n ? \"none\"\n : featureAuthority\n ? (status ?? \"none\")\n : (status ?? null);\n const featuresEnabled =\n resolvedStatus !== \"expired\" && resolvedStatus !== \"invalid\";\n\n return {\n status: resolvedStatus,\n license: null,\n checkFeature: (feature) =>\n featureAuthority\n ? activeEntitlement\n ? feature === \"threads\" &&\n Object.prototype.hasOwnProperty.call(\n activeEntitlement.limits,\n \"threads.max_count\",\n )\n ? true\n : (getOwnRecordValue(activeEntitlement.features, feature) ??\n isLegacyUiFeature(feature))\n : false\n : featuresEnabled,\n getLimit: (feature) =>\n activeEntitlement\n ? (getOwnRecordValue(activeEntitlement.limits, feature) ?? null)\n : null,\n };\n}\n\nexport {\n A2UI_DEFAULT_GENERATION_GUIDELINES,\n A2UI_DEFAULT_DESIGN_GUIDELINES,\n} from \"./a2ui-prompts\";\n\nexport type { DebugEventEnvelope } from \"./debug-event-envelope\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAa,qBAAqBA;;AA0ClC,SAAS,kBACP,QACA,KACmB;AACnB,QAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI,GACpD,OAAO,OACP;;;AAIN,SAAS,kBAAkB,SAA0B;AACnD,QAAO,YAAY,UAAU,YAAY,WAAW,YAAY;;;;;;;;;;;;;;;;AAiBlE,SAAgB,0BACd,QACA,qBACqB;CACrB,MAAM,mBACJ,qBAAqB,WAAW,UAC5B,oBAAoB,cACpB;CACN,MAAM,oCACJ,oBACA,CAAC,iBAAiB,UAClB,iBAAiB,WAAW,kCAC3B,WAAW,WAAW,WAAW;CACpC,MAAM,mBACJ,oBAAoB,CAAC,oCACjB,mBACA;CACN,MAAM,oBAAoB,kBAAkB,SAAS,mBAAmB;CACxE,MAAM,iBAAiB,oBACnB,UACA,kBAAkB,WAAW,4BAC3B,kBAAkB,WAAW,oCAC7B,SACA,mBACG,UAAU,SACV,UAAU;CACnB,MAAM,kBACJ,mBAAmB,aAAa,mBAAmB;AAErD,QAAO;EACL,QAAQ;EACR,SAAS;EACT,eAAe,YACb,mBACI,oBACE,YAAY,aACZ,OAAO,UAAU,eAAe,KAC9B,kBAAkB,QAClB,oBACD,GACC,OACC,kBAAkB,kBAAkB,UAAU,QAAQ,IACvD,kBAAkB,QAAQ,GAC5B,QACF;EACN,WAAW,YACT,oBACK,kBAAkB,kBAAkB,QAAQ,QAAQ,IAAI,OACzD;EACP"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1332,15 +1332,34 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
1332
1332
|
|
|
1333
1333
|
//#endregion
|
|
1334
1334
|
//#region src/telemetry/sampling.ts
|
|
1335
|
-
/**
|
|
1335
|
+
/** The rate a sink that takes every event is "gated" at. */
|
|
1336
|
+
const UNSAMPLED_RATE = 1;
|
|
1337
|
+
/** Identifies which client emitted an event. */
|
|
1336
1338
|
const TELEMETRY_EMITTER_V1 = "v1-shared";
|
|
1337
1339
|
const TELEMETRY_EMITTER_V2 = "v2-runtime";
|
|
1338
1340
|
/**
|
|
1341
|
+
* Which public API surface the developer built against.
|
|
1342
|
+
*
|
|
1343
|
+
* Separate from {@link TelemetryEmitter} on purpose. The emitter names a
|
|
1344
|
+
* client library, and there are six of them across four languages; the
|
|
1345
|
+
* surface answers the question anyone actually asks of this data, which
|
|
1346
|
+
* is how much traffic still arrives through the deprecated v1 API. The
|
|
1347
|
+
* native runtimes (Go, Python, Ruby, .NET) expose v2 only, so they report
|
|
1348
|
+
* `v2` without having a v1 notion of their own.
|
|
1349
|
+
*/
|
|
1350
|
+
const TELEMETRY_SURFACE_V1 = "v1";
|
|
1351
|
+
const TELEMETRY_SURFACE_V2 = "v2";
|
|
1352
|
+
/**
|
|
1339
1353
|
* Compute the sampling block for one captured event.
|
|
1340
1354
|
*
|
|
1341
1355
|
* `telemetryId` is the caller's parsed license telemetry_id, or null when
|
|
1342
1356
|
* anonymous — it decides the branch, and is deliberately not returned:
|
|
1343
1357
|
* only the non-PII shape below travels on the event.
|
|
1358
|
+
*
|
|
1359
|
+
* `sampleRate` is the rate of the wire this copy travels on, so an
|
|
1360
|
+
* unsampled sink passes {@link UNSAMPLED_RATE}. Call it once per wire:
|
|
1361
|
+
* the v1 client sends one capture to two wires gated differently, and a
|
|
1362
|
+
* shared block would misweight one of them.
|
|
1344
1363
|
*/
|
|
1345
1364
|
function computeSamplingMeta({ telemetryId, sampleRate }) {
|
|
1346
1365
|
const identified = Boolean(telemetryId);
|
|
@@ -1353,6 +1372,106 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
1353
1372
|
};
|
|
1354
1373
|
}
|
|
1355
1374
|
|
|
1375
|
+
//#endregion
|
|
1376
|
+
//#region src/telemetry/model-host.ts
|
|
1377
|
+
/**
|
|
1378
|
+
* Every value `classifyModelHost` can return.
|
|
1379
|
+
*
|
|
1380
|
+
* `other` means a host we observed and did not recognize: a gateway, a proxy,
|
|
1381
|
+
* or a vendor we have no rule for. `unknown` means we never saw a host at all,
|
|
1382
|
+
* which is the case when a caller hands us an already-built LanguageModel.
|
|
1383
|
+
* The two are not interchangeable — one is an unrecognized answer, the other
|
|
1384
|
+
* is a missing one, and they need different follow-up.
|
|
1385
|
+
*/
|
|
1386
|
+
const MODEL_HOST_CLASSES = [
|
|
1387
|
+
"openai",
|
|
1388
|
+
"azure",
|
|
1389
|
+
"openrouter",
|
|
1390
|
+
"anthropic",
|
|
1391
|
+
"google",
|
|
1392
|
+
"vertex",
|
|
1393
|
+
"bedrock",
|
|
1394
|
+
"groq",
|
|
1395
|
+
"unify",
|
|
1396
|
+
"minimax",
|
|
1397
|
+
"local",
|
|
1398
|
+
"other",
|
|
1399
|
+
"unknown"
|
|
1400
|
+
];
|
|
1401
|
+
/**
|
|
1402
|
+
* Host suffixes mapped to their vendor.
|
|
1403
|
+
*
|
|
1404
|
+
* Matched on label boundaries, never as substrings, so
|
|
1405
|
+
* `myresource.openai.azure.com.attacker.test` does not read as Azure.
|
|
1406
|
+
*/
|
|
1407
|
+
const HOST_SUFFIXES = [
|
|
1408
|
+
["openai.azure.com", "azure"],
|
|
1409
|
+
["services.ai.azure.com", "azure"],
|
|
1410
|
+
["cognitiveservices.azure.com", "azure"],
|
|
1411
|
+
["azure-api.net", "azure"],
|
|
1412
|
+
["api.openai.com", "openai"],
|
|
1413
|
+
["openrouter.ai", "openrouter"],
|
|
1414
|
+
["api.anthropic.com", "anthropic"],
|
|
1415
|
+
["generativelanguage.googleapis.com", "google"],
|
|
1416
|
+
["aiplatform.googleapis.com", "vertex"],
|
|
1417
|
+
["api.groq.com", "groq"],
|
|
1418
|
+
["api.unify.ai", "unify"],
|
|
1419
|
+
["api.minimax.io", "minimax"],
|
|
1420
|
+
["api.minimaxi.com", "minimax"]
|
|
1421
|
+
];
|
|
1422
|
+
/** Suffixes that mean the model runs on the same machine or private network. */
|
|
1423
|
+
const LOCAL_SUFFIXES = [
|
|
1424
|
+
"localhost",
|
|
1425
|
+
"local",
|
|
1426
|
+
"internal",
|
|
1427
|
+
"docker.internal"
|
|
1428
|
+
];
|
|
1429
|
+
/** Matches `<region>-aiplatform.googleapis.com` and the Bedrock regional hosts. */
|
|
1430
|
+
const REGIONAL_HOST_PATTERNS = [[/^[a-z0-9-]+-aiplatform\.googleapis\.com$/, "vertex"], [/^bedrock[a-z0-9.-]*\.[a-z0-9-]+\.amazonaws\.com$/, "bedrock"]];
|
|
1431
|
+
/** True when `host` equals `suffix` or sits directly beneath it. */
|
|
1432
|
+
function matchesSuffix(host, suffix) {
|
|
1433
|
+
return host === suffix || host.endsWith(`.${suffix}`);
|
|
1434
|
+
}
|
|
1435
|
+
/** True for loopback, unspecified, and RFC 1918 private addresses. */
|
|
1436
|
+
function isPrivateAddress(host) {
|
|
1437
|
+
if (host === "127.0.0.1" || host === "0.0.0.0" || host === "::1") return true;
|
|
1438
|
+
if (/^127\./.test(host)) return true;
|
|
1439
|
+
if (/^10\./.test(host) || /^192\.168\./.test(host)) return true;
|
|
1440
|
+
const privateClassB = /^172\.(\d{1,3})\./.exec(host);
|
|
1441
|
+
if (privateClassB) {
|
|
1442
|
+
const secondOctet = Number(privateClassB[1]);
|
|
1443
|
+
return secondOctet >= 16 && secondOctet <= 31;
|
|
1444
|
+
}
|
|
1445
|
+
return false;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Reduce a model endpoint to one of {@link MODEL_HOST_CLASSES}.
|
|
1449
|
+
*
|
|
1450
|
+
* @param baseUrl The endpoint the provider was configured with. Absent when
|
|
1451
|
+
* the provider was left on its own default, which is why `providerDefault`
|
|
1452
|
+
* exists: "no base URL, provider is openai" means api.openai.com.
|
|
1453
|
+
* @param providerDefault What to report when no base URL was supplied. Callers
|
|
1454
|
+
* that genuinely cannot observe a host — a pre-built LanguageModel handed in
|
|
1455
|
+
* by the developer — leave this alone and get `unknown`.
|
|
1456
|
+
*/
|
|
1457
|
+
function classifyModelHost(baseUrl, providerDefault = "unknown") {
|
|
1458
|
+
const trimmed = baseUrl === null || baseUrl === void 0 ? void 0 : baseUrl.trim();
|
|
1459
|
+
if (!trimmed) return providerDefault;
|
|
1460
|
+
let host;
|
|
1461
|
+
try {
|
|
1462
|
+
host = new URL(trimmed).hostname.toLowerCase();
|
|
1463
|
+
} catch (_unused) {
|
|
1464
|
+
return "other";
|
|
1465
|
+
}
|
|
1466
|
+
host = host.replace(/^\[|\]$/g, "");
|
|
1467
|
+
if (!host) return "other";
|
|
1468
|
+
if (isPrivateAddress(host)) return "local";
|
|
1469
|
+
for (const suffix of LOCAL_SUFFIXES) if (matchesSuffix(host, suffix)) return "local";
|
|
1470
|
+
for (const [suffix, hostClass] of HOST_SUFFIXES) if (matchesSuffix(host, suffix)) return hostClass;
|
|
1471
|
+
for (const [pattern, hostClass] of REGIONAL_HOST_PATTERNS) if (pattern.test(host)) return hostClass;
|
|
1472
|
+
return "other";
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1356
1475
|
//#endregion
|
|
1357
1476
|
//#region src/telemetry/lambda-client.ts
|
|
1358
1477
|
var _process$env;
|
|
@@ -1642,69 +1761,77 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
1642
1761
|
//#region src/finalize-events.ts
|
|
1643
1762
|
const defaultStopMessage = "Run stopped by user";
|
|
1644
1763
|
const defaultAbruptEndMessage = "Run ended without emitting a terminal event";
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1764
|
+
/**
|
|
1765
|
+
* Incremental finalizer for a streamed AG-UI run. Feed every event to
|
|
1766
|
+
* `observe`; when the stream ends without a terminal event, `finalize` returns
|
|
1767
|
+
* the closers for text messages and tool calls still open plus a terminal
|
|
1768
|
+
* event. Closed lifecycles are forgotten at once and payloads are never kept,
|
|
1769
|
+
* so a caller does not have to retain the event array for this purpose.
|
|
1770
|
+
*/
|
|
1771
|
+
function createRunEventFinalizer() {
|
|
1650
1772
|
const openMessageIds = /* @__PURE__ */ new Set();
|
|
1651
1773
|
const openToolCalls = /* @__PURE__ */ new Map();
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1774
|
+
let terminalEventObserved = false;
|
|
1775
|
+
const observe = (event) => {
|
|
1776
|
+
if (terminalEventObserved) return;
|
|
1777
|
+
switch (event.type) {
|
|
1778
|
+
case _ag_ui_client.EventType.TEXT_MESSAGE_START: {
|
|
1779
|
+
const messageId = event.messageId;
|
|
1780
|
+
if (messageId) openMessageIds.add(messageId);
|
|
1781
|
+
break;
|
|
1782
|
+
}
|
|
1783
|
+
case _ag_ui_client.EventType.TEXT_MESSAGE_END: {
|
|
1784
|
+
const messageId = event.messageId;
|
|
1785
|
+
if (typeof messageId === "string") openMessageIds.delete(messageId);
|
|
1786
|
+
break;
|
|
1787
|
+
}
|
|
1788
|
+
case _ag_ui_client.EventType.TOOL_CALL_START: {
|
|
1789
|
+
const toolCallId = event.toolCallId;
|
|
1790
|
+
if (toolCallId && !openToolCalls.has(toolCallId)) openToolCalls.set(toolCallId, {
|
|
1791
|
+
hasEnd: false,
|
|
1792
|
+
hasResult: false
|
|
1793
|
+
});
|
|
1794
|
+
break;
|
|
1795
|
+
}
|
|
1796
|
+
case _ag_ui_client.EventType.TOOL_CALL_END:
|
|
1797
|
+
case _ag_ui_client.EventType.TOOL_CALL_RESULT: {
|
|
1798
|
+
const toolCallId = event.toolCallId;
|
|
1799
|
+
if (!toolCallId) break;
|
|
1800
|
+
const info = openToolCalls.get(toolCallId);
|
|
1801
|
+
if (!info) break;
|
|
1802
|
+
if (event.type === _ag_ui_client.EventType.TOOL_CALL_END) info.hasEnd = true;
|
|
1803
|
+
else info.hasResult = true;
|
|
1804
|
+
if (info.hasEnd && info.hasResult) openToolCalls.delete(toolCallId);
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
case _ag_ui_client.EventType.RUN_FINISHED:
|
|
1808
|
+
case _ag_ui_client.EventType.RUN_ERROR:
|
|
1809
|
+
terminalEventObserved = true;
|
|
1810
|
+
openMessageIds.clear();
|
|
1811
|
+
openToolCalls.clear();
|
|
1812
|
+
break;
|
|
1813
|
+
default: break;
|
|
1682
1814
|
}
|
|
1683
|
-
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
const
|
|
1815
|
+
};
|
|
1816
|
+
const finalize = (options = {}) => {
|
|
1817
|
+
if (terminalEventObserved) return [];
|
|
1818
|
+
const { stopRequested = false, interruptionMessage } = options;
|
|
1819
|
+
const resolvedStopMessage = interruptionMessage !== null && interruptionMessage !== void 0 ? interruptionMessage : defaultStopMessage;
|
|
1820
|
+
const resolvedAbruptMessage = interruptionMessage && interruptionMessage !== defaultStopMessage ? interruptionMessage : defaultAbruptEndMessage;
|
|
1821
|
+
const appended = [];
|
|
1822
|
+
for (const messageId of openMessageIds) appended.push({
|
|
1688
1823
|
type: _ag_ui_client.EventType.TEXT_MESSAGE_END,
|
|
1689
1824
|
messageId
|
|
1690
|
-
};
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1694
|
-
for (const [toolCallId, info] of openToolCalls) {
|
|
1695
|
-
if (!info.hasEnd) {
|
|
1696
|
-
const endEvent = {
|
|
1825
|
+
});
|
|
1826
|
+
for (const [toolCallId, info] of openToolCalls) {
|
|
1827
|
+
if (!info.hasEnd) appended.push({
|
|
1697
1828
|
type: _ag_ui_client.EventType.TOOL_CALL_END,
|
|
1698
1829
|
toolCallId
|
|
1699
|
-
};
|
|
1700
|
-
|
|
1701
|
-
appended.push(endEvent);
|
|
1702
|
-
}
|
|
1703
|
-
if (!info.hasResult) {
|
|
1704
|
-
const resultEvent = {
|
|
1830
|
+
});
|
|
1831
|
+
if (!info.hasResult) appended.push({
|
|
1705
1832
|
type: _ag_ui_client.EventType.TOOL_CALL_RESULT,
|
|
1706
1833
|
toolCallId,
|
|
1707
|
-
messageId: `${toolCallId
|
|
1834
|
+
messageId: `${toolCallId}-result`,
|
|
1708
1835
|
role: "tool",
|
|
1709
1836
|
content: JSON.stringify(stopRequested ? {
|
|
1710
1837
|
status: "stopped",
|
|
@@ -1715,24 +1842,37 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
1715
1842
|
reason: "missing_terminal_event",
|
|
1716
1843
|
message: resolvedAbruptMessage
|
|
1717
1844
|
})
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
if (stopRequested) appended.push({ type: _ag_ui_client.EventType.RUN_FINISHED });
|
|
1848
|
+
else {
|
|
1849
|
+
const errorEvent = {
|
|
1850
|
+
type: _ag_ui_client.EventType.RUN_ERROR,
|
|
1851
|
+
message: resolvedAbruptMessage,
|
|
1852
|
+
code: "INCOMPLETE_STREAM"
|
|
1718
1853
|
};
|
|
1719
|
-
|
|
1720
|
-
appended.push(resultEvent);
|
|
1854
|
+
appended.push(errorEvent);
|
|
1721
1855
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1856
|
+
terminalEventObserved = true;
|
|
1857
|
+
openMessageIds.clear();
|
|
1858
|
+
openToolCalls.clear();
|
|
1859
|
+
return appended;
|
|
1860
|
+
};
|
|
1861
|
+
return {
|
|
1862
|
+
observe,
|
|
1863
|
+
finalize
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Array form of {@link createRunEventFinalizer} for callers that already keep
|
|
1868
|
+
* the run's events (runners persist them). Appends the closers to `events` in
|
|
1869
|
+
* place and returns them.
|
|
1870
|
+
*/
|
|
1871
|
+
function finalizeRunEvents(events, options = {}) {
|
|
1872
|
+
const finalizer = createRunEventFinalizer();
|
|
1873
|
+
for (const event of events) finalizer.observe(event);
|
|
1874
|
+
const appended = finalizer.finalize(options);
|
|
1875
|
+
events.push(...appended);
|
|
1736
1876
|
return appended;
|
|
1737
1877
|
}
|
|
1738
1878
|
|
|
@@ -1818,7 +1958,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
1818
1958
|
|
|
1819
1959
|
//#endregion
|
|
1820
1960
|
//#region package.json
|
|
1821
|
-
var version = "1.
|
|
1961
|
+
var version = "1.73.0";
|
|
1822
1962
|
|
|
1823
1963
|
//#endregion
|
|
1824
1964
|
//#region src/a2ui-prompts.ts
|
|
@@ -2008,6 +2148,7 @@ exports.DEFAULT_AGENT_ID = DEFAULT_AGENT_ID;
|
|
|
2008
2148
|
exports.ERROR_CONFIG = ERROR_CONFIG;
|
|
2009
2149
|
exports.ERROR_NAMES = ERROR_NAMES;
|
|
2010
2150
|
exports.ErrorVisibility = ErrorVisibility;
|
|
2151
|
+
exports.MODEL_HOST_CLASSES = MODEL_HOST_CLASSES;
|
|
2011
2152
|
exports.MissingPublicApiKeyError = MissingPublicApiKeyError;
|
|
2012
2153
|
exports.RUNTIME_MODE_INTELLIGENCE = RUNTIME_MODE_INTELLIGENCE;
|
|
2013
2154
|
exports.RUNTIME_MODE_SSE = RUNTIME_MODE_SSE;
|
|
@@ -2015,14 +2156,19 @@ exports.ResolvedCopilotKitError = ResolvedCopilotKitError;
|
|
|
2015
2156
|
exports.Severity = Severity;
|
|
2016
2157
|
exports.TELEMETRY_EMITTER_V1 = TELEMETRY_EMITTER_V1;
|
|
2017
2158
|
exports.TELEMETRY_EMITTER_V2 = TELEMETRY_EMITTER_V2;
|
|
2159
|
+
exports.TELEMETRY_SURFACE_V1 = TELEMETRY_SURFACE_V1;
|
|
2160
|
+
exports.TELEMETRY_SURFACE_V2 = TELEMETRY_SURFACE_V2;
|
|
2018
2161
|
exports.TranscriptionErrorCode = TranscriptionErrorCode;
|
|
2019
2162
|
exports.TranscriptionErrors = TranscriptionErrors;
|
|
2163
|
+
exports.UNSAMPLED_RATE = UNSAMPLED_RATE;
|
|
2020
2164
|
exports.UpgradeRequiredError = UpgradeRequiredError;
|
|
2021
2165
|
exports.actionParametersToJsonSchema = actionParametersToJsonSchema;
|
|
2166
|
+
exports.classifyModelHost = classifyModelHost;
|
|
2022
2167
|
exports.computeSamplingMeta = computeSamplingMeta;
|
|
2023
2168
|
exports.convertJsonSchemaToZodSchema = convertJsonSchemaToZodSchema;
|
|
2024
2169
|
exports.copyToClipboard = copyToClipboard;
|
|
2025
2170
|
exports.createLicenseContextValue = createLicenseContextValue;
|
|
2171
|
+
exports.createRunEventFinalizer = createRunEventFinalizer;
|
|
2026
2172
|
exports.dataToUUID = dataToUUID;
|
|
2027
2173
|
exports.ensureStructuredError = ensureStructuredError;
|
|
2028
2174
|
exports.exceedsMaxSize = exceedsMaxSize;
|