@copilotkit/core 1.62.2 → 1.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -200,6 +200,7 @@ declare class AgentRegistry {
200
200
  private localAgents;
201
201
  private remoteAgents;
202
202
  private _runtimeUrl?;
203
+ private _connectionInFlight?;
203
204
  private _runtimeVersion?;
204
205
  private _runtimeConnectionStatus;
205
206
  private _runtimeTransport;
@@ -208,6 +209,7 @@ declare class AgentRegistry {
208
209
  private _runtimeMode;
209
210
  private _intelligence?;
210
211
  private _threadEndpoints?;
212
+ private _suggestions?;
211
213
  private _a2uiEnabled;
212
214
  private _a2uiAgents?;
213
215
  private _openGenerativeUIEnabled;
@@ -237,6 +239,7 @@ declare class AgentRegistry {
237
239
  get runtimeMode(): RuntimeMode$1;
238
240
  get intelligence(): IntelligenceRuntimeInfo$1 | undefined;
239
241
  get threadEndpoints(): ThreadEndpointRuntimeInfo$1 | undefined;
242
+ get suggestions(): boolean | undefined;
240
243
  get a2uiEnabled(): boolean;
241
244
  /**
242
245
  * Agent ids the runtime applies A2UI to (#5369). `undefined` means A2UI
@@ -253,7 +256,21 @@ declare class AgentRegistry {
253
256
  /**
254
257
  * Set the runtime URL and update connection
255
258
  */
256
- setRuntimeUrl(runtimeUrl: string | undefined): void;
259
+ setRuntimeUrl(runtimeUrl: string | undefined, options?: {
260
+ deferConnection?: boolean;
261
+ }): void;
262
+ /**
263
+ * Start the initial runtime connection if it has not been started yet.
264
+ *
265
+ * Backs {@link CopilotKitCore.connect}. Idempotent: it only kicks off a fetch
266
+ * when a `runtimeUrl` is set and the connection is still `Disconnected` (its
267
+ * state before any connect attempt). `updateRuntimeConnection` flips the
268
+ * status to `Connecting` synchronously, so a second call — e.g. React
269
+ * StrictMode double-invoking the mount effect — bails here. A genuine config
270
+ * change still reconnects through `setRuntimeUrl`/`setRuntimeTransport`. See
271
+ * #5801.
272
+ */
273
+ connectRuntime(): void;
257
274
  setRuntimeTransport(runtimeTransport: CopilotRuntimeTransport): void;
258
275
  /**
259
276
  * Set all agents at once (for development use)
@@ -312,6 +329,7 @@ declare class AgentRegistry {
312
329
  * Update runtime connection and fetch remote agents
313
330
  */
314
331
  private updateRuntimeConnection;
332
+ private performRuntimeConnection;
315
333
  private fetchRuntimeInfo;
316
334
  private fetchRuntimeInfoSingle;
317
335
  /**
@@ -862,6 +880,14 @@ interface ThreadState {
862
880
  isLoading: boolean;
863
881
  isFetchingNextPage: boolean;
864
882
  error: Error | null;
883
+ /**
884
+ * Error from the most recent failed next-page (`fetchMore`) load, or `null`.
885
+ * Tracked SEPARATELY from `error` so a paginated-load failure surfaces an
886
+ * inline "couldn't load more" affordance without replacing the already-loaded
887
+ * list with a full-panel error. Cleared when a fetch-more is retried or when
888
+ * one succeeds; reset on context change / stop.
889
+ */
890
+ fetchMoreError: Error | null;
865
891
  context: ThreadRuntimeContext | null;
866
892
  sessionId: number;
867
893
  metadataCredentialsRequested: boolean;
@@ -887,6 +913,7 @@ interface ThreadSelectors {
887
913
  threads: (state: ThreadState) => ThreadRecord[];
888
914
  isLoading: (state: ThreadState) => boolean;
889
915
  error: (state: ThreadState) => Error | null;
916
+ fetchMoreError: (state: ThreadState) => Error | null;
890
917
  hasNextPage: (state: ThreadState) => boolean;
891
918
  isFetchingNextPage: (state: ThreadState) => boolean;
892
919
  isMutating: (state: ThreadState) => boolean;
@@ -994,6 +1021,7 @@ declare const ɵcreateThreadSelectors: typeof createThreadSelectors;
994
1021
  declare const ɵselectThreads: (state: ThreadState) => ThreadRecord[];
995
1022
  declare const ɵselectThreadsIsLoading: (state: ThreadState) => boolean;
996
1023
  declare const ɵselectThreadsError: (state: ThreadState) => Error | null;
1024
+ declare const ɵselectFetchMoreError: (state: ThreadState) => Error | null;
997
1025
  declare const ɵselectHasNextPage: (state: ThreadState) => boolean;
998
1026
  declare const ɵselectIsFetchingNextPage: (state: ThreadState) => boolean;
999
1027
  declare const ɵselectIsMutating: (state: ThreadState) => boolean;
@@ -1005,6 +1033,383 @@ declare const ɵselectIsMutating: (state: ThreadState) => boolean;
1005
1033
  */
1006
1034
  declare const ɵMAX_SOCKET_RETRIES = 5;
1007
1035
  //#endregion
1036
+ //#region src/memory-errors.d.ts
1037
+ /**
1038
+ * Memory error registry — stable codes for the errors the memory store throws.
1039
+ *
1040
+ * The memory store (`memory.ts`) used to throw bare `new Error("Failed to fetch
1041
+ * memories: 500")` / `"Request timed out"` / `"Request failed: <status>"`. Those
1042
+ * reach the `error` selector (and the consumer UI via `useMemories` /
1043
+ * `injectMemories`) verbatim, with no machine-readable `code`/`category`/
1044
+ * `retryable`, so they cannot be grouped in observability or branched on by
1045
+ * consumers.
1046
+ *
1047
+ * Per the repo's error-handling architecture standard (AGENTS.md: "Each project
1048
+ * must maintain an explicit error registry"), this file is the explicit registry
1049
+ * for the memory feature. It is deliberately scoped to memory — not a repo-wide
1050
+ * registry refactor — because `packages/core` has no pre-existing
1051
+ * code/category/retryable registry convention to plug into (the runtime's
1052
+ * `lib/error-messages.ts` is a message-templating table, not a typed
1053
+ * code/category/retryable registry). It mirrors the existing
1054
+ * `AgentThreadLockedError extends Error` precedent in
1055
+ * `intelligence-agent.ts`: a real `Error` subclass so `instanceof Error` holds
1056
+ * and the public `MemoryState.error: Error | null` contract is preserved.
1057
+ *
1058
+ * `docsPath` is recorded per entry per the standard; there is no
1059
+ * `docs/errors/<project>.md` in this repo, so this docblock plus the registry
1060
+ * are the source of truth.
1061
+ *
1062
+ * Each registry entry carries:
1063
+ * - `code`: stable identifier (e.g. `MEMORY_LIST_FAILED`).
1064
+ * - `category`: one of the standard categories
1065
+ * (`validation`|`auth`|`permission`|`not_found`|`conflict`|`rate_limit`|`internal`|`dependency`).
1066
+ * - `retryable`: whether a retry could plausibly succeed (timeouts + transient
1067
+ * dependency failures are retryable; client-caused 4xx are not).
1068
+ * - `message`: the default human-readable message (callers may override with a
1069
+ * status-bearing string to preserve the prior wording).
1070
+ * - `docsPath`: documentation pointer for the code.
1071
+ */
1072
+ /** Standard error categories from the repo error-handling architecture. */
1073
+ type MemoryErrorCategory = "validation" | "auth" | "permission" | "not_found" | "conflict" | "rate_limit" | "internal" | "dependency";
1074
+ /** Stable codes for the memory store's surfaced errors. */
1075
+ type MemoryErrorCode = "MEMORY_LIST_FAILED" | "MEMORY_CREDENTIALS_FAILED" | "MEMORY_MUTATION_FAILED" | "MEMORY_REQUEST_TIMEOUT";
1076
+ /** A single registry entry describing one memory error code. */
1077
+ interface MemoryErrorRegistryEntry {
1078
+ readonly code: MemoryErrorCode;
1079
+ readonly category: MemoryErrorCategory;
1080
+ readonly retryable: boolean;
1081
+ readonly message: string;
1082
+ readonly docsPath: string;
1083
+ }
1084
+ /**
1085
+ * The memory error registry: the single source of truth for memory error
1086
+ * metadata. Keyed by `code` so a code maps to exactly one category/retryable
1087
+ * default.
1088
+ *
1089
+ * Categories/retryable rationale:
1090
+ * - List/credentials/mutation failures are `dependency` (the runtime/platform
1091
+ * the store calls failed). A 5xx is transient (`retryable: true`); a 4xx is
1092
+ * caller-caused, so the helpers below downgrade those to non-retryable.
1093
+ * - Timeouts are `dependency` and `retryable: true` (the request may simply be
1094
+ * slow).
1095
+ */
1096
+ declare const MEMORY_ERROR_REGISTRY: Readonly<Record<MemoryErrorCode, MemoryErrorRegistryEntry>>;
1097
+ /**
1098
+ * An `Error` carrying a stable memory error `code`, `category`, and `retryable`
1099
+ * flag so consumers and observability can branch on it without string-matching
1100
+ * the message.
1101
+ *
1102
+ * It is a real `Error` subclass: `instanceof Error` is true, so the public
1103
+ * `MemoryState.error: Error | null` contract (and the `error: Error | null`
1104
+ * surfaced by `useMemories` / `injectMemories`) holds unchanged. Existing
1105
+ * consumers that only read `.message` keep working; the richer fields are
1106
+ * additive.
1107
+ */
1108
+ declare class MemoryError extends Error {
1109
+ /** Stable, machine-readable error identifier. */
1110
+ readonly code: MemoryErrorCode;
1111
+ /** Coarse error category for grouping/observability. */
1112
+ readonly category: MemoryErrorCategory;
1113
+ /** Whether retrying the operation could plausibly succeed. */
1114
+ readonly retryable: boolean;
1115
+ /**
1116
+ * @param code - Registry code identifying this error.
1117
+ * @param options - Optional overrides:
1118
+ * - `message`: human-readable message (defaults to the registry message;
1119
+ * callers pass a status-bearing string to preserve prior wording).
1120
+ * - `retryable`: overrides the registry default (e.g. a 4xx list failure is
1121
+ * not retryable even though the code's default is).
1122
+ * - `cause`: the underlying error, preserved for debugging.
1123
+ */
1124
+ constructor(code: MemoryErrorCode, options?: {
1125
+ message?: string;
1126
+ retryable?: boolean;
1127
+ cause?: unknown;
1128
+ });
1129
+ }
1130
+ /**
1131
+ * Narrows an HTTP status to whether the failure is worth retrying: a 5xx (or a
1132
+ * missing/0 status) is a transient dependency failure and retryable; a 4xx is
1133
+ * caller-caused and not. Used so a `MEMORY_LIST_FAILED`/`MEMORY_MUTATION_FAILED`
1134
+ * carries an accurate `retryable` flag derived from the response status.
1135
+ */
1136
+ declare function isRetryableStatus(status: number): boolean;
1137
+ //#endregion
1138
+ //#region src/memory.d.ts
1139
+ /** Public, customer-facing memory kind vocabulary (single taxonomy, no mapping). */
1140
+ type MemoryKind = "topical" | "episodic" | "operational";
1141
+ /** Visibility scope of a memory. */
1142
+ type MemoryScope = "user" | "project";
1143
+ /**
1144
+ * Health of the realtime (`user_meta:memories:<code>`) connection that streams
1145
+ * live `memory_metadata` deltas. Distinct from `available`/`error`, which
1146
+ * describe the REST list route: `realtimeStatus` reports ONLY whether the
1147
+ * realtime socket/channel is live so the UI can stop showing a "live" indicator
1148
+ * over a frozen snapshot once the socket permanently gives up.
1149
+ *
1150
+ * - `"connecting"` — fetching join credentials / opening the socket / joining
1151
+ * the channel (the default, and the state every `contextChanged`/`stopped`
1152
+ * resets to).
1153
+ * - `"connected"` — the channel join succeeded; live deltas are flowing.
1154
+ * - `"unavailable"` — the socket exhausted its retries or the join failed
1155
+ * permanently; the snapshot is frozen and no deltas will arrive. This is a
1156
+ * silent degrade for `available`/`error` (those stay untouched) — only this
1157
+ * signal flips.
1158
+ */
1159
+ type MemoryRealtimeStatus = "connecting" | "connected" | "unavailable";
1160
+ /**
1161
+ * A memory as projected across the public REST/realtime boundary — the minimal
1162
+ * shape the SDK surfaces. Mirrors the server's `PublicMemory` projection.
1163
+ */
1164
+ interface Memory {
1165
+ id: string;
1166
+ kind: MemoryKind;
1167
+ scope: MemoryScope;
1168
+ content: string;
1169
+ sourceThreadIds: readonly string[];
1170
+ invalidatedAt: string | null;
1171
+ }
1172
+ /** Input for creating a memory; `scope` defaults to `"user"` (v1 is user-scoped). */
1173
+ interface NewMemory {
1174
+ content: string;
1175
+ kind: MemoryKind;
1176
+ scope?: MemoryScope;
1177
+ sourceThreadIds?: readonly string[];
1178
+ }
1179
+ /**
1180
+ * New values for superseding (updating) a memory — same shape as create.
1181
+ *
1182
+ * Supersede is a FULL replacement, not a partial patch: this is the complete
1183
+ * definition of the new memory that replaces the old one. `content` and `kind`
1184
+ * are required and must be re-supplied, and an omitted `sourceThreadIds` resets
1185
+ * the new memory's source threads to `[]` — it does NOT preserve the prior
1186
+ * memory's value.
1187
+ */
1188
+ type MemoryChanges = NewMemory;
1189
+ /** Outcome of a mutation, tracked so the caller's promise resolves/rejects. */
1190
+ type MemoryMutationOutcome = {
1191
+ requestId: string;
1192
+ sessionId: number;
1193
+ ok: true;
1194
+ memory: Memory | null;
1195
+ } | {
1196
+ requestId: string;
1197
+ sessionId: number;
1198
+ ok: false;
1199
+ error: Error;
1200
+ };
1201
+ /**
1202
+ * Runtime wiring for the memory store: where to reach the REST surface and the
1203
+ * headers (auth + `X-Cpki-User-Id`) to send. Scoped to the current user; v1
1204
+ * surfaces user-scoped memories only.
1205
+ */
1206
+ interface MemoryRuntimeContext {
1207
+ runtimeUrl: string;
1208
+ /** WebSocket URL for the realtime gateway (e.g. `wss://gw.example.com/client`). */
1209
+ wsUrl: string;
1210
+ headers: Record<string, string>;
1211
+ includeInvalidated?: boolean;
1212
+ }
1213
+ /**
1214
+ * In-memory state for the memory store. Session-guarded like the thread store:
1215
+ * `sessionId` is bumped whenever the runtime context changes so that responses
1216
+ * and realtime deltas from a previous context are ignored.
1217
+ */
1218
+ interface MemoryState {
1219
+ memories: Memory[];
1220
+ isLoading: boolean;
1221
+ inFlightMutationCount: number;
1222
+ error: Error | null;
1223
+ context: MemoryRuntimeContext | null;
1224
+ sessionId: number;
1225
+ available: boolean;
1226
+ realtimeStatus: MemoryRealtimeStatus;
1227
+ }
1228
+ declare const memoryDomainEvents: ActionGroupResult<"Memory Domain", {
1229
+ readonly memoryUpserted: PropsActionConfig<{
1230
+ sessionId: number;
1231
+ memory: Memory;
1232
+ }>;
1233
+ readonly memoryInvalidated: PropsActionConfig<{
1234
+ sessionId: number;
1235
+ memoryId: string;
1236
+ }>;
1237
+ readonly realtimeConnecting: PropsActionConfig<{
1238
+ sessionId: number;
1239
+ }>;
1240
+ readonly realtimeConnected: PropsActionConfig<{
1241
+ sessionId: number;
1242
+ }>;
1243
+ readonly realtimeUnavailable: PropsActionConfig<{
1244
+ sessionId: number;
1245
+ }>;
1246
+ }>;
1247
+ /** Wire shape of a memory inside a `memory_metadata` payload (carries tenant ids). */
1248
+ interface MemoryMetadataPayloadMemory extends Memory {
1249
+ organizationId: string;
1250
+ projectId: string;
1251
+ }
1252
+ /**
1253
+ * The realtime `memory_metadata` event broadcast on the `user_meta` channel:
1254
+ * `created`/`updated` carry the full memory, `invalidated` carries only its id.
1255
+ * The gateway strips `userId` before broadcasting and only delivers
1256
+ * user-scoped memories, so this is always the current user's stream.
1257
+ */
1258
+ type MemoryMetadataEvent = {
1259
+ operation: "created" | "updated";
1260
+ memoryId: string;
1261
+ organizationId: string;
1262
+ projectId: string;
1263
+ occurredAt: string;
1264
+ memory: MemoryMetadataPayloadMemory;
1265
+ } | {
1266
+ operation: "invalidated";
1267
+ memoryId: string;
1268
+ organizationId: string;
1269
+ projectId: string;
1270
+ occurredAt: string;
1271
+ invalidated: {
1272
+ id: string;
1273
+ };
1274
+ };
1275
+ /**
1276
+ * Maps a realtime `memory_metadata` event to the domain action that applies it:
1277
+ * `created`/`updated` upsert the projected memory, `invalidated` removes it by
1278
+ * id. Carries the current `sessionId` so the reducer's session guard can drop
1279
+ * deltas left over from a previous context.
1280
+ */
1281
+ declare function mapMemoryMetadataEvent(event: MemoryMetadataEvent, sessionId: number): ReturnType<typeof memoryDomainEvents.memoryUpserted> | ReturnType<typeof memoryDomainEvents.memoryInvalidated>;
1282
+ /**
1283
+ * Dependencies injected into the memory store. The store opens its own
1284
+ * `user_meta:memories:<joinCode>` socket/channel and does not share the
1285
+ * thread store's socket, so only a `fetch` implementation is required.
1286
+ */
1287
+ interface MemoryEnvironment {
1288
+ fetch: typeof fetch;
1289
+ }
1290
+ interface MemoryStore {
1291
+ start(): void;
1292
+ stop(): void;
1293
+ setContext(context: MemoryRuntimeContext | null): void;
1294
+ /**
1295
+ * Re-fetches the REST snapshot without clearing the current list. Resolves
1296
+ * once the re-pull settles (success or failure) for the current context, so
1297
+ * callers (e.g. a `useMemories` `refresh()`) can await it. Resolves
1298
+ * immediately when no context is set.
1299
+ */
1300
+ refresh(): Promise<void>;
1301
+ /** Creates a memory; resolves to the stored memory (server-authoritative). */
1302
+ addMemory(input: NewMemory): Promise<Memory>;
1303
+ /** Supersedes a memory; resolves to the new memory (its id changes). */
1304
+ updateMemory(id: string, changes: MemoryChanges): Promise<Memory>;
1305
+ /** Retires a memory (non-lossy delete). */
1306
+ removeMemory(id: string): Promise<void>;
1307
+ getState(): MemoryState;
1308
+ /**
1309
+ * Stable, render-safe state for SSR/prerender. React's
1310
+ * `useSyncExternalStore` requires a `getServerSnapshot` during SSR/prerender
1311
+ * (e.g. Next.js); without one React throws "Missing getServerSnapshot". The
1312
+ * returned reference is stable across calls so React does not loop. There is
1313
+ * no client-side memory data during prerender, so this is the empty initial
1314
+ * state (no memories, not loading, no error).
1315
+ */
1316
+ getServerState(): MemoryState;
1317
+ select: Store<MemoryState>["select"];
1318
+ }
1319
+ /**
1320
+ * Creates the framework-agnostic memory store: a REST snapshot on `setContext`,
1321
+ * server-authoritative add/update/remove mutations, and realtime
1322
+ * `memory_metadata` deltas off the injected `user_meta` event source — all
1323
+ * reduced into observable state.
1324
+ */
1325
+ declare function createMemoryStore(environment: MemoryEnvironment): MemoryStore;
1326
+ type ɵMemoryState = MemoryState;
1327
+ type ɵMemoryRuntimeContext = MemoryRuntimeContext;
1328
+ type ɵMemoryMetadataEvent = MemoryMetadataEvent;
1329
+ type ɵMemoryEnvironment = MemoryEnvironment;
1330
+ type ɵMemoryStore = MemoryStore;
1331
+ declare const ɵmemoryAdapterEvents: ActionGroupResult<"Memory Adapter", {
1332
+ readonly started: EmptyActionConfig;
1333
+ readonly stopped: EmptyActionConfig;
1334
+ readonly contextChanged: PropsActionConfig<{
1335
+ context: MemoryRuntimeContext | null;
1336
+ }>;
1337
+ readonly addRequested: PropsActionConfig<{
1338
+ requestId: string;
1339
+ input: NewMemory;
1340
+ }>;
1341
+ readonly updateRequested: PropsActionConfig<{
1342
+ requestId: string;
1343
+ id: string;
1344
+ changes: MemoryChanges;
1345
+ }>;
1346
+ readonly removeRequested: PropsActionConfig<{
1347
+ requestId: string;
1348
+ id: string;
1349
+ }>;
1350
+ }>;
1351
+ declare const ɵmemoryRestEvents: ActionGroupResult<"Memory REST", {
1352
+ readonly listRequested: PropsActionConfig<{
1353
+ sessionId: number;
1354
+ }>;
1355
+ readonly listSucceeded: PropsActionConfig<{
1356
+ sessionId: number;
1357
+ memories: Memory[];
1358
+ }>;
1359
+ readonly listFailed: PropsActionConfig<{
1360
+ sessionId: number;
1361
+ error: Error;
1362
+ }>;
1363
+ readonly listUnavailable: PropsActionConfig<{
1364
+ sessionId: number;
1365
+ }>;
1366
+ readonly mutationFinished: PropsActionConfig<{
1367
+ outcome: MemoryMutationOutcome;
1368
+ }>;
1369
+ readonly credentialsRequested: PropsActionConfig<{
1370
+ sessionId: number;
1371
+ }>;
1372
+ readonly credentialsSucceeded: PropsActionConfig<{
1373
+ sessionId: number;
1374
+ joinToken: string;
1375
+ joinCode: string;
1376
+ }>;
1377
+ readonly credentialsFailed: PropsActionConfig<{
1378
+ sessionId: number;
1379
+ error: Error;
1380
+ }>;
1381
+ readonly credentialsUnavailable: PropsActionConfig<{
1382
+ sessionId: number;
1383
+ }>;
1384
+ }>;
1385
+ declare const ɵmemoryDomainEvents: ActionGroupResult<"Memory Domain", {
1386
+ readonly memoryUpserted: PropsActionConfig<{
1387
+ sessionId: number;
1388
+ memory: Memory;
1389
+ }>;
1390
+ readonly memoryInvalidated: PropsActionConfig<{
1391
+ sessionId: number;
1392
+ memoryId: string;
1393
+ }>;
1394
+ readonly realtimeConnecting: PropsActionConfig<{
1395
+ sessionId: number;
1396
+ }>;
1397
+ readonly realtimeConnected: PropsActionConfig<{
1398
+ sessionId: number;
1399
+ }>;
1400
+ readonly realtimeUnavailable: PropsActionConfig<{
1401
+ sessionId: number;
1402
+ }>;
1403
+ }>;
1404
+ declare const ɵmemoryReducer: Reducer<MemoryState>;
1405
+ declare const ɵmapMemoryMetadataEvent: typeof mapMemoryMetadataEvent;
1406
+ declare const ɵselectMemories: Selector<MemoryState, Memory[]>;
1407
+ declare const ɵselectMemoriesIsLoading: Selector<MemoryState, boolean>;
1408
+ declare const ɵselectMemoriesError: Selector<MemoryState, Error | null>;
1409
+ declare const ɵselectMemoriesIsMutating: Selector<MemoryState, boolean>;
1410
+ declare const ɵselectMemoriesAvailable: Selector<MemoryState, boolean>;
1411
+ declare const ɵselectMemoriesRealtimeStatus: Selector<MemoryState, MemoryRealtimeStatus>;
1412
+ //#endregion
1008
1413
  //#region src/core/core.d.ts
1009
1414
  /** Configuration options for `CopilotKitCore`. */
1010
1415
  interface CopilotKitCoreConfig {
@@ -1012,6 +1417,15 @@ interface CopilotKitCoreConfig {
1012
1417
  runtimeUrl?: string;
1013
1418
  /** Transport style for CopilotRuntime endpoints. Defaults to REST. */
1014
1419
  runtimeTransport?: CopilotRuntimeTransport;
1420
+ /**
1421
+ * When true, the constructor sets the runtime config but does NOT start the
1422
+ * `/info` connection. Call {@link CopilotKitCore.connect} to start it —
1423
+ * typically from a host's commit-phase effect. This prevents a burst of
1424
+ * duplicate `/info` requests when a host constructs (and discards) the core
1425
+ * during render, e.g. React concurrent rendering / Suspense / StrictMode.
1426
+ * See https://github.com/CopilotKit/CopilotKit/issues/5801.
1427
+ */
1428
+ deferInitialConnection?: boolean;
1015
1429
  /** Mapping from agent name to its `AbstractAgent` instance. For development only - production requires CopilotRuntime. */
1016
1430
  agents__unsafe_dev_only?: Record<string, AbstractAgent>;
1017
1431
  /**
@@ -1276,6 +1690,13 @@ declare class CopilotKitCore {
1276
1690
  private runHandler;
1277
1691
  private stateManager;
1278
1692
  private threadStoreRegistry;
1693
+ /**
1694
+ * The single core-owned memory store, created lazily on first
1695
+ * `getMemoryStore()` and kept user-scoped for the lifetime of the core.
1696
+ * Its runtime context is wired by the core itself (see `syncMemoryContext`),
1697
+ * so callers never register or look it up by `agentId`.
1698
+ */
1699
+ private _memoryStore?;
1279
1700
  /**
1280
1701
  * Tracks the agent IDs from the most recent `onAgentsChanged` notification.
1281
1702
  * Used to gate thread-store auto-unregister so the FIRST empty-agents
@@ -1286,6 +1707,7 @@ declare class CopilotKitCore {
1286
1707
  constructor({
1287
1708
  runtimeUrl,
1288
1709
  runtimeTransport,
1710
+ deferInitialConnection,
1289
1711
  headers,
1290
1712
  credentials,
1291
1713
  properties,
@@ -1315,6 +1737,16 @@ declare class CopilotKitCore {
1315
1737
  get tools(): Readonly<FrontendTool<any>[]>;
1316
1738
  get runtimeUrl(): string | undefined;
1317
1739
  setRuntimeUrl(runtimeUrl: string | undefined): void;
1740
+ /**
1741
+ * Start the runtime `/info` connection if it has not been started yet.
1742
+ *
1743
+ * Intended to be driven from a host's commit-phase effect when the core was
1744
+ * constructed with {@link CopilotKitCoreConfig.deferInitialConnection}. Safe
1745
+ * to call repeatedly — it is a no-op once a connection is in progress or
1746
+ * settled, so a double-invoked mount effect (React StrictMode) collapses to a
1747
+ * single request. See #5801.
1748
+ */
1749
+ connect(): void;
1318
1750
  get runtimeTransport(): CopilotRuntimeTransport;
1319
1751
  setRuntimeTransport(runtimeTransport: CopilotRuntimeTransport): void;
1320
1752
  get runtimeVersion(): string | undefined;
@@ -1342,6 +1774,7 @@ declare class CopilotKitCore {
1342
1774
  get runtimeMode(): RuntimeMode;
1343
1775
  get intelligence(): IntelligenceRuntimeInfo | undefined;
1344
1776
  get threadEndpoints(): ThreadEndpointRuntimeInfo | undefined;
1777
+ get suggestions(): boolean | undefined;
1345
1778
  get a2uiEnabled(): boolean;
1346
1779
  /**
1347
1780
  * Agent ids the runtime applies A2UI to. `undefined` means A2UI applies to
@@ -1447,6 +1880,29 @@ declare class CopilotKitCore {
1447
1880
  unregisterThreadStore(agentId: string): void;
1448
1881
  getThreadStore(agentId: string): ɵThreadStore | undefined;
1449
1882
  getThreadStores(): Readonly<Record<string, ɵThreadStore>>;
1883
+ /**
1884
+ * Returns the single core-owned, user-scoped memory store, creating and
1885
+ * starting it on first access. Unlike thread stores, memory is not scoped per
1886
+ * agent: there is exactly one store whose runtime context the core wires
1887
+ * itself (see `syncMemoryContext`), so consumers (e.g. a `useMemories`
1888
+ * binding) just read this store rather than registering one.
1889
+ */
1890
+ getMemoryStore(): ɵMemoryStore;
1891
+ /**
1892
+ * Lazily creates, starts, and context-syncs the core-owned memory store on
1893
+ * first access, then returns it. Subsequent calls return the existing store.
1894
+ * The store is constructed with a bound `globalThis.fetch` and immediately
1895
+ * has its runtime context synced from the current connection state.
1896
+ */
1897
+ private ensureMemoryStore;
1898
+ /**
1899
+ * Pushes the current runtime wiring into the memory store. When the runtime
1900
+ * is connected and both the intelligence WebSocket URL and runtime URL are
1901
+ * available, the store receives a context (runtime URL, WebSocket URL, and a
1902
+ * copy of the current headers); otherwise its context is cleared. No-op when
1903
+ * the store has not been created yet.
1904
+ */
1905
+ private syncMemoryContext;
1450
1906
  /**
1451
1907
  * Suggestions management (delegated to SuggestionEngine)
1452
1908
  */
@@ -1557,7 +2013,26 @@ declare class SuggestionEngine {
1557
2013
  */
1558
2014
  getSuggestions(agentId: string): CopilotKitCoreGetSuggestionsResult;
1559
2015
  /**
1560
- * Generate suggestions using a provider agent
2016
+ * Generate suggestions by running a provider agent and extracting the
2017
+ * `copilotkitSuggest` tool call from its streamed messages.
2018
+ *
2019
+ * Two transports, one set of mechanics: both seed an agent with the
2020
+ * consumer's messages + state and the instruction, then `runAgent` with
2021
+ * forced `copilotkitSuggest` tool choice, parsing suggestions as messages
2022
+ * stream in via `onMessagesChanged`.
2023
+ *
2024
+ * - **Stateless** (runtime advertises `suggestions` and transport isn't
2025
+ * `single`): a stock `HttpAgent` pointed at `/agent/:id/suggest`. That
2026
+ * endpoint runs the provider directly and streams AG-UI SSE **without**
2027
+ * persisting a thread, and a plain `HttpAgent` only ever speaks REST SSE —
2028
+ * it never routes through the Intelligence websocket delegate (which would
2029
+ * persist a thread). This is the path that removes the thread flood.
2030
+ * - **Fallback** (capability absent → old runtime, or `single` transport):
2031
+ * clone the provider agent and run it client-side, as before.
2032
+ *
2033
+ * Gated to non-`single` transports because this client only builds the
2034
+ * multi-route `/agent/:id/suggest` URL; single-route deployments (not the
2035
+ * persisting-thread/Intelligence case) fall through to the clone fallback.
1561
2036
  */
1562
2037
  private generateSuggestions;
1563
2038
  /**
@@ -1593,6 +2068,11 @@ declare class SuggestionEngine {
1593
2068
  */
1594
2069
  private addStaticSuggestions;
1595
2070
  }
2071
+ /**
2072
+ * Detects an `AbortController`-driven cancellation so the stateless path can
2073
+ * treat it as an expected (non-error) outcome on clear/reload.
2074
+ */
2075
+ declare function isAbortError(error: unknown): boolean;
1596
2076
  //#endregion
1597
2077
  //#region src/core/state-manager.d.ts
1598
2078
  /**
@@ -1982,5 +2462,5 @@ type ɵCopilotKitFeature = (typeof ɵCOPILOTKIT_FEATURES)[number];
1982
2462
  */
1983
2463
  declare function ɵisCopilotKitFeature(name: string): name is ɵCopilotKitFeature;
1984
2464
  //#endregion
1985
- export { ActionConfig, ActionCreator, ActionFromCreator, ActionFromCreators, ActionGroupConfig, ActionGroupResult, AgentRegistry, AgentThreadLockedError, AnyAction, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, CopilotKitCoreFriendsAccess, CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRegisterProxiedAgentParams, type CopilotKitCoreRegisterProxiedAgentResult, type CopilotKitCoreRunAgentParams, type CopilotKitCoreRunToolParams, type CopilotKitCoreRunToolResult, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreStopAgentParams, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, CopilotRuntimeTransport, DispatchingEffect, DispatchingEffectOptions, DynamicSuggestionsConfig, Effect, EmptyActionConfig, FrontendTool, FrontendToolHandlerContext, IntelligenceAgent, IntelligenceAgentConfig, type IntelligenceRuntimeInfo, NonDispatchingEffect, NonDispatchingEffectOptions, PropsActionConfig, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgentConfig, Reducer, RunCompletionAware, RunHandler, type RuntimeLicenseStatus, type RuntimeMode, ScopedContext, Selector, StateManager, StaticSuggestionsConfig, Store, StoreLifecycleAction, SubscribeToAgentOptions, SubscribeToAgentSubscriber, Suggestion, SuggestionAvailability, SuggestionEngine, SuggestionsConfig, type ThreadEndpointRuntimeInfo, ThreadRunActivityNotification, ToolCallStatus, completePartialMarkdown, createActionGroup, createEffect, createReducer, createSelector, createStore, empty, ensureObjectArgs, isRunCompletionAware, ofType, on, parseToolArguments, props, select, ɵCOPILOTKIT_FEATURES, ɵCopilotKitFeature, ɵMAX_SOCKET_RETRIES, ɵPhoenixChannelLike, ɵPhoenixChannelOptions, ɵPhoenixChannelSession, ɵPhoenixJoinOutcome, ɵPhoenixPushLike, ɵPhoenixSocketLike, ɵPhoenixSocketOptions, ɵPhoenixSocketSession, ɵPhoenixSocketSignal, ɵThread, ɵThreadEnvironment, ɵThreadMetadataEvent, ɵThreadRuntimeContext, ɵThreadSelectors, ɵThreadStore, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵisCopilotKitFeature, ɵjoinPhoenixChannel$, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵthreadAdapterEvents };
2465
+ export { ActionConfig, ActionCreator, ActionFromCreator, ActionFromCreators, ActionGroupConfig, ActionGroupResult, AgentRegistry, AgentThreadLockedError, AnyAction, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, CopilotKitCoreFriendsAccess, CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRegisterProxiedAgentParams, type CopilotKitCoreRegisterProxiedAgentResult, type CopilotKitCoreRunAgentParams, type CopilotKitCoreRunToolParams, type CopilotKitCoreRunToolResult, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreStopAgentParams, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, CopilotRuntimeTransport, DispatchingEffect, DispatchingEffectOptions, DynamicSuggestionsConfig, Effect, EmptyActionConfig, FrontendTool, FrontendToolHandlerContext, IntelligenceAgent, IntelligenceAgentConfig, type IntelligenceRuntimeInfo, MEMORY_ERROR_REGISTRY, Memory, MemoryChanges, MemoryError, type MemoryErrorCategory, type MemoryErrorCode, type MemoryErrorRegistryEntry, MemoryKind, MemoryRealtimeStatus, MemoryScope, NewMemory, NonDispatchingEffect, NonDispatchingEffectOptions, PropsActionConfig, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgentConfig, Reducer, RunCompletionAware, RunHandler, type RuntimeLicenseStatus, type RuntimeMode, ScopedContext, Selector, StateManager, StaticSuggestionsConfig, Store, StoreLifecycleAction, SubscribeToAgentOptions, SubscribeToAgentSubscriber, Suggestion, SuggestionAvailability, SuggestionEngine, SuggestionsConfig, type ThreadEndpointRuntimeInfo, ThreadRunActivityNotification, ToolCallStatus, completePartialMarkdown, createActionGroup, createEffect, createReducer, createSelector, createStore, empty, ensureObjectArgs, isAbortError, isRunCompletionAware, ofType, on, parseToolArguments, props, select, ɵCOPILOTKIT_FEATURES, ɵCopilotKitFeature, ɵMAX_SOCKET_RETRIES, ɵMemoryEnvironment, ɵMemoryMetadataEvent, ɵMemoryRuntimeContext, ɵMemoryState, ɵMemoryStore, ɵPhoenixChannelLike, ɵPhoenixChannelOptions, ɵPhoenixChannelSession, ɵPhoenixJoinOutcome, ɵPhoenixPushLike, ɵPhoenixSocketLike, ɵPhoenixSocketOptions, ɵPhoenixSocketSession, ɵPhoenixSocketSignal, ɵThread, ɵThreadEnvironment, ɵThreadMetadataEvent, ɵThreadRuntimeContext, ɵThreadSelectors, ɵThreadStore, createMemoryStore as ɵcreateMemoryStore, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵisCopilotKitFeature, 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 };
1986
2466
  //# sourceMappingURL=index.d.cts.map