@skillful-ai/piece-skillful-agents 0.0.4 → 0.0.7
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/README.md +1 -1
- package/package.json +7 -5
- package/src/lib/actions/run-agent.js +22 -31
- package/src/lib/actions/run-agent.js.map +1 -1
- package/src/lib/common.d.ts +72 -24
- package/src/lib/common.js +72 -50
- package/src/lib/common.js.map +1 -1
- package/src/lib/types.d.ts +1 -42
- package/src/lib/types.js +1 -1
- package/src/lib/constants.d.ts +0 -5
- package/src/lib/constants.js +0 -11
- package/src/lib/constants.js.map +0 -1
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ UPDATE user SET skaiApiKey = 'your-skai-api-key-here' WHERE id = 'USER_ID';
|
|
|
150
150
|
|
|
151
151
|
## 📋 Technical Details
|
|
152
152
|
|
|
153
|
-
- **Package Name**: `@
|
|
153
|
+
- **Package Name**: `@skillful-ai/piece-skillful-agents`
|
|
154
154
|
- **Piece Name**: `skillful-agents`
|
|
155
155
|
- **Category**: Universal AI
|
|
156
156
|
- **Minimum Release**: 0.66.0
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillful-ai/piece-skillful-agents",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@activepieces/pieces-common": "*",
|
|
9
|
+
"@activepieces/pieces-framework": "*",
|
|
10
|
+
"@activepieces/shared": "*",
|
|
8
11
|
"@ai-sdk/anthropic": "1.2.12",
|
|
9
12
|
"@ai-sdk/google": "1.2.19",
|
|
10
13
|
"@ai-sdk/openai": "1.3.22",
|
|
11
14
|
"@ai-sdk/replicate": "0.2.8",
|
|
12
15
|
"@sinclair/typebox": "0.34.11",
|
|
16
|
+
"@skillful-ai/skai-sdk": "1.0.4",
|
|
13
17
|
"ai": "4.3.16",
|
|
14
18
|
"axios": "1.8.3",
|
|
15
19
|
"axios-retry": "4.4.1",
|
|
16
20
|
"deepmerge-ts": "7.1.0",
|
|
17
21
|
"fast-glob": "3.3.3",
|
|
22
|
+
"fastify": "5.4.0",
|
|
18
23
|
"mime-types": "2.1.35",
|
|
19
24
|
"nanoid": "3.3.8",
|
|
20
25
|
"semver": "7.6.0",
|
|
21
26
|
"tslib": "^2.3.0",
|
|
22
|
-
"zod": "3.25.76"
|
|
23
|
-
"@activepieces/pieces-common": "0.6.0",
|
|
24
|
-
"@activepieces/pieces-framework": "0.15.0",
|
|
25
|
-
"@activepieces/shared": "0.17.2"
|
|
27
|
+
"zod": "3.25.76"
|
|
26
28
|
},
|
|
27
29
|
"overrides": {
|
|
28
30
|
"@tryfabric/martian": {
|
|
@@ -24,34 +24,27 @@ exports.runAgent = (0, pieces_framework_1.createAction)({
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
// Use direct SKAI API calls via common method
|
|
28
|
+
const agents = yield common_1.skillfulAgentsCommon.listAgents({
|
|
28
29
|
serverUrl: ctx.server.publicUrl,
|
|
29
30
|
token: ctx.server.token
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
options: options
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return {
|
|
44
|
-
disabled: true,
|
|
45
|
-
options: [],
|
|
46
|
-
placeholder: `Failed to load agents: ${response.status}`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
32
|
+
const options = agents.map((agent) => ({
|
|
33
|
+
label: `${agent.name}${agent.description ? ` - ${agent.description}` : ''}`,
|
|
34
|
+
value: agent.id
|
|
35
|
+
}));
|
|
36
|
+
return {
|
|
37
|
+
disabled: false,
|
|
38
|
+
options: options
|
|
39
|
+
};
|
|
49
40
|
}
|
|
50
41
|
catch (error) {
|
|
42
|
+
console.error('Failed to load agents:', error);
|
|
43
|
+
const isApiKeyError = error instanceof Error && error.message.includes('SKAI API key not configured');
|
|
51
44
|
return {
|
|
52
45
|
disabled: true,
|
|
53
46
|
options: [],
|
|
54
|
-
placeholder: 'Error loading agents'
|
|
47
|
+
placeholder: isApiKeyError ? 'SKAI API key not configured' : 'Error loading agents'
|
|
55
48
|
};
|
|
56
49
|
}
|
|
57
50
|
}),
|
|
@@ -71,25 +64,23 @@ exports.runAgent = (0, pieces_framework_1.createAction)({
|
|
|
71
64
|
run(context) {
|
|
72
65
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
73
66
|
const { agentId, message, testMode } = context.propsValue;
|
|
74
|
-
const serverUrl = context.server.publicUrl;
|
|
75
|
-
const token = context.server.token;
|
|
76
67
|
if (!agentId || !message) {
|
|
77
68
|
throw new Error('Agent ID and message are required');
|
|
78
69
|
}
|
|
79
|
-
// Use
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
token,
|
|
70
|
+
// Use direct SKAI API calls - no more double HTTP hop!
|
|
71
|
+
const response = yield common_1.skillfulAgentsCommon.chatWithAgent({
|
|
72
|
+
serverUrl: context.server.publicUrl,
|
|
73
|
+
token: context.server.token,
|
|
84
74
|
agentId,
|
|
85
75
|
message,
|
|
86
|
-
isTestMode: testMode || false
|
|
76
|
+
isTestMode: testMode || false,
|
|
77
|
+
flowId: context.flows.current.id,
|
|
78
|
+
flowRunId: context.run.id
|
|
87
79
|
});
|
|
88
|
-
const chatResponse = response.body;
|
|
89
80
|
return {
|
|
90
81
|
success: true,
|
|
91
|
-
message:
|
|
92
|
-
chatHistoryId:
|
|
82
|
+
message: response.message,
|
|
83
|
+
chatHistoryId: response.chatHistoryId,
|
|
93
84
|
agentId: agentId,
|
|
94
85
|
userMessage: message,
|
|
95
86
|
testMode: testMode || false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skillful-agents/src/lib/actions/run-agent.ts"],"names":[],"mappings":";;;;AAAA,qEAAuE;AACvE,sCAAgD;AAGnC,QAAA,QAAQ,GAAG,IAAA,+BAAY,EAAC;IACnC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,iEAAiE;IAC9E,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,CAAO,KAAK,EAAE,GAAG,EAAE,EAAE;;gBAC5B,IAAI,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,KAAK,CAAA,EAAE,CAAC;oBACxB,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,EAAE;wBACX,WAAW,EAAE,uBAAuB;qBACrC,CAAA;gBACH,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,
|
|
1
|
+
{"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skillful-agents/src/lib/actions/run-agent.ts"],"names":[],"mappings":";;;;AAAA,qEAAuE;AACvE,sCAAgD;AAGnC,QAAA,QAAQ,GAAG,IAAA,+BAAY,EAAC;IACnC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,iEAAiE;IAC9E,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,CAAO,KAAK,EAAE,GA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
|
|
2
|
+
interface User {
|
|
3
|
+
id: string;
|
|
4
|
+
skaiApiKey?: string;
|
|
5
|
+
externalId?: string;
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* Common utilities for Skillful Agents piece
|
|
3
|
-
*
|
|
9
|
+
* Now uses the shared SKAI SDK for better consistency
|
|
4
10
|
*/
|
|
5
11
|
export declare const skillfulAgentsCommon: {
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
13
|
+
* Get the piece user (user) with their credentials
|
|
14
|
+
* This is used to get the skaiApiKey for SKAI SDK usage
|
|
8
15
|
*/
|
|
9
|
-
|
|
16
|
+
getPieceUser(params: {
|
|
17
|
+
serverUrl: string;
|
|
18
|
+
token: string;
|
|
19
|
+
}): Promise<User>;
|
|
10
20
|
/**
|
|
11
|
-
*
|
|
21
|
+
* Get SKAI API URL from server configuration
|
|
12
22
|
*/
|
|
13
|
-
|
|
23
|
+
getSkaiApiUrl(params: {
|
|
14
24
|
serverUrl: string;
|
|
15
25
|
token: string;
|
|
16
|
-
}): Promise<
|
|
26
|
+
}): Promise<string>;
|
|
17
27
|
/**
|
|
18
|
-
*
|
|
28
|
+
* Create a SKAI API client instance with proper configuration
|
|
19
29
|
*/
|
|
20
|
-
|
|
30
|
+
createSkaiClient(params: {
|
|
21
31
|
serverUrl: string;
|
|
22
32
|
token: string;
|
|
23
|
-
|
|
24
|
-
}): Promise<
|
|
33
|
+
userApiKey: string;
|
|
34
|
+
}): Promise<SkaiAgentsClient>;
|
|
25
35
|
/**
|
|
26
|
-
*
|
|
27
|
-
* If chatHistoryId is provided, continues existing conversation
|
|
28
|
-
* If chatHistoryId is omitted, starts new conversation
|
|
36
|
+
* List all agents using SKAI SDK
|
|
29
37
|
*/
|
|
30
|
-
|
|
38
|
+
listAgents(params: {
|
|
31
39
|
serverUrl: string;
|
|
32
40
|
token: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
}): Promise<{
|
|
42
|
+
ownerUserId?: string | undefined;
|
|
43
|
+
logoUrl?: string | undefined;
|
|
44
|
+
isDraft?: boolean | undefined;
|
|
45
|
+
isMinted?: boolean | undefined;
|
|
46
|
+
config?: {
|
|
47
|
+
token?: {
|
|
48
|
+
[x: string]: any;
|
|
49
|
+
} | undefined;
|
|
50
|
+
skills?: {
|
|
51
|
+
[x: string]: any;
|
|
52
|
+
}[] | undefined;
|
|
53
|
+
memory?: {
|
|
54
|
+
[x: string]: any;
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
integrations?: {
|
|
57
|
+
[x: string]: any;
|
|
58
|
+
}[] | undefined;
|
|
59
|
+
routines?: {
|
|
60
|
+
[x: string]: any;
|
|
61
|
+
} | undefined;
|
|
62
|
+
mediaProcessing?: {
|
|
63
|
+
[x: string]: any;
|
|
64
|
+
}[] | undefined;
|
|
65
|
+
sampleQuestions?: string[] | undefined;
|
|
66
|
+
llm: {
|
|
67
|
+
temperature?: number | undefined;
|
|
68
|
+
maxTokens?: number | undefined;
|
|
69
|
+
provider: import("@skillful-ai/skai-sdk").LLMProvider;
|
|
70
|
+
model: string;
|
|
71
|
+
};
|
|
72
|
+
character: {
|
|
73
|
+
promptTemplateId?: string | undefined;
|
|
74
|
+
};
|
|
75
|
+
strategy: string;
|
|
76
|
+
} | undefined;
|
|
77
|
+
type: import("@skillful-ai/skai-sdk").AgentType;
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
}[]>;
|
|
38
82
|
/**
|
|
39
|
-
* Chat with an agent using
|
|
40
|
-
* If chatHistoryId is provided, continues existing conversation
|
|
41
|
-
* If chatHistoryId is omitted, starts new conversation
|
|
83
|
+
* Chat with an agent using SKAI SDK (streaming)
|
|
42
84
|
*/
|
|
43
|
-
|
|
85
|
+
chatWithAgent(params: {
|
|
44
86
|
serverUrl: string;
|
|
45
87
|
token: string;
|
|
46
88
|
agentId: string;
|
|
47
89
|
message: string;
|
|
48
90
|
chatHistoryId?: string;
|
|
49
91
|
isTestMode?: boolean;
|
|
50
|
-
|
|
92
|
+
flowId?: string;
|
|
93
|
+
flowRunId?: string;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
message: string;
|
|
96
|
+
chatHistoryId: string;
|
|
97
|
+
}>;
|
|
51
98
|
};
|
|
99
|
+
export {};
|
package/src/lib/common.js
CHANGED
|
@@ -3,91 +3,113 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.skillfulAgentsCommon = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
-
const
|
|
6
|
+
const skai_sdk_1 = require("@skillful-ai/skai-sdk");
|
|
7
7
|
/**
|
|
8
8
|
* Common utilities for Skillful Agents piece
|
|
9
|
-
*
|
|
9
|
+
* Now uses the shared SKAI SDK for better consistency
|
|
10
10
|
*/
|
|
11
11
|
exports.skillfulAgentsCommon = {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Get the piece user (user) with their credentials
|
|
14
|
+
* This is used to get the skaiApiKey for SKAI SDK usage
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* List all available agents for the authenticated user
|
|
18
|
-
*/
|
|
19
|
-
listAgents(params) {
|
|
16
|
+
getPieceUser(params) {
|
|
20
17
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
|
|
18
|
+
console.log('Fetching piece user credentials from:', `${params.serverUrl}v1/users/piece-user`);
|
|
19
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
22
20
|
method: pieces_common_1.HttpMethod.GET,
|
|
23
|
-
url: `${
|
|
21
|
+
url: `${params.serverUrl}v1/users/piece-user`,
|
|
24
22
|
authentication: {
|
|
25
23
|
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
26
24
|
token: params.token,
|
|
27
25
|
},
|
|
28
26
|
});
|
|
27
|
+
const user = response.body;
|
|
28
|
+
console.log('Retrieved user:', {
|
|
29
|
+
id: user.id,
|
|
30
|
+
externalId: user.externalId,
|
|
31
|
+
hasSkaiApiKey: !!user.skaiApiKey,
|
|
32
|
+
skaiApiKeyPrefix: user.skaiApiKey ? user.skaiApiKey.substring(0, 10) + '...' : 'none'
|
|
33
|
+
});
|
|
34
|
+
return user;
|
|
29
35
|
});
|
|
30
36
|
},
|
|
31
37
|
/**
|
|
32
|
-
* Get
|
|
38
|
+
* Get SKAI API URL from server configuration
|
|
33
39
|
*/
|
|
34
|
-
|
|
40
|
+
getSkaiApiUrl(params) {
|
|
35
41
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
|
|
42
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
37
43
|
method: pieces_common_1.HttpMethod.GET,
|
|
38
|
-
url: `${
|
|
44
|
+
url: `${params.serverUrl}v1/skai-agents/config`,
|
|
39
45
|
authentication: {
|
|
40
46
|
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
41
47
|
token: params.token,
|
|
42
48
|
},
|
|
43
49
|
});
|
|
50
|
+
return response.body.agentsApiUrl;
|
|
44
51
|
});
|
|
45
52
|
},
|
|
46
53
|
/**
|
|
47
|
-
*
|
|
48
|
-
* If chatHistoryId is provided, continues existing conversation
|
|
49
|
-
* If chatHistoryId is omitted, starts new conversation
|
|
54
|
+
* Create a SKAI API client instance with proper configuration
|
|
50
55
|
*/
|
|
51
|
-
|
|
56
|
+
createSkaiClient(params) {
|
|
52
57
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
token: params.token,
|
|
59
|
-
},
|
|
60
|
-
body: {
|
|
61
|
-
agentId: params.agentId,
|
|
62
|
-
message: params.message,
|
|
63
|
-
chatHistoryId: params.chatHistoryId,
|
|
64
|
-
isTestMode: params.isTestMode || false
|
|
65
|
-
},
|
|
66
|
-
timeout: constants_1.SKILLFUL_AGENTS_HTTP_TIMEOUT, // 18 minutes (2 minutes less than 20-minute flow timeout)
|
|
58
|
+
const baseUrl = yield this.getSkaiApiUrl(params);
|
|
59
|
+
console.log('Creating SKAI client with:', {
|
|
60
|
+
baseUrl,
|
|
61
|
+
hasUserApiKey: !!params.userApiKey,
|
|
62
|
+
userApiKeyPrefix: params.userApiKey ? params.userApiKey.substring(0, 10) + '...' : 'none'
|
|
67
63
|
});
|
|
64
|
+
const config = {
|
|
65
|
+
baseUrl,
|
|
66
|
+
userApiKey: params.userApiKey
|
|
67
|
+
};
|
|
68
|
+
return new skai_sdk_1.SkaiAgentsClient(skai_sdk_1.consoleLogger, config);
|
|
68
69
|
});
|
|
69
70
|
},
|
|
70
71
|
/**
|
|
71
|
-
*
|
|
72
|
-
* If chatHistoryId is provided, continues existing conversation
|
|
73
|
-
* If chatHistoryId is omitted, starts new conversation
|
|
72
|
+
* List all agents using SKAI SDK
|
|
74
73
|
*/
|
|
75
|
-
|
|
74
|
+
listAgents(params) {
|
|
76
75
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
// Get user credentials first
|
|
77
|
+
const user = yield this.getPieceUser(params);
|
|
78
|
+
if (!user.skaiApiKey) {
|
|
79
|
+
throw new Error('SKAI API key not configured');
|
|
80
|
+
}
|
|
81
|
+
// Use SKAI SDK with proper configuration
|
|
82
|
+
const skaiClient = yield this.createSkaiClient({
|
|
83
|
+
serverUrl: params.serverUrl,
|
|
84
|
+
token: params.token,
|
|
85
|
+
userApiKey: user.skaiApiKey
|
|
86
|
+
});
|
|
87
|
+
return yield skaiClient.listAgents();
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Chat with an agent using SKAI SDK (streaming)
|
|
92
|
+
*/
|
|
93
|
+
chatWithAgent(params) {
|
|
94
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
// Get user credentials first
|
|
96
|
+
const user = yield this.getPieceUser(params);
|
|
97
|
+
if (!user.skaiApiKey) {
|
|
98
|
+
throw new Error('SKAI API key not configured');
|
|
99
|
+
}
|
|
100
|
+
// Use SKAI SDK with proper configuration
|
|
101
|
+
const skaiClient = yield this.createSkaiClient({
|
|
102
|
+
serverUrl: params.serverUrl,
|
|
103
|
+
token: params.token,
|
|
104
|
+
userApiKey: user.skaiApiKey
|
|
105
|
+
});
|
|
106
|
+
return yield skaiClient.chatStream({
|
|
107
|
+
agentId: params.agentId,
|
|
108
|
+
message: params.message,
|
|
109
|
+
chatHistoryId: params.chatHistoryId,
|
|
110
|
+
isTestMode: params.isTestMode || false,
|
|
111
|
+
flowId: params.flowId,
|
|
112
|
+
flowRunId: params.flowRunId
|
|
91
113
|
});
|
|
92
114
|
});
|
|
93
115
|
}
|
package/src/lib/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/custom/skillful-agents/src/lib/common.ts"],"names":[],"mappings":";;;;AAAA,+DAAwF;AACxF,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/custom/skillful-agents/src/lib/common.ts"],"names":[],"mappings":";;;;AAAA,+DAAwF;AACxF,oDAA+F;AAS/F;;;GAGG;AAEU,QAAA,oBAAoB,GAAG;IAClC;;;OAGG;IACG,YAAY,CAAC,MAA4C;;YAC7D,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,GAAG,MAAM,CAAC,SAAS,qBAAqB,CAAC,CAAA;YAE9F,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAO;gBAClD,MAAM,EAAE,0BAAU,CAA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,UAAU;aAC5B,CAAC,CAAA;YACF,OAAO,MAAM,UAAU,CAAC,UAAU,CAAC;gBACjC,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;gBACtC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAA;QACJ,CAAC;KAAA;CACF,CAAA"}
|
package/src/lib/types.d.ts
CHANGED
|
@@ -1,49 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for Skillful Agents piece
|
|
3
|
-
*
|
|
3
|
+
* Most types are now imported from @activepieces/server-shared SKAI SDK
|
|
4
4
|
*/
|
|
5
|
-
export interface SkillfulAgent {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
logoUrl: string;
|
|
10
|
-
isDraft?: boolean;
|
|
11
|
-
isMinted?: boolean;
|
|
12
|
-
type: string;
|
|
13
|
-
ownerUserId?: string;
|
|
14
|
-
config?: any;
|
|
15
|
-
}
|
|
16
|
-
export interface SkillfulChatResponse {
|
|
17
|
-
message: string;
|
|
18
|
-
chatHistoryId: string;
|
|
19
|
-
}
|
|
20
5
|
export interface AgentDropdownOption {
|
|
21
6
|
label: string;
|
|
22
7
|
value: string;
|
|
23
8
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Context passed to actions from piece execution
|
|
26
|
-
*/
|
|
27
|
-
export interface ActionContext {
|
|
28
|
-
server: {
|
|
29
|
-
publicUrl: string;
|
|
30
|
-
token: string;
|
|
31
|
-
};
|
|
32
|
-
propsValue: Record<string, any>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Base parameters for all agent operations
|
|
36
|
-
*/
|
|
37
|
-
export interface BaseAgentParams {
|
|
38
|
-
serverUrl: string;
|
|
39
|
-
token: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Parameters for chat operations
|
|
43
|
-
*/
|
|
44
|
-
export interface ChatParams extends BaseAgentParams {
|
|
45
|
-
agentId: string;
|
|
46
|
-
message: string;
|
|
47
|
-
chatHistoryId?: string;
|
|
48
|
-
isTestMode?: boolean;
|
|
49
|
-
}
|
package/src/lib/types.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Type definitions for Skillful Agents piece
|
|
4
|
-
*
|
|
4
|
+
* Most types are now imported from @activepieces/server-shared SKAI SDK
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
//# sourceMappingURL=types.js.map
|
package/src/lib/constants.d.ts
DELETED
package/src/lib/constants.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Skillful Agents piece timeout constants
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SKILLFUL_AGENTS_HTTP_TIMEOUT_SAFE = exports.SKILLFUL_AGENTS_HTTP_TIMEOUT = void 0;
|
|
7
|
-
// 18 minutes for HTTP requests (2 minutes less than 20-minute flow timeout for graceful error handling)
|
|
8
|
-
exports.SKILLFUL_AGENTS_HTTP_TIMEOUT = 18 * 60 * 1000; // 1,080,000ms
|
|
9
|
-
// Alternative: 17 minutes for even safer buffer
|
|
10
|
-
exports.SKILLFUL_AGENTS_HTTP_TIMEOUT_SAFE = 17 * 60 * 1000; // 1,020,000ms
|
|
11
|
-
//# sourceMappingURL=constants.js.map
|
package/src/lib/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/custom/skillful-agents/src/lib/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,wGAAwG;AAC3F,QAAA,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,cAAc;AAEzE,gDAAgD;AACnC,QAAA,iCAAiC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,cAAc"}
|