@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.js
CHANGED
|
@@ -1016,6 +1016,15 @@ function clearCookies() {
|
|
|
1016
1016
|
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;Domain=${getParentDomain(window.location.hostname)}`;
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Get the value of a cookie by name
|
|
1021
|
+
* @param name - Cookie name
|
|
1022
|
+
* @returns The cookie value or null if not found
|
|
1023
|
+
*/
|
|
1024
|
+
function getCookieValue(name) {
|
|
1025
|
+
const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
|
|
1026
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
1027
|
+
}
|
|
1019
1028
|
/**
|
|
1020
1029
|
* Check if user is currently logged in
|
|
1021
1030
|
* @param tokenKey - The localStorage key for the auth token (default: 'axd_token')
|
|
@@ -1080,8 +1089,48 @@ async function redirectToAuthSpa(options) {
|
|
|
1080
1089
|
userData: "ibl_user_data",
|
|
1081
1090
|
tenant: "ibl_tenant",
|
|
1082
1091
|
logoutTimestamp: "ibl_logout_timestamp",
|
|
1083
|
-
|
|
1084
|
-
|
|
1092
|
+
loginTimestamp: "ibl_login_timestamp",
|
|
1093
|
+
tenantSwitching: "ibl_tenant_switching",
|
|
1094
|
+
}, hasNonExpiredAuthToken, isOffline, preserveTokenKey, authRedirectProxy, isNativeApp, } = options;
|
|
1095
|
+
console.log("[redirectToAuthSpa] starting redirect to auth spa", redirectTo, platformKey, logout, saveRedirect);
|
|
1096
|
+
// Skip if a tenant switch is already in progress
|
|
1097
|
+
if (cookieNames.tenantSwitching &&
|
|
1098
|
+
document.cookie.includes(cookieNames.tenantSwitching)) {
|
|
1099
|
+
console.log("[redirectToAuthSpa] Tenant switch in progress, skipping redirect");
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
// Skip if a login occurred after the last logout (login takes precedence)
|
|
1103
|
+
// but only if this app actually has a valid auth token
|
|
1104
|
+
if (hasNonExpiredAuthToken &&
|
|
1105
|
+
cookieNames.loginTimestamp &&
|
|
1106
|
+
cookieNames.logoutTimestamp) {
|
|
1107
|
+
const loginTs = getCookieValue(cookieNames.loginTimestamp);
|
|
1108
|
+
const logoutTs = getCookieValue(cookieNames.logoutTimestamp);
|
|
1109
|
+
const hasValidToken = hasNonExpiredAuthToken();
|
|
1110
|
+
console.log("[redirectToAuthSpa] Login/logout timestamp check", {
|
|
1111
|
+
loginTs,
|
|
1112
|
+
logoutTs,
|
|
1113
|
+
hasValidToken,
|
|
1114
|
+
loginAhead: loginTs && logoutTs ? Number(loginTs) > Number(logoutTs) : false,
|
|
1115
|
+
});
|
|
1116
|
+
if (hasValidToken &&
|
|
1117
|
+
loginTs &&
|
|
1118
|
+
logoutTs &&
|
|
1119
|
+
Number(loginTs) > Number(logoutTs)) {
|
|
1120
|
+
console.log("[redirectToAuthSpa] Login timestamp is ahead of logout timestamp, skipping redirect", { loginTs, logoutTs });
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
// Skip redirect in offline mode
|
|
1125
|
+
if (isOffline === null || isOffline === void 0 ? void 0 : isOffline()) {
|
|
1126
|
+
console.log("[redirectToAuthSpa] Skipping redirect - offline mode");
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
// Preserve a token before clearing localStorage if requested
|
|
1130
|
+
const preservedToken = preserveTokenKey
|
|
1131
|
+
? window.localStorage.getItem(preserveTokenKey)
|
|
1132
|
+
: null;
|
|
1133
|
+
console.log("[redirectToAuthSpa] clearing local storage");
|
|
1085
1134
|
localStorage.clear();
|
|
1086
1135
|
if (logout || isInIframe()) {
|
|
1087
1136
|
// Delete authentication cookies for cross-SPA synchronization
|
|
@@ -1096,7 +1145,7 @@ async function redirectToAuthSpa(options) {
|
|
|
1096
1145
|
deleteCookieOnAllDomains(cookieNames.tenant, currentDomain);
|
|
1097
1146
|
}
|
|
1098
1147
|
// Set logout timestamp cookie to trigger logout on other SPAs
|
|
1099
|
-
if (cookieNames.logoutTimestamp) {
|
|
1148
|
+
if (cookieNames.logoutTimestamp && !isInIframe()) {
|
|
1100
1149
|
setCookieForAuth(cookieNames.logoutTimestamp, Date.now().toString());
|
|
1101
1150
|
}
|
|
1102
1151
|
}
|
|
@@ -1125,8 +1174,22 @@ async function redirectToAuthSpa(options) {
|
|
|
1125
1174
|
}
|
|
1126
1175
|
// Small delay for any pending operations
|
|
1127
1176
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1128
|
-
|
|
1129
|
-
|
|
1177
|
+
if (isNativeApp === null || isNativeApp === void 0 ? void 0 : isNativeApp()) {
|
|
1178
|
+
// On native apps (e.g., Tauri), pass preserved token and navigate directly
|
|
1179
|
+
if (preservedToken && preserveTokenKey) {
|
|
1180
|
+
authRedirectUrl += `&token=${encodeURIComponent(preservedToken)}`;
|
|
1181
|
+
console.log("[redirectToAuthSpa] Added preserved token to auth URL");
|
|
1182
|
+
}
|
|
1183
|
+
console.log("[redirectToAuthSpa] Native app, navigating to auth URL:", authRedirectUrl);
|
|
1184
|
+
window.location.href = authRedirectUrl;
|
|
1185
|
+
}
|
|
1186
|
+
else if (authRedirectProxy) {
|
|
1187
|
+
// Use auth redirect proxy endpoint
|
|
1188
|
+
window.location.href = `${authRedirectProxy}?to=${encodeURIComponent(authRedirectUrl)}`;
|
|
1189
|
+
}
|
|
1190
|
+
else {
|
|
1191
|
+
window.location.href = authRedirectUrl;
|
|
1192
|
+
}
|
|
1130
1193
|
}
|
|
1131
1194
|
/**
|
|
1132
1195
|
* Get the URL for joining a tenant (sign up flow)
|
|
@@ -3030,6 +3093,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
3030
3093
|
if (isProtectedRoute && storageService) {
|
|
3031
3094
|
const dmTokenInLocalStorage = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_KEY);
|
|
3032
3095
|
console.log("[auth-redirect] local storage keys ", LOCAL_STORAGE_KEYS);
|
|
3096
|
+
console.log("[auth-redirect] local storage ", JSON.stringify(localStorage));
|
|
3033
3097
|
const dmTokenExpired = await isDmTokenExpired(storageService);
|
|
3034
3098
|
if (!dmTokenInLocalStorage || dmTokenExpired) {
|
|
3035
3099
|
if (!!dmTokenInLocalStorage) {
|
|
@@ -13681,44 +13745,71 @@ const getHeaders = async (service) => {
|
|
|
13681
13745
|
}
|
|
13682
13746
|
return token ? { Authorization: `${prefix} ${token}` } : undefined;
|
|
13683
13747
|
};
|
|
13748
|
+
/** Status codes that should not be retried for queryFn endpoints. */
|
|
13749
|
+
const QUERYFN_NON_RETRYABLE_STATUSES = [401, 403, 500];
|
|
13750
|
+
/** Default max retries for queryFn endpoints. */
|
|
13751
|
+
const QUERYFN_MAX_RETRIES = 5;
|
|
13752
|
+
/** Base delay in ms for exponential backoff. */
|
|
13753
|
+
const QUERYFN_BASE_DELAY_MS = 1000;
|
|
13684
13754
|
/**
|
|
13685
13755
|
* Build a generic RTK Query endpoint from a service function.
|
|
13756
|
+
* Includes built-in retry with exponential backoff (since RTK Query
|
|
13757
|
+
* skips baseQuery retry for queryFn endpoints).
|
|
13686
13758
|
*/
|
|
13687
|
-
const buildEndpointFromService = (service, serviceFn) => {
|
|
13759
|
+
const buildEndpointFromService = (service, serviceFn, options) => {
|
|
13760
|
+
var _a;
|
|
13761
|
+
const maxRetries = (_a = void 0 ) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
|
|
13688
13762
|
return {
|
|
13689
13763
|
async queryFn(args) {
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
}
|
|
13699
|
-
catch (err) {
|
|
13700
|
-
console.error('[data-layer] API error:', JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
13701
|
-
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13702
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({ ...((err === null || err === void 0 ? void 0 : err.data) || {}) });
|
|
13764
|
+
let lastError;
|
|
13765
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
13766
|
+
try {
|
|
13767
|
+
iblaiApi.OpenAPI.BASE = getServiceUrl(service);
|
|
13768
|
+
iblaiApi.OpenAPI.HEADERS = await getHeaders(service);
|
|
13769
|
+
iblaiApi.OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
|
|
13770
|
+
const data = await serviceFn(args);
|
|
13771
|
+
return { data };
|
|
13703
13772
|
}
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13773
|
+
catch (err) {
|
|
13774
|
+
lastError = err;
|
|
13775
|
+
const status = err === null || err === void 0 ? void 0 : err.status;
|
|
13776
|
+
// Don't retry auth errors
|
|
13777
|
+
if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status)) {
|
|
13778
|
+
break;
|
|
13779
|
+
}
|
|
13780
|
+
// If we have retries left, wait with exponential backoff
|
|
13781
|
+
if (attempt < maxRetries) {
|
|
13782
|
+
const delay = QUERYFN_BASE_DELAY_MS * Math.pow(2, attempt);
|
|
13783
|
+
console.warn(`[data-layer] Retry ${attempt + 1}/${maxRetries}:`, `service=${service}, fn=${serviceFn.name || 'anonymous'}`);
|
|
13784
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
13785
|
+
continue;
|
|
13786
|
+
}
|
|
13787
|
+
}
|
|
13788
|
+
}
|
|
13789
|
+
// All retries exhausted or non-retryable error
|
|
13790
|
+
console.error('[data-layer] API error:', `service=${service}, fn=${serviceFn.name || 'anonymous'}`, JSON.stringify(lastError, Object.getOwnPropertyNames(lastError)));
|
|
13791
|
+
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
|
|
13792
|
+
Config.httpErrorHandlers[lastError === null || lastError === void 0 ? void 0 : lastError.status]({
|
|
13793
|
+
...((lastError === null || lastError === void 0 ? void 0 : lastError.data) || {}),
|
|
13794
|
+
});
|
|
13710
13795
|
}
|
|
13796
|
+
return {
|
|
13797
|
+
error: {
|
|
13798
|
+
status: (lastError === null || lastError === void 0 ? void 0 : lastError.status) || 500,
|
|
13799
|
+
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',
|
|
13800
|
+
},
|
|
13801
|
+
};
|
|
13711
13802
|
},
|
|
13712
13803
|
};
|
|
13713
13804
|
};
|
|
13714
13805
|
/**
|
|
13715
13806
|
* Shortcut for building an endpoint using the DM service.
|
|
13716
13807
|
*/
|
|
13717
|
-
const buildEndpointFromDmService = (serviceFn) => buildEndpointFromService(SERVICES.DM, serviceFn);
|
|
13808
|
+
const buildEndpointFromDmService = (serviceFn, options) => buildEndpointFromService(SERVICES.DM, serviceFn);
|
|
13718
13809
|
/**
|
|
13719
13810
|
* Shortcut for building an endpoint using the AXD service.
|
|
13720
13811
|
*/
|
|
13721
|
-
const buildEndpointFromAxdService = (serviceFn) => buildEndpointFromService(SERVICES.AXD, serviceFn);
|
|
13812
|
+
const buildEndpointFromAxdService = (serviceFn, options) => buildEndpointFromService(SERVICES.AXD, serviceFn);
|
|
13722
13813
|
const isErrorObject = (data) => {
|
|
13723
13814
|
return (typeof data === 'object' &&
|
|
13724
13815
|
data !== null &&
|
|
@@ -13850,40 +13941,57 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
13850
13941
|
}
|
|
13851
13942
|
};
|
|
13852
13943
|
/**
|
|
13853
|
-
* Build a generic RTK Query endpoint from a service function.
|
|
13944
|
+
* Build a generic RTK Query endpoint from a service function (legacy variant).
|
|
13945
|
+
* Includes built-in retry with exponential backoff.
|
|
13854
13946
|
*/
|
|
13855
|
-
const buildEndpointFromServiceLegacy = (service, serviceFn) => {
|
|
13947
|
+
const buildEndpointFromServiceLegacy = (service, serviceFn, options) => {
|
|
13948
|
+
var _a;
|
|
13949
|
+
const maxRetries = (_a = void 0 ) !== null && _a !== void 0 ? _a : QUERYFN_MAX_RETRIES;
|
|
13856
13950
|
return {
|
|
13857
13951
|
async queryFn(args) {
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
|
|
13861
|
-
|
|
13862
|
-
|
|
13863
|
-
|
|
13864
|
-
|
|
13865
|
-
|
|
13866
|
-
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13867
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({
|
|
13868
|
-
status: err === null || err === void 0 ? void 0 : err.status,
|
|
13869
|
-
body: err === null || err === void 0 ? void 0 : err.body,
|
|
13870
|
-
message: err === null || err === void 0 ? void 0 : err.message,
|
|
13871
|
-
});
|
|
13952
|
+
let lastError;
|
|
13953
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
13954
|
+
try {
|
|
13955
|
+
iblaiApi.OpenAPI.BASE = getServiceUrl(service);
|
|
13956
|
+
iblaiApi.OpenAPI.HEADERS = await getHeaders(service);
|
|
13957
|
+
iblaiApi.OpenAPI.CREDENTIALS = service === SERVICES.LEGACY_LMS ? 'include' : 'omit';
|
|
13958
|
+
const data = await serviceFn(...args);
|
|
13959
|
+
return { data };
|
|
13872
13960
|
}
|
|
13873
|
-
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
|
|
13961
|
+
catch (err) {
|
|
13962
|
+
lastError = err;
|
|
13963
|
+
const status = err === null || err === void 0 ? void 0 : err.status;
|
|
13964
|
+
if (QUERYFN_NON_RETRYABLE_STATUSES.includes(status)) {
|
|
13965
|
+
break;
|
|
13966
|
+
}
|
|
13967
|
+
if (attempt < maxRetries) {
|
|
13968
|
+
const delay = QUERYFN_BASE_DELAY_MS * Math.pow(2, attempt);
|
|
13969
|
+
console.warn(`[data-layer] Retry ${attempt + 1}/${maxRetries}:`, `service=${service}, fn=${serviceFn.name || 'anonymous'}`);
|
|
13970
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
13971
|
+
continue;
|
|
13972
|
+
}
|
|
13973
|
+
}
|
|
13974
|
+
}
|
|
13975
|
+
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, lastError === null || lastError === void 0 ? void 0 : lastError.status)) {
|
|
13976
|
+
Config.httpErrorHandlers[lastError === null || lastError === void 0 ? void 0 : lastError.status]({
|
|
13977
|
+
status: lastError === null || lastError === void 0 ? void 0 : lastError.status,
|
|
13978
|
+
body: lastError === null || lastError === void 0 ? void 0 : lastError.body,
|
|
13979
|
+
message: lastError === null || lastError === void 0 ? void 0 : lastError.message,
|
|
13980
|
+
});
|
|
13879
13981
|
}
|
|
13982
|
+
return {
|
|
13983
|
+
error: {
|
|
13984
|
+
status: (lastError === null || lastError === void 0 ? void 0 : lastError.status) || 500,
|
|
13985
|
+
data: (lastError === null || lastError === void 0 ? void 0 : lastError.body) || (lastError === null || lastError === void 0 ? void 0 : lastError.message) || 'Unknown error',
|
|
13986
|
+
},
|
|
13987
|
+
};
|
|
13880
13988
|
},
|
|
13881
13989
|
};
|
|
13882
13990
|
};
|
|
13883
13991
|
/**
|
|
13884
13992
|
* Shortcut for building an endpoint using the DM service.
|
|
13885
13993
|
*/
|
|
13886
|
-
const buildEndpointFromDmServiceLegacy = (serviceFn) => buildEndpointFromServiceLegacy(SERVICES.DM, serviceFn);
|
|
13994
|
+
const buildEndpointFromDmServiceLegacy = (serviceFn, options) => buildEndpointFromServiceLegacy(SERVICES.DM, serviceFn);
|
|
13887
13995
|
|
|
13888
13996
|
createApi({
|
|
13889
13997
|
reducerPath: 'apiKeysApiSlice',
|
|
@@ -17655,6 +17763,570 @@ createApi({
|
|
|
17655
17763
|
}),
|
|
17656
17764
|
});
|
|
17657
17765
|
|
|
17766
|
+
const CLAW_REDUCER_PATH = 'clawApiSlice';
|
|
17767
|
+
const CLAW_TAG_TYPES = [
|
|
17768
|
+
'ClawMentorConfig',
|
|
17769
|
+
'ClawInstances',
|
|
17770
|
+
'AgentConfig',
|
|
17771
|
+
'AgentSkills',
|
|
17772
|
+
'AgentSkillResources',
|
|
17773
|
+
'MentorSkillAssignments',
|
|
17774
|
+
];
|
|
17775
|
+
const CLAW_ENDPOINTS = {
|
|
17776
|
+
// ── Claw Mentor Config (singular, nested under mentor) ─────────────────────
|
|
17777
|
+
GET_MENTOR_CONFIG: {
|
|
17778
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17779
|
+
service: SERVICES.DM,
|
|
17780
|
+
},
|
|
17781
|
+
CREATE_MENTOR_CONFIG: {
|
|
17782
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17783
|
+
service: SERVICES.DM,
|
|
17784
|
+
},
|
|
17785
|
+
UPDATE_MENTOR_CONFIG: {
|
|
17786
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17787
|
+
service: SERVICES.DM,
|
|
17788
|
+
},
|
|
17789
|
+
DELETE_MENTOR_CONFIG: {
|
|
17790
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/`,
|
|
17791
|
+
service: SERVICES.DM,
|
|
17792
|
+
},
|
|
17793
|
+
PUSH_CONFIG: {
|
|
17794
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/claw-config/push-config/`,
|
|
17795
|
+
service: SERVICES.DM,
|
|
17796
|
+
},
|
|
17797
|
+
// ── Claw Instances (unchanged) ─────────────────────────────────────────────
|
|
17798
|
+
GET_INSTANCES: {
|
|
17799
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/claw/instances/`,
|
|
17800
|
+
service: SERVICES.DM,
|
|
17801
|
+
},
|
|
17802
|
+
GET_INSTANCE: {
|
|
17803
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/`,
|
|
17804
|
+
service: SERVICES.DM,
|
|
17805
|
+
},
|
|
17806
|
+
CREATE_INSTANCE: {
|
|
17807
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/claw/instances/`,
|
|
17808
|
+
service: SERVICES.DM,
|
|
17809
|
+
},
|
|
17810
|
+
UPDATE_INSTANCE: {
|
|
17811
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/`,
|
|
17812
|
+
service: SERVICES.DM,
|
|
17813
|
+
},
|
|
17814
|
+
DELETE_INSTANCE: {
|
|
17815
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/`,
|
|
17816
|
+
service: SERVICES.DM,
|
|
17817
|
+
},
|
|
17818
|
+
HEALTH_CHECK_INSTANCE: {
|
|
17819
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/health-check/`,
|
|
17820
|
+
service: SERVICES.DM,
|
|
17821
|
+
},
|
|
17822
|
+
TEST_CONNECTIVITY_INSTANCE: {
|
|
17823
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/test-connectivity/`,
|
|
17824
|
+
service: SERVICES.DM,
|
|
17825
|
+
},
|
|
17826
|
+
REFRESH_VERSION_INSTANCE: {
|
|
17827
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/claw/instances/${id}/refresh-version/`,
|
|
17828
|
+
service: SERVICES.DM,
|
|
17829
|
+
},
|
|
17830
|
+
// ── Agent Config (singular, nested under mentor) ───────────────────────────
|
|
17831
|
+
GET_AGENT_CONFIG: {
|
|
17832
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/agent-config/`,
|
|
17833
|
+
service: SERVICES.DM,
|
|
17834
|
+
},
|
|
17835
|
+
/** PATCH is upsert — first write bootstraps the row, no separate POST. */
|
|
17836
|
+
UPDATE_AGENT_CONFIG: {
|
|
17837
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/agent-config/`,
|
|
17838
|
+
service: SERVICES.DM,
|
|
17839
|
+
},
|
|
17840
|
+
// ── Agent Skills (platform-level, unchanged) ───────────────────────────────
|
|
17841
|
+
GET_AGENT_SKILLS: {
|
|
17842
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skills/`,
|
|
17843
|
+
service: SERVICES.DM,
|
|
17844
|
+
},
|
|
17845
|
+
GET_AGENT_SKILL: {
|
|
17846
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skills/${id}/`,
|
|
17847
|
+
service: SERVICES.DM,
|
|
17848
|
+
},
|
|
17849
|
+
CREATE_AGENT_SKILL: {
|
|
17850
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skills/`,
|
|
17851
|
+
service: SERVICES.DM,
|
|
17852
|
+
},
|
|
17853
|
+
UPDATE_AGENT_SKILL: {
|
|
17854
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skills/${id}/`,
|
|
17855
|
+
service: SERVICES.DM,
|
|
17856
|
+
},
|
|
17857
|
+
DELETE_AGENT_SKILL: {
|
|
17858
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skills/${id}/`,
|
|
17859
|
+
service: SERVICES.DM,
|
|
17860
|
+
},
|
|
17861
|
+
// ── Agent Skill Resources (file resources attached to skills) ──────────────
|
|
17862
|
+
GET_AGENT_SKILL_RESOURCES: {
|
|
17863
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/`,
|
|
17864
|
+
service: SERVICES.DM,
|
|
17865
|
+
},
|
|
17866
|
+
GET_AGENT_SKILL_RESOURCE: {
|
|
17867
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/${id}/`,
|
|
17868
|
+
service: SERVICES.DM,
|
|
17869
|
+
},
|
|
17870
|
+
CREATE_AGENT_SKILL_RESOURCE: {
|
|
17871
|
+
path: (org) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/`,
|
|
17872
|
+
service: SERVICES.DM,
|
|
17873
|
+
},
|
|
17874
|
+
UPDATE_AGENT_SKILL_RESOURCE: {
|
|
17875
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/${id}/`,
|
|
17876
|
+
service: SERVICES.DM,
|
|
17877
|
+
},
|
|
17878
|
+
DELETE_AGENT_SKILL_RESOURCE: {
|
|
17879
|
+
path: (org, id) => `/api/ai-mentor/orgs/${org}/agent-skill-resources/${id}/`,
|
|
17880
|
+
service: SERVICES.DM,
|
|
17881
|
+
},
|
|
17882
|
+
// ── Mentor Skill Assignments (nested under mentor) ─────────────────────────
|
|
17883
|
+
GET_MENTOR_SKILL_ASSIGNMENTS: {
|
|
17884
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/`,
|
|
17885
|
+
service: SERVICES.DM,
|
|
17886
|
+
},
|
|
17887
|
+
CREATE_MENTOR_SKILL_ASSIGNMENT: {
|
|
17888
|
+
path: (org, mentorUniqueId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/`,
|
|
17889
|
+
service: SERVICES.DM,
|
|
17890
|
+
},
|
|
17891
|
+
GET_MENTOR_SKILL_ASSIGNMENT: {
|
|
17892
|
+
path: (org, mentorUniqueId, assignmentPk) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/${assignmentPk}/`,
|
|
17893
|
+
service: SERVICES.DM,
|
|
17894
|
+
},
|
|
17895
|
+
UPDATE_MENTOR_SKILL_ASSIGNMENT: {
|
|
17896
|
+
path: (org, mentorUniqueId, assignmentPk) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/${assignmentPk}/`,
|
|
17897
|
+
service: SERVICES.DM,
|
|
17898
|
+
},
|
|
17899
|
+
DELETE_MENTOR_SKILL_ASSIGNMENT: {
|
|
17900
|
+
path: (org, mentorUniqueId, assignmentPk) => `/api/ai-mentor/orgs/${org}/mentors/${mentorUniqueId}/skills/${assignmentPk}/`,
|
|
17901
|
+
service: SERVICES.DM,
|
|
17902
|
+
},
|
|
17903
|
+
};
|
|
17904
|
+
|
|
17905
|
+
/**
|
|
17906
|
+
* Normalize API responses that may return either a plain array or a
|
|
17907
|
+
* paginated envelope `{ results: T[] }`.
|
|
17908
|
+
*/
|
|
17909
|
+
function normalizeList(response) {
|
|
17910
|
+
return Array.isArray(response) ? response : response.results;
|
|
17911
|
+
}
|
|
17912
|
+
const clawApiSlice = createApi({
|
|
17913
|
+
reducerPath: CLAW_REDUCER_PATH,
|
|
17914
|
+
baseQuery: iblFetchBaseQuery,
|
|
17915
|
+
tagTypes: [...CLAW_TAG_TYPES],
|
|
17916
|
+
endpoints: (builder) => ({
|
|
17917
|
+
// ── Claw Mentor Config (singular) ─────────────────────────────────────
|
|
17918
|
+
getClawMentorConfig: builder.query({
|
|
17919
|
+
query: (args) => ({
|
|
17920
|
+
url: CLAW_ENDPOINTS.GET_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17921
|
+
service: CLAW_ENDPOINTS.GET_MENTOR_CONFIG.service,
|
|
17922
|
+
}),
|
|
17923
|
+
providesTags: (_result, _error, args) => [
|
|
17924
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17925
|
+
],
|
|
17926
|
+
}),
|
|
17927
|
+
createClawMentorConfig: builder.mutation({
|
|
17928
|
+
query: (args) => ({
|
|
17929
|
+
url: CLAW_ENDPOINTS.CREATE_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17930
|
+
service: CLAW_ENDPOINTS.CREATE_MENTOR_CONFIG.service,
|
|
17931
|
+
method: 'POST',
|
|
17932
|
+
body: {
|
|
17933
|
+
server: args.server,
|
|
17934
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
17935
|
+
...(args.agent_id !== undefined && { agent_id: args.agent_id }),
|
|
17936
|
+
},
|
|
17937
|
+
}),
|
|
17938
|
+
// Seed the GET cache with the create response and then invalidate so the
|
|
17939
|
+
// subscribed query refetches the joined fields (server_name, status, etc.)
|
|
17940
|
+
// that the POST body doesn't include. The refetch is a 200 — no retry storm.
|
|
17941
|
+
async onQueryStarted({ org, mentorUniqueId }, { dispatch, queryFulfilled }) {
|
|
17942
|
+
try {
|
|
17943
|
+
const { data } = await queryFulfilled;
|
|
17944
|
+
dispatch(clawApiSlice.util.upsertQueryData('getClawMentorConfig', { org, mentorUniqueId }, data));
|
|
17945
|
+
}
|
|
17946
|
+
catch (_a) {
|
|
17947
|
+
// Surface error via the mutation's own error state.
|
|
17948
|
+
}
|
|
17949
|
+
},
|
|
17950
|
+
invalidatesTags: (_result, _error, args) => [
|
|
17951
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17952
|
+
],
|
|
17953
|
+
}),
|
|
17954
|
+
updateClawMentorConfig: builder.mutation({
|
|
17955
|
+
query: (args) => ({
|
|
17956
|
+
url: CLAW_ENDPOINTS.UPDATE_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17957
|
+
service: CLAW_ENDPOINTS.UPDATE_MENTOR_CONFIG.service,
|
|
17958
|
+
method: 'PATCH',
|
|
17959
|
+
body: {
|
|
17960
|
+
...(args.server !== undefined && { server: args.server }),
|
|
17961
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
17962
|
+
...(args.auto_push !== undefined && { auto_push: args.auto_push }),
|
|
17963
|
+
...(args.agent_config !== undefined && { agent_config: args.agent_config }),
|
|
17964
|
+
...(args.agent_id !== undefined && { agent_id: args.agent_id }),
|
|
17965
|
+
},
|
|
17966
|
+
}),
|
|
17967
|
+
invalidatesTags: (_result, _error, args) => [
|
|
17968
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17969
|
+
],
|
|
17970
|
+
}),
|
|
17971
|
+
deleteClawMentorConfig: builder.mutation({
|
|
17972
|
+
query: (args) => ({
|
|
17973
|
+
url: CLAW_ENDPOINTS.DELETE_MENTOR_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17974
|
+
service: CLAW_ENDPOINTS.DELETE_MENTOR_CONFIG.service,
|
|
17975
|
+
method: 'DELETE',
|
|
17976
|
+
}),
|
|
17977
|
+
// Optimistically clear the GET cache before the request resolves so the
|
|
17978
|
+
// UI flips to "not connected" instantly. On failure, invalidate to refetch
|
|
17979
|
+
// the real state. We don't invalidate on success — the GET would 404 and
|
|
17980
|
+
// the base query retries 3× on error, which is the lag the user sees.
|
|
17981
|
+
async onQueryStarted({ org, mentorUniqueId }, { dispatch, queryFulfilled }) {
|
|
17982
|
+
dispatch(clawApiSlice.util.upsertQueryData('getClawMentorConfig', { org, mentorUniqueId }, null));
|
|
17983
|
+
try {
|
|
17984
|
+
await queryFulfilled;
|
|
17985
|
+
}
|
|
17986
|
+
catch (_a) {
|
|
17987
|
+
dispatch(clawApiSlice.util.invalidateTags([{ type: 'ClawMentorConfig', id: mentorUniqueId }]));
|
|
17988
|
+
}
|
|
17989
|
+
},
|
|
17990
|
+
}),
|
|
17991
|
+
pushClawConfig: builder.mutation({
|
|
17992
|
+
query: (args) => ({
|
|
17993
|
+
url: CLAW_ENDPOINTS.PUSH_CONFIG.path(args.org, args.mentorUniqueId),
|
|
17994
|
+
service: CLAW_ENDPOINTS.PUSH_CONFIG.service,
|
|
17995
|
+
method: 'POST',
|
|
17996
|
+
}),
|
|
17997
|
+
invalidatesTags: (_result, _error, args) => [
|
|
17998
|
+
{ type: 'ClawMentorConfig', id: args.mentorUniqueId },
|
|
17999
|
+
],
|
|
18000
|
+
}),
|
|
18001
|
+
// ── Claw Instances ────────────────────────────────────────────────────
|
|
18002
|
+
getClawInstances: builder.query({
|
|
18003
|
+
query: (args) => ({
|
|
18004
|
+
url: CLAW_ENDPOINTS.GET_INSTANCES.path(args.org),
|
|
18005
|
+
service: CLAW_ENDPOINTS.GET_INSTANCES.service,
|
|
18006
|
+
}),
|
|
18007
|
+
transformResponse: (response) => normalizeList(response),
|
|
18008
|
+
providesTags: ['ClawInstances'],
|
|
18009
|
+
}),
|
|
18010
|
+
getClawInstance: builder.query({
|
|
18011
|
+
query: (args) => ({
|
|
18012
|
+
url: CLAW_ENDPOINTS.GET_INSTANCE.path(args.org, args.id),
|
|
18013
|
+
service: CLAW_ENDPOINTS.GET_INSTANCE.service,
|
|
18014
|
+
}),
|
|
18015
|
+
providesTags: (_result, _error, args) => [{ type: 'ClawInstances', id: args.id }],
|
|
18016
|
+
}),
|
|
18017
|
+
createClawInstance: builder.mutation({
|
|
18018
|
+
query: (args) => ({
|
|
18019
|
+
url: CLAW_ENDPOINTS.CREATE_INSTANCE.path(args.org),
|
|
18020
|
+
service: CLAW_ENDPOINTS.CREATE_INSTANCE.service,
|
|
18021
|
+
method: 'POST',
|
|
18022
|
+
body: {
|
|
18023
|
+
name: args.name,
|
|
18024
|
+
claw_type: args.claw_type,
|
|
18025
|
+
server_url: args.server_url,
|
|
18026
|
+
...(args.gateway_token && { gateway_token: args.gateway_token }),
|
|
18027
|
+
...(args.auth_headers && { auth_headers: args.auth_headers }),
|
|
18028
|
+
...(args.connection_params && { connection_params: args.connection_params }),
|
|
18029
|
+
...(args.deployment_backend !== undefined && {
|
|
18030
|
+
deployment_backend: args.deployment_backend,
|
|
18031
|
+
}),
|
|
18032
|
+
},
|
|
18033
|
+
}),
|
|
18034
|
+
invalidatesTags: ['ClawInstances'],
|
|
18035
|
+
}),
|
|
18036
|
+
updateClawInstance: builder.mutation({
|
|
18037
|
+
query: (args) => ({
|
|
18038
|
+
url: CLAW_ENDPOINTS.UPDATE_INSTANCE.path(args.org, args.id),
|
|
18039
|
+
service: CLAW_ENDPOINTS.UPDATE_INSTANCE.service,
|
|
18040
|
+
method: 'PATCH',
|
|
18041
|
+
body: {
|
|
18042
|
+
...(args.name !== undefined && { name: args.name }),
|
|
18043
|
+
...(args.claw_type !== undefined && { claw_type: args.claw_type }),
|
|
18044
|
+
...(args.server_url !== undefined && { server_url: args.server_url }),
|
|
18045
|
+
...(args.gateway_token && { gateway_token: args.gateway_token }),
|
|
18046
|
+
...(args.auth_headers && { auth_headers: args.auth_headers }),
|
|
18047
|
+
...(args.connection_params && { connection_params: args.connection_params }),
|
|
18048
|
+
...(args.deployment_backend !== undefined && {
|
|
18049
|
+
deployment_backend: args.deployment_backend,
|
|
18050
|
+
}),
|
|
18051
|
+
},
|
|
18052
|
+
}),
|
|
18053
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18054
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18055
|
+
'ClawInstances',
|
|
18056
|
+
],
|
|
18057
|
+
}),
|
|
18058
|
+
deleteClawInstance: builder.mutation({
|
|
18059
|
+
query: (args) => ({
|
|
18060
|
+
url: CLAW_ENDPOINTS.DELETE_INSTANCE.path(args.org, args.id),
|
|
18061
|
+
service: CLAW_ENDPOINTS.DELETE_INSTANCE.service,
|
|
18062
|
+
method: 'DELETE',
|
|
18063
|
+
}),
|
|
18064
|
+
invalidatesTags: ['ClawInstances'],
|
|
18065
|
+
}),
|
|
18066
|
+
healthCheckClawInstance: builder.mutation({
|
|
18067
|
+
query: (args) => ({
|
|
18068
|
+
url: CLAW_ENDPOINTS.HEALTH_CHECK_INSTANCE.path(args.org, args.id),
|
|
18069
|
+
service: CLAW_ENDPOINTS.HEALTH_CHECK_INSTANCE.service,
|
|
18070
|
+
method: 'POST',
|
|
18071
|
+
}),
|
|
18072
|
+
// Health check updates last_health_check / last_health_status / claw_version
|
|
18073
|
+
// on the instance — invalidate so the list refetches with fresh values.
|
|
18074
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18075
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18076
|
+
'ClawInstances',
|
|
18077
|
+
],
|
|
18078
|
+
}),
|
|
18079
|
+
testConnectivityClawInstance: builder.mutation({
|
|
18080
|
+
query: (args) => ({
|
|
18081
|
+
url: CLAW_ENDPOINTS.TEST_CONNECTIVITY_INSTANCE.path(args.org, args.id),
|
|
18082
|
+
service: CLAW_ENDPOINTS.TEST_CONNECTIVITY_INSTANCE.service,
|
|
18083
|
+
method: 'POST',
|
|
18084
|
+
}),
|
|
18085
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18086
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18087
|
+
'ClawInstances',
|
|
18088
|
+
],
|
|
18089
|
+
}),
|
|
18090
|
+
refreshVersionClawInstance: builder.mutation({
|
|
18091
|
+
query: (args) => ({
|
|
18092
|
+
url: CLAW_ENDPOINTS.REFRESH_VERSION_INSTANCE.path(args.org, args.id),
|
|
18093
|
+
service: CLAW_ENDPOINTS.REFRESH_VERSION_INSTANCE.service,
|
|
18094
|
+
method: 'POST',
|
|
18095
|
+
}),
|
|
18096
|
+
// Refresh-version updates the instance's `claw_version` (and may touch
|
|
18097
|
+
// health fields too) — invalidate so the table picks up the new value.
|
|
18098
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18099
|
+
{ type: 'ClawInstances', id: args.id },
|
|
18100
|
+
'ClawInstances',
|
|
18101
|
+
],
|
|
18102
|
+
}),
|
|
18103
|
+
// ── Agent Config (singular, PATCH is upsert) ──────────────────────────
|
|
18104
|
+
getAgentConfig: builder.query({
|
|
18105
|
+
query: (args) => ({
|
|
18106
|
+
url: CLAW_ENDPOINTS.GET_AGENT_CONFIG.path(args.org, args.mentorUniqueId),
|
|
18107
|
+
service: CLAW_ENDPOINTS.GET_AGENT_CONFIG.service,
|
|
18108
|
+
}),
|
|
18109
|
+
providesTags: (_result, _error, args) => [{ type: 'AgentConfig', id: args.mentorUniqueId }],
|
|
18110
|
+
}),
|
|
18111
|
+
updateAgentConfig: builder.mutation({
|
|
18112
|
+
query: (args) => ({
|
|
18113
|
+
url: CLAW_ENDPOINTS.UPDATE_AGENT_CONFIG.path(args.org, args.mentorUniqueId),
|
|
18114
|
+
service: CLAW_ENDPOINTS.UPDATE_AGENT_CONFIG.service,
|
|
18115
|
+
method: 'PATCH',
|
|
18116
|
+
body: {
|
|
18117
|
+
...(args.identity !== undefined && { identity: args.identity }),
|
|
18118
|
+
...(args.soul !== undefined && { soul: args.soul }),
|
|
18119
|
+
...(args.user_context !== undefined && { user_context: args.user_context }),
|
|
18120
|
+
...(args.tools !== undefined && { tools: args.tools }),
|
|
18121
|
+
...(args.agents !== undefined && { agents: args.agents }),
|
|
18122
|
+
...(args.bootstrap !== undefined && { bootstrap: args.bootstrap }),
|
|
18123
|
+
...(args.heartbeat !== undefined && { heartbeat: args.heartbeat }),
|
|
18124
|
+
...(args.memory !== undefined && { memory: args.memory }),
|
|
18125
|
+
...(args.model !== undefined && { model: args.model }),
|
|
18126
|
+
...(args.config !== undefined && { config: args.config }),
|
|
18127
|
+
},
|
|
18128
|
+
}),
|
|
18129
|
+
// PATCH is upsert and returns the full AgentConfig. Write it straight into
|
|
18130
|
+
// the GET cache so UI subscribers see the new value immediately — relying
|
|
18131
|
+
// on tag invalidation alone leaves a stale window when the prior GET was a
|
|
18132
|
+
// 404 (the entry sits in error state until the refetch completes).
|
|
18133
|
+
async onQueryStarted({ org, mentorUniqueId }, { dispatch, queryFulfilled }) {
|
|
18134
|
+
try {
|
|
18135
|
+
const { data } = await queryFulfilled;
|
|
18136
|
+
dispatch(clawApiSlice.util.upsertQueryData('getAgentConfig', { org, mentorUniqueId }, data));
|
|
18137
|
+
}
|
|
18138
|
+
catch (_a) {
|
|
18139
|
+
// Mutation error surfaces via the hook's own state.
|
|
18140
|
+
}
|
|
18141
|
+
},
|
|
18142
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18143
|
+
{ type: 'AgentConfig', id: args.mentorUniqueId },
|
|
18144
|
+
],
|
|
18145
|
+
}),
|
|
18146
|
+
// ── Agent Skills (platform-level) ─────────────────────────────────────
|
|
18147
|
+
getAgentSkills: builder.query({
|
|
18148
|
+
query: (args) => ({
|
|
18149
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILLS.path(args.org),
|
|
18150
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILLS.service,
|
|
18151
|
+
}),
|
|
18152
|
+
transformResponse: (response) => normalizeList(response),
|
|
18153
|
+
providesTags: ['AgentSkills'],
|
|
18154
|
+
}),
|
|
18155
|
+
getAgentSkill: builder.query({
|
|
18156
|
+
query: (args) => ({
|
|
18157
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILL.path(args.org, args.id),
|
|
18158
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILL.service,
|
|
18159
|
+
}),
|
|
18160
|
+
providesTags: (_result, _error, args) => [{ type: 'AgentSkills', id: args.id }],
|
|
18161
|
+
}),
|
|
18162
|
+
createAgentSkill: builder.mutation({
|
|
18163
|
+
query: (args) => ({
|
|
18164
|
+
url: CLAW_ENDPOINTS.CREATE_AGENT_SKILL.path(args.org),
|
|
18165
|
+
service: CLAW_ENDPOINTS.CREATE_AGENT_SKILL.service,
|
|
18166
|
+
method: 'POST',
|
|
18167
|
+
body: {
|
|
18168
|
+
name: args.name,
|
|
18169
|
+
slug: args.slug,
|
|
18170
|
+
...(args.description !== undefined && { description: args.description }),
|
|
18171
|
+
...(args.version !== undefined && { version: args.version }),
|
|
18172
|
+
...(args.instruction !== undefined && { instruction: args.instruction }),
|
|
18173
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18174
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18175
|
+
},
|
|
18176
|
+
}),
|
|
18177
|
+
invalidatesTags: ['AgentSkills'],
|
|
18178
|
+
}),
|
|
18179
|
+
updateAgentSkill: builder.mutation({
|
|
18180
|
+
query: (args) => ({
|
|
18181
|
+
url: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL.path(args.org, args.id),
|
|
18182
|
+
service: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL.service,
|
|
18183
|
+
method: 'PATCH',
|
|
18184
|
+
body: {
|
|
18185
|
+
...(args.name !== undefined && { name: args.name }),
|
|
18186
|
+
...(args.slug !== undefined && { slug: args.slug }),
|
|
18187
|
+
...(args.description !== undefined && { description: args.description }),
|
|
18188
|
+
...(args.version !== undefined && { version: args.version }),
|
|
18189
|
+
...(args.instruction !== undefined && { instruction: args.instruction }),
|
|
18190
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18191
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18192
|
+
},
|
|
18193
|
+
}),
|
|
18194
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18195
|
+
{ type: 'AgentSkills', id: args.id },
|
|
18196
|
+
'AgentSkills',
|
|
18197
|
+
],
|
|
18198
|
+
}),
|
|
18199
|
+
deleteAgentSkill: builder.mutation({
|
|
18200
|
+
query: (args) => ({
|
|
18201
|
+
url: CLAW_ENDPOINTS.DELETE_AGENT_SKILL.path(args.org, args.id),
|
|
18202
|
+
service: CLAW_ENDPOINTS.DELETE_AGENT_SKILL.service,
|
|
18203
|
+
method: 'DELETE',
|
|
18204
|
+
}),
|
|
18205
|
+
invalidatesTags: ['AgentSkills'],
|
|
18206
|
+
}),
|
|
18207
|
+
// ── Agent Skill Resources ─────────────────────────────────────────────
|
|
18208
|
+
getAgentSkillResources: builder.query({
|
|
18209
|
+
query: (args) => ({
|
|
18210
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCES.path(args.org),
|
|
18211
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCES.service,
|
|
18212
|
+
params: {
|
|
18213
|
+
...(args.skill !== undefined && { skill: args.skill }),
|
|
18214
|
+
...(args.file_type !== undefined && { file_type: args.file_type }),
|
|
18215
|
+
},
|
|
18216
|
+
}),
|
|
18217
|
+
transformResponse: (response) => normalizeList(response),
|
|
18218
|
+
providesTags: ['AgentSkillResources'],
|
|
18219
|
+
}),
|
|
18220
|
+
getAgentSkillResource: builder.query({
|
|
18221
|
+
query: (args) => ({
|
|
18222
|
+
url: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCE.path(args.org, args.id),
|
|
18223
|
+
service: CLAW_ENDPOINTS.GET_AGENT_SKILL_RESOURCE.service,
|
|
18224
|
+
}),
|
|
18225
|
+
providesTags: (_result, _error, args) => [{ type: 'AgentSkillResources', id: args.id }],
|
|
18226
|
+
}),
|
|
18227
|
+
createAgentSkillResource: builder.mutation({
|
|
18228
|
+
query: (args) => ({
|
|
18229
|
+
url: CLAW_ENDPOINTS.CREATE_AGENT_SKILL_RESOURCE.path(args.org),
|
|
18230
|
+
service: CLAW_ENDPOINTS.CREATE_AGENT_SKILL_RESOURCE.service,
|
|
18231
|
+
method: 'POST',
|
|
18232
|
+
body: {
|
|
18233
|
+
skill: args.skill,
|
|
18234
|
+
file_type: args.file_type,
|
|
18235
|
+
name: args.name,
|
|
18236
|
+
...(args.url !== undefined && { url: args.url }),
|
|
18237
|
+
...(args.content !== undefined && { content: args.content }),
|
|
18238
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18239
|
+
},
|
|
18240
|
+
}),
|
|
18241
|
+
invalidatesTags: ['AgentSkillResources'],
|
|
18242
|
+
}),
|
|
18243
|
+
updateAgentSkillResource: builder.mutation({
|
|
18244
|
+
query: (args) => ({
|
|
18245
|
+
url: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL_RESOURCE.path(args.org, args.id),
|
|
18246
|
+
service: CLAW_ENDPOINTS.UPDATE_AGENT_SKILL_RESOURCE.service,
|
|
18247
|
+
method: 'PATCH',
|
|
18248
|
+
body: {
|
|
18249
|
+
...(args.skill !== undefined && { skill: args.skill }),
|
|
18250
|
+
...(args.file_type !== undefined && { file_type: args.file_type }),
|
|
18251
|
+
...(args.name !== undefined && { name: args.name }),
|
|
18252
|
+
...(args.url !== undefined && { url: args.url }),
|
|
18253
|
+
...(args.content !== undefined && { content: args.content }),
|
|
18254
|
+
...(args.metadata !== undefined && { metadata: args.metadata }),
|
|
18255
|
+
},
|
|
18256
|
+
}),
|
|
18257
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18258
|
+
{ type: 'AgentSkillResources', id: args.id },
|
|
18259
|
+
'AgentSkillResources',
|
|
18260
|
+
],
|
|
18261
|
+
}),
|
|
18262
|
+
deleteAgentSkillResource: builder.mutation({
|
|
18263
|
+
query: (args) => ({
|
|
18264
|
+
url: CLAW_ENDPOINTS.DELETE_AGENT_SKILL_RESOURCE.path(args.org, args.id),
|
|
18265
|
+
service: CLAW_ENDPOINTS.DELETE_AGENT_SKILL_RESOURCE.service,
|
|
18266
|
+
method: 'DELETE',
|
|
18267
|
+
}),
|
|
18268
|
+
invalidatesTags: ['AgentSkillResources'],
|
|
18269
|
+
}),
|
|
18270
|
+
// ── Mentor Skill Assignments (nested under mentor) ────────────────────
|
|
18271
|
+
getMentorSkillAssignments: builder.query({
|
|
18272
|
+
query: (args) => ({
|
|
18273
|
+
url: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENTS.path(args.org, args.mentorUniqueId),
|
|
18274
|
+
service: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENTS.service,
|
|
18275
|
+
}),
|
|
18276
|
+
transformResponse: (response) => normalizeList(response),
|
|
18277
|
+
providesTags: (_result, _error, args) => [
|
|
18278
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18279
|
+
],
|
|
18280
|
+
}),
|
|
18281
|
+
getMentorSkillAssignment: builder.query({
|
|
18282
|
+
query: (args) => ({
|
|
18283
|
+
url: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId, args.assignmentPk),
|
|
18284
|
+
service: CLAW_ENDPOINTS.GET_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18285
|
+
}),
|
|
18286
|
+
providesTags: (_result, _error, args) => [
|
|
18287
|
+
{ type: 'MentorSkillAssignments', id: args.assignmentPk },
|
|
18288
|
+
],
|
|
18289
|
+
}),
|
|
18290
|
+
createMentorSkillAssignment: builder.mutation({
|
|
18291
|
+
query: (args) => ({
|
|
18292
|
+
url: CLAW_ENDPOINTS.CREATE_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId),
|
|
18293
|
+
service: CLAW_ENDPOINTS.CREATE_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18294
|
+
method: 'POST',
|
|
18295
|
+
body: {
|
|
18296
|
+
skill: args.skill,
|
|
18297
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18298
|
+
},
|
|
18299
|
+
}),
|
|
18300
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18301
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18302
|
+
],
|
|
18303
|
+
}),
|
|
18304
|
+
updateMentorSkillAssignment: builder.mutation({
|
|
18305
|
+
query: (args) => ({
|
|
18306
|
+
url: CLAW_ENDPOINTS.UPDATE_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId, args.assignmentPk),
|
|
18307
|
+
service: CLAW_ENDPOINTS.UPDATE_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18308
|
+
method: 'PATCH',
|
|
18309
|
+
body: {
|
|
18310
|
+
...(args.enabled !== undefined && { enabled: args.enabled }),
|
|
18311
|
+
},
|
|
18312
|
+
}),
|
|
18313
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18314
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18315
|
+
],
|
|
18316
|
+
}),
|
|
18317
|
+
deleteMentorSkillAssignment: builder.mutation({
|
|
18318
|
+
query: (args) => ({
|
|
18319
|
+
url: CLAW_ENDPOINTS.DELETE_MENTOR_SKILL_ASSIGNMENT.path(args.org, args.mentorUniqueId, args.assignmentPk),
|
|
18320
|
+
service: CLAW_ENDPOINTS.DELETE_MENTOR_SKILL_ASSIGNMENT.service,
|
|
18321
|
+
method: 'DELETE',
|
|
18322
|
+
}),
|
|
18323
|
+
invalidatesTags: (_result, _error, args) => [
|
|
18324
|
+
{ type: 'MentorSkillAssignments', id: args.mentorUniqueId },
|
|
18325
|
+
],
|
|
18326
|
+
}),
|
|
18327
|
+
}),
|
|
18328
|
+
});
|
|
18329
|
+
|
|
17658
18330
|
const CUSTOM_DOMAIN_REDUCER_PATH = 'customDomainApiSlice';
|
|
17659
18331
|
const CUSTOM_DOMAIN_ENDPOINTS = {
|
|
17660
18332
|
GET_CUSTOM_DOMAINS: {
|
|
@@ -24064,6 +24736,7 @@ exports.filesReducer = filesReducer;
|
|
|
24064
24736
|
exports.filesSlice = filesSlice;
|
|
24065
24737
|
exports.formatRelativeTime = formatRelativeTime;
|
|
24066
24738
|
exports.getAuthSpaJoinUrl = getAuthSpaJoinUrl;
|
|
24739
|
+
exports.getCookieValue = getCookieValue;
|
|
24067
24740
|
exports.getDomainParts = getDomainParts;
|
|
24068
24741
|
exports.getFileInfo = getFileInfo;
|
|
24069
24742
|
exports.getInitials = getInitials;
|