@superinterface/react 2.4.5 → 2.6.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/dist/index.cjs +138 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -21
- package/dist/index.d.ts +50 -21
- package/dist/index.js +134 -19
- package/dist/index.js.map +1 -1
- package/dist/{queryFns.cjs → server.cjs} +437 -172
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +39 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.js +879 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +17 -21
- package/dist/types/index.d.ts +17 -21
- package/dist/utils.cjs +54 -252
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +18 -18
- package/dist/utils.d.ts +18 -18
- package/dist/utils.js +42 -244
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
- package/dist/index-CGpJFXMu.d.cts +0 -5
- package/dist/index-CGpJFXMu.d.ts +0 -5
- package/dist/index-u67QcaWg.d.cts +0 -11
- package/dist/index-u67QcaWg.d.ts +0 -11
- package/dist/mutationFns.cjs +0 -357
- package/dist/mutationFns.cjs.map +0 -1
- package/dist/mutationFns.d.cts +0 -15
- package/dist/mutationFns.d.ts +0 -15
- package/dist/mutationFns.js +0 -287
- package/dist/mutationFns.js.map +0 -1
- package/dist/queryFns.cjs.map +0 -1
- package/dist/queryFns.d.cts +0 -26
- package/dist/queryFns.d.ts +0 -26
- package/dist/queryFns.js +0 -618
- package/dist/queryFns.js.map +0 -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,30 @@ 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
|
+
console.log({
|
|
496
|
+
variables: variables,
|
|
497
|
+
superinterfaceContext: superinterfaceContext
|
|
498
|
+
});
|
|
499
|
+
if (variables.threadId) return variables;
|
|
500
|
+
if (!variables.assistantId) return variables;
|
|
501
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
502
|
+
console.log("using");
|
|
503
|
+
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
504
|
+
assistantId: variables.assistantId
|
|
505
|
+
});
|
|
506
|
+
if (!threadId) return variables;
|
|
507
|
+
console.log({
|
|
508
|
+
threadId: threadId
|
|
509
|
+
});
|
|
510
|
+
return _object_spread_props(_object_spread({}, variables), {
|
|
511
|
+
threadId: threadId
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
// src/lib/threads/queryOptions/index.ts
|
|
456
515
|
var queryOptions = function(param) {
|
|
457
516
|
var queryKeyBase = param.queryKeyBase, path = param.path, queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext;
|
|
458
517
|
var queryKey = _to_consumable_array(queryKeyBase).concat([
|
|
@@ -468,12 +527,13 @@ var queryOptions = function(param) {
|
|
|
468
527
|
_queryKey2 = _sliced_to_array(queryKey2, 2), _key = _queryKey2[0], variables = _queryKey2[1];
|
|
469
528
|
params = new URLSearchParams(_object_spread({}, pageParam ? {
|
|
470
529
|
pageParam: pageParam
|
|
471
|
-
} : {},
|
|
530
|
+
} : {}, variableParams({
|
|
531
|
+
variables: variables,
|
|
532
|
+
superinterfaceContext: superinterfaceContext
|
|
533
|
+
})));
|
|
472
534
|
return [
|
|
473
535
|
2,
|
|
474
|
-
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({
|
|
475
|
-
credentials: "include"
|
|
476
|
-
}, superinterfaceContext.publicApiKey ? {
|
|
536
|
+
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params), _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
477
537
|
headers: {
|
|
478
538
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
479
539
|
}
|
|
@@ -1260,6 +1320,14 @@ var Message = function(param) {
|
|
|
1260
1320
|
}, [
|
|
1261
1321
|
message
|
|
1262
1322
|
]), 2), olderRunSteps = _ref[0], laterRunSteps = _ref[1];
|
|
1323
|
+
var isInProgress = (0, import_react18.useMemo)(function() {
|
|
1324
|
+
if (message.status === "in_progress") return true;
|
|
1325
|
+
return message.runSteps.some(function(rs) {
|
|
1326
|
+
return rs.status === "in_progress";
|
|
1327
|
+
});
|
|
1328
|
+
}, [
|
|
1329
|
+
message
|
|
1330
|
+
]);
|
|
1263
1331
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Provider, {
|
|
1264
1332
|
value: {
|
|
1265
1333
|
message: message
|
|
@@ -1278,7 +1346,7 @@ var Message = function(param) {
|
|
|
1278
1346
|
})
|
|
1279
1347
|
}, index);
|
|
1280
1348
|
}),
|
|
1281
|
-
|
|
1349
|
+
isInProgress && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(StartingContentSkeleton, {})
|
|
1282
1350
|
]
|
|
1283
1351
|
}),
|
|
1284
1352
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RunSteps, {
|
|
@@ -1696,6 +1764,25 @@ var onMutate = function(param) {
|
|
|
1696
1764
|
};
|
|
1697
1765
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
1698
1766
|
var import_json_whatwg = require("@streamparser/json-whatwg");
|
|
1767
|
+
// src/lib/threadIdCookies/ensure.ts
|
|
1768
|
+
var ensure = function(param) {
|
|
1769
|
+
var superinterfaceContext = param.superinterfaceContext, variables = param.variables, value = param.value;
|
|
1770
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
1771
|
+
console.log({
|
|
1772
|
+
value: value,
|
|
1773
|
+
variables: variables,
|
|
1774
|
+
superinterfaceContext: superinterfaceContext
|
|
1775
|
+
});
|
|
1776
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.set)) return;
|
|
1777
|
+
if (value.value.event !== "thread.run.created") return;
|
|
1778
|
+
if (variables.threadId) return;
|
|
1779
|
+
if (!variables.assistantId) return;
|
|
1780
|
+
console.log("saving");
|
|
1781
|
+
superinterfaceContext.threadIdCookieOptions.set({
|
|
1782
|
+
assistantId: variables.assistantId,
|
|
1783
|
+
threadId: value.value.data.thread_id
|
|
1784
|
+
});
|
|
1785
|
+
};
|
|
1699
1786
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/handleResponse/handlers/extendMessage.ts
|
|
1700
1787
|
var import_radash5 = require("radash");
|
|
1701
1788
|
var extendMessage = function(param) {
|
|
@@ -1928,9 +2015,9 @@ var updatedToolCall = function(param) {
|
|
|
1928
2015
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1929
2016
|
try {
|
|
1930
2017
|
for(var _iterator = Object.entries(delta.function)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1931
|
-
var _step_value = _sliced_to_array(_step.value, 2),
|
|
1932
|
-
var
|
|
1933
|
-
result.function[
|
|
2018
|
+
var _step_value = _sliced_to_array(_step.value, 2), key2 = _step_value[0], value = _step_value[1];
|
|
2019
|
+
var _result_function_key2;
|
|
2020
|
+
result.function[key2] = "".concat((_result_function_key2 = result.function[key2]) !== null && _result_function_key2 !== void 0 ? _result_function_key2 : "").concat(value);
|
|
1934
2021
|
}
|
|
1935
2022
|
} catch (err) {
|
|
1936
2023
|
_didIteratorError = true;
|
|
@@ -2049,6 +2136,29 @@ var handleResponse = function(param) {
|
|
|
2049
2136
|
value: value.value
|
|
2050
2137
|
}));
|
|
2051
2138
|
};
|
|
2139
|
+
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/body.ts
|
|
2140
|
+
var body = function(param) {
|
|
2141
|
+
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
2142
|
+
var _superinterfaceContext_threadIdCookieOptions;
|
|
2143
|
+
console.log({
|
|
2144
|
+
variables: variables,
|
|
2145
|
+
superinterfaceContext: superinterfaceContext
|
|
2146
|
+
});
|
|
2147
|
+
if (variables.threadId) return variables;
|
|
2148
|
+
if (!variables.assistantId) return variables;
|
|
2149
|
+
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
2150
|
+
console.log("using");
|
|
2151
|
+
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
2152
|
+
assistantId: variables.assistantId
|
|
2153
|
+
});
|
|
2154
|
+
if (!threadId) return variables;
|
|
2155
|
+
console.log({
|
|
2156
|
+
threadId: threadId
|
|
2157
|
+
});
|
|
2158
|
+
return _object_spread_props(_object_spread({}, variables), {
|
|
2159
|
+
threadId: threadId
|
|
2160
|
+
});
|
|
2161
|
+
};
|
|
2052
2162
|
// src/hooks/messages/useCreateMessage/lib/mutationOptions/mutationFn/index.ts
|
|
2053
2163
|
var mutationFn = function(param) {
|
|
2054
2164
|
var superinterfaceContext = param.superinterfaceContext, queryClient = param.queryClient, threadContext = param.threadContext;
|
|
@@ -2062,8 +2172,10 @@ var mutationFn = function(param) {
|
|
|
2062
2172
|
4,
|
|
2063
2173
|
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), _object_spread({
|
|
2064
2174
|
method: "POST",
|
|
2065
|
-
body: JSON.stringify(
|
|
2066
|
-
|
|
2175
|
+
body: JSON.stringify(body({
|
|
2176
|
+
variables: variables,
|
|
2177
|
+
superinterfaceContext: superinterfaceContext
|
|
2178
|
+
}))
|
|
2067
2179
|
}, superinterfaceContext.publicApiKey ? {
|
|
2068
2180
|
headers: {
|
|
2069
2181
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
@@ -2108,6 +2220,11 @@ var mutationFn = function(param) {
|
|
|
2108
2220
|
messagesQueryKey: messagesQueryKey,
|
|
2109
2221
|
queryClient: queryClient
|
|
2110
2222
|
});
|
|
2223
|
+
ensure({
|
|
2224
|
+
superinterfaceContext: superinterfaceContext,
|
|
2225
|
+
variables: variables,
|
|
2226
|
+
value: value
|
|
2227
|
+
});
|
|
2111
2228
|
return [
|
|
2112
2229
|
3,
|
|
2113
2230
|
2
|
|
@@ -3061,13 +3178,11 @@ var useMessageAudio = function(param) {
|
|
|
3061
3178
|
}
|
|
3062
3179
|
}
|
|
3063
3180
|
}, isHtmlAudioSupported ? {} : {
|
|
3064
|
-
xhr:
|
|
3181
|
+
xhr: _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
3065
3182
|
headers: {
|
|
3066
3183
|
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
3067
3184
|
}
|
|
3068
|
-
} : {})
|
|
3069
|
-
withCredentials: true
|
|
3070
|
-
})
|
|
3185
|
+
} : {})
|
|
3071
3186
|
}));
|
|
3072
3187
|
}, [
|
|
3073
3188
|
unplayedMessageSentences,
|