@superinterface/react 2.5.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +107 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +103 -18
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +0 -6
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +0 -6
- package/dist/server.js.map +1 -1
- package/dist/utils.cjs +14 -5
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -1
- package/dist/utils.d.ts +5 -1
- package/dist/utils.js +6 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -282,12 +282,12 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
282
282
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
283
283
|
try {
|
|
284
284
|
var _loop = function() {
|
|
285
|
-
var
|
|
286
|
-
if (!__hasOwnProp.call(to,
|
|
285
|
+
var key2 = _step.value;
|
|
286
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except) __defProp(to, key2, {
|
|
287
287
|
get: function() {
|
|
288
|
-
return from[
|
|
288
|
+
return from[key2];
|
|
289
289
|
},
|
|
290
|
-
enumerable: !(desc = __getOwnPropDesc(from,
|
|
290
|
+
enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable
|
|
291
291
|
});
|
|
292
292
|
};
|
|
293
293
|
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
@@ -412,13 +412,46 @@ var merge = function(obj) {
|
|
|
412
412
|
};
|
|
413
413
|
// src/contexts/core/SuperinterfaceContext/index.tsx
|
|
414
414
|
var import_react = require("react");
|
|
415
|
+
// src/lib/superinterfaceCloud/baseUrl.ts
|
|
416
|
+
var baseUrl = "https://superinterface.ai/api/cloud";
|
|
417
|
+
// src/lib/threadIdCookies/options/get.ts
|
|
418
|
+
var import_js_cookie = __toESM(require("js-cookie"), 1);
|
|
419
|
+
// src/lib/threadIdCookies/key.ts
|
|
420
|
+
var key = function(param) {
|
|
421
|
+
var assistantId = param.assistantId;
|
|
422
|
+
return "superinterface-".concat(assistantId, "-threadId");
|
|
423
|
+
};
|
|
424
|
+
// src/lib/threadIdCookies/options/get.ts
|
|
425
|
+
var get = function(param) {
|
|
426
|
+
var assistantId = param.assistantId;
|
|
427
|
+
return import_js_cookie.default.get(key({
|
|
428
|
+
assistantId: assistantId
|
|
429
|
+
}));
|
|
430
|
+
};
|
|
431
|
+
// src/lib/threadIdCookies/options/set.ts
|
|
432
|
+
var import_js_cookie2 = __toESM(require("js-cookie"), 1);
|
|
433
|
+
var set = function(param) {
|
|
434
|
+
var assistantId = param.assistantId, threadId = param.threadId;
|
|
435
|
+
return import_js_cookie2.default.set(key({
|
|
436
|
+
assistantId: assistantId
|
|
437
|
+
}), threadId, {
|
|
438
|
+
expires: 270
|
|
439
|
+
});
|
|
440
|
+
};
|
|
441
|
+
// src/lib/threadIdCookies/options/index.ts
|
|
442
|
+
var options = {
|
|
443
|
+
get: get,
|
|
444
|
+
set: set
|
|
445
|
+
};
|
|
446
|
+
// src/contexts/core/SuperinterfaceContext/index.tsx
|
|
415
447
|
var SuperinterfaceContext = (0, import_react.createContext)({
|
|
416
|
-
baseUrl:
|
|
448
|
+
baseUrl: baseUrl,
|
|
417
449
|
variables: {},
|
|
418
450
|
defaultOptions: {
|
|
419
451
|
queries: {},
|
|
420
452
|
mutations: {}
|
|
421
|
-
}
|
|
453
|
+
},
|
|
454
|
+
threadIdCookieOptions: options
|
|
422
455
|
});
|
|
423
456
|
// src/hooks/core/useSuperinterfaceContext/index.ts
|
|
424
457
|
var import_react2 = require("react");
|
|
@@ -428,16 +461,18 @@ var useSuperinterfaceContext = function() {
|
|
|
428
461
|
// src/components/core/SuperinterfaceProvider/index.tsx
|
|
429
462
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
430
463
|
var SuperinterfaceProvider = function(param) {
|
|
431
|
-
var children = param.children,
|
|
464
|
+
var children = param.children, baseUrl2 = param.baseUrl, publicApiKey = param.publicApiKey, variables = param.variables, defaultOptions = param.defaultOptions, threadIdCookieOptions = param.threadIdCookieOptions;
|
|
432
465
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
433
|
-
var value = merge(superinterfaceContext, _object_spread({},
|
|
434
|
-
baseUrl:
|
|
466
|
+
var value = merge(superinterfaceContext, _object_spread({}, baseUrl2 ? {
|
|
467
|
+
baseUrl: baseUrl2
|
|
435
468
|
} : {}, publicApiKey ? {
|
|
436
469
|
publicApiKey: publicApiKey
|
|
437
470
|
} : {}, variables ? {
|
|
438
471
|
variables: variables
|
|
439
472
|
} : {}, defaultOptions ? {
|
|
440
473
|
defaultOptions: defaultOptions
|
|
474
|
+
} : {}, threadIdCookieOptions ? {
|
|
475
|
+
threadIdCookieOptions: threadIdCookieOptions
|
|
441
476
|
} : {}));
|
|
442
477
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SuperinterfaceContext.Provider, {
|
|
443
478
|
value: value,
|
|
@@ -453,6 +488,22 @@ var import_react3 = require("react");
|
|
|
453
488
|
var import_react_query2 = require("@tanstack/react-query");
|
|
454
489
|
// src/lib/threads/queryOptions/index.ts
|
|
455
490
|
var import_react_query = require("@tanstack/react-query");
|
|
491
|
+
// src/lib/threads/queryOptions/variableParams.ts
|
|
492
|
+
var variableParams = function(param) {
|
|
493
|
+
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
494
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
495
|
+
if (variables.threadId) return variables;
|
|
496
|
+
if (!variables.assistantId) return variables;
|
|
497
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
498
|
+
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
499
|
+
assistantId: variables.assistantId
|
|
500
|
+
});
|
|
501
|
+
if (!threadId) return variables;
|
|
502
|
+
return _object_spread_props(_object_spread({}, variables), {
|
|
503
|
+
threadId: threadId
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
// src/lib/threads/queryOptions/index.ts
|
|
456
507
|
var queryOptions = function(param) {
|
|
457
508
|
var queryKeyBase = param.queryKeyBase, path = param.path, queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext;
|
|
458
509
|
var queryKey = _to_consumable_array(queryKeyBase).concat([
|
|
@@ -468,12 +519,13 @@ var queryOptions = function(param) {
|
|
|
468
519
|
_queryKey2 = _sliced_to_array(queryKey2, 2), _key = _queryKey2[0], variables = _queryKey2[1];
|
|
469
520
|
params = new URLSearchParams(_object_spread({}, pageParam ? {
|
|
470
521
|
pageParam: pageParam
|
|
471
|
-
} : {},
|
|
522
|
+
} : {}, variableParams({
|
|
523
|
+
variables: variables,
|
|
524
|
+
superinterfaceContext: superinterfaceContext
|
|
525
|
+
})));
|
|
472
526
|
return [
|
|
473
527
|
2,
|
|
474
|
-
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({
|
|
475
|
-
credentials: "include"
|
|
476
|
-
}, superinterfaceContext.publicApiKey ? {
|
|
528
|
+
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
477
529
|
headers: {
|
|
478
530
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
479
531
|
}
|
|
@@ -1704,6 +1756,19 @@ var onMutate = function(param) {
|
|
|
1704
1756
|
};
|
|
1705
1757
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
1706
1758
|
var import_json_whatwg = require("@streamparser/json-whatwg");
|
|
1759
|
+
// src/lib/threadIdCookies/ensure.ts
|
|
1760
|
+
var ensure = function(param) {
|
|
1761
|
+
var superinterfaceContext = param.superinterfaceContext, variables = param.variables, value = param.value;
|
|
1762
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
1763
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.set)) return;
|
|
1764
|
+
if (value.value.event !== "thread.run.created") return;
|
|
1765
|
+
if (variables.threadId) return;
|
|
1766
|
+
if (!variables.assistantId) return;
|
|
1767
|
+
superinterfaceContext.threadIdCookieOptions.set({
|
|
1768
|
+
assistantId: variables.assistantId,
|
|
1769
|
+
threadId: value.value.data.thread_id
|
|
1770
|
+
});
|
|
1771
|
+
};
|
|
1707
1772
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/extendMessage.ts
|
|
1708
1773
|
var import_radash5 = require("radash");
|
|
1709
1774
|
var extendMessage = function(param) {
|
|
@@ -1936,9 +2001,9 @@ var updatedToolCall = function(param) {
|
|
|
1936
2001
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1937
2002
|
try {
|
|
1938
2003
|
for(var _iterator = Object.entries(delta.function)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1939
|
-
var _step_value = _sliced_to_array(_step.value, 2),
|
|
1940
|
-
var
|
|
1941
|
-
result.function[
|
|
2004
|
+
var _step_value = _sliced_to_array(_step.value, 2), key2 = _step_value[0], value = _step_value[1];
|
|
2005
|
+
var _result_function_key2;
|
|
2006
|
+
result.function[key2] = "".concat((_result_function_key2 = result.function[key2]) !== null && _result_function_key2 !== void 0 ? _result_function_key2 : "").concat(value);
|
|
1942
2007
|
}
|
|
1943
2008
|
} catch (err) {
|
|
1944
2009
|
_didIteratorError = true;
|
|
@@ -2057,6 +2122,21 @@ var handleResponse = function(param) {
|
|
|
2057
2122
|
value: value.value
|
|
2058
2123
|
}));
|
|
2059
2124
|
};
|
|
2125
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/body.ts
|
|
2126
|
+
var body = function(param) {
|
|
2127
|
+
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
2128
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
2129
|
+
if (variables.threadId) return variables;
|
|
2130
|
+
if (!variables.assistantId) return variables;
|
|
2131
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
2132
|
+
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
2133
|
+
assistantId: variables.assistantId
|
|
2134
|
+
});
|
|
2135
|
+
if (!threadId) return variables;
|
|
2136
|
+
return _object_spread_props(_object_spread({}, variables), {
|
|
2137
|
+
threadId: threadId
|
|
2138
|
+
});
|
|
2139
|
+
};
|
|
2060
2140
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
2061
2141
|
var mutationFn = function(param) {
|
|
2062
2142
|
var superinterfaceContext = param.superinterfaceContext, queryClient = param.queryClient, threadContext = param.threadContext;
|
|
@@ -2070,8 +2150,10 @@ var mutationFn = function(param) {
|
|
|
2070
2150
|
4,
|
|
2071
2151
|
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), _object_spread({
|
|
2072
2152
|
method: "POST",
|
|
2073
|
-
body: JSON.stringify(
|
|
2074
|
-
|
|
2153
|
+
body: JSON.stringify(body({
|
|
2154
|
+
variables: variables,
|
|
2155
|
+
superinterfaceContext: superinterfaceContext
|
|
2156
|
+
}))
|
|
2075
2157
|
}, superinterfaceContext.publicApiKey ? {
|
|
2076
2158
|
headers: {
|
|
2077
2159
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
@@ -2116,6 +2198,11 @@ var mutationFn = function(param) {
|
|
|
2116
2198
|
messagesQueryKey: messagesQueryKey,
|
|
2117
2199
|
queryClient: queryClient
|
|
2118
2200
|
});
|
|
2201
|
+
ensure({
|
|
2202
|
+
superinterfaceContext: superinterfaceContext,
|
|
2203
|
+
variables: variables,
|
|
2204
|
+
value: value
|
|
2205
|
+
});
|
|
2119
2206
|
return [
|
|
2120
2207
|
3,
|
|
2121
2208
|
2
|
|
@@ -3069,13 +3156,11 @@ var useMessageAudio = function(param) {
|
|
|
3069
3156
|
}
|
|
3070
3157
|
}
|
|
3071
3158
|
}, isHtmlAudioSupported ? {} : {
|
|
3072
|
-
xhr:
|
|
3159
|
+
xhr: _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
3073
3160
|
headers: {
|
|
3074
3161
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
3075
3162
|
}
|
|
3076
|
-
} : {})
|
|
3077
|
-
withCredentials: true
|
|
3078
|
-
})
|
|
3163
|
+
} : {})
|
|
3079
3164
|
}));
|
|
3080
3165
|
}, [
|
|
3081
3166
|
unplayedMessageSentences,
|