@jamesmurdza/opencode-daytona 0.1.13 → 0.1.15

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 (55) hide show
  1. package/.opencode/plugin/daytona/core/logger.ts +50 -0
  2. package/.opencode/plugin/daytona/core/project-data-storage.ts +154 -0
  3. package/.opencode/plugin/daytona/core/session-manager.ts +170 -0
  4. package/.opencode/plugin/daytona/core/types.ts +68 -0
  5. package/.opencode/plugin/daytona/git/host-git-manager.ts +94 -0
  6. package/.opencode/plugin/daytona/git/index.ts +1 -0
  7. package/.opencode/plugin/daytona/git/sandbox-git-manager.ts +51 -0
  8. package/.opencode/plugin/daytona/git/session-git-manager.ts +65 -0
  9. package/.opencode/plugin/daytona/index.ts +50 -0
  10. package/.opencode/plugin/daytona/plugins/custom-tools.ts +20 -0
  11. package/.opencode/plugin/daytona/plugins/index.ts +8 -0
  12. package/.opencode/plugin/daytona/plugins/session-cleanup.ts +22 -0
  13. package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.ts +30 -0
  14. package/.opencode/plugin/daytona/plugins/system-transform.ts +28 -0
  15. package/.opencode/plugin/daytona/tools/bash.ts +32 -0
  16. package/.opencode/plugin/daytona/tools/edit.ts +21 -0
  17. package/.opencode/plugin/daytona/tools/get-preview-url.ts +15 -0
  18. package/.opencode/plugin/daytona/tools/glob.ts +16 -0
  19. package/.opencode/plugin/daytona/tools/grep.ts +16 -0
  20. package/.opencode/plugin/daytona/tools/ls.ts +18 -0
  21. package/.opencode/plugin/daytona/tools/lsp.ts +15 -0
  22. package/.opencode/plugin/daytona/tools/multiedit.ts +32 -0
  23. package/.opencode/plugin/daytona/tools/patch.ts +21 -0
  24. package/.opencode/plugin/daytona/tools/read.ts +16 -0
  25. package/.opencode/plugin/daytona/tools/write.ts +16 -0
  26. package/.opencode/plugin/daytona/tools.ts +33 -0
  27. package/.opencode/plugin/{index.js → index.ts} +1 -2
  28. package/package.json +3 -12
  29. package/.opencode/plugin/daytona/index.d.ts +0 -25
  30. package/.opencode/plugin/daytona/index.d.ts.map +0 -1
  31. package/.opencode/plugin/daytona/index.js +0 -36
  32. package/.opencode/plugin/daytona/index.js.map +0 -1
  33. package/.opencode/plugin/daytona/logger.d.ts +0 -13
  34. package/.opencode/plugin/daytona/logger.d.ts.map +0 -1
  35. package/.opencode/plugin/daytona/logger.js +0 -26
  36. package/.opencode/plugin/daytona/logger.js.map +0 -1
  37. package/.opencode/plugin/daytona/plugins.d.ts +0 -22
  38. package/.opencode/plugin/daytona/plugins.d.ts.map +0 -1
  39. package/.opencode/plugin/daytona/plugins.js +0 -60
  40. package/.opencode/plugin/daytona/plugins.js.map +0 -1
  41. package/.opencode/plugin/daytona/session-manager.d.ts +0 -47
  42. package/.opencode/plugin/daytona/session-manager.d.ts.map +0 -1
  43. package/.opencode/plugin/daytona/session-manager.js +0 -165
  44. package/.opencode/plugin/daytona/session-manager.js.map +0 -1
  45. package/.opencode/plugin/daytona/tools.d.ts +0 -185
  46. package/.opencode/plugin/daytona/tools.d.ts.map +0 -1
  47. package/.opencode/plugin/daytona/tools.js +0 -232
  48. package/.opencode/plugin/daytona/tools.js.map +0 -1
  49. package/.opencode/plugin/daytona/types.d.ts +0 -32
  50. package/.opencode/plugin/daytona/types.d.ts.map +0 -1
  51. package/.opencode/plugin/daytona/types.js +0 -10
  52. package/.opencode/plugin/daytona/types.js.map +0 -1
  53. package/.opencode/plugin/index.d.ts +0 -6
  54. package/.opencode/plugin/index.d.ts.map +0 -1
  55. package/.opencode/plugin/index.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ /**
2
+ * OpenCode Plugin: Daytona Sandbox Integration
3
+ *
4
+ * OpenCode plugins extend the AI coding assistant by adding custom tools, handling events,
5
+ * and modifying behavior. Plugins are TypeScript/JavaScript modules that export functions
6
+ * which return hooks for various lifecycle events.
7
+ *
8
+ * This plugin integrates Daytona sandboxes with OpenCode, providing isolated development
9
+ * environments for each session. It adds custom tools for file operations, command execution,
10
+ * and search within sandboxes, and automatically cleans up resources when sessions end.
11
+ *
12
+ * Learn more: https://opencode.ai/docs/plugins/
13
+ *
14
+ * Daytona Sandbox Integration Tools
15
+ *
16
+ * Requires:
17
+ * - npm install @daytonaio/sdk
18
+ * - Environment: DAYTONA_API_KEY
19
+ */
20
+
21
+ import { join } from 'path'
22
+ import { xdgData } from 'xdg-basedir'
23
+ import type { Plugin } from '@opencode-ai/plugin'
24
+
25
+ // Import modules
26
+ import { setLogFilePath } from './core/logger'
27
+ import { DaytonaSessionManager } from './core/session-manager'
28
+ import {
29
+ createCustomToolsPlugin,
30
+ createSessionCleanupPlugin,
31
+ createSystemTransformPlugin,
32
+ createSessionIdleAutoCommitPlugin,
33
+ } from './plugins'
34
+
35
+ // Export types for consumers
36
+ export type { EventSessionDeleted, LogLevel, SandboxInfo, SessionInfo, ProjectSessionData } from './core/types'
37
+
38
+ // Initialize logger and session manager using xdg-basedir (same as OpenCode)
39
+ const LOG_FILE = join(xdgData!, '.daytona-plugin.log')
40
+ const STORAGE_DIR = join(xdgData!, 'opencode', 'storage', 'daytona')
41
+ const REPO_PATH = '/home/daytona/project'
42
+
43
+ setLogFilePath(LOG_FILE)
44
+ const sessionManager = new DaytonaSessionManager(process.env.DAYTONA_API_KEY || '', STORAGE_DIR, REPO_PATH)
45
+
46
+ // Export plugin instances
47
+ export const CustomToolsPlugin: Plugin = createCustomToolsPlugin(sessionManager)
48
+ export const DaytonaSessionCleanupPlugin: Plugin = createSessionCleanupPlugin(sessionManager)
49
+ export const SystemTransformPlugin: Plugin = createSystemTransformPlugin(REPO_PATH)
50
+ export const DaytonaSessionIdleAutoCommitPlugin: Plugin = createSessionIdleAutoCommitPlugin(sessionManager, REPO_PATH)
@@ -0,0 +1,20 @@
1
+ import type { Plugin, PluginInput } from '@opencode-ai/plugin'
2
+ import { createDaytonaTools } from '../tools'
3
+ import { logger } from '../core/logger'
4
+ import type { DaytonaSessionManager } from '../core/session-manager'
5
+
6
+ /**
7
+ * Creates the custom tools plugin for Daytona sandbox integration
8
+ * Provides tools for file operations, command execution, and search within sandboxes
9
+ */
10
+ export function createCustomToolsPlugin(sessionManager: DaytonaSessionManager): Plugin {
11
+ return async (pluginCtx: PluginInput) => {
12
+ logger.info('OpenCode started with Daytona plugin')
13
+ const projectId = pluginCtx.project.id
14
+ const worktree = pluginCtx.project.worktree
15
+
16
+ return {
17
+ tool: createDaytonaTools(sessionManager, projectId, worktree),
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * OpenCode plugin implementations for Daytona sandbox integration
3
+ */
4
+
5
+ export { createCustomToolsPlugin } from './custom-tools'
6
+ export { createSessionIdleAutoCommitPlugin } from './session-idle-auto-commit'
7
+ export { createSessionCleanupPlugin } from './session-cleanup'
8
+ export { createSystemTransformPlugin } from './system-transform'
@@ -0,0 +1,22 @@
1
+ import type { Plugin, PluginInput } from '@opencode-ai/plugin'
2
+ import type { DaytonaSessionManager } from '../core/session-manager'
3
+ import { EVENT_TYPE_SESSION_DELETED } from '../core/types'
4
+ import type { EventSessionDeleted } from '../core/types'
5
+
6
+ /**
7
+ * Creates the session cleanup plugin for Daytona
8
+ * Automatically cleans up sandbox resources when sessions end
9
+ */
10
+ export function createSessionCleanupPlugin(sessionManager: DaytonaSessionManager): Plugin {
11
+ return async (pluginCtx: PluginInput) => {
12
+ const projectId = pluginCtx.project.id
13
+ return {
14
+ event: async ({ event }) => {
15
+ if (event.type === EVENT_TYPE_SESSION_DELETED) {
16
+ const sessionId = (event as EventSessionDeleted).properties.info.id
17
+ await sessionManager.deleteSandbox(sessionId, projectId)
18
+ }
19
+ },
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,30 @@
1
+ import type { Plugin, PluginInput } from '@opencode-ai/plugin'
2
+ import type { DaytonaSessionManager } from '../core/session-manager'
3
+ import { SessionGitManager } from '../git/session-git-manager'
4
+ import { EVENT_TYPE_SESSION_IDLE } from '../core/types'
5
+
6
+ /**
7
+ * Creates a plugin to auto-commit in the sandbox on session idle
8
+ */
9
+ export function createSessionIdleAutoCommitPlugin(sessionManager: DaytonaSessionManager, repoPath: string): Plugin {
10
+ return async (pluginCtx: PluginInput) => {
11
+ const projectId = pluginCtx.project.id
12
+ const worktree = pluginCtx.project.worktree
13
+ return {
14
+ event: async (args: any) => {
15
+ const event = args.event
16
+ if (event.type === EVENT_TYPE_SESSION_IDLE) {
17
+ const sessionId = event.properties.sessionID
18
+ // Use SessionGitManager abstraction for auto-commit and pull
19
+ const sandbox = await sessionManager.getSandbox(sessionId, projectId, worktree)
20
+ const branchNumber = sessionManager.getBranchNumberForSandbox(projectId, sandbox.id)
21
+ if (!branchNumber) {
22
+ throw new Error(`No branch number found for sandbox ${sandbox.id}`)
23
+ }
24
+ const sessionGit = new SessionGitManager(sandbox, repoPath, branchNumber)
25
+ await sessionGit.autoCommitAndPull()
26
+ }
27
+ },
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,28 @@
1
+ import type { Plugin, PluginInput } from '@opencode-ai/plugin'
2
+ import type {
3
+ ExperimentalChatSystemTransformInput,
4
+ ExperimentalChatSystemTransformOutput,
5
+ } from '../core/types'
6
+
7
+ /**
8
+ * Creates the system transform plugin for Daytona
9
+ * Adds Daytona-specific instructions to the system prompt
10
+ */
11
+ export function createSystemTransformPlugin(repoPath: string): Plugin {
12
+ return async (pluginCtx: PluginInput) => {
13
+ return {
14
+ 'experimental.chat.system.transform': async (
15
+ input: ExperimentalChatSystemTransformInput,
16
+ output: ExperimentalChatSystemTransformOutput,
17
+ ) => {
18
+ output.system.push(`
19
+ ## Daytona Sandbox Integration
20
+ This session is integrated with a Daytona sandbox.
21
+ The main project repository is located at: ${repoPath}.
22
+ Work in this directory. Do NOT try to use the current working directory of the host system.
23
+ When executing long-running commands, use the 'background' option to run them asynchronously.
24
+ `)
25
+ },
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const bashTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Executes shell commands in a Daytona sandbox',
7
+ args: {
8
+ command: z.string(),
9
+ background: z.boolean().optional(),
10
+ },
11
+ async execute(args: { command: string; background?: boolean }, ctx: ToolContext) {
12
+ const sessionId = ctx.sessionID
13
+ const sandbox = await sessionManager.getSandbox(sessionId, projectId, worktree)
14
+
15
+ if (args.background) {
16
+ const execSessionId = `exec-session-${sessionId}`
17
+ try {
18
+ await sandbox.process.getSession(execSessionId)
19
+ } catch {
20
+ await sandbox.process.createSession(execSessionId)
21
+ }
22
+ const result = await sandbox.process.executeSessionCommand(execSessionId, {
23
+ command: args.command,
24
+ runAsync: true,
25
+ })
26
+ return `Command started in background (cmdId: ${result.cmdId})`
27
+ } else {
28
+ const result = await sandbox.process.executeCommand(args.command)
29
+ return `Exit code: ${result.exitCode}\n${result.result}`
30
+ }
31
+ },
32
+ })
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const editTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Replaces text in a file in Daytona sandbox',
7
+ args: {
8
+ filePath: z.string(),
9
+ oldString: z.string(),
10
+ newString: z.string(),
11
+ },
12
+ async execute(args: { filePath: string; oldString: string; newString: string }, ctx: ToolContext) {
13
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
14
+ const buffer = await sandbox.fs.downloadFile(args.filePath)
15
+ const decoder = new TextDecoder()
16
+ const content = decoder.decode(buffer)
17
+ const newContent = content.replace(args.oldString, args.newString)
18
+ await sandbox.fs.uploadFile(Buffer.from(newContent), args.filePath)
19
+ return `Edited ${args.filePath}`
20
+ },
21
+ })
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const getPreviewURLTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Gets a preview URL for the Daytona sandbox',
7
+ args: {
8
+ port: z.number(),
9
+ },
10
+ async execute(args: { port: number }, ctx: ToolContext) {
11
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
12
+ const previewLink = await sandbox.getPreviewLink(args.port)
13
+ return `Sandbox Preview URL: ${previewLink.url}`
14
+ },
15
+ })
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const globTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Searches for files matching a pattern in Daytona sandbox',
7
+ args: {
8
+ pattern: z.string(),
9
+ },
10
+ async execute(args: { pattern: string }, ctx: ToolContext) {
11
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
12
+ const workDir = await sandbox.getWorkDir()
13
+ const result = await sandbox.fs.searchFiles(workDir, args.pattern)
14
+ return result.files.join('\n')
15
+ },
16
+ })
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const grepTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Searches for text pattern in files in Daytona sandbox',
7
+ args: {
8
+ pattern: z.string(),
9
+ },
10
+ async execute(args: { pattern: string }, ctx: ToolContext) {
11
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
12
+ const workDir = await sandbox.getWorkDir()
13
+ const matches = await sandbox.fs.findFiles(workDir, args.pattern)
14
+ return matches.map((m) => `${m.file}:${m.line}: ${m.content}`).join('\n')
15
+ },
16
+ })
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+ import type { FileInfo } from '@daytonaio/sdk'
5
+
6
+ export const lsTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
7
+ description: 'Lists files in a directory in Daytona sandbox',
8
+ args: {
9
+ dirPath: z.string().optional(),
10
+ },
11
+ async execute(args: { dirPath?: string }, ctx: ToolContext) {
12
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
13
+ const workDir = await sandbox.getWorkDir()
14
+ const path = args.dirPath || workDir
15
+ const files = (await sandbox.fs.listFiles(path)) as FileInfo[]
16
+ return files.map((f) => f.name).join('\n')
17
+ },
18
+ })
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const lspTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'LSP operation in Daytona sandbox (code intelligence)',
7
+ args: {
8
+ op: z.string(),
9
+ filePath: z.string(),
10
+ line: z.number(),
11
+ },
12
+ async execute(args: { op: string; filePath: string; line: number }, ctx: ToolContext) {
13
+ return `LSP operations are not yet implemented in the Daytona plugin.`
14
+ },
15
+ })
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const multieditTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Applies multiple edits to a file in Daytona sandbox atomically',
7
+ args: {
8
+ filePath: z.string(),
9
+ edits: z.array(
10
+ z.object({
11
+ oldString: z.string(),
12
+ newString: z.string(),
13
+ }),
14
+ ),
15
+ },
16
+ async execute(
17
+ args: { filePath: string; edits: Array<{ oldString: string; newString: string }> },
18
+ ctx: ToolContext,
19
+ ) {
20
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
21
+ const buffer = await sandbox.fs.downloadFile(args.filePath)
22
+ const decoder = new TextDecoder()
23
+ let content = decoder.decode(buffer)
24
+
25
+ for (const edit of args.edits) {
26
+ content = content.replace(edit.oldString, edit.newString)
27
+ }
28
+
29
+ await sandbox.fs.uploadFile(Buffer.from(content), args.filePath)
30
+ return `Applied ${args.edits.length} edits to ${args.filePath}`
31
+ },
32
+ })
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const patchTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Patches a file with a code snippet in Daytona sandbox',
7
+ args: {
8
+ filePath: z.string(),
9
+ oldSnippet: z.string(),
10
+ newSnippet: z.string(),
11
+ },
12
+ async execute(args: { filePath: string; oldSnippet: string; newSnippet: string }, ctx: ToolContext) {
13
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
14
+ const buffer = await sandbox.fs.downloadFile(args.filePath)
15
+ const decoder = new TextDecoder()
16
+ const content = decoder.decode(buffer)
17
+ const newContent = content.replace(args.oldSnippet, args.newSnippet)
18
+ await sandbox.fs.uploadFile(Buffer.from(newContent), args.filePath)
19
+ return `Patched ${args.filePath}`
20
+ },
21
+ })
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const readTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Reads file from Daytona sandbox',
7
+ args: {
8
+ filePath: z.string(),
9
+ },
10
+ async execute(args: { filePath: string }, ctx: ToolContext) {
11
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
12
+ const buffer = await sandbox.fs.downloadFile(args.filePath)
13
+ const decoder = new TextDecoder()
14
+ return decoder.decode(buffer)
15
+ },
16
+ })
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod'
2
+ import type { ToolContext } from '@opencode-ai/plugin'
3
+ import type { DaytonaSessionManager } from '../core/session-manager'
4
+
5
+ export const writeTool = (sessionManager: DaytonaSessionManager, projectId: string, worktree: string) => ({
6
+ description: 'Writes content to file in Daytona sandbox',
7
+ args: {
8
+ filePath: z.string(),
9
+ content: z.string(),
10
+ },
11
+ async execute(args: { filePath: string; content: string }, ctx: ToolContext) {
12
+ const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree)
13
+ await sandbox.fs.uploadFile(Buffer.from(args.content), args.filePath)
14
+ return `Written ${args.content.length} bytes to ${args.filePath}`
15
+ },
16
+ })
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Tool implementations for Daytona sandbox integration
3
+ */
4
+
5
+ import { bashTool } from './tools/bash'
6
+ import { readTool } from './tools/read'
7
+ import { writeTool } from './tools/write'
8
+ import { editTool } from './tools/edit'
9
+ import { multieditTool } from './tools/multiedit'
10
+ import { patchTool } from './tools/patch'
11
+ import { lsTool } from './tools/ls'
12
+ import { globTool } from './tools/glob'
13
+ import { grepTool } from './tools/grep'
14
+ import { lspTool } from './tools/lsp'
15
+ import { getPreviewURLTool } from './tools/get-preview-url'
16
+
17
+ import type { DaytonaSessionManager } from './core/session-manager'
18
+
19
+ export function createDaytonaTools(sessionManager: DaytonaSessionManager, projectId: string, worktree: string) {
20
+ return {
21
+ bash: bashTool(sessionManager, projectId, worktree),
22
+ read: readTool(sessionManager, projectId, worktree),
23
+ write: writeTool(sessionManager, projectId, worktree),
24
+ edit: editTool(sessionManager, projectId, worktree),
25
+ multiedit: multieditTool(sessionManager, projectId, worktree),
26
+ patch: patchTool(sessionManager, projectId, worktree),
27
+ ls: lsTool(sessionManager, projectId, worktree),
28
+ glob: globTool(sessionManager, projectId, worktree),
29
+ grep: grepTool(sessionManager, projectId, worktree),
30
+ lsp: lspTool(sessionManager, projectId, worktree),
31
+ getPreviewURL: getPreviewURLTool(sessionManager, projectId, worktree),
32
+ }
33
+ }
@@ -2,5 +2,4 @@
2
2
  * Main entry point for the OpenCode Daytona plugin
3
3
  * Re-exports all plugin components from the daytona module
4
4
  */
5
- export * from './daytona/index.js';
6
- //# sourceMappingURL=index.js.map
5
+ export * from './daytona/index.js';
package/package.json CHANGED
@@ -1,17 +1,10 @@
1
1
  {
2
2
  "name": "@jamesmurdza/opencode-daytona",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "OpenCode plugin that automatically runs all sessions in Daytona sandboxes for isolated, reproducible development environments",
5
- "main": "./.opencode/plugin/index.js",
6
- "types": "./.opencode/plugin/index.d.ts",
7
5
  "files": [
8
6
  ".opencode"
9
7
  ],
10
- "scripts": {
11
- "build": "tsc",
12
- "dev": "tsc --watch",
13
- "clean": "rm -rf dist"
14
- },
15
8
  "keywords": [
16
9
  "daytona",
17
10
  "opencode",
@@ -27,7 +20,5 @@
27
20
  "@opencode-ai/plugin": "^1.1.21",
28
21
  "@types/node": "^25.0.9",
29
22
  "typescript": "^5.3.3"
30
- },
31
- "module": "./libs/opencode-plugin/src/index.js",
32
- "type": "module"
33
- }
23
+ }
24
+ }
@@ -1,25 +0,0 @@
1
- /**
2
- * OpenCode Plugin: Daytona Sandbox Integration
3
- *
4
- * OpenCode plugins extend the AI coding assistant by adding custom tools, handling events,
5
- * and modifying behavior. Plugins are TypeScript/JavaScript modules that export functions
6
- * which return hooks for various lifecycle events.
7
- *
8
- * This plugin integrates Daytona sandboxes with OpenCode, providing isolated development
9
- * environments for each session. It adds custom tools for file operations, command execution,
10
- * and search within sandboxes, and automatically cleans up resources when sessions end.
11
- *
12
- * Learn more: https://opencode.ai/docs/plugins/
13
- *
14
- * Daytona Sandbox Integration Tools
15
- *
16
- * Requires:
17
- * - npm install @daytonaio/sdk
18
- * - Environment: DAYTONA_API_KEY
19
- */
20
- import type { Plugin } from "@opencode-ai/plugin";
21
- export type { EventSessionDeleted, LogLevel, SandboxInfo, SessionInfo, ProjectSessionData } from "./types";
22
- export declare const CustomToolsPlugin: Plugin;
23
- export declare const DaytonaSessionCleanupPlugin: Plugin;
24
- export declare const SystemTransformPlugin: Plugin;
25
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAYlD,YAAY,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAc3G,eAAO,MAAM,iBAAiB,EAAE,MAAwD,CAAC;AACzF,eAAO,MAAM,2BAA2B,EAAE,MAAmD,CAAC;AAC9F,eAAO,MAAM,qBAAqB,EAAE,MAAsC,CAAC"}
@@ -1,36 +0,0 @@
1
- /**
2
- * OpenCode Plugin: Daytona Sandbox Integration
3
- *
4
- * OpenCode plugins extend the AI coding assistant by adding custom tools, handling events,
5
- * and modifying behavior. Plugins are TypeScript/JavaScript modules that export functions
6
- * which return hooks for various lifecycle events.
7
- *
8
- * This plugin integrates Daytona sandboxes with OpenCode, providing isolated development
9
- * environments for each session. It adds custom tools for file operations, command execution,
10
- * and search within sandboxes, and automatically cleans up resources when sessions end.
11
- *
12
- * Learn more: https://opencode.ai/docs/plugins/
13
- *
14
- * Daytona Sandbox Integration Tools
15
- *
16
- * Requires:
17
- * - npm install @daytonaio/sdk
18
- * - Environment: DAYTONA_API_KEY
19
- */
20
- import { join } from "path";
21
- import { tmpdir } from "os";
22
- import { xdgData } from "xdg-basedir";
23
- // Import modules
24
- import { Logger } from "./logger";
25
- import { DaytonaSessionManager } from "./session-manager";
26
- import { createCustomToolsPlugin, createSessionCleanupPlugin, createSystemTransformPlugin, } from "./plugins";
27
- // Initialize logger and session manager using xdg-basedir (same as OpenCode)
28
- const LOG_FILE = join(tmpdir(), '.daytona-plugin.log');
29
- const STORAGE_DIR = join(xdgData, 'opencode', 'storage', 'daytona');
30
- const logger = new Logger(LOG_FILE);
31
- const sessionManager = new DaytonaSessionManager(process.env.DAYTONA_API_KEY || '', STORAGE_DIR, logger);
32
- // Export plugin instances
33
- export const CustomToolsPlugin = createCustomToolsPlugin(logger, sessionManager);
34
- export const DaytonaSessionCleanupPlugin = createSessionCleanupPlugin(sessionManager);
35
- export const SystemTransformPlugin = createSystemTransformPlugin();
36
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,iBAAiB;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AAKnB,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC;AACvD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAErE,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpC,MAAM,cAAc,GAAG,IAAI,qBAAqB,CAC9C,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,EACjC,WAAW,EACX,MAAM,CACP,CAAC;AAEF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,iBAAiB,GAAW,uBAAuB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,2BAA2B,GAAW,0BAA0B,CAAC,cAAc,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,qBAAqB,GAAW,2BAA2B,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Logger class for handling plugin logging
3
- */
4
- import type { LogLevel } from "./types";
5
- export declare class Logger {
6
- private readonly logFile;
7
- constructor(logFile: string);
8
- log(message: string, level?: LogLevel): void;
9
- info(message: string): void;
10
- error(message: string): void;
11
- warn(message: string): void;
12
- }
13
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,MAAM;IAI3B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,QAAyB,GAAG,IAAI;IAM5D,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG5B"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Logger class for handling plugin logging
3
- */
4
- import { appendFileSync } from "fs";
5
- import { LOG_LEVEL_INFO, LOG_LEVEL_ERROR, LOG_LEVEL_WARN } from "./types";
6
- export class Logger {
7
- logFile;
8
- constructor(logFile) {
9
- this.logFile = logFile;
10
- }
11
- log(message, level = LOG_LEVEL_INFO) {
12
- const timestamp = new Date().toISOString();
13
- const logEntry = `[${timestamp}] [${level}] ${message}\n`;
14
- appendFileSync(this.logFile, logEntry);
15
- }
16
- info(message) {
17
- this.log(message, LOG_LEVEL_INFO);
18
- }
19
- error(message) {
20
- this.log(message, LOG_LEVEL_ERROR);
21
- }
22
- warn(message) {
23
- this.log(message, LOG_LEVEL_WARN);
24
- }
25
- }
26
- //# sourceMappingURL=logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,MAAM,OAAO,MAAM;IACA,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,cAAc,CAAC,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"}
@@ -1,22 +0,0 @@
1
- /**
2
- * OpenCode plugin implementations for Daytona sandbox integration
3
- */
4
- import type { Plugin } from "@opencode-ai/plugin";
5
- import type { Logger } from "./logger";
6
- import type { DaytonaSessionManager } from "./session-manager";
7
- /**
8
- * Creates the custom tools plugin for Daytona sandbox integration
9
- * Provides tools for file operations, command execution, and search within sandboxes
10
- */
11
- export declare function createCustomToolsPlugin(logger: Logger, sessionManager: DaytonaSessionManager): Plugin;
12
- /**
13
- * Creates the session cleanup plugin for Daytona
14
- * Automatically cleans up sandbox resources when sessions end
15
- */
16
- export declare function createSessionCleanupPlugin(sessionManager: DaytonaSessionManager): Plugin;
17
- /**
18
- * Creates the system transform plugin for Daytona
19
- * Adds Daytona-specific instructions to the system prompt
20
- */
21
- export declare function createSystemTransformPlugin(): Plugin;
22
- //# sourceMappingURL=plugins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/plugins.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK/D;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,qBAAqB,GACpC,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,qBAAqB,GACpC,MAAM,CAgBR;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAepD"}