@useago/sdk 0.4.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +10 -0
  4. package/README.md +19 -11
  5. package/dist/{AgoClient-rvTz2thR.js → AgoClient-BrYhSO5M.js} +32 -26
  6. package/dist/AgoClient-CPqPT5s6.cjs +6 -0
  7. package/dist/angular.cjs +1 -1
  8. package/dist/angular.d.cts +5 -0
  9. package/dist/angular.d.ts +5 -0
  10. package/dist/angular.js +1 -1
  11. package/dist/{createConversationSession-DGcM_Z3f.cjs → createConversationSession-CGRO0bs2.cjs} +1 -1
  12. package/dist/{createConversationSession-D-eq8VIo.js → createConversationSession-Dmqd80DX.js} +1 -1
  13. package/dist/{createFormCollector-DON4vdJV.js → createFormCollector-CPS2phYq.js} +51 -50
  14. package/dist/createFormCollector-DaWZsBsI.cjs +1 -0
  15. package/dist/devtools.cjs +3 -3
  16. package/dist/devtools.d.cts +7 -2
  17. package/dist/devtools.d.ts +7 -2
  18. package/dist/devtools.js +41 -35
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +14 -0
  21. package/dist/index.d.ts +14 -0
  22. package/dist/index.js +38 -37
  23. package/dist/react.cjs +19 -19
  24. package/dist/react.d.cts +16 -0
  25. package/dist/react.d.ts +16 -0
  26. package/dist/react.js +1516 -1490
  27. package/dist/testing.cjs +1 -0
  28. package/dist/testing.d.cts +482 -0
  29. package/dist/testing.d.ts +482 -0
  30. package/dist/testing.js +4 -0
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +5 -0
  33. package/dist/vue.d.ts +5 -0
  34. package/dist/vue.js +1 -1
  35. package/dist/widget.cjs +4 -4
  36. package/dist/widget.d.cts +6 -1
  37. package/dist/widget.d.ts +6 -1
  38. package/dist/widget.js +300 -286
  39. package/package.json +30 -9
  40. package/dist/AgoClient-D4EL6nva.cjs +0 -6
  41. package/dist/createFormCollector-IO6bfPQx.cjs +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,98 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@useago/sdk` are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2026-06-11
9
+
10
+ First stable public release.
11
+
12
+ ### Added
13
+
14
+ - `@useago/sdk/testing` entry point exposing `createMockClient`.
15
+
16
+ ### Changed
17
+
18
+ - **License is now Apache 2.0.** The SDK is officially open source. A `LICENSE`
19
+ and `NOTICE` file ship with the package.
20
+
21
+ ## [0.4.7]
22
+
23
+ ### Fixed
24
+
25
+ - Follow-up replies now only render on the last chat message.
26
+ - Dev panel context display.
27
+
28
+ ## [0.4.6]
29
+
30
+ ### Added
31
+
32
+ - Form schema and collection status are exposed in the agent context.
33
+ - Markdown rendering in the vanilla chat widget.
34
+ - Conditional field requirements in the form collector.
35
+ - Theming support for the widget via `--ago-*` CSS tokens and a `theme` option.
36
+
37
+ ## [0.4.1]
38
+
39
+ ### Added
40
+
41
+ - Conversational form collector restores its state when a conversation is reloaded.
42
+ - Single widget-id session with the last thread cached on the front end.
43
+ - Tool calls are included in the SDK conversation detail (`tool_call_data`).
44
+
45
+ ### Fixed
46
+
47
+ - Form collector missing values now show in the dev panel from the start.
48
+
49
+ ## [0.4.0]
50
+
51
+ ### Added
52
+
53
+ - Conversation persistence and session management for the chat widget.
54
+ - Dev panel shows the live agent context instead of raw store state.
55
+
56
+ ## [0.3.4]
57
+
58
+ ### Added
59
+
60
+ - Complete chat widget: form creator, suggested replies, and vanilla `mountChatWidget`.
61
+ - Conversational form collector with optional backend relay.
62
+ - In-browser debug panel (`@useago/sdk/devtools`) with store persistence.
63
+ - Tool-call result submit route in the SDK API.
64
+
65
+ ### Fixed
66
+
67
+ - Devtools DOM ids and storage keys are namespaced to avoid host-page collisions.
68
+
69
+ ## [0.3.0]
70
+
71
+ ### Added
72
+
73
+ - Observable store with `createStore`, plus `useAgoStore` bindings for React and Vue.
74
+
75
+ ## [0.2.1]
76
+
77
+ ### Added
78
+
79
+ - Comprehensive README and per-framework guides (core, React, Vue, Angular, widget).
80
+
81
+ ## [0.1.x]
82
+
83
+ Initial public releases establishing the SDK foundation:
84
+
85
+ - Framework-agnostic `AgoClient` with SSE streaming.
86
+ - React hooks/components, Vue composables, and Angular service bindings.
87
+ - Client-side functions (`defineFunction`, `registerFunction`) and pre-built helpers.
88
+ - Client/page context API and programmatic navigation.
89
+ - Zero-config auto-detection (`createAgo`) and a mock client for testing.
90
+
91
+ [1.0.0]: https://github.com/useago/ago-sdk/releases/tag/v1.0.0
92
+ [0.4.7]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.4.7
93
+ [0.4.6]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.4.6
94
+ [0.4.1]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.4.1
95
+ [0.4.0]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.4.0
96
+ [0.3.4]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.3.4
97
+ [0.3.0]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.3.0
98
+ [0.2.1]: https://github.com/useago/ago-chat/releases/tag/sdk-v0.2.1
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 AGO
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ @useago/sdk
2
+ Copyright 2026 AGO (https://useago.com)
3
+
4
+ This product includes software developed at AGO.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @useago/sdk
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@useago/sdk.svg)](https://www.npmjs.com/package/@useago/sdk)
4
+ [![license](https://img.shields.io/npm/l/@useago/sdk.svg)](./LICENSE)
5
+ [![types](https://img.shields.io/npm/types/@useago/sdk.svg)](https://www.npmjs.com/package/@useago/sdk)
6
+
3
7
  Official JavaScript/TypeScript SDK for [AGO](https://useago.com) — embed AGO's AI
4
8
  agents directly inside your own app. Stream answers, let the agent call **your**
5
9
  client-side functions, navigate users around your UI, and feed it live context
@@ -13,6 +17,9 @@ same `AgoClient`.
13
17
  npm install @useago/sdk
14
18
  ```
15
19
 
20
+ 📚 **Full documentation:** [docs.useago.com](https://docs.useago.com) · the
21
+ framework guides below are also published there.
22
+
16
23
  ---
17
24
 
18
25
  ## Quick start
@@ -21,19 +28,19 @@ Pick your stack — each guide is self-contained.
21
28
 
22
29
  | Stack | Guide |
23
30
  | --- | --- |
24
- | Plain JavaScript / TypeScript | [docs/core.md](docs/core.md) |
25
- | React | [docs/react.md](docs/react.md) |
26
- | Vue 3 | [docs/vue.md](docs/vue.md) |
27
- | Angular | [docs/angular.md](docs/angular.md) |
28
- | Embeddable widget (`<script>`) | [docs/widget.md](docs/widget.md) |
31
+ | Plain JavaScript / TypeScript | [docs/general/core.md](docs/general/core.md) |
32
+ | React | [docs/frameworks/react.md](docs/frameworks/react.md) |
33
+ | Vue 3 | [docs/frameworks/vue.md](docs/frameworks/vue.md) |
34
+ | Angular | [docs/frameworks/angular.md](docs/frameworks/angular.md) |
35
+ | Embeddable widget (`<script>`) | [docs/general/widget.md](docs/general/widget.md) |
29
36
 
30
37
  Cross-cutting topics (apply to every framework):
31
38
 
32
- - [**Client-side functions & helpers**](docs/functions-and-context.md#client-side-functions) — let the agent run code in the browser
33
- - [**Client context**](docs/functions-and-context.md#client-context) — tell the agent what the user is looking at
34
- - [**Events & streaming**](docs/events-and-streaming.md) — low-level hooks into the message stream
35
- - [**Testing**](docs/testing.md) — a mock client for unit tests
36
- - [**Configuration & auth**](docs/configuration.md) — every `AgoConfig` option, headers, errors
39
+ - [**Client-side functions & helpers**](docs/general/functions-and-context.md#client-side-functions) — let the agent run code in the browser
40
+ - [**Client context**](docs/general/functions-and-context.md#client-context) — tell the agent what the user is looking at
41
+ - [**Events & streaming**](docs/general/events-and-streaming.md) — low-level hooks into the message stream
42
+ - [**Testing**](docs/general/testing.md) — a mock client for unit tests
43
+ - [**Configuration & auth**](docs/general/configuration.md) — every `AgoConfig` option, headers, errors
37
44
 
38
45
  The 30-second version (vanilla):
39
46
 
@@ -98,6 +105,7 @@ what you use:
98
105
  | `@useago/sdk/helpers` | Pre-built client functions only |
99
106
  | `@useago/sdk/widget` | `window.AGO` widget config types |
100
107
  | `@useago/sdk/devtools` | `initDevPanel` — in-browser debug overlay (DOM/CSS) |
108
+ | `@useago/sdk/testing` | `createMockClient` — mock client for tests |
101
109
 
102
110
  ESM and CJS builds are both shipped, with full TypeScript declarations.
103
111
 
@@ -112,4 +120,4 @@ ESM and CJS builds are both shipped, with full TypeScript declarations.
112
120
 
113
121
  ## License
114
122
 
115
- MIT · [Documentation](https://docs.useago.com) · [Website](https://useago.com)
123
+ [Apache 2.0](./LICENSE) · [Documentation](https://docs.useago.com) · [Website](https://useago.com)
@@ -22,7 +22,7 @@ var d = class extends Error {
22
22
  constructor(e, t, s) {
23
23
  super(e, "function_error"), this.functionName = t, this.originalError = s, this.name = "AgoFunctionError";
24
24
  }
25
- }, w = class {
25
+ }, y = class {
26
26
  constructor(e = !1) {
27
27
  this.enabled = e;
28
28
  }
@@ -44,7 +44,7 @@ var d = class extends Error {
44
44
  debug(...e) {
45
45
  this.enabled && console.debug("[AGO SDK]", ...e);
46
46
  }
47
- }, n = new w(), f = "ago_widget_id";
47
+ }, n = new y(), f = "ago_widget_id";
48
48
  function C() {
49
49
  if (typeof localStorage < "u") {
50
50
  const t = localStorage.getItem(f);
@@ -133,10 +133,10 @@ var E = class {
133
133
  }
134
134
  register(e, t, s) {
135
135
  if (typeof e == "object") {
136
- const { name: i, handler: o, description: a, parameters: c } = e;
136
+ const { name: i, handler: o, description: a, parameters: l } = e;
137
137
  return this.register(i, o, {
138
138
  description: a,
139
- parameters: c
139
+ parameters: l
140
140
  });
141
141
  }
142
142
  const r = e;
@@ -212,9 +212,9 @@ var E = class {
212
212
  clear() {
213
213
  this.entries.clear(), this.dynamicProviders.clear(), n.log("ClientContext cleared");
214
214
  }
215
- }, S = class {
215
+ }, k = class {
216
216
  constructor(e) {
217
- this.callbacks = e, this.buffer = "", this.message = {}, this.toolCalls = [], this.sources = [], this.followUpReplies = [], this.isFirstChunk = !0;
217
+ this.callbacks = e, this.buffer = "", this.message = {}, this.toolCalls = [], this.sources = [], this.followUpReplies = [], this.isFirstChunk = !0, this.answerCompleteEmitted = !1;
218
218
  }
219
219
  async processStream(e) {
220
220
  if (!e.body) throw new g("Response has no body");
@@ -285,7 +285,7 @@ var E = class {
285
285
  const s = this.toolCalls.findIndex((r) => r.id === t.id);
286
286
  s >= 0 ? this.toolCalls[s] = t : this.toolCalls.push(t);
287
287
  }
288
- e.follow_up_replies && (this.followUpReplies = e.follow_up_replies);
288
+ e.follow_up_replies && (this.followUpReplies = e.follow_up_replies), this.message.status === "DONE" && !this.answerCompleteEmitted && this.message.id && (this.answerCompleteEmitted = !0, this.callbacks.onAnswerComplete?.(this.buildMessage()));
289
289
  }
290
290
  parseToolCall(e) {
291
291
  return {
@@ -301,8 +301,8 @@ var E = class {
301
301
  arguments: e.arguments
302
302
  };
303
303
  }
304
- buildFinalMessage() {
305
- const e = {
304
+ buildMessage() {
305
+ return {
306
306
  id: this.message.id || "",
307
307
  conversationId: this.message.conversationId || "",
308
308
  content: this.message.content || "",
@@ -314,6 +314,9 @@ var E = class {
314
314
  followUpReplies: this.followUpReplies.length > 0 ? this.followUpReplies : void 0,
315
315
  createdAt: /* @__PURE__ */ new Date()
316
316
  };
317
+ }
318
+ buildFinalMessage() {
319
+ const e = this.buildMessage();
317
320
  return this.callbacks.onComplete?.(e), e;
318
321
  }
319
322
  };
@@ -321,7 +324,7 @@ function x(e) {
321
324
  const t = e.message.toLowerCase();
322
325
  return t.includes("load failed") || t.includes("failed to fetch") || t.includes("network") || t.includes("abort");
323
326
  }
324
- var k = class {
327
+ var S = class {
325
328
  constructor() {
326
329
  this.handlers = /* @__PURE__ */ new Map();
327
330
  }
@@ -362,9 +365,9 @@ var k = class {
362
365
  removeAllListeners(e) {
363
366
  e ? this.handlers.delete(e) : this.handlers.clear();
364
367
  }
365
- }, $ = class v {
368
+ }, $ = class w {
366
369
  constructor(t) {
367
- this.config = t, this.httpClient = new E(t), this.functionRegistry = new b(), this.contextRegistry = new _(), this.eventEmitter = new k(), t.debug && n.enable(), n.log("AgoClient initialized");
370
+ this.config = t, this.httpClient = new E(t), this.functionRegistry = new b(), this.contextRegistry = new _(), this.eventEmitter = new S(), t.debug && n.enable(), n.log("AgoClient initialized");
368
371
  }
369
372
  async sendMessage(t, s) {
370
373
  const r = this.functionRegistry.getSchemas(), i = this.contextRegistry.getSnapshot(), o = this.config.agent || this.config.defaultAgentId, a = {
@@ -373,17 +376,17 @@ var k = class {
373
376
  agent_id: s?.agentId || o
374
377
  };
375
378
  r.length > 0 && (a.client_functions = r), i && (a.client_context = i);
376
- let c;
379
+ let l;
377
380
  if (s?.files && s.files.length > 0) {
378
- const l = new FormData();
379
- l.append("content", t), s.conversationId && l.append("conversation_id", s.conversationId), (s.agentId || o) && l.append("agent_id", s.agentId || o || ""), r.length > 0 && l.append("client_functions", JSON.stringify(r)), i && l.append("client_context", JSON.stringify(i));
380
- for (const y of s.files) l.append("files", y);
381
- c = await this.httpClient.postFormData("/api/sdk/v1/messages", l);
382
- } else c = await this.httpClient.postStream("/api/sdk/v1/messages", a);
383
- return this.processSSEResponse(c);
381
+ const c = new FormData();
382
+ c.append("content", t), s.conversationId && c.append("conversation_id", s.conversationId), (s.agentId || o) && c.append("agent_id", s.agentId || o || ""), r.length > 0 && c.append("client_functions", JSON.stringify(r)), i && c.append("client_context", JSON.stringify(i));
383
+ for (const v of s.files) c.append("files", v);
384
+ l = await this.httpClient.postFormData("/api/sdk/v1/messages", c);
385
+ } else l = await this.httpClient.postStream("/api/sdk/v1/messages", a);
386
+ return this.processSSEResponse(l);
384
387
  }
385
388
  async processSSEResponse(t) {
386
- return new S({
389
+ return new k({
387
390
  onStart: (s) => {
388
391
  this.eventEmitter.emit("message:start", s);
389
392
  },
@@ -396,6 +399,9 @@ var k = class {
396
399
  onClientFunction: async (s) => {
397
400
  this.eventEmitter.emit("function:invoke", s), await this.handleClientFunctionInvocation(s);
398
401
  },
402
+ onAnswerComplete: (s) => {
403
+ this.eventEmitter.emit("message:answer-complete", s);
404
+ },
399
405
  onComplete: (s) => {
400
406
  this.eventEmitter.emit("message:complete", s);
401
407
  },
@@ -445,7 +451,7 @@ var k = class {
445
451
  role: i.role,
446
452
  status: i.status,
447
453
  createdAt: new Date(i.created_at),
448
- toolCalls: v.mapPersistedToolCalls(i.tool_call_data)
454
+ toolCalls: w.mapPersistedToolCalls(i.tool_call_data)
449
455
  }))
450
456
  };
451
457
  return this.eventEmitter.emit("conversation:loaded", r), r;
@@ -503,10 +509,10 @@ var k = class {
503
509
  const r = s.map((o) => o.name), i = s.map((o) => `- "${o.name}": ${o.description}`).join(`
504
510
  `);
505
511
  this.registerFunction("navigateToPage", async (o) => {
506
- const a = o.page, c = s.find((l) => l.name === a);
507
- return c ? (t(c.path), {
512
+ const a = o.page, l = s.find((c) => c.name === a);
513
+ return l ? (t(l.path), {
508
514
  success: !0,
509
- navigatedTo: c.path
515
+ navigatedTo: l.path
510
516
  }) : {
511
517
  success: !1,
512
518
  error: `Unknown page: ${a}`
@@ -587,9 +593,9 @@ export {
587
593
  g as f,
588
594
  x as i,
589
595
  d as l,
590
- k as n,
596
+ S as n,
591
597
  b as o,
592
- S as r,
598
+ k as r,
593
599
  n as s,
594
600
  $ as t,
595
601
  m as u
@@ -0,0 +1,6 @@
1
+ var u=class extends Error{constructor(e,t,s){super(e),this.code=t,this.statusCode=s,this.name="AgoError"}},h=class p extends u{constructor(t,s,r,n,o,a){super(t,s,r),this.type=n,this.param=o,this.docUrl=a,this.name="AgoApiError"}static fromResponse(t,s){const r=t.error;return new p(r.message,r.code,s,r.type,r.param,r.doc_url)}},d=class extends u{constructor(e,t){super(e,"network_error"),this.originalError=t,this.name="AgoNetworkError"}},g=class extends u{constructor(e){super(e,"stream_error"),this.name="AgoStreamError"}},m=class extends u{constructor(e,t,s){super(e,"function_error"),this.functionName=t,this.originalError=s,this.name="AgoFunctionError"}},_=class{constructor(e=!1){this.enabled=e}enable(){this.enabled=!0}disable(){this.enabled=!1}log(...e){this.enabled&&console.log("[AGO SDK]",...e)}warn(...e){this.enabled&&console.warn("[AGO SDK]",...e)}error(...e){console.error("[AGO SDK]",...e)}debug(...e){this.enabled&&console.debug("[AGO SDK]",...e)}},i=new _,f="ago_widget_id";function S(){if(typeof localStorage<"u"){const t=localStorage.getItem(f);if(t)return t}const e=crypto.randomUUID();if(typeof localStorage<"u")try{localStorage.setItem(f,e)}catch{}return e}var k=class{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.headers={"X-Widget-Id":e.widgetId||S()},e.userEmail&&(this.headers["X-User-Email"]=e.userEmail),e.userJwt&&(this.headers.Authorization=`Bearer ${e.userJwt}`),e.permission&&(this.headers["X-Widget-Permission"]=e.permission)}updateConfig(e){e.baseUrl&&(this.baseUrl=e.baseUrl.replace(/\/$/,"")),e.widgetId&&(this.headers["X-Widget-Id"]=e.widgetId),e.userEmail&&(this.headers["X-User-Email"]=e.userEmail),e.userJwt&&(this.headers.Authorization=`Bearer ${e.userJwt}`),e.permission!==void 0&&(e.permission?this.headers["X-Widget-Permission"]=e.permission:delete this.headers["X-Widget-Permission"])}async get(e){return this.request("GET",e)}async post(e,t){return this.request("POST",e,t)}async postStream(e,t){const s=`${this.baseUrl}${e}`;i.debug("POST (stream)",s,t);try{const r=await fetch(s,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0});return r.ok||await this.handleErrorResponse(r),r}catch(r){throw r instanceof h?r:new d(`Network error: ${r instanceof Error?r.message:"Unknown error"}`,r instanceof Error?r:void 0)}}async postFormData(e,t){const s=`${this.baseUrl}${e}`;i.debug("POST (formData)",s);const r={...this.headers};try{const n=await fetch(s,{method:"POST",headers:r,body:t});return n.ok||await this.handleErrorResponse(n),n}catch(n){throw n instanceof h?n:new d(`Network error: ${n instanceof Error?n.message:"Unknown error"}`,n instanceof Error?n:void 0)}}async request(e,t,s){const r=`${this.baseUrl}${t}`;i.debug(e,r,s);try{const n=await fetch(r,{method:e,headers:{...this.headers,"Content-Type":"application/json"},body:s?JSON.stringify(s):void 0});return n.ok||await this.handleErrorResponse(n),n.status===204?void 0:n.json()}catch(n){throw n instanceof h?n:new d(`Network error: ${n instanceof Error?n.message:"Unknown error"}`,n instanceof Error?n:void 0)}}async handleErrorResponse(e){let t;try{t=await e.json()}catch{}throw t?.error?h.fromResponse(t,e.status):new h(`HTTP ${e.status}: ${e.statusText}`,"http_error",e.status,"api_error")}},y=class{constructor(){this.functions=new Map}register(e,t,s){if(typeof e=="object"){const{name:n,handler:o,description:a,parameters:c}=e;return this.register(n,o,{description:a,parameters:c})}const r=e;if(!t||!s)throw new Error("handler and schema are required");this.functions.has(r)&&i.warn(`Function "${r}" is being overwritten`),this.functions.set(r,{schema:{...s,name:r},handler:t}),i.log(`Registered function: ${r}`)}unregister(e){const t=this.functions.delete(e);return t&&i.log(`Unregistered function: ${e}`),t}get(e){return this.functions.get(e)}has(e){return this.functions.has(e)}getSchemas(){return Array.from(this.functions.values()).map(e=>e.schema)}async execute(e,t){const s=this.functions.get(e);if(!s)throw new m(`Function "${e}" is not registered`,e);i.log(`Executing function: ${e}`,t);try{const r=await s.handler(t);return i.log(`Function ${e} completed:`,r),r}catch(r){throw i.error(`Function ${e} failed:`,r),new m(`Function "${e}" execution failed: ${r instanceof Error?r.message:"Unknown error"}`,e,r instanceof Error?r:void 0)}}clear(){this.functions.clear(),i.log("Cleared all registered functions")}get size(){return this.functions.size}},w=class{constructor(){this.entries=new Map,this.dynamicProviders=new Map}set(e,t){this.entries.set(e,t),i.log(`ClientContext set: ${e}`)}remove(e){const t=this.entries.delete(e);return t&&i.log(`ClientContext removed: ${e}`),t}addDynamicProvider(e,t){this.dynamicProviders.set(e,t),i.log(`DynamicContext provider added: ${e}`)}removeDynamicProvider(e){const t=this.dynamicProviders.delete(e);return t&&i.log(`DynamicContext provider removed: ${e}`),t}getSnapshot(){if(this.entries.size===0&&this.dynamicProviders.size===0)return null;const e={};for(const[t,s]of this.entries)e[t]=s;for(const[t,s]of this.dynamicProviders)try{const r=s();r&&(e[t]=r)}catch(r){i.error(`DynamicContext provider "${t}" threw:`,r)}return Object.keys(e).length===0?null:{entries:e}}clear(){this.entries.clear(),this.dynamicProviders.clear(),i.log("ClientContext cleared")}},v=class{constructor(e){this.callbacks=e,this.buffer="",this.message={},this.toolCalls=[],this.sources=[],this.followUpReplies=[],this.isFirstChunk=!0,this.answerCompleteEmitted=!1}async processStream(e){if(!e.body)throw new g("Response has no body");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:r,value:n}=await t.read();if(r)break;const o=s.decode(n,{stream:!0});this.buffer+=o,this.processBuffer()}return this.buffer.trim()&&this.processBuffer(),this.buildFinalMessage()}catch(r){const n=r instanceof Error?r:new g("Stream processing failed");throw this.callbacks.onError?.(n),n}finally{t.releaseLock()}}processBuffer(){const e=this.buffer.split(`
2
+
3
+ `);this.buffer=e.pop()||"";for(const t of e){if(!t.trim())continue;const s=t.split(`
4
+ `);for(const r of s)if(!r.startsWith(": ")&&r.startsWith("data: ")){const n=r.slice(6);try{const o=JSON.parse(n);this.handleChunk(o)}catch(o){i.warn("Failed to parse SSE data:",n,o)}}}}handleChunk(e){if(e.message_id&&!this.message.id&&(this.message.id=e.message_id),e.thread?.id&&(this.message.conversationId=e.thread.id,this.isFirstChunk&&this.message.id&&(this.isFirstChunk=!1,this.callbacks.onStart?.({conversationId:this.message.conversationId,messageId:this.message.id}))),e.content!==void 0&&(this.message.content=(this.message.content||"")+e.content,this.message.conversationId&&this.message.id&&this.callbacks.onChunk?.({content:e.content,conversationId:this.message.conversationId,messageId:this.message.id})),e.full_content!==void 0&&(this.message.content=e.full_content),e.status&&(this.message.status=e.status),e.agent&&(this.message.agent={id:e.agent.id,name:e.agent.name,displayName:e.agent.display_name}),e.knowledge_sources&&(this.sources=e.knowledge_sources.map(t=>{const s=t.knowledge_document;return{id:s.id,title:s.title,url:s.use_external_link?s.external_link_url:s.internal_link_url}})),e.type==="client_function"&&e.function_name&&this.callbacks.onClientFunction?.({invocationId:e.id||"",functionName:e.function_name,arguments:e.arguments||{},conversationId:this.message.conversationId||""}),e.tool_call_data&&e.type&&e.type!=="client_function"){const t=this.parseToolCall(e);this.callbacks.onToolCall?.(t);const s=this.toolCalls.findIndex(r=>r.id===t.id);s>=0?this.toolCalls[s]=t:this.toolCalls.push(t)}e.follow_up_replies&&(this.followUpReplies=e.follow_up_replies),this.message.status==="DONE"&&!this.answerCompleteEmitted&&this.message.id&&(this.answerCompleteEmitted=!0,this.callbacks.onAnswerComplete?.(this.buildMessage()))}parseToolCall(e){return{id:e.id||"",type:e.type||"status_message",status:e.status||"unknown",toolName:e.tool_name||"",toolDisplayName:e.tool_display_name,message:e.message,formSchema:e.form_schema,data:e.data,functionName:e.function_name,arguments:e.arguments}}buildMessage(){return{id:this.message.id||"",conversationId:this.message.conversationId||"",content:this.message.content||"",role:"assistant",status:this.message.status||"DONE",agent:this.message.agent,sources:this.sources.length>0?this.sources:void 0,toolCalls:this.toolCalls.length>0?this.toolCalls:void 0,followUpReplies:this.followUpReplies.length>0?this.followUpReplies:void 0,createdAt:new Date}}buildFinalMessage(){const e=this.buildMessage();return this.callbacks.onComplete?.(e),e}};function x(e){const t=e.message.toLowerCase();return t.includes("load failed")||t.includes("failed to fetch")||t.includes("network")||t.includes("abort")}var C=class{constructor(){this.handlers=new Map}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t)}off(e,t){const s=this.handlers.get(e);s&&s.delete(t)}emit(e,t){const s=this.handlers.get(e);s&&s.forEach(r=>{try{r(t)}catch(n){console.error(`Error in event handler for ${String(e)}:`,n)}})}once(e,t){const s=(r=>{this.off(e,s),t(r)});this.on(e,s)}waitFor(e,t){return new Promise((s,r)=>{let n;const o=(a=>{n&&clearTimeout(n),s(a)});this.once(e,o),t?.timeout&&(n=setTimeout(()=>{this.off(e,o),r(new Error(`waitFor("${String(e)}") timed out after ${t.timeout}ms`))},t.timeout))})}removeAllListeners(e){e?this.handlers.delete(e):this.handlers.clear()}},A=class b{constructor(t){this.config=t,this.httpClient=new k(t),this.functionRegistry=new y,this.contextRegistry=new w,this.eventEmitter=new C,t.debug&&i.enable(),i.log("AgoClient initialized")}async sendMessage(t,s){const r=this.functionRegistry.getSchemas(),n=this.contextRegistry.getSnapshot(),o=this.config.agent||this.config.defaultAgentId,a={content:t,conversation_id:s?.conversationId,agent_id:s?.agentId||o};r.length>0&&(a.client_functions=r),n&&(a.client_context=n);let c;if(s?.files&&s.files.length>0){const l=new FormData;l.append("content",t),s.conversationId&&l.append("conversation_id",s.conversationId),(s.agentId||o)&&l.append("agent_id",s.agentId||o||""),r.length>0&&l.append("client_functions",JSON.stringify(r)),n&&l.append("client_context",JSON.stringify(n));for(const E of s.files)l.append("files",E);c=await this.httpClient.postFormData("/api/sdk/v1/messages",l)}else c=await this.httpClient.postStream("/api/sdk/v1/messages",a);return this.processSSEResponse(c)}async processSSEResponse(t){return new v({onStart:s=>{this.eventEmitter.emit("message:start",s)},onChunk:s=>{this.eventEmitter.emit("message:chunk",s)},onToolCall:s=>{this.eventEmitter.emit("toolCall:received",s),s.type==="form"&&this.eventEmitter.emit("toolCall:form",s)},onClientFunction:async s=>{this.eventEmitter.emit("function:invoke",s),await this.handleClientFunctionInvocation(s)},onAnswerComplete:s=>{this.eventEmitter.emit("message:answer-complete",s)},onComplete:s=>{this.eventEmitter.emit("message:complete",s)},onError:s=>{this.eventEmitter.emit("message:error",{error:s.message})}}).processStream(t)}async handleClientFunctionInvocation(t){let s,r;try{s=await this.functionRegistry.execute(t.functionName,t.arguments)}catch(n){r=n instanceof Error?n.message:"Unknown error",i.error("Client function execution failed:",n)}if(t.invocationId)try{await this.submitToolCallForm(t.invocationId,{result:s,error:r,_type:"client_function_result"})}catch(n){i.error("Failed to submit function result:",n)}this.eventEmitter.emit("function:result",{invocationId:t.invocationId,result:s,error:r})}async getConversations(){return(await this.httpClient.get("/api/sdk/v1/conversations")).items.map(t=>({id:t.id,title:t.title,lastMessageDate:new Date(t.last_message_date)}))}async getConversation(t){const s=await this.httpClient.get(`/api/sdk/v1/conversations/${t}`),r={id:s.id,title:s.title,lastMessageDate:new Date(s.last_message_date),messages:s.messages.map(n=>({id:n.id,conversationId:s.id,content:n.content,role:n.role,status:n.status,createdAt:new Date(n.created_at),toolCalls:b.mapPersistedToolCalls(n.tool_call_data)}))};return this.eventEmitter.emit("conversation:loaded",r),r}static mapPersistedToolCalls(t){if(!(!t||t.length===0))return t.map(s=>({id:String(s.id??""),type:s.type??"status_message",status:String(s.status??"unknown"),toolName:s.tool_name??"",toolDisplayName:s.tool_display_name,message:s.message,formSchema:s.form_schema,data:s.data,functionName:s.function_name,arguments:s.arguments}))}async getMessages(t){return(await this.getConversation(t)).messages||[]}async submitToolCallForm(t,s){await this.httpClient.post(`/api/sdk/v1/tool-calls/${t}/submit`,{formData:s})}async confirmToolCall(t){await this.httpClient.post(`/api/tool-calls/${t}/confirm/`)}async rejectToolCall(t){await this.httpClient.post(`/api/tool-calls/${t}/reject/`)}async submitFormCollector(t,s){return this.httpClient.post("/api/sdk/v1/forms/submit",{destination:t,values:s})}async submitFeedback(t,s){await this.httpClient.post(`/api/sdk/v1/messages/${t}/feedback`,{rating:s})}registerFunction(t,s,r){typeof t=="object"?this.functionRegistry.register(t):this.functionRegistry.register(t,s,r)}register(t){if(Array.isArray(t))for(const s of t)this.functionRegistry.register(s);else this.functionRegistry.register(t)}unregisterFunction(t){return this.functionRegistry.unregister(t)}getRegisteredFunctions(){return this.functionRegistry.getSchemas()}registerNavigationFunction(t,s){const r=s.map(o=>o.name),n=s.map(o=>`- "${o.name}": ${o.description}`).join(`
5
+ `);this.registerFunction("navigateToPage",async o=>{const a=o.page,c=s.find(l=>l.name===a);return c?(t(c.path),{success:!0,navigatedTo:c.path}):{success:!1,error:`Unknown page: ${a}`}},{description:`Navigate the user to a page in the application. Available pages:
6
+ ${n}`,parameters:{type:"object",properties:{page:{type:"string",description:"The page to navigate to",enum:r}},required:["page"]}})}setContext(t,s){this.contextRegistry.set(t,s),this.notifyContextChanged()}removeContext(t){const s=this.contextRegistry.remove(t);return s&&this.notifyContextChanged(),s}addDynamicContext(t,s){this.contextRegistry.addDynamicProvider(t,s),this.notifyContextChanged()}removeDynamicContext(t){const s=this.contextRegistry.removeDynamicProvider(t);return s&&this.notifyContextChanged(),s}notifyContextChanged(){this.eventEmitter.emit("context:changed",this.contextRegistry.getSnapshot())}enableAutoPageContext(){this.addDynamicContext("browser-page",()=>{const t=typeof window<"u"?window.location.href:void 0,s=typeof document<"u"?document.title:void 0;return!t&&!s?null:{name:"Browser page",description:"Current page the user is viewing",data:{url:t,title:s}}})}getContextSnapshot(){return this.contextRegistry.getSnapshot()}on(t,s){this.eventEmitter.on(t,s)}off(t,s){this.eventEmitter.off(t,s)}once(t,s){this.eventEmitter.once(t,s)}waitFor(t,s){return this.eventEmitter.waitFor(t,s)}updateConfig(t){this.config={...this.config,...t},this.httpClient.updateConfig(t),t.debug!==void 0&&(t.debug?i.enable():i.disable())}destroy(){this.eventEmitter.removeAllListeners(),this.functionRegistry.clear(),this.contextRegistry.clear(),i.log("AgoClient destroyed")}};Object.defineProperty(exports,"AgoApiError",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"AgoClient",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"AgoError",{enumerable:!0,get:function(){return u}});Object.defineProperty(exports,"AgoFunctionError",{enumerable:!0,get:function(){return m}});Object.defineProperty(exports,"AgoNetworkError",{enumerable:!0,get:function(){return d}});Object.defineProperty(exports,"AgoStreamError",{enumerable:!0,get:function(){return g}});Object.defineProperty(exports,"ClientContextRegistry",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"EventEmitter",{enumerable:!0,get:function(){return C}});Object.defineProperty(exports,"FunctionRegistry",{enumerable:!0,get:function(){return y}});Object.defineProperty(exports,"SSEHandler",{enumerable:!0,get:function(){return v}});Object.defineProperty(exports,"isStreamNetworkError",{enumerable:!0,get:function(){return x}});Object.defineProperty(exports,"logger",{enumerable:!0,get:function(){return i}});
package/dist/angular.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AgoClient-D4EL6nva.cjs");var n=class{constructor(e){this.client=new o.AgoClient(e),this.messages$=this.fromEvent("message:complete"),this.chunks$=this.fromEvent("message:chunk"),this.errors$=this.fromEvent("message:error"),this.messageStart$=this.fromEvent("message:start")}fromEvent(e){const t=this.client;return{subscribe(i){const s=r=>{i.next?.(r)};return t.on(e,s),{unsubscribe:()=>t.off(e,s)}}}}sendMessage(e,t){return this.client.sendMessage(e,t)}getConversations(){return this.client.getConversations()}getConversation(e){return this.client.getConversation(e)}getMessages(e){return this.client.getMessages(e)}submitToolCallForm(e,t){return this.client.submitToolCallForm(e,t)}confirmToolCall(e){return this.client.confirmToolCall(e)}rejectToolCall(e){return this.client.rejectToolCall(e)}submitFeedback(e,t){return this.client.submitFeedback(e,t)}registerFunction(e,t,i){typeof e=="object"?this.client.registerFunction(e):this.client.registerFunction(e,t,i)}unregisterFunction(e){return this.client.unregisterFunction(e)}registerNavigationFunction(e,t){this.client.registerNavigationFunction(e,t)}on(e,t){this.client.on(e,t)}off(e,t){this.client.off(e,t)}updateConfig(e){this.client.updateConfig(e)}getClient(){return this.client}destroy(){this.client.destroy()}};function c(e){return{provide:n,useValue:new n(e)}}exports.AgoService=n;exports.provideAgo=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AgoClient-CPqPT5s6.cjs");var n=class{constructor(e){this.client=new o.AgoClient(e),this.messages$=this.fromEvent("message:complete"),this.chunks$=this.fromEvent("message:chunk"),this.errors$=this.fromEvent("message:error"),this.messageStart$=this.fromEvent("message:start")}fromEvent(e){const t=this.client;return{subscribe(i){const s=r=>{i.next?.(r)};return t.on(e,s),{unsubscribe:()=>t.off(e,s)}}}}sendMessage(e,t){return this.client.sendMessage(e,t)}getConversations(){return this.client.getConversations()}getConversation(e){return this.client.getConversation(e)}getMessages(e){return this.client.getMessages(e)}submitToolCallForm(e,t){return this.client.submitToolCallForm(e,t)}confirmToolCall(e){return this.client.confirmToolCall(e)}rejectToolCall(e){return this.client.rejectToolCall(e)}submitFeedback(e,t){return this.client.submitFeedback(e,t)}registerFunction(e,t,i){typeof e=="object"?this.client.registerFunction(e):this.client.registerFunction(e,t,i)}unregisterFunction(e){return this.client.unregisterFunction(e)}registerNavigationFunction(e,t){this.client.registerNavigationFunction(e,t)}on(e,t){this.client.on(e,t)}off(e,t){this.client.off(e,t)}updateConfig(e){this.client.updateConfig(e)}getClient(){return this.client}destroy(){this.client.destroy()}};function c(e){return{provide:n,useValue:new n(e)}}exports.AgoService=n;exports.provideAgo=c;
@@ -216,6 +216,11 @@ export declare interface AgoClientEvents {
216
216
  conversationId: string;
217
217
  messageId: string;
218
218
  };
219
+ /**
220
+ * The main answer text is done (backend emitted `status: "DONE"`), but follow-up
221
+ * replies may still be pending. Fires once, before `message:complete`.
222
+ */
223
+ "message:answer-complete": AgoMessage;
219
224
  "message:complete": AgoMessage;
220
225
  "message:error": {
221
226
  error: string;
package/dist/angular.d.ts CHANGED
@@ -216,6 +216,11 @@ export declare interface AgoClientEvents {
216
216
  conversationId: string;
217
217
  messageId: string;
218
218
  };
219
+ /**
220
+ * The main answer text is done (backend emitted `status: "DONE"`), but follow-up
221
+ * replies may still be pending. Fires once, before `message:complete`.
222
+ */
223
+ "message:answer-complete": AgoMessage;
219
224
  "message:complete": AgoMessage;
220
225
  "message:error": {
221
226
  error: string;
package/dist/angular.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as o } from "./AgoClient-rvTz2thR.js";
1
+ import { t as o } from "./AgoClient-BrYhSO5M.js";
2
2
  var n = class {
3
3
  constructor(t) {
4
4
  this.client = new o(t), this.messages$ = this.fromEvent("message:complete"), this.chunks$ = this.fromEvent("message:chunk"), this.errors$ = this.fromEvent("message:error"), this.messageStart$ = this.fromEvent("message:start");
@@ -1 +1 @@
1
- const d=require("./createFormCollector-IO6bfPQx.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
1
+ const d=require("./createFormCollector-DaWZsBsI.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
@@ -1,4 +1,4 @@
1
- import { r as d } from "./createFormCollector-DON4vdJV.js";
1
+ import { r as d } from "./createFormCollector-CPS2phYq.js";
2
2
  var f = "ago_widget_id", g = "ago_last_thread", y = 7200 * 1e3;
3
3
  function v() {
4
4
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {