aov-agent 1.0.0 → 1.0.6
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/README.md +313 -1
- package/dist/agent-ui/components/Assistant/AgentButton/AgentButton.js +28 -0
- package/dist/agent-ui/components/Assistant/AgentButton/AgentButton.scss +40 -0
- package/dist/agent-ui/components/Assistant/Assistant.js +68 -0
- package/dist/agent-ui/components/Assistant/Assistant.scss +3 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/AssistantWidget.js +193 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/AssistantWidget.scss +205 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/components/CampaignRendered.js +30 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/components/ListChat.js +129 -0
- package/dist/agent-ui/components/Assistant/Markdown/MarkdownText.js +228 -0
- package/dist/agent-ui/components/Assistant/Markdown/MarkdownText.scss +222 -0
- package/dist/agent-ui/components/Assistant/Markdown/MathRenderer.js +52 -0
- package/dist/agent-ui/components/Assistant/Suggestions/Suggestions.js +62 -0
- package/dist/agent-ui/components/Assistant/Suggestions/Suggestions.scss +22 -0
- package/dist/agent-ui/components/Assistant/ThreadProvider.js +481 -0
- package/dist/agent-ui/components/Assistant/ToolResult/CardTool.js +98 -0
- package/dist/agent-ui/components/Assistant/ToolResult/CardTool.scss +12 -0
- package/dist/agent-ui/components/Assistant/ToolResult/ToolResult.js +44 -0
- package/dist/agent-ui/components/CopyToClipboard/CopyToClipboard.js +43 -0
- package/dist/agent-ui/components/CopyToClipboard/index.js +2 -0
- package/dist/agent-ui/components/ResizableModal/ResizableModal.js +262 -0
- package/dist/agent-ui/components/ResizableModal/ResizableModal.scss +117 -0
- package/dist/agent-ui/const/appName.js +6 -0
- package/dist/agent-ui/const/option.js +9 -0
- package/dist/agent-ui/const/toolName.js +6 -0
- package/dist/agent-ui/contexts/AgentContext.js +54 -0
- package/dist/agent-ui/contexts/SuggestionsContext.js +64 -0
- package/dist/agent-ui/contexts/ThreadContext.js +60 -0
- package/dist/agent-ui/helpers/copyToClipboard.js +33 -0
- package/dist/agent-ui/helpers/formatQuery.js +15 -0
- package/dist/agent-ui/hooks/useFetchApi.js +238 -0
- package/dist/agent-ui/hooks/useStreamApi.js +127 -0
- package/dist/agent-ui/index.js +1 -0
- package/dist/agent-ui/resources/assistant-avatar.svg +51 -0
- package/dist/agent-ui/services/errorService.js +39 -0
- package/dist/agent-ui/utils/api.js +164 -0
- package/package.json +44 -9
- package/dist/index.js +0 -7
- package/types/index.d.ts +0 -5
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
var isFormData = function isFormData(value) {
|
|
6
|
+
return value instanceof FormData;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {string} uri
|
|
12
|
+
* @param {Object} options
|
|
13
|
+
* @param {Object} clientConfig
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export var fetchAuthenticateApi = /*#__PURE__*/function () {
|
|
17
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
18
|
+
var uri, _ref$options, options, _ref$clientConfig, clientConfig, response;
|
|
19
|
+
return _regenerator().w(function (_context) {
|
|
20
|
+
while (1) switch (_context.n) {
|
|
21
|
+
case 0:
|
|
22
|
+
uri = _ref.uri, _ref$options = _ref.options, options = _ref$options === void 0 ? {} : _ref$options, _ref$clientConfig = _ref.clientConfig, clientConfig = _ref$clientConfig === void 0 ? {
|
|
23
|
+
baseURL: "/api"
|
|
24
|
+
} : _ref$clientConfig;
|
|
25
|
+
if (options !== null && options !== void 0 && options.body && !isFormData(options.body)) {
|
|
26
|
+
options.body = JSON.stringify(options.body);
|
|
27
|
+
options.headers = options.headers || {};
|
|
28
|
+
options.headers["Content-Type"] = "application/json";
|
|
29
|
+
}
|
|
30
|
+
_context.n = 1;
|
|
31
|
+
return fetch(clientConfig.baseURL + uri, options);
|
|
32
|
+
case 1:
|
|
33
|
+
response = _context.v;
|
|
34
|
+
_context.n = 2;
|
|
35
|
+
return response.json();
|
|
36
|
+
case 2:
|
|
37
|
+
return _context.a(2, _context.v);
|
|
38
|
+
}
|
|
39
|
+
}, _callee);
|
|
40
|
+
}));
|
|
41
|
+
return function fetchAuthenticateApi(_x) {
|
|
42
|
+
return _ref2.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
}();
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} options.data
|
|
49
|
+
* @param {string} options.method
|
|
50
|
+
* @param {function} options.onChunk
|
|
51
|
+
* @param {AbortSignal} options.signal
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export var streamApi = /*#__PURE__*/function () {
|
|
55
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3) {
|
|
56
|
+
var apiUrl, _ref3$data, data, _ref3$method, method, onChunk, signal, idToken, fullUrl, resp, text, reader, decoder, accumulated, readResult, _readResult, value, done, str, _t;
|
|
57
|
+
return _regenerator().w(function (_context2) {
|
|
58
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
59
|
+
case 0:
|
|
60
|
+
apiUrl = _ref3.apiUrl, _ref3$data = _ref3.data, data = _ref3$data === void 0 ? {} : _ref3$data, _ref3$method = _ref3.method, method = _ref3$method === void 0 ? "POST" : _ref3$method, onChunk = _ref3.onChunk, signal = _ref3.signal;
|
|
61
|
+
_context2.n = 1;
|
|
62
|
+
return window.shopify.idToken();
|
|
63
|
+
case 1:
|
|
64
|
+
idToken = _context2.v;
|
|
65
|
+
fullUrl = apiUrl ? "".concat(apiUrl, "/api-public/chat/message") : "/api-public/chat/message";
|
|
66
|
+
_context2.n = 2;
|
|
67
|
+
return fetch(fullUrl, {
|
|
68
|
+
method: method,
|
|
69
|
+
headers: {
|
|
70
|
+
accept: "text/event-stream",
|
|
71
|
+
"Content-Type": "application/json",
|
|
72
|
+
Connection: "keep-alive",
|
|
73
|
+
"Cache-Control": "no-cache",
|
|
74
|
+
Authorization: "Bearer ".concat(idToken),
|
|
75
|
+
"X-Auth-Token": idToken
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify(data),
|
|
78
|
+
signal: signal
|
|
79
|
+
});
|
|
80
|
+
case 2:
|
|
81
|
+
resp = _context2.v;
|
|
82
|
+
if (!(!resp.body || !resp.body.getReader)) {
|
|
83
|
+
_context2.n = 4;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
_context2.n = 3;
|
|
87
|
+
return resp.text();
|
|
88
|
+
case 3:
|
|
89
|
+
text = _context2.v;
|
|
90
|
+
if (onChunk) {
|
|
91
|
+
onChunk({
|
|
92
|
+
currentTarget: {
|
|
93
|
+
response: text,
|
|
94
|
+
responseText: text
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return _context2.a(2, text);
|
|
99
|
+
case 4:
|
|
100
|
+
reader = resp.body.getReader();
|
|
101
|
+
decoder = new TextDecoder();
|
|
102
|
+
accumulated = "";
|
|
103
|
+
_context2.p = 5;
|
|
104
|
+
case 6:
|
|
105
|
+
if (!true) {
|
|
106
|
+
_context2.n = 13;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
readResult = void 0;
|
|
110
|
+
_context2.p = 7;
|
|
111
|
+
_context2.n = 8;
|
|
112
|
+
return reader.read();
|
|
113
|
+
case 8:
|
|
114
|
+
readResult = _context2.v;
|
|
115
|
+
_context2.n = 11;
|
|
116
|
+
break;
|
|
117
|
+
case 9:
|
|
118
|
+
_context2.p = 9;
|
|
119
|
+
_t = _context2.v;
|
|
120
|
+
console.warn("AbortError", _t);
|
|
121
|
+
if (!((_t === null || _t === void 0 ? void 0 : _t.name) === "AbortError" || signal !== null && signal !== void 0 && signal.aborted)) {
|
|
122
|
+
_context2.n = 10;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
return _context2.a(3, 13);
|
|
126
|
+
case 10:
|
|
127
|
+
throw _t;
|
|
128
|
+
case 11:
|
|
129
|
+
_readResult = readResult, value = _readResult.value, done = _readResult.done;
|
|
130
|
+
if (!done) {
|
|
131
|
+
_context2.n = 12;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
return _context2.a(3, 13);
|
|
135
|
+
case 12:
|
|
136
|
+
str = decoder.decode(value, {
|
|
137
|
+
stream: true
|
|
138
|
+
});
|
|
139
|
+
accumulated += str;
|
|
140
|
+
if (onChunk) {
|
|
141
|
+
onChunk({
|
|
142
|
+
currentTarget: {
|
|
143
|
+
response: accumulated,
|
|
144
|
+
responseText: accumulated
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
_context2.n = 6;
|
|
149
|
+
break;
|
|
150
|
+
case 13:
|
|
151
|
+
_context2.p = 13;
|
|
152
|
+
try {
|
|
153
|
+
reader.releaseLock();
|
|
154
|
+
} catch (_unused) {}
|
|
155
|
+
return _context2.f(13);
|
|
156
|
+
case 14:
|
|
157
|
+
return _context2.a(2, accumulated);
|
|
158
|
+
}
|
|
159
|
+
}, _callee2, null, [[7, 9], [5,, 13, 14]]);
|
|
160
|
+
}));
|
|
161
|
+
return function streamApi(_x2) {
|
|
162
|
+
return _ref4.apply(this, arguments);
|
|
163
|
+
};
|
|
164
|
+
}();
|
package/package.json
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aov-agent",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "AOV Agent",
|
|
5
|
-
"main": "dist/index.js",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "AOV AI Agent - Monorepo for AI Assistant Components",
|
|
6
5
|
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./agent-ui": "./dist/agent-ui/index.js",
|
|
8
|
+
"./agent-ui/*": "./dist/agent-ui/*"
|
|
9
|
+
},
|
|
10
|
+
"workspaces": [
|
|
11
|
+
"packages/*"
|
|
12
|
+
],
|
|
7
13
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"build
|
|
14
|
+
"dev": "npm run dev --workspace=@aov/admin",
|
|
15
|
+
"build": "npm run build:ui && npm run build --workspace=@aov/admin",
|
|
16
|
+
"build:ui": "npm run build --workspace=@aov/agent-ui",
|
|
17
|
+
"build:watch": "npm run build:watch --workspace=@aov/agent-ui",
|
|
18
|
+
"start": "npm run start --workspace=@aov/admin",
|
|
19
|
+
"clean": "rimraf dist && npm run clean --workspaces --if-present",
|
|
20
|
+
"lint": "npm run lint --workspaces --if-present",
|
|
21
|
+
"test": "npm run test --workspaces --if-present",
|
|
22
|
+
"install:all": "npm install && npm install --workspaces",
|
|
23
|
+
"prepublishOnly": "npm run clean && npm run build:ui",
|
|
24
|
+
"publish:patch": "npm run clean && npm run build:ui && npm version patch --force && npm publish",
|
|
25
|
+
"publish:minor": "npm run clean && npm run build:ui && npm version minor --force && npm publish",
|
|
26
|
+
"publish:major": "npm run clean && npm run build:ui && npm version major --force && npm publish"
|
|
10
27
|
},
|
|
11
28
|
"repository": {
|
|
12
29
|
"type": "git",
|
|
@@ -14,7 +31,12 @@
|
|
|
14
31
|
},
|
|
15
32
|
"keywords": [
|
|
16
33
|
"AOV",
|
|
17
|
-
"Agent"
|
|
34
|
+
"Agent",
|
|
35
|
+
"AI",
|
|
36
|
+
"Assistant",
|
|
37
|
+
"React",
|
|
38
|
+
"UI Components",
|
|
39
|
+
"Shopify"
|
|
18
40
|
],
|
|
19
41
|
"author": "AOV.ai",
|
|
20
42
|
"license": "ISC",
|
|
@@ -26,13 +48,26 @@
|
|
|
26
48
|
"@babel/cli": "^7.28.3",
|
|
27
49
|
"@babel/core": "^7.28.5",
|
|
28
50
|
"@babel/preset-env": "^7.28.5",
|
|
29
|
-
"@babel/preset-
|
|
51
|
+
"@babel/preset-react": "^7.28.0",
|
|
52
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
53
|
+
"concurrently": "^9.2.1",
|
|
54
|
+
"cpx": "^1.5.0",
|
|
55
|
+
"rimraf": "^5.0.10"
|
|
30
56
|
},
|
|
31
57
|
"files": [
|
|
32
|
-
"dist"
|
|
33
|
-
"types"
|
|
58
|
+
"dist"
|
|
34
59
|
],
|
|
35
60
|
"publishConfig": {
|
|
36
61
|
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@google-cloud/firestore": "^8.0.0",
|
|
65
|
+
"@types/node": "^25.0.3",
|
|
66
|
+
"@types/react": "^19.2.7",
|
|
67
|
+
"@types/react-dom": "^19.2.3",
|
|
68
|
+
"next": "^16.1.1",
|
|
69
|
+
"sass": "^1.97.1",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"zod": "^4.2.1"
|
|
37
72
|
}
|
|
38
73
|
}
|
package/dist/index.js
DELETED