@jamesmurdza/opencode-daytona 0.1.2 → 0.1.3

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/dist/src/index.js DELETED
@@ -1,411 +0,0 @@
1
- "use strict";
2
- /**
3
- * OpenCode Plugin: Daytona Sandbox Integration
4
- *
5
- * OpenCode plugins extend the AI coding assistant by adding custom tools, handling events,
6
- * and modifying behavior. Plugins are TypeScript/JavaScript modules that export functions
7
- * which return hooks for various lifecycle events.
8
- *
9
- * This plugin integrates Daytona sandboxes with OpenCode, providing isolated development
10
- * environments for each session. It adds custom tools for file operations, command execution,
11
- * and search within sandboxes, and automatically cleans up resources when sessions end.
12
- *
13
- * Learn more: https://opencode.ai/docs/plugins/
14
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.SystemTransformPlugin = exports.DaytonaSessionCleanupPlugin = exports.CustomToolsPlugin = void 0;
17
- const plugin_1 = require("@opencode-ai/plugin");
18
- const fs_1 = require("fs");
19
- const path_1 = require("path");
20
- const sdk_1 = require("@daytonaio/sdk");
21
- // OpenCode constants:
22
- const EVENT_TYPE_SESSION_DELETED = 'session.deleted';
23
- // Daytona plugin constants:
24
- const LOG_LEVEL_INFO = 'INFO';
25
- const LOG_LEVEL_ERROR = 'ERROR';
26
- const LOG_LEVEL_WARN = 'WARN';
27
- /**
28
- * Daytona Sandbox Integration Tools
29
- *
30
- * Requires:
31
- * - npm install @daytonaio/sdk
32
- * - Environment: DAYTONA_API_KEY
33
- */
34
- /**
35
- * Logger class for handling plugin logging
36
- */
37
- class Logger {
38
- logFile;
39
- constructor(logFile) {
40
- this.logFile = logFile;
41
- }
42
- log(message, level = LOG_LEVEL_INFO) {
43
- const timestamp = new Date().toISOString();
44
- const logEntry = `[${timestamp}] [${level}] ${message}\n`;
45
- (0, fs_1.appendFileSync)(this.logFile, logEntry);
46
- }
47
- info(message) {
48
- this.log(message, LOG_LEVEL_INFO);
49
- }
50
- error(message) {
51
- this.log(message, LOG_LEVEL_ERROR);
52
- }
53
- warn(message) {
54
- this.log(message, LOG_LEVEL_WARN);
55
- }
56
- }
57
- /**
58
- * Manages Daytona sandbox sessions and persists session-sandbox mappings
59
- */
60
- class DaytonaSessionManager {
61
- apiKey;
62
- sessionMapFile;
63
- logger;
64
- sessionSandboxes;
65
- // Initialize with API key, session map file path, and logger
66
- constructor(apiKey, sessionMapFile, logger) {
67
- this.apiKey = apiKey;
68
- this.sessionMapFile = sessionMapFile;
69
- this.logger = logger;
70
- this.sessionSandboxes = this.loadSessionMap();
71
- }
72
- // Load session map from file
73
- loadSessionMap() {
74
- const map = new Map();
75
- try {
76
- if ((0, fs_1.existsSync)(this.sessionMapFile)) {
77
- const data = JSON.parse((0, fs_1.readFileSync)(this.sessionMapFile, 'utf-8'));
78
- for (const [sessionId, sandboxInfo] of Object.entries(data)) {
79
- map.set(sessionId, sandboxInfo);
80
- }
81
- }
82
- }
83
- catch (err) {
84
- this.logger.error(`Failed to load session map: ${err}`);
85
- }
86
- return map;
87
- }
88
- // Save session map to file
89
- saveSessionMap() {
90
- try {
91
- const data = {};
92
- for (const [sessionId, sandbox] of this.sessionSandboxes.entries()) {
93
- data[sessionId] = { id: sandbox.id };
94
- }
95
- (0, fs_1.writeFileSync)(this.sessionMapFile, JSON.stringify(data, null, 2));
96
- }
97
- catch (err) {
98
- this.logger.error(`Failed to save session map: ${err}`);
99
- }
100
- }
101
- // Get or create a sandbox for the given session ID
102
- async getSandbox(sessionId) {
103
- if (!this.apiKey) {
104
- this.logger.error('DAYTONA_API_KEY is not set. Cannot create or retrieve sandbox.');
105
- throw new Error('DAYTONA_API_KEY is not set. Please set the environment variable to use Daytona sandboxes.');
106
- }
107
- if (!this.sessionSandboxes.has(sessionId)) {
108
- this.logger.info(`Creating new sandbox for session: ${sessionId}`);
109
- const daytona = new sdk_1.Daytona({ apiKey: this.apiKey });
110
- const sandbox = await daytona.create();
111
- this.sessionSandboxes.set(sessionId, sandbox);
112
- this.saveSessionMap();
113
- this.logger.info(`Sandbox created successfully.`);
114
- }
115
- else {
116
- const sandboxInfo = this.sessionSandboxes.get(sessionId);
117
- if (sandboxInfo && !('process' in sandboxInfo)) {
118
- const daytona = new sdk_1.Daytona({ apiKey: this.apiKey });
119
- const sandbox = await daytona.create();
120
- this.sessionSandboxes.set(sessionId, sandbox);
121
- this.saveSessionMap();
122
- }
123
- else {
124
- this.logger.info(`Reusing existing sandbox for session: ${sessionId}`);
125
- }
126
- }
127
- const sandbox = this.sessionSandboxes.get(sessionId);
128
- if (!sandbox) {
129
- throw new Error(`Failed to get sandbox for session: ${sessionId}`);
130
- }
131
- if (!('process' in sandbox)) {
132
- throw new Error(`Sandbox is not fully initialized for session: ${sessionId}`);
133
- }
134
- return sandbox;
135
- }
136
- // Delete the sandbox associated with the given session ID
137
- async deleteSandbox(sessionId) {
138
- const sandbox = this.sessionSandboxes.get(sessionId);
139
- if (sandbox && 'delete' in sandbox) {
140
- this.logger.info(`Removing sandbox for session: ${sessionId}`);
141
- await sandbox.delete();
142
- this.sessionSandboxes.delete(sessionId);
143
- this.saveSessionMap();
144
- this.logger.info(`Sandbox deleted successfully.`);
145
- }
146
- else {
147
- this.logger.warn(`No sandbox found for session: ${sessionId}`);
148
- }
149
- }
150
- }
151
- // Initialize logger and session manager
152
- const LOG_FILE = (0, path_1.join)(process.env.HOME || '/tmp', '.daytona-plugin.log');
153
- const SESSION_MAP_FILE = (0, path_1.join)(process.env.HOME || '/tmp', '.daytona-sessions.json');
154
- const logger = new Logger(LOG_FILE);
155
- const sessionManager = new DaytonaSessionManager(process.env.DAYTONA_API_KEY || '', SESSION_MAP_FILE, logger);
156
- const CustomToolsPlugin = async (pluginCtx) => {
157
- logger.info('OpenCode started with Daytona plugin');
158
- return {
159
- tool: {
160
- /**
161
- * Executes a shell command in the Daytona sandbox and returns the output
162
- * @param command - Shell command to execute
163
- */
164
- bash: (0, plugin_1.tool)({
165
- description: "Executes shell commands in a Daytona sandbox",
166
- args: {
167
- command: plugin_1.tool.schema.string(),
168
- background: plugin_1.tool.schema.boolean().optional(),
169
- },
170
- async execute(args, ctx) {
171
- const sessionId = ctx.sessionID;
172
- const sandbox = await sessionManager.getSandbox(sessionId);
173
- if (args.background) {
174
- // Run command in background using session-based execution
175
- const execSessionId = `exec-session-${sessionId}`;
176
- // Create session if it doesn't exist
177
- try {
178
- await sandbox.process.getSession(execSessionId);
179
- }
180
- catch {
181
- await sandbox.process.createSession(execSessionId);
182
- }
183
- // Execute command asynchronously in the session
184
- const result = await sandbox.process.executeSessionCommand(execSessionId, {
185
- command: args.command,
186
- runAsync: true,
187
- });
188
- return `Command started in background (cmdId: ${result.cmdId})`;
189
- }
190
- else {
191
- const result = await sandbox.process.executeCommand(args.command);
192
- return `Exit code: ${result.exitCode}\n${result.result}`;
193
- }
194
- },
195
- }),
196
- /**
197
- * Reads and returns the contents of a file from the sandbox
198
- * @param filePath - Path to the file to read
199
- */
200
- read: (0, plugin_1.tool)({
201
- description: "Reads file from Daytona sandbox",
202
- args: {
203
- filePath: plugin_1.tool.schema.string(),
204
- },
205
- async execute(args, ctx) {
206
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
207
- const buffer = await sandbox.fs.downloadFile(args.filePath);
208
- const decoder = new TextDecoder();
209
- return decoder.decode(buffer);
210
- },
211
- }),
212
- /**
213
- * Writes content to a file in the sandbox, creating it if it doesn't exist
214
- * @param filePath - Path to the file to write
215
- * @param content - Content to write to the file
216
- */
217
- write: (0, plugin_1.tool)({
218
- description: "Writes content to file in Daytona sandbox",
219
- args: {
220
- filePath: plugin_1.tool.schema.string(),
221
- content: plugin_1.tool.schema.string(),
222
- },
223
- async execute(args, ctx) {
224
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
225
- await sandbox.fs.uploadFile(Buffer.from(args.content), args.filePath);
226
- return `Written ${args.content.length} bytes to ${args.filePath}`;
227
- },
228
- }),
229
- /**
230
- * Replaces the first occurrence of a text pattern in a file
231
- * @param filePath - Path to the file to edit
232
- * @param oldString - Text to search for
233
- * @param newString - Text to replace with
234
- */
235
- edit: (0, plugin_1.tool)({
236
- description: "Replaces text in a file in Daytona sandbox",
237
- args: {
238
- filePath: plugin_1.tool.schema.string(),
239
- oldString: plugin_1.tool.schema.string(),
240
- newString: plugin_1.tool.schema.string(),
241
- },
242
- async execute(args, ctx) {
243
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
244
- const buffer = await sandbox.fs.downloadFile(args.filePath);
245
- const decoder = new TextDecoder();
246
- const content = decoder.decode(buffer);
247
- const newContent = content.replace(args.oldString, args.newString);
248
- await sandbox.fs.uploadFile(Buffer.from(newContent), args.filePath);
249
- return `Edited ${args.filePath}`;
250
- },
251
- }),
252
- /**
253
- * Applies multiple text replacements to a file atomically
254
- * @param filePath - Path to the file to edit
255
- * @param edits - Array of {oldString, newString} pairs to apply
256
- */
257
- multiedit: (0, plugin_1.tool)({
258
- description: "Applies multiple edits to a file in Daytona sandbox atomically",
259
- args: {
260
- filePath: plugin_1.tool.schema.string(),
261
- edits: plugin_1.tool.schema.array(plugin_1.tool.schema.object({
262
- oldString: plugin_1.tool.schema.string(),
263
- newString: plugin_1.tool.schema.string(),
264
- })),
265
- },
266
- async execute(args, ctx) {
267
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
268
- const buffer = await sandbox.fs.downloadFile(args.filePath);
269
- const decoder = new TextDecoder();
270
- let content = decoder.decode(buffer);
271
- for (const edit of args.edits) {
272
- content = content.replace(edit.oldString, edit.newString);
273
- }
274
- await sandbox.fs.uploadFile(Buffer.from(content), args.filePath);
275
- return `Applied ${args.edits.length} edits to ${args.filePath}`;
276
- },
277
- }),
278
- /**
279
- * Patches a file by replacing a code snippet with a new one
280
- * @param filePath - Path to the file to patch
281
- * @param oldSnippet - Code snippet to search for
282
- * @param newSnippet - Code snippet to replace with
283
- */
284
- patch: (0, plugin_1.tool)({
285
- description: "Patches a file with a code snippet in Daytona sandbox",
286
- args: {
287
- filePath: plugin_1.tool.schema.string(),
288
- oldSnippet: plugin_1.tool.schema.string(),
289
- newSnippet: plugin_1.tool.schema.string(),
290
- },
291
- async execute(args, ctx) {
292
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
293
- const buffer = await sandbox.fs.downloadFile(args.filePath);
294
- const decoder = new TextDecoder();
295
- const content = decoder.decode(buffer);
296
- const newContent = content.replace(args.oldSnippet, args.newSnippet);
297
- await sandbox.fs.uploadFile(Buffer.from(newContent), args.filePath);
298
- return `Patched ${args.filePath}`;
299
- },
300
- }),
301
- /**
302
- * Lists files and directories in the specified path (or working directory)
303
- * @param dirPath - Optional directory path to list (defaults to working directory)
304
- */
305
- ls: (0, plugin_1.tool)({
306
- description: "Lists files in a directory in Daytona sandbox",
307
- args: {
308
- dirPath: plugin_1.tool.schema.string().optional(),
309
- },
310
- async execute(args, ctx) {
311
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
312
- const workDir = await sandbox.getWorkDir();
313
- const path = args.dirPath || workDir;
314
- const files = await sandbox.fs.listFiles(path);
315
- return files.map((f) => f.name).join('\n');
316
- },
317
- }),
318
- /**
319
- * Searches for files matching a glob pattern in the sandbox
320
- * @param pattern - Glob pattern to match files (e.g., "**\/*.ts")
321
- */
322
- glob: (0, plugin_1.tool)({
323
- description: "Searches for files matching a pattern in Daytona sandbox",
324
- args: {
325
- pattern: plugin_1.tool.schema.string(),
326
- },
327
- async execute(args, ctx) {
328
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
329
- const workDir = await sandbox.getWorkDir();
330
- const result = await sandbox.fs.searchFiles(workDir, args.pattern);
331
- return result.files.join('\n');
332
- },
333
- }),
334
- /**
335
- * Searches for text patterns in files and returns matching lines
336
- * @param pattern - Text pattern to search for
337
- */
338
- grep: (0, plugin_1.tool)({
339
- description: "Searches for text pattern in files in Daytona sandbox",
340
- args: {
341
- pattern: plugin_1.tool.schema.string(),
342
- },
343
- async execute(args, ctx) {
344
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
345
- const workDir = await sandbox.getWorkDir();
346
- const matches = await sandbox.fs.findFiles(workDir, args.pattern);
347
- return matches.map((m) => `${m.file}:${m.line}: ${m.content}`).join('\n');
348
- },
349
- }),
350
- /**
351
- * Performs LSP (Language Server Protocol) operations for code intelligence (not yet implemented)
352
- * @param op - LSP operation to perform
353
- * @param filePath - Path to the file
354
- * @param line - Line number
355
- */
356
- lsp: (0, plugin_1.tool)({
357
- description: "LSP operation in Daytona sandbox (code intelligence)",
358
- args: {
359
- op: plugin_1.tool.schema.string(),
360
- filePath: plugin_1.tool.schema.string(),
361
- line: plugin_1.tool.schema.number(),
362
- },
363
- async execute(args, ctx) {
364
- return `LSP operations are not yet implemented in the Daytona plugin.`;
365
- },
366
- }),
367
- getPreviewURL: (0, plugin_1.tool)({
368
- description: "Gets a preview URL for the Daytona sandbox",
369
- args: {
370
- port: plugin_1.tool.schema.number()
371
- },
372
- async execute(args, ctx) {
373
- const sandbox = await sessionManager.getSandbox(ctx.sessionID);
374
- const previewLink = await sandbox.getPreviewLink(args.port);
375
- return `Sandbox Preview URL: ${previewLink.url}`;
376
- },
377
- }),
378
- },
379
- };
380
- };
381
- exports.CustomToolsPlugin = CustomToolsPlugin;
382
- const DaytonaSessionCleanupPlugin = async ({ $ }) => {
383
- return {
384
- /**
385
- * Cleans up sandbox resources when a session is deleted
386
- */
387
- event: async ({ event }) => {
388
- if (event.type === EVENT_TYPE_SESSION_DELETED) {
389
- const sessionId = event.properties.info.id;
390
- await sessionManager.deleteSandbox(sessionId);
391
- }
392
- },
393
- };
394
- };
395
- exports.DaytonaSessionCleanupPlugin = DaytonaSessionCleanupPlugin;
396
- const SystemTransformPlugin = async (pluginCtx) => {
397
- return {
398
- "experimental.chat.system.transform": async (input, output) => {
399
- output.system.push(`
400
- ## Daytona Sandbox Integration
401
- This session is running with Daytona sandbox integration enabled.
402
- All tool calls will execute in a Daytona sandbox environment.
403
- The sandbox working directory is /home/daytona/.
404
- Do NOT try to use the current working directory of the host system.
405
- When executing long-running commands, use the 'background' option to run them asynchronously.
406
- `);
407
- },
408
- };
409
- };
410
- exports.SystemTransformPlugin = SystemTransformPlugin;
411
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,gDAAiF;AACjF,2BAA4E;AAC5E,+BAA2B;AAC3B,wCAA2D;AAW3D,sBAAsB;AAEtB,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AAUrD,4BAA4B;AAE5B,MAAM,cAAc,GAAa,MAAM,CAAC;AACxC,MAAM,eAAe,GAAa,OAAO,CAAC;AAC1C,MAAM,cAAc,GAAa,MAAM,CAAC;AAExC;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM;IACO,OAAO,CAAS;IAEjC,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,QAAkB,cAAc;QACnD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,SAAS,MAAM,KAAK,KAAK,OAAO,IAAI,CAAC;QAC1D,IAAA,mBAAc,EAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,qBAAqB;IACR,MAAM,CAAS;IACf,cAAc,CAAS;IACvB,MAAM,CAAS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