@iblai/web-utils 1.6.1 → 1.6.3
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/data-layer/src/features/claw/api-slice.d.ts +5471 -0
- package/dist/data-layer/src/features/claw/constants.d.ts +126 -0
- package/dist/data-layer/src/features/claw/types.d.ts +275 -0
- package/dist/data-layer/src/features/utils.d.ts +22 -7
- package/dist/data-layer/src/index.d.ts +3 -0
- package/dist/index.d.ts +22 -4
- package/dist/index.esm.js +723 -51
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +723 -50
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/utils/auth.d.ts +18 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -996,6 +996,15 @@ function clearCookies() {
|
|
|
996
996
|
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;Domain=${getParentDomain(window.location.hostname)}`;
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Get the value of a cookie by name
|
|
1001
|
+
* @param name - Cookie name
|
|
1002
|
+
* @returns The cookie value or null if not found
|
|
1003
|
+
*/
|
|
1004
|
+
function getCookieValue(name) {
|
|
1005
|
+
const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
|
|
1006
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
1007
|
+
}
|
|
999
1008
|
/**
|
|
1000
1009
|
* Check if user is currently logged in
|
|
1001
1010
|
* @param tokenKey - The localStorage key for the auth token (default: 'axd_token')
|
|
@@ -1060,8 +1069,48 @@ async function redirectToAuthSpa(options) {
|
|
|
1060
1069
|
userData: "ibl_user_data",
|
|
1061
1070
|
tenant: "ibl_tenant",
|
|
1062
1071
|
logoutTimestamp: "ibl_logout_timestamp",
|
|
1063
|
-
|
|
1064
|
-
|
|
1072
|
+
loginTimestamp: "ibl_login_timestamp",
|
|
1073
|
+
tenantSwitching: "ibl_tenant_switching",
|
|
1074
|
+
}, hasNonExpiredAuthToken, isOffline, preserveTokenKey, authRedirectProxy, isNativeApp, } = options;
|
|
1075
|
+
console.log("[redirectToAuthSpa] starting redirect to auth spa", redirectTo, platformKey, logout, saveRedirect);
|
|
1076
|
+
// Skip if a tenant switch is already in progress
|
|
1077
|
+
if (cookieNames.tenantSwitching &&
|
|
1078
|
+
document.cookie.includes(cookieNames.tenantSwitching)) {
|
|
1079
|
+
console.log("[redirectToAuthSpa] Tenant switch in progress, skipping redirect");
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
// Skip if a login occurred after the last logout (login takes precedence)
|
|
1083
|
+
// but only if this app actually has a valid auth token
|
|
1084
|
+
if (hasNonExpiredAuthToken &&
|
|
1085
|
+
cookieNames.loginTimestamp &&
|
|
1086
|
+
cookieNames.logoutTimestamp) {
|
|
1087
|
+
const loginTs = getCookieValue(cookieNames.loginTimestamp);
|
|
1088
|
+
const logoutTs = getCookieValue(cookieNames.logoutTimestamp);
|
|
1089
|
+
const hasValidToken = hasNonExpiredAuthToken();
|
|
1090
|
+
console.log("[redirectToAuthSpa] Login/logout timestamp check", {
|
|
1091
|
+
loginTs,
|
|
1092
|
+
logoutTs,
|
|
1093
|
+
hasValidToken,
|
|
1094
|
+
loginAhead: loginTs && logoutTs ? Number(loginTs) > Number(logoutTs) : false,
|
|
1095
|
+
});
|
|
1096
|
+
if (hasValidToken &&
|
|
1097
|
+
loginTs &&
|
|
1098
|
+
logoutTs &&
|
|
1099
|
+
Number(loginTs) > Number(logoutTs)) {
|
|
1100
|
+
console.log("[redirectToAuthSpa] Login timestamp is ahead of logout timestamp, skipping redirect", { loginTs, logoutTs });
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
// Skip redirect in offline mode
|
|
1105
|
+
if (isOffline === null || isOffline === void 0 ? void 0 : isOffline()) {
|
|
1106
|
+
console.log("[redirectToAuthSpa] Skipping redirect - offline mode");
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
// Preserve a token before clearing localStorage if requested
|
|
1110
|
+
const preservedToken = preserveTokenKey
|
|
1111
|
+
? window.localStorage.getItem(preserveTokenKey)
|
|
1112
|
+
: null;
|
|
1113
|
+
console.log("[redirectToAuthSpa] clearing local storage");
|
|
1065
1114
|
localStorage.clear();
|
|
1066
1115
|
if (logout || isInIframe()) {
|
|
1067
1116
|
// Delete authentication cookies for cross-SPA synchronization
|
|
@@ -1076,7 +1125,7 @@ async function redirectToAuthSpa(options) {
|
|
|
1076
1125
|
deleteCookieOnAllDomains(cookieNames.tenant, currentDomain);
|
|
1077
1126
|
}
|
|
1078
1127
|
// Set logout timestamp cookie to trigger logout on other SPAs
|
|
1079
|
-
if (cookieNames.logoutTimestamp) {
|
|
1128
|
+
if (cookieNames.logoutTimestamp && !isInIframe()) {
|
|
1080
1129
|
setCookieForAuth(cookieNames.logoutTimestamp, Date.now().toString());
|
|
1081
1130
|
}
|
|
1082
1131
|
}
|
|
@@ -1105,8 +1154,22 @@ async function redirectToAuthSpa(options) {
|
|
|
1105
1154
|
}
|
|
1106
1155
|
// Small delay for any pending operations
|
|
1107
1156
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1108
|
-
|
|
1109
|
-
|
|
1157
|
+
if (isNativeApp === null || isNativeApp === void 0 ? void 0 : isNativeApp()) {
|
|
1158
|
+
// On native apps (e.g., Tauri), pass preserved token and navigate directly
|
|
1159
|
+
if (preservedToken && preserveTokenKey) {
|
|
1160
|
+
authRedirectUrl += `&token=${encodeURIComponent(preservedToken)}`;
|
|
1161
|
+
console.log("[redirectToAuthSpa] Added preserved token to auth URL");
|
|
1162
|
+
}
|
|
1163
|
+
console.log("[redirectToAuthSpa] Native app, navigating to auth URL:", authRedirectUrl);
|
|
1164
|
+
window.location.href = authRedirectUrl;
|
|
1165
|
+
}
|
|
1166
|
+
else if (authRedirectProxy) {
|
|
1167
|
+
// Use auth redirect proxy endpoint
|
|
1168
|
+
window.location.href = `${authRedirectProxy}?to=${encodeURIComponent(authRedirectUrl)}`;
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
window.location.href = authRedirectUrl;
|
|
1172
|
+
}
|
|
1110
1173
|
}
|
|
1111
1174
|
/**
|
|
1112
1175
|
* Get the URL for joining a tenant (sign up flow)
|
|
@@ -3010,6 +3073,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
3010
3073
|
if (isProtectedRoute && storageService) {
|
|
3011
3074
|
const dmTokenInLocalStorage = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_KEY);
|
|
3012
3075
|
console.log("[auth-redirect] local storage keys ", LOCAL_STORAGE_KEYS);
|
|
3076
|
+
console.log("[auth-redirect] local storage ", JSON.stringify(localStorage));
|
|
3013
3077
|
const dmTokenExpired = await isDmTokenExpired(storageService);
|
|
3014
3078
|
if (!dmTokenInLocalStorage || dmTokenExpired) {
|
|
3015
3079
|
if (!!dmTokenInLocalStorage) {
|
|
@@ -13661,44 +13725,71 @@ const getHeaders = async (service) => {
|
|
|
13661
13725
|
}
|
|
13662
13726
|
return token ? { Authorization: `${prefix} ${token}` } : undefined;
|
|
13663
13727
|
};
|
|
13728
|
+
/** Status codes that should not be retried for queryFn endpoints. */
|
|
13729
|
+
const QUERYFN_NON_RETRYABLE_STATUSES = [401, 403, 500];
|
|
13730
|
+
/** Default max retries for queryFn endpoints. */
|
|
13731
|
+
const QUERYFN_MAX_RETRIES = 5;
|
|
13732
|
+
/** Base delay in ms for exponential backoff. */
|
|
13733
|
+
const QUERYFN_BASE_DELAY_MS = 1000;
|
|
13664
13734
|
/**
|
|
13665
13735
|
* Build a generic RTK Query endpoint from a service function.
|
|
13736
|
+
* Includes built-in retry with exponential backoff (since RTK Query
|
|
13737
|
+
* skips baseQuery retry for queryFn endpoints).
|
|
13666
13738
|
*/
|
|
13667
|
-
const buildEndpointFromService = (service, serviceFn) => {
|
|
13739
|
+
const buildEndpointFromService = (service, serviceFn, options) => {
|
|
13740
|
+
var _a;
|
|
13741
|
+
const maxRetries = (_a = void 0 ) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
|
|
13668
13742
|
return {
|
|
13669
13743
|
async queryFn(args) {
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
}
|
|
13679
|
-
catch (err) {
|
|
13680
|
-
console.error('[data-layer] API error:', JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
13681
|
-
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13682
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({ ...((err === null || err === void 0 ? void 0 : err.data) || {}) });
|
|
13744
|
+
let lastError;
|
|
13745
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
13746
|
+
try {
|
|
13747
|
+
OpenAPI.BASE = getServiceUrl(service);
|
|
13748
|
+
OpenAPI.HEADERS = await getHeaders(service);
|
|
13749
|
+
OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
|
|
13750
|
+
const data = await serviceFn(args);
|
|
13751
|
+
return { data };
|
|
13683
13752
|
}
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13753
|
+
catch (err) {
|
|
13754
|
+
lastError = err;
|
|
13755
|
+
const status = err === null || err === void 0 ? void 0 : err.status;
|
|
13756
|
+
// Don't retry auth errors
|
|
13757
|
+
if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status)) {
|
|
13758
|
+
break;
|
|
13759
|
+
}
|
|
13760
|
+
// If we have retries left, wait with exponential backoff
|
|
13761
|
+
if (attempt < maxRetries) {
|
|
13762
|
+
const delay = QUERYFN_BASE_DELAY_MS * Math.pow(2, attempt);
|
|
13763
|
+
console.warn(`[data-layer] Retry ${attempt + 1}/${maxRetries}:`, `service=${service}, fn=${serviceFn.name || 'anonymous'}`);
|
|
13764
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
13765
|
+
continue;
|
|
13766
|
+
}
|
|
13767
|
+
}
|
|
13768
|
+
}
|
|
13769
|
+
// All retries exhausted or non-retryable error
|
|
13770
|
+
console.error('[data-layer] API error:', `service=${service}, fn=${serviceFn.name || 'anonymous'}`, JSON.stringify(lastError, Object.getOwnPropertyNames(lastError)));
|
|
13771
|
+
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
|
|
13772
|
+
Config.httpErrorHandlers[lastError === null || lastError === void 0 ? void 0 : lastError.status]({
|
|
13773
|
+
...((lastError === null || lastError === void 0 ? void 0 : lastError.data) || {}),
|
|
13774
|
+
});
|
|
13690
13775
|
}
|
|
13776
|
+
return {
|
|
13777
|
+
error: {
|
|
13778
|
+
status: (lastError === null || lastError === void 0 ? void 0 : lastError.status) || 500,
|
|
13779
|
+
data: (lastError === null || lastError === void 0 ? void 0 : lastError.body) || (lastError === null || lastError === void 0 ? void 0 : lastError.data) || (lastError === null || lastError === void 0 ? void 0 : lastError.message) || 'Unknown error',
|
|
13780
|
+
},
|
|
13781
|
+
};
|
|
13691
13782
|
},
|
|
13692
13783
|
};
|
|
13693
13784
|
};
|
|
13694
13785
|
/**
|
|
13695
13786
|
* Shortcut for building an endpoint using the DM service.
|
|
13696
13787
|
*/
|
|
13697
|
-
const buildEndpointFromDmService = (serviceFn) => buildEndpointFromService(SERVICES.DM, serviceFn);
|
|
13788
|
+
const buildEndpointFromDmService = (serviceFn, options) => buildEndpointFromService(SERVICES.DM, serviceFn);
|
|
13698
13789
|
/**
|
|
13699
13790
|
* Shortcut for building an endpoint using the AXD service.
|
|
13700
13791
|
*/
|
|
13701
|
-
const buildEndpointFromAxdService = (serviceFn) => buildEndpointFromService(SERVICES.AXD, serviceFn);
|
|
13792
|
+
const buildEndpointFromAxdService = (serviceFn, options) => buildEndpointFromService(SERVICES.AXD, serviceFn);
|
|
13702
13793
|
const isErrorObject = (data) => {
|
|
13703
13794
|
return (typeof data === 'object' &&
|
|
13704
13795
|
data !== null &&
|
|
@@ -13830,40 +13921,57 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
13830
13921
|
}
|
|
13831
13922
|
};
|
|
13832
13923
|
/**
|
|
13833
|
-
* Build a generic RTK Query endpoint from a service function.
|
|
13924
|
+
* Build a generic RTK Query endpoint from a service function (legacy variant).
|
|
13925
|
+
* Includes built-in retry with exponential backoff.
|
|
13834
13926
|
*/
|
|
13835
|
-
const buildEndpointFromServiceLegacy = (service, serviceFn) => {
|
|
13927
|
+
const buildEndpointFromServiceLegacy = (service, serviceFn, options) => {
|
|
13928
|
+
var _a;
|
|
13929
|
+
const maxRetries = (_a = void 0 ) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
|
|
13836
13930
|
return {
|
|
13837
13931
|
async queryFn(args) {
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13847
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({
|
|
13848
|
-
status: err === null || err === void 0 ? void 0 : err.status,
|
|
13849
|
-
body: err === null || err === void 0 ? void 0 : err.body,
|
|
13850
|
-
message: err === null || err === void 0 ? void 0 : err.message,
|
|
13851
|
-
});
|
|
13932
|
+
let lastError;
|
|
13933
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
13934
|
+
try {
|
|
13935
|
+
OpenAPI.BASE = getServiceUrl(service);
|
|
13936
|
+
OpenAPI.HEADERS = await getHeaders(service);
|
|
13937
|
+
OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
|
|
13938
|
+
const data = await serviceFn(...args);
|
|
13939
|
+
return { data };
|
|
13852
13940
|
}
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13941
|
+
catch (err) {
|
|
13942
|
+
lastError = err;
|
|
13943
|
+
const status = err === null || err === void 0 ? void 0 : err.status;
|
|
13944
|
+
if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status)) {
|
|
13945
|
+
break;
|
|
13946
|
+
}
|
|
13947
|
+
if (attempt < maxRetries) {
|
|
13948
|
+
const delay = QUERYFN_BASE_DELAY_MS * Math.pow(2, attempt);
|
|
13949
|
+
console.warn(`[data-layer] Retry ${attempt + 1}/${maxRetries}:`, `service=${service}, fn=${serviceFn.name || 'anonymous'}`);
|
|
13950
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
13951
|
+
continue;
|
|
13952
|
+
}
|
|
13953
|
+
}
|
|
13954
|
+
}
|
|
13955
|
+
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
|
|
13956
|
+
Config.httpErrorHandlers[lastError === null || lastError === void 0 ? void 0 : lastError.status]({
|
|
13957
|
+
status: lastError === null || lastError === void 0 ? void 0 : lastError.status,
|
|
13958
|
+
body: lastError === null || lastError === void 0 ? void 0 : lastError.body,
|
|
13959
|
+
message: lastError === null || lastError === void 0 ? void 0 : lastError.message,
|
|
13960
|
+
});
|
|
13859
13961
|
}
|
|
13962
|
+
return {
|
|
13963
|
+
error: {
|
|
13964
|
+
status: (lastError === null || lastError === void 0 ? void 0 : lastError.status) || 500,
|
|
13965
|
+
data: (lastError === null || lastError === void 0 ? void 0 : lastError.body) || (lastError === null || lastError === void 0 ? void 0 : lastError.message) || 'Unknown error',
|
|
13966
|
+
},
|
|
13967
|
+
};
|
|
13860
13968
|
},
|
|
13861
13969
|
};
|
|
13862
13970
|
};
|
|
13863
13971
|
/**
|
|
13864
13972
|
* Shortcut for building an endpoint using the DM service.
|
|
13865
13973
|
*/
|
|
13866
|
-
const buildEndpointFromDmServiceLegacy = (serviceFn) => buildEndpointFromServiceLegacy(SERVICES.DM, serviceFn);
|
|
13974
|
+
const buildEndpointFromDmServiceLegacy = (serviceFn, options) => buildEndpointFromServiceLegacy(SERVICES.DM, serviceFn);
|
|
13867
13975
|
|
|
13868
13976
|
createApi({
|
|
13869
13977
|
reducerPath: 'apiKeysApiSlice',
|
|
@@ -17635,6 +17743,570 @@ createApi({
|
|
|
17635
17743
|
}),
|
|
17636
17744
|
});
|
|
17637
17745
|
|
|
17746
|
+
const CLAW_REDUCER_PATH = 'clawApiSlice';
|
|
17747
|
+
const CLAW_TAG_TYPES = [
|
|
17748
|
+
'ClawMentorConfig',
|
|
17749
|
+
'ClawInstances',
|
|
17750
|
+
'AgentConfig',
|
|
17751
|
+
'AgentSkills',
|
|
17752
|
+
'AgentSkillResources',
|
|
17753
|
+
'MentorSkillAssignments',
|
|
17754
|
+
];
|
|
17755
|
+
const CLAW_ENDPOINTS = {
|
|
17756
|
+
// ── Claw Mentor Config (singular, nested under mentor) ─────────────────────
|
|
17757
|
+
GET_MENTOR_CONFIG: {
|
|
17758
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17759
|
+
service: SERVICES.DM,
|
|
17760
|
+
},
|
|
17761
|
+
CREATE_MENTOR_CONFIG: {
|
|
17762
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17763
|
+
service: SERVICES.DM,
|
|
17764
|
+
},
|
|
17765
|
+
UPDATE_MENTOR_CONFIG: {
|
|
17766
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17767
|
+
service: SERVICES.DM,
|
|
17768
|
+
},
|
|
17769
|
+
DELETE_MENTOR_CONFIG: {
|
|
17770
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17771
|
+
service: SERVICES.DM,
|
|
17772
|
+
},
|
|
17773
|
+
PUSH_CONFIG: {
|
|
17774
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/push-config/`,
|
|
17775
|
+
service: SERVICES.DM,
|
|
17776
|
+
},
|
|
17777
|
+
// ── Claw Instances (unchanged) ─────────────────────────────────────────────
|
|
17778
|
+
GET_INSTANCES: {
|
|
17779
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/claw/instances/`,
|
|
17780
|
+
service: SERVICES.DM,
|
|
17781
|
+
},
|
|
17782
|
+
GET_INSTANCE: {
|
|
17783
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/`,
|
|
17784
|
+
service: SERVICES.DM,
|
|
17785
|
+
},
|
|
17786
|
+
CREATE_INSTANCE: {
|
|
17787
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/claw/instances/`,
|
|
17788
|
+
service: SERVICES.DM,
|
|
17789
|
+
},
|
|
17790
|
+
UPDATE_INSTANCE: {
|
|
17791
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/`,
|
|
17792
|
+
service: SERVICES.DM,
|
|
17793
|
+
},
|
|
17794
|
+
DELETE_INSTANCE: {
|
|
17795
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/`,
|
|
17796
|
+
service: SERVICES.DM,
|
|
17797
|
+
},
|
|
17798
|
+
HEALTH_CHECK_INSTANCE: {
|
|
17799
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/health-check/`,
|
|
17800
|
+
service: SERVICES.DM,
|
|
17801
|
+
},
|
|
17802
|
+
TEST_CONNECTIVITY_INSTANCE: {
|
|
17803
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/test-connectivity/`,
|
|
17804
|
+
service: SERVICES.DM,
|
|
17805
|
+
},
|
|
17806
|
+
REFRESH_VERSION_INSTANCE: {
|
|
17807
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/refresh-version/`,
|
|
17808
|
+
service: SERVICES.DM,
|
|
17809
|
+
},
|
|
17810
|
+
// ── Agent Config (singular, nested under mentor) ───────────────────────────
|
|
17811
|
+
GET_AGENT_CONFIG: {
|
|
17812
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/agent-config/`,
|
|
17813
|
+
service: SERVICES.DM,
|
|
17814
|
+
},
|
|
17815
|
+
/** PATCH is upsert — first write bootstraps the row, no separate POST. */
|
|
17816
|
+
UPDATE_AGENT_CONFIG: {
|
|
17817
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/agent-config/`,
|
|
17818
|
+
service: SERVICES.DM,
|
|
17819
|
+
},
|
|
17820
|
+
// ── Agent Skills (platform-level, unchanged) ───────────────────────────────
|
|
17821
|
+
GET_AGENT_SKILLS: {
|
|
17822
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skills/`,
|
|
17823
|
+
service: SERVICES.DM,
|
|
17824
|
+
},
|
|
17825
|
+
GET_AGENT_SKILL: {
|
|
17826
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skills/${id}/`,
|
|
17827
|
+
service: SERVICES.DM,
|
|
17828
|
+
},
|
|
17829
|
+
CREATE_AGENT_SKILL: {
|
|
17830
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skills/`,
|
|
17831
|
+
service: SERVICES.DM,
|
|
17832
|
+
},
|
|
17833
|
+
UPDATE_AGENT_SKILL: {
|
|
17834
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skills/${id}/`,
|
|
17835
|
+
service: SERVICES.DM,
|
|
17836
|
+
},
|
|
17837
|
+
DELETE_AGENT_SKILL: {
|
|
17838
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skills/${id}/`,
|
|
17839
|
+
service: SERVICES.DM,
|
|
17840
|
+
},
|
|
17841
|
+
// ── Agent Skill Resources (file resources attached to skills) ──────────────
|
|
17842
|
+
GET_AGENT_SKILL_RESOURCES: {
|
|
17843
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/`,
|
|
17844
|
+
service: SERVICES.DM,
|
|
17845
|
+
},
|
|
17846
|
+
GET_AGENT_SKILL_RESOURCE: {
|
|
17847
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/${id}/`,
|
|
17848
|
+
service: SERVICES.DM,
|
|
17849
|
+
},
|
|
17850
|
+
CREATE_AGENT_SKILL_RESOURCE: {
|
|
17851
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/`,
|
|
17852
|
+
service: SERVICES.DM,
|
|
17853
|
+
},
|
|
17854
|
+
UPDATE_AGENT_SKILL_RESOURCE: {
|
|
17855
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/${id}/`,
|
|
17856
|
+
service: SERVICES.DM,
|
|
17857
|
+
},
|
|
17858
|
+
DELETE_AGENT_SKILL_RESOURCE: {
|
|
17859
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/${id}/`,
|
|
17860
|
+
service: SERVICES.DM,
|
|
17861
|
+
},
|
|
17862
|
+
// ── Mentor Skill Assignments (nested under mentor) ─────────────────────────
|
|
17863
|
+
GET_MENTOR_SKILL_ASSIGNMENTS: {
|
|
17864
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/`,
|
|
17865
|
+
service: SERVICES.DM,
|
|
17866
|
+
},
|
|
17867
|
+
CREATE_MENTOR_SKILL_ASSIGNMENT: {
|
|
17868
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/`,
|
|
17869
|
+
service: SERVICES.DM,
|
|
17870
|
+
},
|
|
17871
|
+
GET_MENTOR_SKILL_ASSIGNMENT: {
|
|
17872
|
+
path: (org, mentorUniqueId, assignmentPk) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/${assignmentPk}/`,
|
|
17873
|
+
service: SERVICES.DM,
|
|
17874
|
+
},
|
|
17875
|
+
UPDATE_MENTOR_SKILL_ASSIGNMENT: {
|
|
17876
|
+
path: (org, mentorUniqueId, assignmentPk) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/${assignmentPk}/`,
|
|
17877
|
+
service: SERVICES.DM,
|
|
17878
|
+
},
|
|
17879
|
+
DELETE_MENTOR_SKILL_ASSIGNMENT: {
|
|
17880
|
+
path: (org, mentorUniqueId, assignmentPk) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/${assignmentPk}/`,
|
|
17881
|
+
service: SERVICES.DM,
|
|
17882
|
+
},
|
|
17883
|
+
};
|
|
17884
|
+
|
|
17885
|
+
/**
|
|
17886
|
+
* Normalize API responses that may return either a plain array or a
|
|
17887
|
+
* paginated envelope `{ results: T[] }`.
|
|
17888
|
+
*/
|
|
17889
|
+
function normalizeList(response) {
|
|
17890
|
+
return Array.isArray(response) ? response : response.results;
|
|
17891
|
+
}
|
|
17892
|
+
const clawApiSlice = createApi({
|
|
17893
|
+
reducerPath: CLAW_REDUCER_PATH,
|
|
17894
|
+
baseQuery: iblFetchBaseQuery,
|
|
17895
|
+
tagTypes: [...CLAW_TAG_TYPES],
|
|
17896
|
+
endpoints: (builder) => ({
|
|
17897
|
+
// ── Claw Mentor Config (singular) ─────────────────────────────────────
|
|
17898
|
+
getClawMentorConfig: builder.query({
|
|
17899
|
+
query: (args) => ({
|
|
17900
|
+
url: CLAW_ENDPOINTS.GET_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17901
|
+
service: CLAW_ENDPOINTS.GET_MENTOR_CONFIG.service,
|
|
17902
|
+
}),
|
|
17903
|
+
providesTags: (_result, _error, args) => [
|
|
17904
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17905
|
+
],
|
|
17906
|
+
}),
|
|
17907
|
+
createClawMentorConfig: builder.mutation({
|
|
17908
|
+
query: (args) => ({
|
|
17909
|
+
url: CLAW_ENDPOINTS.CREATE_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17910
|
+
service: CLAW_ENDPOINTS.CREATE_MENTOR_CONFIG.service,
|
|
17911
|
+
method: 'POST',
|
|
17912
|
+
body: {
|
|
17913
|
+
server: args.server,
|
|
17914
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
17915
|
+
...(args.agent_id !== undefined && { agent_id: args.agent_id }),
|
|
17916
|
+
},
|
|
17917
|
+
}),
|
|
17918
|
+
// Seed the GET cache with the create response and then invalidate so the
|
|
17919
|
+
// subscribed query refetches the joined fields (server_name, status, etc.)
|
|
17920
|
+
// that the POST body doesn't include. The refetch is a 200 — no retry storm.
|
|
17921
|
+
async onQueryStarted({ org, mentorUniqueId }, { dispatch, queryFulfilled }) {
|
|
17922
|
+
try {
|
|
17923
|
+
const { data } = await queryFulfilled;
|
|
17924
|
+
dispatch(clawApiSlice.util.upsertQueryData('getClawMentorConfig', { org, mentorUniqueId }, data));
|
|
17925
|
+
}
|
|
17926
|
+
catch (_a) {
|
|
17927
|
+
// Surface error via the mutation's own error state.
|
|
17928
|
+
}
|
|
17929
|
+
},
|
|
17930
|
+
invalidatesTags: (_result, _error, args) => [
|
|
17931
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17932
|
+
],
|
|
17933
|
+
}),
|
|
17934
|
+
updateClawMentorConfig: builder.mutation({
|
|
17935
|
+
query: (args) => ({
|
|
17936
|
+
url: CLAW_ENDPOINTS.UPDATE_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17937
|
+
service: CLAW_ENDPOINTS.UPDATE_MENTOR_CONFIG.service,
|
|
17938
|
+
method: 'PATCH',
|
|
17939
|
+
body: {
|
|
17940
|
+
...(args.server !== undefined && { server: args.server }),
|
|
17941
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
17942
|
+
...(args.auto_push !== undefined && { auto_push: args.auto_push }),
|
|
17943
|
+
...(args.agent_config !== undefined && { agent_config: args.agent_config }),
|
|
17944
|
+
...(args.agent_id !== undefined && { agent_id: args.agent_id }),
|
|
17945
|
+
},
|
|
17946
|
+
}),
|
|
17947
|
+
invalidatesTags: (_result, _error, args) => [
|
|
17948
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17949
|
+
],
|
|
17950
|
+
}),
|
|
17951
|
+
deleteClawMentorConfig: builder.mutation({
|
|
17952
|
+
query: (args) => ({
|
|
17953
|
+
url: CLAW_ENDPOINTS.DELETE_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17954
|
+
service: CLAW_ENDPOINTS.DELETE_MENTOR_CONFIG.service,
|
|
17955
|
+
method: 'DELETE',
|
|
17956
|
+
}),
|
|
17957
|
+
// Optimistically clear the GET cache before the request resolves so the
|
|
17958
|
+
// UI flips to "not connected" instantly. On failure, invalidate to refetch
|
|
17959
|
+
// the real state. We don't invalidate on success — the GET would 404 and
|
|
17960
|
+
// the base query retries 3× on error, which is the lag the user sees.
|
|
17961
|
+
async onQueryStarted({ org, mentorUniqueId }, { dispatch, queryFulfilled }) {
|
|
17962
|
+
dispatch(clawApiSlice.util.upsertQueryData('getClawMentorConfig', { org, mentorUniqueId }, null));
|
|
17963
|
+
try {
|
|
17964
|
+
await queryFulfilled;
|
|
17965
|
+
}
|
|
17966
|
+
catch (_a) {
|
|
17967
|
+
dispatch(clawApiSlice.util.invalidateTags([{ type: 'ClawMentorConfig', id: mentorUniqueId }]));
|
|
17968
|
+
}
|
|
17969
|
+
},
|
|
17970
|
+
}),
|
|
17971
|
+
pushClawConfig: builder.mutation({
|
|
17972
|
+
query: (args) => ({
|
|
17973
|
+
url: CLAW_ENDPOINTS.PUSH_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17974
|
+
service: CLAW_ENDPOINTS.PUSH_CONFIG.service,
|
|
17975
|
+
method: 'POST',
|
|
17976
|
+
}),
|
|
17977
|
+
invalidatesTags: (_result, _error, args) => [
|
|
17978
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17979
|
+
],
|
|
17980
|
+
}),
|
|
17981
|
+
// ── Claw Instances ────────────────────────────────────────────────────
|
|
17982
|
+
getClawInstances: builder.query({
|
|
17983
|
+
query: (args) => ({
|
|
17984
|
+
url: CLAW_ENDPOINTS.GET_INSTANCES.path(args.org),
|
|
17985
|
+
service: CLAW_ENDPOINTS.GET_INSTANCES.service,
|
|
17986
|
+
}),
|
|
17987
|
+
transformResponse: (response) => normalizeList(response),
|
|
17988
|
+
providesTags: ['ClawInstances'],
|
|
17989
|
+
}),
|
|
17990
|
+
getClawInstance: builder.query({
|
|
17991
|
+
query: (args) => ({
|
|
17992
|
+
url: CLAW_ENDPOINTS.GET_INSTANCE.path(args.org, args.id),
|
|
17993
|
+
service: CLAW_ENDPOINTS.GET_INSTANCE.service,
|
|
17994
|
+
}),
|
|
17995
|
+
providesTags: (_result, _error, args) => [{ type: 'ClawInstances', id: args.id }],
|
|
17996
|
+
}),
|
|
17997
|
+
createClawInstance: builder.mutation({
|
|
17998
|
+
query: (args) => ({
|
|
17999
|
+
url: CLAW_ENDPOINTS.CREATE_INSTANCE.path(args.org),
|
|
18000
|
+
service: CLAW_ENDPOINTS.CREATE_INSTANCE.service,
|
|
18001
|
+
method: 'POST',
|
|
18002
|
+
body: {
|
|
18003
|
+
name: args.name,
|
|
18004
|
+
claw_type: args.claw_type,
|
|
18005
|
+
server_url: args.server_url,
|
|
18006
|
+
...(args.gateway_token && { gateway_token: args.gateway_token }),
|
|
18007
|
+
...(args.auth_headers && { auth_headers: args.auth_headers }),
|
|
18008
|
+
...(args.connection_params && { connection_params: args.connection_params }),
|
|
18009
|
+
...(args.deployment_backend !== undefined && {
|
|
18010
|
+
deployment_backend: args.deployment_backend,
|
|
18011
|
+
}),
|
|
18012
|
+
},
|
|
18013
|
+
}),
|
|
18014
|
+
invalidatesTags: ['ClawInstances'],
|
|
18015
|
+
}),
|
|
18016
|
+
updateClawInstance: builder.mutation({
|
|
18017
|
+
query: (args) => ({
|
|
18018
|
+
url: CLAW_ENDPOINTS.UPDATE_INSTANCE.path(args.org, args.id),
|
|
18019
|
+
service: CLAW_ENDPOINTS.UPDATE_INSTANCE.service,
|
|
18020
|
+
method: 'PATCH',
|
|
18021
|
+
body: {
|
|
18022
|
+
...(args.name !== undefined && { name: args.name }),
|
|
18023
|
+
...(args.claw_type !== undefined && { claw_type: args.claw_type }),
|
|
18024
|
+
...(args.server_url !== undefined && { server_url: args.server_url }),
|
|
18025
|
+
...(args.gateway_token && { gateway_token: args.gateway_token }),
|
|
18026
|
+
...(args.auth_headers && { auth_headers: args.auth_headers }),
|
|
18027
|
+
...(args.connection_params && { connection_params: args.connection_params }),
|
|
18028
|
+
...(args.deployment_backend !== undefined && {
|
|
18029
|
+
deployment_backend: args.deployment_backend,
|
|
18030
|
+
}),
|
|
18031
|
+
},
|
|
18032
|
+
}),
|
|
18033
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18034
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18035
|
+
'ClawInstances',
|
|
18036
|
+
],
|
|
18037
|
+
}),
|
|
18038
|
+
deleteClawInstance: builder.mutation({
|
|
18039
|
+
query: (args) => ({
|
|
18040
|
+
url: CLAW_ENDPOINTS.DELETE_INSTANCE.path(args.org, args.id),
|
|
18041
|
+
service: CLAW_ENDPOINTS.DELETE_INSTANCE.service,
|
|
18042
|
+
method: 'DELETE',
|
|
18043
|
+
}),
|
|
18044
|
+
invalidatesTags: ['ClawInstances'],
|
|
18045
|
+
}),
|
|
18046
|
+
healthCheckClawInstance: builder.mutation({
|
|
18047
|
+
query: (args) => ({
|
|
18048
|
+
url: CLAW_ENDPOINTS.HEALTH_CHECK_INSTANCE.path(args.org, args.id),
|
|
18049
|
+
service: CLAW_ENDPOINTS.HEALTH_CHECK_INSTANCE.service,
|
|
18050
|
+
method: 'POST',
|
|
18051
|
+
}),
|
|
18052
|
+
// Health check updates last_health_check / last_health_status / claw_version
|
|
18053
|
+
// on the instance — invalidate so the list refetches with fresh values.
|
|
18054
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18055
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18056
|
+
'ClawInstances',
|
|
18057
|
+
],
|
|
18058
|
+
}),
|
|
18059
|
+
testConnectivityClawInstance: builder.mutation({
|
|
18060
|
+
query: (args) => ({
|
|
18061
|
+
url: CLAW_ENDPOINTS.TEST_CONNECTIVITY_INSTANCE.path(args.org, args.id),
|
|
18062
|
+
service: CLAW_ENDPOINTS.TEST_CONNECTIVITY_INSTANCE.service,
|
|
18063
|
+
method: 'POST',
|
|
18064
|
+
}),
|
|
18065
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18066
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18067
|
+
'ClawInstances',
|
|
18068
|
+
],
|
|
18069
|
+
}),
|
|
18070
|
+
refreshVersionClawInstance: builder.mutation({
|
|
18071
|
+
query: (args) => ({
|
|
18072
|
+
url: CLAW_ENDPOINTS.REFRESH_VERSION_INSTANCE.path(args.org, args.id),
|
|
18073
|
+
service: CLAW_ENDPOINTS.REFRESH_VERSION_INSTANCE.service,
|
|
18074
|
+
method: 'POST',
|
|
18075
|
+
}),
|
|
18076
|
+
// Refresh-version updates the instance's `claw_version` (and may touch
|
|
18077
|
+
// health fields too) — invalidate so the table picks up the new value.
|
|
18078
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18079
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18080
|
+
'ClawInstances',
|
|
18081
|
+
],
|
|
18082
|
+
}),
|
|
18083
|
+
// ── Agent Config (singular, PATCH is upsert) ──────────────────────────
|
|
18084
|
+
getAgentConfig: builder.query({
|
|
18085
|
+
query: (args) => ({
|
|
18086
|
+
url: CLAW_ENDPOINTS.GET_AGENT_CONFIG.path(args.org, args.mentorUniqueId),
|
|
18087
|
+
service: CLAW_ENDPOINTS.GET_AGENT_CONFIG.service,
|
|
18088
|
+
}),
|
|
18089
|
+
providesTags: (_result, _error, args) => [{ type: 'AgentConfig', id: args.mentorUniqueId }],
|
|
18090
|
+
}),
|
|
18091
|
+
updateAgentConfig: builder.mutation({
|
|
18092
|
+
query: (args) => ({
|
|
18093
|
+
url: CLAW_ENDPOINTS.UPDATE_AGENT_CONFIG.path(args.org, args.mentorUniqueId),
|
|
18094
|
+
service: CLAW_ENDPOINTS.UPDATE_AGENT_CONFIG.service,
|
|
18095
|
+
method: 'PATCH',
|
|
18096
|
+
body: {
|
|
18097
|
+
...(args.identity !== undefined && { identity: args.identity }),
|
|
18098
|
+
...(args.soul !== undefined && { soul: args.soul }),
|
|
18099
|
+
...(args.user_context !== undefined && { user_context: args.user_context }),
|
|
18100
|
+
...(args.tools !== undefined && { tools: args.tools }),
|
|
18101
|
+
...(args.agents !== undefined && { agents: args.agents }),
|
|
18102
|
+
...(args.bootstrap !== undefined && { bootstrap: args.bootstrap }),
|
|
18103
|
+
...(args.heartbeat !== undefined && { heartbeat: args.heartbeat }),
|
|
18104
|
+
...(args.memory !== undefined && { memory: args.memory }),
|
|
18105
|
+
...(args.model !== undefined && { model: args.model }),
|
|
18106
|
+
...(args.config !== undefined && { config: args.config }),
|
|
18107
|
+
},
|
|
18108
|
+
}),
|
|
18109
|
+
// PATCH is upsert and returns the full AgentConfig. Write it straight into
|
|
18110
|
+
// the GET cache so UI subscribers see the new value immediately — relying
|
|
18111
|
+
// on tag invalidation alone leaves a stale window when the prior GET was a
|
|
18112
|
+
// 404 (the entry sits in error state until the refetch completes).
|
|
18113
|
+
async onQueryStarted({ org, mentorUniqueId }, { dispatch, queryFulfilled }) {
|
|
18114
|
+
try {
|
|
18115
|
+
const { data } = await queryFulfilled;
|
|
18116
|
+
dispatch(clawApiSlice.util.upsertQueryData('getAgentConfig', { org, mentorUniqueId }, data));
|
|
18117
|
+
}
|
|
18118
|
+
catch (_a) {
|
|
18119
|
+
// Mutation error surfaces via the hook's own state.
|
|
18120
|
+
}
|
|
18121
|
+
},
|
|
18122
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18123
|
+
{ type: 'AgentConfig', id: args.mentorUniqueId },
|
|
18124
|
+
],
|
|
18125
|
+
}),
|
|
18126
|
+
// ── Agent Skills (platform-level) ─────────────────────────────────────
|
|
18127
|
+
getAgentSkills: builder.query({
|
|
18128
|
+
query: (args) => ({
|
|
18129
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILLS.path(args.org),
|
|
18130
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILLS.service,
|
|
18131
|
+
}),
|
|
18132
|
+
transformResponse: (response) => normalizeList(response),
|
|
18133
|
+
providesTags: ['AgentSkills'],
|
|
18134
|
+
}),
|
|
18135
|
+
getAgentSkill: builder.query({
|
|
18136
|
+
query: (args) => ({
|
|
18137
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILL.path(args.org, args.id),
|
|
18138
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILL.service,
|
|
18139
|
+
}),
|
|
18140
|
+
providesTags: (_result, _error, args) => [{ type: 'AgentSkills', id: args.id }],
|
|
18141
|
+
}),
|
|
18142
|
+
createAgentSkill: builder.mutation({
|
|
18143
|
+
query: (args) => ({
|
|
18144
|
+
url: CLAW_ENDPOINTS.CREATE_AGENT_SKILL.path(args.org),
|
|
18145
|
+
service: CLAW_ENDPOINTS.CREATE_AGENT_SKILL.service,
|
|
18146
|
+
method: 'POST',
|
|
18147
|
+
body: {
|
|
18148
|
+
name: args.name,
|
|
18149
|
+
slug: args.slug,
|
|
18150
|
+
...(args.description !== undefined && { description: args.description }),
|
|
18151
|
+
...(args.version !== undefined && { version: args.version }),
|
|
18152
|
+
...(args.instruction !== undefined && { instruction: args.instruction }),
|
|
18153
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18154
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18155
|
+
},
|
|
18156
|
+
}),
|
|
18157
|
+
invalidatesTags: ['AgentSkills'],
|
|
18158
|
+
}),
|
|
18159
|
+
updateAgentSkill: builder.mutation({
|
|
18160
|
+
query: (args) => ({
|
|
18161
|
+
url: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL.path(args.org, args.id),
|
|
18162
|
+
service: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL.service,
|
|
18163
|
+
method: 'PATCH',
|
|
18164
|
+
body: {
|
|
18165
|
+
...(args.name !== undefined && { name: args.name }),
|
|
18166
|
+
...(args.slug !== undefined && { slug: args.slug }),
|
|
18167
|
+
...(args.description !== undefined && { description: args.description }),
|
|
18168
|
+
...(args.version !== undefined && { version: args.version }),
|
|
18169
|
+
...(args.instruction !== undefined && { instruction: args.instruction }),
|
|
18170
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18171
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18172
|
+
},
|
|
18173
|
+
}),
|
|
18174
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18175
|
+
{ type: 'AgentSkills', id: args.id },
|
|
18176
|
+
'AgentSkills',
|
|
18177
|
+
],
|
|
18178
|
+
}),
|
|
18179
|
+
deleteAgentSkill: builder.mutation({
|
|
18180
|
+
query: (args) => ({
|
|
18181
|
+
url: CLAW_ENDPOINTS.DELETE_AGENT_SKILL.path(args.org, args.id),
|
|
18182
|
+
service: CLAW_ENDPOINTS.DELETE_AGENT_SKILL.service,
|
|
18183
|
+
method: 'DELETE',
|
|
18184
|
+
}),
|
|
18185
|
+
invalidatesTags: ['AgentSkills'],
|
|
18186
|
+
}),
|
|
18187
|
+
// ── Agent Skill Resources ─────────────────────────────────────────────
|
|
18188
|
+
getAgentSkillResources: builder.query({
|
|
18189
|
+
query: (args) => ({
|
|
18190
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCES.path(args.org),
|
|
18191
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCES.service,
|
|
18192
|
+
params: {
|
|
18193
|
+
...(args.skill !== undefined && { skill: args.skill }),
|
|
18194
|
+
...(args.file_type !== undefined && { file_type: args.file_type }),
|
|
18195
|
+
},
|
|
18196
|
+
}),
|
|
18197
|
+
transformResponse: (response) => normalizeList(response),
|
|
18198
|
+
providesTags: ['AgentSkillResources'],
|
|
18199
|
+
}),
|
|
18200
|
+
getAgentSkillResource: builder.query({
|
|
18201
|
+
query: (args) => ({
|
|
18202
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCE.path(args.org, args.id),
|
|
18203
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCE.service,
|
|
18204
|
+
}),
|
|
18205
|
+
providesTags: (_result, _error, args) => [{ type: 'AgentSkillResources', id: args.id }],
|
|
18206
|
+
}),
|
|
18207
|
+
createAgentSkillResource: builder.mutation({
|
|
18208
|
+
query: (args) => ({
|
|
18209
|
+
url: CLAW_ENDPOINTS.CREATE_AGENT_SKILL_RESOURCE.path(args.org),
|
|
18210
|
+
service: CLAW_ENDPOINTS.CREATE_AGENT_SKILL_RESOURCE.service,
|
|
18211
|
+
method: 'POST',
|
|
18212
|
+
body: {
|
|
18213
|
+
skill: args.skill,
|
|
18214
|
+
file_type: args.file_type,
|
|
18215
|
+
name: args.name,
|
|
18216
|
+
...(args.url !== undefined && { url: args.url }),
|
|
18217
|
+
...(args.content !== undefined && { content: args.content }),
|
|
18218
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18219
|
+
},
|
|
18220
|
+
}),
|
|
18221
|
+
invalidatesTags: ['AgentSkillResources'],
|
|
18222
|
+
}),
|
|
18223
|
+
updateAgentSkillResource: builder.mutation({
|
|
18224
|
+
query: (args) => ({
|
|
18225
|
+
url: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL_RESOURCE.path(args.org, args.id),
|
|
18226
|
+
service: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL_RESOURCE.service,
|
|
18227
|
+
method: 'PATCH',
|
|
18228
|
+
body: {
|
|
18229
|
+
...(args.skill !== undefined && { skill: args.skill }),
|
|
18230
|
+
...(args.file_type !== undefined && { file_type: args.file_type }),
|
|
18231
|
+
...(args.name !== undefined && { name: args.name }),
|
|
18232
|
+
...(args.url !== undefined && { url: args.url }),
|
|
18233
|
+
...(args.content !== undefined && { content: args.content }),
|
|
18234
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18235
|
+
},
|
|
18236
|
+
}),
|
|
18237
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18238
|
+
{ type: 'AgentSkillResources', id: args.id },
|
|
18239
|
+
'AgentSkillResources',
|
|
18240
|
+
],
|
|
18241
|
+
}),
|
|
18242
|
+
deleteAgentSkillResource: builder.mutation({
|
|
18243
|
+
query: (args) => ({
|
|
18244
|
+
url: CLAW_ENDPOINTS.DELETE_AGENT_SKILL_RESOURCE.path(args.org, args.id),
|
|
18245
|
+
service: CLAW_ENDPOINTS.DELETE_AGENT_SKILL_RESOURCE.service,
|
|
18246
|
+
method: 'DELETE',
|
|
18247
|
+
}),
|
|
18248
|
+
invalidatesTags: ['AgentSkillResources'],
|
|
18249
|
+
}),
|
|
18250
|
+
// ── Mentor Skill Assignments (nested under mentor) ────────────────────
|
|
18251
|
+
getMentorSkillAssignments: builder.query({
|
|
18252
|
+
query: (args) => ({
|
|
18253
|
+
url: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENTS.path(args.org, args.mentorUniqueId),
|
|
18254
|
+
service: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENTS.service,
|
|
18255
|
+
}),
|
|
18256
|
+
transformResponse: (response) => normalizeList(response),
|
|
18257
|
+
providesTags: (_result, _error, args) => [
|
|
18258
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18259
|
+
],
|
|
18260
|
+
}),
|
|
18261
|
+
getMentorSkillAssignment: builder.query({
|
|
18262
|
+
query: (args) => ({
|
|
18263
|
+
url: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId, args.assignmentPk),
|
|
18264
|
+
service: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18265
|
+
}),
|
|
18266
|
+
providesTags: (_result, _error, args) => [
|
|
18267
|
+
{ type: 'MentorSkillAssignments', id: args.assignmentPk },
|
|
18268
|
+
],
|
|
18269
|
+
}),
|
|
18270
|
+
createMentorSkillAssignment: builder.mutation({
|
|
18271
|
+
query: (args) => ({
|
|
18272
|
+
url: CLAW_ENDPOINTS.CREATE_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId),
|
|
18273
|
+
service: CLAW_ENDPOINTS.CREATE_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18274
|
+
method: 'POST',
|
|
18275
|
+
body: {
|
|
18276
|
+
skill: args.skill,
|
|
18277
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18278
|
+
},
|
|
18279
|
+
}),
|
|
18280
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18281
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18282
|
+
],
|
|
18283
|
+
}),
|
|
18284
|
+
updateMentorSkillAssignment: builder.mutation({
|
|
18285
|
+
query: (args) => ({
|
|
18286
|
+
url: CLAW_ENDPOINTS.UPDATE_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId, args.assignmentPk),
|
|
18287
|
+
service: CLAW_ENDPOINTS.UPDATE_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18288
|
+
method: 'PATCH',
|
|
18289
|
+
body: {
|
|
18290
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18291
|
+
},
|
|
18292
|
+
}),
|
|
18293
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18294
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18295
|
+
],
|
|
18296
|
+
}),
|
|
18297
|
+
deleteMentorSkillAssignment: builder.mutation({
|
|
18298
|
+
query: (args) => ({
|
|
18299
|
+
url: CLAW_ENDPOINTS.DELETE_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId, args.assignmentPk),
|
|
18300
|
+
service: CLAW_ENDPOINTS.DELETE_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18301
|
+
method: 'DELETE',
|
|
18302
|
+
}),
|
|
18303
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18304
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18305
|
+
],
|
|
18306
|
+
}),
|
|
18307
|
+
}),
|
|
18308
|
+
});
|
|
18309
|
+
|
|
17638
18310
|
const CUSTOM_DOMAIN_REDUCER_PATH = 'customDomainApiSlice';
|
|
17639
18311
|
const CUSTOM_DOMAIN_ENDPOINTS = {
|
|
17640
18312
|
GET_CUSTOM_DOMAINS: {
|
|
@@ -23991,5 +24663,5 @@ const checkRbacPermission = (rbacPermissions, rbacResource, enableRBAC = true) =
|
|
|
23991
24663
|
return checkRbacPermissionInternal(rbacPermissions, rbacResource);
|
|
23992
24664
|
};
|
|
23993
24665
|
|
|
23994
|
-
export { ALPHANUMERIC_32_REGEX, ANONYMOUS_USERNAME, AuthContext, AuthContextProvider, AuthProvider, CHAT_AREA_SIZE, LOCAL_STORAGE_KEYS, MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS, MENTOR_CHAT_DOCUMENTS_EXTENSIONS, METADATAS, MentorProvider, REQUIRED_ACTIONS_FOR_GROUPS, STREAMING_CONTENT_BUFFER_THRESHOLD, STREAMING_CONTENT_FLUSH_INTERVAL, SUBSCRIPTION_MESSAGES, SUBSCRIPTION_PACKAGES, SUBSCRIPTION_PACKAGES_V2, SUBSCRIPTION_TRIGGERS, SUBSCRIPTION_V2_TRIGGERS, SubscriptionFlow, SubscriptionFlowV2, TOOLS, TenantContext, TenantContextProvider, TenantProvider, TimeTracker, WithFormPermissions, WithPermissions, addFiles, addProtocolToUrl, advancedTabs, advancedTabsProperties, chatActions, chatSliceReducerShared, checkModelAvailable, checkOllamaHealth, checkRbacPermission, clearAuthCookies, clearCookies, clearCurrentTenantCookie, clearFiles, combineCSVData, convertToOllamaMessages, createFileReference, createMultipleFileReferences, csvDataToText, defaultSessionIds, deleteCookie, deleteCookieOnAllDomains, filesReducer, filesSlice, formatRelativeTime, getAuthSpaJoinUrl, getDomainParts, getFileInfo, getInitials, getLocalLLMSystemPrompt, getNextNavigation, getParentDomain, getPlatform, getPlatformKey, getTimeAgo, getUserName, handleLogout, isAlphaNumeric32, isExpo, isInIframe, isJSON, isLoggedIn, isNode, isReactNative$1 as isReactNative, isTauri, isWeb$2 as isWeb, loadMetadataConfig, markdownToPlainText, monetizationSlice, parseCSV, redirectToAuthSpa, redirectToAuthSpaJoinTenant, removeFile, requestPresignedUrl, safeRequire, selectActiveChatMessages, selectActiveTab, selectArtifactsEnabled, selectChats, selectCurrentStreamingArtifact, selectCurrentStreamingMessage, selectDocumentFilter, selectIframeContext, selectIsError, selectIsPending, selectIsStopped, selectIsTyping, selectLastArtifactContentFlushTime, selectMetadata, selectNumberOfActiveChatMessages, selectSessionId, selectSessionIds, selectShouldStartNewChat, selectShowingSharedChat, selectStatus, selectStreaming, selectStreamingArtifactContentBuffer, selectStreamingArtifactFullContent, selectToken, selectTokenEnabled, selectTools, sendMessageToParentWebsite, setAccessCheckResponse, setAdvancedDisplayMonetizationCheckoutModal, setCookieForAuth, setDisplayMonetizationCheckoutModal, showMonetizationCheckoutModal, streamOllamaChat, syncAuthToCookies, tenantKeySchema, tenantSchema, translatePrompt, updateFileMetadata, updateFileProgress, updateFileRetryCount, updateFileStatus, updateFileUrl, updateFileUrlFromWebSocket, uploadToS3, useAdvancedChat, useAuthContext, useAuthProvider, useChat, useDayJs, useExternalPricingPlan, useMentorSettings, useMentorTools, useProfileImageUpload, useStripeUpgrade, useSubscriptionHandler, useSubscriptionHandlerV2, useTenantContext, useTenantMetadata, useTimeTracker, useTimeTrackerNative, useUserProfileUpdate, userDataSchema, validateFile };
|
|
24666
|
+
export { ALPHANUMERIC_32_REGEX, ANONYMOUS_USERNAME, AuthContext, AuthContextProvider, AuthProvider, CHAT_AREA_SIZE, LOCAL_STORAGE_KEYS, MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS, MENTOR_CHAT_DOCUMENTS_EXTENSIONS, METADATAS, MentorProvider, REQUIRED_ACTIONS_FOR_GROUPS, STREAMING_CONTENT_BUFFER_THRESHOLD, STREAMING_CONTENT_FLUSH_INTERVAL, SUBSCRIPTION_MESSAGES, SUBSCRIPTION_PACKAGES, SUBSCRIPTION_PACKAGES_V2, SUBSCRIPTION_TRIGGERS, SUBSCRIPTION_V2_TRIGGERS, SubscriptionFlow, SubscriptionFlowV2, TOOLS, TenantContext, TenantContextProvider, TenantProvider, TimeTracker, WithFormPermissions, WithPermissions, addFiles, addProtocolToUrl, advancedTabs, advancedTabsProperties, chatActions, chatSliceReducerShared, checkModelAvailable, checkOllamaHealth, checkRbacPermission, clearAuthCookies, clearCookies, clearCurrentTenantCookie, clearFiles, combineCSVData, convertToOllamaMessages, createFileReference, createMultipleFileReferences, csvDataToText, defaultSessionIds, deleteCookie, deleteCookieOnAllDomains, filesReducer, filesSlice, formatRelativeTime, getAuthSpaJoinUrl, getCookieValue, getDomainParts, getFileInfo, getInitials, getLocalLLMSystemPrompt, getNextNavigation, getParentDomain, getPlatform, getPlatformKey, getTimeAgo, getUserName, handleLogout, isAlphaNumeric32, isExpo, isInIframe, isJSON, isLoggedIn, isNode, isReactNative$1 as isReactNative, isTauri, isWeb$2 as isWeb, loadMetadataConfig, markdownToPlainText, monetizationSlice, parseCSV, redirectToAuthSpa, redirectToAuthSpaJoinTenant, removeFile, requestPresignedUrl, safeRequire, selectActiveChatMessages, selectActiveTab, selectArtifactsEnabled, selectChats, selectCurrentStreamingArtifact, selectCurrentStreamingMessage, selectDocumentFilter, selectIframeContext, selectIsError, selectIsPending, selectIsStopped, selectIsTyping, selectLastArtifactContentFlushTime, selectMetadata, selectNumberOfActiveChatMessages, selectSessionId, selectSessionIds, selectShouldStartNewChat, selectShowingSharedChat, selectStatus, selectStreaming, selectStreamingArtifactContentBuffer, selectStreamingArtifactFullContent, selectToken, selectTokenEnabled, selectTools, sendMessageToParentWebsite, setAccessCheckResponse, setAdvancedDisplayMonetizationCheckoutModal, setCookieForAuth, setDisplayMonetizationCheckoutModal, showMonetizationCheckoutModal, streamOllamaChat, syncAuthToCookies, tenantKeySchema, tenantSchema, translatePrompt, updateFileMetadata, updateFileProgress, updateFileRetryCount, updateFileStatus, updateFileUrl, updateFileUrlFromWebSocket, uploadToS3, useAdvancedChat, useAuthContext, useAuthProvider, useChat, useDayJs, useExternalPricingPlan, useMentorSettings, useMentorTools, useProfileImageUpload, useStripeUpgrade, useSubscriptionHandler, useSubscriptionHandlerV2, useTenantContext, useTenantMetadata, useTimeTracker, useTimeTrackerNative, useUserProfileUpdate, userDataSchema, validateFile };
|
|
23995
24667
|
//# sourceMappingURL=index.esm.js.map
|