@skillful-ai/skai-sdk 1.0.2
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/package.json +34 -0
- package/src/clients/admin-client.d.ts +33 -0
- package/src/clients/admin-client.js +41 -0
- package/src/clients/admin-client.js.map +1 -0
- package/src/clients/agents-client.d.ts +98 -0
- package/src/clients/agents-client.js +344 -0
- package/src/clients/agents-client.js.map +1 -0
- package/src/clients/base-client.d.ts +22 -0
- package/src/clients/base-client.js +148 -0
- package/src/clients/base-client.js.map +1 -0
- package/src/clients/index.d.ts +3 -0
- package/src/clients/index.js +7 -0
- package/src/clients/index.js.map +1 -0
- package/src/constants.d.ts +6 -0
- package/src/constants.js +13 -0
- package/src/constants.js.map +1 -0
- package/src/errors.d.ts +18 -0
- package/src/errors.js +23 -0
- package/src/errors.js.map +1 -0
- package/src/index.d.ts +37 -0
- package/src/index.js +50 -0
- package/src/index.js.map +1 -0
- package/src/streaming/index.d.ts +6 -0
- package/src/streaming/index.js +13 -0
- package/src/streaming/index.js.map +1 -0
- package/src/types/admin-api-types.d.ts +46 -0
- package/src/types/admin-api-types.js +32 -0
- package/src/types/admin-api-types.js.map +1 -0
- package/src/types/agents-api-types.d.ts +192 -0
- package/src/types/agents-api-types.js +135 -0
- package/src/types/agents-api-types.js.map +1 -0
- package/src/types/api-types.d.ts +20 -0
- package/src/types/api-types.js +12 -0
- package/src/types/api-types.js.map +1 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/index.js +7 -0
- package/src/types/index.js.map +1 -0
- package/src/types/streaming.d.ts +109 -0
- package/src/types/streaming.js +55 -0
- package/src/types/streaming.js.map +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +5 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/logger-adapter.d.ts +7 -0
- package/src/utils/logger-adapter.js +54 -0
- package/src/utils/logger-adapter.js.map +1 -0
- package/src/utils/skai-helpers.d.ts +19 -0
- package/src/utils/skai-helpers.js +47 -0
- package/src/utils/skai-helpers.js.map +1 -0
- package/src/utils/stream-metrics.d.ts +55 -0
- package/src/utils/stream-metrics.js +132 -0
- package/src/utils/stream-metrics.js.map +1 -0
- package/src/utils/stream-parser.d.ts +49 -0
- package/src/utils/stream-parser.js +181 -0
- package/src/utils/stream-parser.js.map +1 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkaiBaseClient = exports.consoleLogger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
// Default console logger for pieces
|
|
9
|
+
exports.consoleLogger = {
|
|
10
|
+
debug: (objectOrMessage, message) => {
|
|
11
|
+
if (typeof objectOrMessage === 'object' && message) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.debug(message, objectOrMessage);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.debug(objectOrMessage);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
info: (objectOrMessage, message) => {
|
|
21
|
+
if (typeof objectOrMessage === 'object' && message) {
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.info(message, objectOrMessage);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.info(objectOrMessage);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
warn: (objectOrMessage, message) => {
|
|
31
|
+
if (typeof objectOrMessage === 'object' && message) {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.warn(message, objectOrMessage);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.warn(objectOrMessage);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
error: (objectOrMessage, message) => {
|
|
41
|
+
if (typeof objectOrMessage === 'object' && message) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.error(message, objectOrMessage);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.error(objectOrMessage);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
class SkaiBaseClient {
|
|
52
|
+
constructor(log, baseUrl, timeout = constants_1.SKAI_API_TIMEOUT) {
|
|
53
|
+
this.log = log;
|
|
54
|
+
this.baseUrl = baseUrl;
|
|
55
|
+
this.timeout = timeout;
|
|
56
|
+
// Create axios instance with base configuration
|
|
57
|
+
this.httpClient = axios_1.default.create({
|
|
58
|
+
baseURL: this.baseUrl,
|
|
59
|
+
timeout: this.timeout,
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
'User-Agent': 'Activepieces-SKAI-SDK/1.0',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
this.setupErrorInterceptor();
|
|
66
|
+
}
|
|
67
|
+
setupErrorInterceptor() {
|
|
68
|
+
this.httpClient.interceptors.response.use((response) => response, (error) => {
|
|
69
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
70
|
+
this.log.error({
|
|
71
|
+
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
72
|
+
data: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
|
|
73
|
+
url: (_c = error.config) === null || _c === void 0 ? void 0 : _c.url,
|
|
74
|
+
method: (_d = error.config) === null || _d === void 0 ? void 0 : _d.method,
|
|
75
|
+
}, 'SKAI API Error');
|
|
76
|
+
if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) === 404) {
|
|
77
|
+
throw new errors_1.SkaiError(errors_1.SkaiErrorCode.ENTITY_NOT_FOUND, {
|
|
78
|
+
message: ((_f = error.response.data) === null || _f === void 0 ? void 0 : _f.detail) || 'Resource not found in SKAI API',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (((_g = error.response) === null || _g === void 0 ? void 0 : _g.status) === 401) {
|
|
82
|
+
throw new errors_1.SkaiError(errors_1.SkaiErrorCode.AUTHORIZATION, {
|
|
83
|
+
message: 'Unauthorized access to SKAI API',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (((_h = error.response) === null || _h === void 0 ? void 0 : _h.status) && error.response.status >= 500) {
|
|
87
|
+
throw new errors_1.SkaiError(errors_1.SkaiErrorCode.VALIDATION, {
|
|
88
|
+
message: 'SKAI API server error',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
throw new errors_1.SkaiError(errors_1.SkaiErrorCode.VALIDATION, {
|
|
92
|
+
message: ((_k = (_j = error.response) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.detail) || 'SKAI API request failed',
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
healthCheck() {
|
|
97
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
try {
|
|
99
|
+
yield this.httpClient.get('/api/health');
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.log.warn('SKAI API health check failed');
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Make a request to the SKAI API
|
|
110
|
+
*/
|
|
111
|
+
makeRequest(method, endpoint, data, options) {
|
|
112
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
const url = endpoint.startsWith('/api') ? endpoint : `/api${endpoint}`;
|
|
115
|
+
// Log the API request being made
|
|
116
|
+
this.log.info({
|
|
117
|
+
method,
|
|
118
|
+
url,
|
|
119
|
+
endpoint,
|
|
120
|
+
hasData: !!data,
|
|
121
|
+
timeout: (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout,
|
|
122
|
+
}, `SKAI API Request: ${method} ${url}`);
|
|
123
|
+
try {
|
|
124
|
+
const response = yield this.httpClient.request({
|
|
125
|
+
method,
|
|
126
|
+
url,
|
|
127
|
+
data,
|
|
128
|
+
timeout: (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout,
|
|
129
|
+
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
130
|
+
});
|
|
131
|
+
return response.data;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
const axiosError = error;
|
|
135
|
+
this.log.error({
|
|
136
|
+
message: axiosError.message,
|
|
137
|
+
status: (_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
138
|
+
statusText: (_b = axiosError.response) === null || _b === void 0 ? void 0 : _b.statusText,
|
|
139
|
+
responseData: (_c = axiosError.response) === null || _c === void 0 ? void 0 : _c.data,
|
|
140
|
+
code: axiosError.code,
|
|
141
|
+
}, `SKAI API ${method} ${url} - Failed`);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.SkaiBaseClient = SkaiBaseClient;
|
|
148
|
+
//# sourceMappingURL=base-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-client.js","sourceRoot":"","sources":["../../../../../../packages/custom/skai-sdk/src/clients/base-client.ts"],"names":[],"mappings":";;;;AAAA,0DAAwD;AACxD,4CAA+C;AAC/C,sCAAoD;AAYpD,oCAAoC;AACvB,QAAA,aAAa,GAAW;IACjC,KAAK,EAAE,CAAC,eAAgC,EAAE,OAAgB,EAAQ,EAAE;QAChE,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,OAAO,EAAE,CAAC;YACjD,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,OAA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AC,OAAO,CAAI;oBAC9C,MAAM;oBACN,GAAG;oBACH,IAAI;oBACJ,OAAO,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,IAAI,CAAC,OAAO;oBACzC,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO;iBAC5B,CAAC,CAAA;gBACF,OAAO,QAAQ,CAAC,IAAI,CAAA;YACxB,CAAC;YACD,OAAO,KAAK,EAAE,CAAC;gBACX,MAAM,UAAU,GAAG,KAAmB,CAAA;gBACtC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;oBACX,OAAO,EAAE,UAAU,CAAC,OAAO;oBAC3B,MAAM,EAAE,MAAA,UAAU,CAAC,QAAQ,0CAAE,MAAM;oBACnC,UAAU,EAAE,MAAA,UAAU,CAAC,QAAQ,0CAAE,UAAU;oBAC3C,YAAY,EAAE,MAAA,UAAU,CAAC,QAAQ,0CAAE,IAAI;oBACvC,IAAI,EAAE,UAAU,CAAC,IAAI;iBACxB,EAAE,YAAY,MAAM,IAAI,GAAG,WAAW,CAAC,CAAA;gBACxC,MAAM,KAAK,CAAA;YACf,CAAC;QACL,CAAC;KAAA;CAEJ;AA3HD,wCA2HC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./base-client"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./admin-client"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./agents-client"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/custom/skai-sdk/src/clients/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,yDAA8B;AAC9B,0DAA+B"}
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SKAI SDK timeout constants
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SKAI_API_TIMEOUT = exports.SKAI_AGENTS_STREAMING_TIMEOUT = exports.SKAI_AGENTS_EXECUTION_TIMEOUT = void 0;
|
|
7
|
+
// 15 minutes for agent execution requests (non-streaming chat, etc.)
|
|
8
|
+
exports.SKAI_AGENTS_EXECUTION_TIMEOUT = 15 * 60 * 1000; // 900,000ms
|
|
9
|
+
// 15 minutes for streaming agent execution requests (avoids API gateway timeout)
|
|
10
|
+
exports.SKAI_AGENTS_STREAMING_TIMEOUT = 15 * 60 * 1000; // 900,000ms
|
|
11
|
+
// 5 minutes for other API requests (list agents, get agent, etc.)
|
|
12
|
+
exports.SKAI_API_TIMEOUT = 5 * 60 * 1000; // 300,000ms
|
|
13
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/custom/skai-sdk/src/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qEAAqE;AACxD,QAAA,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,YAAY;AAExE,iFAAiF;AACpE,QAAA,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,YAAY;AAExE,kEAAkE;AACrD,QAAA,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,YAAY"}
|
package/src/errors.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SKAI SDK Error Types - Independent of ActivePieces shared types
|
|
3
|
+
* These errors can be used in both server and piece contexts
|
|
4
|
+
*/
|
|
5
|
+
export declare enum SkaiErrorCode {
|
|
6
|
+
ENTITY_NOT_FOUND = "ENTITY_NOT_FOUND",
|
|
7
|
+
AUTHORIZATION = "AUTHORIZATION",
|
|
8
|
+
VALIDATION = "VALIDATION"
|
|
9
|
+
}
|
|
10
|
+
export declare class SkaiError extends Error {
|
|
11
|
+
readonly code: SkaiErrorCode;
|
|
12
|
+
readonly params: {
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
constructor(code: SkaiErrorCode, params: {
|
|
16
|
+
message: string;
|
|
17
|
+
}, message?: string);
|
|
18
|
+
}
|
package/src/errors.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SKAI SDK Error Types - Independent of ActivePieces shared types
|
|
4
|
+
* These errors can be used in both server and piece contexts
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SkaiError = exports.SkaiErrorCode = void 0;
|
|
8
|
+
var SkaiErrorCode;
|
|
9
|
+
(function (SkaiErrorCode) {
|
|
10
|
+
SkaiErrorCode["ENTITY_NOT_FOUND"] = "ENTITY_NOT_FOUND";
|
|
11
|
+
SkaiErrorCode["AUTHORIZATION"] = "AUTHORIZATION";
|
|
12
|
+
SkaiErrorCode["VALIDATION"] = "VALIDATION";
|
|
13
|
+
})(SkaiErrorCode || (exports.SkaiErrorCode = SkaiErrorCode = {}));
|
|
14
|
+
class SkaiError extends Error {
|
|
15
|
+
constructor(code, params, message) {
|
|
16
|
+
super(message || params.message);
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.params = params;
|
|
19
|
+
this.name = 'SkaiError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.SkaiError = SkaiError;
|
|
23
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../packages/custom/skai-sdk/src/errors.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,sDAAqC,CAAA;IACrC,gDAA+B,CAAA;IAC/B,0CAAyB,CAAA;AAC7B,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,MAAa,SAAU,SAAQ,KAAK;IAChC,YACoB,IAAmB,EACnB,MAA2B,EAC3C,OAAgB;QAEhB,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAA;QAJhB,SAAI,GAAJ,IAAI,CAAe;QACnB,WAAM,GAAN,MAAM,CAAqB;QAI3C,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IAC3B,CAAC;CACJ;AATD,8BASC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SKAI SDK - Standalone SDK for interacting with SKAI APIs
|
|
3
|
+
*
|
|
4
|
+
* This SDK provides independent clients for different SKAI services.
|
|
5
|
+
* Each client can be instantiated with only the configuration it needs.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createSkaiAgentsClient, createSkaiAdminClient } from '@skillful-ai/skai-sdk'
|
|
10
|
+
*
|
|
11
|
+
* // Create an agents client
|
|
12
|
+
* const agentsClient = createSkaiAgentsClient(log, {
|
|
13
|
+
* baseUrl: 'https://api-dev.agents.skillfulai.io',
|
|
14
|
+
* userApiKey: 'sk-...'
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // Create an admin client (if needed)
|
|
18
|
+
* const adminClient = createSkaiAdminClient(log, {
|
|
19
|
+
* baseUrl: 'https://api-dev.agents.skillfulai.io',
|
|
20
|
+
* adminApiKey: 'admin-key-...'
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* // Use the clients
|
|
24
|
+
* const agents = await agentsClient.listAgents()
|
|
25
|
+
* const userApiKeys = await adminClient.getUserApiKeys('user-123')
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export * from './clients';
|
|
29
|
+
export * from './types';
|
|
30
|
+
export * from './utils';
|
|
31
|
+
export * from './errors';
|
|
32
|
+
export { SkaiAgentsClient, type SkaiAgentsClientConfig } from './clients/agents-client';
|
|
33
|
+
export { SkaiAdminClient, type SkaiAdminClientConfig } from './clients/admin-client';
|
|
34
|
+
export { consoleLogger } from './clients/base-client';
|
|
35
|
+
export type { Logger } from './clients/base-client';
|
|
36
|
+
export { createSkaiAgentsClient, createSkaiAdminClient, checkSkaiApiStatus } from './utils/skai-helpers';
|
|
37
|
+
export { createFastifyLoggerAdapter } from './utils/logger-adapter';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SKAI SDK - Standalone SDK for interacting with SKAI APIs
|
|
4
|
+
*
|
|
5
|
+
* This SDK provides independent clients for different SKAI services.
|
|
6
|
+
* Each client can be instantiated with only the configuration it needs.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createSkaiAgentsClient, createSkaiAdminClient } from '@skillful-ai/skai-sdk'
|
|
11
|
+
*
|
|
12
|
+
* // Create an agents client
|
|
13
|
+
* const agentsClient = createSkaiAgentsClient(log, {
|
|
14
|
+
* baseUrl: 'https://api-dev.agents.skillfulai.io',
|
|
15
|
+
* userApiKey: 'sk-...'
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* // Create an admin client (if needed)
|
|
19
|
+
* const adminClient = createSkaiAdminClient(log, {
|
|
20
|
+
* baseUrl: 'https://api-dev.agents.skillfulai.io',
|
|
21
|
+
* adminApiKey: 'admin-key-...'
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Use the clients
|
|
25
|
+
* const agents = await agentsClient.listAgents()
|
|
26
|
+
* const userApiKeys = await adminClient.getUserApiKeys('user-123')
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.createFastifyLoggerAdapter = exports.checkSkaiApiStatus = exports.createSkaiAdminClient = exports.createSkaiAgentsClient = exports.consoleLogger = exports.SkaiAdminClient = exports.SkaiAgentsClient = void 0;
|
|
31
|
+
const tslib_1 = require("tslib");
|
|
32
|
+
// Main exports
|
|
33
|
+
tslib_1.__exportStar(require("./clients"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
36
|
+
tslib_1.__exportStar(require("./errors"), exports);
|
|
37
|
+
// Convenience re-exports for common usage
|
|
38
|
+
var agents_client_1 = require("./clients/agents-client");
|
|
39
|
+
Object.defineProperty(exports, "SkaiAgentsClient", { enumerable: true, get: function () { return agents_client_1.SkaiAgentsClient; } });
|
|
40
|
+
var admin_client_1 = require("./clients/admin-client");
|
|
41
|
+
Object.defineProperty(exports, "SkaiAdminClient", { enumerable: true, get: function () { return admin_client_1.SkaiAdminClient; } });
|
|
42
|
+
var base_client_1 = require("./clients/base-client");
|
|
43
|
+
Object.defineProperty(exports, "consoleLogger", { enumerable: true, get: function () { return base_client_1.consoleLogger; } });
|
|
44
|
+
var skai_helpers_1 = require("./utils/skai-helpers");
|
|
45
|
+
Object.defineProperty(exports, "createSkaiAgentsClient", { enumerable: true, get: function () { return skai_helpers_1.createSkaiAgentsClient; } });
|
|
46
|
+
Object.defineProperty(exports, "createSkaiAdminClient", { enumerable: true, get: function () { return skai_helpers_1.createSkaiAdminClient; } });
|
|
47
|
+
Object.defineProperty(exports, "checkSkaiApiStatus", { enumerable: true, get: function () { return skai_helpers_1.checkSkaiApiStatus; } });
|
|
48
|
+
var logger_adapter_1 = require("./utils/logger-adapter");
|
|
49
|
+
Object.defineProperty(exports, "createFastifyLoggerAdapter", { enumerable: true, get: function () { return logger_adapter_1.createFastifyLoggerAdapter; } });
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/custom/skai-sdk/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;AAEH,eAAe;AACf,oDAAyB;AACzB,kDAAuB;AACvB,kDAAuB;AACvB,mDAAwB;AAExB,0CAA0C;AAC1C,yDAAuF;AAA9E,iHAAA,gBAAgB,OAAA;AACzB,uDAAoF;AAA3E,+GAAA,eAAe,OAAA;AACxB,qDAAqD;AAA5C,4GAAA,aAAa,OAAA;AAEtB,qDAAwG;AAA/F,sHAAA,sBAAsB,OAAA;AAAE,qHAAA,qBAAqB,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAC1E,yDAAmE;AAA1D,4HAAA,0BAA0B,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SKAI Streaming Module Exports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
// Types and constants
|
|
8
|
+
tslib_1.__exportStar(require("../types/streaming"), exports);
|
|
9
|
+
// Stream parsing utilities
|
|
10
|
+
tslib_1.__exportStar(require("../utils/stream-parser"), exports);
|
|
11
|
+
// Stream metrics tracking
|
|
12
|
+
tslib_1.__exportStar(require("../utils/stream-metrics"), exports);
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/custom/skai-sdk/src/streaming/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sBAAsB;AACtB,6DAAkC;AAElC,2BAA2B;AAC3B,iEAAsC;AAEtC,0BAA0B;AAC1B,kEAAuC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Static } from '@sinclair/typebox';
|
|
2
|
+
/**
|
|
3
|
+
* Admin API Types for SKAI Admin Client
|
|
4
|
+
* These types match the actual API response format with camelCase fields
|
|
5
|
+
*/
|
|
6
|
+
export declare const UserAPIKey: import("@sinclair/typebox").TObject<{
|
|
7
|
+
id: import("@sinclair/typebox").TString;
|
|
8
|
+
userId: import("@sinclair/typebox").TString;
|
|
9
|
+
apiKey: import("@sinclair/typebox").TString;
|
|
10
|
+
name: import("@sinclair/typebox").TString;
|
|
11
|
+
isActive: import("@sinclair/typebox").TBoolean;
|
|
12
|
+
isSystemManaged: import("@sinclair/typebox").TBoolean;
|
|
13
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
14
|
+
updatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
15
|
+
}>;
|
|
16
|
+
export type UserAPIKey = Static<typeof UserAPIKey>;
|
|
17
|
+
export declare const GetUserAPIKeyResponse: import("@sinclair/typebox").TObject<{
|
|
18
|
+
success: import("@sinclair/typebox").TBoolean;
|
|
19
|
+
data: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
20
|
+
id: import("@sinclair/typebox").TString;
|
|
21
|
+
userId: import("@sinclair/typebox").TString;
|
|
22
|
+
apiKey: import("@sinclair/typebox").TString;
|
|
23
|
+
name: import("@sinclair/typebox").TString;
|
|
24
|
+
isActive: import("@sinclair/typebox").TBoolean;
|
|
25
|
+
isSystemManaged: import("@sinclair/typebox").TBoolean;
|
|
26
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
27
|
+
updatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
28
|
+
}>>;
|
|
29
|
+
error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
|
|
30
|
+
}>;
|
|
31
|
+
export type GetUserAPIKeyResponse = Static<typeof GetUserAPIKeyResponse>;
|
|
32
|
+
export declare const GetUserAPIKeysResponse: import("@sinclair/typebox").TObject<{
|
|
33
|
+
success: import("@sinclair/typebox").TBoolean;
|
|
34
|
+
data: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
35
|
+
id: import("@sinclair/typebox").TString;
|
|
36
|
+
userId: import("@sinclair/typebox").TString;
|
|
37
|
+
apiKey: import("@sinclair/typebox").TString;
|
|
38
|
+
name: import("@sinclair/typebox").TString;
|
|
39
|
+
isActive: import("@sinclair/typebox").TBoolean;
|
|
40
|
+
isSystemManaged: import("@sinclair/typebox").TBoolean;
|
|
41
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
42
|
+
updatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
43
|
+
}>>>;
|
|
44
|
+
error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
|
|
45
|
+
}>;
|
|
46
|
+
export type GetUserAPIKeysResponse = Static<typeof GetUserAPIKeysResponse>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetUserAPIKeysResponse = exports.GetUserAPIKeyResponse = exports.UserAPIKey = void 0;
|
|
4
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
5
|
+
/**
|
|
6
|
+
* Admin API Types for SKAI Admin Client
|
|
7
|
+
* These types match the actual API response format with camelCase fields
|
|
8
|
+
*/
|
|
9
|
+
// User API key object
|
|
10
|
+
exports.UserAPIKey = typebox_1.Type.Object({
|
|
11
|
+
id: typebox_1.Type.String(),
|
|
12
|
+
userId: typebox_1.Type.String(),
|
|
13
|
+
apiKey: typebox_1.Type.String(),
|
|
14
|
+
name: typebox_1.Type.String(),
|
|
15
|
+
isActive: typebox_1.Type.Boolean(),
|
|
16
|
+
isSystemManaged: typebox_1.Type.Boolean(),
|
|
17
|
+
createdAt: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
18
|
+
updatedAt: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
19
|
+
});
|
|
20
|
+
// Response for getting a single user's system API key
|
|
21
|
+
exports.GetUserAPIKeyResponse = typebox_1.Type.Object({
|
|
22
|
+
success: typebox_1.Type.Boolean(),
|
|
23
|
+
data: typebox_1.Type.Optional(exports.UserAPIKey),
|
|
24
|
+
error: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()])),
|
|
25
|
+
});
|
|
26
|
+
// Response for getting all system API keys for a user (if needed in future)
|
|
27
|
+
exports.GetUserAPIKeysResponse = typebox_1.Type.Object({
|
|
28
|
+
success: typebox_1.Type.Boolean(),
|
|
29
|
+
data: typebox_1.Type.Optional(typebox_1.Type.Array(exports.UserAPIKey)),
|
|
30
|
+
error: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()])),
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=admin-api-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-api-types.js","sourceRoot":"","sources":["../../../../../../packages/custom/skai-sdk/src/types/admin-api-types.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAEhD;;;GAGG;AAEH,sBAAsB;AACT,QAAA,UAAU,GAAG,cAAI,CAAC,MAAM,CAAC;IAClC,EAAE,EAAE,cAAI,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,cAAI,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,cAAI,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,cAAI,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,cAAI,CAAC,OAAO,EAAE;IACxB,eAAe,EAAE,cAAI,CAAC,OAAO,EAAE;IAC/B,SAAS,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAA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