@bigbinary/neeto-assist-frontend 1.2.1 → 1.3.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.
- package/README.md +430 -21
- package/app/javascript/src/translations/en.json +39 -2
- package/dist/.ready +1 -1
- package/dist/NeetoAssistButton.js +13 -6
- package/dist/NeetoAssistButton.js.map +1 -1
- package/dist/NeetoAssistPane.js +1469 -166
- package/dist/NeetoAssistPane.js.map +1 -1
- package/dist/cjs/NeetoAssistButton.js +16 -9
- package/dist/cjs/NeetoAssistButton.js.map +1 -1
- package/dist/cjs/NeetoAssistPane.js +1491 -188
- package/dist/cjs/NeetoAssistPane.js.map +1 -1
- package/dist/cjs/index.js +11 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/useNeetoAssistAssistant.js +43 -0
- package/dist/cjs/useNeetoAssistAssistant.js.map +1 -0
- package/dist/cjs/useNeetoAssistStatus.js +3 -1
- package/dist/cjs/useNeetoAssistStatus.js.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/neeto_assist-COp7BR77.js +249 -0
- package/dist/neeto_assist-COp7BR77.js.map +1 -0
- package/dist/neeto_assist-D1wzZ3ou.js +219 -0
- package/dist/neeto_assist-D1wzZ3ou.js.map +1 -0
- package/dist/useNeetoAssistAssistant.js +41 -0
- package/dist/useNeetoAssistAssistant.js.map +1 -0
- package/dist/useNeetoAssistStatus.js +3 -1
- package/dist/useNeetoAssistStatus.js.map +1 -1
- package/dist/useNeetoAssistStore-Bj6niQdc.js +103 -0
- package/dist/useNeetoAssistStore-Bj6niQdc.js.map +1 -0
- package/dist/useNeetoAssistStore-Dgt8aV52.js +101 -0
- package/dist/useNeetoAssistStore-Dgt8aV52.js.map +1 -0
- package/dist/{useNeetoAssistStore-InICsbe8.js → useRunsApi-BgsICthX.js} +228 -113
- package/dist/useRunsApi-BgsICthX.js.map +1 -0
- package/dist/{useNeetoAssistStore-VaZp3268.js → useRunsApi-Rh6xXOwm.js} +232 -112
- package/dist/useRunsApi-Rh6xXOwm.js.map +1 -0
- package/package.json +4 -4
- package/types.d.ts +81 -8
- package/dist/neeto_assist-CpUBA-3Z.js +0 -135
- package/dist/neeto_assist-CpUBA-3Z.js.map +0 -1
- package/dist/neeto_assist-CznTN_YY.js +0 -157
- package/dist/neeto_assist-CznTN_YY.js.map +0 -1
- package/dist/useNeetoAssistStore-InICsbe8.js.map +0 -1
- package/dist/useNeetoAssistStore-VaZp3268.js.map +0 -1
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import
|
|
5
|
-
import { useMutationWithInvalidation, withImmutableActions } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
6
|
-
import { E as ERROR_MESSAGE_KEYS, P as PENDING_STATUSES, S as SKIPPED_REASON_MESSAGE_KEYS, R as RATEABLE_STATUSES, U as UNRATEABLE_SKIPPED_REASONS, a as REPLY_SUGGESTION, b as QUIET_SKIPPED_REASONS, n as neetoAssistApi, Q as QUERY_KEYS, c as PENDING_POLL_INTERVAL, I as IDLE_POLL_INTERVAL, d as EXPANDED_STORAGE_KEY } from './neeto_assist-CpUBA-3Z.js';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
7
5
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
7
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
8
|
+
import { useQueryClient, useMutation, useQuery, useIsMutating } from '@tanstack/react-query';
|
|
9
|
+
import { existsById } from '@bigbinary/neeto-cist';
|
|
10
|
+
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
11
|
+
import { A as ASSISTANT_ERROR_MESSAGE_KEYS, a as ERROR_MESSAGE_KEYS, b as PENDING_STATUSES, S as SKIPPED_REASON_MESSAGE_KEYS, c as STOPPED_STATUS, R as RATEABLE_STATUSES, U as UNRATEABLE_SKIPPED_REASONS, L as LOOKUP_SOURCE_KIND, d as SOURCE_KIND_KEYS, D as DEFAULT_SOURCE_KIND, e as REPLY_SUGGESTION, f as QUIET_SKIPPED_REASONS, n as neetoAssistApi, Q as QUERY_KEYS, P as PANE_MODES, g as PENDING_POLL_INTERVAL, I as IDLE_POLL_INTERVAL } from './neeto_assist-D1wzZ3ou.js';
|
|
8
12
|
import _toArray from '@babel/runtime/helpers/toArray';
|
|
9
13
|
import { isEmpty, any, propEq, propOr, reverse } from 'ramda';
|
|
10
|
-
import { setToLocalStorage, getFromLocalStorage } from '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
11
|
-
import { create } from 'zustand';
|
|
12
14
|
|
|
13
15
|
var _excluded = ["size", "className"];
|
|
14
|
-
function ownKeys$
|
|
15
|
-
function _objectSpread$
|
|
16
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
18
|
var Sparkle = function Sparkle(_ref) {
|
|
17
19
|
var _ref$size = _ref.size,
|
|
18
20
|
size = _ref$size === void 0 ? 18 : _ref$size,
|
|
19
21
|
className = _ref.className,
|
|
20
22
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
-
return /*#__PURE__*/jsxs("svg", _objectSpread$
|
|
23
|
+
return /*#__PURE__*/jsxs("svg", _objectSpread$1(_objectSpread$1({
|
|
22
24
|
className: className,
|
|
23
25
|
"aria-hidden": "true",
|
|
24
26
|
fill: "none",
|
|
@@ -139,10 +141,29 @@ var withoutReplacedDrafts = function withoutReplacedDrafts(runs) {
|
|
|
139
141
|
}));
|
|
140
142
|
});
|
|
141
143
|
};
|
|
144
|
+
var textOrEmpty = function textOrEmpty(value) {
|
|
145
|
+
return typeof value === "string" ? value.trim() : "";
|
|
146
|
+
};
|
|
142
147
|
var isPending = function isPending(_ref2) {
|
|
143
148
|
var status = _ref2.status;
|
|
144
149
|
return PENDING_STATUSES.includes(status);
|
|
145
150
|
};
|
|
151
|
+
var isStopped = function isStopped(_ref3) {
|
|
152
|
+
var status = _ref3.status;
|
|
153
|
+
return status === STOPPED_STATUS;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// The ask a stop button is for: the newest one still queued or running. The
|
|
157
|
+
// engine lists only the person's own asks, since an answer is built with the
|
|
158
|
+
// asker's access, so every ask in the list is theirs. A reply suggestion being
|
|
159
|
+
// written is nobody's ask. Runs are newest first.
|
|
160
|
+
var stoppableAsk = function stoppableAsk() {
|
|
161
|
+
var _runs$find;
|
|
162
|
+
var runs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
163
|
+
return (_runs$find = runs.find(function (run) {
|
|
164
|
+
return run.kind === "ask" && isPending(run);
|
|
165
|
+
})) !== null && _runs$find !== void 0 ? _runs$find : null;
|
|
166
|
+
};
|
|
146
167
|
var withoutRepeatedQuietSkips = function withoutRepeatedQuietSkips(runs) {
|
|
147
168
|
return collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);
|
|
148
169
|
};
|
|
@@ -156,27 +177,27 @@ var runsInConversationOrder = function runsInConversationOrder(runs) {
|
|
|
156
177
|
|
|
157
178
|
// The newest reply NeetoAssist drafted on its own. Runs are newest first.
|
|
158
179
|
var latestDraftId = function latestDraftId(runs) {
|
|
159
|
-
var _runs$
|
|
160
|
-
return (_runs$
|
|
161
|
-
var kind =
|
|
162
|
-
suggestedReply =
|
|
180
|
+
var _runs$find2;
|
|
181
|
+
return (_runs$find2 = runs.find(function (_ref4) {
|
|
182
|
+
var kind = _ref4.kind,
|
|
183
|
+
suggestedReply = _ref4.suggestedReply;
|
|
163
184
|
return kind === REPLY_SUGGESTION && !!suggestedReply;
|
|
164
|
-
})) === null || _runs$
|
|
185
|
+
})) === null || _runs$find2 === void 0 ? void 0 : _runs$find2.id;
|
|
165
186
|
};
|
|
166
187
|
|
|
167
188
|
// A hello is skipped, since nothing was looked up, but it still gets a reply.
|
|
168
|
-
var hasWrittenReply = function hasWrittenReply(
|
|
169
|
-
var status =
|
|
170
|
-
answer =
|
|
171
|
-
suggestedReply =
|
|
189
|
+
var hasWrittenReply = function hasWrittenReply(_ref5) {
|
|
190
|
+
var status = _ref5.status,
|
|
191
|
+
answer = _ref5.answer,
|
|
192
|
+
suggestedReply = _ref5.suggestedReply;
|
|
172
193
|
return status === "completed" || status === "skipped" && !!(answer || suggestedReply);
|
|
173
194
|
};
|
|
174
195
|
|
|
175
196
|
// A rep's own hello or thanks got a friendly line, which is nothing to judge.
|
|
176
|
-
var isRateable = function isRateable(
|
|
177
|
-
var kind =
|
|
178
|
-
status =
|
|
179
|
-
skippedReason =
|
|
197
|
+
var isRateable = function isRateable(_ref6) {
|
|
198
|
+
var kind = _ref6.kind,
|
|
199
|
+
status = _ref6.status,
|
|
200
|
+
skippedReason = _ref6.skippedReason;
|
|
180
201
|
return RATEABLE_STATUSES.includes(status) && !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) && !(kind === "ask" && status === "skipped");
|
|
181
202
|
};
|
|
182
203
|
|
|
@@ -191,8 +212,8 @@ var hasPendingRun = function hasPendingRun() {
|
|
|
191
212
|
|
|
192
213
|
// The lookups NeetoAssist made while answering, in the order they started. A
|
|
193
214
|
// run from an older NeetoAssist carries none.
|
|
194
|
-
var stepsOf = function stepsOf(
|
|
195
|
-
var steps =
|
|
215
|
+
var stepsOf = function stepsOf(_ref7) {
|
|
216
|
+
var steps = _ref7.steps;
|
|
196
217
|
return steps !== null && steps !== void 0 ? steps : [];
|
|
197
218
|
};
|
|
198
219
|
var hasRunningStep = function hasRunningStep(run) {
|
|
@@ -201,9 +222,9 @@ var hasRunningStep = function hasRunningStep(run) {
|
|
|
201
222
|
|
|
202
223
|
// A suggested action can only be applied once its run has finished. Until then
|
|
203
224
|
// NeetoAssist may still take it back and start over, so its card waits.
|
|
204
|
-
var actionsOf = function actionsOf(
|
|
205
|
-
var status =
|
|
206
|
-
actions =
|
|
225
|
+
var actionsOf = function actionsOf(_ref8) {
|
|
226
|
+
var status = _ref8.status,
|
|
227
|
+
actions = _ref8.actions;
|
|
207
228
|
return status === "completed" ? actions !== null && actions !== void 0 ? actions : [] : [];
|
|
208
229
|
};
|
|
209
230
|
var skippedReasonMessageKey = function skippedReasonMessageKey(reason) {
|
|
@@ -212,58 +233,208 @@ var skippedReasonMessageKey = function skippedReasonMessageKey(reason) {
|
|
|
212
233
|
|
|
213
234
|
// No answer at all means the request never reached NeetoAssist.
|
|
214
235
|
var errorMessageKey = function errorMessageKey(error) {
|
|
215
|
-
|
|
216
|
-
|
|
236
|
+
var isAssistant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
237
|
+
var keys = isAssistant ? ASSISTANT_ERROR_MESSAGE_KEYS : ERROR_MESSAGE_KEYS;
|
|
238
|
+
if (!(error !== null && error !== void 0 && error.response)) return keys[503];
|
|
239
|
+
return propOr("neetoAssist.errors.generic", error.response.status, keys);
|
|
217
240
|
};
|
|
218
241
|
|
|
219
|
-
// Sources come from a knowledge base, so only web links become links.
|
|
242
|
+
// Sources come from a knowledge base, so only web links become links. An
|
|
243
|
+
// address with a name or a password before an "@", such as
|
|
244
|
+
// "https://acme.neetochat.com@evil.example/", reads as one site and opens
|
|
245
|
+
// another, so it is none, and so is any "@" before the address's path.
|
|
220
246
|
var isWebUrl = function isWebUrl(url) {
|
|
221
|
-
return /^https
|
|
247
|
+
return /^https?:\/\/[^/?#@]*(?:[/?#]|$)/i.test(url !== null && url !== void 0 ? url : "");
|
|
222
248
|
};
|
|
223
249
|
|
|
224
|
-
|
|
225
|
-
|
|
250
|
+
// The sources of an answer as the pane lists them, in the order NeetoAssist
|
|
251
|
+
// gave. Each has the key of its kind's word, or a lookup's product, its title,
|
|
252
|
+
// and its address when that is a web address. One with neither a title nor
|
|
253
|
+
// such an address says nothing a person can use, so it is left out.
|
|
254
|
+
var shownSources = function shownSources(sources) {
|
|
255
|
+
return (Array.isArray(sources) ? sources : []).flatMap(function (source) {
|
|
256
|
+
var _SOURCE_KIND_KEYS$get;
|
|
257
|
+
var _ref9 = source !== null && source !== void 0 ? source : {},
|
|
258
|
+
kind = _ref9.kind,
|
|
259
|
+
product = _ref9.product,
|
|
260
|
+
title = _ref9.title,
|
|
261
|
+
url = _ref9.url;
|
|
262
|
+
var sourceKind = kind !== null && kind !== void 0 ? kind : DEFAULT_SOURCE_KIND;
|
|
263
|
+
var shown = {
|
|
264
|
+
kindKey: (_SOURCE_KIND_KEYS$get = SOURCE_KIND_KEYS.get(sourceKind)) !== null && _SOURCE_KIND_KEYS$get !== void 0 ? _SOURCE_KIND_KEYS$get : null,
|
|
265
|
+
product: sourceKind === LOOKUP_SOURCE_KIND ? textOrEmpty(product) || null : null,
|
|
266
|
+
title: textOrEmpty(title),
|
|
267
|
+
url: isWebUrl(url) ? url : null
|
|
268
|
+
};
|
|
269
|
+
return shown.title || shown.url ? [shown] : [];
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
274
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
275
|
+
|
|
276
|
+
// Runs live on a conversation or on an assistant thread: { conversationId } or
|
|
277
|
+
// { threadId }. A conversation's id alone, as these hooks were always given,
|
|
278
|
+
// names the conversation, and a conversation's runs keep the query key they
|
|
279
|
+
// always had.
|
|
280
|
+
var whereOf = function whereOf(thread) {
|
|
281
|
+
return _typeof(thread) === "object" && thread !== null ? thread : {
|
|
282
|
+
conversationId: thread
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
var runsKey = function runsKey(thread) {
|
|
286
|
+
var _whereOf = whereOf(thread),
|
|
287
|
+
conversationId = _whereOf.conversationId,
|
|
288
|
+
threadId = _whereOf.threadId;
|
|
289
|
+
return threadId ? [QUERY_KEYS.RUNS, PANE_MODES.ASSISTANT, threadId] : [QUERY_KEYS.RUNS, conversationId];
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// A question asked on an assistant thread, for as long as it is being asked.
|
|
293
|
+
var askKey = function askKey(thread) {
|
|
294
|
+
return ["neeto-assist-ask"].concat(_toConsumableArray(runsKey(thread)));
|
|
295
|
+
};
|
|
226
296
|
|
|
227
297
|
// Fresh on every mount, then polled: quickly while NeetoAssist is working on a
|
|
228
298
|
// run, slowly otherwise. A failed poll is retried by the next one and never
|
|
229
299
|
// shown as a toast. Comes with the workspace's credit state, and with the
|
|
230
|
-
// commands a rep can pick in the box, which an older engine does not list
|
|
231
|
-
|
|
300
|
+
// commands a rep can pick in the box, which an older engine does not list, and
|
|
301
|
+
// whether the engine can stop an ask, which an older one does not say.
|
|
302
|
+
// The assistant turns its thread's runs off while it is closed, so a closed
|
|
303
|
+
// assistant asks for nothing, and they are fetched again when it is opened.
|
|
304
|
+
// A conversation's are always on.
|
|
305
|
+
var useFetchRuns = function useFetchRuns(thread) {
|
|
306
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
307
|
+
_ref$enabled = _ref.enabled,
|
|
308
|
+
enabled = _ref$enabled === void 0 ? true : _ref$enabled;
|
|
309
|
+
var queryClient = useQueryClient();
|
|
310
|
+
var queryKey = runsKey(thread);
|
|
311
|
+
var where = whereOf(thread);
|
|
232
312
|
return useQuery({
|
|
233
|
-
queryKey:
|
|
234
|
-
queryFn: function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
313
|
+
queryKey: queryKey,
|
|
314
|
+
queryFn: function () {
|
|
315
|
+
var _queryFn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
316
|
+
var _queryClient$getQuery, _queryClient$getQuery2, _listed$runs2;
|
|
317
|
+
var listed, acceptedRuns;
|
|
318
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
319
|
+
while (1) switch (_context.prev = _context.next) {
|
|
320
|
+
case 0:
|
|
321
|
+
_context.next = 2;
|
|
322
|
+
return neetoAssistApi.fetchRuns(where);
|
|
323
|
+
case 2:
|
|
324
|
+
listed = _context.sent;
|
|
325
|
+
if (where.threadId) {
|
|
326
|
+
_context.next = 5;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
return _context.abrupt("return", listed);
|
|
330
|
+
case 5:
|
|
331
|
+
// A list can be older than the answer to an ask. Keep each accepted run
|
|
332
|
+
// until a list holds it, then use the list's version from then on.
|
|
333
|
+
acceptedRuns = ((_queryClient$getQuery = (_queryClient$getQuery2 = queryClient.getQueryData(queryKey)) === null || _queryClient$getQuery2 === void 0 ? void 0 : _queryClient$getQuery2.acceptedRuns) !== null && _queryClient$getQuery !== void 0 ? _queryClient$getQuery : []).filter(function (run) {
|
|
334
|
+
var _listed$runs;
|
|
335
|
+
return !existsById(run.id, (_listed$runs = listed.runs) !== null && _listed$runs !== void 0 ? _listed$runs : []);
|
|
336
|
+
});
|
|
337
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, listed), {}, {
|
|
338
|
+
runs: [].concat(_toConsumableArray(acceptedRuns), _toConsumableArray((_listed$runs2 = listed.runs) !== null && _listed$runs2 !== void 0 ? _listed$runs2 : [])),
|
|
339
|
+
acceptedRuns: acceptedRuns
|
|
340
|
+
}));
|
|
341
|
+
case 7:
|
|
342
|
+
case "end":
|
|
343
|
+
return _context.stop();
|
|
344
|
+
}
|
|
345
|
+
}, _callee);
|
|
346
|
+
}));
|
|
347
|
+
function queryFn() {
|
|
348
|
+
return _queryFn.apply(this, arguments);
|
|
349
|
+
}
|
|
350
|
+
return queryFn;
|
|
351
|
+
}(),
|
|
352
|
+
enabled: enabled,
|
|
353
|
+
select: function select(_ref2) {
|
|
354
|
+
var _ref2$runs = _ref2.runs,
|
|
355
|
+
runs = _ref2$runs === void 0 ? [] : _ref2$runs,
|
|
356
|
+
_ref2$credits = _ref2.credits,
|
|
357
|
+
credits = _ref2$credits === void 0 ? null : _ref2$credits,
|
|
358
|
+
commands = _ref2.commands,
|
|
359
|
+
canStop = _ref2.canStop;
|
|
243
360
|
return {
|
|
244
361
|
runs: runs,
|
|
245
362
|
credits: credits,
|
|
246
|
-
commands: commandsOf(commands)
|
|
363
|
+
commands: commandsOf(commands),
|
|
364
|
+
canStop: canStop === true
|
|
247
365
|
};
|
|
248
366
|
},
|
|
249
367
|
staleTime: 0,
|
|
250
368
|
retry: false,
|
|
251
|
-
refetchInterval: function refetchInterval(
|
|
252
|
-
var
|
|
253
|
-
data =
|
|
254
|
-
error =
|
|
369
|
+
refetchInterval: function refetchInterval(_ref3) {
|
|
370
|
+
var _ref3$state = _ref3.state,
|
|
371
|
+
data = _ref3$state.data,
|
|
372
|
+
error = _ref3$state.error;
|
|
255
373
|
return !error && hasPendingRun(data === null || data === void 0 ? void 0 : data.runs) ? PENDING_POLL_INTERVAL : IDLE_POLL_INTERVAL;
|
|
256
374
|
}
|
|
257
375
|
});
|
|
258
376
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
377
|
+
|
|
378
|
+
// On a conversation the runs are fetched again once the question is taken, as
|
|
379
|
+
// they always were. On an assistant thread the question is still being asked
|
|
380
|
+
// until the runs that hold it are back, so New chat, which waits for every
|
|
381
|
+
// question on the thread, cannot leave one behind in a thread nobody sees.
|
|
382
|
+
// Keep the accepted run before fetching the list: a failed refresh must not
|
|
383
|
+
// lose the stop button or let New chat leave the question behind.
|
|
384
|
+
var useAskNeetoAssist = function useAskNeetoAssist(thread) {
|
|
385
|
+
var queryClient = useQueryClient();
|
|
386
|
+
var queryKey = runsKey(thread);
|
|
387
|
+
return useMutationWithInvalidation(neetoAssistApi.createRun, whereOf(thread).threadId ? {
|
|
388
|
+
mutationKey: askKey(thread),
|
|
389
|
+
keysToInvalidate: [],
|
|
390
|
+
onSuccess: function onSuccess(_ref4) {
|
|
391
|
+
var run = _ref4.run;
|
|
392
|
+
if (!(run !== null && run !== void 0 && run.id)) return;
|
|
393
|
+
queryClient.setQueryData(queryKey, function () {
|
|
394
|
+
var _data$runs, _data$runs2, _data$acceptedRuns;
|
|
395
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
396
|
+
if (existsById(run.id, (_data$runs = data.runs) !== null && _data$runs !== void 0 ? _data$runs : [])) return data;
|
|
397
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
|
398
|
+
runs: [run].concat(_toConsumableArray((_data$runs2 = data.runs) !== null && _data$runs2 !== void 0 ? _data$runs2 : [])),
|
|
399
|
+
acceptedRuns: [run].concat(_toConsumableArray((_data$acceptedRuns = data.acceptedRuns) !== null && _data$acceptedRuns !== void 0 ? _data$acceptedRuns : []))
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
onSettled: function onSettled(_data, error) {
|
|
404
|
+
return error ? undefined : queryClient.refetchQueries({
|
|
405
|
+
queryKey: queryKey
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
} : {
|
|
409
|
+
keysToInvalidate: [queryKey]
|
|
262
410
|
});
|
|
263
411
|
};
|
|
264
|
-
|
|
412
|
+
|
|
413
|
+
// Whether a question on this thread is being asked, from the box or from a
|
|
414
|
+
// suggestion.
|
|
415
|
+
var useIsAsking = function useIsAsking(thread) {
|
|
416
|
+
return useIsMutating({
|
|
417
|
+
mutationKey: askKey(thread)
|
|
418
|
+
}) > 0;
|
|
419
|
+
};
|
|
420
|
+
var useUpdateFeedback = function useUpdateFeedback(thread) {
|
|
265
421
|
return useMutationWithInvalidation(neetoAssistApi.updateFeedback, {
|
|
266
|
-
keysToInvalidate: [
|
|
422
|
+
keysToInvalidate: [runsKey(thread)]
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// Whatever the answer to a stop, the run has ended or is about to: stopped, or
|
|
427
|
+
// answered first. So the runs are fetched again either way, and the list says
|
|
428
|
+
// which.
|
|
429
|
+
var useStopRun = function useStopRun(thread) {
|
|
430
|
+
var queryClient = useQueryClient();
|
|
431
|
+
return useMutation({
|
|
432
|
+
mutationFn: neetoAssistApi.stopRun,
|
|
433
|
+
onSettled: function onSettled() {
|
|
434
|
+
return queryClient.invalidateQueries({
|
|
435
|
+
queryKey: runsKey(thread)
|
|
436
|
+
});
|
|
437
|
+
}
|
|
267
438
|
});
|
|
268
439
|
};
|
|
269
440
|
|
|
@@ -274,7 +445,7 @@ var useUpdateFeedback = function useUpdateFeedback(conversationId) {
|
|
|
274
445
|
var useActOnAction = function useActOnAction(mutationFn, conversationId) {
|
|
275
446
|
var callbacks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
276
447
|
var queryClient = useQueryClient();
|
|
277
|
-
return useMutation(_objectSpread
|
|
448
|
+
return useMutation(_objectSpread({
|
|
278
449
|
mutationFn: mutationFn,
|
|
279
450
|
onSettled: function onSettled() {
|
|
280
451
|
queryClient.invalidateQueries({
|
|
@@ -300,61 +471,5 @@ var useDismissAction = function useDismissAction(conversationId) {
|
|
|
300
471
|
return useActOnAction(neetoAssistApi.dismissAction, conversationId);
|
|
301
472
|
};
|
|
302
473
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
// The pane is mounted once in the host's layout and the button sits on the
|
|
307
|
-
// ticket, so this is how they talk: whether the pane is open and how wide, and
|
|
308
|
-
// which conversation it is about. A reload starts closed, and the width is kept.
|
|
309
|
-
/** @type {import("neetocommons/react-utils").ZustandStoreHook} */
|
|
310
|
-
var useNeetoAssistStore = create(withImmutableActions(function (set) {
|
|
311
|
-
return {
|
|
312
|
-
isOpen: false,
|
|
313
|
-
isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,
|
|
314
|
-
conversation: null,
|
|
315
|
-
seenDrafts: {},
|
|
316
|
-
close: function close() {
|
|
317
|
-
return set({
|
|
318
|
-
isOpen: false
|
|
319
|
-
});
|
|
320
|
-
},
|
|
321
|
-
toggle: function toggle() {
|
|
322
|
-
return set(function (state) {
|
|
323
|
-
return {
|
|
324
|
-
isOpen: !state.isOpen
|
|
325
|
-
};
|
|
326
|
-
});
|
|
327
|
-
},
|
|
328
|
-
setExpanded: function setExpanded(value) {
|
|
329
|
-
setToLocalStorage(EXPANDED_STORAGE_KEY, value);
|
|
330
|
-
set({
|
|
331
|
-
isExpanded: value
|
|
332
|
-
});
|
|
333
|
-
},
|
|
334
|
-
setConversation: function setConversation(conversation) {
|
|
335
|
-
return set({
|
|
336
|
-
conversation: conversation
|
|
337
|
-
});
|
|
338
|
-
},
|
|
339
|
-
// Only the conversation that is leaving: the next one's button may already
|
|
340
|
-
// have taken its place.
|
|
341
|
-
clearConversation: function clearConversation(conversationId) {
|
|
342
|
-
return set(function (state) {
|
|
343
|
-
var _state$conversation;
|
|
344
|
-
return ((_state$conversation = state.conversation) === null || _state$conversation === void 0 ? void 0 : _state$conversation.id) === conversationId ? {
|
|
345
|
-
conversation: null
|
|
346
|
-
} : {};
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
markDraftSeen: function markDraftSeen(conversationId, runId) {
|
|
350
|
-
return set(function (state) {
|
|
351
|
-
return {
|
|
352
|
-
seenDrafts: _objectSpread(_objectSpread({}, state.seenDrafts), {}, _defineProperty({}, conversationId, runId))
|
|
353
|
-
};
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
}));
|
|
358
|
-
|
|
359
|
-
export { Sparkle as S, useFetchRuns as a, useAskNeetoAssist as b, useApplyAction as c, useDismissAction as d, errorMessageKey as e, actionsOf as f, useUpdateFeedback as g, commandPart as h, isWebUrl as i, isPending as j, hasRunningStep as k, latestDraftId as l, matchingCommands as m, hasWrittenReply as n, optionId as o, pickedCommand as p, skippedReasonMessageKey as q, isRateable as r, stepsOf as s, runsInConversationOrder as t, useNeetoAssistStore as u };
|
|
360
|
-
//# sourceMappingURL=useNeetoAssistStore-InICsbe8.js.map
|
|
474
|
+
export { Sparkle as S, useAskNeetoAssist as a, useStopRun as b, useApplyAction as c, useDismissAction as d, errorMessageKey as e, actionsOf as f, useUpdateFeedback as g, commandPart as h, isWebUrl as i, stepsOf as j, isPending as k, latestDraftId as l, matchingCommands as m, hasRunningStep as n, optionId as o, pickedCommand as p, hasWrittenReply as q, skippedReasonMessageKey as r, shownSources as s, isStopped as t, useFetchRuns as u, isRateable as v, stoppableAsk as w, runsInConversationOrder as x, useIsAsking as y, hasPendingRun as z };
|
|
475
|
+
//# sourceMappingURL=useRunsApi-BgsICthX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunsApi-BgsICthX.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/commands.js","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// A command is a named way to ask NeetoAssist for one of the things it can do\n// here. A rep types \"/\" in the box, picks a command from the menu and may add\n// a few words. The engine lists the commands with the runs: NeetoAssist's own,\n// then those of the host's actions this rep is offered.\nimport { any, isEmpty, propEq } from \"ramda\";\n\nconst wordsOf = text => text.toLowerCase().split(/\\s+/).filter(Boolean);\n\n// The commands as the engine listed them with the runs. It lists only what has\n// a name, a title and a description, and an older engine lists none. Anything\n// else that turns up is left out here, so a menu never has a row it cannot\n// show.\nexport const commandsOf = commands =>\n (Array.isArray(commands) ? commands : []).filter(command =>\n [command?.name, command?.title, command?.description].every(\n text => typeof text === \"string\"\n )\n );\n\n// What a rep has typed of a command so far: the text after the \"/\", in lower\n// case, or null when the box holds no command being typed. That is so once\n// the text runs on to another line, and once a full name has a space after\n// it: the command is chosen then, and what follows are the rep's own words.\nexport const typedCommand = (text, commands) => {\n if (!text.startsWith(\"/\") || text.includes(\"\\n\")) return null;\n\n const typed = text.slice(1).toLowerCase();\n const [name, ...rest] = typed.split(/\\s/);\n const isChosen = !isEmpty(rest) && any(propEq(name, \"name\"), commands);\n\n return isChosen ? null : typed;\n};\n\n// The commands that fit what was typed, as the menu lists them: all of them\n// after a bare \"/\", otherwise those whose name starts with what was typed,\n// then those whose title has a word that starts with each word typed.\nexport const matchingCommands = (text, commands) => {\n const typed = typedCommand(text, commands);\n if (typed === null) return [];\n\n const words = wordsOf(typed);\n if (isEmpty(words)) return commands;\n\n const fitsName = ({ name }) =>\n words.length === 1 && name.startsWith(words[0]);\n\n const fitsTitle = ({ title }) =>\n words.every(word =>\n wordsOf(title).some(titleWord => titleWord.startsWith(word))\n );\n\n return [\n ...commands.filter(fitsName),\n ...commands.filter(command => !fitsName(command) && fitsTitle(command)),\n ];\n};\n\n// What the box holds once a command is picked: the command and a space, for\n// the rep to add words after or to send as it is.\nexport const pickedCommand = ({ name }) => `/${name} `;\n\n// The id of a command's row in the menu, which the box points at while the\n// row is the marked one.\nexport const optionId = (menuId, { name }) => `${menuId}-${name}`;\n\n// The command at the start of a question, as the rep typed it, or null for a\n// question that NeetoAssist did not read as a command.\nexport const commandPart = (question, command) => {\n if (!command || typeof question !== \"string\") return null;\n\n const typed = question.slice(0, command.length + 1);\n\n return typed.toLowerCase() === `/${command}`.toLowerCase() ? typed : null;\n};\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { any, propEq, propOr, reverse } from \"ramda\";\n\nimport {\n ASSISTANT_ERROR_MESSAGE_KEYS,\n DEFAULT_SOURCE_KIND,\n ERROR_MESSAGE_KEYS,\n LOOKUP_SOURCE_KIND,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n SOURCE_KIND_KEYS,\n STOPPED_STATUS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nconst textOrEmpty = value => (typeof value === \"string\" ? value.trim() : \"\");\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const isStopped = ({ status }) => status === STOPPED_STATUS;\n\n// The ask a stop button is for: the newest one still queued or running. The\n// engine lists only the person's own asks, since an answer is built with the\n// asker's access, so every ask in the list is theirs. A reply suggestion being\n// written is nobody's ask. Runs are newest first.\nexport const stoppableAsk = (runs = []) =>\n runs.find(run => run.kind === \"ask\" && isPending(run)) ?? null;\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\n// What the pane polls quickly for: a run NeetoAssist is still working on. An\n// action someone is applying is not one. The rep who clicked has the answer\n// to the click, and an action whose end NeetoAssist never hears of would keep\n// every open pane polling quickly until NeetoAssist gives up on it.\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\n// The lookups NeetoAssist made while answering, in the order they started. A\n// run from an older NeetoAssist carries none.\nexport const stepsOf = ({ steps }) => steps ?? [];\n\nexport const hasRunningStep = run =>\n any(propEq(\"running\", \"status\"), stepsOf(run));\n\n// A suggested action can only be applied once its run has finished. Until then\n// NeetoAssist may still take it back and start over, so its card waits.\nexport const actionsOf = ({ status, actions }) =>\n status === \"completed\" ? (actions ?? []) : [];\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = (error, isAssistant = false) => {\n const keys = isAssistant ? ASSISTANT_ERROR_MESSAGE_KEYS : ERROR_MESSAGE_KEYS;\n if (!error?.response) return keys[503];\n\n return propOr(\"neetoAssist.errors.generic\", error.response.status, keys);\n};\n\n// Sources come from a knowledge base, so only web links become links. An\n// address with a name or a password before an \"@\", such as\n// \"https://acme.neetochat.com@evil.example/\", reads as one site and opens\n// another, so it is none, and so is any \"@\" before the address's path.\nexport const isWebUrl = url =>\n /^https?:\\/\\/[^/?#@]*(?:[/?#]|$)/i.test(url ?? \"\");\n\n// The sources of an answer as the pane lists them, in the order NeetoAssist\n// gave. Each has the key of its kind's word, or a lookup's product, its title,\n// and its address when that is a web address. One with neither a title nor\n// such an address says nothing a person can use, so it is left out.\nexport const shownSources = sources =>\n (Array.isArray(sources) ? sources : []).flatMap(source => {\n const { kind, product, title, url } = source ?? {};\n const sourceKind = kind ?? DEFAULT_SOURCE_KIND;\n const shown = {\n kindKey: SOURCE_KIND_KEYS.get(sourceKind) ?? null,\n product:\n sourceKind === LOOKUP_SOURCE_KIND ? textOrEmpty(product) || null : null,\n title: textOrEmpty(title),\n url: isWebUrl(url) ? url : null,\n };\n\n return shown.title || shown.url ? [shown] : [];\n });\n","import {\n useIsMutating,\n useMutation,\n useQuery,\n useQueryClient,\n} from \"@tanstack/react-query\";\nimport { existsById } from \"neetocist\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PANE_MODES,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { commandsOf } from \"utils/commands\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Runs live on a conversation or on an assistant thread: { conversationId } or\n// { threadId }. A conversation's id alone, as these hooks were always given,\n// names the conversation, and a conversation's runs keep the query key they\n// always had.\nconst whereOf = thread =>\n typeof thread === \"object\" && thread !== null\n ? thread\n : { conversationId: thread };\n\nconst runsKey = thread => {\n const { conversationId, threadId } = whereOf(thread);\n\n return threadId\n ? [QUERY_KEYS.RUNS, PANE_MODES.ASSISTANT, threadId]\n : [QUERY_KEYS.RUNS, conversationId];\n};\n\n// A question asked on an assistant thread, for as long as it is being asked.\nconst askKey = thread => [\"neeto-assist-ask\", ...runsKey(thread)];\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state, and with the\n// commands a rep can pick in the box, which an older engine does not list, and\n// whether the engine can stop an ask, which an older one does not say.\n// The assistant turns its thread's runs off while it is closed, so a closed\n// assistant asks for nothing, and they are fetched again when it is opened.\n// A conversation's are always on.\nconst useFetchRuns = (thread, { enabled = true } = {}) => {\n const queryClient = useQueryClient();\n const queryKey = runsKey(thread);\n const where = whereOf(thread);\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n const listed = await neetoAssistApi.fetchRuns(where);\n if (!where.threadId) return listed;\n\n // A list can be older than the answer to an ask. Keep each accepted run\n // until a list holds it, then use the list's version from then on.\n const acceptedRuns = (\n queryClient.getQueryData(queryKey)?.acceptedRuns ?? []\n ).filter(run => !existsById(run.id, listed.runs ?? []));\n\n return {\n ...listed,\n runs: [...acceptedRuns, ...(listed.runs ?? [])],\n acceptedRuns,\n };\n },\n enabled,\n select: ({ runs = [], credits = null, commands, canStop }) => ({\n runs,\n credits,\n commands: commandsOf(commands),\n canStop: canStop === true,\n }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n};\n\n// On a conversation the runs are fetched again once the question is taken, as\n// they always were. On an assistant thread the question is still being asked\n// until the runs that hold it are back, so New chat, which waits for every\n// question on the thread, cannot leave one behind in a thread nobody sees.\n// Keep the accepted run before fetching the list: a failed refresh must not\n// lose the stop button or let New chat leave the question behind.\nconst useAskNeetoAssist = thread => {\n const queryClient = useQueryClient();\n const queryKey = runsKey(thread);\n\n return useMutationWithInvalidation(\n neetoAssistApi.createRun,\n whereOf(thread).threadId\n ? {\n mutationKey: askKey(thread),\n keysToInvalidate: [],\n onSuccess: ({ run }) => {\n if (!run?.id) return;\n\n queryClient.setQueryData(queryKey, (data = {}) => {\n if (existsById(run.id, data.runs ?? [])) return data;\n\n return {\n ...data,\n runs: [run, ...(data.runs ?? [])],\n acceptedRuns: [run, ...(data.acceptedRuns ?? [])],\n };\n });\n },\n onSettled: (_data, error) =>\n error ? undefined : queryClient.refetchQueries({ queryKey }),\n }\n : { keysToInvalidate: [queryKey] }\n );\n};\n\n// Whether a question on this thread is being asked, from the box or from a\n// suggestion.\nconst useIsAsking = thread =>\n useIsMutating({ mutationKey: askKey(thread) }) > 0;\n\nconst useUpdateFeedback = thread =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [runsKey(thread)],\n });\n\n// Whatever the answer to a stop, the run has ended or is about to: stopped, or\n// answered first. So the runs are fetched again either way, and the list says\n// which.\nconst useStopRun = thread => {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: neetoAssistApi.stopRun,\n onSettled: () =>\n queryClient.invalidateQueries({ queryKey: runsKey(thread) }),\n });\n};\n\n// A click on a card changes what its run shows whether it worked or not: the\n// action was applied, or someone else got to it first, or it expired. So the\n// runs are fetched again either way. The card does not wait for them: the\n// answer to the click already says what happened.\nconst useActOnAction = (mutationFn, conversationId, callbacks = {}) => {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn,\n onSettled: () => {\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n });\n },\n ...callbacks,\n });\n};\n\n// The host hears of an applied action from here and not from the card that\n// was clicked. React Query drops what a card hands to mutate once the card is\n// off the screen, as when the rep opens another conversation before the answer\n// arrives, and the change was made all the same. The click does not wait for\n// the host's handler, so what the handler returns is left alone.\nconst useApplyAction = (conversationId, onApplied) =>\n useActOnAction(neetoAssistApi.applyAction, conversationId, {\n onSuccess: data => {\n onApplied?.(data?.action);\n },\n });\n\nconst useDismissAction = conversationId =>\n useActOnAction(neetoAssistApi.dismissAction, conversationId);\n\nexport {\n useFetchRuns,\n useAskNeetoAssist,\n useIsAsking,\n useUpdateFeedback,\n useStopRun,\n useApplyAction,\n useDismissAction,\n};\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","wordsOf","text","toLowerCase","split","filter","Boolean","commandsOf","commands","Array","isArray","command","name","title","description","every","typedCommand","startsWith","includes","typed","slice","_typed$split","_typed$split2","_toArray","rest","isChosen","isEmpty","any","propEq","matchingCommands","words","fitsName","length","fitsTitle","_ref2","word","some","titleWord","concat","_toConsumableArray","pickedCommand","_ref3","optionId","menuId","_ref4","commandPart","question","collapseRepeatedSkips","runs","reasons","run","index","next","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","textOrEmpty","value","trim","isPending","PENDING_STATUSES","isStopped","STOPPED_STATUS","stoppableAsk","_runs$find","arguments","undefined","find","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find2","suggestedReply","id","hasWrittenReply","_ref5","answer","isRateable","_ref6","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","stepsOf","_ref7","steps","hasRunningStep","actionsOf","_ref8","actions","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","isAssistant","keys","ASSISTANT_ERROR_MESSAGE_KEYS","ERROR_MESSAGE_KEYS","response","isWebUrl","url","test","shownSources","sources","flatMap","source","_SOURCE_KIND_KEYS$get","_ref9","product","sourceKind","DEFAULT_SOURCE_KIND","shown","kindKey","SOURCE_KIND_KEYS","get","LOOKUP_SOURCE_KIND","whereOf","thread","_typeof","conversationId","runsKey","_whereOf","threadId","QUERY_KEYS","RUNS","PANE_MODES","ASSISTANT","askKey","useFetchRuns","_ref$enabled","enabled","queryClient","useQueryClient","queryKey","where","useQuery","queryFn","_queryFn","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_queryClient$getQuery","_queryClient$getQuery2","_listed$runs2","listed","acceptedRuns","wrap","_callee$","_context","prev","neetoAssistApi","fetchRuns","sent","abrupt","getQueryData","_listed$runs","existsById","stop","apply","select","_ref2$runs","_ref2$credits","credits","canStop","staleTime","retry","refetchInterval","_ref3$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","mutationKey","keysToInvalidate","onSuccess","setQueryData","_data$runs","_data$runs2","_data$acceptedRuns","onSettled","_data","refetchQueries","useIsAsking","useIsMutating","useUpdateFeedback","updateFeedback","useStopRun","useMutation","mutationFn","stopRun","invalidateQueries","useActOnAction","callbacks","useApplyAction","onApplied","applyAction","action","useDismissAction","dismissAction"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAAC,SAAA,GAAAD,IAAA,CAAME,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,SAAA;IAAEE,SAAS,GAAAH,IAAA,CAATG,SAAS;AAAKC,IAAAA,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA,CAAA;AAAA,EAAA,oBACpDC,IAAA,CAAA,KAAA,EAAAC,eAAA,CAAAA,eAAA,CAAA;AACQL,IAAAA,SAAS,EAATA,SAAS;AACf,IAAA,aAAA,EAAY,MAAM;AAClBM,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,MAAM,EAAER,IAAK;AACbS,IAAAA,MAAM,EAAC,cAAc;AACrBC,IAAAA,aAAa,EAAC,OAAO;AACrBC,IAAAA,cAAc,EAAC,OAAO;AACtBC,IAAAA,WAAW,EAAC,KAAK;AACjBC,IAAAA,OAAO,EAAC,WAAW;AACnBC,IAAAA,KAAK,EAAEd,IAAK;AACZe,IAAAA,KAAK,EAAC;AAA4B,GAAA,EAC9Bb,UAAU,CAAA,EAAA,EAAA,EAAA;AAAAc,IAAAA,QAAA,gBAEdC,GAAA,CAAA,MAAA,EAAA;AACEC,MAAAA,CAAC,EAAC,oWAAoW;AACtWX,MAAAA,IAAI,EAAC,cAAc;AACnBE,MAAAA,MAAM,EAAC;KACR,CAAC,eACFQ,GAAA,CAAA,MAAA,EAAA;AAAMC,MAAAA,CAAC,EAAC;AAAsG,KAAE,CAAC;AAAA,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