@copilotkit/react-core 1.61.0 → 1.61.2
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/{copilotkit-BCxdKlMw.mjs → copilotkit-Be-o2UaU.mjs} +262 -128
- package/dist/copilotkit-Be-o2UaU.mjs.map +1 -0
- package/dist/{copilotkit-M1FiciGd.d.mts → copilotkit-Bpt1c_-q.d.mts} +79 -71
- package/dist/copilotkit-Bpt1c_-q.d.mts.map +1 -0
- package/dist/{copilotkit-DtPCrXXd.cjs → copilotkit-CTCjVxkH.cjs} +251 -117
- package/dist/copilotkit-CTCjVxkH.cjs.map +1 -0
- package/dist/{copilotkit-CEdu_aie.d.cts → copilotkit-ClqbUuGX.d.cts} +79 -71
- package/dist/copilotkit-ClqbUuGX.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +188 -96
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.d.cts +5 -1
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +5 -1
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/headless.cjs +219 -102
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +76 -68
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +76 -68
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +220 -103
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +250 -116
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/skills/react-core/references/provider-setup.md +20 -2
- package/dist/copilotkit-BCxdKlMw.mjs.map +0 -1
- package/dist/copilotkit-CEdu_aie.d.cts.map +0 -1
- package/dist/copilotkit-DtPCrXXd.cjs.map +0 -1
- package/dist/copilotkit-M1FiciGd.d.mts.map +0 -1
package/dist/v2/headless.d.cts
CHANGED
|
@@ -2,12 +2,16 @@ import React$1, { ComponentType, ReactNode } from "react";
|
|
|
2
2
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
3
|
import { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus } from "@copilotkit/core";
|
|
4
4
|
import { ActivityMessage, AgentCapabilities, Message } from "@ag-ui/core";
|
|
5
|
-
import { AbstractAgent, RunAgentResult } from "@ag-ui/client";
|
|
5
|
+
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus, RunAgentResult } from "@ag-ui/client";
|
|
6
6
|
|
|
7
7
|
//#region src/v2/types/react-tool-call-renderer.d.ts
|
|
8
8
|
interface ReactToolCallRenderer<T = unknown> {
|
|
9
9
|
name: string;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Schema describing the tool arguments. Optional — renderers registered for
|
|
12
|
+
* tools without parameters (e.g. HITL confirm dialogs) have no schema.
|
|
13
|
+
*/
|
|
14
|
+
args?: StandardSchemaV1<any, T>;
|
|
11
15
|
/**
|
|
12
16
|
* Optional agent ID to constrain this tool renderer to a specific agent.
|
|
13
17
|
* If specified, this renderer will only be used for the specified agent.
|
|
@@ -168,18 +172,49 @@ declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
|
168
172
|
}): ReactToolCallRenderer<InferSchemaOutput<S>>;
|
|
169
173
|
//#endregion
|
|
170
174
|
//#region src/v2/types/interrupt.d.ts
|
|
175
|
+
/** Legacy custom-event interrupt payload (agent emits a custom `on_interrupt` event). */
|
|
171
176
|
interface InterruptEvent<TValue = unknown> {
|
|
172
177
|
name: string;
|
|
173
178
|
value: TValue;
|
|
174
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Resolve the agent with user input for an interrupt.
|
|
182
|
+
*
|
|
183
|
+
* - Standard interrupts: records `{ status: "resolved", payload }` for the target
|
|
184
|
+
* interrupt (defaults to the primary one). Resumes once every open interrupt is
|
|
185
|
+
* addressed; returns the resume run result, or `void` while still awaiting others.
|
|
186
|
+
* - Legacy interrupts: resumes immediately via `command.resume = payload`.
|
|
187
|
+
*/
|
|
188
|
+
type InterruptResolveFn = (payload?: unknown, interruptId?: string) => Promise<RunAgentResult | void>;
|
|
189
|
+
/**
|
|
190
|
+
* Cancel an interrupt.
|
|
191
|
+
*
|
|
192
|
+
* - Standard interrupts: records `{ status: "cancelled" }` for the target interrupt
|
|
193
|
+
* (defaults to the primary one), then resumes once all are addressed.
|
|
194
|
+
* - Legacy interrupts: dismisses the pending interrupt without resuming.
|
|
195
|
+
*/
|
|
196
|
+
type InterruptCancelFn = (interruptId?: string) => Promise<RunAgentResult | void>;
|
|
175
197
|
interface InterruptHandlerProps<TValue = unknown> {
|
|
198
|
+
/**
|
|
199
|
+
* Legacy event shape (`{ name, value }`). Always present for back-compat: for
|
|
200
|
+
* standard interrupts, `value` is the primary `Interrupt` and `name` is `"on_interrupt"`.
|
|
201
|
+
* Prefer `interrupt` / `interrupts` for standard interrupts.
|
|
202
|
+
*/
|
|
176
203
|
event: InterruptEvent<TValue>;
|
|
177
|
-
|
|
204
|
+
/** Primary standard interrupt (`interrupts[0]`), or `null` for legacy interrupts. */
|
|
205
|
+
interrupt: Interrupt | null;
|
|
206
|
+
/** All open standard interrupts (empty array for legacy interrupts). */
|
|
207
|
+
interrupts: Interrupt[];
|
|
208
|
+
resolve: InterruptResolveFn;
|
|
209
|
+
cancel: InterruptCancelFn;
|
|
178
210
|
}
|
|
179
211
|
interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
|
|
180
212
|
event: InterruptEvent<TValue>;
|
|
213
|
+
interrupt: Interrupt | null;
|
|
214
|
+
interrupts: Interrupt[];
|
|
181
215
|
result: TResult;
|
|
182
|
-
resolve:
|
|
216
|
+
resolve: InterruptResolveFn;
|
|
217
|
+
cancel: InterruptCancelFn;
|
|
183
218
|
}
|
|
184
219
|
//#endregion
|
|
185
220
|
//#region src/v2/lib/react-core.d.ts
|
|
@@ -373,7 +408,7 @@ type InferRenderProps<T> = T extends StandardSchemaV1 ? InferSchemaOutput<T> : a
|
|
|
373
408
|
* );
|
|
374
409
|
* ```
|
|
375
410
|
*/
|
|
376
|
-
declare function useComponent<TSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
411
|
+
declare function useComponent<TSchema extends StandardSchemaV1<any, Record<string, unknown>> | undefined = undefined>(config: {
|
|
377
412
|
name: string;
|
|
378
413
|
description?: string;
|
|
379
414
|
parameters?: TSchema;
|
|
@@ -398,86 +433,53 @@ interface UseInterruptConfigBase<TValue = unknown, TResult = never> {
|
|
|
398
433
|
/**
|
|
399
434
|
* Render function for the interrupt UI.
|
|
400
435
|
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
436
|
+
* Receives both the standard `interrupt`/`interrupts` and the legacy `event`.
|
|
437
|
+
* Call `resolve(payload)` to resume with user input, or `cancel()` to cancel.
|
|
403
438
|
*/
|
|
404
439
|
render: (props: InterruptRenderProps<TValue, InterruptResult<TValue, TResult>>) => React$1.ReactElement;
|
|
405
440
|
/**
|
|
406
441
|
* Optional pre-render handler invoked when an interrupt is received.
|
|
407
|
-
*
|
|
408
|
-
* Return either a sync value or an async value to pass into `render` as `result`.
|
|
442
|
+
* Return a sync or async value to expose as `result` in `render`.
|
|
409
443
|
* Rejecting/throwing falls back to `result = null`.
|
|
410
444
|
*/
|
|
411
445
|
handler?: InterruptHandlerFn<TValue, TResult>;
|
|
412
446
|
/**
|
|
413
|
-
* Optional predicate to filter which interrupts
|
|
414
|
-
*
|
|
447
|
+
* Optional predicate to filter which interrupts this hook handles.
|
|
448
|
+
* Receives the legacy-compatible event (for standard interrupts, `value` is
|
|
449
|
+
* the primary `Interrupt`). Return `false` to ignore.
|
|
415
450
|
*/
|
|
416
451
|
enabled?: (event: InterruptEvent<TValue>) => boolean;
|
|
417
452
|
/** Optional agent id. Defaults to the current configured chat agent. */
|
|
418
453
|
agentId?: string;
|
|
419
454
|
}
|
|
420
455
|
type UseInterruptConfig<TValue = unknown, TResult = never, TRenderInChat extends InterruptRenderInChat = undefined> = UseInterruptConfigBase<TValue, TResult> & {
|
|
421
|
-
/** When true (default), the interrupt UI renders inside `<CopilotChat>` automatically.
|
|
456
|
+
/** When true (default), the interrupt UI renders inside `<CopilotChat>` automatically. */renderInChat?: TRenderInChat;
|
|
422
457
|
};
|
|
423
458
|
/**
|
|
424
|
-
* Handles agent interrupts
|
|
425
|
-
*
|
|
426
|
-
* The hook listens to custom events on the active agent, stores interrupt payloads per run,
|
|
427
|
-
* and surfaces a render callback once the run finalizes. Call `resolve` from your UI to resume
|
|
428
|
-
* execution with user-provided data.
|
|
429
|
-
*
|
|
430
|
-
* - `renderInChat: true` (default): the element is published into `<CopilotChat>` and this hook returns `void`.
|
|
431
|
-
* - `renderInChat: false`: the hook returns the interrupt element so you can place it anywhere in your component tree.
|
|
459
|
+
* Handles agent interrupts with optional filtering, preprocessing, and resume behavior.
|
|
432
460
|
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
461
|
+
* Supports both the AG-UI standard interrupt flow (`RUN_FINISHED` with
|
|
462
|
+
* `outcome.type === "interrupt"`) and the legacy custom-event flow
|
|
463
|
+
* (`on_interrupt`). For standard interrupts, `render` receives `interrupt`
|
|
464
|
+
* (the primary one) and `interrupts` (the full open set); call `resolve(payload)`
|
|
465
|
+
* to resume or `cancel()` to cancel. Resuming addresses the targeted interrupt
|
|
466
|
+
* and, once every open interrupt is addressed, submits a single spec `resume`
|
|
467
|
+
* array via `copilotkit.runAgent`.
|
|
435
468
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* @returns When `renderInChat` is `false`, returns the interrupt element (or `null` when idle).
|
|
439
|
-
* Otherwise returns `void` and publishes the element into chat. In `render`, `result` is always
|
|
440
|
-
* either the handler's resolved return value or `null` (including when no handler is provided,
|
|
441
|
-
* when filtering skips the interrupt, or when handler execution fails).
|
|
469
|
+
* - `renderInChat: true` (default): the element is published into `<CopilotChat>`; returns `void`.
|
|
470
|
+
* - `renderInChat: false`: the hook returns the interrupt element for manual placement.
|
|
442
471
|
*
|
|
443
472
|
* @example
|
|
444
473
|
* ```tsx
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* <
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* </div>
|
|
455
|
-
* ),
|
|
456
|
-
* });
|
|
457
|
-
*
|
|
458
|
-
* return null;
|
|
459
|
-
* }
|
|
460
|
-
* ```
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* ```tsx
|
|
464
|
-
* import { useInterrupt } from "@copilotkit/react-core/v2";
|
|
465
|
-
*
|
|
466
|
-
* function CustomPanel() {
|
|
467
|
-
* const interruptElement = useInterrupt({
|
|
468
|
-
* renderInChat: false,
|
|
469
|
-
* enabled: (event) => event.value.startsWith("approval:"),
|
|
470
|
-
* handler: async ({ event }) => ({ label: event.value.toUpperCase() }),
|
|
471
|
-
* render: ({ event, result, resolve }) => (
|
|
472
|
-
* <aside>
|
|
473
|
-
* <strong>{result?.label ?? ""}</strong>
|
|
474
|
-
* <button onClick={() => resolve({ value: event.value })}>Continue</button>
|
|
475
|
-
* </aside>
|
|
476
|
-
* ),
|
|
477
|
-
* });
|
|
478
|
-
*
|
|
479
|
-
* return <>{interruptElement}</>;
|
|
480
|
-
* }
|
|
474
|
+
* useInterrupt({
|
|
475
|
+
* render: ({ interrupt, resolve, cancel }) => (
|
|
476
|
+
* <div>
|
|
477
|
+
* <p>{interrupt?.message}</p>
|
|
478
|
+
* <button onClick={() => resolve({ approved: true })}>Approve</button>
|
|
479
|
+
* <button onClick={() => cancel()}>Cancel</button>
|
|
480
|
+
* </div>
|
|
481
|
+
* ),
|
|
482
|
+
* });
|
|
481
483
|
* ```
|
|
482
484
|
*/
|
|
483
485
|
declare function useInterrupt<TResult = never, TRenderInChat extends InterruptRenderInChat = undefined>(config: UseInterruptConfig<any, TResult, TRenderInChat>): UseInterruptReturn<TRenderInChat>;
|
|
@@ -609,6 +611,12 @@ interface UseThreadsResult {
|
|
|
609
611
|
* Resolves when the server confirms the update; rejects on failure.
|
|
610
612
|
*/
|
|
611
613
|
archiveThread: (threadId: string) => Promise<void>;
|
|
614
|
+
/**
|
|
615
|
+
* Restore a previously archived thread on the platform.
|
|
616
|
+
* The thread re-appears in default (non-archived) list results.
|
|
617
|
+
* Resolves when the server confirms the update; rejects on failure.
|
|
618
|
+
*/
|
|
619
|
+
unarchiveThread: (threadId: string) => Promise<void>;
|
|
612
620
|
/**
|
|
613
621
|
* Permanently delete a thread from the platform.
|
|
614
622
|
* This is irreversible. Resolves when the server confirms deletion;
|
|
@@ -625,9 +633,9 @@ interface UseThreadsResult {
|
|
|
625
633
|
* current without polling — thread creates, renames, archives, and deletes
|
|
626
634
|
* from any client are reflected immediately.
|
|
627
635
|
*
|
|
628
|
-
* Mutation methods (`renameThread`, `archiveThread`, `
|
|
629
|
-
* promises that resolve once the platform confirms the
|
|
630
|
-
* with an `Error` on failure.
|
|
636
|
+
* Mutation methods (`renameThread`, `archiveThread`, `unarchiveThread`,
|
|
637
|
+
* `deleteThread`) return promises that resolve once the platform confirms the
|
|
638
|
+
* operation and reject with an `Error` on failure.
|
|
631
639
|
*
|
|
632
640
|
* @param input - Agent identifier and optional list controls.
|
|
633
641
|
* @returns Thread list state and stable mutation callbacks.
|
|
@@ -763,5 +771,5 @@ declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
|
763
771
|
*/
|
|
764
772
|
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
765
773
|
//#endregion
|
|
766
|
-
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type Thread, type UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
774
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread, type UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
767
775
|
//# sourceMappingURL=headless.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;
|
|
1
|
+
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;;;;AADF;EAME,IAAA,GAAO,gBAAA,MAAsB,CAAA;EANO;;;;EAWpC,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ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ACDA;;;;;;;;;;;;;;ADCA,iBe6KgB,UAAA,CAAA;EACd,OAAA;EACA,eAAA;EACA;AAAA,GACC,eAAA,GAAkB,gBAAA;;;UC7KJ,yBAAA,WAAoC,gBAAA;EACnD,IAAA;EACA,UAAA;EACA,UAAA,EAAY,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EACtC,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,wBAAA,WAAmC,gBAAA;EAClD,IAAA;EACA,UAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,uBAAA,WAAkC,gBAAA;EACjD,IAAA;EACA,UAAA;EACA,UAAA,EAAY,iBAAA,CAAkB,CAAA;EAC9B,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,eAAA,WAA0B,gBAAA,IAClC,yBAAA,CAA0B,CAAA,IAC1B,wBAAA,CAAyB,CAAA,IACzB,uBAAA,CAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCZ,aAAA,CACd,MAAA;EACE,IAAA;EACA,MAAA,GAAS,KAAA,UAAe,KAAA,CAAM,YAAA;EAC9B,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;;AjBtET;;;;;;;;;;;;;;;;;;iBiBoGgB,aAAA,WAAwB,gBAAA,CAAA,CACtC,MAAA;EACE,IAAA;EACA,UAAA,EAAY,CAAA;EACZ,MAAA,GAAS,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAO,KAAA,CAAM,YAAA;EAC7C,OAAA;AAAA,GAEF,IAAA,GAAO,aAAA;;;;;;;;;AlB5GT;;;;;iBmBWgB,eAAA,CACd,OAAA,YACC,iBAAA"}
|
package/dist/v2/headless.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React$1, { ComponentType, ReactNode } from "react";
|
|
2
2
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
|
-
import { AbstractAgent, RunAgentResult } from "@ag-ui/client";
|
|
3
|
+
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus, RunAgentResult } from "@ag-ui/client";
|
|
4
4
|
import { DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus } from "@copilotkit/core";
|
|
5
5
|
import { CopilotKitCoreReact, CopilotKitCoreReactConfig } from "./context";
|
|
6
6
|
import { AgentCapabilities } from "@ag-ui/core";
|
|
@@ -92,7 +92,11 @@ declare function useAgent({
|
|
|
92
92
|
//#region src/v2/types/react-tool-call-renderer.d.ts
|
|
93
93
|
interface ReactToolCallRenderer<T = unknown> {
|
|
94
94
|
name: string;
|
|
95
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Schema describing the tool arguments. Optional — renderers registered for
|
|
97
|
+
* tools without parameters (e.g. HITL confirm dialogs) have no schema.
|
|
98
|
+
*/
|
|
99
|
+
args?: StandardSchemaV1<any, T>;
|
|
96
100
|
/**
|
|
97
101
|
* Optional agent ID to constrain this tool renderer to a specific agent.
|
|
98
102
|
* If specified, this renderer will only be used for the specified agent.
|
|
@@ -179,7 +183,7 @@ type InferRenderProps<T> = T extends StandardSchemaV1 ? InferSchemaOutput<T> : a
|
|
|
179
183
|
* );
|
|
180
184
|
* ```
|
|
181
185
|
*/
|
|
182
|
-
declare function useComponent<TSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
186
|
+
declare function useComponent<TSchema extends StandardSchemaV1<any, Record<string, unknown>> | undefined = undefined>(config: {
|
|
183
187
|
name: string;
|
|
184
188
|
description?: string;
|
|
185
189
|
parameters?: TSchema;
|
|
@@ -240,18 +244,49 @@ type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unkn
|
|
|
240
244
|
declare function useHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>): void;
|
|
241
245
|
//#endregion
|
|
242
246
|
//#region src/v2/types/interrupt.d.ts
|
|
247
|
+
/** Legacy custom-event interrupt payload (agent emits a custom `on_interrupt` event). */
|
|
243
248
|
interface InterruptEvent<TValue = unknown> {
|
|
244
249
|
name: string;
|
|
245
250
|
value: TValue;
|
|
246
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Resolve the agent with user input for an interrupt.
|
|
254
|
+
*
|
|
255
|
+
* - Standard interrupts: records `{ status: "resolved", payload }` for the target
|
|
256
|
+
* interrupt (defaults to the primary one). Resumes once every open interrupt is
|
|
257
|
+
* addressed; returns the resume run result, or `void` while still awaiting others.
|
|
258
|
+
* - Legacy interrupts: resumes immediately via `command.resume = payload`.
|
|
259
|
+
*/
|
|
260
|
+
type InterruptResolveFn = (payload?: unknown, interruptId?: string) => Promise<RunAgentResult | void>;
|
|
261
|
+
/**
|
|
262
|
+
* Cancel an interrupt.
|
|
263
|
+
*
|
|
264
|
+
* - Standard interrupts: records `{ status: "cancelled" }` for the target interrupt
|
|
265
|
+
* (defaults to the primary one), then resumes once all are addressed.
|
|
266
|
+
* - Legacy interrupts: dismisses the pending interrupt without resuming.
|
|
267
|
+
*/
|
|
268
|
+
type InterruptCancelFn = (interruptId?: string) => Promise<RunAgentResult | void>;
|
|
247
269
|
interface InterruptHandlerProps<TValue = unknown> {
|
|
270
|
+
/**
|
|
271
|
+
* Legacy event shape (`{ name, value }`). Always present for back-compat: for
|
|
272
|
+
* standard interrupts, `value` is the primary `Interrupt` and `name` is `"on_interrupt"`.
|
|
273
|
+
* Prefer `interrupt` / `interrupts` for standard interrupts.
|
|
274
|
+
*/
|
|
248
275
|
event: InterruptEvent<TValue>;
|
|
249
|
-
|
|
276
|
+
/** Primary standard interrupt (`interrupts[0]`), or `null` for legacy interrupts. */
|
|
277
|
+
interrupt: Interrupt | null;
|
|
278
|
+
/** All open standard interrupts (empty array for legacy interrupts). */
|
|
279
|
+
interrupts: Interrupt[];
|
|
280
|
+
resolve: InterruptResolveFn;
|
|
281
|
+
cancel: InterruptCancelFn;
|
|
250
282
|
}
|
|
251
283
|
interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
|
|
252
284
|
event: InterruptEvent<TValue>;
|
|
285
|
+
interrupt: Interrupt | null;
|
|
286
|
+
interrupts: Interrupt[];
|
|
253
287
|
result: TResult;
|
|
254
|
-
resolve:
|
|
288
|
+
resolve: InterruptResolveFn;
|
|
289
|
+
cancel: InterruptCancelFn;
|
|
255
290
|
}
|
|
256
291
|
//#endregion
|
|
257
292
|
//#region src/v2/hooks/use-interrupt.d.ts
|
|
@@ -267,86 +302,53 @@ interface UseInterruptConfigBase<TValue = unknown, TResult = never> {
|
|
|
267
302
|
/**
|
|
268
303
|
* Render function for the interrupt UI.
|
|
269
304
|
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
305
|
+
* Receives both the standard `interrupt`/`interrupts` and the legacy `event`.
|
|
306
|
+
* Call `resolve(payload)` to resume with user input, or `cancel()` to cancel.
|
|
272
307
|
*/
|
|
273
308
|
render: (props: InterruptRenderProps<TValue, InterruptResult<TValue, TResult>>) => React$1.ReactElement;
|
|
274
309
|
/**
|
|
275
310
|
* Optional pre-render handler invoked when an interrupt is received.
|
|
276
|
-
*
|
|
277
|
-
* Return either a sync value or an async value to pass into `render` as `result`.
|
|
311
|
+
* Return a sync or async value to expose as `result` in `render`.
|
|
278
312
|
* Rejecting/throwing falls back to `result = null`.
|
|
279
313
|
*/
|
|
280
314
|
handler?: InterruptHandlerFn<TValue, TResult>;
|
|
281
315
|
/**
|
|
282
|
-
* Optional predicate to filter which interrupts
|
|
283
|
-
*
|
|
316
|
+
* Optional predicate to filter which interrupts this hook handles.
|
|
317
|
+
* Receives the legacy-compatible event (for standard interrupts, `value` is
|
|
318
|
+
* the primary `Interrupt`). Return `false` to ignore.
|
|
284
319
|
*/
|
|
285
320
|
enabled?: (event: InterruptEvent<TValue>) => boolean;
|
|
286
321
|
/** Optional agent id. Defaults to the current configured chat agent. */
|
|
287
322
|
agentId?: string;
|
|
288
323
|
}
|
|
289
324
|
type UseInterruptConfig<TValue = unknown, TResult = never, TRenderInChat extends InterruptRenderInChat = undefined> = UseInterruptConfigBase<TValue, TResult> & {
|
|
290
|
-
/** When true (default), the interrupt UI renders inside `<CopilotChat>` automatically.
|
|
325
|
+
/** When true (default), the interrupt UI renders inside `<CopilotChat>` automatically. */renderInChat?: TRenderInChat;
|
|
291
326
|
};
|
|
292
327
|
/**
|
|
293
|
-
* Handles agent interrupts
|
|
294
|
-
*
|
|
295
|
-
* The hook listens to custom events on the active agent, stores interrupt payloads per run,
|
|
296
|
-
* and surfaces a render callback once the run finalizes. Call `resolve` from your UI to resume
|
|
297
|
-
* execution with user-provided data.
|
|
298
|
-
*
|
|
299
|
-
* - `renderInChat: true` (default): the element is published into `<CopilotChat>` and this hook returns `void`.
|
|
300
|
-
* - `renderInChat: false`: the hook returns the interrupt element so you can place it anywhere in your component tree.
|
|
328
|
+
* Handles agent interrupts with optional filtering, preprocessing, and resume behavior.
|
|
301
329
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
330
|
+
* Supports both the AG-UI standard interrupt flow (`RUN_FINISHED` with
|
|
331
|
+
* `outcome.type === "interrupt"`) and the legacy custom-event flow
|
|
332
|
+
* (`on_interrupt`). For standard interrupts, `render` receives `interrupt`
|
|
333
|
+
* (the primary one) and `interrupts` (the full open set); call `resolve(payload)`
|
|
334
|
+
* to resume or `cancel()` to cancel. Resuming addresses the targeted interrupt
|
|
335
|
+
* and, once every open interrupt is addressed, submits a single spec `resume`
|
|
336
|
+
* array via `copilotkit.runAgent`.
|
|
304
337
|
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
* @returns When `renderInChat` is `false`, returns the interrupt element (or `null` when idle).
|
|
308
|
-
* Otherwise returns `void` and publishes the element into chat. In `render`, `result` is always
|
|
309
|
-
* either the handler's resolved return value or `null` (including when no handler is provided,
|
|
310
|
-
* when filtering skips the interrupt, or when handler execution fails).
|
|
338
|
+
* - `renderInChat: true` (default): the element is published into `<CopilotChat>`; returns `void`.
|
|
339
|
+
* - `renderInChat: false`: the hook returns the interrupt element for manual placement.
|
|
311
340
|
*
|
|
312
341
|
* @example
|
|
313
342
|
* ```tsx
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* <
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* </div>
|
|
324
|
-
* ),
|
|
325
|
-
* });
|
|
326
|
-
*
|
|
327
|
-
* return null;
|
|
328
|
-
* }
|
|
329
|
-
* ```
|
|
330
|
-
*
|
|
331
|
-
* @example
|
|
332
|
-
* ```tsx
|
|
333
|
-
* import { useInterrupt } from "@copilotkit/react-core/v2";
|
|
334
|
-
*
|
|
335
|
-
* function CustomPanel() {
|
|
336
|
-
* const interruptElement = useInterrupt({
|
|
337
|
-
* renderInChat: false,
|
|
338
|
-
* enabled: (event) => event.value.startsWith("approval:"),
|
|
339
|
-
* handler: async ({ event }) => ({ label: event.value.toUpperCase() }),
|
|
340
|
-
* render: ({ event, result, resolve }) => (
|
|
341
|
-
* <aside>
|
|
342
|
-
* <strong>{result?.label ?? ""}</strong>
|
|
343
|
-
* <button onClick={() => resolve({ value: event.value })}>Continue</button>
|
|
344
|
-
* </aside>
|
|
345
|
-
* ),
|
|
346
|
-
* });
|
|
347
|
-
*
|
|
348
|
-
* return <>{interruptElement}</>;
|
|
349
|
-
* }
|
|
343
|
+
* useInterrupt({
|
|
344
|
+
* render: ({ interrupt, resolve, cancel }) => (
|
|
345
|
+
* <div>
|
|
346
|
+
* <p>{interrupt?.message}</p>
|
|
347
|
+
* <button onClick={() => resolve({ approved: true })}>Approve</button>
|
|
348
|
+
* <button onClick={() => cancel()}>Cancel</button>
|
|
349
|
+
* </div>
|
|
350
|
+
* ),
|
|
351
|
+
* });
|
|
350
352
|
* ```
|
|
351
353
|
*/
|
|
352
354
|
declare function useInterrupt<TResult = never, TRenderInChat extends InterruptRenderInChat = undefined>(config: UseInterruptConfig<any, TResult, TRenderInChat>): UseInterruptReturn<TRenderInChat>;
|
|
@@ -478,6 +480,12 @@ interface UseThreadsResult {
|
|
|
478
480
|
* Resolves when the server confirms the update; rejects on failure.
|
|
479
481
|
*/
|
|
480
482
|
archiveThread: (threadId: string) => Promise<void>;
|
|
483
|
+
/**
|
|
484
|
+
* Restore a previously archived thread on the platform.
|
|
485
|
+
* The thread re-appears in default (non-archived) list results.
|
|
486
|
+
* Resolves when the server confirms the update; rejects on failure.
|
|
487
|
+
*/
|
|
488
|
+
unarchiveThread: (threadId: string) => Promise<void>;
|
|
481
489
|
/**
|
|
482
490
|
* Permanently delete a thread from the platform.
|
|
483
491
|
* This is irreversible. Resolves when the server confirms deletion;
|
|
@@ -494,9 +502,9 @@ interface UseThreadsResult {
|
|
|
494
502
|
* current without polling — thread creates, renames, archives, and deletes
|
|
495
503
|
* from any client are reflected immediately.
|
|
496
504
|
*
|
|
497
|
-
* Mutation methods (`renameThread`, `archiveThread`, `
|
|
498
|
-
* promises that resolve once the platform confirms the
|
|
499
|
-
* with an `Error` on failure.
|
|
505
|
+
* Mutation methods (`renameThread`, `archiveThread`, `unarchiveThread`,
|
|
506
|
+
* `deleteThread`) return promises that resolve once the platform confirms the
|
|
507
|
+
* operation and reject with an `Error` on failure.
|
|
500
508
|
*
|
|
501
509
|
* @param input - Agent identifier and optional list controls.
|
|
502
510
|
* @returns Thread list state and stable mutation callbacks.
|
|
@@ -671,5 +679,5 @@ declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
|
671
679
|
*/
|
|
672
680
|
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
673
681
|
//#endregion
|
|
674
|
-
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type Thread, type UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
682
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread, type UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
675
683
|
//# sourceMappingURL=headless.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;cAca,wBAAA;;;;;;;;;;;;;;;;;;;;;;KAwBD,iBAAA,UAA2B,wBAAA;AAAA,UAGtB,6BAAA;EACf,MAAA,EAAQ,iBAAA;EACR,OAAA;EACA,QAAA;EACA,WAAA;EACA,YAAA,GAAe,IAAA;EAKf,mBAAA;AAAA;AAAA,UAQe,qCAAA;EACf,QAAA,EAAU,SAAA;EACV,MAAA,GAAS,OAAA,CAAQ,iBAAA;EACjB,OAAA;EACA,QAAA;EAMA,mBAAA;EACA,kBAAA;AAAA;AAAA,cAIW,gCAAA,EAAkC,OAAA,CAAM,EAAA,CACnD,qCAAA;AAAA,cAoHW,2BAAA,QACP,6BAAA;;;aCpLM,cAAA;EACV,iBAAA;EACA,cAAA;EACA,kBAAA;AAAA;AAAA,UASe,aAAA;EACf,OAAA;EACA,OAAA,GAAU,cAAA;EDUX;;;;;;;;;;;;;;;;;;;;;;ECaC,UAAA;AAAA;AAAA,iBAGc,QAAA,CAAA;EAAW,OAAA;EAAS,OAAA;EAAS;AAAA,IAAc,aAAA;;;;;UCjD1C,qBAAA;EACf,IAAA
|
|
1
|
+
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/types/defineToolC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