@skillful-ai/piece-skillful-agents 0.0.1

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/.eslintrc.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": ["../../../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
+ "rules": {}
8
+ },
9
+ {
10
+ "files": ["*.ts", "*.tsx"],
11
+ "rules": {}
12
+ },
13
+ {
14
+ "files": ["*.js", "*.jsx"],
15
+ "rules": {}
16
+ }
17
+ ]
18
+ }
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ # Skillful Agents Piece
2
+
3
+ Interact with Skillful AI agents for advanced conversational AI and task automation. This piece provides seamless integration with the SKAI Agents platform through Activepieces, allowing you to send messages to your Skillful agents directly from your workflows.
4
+
5
+ ## 🎯 Features
6
+
7
+ - **Send Messages to Agents**: Send messages to Skillful agents and receive intelligent responses
8
+ - **Agent Selection**: Choose from your available Skillful agents via dropdown
9
+ - **Test Mode**: Test agents without consuming your usage allowance
10
+ - **Server-side Authentication**: Secure API key management handled by Activepieces
11
+ - **Flow Builder Integration**: Skillful agents appear directly in the Activepieces agents view
12
+
13
+ ## 🚀 Actions
14
+
15
+ ### Send Message to Skillful Agent
16
+
17
+ The primary action for interacting with Skillful agents. Always starts a new conversation.
18
+
19
+ **Properties:**
20
+ - **Skillful Agent** (required): Select from your available Skillful agents
21
+ - **Message** (required): The message to send to the agent
22
+ - **Test Mode** (optional): Enable to avoid consuming your usage allowance
23
+
24
+ **Response:**
25
+ ```json
26
+ {
27
+ "success": true,
28
+ "message": "Agent's response text",
29
+ "chat_history_id": "conversation-id-123",
30
+ "agent_id": "agent-456",
31
+ "user_message": "Your original message",
32
+ "test_mode": false
33
+ }
34
+ ```
35
+
36
+ ## 🔧 Authentication & Setup
37
+
38
+ ### Server-Side Authentication
39
+ This piece uses **server-side authentication** - no piece-level configuration required. Your SKAI API key is securely stored and managed by the Activepieces server.
40
+
41
+ ### Setting Up SKAI API Key
42
+ 1. Obtain your SKAI API key from your Skillful account
43
+ 2. Configure it in your Activepieces user settings (stored as `skaiApiKey` in user profile)
44
+ 3. The piece automatically uses your configured API key for all requests
45
+
46
+ ### Agent Access Integration
47
+ Skillful agents are integrated directly into Activepieces:
48
+ - **Agents View**: Skillful agents appear in the flow builder's agents section
49
+ - **Unified Experience**: Same interface as internal Activepieces agents
50
+ - **Dynamic Loading**: Agent list updates automatically based on your SKAI account
51
+
52
+ ## 📖 Usage Examples
53
+
54
+ ### Basic Message Sending
55
+ 1. Add "Send Message to Skillful Agent" action to your flow
56
+ 2. Select an agent from the dropdown (populated from your SKAI account)
57
+ 3. Enter your message
58
+ 4. Run the flow to get the agent's response
59
+
60
+ ### In a Workflow Context
61
+ ```yaml
62
+ Flow Example:
63
+ 1. Trigger: New email received
64
+ 2. Action: Send Message to Skillful Agent
65
+ - Agent: "Customer Support Agent"
66
+ - Message: "Analyze this email: {{trigger.email_body}}"
67
+ 3. Action: Send response email with agent's analysis
68
+ ```
69
+
70
+ ### Testing Mode
71
+ Enable "Test Mode" to:
72
+ - Verify agent responses without consuming allowance
73
+ - Test different message formats
74
+ - Debug agent behavior during development
75
+
76
+ ## ⚠️ Error Handling
77
+
78
+ The action returns structured error information for troubleshooting:
79
+
80
+ ### Success Response
81
+ ```json
82
+ {
83
+ "success": true,
84
+ "message": "Agent response",
85
+ "chat_history_id": "abc-123",
86
+ // ... additional fields
87
+ }
88
+ ```
89
+
90
+ ### Error Response
91
+ ```json
92
+ {
93
+ "success": false,
94
+ "error": "Error description",
95
+ "agent_id": "agent-456",
96
+ "user_message": "Your message"
97
+ }
98
+ ```
99
+
100
+ ### Common Issues
101
+
102
+ | Issue | Cause | Solution |
103
+ |-------|-------|----------|
104
+ | No agents in dropdown | Missing SKAI API key | Configure API key in user settings |
105
+ | "Agent not found" error | Invalid agent selection | Verify agent is accessible to your account |
106
+ | Authentication errors | Invalid/expired API key | Update API key in user settings |
107
+ | Network timeouts | SKAI API connectivity | Check network and API status |
108
+
109
+ ## 🧪 Local Development & Testing
110
+
111
+ ### Adding to Development Environment
112
+ Add the piece to your local development:
113
+
114
+ ```bash
115
+ # 1. Add to development pieces in packages/server/api/.env
116
+ AP_DEV_PIECES="google-sheets,store,skillful-agents"
117
+
118
+ # 2. Build the piece
119
+ npx nx build pieces-skillful-agents
120
+
121
+ # 3. Start development server
122
+ npm run dev
123
+ ```
124
+
125
+ ### Database Setup (SQLite)
126
+ For local testing with SQLite, add SKAI API key to user:
127
+
128
+ ```sql
129
+ -- Update user with SKAI API key
130
+ UPDATE user SET skaiApiKey = 'your-skai-api-key-here' WHERE id = 'USER_ID';
131
+ ```
132
+
133
+ ### Testing Integration
134
+ 1. **Agents View**: Navigate to agents in flow builder - should show Skillful agents
135
+ 2. **Piece Available**: "Skillful Agents" should appear in pieces list
136
+ 3. **Agent Dropdown**: Should populate with your agents when creating flows
137
+ 4. **End-to-End**: Send test message and verify response
138
+
139
+ ## 🔗 Architecture
140
+
141
+ ### System Integration
142
+ - **Bridge Service**: `/v1/skai-agents` API endpoints handle SKAI communication
143
+ - **Agents Service**: Modified to return Skillful agents in place of internal agents
144
+ - **Piece Framework**: Standard Activepieces piece using dropdown properties
145
+ - **Authentication**: Server-side user context extraction with API key management
146
+
147
+ ### API Endpoints Used
148
+ - `GET /v1/skai-agents` - List user's agents (used by dropdown)
149
+ - `POST /v1/skai-agents/chat/new` - Send new message (used by action)
150
+
151
+ ## 📋 Technical Details
152
+
153
+ - **Package Name**: `@activepieces/piece-skillful-agents`
154
+ - **Piece Name**: `skillful-agents`
155
+ - **Category**: Universal AI
156
+ - **Minimum Release**: 0.66.0
157
+ - **Authentication**: Server-side (PieceAuth.None)
158
+
159
+ ## 🆘 Support
160
+
161
+ ### For Piece Issues
162
+ 1. Check SKAI API key is configured in user settings
163
+ 2. Verify selected agents are accessible to your account
164
+ 3. Check Activepieces server logs for detailed error messages
165
+ 4. Ensure piece is built and loaded in development environment
166
+
167
+ ### For Skillful Platform Issues
168
+ Visit [https://skillful.ai](https://skillful.ai) for Skillful Agents platform support.
169
+
170
+ ### Development Support
171
+ - Check `AP_DEV_PIECES` environment variable includes `skillful-agents`
172
+ - Verify piece builds successfully: `npx nx build pieces-skillful-agents`
173
+ - Monitor server logs during piece loading and execution
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@skillful-ai/piece-skillful-agents",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "tslib": "^2.3.0"
9
+ }
10
+ }
package/project.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "pieces-skillful-agents",
3
+ "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/pieces/custom/skillful-agents/src",
5
+ "projectType": "library",
6
+ "release": {
7
+ "version": {
8
+ "manifestRootsToUpdate": ["dist/{projectRoot}"],
9
+ "currentVersionResolver": "git-tag",
10
+ "fallbackCurrentVersionResolver": "disk"
11
+ }
12
+ },
13
+ "tags": [],
14
+ "targets": {
15
+ "build": {
16
+ "executor": "@nx/js:tsc",
17
+ "outputs": ["{options.outputPath}"],
18
+ "options": {
19
+ "outputPath": "dist/packages/pieces/custom/skillful-agents",
20
+ "tsConfig": "packages/pieces/custom/skillful-agents/tsconfig.lib.json",
21
+ "packageJson": "packages/pieces/custom/skillful-agents/package.json",
22
+ "main": "packages/pieces/custom/skillful-agents/src/index.ts",
23
+ "assets": [
24
+ "packages/pieces/custom/skillful-agents/*.md",
25
+ {
26
+ "input": "packages/pieces/custom/skillful-agents/src/i18n",
27
+ "output": "./src/i18n",
28
+ "glob": "**/!(i18n.json)"
29
+ }
30
+ ],
31
+ "buildableProjectDepsInPackageJsonType": "dependencies",
32
+ "updateBuildableProjectDepsInPackageJson": true
33
+ },
34
+ "dependsOn": ["^build"]
35
+ },
36
+ "nx-release-publish": {
37
+ "options": {
38
+ "packageRoot": "dist/{projectRoot}"
39
+ }
40
+ },
41
+ "lint": {
42
+ "executor": "@nx/eslint:lint",
43
+ "outputs": ["{options.outputFile}"]
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "List Skillful Agents": "List Skillful Agents",
3
+ "Chat with Skillful Agent": "Chat with Skillful Agent",
4
+ "Start New Chat with Agent": "Start New Chat with Agent",
5
+ "Continue Chat with Agent": "Continue Chat with Agent",
6
+ "Skillful Agent": "Skillful Agent",
7
+ "Message": "Message",
8
+ "Initial Message": "Initial Message",
9
+ "Chat History ID": "Chat History ID",
10
+ "Test Mode": "Test Mode",
11
+ "Retrieve all available Skillful agents for the authenticated user": "Retrieve all available Skillful agents for the authenticated user",
12
+ "Send a message to a Skillful agent and receive a response. Can be used for new conversations or to continue existing ones.": "Send a message to a Skillful agent and receive a response. Can be used for new conversations or to continue existing ones.",
13
+ "Start a new conversation with a Skillful agent. This will always create a new chat history.": "Start a new conversation with a Skillful agent. This will always create a new chat history.",
14
+ "Continue an existing conversation with a Skillful agent using a chat history ID.": "Continue an existing conversation with a Skillful agent using a chat history ID.",
15
+ "Select the Skillful agent to chat with": "Select the Skillful agent to chat with",
16
+ "Select the Skillful agent to start chatting with": "Select the Skillful agent to start chatting with",
17
+ "Select the Skillful agent you were chatting with": "Select the Skillful agent you were chatting with",
18
+ "The message to send to the agent": "The message to send to the agent",
19
+ "The first message to send to start the conversation": "The first message to send to start the conversation",
20
+ "The message to send in the existing conversation": "The message to send in the existing conversation",
21
+ "Optional: Provide to continue an existing conversation. Leave empty to start a new chat.": "Optional: Provide to continue an existing conversation. Leave empty to start a new chat.",
22
+ "The chat history ID from a previous conversation (obtained from \"Start Chat\" or previous \"Continue Chat\")": "The chat history ID from a previous conversation (obtained from \"Start Chat\" or previous \"Continue Chat\")",
23
+ "Enable test mode - messages won't consume your usage allowance": "Enable test mode - messages won't consume your usage allowance"
24
+ }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { createPiece, PieceAuth } from "@activepieces/pieces-framework";
2
+ import { PieceCategory } from "@activepieces/shared";
3
+ import { runAgent } from "./lib/actions/run-agent";
4
+
5
+ export const skillfulAgents = createPiece({
6
+ displayName: "Skillful Agents",
7
+ auth: PieceAuth.None(),
8
+ minimumSupportedRelease: '0.66.0',
9
+ logoUrl: "https://app.skillfulai.io/images/logo.png",
10
+ authors: ['skillful-ai'],
11
+ description: "Interact with Skillful AI agents for advanced conversational AI and task automation",
12
+ actions: [
13
+ runAgent
14
+ ],
15
+ triggers: [],
16
+ categories: [PieceCategory.UNIVERSAL_AI],
17
+ });
@@ -0,0 +1,114 @@
1
+ import { createAction, Property } from '@activepieces/pieces-framework'
2
+ import { skillfulAgentsCommon } from '../common'
3
+ import { SkillfulAgent, SkillfulChatResponse, AgentDropdownOption } from '../types'
4
+
5
+ export const runAgent = createAction({
6
+ name: 'run_agent',
7
+ displayName: 'Run Agent',
8
+ description: 'Execute a Skillful agent with a message and receive a response.',
9
+ props: {
10
+ agentId: Property.Dropdown({
11
+ displayName: 'Skillful Agent',
12
+ description: 'Select the Skillful agent to run',
13
+ required: true,
14
+ refreshers: [],
15
+ options: async (_auth, ctx) => {
16
+ if (!ctx?.server?.token) {
17
+ return {
18
+ disabled: true,
19
+ options: [],
20
+ placeholder: 'Server token required'
21
+ }
22
+ }
23
+
24
+ try {
25
+ const response = await skillfulAgentsCommon.listAgents({
26
+ serverUrl: ctx.server.publicUrl,
27
+ token: ctx.server.token
28
+ })
29
+
30
+ if (response.status === 200) {
31
+ const agents: SkillfulAgent[] = response.body
32
+ const options: AgentDropdownOption[] = agents.map((agent) => ({
33
+ label: `${agent.name}${agent.description ? ` - ${agent.description}` : ''}`,
34
+ value: agent.id
35
+ }))
36
+
37
+ return {
38
+ disabled: false,
39
+ options: options
40
+ }
41
+ } else {
42
+ return {
43
+ disabled: true,
44
+ options: [],
45
+ placeholder: `Failed to load agents: ${response.status}`
46
+ }
47
+ }
48
+ } catch (error) {
49
+ return {
50
+ disabled: true,
51
+ options: [],
52
+ placeholder: 'Error loading agents'
53
+ }
54
+ }
55
+ },
56
+ }),
57
+ message: Property.LongText({
58
+ displayName: 'Message',
59
+ description: 'The input message or prompt for the agent',
60
+ required: true,
61
+ }),
62
+ testMode: Property.Checkbox({
63
+ displayName: 'Test Mode',
64
+ description: 'Enable test mode - agent execution won\'t consume your usage allowance',
65
+ required: false,
66
+ defaultValue: false,
67
+ }),
68
+ },
69
+ async run(context) {
70
+ const { agentId, message, testMode } = context.propsValue
71
+ const serverUrl = context.server.publicUrl
72
+ const token = context.server.token
73
+
74
+ if (!agentId || !message) {
75
+ return {
76
+ success: false,
77
+ error: 'Agent ID and message are required'
78
+ }
79
+ }
80
+
81
+ try {
82
+ // Use single chat endpoint (no chatHistoryId = new chat)
83
+ const response = await skillfulAgentsCommon.chatWithAgent({
84
+ serverUrl,
85
+ token,
86
+ agentId,
87
+ message,
88
+ isTestMode: testMode || false
89
+ })
90
+
91
+ if (response.status === 200) {
92
+ const chatResponse: SkillfulChatResponse = response.body
93
+
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
+ } else {
103
+ throw new Error(`Message send failed: ${response.status} ${response.body?.message || 'Unknown error'}`)
104
+ }
105
+ } catch (error) {
106
+ return {
107
+ success: false,
108
+ error: error instanceof Error ? error.message : 'Unknown error occurred',
109
+ agentId: agentId,
110
+ userMessage: message
111
+ }
112
+ }
113
+ },
114
+ })
@@ -0,0 +1,70 @@
1
+ import { httpClient, HttpMethod, AuthenticationType } from '@activepieces/pieces-common'
2
+
3
+ /**
4
+ * Common utilities for Skillful Agents piece
5
+ * Handles communication with the SKAI Agents bridge service
6
+ */
7
+
8
+ export const skillfulAgentsCommon = {
9
+ /**
10
+ * Base URL for SKAI agents bridge service endpoints
11
+ */
12
+ getBaseUrl: (serverUrl: string) => `${serverUrl}v1/skai-agents`,
13
+
14
+ /**
15
+ * List all available agents for the authenticated user
16
+ */
17
+ async listAgents(params: { serverUrl: string, token: string }) {
18
+ return await httpClient.sendRequest({
19
+ method: HttpMethod.GET,
20
+ url: `${skillfulAgentsCommon.getBaseUrl(params.serverUrl)}`,
21
+ authentication: {
22
+ type: AuthenticationType.BEARER_TOKEN,
23
+ token: params.token,
24
+ },
25
+ })
26
+ },
27
+
28
+ /**
29
+ * Get a specific agent by ID
30
+ */
31
+ async getAgent(params: { serverUrl: string, token: string, agentId: string }) {
32
+ return await httpClient.sendRequest({
33
+ method: HttpMethod.GET,
34
+ url: `${skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/${params.agentId}`,
35
+ authentication: {
36
+ type: AuthenticationType.BEARER_TOKEN,
37
+ token: params.token,
38
+ },
39
+ })
40
+ },
41
+
42
+ /**
43
+ * Chat with an agent (handles both new and existing conversations)
44
+ * If chatHistoryId is provided, continues existing conversation
45
+ * If chatHistoryId is omitted, starts new conversation
46
+ */
47
+ async chatWithAgent(params: {
48
+ serverUrl: string,
49
+ token: string,
50
+ agentId: string,
51
+ message: string,
52
+ chatHistoryId?: string,
53
+ isTestMode?: boolean
54
+ }) {
55
+ return await httpClient.sendRequest({
56
+ method: HttpMethod.POST,
57
+ url: `${skillfulAgentsCommon.getBaseUrl(params.serverUrl)}/chat`,
58
+ authentication: {
59
+ type: AuthenticationType.BEARER_TOKEN,
60
+ token: params.token,
61
+ },
62
+ body: {
63
+ agentId: params.agentId,
64
+ message: params.message,
65
+ chatHistoryId: params.chatHistoryId,
66
+ isTestMode: params.isTestMode || false
67
+ },
68
+ })
69
+ }
70
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Type definitions for Skillful Agents piece
3
+ * These types match the SKAI API response formats
4
+ */
5
+
6
+ export interface SkillfulAgent {
7
+ id: string
8
+ name: string
9
+ description: string
10
+ logoUrl: string
11
+ isDraft?: boolean
12
+ isMinted?: boolean
13
+ type: string
14
+ ownerUserId?: string
15
+ config?: any
16
+ }
17
+
18
+ export interface SkillfulChatResponse {
19
+ message: string
20
+ chatHistoryId: string
21
+ }
22
+
23
+ export interface AgentDropdownOption {
24
+ label: string
25
+ value: string
26
+ }
27
+
28
+ /**
29
+ * Context passed to actions from piece execution
30
+ */
31
+ export interface ActionContext {
32
+ server: {
33
+ publicUrl: string
34
+ token: string
35
+ }
36
+ propsValue: Record<string, any>
37
+ }
38
+
39
+ /**
40
+ * Base parameters for all agent operations
41
+ */
42
+ export interface BaseAgentParams {
43
+ serverUrl: string
44
+ token: string
45
+ }
46
+
47
+ /**
48
+ * Parameters for chat operations
49
+ */
50
+ export interface ChatParams extends BaseAgentParams {
51
+ agentId: string
52
+ message: string
53
+ chatHistoryId?: string
54
+ isTestMode?: boolean
55
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "../../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "forceConsistentCasingInFileNames": true,
6
+ "strict": true,
7
+ "importHelpers": true,
8
+ "noImplicitOverride": true,
9
+ "noImplicitReturns": true,
10
+ "noFallthroughCasesInSwitch": true,
11
+ "noPropertyAccessFromIndexSignature": true
12
+ },
13
+ "files": [],
14
+ "include": [],
15
+ "references": [
16
+ {
17
+ "path": "./tsconfig.lib.json"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"]
7
+ },
8
+ "include": ["src/**/*.ts"]
9
+ }