@copilotkitnext/core 0.0.17-alpha.0 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +25 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ declare enum ToolCallStatus {
|
|
|
11
11
|
Executing = "executing",
|
|
12
12
|
Complete = "complete"
|
|
13
13
|
}
|
|
14
|
-
type FrontendTool<T extends
|
|
14
|
+
type FrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
15
15
|
name: string;
|
|
16
16
|
description?: string;
|
|
17
17
|
parameters?: z.ZodType<T>;
|
|
@@ -182,7 +182,7 @@ declare class RunHandler {
|
|
|
182
182
|
/**
|
|
183
183
|
* Add a tool to the registry
|
|
184
184
|
*/
|
|
185
|
-
addTool<T extends
|
|
185
|
+
addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
|
|
186
186
|
/**
|
|
187
187
|
* Remove a tool by name and optionally by agentId
|
|
188
188
|
*/
|
|
@@ -243,6 +243,9 @@ interface CopilotKitCoreConfig {
|
|
|
243
243
|
suggestionsConfig?: SuggestionsConfig[];
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
interface CopilotKitCoreStopAgentParams {
|
|
247
|
+
agent: AbstractAgent;
|
|
248
|
+
}
|
|
246
249
|
type CopilotKitCoreGetSuggestionsResult = {
|
|
247
250
|
suggestions: Suggestion[];
|
|
248
251
|
isLoading: boolean;
|
|
@@ -401,7 +404,7 @@ declare class CopilotKitCore {
|
|
|
401
404
|
/**
|
|
402
405
|
* Tool management (delegated to RunHandler)
|
|
403
406
|
*/
|
|
404
|
-
addTool<T extends
|
|
407
|
+
addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
|
|
405
408
|
removeTool(id: string, agentId?: string): void;
|
|
406
409
|
getTool(params: CopilotKitCoreGetToolParams): FrontendTool<any> | undefined;
|
|
407
410
|
setTools(tools: FrontendTool<any>[]): void;
|
|
@@ -414,6 +417,7 @@ declare class CopilotKitCore {
|
|
|
414
417
|
* Agent connectivity (delegated to RunHandler)
|
|
415
418
|
*/
|
|
416
419
|
connectAgent(params: CopilotKitCoreConnectAgentParams): Promise<_ag_ui_client.RunAgentResult>;
|
|
420
|
+
stopAgent(params: CopilotKitCoreStopAgentParams): void;
|
|
417
421
|
runAgent(params: CopilotKitCoreRunAgentParams): Promise<_ag_ui_client.RunAgentResult>;
|
|
418
422
|
/**
|
|
419
423
|
* State management (delegated to StateManager)
|
|
@@ -615,9 +619,10 @@ interface ProxiedCopilotRuntimeAgentConfig extends Omit<HttpAgentConfig, "url">
|
|
|
615
619
|
declare class ProxiedCopilotRuntimeAgent extends HttpAgent {
|
|
616
620
|
runtimeUrl?: string;
|
|
617
621
|
constructor(config: ProxiedCopilotRuntimeAgentConfig);
|
|
622
|
+
abortRun(): void;
|
|
618
623
|
connect(input: RunAgentInput): Observable<BaseEvent>;
|
|
619
624
|
}
|
|
620
625
|
|
|
621
626
|
declare function completePartialMarkdown(input: string): string;
|
|
622
627
|
|
|
623
|
-
export { AgentRegistry, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, type CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, type CopilotKitCoreFriendsAccess, type CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRunAgentParams, CopilotKitCoreRuntimeConnectionStatus, type CopilotKitCoreSubscriber, type DynamicSuggestionsConfig, type FrontendTool, ProxiedCopilotRuntimeAgent, type ProxiedCopilotRuntimeAgentConfig, RunHandler, StateManager, type StaticSuggestionsConfig, type Suggestion, type SuggestionAvailability, SuggestionEngine, type SuggestionsConfig, ToolCallStatus, completePartialMarkdown };
|
|
628
|
+
export { AgentRegistry, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, type CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, type CopilotKitCoreFriendsAccess, type CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRunAgentParams, CopilotKitCoreRuntimeConnectionStatus, type CopilotKitCoreStopAgentParams, type CopilotKitCoreSubscriber, type DynamicSuggestionsConfig, type FrontendTool, ProxiedCopilotRuntimeAgent, type ProxiedCopilotRuntimeAgentConfig, RunHandler, StateManager, type StaticSuggestionsConfig, type Suggestion, type SuggestionAvailability, SuggestionEngine, type SuggestionsConfig, ToolCallStatus, completePartialMarkdown };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare enum ToolCallStatus {
|
|
|
11
11
|
Executing = "executing",
|
|
12
12
|
Complete = "complete"
|
|
13
13
|
}
|
|
14
|
-
type FrontendTool<T extends
|
|
14
|
+
type FrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
15
15
|
name: string;
|
|
16
16
|
description?: string;
|
|
17
17
|
parameters?: z.ZodType<T>;
|
|
@@ -182,7 +182,7 @@ declare class RunHandler {
|
|
|
182
182
|
/**
|
|
183
183
|
* Add a tool to the registry
|
|
184
184
|
*/
|
|
185
|
-
addTool<T extends
|
|
185
|
+
addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
|
|
186
186
|
/**
|
|
187
187
|
* Remove a tool by name and optionally by agentId
|
|
188
188
|
*/
|
|
@@ -243,6 +243,9 @@ interface CopilotKitCoreConfig {
|
|
|
243
243
|
suggestionsConfig?: SuggestionsConfig[];
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
interface CopilotKitCoreStopAgentParams {
|
|
247
|
+
agent: AbstractAgent;
|
|
248
|
+
}
|
|
246
249
|
type CopilotKitCoreGetSuggestionsResult = {
|
|
247
250
|
suggestions: Suggestion[];
|
|
248
251
|
isLoading: boolean;
|
|
@@ -401,7 +404,7 @@ declare class CopilotKitCore {
|
|
|
401
404
|
/**
|
|
402
405
|
* Tool management (delegated to RunHandler)
|
|
403
406
|
*/
|
|
404
|
-
addTool<T extends
|
|
407
|
+
addTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: FrontendTool<T>): void;
|
|
405
408
|
removeTool(id: string, agentId?: string): void;
|
|
406
409
|
getTool(params: CopilotKitCoreGetToolParams): FrontendTool<any> | undefined;
|
|
407
410
|
setTools(tools: FrontendTool<any>[]): void;
|
|
@@ -414,6 +417,7 @@ declare class CopilotKitCore {
|
|
|
414
417
|
* Agent connectivity (delegated to RunHandler)
|
|
415
418
|
*/
|
|
416
419
|
connectAgent(params: CopilotKitCoreConnectAgentParams): Promise<_ag_ui_client.RunAgentResult>;
|
|
420
|
+
stopAgent(params: CopilotKitCoreStopAgentParams): void;
|
|
417
421
|
runAgent(params: CopilotKitCoreRunAgentParams): Promise<_ag_ui_client.RunAgentResult>;
|
|
418
422
|
/**
|
|
419
423
|
* State management (delegated to StateManager)
|
|
@@ -615,9 +619,10 @@ interface ProxiedCopilotRuntimeAgentConfig extends Omit<HttpAgentConfig, "url">
|
|
|
615
619
|
declare class ProxiedCopilotRuntimeAgent extends HttpAgent {
|
|
616
620
|
runtimeUrl?: string;
|
|
617
621
|
constructor(config: ProxiedCopilotRuntimeAgentConfig);
|
|
622
|
+
abortRun(): void;
|
|
618
623
|
connect(input: RunAgentInput): Observable<BaseEvent>;
|
|
619
624
|
}
|
|
620
625
|
|
|
621
626
|
declare function completePartialMarkdown(input: string): string;
|
|
622
627
|
|
|
623
|
-
export { AgentRegistry, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, type CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, type CopilotKitCoreFriendsAccess, type CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRunAgentParams, CopilotKitCoreRuntimeConnectionStatus, type CopilotKitCoreSubscriber, type DynamicSuggestionsConfig, type FrontendTool, ProxiedCopilotRuntimeAgent, type ProxiedCopilotRuntimeAgentConfig, RunHandler, StateManager, type StaticSuggestionsConfig, type Suggestion, type SuggestionAvailability, SuggestionEngine, type SuggestionsConfig, ToolCallStatus, completePartialMarkdown };
|
|
628
|
+
export { AgentRegistry, ContextStore, CopilotKitCore, type CopilotKitCoreAddAgentParams, type CopilotKitCoreConfig, type CopilotKitCoreConnectAgentParams, CopilotKitCoreErrorCode, type CopilotKitCoreFriendsAccess, type CopilotKitCoreGetSuggestionsResult, type CopilotKitCoreGetToolParams, type CopilotKitCoreRunAgentParams, CopilotKitCoreRuntimeConnectionStatus, type CopilotKitCoreStopAgentParams, type CopilotKitCoreSubscriber, type DynamicSuggestionsConfig, type FrontendTool, ProxiedCopilotRuntimeAgent, type ProxiedCopilotRuntimeAgentConfig, RunHandler, StateManager, type StaticSuggestionsConfig, type Suggestion, type SuggestionAvailability, SuggestionEngine, type SuggestionsConfig, ToolCallStatus, completePartialMarkdown };
|
package/dist/index.js
CHANGED
|
@@ -49,11 +49,29 @@ var ProxiedCopilotRuntimeAgent = class extends import_client.HttpAgent {
|
|
|
49
49
|
});
|
|
50
50
|
this.runtimeUrl = config.runtimeUrl;
|
|
51
51
|
}
|
|
52
|
+
abortRun() {
|
|
53
|
+
if (!this.runtimeUrl || !this.agentId || !this.threadId) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (typeof fetch === "undefined") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const stopPath = `${this.runtimeUrl}/agent/${encodeURIComponent(this.agentId)}/stop/${encodeURIComponent(this.threadId)}`;
|
|
60
|
+
const origin = typeof window !== "undefined" && window.location ? window.location.origin : "http://localhost";
|
|
61
|
+
const base = new URL(this.runtimeUrl, origin);
|
|
62
|
+
const stopUrl = new URL(stopPath, base);
|
|
63
|
+
void fetch(stopUrl.toString(), {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": "application/json",
|
|
67
|
+
...this.headers
|
|
68
|
+
}
|
|
69
|
+
}).catch((error) => {
|
|
70
|
+
console.error("ProxiedCopilotRuntimeAgent: stop request failed", error);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
52
73
|
connect(input) {
|
|
53
|
-
const httpEvents = (0, import_client.runHttpRequest)(
|
|
54
|
-
`${this.runtimeUrl}/agent/${this.agentId}/connect`,
|
|
55
|
-
this.requestInit(input)
|
|
56
|
-
);
|
|
74
|
+
const httpEvents = (0, import_client.runHttpRequest)(`${this.runtimeUrl}/agent/${this.agentId}/connect`, this.requestInit(input));
|
|
57
75
|
return (0, import_client.transformHttpEventStream)(httpEvents);
|
|
58
76
|
}
|
|
59
77
|
};
|
|
@@ -1521,6 +1539,9 @@ var CopilotKitCore = class {
|
|
|
1521
1539
|
async connectAgent(params) {
|
|
1522
1540
|
return this.runHandler.connectAgent(params);
|
|
1523
1541
|
}
|
|
1542
|
+
stopAgent(params) {
|
|
1543
|
+
params.agent.abortRun();
|
|
1544
|
+
}
|
|
1524
1545
|
async runAgent(params) {
|
|
1525
1546
|
return this.runHandler.runAgent(params);
|
|
1526
1547
|
}
|