@copilotkit/core 2.0.0-rc.5 → 2.0.0-rc.50

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.
Files changed (47) hide show
  1. package/dist/a2ui-markdown-BxZr1mEU.mjs +1360 -0
  2. package/dist/a2ui-markdown-BxZr1mEU.mjs.map +1 -0
  3. package/dist/a2ui-markdown-DkMXFQih.cjs +1419 -0
  4. package/dist/a2ui-markdown-DkMXFQih.cjs.map +1 -0
  5. package/dist/chat-configuration.cjs +269 -0
  6. package/dist/chat-configuration.cjs.map +1 -0
  7. package/dist/chat-configuration.d.cts +123 -0
  8. package/dist/chat-configuration.d.cts.map +1 -0
  9. package/dist/chat-configuration.d.mts +123 -0
  10. package/dist/chat-configuration.d.mts.map +1 -0
  11. package/dist/chat-configuration.mjs +268 -0
  12. package/dist/chat-configuration.mjs.map +1 -0
  13. package/dist/generative-ui/index.cjs +3786 -0
  14. package/dist/generative-ui/index.cjs.map +1 -0
  15. package/dist/generative-ui/index.d.cts +1139 -0
  16. package/dist/generative-ui/index.d.cts.map +1 -0
  17. package/dist/generative-ui/index.d.mts +1139 -0
  18. package/dist/generative-ui/index.d.mts.map +1 -0
  19. package/dist/generative-ui/index.mjs +3737 -0
  20. package/dist/generative-ui/index.mjs.map +1 -0
  21. package/dist/index.cjs +10227 -2255
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +3 -3908
  24. package/dist/index.d.mts +3 -3908
  25. package/dist/index.mjs +9973 -2246
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/index.umd.js +13753 -2220
  28. package/dist/index.umd.js.map +1 -1
  29. package/dist/learning-bridge-DEVwyO7F.d.cts +10553 -0
  30. package/dist/learning-bridge-DEVwyO7F.d.cts.map +1 -0
  31. package/dist/learning-bridge-DZOhtLs1.d.mts +10553 -0
  32. package/dist/learning-bridge-DZOhtLs1.d.mts.map +1 -0
  33. package/dist/styles.cjs +1 -1
  34. package/dist/styles.cjs.map +1 -1
  35. package/dist/styles.css +1 -1
  36. package/dist/styles.mjs +1 -1
  37. package/dist/styles.mjs.map +1 -1
  38. package/dist/viewport-CksL5y8p.mjs +954 -0
  39. package/dist/viewport-CksL5y8p.mjs.map +1 -0
  40. package/dist/viewport-D-tuKCeb.cjs +1182 -0
  41. package/dist/viewport-D-tuKCeb.cjs.map +1 -0
  42. package/package.json +35 -8
  43. package/stryker.config.mjs +6 -0
  44. package/tsdown.config.ts +12 -2
  45. package/vitest.mutation.config.mjs +6 -0
  46. package/dist/index.d.cts.map +0 -1
  47. package/dist/index.d.mts.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,3908 +1,3 @@
1
- import * as _ag_ui_client0 from "@ag-ui/client";
2
- import { AbstractAgent, AgentCapabilities, AgentSubscriber, BaseEvent, Context, HttpAgent, HttpAgentConfig, Interrupt, Message, ResumeEntry, RunAgentInput, RunAgentParameters, RunAgentResult, State, Tool, ToolCall } from "@ag-ui/client";
3
- import { CaptureOptions, CollectorOptions, JsonValue, JsonValue as JsonValue$1, StartResult, StartResult as StartResult$1, TrajectoryCaptureOptions } from "@copilotkit/learning";
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
- import { Observable, OperatorFunction, Subscription } from "rxjs";
6
- import { Token, Tokens, TokensList } from "marked";
7
-
8
- //#region src/core/learning-bridge.d.ts
9
- /** Interaction capture settings for {@link CopilotKitCore}. See `@copilotkit/learning`. */
10
- interface LegacyLearningConfig extends Omit<CollectorOptions, "enrich" | "capture"> {
11
- /** Capture modules, plus `agentText: false` to omit message text (included in full by default). */
12
- capture?: CaptureOptions & {
13
- agentText?: boolean;
14
- };
15
- }
16
- type LearningConfig = LegacyLearningConfig | (TrajectoryCaptureOptions & {
17
- sink?: undefined;
18
- });
19
- type TrajectoryStartOptions = {
20
- trajectoryId?: string;
21
- /**
22
- * Used only by explicit custom sinks. Authenticated capture warns and ignores
23
- * this option; assign Learning Spaces on the server with
24
- * `getTrajectoryLearningContainerIds` on `CopilotKitIntelligence`.
25
- */
26
- learningContainerIds?: string[];
27
- };
28
- /** Returned by {@link CopilotKitCore.registerOpenThread}. */
29
- interface OpenThreadRegistration {
30
- /** The view now shows another Thread. */
31
- update(threadId: string): void;
32
- /** The view that showed this Thread is gone. */
33
- unregister(): void;
34
- }
35
- //#endregion
36
- //#region src/types.d.ts
37
- /**
38
- * Status of a tool call execution
39
- */
40
- declare enum ToolCallStatus {
41
- InProgress = "inProgress",
42
- Executing = "executing",
43
- Complete = "complete"
44
- }
45
- type CopilotRuntimeTransport = "rest" | "single" | "auto";
46
- /**
47
- * Context passed to a frontend tool handler
48
- */
49
- type FrontendToolHandlerContext = {
50
- toolCall: ToolCall;
51
- /**
52
- * The agent that invoked the tool. Absent when the tool is invoked through
53
- * the WebMCP browser API (`document.modelContext`), which has no agent.
54
- */
55
- agent?: AbstractAgent;
56
- /** Aborted when `stopAgent()` is called. Handlers can check `signal.aborted`
57
- * or pass the signal to fetch/setTimeout to cooperatively cancel. */
58
- signal?: AbortSignal;
59
- /**
60
- * True when CopilotKit runs this call while restoring a thread's history on
61
- * connect, for a call that a previous page or client left without a result.
62
- * Absent for a call made by a live run. See `reconnectBehavior`.
63
- */
64
- isReplay?: boolean;
65
- };
66
- /**
67
- * What a frontend tool does with its own calls that are still unanswered when
68
- * a thread's history is restored (a reload, a remount, or a thread switch).
69
- * Only calls after the latest user message are eligible; older unanswered
70
- * calls remain historical and never resume work on reconnect.
71
- *
72
- * - `"passive"` (default) — show the call, but do not run the handler. Nothing
73
- * the handler did runs twice.
74
- * - `"resume-pending"` — run the handler for each call that has no result,
75
- * with `isReplay: true` in its context, then continue the run as usual
76
- * (follow-up included, unless `followUp` is false).
77
- *
78
- * Use `"resume-pending"` only for a handler that is safe to run more than
79
- * once. A call does not start twice at the same time in one CopilotKit
80
- * instance, but it can run again after a stop or a thread switch if its result
81
- * never reached the agent, and two tabs or devices that restore the same
82
- * thread can each run it.
83
- *
84
- * If one assistant message also calls a tool that stays passive, the follow-up
85
- * run sends that call without a result, which some model providers reject.
86
- * Opt in every tool the agent calls together, or set `followUp: false`.
87
- */
88
- type FrontendToolReconnectBehavior = "passive" | "resume-pending";
89
- /**
90
- * Annotations for a WebMCP tool, passed through to
91
- * `document.modelContext.registerTool`. Mirrors the WebMCP spec's tool
92
- * annotations. These are hints for browser agents only — they do not enforce
93
- * any policy on their own.
94
- */
95
- type WebMCPToolAnnotations = {
96
- /**
97
- * Hint that the tool does not modify state. Defaults to false.
98
- * Set it for read-only tools (search, status lookup, ...).
99
- */
100
- readOnlyHint?: boolean;
101
- /**
102
- * Hint that the tool's output may contain untrusted content
103
- * (e.g. user-generated or external content). Defaults to false.
104
- */
105
- untrustedContentHint?: boolean;
106
- };
107
- /**
108
- * WebMCP registration options for a frontend tool.
109
- */
110
- type WebMCPToolConfig = {
111
- /** Hints that tell browser agents how the tool behaves. */annotations?: WebMCPToolAnnotations;
112
- };
113
- type FrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = {
114
- /**
115
- * @internal Classifies local execution. Omitted means an ordinary frontend
116
- * tool. Pending calls in the latest user turn are eligible for restoration.
117
- * Human-in-the-loop handlers are restored from history replay;
118
- * other handlers only with `reconnectBehavior: "resume-pending"`. Tools
119
- * without a handler restore missing empty completion results automatically.
120
- * This field is not sent to the agent as part of the tool schema.
121
- */
122
- type?: "frontend" | "human-in-the-loop";
123
- name: string;
124
- description?: string;
125
- parameters?: StandardSchemaV1<any, T>;
126
- handler?: (args: T, context: FrontendToolHandlerContext) => Promise<unknown>;
127
- followUp?: boolean;
128
- /**
129
- * Whether to run the handler again for a call that is still unanswered when
130
- * the thread's history is restored. Defaults to `"passive"`. See
131
- * {@link FrontendToolReconnectBehavior}.
132
- */
133
- reconnectBehavior?: FrontendToolReconnectBehavior;
134
- /**
135
- * Optional agent ID to constrain this tool to a specific agent.
136
- * If specified, this tool will only be available to the specified agent.
137
- */
138
- agentId?: string;
139
- /**
140
- * Whether this tool is available to the agent.
141
- * Set to false to hide the tool from the agent without unregistering it.
142
- * Defaults to true when not specified.
143
- */
144
- available?: boolean;
145
- /**
146
- * Also expose this tool to browser agents through the WebMCP API
147
- * (`document.modelContext`) while keeping the normal agent registration.
148
- *
149
- * - `true` — register with default annotations.
150
- * - `{ annotations }` — register with the given WebMCP annotations.
151
- * - `false` / `undefined` — do not register.
152
- *
153
- * The tool's `handler` runs when a browser agent calls the tool; the handler
154
- * context then has no `agent`. No-op in environments without WebMCP support
155
- * (e.g. React Native, or browsers without the API enabled).
156
- */
157
- webmcp?: boolean | WebMCPToolConfig;
158
- };
159
- type Suggestion = {
160
- title: string;
161
- message: string; /** Indicates whether this suggestion is still being generated. */
162
- isLoading: boolean; /** Optional CSS class name applied to the suggestion pill. */
163
- className?: string;
164
- };
165
- type SuggestionAvailability = "before-first-message" | "after-first-message" | "always" | "disabled";
166
- type DynamicSuggestionsConfig = {
167
- /**
168
- * A prompt or instructions for the GPT to generate suggestions.
169
- */
170
- instructions: string;
171
- /**
172
- * The minimum number of suggestions to generate. Defaults to `1`.
173
- * @default 1
174
- */
175
- minSuggestions?: number;
176
- /**
177
- * The maximum number of suggestions to generate. Defaults to `3`.
178
- * @default 1
179
- */
180
- maxSuggestions?: number;
181
- /**
182
- * When the suggestions are available. Defaults to "after-first-message".
183
- */
184
- available?: SuggestionAvailability;
185
- /**
186
- * The agent ID of the provider of the suggestions. Defaults to `"default"`.
187
- */
188
- providerAgentId?: string;
189
- /**
190
- * The agent ID of the consumer of the suggestions. Defaults to `"*"` (all agents).
191
- */
192
- consumerAgentId?: string;
193
- };
194
- type StaticSuggestionsConfig = {
195
- /**
196
- * The suggestions to display.
197
- */
198
- suggestions: Omit<Suggestion, "isLoading">[];
199
- /**
200
- * When the suggestions are available. Defaults to "before-first-message".
201
- */
202
- available?: SuggestionAvailability;
203
- /**
204
- * The agent ID of the consumer of the suggestions. Defaults to `"*"` (all agents).
205
- */
206
- consumerAgentId?: string;
207
- };
208
- type SuggestionsConfig = DynamicSuggestionsConfig | StaticSuggestionsConfig;
209
- //#endregion
210
- //#region src/utils/connect-replay.d.ts
211
- /** Internal connection callbacks; HTTP connections keep their EOF behavior. */
212
- interface ConnectionReplayLifecycle {
213
- onReplayStarted?: () => void;
214
- onReplayFinished?: () => void;
215
- }
216
- //#endregion
217
- //#region src/core/message-filter.d.ts
218
- /**
219
- * Rewrites the message list a runtime agent sends on each run.
220
- *
221
- * CopilotKit sends the whole thread on every request. When the backend already
222
- * stores the conversation (a LangGraph checkpointer, a Mastra memory store, a
223
- * Strands `SessionManager`, an Agent Framework chat history provider), that
224
- * history is dead weight: the payload grows without bound, and an agent that
225
- * merges the inbound list with its own store can show the model every turn
226
- * twice. See https://github.com/CopilotKit/CopilotKit/issues/1482.
227
- *
228
- * The filter runs on the outbound payload only. It never touches the messages
229
- * the UI renders, so trimming here does not shorten the visible transcript.
230
- *
231
- * Return the messages to send. Returning an empty array is valid and means
232
- * "send nothing but the run metadata".
233
- *
234
- * @param messages - The thread as the client holds it, in order, with
235
- * `activity`-role messages already removed.
236
- * @param context - Which agent is about to run.
237
- */
238
- type CopilotKitMessageFilter = (messages: Message[], context: {
239
- agentId: string;
240
- }) => Message[];
241
- //#endregion
242
- //#region src/agent.d.ts
243
- type ResolvedRuntimeMode = RuntimeMode$1 | "pending";
244
- interface ProxiedCopilotRuntimeAgentConfig extends Omit<HttpAgentConfig, "url"> {
245
- runtimeUrl?: string;
246
- transport?: CopilotRuntimeTransport;
247
- credentials?: RequestCredentials;
248
- runtimeMode?: ResolvedRuntimeMode;
249
- intelligence?: IntelligenceRuntimeInfo$1;
250
- capabilities?: AgentCapabilities;
251
- debug?: ResolvedDebugConfig;
252
- /**
253
- * When set, runtime requests (HTTP path, single-route envelope, intelligence
254
- * delegate) are routed to this agent on the runtime instead of `agentId`.
255
- * The local `agentId` remains the registry key used for subscriber
256
- * bookkeeping; only outbound routing is overridden.
257
- */
258
- runtimeAgentId?: string;
259
- /**
260
- * Rewrites the outbound message list on every run. See
261
- * {@link CopilotKitMessageFilter}. Not applied in Intelligence mode.
262
- */
263
- messageFilter?: CopilotKitMessageFilter;
264
- }
265
- declare class ProxiedCopilotRuntimeAgent extends HttpAgent {
266
- #private;
267
- runtimeUrl?: string;
268
- credentials?: RequestCredentials;
269
- readonly runtimeAgentId?: string;
270
- private transport;
271
- /**
272
- * The runtime URL exactly as the caller supplied it. `runtimeUrl` is the
273
- * slash-stripped form used for path joins; the single-route endpoint (run,
274
- * connect, stop, info envelopes) is this verbatim value, because a trailing
275
- * slash can select a different proxy location.
276
- */
277
- private readonly runtimeEndpointUrl?;
278
- private singleEndpointUrl?;
279
- private runtimeMode;
280
- private intelligence?;
281
- private _capabilities?;
282
- private delegate?;
283
- private runtimeInfoPromise?;
284
- private connectionAttempt?;
285
- private _messageFilter?;
286
- /**
287
- * The HTTP `run` this agent started and has not yet seen finish, as the
288
- * exact `{ threadId, runId }` it POSTed. `abortRun` narrows `/stop` to this
289
- * run only while `threadId` still matches: `threadId` is a public field the
290
- * host may reassign under a live run, and a runId from another thread must
291
- * not be sent as if it were this thread's. Released when the run stream
292
- * finalizes, cleared on `connect` (a reconnected thread may run under a
293
- * runId this client never saw) and never copied by `clone`. Without a
294
- * provable active run the stop stays thread-wide.
295
- */
296
- private activeRun?;
297
- constructor(config: ProxiedCopilotRuntimeAgentConfig);
298
- /**
299
- * Adopt the runtime mode a fresh `/info` just reported.
300
- *
301
- * A live proxy outlives the runtime configuration that minted it: a
302
- * redeploy, an env-var change or a rollback can flip `intelligence` → `sse`
303
- * under a page that is already open. The registry preserves the proxy across
304
- * that re-sync on purpose — it is backing an open conversation — so the new
305
- * mode is pushed onto the instance here instead of replacing it.
306
- *
307
- * Without this the mode was decided once, at construction, and `run()` kept
308
- * taking the delegate path against a runtime serving plain SSE, where
309
- * `response.json()` on a `text/event-stream` body throws for the rest of the
310
- * page's life. See #7130.
311
- *
312
- * A delegate built for the old mode is torn down: it speaks a protocol the
313
- * runtime no longer serves, and it may be holding a websocket open. The
314
- * memoized `/info` promise goes with it — it answered for the old
315
- * configuration, so a later `ensureRuntimeConfiguration()` must re-ask
316
- * rather than treat that answer as current.
317
- *
318
- * Only `wsUrl` is compared on the Intelligence metadata, because that is the
319
- * one field the delegate bakes in at construction.
320
- */
321
- adoptRuntimeMode(runtimeMode: ResolvedRuntimeMode, intelligence: IntelligenceRuntimeInfo$1 | undefined): void;
322
- /**
323
- * The agent id used for outbound runtime requests — `runtimeAgentId` when
324
- * set (manually-registered proxy), otherwise `agentId` (registry id
325
- * matches runtime id). Subscriber bookkeeping keeps using `agentId`
326
- * directly.
327
- *
328
- * Throws when both are unset: a proxy reaching an HTTP path with no
329
- * routable id is a bug, and a missing id would otherwise produce a
330
- * malformed `/agent//run` or `/agent/undefined/connect` URL silently.
331
- */
332
- private routedAgentId;
333
- get capabilities(): AgentCapabilities | undefined;
334
- /**
335
- * The filter applied to the outbound message list on every run.
336
- *
337
- * Registry-owned. `AgentRegistry` writes it whenever the core-level filter
338
- * changes, so an agent discovered before the app configured one still picks
339
- * it up — and so a value written here by hand is replaced on the registry's
340
- * next sweep. Configure it through `CopilotKitCore` instead.
341
- */
342
- get messageFilter(): CopilotKitMessageFilter | undefined;
343
- set messageFilter(filter: CopilotKitMessageFilter | undefined);
344
- requestInit(input: RunAgentInput): RequestInit;
345
- getCapabilities(): Promise<AgentCapabilities>;
346
- detachActiveRun(): Promise<void>;
347
- abortRun(): void;
348
- connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
349
- connect(input: RunAgentInput, lifecycle?: ConnectionReplayLifecycle): Observable<BaseEvent>;
350
- run(input: RunAgentInput): Observable<BaseEvent>;
351
- clone(): ProxiedCopilotRuntimeAgent;
352
- /** Run presentation-only MCP reads on a separate client agent so their
353
- * lifecycle cannot replace an in-flight approval's detach/completion state. */
354
- ɵrunMcpResourceRead(parameters: RunAgentParameters): Promise<RunAgentResult>;
355
- /**
356
- * Drop the delegate's cached `lastSeenEventId` for this thread so
357
- * the next connect requests a full historical replay from the
358
- * gateway. Used by `RunHandler.connectAgent` on a detected thread
359
- * switch (the chat moved between threads, so its local
360
- * messages/state are about to be cleared and need rebuilding from
361
- * the gateway). Skipped on same-thread churn re-connects so the
362
- * gateway can resume from the cursor instead.
363
- *
364
- * No-op for non-Intelligence runtime modes — the HTTP transport
365
- * doesn't replay.
366
- */
367
- clearReplayCursor(threadId: string): void;
368
- private resolveDelegate;
369
- /** Resolve transport and runtime mode before the first outbound request. */
370
- private ensureRuntimeConfiguration;
371
- private fetchRuntimeInfo;
372
- private fetchRuntimeInfoAutoDetect;
373
- private createSingleRouteRequestInit;
374
- private createIntelligenceDelegate;
375
- private syncDelegate;
376
- }
377
- //#endregion
378
- //#region src/core/agent-registry.d.ts
379
- declare const ɵRUNTIME_PROBE_TIMEOUT_MS = 5000;
380
- interface CopilotKitCoreAddAgentParams {
381
- id: string;
382
- agent: AbstractAgent;
383
- }
384
- /**
385
- * Parameters for registering a proxied agent against an existing runtime agent.
386
- */
387
- interface CopilotKitCoreRegisterProxiedAgentParams {
388
- /**
389
- * The local registry id under which the proxy is registered. Used by
390
- * `useAgent`, state-manager subscriptions, and all subscriber bookkeeping.
391
- * Must not collide with any existing local or runtime-discovered agent id.
392
- */
393
- agentId: string;
394
- /**
395
- * The id of the runtime agent that this proxy routes outbound HTTP requests
396
- * to. Invisible to subscribers — only affects URL paths and single-route
397
- * envelopes.
398
- */
399
- runtimeAgentId: string;
400
- }
401
- interface CopilotKitCoreRegisterProxiedAgentResult {
402
- agent: ProxiedCopilotRuntimeAgent;
403
- unregister: () => void;
404
- }
405
- /**
406
- * Manages agent registration, lifecycle, and runtime connectivity for CopilotKitCore.
407
- * Handles both local development agents and remote runtime agents.
408
- */
409
- declare class AgentRegistry {
410
- private core;
411
- private _agents;
412
- private localAgents;
413
- private remoteAgents;
414
- private readonly mintedThreadIds;
415
- private _runtimeUrl?;
416
- /** The runtime URL as the caller supplied it; the single-route endpoint uses it verbatim. */
417
- private _runtimeEndpointUrl?;
418
- private _connectionInFlight?;
419
- private _runtimeConnectionGeneration;
420
- private _activeRuntimeConnectionAttempt?;
421
- private _runtimeEntitlementRetryTimer?;
422
- private _runtimeEntitlementRetryAttemptedKey?;
423
- private _runtimeEntitlementRetryPendingKey?;
424
- private _runtimeVersion?;
425
- private _runtimeConnectionStatus;
426
- private _runtimeTransport;
427
- private _requestedTransport;
428
- private _audioFileTranscriptionEnabled;
429
- private _runtimeMode;
430
- private _intelligence?;
431
- private _threadEndpoints?;
432
- private _singleRouteResourceOperations;
433
- private _suggestions?;
434
- private _inspectorLearning;
435
- private _inspectorMetadata?;
436
- private _inspectorMetadataSupported;
437
- private inspectorMetadataRefreshReady;
438
- private inspectorMetadataConnectionGeneration;
439
- private inspectorMetadataGeneration;
440
- private inspectorMetadataHeadersGeneration;
441
- private inspectorMetadataCredentialsGeneration;
442
- private inspectorMetadataAbortController?;
443
- private inspectorMetadataNotificationQueue;
444
- private _a2uiEnabled;
445
- private _a2uiAgents?;
446
- private _openGenerativeUIEnabled;
447
- private _licenseStatus?;
448
- private _runtimeEntitlements?;
449
- private _telemetryDisabled;
450
- private remoteAgentConnections;
451
- private runtimeFetch?;
452
- private runtimeProbeInFlight;
453
- private runtimeProbeToken;
454
- private runtimeProbeAbortController?;
455
- private runtimeRecoveryRunning;
456
- private runtimeRecoveryPending;
457
- private runtimeHealthGeneration;
458
- /**
459
- * The headers each HttpAgent was constructed with, captured on the first
460
- * `applyHeadersToAgent` call for that agent (which, for agents the registry
461
- * owns, happens at registration before any core headers are applied). Core
462
- * headers are merged ON TOP of this baseline so that headers configured
463
- * directly on an agent (e.g. an `Authorization` for a self-hosted backend)
464
- * survive registration instead of being silently replaced. The baseline is
465
- * captured once and never re-captured, so a later direct mutation of
466
- * `agent.headers` is not folded into it. See #5635.
467
- */
468
- private agentOwnHeaders;
469
- constructor(core: CopilotKitCore);
470
- /**
471
- * Get all agents as a readonly record
472
- */
473
- get agents(): Readonly<Record<string, AbstractAgent>>;
474
- get runtimeUrl(): string | undefined;
475
- get runtimeVersion(): string | undefined;
476
- get runtimeConnectionStatus(): CopilotKitCoreRuntimeConnectionStatus;
477
- get runtimeTransport(): CopilotRuntimeTransport;
478
- get audioFileTranscriptionEnabled(): boolean;
479
- get runtimeMode(): RuntimeMode$1;
480
- get intelligence(): IntelligenceRuntimeInfo$1 | undefined;
481
- get threadEndpoints(): ThreadEndpointRuntimeInfo$1 | undefined;
482
- get suggestions(): boolean | undefined;
483
- get inspectorLearning(): boolean;
484
- get inspectorMetadata(): InspectorMetadataV1$1 | undefined;
485
- get a2uiEnabled(): boolean;
486
- /**
487
- * Agent ids the runtime applies A2UI to (#5369). `undefined` means A2UI
488
- * applies to every agent — or is disabled entirely; check `a2uiEnabled`.
489
- */
490
- get a2uiAgents(): string[] | undefined;
491
- get openGenerativeUIEnabled(): boolean;
492
- get licenseStatus(): RuntimeLicenseStatus$1 | undefined;
493
- /** Structured Runtime entitlement authority advertised by `/info`. */
494
- get runtimeEntitlements(): RuntimeEntitlementResponse | undefined;
495
- get runtimeEntitlementRetryPending(): boolean;
496
- get telemetryDisabled(): boolean;
497
- /**
498
- * Initialize agents from configuration
499
- */
500
- initialize(agents: Record<string, AbstractAgent>): void;
501
- /**
502
- * Set the runtime URL and update connection
503
- */
504
- setRuntimeUrl(runtimeUrl: string | undefined, options?: {
505
- deferConnection?: boolean;
506
- }): void;
507
- /**
508
- * Start the initial runtime connection if it has not been started yet.
509
- *
510
- * Backs {@link CopilotKitCore.connect}. Idempotent: it only kicks off a fetch
511
- * when a `runtimeUrl` is set and the connection is still `Disconnected` (its
512
- * state before any connect attempt). `updateRuntimeConnection` flips the
513
- * status to `Connecting` synchronously, so a second call — e.g. React
514
- * StrictMode double-invoking the mount effect — bails here. A genuine config
515
- * change still reconnects through `setRuntimeUrl`/`setRuntimeTransport`. See
516
- * #5801.
517
- */
518
- connectRuntime(): void;
519
- setRuntimeTransport(runtimeTransport: CopilotRuntimeTransport): void;
520
- private hasLiveRuntimeKnowledgeToProtect;
521
- private reconcileRecoveredAgents;
522
- private carriesConversationState;
523
- private abandonRuntimeHealthProbe;
524
- /**
525
- * Set all agents at once (for development use)
526
- */
527
- setAgents__unsafe_dev_only(agents: Record<string, AbstractAgent>): void;
528
- /**
529
- * Add a single agent (for development use)
530
- */
531
- addAgent__unsafe_dev_only({
532
- id,
533
- agent
534
- }: CopilotKitCoreAddAgentParams): void;
535
- /**
536
- * Remove an agent by ID (for development use)
537
- */
538
- removeAgent__unsafe_dev_only(id: string): void;
539
- /**
540
- * Register a proxied agent that routes outbound runtime requests to an
541
- * existing runtime agent (`runtimeAgentId`) while exposing a distinct local
542
- * registry id (`agentId`). Throws if `agentId` is already taken by either a
543
- * local or runtime-discovered agent.
544
- *
545
- * Use this to mount multiple frontend agents against a single runtime
546
- * agent (e.g. a chat-1 / chat-2 pair both proxying to "default") without
547
- * implicit per-thread cloning. The returned `unregister` removes the proxy
548
- * from the registry and emits `onAgentsChanged`.
549
- */
550
- registerProxiedAgent({
551
- agentId,
552
- runtimeAgentId
553
- }: CopilotKitCoreRegisterProxiedAgentParams): CopilotKitCoreRegisterProxiedAgentResult;
554
- /**
555
- * Get an agent by ID
556
- */
557
- getAgent(id: string): AbstractAgent | undefined;
558
- /**
559
- * Shared core-and-own-header merge for a single agent. Captures the
560
- * agent's construction-time headers once (the per-agent baseline in
561
- * `agentOwnHeaders`), then either keeps only that baseline — a
562
- * `ProxiedCopilotRuntimeAgent`, whose core headers are added by
563
- * `ɵruntimeFetch` when each request is actually sent instead, so a key the
564
- * builder stops returning can never ride along from a stale copy baked
565
- * onto the agent (see #1937) — or merges `coreHeaders` on top of it (any
566
- * other `HttpAgent`; core wins on a key conflict, see #5635).
567
- */
568
- private applyHeaderRecordToAgent;
569
- /**
570
- * Apply the last resolved header snapshot to an agent, merged ON TOP of
571
- * the agent's own construction-time headers. Non-`HttpAgent` agents are
572
- * left untouched because only `HttpAgent` carries a `headers` field. See
573
- * #5635.
574
- *
575
- * Never invokes the headers builder — safe to call from anywhere (dev-only
576
- * registration helpers, a React effect that re-runs on every render)
577
- * without risking a synchronous throw or an unhandled async rejection from
578
- * a user-supplied builder. Use `prepareAgentHeadersForRun` (friends-only)
579
- * on the run/connect path, where a builder failure can be awaited and
580
- * reported once.
581
- */
582
- applyHeadersToAgent(agent: AbstractAgent): void;
583
- /**
584
- * Apply the last resolved header snapshot to every agent, without
585
- * triggering a builder call per agent. Used by `initialize` and
586
- * `setHeaders`; a run re-applies with fresh headers anyway (see
587
- * `prepareAgentHeadersForRun`).
588
- */
589
- applyHeadersToAgents(agents: Record<string, AbstractAgent>): void;
590
- /**
591
- * Resolve headers fresh and apply them to `agent` right before a run or
592
- * connect actually sends (#1937) — the resolving counterpart to
593
- * `applyHeadersToAgent`. Friends-only: only the run handler should call
594
- * this, since resolving can invoke a user-supplied builder that throws
595
- * synchronously or returns a rejecting promise. Resolution is synchronous
596
- * for a record or a sync builder; this returns a promise only when an
597
- * async builder must be awaited first, and callers that need the write to
598
- * have landed before continuing must await a returned promise.
599
- *
600
- * A `ProxiedCopilotRuntimeAgent` never invokes the builder here: its core
601
- * headers are added by `ɵruntimeFetch` at send time instead, so only its
602
- * own headers are (re)applied.
603
- */
604
- prepareAgentHeadersForRun(agent: AbstractAgent): void | Promise<void>;
605
- /**
606
- * Apply current credentials to an agent
607
- */
608
- applyCredentialsToAgent(agent: AbstractAgent): void;
609
- /**
610
- * Apply current credentials to all agents
611
- */
612
- applyCredentialsToAgents(agents: Record<string, AbstractAgent>): void;
613
- /**
614
- * Carry the mode a fresh `/info` reported onto a proxy this re-sync kept.
615
- *
616
- * `canReuseRuntimeAgent` deliberately ignores the mode: a preserved proxy is
617
- * backing an open conversation, and replacing the instance to change one
618
- * field would drop it. The mode is therefore pushed onto the survivor here,
619
- * the same way headers and credentials are. Without it the mode was fixed at
620
- * construction, so a runtime that flipped `intelligence` → `sse` under an
621
- * open page left every later run on the delegate path. See #7130.
622
- */
623
- applyRuntimeModeToAgent(agent: AbstractAgent, runtimeInfo: RuntimeInfo): void;
624
- /**
625
- * Apply the core's message filter to an agent.
626
- *
627
- * The test is the class, not which bucket the agent is registered in: every
628
- * `ProxiedCopilotRuntimeAgent` gets the core filter, whether it came from
629
- * `/info` or from `registerProxiedAgent` (which files its proxy under
630
- * `localAgents`). Agents of any other class are left untouched — an
631
- * `AbstractAgent` the app built has no such hook, and its owner already has
632
- * the AG-UI middleware seam.
633
- *
634
- * This is the sole writer of `agent.messageFilter` in normal operation. The
635
- * public setter exists for the registry and for tests; a value written
636
- * directly onto an agent is replaced the next time the registry sweeps, the
637
- * same way per-agent credentials are.
638
- */
639
- applyMessageFilterToAgent(agent: AbstractAgent): void;
640
- /**
641
- * Apply the core's message filter to all agents
642
- */
643
- applyMessageFilterToAgents(agents: Record<string, AbstractAgent>): void;
644
- /** Preserve the exact configured URL when posting to a single endpoint. */
645
- get runtimeEndpointUrl(): string | undefined;
646
- createRuntimeFetch(): typeof fetch;
647
- private armRuntimeRequestWatchdog;
648
- applyRuntimeFetchToAgent(agent: AbstractAgent): void;
649
- applyRuntimeFetchToAgents(agents: Record<string, AbstractAgent>): void;
650
- /** Refresh metadata after the Core header snapshot changes. */
651
- handleHeadersChanged(): void;
652
- /** Refresh metadata after the Core credentials mode changes. */
653
- handleCredentialsChanged(): void;
654
- /**
655
- * Fetch trusted inspector metadata independently from runtime discovery.
656
- * Optional-route failures degrade to absent metadata and never affect the
657
- * runtime connection state.
658
- */
659
- refreshInspectorMetadata(): Promise<void>;
660
- private fetchInspectorMetadataRest;
661
- private fetchInspectorMetadataSingle;
662
- private isInspectorMetadataRequestCurrent;
663
- private invalidateInspectorMetadataConnection;
664
- /**
665
- * Publish one state transition without making refreshes wait on subscribers.
666
- * Each queued callback closes over its readonly snapshot so reentrant changes
667
- * cannot replace the value that an older publication is still delivering.
668
- */
669
- private setInspectorMetadata;
670
- private setRuntimeConnectionStatus;
671
- private handleRuntimeRequestOutcome;
672
- private fetchRuntimeInfoWithTimeout;
673
- private probeRuntimeReachability;
674
- private markRuntimeUnreachable;
675
- private recoverRuntimeConnection;
676
- /**
677
- * Update runtime connection and fetch remote agents
678
- */
679
- private updateRuntimeConnection;
680
- /** Return the stable key that scopes connection and entitlement retries. */
681
- private runtimeConnectionKey;
682
- /** Return whether a proxy still targets this Runtime connection. */
683
- private canReuseRuntimeAgent;
684
- /** Return whether an async attempt still owns the active Runtime state. */
685
- private isCurrentRuntimeConnection;
686
- /** Cancel a pending entitlement retry and allow a new target to retry. */
687
- private resetRuntimeEntitlementRetry;
688
- /** Schedule one retry after Runtime's short failed-entitlement cache. */
689
- private updateRuntimeEntitlementRetry;
690
- /** Start the bounded retry after the original connection has settled. */
691
- private executeRuntimeEntitlementRetry;
692
- private performRuntimeConnection;
693
- private fetchRuntimeInfo;
694
- /**
695
- * The URL a single-route request targets: the runtime URL as the caller
696
- * supplied it. `runtimeUrl` is the slash-stripped form used for path joins;
697
- * a trailing slash can select a different proxy location, so the endpoint
698
- * itself keeps it.
699
- */
700
- private singleEndpointUrlFor;
701
- private fetchRuntimeInfoSingle;
702
- /**
703
- * Auto-detect transport by trying REST first, then falling back to single-endpoint.
704
- * The caller commits the detected transport only after confirming this
705
- * connection attempt is still current.
706
- */
707
- private fetchRuntimeInfoAutoDetect;
708
- /**
709
- * Assign agent IDs to a record of agents
710
- */
711
- private assignAgentIds;
712
- /**
713
- * Validate and assign an agent ID
714
- */
715
- private validateAndAssignAgentId;
716
- /**
717
- * Notify subscribers of runtime status changes
718
- */
719
- private notifyRuntimeStatusChanged;
720
- /**
721
- * Notify subscribers of agent changes
722
- */
723
- private notifyAgentsChanged;
724
- private notifyInspectorMetadataChanged;
725
- }
726
- //#endregion
727
- //#region src/core/context-store.d.ts
728
- /**
729
- * A context entry with optional per-agent scoping.
730
- * When `agentIds` is set, the entry is forwarded only to runs of those agents;
731
- * when omitted, the entry is forwarded to every agent run.
732
- */
733
- interface ScopedContext extends Context {
734
- agentIds?: string[];
735
- }
736
- /**
737
- * Manages context storage and lifecycle for CopilotKitCore.
738
- * Context represents additional information available to agents during execution.
739
- */
740
- declare class ContextStore {
741
- private core;
742
- private _context;
743
- constructor(core: CopilotKitCore);
744
- /**
745
- * Get all context entries as a readonly record
746
- */
747
- get context(): Readonly<Record<string, ScopedContext>>;
748
- /**
749
- * Add a new context entry. Pass `agentIds` to restrict the entry to runs of
750
- * specific agents (#5369); omit it for context every agent should receive.
751
- * @returns The ID of the created context entry
752
- */
753
- addContext({
754
- description,
755
- value,
756
- agentIds
757
- }: ScopedContext): string;
758
- /**
759
- * Build the context array for a run of the given agent: entries scoped to
760
- * other agents are dropped, and the scoping metadata is stripped so only
761
- * protocol-shaped `{ description, value }` entries go over the wire.
762
- */
763
- getContextForAgent(agentId?: string): Context[];
764
- /**
765
- * Remove a context entry by ID
766
- */
767
- removeContext(id: string): void;
768
- /**
769
- * Notify all subscribers of context changes
770
- */
771
- private notifySubscribers;
772
- }
773
- //#endregion
774
- //#region src/core/state-manager.d.ts
775
- interface CopilotKitCoreContinuationHandoff {
776
- cancel(): void;
777
- bind(input: object): void;
778
- }
779
- /**
780
- * Manages state and message tracking by run for CopilotKitCore.
781
- * Tracks agent state snapshots and message-to-run associations.
782
- */
783
- declare class StateManager {
784
- private core;
785
- private stateByRun;
786
- private messageToRun;
787
- private rawEventByMessage;
788
- private activeRun;
789
- private agentSubscriptions;
790
- private pendingContinuations;
791
- private interruptedRuns;
792
- /** Find the interrupted logical run without consuming its pending answers. */
793
- getContinuationRunId(agent: AbstractAgent, input: Pick<RunAgentInput, "threadId" | "resume" | "forwardedProps">): string | undefined;
794
- constructor(core: CopilotKitCore);
795
- /**
796
- * Initialize state tracking for an agent
797
- */
798
- initialize(): void;
799
- markNextRunAsContinuation(agent: AbstractAgent, expectedRunId?: string): CopilotKitCoreContinuationHandoff;
800
- /**
801
- * Subscribe to an agent's events to track state and messages.
802
- */
803
- subscribeToAgent(agent: AbstractAgent): void;
804
- /**
805
- * Unsubscribe an agent's subscription.
806
- */
807
- unsubscribeFromAgent(agentId: string): void;
808
- /**
809
- * Get state for a specific run
810
- * Returns a deep copy to prevent external mutations
811
- */
812
- getStateByRun(agentId: string, threadId: string, runId: string): State | undefined;
813
- /**
814
- * Get runId associated with a message
815
- */
816
- getRunIdForMessage(agentId: string, threadId: string, messageId: string): string | undefined;
817
- /**
818
- * Get direct text-start metadata associated with a message.
819
- */
820
- getRawEventForMessage(agentId: string, threadId: string, messageId: string): unknown;
821
- /**
822
- * Get all states for an agent's thread
823
- */
824
- getStatesForThread(agentId: string, threadId: string): Map<string, State>;
825
- /**
826
- * Get all run IDs for an agent's thread
827
- */
828
- getRunIdsForThread(agentId: string, threadId: string): string[];
829
- /**
830
- * Handle run started event
831
- */
832
- private handleRunStarted;
833
- /**
834
- * Handle run finished event
835
- */
836
- private handleRunFinished;
837
- /**
838
- * Handle state snapshot event
839
- */
840
- private handleStateSnapshot;
841
- /**
842
- * Handle state delta event
843
- */
844
- private handleStateDelta;
845
- /**
846
- * Capture only defined metadata from a normalized direct text-start event.
847
- */
848
- private handleTextMessageStart;
849
- /**
850
- * Handle messages snapshot event
851
- */
852
- private handleMessagesSnapshot;
853
- /**
854
- * Handle new message event
855
- */
856
- private handleNewMessage;
857
- /**
858
- * Save state for a specific run
859
- */
860
- private saveState;
861
- /**
862
- * Associate a message with a run
863
- */
864
- private associateMessageWithRun;
865
- private pruneRawEvents;
866
- /**
867
- * Clear all state for an agent
868
- */
869
- clearAgentState(agentId: string): void;
870
- /**
871
- * Clear all state for a thread
872
- */
873
- clearThreadState(agentId: string, threadId: string): void;
874
- }
875
- //#endregion
876
- //#region src/core/run-handler.d.ts
877
- interface CopilotKitCoreRunAgentParams {
878
- agent: AbstractAgent;
879
- forwardedProps?: Record<string, unknown>;
880
- /**
881
- * Optional caller-supplied run identifier forwarded to the underlying AG-UI
882
- * agent. When omitted, the agent creates one.
883
- */
884
- runId?: string;
885
- /**
886
- * Per-interrupt responses addressing every open AG-UI interrupt from the
887
- * previous run. Forwarded to the agent as the standard `resume` array.
888
- */
889
- resume?: ResumeEntry[];
890
- }
891
- interface CopilotKitCoreConnectAgentParams {
892
- agent: AbstractAgent;
893
- }
894
- interface CopilotKitCoreGetToolParams {
895
- toolName: string;
896
- agentId?: string;
897
- }
898
- /**
899
- * Parameters for programmatic tool execution via `copilotkit.runTool()`.
900
- */
901
- interface CopilotKitCoreRunToolParams {
902
- /** Name of the registered frontend tool to execute. */
903
- name: string;
904
- /** Optional agent ID. If omitted, uses the default agent lookup. */
905
- agentId?: string;
906
- /** Parameters to pass to the tool handler. */
907
- parameters?: Record<string, unknown>;
908
- /**
909
- * Whether to trigger an LLM follow-up after tool execution.
910
- * - `false` (default): execute tool, add messages to history, done.
911
- * - `"generate"`: after execution, trigger another agent run so the LLM responds to the tool result.
912
- * - Any other string: add a user message with this text, then trigger another agent run.
913
- */
914
- followUp?: string | false;
915
- }
916
- /**
917
- * Result of programmatic tool execution via `copilotkit.runTool()`.
918
- */
919
- interface CopilotKitCoreRunToolResult {
920
- /** The unique ID of the tool call. */
921
- toolCallId: string;
922
- /** The stringified result from the tool handler. */
923
- result: string;
924
- /** Error message if the handler failed. */
925
- error?: string;
926
- }
927
- /**
928
- * A registered A2UI catalog component, as exposed to the inspector via
929
- * `CopilotKitCore.catalogComponents`. `schema` is an opaque JSON-schema-ish
930
- * value (the built catalog's Zod schema or a serialized form); the inspector
931
- * treats it as unknown. `description` is optional because the built
932
- * `ComponentApi` does not carry descriptions.
933
- */
934
- interface CopilotKitCoreCatalogComponent {
935
- name: string;
936
- description?: string;
937
- schema: unknown;
938
- }
939
- /**
940
- * Handles agent execution, tool calling, and agent connectivity for CopilotKitCore.
941
- * Manages the complete lifecycle of agent runs including tool execution and follow-ups.
942
- */
943
- declare class RunHandler {
944
- private core;
945
- /**
946
- * Tools owned by the framework provider, replaced wholesale by
947
- * {@link initialize} and {@link setTools} whenever the provider re-syncs its
948
- * props or runtime feature flags.
949
- */
950
- private _propTools;
951
- /**
952
- * Tools registered imperatively via {@link addTool} — `useFrontendTool`,
953
- * `useHumanInTheLoop`, and direct `core.addTool()` callers. Held separately
954
- * from {@link _propTools} so a provider re-sync cannot wipe them: they shared
955
- * one array before, so the `/info` response flipping `openGenerativeUI` (or
956
- * any other provider-prop change) silently dropped every hook-registered
957
- * tool (#4952). Key = `capabilityKey(name, agentId)`.
958
- */
959
- private _hookTools;
960
- /**
961
- * Memoized merge of both buckets, invalidated on every registry write.
962
- *
963
- * This is about identity, not speed: `tools` is public and used to return the
964
- * same array instance until something mutated the registry, so consumers can
965
- * hold it or use it as an effect dependency. Rebuilding the merge on every
966
- * read would hand out a new array each time.
967
- */
968
- private _cachedMergedTools;
969
- /**
970
- * The full list of A2UI catalog components registered by the provider.
971
- * Order is preserved for display in the inspector.
972
- */
973
- private _catalogComponents;
974
- /**
975
- * Names of catalog components the caller has explicitly disabled. A name
976
- * absent from this set is enabled (default). Survives re-registration so a
977
- * catalog identity change does not silently re-enable a disabled component.
978
- */
979
- private _disabledCatalogComponents;
980
- /**
981
- * Keys of frontend tools explicitly disabled at runtime via the Inspector's
982
- * Capabilities tool (`setToolEnabled`). Kept independently of each tool's own
983
- * `available` flag so a hook re-registering the tool (which resets
984
- * `available`) does not clobber the override. Key = `capabilityKey(name, agentId)`.
985
- */
986
- private _disabledToolKeys;
987
- /**
988
- * Registry keys already reported by {@link warnOnMissingToolParameters}.
989
- * Development only, and per instance rather than per module so tests and
990
- * multiple cores stay independent. Deliberately NOT cleared by
991
- * {@link removeTool}: `useFrontendTool` tears down and re-registers on every
992
- * dependency change, so clearing it would turn one warning into one per
993
- * render. Key = `capabilityKey(name, agentId)`.
994
- */
995
- private _warnedMissingToolParameters;
996
- /**
997
- * Abort controllers of each agent's in-flight run chains (a run plus its
998
- * recursive follow-ups), recording whether a chain, including its tool
999
- * execution, was aborted via `stopAgent()` or `agent.abortRun()`. Every run
1000
- * that is not a follow-up gets a fresh controller, so a run started after
1001
- * Stop is not born aborted while the stopped chain is still settling. Keyed
1002
- * by agent so that stopping one agent never cancels another agent's run on
1003
- * the same core.
1004
- */
1005
- private _runAbortControllers;
1006
- /**
1007
- * Per-agent `runAgent` depth (in-flight runs plus their recursive
1008
- * follow-ups), so that the `agent.abortRun()` intercept is installed while
1009
- * any of the agent's runs is in flight and removed once none is, and so
1010
- * that runaway follow-up chains trip `MAX_FOLLOW_UP_DEPTH`.
1011
- */
1012
- private _runDepths;
1013
- /**
1014
- * Each agent's own `abortRun`, saved while RunHandler's intercept is
1015
- * installed. Restored only once none of the agent's runs is in flight, so an
1016
- * overlapping run keeps the intercept after an earlier run finishes.
1017
- */
1018
- private _originalAbortRuns;
1019
- /**
1020
- * The request each agent's in-flight run belongs to. Its follow-up runs
1021
- * send the same ID, so Intelligence counts the chain as one request.
1022
- */
1023
- private _activeRequestIds;
1024
- /**
1025
- * Request IDs of recent logical runs, so an approval that resumes a paused
1026
- * run sends the ID of the request that paused. Oldest entries go first.
1027
- */
1028
- private _requestIdByRun;
1029
- /**
1030
- * Keeps tools that opt in via `webmcp` registered on the page's WebMCP model
1031
- * context (`document.modelContext`), in addition to the normal agent
1032
- * registration. Reconciled on every tool registry mutation.
1033
- */
1034
- private _webmcpRegistry;
1035
- /**
1036
- * Tracks the threadId of the most recent `connectAgent` call so we
1037
- * can distinguish a fresh thread restore (different threadId than
1038
- * last time — chat is rebuilding state from scratch, must clear
1039
- * messages/state and ask the gateway for a full replay) from a
1040
- * same-thread churn re-connect (effect-dep churn or transient
1041
- * disconnect — local messages/state are still meaningful, must
1042
- * preserve them and let the gateway resume from
1043
- * `lastSeenEventId`).
1044
- *
1045
- * Tyler's bug fired because every `connectAgent` was treated as a
1046
- * fresh restore, which forced the gateway to replay the full
1047
- * thread history on every churn re-connect and amplified the
1048
- * downstream churn into duplicate `cpki_event_id` rows in the
1049
- * inspector and intermittent "Message not found" toasts.
1050
- */
1051
- private _lastConnectedThreadIdsByAgent;
1052
- private _lastActiveThreadIdsByAgent;
1053
- private _anonymousAgentIds;
1054
- private _nextAnonymousAgentId;
1055
- /** Prevent reconnects from starting an interaction already executing locally. */
1056
- private _executingToolCalls;
1057
- private _connectionGenerations;
1058
- private _runGenerations;
1059
- private _interactionAbortControllers;
1060
- constructor(core: CopilotKitCore);
1061
- /**
1062
- * Abort the current run. Called by `CopilotKitCore.stopAgent()` to signal
1063
- * that in-flight tool handlers should stop and `processAgentResult` should
1064
- * not start a follow-up run.
1065
- */
1066
- abortCurrentRun(agent: AbstractAgent): void;
1067
- private abortAgentRuns;
1068
- /** Signal of the agent's most recently started in-flight run, if any. */
1069
- private latestRunSignal;
1070
- /**
1071
- * Typed access to CopilotKitCore's internal ("friend") methods.
1072
- * Centralises the single unavoidable cast so call-sites stay clean.
1073
- */
1074
- private get _internal();
1075
- /**
1076
- * Return a stable restore-tracking key for the logical agent being
1077
- * connected. Named agents share their last-thread marker across proxy
1078
- * instances; anonymous agents fall back to object identity.
1079
- */
1080
- private getConnectRestoreKey;
1081
- /**
1082
- * Get all tools as a readonly array: provider-owned tools in registration
1083
- * order, with imperatively-added tools appended and taking precedence over a
1084
- * provider tool of the same name + agentId.
1085
- */
1086
- get tools(): Readonly<FrontendTool<any>[]>;
1087
- /**
1088
- * Initialize with tools
1089
- */
1090
- initialize(tools: FrontendTool<any>[]): void;
1091
- /**
1092
- * Add a tool to the registry. Survives provider re-syncs ({@link setTools}),
1093
- * and shadows a provider tool of the same name + agentId.
1094
- */
1095
- addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
1096
- /**
1097
- * Report, once per tool and at development time only, a tool registered with
1098
- * no `parameters` schema.
1099
- *
1100
- * `createToolSchema` substitutes `{ type: "object", properties: {} }` for a
1101
- * missing `parameters` and returns silently, and `parameters` is optional on
1102
- * `FrontendTool`, so nothing — not the compiler, not the runtime — tells the
1103
- * developer that the model was handed a tool with nothing to fill in. It then
1104
- * calls the tool with no arguments. `useComponent`, `useFrontendTool` and
1105
- * `useHumanInTheLoop` all funnel into {@link addTool}; the provider's `tools`
1106
- * prop funnels into {@link initialize} and {@link setTools}.
1107
- *
1108
- * A parameterless tool is legitimate (a HITL confirm dialog, say), so this
1109
- * stays a warning rather than an error. An explicit empty schema
1110
- * (`parameters: z.object({})`) is the way to say "takes none on purpose": it
1111
- * satisfies the check below and `createToolSchema` reduces it to the same
1112
- * advertised `{ type: "object", properties: {} }` that omitting `parameters`
1113
- * produces, so silencing the warning costs nothing on the wire.
1114
- */
1115
- private warnOnMissingToolParameters;
1116
- /**
1117
- * Remove a tool by name and optionally by agentId
1118
- */
1119
- removeTool(id: string, agentId?: string): void;
1120
- /**
1121
- * Get a tool by name and optionally by agentId.
1122
- * If agentId is provided, it will first look for an agent-specific tool,
1123
- * then fall back to a global tool with the same name.
1124
- */
1125
- getTool(params: CopilotKitCoreGetToolParams): FrontendTool<any> | undefined;
1126
- /**
1127
- * Set all provider-owned tools at once. Replaces the previous provider set;
1128
- * tools registered via {@link addTool} are unaffected.
1129
- */
1130
- setTools(tools: FrontendTool<any>[]): void;
1131
- /**
1132
- * Return the registered A2UI catalog components (readonly).
1133
- */
1134
- get catalogComponents(): ReadonlyArray<CopilotKitCoreCatalogComponent>;
1135
- /**
1136
- * Replace the registered catalog component list. Preserves the disabled set
1137
- * (by name) so re-registration does not re-enable disabled components.
1138
- */
1139
- setCatalogComponents(components: CopilotKitCoreCatalogComponent[]): void;
1140
- /**
1141
- * Enable or disable a catalog component by name.
1142
- */
1143
- setCatalogComponentEnabled(name: string, enabled: boolean): void;
1144
- /**
1145
- * Whether a catalog component is enabled. Unknown names default to enabled.
1146
- */
1147
- isCatalogComponentEnabled(name: string): boolean;
1148
- /**
1149
- * Connect an agent (establish initial connection)
1150
- */
1151
- connectAgent({
1152
- agent
1153
- }: CopilotKitCoreConnectAgentParams): Promise<RunAgentResult>;
1154
- /**
1155
- * Run an agent
1156
- */
1157
- runAgent({
1158
- agent,
1159
- forwardedProps,
1160
- resume,
1161
- runId
1162
- }: CopilotKitCoreRunAgentParams, continuationHandoff?: CopilotKitCoreContinuationHandoff,
1163
- /**
1164
- * Set only by `processAgentResult` for a recursive follow-up: the
1165
- * controller of the run being followed up, which the follow-up shares.
1166
- */
1167
-
1168
- followUpOf?: AbortController): Promise<RunAgentResult>;
1169
- private rememberRequestId;
1170
- /**
1171
- * Process agent result and execute tools
1172
- */
1173
- private processAgentResult;
1174
- /** A later user message supersedes pending work from an older turn. */
1175
- private isInLatestUserTurn;
1176
- /** Locate a missing result before saved results for later calls in its batch. */
1177
- private toolResultInsertionIndex;
1178
- /** Identify transport placeholders that must not count as completed answers. */
1179
- private isFrontendPlaceholderResult;
1180
- /**
1181
- * Shared handler execution logic used by executeSpecificTool, executeWildcardTool, and runTool.
1182
- * Handles arg parsing, subscriber notifications, handler invocation, result stringification,
1183
- * and error handling.
1184
- */
1185
- private executeToolHandler;
1186
- /**
1187
- * Execute a specific tool
1188
- */
1189
- private executeSpecificTool;
1190
- /**
1191
- * Execute a wildcard tool.
1192
- * Wildcard tools receive args wrapped as `{toolName, args}`, which differs from
1193
- * specific tools, so this method keeps its own arg-wrapping logic rather than
1194
- * delegating to `executeToolHandler`.
1195
- */
1196
- private executeWildcardTool;
1197
- /**
1198
- * Programmatically execute a registered frontend tool without going through an LLM turn.
1199
- * The handler runs, render components show up in the UI, and both the tool call and
1200
- * result messages are added to `agent.messages`.
1201
- */
1202
- runTool(params: CopilotKitCoreRunToolParams): Promise<CopilotKitCoreRunToolResult>;
1203
- /** Stable identity for a tool override: agent-scope + name (NUL-separated). */
1204
- private capabilityKey;
1205
- /**
1206
- * Enable/disable a registered frontend tool at runtime without unregistering
1207
- * it. A disabled tool is omitted from {@link buildFrontendTools}, so the agent
1208
- * never receives it. Unlike the per-tool `available` flag, this override
1209
- * survives the tool being re-registered.
1210
- */
1211
- setToolEnabled(name: string, enabled: boolean, agentId?: string): void;
1212
- /** Whether a tool is currently enabled (not overridden off). Defaults true. */
1213
- isToolEnabled(name: string, agentId?: string): boolean;
1214
- /**
1215
- * Build frontend tools for an agent
1216
- */
1217
- buildFrontendTools(agentId?: string): Tool[];
1218
- /**
1219
- * Reconcile the WebMCP registrations with the current tool registry. Tools
1220
- * opt in via `webmcp: true` or `webmcp: { annotations }`; the same
1221
- * availability rules as `buildFrontendTools` apply. WebMCP tools are
1222
- * page-level, so unlike the agent tool list they are not filtered by
1223
- * agentId — a name collision across agentIds keeps the first registration.
1224
- */
1225
- private syncWebMCP;
1226
- /**
1227
- * Create an agent error subscriber
1228
- */
1229
- private createAgentErrorSubscriber;
1230
- }
1231
- /**
1232
- * Ensures parsed tool arguments are a plain object.
1233
- * Throws for non-object values so the caller's catch block can emit
1234
- * a structured TOOL_ARGUMENT_PARSE_FAILED error.
1235
- *
1236
- * @internal Exported for testing only.
1237
- */
1238
- declare function ensureObjectArgs(parsed: unknown, toolName: string): Record<string, unknown>;
1239
- /**
1240
- * Parses raw tool call arguments into a validated object.
1241
- *
1242
- * Some LLM providers (e.g. @ai-sdk/openai-compatible) may send empty string "",
1243
- * null, or undefined instead of "{}". This function normalises those cases to an
1244
- * empty object so callers don't crash on JSON.parse("").
1245
- *
1246
- * A debug-level warning is emitted when the fallback triggers so silent coercion
1247
- * is observable in logs.
1248
- *
1249
- * @internal Exported for testing only.
1250
- */
1251
- declare function parseToolArguments(rawArgs: unknown, toolName: string): Record<string, unknown>;
1252
- //#endregion
1253
- //#region src/utils/micro-redux.d.ts
1254
- /**
1255
- * The minimal action shape used by this micro-redux implementation.
1256
- */
1257
- interface AnyAction {
1258
- type: string;
1259
- }
1260
- /**
1261
- * A typed action creator function with a `type` literal and runtime matcher.
1262
- */
1263
- type ActionCreator<Type extends string, Args extends unknown[] = unknown[], Action extends AnyAction & {
1264
- type: Type;
1265
- } = {
1266
- type: Type;
1267
- }> = ((...args: Args) => Action) & {
1268
- type: Type;
1269
- match(action: AnyAction): action is Action;
1270
- };
1271
- /**
1272
- * Extracts the action type produced by an action creator.
1273
- */
1274
- type ActionFromCreator<T> = T extends ((...args: any[]) => infer A) ? A : never;
1275
- /**
1276
- * Extracts a union of actions produced by a tuple/array of action creators.
1277
- */
1278
- type ActionFromCreators<Creators extends readonly ActionCreator<string, any[], any>[]> = ActionFromCreator<Creators[number]>;
1279
- /**
1280
- * A reducer transforms state in response to actions.
1281
- */
1282
- type Reducer<State, Action extends AnyAction = AnyAction> = (state: State | undefined, action: Action) => State;
1283
- /**
1284
- * A selector derives a value from state.
1285
- */
1286
- type Selector<State, Result> = (state: State) => Result;
1287
- /**
1288
- * Marker config for action creators that accept no payload.
1289
- */
1290
- interface EmptyActionConfig {
1291
- readonly kind: "empty";
1292
- }
1293
- declare const PROPS_MARKER: unique symbol;
1294
- /**
1295
- * Marker config for action creators that require payload props.
1296
- */
1297
- interface PropsActionConfig<Props extends Record<string, unknown>> {
1298
- readonly kind: "props";
1299
- readonly [PROPS_MARKER]?: Props;
1300
- }
1301
- /**
1302
- * Supported action creator config node in an action group.
1303
- */
1304
- type ActionConfig = EmptyActionConfig | PropsActionConfig<Record<string, unknown>>;
1305
- /**
1306
- * Shape of an action group declaration object.
1307
- */
1308
- type ActionGroupConfig = Record<string, ActionConfig>;
1309
- /**
1310
- * Maps an action group declaration to a strongly typed action-creator object.
1311
- */
1312
- type ActionGroupResult<Source extends string, Config extends ActionGroupConfig> = { [K in keyof Config & string]: Config[K] extends PropsActionConfig<infer P> ? ActionCreator<`[${Source}] ${K}`, [P], {
1313
- type: `[${Source}] ${K}`;
1314
- } & P> : ActionCreator<`[${Source}] ${K}`, [], {
1315
- type: `[${Source}] ${K}`;
1316
- }> };
1317
- interface OnReducerEntry<State, Action extends AnyAction = AnyAction, Creators extends readonly ActionCreator<string, any[], any>[] = readonly ActionCreator<string, any[], any>[]> {
1318
- creators: Creators;
1319
- reducer: (state: State, action: Action) => State;
1320
- }
1321
- type ActionFromOnReducerEntry<TEntry> = TEntry extends OnReducerEntry<any, infer TAction, any> ? TAction : never;
1322
- /**
1323
- * Effect contract for streams that emit actions to dispatch.
1324
- */
1325
- interface DispatchingEffect<State, InputAction extends AnyAction = AnyAction, OutputAction extends AnyAction = AnyAction> {
1326
- run: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<OutputAction>;
1327
- dispatch: true;
1328
- }
1329
- /**
1330
- * Effect contract for side-effect-only streams whose emissions are ignored.
1331
- */
1332
- interface NonDispatchingEffect<State, InputAction extends AnyAction = AnyAction> {
1333
- run: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<unknown>;
1334
- dispatch: false;
1335
- }
1336
- /**
1337
- * Union of supported effect shapes.
1338
- */
1339
- type Effect<State, InputAction extends AnyAction = AnyAction, OutputAction extends AnyAction = AnyAction> = DispatchingEffect<State, InputAction, OutputAction> | NonDispatchingEffect<State, InputAction>;
1340
- /**
1341
- * Lifecycle actions dispatched by the store.
1342
- */
1343
- type StoreLifecycleAction = {
1344
- type: "@@micro-redux/init";
1345
- } | {
1346
- type: "@@micro-redux/stop";
1347
- };
1348
- /**
1349
- * Options for a dispatching effect.
1350
- */
1351
- interface DispatchingEffectOptions {
1352
- dispatch?: true;
1353
- }
1354
- /**
1355
- * Options for a non-dispatching effect.
1356
- */
1357
- interface NonDispatchingEffectOptions {
1358
- dispatch: false;
1359
- }
1360
- /**
1361
- * Declares a payload-based action config for `createActionGroup`.
1362
- *
1363
- * @example
1364
- * ```ts
1365
- * const actions = createActionGroup("User", {
1366
- * loaded: props<{ id: string }>(),
1367
- * });
1368
- * ```
1369
- */
1370
- declare function props<Props extends Record<string, unknown>>(): PropsActionConfig<Props>;
1371
- /**
1372
- * Declares a no-payload action config for `createActionGroup`.
1373
- *
1374
- * @example
1375
- * ```ts
1376
- * const actions = createActionGroup("User", {
1377
- * reset: empty(),
1378
- * });
1379
- * ```
1380
- */
1381
- declare function empty(): EmptyActionConfig;
1382
- /**
1383
- * Creates a namespaced group of typed action creators.
1384
- *
1385
- * Action types are formatted as: `[Source] actionName`.
1386
- */
1387
- declare function createActionGroup<const Source extends string, const Config extends ActionGroupConfig>(source: Source, config: Config): ActionGroupResult<Source, Config>;
1388
- /**
1389
- * Registers one reducer handler for one or more action creators.
1390
- *
1391
- * @throws Error when called without at least one action creator and reducer.
1392
- */
1393
- declare function on<State, const Creators extends readonly ActionCreator<string, any[], any>[], Action extends ActionFromCreators<Creators>>(...args: [...creators: Creators, reducer: (state: State, action: Action) => State]): OnReducerEntry<State, Action, Creators>;
1394
- /**
1395
- * Creates a reducer from an initial state and `on(...)` handler entries.
1396
- *
1397
- * Unknown action types return the current state unchanged.
1398
- */
1399
- declare function createReducer<State, const Entries extends readonly OnReducerEntry<any, any, any>[]>(initialState: State, ...entries: Entries): Reducer<State, ActionFromOnReducerEntry<Entries[number]>>;
1400
- /**
1401
- * Creates a memoized selector from a single projector.
1402
- */
1403
- declare function createSelector<State, Result>(projector: (state: State) => Result): Selector<State, Result>;
1404
- /**
1405
- * Creates a memoized selector from input selectors and a projector.
1406
- *
1407
- * Memoization uses one-entry caching over the latest input selector values.
1408
- */
1409
- declare function createSelector<State, const Selectors extends readonly Selector<State, unknown>[], Result>(...args: [...selectors: Selectors, projector: (...inputs: { [K in keyof Selectors]: ReturnType<Selectors[K]> }) => Result]): Selector<State, Result>;
1410
- /**
1411
- * RxJS operator that maps state emissions through a selector and suppresses
1412
- * unchanged projected values via reference equality.
1413
- */
1414
- declare function select<State, Result>(selector: Selector<State, Result>): OperatorFunction<State, Result>;
1415
- /**
1416
- * RxJS operator that filters an action stream by action creators and narrows
1417
- * the output action type to the matched creator union.
1418
- *
1419
- * @throws Error when called without at least one action creator.
1420
- */
1421
- declare function ofType<const Creators extends readonly ActionCreator<string, any[], AnyAction>[]>(...creators: Creators): OperatorFunction<AnyAction, ActionFromCreators<Creators>>;
1422
- /**
1423
- * Creates a dispatching effect. Emitted actions are automatically dispatched.
1424
- */
1425
- declare function createEffect<State, InputAction extends AnyAction, OutputAction extends AnyAction>(factory: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<OutputAction>, options?: DispatchingEffectOptions): DispatchingEffect<State, InputAction, OutputAction>;
1426
- /**
1427
- * Creates a non-dispatching effect. Emitted values are ignored.
1428
- */
1429
- declare function createEffect<State, InputAction extends AnyAction>(factory: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<unknown>, options: NonDispatchingEffectOptions): NonDispatchingEffect<State, InputAction>;
1430
- /**
1431
- * Store interface returned by `createStore`.
1432
- */
1433
- interface Store<State, Action extends AnyAction = AnyAction> {
1434
- dispatch(action: Action): void;
1435
- getState(): State;
1436
- readonly state$: Observable<State>;
1437
- readonly actions$: Observable<Action | StoreLifecycleAction>;
1438
- select<Result>(selector: Selector<State, Result>): Observable<Result>;
1439
- init(): void;
1440
- stop(): void;
1441
- }
1442
- /**
1443
- * Creates a small observable store with reducer + effects.
1444
- *
1445
- * Behavior:
1446
- * - `init()` starts effects and dispatches `@@micro-redux/init`.
1447
- * - `stop()` dispatches `@@micro-redux/stop` and unsubscribes all effects.
1448
- * - Effect action observation is scheduled on `asapScheduler` to avoid
1449
- * synchronous re-entrancy in the effect loop.
1450
- * - Any effect error triggers fail-fast teardown and errors both `actions$`
1451
- * and `state$`.
1452
- */
1453
- declare function createStore<State, Action extends AnyAction = AnyAction>(options: {
1454
- reducer: Reducer<State, Action | StoreLifecycleAction>;
1455
- effects?: Array<Effect<State, Action | StoreLifecycleAction, Action>>;
1456
- }): Store<State, Action>;
1457
- //#endregion
1458
- //#region src/threads.d.ts
1459
- interface ThreadRecord {
1460
- id: string;
1461
- organizationId: string;
1462
- agentId: string;
1463
- createdById: string;
1464
- name: string | null;
1465
- archived: boolean;
1466
- createdAt: string;
1467
- updatedAt: string;
1468
- lastRunAt?: string;
1469
- }
1470
- interface ThreadRuntimeContext {
1471
- runtimeUrl: string;
1472
- /**
1473
- * Optional: `environment.fetch` is expected to be `ɵruntimeFetch`, which
1474
- * already resolves and overlays the current core headers at send time
1475
- * (#1937). Set explicitly only when the store's `fetch` does NOT already
1476
- * carry headers.
1477
- */
1478
- headers?: Record<string, string>;
1479
- wsUrl?: string;
1480
- agentId: string;
1481
- includeArchived?: boolean;
1482
- limit?: number;
1483
- }
1484
- type ThreadMetadataEvent = {
1485
- operation: "created" | "renamed" | "archived" | "unarchived" | "updated";
1486
- threadId: string;
1487
- userId: string;
1488
- organizationId: string;
1489
- occurredAt: string;
1490
- thread: ThreadRecord;
1491
- } | {
1492
- operation: "deleted";
1493
- threadId: string;
1494
- userId: string;
1495
- organizationId: string;
1496
- occurredAt: string;
1497
- deleted: {
1498
- id: string;
1499
- };
1500
- };
1501
- /**
1502
- * Internal notification emitted when Intelligence observes new run activity
1503
- * for a thread without changing that thread's metadata row.
1504
- */
1505
- type ThreadRunActivityNotification = {
1506
- type: "thread_run_activity";
1507
- threadId: string;
1508
- agentId?: string;
1509
- runId?: string;
1510
- eventType: string;
1511
- latestEventId?: string;
1512
- };
1513
- interface ThreadEnvironment {
1514
- fetch: typeof fetch;
1515
- /**
1516
- * Optional callback invoked whenever a thread mutation (rename, archive,
1517
- * unarchive, delete) is rejected by the server. Lets framework wrappers
1518
- * surface a transient error toast without subscribing to the error
1519
- * selector. The error is also recorded in `state.error` regardless.
1520
- *
1521
- * Fired after any rollback (delete) has been applied to local state.
1522
- */
1523
- onError?: (error: Error) => void;
1524
- }
1525
- interface ThreadState {
1526
- threads: ThreadRecord[];
1527
- isLoading: boolean;
1528
- isFetchingNextPage: boolean;
1529
- error: Error | null;
1530
- /**
1531
- * Error from the most recent failed next-page (`fetchMore`) load, or `null`.
1532
- * Tracked SEPARATELY from `error` so a paginated-load failure surfaces an
1533
- * inline "couldn't load more" affordance without replacing the already-loaded
1534
- * list with a full-panel error. Cleared when a fetch-more is retried or when
1535
- * one succeeds; reset on context change / stop.
1536
- */
1537
- fetchMoreError: Error | null;
1538
- context: ThreadRuntimeContext | null;
1539
- sessionId: number;
1540
- metadataCredentialsRequested: boolean;
1541
- metadataJoinCode: string | null;
1542
- nextCursor: string | null;
1543
- /** Number of thread mutations currently awaiting a server response. */
1544
- inFlightMutationCount: number;
1545
- /**
1546
- * Rows optimistically removed by an in-flight `delete`, keyed by the
1547
- * originating request id. DELETE is the one mutation that rolls back on
1548
- * rejection, so the removed row is parked here and restored if the server
1549
- * rejects. Rename/archive/unarchive are optimistic no-rollback and do not
1550
- * populate this map.
1551
- */
1552
- pendingDeletes: Record<string, ThreadRecord>;
1553
- }
1554
- /**
1555
- * The set of memoized thread selectors bound to a single store instance.
1556
- *
1557
- * @see createThreadSelectors
1558
- */
1559
- interface ThreadSelectors {
1560
- threads: (state: ThreadState) => ThreadRecord[];
1561
- isLoading: (state: ThreadState) => boolean;
1562
- error: (state: ThreadState) => Error | null;
1563
- fetchMoreError: (state: ThreadState) => Error | null;
1564
- hasNextPage: (state: ThreadState) => boolean;
1565
- isFetchingNextPage: (state: ThreadState) => boolean;
1566
- isMutating: (state: ThreadState) => boolean;
1567
- }
1568
- /**
1569
- * Builds a fresh set of memoized thread selectors.
1570
- *
1571
- * Each `createSelector` closure owns a private one-entry cache. Sharing a
1572
- * single module-level selector instance across multiple concurrent stores
1573
- * (e.g. a `<CopilotThreadsDrawer>` plus an independent `useThreads`) makes every
1574
- * cross-store emission a cache miss, defeating memoization and risking
1575
- * emission instability for any future selector that allocates a new
1576
- * object/array. Creating a per-store instance keeps each store's cache
1577
- * isolated so concurrent stores never thrash one another.
1578
- */
1579
- declare function createThreadSelectors(): ThreadSelectors;
1580
- interface ThreadStore {
1581
- start(): void;
1582
- stop(): void;
1583
- setContext(context: ThreadRuntimeContext | null): void;
1584
- /** Re-fetches the thread list without resetting the current list to empty. */
1585
- refresh(): void;
1586
- /**
1587
- * Re-fetches the thread list without resetting the current list to empty.
1588
- *
1589
- * Public, design-named alias of {@link refresh} used by the drawer's
1590
- * error-state Retry affordance and the Active/All filter-change refetch.
1591
- */
1592
- refetchThreads(): void;
1593
- /**
1594
- * Resets to a fresh, client-side thread so the welcome screen can show.
1595
- *
1596
- * Lazy creation: no phantom row is added to the list — the new thread only
1597
- * materializes once its first run persists server-side. This is distinct
1598
- * from selecting an existing thread (which the wrapper marks *explicit*,
1599
- * suppressing the welcome screen): the thread produced here is NOT explicit.
1600
- */
1601
- startNewThread(): void;
1602
- fetchNextPage(): void;
1603
- renameThread(threadId: string, name: string): Promise<void>;
1604
- archiveThread(threadId: string): Promise<void>;
1605
- unarchiveThread(threadId: string): Promise<void>;
1606
- deleteThread(threadId: string): Promise<void>;
1607
- /**
1608
- * Subscribes to synthetic run-activity notifications without changing the
1609
- * thread metadata list.
1610
- */
1611
- subscribeToRunActivity?(callback: (notification: ThreadRunActivityNotification) => void): Subscription;
1612
- getState(): ThreadState;
1613
- /**
1614
- * Returns a stable initial snapshot for server-side rendering.
1615
- *
1616
- * `useSyncExternalStore` requires a `getServerSnapshot` during SSR/prerender
1617
- * (e.g. Next.js); without one React throws "Missing getServerSnapshot". The
1618
- * returned reference is stable across calls so React does not loop. There is
1619
- * no client-side thread data during prerender, so this is the empty initial
1620
- * state.
1621
- */
1622
- getServerState(): ThreadState;
1623
- select: Store<ThreadState>["select"];
1624
- /**
1625
- * Memoized selectors bound to THIS store instance.
1626
- *
1627
- * Subscriptions should pass these to {@link select} (e.g.
1628
- * `store.select(store.selectors.threads)`) so each store keeps its own
1629
- * one-entry memo cache. Sharing the module-level singletons across
1630
- * concurrent stores defeats memoization and risks emission instability.
1631
- */
1632
- selectors: ThreadSelectors;
1633
- }
1634
- declare function createThreadStore(environment: ThreadEnvironment): ThreadStore;
1635
- type ɵThread = ThreadRecord;
1636
- type ɵThreadRuntimeContext = ThreadRuntimeContext;
1637
- type ɵThreadMetadataEvent = ThreadMetadataEvent;
1638
- type ɵThreadEnvironment = ThreadEnvironment;
1639
- type ɵThreadStore = ThreadStore;
1640
- type ɵThreadSelectors = ThreadSelectors;
1641
- declare const ɵthreadAdapterEvents: ActionGroupResult<"Thread Adapter", {
1642
- readonly started: EmptyActionConfig;
1643
- readonly stopped: EmptyActionConfig;
1644
- readonly contextChanged: PropsActionConfig<{
1645
- context: ThreadRuntimeContext | null;
1646
- }>;
1647
- readonly fetchNextPageRequested: EmptyActionConfig;
1648
- readonly renameRequested: PropsActionConfig<{
1649
- requestId: string;
1650
- threadId: string;
1651
- name: string;
1652
- }>;
1653
- readonly archiveRequested: PropsActionConfig<{
1654
- requestId: string;
1655
- threadId: string;
1656
- }>;
1657
- readonly unarchiveRequested: PropsActionConfig<{
1658
- requestId: string;
1659
- threadId: string;
1660
- }>;
1661
- readonly deleteRequested: PropsActionConfig<{
1662
- requestId: string;
1663
- threadId: string;
1664
- }>;
1665
- readonly newThreadStarted: EmptyActionConfig;
1666
- }>;
1667
- declare const ɵcreateThreadSelectors: typeof createThreadSelectors;
1668
- declare const ɵselectThreads: (state: ThreadState) => ThreadRecord[];
1669
- declare const ɵselectThreadsIsLoading: (state: ThreadState) => boolean;
1670
- declare const ɵselectThreadsError: (state: ThreadState) => Error | null;
1671
- declare const ɵselectFetchMoreError: (state: ThreadState) => Error | null;
1672
- declare const ɵselectHasNextPage: (state: ThreadState) => boolean;
1673
- declare const ɵselectIsFetchingNextPage: (state: ThreadState) => boolean;
1674
- declare const ɵselectIsMutating: (state: ThreadState) => boolean;
1675
- /**
1676
- * Number of consecutive WebSocket connection failures after which the
1677
- * threads channel tears itself down rather than retrying indefinitely.
1678
- * Exposed for tests so they can assert teardown semantics without
1679
- * hardcoding the threshold separately from production.
1680
- */
1681
- declare const ɵMAX_SOCKET_RETRIES = 5;
1682
- /**
1683
- * How long a thread REST request is given before the store gives up on it.
1684
- * Exposed for tests for the same reason as {@link ɵMAX_SOCKET_RETRIES}: a
1685
- * separately hardcoded copy silently drifts away from this one.
1686
- */
1687
- declare const ɵTHREAD_REQUEST_TIMEOUT_MS = 15000;
1688
- //#endregion
1689
- //#region src/core/generative-ui-debug.d.ts
1690
- /** @internal One declared function of the generative UI, for the inspector. */
1691
- interface ɵGenerativeUIDebugFunction {
1692
- description?: string;
1693
- parameters: GenerativeUIJSONSchema;
1694
- /** How many `useGenerativeUIFunction` handlers are mounted. Only 1 is valid. */
1695
- handlers: number;
1696
- }
1697
- /** @internal One surface that the browser holds, for the inspector. */
1698
- interface ɵGenerativeUIDebugSurface {
1699
- surfaceId: string;
1700
- threadId: string;
1701
- agentId: string | undefined;
1702
- target: string;
1703
- status: GenerativeUISurfaceStatus;
1704
- /** The committed operations, in order. The browser can still reject some. */
1705
- operations: readonly A2UIOperation[];
1706
- /** The current data model. */
1707
- dataModel: unknown;
1708
- /** The values that the user wrote, by path. Agent writes to them are ignored. */
1709
- userValues: Record<string, unknown>;
1710
- rejected: Array<GenerativeUIRejectedOperation & {
1711
- source: "runtime" | "browser";
1712
- }>;
1713
- }
1714
- /** @internal One part of the text that a run adds to the prompt of the model. */
1715
- interface ɵGenerativeUIDebugPromptSection {
1716
- title: string;
1717
- /** Who adds the text to the prompt. */
1718
- source: "runtime" | "context" | "backend";
1719
- text: string;
1720
- }
1721
- /** @internal What one run sends, or what the next run will send. */
1722
- interface ɵGenerativeUIDebugRun {
1723
- agentId: string | undefined;
1724
- threadId: string | undefined;
1725
- /** When the run started. Left out for the next run. */
1726
- startedAt?: number;
1727
- /** `forwardedProps.copilotkit.ui` of the run. */
1728
- envelope: CopilotKitUIEnvelope;
1729
- prompt: ɵGenerativeUIDebugPromptSection[];
1730
- }
1731
- /** @internal The state of a generative UI, for the inspector. */
1732
- interface ɵGenerativeUIDebugSnapshot {
1733
- catalogId: string;
1734
- transport: "tool" | "markdown";
1735
- /** The agents that get the generative UI. Left out: every agent. */
1736
- agentIds?: string[];
1737
- components: Record<string, GenerativeUIComponentManifest>;
1738
- /** The id of the catalog that declared each component, by name. */
1739
- componentCatalogs: Record<string, string>;
1740
- functions: Record<string, ɵGenerativeUIDebugFunction>;
1741
- /** The app state that bound props read, by key. */
1742
- state: Record<string, unknown>;
1743
- /** The chat first, then each mounted `<GenerativeUISurface>`. */
1744
- targets: GenerativeUITarget[];
1745
- activeThreadId: string | undefined;
1746
- surfaces: ɵGenerativeUIDebugSurface[];
1747
- lastRun: ɵGenerativeUIDebugRun | undefined;
1748
- nextRun: ɵGenerativeUIDebugRun;
1749
- }
1750
- /**
1751
- * @internal What a framework package (react-core) gives core, so that the
1752
- * inspector can show its generative UI. `getSnapshot` builds the snapshot
1753
- * when it is called, so a source that nobody reads costs nothing.
1754
- */
1755
- interface ɵGenerativeUIDebugSource {
1756
- getSnapshot(): ɵGenerativeUIDebugSnapshot;
1757
- /** Calls `listener` when the snapshot changes. Returns the unsubscribe. */
1758
- subscribe(listener: () => void): () => void;
1759
- }
1760
- //#endregion
1761
- //#region src/memory-errors.d.ts
1762
- /**
1763
- * Memory error registry — stable codes for the errors the memory store throws.
1764
- *
1765
- * The memory store (`memory.ts`) used to throw bare `new Error("Failed to fetch
1766
- * memories: 500")` / `"Request timed out"` / `"Request failed: <status>"`. Those
1767
- * reach the `error` selector (and the consumer UI via `useMemories` /
1768
- * `injectMemories`) verbatim, with no machine-readable `code`/`category`/
1769
- * `retryable`, so they cannot be grouped in observability or branched on by
1770
- * consumers.
1771
- *
1772
- * Per the repo's error-handling architecture standard (AGENTS.md: "Each project
1773
- * must maintain an explicit error registry"), this file is the explicit registry
1774
- * for the memory feature. It is deliberately scoped to memory — not a repo-wide
1775
- * registry refactor — because `packages/core` has no pre-existing
1776
- * code/category/retryable registry convention to plug into (the runtime's
1777
- * `lib/error-messages.ts` is a message-templating table, not a typed
1778
- * code/category/retryable registry). It mirrors the existing
1779
- * `AgentThreadLockedError extends Error` precedent in
1780
- * `intelligence-agent.ts`: a real `Error` subclass so `instanceof Error` holds
1781
- * and the public `MemoryState.error: Error | null` contract is preserved.
1782
- *
1783
- * `docsPath` is recorded per entry per the standard; there is no
1784
- * `docs/errors/<project>.md` in this repo, so this docblock plus the registry
1785
- * are the source of truth.
1786
- *
1787
- * Each registry entry carries:
1788
- * - `code`: stable identifier (e.g. `MEMORY_LIST_FAILED`).
1789
- * - `category`: one of the standard categories
1790
- * (`validation`|`auth`|`permission`|`not_found`|`conflict`|`rate_limit`|`internal`|`dependency`).
1791
- * - `retryable`: whether a retry could plausibly succeed (timeouts + transient
1792
- * dependency failures are retryable; client-caused 4xx are not).
1793
- * - `message`: the default human-readable message (callers may override with a
1794
- * status-bearing string to preserve the prior wording).
1795
- * - `docsPath`: documentation pointer for the code.
1796
- */
1797
- /** Standard error categories from the repo error-handling architecture. */
1798
- type MemoryErrorCategory = "validation" | "auth" | "permission" | "not_found" | "conflict" | "rate_limit" | "internal" | "dependency";
1799
- /** Stable codes for the memory store's surfaced errors. */
1800
- type MemoryErrorCode = "MEMORY_LIST_FAILED" | "MEMORY_RECALL_FAILED" | "MEMORY_CREDENTIALS_FAILED" | "MEMORY_MUTATION_FAILED" | "MEMORY_REQUEST_TIMEOUT";
1801
- /** A single registry entry describing one memory error code. */
1802
- interface MemoryErrorRegistryEntry {
1803
- readonly code: MemoryErrorCode;
1804
- readonly category: MemoryErrorCategory;
1805
- readonly retryable: boolean;
1806
- readonly message: string;
1807
- readonly docsPath: string;
1808
- }
1809
- /**
1810
- * The memory error registry: the single source of truth for memory error
1811
- * metadata. Keyed by `code` so a code maps to exactly one category/retryable
1812
- * default.
1813
- *
1814
- * Categories/retryable rationale:
1815
- * - List/credentials/mutation failures are `dependency` (the runtime/platform
1816
- * the store calls failed). A 5xx is transient (`retryable: true`); a 4xx is
1817
- * caller-caused, so the helpers below downgrade those to non-retryable.
1818
- * - Timeouts are `dependency` and `retryable: true` (the request may simply be
1819
- * slow).
1820
- */
1821
- declare const MEMORY_ERROR_REGISTRY: Readonly<Record<MemoryErrorCode, MemoryErrorRegistryEntry>>;
1822
- /**
1823
- * An `Error` carrying a stable memory error `code`, `category`, and `retryable`
1824
- * flag so consumers and observability can branch on it without string-matching
1825
- * the message.
1826
- *
1827
- * It is a real `Error` subclass: `instanceof Error` is true, so the public
1828
- * `MemoryState.error: Error | null` contract (and the `error: Error | null`
1829
- * surfaced by `useMemories` / `injectMemories`) holds unchanged. Existing
1830
- * consumers that only read `.message` keep working; the richer fields are
1831
- * additive.
1832
- */
1833
- declare class MemoryError extends Error {
1834
- /** Stable, machine-readable error identifier. */
1835
- readonly code: MemoryErrorCode;
1836
- /** Coarse error category for grouping/observability. */
1837
- readonly category: MemoryErrorCategory;
1838
- /** Whether retrying the operation could plausibly succeed. */
1839
- readonly retryable: boolean;
1840
- /**
1841
- * @param code - Registry code identifying this error.
1842
- * @param options - Optional overrides:
1843
- * - `message`: human-readable message (defaults to the registry message;
1844
- * callers pass a status-bearing string to preserve prior wording).
1845
- * - `retryable`: overrides the registry default (e.g. a 4xx list failure is
1846
- * not retryable even though the code's default is).
1847
- * - `cause`: the underlying error, preserved for debugging.
1848
- */
1849
- constructor(code: MemoryErrorCode, options?: {
1850
- message?: string;
1851
- retryable?: boolean;
1852
- cause?: unknown;
1853
- });
1854
- }
1855
- /**
1856
- * Narrows an HTTP status to whether the failure is worth retrying: a 5xx (or a
1857
- * missing/0 status) is a transient dependency failure and retryable; a 4xx is
1858
- * caller-caused and not. Used so a `MEMORY_LIST_FAILED`/`MEMORY_MUTATION_FAILED`
1859
- * carries an accurate `retryable` flag derived from the response status.
1860
- */
1861
- declare function isRetryableStatus(status: number): boolean;
1862
- //#endregion
1863
- //#region src/memory.d.ts
1864
- /** Public, customer-facing memory kind vocabulary (single taxonomy, no mapping). */
1865
- type MemoryKind = "topical" | "episodic" | "operational";
1866
- /** Visibility scope of a memory. */
1867
- type MemoryScope = "user" | "project";
1868
- /**
1869
- * Health of the realtime (`user_meta:memories:<code>`) connection that streams
1870
- * live `memory_metadata` deltas. Distinct from `available`/`error`, which
1871
- * describe the REST list route: `realtimeStatus` reports ONLY whether the
1872
- * realtime socket/channel is live so the UI can stop showing a "live" indicator
1873
- * over a frozen snapshot once the socket permanently gives up.
1874
- *
1875
- * - `"connecting"` — fetching join credentials / opening the socket / joining
1876
- * the channel (the default, and the state every `contextChanged`/`stopped`
1877
- * resets to).
1878
- * - `"connected"` — the channel join succeeded; live deltas are flowing.
1879
- * - `"unavailable"` — the socket exhausted its retries or the join failed
1880
- * permanently; the snapshot is frozen and no deltas will arrive. This is a
1881
- * silent degrade for `available`/`error` (those stay untouched) — only this
1882
- * signal flips.
1883
- */
1884
- type MemoryRealtimeStatus = "connecting" | "connected" | "unavailable";
1885
- /**
1886
- * A memory as projected across the public REST/realtime boundary — the minimal
1887
- * shape the SDK surfaces. Mirrors the server's `PublicMemory` projection.
1888
- */
1889
- interface Memory {
1890
- id: string;
1891
- kind: MemoryKind;
1892
- scope: MemoryScope;
1893
- content: string;
1894
- sourceThreadIds: readonly string[];
1895
- invalidatedAt: string | null;
1896
- /** Relevance score from a `recall()` (hybrid RAG) query; `undefined` for list/realtime/mutation memories. */
1897
- score?: number;
1898
- }
1899
- /** Input for creating a memory; `scope` defaults to `"user"` (v1 is user-scoped). */
1900
- interface NewMemory {
1901
- content: string;
1902
- kind: MemoryKind;
1903
- scope?: MemoryScope;
1904
- sourceThreadIds?: readonly string[];
1905
- }
1906
- /**
1907
- * New values for superseding (updating) a memory — same shape as create.
1908
- *
1909
- * Supersede is a FULL replacement, not a partial patch: this is the complete
1910
- * definition of the new memory that replaces the old one. `content` and `kind`
1911
- * are required and must be re-supplied, and an omitted `sourceThreadIds` resets
1912
- * the new memory's source threads to `[]` — it does NOT preserve the prior
1913
- * memory's value.
1914
- */
1915
- type MemoryChanges = NewMemory;
1916
- /** Outcome of a mutation, tracked so the caller's promise resolves/rejects. */
1917
- type MemoryMutationOutcome = {
1918
- requestId: string;
1919
- sessionId: number;
1920
- ok: true;
1921
- memory: Memory | null;
1922
- } | {
1923
- requestId: string;
1924
- sessionId: number;
1925
- ok: false;
1926
- error: Error;
1927
- };
1928
- /**
1929
- * Runtime wiring for the memory store: where to reach the REST surface and the
1930
- * headers (auth + `X-Cpki-User-Id`) to send. Scoped to the current user; v1
1931
- * surfaces user-scoped memories only.
1932
- */
1933
- interface MemoryRuntimeContext {
1934
- runtimeUrl: string;
1935
- /** WebSocket URL for the realtime gateway (e.g. `wss://gw.example.com/client`). */
1936
- wsUrl: string;
1937
- /**
1938
- * Optional: `environment.fetch` is expected to be `ɵruntimeFetch`, which
1939
- * already resolves and overlays the current core headers at send time
1940
- * (#1937). Set explicitly only when the store's `fetch` does NOT already
1941
- * carry headers.
1942
- */
1943
- headers?: Record<string, string>;
1944
- includeInvalidated?: boolean;
1945
- }
1946
- /**
1947
- * In-memory state for the memory store. Session-guarded like the thread store:
1948
- * `sessionId` is bumped whenever the runtime context changes so that responses
1949
- * and realtime deltas from a previous context are ignored.
1950
- */
1951
- interface MemoryState {
1952
- memories: Memory[];
1953
- isLoading: boolean;
1954
- inFlightMutationCount: number;
1955
- error: Error | null;
1956
- context: MemoryRuntimeContext | null;
1957
- sessionId: number;
1958
- available: boolean;
1959
- realtimeStatus: MemoryRealtimeStatus;
1960
- }
1961
- declare const memoryDomainEvents: ActionGroupResult<"Memory Domain", {
1962
- readonly memoryUpserted: PropsActionConfig<{
1963
- sessionId: number;
1964
- memory: Memory;
1965
- }>;
1966
- readonly memoryInvalidated: PropsActionConfig<{
1967
- sessionId: number;
1968
- memoryId: string;
1969
- }>;
1970
- readonly realtimeConnecting: PropsActionConfig<{
1971
- sessionId: number;
1972
- }>;
1973
- readonly realtimeConnected: PropsActionConfig<{
1974
- sessionId: number;
1975
- }>;
1976
- readonly realtimeUnavailable: PropsActionConfig<{
1977
- sessionId: number;
1978
- }>;
1979
- }>;
1980
- /** Wire shape of a memory inside a `memory_metadata` payload (carries tenant ids). */
1981
- interface MemoryMetadataPayloadMemory extends Memory {
1982
- organizationId: string;
1983
- projectId: string;
1984
- }
1985
- /**
1986
- * The realtime `memory_metadata` event broadcast on a memory channel:
1987
- * `created`/`updated` carry the full memory, `invalidated` carries only its id.
1988
- * The same wire shape is delivered on both the user channel
1989
- * (`user_meta:memories:<code>`, current user's memories) and the optional
1990
- * project channel (`project_meta:memories:<code>`, memories shared across the
1991
- * project); the store reduces both into one id-keyed list.
1992
- */
1993
- type MemoryMetadataEvent = {
1994
- operation: "created" | "updated";
1995
- memoryId: string;
1996
- organizationId: string;
1997
- projectId: string;
1998
- occurredAt: string;
1999
- memory: MemoryMetadataPayloadMemory;
2000
- } | {
2001
- operation: "invalidated";
2002
- memoryId: string;
2003
- organizationId: string;
2004
- projectId: string;
2005
- occurredAt: string;
2006
- invalidated: {
2007
- id: string;
2008
- };
2009
- };
2010
- /**
2011
- * Maps a realtime `memory_metadata` event to the domain action that applies it:
2012
- * `created`/`updated` upsert the projected memory, `invalidated` removes it by
2013
- * id. Carries the current `sessionId` so the reducer's session guard can drop
2014
- * deltas left over from a previous context.
2015
- */
2016
- declare function mapMemoryMetadataEvent(event: MemoryMetadataEvent, sessionId: number): ReturnType<typeof memoryDomainEvents.memoryUpserted> | ReturnType<typeof memoryDomainEvents.memoryInvalidated>;
2017
- /**
2018
- * Dependencies injected into the memory store. The store opens its own
2019
- * `user_meta:memories:<joinCode>` socket/channel and does not share the
2020
- * thread store's socket, so only a `fetch` implementation is required.
2021
- */
2022
- interface MemoryEnvironment {
2023
- fetch: typeof fetch;
2024
- }
2025
- interface MemoryStore {
2026
- start(): void;
2027
- stop(): void;
2028
- setContext(context: MemoryRuntimeContext | null): void;
2029
- /**
2030
- * Re-fetches the REST snapshot without clearing the current list. Resolves
2031
- * once the re-pull settles (success or failure) for the current context, so
2032
- * callers (e.g. a `useMemories` `refresh()`) can await it. Resolves
2033
- * immediately when no context is set.
2034
- */
2035
- refresh(): Promise<void>;
2036
- /**
2037
- * Semantically recalls memories via `POST {runtimeUrl}/memories/recall`
2038
- * (hybrid RAG). Returns memories ordered by relevance, each carrying a
2039
- * `score`. Does NOT mutate the snapshot — a one-shot query. Rejects when no
2040
- * context is set or the request fails.
2041
- */
2042
- recall(query: string, opts?: {
2043
- limit?: number;
2044
- scope?: MemoryScope;
2045
- }): Promise<Memory[]>;
2046
- /** Creates a memory; resolves to the stored memory (server-authoritative). */
2047
- addMemory(input: NewMemory): Promise<Memory>;
2048
- /** Supersedes a memory; resolves to the new memory (its id changes). */
2049
- updateMemory(id: string, changes: MemoryChanges): Promise<Memory>;
2050
- /** Retires a memory (non-lossy delete). */
2051
- removeMemory(id: string): Promise<void>;
2052
- getState(): MemoryState;
2053
- /**
2054
- * Stable, render-safe state for SSR/prerender. React's
2055
- * `useSyncExternalStore` requires a `getServerSnapshot` during SSR/prerender
2056
- * (e.g. Next.js); without one React throws "Missing getServerSnapshot". The
2057
- * returned reference is stable across calls so React does not loop. There is
2058
- * no client-side memory data during prerender, so this is the empty initial
2059
- * state (no memories, not loading, no error).
2060
- */
2061
- getServerState(): MemoryState;
2062
- select: Store<MemoryState>["select"];
2063
- }
2064
- /**
2065
- * Creates the framework-agnostic memory store: a REST snapshot on `setContext`,
2066
- * server-authoritative add/update/remove mutations, and realtime
2067
- * `memory_metadata` deltas off the injected `user_meta` event source — all
2068
- * reduced into observable state.
2069
- */
2070
- declare function createMemoryStore(environment: MemoryEnvironment): MemoryStore;
2071
- type ɵMemoryState = MemoryState;
2072
- type ɵMemoryRuntimeContext = MemoryRuntimeContext;
2073
- type ɵMemoryMetadataEvent = MemoryMetadataEvent;
2074
- type ɵMemoryEnvironment = MemoryEnvironment;
2075
- type ɵMemoryStore = MemoryStore;
2076
- declare const ɵmemoryAdapterEvents: ActionGroupResult<"Memory Adapter", {
2077
- readonly started: EmptyActionConfig;
2078
- readonly stopped: EmptyActionConfig;
2079
- readonly contextChanged: PropsActionConfig<{
2080
- context: MemoryRuntimeContext | null;
2081
- }>;
2082
- readonly addRequested: PropsActionConfig<{
2083
- requestId: string;
2084
- input: NewMemory;
2085
- }>;
2086
- readonly updateRequested: PropsActionConfig<{
2087
- requestId: string;
2088
- id: string;
2089
- changes: MemoryChanges;
2090
- }>;
2091
- readonly removeRequested: PropsActionConfig<{
2092
- requestId: string;
2093
- id: string;
2094
- }>;
2095
- }>;
2096
- declare const ɵmemoryRestEvents: ActionGroupResult<"Memory REST", {
2097
- readonly listRequested: PropsActionConfig<{
2098
- sessionId: number;
2099
- }>;
2100
- readonly listSucceeded: PropsActionConfig<{
2101
- sessionId: number;
2102
- memories: Memory[];
2103
- }>;
2104
- readonly listFailed: PropsActionConfig<{
2105
- sessionId: number;
2106
- error: Error;
2107
- }>;
2108
- readonly listUnavailable: PropsActionConfig<{
2109
- sessionId: number;
2110
- }>;
2111
- readonly mutationFinished: PropsActionConfig<{
2112
- outcome: MemoryMutationOutcome;
2113
- }>;
2114
- readonly credentialsRequested: PropsActionConfig<{
2115
- sessionId: number;
2116
- }>;
2117
- readonly credentialsSucceeded: PropsActionConfig<{
2118
- sessionId: number;
2119
- joinToken?: string;
2120
- joinCode?: string;
2121
- projectJoinToken?: string;
2122
- projectJoinCode?: string;
2123
- }>;
2124
- readonly credentialsFailed: PropsActionConfig<{
2125
- sessionId: number;
2126
- error: Error;
2127
- }>;
2128
- readonly credentialsUnavailable: PropsActionConfig<{
2129
- sessionId: number;
2130
- }>;
2131
- }>;
2132
- declare const ɵmemoryDomainEvents: ActionGroupResult<"Memory Domain", {
2133
- readonly memoryUpserted: PropsActionConfig<{
2134
- sessionId: number;
2135
- memory: Memory;
2136
- }>;
2137
- readonly memoryInvalidated: PropsActionConfig<{
2138
- sessionId: number;
2139
- memoryId: string;
2140
- }>;
2141
- readonly realtimeConnecting: PropsActionConfig<{
2142
- sessionId: number;
2143
- }>;
2144
- readonly realtimeConnected: PropsActionConfig<{
2145
- sessionId: number;
2146
- }>;
2147
- readonly realtimeUnavailable: PropsActionConfig<{
2148
- sessionId: number;
2149
- }>;
2150
- }>;
2151
- declare const ɵmemoryReducer: Reducer<MemoryState>;
2152
- declare const ɵmapMemoryMetadataEvent: typeof mapMemoryMetadataEvent;
2153
- declare const ɵselectMemories: Selector<MemoryState, Memory[]>;
2154
- declare const ɵselectMemoriesIsLoading: Selector<MemoryState, boolean>;
2155
- declare const ɵselectMemoriesError: Selector<MemoryState, Error | null>;
2156
- declare const ɵselectMemoriesIsMutating: Selector<MemoryState, boolean>;
2157
- declare const ɵselectMemoriesAvailable: Selector<MemoryState, boolean>;
2158
- declare const ɵselectMemoriesRealtimeStatus: Selector<MemoryState, MemoryRealtimeStatus>;
2159
- //#endregion
2160
- //#region src/core/header-source.d.ts
2161
- type HeaderRecordInput = Record<string, string | null | undefined>;
2162
- /**
2163
- * What `headers` accepts: a record, a sync builder, or an async builder. A
2164
- * builder runs once per request, when the request is sent. See #1937.
2165
- */
2166
- type CopilotKitHeadersSource = HeaderRecordInput | (() => HeaderRecordInput) | (() => Promise<HeaderRecordInput>);
2167
- declare class CopilotKitHeaderResolutionError extends Error {
2168
- readonly name = "CopilotKitHeaderResolutionError";
2169
- constructor(cause: unknown);
2170
- }
2171
- /**
2172
- * Add default headers (e.g. the public API key) to a source, only where the
2173
- * source left the key unset or empty. The single shared replacement for the
2174
- * React, Vue and Angular providers' own merges.
2175
- */
2176
- declare function ɵwithHeaderDefaults(source: CopilotKitHeadersSource, defaults: Record<string, string>): CopilotKitHeadersSource;
2177
- //#endregion
2178
- //#region src/core/core.d.ts
2179
- /**
2180
- * Run properties that go only to the runs of some agents.
2181
- * See `CopilotKitCore.addScopedProperties`.
2182
- */
2183
- interface ScopedProperties {
2184
- /** The properties to merge on top of the base run properties. */
2185
- properties: Record<string, unknown>;
2186
- /** The agents that get these properties. When omitted, every agent gets them. */
2187
- agentIds?: string[];
2188
- }
2189
- /** Configuration options for `CopilotKitCore`. */
2190
- interface CopilotKitCoreConfig {
2191
- /** The endpoint of the CopilotRuntime. */
2192
- runtimeUrl?: string;
2193
- /** Transport style for CopilotRuntime endpoints. Defaults to REST. */
2194
- runtimeTransport?: CopilotRuntimeTransport;
2195
- /**
2196
- * When true, the constructor sets the runtime config but does NOT start the
2197
- * `/info` connection. Call {@link CopilotKitCore.connect} to start it —
2198
- * typically from a host's commit-phase effect. This prevents a burst of
2199
- * duplicate `/info` requests when a host constructs (and discards) the core
2200
- * during render, e.g. React concurrent rendering / Suspense / StrictMode.
2201
- * See https://github.com/CopilotKit/CopilotKit/issues/5801.
2202
- */
2203
- deferInitialConnection?: boolean;
2204
- /** Mapping from agent name to its `AbstractAgent` instance. For development only - production requires CopilotRuntime. */
2205
- agents__unsafe_dev_only?: Record<string, AbstractAgent>;
2206
- /**
2207
- * Headers sent with every runtime request: a record, or a sync or async
2208
- * builder that runs when each request is sent. Merged on top of each
2209
- * `HttpAgent`'s own headers (core wins on a key conflict). See `setHeaders`.
2210
- */
2211
- headers?: CopilotKitHeadersSource;
2212
- /** Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies). */
2213
- credentials?: RequestCredentials;
2214
- /**
2215
- * Rewrites the message list sent to runtime agents on every run. Use it when
2216
- * the backend already stores the conversation and re-sending it is waste or
2217
- * duplication. See `setMessageFilter` and {@link CopilotKitMessageFilter}.
2218
- */
2219
- messageFilter?: CopilotKitMessageFilter;
2220
- /** Properties sent as `forwardedProps` to the AG-UI agent. */
2221
- properties?: Record<string, unknown>;
2222
- /** Ordered collection of frontend tools available to the core. */
2223
- tools?: FrontendTool<any>[];
2224
- /** Suggestions config for the core. */
2225
- suggestionsConfig?: SuggestionsConfig[];
2226
- /** Enable debug logging for the client-side event pipeline. */
2227
- debug?: DebugConfig;
2228
- /**
2229
- * Turns on interaction capture (`@copilotkit/learning`). Capture starts only
2230
- * when {@link CopilotKitCore.startTrajectory} authenticates and joins the
2231
- * capture channel. The default path captures outside-chat activity. An explicit
2232
- * legacy sink also receives Thread, message, tool call, and run context.
2233
- * Update future captures with
2234
- * {@link CopilotKitCore.setLearningConfig}.
2235
- */
2236
- learning?: LearningConfig;
2237
- }
2238
- interface CopilotKitCoreStopAgentParams {
2239
- agent: AbstractAgent;
2240
- }
2241
- type CopilotKitCoreGetSuggestionsResult = {
2242
- suggestions: Suggestion[];
2243
- isLoading: boolean;
2244
- };
2245
- declare enum CopilotKitCoreErrorCode {
2246
- RUNTIME_INFO_FETCH_FAILED = "runtime_info_fetch_failed",
2247
- AGENT_CONNECT_FAILED = "agent_connect_failed",
2248
- AGENT_RUN_FAILED = "agent_run_failed",
2249
- AGENT_RUN_FAILED_EVENT = "agent_run_failed_event",
2250
- AGENT_RUN_ERROR_EVENT = "agent_run_error_event",
2251
- TOOL_ARGUMENT_PARSE_FAILED = "tool_argument_parse_failed",
2252
- TOOL_HANDLER_FAILED = "tool_handler_failed",
2253
- TOOL_NOT_FOUND = "tool_not_found",
2254
- AGENT_NOT_FOUND = "agent_not_found",
2255
- /**
2256
- * Emitted when an agent run fails because the thread is already locked
2257
- * by another active run.
2258
- *
2259
- * @example
2260
- * ```tsx
2261
- * <CopilotKitProvider
2262
- * onError={({ code, error, context }) => {
2263
- * if (code === "agent_thread_locked") {
2264
- * // Show "Agent is busy, retry?" UI
2265
- * }
2266
- * }}
2267
- * />
2268
- * ```
2269
- */
2270
- AGENT_THREAD_LOCKED = "agent_thread_locked",
2271
- TRANSCRIPTION_FAILED = "transcription_failed",
2272
- TRANSCRIPTION_SERVICE_NOT_CONFIGURED = "transcription_service_not_configured",
2273
- TRANSCRIPTION_INVALID_AUDIO = "transcription_invalid_audio",
2274
- TRANSCRIPTION_RATE_LIMITED = "transcription_rate_limited",
2275
- TRANSCRIPTION_AUTH_FAILED = "transcription_auth_failed",
2276
- TRANSCRIPTION_NETWORK_ERROR = "transcription_network_error",
2277
- SUBSCRIBER_CALLBACK_FAILED = "subscriber_callback_failed",
2278
- /**
2279
- * The `headers` builder threw, rejected, or returned something other than
2280
- * an object. The request was not sent. `error.cause` is the builder's error.
2281
- */
2282
- HEADER_RESOLUTION_FAILED = "header_resolution_failed"
2283
- }
2284
- interface CopilotKitCoreSubscriber {
2285
- onTrajectoryChanged?: (event: {
2286
- copilotkit: CopilotKitCore;
2287
- trajectoryId: string | null;
2288
- }) => void | Promise<void>;
2289
- onRuntimeConnectionStatusChanged?: (event: {
2290
- copilotkit: CopilotKitCore;
2291
- status: CopilotKitCoreRuntimeConnectionStatus;
2292
- }) => void | Promise<void>;
2293
- onToolExecutionStart?: (event: {
2294
- copilotkit: CopilotKitCore;
2295
- toolCallId: string;
2296
- agentId: string;
2297
- toolName: string;
2298
- args: unknown;
2299
- }) => void | Promise<void>;
2300
- onToolExecutionEnd?: (event: {
2301
- copilotkit: CopilotKitCore;
2302
- toolCallId: string;
2303
- agentId: string;
2304
- toolName: string;
2305
- result: string;
2306
- error?: string;
2307
- }) => void | Promise<void>;
2308
- onAgentsChanged?: (event: {
2309
- copilotkit: CopilotKitCore;
2310
- agents: Readonly<Record<string, AbstractAgent>>;
2311
- }) => void | Promise<void>;
2312
- /**
2313
- * Fired when an agent run or connect begins. The `agent` may be a per-thread
2314
- * clone that is not present in `core.agents`, so `onAgentsChanged` never fires
2315
- * for it. Subscribers (e.g. the inspector) can use this to subscribe to the
2316
- * running instance's AG-UI events.
2317
- */
2318
- onAgentRunStarted?: (event: {
2319
- copilotkit: CopilotKitCore;
2320
- agent: AbstractAgent;
2321
- }) => void | Promise<void>;
2322
- onContextChanged?: (event: {
2323
- copilotkit: CopilotKitCore;
2324
- context: Readonly<Record<string, Context>>;
2325
- }) => void | Promise<void>;
2326
- /**
2327
- * Fired when the A2UI catalog component list changes (registration) or when
2328
- * a component is enabled/disabled. Consumers (the provider, the inspector)
2329
- * re-derive the filtered catalog from this event.
2330
- */
2331
- onCatalogComponentsChanged?: (event: {
2332
- copilotkit: CopilotKitCore;
2333
- catalogComponents: ReadonlyArray<CopilotKitCoreCatalogComponent>;
2334
- }) => void | Promise<void>;
2335
- onSuggestionsConfigChanged?: (event: {
2336
- copilotkit: CopilotKitCore;
2337
- suggestionsConfig: Readonly<Record<string, SuggestionsConfig>>;
2338
- }) => void | Promise<void>;
2339
- onSuggestionsChanged?: (event: {
2340
- copilotkit: CopilotKitCore;
2341
- agentId: string;
2342
- suggestions: Suggestion[];
2343
- }) => void | Promise<void>;
2344
- onSuggestionsStartedLoading?: (event: {
2345
- copilotkit: CopilotKitCore;
2346
- agentId: string;
2347
- }) => void | Promise<void>;
2348
- onSuggestionsFinishedLoading?: (event: {
2349
- copilotkit: CopilotKitCore;
2350
- agentId: string;
2351
- }) => void | Promise<void>;
2352
- onPropertiesChanged?: (event: {
2353
- copilotkit: CopilotKitCore;
2354
- properties: Readonly<Record<string, unknown>>;
2355
- }) => void | Promise<void>;
2356
- onHeadersChanged?: (event: {
2357
- copilotkit: CopilotKitCore;
2358
- headers: Readonly<Record<string, string>>;
2359
- }) => void | Promise<void>;
2360
- onInspectorMetadataChanged?: (event: {
2361
- copilotkit: CopilotKitCore;
2362
- inspectorMetadata: InspectorMetadataV1 | undefined;
2363
- }) => void | Promise<void>;
2364
- onError?: (event: {
2365
- copilotkit: CopilotKitCore;
2366
- error: Error;
2367
- code: CopilotKitCoreErrorCode;
2368
- context: Record<string, any>;
2369
- }) => void | Promise<void>;
2370
- onThreadStoreRegistered?: (event: {
2371
- copilotkit: CopilotKitCore;
2372
- agentId: string;
2373
- store: ɵThreadStore;
2374
- }) => void | Promise<void>;
2375
- /**
2376
- * Fired when a thread store is removed from the registry, either by an
2377
- * explicit `unregister()` call or by a `register()` call that replaces an
2378
- * existing store for the same `agentId`.
2379
- *
2380
- * The previous store is delivered via `prevStore` so subscribers can tear
2381
- * down state that depends on the concrete instance (e.g. cancel an active
2382
- * subscription) without consulting the registry. By the time async
2383
- * subscribers resume after an `await`, a replacement `register()` may have
2384
- * already installed the new store under the same key, so calling
2385
- * `registry.get(agentId)` inside this callback is unsafe and may return
2386
- * the new store instead of the unregistered one.
2387
- */
2388
- onThreadStoreUnregistered?: (event: {
2389
- copilotkit: CopilotKitCore;
2390
- agentId: string;
2391
- prevStore: ɵThreadStore;
2392
- }) => void | Promise<void>;
2393
- }
2394
- interface CopilotKitCoreSubscription {
2395
- unsubscribe: () => void;
2396
- }
2397
- /**
2398
- * The callback keys accepted by {@link CopilotKitCore.subscribeToAgentWithOptions}.
2399
- * This tuple is the single source of truth — both the
2400
- * `SubscribeToAgentSubscriber` type and the runtime `ALLOWED_KEYS` set
2401
- * are derived from it, so they cannot desynchronise.
2402
- */
2403
- declare const SUBSCRIBE_TO_AGENT_KEYS: readonly ["onMessagesChanged", "onStateChanged", "onRunInitialized", "onRunStartedEvent", "onRunFinalized", "onRunFailed", "onRunErrorEvent"];
2404
- /**
2405
- * The subset of `AgentSubscriber` callbacks accepted by
2406
- * {@link CopilotKitCore.subscribeToAgentWithOptions}. Only the callbacks
2407
- * listed in {@link SUBSCRIBE_TO_AGENT_KEYS} are supported:
2408
- * `onMessagesChanged`, `onStateChanged`, and the run lifecycle
2409
- * callbacks (`onRunInitialized`, `onRunStartedEvent`, `onRunFinalized`, `onRunFailed`,
2410
- * `onRunErrorEvent`).
2411
- *
2412
- * Two categories of `AgentSubscriber` members are excluded:
2413
- *
2414
- * - **AG-UI event handlers** (`onEvent`, `onToolCallStartEvent`, etc.)
2415
- * return `AgentStateMutation` with `stopPropagation` — semantics that
2416
- * the throttle and error-protection wrappers cannot safely mediate.
2417
- *
2418
- * - **Per-item notification callbacks** (`onNewMessage`, `onNewToolCall`)
2419
- * return `void` and have no mutation concerns, but are excluded to keep
2420
- * the surface area minimal — `onMessagesChanged` already covers the
2421
- * same data at a coarser granularity, and throttling per-item callbacks
2422
- * would have different semantic expectations.
2423
- *
2424
- * `onRunErrorEvent` and `onRunStartedEvent` are AG-UI event handlers whose
2425
- * return types include `stopPropagation`. They are included so framework
2426
- * consumers can reflect running-state changes while a connection stays open:
2427
- * a live error clears busy and a successor run marks it busy again. Consumers
2428
- * use these callbacks for notification and return `void`.
2429
- *
2430
- * Note: the included lifecycle callbacks return
2431
- * `Omit<AgentStateMutation, "stopPropagation">` (or full
2432
- * `AgentStateMutation` for the included AG-UI event handlers). On the error
2433
- * path, `safeCall` discards those return values (see its inline
2434
- * documentation).
2435
- *
2436
- * Use `agent.subscribe()` directly when event mutation or per-item
2437
- * notification semantics are needed.
2438
- */
2439
- type SubscribeToAgentSubscriber = Pick<AgentSubscriber, (typeof SUBSCRIBE_TO_AGENT_KEYS)[number]>;
2440
- /** Options for {@link CopilotKitCore.subscribeToAgentWithOptions}. */
2441
- interface SubscribeToAgentOptions {
2442
- /**
2443
- * Throttle interval (ms) for `onMessagesChanged` / `onStateChanged`.
2444
- * Non-negative finite number; `0` explicitly disables throttling.
2445
- * Falls back to `defaultThrottleMs` when `undefined`.
2446
- */
2447
- throttleMs?: number;
2448
- }
2449
- declare enum CopilotKitCoreRuntimeConnectionStatus {
2450
- Disconnected = "disconnected",
2451
- Connected = "connected",
2452
- Connecting = "connecting",
2453
- Error = "error"
2454
- }
2455
- /**
2456
- * Internal interface for delegate classes to access CopilotKitCore methods.
2457
- * This provides type safety while allowing controlled access to private functionality.
2458
- */
2459
- interface CopilotKitCoreFriendsAccess {
2460
- notifySubscribers(handler: (subscriber: CopilotKitCoreSubscriber) => void | Promise<void>, errorMessage: string): Promise<void>;
2461
- emitError(params: {
2462
- error: Error;
2463
- code: CopilotKitCoreErrorCode;
2464
- context?: Record<string, any>;
2465
- }): Promise<void>;
2466
- readonly headers: Readonly<Record<string, string>>;
2467
- resolveHeaders(): Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
2468
- readonly credentials: RequestCredentials | undefined;
2469
- readonly messageFilter: CopilotKitMessageFilter | undefined;
2470
- readonly properties: Readonly<Record<string, unknown>>;
2471
- readonly context: Readonly<Record<string, Context>>;
2472
- readonly debug?: DebugConfig;
2473
- buildFrontendTools(agentId?: string): _ag_ui_client0.Tool[];
2474
- getContextForAgent(agentId?: string): Context[];
2475
- getPropertiesForAgent(agentId?: string): Record<string, unknown>;
2476
- getAgent(id: string): AbstractAgent | undefined;
2477
- /**
2478
- * Re-apply the last resolved header snapshot to a single agent, merged on
2479
- * top of the headers the agent was constructed with (see #5635). Never
2480
- * invokes the headers builder — safe to call from anywhere without risking
2481
- * a synchronous throw or an unhandled async rejection from a user-supplied
2482
- * builder.
2483
- */
2484
- applyHeadersToAgent(agent: AbstractAgent): void;
2485
- /**
2486
- * Resolve headers fresh (including invoking a sync/async builder) and
2487
- * apply them to `agent` right before a run or connect actually sends
2488
- * (#1937). Friends-only — only the run handler should call this, since
2489
- * unlike `applyHeadersToAgent` it can throw synchronously or return a
2490
- * rejecting promise. Returns a promise only when an async builder must be
2491
- * awaited first; callers that need the write to have landed before
2492
- * continuing must await a returned promise.
2493
- */
2494
- prepareAgentHeadersForRun(agent: AbstractAgent): void | Promise<void>;
2495
- readonly suggestionEngine: {
2496
- clearSuggestions(agentId: string): void;
2497
- reloadSuggestions(agentId: string): void;
2498
- };
2499
- /**
2500
- * Called before each follow-up agent run (after tool execution).
2501
- * See CopilotKitCore.waitForPendingFrameworkUpdates for details.
2502
- */
2503
- waitForPendingFrameworkUpdates(): Promise<void>;
2504
- readonly stateManager: {
2505
- getContinuationRunId(agent: AbstractAgent, input: Pick<RunAgentInput, "threadId" | "resume" | "forwardedProps">): string | undefined;
2506
- markNextRunAsContinuation(agent: AbstractAgent, expectedRunId?: string): CopilotKitCoreContinuationHandoff;
2507
- };
2508
- }
2509
- declare class CopilotKitCore {
2510
- private headerSource;
2511
- private _credentials?;
2512
- private _messageFilter?;
2513
- private _properties;
2514
- private _scopedProperties;
2515
- private _defaultThrottleMs?;
2516
- private _debug?;
2517
- private subscribers;
2518
- private agentRegistry;
2519
- private contextStore;
2520
- private suggestionEngine;
2521
- private runHandler;
2522
- private stateManager;
2523
- private threadStoreRegistry;
2524
- private learningBridge;
2525
- private notifiedTrajectoryId;
2526
- private readonly learningConfiguredListeners;
2527
- private _generativeUIDebugSource;
2528
- private readonly generativeUIDebugListeners;
2529
- /**
2530
- * The single core-owned memory store, created lazily on first
2531
- * `getMemoryStore()` and kept user-scoped for the lifetime of the core.
2532
- * Its runtime context is wired by the core itself (see `syncMemoryContext`),
2533
- * so callers never register or look it up by `agentId`.
2534
- */
2535
- private _memoryStore?;
2536
- /**
2537
- * Tracks the agent IDs from the most recent `onAgentsChanged` notification.
2538
- * Used to gate thread-store auto-unregister so the FIRST empty-agents
2539
- * notification (before published agents are merged in) does not rip out a
2540
- * store that was registered prior to that initial notification.
2541
- */
2542
- private previousAgentIds;
2543
- constructor({
2544
- runtimeUrl,
2545
- runtimeTransport,
2546
- deferInitialConnection,
2547
- headers,
2548
- credentials,
2549
- messageFilter,
2550
- properties,
2551
- agents__unsafe_dev_only,
2552
- tools,
2553
- suggestionsConfig,
2554
- debug,
2555
- learning
2556
- }: CopilotKitCoreConfig);
2557
- /**
2558
- * Internal method used by delegate classes and subclasses to notify subscribers
2559
- */
2560
- protected notifySubscribers(handler: (subscriber: CopilotKitCoreSubscriber) => void | Promise<void>, errorMessage: string): Promise<void>;
2561
- /**
2562
- * Internal method used by delegate classes to emit errors
2563
- */
2564
- private emitError;
2565
- /**
2566
- * Log a message to the console and emit an error to subscribers.
2567
- * Catches failures from `emitError` itself to prevent unhandled rejections.
2568
- */
2569
- private logAndEmitError;
2570
- /**
2571
- * Snapshot accessors
2572
- */
2573
- get context(): Readonly<Record<string, ScopedContext>>;
2574
- get agents(): Readonly<Record<string, AbstractAgent>>;
2575
- get tools(): Readonly<FrontendTool<any>[]>;
2576
- get catalogComponents(): ReadonlyArray<CopilotKitCoreCatalogComponent>;
2577
- get runtimeUrl(): string | undefined;
2578
- setRuntimeUrl(runtimeUrl: string | undefined): void;
2579
- /**
2580
- * Start the runtime `/info` connection if it has not been started yet.
2581
- *
2582
- * Intended to be driven from a host's commit-phase effect when the core was
2583
- * constructed with {@link CopilotKitCoreConfig.deferInitialConnection}. Safe
2584
- * to call repeatedly — it is a no-op once a connection is in progress or
2585
- * settled, so a double-invoked mount effect (React StrictMode) collapses to a
2586
- * single request. See #5801.
2587
- */
2588
- connect(): void;
2589
- get runtimeTransport(): CopilotRuntimeTransport;
2590
- setRuntimeTransport(runtimeTransport: CopilotRuntimeTransport): void;
2591
- get runtimeVersion(): string | undefined;
2592
- /**
2593
- * The last resolved headers. With a builder this is the value from the most
2594
- * recent request, not necessarily current; call `resolveHeaders()` for that.
2595
- */
2596
- get headers(): Readonly<Record<string, string>>;
2597
- /**
2598
- * Resolve the current headers. Synchronous for a record or a sync builder,
2599
- * a promise for an async builder. Concurrent calls share one builder call.
2600
- * The returned object is shared; copy it before modifying.
2601
- */
2602
- resolveHeaders(): Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
2603
- /** Changes only on `setHeaders` or a new source, never on a new token. */
2604
- get ɵheadersGeneration(): number;
2605
- get credentials(): RequestCredentials | undefined;
2606
- get messageFilter(): CopilotKitMessageFilter | undefined;
2607
- get properties(): Readonly<Record<string, unknown>>;
2608
- /**
2609
- * Default throttle interval (ms) used by `subscribeToAgentWithOptions()`
2610
- * when the caller does not specify an explicit `throttleMs`.
2611
- * `undefined` means no default is configured; `0` means no throttling.
2612
- */
2613
- get defaultThrottleMs(): number | undefined;
2614
- /**
2615
- * Set the default throttle interval (ms) for `subscribeToAgentWithOptions()`.
2616
- *
2617
- * Accepts a non-negative finite number or `undefined` (to clear the
2618
- * default). Invalid values (NaN, Infinity, negative) are logged as
2619
- * errors and ignored — the previous valid value is preserved.
2620
- */
2621
- setDefaultThrottleMs(value: number | undefined): void;
2622
- get debug(): DebugConfig | undefined;
2623
- setDebug(debug: DebugConfig | undefined): void;
2624
- get runtimeConnectionStatus(): CopilotKitCoreRuntimeConnectionStatus;
2625
- /** @internal The verbatim single-endpoint URL, including any trailing slash. */
2626
- get ɵruntimeEndpointUrl(): string | undefined;
2627
- get ɵruntimeFetch(): typeof fetch;
2628
- get audioFileTranscriptionEnabled(): boolean;
2629
- get runtimeMode(): RuntimeMode;
2630
- get intelligence(): IntelligenceRuntimeInfo | undefined;
2631
- get threadEndpoints(): ThreadEndpointRuntimeInfo | undefined;
2632
- get suggestions(): boolean | undefined;
2633
- /** Whether the connected Runtime exposes debug-authorized Learning data. */
2634
- get inspectorLearning(): boolean;
2635
- /** Trusted, optional metadata advertised by the connected runtime. */
2636
- get inspectorMetadata(): InspectorMetadataV1 | undefined;
2637
- /** Refresh trusted inspector metadata without reconnecting runtime agents. */
2638
- refreshInspectorMetadata(): Promise<void>;
2639
- get a2uiEnabled(): boolean;
2640
- /**
2641
- * Agent ids the runtime applies A2UI to. `undefined` means A2UI applies to
2642
- * every agent (or is disabled — check `a2uiEnabled`).
2643
- */
2644
- get a2uiAgents(): string[] | undefined;
2645
- get openGenerativeUIEnabled(): boolean;
2646
- get licenseStatus(): RuntimeLicenseStatus | undefined;
2647
- /** Structured Runtime entitlement authority advertised by `/info`. */
2648
- get runtimeEntitlements(): RuntimeEntitlementResponse | undefined;
2649
- /** Whether Core still has a bounded Runtime entitlement retry to settle. */
2650
- get runtimeEntitlementRetryPending(): boolean;
2651
- get telemetryDisabled(): boolean;
2652
- /**
2653
- * Configuration updates
2654
- */
2655
- /**
2656
- * Replace the headers sent with every runtime request.
2657
- *
2658
- * This is an overwrite, not a merge — the supplied object becomes the
2659
- * complete header set. Entries whose value is `null` or `undefined` are
2660
- * dropped, which is how you clear a header (e.g. removing `Authorization`
2661
- * on logout) without leaving an empty-string value behind:
2662
- *
2663
- * ```ts
2664
- * copilotkit.setHeaders({
2665
- * ...copilotkit.headers,
2666
- * Authorization: token ? `Bearer ${token}` : null,
2667
- * });
2668
- * ```
2669
- *
2670
- * The resulting header set is also re-applied to every agent in the registry
2671
- * and `onHeadersChanged` subscribers are notified. These headers are merged
2672
- * ON TOP of the headers each `HttpAgent` was constructed with, so per-agent
2673
- * headers (e.g. an `Authorization` for a self-hosted backend) are preserved;
2674
- * on a key conflict the core-level value wins.
2675
- *
2676
- * Because the agent's construction-time headers form the merge baseline, this
2677
- * method can override a per-agent header but cannot REMOVE one: clearing a
2678
- * core key here only drops the core-level override, after which the agent's
2679
- * own value (if any) re-surfaces. To change a header an agent was constructed
2680
- * with, set it at the provider/core level instead of on the agent, or update
2681
- * it on the agent directly. The clear-on-logout pattern above is for
2682
- * core-level headers.
2683
- *
2684
- * Pass a function to have headers evaluated when each request is sent
2685
- * (sync or async). Setting the same function again is a no-op. A new token
2686
- * from the builder doesn't notify `onHeadersChanged`. On a user switch,
2687
- * call `setHeaders` with a NEW function (or a record), or remount.
2688
- *
2689
- * Passing a record equal (by value) to the currently applied record is
2690
- * also a no-op — safe to call on every render with a fresh object literal.
2691
- */
2692
- setHeaders(headers: CopilotKitHeadersSource): void;
2693
- setCredentials(credentials: RequestCredentials | undefined): void;
2694
- /**
2695
- * Replace the message filter applied to every runtime agent.
2696
- *
2697
- * Applies to agents already discovered as well as ones discovered later, so
2698
- * a filter set before `/info` lands is not lost. Pass `undefined` to go back
2699
- * to sending the full thread.
2700
- */
2701
- setMessageFilter(messageFilter: CopilotKitMessageFilter | undefined): void;
2702
- /**
2703
- * Add run properties that go only to the runs of `agentIds`. When
2704
- * `agentIds` is omitted, every agent gets them. They merge on top of the
2705
- * base `properties`.
2706
- *
2707
- * When an entry value and the existing value under the same key are both
2708
- * plain objects, their keys merge one level deep. So several entries can
2709
- * add keys under one namespace (for example `copilotkit`).
2710
- *
2711
- * @param entry - The properties and the optional agent ids.
2712
- * @returns The id to pass to `removeScopedProperties`.
2713
- *
2714
- * @example
2715
- * const id = copilotkit.addScopedProperties({
2716
- * properties: { copilotkit: { theme: "dark" } },
2717
- * agentIds: ["research"],
2718
- * });
2719
- * copilotkit.removeScopedProperties(id);
2720
- */
2721
- addScopedProperties({
2722
- properties,
2723
- agentIds
2724
- }: ScopedProperties): string;
2725
- /** Remove an entry that `addScopedProperties` added. An unknown id does nothing. */
2726
- removeScopedProperties(id: string): void;
2727
- /**
2728
- * Build the forwarded properties for a run of the given agent: the base
2729
- * properties plus every scoped entry that matches the agent. An entry with
2730
- * `agentIds` does not match when `agentId` is omitted.
2731
- */
2732
- getPropertiesForAgent(agentId?: string): Record<string, unknown>;
2733
- setProperties(properties: Record<string, unknown>): void;
2734
- /**
2735
- * Agent management (delegated to AgentRegistry)
2736
- */
2737
- setAgents__unsafe_dev_only(agents: Record<string, AbstractAgent>): void;
2738
- addAgent__unsafe_dev_only(params: CopilotKitCoreAddAgentParams): void;
2739
- removeAgent__unsafe_dev_only(id: string): void;
2740
- /**
2741
- * Register a proxied agent against an existing runtime agent. The proxy is
2742
- * exposed under `agentId` (local registry id) and routes outbound runtime
2743
- * requests to `runtimeAgentId`. Throws if `agentId` is already taken.
2744
- *
2745
- * Returns the minted proxy and an `unregister` handle for cleanup.
2746
- *
2747
- * Use this to mount multiple frontend agents against a single runtime
2748
- * agent (e.g. one per chat window) without implicit per-thread cloning.
2749
- *
2750
- * @example
2751
- * const { agent, unregister } = copilotkit.registerProxiedAgent({
2752
- * agentId: "chat-1",
2753
- * runtimeAgentId: "default",
2754
- * });
2755
- * // ... <CopilotChat agentId="chat-1" />
2756
- * // on cleanup:
2757
- * unregister();
2758
- */
2759
- registerProxiedAgent(params: CopilotKitCoreRegisterProxiedAgentParams): CopilotKitCoreRegisterProxiedAgentResult;
2760
- getAgent(id: string): AbstractAgent | undefined;
2761
- /** Updates settings for the next capture. Removing the config stops capture. */
2762
- setLearningConfig(config: LearningConfig | undefined): void;
2763
- /**
2764
- * @internal Whether a `learning` config is set. Unlike {@link trajectoryId},
2765
- * it does not change with capture start, connection failures or reconnects.
2766
- */
2767
- get ɵlearningConfigured(): boolean;
2768
- /**
2769
- * @internal Whether captured events may carry agent message text: false
2770
- * without a `learning` config, or when a custom sink sets
2771
- * `capture.agentText` to false. A running custom-sink capture keeps the
2772
- * choice it started with.
2773
- */
2774
- get ɵlearningCapturesAgentText(): boolean;
2775
- /** @internal Calls `listener` when {@link ɵlearningConfigured} changes. */
2776
- ɵsubscribeToLearningConfigured(listener: () => void): () => void;
2777
- /**
2778
- * @internal The generative UI of the framework package, for the inspector.
2779
- * `undefined` when no provider has a `generativeUI` config.
2780
- */
2781
- get ɵgenerativeUIDebugSource(): ɵGenerativeUIDebugSource | undefined;
2782
- /** @internal Set by the framework package. `undefined` removes it. */
2783
- ɵsetGenerativeUIDebugSource(source: ɵGenerativeUIDebugSource | undefined): void;
2784
- /** @internal Calls `listener` when {@link ɵgenerativeUIDebugSource} is set or removed. */
2785
- ɵsubscribeToGenerativeUIDebugSource(listener: () => void): () => void;
2786
- /** The active capture's Trajectory ID, or null while capture is stopped. */
2787
- get trajectoryId(): string | null;
2788
- private notifyTrajectoryChanged;
2789
- /**
2790
- * Starts one Trajectory after Runtime authorization and the Gateway join.
2791
- * Omit the ID to create one. Repeated starts await the active connection;
2792
- * a different ID stops the previous capture. Explicit sinks retain the
2793
- * prototype's synchronous capture and require a stop before changing IDs.
2794
- *
2795
- * @example copilotkit.startTrajectory({ trajectoryId: crypto.randomUUID() })
2796
- */
2797
- startTrajectory(options?: TrajectoryStartOptions): Promise<StartResult$1>;
2798
- /** Cancels pending work and stops capture, attempting one final batch without waiting for its ACK. */
2799
- stopTrajectory(): void;
2800
- /**
2801
- * Records an outcome that clicks cannot show, such as a saved report or an
2802
- * approved deal. The wire adds `value.seq`; arrays, primitives, and objects
2803
- * already containing `seq` are preserved under `value.data`. Explicit legacy
2804
- * sinks retain object-only events with open-Thread enrichment.
2805
- * No-op while no Trajectory runs. Events emitted during connection recovery
2806
- * count as dropped. Built-in names such as `click` are rejected.
2807
- *
2808
- * @example copilotkit.emitTrajectoryEvent("deal.approved", { dealId: "deal-1" })
2809
- */
2810
- emitTrajectoryEvent(name: string, value?: JsonValue$1): void;
2811
- /**
2812
- * Tells Core that a view shows this Thread, so captured interactions can link to it.
2813
- * Framework bindings call this; call it yourself only without a CopilotKit provider.
2814
- */
2815
- registerOpenThread(params: {
2816
- agentId: string;
2817
- threadId: string;
2818
- }): OpenThreadRegistration;
2819
- /**
2820
- * Re-apply the last resolved header snapshot to a single agent (delegated
2821
- * to AgentRegistry). Core headers are merged on top of the agent's own
2822
- * construction-time headers rather than replacing them, so headers
2823
- * configured directly on an `HttpAgent` (e.g. an `Authorization` for a
2824
- * self-hosted backend) survive header updates instead of being silently
2825
- * dropped (see #5635). On a key conflict the core-level value wins.
2826
- *
2827
- * The merge baseline is the agent's headers as captured the first time the
2828
- * agent is applied (at registration), so the way to change headers
2829
- * afterwards is `setHeaders` (which re-applies to every agent), not mutating
2830
- * `agent.headers` directly — a direct mutation is overwritten on the next
2831
- * re-apply.
2832
- *
2833
- * A `ProxiedCopilotRuntimeAgent` keeps only its own construction-time
2834
- * headers here — core headers are added by `ɵruntimeFetch` when each
2835
- * request is sent (see #1937), so `agent.headers` never carries a stale
2836
- * copy of a core header the builder has since stopped returning.
2837
- *
2838
- * Never invokes the headers builder (unlike the run/connect path's
2839
- * internal `prepareAgentHeadersForRun`): safe to call from a dev-only
2840
- * registration helper or a React effect that re-runs on every render
2841
- * without risking a synchronous throw or an unhandled async rejection from
2842
- * a user-supplied builder.
2843
- */
2844
- applyHeadersToAgent(agent: AbstractAgent): void;
2845
- /**
2846
- * Resolve headers fresh and apply them to `agent` right before a run or
2847
- * connect actually sends (#1937). Friends-only (delegated to
2848
- * AgentRegistry) — the run handler is the sole caller, since resolving can
2849
- * invoke a user-supplied builder that throws or rejects.
2850
- */
2851
- private prepareAgentHeadersForRun;
2852
- /**
2853
- * Context management (delegated to ContextStore).
2854
- * Pass `agentIds` to restrict the entry to runs of specific agents;
2855
- * omit it for context every agent should receive.
2856
- */
2857
- addContext(context: ScopedContext): string;
2858
- removeContext(id: string): void;
2859
- /**
2860
- * Build the context array for a run of the given agent, dropping entries
2861
- * scoped to other agents and stripping the scoping metadata.
2862
- */
2863
- getContextForAgent(agentId?: string): Context[];
2864
- /**
2865
- * Thread store registry (delegated to ThreadStoreRegistry)
2866
- */
2867
- registerThreadStore(agentId: string, store: ɵThreadStore): void;
2868
- unregisterThreadStore(agentId: string): void;
2869
- getThreadStore(agentId: string): ɵThreadStore | undefined;
2870
- getThreadStores(): Readonly<Record<string, ɵThreadStore>>;
2871
- /**
2872
- * Returns the single core-owned, user-scoped memory store, creating and
2873
- * starting it on first access. Unlike thread stores, memory is not scoped per
2874
- * agent: there is exactly one store whose runtime context the core wires
2875
- * itself (see `syncMemoryContext`), so consumers (e.g. a `useMemories`
2876
- * binding) just read this store rather than registering one.
2877
- */
2878
- getMemoryStore(): ɵMemoryStore;
2879
- /**
2880
- * Lazily creates, starts, and context-syncs the core-owned memory store on
2881
- * first access, then returns it. Subsequent calls return the existing store.
2882
- * The store uses the Core Runtime fetch so REST and single-route transports
2883
- * share the same resource behavior. Its Runtime context is synced at once.
2884
- */
2885
- private ensureMemoryStore;
2886
- /**
2887
- * Pushes the current runtime wiring into the memory store. When the runtime
2888
- * is connected and both the intelligence WebSocket URL and runtime URL are
2889
- * available, the store receives a context (runtime URL, WebSocket URL);
2890
- * otherwise its context is cleared. No-op when the store has not been
2891
- * created yet.
2892
- *
2893
- * Headers are deliberately NOT part of this context: the store's `fetch` is
2894
- * `ɵruntimeFetch` (see `ensureMemoryStore`), which already resolves and
2895
- * overlays the current core headers at send time (#1937) — a header
2896
- * snapshot copied here would go stale between context syncs.
2897
- */
2898
- private syncMemoryContext;
2899
- /**
2900
- * Suggestions management (delegated to SuggestionEngine)
2901
- */
2902
- addSuggestionsConfig(config: SuggestionsConfig): string;
2903
- removeSuggestionsConfig(id: string): void;
2904
- reloadSuggestions(agentId: string): void;
2905
- clearSuggestions(agentId: string): void;
2906
- getSuggestions(agentId: string): CopilotKitCoreGetSuggestionsResult;
2907
- /**
2908
- * Tool management (delegated to RunHandler)
2909
- */
2910
- addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
2911
- removeTool(id: string, agentId?: string): void;
2912
- getTool(params: CopilotKitCoreGetToolParams): FrontendTool<any> | undefined;
2913
- setTools(tools: FrontendTool<any>[]): void;
2914
- /**
2915
- * Enable/disable a registered frontend tool at runtime without unregistering
2916
- * it (Inspector "Capabilities" tool). A disabled tool is omitted from the
2917
- * tool list sent to the agent on the next run. The override is keyed by name
2918
- * (+ optional agentId) and survives the tool being re-registered.
2919
- */
2920
- setToolEnabled(name: string, enabled: boolean, agentId?: string): void;
2921
- /** Whether a registered tool is currently enabled (defaults true). */
2922
- isToolEnabled(name: string, agentId?: string): boolean;
2923
- /**
2924
- * A2UI catalog component management (delegated to RunHandler).
2925
- * Registers the full component list and controls per-component enablement.
2926
- */
2927
- setCatalogComponents(components: CopilotKitCoreCatalogComponent[]): void;
2928
- setCatalogComponentEnabled(name: string, enabled: boolean): void;
2929
- isCatalogComponentEnabled(name: string): boolean;
2930
- /**
2931
- * Subscription lifecycle
2932
- */
2933
- subscribe(subscriber: CopilotKitCoreSubscriber): CopilotKitCoreSubscription;
2934
- /**
2935
- * Subscribe to an agent's notification and lifecycle events with
2936
- * optional configuration (e.g. throttling).
2937
- *
2938
- * Wraps every callback with error protection (`safeCall`) and applies
2939
- * the options before delegating to `agent.subscribe()`.
2940
- *
2941
- * See {@link SubscribeToAgentSubscriber} for the accepted callback subset
2942
- * and the rationale for excluding AG-UI event handlers.
2943
- */
2944
- subscribeToAgentWithOptions(agent: AbstractAgent, subscriber: SubscribeToAgentSubscriber, options?: SubscribeToAgentOptions): CopilotKitCoreSubscription;
2945
- /**
2946
- * Agent connectivity (delegated to RunHandler)
2947
- */
2948
- connectAgent(params: CopilotKitCoreConnectAgentParams): Promise<_ag_ui_client0.RunAgentResult>;
2949
- stopAgent(params: CopilotKitCoreStopAgentParams): void;
2950
- runAgent(params: CopilotKitCoreRunAgentParams): Promise<_ag_ui_client0.RunAgentResult>;
2951
- /**
2952
- * Programmatically execute a registered frontend tool without going through an LLM turn.
2953
- * The handler runs, render components show up in the UI, and both the tool call and
2954
- * result messages are added to `agent.messages`.
2955
- */
2956
- runTool(params: CopilotKitCoreRunToolParams): Promise<CopilotKitCoreRunToolResult>;
2957
- /**
2958
- * State management (delegated to StateManager)
2959
- */
2960
- getStateByRun(agentId: string, threadId: string, runId: string): State | undefined;
2961
- getRunIdForMessage(agentId: string, threadId: string, messageId: string): string | undefined;
2962
- getRawEventForMessage(agentId: string, threadId: string, messageId: string): unknown;
2963
- getRunIdsForThread(agentId: string, threadId: string): string[];
2964
- /**
2965
- * Internal method used by RunHandler to build frontend tools
2966
- */
2967
- private buildFrontendTools;
2968
- /**
2969
- * Called before each follow-up agent run (after tool execution).
2970
- *
2971
- * When a frontend tool handler calls framework state setters (e.g. React's
2972
- * setState), those updates are batched and deferred — they do not take effect
2973
- * until the framework's scheduler runs (React uses MessageChannel).
2974
- * useAgentContext registers context via useLayoutEffect, which runs
2975
- * synchronously after React commits that deferred batch.
2976
- *
2977
- * Without yielding here, the follow-up runAgent reads the context store
2978
- * synchronously while the deferred updates are still pending, producing stale
2979
- * context for the next agent turn.
2980
- *
2981
- * Override in framework-specific subclasses to yield to the framework
2982
- * scheduler before the follow-up run. The base implementation is a no-op
2983
- * because non-React environments have no deferred state to flush.
2984
- */
2985
- waitForPendingFrameworkUpdates(): Promise<void>;
2986
- }
2987
- //#endregion
2988
- //#region src/core/suggestion-engine.d.ts
2989
- /**
2990
- * Manages suggestion generation, streaming, and lifecycle for CopilotKitCore.
2991
- * Handles both dynamic (AI-generated) and static suggestions.
2992
- */
2993
- declare class SuggestionEngine {
2994
- private core;
2995
- private _suggestionsConfig;
2996
- private _suggestions;
2997
- private _runningSuggestions;
2998
- constructor(core: CopilotKitCore);
2999
- /**
3000
- * Initialize with suggestion configs
3001
- */
3002
- initialize(suggestionsConfig: SuggestionsConfig[]): void;
3003
- /**
3004
- * Add a suggestion configuration
3005
- * @returns The ID of the created config
3006
- */
3007
- addSuggestionsConfig(config: SuggestionsConfig): string;
3008
- /**
3009
- * Remove a suggestion configuration by ID
3010
- */
3011
- removeSuggestionsConfig(id: string): void;
3012
- /**
3013
- * Reload suggestions for a specific agent
3014
- * This triggers generation of new suggestions based on current configs
3015
- */
3016
- reloadSuggestions(agentId: string): void;
3017
- /**
3018
- * Clear all suggestions for a specific agent
3019
- */
3020
- clearSuggestions(agentId: string): void;
3021
- /**
3022
- * Get current suggestions for an agent
3023
- */
3024
- getSuggestions(agentId: string): CopilotKitCoreGetSuggestionsResult;
3025
- /**
3026
- * Generate suggestions by running a provider agent and extracting the
3027
- * `copilotkitSuggest` tool call from its streamed messages.
3028
- *
3029
- * Two transports, one set of mechanics: both seed an agent with the
3030
- * consumer's messages + state and the instruction, then `runAgent` with
3031
- * forced `copilotkitSuggest` tool choice, parsing suggestions as messages
3032
- * stream in via `onMessagesChanged`.
3033
- *
3034
- * - **Stateless** (runtime advertises `suggestions` and transport isn't
3035
- * `single`): a stock `HttpAgent` pointed at `/agent/:id/suggest`. That
3036
- * endpoint runs the provider directly and streams AG-UI SSE **without**
3037
- * persisting a thread, and a plain `HttpAgent` only ever speaks REST SSE —
3038
- * it never routes through the Intelligence websocket delegate (which would
3039
- * persist a thread). This is the path that removes the thread flood.
3040
- * - **Fallback** (capability absent → old runtime, or `single` transport):
3041
- * clone the provider agent and run it client-side, as before.
3042
- *
3043
- * Gated to non-`single` transports because this client only builds the
3044
- * multi-route `/agent/:id/suggest` URL; single-route deployments (not the
3045
- * persisting-thread/Intelligence case) fall through to the clone fallback.
3046
- */
3047
- private generateSuggestions;
3048
- /**
3049
- * Finalize suggestions by marking them as no longer loading
3050
- */
3051
- private finalizeSuggestions;
3052
- /**
3053
- * Extract suggestions from messages (called during streaming)
3054
- */
3055
- extractSuggestions(messages: readonly Message[], suggestionId: string, consumerAgentId: string, isRunning: boolean): void;
3056
- /**
3057
- * Notify subscribers of suggestions config changes
3058
- */
3059
- private notifySuggestionsConfigChanged;
3060
- /**
3061
- * Notify subscribers of suggestions changes
3062
- */
3063
- private notifySuggestionsChanged;
3064
- /**
3065
- * Notify subscribers that suggestions started loading
3066
- */
3067
- private notifySuggestionsStartedLoading;
3068
- /**
3069
- * Notify subscribers that suggestions finished loading
3070
- */
3071
- private notifySuggestionsFinishedLoading;
3072
- /**
3073
- * Check if suggestions should be shown based on availability and message count
3074
- */
3075
- private shouldShowSuggestions;
3076
- /**
3077
- * Add static suggestions directly without AI generation
3078
- */
3079
- private addStaticSuggestions;
3080
- }
3081
- /**
3082
- * Detects an `AbortController`-driven cancellation so the stateless path can
3083
- * treat it as an expected (non-error) outcome on clear/reload.
3084
- */
3085
- declare function isAbortError(error: unknown): boolean;
3086
- //#endregion
3087
- //#region src/core/webmcp.d.ts
3088
- /**
3089
- * The subset of the WebMCP `ModelContext` API
3090
- * (https://webmachinelearning.github.io/webmcp/) that the registry depends on.
3091
- * Kept structural so the code works against the real browser API and test
3092
- * doubles alike. Aborting the registration signal unregisters the tool.
3093
- */
3094
- interface WebMCPModelContext {
3095
- registerTool(tool: {
3096
- name: string;
3097
- description: string;
3098
- inputSchema: Record<string, unknown>;
3099
- execute: (args: Record<string, unknown>, options: {
3100
- signal?: AbortSignal;
3101
- }) => Promise<unknown>;
3102
- annotations?: WebMCPToolAnnotations;
3103
- }, options: {
3104
- signal: AbortSignal;
3105
- }): Promise<undefined>;
3106
- }
3107
- /**
3108
- * Return the page's `document.modelContext`, or null when WebMCP is not
3109
- * available (SSR, React Native, browsers without the API enabled).
3110
- */
3111
- declare function getWebMCPModelContext(): WebMCPModelContext | null;
3112
- /**
3113
- * Keeps a set of frontend tools registered on the page's WebMCP model context.
3114
- *
3115
- * `sync(desired)` reconciles the registrations with the desired set: tools that
3116
- * are gone (or were re-registered with a new tool object) are unregistered by
3117
- * aborting their registration signal, and new tools are registered with an
3118
- * `execute` that delegates to the frontend tool's own handler.
3119
- *
3120
- * All WebMCP-API constraints live here so callers only supply the desired set:
3121
- * a tool without a description is skipped with a warning (the spec rejects
3122
- * empty descriptions), and failures from `registerTool` (duplicate name,
3123
- * unsupported context, ...) are warned rather than thrown.
3124
- */
3125
- declare class WebMCPRegistry {
3126
- private entries;
3127
- private warnedNames;
3128
- /** Names currently kept registered on the model context. */
3129
- get registeredNames(): string[];
3130
- /** Reconcile the registered tools with the desired set. */
3131
- sync(desired: Map<string, FrontendTool<any>>): void;
3132
- /**
3133
- * Build the WebMCP model-context tool for a frontend tool. The `execute`
3134
- * callback delegates to the frontend tool's own handler, so a browser agent
3135
- * call runs the same application code as an agent call.
3136
- */
3137
- private buildModelContextTool;
3138
- /** Log `message` once per tool name. Repeated syncs must not spam the log. */
3139
- private warnOnce;
3140
- }
3141
- //#endregion
3142
- //#region src/utils/markdown/complete-partial-markdown.d.ts
3143
- declare function completePartialMarkdown(input: string): string;
3144
- //#endregion
3145
- //#region src/utils/markdown/types.d.ts
3146
- /**
3147
- * A single parsed markdown node. This is `marked`'s token union, re-exported as
3148
- * the stable public contract that framework renderers switch on. Consumers
3149
- * should treat `type` as the discriminant (e.g. "heading", "paragraph", "code",
3150
- * "list", "table", "strong", "em", "link", "image", ...).
3151
- */
3152
- type MarkdownToken = Token;
3153
- /** The ordered list of top-level tokens returned by parseMarkdown. */
3154
- type MarkdownTokenList = TokensList;
3155
- //#endregion
3156
- //#region src/utils/markdown/parse.d.ts
3157
- interface ParseMarkdownOptions {
3158
- /**
3159
- * When true (default), the input is run through `completePartialMarkdown`
3160
- * first so that incomplete streaming markdown (unterminated emphasis, code
3161
- * fences, links) renders cleanly. Set false to parse the raw string as-is.
3162
- */
3163
- complete?: boolean;
3164
- }
3165
- /**
3166
- * Parse a markdown string into a framework-agnostic token tree.
3167
- *
3168
- * Uses `marked`'s lexer (GFM enabled) so the result is DOM-free and can be
3169
- * walked into React, Vue, or React Native elements by each framework's
3170
- * built-in renderer.
3171
- */
3172
- declare function parseMarkdown(content: string, options?: ParseMarkdownOptions): MarkdownTokenList;
3173
- //#endregion
3174
- //#region src/utils/http-agent.d.ts
3175
- /**
3176
- * Whether an agent is an `HttpAgent`, including one built from another copy of
3177
- * `@ag-ui/client` (an app that pins its own 0.x version next to CopilotKit's
3178
- * 1.0, for example). `instanceof` is false across package copies, which made
3179
- * CopilotKit silently skip headers and abort wiring for those agents. The
3180
- * fallback checks the public fields CopilotKit uses, which every published
3181
- * `HttpAgent` has.
3182
- */
3183
- declare function ɵisHttpAgent(agent: unknown): agent is HttpAgent;
3184
- //#endregion
3185
- //#region src/intelligence-agent.d.ts
3186
- interface IntelligenceAgentSharedState {
3187
- lastSeenEventIds: Map<string, string>;
3188
- }
3189
- declare class AgentThreadLockedError extends Error {
3190
- constructor(threadId?: string);
3191
- }
3192
- /**
3193
- * Typed contract for agents that expose the completion promise of their
3194
- * currently in-flight run.
3195
- *
3196
- * `IntelligenceAgent` resolves this promise once a run's observable pipeline
3197
- * finalizes (see {@link IntelligenceAgent.connectAgent}). Consumers (e.g. the
3198
- * v2 `CopilotChat` send-serialization path) await it to let an in-flight run —
3199
- * notably an interrupt RESUME — finish before dispatching a new run, instead
3200
- * of pre-empting it.
3201
- *
3202
- * The base `AbstractAgent` from `@ag-ui/client` only declares this property
3203
- * privately, so it is reachable only through this contract plus the
3204
- * {@link isRunCompletionAware} type guard. This keeps callers off `as unknown`
3205
- * casts while still degrading safely for agents that don't implement it.
3206
- */
3207
- interface RunCompletionAware {
3208
- /**
3209
- * Resolves when the active run's pipeline finalizes (completes, errors, or is
3210
- * detached). `undefined` when no run is in flight.
3211
- */
3212
- readonly activeRunCompletionPromise?: Promise<void>;
3213
- }
3214
- /**
3215
- * Type guard for {@link RunCompletionAware}. Returns true when `agent` exposes
3216
- * an `activeRunCompletionPromise` property, so callers can await an in-flight
3217
- * run without an `as unknown as` cast. Returns false for agents that don't
3218
- * implement the contract, letting the caller skip the await and degrade safely.
3219
- */
3220
- declare function isRunCompletionAware(agent: unknown): agent is RunCompletionAware;
3221
- interface IntelligenceAgentConfig {
3222
- /** Phoenix websocket URL, e.g. "ws://localhost:4000/socket" */
3223
- url: string;
3224
- /** Runtime base URL, e.g. "http://localhost:4000" */
3225
- runtimeUrl: string;
3226
- /** HTTP transport for run/connect requests. Defaults to REST. */
3227
- transport?: "rest" | "single";
3228
- /** Agent identifier for REST endpoints */
3229
- agentId: string;
3230
- /** Optional params sent on socket connect (e.g. auth token) */
3231
- socketParams?: Record<string, string>;
3232
- /** Optional headers sent with REST requests */
3233
- headers?: Record<string, string>;
3234
- /** Optional credentials mode for fetch requests */
3235
- credentials?: RequestCredentials;
3236
- fetch?: typeof fetch;
3237
- }
3238
- declare class IntelligenceAgent extends AbstractAgent {
3239
- private config;
3240
- private socket;
3241
- private activeChannel;
3242
- private canonicalRunId;
3243
- private sharedState;
3244
- constructor(config: IntelligenceAgentConfig, sharedState?: IntelligenceAgentSharedState);
3245
- /**
3246
- * Headers sent with the REST join requests (`/connect`, `/run`).
3247
- *
3248
- * Deliberately a public accessor pair rather than a plain read of `config`.
3249
- * `ProxiedCopilotRuntimeAgent` builds its delegate once and caches it for the
3250
- * proxy's lifetime, so a header that changes later (a tenant switch, a
3251
- * rotated bearer) would otherwise never reach the gateway. The accessor is
3252
- * what closes that gap: `syncDelegate` refreshes the delegate before every
3253
- * join, and its `hasHeaders` probe is an `"headers" in agent` check — which a
3254
- * prototype accessor satisfies but a `private config` does not.
3255
- *
3256
- * The setter replaces the config object instead of mutating it because
3257
- * `clone()` hands the same config reference to the copy. An in-place write
3258
- * would therefore have a per-thread clone's headers land on the original's
3259
- * config too. The join path itself would survive that (`syncDelegate`
3260
- * rewrites the headers just before every join), but the re-acquisition inside
3261
- * an already-running pipeline does not go through `syncDelegate` — so a
3262
- * clone's tenant could ride out on the original's socket-error refresh. That
3263
- * is the same cross-tenant leak this accessor exists to prevent.
3264
- */
3265
- get headers(): Record<string, string> | undefined;
3266
- set headers(headers: Record<string, string> | undefined);
3267
- /** Credentials mode for the REST join requests. Live for the same reason as {@link headers}. */
3268
- get credentials(): RequestCredentials | undefined;
3269
- set credentials(credentials: RequestCredentials | undefined);
3270
- clone(): IntelligenceAgent;
3271
- /**
3272
- * Override of AbstractAgent.connectAgent that removes the `verifyEvents` step.
3273
- *
3274
- * IntelligenceAgent uses long-lived WebSocket connections rather than
3275
- * request-scoped SSE streams. When connecting to replay historical messages
3276
- * for an existing thread, the connection semantics don't map to a single
3277
- * agent run start/stop cycle: the replayed events may omit the
3278
- * RUN_STARTED/RUN_FINISHED bookends, or carry events from several past runs,
3279
- * either of which makes `verifyEvents` stall or error out.
3280
- *
3281
- * See {@link ɵconnectWithoutEventVerification} for the pipeline itself, which
3282
- * the self-hosted `/connect` path shares for the same reason.
3283
- */
3284
- connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
3285
- abortRun(): void;
3286
- /**
3287
- * Trigger the run via REST, then join the realtime thread channel and relay
3288
- * server-pushed AG-UI events to the Observable subscriber.
3289
- */
3290
- run(input: RunAgentInput): Observable<BaseEvent>;
3291
- /**
3292
- * Reconnect to an existing thread by fetching websocket credentials and
3293
- * joining the realtime thread channel.
3294
- */
3295
- /**
3296
- * Reconnect to an existing thread by fetching websocket credentials
3297
- * and joining the realtime thread channel.
3298
- *
3299
- * Note: this method does NOT clear the replay cursor. Whether to
3300
- * request a full historical replay vs. resume from
3301
- * `lastSeenEventId` is a decision the caller (typically
3302
- * `RunHandler.connectAgent`) makes by calling
3303
- * {@link clearReconnectCursor} ahead of time on a fresh thread
3304
- * restore. Same-thread churn re-connects preserve the cursor so the
3305
- * gateway only streams events past it instead of replaying the
3306
- * entire history every time the chat re-opens a socket.
3307
- */
3308
- protected connect(input: RunAgentInput, lifecycle?: ConnectionReplayLifecycle): Observable<BaseEvent>;
3309
- /**
3310
- * Tear down a specific channel + socket pair that belongs to one pipeline.
3311
- * Only nulls instance references when they still point to the owned resource,
3312
- * so a concurrent pipeline's resources are never clobbered.
3313
- */
3314
- private cleanupOwned;
3315
- private cleanup;
3316
- private requestJoinCredentials$;
3317
- private normalizeJoinCredentials;
3318
- private observeThread$;
3319
- private observeThreadSession$;
3320
- private joinThreadChannel$;
3321
- private observeSocketHealth$;
3322
- private observeThreadEvents$;
3323
- private observeControlEvent$;
3324
- private observeChannelEvent$;
3325
- private createThreadNotifications;
3326
- private buildRuntimeUrl;
3327
- private createThreadChannelParams;
3328
- private getLastSeenEventId;
3329
- private getReconnectCursor;
3330
- /**
3331
- * Drop the cached `lastSeenEventId` cursor for `threadId` so the
3332
- * next connect to that topic asks the gateway for a full historical
3333
- * replay (rather than resuming). Public because
3334
- * `RunHandler.connectAgent` calls it on a detected thread switch
3335
- * to rebuild local state from scratch, and skips it on same-thread
3336
- * churn so the gateway can resume.
3337
- */
3338
- clearReconnectCursor(threadId: string): void;
3339
- private updateLastSeenEventId;
3340
- private updateLastSeenEventIdFromControl;
3341
- private advanceLastSeenEventId;
3342
- private readEventId;
3343
- private readControlEventId;
3344
- private readDurableEventId;
3345
- private canFallbackCompleteConnect;
3346
- private applyCanonicalRunIdentity;
3347
- private isSocketReconnectExhaustedError;
3348
- }
3349
- //#endregion
3350
- //#region src/utils/phoenix-observable.d.ts
3351
- /**
3352
- * Minimal Phoenix push contract used by the observable adapters.
3353
- */
3354
- interface ɵPhoenixPushLike {
3355
- receive(status: string, callback: (payload?: unknown) => unknown): ɵPhoenixPushLike;
3356
- }
3357
- /**
3358
- * Minimal Phoenix channel contract used by the observable adapters.
3359
- */
3360
- interface ɵPhoenixChannelLike {
3361
- on(event: string, callback: (payload: unknown) => void): number;
3362
- off(event: string, ref?: number): void;
3363
- onError?(callback: (reason?: unknown) => void): unknown;
3364
- join(params?: Record<string, unknown>): ɵPhoenixPushLike;
3365
- push?(event: string, payload: unknown): ɵPhoenixPushLike;
3366
- leave(): void;
3367
- }
3368
- /**
3369
- * Minimal Phoenix socket contract used by the observable adapters.
3370
- */
3371
- interface ɵPhoenixSocketLike {
3372
- connect(): void;
3373
- disconnect(): void;
3374
- channel(topic: string, params?: Record<string, unknown>): ɵPhoenixChannelLike;
3375
- onError(callback: (error?: unknown) => void): unknown;
3376
- onOpen(callback: () => void): unknown;
3377
- }
3378
- /**
3379
- * Socket lifecycle notifications exposed by {@link ɵphoenixSocket$}.
3380
- */
3381
- type ɵPhoenixSocketSignal = {
3382
- type: "open";
3383
- } | {
3384
- type: "error";
3385
- error?: unknown;
3386
- };
3387
- /**
3388
- * Terminal outcomes of a Phoenix channel join attempt.
3389
- */
3390
- type ɵPhoenixJoinOutcome = {
3391
- type: "joined";
3392
- } | {
3393
- type: "error";
3394
- response?: unknown;
3395
- } | {
3396
- type: "timeout";
3397
- };
3398
- /**
3399
- * Active Phoenix socket session plus its derived lifecycle stream.
3400
- */
3401
- interface ɵPhoenixSocketSession {
3402
- socket: ɵPhoenixSocketLike;
3403
- signals$: Observable<ɵPhoenixSocketSignal>;
3404
- }
3405
- /**
3406
- * Active Phoenix channel session plus its derived join-outcome stream.
3407
- */
3408
- interface ɵPhoenixChannelSession {
3409
- channel: ɵPhoenixChannelLike;
3410
- joinOutcome$: Observable<ɵPhoenixJoinOutcome>;
3411
- }
3412
- /**
3413
- * Options for creating a cold Phoenix socket session stream.
3414
- */
3415
- interface ɵPhoenixSocketOptions {
3416
- url: string;
3417
- options?: Record<string, unknown>;
3418
- }
3419
- /**
3420
- * Options for creating a cold Phoenix channel session stream from a socket stream.
3421
- */
3422
- interface ɵPhoenixChannelOptions {
3423
- socket$: Observable<ɵPhoenixSocketSession>;
3424
- topic: string;
3425
- params?: Record<string, unknown>;
3426
- leaveOnUnsubscribe?: boolean;
3427
- }
3428
- /**
3429
- * Create a cold Phoenix socket session.
3430
- *
3431
- * The socket is constructed and connected on subscription, and disconnected on
3432
- * teardown. Each subscription creates an isolated socket instance.
3433
- *
3434
- * Heartbeats default to every 15s: Phoenix's own 30s default matches common
3435
- * reverse-proxy WebSocket idle timeouts (e.g. Azure Application Gateway), which
3436
- * would drop the socket during a quiet run. Callers may override it.
3437
- */
3438
- declare function ɵphoenixSocket$(options: ɵPhoenixSocketOptions): Observable<ɵPhoenixSocketSession>;
3439
- /**
3440
- * Create a cold Phoenix channel session from a socket session stream.
3441
- *
3442
- * A channel is created and joined for each active socket session. If the
3443
- * upstream socket session changes, the previous channel is left before the
3444
- * next one becomes active.
3445
- */
3446
- declare function ɵphoenixChannel$(options: ɵPhoenixChannelOptions): Observable<ɵPhoenixChannelSession>;
3447
- /**
3448
- * Observe a named Phoenix channel event as an observable payload stream.
3449
- */
3450
- declare function ɵobservePhoenixEvent$<T>(channel: ɵPhoenixChannelLike, eventName: string): Observable<T>;
3451
- /**
3452
- * Flatten channel sessions into their join-outcome stream.
3453
- */
3454
- declare function ɵobservePhoenixJoinOutcome$(channel$: Observable<ɵPhoenixChannelSession>): Observable<ɵPhoenixJoinOutcome>;
3455
- /**
3456
- * Complete when a channel joins successfully, or error if the join fails.
3457
- */
3458
- declare function ɵjoinPhoenixChannel$(channel$: Observable<ɵPhoenixChannelSession>): Observable<never>;
3459
- /**
3460
- * Flatten socket sessions into their lifecycle signal stream.
3461
- */
3462
- declare function ɵobservePhoenixSocketSignals$(socket$: Observable<ɵPhoenixSocketSession>): Observable<ɵPhoenixSocketSignal>;
3463
- /**
3464
- * Error after a socket emits the configured number of consecutive error
3465
- * signals, resetting the counter after each successful open signal.
3466
- */
3467
- declare function ɵobservePhoenixSocketHealth$(socketSignals$: Observable<ɵPhoenixSocketSignal>, maxConsecutiveErrors: number): Observable<never>;
3468
- //#endregion
3469
- //#region src/features.d.ts
3470
- /**
3471
- * Central registry of CopilotKit feature names.
3472
- *
3473
- * Feature names are the strings passed to a license context's `checkFeature`
3474
- * (see `@copilotkit/shared`'s `LicenseContextValue`). Historically the only
3475
- * features referenced by literal were the chat surfaces (`chat`, `sidebar`,
3476
- * `popup`); this module makes the set explicit and typed so new surfaces —
3477
- * such as the threads drawer — register a real, discoverable feature name
3478
- * rather than an ad-hoc string scattered across components.
3479
- *
3480
- * `checkFeature` itself still accepts any `string` for backward compatibility;
3481
- * this registry simply documents and types the names CopilotKit recognises.
3482
- */
3483
- /**
3484
- * The set of feature names CopilotKit recognises.
3485
- *
3486
- * Frozen so the array cannot be mutated at runtime. Add new surfaces here when
3487
- * they begin gating behaviour on `checkFeature`.
3488
- */
3489
- declare const ɵCOPILOTKIT_FEATURES: readonly ["chat", "sidebar", "popup", "threads"];
3490
- /**
3491
- * Union of recognised CopilotKit feature names.
3492
- */
3493
- type ɵCopilotKitFeature = (typeof ɵCOPILOTKIT_FEATURES)[number];
3494
- /**
3495
- * Type guard: returns `true` when `name` is a recognised CopilotKit feature.
3496
- *
3497
- * @param name - Candidate feature name.
3498
- * @returns Whether `name` is a registered feature.
3499
- *
3500
- * @example
3501
- * ```ts
3502
- * if (ɵisCopilotKitFeature("threads")) {
3503
- * // narrowed to ɵCopilotKitFeature
3504
- * }
3505
- * ```
3506
- */
3507
- declare function ɵisCopilotKitFeature(name: string): name is ɵCopilotKitFeature;
3508
- //#endregion
3509
- //#region src/interrupt-state.d.ts
3510
- /** @internal Application authors must not depend on this contract. */
3511
- interface ɵInterruptEvent<TValue = unknown> {
3512
- name: string;
3513
- value: TValue;
3514
- }
3515
- /** @internal Application authors must not depend on this contract. */
3516
- type ɵPendingInterrupt<TValue = unknown> = {
3517
- kind: "legacy";
3518
- event: ɵInterruptEvent<TValue>;
3519
- } | {
3520
- kind: "standard";
3521
- interrupts: readonly Interrupt[];
3522
- };
3523
- /** @internal Application authors must not depend on this contract. */
3524
- interface ɵInterruptToolResult {
3525
- toolCallId: string;
3526
- content: Extract<Message, {
3527
- role: "tool";
3528
- }>["content"];
3529
- }
3530
- /** @internal Application authors must not depend on this contract. */
3531
- type ɵInterruptDecision = {
3532
- kind: "ignored";
3533
- } | {
3534
- kind: "waiting";
3535
- } | {
3536
- kind: "dismiss";
3537
- } | {
3538
- kind: "expired";
3539
- interrupt: Interrupt;
3540
- } | {
3541
- kind: "legacy-resume";
3542
- payload: unknown;
3543
- interruptValue: unknown;
3544
- } | {
3545
- kind: "resume";
3546
- resume: ResumeEntry[];
3547
- toolResults: ɵInterruptToolResult[];
3548
- };
3549
- /**
3550
- * @internal Framework-neutral interrupt response state shared by framework
3551
- * adapters. Application authors must not depend on this API.
3552
- */
3553
- declare class ɵInterruptState<TValue = unknown> {
3554
- #private;
3555
- /** Return the active normalized interrupt without exposing mutable state. */
3556
- get pending(): ɵPendingInterrupt<TValue> | null;
3557
- /** Replace the current interrupt with a legacy custom-event interrupt. */
3558
- setLegacy(event: ɵInterruptEvent<TValue>): void;
3559
- /** Replace the current interrupt with an AG-UI standard interrupt set. */
3560
- setStandard(interrupts: readonly Interrupt[]): void;
3561
- /** Clear all pending interrupt data and accumulated responses. */
3562
- clear(): void;
3563
- /** Record a resolved response and return the next framework action. */
3564
- resolve(payload?: unknown, interruptId?: string, messages?: readonly Message[]): ɵInterruptDecision;
3565
- /** Record a cancelled response and return the next framework action. */
3566
- cancel(interruptId?: string, messages?: readonly Message[]): ɵInterruptDecision;
3567
- /** Reject ambiguous assistant definitions before executing or answering a call. */
3568
- validateToolCalls(messages: readonly Message[]): void;
3569
- /** Let UI adapters ignore answers for exactly one successful frontend result. */
3570
- isCompletedToolCall(interruptId: string | undefined, messages: readonly Message[]): boolean;
3571
- /** Resume only when saved frontend results answer every pending interrupt. */
3572
- resumeWithToolResults(messages: readonly Message[]): ɵInterruptDecision;
3573
- }
3574
- /** @internal Share decisions and the single resume claim for an agent's pending batch. */
3575
- declare function ɵgetAgentInterruptState(agent: AbstractAgent, interrupts?: readonly Interrupt[]): ɵInterruptState;
3576
- /** @internal A new run owns a new batch, even if the server reuses interrupt IDs. */
3577
- declare function ɵclearAgentInterruptState(agent: AbstractAgent): void;
3578
- //#endregion
3579
- //#region src/inspector-thread-bridge.d.ts
3580
- declare const INSPECTOR_THREAD_BRIDGE_PLUGIN_ID: "cpk-inspector-thread";
3581
- type InspectorViewThreadPayload = {
3582
- requestId: string;
3583
- threadId: string;
3584
- agentId: string;
3585
- };
3586
- type InspectorStopViewingPayload = {
3587
- requestId: string;
3588
- agentId: string;
3589
- };
3590
- type InspectorActiveThreadPayload = {
3591
- requestId: string;
3592
- threadId: string;
3593
- agentId: string;
3594
- source: "app" | "override";
3595
- };
3596
- type InspectorViewThreadResultPayload = {
3597
- requestId: string;
3598
- threadId: string;
3599
- agentId: string;
3600
- ok: true;
3601
- } | {
3602
- requestId: string;
3603
- threadId: string;
3604
- agentId: string;
3605
- ok: false;
3606
- reason: "connect-failed";
3607
- };
3608
- /** The Inspector thread bridge is development-only. */
3609
- declare function isInspectorThreadBridgeEnabled(): boolean;
3610
- declare function createInspectorThreadRequestId(): string;
3611
- /**
3612
- * Ask the first mounted official chat for the matching agent to load a thread.
3613
- * Returns false when no chat claims the request synchronously.
3614
- */
3615
- declare function emitInspectorViewThread(payload: InspectorViewThreadPayload): boolean;
3616
- declare function emitInspectorStopViewing(payload: InspectorStopViewingPayload): void;
3617
- declare function emitInspectorActiveThread(payload: InspectorActiveThreadPayload): void;
3618
- declare function emitInspectorViewThreadResult(payload: InspectorViewThreadResultPayload): void;
3619
- declare function onInspectorViewThread(handler: (payload: InspectorViewThreadPayload) => boolean): () => void;
3620
- declare function onInspectorStopViewing(handler: (payload: InspectorStopViewingPayload) => void): () => void;
3621
- declare function onInspectorActiveThread(handler: (payload: InspectorActiveThreadPayload) => void): () => void;
3622
- declare function onInspectorViewThreadResult(handler: (payload: InspectorViewThreadResultPayload) => void): () => void;
3623
- //#endregion
3624
- //#region src/a2ui-markdown/fence-parser.d.ts
3625
- /** Language of a fenced code block that carries A2UI operations. */
3626
- declare const A2UI_FENCE_LANGUAGE = "a2ui";
3627
- /**
3628
- * One part of an assistant message, in source order: prose markdown, or the
3629
- * body of a top-level ```a2ui fence. `target` is the id from a
3630
- * `target=<id>` token in the fence info string. With no target, the surface
3631
- * goes to the chat.
3632
- */
3633
- type MarkdownSegment = {
3634
- type: "markdown";
3635
- text: string;
3636
- } | {
3637
- type: "a2ui";
3638
- index: number;
3639
- text: string;
3640
- closed: boolean;
3641
- target?: string;
3642
- };
3643
- /**
3644
- * Split a (possibly still streaming) markdown string into prose segments and
3645
- * top-level ```a2ui fences. Fences of other languages stay inside prose
3646
- * segments byte-for-byte, and a2ui markers inside them are ignored. Only
3647
- * column-0 fences are recognised, so a fence indented inside a list item is
3648
- * left to the markdown renderer.
3649
- *
3650
- * The first info-string token must be exactly `a2ui`. A later
3651
- * `target=<id>` token sets `target` on the segment (for example
3652
- * ```` ```a2ui target=recommendations ````). Other tokens are ignored.
3653
- *
3654
- * An a2ui segment's `text` is the fence body. For a closed fence it ends with
3655
- * "\n" when non-empty. For an open (still streaming or aborted) fence it is
3656
- * everything after the opener line, minus a half-streamed closing marker.
3657
- *
3658
- * @param markdown - The assistant message text, complete or still streaming.
3659
- * @returns The segments in source order.
3660
- *
3661
- * @example
3662
- * ```ts
3663
- * for (const segment of splitA2UIMarkdown(message.content)) {
3664
- * if (segment.type === "a2ui") renderSurface(segment.text, segment.target);
3665
- * else renderMarkdown(segment.text);
3666
- * }
3667
- * ```
3668
- */
3669
- declare function splitA2UIMarkdown(markdown: string): MarkdownSegment[];
3670
- //#endregion
3671
- //#region src/a2ui-markdown/operations.d.ts
3672
- /**
3673
- * An A2UI v1.0 message as the model wrote it in an a2ui fence: an object that
3674
- * carries one of createSurface, updateComponents, updateDataModel,
3675
- * deleteSurface or callRendererFunction. The shape is not checked yet.
3676
- * Validate it (for example with `validateOperation` from `@copilotkit/shared`)
3677
- * before it reaches a surface or runs a function.
3678
- *
3679
- * It is named `A2UIMarkdownOperation` because `@copilotkit/shared` already
3680
- * exports the strict `A2UIOperation` type.
3681
- */
3682
- type A2UIMarkdownOperation = Record<string, unknown>;
3683
- /**
3684
- * Read `"key":"value"` from partial JSON. The first match anywhere in the
3685
- * text wins, at any depth.
3686
- *
3687
- * @param partialJson - JSON text that can still be streaming.
3688
- * @param key - The field name.
3689
- * @returns The string value, or null until its closing quote has arrived.
3690
- *
3691
- * @example
3692
- * ```ts
3693
- * extractStringField('{"createSurface":{"surfaceId":"plan","cat', "surfaceId"); // "plan"
3694
- * ```
3695
- */
3696
- declare function extractStringField(partialJson: string, key: string): string | null;
3697
- /**
3698
- * Find `"key":[` in partial JSON and return every complete item of that array
3699
- * so far, plus whether the array has closed. Items of a `components` array get
3700
- * structural-key depth repair: a component that lost closing braces is fixed
3701
- * when its `id`, `component`, `child` or `children` key shows where it ends.
3702
- *
3703
- * @param partialJson - JSON text that can still be streaming.
3704
- * @param key - The name of the array field.
3705
- * @returns `{ items, closed }`, or null when the key (with an array value)
3706
- * has not appeared yet.
3707
- *
3708
- * @example
3709
- * ```ts
3710
- * const result = extractCompleteArrayItems(streamedText, "components");
3711
- * if (result) render(result.items);
3712
- * ```
3713
- */
3714
- declare function extractCompleteArrayItems(partialJson: string, key: string): {
3715
- items: unknown[];
3716
- closed: boolean;
3717
- } | null;
3718
- /**
3719
- * The surfaceId an operation targets: the one nested under its operation key,
3720
- * else a top-level `surfaceId`. A `callRendererFunction` operation targets no
3721
- * surface, so it gets undefined.
3722
- *
3723
- * It is named `getMarkdownOperationSurfaceId` because `@copilotkit/shared`
3724
- * already exports a strict `getOperationSurfaceId`. This one also reads a
3725
- * top-level `surfaceId`, which models sometimes write.
3726
- *
3727
- * @param op - An operation from an a2ui fence.
3728
- * @returns The surfaceId, or undefined when the operation names none or is a
3729
- * function call.
3730
- *
3731
- * @example
3732
- * ```ts
3733
- * getMarkdownOperationSurfaceId({ updateDataModel: { surfaceId: "plan" } }); // "plan"
3734
- * ```
3735
- */
3736
- declare function getMarkdownOperationSurfaceId(op: A2UIMarkdownOperation): string | undefined;
3737
- /**
3738
- * Parse the body of an a2ui fence as a stream of top-level JSON values, so
3739
- * operations may be one per line (the documented format), several per line,
3740
- * pretty-printed over many lines, or wrapped in a top-level array (which is
3741
- * flattened). Whitespace and commas between objects are ignored.
3742
- *
3743
- * - A balanced object is `JSON.parse`d. When that fails (e.g. a stray quote),
3744
- * its raw text goes to `invalidLines` and whatever `partialOperation` can
3745
- * salvage (complete components, data-model entries, createSurface fields)
3746
- * is kept.
3747
- * - An unbalanced object followed by a line that opens a new operation is
3748
- * treated the same way.
3749
- * - The trailing unbalanced object (still streaming, or never closed) is
3750
- * `partialObject` and yields a partial operation when it has usable data.
3751
- * - Other text between objects is skipped and reported in `recovered` (and in
3752
- * `invalidLines`, which predates it).
3753
- *
3754
- * `partialLine` is a deprecated alias of `partialObject`.
3755
- *
3756
- * @param fenceText - The body of an a2ui fence (`text` of an a2ui
3757
- * `MarkdownSegment`), complete or still streaming.
3758
- * @returns `{ operations, partialObject, partialLine, invalidLines, recovered }`.
3759
- *
3760
- * @example
3761
- * ```ts
3762
- * const { operations } = extractFenceOperations(segment.text);
3763
- * ```
3764
- */
3765
- declare function extractFenceOperations(fenceText: string): {
3766
- operations: A2UIMarkdownOperation[];
3767
- partialObject: string | null;
3768
- partialLine: string | null;
3769
- invalidLines: string[];
3770
- recovered: string[];
3771
- };
3772
- /**
3773
- * Normalise a fence's operations for the renderer: drop unknown messages, fill
3774
- * in `version` and missing `surfaceId`s, keep only the first `createSurface`,
3775
- * keep its `catalogId` when `catalogIds` lists it (else use `catalogId`), synthesize
3776
- * `createSurface` when the model omitted it, and report the
3777
- * surfaceId (the first one found, else `fallbackSurfaceId`).
3778
- *
3779
- * `callRendererFunction` operations target no surface. They get no surfaceId,
3780
- * do not cause a synthesized `createSurface`, and come back in
3781
- * `functionCalls` (in fence order), never in `operations`.
3782
- *
3783
- * @param input.operations - Operations from `extractFenceOperations`.
3784
- * @param input.fallbackSurfaceId - The surfaceId to use when no operation
3785
- * names one.
3786
- * @param input.catalogId - The client catalog. It replaces a catalogId of the
3787
- * model that `catalogIds` does not list.
3788
- * @param input.catalogIds - The catalogs that the model can name. Left out,
3789
- * only `catalogId`.
3790
- * @returns `{ surfaceId, operations, functionCalls }`.
3791
- *
3792
- * @example
3793
- * ```ts
3794
- * const { surfaceId, operations, functionCalls } = prepareSurfaceOperations({
3795
- * operations: extractFenceOperations(segment.text).operations,
3796
- * fallbackSurfaceId: `${messageId}-${segment.index}`,
3797
- * catalogId,
3798
- * });
3799
- * ```
3800
- */
3801
- declare function prepareSurfaceOperations(input: {
3802
- operations: A2UIMarkdownOperation[];
3803
- fallbackSurfaceId: string;
3804
- catalogId: string;
3805
- catalogIds?: readonly string[];
3806
- }): {
3807
- surfaceId: string;
3808
- operations: A2UIMarkdownOperation[];
3809
- functionCalls: A2UIMarkdownOperation[];
3810
- };
3811
- /**
3812
- * More ids a component renders, beyond `child`, `children` and the table
3813
- * cells: the typed child references of its catalog, which can sit at any
3814
- * depth of its props (the `child` of each entry of `tabs`). The catalog
3815
- * knows them; the operations alone do not.
3816
- */
3817
- type ChildIdsOf = (component: Record<string, unknown>) => string[] | "unknown";
3818
- /** The options of the walks that follow child ids. */
3819
- interface ChildWalkOptions {
3820
- childIds?: ChildIdsOf;
3821
- }
3822
- /**
3823
- * Ids of the `Card` components that are interactive panels: at least one
3824
- * descendant (via `child`, `children` or table component cells) is a control
3825
- * (Button, Pressable, Form, TextField, TextArea, Select, CheckBox, Radio,
3826
- * RadioGroup, Slider, SegmentedControl, DateTimeInput).
3827
- *
3828
- * @param components - The components of one surface.
3829
- * @returns The ids of the interactive cards.
3830
- *
3831
- * @example
3832
- * ```ts
3833
- * const interactive = classifySurfaceCards(components);
3834
- * const keepsBox = interactive.has("quote-form");
3835
- * ```
3836
- */
3837
- declare function classifySurfaceCards(components: Record<string, unknown>[], options?: ChildWalkOptions): Set<string>;
3838
- /**
3839
- * Markdown mode: only interactive panels keep a box. Every `Card` that is not
3840
- * an interactive panel (see `classifySurfaceCards`), sets no `variant` or
3841
- * `border` of its own and is not nested inside an interactive panel becomes
3842
- * `variant: "section"` (a heading plus content without a box). Operations
3843
- * other than updateComponents pass through unchanged.
3844
- *
3845
- * @param operations - The operations of one surface.
3846
- * @returns The operations with informational cards set to `variant: "section"`.
3847
- * When no card changes, it returns the same array.
3848
- *
3849
- * @example
3850
- * ```ts
3851
- * const operations = flattenInformationalCards(prepared.operations);
3852
- * ```
3853
- */
3854
- declare function flattenInformationalCards(operations: A2UIMarkdownOperation[], options?: ChildWalkOptions): A2UIMarkdownOperation[];
3855
- /** One block of a segmented surface, in render order. */
3856
- type SurfaceSegment = {
3857
- kind: "markdown";
3858
- markdown: string;
3859
- } | {
3860
- kind: "surface";
3861
- components: Record<string, unknown>[];
3862
- };
3863
- /**
3864
- * Markdown mode: split a surface into markdown and surface segments so that
3865
- * only real UI renders as A2UI and everything else is the chat's markdown.
3866
- *
3867
- * From `root`, descend through single-child vertical containers (Column,
3868
- * column Box, informational Card) to the first one with several children:
3869
- * the stack. Its children are partitioned, in order, into runs of prose and
3870
- * runs of UI. Prose is `Title`, `Text`, `Caption`, `Markdown` with literal
3871
- * text, a `List` of literal text items, plus `Divider`/`Spacer` next to them:
3872
- * `Title` → heading by size (sm `####`, md/lg `###`, larger `##`), `Text` →
3873
- * paragraph (`strong` → `**…**`), `Caption`/`Markdown` → paragraph, `List` →
3874
- * `- …` (or `1. …` for `marker: "number"`, `**label** — description` for
3875
- * described items), and a `Divider` between two prose blocks → `---`.
3876
- *
3877
- * Not prose: `{path}`-bound text or items, a Text with inline children, a
3878
- * List with `children`/icons/actions, a template entry, a component with an
3879
- * `accessibility` envelope, and a child whose component has not streamed
3880
- * yet. Separators with no text beside them stay in
3881
- * the surface. An interactive Card (see `classifySurfaceCards`) is never
3882
- * entered.
3883
- *
3884
- * Each prose run becomes a markdown segment; each UI run becomes a surface
3885
- * segment whose `root` is a copy of the stack (its other props kept, `child`
3886
- * dropped) with only that run's `children`, followed by every component
3887
- * reachable from them. When nothing is prose the input comes back as the one
3888
- * surface segment (same array); when everything is (or `root` itself is),
3889
- * there are only markdown segments.
3890
- *
3891
- * Pure and linear in the number of components, so it runs on every stream
3892
- * update.
3893
- *
3894
- * @param components - The components of one surface, root included.
3895
- * @returns The segments in render order.
3896
- *
3897
- * @example
3898
- * ```ts
3899
- * for (const segment of segmentSurfaceProse(components)) {
3900
- * if (segment.kind === "markdown") renderMarkdown(segment.markdown);
3901
- * else renderSurface(segment.components);
3902
- * }
3903
- * ```
3904
- */
3905
- declare function segmentSurfaceProse(components: Record<string, unknown>[], options?: ChildWalkOptions): SurfaceSegment[];
3906
- //#endregion
3907
- 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, MarkdownToken, MarkdownTokenList, Memory, MemoryChanges, MemoryError, type MemoryErrorCategory, type MemoryErrorCode, type MemoryErrorRegistryEntry, MemoryKind, MemoryRealtimeStatus, MemoryScope, NewMemory, NonDispatchingEffect, NonDispatchingEffectOptions, type OpenThreadRegistration, ParseMarkdownOptions, 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, type Tokens, 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, parseMarkdown, 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, ɵclearAgentInterruptState, createMemoryStore as ɵcreateMemoryStore, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵgetAgentInterruptState, ɵ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 };
3908
- //# sourceMappingURL=index.d.cts.map
1
+ import { $ as isOpenGenerativeUIActive, $a as getToolCallRowStatus, $c as ɵRuntimeInfoStore, $i as ɵChatRunScope, $l as ToolCallRendererDef, $n as ɵINLINE_FEATURE_WARNING_STYLE, $o as A2UI_FENCE_LANGUAGE, $r as ɵComposerAutosizeOptions, $s as ɵPhoenixChannelOptions, $t as ɵStickToBottom, $u as CopilotKitHeaderResolutionError, A as ɵThreadSelectors, Aa as TOOL_CALL_STATUS_ICONS, Ac as Store, Ad as RuntimeLicenseStatus, Ai as ɵresolveSlashKey, Al as ɵpublicKeyHeaderDefaults, An as ɵsubscribeToLearningFeedbackEnabled, Ao as ɵgetCustomMessageRenderProps, Ar as ɵbindDialogFocus, As as ɵMemoryEnvironment, At as ɵAssistantToolbarInput, Au as ɵbuildLearnFromUserActionPayload, B as ɵthreadAdapterEvents, Ba as TurnOpenState, Bc as props, Bi as ɵcreateMessageViewModel, Bl as ɵbindSuggestionsConfig, Bn as ɵThreadSummary, Bo as ɵformatLabel, Br as ɵisFocusVisible, Bs as ɵselectMemories, Bt as ɵformatReasoningDurationLabel, Bu as ɵAgentUpdateFlag, C as createThreadStore, Ca as ɵAttachmentQueue, Cc as Effect, Cd as CopilotRuntimeTransport, Ci as ɵfilterCommands, Cl as ɵStableArrayProp, Cn as ɵMessageFeedbackScope, Co as ɵtoDefaultToolCallStatus, Cr as ɵPopupDismissOptions, Cs as Memory, Ct as ɵInspectorKiteArtwork, Cu as ɵGenerativeUIDebugSurface, D as ɵThreadEnvironment, Da as ɵmessagesFingerprint, Dc as PropsActionConfig, Dd as FrontendToolReconnectBehavior, Di as ɵnormalizeToolsMenu, Dl as ɵassembleProviderRegistry, Dn as ɵisOwnFeedbackThumb, Do as ɵCustomMessageRunSource, Dr as ɵSIDEBAR_TRANSITION_MS, Ds as MemoryScope, Dt as ɵinspectorKiteFill, Du as ɵLearnFromUserActionFields, E as ɵThread, Ea as ɵdeduplicateMessages, Ec as NonDispatchingEffectOptions, Ed as FrontendToolHandlerContext, Ei as ɵnextSlashIndex, El as ɵassembleHumanInTheLoop, En as ɵisLearningFeedbackEnabled, Eo as ɵActivityRendererQuery, Er as ɵSIDEBAR_DEFAULT_WIDTH, Es as MemoryRealtimeStatus, Et as ɵInspectorKiteStop, Eu as ɵRendererRegistryInit, F as ɵselectIsFetchingNextPage, Fa as ToolCallLayout, Fc as createSelector, Fd as SuggestionsConfig, Fi as ɵcreateLastUserMessageTracker, Fl as ɵtoolRendererShapeChanged, Fn as ɵThreadsDrawerThreads, Fo as ɵresolveCustomMessageRenderers, Fr as ɵcreateObjectUrlFromSource, Fs as ɵmapMemoryMetadataEvent, Ft as ɵReasoningDisclosureOptions, Fu as ɵserializeContextValue, G as PlaceholderCycler, Ga as formatToolNames, Gc as RunCompletionAware, Gi as ɵChatConnectionHandle, Gl as ɵhitlRenderProps, Gn as ɵprojectThread, Go as classifySurfaceCards, Gr as ɵwatchElementWidth, Gs as ɵselectMemoriesRealtimeStatus, Gt as ɵgetWorkSummaryText, Gu as ɵsnapshotAgentState, H as cn, Ha as WorkTime, Hc as AgentThreadLockedError, Hi as ɵshouldShowMessageCursor, Hl as ɵHITL_ABORTED_MESSAGE, Hn as ɵThreadsCore, Ho as ChildIdsOf, Hr as ɵmorphViewTransition, Hs as ɵselectMemoriesError, Ht as ɵgetReasoningHeaderLabel, Hu as ɵgetAgentResolver, I as ɵselectIsMutating, Ia as ToolCallRendererNames, Ic as createStore, Id as ThreadEndpointRuntimeInfo, Ii as ɵgetChatViewState, Il as ɵStaticSuggestionInput, In as ɵcreateThreadsDrawerActions, Io as ɵresolveToolCallRenderer, Ir as ɵdecodeTextSource, Is as ɵmemoryAdapterEvents, It as ɵReasoningDisclosureState, Iu as ɵALL_AGENT_UPDATES, J as OPEN_GENERATIVE_UI_SANDBOX_FUNCTIONS_CONTEXT_DESCRIPTION, Ja as getLatestTurnKey, Jc as completePartialMarkdown, Ji as ɵChatErrorEvent, Jl as CustomMessageRenderProps, Jn as CopilotIconName, Jo as extractStringField, Jr as ɵAudioRecorderState, Js as MemoryErrorCategory, Jt as ɵAutoScrollMode, Ju as WebMCPModelContext, K as PlaceholderCyclerSnapshot, Ka as formatWorkDuration, Kc as isRunCompletionAware, Ki as ɵChatConnectionOptions, Kl as ActivityMessageRenderProps, Kn as CopilotIconData, Ko as extractCompleteArrayItems, Kr as ɵAudioRecorder, Ks as MEMORY_ERROR_REGISTRY, Kt as ɵhasAssistantMessageText, Ku as ɵsubscribeToAgentUpdates, L as ɵselectThreads, La as ToolCallRendererNamesOptions, Lc as empty, Ld as ToolCallStatus, Li as ɵgetLastUserMessageId, Ll as ɵSuggestionsBinding, Ln as ɵfindChatInput, Lo as CopilotChatDefaultLabels, Lr as ɵdimensionToCss, Ls as ɵmemoryDomainEvents, Lt as ɵUserMessageMediaPart, Lu as ɵAgentBindingInput, M as ɵcreateThreadSelectors, Ma as ToolCallDisplayContextValue, Mc as createActionGroup, Md as StaticSuggestionsConfig, Mi as ɵsyncRecorderToMode, Ml as ɵresolveGenerativeUIDefault, Mn as ɵDrawerThread, Mo as ɵmatchActivityRenderer, Mr as ɵcanPreviewDocument, Ms as ɵMemoryRuntimeContext, Mt as ɵCOPY_FEEDBACK_RESET_MS, Mu as ɵAgentContextInput, N as ɵselectFetchMoreError, Na as ToolCallEntry, Nc as createEffect, Nd as Suggestion, Ni as ɵChatViewStateInput, Nl as ɵresolveProviderConfig, Nn as ɵThreadsDrawerCallbacks, No as ɵresolveActivityRenderer, Nr as ɵcreateDockedSidebar, Ns as ɵMemoryState, Nt as ɵCopyFeedback, Nu as ɵJsonSerializable, O as ɵThreadMetadataEvent, Oa as CopilotChatToolCallDisplay, Oc as Reducer, Od as InspectorMetadataV1, Oi as ɵparseSlashQuery, Ol as ɵassembleProviderToolRenderers, On as ɵresetMessageFeedbackCache, Oo as ɵdescribeActivityRendererFailure, Or as ɵSidebarPosition, Os as NewMemory, Ot as ɵinspectorKiteIcon, Ou as ɵRecordAnnotationArgs, P as ɵselectHasNextPage, Pa as ToolCallGroupAppearance, Pc as createReducer, Pd as SuggestionAvailability, Pi as ɵLastUserMessageState, Pl as ɵstableArrayPropWarning, Pn as ɵThreadsDrawerConfig, Po as ɵresolveCustomMessageRenderContext, Pr as ɵcreateExitPresence, Ps as ɵMemoryStore, Pt as ɵReasoningDisclosure, Pu as ɵgetAgentCapabilities, Q as createOpenGenerativeUITool, Qa as getToolCallRendererNames, Qc as ɵRuntimeInfo, Qi as ɵChatNotice, Ql as ToolCallRenderProps, Qn as LicenseStateInput, Qo as segmentSurfaceProse, Qr as ɵComposerAutosize, Qs as ɵPhoenixChannelLike, Qt as ɵPinMessageToTopOptions, Qu as isAbortError, R as ɵselectThreadsError, Ra as ToolCallRowStatus, Rc as ofType, Rd as WebMCPToolAnnotations, Ri as ɵMessageViewInput, Rl as ɵSuggestionsBindingOptions, Rn as ɵgetThreadsDrawerElementProps, Ro as CopilotChatLabels, Rr as ɵdockedSidebarRegistryFor, Rs as ɵmemoryReducer, Rt as ɵWorkSummaryInput, Ru as ɵAgentResolveInput, S as ThreadRunActivityNotification, Sa as ɵThreadSwitchCoordinator, Sc as DispatchingEffectOptions, Sd as CopilotKitMessageFilter, Si as ɵcomposerButtonState, Sl as ɵSTABLE_ARRAY_WARNINGS, Sn as ɵMessageFeedbackRating, So as ɵresolveToolCallAgentId, Sr as ɵPOPUP_DEFAULT_WIDTH, Ss as ɵisCopilotKitFeature, St as ɵHoverMenuState, Su as ɵGenerativeUIDebugSource, T as ɵTHREAD_REQUEST_TIMEOUT_MS, Ta as ɵbuildUserMessageContent, Tc as NonDispatchingEffect, Td as FrontendTool, Ti as ɵflattenToolsMenuForDisplay, Tl as ɵassembleActivityRenderers, Tn as ɵgetMessageFeedbackControls, To as ɵActivityRendererLookup, Tr as ɵSCROLL_BOTTOM_THRESHOLD_PX, Ts as MemoryKind, Tt as ɵInspectorKitePath, Tu as ɵRendererRegistry, U as shallowEqualRecord, Ua as countFailedToolCalls, Uc as IntelligenceAgent, Ui as ɵChatConnectHooks, Ul as ɵHumanInTheLoopRegistry, Un as ɵThreadsInput, Uo as ChildWalkOptions, Ur as ɵnextTabStop, Us as ɵselectMemoriesIsLoading, Ut as ɵgetUserMessageMediaFilename, Uu as ɵresolveAgentId, V as ClassValue, Va as TurnWork, Vc as select, Vi as ɵduplicateMessagesWarning, Vl as ɵsubscribeToAgentSuggestions, Vn as ɵThreadsController, Vo as A2UIMarkdownOperation, Vr as ɵisScrolledToBottom, Vs as ɵselectMemoriesAvailable, Vt as ɵgetBranchNavState, Vu as ɵagentUpdateHandlers, W as PLACEHOLDER_CYCLE_MS, Wa as formatReasoningDuration, Wc as IntelligenceAgentConfig, Wi as ɵChatConnection, Wl as ɵbuildHumanInTheLoopTool, Wn as ɵThreadsSnapshot, Wo as SurfaceSegment, Wr as ɵwatchElementHeight, Ws as ɵselectMemoriesIsMutating, Wt as ɵgetUserMessageMediaParts, Wu as ɵresolveAgentThreadId, X as addOpenGenerativeUIContexts, Xa as getToolCallLayouts, Xc as ɵFrontendToolRenderer, Xi as ɵimplementsConnect, Xl as CustomMessageRendererPosition, Xn as ɵcopilotIconSvgAttributes, Xo as getMarkdownOperationSurfaceId, Xr as ɵrmsAmplitude, Xs as MemoryErrorRegistryEntry, Xt as ɵKeyboardState, Xu as getWebMCPModelContext, Y as OpenGenerativeUISandboxFunction, Ya as getToolCallGroupState, Yc as isContentPart, Yi as ɵFreshThreadId, Yl as CustomMessageRendererDef, Yn as CopilotIconNode, Yo as flattenInformationalCards, Yr as ɵcreateWaveformRenderer, Ys as MemoryErrorCode, Yt as ɵKEYBOARD_OPEN_THRESHOLD_PX, Yu as WebMCPRegistry, Z as buildOpenGenerativeUIContexts, Za as getToolCallPreview, Zc as ɵregisterFrontendTools, Zi as ɵsubscribeToAgentErrors, Zl as HumanInTheLoopRenderProps, Zn as ɵcopilotIcons, Zo as prepareSurfaceOperations, Zr as ɵCOMPOSER_DEFAULT_MAX_ROWS, Zs as isRetryableStatus, Zt as ɵMOBILE_MAX_WIDTH_QUERY, Zu as SuggestionEngine, _ as ScopedProperties, _a as ɵtranscribeAudio, _c as ActionFromCreators, _d as CopilotKitCoreRegisterProxiedAgentParams, _i as ɵRunnableCommand, _l as ɵProviderHumanInTheLoop, _n as ɵFeedbackThumbHandlers, _o as ɵfindToolMessage, _r as ɵElementHeightState, _s as ɵInspectorThreadOverride, _t as GenerateSandboxedUiArgs, _u as ɵgetAgentInterruptState, a as CopilotKitCore, aa as ɵbuildUserMessage, ac as ɵPhoenixSocketSession, ad as CopilotKitCoreRunAgentParams, ai as ɵmeasureTextarea, al as ɵActivityRenderersInput, an as ɵpinMessageToTop, ao as pluralize, ar as ɵLicenseBannerType, as as InspectorViewThreadPayload, at as OpenGenerativeUIPhase, au as INTERRUPT_EVENT_NAME, b as SubscribeToAgentSubscriber, ba as ɵThreadSelection, bc as AnyAction, bd as ProxiedCopilotRuntimeAgent, bi as ɵToolsMenuDisplayEntry, bl as ɵReportProviderConfigDiagnosticsOptions, bn as ɵMessageFeedback, bo as ɵnormalizeToolCallStatus, br as ɵPOPUP_ANIMATION_MS, bs as ɵCOPILOTKIT_FEATURES, bt as ɵHOVER_MENU_CLOSE_DELAY_MS, bu as ɵGenerativeUIDebugRun, c as CopilotKitCoreErrorEvent, ca as ɵstopAgentWithFallback, cc as ɵobservePhoenixEvent$, cd as RunHandler, ci as ɵComposerControllerInputs, cl as ɵCOPILOT_CLOUD_RUNTIME_URL, cn as ɵwatchMobileViewport, co as stringifyToolCallPayload, cr as ɵreserveLicenseBannerOffset, cs as emitInspectorActiveThread, ct as SandboxLocalApi, cu as InterruptHandlerProps, d as CopilotKitCoreGetSuggestionsResult, da as TranscriptionCore, dc as ɵobservePhoenixSocketSignals$, dd as CopilotKitCoreContinuationHandoff, di as ɵComposerKeyAction, dl as ɵGenerativeUIDefault, dn as ɵFeedbackCommentControllerOptions, do as ɵRawToolCallRenderProps, dr as ɵDialogFocusOptions, ds as emitInspectorViewThreadResult, dt as WebsandboxLoader, du as ɵInterruptDecision, ea as ɵChatSubmitter, ec as ɵPhoenixChannelSession, ed as CopilotKitHeadersSource, ei as ɵComposerElements, el as ɵThreadBaselineResetOptions, en as ɵStickToBottomOptions, eo as getToolResults, er as ɵLICENSE_BANNER_OFFSET, es as MarkdownSegment, et as GENERATE_SANDBOXED_UI_ARGS_SCHEMA, eu as ɵInterruptController, f as CopilotKitCoreRuntimeConnectionStatus, fa as TranscriptionError, fc as ɵphoenixChannel$, fd as StateManager, fi as ɵComposerKeyDownResult, fl as ɵGenerativeUIDefaultInput, fn as ɵFeedbackCommentState, fo as ɵToolCallCardStatus, fr as ɵDockedSidebar, fs as isInspectorThreadBridgeEnabled, ft as loadWebsandbox, fu as ɵInterruptEvent, g as JsonValue, ga as ɵTranscriptionErrorLabelKey, gc as ActionFromCreator, gd as CopilotKitCoreAddAgentParams, gi as ɵModeRecorder, gl as ɵProviderFrontendTool, gn as ɵFeedbackThumbAttributes, go as ɵdescribeUnrenderedToolCalls, gr as ɵDockedSidebarTransition, gs as onInspectorViewThreadResult, gt as GENERATE_SANDBOXED_UI_TOOL_NAME, gu as ɵclearAgentInterruptState, h as CopilotKitCoreSubscription, ha as TranscriptionResult, hc as ActionCreator, hd as AgentRegistry, hi as ɵComposerSnapshot, hl as ɵProviderConfigInput, hn as ɵFeedbackThumb, ho as ɵcomponentToolDescription, hr as ɵDockedSidebarState, hs as onInspectorViewThread, ht as DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL, hu as ɵPendingInterrupt, i as TrajectoryStartOptions, ia as ɵappendTranscript, ic as ɵPhoenixSocketOptions, id as CopilotKitCoreGetToolParams, ii as ɵfitTextareaHeight, il as ɵtoLearningConfig, in as ɵnormalizeAutoScroll, io as isTurnWorking, ir as ɵLicenseBannerSpec, is as InspectorStopViewingPayload, it as OpenGenerativeUIControllerOptions, iu as ɵInterruptSnapshot, j as ɵThreadStore, ja as TOOL_CALL_STATUS_LABEL_KEYS, jc as StoreLifecycleAction, jd as RuntimeMode, ji as ɵshowsComposerDisclaimer, jl as ɵreportProviderConfigDiagnostics, jn as ɵsubscribeToMessageFeedback, jo as ɵgetMessageRunStateSnapshot, jr as ɵbindPopupDismiss, js as ɵMemoryMetadataEvent, jt as ɵBranchNavInput, ju as ɵrecordAnnotation, k as ɵThreadRuntimeContext, ka as ReasoningDuration, kc as Selector, kd as IntelligenceRuntimeInfo, ki as ɵresolveComposerKey, kl as ɵassembleProviderTools, kn as ɵsetMessageFeedback, ko as ɵfindActivityRenderer, kr as ɵTAB_STOP_SELECTOR, ks as createMemoryStore, kt as ɵinspectorShortcuts, ku as ɵRecordAnnotationResult, l as CopilotKitCoreErrorHandler, la as ɵtranscriptionErrorNotice, lc as ɵobservePhoenixJoinOutcome$, ld as ensureObjectArgs, li as ɵComposerControllerOptions, ll as ɵCopilotKitLearningOptions, ln as ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS, lo as toolCallAppearance, lr as ɵresolveLicenseState, ls as emitInspectorStopViewing, lt as WebsandboxConstructor, lu as InterruptRenderProps, m as CopilotKitCoreSubscriber, ma as TranscriptionErrorInfo, mc as ActionConfig, md as ScopedContext, mi as ɵComposerMode, ml as ɵProviderConfigDiagnosticCode, mn as ɵFeedbackKeyEvent, mo as ɵbuildToolCallRenderProps, mr as ɵDockedSidebarRegistry, ms as onInspectorStopViewing, mt as processPartialHtml, mu as ɵInterruptToolResult, n as LegacyLearningConfig, na as ɵChatSubmitterSnapshot, nc as ɵPhoenixPushLike, nd as CopilotKitCoreCatalogComponent, ni as ɵTextareaMetrics, nl as ɵresetAgentThreadBaseline, nn as ɵinitialKeyboardState, no as getWorkOpenState, nr as ɵLicenseBannerDetails, ns as INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, nt as OpenGenerativeUISchema, nu as ɵInterruptExpiredError, o as CopilotKitCoreConfig, oa as ɵcreateChatSubmitter, oc as ɵPhoenixSocketSignal, od as CopilotKitCoreRunToolParams, oi as ɵCommandMenuItem, ol as ɵAssembledHumanInTheLoop, on as ɵreadKeyboardState, oo as recordWorkTime, or as ɵgetInlineFeatureWarningSpec, os as InspectorViewThreadResultPayload, ot as OpenGenerativeUIState, ou as InterruptCancelFn, p as CopilotKitCoreStopAgentParams, pa as TranscriptionErrorCode, pc as ɵphoenixSocket$, pd as ContextStore, pi as ɵComposerKeyEvent, pl as ɵProviderConfigDiagnostic, pn as ɵFeedbackCommentVia, po as ɵadaptDefaultToolCallRenderProps, pr as ɵDockedSidebarPlacement, ps as onInspectorActiveThread, pt as extractCompleteStyles, pu as ɵInterruptState, q as OPEN_GENERATIVE_UI_DESIGN_CONTEXT_DESCRIPTION, qa as getArgumentPreview, qc as ɵisHttpAgent, qi as ɵChatConnectionSnapshot, ql as ActivityMessageRendererDef, qn as CopilotIconDefinition, qo as extractFenceOperations, qr as ɵAudioRecorderError, qs as MemoryError, qt as ɵshouldShowAssistantToolbar, qu as ɵvalidateAgentBinding, r as OpenThreadRegistration, ra as ɵTRANSCRIPTION_ERROR_TIMEOUT_MS, rc as ɵPhoenixSocketLike, rd as CopilotKitCoreConnectAgentParams, ri as ɵcreateComposerAutosize, rl as ɵLearningAutoStarter, rn as ɵisMobileViewport, ro as isTurnWorkOpen, rr as ɵLicenseBannerSeverity, rs as InspectorActiveThreadPayload, rt as OpenGenerativeUIController, ru as ɵInterruptRunner, s as CopilotKitCoreErrorCode, sa as ɵresolveChatNotice, sc as ɵjoinPhoenixChannel$, sd as CopilotKitCoreRunToolResult, si as ɵComposerController, sl as ɵCOPILOT_CLOUD_PUBLIC_API_KEY_HEADER, sn as ɵwatchKeyboardState, so as stringifyToolCallAttr, sr as ɵgetLicenseBannerSpec, ss as createInspectorThreadRequestId, st as SandboxFunctionHandle, su as InterruptEvent, t as LearningConfig, ta as ɵChatSubmitterOptions, tc as ɵPhoenixJoinOutcome, td as ɵwithHeaderDefaults, ti as ɵComposerLayout, tl as ɵclearAgentThreadCursors, tn as ɵcreateStickToBottom, to as getTurnWork, tr as ɵLICENSE_BANNER_STYLE, ts as splitA2UIMarkdown, tt as OPEN_GENERATIVE_UI_CONTENT_SCHEMA, tu as ɵInterruptControllerOptions, u as CopilotKitCoreFriendsAccess, ua as ɵwaitForActiveRun, uc as ɵobservePhoenixSocketHealth$, ud as parseToolArguments, ui as ɵComposerInput, ul as ɵCopilotKitProviderBaseOptions, un as ɵFeedbackCommentController, uo as ɵDefaultToolCallRenderProps, ur as ɵresolveThreadsLicense, us as emitInspectorViewThread, ut as WebsandboxInstance, uu as InterruptResolveFn, v as StartResult, va as ɵtranscriptionErrorMessageKey, vc as ActionGroupConfig, vd as CopilotKitCoreRegisterProxiedAgentResult, vi as ɵSlashKeyResult, vl as ɵProviderRegistryInput, vn as ɵMESSAGE_FEEDBACK_EVENT_NAME, vo as ɵgetToolCallBadge, vr as ɵExitPresence, vs as ɵInspectorThreadOverrideInput, vt as OPEN_GENERATIVE_UI_ACTIVITY_TYPE, vu as ɵGenerativeUIDebugFunction, w as ɵMAX_SOCKET_RETRIES, wa as ɵClipboardItem, wc as EmptyActionConfig, wd as DynamicSuggestionsConfig, wi as ɵflattenCommandItems, wl as ɵToolRendererShape, wn as ɵgetMessageFeedback, wo as ɵActivityRendererFailureReason, wr as ɵRESIZE_SETTLE_MS, ws as MemoryChanges, wt as ɵInspectorKiteGradient, wu as ɵRendererKind, x as ɵCopilotKitCoreConfigPatch, xa as ɵThreadSelectionInput, xc as DispatchingEffect, xd as ProxiedCopilotRuntimeAgentConfig, xi as ɵclampSlashIndex, xl as ɵResolvedProviderConfig, xn as ɵMessageFeedbackControls, xo as ɵparseToolCallArguments, xr as ɵPOPUP_DEFAULT_HEIGHT, xs as ɵCopilotKitFeature, xt as ɵHoverMenuController, xu as ɵGenerativeUIDebugSnapshot, y as SubscribeToAgentOptions, ya as ɵConnectionWaitResult, yc as ActionGroupResult, yd as ɵRUNTIME_PROBE_TIMEOUT_MS, yi as ɵSlashMenuState, yl as ɵProviderToolRenderer, yn as ɵMESSAGE_FEEDBACK_MAX_COMMENT_LENGTH, yo as ɵgetToolCallStatus, yr as ɵExitPresenceState, ys as ɵInspectorThreadOverrideSnapshot, yt as OpenGenerativeUIContent, yu as ɵGenerativeUIDebugPromptSection, z as ɵselectThreadsIsLoading, za as ToolCallSegment, zc as on, zd as WebMCPToolConfig, zi as ɵMessageViewModel, zl as ɵSuggestionsConfigInput, zn as ɵtoDrawerThread, zo as ɵformatCountLabel, zr as ɵisContentScrolledToBottom, zs as ɵmemoryRestEvents, zt as ɵflattenUserMessageContent, zu as ɵAgentResolver } from "./learning-bridge-DEVwyO7F.cjs";
2
+ import { ɵChatConfigurationOptions, ɵChatConfigurationSnapshot, ɵChatConfigurationStore, ɵOpenThreadRegistry } from "./chat-configuration.cjs";
3
+ export { A2UIMarkdownOperation, A2UI_FENCE_LANGUAGE, ActionConfig, ActionCreator, ActionFromCreator, ActionFromCreators, ActionGroupConfig, ActionGroupResult, ActivityMessageRenderProps, ActivityMessageRendererDef, AgentRegistry, AgentThreadLockedError, AnyAction, ChildIdsOf, ChildWalkOptions, ContextStore, CopilotChatDefaultLabels, CopilotChatLabels, CopilotChatToolCallDisplay, CopilotIconData, CopilotIconDefinition, CopilotIconName, CopilotIconNode, CopilotKitCore, CopilotKitCoreAddAgentParams, CopilotKitCoreCatalogComponent, CopilotKitCoreConfig, CopilotKitCoreConnectAgentParams, CopilotKitCoreContinuationHandoff, CopilotKitCoreErrorCode, CopilotKitCoreErrorEvent, CopilotKitCoreErrorHandler, CopilotKitCoreFriendsAccess, CopilotKitCoreGetSuggestionsResult, CopilotKitCoreGetToolParams, CopilotKitCoreRegisterProxiedAgentParams, CopilotKitCoreRegisterProxiedAgentResult, CopilotKitCoreRunAgentParams, CopilotKitCoreRunToolParams, CopilotKitCoreRunToolResult, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreStopAgentParams, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, CopilotKitHeaderResolutionError, CopilotKitHeadersSource, CopilotKitMessageFilter, CopilotRuntimeTransport, CustomMessageRenderProps, CustomMessageRendererDef, CustomMessageRendererPosition, DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL, DispatchingEffect, DispatchingEffectOptions, DynamicSuggestionsConfig, Effect, EmptyActionConfig, FrontendTool, FrontendToolHandlerContext, FrontendToolReconnectBehavior, GENERATE_SANDBOXED_UI_TOOL_NAME, GenerateSandboxedUiArgs, HumanInTheLoopRenderProps, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, INTERRUPT_EVENT_NAME, InspectorActiveThreadPayload, InspectorMetadataV1, InspectorStopViewingPayload, InspectorViewThreadPayload, InspectorViewThreadResultPayload, IntelligenceAgent, IntelligenceAgentConfig, IntelligenceRuntimeInfo, InterruptCancelFn, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, InterruptResolveFn, JsonValue, LearningConfig, LegacyLearningConfig, MEMORY_ERROR_REGISTRY, MarkdownSegment, Memory, MemoryChanges, MemoryError, MemoryErrorCategory, MemoryErrorCode, MemoryErrorRegistryEntry, MemoryKind, MemoryRealtimeStatus, MemoryScope, NewMemory, NonDispatchingEffect, NonDispatchingEffectOptions, OPEN_GENERATIVE_UI_ACTIVITY_TYPE, OpenGenerativeUIContent, OpenThreadRegistration, PropsActionConfig, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgentConfig, Reducer, RunCompletionAware, RunHandler, RuntimeLicenseStatus, RuntimeMode, ScopedContext, ScopedProperties, Selector, StartResult, StateManager, StaticSuggestionsConfig, Store, StoreLifecycleAction, SubscribeToAgentOptions, SubscribeToAgentSubscriber, Suggestion, SuggestionAvailability, SuggestionEngine, SuggestionsConfig, SurfaceSegment, ThreadEndpointRuntimeInfo, ThreadRunActivityNotification, ToolCallEntry, ToolCallRenderProps, ToolCallRendererDef, ToolCallStatus, TrajectoryStartOptions, TranscriptionError, TranscriptionErrorCode, TranscriptionErrorInfo, TranscriptionResult, 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, ɵALL_AGENT_UPDATES, ɵActivityRendererFailureReason, ɵActivityRendererLookup, ɵActivityRendererQuery, ɵActivityRenderersInput, ɵAgentBindingInput, ɵAgentContextInput, ɵAgentResolveInput, ɵAgentResolver, ɵAgentUpdateFlag, ɵAssembledHumanInTheLoop, ɵAssistantToolbarInput, ɵAttachmentQueue, ɵAudioRecorder, ɵAudioRecorderError, ɵAudioRecorderState, ɵAutoScrollMode, ɵBranchNavInput, ɵCOMPOSER_DEFAULT_MAX_ROWS, ɵCOPILOTKIT_FEATURES, ɵCOPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ɵCOPILOT_CLOUD_RUNTIME_URL, ɵCOPY_FEEDBACK_RESET_MS, ɵChatConfigurationOptions, ɵChatConfigurationSnapshot, ɵChatConfigurationStore, ɵChatConnectHooks, ɵChatConnection, ɵChatConnectionHandle, ɵChatConnectionOptions, ɵChatConnectionSnapshot, ɵChatErrorEvent, ɵChatNotice, ɵChatRunScope, ɵChatSubmitter, ɵChatSubmitterOptions, ɵChatSubmitterSnapshot, ɵChatViewStateInput, type ClassValue as ɵClassValue, ɵClipboardItem, ɵCommandMenuItem, ɵComposerAutosize, ɵComposerAutosizeOptions, ɵComposerController, ɵComposerControllerInputs, ɵComposerControllerOptions, ɵComposerElements, ɵComposerInput, ɵComposerKeyAction, ɵComposerKeyDownResult, ɵComposerKeyEvent, ɵComposerLayout, ɵComposerMode, ɵComposerSnapshot, ɵConnectionWaitResult, ɵCopilotKitCoreConfigPatch, ɵCopilotKitFeature, ɵCopilotKitLearningOptions, ɵCopilotKitProviderBaseOptions, ɵCopyFeedback, ɵCustomMessageRunSource, ɵDefaultToolCallRenderProps, ɵDialogFocusOptions, ɵDockedSidebar, ɵDockedSidebarPlacement, ɵDockedSidebarRegistry, ɵDockedSidebarState, ɵDockedSidebarTransition, ɵDrawerThread, ɵElementHeightState, ɵExitPresence, ɵExitPresenceState, ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS, ɵFeedbackCommentController, ɵFeedbackCommentControllerOptions, ɵFeedbackCommentState, ɵFeedbackCommentVia, ɵFeedbackKeyEvent, ɵFeedbackThumb, ɵFeedbackThumbAttributes, ɵFeedbackThumbHandlers, ɵFreshThreadId, ɵFrontendToolRenderer, GENERATE_SANDBOXED_UI_ARGS_SCHEMA as ɵGENERATE_SANDBOXED_UI_ARGS_SCHEMA, ɵGenerativeUIDebugFunction, ɵGenerativeUIDebugPromptSection, ɵGenerativeUIDebugRun, ɵGenerativeUIDebugSnapshot, ɵGenerativeUIDebugSource, ɵGenerativeUIDebugSurface, ɵGenerativeUIDefault, ɵGenerativeUIDefaultInput, ɵHITL_ABORTED_MESSAGE, ɵHOVER_MENU_CLOSE_DELAY_MS, ɵHoverMenuController, ɵHoverMenuState, ɵHumanInTheLoopRegistry, ɵINLINE_FEATURE_WARNING_STYLE, ɵInspectorKiteArtwork, ɵInspectorKiteGradient, ɵInspectorKitePath, ɵInspectorKiteStop, ɵInspectorThreadOverride, ɵInspectorThreadOverrideInput, ɵInspectorThreadOverrideSnapshot, ɵInterruptController, ɵInterruptControllerOptions, ɵInterruptDecision, ɵInterruptEvent, ɵInterruptExpiredError, ɵInterruptRunner, ɵInterruptSnapshot, ɵInterruptState, ɵInterruptToolResult, ɵJsonSerializable, ɵKEYBOARD_OPEN_THRESHOLD_PX, ɵKeyboardState, ɵLICENSE_BANNER_OFFSET, ɵLICENSE_BANNER_STYLE, ɵLastUserMessageState, ɵLearnFromUserActionFields, ɵLearningAutoStarter, ɵLicenseBannerDetails, ɵLicenseBannerSeverity, ɵLicenseBannerSpec, ɵLicenseBannerType, LicenseStateInput as ɵLicenseStateInput, ɵMAX_SOCKET_RETRIES, ɵMESSAGE_FEEDBACK_EVENT_NAME, ɵMESSAGE_FEEDBACK_MAX_COMMENT_LENGTH, ɵMOBILE_MAX_WIDTH_QUERY, ɵMemoryEnvironment, ɵMemoryMetadataEvent, ɵMemoryRuntimeContext, ɵMemoryState, ɵMemoryStore, ɵMessageFeedback, ɵMessageFeedbackControls, ɵMessageFeedbackRating, ɵMessageFeedbackScope, ɵMessageViewInput, ɵMessageViewModel, ɵModeRecorder, OPEN_GENERATIVE_UI_CONTENT_SCHEMA as ɵOPEN_GENERATIVE_UI_CONTENT_SCHEMA, OPEN_GENERATIVE_UI_DESIGN_CONTEXT_DESCRIPTION as ɵOPEN_GENERATIVE_UI_DESIGN_CONTEXT_DESCRIPTION, OPEN_GENERATIVE_UI_SANDBOX_FUNCTIONS_CONTEXT_DESCRIPTION as ɵOPEN_GENERATIVE_UI_SANDBOX_FUNCTIONS_CONTEXT_DESCRIPTION, OpenGenerativeUIController as ɵOpenGenerativeUIController, OpenGenerativeUIControllerOptions as ɵOpenGenerativeUIControllerOptions, OpenGenerativeUIPhase as ɵOpenGenerativeUIPhase, OpenGenerativeUISandboxFunction as ɵOpenGenerativeUISandboxFunction, OpenGenerativeUISchema as ɵOpenGenerativeUISchema, OpenGenerativeUIState as ɵOpenGenerativeUIState, ɵOpenThreadRegistry, PLACEHOLDER_CYCLE_MS as ɵPLACEHOLDER_CYCLE_MS, ɵPOPUP_ANIMATION_MS, ɵPOPUP_DEFAULT_HEIGHT, ɵPOPUP_DEFAULT_WIDTH, ɵPendingInterrupt, ɵPhoenixChannelLike, ɵPhoenixChannelOptions, ɵPhoenixChannelSession, ɵPhoenixJoinOutcome, ɵPhoenixPushLike, ɵPhoenixSocketLike, ɵPhoenixSocketOptions, ɵPhoenixSocketSession, ɵPhoenixSocketSignal, ɵPinMessageToTopOptions, PlaceholderCycler as ɵPlaceholderCycler, PlaceholderCyclerSnapshot as ɵPlaceholderCyclerSnapshot, ɵPopupDismissOptions, ɵProviderConfigDiagnostic, ɵProviderConfigDiagnosticCode, ɵProviderConfigInput, ɵProviderFrontendTool, ɵProviderHumanInTheLoop, ɵProviderRegistryInput, ɵProviderToolRenderer, ɵRESIZE_SETTLE_MS, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵRawToolCallRenderProps, ɵReasoningDisclosure, ɵReasoningDisclosureOptions, ɵReasoningDisclosureState, ReasoningDuration as ɵReasoningDuration, ɵRecordAnnotationArgs, ɵRecordAnnotationResult, ɵRendererKind, ɵRendererRegistry, ɵRendererRegistryInit, ɵReportProviderConfigDiagnosticsOptions, ɵResolvedProviderConfig, ɵRunnableCommand, ɵRuntimeInfo, ɵRuntimeInfoStore, ɵSCROLL_BOTTOM_THRESHOLD_PX, ɵSIDEBAR_DEFAULT_WIDTH, ɵSIDEBAR_TRANSITION_MS, ɵSTABLE_ARRAY_WARNINGS, SandboxFunctionHandle as ɵSandboxFunctionHandle, SandboxLocalApi as ɵSandboxLocalApi, ɵSidebarPosition, ɵSlashKeyResult, ɵSlashMenuState, ɵStableArrayProp, ɵStaticSuggestionInput, ɵStickToBottom, ɵStickToBottomOptions, ɵSuggestionsBinding, ɵSuggestionsBindingOptions, ɵSuggestionsConfigInput, ɵTAB_STOP_SELECTOR, ɵTHREAD_REQUEST_TIMEOUT_MS, TOOL_CALL_STATUS_ICONS as ɵTOOL_CALL_STATUS_ICONS, TOOL_CALL_STATUS_LABEL_KEYS as ɵTOOL_CALL_STATUS_LABEL_KEYS, ɵTRANSCRIPTION_ERROR_TIMEOUT_MS, ɵTextareaMetrics, ɵThread, ɵThreadBaselineResetOptions, ɵThreadEnvironment, ɵThreadMetadataEvent, ɵThreadRuntimeContext, ɵThreadSelection, ɵThreadSelectionInput, ɵThreadSelectors, ɵThreadStore, type ɵThreadSummary, ɵThreadSwitchCoordinator, ɵThreadsController, type ɵThreadsCore, ɵThreadsDrawerCallbacks, ɵThreadsDrawerConfig, ɵThreadsDrawerThreads, type ɵThreadsInput, type ɵThreadsSnapshot, ɵToolCallCardStatus, ToolCallDisplayContextValue as ɵToolCallDisplayContextValue, ToolCallGroupAppearance as ɵToolCallGroupAppearance, ToolCallLayout as ɵToolCallLayout, ToolCallRendererNames as ɵToolCallRendererNames, ToolCallRendererNamesOptions as ɵToolCallRendererNamesOptions, ToolCallRowStatus as ɵToolCallRowStatus, ToolCallSegment as ɵToolCallSegment, ɵToolRendererShape, ɵToolsMenuDisplayEntry, TranscriptionCore as ɵTranscriptionCore, ɵTranscriptionErrorLabelKey, TurnOpenState as ɵTurnOpenState, TurnWork as ɵTurnWork, ɵUserMessageMediaPart, WebsandboxConstructor as ɵWebsandboxConstructor, WebsandboxInstance as ɵWebsandboxInstance, WebsandboxLoader as ɵWebsandboxLoader, ɵWorkSummaryInput, WorkTime as ɵWorkTime, ɵadaptDefaultToolCallRenderProps, addOpenGenerativeUIContexts as ɵaddOpenGenerativeUIContexts, ɵagentUpdateHandlers, ɵappendTranscript, ɵassembleActivityRenderers, ɵassembleHumanInTheLoop, ɵassembleProviderRegistry, ɵassembleProviderToolRenderers, ɵassembleProviderTools, ɵbindDialogFocus, ɵbindPopupDismiss, ɵbindSuggestionsConfig, ɵbuildHumanInTheLoopTool, ɵbuildLearnFromUserActionPayload, buildOpenGenerativeUIContexts as ɵbuildOpenGenerativeUIContexts, ɵbuildToolCallRenderProps, ɵbuildUserMessage, ɵbuildUserMessageContent, ɵcanPreviewDocument, ɵclampSlashIndex, ɵclearAgentInterruptState, ɵclearAgentThreadCursors, cn as ɵcn, ɵcomponentToolDescription, ɵcomposerButtonState, ɵcopilotIconSvgAttributes, ɵcopilotIcons, countFailedToolCalls as ɵcountFailedToolCalls, ɵcreateChatSubmitter, ɵcreateComposerAutosize, ɵcreateDockedSidebar, ɵcreateExitPresence, ɵcreateLastUserMessageTracker, createMemoryStore as ɵcreateMemoryStore, ɵcreateMessageViewModel, ɵcreateObjectUrlFromSource, createOpenGenerativeUITool as ɵcreateOpenGenerativeUITool, ɵcreateStickToBottom, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵcreateThreadsDrawerActions, ɵcreateWaveformRenderer, ɵdecodeTextSource, ɵdeduplicateMessages, ɵdescribeActivityRendererFailure, ɵdescribeUnrenderedToolCalls, ɵdimensionToCss, ɵdockedSidebarRegistryFor, ɵduplicateMessagesWarning, extractCompleteStyles as ɵextractCompleteStyles, ɵfilterCommands, ɵfindActivityRenderer, ɵfindChatInput, ɵfindToolMessage, ɵfitTextareaHeight, ɵflattenCommandItems, ɵflattenToolsMenuForDisplay, ɵflattenUserMessageContent, ɵformatCountLabel, ɵformatLabel, formatReasoningDuration as ɵformatReasoningDuration, ɵformatReasoningDurationLabel, formatToolNames as ɵformatToolNames, formatWorkDuration as ɵformatWorkDuration, ɵgetAgentCapabilities, ɵgetAgentInterruptState, ɵgetAgentResolver, getArgumentPreview as ɵgetArgumentPreview, ɵgetBranchNavState, ɵgetChatViewState, ɵgetCustomMessageRenderProps, ɵgetInlineFeatureWarningSpec, ɵgetLastUserMessageId, getLatestTurnKey as ɵgetLatestTurnKey, ɵgetLicenseBannerSpec, ɵgetMessageFeedback, ɵgetMessageFeedbackControls, ɵgetMessageRunStateSnapshot, ɵgetReasoningHeaderLabel, ɵgetThreadsDrawerElementProps, ɵgetToolCallBadge, getToolCallGroupState as ɵgetToolCallGroupState, getToolCallLayouts as ɵgetToolCallLayouts, getToolCallPreview as ɵgetToolCallPreview, getToolCallRendererNames as ɵgetToolCallRendererNames, getToolCallRowStatus as ɵgetToolCallRowStatus, ɵgetToolCallStatus, getToolResults as ɵgetToolResults, getTurnWork as ɵgetTurnWork, ɵgetUserMessageMediaFilename, ɵgetUserMessageMediaParts, getWorkOpenState as ɵgetWorkOpenState, ɵgetWorkSummaryText, ɵhasAssistantMessageText, ɵhitlRenderProps, ɵimplementsConnect, ɵinitialKeyboardState, ɵinspectorKiteFill, ɵinspectorKiteIcon, ɵinspectorShortcuts, isContentPart as ɵisContentPart, ɵisContentScrolledToBottom, ɵisCopilotKitFeature, ɵisFocusVisible, ɵisHttpAgent, ɵisLearningFeedbackEnabled, ɵisMobileViewport, isOpenGenerativeUIActive as ɵisOpenGenerativeUIActive, ɵisOwnFeedbackThumb, isRetryableStatus as ɵisRetryableMemoryStatus, ɵisScrolledToBottom, isTurnWorkOpen as ɵisTurnWorkOpen, isTurnWorking as ɵisTurnWorking, ɵjoinPhoenixChannel$, loadWebsandbox as ɵloadWebsandbox, ɵmapMemoryMetadataEvent, ɵmatchActivityRenderer, ɵmeasureTextarea, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵmessagesFingerprint, ɵmorphViewTransition, ɵnextSlashIndex, ɵnextTabStop, ɵnormalizeAutoScroll, ɵnormalizeToolCallStatus, ɵnormalizeToolsMenu, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵparseSlashQuery, ɵparseToolCallArguments, ɵphoenixChannel$, ɵphoenixSocket$, ɵpinMessageToTop, pluralize as ɵpluralize, processPartialHtml as ɵprocessPartialHtml, ɵprojectThread, ɵpublicKeyHeaderDefaults, ɵreadKeyboardState, ɵrecordAnnotation, recordWorkTime as ɵrecordWorkTime, ɵregisterFrontendTools, ɵreportProviderConfigDiagnostics, ɵreserveLicenseBannerOffset, ɵresetAgentThreadBaseline, ɵresetMessageFeedbackCache, ɵresolveActivityRenderer, ɵresolveAgentId, ɵresolveAgentThreadId, ɵresolveChatNotice, ɵresolveComposerKey, ɵresolveCustomMessageRenderContext, ɵresolveCustomMessageRenderers, ɵresolveGenerativeUIDefault, ɵresolveLicenseState, ɵresolveProviderConfig, ɵresolveSlashKey, ɵresolveThreadsLicense, ɵresolveToolCallAgentId, ɵresolveToolCallRenderer, ɵrmsAmplitude, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵserializeContextValue, ɵsetMessageFeedback, shallowEqualRecord as ɵshallowEqualRecord, ɵshouldShowAssistantToolbar, ɵshouldShowMessageCursor, ɵshowsComposerDisclaimer, ɵsnapshotAgentState, ɵstableArrayPropWarning, ɵstopAgentWithFallback, stringifyToolCallAttr as ɵstringifyToolCallAttr, stringifyToolCallPayload as ɵstringifyToolCallPayload, ɵsubscribeToAgentErrors, ɵsubscribeToAgentSuggestions, ɵsubscribeToAgentUpdates, ɵsubscribeToLearningFeedbackEnabled, ɵsubscribeToMessageFeedback, ɵsyncRecorderToMode, ɵthreadAdapterEvents, ɵtoDefaultToolCallStatus, ɵtoDrawerThread, ɵtoLearningConfig, toolCallAppearance as ɵtoolCallAppearance, ɵtoolRendererShapeChanged, ɵtranscribeAudio, ɵtranscriptionErrorMessageKey, ɵtranscriptionErrorNotice, ɵvalidateAgentBinding, ɵwaitForActiveRun, ɵwatchElementHeight, ɵwatchElementWidth, ɵwatchKeyboardState, ɵwatchMobileViewport, ɵwithHeaderDefaults };