@copilotkit/core 1.79.2-canary.1792172552 → 1.81.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.cts CHANGED
@@ -1,7 +1,7 @@
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
3
  import { CaptureOptions, CollectorOptions, JsonValue, JsonValue as JsonValue$1, StartResult, StartResult as StartResult$1, TrajectoryCaptureOptions } from "@copilotkit/learning";
4
- 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";
4
+ 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";
5
5
  import { Observable, OperatorFunction, Subscription } from "rxjs";
6
6
 
7
7
  //#region src/core/learning-bridge.d.ts
@@ -65,6 +65,8 @@ type FrontendToolHandlerContext = {
65
65
  /**
66
66
  * What a frontend tool does with its own calls that are still unanswered when
67
67
  * a thread's history is restored (a reload, a remount, or a thread switch).
68
+ * Only calls after the latest user message are eligible; older unanswered
69
+ * calls remain historical and never resume work on reconnect.
68
70
  *
69
71
  * - `"passive"` (default) — show the call, but do not run the handler. Nothing
70
72
  * the handler did runs twice.
@@ -110,8 +112,10 @@ type WebMCPToolConfig = {
110
112
  type FrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = {
111
113
  /**
112
114
  * @internal Classifies local execution. Omitted means an ordinary frontend
113
- * tool. Human-in-the-loop handlers are always restored from history replay;
114
- * other tools only with `reconnectBehavior: "resume-pending"`.
115
+ * tool. Pending calls in the latest user turn are eligible for restoration.
116
+ * Human-in-the-loop handlers are restored from history replay;
117
+ * other handlers only with `reconnectBehavior: "resume-pending"`. Tools
118
+ * without a handler restore missing empty completion results automatically.
115
119
  * This field is not sent to the agent as part of the tool schema.
116
120
  */
117
121
  type?: "frontend" | "human-in-the-loop";
@@ -208,12 +212,6 @@ interface ConnectionReplayLifecycle {
208
212
  onReplayStarted?: () => void;
209
213
  onReplayFinished?: () => void;
210
214
  }
211
- /**
212
- * Whether a RUN_ERROR received while connecting is stored history (`replay`)
213
- * or a failure of a run that is happening now (`live`). `unknown` when the
214
- * transport reports no replay boundaries, as with HTTP `/connect`.
215
- */
216
- type RunErrorPhase = "replay" | "live" | "unknown";
217
215
  //#endregion
218
216
  //#region src/core/message-filter.d.ts
219
217
  /**
@@ -995,18 +993,28 @@ declare class RunHandler {
995
993
  */
996
994
  private _warnedMissingToolParameters;
997
995
  /**
998
- * Tracks whether the current run (including in-flight tool execution)
999
- * has been aborted via `stopAgent()` or `agent.abortRun()`. Created
1000
- * fresh in `runAgent()`, aborted by `abortCurrentRun()`.
996
+ * Abort controllers of each agent's in-flight run chains (a run plus its
997
+ * recursive follow-ups), recording whether a chain, including its tool
998
+ * execution, was aborted via `stopAgent()` or `agent.abortRun()`. Every run
999
+ * that is not a follow-up gets a fresh controller, so a run started after
1000
+ * Stop is not born aborted while the stopped chain is still settling. Keyed
1001
+ * by agent so that stopping one agent never cancels another agent's run on
1002
+ * the same core.
1001
1003
  */
1002
- private _runAbortController;
1004
+ private _runAbortControllers;
1003
1005
  /**
1004
- * Tracks recursive `runAgent` depth so that the abort controller and
1005
- * `agent.abortRun()` intercept are only set up / torn down at the
1006
- * top-level call, not on follow-up recursive calls from
1007
- * `processAgentResult`.
1006
+ * Per-agent `runAgent` depth (in-flight runs plus their recursive
1007
+ * follow-ups), so that the `agent.abortRun()` intercept is installed while
1008
+ * any of the agent's runs is in flight and removed once none is, and so
1009
+ * that runaway follow-up chains trip `MAX_FOLLOW_UP_DEPTH`.
1008
1010
  */
1009
- private _runDepth;
1011
+ private _runDepths;
1012
+ /**
1013
+ * Each agent's own `abortRun`, saved while RunHandler's intercept is
1014
+ * installed. Restored only once none of the agent's runs is in flight, so an
1015
+ * overlapping run keeps the intercept after an earlier run finishes.
1016
+ */
1017
+ private _originalAbortRuns;
1010
1018
  /**
1011
1019
  * Keeps tools that opt in via `webmcp` registered on the page's WebMCP model
1012
1020
  * context (`document.modelContext`), in addition to the normal agent
@@ -1044,6 +1052,9 @@ declare class RunHandler {
1044
1052
  * not start a follow-up run.
1045
1053
  */
1046
1054
  abortCurrentRun(agent: AbstractAgent): void;
1055
+ private abortAgentRuns;
1056
+ /** Signal of the agent's most recently started in-flight run, if any. */
1057
+ private latestRunSignal;
1047
1058
  /**
1048
1059
  * Typed access to CopilotKitCore's internal ("friend") methods.
1049
1060
  * Centralises the single unavoidable cast so call-sites stay clean.
@@ -1136,11 +1147,22 @@ declare class RunHandler {
1136
1147
  forwardedProps,
1137
1148
  resume,
1138
1149
  runId
1139
- }: CopilotKitCoreRunAgentParams, continuationHandoff?: CopilotKitCoreContinuationHandoff): Promise<RunAgentResult>;
1150
+ }: CopilotKitCoreRunAgentParams, continuationHandoff?: CopilotKitCoreContinuationHandoff,
1151
+ /**
1152
+ * Set only by `processAgentResult` for a recursive follow-up: the
1153
+ * controller of the run being followed up, which the follow-up shares.
1154
+ */
1155
+
1156
+ followUpOf?: AbortController): Promise<RunAgentResult>;
1140
1157
  /**
1141
1158
  * Process agent result and execute tools
1142
1159
  */
1143
1160
  private processAgentResult;
1161
+ /** A later user message supersedes pending work from an older turn. */
1162
+ private isInLatestUserTurn;
1163
+ /** Locate a missing result before saved results for later calls in its batch. */
1164
+ private toolResultInsertionIndex;
1165
+ /** Identify transport placeholders that must not count as completed answers. */
1144
1166
  private isFrontendPlaceholderResult;
1145
1167
  /**
1146
1168
  * Shared handler execution logic used by executeSpecificTool, executeWildcardTool, and runTool.
@@ -1651,6 +1673,78 @@ declare const ɵMAX_SOCKET_RETRIES = 5;
1651
1673
  */
1652
1674
  declare const ɵTHREAD_REQUEST_TIMEOUT_MS = 15000;
1653
1675
  //#endregion
1676
+ //#region src/core/generative-ui-debug.d.ts
1677
+ /** @internal One declared function of the generative UI, for the inspector. */
1678
+ interface ɵGenerativeUIDebugFunction {
1679
+ description?: string;
1680
+ parameters: GenerativeUIJSONSchema;
1681
+ /** How many `useGenerativeUIFunction` handlers are mounted. Only 1 is valid. */
1682
+ handlers: number;
1683
+ }
1684
+ /** @internal One surface that the browser holds, for the inspector. */
1685
+ interface ɵGenerativeUIDebugSurface {
1686
+ surfaceId: string;
1687
+ threadId: string;
1688
+ agentId: string | undefined;
1689
+ target: string;
1690
+ status: GenerativeUISurfaceStatus;
1691
+ /** The committed operations, in order. The browser can still reject some. */
1692
+ operations: readonly A2UIOperation[];
1693
+ /** The current data model. */
1694
+ dataModel: unknown;
1695
+ /** The values that the user wrote, by path. Agent writes to them are ignored. */
1696
+ userValues: Record<string, unknown>;
1697
+ rejected: Array<GenerativeUIRejectedOperation & {
1698
+ source: "runtime" | "browser";
1699
+ }>;
1700
+ }
1701
+ /** @internal One part of the text that a run adds to the prompt of the model. */
1702
+ interface ɵGenerativeUIDebugPromptSection {
1703
+ title: string;
1704
+ /** Who adds the text to the prompt. */
1705
+ source: "runtime" | "context" | "backend";
1706
+ text: string;
1707
+ }
1708
+ /** @internal What one run sends, or what the next run will send. */
1709
+ interface ɵGenerativeUIDebugRun {
1710
+ agentId: string | undefined;
1711
+ threadId: string | undefined;
1712
+ /** When the run started. Left out for the next run. */
1713
+ startedAt?: number;
1714
+ /** `forwardedProps.copilotkit.ui` of the run. */
1715
+ envelope: CopilotKitUIEnvelope;
1716
+ prompt: ɵGenerativeUIDebugPromptSection[];
1717
+ }
1718
+ /** @internal The state of a generative UI, for the inspector. */
1719
+ interface ɵGenerativeUIDebugSnapshot {
1720
+ catalogId: string;
1721
+ transport: "tool" | "markdown";
1722
+ /** The agents that get the generative UI. Left out: every agent. */
1723
+ agentIds?: string[];
1724
+ components: Record<string, GenerativeUIComponentManifest>;
1725
+ /** The id of the catalog that declared each component, by name. */
1726
+ componentCatalogs: Record<string, string>;
1727
+ functions: Record<string, ɵGenerativeUIDebugFunction>;
1728
+ /** The app state that bound props read, by key. */
1729
+ state: Record<string, unknown>;
1730
+ /** The chat first, then each mounted `<GenerativeUISurface>`. */
1731
+ targets: GenerativeUITarget[];
1732
+ activeThreadId: string | undefined;
1733
+ surfaces: ɵGenerativeUIDebugSurface[];
1734
+ lastRun: ɵGenerativeUIDebugRun | undefined;
1735
+ nextRun: ɵGenerativeUIDebugRun;
1736
+ }
1737
+ /**
1738
+ * @internal What a framework package (react-core) gives core, so that the
1739
+ * inspector can show its generative UI. `getSnapshot` builds the snapshot
1740
+ * when it is called, so a source that nobody reads costs nothing.
1741
+ */
1742
+ interface ɵGenerativeUIDebugSource {
1743
+ getSnapshot(): ɵGenerativeUIDebugSnapshot;
1744
+ /** Calls `listener` when the snapshot changes. Returns the unsubscribe. */
1745
+ subscribe(listener: () => void): () => void;
1746
+ }
1747
+ //#endregion
1654
1748
  //#region src/memory-errors.d.ts
1655
1749
  /**
1656
1750
  * Memory error registry — stable codes for the errors the memory store throws.
@@ -2069,6 +2163,16 @@ declare class CopilotKitHeaderResolutionError extends Error {
2069
2163
  declare function ɵwithHeaderDefaults(source: CopilotKitHeadersSource, defaults: Record<string, string>): CopilotKitHeadersSource;
2070
2164
  //#endregion
2071
2165
  //#region src/core/core.d.ts
2166
+ /**
2167
+ * Run properties that go only to the runs of some agents.
2168
+ * See `CopilotKitCore.addScopedProperties`.
2169
+ */
2170
+ interface ScopedProperties {
2171
+ /** The properties to merge on top of the base run properties. */
2172
+ properties: Record<string, unknown>;
2173
+ /** The agents that get these properties. When omitted, every agent gets them. */
2174
+ agentIds?: string[];
2175
+ }
2072
2176
  /** Configuration options for `CopilotKitCore`. */
2073
2177
  interface CopilotKitCoreConfig {
2074
2178
  /** The endpoint of the CopilotRuntime. */
@@ -2130,12 +2234,6 @@ declare enum CopilotKitCoreErrorCode {
2130
2234
  AGENT_CONNECT_FAILED = "agent_connect_failed",
2131
2235
  AGENT_RUN_FAILED = "agent_run_failed",
2132
2236
  AGENT_RUN_FAILED_EVENT = "agent_run_failed_event",
2133
- /**
2134
- * An agent emitted RUN_ERROR. `context.phase` (`RunErrorPhase`) is
2135
- * `"replay"` when the error belongs to stored thread history replayed on
2136
- * connect, `"live"` when the run is happening now, and `"unknown"` when the
2137
- * transport cannot tell. Show a live-failure notice only for `"live"`.
2138
- */
2139
2237
  AGENT_RUN_ERROR_EVENT = "agent_run_error_event",
2140
2238
  TOOL_ARGUMENT_PARSE_FAILED = "tool_argument_parse_failed",
2141
2239
  TOOL_HANDLER_FAILED = "tool_handler_failed",
@@ -2361,6 +2459,7 @@ interface CopilotKitCoreFriendsAccess {
2361
2459
  readonly debug?: DebugConfig;
2362
2460
  buildFrontendTools(agentId?: string): _ag_ui_client0.Tool[];
2363
2461
  getContextForAgent(agentId?: string): Context[];
2462
+ getPropertiesForAgent(agentId?: string): Record<string, unknown>;
2364
2463
  getAgent(id: string): AbstractAgent | undefined;
2365
2464
  /**
2366
2465
  * Re-apply the last resolved header snapshot to a single agent, merged on
@@ -2399,6 +2498,7 @@ declare class CopilotKitCore {
2399
2498
  private _credentials?;
2400
2499
  private _messageFilter?;
2401
2500
  private _properties;
2501
+ private _scopedProperties;
2402
2502
  private _defaultThrottleMs?;
2403
2503
  private _debug?;
2404
2504
  private subscribers;
@@ -2411,6 +2511,8 @@ declare class CopilotKitCore {
2411
2511
  private learningBridge;
2412
2512
  private notifiedTrajectoryId;
2413
2513
  private readonly learningConfiguredListeners;
2514
+ private _generativeUIDebugSource;
2515
+ private readonly generativeUIDebugListeners;
2414
2516
  /**
2415
2517
  * The single core-owned memory store, created lazily on first
2416
2518
  * `getMemoryStore()` and kept user-scoped for the lifetime of the core.
@@ -2584,6 +2686,37 @@ declare class CopilotKitCore {
2584
2686
  * to sending the full thread.
2585
2687
  */
2586
2688
  setMessageFilter(messageFilter: CopilotKitMessageFilter | undefined): void;
2689
+ /**
2690
+ * Add run properties that go only to the runs of `agentIds`. When
2691
+ * `agentIds` is omitted, every agent gets them. They merge on top of the
2692
+ * base `properties`.
2693
+ *
2694
+ * When an entry value and the existing value under the same key are both
2695
+ * plain objects, their keys merge one level deep. So several entries can
2696
+ * add keys under one namespace (for example `copilotkit`).
2697
+ *
2698
+ * @param entry - The properties and the optional agent ids.
2699
+ * @returns The id to pass to `removeScopedProperties`.
2700
+ *
2701
+ * @example
2702
+ * const id = copilotkit.addScopedProperties({
2703
+ * properties: { copilotkit: { theme: "dark" } },
2704
+ * agentIds: ["research"],
2705
+ * });
2706
+ * copilotkit.removeScopedProperties(id);
2707
+ */
2708
+ addScopedProperties({
2709
+ properties,
2710
+ agentIds
2711
+ }: ScopedProperties): string;
2712
+ /** Remove an entry that `addScopedProperties` added. An unknown id does nothing. */
2713
+ removeScopedProperties(id: string): void;
2714
+ /**
2715
+ * Build the forwarded properties for a run of the given agent: the base
2716
+ * properties plus every scoped entry that matches the agent. An entry with
2717
+ * `agentIds` does not match when `agentId` is omitted.
2718
+ */
2719
+ getPropertiesForAgent(agentId?: string): Record<string, unknown>;
2587
2720
  setProperties(properties: Record<string, unknown>): void;
2588
2721
  /**
2589
2722
  * Agent management (delegated to AgentRegistry)
@@ -2619,8 +2752,24 @@ declare class CopilotKitCore {
2619
2752
  * it does not change with capture start, connection failures or reconnects.
2620
2753
  */
2621
2754
  get ɵlearningConfigured(): boolean;
2755
+ /**
2756
+ * @internal Whether captured events may carry agent message text: false
2757
+ * without a `learning` config, or when a custom sink sets
2758
+ * `capture.agentText` to false. A running custom-sink capture keeps the
2759
+ * choice it started with.
2760
+ */
2761
+ get ɵlearningCapturesAgentText(): boolean;
2622
2762
  /** @internal Calls `listener` when {@link ɵlearningConfigured} changes. */
2623
2763
  ɵsubscribeToLearningConfigured(listener: () => void): () => void;
2764
+ /**
2765
+ * @internal The generative UI of the framework package, for the inspector.
2766
+ * `undefined` when no provider has a `generativeUI` config.
2767
+ */
2768
+ get ɵgenerativeUIDebugSource(): ɵGenerativeUIDebugSource | undefined;
2769
+ /** @internal Set by the framework package. `undefined` removes it. */
2770
+ ɵsetGenerativeUIDebugSource(source: ɵGenerativeUIDebugSource | undefined): void;
2771
+ /** @internal Calls `listener` when {@link ɵgenerativeUIDebugSource} is set or removed. */
2772
+ ɵsubscribeToGenerativeUIDebugSource(listener: () => void): () => void;
2624
2773
  /** The active capture's Trajectory ID, or null while capture is stopped. */
2625
2774
  get trajectoryId(): string | null;
2626
2775
  private notifyTrajectoryChanged;
@@ -2998,17 +3147,6 @@ interface IntelligenceAgentSharedState {
2998
3147
  declare class AgentThreadLockedError extends Error {
2999
3148
  constructor(threadId?: string);
3000
3149
  }
3001
- /**
3002
- * The gateway could not replay a live run's events, so the client cannot
3003
- * verify the run it is following. The run itself may still be going on the
3004
- * server; reconnecting to the thread shows its real state.
3005
- */
3006
- declare class IntelligenceReplayFailedError extends Error {
3007
- readonly threadId: string;
3008
- readonly runId: string | null;
3009
- readonly code = "INTELLIGENCE_REPLAY_FAILED";
3010
- constructor(threadId: string, runId: string | null);
3011
- }
3012
3150
  /**
3013
3151
  * Typed contract for agents that expose the completion promise of their
3014
3152
  * currently in-flight run.
@@ -3429,5 +3567,288 @@ declare function onInspectorStopViewing(handler: (payload: InspectorStopViewingP
3429
3567
  declare function onInspectorActiveThread(handler: (payload: InspectorActiveThreadPayload) => void): () => void;
3430
3568
  declare function onInspectorViewThreadResult(handler: (payload: InspectorViewThreadResultPayload) => void): () => void;
3431
3569
  //#endregion
3432
- 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, IntelligenceReplayFailedError, 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, type RunErrorPhase, 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 };
3570
+ //#region src/a2ui-markdown/fence-parser.d.ts
3571
+ /** Language of a fenced code block that carries A2UI operations. */
3572
+ declare const A2UI_FENCE_LANGUAGE = "a2ui";
3573
+ /**
3574
+ * One part of an assistant message, in source order: prose markdown, or the
3575
+ * body of a top-level ```a2ui fence. `target` is the id from a
3576
+ * `target=<id>` token in the fence info string. With no target, the surface
3577
+ * goes to the chat.
3578
+ */
3579
+ type MarkdownSegment = {
3580
+ type: "markdown";
3581
+ text: string;
3582
+ } | {
3583
+ type: "a2ui";
3584
+ index: number;
3585
+ text: string;
3586
+ closed: boolean;
3587
+ target?: string;
3588
+ };
3589
+ /**
3590
+ * Split a (possibly still streaming) markdown string into prose segments and
3591
+ * top-level ```a2ui fences. Fences of other languages stay inside prose
3592
+ * segments byte-for-byte, and a2ui markers inside them are ignored. Only
3593
+ * column-0 fences are recognised, so a fence indented inside a list item is
3594
+ * left to the markdown renderer.
3595
+ *
3596
+ * The first info-string token must be exactly `a2ui`. A later
3597
+ * `target=<id>` token sets `target` on the segment (for example
3598
+ * ```` ```a2ui target=recommendations ````). Other tokens are ignored.
3599
+ *
3600
+ * An a2ui segment's `text` is the fence body. For a closed fence it ends with
3601
+ * "\n" when non-empty. For an open (still streaming or aborted) fence it is
3602
+ * everything after the opener line, minus a half-streamed closing marker.
3603
+ *
3604
+ * @param markdown - The assistant message text, complete or still streaming.
3605
+ * @returns The segments in source order.
3606
+ *
3607
+ * @example
3608
+ * ```ts
3609
+ * for (const segment of splitA2UIMarkdown(message.content)) {
3610
+ * if (segment.type === "a2ui") renderSurface(segment.text, segment.target);
3611
+ * else renderMarkdown(segment.text);
3612
+ * }
3613
+ * ```
3614
+ */
3615
+ declare function splitA2UIMarkdown(markdown: string): MarkdownSegment[];
3616
+ //#endregion
3617
+ //#region src/a2ui-markdown/operations.d.ts
3618
+ /**
3619
+ * An A2UI v1.0 message as the model wrote it in an a2ui fence: an object that
3620
+ * carries one of createSurface, updateComponents, updateDataModel,
3621
+ * deleteSurface or callRendererFunction. The shape is not checked yet.
3622
+ * Validate it (for example with `validateOperation` from `@copilotkit/shared`)
3623
+ * before it reaches a surface or runs a function.
3624
+ *
3625
+ * It is named `A2UIMarkdownOperation` because `@copilotkit/shared` already
3626
+ * exports the strict `A2UIOperation` type.
3627
+ */
3628
+ type A2UIMarkdownOperation = Record<string, unknown>;
3629
+ /**
3630
+ * Read `"key":"value"` from partial JSON. The first match anywhere in the
3631
+ * text wins, at any depth.
3632
+ *
3633
+ * @param partialJson - JSON text that can still be streaming.
3634
+ * @param key - The field name.
3635
+ * @returns The string value, or null until its closing quote has arrived.
3636
+ *
3637
+ * @example
3638
+ * ```ts
3639
+ * extractStringField('{"createSurface":{"surfaceId":"plan","cat', "surfaceId"); // "plan"
3640
+ * ```
3641
+ */
3642
+ declare function extractStringField(partialJson: string, key: string): string | null;
3643
+ /**
3644
+ * Find `"key":[` in partial JSON and return every complete item of that array
3645
+ * so far, plus whether the array has closed. Items of a `components` array get
3646
+ * structural-key depth repair: a component that lost closing braces is fixed
3647
+ * when its `id`, `component`, `child` or `children` key shows where it ends.
3648
+ *
3649
+ * @param partialJson - JSON text that can still be streaming.
3650
+ * @param key - The name of the array field.
3651
+ * @returns `{ items, closed }`, or null when the key (with an array value)
3652
+ * has not appeared yet.
3653
+ *
3654
+ * @example
3655
+ * ```ts
3656
+ * const result = extractCompleteArrayItems(streamedText, "components");
3657
+ * if (result) render(result.items);
3658
+ * ```
3659
+ */
3660
+ declare function extractCompleteArrayItems(partialJson: string, key: string): {
3661
+ items: unknown[];
3662
+ closed: boolean;
3663
+ } | null;
3664
+ /**
3665
+ * The surfaceId an operation targets: the one nested under its operation key,
3666
+ * else a top-level `surfaceId`. A `callRendererFunction` operation targets no
3667
+ * surface, so it gets undefined.
3668
+ *
3669
+ * It is named `getMarkdownOperationSurfaceId` because `@copilotkit/shared`
3670
+ * already exports a strict `getOperationSurfaceId`. This one also reads a
3671
+ * top-level `surfaceId`, which models sometimes write.
3672
+ *
3673
+ * @param op - An operation from an a2ui fence.
3674
+ * @returns The surfaceId, or undefined when the operation names none or is a
3675
+ * function call.
3676
+ *
3677
+ * @example
3678
+ * ```ts
3679
+ * getMarkdownOperationSurfaceId({ updateDataModel: { surfaceId: "plan" } }); // "plan"
3680
+ * ```
3681
+ */
3682
+ declare function getMarkdownOperationSurfaceId(op: A2UIMarkdownOperation): string | undefined;
3683
+ /**
3684
+ * Parse the body of an a2ui fence as a stream of top-level JSON values, so
3685
+ * operations may be one per line (the documented format), several per line,
3686
+ * pretty-printed over many lines, or wrapped in a top-level array (which is
3687
+ * flattened). Whitespace and commas between objects are ignored.
3688
+ *
3689
+ * - A balanced object is `JSON.parse`d. When that fails (e.g. a stray quote),
3690
+ * its raw text goes to `invalidLines` and whatever `partialOperation` can
3691
+ * salvage (complete components, data-model entries, createSurface fields)
3692
+ * is kept.
3693
+ * - An unbalanced object followed by a line that opens a new operation is
3694
+ * treated the same way.
3695
+ * - The trailing unbalanced object (still streaming, or never closed) is
3696
+ * `partialObject` and yields a partial operation when it has usable data.
3697
+ * - Other text between objects is skipped and reported in `recovered` (and in
3698
+ * `invalidLines`, which predates it).
3699
+ *
3700
+ * `partialLine` is a deprecated alias of `partialObject`.
3701
+ *
3702
+ * @param fenceText - The body of an a2ui fence (`text` of an a2ui
3703
+ * `MarkdownSegment`), complete or still streaming.
3704
+ * @returns `{ operations, partialObject, partialLine, invalidLines, recovered }`.
3705
+ *
3706
+ * @example
3707
+ * ```ts
3708
+ * const { operations } = extractFenceOperations(segment.text);
3709
+ * ```
3710
+ */
3711
+ declare function extractFenceOperations(fenceText: string): {
3712
+ operations: A2UIMarkdownOperation[];
3713
+ partialObject: string | null;
3714
+ partialLine: string | null;
3715
+ invalidLines: string[];
3716
+ recovered: string[];
3717
+ };
3718
+ /**
3719
+ * Normalise a fence's operations for the renderer: drop unknown messages, fill
3720
+ * in `version` and missing `surfaceId`s, keep only the first `createSurface`,
3721
+ * keep its `catalogId` when `catalogIds` lists it (else use `catalogId`), synthesize
3722
+ * `createSurface` when the model omitted it, and report the
3723
+ * surfaceId (the first one found, else `fallbackSurfaceId`).
3724
+ *
3725
+ * `callRendererFunction` operations target no surface. They get no surfaceId,
3726
+ * do not cause a synthesized `createSurface`, and come back in
3727
+ * `functionCalls` (in fence order), never in `operations`.
3728
+ *
3729
+ * @param input.operations - Operations from `extractFenceOperations`.
3730
+ * @param input.fallbackSurfaceId - The surfaceId to use when no operation
3731
+ * names one.
3732
+ * @param input.catalogId - The client catalog. It replaces a catalogId of the
3733
+ * model that `catalogIds` does not list.
3734
+ * @param input.catalogIds - The catalogs that the model can name. Left out,
3735
+ * only `catalogId`.
3736
+ * @returns `{ surfaceId, operations, functionCalls }`.
3737
+ *
3738
+ * @example
3739
+ * ```ts
3740
+ * const { surfaceId, operations, functionCalls } = prepareSurfaceOperations({
3741
+ * operations: extractFenceOperations(segment.text).operations,
3742
+ * fallbackSurfaceId: `${messageId}-${segment.index}`,
3743
+ * catalogId,
3744
+ * });
3745
+ * ```
3746
+ */
3747
+ declare function prepareSurfaceOperations(input: {
3748
+ operations: A2UIMarkdownOperation[];
3749
+ fallbackSurfaceId: string;
3750
+ catalogId: string;
3751
+ catalogIds?: readonly string[];
3752
+ }): {
3753
+ surfaceId: string;
3754
+ operations: A2UIMarkdownOperation[];
3755
+ functionCalls: A2UIMarkdownOperation[];
3756
+ };
3757
+ /**
3758
+ * More ids a component renders, beyond `child`, `children` and the table
3759
+ * cells: the typed child references of its catalog, which can sit at any
3760
+ * depth of its props (the `child` of each entry of `tabs`). The catalog
3761
+ * knows them; the operations alone do not.
3762
+ */
3763
+ type ChildIdsOf = (component: Record<string, unknown>) => string[] | "unknown";
3764
+ /** The options of the walks that follow child ids. */
3765
+ interface ChildWalkOptions {
3766
+ childIds?: ChildIdsOf;
3767
+ }
3768
+ /**
3769
+ * Ids of the `Card` components that are interactive panels: at least one
3770
+ * descendant (via `child`, `children` or table component cells) is a control
3771
+ * (Button, Pressable, Form, TextField, TextArea, Select, CheckBox, Radio,
3772
+ * RadioGroup, Slider, SegmentedControl, DateTimeInput).
3773
+ *
3774
+ * @param components - The components of one surface.
3775
+ * @returns The ids of the interactive cards.
3776
+ *
3777
+ * @example
3778
+ * ```ts
3779
+ * const interactive = classifySurfaceCards(components);
3780
+ * const keepsBox = interactive.has("quote-form");
3781
+ * ```
3782
+ */
3783
+ declare function classifySurfaceCards(components: Record<string, unknown>[], options?: ChildWalkOptions): Set<string>;
3784
+ /**
3785
+ * Markdown mode: only interactive panels keep a box. Every `Card` that is not
3786
+ * an interactive panel (see `classifySurfaceCards`), sets no `variant` or
3787
+ * `border` of its own and is not nested inside an interactive panel becomes
3788
+ * `variant: "section"` (a heading plus content without a box). Operations
3789
+ * other than updateComponents pass through unchanged.
3790
+ *
3791
+ * @param operations - The operations of one surface.
3792
+ * @returns The operations with informational cards set to `variant: "section"`.
3793
+ * When no card changes, it returns the same array.
3794
+ *
3795
+ * @example
3796
+ * ```ts
3797
+ * const operations = flattenInformationalCards(prepared.operations);
3798
+ * ```
3799
+ */
3800
+ declare function flattenInformationalCards(operations: A2UIMarkdownOperation[], options?: ChildWalkOptions): A2UIMarkdownOperation[];
3801
+ /** One block of a segmented surface, in render order. */
3802
+ type SurfaceSegment = {
3803
+ kind: "markdown";
3804
+ markdown: string;
3805
+ } | {
3806
+ kind: "surface";
3807
+ components: Record<string, unknown>[];
3808
+ };
3809
+ /**
3810
+ * Markdown mode: split a surface into markdown and surface segments so that
3811
+ * only real UI renders as A2UI and everything else is the chat's markdown.
3812
+ *
3813
+ * From `root`, descend through single-child vertical containers (Column,
3814
+ * column Box, informational Card) to the first one with several children:
3815
+ * the stack. Its children are partitioned, in order, into runs of prose and
3816
+ * runs of UI. Prose is `Title`, `Text`, `Caption`, `Markdown` with literal
3817
+ * text, a `List` of literal text items, plus `Divider`/`Spacer` next to them:
3818
+ * `Title` → heading by size (sm `####`, md/lg `###`, larger `##`), `Text` →
3819
+ * paragraph (`strong` → `**…**`), `Caption`/`Markdown` → paragraph, `List` →
3820
+ * `- …` (or `1. …` for `marker: "number"`, `**label** — description` for
3821
+ * described items), and a `Divider` between two prose blocks → `---`.
3822
+ *
3823
+ * Not prose: `{path}`-bound text or items, a Text with inline children, a
3824
+ * List with `children`/icons/actions, a template entry, a component with an
3825
+ * `accessibility` envelope, and a child whose component has not streamed
3826
+ * yet. Separators with no text beside them stay in
3827
+ * the surface. An interactive Card (see `classifySurfaceCards`) is never
3828
+ * entered.
3829
+ *
3830
+ * Each prose run becomes a markdown segment; each UI run becomes a surface
3831
+ * segment whose `root` is a copy of the stack (its other props kept, `child`
3832
+ * dropped) with only that run's `children`, followed by every component
3833
+ * reachable from them. When nothing is prose the input comes back as the one
3834
+ * surface segment (same array); when everything is (or `root` itself is),
3835
+ * there are only markdown segments.
3836
+ *
3837
+ * Pure and linear in the number of components, so it runs on every stream
3838
+ * update.
3839
+ *
3840
+ * @param components - The components of one surface, root included.
3841
+ * @returns The segments in render order.
3842
+ *
3843
+ * @example
3844
+ * ```ts
3845
+ * for (const segment of segmentSurfaceProse(components)) {
3846
+ * if (segment.kind === "markdown") renderMarkdown(segment.markdown);
3847
+ * else renderSurface(segment.components);
3848
+ * }
3849
+ * ```
3850
+ */
3851
+ declare function segmentSurfaceProse(components: Record<string, unknown>[], options?: ChildWalkOptions): SurfaceSegment[];
3852
+ //#endregion
3853
+ 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 };
3433
3854
  //# sourceMappingURL=index.d.cts.map