@copilotkit/core 1.80.0 → 1.82.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/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _ag_ui_client0 from "@ag-ui/client";
2
2
  import { AbstractAgent, AgentCapabilities, AgentSubscriber, BaseEvent, Context, HttpAgent, HttpAgentConfig, Interrupt, Message, ResumeEntry, RunAgentInput, RunAgentParameters, RunAgentResult, State, Tool, ToolCall } from "@ag-ui/client";
3
- import { DebugConfig, InspectorMetadataV1, InspectorMetadataV1 as InspectorMetadataV1$1, IntelligenceRuntimeInfo, IntelligenceRuntimeInfo as IntelligenceRuntimeInfo$1, ResolvedDebugConfig, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeLicenseStatus as RuntimeLicenseStatus$1, RuntimeMode, RuntimeMode as RuntimeMode$1, StandardSchemaV1, ThreadEndpointRuntimeInfo, ThreadEndpointRuntimeInfo as ThreadEndpointRuntimeInfo$1 } from "@copilotkit/shared";
3
+ import { A2UIOperation, CopilotKitUIEnvelope, DebugConfig, GenerativeUIComponentManifest, GenerativeUIJSONSchema, GenerativeUIRejectedOperation, GenerativeUISurfaceStatus, GenerativeUITarget, InspectorMetadataV1, InspectorMetadataV1 as InspectorMetadataV1$1, IntelligenceRuntimeInfo, IntelligenceRuntimeInfo as IntelligenceRuntimeInfo$1, ResolvedDebugConfig, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeLicenseStatus as RuntimeLicenseStatus$1, RuntimeMode, RuntimeMode as RuntimeMode$1, StandardSchemaV1, ThreadEndpointRuntimeInfo, ThreadEndpointRuntimeInfo as ThreadEndpointRuntimeInfo$1 } from "@copilotkit/shared";
4
4
  import { Observable, OperatorFunction, Subscription } from "rxjs";
5
5
  import { CaptureOptions, CollectorOptions, JsonValue, JsonValue as JsonValue$1, StartResult, StartResult as StartResult$1, TrajectoryCaptureOptions } from "@copilotkit/learning";
6
6
 
@@ -1015,6 +1015,16 @@ declare class RunHandler {
1015
1015
  * overlapping run keeps the intercept after an earlier run finishes.
1016
1016
  */
1017
1017
  private _originalAbortRuns;
1018
+ /**
1019
+ * The request each agent's in-flight run belongs to. Its follow-up runs
1020
+ * send the same ID, so Intelligence counts the chain as one request.
1021
+ */
1022
+ private _activeRequestIds;
1023
+ /**
1024
+ * Request IDs of recent logical runs, so an approval that resumes a paused
1025
+ * run sends the ID of the request that paused. Oldest entries go first.
1026
+ */
1027
+ private _requestIdByRun;
1018
1028
  /**
1019
1029
  * Keeps tools that opt in via `webmcp` registered on the page's WebMCP model
1020
1030
  * context (`document.modelContext`), in addition to the normal agent
@@ -1154,6 +1164,7 @@ declare class RunHandler {
1154
1164
  */
1155
1165
 
1156
1166
  followUpOf?: AbortController): Promise<RunAgentResult>;
1167
+ private rememberRequestId;
1157
1168
  /**
1158
1169
  * Process agent result and execute tools
1159
1170
  */
@@ -1673,6 +1684,78 @@ declare const ɵMAX_SOCKET_RETRIES = 5;
1673
1684
  */
1674
1685
  declare const ɵTHREAD_REQUEST_TIMEOUT_MS = 15000;
1675
1686
  //#endregion
1687
+ //#region src/core/generative-ui-debug.d.ts
1688
+ /** @internal One declared function of the generative UI, for the inspector. */
1689
+ interface ɵGenerativeUIDebugFunction {
1690
+ description?: string;
1691
+ parameters: GenerativeUIJSONSchema;
1692
+ /** How many `useGenerativeUIFunction` handlers are mounted. Only 1 is valid. */
1693
+ handlers: number;
1694
+ }
1695
+ /** @internal One surface that the browser holds, for the inspector. */
1696
+ interface ɵGenerativeUIDebugSurface {
1697
+ surfaceId: string;
1698
+ threadId: string;
1699
+ agentId: string | undefined;
1700
+ target: string;
1701
+ status: GenerativeUISurfaceStatus;
1702
+ /** The committed operations, in order. The browser can still reject some. */
1703
+ operations: readonly A2UIOperation[];
1704
+ /** The current data model. */
1705
+ dataModel: unknown;
1706
+ /** The values that the user wrote, by path. Agent writes to them are ignored. */
1707
+ userValues: Record<string, unknown>;
1708
+ rejected: Array<GenerativeUIRejectedOperation & {
1709
+ source: "runtime" | "browser";
1710
+ }>;
1711
+ }
1712
+ /** @internal One part of the text that a run adds to the prompt of the model. */
1713
+ interface ɵGenerativeUIDebugPromptSection {
1714
+ title: string;
1715
+ /** Who adds the text to the prompt. */
1716
+ source: "runtime" | "context" | "backend";
1717
+ text: string;
1718
+ }
1719
+ /** @internal What one run sends, or what the next run will send. */
1720
+ interface ɵGenerativeUIDebugRun {
1721
+ agentId: string | undefined;
1722
+ threadId: string | undefined;
1723
+ /** When the run started. Left out for the next run. */
1724
+ startedAt?: number;
1725
+ /** `forwardedProps.copilotkit.ui` of the run. */
1726
+ envelope: CopilotKitUIEnvelope;
1727
+ prompt: ɵGenerativeUIDebugPromptSection[];
1728
+ }
1729
+ /** @internal The state of a generative UI, for the inspector. */
1730
+ interface ɵGenerativeUIDebugSnapshot {
1731
+ catalogId: string;
1732
+ transport: "tool" | "markdown";
1733
+ /** The agents that get the generative UI. Left out: every agent. */
1734
+ agentIds?: string[];
1735
+ components: Record<string, GenerativeUIComponentManifest>;
1736
+ /** The id of the catalog that declared each component, by name. */
1737
+ componentCatalogs: Record<string, string>;
1738
+ functions: Record<string, ɵGenerativeUIDebugFunction>;
1739
+ /** The app state that bound props read, by key. */
1740
+ state: Record<string, unknown>;
1741
+ /** The chat first, then each mounted `<GenerativeUISurface>`. */
1742
+ targets: GenerativeUITarget[];
1743
+ activeThreadId: string | undefined;
1744
+ surfaces: ɵGenerativeUIDebugSurface[];
1745
+ lastRun: ɵGenerativeUIDebugRun | undefined;
1746
+ nextRun: ɵGenerativeUIDebugRun;
1747
+ }
1748
+ /**
1749
+ * @internal What a framework package (react-core) gives core, so that the
1750
+ * inspector can show its generative UI. `getSnapshot` builds the snapshot
1751
+ * when it is called, so a source that nobody reads costs nothing.
1752
+ */
1753
+ interface ɵGenerativeUIDebugSource {
1754
+ getSnapshot(): ɵGenerativeUIDebugSnapshot;
1755
+ /** Calls `listener` when the snapshot changes. Returns the unsubscribe. */
1756
+ subscribe(listener: () => void): () => void;
1757
+ }
1758
+ //#endregion
1676
1759
  //#region src/memory-errors.d.ts
1677
1760
  /**
1678
1761
  * Memory error registry — stable codes for the errors the memory store throws.
@@ -2091,6 +2174,16 @@ declare class CopilotKitHeaderResolutionError extends Error {
2091
2174
  declare function ɵwithHeaderDefaults(source: CopilotKitHeadersSource, defaults: Record<string, string>): CopilotKitHeadersSource;
2092
2175
  //#endregion
2093
2176
  //#region src/core/core.d.ts
2177
+ /**
2178
+ * Run properties that go only to the runs of some agents.
2179
+ * See `CopilotKitCore.addScopedProperties`.
2180
+ */
2181
+ interface ScopedProperties {
2182
+ /** The properties to merge on top of the base run properties. */
2183
+ properties: Record<string, unknown>;
2184
+ /** The agents that get these properties. When omitted, every agent gets them. */
2185
+ agentIds?: string[];
2186
+ }
2094
2187
  /** Configuration options for `CopilotKitCore`. */
2095
2188
  interface CopilotKitCoreConfig {
2096
2189
  /** The endpoint of the CopilotRuntime. */
@@ -2377,6 +2470,7 @@ interface CopilotKitCoreFriendsAccess {
2377
2470
  readonly debug?: DebugConfig;
2378
2471
  buildFrontendTools(agentId?: string): _ag_ui_client0.Tool[];
2379
2472
  getContextForAgent(agentId?: string): Context[];
2473
+ getPropertiesForAgent(agentId?: string): Record<string, unknown>;
2380
2474
  getAgent(id: string): AbstractAgent | undefined;
2381
2475
  /**
2382
2476
  * Re-apply the last resolved header snapshot to a single agent, merged on
@@ -2415,6 +2509,7 @@ declare class CopilotKitCore {
2415
2509
  private _credentials?;
2416
2510
  private _messageFilter?;
2417
2511
  private _properties;
2512
+ private _scopedProperties;
2418
2513
  private _defaultThrottleMs?;
2419
2514
  private _debug?;
2420
2515
  private subscribers;
@@ -2427,6 +2522,8 @@ declare class CopilotKitCore {
2427
2522
  private learningBridge;
2428
2523
  private notifiedTrajectoryId;
2429
2524
  private readonly learningConfiguredListeners;
2525
+ private _generativeUIDebugSource;
2526
+ private readonly generativeUIDebugListeners;
2430
2527
  /**
2431
2528
  * The single core-owned memory store, created lazily on first
2432
2529
  * `getMemoryStore()` and kept user-scoped for the lifetime of the core.
@@ -2600,6 +2697,37 @@ declare class CopilotKitCore {
2600
2697
  * to sending the full thread.
2601
2698
  */
2602
2699
  setMessageFilter(messageFilter: CopilotKitMessageFilter | undefined): void;
2700
+ /**
2701
+ * Add run properties that go only to the runs of `agentIds`. When
2702
+ * `agentIds` is omitted, every agent gets them. They merge on top of the
2703
+ * base `properties`.
2704
+ *
2705
+ * When an entry value and the existing value under the same key are both
2706
+ * plain objects, their keys merge one level deep. So several entries can
2707
+ * add keys under one namespace (for example `copilotkit`).
2708
+ *
2709
+ * @param entry - The properties and the optional agent ids.
2710
+ * @returns The id to pass to `removeScopedProperties`.
2711
+ *
2712
+ * @example
2713
+ * const id = copilotkit.addScopedProperties({
2714
+ * properties: { copilotkit: { theme: "dark" } },
2715
+ * agentIds: ["research"],
2716
+ * });
2717
+ * copilotkit.removeScopedProperties(id);
2718
+ */
2719
+ addScopedProperties({
2720
+ properties,
2721
+ agentIds
2722
+ }: ScopedProperties): string;
2723
+ /** Remove an entry that `addScopedProperties` added. An unknown id does nothing. */
2724
+ removeScopedProperties(id: string): void;
2725
+ /**
2726
+ * Build the forwarded properties for a run of the given agent: the base
2727
+ * properties plus every scoped entry that matches the agent. An entry with
2728
+ * `agentIds` does not match when `agentId` is omitted.
2729
+ */
2730
+ getPropertiesForAgent(agentId?: string): Record<string, unknown>;
2603
2731
  setProperties(properties: Record<string, unknown>): void;
2604
2732
  /**
2605
2733
  * Agent management (delegated to AgentRegistry)
@@ -2644,6 +2772,15 @@ declare class CopilotKitCore {
2644
2772
  get ɵlearningCapturesAgentText(): boolean;
2645
2773
  /** @internal Calls `listener` when {@link ɵlearningConfigured} changes. */
2646
2774
  ɵsubscribeToLearningConfigured(listener: () => void): () => void;
2775
+ /**
2776
+ * @internal The generative UI of the framework package, for the inspector.
2777
+ * `undefined` when no provider has a `generativeUI` config.
2778
+ */
2779
+ get ɵgenerativeUIDebugSource(): ɵGenerativeUIDebugSource | undefined;
2780
+ /** @internal Set by the framework package. `undefined` removes it. */
2781
+ ɵsetGenerativeUIDebugSource(source: ɵGenerativeUIDebugSource | undefined): void;
2782
+ /** @internal Calls `listener` when {@link ɵgenerativeUIDebugSource} is set or removed. */
2783
+ ɵsubscribeToGenerativeUIDebugSource(listener: () => void): () => void;
2647
2784
  /** The active capture's Trajectory ID, or null while capture is stopped. */
2648
2785
  get trajectoryId(): string | null;
2649
2786
  private notifyTrajectoryChanged;
@@ -3441,5 +3578,288 @@ declare function onInspectorStopViewing(handler: (payload: InspectorStopViewingP
3441
3578
  declare function onInspectorActiveThread(handler: (payload: InspectorActiveThreadPayload) => void): () => void;
3442
3579
  declare function onInspectorViewThreadResult(handler: (payload: InspectorViewThreadResultPayload) => void): () => void;
3443
3580
  //#endregion
3444
- export { ActionConfig, ActionCreator, ActionFromCreator, ActionFromCreators, ActionGroupConfig, ActionGroupResult, AgentRegistry, AgentThreadLockedError, AnyAction, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, type CopilotKitCoreCatalogComponent, CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreContinuationHandoff, CopilotKitCoreErrorCode, CopilotKitCoreFriendsAccess, CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRegisterProxiedAgentParams, type CopilotKitCoreRegisterProxiedAgentResult, type CopilotKitCoreRunAgentParams, type CopilotKitCoreRunToolParams, type CopilotKitCoreRunToolResult, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreStopAgentParams, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, CopilotKitHeaderResolutionError, type CopilotKitHeadersSource, type CopilotKitMessageFilter, CopilotRuntimeTransport, DispatchingEffect, DispatchingEffectOptions, DynamicSuggestionsConfig, Effect, EmptyActionConfig, FrontendTool, FrontendToolHandlerContext, FrontendToolReconnectBehavior, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, InspectorActiveThreadPayload, type InspectorMetadataV1, InspectorStopViewingPayload, InspectorViewThreadPayload, InspectorViewThreadResultPayload, IntelligenceAgent, IntelligenceAgentConfig, type IntelligenceRuntimeInfo, type JsonValue, type LearningConfig, type LegacyLearningConfig, MEMORY_ERROR_REGISTRY, Memory, MemoryChanges, MemoryError, type MemoryErrorCategory, type MemoryErrorCode, type MemoryErrorRegistryEntry, MemoryKind, MemoryRealtimeStatus, MemoryScope, NewMemory, NonDispatchingEffect, NonDispatchingEffectOptions, type OpenThreadRegistration, PropsActionConfig, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgentConfig, Reducer, RunCompletionAware, RunHandler, type RuntimeLicenseStatus, type RuntimeMode, ScopedContext, Selector, type StartResult, StateManager, StaticSuggestionsConfig, Store, StoreLifecycleAction, SubscribeToAgentOptions, SubscribeToAgentSubscriber, Suggestion, SuggestionAvailability, SuggestionEngine, SuggestionsConfig, type ThreadEndpointRuntimeInfo, ThreadRunActivityNotification, ToolCallStatus, type TrajectoryStartOptions, WebMCPModelContext, WebMCPRegistry, WebMCPToolAnnotations, WebMCPToolConfig, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, empty, ensureObjectArgs, getWebMCPModelContext, isAbortError, isInspectorThreadBridgeEnabled, isRunCompletionAware, ofType, on, onInspectorActiveThread, onInspectorStopViewing, onInspectorViewThread, onInspectorViewThreadResult, parseToolArguments, props, select, ɵCOPILOTKIT_FEATURES, ɵCopilotKitFeature, ɵInterruptDecision, ɵInterruptEvent, ɵInterruptState, ɵInterruptToolResult, ɵMAX_SOCKET_RETRIES, ɵMemoryEnvironment, ɵMemoryMetadataEvent, ɵMemoryRuntimeContext, ɵMemoryState, ɵMemoryStore, ɵPendingInterrupt, ɵPhoenixChannelLike, ɵPhoenixChannelOptions, ɵPhoenixChannelSession, ɵPhoenixJoinOutcome, ɵPhoenixPushLike, ɵPhoenixSocketLike, ɵPhoenixSocketOptions, ɵPhoenixSocketSession, ɵPhoenixSocketSignal, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵThread, ɵThreadEnvironment, ɵThreadMetadataEvent, ɵThreadRuntimeContext, ɵThreadSelectors, ɵThreadStore, createMemoryStore as ɵcreateMemoryStore, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵisCopilotKitFeature, ɵisHttpAgent, isRetryableStatus as ɵisRetryableMemoryStatus, ɵjoinPhoenixChannel$, ɵmapMemoryMetadataEvent, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵthreadAdapterEvents, ɵwithHeaderDefaults };
3581
+ //#region src/a2ui-markdown/fence-parser.d.ts
3582
+ /** Language of a fenced code block that carries A2UI operations. */
3583
+ declare const A2UI_FENCE_LANGUAGE = "a2ui";
3584
+ /**
3585
+ * One part of an assistant message, in source order: prose markdown, or the
3586
+ * body of a top-level ```a2ui fence. `target` is the id from a
3587
+ * `target=<id>` token in the fence info string. With no target, the surface
3588
+ * goes to the chat.
3589
+ */
3590
+ type MarkdownSegment = {
3591
+ type: "markdown";
3592
+ text: string;
3593
+ } | {
3594
+ type: "a2ui";
3595
+ index: number;
3596
+ text: string;
3597
+ closed: boolean;
3598
+ target?: string;
3599
+ };
3600
+ /**
3601
+ * Split a (possibly still streaming) markdown string into prose segments and
3602
+ * top-level ```a2ui fences. Fences of other languages stay inside prose
3603
+ * segments byte-for-byte, and a2ui markers inside them are ignored. Only
3604
+ * column-0 fences are recognised, so a fence indented inside a list item is
3605
+ * left to the markdown renderer.
3606
+ *
3607
+ * The first info-string token must be exactly `a2ui`. A later
3608
+ * `target=<id>` token sets `target` on the segment (for example
3609
+ * ```` ```a2ui target=recommendations ````). Other tokens are ignored.
3610
+ *
3611
+ * An a2ui segment's `text` is the fence body. For a closed fence it ends with
3612
+ * "\n" when non-empty. For an open (still streaming or aborted) fence it is
3613
+ * everything after the opener line, minus a half-streamed closing marker.
3614
+ *
3615
+ * @param markdown - The assistant message text, complete or still streaming.
3616
+ * @returns The segments in source order.
3617
+ *
3618
+ * @example
3619
+ * ```ts
3620
+ * for (const segment of splitA2UIMarkdown(message.content)) {
3621
+ * if (segment.type === "a2ui") renderSurface(segment.text, segment.target);
3622
+ * else renderMarkdown(segment.text);
3623
+ * }
3624
+ * ```
3625
+ */
3626
+ declare function splitA2UIMarkdown(markdown: string): MarkdownSegment[];
3627
+ //#endregion
3628
+ //#region src/a2ui-markdown/operations.d.ts
3629
+ /**
3630
+ * An A2UI v1.0 message as the model wrote it in an a2ui fence: an object that
3631
+ * carries one of createSurface, updateComponents, updateDataModel,
3632
+ * deleteSurface or callRendererFunction. The shape is not checked yet.
3633
+ * Validate it (for example with `validateOperation` from `@copilotkit/shared`)
3634
+ * before it reaches a surface or runs a function.
3635
+ *
3636
+ * It is named `A2UIMarkdownOperation` because `@copilotkit/shared` already
3637
+ * exports the strict `A2UIOperation` type.
3638
+ */
3639
+ type A2UIMarkdownOperation = Record<string, unknown>;
3640
+ /**
3641
+ * Read `"key":"value"` from partial JSON. The first match anywhere in the
3642
+ * text wins, at any depth.
3643
+ *
3644
+ * @param partialJson - JSON text that can still be streaming.
3645
+ * @param key - The field name.
3646
+ * @returns The string value, or null until its closing quote has arrived.
3647
+ *
3648
+ * @example
3649
+ * ```ts
3650
+ * extractStringField('{"createSurface":{"surfaceId":"plan","cat', "surfaceId"); // "plan"
3651
+ * ```
3652
+ */
3653
+ declare function extractStringField(partialJson: string, key: string): string | null;
3654
+ /**
3655
+ * Find `"key":[` in partial JSON and return every complete item of that array
3656
+ * so far, plus whether the array has closed. Items of a `components` array get
3657
+ * structural-key depth repair: a component that lost closing braces is fixed
3658
+ * when its `id`, `component`, `child` or `children` key shows where it ends.
3659
+ *
3660
+ * @param partialJson - JSON text that can still be streaming.
3661
+ * @param key - The name of the array field.
3662
+ * @returns `{ items, closed }`, or null when the key (with an array value)
3663
+ * has not appeared yet.
3664
+ *
3665
+ * @example
3666
+ * ```ts
3667
+ * const result = extractCompleteArrayItems(streamedText, "components");
3668
+ * if (result) render(result.items);
3669
+ * ```
3670
+ */
3671
+ declare function extractCompleteArrayItems(partialJson: string, key: string): {
3672
+ items: unknown[];
3673
+ closed: boolean;
3674
+ } | null;
3675
+ /**
3676
+ * The surfaceId an operation targets: the one nested under its operation key,
3677
+ * else a top-level `surfaceId`. A `callRendererFunction` operation targets no
3678
+ * surface, so it gets undefined.
3679
+ *
3680
+ * It is named `getMarkdownOperationSurfaceId` because `@copilotkit/shared`
3681
+ * already exports a strict `getOperationSurfaceId`. This one also reads a
3682
+ * top-level `surfaceId`, which models sometimes write.
3683
+ *
3684
+ * @param op - An operation from an a2ui fence.
3685
+ * @returns The surfaceId, or undefined when the operation names none or is a
3686
+ * function call.
3687
+ *
3688
+ * @example
3689
+ * ```ts
3690
+ * getMarkdownOperationSurfaceId({ updateDataModel: { surfaceId: "plan" } }); // "plan"
3691
+ * ```
3692
+ */
3693
+ declare function getMarkdownOperationSurfaceId(op: A2UIMarkdownOperation): string | undefined;
3694
+ /**
3695
+ * Parse the body of an a2ui fence as a stream of top-level JSON values, so
3696
+ * operations may be one per line (the documented format), several per line,
3697
+ * pretty-printed over many lines, or wrapped in a top-level array (which is
3698
+ * flattened). Whitespace and commas between objects are ignored.
3699
+ *
3700
+ * - A balanced object is `JSON.parse`d. When that fails (e.g. a stray quote),
3701
+ * its raw text goes to `invalidLines` and whatever `partialOperation` can
3702
+ * salvage (complete components, data-model entries, createSurface fields)
3703
+ * is kept.
3704
+ * - An unbalanced object followed by a line that opens a new operation is
3705
+ * treated the same way.
3706
+ * - The trailing unbalanced object (still streaming, or never closed) is
3707
+ * `partialObject` and yields a partial operation when it has usable data.
3708
+ * - Other text between objects is skipped and reported in `recovered` (and in
3709
+ * `invalidLines`, which predates it).
3710
+ *
3711
+ * `partialLine` is a deprecated alias of `partialObject`.
3712
+ *
3713
+ * @param fenceText - The body of an a2ui fence (`text` of an a2ui
3714
+ * `MarkdownSegment`), complete or still streaming.
3715
+ * @returns `{ operations, partialObject, partialLine, invalidLines, recovered }`.
3716
+ *
3717
+ * @example
3718
+ * ```ts
3719
+ * const { operations } = extractFenceOperations(segment.text);
3720
+ * ```
3721
+ */
3722
+ declare function extractFenceOperations(fenceText: string): {
3723
+ operations: A2UIMarkdownOperation[];
3724
+ partialObject: string | null;
3725
+ partialLine: string | null;
3726
+ invalidLines: string[];
3727
+ recovered: string[];
3728
+ };
3729
+ /**
3730
+ * Normalise a fence's operations for the renderer: drop unknown messages, fill
3731
+ * in `version` and missing `surfaceId`s, keep only the first `createSurface`,
3732
+ * keep its `catalogId` when `catalogIds` lists it (else use `catalogId`), synthesize
3733
+ * `createSurface` when the model omitted it, and report the
3734
+ * surfaceId (the first one found, else `fallbackSurfaceId`).
3735
+ *
3736
+ * `callRendererFunction` operations target no surface. They get no surfaceId,
3737
+ * do not cause a synthesized `createSurface`, and come back in
3738
+ * `functionCalls` (in fence order), never in `operations`.
3739
+ *
3740
+ * @param input.operations - Operations from `extractFenceOperations`.
3741
+ * @param input.fallbackSurfaceId - The surfaceId to use when no operation
3742
+ * names one.
3743
+ * @param input.catalogId - The client catalog. It replaces a catalogId of the
3744
+ * model that `catalogIds` does not list.
3745
+ * @param input.catalogIds - The catalogs that the model can name. Left out,
3746
+ * only `catalogId`.
3747
+ * @returns `{ surfaceId, operations, functionCalls }`.
3748
+ *
3749
+ * @example
3750
+ * ```ts
3751
+ * const { surfaceId, operations, functionCalls } = prepareSurfaceOperations({
3752
+ * operations: extractFenceOperations(segment.text).operations,
3753
+ * fallbackSurfaceId: `${messageId}-${segment.index}`,
3754
+ * catalogId,
3755
+ * });
3756
+ * ```
3757
+ */
3758
+ declare function prepareSurfaceOperations(input: {
3759
+ operations: A2UIMarkdownOperation[];
3760
+ fallbackSurfaceId: string;
3761
+ catalogId: string;
3762
+ catalogIds?: readonly string[];
3763
+ }): {
3764
+ surfaceId: string;
3765
+ operations: A2UIMarkdownOperation[];
3766
+ functionCalls: A2UIMarkdownOperation[];
3767
+ };
3768
+ /**
3769
+ * More ids a component renders, beyond `child`, `children` and the table
3770
+ * cells: the typed child references of its catalog, which can sit at any
3771
+ * depth of its props (the `child` of each entry of `tabs`). The catalog
3772
+ * knows them; the operations alone do not.
3773
+ */
3774
+ type ChildIdsOf = (component: Record<string, unknown>) => string[] | "unknown";
3775
+ /** The options of the walks that follow child ids. */
3776
+ interface ChildWalkOptions {
3777
+ childIds?: ChildIdsOf;
3778
+ }
3779
+ /**
3780
+ * Ids of the `Card` components that are interactive panels: at least one
3781
+ * descendant (via `child`, `children` or table component cells) is a control
3782
+ * (Button, Pressable, Form, TextField, TextArea, Select, CheckBox, Radio,
3783
+ * RadioGroup, Slider, SegmentedControl, DateTimeInput).
3784
+ *
3785
+ * @param components - The components of one surface.
3786
+ * @returns The ids of the interactive cards.
3787
+ *
3788
+ * @example
3789
+ * ```ts
3790
+ * const interactive = classifySurfaceCards(components);
3791
+ * const keepsBox = interactive.has("quote-form");
3792
+ * ```
3793
+ */
3794
+ declare function classifySurfaceCards(components: Record<string, unknown>[], options?: ChildWalkOptions): Set<string>;
3795
+ /**
3796
+ * Markdown mode: only interactive panels keep a box. Every `Card` that is not
3797
+ * an interactive panel (see `classifySurfaceCards`), sets no `variant` or
3798
+ * `border` of its own and is not nested inside an interactive panel becomes
3799
+ * `variant: "section"` (a heading plus content without a box). Operations
3800
+ * other than updateComponents pass through unchanged.
3801
+ *
3802
+ * @param operations - The operations of one surface.
3803
+ * @returns The operations with informational cards set to `variant: "section"`.
3804
+ * When no card changes, it returns the same array.
3805
+ *
3806
+ * @example
3807
+ * ```ts
3808
+ * const operations = flattenInformationalCards(prepared.operations);
3809
+ * ```
3810
+ */
3811
+ declare function flattenInformationalCards(operations: A2UIMarkdownOperation[], options?: ChildWalkOptions): A2UIMarkdownOperation[];
3812
+ /** One block of a segmented surface, in render order. */
3813
+ type SurfaceSegment = {
3814
+ kind: "markdown";
3815
+ markdown: string;
3816
+ } | {
3817
+ kind: "surface";
3818
+ components: Record<string, unknown>[];
3819
+ };
3820
+ /**
3821
+ * Markdown mode: split a surface into markdown and surface segments so that
3822
+ * only real UI renders as A2UI and everything else is the chat's markdown.
3823
+ *
3824
+ * From `root`, descend through single-child vertical containers (Column,
3825
+ * column Box, informational Card) to the first one with several children:
3826
+ * the stack. Its children are partitioned, in order, into runs of prose and
3827
+ * runs of UI. Prose is `Title`, `Text`, `Caption`, `Markdown` with literal
3828
+ * text, a `List` of literal text items, plus `Divider`/`Spacer` next to them:
3829
+ * `Title` → heading by size (sm `####`, md/lg `###`, larger `##`), `Text` →
3830
+ * paragraph (`strong` → `**…**`), `Caption`/`Markdown` → paragraph, `List` →
3831
+ * `- …` (or `1. …` for `marker: "number"`, `**label** — description` for
3832
+ * described items), and a `Divider` between two prose blocks → `---`.
3833
+ *
3834
+ * Not prose: `{path}`-bound text or items, a Text with inline children, a
3835
+ * List with `children`/icons/actions, a template entry, a component with an
3836
+ * `accessibility` envelope, and a child whose component has not streamed
3837
+ * yet. Separators with no text beside them stay in
3838
+ * the surface. An interactive Card (see `classifySurfaceCards`) is never
3839
+ * entered.
3840
+ *
3841
+ * Each prose run becomes a markdown segment; each UI run becomes a surface
3842
+ * segment whose `root` is a copy of the stack (its other props kept, `child`
3843
+ * dropped) with only that run's `children`, followed by every component
3844
+ * reachable from them. When nothing is prose the input comes back as the one
3845
+ * surface segment (same array); when everything is (or `root` itself is),
3846
+ * there are only markdown segments.
3847
+ *
3848
+ * Pure and linear in the number of components, so it runs on every stream
3849
+ * update.
3850
+ *
3851
+ * @param components - The components of one surface, root included.
3852
+ * @returns The segments in render order.
3853
+ *
3854
+ * @example
3855
+ * ```ts
3856
+ * for (const segment of segmentSurfaceProse(components)) {
3857
+ * if (segment.kind === "markdown") renderMarkdown(segment.markdown);
3858
+ * else renderSurface(segment.components);
3859
+ * }
3860
+ * ```
3861
+ */
3862
+ declare function segmentSurfaceProse(components: Record<string, unknown>[], options?: ChildWalkOptions): SurfaceSegment[];
3863
+ //#endregion
3864
+ export { A2UIMarkdownOperation, A2UI_FENCE_LANGUAGE, ActionConfig, ActionCreator, ActionFromCreator, ActionFromCreators, ActionGroupConfig, ActionGroupResult, AgentRegistry, AgentThreadLockedError, AnyAction, ChildIdsOf, ChildWalkOptions, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, type CopilotKitCoreCatalogComponent, CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreContinuationHandoff, CopilotKitCoreErrorCode, CopilotKitCoreFriendsAccess, CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRegisterProxiedAgentParams, type CopilotKitCoreRegisterProxiedAgentResult, type CopilotKitCoreRunAgentParams, type CopilotKitCoreRunToolParams, type CopilotKitCoreRunToolResult, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreStopAgentParams, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, CopilotKitHeaderResolutionError, type CopilotKitHeadersSource, type CopilotKitMessageFilter, CopilotRuntimeTransport, DispatchingEffect, DispatchingEffectOptions, DynamicSuggestionsConfig, Effect, EmptyActionConfig, FrontendTool, FrontendToolHandlerContext, FrontendToolReconnectBehavior, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, InspectorActiveThreadPayload, type InspectorMetadataV1, InspectorStopViewingPayload, InspectorViewThreadPayload, InspectorViewThreadResultPayload, IntelligenceAgent, IntelligenceAgentConfig, type IntelligenceRuntimeInfo, type JsonValue, type LearningConfig, type LegacyLearningConfig, MEMORY_ERROR_REGISTRY, MarkdownSegment, Memory, MemoryChanges, MemoryError, type MemoryErrorCategory, type MemoryErrorCode, type MemoryErrorRegistryEntry, MemoryKind, MemoryRealtimeStatus, MemoryScope, NewMemory, NonDispatchingEffect, NonDispatchingEffectOptions, type OpenThreadRegistration, PropsActionConfig, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgentConfig, Reducer, RunCompletionAware, RunHandler, type RuntimeLicenseStatus, type RuntimeMode, ScopedContext, ScopedProperties, Selector, type StartResult, StateManager, StaticSuggestionsConfig, Store, StoreLifecycleAction, SubscribeToAgentOptions, SubscribeToAgentSubscriber, Suggestion, SuggestionAvailability, SuggestionEngine, SuggestionsConfig, SurfaceSegment, type ThreadEndpointRuntimeInfo, ThreadRunActivityNotification, ToolCallStatus, type TrajectoryStartOptions, WebMCPModelContext, WebMCPRegistry, WebMCPToolAnnotations, WebMCPToolConfig, classifySurfaceCards, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, empty, ensureObjectArgs, extractCompleteArrayItems, extractFenceOperations, extractStringField, flattenInformationalCards, getMarkdownOperationSurfaceId, getWebMCPModelContext, isAbortError, isInspectorThreadBridgeEnabled, isRunCompletionAware, ofType, on, onInspectorActiveThread, onInspectorStopViewing, onInspectorViewThread, onInspectorViewThreadResult, parseToolArguments, prepareSurfaceOperations, props, segmentSurfaceProse, select, splitA2UIMarkdown, ɵCOPILOTKIT_FEATURES, ɵCopilotKitFeature, ɵGenerativeUIDebugFunction, ɵGenerativeUIDebugPromptSection, ɵGenerativeUIDebugRun, ɵGenerativeUIDebugSnapshot, ɵGenerativeUIDebugSource, ɵGenerativeUIDebugSurface, ɵInterruptDecision, ɵInterruptEvent, ɵInterruptState, ɵInterruptToolResult, ɵMAX_SOCKET_RETRIES, ɵMemoryEnvironment, ɵMemoryMetadataEvent, ɵMemoryRuntimeContext, ɵMemoryState, ɵMemoryStore, ɵPendingInterrupt, ɵPhoenixChannelLike, ɵPhoenixChannelOptions, ɵPhoenixChannelSession, ɵPhoenixJoinOutcome, ɵPhoenixPushLike, ɵPhoenixSocketLike, ɵPhoenixSocketOptions, ɵPhoenixSocketSession, ɵPhoenixSocketSignal, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵThread, ɵThreadEnvironment, ɵThreadMetadataEvent, ɵThreadRuntimeContext, ɵThreadSelectors, ɵThreadStore, createMemoryStore as ɵcreateMemoryStore, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵisCopilotKitFeature, ɵisHttpAgent, isRetryableStatus as ɵisRetryableMemoryStatus, ɵjoinPhoenixChannel$, ɵmapMemoryMetadataEvent, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵthreadAdapterEvents, ɵwithHeaderDefaults };
3445
3865
  //# sourceMappingURL=index.d.mts.map