@copilotkit/core 1.55.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +3360 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1374 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1374 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3321 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +3535 -0
- package/dist/index.umd.js.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +56 -0
- package/tsdown.config.ts +45 -0
- package/vitest.config.mjs +17 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1374 @@
|
|
|
1
|
+
import * as _ag_ui_client0 from "@ag-ui/client";
|
|
2
|
+
import { AbstractAgent, AgentSubscriber, BaseEvent, Context, HttpAgent, HttpAgentConfig, Message, RunAgentInput, RunAgentParameters, RunAgentResult, State, Tool, ToolCall } from "@ag-ui/client";
|
|
3
|
+
import { IntelligenceRuntimeInfo, IntelligenceRuntimeInfo as IntelligenceRuntimeInfo$1, RuntimeLicenseStatus, RuntimeLicenseStatus as RuntimeLicenseStatus$1, RuntimeMode, RuntimeMode as RuntimeMode$1, StandardSchemaV1 } from "@copilotkit/shared";
|
|
4
|
+
import { Observable, OperatorFunction } from "rxjs";
|
|
5
|
+
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Status of a tool call execution
|
|
9
|
+
*/
|
|
10
|
+
declare enum ToolCallStatus {
|
|
11
|
+
InProgress = "inProgress",
|
|
12
|
+
Executing = "executing",
|
|
13
|
+
Complete = "complete"
|
|
14
|
+
}
|
|
15
|
+
type CopilotRuntimeTransport = "rest" | "single";
|
|
16
|
+
/**
|
|
17
|
+
* Context passed to a frontend tool handler
|
|
18
|
+
*/
|
|
19
|
+
type FrontendToolHandlerContext = {
|
|
20
|
+
toolCall: ToolCall;
|
|
21
|
+
agent: AbstractAgent;
|
|
22
|
+
/** Aborted when `stopAgent()` is called. Handlers can check `signal.aborted`
|
|
23
|
+
* or pass the signal to fetch/setTimeout to cooperatively cancel. */
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
};
|
|
26
|
+
type FrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
parameters?: StandardSchemaV1<any, T>;
|
|
30
|
+
handler?: (args: T, context: FrontendToolHandlerContext) => Promise<unknown>;
|
|
31
|
+
followUp?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Optional agent ID to constrain this tool to a specific agent.
|
|
34
|
+
* If specified, this tool will only be available to the specified agent.
|
|
35
|
+
*/
|
|
36
|
+
agentId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Whether this tool is available to the agent.
|
|
39
|
+
* Set to false to hide the tool from the agent without unregistering it.
|
|
40
|
+
* Defaults to true when not specified.
|
|
41
|
+
*/
|
|
42
|
+
available?: boolean;
|
|
43
|
+
};
|
|
44
|
+
type Suggestion = {
|
|
45
|
+
title: string;
|
|
46
|
+
message: string; /** Indicates whether this suggestion is still being generated. */
|
|
47
|
+
isLoading: boolean;
|
|
48
|
+
};
|
|
49
|
+
type SuggestionAvailability = "before-first-message" | "after-first-message" | "always" | "disabled";
|
|
50
|
+
type DynamicSuggestionsConfig = {
|
|
51
|
+
/**
|
|
52
|
+
* A prompt or instructions for the GPT to generate suggestions.
|
|
53
|
+
*/
|
|
54
|
+
instructions: string;
|
|
55
|
+
/**
|
|
56
|
+
* The minimum number of suggestions to generate. Defaults to `1`.
|
|
57
|
+
* @default 1
|
|
58
|
+
*/
|
|
59
|
+
minSuggestions?: number;
|
|
60
|
+
/**
|
|
61
|
+
* The maximum number of suggestions to generate. Defaults to `3`.
|
|
62
|
+
* @default 1
|
|
63
|
+
*/
|
|
64
|
+
maxSuggestions?: number;
|
|
65
|
+
/**
|
|
66
|
+
* When the suggestions are available. Defaults to "after-first-message".
|
|
67
|
+
*/
|
|
68
|
+
available?: SuggestionAvailability;
|
|
69
|
+
/**
|
|
70
|
+
* The agent ID of the provider of the suggestions. Defaults to `"default"`.
|
|
71
|
+
*/
|
|
72
|
+
providerAgentId?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The agent ID of the consumer of the suggestions. Defaults to `"*"` (all agents).
|
|
75
|
+
*/
|
|
76
|
+
consumerAgentId?: string;
|
|
77
|
+
};
|
|
78
|
+
type StaticSuggestionsConfig = {
|
|
79
|
+
/**
|
|
80
|
+
* The suggestions to display.
|
|
81
|
+
*/
|
|
82
|
+
suggestions: Omit<Suggestion, "isLoading">[];
|
|
83
|
+
/**
|
|
84
|
+
* When the suggestions are available. Defaults to "before-first-message".
|
|
85
|
+
*/
|
|
86
|
+
available?: SuggestionAvailability;
|
|
87
|
+
/**
|
|
88
|
+
* The agent ID of the consumer of the suggestions. Defaults to `"*"` (all agents).
|
|
89
|
+
*/
|
|
90
|
+
consumerAgentId?: string;
|
|
91
|
+
};
|
|
92
|
+
type SuggestionsConfig = DynamicSuggestionsConfig | StaticSuggestionsConfig;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/core/agent-registry.d.ts
|
|
95
|
+
interface CopilotKitCoreAddAgentParams {
|
|
96
|
+
id: string;
|
|
97
|
+
agent: AbstractAgent;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Manages agent registration, lifecycle, and runtime connectivity for CopilotKitCore.
|
|
101
|
+
* Handles both local development agents and remote runtime agents.
|
|
102
|
+
*/
|
|
103
|
+
declare class AgentRegistry {
|
|
104
|
+
private core;
|
|
105
|
+
private _agents;
|
|
106
|
+
private localAgents;
|
|
107
|
+
private remoteAgents;
|
|
108
|
+
private _runtimeUrl?;
|
|
109
|
+
private _runtimeVersion?;
|
|
110
|
+
private _runtimeConnectionStatus;
|
|
111
|
+
private _runtimeTransport;
|
|
112
|
+
private _audioFileTranscriptionEnabled;
|
|
113
|
+
private _runtimeMode;
|
|
114
|
+
private _intelligence?;
|
|
115
|
+
private _a2uiEnabled;
|
|
116
|
+
private _licenseStatus?;
|
|
117
|
+
constructor(core: CopilotKitCore);
|
|
118
|
+
/**
|
|
119
|
+
* Get all agents as a readonly record
|
|
120
|
+
*/
|
|
121
|
+
get agents(): Readonly<Record<string, AbstractAgent>>;
|
|
122
|
+
get runtimeUrl(): string | undefined;
|
|
123
|
+
get runtimeVersion(): string | undefined;
|
|
124
|
+
get runtimeConnectionStatus(): CopilotKitCoreRuntimeConnectionStatus;
|
|
125
|
+
get runtimeTransport(): CopilotRuntimeTransport;
|
|
126
|
+
get audioFileTranscriptionEnabled(): boolean;
|
|
127
|
+
get runtimeMode(): RuntimeMode$1;
|
|
128
|
+
get intelligence(): IntelligenceRuntimeInfo$1 | undefined;
|
|
129
|
+
get a2uiEnabled(): boolean;
|
|
130
|
+
get licenseStatus(): RuntimeLicenseStatus$1 | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Initialize agents from configuration
|
|
133
|
+
*/
|
|
134
|
+
initialize(agents: Record<string, AbstractAgent>): void;
|
|
135
|
+
/**
|
|
136
|
+
* Set the runtime URL and update connection
|
|
137
|
+
*/
|
|
138
|
+
setRuntimeUrl(runtimeUrl: string | undefined): void;
|
|
139
|
+
setRuntimeTransport(runtimeTransport: CopilotRuntimeTransport): void;
|
|
140
|
+
/**
|
|
141
|
+
* Set all agents at once (for development use)
|
|
142
|
+
*/
|
|
143
|
+
setAgents__unsafe_dev_only(agents: Record<string, AbstractAgent>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Add a single agent (for development use)
|
|
146
|
+
*/
|
|
147
|
+
addAgent__unsafe_dev_only({
|
|
148
|
+
id,
|
|
149
|
+
agent
|
|
150
|
+
}: CopilotKitCoreAddAgentParams): void;
|
|
151
|
+
/**
|
|
152
|
+
* Remove an agent by ID (for development use)
|
|
153
|
+
*/
|
|
154
|
+
removeAgent__unsafe_dev_only(id: string): void;
|
|
155
|
+
/**
|
|
156
|
+
* Get an agent by ID
|
|
157
|
+
*/
|
|
158
|
+
getAgent(id: string): AbstractAgent | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Apply current headers to an agent
|
|
161
|
+
*/
|
|
162
|
+
applyHeadersToAgent(agent: AbstractAgent): void;
|
|
163
|
+
/**
|
|
164
|
+
* Apply current headers to all agents
|
|
165
|
+
*/
|
|
166
|
+
applyHeadersToAgents(agents: Record<string, AbstractAgent>): void;
|
|
167
|
+
/**
|
|
168
|
+
* Apply current credentials to an agent
|
|
169
|
+
*/
|
|
170
|
+
applyCredentialsToAgent(agent: AbstractAgent): void;
|
|
171
|
+
/**
|
|
172
|
+
* Apply current credentials to all agents
|
|
173
|
+
*/
|
|
174
|
+
applyCredentialsToAgents(agents: Record<string, AbstractAgent>): void;
|
|
175
|
+
/**
|
|
176
|
+
* Update runtime connection and fetch remote agents
|
|
177
|
+
*/
|
|
178
|
+
private updateRuntimeConnection;
|
|
179
|
+
private fetchRuntimeInfo;
|
|
180
|
+
/**
|
|
181
|
+
* Assign agent IDs to a record of agents
|
|
182
|
+
*/
|
|
183
|
+
private assignAgentIds;
|
|
184
|
+
/**
|
|
185
|
+
* Validate and assign an agent ID
|
|
186
|
+
*/
|
|
187
|
+
private validateAndAssignAgentId;
|
|
188
|
+
/**
|
|
189
|
+
* Notify subscribers of runtime status changes
|
|
190
|
+
*/
|
|
191
|
+
private notifyRuntimeStatusChanged;
|
|
192
|
+
/**
|
|
193
|
+
* Notify subscribers of agent changes
|
|
194
|
+
*/
|
|
195
|
+
private notifyAgentsChanged;
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/core/run-handler.d.ts
|
|
199
|
+
interface CopilotKitCoreRunAgentParams {
|
|
200
|
+
agent: AbstractAgent;
|
|
201
|
+
forwardedProps?: Record<string, unknown>;
|
|
202
|
+
}
|
|
203
|
+
interface CopilotKitCoreConnectAgentParams {
|
|
204
|
+
agent: AbstractAgent;
|
|
205
|
+
}
|
|
206
|
+
interface CopilotKitCoreGetToolParams {
|
|
207
|
+
toolName: string;
|
|
208
|
+
agentId?: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Parameters for programmatic tool execution via `copilotkit.runTool()`.
|
|
212
|
+
*/
|
|
213
|
+
interface CopilotKitCoreRunToolParams {
|
|
214
|
+
/** Name of the registered frontend tool to execute. */
|
|
215
|
+
name: string;
|
|
216
|
+
/** Optional agent ID. If omitted, uses the default agent lookup. */
|
|
217
|
+
agentId?: string;
|
|
218
|
+
/** Parameters to pass to the tool handler. */
|
|
219
|
+
parameters?: Record<string, unknown>;
|
|
220
|
+
/**
|
|
221
|
+
* Whether to trigger an LLM follow-up after tool execution.
|
|
222
|
+
* - `false` (default): execute tool, add messages to history, done.
|
|
223
|
+
* - `"generate"`: after execution, trigger another agent run so the LLM responds to the tool result.
|
|
224
|
+
* - Any other string: add a user message with this text, then trigger another agent run.
|
|
225
|
+
*/
|
|
226
|
+
followUp?: string | false;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Result of programmatic tool execution via `copilotkit.runTool()`.
|
|
230
|
+
*/
|
|
231
|
+
interface CopilotKitCoreRunToolResult {
|
|
232
|
+
/** The unique ID of the tool call. */
|
|
233
|
+
toolCallId: string;
|
|
234
|
+
/** The stringified result from the tool handler. */
|
|
235
|
+
result: string;
|
|
236
|
+
/** Error message if the handler failed. */
|
|
237
|
+
error?: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Handles agent execution, tool calling, and agent connectivity for CopilotKitCore.
|
|
241
|
+
* Manages the complete lifecycle of agent runs including tool execution and follow-ups.
|
|
242
|
+
*/
|
|
243
|
+
declare class RunHandler {
|
|
244
|
+
private core;
|
|
245
|
+
private _tools;
|
|
246
|
+
/**
|
|
247
|
+
* Tracks whether the current run (including in-flight tool execution)
|
|
248
|
+
* has been aborted via `stopAgent()` or `agent.abortRun()`. Created
|
|
249
|
+
* fresh in `runAgent()`, aborted by `abortCurrentRun()`.
|
|
250
|
+
*/
|
|
251
|
+
private _runAbortController;
|
|
252
|
+
/**
|
|
253
|
+
* Tracks recursive `runAgent` depth so that the abort controller and
|
|
254
|
+
* `agent.abortRun()` intercept are only set up / torn down at the
|
|
255
|
+
* top-level call, not on follow-up recursive calls from
|
|
256
|
+
* `processAgentResult`.
|
|
257
|
+
*/
|
|
258
|
+
private _runDepth;
|
|
259
|
+
constructor(core: CopilotKitCore);
|
|
260
|
+
/**
|
|
261
|
+
* Abort the current run. Called by `CopilotKitCore.stopAgent()` to signal
|
|
262
|
+
* that in-flight tool handlers should stop and `processAgentResult` should
|
|
263
|
+
* not start a follow-up run.
|
|
264
|
+
*/
|
|
265
|
+
abortCurrentRun(): void;
|
|
266
|
+
/**
|
|
267
|
+
* Typed access to CopilotKitCore's internal ("friend") methods.
|
|
268
|
+
* Centralises the single unavoidable cast so call-sites stay clean.
|
|
269
|
+
*/
|
|
270
|
+
private get _internal();
|
|
271
|
+
/**
|
|
272
|
+
* Get all tools as a readonly array
|
|
273
|
+
*/
|
|
274
|
+
get tools(): Readonly<FrontendTool<any>[]>;
|
|
275
|
+
/**
|
|
276
|
+
* Initialize with tools
|
|
277
|
+
*/
|
|
278
|
+
initialize(tools: FrontendTool<any>[]): void;
|
|
279
|
+
/**
|
|
280
|
+
* Add a tool to the registry
|
|
281
|
+
*/
|
|
282
|
+
addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
|
|
283
|
+
/**
|
|
284
|
+
* Remove a tool by name and optionally by agentId
|
|
285
|
+
*/
|
|
286
|
+
removeTool(id: string, agentId?: string): void;
|
|
287
|
+
/**
|
|
288
|
+
* Get a tool by name and optionally by agentId.
|
|
289
|
+
* If agentId is provided, it will first look for an agent-specific tool,
|
|
290
|
+
* then fall back to a global tool with the same name.
|
|
291
|
+
*/
|
|
292
|
+
getTool(params: CopilotKitCoreGetToolParams): FrontendTool<any> | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* Set all tools at once. Replaces existing tools.
|
|
295
|
+
*/
|
|
296
|
+
setTools(tools: FrontendTool<any>[]): void;
|
|
297
|
+
/**
|
|
298
|
+
* Connect an agent (establish initial connection)
|
|
299
|
+
*/
|
|
300
|
+
connectAgent({
|
|
301
|
+
agent
|
|
302
|
+
}: CopilotKitCoreConnectAgentParams): Promise<RunAgentResult>;
|
|
303
|
+
/**
|
|
304
|
+
* Run an agent
|
|
305
|
+
*/
|
|
306
|
+
runAgent({
|
|
307
|
+
agent,
|
|
308
|
+
forwardedProps
|
|
309
|
+
}: CopilotKitCoreRunAgentParams): Promise<RunAgentResult>;
|
|
310
|
+
/**
|
|
311
|
+
* Process agent result and execute tools
|
|
312
|
+
*/
|
|
313
|
+
private processAgentResult;
|
|
314
|
+
/**
|
|
315
|
+
* Shared handler execution logic used by executeSpecificTool, executeWildcardTool, and runTool.
|
|
316
|
+
* Handles arg parsing, subscriber notifications, handler invocation, result stringification,
|
|
317
|
+
* and error handling.
|
|
318
|
+
*/
|
|
319
|
+
private executeToolHandler;
|
|
320
|
+
/**
|
|
321
|
+
* Execute a specific tool
|
|
322
|
+
*/
|
|
323
|
+
private executeSpecificTool;
|
|
324
|
+
/**
|
|
325
|
+
* Execute a wildcard tool.
|
|
326
|
+
* Wildcard tools receive args wrapped as `{toolName, args}`, which differs from
|
|
327
|
+
* specific tools, so this method keeps its own arg-wrapping logic rather than
|
|
328
|
+
* delegating to `executeToolHandler`.
|
|
329
|
+
*/
|
|
330
|
+
private executeWildcardTool;
|
|
331
|
+
/**
|
|
332
|
+
* Programmatically execute a registered frontend tool without going through an LLM turn.
|
|
333
|
+
* The handler runs, render components show up in the UI, and both the tool call and
|
|
334
|
+
* result messages are added to `agent.messages`.
|
|
335
|
+
*/
|
|
336
|
+
runTool(params: CopilotKitCoreRunToolParams): Promise<CopilotKitCoreRunToolResult>;
|
|
337
|
+
/**
|
|
338
|
+
* Build frontend tools for an agent
|
|
339
|
+
*/
|
|
340
|
+
buildFrontendTools(agentId?: string): Tool[];
|
|
341
|
+
/**
|
|
342
|
+
* Create an agent error subscriber
|
|
343
|
+
*/
|
|
344
|
+
private createAgentErrorSubscriber;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Ensures parsed tool arguments are a plain object.
|
|
348
|
+
* Throws for non-object values so the caller's catch block can emit
|
|
349
|
+
* a structured TOOL_ARGUMENT_PARSE_FAILED error.
|
|
350
|
+
*
|
|
351
|
+
* @internal Exported for testing only.
|
|
352
|
+
*/
|
|
353
|
+
declare function ensureObjectArgs(parsed: unknown, toolName: string): Record<string, unknown>;
|
|
354
|
+
/**
|
|
355
|
+
* Parses raw tool call arguments into a validated object.
|
|
356
|
+
*
|
|
357
|
+
* Some LLM providers (e.g. @ai-sdk/openai-compatible) may send empty string "",
|
|
358
|
+
* null, or undefined instead of "{}". This function normalises those cases to an
|
|
359
|
+
* empty object so callers don't crash on JSON.parse("").
|
|
360
|
+
*
|
|
361
|
+
* A debug-level warning is emitted when the fallback triggers so silent coercion
|
|
362
|
+
* is observable in logs.
|
|
363
|
+
*
|
|
364
|
+
* @internal Exported for testing only.
|
|
365
|
+
*/
|
|
366
|
+
declare function parseToolArguments(rawArgs: unknown, toolName: string): Record<string, unknown>;
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/core/core.d.ts
|
|
369
|
+
/** Configuration options for `CopilotKitCore`. */
|
|
370
|
+
interface CopilotKitCoreConfig {
|
|
371
|
+
/** The endpoint of the CopilotRuntime. */
|
|
372
|
+
runtimeUrl?: string;
|
|
373
|
+
/** Transport style for CopilotRuntime endpoints. Defaults to REST. */
|
|
374
|
+
runtimeTransport?: CopilotRuntimeTransport;
|
|
375
|
+
/** Mapping from agent name to its `AbstractAgent` instance. For development only - production requires CopilotRuntime. */
|
|
376
|
+
agents__unsafe_dev_only?: Record<string, AbstractAgent>;
|
|
377
|
+
/** Headers appended to every HTTP request made by `CopilotKitCore`. */
|
|
378
|
+
headers?: Record<string, string>;
|
|
379
|
+
/** Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies). */
|
|
380
|
+
credentials?: RequestCredentials;
|
|
381
|
+
/** Properties sent as `forwardedProps` to the AG-UI agent. */
|
|
382
|
+
properties?: Record<string, unknown>;
|
|
383
|
+
/** Ordered collection of frontend tools available to the core. */
|
|
384
|
+
tools?: FrontendTool<any>[];
|
|
385
|
+
/** Suggestions config for the core. */
|
|
386
|
+
suggestionsConfig?: SuggestionsConfig[];
|
|
387
|
+
}
|
|
388
|
+
interface CopilotKitCoreStopAgentParams {
|
|
389
|
+
agent: AbstractAgent;
|
|
390
|
+
}
|
|
391
|
+
type CopilotKitCoreGetSuggestionsResult = {
|
|
392
|
+
suggestions: Suggestion[];
|
|
393
|
+
isLoading: boolean;
|
|
394
|
+
};
|
|
395
|
+
declare enum CopilotKitCoreErrorCode {
|
|
396
|
+
RUNTIME_INFO_FETCH_FAILED = "runtime_info_fetch_failed",
|
|
397
|
+
AGENT_CONNECT_FAILED = "agent_connect_failed",
|
|
398
|
+
AGENT_RUN_FAILED = "agent_run_failed",
|
|
399
|
+
AGENT_RUN_FAILED_EVENT = "agent_run_failed_event",
|
|
400
|
+
AGENT_RUN_ERROR_EVENT = "agent_run_error_event",
|
|
401
|
+
TOOL_ARGUMENT_PARSE_FAILED = "tool_argument_parse_failed",
|
|
402
|
+
TOOL_HANDLER_FAILED = "tool_handler_failed",
|
|
403
|
+
TOOL_NOT_FOUND = "tool_not_found",
|
|
404
|
+
AGENT_NOT_FOUND = "agent_not_found",
|
|
405
|
+
/**
|
|
406
|
+
* Emitted when an agent run fails because the thread is already locked
|
|
407
|
+
* by another active run.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```tsx
|
|
411
|
+
* <CopilotKitProvider
|
|
412
|
+
* onError={({ code, error, context }) => {
|
|
413
|
+
* if (code === "agent_thread_locked") {
|
|
414
|
+
* // Show "Agent is busy, retry?" UI
|
|
415
|
+
* }
|
|
416
|
+
* }}
|
|
417
|
+
* />
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
AGENT_THREAD_LOCKED = "agent_thread_locked",
|
|
421
|
+
TRANSCRIPTION_FAILED = "transcription_failed",
|
|
422
|
+
TRANSCRIPTION_SERVICE_NOT_CONFIGURED = "transcription_service_not_configured",
|
|
423
|
+
TRANSCRIPTION_INVALID_AUDIO = "transcription_invalid_audio",
|
|
424
|
+
TRANSCRIPTION_RATE_LIMITED = "transcription_rate_limited",
|
|
425
|
+
TRANSCRIPTION_AUTH_FAILED = "transcription_auth_failed",
|
|
426
|
+
TRANSCRIPTION_NETWORK_ERROR = "transcription_network_error"
|
|
427
|
+
}
|
|
428
|
+
interface CopilotKitCoreSubscriber {
|
|
429
|
+
onRuntimeConnectionStatusChanged?: (event: {
|
|
430
|
+
copilotkit: CopilotKitCore;
|
|
431
|
+
status: CopilotKitCoreRuntimeConnectionStatus;
|
|
432
|
+
}) => void | Promise<void>;
|
|
433
|
+
onToolExecutionStart?: (event: {
|
|
434
|
+
copilotkit: CopilotKitCore;
|
|
435
|
+
toolCallId: string;
|
|
436
|
+
agentId: string;
|
|
437
|
+
toolName: string;
|
|
438
|
+
args: unknown;
|
|
439
|
+
}) => void | Promise<void>;
|
|
440
|
+
onToolExecutionEnd?: (event: {
|
|
441
|
+
copilotkit: CopilotKitCore;
|
|
442
|
+
toolCallId: string;
|
|
443
|
+
agentId: string;
|
|
444
|
+
toolName: string;
|
|
445
|
+
result: string;
|
|
446
|
+
error?: string;
|
|
447
|
+
}) => void | Promise<void>;
|
|
448
|
+
onAgentsChanged?: (event: {
|
|
449
|
+
copilotkit: CopilotKitCore;
|
|
450
|
+
agents: Readonly<Record<string, AbstractAgent>>;
|
|
451
|
+
}) => void | Promise<void>;
|
|
452
|
+
onContextChanged?: (event: {
|
|
453
|
+
copilotkit: CopilotKitCore;
|
|
454
|
+
context: Readonly<Record<string, Context>>;
|
|
455
|
+
}) => void | Promise<void>;
|
|
456
|
+
onSuggestionsConfigChanged?: (event: {
|
|
457
|
+
copilotkit: CopilotKitCore;
|
|
458
|
+
suggestionsConfig: Readonly<Record<string, SuggestionsConfig>>;
|
|
459
|
+
}) => void | Promise<void>;
|
|
460
|
+
onSuggestionsChanged?: (event: {
|
|
461
|
+
copilotkit: CopilotKitCore;
|
|
462
|
+
agentId: string;
|
|
463
|
+
suggestions: Suggestion[];
|
|
464
|
+
}) => void | Promise<void>;
|
|
465
|
+
onSuggestionsStartedLoading?: (event: {
|
|
466
|
+
copilotkit: CopilotKitCore;
|
|
467
|
+
agentId: string;
|
|
468
|
+
}) => void | Promise<void>;
|
|
469
|
+
onSuggestionsFinishedLoading?: (event: {
|
|
470
|
+
copilotkit: CopilotKitCore;
|
|
471
|
+
agentId: string;
|
|
472
|
+
}) => void | Promise<void>;
|
|
473
|
+
onPropertiesChanged?: (event: {
|
|
474
|
+
copilotkit: CopilotKitCore;
|
|
475
|
+
properties: Readonly<Record<string, unknown>>;
|
|
476
|
+
}) => void | Promise<void>;
|
|
477
|
+
onHeadersChanged?: (event: {
|
|
478
|
+
copilotkit: CopilotKitCore;
|
|
479
|
+
headers: Readonly<Record<string, string>>;
|
|
480
|
+
}) => void | Promise<void>;
|
|
481
|
+
onError?: (event: {
|
|
482
|
+
copilotkit: CopilotKitCore;
|
|
483
|
+
error: Error;
|
|
484
|
+
code: CopilotKitCoreErrorCode;
|
|
485
|
+
context: Record<string, any>;
|
|
486
|
+
}) => void | Promise<void>;
|
|
487
|
+
}
|
|
488
|
+
interface CopilotKitCoreSubscription {
|
|
489
|
+
unsubscribe: () => void;
|
|
490
|
+
}
|
|
491
|
+
declare enum CopilotKitCoreRuntimeConnectionStatus {
|
|
492
|
+
Disconnected = "disconnected",
|
|
493
|
+
Connected = "connected",
|
|
494
|
+
Connecting = "connecting",
|
|
495
|
+
Error = "error"
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Internal interface for delegate classes to access CopilotKitCore methods.
|
|
499
|
+
* This provides type safety while allowing controlled access to private functionality.
|
|
500
|
+
*/
|
|
501
|
+
interface CopilotKitCoreFriendsAccess {
|
|
502
|
+
notifySubscribers(handler: (subscriber: CopilotKitCoreSubscriber) => void | Promise<void>, errorMessage: string): Promise<void>;
|
|
503
|
+
emitError(params: {
|
|
504
|
+
error: Error;
|
|
505
|
+
code: CopilotKitCoreErrorCode;
|
|
506
|
+
context?: Record<string, any>;
|
|
507
|
+
}): Promise<void>;
|
|
508
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
509
|
+
readonly credentials: RequestCredentials | undefined;
|
|
510
|
+
readonly properties: Readonly<Record<string, unknown>>;
|
|
511
|
+
readonly context: Readonly<Record<string, Context>>;
|
|
512
|
+
buildFrontendTools(agentId?: string): _ag_ui_client0.Tool[];
|
|
513
|
+
getAgent(id: string): AbstractAgent | undefined;
|
|
514
|
+
readonly suggestionEngine: {
|
|
515
|
+
clearSuggestions(agentId: string): void;
|
|
516
|
+
reloadSuggestions(agentId: string): void;
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* Called before each follow-up agent run (after tool execution).
|
|
520
|
+
* See CopilotKitCore.waitForPendingFrameworkUpdates for details.
|
|
521
|
+
*/
|
|
522
|
+
waitForPendingFrameworkUpdates(): Promise<void>;
|
|
523
|
+
}
|
|
524
|
+
declare class CopilotKitCore {
|
|
525
|
+
private _headers;
|
|
526
|
+
private _credentials?;
|
|
527
|
+
private _properties;
|
|
528
|
+
private subscribers;
|
|
529
|
+
private agentRegistry;
|
|
530
|
+
private contextStore;
|
|
531
|
+
private suggestionEngine;
|
|
532
|
+
private runHandler;
|
|
533
|
+
private stateManager;
|
|
534
|
+
constructor({
|
|
535
|
+
runtimeUrl,
|
|
536
|
+
runtimeTransport,
|
|
537
|
+
headers,
|
|
538
|
+
credentials,
|
|
539
|
+
properties,
|
|
540
|
+
agents__unsafe_dev_only,
|
|
541
|
+
tools,
|
|
542
|
+
suggestionsConfig
|
|
543
|
+
}: CopilotKitCoreConfig);
|
|
544
|
+
/**
|
|
545
|
+
* Internal method used by delegate classes and subclasses to notify subscribers
|
|
546
|
+
*/
|
|
547
|
+
protected notifySubscribers(handler: (subscriber: CopilotKitCoreSubscriber) => void | Promise<void>, errorMessage: string): Promise<void>;
|
|
548
|
+
/**
|
|
549
|
+
* Internal method used by delegate classes to emit errors
|
|
550
|
+
*/
|
|
551
|
+
private emitError;
|
|
552
|
+
/**
|
|
553
|
+
* Snapshot accessors
|
|
554
|
+
*/
|
|
555
|
+
get context(): Readonly<Record<string, Context>>;
|
|
556
|
+
get agents(): Readonly<Record<string, AbstractAgent>>;
|
|
557
|
+
get tools(): Readonly<FrontendTool<any>[]>;
|
|
558
|
+
get runtimeUrl(): string | undefined;
|
|
559
|
+
setRuntimeUrl(runtimeUrl: string | undefined): void;
|
|
560
|
+
get runtimeTransport(): CopilotRuntimeTransport;
|
|
561
|
+
setRuntimeTransport(runtimeTransport: CopilotRuntimeTransport): void;
|
|
562
|
+
get runtimeVersion(): string | undefined;
|
|
563
|
+
get headers(): Readonly<Record<string, string>>;
|
|
564
|
+
get credentials(): RequestCredentials | undefined;
|
|
565
|
+
get properties(): Readonly<Record<string, unknown>>;
|
|
566
|
+
get runtimeConnectionStatus(): CopilotKitCoreRuntimeConnectionStatus;
|
|
567
|
+
get audioFileTranscriptionEnabled(): boolean;
|
|
568
|
+
get runtimeMode(): RuntimeMode;
|
|
569
|
+
get intelligence(): IntelligenceRuntimeInfo | undefined;
|
|
570
|
+
get a2uiEnabled(): boolean;
|
|
571
|
+
get licenseStatus(): RuntimeLicenseStatus | undefined;
|
|
572
|
+
/**
|
|
573
|
+
* Configuration updates
|
|
574
|
+
*/
|
|
575
|
+
setHeaders(headers: Record<string, string>): void;
|
|
576
|
+
setCredentials(credentials: RequestCredentials | undefined): void;
|
|
577
|
+
setProperties(properties: Record<string, unknown>): void;
|
|
578
|
+
/**
|
|
579
|
+
* Agent management (delegated to AgentRegistry)
|
|
580
|
+
*/
|
|
581
|
+
setAgents__unsafe_dev_only(agents: Record<string, AbstractAgent>): void;
|
|
582
|
+
addAgent__unsafe_dev_only(params: CopilotKitCoreAddAgentParams): void;
|
|
583
|
+
removeAgent__unsafe_dev_only(id: string): void;
|
|
584
|
+
getAgent(id: string): AbstractAgent | undefined;
|
|
585
|
+
/**
|
|
586
|
+
* Context management (delegated to ContextStore)
|
|
587
|
+
*/
|
|
588
|
+
addContext(context: Context): string;
|
|
589
|
+
removeContext(id: string): void;
|
|
590
|
+
/**
|
|
591
|
+
* Suggestions management (delegated to SuggestionEngine)
|
|
592
|
+
*/
|
|
593
|
+
addSuggestionsConfig(config: SuggestionsConfig): string;
|
|
594
|
+
removeSuggestionsConfig(id: string): void;
|
|
595
|
+
reloadSuggestions(agentId: string): void;
|
|
596
|
+
clearSuggestions(agentId: string): void;
|
|
597
|
+
getSuggestions(agentId: string): CopilotKitCoreGetSuggestionsResult;
|
|
598
|
+
/**
|
|
599
|
+
* Tool management (delegated to RunHandler)
|
|
600
|
+
*/
|
|
601
|
+
addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
|
|
602
|
+
removeTool(id: string, agentId?: string): void;
|
|
603
|
+
getTool(params: CopilotKitCoreGetToolParams): FrontendTool<any> | undefined;
|
|
604
|
+
setTools(tools: FrontendTool<any>[]): void;
|
|
605
|
+
/**
|
|
606
|
+
* Subscription lifecycle
|
|
607
|
+
*/
|
|
608
|
+
subscribe(subscriber: CopilotKitCoreSubscriber): CopilotKitCoreSubscription;
|
|
609
|
+
/**
|
|
610
|
+
* Agent connectivity (delegated to RunHandler)
|
|
611
|
+
*/
|
|
612
|
+
connectAgent(params: CopilotKitCoreConnectAgentParams): Promise<_ag_ui_client0.RunAgentResult>;
|
|
613
|
+
stopAgent(params: CopilotKitCoreStopAgentParams): void;
|
|
614
|
+
runAgent(params: CopilotKitCoreRunAgentParams): Promise<_ag_ui_client0.RunAgentResult>;
|
|
615
|
+
/**
|
|
616
|
+
* Programmatically execute a registered frontend tool without going through an LLM turn.
|
|
617
|
+
* The handler runs, render components show up in the UI, and both the tool call and
|
|
618
|
+
* result messages are added to `agent.messages`.
|
|
619
|
+
*/
|
|
620
|
+
runTool(params: CopilotKitCoreRunToolParams): Promise<CopilotKitCoreRunToolResult>;
|
|
621
|
+
/**
|
|
622
|
+
* State management (delegated to StateManager)
|
|
623
|
+
*/
|
|
624
|
+
getStateByRun(agentId: string, threadId: string, runId: string): State | undefined;
|
|
625
|
+
getRunIdForMessage(agentId: string, threadId: string, messageId: string): string | undefined;
|
|
626
|
+
getRunIdsForThread(agentId: string, threadId: string): string[];
|
|
627
|
+
/**
|
|
628
|
+
* Internal method used by RunHandler to build frontend tools
|
|
629
|
+
*/
|
|
630
|
+
private buildFrontendTools;
|
|
631
|
+
/**
|
|
632
|
+
* Called before each follow-up agent run (after tool execution).
|
|
633
|
+
*
|
|
634
|
+
* When a frontend tool handler calls framework state setters (e.g. React's
|
|
635
|
+
* setState), those updates are batched and deferred — they do not take effect
|
|
636
|
+
* until the framework's scheduler runs (React uses MessageChannel).
|
|
637
|
+
* useAgentContext registers context via useLayoutEffect, which runs
|
|
638
|
+
* synchronously after React commits that deferred batch.
|
|
639
|
+
*
|
|
640
|
+
* Without yielding here, the follow-up runAgent reads the context store
|
|
641
|
+
* synchronously while the deferred updates are still pending, producing stale
|
|
642
|
+
* context for the next agent turn.
|
|
643
|
+
*
|
|
644
|
+
* Override in framework-specific subclasses to yield to the framework
|
|
645
|
+
* scheduler before the follow-up run. The base implementation is a no-op
|
|
646
|
+
* because non-React environments have no deferred state to flush.
|
|
647
|
+
*/
|
|
648
|
+
waitForPendingFrameworkUpdates(): Promise<void>;
|
|
649
|
+
}
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/core/context-store.d.ts
|
|
652
|
+
/**
|
|
653
|
+
* Manages context storage and lifecycle for CopilotKitCore.
|
|
654
|
+
* Context represents additional information available to agents during execution.
|
|
655
|
+
*/
|
|
656
|
+
declare class ContextStore {
|
|
657
|
+
private core;
|
|
658
|
+
private _context;
|
|
659
|
+
constructor(core: CopilotKitCore);
|
|
660
|
+
/**
|
|
661
|
+
* Get all context entries as a readonly record
|
|
662
|
+
*/
|
|
663
|
+
get context(): Readonly<Record<string, Context>>;
|
|
664
|
+
/**
|
|
665
|
+
* Add a new context entry
|
|
666
|
+
* @returns The ID of the created context entry
|
|
667
|
+
*/
|
|
668
|
+
addContext({
|
|
669
|
+
description,
|
|
670
|
+
value
|
|
671
|
+
}: Context): string;
|
|
672
|
+
/**
|
|
673
|
+
* Remove a context entry by ID
|
|
674
|
+
*/
|
|
675
|
+
removeContext(id: string): void;
|
|
676
|
+
/**
|
|
677
|
+
* Notify all subscribers of context changes
|
|
678
|
+
*/
|
|
679
|
+
private notifySubscribers;
|
|
680
|
+
}
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/core/suggestion-engine.d.ts
|
|
683
|
+
/**
|
|
684
|
+
* Manages suggestion generation, streaming, and lifecycle for CopilotKitCore.
|
|
685
|
+
* Handles both dynamic (AI-generated) and static suggestions.
|
|
686
|
+
*/
|
|
687
|
+
declare class SuggestionEngine {
|
|
688
|
+
private core;
|
|
689
|
+
private _suggestionsConfig;
|
|
690
|
+
private _suggestions;
|
|
691
|
+
private _runningSuggestions;
|
|
692
|
+
constructor(core: CopilotKitCore);
|
|
693
|
+
/**
|
|
694
|
+
* Initialize with suggestion configs
|
|
695
|
+
*/
|
|
696
|
+
initialize(suggestionsConfig: SuggestionsConfig[]): void;
|
|
697
|
+
/**
|
|
698
|
+
* Add a suggestion configuration
|
|
699
|
+
* @returns The ID of the created config
|
|
700
|
+
*/
|
|
701
|
+
addSuggestionsConfig(config: SuggestionsConfig): string;
|
|
702
|
+
/**
|
|
703
|
+
* Remove a suggestion configuration by ID
|
|
704
|
+
*/
|
|
705
|
+
removeSuggestionsConfig(id: string): void;
|
|
706
|
+
/**
|
|
707
|
+
* Reload suggestions for a specific agent
|
|
708
|
+
* This triggers generation of new suggestions based on current configs
|
|
709
|
+
*/
|
|
710
|
+
reloadSuggestions(agentId: string): void;
|
|
711
|
+
/**
|
|
712
|
+
* Clear all suggestions for a specific agent
|
|
713
|
+
*/
|
|
714
|
+
clearSuggestions(agentId: string): void;
|
|
715
|
+
/**
|
|
716
|
+
* Get current suggestions for an agent
|
|
717
|
+
*/
|
|
718
|
+
getSuggestions(agentId: string): CopilotKitCoreGetSuggestionsResult;
|
|
719
|
+
/**
|
|
720
|
+
* Generate suggestions using a provider agent
|
|
721
|
+
*/
|
|
722
|
+
private generateSuggestions;
|
|
723
|
+
/**
|
|
724
|
+
* Finalize suggestions by marking them as no longer loading
|
|
725
|
+
*/
|
|
726
|
+
private finalizeSuggestions;
|
|
727
|
+
/**
|
|
728
|
+
* Extract suggestions from messages (called during streaming)
|
|
729
|
+
*/
|
|
730
|
+
extractSuggestions(messages: Message[], suggestionId: string, consumerAgentId: string, isRunning: boolean): void;
|
|
731
|
+
/**
|
|
732
|
+
* Notify subscribers of suggestions config changes
|
|
733
|
+
*/
|
|
734
|
+
private notifySuggestionsConfigChanged;
|
|
735
|
+
/**
|
|
736
|
+
* Notify subscribers of suggestions changes
|
|
737
|
+
*/
|
|
738
|
+
private notifySuggestionsChanged;
|
|
739
|
+
/**
|
|
740
|
+
* Notify subscribers that suggestions started loading
|
|
741
|
+
*/
|
|
742
|
+
private notifySuggestionsStartedLoading;
|
|
743
|
+
/**
|
|
744
|
+
* Notify subscribers that suggestions finished loading
|
|
745
|
+
*/
|
|
746
|
+
private notifySuggestionsFinishedLoading;
|
|
747
|
+
/**
|
|
748
|
+
* Check if suggestions should be shown based on availability and message count
|
|
749
|
+
*/
|
|
750
|
+
private shouldShowSuggestions;
|
|
751
|
+
/**
|
|
752
|
+
* Add static suggestions directly without AI generation
|
|
753
|
+
*/
|
|
754
|
+
private addStaticSuggestions;
|
|
755
|
+
}
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/core/state-manager.d.ts
|
|
758
|
+
/**
|
|
759
|
+
* Manages state and message tracking by run for CopilotKitCore.
|
|
760
|
+
* Tracks agent state snapshots and message-to-run associations.
|
|
761
|
+
*/
|
|
762
|
+
declare class StateManager {
|
|
763
|
+
private core;
|
|
764
|
+
private stateByRun;
|
|
765
|
+
private messageToRun;
|
|
766
|
+
private agentSubscriptions;
|
|
767
|
+
constructor(core: CopilotKitCore);
|
|
768
|
+
/**
|
|
769
|
+
* Initialize state tracking for an agent
|
|
770
|
+
*/
|
|
771
|
+
initialize(): void;
|
|
772
|
+
/**
|
|
773
|
+
* Subscribe to an agent's events to track state and messages
|
|
774
|
+
*/
|
|
775
|
+
subscribeToAgent(agent: AbstractAgent): void;
|
|
776
|
+
/**
|
|
777
|
+
* Unsubscribe from an agent's events
|
|
778
|
+
*/
|
|
779
|
+
unsubscribeFromAgent(agentId: string): void;
|
|
780
|
+
/**
|
|
781
|
+
* Get state for a specific run
|
|
782
|
+
* Returns a deep copy to prevent external mutations
|
|
783
|
+
*/
|
|
784
|
+
getStateByRun(agentId: string, threadId: string, runId: string): State | undefined;
|
|
785
|
+
/**
|
|
786
|
+
* Get runId associated with a message
|
|
787
|
+
*/
|
|
788
|
+
getRunIdForMessage(agentId: string, threadId: string, messageId: string): string | undefined;
|
|
789
|
+
/**
|
|
790
|
+
* Get all states for an agent's thread
|
|
791
|
+
*/
|
|
792
|
+
getStatesForThread(agentId: string, threadId: string): Map<string, State>;
|
|
793
|
+
/**
|
|
794
|
+
* Get all run IDs for an agent's thread
|
|
795
|
+
*/
|
|
796
|
+
getRunIdsForThread(agentId: string, threadId: string): string[];
|
|
797
|
+
/**
|
|
798
|
+
* Handle run started event
|
|
799
|
+
*/
|
|
800
|
+
private handleRunStarted;
|
|
801
|
+
/**
|
|
802
|
+
* Handle run finished event
|
|
803
|
+
*/
|
|
804
|
+
private handleRunFinished;
|
|
805
|
+
/**
|
|
806
|
+
* Handle state snapshot event
|
|
807
|
+
*/
|
|
808
|
+
private handleStateSnapshot;
|
|
809
|
+
/**
|
|
810
|
+
* Handle state delta event
|
|
811
|
+
*/
|
|
812
|
+
private handleStateDelta;
|
|
813
|
+
/**
|
|
814
|
+
* Handle messages snapshot event
|
|
815
|
+
*/
|
|
816
|
+
private handleMessagesSnapshot;
|
|
817
|
+
/**
|
|
818
|
+
* Handle new message event
|
|
819
|
+
*/
|
|
820
|
+
private handleNewMessage;
|
|
821
|
+
/**
|
|
822
|
+
* Save state for a specific run
|
|
823
|
+
*/
|
|
824
|
+
private saveState;
|
|
825
|
+
/**
|
|
826
|
+
* Associate a message with a run
|
|
827
|
+
*/
|
|
828
|
+
private associateMessageWithRun;
|
|
829
|
+
/**
|
|
830
|
+
* Clear all state for an agent
|
|
831
|
+
*/
|
|
832
|
+
clearAgentState(agentId: string): void;
|
|
833
|
+
/**
|
|
834
|
+
* Clear all state for a thread
|
|
835
|
+
*/
|
|
836
|
+
clearThreadState(agentId: string, threadId: string): void;
|
|
837
|
+
}
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region src/agent.d.ts
|
|
840
|
+
type ResolvedRuntimeMode = RuntimeMode$1 | "pending";
|
|
841
|
+
interface ProxiedCopilotRuntimeAgentConfig extends Omit<HttpAgentConfig, "url"> {
|
|
842
|
+
runtimeUrl?: string;
|
|
843
|
+
transport?: CopilotRuntimeTransport;
|
|
844
|
+
credentials?: RequestCredentials;
|
|
845
|
+
runtimeMode?: ResolvedRuntimeMode;
|
|
846
|
+
intelligence?: IntelligenceRuntimeInfo$1;
|
|
847
|
+
}
|
|
848
|
+
declare class ProxiedCopilotRuntimeAgent extends HttpAgent {
|
|
849
|
+
#private;
|
|
850
|
+
runtimeUrl?: string;
|
|
851
|
+
credentials?: RequestCredentials;
|
|
852
|
+
private transport;
|
|
853
|
+
private singleEndpointUrl?;
|
|
854
|
+
private runtimeMode;
|
|
855
|
+
private intelligence?;
|
|
856
|
+
private delegate?;
|
|
857
|
+
private runtimeInfoPromise?;
|
|
858
|
+
constructor(config: ProxiedCopilotRuntimeAgentConfig);
|
|
859
|
+
detachActiveRun(): Promise<void>;
|
|
860
|
+
abortRun(): void;
|
|
861
|
+
connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
|
|
862
|
+
connect(input: RunAgentInput): Observable<BaseEvent>;
|
|
863
|
+
run(input: RunAgentInput): Observable<BaseEvent>;
|
|
864
|
+
clone(): ProxiedCopilotRuntimeAgent;
|
|
865
|
+
private resolveDelegate;
|
|
866
|
+
private ensureRuntimeMode;
|
|
867
|
+
private fetchRuntimeInfo;
|
|
868
|
+
private createSingleRouteRequestInit;
|
|
869
|
+
private createIntelligenceDelegate;
|
|
870
|
+
private syncDelegate;
|
|
871
|
+
}
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region src/utils/markdown.d.ts
|
|
874
|
+
declare function completePartialMarkdown(input: string): string;
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region src/intelligence-agent.d.ts
|
|
877
|
+
interface IntelligenceAgentSharedState {
|
|
878
|
+
lastSeenEventIds: Map<string, string>;
|
|
879
|
+
}
|
|
880
|
+
declare class AgentThreadLockedError extends Error {
|
|
881
|
+
constructor(threadId?: string);
|
|
882
|
+
}
|
|
883
|
+
interface IntelligenceAgentConfig {
|
|
884
|
+
/** Phoenix websocket URL, e.g. "ws://localhost:4000/socket" */
|
|
885
|
+
url: string;
|
|
886
|
+
/** Runtime REST URL, e.g. "http://localhost:4000" */
|
|
887
|
+
runtimeUrl: string;
|
|
888
|
+
/** Agent identifier for REST endpoints */
|
|
889
|
+
agentId: string;
|
|
890
|
+
/** Optional params sent on socket connect (e.g. auth token) */
|
|
891
|
+
socketParams?: Record<string, string>;
|
|
892
|
+
/** Optional headers sent with REST requests */
|
|
893
|
+
headers?: Record<string, string>;
|
|
894
|
+
/** Optional credentials mode for fetch requests */
|
|
895
|
+
credentials?: RequestCredentials;
|
|
896
|
+
}
|
|
897
|
+
declare class IntelligenceAgent extends AbstractAgent {
|
|
898
|
+
private config;
|
|
899
|
+
private socket;
|
|
900
|
+
private activeChannel;
|
|
901
|
+
private runId;
|
|
902
|
+
private sharedState;
|
|
903
|
+
constructor(config: IntelligenceAgentConfig, sharedState?: IntelligenceAgentSharedState);
|
|
904
|
+
clone(): IntelligenceAgent;
|
|
905
|
+
/**
|
|
906
|
+
* Override of AbstractAgent.connectAgent that removes the `verifyEvents` step.
|
|
907
|
+
*
|
|
908
|
+
* Background: AbstractAgent's connectAgent pipeline runs events through
|
|
909
|
+
* `verifyEvents`, which validates that the stream follows the AG-UI protocol
|
|
910
|
+
* lifecycle — specifically, it expects a RUN_STARTED event before any content
|
|
911
|
+
* events and a RUN_FINISHED/RUN_ERROR event to complete the stream.
|
|
912
|
+
*
|
|
913
|
+
* IntelligenceAgent uses long-lived WebSocket connections rather than
|
|
914
|
+
* request-scoped SSE streams. When connecting to replay historical messages
|
|
915
|
+
* for an existing thread, the connection semantics don't map to a single
|
|
916
|
+
* agent run start/stop cycle. The replayed events may not include
|
|
917
|
+
* RUN_STARTED/RUN_FINISHED bookends (or may contain events from multiple
|
|
918
|
+
* past runs), which causes verifyEvents to either never complete or to
|
|
919
|
+
* error out.
|
|
920
|
+
*
|
|
921
|
+
* This override replicates the base connectAgent implementation exactly,
|
|
922
|
+
* substituting only `transformChunks` (which is still needed for message
|
|
923
|
+
* reassembly) and omitting `verifyEvents`.
|
|
924
|
+
*
|
|
925
|
+
* TODO: Remove this override once AG-UI's AbstractAgent supports opting out
|
|
926
|
+
* of verifyEvents for transports with different connection life-cycles.
|
|
927
|
+
*/
|
|
928
|
+
connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
|
|
929
|
+
abortRun(): void;
|
|
930
|
+
/**
|
|
931
|
+
* Trigger the run via REST, then join the realtime thread channel and relay
|
|
932
|
+
* server-pushed AG-UI events to the Observable subscriber.
|
|
933
|
+
*/
|
|
934
|
+
run(input: RunAgentInput): Observable<BaseEvent>;
|
|
935
|
+
/**
|
|
936
|
+
* Reconnect to an existing thread by fetching websocket credentials and
|
|
937
|
+
* joining the realtime thread channel.
|
|
938
|
+
*/
|
|
939
|
+
protected connect(input: RunAgentInput): Observable<BaseEvent>;
|
|
940
|
+
/**
|
|
941
|
+
* Tear down a specific channel + socket pair that belongs to one pipeline.
|
|
942
|
+
* Only nulls instance references when they still point to the owned resource,
|
|
943
|
+
* so a concurrent pipeline's resources are never clobbered.
|
|
944
|
+
*/
|
|
945
|
+
private cleanupOwned;
|
|
946
|
+
private cleanup;
|
|
947
|
+
private requestJoinCredentials$;
|
|
948
|
+
private requestConnectPlan$;
|
|
949
|
+
private normalizeConnectPlan;
|
|
950
|
+
private observeThread$;
|
|
951
|
+
private joinThreadChannel$;
|
|
952
|
+
private observeSocketHealth$;
|
|
953
|
+
private observeThreadEvents$;
|
|
954
|
+
private observeChannelEvent$;
|
|
955
|
+
private createThreadNotifications;
|
|
956
|
+
private buildRuntimeUrl;
|
|
957
|
+
private createThreadChannelDescriptor;
|
|
958
|
+
private getLastSeenEventId;
|
|
959
|
+
private getReconnectCursor;
|
|
960
|
+
private hasLocalThreadMessages;
|
|
961
|
+
private updateLastSeenEventId;
|
|
962
|
+
private setLastSeenEventId;
|
|
963
|
+
/**
|
|
964
|
+
* Keep `this.runId` in sync with the backend's actual run ID.
|
|
965
|
+
*
|
|
966
|
+
* During a `connect` (resume) flow the client generates a fresh `runId`
|
|
967
|
+
* via `prepareRunAgentInput`, but the backend is running under its own
|
|
968
|
+
* run ID. If the client later sends `STOP_RUN_EVENT` with the wrong
|
|
969
|
+
* `runId`, the gateway's runner channel will not match it and the agent
|
|
970
|
+
* keeps running. Extracting the run ID from live events fixes this.
|
|
971
|
+
*
|
|
972
|
+
* The runner normalises events to `run_id` (snake_case) before pushing
|
|
973
|
+
* to the gateway, so we check both `runId` and `run_id`.
|
|
974
|
+
*/
|
|
975
|
+
private updateRunIdFromEvent;
|
|
976
|
+
private readEventId;
|
|
977
|
+
}
|
|
978
|
+
//#endregion
|
|
979
|
+
//#region src/utils/micro-redux.d.ts
|
|
980
|
+
/**
|
|
981
|
+
* The minimal action shape used by this micro-redux implementation.
|
|
982
|
+
*/
|
|
983
|
+
interface AnyAction {
|
|
984
|
+
type: string;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* A typed action creator function with a `type` literal and runtime matcher.
|
|
988
|
+
*/
|
|
989
|
+
type ActionCreator<Type extends string, Args extends unknown[] = unknown[], Action extends AnyAction & {
|
|
990
|
+
type: Type;
|
|
991
|
+
} = {
|
|
992
|
+
type: Type;
|
|
993
|
+
}> = ((...args: Args) => Action) & {
|
|
994
|
+
type: Type;
|
|
995
|
+
match(action: AnyAction): action is Action;
|
|
996
|
+
};
|
|
997
|
+
/**
|
|
998
|
+
* Extracts the action type produced by an action creator.
|
|
999
|
+
*/
|
|
1000
|
+
type ActionFromCreator<T> = T extends ((...args: any[]) => infer A) ? A : never;
|
|
1001
|
+
/**
|
|
1002
|
+
* Extracts a union of actions produced by a tuple/array of action creators.
|
|
1003
|
+
*/
|
|
1004
|
+
type ActionFromCreators<Creators extends readonly ActionCreator<string, any[], any>[]> = ActionFromCreator<Creators[number]>;
|
|
1005
|
+
/**
|
|
1006
|
+
* A reducer transforms state in response to actions.
|
|
1007
|
+
*/
|
|
1008
|
+
type Reducer<State, Action extends AnyAction = AnyAction> = (state: State | undefined, action: Action) => State;
|
|
1009
|
+
/**
|
|
1010
|
+
* A selector derives a value from state.
|
|
1011
|
+
*/
|
|
1012
|
+
type Selector<State, Result> = (state: State) => Result;
|
|
1013
|
+
/**
|
|
1014
|
+
* Marker config for action creators that accept no payload.
|
|
1015
|
+
*/
|
|
1016
|
+
interface EmptyActionConfig {
|
|
1017
|
+
readonly kind: "empty";
|
|
1018
|
+
}
|
|
1019
|
+
declare const PROPS_MARKER: unique symbol;
|
|
1020
|
+
/**
|
|
1021
|
+
* Marker config for action creators that require payload props.
|
|
1022
|
+
*/
|
|
1023
|
+
interface PropsActionConfig<Props extends Record<string, unknown>> {
|
|
1024
|
+
readonly kind: "props";
|
|
1025
|
+
readonly [PROPS_MARKER]?: Props;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Supported action creator config node in an action group.
|
|
1029
|
+
*/
|
|
1030
|
+
type ActionConfig = EmptyActionConfig | PropsActionConfig<Record<string, unknown>>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Shape of an action group declaration object.
|
|
1033
|
+
*/
|
|
1034
|
+
type ActionGroupConfig = Record<string, ActionConfig>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Maps an action group declaration to a strongly typed action-creator object.
|
|
1037
|
+
*/
|
|
1038
|
+
type ActionGroupResult<Source extends string, Config extends ActionGroupConfig> = { [K in keyof Config & string]: Config[K] extends PropsActionConfig<infer P> ? ActionCreator<`[${Source}] ${K}`, [P], {
|
|
1039
|
+
type: `[${Source}] ${K}`;
|
|
1040
|
+
} & P> : ActionCreator<`[${Source}] ${K}`, [], {
|
|
1041
|
+
type: `[${Source}] ${K}`;
|
|
1042
|
+
}> };
|
|
1043
|
+
interface OnReducerEntry<State, Action extends AnyAction = AnyAction, Creators extends readonly ActionCreator<string, any[], any>[] = readonly ActionCreator<string, any[], any>[]> {
|
|
1044
|
+
creators: Creators;
|
|
1045
|
+
reducer: (state: State, action: Action) => State;
|
|
1046
|
+
}
|
|
1047
|
+
type ActionFromOnReducerEntry<TEntry> = TEntry extends OnReducerEntry<any, infer TAction, any> ? TAction : never;
|
|
1048
|
+
/**
|
|
1049
|
+
* Effect contract for streams that emit actions to dispatch.
|
|
1050
|
+
*/
|
|
1051
|
+
interface DispatchingEffect<State, InputAction extends AnyAction = AnyAction, OutputAction extends AnyAction = AnyAction> {
|
|
1052
|
+
run: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<OutputAction>;
|
|
1053
|
+
dispatch: true;
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Effect contract for side-effect-only streams whose emissions are ignored.
|
|
1057
|
+
*/
|
|
1058
|
+
interface NonDispatchingEffect<State, InputAction extends AnyAction = AnyAction> {
|
|
1059
|
+
run: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<unknown>;
|
|
1060
|
+
dispatch: false;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Union of supported effect shapes.
|
|
1064
|
+
*/
|
|
1065
|
+
type Effect<State, InputAction extends AnyAction = AnyAction, OutputAction extends AnyAction = AnyAction> = DispatchingEffect<State, InputAction, OutputAction> | NonDispatchingEffect<State, InputAction>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Lifecycle actions dispatched by the store.
|
|
1068
|
+
*/
|
|
1069
|
+
type StoreLifecycleAction = {
|
|
1070
|
+
type: "@@micro-redux/init";
|
|
1071
|
+
} | {
|
|
1072
|
+
type: "@@micro-redux/stop";
|
|
1073
|
+
};
|
|
1074
|
+
/**
|
|
1075
|
+
* Options for a dispatching effect.
|
|
1076
|
+
*/
|
|
1077
|
+
interface DispatchingEffectOptions {
|
|
1078
|
+
dispatch?: true;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Options for a non-dispatching effect.
|
|
1082
|
+
*/
|
|
1083
|
+
interface NonDispatchingEffectOptions {
|
|
1084
|
+
dispatch: false;
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Declares a payload-based action config for `createActionGroup`.
|
|
1088
|
+
*
|
|
1089
|
+
* @example
|
|
1090
|
+
* ```ts
|
|
1091
|
+
* const actions = createActionGroup("User", {
|
|
1092
|
+
* loaded: props<{ id: string }>(),
|
|
1093
|
+
* });
|
|
1094
|
+
* ```
|
|
1095
|
+
*/
|
|
1096
|
+
declare function props<Props extends Record<string, unknown>>(): PropsActionConfig<Props>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Declares a no-payload action config for `createActionGroup`.
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* const actions = createActionGroup("User", {
|
|
1103
|
+
* reset: empty(),
|
|
1104
|
+
* });
|
|
1105
|
+
* ```
|
|
1106
|
+
*/
|
|
1107
|
+
declare function empty(): EmptyActionConfig;
|
|
1108
|
+
/**
|
|
1109
|
+
* Creates a namespaced group of typed action creators.
|
|
1110
|
+
*
|
|
1111
|
+
* Action types are formatted as: `[Source] actionName`.
|
|
1112
|
+
*/
|
|
1113
|
+
declare function createActionGroup<const Source extends string, const Config extends ActionGroupConfig>(source: Source, config: Config): ActionGroupResult<Source, Config>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Registers one reducer handler for one or more action creators.
|
|
1116
|
+
*
|
|
1117
|
+
* @throws Error when called without at least one action creator and reducer.
|
|
1118
|
+
*/
|
|
1119
|
+
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>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Creates a reducer from an initial state and `on(...)` handler entries.
|
|
1122
|
+
*
|
|
1123
|
+
* Unknown action types return the current state unchanged.
|
|
1124
|
+
*/
|
|
1125
|
+
declare function createReducer<State, const Entries extends readonly OnReducerEntry<any, any, any>[]>(initialState: State, ...entries: Entries): Reducer<State, ActionFromOnReducerEntry<Entries[number]>>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Creates a memoized selector from a single projector.
|
|
1128
|
+
*/
|
|
1129
|
+
declare function createSelector<State, Result>(projector: (state: State) => Result): Selector<State, Result>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Creates a memoized selector from input selectors and a projector.
|
|
1132
|
+
*
|
|
1133
|
+
* Memoization uses one-entry caching over the latest input selector values.
|
|
1134
|
+
*/
|
|
1135
|
+
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>;
|
|
1136
|
+
/**
|
|
1137
|
+
* RxJS operator that maps state emissions through a selector and suppresses
|
|
1138
|
+
* unchanged projected values via reference equality.
|
|
1139
|
+
*/
|
|
1140
|
+
declare function select<State, Result>(selector: Selector<State, Result>): OperatorFunction<State, Result>;
|
|
1141
|
+
/**
|
|
1142
|
+
* RxJS operator that filters an action stream by action creators and narrows
|
|
1143
|
+
* the output action type to the matched creator union.
|
|
1144
|
+
*
|
|
1145
|
+
* @throws Error when called without at least one action creator.
|
|
1146
|
+
*/
|
|
1147
|
+
declare function ofType<const Creators extends readonly ActionCreator<string, any[], AnyAction>[]>(...creators: Creators): OperatorFunction<AnyAction, ActionFromCreators<Creators>>;
|
|
1148
|
+
/**
|
|
1149
|
+
* Creates a dispatching effect. Emitted actions are automatically dispatched.
|
|
1150
|
+
*/
|
|
1151
|
+
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>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Creates a non-dispatching effect. Emitted values are ignored.
|
|
1154
|
+
*/
|
|
1155
|
+
declare function createEffect<State, InputAction extends AnyAction>(factory: (actions$: Observable<InputAction>, state$: Observable<State>) => Observable<unknown>, options: NonDispatchingEffectOptions): NonDispatchingEffect<State, InputAction>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Store interface returned by `createStore`.
|
|
1158
|
+
*/
|
|
1159
|
+
interface Store<State, Action extends AnyAction = AnyAction> {
|
|
1160
|
+
dispatch(action: Action): void;
|
|
1161
|
+
getState(): State;
|
|
1162
|
+
readonly state$: Observable<State>;
|
|
1163
|
+
readonly actions$: Observable<Action | StoreLifecycleAction>;
|
|
1164
|
+
select<Result>(selector: Selector<State, Result>): Observable<Result>;
|
|
1165
|
+
init(): void;
|
|
1166
|
+
stop(): void;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Creates a small observable store with reducer + effects.
|
|
1170
|
+
*
|
|
1171
|
+
* Behavior:
|
|
1172
|
+
* - `init()` starts effects and dispatches `@@micro-redux/init`.
|
|
1173
|
+
* - `stop()` dispatches `@@micro-redux/stop` and unsubscribes all effects.
|
|
1174
|
+
* - Effect action observation is scheduled on `asapScheduler` to avoid
|
|
1175
|
+
* synchronous re-entrancy in the effect loop.
|
|
1176
|
+
* - Any effect error triggers fail-fast teardown and errors both `actions$`
|
|
1177
|
+
* and `state$`.
|
|
1178
|
+
*/
|
|
1179
|
+
declare function createStore<State, Action extends AnyAction = AnyAction>(options: {
|
|
1180
|
+
reducer: Reducer<State, Action | StoreLifecycleAction>;
|
|
1181
|
+
effects?: Array<Effect<State, Action | StoreLifecycleAction, Action>>;
|
|
1182
|
+
}): Store<State, Action>;
|
|
1183
|
+
//#endregion
|
|
1184
|
+
//#region src/utils/phoenix-observable.d.ts
|
|
1185
|
+
/**
|
|
1186
|
+
* Minimal Phoenix push contract used by the observable adapters.
|
|
1187
|
+
*/
|
|
1188
|
+
interface ɵPhoenixPushLike {
|
|
1189
|
+
receive(status: string, callback: (payload?: unknown) => unknown): unknown;
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Minimal Phoenix channel contract used by the observable adapters.
|
|
1193
|
+
*/
|
|
1194
|
+
interface ɵPhoenixChannelLike {
|
|
1195
|
+
on(event: string, callback: (payload: unknown) => void): number;
|
|
1196
|
+
off(event: string, ref?: number): void;
|
|
1197
|
+
onError?(callback: (reason?: unknown) => void): unknown;
|
|
1198
|
+
join(params?: Record<string, unknown>): ɵPhoenixPushLike;
|
|
1199
|
+
push?(event: string, payload: unknown): ɵPhoenixPushLike;
|
|
1200
|
+
leave(): void;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Minimal Phoenix socket contract used by the observable adapters.
|
|
1204
|
+
*/
|
|
1205
|
+
interface ɵPhoenixSocketLike {
|
|
1206
|
+
connect(): void;
|
|
1207
|
+
disconnect(): void;
|
|
1208
|
+
channel(topic: string, params?: Record<string, unknown>): ɵPhoenixChannelLike;
|
|
1209
|
+
onError(callback: (error?: unknown) => void): unknown;
|
|
1210
|
+
onOpen(callback: () => void): unknown;
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Socket lifecycle notifications exposed by {@link ɵphoenixSocket$}.
|
|
1214
|
+
*/
|
|
1215
|
+
type ɵPhoenixSocketSignal = {
|
|
1216
|
+
type: "open";
|
|
1217
|
+
} | {
|
|
1218
|
+
type: "error";
|
|
1219
|
+
error?: unknown;
|
|
1220
|
+
};
|
|
1221
|
+
/**
|
|
1222
|
+
* Terminal outcomes of a Phoenix channel join attempt.
|
|
1223
|
+
*/
|
|
1224
|
+
type ɵPhoenixJoinOutcome = {
|
|
1225
|
+
type: "joined";
|
|
1226
|
+
} | {
|
|
1227
|
+
type: "error";
|
|
1228
|
+
response?: unknown;
|
|
1229
|
+
} | {
|
|
1230
|
+
type: "timeout";
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* Active Phoenix socket session plus its derived lifecycle stream.
|
|
1234
|
+
*/
|
|
1235
|
+
interface ɵPhoenixSocketSession {
|
|
1236
|
+
socket: ɵPhoenixSocketLike;
|
|
1237
|
+
signals$: Observable<ɵPhoenixSocketSignal>;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Active Phoenix channel session plus its derived join-outcome stream.
|
|
1241
|
+
*/
|
|
1242
|
+
interface ɵPhoenixChannelSession {
|
|
1243
|
+
channel: ɵPhoenixChannelLike;
|
|
1244
|
+
joinOutcome$: Observable<ɵPhoenixJoinOutcome>;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Options for creating a cold Phoenix socket session stream.
|
|
1248
|
+
*/
|
|
1249
|
+
interface ɵPhoenixSocketOptions {
|
|
1250
|
+
url: string;
|
|
1251
|
+
options?: Record<string, unknown>;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Options for creating a cold Phoenix channel session stream from a socket stream.
|
|
1255
|
+
*/
|
|
1256
|
+
interface ɵPhoenixChannelOptions {
|
|
1257
|
+
socket$: Observable<ɵPhoenixSocketSession>;
|
|
1258
|
+
topic: string;
|
|
1259
|
+
params?: Record<string, unknown>;
|
|
1260
|
+
leaveOnUnsubscribe?: boolean;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Create a cold Phoenix socket session.
|
|
1264
|
+
*
|
|
1265
|
+
* The socket is constructed and connected on subscription, and disconnected on
|
|
1266
|
+
* teardown. Each subscription creates an isolated socket instance.
|
|
1267
|
+
*/
|
|
1268
|
+
declare function ɵphoenixSocket$(options: ɵPhoenixSocketOptions): Observable<ɵPhoenixSocketSession>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Create a cold Phoenix channel session from a socket session stream.
|
|
1271
|
+
*
|
|
1272
|
+
* A channel is created and joined for each active socket session. If the
|
|
1273
|
+
* upstream socket session changes, the previous channel is left before the
|
|
1274
|
+
* next one becomes active.
|
|
1275
|
+
*/
|
|
1276
|
+
declare function ɵphoenixChannel$(options: ɵPhoenixChannelOptions): Observable<ɵPhoenixChannelSession>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Observe a named Phoenix channel event as an observable payload stream.
|
|
1279
|
+
*/
|
|
1280
|
+
declare function ɵobservePhoenixEvent$<T>(channel: ɵPhoenixChannelLike, eventName: string): Observable<T>;
|
|
1281
|
+
/**
|
|
1282
|
+
* Flatten channel sessions into their join-outcome stream.
|
|
1283
|
+
*/
|
|
1284
|
+
declare function ɵobservePhoenixJoinOutcome$(channel$: Observable<ɵPhoenixChannelSession>): Observable<ɵPhoenixJoinOutcome>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Complete when a channel joins successfully, or error if the join fails.
|
|
1287
|
+
*/
|
|
1288
|
+
declare function ɵjoinPhoenixChannel$(channel$: Observable<ɵPhoenixChannelSession>): Observable<never>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Flatten socket sessions into their lifecycle signal stream.
|
|
1291
|
+
*/
|
|
1292
|
+
declare function ɵobservePhoenixSocketSignals$(socket$: Observable<ɵPhoenixSocketSession>): Observable<ɵPhoenixSocketSignal>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Error after a socket emits the configured number of consecutive error
|
|
1295
|
+
* signals, resetting the counter after each successful open signal.
|
|
1296
|
+
*/
|
|
1297
|
+
declare function ɵobservePhoenixSocketHealth$(socketSignals$: Observable<ɵPhoenixSocketSignal>, maxConsecutiveErrors: number): Observable<never>;
|
|
1298
|
+
//#endregion
|
|
1299
|
+
//#region src/threads.d.ts
|
|
1300
|
+
interface ThreadRecord {
|
|
1301
|
+
id: string;
|
|
1302
|
+
organizationId: string;
|
|
1303
|
+
agentId: string;
|
|
1304
|
+
createdById: string;
|
|
1305
|
+
name: string | null;
|
|
1306
|
+
archived: boolean;
|
|
1307
|
+
createdAt: string;
|
|
1308
|
+
updatedAt: string;
|
|
1309
|
+
}
|
|
1310
|
+
interface ThreadRuntimeContext {
|
|
1311
|
+
runtimeUrl: string;
|
|
1312
|
+
headers: Record<string, string>;
|
|
1313
|
+
wsUrl?: string;
|
|
1314
|
+
agentId: string;
|
|
1315
|
+
includeArchived?: boolean;
|
|
1316
|
+
limit?: number;
|
|
1317
|
+
}
|
|
1318
|
+
type ThreadMetadataEvent = {
|
|
1319
|
+
operation: "created" | "renamed" | "archived" | "unarchived" | "updated";
|
|
1320
|
+
threadId: string;
|
|
1321
|
+
userId: string;
|
|
1322
|
+
organizationId: string;
|
|
1323
|
+
occurredAt: string;
|
|
1324
|
+
thread: ThreadRecord;
|
|
1325
|
+
} | {
|
|
1326
|
+
operation: "deleted";
|
|
1327
|
+
threadId: string;
|
|
1328
|
+
userId: string;
|
|
1329
|
+
organizationId: string;
|
|
1330
|
+
occurredAt: string;
|
|
1331
|
+
deleted: {
|
|
1332
|
+
id: string;
|
|
1333
|
+
};
|
|
1334
|
+
};
|
|
1335
|
+
interface ThreadEnvironment {
|
|
1336
|
+
fetch: typeof fetch;
|
|
1337
|
+
}
|
|
1338
|
+
interface ThreadState {
|
|
1339
|
+
threads: ThreadRecord[];
|
|
1340
|
+
isLoading: boolean;
|
|
1341
|
+
isFetchingNextPage: boolean;
|
|
1342
|
+
error: Error | null;
|
|
1343
|
+
context: ThreadRuntimeContext | null;
|
|
1344
|
+
sessionId: number;
|
|
1345
|
+
metadataCredentialsRequested: boolean;
|
|
1346
|
+
metadataJoinCode: string | null;
|
|
1347
|
+
nextCursor: string | null;
|
|
1348
|
+
}
|
|
1349
|
+
interface ThreadStore {
|
|
1350
|
+
start(): void;
|
|
1351
|
+
stop(): void;
|
|
1352
|
+
setContext(context: ThreadRuntimeContext | null): void;
|
|
1353
|
+
fetchNextPage(): void;
|
|
1354
|
+
renameThread(threadId: string, name: string): Promise<void>;
|
|
1355
|
+
archiveThread(threadId: string): Promise<void>;
|
|
1356
|
+
deleteThread(threadId: string): Promise<void>;
|
|
1357
|
+
getState(): ThreadState;
|
|
1358
|
+
select: Store<ThreadState>["select"];
|
|
1359
|
+
}
|
|
1360
|
+
declare function createThreadStore(environment: ThreadEnvironment): ThreadStore;
|
|
1361
|
+
type ɵThread = ThreadRecord;
|
|
1362
|
+
type ɵThreadRuntimeContext = ThreadRuntimeContext;
|
|
1363
|
+
type ɵThreadMetadataEvent = ThreadMetadataEvent;
|
|
1364
|
+
type ɵThreadEnvironment = ThreadEnvironment;
|
|
1365
|
+
type ɵThreadStore = ThreadStore;
|
|
1366
|
+
declare const ɵthreadAdapterEvents: any;
|
|
1367
|
+
declare const ɵselectThreads: any;
|
|
1368
|
+
declare const ɵselectThreadsIsLoading: any;
|
|
1369
|
+
declare const ɵselectThreadsError: any;
|
|
1370
|
+
declare const ɵselectHasNextPage: any;
|
|
1371
|
+
declare const ɵselectIsFetchingNextPage: any;
|
|
1372
|
+
//#endregion
|
|
1373
|
+
export { ActionConfig, ActionCreator, ActionFromCreator, ActionFromCreators, ActionGroupConfig, ActionGroupResult, AgentRegistry, AgentThreadLockedError, AnyAction, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, CopilotKitCoreFriendsAccess, CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, 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, RunHandler, type RuntimeLicenseStatus, type RuntimeMode, Selector, StateManager, StaticSuggestionsConfig, Store, StoreLifecycleAction, Suggestion, SuggestionAvailability, SuggestionEngine, SuggestionsConfig, ToolCallStatus, completePartialMarkdown, createActionGroup, createEffect, createReducer, createSelector, createStore, empty, ensureObjectArgs, ofType, on, parseToolArguments, props, select, ɵPhoenixChannelLike, ɵPhoenixChannelOptions, ɵPhoenixChannelSession, ɵPhoenixJoinOutcome, ɵPhoenixPushLike, ɵPhoenixSocketLike, ɵPhoenixSocketOptions, ɵPhoenixSocketSession, ɵPhoenixSocketSignal, ɵThread, ɵThreadEnvironment, ɵThreadMetadataEvent, ɵThreadRuntimeContext, ɵThreadStore, createThreadStore as ɵcreateThreadStore, ɵjoinPhoenixChannel$, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵthreadAdapterEvents };
|
|
1374
|
+
//# sourceMappingURL=index.d.cts.map
|