@copilotkitnext/angular 0.0.6 → 0.0.8

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.ts CHANGED
@@ -8,7 +8,7 @@ export * from "./core/chat-configuration/chat-configuration.providers";
8
8
  export * from "./utils/copilotkit.utils";
9
9
  export * from "./utils/agent-context.utils";
10
10
  export * from "./utils/frontend-tool.utils";
11
- export { watchAgent, getAgent, subscribeToAgent, registerAgentWatcher, } from "./utils/agent.utils";
11
+ export { watchAgent, watchAgentWith, getAgent, subscribeToAgent, } from "./utils/agent.utils";
12
12
  export * from "./utils/human-in-the-loop.utils";
13
13
  export * from "./utils/chat-config.utils";
14
14
  export { CopilotTooltipDirective } from "./lib/directives/tooltip.directive";
@@ -1,3 +1,4 @@
1
+ import { Injector } from "@angular/core";
1
2
  import { CopilotKitService } from "../core/copilotkit.service";
2
3
  import { AgentSubscriptionCallbacks, AgentWatchResult } from "../core/copilotkit.types";
3
4
  import { AbstractAgent } from "@ag-ui/client";
@@ -48,6 +49,32 @@ export declare function watchAgent(config?: {
48
49
  */
49
50
  export declare function getAgent(service: CopilotKitService, agentId?: string): AbstractAgent | undefined;
50
51
  export type { AgentWatchResult } from "../core/copilotkit.types";
52
+ /**
53
+ * Convenience wrapper for watchAgent that handles injection context.
54
+ * Useful when you need to call watchAgent outside of a constructor or field initializer.
55
+ *
56
+ * @param injector - The Angular Injector to use for injection context
57
+ * @param config - Optional configuration with agentId
58
+ * @returns Object with agent, messages, and isRunning signals plus observables
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * export class MyComponent {
63
+ * constructor(private injector: Injector) {}
64
+ *
65
+ * switchAgent(newAgentId: string) {
66
+ * // Can call outside of constructor using watchAgentWith
67
+ * const watcher = watchAgentWith(this.injector, { agentId: newAgentId });
68
+ * this.agent = watcher.agent;
69
+ * this.messages = watcher.messages;
70
+ * this.isRunning = watcher.isRunning;
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ export declare function watchAgentWith(injector: Injector, config?: {
76
+ agentId?: string;
77
+ }): AgentWatchResult;
51
78
  /**
52
79
  * Subscribes to an agent's events with custom callbacks.
53
80
  * Returns a cleanup function that should be called to unsubscribe.
@@ -79,21 +106,3 @@ export type { AgentWatchResult } from "../core/copilotkit.types";
79
106
  * ```
80
107
  */
81
108
  export declare function subscribeToAgent(service: CopilotKitService, agentId?: string, callbacks?: AgentSubscriptionCallbacks): () => void;
82
- /**
83
- * Registers an agent watcher that automatically cleans up on component destroy.
84
- * This is an alias for watchAgent with a more explicit name.
85
- * Must be called within an injection context.
86
- *
87
- * @param config - Optional configuration with agentId
88
- * @returns Object with agent, messages, and isRunning signals plus observables
89
- *
90
- * @example
91
- * ```typescript
92
- * export class MyComponent {
93
- * agentState = registerAgentWatcher({ agentId: 'my-agent' });
94
- * }
95
- * ```
96
- */
97
- export declare function registerAgentWatcher(config?: {
98
- agentId?: string;
99
- }): AgentWatchResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkitnext/angular",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Angular library for CopilotKit",
5
5
  "main": "dist/fesm2022/copilotkitnext-angular.mjs",
6
6
  "module": "dist/fesm2022/copilotkitnext-angular.mjs",
@@ -29,8 +29,8 @@
29
29
  "rxjs": "^7.8.1",
30
30
  "tailwind-merge": "^2.6.0",
31
31
  "zod": "^3.22.4",
32
- "@copilotkitnext/core": "0.0.6",
33
- "@copilotkitnext/shared": "0.0.6"
32
+ "@copilotkitnext/core": "0.0.8",
33
+ "@copilotkitnext/shared": "0.0.8"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@angular/cdk": "^18.0.0 || ^19.0.0",