@skillful-ai/piece-skillful-agents 0.0.3 → 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.3",
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
  }),
@@ -70,48 +63,28 @@ exports.runAgent = (0, pieces_framework_1.createAction)({
70
63
  },
71
64
  run(context) {
72
65
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
- var _a;
74
66
  const { agentId, message, testMode } = context.propsValue;
75
- const serverUrl = context.server.publicUrl;
76
- const token = context.server.token;
77
67
  if (!agentId || !message) {
78
- return {
79
- success: false,
80
- error: 'Agent ID and message are required'
81
- };
82
- }
83
- try {
84
- // Use single chat endpoint (no chatHistoryId = new chat)
85
- const response = yield common_1.skillfulAgentsCommon.chatWithAgent({
86
- serverUrl,
87
- token,
88
- agentId,
89
- message,
90
- isTestMode: testMode || false
91
- });
92
- if (response.status === 200) {
93
- const chatResponse = response.body;
94
- return {
95
- success: true,
96
- message: chatResponse.message,
97
- chatHistoryId: chatResponse.chatHistoryId,
98
- agentId: agentId,
99
- userMessage: message,
100
- testMode: testMode || false
101
- };
102
- }
103
- else {
104
- throw new Error(`Message send failed: ${response.status} ${((_a = response.body) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
105
- }
106
- }
107
- catch (error) {
108
- return {
109
- success: false,
110
- error: error instanceof Error ? error.message : 'Unknown error occurred',
111
- agentId: agentId,
112
- userMessage: message
113
- };
68
+ throw new Error('Agent ID and message are required');
114
69
  }
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,
74
+ agentId,
75
+ message,
76
+ isTestMode: testMode || false,
77
+ flowId: context.flows.current.id,
78
+ flowRunId: context.run.id
79
+ });
80
+ return {
81
+ success: true,
82
+ message: response.message,
83
+ chatHistoryId: response.chatHistoryId,
84
+ agentId: agentId,
85
+ userMessage: message,
86
+ testMode: testMode || false
87
+ };
115
88
  });
116
89
  },
117
90
  });
@@ -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,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AK,CAAC,wBAAwB,QAAQ,CAAC,MAAM,IAAI,CAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,OAAO,KAAI,eAAe,EAAE,CAAC,CAAA;gBACzG,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;oBACxE,OAAO,EAAE,OAAO;oBAChB,WAAW,EAAE,OAAO;iBACrB,CAAA;YACH,CAAC;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;;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,8CAA8C;oBAC9C,MAAM,MAAM,GAAG,MAAM,6BAAoB,CAAC,UAAU,CAAC;wBACnD,SAAS,EAAE,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EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,UAAU,CAAA;YAEzD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;YACtD,CAAC;YAED,uDAAuD;YACvD,MAAM,QAAQ,GAAG,MAAM,6BAAoB,CAAC,aAAa,CAAC;gBACxD,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS;gBACnC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;gBAC3B,OAAO;gBACP,OAAO;gBACP,UAAU,EAAE,QAAQ,IAAI,KAAK;gBAC7B,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBAChC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;aAC1B,CAAC,CAAA;YAEF,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,aAAa,EAAE,QAAQ,CAAC,aAAa;gBACrC,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,OAAO;gBACpB,QAAQ,EAAE,QAAQ,IAAI,KAAK;aAC5B,CAAA;QACH,CAAC;KAAA;CACF,CAAC,CAAA"}
@@ -1,31 +1,86 @@
1
+ import { SkaiAgentsClient } from '@skillful-ai/skai-sdk';
2
+ interface User {
3
+ id: string;
4
+ skaiApiKey?: string;
5
+ externalId?: string;
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>;
35
+ /**
36
+ * List all agents using SKAI SDK
37
+ */
38
+ listAgents(params: {
39
+ serverUrl: string;
40
+ token: string;
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
+ }[]>;
25
82
  /**
26
- * Chat with an agent (handles both new and existing conversations)
27
- * If chatHistoryId is provided, continues existing conversation
28
- * If chatHistoryId is omitted, starts new conversation
83
+ * Chat with an agent using SKAI SDK (streaming)
29
84
  */
30
85
  chatWithAgent(params: {
31
86
  serverUrl: string;
@@ -34,5 +89,11 @@ export declare const skillfulAgentsCommon: {
34
89
  message: string;
35
90
  chatHistoryId?: string;
36
91
  isTestMode?: boolean;
37
- }): Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
92
+ flowId?: string;
93
+ flowRunId?: string;
94
+ }): Promise<{
95
+ message: string;
96
+ chatHistoryId: string;
97
+ }>;
38
98
  };
99
+ export {};
package/src/lib/common.js CHANGED
@@ -3,65 +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 skai_sdk_1 = require("@skillful-ai/skai-sdk");
6
7
  /**
7
8
  * Common utilities for Skillful Agents piece
8
- * Handles communication with the SKAI Agents bridge service
9
+ * Now uses the shared SKAI SDK for better consistency
9
10
  */
10
11
  exports.skillfulAgentsCommon = {
11
12
  /**
12
- * 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
13
15
  */
14
- getBaseUrl: (serverUrl) => `${serverUrl}v1/skai-agents`,
15
- /**
16
- * List all available agents for the authenticated user
17
- */
18
- listAgents(params) {
16
+ getPieceUser(params) {
19
17
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
- 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({
21
20
  method: pieces_common_1.HttpMethod.GET,
22
- url: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}`,
21
+ url: `${params.serverUrl}v1/users/piece-user`,
23
22
  authentication: {
24
23
  type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
25
24
  token: params.token,
26
25
  },
27
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;
28
35
  });
29
36
  },
30
37
  /**
31
- * Get a specific agent by ID
38
+ * Get SKAI API URL from server configuration
32
39
  */
33
- getAgent(params) {
40
+ getSkaiApiUrl(params) {
34
41
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
- return yield pieces_common_1.httpClient.sendRequest({
42
+ const response = yield pieces_common_1.httpClient.sendRequest({
36
43
  method: pieces_common_1.HttpMethod.GET,
37
- url: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/${params.agentId}`,
44
+ url: `${params.serverUrl}v1/skai-agents/config`,
38
45
  authentication: {
39
46
  type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
40
47
  token: params.token,
41
48
  },
42
49
  });
50
+ return response.body.agentsApiUrl;
51
+ });
52
+ },
53
+ /**
54
+ * Create a SKAI API client instance with proper configuration
55
+ */
56
+ createSkaiClient(params) {
57
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
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'
63
+ });
64
+ const config = {
65
+ baseUrl,
66
+ userApiKey: params.userApiKey
67
+ };
68
+ return new skai_sdk_1.SkaiAgentsClient(skai_sdk_1.consoleLogger, config);
43
69
  });
44
70
  },
45
71
  /**
46
- * Chat with an agent (handles both new and existing conversations)
47
- * If chatHistoryId is provided, continues existing conversation
48
- * If chatHistoryId is omitted, starts new conversation
72
+ * List all agents using SKAI SDK
73
+ */
74
+ listAgents(params) {
75
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
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)
49
92
  */
50
93
  chatWithAgent(params) {
51
94
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
52
- return yield pieces_common_1.httpClient.sendRequest({
53
- method: pieces_common_1.HttpMethod.POST,
54
- url: `${exports.skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/chat`,
55
- authentication: {
56
- type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
57
- token: params.token,
58
- },
59
- body: {
60
- agentId: params.agentId,
61
- message: params.message,
62
- chatHistoryId: params.chatHistoryId,
63
- isTestMode: params.isTestMode || false
64
- },
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
65
113
  });
66
114
  });
67
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/custom/skillful-agents/src/lib/common.ts"],"names":[],"mappings":";;;;AAAA,+DAAwF;AAExF;;;GAGG;AAEU,QAAA,oBAAoB,GAAG;IAClC;;OAEG;IACH,UAAU,EAAE,CAAC,SA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AK;iBACvC;aACF,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;YAC1B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;gBAC7B,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU;gBAChC,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM;aACtF,CAAC,CAAA;YAEF,OAAO,IAAI,CAAA;QACb,CAAC;KAAA;IAED;;OAEG;IACG,aAAa,CAAC,MAA4C;;YAC9D,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAA2B;gBACtE,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,MAAM,CAAC,SA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,EAAE,CAAA;QACtC,CAAC;KAAA;IAED;;OAEG;IACG,aAAa,CAAC,MASnB;;YACC,6BAA6B;YAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;YAE5C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;YAChD,CAAC;YAED,yCAAyC;YACzC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC;gBAC7C,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,UAAU,EAAE,IAAI,CAAC,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"}
@@ -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