@daytonaio/opencode 0.143.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.
- package/.opencode/plugin/daytona/core/logger.d.ts +15 -0
- package/.opencode/plugin/daytona/core/logger.js +64 -0
- package/.opencode/plugin/daytona/core/logger.js.map +1 -0
- package/.opencode/plugin/daytona/core/project-data-storage.d.ts +42 -0
- package/.opencode/plugin/daytona/core/project-data-storage.js +171 -0
- package/.opencode/plugin/daytona/core/project-data-storage.js.map +1 -0
- package/.opencode/plugin/daytona/core/session-manager.d.ts +46 -0
- package/.opencode/plugin/daytona/core/session-manager.js +239 -0
- package/.opencode/plugin/daytona/core/session-manager.js.map +1 -0
- package/.opencode/plugin/daytona/core/toast.d.ts +47 -0
- package/.opencode/plugin/daytona/core/toast.js +73 -0
- package/.opencode/plugin/daytona/core/toast.js.map +1 -0
- package/.opencode/plugin/daytona/core/types.d.ts +53 -0
- package/.opencode/plugin/daytona/core/types.js +15 -0
- package/.opencode/plugin/daytona/core/types.js.map +1 -0
- package/.opencode/plugin/daytona/git/host-git-manager.d.ts +40 -0
- package/.opencode/plugin/daytona/git/host-git-manager.js +283 -0
- package/.opencode/plugin/daytona/git/host-git-manager.js.map +1 -0
- package/.opencode/plugin/daytona/git/index.d.ts +5 -0
- package/.opencode/plugin/daytona/git/index.js +10 -0
- package/.opencode/plugin/daytona/git/index.js.map +1 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.d.ts +14 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.js +68 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.js.map +1 -0
- package/.opencode/plugin/daytona/git/session-git-manager.d.ts +43 -0
- package/.opencode/plugin/daytona/git/session-git-manager.js +132 -0
- package/.opencode/plugin/daytona/git/session-git-manager.js.map +1 -0
- package/.opencode/plugin/daytona/index.d.ts +10 -0
- package/.opencode/plugin/daytona/index.js +44 -0
- package/.opencode/plugin/daytona/index.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.d.ts +11 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.js +26 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/index.d.ts +11 -0
- package/.opencode/plugin/daytona/plugins/index.js +19 -0
- package/.opencode/plugin/daytona/plugins/index.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.d.ts +11 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.js +43 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.js +54 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/system-transform.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/system-transform.js +29 -0
- package/.opencode/plugin/daytona/plugins/system-transform.js.map +1 -0
- package/.opencode/plugin/daytona/tools/bash.d.ts +19 -0
- package/.opencode/plugin/daytona/tools/bash.js +42 -0
- package/.opencode/plugin/daytona/tools/bash.js.map +1 -0
- package/.opencode/plugin/daytona/tools/edit.d.ts +21 -0
- package/.opencode/plugin/daytona/tools/edit.js +27 -0
- package/.opencode/plugin/daytona/tools/edit.js.map +1 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.js +21 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.js.map +1 -0
- package/.opencode/plugin/daytona/tools/glob.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/glob.js +25 -0
- package/.opencode/plugin/daytona/tools/glob.js.map +1 -0
- package/.opencode/plugin/daytona/tools/grep.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/grep.js +25 -0
- package/.opencode/plugin/daytona/tools/grep.js.map +1 -0
- package/.opencode/plugin/daytona/tools/ls.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/ls.js +26 -0
- package/.opencode/plugin/daytona/tools/ls.js.map +1 -0
- package/.opencode/plugin/daytona/tools/lsp.d.ts +21 -0
- package/.opencode/plugin/daytona/tools/lsp.js +21 -0
- package/.opencode/plugin/daytona/tools/lsp.js.map +1 -0
- package/.opencode/plugin/daytona/tools/multiedit.d.ts +25 -0
- package/.opencode/plugin/daytona/tools/multiedit.js +31 -0
- package/.opencode/plugin/daytona/tools/multiedit.js.map +1 -0
- package/.opencode/plugin/daytona/tools/patch.d.ts +19 -0
- package/.opencode/plugin/daytona/tools/patch.js +19 -0
- package/.opencode/plugin/daytona/tools/patch.js.map +1 -0
- package/.opencode/plugin/daytona/tools/read.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/read.js +22 -0
- package/.opencode/plugin/daytona/tools/read.js.map +1 -0
- package/.opencode/plugin/daytona/tools/write.d.ts +19 -0
- package/.opencode/plugin/daytona/tools/write.js +22 -0
- package/.opencode/plugin/daytona/tools/write.js.map +1 -0
- package/.opencode/plugin/daytona/tools.d.ts +129 -0
- package/.opencode/plugin/daytona/tools.js +38 -0
- package/.opencode/plugin/daytona/tools.js.map +1 -0
- package/.opencode/plugin/index.d.ts +9 -0
- package/.opencode/plugin/index.js +13 -0
- package/.opencode/plugin/index.js.map +1 -0
- package/README.md +219 -0
- package/package.json +55 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SessionGitManager = void 0;
|
|
8
|
+
const logger_1 = require("../core/logger");
|
|
9
|
+
const toast_1 = require("../core/toast");
|
|
10
|
+
const sandbox_git_manager_1 = require("./sandbox-git-manager");
|
|
11
|
+
const host_git_manager_1 = require("./host-git-manager");
|
|
12
|
+
/**
|
|
13
|
+
* SessionGitManager: Combines DaytonaSandboxGitManager and HostGitManager for session lifecycle git operations.
|
|
14
|
+
*/
|
|
15
|
+
class SessionGitManager {
|
|
16
|
+
sandboxGit;
|
|
17
|
+
hostGit;
|
|
18
|
+
sandbox;
|
|
19
|
+
repoPath;
|
|
20
|
+
worktree;
|
|
21
|
+
branch;
|
|
22
|
+
localBranch;
|
|
23
|
+
/** Numbered remote (sandbox-2) matches localBranch (opencode/2) */
|
|
24
|
+
remoteName;
|
|
25
|
+
constructor(sandbox, repoPath, worktree, branchNumber) {
|
|
26
|
+
this.sandbox = sandbox;
|
|
27
|
+
this.repoPath = repoPath;
|
|
28
|
+
this.worktree = worktree;
|
|
29
|
+
this.branch = 'opencode';
|
|
30
|
+
this.localBranch = `opencode/${branchNumber}`;
|
|
31
|
+
this.remoteName = `sandbox-${branchNumber}`;
|
|
32
|
+
this.sandboxGit = new sandbox_git_manager_1.DaytonaSandboxGitManager(sandbox, repoPath);
|
|
33
|
+
this.hostGit = new host_git_manager_1.HostGitManager();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Allocate and reserve the next opencode/N number in the local repo at `worktree`.
|
|
37
|
+
* This keeps all host-git concerns inside the git manager layer.
|
|
38
|
+
*/
|
|
39
|
+
static allocateAndReserveBranchNumber(worktree, prefix = 'opencode') {
|
|
40
|
+
return new host_git_manager_1.HostGitManager().allocateAndReserveBranchNumber(worktree, prefix);
|
|
41
|
+
}
|
|
42
|
+
async getSshUrl() {
|
|
43
|
+
const sshAccess = await this.sandbox.createSshAccess(10);
|
|
44
|
+
return `ssh://${sshAccess.token}@ssh.app.daytona.io${this.repoPath}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if local git repository exists
|
|
48
|
+
* @returns true if repo exists, false otherwise
|
|
49
|
+
*/
|
|
50
|
+
hasLocalRepo() {
|
|
51
|
+
return this.hostGit.hasRepo(this.worktree);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Initialize git in the sandbox and sync with host
|
|
55
|
+
* Used when a new sandbox is created for a session
|
|
56
|
+
*/
|
|
57
|
+
async initializeAndSync(pluginCtx) {
|
|
58
|
+
if (pluginCtx?.client?.tui) {
|
|
59
|
+
toast_1.toast.initialize(pluginCtx.client.tui);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
// Check if local git repo exists before initializing sandbox repo
|
|
63
|
+
if (!this.hostGit.hasRepo(this.worktree)) {
|
|
64
|
+
// Always ensure the directory exists, even if git syncing is disabled
|
|
65
|
+
await this.sandboxGit.ensureDirectory();
|
|
66
|
+
logger_1.logger.warn('No local git repository found. Git syncing is disabled.');
|
|
67
|
+
toast_1.toast.show({
|
|
68
|
+
title: 'Git syncing disabled',
|
|
69
|
+
message: 'No local git repository found. Git syncing is disabled for this session.',
|
|
70
|
+
variant: 'warning',
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
await this.sandboxGit.ensureRepo();
|
|
75
|
+
const sshUrl = await this.getSshUrl();
|
|
76
|
+
const pushed = await this.hostGit.pushLocalToSandboxRemote(this.remoteName, sshUrl, this.branch, this.worktree);
|
|
77
|
+
if (pushed) {
|
|
78
|
+
await this.sandboxGit.resetToRemote(this.branch);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
toast_1.toast.show({
|
|
83
|
+
title: 'Git sync error',
|
|
84
|
+
message: err?.message || 'Failed to sync git repo.',
|
|
85
|
+
variant: 'error',
|
|
86
|
+
});
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Auto-commit in the sandbox and pull latest from host
|
|
92
|
+
* Used on session idle
|
|
93
|
+
* Returns true if changes were synced, false if no changes or no local repo
|
|
94
|
+
*/
|
|
95
|
+
async autoCommitAndPull(pluginCtx) {
|
|
96
|
+
if (pluginCtx?.client?.tui) {
|
|
97
|
+
toast_1.toast.initialize(pluginCtx.client.tui);
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
// Check if local git repo exists before attempting any git operations
|
|
101
|
+
if (!this.hostGit.hasRepo(this.worktree)) {
|
|
102
|
+
logger_1.logger.warn('No local git repository found. Git syncing is disabled.');
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
await this.sandboxGit.ensureRepo();
|
|
106
|
+
const hasChanges = await this.sandboxGit.autoCommit();
|
|
107
|
+
// Only sync and notify if there were actual changes
|
|
108
|
+
if (!hasChanges) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const sshUrl = await this.getSshUrl();
|
|
112
|
+
await this.hostGit.pull(this.remoteName, sshUrl, this.branch, this.worktree, this.localBranch);
|
|
113
|
+
toast_1.toast.show({
|
|
114
|
+
title: 'Changes synced',
|
|
115
|
+
message: `Changes have been synced to ${this.localBranch} in your local repository`,
|
|
116
|
+
variant: 'success',
|
|
117
|
+
});
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
toast_1.toast.show({
|
|
122
|
+
title: 'Sync failed',
|
|
123
|
+
message: err?.message || 'Failed to auto-commit and pull.',
|
|
124
|
+
variant: 'error',
|
|
125
|
+
});
|
|
126
|
+
logger_1.logger.error(`[idle/git] error sandboxId=${this.sandbox.id}: ${err}`);
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.SessionGitManager = SessionGitManager;
|
|
132
|
+
//# sourceMappingURL=session-git-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-git-manager.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/git/session-git-manager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2CAAuC;AACvC,yCAAqC;AACrC,+DAAgE;AAChE,yDAAmD;AAGnD;;GAEG;AACH,MAAa,iBAAiB;IACX,UAAU,CAA0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,CAAC;CACF;AA5HD,8CA4HC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
6
|
+
export type { EventSessionDeleted, LogLevel, SandboxInfo, SessionInfo, ProjectSessionData } from './core/types';
|
|
7
|
+
export declare const CustomToolsPlugin: Plugin;
|
|
8
|
+
export declare const DaytonaSessionCleanupPlugin: Plugin;
|
|
9
|
+
export declare const SystemTransformPlugin: Plugin;
|
|
10
|
+
export declare const DaytonaSessionIdleAutoCommitPlugin: Plugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DaytonaSessionIdleAutoCommitPlugin = exports.SystemTransformPlugin = exports.DaytonaSessionCleanupPlugin = exports.CustomToolsPlugin = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* OpenCode Plugin: Daytona Sandbox Integration
|
|
10
|
+
*
|
|
11
|
+
* OpenCode plugins extend the AI coding assistant by adding custom tools, handling events,
|
|
12
|
+
* and modifying behavior. Plugins are TypeScript/JavaScript modules that export functions
|
|
13
|
+
* which return hooks for various lifecycle events.
|
|
14
|
+
*
|
|
15
|
+
* This plugin integrates Daytona sandboxes with OpenCode, providing isolated development
|
|
16
|
+
* environments for each session. It adds custom tools for file operations, command execution,
|
|
17
|
+
* and search within sandboxes, and automatically cleans up resources when sessions end.
|
|
18
|
+
*
|
|
19
|
+
* Learn more: https://opencode.ai/docs/plugins/
|
|
20
|
+
*
|
|
21
|
+
* Daytona Sandbox Integration Tools
|
|
22
|
+
*
|
|
23
|
+
* Requires:
|
|
24
|
+
* - npm install @daytonaio/sdk
|
|
25
|
+
* - Environment: DAYTONA_API_KEY
|
|
26
|
+
*/
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const xdg_basedir_1 = require("xdg-basedir");
|
|
29
|
+
// Import modules
|
|
30
|
+
const logger_1 = require("./core/logger");
|
|
31
|
+
const session_manager_1 = require("./core/session-manager");
|
|
32
|
+
const plugins_1 = require("./plugins");
|
|
33
|
+
// Initialize logger and session manager using xdg-basedir (same as OpenCode)
|
|
34
|
+
const LOG_FILE = (0, path_1.join)(xdg_basedir_1.xdgData, 'opencode', 'log', 'daytona.log');
|
|
35
|
+
const STORAGE_DIR = (0, path_1.join)(xdg_basedir_1.xdgData, 'opencode', 'storage', 'daytona');
|
|
36
|
+
const REPO_PATH = '/home/daytona/project';
|
|
37
|
+
(0, logger_1.setLogFilePath)(LOG_FILE);
|
|
38
|
+
const sessionManager = new session_manager_1.DaytonaSessionManager(process.env.DAYTONA_API_KEY || '', STORAGE_DIR, REPO_PATH);
|
|
39
|
+
// Export plugin instances
|
|
40
|
+
exports.CustomToolsPlugin = (0, plugins_1.createCustomToolsPlugin)(sessionManager);
|
|
41
|
+
exports.DaytonaSessionCleanupPlugin = (0, plugins_1.createSessionCleanupPlugin)(sessionManager);
|
|
42
|
+
exports.SystemTransformPlugin = (0, plugins_1.createSystemTransformPlugin)(REPO_PATH);
|
|
43
|
+
exports.DaytonaSessionIdleAutoCommitPlugin = (0, plugins_1.createSessionIdleAutoCommitPlugin)(sessionManager, REPO_PATH);
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,+BAA2B;AAC3B,6CAAqC;AAGrC,iBAAiB;AACjB,0CAA8C;AAC9C,4DAA8D;AAC9D,uCAKkB;AAKlB,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,qBAAO,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,CAAC,CAAA;AAChE,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,qBAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AACnE,MAAM,SAAS,GAAG,uBAAuB,CAAA;AAEzC,IAAA,uBAAc,EAAC,QAAQ,CAAC,CAAA;AACxB,MAAM,cAAc,GAAG,IAAI,uCAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;AAE3G,0BAA0B;AACb,QAAA,iBAAiB,GAAW,IAAA,iCAAuB,EAAC,cAAc,CAAC,CAAA;AACnE,QAAA,2BAA2B,GAAW,IAAA,oCAA0B,EAAC,cAAc,CAAC,CAAA;AAChF,QAAA,qBAAqB,GAAW,IAAA,qCAA2B,EAAC,SAAS,CAAC,CAAA;AACtE,QAAA,kCAAkC,GAAW,IAAA,2CAAiC,EAAC,cAAc,EAAE,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
6
|
+
import type { DaytonaSessionManager } from '../core/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(sessionManager: DaytonaSessionManager): Plugin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createCustomToolsPlugin = createCustomToolsPlugin;
|
|
8
|
+
const tools_1 = require("../tools");
|
|
9
|
+
const logger_1 = require("../core/logger");
|
|
10
|
+
const toast_1 = require("../core/toast");
|
|
11
|
+
/**
|
|
12
|
+
* Creates the custom tools plugin for Daytona sandbox integration
|
|
13
|
+
* Provides tools for file operations, command execution, and search within sandboxes
|
|
14
|
+
*/
|
|
15
|
+
function createCustomToolsPlugin(sessionManager) {
|
|
16
|
+
return async (pluginCtx) => {
|
|
17
|
+
logger_1.logger.info('OpenCode started with Daytona plugin');
|
|
18
|
+
toast_1.toast.initialize(pluginCtx.client?.tui);
|
|
19
|
+
const projectId = pluginCtx.project.id;
|
|
20
|
+
const worktree = pluginCtx.project.worktree;
|
|
21
|
+
return {
|
|
22
|
+
tool: (0, tools_1.createDaytonaTools)(sessionManager, projectId, worktree, pluginCtx),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=custom-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-tools.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/plugins/custom-tools.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,0DAYC;AArBD,oCAA6C;AAC7C,2CAAuC;AAEvC,yCAAqC;AAErC;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,cAAqC;IAC3E,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,eAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;QACnD,aAAK,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAEvC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAA;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAA;QAE3C,OAAO;YACL,IAAI,EAAE,IAAA,0BAAkB,EAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC;SACzE,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* OpenCode plugin implementations for Daytona sandbox integration
|
|
7
|
+
*/
|
|
8
|
+
export { createCustomToolsPlugin } from './custom-tools';
|
|
9
|
+
export { createSessionIdleAutoCommitPlugin } from './session-idle-auto-commit';
|
|
10
|
+
export { createSessionCleanupPlugin } from './session-cleanup';
|
|
11
|
+
export { createSystemTransformPlugin } from './system-transform';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createSystemTransformPlugin = exports.createSessionCleanupPlugin = exports.createSessionIdleAutoCommitPlugin = exports.createCustomToolsPlugin = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* OpenCode plugin implementations for Daytona sandbox integration
|
|
10
|
+
*/
|
|
11
|
+
var custom_tools_1 = require("./custom-tools");
|
|
12
|
+
Object.defineProperty(exports, "createCustomToolsPlugin", { enumerable: true, get: function () { return custom_tools_1.createCustomToolsPlugin; } });
|
|
13
|
+
var session_idle_auto_commit_1 = require("./session-idle-auto-commit");
|
|
14
|
+
Object.defineProperty(exports, "createSessionIdleAutoCommitPlugin", { enumerable: true, get: function () { return session_idle_auto_commit_1.createSessionIdleAutoCommitPlugin; } });
|
|
15
|
+
var session_cleanup_1 = require("./session-cleanup");
|
|
16
|
+
Object.defineProperty(exports, "createSessionCleanupPlugin", { enumerable: true, get: function () { return session_cleanup_1.createSessionCleanupPlugin; } });
|
|
17
|
+
var system_transform_1 = require("./system-transform");
|
|
18
|
+
Object.defineProperty(exports, "createSystemTransformPlugin", { enumerable: true, get: function () { return system_transform_1.createSystemTransformPlugin; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/plugins/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AAEH,+CAAwD;AAA/C,uHAAA,uBAAuB,OAAA;AAChC,uEAA8E;AAArE,6IAAA,iCAAiC,OAAA;AAC1C,qDAA8D;AAArD,6HAAA,0BAA0B,OAAA;AACnC,uDAAgE;AAAvD,+HAAA,2BAA2B,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
6
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
7
|
+
/**
|
|
8
|
+
* Creates the session cleanup plugin for Daytona
|
|
9
|
+
* Automatically cleans up sandbox resources when sessions end
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSessionCleanupPlugin(sessionManager: DaytonaSessionManager): Plugin;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createSessionCleanupPlugin = createSessionCleanupPlugin;
|
|
8
|
+
const types_1 = require("../core/types");
|
|
9
|
+
const toast_1 = require("../core/toast");
|
|
10
|
+
/**
|
|
11
|
+
* Creates the session cleanup plugin for Daytona
|
|
12
|
+
* Automatically cleans up sandbox resources when sessions end
|
|
13
|
+
*/
|
|
14
|
+
function createSessionCleanupPlugin(sessionManager) {
|
|
15
|
+
return async (pluginCtx) => {
|
|
16
|
+
toast_1.toast.initialize(pluginCtx.client?.tui);
|
|
17
|
+
const projectId = pluginCtx.project.id;
|
|
18
|
+
return {
|
|
19
|
+
event: async ({ event }) => {
|
|
20
|
+
if (event.type === types_1.EVENT_TYPE_SESSION_DELETED) {
|
|
21
|
+
const sessionId = event.properties.info.id;
|
|
22
|
+
try {
|
|
23
|
+
await sessionManager.deleteSandbox(sessionId, projectId);
|
|
24
|
+
toast_1.toast.show({
|
|
25
|
+
title: 'Session deleted',
|
|
26
|
+
message: 'Sandbox deleted successfully.',
|
|
27
|
+
variant: 'success',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
toast_1.toast.show({
|
|
32
|
+
title: 'Delete failed',
|
|
33
|
+
message: err?.message || 'Failed to delete sandbox.',
|
|
34
|
+
variant: 'error',
|
|
35
|
+
});
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=session-cleanup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-cleanup.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/plugins/session-cleanup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,gEA2BC;AAnCD,yCAA0D;AAE1D,yCAAqC;AAErC;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,cAAqC;IAC9E,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,aAAK,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACvC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAA;QACtC,OAAO;YACL,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;gBACzB,IAAI,KAAK,CAAC,IAAI,KAAK,kCAA0B,EAAE,CAAC;oBAC9C,MAAM,SAAS,GAAI,KAA6B,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAA;oBACnE,IAAI,CAAC;wBACH,MAAM,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;wBACxD,aAAK,CAAC,IAAI,CAAC;4BACT,KAAK,EAAE,iBAAiB;4BACxB,OAAO,EAAE,+BAA+B;4BACxC,OAAO,EAAE,SAAS;yBACnB,CAAC,CAAA;oBACJ,CAAC;oBAAC,OAAO,GAAQ,EAAE,CAAC;wBAClB,aAAK,CAAC,IAAI,CAAC;4BACT,KAAK,EAAE,eAAe;4BACtB,OAAO,EAAE,GAAG,EAAE,OAAO,IAAI,2BAA2B;4BACpD,OAAO,EAAE,OAAO;yBACjB,CAAC,CAAA;wBACF,MAAM,GAAG,CAAA;oBACX,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
6
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a plugin to auto-commit in the sandbox on session idle
|
|
9
|
+
*/
|
|
10
|
+
export declare function createSessionIdleAutoCommitPlugin(sessionManager: DaytonaSessionManager, repoPath: string): Plugin;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createSessionIdleAutoCommitPlugin = createSessionIdleAutoCommitPlugin;
|
|
8
|
+
const session_git_manager_1 = require("../git/session-git-manager");
|
|
9
|
+
const types_1 = require("../core/types");
|
|
10
|
+
const toast_1 = require("../core/toast");
|
|
11
|
+
const logger_1 = require("../core/logger");
|
|
12
|
+
/**
|
|
13
|
+
* Creates a plugin to auto-commit in the sandbox on session idle
|
|
14
|
+
*/
|
|
15
|
+
function createSessionIdleAutoCommitPlugin(sessionManager, repoPath) {
|
|
16
|
+
return async (pluginCtx) => {
|
|
17
|
+
toast_1.toast.initialize(pluginCtx.client?.tui);
|
|
18
|
+
const projectId = pluginCtx.project.id;
|
|
19
|
+
const worktree = pluginCtx.project.worktree;
|
|
20
|
+
return {
|
|
21
|
+
event: async (args) => {
|
|
22
|
+
const event = args.event;
|
|
23
|
+
if (event.type === types_1.EVENT_TYPE_SESSION_IDLE) {
|
|
24
|
+
const sessionId = event.properties.sessionID;
|
|
25
|
+
const start = Date.now();
|
|
26
|
+
try {
|
|
27
|
+
const sandbox = await sessionManager.getSandbox(sessionId, projectId, worktree, pluginCtx);
|
|
28
|
+
const branchNumber = sessionManager.getBranchNumberForSandbox(projectId, sandbox.id);
|
|
29
|
+
if (!branchNumber) {
|
|
30
|
+
// No local git repo => no branch reservation => nothing to sync.
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const sessionGit = new session_git_manager_1.SessionGitManager(sandbox, repoPath, worktree, branchNumber);
|
|
34
|
+
const didSync = await sessionGit.autoCommitAndPull(pluginCtx);
|
|
35
|
+
logger_1.logger.info(`[idle] done sessionId=${sessionId} sandboxId=${sandbox.id} synced=${didSync} in ${Date.now() - start}ms`);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
logger_1.logger.error(`[idle] error sessionId=${sessionId} in ${Date.now() - start}ms: ${err}`);
|
|
39
|
+
toast_1.toast.show({
|
|
40
|
+
title: 'Auto-commit error',
|
|
41
|
+
message: err?.message || 'Failed to auto-commit and pull.',
|
|
42
|
+
variant: 'error',
|
|
43
|
+
});
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
// Intentionally no-op; keep logs minimal.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=session-idle-auto-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-idle-auto-commit.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/plugins/session-idle-auto-commit.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,8EAuCC;AA/CD,oEAA8D;AAC9D,yCAAuD;AACvD,yCAAqC;AACrC,2CAAuC;AAEvC;;GAEG;AACH,SAAgB,iCAAiC,CAAC,cAAqC,EAAE,QAAgB;IACvG,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,aAAK,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACvC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAA;QACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAA;QAE3C,OAAO;YACL,KAAK,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;gBACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;gBACxB,IAAI,KAAK,CAAC,IAAI,KAAK,+BAAuB,EAAE,CAAC;oBAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,CAAA;oBAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;oBACxB,IAAI,CAA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/plugin';
|
|
6
|
+
/**
|
|
7
|
+
* Creates the system transform plugin for Daytona
|
|
8
|
+
* Adds Daytona-specific instructions to the system prompt
|
|
9
|
+
*/
|
|
10
|
+
export declare function createSystemTransformPlugin(repoPath: string): Plugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createSystemTransformPlugin = createSystemTransformPlugin;
|
|
8
|
+
/**
|
|
9
|
+
* Creates the system transform plugin for Daytona
|
|
10
|
+
* Adds Daytona-specific instructions to the system prompt
|
|
11
|
+
*/
|
|
12
|
+
function createSystemTransformPlugin(repoPath) {
|
|
13
|
+
return async (pluginCtx) => {
|
|
14
|
+
return {
|
|
15
|
+
'experimental.chat.system.transform': async (input, output) => {
|
|
16
|
+
output.system.push([
|
|
17
|
+
'## Daytona Sandbox Integration',
|
|
18
|
+
'This session is integrated with a Daytona sandbox.',
|
|
19
|
+
`The main project repository is located at: ${repoPath}.`,
|
|
20
|
+
'Bash commands will run in this directory.',
|
|
21
|
+
'Work in this directory. Do NOT try to use the current working directory of the host system.',
|
|
22
|
+
"When executing long-running commands, use the 'background' option to run them asynchronously.",
|
|
23
|
+
'Before showing a preview URL, ensure the server is running in the sandbox on that port.',
|
|
24
|
+
].join('\n'));
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=system-transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-transform.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/plugins/system-transform.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AASH,kEAqBC;AAzBD;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,QAAgB;IAC1D,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,OAAO;YACL,oCAAoC,EAAE,KAAK,EACzC,KAA2C,EAC3C,MAA6C,EAC7C,EAAE;gBACF,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB;oBACE,gCAAgC;oBAChC,oDAAoD;oBACpD,8CAA8C,QAAQ,GAAG;oBACzD,2CAA2C;oBAC3C,6FAA6F;oBAC7F,+FAA+F;oBAC/F,yFAAyF;iBAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAA;YACH,CAAC;SACF,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
7
|
+
import type { ToolContext } from '@opencode-ai/plugin/tool';
|
|
8
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
9
|
+
export declare const bashTool: (sessionManager: DaytonaSessionManager, projectId: string, worktree: string, pluginCtx: PluginInput, repoPath: string) => {
|
|
10
|
+
description: string;
|
|
11
|
+
args: {
|
|
12
|
+
command: z.ZodString;
|
|
13
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
};
|
|
15
|
+
execute(args: {
|
|
16
|
+
command: string;
|
|
17
|
+
background?: boolean;
|
|
18
|
+
}, ctx: ToolContext): Promise<string>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.bashTool = void 0;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const bashTool = (sessionManager, projectId, worktree, pluginCtx, repoPath) => ({
|
|
10
|
+
description: 'Executes shell commands in a Daytona sandbox',
|
|
11
|
+
args: {
|
|
12
|
+
command: zod_1.z.string(),
|
|
13
|
+
background: zod_1.z.boolean().optional(),
|
|
14
|
+
},
|
|
15
|
+
async execute(args, ctx) {
|
|
16
|
+
const sessionId = ctx.sessionID;
|
|
17
|
+
const sandbox = await sessionManager.getSandbox(sessionId, projectId, worktree, pluginCtx);
|
|
18
|
+
if (args.background) {
|
|
19
|
+
const execSessionId = `exec-session-${sessionId}`;
|
|
20
|
+
try {
|
|
21
|
+
await sandbox.process.getSession(execSessionId);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
await sandbox.process.createSession(execSessionId);
|
|
25
|
+
}
|
|
26
|
+
await sandbox.process.executeSessionCommand(execSessionId, {
|
|
27
|
+
command: `cd ${repoPath}`,
|
|
28
|
+
});
|
|
29
|
+
const result = await sandbox.process.executeSessionCommand(execSessionId, {
|
|
30
|
+
command: args.command,
|
|
31
|
+
runAsync: true,
|
|
32
|
+
});
|
|
33
|
+
return `Command started in background (cmdId: ${result.cmdId})`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const result = await sandbox.process.executeCommand(args.command, repoPath);
|
|
37
|
+
return `Exit code: ${result.exitCode}\n${result.result}`;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
exports.bashTool = bashTool;
|
|
42
|
+
//# sourceMappingURL=bash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/tools/bash.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAKhB,MAAM,QAAQ,GAAG,CACtB,cAAqC,EACrC,SAAiB,EACjB,QAAgB,EAChB,SAAsB,EACtB,QAAgB,EAChB,EAA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AC,CAAA;AApCW,QAAA,QAAQ,YAoCnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
7
|
+
import type { ToolContext } from '@opencode-ai/plugin/tool';
|
|
8
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
9
|
+
export declare const editTool: (sessionManager: DaytonaSessionManager, projectId: string, worktree: string, pluginCtx: PluginInput) => {
|
|
10
|
+
description: string;
|
|
11
|
+
args: {
|
|
12
|
+
filePath: z.ZodString;
|
|
13
|
+
oldString: z.ZodString;
|
|
14
|
+
newString: z.ZodString;
|
|
15
|
+
};
|
|
16
|
+
execute(args: {
|
|
17
|
+
filePath: string;
|
|
18
|
+
oldString: string;
|
|
19
|
+
newString: string;
|
|
20
|
+
}, ctx: ToolContext): Promise<string>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.editTool = void 0;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const editTool = (sessionManager, projectId, worktree, pluginCtx) => ({
|
|
10
|
+
description: 'Replaces text in a file in Daytona sandbox',
|
|
11
|
+
args: {
|
|
12
|
+
filePath: zod_1.z.string(),
|
|
13
|
+
oldString: zod_1.z.string(),
|
|
14
|
+
newString: zod_1.z.string(),
|
|
15
|
+
},
|
|
16
|
+
async execute(args, ctx) {
|
|
17
|
+
const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree, pluginCtx);
|
|
18
|
+
const buffer = await sandbox.fs.downloadFile(args.filePath);
|
|
19
|
+
const decoder = new TextDecoder();
|
|
20
|
+
const content = decoder.decode(buffer);
|
|
21
|
+
const newContent = content.replace(args.oldString, args.newString);
|
|
22
|
+
await sandbox.fs.uploadFile(Buffer.from(newContent), args.filePath);
|
|
23
|
+
return `Edited ${args.filePath}`;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
exports.editTool = editTool;
|
|
27
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/tools/edit.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAKhB,MAAM,QAAQ,GAAG,CACtB,cAAqC,EACrC,SAAiB,EACjB,QAAgB,EAChB,SAAsB,EACtB,EAAE,CAAC,CAAC;IACJ,WAAW,EAAE,4CAA4C;IACzD,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;QACpB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;KACtB;IACD,KAAK,CAAC,OAAO,CAAC,IAAgE,EAAE,GAAgB;QAC9F,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC9F,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC3D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;QACjC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACtC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAClE,MAAM,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QACnE,OAAO,UAAU,IAAI,CAAC,QAAQ,EAAE,CAAA;IAClC,CAAC;CACF,CAAC,CAAA;AArBW,QAAA,QAAQ,YAqBnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
7
|
+
import type { ToolContext } from '@opencode-ai/plugin/tool';
|
|
8
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
9
|
+
export declare const getPreviewURLTool: (sessionManager: DaytonaSessionManager, projectId: string, worktree: string, pluginCtx: PluginInput) => {
|
|
10
|
+
description: string;
|
|
11
|
+
args: {
|
|
12
|
+
port: z.ZodNumber;
|
|
13
|
+
};
|
|
14
|
+
execute(args: {
|
|
15
|
+
port: number;
|
|
16
|
+
}, ctx: ToolContext): Promise<string>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getPreviewURLTool = void 0;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const getPreviewURLTool = (sessionManager, projectId, worktree, pluginCtx) => ({
|
|
10
|
+
description: 'Gets a preview URL for the Daytona sandbox',
|
|
11
|
+
args: {
|
|
12
|
+
port: zod_1.z.number(),
|
|
13
|
+
},
|
|
14
|
+
async execute(args, ctx) {
|
|
15
|
+
const sandbox = await sessionManager.getSandbox(ctx.sessionID, projectId, worktree, pluginCtx);
|
|
16
|
+
const previewLink = await sandbox.getPreviewLink(args.port);
|
|
17
|
+
return `Sandbox Preview URL: ${previewLink.url}`;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
exports.getPreviewURLTool = getPreviewURLTool;
|
|
21
|
+
//# sourceMappingURL=get-preview-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-preview-url.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/tools/get-preview-url.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AAKhB,MAAM,iBAAiB,GAAG,CAC/B,cAAqC,EACrC,SAAiB,EACjB,QAAgB,EAChB,SAAsB,EACtB,EAAE,CAAC,CAAC;IACJ,WAAW,EAAE,4CAA4C;IACzD,IAAI,EAAE;QACJ,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;KACjB;IACD,KAAK,CAAC,OAAO,CAAC,IAAsB,EAAE,GAAgB;QACpD,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;QAC9F,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3D,OAAO,wBAAwB,WAAW,CAAC,GAAG,EAAE,CAAA;IAClD,CAAC;CACF,CAAC,CAAA;AAfW,QAAA,iBAAiB,qBAe5B"}
|