n8n-nodes-opencode-ai 0.1.0

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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/assets/opencode.svg +6 -0
  4. package/dist/credentials/OpenCodeApi.credentials.d.ts +8 -0
  5. package/dist/credentials/OpenCodeApi.credentials.js +50 -0
  6. package/dist/credentials/OpenCodeApi.credentials.js.map +1 -0
  7. package/dist/nodes/OpenCode/OpenCode.node.d.ts +13 -0
  8. package/dist/nodes/OpenCode/OpenCode.node.js +787 -0
  9. package/dist/nodes/OpenCode/OpenCode.node.js.map +1 -0
  10. package/dist/nodes/OpenCode/actions/config/getProviders.d.ts +2 -0
  11. package/dist/nodes/OpenCode/actions/config/getProviders.js +19 -0
  12. package/dist/nodes/OpenCode/actions/config/getProviders.js.map +1 -0
  13. package/dist/nodes/OpenCode/actions/config/index.d.ts +4 -0
  14. package/dist/nodes/OpenCode/actions/config/index.js +15 -0
  15. package/dist/nodes/OpenCode/actions/config/index.js.map +1 -0
  16. package/dist/nodes/OpenCode/actions/index.d.ts +5 -0
  17. package/dist/nodes/OpenCode/actions/index.js +26 -0
  18. package/dist/nodes/OpenCode/actions/index.js.map +1 -0
  19. package/dist/nodes/OpenCode/actions/message/command.d.ts +2 -0
  20. package/dist/nodes/OpenCode/actions/message/command.js +102 -0
  21. package/dist/nodes/OpenCode/actions/message/command.js.map +1 -0
  22. package/dist/nodes/OpenCode/actions/message/getMessage.d.ts +2 -0
  23. package/dist/nodes/OpenCode/actions/message/getMessage.js +21 -0
  24. package/dist/nodes/OpenCode/actions/message/getMessage.js.map +1 -0
  25. package/dist/nodes/OpenCode/actions/message/index.d.ts +9 -0
  26. package/dist/nodes/OpenCode/actions/message/index.js +35 -0
  27. package/dist/nodes/OpenCode/actions/message/index.js.map +1 -0
  28. package/dist/nodes/OpenCode/actions/message/list.d.ts +2 -0
  29. package/dist/nodes/OpenCode/actions/message/list.js +37 -0
  30. package/dist/nodes/OpenCode/actions/message/list.js.map +1 -0
  31. package/dist/nodes/OpenCode/actions/message/send.d.ts +2 -0
  32. package/dist/nodes/OpenCode/actions/message/send.js +124 -0
  33. package/dist/nodes/OpenCode/actions/message/send.js.map +1 -0
  34. package/dist/nodes/OpenCode/actions/message/sendAsync.d.ts +2 -0
  35. package/dist/nodes/OpenCode/actions/message/sendAsync.js +88 -0
  36. package/dist/nodes/OpenCode/actions/message/sendAsync.js.map +1 -0
  37. package/dist/nodes/OpenCode/actions/message/shell.d.ts +2 -0
  38. package/dist/nodes/OpenCode/actions/message/shell.js +102 -0
  39. package/dist/nodes/OpenCode/actions/message/shell.js.map +1 -0
  40. package/dist/nodes/OpenCode/actions/session/abort.d.ts +2 -0
  41. package/dist/nodes/OpenCode/actions/session/abort.js +24 -0
  42. package/dist/nodes/OpenCode/actions/session/abort.js.map +1 -0
  43. package/dist/nodes/OpenCode/actions/session/create.d.ts +2 -0
  44. package/dist/nodes/OpenCode/actions/session/create.js +21 -0
  45. package/dist/nodes/OpenCode/actions/session/create.js.map +1 -0
  46. package/dist/nodes/OpenCode/actions/session/delete.d.ts +2 -0
  47. package/dist/nodes/OpenCode/actions/session/delete.js +24 -0
  48. package/dist/nodes/OpenCode/actions/session/delete.js.map +1 -0
  49. package/dist/nodes/OpenCode/actions/session/get.d.ts +2 -0
  50. package/dist/nodes/OpenCode/actions/session/get.js +20 -0
  51. package/dist/nodes/OpenCode/actions/session/get.js.map +1 -0
  52. package/dist/nodes/OpenCode/actions/session/index.d.ts +9 -0
  53. package/dist/nodes/OpenCode/actions/session/index.js +35 -0
  54. package/dist/nodes/OpenCode/actions/session/index.js.map +1 -0
  55. package/dist/nodes/OpenCode/actions/session/list.d.ts +2 -0
  56. package/dist/nodes/OpenCode/actions/session/list.js +18 -0
  57. package/dist/nodes/OpenCode/actions/session/list.js.map +1 -0
  58. package/dist/nodes/OpenCode/actions/session/status.d.ts +2 -0
  59. package/dist/nodes/OpenCode/actions/session/status.js +19 -0
  60. package/dist/nodes/OpenCode/actions/session/status.js.map +1 -0
  61. package/dist/nodes/OpenCode/helpers/api.d.ts +13 -0
  62. package/dist/nodes/OpenCode/helpers/api.js +62 -0
  63. package/dist/nodes/OpenCode/helpers/api.js.map +1 -0
  64. package/dist/nodes/OpenCode/opencode.svg +6 -0
  65. package/dist/nodes/OpenCode/types/index.d.ts +100 -0
  66. package/dist/nodes/OpenCode/types/index.js +3 -0
  67. package/dist/nodes/OpenCode/types/index.js.map +1 -0
  68. package/dist/nodes/OpenCodeChatModel/ChatOpenCode.d.ts +57 -0
  69. package/dist/nodes/OpenCodeChatModel/ChatOpenCode.js +270 -0
  70. package/dist/nodes/OpenCodeChatModel/ChatOpenCode.js.map +1 -0
  71. package/dist/nodes/OpenCodeChatModel/OpenCodeChatModel.node.d.ts +11 -0
  72. package/dist/nodes/OpenCodeChatModel/OpenCodeChatModel.node.js +217 -0
  73. package/dist/nodes/OpenCodeChatModel/OpenCodeChatModel.node.js.map +1 -0
  74. package/dist/nodes/OpenCodeChatModel/opencode.svg +6 -0
  75. package/dist/nodes/OpenCodeTool/OpenCodeTool.node.d.ts +11 -0
  76. package/dist/nodes/OpenCodeTool/OpenCodeTool.node.js +319 -0
  77. package/dist/nodes/OpenCodeTool/OpenCodeTool.node.js.map +1 -0
  78. package/dist/nodes/OpenCodeTool/opencode.svg +6 -0
  79. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dante Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # n8n-nodes-opencode-ai
2
+
3
+ [![npm version](https://badge.fury.io/js/n8n-nodes-opencode-ai.svg)](https://www.npmjs.com/package/n8n-nodes-opencode-ai)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ This is an n8n community node package that provides integration with [OpenCode](https://opencode.ai/) AI Server API.
7
+
8
+ [OpenCode](https://github.com/opencode-ai/opencode) is a powerful terminal-based AI coding assistant. This node enables you to interact with OpenCode Server from your n8n workflows.
9
+
10
+ ## Features
11
+
12
+ - **Session Management**: Create, list, get, delete, and abort OpenCode sessions
13
+ - **Message Operations**: Send messages (sync/async), execute commands, run shell commands
14
+ - **AI Agent Integration**: LangChain-compatible Tool and ChatModel nodes for n8n AI agents
15
+ - **Dynamic Configuration**: Auto-load available models, agents, and commands from server
16
+
17
+ ## Prerequisites
18
+
19
+ > **⚠️ Important**: This package requires a running OpenCode Server instance. The node connects to OpenCode Server via REST API, so you must have the server running before using this node.
20
+
21
+ ### Installing OpenCode
22
+
23
+ ```bash
24
+ # Install OpenCode CLI
25
+ curl -fsSL https://opencode.ai/install | bash
26
+ ```
27
+
28
+ For other installation methods (npm, Homebrew, Scoop, etc.), see the [OpenCode Installation Guide](https://opencode.ai/docs/installation/).
29
+
30
+ ### Oh My OpenCode (Optional, Recommended)
31
+
32
+ [Oh My OpenCode](https://ohmyopencode.com/) is a powerful plugin that enhances OpenCode with specialized agents like **Sisyphus** (Claude Opus 4.5 with extended thinking) and parallel background task execution.
33
+
34
+ ```bash
35
+ # Install via bunx
36
+ bunx oh-my-opencode install
37
+
38
+ # Or via npm
39
+ npm install -g oh-my-opencode
40
+ ```
41
+
42
+ For more details, visit [Oh My OpenCode GitHub](https://github.com/code-yeongyu/oh-my-opencode).
43
+
44
+ ### Starting OpenCode Server
45
+
46
+ ```bash
47
+ # Set authentication credentials via environment variables
48
+ OPENCODE_SERVER_USERNAME=your_username OPENCODE_SERVER_PASSWORD=your_password opencode serve --port 4096
49
+ ```
50
+
51
+ You can change the port number as needed. The credentials you set here will be used in the n8n credential configuration.
52
+
53
+ ### Security Considerations
54
+
55
+ > **🔒 Security Warning**: The example above is for development/testing purposes only.
56
+
57
+ For production deployments:
58
+
59
+ - **Never hardcode credentials** in scripts or command lines
60
+ - Use secure environment variable management (e.g., `.env` files with proper permissions, secrets managers)
61
+ - Deploy behind a **reverse proxy** (nginx, Caddy) with HTTPS/TLS encryption
62
+ - Implement **network-level security** (firewall rules, VPN, private networks)
63
+ - Use **strong passwords** and consider rotating credentials regularly
64
+ - Monitor access logs and set up alerts for suspicious activity
65
+
66
+ Example production setup with environment file:
67
+
68
+ ```bash
69
+ # .env file (chmod 600)
70
+ OPENCODE_SERVER_USERNAME=secure_username
71
+ OPENCODE_SERVER_PASSWORD=strong_random_password
72
+
73
+ # Start server
74
+ source .env && opencode serve --port 4096
75
+ ```
76
+
77
+ ## Installation
78
+
79
+ ### Community Nodes (Recommended)
80
+
81
+ 1. Go to **Settings > Community Nodes** in your n8n instance
82
+ 2. Click **Install**
83
+ 3. Enter `n8n-nodes-opencode-ai` and click **Install**
84
+
85
+ ### Manual Installation
86
+
87
+ ```bash
88
+ npm install n8n-nodes-opencode-ai
89
+ ```
90
+
91
+ ## Nodes
92
+
93
+ | Node | Description |
94
+ |------|-------------|
95
+ | **OpenCode** | Main node for session and message operations |
96
+ | **OpenCode Tool** | LangChain tool for AI agent workflows |
97
+ | **OpenCode Chat Model** | LangChain chat model for AI agent workflows |
98
+
99
+ ## Credentials
100
+
101
+ This node uses Basic Authentication to connect to OpenCode Server.
102
+
103
+ | Field | Description | Default |
104
+ |-------|-------------|---------|
105
+ | Base URL | OpenCode Server URL | `http://127.0.0.1:4096` |
106
+ | Username | Basic Auth username | - |
107
+ | Password | Basic Auth password | - |
108
+
109
+ ## Operations
110
+
111
+ ### Session Resource
112
+ - **List**: Get all sessions
113
+ - **Get**: Get a specific session
114
+ - **Create**: Create a new session
115
+ - **Delete**: Delete a session
116
+ - **Abort**: Abort a running session
117
+ - **Status**: Get status of all sessions
118
+
119
+ ### Message Resource
120
+ - **Send**: Send a message and wait for response
121
+ - **Send Async**: Send a message without waiting
122
+ - **Execute Command**: Run a slash command (e.g., /help)
123
+ - **Run Shell**: Execute a shell command
124
+ - **List**: Get all messages in a session
125
+ - **Get**: Get a specific message by ID
126
+
127
+ ### Config Resource
128
+ - **Get Providers**: List available AI providers and models
129
+
130
+ ## Usage Examples
131
+
132
+ ### Basic Message Send
133
+
134
+ 1. Add the **OpenCode** node to your workflow
135
+ 2. Select **Message** resource and **Send** operation
136
+ 3. Choose or create a session
137
+ 4. Enter your message
138
+ 5. Execute to get AI response
139
+
140
+ ### Using with AI Agent
141
+
142
+ 1. Add **OpenCode Chat Model** node as the model
143
+ 2. Add **OpenCode Tool** node as a tool
144
+ 3. Connect to an AI Agent node
145
+ 4. The agent can now use OpenCode for coding tasks
146
+
147
+ ### Temporary Session Mode
148
+
149
+ Enable **Temporary Session** mode to automatically create and delete sessions per request - useful for stateless operations.
150
+
151
+ ## Requirements
152
+
153
+ - **OpenCode Server** running and accessible (see [Prerequisites](#prerequisites))
154
+ - n8n version 1.0.0 or later
155
+ - Node.js 18.0.0 or later
156
+
157
+ ## Related Links
158
+
159
+ - [OpenCode Official Site](https://opencode.ai/)
160
+ - [OpenCode GitHub Repository](https://github.com/opencode-ai/opencode)
161
+ - [OpenCode Installation Guide](https://opencode.ai/docs/installation/)
162
+ - [OpenCode Server Documentation](https://opencode.ai/docs/server/)
163
+ - [Oh My OpenCode](https://ohmyopencode.com/) - Recommended plugin with specialized agents
164
+ - [Oh My OpenCode GitHub](https://github.com/code-yeongyu/oh-my-opencode)
165
+ - [n8n Community Nodes Documentation](https://docs.n8n.io/integrations/community-nodes/)
166
+
167
+ ## License
168
+
169
+ This project is licensed under the [MIT License](LICENSE).
170
+
171
+ This is an independent community node and is not officially affiliated with or endorsed by OpenCode. [OpenCode](https://github.com/opencode-ai/opencode) is also licensed under the MIT License.
172
+
173
+ ---
174
+
175
+ ## Dante Labs
176
+
177
+ **Developed and maintained by Dante Labs**
178
+
179
+ - **Homepage**: [dante-datalab.com](https://dante-datalab.com)
180
+ - **YouTube**: [@dante-labs](https://youtube.com/@dante-labs)
181
+ - **Discord**: [Dante Labs Community](https://discord.com/invite/rXyy5e9ujs)
182
+ - **Email**: datapod.k@gmail.com
183
+
184
+ ### Support
185
+
186
+ If you find this project helpful, consider supporting the development!
187
+
188
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow?style=for-the-badge&logo=buy-me-a-coffee)](https://buymeacoffee.com/dante.labs)
189
+
190
+ **☕ Buy Me a Coffee**: https://buymeacoffee.com/dante.labs
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" fill="none">
2
+ <rect width="60" height="60" rx="8" fill="#1a1a2e"/>
3
+ <path d="M20 22L12 30L20 38" stroke="#00d9ff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M40 22L48 30L40 38" stroke="#00d9ff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M35 16L25 44" stroke="#ff6b6b" stroke-width="3" stroke-linecap="round"/>
6
+ </svg>
@@ -0,0 +1,8 @@
1
+ import { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class OpenCodeApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ test: ICredentialTestRequest;
8
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenCodeApi = void 0;
4
+ class OpenCodeApi {
5
+ constructor() {
6
+ this.name = 'openCodeApi';
7
+ this.displayName = 'OpenCode API';
8
+ this.documentationUrl = 'https://opencode.ai/docs/server/';
9
+ this.properties = [
10
+ {
11
+ displayName: 'Base URL',
12
+ name: 'baseUrl',
13
+ type: 'string',
14
+ default: 'http://127.0.0.1:4096',
15
+ required: true,
16
+ description: 'The base URL of the OpenCode server (e.g., http://127.0.0.1:4096)',
17
+ },
18
+ {
19
+ displayName: 'Username',
20
+ name: 'username',
21
+ type: 'string',
22
+ default: '',
23
+ required: true,
24
+ description: 'Username for Basic Auth (OPENCODE_SERVER_USERNAME)',
25
+ },
26
+ {
27
+ displayName: 'Password',
28
+ name: 'password',
29
+ type: 'string',
30
+ typeOptions: { password: true },
31
+ default: '',
32
+ required: true,
33
+ description: 'Password for Basic Auth (OPENCODE_SERVER_PASSWORD)',
34
+ },
35
+ ];
36
+ this.test = {
37
+ request: {
38
+ baseURL: '={{$credentials.baseUrl}}',
39
+ url: '/session',
40
+ method: 'GET',
41
+ auth: {
42
+ username: '={{$credentials.username}}',
43
+ password: '={{$credentials.password}}',
44
+ },
45
+ },
46
+ };
47
+ }
48
+ }
49
+ exports.OpenCodeApi = OpenCodeApi;
50
+ //# sourceMappingURL=OpenCodeApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenCodeApi.credentials.js","sourceRoot":"","sources":["../../src/credentials/OpenCodeApi.credentials.ts"],"names":[],"mappings":";;;AAMA,MAAa,WAAW;IAAxB;QACC,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,cAAc,CAAC;QAC7B,qBAAgB,GAAG,kCAAkC,CAAC;QAEtD,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,mEAAmE;aAChF;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,oDAAoD;aACjE;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,oDAAoD;aACjE;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,UAAU;gBACf,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE;oBACL,QAAQ,EAAE,4BAA4B;oBACtC,QAAQ,EAAE,4BAA4B;iBACtC;aACD;SACD,CAAC;IACH,CAAC;CAAA;AA5CD,kCA4CC"}
@@ -0,0 +1,13 @@
1
+ import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class OpenCode implements INodeType {
3
+ description: INodeTypeDescription;
4
+ methods: {
5
+ loadOptions: {
6
+ getSessions(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ getModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
8
+ getAgents(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
9
+ getCommands(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
10
+ };
11
+ };
12
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
13
+ }