@daytona/opencode 0.0.0-dev
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 +134 -0
- package/.opencode/plugin/daytona/index.js +48 -0
- package/.opencode/plugin/daytona/index.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.d.ts +132 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.js +19 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/session-events.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/session-events.js +55 -0
- package/.opencode/plugin/daytona/plugins/session-events.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/system-transform.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/system-transform.js +24 -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 +15 -0
- package/.opencode/plugin/index.js.map +1 -0
- package/README.md +238 -0
- package/package.json +56 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 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,CAA0B;IACpC,OAAO,CAAgB;IACvB,OAAO,CAAS;IAChB,QAAQ,CAAQ;IAChB,QAAQ,CAAQ;IAChB,MAAM,CAAQ;IACd,WAAW,CAAQ;IACpC,mEAAmE;IAClD,UAAU,CAAQ;IAEnC,YAAY,OAAgB,EAAE,QAAgB,EAAE,QAAgB,EAAE,YAAoB;QACpF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CA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KAAK,CAAA;YACd,CAAC;YAED,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAA;YAClC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAA;YAErD,oDAAoD;YACpD,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,OAAO,KAAK,CAAA;YACd,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;YAErC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YAC9F,aAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,gBAAgB;gBACvB,OAAO,EAAE,+BAA+B,IAAI,CAAC,WAAW,2BAA2B;gBACnF,OAAO,EAAE,SAAS;aACnB,CAAC,CAAA;YACF,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,aAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,aAAa;gBACpB,OAAO,EAAE,GAAG,EAAE,OAAO,IAAI,iCAAiC;gBAC1D,OAAO,EAAE,OAAO;aACjB,CAAC,CAAA;YACF,eAAM,CAAC,KAAK,CAAC,8BAA8B,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC,CAAA;YACrE,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;CACF;AA5HD,8CA4HC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
6
|
+
export type { EventSessionDeleted, LogLevel, SandboxInfo, SessionInfo, ProjectSessionData } from './core/types';
|
|
7
|
+
declare function daytonaPlugin(ctx: PluginInput): Promise<{
|
|
8
|
+
tool: {
|
|
9
|
+
bash: {
|
|
10
|
+
description: string;
|
|
11
|
+
args: {
|
|
12
|
+
command: import("zod").ZodString;
|
|
13
|
+
background: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
14
|
+
};
|
|
15
|
+
execute(args: {
|
|
16
|
+
command: string;
|
|
17
|
+
background?: boolean;
|
|
18
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
read: {
|
|
21
|
+
description: string;
|
|
22
|
+
args: {
|
|
23
|
+
filePath: import("zod").ZodString;
|
|
24
|
+
};
|
|
25
|
+
execute(args: {
|
|
26
|
+
filePath: string;
|
|
27
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
28
|
+
};
|
|
29
|
+
write: {
|
|
30
|
+
description: string;
|
|
31
|
+
args: {
|
|
32
|
+
filePath: import("zod").ZodString;
|
|
33
|
+
content: import("zod").ZodString;
|
|
34
|
+
};
|
|
35
|
+
execute(args: {
|
|
36
|
+
filePath: string;
|
|
37
|
+
content: string;
|
|
38
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
39
|
+
};
|
|
40
|
+
edit: {
|
|
41
|
+
description: string;
|
|
42
|
+
args: {
|
|
43
|
+
filePath: import("zod").ZodString;
|
|
44
|
+
oldString: import("zod").ZodString;
|
|
45
|
+
newString: import("zod").ZodString;
|
|
46
|
+
};
|
|
47
|
+
execute(args: {
|
|
48
|
+
filePath: string;
|
|
49
|
+
oldString: string;
|
|
50
|
+
newString: string;
|
|
51
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
52
|
+
};
|
|
53
|
+
multiedit: {
|
|
54
|
+
description: string;
|
|
55
|
+
args: {
|
|
56
|
+
filePath: import("zod").ZodString;
|
|
57
|
+
edits: import("zod").ZodArray<import("zod").ZodObject<{
|
|
58
|
+
oldString: import("zod").ZodString;
|
|
59
|
+
newString: import("zod").ZodString;
|
|
60
|
+
}, import("zod/v4/core").$strip>>;
|
|
61
|
+
};
|
|
62
|
+
execute(args: {
|
|
63
|
+
filePath: string;
|
|
64
|
+
edits: Array<{
|
|
65
|
+
oldString: string;
|
|
66
|
+
newString: string;
|
|
67
|
+
}>;
|
|
68
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
69
|
+
};
|
|
70
|
+
patch: {
|
|
71
|
+
description: string;
|
|
72
|
+
args: {
|
|
73
|
+
patchText: import("zod").ZodString;
|
|
74
|
+
};
|
|
75
|
+
execute(args: {
|
|
76
|
+
filePath: string;
|
|
77
|
+
oldSnippet: string;
|
|
78
|
+
newSnippet: string;
|
|
79
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
80
|
+
};
|
|
81
|
+
ls: {
|
|
82
|
+
description: string;
|
|
83
|
+
args: {
|
|
84
|
+
dirPath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
85
|
+
};
|
|
86
|
+
execute(args: {
|
|
87
|
+
dirPath?: string;
|
|
88
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
89
|
+
};
|
|
90
|
+
glob: {
|
|
91
|
+
description: string;
|
|
92
|
+
args: {
|
|
93
|
+
pattern: import("zod").ZodString;
|
|
94
|
+
};
|
|
95
|
+
execute(args: {
|
|
96
|
+
pattern: string;
|
|
97
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
98
|
+
};
|
|
99
|
+
grep: {
|
|
100
|
+
description: string;
|
|
101
|
+
args: {
|
|
102
|
+
pattern: import("zod").ZodString;
|
|
103
|
+
};
|
|
104
|
+
execute(args: {
|
|
105
|
+
pattern: string;
|
|
106
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
107
|
+
};
|
|
108
|
+
lsp: {
|
|
109
|
+
description: string;
|
|
110
|
+
args: {
|
|
111
|
+
op: import("zod").ZodString;
|
|
112
|
+
filePath: import("zod").ZodString;
|
|
113
|
+
line: import("zod").ZodNumber;
|
|
114
|
+
};
|
|
115
|
+
execute(args: {
|
|
116
|
+
op: string;
|
|
117
|
+
filePath: string;
|
|
118
|
+
line: number;
|
|
119
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
120
|
+
};
|
|
121
|
+
getPreviewURL: {
|
|
122
|
+
description: string;
|
|
123
|
+
args: {
|
|
124
|
+
port: import("zod").ZodNumber;
|
|
125
|
+
};
|
|
126
|
+
execute(args: {
|
|
127
|
+
port: number;
|
|
128
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
event: (args: any) => Promise<void>;
|
|
132
|
+
'experimental.chat.system.transform': (input: import("./core/types").ExperimentalChatSystemTransformInput, output: import("./core/types").ExperimentalChatSystemTransformOutput) => Promise<void>;
|
|
133
|
+
}>;
|
|
134
|
+
export default daytonaPlugin;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
/**
|
|
8
|
+
* OpenCode Plugin: Daytona Sandbox Integration
|
|
9
|
+
*
|
|
10
|
+
* OpenCode plugins extend the AI coding assistant by adding custom tools, handling events,
|
|
11
|
+
* and modifying behavior. Plugins are TypeScript/JavaScript modules that export functions
|
|
12
|
+
* which return hooks for various lifecycle events.
|
|
13
|
+
*
|
|
14
|
+
* This plugin integrates Daytona sandboxes with OpenCode, providing isolated development
|
|
15
|
+
* environments for each session. It adds custom tools for file operations, command execution,
|
|
16
|
+
* and search within sandboxes, and automatically cleans up resources when sessions end.
|
|
17
|
+
*
|
|
18
|
+
* Learn more: https://opencode.ai/docs/plugins/
|
|
19
|
+
*
|
|
20
|
+
* Daytona Sandbox Integration Tools
|
|
21
|
+
*
|
|
22
|
+
* Requires:
|
|
23
|
+
* - npm install @daytona/sdk
|
|
24
|
+
* - Environment: DAYTONA_API_KEY
|
|
25
|
+
*/
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
const xdg_basedir_1 = require("xdg-basedir");
|
|
28
|
+
const logger_1 = require("./core/logger");
|
|
29
|
+
const session_manager_1 = require("./core/session-manager");
|
|
30
|
+
const toast_1 = require("./core/toast");
|
|
31
|
+
const custom_tools_1 = require("./plugins/custom-tools");
|
|
32
|
+
const session_events_1 = require("./plugins/session-events");
|
|
33
|
+
const system_transform_1 = require("./plugins/system-transform");
|
|
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
|
+
async function daytonaPlugin(ctx) {
|
|
40
|
+
toast_1.toast.initialize(ctx.client?.tui);
|
|
41
|
+
return {
|
|
42
|
+
tool: await (0, custom_tools_1.customTools)(ctx, sessionManager),
|
|
43
|
+
event: await (0, session_events_1.eventHandlers)(ctx, sessionManager, REPO_PATH),
|
|
44
|
+
'experimental.chat.system.transform': await (0, system_transform_1.systemPromptTransform)(ctx, REPO_PATH),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.default = daytonaPlugin;
|
|
48
|
+
//# 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;AAErC,0CAA8C;AAC9C,4DAA8D;AAC9D,wCAAoC;AACpC,yDAAoD;AACpD,6DAAwD;AACxD,iEAAkE;AAIlE,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,KAAK,UAAU,aAAa,CAAC,GAAgB;IAC3C,aAAK,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACjC,OAAO;QACL,IAAI,EAAE,MAAM,IAAA,0BAAW,EAAC,GAAG,EAAE,cAAc,CAAC;QAC5C,KAAK,EAAE,MAAM,IAAA,8BAAa,EAAC,GAAG,EAAE,cAAc,EAAE,SAAS,CAAC;QAC1D,oCAAoC,EAAE,MAAM,IAAA,wCAAqB,EAAC,GAAG,EAAE,SAAS,CAAC;KAClF,CAAA;AACH,CAAC;AAED,kBAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
6
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
7
|
+
/**
|
|
8
|
+
* Custom tools for Daytona sandbox: file ops, command execution, search.
|
|
9
|
+
*/
|
|
10
|
+
export declare function customTools(ctx: PluginInput, sessionManager: DaytonaSessionManager): Promise<{
|
|
11
|
+
bash: {
|
|
12
|
+
description: string;
|
|
13
|
+
args: {
|
|
14
|
+
command: import("zod").ZodString;
|
|
15
|
+
background: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
16
|
+
};
|
|
17
|
+
execute(args: {
|
|
18
|
+
command: string;
|
|
19
|
+
background?: boolean;
|
|
20
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
21
|
+
};
|
|
22
|
+
read: {
|
|
23
|
+
description: string;
|
|
24
|
+
args: {
|
|
25
|
+
filePath: import("zod").ZodString;
|
|
26
|
+
};
|
|
27
|
+
execute(args: {
|
|
28
|
+
filePath: string;
|
|
29
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
30
|
+
};
|
|
31
|
+
write: {
|
|
32
|
+
description: string;
|
|
33
|
+
args: {
|
|
34
|
+
filePath: import("zod").ZodString;
|
|
35
|
+
content: import("zod").ZodString;
|
|
36
|
+
};
|
|
37
|
+
execute(args: {
|
|
38
|
+
filePath: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
41
|
+
};
|
|
42
|
+
edit: {
|
|
43
|
+
description: string;
|
|
44
|
+
args: {
|
|
45
|
+
filePath: import("zod").ZodString;
|
|
46
|
+
oldString: import("zod").ZodString;
|
|
47
|
+
newString: import("zod").ZodString;
|
|
48
|
+
};
|
|
49
|
+
execute(args: {
|
|
50
|
+
filePath: string;
|
|
51
|
+
oldString: string;
|
|
52
|
+
newString: string;
|
|
53
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
54
|
+
};
|
|
55
|
+
multiedit: {
|
|
56
|
+
description: string;
|
|
57
|
+
args: {
|
|
58
|
+
filePath: import("zod").ZodString;
|
|
59
|
+
edits: import("zod").ZodArray<import("zod").ZodObject<{
|
|
60
|
+
oldString: import("zod").ZodString;
|
|
61
|
+
newString: import("zod").ZodString;
|
|
62
|
+
}, import("zod/v4/core").$strip>>;
|
|
63
|
+
};
|
|
64
|
+
execute(args: {
|
|
65
|
+
filePath: string;
|
|
66
|
+
edits: Array<{
|
|
67
|
+
oldString: string;
|
|
68
|
+
newString: string;
|
|
69
|
+
}>;
|
|
70
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
71
|
+
};
|
|
72
|
+
patch: {
|
|
73
|
+
description: string;
|
|
74
|
+
args: {
|
|
75
|
+
patchText: import("zod").ZodString;
|
|
76
|
+
};
|
|
77
|
+
execute(args: {
|
|
78
|
+
filePath: string;
|
|
79
|
+
oldSnippet: string;
|
|
80
|
+
newSnippet: string;
|
|
81
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
82
|
+
};
|
|
83
|
+
ls: {
|
|
84
|
+
description: string;
|
|
85
|
+
args: {
|
|
86
|
+
dirPath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
87
|
+
};
|
|
88
|
+
execute(args: {
|
|
89
|
+
dirPath?: string;
|
|
90
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
91
|
+
};
|
|
92
|
+
glob: {
|
|
93
|
+
description: string;
|
|
94
|
+
args: {
|
|
95
|
+
pattern: import("zod").ZodString;
|
|
96
|
+
};
|
|
97
|
+
execute(args: {
|
|
98
|
+
pattern: string;
|
|
99
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
100
|
+
};
|
|
101
|
+
grep: {
|
|
102
|
+
description: string;
|
|
103
|
+
args: {
|
|
104
|
+
pattern: import("zod").ZodString;
|
|
105
|
+
};
|
|
106
|
+
execute(args: {
|
|
107
|
+
pattern: string;
|
|
108
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
109
|
+
};
|
|
110
|
+
lsp: {
|
|
111
|
+
description: string;
|
|
112
|
+
args: {
|
|
113
|
+
op: import("zod").ZodString;
|
|
114
|
+
filePath: import("zod").ZodString;
|
|
115
|
+
line: import("zod").ZodNumber;
|
|
116
|
+
};
|
|
117
|
+
execute(args: {
|
|
118
|
+
op: string;
|
|
119
|
+
filePath: string;
|
|
120
|
+
line: number;
|
|
121
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
122
|
+
};
|
|
123
|
+
getPreviewURL: {
|
|
124
|
+
description: string;
|
|
125
|
+
args: {
|
|
126
|
+
port: import("zod").ZodNumber;
|
|
127
|
+
};
|
|
128
|
+
execute(args: {
|
|
129
|
+
port: number;
|
|
130
|
+
}, ctx: import("@opencode-ai/plugin/tool", { with: { "resolution-mode": "import" } }).ToolContext): Promise<string>;
|
|
131
|
+
};
|
|
132
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.customTools = customTools;
|
|
8
|
+
const tools_1 = require("../tools");
|
|
9
|
+
const logger_1 = require("../core/logger");
|
|
10
|
+
/**
|
|
11
|
+
* Custom tools for Daytona sandbox: file ops, command execution, search.
|
|
12
|
+
*/
|
|
13
|
+
async function customTools(ctx, sessionManager) {
|
|
14
|
+
logger_1.logger.info('OpenCode started with Daytona plugin');
|
|
15
|
+
const projectId = ctx.project.id;
|
|
16
|
+
const worktree = ctx.project.worktree;
|
|
17
|
+
return (0, tools_1.createDaytonaTools)(sessionManager, projectId, worktree, ctx);
|
|
18
|
+
}
|
|
19
|
+
//# 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;;AAUH,kCAKC;AAZD,oCAA6C;AAC7C,2CAAuC;AAGvC;;GAEG;AACI,KAAK,UAAU,WAAW,CAAC,GAAgB,EAAE,cAAqC;IACvF,eAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;IACnD,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAA;IACrC,OAAO,IAAA,0BAAkB,EAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
6
|
+
import type { DaytonaSessionManager } from '../core/session-manager';
|
|
7
|
+
/**
|
|
8
|
+
* Handles OpenCode session events.
|
|
9
|
+
*/
|
|
10
|
+
export declare function eventHandlers(ctx: PluginInput, sessionManager: DaytonaSessionManager, repoPath: string): Promise<(args: any) => Promise<void>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.eventHandlers = eventHandlers;
|
|
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
|
+
* Handles OpenCode session events.
|
|
14
|
+
*/
|
|
15
|
+
async function eventHandlers(ctx, sessionManager, repoPath) {
|
|
16
|
+
const projectId = ctx.project.id;
|
|
17
|
+
const worktree = ctx.project.worktree;
|
|
18
|
+
return async (args) => {
|
|
19
|
+
const event = args.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({ title: 'Session deleted', message: 'Sandbox deleted successfully.', variant: 'success' });
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
toast_1.toast.show({ title: 'Delete failed', message: err?.message || 'Failed to delete sandbox.', variant: 'error' });
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (event.type === types_1.EVENT_TYPE_SESSION_IDLE) {
|
|
32
|
+
const sessionId = event.properties.sessionID;
|
|
33
|
+
const start = Date.now();
|
|
34
|
+
try {
|
|
35
|
+
const sandbox = await sessionManager.getSandbox(sessionId, projectId, worktree, ctx);
|
|
36
|
+
const branchNumber = sessionManager.getBranchNumberForSandbox(projectId, sandbox.id);
|
|
37
|
+
if (!branchNumber)
|
|
38
|
+
return;
|
|
39
|
+
const sessionGit = new session_git_manager_1.SessionGitManager(sandbox, repoPath, worktree, branchNumber);
|
|
40
|
+
const didSync = await sessionGit.autoCommitAndPull(ctx);
|
|
41
|
+
logger_1.logger.info(`[idle] done sessionId=${sessionId} sandboxId=${sandbox.id} synced=${didSync} in ${Date.now() - start}ms`);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
logger_1.logger.error(`[idle] error sessionId=${sessionId} in ${Date.now() - start}ms: ${err}`);
|
|
45
|
+
toast_1.toast.show({
|
|
46
|
+
title: 'Auto-commit error',
|
|
47
|
+
message: err?.message || 'Failed to auto-commit and pull.',
|
|
48
|
+
variant: 'error',
|
|
49
|
+
});
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=session-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-events.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/plugins/session-events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,sCAqCC;AA9CD,oEAA8D;AAC9D,yCAA6G;AAC7G,yCAAqC;AACrC,2CAAuC;AAGvC;;GAEG;AACI,KAAK,UAAU,aAAa,CAAC,GAAgB,EAAE,cAAqC,EAAE,QAAgB;IAC3G,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAA;IACrC,OAAO,KAAK,EAAE,IAAS,EAAE,EAAE;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,kCAA0B,EAAE,CAAC;YAC9C,MAAM,SAAS,GAAI,KAA6B,CAAC,UAAU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;YACH,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,eAAM,CAAC,KAAK,CAAC,0BAA0B,SAAS,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,GAAG,EAAE,CAAC,CAAA;gBACtF,aAAK,CAAC,IAAI,CAAC;oBACT,KAAK,EAAE,mBAAmB;oBAC1B,OAAO,EAAE,GAAG,EAAE,OAAO,IAAI,iCAAiC;oBAC1D,OAAO,EAAE,OAAO;iBACjB,CAAC,CAAA;gBACF,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
6
|
+
import type { ExperimentalChatSystemTransformInput, ExperimentalChatSystemTransformOutput } from '../core/types';
|
|
7
|
+
/**
|
|
8
|
+
* Adds Daytona-specific instructions to the system prompt.
|
|
9
|
+
*/
|
|
10
|
+
export declare function systemPromptTransform(ctx: PluginInput, repoPath: string): Promise<(input: ExperimentalChatSystemTransformInput, output: ExperimentalChatSystemTransformOutput) => Promise<void>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.systemPromptTransform = systemPromptTransform;
|
|
8
|
+
/**
|
|
9
|
+
* Adds Daytona-specific instructions to the system prompt.
|
|
10
|
+
*/
|
|
11
|
+
async function systemPromptTransform(ctx, repoPath) {
|
|
12
|
+
return async (input, output) => {
|
|
13
|
+
output.system.push([
|
|
14
|
+
'## Daytona Sandbox Integration',
|
|
15
|
+
'This session is integrated with a Daytona sandbox.',
|
|
16
|
+
`The main project repository is located at: ${repoPath}.`,
|
|
17
|
+
'Bash commands will run in this directory.',
|
|
18
|
+
'Put all projects in the project directory. Do NOT try to use the current working directory of the host system.',
|
|
19
|
+
"When executing long-running commands, use the 'background' option to run them asynchronously.",
|
|
20
|
+
'Before showing a preview URL, ensure the server is running in the sandbox on that port.',
|
|
21
|
+
].join('\n'));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# 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;;AAQH,sDAcC;AAjBD;;GAEG;AACI,KAAK,UAAU,qBAAqB,CAAC,GAAgB,EAAE,QAAgB;IAC5E,OAAO,KAAK,EAAE,KAA2C,EAAE,MAA6C,EAAE,EAAE;QAC1G,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB;YACE,gCAAgC;YAChC,oDAAoD;YACpD,8CAA8C,QAAQ,GAAG;YACzD,2CAA2C;YAC3C,gHAAgH;YAChH,+FAA+F;YAC/F,yFAAyF;SAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 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 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
|