@skillful-ai/piece-skillful-agents 0.0.4 → 0.0.6

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 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**: `@activepieces/piece-skillful-agents`
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.4",
3
+ "version": "0.0.6",
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": "*",
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
- const response = yield common_1.skillfulAgentsCommon.listAgents({
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
- if (response.status === 200) {
32
- const agents = response.body;
33
- const options = agents.map((agent) => ({
34
- label: `${agent.name}${agent.description ? ` - ${agent.description}` : ''}`,
35
- value: agent.id
36
- }));
37
- return {
38
- disabled: false,
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 streaming to avoid API gateway timeouts
80
- // httpClient will throw automatically for non-200 responses
81
- const response = yield common_1.skillfulAgentsCommon.chatWithAgentStream({
82
- serverUrl,
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: chatResponse.message,
92
- chatHistoryId: chatResponse.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,QAAQ,GAAG,MAAM,6BAAoB,CAAC,UAAU,CAAC;wBACrD,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS;wBAC/B,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK;qBACxB,C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UAAU,CAAA;YACzD,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAA;YAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAA;YAElC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;YACtD,CAAC;YAED,8CAA8C;YAC9C,4DAA4D;YAC5D,MAAM,QAAQ,GAAG,MAAM,6BAAoB,CAAC,mBAAmB,CAAC;gBAC9D,SAAS;gBACT,KAAK;gBACL,OAAO;gBACP,OAAO;gBACP,UAAU,EAAE,QAAQ,IAAI,KAAK;aAC9B,CAAC,CAAA;YAEF,MAAM,YAAY,GAAyB,QAAQ,CAAC,IAAI,CAAA;YAExD,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,aAAa,EAAE,YAAY,CAAC,aAAa;gBACzC,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,OAAO;gBACpB,QAAQ,EAAE,QAAQ,IAAI,KAAK;aAC5B,CAAA;QACH,CAAC;KAAA;CACF,CAAC,CAAA"}
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;;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
6
+ }
1
7
  /**
2
8
  * Common utilities for Skillful Agents piece
3
- * Handles communication with the SKAI Agents bridge service
9
+ * Now uses the shared SKAI SDK for better consistency
4
10
  */
5
11
  export declare const skillfulAgentsCommon: {
6
12
  /**
7
- * Base URL for SKAI agents bridge service endpoints
13
+ * Get the piece user (user) with their credentials
14
+ * This is used to get the skaiApiKey for SKAI SDK usage
8
15
  */
9
- getBaseUrl: (serverUrl: string) => string;
16
+ getPieceUser(params: {
17
+ serverUrl: string;
18
+ token: string;
19
+ }): Promise<User>;
10
20
  /**
11
- * List all available agents for the authenticated user
21
+ * Get SKAI API URL from server configuration
12
22
  */
13
- listAgents(params: {
23
+ getSkaiApiUrl(params: {
14
24
  serverUrl: string;
15
25
  token: string;
16
- }): Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
26
+ }): Promise<string>;
17
27
  /**
18
- * Get a specific agent by ID
28
+ * Create a SKAI API client instance with proper configuration
19
29
  */
20
- getAgent(params: {
30
+ createSkaiClient(params: {
21
31
  serverUrl: string;
22
32
  token: string;
23
- agentId: string;
24
- }): Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
33
+ userApiKey: string;
34
+ }): Promise<SkaiAgentsClient>;
25
35
  /**
26
- * Chat with an agent (non-streaming - handles both new and existing conversations)
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
- chatWithAgent(params: {
38
+ listAgents(params: {
31
39
  serverUrl: string;
32
40
  token: string;
33
- agentId: string;
34
- message: string;
35
- chatHistoryId?: string;
36
- isTestMode?: boolean;
37
- }): Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
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 streaming (avoids API gateway timeouts)
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
- chatWithAgentStream(params: {
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
- }): Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
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 constants_1 = require("./constants");
6
+ const skai_sdk_1 = require("@skillful-ai/skai-sdk");
7
7
  /**
8
8
  * Common utilities for Skillful Agents piece
9
- * Handles communication with the SKAI Agents bridge service
9
+ * Now uses the shared SKAI SDK for better consistency
10
10
  */
11
11
  exports.skillfulAgentsCommon = {
12
12
  /**
13
- * Base URL for SKAI agents bridge service endpoints
13
+ * Get the piece user (user) with their credentials
14
+ * This is used to get the skaiApiKey for SKAI SDK usage
14
15
  */
15
- getBaseUrl: (serverUrl) => `${serverUrl}v1/skai-agents`,
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
- return yield pieces_common_1.httpClient.sendRequest({
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: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}`,
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 a specific agent by ID
38
+ * Get SKAI API URL from server configuration
33
39
  */
34
- getAgent(params) {
40
+ getSkaiApiUrl(params) {
35
41
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
- return yield pieces_common_1.httpClient.sendRequest({
42
+ const response = yield pieces_common_1.httpClient.sendRequest({
37
43
  method: pieces_common_1.HttpMethod.GET,
38
- url: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/${params.agentId}`,
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
- * Chat with an agent (non-streaming - handles both new and existing conversations)
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
- chatWithAgent(params) {
56
+ createSkaiClient(params) {
52
57
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
- return yield pieces_common_1.httpClient.sendRequest({
54
- method: pieces_common_1.HttpMethod.POST,
55
- url: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/chat`,
56
- authentication: {
57
- type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
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
- * Chat with an agent using streaming (avoids API gateway timeouts)
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
- chatWithAgentStream(params) {
74
+ listAgents(params) {
76
75
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
77
- return yield pieces_common_1.httpClient.sendRequest({
78
- method: pieces_common_1.HttpMethod.POST,
79
- url: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/chat/stream`,
80
- authentication: {
81
- type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
82
- token: params.token,
83
- },
84
- body: {
85
- agentId: params.agentId,
86
- message: params.message,
87
- chatHistoryId: params.chatHistoryId,
88
- isTestMode: params.isTestMode || false
89
- },
90
- timeout: constants_1.SKILLFUL_AGENTS_HTTP_TIMEOUT, // 18 minutes (2 minutes less than 20-minute flow timeout)
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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/custom/skillful-agents/src/lib/common.ts"],"names":[],"mappings":";;;;AAAA,+DAAwF;AACxF,2CAA0D;AAE1D;;;GAGG;AAEU,QAAA,oBAAoB,GAAG;IAClC;;OAEG;IACH,UAAU,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,GAAG,SAAS,gBAAgB;IAE/D;;OA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ClG,CAAC,CAAA;QACJ,CAAC;KAAA;IAED;;;;OAIG;IACG,mBAAmB,CAAC,MAOzB;;YACC,OAAO,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAClC,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,4BAAoB,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc;gBACvE,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB;gBACD,IAAI,EAAE;oBACJ,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,aAAa,EAAE,MAAM,CAAC,aAAa;oBACnC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;iBACvC;gBACD,OAAO,EAAE,wCAA4B,EAAE,0DAA0D;aAClG,CAAC,CAAA;QACJ,CAAC;KAAA;CACF,CAAA"}
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,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,qBAAqB;gBAC7C,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB;aACF,CAAC,CAAA;YAEF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAA;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BACtC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAA;QACJ,CAAC;KAAA;CACF,CAAA"}
@@ -1,49 +1,8 @@
1
1
  /**
2
2
  * Type definitions for Skillful Agents piece
3
- * These types match the SKAI API response formats
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
- * These types match the SKAI API response formats
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
@@ -1,5 +0,0 @@
1
- /**
2
- * Skillful Agents piece timeout constants
3
- */
4
- export declare const SKILLFUL_AGENTS_HTTP_TIMEOUT: number;
5
- export declare const SKILLFUL_AGENTS_HTTP_TIMEOUT_SAFE: number;
@@ -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
@@ -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"}